Merge remote-tracking branch 'origin/tizen_3.0_dbus' into tizen
[platform/core/api/notification.git] / src / notification.c
1 /*
2  *  libnotification
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Seungtaek Chung <seungtaek.chung@samsung.com>, Mi-Ju Lee <miju52.lee@samsung.com>, Xi Zhichan <zhichan.xi@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <unistd.h>
26 #include <fcntl.h>
27 #include <libintl.h>
28 #include <dbus/dbus.h>
29 #include <dbus/dbus-glib-lowlevel.h>
30
31 #include <app.h>
32 #include <app_internal.h>
33 #include <app_manager.h>
34 #include <app_control_internal.h>
35 #include <package_manager.h>
36 #include <aul.h>
37 #include <ail.h>
38 #include <appsvc.h>
39 #include <tizen.h>
40 #include <vconf-keys.h>
41 #include <vconf.h>
42
43 #include <notification.h>
44 #include <notification_list.h>
45 #include <notification_debug.h>
46 #include <notification_private.h>
47 #include <notification_noti.h>
48 #include <notification_ongoing.h>
49 #include <notification_group.h>
50 #include <notification_ipc.h>
51 #include <notification_internal.h>
52
53 static void (*posted_toast_message_cb) (void *data);
54
55 #define NOTI_TEXT_RESULT_LEN 2048
56 #define NOTI_PKGNAME_LEN        512
57
58 char *notification_get_pkgname_by_pid(void)
59 {
60         char pkgname[NOTI_PKGNAME_LEN + 1] = { 0, };
61         int pid = 0, ret = AUL_R_OK;
62         int fd;
63         char  *dup_pkgname;
64         char buf[NOTI_PKGNAME_LEN + 1] = { 0, };
65
66         pid = getpid();
67
68         ret = aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname));
69         if (ret != AUL_R_OK) {
70
71                 snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
72
73                 fd = open(buf, O_RDONLY);
74                 if (fd < 0)
75                         return NULL;
76
77                 ret = read(fd, pkgname, sizeof(pkgname) - 1);
78                 close(fd);
79
80                 if (ret <= 0)
81                         return NULL;
82
83                 pkgname[ret] = '\0';
84                 /*!
85                  * \NOTE
86                  * "ret" is not able to be larger than "sizeof(pkgname) - 1",
87                  * if the system is not going wrong.
88                  */
89         } else {
90                 if (strlen(pkgname) <= 0)
91                         return NULL;
92         }
93
94         dup_pkgname = strdup(pkgname);
95         if (!dup_pkgname)
96                 NOTIFICATION_ERR("Heap: %d\n", errno);
97
98         return dup_pkgname;
99 }
100
101 EXPORT_API int notification_set_image(notification_h noti,
102                                                        notification_image_type_e type,
103                                                        const char *image_path)
104 {
105         bundle *b = NULL;
106         char buf_key[32] = { 0, };
107         char *ret_val = NULL;
108
109         /* Check noti and image_path are valid data */
110         if (noti == NULL || image_path == NULL)
111                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
112
113         /* Check image type is valid type */
114         if (type <= NOTIFICATION_IMAGE_TYPE_NONE
115             || type >= NOTIFICATION_IMAGE_TYPE_MAX)
116                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
117
118         /* Check image path bundle is exist */
119         if (noti->b_image_path) {
120                 /* If image path bundle is exist, store local bundle value */
121                 b = noti->b_image_path;
122
123                 /* Set image type to key as char string type */
124                 snprintf(buf_key, sizeof(buf_key), "%d", type);
125
126                 /* Get value using key */
127                 bundle_get_str(b, buf_key, &ret_val);
128                 if (ret_val != NULL)
129                         /* If key is exist, remove this value to store new image path */
130                         bundle_del(b, buf_key);
131
132                 /* Add new image path with type key */
133                 bundle_add_str(b, buf_key, image_path);
134         } else {
135                 /* If image path bundle is not exist, create new one */
136                 b = bundle_create();
137
138                 /* Set image type to key as char string type */
139                 snprintf(buf_key, sizeof(buf_key), "%d", type);
140
141                 /* Add new image path with type key */
142                 bundle_add_str(b, buf_key, image_path);
143
144                 /* Save to image path bundle */
145                 noti->b_image_path = b;
146         }
147
148         return NOTIFICATION_ERROR_NONE;
149 }
150
151 EXPORT_API int notification_get_image(notification_h noti,
152                                                        notification_image_type_e type,
153                                                        char **image_path)
154 {
155         bundle *b = NULL;
156         char buf_key[32] = { 0, };
157         char *ret_val = NULL;
158
159         /* Check noti and image_path is valid data */
160         if (noti == NULL || image_path == NULL)
161                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
162
163         /* Check image type is valid data */
164         if (type <= NOTIFICATION_IMAGE_TYPE_NONE
165             || type >= NOTIFICATION_IMAGE_TYPE_MAX)
166                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
167
168         /* Check image path bundle exist */
169         if (noti->b_image_path) {
170                 /* If image path bundle exist, store local bundle data */
171                 b = noti->b_image_path;
172
173                 /* Set image type to key as char string type */
174                 snprintf(buf_key, sizeof(buf_key), "%d", type);
175
176                 /* Get value of key */
177                 bundle_get_str(b, buf_key, &ret_val);
178
179                 *image_path = ret_val;
180         } else {
181                 /* If image path bundle does not exist, image path is NULL */
182                 *image_path = NULL;
183         }
184
185         /* If image path is NULL and type is ICON, icon path set from AIL */
186         /* order : user icon -> launch_pkgname icon -> caller_pkgname icon -> service app icon */
187         if (*image_path == NULL && type == NOTIFICATION_IMAGE_TYPE_ICON) {
188                 /* Check App icon path is already set */
189                 if (noti->app_icon_path != NULL)
190                         /* image path will be app icon path */
191                         *image_path = noti->app_icon_path;
192                 else
193                         *image_path = NULL;
194         }
195
196         return NOTIFICATION_ERROR_NONE;
197 }
198
199 EXPORT_API int notification_set_time(notification_h noti,
200                                                       time_t input_time)
201 {
202         /* Check noti is valid data */
203         if (noti == NULL)
204                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
205
206         if (input_time == 0)
207                 /* If input time is 0, set current time */
208                 noti->time = time(NULL);
209         else
210                 /* save input time */
211                 noti->time = input_time;
212
213         return NOTIFICATION_ERROR_NONE;
214 }
215
216 EXPORT_API int notification_get_time(notification_h noti,
217                                                       time_t * ret_time)
218 {
219         /* Check noti and time is valid data */
220         if (noti == NULL || ret_time == NULL)
221                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
222
223         /* Set time infomation */
224         *ret_time = noti->time;
225
226         return NOTIFICATION_ERROR_NONE;
227 }
228
229 EXPORT_API int notification_get_insert_time(notification_h noti,
230                                                              time_t * ret_time)
231 {
232         /* Check noti and ret_time is valid data */
233         if (noti == NULL || ret_time == NULL)
234                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
235
236         /* Set insert time information */
237         *ret_time = noti->insert_time;
238
239         return NOTIFICATION_ERROR_NONE;
240 }
241
242 EXPORT_API int notification_set_text(notification_h noti,
243                                                       notification_text_type_e type,
244                                                       const char *text,
245                                                       const char *key,
246                                                       int args_type, ...)
247 {
248         bundle *b = NULL;
249         char buf_key[32] = { 0, };
250         char buf_val[1024] = { 0, };
251         char *ret_val = NULL;
252         va_list var_args;
253         notification_variable_type_e var_type;
254         int num_args = 0;
255         int noti_err = NOTIFICATION_ERROR_NONE;
256         int var_value_int = 0;
257         double var_value_double = 0.0;
258         char *var_value_string = NULL;
259         notification_count_pos_type_e var_value_count =
260             NOTIFICATION_COUNT_POS_NONE;
261
262         /* Check noti is valid data */
263         if (noti == NULL)
264                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
265
266         /* Check text type is valid type */
267         if (type <= NOTIFICATION_TEXT_TYPE_NONE
268             || type >= NOTIFICATION_TEXT_TYPE_MAX)
269                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
270
271         /* Check text bundle exist */
272         if (text != NULL) {
273                 if (noti->b_text != NULL) {
274                         /* If text bundle exist, store local bundle data */
275                         b = noti->b_text;
276
277                         /* Make type to key as char string */
278                         snprintf(buf_key, sizeof(buf_key), "%d", type);
279
280                         /* Get value using type key */
281                         bundle_get_str(b, buf_key, &ret_val);
282
283                         if (ret_val != NULL)
284                                 /* If value exist, remove this to add new value */
285                                 bundle_del(b, buf_key);
286
287                         snprintf(buf_val, sizeof(buf_val), "%s", text);
288
289                         /* Add new text value */
290                         bundle_add_str(b, buf_key, buf_val);
291                 } else {
292                         /* If text bundle does not exist, create new one */
293                         b = bundle_create();
294
295                         /* Make type to key as char string */
296                         snprintf(buf_key, sizeof(buf_key), "%d", type);
297
298                         snprintf(buf_val, sizeof(buf_val), "%s", text);
299
300                         /* Add new text value */
301                         bundle_add_str(b, buf_key, buf_val);
302
303                         /* Save text bundle */
304                         noti->b_text = b;
305                 }
306         } else {
307                 /* Reset if text is NULL */
308                 if (noti->b_text != NULL) {
309                         /* If text bundle exist, store local bundle data */
310                         b = noti->b_text;
311
312                         /* Make type to key as char string */
313                         snprintf(buf_key, sizeof(buf_key), "%d", type);
314
315                         /* Get value using type key */
316                         bundle_get_str(b, buf_key, &ret_val);
317                         if (ret_val != NULL)
318                                 /* If value exist, remove this */
319                                 bundle_del(b, buf_key);
320                 }
321         }
322
323         /* Save key if key is valid data */
324         if (key != NULL) {
325                 /* Check key bundle exist */
326                 if (noti->b_key != NULL) {
327                         /* If key bundle exist,  store local bundle data */
328                         b = noti->b_key;
329
330                         /* Make type to key as char string */
331                         snprintf(buf_key, sizeof(buf_key), "%d", type);
332
333                         /* Get value using type key */
334                         bundle_get_str(b, buf_key, &ret_val);
335                         if (ret_val != NULL)
336                                 /* If value exist, remove this to add new value */
337                                 bundle_del(b, buf_key);
338
339                         snprintf(buf_val, sizeof(buf_val), "%s", key);
340
341                         /* Add new key value */
342                         bundle_add_str(b, buf_key, buf_val);
343                 } else {
344                         /* If key bundle does not exist, create new one */
345                         b = bundle_create();
346
347                         /* Make type to key as char string */
348                         snprintf(buf_key, sizeof(buf_key), "%d", type);
349
350                         snprintf(buf_val, sizeof(buf_val), "%s", key);
351
352                         /* Add new key value */
353                         bundle_add_str(b, buf_key, buf_val);
354
355                         /* Save key bundle */
356                         noti->b_key = b;
357                 }
358         } else {
359                 /* Reset if key is NULL */
360                 if (noti->b_key != NULL) {
361                         /* If key bundle exist,  store local bundle data */
362                         b = noti->b_key;
363
364                         /* Make type to key as char string */
365                         snprintf(buf_key, sizeof(buf_key), "%d", type);
366
367                         /* Get value using type key */
368                         bundle_get_str(b, buf_key, &ret_val);
369                         if (ret_val != NULL)
370                                 /* If value exist, remove this */
371                                 bundle_del(b, buf_key);
372                 }
373         }
374
375         if (noti->b_format_args != NULL)
376                 b = noti->b_format_args;
377         else
378                 b = bundle_create();
379
380         va_start(var_args, args_type);
381
382         var_type = args_type;
383         num_args = 0;
384
385         while (var_type != NOTIFICATION_VARIABLE_TYPE_NONE) {
386                 /* Type */
387                 snprintf(buf_key, sizeof(buf_key), "%dtype%d", type, num_args);
388                 snprintf(buf_val, sizeof(buf_val), "%d", var_type);
389
390                 bundle_get_str(b, buf_key, &ret_val);
391                 if (ret_val != NULL)
392                         bundle_del(b, buf_key);
393
394                 bundle_add_str(b, buf_key, buf_val);
395
396                 switch (var_type) {
397                 case NOTIFICATION_VARIABLE_TYPE_INT:
398                         var_value_int = va_arg(var_args, int);
399
400                         /* Value */
401                         snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
402                                  num_args);
403                         snprintf(buf_val, sizeof(buf_val), "%d", var_value_int);
404
405                         bundle_get_str(b, buf_key, &ret_val);
406                         if (ret_val != NULL)
407                                 bundle_del(b, buf_key);
408
409                         bundle_add_str(b, buf_key, buf_val);
410                         break;
411
412                 case NOTIFICATION_VARIABLE_TYPE_DOUBLE:
413                         var_value_double = va_arg(var_args, double);
414
415                         /* Value */
416                         snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
417                                  num_args);
418                         snprintf(buf_val, sizeof(buf_val), "%.2f",
419                                  var_value_double);
420
421                         bundle_get_str(b, buf_key, &ret_val);
422                         if (ret_val != NULL)
423                                 bundle_del(b, buf_key);
424
425                         bundle_add_str(b, buf_key, buf_val);
426                         break;
427
428                 case NOTIFICATION_VARIABLE_TYPE_STRING:
429                         var_value_string = va_arg(var_args, char *);
430
431                         /* Value */
432                         snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
433                                  num_args);
434                         snprintf(buf_val, sizeof(buf_val), "%s",
435                                  var_value_string);
436
437                         bundle_get_str(b, buf_key, &ret_val);
438                         if (ret_val != NULL)
439                                 bundle_del(b, buf_key);
440
441                         bundle_add_str(b, buf_key, buf_val);
442                         break;
443
444                 case NOTIFICATION_VARIABLE_TYPE_COUNT:
445                         var_value_count =
446                             va_arg(var_args, notification_count_pos_type_e);
447
448                         /* Value */
449                         snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
450                                  num_args);
451                         snprintf(buf_val, sizeof(buf_val), "%d",
452                                  var_value_count);
453
454                         bundle_get_str(b, buf_key, &ret_val);
455                         if (ret_val != NULL)
456                                 bundle_del(b, buf_key);
457
458                         bundle_add_str(b, buf_key, buf_val);
459                         break;
460
461                 default:
462                         NOTIFICATION_ERR("Error. invalid variable type. : %d",
463                                          var_type);
464                         noti_err = NOTIFICATION_ERROR_INVALID_PARAMETER;
465                         break;
466                 }
467
468                 num_args++;
469                 var_type = va_arg(var_args, notification_variable_type_e);
470         }
471         va_end(var_args);
472
473         if (noti_err == NOTIFICATION_ERROR_NONE)
474                 noti->num_format_args = num_args;
475         else
476                 noti->num_format_args = 0;
477
478         snprintf(buf_key, sizeof(buf_key), "num%d", type);
479         snprintf(buf_val, sizeof(buf_val), "%d", noti->num_format_args);
480
481         bundle_get_str(b, buf_key, &ret_val);
482         if (ret_val != NULL)
483                 bundle_del(b, buf_key);
484
485         bundle_add_str(b, buf_key, buf_val);
486
487         noti->b_format_args = b;
488
489         return noti_err;
490 }
491
492 EXPORT_API int notification_get_text(notification_h noti,
493                                                       notification_text_type_e type,
494                                                       char **text)
495 {
496         bundle *b = NULL;
497         char buf_key[32] = { 0, };
498         char *ret_val = NULL;
499         char *get_str = NULL;
500         notification_text_type_e check_type = NOTIFICATION_TEXT_TYPE_NONE;
501         /* int display_option_flag = 0; */
502
503         char *temp_str = NULL;
504         char *translated_str = NULL;
505         char result_str[NOTI_TEXT_RESULT_LEN] = { 0, };
506         char buf_str[1024] = { 0, };
507         int num_args = 0;
508         notification_variable_type_e ret_var_type = 0;
509         int ret_variable_int = 0;
510         double ret_variable_double = 0.0;
511         int src_len = 0;
512         int max_len = 0;
513
514         /* Check noti is valid data */
515         if (noti == NULL || text == NULL)
516                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
517
518         /* Check text type is valid type */
519         if (type <= NOTIFICATION_TEXT_TYPE_NONE
520             || type >= NOTIFICATION_TEXT_TYPE_MAX)
521                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
522
523
524         /* Check key */
525         if (noti->b_key != NULL) {
526                 b = noti->b_key;
527
528                 /* Get text domain and dir */
529                 /* _notification_get_text_domain(noti); */
530
531                 snprintf(buf_key, sizeof(buf_key), "%d", type);
532
533                 bundle_get_str(b, buf_key, &ret_val);
534                 if (ret_val != NULL && noti->domain != NULL
535                     && noti->dir != NULL) {
536                         /* Get application string */
537                         bindtextdomain(noti->domain, noti->dir);
538
539                         get_str = dgettext(noti->domain, ret_val);
540                 } else if (ret_val != NULL) {
541                         /* Get system string */
542                         get_str = dgettext("sys_string", ret_val);
543                 } else {
544                         get_str = NULL;
545                 }
546         }
547
548         if (get_str == NULL && noti->b_text != NULL) {
549                 b = noti->b_text;
550                 /* Get basic text */
551                 snprintf(buf_key, sizeof(buf_key), "%d", type);
552
553                 bundle_get_str(b, buf_key, &get_str);
554         }
555
556         check_type = type;
557
558         if (get_str != NULL) {
559                 /* Get number format args */
560                 b = noti->b_format_args;
561                 noti->num_format_args = 0;
562
563                 if (b != NULL) {
564                         snprintf(buf_key, sizeof(buf_key), "num%d", check_type);
565                         bundle_get_str(b, buf_key, &ret_val);
566                         if (ret_val != NULL)
567                                 noti->num_format_args = atoi(ret_val);
568                 }
569
570                 if (noti->num_format_args == 0) {
571                         *text = (char *)get_str;
572                 } else {
573                         /* Check first variable is count, LEFT pos */
574                         snprintf(buf_key, sizeof(buf_key), "%dtype%d",
575                                  check_type, num_args);
576                         bundle_get_str(b, buf_key, &ret_val);
577                         if (ret_val != NULL)
578                                 ret_var_type = atoi(ret_val);
579
580                         if (ret_var_type == NOTIFICATION_VARIABLE_TYPE_COUNT) {
581                                 /* Get var Value */
582                                 snprintf(buf_key, sizeof(buf_key), "%dvalue%d",
583                                          check_type, num_args);
584                                 bundle_get_str(b, buf_key, &ret_val);
585                                 if (ret_val != NULL)
586                                         ret_variable_int = atoi(ret_val);
587
588                                 if (ret_variable_int ==
589                                     NOTIFICATION_COUNT_POS_LEFT) {
590                                         notification_get_count(noti->type,
591                                                         noti->caller_pkgname,
592                                                         noti->group_id,
593                                                         noti->priv_id,
594                                                         &ret_variable_int);
595                                         snprintf(buf_str, sizeof(buf_str),
596                                                  "%d ", ret_variable_int);
597
598                                         src_len = strlen(result_str);
599                                         max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
600
601                                         strncat(result_str, buf_str,
602                                                         max_len);
603                                         num_args++;
604                                 }
605                         }
606
607                         /* Check variable IN pos */
608                         for (temp_str = (char *)get_str; *temp_str != '\0';
609                              temp_str++) {
610                                 if (*temp_str != '%') {
611                                         strncat(result_str, temp_str, 1);
612                                 } else {
613                                         if (*(temp_str + 1) == '%') {
614                                                 strncat(result_str, temp_str,
615                                                         1);
616                                         } else if (*(temp_str + 1) == 'd') {
617                                                 /* Get var Type */
618                                                 ret_variable_int = 0;
619
620                                                 snprintf(buf_key,
621                                                          sizeof(buf_key),
622                                                          "%dtype%d", check_type,
623                                                          num_args);
624                                                 bundle_get_str(b, buf_key, &ret_val);
625                                                 if (ret_val != NULL)
626                                                         ret_var_type = atoi(ret_val);
627
628                                                 if (ret_var_type ==
629                                                     NOTIFICATION_VARIABLE_TYPE_COUNT) {
630                                                         /* Get notification count */
631                                                         notification_get_count(noti->type,
632                                                                         noti->caller_pkgname,
633                                                                         noti->group_id,
634                                                                         noti->priv_id,
635                                                                         &ret_variable_int);
636                                                 } else {
637                                                         /* Get var Value */
638                                                         snprintf(buf_key,
639                                                                  sizeof(buf_key),
640                                                                  "%dvalue%d",
641                                                                  check_type,
642                                                                  num_args);
643                                                         bundle_get_str(b, buf_key, &ret_val);
644                                                         if (ret_val != NULL)
645                                                                 ret_variable_int = atoi(ret_val);
646                                                 }
647
648                                                 snprintf(buf_str,
649                                                          sizeof(buf_str), "%d",
650                                                          ret_variable_int);
651
652                                                 src_len = strlen(result_str);
653                                                 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
654
655                                                 strncat(result_str, buf_str,
656                                                                 max_len);
657
658                                                 temp_str++;
659
660                                                 num_args++;
661                                         } else if (*(temp_str + 1) == 's') {
662                                                 /* Get var Value */
663                                                 snprintf(buf_key,
664                                                          sizeof(buf_key),
665                                                          "%dvalue%d",
666                                                          check_type, num_args);
667                                                 bundle_get_str(b, buf_key, &ret_val);
668
669                                                 if (ret_val != NULL && noti->domain != NULL     && noti->dir != NULL) {
670                                                         /* Get application string */
671                                                         bindtextdomain(noti->domain, noti->dir);
672                                                         translated_str = dgettext(noti->domain, ret_val);
673                                                         NOTIFICATION_INFO("translated_str[%s]", translated_str);
674                                                 } else if (ret_val != NULL) {
675                                                         /* Get system string */
676                                                         translated_str = dgettext("sys_string", ret_val);
677                                                         NOTIFICATION_INFO("translated_str[%s]", translated_str);
678                                                 } else {
679                                                         translated_str = NULL;
680                                                 }
681
682                                                 if (translated_str != NULL) {
683                                                         strncpy(buf_str, translated_str, sizeof(buf_str) - 1);
684                                                         src_len = strlen(result_str);
685                                                         max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
686                                                         strncat(result_str, buf_str, max_len);
687                                                 }
688                                                 temp_str++;
689                                                 num_args++;
690                                         } else if (*(temp_str + 1) == 'f') {
691                                                 /* Get var Value */
692                                                 snprintf(buf_key,
693                                                          sizeof(buf_key),
694                                                          "%dvalue%d",
695                                                          check_type, num_args);
696                                                 bundle_get_str(b, buf_key, &ret_val);
697                                                 if (ret_val != NULL)
698                                                         ret_variable_double = atof(ret_val);
699
700                                                 snprintf(buf_str,
701                                                          sizeof(buf_str),
702                                                          "%.2f",
703                                                          ret_variable_double);
704
705                                                 src_len = strlen(result_str);
706                                                 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
707                                                 strncat(result_str, buf_str, max_len);
708
709                                                 temp_str++;
710                                                 num_args++;
711                                         } else if (*(temp_str + 1) >= '1' && *(temp_str + 1) <= '9') {
712                                                 if (*(temp_str + 3) == 'd') {
713                                                         /* Get var Type */
714                                                         ret_variable_int = 0;
715
716                                                         snprintf(buf_key,
717                                                                  sizeof(buf_key),
718                                                                  "%dtype%d", check_type,
719                                                                  num_args + *(temp_str + 1) - 49);
720                                                         bundle_get_str(b, buf_key, &ret_val);
721                                                         if (ret_val != NULL)
722                                                                 ret_var_type = atoi(ret_val);
723
724                                                         if (ret_var_type ==
725                                                             NOTIFICATION_VARIABLE_TYPE_COUNT) {
726                                                                 /* Get notification count */
727                                                                 notification_get_count(noti->type,
728                                                                                 noti->caller_pkgname,
729                                                                                 noti->group_id,
730                                                                                 noti->priv_id,
731                                                                                 &ret_variable_int);
732                                                         } else {
733                                                                 /* Get var Value */
734                                                                 snprintf(buf_key,
735                                                                          sizeof
736                                                                          (buf_key),
737                                                                          "%dvalue%d",
738                                                                          check_type,
739                                                                          num_args + *(temp_str + 1) - 49);
740                                                                 bundle_get_str(b, buf_key, &ret_val);
741                                                                 if (ret_val != NULL)
742                                                                         ret_variable_int = atoi(ret_val);
743
744                                                         }
745
746                                                         snprintf(buf_str,
747                                                                  sizeof(buf_str), "%d",
748                                                                  ret_variable_int);
749
750                                                         src_len = strlen(result_str);
751                                                         max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
752
753                                                         strncat(result_str, buf_str, max_len);
754
755                                                         temp_str += 3;
756                                                 } else if (*(temp_str + 3) == 's') {
757                                                         /* Get var Value */
758                                                         snprintf(buf_key,
759                                                                  sizeof(buf_key),
760                                                                  "%dvalue%d",
761                                                                  check_type, num_args + *(temp_str + 1) - 49);
762                                                         bundle_get_str(b, buf_key, &ret_val);
763
764                                                         snprintf(buf_str,
765                                                                  sizeof(buf_str), "%s",
766                                                                  ret_val);
767
768                                                         src_len = strlen(result_str);
769                                                         max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
770
771                                                         strncat(result_str, buf_str, max_len);
772
773                                                         temp_str += 3;
774                                                 } else if (*(temp_str + 3) == 'f') {
775                                                         /* Get var Value */
776                                                         snprintf(buf_key,
777                                                                  sizeof(buf_key),
778                                                                  "%dvalue%d",
779                                                                  check_type, num_args + *(temp_str + 1) - 49);
780                                                         bundle_get_str(b, buf_key, &ret_val);
781                                                         if (ret_val != NULL)
782                                                                 ret_variable_double = atof(ret_val);
783
784                                                         snprintf(buf_str,
785                                                                  sizeof(buf_str),
786                                                                  "%.2f",
787                                                                  ret_variable_double);
788
789                                                         src_len = strlen(result_str);
790                                                         max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
791
792                                                         strncat(result_str, buf_str, max_len);
793
794                                                         temp_str += 3;
795                                                 }
796                                         }
797                                 }
798
799                         }
800
801                         /* Check last variable is count, LEFT pos */
802                         if (num_args < noti->num_format_args) {
803                                 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
804                                          check_type, num_args);
805                                 bundle_get_str(b, buf_key, &ret_val);
806                                 if (ret_val != NULL)
807                                         ret_var_type = atoi(ret_val);
808
809                                 if (ret_var_type ==
810                                     NOTIFICATION_VARIABLE_TYPE_COUNT) {
811                                         /* Get var Value */
812                                         snprintf(buf_key, sizeof(buf_key),
813                                                  "%dvalue%d", check_type,
814                                                  num_args);
815                                         bundle_get_str(b, buf_key, &ret_val);
816                                         if (ret_val != NULL)
817                                                 ret_variable_int = atoi(ret_val);
818
819                                         if (ret_variable_int ==
820                                             NOTIFICATION_COUNT_POS_RIGHT) {
821                                                 notification_get_count(noti->type,
822                                                                 noti->caller_pkgname,
823                                                                 noti->group_id,
824                                                                 noti->priv_id,
825                                                                 &ret_variable_int);
826                                                 snprintf(buf_str,
827                                                          sizeof(buf_str), " %d",
828                                                          ret_variable_int);
829
830                                                 src_len = strlen(result_str);
831                                                 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
832
833                                                 strncat(result_str, buf_str, max_len);
834
835                                                 num_args++;
836                                         }
837
838                                 }
839                         }
840
841                         switch (check_type) {
842                         case NOTIFICATION_TEXT_TYPE_TITLE:
843                         case NOTIFICATION_TEXT_TYPE_GROUP_TITLE:
844                                 if (noti->temp_title != NULL)
845                                         free(noti->temp_title);
846
847                                 noti->temp_title = strdup(result_str);
848
849                                 *text = noti->temp_title;
850                                 break;
851                         case NOTIFICATION_TEXT_TYPE_CONTENT:
852                         case NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
853                         case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT:
854                         case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
855                                 if (noti->temp_content !=
856                                     NULL)
857                                         free(noti->temp_content);
858
859                                 noti->temp_content = strdup(result_str);
860
861                                 *text = noti->temp_content;
862                                 break;
863                         default:
864                                 break;
865                         }
866
867                 }
868
869         } else {
870                 *text = NULL;
871         }
872
873         return NOTIFICATION_ERROR_NONE;
874 }
875
876 EXPORT_API int notification_set_text_domain(notification_h noti,
877                                                              const char *domain,
878                                                              const char *dir)
879 {
880         /* check noti and domain is valid data */
881         if (noti == NULL || domain == NULL || dir == NULL)
882                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
883
884         /* Check domain */
885         if (noti->domain)
886                 /* Remove previous domain */
887                 free(noti->domain);
888
889         /* Copy domain */
890         noti->domain = strdup(domain);
891
892         /* Check locale dir */
893         if (noti->dir)
894                 /* Remove previous locale dir */
895                 free(noti->dir);
896
897         /* Copy locale dir */
898         noti->dir = strdup(dir);
899
900         return NOTIFICATION_ERROR_NONE;
901 }
902
903 EXPORT_API int notification_get_text_domain(notification_h noti,
904                                                              char **domain,
905                                                              char **dir)
906 {
907         /* Check noti is valid data */
908         if (noti == NULL)
909                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
910
911         /* Get domain */
912         if (domain != NULL && noti->domain != NULL)
913                 *domain = noti->domain;
914
915         /* Get locale dir */
916         if (dir != NULL && noti->dir != NULL)
917                 *dir = noti->dir;
918
919         return NOTIFICATION_ERROR_NONE;
920 }
921
922 EXPORT_API int notification_set_time_to_text(notification_h noti, notification_text_type_e type,
923                                                                 time_t time)
924 {
925         int ret = NOTIFICATION_ERROR_NONE;
926         char buf[256] = { 0, };
927         char buf_tag[512] = { 0, };
928
929         if (noti == NULL)
930                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
931
932         if (time <= 0)
933                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
934
935         if (type <= NOTIFICATION_TEXT_TYPE_NONE
936             || type >= NOTIFICATION_TEXT_TYPE_MAX)
937                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
938
939
940         snprintf(buf, sizeof(buf), "%lu", time);
941         ret = notification_noti_set_tag(TAG_TIME, buf, buf_tag, sizeof(buf_tag));
942
943         if (ret != NOTIFICATION_ERROR_NONE)
944                 return ret;
945
946         return notification_set_text(noti, type, buf_tag, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
947 }
948
949 EXPORT_API int notification_get_time_from_text(notification_h noti, notification_text_type_e type,
950                                                                 time_t *time)
951 {
952         int ret = NOTIFICATION_ERROR_NONE;
953         char *ret_text = NULL;
954         char *tag_value;
955
956         if (noti == NULL)
957                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
958
959         if (time == NULL)
960                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
961
962         if (type <= NOTIFICATION_TEXT_TYPE_NONE
963             || type >= NOTIFICATION_TEXT_TYPE_MAX)
964                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
965
966         ret = notification_get_text(noti, type, &ret_text);
967
968         if (ret != NOTIFICATION_ERROR_NONE || ret_text == NULL)
969                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
970
971         if (notification_noti_get_tag_type(ret_text) == TAG_TYPE_INVALID)
972                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
973
974         tag_value = notification_noti_strip_tag(ret_text);
975         if (tag_value == NULL)
976                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
977
978         *time = atol(tag_value);
979         free(tag_value);
980
981         return NOTIFICATION_ERROR_NONE;
982 }
983
984 EXPORT_API int notification_set_sound(notification_h noti,
985                                                        notification_sound_type_e type,
986                                                        const char *path)
987 {
988         /* Check noti is valid data */
989         if (noti == NULL)
990                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
991
992
993         /* Check type is valid */
994         if (type < NOTIFICATION_SOUND_TYPE_NONE
995             || type >= NOTIFICATION_SOUND_TYPE_MAX)
996                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
997
998         /* Save sound type */
999         noti->sound_type = type;
1000
1001         /* Save sound path if user data type */
1002         if (type == NOTIFICATION_SOUND_TYPE_USER_DATA && path != NULL) {
1003                 if (noti->sound_path != NULL)
1004                         free(noti->sound_path);
1005
1006                 noti->sound_path = strdup(path);
1007         } else {
1008                 if (noti->sound_path != NULL) {
1009                         free(noti->sound_path);
1010                         noti->sound_path = NULL;
1011                 }
1012                 if (type == NOTIFICATION_SOUND_TYPE_USER_DATA) {
1013                         noti->sound_type = NOTIFICATION_SOUND_TYPE_DEFAULT;
1014                         return NOTIFICATION_ERROR_INVALID_PARAMETER;
1015                 }
1016         }
1017
1018         return NOTIFICATION_ERROR_NONE;
1019 }
1020
1021 EXPORT_API int notification_get_sound(notification_h noti,
1022                                                        notification_sound_type_e *type,
1023                                                        const char **path)
1024 {
1025         /* check noti and type is valid data */
1026         if (noti == NULL || type == NULL)
1027                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1028
1029         /* Set sound type */
1030         *type = noti->sound_type;
1031
1032         /* Set sound path if user data type */
1033         if (noti->sound_type == NOTIFICATION_SOUND_TYPE_USER_DATA
1034             && path != NULL)
1035                 *path = noti->sound_path;
1036
1037         return NOTIFICATION_ERROR_NONE;
1038 }
1039
1040 EXPORT_API int notification_set_vibration(notification_h noti,
1041                                                            notification_vibration_type_e type,
1042                                                            const char *path)
1043 {
1044         /* Check noti is valid data */
1045         if (noti == NULL)
1046                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1047
1048         /* Check type is valid */
1049         if (type < NOTIFICATION_VIBRATION_TYPE_NONE
1050             || type >= NOTIFICATION_VIBRATION_TYPE_MAX)
1051                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1052
1053         /* Save vibration type */
1054         noti->vibration_type = type;
1055
1056         /* Save sound path if user data type */
1057         if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA && path != NULL) {
1058                 if (noti->vibration_path != NULL)
1059                         free(noti->vibration_path);
1060
1061                 noti->vibration_path = strdup(path);
1062         } else {
1063                 if (noti->vibration_path != NULL) {
1064                         free(noti->vibration_path);
1065                         noti->vibration_path = NULL;
1066                 }
1067                 if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA) {
1068                         noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_DEFAULT;
1069                         return NOTIFICATION_ERROR_INVALID_PARAMETER;
1070                 }
1071         }
1072
1073         return NOTIFICATION_ERROR_NONE;
1074
1075 }
1076
1077 EXPORT_API int notification_get_vibration(notification_h noti,
1078                                                            notification_vibration_type_e *type,
1079                                                            const char **path)
1080 {
1081         /* check noti and type is valid data */
1082         if (noti == NULL || type == NULL)
1083                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1084
1085         /* Set vibration type */
1086         *type = noti->vibration_type;
1087
1088         /* Set sound path if user data type */
1089         if (noti->vibration_type == NOTIFICATION_VIBRATION_TYPE_USER_DATA
1090             && path != NULL)
1091                 *path = noti->vibration_path;
1092
1093         return NOTIFICATION_ERROR_NONE;
1094 }
1095
1096 EXPORT_API int notification_set_led(notification_h noti,
1097                                                            notification_led_op_e operation,
1098                                                            int led_argb)
1099 {
1100         /* Check noti is valid data */
1101         if (noti == NULL)
1102                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1103
1104         /* Check operation is valid */
1105         if (operation < NOTIFICATION_LED_OP_OFF
1106             || operation >= NOTIFICATION_LED_OP_MAX)
1107                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1108
1109         /* Save led operation */
1110         noti->led_operation = operation;
1111
1112         /* Save led argb if operation is turning on LED with custom color */
1113         if (operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR)
1114                 noti->led_argb = led_argb;
1115
1116         return NOTIFICATION_ERROR_NONE;
1117 }
1118
1119 EXPORT_API int notification_get_led(notification_h noti,
1120                                                            notification_led_op_e *operation,
1121                                                            int *led_argb)
1122 {
1123         /* check noti and operation is valid data */
1124         if (noti == NULL || operation == NULL)
1125                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1126
1127         /* Set led operation */
1128         *operation = noti->led_operation;
1129
1130         /* Save led argb if operation is turning on LED with custom color */
1131         if (noti->led_operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR
1132             && led_argb != NULL)
1133                 *led_argb = noti->led_argb;
1134
1135         return NOTIFICATION_ERROR_NONE;
1136 }
1137
1138 EXPORT_API int notification_set_led_time_period(notification_h noti,
1139                                                                         int on_ms, int off_ms)
1140 {
1141         /* Check noti is valid data */
1142         if (noti == NULL || on_ms < 0 || off_ms < 0)
1143                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1144
1145         /* Save led operation */
1146         noti->led_on_ms = on_ms;
1147         noti->led_off_ms = off_ms;
1148
1149         return NOTIFICATION_ERROR_NONE;
1150 }
1151
1152 EXPORT_API int notification_get_led_time_period(notification_h noti,
1153                                                                         int *on_ms, int *off_ms)
1154 {
1155         /* check noti and operation is valid data */
1156         if (noti == NULL)
1157                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1158
1159         if (on_ms)
1160                 *(on_ms) = noti->led_on_ms;
1161         if (off_ms)
1162                 *(off_ms) = noti->led_off_ms;
1163
1164         return NOTIFICATION_ERROR_NONE;
1165 }
1166
1167 EXPORT_API int notification_set_launch_option(notification_h noti,
1168                                                                 notification_launch_option_type type, void *option)
1169 {
1170         int err = NOTIFICATION_ERROR_NONE;
1171         int ret = 0;
1172         bundle *b = NULL;
1173         app_control_h app_control = option;
1174
1175         if (noti == NULL || app_control == NULL || type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL) {
1176                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1177                 goto out;
1178         }
1179
1180         if ((ret = app_control_export_as_bundle(app_control, &b)) != APP_CONTROL_ERROR_NONE) {
1181                 NOTIFICATION_ERR("Failed to convert appcontrol to bundle:%d", ret);
1182                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1183                 goto out;
1184         }
1185
1186         err = notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, b);
1187
1188 out:
1189         if (b)
1190                 bundle_free(b);
1191
1192         return err;
1193 }
1194
1195 EXPORT_API int notification_get_launch_option(notification_h noti,
1196                                                                 notification_launch_option_type type, void *option)
1197 {
1198         int ret = 0;
1199         bundle *b = NULL;
1200         app_control_h *app_control = (app_control_h *)option;
1201         app_control_h app_control_new = NULL;
1202
1203         if (noti == NULL)
1204                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1205
1206         if (app_control == NULL)
1207                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1208
1209         if (type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL)
1210                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1211
1212
1213         ret = notification_get_execute_option(noti,
1214                                 NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
1215                                 NULL,
1216                                 &b);
1217         if (ret == NOTIFICATION_ERROR_NONE && b != NULL) {
1218                 ret = app_control_create(&app_control_new);
1219                 if (ret == APP_CONTROL_ERROR_NONE && app_control_new != NULL) {
1220                         ret = app_control_import_from_bundle(app_control_new, b);
1221                         if (ret == APP_CONTROL_ERROR_NONE) {
1222                                 *app_control = app_control_new;
1223                         } else {
1224                                 app_control_destroy(app_control_new);
1225                                 NOTIFICATION_ERR("Failed to import app control from bundle:%d", ret);
1226                                 return NOTIFICATION_ERROR_IO_ERROR;
1227                         }
1228                 } else {
1229                         NOTIFICATION_ERR("Failed to create app control:%d", ret);
1230                         return NOTIFICATION_ERROR_IO_ERROR;
1231                 }
1232         } else {
1233                 NOTIFICATION_ERR("Failed to get execute option:%d", ret);
1234                 return ret;
1235         }
1236
1237         return NOTIFICATION_ERROR_NONE;
1238 }
1239
1240 EXPORT_API int notification_set_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h event_handler)
1241 {
1242         int err = NOTIFICATION_ERROR_NONE;
1243         bundle *app_control_bundle = NULL;
1244
1245         if (noti == NULL) {
1246                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1247                 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1248                 goto out;
1249         }
1250
1251         if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
1252                 || event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
1253                 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1254                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1255                 goto out;
1256         }
1257
1258         if ((err = app_control_export_as_bundle(event_handler, &app_control_bundle)) != APP_CONTROL_ERROR_NONE) {
1259                 NOTIFICATION_ERR("app_control_to_bundle failed [%d]", err);
1260                 goto out;
1261         }
1262
1263         if (noti->b_event_handler[event_type] != NULL)
1264                 bundle_free(noti->b_event_handler[event_type]);
1265
1266         noti->b_event_handler[event_type] = app_control_bundle;
1267
1268 out:
1269         return err;
1270 }
1271
1272 EXPORT_API int notification_get_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h *event_handler)
1273 {
1274         int err = NOTIFICATION_ERROR_NONE;
1275         bundle *b = NULL;
1276         app_control_h app_control_new = NULL;
1277
1278         if (noti == NULL) {
1279                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1280                 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1281                 goto out;
1282         }
1283         if (event_handler == NULL) {
1284                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1285                 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1286                 goto out;
1287         }
1288         if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
1289                 || event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
1290                 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1291                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1292                 goto out;
1293         }
1294
1295         b = noti->b_event_handler[event_type];
1296
1297         if (b == NULL) {
1298                 NOTIFICATION_DBG("No event handler\n");
1299                 err = NOTIFICATION_ERROR_NOT_EXIST_ID;
1300                 goto out;
1301         }
1302
1303         err = app_control_create(&app_control_new);
1304         if (err != APP_CONTROL_ERROR_NONE || app_control_new == NULL) {
1305                 NOTIFICATION_ERR("app_control_create failed [%d]", err);
1306                 err = NOTIFICATION_ERROR_IO_ERROR;
1307                 goto out;
1308         }
1309
1310         err = app_control_import_from_bundle(app_control_new, b);
1311         if (err == APP_CONTROL_ERROR_NONE) {
1312                 *event_handler = app_control_new;
1313         } else {
1314                 app_control_destroy(app_control_new);
1315                 app_control_new = NULL;
1316                 NOTIFICATION_ERR("Failed to import app control from bundle [%d]", err);
1317                 err = NOTIFICATION_ERROR_IO_ERROR;
1318                 goto out;
1319         }
1320
1321 out:
1322         if (event_handler)
1323                 *event_handler = app_control_new;
1324
1325         return err;
1326 }
1327
1328
1329
1330
1331
1332 EXPORT_API int notification_set_property(notification_h noti,
1333                                                           int flags)
1334 {
1335         /* Check noti is valid data */
1336         if (noti == NULL)
1337                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1338
1339         /* Set flags */
1340         noti->flags_for_property = flags;
1341
1342         return NOTIFICATION_ERROR_NONE;
1343 }
1344
1345 EXPORT_API int notification_get_property(notification_h noti,
1346                                                           int *flags)
1347 {
1348         /* Check noti and flags are valid data */
1349         if (noti == NULL || flags == NULL)
1350                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1351
1352         /* Set flags */
1353         *flags = noti->flags_for_property;
1354
1355         return NOTIFICATION_ERROR_NONE;
1356 }
1357
1358 EXPORT_API int notification_set_display_applist(notification_h noti,
1359                                                                  int applist)
1360 {
1361         /* Check noti is valid data */
1362         if (noti == NULL)
1363                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1364
1365
1366         /* Set app list */
1367         if (applist == 0xffffffff) /* 0xffffffff means old NOTIFICATION_DISPLAY_APP_ALL */
1368                 applist = NOTIFICATION_DISPLAY_APP_ALL;
1369
1370         noti->display_applist = applist;
1371
1372         return NOTIFICATION_ERROR_NONE;
1373 }
1374
1375 EXPORT_API int notification_get_display_applist(notification_h noti,
1376                                                                  int *applist)
1377 {
1378         /* Check noti and applist are valid data */
1379         if (noti == NULL || applist == NULL)
1380                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1381
1382         /* Set app list */
1383         *applist = noti->display_applist;
1384
1385         return NOTIFICATION_ERROR_NONE;
1386 }
1387
1388 EXPORT_API int notification_set_size(notification_h noti,
1389                                                       double size)
1390 {
1391         /* Check noti is valid data */
1392         if (noti == NULL)
1393                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1394
1395         /* Save progress size */
1396         noti->progress_size = size;
1397
1398         return NOTIFICATION_ERROR_NONE;
1399 }
1400
1401 EXPORT_API int notification_get_size(notification_h noti,
1402                                                       double *size)
1403 {
1404         /* Check noti and size is valid data */
1405         if (noti == NULL || size == NULL)
1406                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1407
1408         /* Set progress size */
1409         *size = noti->progress_size;
1410
1411         return NOTIFICATION_ERROR_NONE;
1412 }
1413
1414 EXPORT_API int notification_set_progress(notification_h noti,
1415                                                           double percentage)
1416 {
1417         /* Check noti is valid data */
1418         if (noti == NULL)
1419                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1420
1421         /* Save progress percentage */
1422         noti->progress_percentage = percentage;
1423
1424         return NOTIFICATION_ERROR_NONE;
1425 }
1426
1427 EXPORT_API int notification_get_progress(notification_h noti,
1428                                                           double *percentage)
1429 {
1430         /* Check noti and percentage are valid data */
1431         if (noti == NULL || percentage == NULL)
1432                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1433
1434         /* Set progress percentage */
1435         *percentage = noti->progress_percentage;
1436
1437         return NOTIFICATION_ERROR_NONE;
1438 }
1439
1440 EXPORT_API int notification_get_pkgname(notification_h noti,
1441                                                          char **pkgname)
1442 {
1443         /* Check noti and pkgname are valid data */
1444         if (noti == NULL || pkgname == NULL)
1445                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1446
1447         /* Get caller pkgname */
1448         if (noti->caller_pkgname)
1449                 *pkgname = noti->caller_pkgname;
1450         else
1451                 *pkgname = NULL;
1452
1453         return NOTIFICATION_ERROR_NONE;
1454 }
1455
1456 EXPORT_API int notification_set_layout(notification_h noti,
1457                 notification_ly_type_e layout)
1458 {
1459         /* check noti and pkgname are valid data */
1460         if (noti == NULL || (layout < NOTIFICATION_LY_NONE || layout >= NOTIFICATION_LY_MAX))
1461                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1462
1463         noti->layout = layout;
1464
1465         return NOTIFICATION_ERROR_NONE;
1466 }
1467
1468 EXPORT_API int notification_get_layout(notification_h noti,
1469                 notification_ly_type_e *layout)
1470 {
1471         /* Check noti and pkgname are valid data */
1472         if (noti == NULL || layout == NULL)
1473                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1474
1475         *layout = noti->layout;
1476
1477         return NOTIFICATION_ERROR_NONE;
1478 }
1479
1480
1481
1482 EXPORT_API int notification_get_type(notification_h noti,
1483                                                       notification_type_e *type)
1484 {
1485         /* Check noti and type is valid data */
1486         if (noti == NULL || type == NULL)
1487                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1488
1489         /* Set noti type */
1490         *type = noti->type;
1491
1492         return NOTIFICATION_ERROR_NONE;
1493 }
1494
1495 EXPORT_API int notification_post(notification_h noti)
1496 {
1497         int ret = 0;
1498         int id = 0;
1499
1500         /* Check noti is vaild data */
1501         if (noti == NULL)
1502                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1503
1504         /* Check noti type is valid type */
1505         if (noti->type <= NOTIFICATION_TYPE_NONE
1506             || noti->type >= NOTIFICATION_TYPE_MAX)
1507                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1508
1509         /* Save insert time */
1510         noti->insert_time = time(NULL);
1511
1512         ret = notification_ipc_request_insert(noti, &id);
1513         if (ret != NOTIFICATION_ERROR_NONE)
1514                 return ret;
1515
1516         noti->priv_id = id;
1517         NOTIFICATION_DBG("from master:%d", id);
1518
1519         return NOTIFICATION_ERROR_NONE;
1520 }
1521
1522
1523
1524 EXPORT_API int notification_update(notification_h noti)
1525 {
1526         int ret = 0;
1527
1528         /* Check noti is valid data */
1529         if (noti != NULL) {
1530                 /* Update insert time ? */
1531                 noti->insert_time = time(NULL);
1532                 ret = notification_ipc_request_update(noti);
1533         } else {
1534                 notification_ipc_request_refresh();
1535                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1536         }
1537         return ret;
1538 }
1539
1540 EXPORT_API int notification_delete_all(notification_type_e type)
1541 {
1542         int ret = 0;
1543         char *caller_pkgname = NULL;
1544
1545         if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX)
1546                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1547
1548         caller_pkgname = notification_get_pkgname_by_pid();
1549
1550         ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
1551
1552         if (caller_pkgname)
1553                 free(caller_pkgname);
1554
1555         return ret;
1556 }
1557
1558 EXPORT_API int notification_delete(notification_h noti)
1559 {
1560         int ret = 0;
1561
1562         if (noti == NULL)
1563                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1564
1565         ret = notification_ipc_request_delete_single(NOTIFICATION_TYPE_NONE, noti->caller_pkgname, noti->priv_id);
1566
1567         return ret;
1568 }
1569
1570 static notification_h _notification_create(notification_type_e type)
1571 {
1572         notification_h noti = NULL;
1573         package_info_h package_info = NULL;
1574         char *app_id = NULL;
1575         char *domain_name = NULL;
1576         char *app_root_path = NULL;
1577         char locale_directory[PATH_MAX] = { 0, }; /* PATH_MAX 4096 */
1578         int err_app_manager = APP_MANAGER_ERROR_NONE;
1579
1580         if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
1581                 NOTIFICATION_ERR("INVALID TYPE : %d", type);
1582                 set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
1583                 return NULL;
1584         }
1585
1586         noti = (notification_h) calloc(1, sizeof(struct _notification));
1587         if (noti == NULL) {
1588                 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
1589                 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
1590                 return NULL;
1591         }
1592
1593         noti->type = type;
1594
1595         if (type == NOTIFICATION_TYPE_NOTI)
1596                 noti->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
1597         else if (type == NOTIFICATION_TYPE_ONGOING)
1598                 noti->layout = NOTIFICATION_LY_ONGOING_PROGRESS;
1599
1600         noti->caller_pkgname = notification_get_pkgname_by_pid();
1601         noti->group_id = NOTIFICATION_GROUP_ID_NONE;
1602         noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
1603         noti->sound_type = NOTIFICATION_SOUND_TYPE_NONE;
1604         noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_NONE;
1605         noti->led_operation = NOTIFICATION_LED_OP_OFF;
1606         noti->display_applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_TICKER | NOTIFICATION_DISPLAY_APP_INDICATOR;
1607         noti->auto_remove = true;
1608
1609         err_app_manager = app_manager_get_app_id(getpid(), &app_id);
1610         if (err_app_manager != APP_MANAGER_ERROR_NONE || app_id == NULL) {
1611                 NOTIFICATION_WARN("app_manager_get_app_id failed err[%d] app_id[%p]", err_app_manager, app_id);
1612                 goto out;
1613         }
1614
1615         /* app name is used as domain name */
1616         /* domain_name is allocated by app_get_package_app_name */
1617         err_app_manager = app_get_package_app_name(app_id, &domain_name);
1618
1619         if (err_app_manager != APP_ERROR_NONE || domain_name == NULL) {
1620                 NOTIFICATION_WARN("app_get_package_app_name failed err[%d] domain_name[%p]", err_app_manager, domain_name);
1621                 goto out;
1622         }
1623
1624         err_app_manager = package_info_create(noti->caller_pkgname, &package_info);
1625
1626         if (err_app_manager != PACKAGE_MANAGER_ERROR_NONE || package_info == NULL) {
1627                 NOTIFICATION_WARN("package_info_create failed err[%d] package_info[%p] caller_pkgname[%s]",
1628                                 err_app_manager, package_info, noti->caller_pkgname);
1629                 goto out;
1630         }
1631
1632         err_app_manager = package_info_get_root_path(package_info, &app_root_path);
1633
1634         if (err_app_manager != PACKAGE_MANAGER_ERROR_NONE || app_root_path == NULL) {
1635                 NOTIFICATION_WARN("package_info_get_root_path failed err[%d] app_root_path[%p]", err_app_manager, app_root_path);
1636                 goto out;
1637         }
1638
1639         snprintf(locale_directory, PATH_MAX, "%s/res/locale", app_root_path);
1640
1641         noti->domain = strdup(domain_name);
1642         noti->dir    = strdup(locale_directory);
1643
1644 out:
1645         if (domain_name)
1646                 free(domain_name);
1647
1648         if (app_id)
1649                 free(app_id);
1650
1651         if (app_root_path)
1652                 free(app_root_path);
1653
1654         if (package_info)
1655                 package_info_destroy(package_info);
1656
1657         /*!
1658          * \NOTE
1659          * Other fields are already initialized with ZERO.
1660          */
1661         set_last_result(NOTIFICATION_ERROR_NONE);
1662         return noti;
1663 }
1664
1665 EXPORT_API notification_h notification_create(notification_type_e type)
1666 {
1667         return _notification_create(type);
1668 }
1669
1670 EXPORT_API notification_h  notification_load_by_tag(const char *tag)
1671 {
1672         int ret = 0;
1673         notification_h noti = NULL;
1674         char *caller_pkgname = NULL;
1675
1676         if (tag == NULL) {
1677                 NOTIFICATION_ERR("Invalid parameter");
1678                 set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
1679                 return NULL;
1680         }
1681
1682         caller_pkgname = notification_get_pkgname_by_pid();
1683         if (!caller_pkgname) {
1684                 NOTIFICATION_ERR("Failed to get a package name");
1685                 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
1686                 return NULL;
1687         }
1688
1689         noti = (notification_h)calloc(1, sizeof(struct _notification));
1690         if (noti == NULL) {
1691                 NOTIFICATION_ERR("Failed to alloc a new notification");
1692                 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
1693                 free(caller_pkgname);
1694
1695                 return NULL;
1696         }
1697
1698         ret = notification_ipc_request_load_noti_by_tag(noti, caller_pkgname, (char*)tag);
1699         free(caller_pkgname);
1700
1701         set_last_result(ret);
1702         if (ret != NOTIFICATION_ERROR_NONE) {
1703                 notification_free(noti);
1704                 return NULL;
1705         }
1706
1707         return noti;
1708 }
1709
1710 EXPORT_API int notification_clone(notification_h noti, notification_h *clone)
1711 {
1712         int i = 0;
1713         notification_h new_noti = NULL;
1714
1715         if (noti == NULL || clone == NULL) {
1716                 NOTIFICATION_ERR("INVALID PARAMETER.");
1717                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1718         }
1719
1720         new_noti = (notification_h) calloc(1, sizeof(struct _notification));
1721         if (new_noti == NULL) {
1722                 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
1723                 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
1724         }
1725
1726         new_noti->type = noti->type;
1727         new_noti->layout = noti->layout;
1728
1729         new_noti->group_id = noti->group_id;
1730         new_noti->internal_group_id = noti->internal_group_id;
1731         new_noti->priv_id = noti->priv_id;
1732
1733         if (noti->caller_pkgname != NULL)
1734                 new_noti->caller_pkgname = strdup(noti->caller_pkgname);
1735         else
1736                 new_noti->caller_pkgname = notification_get_pkgname_by_pid();
1737
1738         if (noti->launch_pkgname != NULL)
1739                 new_noti->launch_pkgname = strdup(noti->launch_pkgname);
1740         else
1741                 new_noti->launch_pkgname = NULL;
1742
1743         if (noti->args != NULL)
1744                 new_noti->args = bundle_dup(noti->args);
1745         else
1746                 new_noti->args = NULL;
1747
1748         if (noti->group_args != NULL)
1749                 new_noti->group_args = bundle_dup(noti->group_args);
1750         else
1751                 new_noti->group_args = NULL;
1752
1753         if (noti->b_execute_option != NULL)
1754                 new_noti->b_execute_option = bundle_dup(noti->b_execute_option);
1755         else
1756                 new_noti->b_execute_option = NULL;
1757
1758         if (noti->b_service_responding != NULL)
1759                 new_noti->b_service_responding = bundle_dup(noti->b_service_responding);
1760         else
1761                 new_noti->b_service_responding = NULL;
1762
1763         if (noti->b_service_single_launch != NULL)
1764                 new_noti->b_service_single_launch = bundle_dup(noti->b_service_single_launch);
1765         else
1766                 new_noti->b_service_single_launch = NULL;
1767
1768         if (noti->b_service_multi_launch != NULL)
1769                 new_noti->b_service_multi_launch = bundle_dup(noti->b_service_multi_launch);
1770         else
1771                 new_noti->b_service_multi_launch = NULL;
1772
1773         for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
1774                 if (noti->b_event_handler[i] != NULL)
1775                         new_noti->b_event_handler[i] = bundle_dup(noti->b_event_handler[i]);
1776                 else
1777                         new_noti->b_event_handler[i] = NULL;
1778         }
1779
1780         new_noti->sound_type = noti->sound_type;
1781         if (noti->sound_path != NULL)
1782                 new_noti->sound_path = strdup(noti->sound_path);
1783         else
1784                 new_noti->sound_path = NULL;
1785
1786         new_noti->vibration_type = noti->vibration_type;
1787         if (noti->vibration_path != NULL)
1788                 new_noti->vibration_path = strdup(noti->vibration_path);
1789         else
1790                 new_noti->vibration_path = NULL;
1791
1792         new_noti->led_operation = noti->led_operation;
1793         new_noti->led_argb = noti->led_argb;
1794         new_noti->led_on_ms = noti->led_on_ms;
1795         new_noti->led_off_ms = noti->led_off_ms;
1796
1797         if (noti->domain != NULL)
1798                 new_noti->domain = strdup(noti->domain);
1799         else
1800                 new_noti->domain = NULL;
1801
1802         if (noti->dir != NULL)
1803                 new_noti->dir = strdup(noti->dir);
1804         else
1805                 new_noti->dir = NULL;
1806
1807         if (noti->b_text != NULL)
1808                 new_noti->b_text = bundle_dup(noti->b_text);
1809         else
1810                 new_noti->b_text = NULL;
1811
1812         if (noti->b_key != NULL)
1813                 new_noti->b_key = bundle_dup(noti->b_key);
1814         else
1815                 new_noti->b_key = NULL;
1816
1817         if (noti->b_format_args != NULL)
1818                 new_noti->b_format_args = bundle_dup(noti->b_format_args);
1819         else
1820                 new_noti->b_format_args = NULL;
1821
1822         new_noti->num_format_args = noti->num_format_args;
1823
1824         if (noti->b_image_path != NULL)
1825                 new_noti->b_image_path = bundle_dup(noti->b_image_path);
1826         else
1827                 new_noti->b_image_path = NULL;
1828
1829         new_noti->time = noti->time;
1830         new_noti->insert_time = noti->insert_time;
1831
1832         new_noti->flags_for_property = noti->flags_for_property;
1833         new_noti->display_applist = noti->display_applist;
1834
1835         new_noti->progress_size = noti->progress_size;
1836         new_noti->progress_percentage = noti->progress_percentage;
1837
1838         new_noti->ongoing_flag = noti->ongoing_flag;
1839         new_noti->auto_remove = noti->auto_remove;
1840
1841         new_noti->app_icon_path = NULL;
1842         new_noti->app_name = NULL;
1843         new_noti->temp_title = NULL;
1844         new_noti->temp_content = NULL;
1845
1846         *clone = new_noti;
1847
1848         return NOTIFICATION_ERROR_NONE;
1849 }
1850
1851
1852 EXPORT_API int notification_free(notification_h noti)
1853 {
1854         int i = 0;
1855         if (noti == NULL)
1856                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1857
1858         if (noti->caller_pkgname)
1859                 free(noti->caller_pkgname);
1860
1861         if (noti->launch_pkgname)
1862                 free(noti->launch_pkgname);
1863
1864         if (noti->args)
1865                 bundle_free(noti->args);
1866
1867         if (noti->group_args)
1868                 bundle_free(noti->group_args);
1869
1870         if (noti->b_execute_option)
1871                 bundle_free(noti->b_execute_option);
1872
1873         if (noti->b_service_responding)
1874                 bundle_free(noti->b_service_responding);
1875
1876         if (noti->b_service_single_launch)
1877                 bundle_free(noti->b_service_single_launch);
1878
1879         if (noti->b_service_multi_launch)
1880                 bundle_free(noti->b_service_multi_launch);
1881
1882         for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
1883                 if (noti->b_event_handler[i] != NULL)
1884                         bundle_free(noti->b_event_handler[i]);
1885         }
1886
1887         if (noti->sound_path)
1888                 free(noti->sound_path);
1889
1890         if (noti->vibration_path)
1891                 free(noti->vibration_path);
1892
1893         if (noti->domain)
1894                 free(noti->domain);
1895
1896         if (noti->dir)
1897                 free(noti->dir);
1898
1899         if (noti->b_text)
1900                 bundle_free(noti->b_text);
1901
1902         if (noti->b_key)
1903                 bundle_free(noti->b_key);
1904
1905         if (noti->b_format_args)
1906                 bundle_free(noti->b_format_args);
1907
1908         if (noti->b_image_path)
1909                 bundle_free(noti->b_image_path);
1910
1911         if (noti->app_icon_path)
1912                 free(noti->app_icon_path);
1913
1914         if (noti->app_name)
1915                 free(noti->app_name);
1916
1917         if (noti->temp_title)
1918                 free(noti->temp_title);
1919
1920         if (noti->temp_content)
1921                 free(noti->temp_content);
1922
1923         if (noti->tag)
1924                 free(noti->tag);
1925
1926         free(noti);
1927
1928         return NOTIFICATION_ERROR_NONE;
1929 }
1930
1931 EXPORT_API int notification_set_tag(notification_h noti, const char *tag)
1932 {
1933         /* Check noti is valid data */
1934         if (noti == NULL)
1935                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1936
1937         if (tag != NULL) {
1938                 /* save input TAG */
1939                 if (noti->tag != NULL)
1940                         free(noti->tag);
1941
1942                 noti->tag = strdup(tag);
1943         }
1944
1945         return NOTIFICATION_ERROR_NONE;
1946
1947 }
1948
1949 EXPORT_API int notification_get_tag(notification_h noti, const char **tag)
1950 {
1951         /* Check noti is valid data */
1952         if (noti == NULL)
1953                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1954
1955         *tag = noti->tag;
1956         return NOTIFICATION_ERROR_NONE;
1957 }
1958
1959 void notification_call_posted_toast_cb(const char *message)
1960 {
1961         if (posted_toast_message_cb != NULL)
1962                 posted_toast_message_cb((void*)message);
1963 }
1964
1965 EXPORT_API int notification_set_ongoing_flag(notification_h noti, bool ongoing_flag)
1966 {
1967         if (noti == NULL)
1968                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1969
1970         noti->ongoing_flag = ongoing_flag;
1971
1972         return NOTIFICATION_ERROR_NONE;
1973 }
1974
1975 EXPORT_API int notification_get_ongoing_flag(notification_h noti, bool *ongoing_flag)
1976 {
1977         if (noti == NULL || ongoing_flag == NULL)
1978                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1979
1980         *ongoing_flag = noti->ongoing_flag;
1981
1982         return NOTIFICATION_ERROR_NONE;
1983 }
1984
1985
1986 EXPORT_API int notification_add_button(notification_h noti, notification_button_index_e button_index)
1987 {
1988         if (noti == NULL || button_index < NOTIFICATION_BUTTON_1 || button_index > NOTIFICATION_BUTTON_6)
1989                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1990
1991         return NOTIFICATION_ERROR_NONE;
1992 }
1993
1994 EXPORT_API int notification_remove_button(notification_h noti, notification_button_index_e button_index)
1995 {
1996         if (noti == NULL || button_index < NOTIFICATION_BUTTON_1 || button_index > NOTIFICATION_BUTTON_6)
1997                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1998
1999         if (noti->b_event_handler[button_index - 1]) {
2000                 bundle_free(noti->b_event_handler[button_index - 1]);
2001                 noti->b_event_handler[button_index - 1] = NULL;
2002         }
2003
2004         return NOTIFICATION_ERROR_NONE;
2005 }
2006
2007 EXPORT_API int notification_set_auto_remove(notification_h noti, bool auto_remove)
2008 {
2009         if (noti == NULL)
2010                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2011
2012         noti->auto_remove = auto_remove;
2013
2014         return NOTIFICATION_ERROR_NONE;
2015 }
2016
2017 EXPORT_API int notification_get_auto_remove(notification_h noti, bool *auto_remove)
2018 {
2019         if (noti == NULL || auto_remove == NULL)
2020                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2021
2022         *auto_remove = noti->auto_remove;
2023
2024         return NOTIFICATION_ERROR_NONE;
2025 }