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) ...@@ -150,7 +150,7 @@ void Account::setRegistrationState(RegistrationState state)
if (state != registrationState_) { if (state != registrationState_) {
registrationState_ = state; registrationState_ = state;
// Notify the client // Notify the client
ConfigurationManager *c(Manager::instance().getClient()->getConfigurationManager()); ConfigurationManager *c(Manager::instance().getConfigurationManager());
c->registrationStateChanged(accountID_, static_cast<int32_t>(registrationState_)); c->registrationStateChanged(accountID_, static_cast<int32_t>(registrationState_));
c->volatileAccountDetailsChanged(accountID_, getVolatileAccountDetails()); c->volatileAccountDetailsChanged(accountID_, getVolatileAccountDetails());
} }
......
...@@ -3,8 +3,7 @@ include $(top_srcdir)/globals.mak ...@@ -3,8 +3,7 @@ include $(top_srcdir)/globals.mak
noinst_LTLIBRARIES = libclient.la noinst_LTLIBRARIES = libclient.la
noinst_HEADERS = callmanager.h \ noinst_HEADERS = callmanager.h \
configurationmanager.h \ configurationmanager.h
client.h
PRESENCE_SRC = presencemanager.cpp PRESENCE_SRC = presencemanager.cpp
noinst_HEADERS += presencemanager.h noinst_HEADERS += presencemanager.h
...@@ -14,8 +13,7 @@ VIDEO_SRC = videomanager.cpp ...@@ -14,8 +13,7 @@ VIDEO_SRC = videomanager.cpp
noinst_HEADERS += videomanager.h noinst_HEADERS += videomanager.h
endif endif
libclient_la_SOURCES = client.cpp \ libclient_la_SOURCES = callmanager.cpp \
callmanager.cpp \
configurationmanager.cpp \ configurationmanager.cpp \
$(PRESENCE_SRC) \ $(PRESENCE_SRC) \
$(VIDEO_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 @@ ...@@ -73,6 +73,7 @@
#include "client/configurationmanager.h" #include "client/configurationmanager.h"
#include "client/callmanager.h" #include "client/callmanager.h"
#include "client/presencemanager.h"
#ifdef RING_VIDEO #ifdef RING_VIDEO
#include "client/videomanager.h" #include "client/videomanager.h"
...@@ -158,8 +159,16 @@ ManagerImpl::ManagerImpl() : ...@@ -158,8 +159,16 @@ ManagerImpl::ManagerImpl() :
pluginManager_(new PluginManager) pluginManager_(new PluginManager)
, preferences(), voipPreferences(), , preferences(), voipPreferences(),
hookPreference(), audioPreference(), shortcutPreferences(), hookPreference(), audioPreference(), shortcutPreferences(),
hasTriedToRegister_(false), audioCodecFactory(*pluginManager_), client_(), hasTriedToRegister_(false), audioCodecFactory(*pluginManager_),
currentCallMutex_(), dtmfKey_(), dtmfBuf_(0, AudioFormat::MONO()), 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_(), toneMutex_(), telephoneTone_(), audiofile_(), audioLayerMutex_(),
waitingCalls_(), waitingCallsMutex_(), path_() waitingCalls_(), waitingCallsMutex_(), path_()
, ringbufferpool_(new RingBufferPool) , ringbufferpool_(new RingBufferPool)
...@@ -176,6 +185,32 @@ ManagerImpl::ManagerImpl() : ...@@ -176,6 +185,32 @@ ManagerImpl::ManagerImpl() :
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 bool
ManagerImpl::parseConfiguration() ManagerImpl::parseConfiguration()
{ {
...@@ -493,7 +528,7 @@ ManagerImpl::answerCall(const std::string& call_id) ...@@ -493,7 +528,7 @@ ManagerImpl::answerCall(const std::string& call_id)
if (audioPreference.getIsAlwaysRecording()) if (audioPreference.getIsAlwaysRecording())
toggleRecordingCall(call_id); toggleRecordingCall(call_id);
client_.getCallManager()->callStateChanged(call_id, "CURRENT"); getCallManager()->callStateChanged(call_id, "CURRENT");
return result; return result;
} }
...@@ -518,7 +553,7 @@ ManagerImpl::hangupCall(const std::string& callId) ...@@ -518,7 +553,7 @@ ManagerImpl::hangupCall(const std::string& callId)
stopTone(); stopTone();
RING_DBG("Send call state change (HUNGUP) for id %s", callId.c_str()); 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 */ /* We often get here when the call was hungup before being created */
auto call = getCallFromCallID(callId); auto call = getCallFromCallID(callId);
...@@ -609,7 +644,7 @@ ManagerImpl::onHoldCall(const std::string& callId) ...@@ -609,7 +644,7 @@ ManagerImpl::onHoldCall(const std::string& callId)
if (current_call_id == callId) if (current_call_id == callId)
unsetCurrentCall(); unsetCurrentCall();
client_.getCallManager()->callStateChanged(callId, "HOLD"); getCallManager()->callStateChanged(callId, "HOLD");
return result; return result;
} }
...@@ -647,7 +682,7 @@ ManagerImpl::offHoldCall(const std::string& callId) ...@@ -647,7 +682,7 @@ ManagerImpl::offHoldCall(const std::string& callId)
return false; return false;
} }
client_.getCallManager()->callStateChanged(callId, "UNHOLD"); getCallManager()->callStateChanged(callId, "UNHOLD");
if (isConferenceParticipant(callId)) if (isConferenceParticipant(callId))
switchCall(getCallFromCallID(call->getConfId())); switchCall(getCallFromCallID(call->getConfId()));
...@@ -682,13 +717,13 @@ ManagerImpl::transferCall(const std::string& callId, const std::string& to) ...@@ -682,13 +717,13 @@ ManagerImpl::transferCall(const std::string& callId, const std::string& to)
void void
ManagerImpl::transferFailed() ManagerImpl::transferFailed()
{ {
client_.getCallManager()->transferFailed(); getCallManager()->transferFailed();
} }
void void
ManagerImpl::transferSucceeded() ManagerImpl::transferSucceeded()
{ {
client_.getCallManager()->transferSucceeded(); getCallManager()->transferSucceeded();
} }
bool bool
...@@ -722,7 +757,7 @@ ManagerImpl::refuseCall(const std::string& id) ...@@ -722,7 +757,7 @@ ManagerImpl::refuseCall(const std::string& id)
removeWaitingCall(id); removeWaitingCall(id);
client_.getCallManager()->callStateChanged(id, "HUNGUP"); getCallManager()->callStateChanged(id, "HUNGUP");
// Disconnect streams // Disconnect streams
removeStream(*call); removeStream(*call);
...@@ -743,7 +778,7 @@ ManagerImpl::createConference(const std::string& id1, const std::string& id2) ...@@ -743,7 +778,7 @@ ManagerImpl::createConference(const std::string& id1, const std::string& id2)
// Add conference to map // Add conference to map
conferenceMap_.insert(std::make_pair(conf->getConfID(), conf)); conferenceMap_.insert(std::make_pair(conf->getConfID(), conf));
client_.getCallManager()->conferenceCreated(conf->getConfID()); getCallManager()->conferenceCreated(conf->getConfID());
return conf; return conf;
} }
...@@ -765,7 +800,7 @@ ManagerImpl::removeConference(const std::string& conference_id) ...@@ -765,7 +800,7 @@ ManagerImpl::removeConference(const std::string& conference_id)
return; return;
} }
client_.getCallManager()->conferenceRemoved(conference_id); getCallManager()->conferenceRemoved(conference_id);
// We now need to bind the audio to the remain participant // We now need to bind the audio to the remain participant
...@@ -825,7 +860,7 @@ ManagerImpl::holdConference(const std::string& id) ...@@ -825,7 +860,7 @@ ManagerImpl::holdConference(const std::string& id)
conf->setState(isRec ? Conference::HOLD_REC : Conference::HOLD); conf->setState(isRec ? Conference::HOLD_REC : Conference::HOLD);
client_.getCallManager()->conferenceChanged(conf->getConfID(), conf->getStateStr()); getCallManager()->conferenceChanged(conf->getConfID(), conf->getStateStr());
return true; return true;
} }
...@@ -858,7 +893,7 @@ ManagerImpl::unHoldConference(const std::string& id) ...@@ -858,7 +893,7 @@ ManagerImpl::unHoldConference(const std::string& id)
conf->setState(isRec ? Conference::ACTIVE_ATTACHED_REC : Conference::ACTIVE_ATTACHED); 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; return true;
} }
...@@ -988,7 +1023,7 @@ ManagerImpl::addMainParticipant(const std::string& conference_id) ...@@ -988,7 +1023,7 @@ ManagerImpl::addMainParticipant(const std::string& conference_id)
else else
RING_WARN("Invalid conference state while adding main participant"); 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)); switchCall(getCallFromCallID(conference_id));
...@@ -1132,7 +1167,7 @@ ManagerImpl::createConfFromParticipantList(const std::vector< std::string > &par ...@@ -1132,7 +1167,7 @@ ManagerImpl::createConfFromParticipantList(const std::vector< std::string > &par
if (!callSuccess) if (!callSuccess)
conf->remove(generatedCallID); conf->remove(generatedCallID);
else { else {
client_.getCallManager()->newCallCreated(account, generatedCallID, tostr); getCallManager()->newCallCreated(account, generatedCallID, tostr);
successCounter++; successCounter++;
} }
} }
...@@ -1140,7 +1175,7 @@ ManagerImpl::createConfFromParticipantList(const std::vector< std::string > &par ...@@ -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 // Create the conference if and only if at least 2 calls have been successfully created
if (successCounter >= 2) { if (successCounter >= 2) {
conferenceMap_[conf->getConfID()] = conf; conferenceMap_[conf->getConfID()] = conf;
client_.getCallManager()->conferenceCreated(conf->getConfID()); getCallManager()->conferenceCreated(conf->getConfID());
conf->setRecordingFormat(ringbufferpool_->getInternalAudioFormat()); conf->setRecordingFormat(ringbufferpool_->getInternalAudioFormat());
} }
} }
...@@ -1202,7 +1237,7 @@ ManagerImpl::detachParticipant(const std::string& call_id) ...@@ -1202,7 +1237,7 @@ ManagerImpl::detachParticipant(const std::string& call_id)
else else
RING_WARN("Undefined behavior, invalid conference state in detach participant"); RING_WARN("Undefined behavior, invalid conference state in detach participant");
client_.getCallManager()->conferenceChanged(conf->getConfID(), getCallManager()->conferenceChanged(conf->getConfID(),
conf->getStateStr()); conf->getStateStr());
unsetCurrentCall(); unsetCurrentCall();
...@@ -1236,7 +1271,7 @@ ManagerImpl::removeParticipant(const std::string& call_id) ...@@ -1236,7 +1271,7 @@ ManagerImpl::removeParticipant(const std::string& call_id)
removeStream(*call); removeStream(*call);
client_.getCallManager()->conferenceChanged(conf->getConfID(), conf->getStateStr()); getCallManager()->conferenceChanged(conf->getConfID(), conf->getStateStr());
processRemainingParticipants(*conf); processRemainingParticipants(*conf);
} }
...@@ -1541,7 +1576,7 @@ ManagerImpl::incomingCall(Call &call, const std::string& accountId) ...@@ -1541,7 +1576,7 @@ ManagerImpl::incomingCall(Call &call, const std::string& accountId)
std::string from("<" + number + ">"); std::string from("<" + number + ">");
client_.getCallManager()->incomingCall(accountId, callID, call.getDisplayName() + " " + from); getCallManager()->incomingCall(accountId, callID, call.getDisplayName() + " " + from);
} }
//THREAD=VoIP //THREAD=VoIP
...@@ -1572,10 +1607,10 @@ ManagerImpl::incomingMessage(const std::string& callID, ...@@ -1572,10 +1607,10 @@ ManagerImpl::incomingMessage(const std::string& callID,
} }
// in case of a conference we must notify client using conference id // 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 } else
client_.getCallManager()->incomingMessage(callID, from, message); getCallManager()->incomingMessage(callID, from, message);
} }
//THREAD=VoIP //THREAD=VoIP
...@@ -1664,7 +1699,7 @@ ManagerImpl::peerAnsweredCall(Call& call) ...@@ -1664,7 +1699,7 @@ ManagerImpl::peerAnsweredCall(Call& call)
if (audioPreference.getIsAlwaysRecording()) if (audioPreference.getIsAlwaysRecording())
toggleRecordingCall(call_id); toggleRecordingCall(call_id);
client_.getCallManager()->callStateChanged(call_id, "CURRENT"); getCallManager()->callStateChanged(call_id, "CURRENT");
} }
//THREAD=VoIP Call=Outgoing //THREAD=VoIP Call=Outgoing
...@@ -1677,7 +1712,7 @@ ManagerImpl::peerRingingCall(Call& call) ...@@ -1677,7 +1712,7 @@ ManagerImpl::peerRingingCall(Call& call)
if (isCurrentCall(call)) if (isCurrentCall(call))
ringback(); ringback();
client_.getCallManager()->callStateChanged(call_id, "RINGING"); getCallManager()->callStateChanged(call_id, "RINGING");
} }
//THREAD=VoIP Call=Outgoing/Ingoing //THREAD=VoIP Call=Outgoing/Ingoing
...@@ -1698,7 +1733,7 @@ ManagerImpl::peerHungupCall(Call& call) ...@@ -1698,7 +1733,7 @@ ManagerImpl::peerHungupCall(Call& call)
call.peerHungup(); call.peerHungup();
saveHistory(); saveHistory();
client_.getCallManager()->callStateChanged(call_id, "HUNGUP"); getCallManager()->callStateChanged(call_id, "HUNGUP");
checkAudio(); checkAudio();
removeWaitingCall(call_id); removeWaitingCall(call_id);
...@@ -1714,7 +1749,7 @@ ManagerImpl::callBusy(Call& call) ...@@ -1714,7 +1749,7 @@ ManagerImpl::callBusy(Call& call)
{ {
const auto call_id = call.getCallId(); const auto call_id = call.getCallId();
client_.getCallManager()->callStateChanged(call_id, "BUSY"); getCallManager()->callStateChanged(call_id, "BUSY");
if (isCurrentCall(call)) { if (isCurrentCall(call)) {
playATone(Tone::TONE_BUSY); playATone(Tone::TONE_BUSY);
...@@ -1731,7 +1766,7 @@ ManagerImpl::callFailure(Call& call) ...@@ -1731,7 +1766,7 @@ ManagerImpl::callFailure(Call& call)
{ {
const auto call_id = call.getCallId(); const auto call_id = call.getCallId();
client_.getCallManager()->callStateChanged(call_id, "FAILURE"); getCallManager()->callStateChanged(call_id, "FAILURE");
if (isCurrentCall(call)) { if (isCurrentCall(call)) {
playATone(Tone::TONE_BUSY); playATone(Tone::TONE_BUSY);
...@@ -1753,7 +1788,7 @@ void ...@@ -1753,7 +1788,7 @@ void
ManagerImpl::startVoiceMessageNotification(const std::string& accountId, ManagerImpl::startVoiceMessageNotification(const std::string& accountId,
int nb_msg) int nb_msg)
{ {
client_.getCallManager()->voiceMailNotify(accountId, nb_msg); getCallManager()->voiceMailNotify(accountId, nb_msg);
} }
/** /**
...@@ -1800,7 +1835,7 @@ ManagerImpl::stopTone() ...@@ -1800,7 +1835,7 @@ ManagerImpl::stopTone()
if (audiofile_) { if (audiofile_) {
std::string filepath(audiofile_->getFilePath()); std::string filepath(audiofile_->getFilePath());
client_.getCallManager()->recordPlaybackStopped(filepath); getCallManager()->recordPlaybackStopped(filepath);
audiofile_.reset(); audiofile_.reset();
} }
} }
...@@ -1893,7 +1928,7 @@ ManagerImpl::playRingtone(const std::string& accountID) ...@@ -1893,7 +1928,7 @@ ManagerImpl::playRingtone(const std::string& accountID)
std::lock_guard<std::mutex> m(toneMutex_); std::lock_guard<std::mutex> m(toneMutex_);