X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=notification_display_service.c;h=1cb2c7118f6ce396278cee39a155983caabfbfa0;hb=96473214d63d3f991fba448eeb7887a09f5e5701;hp=3e25ea5dfe65967cbea5a98a27dfcb216cf3d024;hpb=cc0afaa75d95225665f304933a146fb33ce1aa5a;p=platform%2Fcore%2Fappfw%2Fnotification-service.git diff --git a/notification_display_service.c b/notification_display_service.c index 3e25ea5..1cb2c71 100644 --- a/notification_display_service.c +++ b/notification_display_service.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -27,6 +28,9 @@ void display_notifications () char *title = NULL; char *content = NULL; char *image_path = NULL; + char *info1 = NULL; + enum { NOTIF_TYPE_INFO, NOTIF_TYPE_USERPROMPT, NOTIF_TYPE_USERCONFIRM } type = 0; + notification_get_list (NOTIFICATION_TYPE_NOTI, -1, ¬ification_list); if (notification_list) { @@ -40,18 +44,53 @@ void display_notifications () notification_get_text (noti, NOTIFICATION_TEXT_TYPE_CONTENT, &content); notification_get_image (noti, NOTIFICATION_IMAGE_TYPE_ICON, &image_path); + /* react specifically to the source framework and event (TODO : plugins !) */ + if (!strcmp(pkgname, "bt-agent")) { + notification_get_text (noti, NOTIFICATION_TEXT_TYPE_INFO_1, &info1); + if (info1) { + if ( (!strcmp(info1, "RequestPinCode")) || (!strcmp(info1, "RequestPasskey")) ) { + type = NOTIF_TYPE_USERPROMPT; + } + else if (!strcmp(info1, "RequestConfirmation")) { + type = NOTIF_TYPE_USERCONFIRM; + content = "Please confirm"; + } + } + } + # ifdef HAVE_WAYLAND struct wlmessage *wlmessage = wlmessage_create (); - wlmessage_set_title (wlmessage, title); - wlmessage_set_icon (wlmessage, image_path); - wlmessage_set_message (wlmessage, content); - wlmessage_add_button (wlmessage, 0, "Ok"); - wlmessage_show (wlmessage, NULL); + if (title) + wlmessage_set_title (wlmessage, title); + if (image_path) + wlmessage_set_icon (wlmessage, image_path); + if (content) + wlmessage_set_message (wlmessage, content); + else + wlmessage_set_message (wlmessage, ""); + if (type == NOTIF_TYPE_USERPROMPT) + wlmessage_set_textfield (wlmessage, ""); + if (type == NOTIF_TYPE_USERCONFIRM) { + wlmessage_add_button (wlmessage, 1, "Yes"); + wlmessage_add_button (wlmessage, 0, "No"); + } else { + wlmessage_add_button (wlmessage, 0, "Ok"); + } + + if (wlmessage_show (wlmessage, NULL) < 0) { + wlmessage_destroy (wlmessage); + return; + } wlmessage_destroy (wlmessage); + +# else + fprintf(stderr, "\nNew Notification : %s\n", title); + fprintf(stderr, "Icon : %s\n", image_path); + fprintf(stderr, "Message : %s\n", content); # endif - notification_delete (noti); - get_list = notification_list_get_head (notification_list); + get_list = notification_list_remove(get_list, noti); + notification_delete(noti); } } } @@ -71,7 +110,7 @@ int main (int argc, char **argv) } signal (SIGINT, sigint_handler); - wd = inotify_add_watch (fd, "/opt/dbspace/.notification.db", IN_MODIFY); + wd = inotify_add_watch (fd, "/usr/dbspace/.notification.db", IN_MODIFY); while (1) { read (fd, buffer, sizeof(buffer)); display_notifications ();