diff --git a/daemon/doc/dbus-api/spec/callmanager-introspec.xml b/daemon/doc/dbus-api/spec/callmanager-introspec.xml index 2150eca25d2f7405bf1f7c8684247457538207c6..53db533cb4d857656715826320c029076b61beb5 120000 --- a/daemon/doc/dbus-api/spec/callmanager-introspec.xml +++ b/daemon/doc/dbus-api/spec/callmanager-introspec.xml @@ -1 +1 @@ -../../../src/dbus/callmanager-introspec.xml \ No newline at end of file +../../../src/client/dbus/callmanager-introspec.xml \ No newline at end of file diff --git a/daemon/doc/dbus-api/spec/configurationmanager-introspec.xml b/daemon/doc/dbus-api/spec/configurationmanager-introspec.xml index d340519f1a8287c927fa3e8c516b256438dc2a63..17ad4338ba18e653ddf6a84be9b6f79480db3ecb 120000 --- a/daemon/doc/dbus-api/spec/configurationmanager-introspec.xml +++ b/daemon/doc/dbus-api/spec/configurationmanager-introspec.xml @@ -1 +1 @@ -../../../src/dbus/configurationmanager-introspec.xml \ No newline at end of file +../../../src/client/dbus/configurationmanager-introspec.xml \ No newline at end of file diff --git a/daemon/doc/dbus-api/spec/instance-introspec.xml b/daemon/doc/dbus-api/spec/instance-introspec.xml index 2e02dfe7239982ae1df5ef975ddacafb9897839a..c5516292837c841e531a1ad47e57f3b78f3c4859 120000 --- a/daemon/doc/dbus-api/spec/instance-introspec.xml +++ b/daemon/doc/dbus-api/spec/instance-introspec.xml @@ -1 +1 @@ -../../../src/dbus/instance-introspec.xml \ No newline at end of file +../../../src/client/dbus/instance-introspec.xml \ No newline at end of file diff --git a/daemon/doc/dbus-api/spec/presencemanager-introspec.xml b/daemon/doc/dbus-api/spec/presencemanager-introspec.xml new file mode 120000 index 0000000000000000000000000000000000000000..19c1ff524af8c0956496330eeacae9329cf5551b --- /dev/null +++ b/daemon/doc/dbus-api/spec/presencemanager-introspec.xml @@ -0,0 +1 @@ +../../../src/client/dbus/presencemanager-introspec.xml \ No newline at end of file diff --git a/daemon/src/account.cpp b/daemon/src/account.cpp index ccc5f6d3c59a8596e9a9e2a27d6b185e301bd0b7..8eda7476d03e47160f37c5d817fc7ecaea19800f 100644 --- a/daemon/src/account.cpp +++ b/daemon/src/account.cpp @@ -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; diff --git a/daemon/src/account.h b/daemon/src/account.h index ecd961b467aafe7735673c9cb9026dd1a35afd05..a4dc44b05c4466ab8abf07547adf9ac942e77310 100644 --- a/daemon/src/account.h +++ b/daemon/src/account.h @@ -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); 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/callmanager.h b/daemon/src/client/callmanager.h index 6e9fc21b0577793c75d94dd4da6f8da4fd431a64..ddc3b177dabd4c2186c50a3821bf8dc599935a3e 100644 --- a/daemon/src/client/callmanager.h +++ b/daemon/src/client/callmanager.h @@ -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 diff --git a/daemon/src/client/client.h b/daemon/src/client/client.h index d88617d42af546ec8c7b5ea108be32fbc826e22c..9b31b08a6b144740e12564fdad63b6b8b2ec64e6 100644 --- a/daemon/src/client/client.h +++ b/daemon/src/client/client.h @@ -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 diff --git a/daemon/src/client/dbus/Makefile.am b/daemon/src/client/dbus/Makefile.am index bbd66cc08baa64fb865701ce79abc8d1453d3819..f2728df530d5fd4629cc97328e082f56dfa1fce7 100644 --- a/daemon/src/client/dbus/Makefile.am +++ b/daemon/src/client/dbus/Makefile.am @@ -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 diff --git a/daemon/src/client/dbus/callmanager-introspec.xml b/daemon/src/client/dbus/callmanager-introspec.xml index c1777487114beace2d65e78eb1d9e38dea9b8c0e..f84cd937b8b35aa694adfe80ad8422c500f5bea1 100644 --- a/daemon/src/client/dbus/callmanager-introspec.xml +++ b/daemon/src/client/dbus/callmanager-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> diff --git a/daemon/src/client/dbus/callmanager.cpp b/daemon/src/client/dbus/callmanager.cpp index ae24655e4bf1e5871d96b1b8eab36ffccde7fd42..265120d0d9d461ba5b7f13db04966ef10bbfe6ac 100644 --- a/daemon/src/client/dbus/callmanager.cpp +++ b/daemon/src/client/dbus/callmanager.cpp @@ -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); - } -} diff --git a/daemon/src/client/dbus/client.cpp b/daemon/src/client/dbus/client.cpp index 0433901f856eb035fb230becfb090e0cf85712a8..19691560f98b765c3781bc3c20b404a2343f3af2 100644 --- a/daemon/src/client/dbus/client.cpp +++ b/daemon/src/client/dbus/client.cpp @@ -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); diff --git a/daemon/src/client/dbus/configurationmanager-introspec.xml b/daemon/src/client/dbus/configurationmanager-introspec.xml index bc6f3d7b9d5e5634b5d1a0cdcd6d965ea1b59a53..cb4660b2500a18b13a2d2dd499012c7127df2431 100644 --- a/daemon/src/client/dbus/configurationmanager-introspec.xml +++ b/daemon/src/client/dbus/configurationmanager-introspec.xml @@ -46,6 +46,7 @@ <li>ACCOUNT_REGISTRATION_STATUS: The account registration status. Should be Registered to make calls.</li> <li>ACCOUNT_REGISTRATION_STATE_CODE</li> <li>ACCOUNT_REGISTRATION_STATE_DESC</li> + <li>CONFIG_DEFAULT_PRESENCE_ENABLED: enable/disable presence support - true or false</li> <li>SRTP_KEY_EXCHANGE</li> <li>SRTP_ENABLE: Whether or not voice communication are encrypted - True or False (Default: False)</li> <li>SRTP_RTP_FALLBACK</li> 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 new file mode 100644 index 0000000000000000000000000000000000000000..cd69b3371a2d515b71dd6ba1f4f610274c89d68f --- /dev/null +++ b/daemon/src/client/dbus/presencemanager-introspec.xml @@ -0,0 +1,137 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<node name="/presencemanager-introspec" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> + <interface name="org.sflphone.SFLphone.PresenceManager"> + <!-- METHODS !--> + <method name="publish" tp:name-for-bindings="publish"> + <tp:added version="1.3.0"/> + <arg type="s" name="accountID" direction="in"> + <tp:docstring> + The account from which the presence will be emitted + </tp:docstring> + </arg> + <arg type="b" name="status" direction="in"> + <tp:docstring> + Is this account present or not + </tp:docstring> + </arg> + <arg type="s" name="note" direction="in"> + <tp:docstring> + A message transmitted by the server to other users + </tp:docstring> + </arg> + </method> + + <method name="answerServerRequest" tp:name-for-bindings="answerServerRequest"> + <tp:docstring> + Answer a presence request from the server + </tp:docstring> + <tp:added version="1.3.0"/> + <arg type="s" name="uri" direction="in"> + <tp:docstring> + </tp:docstring> + </arg> + <arg type="b" name="flag" direction="in"> + <tp:docstring> + Is the request granted or denied + </tp:docstring> + </arg> + </method> + + <method name="subscribeBuddy" tp:name-for-bindings="subscribeBuddy"> + <tp:docstring> + Ask be be notified when 'uri' presence change + </tp:docstring> + <tp:added version="1.3.0"/> + <arg type="s" name="accountID" direction="in"> + <tp:docstring> + An account from which get request presence informations + </tp:docstring> + </arg> + <arg type="s" name="uri" direction="in"> + <tp:docstring> + A SIP uri to watch + </tp:docstring> + </arg> + <arg type="b" name="flag" direction="in"> + <tp:docstring> + </tp:docstring> + </arg> + </method> + + <method name="getSubscriptions" tp:name-for-bindings="getSubscriptions"> + <tp:added version="1.3.0"/> + <tp:rationale> + New clients connecting to existing daemon need to be aware of active + subscriptions. + </tp:rationale> + <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="VectorMapStringString"/> + <annotation> + While there is more status than "Online" or "Offline", only those + </annotation> + <arg type="s" name="accountID" direction="in"> + </arg> + <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="VectorMapStringString"/> + <arg type="aa{ss}" name="credentialInformation" direction="out" tp:type="String_String_Map"> + <tp:docstring> + List of hashes map with the following key-value pairs: + * Status: "Online" or "Offline" + * LineStatus: String + </tp:docstring> + </arg> + </method> + + <method name="setSubscriptions" tp:name-for-bindings="setSubscriptions"> + <tp:added version="1.3.0"/> + <tp:rationale>Calling "subscribeClient" in a loop is too slow</tp:rationale> + <arg type="s" name="accountID" direction="in"> + </arg> + <annotation name="com.trolltech.QtDBus.QtTypeName.In1" value="VectorString"/> + <arg type="as" name="uriList" direction="in"> + <tp:docstring> + A list of SIP URIs + </tp:docstring> + </arg> + <!--TODO<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="VectorString"/> + <arg type="as" name="invalidUris" direction="out"> + <tp:docstring> + List of invalid URIs. An URI must be a valid SIP URI. Clients should purge + the list from all invalid URIs + </tp:docstring> + </arg>--> + </method> + + <!-- SIGNALS !--> + + <signal name="newBuddySubscription" tp:name-for-bindings="newBuddySubscription"> + <tp:added version="1.3.0"/> + <tp:docstring> + Notify when a registered presence uri presence informations changes + </tp:docstring> + <arg type="s" name="buddyUri"> + <tp:docstring> + The registered URI + </tp:docstring> + </arg> + <arg type="b" name="status"> + <tp:docstring> + Is the URI present or not + </tp:docstring> + </arg> + <arg type="s" name="lineStatus"> + <tp:docstring> + A string containing informations from the user (human readable) + </tp:docstring> + </arg> + </signal> + + <signal name="newServerSubscriptionRequest" tp:name-for-bindings="newServerSubscriptionRequest"> + <tp:added version="1.3.0"/> + <arg type="s" name="buddyUri"> + <tp:docstring> + Notify when an other user (or the server) request your presence informations + </tp:docstring> + </arg> + </signal> + </interface> +</node> diff --git a/daemon/src/client/dbus/presencemanager.cpp b/daemon/src/client/dbus/presencemanager.cpp new file mode 100644 index 0000000000000000000000000000000000000000..de6c17aefbe15a358a0d0f905cf65d2ec673da13 --- /dev/null +++ b/daemon/src/client/dbus/presencemanager.cpp @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2013 Savoir-Faire Linux Inc. + * Author: Patrick Keroulas <patrick.keroulas@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 "presencemanager.h" + +#include <cerrno> +#include <sstream> + +#include "logger.h" +#include "sip/sipaccount.h" +#include "manager.h" +#include "sip/sippresence.h" +#include "sip/pres_sub_client.h" + +namespace { + constexpr static const char* SERVER_PATH = "/org/sflphone/SFLphone/PresenceManager"; + constexpr static const char* STATUS_KEY = "Status"; + constexpr static const char* LINESTATUS_KEY = "LineStatus"; + constexpr static const char* ONLINE_KEY = "Online"; + constexpr static const char* OFFLINE_KEY = "Offline"; +} + +PresenceManager::PresenceManager(DBus::Connection& connection) : + DBus::ObjectAdaptor(connection, SERVER_PATH) +{} + +/** + * Un/subscribe to buddySipUri for an accountID + */ +void +PresenceManager::subscribeBuddy(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()->subscribeClient(uri,flag); + } +} + +/** + * push a presence for a account + * Notify for IP2IP account and publish for PBX account + */ +void +PresenceManager::publish(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 +PresenceManager::answerServerRequest(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); + } +} + +/** + * Get all active subscriptions for "accountID" + */ +std::vector<std::map<std::string, std::string> > +PresenceManager::getSubscriptions(const std::string& accountID) +{ + std::vector<std::map<std::string, std::string> > ret; + SIPAccount *sipaccount = Manager::instance().getSipAccount(accountID); + if (sipaccount) { + for (auto s : sipaccount->getPresence()->getClientSubscriptions()) { + std::map<std::string, std::string> sub; + sub[ STATUS_KEY ] = s->isPresent()?ONLINE_KEY:OFFLINE_KEY; + sub[ LINESTATUS_KEY ] = s->getLineStatus(); + ret.push_back(sub); + } + } + return ret; +} + +/** + * Batch subscribing of URIs + */ +void +PresenceManager::setSubscriptions(const std::string& accountID, const std::vector<std::string>& uris) +{ + SIPAccount *sipaccount = Manager::instance().getSipAccount(accountID); + for (auto u:uris) { + sipaccount->getPresence()->subscribeClient(u,true); + } +} \ No newline at end of file diff --git a/daemon/src/client/presencemanager.h b/daemon/src/client/presencemanager.h new file mode 100644 index 0000000000000000000000000000000000000000..30d8890571ff8a9de64cf9995251b394da86a00f --- /dev/null +++ b/daemon/src/client/presencemanager.h @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2013 Savoir-Faire Linux Inc. + * Author: Patrick Keroulas <patrick.keroulas@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 PRESENCEINT_H +#define PRESENCEINT_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#if HAVE_DBUS + +#include "dbus/dbus_cpp.h" + +#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6 +#pragma GCC diagnostic ignored "-Wunused-but-set-variable" +#endif + +#pragma GCC diagnostic ignored "-Wignored-qualifiers" +#pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Weffc++" +#include "dbus/presencemanager-glue.h" +#pragma GCC diagnostic warning "-Wignored-qualifiers" +#pragma GCC diagnostic warning "-Wunused-parameter" +#pragma GCC diagnostic warning "-Weffc++" + +#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 6 +#pragma GCC diagnostic warning "-Wunused-but-set-variable" +#endif + +#else +// these includes normally come with DBus C++ +#include <vector> +#include <map> +#include <string> +#endif // HAVE_DBUS + +class PresenceManager +#if HAVE_DBUS + : public org::sflphone::SFLphone::PresenceManager_adaptor, + public DBus::IntrospectableAdaptor, + public DBus::ObjectAdaptor +#endif +{ + public: +#if HAVE_DBUS + PresenceManager(DBus::Connection& connection); +#else + PresenceManager(); +#endif + +#ifdef __ANDROID__ + void newBuddySubscription(const std::string& uri, const std::string& basic, const std::string& note); + void newServerSubscriptionRequest(const std::string& remote); +#endif //__ANDROID__ + + /* Presence subscription/Notification. */ + void publish(const std::string& accountID, const bool& status, const std::string& note); + void answerServerRequest(const std::string& uri, const bool& flag); + void subscribeBuddy(const std::string& accountID, const std::string& uri, const bool& flag); + std::vector<std::map<std::string, std::string> > getSubscriptions(const std::string& accountID); + void setSubscriptions(const std::string& accountID, const std::vector<std::string>& uris); + +}; + +#endif //CONFIGURATIONMANAGER_H diff --git a/daemon/src/sip/pres_sub_client.cpp b/daemon/src/sip/pres_sub_client.cpp index f0f89743ad25e89e3c60d697990ebc2ce9b78878..d853de066e6f69fccda067f710135a1840f3ce9f 100644 --- a/daemon/src/sip/pres_sub_client.cpp +++ b/daemon/src/sip/pres_sub_client.cpp @@ -298,6 +298,14 @@ std::string PresSubClient::getURI() { return res; } +bool PresSubClient::isPresent() { + return status.info[0].basic_open; +} + +std::string PresSubClient::getLineStatus() { + return std::string(status.info[0].rpid.note.ptr,status.info[0].rpid.note.slen); +} + bool PresSubClient::isTermReason(std::string reason) { std::string myReason(term_reason.ptr, term_reason.slen); return !myReason.compare(reason); diff --git a/daemon/src/sip/pres_sub_client.h b/daemon/src/sip/pres_sub_client.h index 7fa31f1da5626edfc39fe5de7ee6afa8ef765a63..86ff282dca96d1521940f59a52befc69c5462f38 100644 --- a/daemon/src/sip/pres_sub_client.h +++ b/daemon/src/sip/pres_sub_client.h @@ -101,6 +101,16 @@ class PresSubClient { */ std::string getURI(); + /** + * Is the URI present + */ + bool isPresent(); + + /** + * A message from the URIs + */ + std::string getLineStatus(); + friend void pres_client_evsub_on_state(pjsip_evsub *sub, pjsip_event *event); friend void pres_client_evsub_on_tsx_state(pjsip_evsub *sub, diff --git a/daemon/src/sip/pres_sub_server.cpp b/daemon/src/sip/pres_sub_server.cpp index efc8ebd4122cbfc2ce747e18440386f35ce125ab..9d239a54d115c66f8c2e84f7a03287c21b6134e4 100644 --- a/daemon/src/sip/pres_sub_server.cpp +++ b/daemon/src/sip/pres_sub_server.cpp @@ -154,7 +154,7 @@ pj_bool_t pres_on_rx_subscribe_request(pjsip_rx_data *rdata) { /* Create a new PresSubServer server and wait for client approve */ PresSubServer *presSubServer = new PresSubServer(pres, sub, remote, dlg); pjsip_evsub_set_mod_data(sub, pres->getModId(), presSubServer); - pres->reportNewPresSubServerRequest(presSubServer); // Notify the client. + pres->reportnewServerSubscriptionRequest(presSubServer); // Notify the client. pres->addPresSubServer(presSubServer); /* Capture the value of Expires header. */ 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 6472f9bea5406da98dc189bd6fe4b78b30255787..ea259b3d6a0e08f19371d82743567f0a8f49e4d6 100644 --- a/daemon/src/sip/sippresence.cpp +++ b/daemon/src/sip/sippresence.cpp @@ -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" @@ -78,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_; } @@ -138,12 +139,12 @@ void SIPPresence::reportPresSubClientNotification(const std::string& uri, pjsip_ /* Update our info. See pjsua_buddy_get_info() for additionnal ideas*/ const std::string basic(status->info[0].basic_open ? "open" : "closed"); 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()); + DEBUG(" Received status of PresSubClient %s: status=%s note=%s",uri.c_str(),(status->info[0].basic_open?"open":"closed"),note.c_str()); /* report status to client signal */ - Manager::instance().getClient()->getCallManager()->newPresSubClientNotification(uri, basic, note); + Manager::instance().getClient()->getPresenceManager()->newBuddySubscription(uri, status->info[0].basic_open, note); } -void SIPPresence::subscribePresSubClient(const std::string& uri, const bool& flag){ +void SIPPresence::subscribeClient(const std::string& uri, const bool& flag){ /* Check if the buddy was already subscribed */ for(auto c : pres_sub_client_list_) if(c->getURI()==uri){ @@ -185,8 +186,8 @@ void SIPPresence::removePresSubClient(PresSubClient *c){ } -void SIPPresence::reportNewPresSubServerRequest(PresSubServer *s){ - Manager::instance().getClient()->getCallManager()->newPresSubServerRequest(s->remote); +void SIPPresence::reportnewServerSubscriptionRequest(PresSubServer *s){ + Manager::instance().getClient()->getPresenceManager()->newServerSubscriptionRequest(s->remote); } void SIPPresence::approvePresSubServer(const std::string& uri, const bool& flag){ diff --git a/daemon/src/sip/sippresence.h b/daemon/src/sip/sippresence.h index 9e7a7b0ae11d1703663fd00bde70c47f59e054af..af8e565428571ce1c1392baa3ef135cb6094b55a 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) */ @@ -158,7 +158,7 @@ public: * Send a SUBSCRIBE request to PBX/IP2IP * @param buddyUri Remote user that we want to subscribe */ - void subscribePresSubClient(const std::string& uri, const bool& flag); + void subscribeClient(const std::string& uri, const bool& flag); /** * Add a buddy in the buddy list. * @param b PresSubClient pointer @@ -175,7 +175,7 @@ public: * Report new Subscription to the client, waiting for approval. * @param s PresenceSubcription pointer. */ - void reportNewPresSubServerRequest(PresSubServer *s); + void reportnewServerSubscriptionRequest(PresSubServer *s); /** * IP2IP context. * Process new subscription based on client decision. @@ -201,6 +201,14 @@ public: */ void notifyPresSubServer(); + bool isEnabled() const { + return enabled; + } + + const std::list< PresSubClient *> getClientSubscriptions() { + return pres_sub_client_list_; + } + /** * Lock methods */ diff --git a/kde b/kde index 39ec90aec140f3184b298c6de670183421e66bff..9531d976a881db54215ccad42752b09e51995e8e 160000 --- a/kde +++ b/kde @@ -1 +1 @@ -Subproject commit 39ec90aec140f3184b298c6de670183421e66bff +Subproject commit 9531d976a881db54215ccad42752b09e51995e8e