Change-Id: I770d04d4895c1f3f99210611ca42f23fb512d990
19 files changed:
PrivacyChecker::checkMonitorPolicyWithPrivilege(const int userId, const std::string packageId, const std::string privilegeId, std::string &privacyId, int &monitorPolicy)
{
checkMonitorByPrivilege(privilegeId);
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);
if (m_isMonitorEnable == true) {
int res = PrivacyIdInfo::getPrivacyIdFromPrivilege(privilegeId, privacyId);
TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "getPrivacyIdFromPrivilege : %d", res);
PrivacyChecker::runSignalListenerThread(void* pData)
{
pthread_detach(pthread_self());
PrivacyChecker::runSignalListenerThread(void* pData)
{
pthread_detach(pthread_self());
PG_LOGI("Running g main loop for signal");
initializeDbus();
PG_LOGI("Running g main loop for signal");
initializeDbus();
res = m_pSocketClient->connect();
if(res != PRIV_GUARD_ERROR_SUCCESS) {
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;
isServerOperation = false;
- PG_LOGE("connect : %d", res);
- PG_LOGD("Failed to connect. So change to the offline mode");
} else {
isServerOperation = true;
}
} else {
isServerOperation = true;
}
//Socket should be already closed by server side,
//even though we should close it in case of any errors
close(m_socketFd);
//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;
PG_LOGI("Client disconnected");
return PRIV_GUARD_ERROR_SUCCESS;
if (packageList.size() == 0)
return PRIV_GUARD_ERROR_NO_DATA;
if (packageList.size() == 0)
return PRIV_GUARD_ERROR_NO_DATA;
#endif //_PRIVACY_GUARD_CLIENT_INTERNAL_TYPES_H_
\ No newline at end of file
#endif //_PRIVACY_GUARD_CLIENT_INTERNAL_TYPES_H_
\ No newline at end of file
* limitations under the License.
*/
* limitations under the License.
*/
-#ifndef _IPRIVACYGUARD_H_
-#define _IPRIVACYGUARD_H_
+#ifndef _IPRIVACY_GUARD_H_
+#define _IPRIVACY_GUARD_H_
#include <string>
#include <mutex>
#include <string>
#include <mutex>
int getAppPackagePrivacyInfo(const std::string pkgId, std::list < std::pair <std::string, bool > > & pList);
};
int getAppPackagePrivacyInfo(const std::string pkgId, std::list < std::pair <std::string, bool > > & pList);
};
-#endif // _IPRIVACYGUARD_H_
\ No newline at end of file
+#endif // _IPRIVACY_GUARD_H_
\ No newline at end of file
#include <db-util.h>
#include <stdbool.h>
#include <db-util.h>
#include <stdbool.h>
-#endif // PRIVACYGUARDCOMMON_H_
+#endif // _PRIVACY_GUARD_COMMON_H_
\ No newline at end of file
#define CYNARA_BUFFER_SIZE 100
#define USER_APP_PREFIX "User::App::"
#define USER_APP_PREFIX_LEN 11
#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 USER_PKG_PREFIX "User::Pkg::"
#define USER_PKG_PREFIX_LEN 11
#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
typedef struct _privacy_data_s {
#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
typedef struct _privacy_data_s {
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 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
explicit SocketConnection(int socket_fd) : m_socketStream(socket_fd){
PG_LOGI("Created");
}
explicit SocketConnection(int socket_fd) : m_socketStream(socket_fd){
PG_LOGI("Created");
}
private:
SocketStream m_socketStream;
};
private:
SocketStream m_socketStream;
};
int readStream(size_t num, void * bytes);
int writeStream(size_t num, const void * bytes);
int readStream(size_t num, void * bytes);
int writeStream(size_t num, const void * bytes);
private:
int throwWithErrnoMessage(std::string specificInfo);
int m_socketFd;
private:
int throwWithErrnoMessage(std::string specificInfo);
int m_socketFd;
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
#define IF_MATCH_RET_ERROR(condition, msgFormat, error) \
if (condition) { \
PG_LOGE(msgFormat, error); \
#define IF_MATCH_RET_ERROR(condition, msgFormat, error) \
if (condition) { \
PG_LOGE(msgFormat, error); \
public:
static std::string toHash (std::string src);
};
public:
static std::string toHash (std::string src);
};
PG_LOGE("Failed to do pkgmgrinfo_pkginfo_is_global [%d]", res);
} else {
if (is_global == true) {
PG_LOGE("Failed to do pkgmgrinfo_pkginfo_is_global [%d]", res);
} else {
if (is_global == true) {
- userId = GLOBAL_APP_USER_ID;
}
}
pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle);
}
}
pkgmgrinfo_pkginfo_destroy_pkginfo(pkg_handle);
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;
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;
}
return PRIV_GUARD_ERROR_SUCCESS;
}
#include "PrivacyGuardDaemon.h"
#include "PrivacyInfoService.h"
#include "SocketService.h"
#include "PrivacyGuardDaemon.h"
#include "PrivacyInfoService.h"
#include "SocketService.h"
#include <CynaraService.h>
PrivacyGuardDaemon* PrivacyGuardDaemon::pInstance = NULL;
#include <CynaraService.h>
PrivacyGuardDaemon* PrivacyGuardDaemon::pInstance = NULL;
PG_LOGD("calling PrivacyInfoService::registerCallbacks(pSocketService)");
PrivacyInfoService::registerCallbacks(pSocketService);
PG_LOGD("calling PrivacyInfoService::registerCallbacks(pSocketService)");
PrivacyInfoService::registerCallbacks(pSocketService);
if (pCynaraService == NULL)
pCynaraService = new CynaraService();
if (pCynaraService == NULL)
pCynaraService = new CynaraService();
PG_LOGD("calling pCynaraService->start()");
if (pCynaraService == NULL)
return PRIV_GUARD_ERROR_NOT_INITIALIZED;
PG_LOGD("calling pCynaraService->start()");
if (pCynaraService == NULL)
return PRIV_GUARD_ERROR_NOT_INITIALIZED;
#define PRIVACY_GUARD_DAYS 7
#define UNIX_TIME_ONE_DAY (24 * 60 * 60) // 86400 secs
#define PRIVACY_GUARD_DAYS 7
#define UNIX_TIME_ONE_DAY (24 * 60 * 60) // 86400 secs
std::mutex PrivacyGuardDb::m_singletonMutex;
PrivacyGuardDb* PrivacyGuardDb::m_pInstance = NULL;
std::mutex PrivacyGuardDb::m_singletonMutex;
PrivacyGuardDb* PrivacyGuardDb::m_pInstance = NULL;
res = sqlite3_open_v2(PRIVACY_DB_PATH, &m_sqlHandler, SQLITE_OPEN_READWRITE, NULL);
if(res == SQLITE_OK) {
PG_LOGI("monitor db is opened successfully");
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 {
m_bDBOpen = true;
}
else {
PrivacyGuardDb::PgCheckPrivacyPackage(const int userId, const std::string packageId, bool &isPrivacyPackage)
{
int res = -1;
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);
PrivacyGuardDb::PgForeachTotalPrivacyCountOfPackage(const int userId, const int startDate, const int endDate, std::list < std::pair < std::string, int > >& packageInfoList)
{
int res = -1;
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);
// [CYNARA] Flush Entries
res = cynara_monitor_entries_flush(p_cynara_monitor);
- 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);
-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)
// [CYNARA] Flush Entries
res = cynara_monitor_entries_flush(p_cynara_monitor);
// [CYNARA] Flush Entries
res = cynara_monitor_entries_flush(p_cynara_monitor);
- 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);
const std::string privacyId, std::list < std::pair < std::string, int > >& packageInfoList)
{
int res = -1;
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);
// [CYNARA] Flush Entries
res = cynara_monitor_entries_flush(p_cynara_monitor);
- 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);
const std::string packageId, std::list < std::pair < std::string, int > >& privacyInfoList)
{
int res = -1;
const std::string packageId, std::list < std::pair < std::string, int > >& privacyInfoList)
{
int res = -1;
// [CYNARA] Flush Entries
res = cynara_monitor_entries_flush(p_cynara_monitor);
// [CYNARA] Flush Entries
res = cynara_monitor_entries_flush(p_cynara_monitor);
- 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);
- 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);
PrivacyGuardDb::PgForeachMonitorPolicyByPackageId(const int userId, const std::string packageId, std::list <privacy_data_s>& privacyInfoList)
{
int res = -1;
PrivacyGuardDb::PgForeachMonitorPolicyByPackageId(const int userId, const std::string packageId, std::list <privacy_data_s>& 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);
PrivacyGuardDb::PgForeachPrivacyPackageId(const int userId, std::list < std::string > &packageList)
{
int res = -1;
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);
PrivacyGuardDb::PgForeachPackageInfoByPrivacyId(const int userId, const std::string privacyId, std::list < package_data_s > &packageInfoList)
{
int res = -1;
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;
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);
// get start~end date (for 7 days)
end_date = time(NULL);
PG_LOGE("cynara_monitor_entries_flush FAIL [%d]", res);
}
}
PG_LOGE("cynara_monitor_entries_flush FAIL [%d]", res);
}
}
m_dbMutex.lock();
// initialize
m_dbMutex.lock();
// initialize
PrivacyGuardDb::PgUpdateMonitorPolicy(const int userId, const std::string packageId, const std::string privacyId, const int monitorPolicy)
{
int res = -1;
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);
PrivacyGuardDb::PgUpdateMainMonitorPolicy(const int userId, const bool mainMonitorPolicy)
{
int res = -1;
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);
int
PrivacyGuardDb::PgGetMainMonitorPolicy(const int userId, bool &mainMonitorPolicy)
{
int
PrivacyGuardDb::PgGetMainMonitorPolicy(const int userId, bool &mainMonitorPolicy)
{
- 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_signalToClose(-1)
, m_mainThread(-1)
{
, m_signalToClose(-1)
, m_mainThread(-1)
{
- //PG_LOGD("SocketService() called.");
}
SocketService::~SocketService(void)
{
}
SocketService::~SocketService(void)
{
- //PG_LOGD("~SocketService() called.");
int
SocketService::start(void)
{
int
SocketService::start(void)
{
- //PG_LOGI("SocketService starting");
-
sigset_t sigset;
sigemptyset(&sigset);
// if ( sigaddset(&sigset, m_signalToClose) == -1 )
sigset_t sigset;
sigemptyset(&sigset);
// if ( sigaddset(&sigset, m_signalToClose) == -1 )
m_mainThread = mainThread;
m_mainThread = mainThread;
- //PG_LOGI("SocketService started");
-
return PRIV_GUARD_ERROR_SUCCESS;
}
void*
SocketService::serverThread(void* pData)
{
return PRIV_GUARD_ERROR_SUCCESS;
}
void*
SocketService::serverThread(void* pData)
{
- //PG_LOGD("serverThread() called.");
pthread_detach(pthread_self());
SocketService &t = *static_cast< SocketService* > (pData);
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;
int ret = t.mainloop();
if (ret < 0) {
return (void*) 1;
int
SocketService::mainloop(void)
{
int
SocketService::mainloop(void)
{
- //PG_LOGD("mainloop() called.");
-
char buf[BUF_SIZE];
if( listen(m_listenFd, MAX_LISTEN) == -1 ){
char buf[BUF_SIZE];
if( listen(m_listenFd, MAX_LISTEN) == -1 ){
void*
SocketService::connectionThread(void* pData)
{
void*
SocketService::connectionThread(void* pData)
{
- //PG_LOGD("connectionThread() called.");
pthread_detach(pthread_self());
std::unique_ptr<ConnectionInfo> connectionInfo (static_cast<ConnectionInfo *>(pData));
SocketService &t = *static_cast<SocketService *>(connectionInfo->pData);
pthread_detach(pthread_self());
std::unique_ptr<ConnectionInfo> connectionInfo (static_cast<ConnectionInfo *>(pData));
SocketService &t = *static_cast<SocketService *>(connectionInfo->pData);
- //PG_LOGI("Starting connection thread");
int ret = t.connectionService(connectionInfo->connFd);
if (ret < 0)
{
int ret = t.connectionService(connectionInfo->connFd);
if (ret < 0)
{
close(connectionInfo->connFd);
return (void*)1;
}
close(connectionInfo->connFd);
return (void*)1;
}
- //PG_LOGI("Client serviced");
return (void*)0;
}
int
SocketService::connectionService(int fd)
{
return (void*)0;
}
int
SocketService::connectionService(int fd)
{
- //PG_LOGD("connectionService() called.");
-
SocketConnection connector = SocketConnection(fd);
std::string interfaceName, methodName;
SocketConnection connector = SocketConnection(fd);
std::string interfaceName, methodName;
- //PG_LOGI("Calling service");
m_callbackMap[interfaceName][methodName]->serviceCallback(&connector);
m_callbackMap[interfaceName][methodName]->serviceCallback(&connector);
- //PG_LOGI("Removing client");
removeClientSocket(fd);
close(fd);
removeClientSocket(fd);
close(fd);
- //PG_LOGI("Call served");
-
return PRIV_GUARD_ERROR_SUCCESS;
}
int
SocketService::stop(void)
{
return PRIV_GUARD_ERROR_SUCCESS;
}
int
SocketService::stop(void)
{
- //PG_LOGD("Stopping");
-
char buf[BUF_SIZE];
if(close(m_listenFd) == -1)
char buf[BUF_SIZE];
if(close(m_listenFd) == -1)
}
pthread_join(m_mainThread, NULL);
}
pthread_join(m_mainThread, NULL);
- //PG_LOGD("Stopped");
-
return PRIV_GUARD_ERROR_SUCCESS;
}
int
SocketService::shutdown(void)
{
return PRIV_GUARD_ERROR_SUCCESS;
}
int
SocketService::shutdown(void)
{
return PRIV_GUARD_ERROR_SUCCESS;
}
int
SocketService::registerServiceCallback(const std::string &interfaceName, const std::string &methodName, socketServiceCallback callbackMethod)
{
return PRIV_GUARD_ERROR_SUCCESS;
}
int
SocketService::registerServiceCallback(const std::string &interfaceName, const std::string &methodName, socketServiceCallback callbackMethod)
{
if(NULL == callbackMethod)
{
PG_LOGE("Null callback");
if(NULL == callbackMethod)
{
PG_LOGE("Null callback");
void
SocketService::addClientSocket(int clientSocket)
{
void
SocketService::addClientSocket(int clientSocket)
{
std::lock_guard<std::mutex> guard(m_clientSocketListMutex);
m_clientSocketList.push_back(clientSocket);
}
std::lock_guard<std::mutex> guard(m_clientSocketListMutex);
m_clientSocketList.push_back(clientSocket);
}
void
SocketService::removeClientSocket(int clientSocket)
{
void
SocketService::removeClientSocket(int clientSocket)
{
std::lock_guard<std::mutex> guard(m_clientSocketListMutex);
m_clientSocketList.remove(clientSocket);
}
std::lock_guard<std::mutex> guard(m_clientSocketListMutex);
m_clientSocketList.remove(clientSocket);
}
bool
SocketService::popClientSocket(int * pClientSocket)
{
bool
SocketService::popClientSocket(int * pClientSocket)
{
std::lock_guard<std::mutex> guard(m_clientSocketListMutex);
if(m_clientSocketList.empty())
return false;
std::lock_guard<std::mutex> guard(m_clientSocketListMutex);
if(m_clientSocketList.empty())
return false;
void
SocketService::closeConnections(void)
{
void
SocketService::closeConnections(void)
{
int clientSocket;
char buf[BUF_SIZE];
PG_LOGI("Closing client sockets");
int clientSocket;
char buf[BUF_SIZE];
PG_LOGI("Closing client sockets");
PG_LOGE("close() : %s", strerror_r(errno, buf, sizeof(buf)));
}
}
PG_LOGE("close() : %s", strerror_r(errno, buf, sizeof(buf)));
}
}
-
- //PG_LOGD("Connections closed");
#include <glib.h>
#include "PrivacyGuardDaemon.h"
#include <glib.h>
#include "PrivacyGuardDaemon.h"
-// [kylee76]temp
-#include "Utils.h"
-
int
main(int argc, char* argv[])
{
int
main(int argc, char* argv[])
{
PrivacyGuardDaemon* pDaemon = PrivacyGuardDaemon::getInstance();
PrivacyGuardDaemon* pDaemon = PrivacyGuardDaemon::getInstance();
- PG_LOGD("pDaemon->initialize()");
- PG_LOGD("pDaemon->start()");
pDaemon->start();
GMainLoop* pLoop;
pLoop = g_main_new(TRUE);
pDaemon->start();
GMainLoop* pLoop;
pLoop = g_main_new(TRUE);
- PG_LOGD("g_main_loop_run(pLoop)");
- PG_LOGD("pDaemon->stop()");
- PG_LOGD("pDaemon->shutdown()");
pDaemon->shutdown();
return 0;
pDaemon->shutdown();
return 0;
int privacy_guard_daemon_initialize(void)
{
PrivacyGuardDaemon* pPrivacyDaemon = PrivacyGuardDaemon::getInstance();
int privacy_guard_daemon_initialize(void)
{
PrivacyGuardDaemon* pPrivacyDaemon = PrivacyGuardDaemon::getInstance();
return pPrivacyDaemon->initialize();
}
int privacy_guard_daemon_start(void)
{
PrivacyGuardDaemon* pInstance = 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->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->stop();
}
int privacy_guard_daemon_shutdown(void)
{
PrivacyGuardDaemon* pInstance = PrivacyGuardDaemon::getInstance();
return pInstance->shutdown();
}
return pInstance->shutdown();
}