[ekiga] OpalAccount: Fixed various problems.



commit 76eaaafb4d6a90648bcd0fa5279a95788f0060e0
Author: Damien Sandras <dsandras beip be>
Date:   Sun Sep 23 13:28:35 2012 +0200

    OpalAccount: Fixed various problems.
    
    Ekiga was freezing, crashing or similar in various cases. They have
    been fixed:
    - Removing an account works
    - Enabling/disabling an account now works
    
    The roster is correctly updated as it should.

 lib/engine/components/opal/opal-account.cpp |   31 ++++++++++++--------------
 lib/engine/components/opal/opal-account.h   |    6 ++--
 2 files changed, 17 insertions(+), 20 deletions(-)
---
diff --git a/lib/engine/components/opal/opal-account.cpp b/lib/engine/components/opal/opal-account.cpp
index 7259da4..993ef75 100644
--- a/lib/engine/components/opal/opal-account.cpp
+++ b/lib/engine/components/opal/opal-account.cpp
@@ -310,27 +310,25 @@ void Opal::Account::disable ()
 {
   enabled = false;
 
-  // Translators: this is a state, not an action, i.e. it should be read as
-  // "(you are) unregistered", and not as "(you have been) unregistered"
-  status = _("Unregistered");
-
-  updated ();
-  trigger_saving ();
-
   // the above change is needed because if we are already not
   // registered (because a registration failed, for example), then the
   // next action won't change the status.
-  endpoint->unsubscribe (*this, presentity);
   if (presentity) {
 
-    // FIXME : the following actions should probably be done by opal itself,
-    // remembering what ekiga asked...
     for (std::set<std::string>::iterator iter = watched_uris.begin ();
          iter != watched_uris.end (); ++iter) {
       presentity->UnsubscribeFromPresence (PString (*iter));
-      Ekiga::Runtime::run_in_main (boost::bind (&Opal::Account::presence_status_in_main, this, (*iter), "unknown", ""));
+      Ekiga::Runtime::run_in_main (boost::bind (&Opal::Account::presence_status_in_main, this, *iter, "unknown", ""));
     }
   }
+  endpoint->unsubscribe (*this, presentity);
+
+  // Translators: this is a state, not an action, i.e. it should be read as
+  // "(you are) unregistered", and not as "(you have been) unregistered"
+  status = _("Unregistered");
+
+  updated ();
+  trigger_saving ();
 }
 
 
@@ -357,14 +355,10 @@ SIPRegister::CompatibilityModes Opal::Account::get_compat_mode () const
 
 void Opal::Account::remove ()
 {
+  disable();
   dead = true;
 
-  endpoint->unsubscribe (*this, presentity);
-
-  if (!enabled)
-    removed ();
   trigger_saving ();
-  enabled = false;
 }
 
 
@@ -571,6 +565,7 @@ Opal::Account::unfetch (const std::string uri)
   if (is_myself (uri) && presentity) {
     presentity->UnsubscribeFromPresence (PString (uri));
     watched_uris.erase (uri);
+    Ekiga::Runtime::run_in_main (boost::bind (&Opal::Account::presence_status_in_main, this, uri, "unknown", ""));
   }
 }
 
@@ -782,9 +777,11 @@ Opal::Account::OnPresenceChange (OpalPresentity& /*presentity*/,
       }
     }
     break;
+  case OpalPresenceInfo::NoPresence:
+    new_presence = "unknown";
+    break;
   case OpalPresenceInfo::InternalError:
   case OpalPresenceInfo::Forbidden:
-  case OpalPresenceInfo::NoPresence:
   case OpalPresenceInfo::Unavailable:
   case OpalPresenceInfo::UnknownExtended:
     new_presence = "offline";
diff --git a/lib/engine/components/opal/opal-account.h b/lib/engine/components/opal/opal-account.h
index eb39e2a..54c274c 100644
--- a/lib/engine/components/opal/opal-account.h
+++ b/lib/engine/components/opal/opal-account.h
@@ -200,9 +200,9 @@ private:
 
     PDECLARE_PresenceChangeNotifier (Account, OnPresenceChange);
 
-    std::set<std::string> watched_uris; // FIXME: that is wrong... the opal code should do that!
-    OpalPresenceInfo::State personal_state; // FIXME: shouldn't the opal code do that too?
-    std::string presence_status; // FIXME: shouldn't the opal code do that too?
+    std::set<std::string> watched_uris;
+    OpalPresenceInfo::State personal_state;
+    std::string presence_status;
     void presence_status_in_main (std::string uri,
 				  std::string presence,
 				  std::string status);



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