ekiga r7242 - in trunk/lib/engine/addressbook: call-history evolution kab ldap skel



Author: jpuydt
Date: Thu Oct 16 18:33:32 2008
New Revision: 7242
URL: http://svn.gnome.org/viewvc/ekiga?rev=7242&view=rev

Log:
Use gmref_ptr to manage sources in the contact core

Modified:
   trunk/lib/engine/addressbook/call-history/history-main.cpp
   trunk/lib/engine/addressbook/evolution/evolution-main.cpp
   trunk/lib/engine/addressbook/kab/kab-main.cpp
   trunk/lib/engine/addressbook/ldap/ldap-main.cpp
   trunk/lib/engine/addressbook/skel/contact-core.cpp
   trunk/lib/engine/addressbook/skel/contact-core.h
   trunk/lib/engine/addressbook/skel/source.h

Modified: trunk/lib/engine/addressbook/call-history/history-main.cpp
==============================================================================
--- trunk/lib/engine/addressbook/call-history/history-main.cpp	(original)
+++ trunk/lib/engine/addressbook/call-history/history-main.cpp	Thu Oct 16 18:33:32 2008
@@ -53,7 +53,7 @@
 
     gmref_ptr<History::Source> source =  new History::Source (core);
     core.add (source);
-    contact_core->add_source (*source);
+    contact_core->add_source (source);
     result = true;
   }
 

Modified: trunk/lib/engine/addressbook/evolution/evolution-main.cpp
==============================================================================
--- trunk/lib/engine/addressbook/evolution/evolution-main.cpp	(original)
+++ trunk/lib/engine/addressbook/evolution/evolution-main.cpp	Thu Oct 16 18:33:32 2008
@@ -51,7 +51,7 @@
 
     gmref_ptr<Evolution::Source> source = new Evolution::Source (services);
     services.add (source);
-    core->add_source (*source);
+    core->add_source (source);
     result = true;
   }
 

Modified: trunk/lib/engine/addressbook/kab/kab-main.cpp
==============================================================================
--- trunk/lib/engine/addressbook/kab/kab-main.cpp	(original)
+++ trunk/lib/engine/addressbook/kab/kab-main.cpp	Thu Oct 16 18:33:32 2008
@@ -52,7 +52,7 @@
 
     gmref_ptr<KAB::Source> source = new KAB::Source (*contact_core);
     core.add (source);
-    contact_core->add_source (*source);
+    contact_core->add_source (source);
     result = true;
   }
 

Modified: trunk/lib/engine/addressbook/ldap/ldap-main.cpp
==============================================================================
--- trunk/lib/engine/addressbook/ldap/ldap-main.cpp	(original)
+++ trunk/lib/engine/addressbook/ldap/ldap-main.cpp	Thu Oct 16 18:33:32 2008
@@ -55,7 +55,7 @@
 
     gmref_ptr<OPENLDAP::Source> service = new OPENLDAP::Source (core);
     core.add (service);
-    contact_core->add_source (*service);
+    contact_core->add_source (service);
     sasl_client_init (NULL); // FIXME: shouldn't it be done by the source!?
     result = true;
   }

Modified: trunk/lib/engine/addressbook/skel/contact-core.cpp
==============================================================================
--- trunk/lib/engine/addressbook/skel/contact-core.cpp	(original)
+++ trunk/lib/engine/addressbook/skel/contact-core.cpp	Thu Oct 16 18:33:32 2008
@@ -57,9 +57,9 @@
   builder.add_action ("search", _("_Find"), sigc::ptr_fun (on_search));
   populated = true;
 
-  for (std::set<Source *>::const_iterator iter = sources.begin ();
+  for (std::list<gmref_ptr<Source> >::const_iterator iter = sources.begin ();
        iter != sources.end ();
-       iter++) {
+       ++iter) {
 
     if (populated)
       builder.add_separator ();
@@ -70,17 +70,17 @@
 }
 
 void
-Ekiga::ContactCore::add_source (Source &source)
+Ekiga::ContactCore::add_source (gmref_ptr<Source> source)
 {
-  sources.insert (&source);
-  source_added.emit (source);
-  source.book_added.connect (sigc::bind (sigc::mem_fun (this, &Ekiga::ContactCore::on_book_added), &source));
-  source.book_removed.connect (sigc::bind (sigc::mem_fun (this, &Ekiga::ContactCore::on_book_removed), &source));
-  source.book_updated.connect (sigc::bind (sigc::mem_fun (this, &Ekiga::ContactCore::on_book_updated), &source));
-  source.contact_added.connect (sigc::bind (sigc::mem_fun (this, &Ekiga::ContactCore::on_contact_added), &source));
-  source.contact_removed.connect (sigc::bind (sigc::mem_fun (this, &Ekiga::ContactCore::on_contact_removed), &source));
-  source.contact_updated.connect (sigc::bind (sigc::mem_fun (this, &Ekiga::ContactCore::on_contact_updated), &source));
-  source.questions.add_handler (questions.make_slot ());
+  sources.push_back (source);
+  source_added.emit (*source);
+  source->book_added.connect (sigc::bind (sigc::mem_fun (this, &Ekiga::ContactCore::on_book_added), source));
+  source->book_removed.connect (sigc::bind (sigc::mem_fun (this, &Ekiga::ContactCore::on_book_removed), source));
+  source->book_updated.connect (sigc::bind (sigc::mem_fun (this, &Ekiga::ContactCore::on_book_updated), source));
+  source->contact_added.connect (sigc::bind (sigc::mem_fun (this, &Ekiga::ContactCore::on_contact_added), source));
+  source->contact_removed.connect (sigc::bind (sigc::mem_fun (this, &Ekiga::ContactCore::on_contact_removed), source));
+  source->contact_updated.connect (sigc::bind (sigc::mem_fun (this, &Ekiga::ContactCore::on_contact_updated), source));
+  source->questions.add_handler (questions.make_slot ());
 }
 
 void
@@ -88,16 +88,16 @@
 {
   bool go_on = true;
 
-  for (std::set<Source *>::iterator iter = sources.begin ();
+  for (std::list<gmref_ptr<Source> >::iterator iter = sources.begin ();
        iter != sources.end () && go_on;
-       iter++)
+       ++iter)
     go_on = visitor (*(*iter));
 }
 
 
 void
 Ekiga::ContactCore::on_book_added (Book &book,
-				   Source *source)
+				   gmref_ptr<Source> source)
 {
   book_added.emit (*source, book);
 }
@@ -105,7 +105,7 @@
 
 void
 Ekiga::ContactCore::on_book_removed (Book &book,
-				     Source *source)
+				     gmref_ptr<Source> source)
 {
   book_removed.emit (*source, book);
 }
@@ -113,7 +113,7 @@
 
 void
 Ekiga::ContactCore::on_book_updated (Book &book,
-				     Source *source)
+				     gmref_ptr<Source> source)
 {
   book_updated.emit (*source, book);
 }
@@ -122,7 +122,7 @@
 void
 Ekiga::ContactCore::on_contact_added (Book &book,
 				      Contact &contact,
-				      Source *source)
+				      gmref_ptr<Source> source)
 {
   contact_added.emit (*source, book, contact);
 }
@@ -131,7 +131,7 @@
 void
 Ekiga::ContactCore::on_contact_removed (Book &book,
 					Contact &contact,
-					Source *source)
+					gmref_ptr<Source> source)
 {
   contact_removed.emit (*source, book, contact);
 }
@@ -140,7 +140,7 @@
 void
 Ekiga::ContactCore::on_contact_updated (Book &book,
 					Contact &contact,
-					Source *source)
+					gmref_ptr<Source> source)
 {
   contact_updated.emit (*source, book, contact);
 }

Modified: trunk/lib/engine/addressbook/skel/contact-core.h
==============================================================================
--- trunk/lib/engine/addressbook/skel/contact-core.h	(original)
+++ trunk/lib/engine/addressbook/skel/contact-core.h	Thu Oct 16 18:33:32 2008
@@ -100,7 +100,7 @@
     /** Adds a source to the ContactCore service.
      * @param The source to be added.
      */
-    void add_source (Source &source);
+    void add_source (gmref_ptr<Source> source);
 
 
     /** Triggers a callback for all Ekiga::Source sources of the
@@ -148,15 +148,15 @@
 
   private:
 
-    std::set<Source *> sources;
+    std::list<gmref_ptr<Source> > sources;
 
     /* those functions are signal relayers */
-    void on_book_added (Book &book, Source *source);
-    void on_book_removed (Book &book, Source *source);
-    void on_book_updated (Book &book, Source *source);
-    void on_contact_added (Book &book, Contact &contact, Source *source);
-    void on_contact_removed (Book &book, Contact &contact, Source *source);
-    void on_contact_updated (Book &book, Contact &contact, Source *source);
+    void on_book_added (Book &book, gmref_ptr<Source> source);
+    void on_book_removed (Book &book, gmref_ptr<Source> source);
+    void on_book_updated (Book &book, gmref_ptr<Source> source);
+    void on_contact_added (Book &book, Contact &contact, gmref_ptr<Source> source);
+    void on_contact_removed (Book &book, Contact &contact, gmref_ptr<Source> source);
+    void on_contact_updated (Book &book, Contact &contact, gmref_ptr<Source> source);
 
     /*** Contact Helpers ***/
 

Modified: trunk/lib/engine/addressbook/skel/source.h
==============================================================================
--- trunk/lib/engine/addressbook/skel/source.h	(original)
+++ trunk/lib/engine/addressbook/skel/source.h	Thu Oct 16 18:33:32 2008
@@ -37,11 +37,13 @@
 #ifndef __SOURCE_H__
 #define __SOURCE_H__
 
+#include "gmref.h"
+
 #include "book.h"
 
 namespace Ekiga {
 
-  class Source
+  class Source: public virtual GmRefCounted
   {
   public:
 



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