1. New API set for notification settings.
[platform/core/api/notification.git] / src / notification_permission.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
27 #include <notification.h>
28 #include <notification_db.h>
29 #include <notification_noti.h>
30 #include <notification_debug.h>
31 #include <notification_ipc.h>
32 #include <notification_private.h>
33
34 #define NOTIFICATION_DB_ACCESS_READ 0
35 #define NOTIFICATION_DB_ACCESS_WRITE 1
36
37 #if 0
38 int notification_permission_check_by_pid(const char *noti_pkgname, int pid, int access) {
39         int ret = 0;
40         char pkgname[512 + 1] = { 0, };
41         bool preload = false;
42         package_manager_compare_result_type_e compare_result;
43
44         //get pkgname by pid
45         const char *pkgname = aul_app_get_pkgname_bypid(pid);
46         ret = aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname));
47         if (ret == AUL_R_OK) {
48                 if (strcmp(pkgname, noti_pkgname) == 0) {
49                         return NOTIFICATION_ERROR_NONE;
50                 }
51
52                 package_manager_is_preload_package_by_app_id(pkgname, &preload);
53                 if (preload == true) {
54                         return NOTIFICATION_ERROR_NONE;
55                 }
56
57                 package_manager_compare_package_cert_info(noti_pkgname, &compare_result);
58                 if (compare_result == PACKAGE_MANAGER_COMPARE_MATCH ) {
59                         return NOTIFICATION_ERROR_NONE;
60                 }
61         }
62
63         return NOTIFICATION_ERROR_PERMISSION_DENIED;
64 }
65 #endif