ekiga r6608 - in trunk: . src/endpoints



Author: dsandras
Date: Thu Aug 14 10:33:37 2008
New Revision: 6608
URL: http://svn.gnome.org/viewvc/ekiga?rev=6608&view=rev

Log:
Do not used OPAL methods anymore when checking for alive subscribes.
Patch from MD.


Modified:
   trunk/ChangeLog
   trunk/src/endpoints/sip-endpoint.cpp
   trunk/src/endpoints/sip-endpoint.h

Modified: trunk/src/endpoints/sip-endpoint.cpp
==============================================================================
--- trunk/src/endpoints/sip-endpoint.cpp	(original)
+++ trunk/src/endpoints/sip-endpoint.cpp	Thu Aug 14 10:33:37 2008
@@ -299,23 +299,28 @@
   if (loc != string::npos) 
     domain = _uri.substr (loc+1);
 
-  if (std::find (subscribed_uris.begin (), subscribed_uris.end (), _uri) == subscribed_uris.end ())
-    subscribed_uris.push_back (_uri);
+  // It is not in the list of uris for which a subscribe is active
+  if (std::find (subscribed_uris.begin (), subscribed_uris.end (), _uri) == subscribed_uris.end ()) {
 
-  if (std::find (domains.begin (), domains.end (), domain) != domains.end ()
-      && !IsSubscribed (SIPSubscribe::Presence, _uri.c_str ())) {
+    // We are registered yet
+    if (std::find (domains.begin (), domains.end (), domain) != domains.end ()) {
 
-    Subscribe (SIPSubscribe::Presence, 1800, PString (_uri.c_str ()));
+      Subscribe (SIPSubscribe::Presence, 1800, PString (_uri.c_str ()));
+      subscribed_uris.push_back (_uri);
+    }
+    else {
+     
+      to_subscribe_uris.push_back (_uri);
+    }
   }
 }
 
 
 void Opal::Sip::EndPoint::unfetch (const std::string uri)
 {
-  if (IsSubscribed (SIPSubscribe::Presence, uri.c_str ())) {
+  if (std::find (subscribed_uris.begin (), subscribed_uris.end (), uri) != subscribed_uris.end ()) {
 
     Subscribe (SIPSubscribe::Presence, 0, PString (uri.c_str ()));
-
     subscribed_uris.remove (uri);
   }
 }
@@ -603,6 +608,7 @@
       aors.remove (strm.str ());
   }
 
+  std::cout << "OnREGISTERED" << std::endl << std::flush;
   if (loc != string::npos) {
 
     server = aor.substr (loc+1);
@@ -616,18 +622,39 @@
     if (!was_registering && std::find (domains.begin (), domains.end (), server) != domains.end ()) 
       domains.remove (server);
 
-    for (std::list<std::string>::const_iterator iter = subscribed_uris.begin (); 
-         iter != subscribed_uris.end () ; 
-         iter++) {
-
-      found = (*iter).find (server, 0);
-      if (found != string::npos
-          && ((was_registering && !IsSubscribed (SIPSubscribe::Presence, (*iter).c_str ()))
-              || (!was_registering && IsSubscribed (SIPSubscribe::Presence, (*iter).c_str ())))) {
+    if (was_registering) {
+      for (std::list<std::string>::const_iterator iter = to_subscribe_uris.begin (); 
+           iter != to_subscribe_uris.end () ; 
+           iter++) {
+
+        std::cout << "Will search for " << (*iter) << std::endl << std::flush;
+        found = (*iter).find (server, 0);
+        std::cout << "DONE SEARCH" << std::endl << std::flush;
+        if (found != string::npos) {
+
+          std::cout << "NEW Subscribing presence for " << _aor << std::endl << std::flush;
+          Subscribe (SIPSubscribe::Presence, 500, PString ((*iter).c_str ()));
+          subscribed_uris.push_back (*iter);
+          to_subscribe_uris.remove (*iter);
+          std::cout << "DONE SUBSCRIBE" << std::endl << std::flush;
+          iter = to_subscribe_uris.begin ();
+        }
+      }
+    }
+    else {
+      for (std::list<std::string>::const_iterator iter = subscribed_uris.begin (); 
+           iter != subscribed_uris.end () ; 
+           iter++) {
+
+        found = (*iter).find (server, 0);
+        if (found != string::npos) {
 
-        Subscribe (SIPSubscribe::Presence, was_registering ? 500 : 0, PString ((*iter).c_str ()));
-        if (!was_registering)
+          std::cout << "UNSubscribing presence for " << _aor << std::endl << std::flush;
+          Subscribe (SIPSubscribe::Presence, 0, PString ((*iter).c_str ()));
           subscribed_uris.remove (*iter);
+          to_subscribe_uris.push_back (*iter);
+          iter = subscribed_uris.begin ();
+        }
       }
     }
   }

Modified: trunk/src/endpoints/sip-endpoint.h
==============================================================================
--- trunk/src/endpoints/sip-endpoint.h	(original)
+++ trunk/src/endpoints/sip-endpoint.h	Thu Aug 14 10:33:37 2008
@@ -173,9 +173,10 @@
 
       CallManager & manager;
 
+      std::list<std::string> to_subscribe_uris;  // List of uris to subscribe
       std::list<std::string> subscribed_uris;    // List of subscribed uris
-      std::list<std::string> domains; // List of registered domains
-      std::list<std::string> aors;     // List of registered aor
+      std::list<std::string> domains;            // List of registered domains
+      std::list<std::string> aors;               // List of registered aor
       Ekiga::ServiceCore & core;
       Ekiga::PresenceCore & presence_core;
       Ekiga::Runtime & runtime;



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