Commit 94611b11 authored by Alexandre Lision's avatar Alexandre Lision Committed by Alexandre Lision

Remove Client abstraction layer

Refs #65862

Change-Id: I43cee3d565f769a1c463e0f2e2195c92429a4800
parent 05ae6379
......@@ -150,7 +150,7 @@ void Account::setRegistrationState(RegistrationState state)
if (state != registrationState_) {
registrationState_ = state;
// Notify the client
ConfigurationManager *c(Manager::instance().getClient()->getConfigurationManager());
ConfigurationManager *c(Manager::instance().getConfigurationManager());
c->registrationStateChanged(accountID_, static_cast<int32_t>(registrationState_));
c->volatileAccountDetailsChanged(accountID_, getVolatileAccountDetails());
}
......
......@@ -3,8 +3,7 @@ include $(top_srcdir)/globals.mak
noinst_LTLIBRARIES = libclient.la
noinst_HEADERS = callmanager.h \
configurationmanager.h \
client.h
configurationmanager.h
PRESENCE_SRC = presencemanager.cpp
noinst_HEADERS += presencemanager.h
......@@ -14,8 +13,7 @@ VIDEO_SRC = videomanager.cpp
noinst_HEADERS += videomanager.h
endif
libclient_la_SOURCES = client.cpp \
callmanager.cpp \
libclient_la_SOURCES = callmanager.cpp \
configurationmanager.cpp \
$(PRESENCE_SRC) \
$(VIDEO_SRC)
......
/*
* Copyright (C) 2004-2015 Savoir-Faire Linux Inc.
* Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "client.h"
#include "callmanager.h"
#include "configurationmanager.h"
#include "presencemanager.h"
#ifdef RING_VIDEO
#include "videomanager.h"
#endif // RING_VIDEO
namespace ring {
Client::Client() :
callManager_(new CallManager)
, configurationManager_(new ConfigurationManager)
, presenceManager_(new PresenceManager)
#ifdef RING_VIDEO
, videoManager_(new VideoManager)
#endif
#ifdef USE_NETWORKMANAGER
, networkManager_(0)
#endif
{}
Client::~Client()
{
#ifdef USE_NETWORKMANAGER
delete networkManager_;
#endif
#ifdef RING_VIDEO
delete videoManager_;
#endif
delete configurationManager_;
delete presenceManager_;
delete callManager_;
}
CallManager * Client::getCallManager()
{
return callManager_;
}
ConfigurationManager * Client::getConfigurationManager()
{
return configurationManager_;
}
PresenceManager * Client::getPresenceManager()
{
return presenceManager_;
}
#ifdef RING_VIDEO
VideoManager * Client::getVideoManager()
{
return videoManager_;
}
#endif
} // namespace ring
/*
* Copyright (C) 2004-2015 Savoir-Faire Linux Inc.
* Author: Pierre-Luc Beaudoin <pierre-luc.beaudoin@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef __CLIENT_H__
#define __CLIENT_H__
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "noncopyable.h"
namespace ring {
class ConfigurationManager;
class CallManager;
class NetworkManager;
class Instance;
class PresenceManager;
#ifdef RING_VIDEO
class VideoManager;
#endif
class Client {
public:
Client();
~Client();
CallManager * getCallManager();
ConfigurationManager * getConfigurationManager();
PresenceManager * getPresenceManager();
#ifdef RING_VIDEO
VideoManager* getVideoManager();
#endif
private:
NON_COPYABLE(Client);
CallManager* callManager_;
ConfigurationManager* configurationManager_;
PresenceManager* presenceManager_;
#ifdef RING_VIDEO
VideoManager *videoManager_;
#endif
#if USE_NETWORKMANAGER
NetworkManager* networkManager_;
#endif
};
} // namespace ring
#endif
......@@ -73,6 +73,7 @@
#include "client/configurationmanager.h"
#include "client/callmanager.h"
#include "client/presencemanager.h"
#ifdef RING_VIDEO
#include "client/videomanager.h"
......@@ -158,8 +159,16 @@ ManagerImpl::ManagerImpl() :
pluginManager_(new PluginManager)
, preferences(), voipPreferences(),
hookPreference(), audioPreference(), shortcutPreferences(),
hasTriedToRegister_(false), audioCodecFactory(*pluginManager_), client_(),
currentCallMutex_(), dtmfKey_(), dtmfBuf_(0, AudioFormat::MONO()),
hasTriedToRegister_(false), audioCodecFactory(*pluginManager_),
callManager_(new CallManager), configurationManager_(new ConfigurationManager),
presenceManager_(new PresenceManager)
#ifdef RING_VIDEO
, videoManager_(new VideoManager)
#endif
#ifdef USE_NETWORKMANAGER
, networkManager_(0)
#endif
, currentCallMutex_(), dtmfKey_(), dtmfBuf_(0, AudioFormat::MONO()),
toneMutex_(), telephoneTone_(), audiofile_(), audioLayerMutex_(),
waitingCalls_(), waitingCallsMutex_(), path_()
, ringbufferpool_(new RingBufferPool)
......@@ -176,6 +185,32 @@ ManagerImpl::ManagerImpl() :
ManagerImpl::~ManagerImpl()
{}
CallManager*
ManagerImpl::getCallManager()
{
return callManager_.get();
}
ConfigurationManager*
ManagerImpl::getConfigurationManager()
{
return configurationManager_.get();
}
PresenceManager*
ManagerImpl::getPresenceManager()
{
return presenceManager_.get();
}
#ifdef RING_VIDEO
VideoManager*
ManagerImpl::getVideoManager()
{
return videoManager_.get();
}
#endif
bool
ManagerImpl::parseConfiguration()
{
......@@ -493,7 +528,7 @@ ManagerImpl::answerCall(const std::string& call_id)
if (audioPreference.getIsAlwaysRecording())
toggleRecordingCall(call_id);
client_.getCallManager()->callStateChanged(call_id, "CURRENT");
getCallManager()->callStateChanged(call_id, "CURRENT");
return result;
}
......@@ -518,7 +553,7 @@ ManagerImpl::hangupCall(const std::string& callId)
stopTone();
RING_DBG("Send call state change (HUNGUP) for id %s", callId.c_str());
client_.getCallManager()->callStateChanged(callId, "HUNGUP");
getCallManager()->callStateChanged(callId, "HUNGUP");
/* We often get here when the call was hungup before being created */
auto call = getCallFromCallID(callId);
......@@ -609,7 +644,7 @@ ManagerImpl::onHoldCall(const std::string& callId)
if (current_call_id == callId)
unsetCurrentCall();
client_.getCallManager()->callStateChanged(callId, "HOLD");
getCallManager()->callStateChanged(callId, "HOLD");
return result;
}
......@@ -647,7 +682,7 @@ ManagerImpl::offHoldCall(const std::string& callId)
return false;
}
client_.getCallManager()->callStateChanged(callId, "UNHOLD");
getCallManager()->callStateChanged(callId, "UNHOLD");
if (isConferenceParticipant(callId))
switchCall(getCallFromCallID(call->getConfId()));
......@@ -682,13 +717,13 @@ ManagerImpl::transferCall(const std::string& callId, const std::string& to)
void
ManagerImpl::transferFailed()
{
client_.getCallManager()->transferFailed();
getCallManager()->transferFailed();
}
void
ManagerImpl::transferSucceeded()
{
client_.getCallManager()->transferSucceeded();
getCallManager()->transferSucceeded();
}
bool
......@@ -722,7 +757,7 @@ ManagerImpl::refuseCall(const std::string& id)
removeWaitingCall(id);
client_.getCallManager()->callStateChanged(id, "HUNGUP");
getCallManager()->callStateChanged(id, "HUNGUP");
// Disconnect streams
removeStream(*call);
......@@ -743,7 +778,7 @@ ManagerImpl::createConference(const std::string& id1, const std::string& id2)
// Add conference to map
conferenceMap_.insert(std::make_pair(conf->getConfID(), conf));
client_.getCallManager()->conferenceCreated(conf->getConfID());
getCallManager()->conferenceCreated(conf->getConfID());
return conf;
}
......@@ -765,7 +800,7 @@ ManagerImpl::removeConference(const std::string& conference_id)
return;
}
client_.getCallManager()->conferenceRemoved(conference_id);
getCallManager()->conferenceRemoved(conference_id);
// We now need to bind the audio to the remain participant
......@@ -825,7 +860,7 @@ ManagerImpl::holdConference(const std::string& id)
conf->setState(isRec ? Conference::HOLD_REC : Conference::HOLD);
client_.getCallManager()->conferenceChanged(conf->getConfID(), conf->getStateStr());
getCallManager()->conferenceChanged(conf->getConfID(), conf->getStateStr());
return true;
}
......@@ -858,7 +893,7 @@ ManagerImpl::unHoldConference(const std::string& id)
conf->setState(isRec ? Conference::ACTIVE_ATTACHED_REC : Conference::ACTIVE_ATTACHED);
client_.getCallManager()->conferenceChanged(conf->getConfID(), conf->getStateStr());
getCallManager()->conferenceChanged(conf->getConfID(), conf->getStateStr());
return true;
}
......@@ -988,7 +1023,7 @@ ManagerImpl::addMainParticipant(const std::string& conference_id)
else
RING_WARN("Invalid conference state while adding main participant");
client_.getCallManager()->conferenceChanged(conference_id, conf->getStateStr());
getCallManager()->conferenceChanged(conference_id, conf->getStateStr());
}
switchCall(getCallFromCallID(conference_id));
......@@ -1132,7 +1167,7 @@ ManagerImpl::createConfFromParticipantList(const std::vector< std::string > &par
if (!callSuccess)
conf->remove(generatedCallID);
else {
client_.getCallManager()->newCallCreated(account, generatedCallID, tostr);
getCallManager()->newCallCreated(account, generatedCallID, tostr);
successCounter++;
}
}
......@@ -1140,7 +1175,7 @@ ManagerImpl::createConfFromParticipantList(const std::vector< std::string > &par
// Create the conference if and only if at least 2 calls have been successfully created
if (successCounter >= 2) {
conferenceMap_[conf->getConfID()] = conf;
client_.getCallManager()->conferenceCreated(conf->getConfID());
getCallManager()->conferenceCreated(conf->getConfID());
conf->setRecordingFormat(ringbufferpool_->getInternalAudioFormat());
}
}
......@@ -1202,7 +1237,7 @@ ManagerImpl::detachParticipant(const std::string& call_id)
else
RING_WARN("Undefined behavior, invalid conference state in detach participant");
client_.getCallManager()->conferenceChanged(conf->getConfID(),
getCallManager()->conferenceChanged(conf->getConfID(),
conf->getStateStr());
unsetCurrentCall();
......@@ -1236,7 +1271,7 @@ ManagerImpl::removeParticipant(const std::string& call_id)
removeStream(*call);
client_.getCallManager()->conferenceChanged(conf->getConfID(), conf->getStateStr());
getCallManager()->conferenceChanged(conf->getConfID(), conf->getStateStr());
processRemainingParticipants(*conf);
}
......@@ -1541,7 +1576,7 @@ ManagerImpl::incomingCall(Call &call, const std::string& accountId)
std::string from("<" + number + ">");
client_.getCallManager()->incomingCall(accountId, callID, call.getDisplayName() + " " + from);
getCallManager()->incomingCall(accountId, callID, call.getDisplayName() + " " + from);
}
//THREAD=VoIP
......@@ -1572,10 +1607,10 @@ ManagerImpl::incomingMessage(const std::string& callID,
}
// in case of a conference we must notify client using conference id
client_.getCallManager()->incomingMessage(conf->getConfID(), from, message);
getCallManager()->incomingMessage(conf->getConfID(), from, message);
} else
client_.getCallManager()->incomingMessage(callID, from, message);
getCallManager()->incomingMessage(callID, from, message);
}
//THREAD=VoIP
......@@ -1664,7 +1699,7 @@ ManagerImpl::peerAnsweredCall(Call& call)
if (audioPreference.getIsAlwaysRecording())
toggleRecordingCall(call_id);
client_.getCallManager()->callStateChanged(call_id, "CURRENT");
getCallManager()->callStateChanged(call_id, "CURRENT");
}
//THREAD=VoIP Call=Outgoing
......@@ -1677,7 +1712,7 @@ ManagerImpl::peerRingingCall(Call& call)
if (isCurrentCall(call))
ringback();
client_.getCallManager()->callStateChanged(call_id, "RINGING");
getCallManager()->callStateChanged(call_id, "RINGING");
}
//THREAD=VoIP Call=Outgoing/Ingoing
......@@ -1698,7 +1733,7 @@ ManagerImpl::peerHungupCall(Call& call)
call.peerHungup();
saveHistory();
client_.getCallManager()->callStateChanged(call_id, "HUNGUP");
getCallManager()->callStateChanged(call_id, "HUNGUP");
checkAudio();
removeWaitingCall(call_id);
......@@ -1714,7 +1749,7 @@ ManagerImpl::callBusy(Call& call)
{
const auto call_id = call.getCallId();
client_.getCallManager()->callStateChanged(call_id, "BUSY");
getCallManager()->callStateChanged(call_id, "BUSY");
if (isCurrentCall(call)) {
playATone(Tone::TONE_BUSY);
......@@ -1731,7 +1766,7 @@ ManagerImpl::callFailure(Call& call)
{
const auto call_id = call.getCallId();
client_.getCallManager()->callStateChanged(call_id, "FAILURE");
getCallManager()->callStateChanged(call_id, "FAILURE");
if (isCurrentCall(call)) {
playATone(Tone::TONE_BUSY);
......@@ -1753,7 +1788,7 @@ void
ManagerImpl::startVoiceMessageNotification(const std::string& accountId,
int nb_msg)
{
client_.getCallManager()->voiceMailNotify(accountId, nb_msg);
getCallManager()->voiceMailNotify(accountId, nb_msg);
}
/**
......@@ -1800,7 +1835,7 @@ ManagerImpl::stopTone()
if (audiofile_) {
std::string filepath(audiofile_->getFilePath());
client_.getCallManager()->recordPlaybackStopped(filepath);
getCallManager()->recordPlaybackStopped(filepath);
audiofile_.reset();
}
}
......@@ -1893,7 +1928,7 @@ ManagerImpl::playRingtone(const std::string& accountID)
std::lock_guard<std::mutex> m(toneMutex_);
if (audiofile_) {
client_.getCallManager()->recordPlaybackStopped(audiofile_->getFilePath());
getCallManager()->recordPlaybackStopped(audiofile_->getFilePath());
audiofile_.reset();
}
......@@ -2112,8 +2147,8 @@ ManagerImpl::toggleRecordingCall(const std::string& id)
}
const bool result = rec->toggleRecording();
client_.getCallManager()->recordPlaybackFilepath(id, rec->getFilename());
client_.getCallManager()->recordingStateChanged(id, result);
getCallManager()->recordPlaybackFilepath(id, rec->getFilename());
getCallManager()->recordingStateChanged(id, result);
return result;
}
......@@ -2145,7 +2180,7 @@ ManagerImpl::startRecordedFilePlayback(const std::string& filepath)
std::lock_guard<std::mutex> m(toneMutex_);
if (audiofile_) {
client_.getCallManager()->recordPlaybackStopped(audiofile_->getFilePath());
getCallManager()->recordPlaybackStopped(audiofile_->getFilePath());
audiofile_.reset();
}
......@@ -2184,7 +2219,7 @@ void ManagerImpl::stopRecordedFilePlayback(const std::string& filepath)
std::lock_guard<std::mutex> m(toneMutex_);
audiofile_.reset();
}
client_.getCallManager()->recordPlaybackStopped(filepath);
getCallManager()->recordPlaybackStopped(filepath);
}
void ManagerImpl::setHistoryLimit(int days)
......@@ -2444,7 +2479,7 @@ ManagerImpl::setAccountDetails(const std::string& accountID,
account->doUnregister();
// Update account details to the client side
client_.getConfigurationManager()->accountsChanged();
getConfigurationManager()->accountsChanged();
});
}
......@@ -2489,7 +2524,7 @@ ManagerImpl::addAccount(const std::map<std::string, std::string>& details)
saveConfig();
client_.getConfigurationManager()->accountsChanged();
getConfigurationManager()->accountsChanged();
return newAccountID;
}
......@@ -2512,7 +2547,7 @@ void ManagerImpl::removeAccount(const std::string& accountID)
saveConfig();
client_.getConfigurationManager()->accountsChanged();
getConfigurationManager()->accountsChanged();
}
bool
......@@ -2710,7 +2745,7 @@ ManagerImpl::saveHistory()
if (!history_.save())
RING_ERR("Could not save history!");
else
client_.getConfigurationManager()->historyChanged();
getConfigurationManager()->historyChanged();
}
void
......@@ -2782,20 +2817,6 @@ ManagerImpl::getAudioDriver()
return audiodriver_;
}
Client*
ManagerImpl::getClient()
{
return &client_;
}
#ifdef RING_VIDEO
VideoManager *
ManagerImpl::getVideoManager()
{
return client_.getVideoManager();
}
#endif
std::shared_ptr<Call>
ManagerImpl::newOutgoingCall(const std::string& id,
const std::string& toUrl,
......
......@@ -49,8 +49,6 @@
#include <random>
#include <atomic>
#include "client/client.h"
#include "conference.h"
#include "account_factory.h"
......@@ -75,6 +73,12 @@ class PluginManager;
class AudioFile;
class DTMF;
class TelephoneTone;
class ConfigurationManager;
class PresenceManager;
class CallManager;
#ifdef RING_VIDEO
class VideoManager;
#endif
/** To send multiple string */
typedef std::list<std::string> TokenList;
......@@ -97,6 +101,13 @@ class ManagerImpl {
ManagerImpl();
~ManagerImpl();
std::unique_ptr<ConfigurationManager> configurationManager_;
std::unique_ptr<CallManager> callManager_;
std::unique_ptr<PresenceManager> presenceManager_;
#ifdef RING_VIDEO
std::unique_ptr<VideoManager> videoManager_;
#endif
/**
* General preferences configuration
*/
......@@ -784,8 +795,6 @@ class ManagerImpl {
*/
void playATone(Tone::TONEID toneId);
Client client_;
/** Current Call ID */
std::shared_ptr<Call> currentCall_ = nullptr;
......@@ -872,11 +881,10 @@ class ManagerImpl {
*/
bool hasCurrentCall() const;
/**
* Return the current Client
* @return A pointer to the Client instance
*/
Client* getClient();
CallManager* getCallManager();
ConfigurationManager* getConfigurationManager();
PresenceManager* getPresenceManager();
#ifdef RING_VIDEO
VideoManager * getVideoManager();
#endif
......
......@@ -103,18 +103,18 @@ void AlsaThread::initAudioLayer(void)
alsa_->is_capture_open_ = alsa_->openDevice(&alsa_->captureHandle_, pcmc, SND_PCM_STREAM_CAPTURE);