Use the new wait/send API for interactive notifications 94/30094/2 accepted/tizen/common/20141114.144142 accepted/tizen/ivi/20141119.063314 submit/tizen_common/20141114.091625 submit/tizen_ivi/20141119.000000 submit/tizen_ivi/20141119.111111 submit/tizen_mobile/20141120.000000
authorManuel Bachmann <manuel.bachmann@open.eurogiciel.org>
Mon, 10 Nov 2014 13:51:02 +0000 (14:51 +0100)
committerManuel Bachmann <manuel.bachmann@open.eurogiciel.org>
Mon, 10 Nov 2014 14:27:54 +0000 (15:27 +0100)
If the notification has the EXECUTE_RESPONDING flag,
the display plugin will retrieve values from the attached
bundle to add an input textfield and multiple buttons,
and eventually send a response using the new
notification_send_response() API.

Bug-Tizen: TC-996

Change-Id: I6bc11837cc6c9fd5046f54152e1212ac948cd271
Signed-off-by: Manuel Bachmann <manuel.bachmann@open.eurogiciel.org>
plugins/wlmessage.c

index 1973bf7..6113580 100644 (file)
@@ -56,6 +56,13 @@ int display_notification (notification_h noti)
        char *title = NULL;
        char *content = NULL;
        char *image_path = NULL;
+       int result;
+
+       bundle *resp_data = NULL;
+       const char *buttons_str = NULL;
+       const char *textfield = NULL;
+       gchar **buttons = NULL;
+       int pos;
 
        notification_get_pkgname (noti, &pkgname);
        if (pkgname == NULL)
@@ -66,6 +73,14 @@ int display_notification (notification_h noti)
 
        LOGD("NOTIFICATION RECEIVED: %s - %s - %s", pkgname, title, content);
 
+        /* verify if we are supposed to respond to this notification */
+       notification_get_execute_option (noti, NOTIFICATION_EXECUTE_TYPE_RESPONDING,
+                                        NULL, &resp_data);
+       if (resp_data) {
+               buttons_str = bundle_get_val (resp_data, "buttons");
+               textfield = bundle_get_val (resp_data, "textfield");
+       }
+
        if (!strcasecmp(pkgname, "bluetooth-frwk-bt-service")) {
                bundle *user_data = NULL;
                DBusGProxy *proxy;
@@ -155,12 +170,27 @@ int display_notification (notification_h noti)
                wlmessage_set_title (wlmessage, title);
                wlmessage_set_icon (wlmessage, image_path);
                wlmessage_set_message (wlmessage, content);
-               wlmessage_add_button (wlmessage, 0, "Ok");
-               if (wlmessage_show (wlmessage, NULL) < 0) {
+               if (textfield)
+                       wlmessage_set_textfield (wlmessage, (char *)textfield);
+               if (buttons_str) {
+                       buttons = g_strsplit (buttons_str, ",", 0);
+                       for (pos = 0; buttons[pos]; pos++)
+                               wlmessage_add_button (wlmessage, pos + 1, buttons[pos]);
+                       g_strfreev (buttons);
+               } else {
+                       wlmessage_add_button (wlmessage, 0, "Ok");
+               }
+               wlmessage_set_timeout (wlmessage, 60);
+
+               result = wlmessage_show (wlmessage, NULL);
+               if (result < 0) {
                        wlmessage_destroy (wlmessage);
                        return 0;
+               } else if (result > 0) {
+                       notification_send_response (noti, result, (char *)textfield);
+                       return 1;
+               } else {
+                       return 1;
                }
-
-               return 1;
        }
 }