From 81d8b0c9e8437729b0838433673a4fc1c792f613 Mon Sep 17 00:00:00 2001 From: Rusty Lynch Date: Thu, 24 Oct 2013 12:58:59 -0700 Subject: [PATCH 01/16] Fix build warnings - Stop using deprecated gets - Fix prototype for notification callback Change-Id: I56b088c461d04bf26ae568ce9074e0b680e57847 Signed-off-by: Rusty Lynch --- bluetooth_notification_client.c | 33 +++++++++++++++++---------------- packaging/notification-service.changes | 4 ++++ 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/bluetooth_notification_client.c b/bluetooth_notification_client.c index 50a3095..2ccd5ad 100644 --- a/bluetooth_notification_client.c +++ b/bluetooth_notification_client.c @@ -100,11 +100,12 @@ __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; - char line[256]; + char line[4]; fprintf(stdout, "Do you confirm yes or no ? "); while ( bt_yesno != 0){ - gets(line); + if (!fgets(line, sizeof(line), stdin)) + continue; if ( strcmp(line,"yes") == 0){ (cb_1) (proxy); bt_yesno = 0; @@ -122,7 +123,7 @@ __display_notification(bt_notification cb_1, bt_notification cb_2, DBusGProxy *p } -static int __noti_changed_cb(void *data, notification_type_e type) +static void __noti_changed_cb(void *data, notification_type_e type) { notification_h noti = NULL; notification_list_h notification_list = NULL; @@ -180,13 +181,13 @@ static int __noti_changed_cb(void *data, notification_type_e type) sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); if (sys_conn == NULL) { fprintf(stdout,"ERROR: Can't get on system bus"); - return EXIT_FAILURE; + return; } agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path); if (!agent_proxy){ fprintf(stdout,"create new agent_proxy failed\n"); - return EXIT_FAILURE; + return; } __display_notification(__notify_passkey_confirm_request_accept_cb, __notify_passkey_confirm_request_cancel_cb,agent_proxy); @@ -205,13 +206,13 @@ static int __noti_changed_cb(void *data, notification_type_e type) sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); if (sys_conn == NULL) { fprintf(stdout,"ERROR: Can't get on system bus"); - return EXIT_FAILURE; + return; } agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path); if (!agent_proxy){ fprintf(stdout,"create new agent_proxy failed\n"); - return EXIT_FAILURE; + return; } __display_notification( __notify_authorize_request_accept_cb, __notify_authorize_request_cancel_cb,agent_proxy); @@ -226,13 +227,13 @@ static int __noti_changed_cb(void *data, notification_type_e type) sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); if (sys_conn == NULL) { fprintf(stdout,"ERROR: Can't get on system bus"); - return EXIT_FAILURE; + return; } obex_proxy = __bluetooth_create_obex_proxy(sys_conn); if (!obex_proxy){ fprintf(stdout,"create new obex_proxy failed\n"); - return EXIT_FAILURE; + return; } __display_notification( __notify_push_authorize_request_accept_cb, __notify_push_authorize_request_cancel_cb,obex_proxy); @@ -255,13 +256,13 @@ static int __noti_changed_cb(void *data, notification_type_e type) sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); if (sys_conn == NULL) { fprintf(stdout,"ERROR: Can't get on system bus"); - return EXIT_FAILURE; + return; } agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path); if (!agent_proxy){ fprintf(stdout,"create new agent_proxy failed\n"); - return EXIT_FAILURE; + return; } __display_notification( __notify_authorize_request_accept_cb, __notify_authorize_request_cancel_cb,agent_proxy); @@ -272,13 +273,13 @@ static int __noti_changed_cb(void *data, notification_type_e type) sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); if (sys_conn == NULL) { fprintf(stdout,"ERROR: Can't get on system bus"); - return EXIT_FAILURE; + return; } agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path); if (!agent_proxy){ fprintf(stdout,"create new agent_proxy failed\n"); - return EXIT_FAILURE; + return; } __display_notification( __notify_authorize_request_accept_cb, __notify_authorize_request_cancel_cb,agent_proxy); @@ -289,13 +290,13 @@ static int __noti_changed_cb(void *data, notification_type_e type) sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); if (sys_conn == NULL) { fprintf(stdout,"ERROR: Can't get on system bus"); - return EXIT_FAILURE; + return; } agent_proxy = __bluetooth_create_agent_proxy(sys_conn, agent_path); if (!agent_proxy){ fprintf(stdout,"create new agent_proxy failed\n"); - return EXIT_FAILURE; + return; } __display_notification( __notify_authorize_request_accept_cb, __notify_authorize_request_cancel_cb,agent_proxy); @@ -306,7 +307,7 @@ static int __noti_changed_cb(void *data, notification_type_e type) notification_list = NULL; } - return EXIT_SUCCESS; + return; } int diff --git a/packaging/notification-service.changes b/packaging/notification-service.changes index 01b10c1..27d4d6b 100644 --- a/packaging/notification-service.changes +++ b/packaging/notification-service.changes @@ -1,3 +1,7 @@ +* Thu Oct 24 2013 Rusty Lynch accepted/tizen/20130920.213625@237321e +- Fix build warnings by no longer using 'gets' and fixing the + prototype for notification callback + * Fri Sep 20 2013 Rusty Lynch accepted/tizen/20130917.000007@6b2a8d7 - Add Bluetooth-client-notification to test bluetooth pairing - Send and display content from notification -- 2.7.4 From 42929a10a04bfe1b91648fad8d12bb6a57ca9364 Mon Sep 17 00:00:00 2001 From: Corentin Lecouvey Date: Thu, 16 Jan 2014 15:28:45 +0100 Subject: [PATCH 02/16] Do not use systemd socket mechanism Notifications daemon discusses with its clients using secure sockets. Secure sockets are not adapted to systemd socket. Now notifications daemon is started at boot time. Change-Id: If6ee8164df1d1db18b973da62d5b066d06c44524 Signed-off-by: Corentin Lecouvey --- Makefile.am | 8 ++------ configure.ac | 2 +- notifications.service.in | 6 ++++++ packaging/notification-service.spec | 25 ++++++++++++++++--------- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/Makefile.am b/Makefile.am index 28b715c..60a8844 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,12 +23,8 @@ bluetooth_notification_client_CFLAGS = -I. $(TIZEN_CFLAGS) bluetooth_notification_client_LDADD = $(TIZEN_LIBS) SCRIPT_IN_FILES = \ - notifications.service.in \ - notifications.socket.in + notifications.service.in install-data-hook: - $(mkinstalldirs) $(DESTDIR)/usr/lib/systemd/system/sockets.target.wants + $(mkinstalldirs) $(DESTDIR)/usr/lib/systemd/system/ install -m 0644 notifications.service $(DESTDIR)/usr/lib/systemd/system/notifications.service - install -m 0644 notifications.socket $(DESTDIR)/usr/lib/systemd/system/notifications.socket - ln -fs ../notifications.socket $(DESTDIR)/usr/lib/systemd/system/sockets.target.wants/notifications.socket - diff --git a/configure.ac b/configure.ac index 56dec67..9f7eae1 100644 --- a/configure.ac +++ b/configure.ac @@ -14,6 +14,6 @@ PKG_CHECK_MODULES([TIZEN], [eina ecore com-core notification dbus-1 bluetooth-ap AC_SUBST(TIZEN_CFLAGS) AC_SUBST(TIZEN_LIBS) -AC_CONFIG_FILES([Makefile notifications.service notifications.socket]) +AC_CONFIG_FILES([Makefile notifications.service]) AC_PROG_RANLIB([ranlib]) AC_OUTPUT diff --git a/notifications.service.in b/notifications.service.in index 47db370..ebbd62c 100644 --- a/notifications.service.in +++ b/notifications.service.in @@ -1,2 +1,8 @@ +[Unit] +Description=Notifications daemon + [Service] ExecStart=/usr/bin/notification-service + +[Install] +WantedBy=graphical.target diff --git a/packaging/notification-service.spec b/packaging/notification-service.spec index e48dfa8..ecea933 100644 --- a/packaging/notification-service.spec +++ b/packaging/notification-service.spec @@ -9,10 +9,11 @@ BuildRequires: pkgconfig(eina) BuildRequires: pkgconfig(ecore) BuildRequires: pkgconfig(com-core) BuildRequires: pkgconfig(notification) -BuildRequires: dbus-devel +BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(dbus-glib-1) -BuildRequires: bluetooth-frwk-devel -BuildRequires: bundle-devel +BuildRequires: pkgconfig(bluetooth-api) +BuildRequires: pkgconfig(bundle) +%{?systemd_requires} %description Headless notification service that collects incoming notifications from the @@ -28,22 +29,28 @@ This package provides unit test used in the development of the notification serv %prep %setup -q -n %{name}-%{version} -%define PREFIX %{_prefix}/apps/ - %build %autogen make %{?_smp_mflags} %install -rm -rf %{buildroot} %make_install +%install_service graphical.target.wants notifications.service + +%post +%systemd_post notifications.service + +%preun +%systemd_preun notifications.service + +%postun +%systemd_postun notifications.service %files %defattr(-,root,root,-) %{_bindir}/notification-service -%{_libdir}/systemd/system/notifications.service -%{_libdir}/systemd/system/notifications.socket -%{_libdir}/systemd/system/sockets.target.wants/notifications.socket +%{_unitdir}/notifications.service +%{_unitdir}/graphical.target.wants/notifications.service %files test %defattr(-,root,root,-) -- 2.7.4 From 800d8f5c481bda3fd05868f575a9b945e726a2eb Mon Sep 17 00:00:00 2001 From: Corentin Lecouvey Date: Thu, 16 Jan 2014 15:42:04 +0100 Subject: [PATCH 03/16] adapt agent dbus interface to BlueZ 5 in test program Change-Id: Ic17652f6d5dda394c168f892b2452305648f663b Signed-off-by: Corentin Lecouvey --- bluetooth_notification_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bluetooth_notification_client.c b/bluetooth_notification_client.c index 2ccd5ad..ffe475e 100644 --- a/bluetooth_notification_client.c +++ b/bluetooth_notification_client.c @@ -23,7 +23,7 @@ __bluetooth_create_agent_proxy(DBusGConnection *sys_conn, const char *path) return dbus_g_proxy_new_for_name (sys_conn, "org.projectx.bt", path, - "org.bluez.Agent"); + "org.bluez.Agent1"); } static DBusGProxy* -- 2.7.4 From 5c1deada45c2f66ba1f493bee8bc333914e0ff29 Mon Sep 17 00:00:00 2001 From: Manuel Bachmann Date: Tue, 20 May 2014 11:43:35 +0200 Subject: [PATCH 04/16] send-notification: do not send a notification when using "--help" The "--help" option should make the program display the help text and return directly, not sending a blank notification. Change-Id: Ifb2f9ede3b64338cba792c6b98a9e9f610fd5a11 Signed-off-by: Manuel Bachmann --- send_notification.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/send_notification.c b/send_notification.c index 0a15d86..a42b9dd 100644 --- a/send_notification.c +++ b/send_notification.c @@ -75,6 +75,7 @@ main(int argc, char **argv) char *icon = NULL; char *image = NULL; int imageType = 0; + Eina_Bool quit = EINA_FALSE; Eina_Bool remove = EINA_FALSE; notification_h noti = NULL; notification_error_e err = NOTIFICATION_ERROR_NONE; @@ -85,7 +86,8 @@ main(int argc, char **argv) ECORE_GETOPT_VALUE_STR(icon), ECORE_GETOPT_VALUE_STR(image), ECORE_GETOPT_VALUE_INT(imageType), - ECORE_GETOPT_VALUE_NONE + ECORE_GETOPT_VALUE_NONE, + ECORE_GETOPT_VALUE_BOOL(quit) }; if (!ecore_init()) { @@ -98,6 +100,9 @@ main(int argc, char **argv) return -1; } + if (quit) + return 0; + noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE); -- 2.7.4 From 97d87d6956ae90d7bc9988480028cc8d5e647652 Mon Sep 17 00:00:00 2001 From: Stephane Desneux Date: Thu, 22 May 2014 00:44:36 +0200 Subject: [PATCH 05/16] Fix build dependency (notification-service-devel) Commit 38b527f on platform/core/api/notification splitted notification API in two packages. Dependency on notification-service-devel was added. Change-Id: I40cbfd36281275fd89ab4daf671e406db9fb8a49 Signed-off-by: Stephane Desneux --- notification_service.c | 4 ++-- packaging/notification-service.spec | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/notification_service.c b/notification_service.c index 93e8d52..569de48 100644 --- a/notification_service.c +++ b/notification_service.c @@ -16,8 +16,8 @@ #include #include #include -#include -#include +#include +#include #include #include "service_common.h" diff --git a/packaging/notification-service.spec b/packaging/notification-service.spec index ecea933..33aad4f 100644 --- a/packaging/notification-service.spec +++ b/packaging/notification-service.spec @@ -5,10 +5,11 @@ Release: 1 Group: Application Framework/Notifications License: Flora Source0: %{name}-%{version}.tar.bz2 -BuildRequires: pkgconfig(eina) -BuildRequires: pkgconfig(ecore) -BuildRequires: pkgconfig(com-core) +BuildRequires: pkgconfig(eina) +BuildRequires: pkgconfig(ecore) +BuildRequires: pkgconfig(com-core) BuildRequires: pkgconfig(notification) +BuildRequires: pkgconfig(notification-service) BuildRequires: pkgconfig(dbus-1) BuildRequires: pkgconfig(dbus-glib-1) BuildRequires: pkgconfig(bluetooth-api) -- 2.7.4 From 81c3bdc85bb1ca835b41a95c1bca0eef8ac89a86 Mon Sep 17 00:00:00 2001 From: Manuel Bachmann Date: Fri, 29 Aug 2014 10:35:50 +0200 Subject: [PATCH 06/16] send-notification: do not send a notification when using "--help" Change-Id: I5d0b339e0c7e1dca644839d3e5e2061393687c7b Signed-off-by: Manuel Bachmann --- send_notification.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/send_notification.c b/send_notification.c index 0a15d86..a42b9dd 100644 --- a/send_notification.c +++ b/send_notification.c @@ -75,6 +75,7 @@ main(int argc, char **argv) char *icon = NULL; char *image = NULL; int imageType = 0; + Eina_Bool quit = EINA_FALSE; Eina_Bool remove = EINA_FALSE; notification_h noti = NULL; notification_error_e err = NOTIFICATION_ERROR_NONE; @@ -85,7 +86,8 @@ main(int argc, char **argv) ECORE_GETOPT_VALUE_STR(icon), ECORE_GETOPT_VALUE_STR(image), ECORE_GETOPT_VALUE_INT(imageType), - ECORE_GETOPT_VALUE_NONE + ECORE_GETOPT_VALUE_NONE, + ECORE_GETOPT_VALUE_BOOL(quit) }; if (!ecore_init()) { @@ -98,6 +100,9 @@ main(int argc, char **argv) return -1; } + if (quit) + return 0; + noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE); -- 2.7.4 From a6677f7ec1ca22e265d02e7d2f2418bd08f7d033 Mon Sep 17 00:00:00 2001 From: Corentin Lecouvey Date: Fri, 29 Aug 2014 14:10:00 +0200 Subject: [PATCH 07/16] bluetooth_notification_client: activate GUI notifications 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 Author: Manuel Bachmann Author: Corentin Lecouvey --- bluetooth_notification_client.c | 42 ++++++++++++++++++++++++++++++------- configure.ac | 2 +- packaging/notification-service.spec | 4 ++++ 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/bluetooth_notification_client.c b/bluetooth_notification_client.c index ffe475e..bffaecd 100644 --- a/bluetooth_notification_client.c +++ b/bluetooth_notification_client.c @@ -6,6 +6,8 @@ #include #include #include +#include +#include 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; } diff --git a/configure.ac b/configure.ac index 9f7eae1..194baa9 100644 --- a/configure.ac +++ b/configure.ac @@ -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) diff --git a/packaging/notification-service.spec b/packaging/notification-service.spec index 33aad4f..8772d1e 100644 --- a/packaging/notification-service.spec +++ b/packaging/notification-service.spec @@ -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 -- 2.7.4 From 2e671f2fe8c77fc9b560148f0263f26ec5b88713 Mon Sep 17 00:00:00 2001 From: Corentin Lecouvey Date: Mon, 1 Sep 2014 10:05:17 +0200 Subject: [PATCH 08/16] Create a "notification-display-service" daemon "notification-display-service" is run by a systemd unit named "notifications-display.service" ; if we are running under a Wayland or X11 profile, it will display new notifications under the form of customized popup windows, and delete them once they are validated with "Ok". Otherwise, it will just print the messages to stderr without deleting them. Change-Id: Id33b01d67df4d731f666c2b145262642ca21cdbc Signed-off-by: Manuel Bachmann Author: Manuel Bachmann Author: Corentin Lecouvey --- Makefile.am | 10 ++++- configure.ac | 2 +- notification_display_service.c | 87 +++++++++++++++++++++++++++++++++++++ notifications-display.service.in | 11 +++++ packaging/notification-service.spec | 4 ++ 5 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 notification_display_service.c create mode 100644 notifications-display.service.in diff --git a/Makefile.am b/Makefile.am index 60a8844..3ff5d19 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -bin_PROGRAMS = notification-service sample-display-client send-notification bluetooth_notification_client +bin_PROGRAMS = notification-service notification-display-service sample-display-client send-notification bluetooth_notification_client AM_CFLAGS = $(GCC_CFLAGS) AM_CPPFLAGS = $(GCC_CFLAGS) @@ -10,6 +10,10 @@ notification_service_SOURCES = \ notification_service_CFLAGS = -I. $(TIZEN_CFLAGS) notification_service_LDADD = $(TIZEN_LIBS) +notification_display_service_SOURCES = notification_display_service.c +notification_display_service_CFLAGS = -I. $(TIZEN_CFLAGS) +notification_display_service_LDADD = $(TIZEN_LIBS) + send_notification_SOURCES = send_notification.c send_notification_CFLAGS = -I. $(TIZEN_CFLAGS) send_notification_LDADD = $(TIZEN_LIBS) @@ -23,8 +27,10 @@ bluetooth_notification_client_CFLAGS = -I. $(TIZEN_CFLAGS) bluetooth_notification_client_LDADD = $(TIZEN_LIBS) SCRIPT_IN_FILES = \ - notifications.service.in + notifications.service.in \ + notifications-display.service.in install-data-hook: $(mkinstalldirs) $(DESTDIR)/usr/lib/systemd/system/ install -m 0644 notifications.service $(DESTDIR)/usr/lib/systemd/system/notifications.service + install -m 0644 notifications-display.service $(DESTDIR)/usr/lib/systemd/system/notifications-display.service diff --git a/configure.ac b/configure.ac index 194baa9..edb8edb 100644 --- a/configure.ac +++ b/configure.ac @@ -14,6 +14,6 @@ PKG_CHECK_MODULES([TIZEN], [eina ecore com-core notification dbus-1 bluetooth-ap AC_SUBST(TIZEN_CFLAGS) AC_SUBST(TIZEN_LIBS) -AC_CONFIG_FILES([Makefile notifications.service]) +AC_CONFIG_FILES([Makefile notifications.service notifications-display.service]) AC_PROG_RANLIB([ranlib]) AC_OUTPUT diff --git a/notification_display_service.c b/notification_display_service.c new file mode 100644 index 0000000..df35e42 --- /dev/null +++ b/notification_display_service.c @@ -0,0 +1,87 @@ +#include +#include +#include +#include +#include +#include + + +void display_notifications_cb (void *data, notification_type_e notif_type) +{ + notification_h noti = NULL; + notification_list_h notification_list = NULL; + notification_list_h get_list = NULL; + + char *pkgname = NULL; + char *title = NULL; + char *content = NULL; + char *image_path = NULL; + + notification_get_list (NOTIFICATION_TYPE_NOTI, -1, ¬ification_list); + if (notification_list) { + get_list = notification_list_get_head (notification_list); + while (get_list) { + noti = notification_list_get_data (get_list); + notification_get_pkgname (noti, &pkgname); + if (pkgname == NULL) + notification_get_application (noti, &pkgname); + notification_get_title (noti, &title, NULL); + notification_get_text (noti, NOTIFICATION_TEXT_TYPE_CONTENT, &content); + notification_get_image (noti, NOTIFICATION_IMAGE_TYPE_ICON, &image_path); + + 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"); + if (wlmessage_show (wlmessage, NULL) < 0) { + wlmessage_destroy (wlmessage); + return; + } + wlmessage_destroy (wlmessage); + + LOGD("\nNew Notification : %s\n", title); + LOGD("Icon : %s\n", image_path); + LOGD("Message : %s\n", content); + + get_list = notification_list_remove(get_list, noti); + notification_delete(noti); + } + } +} + +int main (int argc, char **argv) +{ + GMainLoop *mainloop = NULL; + notification_error_e error_n; + int error_s; + struct stat buf; + +retry_socket: + LOGD("Checking if the notifications server socket exists..."); + error_s = stat ("/tmp/.notification.service", &buf); + if (error_s == -1) { + LOGD("Could not find the notifications server socket"); + sleep (5); + goto retry_socket; + } + +retry_service: + LOGD("Checking if the notifications server is available..."); + error_n = notification_resister_changed_cb (display_notifications_cb, NULL); + if (error_n != NOTIFICATION_ERROR_NONE) { + LOGD("Could not register with notifications server"); + sleep (5); + goto retry_service; + } + + mainloop = g_main_loop_new (NULL, FALSE); + if (!mainloop) { + printf ("Failed to create the GLib main loop\n"); + return -1; + } + + g_main_loop_run (mainloop); + + return 0; +} diff --git a/notifications-display.service.in b/notifications-display.service.in new file mode 100644 index 0000000..11481e5 --- /dev/null +++ b/notifications-display.service.in @@ -0,0 +1,11 @@ +[Unit] +Description=Notifications Popup daemon +Requires=notifications.service display-manager-run.service +After=notifications.service display-manager-run.service + +[Service] +ExecStart=/usr/bin/notification-display-service +EnvironmentFile=/etc/sysconfig/weston + +[Install] +WantedBy=graphical.target diff --git a/packaging/notification-service.spec b/packaging/notification-service.spec index 8772d1e..cc557c6 100644 --- a/packaging/notification-service.spec +++ b/packaging/notification-service.spec @@ -41,6 +41,7 @@ make %{?_smp_mflags} %install %make_install %install_service graphical.target.wants notifications.service +%install_service graphical.target.wants notifications-display.service %post %systemd_post notifications.service @@ -54,8 +55,11 @@ make %{?_smp_mflags} %files %defattr(-,root,root,-) %{_bindir}/notification-service +%{_bindir}/notification-display-service %{_unitdir}/notifications.service +%{_unitdir}/notifications-display.service %{_unitdir}/graphical.target.wants/notifications.service +%{_unitdir}/graphical.target.wants/notifications-display.service %files test %defattr(-,root,root,-) -- 2.7.4 From 0a2700ea5288a37c1eaf90fd97116037db4d634b Mon Sep 17 00:00:00 2001 From: Manuel Bachmann Date: Wed, 10 Sep 2014 16:48:55 +0200 Subject: [PATCH 09/16] Introduce the display plugin system At startup, "notification-display-service" will now search for plugins in the "/usr/lib$ARCH/notification-service /plugins" directory. If one is found, it will use it to display notifications on screens. Otherwise, it will fall back to pure text with dlog. There is currently one plugin : wlmessage.so. Change-Id: I663fc24ec2c9fd8c1f0a2f07be08f479f2a4569d Signed-off-by: Manuel Bachmann --- Makefile.am | 7 ++- configure.ac | 7 ++- notification_display_service.c | 112 +++++++++++++++++++++++++----------- packaging/notification-service.spec | 1 + plugins/Makefile.am | 14 +++++ plugins/wlmessage.c | 30 ++++++++++ 6 files changed, 134 insertions(+), 37 deletions(-) create mode 100644 plugins/Makefile.am create mode 100644 plugins/wlmessage.c diff --git a/Makefile.am b/Makefile.am index 3ff5d19..532cab3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,10 @@ +SUBDIRS = plugins +moduledir = $(libdir)/notification-service/plugins + bin_PROGRAMS = notification-service notification-display-service sample-display-client send-notification bluetooth_notification_client AM_CFLAGS = $(GCC_CFLAGS) -AM_CPPFLAGS = $(GCC_CFLAGS) +AM_CPPFLAGS = $(GCC_CFLAGS) -DPLUGINSDIR='"$(moduledir)"' notification_service_SOURCES = \ main.c \ @@ -12,7 +15,7 @@ notification_service_LDADD = $(TIZEN_LIBS) notification_display_service_SOURCES = notification_display_service.c notification_display_service_CFLAGS = -I. $(TIZEN_CFLAGS) -notification_display_service_LDADD = $(TIZEN_LIBS) +notification_display_service_LDADD = $(TIZEN_LIBS) $(DLOPEN_LIBS) send_notification_SOURCES = send_notification.c send_notification_CFLAGS = -I. $(TIZEN_CFLAGS) diff --git a/configure.ac b/configure.ac index edb8edb..2987c6b 100644 --- a/configure.ac +++ b/configure.ac @@ -10,10 +10,15 @@ LT_PREREQ([2.2]) LT_INIT([disable-static]) PKG_PROG_PKG_CONFIG() + +AC_CHECK_FUNC([dlopen], [], + AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl")) +AC_SUBST(DLOPEN_LIBS) + PKG_CHECK_MODULES([TIZEN], [eina ecore com-core notification dbus-1 bluetooth-api dlog libwlmessage]) AC_SUBST(TIZEN_CFLAGS) AC_SUBST(TIZEN_LIBS) -AC_CONFIG_FILES([Makefile notifications.service notifications-display.service]) +AC_CONFIG_FILES([Makefile plugins/Makefile notifications.service notifications-display.service]) AC_PROG_RANLIB([ranlib]) AC_OUTPUT diff --git a/notification_display_service.c b/notification_display_service.c index df35e42..30211ac 100644 --- a/notification_display_service.c +++ b/notification_display_service.c @@ -1,66 +1,110 @@ #include -#include +#include #include +#include #include +#include #include -#include -void display_notifications_cb (void *data, notification_type_e notif_type) +void load_plugins (char *path, int (**fct)(notification_h)) { - notification_h noti = NULL; - notification_list_h notification_list = NULL; - notification_list_h get_list = NULL; + DIR *dir; + struct dirent *plugins_dir; + char *plugin_path; + void *plugin; + int (*plugin_fct)(notification_h); + + dir = opendir (path); + if (!dir) + return; + + while ((plugins_dir = readdir(dir)) != NULL) { + if (g_str_has_suffix (plugins_dir->d_name, ".so")) { + plugin_path = g_strconcat (path, G_DIR_SEPARATOR_S, plugins_dir->d_name, NULL); + plugin = dlopen (plugin_path, RTLD_NOW | RTLD_LOCAL); + plugin_fct = dlsym (plugin, "display_notification"); + g_free (plugin_path); + if (!plugin) { + LOGD("\"%s\" is not a plugin, continuing", plugins_dir->d_name); + continue; + } else if (!plugin_fct) { + LOGD("Plugin \"%s\" incompatible, continuing", plugins_dir->d_name); + dlclose (plugins_dir->d_name); + continue; + } else { + /* use the first working plugin, if not configured otherwise */ + LOGD("Plugin \"%s\" compatible, loading...", plugins_dir->d_name); + *fct = plugin_fct; + break; + } + } + } + + closedir (dir); +} +int display_notification_text (notification_h noti) +{ char *pkgname = NULL; char *title = NULL; char *content = NULL; char *image_path = NULL; + notification_get_pkgname (noti, &pkgname); + if (pkgname == NULL) + notification_get_application (noti, &pkgname); + notification_get_title (noti, &title, NULL); + notification_get_text (noti, NOTIFICATION_TEXT_TYPE_CONTENT, &content); + notification_get_image (noti, NOTIFICATION_IMAGE_TYPE_ICON, &image_path); + + LOGD("\nNew Notification : %s", title); + LOGD("Icon : %s", image_path); + LOGD("Message : %s", content); + + return 1; +} + +void display_notifications_cb (void *data, notification_type_e notif_type) +{ + int (*fct)(notification_h) = data; + notification_h noti = NULL; + notification_list_h notification_list = NULL; + notification_list_h get_list = NULL; + notification_get_list (NOTIFICATION_TYPE_NOTI, -1, ¬ification_list); if (notification_list) { get_list = notification_list_get_head (notification_list); while (get_list) { noti = notification_list_get_data (get_list); - notification_get_pkgname (noti, &pkgname); - if (pkgname == NULL) - notification_get_application (noti, &pkgname); - notification_get_title (noti, &title, NULL); - notification_get_text (noti, NOTIFICATION_TEXT_TYPE_CONTENT, &content); - notification_get_image (noti, NOTIFICATION_IMAGE_TYPE_ICON, &image_path); - - 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"); - if (wlmessage_show (wlmessage, NULL) < 0) { - wlmessage_destroy (wlmessage); - return; - } - wlmessage_destroy (wlmessage); - - LOGD("\nNew Notification : %s\n", title); - LOGD("Icon : %s\n", image_path); - LOGD("Message : %s\n", content); - get_list = notification_list_remove(get_list, noti); - notification_delete(noti); + /* if the display function was successful, delete the notification */ + if ( (*fct)(noti) ) { + get_list = notification_list_remove(get_list, noti); + notification_delete(noti); + } } } } + int main (int argc, char **argv) { GMainLoop *mainloop = NULL; + gboolean error_s; notification_error_e error_n; - int error_s; - struct stat buf; + int (*disp_fct)(notification_h); + + /* fall back to pure text notification if no plugin works */ + disp_fct = &display_notification_text; + LOGD("Checking for display plugins..."); + if (g_file_test (PLUGINSDIR, G_FILE_TEST_IS_DIR)) + load_plugins (PLUGINSDIR, &disp_fct); retry_socket: LOGD("Checking if the notifications server socket exists..."); - error_s = stat ("/tmp/.notification.service", &buf); - if (error_s == -1) { + error_s = g_file_test ("/tmp/.notification.service", G_FILE_TEST_EXISTS); + if (!error_s) { LOGD("Could not find the notifications server socket"); sleep (5); goto retry_socket; @@ -68,7 +112,7 @@ retry_socket: retry_service: LOGD("Checking if the notifications server is available..."); - error_n = notification_resister_changed_cb (display_notifications_cb, NULL); + error_n = notification_resister_changed_cb (display_notifications_cb, (*disp_fct)); if (error_n != NOTIFICATION_ERROR_NONE) { LOGD("Could not register with notifications server"); sleep (5); diff --git a/packaging/notification-service.spec b/packaging/notification-service.spec index cc557c6..68dd000 100644 --- a/packaging/notification-service.spec +++ b/packaging/notification-service.spec @@ -56,6 +56,7 @@ make %{?_smp_mflags} %defattr(-,root,root,-) %{_bindir}/notification-service %{_bindir}/notification-display-service +%{_libdir}/notification-service/plugins/wlmessage.so %{_unitdir}/notifications.service %{_unitdir}/notifications-display.service %{_unitdir}/graphical.target.wants/notifications.service diff --git a/plugins/Makefile.am b/plugins/Makefile.am new file mode 100644 index 0000000..0d2c4b7 --- /dev/null +++ b/plugins/Makefile.am @@ -0,0 +1,14 @@ +bin_PROGRAMS = +moduledir = $(libdir)/notification-service/plugins + +AM_CFLAGS = $(GCC_CFLAGS) +AM_CPPFLAGS = $(GCC_CFLAGS) + +module_LTLIBRARIES = wlmessage.la + +wlmessage_la_SOURCES = wlmessage.c + +wlmessage_la_LDFLAGS = -module -avoid-version +wlmessage_la_CPPFLAGS = $(AM_CPPFLAGS) +wlmessage_la_CFLAGS = $(TIZEN_CFLAGS) +wlmessage_la_LIBADD = $(TIZEN_LIBS) diff --git a/plugins/wlmessage.c b/plugins/wlmessage.c new file mode 100644 index 0000000..6f691af --- /dev/null +++ b/plugins/wlmessage.c @@ -0,0 +1,30 @@ +#include +#include + + +int display_notification (notification_h noti) +{ + char *pkgname = NULL; + char *title = NULL; + char *content = NULL; + char *image_path = NULL; + + notification_get_pkgname (noti, &pkgname); + if (pkgname == NULL) + notification_get_application (noti, &pkgname); + notification_get_title (noti, &title, NULL); + notification_get_text (noti, NOTIFICATION_TEXT_TYPE_CONTENT, &content); + notification_get_image (noti, NOTIFICATION_IMAGE_TYPE_ICON, &image_path); + + 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"); + if (wlmessage_show (wlmessage, NULL) < 0) { + wlmessage_destroy (wlmessage); + return 0; + } + + return 1; +} -- 2.7.4 From 016f2f96cea05033d91759b9bb67fcf08095e317 Mon Sep 17 00:00:00 2001 From: Manuel Bachmann Date: Wed, 17 Sep 2014 14:55:28 +0200 Subject: [PATCH 10/16] Add an IVI-specific systemd service IVI does not have a systemd setup similar to Common, most notably the Weston part. This makes starting "notifications-display.service" on IVI fail. Fix that. This can safely be reverted in the future. Change-Id: I48f169082a0e12e4b778710a2a34d8a4efcbe87f Signed-off-by: Manuel Bachmann --- Makefile.am | 5 +++-- configure.ac | 7 ++++++- notifications-display-ivi.service.in | 11 +++++++++++ packaging/notification-service.spec | 9 ++++++++- 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 notifications-display-ivi.service.in diff --git a/Makefile.am b/Makefile.am index 532cab3..f7ff9f5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -31,9 +31,10 @@ bluetooth_notification_client_LDADD = $(TIZEN_LIBS) SCRIPT_IN_FILES = \ notifications.service.in \ - notifications-display.service.in + notifications-display.service.in \ + notifications-display-ivi.service.in install-data-hook: $(mkinstalldirs) $(DESTDIR)/usr/lib/systemd/system/ install -m 0644 notifications.service $(DESTDIR)/usr/lib/systemd/system/notifications.service - install -m 0644 notifications-display.service $(DESTDIR)/usr/lib/systemd/system/notifications-display.service + install -m 0644 $(notif_display_service) $(DESTDIR)/usr/lib/systemd/system/notifications-display.service diff --git a/configure.ac b/configure.ac index 2987c6b..d9db945 100644 --- a/configure.ac +++ b/configure.ac @@ -15,10 +15,15 @@ AC_CHECK_FUNC([dlopen], [], AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl")) AC_SUBST(DLOPEN_LIBS) +AC_ARG_WITH(notif-display-service, AS_HELP_STRING([--with-notif-display-service=],[]),, + with_notif_display_service="notifications-display.service") +notif_display_service=$with_notif_display_service +AC_SUBST(notif_display_service) + PKG_CHECK_MODULES([TIZEN], [eina ecore com-core notification dbus-1 bluetooth-api dlog libwlmessage]) AC_SUBST(TIZEN_CFLAGS) AC_SUBST(TIZEN_LIBS) -AC_CONFIG_FILES([Makefile plugins/Makefile notifications.service notifications-display.service]) +AC_CONFIG_FILES([Makefile plugins/Makefile notifications.service notifications-display.service notifications-display-ivi.service]) AC_PROG_RANLIB([ranlib]) AC_OUTPUT diff --git a/notifications-display-ivi.service.in b/notifications-display-ivi.service.in new file mode 100644 index 0000000..6e89495 --- /dev/null +++ b/notifications-display-ivi.service.in @@ -0,0 +1,11 @@ +[Unit] +Description=Notifications Popup daemon +Requires=notifications.service +After=notifications.service + +[Service] +ExecStart=/usr/bin/notification-display-service +Environment=XDG_RUNTIME_DIR=/run/user/5000 + +[Install] +WantedBy=graphical.target diff --git a/packaging/notification-service.spec b/packaging/notification-service.spec index 68dd000..5b552ed 100644 --- a/packaging/notification-service.spec +++ b/packaging/notification-service.spec @@ -35,9 +35,16 @@ This package provides unit test used in the development of the notification serv %setup -q -n %{name}-%{version} %build -%autogen +%if "%{profile}" == "ivi" +notifications_display_service="notifications-display-ivi.service" +%else +notifications_display_service="notifications-display.service" +%endif + +%autogen --with-notif-display-service=$notifications_display_service make %{?_smp_mflags} + %install %make_install %install_service graphical.target.wants notifications.service -- 2.7.4 From 10079e3b7407efc02e7a151eb05c714f4bf3078f Mon Sep 17 00:00:00 2001 From: Corentin Lecouvey Date: Fri, 19 Sep 2014 18:22:04 +0200 Subject: [PATCH 11/16] handle bluetooth notifications in wlmessage plugin This is a minimal implementation that treats pairing confirmation and authorize push requests. Change-Id: I97d95c0a961d98fdcec1ab8840a335d611181e26 Signed-off-by: Corentin Lecouvey --- plugins/wlmessage.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 145 insertions(+), 9 deletions(-) diff --git a/plugins/wlmessage.c b/plugins/wlmessage.c index 6f691af..1973bf7 100644 --- a/plugins/wlmessage.c +++ b/plugins/wlmessage.c @@ -1,6 +1,54 @@ +#include +#include +#include +#include +#include #include #include +typedef enum { + BT_AGENT_ACCEPT, + BT_AGENT_REJECT, + BT_AGENT_CANCEL, + BT_CORE_AGENT_TIMEOUT, +} bt_agent_accept_type_t; + + +static DBusGProxy* create_agent_proxy(const char *path) +{ + DBusGConnection *sys_conn; + + sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); + if (sys_conn == NULL) { + LOGD("ERROR: Can't get on system bus"); + return NULL; + } + + return dbus_g_proxy_new_for_name(sys_conn, "org.projectx.bt", path, + "org.bluez.Agent1"); +} + +static DBusGProxy* create_obex_proxy(void) +{ + DBusGConnection *sys_conn; + + sys_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, NULL); + if (sys_conn == NULL) { + LOGD("ERROR: Can't get on system bus"); + return NULL; + } + + return dbus_g_proxy_new_for_name(sys_conn, "org.bluez.frwk_agent", + "/org/obex/ops_agent", "org.openobex.Agent"); +} + +static void send_user_reply (DBusGProxy *agent_proxy, + const char *reply_method, + bt_agent_accept_type_t user_reply) +{ + dbus_g_proxy_call_no_reply( agent_proxy, reply_method, G_TYPE_UINT, + user_reply, G_TYPE_INVALID, G_TYPE_INVALID); +} int display_notification (notification_h noti) { @@ -16,15 +64,103 @@ int display_notification (notification_h noti) notification_get_text (noti, NOTIFICATION_TEXT_TYPE_CONTENT, &content); notification_get_image (noti, NOTIFICATION_IMAGE_TYPE_ICON, &image_path); - 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"); - if (wlmessage_show (wlmessage, NULL) < 0) { + LOGD("NOTIFICATION RECEIVED: %s - %s - %s", pkgname, title, content); + + if (!strcasecmp(pkgname, "bluetooth-frwk-bt-service")) { + bundle *user_data = NULL; + DBusGProxy *proxy; + char *reply_method; + int button = 0; + + const char *device_name = NULL; + const char *passkey = NULL; + const char *file = NULL; + const char *agent_path; + const char *event_type = NULL; + + notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,NULL, &user_data); + + event_type = bundle_get_val(user_data, "event-type"); + if (!event_type) { + LOGD("Not a bluetooth-related notification..."); + } else { + LOGD("bluetooth notification type: [%s]", event_type); + } + + if (!strcasecmp(event_type, "passkey-confirm-request")) { + device_name = (gchar*) bundle_get_val(user_data, "device-name"); + passkey = (gchar*) bundle_get_val(user_data, "passkey"); + agent_path = bundle_get_val(user_data, "agent-path"); + proxy = create_agent_proxy(agent_path); + reply_method = "ReplyConfirmation"; + + } else if(!strcasecmp(event_type, "pin-request")) { + LOGD("Not implemented"); + } else if(!strcasecmp(event_type, "passkey-request")) { + LOGD("Not implemented"); + } else if(!strcasecmp(event_type, "passkey-display-request")) { + LOGD("Not implemented"); + + } else if (!strcasecmp(event_type, "authorize-request")) { + device_name = (gchar*) bundle_get_val(user_data, "device-name"); + agent_path = bundle_get_val(user_data, "agent-path"); + proxy = create_agent_proxy(agent_path); + reply_method = "ReplyAuthorize"; + + } else if(!strcasecmp(event_type, "app-confirm-request")) { + LOGD("Not implemented"); + + } else if(!strcasecmp(event_type, "push-authorize-request")) { + file = (gchar*) bundle_get_val(user_data, "file"); + device_name = (gchar*) bundle_get_val(user_data, "device-name"); + proxy = create_obex_proxy(); + reply_method = "ReplyAuthorize"; + + } else if(!strcasecmp(event_type, "confirm-overwrite-request")) { + LOGD("Not implemented"); + } else if(!strcasecmp(event_type, "keyboard-passkey-request")) { + LOGD("Not implemented"); + } else if(!strcasecmp(event_type, "bt-information")) { + LOGD("Not implemented"); + } else if(!strcasecmp(event_type, "exchange-request")) { + LOGD("Not implemented"); + } else if(!strcasecmp(event_type, "phonebook-request")) { + LOGD("Not implemented"); + } else if(!strcasecmp(event_type, "message-request")) { + LOGD("Not implemented"); + } + + 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, 1, "Yes"); + wlmessage_add_button (wlmessage, 0, "No"); + + button = wlmessage_show (wlmessage, NULL); + if (button < 0) { + wlmessage_destroy (wlmessage); + return 0; + } else if (button == 1) { + LOGD("user clicked on 'Yes' popup button"); + send_user_reply(proxy, reply_method, BT_AGENT_ACCEPT); + } else if (button == 0) { + LOGD("user clicked on 'No' popup button"); + send_user_reply(proxy, reply_method, BT_AGENT_CANCEL); + } wlmessage_destroy (wlmessage); - return 0; - } + return 1; + } else { + 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"); + if (wlmessage_show (wlmessage, NULL) < 0) { + wlmessage_destroy (wlmessage); + return 0; + } - return 1; + return 1; + } } -- 2.7.4 From 2320a43f92412ed1eaeb905a5a81cdb4f8b6d2a5 Mon Sep 17 00:00:00 2001 From: Corentin Lecouvey Date: Tue, 21 Oct 2014 18:34:06 +0200 Subject: [PATCH 12/16] remove pending notifications from DB when starting notifications-display service If some notifications are present in notification.db when starting notifications-display service, we remove them. Otherwise, wrong popups appears when starting the service. Change-Id: Id8813a9dc420ef7b84ddcb4817484b61362a18fa Signed-off-by: Corentin Lecouvey --- notification_display_service.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/notification_display_service.c b/notification_display_service.c index 30211ac..e0d2fd8 100644 --- a/notification_display_service.c +++ b/notification_display_service.c @@ -87,6 +87,23 @@ void display_notifications_cb (void *data, notification_type_e notif_type) } } +void del_pending_notifications(void) +{ + notification_h noti = NULL; + notification_list_h notification_list = NULL; + notification_list_h get_list = NULL; + + notification_get_list (NOTIFICATION_TYPE_NOTI, -1, ¬ification_list); + if (notification_list) { + get_list = notification_list_get_head (notification_list); + while (get_list) { + noti = notification_list_get_data(get_list); + notification_delete(noti); + LOGD("remove pending notification: %p from DB", noti); + get_list = notification_list_remove(get_list, noti); + } + } +} int main (int argc, char **argv) { @@ -110,6 +127,9 @@ retry_socket: goto retry_socket; } + /* remove all notifications stored in DB before handling new notifications */ + del_pending_notifications(); + retry_service: LOGD("Checking if the notifications server is available..."); error_n = notification_resister_changed_cb (display_notifications_cb, (*disp_fct)); -- 2.7.4 From 90239d46fa457e65d969c9fd6a2ab15160c3cefb Mon Sep 17 00:00:00 2001 From: Manuel Bachmann Date: Mon, 10 Nov 2014 14:51:02 +0100 Subject: [PATCH 13/16] Use the new wait/send API for interactive notifications 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 --- plugins/wlmessage.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/plugins/wlmessage.c b/plugins/wlmessage.c index 1973bf7..6113580 100644 --- a/plugins/wlmessage.c +++ b/plugins/wlmessage.c @@ -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; } } -- 2.7.4 From ff8c657bb42262fcda8fa96dfe2d4bb922199ba7 Mon Sep 17 00:00:00 2001 From: Mikko Ylinen Date: Mon, 24 Nov 2014 14:04:37 +0200 Subject: [PATCH 14/16] Move display service .service install outside autotools IVI profile needs the notification-display.service inside systemd --user session. To simplify the .service file install for both Common and IVI, move it outside autotools and do it in the .spec file instead. Change-Id: I7d31a5cfb2574b2123dbdf53c32d324049362028 Signed-off-by: Mikko Ylinen --- Makefile.am | 1 - configure.ac | 5 ----- packaging/notification-service.spec | 22 +++++++++++++++------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Makefile.am b/Makefile.am index f7ff9f5..4f1528a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,4 +37,3 @@ SCRIPT_IN_FILES = \ install-data-hook: $(mkinstalldirs) $(DESTDIR)/usr/lib/systemd/system/ install -m 0644 notifications.service $(DESTDIR)/usr/lib/systemd/system/notifications.service - install -m 0644 $(notif_display_service) $(DESTDIR)/usr/lib/systemd/system/notifications-display.service diff --git a/configure.ac b/configure.ac index d9db945..d09481d 100644 --- a/configure.ac +++ b/configure.ac @@ -15,11 +15,6 @@ AC_CHECK_FUNC([dlopen], [], AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl")) AC_SUBST(DLOPEN_LIBS) -AC_ARG_WITH(notif-display-service, AS_HELP_STRING([--with-notif-display-service=],[]),, - with_notif_display_service="notifications-display.service") -notif_display_service=$with_notif_display_service -AC_SUBST(notif_display_service) - PKG_CHECK_MODULES([TIZEN], [eina ecore com-core notification dbus-1 bluetooth-api dlog libwlmessage]) AC_SUBST(TIZEN_CFLAGS) AC_SUBST(TIZEN_LIBS) diff --git a/packaging/notification-service.spec b/packaging/notification-service.spec index 5b552ed..342168b 100644 --- a/packaging/notification-service.spec +++ b/packaging/notification-service.spec @@ -35,20 +35,23 @@ This package provides unit test used in the development of the notification serv %setup -q -n %{name}-%{version} %build -%if "%{profile}" == "ivi" -notifications_display_service="notifications-display-ivi.service" -%else -notifications_display_service="notifications-display.service" -%endif -%autogen --with-notif-display-service=$notifications_display_service +%autogen make %{?_smp_mflags} %install %make_install %install_service graphical.target.wants notifications.service + +%if "%{profile}" == "ivi" +mkdir -p %{buildroot}/%{_unitdir_user}/default.target.wants +install -m 0644 notifications-display-ivi.service %{buildroot}/%_unitdir_user/notifications-display.service +ln -s ../notifications-display.service %{buildroot}/%{_unitdir_user}/default.target.wants/notifications-display.service +%else +install -m 0644 notifications-display.service %{buildroot}/%_unitdir/ %install_service graphical.target.wants notifications-display.service +%endif %post %systemd_post notifications.service @@ -65,9 +68,14 @@ make %{?_smp_mflags} %{_bindir}/notification-display-service %{_libdir}/notification-service/plugins/wlmessage.so %{_unitdir}/notifications.service -%{_unitdir}/notifications-display.service %{_unitdir}/graphical.target.wants/notifications.service +%if "%{profile}" == "ivi" +%{_unitdir_user}/notifications-display.service +%{_unitdir_user}/default.target.wants/notifications-display.service +%else +%{_unitdir}/notifications-display.service %{_unitdir}/graphical.target.wants/notifications-display.service +%endif %files test %defattr(-,root,root,-) -- 2.7.4 From 413ea279c218da0943246eea738e38a46c83be8f Mon Sep 17 00:00:00 2001 From: Mikko Ylinen Date: Mon, 24 Nov 2014 14:07:48 +0200 Subject: [PATCH 15/16] Clean up notifications-display-ivi.service Change-Id: I50cd86c97c9cec24bec72c93cb356cc5a71bb356 Signed-off-by: Mikko Ylinen --- notifications-display-ivi.service.in | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/notifications-display-ivi.service.in b/notifications-display-ivi.service.in index 6e89495..5844dd3 100644 --- a/notifications-display-ivi.service.in +++ b/notifications-display-ivi.service.in @@ -1,11 +1,8 @@ [Unit] Description=Notifications Popup daemon -Requires=notifications.service -After=notifications.service [Service] ExecStart=/usr/bin/notification-display-service -Environment=XDG_RUNTIME_DIR=/run/user/5000 [Install] -WantedBy=graphical.target +WantedBy=default.target -- 2.7.4 From 363328db78e3d88ed6e03a332f3c934f85fc2549 Mon Sep 17 00:00:00 2001 From: hyun lee Date: Tue, 2 Dec 2014 11:14:05 +0900 Subject: [PATCH 16/16] Apply apache license Change-Id: I2387ec272d92ab3c98da234666067b260ec439fd Signed-off-by: hyun lee --- LICENSE | 202 ++++++++++++++++++++++++++++++++++++ notification_service.c | 9 +- notification_service.h | 9 +- packaging/notification-service.spec | 2 +- service_common.c | 9 +- service_common.h | 9 +- 6 files changed, 223 insertions(+), 17 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/notification_service.c b/notification_service.c index 569de48..5e5b0c3 100644 --- a/notification_service.c +++ b/notification_service.c @@ -1,18 +1,19 @@ /* - * Copyright 2013 Samsung Electronics Co., Ltd + * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * - * Licensed under the Flora License, Version 1.1 (the "License"); + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://floralicense.org/license/ + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + * +*/ #include #include #include diff --git a/notification_service.h b/notification_service.h index e02dfa3..eb05cd5 100644 --- a/notification_service.h +++ b/notification_service.h @@ -1,18 +1,19 @@ /* - * Copyright 2013 Samsung Electronics Co., Ltd + * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * - * Licensed under the Flora License, Version 1.1 (the "License"); + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://floralicense.org/license/ + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + * +*/ extern int notification_service_init(void); extern int notification_service_fini(void); diff --git a/packaging/notification-service.spec b/packaging/notification-service.spec index 342168b..18434bb 100644 --- a/packaging/notification-service.spec +++ b/packaging/notification-service.spec @@ -5,7 +5,7 @@ Summary: Simple notification service Version: 0.0.3 Release: 1 Group: Application Framework/Notifications -License: Flora +License: Apache Source0: %{name}-%{version}.tar.bz2 BuildRequires: pkgconfig(eina) BuildRequires: pkgconfig(ecore) diff --git a/service_common.c b/service_common.c index b53d1ff..fdf48c1 100644 --- a/service_common.c +++ b/service_common.c @@ -1,18 +1,19 @@ /* - * Copyright 2013 Samsung Electronics Co., Ltd + * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * - * Licensed under the Flora License, Version 1.1 (the "License"); + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://floralicense.org/license/ + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + * +*/ #define _GNU_SOURCE #include #include diff --git a/service_common.h b/service_common.h index 3dc7d46..6136018 100644 --- a/service_common.h +++ b/service_common.h @@ -1,18 +1,19 @@ /* - * Copyright 2013 Samsung Electronics Co., Ltd + * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved. * - * Licensed under the Flora License, Version 1.1 (the "License"); + * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://floralicense.org/license/ + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + * +*/ enum tcb_type { TCB_CLIENT_TYPE_APP = 0x00, TCB_CLIENT_TYPE_SERVICE = 0x01, -- 2.7.4