Commit 33c9ce5d authored by Emmanuel Lepage Vallee's avatar Emmanuel Lepage Vallee
Browse files

* #29696: presence: move enable/disable to account settings

parent 556db131
...@@ -55,10 +55,12 @@ static const char *const CONFIG_ACCOUNT_DTMF_TYPE = "Account.dtmfT ...@@ -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_PATH = "Account.ringtonePath";
static const char *const CONFIG_RINGTONE_ENABLED = "Account.ringtoneEnabled"; static const char *const CONFIG_RINGTONE_ENABLED = "Account.ringtoneEnabled";
static const char *const CONFIG_KEEP_ALIVE_ENABLED = "Account.keepAliveEnabled"; 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_REGISTRATION_EXPIRE = "60";
static const char *const CONFIG_DEFAULT_RINGTONE_ENABLED = "true"; 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_HOSTNAME = "Account.hostname";
static const char *const CONFIG_ACCOUNT_USERNAME = "Account.username"; static const char *const CONFIG_ACCOUNT_USERNAME = "Account.username";
......
...@@ -147,12 +147,13 @@ void ConfigurationManager::registerAllAccounts() ...@@ -147,12 +147,13 @@ void ConfigurationManager::registerAllAccounts()
std::map<std::string, std::string> ConfigurationManager::getAccountTemplate() std::map<std::string, std::string> ConfigurationManager::getAccountTemplate()
{ {
std::map<std::string, std::string> accTemplate; std::map<std::string, std::string> accTemplate;
accTemplate[ CONFIG_LOCAL_PORT ] = CONFIG_DEFAULT_LOCAL_PORT; accTemplate[ CONFIG_LOCAL_PORT ] = CONFIG_DEFAULT_LOCAL_PORT ;
accTemplate[ CONFIG_PUBLISHED_PORT ] = CONFIG_DEFAULT_PUBLISHED_PORT; accTemplate[ CONFIG_PUBLISHED_PORT ] = CONFIG_DEFAULT_PUBLISHED_PORT ;
accTemplate[ CONFIG_PUBLISHED_SAMEAS_LOCAL ] = CONFIG_DEFAULT_PUBLISHED_SAMEAS_LOCAL; accTemplate[ CONFIG_PUBLISHED_SAMEAS_LOCAL ] = CONFIG_DEFAULT_PUBLISHED_SAMEAS_LOCAL;
accTemplate[ CONFIG_INTERFACE ] = CONFIG_DEFAULT_INTERFACE; accTemplate[ CONFIG_INTERFACE ] = CONFIG_DEFAULT_INTERFACE ;
accTemplate[ CONFIG_ACCOUNT_REGISTRATION_EXPIRE ] = CONFIG_DEFAULT_REGISTRATION_EXPIRE; accTemplate[ CONFIG_ACCOUNT_REGISTRATION_EXPIRE ] = CONFIG_DEFAULT_REGISTRATION_EXPIRE ;
accTemplate[ CONFIG_RINGTONE_ENABLED ] = CONFIG_DEFAULT_RINGTONE_ENABLED; accTemplate[ CONFIG_RINGTONE_ENABLED ] = CONFIG_DEFAULT_RINGTONE_ENABLED ;
accTemplate[ CONFIG_PRESENCE_ENABLED ] = CONFIG_DEFAULT_PRESENCE_ENABLED ;
return accTemplate; return accTemplate;
} }
......
...@@ -3,11 +3,6 @@ ...@@ -3,11 +3,6 @@
<node name="/presencemanager-introspec" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> <node name="/presencemanager-introspec" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.sflphone.SFLphone.PresenceManager"> <interface name="org.sflphone.SFLphone.PresenceManager">
<!-- METHODS !--> <!-- 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"> <method name="sendPresence" tp:name-for-bindings="sendPresence">
<tp:added version="1.3.0"/> <tp:added version="1.3.0"/>
<arg type="s" name="accountID" direction="in"/> <arg type="s" name="accountID" direction="in"/>
......
...@@ -66,20 +66,6 @@ PresenceManager::subscribePresSubClient(const std::string& accountID, const std: ...@@ -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 * push a presence for a account
* Notify for IP2IP account and publish for PBX account * Notify for IP2IP account and publish for PBX account
......
...@@ -82,7 +82,6 @@ class PresenceManager ...@@ -82,7 +82,6 @@ class PresenceManager
#endif //__ANDROID__ #endif //__ANDROID__
/* Presence subscription/Notification. */ /* 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 sendPresence(const std::string& accountID, const bool& status, const std::string& note);
void approvePresSubServer(const std::string& uri, const bool& flag); void approvePresSubServer(const std::string& uri, const bool& flag);
void subscribePresSubClient(const std::string& accountID, const std::string& uri, const bool& flag); void subscribePresSubClient(const std::string& accountID, const std::string& uri, const bool& flag);
......
...@@ -603,6 +603,8 @@ void SIPAccount::setAccountDetails(std::map<std::string, std::string> details) ...@@ -603,6 +603,8 @@ void SIPAccount::setAccountDetails(std::map<std::string, std::string> details)
updateRange(tmpMin, tmpMax, videoPortRange_); updateRange(tmpMin, tmpMax, videoPortRange_);
#endif #endif
enablePresence(details[CONFIG_PRESENCE_ENABLED] == TRUE_STR);
// srtp settings // srtp settings
srtpEnabled_ = details[CONFIG_SRTP_ENABLE] == TRUE_STR; srtpEnabled_ = details[CONFIG_SRTP_ENABLE] == TRUE_STR;
srtpFallback_ = details[CONFIG_SRTP_RTP_FALLBACK] == TRUE_STR; srtpFallback_ = details[CONFIG_SRTP_RTP_FALLBACK] == TRUE_STR;
...@@ -698,6 +700,7 @@ std::map<std::string, std::string> SIPAccount::getAccountDetails() const ...@@ -698,6 +700,7 @@ std::map<std::string, std::string> SIPAccount::getAccountDetails() const
a[CONFIG_RINGTONE_PATH] = ringtonePath_; a[CONFIG_RINGTONE_PATH] = ringtonePath_;
a[CONFIG_RINGTONE_ENABLED] = ringtoneEnabled_ ? TRUE_STR : FALSE_STR; a[CONFIG_RINGTONE_ENABLED] = ringtoneEnabled_ ? TRUE_STR : FALSE_STR;
a[CONFIG_ACCOUNT_MAILBOX] = mailBox_; a[CONFIG_ACCOUNT_MAILBOX] = mailBox_;
a[CONFIG_PRESENCE_ENABLED] = getPresence()->isEnabled()? TRUE_STR : FALSE_STR;
RegistrationState state = UNREGISTERED; RegistrationState state = UNREGISTERED;
std::string registrationStateCode; std::string registrationStateCode;
...@@ -1381,10 +1384,19 @@ bool SIPAccount::isIP2IP() const{ ...@@ -1381,10 +1384,19 @@ bool SIPAccount::isIP2IP() const{
return accountID_ == IP2IP_PROFILE; return accountID_ == IP2IP_PROFILE;
} }
SIPPresence * SIPAccount::getPresence(){ SIPPresence * SIPAccount::getPresence() const {
return presence_; 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, bool SIPAccount::matches(const std::string &userName, const std::string &server,
pjsip_endpoint *endpt, pj_pool_t *pool) const pjsip_endpoint *endpt, pj_pool_t *pool) const
{ {
......
...@@ -534,7 +534,9 @@ class SIPAccount : public Account { ...@@ -534,7 +534,9 @@ class SIPAccount : public Account {
/** /**
* Presence management * Presence management
*/ */
SIPPresence * getPresence(); SIPPresence * getPresence() const;
void enablePresence(const bool& flag);
// unsigned generateAudioPort() const; // unsigned generateAudioPort() const;
uint16_t generateAudioPort() const; uint16_t generateAudioPort() const;
......
...@@ -79,19 +79,19 @@ SIPPresence::~SIPPresence(){ ...@@ -79,19 +79,19 @@ SIPPresence::~SIPPresence(){
removePresSubServer(s); removePresSubServer(s);
} }
SIPAccount * SIPPresence::getAccount(){ SIPAccount * SIPPresence::getAccount() const {
return acc_; return acc_;
} }
pjsip_pres_status * SIPPresence::getStatus(){ pjsip_pres_status * SIPPresence::getStatus() {
return &pres_status_data; return &pres_status_data;
} }
int SIPPresence::getModId(){ int SIPPresence::getModId() const {
return ((SIPVoIPLink*) (acc_->getVoIPLink()))->getModId(); return ((SIPVoIPLink*) (acc_->getVoIPLink()))->getModId();
} }
pj_pool_t* SIPPresence::getPool(){ pj_pool_t* SIPPresence::getPool() const {
return pool_; return pool_;
} }
......
...@@ -118,7 +118,7 @@ public: ...@@ -118,7 +118,7 @@ public:
/** /**
* Return associated sipaccount * Return associated sipaccount
*/ */
SIPAccount * getAccount(); SIPAccount * getAccount() const;
/** /**
* Return presence data. * Return presence data.
*/ */
...@@ -126,11 +126,11 @@ public: ...@@ -126,11 +126,11 @@ public:
/** /**
* Return presence module ID which is actually the same as the VOIP link * Return presence module ID which is actually the same as the VOIP link
*/ */
int getModId(); int getModId() const;
/** /**
* Return a pool for generic functions. * Return a pool for generic functions.
*/ */
pj_pool_t* getPool(); pj_pool_t* getPool() const;
/** /**
* Activate the module (PUBLISH/SUBSCRIBE) * Activate the module (PUBLISH/SUBSCRIBE)
*/ */
...@@ -200,6 +200,10 @@ public: ...@@ -200,6 +200,10 @@ public:
* Iterate through the subscriber list and send NOTIFY to each. * Iterate through the subscriber list and send NOTIFY to each.
*/ */
void notifyPresSubServer(); void notifyPresSubServer();
bool isEnabled() const {
return enabled;
}
/** /**
* Lock methods * Lock methods
......
Supports Markdown
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