Initial implementation of a graphical notifications display deamon.
[platform/core/appfw/notification-service.git] / sample_display_client.c
1 #include <Ecore.h>
2 #include <notification.h>
3 #include <unistd.h>
4
5 static void __noti_changed_cb(void *data, notification_type_e type)
6 {
7     notification_h noti = NULL;
8     notification_list_h notification_list = NULL;
9     notification_list_h get_list = NULL;
10     int count = 0, group_id = 0, priv_id = 0, show_noti = 0, num = 1;
11     char *pkgname = NULL;
12     char *title = NULL;
13     char *str_count = NULL;
14     char *content = NULL;
15     int i = 1;
16     char buf[512] = {0};
17
18     notification_get_list(NOTIFICATION_TYPE_NOTI, -1, &notification_list);
19     if (notification_list) {
20         get_list = notification_list_get_head(notification_list);
21         noti = notification_list_get_data(get_list);
22         while(get_list != NULL) {
23             notification_get_id(noti, &group_id, &priv_id);
24             notification_get_pkgname(noti, &pkgname);
25             if(pkgname == NULL){
26                 notification_get_application(noti, &pkgname);
27             }
28
29             notification_get_text(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &str_count);
30             if (!str_count) {
31                 count = 0;
32             } else {
33                 count = atoi(str_count);
34             }
35             notification_get_title(noti, &title, NULL);
36             notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, &content);
37
38
39             fprintf(stdout, "NOTIFICATION: %s - %s - %s - %i - %i\n", pkgname, title, content, count, num);
40
41             get_list = notification_list_get_next(get_list);
42             noti = notification_list_get_data(get_list);
43             num++;
44         }
45     }
46     if (notification_list != NULL) {
47         notification_free_list(notification_list);
48         notification_list = NULL;
49     }
50 }
51
52 int
53 main(int argc, char **argv)
54 {
55     if (!ecore_init()) {
56         fprintf(stderr, "ERROR: Cannot init Ecore!\n");
57         return -1;
58     }
59
60     notification_resister_changed_cb(__noti_changed_cb, NULL);
61     ecore_main_loop_begin();
62
63  shutdown:
64     ecore_shutdown();
65     return 0;
66 }
67