Activate Wayland notifications in bluetooth_notification_client
authorManuel Bachmann <manuel.bachmann@open.eurogiciel.org>
Sun, 1 Jun 2014 06:16:32 +0000 (08:16 +0200)
committerManuel Bachmann <manuel.bachmann@open.eurogiciel.org>
Sun, 1 Jun 2014 06:16:32 +0000 (08:16 +0200)
Add a conditional dependency to libwlmessage, and make
bluetooth_notification_client use it if found.

Change-Id: Ic968858bdf52054516d0a3c4365a7c7874ad1916
Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
Makefile.am
bluetooth_notification_client.c
configure.ac
packaging/notification-service.spec

index 60a8844..e54f3de 100644 (file)
@@ -3,6 +3,10 @@ bin_PROGRAMS = notification-service sample-display-client send-notification blue
 AM_CFLAGS = $(GCC_CFLAGS)
 AM_CPPFLAGS = $(GCC_CFLAGS)
 
+if HAVE_WAYLAND
+AM_CPPFLAGS += -DHAVE_WAYLAND
+endif
+
 notification_service_SOURCES = \
     main.c \
     notification_service.c \
index ffe475e..1b8ab7c 100644 (file)
@@ -6,6 +6,9 @@
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
 #include <bundle.h>
+#ifdef HAVE_WAYLAND
+#include <libwlmessage.h>
+#endif
 
 typedef enum {
            BT_AGENT_ACCEPT,
@@ -102,6 +105,20 @@ __display_notification(bt_notification cb_1, bt_notification cb_2, DBusGProxy *p
          bt_yesno = 1;
          char line[4];
 
+#ifdef HAVE_WAYLAND
+         struct wlmessage *wlmessage = wlmessage_create();
+         wlmessage_set_message(wlmessage, "Do you confirm ?");
+         wlmessage_add_button(wlmessage, 1, "Yes");
+         wlmessage_add_button(wlmessage, 0, "No");
+         wlmessage_set_default_button(wlmessage, 1);
+         bt_yesno = wlmessage_show(wlmessage, NULL);
+         wlmessage_destroy(wlmessage);
+
+         if (bt_yesno == 1)
+                 (cb_1) (proxy);
+         else if (bt_yesno == 0)
+                 (cb_2) (proxy);
+#else
          fprintf(stdout, "Do you confirm yes or no ? ");
          while ( bt_yesno != 0){
                  if (!fgets(line, sizeof(line), stdin))
@@ -116,6 +133,7 @@ __display_notification(bt_notification cb_1, bt_notification cb_2, DBusGProxy *p
                          fprintf(stdout," yes or no :");
                  }
          }
+#endif
          err = notification_delete_all_by_type("bluetooth-frwk-bt-service", NOTIFICATION_TYPE_NOTI);
          if (err != NOTIFICATION_ERROR_NONE) {
                   fprintf(stdout, "Unable to remove notifications");
index 9f7eae1..72aa0d8 100644 (file)
@@ -10,7 +10,12 @@ LT_PREREQ([2.2])
 LT_INIT([disable-static])
 
 PKG_PROG_PKG_CONFIG()
-PKG_CHECK_MODULES([TIZEN], [eina ecore com-core notification dbus-1 bluetooth-api])
+AC_ARG_ENABLE(wayland, [  --enable-wayland],, enable_wayland=no)
+AM_CONDITIONAL(HAVE_WAYLAND, test x$enable_wayland = xyes)
+if test "x$enable_wayland" = "xyes"; then
+  wayland_libs="libwlmessage"
+fi
+PKG_CHECK_MODULES([TIZEN], [eina ecore com-core notification dbus-1 bluetooth-api $wayland_libs])
 AC_SUBST(TIZEN_CFLAGS)
 AC_SUBST(TIZEN_LIBS)
 
index 33aad4f..708f0f7 100644 (file)
@@ -1,3 +1,5 @@
+%bcond_with wayland
+
 Name:       notification-service
 Summary:    Simple notification service
 Version:    0.0.3
@@ -14,6 +16,9 @@ BuildRequires: pkgconfig(dbus-1)
 BuildRequires: pkgconfig(dbus-glib-1)
 BuildRequires: pkgconfig(bluetooth-api)
 BuildRequires: pkgconfig(bundle)
+%if %{with wayland}
+BuildRequires: pkgconfig(libwlmessage)
+%endif
 %{?systemd_requires}
 
 %description
@@ -31,7 +36,11 @@ This package provides unit test used in the development of the notification serv
 %setup -q -n %{name}-%{version}
 
 %build
+%if %{with wayland}
+%autogen --enable-wayland
+%else
 %autogen
+%endif
 make %{?_smp_mflags}
 
 %install