Add unit test for sending and recieving notifications
[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     int i = 1;
15     char buf[512] = {0};
16
17     notification_get_list(NOTIFICATION_TYPE_NOTI, -1, &notification_list);
18     if (notification_list) {
19         get_list = notification_list_get_head(notification_list);
20         noti = notification_list_get_data(get_list);
21         while(get_list != NULL) {
22             notification_get_id(noti, &group_id, &priv_id);
23             notification_get_pkgname(noti, &pkgname);
24             if(pkgname == NULL){
25                 notification_get_application(noti, &pkgname);
26             }
27
28             notification_get_text(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &str_count);
29             if (!str_count) {
30                 count = 0;
31             } else {
32                 count = atoi(str_count);
33             }
34             notification_get_title(noti, &title, NULL);
35
36             fprintf(stdout, "NOTIFICATION: %s - %s - %i - %i\n", pkgname, title, count, num);
37
38             get_list = notification_list_get_next(get_list);
39             noti = notification_list_get_data(get_list);
40             num++;
41         }
42     }
43     if (notification_list != NULL) {
44         notification_free_list(notification_list);
45         notification_list = NULL;
46     }
47 }
48
49 int
50 main(int argc, char **argv)
51 {
52     if (!ecore_init()) {
53         fprintf(stderr, "ERROR: Cannot init Ecore!\n");
54         return -1;
55     }
56
57     notification_resister_changed_cb(__noti_changed_cb, NULL);
58     ecore_main_loop_begin();
59
60  shutdown:
61     ecore_shutdown();
62     return 0;
63 }
64