Commit 2f1ee04e authored by Emmanuel Lepage Vallee's avatar Emmanuel Lepage Vallee
Browse files

* #29696: presence: Refactor API, create new XML

parent 8218089d
......@@ -45,27 +45,28 @@
#include "client/configurationmanager.h"
const char * const Account::AUDIO_CODECS_KEY = "audioCodecs"; // 0/9/110/111/112/
const char * const Account::VIDEO_CODECS_KEY = "videoCodecs";
const char * const Account::VIDEO_CODEC_ENABLED = "enabled";
const char * const Account::VIDEO_CODEC_NAME = "name";
const char * const Account::VIDEO_CODEC_PARAMETERS ="parameters";
const char * const Account::VIDEO_CODEC_BITRATE = "bitrate";
const char * const Account::RINGTONE_PATH_KEY = "ringtonePath";
const char * const Account::RINGTONE_ENABLED_KEY = "ringtoneEnabled";
const char * const Account::DISPLAY_NAME_KEY = "displayName";
const char * const Account::ALIAS_KEY = "alias";
const char * const Account::TYPE_KEY = "type";
const char * const Account::ID_KEY = "id";
const char * const Account::USERNAME_KEY = "username";
const char * const Account::AUDIO_CODECS_KEY = "audioCodecs"; // 0/9/110/111/112/
const char * const Account::VIDEO_CODECS_KEY = "videoCodecs";
const char * const Account::VIDEO_CODEC_ENABLED = "enabled";
const char * const Account::VIDEO_CODEC_NAME = "name";
const char * const Account::VIDEO_CODEC_PARAMETERS = "parameters";
const char * const Account::VIDEO_CODEC_BITRATE = "bitrate";
const char * const Account::RINGTONE_PATH_KEY = "ringtonePath";
const char * const Account::RINGTONE_ENABLED_KEY = "ringtoneEnabled";
const char * const Account::DISPLAY_NAME_KEY = "displayName";
const char * const Account::ALIAS_KEY = "alias";
const char * const Account::TYPE_KEY = "type";
const char * const Account::ID_KEY = "id";
const char * const Account::USERNAME_KEY = "username";
const char * const Account::AUTHENTICATION_USERNAME_KEY = "authenticationUsername";
const char * const Account::PASSWORD_KEY = "password";
const char * const Account::HOSTNAME_KEY = "hostname";
const char * const Account::ACCOUNT_ENABLE_KEY = "enable";
const char * const Account::ACCOUNT_AUTOANSWER_KEY = "autoAnswer";
const char * const Account::MAILBOX_KEY = "mailbox";
const char * const Account::DEFAULT_USER_AGENT = "SFLphone/" PACKAGE_VERSION;
const char * const Account::USER_AGENT_KEY = "useragent";
const char * const Account::PASSWORD_KEY = "password";
const char * const Account::HOSTNAME_KEY = "hostname";
const char * const Account::ACCOUNT_ENABLE_KEY = "enable";
const char * const Account::ACCOUNT_AUTOANSWER_KEY = "autoAnswer";
const char * const Account::MAILBOX_KEY = "mailbox";
const char * const Account::DEFAULT_USER_AGENT = "SFLphone/" PACKAGE_VERSION;
const char * const Account::USER_AGENT_KEY = "useragent";
const char * const Account::PRESENCE_MODULE_ENABLED_KEY = "presenceModuleEnabled";
using std::map;
using std::string;
......
......@@ -224,6 +224,7 @@ class Account : public Serializable {
static const char * const MAILBOX_KEY;
static const char * const USER_AGENT_KEY;
static const char * const DEFAULT_USER_AGENT;
static const char * const PRESENCE_MODULE_ENABLED_KEY;
static std::string mapStateNumberToString(RegistrationState state);
......
......@@ -179,16 +179,7 @@ class CallManager
void registrationStateChanged(const std::string&, const std::string&, const int32_t&);
void sipCallStateChanged(const std::string&, const std::string&, const int32_t&);
void newPresSubClientNotification(const std::string& uri, const std::string& basic, const std::string& note);
void newPresSubServerRequest(const std::string& remote);
#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);
private:
#if HAVE_ZRTP
......
......@@ -38,6 +38,7 @@
class ConfigurationManager;
class CallManager;
class PresenceManager;
class NetworkManager;
class Instance;
class VideoControls;
......@@ -57,6 +58,10 @@ class Client {
ConfigurationManager * getConfigurationManager() {
return configurationManager_;
}
PresenceManager * getPresenceManager() {
return presenceManager_;
}
#ifdef SFL_VIDEO
VideoControls* getVideoControls() {
return videoControls_;
......@@ -70,6 +75,7 @@ class Client {
NON_COPYABLE(Client);
CallManager* callManager_;
ConfigurationManager* configurationManager_;
PresenceManager* presenceManager_;
Instance* instanceManager_;
DBus::BusDispatcher* dispatcher_;
#ifdef SFL_VIDEO
......
......@@ -5,6 +5,7 @@ noinst_LTLIBRARIES = libclient.la
BUILT_SOURCES= \
callmanager-glue.h \
configurationmanager-glue.h \
presencemanager-glue.h \
instance-glue.h
if SFL_VIDEO
......@@ -21,6 +22,10 @@ callmanager-glue.h: callmanager-introspec.xml Makefile.am
configurationmanager-glue.h: configurationmanager-introspec.xml Makefile.am
dbusxx-xml2cpp $< --adaptor=$@
# Rule to generate the binding headers
presencemanager-glue.h: presencemanager-introspec.xml Makefile.am
dbusxx-xml2cpp $< --adaptor=$@
# Rule to generate the binding headers
instance-glue.h: instance-introspec.xml Makefile.am
dbusxx-xml2cpp $< --adaptor=$@
......@@ -29,7 +34,8 @@ libclient_la_SOURCES = \
callmanager.cpp \
configurationmanager.cpp \
instance.cpp \
client.cpp
client.cpp \
presencemanager.cpp
if SFL_VIDEO
libclient_la_SOURCES+=video_controls.cpp
......@@ -51,6 +57,7 @@ libclient_la_CXXFLAGS = -I../ \
noinst_HEADERS = \
../callmanager.h \
../configurationmanager.h \
../presencemanager.h \
instance.h \
../client.h \
networkmanager_proxy.h \
......@@ -75,7 +82,8 @@ EXTRA_DIST = README $(service_in_files) \
callmanager-introspec.xml \
configurationmanager-introspec.xml \
instance-introspec.xml \
org.freedesktop.NetworkManager.xml
org.freedesktop.NetworkManager.xml \
presencemanager-introspec.xml
if SFL_VIDEO
EXTRA_DIST += video_controls-introspec.xml
......
......@@ -819,43 +819,5 @@
<arg type="s" name="callID" direction="in"/>
<arg type="b" name="accepted" direction="in"/>
</method>
<method name="subscribePresSubClient" tp:name-for-bindings="subscribePresSubClient">
<tp:added version="0.9.7"/>
<arg type="s" name="accountID" direction="in"/>
<arg type="s" name="uri" direction="in"/>
<arg type="b" name="flag" direction="in"/>
</method>
<method name="enablePresence" tp:name-for-bindings="enablePresence">
<tp:added version="0.9.7"/>
<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="0.9.7"/>
<arg type="s" name="accountID" direction="in"/>
<arg type="b" name="status" direction="in"/>
<arg type="s" name="note" direction="in"/>
</method>
<method name="approvePresSubServer" tp:name-for-bindings="approvePresSubServer">
<tp:added version="0.9.7"/>
<arg type="s" name="uri" direction="in"/>
<arg type="b" name="flag" direction="in"/>
</method>
<signal name="newPresSubClientNotification" tp:name-for-bindings="newPresSubClientNotification">
<tp:added version="0.9.7"/>
<arg type="s" name="buddyUri"/>
<arg type="s" name="status"/>
<arg type="s" name="lineStatus"/>
</signal>
<signal name="newPresSubServerRequest" tp:name-for-bindings="newPresSubServerRequest">
<arg type="s" name="buddyUri"/>
</signal>
</interface>
</node>
......@@ -424,65 +424,3 @@ CallManager::sendTextMessage(const std::string& callID, const std::string& messa
ERROR("Could not send \"%s\" text message to %s since SFLphone daemon does not support it, please recompile with instant messaging support", message.c_str(), callID.c_str());
#endif
}
/**
* Un/subscribe to buddySipUri for an accountID
*/
void
CallManager::subscribePresSubClient(const std::string& accountID, const std::string& uri, const bool& flag)
{
SIPAccount *sipaccount = Manager::instance().getSipAccount(accountID);
if (!sipaccount)
ERROR("Could not find account %s",accountID.c_str());
else{
DEBUG("%subscribePresence (acc:%s, buddy:%s)",flag? "S":"Uns", accountID.c_str(), uri.c_str());
sipaccount->getPresence()->subscribePresSubClient(uri,flag);
}
}
/**
* Enable the presence module (PUBLISH/SUBSCRIBE)
*/
void
CallManager::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
*/
void
CallManager::sendPresence(const std::string& accountID, const bool& status, const std::string& note)
{
SIPAccount *sipaccount = Manager::instance().getSipAccount(accountID);
if (!sipaccount)
ERROR("Could not find account %s.",accountID.c_str());
else{
DEBUG("Send Presence (acc:%s, status %s).",accountID.c_str(),status? "online":"offline");
sipaccount->getPresence()->sendPresence(status, note);
}
}
/**
* Accept or not a PresSubServer request for IP2IP account
*/
void
CallManager::approvePresSubServer(const std::string& uri, const bool& flag)
{
SIPAccount *sipaccount = Manager::instance().getIP2IPAccount();
if (!sipaccount)
ERROR("Could not find account IP2IP");
else{
DEBUG("Approve presence (acc:IP2IP, serv:%s, flag:%s)", uri.c_str(), flag? "true":"false");
sipaccount->getPresence()->approvePresSubServer(uri, flag);
}
}
......@@ -43,6 +43,7 @@
#include "callmanager.h"
#include "configurationmanager.h"
#include "presencemanager.h"
#include "networkmanager.h"
#ifdef SFL_VIDEO
......@@ -51,6 +52,7 @@
Client::Client() : callManager_(0)
, configurationManager_(0)
, presenceManager_(0)
, instanceManager_(0)
, dispatcher_(new DBus::BusDispatcher)
#ifdef SFL_VIDEO
......@@ -75,6 +77,8 @@ Client::Client() : callManager_(0)
callManager_ = new CallManager(sessionConnection);
DEBUG("DBUS create configuration manager from session connection");
configurationManager_ = new ConfigurationManager(sessionConnection);
DEBUG("DBUS create presence manager from session connection");
presenceManager_ = new PresenceManager(sessionConnection);
DEBUG("DBUS create instance manager from session connection");
instanceManager_ = new Instance(sessionConnection);
......
......@@ -3,11 +3,11 @@
<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">
<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>
<method name="sendPresence" tp:name-for-bindings="sendPresence">
<tp:added version="1.3.0"/>
<arg type="s" name="accountID" direction="in"/>
......@@ -21,22 +21,24 @@
<arg type="b" name="flag" direction="in"/>
</method>
<signal name="newPresSubClientNotification" tp:name-for-bindings="newPresSubClientNotification">
<tp:added version="1.3.0"/>
<arg type="s" name="buddyUri"/>
<arg type="s" name="status"/>
<arg type="s" name="lineStatus"/>
</signal>
<method name="subscribePresSubClient" tp:name-for-bindings="subscribePresSubClient">
<tp:added version="0.9.7"/>
<tp:added version="1.3.0"/>
<arg type="s" name="accountID" direction="in"/>
<arg type="s" name="uri" direction="in"/>
<arg type="b" name="flag" direction="in"/>
</method>
<!-- SIGNALS !-->
<signal name="newPresSubClientNotification" tp:name-for-bindings="newPresSubClientNotification">
<tp:added version="1.3.0"/>
<arg type="s" name="buddyUri"/>
<arg type="s" name="status"/>
<arg type="s" name="lineStatus"/>
</signal>
<signal name="newPresSubServerRequest" tp:name-for-bindings="newPresSubServerRequest">
<tp:added version="1.3.0"/>
<arg type="s" name="buddyUri"/>
</signal>
</interface>
......
......@@ -76,8 +76,10 @@ class PresenceManager
PresenceManager();
#endif
#ifdef __ANDROID__
void newPresSubClientNotification(const std::string& uri, const std::string& basic, const std::string& note);
void newPresSubServerRequest(const std::string& remote);
#endif //__ANDROID__
/* Presence subscription/Notification. */
void enablePresence(const std::string& accountID, const bool& flag);
......
......@@ -34,6 +34,7 @@
#include "manager.h"
#include "client/client.h"
#include "client/callmanager.h"
#include "client/presencemanager.h"
#include "sipaccount.h"
#include "sippublish.h"
#include "sippresence.h"
......@@ -140,7 +141,7 @@ void SIPPresence::reportPresSubClientNotification(const std::string& uri, pjsip_
const std::string note(status->info[0].rpid.note.ptr,status->info[0].rpid.note.slen);
DEBUG(" Received status of PresSubClient %s: status=%s note=%s",uri.c_str(),basic.c_str(),note.c_str());
/* report status to client signal */
Manager::instance().getClient()->getCallManager()->newPresSubClientNotification(uri, basic, note);
Manager::instance().getClient()->getPresenceManager()->newPresSubClientNotification(uri, basic, note);
}
void SIPPresence::subscribePresSubClient(const std::string& uri, const bool& flag){
......@@ -186,7 +187,7 @@ void SIPPresence::removePresSubClient(PresSubClient *c){
void SIPPresence::reportNewPresSubServerRequest(PresSubServer *s){
Manager::instance().getClient()->getCallManager()->newPresSubServerRequest(s->remote);
Manager::instance().getClient()->getPresenceManager()->newPresSubServerRequest(s->remote);
}
void SIPPresence::approvePresSubServer(const std::string& uri, const bool& flag){
......
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