diff --git a/daemon/src/dbus/callmanager-introspec.xml b/daemon/src/dbus/callmanager-introspec.xml index 6551f361894942a5aa1d0f010475f6e905fcd253..0b954e894561d692319307deba867efdeedeb4e8 100644 --- a/daemon/src/dbus/callmanager-introspec.xml +++ b/daemon/src/dbus/callmanager-introspec.xml @@ -814,5 +814,11 @@ <arg type="b" name="accepted" direction="in"/> </method> + <method name="subscribePresence" tp:name-for-bindings="subscribePresence"> + <tp:added version="0.9.7"/> + <arg type="s" name="accountID" direction="in"/> + <arg type="s" name="buddySipUri" direction="in"/> + </method> + </interface> </node> diff --git a/daemon/src/dbus/callmanager.cpp b/daemon/src/dbus/callmanager.cpp index 8afb4c2ae47dcdd54c3bf6830fd97e222d71c928..27c0a56321a630cc53afc9fd6adf24265a5ca687 100644 --- a/daemon/src/dbus/callmanager.cpp +++ b/daemon/src/dbus/callmanager.cpp @@ -403,3 +403,9 @@ 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 } +void +CallManager::subscribePresence(const std::string& accountID, const std::string& buddySipUri) +{ + DEBUG("subscribePresence"); + Manager::instance().subscribePresence(accountID,buddySipUri); +} diff --git a/daemon/src/dbus/callmanager.h b/daemon/src/dbus/callmanager.h index e99a72b6b0faa45d2ad97122b443c372ef454311..131772d30fd4e9c96a97b119f573f30c9e13a06b 100644 --- a/daemon/src/dbus/callmanager.h +++ b/daemon/src/dbus/callmanager.h @@ -127,6 +127,9 @@ class CallManager /* Instant messaging */ void sendTextMessage(const std::string& callID, const std::string& message); + /* Presence subscription */ + void subscribePresence(const std::string& accountID, const std::string& buddySipUri); + private: #if HAVE_ZRTP diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index 92258800f7d36cb758cf7dd48632bdc2bd3a8068..131cd82cd44fc5bc52578eead45d4761b3b08529 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -85,6 +85,8 @@ #include <sys/types.h> // mkdir(2) #include <sys/stat.h> // mkdir(2) +#include "sip/sipbuddy.h" + ManagerImpl::ManagerImpl() : preferences(), voipPreferences(), hookPreference(), audioPreference(), shortcutPreferences(), @@ -2893,3 +2895,11 @@ void ManagerImpl::startAudioDriverStream() sfl::ScopedLock lock(audioLayerMutex_); audiodriver_->startStream(); } + +void ManagerImpl::subscribePresence(const std::string& accountID, const std::string& buddySipUri) +{ + DEBUG("SubscribePresence "); + SIPAccount *account = Manager::instance().getSipAccount(accountID); + SIPBuddy *b = new SIPBuddy(buddySipUri, account); + b->subscribe(); +} diff --git a/daemon/src/managerimpl.h b/daemon/src/managerimpl.h index 2313256a21591649e28495d096916277440a03c7..bee04718c708666be25235860f775c2b2bd69df9 100644 --- a/daemon/src/managerimpl.h +++ b/daemon/src/managerimpl.h @@ -1041,6 +1041,11 @@ class ManagerImpl { void checkAudio(); + /** + * Subscribe to buddySipUri for an accountID + */ + void subscribePresence(const std::string& accountID, const std::string& buddySipUri); + private: NON_COPYABLE(ManagerImpl); diff --git a/daemon/src/sip/Makefile.am b/daemon/src/sip/Makefile.am index b960ace4a0e803ed256322123aaf6d187fdce291..0e681ebfe73a140df66a0773d8649f47e4a6d7e4 100644 --- a/daemon/src/sip/Makefile.am +++ b/daemon/src/sip/Makefile.am @@ -14,7 +14,11 @@ libsiplink_la_SOURCES = \ sipvoiplink.h \ siptransport.h \ sip_utils.cpp \ - sip_utils.h + sip_utils.h \ + sipbuddy.cpp \ + sipbuddy.h \ + sipvoip_pres.cpp \ + sipvoip_pres.h if BUILD_SDES libsiplink_la_SOURCES+= sdes_negotiator.cpp \ diff --git a/daemon/src/sip/sipvoiplink.cpp b/daemon/src/sip/sipvoiplink.cpp index 7e07835578f4159da55fbe2142cc23b7bf84aa12..98a6fb8bb40bda07889dadbbcba24f39fecdca43 100644 --- a/daemon/src/sip/sipvoiplink.cpp +++ b/daemon/src/sip/sipvoiplink.cpp @@ -78,6 +78,8 @@ #include <istream> #include <utility> // for std::pair #include <algorithm> +#include "sipvoip_pres.h" +#include"pjsip-simple/presence.h" using namespace sfl; @@ -442,6 +444,13 @@ pj_bool_t transaction_request_cb(pjsip_rx_data *rdata) } // end anonymous namespace /*************************************************************************************************/ +pjsip_endpoint * SIPVoIPLink::getEndpoint() { + return endpt_; +} + +pjsip_module * SIPVoIPLink::getMod() { + return &mod_ua_; +} SIPVoIPLink::SIPVoIPLink() : sipTransport(endpt_, cp_, pool_), sipAccountMap_(), sipCallMapMutex_(), sipCallMap_(), evThread_(this) @@ -500,6 +509,11 @@ SIPVoIPLink::SIPVoIPLink() : sipTransport(endpt_, cp_, pool_), sipAccountMap_(), TRY(pjsip_evsub_init_module(endpt_)); TRY(pjsip_xfer_init_module(endpt_)); +// aol changes + TRY(pjsip_pres_init_module(endpt_, pjsip_evsub_instance())); + TRY(pjsip_endpt_register_module(endpt_, &my_mod_pres)); +// aol changes end + static const pjsip_inv_callback inv_cb = { invite_session_state_changed_cb, outgoing_request_forked_cb, @@ -1539,6 +1553,12 @@ SIPVoIPLink::SIPStartCall(SIPCall *call) "calling %s", toUri.c_str()); return false; } +// aol + pj_str_t subj_hdr_name = pj_str("Subject"); + pjsip_hdr* subj_hdr = (pjsip_hdr*) pjsip_parse_hdr(dialog->pool, &subj_hdr_name, "Phone call", 10, NULL); + + pj_list_push_back(&dialog->inv_hdr, subj_hdr); +// aol if (pjsip_inv_create_uac(dialog, call->getLocalSDP()->getLocalSdpSession(), 0, &call->inv) != PJ_SUCCESS) { ERROR("Unable to create invite session for user agent client"); @@ -2315,3 +2335,6 @@ void setCallMediaLocal(SIPCall* call, const std::string &localIP) #endif } } // end anonymous namespace +int SIPVoIPLink::getModId() { + return mod_ua_.id; +} diff --git a/daemon/src/sip/sipvoiplink.h b/daemon/src/sip/sipvoiplink.h index b37c05f4c3deed1e6410398e34409c3f9366fe62..414f26861e656a15e602630fea3f3eb2c98a4e83 100644 --- a/daemon/src/sip/sipvoiplink.h +++ b/daemon/src/sip/sipvoiplink.h @@ -294,7 +294,9 @@ class SIPVoIPLink : public VoIPLink { std::string getAccountIdFromNameAndServer(const std::string &userName, const std::string &server) const; - + int getModId(); + pjsip_endpoint * getEndpoint(); + pjsip_module * getMod(); private: NON_COPYABLE(SIPVoIPLink);