diff --git a/daemon/src/account_schema.h b/daemon/src/account_schema.h index 9d35062885053ae2bf8cbf88f567c082c4b766e1..8bd2d092e91816000f0112a324c7abdded3b68aa 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 175a137dd7075e714102ddb6016ea5517ae0d35f..7a2424b206752321946e68a45280634625d5a0a0 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 9cf82b81174073dccdd033ad7c61cc9d165398a7..d61ea14c8c882a31e6855c0807b8dfaab8a25bc5 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 89490e888915482af424e3bb453aa76a33f75f27..fda04f83400e3b7cb5b29cdaed0eb984e27a5ca4 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 370308face199e5bb7a41aa2b96acbba58aa51f5..773b81001fad1c19ecf3abdb7ee8054c0d5826d4 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 8b2756b548f58594533a324baeaf905506484b17..eee62bafd0acd16f0d9848d38489694141ff499e 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 3c073c3575eb6e55a1f763c6b90d99bc294e9cd0..02b64690a2b7cae1ec0e927def083f98dcf3e1b9 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 7e198f77f9f1e5c2d5bf394fad1b316f648aa26f..da8a486d62a764004be649f7c563f2058324b97c 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 9e7a7b0ae11d1703663fd00bde70c47f59e054af..c0a13d6c59df4f11ea3e597cfc88551f33a8617b 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