[ekiga] Added is_active method to the API.



commit 1f96a9cc302a684272c77773bf84391745a6dab6
Author: Damien Sandras <dsandras seconix com>
Date:   Sun Oct 25 16:14:09 2009 +0100

    Added is_active method to the API.
    
    This method is supposed to help determining if an account is in a good state
    or not. Having an account enabled does not mean it is active. This is the
    reason why we need another method to help with this.

 lib/engine/account/account.h                |   10 ++++++++++
 lib/engine/components/opal/opal-account.cpp |   10 ++++++++++
 lib/engine/components/opal/opal-account.h   |    2 ++
 plugins/loudmouth/loudmouth-account.cpp     |    9 +++++++++
 plugins/loudmouth/loudmouth-account.h       |    2 ++
 5 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/lib/engine/account/account.h b/lib/engine/account/account.h
index c5688c1..029a313 100644
--- a/lib/engine/account/account.h
+++ b/lib/engine/account/account.h
@@ -86,6 +86,16 @@ namespace Ekiga
     virtual bool is_enabled () const = 0;
 
 
+    /** Returns a boolean indicating whether the account is active.
+     * An account can be enabled but inactive. It can happen if
+     * the connection to the server failed (for example).
+     * This method returns true if the account is in a sane state.
+     *
+     * @return Whether the account is active
+     */
+    virtual bool is_active () const = 0;
+
+
     /** Create the menu for that account and its actions.
      * This function is purely virtual and should be implemented by
      * the descendant of the Ekiga::Contact.
diff --git a/lib/engine/components/opal/opal-account.cpp b/lib/engine/components/opal/opal-account.cpp
index d070c28..4171400 100644
--- a/lib/engine/components/opal/opal-account.cpp
+++ b/lib/engine/components/opal/opal-account.cpp
@@ -309,6 +309,15 @@ bool Opal::Account::is_enabled () const
 }
 
 
+bool Opal::Account::is_active () const
+{
+  if (!enabled)
+    return false;
+
+  return (state == Registered);
+}
+
+
 bool Opal::Account::is_limited () const
 {
   return limited;
@@ -465,6 +474,7 @@ Opal::Account::on_consult (const std::string url)
   gm_open_uri (url.c_str ());
 }
 
+
 void
 Opal::Account::handle_registration_event (RegistrationState state_,
 					  const std::string info) const
diff --git a/lib/engine/components/opal/opal-account.h b/lib/engine/components/opal/opal-account.h
index 9ab7155..30f6252 100644
--- a/lib/engine/components/opal/opal-account.h
+++ b/lib/engine/components/opal/opal-account.h
@@ -128,6 +128,8 @@ public:
 
     bool is_enabled () const;
 
+    bool is_active () const;
+
     bool is_limited () const;
 
     void remove ();
diff --git a/plugins/loudmouth/loudmouth-account.cpp b/plugins/loudmouth/loudmouth-account.cpp
index 43bc5b3..ad5ee1d 100644
--- a/plugins/loudmouth/loudmouth-account.cpp
+++ b/plugins/loudmouth/loudmouth-account.cpp
@@ -395,6 +395,15 @@ LM::Account::is_enabled () const
   return result;
 }
 
+bool
+LM::Account::is_active () const
+{
+  if (!is_enabled ())
+    return false;
+
+  return true; // Isn't there a way to know if an account is active?
+}
+
 const std::string
 LM::Account::get_name () const
 {
diff --git a/plugins/loudmouth/loudmouth-account.h b/plugins/loudmouth/loudmouth-account.h
index 80cfdfc..0d681b7 100644
--- a/plugins/loudmouth/loudmouth-account.h
+++ b/plugins/loudmouth/loudmouth-account.h
@@ -69,6 +69,8 @@ namespace LM
 
     bool is_enabled () const;
 
+    bool is_active () const;
+
     bool populate_menu (Ekiga::MenuBuilder& builder);
 
     /* public only to be called by C callbacks */



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