6 #include "notification.h"
10 errorToString(notification_error_e error)
12 const char *strerr = NULL;
15 case NOTIFICATION_ERROR_NONE:
16 strerr = "NOTIFICATION_ERROR_NONE";
18 case NOTIFICATION_ERROR_INVALID_DATA:
19 strerr = "NOTIFICATION_ERROR_INVALID_DATA";
21 case NOTIFICATION_ERROR_NO_MEMORY:
22 strerr = "NOTIFICATION_ERROR_NO_MEMORY";
24 case NOTIFICATION_ERROR_FROM_DB:
25 strerr = "NOTIFICATION_ERROR_FROM_DB";
27 case NOTIFICATION_ERROR_ALREADY_EXIST_ID:
28 strerr = "NOTIFICATION_ERROR_ALREADY_EXIST_ID";
30 case NOTIFICATION_ERROR_FROM_DBUS:
31 strerr = "NOTIFICATION_ERROR_FROM_DBUS";
33 case NOTIFICATION_ERROR_NOT_EXIST_ID:
34 strerr = "NOTIFICATION_ERROR_NOT_EXIST_ID";
36 case NOTIFICATION_ERROR_IO:
37 strerr = "NOTIFICATION_ERROR_IO";
39 case NOTIFICATION_ERROR_SERVICE_NOT_READY:
40 strerr = "NOTIFICATION_ERROR_SERVICE_NOT_READY";
42 case NOTIFICATION_ERROR_PERMISSION_DENIED:
43 strerr = "NOTIFICATION_ERROR_PERMISSION_DENIED";
54 insert_notification(notification_type_e type,
62 notification_h noti = notification_new(type,
66 cout << "notification_new() failed." << endl;
71 if (NULL == pkgname) {
75 notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
77 noti_err = notification_set_pkgname(noti, pkgname);
78 if (noti_err != NOTIFICATION_ERROR_NONE) {
79 printf("notification_set_pkgname failed(%s).\n",
80 errorToString(noti_err));
88 noti_err = notification_set_text(noti,
89 NOTIFICATION_TEXT_TYPE_TITLE,
92 NOTIFICATION_VARIABLE_TYPE_NONE);
93 if (noti_err != NOTIFICATION_ERROR_NONE) {
94 cout << "Failed to set notification title <error code>:"<< noti_err<<endl;
99 if (NULL == content) {
102 noti_err = notification_set_text(noti,
103 NOTIFICATION_TEXT_TYPE_CONTENT,
106 NOTIFICATION_VARIABLE_TYPE_NONE);
107 if (noti_err != NOTIFICATION_ERROR_NONE) {
108 cout << "Failed to set notification content <error code>:"<< noti_err<<endl;
116 noti_err = notification_set_icon(noti, icon);
117 if (noti_err != NOTIFICATION_ERROR_NONE) {
118 cout <<"Failed to set icon_path <error code>:"<< noti_err <<endl;
122 //insert to DB and appear on the notification_area
123 //noti_err = notification_update(noti);
125 noti_err = notification_insert(noti, &private_id);
126 if (noti_err != NOTIFICATION_ERROR_NONE) {
127 printf("notification_insert failed(%s).\n",
128 errorToString(noti_err));
132 //free to notification
133 noti_err = notification_free(noti);
134 if (noti_err != NOTIFICATION_ERROR_NONE) {
135 cout <<"Failed to free notification <error code>:"<< noti_err <<endl;
143 main(int argc, char **argv)
145 const char* msgTyp = "TYPE_NOTI";
146 notification_type_e nType = NOTIFICATION_TYPE_NOTI;
149 string sargv1(argv[1]);
150 if (0 == sargv1.compare("--ongoing")) {
151 msgTyp = "TYPE_ONGOING";
152 nType = NOTIFICATION_TYPE_ONGOING;
156 cout << "Notification TestProgram Start("<<msgTyp<<")=========" <<endl;
158 insert_notification(nType,
159 NOTIFICATION_GROUP_ID_DEFAULT,
160 NOTIFICATION_PRIV_ID_NONE,
163 "0123456789012345678901234",
164 "/usr/share/icons/default/small/org.tizen.dialer.png");
166 insert_notification(nType,
167 NOTIFICATION_GROUP_ID_NONE,
168 NOTIFICATION_PRIV_ID_NONE,
169 "GV3ySIINq7.GhostCluster",
172 "/opt/share/icons/default/small/GV3ySIINq7.GhostCluster.png");
174 insert_notification(nType,
175 NOTIFICATION_GROUP_ID_NONE,
176 NOTIFICATION_PRIV_ID_NONE,
177 "ODBQpKvkS1.Settings",
180 "/opt/share/icons/default/small/ODBQpKvkS1.Settings.png");
182 insert_notification(nType,
183 NOTIFICATION_GROUP_ID_NONE,
184 NOTIFICATION_PRIV_ID_NONE,
185 "lYjFlj49Q4.saythis",
188 "/opt/share/icons/default/small/lYjFlj49Q4.saythis.png");
190 insert_notification(nType,
191 NOTIFICATION_GROUP_ID_NONE,
192 NOTIFICATION_PRIV_ID_NONE,
193 "t8j6HTRpuz.MediaPlayer",
196 "/opt/share/icons/default/small/t8j6HTRpuz.MediaPlayer.png");
198 cout << "Notification_TestProgram End!=========" <<endl;