4 #include <notification.h>
6 #include <libwlmessage.h>
9 void display_notifications_cb (void *data, notification_type_e notif_type)
11 notification_h noti = NULL;
12 notification_list_h notification_list = NULL;
13 notification_list_h get_list = NULL;
18 char *image_path = NULL;
20 notification_get_list (NOTIFICATION_TYPE_NOTI, -1, ¬ification_list);
21 if (notification_list) {
22 get_list = notification_list_get_head (notification_list);
24 noti = notification_list_get_data (get_list);
25 notification_get_pkgname (noti, &pkgname);
27 notification_get_application (noti, &pkgname);
28 notification_get_title (noti, &title, NULL);
29 notification_get_text (noti, NOTIFICATION_TEXT_TYPE_CONTENT, &content);
30 notification_get_image (noti, NOTIFICATION_IMAGE_TYPE_ICON, &image_path);
32 struct wlmessage *wlmessage = wlmessage_create ();
33 wlmessage_set_title (wlmessage, title);
34 wlmessage_set_icon (wlmessage, image_path);
35 wlmessage_set_message (wlmessage, content);
36 wlmessage_add_button (wlmessage, 0, "Ok");
37 if (wlmessage_show (wlmessage, NULL) < 0) {
38 wlmessage_destroy (wlmessage);
41 wlmessage_destroy (wlmessage);
43 LOGD("\nNew Notification : %s\n", title);
44 LOGD("Icon : %s\n", image_path);
45 LOGD("Message : %s\n", content);
47 get_list = notification_list_remove(get_list, noti);
48 notification_delete(noti);
53 int main (int argc, char **argv)
55 GMainLoop *mainloop = NULL;
56 notification_error_e error_n;
61 LOGD("Checking if the notifications server socket exists...");
62 error_s = stat ("/tmp/.notification.service", &buf);
64 LOGD("Could not find the notifications server socket");
70 LOGD("Checking if the notifications server is available...");
71 error_n = notification_resister_changed_cb (display_notifications_cb, NULL);
72 if (error_n != NOTIFICATION_ERROR_NONE) {
73 LOGD("Could not register with notifications server");
78 mainloop = g_main_loop_new (NULL, FALSE);
80 printf ("Failed to create the GLib main loop\n");
84 g_main_loop_run (mainloop);