Apply coding rule
[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 {
40         int ret = 0;
41         char pkgname[512 + 1] = { 0, };
42         bool preload = false;
43         package_manager_compare_result_type_e compare_result;
44
45         /* get pkgname by pid */
46         const char *pkgname = aul_app_get_pkgname_bypid(pid);
47         ret = aul_app_get_pkgname_bypid(pid, pkgname, sizeof(pkgname));
48         if (ret == AUL_R_OK) {
49                 if (strcmp(pkgname, noti_pkgname) == 0)
50                         return NOTIFICATION_ERROR_NONE;
51
52                 package_manager_is_preload_package_by_app_id(pkgname, &preload);
53                 if (preload == true)
54                         return NOTIFICATION_ERROR_NONE;
55
56                 package_manager_compare_package_cert_info(noti_pkgname, &compare_result);
57                 if (compare_result == PACKAGE_MANAGER_COMPARE_MATCH)
58                         return NOTIFICATION_ERROR_NONE;
59         }
60
61         return NOTIFICATION_ERROR_PERMISSION_DENIED;
62 }
63 #endif