ekiga r7239 - in trunk: lib/engine/components/avahi-publisher lib/engine/presence/skel src/endpoints



Author: jpuydt
Date: Thu Oct 16 13:44:41 2008
New Revision: 7239
URL: http://svn.gnome.org/viewvc/ekiga?rev=7239&view=rev

Log:
Use gmref_ptr for the presence publishers too

Modified:
   trunk/lib/engine/components/avahi-publisher/avahi-publisher-main.cpp
   trunk/lib/engine/components/avahi-publisher/avahi-publisher.h
   trunk/lib/engine/presence/skel/presence-core.cpp
   trunk/lib/engine/presence/skel/presence-core.h
   trunk/src/endpoints/opal-main.cpp

Modified: trunk/lib/engine/components/avahi-publisher/avahi-publisher-main.cpp
==============================================================================
--- trunk/lib/engine/components/avahi-publisher/avahi-publisher-main.cpp	(original)
+++ trunk/lib/engine/components/avahi-publisher/avahi-publisher-main.cpp	Thu Oct 16 13:44:41 2008
@@ -40,34 +40,6 @@
 
 #include <iostream>
 
-class Service: public Ekiga::Service
-{
-public:
-
-  Service (Ekiga::PresenceCore& core_,
-	   Avahi::PresencePublisher* publisher_):
-    core(core_), publisher(publisher_)
-  {
-    core.add_presence_publisher (*publisher);
-  }
-
-  ~Service ()
-  {
-    core.remove_presence_publisher (*publisher);
-    delete publisher;
-  }
-
-  const std::string get_name () const
-  { return "avahi-presence-publisher"; }
-
-  const std::string get_description () const
-  { return "\tObject bringing in Avahi presence publishing"; }
-
-private:
-  Ekiga::PresenceCore& core;
-  Avahi::PresencePublisher* publisher;
-};
-
 bool
 avahi_publisher_init (Ekiga::ServiceCore &core,
                       int* /*argc*/,
@@ -81,10 +53,10 @@
 
   if (presence_core && call_core && details) {
 
-    Avahi::PresencePublisher* publisher = NULL;
-    publisher = new Avahi::PresencePublisher (core, *details, *call_core);
-    gmref_ptr<Service> service = new Service (*presence_core, publisher);
-    core.add (service);
+    gmref_ptr<Avahi::PresencePublisher> publisher
+      = new Avahi::PresencePublisher (core, *details, *call_core);
+    presence_core->add_presence_publisher (publisher);
+    core.add (publisher);
     result = true;
   }
 

Modified: trunk/lib/engine/components/avahi-publisher/avahi-publisher.h
==============================================================================
--- trunk/lib/engine/components/avahi-publisher/avahi-publisher.h	(original)
+++ trunk/lib/engine/components/avahi-publisher/avahi-publisher.h	Thu Oct 16 13:44:41 2008
@@ -54,7 +54,9 @@
 
 namespace Avahi
 {
-  class PresencePublisher: public Ekiga::PresencePublisher
+  class PresencePublisher:
+    public Ekiga::Service,
+    public Ekiga::PresencePublisher
   {
 public:
 
@@ -64,6 +66,12 @@
 
     ~PresencePublisher ();
 
+    const std::string get_name () const
+    { return "avahi-presence-publisher"; }
+
+    const std::string get_description () const
+    { return "\tObject bringing in Avahi presence publishing"; }
+
     void publish (const Ekiga::PersonalDetails & details);
 
     /* public only to be called by C callbacks... */

Modified: trunk/lib/engine/presence/skel/presence-core.cpp
==============================================================================
--- trunk/lib/engine/presence/skel/presence-core.cpp	(original)
+++ trunk/lib/engine/presence/skel/presence-core.cpp	Thu Oct 16 13:44:41 2008
@@ -226,23 +226,17 @@
 }
 
 void
-Ekiga::PresenceCore::add_presence_publisher (PresencePublisher &publisher)
+Ekiga::PresenceCore::add_presence_publisher (gmref_ptr<PresencePublisher> publisher)
 {
-  presence_publishers.push_back (&publisher);
-}
-
-void
-Ekiga::PresenceCore::remove_presence_publisher (PresencePublisher& publisher)
-{
-  presence_publishers.remove (&publisher);
+  presence_publishers.push_back (publisher);
 }
 
 void Ekiga::PresenceCore::publish (gmref_ptr<PersonalDetails> details) 
 {
-  for (std::list<PresencePublisher*>::iterator iter
+  for (std::list<gmref_ptr<PresencePublisher> >::iterator iter
 	 = presence_publishers.begin ();
        iter != presence_publishers.end ();
-       iter++)
+       ++iter)
     (*iter)->publish (*details);
 }
 

Modified: trunk/lib/engine/presence/skel/presence-core.h
==============================================================================
--- trunk/lib/engine/presence/skel/presence-core.h	(original)
+++ trunk/lib/engine/presence/skel/presence-core.h	Thu Oct 16 13:44:41 2008
@@ -101,7 +101,7 @@
     sigc::signal<void, std::string, std::string> status_received;
   };
 
-  class PresencePublisher
+  class PresencePublisher: public virtual GmRefCounted
   {
   public:
 
@@ -281,12 +281,11 @@
     /* help publishing presence */
   public:
 
-    void add_presence_publisher (PresencePublisher &publisher);
-    void remove_presence_publisher (PresencePublisher& publisher);
+    void add_presence_publisher (gmref_ptr<PresencePublisher> publisher);
 
   private:
 
-    std::list<PresencePublisher*> presence_publishers;
+    std::list<gmref_ptr<PresencePublisher> > presence_publishers;
     void publish (gmref_ptr<PersonalDetails> details);
     void on_personal_details_updated (PersonalDetails &details);
     void on_registration_event (const Ekiga::Account & account,

Modified: trunk/src/endpoints/opal-main.cpp
==============================================================================
--- trunk/src/endpoints/opal-main.cpp	(original)
+++ trunk/src/endpoints/opal-main.cpp	Thu Oct 16 13:44:41 2008
@@ -142,7 +142,7 @@
 #ifdef HAVE_SIP
     presence_core->add_presentity_decorator (sip_manager);
     presence_core->add_presence_fetcher (sip_manager);
-    presence_core->add_presence_publisher (*sip_manager);
+    presence_core->add_presence_publisher (sip_manager);
 #endif
 #ifdef HAVE_H323
     presence_core->add_presentity_decorator (h323_manager);



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