SUBDIRS = plugins
moduledir = $(libdir)/notification-service/plugins
-bin_PROGRAMS = notification-service notification-display-service sample-display-client send-notification bluetooth_notification_client
+bin_PROGRAMS = notification-service sample-display-client send-notification bluetooth_notification_client
AM_CFLAGS = $(GCC_CFLAGS)
AM_CPPFLAGS = $(GCC_CFLAGS) -DPLUGINSDIR='"$(moduledir)"'
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) $(DLOPEN_LIBS)
-
send_notification_SOURCES = send_notification.c
send_notification_CFLAGS = -I. $(TIZEN_CFLAGS)
send_notification_LDADD = $(TIZEN_LIBS)
bluetooth_notification_client_LDADD = $(TIZEN_LIBS)
SCRIPT_IN_FILES = \
- notifications.service.in \
- notifications-display-ivi.service.in \
- notifications-display-x11.service.in \
- notifications-display-wayland.service.in
+ notifications.service.in
install-data-hook:
$(mkinstalldirs) $(DESTDIR)/usr/lib/systemd/system/
+++ /dev/null
-#include <stdio.h>
-#include <unistd.h>
-#include <glib.h>
-#include <dirent.h>
-#include <notification.h>
-#include <dlfcn.h>
-#include <dlog.h>
-
-
-void load_plugins (char *path, int (**fct)(notification_h))
-{
- 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);
-
- /* if the display function was successful, delete the notification */
- if ( (*fct)(noti) ) {
- get_list = notification_list_remove(get_list, noti);
- notification_delete(noti);
- }
- }
- }
-}
-
-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)
-{
- GMainLoop *mainloop = NULL;
- gboolean error_s;
- notification_error_e error_n;
- 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 = 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;
- }
-
- /* 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));
- 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;
-}
%install
%make_install
-%install_service default.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
-%if %{with x}
-install -m 0644 notifications-display-x11.service %{buildroot}/%_unitdir/notifications-display.service
-%endif
-%if %{with wayland}
-install -m 0644 notifications-display-wayland.service %{buildroot}/%_unitdir/notifications-display.service
-%endif
-%install_service default.target.wants notifications-display.service
-%endif
+%install_service graphical.target.wants notifications.service
%post
%systemd_post notifications.service
%files
%defattr(-,root,root,-)
%{_bindir}/notification-service
-%{_bindir}/notification-display-service
%{_libdir}/notification-service/plugins/wlmessage.so
%{_unitdir}/notifications.service
-%{_unitdir}/default.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}/default.target.wants/notifications-display.service
-%endif
+%{_unitdir}/graphical.target.wants/notifications.service
%files test
%defattr(-,root,root,-)