bluetooth_notification_client: activate GUI notifications 07/26907/2
authorCorentin Lecouvey <corentin.lecouvey@open.eurogiciel.org>
Fri, 29 Aug 2014 12:10:00 +0000 (14:10 +0200)
committerManuel Bachmann <manuel.bachmann@open.eurogiciel.org>
Thu, 4 Sep 2014 13:47:30 +0000 (15:47 +0200)
Add a dependency on libwlmessage, which will be used by
blueooth_notification_client to display popup messages
on both Wayland and X11.

dlog some of the error messages.

Change-Id: Ic85de8aad4f20f080c6776ded5dd2237b6364271
Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
Author: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
Author: Corentin Lecouvey <corentin.lecouvey@open.eurogiciel.org>

bluetooth_notification_client.c
configure.ac
packaging/notification-service.spec

index ffe475e..bffaecd 100644 (file)
@@ -6,6 +6,8 @@
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
 #include <bundle.h>
+#include <dlog.h>
+#include <libwlmessage.h>
 
 typedef enum {
            BT_AGENT_ACCEPT,
@@ -98,27 +100,46 @@ __display_notification(bt_notification cb_1, bt_notification cb_2, DBusGProxy *p
 {
 
          notification_error_e err = NOTIFICATION_ERROR_NONE;
-         int bt_yesno;
-         bt_yesno = 1;
+         int bt_yesno = 1;
          char line[4];
 
+         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) {
+                 LOGD("user accepts to pair with device ");
+                 (cb_1) (proxy);
+         } else if (bt_yesno == 0) {
+                 LOGD("user rejects to pair with device ");
+                 (cb_2) (proxy);
+       }
+
+#if 0
          fprintf(stdout, "Do you confirm yes or no ? ");
          while ( bt_yesno != 0){
                  if (!fgets(line, sizeof(line), stdin))
                          continue;
-                 if ( strcmp(line,"yes") == 0){
+                 if (strncmp("yes", line, 3) == 0) {
+                         LOGD("user accepts to pair with device ");
                          (cb_1) (proxy);
                          bt_yesno = 0;
-                 } else if ( strcmp(line,"no") == 0){
+                 } else if (strncmp("no", line, 2) == 0) {
+                         LOGD("user rejects to pair with device ");
                          (cb_2) (proxy);
                          bt_yesno = 0;
                  } else {
-                         fprintf(stdout," yes or no :");
+                         fprintf(stdout," yes or no ?\n");
                  }
          }
+#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");
+                  LOGE("Unable to remove notifications");
          }
 
 }
@@ -169,6 +190,11 @@ static void __noti_changed_cb(void *data, notification_type_e type)
 
                 event_type = bundle_get_val(user_data, "event-type");
 
+                if (!event_type) {
+                        LOGD("Not a bluetooth-related notification...");
+                        return;
+               }
+
                 if(!strcasecmp(event_type, "pin-request")) {
                         /* Not implemented */
                         fprintf(stdout," Not implemented\n");
@@ -314,7 +340,7 @@ int
 main(int argc, char **argv)
 {
     if (!ecore_init()) {
-        fprintf(stderr, "ERROR: Cannot init Ecore!\n");
+        LOGE("ERROR: Cannot init Ecore!\n");
         return -1;
     }
 
@@ -323,6 +349,6 @@ main(int argc, char **argv)
 
  shutdown:
     ecore_shutdown();
-    return 0;
+    return 1;
 }
 
index 9f7eae1..194baa9 100644 (file)
@@ -10,7 +10,7 @@ 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])
+PKG_CHECK_MODULES([TIZEN], [eina ecore com-core notification dbus-1 bluetooth-api dlog libwlmessage])
 AC_SUBST(TIZEN_CFLAGS)
 AC_SUBST(TIZEN_LIBS)
 
index 33aad4f..8772d1e 100644 (file)
@@ -1,3 +1,5 @@
+%bcond_with wayland
+
 Name:       notification-service
 Summary:    Simple notification service
 Version:    0.0.3
@@ -13,7 +15,9 @@ BuildRequires: pkgconfig(notification-service)
 BuildRequires: pkgconfig(dbus-1)
 BuildRequires: pkgconfig(dbus-glib-1)
 BuildRequires: pkgconfig(bluetooth-api)
+BuildRequires: pkgconfig(dlog)
 BuildRequires: pkgconfig(bundle)
+BuildRequires: pkgconfig(libwlmessage)
 %{?systemd_requires}
 
 %description