ekiga r6570 - in trunk: lib/engine/account/skel src/endpoints



Author: dsandras
Date: Mon Aug 11 18:48:57 2008
New Revision: 6570
URL: http://svn.gnome.org/viewvc/ekiga?rev=6570&view=rev

Log:
Sanitized signals logic, the registration_event signal is now emitted
by the Account. Fixed is_active method so that it only returns true
when the account is really active.


Modified:
   trunk/lib/engine/account/skel/account-core.cpp
   trunk/lib/engine/account/skel/account-core.h
   trunk/lib/engine/account/skel/account.h
   trunk/lib/engine/account/skel/bank-impl.h
   trunk/lib/engine/account/skel/bank.h
   trunk/src/endpoints/h323-endpoint.cpp
   trunk/src/endpoints/opal-account.cpp
   trunk/src/endpoints/opal-account.h

Modified: trunk/lib/engine/account/skel/account-core.cpp
==============================================================================
--- trunk/lib/engine/account/skel/account-core.cpp	(original)
+++ trunk/lib/engine/account/skel/account-core.cpp	Mon Aug 11 18:48:57 2008
@@ -89,6 +89,7 @@
   bank_added.emit (bank);
 
   bank.questions.add_handler (questions.make_slot ());
+  bank.registration_event.connect (sigc::mem_fun (this, &Ekiga::AccountCore::on_registration_event));
 }
 
 
@@ -116,8 +117,6 @@
 void Ekiga::AccountCore::add_account_subscriber (AccountSubscriber &subscriber)
 {
   account_subscribers.insert (&subscriber);
-
-  subscriber.registration_event.connect (sigc::mem_fun (this, &Ekiga::AccountCore::on_registration_event));
 }
 
 

Modified: trunk/lib/engine/account/skel/account-core.h
==============================================================================
--- trunk/lib/engine/account/skel/account-core.h	(original)
+++ trunk/lib/engine/account/skel/account-core.h	Mon Aug 11 18:48:57 2008
@@ -192,6 +192,7 @@
     template<class T>
     bool unsubscribe_account (const T &account);
 
+    /*** Misc ***/
   private:
     std::set<AccountSubscriber *> account_subscribers;
     typedef std::set<AccountSubscriber *>::iterator subscriber_iterator;
@@ -206,13 +207,6 @@
   {
 public:
     virtual ~AccountSubscriber () {}
-
-    /** This signal is emitted when there is a new registration event
-     * @param: account is the account 
-     *         state is the state
-     *         info contains information about the registration status
-     */
-    sigc::signal<void, const Ekiga::Account *, Ekiga::AccountCore::RegistrationState, std::string> registration_event;
   };
 
 

Modified: trunk/lib/engine/account/skel/account.h
==============================================================================
--- trunk/lib/engine/account/skel/account.h	(original)
+++ trunk/lib/engine/account/skel/account.h	Mon Aug 11 18:48:57 2008
@@ -41,6 +41,8 @@
 #include <map>
 #include <string>
 
+#include "account-core.h"
+
 #include "chain-of-responsibility.h"
 #include "form-request.h"
 #include "menu-builder.h"
@@ -57,6 +59,7 @@
   {
   public:
 
+
     /** The destructor.
      */
     virtual ~Account () { }
@@ -138,13 +141,20 @@
     virtual void disable () = 0;
 
 
-    /** Return true if the account is active.
+    /** Return true if the account is enabled.
      * It does not mean that the account is successfully registered, it
-     * just means it is active.
+     * just means it is enabled.
      * This function is purely virtual and should be implemented by the
      * Ekiga::Account descendant.
      */
     virtual bool is_enabled () const = 0;
+
+
+    /** Return true if the account is active.
+     * This function is purely virtual and should be implemented by the
+     * Ekiga::Account descendant.
+     */
+    virtual bool is_active () const = 0;
     
     
     /** Create the menu for that account and its actions.
@@ -169,6 +179,14 @@
     sigc::signal<void> removed;
 
 
+    /** This signal is emitted when there is a new registration event for 
+     *  the Account.
+     * @param: state is the state
+     *         info contains information about the registration status
+     */
+    sigc::signal<void, Ekiga::AccountCore::RegistrationState, std::string> registration_event;
+
+
     /** This chain allows the Account to present forms to the user
      */
     ChainOfResponsibility<FormRequest*> questions;

Modified: trunk/lib/engine/account/skel/bank-impl.h
==============================================================================
--- trunk/lib/engine/account/skel/bank-impl.h	(original)
+++ trunk/lib/engine/account/skel/bank-impl.h	Mon Aug 11 18:48:57 2008
@@ -154,6 +154,9 @@
   protected:
     ServiceCore & core;
     AccountCore *account_core;
+
+  private:
+    void on_registration_event (Ekiga::AccountCore::RegistrationState, std::string info, Ekiga::Account *account);
   };
 
 /**
@@ -294,6 +297,7 @@
 
   account.questions.add_handler (questions.make_slot ());
   account.trigger_saving.connect (sigc::mem_fun (this, &Ekiga::BankImpl<T>::save));
+  account.registration_event.connect (sigc::bind (sigc::mem_fun (this, &Ekiga::BankImpl<T>::on_registration_event), &account));
 }
 
 
@@ -304,4 +308,10 @@
   remove_object (account);
 }
 
+template<typename T>
+void
+Ekiga::BankImpl<T>::on_registration_event (Ekiga::AccountCore::RegistrationState state, std::string info, Ekiga::Account *account)
+{
+  registration_event.emit (account, state, info);
+}
 #endif

Modified: trunk/lib/engine/account/skel/bank.h
==============================================================================
--- trunk/lib/engine/account/skel/bank.h	(original)
+++ trunk/lib/engine/account/skel/bank.h	Mon Aug 11 18:48:57 2008
@@ -93,6 +93,12 @@
      */
     sigc::signal<void, Account &> account_updated;
 
+    /** This signal is emitted when there is a new registration event
+     * @param: account is the account 
+     *         state is the state
+     *         info contains information about the registration status
+     */
+    sigc::signal<void, const Ekiga::Account *, Ekiga::AccountCore::RegistrationState, std::string> registration_event;
 
     /** This chain allows the BankImpl to present forms to the user
      */

Modified: trunk/src/endpoints/h323-endpoint.cpp
==============================================================================
--- trunk/src/endpoints/h323-endpoint.cpp	(original)
+++ trunk/src/endpoints/h323-endpoint.cpp	Mon Aug 11 18:48:57 2008
@@ -333,13 +333,13 @@
         info = _("Failed");
 
       /* Signal */
-      runtime.run_in_main (sigc::bind (registration_event.make_slot (), &account,
+      runtime.run_in_main (sigc::bind (account.registration_event.make_slot (),
                                        Ekiga::AccountCore::RegistrationFailed,
                                        info));
     }
     else {
 
-      runtime.run_in_main (sigc::bind (registration_event.make_slot (), &account,
+      runtime.run_in_main (sigc::bind (account.registration_event.make_slot (),
                                        Ekiga::AccountCore::Registered,
                                        std::string ()));
     }
@@ -350,7 +350,7 @@
     RemoveAliasName (account.get_username ());
 
     /* Signal */
-    runtime.run_in_main (sigc::bind (registration_event.make_slot (), &account,
+    runtime.run_in_main (sigc::bind (account.registration_event.make_slot (),
                                      Ekiga::AccountCore::Unregistered,
                                      std::string ()));
   }

Modified: trunk/src/endpoints/opal-account.cpp
==============================================================================
--- trunk/src/endpoints/opal-account.cpp	(original)
+++ trunk/src/endpoints/opal-account.cpp	Mon Aug 11 18:48:57 2008
@@ -55,6 +55,7 @@
 : core (_core)
 {
   dead = false;
+  active = false;
 
   int i = 0;
   char *pch = strtok ((char *) account.c_str (), "|");
@@ -122,6 +123,8 @@
     type = Account::SIP;
   else 
     type = Account::H323;
+
+  registration_event.connect (sigc::mem_fun (this, &Opal::Account::on_registration_event));
 }
 
 
@@ -137,6 +140,7 @@
 : core (_core)
 {
   dead = false;
+  active = false;
   enabled = _enabled;
   aid = (const char *) PGloballyUniqueID ().AsString ();
   name = _name;
@@ -150,6 +154,8 @@
 
   if (enabled)
     enable ();
+
+  registration_event.connect (sigc::mem_fun (this, &Opal::Account::on_registration_event));
 }
 
 
@@ -269,7 +275,13 @@
   return enabled;
 }
 
-    
+
+bool Opal::Account::is_active () const
+{
+  return active;
+}
+
+
 void Opal::Account::remove ()
 {
   dead = true;
@@ -427,3 +439,11 @@
 {
   gm_open_uri (url.c_str ());
 }
+
+void Opal::Account::on_registration_event (Ekiga::AccountCore::RegistrationState state, std::string /*info*/)
+{
+  active = false;
+
+  if (state == Ekiga::AccountCore::Registered)
+    active = true;
+}

Modified: trunk/src/endpoints/opal-account.h
==============================================================================
--- trunk/src/endpoints/opal-account.h	(original)
+++ trunk/src/endpoints/opal-account.h	Mon Aug 11 18:48:57 2008
@@ -97,6 +97,8 @@
 
     bool is_enabled () const;
 
+    bool is_active () const;
+
     void remove ();
 
     void edit ();
@@ -110,8 +112,12 @@
 private:
     void on_edit_form_submitted (Ekiga::Form &result);
     void on_consult (const std::string url);
+    
+    // Triggered for our own event
+    void on_registration_event (Ekiga::AccountCore::RegistrationState state, std::string info);
 
     bool dead;
+    bool active;
     bool enabled;
     unsigned timeout;
     std::string aid;



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