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
This diff is collapsed.
......@@ -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);
if (not alsa_->is_capture_open_)
Manager::instance().getClient()->getConfigurationManager()->errorAlert(ALSA_CAPTURE_DEVICE);
Manager::instance().getConfigurationManager()->errorAlert(ALSA_CAPTURE_DEVICE);
}
if (not alsa_->is_playback_open_) {
alsa_->is_playback_open_ = alsa_->openDevice(&alsa_->playbackHandle_, pcmp, SND_PCM_STREAM_PLAYBACK);
if (not alsa_->is_playback_open_)
Manager::instance().getClient()->getConfigurationManager()->errorAlert(ALSA_PLAYBACK_DEVICE);
Manager::instance().getConfigurationManager()->errorAlert(ALSA_PLAYBACK_DEVICE);
if (alsa_->getIndexPlayback() != alsa_->getIndexRingtone())
if (!alsa_->openDevice(&alsa_->ringtoneHandle_, pcmr, SND_PCM_STREAM_PLAYBACK))
Manager::instance().getClient()->getConfigurationManager()->errorAlert(ALSA_PLAYBACK_DEVICE);
Manager::instance().getConfigurationManager()->errorAlert(ALSA_PLAYBACK_DEVICE);
}
alsa_->hardwareFormatAvailable(alsa_->getFormat());
......
......@@ -115,7 +115,7 @@ OpenSLLayer::startStream()
RING_DBG("Start OpenSL audio layer");
std::vector<int32_t> hw_infos = Manager::instance().getClient()->getConfigurationManager()->getHardwareAudioFormat();
std::vector<int32_t> hw_infos = Manager::instance().getConfigurationManager()->getHardwareAudioFormat();
hardwareFormat_ = AudioFormat(hw_infos[0], 1); // Mono on Android
hardwareBuffSize_ = hw_infos[1];
......
......@@ -59,7 +59,7 @@ AudioFile::onBufferFinish()
}
if ((updatePlaybackScale_ % 5) == 0) {
CallManager *cm = Manager::instance().getClient()->getCallManager();
CallManager *cm = Manager::instance().getCallManager();
cm->updatePlaybackScale(filepath_, pos_ / divisor, buffer_->frames() / divisor);
}
......
......@@ -50,23 +50,23 @@
static ring::CallManager* getCallManager()
{
return ring::Manager::instance().getClient()->getCallManager();
return ring::Manager::instance().getCallManager();
}
static ring::ConfigurationManager* getConfigurationManager()
{
return ring::Manager::instance().getClient()->getConfigurationManager();
return ring::Manager::instance().getConfigurationManager();
}
static ring::PresenceManager* getPresenceManager()
{
return ring::Manager::instance().getClient()->getPresenceManager();
return ring::Manager::instance().getPresenceManager();
}
#ifdef RING_VIDEO
static ring::VideoManager* getVideoManager()
{
return ring::Manager::instance().getClient()->getVideoManager();
return ring::Manager::instance().getVideoManager();
}
#endif // RING_VIDEO
......
......@@ -92,7 +92,7 @@ PresSubClient::pres_client_evsub_on_state(pjsip_evsub *sub, pjsip_event *event)
if (state == PJSIP_EVSUB_STATE_ACCEPTED) {
pres_client->enable(true);
Manager::instance().getClient()->getPresenceManager()->subscriptionStateChanged(
Manager::instance().getPresenceManager()->subscriptionStateChanged(
pres->getAccount()->getAccountID(),
pres_client->getURI().c_str(),
PJ_TRUE);
......@@ -103,7 +103,7 @@ PresSubClient::pres_client_evsub_on_state(pjsip_evsub *sub, pjsip_event *event)
int resub_delay = -1;
pj_strdup_with_null(pres_client->pool_, &pres_client->term_reason_, pjsip_evsub_get_termination_reason(sub));
Manager::instance().getClient()->getPresenceManager()->subscriptionStateChanged(
Manager::instance().getPresenceManager()->subscriptionStateChanged(
pres->getAccount()->getAccountID(),
pres_client->getURI().c_str(),
PJ_FALSE);
......@@ -162,7 +162,7 @@ PresSubClient::pres_client_evsub_on_state(pjsip_evsub *sub, pjsip_event *event)
* 2) change the support field in the account schema if the pres_sub's server
* is the same as the account's server
*/
Manager::instance().getClient()->getPresenceManager()->serverError(
Manager::instance().getPresenceManager()->serverError(
pres_client->getPresence()->getAccount()->getAccountID(),
error,
msg);
......
......@@ -188,7 +188,7 @@ PresSubServer::pres_on_rx_subscribe_request(pjsip_rx_data *rdata)
PresSubServer *presSubServer = new PresSubServer(pres, sub, remote, dlg);
pjsip_evsub_set_mod_data(sub, pres->getModId(), presSubServer);
// Notify the client.
Manager::instance().getClient()->getPresenceManager()->newServerSubscriptionRequest(presSubServer->remote_);
Manager::instance().getPresenceManager()->newServerSubscriptionRequest(presSubServer->remote_);
pres->addPresSubServer(presSubServer);
......
......@@ -1109,8 +1109,8 @@ SIPAccount::onRegister(pjsip_regc_cbparam *param)
if (param->code && description) {
std::string state(description->ptr, description->slen);
Manager::instance().getClient()->getConfigurationManager()->sipRegistrationStateChanged(getAccountID(), state, param->code);
Manager::instance().getClient()->getConfigurationManager()->volatileAccountDetailsChanged(accountID_, getVolatileAccountDetails());
Manager::instance().getConfigurationManager()->sipRegistrationStateChanged(getAccountID(), state, param->code);
Manager::instance().getConfigurationManager()->volatileAccountDetailsChanged(accountID_, getVolatileAccountDetails());
std::pair<int, std::string> details(param->code, state);
// TODO: there id a race condition for this ressource when closing the application
setRegistrationStateDetailed(details);
......@@ -1818,7 +1818,7 @@ SIPAccount::supportPresence(int function, bool enabled)
enablePresence(false);
Manager::instance().saveConfig();
Manager::instance().getClient()->getConfigurationManager()->accountsChanged();
Manager::instance().getConfigurationManager()->accountsChanged();
}
MatchRank
......
......@@ -277,7 +277,7 @@ SIPAccountBase::onTransportStateChanged(pjsip_transport_state state, const pjsip
// Notify the client of the new transport state
if (currentStatus != transportStatus_)
Manager::instance().getClient()->getConfigurationManager()->volatileAccountDetailsChanged(accountID_, getVolatileAccountDetails());
Manager::instance().getConfigurationManager()->volatileAccountDetailsChanged(accountID_, getVolatileAccountDetails());
}
void
......
......@@ -63,7 +63,7 @@ namespace ring {
static video::VideoSettings
getSettings()
{
const auto videoman = Manager::instance().getClient()->getVideoManager();
const auto videoman = Manager::instance().getVideoManager();
return videoman->getSettings(videoman->getDefaultDevice());
}
#endif
......
......@@ -35,7 +35,6 @@
#include <sstream>
#include "logger.h"
#include "manager.h"
#include "client/client.h"
#include "client/presencemanager.h"
#include "client/configurationmanager.h"
#include "sipaccount.h"
......@@ -206,7 +205,7 @@ void SIPPresence::reportPresSubClientNotification(const std::string& uri, pjsip_
note_ = note;
}
// report status to client signal
Manager::instance().getClient()->getPresenceManager()->newBuddyNotification(acc_ID, uri, status->info[0].basic_open, note);
Manager::instance().getPresenceManager()->newBuddyNotification(acc_ID, uri, status->info[0].basic_open, note);
}
void SIPPresence::subscribeClient(const std::string& uri, bool flag)
......@@ -382,7 +381,7 @@ SIPPresence::publish_cb(struct pjsip_publishc_cbparam *param)
char errmsg[PJ_ERR_MSG_SIZE];
pj_strerror(param->status, errmsg, sizeof(errmsg));
RING_ERR("Client (PUBLISH) failed, status=%d, msg=%s", param->status, errmsg);
Manager::instance().getClient()->getPresenceManager()->serverError(
Manager::instance().getPresenceManager()->serverError(
pres->getAccount()->getAccountID(),
error,
errmsg);
......@@ -396,7 +395,7 @@ SIPPresence::publish_cb(struct pjsip_publishc_cbparam *param)
} else if ((param->code == PJSIP_SC_BAD_EVENT) || (param->code == PJSIP_SC_NOT_IMPLEMENTED)){ //489 or 501
RING_WARN("Client (PUBLISH) failed (%s)",error.c_str());
Manager::instance().getClient()->getPresenceManager()->serverError(
Manager::instance().getPresenceManager()->serverError(
pres->getAccount()->getAccountID(),
error,
"Publish not supported.");
......
......@@ -62,7 +62,6 @@
#include "client/videomanager.h"
#endif
#include "client/client.h"
#include "client/callmanager.h"
#include "client/configurationmanager.h"
......@@ -819,7 +818,7 @@ invite_session_state_changed_cb(pjsip_inv_session *inv, pjsip_event *ev)
const pj_str_t * description = pjsip_get_status_text(statusCode);
std::string desc(description->ptr, description->slen);
CallManager *cm = Manager::instance().getClient()->getCallManager();
CallManager *cm = Manager::instance().getCallManager();
cm->sipCallStateChanged(call->getCallId(), desc, statusCode);
}
}
......
......@@ -43,7 +43,7 @@ void AccountTest::TestAddRemove()
{
RING_DBG("-------------------- %s --------------------\n", __PRETTY_FUNCTION__);
std::map<std::string, std::string> details(Manager::instance().getClient()->getConfigurationManager()->getAccountTemplate());
std::map<std::string, std::string> details(Manager::instance().getConfigurationManager()->getAccountTemplate());
details[Conf::CONFIG_ACCOUNT_TYPE] = "SIP";
details[Conf::CONFIG_ACCOUNT_ENABLE] = "false";
details[Conf::CONFIG_LOCAL_INTERFACE] = "default";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment