[ekiga] Added back the support for the old opal presence api



commit 9345f23cdade23a97c371581fd19db86fda8e0e4
Author: Julien Puydt <jpuydt gnome org>
Date:   Thu Sep 30 18:01:38 2010 +0200

    Added back the support for the old opal presence api
    
    This sort of works sometimes... I still have to investigate why it is so
    unreliable.

 lib/engine/components/opal/sip-endpoint.cpp |   25 +++++++++++++++++++------
 lib/engine/components/opal/sip-endpoint.h   |    7 +++++++
 2 files changed, 26 insertions(+), 6 deletions(-)
---
diff --git a/lib/engine/components/opal/sip-endpoint.cpp b/lib/engine/components/opal/sip-endpoint.cpp
index 4ffe661..46cd94c 100644
--- a/lib/engine/components/opal/sip-endpoint.cpp
+++ b/lib/engine/components/opal/sip-endpoint.cpp
@@ -274,12 +274,14 @@ Opal::Sip::EndPoint::menu_builder_add_actions (const std::string& fullname,
 void
 Opal::Sip::EndPoint::fetch (const std::string uri)
 {
+  /* this is for the new opal presence api */
   PSafePtr<OpalPresentity> presentity = manager.AddPresentity (uri);
-
   presentity->SetPresenceChangeNotifier (PCREATE_PresenceChangeNotifier(OnPresenceChange));
-
   presentity->Open ();
 
+  /* this is for the old opal presence api */
+  Subscribe (SIPSubscribe::Presence, 300, uri);
+
   Subscribe (SIPSubscribe::Dialog, 300, uri);
 }
 
@@ -287,8 +289,12 @@ Opal::Sip::EndPoint::fetch (const std::string uri)
 void
 Opal::Sip::EndPoint::unfetch (const std::string uri)
 {
+  /* this is for the new opal presence api */
   manager.RemovePresentity (uri);
 
+  /* this is for the old opal presence api */
+  Subscribe (SIPSubscribe::Presence, 0, uri);
+
   Subscribe (SIPSubscribe::Dialog, 0, uri);
 }
 
@@ -1005,11 +1011,22 @@ Opal::Sip::EndPoint::GetRegisteredPartyName (const SIPURL & aor,
   return GetDefaultRegisteredPartyName (transport);
 }
 
+void
+Opal::Sip::EndPoint::OnPresenceInfoReceived (const SIPPresenceInfo& info)
+{
+  treat_presence_info (info);
+}
 
 void
 Opal::Sip::EndPoint::OnPresenceChange (OpalPresentity& /*presentity*/,
 				       const OpalPresenceInfo& info)
 {
+  treat_presence_info (info);
+}
+
+void
+Opal::Sip::EndPoint::treat_presence_info (const OpalPresenceInfo& info)
+{
   std::string presence = "unknown";
   std::string status;
 
@@ -1086,10 +1103,6 @@ Opal::Sip::EndPoint::OnPresenceChange (OpalPresentity& /*presentity*/,
   std::string old_presence = presence_infos[_uri].presence;
   std::string old_status = presence_infos[_uri].status;
 
-  std::cout << "I got presence for " << _uri
-	    << " and state is " << info.m_state
-	    << std::endl;
-
   // If first notification, and no information, then we are offline
   if (presence == "unknown" && old_presence.empty ())
     presence = "offline";
diff --git a/lib/engine/components/opal/sip-endpoint.h b/lib/engine/components/opal/sip-endpoint.h
index 1816cb0..133c2ed 100644
--- a/lib/engine/components/opal/sip-endpoint.h
+++ b/lib/engine/components/opal/sip-endpoint.h
@@ -179,8 +179,15 @@ namespace Opal {
                                  unsigned options,
                                  OpalConnection::StringOptions * stroptions);
 
+      /* new opal presence api -- doesn't work yet with ekiga.net */
       PDECLARE_PresenceChangeNotifier (EndPoint, OnPresenceChange);
 
+      /* old opal presence api -- the one which works with ekiga.net */
+      void OnPresenceInfoReceived (const SIPPresenceInfo& info);
+
+      /* common function to treat presence information coming from both opal presence api */
+      void treat_presence_info (const OpalPresenceInfo& info);
+
       void OnDialogInfoReceived (const SIPDialogNotification & info);
 
       PBoolean OnReceivedINVITE (OpalTransport & transport, SIP_PDU * pdu);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]