Apply coding rule
[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_noti_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_noti_get_count
632                                                             (noti->type,
633                                                              noti->caller_pkgname,
634                                                              noti->group_id,
635                                                              noti->priv_id,
636                                                              &ret_variable_int);
637                                                 } else {
638                                                         /* Get var Value */
639                                                         snprintf(buf_key,
640                                                                  sizeof(buf_key),
641                                                                  "%dvalue%d",
642                                                                  check_type,
643                                                                  num_args);
644                                                         bundle_get_str(b, buf_key, &ret_val);
645                                                         if (ret_val != NULL)
646                                                                 ret_variable_int = atoi(ret_val);
647                                                 }
648
649                                                 snprintf(buf_str,
650                                                          sizeof(buf_str), "%d",
651                                                          ret_variable_int);
652
653                                                 src_len = strlen(result_str);
654                                                 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
655
656                                                 strncat(result_str, buf_str,
657                                                                 max_len);
658
659                                                 temp_str++;
660
661                                                 num_args++;
662                                         } else if (*(temp_str + 1) == 's') {
663                                                 /* Get var Value */
664                                                 snprintf(buf_key,
665                                                          sizeof(buf_key),
666                                                          "%dvalue%d",
667                                                          check_type, num_args);
668                                                 bundle_get_str(b, buf_key, &ret_val);
669
670                                                 if (ret_val != NULL && noti->domain != NULL     && noti->dir != NULL) {
671                                                         /* Get application string */
672                                                         bindtextdomain(noti->domain, noti->dir);
673                                                         translated_str = dgettext(noti->domain, ret_val);
674                                                         NOTIFICATION_INFO("translated_str[%s]", translated_str);
675                                                 } else if (ret_val != NULL) {
676                                                         /* Get system string */
677                                                         translated_str = dgettext("sys_string", ret_val);
678                                                         NOTIFICATION_INFO("translated_str[%s]", translated_str);
679                                                 } else {
680                                                         translated_str = NULL;
681                                                 }
682
683                                                 if (translated_str != NULL) {
684                                                         strncpy(buf_str, translated_str, sizeof(buf_str) - 1);
685                                                         src_len = strlen(result_str);
686                                                         max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
687                                                         strncat(result_str, buf_str, max_len);
688                                                 }
689                                                 temp_str++;
690                                                 num_args++;
691                                         } else if (*(temp_str + 1) == 'f') {
692                                                 /* Get var Value */
693                                                 snprintf(buf_key,
694                                                          sizeof(buf_key),
695                                                          "%dvalue%d",
696                                                          check_type, num_args);
697                                                 bundle_get_str(b, buf_key, &ret_val);
698                                                 if (ret_val != NULL)
699                                                         ret_variable_double = atof(ret_val);
700
701                                                 snprintf(buf_str,
702                                                          sizeof(buf_str),
703                                                          "%.2f",
704                                                          ret_variable_double);
705
706                                                 src_len = strlen(result_str);
707                                                 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
708                                                 strncat(result_str, buf_str, max_len);
709
710                                                 temp_str++;
711                                                 num_args++;
712                                         } else if (*(temp_str + 1) >= '1' && *(temp_str + 1) <= '9') {
713                                                 if (*(temp_str + 3) == 'd') {
714                                                         /* Get var Type */
715                                                         ret_variable_int = 0;
716
717                                                         snprintf(buf_key,
718                                                                  sizeof(buf_key),
719                                                                  "%dtype%d", check_type,
720                                                                  num_args + *(temp_str + 1) - 49);
721                                                         bundle_get_str(b, buf_key, &ret_val);
722                                                         if (ret_val != NULL)
723                                                                 ret_var_type = atoi(ret_val);
724
725                                                         if (ret_var_type ==
726                                                             NOTIFICATION_VARIABLE_TYPE_COUNT) {
727                                                                 /* Get notification count */
728                                                                 notification_noti_get_count
729                                                                     (noti->type,
730                                                                      noti->caller_pkgname,
731                                                                      noti->group_id,
732                                                                      noti->priv_id,
733                                                                      &ret_variable_int);
734                                                         } else {
735                                                                 /* Get var Value */
736                                                                 snprintf(buf_key,
737                                                                          sizeof
738                                                                          (buf_key),
739                                                                          "%dvalue%d",
740                                                                          check_type,
741                                                                          num_args + *(temp_str + 1) - 49);
742                                                                 bundle_get_str(b, buf_key, &ret_val);
743                                                                 if (ret_val != NULL)
744                                                                         ret_variable_int = atoi(ret_val);
745
746                                                         }
747
748                                                         snprintf(buf_str,
749                                                                  sizeof(buf_str), "%d",
750                                                                  ret_variable_int);
751
752                                                         src_len = strlen(result_str);
753                                                         max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
754
755                                                         strncat(result_str, buf_str, max_len);
756
757                                                         temp_str += 3;
758                                                 } else if (*(temp_str + 3) == 's') {
759                                                         /* Get var Value */
760                                                         snprintf(buf_key,
761                                                                  sizeof(buf_key),
762                                                                  "%dvalue%d",
763                                                                  check_type, num_args + *(temp_str + 1) - 49);
764                                                         bundle_get_str(b, buf_key, &ret_val);
765
766                                                         snprintf(buf_str,
767                                                                  sizeof(buf_str), "%s",
768                                                                  ret_val);
769
770                                                         src_len = strlen(result_str);
771                                                         max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
772
773                                                         strncat(result_str, buf_str, max_len);
774
775                                                         temp_str += 3;
776                                                 } else if (*(temp_str + 3) == 'f') {
777                                                         /* Get var Value */
778                                                         snprintf(buf_key,
779                                                                  sizeof(buf_key),
780                                                                  "%dvalue%d",
781                                                                  check_type, num_args + *(temp_str + 1) - 49);
782                                                         bundle_get_str(b, buf_key, &ret_val);
783                                                         if (ret_val != NULL)
784                                                                 ret_variable_double = atof(ret_val);
785
786                                                         snprintf(buf_str,
787                                                                  sizeof(buf_str),
788                                                                  "%.2f",
789                                                                  ret_variable_double);
790
791                                                         src_len = strlen(result_str);
792                                                         max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
793
794                                                         strncat(result_str, buf_str, max_len);
795
796                                                         temp_str += 3;
797                                                 }
798                                         }
799                                 }
800
801                         }
802
803                         /* Check last variable is count, LEFT pos */
804                         if (num_args < noti->num_format_args) {
805                                 snprintf(buf_key, sizeof(buf_key), "%dtype%d",
806                                          check_type, num_args);
807                                 bundle_get_str(b, buf_key, &ret_val);
808                                 if (ret_val != NULL)
809                                         ret_var_type = atoi(ret_val);
810
811                                 if (ret_var_type ==
812                                     NOTIFICATION_VARIABLE_TYPE_COUNT) {
813                                         /* Get var Value */
814                                         snprintf(buf_key, sizeof(buf_key),
815                                                  "%dvalue%d", check_type,
816                                                  num_args);
817                                         bundle_get_str(b, buf_key, &ret_val);
818                                         if (ret_val != NULL)
819                                                 ret_variable_int = atoi(ret_val);
820
821                                         if (ret_variable_int ==
822                                             NOTIFICATION_COUNT_POS_RIGHT) {
823                                                 notification_noti_get_count
824                                                     (noti->type,
825                                                      noti->caller_pkgname,
826                                                      noti->group_id,
827                                                      noti->priv_id,
828                                                      &ret_variable_int);
829                                                 snprintf(buf_str,
830                                                          sizeof(buf_str), " %d",
831                                                          ret_variable_int);
832
833                                                 src_len = strlen(result_str);
834                                                 max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
835
836                                                 strncat(result_str, buf_str, max_len);
837
838                                                 num_args++;
839                                         }
840
841                                 }
842                         }
843
844                         switch (check_type) {
845                         case NOTIFICATION_TEXT_TYPE_TITLE:
846                         case NOTIFICATION_TEXT_TYPE_GROUP_TITLE:
847                                 if (noti->temp_title != NULL)
848                                         free(noti->temp_title);
849
850                                 noti->temp_title = strdup(result_str);
851
852                                 *text = noti->temp_title;
853                                 break;
854                         case NOTIFICATION_TEXT_TYPE_CONTENT:
855                         case NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
856                         case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT:
857                         case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
858                                 if (noti->temp_content !=
859                                     NULL)
860                                         free(noti->temp_content);
861
862                                 noti->temp_content = strdup(result_str);
863
864                                 *text = noti->temp_content;
865                                 break;
866                         default:
867                                 break;
868                         }
869
870                 }
871
872         } else {
873                 *text = NULL;
874         }
875
876         return NOTIFICATION_ERROR_NONE;
877 }
878
879 EXPORT_API int notification_set_text_domain(notification_h noti,
880                                                              const char *domain,
881                                                              const char *dir)
882 {
883         /* check noti and domain is valid data */
884         if (noti == NULL || domain == NULL || dir == NULL)
885                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
886
887         /* Check domain */
888         if (noti->domain)
889                 /* Remove previous domain */
890                 free(noti->domain);
891
892         /* Copy domain */
893         noti->domain = strdup(domain);
894
895         /* Check locale dir */
896         if (noti->dir)
897                 /* Remove previous locale dir */
898                 free(noti->dir);
899
900         /* Copy locale dir */
901         noti->dir = strdup(dir);
902
903         return NOTIFICATION_ERROR_NONE;
904 }
905
906 EXPORT_API int notification_get_text_domain(notification_h noti,
907                                                              char **domain,
908                                                              char **dir)
909 {
910         /* Check noti is valid data */
911         if (noti == NULL)
912                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
913
914         /* Get domain */
915         if (domain != NULL && noti->domain != NULL)
916                 *domain = noti->domain;
917
918         /* Get locale dir */
919         if (dir != NULL && noti->dir != NULL)
920                 *dir = noti->dir;
921
922         return NOTIFICATION_ERROR_NONE;
923 }
924
925 EXPORT_API int notification_set_time_to_text(notification_h noti, notification_text_type_e type,
926                                                                 time_t time)
927 {
928         int ret = NOTIFICATION_ERROR_NONE;
929         char buf[256] = { 0, };
930         char buf_tag[512] = { 0, };
931
932         if (noti == NULL)
933                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
934
935         if (time <= 0)
936                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
937
938         if (type <= NOTIFICATION_TEXT_TYPE_NONE
939             || type >= NOTIFICATION_TEXT_TYPE_MAX)
940                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
941
942
943         snprintf(buf, sizeof(buf), "%lu", time);
944         ret = notification_noti_set_tag(TAG_TIME, buf, buf_tag, sizeof(buf_tag));
945
946         if (ret != NOTIFICATION_ERROR_NONE)
947                 return ret;
948
949         return notification_set_text(noti, type, buf_tag, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
950 }
951
952 EXPORT_API int notification_get_time_from_text(notification_h noti, notification_text_type_e type,
953                                                                 time_t *time)
954 {
955         int ret = NOTIFICATION_ERROR_NONE;
956         char *ret_text = NULL;
957         char *tag_value;
958
959         if (noti == NULL)
960                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
961
962         if (time == NULL)
963                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
964
965         if (type <= NOTIFICATION_TEXT_TYPE_NONE
966             || type >= NOTIFICATION_TEXT_TYPE_MAX)
967                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
968
969         ret = notification_get_text(noti, type, &ret_text);
970
971         if (ret != NOTIFICATION_ERROR_NONE || ret_text == NULL)
972                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
973
974         if (notification_noti_get_tag_type(ret_text) == TAG_TYPE_INVALID)
975                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
976
977         tag_value = notification_noti_strip_tag(ret_text);
978         if (tag_value == NULL)
979                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
980
981         *time = atol(tag_value);
982         free(tag_value);
983
984         return NOTIFICATION_ERROR_NONE;
985 }
986
987 EXPORT_API int notification_set_sound(notification_h noti,
988                                                        notification_sound_type_e type,
989                                                        const char *path)
990 {
991         /* Check noti is valid data */
992         if (noti == NULL)
993                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
994
995
996         /* Check type is valid */
997         if (type < NOTIFICATION_SOUND_TYPE_NONE
998             || type >= NOTIFICATION_SOUND_TYPE_MAX)
999                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1000
1001         /* Save sound type */
1002         noti->sound_type = type;
1003
1004         /* Save sound path if user data type */
1005         if (type == NOTIFICATION_SOUND_TYPE_USER_DATA && path != NULL) {
1006                 if (noti->sound_path != NULL)
1007                         free(noti->sound_path);
1008
1009                 noti->sound_path = strdup(path);
1010         } else {
1011                 if (noti->sound_path != NULL) {
1012                         free(noti->sound_path);
1013                         noti->sound_path = NULL;
1014                 }
1015                 if (type == NOTIFICATION_SOUND_TYPE_USER_DATA) {
1016                         noti->sound_type = NOTIFICATION_SOUND_TYPE_DEFAULT;
1017                         return NOTIFICATION_ERROR_INVALID_PARAMETER;
1018                 }
1019         }
1020
1021         return NOTIFICATION_ERROR_NONE;
1022 }
1023
1024 EXPORT_API int notification_get_sound(notification_h noti,
1025                                                        notification_sound_type_e *type,
1026                                                        const char **path)
1027 {
1028         /* check noti and type is valid data */
1029         if (noti == NULL || type == NULL)
1030                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1031
1032         /* Set sound type */
1033         *type = noti->sound_type;
1034
1035         /* Set sound path if user data type */
1036         if (noti->sound_type == NOTIFICATION_SOUND_TYPE_USER_DATA
1037             && path != NULL)
1038                 *path = noti->sound_path;
1039
1040         return NOTIFICATION_ERROR_NONE;
1041 }
1042
1043 EXPORT_API int notification_set_vibration(notification_h noti,
1044                                                            notification_vibration_type_e type,
1045                                                            const char *path)
1046 {
1047         /* Check noti is valid data */
1048         if (noti == NULL)
1049                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1050
1051         /* Check type is valid */
1052         if (type < NOTIFICATION_VIBRATION_TYPE_NONE
1053             || type >= NOTIFICATION_VIBRATION_TYPE_MAX)
1054                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1055
1056         /* Save vibration type */
1057         noti->vibration_type = type;
1058
1059         /* Save sound path if user data type */
1060         if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA && path != NULL) {
1061                 if (noti->vibration_path != NULL)
1062                         free(noti->vibration_path);
1063
1064                 noti->vibration_path = strdup(path);
1065         } else {
1066                 if (noti->vibration_path != NULL) {
1067                         free(noti->vibration_path);
1068                         noti->vibration_path = NULL;
1069                 }
1070                 if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA) {
1071                         noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_DEFAULT;
1072                         return NOTIFICATION_ERROR_INVALID_PARAMETER;
1073                 }
1074         }
1075
1076         return NOTIFICATION_ERROR_NONE;
1077
1078 }
1079
1080 EXPORT_API int notification_get_vibration(notification_h noti,
1081                                                            notification_vibration_type_e *type,
1082                                                            const char **path)
1083 {
1084         /* check noti and type is valid data */
1085         if (noti == NULL || type == NULL)
1086                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1087
1088         /* Set vibration type */
1089         *type = noti->vibration_type;
1090
1091         /* Set sound path if user data type */
1092         if (noti->vibration_type == NOTIFICATION_VIBRATION_TYPE_USER_DATA
1093             && path != NULL)
1094                 *path = noti->vibration_path;
1095
1096         return NOTIFICATION_ERROR_NONE;
1097 }
1098
1099 EXPORT_API int notification_set_led(notification_h noti,
1100                                                            notification_led_op_e operation,
1101                                                            int led_argb)
1102 {
1103         /* Check noti is valid data */
1104         if (noti == NULL)
1105                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1106
1107         /* Check operation is valid */
1108         if (operation < NOTIFICATION_LED_OP_OFF
1109             || operation >= NOTIFICATION_LED_OP_MAX)
1110                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1111
1112         /* Save led operation */
1113         noti->led_operation = operation;
1114
1115         /* Save led argb if operation is turning on LED with custom color */
1116         if (operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR)
1117                 noti->led_argb = led_argb;
1118
1119         return NOTIFICATION_ERROR_NONE;
1120 }
1121
1122 EXPORT_API int notification_get_led(notification_h noti,
1123                                                            notification_led_op_e *operation,
1124                                                            int *led_argb)
1125 {
1126         /* check noti and operation is valid data */
1127         if (noti == NULL || operation == NULL)
1128                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1129
1130         /* Set led operation */
1131         *operation = noti->led_operation;
1132
1133         /* Save led argb if operation is turning on LED with custom color */
1134         if (noti->led_operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR
1135             && led_argb != NULL)
1136                 *led_argb = noti->led_argb;
1137
1138         return NOTIFICATION_ERROR_NONE;
1139 }
1140
1141 EXPORT_API int notification_set_led_time_period(notification_h noti,
1142                                                                         int on_ms, int off_ms)
1143 {
1144         /* Check noti is valid data */
1145         if (noti == NULL || on_ms < 0 || off_ms < 0)
1146                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1147
1148         /* Save led operation */
1149         noti->led_on_ms = on_ms;
1150         noti->led_off_ms = off_ms;
1151
1152         return NOTIFICATION_ERROR_NONE;
1153 }
1154
1155 EXPORT_API int notification_get_led_time_period(notification_h noti,
1156                                                                         int *on_ms, int *off_ms)
1157 {
1158         /* check noti and operation is valid data */
1159         if (noti == NULL)
1160                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1161
1162         if (on_ms)
1163                 *(on_ms) = noti->led_on_ms;
1164         if (off_ms)
1165                 *(off_ms) = noti->led_off_ms;
1166
1167         return NOTIFICATION_ERROR_NONE;
1168 }
1169
1170 EXPORT_API int notification_set_launch_option(notification_h noti,
1171                                                                 notification_launch_option_type type, void *option)
1172 {
1173         int err = NOTIFICATION_ERROR_NONE;
1174         int ret = 0;
1175         bundle *b = NULL;
1176         app_control_h app_control = option;
1177
1178         if (noti == NULL || app_control == NULL || type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL) {
1179                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1180                 goto out;
1181         }
1182
1183         if ((ret = app_control_export_as_bundle(app_control, &b)) != APP_CONTROL_ERROR_NONE) {
1184                 NOTIFICATION_ERR("Failed to convert appcontrol to bundle:%d", ret);
1185                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1186                 goto out;
1187         }
1188
1189         err = notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, b);
1190
1191 out:
1192         if (b)
1193                 bundle_free(b);
1194
1195         return err;
1196 }
1197
1198 EXPORT_API int notification_get_launch_option(notification_h noti,
1199                                                                 notification_launch_option_type type, void *option)
1200 {
1201         int ret = 0;
1202         bundle *b = NULL;
1203         app_control_h *app_control = (app_control_h *)option;
1204         app_control_h app_control_new = NULL;
1205
1206         if (noti == NULL)
1207                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1208
1209         if (app_control == NULL)
1210                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1211
1212         if (type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL)
1213                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1214
1215
1216         ret = notification_get_execute_option(noti,
1217                                 NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
1218                                 NULL,
1219                                 &b);
1220         if (ret == NOTIFICATION_ERROR_NONE && b != NULL) {
1221                 ret = app_control_create(&app_control_new);
1222                 if (ret == APP_CONTROL_ERROR_NONE && app_control_new != NULL) {
1223                         ret = app_control_import_from_bundle(app_control_new, b);
1224                         if (ret == APP_CONTROL_ERROR_NONE) {
1225                                 *app_control = app_control_new;
1226                         } else {
1227                                 app_control_destroy(app_control_new);
1228                                 NOTIFICATION_ERR("Failed to import app control from bundle:%d", ret);
1229                                 return NOTIFICATION_ERROR_IO_ERROR;
1230                         }
1231                 } else {
1232                         NOTIFICATION_ERR("Failed to create app control:%d", ret);
1233                         return NOTIFICATION_ERROR_IO_ERROR;
1234                 }
1235         } else {
1236                 NOTIFICATION_ERR("Failed to get execute option:%d", ret);
1237                 return ret;
1238         }
1239
1240         return NOTIFICATION_ERROR_NONE;
1241 }
1242
1243 EXPORT_API int notification_set_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h event_handler)
1244 {
1245         int err = NOTIFICATION_ERROR_NONE;
1246         bundle *app_control_bundle = NULL;
1247
1248         if (noti == NULL) {
1249                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1250                 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1251                 goto out;
1252         }
1253
1254         if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
1255                 || event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
1256                 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1257                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1258                 goto out;
1259         }
1260
1261         if ((err = app_control_export_as_bundle(event_handler, &app_control_bundle)) != APP_CONTROL_ERROR_NONE) {
1262                 NOTIFICATION_ERR("app_control_to_bundle failed [%d]", err);
1263                 goto out;
1264         }
1265
1266         if (noti->b_event_handler[event_type] != NULL)
1267                 bundle_free(noti->b_event_handler[event_type]);
1268
1269         noti->b_event_handler[event_type] = app_control_bundle;
1270
1271 out:
1272         return err;
1273 }
1274
1275 EXPORT_API int notification_get_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h *event_handler)
1276 {
1277         int err = NOTIFICATION_ERROR_NONE;
1278         bundle *b = NULL;
1279         app_control_h app_control_new = NULL;
1280
1281         if (noti == NULL) {
1282                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1283                 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1284                 goto out;
1285         }
1286         if (event_handler == NULL) {
1287                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1288                 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1289                 goto out;
1290         }
1291         if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
1292                 || event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
1293                 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
1294                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
1295                 goto out;
1296         }
1297
1298         b = noti->b_event_handler[event_type];
1299
1300         if (b == NULL) {
1301                 NOTIFICATION_DBG("No event handler\n");
1302                 err = NOTIFICATION_ERROR_NOT_EXIST_ID;
1303                 goto out;
1304         }
1305
1306         err = app_control_create(&app_control_new);
1307         if (err != APP_CONTROL_ERROR_NONE || app_control_new == NULL) {
1308                 NOTIFICATION_ERR("app_control_create failed [%d]", err);
1309                 err = NOTIFICATION_ERROR_IO_ERROR;
1310                 goto out;
1311         }
1312
1313         err = app_control_import_from_bundle(app_control_new, b);
1314         if (err == APP_CONTROL_ERROR_NONE) {
1315                 *event_handler = app_control_new;
1316         } else {
1317                 app_control_destroy(app_control_new);
1318                 app_control_new = NULL;
1319                 NOTIFICATION_ERR("Failed to import app control from bundle [%d]", err);
1320                 err = NOTIFICATION_ERROR_IO_ERROR;
1321                 goto out;
1322         }
1323
1324 out:
1325         if (event_handler)
1326                 *event_handler = app_control_new;
1327
1328         return err;
1329 }
1330
1331
1332
1333
1334
1335 EXPORT_API int notification_set_property(notification_h noti,
1336                                                           int flags)
1337 {
1338         /* Check noti is valid data */
1339         if (noti == NULL)
1340                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1341
1342         /* Set flags */
1343         noti->flags_for_property = flags;
1344
1345         return NOTIFICATION_ERROR_NONE;
1346 }
1347
1348 EXPORT_API int notification_get_property(notification_h noti,
1349                                                           int *flags)
1350 {
1351         /* Check noti and flags are valid data */
1352         if (noti == NULL || flags == NULL)
1353                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1354
1355         /* Set flags */
1356         *flags = noti->flags_for_property;
1357
1358         return NOTIFICATION_ERROR_NONE;
1359 }
1360
1361 EXPORT_API int notification_set_display_applist(notification_h noti,
1362                                                                  int applist)
1363 {
1364         /* Check noti is valid data */
1365         if (noti == NULL)
1366                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1367
1368
1369         /* Set app list */
1370         if (applist == 0xffffffff) /* 0xffffffff means old NOTIFICATION_DISPLAY_APP_ALL */
1371                 applist = NOTIFICATION_DISPLAY_APP_ALL;
1372
1373         noti->display_applist = applist;
1374
1375         return NOTIFICATION_ERROR_NONE;
1376 }
1377
1378 EXPORT_API int notification_get_display_applist(notification_h noti,
1379                                                                  int *applist)
1380 {
1381         /* Check noti and applist are valid data */
1382         if (noti == NULL || applist == NULL)
1383                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1384
1385         /* Set app list */
1386         *applist = noti->display_applist;
1387
1388         return NOTIFICATION_ERROR_NONE;
1389 }
1390
1391 EXPORT_API int notification_set_size(notification_h noti,
1392                                                       double size)
1393 {
1394         /* Check noti is valid data */
1395         if (noti == NULL)
1396                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1397
1398         /* Save progress size */
1399         noti->progress_size = size;
1400
1401         return NOTIFICATION_ERROR_NONE;
1402 }
1403
1404 EXPORT_API int notification_get_size(notification_h noti,
1405                                                       double *size)
1406 {
1407         /* Check noti and size is valid data */
1408         if (noti == NULL || size == NULL)
1409                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1410
1411         /* Set progress size */
1412         *size = noti->progress_size;
1413
1414         return NOTIFICATION_ERROR_NONE;
1415 }
1416
1417 EXPORT_API int notification_set_progress(notification_h noti,
1418                                                           double percentage)
1419 {
1420         /* Check noti is valid data */
1421         if (noti == NULL)
1422                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1423
1424         /* Save progress percentage */
1425         noti->progress_percentage = percentage;
1426
1427         return NOTIFICATION_ERROR_NONE;
1428 }
1429
1430 EXPORT_API int notification_get_progress(notification_h noti,
1431                                                           double *percentage)
1432 {
1433         /* Check noti and percentage are valid data */
1434         if (noti == NULL || percentage == NULL)
1435                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1436
1437         /* Set progress percentage */
1438         *percentage = noti->progress_percentage;
1439
1440         return NOTIFICATION_ERROR_NONE;
1441 }
1442
1443 EXPORT_API int notification_get_pkgname(notification_h noti,
1444                                                          char **pkgname)
1445 {
1446         /* Check noti and pkgname are valid data */
1447         if (noti == NULL || pkgname == NULL)
1448                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1449
1450         /* Get caller pkgname */
1451         if (noti->caller_pkgname)
1452                 *pkgname = noti->caller_pkgname;
1453         else
1454                 *pkgname = NULL;
1455
1456         return NOTIFICATION_ERROR_NONE;
1457 }
1458
1459 EXPORT_API int notification_set_layout(notification_h noti,
1460                 notification_ly_type_e layout)
1461 {
1462         /* check noti and pkgname are valid data */
1463         if (noti == NULL || (layout < NOTIFICATION_LY_NONE || layout >= NOTIFICATION_LY_MAX))
1464                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1465
1466         noti->layout = layout;
1467
1468         return NOTIFICATION_ERROR_NONE;
1469 }
1470
1471 EXPORT_API int notification_get_layout(notification_h noti,
1472                 notification_ly_type_e *layout)
1473 {
1474         /* Check noti and pkgname are valid data */
1475         if (noti == NULL || layout == NULL)
1476                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1477
1478         *layout = noti->layout;
1479
1480         return NOTIFICATION_ERROR_NONE;
1481 }
1482
1483
1484
1485 EXPORT_API int notification_get_type(notification_h noti,
1486                                                       notification_type_e *type)
1487 {
1488         /* Check noti and type is valid data */
1489         if (noti == NULL || type == NULL)
1490                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1491
1492         /* Set noti type */
1493         *type = noti->type;
1494
1495         return NOTIFICATION_ERROR_NONE;
1496 }
1497
1498 EXPORT_API int notification_post(notification_h noti)
1499 {
1500         int ret = 0;
1501         int id = 0;
1502
1503         /* Check noti is vaild data */
1504         if (noti == NULL)
1505                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1506
1507         /* Check noti type is valid type */
1508         if (noti->type <= NOTIFICATION_TYPE_NONE
1509             || noti->type >= NOTIFICATION_TYPE_MAX)
1510                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1511
1512         /* Save insert time */
1513         noti->insert_time = time(NULL);
1514
1515         ret = notification_ipc_request_insert(noti, &id);
1516         if (ret != NOTIFICATION_ERROR_NONE)
1517                 return ret;
1518
1519         noti->priv_id = id;
1520         NOTIFICATION_DBG("from master:%d", id);
1521
1522         return NOTIFICATION_ERROR_NONE;
1523 }
1524
1525
1526
1527 EXPORT_API int notification_update(notification_h noti)
1528 {
1529         int ret = 0;
1530
1531         /* Check noti is valid data */
1532         if (noti != NULL) {
1533                 /* Update insert time ? */
1534                 noti->insert_time = time(NULL);
1535                 ret = notification_ipc_request_update(noti);
1536         } else {
1537                 notification_ipc_request_refresh();
1538                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1539         }
1540         return ret;
1541 }
1542
1543 EXPORT_API int notification_delete_all(notification_type_e type)
1544 {
1545         int ret = 0;
1546         char *caller_pkgname = NULL;
1547
1548         if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX)
1549                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1550
1551         caller_pkgname = notification_get_pkgname_by_pid();
1552
1553         ret = notification_ipc_request_delete_multiple(type, caller_pkgname);
1554
1555         if (caller_pkgname)
1556                 free(caller_pkgname);
1557
1558         return ret;
1559 }
1560
1561 EXPORT_API int notification_delete(notification_h noti)
1562 {
1563         int ret = 0;
1564
1565         if (noti == NULL)
1566                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1567
1568         ret = notification_ipc_request_delete_single(NOTIFICATION_TYPE_NONE, noti->caller_pkgname, noti->priv_id);
1569
1570         return ret;
1571 }
1572
1573 static notification_h _notification_create(notification_type_e type)
1574 {
1575         notification_h noti = NULL;
1576         package_info_h package_info = NULL;
1577         char *app_id = NULL;
1578         char *domain_name = NULL;
1579         char *app_root_path = NULL;
1580         char locale_directory[PATH_MAX] = { 0, }; /* PATH_MAX 4096 */
1581         int err_app_manager = APP_MANAGER_ERROR_NONE;
1582
1583         if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
1584                 NOTIFICATION_ERR("INVALID TYPE : %d", type);
1585                 set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
1586                 return NULL;
1587         }
1588
1589         noti = (notification_h) calloc(1, sizeof(struct _notification));
1590         if (noti == NULL) {
1591                 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
1592                 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
1593                 return NULL;
1594         }
1595
1596         noti->type = type;
1597
1598         if (type == NOTIFICATION_TYPE_NOTI)
1599                 noti->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
1600         else if (type == NOTIFICATION_TYPE_ONGOING)
1601                 noti->layout = NOTIFICATION_LY_ONGOING_PROGRESS;
1602
1603         noti->caller_pkgname = notification_get_pkgname_by_pid();
1604         noti->group_id = NOTIFICATION_GROUP_ID_NONE;
1605         noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
1606         noti->sound_type = NOTIFICATION_SOUND_TYPE_NONE;
1607         noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_NONE;
1608         noti->led_operation = NOTIFICATION_LED_OP_OFF;
1609         noti->display_applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_TICKER | NOTIFICATION_DISPLAY_APP_INDICATOR;
1610         noti->auto_remove = true;
1611
1612         err_app_manager = app_manager_get_app_id(getpid(), &app_id);
1613         if (err_app_manager != APP_MANAGER_ERROR_NONE || app_id == NULL) {
1614                 NOTIFICATION_WARN("app_manager_get_app_id failed err[%d] app_id[%p]", err_app_manager, app_id);
1615                 goto out;
1616         }
1617
1618         /* app name is used as domain name */
1619         /* domain_name is allocated by app_get_package_app_name */
1620         err_app_manager = app_get_package_app_name(app_id, &domain_name);
1621
1622         if (err_app_manager != APP_ERROR_NONE || domain_name == NULL) {
1623                 NOTIFICATION_WARN("app_get_package_app_name failed err[%d] domain_name[%p]", err_app_manager, domain_name);
1624                 goto out;
1625         }
1626
1627         err_app_manager = package_info_create(noti->caller_pkgname, &package_info);
1628
1629         if (err_app_manager != PACKAGE_MANAGER_ERROR_NONE || package_info == NULL) {
1630                 NOTIFICATION_WARN("package_info_create failed err[%d] package_info[%p] caller_pkgname[%s]",
1631                                 err_app_manager, package_info, noti->caller_pkgname);
1632                 goto out;
1633         }
1634
1635         err_app_manager = package_info_get_root_path(package_info, &app_root_path);
1636
1637         if (err_app_manager != PACKAGE_MANAGER_ERROR_NONE || app_root_path == NULL) {
1638                 NOTIFICATION_WARN("package_info_get_root_path failed err[%d] app_root_path[%p]", err_app_manager, app_root_path);
1639                 goto out;
1640         }
1641
1642         snprintf(locale_directory, PATH_MAX, "%s/res/locale", app_root_path);
1643
1644         noti->domain = strdup(domain_name);
1645         noti->dir    = strdup(locale_directory);
1646
1647 out:
1648         if (domain_name)
1649                 free(domain_name);
1650
1651         if (app_id)
1652                 free(app_id);
1653
1654         if (app_root_path)
1655                 free(app_root_path);
1656
1657         if (package_info)
1658                 package_info_destroy(package_info);
1659
1660         /*!
1661          * \NOTE
1662          * Other fields are already initialized with ZERO.
1663          */
1664         set_last_result(NOTIFICATION_ERROR_NONE);
1665         return noti;
1666 }
1667
1668 EXPORT_API notification_h notification_create(notification_type_e type)
1669 {
1670         return _notification_create(type);
1671 }
1672
1673 EXPORT_API notification_h  notification_load_by_tag(const char *tag)
1674 {
1675         int ret = 0;
1676         notification_h noti = NULL;
1677         char *caller_pkgname = NULL;
1678
1679         if (tag == NULL) {
1680                 NOTIFICATION_ERR("Invalid parameter");
1681                 set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
1682                 return NULL;
1683         }
1684
1685         caller_pkgname = notification_get_pkgname_by_pid();
1686         if (!caller_pkgname) {
1687                 NOTIFICATION_ERR("Failed to get a package name");
1688                 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
1689                 return NULL;
1690         }
1691
1692         noti = (notification_h) calloc(1, sizeof(struct _notification));
1693         if (noti == NULL) {
1694                 NOTIFICATION_ERR("Failed to alloc a new notification");
1695                 set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
1696                 free(caller_pkgname);
1697
1698                 return NULL;
1699         }
1700
1701         ret = notification_noti_get_by_tag(noti, caller_pkgname, (char*)tag);
1702
1703         free(caller_pkgname);
1704
1705         set_last_result(ret);
1706
1707         if (ret != NOTIFICATION_ERROR_NONE) {
1708                 notification_free(noti);
1709                 return NULL;
1710         }
1711
1712         return noti;
1713 }
1714
1715 EXPORT_API int notification_clone(notification_h noti, notification_h *clone)
1716 {
1717         int i = 0;
1718         notification_h new_noti = NULL;
1719
1720         if (noti == NULL || clone == NULL) {
1721                 NOTIFICATION_ERR("INVALID PARAMETER.");
1722                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1723         }
1724
1725         new_noti = (notification_h) calloc(1, sizeof(struct _notification));
1726         if (new_noti == NULL) {
1727                 NOTIFICATION_ERR("NO MEMORY : noti == NULL");
1728                 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
1729         }
1730
1731         new_noti->type = noti->type;
1732         new_noti->layout = noti->layout;
1733
1734         new_noti->group_id = noti->group_id;
1735         new_noti->internal_group_id = noti->internal_group_id;
1736         new_noti->priv_id = noti->priv_id;
1737
1738         if (noti->caller_pkgname != NULL)
1739                 new_noti->caller_pkgname = strdup(noti->caller_pkgname);
1740         else
1741                 new_noti->caller_pkgname = notification_get_pkgname_by_pid();
1742
1743         if (noti->launch_pkgname != NULL)
1744                 new_noti->launch_pkgname = strdup(noti->launch_pkgname);
1745         else
1746                 new_noti->launch_pkgname = NULL;
1747
1748         if (noti->args != NULL)
1749                 new_noti->args = bundle_dup(noti->args);
1750         else
1751                 new_noti->args = NULL;
1752
1753         if (noti->group_args != NULL)
1754                 new_noti->group_args = bundle_dup(noti->group_args);
1755         else
1756                 new_noti->group_args = NULL;
1757
1758         if (noti->b_execute_option != NULL)
1759                 new_noti->b_execute_option = bundle_dup(noti->b_execute_option);
1760         else
1761                 new_noti->b_execute_option = NULL;
1762
1763         if (noti->b_service_responding != NULL)
1764                 new_noti->b_service_responding = bundle_dup(noti->b_service_responding);
1765         else
1766                 new_noti->b_service_responding = NULL;
1767
1768         if (noti->b_service_single_launch != NULL)
1769                 new_noti->b_service_single_launch = bundle_dup(noti->b_service_single_launch);
1770         else
1771                 new_noti->b_service_single_launch = NULL;
1772
1773         if (noti->b_service_multi_launch != NULL)
1774                 new_noti->b_service_multi_launch = bundle_dup(noti->b_service_multi_launch);
1775         else
1776                 new_noti->b_service_multi_launch = NULL;
1777
1778         for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
1779                 if (noti->b_event_handler[i] != NULL)
1780                         new_noti->b_event_handler[i] = bundle_dup(noti->b_event_handler[i]);
1781                 else
1782                         new_noti->b_event_handler[i] = NULL;
1783         }
1784
1785         new_noti->sound_type = noti->sound_type;
1786         if (noti->sound_path != NULL)
1787                 new_noti->sound_path = strdup(noti->sound_path);
1788         else
1789                 new_noti->sound_path = NULL;
1790
1791         new_noti->vibration_type = noti->vibration_type;
1792         if (noti->vibration_path != NULL)
1793                 new_noti->vibration_path = strdup(noti->vibration_path);
1794         else
1795                 new_noti->vibration_path = NULL;
1796
1797         new_noti->led_operation = noti->led_operation;
1798         new_noti->led_argb = noti->led_argb;
1799         new_noti->led_on_ms = noti->led_on_ms;
1800         new_noti->led_off_ms = noti->led_off_ms;
1801
1802         if (noti->domain != NULL)
1803                 new_noti->domain = strdup(noti->domain);
1804         else
1805                 new_noti->domain = NULL;
1806
1807         if (noti->dir != NULL)
1808                 new_noti->dir = strdup(noti->dir);
1809         else
1810                 new_noti->dir = NULL;
1811
1812         if (noti->b_text != NULL)
1813                 new_noti->b_text = bundle_dup(noti->b_text);
1814         else
1815                 new_noti->b_text = NULL;
1816
1817         if (noti->b_key != NULL)
1818                 new_noti->b_key = bundle_dup(noti->b_key);
1819         else
1820                 new_noti->b_key = NULL;
1821
1822         if (noti->b_format_args != NULL)
1823                 new_noti->b_format_args = bundle_dup(noti->b_format_args);
1824         else
1825                 new_noti->b_format_args = NULL;
1826
1827         new_noti->num_format_args = noti->num_format_args;
1828
1829         if (noti->b_image_path != NULL)
1830                 new_noti->b_image_path = bundle_dup(noti->b_image_path);
1831         else
1832                 new_noti->b_image_path = NULL;
1833
1834         new_noti->time = noti->time;
1835         new_noti->insert_time = noti->insert_time;
1836
1837         new_noti->flags_for_property = noti->flags_for_property;
1838         new_noti->display_applist = noti->display_applist;
1839
1840         new_noti->progress_size = noti->progress_size;
1841         new_noti->progress_percentage = noti->progress_percentage;
1842
1843         new_noti->ongoing_flag = noti->ongoing_flag;
1844         new_noti->auto_remove = noti->auto_remove;
1845
1846         new_noti->app_icon_path = NULL;
1847         new_noti->app_name = NULL;
1848         new_noti->temp_title = NULL;
1849         new_noti->temp_content = NULL;
1850
1851         *clone = new_noti;
1852
1853         return NOTIFICATION_ERROR_NONE;
1854 }
1855
1856
1857 EXPORT_API int notification_free(notification_h noti)
1858 {
1859         int i = 0;
1860         if (noti == NULL)
1861                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1862
1863         if (noti->caller_pkgname)
1864                 free(noti->caller_pkgname);
1865
1866         if (noti->launch_pkgname)
1867                 free(noti->launch_pkgname);
1868
1869         if (noti->args)
1870                 bundle_free(noti->args);
1871
1872         if (noti->group_args)
1873                 bundle_free(noti->group_args);
1874
1875         if (noti->b_execute_option)
1876                 bundle_free(noti->b_execute_option);
1877
1878         if (noti->b_service_responding)
1879                 bundle_free(noti->b_service_responding);
1880
1881         if (noti->b_service_single_launch)
1882                 bundle_free(noti->b_service_single_launch);
1883
1884         if (noti->b_service_multi_launch)
1885                 bundle_free(noti->b_service_multi_launch);
1886
1887         for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
1888                 if (noti->b_event_handler[i] != NULL)
1889                         bundle_free(noti->b_event_handler[i]);
1890         }
1891
1892         if (noti->sound_path)
1893                 free(noti->sound_path);
1894
1895         if (noti->vibration_path)
1896                 free(noti->vibration_path);
1897
1898         if (noti->domain)
1899                 free(noti->domain);
1900
1901         if (noti->dir)
1902                 free(noti->dir);
1903
1904         if (noti->b_text)
1905                 bundle_free(noti->b_text);
1906
1907         if (noti->b_key)
1908                 bundle_free(noti->b_key);
1909
1910         if (noti->b_format_args)
1911                 bundle_free(noti->b_format_args);
1912
1913         if (noti->b_image_path)
1914                 bundle_free(noti->b_image_path);
1915
1916         if (noti->app_icon_path)
1917                 free(noti->app_icon_path);
1918
1919         if (noti->app_name)
1920                 free(noti->app_name);
1921
1922         if (noti->temp_title)
1923                 free(noti->temp_title);
1924
1925         if (noti->temp_content)
1926                 free(noti->temp_content);
1927
1928         if (noti->tag)
1929                 free(noti->tag);
1930
1931         free(noti);
1932
1933         return NOTIFICATION_ERROR_NONE;
1934 }
1935
1936 EXPORT_API int notification_set_tag(notification_h noti, const char *tag)
1937 {
1938         /* Check noti is valid data */
1939         if (noti == NULL)
1940                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1941
1942         if (tag != NULL) {
1943                 /* save input TAG */
1944                 if (noti->tag != NULL)
1945                         free(noti->tag);
1946
1947                 noti->tag = strdup(tag);
1948         }
1949
1950         return NOTIFICATION_ERROR_NONE;
1951
1952 }
1953
1954 EXPORT_API int notification_get_tag(notification_h noti, const char **tag)
1955 {
1956         /* Check noti is valid data */
1957         if (noti == NULL)
1958                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1959
1960         *tag = noti->tag;
1961         return NOTIFICATION_ERROR_NONE;
1962 }
1963
1964 void notification_call_posted_toast_cb(const char *message)
1965 {
1966         if (posted_toast_message_cb != NULL)
1967                 posted_toast_message_cb((void*)message);
1968 }
1969
1970 EXPORT_API int notification_set_ongoing_flag(notification_h noti, bool ongoing_flag)
1971 {
1972         if (noti == NULL)
1973                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1974
1975         noti->ongoing_flag = ongoing_flag;
1976
1977         return NOTIFICATION_ERROR_NONE;
1978 }
1979
1980 EXPORT_API int notification_get_ongoing_flag(notification_h noti, bool *ongoing_flag)
1981 {
1982         if (noti == NULL || ongoing_flag == NULL)
1983                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1984
1985         *ongoing_flag = noti->ongoing_flag;
1986
1987         return NOTIFICATION_ERROR_NONE;
1988 }
1989
1990
1991 EXPORT_API int notification_add_button(notification_h noti, notification_button_index_e button_index)
1992 {
1993         if (noti == NULL || button_index < NOTIFICATION_BUTTON_1 || button_index > NOTIFICATION_BUTTON_6)
1994                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1995
1996         return NOTIFICATION_ERROR_NONE;
1997 }
1998
1999 EXPORT_API int notification_remove_button(notification_h noti, notification_button_index_e button_index)
2000 {
2001         if (noti == NULL || button_index < NOTIFICATION_BUTTON_1 || button_index > NOTIFICATION_BUTTON_6)
2002                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2003
2004         if (noti->b_event_handler[button_index - 1]) {
2005                 bundle_free(noti->b_event_handler[button_index - 1]);
2006                 noti->b_event_handler[button_index - 1] = NULL;
2007         }
2008
2009         return NOTIFICATION_ERROR_NONE;
2010 }
2011
2012 EXPORT_API int notification_set_auto_remove(notification_h noti, bool auto_remove)
2013 {
2014         if (noti == NULL)
2015                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2016
2017         noti->auto_remove = auto_remove;
2018
2019         return NOTIFICATION_ERROR_NONE;
2020 }
2021
2022 EXPORT_API int notification_get_auto_remove(notification_h noti, bool *auto_remove)
2023 {
2024         if (noti == NULL || auto_remove == NULL)
2025                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
2026
2027         *auto_remove = noti->auto_remove;
2028
2029         return NOTIFICATION_ERROR_NONE;
2030 }