ekiga r7676 - in trunk: . lib/engine lib/engine/components lib/engine/components/libnotify



Author: jpuydt
Date: Sun Feb 22 10:47:19 2009
New Revision: 7676
URL: http://svn.gnome.org/viewvc/ekiga?rev=7676&view=rev

Log:
Added a libnotify view of the notification framework

Added:
   trunk/lib/engine/components/libnotify/
   trunk/lib/engine/components/libnotify/Makefile.am
   trunk/lib/engine/components/libnotify/libnotify-main.cpp
   trunk/lib/engine/components/libnotify/libnotify-main.h
Modified:
   trunk/configure.ac
   trunk/lib/engine/Makefile.am
   trunk/lib/engine/components/Makefile.am
   trunk/lib/engine/engine.cpp

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Sun Feb 22 10:47:19 2009
@@ -609,6 +609,24 @@
 AM_CONDITIONAL(HAVE_XCAP, test "x$found_xcap" = "xyes")
 
 dnl ###############################
+dnl     libnotify support
+dnl ###############################
+LIBNOTIFY="disabled"
+
+AC_ARG_ENABLE(libnotify, [ --enable-libnotify           Enable libnotify support],enable_libnotify=yes,)
+
+if test "x$enable_libnotify" = "xyes"; then
+   PKG_CHECK_MODULES([LIBNOTIFY], [libnotify])
+   found_libnotify=yes
+   LIBNOTIFY="enabled"
+   AC_SUBST(LIBNOTIFY_CFLAGS)
+   AC_SUBST(LIBNOTIFY_LIBS)
+   AC_DEFINE(HAVE_LIBNOTIFY,1,[libnotify support])
+fi
+
+AM_CONDITIONAL(HAVE_LIBNOTIFY, test "x$found_libnotify" = "xyes")
+
+dnl ###############################
 dnl   Gnome-Doc-Utils
 dnl ###############################
 GDU="disabled"
@@ -769,6 +787,7 @@
 lib/engine/components/avahi-publisher/Makefile
 lib/engine/components/gstreamer/Makefile
 lib/engine/components/kde/Makefile
+lib/engine/components/libnotify/Makefile
 lib/engine/components/resource-list/Makefile
 lib/engine/components/gnome-session/Makefile
 lib/engine/components/xcap/Makefile
@@ -817,6 +836,7 @@
 echo "            KAddressBook support  :  $KAB"
 echo "                     KDE support  :  $KDE"
 echo "                    XCAP support  :  $XCAP"
+echo "               libnotify support  :  $LIBNOTIFY"
 echo ""
 echo "                         OS Type  :  $target_os"
 echo "                    Machine Type  :  $target_cpu"

Modified: trunk/lib/engine/Makefile.am
==============================================================================
--- trunk/lib/engine/Makefile.am	(original)
+++ trunk/lib/engine/Makefile.am	Sun Feb 22 10:47:19 2009
@@ -164,6 +164,11 @@
 	components/resource-list/libgmresource_list.la
 endif
 
+if HAVE_LIBNOTIFY
+INCLUDES += -I$(top_srcdir)/lib/engine/components/libnotify/
+libekiga_engine_la_LIBADD += components/libnotify/libgmlibnotify.la
+endif
+
 #### FIXME should be removed at a later stage
 INCLUDES += \
 	-I$(top_srcdir)/lib/gui/	                \

Modified: trunk/lib/engine/components/Makefile.am
==============================================================================
--- trunk/lib/engine/components/Makefile.am	(original)
+++ trunk/lib/engine/components/Makefile.am	Sun Feb 22 10:47:19 2009
@@ -39,6 +39,10 @@
 KDE_DIR = kde
 endif
 
+if HAVE_LIBNOTIFY
+LIBNOTIFY_DIR = libnotify
+endif
+
 if HAVE_XCAP
 XCAP_DIRS = xcap resource-list
 endif
@@ -62,6 +66,7 @@
 	$(DBUS_DIR)             \
 	$(GSTREAMER_DIR)        \
 	$(KDE_DIR)              \
+	$(LIBNOTIFY_DIR)	\
 	$(EDS_DIR) 	        \
 	$(LDAP_DIR)	        \
 	$(KAB_DIR)              \

Added: trunk/lib/engine/components/libnotify/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/lib/engine/components/libnotify/Makefile.am	Sun Feb 22 10:47:19 2009
@@ -0,0 +1,19 @@
+noinst_LTLIBRARIES = libgmlibnotify.la
+
+libnotify_dir = $(top_srcdir)/lib/engine/components/libnotify
+
+AM_CXXFLAGS = $(SIGC_CFLAGS) $(LIBNOTIFY_CFLAGS)
+
+INCLUDES = \
+	-I$(top_srcdir)/lib/engine/framework \
+	-I$(top_srcdir)/lib/engine/notification
+
+libgmlibnotify_la_SOURCES = \
+	$(libnotify_dir)/libnotify-main.h \
+	$(libnotify_dir)/libnotify-main.cpp
+
+libgmlibnotify_la_LIBADD = \
+	$(top_builddir)/lib/engine/framework/libgmframework.la \
+	$(top_builddir)/lib/engine/notification/libnotification.la
+
+libgmlibnotify_la_LDFLAGS = -export-dynamic -no-undefined $(SIGC_LIBS) $(LIBNOTIFY_LIBS)
\ No newline at end of file

Added: trunk/lib/engine/components/libnotify/libnotify-main.cpp
==============================================================================
--- (empty file)
+++ trunk/lib/engine/components/libnotify/libnotify-main.cpp	Sun Feb 22 10:47:19 2009
@@ -0,0 +1,188 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2009 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Ekiga is licensed under the GPL license and as a special exception,
+ * you have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination,
+ * without applying the requirements of the GNU GPL to the OPAL, OpenH323
+ * and PWLIB programs, as long as you do follow the requirements of the
+ * GNU GPL for all the rest of the software thus combined.
+ */
+
+
+/*
+ *                         libnotify-main.cpp  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2009 by Damien Sandras
+ *   copyright            : (c) 2009 by Julien Puydt
+ *   description          : code to push user notifications to the desktop
+ *
+ */
+
+#include <map>
+
+#include <libnotify/notify.h>
+
+#include "services.h"
+#include "notification-core.h"
+
+#include "libnotify-main.h"
+
+class LibNotify: public Ekiga::Service
+{
+public:
+
+  LibNotify (gmref_ptr<Ekiga::NotificationCore> core);
+
+  ~LibNotify ();
+
+  const std::string get_name () const
+  { return "libnotify"; }
+
+  const std::string get_description () const
+  { return "\tService pushing user notifications to the desktop"; }
+
+private:
+
+  void on_notification_added (gmref_ptr<Ekiga::Notification> notif);
+  void on_notification_removed (gmref_ptr<Ekiga::Notification> notif);
+
+  typedef std::map<gmref_ptr<Ekiga::Notification>, std::pair<sigc::connection, NotifyNotification*> > container_type;
+  container_type live;
+};
+
+
+struct LIBNOTIFYSpark: public Ekiga::Spark
+{
+  LIBNOTIFYSpark (): result(false)
+  {}
+
+  bool try_initialize_more (Ekiga::ServiceCore& core,
+			    int* /*argc*/,
+			    char** /*argv*/[])
+  {
+    gmref_ptr<Ekiga::NotificationCore> notification = core.get ("notification-core");
+    gmref_ptr<Ekiga::Service> service = core.get ("libnotify");
+
+    if (notification && !service) {
+
+      core.add (gmref_ptr<Ekiga::Service> (new LibNotify (notification)));
+      result = true;
+    }
+
+    return result;
+  }
+
+  Ekiga::Spark::state get_state () const
+  { return result?FULL:BLANK; }
+
+  const std::string get_name () const
+  { return "LIBNOTIFY"; }
+
+  bool result;
+
+};
+
+void
+libnotify_init (Ekiga::KickStart& kickstart)
+{
+  gmref_ptr<Ekiga::Spark> spark(new LIBNOTIFYSpark);
+  kickstart.add_spark (spark);
+}
+
+LibNotify::LibNotify (gmref_ptr<Ekiga::NotificationCore> core)
+{
+  notify_init ("Ekiga");
+  core->notification_added.connect (sigc::mem_fun (this, &LibNotify::on_notification_added));
+}
+
+LibNotify::~LibNotify ()
+{
+  for (container_type::iterator iter = live.begin ();
+       iter != live.end ();
+       ++iter) {
+
+    iter->second.first.disconnect ();
+    g_object_unref (iter->second.second);
+  }
+  live.clear ();
+
+  notify_uninit ();
+}
+
+static void
+on_notif_closed (NotifyNotification* /*notif*/,
+		 gpointer data)
+{
+  Ekiga::Notification* notification = (Ekiga::Notification*)data;
+
+  notification->removed.emit ();
+}
+
+void
+LibNotify::on_notification_added (gmref_ptr<Ekiga::Notification> notification)
+{
+  NotifyNotification* notif = NULL;
+  const gchar* urgency = NULL;
+
+  switch (notification->get_level ()) {
+
+  case Ekiga::Notification::Info:
+
+    urgency = "gtk-info";
+    break;
+
+  case Ekiga::Notification::Warning:
+
+    urgency = "gtk-warning";
+    break;
+
+  case Ekiga::Notification::Error:
+
+    urgency = "gtk-warning";
+    break;
+  default:
+    urgency = "gtk-info";
+  }
+
+  notif = notify_notification_new (notification->get_title ().c_str (),
+				   notification->get_body ().c_str (),
+				   urgency, NULL);
+
+  g_signal_connect (notif, "closed",
+		    G_CALLBACK (on_notif_closed), &*notification);
+  sigc::connection conn = notification->removed.connect (sigc::bind (sigc::mem_fun (this, &LibNotify::on_notification_removed), notification));
+
+  live[notification] = std::pair<sigc::connection, NotifyNotification*> (conn, notif);
+
+  (void)notify_notification_show (notif, NULL);
+}
+
+void
+LibNotify::on_notification_removed (gmref_ptr<Ekiga::Notification> notification)
+{
+  container_type::iterator iter = live.find (notification);
+
+  if (iter != live.end ()) {
+
+    iter->second.first.disconnect ();
+    g_object_unref (iter->second.second);
+    live.erase (iter);
+  }
+}

Added: trunk/lib/engine/components/libnotify/libnotify-main.h
==============================================================================
--- (empty file)
+++ trunk/lib/engine/components/libnotify/libnotify-main.h	Sun Feb 22 10:47:19 2009
@@ -0,0 +1,45 @@
+
+/* Ekiga -- A VoIP and Video-Conferencing application
+ * Copyright (C) 2000-2009 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *
+ * Ekiga is licensed under the GPL license and as a special exception,
+ * you have permission to link or otherwise combine this program with the
+ * programs OPAL, OpenH323 and PWLIB, and distribute the combination,
+ * without applying the requirements of the GNU GPL to the OPAL, OpenH323
+ * and PWLIB programs, as long as you do follow the requirements of the
+ * GNU GPL for all the rest of the software thus combined.
+ */
+
+
+/*
+ *                         libnotify-main.h  -  description
+ *                         ------------------------------------------
+ *   begin                : written in 2009 by Julien Puydt
+ *   copyright            : (c) 2009 by Julien Puydt
+ *   description          : code to hook libnotify to ekiga
+ *
+ */
+
+#ifndef __LIBNOTIFY_MAIN_H__
+#define __LIBNOTIFY_MAIN_H__
+
+#include "kickstart.h"
+
+void libnotify_init (Ekiga::KickStart& kickstart);
+
+#endif

Modified: trunk/lib/engine/engine.cpp
==============================================================================
--- trunk/lib/engine/engine.cpp	(original)
+++ trunk/lib/engine/engine.cpp	Sun Feb 22 10:47:19 2009
@@ -99,6 +99,10 @@
 #include "ldap-main.h"
 #endif
 
+#ifdef HAVE_LIBNOTIFY
+#include "libnotify-main.h"
+#endif
+
 #ifdef HAVE_GSTREAMER
 #include "gst-main.h"
 #endif
@@ -198,6 +202,10 @@
     return;
   }
 
+#ifdef HAVE_LIBNOTIFY
+  libnotify_init (kickstart);
+#endif
+
 #ifdef HAVE_GSTREAMER
   (void)gstreamer_init (*service_core, &argc, &argv);
 #endif



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