ekiga r6213 - in trunk: . lib/engine lib/engine/components/avahi-publisher



Author: dsandras
Date: Sun Apr 20 19:37:02 2008
New Revision: 6213
URL: http://svn.gnome.org/viewvc/ekiga?rev=6213&view=rev

Log:
More porting of old avahi publisher code to the engine. 
Fixes compilation.


Added:
   trunk/lib/engine/components/avahi-publisher/avahi-publisher.cpp
      - copied, changed from r6212, /trunk/lib/engine/components/avahi-publisher/avahi.cpp
   trunk/lib/engine/components/avahi-publisher/avahi-publisher.h
      - copied, changed from r6212, /trunk/lib/engine/components/avahi-publisher/avahi.h
Removed:
   trunk/lib/engine/components/avahi-publisher/avahi.cpp
   trunk/lib/engine/components/avahi-publisher/avahi.h
Modified:
   trunk/ChangeLog
   trunk/lib/engine/Makefile.am
   trunk/lib/engine/components/avahi-publisher/Makefile.am

Modified: trunk/lib/engine/Makefile.am
==============================================================================
--- trunk/lib/engine/Makefile.am	(original)
+++ trunk/lib/engine/Makefile.am	Sun Apr 20 19:37:02 2008
@@ -77,7 +77,6 @@
 	$(top_builddir)/lib/engine/audiooutput/skel/libgmaudiooutput.la					\
 	$(top_builddir)/lib/engine/hal/skel/libgmhal.la							\
 	$(top_builddir)/lib/engine/components/gmconf-personal-details/libgmconfpersonaldetails.la	\
-	$(top_builddir)/lib/engine/components/avahi-publisher/libavahipublisher.la
 	$(AM_LIBS)
 
 # Default Input Devices
@@ -113,7 +112,9 @@
 
 
 if HAVE_AVAHI
-libekiga_engine_la_LIBADD += presence/avahi/libgmavahi.la
+libekiga_engine_la_LIBADD += \
+	$(top_builddir)/lib/engine/presence/avahi/libgmavahi.la \
+	$(top_builddir)/lib/engine/components/avahi-publisher/libavahipublisher.la
 endif
 
 if HAVE_EDS

Modified: trunk/lib/engine/components/avahi-publisher/Makefile.am
==============================================================================
--- trunk/lib/engine/components/avahi-publisher/Makefile.am	(original)
+++ trunk/lib/engine/components/avahi-publisher/Makefile.am	Sun Apr 20 19:37:02 2008
@@ -2,7 +2,7 @@
 
 avahi_publisher_dir = $(top_srcdir)/lib/engine/components/avahi-publisher/
 
-AM_CXXFLAGS = $(SIGC_CFLAGS) $(GLIB_CFLAGS)
+AM_CXXFLAGS = $(SIGC_CFLAGS) $(GLIB_CFLAGS) $(AVAHI_CFLAGS)
 
 INCLUDES = 						\
 	-I$(top_srcdir)/lib/gmconf	 		\
@@ -22,4 +22,4 @@
 	$(top_builddir)/lib/engine/framework/libgmframework.la		\
 	$(top_builddir)/lib/engine/presence/skel/libgmpresence.la
 
-libavahipublisher_la_LDFLAGS = -export-dynamic -no-undefined $(SIGC_LIBS) $(GLIB_LIBS)
+libavahipublisher_la_LDFLAGS = -export-dynamic -no-undefined $(SIGC_LIBS) $(GLIB_LIBS) $(AVAHI_LIBS)

Copied: trunk/lib/engine/components/avahi-publisher/avahi-publisher.cpp (from r6212, /trunk/lib/engine/components/avahi-publisher/avahi.cpp)
==============================================================================
--- /trunk/lib/engine/components/avahi-publisher/avahi.cpp	(original)
+++ trunk/lib/engine/components/avahi-publisher/avahi-publisher.cpp	Sun Apr 20 19:37:02 2008
@@ -37,11 +37,13 @@
 
 
 #include <gmconf.h>
+#include <iostream>
+
+#include "avahi-publisher.h"
+#include "personal-details.h"
+
+using namespace Avahi;
 
-#include "avahi.h"
-#include "manager.h"
-#include "ekiga.h"
-#include "misc.h"
 
 /* deconnection callback */
 
@@ -66,7 +68,7 @@
 static gboolean
 on_disconnect (gpointer data)
 {
-  GMZeroconfPublisher *zero = (GMZeroconfPublisher *) data;
+  PresencePublisher *zero = (PresencePublisher *) data;
 
   zero->OnDisconnect();
   
@@ -78,7 +80,7 @@
 		      AvahiEntryGroupState state, 
 		      void *userdata) 
 {
-  GMZeroconfPublisher *zero = (GMZeroconfPublisher *) userdata;
+  PresencePublisher *zero = (PresencePublisher *) userdata;
   zero->EntryGroupCallback(group,state,userdata);
 }
 
@@ -88,7 +90,7 @@
 		 AvahiClientState state, 
 		 void *userdata) 
 {
-  GMZeroconfPublisher *zero = (GMZeroconfPublisher *) userdata;
+  PresencePublisher *zero = (PresencePublisher *) userdata;
   zero->ClientCallback(c, state, userdata);
 }
 
@@ -97,15 +99,16 @@
 create_services (AvahiClient *c, 
 		 void *userdata) 
 {
-  GMZeroconfPublisher *zero = (GMZeroconfPublisher *) userdata;
+  PresencePublisher *zero = (PresencePublisher *) userdata;
   return zero->CreateServices (c, userdata);
 }
 
 
 /* Implementation of the class */
-GMZeroconfPublisher::GMZeroconfPublisher (GMManager & m)
-  : manager (m)
-{  
+PresencePublisher::PresencePublisher (Ekiga::ServiceCore & _core)
+: Ekiga::PresencePublisher (_core),
+  core (_core)
+{
   std::cout << "Created publisher " << std::endl << std::flush;
   /* Create the GLIB Adaptor */
   glib_poll = avahi_glib_poll_new (NULL, G_PRIORITY_DEFAULT);
@@ -119,7 +122,7 @@
 }
 
 
-GMZeroconfPublisher::~GMZeroconfPublisher()
+PresencePublisher::~PresencePublisher()
 {
   if (h323_text_record) {
     
@@ -159,8 +162,17 @@
 }
 
 
+void 
+PresencePublisher::publish (const Ekiga::PersonalDetails & details)
+{
+  std::string status = ((Ekiga::PersonalDetails &) (details)).get_short_status ();
+
+  std::cout << "NEW AVAHI STATUS" << status << std::endl << std::flush;
+}
+
+
 void
-GMZeroconfPublisher::EntryGroupCallback (AvahiEntryGroup *_group,
+PresencePublisher::EntryGroupCallback (AvahiEntryGroup *_group,
 					 AvahiEntryGroupState state,
 					 void *userdata) 
 {
@@ -181,7 +193,7 @@
 
 
 int
-GMZeroconfPublisher::CreateServices (AvahiClient *c, 
+PresencePublisher::CreateServices (AvahiClient *c, 
 				     void *userdata) 
 {
   int ret = 0;
@@ -193,16 +205,12 @@
     
     if (group == NULL) {
 
-      PTRACE (1, "AVAHI\tavahi_entry_group_new failed: " << 
-	      avahi_strerror (avahi_client_errno(c)));
       failure = TRUE;
     }
   }
   
   if (failure == FALSE) {
   
-    PTRACE(1, "AVAHI\tAdding service " << name);
-
     /* H.323 */
     ret = avahi_entry_group_add_service_strlst (group,
 						AVAHI_IF_UNSPEC,
@@ -216,7 +224,6 @@
 						h323_text_record);
     if (ret < 0) {
 
-      PTRACE (1, "AVAHI\tFailed to add service: " << avahi_strerror (ret));
       failure = TRUE;
     }
   }
@@ -236,7 +243,6 @@
 						sip_text_record);
     if (ret < 0) {
     
-      PTRACE (1, "AVAHI\tFailed to add service: " << avahi_strerror(ret));
       failure = TRUE;
     }
   }
@@ -247,7 +253,6 @@
     ret = avahi_entry_group_commit (group);
     if (ret < 0) {
     
-      PTRACE (1, "AVAHI\tFailed to commit entry_group: " << avahi_strerror (ret));
       failure = TRUE;
     }
   }
@@ -257,7 +262,7 @@
 
 
 void
-GMZeroconfPublisher::ClientCallback (AvahiClient *c, 
+PresencePublisher::ClientCallback (AvahiClient *c, 
 				     AvahiClientState state, 
 				     void *userdata) 
 {
@@ -282,7 +287,6 @@
 
       if (avahi_client_errno(c) == AVAHI_ERR_DISCONNECTED) {
 
-	PTRACE(1, "AVAHI\tDbus Server connection scheduled for a restart.");
 	g_timeout_add (60000, on_disconnect, this);
       }
     }
@@ -290,9 +294,8 @@
 }
 
 void
-GMZeroconfPublisher::OnDisconnect ()
+PresencePublisher::OnDisconnect ()
 {
-  PTRACE(1, "AVAHI\tRepublishing after a disconnection");
   
   if (client) {
 
@@ -306,7 +309,7 @@
 }
 
 int
-GMZeroconfPublisher::Publish()
+PresencePublisher::Publish()
 {
   int error = 0;
 
@@ -333,8 +336,6 @@
       
       if (client == NULL) {
 	  
-	PTRACE (1, "AVAHI\tError initializing Avahi: %s" << 
-		avahi_strerror (error));
 	return -1;
       }
     }
@@ -345,19 +346,17 @@
 
 
 int
-GMZeroconfPublisher::GetPersonalData()
+PresencePublisher::GetPersonalData()
 {
   gchar	*full_name = NULL;
   std::string status;
   
   int state = 0;
 
-  gnomemeeting_threads_enter ();
+  /*
   full_name = gm_conf_get_string (PERSONAL_DATA_KEY "full_name");
   h323_port = gm_conf_get_int (H323_KEY "listen_port");
   sip_port = gm_conf_get_int (SIP_KEY "listen_port");
-  std::cout << "FIXME" << std::endl << std::flush;
-  gnomemeeting_threads_leave ();
 
   // TODO: largely improve this
   switch (state) {
@@ -382,7 +381,7 @@
   default:
     break;
   }
-
+*/
 
   /* Cleanups */
   if (h323_text_record) {
@@ -410,11 +409,12 @@
   sip_text_record = 
     avahi_string_list_add_printf (sip_text_record,"presence=%s", status.c_str ());
 
+  /*
   h323_text_record = 
     avahi_string_list_add (h323_text_record, "software=Ekiga/" PACKAGE_VERSION);
   sip_text_record = 
     avahi_string_list_add (sip_text_record, "software=Ekiga/" PACKAGE_VERSION);
-
+*/
   return 0;
 }
 

Copied: trunk/lib/engine/components/avahi-publisher/avahi-publisher.h (from r6212, /trunk/lib/engine/components/avahi-publisher/avahi.h)
==============================================================================
--- /trunk/lib/engine/components/avahi-publisher/avahi.h	(original)
+++ trunk/lib/engine/components/avahi-publisher/avahi-publisher.h	Sun Apr 20 19:37:02 2008
@@ -36,8 +36,6 @@
  */
 
 
-#include "common.h"
-
 #ifndef _AVAHI_PUBLISHER_H_
 #define _AVAHI_PUBLISHER_H_
 
@@ -49,86 +47,73 @@
 #include <avahi-common/timeval.h>
 #include <avahi-glib/glib-watch.h>
 
+#include "presence-core.h"
+#include "services.h"
 
 /* Zeroconf Service Type */
 #define ZC_H323 "_h323._tcp"
 #define ZC_SIP "_sip._udp"
 
-class GMManager;
-
+class Ekiga::PersonalDetails;
 
-class GMZeroconfPublisher
+namespace Avahi
 {
+  class PresencePublisher 
+    : public Ekiga::PresencePublisher,
+      public Ekiga::Service
+  {
+
+    public:
+    PresencePublisher (Ekiga::ServiceCore & core);
+    ~PresencePublisher ();
+
+    /*** Service API ***/
+    const std::string get_name () const
+      { return "avahi-presence-publisher"; }
+
+    const std::string get_description () const
+      { return "\tObject bringing in Avahi presence publishing"; }
+
+    /*** PresencePublisher API ***/
+    void publish (const Ekiga::PersonalDetails & details);
+
+
+    int Publish ();
+
 
- public:
+    void ClientCallback (AvahiClient *c, 
+                         AvahiClientState state, 
+                         void *userdata);
 
-  /* DESCRIPTION  : / 
-   * BEHAVIOR     : ZeroconfPublisher constructor
-   *		    - insert Avahi in Gnomemeeting Mainloop
-   *		    - initialization of some variables
-   * PRE          : /
-   */
-  GMZeroconfPublisher (GMManager &);
-
-
-  /* DESCRIPTION  : ZeroconfPublisher destructor 
-   * BEHAVIOR     : 
-   *		    - Free avahi Client and Entry group
-   *		    - Stop publishing the gnomemeeting zeroconf service
-   *		    - free text_record.
-   * PRE          : /
-   */
-  ~GMZeroconfPublisher ();
-
-
-  /* DESCRIPTION  : / 
-   * BEHAVIOR     : Return -1 when error occurred, 0 if no error.
-   *		    Publish the gnomemeeting zeroconf service
-   *		    with data store in class attributes info.
-   * PRE          : Start() method must be called before Publish ().
-   */
-  int Publish ();
-  
-  
-  void ClientCallback (AvahiClient *c, 
-		       AvahiClientState state, 
-		       void *userdata);
-  
-  
-  int CreateServices (AvahiClient *c, 
-		      void *userdata);
-
-  void OnDisconnect ();
-  
-  void EntryGroupCallback (AvahiEntryGroup *group, 
-			   AvahiEntryGroupState state, 
-			   void *userdata);
-
- private:
-
-  AvahiClient *client;
-  AvahiEntryGroup *group;
-  
-  char *name;                         /* Srv Record */
-  
-  AvahiStringList *h323_text_record;  /* H323 Txt Record */
-  AvahiStringList *sip_text_record;   /* Sip Txt Record */
-  
-  uint16_t h323_port;                 /* port number of Srv Record */
-  uint16_t sip_port;                  /* port number of Srv Record */
-  
-  AvahiGLibPoll *glib_poll;
-  const AvahiPoll *poll_api;
-
-  /* DESCRIPTION  : / 
-   * BEHAVIOR     : Return err=SW_OKAY when no error occurred.
-   *		    Retrieve user personal data from gmconf 
-   *		    to class attributes info.
-   * PRE          : must be call to update personal data
-   */
-  int GetPersonalData();
 
-  GMManager & manager;
+    int CreateServices (AvahiClient *c, 
+                        void *userdata);
+
+    void OnDisconnect ();
+
+    void EntryGroupCallback (AvahiEntryGroup *group, 
+                             AvahiEntryGroupState state, 
+                             void *userdata);
+
+    private:
+    Ekiga::ServiceCore & core;
+    AvahiClient *client;
+    AvahiEntryGroup *group;
+
+    char *name;                         /* Srv Record */
+
+    AvahiStringList *h323_text_record;  /* H323 Txt Record */
+    AvahiStringList *sip_text_record;   /* Sip Txt Record */
+
+    uint16_t h323_port;                 /* port number of Srv Record */
+    uint16_t sip_port;                  /* port number of Srv Record */
+
+    AvahiGLibPoll *glib_poll;
+    const AvahiPoll *poll_api;
+
+    int GetPersonalData();
+  };
 };
 
+
 #endif



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