Revert "Corresponding to TizenIVI3.0 M14.3, GENIVI-LayerManagement was used instead...
[profile/ivi/ico-uxf-homescreen.git] / tool / notification / dump_notification.cpp
1 #include <stdio.h>
2 #include <iostream>
3 #include "notification.h"
4 using namespace std;
5
6 int
7 main()
8 {
9     cout << "Notification TestProgram Start=========" << endl;
10     
11     //notification variable declaration
12     notification_error_e err = NOTIFICATION_ERROR_NONE;
13     notification_list_h noti_list = NULL;
14
15     err = notification_get_list(NOTIFICATION_TYPE_NONE, -1, &noti_list);
16     if (err != NOTIFICATION_ERROR_NONE) {
17         cout << "Failed to get notificationList <error code>:"<< err << endl;
18         return -1;
19     }
20
21     if (NULL == noti_list){ 
22         cout <<"Nothing NotificationList" <<endl;
23         return -1;  
24     }
25
26     printf("gid | typ | pid | %-30s | %-30s | content\n", "pkgname", "title");
27     printf("----+-----+-----+--------------------------------+--------------------------------+--------------------------------\n");
28     //notification_list_h getlist = notification_list_get_head(noti_list);
29     notification_list_h getlist = notification_list_get_tail(noti_list);
30     do {
31         notification_h noti = notification_list_get_data(getlist);
32
33
34         notification_type_e type = NOTIFICATION_TYPE_NONE;
35         err = notification_get_type(noti, &type);
36         if (NOTIFICATION_ERROR_NONE != err) {
37             printf("notification_set_text() failed(%d).\n", err);
38             return -1;
39         }
40
41         int grpid = 0;
42         int privid = 0;
43         err = notification_get_id(noti, &grpid, &privid);
44         if (NOTIFICATION_ERROR_NONE != err) {
45             printf("notification_set_text() failed(%d).\n", err);
46             return -1;
47         }
48
49         char *caller_pkgname = NULL;
50         err = notification_get_pkgname(noti, &caller_pkgname);
51         if (NOTIFICATION_ERROR_NONE != err) {
52             printf("notification_get_pkgname() failed(%d).\n", err);
53             return -1;
54         }
55
56         char *title = NULL;
57         err = notification_get_text(noti,
58                                     NOTIFICATION_TEXT_TYPE_TITLE,
59                                     &title);
60         if (NOTIFICATION_ERROR_NONE != err) {
61             printf("notification_set_text() failed(%d).\n", err);
62             return -1;
63         }
64
65         char *content = NULL;
66         err = notification_get_text(noti,
67                                     NOTIFICATION_TEXT_TYPE_CONTENT,
68                                     &content);
69         if (NOTIFICATION_ERROR_NONE != err) {
70             printf("notification_get_text() failed(%d).\n", err);
71             return -1;
72         }
73
74         printf("%3d | %3d | %3d | %-30s | %-30s | %-30s\n",
75                grpid, type, privid, caller_pkgname, title, content);
76
77         //getlist = notification_list_get_next(getlist);
78         getlist = notification_list_get_prev(getlist);
79     } while (getlist != NULL);
80
81
82     cout << "Notification_TestProgram End!=========" << endl;
83     return 0;
84 }