2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef _PRIVACY_CHECKER_H_
18 #define _PRIVACY_CHECKER_H_
26 #include <PrivacyManagerTypes.h>
27 #include <dbus/dbus.h>
32 class EXTERN_API PrivacyChecker
35 static std::map < std::string, bool > m_privacyCache;
36 static std::map < std::string, std::map < std::string, bool > > m_privacyInfoCache;
37 static std::string m_pkgId;
38 static bool m_isInitialized;
39 static std::mutex m_cacheMutex;
40 static DBusConnection* m_pDBusConnection;
41 static GMainLoop* m_pLoop;
42 static GMainContext* m_pHandlerGMainContext;
43 static pthread_t m_signalThread;
46 static int initializeDbus(void);
47 static int finalizeDbus(void);
48 static int updateCache(const std::string pkgId, std::string privacyId, std::map < std::string, bool >& pkgCacheMap);
49 static int updateCache(const std::string pkgId, std::map < std::string, bool >& pkgCacheMap);
50 static void printCache(void);
51 static void* runSignalListenerThread(void* pData);
52 static int getCurrentPkgId(std::string& pkgId);
53 static int check(const std::string privacyId, std::map < std::string, bool >& privacyMap);
56 // for Checking in App Process
57 static int initialize(const std::string pkgId);
58 static int check(const std::string pkgId, const std::string privacyId);
59 static int checkWithPrivilege(const std::string pkgId, const std::string privilegeId);
60 static int checkWithDeviceCap(const std::string pkgId, const std::string deviceCap);
62 // for Checking in Server Process
63 static int initialize(void);
64 static int check(const std::string privacyId);
65 static int checkWithPrivilege(const std::string privilegeId);
66 static int checkWithDeviceCap(const std::string deviceCap);
69 static int finalize(void);
70 static DBusHandlerResult handleNotification(DBusConnection* connection, DBusMessage* message, void* user_data);
73 #endif // _PRIVACY_CHECKER_H_