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

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <libintl.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib-lowlevel.h>

#include <app.h>
#include <app_internal.h>
#include <app_manager.h>
#include <app_control_internal.h>
#include <package_manager.h>
#include <aul.h>
#include <ail.h>
#include <appsvc.h>
#include <tizen.h>
#include <vconf-keys.h>
#include <vconf.h>

#include <notification.h>
#include <notification_list.h>
#include <notification_debug.h>
#include <notification_private.h>
#include <notification_noti.h>
#include <notification_ongoing.h>
#include <notification_group.h>
#include <notification_ipc.h>
#include <notification_internal.h>

static void (*posted_toast_message_cb) (void *data);

#define NOTI_TEXT_RESULT_LEN 2048
#define NOTI_PKGNAME_LEN	512

char *notification_get_pkgname_by_pid(void)
{
	char pkgname[NOTI_PKGNAME_LEN + 1] = { 0, };
	int pid = 0, ret = AUL_R_OK;
	int fd;
	char  *dup_pkgname;
	char buf[NOTI_PKGNAME_LEN + 1] = { 0, };

	pid = getpid();

	ret = aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname));
	if (ret != AUL_R_OK) {

		snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);

		fd = open(buf, O_RDONLY);
		if (fd < 0)
			return NULL;

		ret = read(fd, pkgname, sizeof(pkgname) - 1);
		close(fd);

		if (ret <= 0)
			return NULL;

		pkgname[ret] = '\0';
		/*!
		 * \NOTE
		 * "ret" is not able to be larger than "sizeof(pkgname) - 1",
		 * if the system is not going wrong.
		 */
	} else {
		if (strlen(pkgname) <= 0)
			return NULL;
	}

	dup_pkgname = strdup(pkgname);
	if (!dup_pkgname)
		NOTIFICATION_ERR("Heap: %d\n", errno);

	return dup_pkgname;
}

EXPORT_API int notification_set_image(notification_h noti,
						       notification_image_type_e type,
						       const char *image_path)
{
	bundle *b = NULL;
	char buf_key[32] = { 0, };
	char *ret_val = NULL;

	/* Check noti and image_path are valid data */
	if (noti == NULL || image_path == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Check image type is valid type */
	if (type <= NOTIFICATION_IMAGE_TYPE_NONE
	    || type >= NOTIFICATION_IMAGE_TYPE_MAX)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Check image path bundle is exist */
	if (noti->b_image_path) {
		/* If image path bundle is exist, store local bundle value */
		b = noti->b_image_path;

		/* Set image type to key as char string type */
		snprintf(buf_key, sizeof(buf_key), "%d", type);

		/* Get value using key */
		bundle_get_str(b, buf_key, &ret_val);
		if (ret_val != NULL)
			/* If key is exist, remove this value to store new image path */
			bundle_del(b, buf_key);

		/* Add new image path with type key */
		bundle_add_str(b, buf_key, image_path);
	} else {
		/* If image path bundle is not exist, create new one */
		b = bundle_create();

		/* Set image type to key as char string type */
		snprintf(buf_key, sizeof(buf_key), "%d", type);

		/* Add new image path with type key */
		bundle_add_str(b, buf_key, image_path);

		/* Save to image path bundle */
		noti->b_image_path = b;
	}

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_get_image(notification_h noti,
						       notification_image_type_e type,
						       char **image_path)
{
	bundle *b = NULL;
	char buf_key[32] = { 0, };
	char *ret_val = NULL;

	/* Check noti and image_path is valid data */
	if (noti == NULL || image_path == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Check image type is valid data */
	if (type <= NOTIFICATION_IMAGE_TYPE_NONE
	    || type >= NOTIFICATION_IMAGE_TYPE_MAX)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Check image path bundle exist */
	if (noti->b_image_path) {
		/* If image path bundle exist, store local bundle data */
		b = noti->b_image_path;

		/* Set image type to key as char string type */
		snprintf(buf_key, sizeof(buf_key), "%d", type);

		/* Get value of key */
		bundle_get_str(b, buf_key, &ret_val);

		*image_path = ret_val;
	} else {
		/* If image path bundle does not exist, image path is NULL */
		*image_path = NULL;
	}

	/* If image path is NULL and type is ICON, icon path set from AIL */
	/* order : user icon -> launch_pkgname icon -> caller_pkgname icon -> service app icon */
	if (*image_path == NULL && type == NOTIFICATION_IMAGE_TYPE_ICON) {
		/* Check App icon path is already set */
		if (noti->app_icon_path != NULL)
			/* image path will be app icon path */
			*image_path = noti->app_icon_path;
		else
			*image_path = NULL;
	}

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_set_time(notification_h noti,
						      time_t input_time)
{
	/* Check noti is valid data */
	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	if (input_time == 0)
		/* If input time is 0, set current time */
		noti->time = time(NULL);
	else
		/* save input time */
		noti->time = input_time;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_get_time(notification_h noti,
						      time_t * ret_time)
{
	/* Check noti and time is valid data */
	if (noti == NULL || ret_time == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Set time infomation */
	*ret_time = noti->time;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_get_insert_time(notification_h noti,
							     time_t * ret_time)
{
	/* Check noti and ret_time is valid data */
	if (noti == NULL || ret_time == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Set insert time information */
	*ret_time = noti->insert_time;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_set_text(notification_h noti,
						      notification_text_type_e type,
						      const char *text,
						      const char *key,
						      int args_type, ...)
{
	bundle *b = NULL;
	char buf_key[32] = { 0, };
	char buf_val[1024] = { 0, };
	char *ret_val = NULL;
	va_list var_args;
	notification_variable_type_e var_type;
	int num_args = 0;
	int noti_err = NOTIFICATION_ERROR_NONE;
	int var_value_int = 0;
	double var_value_double = 0.0;
	char *var_value_string = NULL;
	notification_count_pos_type_e var_value_count =
	    NOTIFICATION_COUNT_POS_NONE;

	/* Check noti is valid data */
	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Check text type is valid type */
	if (type <= NOTIFICATION_TEXT_TYPE_NONE
	    || type >= NOTIFICATION_TEXT_TYPE_MAX)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Check text bundle exist */
	if (text != NULL) {
		if (noti->b_text != NULL) {
			/* If text bundle exist, store local bundle data */
			b = noti->b_text;

			/* Make type to key as char string */
			snprintf(buf_key, sizeof(buf_key), "%d", type);

			/* Get value using type key */
			bundle_get_str(b, buf_key, &ret_val);

			if (ret_val != NULL)
				/* If value exist, remove this to add new value */
				bundle_del(b, buf_key);

			snprintf(buf_val, sizeof(buf_val), "%s", text);

			/* Add new text value */
			bundle_add_str(b, buf_key, buf_val);
		} else {
			/* If text bundle does not exist, create new one */
			b = bundle_create();

			/* Make type to key as char string */
			snprintf(buf_key, sizeof(buf_key), "%d", type);

			snprintf(buf_val, sizeof(buf_val), "%s", text);

			/* Add new text value */
			bundle_add_str(b, buf_key, buf_val);

			/* Save text bundle */
			noti->b_text = b;
		}
	} else {
		/* Reset if text is NULL */
		if (noti->b_text != NULL) {
			/* If text bundle exist, store local bundle data */
			b = noti->b_text;

			/* Make type to key as char string */
			snprintf(buf_key, sizeof(buf_key), "%d", type);

			/* Get value using type key */
			bundle_get_str(b, buf_key, &ret_val);
			if (ret_val != NULL)
				/* If value exist, remove this */
				bundle_del(b, buf_key);
		}
	}

	/* Save key if key is valid data */
	if (key != NULL) {
		/* Check key bundle exist */
		if (noti->b_key != NULL) {
			/* If key bundle exist,  store local bundle data */
			b = noti->b_key;

			/* Make type to key as char string */
			snprintf(buf_key, sizeof(buf_key), "%d", type);

			/* Get value using type key */
			bundle_get_str(b, buf_key, &ret_val);
			if (ret_val != NULL)
				/* If value exist, remove this to add new value */
				bundle_del(b, buf_key);

			snprintf(buf_val, sizeof(buf_val), "%s", key);

			/* Add new key value */
			bundle_add_str(b, buf_key, buf_val);
		} else {
			/* If key bundle does not exist, create new one */
			b = bundle_create();

			/* Make type to key as char string */
			snprintf(buf_key, sizeof(buf_key), "%d", type);

			snprintf(buf_val, sizeof(buf_val), "%s", key);

			/* Add new key value */
			bundle_add_str(b, buf_key, buf_val);

			/* Save key bundle */
			noti->b_key = b;
		}
	} else {
		/* Reset if key is NULL */
		if (noti->b_key != NULL) {
			/* If key bundle exist,  store local bundle data */
			b = noti->b_key;

			/* Make type to key as char string */
			snprintf(buf_key, sizeof(buf_key), "%d", type);

			/* Get value using type key */
			bundle_get_str(b, buf_key, &ret_val);
			if (ret_val != NULL)
				/* If value exist, remove this */
				bundle_del(b, buf_key);
		}
	}

	if (noti->b_format_args != NULL)
		b = noti->b_format_args;
	else
		b = bundle_create();

	va_start(var_args, args_type);

	var_type = args_type;
	num_args = 0;

	while (var_type != NOTIFICATION_VARIABLE_TYPE_NONE) {
		/* Type */
		snprintf(buf_key, sizeof(buf_key), "%dtype%d", type, num_args);
		snprintf(buf_val, sizeof(buf_val), "%d", var_type);

		bundle_get_str(b, buf_key, &ret_val);
		if (ret_val != NULL)
			bundle_del(b, buf_key);

		bundle_add_str(b, buf_key, buf_val);

		switch (var_type) {
		case NOTIFICATION_VARIABLE_TYPE_INT:
			var_value_int = va_arg(var_args, int);

			/* Value */
			snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
				 num_args);
			snprintf(buf_val, sizeof(buf_val), "%d", var_value_int);

			bundle_get_str(b, buf_key, &ret_val);
			if (ret_val != NULL)
				bundle_del(b, buf_key);

			bundle_add_str(b, buf_key, buf_val);
			break;

		case NOTIFICATION_VARIABLE_TYPE_DOUBLE:
			var_value_double = va_arg(var_args, double);

			/* Value */
			snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
				 num_args);
			snprintf(buf_val, sizeof(buf_val), "%.2f",
				 var_value_double);

			bundle_get_str(b, buf_key, &ret_val);
			if (ret_val != NULL)
				bundle_del(b, buf_key);

			bundle_add_str(b, buf_key, buf_val);
			break;

		case NOTIFICATION_VARIABLE_TYPE_STRING:
			var_value_string = va_arg(var_args, char *);

			/* Value */
			snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
				 num_args);
			snprintf(buf_val, sizeof(buf_val), "%s",
				 var_value_string);

			bundle_get_str(b, buf_key, &ret_val);
			if (ret_val != NULL)
				bundle_del(b, buf_key);

			bundle_add_str(b, buf_key, buf_val);
			break;

		case NOTIFICATION_VARIABLE_TYPE_COUNT:
			var_value_count =
			    va_arg(var_args, notification_count_pos_type_e);

			/* Value */
			snprintf(buf_key, sizeof(buf_key), "%dvalue%d", type,
				 num_args);
			snprintf(buf_val, sizeof(buf_val), "%d",
				 var_value_count);

			bundle_get_str(b, buf_key, &ret_val);
			if (ret_val != NULL)
				bundle_del(b, buf_key);

			bundle_add_str(b, buf_key, buf_val);
			break;

		default:
			NOTIFICATION_ERR("Error. invalid variable type. : %d",
					 var_type);
			noti_err = NOTIFICATION_ERROR_INVALID_PARAMETER;
			break;
		}

		num_args++;
		var_type = va_arg(var_args, notification_variable_type_e);
	}
	va_end(var_args);

	if (noti_err == NOTIFICATION_ERROR_NONE)
		noti->num_format_args = num_args;
	else
		noti->num_format_args = 0;

	snprintf(buf_key, sizeof(buf_key), "num%d", type);
	snprintf(buf_val, sizeof(buf_val), "%d", noti->num_format_args);

	bundle_get_str(b, buf_key, &ret_val);
	if (ret_val != NULL)
		bundle_del(b, buf_key);

	bundle_add_str(b, buf_key, buf_val);

	noti->b_format_args = b;

	return noti_err;
}

EXPORT_API int notification_get_text(notification_h noti,
						      notification_text_type_e type,
						      char **text)
{
	bundle *b = NULL;
	char buf_key[32] = { 0, };
	char *ret_val = NULL;
	char *get_str = NULL;
	notification_text_type_e check_type = NOTIFICATION_TEXT_TYPE_NONE;
	/* int display_option_flag = 0; */

	char *temp_str = NULL;
	char *translated_str = NULL;
	char result_str[NOTI_TEXT_RESULT_LEN] = { 0, };
	char buf_str[1024] = { 0, };
	int num_args = 0;
	notification_variable_type_e ret_var_type = 0;
	int ret_variable_int = 0;
	double ret_variable_double = 0.0;
	int src_len = 0;
	int max_len = 0;

	/* Check noti is valid data */
	if (noti == NULL || text == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Check text type is valid type */
	if (type <= NOTIFICATION_TEXT_TYPE_NONE
	    || type >= NOTIFICATION_TEXT_TYPE_MAX)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;


	/* Check key */
	if (noti->b_key != NULL) {
		b = noti->b_key;

		/* Get text domain and dir */
		/* _notification_get_text_domain(noti); */

		snprintf(buf_key, sizeof(buf_key), "%d", type);

		bundle_get_str(b, buf_key, &ret_val);
		if (ret_val != NULL && noti->domain != NULL
		    && noti->dir != NULL) {
			/* Get application string */
			bindtextdomain(noti->domain, noti->dir);

			get_str = dgettext(noti->domain, ret_val);
		} else if (ret_val != NULL) {
			/* Get system string */
			get_str = dgettext("sys_string", ret_val);
		} else {
			get_str = NULL;
		}
	}

	if (get_str == NULL && noti->b_text != NULL) {
		b = noti->b_text;
		/* Get basic text */
		snprintf(buf_key, sizeof(buf_key), "%d", type);

		bundle_get_str(b, buf_key, &get_str);
	}

	check_type = type;

	if (get_str != NULL) {
		/* Get number format args */
		b = noti->b_format_args;
		noti->num_format_args = 0;

		if (b != NULL) {
			snprintf(buf_key, sizeof(buf_key), "num%d", check_type);
			bundle_get_str(b, buf_key, &ret_val);
			if (ret_val != NULL)
				noti->num_format_args = atoi(ret_val);
		}

		if (noti->num_format_args == 0) {
			*text = (char *)get_str;
		} else {
			/* Check first variable is count, LEFT pos */
			snprintf(buf_key, sizeof(buf_key), "%dtype%d",
				 check_type, num_args);
			bundle_get_str(b, buf_key, &ret_val);
			if (ret_val != NULL)
				ret_var_type = atoi(ret_val);

			if (ret_var_type == NOTIFICATION_VARIABLE_TYPE_COUNT) {
				/* Get var Value */
				snprintf(buf_key, sizeof(buf_key), "%dvalue%d",
					 check_type, num_args);
				bundle_get_str(b, buf_key, &ret_val);
				if (ret_val != NULL)
					ret_variable_int = atoi(ret_val);

				if (ret_variable_int ==
				    NOTIFICATION_COUNT_POS_LEFT) {
					notification_noti_get_count(noti->type,
								    noti->caller_pkgname,
								    noti->group_id,
								    noti->priv_id,
								    &ret_variable_int);
					snprintf(buf_str, sizeof(buf_str),
						 "%d ", ret_variable_int);

					src_len = strlen(result_str);
					max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;

					strncat(result_str, buf_str,
							max_len);
					num_args++;
				}
			}

			/* Check variable IN pos */
			for (temp_str = (char *)get_str; *temp_str != '\0';
			     temp_str++) {
				if (*temp_str != '%') {
					strncat(result_str, temp_str, 1);
				} else {
					if (*(temp_str + 1) == '%') {
						strncat(result_str, temp_str,
							1);
					} else if (*(temp_str + 1) == 'd') {
						/* Get var Type */
						ret_variable_int = 0;

						snprintf(buf_key,
							 sizeof(buf_key),
							 "%dtype%d", check_type,
							 num_args);
						bundle_get_str(b, buf_key, &ret_val);
						if (ret_val != NULL)
							ret_var_type = atoi(ret_val);

						if (ret_var_type ==
						    NOTIFICATION_VARIABLE_TYPE_COUNT) {
							/* Get notification count */
							notification_noti_get_count
							    (noti->type,
							     noti->caller_pkgname,
							     noti->group_id,
							     noti->priv_id,
							     &ret_variable_int);
						} else {
							/* Get var Value */
							snprintf(buf_key,
								 sizeof(buf_key),
								 "%dvalue%d",
								 check_type,
								 num_args);
							bundle_get_str(b, buf_key, &ret_val);
							if (ret_val != NULL)
								ret_variable_int = atoi(ret_val);
						}

						snprintf(buf_str,
							 sizeof(buf_str), "%d",
							 ret_variable_int);

						src_len = strlen(result_str);
						max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;

						strncat(result_str, buf_str,
								max_len);

						temp_str++;

						num_args++;
					} else if (*(temp_str + 1) == 's') {
						/* Get var Value */
						snprintf(buf_key,
							 sizeof(buf_key),
							 "%dvalue%d",
							 check_type, num_args);
						bundle_get_str(b, buf_key, &ret_val);

						if (ret_val != NULL && noti->domain != NULL	&& noti->dir != NULL) {
							/* Get application string */
							bindtextdomain(noti->domain, noti->dir);
							translated_str = dgettext(noti->domain, ret_val);
							NOTIFICATION_INFO("translated_str[%s]", translated_str);
						} else if (ret_val != NULL) {
							/* Get system string */
							translated_str = dgettext("sys_string", ret_val);
							NOTIFICATION_INFO("translated_str[%s]", translated_str);
						} else {
							translated_str = NULL;
						}

						if (translated_str != NULL) {
							strncpy(buf_str, translated_str, sizeof(buf_str) - 1);
							src_len = strlen(result_str);
							max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
							strncat(result_str, buf_str, max_len);
						}
						temp_str++;
						num_args++;
					} else if (*(temp_str + 1) == 'f') {
						/* Get var Value */
						snprintf(buf_key,
							 sizeof(buf_key),
							 "%dvalue%d",
							 check_type, num_args);
						bundle_get_str(b, buf_key, &ret_val);
						if (ret_val != NULL)
							ret_variable_double = atof(ret_val);

						snprintf(buf_str,
							 sizeof(buf_str),
							 "%.2f",
							 ret_variable_double);

						src_len = strlen(result_str);
						max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;
						strncat(result_str, buf_str, max_len);

						temp_str++;
						num_args++;
					} else if (*(temp_str + 1) >= '1' && *(temp_str + 1) <= '9') {
						if (*(temp_str + 3) == 'd') {
							/* Get var Type */
							ret_variable_int = 0;

							snprintf(buf_key,
								 sizeof(buf_key),
								 "%dtype%d", check_type,
								 num_args + *(temp_str + 1) - 49);
							bundle_get_str(b, buf_key, &ret_val);
							if (ret_val != NULL)
								ret_var_type = atoi(ret_val);

							if (ret_var_type ==
							    NOTIFICATION_VARIABLE_TYPE_COUNT) {
								/* Get notification count */
								notification_noti_get_count
								    (noti->type,
								     noti->caller_pkgname,
								     noti->group_id,
								     noti->priv_id,
								     &ret_variable_int);
							} else {
								/* Get var Value */
								snprintf(buf_key,
									 sizeof
									 (buf_key),
									 "%dvalue%d",
									 check_type,
									 num_args + *(temp_str + 1) - 49);
								bundle_get_str(b, buf_key, &ret_val);
								if (ret_val != NULL)
									ret_variable_int = atoi(ret_val);

							}

							snprintf(buf_str,
								 sizeof(buf_str), "%d",
								 ret_variable_int);

							src_len = strlen(result_str);
							max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;

							strncat(result_str, buf_str, max_len);

							temp_str += 3;
						} else if (*(temp_str + 3) == 's') {
							/* Get var Value */
							snprintf(buf_key,
								 sizeof(buf_key),
								 "%dvalue%d",
								 check_type, num_args + *(temp_str + 1) - 49);
							bundle_get_str(b, buf_key, &ret_val);

							snprintf(buf_str,
								 sizeof(buf_str), "%s",
								 ret_val);

							src_len = strlen(result_str);
							max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;

							strncat(result_str, buf_str, max_len);

							temp_str += 3;
						} else if (*(temp_str + 3) == 'f') {
							/* Get var Value */
							snprintf(buf_key,
								 sizeof(buf_key),
								 "%dvalue%d",
								 check_type, num_args + *(temp_str + 1) - 49);
							bundle_get_str(b, buf_key, &ret_val);
							if (ret_val != NULL)
								ret_variable_double = atof(ret_val);

							snprintf(buf_str,
								 sizeof(buf_str),
								 "%.2f",
								 ret_variable_double);

							src_len = strlen(result_str);
							max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;

							strncat(result_str, buf_str, max_len);

							temp_str += 3;
						}
					}
				}

			}

			/* Check last variable is count, LEFT pos */
			if (num_args < noti->num_format_args) {
				snprintf(buf_key, sizeof(buf_key), "%dtype%d",
					 check_type, num_args);
				bundle_get_str(b, buf_key, &ret_val);
				if (ret_val != NULL)
					ret_var_type = atoi(ret_val);

				if (ret_var_type ==
				    NOTIFICATION_VARIABLE_TYPE_COUNT) {
					/* Get var Value */
					snprintf(buf_key, sizeof(buf_key),
						 "%dvalue%d", check_type,
						 num_args);
					bundle_get_str(b, buf_key, &ret_val);
					if (ret_val != NULL)
						ret_variable_int = atoi(ret_val);

					if (ret_variable_int ==
					    NOTIFICATION_COUNT_POS_RIGHT) {
						notification_noti_get_count
						    (noti->type,
						     noti->caller_pkgname,
						     noti->group_id,
						     noti->priv_id,
						     &ret_variable_int);
						snprintf(buf_str,
							 sizeof(buf_str), " %d",
							 ret_variable_int);

						src_len = strlen(result_str);
						max_len = NOTI_TEXT_RESULT_LEN - src_len - 1;

						strncat(result_str, buf_str, max_len);

						num_args++;
					}

				}
			}

			switch (check_type) {
			case NOTIFICATION_TEXT_TYPE_TITLE:
			case NOTIFICATION_TEXT_TYPE_GROUP_TITLE:
				if (noti->temp_title != NULL)
					free(noti->temp_title);

				noti->temp_title = strdup(result_str);

				*text = noti->temp_title;
				break;
			case NOTIFICATION_TEXT_TYPE_CONTENT:
			case NOTIFICATION_TEXT_TYPE_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
			case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT:
			case NOTIFICATION_TEXT_TYPE_GROUP_CONTENT_FOR_DISPLAY_OPTION_IS_OFF:
				if (noti->temp_content !=
				    NULL)
					free(noti->temp_content);

				noti->temp_content = strdup(result_str);

				*text = noti->temp_content;
				break;
			default:
				break;
			}

		}

	} else {
		*text = NULL;
	}

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_set_text_domain(notification_h noti,
							     const char *domain,
							     const char *dir)
{
	/* check noti and domain is valid data */
	if (noti == NULL || domain == NULL || dir == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Check domain */
	if (noti->domain)
		/* Remove previous domain */
		free(noti->domain);

	/* Copy domain */
	noti->domain = strdup(domain);

	/* Check locale dir */
	if (noti->dir)
		/* Remove previous locale dir */
		free(noti->dir);

	/* Copy locale dir */
	noti->dir = strdup(dir);

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_get_text_domain(notification_h noti,
							     char **domain,
							     char **dir)
{
	/* Check noti is valid data */
	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Get domain */
	if (domain != NULL && noti->domain != NULL)
		*domain = noti->domain;

	/* Get locale dir */
	if (dir != NULL && noti->dir != NULL)
		*dir = noti->dir;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_set_time_to_text(notification_h noti, notification_text_type_e type,
								time_t time)
{
	int ret = NOTIFICATION_ERROR_NONE;
	char buf[256] = { 0, };
	char buf_tag[512] = { 0, };

	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	if (time <= 0)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	if (type <= NOTIFICATION_TEXT_TYPE_NONE
	    || type >= NOTIFICATION_TEXT_TYPE_MAX)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;


	snprintf(buf, sizeof(buf), "%lu", time);
	ret = notification_noti_set_tag(TAG_TIME, buf, buf_tag, sizeof(buf_tag));

	if (ret != NOTIFICATION_ERROR_NONE)
		return ret;

	return notification_set_text(noti, type, buf_tag, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
}

EXPORT_API int notification_get_time_from_text(notification_h noti, notification_text_type_e type,
								time_t *time)
{
	int ret = NOTIFICATION_ERROR_NONE;
	char *ret_text = NULL;
	char *tag_value;

	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	if (time == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	if (type <= NOTIFICATION_TEXT_TYPE_NONE
	    || type >= NOTIFICATION_TEXT_TYPE_MAX)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	ret = notification_get_text(noti, type, &ret_text);

	if (ret != NOTIFICATION_ERROR_NONE || ret_text == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	if (notification_noti_get_tag_type(ret_text) == TAG_TYPE_INVALID)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	tag_value = notification_noti_strip_tag(ret_text);
	if (tag_value == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	*time = atol(tag_value);
	free(tag_value);

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_set_sound(notification_h noti,
						       notification_sound_type_e type,
						       const char *path)
{
	/* Check noti is valid data */
	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;


	/* Check type is valid */
	if (type < NOTIFICATION_SOUND_TYPE_NONE
	    || type >= NOTIFICATION_SOUND_TYPE_MAX)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Save sound type */
	noti->sound_type = type;

	/* Save sound path if user data type */
	if (type == NOTIFICATION_SOUND_TYPE_USER_DATA && path != NULL) {
		if (noti->sound_path != NULL)
			free(noti->sound_path);

		noti->sound_path = strdup(path);
	} else {
		if (noti->sound_path != NULL) {
			free(noti->sound_path);
			noti->sound_path = NULL;
		}
		if (type == NOTIFICATION_SOUND_TYPE_USER_DATA) {
			noti->sound_type = NOTIFICATION_SOUND_TYPE_DEFAULT;
			return NOTIFICATION_ERROR_INVALID_PARAMETER;
		}
	}

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_get_sound(notification_h noti,
						       notification_sound_type_e *type,
						       const char **path)
{
	/* check noti and type is valid data */
	if (noti == NULL || type == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Set sound type */
	*type = noti->sound_type;

	/* Set sound path if user data type */
	if (noti->sound_type == NOTIFICATION_SOUND_TYPE_USER_DATA
	    && path != NULL)
		*path = noti->sound_path;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_set_vibration(notification_h noti,
							   notification_vibration_type_e type,
							   const char *path)
{
	/* Check noti is valid data */
	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Check type is valid */
	if (type < NOTIFICATION_VIBRATION_TYPE_NONE
	    || type >= NOTIFICATION_VIBRATION_TYPE_MAX)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Save vibration type */
	noti->vibration_type = type;

	/* Save sound path if user data type */
	if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA && path != NULL) {
		if (noti->vibration_path != NULL)
			free(noti->vibration_path);

		noti->vibration_path = strdup(path);
	} else {
		if (noti->vibration_path != NULL) {
			free(noti->vibration_path);
			noti->vibration_path = NULL;
		}
		if (type == NOTIFICATION_VIBRATION_TYPE_USER_DATA) {
			noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_DEFAULT;
			return NOTIFICATION_ERROR_INVALID_PARAMETER;
		}
	}

	return NOTIFICATION_ERROR_NONE;

}

EXPORT_API int notification_get_vibration(notification_h noti,
							   notification_vibration_type_e *type,
							   const char **path)
{
	/* check noti and type is valid data */
	if (noti == NULL || type == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Set vibration type */
	*type = noti->vibration_type;

	/* Set sound path if user data type */
	if (noti->vibration_type == NOTIFICATION_VIBRATION_TYPE_USER_DATA
	    && path != NULL)
		*path = noti->vibration_path;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_set_led(notification_h noti,
							   notification_led_op_e operation,
							   int led_argb)
{
	/* Check noti is valid data */
	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Check operation is valid */
	if (operation < NOTIFICATION_LED_OP_OFF
	    || operation >= NOTIFICATION_LED_OP_MAX)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Save led operation */
	noti->led_operation = operation;

	/* Save led argb if operation is turning on LED with custom color */
	if (operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR)
		noti->led_argb = led_argb;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_get_led(notification_h noti,
							   notification_led_op_e *operation,
							   int *led_argb)
{
	/* check noti and operation is valid data */
	if (noti == NULL || operation == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Set led operation */
	*operation = noti->led_operation;

	/* Save led argb if operation is turning on LED with custom color */
	if (noti->led_operation == NOTIFICATION_LED_OP_ON_CUSTOM_COLOR
	    && led_argb != NULL)
		*led_argb = noti->led_argb;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_set_led_time_period(notification_h noti,
									int on_ms, int off_ms)
{
	/* Check noti is valid data */
	if (noti == NULL || on_ms < 0 || off_ms < 0)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Save led operation */
	noti->led_on_ms = on_ms;
	noti->led_off_ms = off_ms;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_get_led_time_period(notification_h noti,
									int *on_ms, int *off_ms)
{
	/* check noti and operation is valid data */
	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	if (on_ms)
		*(on_ms) = noti->led_on_ms;
	if (off_ms)
		*(off_ms) = noti->led_off_ms;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_set_launch_option(notification_h noti,
								notification_launch_option_type type, void *option)
{
	int err = NOTIFICATION_ERROR_NONE;
	int ret = 0;
	bundle *b = NULL;
	app_control_h app_control = option;

	if (noti == NULL || app_control == NULL || type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL) {
		err = NOTIFICATION_ERROR_INVALID_PARAMETER;
		goto out;
	}

	if ((ret = app_control_export_as_bundle(app_control, &b)) != APP_CONTROL_ERROR_NONE) {
		NOTIFICATION_ERR("Failed to convert appcontrol to bundle:%d", ret);
		err = NOTIFICATION_ERROR_INVALID_PARAMETER;
		goto out;
	}

	err = notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, b);

out:
	if (b)
		bundle_free(b);

	return err;
}

EXPORT_API int notification_get_launch_option(notification_h noti,
								notification_launch_option_type type, void *option)
{
	int ret = 0;
	bundle *b = NULL;
	app_control_h *app_control = (app_control_h *)option;
	app_control_h app_control_new = NULL;

	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	if (app_control == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	if (type != NOTIFICATION_LAUNCH_OPTION_APP_CONTROL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;


	ret = notification_get_execute_option(noti,
				NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
				NULL,
				&b);
	if (ret == NOTIFICATION_ERROR_NONE && b != NULL) {
		ret = app_control_create(&app_control_new);
		if (ret == APP_CONTROL_ERROR_NONE && app_control_new != NULL) {
			ret = app_control_import_from_bundle(app_control_new, b);
			if (ret == APP_CONTROL_ERROR_NONE) {
				*app_control = app_control_new;
			} else {
				app_control_destroy(app_control_new);
				NOTIFICATION_ERR("Failed to import app control from bundle:%d", ret);
				return NOTIFICATION_ERROR_IO_ERROR;
			}
		} else {
			NOTIFICATION_ERR("Failed to create app control:%d", ret);
			return NOTIFICATION_ERROR_IO_ERROR;
		}
	} else {
		NOTIFICATION_ERR("Failed to get execute option:%d", ret);
		return ret;
	}

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_set_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h event_handler)
{
	int err = NOTIFICATION_ERROR_NONE;
	bundle *app_control_bundle = NULL;

	if (noti == NULL) {
		err = NOTIFICATION_ERROR_INVALID_PARAMETER;
		NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
		goto out;
	}

	if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
		|| event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
		NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
		err = NOTIFICATION_ERROR_INVALID_PARAMETER;
		goto out;
	}

	if ((err = app_control_export_as_bundle(event_handler, &app_control_bundle)) != APP_CONTROL_ERROR_NONE) {
		NOTIFICATION_ERR("app_control_to_bundle failed [%d]", err);
		goto out;
	}

	if (noti->b_event_handler[event_type] != NULL)
		bundle_free(noti->b_event_handler[event_type]);

	noti->b_event_handler[event_type] = app_control_bundle;

out:
	return err;
}

EXPORT_API int notification_get_event_handler(notification_h noti, notification_event_type_e event_type, app_control_h *event_handler)
{
	int err = NOTIFICATION_ERROR_NONE;
	bundle *b = NULL;
	app_control_h app_control_new = NULL;

	if (noti == NULL) {
		err = NOTIFICATION_ERROR_INVALID_PARAMETER;
		NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
		goto out;
	}
	if (event_handler == NULL) {
		err = NOTIFICATION_ERROR_INVALID_PARAMETER;
		NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
		goto out;
	}
	if (event_type < NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1
		|| event_type > NOTIFICATION_EVENT_TYPE_CLICK_ON_THUMBNAIL) {
		NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
		err = NOTIFICATION_ERROR_INVALID_PARAMETER;
		goto out;
	}

	b = noti->b_event_handler[event_type];

	if (b == NULL) {
		NOTIFICATION_DBG("No event handler\n");
		err = NOTIFICATION_ERROR_NOT_EXIST_ID;
		goto out;
	}

	err = app_control_create(&app_control_new);
	if (err != APP_CONTROL_ERROR_NONE || app_control_new == NULL) {
		NOTIFICATION_ERR("app_control_create failed [%d]", err);
		err = NOTIFICATION_ERROR_IO_ERROR;
		goto out;
	}

	err = app_control_import_from_bundle(app_control_new, b);
	if (err == APP_CONTROL_ERROR_NONE) {
		*event_handler = app_control_new;
	} else {
		app_control_destroy(app_control_new);
		app_control_new = NULL;
		NOTIFICATION_ERR("Failed to import app control from bundle [%d]", err);
		err = NOTIFICATION_ERROR_IO_ERROR;
		goto out;
	}

out:
	if (event_handler)
		*event_handler = app_control_new;

	return err;
}





EXPORT_API int notification_set_property(notification_h noti,
							  int flags)
{
	/* Check noti is valid data */
	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Set flags */
	noti->flags_for_property = flags;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_get_property(notification_h noti,
							  int *flags)
{
	/* Check noti and flags are valid data */
	if (noti == NULL || flags == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Set flags */
	*flags = noti->flags_for_property;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_set_display_applist(notification_h noti,
								 int applist)
{
	/* Check noti is valid data */
	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;


	/* Set app list */
	if (applist == 0xffffffff) /* 0xffffffff means old NOTIFICATION_DISPLAY_APP_ALL */
		applist = NOTIFICATION_DISPLAY_APP_ALL;

	noti->display_applist = applist;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_get_display_applist(notification_h noti,
								 int *applist)
{
	/* Check noti and applist are valid data */
	if (noti == NULL || applist == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Set app list */
	*applist = noti->display_applist;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_set_size(notification_h noti,
						      double size)
{
	/* Check noti is valid data */
	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Save progress size */
	noti->progress_size = size;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_get_size(notification_h noti,
						      double *size)
{
	/* Check noti and size is valid data */
	if (noti == NULL || size == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Set progress size */
	*size = noti->progress_size;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_set_progress(notification_h noti,
							  double percentage)
{
	/* Check noti is valid data */
	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Save progress percentage */
	noti->progress_percentage = percentage;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_get_progress(notification_h noti,
							  double *percentage)
{
	/* Check noti and percentage are valid data */
	if (noti == NULL || percentage == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Set progress percentage */
	*percentage = noti->progress_percentage;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_get_pkgname(notification_h noti,
							 char **pkgname)
{
	/* Check noti and pkgname are valid data */
	if (noti == NULL || pkgname == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Get caller pkgname */
	if (noti->caller_pkgname)
		*pkgname = noti->caller_pkgname;
	else
		*pkgname = NULL;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_set_layout(notification_h noti,
		notification_ly_type_e layout)
{
	/* check noti and pkgname are valid data */
	if (noti == NULL || (layout < NOTIFICATION_LY_NONE || layout >= NOTIFICATION_LY_MAX))
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	noti->layout = layout;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_get_layout(notification_h noti,
		notification_ly_type_e *layout)
{
	/* Check noti and pkgname are valid data */
	if (noti == NULL || layout == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	*layout = noti->layout;

	return NOTIFICATION_ERROR_NONE;
}



EXPORT_API int notification_get_type(notification_h noti,
						      notification_type_e *type)
{
	/* Check noti and type is valid data */
	if (noti == NULL || type == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Set noti type */
	*type = noti->type;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_post(notification_h noti)
{
	int ret = 0;
	int id = 0;

	/* Check noti is vaild data */
	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Check noti type is valid type */
	if (noti->type <= NOTIFICATION_TYPE_NONE
	    || noti->type >= NOTIFICATION_TYPE_MAX)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	/* Save insert time */
	noti->insert_time = time(NULL);

	ret = notification_ipc_request_insert(noti, &id);
	if (ret != NOTIFICATION_ERROR_NONE)
		return ret;

	noti->priv_id = id;
	NOTIFICATION_DBG("from master:%d", id);

	return NOTIFICATION_ERROR_NONE;
}



EXPORT_API int notification_update(notification_h noti)
{
	int ret = 0;

	/* Check noti is valid data */
	if (noti != NULL) {
		/* Update insert time ? */
		noti->insert_time = time(NULL);
		ret = notification_ipc_request_update(noti);
	} else {
		notification_ipc_request_refresh();
		return NOTIFICATION_ERROR_INVALID_PARAMETER;
	}
	return ret;
}

EXPORT_API int notification_delete_all(notification_type_e type)
{
	int ret = 0;
	char *caller_pkgname = NULL;

	if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	caller_pkgname = notification_get_pkgname_by_pid();

	ret = notification_ipc_request_delete_multiple(type, caller_pkgname);

	if (caller_pkgname)
		free(caller_pkgname);

	return ret;
}

EXPORT_API int notification_delete(notification_h noti)
{
	int ret = 0;

	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	ret = notification_ipc_request_delete_single(NOTIFICATION_TYPE_NONE, noti->caller_pkgname, noti->priv_id);

	return ret;
}

static notification_h _notification_create(notification_type_e type)
{
	notification_h noti = NULL;
	package_info_h package_info = NULL;
	char *app_id = NULL;
	char *domain_name = NULL;
	char *app_root_path = NULL;
	char locale_directory[PATH_MAX] = { 0, }; /* PATH_MAX 4096 */
	int err_app_manager = APP_MANAGER_ERROR_NONE;

	if (type <= NOTIFICATION_TYPE_NONE || type >= NOTIFICATION_TYPE_MAX) {
		NOTIFICATION_ERR("INVALID TYPE : %d", type);
		set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
		return NULL;
	}

	noti = (notification_h) calloc(1, sizeof(struct _notification));
	if (noti == NULL) {
		NOTIFICATION_ERR("NO MEMORY : noti == NULL");
		set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
		return NULL;
	}

	noti->type = type;

	if (type == NOTIFICATION_TYPE_NOTI)
		noti->layout = NOTIFICATION_LY_NOTI_EVENT_SINGLE;
	else if (type == NOTIFICATION_TYPE_ONGOING)
		noti->layout = NOTIFICATION_LY_ONGOING_PROGRESS;

	noti->caller_pkgname = notification_get_pkgname_by_pid();
	noti->group_id = NOTIFICATION_GROUP_ID_NONE;
	noti->priv_id = NOTIFICATION_PRIV_ID_NONE;
	noti->sound_type = NOTIFICATION_SOUND_TYPE_NONE;
	noti->vibration_type = NOTIFICATION_VIBRATION_TYPE_NONE;
	noti->led_operation = NOTIFICATION_LED_OP_OFF;
	noti->display_applist = NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_TICKER | NOTIFICATION_DISPLAY_APP_INDICATOR;
	noti->auto_remove = true;

	err_app_manager = app_manager_get_app_id(getpid(), &app_id);
	if (err_app_manager != APP_MANAGER_ERROR_NONE || app_id == NULL) {
		NOTIFICATION_WARN("app_manager_get_app_id failed err[%d] app_id[%p]", err_app_manager, app_id);
		goto out;
	}

	/* app name is used as domain name */
	/* domain_name is allocated by app_get_package_app_name */
	err_app_manager = app_get_package_app_name(app_id, &domain_name);

	if (err_app_manager != APP_ERROR_NONE || domain_name == NULL) {
		NOTIFICATION_WARN("app_get_package_app_name failed err[%d] domain_name[%p]", err_app_manager, domain_name);
		goto out;
	}

	err_app_manager = package_info_create(noti->caller_pkgname, &package_info);

	if (err_app_manager != PACKAGE_MANAGER_ERROR_NONE || package_info == NULL) {
		NOTIFICATION_WARN("package_info_create failed err[%d] package_info[%p] caller_pkgname[%s]",
				err_app_manager, package_info, noti->caller_pkgname);
		goto out;
	}

	err_app_manager = package_info_get_root_path(package_info, &app_root_path);

	if (err_app_manager != PACKAGE_MANAGER_ERROR_NONE || app_root_path == NULL) {
		NOTIFICATION_WARN("package_info_get_root_path failed err[%d] app_root_path[%p]", err_app_manager, app_root_path);
		goto out;
	}

	snprintf(locale_directory, PATH_MAX, "%s/res/locale", app_root_path);

	noti->domain = strdup(domain_name);
	noti->dir    = strdup(locale_directory);

out:
	if (domain_name)
		free(domain_name);

	if (app_id)
		free(app_id);

	if (app_root_path)
		free(app_root_path);

	if (package_info)
		package_info_destroy(package_info);

	/*!
	 * \NOTE
	 * Other fields are already initialized with ZERO.
	 */
	set_last_result(NOTIFICATION_ERROR_NONE);
	return noti;
}

EXPORT_API notification_h notification_create(notification_type_e type)
{
	return _notification_create(type);
}

EXPORT_API notification_h  notification_load_by_tag(const char *tag)
{
	int ret = 0;
	notification_h noti = NULL;
	char *caller_pkgname = NULL;

	if (tag == NULL) {
		NOTIFICATION_ERR("Invalid parameter");
		set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
		return NULL;
	}

	caller_pkgname = notification_get_pkgname_by_pid();
	if (!caller_pkgname) {
		NOTIFICATION_ERR("Failed to get a package name");
		set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
		return NULL;
	}

	noti = (notification_h) calloc(1, sizeof(struct _notification));
	if (noti == NULL) {
		NOTIFICATION_ERR("Failed to alloc a new notification");
		set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
		free(caller_pkgname);

		return NULL;
	}

	ret = notification_noti_get_by_tag(noti, caller_pkgname, (char*)tag);

	free(caller_pkgname);

	set_last_result(ret);

	if (ret != NOTIFICATION_ERROR_NONE) {
		notification_free(noti);
		return NULL;
	}

	return noti;
}

EXPORT_API int notification_clone(notification_h noti, notification_h *clone)
{
	int i = 0;
	notification_h new_noti = NULL;

	if (noti == NULL || clone == NULL) {
		NOTIFICATION_ERR("INVALID PARAMETER.");
		return NOTIFICATION_ERROR_INVALID_PARAMETER;
	}

	new_noti = (notification_h) calloc(1, sizeof(struct _notification));
	if (new_noti == NULL) {
		NOTIFICATION_ERR("NO MEMORY : noti == NULL");
		return NOTIFICATION_ERROR_OUT_OF_MEMORY;
	}

	new_noti->type = noti->type;
	new_noti->layout = noti->layout;

	new_noti->group_id = noti->group_id;
	new_noti->internal_group_id = noti->internal_group_id;
	new_noti->priv_id = noti->priv_id;

	if (noti->caller_pkgname != NULL)
		new_noti->caller_pkgname = strdup(noti->caller_pkgname);
	else
		new_noti->caller_pkgname = notification_get_pkgname_by_pid();

	if (noti->launch_pkgname != NULL)
		new_noti->launch_pkgname = strdup(noti->launch_pkgname);
	else
		new_noti->launch_pkgname = NULL;

	if (noti->args != NULL)
		new_noti->args = bundle_dup(noti->args);
	else
		new_noti->args = NULL;

	if (noti->group_args != NULL)
		new_noti->group_args = bundle_dup(noti->group_args);
	else
		new_noti->group_args = NULL;

	if (noti->b_execute_option != NULL)
		new_noti->b_execute_option = bundle_dup(noti->b_execute_option);
	else
		new_noti->b_execute_option = NULL;

	if (noti->b_service_responding != NULL)
		new_noti->b_service_responding = bundle_dup(noti->b_service_responding);
	else
		new_noti->b_service_responding = NULL;

	if (noti->b_service_single_launch != NULL)
		new_noti->b_service_single_launch = bundle_dup(noti->b_service_single_launch);
	else
		new_noti->b_service_single_launch = NULL;

	if (noti->b_service_multi_launch != NULL)
		new_noti->b_service_multi_launch = bundle_dup(noti->b_service_multi_launch);
	else
		new_noti->b_service_multi_launch = NULL;

	for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
		if (noti->b_event_handler[i] != NULL)
			new_noti->b_event_handler[i] = bundle_dup(noti->b_event_handler[i]);
		else
			new_noti->b_event_handler[i] = NULL;
	}

	new_noti->sound_type = noti->sound_type;
	if (noti->sound_path != NULL)
		new_noti->sound_path = strdup(noti->sound_path);
	else
		new_noti->sound_path = NULL;

	new_noti->vibration_type = noti->vibration_type;
	if (noti->vibration_path != NULL)
		new_noti->vibration_path = strdup(noti->vibration_path);
	else
		new_noti->vibration_path = NULL;

	new_noti->led_operation = noti->led_operation;
	new_noti->led_argb = noti->led_argb;
	new_noti->led_on_ms = noti->led_on_ms;
	new_noti->led_off_ms = noti->led_off_ms;

	if (noti->domain != NULL)
		new_noti->domain = strdup(noti->domain);
	else
		new_noti->domain = NULL;

	if (noti->dir != NULL)
		new_noti->dir = strdup(noti->dir);
	else
		new_noti->dir = NULL;

	if (noti->b_text != NULL)
		new_noti->b_text = bundle_dup(noti->b_text);
	else
		new_noti->b_text = NULL;

	if (noti->b_key != NULL)
		new_noti->b_key = bundle_dup(noti->b_key);
	else
		new_noti->b_key = NULL;

	if (noti->b_format_args != NULL)
		new_noti->b_format_args = bundle_dup(noti->b_format_args);
	else
		new_noti->b_format_args = NULL;

	new_noti->num_format_args = noti->num_format_args;

	if (noti->b_image_path != NULL)
		new_noti->b_image_path = bundle_dup(noti->b_image_path);
	else
		new_noti->b_image_path = NULL;

	new_noti->time = noti->time;
	new_noti->insert_time = noti->insert_time;

	new_noti->flags_for_property = noti->flags_for_property;
	new_noti->display_applist = noti->display_applist;

	new_noti->progress_size = noti->progress_size;
	new_noti->progress_percentage = noti->progress_percentage;

	new_noti->ongoing_flag = noti->ongoing_flag;
	new_noti->auto_remove = noti->auto_remove;

	new_noti->app_icon_path = NULL;
	new_noti->app_name = NULL;
	new_noti->temp_title = NULL;
	new_noti->temp_content = NULL;

	*clone = new_noti;

	return NOTIFICATION_ERROR_NONE;
}


EXPORT_API int notification_free(notification_h noti)
{
	int i = 0;
	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	if (noti->caller_pkgname)
		free(noti->caller_pkgname);

	if (noti->launch_pkgname)
		free(noti->launch_pkgname);

	if (noti->args)
		bundle_free(noti->args);

	if (noti->group_args)
		bundle_free(noti->group_args);

	if (noti->b_execute_option)
		bundle_free(noti->b_execute_option);

	if (noti->b_service_responding)
		bundle_free(noti->b_service_responding);

	if (noti->b_service_single_launch)
		bundle_free(noti->b_service_single_launch);

	if (noti->b_service_multi_launch)
		bundle_free(noti->b_service_multi_launch);

	for (i = 0; i < NOTIFICATION_EVENT_TYPE_MAX; i++) {
		if (noti->b_event_handler[i] != NULL)
			bundle_free(noti->b_event_handler[i]);
	}

	if (noti->sound_path)
		free(noti->sound_path);

	if (noti->vibration_path)
		free(noti->vibration_path);

	if (noti->domain)
		free(noti->domain);

	if (noti->dir)
		free(noti->dir);

	if (noti->b_text)
		bundle_free(noti->b_text);

	if (noti->b_key)
		bundle_free(noti->b_key);

	if (noti->b_format_args)
		bundle_free(noti->b_format_args);

	if (noti->b_image_path)
		bundle_free(noti->b_image_path);

	if (noti->app_icon_path)
		free(noti->app_icon_path);

	if (noti->app_name)
		free(noti->app_name);

	if (noti->temp_title)
		free(noti->temp_title);

	if (noti->temp_content)
		free(noti->temp_content);

	if (noti->tag)
		free(noti->tag);

	free(noti);

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_set_tag(notification_h noti, const char *tag)
{
	/* Check noti is valid data */
	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	if (tag != NULL) {
		/* save input TAG */
		if (noti->tag != NULL)
			free(noti->tag);

		noti->tag = strdup(tag);
	}

	return NOTIFICATION_ERROR_NONE;

}

EXPORT_API int notification_get_tag(notification_h noti, const char **tag)
{
	/* Check noti is valid data */
	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	*tag = noti->tag;
	return NOTIFICATION_ERROR_NONE;
}

void notification_call_posted_toast_cb(const char *message)
{
	if (posted_toast_message_cb != NULL)
		posted_toast_message_cb((void*)message);
}

EXPORT_API int notification_set_ongoing_flag(notification_h noti, bool ongoing_flag)
{
	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	noti->ongoing_flag = ongoing_flag;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_get_ongoing_flag(notification_h noti, bool *ongoing_flag)
{
	if (noti == NULL || ongoing_flag == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	*ongoing_flag = noti->ongoing_flag;

	return NOTIFICATION_ERROR_NONE;
}


EXPORT_API int notification_add_button(notification_h noti, notification_button_index_e button_index)
{
	if (noti == NULL || button_index < NOTIFICATION_BUTTON_1 || button_index > NOTIFICATION_BUTTON_6)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_remove_button(notification_h noti, notification_button_index_e button_index)
{
	if (noti == NULL || button_index < NOTIFICATION_BUTTON_1 || button_index > NOTIFICATION_BUTTON_6)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	if (noti->b_event_handler[button_index - 1]) {
		bundle_free(noti->b_event_handler[button_index - 1]);
		noti->b_event_handler[button_index - 1] = NULL;
	}

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_set_auto_remove(notification_h noti, bool auto_remove)
{
	if (noti == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	noti->auto_remove = auto_remove;

	return NOTIFICATION_ERROR_NONE;
}

EXPORT_API int notification_get_auto_remove(notification_h noti, bool *auto_remove)
{
	if (noti == NULL || auto_remove == NULL)
		return NOTIFICATION_ERROR_INVALID_PARAMETER;

	*auto_remove = noti->auto_remove;

	return NOTIFICATION_ERROR_NONE;
}