[ekiga] libnotify: Fixed compilation and use without it.



commit f11079a99a4147be88f5a1e12e23209ff58c9daf
Author: Damien Sandras <dsandras beip be>
Date:   Sun Apr 22 13:08:52 2012 +0200

    libnotify: Fixed compilation and use without it.

 src/Makefile.am         |    8 +----
 src/gui/call_window.cpp |    4 ---
 src/gui/main_window.cpp |   63 +++--------------------------------------------
 src/gui/notify.cpp      |   23 ++++++++++++----
 src/gui/notify.h        |    6 ++--
 5 files changed, 26 insertions(+), 78 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 0c9eac7..bc43a34 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -69,6 +69,8 @@ ekiga_SOURCES +=			\
 	gui/call_window.cpp		\
 	gui/main_window.h		\
 	gui/main_window.cpp		\
+	gui/notify.h		        \
+	gui/notify.cpp                  \
 	gui/preferences.h		\
 	gui/preferences.cpp		\
 	gui/statusicon.h		\
@@ -76,12 +78,6 @@ ekiga_SOURCES +=			\
 	gui/statusmenu.h		\
 	gui/statusmenu.cpp
 
-if HAVE_NOTIFY
-ekiga_SOURCES +=               		\
-	gui/notify.h		        \
-	gui/notify.cpp
-endif
-
 # Endpoints
 ekiga_SOURCES +=			\
 	ekiga.h			        \
diff --git a/src/gui/call_window.cpp b/src/gui/call_window.cpp
index efc89f9..c5a3f59 100644
--- a/src/gui/call_window.cpp
+++ b/src/gui/call_window.cpp
@@ -78,10 +78,6 @@
 #include <cstdio>
 #endif
 
-#ifdef HAVE_NOTIFY
-#include <libnotify/notify.h>
-#endif
-
 #if defined(P_FREEBSD) || defined (P_MACOSX)
 #include <libintl.h>
 #endif
diff --git a/src/gui/main_window.cpp b/src/gui/main_window.cpp
index bb61f6c..bb29982 100644
--- a/src/gui/main_window.cpp
+++ b/src/gui/main_window.cpp
@@ -46,6 +46,7 @@
 #include "callbacks.h"
 #include "dialpad.h"
 #include "statusmenu.h"
+#include "notify.h"
 
 #include "gmdialog.h"
 #include "gmentrydialog.h"
@@ -76,10 +77,6 @@
 #include <cstdio>
 #endif
 
-#ifdef HAVE_NOTIFY
-#include <libnotify/notify.h>
-#endif
-
 #if defined(P_FREEBSD) || defined (P_MACOSX)
 #include <libintl.h>
 #endif
@@ -422,31 +419,6 @@ void on_some_core_updated (EkigaMainWindow* self)
   }
 }
 
-#ifdef HAVE_NOTIFY
-// return if the notify server accepts actions (i.e. buttons)
-// taken from https://wiki.ubuntu.com/NotificationDevelopmentGuidelines#Avoiding%20actions
-int hasActionsCap (void)
-{
-  static int accepts_actions = -1;
-  if (accepts_actions == -1) {  // initialise accepts_actions at the first call
-    accepts_actions = 0;
-    GList *capabilities = notify_get_server_caps ();
-    if (capabilities != NULL) {
-      for (GList *c = capabilities ; c != NULL ; c = c->next) {
-        if (strcmp ((char*)c->data, "actions") == 0 ) {
-          accepts_actions = 1;
-          break;
-        }
-      }
-      g_list_foreach (capabilities, (GFunc)g_free, NULL);
-      g_list_free (capabilities);
-    }
-  }
-  return accepts_actions;
-}
-#endif
-
-
 /* implementation of the name_from_uri_helper */
 const std::string
 name_from_uri_helper::search_name_for_uri (const std::string uri)
@@ -653,12 +625,9 @@ static void on_setup_call_cb (boost::shared_ptr<Ekiga::CallManager> manager,
       return; // No call setup needed if already in a call
 
     audiooutput_core->start_play_event ("incoming_call_sound", 4000, 256);
-#ifdef HAVE_NOTIFY
-    if (!hasActionsCap ())
+    if (!notify_has_actions ())
       ekiga_main_window_incoming_call_dialog_show (mw, call);
-#else
-    ekiga_main_window_incoming_call_dialog_show (mw, call);
-#endif
+
     mw->priv->current_call = call;
     mw->priv->calling_state = Called;
   }
@@ -758,7 +727,7 @@ static void on_cleared_call_cb (boost::shared_ptr<Ekiga::CallManager>  /*manager
 }
 
 static void on_cleared_incoming_call_cb (std::string /*reason*/,
-                                         gpointer self)
+                                         gpointer /*self*/)
 {
   EkigaMainWindow *mw = EKIGA_MAIN_WINDOW (GnomeMeeting::Process ()->GetMainWindow ());
   GtkWidget *call_window = NULL;
@@ -772,15 +741,6 @@ static void on_cleared_incoming_call_cb (std::string /*reason*/,
   audiooutput_core->stop_play_event("incoming_call_sound");
   audiooutput_core->stop_play_event("ring_tone_sound");
 
-#ifdef HAVE_NOTIFY
-  if (hasActionsCap ())
-    notify_notification_close (NOTIFY_NOTIFICATION (self), NULL);
-  else
-    gtk_widget_destroy (GTK_WIDGET (self));
-#else
-  gtk_widget_destroy (GTK_WIDGET (self));
-#endif
-
   /* Hide call window */
   if (!gm_conf_get_bool (VIDEO_DEVICES_KEY "enable_preview")) {
     call_window = GnomeMeeting::Process ()->GetCallWindow ();
@@ -795,14 +755,7 @@ static void on_cleared_incoming_call_cb (std::string /*reason*/,
 
 static void on_incoming_call_gone_cb (gpointer self)
 {
-#ifdef HAVE_NOTIFY
-  if (hasActionsCap ())
-    notify_notification_close (NOTIFY_NOTIFICATION (self), NULL);
-  else
-    gtk_widget_destroy (GTK_WIDGET (self));
-#else
   gtk_widget_destroy (GTK_WIDGET (self));
-#endif
 }
 
 
@@ -2326,10 +2279,6 @@ main (int argc,
   g_option_context_parse (context, &argc, &argv, NULL);
   g_option_context_free (context);
 
-#ifdef HAVE_NOTIFY
-  notify_init (PACKAGE_NAME);
-#endif
-
 #ifndef WIN32
   char* text_label =  g_strdup_printf ("%d", debug_level);
   setenv ("PTLIB_TRACE_CODECS", text_label, TRUE);
@@ -2428,10 +2377,6 @@ main (int argc,
   /* deinitialize platform-specific code */
   gm_platform_shutdown ();
 
-#ifdef HAVE_NOTIFY
-  notify_uninit ();
-#endif
-
   return 0;
 }
 
diff --git a/src/gui/notify.cpp b/src/gui/notify.cpp
index be916d1..e138a56 100644
--- a/src/gui/notify.cpp
+++ b/src/gui/notify.cpp
@@ -35,7 +35,6 @@
  */
 
 
-#include <libnotify/notify.h>
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
 
@@ -54,6 +53,9 @@
 #include "call-core.h"
 #include "gtk-frontend.h"
 
+#ifdef HAVE_NOTIFY
+#include <libnotify/notify.h>
+
 struct CallNotificationInfo
 {
   boost::shared_ptr<Ekiga::Call> call;
@@ -196,14 +198,15 @@ static void on_setup_call_cb (boost::shared_ptr<Ekiga::CallManager> manager,
   if (!call->is_outgoing () && !manager->get_auto_answer () && notify_has_actions ())
     ekiga_incoming_call_notify (call);
 }
-
+#endif
 
 /*
  * Public API
  */
-void
+bool
 notify_start (Ekiga::ServiceCore & core)
 {
+#ifdef HAVE_NOTIFY
   boost::shared_ptr<GtkFrontend> frontend = core.get<GtkFrontend> ("gtk-frontend");
   boost::shared_ptr<Ekiga::CallCore> call_core = core.get<Ekiga::CallCore> ("call-core");
   boost::shared_ptr<Ekiga::AccountCore> account_core = core.get<Ekiga::AccountCore> ("account-core");
@@ -213,12 +216,17 @@ notify_start (Ekiga::ServiceCore & core)
   call_core->setup_call.connect (boost::bind (&on_setup_call_cb, _1, _2));
 
   g_signal_connect (chat_window, "unread-count", G_CALLBACK (on_unread_count_cb), chat_window);
+  return true;
+#else
+  return false;
+#endif
 }
 
-gboolean
+bool
 notify_has_actions (void)
 {
   static int accepts_actions = -1;
+#ifdef HAVE_NOTIFY
   if (accepts_actions == -1) {  // initialise accepts_actions at the first call
     accepts_actions = 0;
     GList *capabilities = notify_get_server_caps ();
@@ -233,13 +241,15 @@ notify_has_actions (void)
       g_list_free (capabilities);
     }
   }
+#endif
   return (accepts_actions > 0);
 }
 
-gboolean
+bool
 notify_has_persistence (void)
 {
-  gboolean has;
+  gboolean has = false;
+#ifdef HAVE_NOTIFY
   GList   *caps;
   GList   *l;
 
@@ -254,6 +264,7 @@ notify_has_persistence (void)
 
   g_list_foreach (caps, (GFunc) g_free, NULL);
   g_list_free (caps);
+#endif
 
   return has;
 }
diff --git a/src/gui/notify.h b/src/gui/notify.h
index c4fafaf..e26fdc3 100644
--- a/src/gui/notify.h
+++ b/src/gui/notify.h
@@ -49,18 +49,18 @@ G_BEGIN_DECLS
 /* DESCRIPTION  : /
  * BEHAVIOR     : Start the notifications monitoring
  */
-void notify_start (Ekiga::ServiceCore & core);
+bool notify_start (Ekiga::ServiceCore & core);
 
 /* DESCRIPTION  : /
  * BEHAVIOR     : Returns true if notification server supports actions.
  */
-gboolean notify_has_actions (void);
+bool notify_has_actions (void);
 
 /* DESCRIPTION  : /
  * BEHAVIOR     : Returns true if notification server supports persistent
  *                notifications.
  */
-gboolean notify_has_persistence (void);
+bool notify_has_persistence (void);
 
 G_END_DECLS
 



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