Fix prevent warning and Filter out preloaded app
authorHyunwoo Kim <hwlove.kim@samsung.com>
Sat, 13 Apr 2013 15:01:19 +0000 (00:01 +0900)
committerHyunwoo Kim <hwlove.kim@samsung.com>
Sun, 14 Apr 2013 06:28:51 +0000 (15:28 +0900)
Change-Id: Ic0962de0c56f0d87beac00f3071ce5ed6be398b1
Signed-off-by: Hyunwoo Kim <hwlove.kim@samsung.com>
capi/src/privacy_info.c
client/CMakeLists.txt
common/inc/PrivacyDb.h
common/inc/Utils.h
common/src/PrivacyDb.cpp
packaging/privacy-manager.spec
pkgmgr_plugin/CMakeLists.txt
server/CMakeLists.txt
server/src/CMakeLists.txt

index 3f88e21f6b926ab059593303d3a637b2d723cbcc..218ba6142a8fa65f9f8bcab30e2741da00b82d10 100644 (file)
@@ -1,34 +1,34 @@
-/*\r
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the License);\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an AS IS BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License. \r
- */\r
-\r
-#include <stdlib.h>\r
-#include <privacy_manager.h>\r
-#include <privacy_info.h>\r
-#include <privacy_manager_client.h>\r
-#include <privacy_manager_client_types.h>\r
-#include <privacy_info_client.h>\r
-#include <privacy_manager_types_private.h>\r
-\r
-static int _privacy_info_convert_error(int error)\r
-{\r
-       int ret = PRIV_MGR_ERROR_SUCCESS;\r
-\r
-       switch (error) \r
-       {\r
-       case PRIV_MGR_ERROR_SUCCESS:\r
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <stdlib.h>
+#include <privacy_manager.h>
+#include <privacy_info.h>
+#include <privacy_manager_client.h>
+#include <privacy_manager_client_types.h>
+#include <privacy_info_client.h>
+#include <privacy_manager_types_private.h>
+
+static int _privacy_info_convert_error(int error)
+{
+       int ret = PRIV_MGR_ERROR_SUCCESS;
+
+       switch (error) 
+       {
+       case PRIV_MGR_ERROR_SUCCESS:
                ret = PRIVACY_MANAGER_ERROR_NONE;
                break;
        case PRIV_MGR_ERROR_INVALID_PARAMETER:
@@ -46,87 +46,90 @@ static int _privacy_info_convert_error(int error)
        case PRIV_MGR_ERROR_DB_ERROR:
                ret = PRIVACY_MANAGER_ERROR_DB_FAILED;
                break;
-       case PRIV_MGR_ERROR_IPC_ERROR:\r
-               ret = PRIVACY_MANAGER_ERROR_IPC_FAILED;\r
-               break;\r
-       }\r
-       return ret;\r
-}\r
-\r
-int privacy_info_destroy(privacy_info_h privacy_info)\r
-{\r
-       int retval;\r
-       if (privacy_info == NULL)\r
-               return PRIV_MGR_ERROR_INVALID_PARAMETER;\r
-\r
-       if (privacy_info->privacy_info_client)\r
-       {\r
-               retval = privacy_info_client_s_destroy(privacy_info->privacy_info_client);\r
-               if (retval != PRIV_MGR_ERROR_SUCCESS)\r
-                       return retval;\r
-       }\r
-\r
-       free (privacy_info);\r
-\r
-       return PRIV_MGR_ERROR_SUCCESS;\r
-}\r
-\r
-int privacy_info_get_privacy_id(privacy_info_h privacy_info, char **package)\r
-{\r
-       int retval = privacy_info_client_get_privacy_id(privacy_info->privacy_info_client, package);\r
-\r
-       return _privacy_info_convert_error(retval);\r
-}\r
-\r
-int privacy_info_get_privacy_display_name(struct privacy_info_s* privacy_info, char **name)\r
-{\r
-       int retval = privacy_info_client_get_privacy_display_name(privacy_info->privacy_info_client, name);\r
-\r
-       return  _privacy_info_convert_error(retval);\r
-}\r
-\r
-int privacy_info_get_privacy_description(struct privacy_info_s* privacy_info, char **description)\r
-{\r
-       int retval = privacy_info_client_get_privacy_description(privacy_info->privacy_info_client, description);\r
-\r
-       return  _privacy_info_convert_error(retval);\r
-}\r
-\r
-int privacy_info_is_enabled(struct privacy_info_s* privacy_info, bool *enable)\r
-{\r
-       int retval = privacy_info_client_is_enabled(privacy_info->privacy_info_client, enable);\r
-\r
-       return  _privacy_info_convert_error(retval);\r
-}\r
-\r
-int privacy_info_create(const char *privacy_id, privacy_info_h *privacy_info)\r
-{\r
-       int retval;\r
-       privacy_info_client_s* privacy_info_client = NULL;\r
-       \r
-       retval = create_privacy_info_client_s(privacy_id, false, &privacy_info_client);\r
-       if  (retval != PRIV_MGR_ERROR_SUCCESS)\r
-               return _privacy_info_convert_error(retval);\r
-\r
-       privacy_info_h privacy_info_temp = NULL;\r
-       privacy_info_temp = (struct privacy_info_s*) calloc(1, sizeof(struct privacy_info_s));\r
-       if (privacy_info_temp == NULL)\r
-               return PRIVACY_MANAGER_ERROR_OUT_OF_MEMORY;\r
-       \r
-       privacy_info_temp->privacy_info_client = privacy_info_client;\r
-\r
-       *privacy_info = privacy_info_temp;\r
-\r
-       return PRIVACY_MANAGER_ERROR_NONE;\r
-}\r
-\r
-int privacy_info_clone(privacy_info_h *clone, privacy_info_h privacy_info)\r
-{\r
-       int retval;\r
-       if (clone == NULL || privacy_info == NULL)\r
-               return PRIVACY_MANAGER_ERROR_INVALID_PARAMETER;\r
-       \r
-       retval = privacy_info_create(privacy_info->privacy_info_client->privacy_id, clone);\r
-\r
-       return retval;\r
+       case PRIV_MGR_ERROR_IPC_ERROR:
+               ret = PRIVACY_MANAGER_ERROR_IPC_FAILED;
+               break;
+       }
+       return ret;
+}
+
+int privacy_info_destroy(privacy_info_h privacy_info)
+{
+       int retval;
+       if (privacy_info == NULL)
+               return PRIV_MGR_ERROR_INVALID_PARAMETER;
+
+       if (privacy_info->privacy_info_client)
+       {
+               retval = privacy_info_client_s_destroy(privacy_info->privacy_info_client);
+               if (retval != PRIV_MGR_ERROR_SUCCESS)
+                       return retval;
+       }
+
+       free (privacy_info);
+
+       return PRIV_MGR_ERROR_SUCCESS;
+}
+
+int privacy_info_get_privacy_id(privacy_info_h privacy_info, char **package)
+{
+       int retval = privacy_info_client_get_privacy_id(privacy_info->privacy_info_client, package);
+
+       return _privacy_info_convert_error(retval);
+}
+
+int privacy_info_get_privacy_display_name(struct privacy_info_s* privacy_info, char **name)
+{
+       int retval = privacy_info_client_get_privacy_display_name(privacy_info->privacy_info_client, name);
+
+       return  _privacy_info_convert_error(retval);
+}
+
+int privacy_info_get_privacy_description(struct privacy_info_s* privacy_info, char **description)
+{
+       int retval = privacy_info_client_get_privacy_description(privacy_info->privacy_info_client, description);
+
+       return  _privacy_info_convert_error(retval);
+}
+
+int privacy_info_is_enabled(struct privacy_info_s* privacy_info, bool *enable)
+{
+       int retval = privacy_info_client_is_enabled(privacy_info->privacy_info_client, enable);
+
+       return  _privacy_info_convert_error(retval);
+}
+
+int privacy_info_create(const char *privacy_id, privacy_info_h *privacy_info)
+{
+       int retval;
+       privacy_info_client_s* privacy_info_client = NULL;
+       
+       retval = create_privacy_info_client_s(privacy_id, false, &privacy_info_client);
+       if  (retval != PRIV_MGR_ERROR_SUCCESS)
+               return _privacy_info_convert_error(retval);
+
+       privacy_info_h privacy_info_temp = NULL;
+       privacy_info_temp = (struct privacy_info_s*) calloc(1, sizeof(struct privacy_info_s));
+       if (privacy_info_temp == NULL)
+       {
+               privacy_info_client_s_destroy(privacy_info_client);
+               return PRIVACY_MANAGER_ERROR_OUT_OF_MEMORY;
+       }
+       
+       privacy_info_temp->privacy_info_client = privacy_info_client;
+
+       *privacy_info = privacy_info_temp;
+
+       return PRIVACY_MANAGER_ERROR_NONE;
+}
+
+int privacy_info_clone(privacy_info_h *clone, privacy_info_h privacy_info)
+{
+       int retval;
+       if (clone == NULL || privacy_info == NULL)
+               return PRIVACY_MANAGER_ERROR_INVALID_PARAMETER;
+       
+       retval = privacy_info_create(privacy_info->privacy_info_client->privacy_id, clone);
+
+       return retval;
 }
\ No newline at end of file
index 43815e16b8278b776c67fdbfd306deb1f6ce8fa1..9d3d4e79cb8627016243229d1aa848723ac317a9 100644 (file)
@@ -8,7 +8,7 @@ SET(LIBDIR "\${prefix}/lib")
 SET(INCLUDEDIR "\${prefix}/include")
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED dlog sqlite3 dbus-1 dbus-glib-1)
+pkg_check_modules(privacy-manager-client REQUIRED dlog sqlite3 dbus-1 dbus-glib-1 db-util pkgmgr-info)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -27,10 +27,10 @@ SET(client_src_dir "${CMAKE_SOURCE_DIR}/client/src")
 SET(client_include_dir "${CMAKE_SOURCE_DIR}/client/inc/")
 SET(common_src_dir "${CMAKE_SOURCE_DIR}/common/src/")
 SET(common_include_dir "${CMAKE_SOURCE_DIR}/common/inc/")
-SET(lib_include_dir 
-       "/usr/include/dbus-1.0"
-       "/usr/include/aul"
-)
+#SET(lib_include_dir 
+#      "/usr/include/dbus-1.0"
+#      "/usr/include/aul"
+#)
 
 ## Additional flag
 ADD_DEFINITIONS("-fvisibility=hidden")
index d74b95834a38a8770fca0ae123570e769ae413a5..c9286ae770cedc070a7f353e36b0bc984febe46a 100644 (file)
@@ -1,59 +1,61 @@
-/*\r
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- *    Licensed under the Apache License, Version 2.0 (the "License");\r
- *    you may not use this file except in compliance with the License.\r
- *    You may obtain a copy of the License at\r
- *\r
- *        http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- *    Unless required by applicable law or agreed to in writing, software\r
- *    distributed under the License is distributed on an "AS IS" BASIS,\r
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- *    See the License for the specific language governing permissions and\r
- *    limitations under the License.\r
- */\r
-\r
-#ifndef _PRIVACY_DB_H_\r
-#define _PRIVACY_DB_H_\r
-\r
-#include <string>\r
-#include <memory>\r
-#include <list>\r
-#include <mutex>\r
-\r
-class PrivacyDb\r
-{\r
-private:\r
-       static std::mutex m_singletonMutex;\r
-       static PrivacyDb* m_pInstance;\r
-\r
-private:\r
-       void createDB(void);\r
-       \r
-       PrivacyDb(void);\r
-\r
-       ~PrivacyDb(void);\r
-\r
-public:\r
-       static PrivacyDb* getInstance(void);\r
-\r
-       int getPrivacyAppPackages(std::list <std::string>& list) const;\r
-\r
-       int getAppPackagePrivacyInfo(const std::string pkgId, std::list < std::pair < std::string, bool > > & list) const;\r
-\r
-       int setPrivacySetting(const std::string pkgId, const std::string privacyId, bool enabled);\r
-\r
-       int addAppPackagePrivacyInfo(const std::string pkgcId, const std::list < std::string > privilegeList);\r
-\r
-       int removeAppPackagePrivacyInfo(const std::string pkgId);\r
-\r
-       int isUserPrompted(const std::string pkgId, bool& isPrompted) const;\r
-\r
-       int setUserPrompted(const std::string pkgId, bool prompted);\r
-\r
-       int getAppPackagesbyPrivacyId(std::string privacyId, std::list < std::pair < std::string, bool > >& list) const;\r
-};\r
-\r
-\r
-#endif // _PRIVACY_DB_H_\r
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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.
+ */
+
+#ifndef _PRIVACY_DB_H_
+#define _PRIVACY_DB_H_
+
+#include <string>
+#include <memory>
+#include <list>
+#include <mutex>
+
+class PrivacyDb
+{
+private:
+       static std::mutex m_singletonMutex;
+       static PrivacyDb* m_pInstance;
+
+private:
+       void createDB(void);
+       
+       bool isFilteredPackage(const std::string pkgId) const;
+       
+       PrivacyDb(void);
+
+       ~PrivacyDb(void);
+
+public:
+       static PrivacyDb* getInstance(void);
+
+       int getPrivacyAppPackages(std::list <std::string>& list) const;
+
+       int getAppPackagePrivacyInfo(const std::string pkgId, std::list < std::pair < std::string, bool > > & list) const;
+
+       int setPrivacySetting(const std::string pkgId, const std::string privacyId, bool enabled);
+
+       int addAppPackagePrivacyInfo(const std::string pkgcId, const std::list < std::string > privilegeList);
+
+       int removeAppPackagePrivacyInfo(const std::string pkgId);
+
+       int isUserPrompted(const std::string pkgId, bool& isPrompted) const;
+
+       int setUserPrompted(const std::string pkgId, bool prompted);
+
+       int getAppPackagesbyPrivacyId(std::string privacyId, std::list < std::pair < std::string, bool > >& list) const;
+};
+
+
+#endif // _PRIVACY_DB_H_
index 7bfcbbca3912706fcf70076ebfcaf4823f1a9c5a..97bfad326128c3ce6b9e6b9913321feae2fde791 100644 (file)
@@ -1,75 +1,75 @@
-/*\r
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- *    Licensed under the Apache License, Version 2.0 (the "License");\r
- *    you may not use this file except in compliance with the License.\r
- *    You may obtain a copy of the License at\r
- *\r
- *        http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- *    Unless required by applicable law or agreed to in writing, software\r
- *    distributed under the License is distributed on an "AS IS" BASIS,\r
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- *    See the License for the specific language governing permissions and\r
- *    limitations under the License.\r
- */\r
-\r
-#ifndef _UTILS_H_\r
-#define _UTILS_H_\r
-\r
-#include <vector>\r
-#include <iostream>\r
-#include <algorithm>\r
-#include <dlog.h>\r
-#include <sqlite3.h>\r
-#include <memory>\r
-#include <string>\r
-\r
-#define        TryCatchLogReturn(condition, expr, r, logFormat)        if (!(condition)) { \\r
-               LOGE(logFormat); \\r
-               expr; \\r
-               return r; \\r
-       } else {;}\r
-\r
-#define        TryCatchResLogReturn(condition, expr, r, logFormat, res)        if (!(condition)) { \\r
-               LOGE(logFormat, res); \\r
-               expr; \\r
-               return r; \\r
-       } else {;}\r
-\r
-\r
-#define TryReturn(condition, r, expr, ...) \\r
-       if ( !(condition) ) { \\r
-               LOGE(__VA_ARGS__); \\r
-               expr; \\r
-               return r; \\r
-       } else {;}\r
-\r
-auto StmtDeleter = [&](sqlite3_stmt* pPtr) { /*LOGI("sqlite3_finalize");*/ sqlite3_reset (pPtr); sqlite3_finalize(pPtr); };\r
-auto DbDeleter = [&](sqlite3* pPtr) { /*LOGI("sqlite3_close");*/ sqlite3_close(pPtr); };\r
-\r
-#define setStmtToUniquePtr(x, y)               std::unique_ptr < sqlite3_stmt, decltype(StmtDeleter) > x (y, StmtDeleter);\r
-#define setDbToUniquePtr(x, y)                 std::unique_ptr < sqlite3, decltype(DbDeleter) > x (y, DbDeleter);\r
-\r
-#define openDb(dbpath, pHandler, mode) sqlite3* pHandler##Temp = NULL;\\r
-       {\\r
-               /*LOGI("sqlite3_open_v2");*/\\r
-               int res = sqlite3_open_v2(dbpath, &pHandler##Temp, mode , NULL);\\r
-               TryCatchResLogReturn( res == SQLITE_OK, , PRIV_MGR_ERROR_DB_ERROR, "sqlite3_open : %d", res);\\r
-       }\\r
-       setDbToUniquePtr(pHandler, pHandler##Temp);\\r
-       \r
-#define prepareDb(pHandler, sql, pStmt)        sqlite3_stmt* pStmt##Temp;\\r
-       {\\r
-               /*LOGI("sqlite3_prepare_v2");*/\\r
-               int res = sqlite3_prepare_v2(pHandler.get(), sql, -1, & pStmt##Temp, NULL);\\r
-               TryCatchResLogReturn( res == SQLITE_OK, , PRIV_MGR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);\\r
-       }\\r
-       setStmtToUniquePtr(pStmt, pStmt##Temp);\r
-\r
-class Utils\r
-{\r
-public:\r
-       static std::string toHash (std::string src);\r
-};\r
-#endif //_UTILS_H_\r
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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.
+ */
+
+#ifndef _UTILS_H_
+#define _UTILS_H_
+
+#include <vector>
+#include <iostream>
+#include <algorithm>
+#include <dlog.h>
+#include <sqlite3.h>
+#include <memory>
+#include <string>
+#include <db-util.h>
+
+#define        TryCatchLogReturn(condition, expr, r, logFormat)        if (!(condition)) { \
+               LOGE(logFormat); \
+               expr; \
+               return r; \
+       } else {;}
+
+#define        TryCatchResLogReturn(condition, expr, r, logFormat, res)        if (!(condition)) { \
+               LOGE(logFormat, res); \
+               expr; \
+               return r; \
+       } else {;}
+
+
+#define TryReturn(condition, r, expr, ...) \
+       if ( !(condition) ) { \
+               LOGE(__VA_ARGS__); \
+               expr; \
+               return r; \
+       } else {;}
+
+auto StmtDeleter = [&](sqlite3_stmt* pPtr) { /*LOGI("sqlite3_finalize");*/ sqlite3_reset (pPtr); sqlite3_finalize(pPtr); };
+auto DbDeleter = [&](sqlite3* pPtr) { /*LOGI("sqlite3_close");*/ /*sqlite3_close(pPtr);*/ db_util_close(pPtr); };
+
+#define setStmtToUniquePtr(x, y)               std::unique_ptr < sqlite3_stmt, decltype(StmtDeleter) > x (y, StmtDeleter);
+#define setDbToUniquePtr(x, y)                 std::unique_ptr < sqlite3, decltype(DbDeleter) > x (y, DbDeleter);
+
+#define openDb(dbpath, pHandler, mode) sqlite3* pHandler##Temp = NULL;\
+       {\
+               /*int res = sqlite3_open_v2(dbpath, &pHandler##Temp, mode , NULL);*/\
+               int res = db_util_open_with_options(dbpath, &pHandler##Temp, mode, NULL);\
+               TryCatchResLogReturn( res == SQLITE_OK, , PRIV_MGR_ERROR_DB_ERROR, "db_util_open_with_options : %d", res);\
+       }\
+       setDbToUniquePtr(pHandler, pHandler##Temp);\
+       
+#define prepareDb(pHandler, sql, pStmt)        sqlite3_stmt* pStmt##Temp;\
+       {\
+               int res = sqlite3_prepare_v2(pHandler.get(), sql, -1, & pStmt##Temp, NULL);\
+               TryCatchResLogReturn( res == SQLITE_OK, , PRIV_MGR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);\
+       }\
+       setStmtToUniquePtr(pStmt, pStmt##Temp);
+
+class Utils
+{
+public:
+       static std::string toHash (std::string src);
+};
+#endif //_UTILS_H_
index efab9e9f9150464be19a20c60a6a8a0d66962a0b..95a6b77e7d45892b7bd133b1de77dc037d13081e 100644 (file)
-/*\r
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- *    Licensed under the Apache License, Version 2.0 (the "License");\r
- *    you may not use this file except in compliance with the License.\r
- *    You may obtain a copy of the License at\r
- *\r
- *        http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- *    Unless required by applicable law or agreed to in writing, software\r
- *    distributed under the License is distributed on an "AS IS" BASIS,\r
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- *    See the License for the specific language governing permissions and\r
- *    limitations under the License.\r
- */\r
-\r
-#include <sstream>\r
-#include <dlog.h>\r
-#include <Utils.h>\r
-#include <PrivacyDb.h>\r
-#include <PrivacyManagerTypes.h>\r
-#include <sqlite3.h>\r
-\r
-std::mutex PrivacyDb::m_singletonMutex;\r
-PrivacyDb* PrivacyDb::m_pInstance = NULL;\r
-\r
-void\r
-PrivacyDb::createDB(void)\r
-{\r
-\r
-}\r
-\r
-int\r
-PrivacyDb::setPrivacySetting(const std::string pkgId, const std::string privacyId, bool enabled)\r
-{\r
-       LOGI("enter");\r
-\r
-       static const std::string query = std::string("UPDATE PrivacyInfo set IS_ENABLED =? where PKG_ID=? and PRIVACY_ID=?");\r
-\r
-       openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READWRITE);\r
-       prepareDb(pDbHandler, query.c_str(), pStmt);\r
-\r
-       int res = sqlite3_bind_int(pStmt.get(), 1, enabled);\r
-       TryReturn(res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);\r
-\r
-       res = sqlite3_bind_text(pStmt.get(), 2, pkgId.c_str(), -1, SQLITE_TRANSIENT);\r
-       TryReturn(res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);\r
-\r
-       res = sqlite3_bind_text(pStmt.get(), 3, privacyId.c_str(), -1, SQLITE_TRANSIENT);\r
-       TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);\r
-       \r
-       res = sqlite3_step(pStmt.get());\r
-       TryReturn( res == SQLITE_DONE, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_step : %d", res);\r
-\r
-       LOGI("leave");\r
-\r
-       return 0;\r
-}\r
-\r
-int\r
-PrivacyDb::getPrivacyAppPackages(std::list <std::string>& list) const\r
-{\r
-       LOGI("enter");\r
-\r
-       std::string query = "SELECT PKG_ID from PackageInfo";\r
-\r
-       openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READONLY);\r
-       prepareDb(pDbHandler, query.c_str(), pStmt);\r
-\r
-       while ( sqlite3_step(pStmt.get()) == SQLITE_ROW )\r
-       {\r
-               const char* pValue =  reinterpret_cast < const char* > (sqlite3_column_text(pStmt.get(), 0));\r
-\r
-               LOGD("AppId found : %s ", pValue);\r
-               list.push_back(std::string(pValue));\r
-       }\r
-\r
-       LOGI("leave");\r
-\r
-       return 0;\r
-}\r
-\r
-int\r
-PrivacyDb::getAppPackagePrivacyInfo(const std::string pkgId, std::list < std::pair < std::string, bool > >& privacyInfoList) const\r
-{\r
-       LOGI("enter");\r
-\r
-       static const std::string query = "SELECT PRIVACY_ID, IS_ENABLED from PrivacyInfo where PKG_ID=?";\r
-\r
-       openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READONLY);\r
-       prepareDb(pDbHandler, query.c_str(), pStmt);\r
-\r
-       int res = sqlite3_bind_text(pStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);\r
-       TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);\r
-\r
-       LOGI("start");\r
-\r
-       while ( (res= sqlite3_step(pStmt.get())) == SQLITE_ROW )\r
-       {\r
-               const char* privacyId =  reinterpret_cast < const char* > (sqlite3_column_text(pStmt.get(), 0));\r
-               bool privacyEnabled = sqlite3_column_int(pStmt.get(), 1) > 0 ? true : false;\r
-\r
-               privacyInfoList.push_back( std::pair <std::string, bool> (std::string(privacyId), privacyEnabled) );\r
-\r
-               LOGD("Privacy found : %s %d", privacyId, privacyEnabled);\r
-       }\r
-\r
-       LOGI("leave");\r
-\r
-       return 0;\r
-}\r
-\r
-\r
-int\r
-PrivacyDb::addAppPackagePrivacyInfo(const std::string pkgId, const std::list < std::string > privilegeList)\r
-{\r
-       LOGI("enter");\r
-\r
-       static const std::string pkgInfoQuery("INSERT INTO PackageInfo(PKG_ID, IS_SET) VALUES(?, ?)");\r
-       static const std::string privacyQuery("INSERT INTO PrivacyInfo(PKG_ID, PRIVACY_ID, IS_ENABLED) VALUES(?, ?, ?)");\r
-       \r
-       openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READWRITE);\r
-       prepareDb(pDbHandler, pkgInfoQuery.c_str(), pPkgInfoStmt);\r
-\r
-       int res = sqlite3_bind_text(pPkgInfoStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);\r
-       TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);\r
-       \r
-       res = sqlite3_bind_int(pPkgInfoStmt.get(), 2, 0);\r
-       TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);\r
-\r
-       res = sqlite3_step(pPkgInfoStmt.get());\r
-       TryReturn( res == SQLITE_DONE, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_step : %d", res);\r
-       \r
-       for ( std::list <std::string>::const_iterator iter = privilegeList.begin(); iter != privilegeList.end(); ++iter)\r
-       {\r
-               LOGD(" install privacy: %s", iter->c_str());\r
-               prepareDb(pDbHandler, privacyQuery.c_str(), pPrivacyStmt);\r
-               \r
-               res = sqlite3_bind_text(pPrivacyStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);\r
-               TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);\r
-\r
-               res = sqlite3_bind_text(pPrivacyStmt.get(), 2, iter->c_str(), -1, SQLITE_TRANSIENT);\r
-               TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);\r
-               \r
-               // Before setting app and popup is ready, default value is true\r
-               res = sqlite3_bind_int(pPrivacyStmt.get(), 3, 1);\r
-               TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);\r
-\r
-               res = sqlite3_step(pPrivacyStmt.get());\r
-               TryReturn( res == SQLITE_DONE || res == SQLITE_CONSTRAINT, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_step : %d", res);\r
-\r
-               sqlite3_reset(pPrivacyStmt.get());\r
-       }\r
-\r
-       return 0;\r
-}\r
-\r
-int\r
-PrivacyDb::removeAppPackagePrivacyInfo(const std::string pkgId)\r
-{\r
-       LOGI("enter");\r
-\r
-       static const std::string pkgInfoQuery("DELETE FROM PackageInfo WHERE PKG_ID=?");\r
-       static const std::string privacyQuery("DELETE FROM PrivacyInfo WHERE PKG_ID=?");\r
-\r
-       int res;\r
-\r
-       openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READWRITE);\r
-       prepareDb(pDbHandler, pkgInfoQuery.c_str(), pPkgInfoStmt);\r
-\r
-       res = sqlite3_bind_text(pPkgInfoStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);\r
-       TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);\r
-\r
-       res = sqlite3_step(pPkgInfoStmt.get());\r
-       TryReturn( res == SQLITE_DONE, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_step : %d", res);\r
-\r
-       prepareDb(pDbHandler, privacyQuery.c_str(), pPrivacyStmt);\r
-\r
-       res = sqlite3_bind_text(pPrivacyStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);\r
-       TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res); \r
-\r
-       res = sqlite3_step(pPrivacyStmt.get());\r
-       TryReturn( res == SQLITE_DONE, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_step : %d", res);\r
-\r
-       return 0;\r
-}\r
-\r
-int\r
-PrivacyDb::isUserPrompted(const std::string pkgId, bool& isPrompted) const\r
-{\r
-       LOGI("enter");\r
-\r
-       static const std::string query = "SELECT IS_SET from PackageInfo where PKG_ID=?";\r
-\r
-       isPrompted = true;\r
-\r
-       openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READONLY);\r
-       prepareDb(pDbHandler, query.c_str(), pStmt);\r
-\r
-       int res = sqlite3_bind_text(pStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);\r
-       TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);\r
-\r
-       std::unique_ptr < std::list < std::pair < std:: string, bool > > > pList ( new std::list < std::pair < std:: string, bool > >);\r
-\r
-       if ((res = sqlite3_step(pStmt.get())) == SQLITE_ROW)\r
-       {\r
-               isPrompted = sqlite3_column_int(pStmt.get(), 0) > 0 ? true : false;\r
-       }\r
-       else\r
-       {\r
-               LOGE("The package[%s] doesnt access privacy", pkgId.c_str());\r
-               return PRIV_MGR_ERROR_SUCCESS;\r
-       }\r
-\r
-       return 0;\r
-}\r
-\r
-int\r
-PrivacyDb::setUserPrompted(const std::string pkgId, bool prompted)\r
-{\r
-       LOGI("enter :%s - %d", pkgId.c_str(), prompted);\r
-\r
-       std::string query = std::string("UPDATE PackageInfo set IS_SET =? where PKG_ID=?");\r
-\r
-       int res;\r
-\r
-       openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READWRITE);\r
-       prepareDb(pDbHandler, query.c_str(), pStmt);\r
-\r
-       res = sqlite3_bind_int(pStmt.get(), 1, prompted? 1 : 0);\r
-       TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);\r
-\r
-       res = sqlite3_bind_text(pStmt.get(), 2, pkgId.c_str(), -1, SQLITE_TRANSIENT);\r
-       TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);\r
-\r
-       res = sqlite3_step(pStmt.get());\r
-       TryReturn( res == SQLITE_DONE, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_step : %d", res);\r
-\r
-       return 0;\r
-}\r
-\r
-int\r
-PrivacyDb::getAppPackagesbyPrivacyId(std::string privacyId, std::list < std::pair < std::string, bool > >& list) const\r
-{\r
-       LOGI("enter");\r
-\r
-       std::string sql = std::string("SELECT PKG_ID, IS_ENABLED from PrivacyInfo where PRIVACY_ID=?");\r
-\r
-       openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READWRITE);\r
-       prepareDb(pDbHandler, sql.c_str(), pStmt);\r
-\r
-       LOGD("privacy id : %s", privacyId.c_str());\r
-       int res = sqlite3_bind_text(pStmt.get(), 1, privacyId.c_str(), -1, SQLITE_TRANSIENT);\r
-       TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);\r
-\r
-       while ( sqlite3_step(pStmt.get()) == SQLITE_ROW )\r
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    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 <sstream>
+#include <dlog.h>
+#include <Utils.h>
+#include <PrivacyDb.h>
+#include <PrivacyManagerTypes.h>
+#include <sqlite3.h>
+#include <pkgmgr-info.h>
+
+std::mutex PrivacyDb::m_singletonMutex;
+PrivacyDb* PrivacyDb::m_pInstance = NULL;
+
+void
+PrivacyDb::createDB(void)
+{
+
+}
+
+bool PrivacyDb::isFilteredPackage(const std::string pkgId) const
+{
+       pkgmgrinfo_pkginfo_h handle;
+
+       int res = pkgmgrinfo_pkginfo_get_pkginfo(pkgId.c_str(), &handle);
+
+       if (res != PMINFO_R_OK)
+               return false;
+
+       bool preloaded = false;
+       res = pkgmgrinfo_pkginfo_is_preload(handle, &preloaded);
+       pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+
+       return preloaded;
+}
+
+int
+PrivacyDb::setPrivacySetting(const std::string pkgId, const std::string privacyId, bool enabled)
+{
+       LOGI("enter");
+
+       static const std::string query = std::string("UPDATE PrivacyInfo set IS_ENABLED =? where PKG_ID=? and PRIVACY_ID=?");
+
+       openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READWRITE);
+       prepareDb(pDbHandler, query.c_str(), pStmt);
+
+       int res = sqlite3_bind_int(pStmt.get(), 1, enabled);
+       TryReturn(res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);
+
+       res = sqlite3_bind_text(pStmt.get(), 2, pkgId.c_str(), -1, SQLITE_TRANSIENT);
+       TryReturn(res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);
+
+       res = sqlite3_bind_text(pStmt.get(), 3, privacyId.c_str(), -1, SQLITE_TRANSIENT);
+       TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
+       
+       res = sqlite3_step(pStmt.get());
+       TryReturn( res == SQLITE_DONE, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_step : %d", res);
+
+       LOGI("leave");
+
+       return 0;
+}
+
+int
+PrivacyDb::getPrivacyAppPackages(std::list <std::string>& list) const
+{
+       LOGI("enter");
+
+       std::string query = "SELECT PKG_ID from PackageInfo";
+
+       openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READONLY);
+       prepareDb(pDbHandler, query.c_str(), pStmt);
+
+       while ( sqlite3_step(pStmt.get()) == SQLITE_ROW )
+       {
+               const char* pValue =  reinterpret_cast < const char* > (sqlite3_column_text(pStmt.get(), 0));
+
+               LOGD("PkgId found : %s ", pValue);
+               std::string pkgId = std::string(pValue);
+
+               if (isFilteredPackage(pkgId))
+               {
+                       LOGD("%s is Filtered", pValue);
+                       continue;
+               }
+               list.push_back(std::string(pValue));
+       }
+
+       LOGI("leave");
+
+       return 0;
+}
+
+int
+PrivacyDb::getAppPackagePrivacyInfo(const std::string pkgId, std::list < std::pair < std::string, bool > >& privacyInfoList) const
+{
+       LOGI("enter");
+
+       static const std::string query = "SELECT PRIVACY_ID, IS_ENABLED from PrivacyInfo where PKG_ID=?";
+
+       openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READONLY);
+       prepareDb(pDbHandler, query.c_str(), pStmt);
+
+       int res = sqlite3_bind_text(pStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);
+       TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);
+
+       LOGI("start");
+
+       while ( (res= sqlite3_step(pStmt.get())) == SQLITE_ROW )
+       {
+               const char* privacyId =  reinterpret_cast < const char* > (sqlite3_column_text(pStmt.get(), 0));
+               bool privacyEnabled = sqlite3_column_int(pStmt.get(), 1) > 0 ? true : false;
+
+               privacyInfoList.push_back( std::pair <std::string, bool> (std::string(privacyId), privacyEnabled) );
+
+               LOGD("Privacy found : %s %d", privacyId, privacyEnabled);
+       }
+
+       LOGI("leave");
+
+       return 0;
+}
+
+
+int
+PrivacyDb::addAppPackagePrivacyInfo(const std::string pkgId, const std::list < std::string > privilegeList)
+{
+       LOGI("enter");
+
+       static const std::string pkgInfoQuery("INSERT INTO PackageInfo(PKG_ID, IS_SET) VALUES(?, ?)");
+       static const std::string privacyQuery("INSERT INTO PrivacyInfo(PKG_ID, PRIVACY_ID, IS_ENABLED) VALUES(?, ?, ?)");
+       
+       openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READWRITE);
+       prepareDb(pDbHandler, pkgInfoQuery.c_str(), pPkgInfoStmt);
+
+       int res = sqlite3_bind_text(pPkgInfoStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);
+       TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
+       
+       res = sqlite3_bind_int(pPkgInfoStmt.get(), 2, 0);
+       TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);
+
+       res = sqlite3_step(pPkgInfoStmt.get());
+       TryReturn( res == SQLITE_DONE, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_step : %d", res);
+       
+       for ( std::list <std::string>::const_iterator iter = privilegeList.begin(); iter != privilegeList.end(); ++iter)
+       {
+               LOGD(" install privacy: %s", iter->c_str());
+               prepareDb(pDbHandler, privacyQuery.c_str(), pPrivacyStmt);
+               
+               res = sqlite3_bind_text(pPrivacyStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);
+               TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);
+
+               res = sqlite3_bind_text(pPrivacyStmt.get(), 2, iter->c_str(), -1, SQLITE_TRANSIENT);
+               TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
+               
+               // Before setting app and popup is ready, default value is true
+               res = sqlite3_bind_int(pPrivacyStmt.get(), 3, 1);
+               TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);
+
+               res = sqlite3_step(pPrivacyStmt.get());
+               TryReturn( res == SQLITE_DONE || res == SQLITE_CONSTRAINT, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_step : %d", res);
+
+               sqlite3_reset(pPrivacyStmt.get());
+       }
+
+       return 0;
+}
+
+int
+PrivacyDb::removeAppPackagePrivacyInfo(const std::string pkgId)
+{
+       LOGI("enter");
+
+       static const std::string pkgInfoQuery("DELETE FROM PackageInfo WHERE PKG_ID=?");
+       static const std::string privacyQuery("DELETE FROM PrivacyInfo WHERE PKG_ID=?");
+
+       int res;
+
+       openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READWRITE);
+       prepareDb(pDbHandler, pkgInfoQuery.c_str(), pPkgInfoStmt);
+
+       res = sqlite3_bind_text(pPkgInfoStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);
+       TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
+
+       res = sqlite3_step(pPkgInfoStmt.get());
+       TryReturn( res == SQLITE_DONE, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_step : %d", res);
+
+       prepareDb(pDbHandler, privacyQuery.c_str(), pPrivacyStmt);
+
+       res = sqlite3_bind_text(pPrivacyStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);
+       TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res); 
+
+       res = sqlite3_step(pPrivacyStmt.get());
+       TryReturn( res == SQLITE_DONE, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_step : %d", res);
+
+       return 0;
+}
+
+int
+PrivacyDb::isUserPrompted(const std::string pkgId, bool& isPrompted) const
+{
+       LOGI("enter");
+
+       static const std::string query = "SELECT IS_SET from PackageInfo where PKG_ID=?";
+
+       isPrompted = true;
+
+       if (isFilteredPackage(pkgId))\r
        {\r
-               \r
-               const char* pPkgId =  reinterpret_cast < const char* > (sqlite3_column_text(pStmt.get(), 0));\r
-               bool isEnabled = sqlite3_column_int(pStmt.get(), 1) > 0 ? true : false;\r
-               LOGD("result : %s %d", pPkgId, isEnabled);\r
-               list.push_back( std::pair <std::string, bool >(std::string(pPkgId), isEnabled) );\r
+               LOGD("%s is Filtered", pkgId.c_str());\r
+               return 0;\r
        }\r
 \r
-       \r
-\r
-\r
-       LOGI("leave %d", res);\r
-\r
-       return PRIV_MGR_ERROR_SUCCESS;\r
-}\r
-\r
-\r
-PrivacyDb::PrivacyDb(void)\r
-{\r
-\r
-}\r
-\r
-PrivacyDb::~PrivacyDb(void)\r
-{\r
-\r
-}\r
-\r
-PrivacyDb*\r
-PrivacyDb::getInstance(void)\r
-{\r
-       LOGI("enter");\r
-       std::lock_guard < std::mutex > guard(m_singletonMutex);\r
-\r
-       if (m_pInstance == NULL)\r
-       {       \r
-               m_pInstance = new PrivacyDb();\r
-       }\r
-\r
-       LOGI("leave");\r
-\r
-       return m_pInstance;\r
+       openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READONLY);
+       prepareDb(pDbHandler, query.c_str(), pStmt);
+
+       int res = sqlite3_bind_text(pStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);
+       TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
+
+       std::unique_ptr < std::list < std::pair < std:: string, bool > > > pList ( new std::list < std::pair < std:: string, bool > >);
+
+       if ((res = sqlite3_step(pStmt.get())) == SQLITE_ROW)
+       {
+               isPrompted = sqlite3_column_int(pStmt.get(), 0) > 0 ? true : false;
+       }
+       else
+       {
+               LOGE("The package[%s] doesnt access privacy", pkgId.c_str());
+               return PRIV_MGR_ERROR_SUCCESS;
+       }
+
+       return 0;
+}
+
+int
+PrivacyDb::setUserPrompted(const std::string pkgId, bool prompted)
+{
+       LOGI("enter :%s - %d", pkgId.c_str(), prompted);
+
+       std::string query = std::string("UPDATE PackageInfo set IS_SET =? where PKG_ID=?");
+
+       int res;
+
+       openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READWRITE);
+       prepareDb(pDbHandler, query.c_str(), pStmt);
+
+       res = sqlite3_bind_int(pStmt.get(), 1, prompted? 1 : 0);
+       TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);
+
+       res = sqlite3_bind_text(pStmt.get(), 2, pkgId.c_str(), -1, SQLITE_TRANSIENT);
+       TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
+
+       res = sqlite3_step(pStmt.get());
+       TryReturn( res == SQLITE_DONE, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_step : %d", res);
+
+       return 0;
+}
+
+int
+PrivacyDb::getAppPackagesbyPrivacyId(std::string privacyId, std::list < std::pair < std::string, bool > >& list) const
+{
+       LOGI("enter");
+
+       std::string sql = std::string("SELECT PKG_ID, IS_ENABLED from PrivacyInfo where PRIVACY_ID=?");
+
+       openDb(PRIVACY_DB_PATH.c_str(), pDbHandler, SQLITE_OPEN_READWRITE);
+       prepareDb(pDbHandler, sql.c_str(), pStmt);
+
+       LOGD("privacy id : %s", privacyId.c_str());
+       int res = sqlite3_bind_text(pStmt.get(), 1, privacyId.c_str(), -1, SQLITE_TRANSIENT);
+       TryReturn( res == SQLITE_OK, PRIV_MGR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
+
+       while ( sqlite3_step(pStmt.get()) == SQLITE_ROW )
+       {
+               
+               const char* pPkgId =  reinterpret_cast < const char* > (sqlite3_column_text(pStmt.get(), 0));
+               bool isEnabled = sqlite3_column_int(pStmt.get(), 1) > 0 ? true : false;
+               LOGD("result : %s %d", pPkgId, isEnabled);
+               list.push_back( std::pair <std::string, bool >(std::string(pPkgId), isEnabled) );
+       }
+
+       LOGI("leave %d", res);
+
+       return PRIV_MGR_ERROR_SUCCESS;
+}
+
+PrivacyDb::PrivacyDb(void)
+{
+
+}
+
+PrivacyDb::~PrivacyDb(void)
+{
+
+}
+
+PrivacyDb*
+PrivacyDb::getInstance(void)
+{
+       LOGI("enter");
+       std::lock_guard < std::mutex > guard(m_singletonMutex);
+
+       if (m_pInstance == NULL)
+       {       
+               m_pInstance = new PrivacyDb();
+       }
+
+       LOGI("leave");
+
+       return m_pInstance;
 }
\ No newline at end of file
index 992e52afac8bded7db5b2417a4da4a52dd4c6bfb..c47ccc5be7ed20876e6d2735a14c590081c59396 100644 (file)
@@ -1,7 +1,7 @@
 Name:    privacy-manager-server
 Summary: Privacy Management
 Version: 0.0.2
-Release: 3
+Release: 4
 Group:   System/Libraries
 License: SAMSUNG
 Source0: %{name}-%{version}.tar.gz
@@ -16,6 +16,9 @@ BuildRequires: pkgconfig(sqlite3)
 BuildRequires: pkgconfig(capi-base-common)
 BuildRequires: pkgconfig(dbus-1)
 BuildRequires: pkgconfig(dbus-glib-1)
+BuildRequires: pkgconfig(db-util)
+BuildRequires: pkgconfig(pkgmgr-info)
+BuildRequires: gettext-tools
 
 Requires(post):   /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
index c3898b634b20e9c56241df96756ddb491b42362f..40162b8d3bd101a856b4b0666ad6f6ae3f2e50a3 100644 (file)
@@ -5,12 +5,15 @@ SET (this_target privileges)
 SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/cmake_build_tmp/output)
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(bin_pkgs REQUIRED dlog libxml-2.0)
+pkg_check_modules(pkg REQUIRED glib-2.0 dlog libxml-2.0 )
+
+FOREACH(flag ${privileges_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
 
 INCLUDE_DIRECTORIES(
     /usr/include
     /usr/include/glib-2.0 
-    /usr/lib/glib-2.0/include
     /usr/include/libxml2
     /usr/include/package_manager
     /usr/include/dlog
@@ -41,9 +44,7 @@ ADD_DEPENDENCIES(${this_target} privacy-manager-client)
 ## SET LINKER FLAGS
 SET(CMAKE_SHARED_LINKER_FLAGS -Wl,--no-undefined)
 
-TARGET_LINK_LIBRARIES(${this_target} "-lxml2" )
-TARGET_LINK_LIBRARIES(${this_target} "-lglib-2.0" )
-TARGET_LINK_LIBRARIES(${this_target} "-ldlog" )
+TARGET_LINK_LIBRARIES(${this_target} ${pkg_LDFLAGS} ${pkg_LIBRARIES})
 TARGET_LINK_LIBRARIES(${this_target} "-lprivacy-manager-client" "-L../client" )
 
 ADD_CUSTOM_COMMAND(TARGET ${this_target}
index 0b0d40d3d1310c01ed268ab8f7cb116c2ea260ab..9886864dabb27b7b42f545b0025901b569bce555 100644 (file)
@@ -8,7 +8,7 @@ SET(LIBDIR "\${prefix}/lib")
 SET(INCLUDEDIR "\${prefix}/include")
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED dlog sqlite3 dbus-1 dbus-glib-1)
+pkg_check_modules(pkgs REQUIRED dlog sqlite3 dbus-1 dbus-glib-1 db-util pkgmgr-info)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 3e51c20b99788ed62b6fbd03db917757c197c879..9aecc40e8470c0cb23e62ec7cb60419134f2b160 100644 (file)
@@ -14,7 +14,7 @@ SET(VERSION "${VERSION_MAJOR}.0.1")
 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED dlog)
+pkg_check_modules(pkgs REQUIRED dlog pkgmgr-info)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")