From: Kyoungyong Lee Date: Sat, 1 Oct 2016 07:26:46 +0000 (+0900) Subject: fixed a defect not to be shown the package list in the privacy-setting X-Git-Tag: accepted/tizen/3.0/mobile/20161015.034230^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F00%2F90600%2F4;p=platform%2Fcore%2Fsecurity%2Fprivacy-guard.git fixed a defect not to be shown the package list in the privacy-setting Change-Id: I770d04d4895c1f3f99210611ca42f23fb512d990 --- diff --git a/client/src/PrivacyChecker.cpp b/client/src/PrivacyChecker.cpp old mode 100755 new mode 100644 index 5e04ee5..43b433a --- a/client/src/PrivacyChecker.cpp +++ b/client/src/PrivacyChecker.cpp @@ -152,6 +152,7 @@ int PrivacyChecker::checkMonitorPolicyWithPrivilege(const int userId, const std::string packageId, const std::string privilegeId, std::string &privacyId, int &monitorPolicy) { checkMonitorByPrivilege(privilegeId); + if (m_isMonitorEnable == true) { int res = PrivacyIdInfo::getPrivacyIdFromPrivilege(privilegeId, privacyId); TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "getPrivacyIdFromPrivilege : %d", res); @@ -166,6 +167,7 @@ void* PrivacyChecker::runSignalListenerThread(void* pData) { pthread_detach(pthread_self()); + PG_LOGI("Running g main loop for signal"); initializeDbus(); diff --git a/client/src/PrivacyGuardClient.cpp b/client/src/PrivacyGuardClient.cpp old mode 100755 new mode 100644 index f7d7b59..f3e2e2a --- a/client/src/PrivacyGuardClient.cpp +++ b/client/src/PrivacyGuardClient.cpp @@ -150,9 +150,8 @@ PrivacyGuardClient::PgAddMonitorPolicy(const int userId, const std::string pkgId res = m_pSocketClient->connect(); if(res != PRIV_GUARD_ERROR_SUCCESS) { + PG_LOGD("Cannot connect to the socket. So change to the offline mode"); isServerOperation = false; - PG_LOGE("connect : %d", res); - PG_LOGD("Failed to connect. So change to the offline mode"); } else { isServerOperation = true; } diff --git a/client/src/SocketClient.cpp b/client/src/SocketClient.cpp old mode 100755 new mode 100644 index 84a3b53..542e3f7 --- a/client/src/SocketClient.cpp +++ b/client/src/SocketClient.cpp @@ -72,6 +72,7 @@ int SocketClient::disconnect() //Socket should be already closed by server side, //even though we should close it in case of any errors close(m_socketFd); + PG_LOGI("Client disconnected"); return PRIV_GUARD_ERROR_SUCCESS; diff --git a/client/src/privacy_guard_client.cpp b/client/src/privacy_guard_client.cpp old mode 100755 new mode 100644 index 4831429..734ac43 --- a/client/src/privacy_guard_client.cpp +++ b/client/src/privacy_guard_client.cpp @@ -343,7 +343,6 @@ int privacy_guard_client_foreach_privacy_package_id(const int user_id, privacy_g return retval; } - if (packageList.size() == 0) return PRIV_GUARD_ERROR_NO_DATA; diff --git a/client/src/privacy_guard_client_internal_types.h b/client/src/privacy_guard_client_internal_types.h old mode 100755 new mode 100644 index ce59c3b..7d70705 --- a/client/src/privacy_guard_client_internal_types.h +++ b/client/src/privacy_guard_client_internal_types.h @@ -28,5 +28,4 @@ extern "C" { } #endif - #endif //_PRIVACY_GUARD_CLIENT_INTERNAL_TYPES_H_ \ No newline at end of file diff --git a/common/inc/IPrivacyGuard.h b/common/inc/IPrivacyGuard.h old mode 100755 new mode 100644 index 4d3b51b..1d85a85 --- a/common/inc/IPrivacyGuard.h +++ b/common/inc/IPrivacyGuard.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef _IPRIVACYGUARD_H_ -#define _IPRIVACYGUARD_H_ +#ifndef _IPRIVACY_GUARD_H_ +#define _IPRIVACY_GUARD_H_ #include #include @@ -40,4 +40,4 @@ public: int getAppPackagePrivacyInfo(const std::string pkgId, std::list < std::pair > & pList); }; -#endif // _IPRIVACYGUARD_H_ \ No newline at end of file +#endif // _IPRIVACY_GUARD_H_ \ No newline at end of file diff --git a/common/inc/PrivacyGuardCommon.h b/common/inc/PrivacyGuardCommon.h old mode 100755 new mode 100644 index 97a5067..3fea18d --- a/common/inc/PrivacyGuardCommon.h +++ b/common/inc/PrivacyGuardCommon.h @@ -21,4 +21,4 @@ #include #include -#endif // PRIVACYGUARDCOMMON_H_ +#endif // _PRIVACY_GUARD_COMMON_H_ \ No newline at end of file diff --git a/common/inc/PrivacyGuardTypes.h b/common/inc/PrivacyGuardTypes.h old mode 100755 new mode 100644 index cb42e05..b7a6cec --- a/common/inc/PrivacyGuardTypes.h +++ b/common/inc/PrivacyGuardTypes.h @@ -26,10 +26,8 @@ #define CYNARA_BUFFER_SIZE 100 #define USER_APP_PREFIX "User::App::" #define USER_APP_PREFIX_LEN 11 -#define GLOBAL_APP_USER_ID 0 #define USER_PKG_PREFIX "User::Pkg::" #define USER_PKG_PREFIX_LEN 11 -#define ROOT_USER_ID 0 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER) typedef struct _privacy_data_s { diff --git a/common/inc/PrivacyIdInfo.h b/common/inc/PrivacyIdInfo.h old mode 100755 new mode 100644 index fe414e8..0584bbf --- a/common/inc/PrivacyIdInfo.h +++ b/common/inc/PrivacyIdInfo.h @@ -34,9 +34,6 @@ public: static int getPrivacyIdListFromPrivilegeList(const std::list< std::string > privilegeList, std::list< std::string >& privacyIdList); static bool isValidPrivacyId(const std::string privacyId); static int getAllPrivacyId(std::list< std::string >& privacyIdList); - //static int getPrivaycDisplayName(const std::string privacyId, std::string& displayName); - //static int getPrivaycDescription(const std::string privacyId, std::string& description); - //static int isFeatureEnabled(const char* feature, bool& enabled); }; -#endif //_PRIVACYIDINFO_H_ +#endif //_PRIVACYIDINFO_H_ \ No newline at end of file diff --git a/common/inc/SocketConnection.h b/common/inc/SocketConnection.h old mode 100755 new mode 100644 index 5e24bb5..b1bd880 --- a/common/inc/SocketConnection.h +++ b/common/inc/SocketConnection.h @@ -39,7 +39,6 @@ class EXTERN_API SocketConnection { public: - explicit SocketConnection(int socket_fd) : m_socketStream(socket_fd){ PG_LOGI("Created"); } @@ -440,7 +439,6 @@ public: return write(*pList); } - private: SocketStream m_socketStream; }; diff --git a/common/inc/SocketStream.h b/common/inc/SocketStream.h old mode 100755 new mode 100644 index 0f6b53c..460d6b6 --- a/common/inc/SocketStream.h +++ b/common/inc/SocketStream.h @@ -33,6 +33,7 @@ public: int readStream(size_t num, void * bytes); int writeStream(size_t num, const void * bytes); + private: int throwWithErrnoMessage(std::string specificInfo); int m_socketFd; diff --git a/common/inc/Utils.h b/common/inc/Utils.h old mode 100755 new mode 100644 index 4082012..c50c85c --- a/common/inc/Utils.h +++ b/common/inc/Utils.h @@ -56,7 +56,6 @@ ////////////////////////////////////////////////////////////////////////// - #define IF_MATCH_RET_ERROR(condition, msgFormat, error) \ if (condition) { \ PG_LOGE(msgFormat, error); \ @@ -129,4 +128,5 @@ class Utils public: static std::string toHash (std::string src); }; + #endif //_UTILS_H_ diff --git a/server/src/CynaraService.cpp b/server/src/CynaraService.cpp old mode 100755 new mode 100644 index 12601c1..19db318 --- a/server/src/CynaraService.cpp +++ b/server/src/CynaraService.cpp @@ -306,7 +306,7 @@ CynaraService::updateDb(cynara_monitor_entry **monitor_entries) PG_LOGE("Failed to do pkgmgrinfo_pkginfo_is_global [%d]", res); } else { if (is_global == true) { - userId = GLOBAL_APP_USER_ID; + userId = GLOBAL_USER; } } pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle); diff --git a/server/src/NotificationServer.cpp b/server/src/NotificationServer.cpp old mode 100755 new mode 100644 index 04fc883..f4a0c1c --- a/server/src/NotificationServer.cpp +++ b/server/src/NotificationServer.cpp @@ -60,6 +60,7 @@ NotificationServer::initialize(void) TryReturn(!dbus_error_is_set(&error), PRIV_GUARD_ERROR_SYSTEM_ERROR, dbus_error_free(&error), "dbus_bus_add_match : %s", error.message); m_initialized = true; + return PRIV_GUARD_ERROR_SUCCESS; } diff --git a/server/src/PrivacyGuardDaemon.cpp b/server/src/PrivacyGuardDaemon.cpp old mode 100755 new mode 100644 index c57e38d..84b56e5 --- a/server/src/PrivacyGuardDaemon.cpp +++ b/server/src/PrivacyGuardDaemon.cpp @@ -18,7 +18,6 @@ #include "PrivacyGuardDaemon.h" #include "PrivacyInfoService.h" #include "SocketService.h" -// [CYNARA] #include PrivacyGuardDaemon* PrivacyGuardDaemon::pInstance = NULL; @@ -56,7 +55,6 @@ PrivacyGuardDaemon::initialize(void) PG_LOGD("calling PrivacyInfoService::registerCallbacks(pSocketService)"); PrivacyInfoService::registerCallbacks(pSocketService); - // [CYNARA] if (pCynaraService == NULL) pCynaraService = new CynaraService(); @@ -79,7 +77,6 @@ PrivacyGuardDaemon::start(void) PG_LOGE("FAIL"); } - // [CYNARA] PG_LOGD("calling pCynaraService->start()"); if (pCynaraService == NULL) return PRIV_GUARD_ERROR_NOT_INITIALIZED; diff --git a/server/src/PrivacyGuardDb.cpp b/server/src/PrivacyGuardDb.cpp old mode 100755 new mode 100644 index af86fb0..0fcdc79 --- a/server/src/PrivacyGuardDb.cpp +++ b/server/src/PrivacyGuardDb.cpp @@ -27,6 +27,7 @@ #define PRIVACY_GUARD_DAYS 7 #define UNIX_TIME_ONE_DAY (24 * 60 * 60) // 86400 secs +#define BUF_SIZE 256 std::mutex PrivacyGuardDb::m_singletonMutex; PrivacyGuardDb* PrivacyGuardDb::m_pInstance = NULL; @@ -73,7 +74,7 @@ PrivacyGuardDb::openSqliteDB(void) res = sqlite3_open_v2(PRIVACY_DB_PATH, &m_sqlHandler, SQLITE_OPEN_READWRITE, NULL); if(res == SQLITE_OK) { PG_LOGI("monitor db is opened successfully"); -// sqlite3_wal_autocheckpoint(m_sqlHandler, 1); + //sqlite3_wal_autocheckpoint(m_sqlHandler, 1); m_bDBOpen = true; } else { @@ -198,7 +199,10 @@ int PrivacyGuardDb::PgCheckPrivacyPackage(const int userId, const std::string packageId, bool &isPrivacyPackage) { int res = -1; - static const std::string query = std::string("SELECT COUNT(*) FROM MonitorPolicy WHERE USER_ID=? AND PKG_ID=?"); + char buf[BUF_SIZE]; + + snprintf(buf, BUF_SIZE, "SELECT COUNT(*) FROM MonitorPolicy WHERE (USER_ID=? OR USER_ID=%d) AND PKG_ID=?", GLOBAL_USER); + static const std::string query = std::string(buf); m_dbMutex.lock(); @@ -371,6 +375,8 @@ int PrivacyGuardDb::PgForeachTotalPrivacyCountOfPackage(const int userId, const int startDate, const int endDate, std::list < std::pair < std::string, int > >& packageInfoList) { int res = -1; + char buf[BUF_SIZE]; + sqlite3_stmt* infoStmt; // [CYNARA] Flush Entries res = cynara_monitor_entries_flush(p_cynara_monitor); @@ -382,9 +388,11 @@ PrivacyGuardDb::PgForeachTotalPrivacyCountOfPackage(const int userId, const int } } - static const std::string PKGID_SELECT = std::string("SELECT DISTINCT PKG_ID FROM StatisticsMonitorInfo WHERE USER_ID=? AND USE_DATE>=? AND USE_DATE<=?"); - static const std::string PKGINFO_SELECT = std::string("SELECT COUNT(*) FROM StatisticsMonitorInfo WHERE USER_ID=? AND PKG_ID=? AND USE_DATE>=? AND USE_DATE<=?"); - sqlite3_stmt* infoStmt; + snprintf(buf, BUF_SIZE, "SELECT DISTINCT PKG_ID FROM StatisticsMonitorInfo WHERE (USER_ID=? OR USER_ID=%d) AND USE_DATE>=? AND USE_DATE<=?", GLOBAL_USER); + static const std::string PKGID_SELECT = std::string(buf); + + snprintf(buf, BUF_SIZE, "SELECT COUNT(*) FROM StatisticsMonitorInfo WHERE (USER_ID=? OR USER_ID=%d) AND PKG_ID=? AND USE_DATE>=? AND USE_DATE<=?", GLOBAL_USER); + static const std::string PKGINFO_SELECT = std::string(buf); m_dbMutex.lock(); @@ -448,10 +456,10 @@ PrivacyGuardDb::PgForeachTotalPrivacyCountOfPackage(const int userId, const int } int -PrivacyGuardDb::PgForeachTotalPrivacyCountOfPrivacy(const int userId, const int startDate, const int endDate, - std::list < std::pair < std::string, int > >& privacyInfoList) +PrivacyGuardDb::PgForeachTotalPrivacyCountOfPrivacy(const int userId, const int startDate, const int endDate, std::list < std::pair < std::string, int > >& privacyInfoList) { int res = -1; + char buf[BUF_SIZE]; // [CYNARA] Flush Entries res = cynara_monitor_entries_flush(p_cynara_monitor); @@ -463,7 +471,8 @@ PrivacyGuardDb::PgForeachTotalPrivacyCountOfPrivacy(const int userId, const int } } - static const std::string PRIVACY_SELECT = std::string("SELECT COUNT(*) FROM StatisticsMonitorInfo WHERE USER_ID=? AND PRIVACY_ID=? AND USE_DATE>=? AND USE_DATE<=?"); + snprintf(buf, BUF_SIZE, "SELECT COUNT(*) FROM StatisticsMonitorInfo WHERE (USER_ID=? OR USER_ID=%d) AND PRIVACY_ID=? AND USE_DATE>=? AND USE_DATE<=?", GLOBAL_USER); + static const std::string PRIVACY_SELECT = std::string(buf); m_dbMutex.lock(); @@ -520,6 +529,8 @@ PrivacyGuardDb::PgForeachPrivacyCountByPrivacyId(const int userId, const int sta const std::string privacyId, std::list < std::pair < std::string, int > >& packageInfoList) { int res = -1; + sqlite3_stmt* infoStmt; + char buf[BUF_SIZE]; // [CYNARA] Flush Entries res = cynara_monitor_entries_flush(p_cynara_monitor); @@ -531,9 +542,11 @@ PrivacyGuardDb::PgForeachPrivacyCountByPrivacyId(const int userId, const int sta } } - static const std::string PKGID_SELECT = std::string("SELECT DISTINCT PKG_ID FROM StatisticsMonitorInfo WHERE USER_ID=? AND PRIVACY_ID=? AND USE_DATE>=? AND USE_DATE<=?"); - static const std::string PKGINFO_SELECT = std::string("SELECT COUNT(*) FROM StatisticsMonitorInfo WHERE USER_ID=? AND PKG_ID=? AND PRIVACY_ID=? AND USE_DATE>=? AND USE_DATE<=?"); - sqlite3_stmt* infoStmt; + snprintf(buf, BUF_SIZE, "SELECT DISTINCT PKG_ID FROM StatisticsMonitorInfo WHERE (USER_ID=? OR USER_ID=%d) AND PRIVACY_ID=? AND USE_DATE>=? AND USE_DATE<=?", GLOBAL_USER); + static const std::string PKGID_SELECT = std::string(buf); + + snprintf(buf, BUF_SIZE, "SELECT COUNT(*) FROM StatisticsMonitorInfo WHERE (USER_ID=? OR USER_ID=%d) AND PKG_ID=? AND PRIVACY_ID=? AND USE_DATE>=? AND USE_DATE<=?", GLOBAL_USER); + static const std::string PKGINFO_SELECT = std::string(buf); m_dbMutex.lock(); @@ -609,6 +622,7 @@ PrivacyGuardDb::PgForeachPrivacyCountByPackageId(const int userId, const int sta const std::string packageId, std::list < std::pair < std::string, int > >& privacyInfoList) { int res = -1; + char buf[BUF_SIZE]; // [CYNARA] Flush Entries res = cynara_monitor_entries_flush(p_cynara_monitor); @@ -620,7 +634,8 @@ PrivacyGuardDb::PgForeachPrivacyCountByPackageId(const int userId, const int sta } } - static const std::string PRIVACY_SELECT = std::string("SELECT COUNT(*) FROM StatisticsMonitorInfo WHERE USER_ID=? AND PKG_ID=? AND PRIVACY_ID=? AND USE_DATE>=? AND USE_DATE<=?"); + snprintf(buf, BUF_SIZE, "SELECT COUNT(*) FROM StatisticsMonitorInfo WHERE (USER_ID=? OR USER_ID=%d) AND PKG_ID=? AND PRIVACY_ID=? AND USE_DATE>=? AND USE_DATE<=?", GLOBAL_USER); + static const std::string PRIVACY_SELECT = std::string(buf); m_dbMutex.lock(); @@ -679,7 +694,10 @@ PrivacyGuardDb::PgGetMonitorPolicy(const int userId, const std::string packageId { int res = -1; - static const std::string query = std::string("SELECT MONITOR_POLICY FROM MonitorPolicy WHERE USER_ID=? AND PKG_ID=? AND PRIVACY_ID=?"); + char buf[BUF_SIZE]; + + snprintf(buf, BUF_SIZE, "SELECT MONITOR_POLICY FROM MonitorPolicy WHERE (USER_ID=? OR USER_ID=%d) AND PKG_ID=? AND PRIVACY_ID=?", GLOBAL_USER); + static const std::string query = std::string(buf); m_dbMutex.lock(); @@ -776,7 +794,10 @@ int PrivacyGuardDb::PgForeachMonitorPolicyByPackageId(const int userId, const std::string packageId, std::list & privacyInfoList) { int res = -1; - static const std::string query = std::string("SELECT DISTINCT PRIVACY_ID, MONITOR_POLICY FROM MonitorPolicy WHERE USER_ID=? AND PKG_ID=?"); + char buf[BUF_SIZE]; + + snprintf(buf, BUF_SIZE, "SELECT DISTINCT PRIVACY_ID, MONITOR_POLICY FROM MonitorPolicy WHERE (USER_ID=? OR USER_ID=%d) AND PKG_ID=?", GLOBAL_USER); + static const std::string query = std::string(buf); m_dbMutex.lock(); @@ -825,7 +846,10 @@ int PrivacyGuardDb::PgForeachPrivacyPackageId(const int userId, std::list < std::string > &packageList) { int res = -1; - static const std::string query = std::string("SELECT DISTINCT PKG_ID FROM MonitorPolicy WHERE USER_ID=?"); + char buf[BUF_SIZE]; + + snprintf(buf, BUF_SIZE, "SELECT DISTINCT PKG_ID FROM MonitorPolicy WHERE (USER_ID=? OR USER_ID=%d)", GLOBAL_USER); + static const std::string query = std::string(buf); m_dbMutex.lock(); @@ -866,11 +890,16 @@ int PrivacyGuardDb::PgForeachPackageInfoByPrivacyId(const int userId, const std::string privacyId, std::list < package_data_s > &packageInfoList) { int res = -1; - static const std::string query = std::string("SELECT DISTINCT PKG_ID, MONITOR_POLICY FROM MonitorPolicy WHERE (USER_ID=? OR USER_ID=0) AND PRIVACY_ID=?"); - static const std::string PKGINFO_SELECT = std::string("SELECT COUNT(*) FROM StatisticsMonitorInfo WHERE (USER_ID=? OR USER_ID=0) AND PKG_ID=? AND PRIVACY_ID=? AND USE_DATE>=? AND USE_DATE<=?"); sqlite3_stmt* infoStmt; time_t start_date, today_midnight, end_date; struct tm date; + char buf[BUF_SIZE]; + + snprintf(buf, BUF_SIZE, "SELECT DISTINCT PKG_ID, MONITOR_POLICY FROM MonitorPolicy WHERE (USER_ID=? OR USER_ID=%d) AND PRIVACY_ID=?", GLOBAL_USER); + static const std::string query = std::string(buf); + + snprintf(buf, BUF_SIZE, "SELECT COUNT(*) FROM StatisticsMonitorInfo WHERE (USER_ID=? OR USER_ID=%d) AND PKG_ID=? AND PRIVACY_ID=? AND USE_DATE>=? AND USE_DATE<=?", GLOBAL_USER); + static const std::string PKGINFO_SELECT = std::string(buf); // get start~end date (for 7 days) end_date = time(NULL); @@ -893,7 +922,6 @@ PrivacyGuardDb::PgForeachPackageInfoByPrivacyId(const int userId, const std::str PG_LOGE("cynara_monitor_entries_flush FAIL [%d]", res); } } - m_dbMutex.lock(); // initialize @@ -971,7 +999,10 @@ int PrivacyGuardDb::PgUpdateMonitorPolicy(const int userId, const std::string packageId, const std::string privacyId, const int monitorPolicy) { int res = -1; - static const std::string query = std::string("UPDATE MonitorPolicy SET MONITOR_POLICY=? WHERE USER_ID=? AND PKG_ID=? AND PRIVACY_ID=?"); + char buf[BUF_SIZE]; + + snprintf(buf, BUF_SIZE, "UPDATE MonitorPolicy SET MONITOR_POLICY=? WHERE (USER_ID=? OR USER_ID=%d) AND PKG_ID=? AND PRIVACY_ID=?", GLOBAL_USER); + static const std::string query = std::string(buf); m_dbMutex.lock(); @@ -1057,7 +1088,10 @@ int PrivacyGuardDb::PgUpdateMainMonitorPolicy(const int userId, const bool mainMonitorPolicy) { int res = -1; - static const std::string query = std::string("UPDATE MainMonitorPolicy SET MAIN_MONITOR_POLICY=? WHERE USER_ID=?"); + char buf[BUF_SIZE]; + + snprintf(buf, BUF_SIZE, "UPDATE MainMonitorPolicy SET MAIN_MONITOR_POLICY=? WHERE (USER_ID=? OR USER_ID=%d)", GLOBAL_USER); + static const std::string query = std::string(buf); m_dbMutex.lock(); @@ -1101,9 +1135,11 @@ PrivacyGuardDb::PgUpdateMainMonitorPolicy(const int userId, const bool mainMonit int PrivacyGuardDb::PgGetMainMonitorPolicy(const int userId, bool &mainMonitorPolicy) { - int res = -1; - static const std::string query = std::string("SELECT MAIN_MONITOR_POLICY FROM MainMonitorPolicy WHERE USER_ID=?"); + char buf[BUF_SIZE]; + + snprintf(buf, BUF_SIZE, "SELECT MAIN_MONITOR_POLICY FROM MainMonitorPolicy WHERE (USER_ID=? OR USER_ID=%d)", GLOBAL_USER); + static const std::string query = std::string(buf); m_dbMutex.lock(); diff --git a/server/src/SocketService.cpp b/server/src/SocketService.cpp old mode 100755 new mode 100644 index 8744ae1..e3cfd90 --- a/server/src/SocketService.cpp +++ b/server/src/SocketService.cpp @@ -39,12 +39,10 @@ SocketService::SocketService(void) , m_signalToClose(-1) , m_mainThread(-1) { - //PG_LOGD("SocketService() called."); } SocketService::~SocketService(void) { - //PG_LOGD("~SocketService() called."); } int @@ -86,8 +84,6 @@ SocketService::initialize(void) int SocketService::start(void) { - //PG_LOGI("SocketService starting"); - sigset_t sigset; sigemptyset(&sigset); // if ( sigaddset(&sigset, m_signalToClose) == -1 ) @@ -107,19 +103,15 @@ SocketService::start(void) m_mainThread = mainThread; - //PG_LOGI("SocketService started"); - return PRIV_GUARD_ERROR_SUCCESS; } void* SocketService::serverThread(void* pData) { - //PG_LOGD("serverThread() called."); pthread_detach(pthread_self()); SocketService &t = *static_cast< SocketService* > (pData); - //PG_LOGD("Running main thread"); int ret = t.mainloop(); if (ret < 0) { return (void*) 1; @@ -131,8 +123,6 @@ SocketService::serverThread(void* pData) int SocketService::mainloop(void) { - //PG_LOGD("mainloop() called."); - char buf[BUF_SIZE]; if( listen(m_listenFd, MAX_LISTEN) == -1 ){ @@ -226,11 +216,10 @@ SocketService::mainloop(void) void* SocketService::connectionThread(void* pData) { - //PG_LOGD("connectionThread() called."); pthread_detach(pthread_self()); std::unique_ptr connectionInfo (static_cast(pData)); SocketService &t = *static_cast(connectionInfo->pData); - //PG_LOGI("Starting connection thread"); + int ret = t.connectionService(connectionInfo->connFd); if (ret < 0) { @@ -239,15 +228,12 @@ SocketService::connectionThread(void* pData) close(connectionInfo->connFd); return (void*)1; } - //PG_LOGI("Client serviced"); return (void*)0; } int SocketService::connectionService(int fd) { - //PG_LOGD("connectionService() called."); - SocketConnection connector = SocketConnection(fd); std::string interfaceName, methodName; @@ -280,23 +266,17 @@ SocketService::connectionService(int fd) // } // } - //PG_LOGI("Calling service"); m_callbackMap[interfaceName][methodName]->serviceCallback(&connector); - //PG_LOGI("Removing client"); removeClientSocket(fd); close(fd); - //PG_LOGI("Call served"); - return PRIV_GUARD_ERROR_SUCCESS; } int SocketService::stop(void) { - //PG_LOGD("Stopping"); - char buf[BUF_SIZE]; if(close(m_listenFd) == -1) @@ -315,23 +295,18 @@ SocketService::stop(void) } pthread_join(m_mainThread, NULL); - //PG_LOGD("Stopped"); - return PRIV_GUARD_ERROR_SUCCESS; } int SocketService::shutdown(void) { - //PG_LOGD("called"); return PRIV_GUARD_ERROR_SUCCESS; } int SocketService::registerServiceCallback(const std::string &interfaceName, const std::string &methodName, socketServiceCallback callbackMethod) { - //PG_LOGD("called"); - if(NULL == callbackMethod) { PG_LOGE("Null callback"); @@ -352,8 +327,6 @@ SocketService::registerServiceCallback(const std::string &interfaceName, const void SocketService::addClientSocket(int clientSocket) { - //PG_LOGD("called"); - std::lock_guard guard(m_clientSocketListMutex); m_clientSocketList.push_back(clientSocket); } @@ -361,8 +334,6 @@ SocketService::addClientSocket(int clientSocket) void SocketService::removeClientSocket(int clientSocket) { - //PG_LOGD("called"); - std::lock_guard guard(m_clientSocketListMutex); m_clientSocketList.remove(clientSocket); } @@ -370,8 +341,6 @@ SocketService::removeClientSocket(int clientSocket) bool SocketService::popClientSocket(int * pClientSocket) { - //PG_LOGD("called"); - std::lock_guard guard(m_clientSocketListMutex); if(m_clientSocketList.empty()) return false; @@ -384,8 +353,6 @@ SocketService::popClientSocket(int * pClientSocket) void SocketService::closeConnections(void) { - //PG_LOGD("called"); - int clientSocket; char buf[BUF_SIZE]; PG_LOGI("Closing client sockets"); @@ -396,6 +363,4 @@ SocketService::closeConnections(void) PG_LOGE("close() : %s", strerror_r(errno, buf, sizeof(buf))); } } - - //PG_LOGD("Connections closed"); } diff --git a/server/src/main.cpp b/server/src/main.cpp old mode 100755 new mode 100644 index 6050163..528355b --- a/server/src/main.cpp +++ b/server/src/main.cpp @@ -17,29 +17,20 @@ #include #include "PrivacyGuardDaemon.h" -// [kylee76]temp -#include "Utils.h" - int main(int argc, char* argv[]) { - PG_LOGD("called"); PrivacyGuardDaemon* pDaemon = PrivacyGuardDaemon::getInstance(); - PG_LOGD("pDaemon->initialize()"); pDaemon->initialize(); - PG_LOGD("pDaemon->start()"); pDaemon->start(); GMainLoop* pLoop; pLoop = g_main_new(TRUE); - PG_LOGD("g_main_loop_run(pLoop)"); g_main_loop_run(pLoop); - PG_LOGD("pDaemon->stop()"); pDaemon->stop(); - PG_LOGD("pDaemon->shutdown()"); pDaemon->shutdown(); return 0; diff --git a/server/src/privacy_guard_daemon.cpp b/server/src/privacy_guard_daemon.cpp old mode 100755 new mode 100644 index 892bfe1..efd2ca2 --- a/server/src/privacy_guard_daemon.cpp +++ b/server/src/privacy_guard_daemon.cpp @@ -20,27 +20,23 @@ int privacy_guard_daemon_initialize(void) { PrivacyGuardDaemon* pPrivacyDaemon = PrivacyGuardDaemon::getInstance(); - return pPrivacyDaemon->initialize(); } int privacy_guard_daemon_start(void) { PrivacyGuardDaemon* pInstance = PrivacyGuardDaemon::getInstance(); - return pInstance->start(); } int privacy_guard_daemon_stop(void) { PrivacyGuardDaemon* pInstance = PrivacyGuardDaemon::getInstance(); - return pInstance->stop(); } int privacy_guard_daemon_shutdown(void) { PrivacyGuardDaemon* pInstance = PrivacyGuardDaemon::getInstance(); - return pInstance->shutdown(); }