Merge from tizen 2.4 latest.
[platform/core/api/notification.git] / src / notification_setting.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 <string.h>
24 #include <stdlib.h>
25 #include <db-util.h>
26 #include <package_manager.h>
27 #include <pkgmgr-info.h>
28 #include <tizen_type.h>
29
30 #include <notification.h>
31 #include <notification_db.h>
32 #include <notification_list.h>
33 #include <notification_noti.h>
34 #include <notification_debug.h>
35 #include <notification_ipc.h>
36 #include <notification_private.h>
37 #include <notification_setting.h>
38 #include <notification_setting_internal.h>
39
40 #define NOTIFICATION_PRIVILEGE "http://tizen.org/privilege/notification"
41
42
43 static int _get_table_field_data_int(char  **table, int *buf, int index)
44 {
45         if ((table == NULL) || (buf == NULL) || (index < 0))  {
46                 NOTIFICATION_ERR("table[%p], buf[%p], index[%d]", table, buf, index);
47                 return false;
48         }
49
50         if (table[index] != NULL) {
51                 *buf = atoi(table[index]);
52                 return true;
53         }
54
55         *buf = 0;
56         return false;
57 }
58
59 static int _get_table_field_data_string(char **table, char **buf, int ucs2, int index)
60 {
61         int ret = false;
62
63         if ((table == NULL) || (buf == NULL) || (index < 0))  {
64                 NOTIFICATION_ERR("table[%p], buf[%p], index[%d]", table, buf, index);
65                 return false;
66         }
67
68         char *pTemp = table[index];
69         int sLen = 0;
70         if (pTemp == NULL)
71                 *buf = NULL;
72         else {
73                 sLen = strlen(pTemp);
74                 if(sLen) {
75                         *buf = (char *) malloc(sLen + 1);
76                         if (*buf == NULL) {
77                                 NOTIFICATION_ERR("malloc is failed");
78                                 goto out;
79                         }
80                         memset(*buf, 0, sLen + 1);
81                         strncpy(*buf, pTemp, sLen);
82                 }
83                 else
84                         *buf = NULL;
85         }
86
87         ret = true;
88 out:
89
90         return ret;
91 }
92
93
94
95 EXPORT_API int notification_setting_get_setting_array(notification_setting_h *setting_array, int *count)
96 {
97         int err = NOTIFICATION_ERROR_NONE;
98         sqlite3 *local_db_handle = NULL;
99         char *sql_query = NULL;
100         char **query_result = NULL;
101         int sql_return;
102         int row_count = 0;
103         int column_count = 0;
104         int i = 0;
105         int col_index = 0;
106         notification_setting_h result_setting_array= NULL;
107
108         if (setting_array == NULL || count == NULL) {
109                 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
110                 err =  NOTIFICATION_ERROR_INVALID_PARAMETER;
111                 goto out;
112         }
113
114         sql_return = db_util_open(DBPATH, &local_db_handle, 0);
115
116         if (sql_return != SQLITE_OK || local_db_handle == NULL) {
117                 NOTIFICATION_ERR("db_util_open failed [%d]", sql_return);
118                 err = NOTIFICATION_ERROR_FROM_DB;
119                 goto out;
120         }
121
122         sql_query = sqlite3_mprintf("SELECT package_name, allow_to_notify, do_not_disturb_except, visibility_class "
123                         "FROM %s "
124                         "ORDER BY package_name", NOTIFICATION_SETTING_DB_TABLE);
125
126         if (!sql_query) {
127                 NOTIFICATION_ERR("fail to alloc query");
128                 err = NOTIFICATION_ERROR_OUT_OF_MEMORY;
129                 goto out;
130         }
131
132         sql_return = sqlite3_get_table(local_db_handle, sql_query, &query_result, &row_count, &column_count, NULL);
133
134         if (sql_return != SQLITE_OK && sql_return != -1) {
135                 NOTIFICATION_ERR("NOTIFICATION_ERROR_FROM_DB failed [%d][%s]", sql_return, sql_query);
136                 err = NOTIFICATION_ERROR_FROM_DB;
137                 goto out;
138         }
139
140         if (!row_count) {
141                 NOTIFICATION_DBG ("No setting found...");
142                 err= NOTIFICATION_ERROR_NOT_EXIST_ID;
143                 goto out;
144         }
145
146         NOTIFICATION_DBG ("row_count [%d] column_count [%d]", row_count, column_count);
147         if (!(result_setting_array = (struct notification_setting*)malloc(sizeof(struct notification_setting) * row_count))) {
148                 NOTIFICATION_ERR("malloc failed...");
149                 err = NOTIFICATION_ERROR_OUT_OF_MEMORY;
150                 goto out;
151         }
152
153         col_index = column_count;
154
155         for (i = 0; i < row_count; i++) {
156                 _get_table_field_data_string(query_result, &(result_setting_array[i].package_name), 1, col_index++);
157                 _get_table_field_data_int(query_result, (int*)&(result_setting_array[i].allow_to_notify), col_index++);
158                 _get_table_field_data_int(query_result, (int*)&(result_setting_array[i].do_not_disturb_except), col_index++);
159                 _get_table_field_data_int(query_result, &(result_setting_array[i].visibility_class), col_index++);
160         }
161
162         *setting_array = result_setting_array;
163         *count = row_count;
164
165 out:
166         if (query_result)
167                         sqlite3_free_table(query_result);
168
169         if (sql_query)
170                 sqlite3_free(sql_query);
171
172         if (local_db_handle) {
173                 sql_return = db_util_close(local_db_handle);
174                 if (sql_return != SQLITE_OK) {
175                         NOTIFICATION_WARN("fail to db_util_close - [%d]", sql_return);
176                 }
177         }
178
179         return err;
180 }
181
182 EXPORT_API int notification_setting_get_setting_by_package_name(const char *package_name, notification_setting_h *setting)
183 {
184         int err = NOTIFICATION_ERROR_NONE;
185         sqlite3 *local_db_handle = NULL;
186         char *sql_query = NULL;
187         char **query_result = NULL;
188         int sql_return;
189         int row_count = 0;
190         int column_count = 0;
191         int i = 0;
192         int col_index = 0;
193         notification_setting_h result_setting_array= NULL;
194
195         if (package_name == NULL || setting == NULL) {
196                 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
197                 err =  NOTIFICATION_ERROR_INVALID_PARAMETER;
198                 goto out;
199         }
200
201         sql_return = db_util_open(DBPATH, &local_db_handle, 0);
202
203         if (sql_return != SQLITE_OK || local_db_handle == NULL) {
204                 NOTIFICATION_ERR("db_util_open failed [%d]", sql_return);
205                 err = NOTIFICATION_ERROR_FROM_DB;
206                 goto out;
207         }
208
209         sql_query = sqlite3_mprintf("SELECT package_name, allow_to_notify, do_not_disturb_except, visibility_class "
210                         "FROM %s "
211                         "WHERE package_name = %Q ", NOTIFICATION_SETTING_DB_TABLE, package_name);
212
213         if (!sql_query) {
214                 NOTIFICATION_ERR("fail to alloc query");
215                 err = NOTIFICATION_ERROR_OUT_OF_MEMORY;
216                 goto out;
217         }
218
219         sql_return = sqlite3_get_table(local_db_handle, sql_query, &query_result, &row_count, &column_count, NULL);
220
221         if (sql_return != SQLITE_OK && sql_return != -1) {
222                 NOTIFICATION_ERR("sqlite3_get_table failed [%d][%s]", sql_return, sql_query);
223                 err = NOTIFICATION_ERROR_FROM_DB;
224                 goto out;
225         }
226
227         if (!row_count) {
228                 NOTIFICATION_DBG ("No setting found for [%s]", package_name);
229                 err= NOTIFICATION_ERROR_NOT_EXIST_ID;
230                 goto out;
231         }
232
233         NOTIFICATION_DBG ("row_count [%d] column_count [%d]", row_count, column_count);
234
235         row_count = 1;
236
237         if (!(result_setting_array = (struct notification_setting*)malloc(sizeof(struct notification_setting) * row_count))) {
238                 NOTIFICATION_ERR("malloc failed...");
239                 err = NOTIFICATION_ERROR_OUT_OF_MEMORY;
240                 goto out;
241         }
242
243         col_index = column_count;
244
245         _get_table_field_data_string(query_result, &(result_setting_array[i].package_name), 1, col_index++);
246         _get_table_field_data_int(query_result, (int*)&(result_setting_array[i].allow_to_notify), col_index++);
247         _get_table_field_data_int(query_result, (int*)&(result_setting_array[i].do_not_disturb_except), col_index++);
248         _get_table_field_data_int(query_result, &(result_setting_array[i].visibility_class), col_index++);
249
250         *setting = result_setting_array;
251
252 out:
253         if (query_result)
254                         sqlite3_free_table(query_result);
255
256         if (sql_query)
257                 sqlite3_free(sql_query);
258
259         if (local_db_handle) {
260                 sql_return = db_util_close(local_db_handle);
261                 if (sql_return != SQLITE_OK) {
262                         NOTIFICATION_WARN("fail to db_util_close - [%d]", sql_return);
263                 }
264         }
265
266         return err;
267 }
268
269 EXPORT_API int notification_setting_get_setting(notification_setting_h *setting)
270 {
271         int ret;
272         char *package_name = NULL;
273
274         package_name = notification_get_pkgname_by_pid();
275
276         if (package_name == NULL)
277                 return NOTIFICATION_ERROR_NOT_EXIST_ID;
278
279         ret = notification_setting_get_setting_by_package_name(package_name, setting);
280
281         free(package_name);
282
283         return ret;
284 }
285
286 EXPORT_API int notification_setting_get_package_name(notification_setting_h setting, char **value)
287 {
288         int err = NOTIFICATION_ERROR_NONE;
289
290         if (setting == NULL || value == NULL) {
291                 NOTIFICATION_ERR("Invalid parameter\n");
292                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
293                 goto out;
294         }
295
296         if (setting->package_name == NULL) {
297                 NOTIFICATION_ERR("setting->package_name is null\n");
298                 err = NOTIFICATION_ERROR_NOT_EXIST_ID;
299                 goto out;
300         }
301
302         *value = SAFE_STRDUP(setting->package_name);
303
304 out:
305
306         return err;
307 }
308
309 EXPORT_API int notification_setting_set_package_name(notification_setting_h setting, char *value)
310 {
311         int err = NOTIFICATION_ERROR_NONE;
312
313         if (setting == NULL || value == NULL) {
314                 NOTIFICATION_ERR("Invalid parameter\n");
315                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
316                 goto out;
317         }
318
319         if (setting->package_name != NULL) {
320                 free(setting->package_name);
321         }
322
323         setting->package_name = SAFE_STRDUP(value);
324
325 out:
326
327         return err;
328 }
329
330 EXPORT_API int notification_setting_get_allow_to_notify(notification_setting_h setting, bool *value)
331 {
332         int err = NOTIFICATION_ERROR_NONE;
333
334         if (setting == NULL || value == NULL) {
335                 NOTIFICATION_ERR("Invalid parameter\n");
336                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
337                 goto out;
338         }
339
340         *value = setting->allow_to_notify;
341
342 out:
343
344         return err;
345 }
346
347 EXPORT_API int notification_setting_set_allow_to_notify(notification_setting_h setting, bool value)
348 {
349         int err = NOTIFICATION_ERROR_NONE;
350
351         if (setting == NULL) {
352                 NOTIFICATION_ERR("Invalid parameter\n");
353                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
354                 goto out;
355         }
356
357         setting->allow_to_notify = value;
358
359 out:
360
361         return err;
362 }
363
364 EXPORT_API int notification_setting_get_do_not_disturb_except(notification_setting_h setting, bool *value)
365 {
366         int err = NOTIFICATION_ERROR_NONE;
367
368         if (setting == NULL || value == NULL) {
369                 NOTIFICATION_ERR("Invalid parameter\n");
370                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
371                 goto out;
372         }
373
374         *value = setting->do_not_disturb_except;
375
376 out:
377
378         return err;
379 }
380
381 EXPORT_API int notification_setting_set_do_not_disturb_except(notification_setting_h setting, bool value)
382 {
383         int err = NOTIFICATION_ERROR_NONE;
384
385         if (setting == NULL) {
386                 NOTIFICATION_ERR("Invalid parameter\n");
387                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
388                 goto out;
389         }
390
391         setting->do_not_disturb_except = value;
392
393 out:
394
395         return err;
396 }
397
398 EXPORT_API int notification_setting_get_visibility_class(notification_setting_h setting, int *value)
399 {
400         int err = NOTIFICATION_ERROR_NONE;
401
402         if (setting == NULL || value == NULL) {
403                 NOTIFICATION_ERR("Invalid parameter\n");
404                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
405                 goto out;
406         }
407
408         *value = setting->visibility_class;
409
410 out:
411
412         return err;
413 }
414
415 EXPORT_API int notification_setting_set_visibility_class(notification_setting_h setting, int value)
416 {
417         int err = NOTIFICATION_ERROR_NONE;
418
419         if (setting == NULL) {
420                 NOTIFICATION_ERR("Invalid parameter\n");
421                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
422                 goto out;
423         }
424
425         setting->visibility_class = value;
426
427 out:
428
429         return err;
430 }
431
432 EXPORT_API int notification_setting_update_setting(notification_setting_h setting)
433 {
434         int err = NOTIFICATION_ERROR_NONE;
435
436         if (setting == NULL) {
437                 NOTIFICATION_ERR("Invalid parameter\n");
438                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
439                 goto out;
440         }
441
442         err = notification_ipc_update_setting(setting);
443         if (err != NOTIFICATION_ERROR_NONE) {
444                 NOTIFICATION_ERR("notification_setting_update_setting returns[%d]\n", err);
445                 goto out;
446         }
447
448 out:
449         return err;
450 }
451
452 EXPORT_API int notification_setting_free_notification(notification_setting_h setting)
453 {
454         int err = NOTIFICATION_ERROR_NONE;
455
456         if (setting == NULL) {
457                         NOTIFICATION_ERR("Invalid parameter\n");
458                         err = NOTIFICATION_ERROR_INVALID_PARAMETER;
459                         goto out;
460                 }
461
462         SAFE_FREE(setting->package_name);
463
464         /* add codes to free all properties */
465
466         SAFE_FREE(setting);
467 out:
468
469         return err;
470 }
471
472 EXPORT_API int notification_setting_db_update(const char *package_name, int allow_to_notify, int do_not_disturb_except, int visibility_class)
473 {
474         int err = NOTIFICATION_ERROR_NONE;
475         sqlite3 *db = NULL;
476         char *sqlbuf = NULL;
477         int sqlret;
478
479         if (package_name == NULL)
480                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
481
482         sqlret = db_util_open(DBPATH, &db, 0);
483         if (sqlret != SQLITE_OK || db == NULL) {
484                 NOTIFICATION_ERR("db_util_open failed [%s][%d]", DBPATH, sqlret);
485                 return NOTIFICATION_ERROR_FROM_DB;
486         }
487
488         sqlbuf = sqlite3_mprintf("UPDATE %s SET allow_to_notify = %d, do_not_disturb_except = %d, visibility_class = %d " \
489                         "WHERE package_name = %Q",
490                         NOTIFICATION_SETTING_DB_TABLE, allow_to_notify, do_not_disturb_except, visibility_class, package_name);
491         if (!sqlbuf) {
492                 NOTIFICATION_ERR("fail to alloc query");
493                 err = NOTIFICATION_ERROR_OUT_OF_MEMORY;
494                 goto return_close_db;
495         }
496
497         err = notification_db_exec(db, sqlbuf, NULL);
498
499         return_close_db:
500         if (sqlbuf)
501                 sqlite3_free(sqlbuf);
502
503         sqlret = db_util_close(db);
504         if (sqlret != SQLITE_OK) {
505                 NOTIFICATION_WARN("fail to db_util_close - [%d]", sqlret);
506         }
507
508         return err;
509 }
510
511 static bool _is_package_in_setting_table(sqlite3 *db, const char *package_name)
512 {
513         sqlite3_stmt *db_statement = NULL;
514         int sqlite3_ret = SQLITE_OK;
515         bool err = true;
516         int field_index = 1;
517
518         sqlite3_ret = sqlite3_prepare_v2(db, "SELECT package_name FROM notification_setting WHERE package_name = ?", -1, &db_statement, NULL);
519
520         if (sqlite3_ret != SQLITE_OK) {
521                 NOTIFICATION_ERR("sqlite3_prepare_v2 failed [%d][%s]", sqlite3_ret, sqlite3_errmsg(db));
522                 err = false;
523                 goto out;
524         }
525
526         sqlite3_bind_text(db_statement, field_index++, package_name, -1, SQLITE_TRANSIENT);
527
528         sqlite3_ret = sqlite3_step(db_statement);
529
530         if (sqlite3_ret == SQLITE_DONE) {
531                 NOTIFICATION_INFO("no matched package_name found[%s][%d]", package_name, sqlite3_ret);
532                 err = false;
533                 goto out;
534         }
535
536         if (sqlite3_ret != SQLITE_OK && sqlite3_ret != SQLITE_ROW) {
537                 NOTIFICATION_ERR("sqlite3_step failed [%d][%s]", sqlite3_ret, sqlite3_errmsg(db));
538                 err = false;
539                 goto out;
540         }
541 out:
542         if (db_statement) {
543                 sqlite3_finalize(db_statement);
544         }
545
546         return err;
547 }
548
549 static int foreach_package_info_callback(const pkgmgrinfo_pkginfo_h package_info, void *user_data)
550 {
551         sqlite3 *db = user_data;
552         sqlite3_stmt *db_statement = NULL;
553         char *package_name = NULL;
554         int pkgmgr_ret = PACKAGE_MANAGER_ERROR_NONE;
555         int sqlite3_ret = SQLITE_OK;
556         int field_index = 1;
557         int err = true;
558
559         if ((pkgmgr_ret = pkgmgrinfo_pkginfo_get_pkgname(package_info, &package_name)) != PACKAGE_MANAGER_ERROR_NONE) {
560                 NOTIFICATION_ERR("package_info_get_package failed [%d]", pkgmgr_ret);
561                 err = false;
562                 goto out;
563         }
564
565         if (_is_package_in_setting_table(db, package_name) == true) {
566                 NOTIFICATION_INFO("[%s] is exist", package_name);
567                 goto out;
568         }
569
570         NOTIFICATION_INFO("[%s] will be inserted", package_name);
571
572         sqlite3_ret = sqlite3_prepare_v2(db, "INSERT INTO notification_setting (package_name) VALUES (?) ", -1, &db_statement, NULL);
573
574         if (sqlite3_ret != SQLITE_OK) {
575                 NOTIFICATION_ERR("sqlite3_prepare_v2 failed [%d][%s]", sqlite3_ret, sqlite3_errmsg(db));
576                 err = false;
577                 goto out;
578         }
579
580         sqlite3_bind_text(db_statement, field_index++, package_name, -1, SQLITE_TRANSIENT);
581
582         sqlite3_ret = sqlite3_step(db_statement);
583
584         NOTIFICATION_INFO("sqlite3_step returns[%d]", sqlite3_ret);
585
586         if (sqlite3_ret != SQLITE_OK && sqlite3_ret != SQLITE_DONE) {
587                 NOTIFICATION_ERR("sqlite3_step failed [%d][%s]", sqlite3_ret, sqlite3_errmsg(db));
588                 err = false;
589         }
590
591 out:
592         if (db_statement) {
593                 sqlite3_finalize(db_statement);
594         }
595
596         NOTIFICATION_INFO("foreach_package_info_callback returns[%d]", err);
597         return err;
598 }
599
600 EXPORT_API int notification_setting_refresh_setting_table()
601 {
602         int err = NOTIFICATION_ERROR_NONE;
603         sqlite3 *db = NULL;
604         int sqlite3_ret = SQLITE_OK;
605         int pkgmgr_ret = PACKAGE_MANAGER_ERROR_NONE;
606         pkgmgrinfo_pkginfo_filter_h filter;
607         uid_t current_uid;
608
609         sqlite3_ret = db_util_open(DBPATH, &db, 0);
610
611         if (sqlite3_ret != SQLITE_OK || db == NULL) {
612                 NOTIFICATION_ERR("db_util_open failed [%s][%d]", DBPATH, sqlite3_ret);
613                 err = NOTIFICATION_ERROR_FROM_DB;
614                 goto out;
615         }
616
617         sqlite3_exec(db, "BEGIN immediate;", NULL, NULL, NULL);
618
619         pkgmgr_ret = pkgmgrinfo_pkginfo_filter_create(&filter);
620         if (pkgmgr_ret != PMINFO_R_OK) {
621                 NOTIFICATION_ERR("pkgmgrinfo_pkginfo_filter_create failed [%d]", pkgmgr_ret);
622                 err = NOTIFICATION_ERROR_FROM_DB;
623                 goto out;
624         }
625
626         pkgmgr_ret = pkgmgrinfo_pkginfo_filter_add_string(filter, PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE, NOTIFICATION_PRIVILEGE);
627         if (pkgmgr_ret != PMINFO_R_OK) {
628                 NOTIFICATION_ERR("pkgmgrinfo_pkginfo_filter_add_string failed [%d]", pkgmgr_ret);
629                 err = NOTIFICATION_ERROR_FROM_DB;
630                 goto out;
631         }
632
633         current_uid = getuid();
634
635         pkgmgr_ret = pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(filter, foreach_package_info_callback, db, current_uid);
636         if (pkgmgr_ret != PMINFO_R_OK) {
637                 NOTIFICATION_ERR("pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo failed [%d]", pkgmgr_ret);
638                 err = NOTIFICATION_ERROR_FROM_DB;
639                 goto out;
640         }
641
642         pkgmgrinfo_pkginfo_filter_destroy(filter);
643
644
645 out:
646
647         if (db) {
648                 if (err == NOTIFICATION_ERROR_NONE) {
649                         sqlite3_exec(db, "END;", NULL, NULL, NULL);
650                 }
651                 else {
652                         sqlite3_exec(db, "ROLLBACK;", NULL, NULL, NULL);
653                 }
654
655                 if ((sqlite3_ret = db_util_close(db)) != SQLITE_OK) {
656                         NOTIFICATION_WARN("fail to db_util_close - [%d]", sqlite3_ret);
657                 }
658         }
659
660         NOTIFICATION_INFO("notification_setting_refresh_setting_table returns [%08X]", err);
661
662         return err;
663 }
664
665 typedef enum {
666         OPERATION_TYPE_INSERT_RECORD = 0,
667         OPERATION_TYPE_DELETE_RECORD = 1,
668 } notification_setting_operation_type;
669
670 static int _notification_setting_alter_package_list(notification_setting_operation_type operation_type, const char *package_name)
671 {
672         sqlite3 *db = NULL;
673         sqlite3_stmt *db_statement = NULL;
674         int sqlite3_ret = SQLITE_OK;
675         int field_index = 1;
676         bool is_package_in_setting_table = false;
677         int err = NOTIFICATION_ERROR_NONE;
678
679         sqlite3_ret = db_util_open(DBPATH, &db, 0);
680
681         if (sqlite3_ret != SQLITE_OK || db == NULL) {
682                 NOTIFICATION_ERR("db_util_open failed [%s][%d]", DBPATH, sqlite3_ret);
683                 err = NOTIFICATION_ERROR_FROM_DB;
684                 goto out;
685         }
686
687         sqlite3_exec(db, "BEGIN immediate;", NULL, NULL, NULL);
688
689         is_package_in_setting_table = _is_package_in_setting_table(db, package_name);
690
691         switch (operation_type) {
692         case OPERATION_TYPE_INSERT_RECORD :
693                 if (is_package_in_setting_table == true) {
694                         NOTIFICATION_INFO("[%s] is already exist", package_name);
695                         goto out;
696                 }
697                 NOTIFICATION_INFO("[%s] will be inserted", package_name);
698                 sqlite3_ret = sqlite3_prepare_v2(db, "INSERT INTO notification_setting (package_name) VALUES (?) ", -1, &db_statement, NULL);
699                 break;
700
701         case OPERATION_TYPE_DELETE_RECORD :
702                 if (is_package_in_setting_table == false) {
703                         NOTIFICATION_INFO("[%s] is not exist", package_name);
704                         goto out;
705                 }
706                 NOTIFICATION_INFO("[%s] will be removed", package_name);
707                 sqlite3_ret = sqlite3_prepare_v2(db, "DELETE FROM notification_setting WHERE package_name = ? ", -1, &db_statement, NULL);
708                 break;
709         default :
710                 break;
711         }
712
713         if (sqlite3_ret != SQLITE_OK) {
714                 NOTIFICATION_ERR("sqlite3_prepare_v2 failed [%d][%s]", sqlite3_ret, sqlite3_errmsg(db));
715                 err = NOTIFICATION_ERROR_FROM_DB;
716                 goto out;
717         }
718
719         sqlite3_bind_text(db_statement, field_index++, package_name, -1, SQLITE_TRANSIENT);
720
721         sqlite3_ret = sqlite3_step(db_statement);
722
723         if (sqlite3_ret != SQLITE_OK && sqlite3_ret != SQLITE_DONE) {
724                 NOTIFICATION_ERR("sqlite3_step failed [%d][%s]", sqlite3_ret, sqlite3_errmsg(db));
725                 err = NOTIFICATION_ERROR_FROM_DB;
726         }
727
728 out:
729         if (db_statement) {
730                 sqlite3_finalize(db_statement);
731         }
732
733         if (db) {
734                 NOTIFICATION_INFO("err [%d]", err);
735                 if (err == NOTIFICATION_ERROR_NONE) {
736                         sqlite3_exec(db, "END;", NULL, NULL, NULL);
737                 }
738                 else {
739                         sqlite3_exec(db, "ROLLBACK;", NULL, NULL, NULL);
740                 }
741
742                 if ((sqlite3_ret = db_util_close(db)) != SQLITE_OK) {
743                         NOTIFICATION_WARN("fail to db_util_close - [%d]", sqlite3_ret);
744                 }
745         }
746
747         return err;
748 }
749
750 bool privilege_info_cb(const char *privilege_name, void *user_data)
751 {
752         bool *found = user_data;
753
754         if (privilege_name && strcmp(NOTIFICATION_PRIVILEGE, privilege_name) == 0) {
755                 *found = true;
756                 return false;
757         }
758
759         return true;
760 }
761
762 static bool _has_privilege(const char *package_id)
763 {
764         bool found = false;
765         int error_from_package_info = PACKAGE_MANAGER_ERROR_NONE;
766         package_info_h package_info = NULL;
767
768         error_from_package_info = package_info_create(package_id, &package_info);
769         if (error_from_package_info != PACKAGE_MANAGER_ERROR_NONE) {
770                 NOTIFICATION_ERR("package_info_create failed [%d]", error_from_package_info);
771                 goto out;
772         }
773
774         error_from_package_info = package_info_foreach_privilege_info(package_info, privilege_info_cb, &found);
775
776         if (error_from_package_info != PACKAGE_MANAGER_ERROR_NONE) {
777                 NOTIFICATION_ERR("package_info_foreach_privilege_info failed [%d]", error_from_package_info);
778                 goto out;
779         }
780
781 out:
782
783         if (package_info) {
784                 package_info_destroy(package_info);
785         }
786
787         return found;
788 }
789
790 EXPORT_API int notification_setting_insert_package(const char *package_id)
791 {
792         int err = NOTIFICATION_ERROR_NONE;
793
794         if (_has_privilege(package_id) == true) {
795                 err = _notification_setting_alter_package_list(OPERATION_TYPE_INSERT_RECORD, package_id);
796         }
797
798         return err;
799 }
800
801 EXPORT_API int notification_setting_delete_package(const char *package_id)
802 {
803         return _notification_setting_alter_package_list(OPERATION_TYPE_DELETE_RECORD, package_id);
804 }
805
806 /* system setting --------------------------------*/
807
808 EXPORT_API int notification_system_setting_load_system_setting(notification_system_setting_h *system_setting)
809 {
810         int err = NOTIFICATION_ERROR_NONE;
811         sqlite3 *local_db_handle = NULL;
812         char *sql_query = NULL;
813         char **query_result = NULL;
814         int sql_return;
815         int row_count = 0;
816         int column_count = 0;
817         int col_index = 0;
818         notification_system_setting_h result_system_setting= NULL;
819
820         if (system_setting == NULL) {
821                 NOTIFICATION_ERR("NOTIFICATION_ERROR_INVALID_PARAMETER");
822                 err =  NOTIFICATION_ERROR_INVALID_PARAMETER;
823                 goto out;
824         }
825
826         sql_return = db_util_open(DBPATH, &local_db_handle, 0);
827
828         if (sql_return != SQLITE_OK || local_db_handle == NULL) {
829                 NOTIFICATION_ERR("db_util_open failed [%d]", sql_return);
830                 err = NOTIFICATION_ERROR_FROM_DB;
831                 goto out;
832         }
833
834         sql_query = sqlite3_mprintf("SELECT do_not_disturb, visibility_class "
835                         "FROM %s ", NOTIFICATION_SYSTEM_SETTING_DB_TABLE);
836
837         if (!sql_query) {
838                 NOTIFICATION_ERR("fail to alloc query");
839                 err = NOTIFICATION_ERROR_OUT_OF_MEMORY;
840                 goto out;
841         }
842
843         sql_return = sqlite3_get_table(local_db_handle, sql_query, &query_result, &row_count, &column_count, NULL);
844
845         if (sql_return != SQLITE_OK && sql_return != -1) {
846                 NOTIFICATION_ERR("sqlite3_get_table failed [%d][%s]", sql_return, sql_query);
847                 err = NOTIFICATION_ERROR_FROM_DB;
848                 goto out;
849         }
850
851         if (!row_count) {
852                 NOTIFICATION_DBG ("No setting found...");
853                 err= NOTIFICATION_ERROR_NOT_EXIST_ID;
854                 goto out;
855         }
856
857         NOTIFICATION_DBG ("row_count [%d] column_count [%d]", row_count, column_count);
858
859         row_count = 1;
860
861         if (!(result_system_setting = (struct notification_system_setting*)malloc(sizeof(struct notification_system_setting)))) {
862                 NOTIFICATION_ERR("malloc failed...");
863                 err = NOTIFICATION_ERROR_OUT_OF_MEMORY;
864                 goto out;
865         }
866
867         col_index = column_count;
868
869         _get_table_field_data_int(query_result, (int*)&(result_system_setting->do_not_disturb), col_index++);
870         _get_table_field_data_int(query_result, &(result_system_setting->visibility_class), col_index++);
871
872         *system_setting = result_system_setting;
873
874 out:
875         if (query_result)
876                         sqlite3_free_table(query_result);
877
878         if (sql_query)
879                 sqlite3_free(sql_query);
880
881         if (local_db_handle) {
882                 sql_return = db_util_close(local_db_handle);
883                 if (sql_return != SQLITE_OK) {
884                         NOTIFICATION_WARN("fail to db_util_close - [%d]", sql_return);
885                 }
886         }
887
888         return err;
889 }
890
891 EXPORT_API int notification_system_setting_update_system_setting(notification_system_setting_h system_setting)
892 {
893         int err = NOTIFICATION_ERROR_NONE;
894
895         if (system_setting == NULL) {
896                 NOTIFICATION_ERR("Invalid parameter\n");
897                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
898                 goto out;
899         }
900
901         err = notification_ipc_update_system_setting(system_setting);
902         if (err != NOTIFICATION_ERROR_NONE) {
903                 NOTIFICATION_ERR("notification_ipc_update_system_setting returns[%d]\n", err);
904                 goto out;
905         }
906
907 out:
908         return err;
909 }
910
911 EXPORT_API int notification_system_setting_free_system_setting(notification_system_setting_h system_setting)
912 {
913         int err = NOTIFICATION_ERROR_NONE;
914
915         if (system_setting == NULL) {
916                         NOTIFICATION_ERR("Invalid parameter\n");
917                         err = NOTIFICATION_ERROR_INVALID_PARAMETER;
918                         goto out;
919                 }
920
921         /* add codes to free all properties */
922
923         SAFE_FREE(system_setting);
924
925 out:
926
927         return err;
928 }
929
930 EXPORT_API int notification_system_setting_get_do_not_disturb(notification_system_setting_h system_setting, bool *value)
931 {
932         int err = NOTIFICATION_ERROR_NONE;
933
934         if (system_setting == NULL || value == NULL) {
935                 NOTIFICATION_ERR("Invalid parameter\n");
936                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
937                 goto out;
938         }
939
940         *value = system_setting->do_not_disturb;
941
942 out:
943
944         return err;
945 }
946
947 EXPORT_API int notification_system_setting_set_do_not_disturb(notification_system_setting_h system_setting, bool value)
948 {
949         int err = NOTIFICATION_ERROR_NONE;
950
951         if (system_setting == NULL) {
952                 NOTIFICATION_ERR("Invalid parameter\n");
953                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
954                 goto out;
955         }
956
957         system_setting->do_not_disturb = value;
958
959 out:
960
961         return err;
962 }
963
964 EXPORT_API int notification_system_setting_get_visibility_class(notification_system_setting_h system_setting, int *value)
965 {
966         int err = NOTIFICATION_ERROR_NONE;
967
968         if (system_setting == NULL || value == NULL) {
969                 NOTIFICATION_ERR("Invalid parameter\n");
970                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
971                 goto out;
972         }
973
974         *value = system_setting->visibility_class;
975
976 out:
977
978         return err;
979 }
980
981 EXPORT_API int notification_system_setting_set_visibility_class(notification_system_setting_h system_setting, int value)
982 {
983         int err = NOTIFICATION_ERROR_NONE;
984
985         if (system_setting == NULL) {
986                 NOTIFICATION_ERR("Invalid parameter\n");
987                 err = NOTIFICATION_ERROR_INVALID_PARAMETER;
988                 goto out;
989         }
990
991         system_setting->visibility_class = value;
992
993 out:
994
995         return err;
996 }
997
998
999 EXPORT_API int notification_setting_db_update_system_setting(int do_not_disturb, int visibility_class)
1000 {
1001         int err = NOTIFICATION_ERROR_NONE;
1002         int sqlret;
1003         int field_index = 1;
1004         sqlite3 *db = NULL;
1005         sqlite3_stmt *db_statement = NULL;
1006
1007         sqlret = db_util_open(DBPATH, &db, 0);
1008
1009         if (sqlret != SQLITE_OK || db == NULL) {
1010                 NOTIFICATION_ERR("db_util_open failed [%s][%d][%s]", DBPATH, sqlret, sqlite3_errmsg(db));
1011                 err =  NOTIFICATION_ERROR_FROM_DB;
1012                 goto return_close_db;
1013         }
1014
1015         sqlite3_exec(db, "BEGIN immediate;", NULL, NULL, NULL);
1016
1017         sqlret = sqlite3_prepare_v2(db, "UPDATE notification_system_setting SET do_not_disturb = ?, visibility_class = ?;", -1, &db_statement, NULL);
1018
1019         if (sqlret != SQLITE_OK) {
1020                 NOTIFICATION_ERR("sqlite3_prepare_v2 failed [%d][%s]", sqlret, sqlite3_errmsg(db));
1021                 err =  NOTIFICATION_ERROR_FROM_DB;
1022                 goto return_close_db;
1023         }
1024
1025         sqlite3_bind_int(db_statement, field_index++, do_not_disturb);
1026         sqlite3_bind_int(db_statement, field_index++, visibility_class);
1027
1028         sqlret = sqlite3_step(db_statement);
1029
1030         if (sqlret != SQLITE_OK && sqlret != SQLITE_DONE) {
1031                 NOTIFICATION_ERR("sqlite3_step failed [%d][%s]", sqlret, sqlite3_errmsg(db));
1032                 err =  NOTIFICATION_ERROR_FROM_DB;
1033                 goto return_close_db;
1034         }
1035
1036         sqlret = sqlite3_changes(db);
1037
1038         if (sqlret == 0) {
1039                 NOTIFICATION_WARN("No changes on DB");
1040         }
1041
1042 return_close_db:
1043         if (db_statement) {
1044                 sqlite3_finalize(db_statement);
1045         }
1046
1047         if (db) {
1048                 if (err == NOTIFICATION_ERROR_NONE) {
1049                         sqlite3_exec(db, "END;", NULL, NULL, NULL);
1050                 }
1051                 else {
1052                         sqlite3_exec(db, "ROLLBACK;", NULL, NULL, NULL);
1053                 }
1054                 sqlret = db_util_close(db);
1055         }
1056
1057         if (sqlret != SQLITE_OK) {
1058                 NOTIFICATION_WARN("fail to db_util_close - [%d]", sqlret);
1059         }
1060
1061         return err;
1062 }
1063
1064 /* OLD IMPLEMENTATION ----------------------------*/
1065 #define NOTIFICATION_SETTING_DB "notification_setting"
1066 #define NOTIFICATION_SETTING_DB_PATH "/opt/usr/dbspace/.notification_parser.db"
1067
1068 struct _notification_setting_h {
1069         char *appid;
1070         char *notification;
1071         char *sounds;
1072         char *contents;
1073         char *badge;
1074         char *pkgid;
1075 };
1076
1077 struct prop_table {
1078         const char *property;
1079         const char *column;
1080         const char *default_value;
1081 };
1082
1083 static struct prop_table g_prop_table[] = {
1084         {
1085                 .property = "OPT_NOTIFICATION",
1086                 .column = "notification",
1087                 .default_value = "ON",
1088         },
1089         {
1090                 .property = "OPT_SOUNDS",
1091                 .column = "sounds",
1092                 .default_value = "ON",
1093         },
1094         {
1095                 .property = "OPT_CONTENTS",
1096                 .column = "contents",
1097                 .default_value = "ON",
1098         },
1099         {
1100                 .property = "OPT_BADGE",
1101                 .column = "badge",
1102                 .default_value = "ON",
1103         },
1104         {
1105                 .property = NULL,
1106                 .column = NULL,
1107                 .default_value = NULL,
1108         }
1109 };
1110
1111 static const char *_get_prop_column(const char *property)
1112 {
1113         int i;
1114
1115         for (i = 0; g_prop_table[i].property; i++) {
1116                 if (strcmp(g_prop_table[i].property, property))
1117                         continue;
1118
1119                 return g_prop_table[i].column;
1120         }
1121
1122         return NULL;
1123 }
1124
1125 #ifdef TBD
1126 static const char *_get_prop_default_value(const char *property)
1127 {
1128         int i;
1129
1130         for (i = 0; g_prop_table[i].property; i++) {
1131                 if (strcmp(g_prop_table[i].property, property))
1132                         continue;
1133
1134                 return g_prop_table[i].default_value;
1135         }
1136
1137         return NULL;
1138 }
1139 #endif
1140
1141 static int _is_record_exist(const char *pkgname, sqlite3 *db)
1142 {
1143         sqlite3_stmt *stmt = NULL;
1144         int count = 0;
1145         int result = NOTIFICATION_ERROR_NONE;
1146         char *sqlbuf = NULL;
1147         int sqlret;
1148
1149         if (!pkgname)
1150                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1151
1152         if (!db)
1153                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1154
1155         sqlbuf = sqlite3_mprintf("SELECT count(*) FROM %s WHERE " \
1156                         "appid = %Q",
1157                         NOTIFICATION_SETTING_DB, pkgname);
1158
1159         if (!sqlbuf) {
1160                 NOTIFICATION_ERR("fail to alloc sql query");
1161                 return NOTIFICATION_ERROR_OUT_OF_MEMORY;
1162         }
1163
1164         sqlret = sqlite3_prepare_v2(db, sqlbuf, -1, &stmt, NULL);
1165         if (sqlret != SQLITE_OK) {
1166                 NOTIFICATION_ERR("DB err [%s]", sqlite3_errmsg(db));
1167                 NOTIFICATION_ERR("query[%s]", sqlbuf);
1168                 result = NOTIFICATION_ERROR_FROM_DB;
1169                 goto free_and_return;
1170         }
1171
1172         sqlret = sqlite3_step(stmt);
1173         if (sqlret == SQLITE_ROW)
1174                 count = sqlite3_column_int(stmt, 0);
1175         else
1176                 count = 0;
1177
1178         if (count > 0)
1179                 result = NOTIFICATION_ERROR_ALREADY_EXIST_ID;
1180         else
1181                 result = NOTIFICATION_ERROR_NOT_EXIST_ID;
1182
1183         free_and_return:
1184         if (sqlbuf)
1185                 sqlite3_free(sqlbuf);
1186
1187         if (stmt)
1188                 sqlite3_finalize(stmt);
1189
1190         return result;
1191 }
1192
1193 EXPORT_API int notification_setting_db_set(const char *pkgname, const char *property, const char *value)
1194 {
1195         int ret = NOTIFICATION_ERROR_NONE;
1196         int result = NOTIFICATION_ERROR_NONE;
1197         sqlite3 *db = NULL;
1198         char *sqlbuf = NULL;
1199         int sqlret;
1200         const char *column = NULL;
1201
1202         if (!pkgname)
1203                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1204
1205         if (!property)
1206                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1207
1208         if (!value)
1209                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1210
1211         column = _get_prop_column(property);
1212         if (!column)
1213                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1214
1215         sqlret = db_util_open(NOTIFICATION_SETTING_DB_PATH, &db, 0);
1216         if (sqlret != SQLITE_OK || !db) {
1217                 NOTIFICATION_ERR("fail to db_util_open - [%d]", sqlret);
1218                 return NOTIFICATION_ERROR_FROM_DB;
1219         }
1220
1221         ret = _is_record_exist(pkgname, db);
1222         if (ret != NOTIFICATION_ERROR_ALREADY_EXIST_ID) {
1223                 result = ret;
1224                 goto return_close_db;
1225         }
1226
1227         sqlbuf = sqlite3_mprintf("UPDATE %s SET %s = %Q " \
1228                         "WHERE appid = %Q",
1229                         NOTIFICATION_SETTING_DB, column, value, pkgname);
1230         if (!sqlbuf) {
1231                 NOTIFICATION_ERR("fail to alloc query");
1232                 result = NOTIFICATION_ERROR_OUT_OF_MEMORY;
1233                 goto return_close_db;
1234         }
1235
1236         result = notification_db_exec(db, sqlbuf, NULL);
1237
1238         return_close_db:
1239         if (sqlbuf)
1240                 sqlite3_free(sqlbuf);
1241
1242         sqlret = db_util_close(db);
1243         if (sqlret != SQLITE_OK) {
1244                 NOTIFICATION_WARN("fail to db_util_close - [%d]", sqlret);
1245         }
1246
1247         return result;
1248 }
1249
1250 EXPORT_API int notification_setting_db_get(const char *pkgname, const char *property, char **value)
1251 {
1252         int ret = NOTIFICATION_ERROR_NONE;
1253         int result = NOTIFICATION_ERROR_NONE;
1254         sqlite3 *db = NULL;
1255         char *sqlbuf = NULL;
1256         sqlite3_stmt *stmt = NULL;
1257         int sqlret;
1258         const char *column = NULL;
1259
1260         if (!pkgname)
1261                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1262
1263         if (!property)
1264                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1265
1266         if (!value)
1267                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1268
1269         column = _get_prop_column(property);
1270         if (!column)
1271                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1272
1273         sqlret = db_util_open(NOTIFICATION_SETTING_DB_PATH, &db, 0);
1274         if (sqlret != SQLITE_OK || !db) {
1275                 NOTIFICATION_ERR("fail to db_util_open - [%d]", sqlret);
1276                 return NOTIFICATION_ERROR_FROM_DB;
1277         }
1278
1279         ret = _is_record_exist(pkgname, db);
1280         if (ret != NOTIFICATION_ERROR_ALREADY_EXIST_ID) {
1281                 result = ret;
1282                 goto return_close_db;
1283         }
1284
1285         sqlbuf = sqlite3_mprintf("SELECT %s FROM %s " \
1286                         "WHERE appid = %Q",
1287                         column, NOTIFICATION_SETTING_DB, pkgname);
1288         if (!sqlbuf) {
1289                 NOTIFICATION_ERR("fail to alloc query");
1290                 result = NOTIFICATION_ERROR_OUT_OF_MEMORY;
1291                 goto return_close_db;
1292         }
1293
1294         sqlret = sqlite3_prepare_v2(db, sqlbuf, -1, &stmt, NULL);
1295         if (sqlret != SQLITE_OK) {
1296                 NOTIFICATION_ERR("fail to prepare %s - [%s]",
1297                                 sqlbuf, sqlite3_errmsg(db));
1298                 result = NOTIFICATION_ERROR_FROM_DB;
1299                 goto return_close_db;
1300         }
1301
1302         sqlret = sqlite3_step(stmt);
1303         if (sqlret == SQLITE_ROW) {
1304                 int get_bytes = sqlite3_column_bytes(stmt, 0);
1305                 char *get_data = (char *)calloc(get_bytes + 1, sizeof(char));
1306                 if (get_data != NULL) {
1307                         memcpy(get_data, sqlite3_column_text(stmt, 0),
1308                                         get_bytes * sizeof(char));
1309                         get_data[get_bytes] = '\0';
1310                         *value = get_data;
1311                 } else {
1312                         NOTIFICATION_ERR("fail to alloc query");
1313                         result = NOTIFICATION_ERROR_OUT_OF_MEMORY;
1314                         goto return_close_db;
1315                 }
1316         }
1317
1318         return_close_db:
1319         if (sqlbuf)
1320                 sqlite3_free(sqlbuf);
1321
1322         if (stmt)
1323                 sqlite3_finalize(stmt);
1324
1325         sqlret = db_util_close(db);
1326         if (sqlret != SQLITE_OK)
1327                 NOTIFICATION_WARN("fail to db_util_close - [%d]", sqlret);
1328
1329         return result;
1330 }
1331
1332 EXPORT_API int notification_setting_property_set(const char *pkgname, const char *property, const char *value)
1333 {
1334         int ret = 0;
1335
1336         if (!pkgname)
1337                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1338
1339         if (!property)
1340                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1341
1342         if (!value)
1343                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1344
1345         ret = notification_ipc_noti_setting_property_set(pkgname, property, value);
1346         if (ret != NOTIFICATION_ERROR_NONE) {
1347                 return ret;
1348         }
1349
1350         return NOTIFICATION_ERROR_NONE;
1351 }
1352
1353 EXPORT_API int notification_setting_property_get(const char *pkgname, const char *property, char **value)
1354 {
1355         int ret = 0;
1356
1357         if (!pkgname)
1358                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1359
1360         if (!property)
1361                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1362
1363         if (!value)
1364                 return NOTIFICATION_ERROR_INVALID_PARAMETER;
1365
1366         ret = notification_ipc_noti_setting_property_get(pkgname, property, value);
1367         if (ret != NOTIFICATION_ERROR_NONE) {
1368                 return ret;
1369         }
1370
1371         return NOTIFICATION_ERROR_NONE;
1372 }
1373