[ekiga] Turn the avahi browse+publish code into a plugin



commit 40653e52b1a6b44080364552fcabce54db07d88c
Author: Julien Puydt <jpuydt free fr>
Date:   Sat Oct 27 19:26:12 2012 +0200

    Turn the avahi browse+publish code into a plugin

 configure.ac                                       |    1 +
 lib/Makefile.am                                    |   27 -------
 .../avahi-publisher/avahi-publisher-main.h         |   54 -------------
 lib/engine/components/avahi/avahi-main.cpp         |   80 --------------------
 lib/engine/components/avahi/avahi-main.h           |   54 -------------
 lib/engine/engine.cpp                              |   10 ---
 plugins/Makefile.am                                |    5 +
 plugins/avahi/Makefile.am                          |   25 ++++++
 .../components => plugins}/avahi/avahi-cluster.cpp |    0
 .../components => plugins}/avahi/avahi-cluster.h   |    0
 .../components => plugins}/avahi/avahi-heap.cpp    |    0
 .../components => plugins}/avahi/avahi-heap.h      |    0
 .../avahi/avahi-main.cpp                           |   32 +++++---
 .../avahi}/avahi-publisher.cpp                     |    0
 .../avahi}/avahi-publisher.h                       |    0
 15 files changed, 51 insertions(+), 237 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 18e6429..3a7e2f1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -870,6 +870,7 @@ pixmaps/Makefile
 sounds/Makefile
 help/Makefile
 plugins/Makefile
+plugins/avahi/Makefile
 plugins/evolution/Makefile
 plugins/gstreamer/Makefile
 plugins/kab/Makefile
diff --git a/lib/Makefile.am b/lib/Makefile.am
index ad4748d..1b48840 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -656,33 +656,6 @@ libekiga_la_LDFLAGS += $(SHM_LIBS)
 endif
 
 ##
-# Support for avahi
-##
-if HAVE_AVAHI
-
-INCLUDES += \
-	-I$(top_srcdir)/lib/engine/components/avahi \
-	-I$(top_srcdir)/lib/engine/components/avahi-publisher
-
-libekiga_la_SOURCES += \
-	$(components_dir)/avahi-publisher/avahi-publisher-main.cpp \
-	$(components_dir)/avahi-publisher/avahi-publisher-main.h \
-	$(components_dir)/avahi-publisher/avahi-publisher.cpp \
-	$(components_dir)/avahi-publisher/avahi-publisher.h
-
-libekiga_la_SOURCES += \
-	$(components_dir)/avahi/avahi-heap.h \
-	$(components_dir)/avahi/avahi-heap.cpp \
-	$(components_dir)/avahi/avahi-cluster.h \
-	$(components_dir)/avahi/avahi-cluster.cpp \
-	$(components_dir)/avahi/avahi-main.h \
-	$(components_dir)/avahi/avahi-main.cpp
-
-libekiga_la_LDFLAGS += $(AVAHI_LIBS)
-
-endif
-
-##
 # Sources of the libnotify component
 ##
 if HAVE_NOTIFY
diff --git a/lib/engine/engine.cpp b/lib/engine/engine.cpp
index 84a3808..de1847a 100644
--- a/lib/engine/engine.cpp
+++ b/lib/engine/engine.cpp
@@ -84,11 +84,6 @@
 
 #include "opal-main.h"
 
-#ifdef HAVE_AVAHI
-#include "avahi-main.h"
-#include "avahi-publisher-main.h"
-#endif
-
 #ifdef HAVE_NOTIFY
 #include "libnotify-main.h"
 #endif
@@ -179,11 +174,6 @@ engine_init (Ekiga::ServiceCorePtr service_core,
 
   opal_init (kickstart);
 
-#ifdef HAVE_AVAHI
-  avahi_init (kickstart);
-  avahi_publisher_init (kickstart);
-#endif
-
   history_init (kickstart);
 
   /* FIXME: this one should go away -- but if I don't put it here, the GUI
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 176459e..f0b25c4 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,3 +1,7 @@
+if HAVE_AVAHI
+AVAHI_DIR = avahi
+endif
+
 if HAVE_EDS
 EVOLUTION_DIR = evolution
 endif
@@ -27,6 +31,7 @@ XCAP_DIRS = xcap resource-list
 endif
 
 SUBDIRS = \
+	$(AVAHI_DIR) \
 	$(EVOLUTION_DIR) \
 	$(GSTREAMER_DIR) \
 	$(KAB_DIR) \
diff --git a/plugins/avahi/Makefile.am b/plugins/avahi/Makefile.am
new file mode 100644
index 0000000..fc8f49c
--- /dev/null
+++ b/plugins/avahi/Makefile.am
@@ -0,0 +1,25 @@
+plugin_LTLIBRARIES = libgmavahi.la
+
+avahi_dir = $(top_srcdir)/plugins/avahi
+
+AM_CXXFLAGS = $(BOOST_CPPFLAGS) $(AVAHI_CFLAGS)
+
+INCLUDES = \
+	-I$(top_srcdir)/lib/engine/framework \
+	-I$(top_srcdir)/lib/engine/account \
+	-I$(top_srcdir)/lib/engine/presence \
+	-I$(top_srcdir)/lib/engine/protocol
+
+libgmavahi_la_SOURCES = \
+	$(avahi_dir)/avahi-main.cpp \
+	$(avahi_dir)/avahi-publisher.cpp \
+	$(avahi_dir)/avahi-publisher.h \
+	$(avahi_dir)/avahi-heap.h \
+	$(avahi_dir)/avahi-heap.cpp \
+	$(avahi_dir)/avahi-cluster.h \
+	$(avahi_dir)/avahi-cluster.cpp
+
+libgmavahi_la_LDFLAGS = $(PLUGINS_LIBTOOL_FLAGS)
+libgmavahi_la_LIBADD = \
+	$(top_builddir)/lib/libekiga.la \
+	$(BOOST_LDFLAGS) $(BOOST_LIBS) $(AVAHI_LIBS)
diff --git a/lib/engine/components/avahi/avahi-cluster.cpp b/plugins/avahi/avahi-cluster.cpp
similarity index 100%
rename from lib/engine/components/avahi/avahi-cluster.cpp
rename to plugins/avahi/avahi-cluster.cpp
diff --git a/lib/engine/components/avahi/avahi-cluster.h b/plugins/avahi/avahi-cluster.h
similarity index 100%
rename from lib/engine/components/avahi/avahi-cluster.h
rename to plugins/avahi/avahi-cluster.h
diff --git a/lib/engine/components/avahi/avahi-heap.cpp b/plugins/avahi/avahi-heap.cpp
similarity index 100%
rename from lib/engine/components/avahi/avahi-heap.cpp
rename to plugins/avahi/avahi-heap.cpp
diff --git a/lib/engine/components/avahi/avahi-heap.h b/plugins/avahi/avahi-heap.h
similarity index 100%
rename from lib/engine/components/avahi/avahi-heap.h
rename to plugins/avahi/avahi-heap.h
diff --git a/lib/engine/components/avahi-publisher/avahi-publisher-main.cpp b/plugins/avahi/avahi-main.cpp
similarity index 75%
rename from lib/engine/components/avahi-publisher/avahi-publisher-main.cpp
rename to plugins/avahi/avahi-main.cpp
index 537a08d..7bdcffb 100644
--- a/lib/engine/components/avahi-publisher/avahi-publisher-main.cpp
+++ b/plugins/avahi/avahi-main.cpp
@@ -1,6 +1,6 @@
 
 /* Ekiga -- A VoIP and Video-Conferencing application
- * Copyright (C) 2000-2009 Damien Sandras <dsandras seconix com>
+ * Copyright (C) 2000-2012 Damien Sandras <dsandras seconix com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -27,20 +27,21 @@
 
 
 /*
- *                         avahi-publisher-main.cpp  -  description
+ *                         avahi-main.cpp  -  description
  *                         ------------------------------------------
- *   begin                : written in 2008 by Damien Sandras
- *   copyright            : (c) 2008 Damien Sandras
- *   description          : code to hook the avahi publisher into the main program
+ *   begin                : written in 2012 by Julien Puydt
+ *   copyright            : (c) 2012 Julien Puydt
+ *   description          : declare the avahi code as a plugin
  *
  */
 
-#include "avahi-publisher-main.h"
+#include "kickstart.h"
 #include "avahi-publisher.h"
+#include "avahi-cluster.h"
 
-struct AVAHIPUBSpark: public Ekiga::Spark
+struct AVAHISpark: public Ekiga::Spark
 {
-  AVAHIPUBSpark (): result(false)
+  AVAHISpark (): result(false)
   {}
 
   bool try_initialize_more (Ekiga::ServiceCore& core,
@@ -59,6 +60,13 @@ struct AVAHIPUBSpark: public Ekiga::Spark
 	presence_core->add_presence_publisher (publisher);
 	result = true;
       }
+
+      boost::shared_ptr<Avahi::Cluster> cluster (new Avahi::Cluster (core));
+      if (core.add (cluster)) {
+
+	presence_core->add_cluster (cluster);
+	result = true;
+      }
     }
 
     return result;
@@ -68,14 +76,14 @@ struct AVAHIPUBSpark: public Ekiga::Spark
   { return result?FULL:BLANK; }
 
   const std::string get_name () const
-  { return "AVAHIPUB"; }
+  { return "AVAHI"; }
 
   bool result;
 };
 
-void
-avahi_publisher_init (Ekiga::KickStart& kickstart)
+extern "C" void
+ekiga_plugin_init (Ekiga::KickStart& kickstart)
 {
-  boost::shared_ptr<Ekiga::Spark> spark(new AVAHIPUBSpark);
+  boost::shared_ptr<Ekiga::Spark> spark(new AVAHISpark);
   kickstart.add_spark (spark);
 }
diff --git a/lib/engine/components/avahi-publisher/avahi-publisher.cpp b/plugins/avahi/avahi-publisher.cpp
similarity index 100%
rename from lib/engine/components/avahi-publisher/avahi-publisher.cpp
rename to plugins/avahi/avahi-publisher.cpp
diff --git a/lib/engine/components/avahi-publisher/avahi-publisher.h b/plugins/avahi/avahi-publisher.h
similarity index 100%
rename from lib/engine/components/avahi-publisher/avahi-publisher.h
rename to plugins/avahi/avahi-publisher.h



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