[ekiga] Presence: Only (un)fetch presence info for current account.



commit f716df15beeabe13a7ad56cb57eada872fd83158
Author: Damien Sandras <dsandras beip be>
Date:   Mon Dec 26 12:35:23 2011 +0100

    Presence: Only (un)fetch presence info for current account.
    
    Fixes bug reported by Eugen where unsubscribing from any account would
    unsubscribe presence information for all accounts.

 lib/engine/components/opal/opal-account.cpp |   37 ++++++++++++++++----------
 lib/engine/components/opal/opal-account.h   |    1 +
 2 files changed, 24 insertions(+), 14 deletions(-)
---
diff --git a/lib/engine/components/opal/opal-account.cpp b/lib/engine/components/opal/opal-account.cpp
index bfadc4f..5643526 100644
--- a/lib/engine/components/opal/opal-account.cpp
+++ b/lib/engine/components/opal/opal-account.cpp
@@ -511,6 +511,22 @@ Opal::Account::on_consult (const std::string url)
   gm_open_uri (url.c_str ());
 }
 
+
+bool
+Opal::Account::is_myself (const std::string uri) const
+{
+  size_t pos = uri.find ("@");
+  if (pos == string::npos)
+    return false;
+
+  std::string uri_host = uri.substr (++pos);
+  if (uri_host != get_host ())
+    return false;
+
+  return true;
+}
+
+
 void
 Opal::Account::publish (const Ekiga::PersonalDetails& details)
 {
@@ -536,33 +552,26 @@ Opal::Account::publish (const Ekiga::PersonalDetails& details)
   }
 }
 
+
 void
 Opal::Account::fetch (const std::string uri)
 {
-  watched_uris.insert (uri); // URI will be watched, but we only subscribe for
-                             // presence information if the account is enabled
-
   if (!is_enabled ())
     return;
 
-  size_t pos = uri.find ("@");
-  if (pos == string::npos)
-    return;
-
-  std::string uri_host = uri.substr (++pos);
-  if (uri_host != get_host ())
-    return;
-
-  if (presentity)
+  if (is_myself (uri) && presentity) {
     presentity->SubscribeToPresence (PString (uri));
+    watched_uris.insert (uri);
+  }
 }
 
 void
 Opal::Account::unfetch (const std::string uri)
 {
-  watched_uris.erase (uri);
-  if (presentity)
+  if (is_myself (uri) && presentity) {
     presentity->UnsubscribeFromPresence (PString (uri));
+    watched_uris.erase (uri);
+  }
 }
 
 void
diff --git a/lib/engine/components/opal/opal-account.h b/lib/engine/components/opal/opal-account.h
index 5faaf8c..a22243e 100644
--- a/lib/engine/components/opal/opal-account.h
+++ b/lib/engine/components/opal/opal-account.h
@@ -175,6 +175,7 @@ private:
     void on_edit_form_submitted (bool submitted,
 				 Ekiga::Form &result);
     void on_consult (const std::string url);
+    bool is_myself (const std::string uri) const;
 
     mutable RegistrationState state;
     bool dead;



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