From 33c9ce5dbc15d9ff92254fdc2ead9745a4fa1981 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> Date: Fri, 6 Sep 2013 12:43:00 -0400 Subject: [PATCH] * #29696: presence: move enable/disable to account settings --- daemon/src/account_schema.h | 2 ++ daemon/src/client/dbus/configurationmanager.cpp | 11 ++++++----- .../src/client/dbus/presencemanager-introspec.xml | 5 ----- daemon/src/client/dbus/presencemanager.cpp | 14 -------------- daemon/src/client/presencemanager.h | 1 - daemon/src/sip/sipaccount.cpp | 14 +++++++++++++- daemon/src/sip/sipaccount.h | 4 +++- daemon/src/sip/sippresence.cpp | 8 ++++---- daemon/src/sip/sippresence.h | 10 +++++++--- 9 files changed, 35 insertions(+), 34 deletions(-) diff --git a/daemon/src/account_schema.h b/daemon/src/account_schema.h index 9d35062885..8bd2d092e9 100644 --- a/daemon/src/account_schema.h +++ b/daemon/src/account_schema.h @@ -55,10 +55,12 @@ static const char *const CONFIG_ACCOUNT_DTMF_TYPE = "Account.dtmfT static const char *const CONFIG_RINGTONE_PATH = "Account.ringtonePath"; static const char *const CONFIG_RINGTONE_ENABLED = "Account.ringtoneEnabled"; static const char *const CONFIG_KEEP_ALIVE_ENABLED = "Account.keepAliveEnabled"; +static const char *const CONFIG_PRESENCE_ENABLED = "Account.presenceModuleEnabled"; static const char *const CONFIG_DEFAULT_REGISTRATION_EXPIRE = "60"; static const char *const CONFIG_DEFAULT_RINGTONE_ENABLED = "true"; +static const char *const CONFIG_DEFAULT_PRESENCE_ENABLED = "true"; static const char *const CONFIG_ACCOUNT_HOSTNAME = "Account.hostname"; static const char *const CONFIG_ACCOUNT_USERNAME = "Account.username"; diff --git a/daemon/src/client/dbus/configurationmanager.cpp b/daemon/src/client/dbus/configurationmanager.cpp index 175a137dd7..7a2424b206 100644 --- a/daemon/src/client/dbus/configurationmanager.cpp +++ b/daemon/src/client/dbus/configurationmanager.cpp @@ -147,12 +147,13 @@ void ConfigurationManager::registerAllAccounts() std::map<std::string, std::string> ConfigurationManager::getAccountTemplate() { std::map<std::string, std::string> accTemplate; - accTemplate[ CONFIG_LOCAL_PORT ] = CONFIG_DEFAULT_LOCAL_PORT; - accTemplate[ CONFIG_PUBLISHED_PORT ] = CONFIG_DEFAULT_PUBLISHED_PORT; + accTemplate[ CONFIG_LOCAL_PORT ] = CONFIG_DEFAULT_LOCAL_PORT ; + accTemplate[ CONFIG_PUBLISHED_PORT ] = CONFIG_DEFAULT_PUBLISHED_PORT ; accTemplate[ CONFIG_PUBLISHED_SAMEAS_LOCAL ] = CONFIG_DEFAULT_PUBLISHED_SAMEAS_LOCAL; - accTemplate[ CONFIG_INTERFACE ] = CONFIG_DEFAULT_INTERFACE; - accTemplate[ CONFIG_ACCOUNT_REGISTRATION_EXPIRE ] = CONFIG_DEFAULT_REGISTRATION_EXPIRE; - accTemplate[ CONFIG_RINGTONE_ENABLED ] = CONFIG_DEFAULT_RINGTONE_ENABLED; + accTemplate[ CONFIG_INTERFACE ] = CONFIG_DEFAULT_INTERFACE ; + accTemplate[ CONFIG_ACCOUNT_REGISTRATION_EXPIRE ] = CONFIG_DEFAULT_REGISTRATION_EXPIRE ; + accTemplate[ CONFIG_RINGTONE_ENABLED ] = CONFIG_DEFAULT_RINGTONE_ENABLED ; + accTemplate[ CONFIG_PRESENCE_ENABLED ] = CONFIG_DEFAULT_PRESENCE_ENABLED ; return accTemplate; } diff --git a/daemon/src/client/dbus/presencemanager-introspec.xml b/daemon/src/client/dbus/presencemanager-introspec.xml index 9cf82b8117..d61ea14c8c 100644 --- a/daemon/src/client/dbus/presencemanager-introspec.xml +++ b/daemon/src/client/dbus/presencemanager-introspec.xml @@ -3,11 +3,6 @@ <node name="/presencemanager-introspec" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> <interface name="org.sflphone.SFLphone.PresenceManager"> <!-- METHODS !--> - <method name="enablePresence" tp:name-for-bindings="enablePresence"> - <tp:added version="1.3.0"/> - <arg type="s" name="accountID" direction="in"/> - <arg type="b" name="flag" direction="in"/> - </method> <method name="sendPresence" tp:name-for-bindings="sendPresence"> <tp:added version="1.3.0"/> <arg type="s" name="accountID" direction="in"/> diff --git a/daemon/src/client/dbus/presencemanager.cpp b/daemon/src/client/dbus/presencemanager.cpp index 89490e8889..fda04f8340 100644 --- a/daemon/src/client/dbus/presencemanager.cpp +++ b/daemon/src/client/dbus/presencemanager.cpp @@ -66,20 +66,6 @@ PresenceManager::subscribePresSubClient(const std::string& accountID, const std: } } -/** - * Enable the presence module (PUBLISH/SUBSCRIBE) - */ -void -PresenceManager::enablePresence(const std::string& accountID, const bool& flag){ - SIPAccount *sipaccount = Manager::instance().getSipAccount(accountID); - if (!sipaccount) - ERROR("Could not find account %s",accountID.c_str()); - else{ - DEBUG("Enable Presence (acc:%s : %s)",accountID.c_str(), flag? "yes":"no"); - sipaccount->getPresence()->enable(flag); - } -} - /** * push a presence for a account * Notify for IP2IP account and publish for PBX account diff --git a/daemon/src/client/presencemanager.h b/daemon/src/client/presencemanager.h index 370308face..773b81001f 100644 --- a/daemon/src/client/presencemanager.h +++ b/daemon/src/client/presencemanager.h @@ -82,7 +82,6 @@ class PresenceManager #endif //__ANDROID__ /* Presence subscription/Notification. */ - void enablePresence(const std::string& accountID, const bool& flag); void sendPresence(const std::string& accountID, const bool& status, const std::string& note); void approvePresSubServer(const std::string& uri, const bool& flag); void subscribePresSubClient(const std::string& accountID, const std::string& uri, const bool& flag); diff --git a/daemon/src/sip/sipaccount.cpp b/daemon/src/sip/sipaccount.cpp index 8b2756b548..eee62bafd0 100644 --- a/daemon/src/sip/sipaccount.cpp +++ b/daemon/src/sip/sipaccount.cpp @@ -603,6 +603,8 @@ void SIPAccount::setAccountDetails(std::map<std::string, std::string> details) updateRange(tmpMin, tmpMax, videoPortRange_); #endif + enablePresence(details[CONFIG_PRESENCE_ENABLED] == TRUE_STR); + // srtp settings srtpEnabled_ = details[CONFIG_SRTP_ENABLE] == TRUE_STR; srtpFallback_ = details[CONFIG_SRTP_RTP_FALLBACK] == TRUE_STR; @@ -698,6 +700,7 @@ std::map<std::string, std::string> SIPAccount::getAccountDetails() const a[CONFIG_RINGTONE_PATH] = ringtonePath_; a[CONFIG_RINGTONE_ENABLED] = ringtoneEnabled_ ? TRUE_STR : FALSE_STR; a[CONFIG_ACCOUNT_MAILBOX] = mailBox_; + a[CONFIG_PRESENCE_ENABLED] = getPresence()->isEnabled()? TRUE_STR : FALSE_STR; RegistrationState state = UNREGISTERED; std::string registrationStateCode; @@ -1381,10 +1384,19 @@ bool SIPAccount::isIP2IP() const{ return accountID_ == IP2IP_PROFILE; } -SIPPresence * SIPAccount::getPresence(){ +SIPPresence * SIPAccount::getPresence() const { return presence_; } +/** + * Enable the presence module (PUBLISH/SUBSCRIBE) + */ +void +SIPAccount::enablePresence(const bool& flag){ + DEBUG("Enable Presence (acc:%s : %s)",accountID_.c_str(), flag? "yes":"no"); + getPresence()->enable(flag); +} + bool SIPAccount::matches(const std::string &userName, const std::string &server, pjsip_endpoint *endpt, pj_pool_t *pool) const { diff --git a/daemon/src/sip/sipaccount.h b/daemon/src/sip/sipaccount.h index 3c073c3575..02b64690a2 100644 --- a/daemon/src/sip/sipaccount.h +++ b/daemon/src/sip/sipaccount.h @@ -534,7 +534,9 @@ class SIPAccount : public Account { /** * Presence management */ - SIPPresence * getPresence(); + SIPPresence * getPresence() const; + + void enablePresence(const bool& flag); // unsigned generateAudioPort() const; uint16_t generateAudioPort() const; diff --git a/daemon/src/sip/sippresence.cpp b/daemon/src/sip/sippresence.cpp index 7e198f77f9..da8a486d62 100644 --- a/daemon/src/sip/sippresence.cpp +++ b/daemon/src/sip/sippresence.cpp @@ -79,19 +79,19 @@ SIPPresence::~SIPPresence(){ removePresSubServer(s); } -SIPAccount * SIPPresence::getAccount(){ +SIPAccount * SIPPresence::getAccount() const { return acc_; } -pjsip_pres_status * SIPPresence::getStatus(){ +pjsip_pres_status * SIPPresence::getStatus() { return &pres_status_data; } -int SIPPresence::getModId(){ +int SIPPresence::getModId() const { return ((SIPVoIPLink*) (acc_->getVoIPLink()))->getModId(); } -pj_pool_t* SIPPresence::getPool(){ +pj_pool_t* SIPPresence::getPool() const { return pool_; } diff --git a/daemon/src/sip/sippresence.h b/daemon/src/sip/sippresence.h index 9e7a7b0ae1..c0a13d6c59 100644 --- a/daemon/src/sip/sippresence.h +++ b/daemon/src/sip/sippresence.h @@ -118,7 +118,7 @@ public: /** * Return associated sipaccount */ - SIPAccount * getAccount(); + SIPAccount * getAccount() const; /** * Return presence data. */ @@ -126,11 +126,11 @@ public: /** * Return presence module ID which is actually the same as the VOIP link */ - int getModId(); + int getModId() const; /** * Return a pool for generic functions. */ - pj_pool_t* getPool(); + pj_pool_t* getPool() const; /** * Activate the module (PUBLISH/SUBSCRIBE) */ @@ -200,6 +200,10 @@ public: * Iterate through the subscriber list and send NOTIFY to each. */ void notifyPresSubServer(); + + bool isEnabled() const { + return enabled; + } /** * Lock methods -- GitLab