[ekiga] Accounts: Added a way to identify failed accounts.



commit 5d5250b140a2c4ec3107054a821711a091bdb7a1
Author: Damien Sandras <dsandras beip be>
Date:   Sun Apr 1 15:04:24 2012 +0200

    Accounts: Added a way to identify failed accounts.
    
    Formerly, an account that was active and in Processing state was
    considered a failed, which is not correct.
    
    Modifying the is_active method to handle that case would not be a good
    idea, because an enabled account in processing state is actually not
    active but not failed either.

 lib/engine/account/account.h                |    7 +++++++
 lib/engine/components/opal/opal-account.cpp |    9 +++++++++
 lib/engine/components/opal/opal-account.h   |    3 +++
 3 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/lib/engine/account/account.h b/lib/engine/account/account.h
index 93a1b91..cda15a0 100644
--- a/lib/engine/account/account.h
+++ b/lib/engine/account/account.h
@@ -93,6 +93,13 @@ namespace Ekiga
      * @return Whether the account is active
      */
     virtual bool is_active () const = 0;
+
+
+    /** Returns a boolean indicating whether the account is in a failure state.
+     *
+     * @return Whether the account is in a failure state
+     */
+    virtual bool is_failed () const = 0;
   };
 
   typedef boost::shared_ptr<Account> AccountPtr;
diff --git a/lib/engine/components/opal/opal-account.cpp b/lib/engine/components/opal/opal-account.cpp
index efa147c..3367e80 100644
--- a/lib/engine/components/opal/opal-account.cpp
+++ b/lib/engine/components/opal/opal-account.cpp
@@ -301,6 +301,7 @@ void Opal::Account::enable ()
 {
   enabled = true;
 
+  state = Processing;
   status = _("Processing...");
   endpoint->subscribe (*this, presentity);
 
@@ -362,6 +363,14 @@ bool Opal::Account::is_active () const
   return (state == Registered);
 }
 
+bool Opal::Account::is_failed () const
+{
+  if (!enabled)
+    return false;
+
+  return (is_enabled () && state == RegistrationFailed);
+}
+
 
 SIPRegister::CompatibilityModes Opal::Account::get_compat_mode () const
 {
diff --git a/lib/engine/components/opal/opal-account.h b/lib/engine/components/opal/opal-account.h
index a22243e..6c9989a 100644
--- a/lib/engine/components/opal/opal-account.h
+++ b/lib/engine/components/opal/opal-account.h
@@ -137,6 +137,8 @@ public:
 
     bool is_active () const;
 
+    bool is_failed () const;
+
     SIPRegister::CompatibilityModes get_compat_mode () const;
 
     void remove ();
@@ -180,6 +182,7 @@ private:
     mutable RegistrationState state;
     bool dead;
     bool enabled;
+    bool failed;
     mutable SIPRegister::CompatibilityModes compat_mode;
     unsigned timeout;
     std::string aid;



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