same "printed page" as the copyright notice for easier
identification within third-party archives.
- Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ Copyright (c) 2011 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.
###################################################################################################
## for libprivacy-guard-client (executable)
INCLUDE_DIRECTORIES(${pkgs_INCLUDE_DIRS} ${client_include_dir} ${common_include_dir} ${extern_include_dir})
-SET(PRIVACY_GUARD_CLIENT_SOURCES
+SET(PRIVACY_GUARD_CLIENT_SOURCES
${common_src_dir}/SocketConnection.cpp
${common_src_dir}/SocketStream.cpp
${common_src_dir}/PrivacyIdInfo.cpp
#include <memory>
#include <string>
-#include <dlog.h>
#include "SocketConnection.h"
/* IMPORTANT:
int call(std::string methodName)
{
- PF_LOGI("call m_interfaceName : %s, methodName : %s", m_interfaceName.c_str(), methodName.c_str());
+ PG_LOGI("call m_interfaceName : %s, methodName : %s", m_interfaceName.c_str(), methodName.c_str());
int res = make_call(m_interfaceName);
- PF_LOGI("call make_call interface res : %d", res);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "make_call : %d", res);
+ PG_LOGI("call make_call interface res : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "make_call : %d", res);
res = make_call(methodName);
- PF_LOGI("call make_call method res : %d", res);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "make_call : %d", res);
+ PG_LOGI("call make_call method res : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "make_call : %d", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
template<typename ...Args>
int call(std::string methodName, const Args&... args)
{
- PF_LOGI("call Args m_interfaceName : %s, methodName : %s", m_interfaceName.c_str(), methodName.c_str());
+ PG_LOGI("call Args m_interfaceName : %s, methodName : %s", m_interfaceName.c_str(), methodName.c_str());
int res = make_call(m_interfaceName);
- PF_LOGI("call Args make_call interface res : %d", res);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "make_call : %d", res);
+ PG_LOGI("call Args make_call interface res : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "make_call : %d", res);
res = make_call(methodName);
- PF_LOGI("call Args make_call method res : %d", res);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "make_call : %d", res);
+ PG_LOGI("call Args make_call method res : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "make_call : %d", res);
res = make_call(args...);
- PF_LOGI("call Args make_call args res : %d", res);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "make_call : %d", res);
+ PG_LOGI("call Args make_call args res : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "make_call : %d", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
template<typename T>
int make_call(const T& invalue, const Args&... args)
{
int res = make_call(invalue);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "make_call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "make_call : %d", res);
res = make_call(args...);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "make_call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "make_call : %d", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
template<typename T>
int make_call(const T* invalue, const Args&... args)
{
int res = make_call(invalue);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "make_call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "make_call : %d", res);
res = make_call(args...);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "make_call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "make_call : %d", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
template<typename T>
int make_call(T * outvalue, const Args&... args)
{
int res = make_call(outvalue);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "make_call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "make_call : %d", res);
res = make_call(args...);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "make_call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "make_call : %d", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
template<typename T>
* 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.
+ * limitations under the License.
*/
-
+
/**
* @file privacy_guard_client_internal.h
* @brief APIs for privacy-guard-client
#include <algorithm>
#include <memory>
-#include <dlog.h>
#include <sqlite3.h>
#include <dbus/dbus-glib-lowlevel.h>
#include <sys/types.h>
PrivacyChecker::initialize(void)
{
if (m_isInitialized) {
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
std::lock_guard < std::mutex > guard(m_cacheMutex);
int res = initMonitorPolicyCache();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, ,"Failed to update cache (%d)", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, ,"Failed to update cache (%d)", res);
res = initializeGMain();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, ,"Failed to initialize() (%d)", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, ,"Failed to initialize() (%d)", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
{
std::unique_lock<std::mutex> initlock(m_initializeMutex);
- TryReturn(!m_isInitialized, PRIV_FLTR_ERROR_SUCCESS, , "Already Initalized");
+ TryReturn(!m_isInitialized, PRIV_GUARD_ERROR_SUCCESS, , "Already Initalized");
m_pHandlerGMainContext = g_main_context_new();
- TryReturn(m_pHandlerGMainContext != NULL, PRIV_FLTR_ERROR_SYSTEM_ERROR, ,"cannot create m_pHandlerGMainContext");
+ TryReturn(m_pHandlerGMainContext != NULL, PRIV_GUARD_ERROR_SYSTEM_ERROR, ,"cannot create m_pHandlerGMainContext");
m_pLoop = g_main_loop_new(m_pHandlerGMainContext, FALSE);
- TryReturn(m_pLoop != NULL, PRIV_FLTR_ERROR_SYSTEM_ERROR, ,"cannot create m_pLoop");
+ TryReturn(m_pLoop != NULL, PRIV_GUARD_ERROR_SYSTEM_ERROR, ,"cannot create m_pLoop");
std::unique_lock<std::mutex> lock(m_dbusMutex);
int res = pthread_create(&m_signalThread, NULL, &runSignalListenerThread, NULL);
- TryReturn(res >= 0, PRIV_FLTR_ERROR_SYSTEM_ERROR, errno = res;, "Failed to create listener thread :%s", strerror(res));
+ TryReturn(res >= 0, PRIV_GUARD_ERROR_SYSTEM_ERROR, errno = res;, "Failed to create listener thread :%s", strerror(res));
m_isInitialized = true;
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
void
PrivacyChecker::printMonitorPolicyCache(void)
{
- for(std::map<std::string, int>::iterator itr = m_monitorPolicyCache.begin(); itr != m_monitorPolicyCache.end(); itr++) {
- PF_LOGD("PRIVACY string : %s", itr->first.c_str());
- PF_LOGD("PRIVACY monitor_policy : %d", itr->second);
+ for(std::map<std::string, int>::iterator itr = m_monitorPolicyCache.begin(); itr != m_monitorPolicyCache.end(); itr++) {
+ PG_LOGD("PRIVACY string : %s", itr->first.c_str());
+ PG_LOGD("PRIVACY monitor_policy : %d", itr->second);
}
}
int
PrivacyChecker::initMonitorPolicyCache(void)
{
- PF_LOGD("PrivacyChecker::initCache");
+ PG_LOGD("PrivacyChecker::initCache");
std::list < std::pair < std::string, int > > monitorPolicyList;
int retval = PrivacyGuardClient::getInstance()->PgGetAllMonitorPolicy(monitorPolicyList);
- if(retval == PRIV_FLTR_ERROR_SUCCESS && !monitorPolicyList.empty()) {
+ if(retval == PRIV_GUARD_ERROR_SUCCESS && !monitorPolicyList.empty()) {
m_monitorPolicyCache.insert(monitorPolicyList.begin(), monitorPolicyList.end());
}
return retval;
int
PrivacyChecker::getMonitorPolicy(const int userId, const std::string packageId, const std::string privacyId, int &monitorPolicy)
{
- PF_LOGD("getMonitorPolicy m_isInitialized : %d", m_isInitialized);
+ PG_LOGD("getMonitorPolicy m_isInitialized : %d", m_isInitialized);
if (m_isInitialized == false) {
initialize();
// printMonitorPolicyCache();
std::string userPkgIdPrivacyId = std::to_string(userId) + std::string("|") + packageId + std::string("|") + privacyId;
- PF_LOGD("key : %s", userPkgIdPrivacyId.c_str());
+ PG_LOGD("key : %s", userPkgIdPrivacyId.c_str());
std::map<std::string, int>::iterator itr = m_monitorPolicyCache.find(userPkgIdPrivacyId);
- int res = PRIV_FLTR_ERROR_SUCCESS;
+ int res = PRIV_GUARD_ERROR_SUCCESS;
if(itr != m_monitorPolicyCache.end()) {
monitorPolicy = itr->second;
}
else {
monitorPolicy = 0;
- res = PRIV_FLTR_ERROR_NO_DATA;
+ res = PRIV_GUARD_ERROR_NO_DATA;
}
- PF_LOGD("Here3");
+ PG_LOGD("Here3");
return res;
}
void
PrivacyChecker::checkMonitorByPrivilege(const std::string privilegeId)
{
- PF_LOGD("checkMonitorByPrivilege");
+ PG_LOGD("checkMonitorByPrivilege");
if(privilegeId.compare("http://tizen.org/privilege/calendar.read") == 0 ||
privilegeId.compare("http://tizen.org/privilege/calendar.write") == 0 ||
checkMonitorByPrivilege(privilegeId);
if (m_isMonitorEnable == true) {
int res = PrivacyIdInfo::getPrivacyIdFromPrivilege(privilegeId, privacyId);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "getPrivacyIdFromPrivilege : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "getPrivacyIdFromPrivilege : %d", res);
return getMonitorPolicy(userId, packageId, privacyId, monitorPolicy);
}
else {
- return PRIV_FLTR_ERROR_NO_DATA;
+ return PRIV_GUARD_ERROR_NO_DATA;
}
}
PrivacyChecker::runSignalListenerThread(void* pData)
{
pthread_detach(pthread_self());
- LOGI("Running g main loop for signal");
+ PG_LOGI("Running g main loop for signal");
initializeDbus();
dbus_error_init(&error);
m_pDBusConnection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
- TryReturn(m_pDBusConnection != NULL, PRIV_FLTR_ERROR_SYSTEM_ERROR, dbus_error_free(&error), "dbus_bus_get_private [%s] : %d", PRIV_FLTR_ERROR_SYSTEM_ERROR);
+ TryReturn(m_pDBusConnection != NULL, PRIV_GUARD_ERROR_SYSTEM_ERROR, dbus_error_free(&error), "dbus_bus_get_private [%s] : %d", PRIV_GUARD_ERROR_SYSTEM_ERROR);
dbus_connection_setup_with_g_main(m_pDBusConnection, m_pHandlerGMainContext);
std::unique_ptr < char[] > pRule(new char[MAX_LOCAL_BUF_SIZE]);
snprintf(pRule.get(), MAX_LOCAL_BUF_SIZE, "path='%s',type='signal',interface='%s'", DBUS_PATH.c_str(), DBUS_SIGNAL_INTERFACE.c_str());
dbus_bus_add_match(m_pDBusConnection, pRule.get(), &error);
- TryReturn(!dbus_error_is_set(&error), PRIV_FLTR_ERROR_SYSTEM_ERROR, dbus_error_free(&error), "dbus_bus_add_match[%s] : %d", error.message, PRIV_FLTR_ERROR_SYSTEM_ERROR);
+ TryReturn(!dbus_error_is_set(&error), PRIV_GUARD_ERROR_SYSTEM_ERROR, dbus_error_free(&error), "dbus_bus_add_match[%s] : %d", error.message, PRIV_GUARD_ERROR_SYSTEM_ERROR);
dbus_bool_t r = dbus_connection_add_filter(m_pDBusConnection, handleNotification, NULL, NULL);
- TryReturn(r, PRIV_FLTR_ERROR_SYSTEM_ERROR, , "dbus_connection_add_filter: %d", PRIV_FLTR_ERROR_SYSTEM_ERROR);
+ TryReturn(r, PRIV_GUARD_ERROR_SYSTEM_ERROR, , "dbus_connection_add_filter: %d", PRIV_GUARD_ERROR_SYSTEM_ERROR);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
dbus_connection_close(m_pDBusConnection);
m_pDBusConnection = NULL;
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
if (std::string(pPkgId) == m_pkgId)
{
- LOGI("Current app pkg privacy information updated");
+ PG_LOGI("Current app pkg privacy information updated");
updateCache(m_pkgId, pPrivacyId, m_privacyCache);
//printCache();
}
std::map < std::string, std::map < std::string, bool > > :: iterator iter = m_privacyInfoCache.find(std::string(pPkgId));
if (iter != m_privacyInfoCache.end())
{
- LOGI("Current pkg privacy is in cache");
+ PG_LOGI("Current pkg privacy is in cache");
updateCache(std::string(pPkgId), pPrivacyId, iter->second);
}
int
PrivacyChecker::check(const std::string privacyId, std::map < std::string, bool >& privacyMap)
{
- TryReturn(m_isInitialized, PRIV_FLTR_ERROR_NOT_INITIALIZED, , "Not initialized");
+ TryReturn(m_isInitialized, PRIV_GUARD_ERROR_NOT_INITIALIZED, , "Not initialized");
std::map < std::string, bool >::iterator iter;
iter = privacyMap.find(privacyId);
if (iter == privacyMap.end() )
{
- LOGD("The application cannot access the privacy inforamtion.");
- return PRIV_FLTR_ERROR_USER_NOT_CONSENTED;
+ PG_LOGD("The application cannot access the privacy inforamtion.");
+ return PRIV_GUARD_ERROR_USER_NOT_CONSENTED;
}
else if (!iter->second)
{
- LOGD("User does not consented to access the privacy information");
- return PRIV_FLTR_ERROR_USER_NOT_CONSENTED;
+ PG_LOGD("User does not consented to access the privacy information");
+ return PRIV_GUARD_ERROR_USER_NOT_CONSENTED;
}
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
PrivacyChecker::check(const std::string privacyId)
{
if (!m_isInitialized)
- return PRIV_FLTR_ERROR_NOT_INITIALIZED;
+ return PRIV_GUARD_ERROR_NOT_INITIALIZED;
std::lock_guard < std::mutex > guard(m_cacheMutex);
{
std::map < std::string, bool > pkgCacheMap;
res = updateCache(pkgId, pkgCacheMap);
- TryReturn( res == PRIV_FLTR_ERROR_SUCCESS, PRIV_FLTR_ERROR_DB_ERROR, , "Failed to update cache : %d", res);
+ TryReturn( res == PRIV_GUARD_ERROR_SUCCESS, PRIV_GUARD_ERROR_DB_ERROR, , "Failed to update cache : %d", res);
m_privacyInfoCache.insert( std::map < std::string, std::map < std::string, bool > >::value_type(std::string(pkgId), pkgCacheMap));
iter = m_privacyInfoCache.find(pkgId);
if (iter->second.size() == 0)
{
- return PRIV_FLTR_ERROR_USER_NOT_CONSENTED;
+ return PRIV_GUARD_ERROR_USER_NOT_CONSENTED;
}
res = check(privacyId, iter->second);
{
std::string privacyId;
int res = PrivacyIdInfo::getPrivacyIdFromPrivilege(privilege, privacyId);
- if (res == PRIV_FLTR_ERROR_NO_DATA) {
- return PRIV_FLTR_ERROR_SUCCESS;
+ if (res == PRIV_GUARD_ERROR_NO_DATA) {
+ return PRIV_GUARD_ERROR_SUCCESS;
}
- TryReturn( res == PRIV_FLTR_ERROR_SUCCESS, res, , "getPrivacyIdFromPrivilege : %d", res);
+ TryReturn( res == PRIV_GUARD_ERROR_SUCCESS, res, , "getPrivacyIdFromPrivilege : %d", res);
return check(pkgId, privacyId);
}
{
std::string privacyId;
int res = PrivacyIdInfo::getPrivacyIdFromPrivilege(privilege, privacyId);
- if (res == PRIV_FLTR_ERROR_NO_DATA) {
- return PRIV_FLTR_ERROR_SUCCESS;
+ if (res == PRIV_GUARD_ERROR_NO_DATA) {
+ return PRIV_GUARD_ERROR_SUCCESS;
}
- TryReturn( res == PRIV_FLTR_ERROR_SUCCESS, res, , "getPrivacyIdFromPrivilege : %d", res);
+ TryReturn( res == PRIV_GUARD_ERROR_SUCCESS, res, , "getPrivacyIdFromPrivilege : %d", res);
return check(privacyId);
}
m_isInitialized = false;
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
void
std::map < std::string, bool >::const_iterator iter = m_privacyCache.begin();
for (; iter != m_privacyCache.end(); ++iter)
{
- LOGD(" %s : %d", iter->first.c_str(), iter->second);
+ PG_LOGD(" %s : %d", iter->first.c_str(), iter->second);
}
}
openDb(PRIVACY_DB_PATH, pDbH, SQLITE_OPEN_READONLY);
prepareDb(pDbH, PrivacyQuery.c_str(), pPrivacyStmt);
int res = sqlite3_bind_text(pPrivacyStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);
- TryReturn( res == 0, PRIV_FLTR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
+ TryReturn( res == 0, PRIV_GUARD_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
res = sqlite3_bind_text(pPrivacyStmt.get(), 2, privacyId.c_str(), -1, SQLITE_TRANSIENT);
- TryReturn( res == 0, PRIV_FLTR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
+ TryReturn( res == 0, PRIV_GUARD_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
while ( sqlite3_step(pPrivacyStmt.get()) == SQLITE_ROW )
{
bool privacyEnabled = sqlite3_column_int(pPrivacyStmt.get(), 0) > 0 ? true : false;
- SECURE_LOGD("Set result : %s : %d", privacyId.c_str(), privacyEnabled );
+ PG_LOGD("Set result : %s : %d", privacyId.c_str(), privacyEnabled );
pkgCacheMap.erase(privacyId);
pkgCacheMap.insert(std::map < std::string, bool >::value_type(privacyId, privacyEnabled));
}
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
openDb(PRIVACY_DB_PATH, pDbH, SQLITE_OPEN_READONLY);
prepareDb(pDbH, PrivacyQuery.c_str(), pPrivacyStmt);
int res = sqlite3_bind_text(pPrivacyStmt.get(), 1, pkgId.c_str(), -1, SQLITE_TRANSIENT);
- TryReturn( res == SQLITE_OK, PRIV_FLTR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
+ TryReturn( res == SQLITE_OK, PRIV_GUARD_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
while ( (res = sqlite3_step(pPrivacyStmt.get())) == SQLITE_ROW )
{
pkgCacheMap.insert(std::map < std::string, bool >::value_type(std::string(privacyId), privacyEnabled));
- SECURE_LOGD("Privacy found : %s %d", privacyId, privacyEnabled);
+ PG_LOGD("Privacy found : %s %d", privacyId, privacyEnabled);
}
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
PrivacyGuardClient::PgAddPrivacyAccessLog(const int userId, const std::string packageId, const std::string privacyId)
{
- int result = PRIV_FLTR_ERROR_SUCCESS;
+ int result = PRIV_GUARD_ERROR_SUCCESS;
logInfoList.push_back(std::pair <std::string, std::string> (packageId, privacyId));
- PF_LOGD("PrivacyGuardClient userId : %d, PgAddPrivacyAccessLog logInfoList.size() : %d", userId, logInfoList.size());
+ PG_LOGD("PrivacyGuardClient userId : %d, PgAddPrivacyAccessLog logInfoList.size() : %d", userId, logInfoList.size());
if(logInfoList.size() >= COUNT) {
int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgAddPrivacyAccessLog", userId, logInfoList, &result);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "disconnect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "disconnect : %d", res);
logInfoList.clear();
}
int
PrivacyGuardClient::PgAddPrivacyAccessLogTest(const int userId, const std::string packageId, const std::string privacyId)
{
- int result = PRIV_FLTR_ERROR_SUCCESS;
+ int result = PRIV_GUARD_ERROR_SUCCESS;
int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgAddPrivacyAccessLogTest", userId, packageId, privacyId, &result);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "disconnect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "disconnect : %d", res);
return result;
}
int
PrivacyGuardClient::PgAddPrivacyAccessLogBeforeTerminate(void)
{
- int result = PRIV_FLTR_ERROR_SUCCESS;
- PF_LOGD("PgAddPrivacyAccessLogBeforeTerminate, logInfoList.size() : %d", logInfoList.size());
+ int result = PRIV_GUARD_ERROR_SUCCESS;
+ PG_LOGD("PgAddPrivacyAccessLogBeforeTerminate, logInfoList.size() : %d", logInfoList.size());
if(logInfoList.size() > 0) {
int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgAddPrivacyAccessLog", logInfoList, &result);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "disconnect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "disconnect : %d", res);
logInfoList.clear();
}
std::list < std::string > privacyList;
int res = PrivacyIdInfo::getPrivacyIdListFromPrivilegeList(list, privacyList);
- if (res != PRIV_FLTR_ERROR_SUCCESS )
+ if (res != PRIV_GUARD_ERROR_SUCCESS )
return res;
if (privacyList.size() == 0)
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
- int result = PRIV_FLTR_ERROR_SUCCESS;
+ int result = PRIV_GUARD_ERROR_SUCCESS;
res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgAddMonitorPolicy", userId, pkgId, privacyList, monitorPolicy, &result);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "disconnect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "disconnect : %d", res);
return result;
}
int
PrivacyGuardClient::PgDeleteAllLogsAndMonitorPolicy(void)
{
- int result = PRIV_FLTR_ERROR_SUCCESS;
+ int result = PRIV_GUARD_ERROR_SUCCESS;
int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgDeleteAllLogsAndMonitorPolicy", &result);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "disconnect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "disconnect : %d", res);
return result;
}
int
PrivacyGuardClient::PgDeleteLogsByPackageId(const std::string packageId)
{
- int result = PRIV_FLTR_ERROR_SUCCESS;
+ int result = PRIV_GUARD_ERROR_SUCCESS;
int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgDeleteLogsByPackageId", packageId, &result);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "disconnect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "disconnect : %d", res);
return result;
}
int
PrivacyGuardClient::PgDeleteMonitorPolicyByPackageId(const std::string packageId)
{
- int result = PRIV_FLTR_ERROR_SUCCESS;
+ int result = PRIV_GUARD_ERROR_SUCCESS;
int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgDeleteMonitorPolicyByPackageId", packageId, &result);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "disconnect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "disconnect : %d", res);
return result;
}
int
PrivacyGuardClient::PgForeachTotalPrivacyCountOfPackage(const int userId, const int startDate, const int endDate, std::list < std::pair <std::string, int > > & packageInfoList) const
{
- int result = PRIV_FLTR_ERROR_SUCCESS;
+ int result = PRIV_GUARD_ERROR_SUCCESS;
int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgForeachTotalPrivacyCountOfPackage", userId, startDate, endDate, &result, &packageInfoList);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "disconnect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "disconnect : %d", res);
return result;
}
int
PrivacyGuardClient::PgForeachTotalPrivacyCountOfPrivacy(const int userId, const int startDate, const int endDate, std::list < std::pair <std::string, int > > & privacyInfoList) const
{
- int result = PRIV_FLTR_ERROR_SUCCESS;
+ int result = PRIV_GUARD_ERROR_SUCCESS;
int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgForeachTotalPrivacyCountOfPrivacy", userId, startDate, endDate, &result, &privacyInfoList);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "disconnect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "disconnect : %d", res);
return result;
}
int
PrivacyGuardClient::PgForeachPrivacyCountByPrivacyId(const int userId, const int startDate, const int endDate, const std::string privacyId, std::list < std::pair <std::string, int > > & packageInfoList) const
{
- int result = PRIV_FLTR_ERROR_SUCCESS;
+ int result = PRIV_GUARD_ERROR_SUCCESS;
bool isValid = PrivacyIdInfo::isValidPrivacyId(privacyId);
if (!isValid)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgForeachPrivacyCountByPrivacyId", userId, startDate, endDate, privacyId, &result, &packageInfoList);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "disconnect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "disconnect : %d", res);
return result;
}
int
PrivacyGuardClient::PgForeachPrivacyCountByPackageId(const int userId, const int startDate, const int endDate, const std::string packageId, std::list < std::pair <std::string, int > > & privacyInfoList) const
{
- int result = PRIV_FLTR_ERROR_SUCCESS;
+ int result = PRIV_GUARD_ERROR_SUCCESS;
int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgForeachPrivacyCountByPackageId", userId, startDate, endDate, packageId, &result, &privacyInfoList);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "disconnect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "disconnect : %d", res);
return result;
}
int
PrivacyGuardClient::PgForeachPrivacyPackageId(const int userId, std::list < std::string > & packageList) const
{
- int result = PRIV_FLTR_ERROR_SUCCESS;
+ int result = PRIV_GUARD_ERROR_SUCCESS;
int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgForeachPrivacyPackageId", userId, &result, &packageList);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
return result;
}
int
PrivacyGuardClient::PgForeachPackageByPrivacyId(const int userId, const std::string privacyId, std::list < std::string > & packageList) const
{
- int result = PRIV_FLTR_ERROR_SUCCESS;
+ int result = PRIV_GUARD_ERROR_SUCCESS;
bool isValid = PrivacyIdInfo::isValidPrivacyId(privacyId);
if (!isValid)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgForeachPackageByPrivacyId", userId, privacyId, &result, &packageList);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
return result;
}
PrivacyGuardClient::PgForeachMonitorPolicyByPackageId(const int userId, const std::string packageId,
std::list <privacy_data_s> & privacyInfoList) const
{
- int result = PRIV_FLTR_ERROR_SUCCESS;
+ int result = PRIV_GUARD_ERROR_SUCCESS;
int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgForeachMonitorPolicyByPackageId", userId, packageId, &result, &privacyInfoList);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "disconnect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "disconnect : %d", res);
return result;
}
PrivacyGuardClient::PgGetMonitorPolicy(const int userId, const std::string packageId,
const std::string privacyId, int &monitorPolicy) const
{
- int result = PRIV_FLTR_ERROR_SUCCESS;
+ int result = PRIV_GUARD_ERROR_SUCCESS;
bool isValid = PrivacyIdInfo::isValidPrivacyId(privacyId);
if (!isValid)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgGetMonitorPolicy", userId, packageId, privacyId, &result, &monitorPolicy);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
return result;
}
int
PrivacyGuardClient::PgGetAllMonitorPolicy(std::list < std::pair < std::string, int > > & monitorPolicyList) const
{
- int result = PRIV_FLTR_ERROR_SUCCESS;
+ int result = PRIV_GUARD_ERROR_SUCCESS;
int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgGetAllMonitorPolicy", &result, &monitorPolicyList);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
return result;
}
int
PrivacyGuardClient::PgCheckPrivacyPackage(const int userId, const std::string packageId, bool &isPrivacyPackage)
{
- int result = PRIV_FLTR_ERROR_SUCCESS;
+ int result = PRIV_GUARD_ERROR_SUCCESS;
int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgCheckPrivacyPackage", userId, packageId, &result, &isPrivacyPackage);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
return result;
}
PrivacyGuardClient::PgUpdateMonitorPolicy(const int userId, const std::string packageId,
const std::string privacyId, const int monitorPolicy)
{
- int result = PRIV_FLTR_ERROR_SUCCESS;
+ int result = PRIV_GUARD_ERROR_SUCCESS;
bool isValid = PrivacyIdInfo::isValidPrivacyId(privacyId);
if (!isValid)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgUpdateMonitorPolicy", userId, packageId, privacyId, monitorPolicy, &result);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
return result;
}
int
PrivacyGuardClient::PgGetMainMonitorPolicy(const int userId, bool &mainMonitorPolicy) const
{
- int result = PRIV_FLTR_ERROR_SUCCESS;
+ int result = PRIV_GUARD_ERROR_SUCCESS;
int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgGetMainMonitorPolicy", userId, &result, &mainMonitorPolicy);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
return result;
}
int
PrivacyGuardClient::PgUpdateMainMonitorPolicy(const int userId, const bool mainMonitorPolicy)
{
- int result = PRIV_FLTR_ERROR_SUCCESS;
+ int result = PRIV_GUARD_ERROR_SUCCESS;
int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgUpdateMainMonitorPolicy", userId, mainMonitorPolicy, &result);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
return result;
}
int
PrivacyGuardClient::PgDeleteMainMonitorPolicyByUserId(const int userId)
{
- int result = PRIV_FLTR_ERROR_SUCCESS;
+ int result = PRIV_GUARD_ERROR_SUCCESS;
int res = m_pSocketClient->connect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "connect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
res = m_pSocketClient->call("PgDeleteMainMonitorPolicyByUserId", userId, &result);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "disconnect : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "disconnect : %d", res);
return result;
}
#include "Utils.h"
#define throwWithErrnoMessage(specificInfo) do {\
- LOGE("%s : %s", specificInfo, strerror(errno)); \
+ PG_LOGE("%s : %s", specificInfo, strerror(errno)); \
return -1; \
} while(0)
{
m_interfaceName = interfaceName;
m_serverAddress = SERVER_ADDRESS;
- PF_LOGI("Client created m_interfaceName : %s, m_serverAddress : %s", m_interfaceName.c_str(), m_serverAddress.c_str());
+ PG_LOGI("Client created m_interfaceName : %s, m_serverAddress : %s", m_interfaceName.c_str(), m_serverAddress.c_str());
}
int SocketClient::connect()
{
struct sockaddr_un remote;
m_socketFd = socket(AF_UNIX, SOCK_STREAM,0);
- TryReturn( m_socketFd != -1, PRIV_FLTR_ERROR_IPC_ERROR, , "socket : %s", strerror(errno));
+ TryReturn( m_socketFd != -1, PRIV_GUARD_ERROR_IPC_ERROR, , "socket : %s", strerror(errno));
int res;
//socket needs to be nonblocking, because read can block after select
if ( (flags = fcntl(m_socketFd, F_GETFL, 0)) == -1 )
flags = 0;
res = fcntl(m_socketFd, F_SETFL, flags | O_NONBLOCK);
- TryReturn( m_socketFd != -1, PRIV_FLTR_ERROR_IPC_ERROR, , "fcntl : %s", strerror(errno));
+ TryReturn( m_socketFd != -1, PRIV_GUARD_ERROR_IPC_ERROR, , "fcntl : %s", strerror(errno));
bzero(&remote, sizeof(remote));
remote.sun_family = AF_UNIX;
strcpy(remote.sun_path, m_serverAddress.c_str());
res = ::connect(m_socketFd, (struct sockaddr *)&remote, SUN_LEN(&remote));
- TryReturn( res != -1, PRIV_FLTR_ERROR_IPC_ERROR, , "connect : %s", strerror(errno));
+ TryReturn( res != -1, PRIV_GUARD_ERROR_IPC_ERROR, , "connect : %s", strerror(errno));
m_socketConnector.reset(new SocketConnection(m_socketFd));
-
- LOGI("Client connected");
- return PRIV_FLTR_ERROR_SUCCESS;
+ PG_LOGI("Client connected");
+
+ return PRIV_GUARD_ERROR_SUCCESS;
}
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);
- LOGI("Client disconnected");
+ PG_LOGI("Client disconnected");
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
* 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.
+ * limitations under the License.
*/
#include <string.h>
#include <string>
#include <memory>
-#include <dlog.h>
#include "PrivacyChecker.h"
#include "PrivacyGuardClient.h"
#include "privacy_guard_client.h"
int privacy_guard_client_add_privacy_access_log(const int user_id, const char *package_id, const char *privilege_id)
{
if (user_id < 0 || package_id == NULL || privilege_id == NULL)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
int monitor_policy = 0;
std::string privacy_id;
- PF_LOGD("user_id : %d, package_id : %s, privilege_id : %s", user_id, package_id, privilege_id);
+ PG_LOGD("user_id : %d, package_id : %s, privilege_id : %s", user_id, package_id, privilege_id);
int retval = PrivacyChecker::checkMonitorPolicyWithPrivilege(user_id, std::string(package_id), std::string(privilege_id), privacy_id, monitor_policy);
- PF_LOGD("monitor policy : %d", monitor_policy);
+ PG_LOGD("monitor policy : %d", monitor_policy);
- if (retval == PRIV_FLTR_ERROR_SUCCESS && monitor_policy == MONITOR_POLICY_ON) {
+ if (retval == PRIV_GUARD_ERROR_SUCCESS && monitor_policy == MONITOR_POLICY_ON) {
PrivacyGuardClient *pInst = PrivacyGuardClient::getInstance();
retval = pInst->PgAddPrivacyAccessLog(user_id, std::string(package_id), std::string(privacy_id));
}
- PF_LOGD("retval : %d", retval);
+ PG_LOGD("retval : %d", retval);
return retval;
}
int privacy_guard_client_delete_logs_by_package_id(const char *package_id)
{
if (package_id == NULL)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
PrivacyGuardClient *pInst = PrivacyGuardClient::getInstance();
int privacy_guard_client_delete_monitor_policy_by_package_id(const char *package_id)
{
if (package_id == NULL)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
PrivacyGuardClient *pInst = PrivacyGuardClient::getInstance();
const time_t end_date, privacy_guard_client_privacy_count_of_package_cb callback, void *user_data)
{
if (user_id < 0 || start_date > end_date || start_date <= 0)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
PrivacyGuardClient *pInst = PrivacyGuardClient::getInstance();
std::list <std::pair<std::string, int>> list;
- PF_LOGD("start_date : %d, end_date : %d", start_date, end_date);
+ PG_LOGD("start_date : %d, end_date : %d", start_date, end_date);
int retval = pInst->PgForeachTotalPrivacyCountOfPackage(user_id, start_date, end_date, list);
- if (retval != PRIV_FLTR_ERROR_SUCCESS)
+ if (retval != PRIV_GUARD_ERROR_SUCCESS)
return retval;
if (list.size() == 0)
- return PRIV_FLTR_ERROR_NO_DATA;
+ return PRIV_GUARD_ERROR_NO_DATA;
for (std::list <std::pair <std::string, int>>::iterator iter = list.begin(); iter != list.end(); ++iter) {
- PF_LOGD("result > package_id : %s, count : %d", iter->first.c_str(), iter->second);
+ PG_LOGD("result > package_id : %s, count : %d", iter->first.c_str(), iter->second);
bool ret = callback(iter->first.c_str(), iter->second, user_data);
if (ret == false)
break;
const time_t end_date, privacy_guard_client_privacy_count_cb callback, void *user_data)
{
if (user_id < 0 || start_date > end_date || start_date <= 0)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
PrivacyGuardClient *pInst = PrivacyGuardClient::getInstance();
std::list <std::pair<std::string, int>> list;
- PF_LOGD("start_date : %d, end_date : %d", start_date, end_date);
+ PG_LOGD("start_date : %d, end_date : %d", start_date, end_date);
int retval = pInst->PgForeachTotalPrivacyCountOfPrivacy(user_id, start_date, end_date, list);
- if (retval != PRIV_FLTR_ERROR_SUCCESS)
+ if (retval != PRIV_GUARD_ERROR_SUCCESS)
return retval;
if (list.size() == 0)
- return PRIV_FLTR_ERROR_NO_DATA;
+ return PRIV_GUARD_ERROR_NO_DATA;
for (std::list <std::pair <std::string, int>>::iterator iter = list.begin(); iter != list.end(); ++iter) {
- PF_LOGD("result > privacy_id : %s, count : %d", iter->first.c_str(), iter->second);
+ PG_LOGD("result > privacy_id : %s, count : %d", iter->first.c_str(), iter->second);
bool ret = callback(iter->first.c_str(), iter->second, user_data);
if (ret == false)
break;
privacy_guard_client_privacy_count_of_package_cb callback, void *user_data)
{
if (user_id < 0 || start_date > end_date || start_date <= 0 || privacy_id == NULL)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
PrivacyGuardClient *pInst = PrivacyGuardClient::getInstance();
std::list <std::pair<std::string, int>> list;
- PF_LOGD("start_date : %d, end_date : %d", start_date, end_date);
+ PG_LOGD("start_date : %d, end_date : %d", start_date, end_date);
int retval = pInst->PgForeachPrivacyCountByPrivacyId(user_id, start_date, end_date, std::string(privacy_id), list);
- if (retval != PRIV_FLTR_ERROR_SUCCESS)
+ if (retval != PRIV_GUARD_ERROR_SUCCESS)
return retval;
if (list.size() == 0)
- return PRIV_FLTR_ERROR_NO_DATA;
+ return PRIV_GUARD_ERROR_NO_DATA;
for (std::list <std::pair <std::string, int>>::iterator iter = list.begin(); iter != list.end(); ++iter) {
- PF_LOGD("result > package_id : %s, count : %d", iter->first.c_str(), iter->second);
+ PG_LOGD("result > package_id : %s, count : %d", iter->first.c_str(), iter->second);
bool ret = callback(iter->first.c_str(), iter->second, user_data);
if (ret == false)
break;
privacy_guard_client_privacy_count_cb callback, void *user_data)
{
if (user_id < 0 || start_date > end_date || start_date <= 0 || package_id == NULL)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
PrivacyGuardClient *pInst = PrivacyGuardClient::getInstance();
std::list <std::pair<std::string, int>> list;
- PF_LOGD("start_date : %d, end_date : %d", start_date, end_date);
+ PG_LOGD("start_date : %d, end_date : %d", start_date, end_date);
int retval = pInst->PgForeachPrivacyCountByPackageId(user_id, start_date, end_date, std::string(package_id), list);
- if (retval != PRIV_FLTR_ERROR_SUCCESS)
+ if (retval != PRIV_GUARD_ERROR_SUCCESS)
return retval;
if (list.size() == 0)
- return PRIV_FLTR_ERROR_NO_DATA;
+ return PRIV_GUARD_ERROR_NO_DATA;
for (std::list <std::pair <std::string, int>>::iterator iter = list.begin(); iter != list.end(); ++iter) {
- PF_LOGD("result > privacy_id : %s, count : %d", iter->first.c_str(), iter->second);
+ PG_LOGD("result > privacy_id : %s, count : %d", iter->first.c_str(), iter->second);
bool ret = callback(iter->first.c_str(), iter->second, user_data);
if (ret == false)
break;
int privacy_guard_client_add_monitor_policy(const int user_id, const char *package_id, const char **privilege_list, const int monitor_policy)
{
if (user_id < 0 || package_id == NULL)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
PrivacyGuardClient *pInst = PrivacyGuardClient::getInstance();
std::list < std::string > privilegeList;
while (*privilege_list[0] != '\0')
{
- PF_LOGD("privacyList : %s", *privilege_list);
+ PG_LOGD("privacyList : %s", *privilege_list);
privilegeList.push_back(std::string(*privilege_list++));
}
int privacy_guard_client_update_monitor_policy(const int user_id, const char *package_id, const char *privacy_id, const int monitor_policy)
{
if (user_id < 0 || package_id == NULL || privacy_id == NULL)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
PrivacyGuardClient *pInst = PrivacyGuardClient::getInstance();
privacy_guard_client_monitor_policy_cb callback, void *user_data)
{
if (user_id < 0 || package_id == NULL)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
- PF_LOGD("package_id : %s", package_id);
+ PG_LOGD("package_id : %s", package_id);
std::list <privacy_data_s> privacyInfoList;
int retval = -1;
retval = PrivacyGuardClient::getInstance()->PgForeachMonitorPolicyByPackageId(user_id, std::string(package_id), privacyInfoList);
- if (retval != PRIV_FLTR_ERROR_SUCCESS) {
- PF_LOGE("PgForeachMonitorPolicyByPackageId : fail");
+ if (retval != PRIV_GUARD_ERROR_SUCCESS) {
+ PG_LOGE("PgForeachMonitorPolicyByPackageId : fail");
return retval;
}
if (privacyInfoList.size() == 0) {
- PF_LOGE("PgForeachMonitorPolicyByPackageId (privacyList.size = 0): fail");
- return PRIV_FLTR_ERROR_NO_DATA;
+ PG_LOGE("PgForeachMonitorPolicyByPackageId (privacyList.size = 0): fail");
+ return PRIV_GUARD_ERROR_NO_DATA;
}
for (std::list <privacy_data_s>::iterator iter = privacyInfoList.begin(); iter != privacyInfoList.end(); ++iter) {
- PF_LOGD("result > privacy_id : %s, monitor_policy : %d",
+ PG_LOGD("result > privacy_id : %s, monitor_policy : %d",
iter->privacy_id, iter->monitor_policy);
bool ret = callback(iter->privacy_id, iter->monitor_policy, user_data);
if (ret == false)
int privacy_guard_client_check_privacy_package(const int user_id, const char *package_id, bool *is_privacy_package)
{
if (user_id < 0 || package_id == NULL)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
PrivacyGuardClient* pInst = PrivacyGuardClient::getInstance();
- PF_LOGD("user_id : %d, package_id : %s", user_id, package_id);
+ PG_LOGD("user_id : %d, package_id : %s", user_id, package_id);
int retval = pInst->PgCheckPrivacyPackage(user_id, std::string(package_id), *is_privacy_package);
- PF_LOGD("result > is_privacy_package : %d", *is_privacy_package);
+ PG_LOGD("result > is_privacy_package : %d", *is_privacy_package);
return retval;
}
int privacy_guard_client_foreach_privacy_package_id(const int user_id, privacy_guard_client_package_id_cb callback, void *user_data)
{
if (user_id < 0)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
PrivacyGuardClient* pInst = PrivacyGuardClient::getInstance();
std::list < std::string > packageList;
int retval = pInst->PgForeachPrivacyPackageId(user_id, packageList);
- if (retval != PRIV_FLTR_ERROR_SUCCESS) {
- PF_LOGE("PgForeachPrivacyPackageId : fail");
+ if (retval != PRIV_GUARD_ERROR_SUCCESS) {
+ PG_LOGE("PgForeachPrivacyPackageId : fail");
return retval;
}
if (packageList.size() == 0) {
- PF_LOGE("PgForeachPrivacyPackageId (packageList.size = 0): fail");
- return PRIV_FLTR_ERROR_NO_DATA;
+ PG_LOGE("PgForeachPrivacyPackageId (packageList.size = 0): fail");
+ return PRIV_GUARD_ERROR_NO_DATA;
}
for (std::list < std::string >::iterator iter = packageList.begin(); iter != packageList.end(); ++iter) {
- PF_LOGD("package_id : %s", iter->c_str());
+ PG_LOGD("package_id : %s", iter->c_str());
bool ret = callback(iter->c_str(), user_data);
if (ret == false)
break;
int privacy_guard_client_foreach_package_by_privacy_id(const int user_id, const char *privacy_id, privacy_guard_client_package_id_cb callback, void *user_data)
{
if (user_id < 0 || privacy_id == NULL)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
PrivacyGuardClient* pInst = PrivacyGuardClient::getInstance();
std::list < std::string > packageList;
int retval = pInst->PgForeachPackageByPrivacyId(user_id, std::string(privacy_id), packageList);
- if (retval != PRIV_FLTR_ERROR_SUCCESS) {
- PF_LOGE("PgForeachPackageByPrivacyId : fail");
+ if (retval != PRIV_GUARD_ERROR_SUCCESS) {
+ PG_LOGE("PgForeachPackageByPrivacyId : fail");
return retval;
}
if (packageList.size() == 0) {
- PF_LOGE("PgForeachPackageByPrivacyId (packageList.size = 0): fail");
- return PRIV_FLTR_ERROR_NO_DATA;
+ PG_LOGE("PgForeachPackageByPrivacyId (packageList.size = 0): fail");
+ return PRIV_GUARD_ERROR_NO_DATA;
}
for (std::list < std::string >::iterator iter = packageList.begin(); iter != packageList.end(); ++iter) {
- PF_LOGD("package_id : %s", iter->c_str());
+ PG_LOGD("package_id : %s", iter->c_str());
bool ret = callback(iter->c_str(), user_data);
if (ret == false)
break;
int privacy_guard_client_update_main_monitor_policy(const int user_id, const bool main_monitor_policy)
{
if (user_id < 0)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
PrivacyGuardClient *pInst = PrivacyGuardClient::getInstance();
int privacy_guard_client_get_main_monitor_policy(const int user_id, bool *main_monitor_policy)
{
if (user_id < 0)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
PrivacyGuardClient* pInst = PrivacyGuardClient::getInstance();
- PF_LOGD("user_id : %d", user_id);
+ PG_LOGD("user_id : %d", user_id);
int retval = pInst->PgGetMainMonitorPolicy(user_id, *main_monitor_policy);
- PF_LOGD("result > main_monitor_policy : %d", *main_monitor_policy);
+ PG_LOGD("result > main_monitor_policy : %d", *main_monitor_policy);
return retval;
}
int privacy_guard_client_delete_main_monitor_policy_by_user_id(const int user_id)
{
if (user_id < 0)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
PrivacyGuardClient *pInst = PrivacyGuardClient::getInstance();
int removeAppPackagePrivacyInfo(const std::string pkgId);
int setPrivacySetting(const std::string pkgId, const std::string privacyId, bool isEnabled);
-
+
int getPrivacyAppPackages(std::list < std::string >& pList);
- 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
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
#ifndef _PRIVACY_GUARD_COMMON_H_
#define _PRIVACY_GUARD_COMMON_H_
#ifndef _SOCKETCONNECTION_H_
#define _SOCKETCONNECTION_H_
-#include <dlog.h>
#include <new>
#include <list>
#include <utility>
public:
explicit SocketConnection(int socket_fd) : m_socketStream(socket_fd){
- LOGI("Created");
+ PG_LOGI("Created");
}
template<typename T, typename ...Args>
int read(T* out, const Args&... args )
{
int res = read(out);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "read : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "read : %d", res);
res = read(args...);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "read : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "read : %d", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
template<typename T>
{
int length = 0;
int res = m_socketStream.readStream(sizeof(length), &length);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "readStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "readStream : %d", res);
char* pBuf = new (std::nothrow) char[length + 1];
- TryReturn(pBuf != NULL, PRIV_FLTR_ERROR_OUT_OF_MEMORY, , "new : %d", PRIV_FLTR_ERROR_OUT_OF_MEMORY);
+ TryReturn(pBuf != NULL, PRIV_GUARD_ERROR_OUT_OF_MEMORY, , "new : %d", PRIV_GUARD_ERROR_OUT_OF_MEMORY);
res = m_socketStream.readStream(length, pBuf);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, delete[] pBuf, "readStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, delete[] pBuf, "readStream : %d", res);
pBuf[length] = 0;
delete[] pBuf;
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
-
+
int read(bool* pB)
{
int length = 0;
int res = m_socketStream.readStream(sizeof(length), &length);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "readStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "readStream : %d", res);
char* pBuf = new (std::nothrow) char[length + 1];
- TryReturn(pBuf != NULL, PRIV_FLTR_ERROR_OUT_OF_MEMORY, , "new : %d", PRIV_FLTR_ERROR_OUT_OF_MEMORY);
+ TryReturn(pBuf != NULL, PRIV_GUARD_ERROR_OUT_OF_MEMORY, , "new : %d", PRIV_GUARD_ERROR_OUT_OF_MEMORY);
res = m_socketStream.readStream(length, pBuf);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, delete[] pBuf, "readStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, delete[] pBuf, "readStream : %d", res);
pBuf[length] = 0;
delete[] pBuf;
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int read(bool& b)
{
return read(&b);
}
-
+
int read(int& i)
{
return read(&i);
{
int length = 0;
int res = m_socketStream.readStream(sizeof(length), &length);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "readStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "readStream : %d", res);
char* pBuf = new (std::nothrow) char[length + 1];
- TryReturn(pBuf != NULL, PRIV_FLTR_ERROR_OUT_OF_MEMORY, , "new : %d", PRIV_FLTR_ERROR_OUT_OF_MEMORY);
+ TryReturn(pBuf != NULL, PRIV_GUARD_ERROR_OUT_OF_MEMORY, , "new : %d", PRIV_GUARD_ERROR_OUT_OF_MEMORY);
res = m_socketStream.readStream(length, pBuf);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, delete[] pBuf, "readStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, delete[] pBuf, "readStream : %d", res);
pBuf[length] = 0;
delete[] pBuf;
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int read(unsigned int* pUi)
{
int length = 0;
int res = m_socketStream.readStream(sizeof(length), &length);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "readStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "readStream : %d", res);
char* pBuf = new (std::nothrow) char[length + 1];
- TryReturn(pBuf != NULL, PRIV_FLTR_ERROR_OUT_OF_MEMORY, , "new : %d", PRIV_FLTR_ERROR_OUT_OF_MEMORY);
+ TryReturn(pBuf != NULL, PRIV_GUARD_ERROR_OUT_OF_MEMORY, , "new : %d", PRIV_GUARD_ERROR_OUT_OF_MEMORY);
res = m_socketStream.readStream(length, pBuf);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, delete[] pBuf, "readStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, delete[] pBuf, "readStream : %d", res);
pBuf[length] = 0;
delete[] pBuf;
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int read(std::string* pStr)
{
int length = 0;
int res = m_socketStream.readStream(sizeof(length), &length);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "readStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "readStream : %d", res);
char* pBuf = new (std::nothrow) char[length + 1];
- TryReturn(pBuf != NULL, PRIV_FLTR_ERROR_OUT_OF_MEMORY, , "new : %d", PRIV_FLTR_ERROR_OUT_OF_MEMORY);
+ TryReturn(pBuf != NULL, PRIV_GUARD_ERROR_OUT_OF_MEMORY, , "new : %d", PRIV_GUARD_ERROR_OUT_OF_MEMORY);
m_socketStream.readStream(length, pBuf);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, delete[] pBuf, "readStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, delete[] pBuf, "readStream : %d", res);
pBuf[length] = 0;
*pStr = std::string(pBuf);
delete[] pBuf;
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
-
+
int read(std::string& str)
{
return read(&str);
char* pBuf;
// privacy id
res = m_socketStream.readStream(sizeof(length), &length);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "readStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "readStream : %d", res);
pBuf = new (std::nothrow) char[length + 1];
- TryReturn(pBuf != NULL, PRIV_FLTR_ERROR_OUT_OF_MEMORY, , "new : %d", PRIV_FLTR_ERROR_OUT_OF_MEMORY);
+ TryReturn(pBuf != NULL, PRIV_GUARD_ERROR_OUT_OF_MEMORY, , "new : %d", PRIV_GUARD_ERROR_OUT_OF_MEMORY);
m_socketStream.readStream(length, pBuf);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, delete[] pBuf, "readStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, delete[] pBuf, "readStream : %d", res);
pBuf[length] = 0;
out.privacy_id = strdup(pBuf);
delete[] pBuf;
// monitor policy
res = read(&(out.monitor_policy));
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "readStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "readStream : %d", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
template < typename T >
int read (std::list<T>& list)
{
int length = 0;
int res = read(length);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "read : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "read : %d", res);
- for (int i = 0; i < length; ++i)
+ for (int i = 0; i < length; ++i)
{
T obj;
res = read (obj);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "read : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "read : %d", res);
list.push_back(obj);
}
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
template < typename T >
int read (std::pair<K, P>& pair)
{
int res = read( pair.first);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "read : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "read : %d", res);
res = read( pair.second);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "read : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "read : %d", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
template < typename K, typename P >
int write(const T& in, const Args&... args)
{
int res = write(in);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "write : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "write : %d", res);
res = write(args...);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "write : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "write : %d", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int write(const std::string& in)
{
int length = in.size();
int res = m_socketStream.writeStream(sizeof(length), &length);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "writeStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "writeStream : %d", res);
res = m_socketStream.writeStream(length, in.c_str());
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "writeStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "writeStream : %d", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
-
+
int write(const unsigned int& in)
{
int length = sizeof(in);
int res = m_socketStream.writeStream(sizeof(length), &length);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "writeStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "writeStream : %d", res);
res = m_socketStream.writeStream(length, &in);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "writeStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "writeStream : %d", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int write(const int& in)
{
int length = sizeof(in);
int res = m_socketStream.writeStream(sizeof(length), &length);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "writeStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "writeStream : %d", res);
res = m_socketStream.writeStream(length, &in);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "writeStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "writeStream : %d", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int write(const bool& in)
{
int length = sizeof(in);
int res = m_socketStream.writeStream(sizeof(length), &length);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "writeStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "writeStream : %d", res);
res = m_socketStream.writeStream(length, &in);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "writeStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "writeStream : %d", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int write(const char*& in)
{
int length = strlen(in);
int res = m_socketStream.writeStream(sizeof(length), &length);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "writeStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "writeStream : %d", res);
res = m_socketStream.writeStream(length, in);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "writeStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "writeStream : %d", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int write(const char* in_str, const int in_int1, const int in_int2)
{
int res = 0;
res = write(in_str);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "write : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "write : %d", res);
res = write(in_int1);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "write : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "write : %d", res);
res = write(in_int2);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "write : %d", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "write : %d", res);
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int write(const privacy_data_s& in)
int length = strlen(in.privacy_id);
int res = 0;
res = m_socketStream.writeStream(sizeof(length), &length);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "writeStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "writeStream : %d", res);
res = m_socketStream.writeStream(length, in.privacy_id);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "writeStream : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "writeStream : %d", res);
// monitor policy
res = write(in.monitor_policy);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "write : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "write : %d", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
template<typename T, typename ...Args>
int write(const T* in, const Args&... args)
{
int res = write(in);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "write : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "write : %d", res);
res = write(args...);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "write : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "write : %d", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
template<typename K, typename T>
int write(const std::pair<K, T> p)
{
int res = write(p.first);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "write : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "write : %d", res);
res = write(p.second);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "write : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "write : %d", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
template<typename K, typename T>
int write(const std::pair<K, T&> p)
{
int res = write(p.first);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "write : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "write : %d", res);
res = write(p.second);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "write : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "write : %d", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
template<typename K, typename T>
{
int length = list.size();
int res = write(length);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "write : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "write : %d", res);
for (typename std::list <T>::const_iterator iter = list.begin(); iter != list.end(); iter++) {
res = write(*iter);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "write : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "write : %d", res);
}
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
template<typename T>
, m_bytesRead(0)
,m_bytesWrote(0)
{
- LOGI("Created");
+ PG_LOGI("Created");
}
int readStream(size_t num, void * bytes);
#if defined(_PRIVACY_GUARD_DEBUG) || defined(_PRIVACY_GUARD_DEBUG_INFO) || defined(_PRIVACY_GUARD_DEBUG_ERROR)
#ifdef _PRIVACY_GUARD_DEBUG
-#define PF_LOGD(fmt, arg...) LOGD(fmt, ##arg)
-#define PF_LOGI(fmt, arg...) LOGI(fmt, ##arg)
-#define PF_LOGE(fmt, arg...) LOGE(fmt, ##arg)
+#define PG_LOGD(fmt, arg...) LOGD(fmt, ##arg)
+#define PG_LOGI(fmt, arg...) LOGI(fmt, ##arg)
+#define PG_LOGE(fmt, arg...) LOGE(fmt, ##arg)
// _PRIVACY_GUARD_DEBUG_INFO
#elif _PRIVACY_GUARD_DEBUG_INFO
-#define PF_LOGD(fmt, arg...)
-#define PF_LOGI(fmt, arg...) LOGI(fmt, ##arg)
-#define PF_LOGE(fmt, arg...) LOGE(fmt, ##arg)
+#define PG_LOGD(fmt, arg...)
+#define PG_LOGI(fmt, arg...) LOGI(fmt, ##arg)
+#define PG_LOGE(fmt, arg...) LOGE(fmt, ##arg)
// _PRIVACY_GUARD_DEBUG_ERROR
#elif _PRIVACY_GUARD_DEBUG_ERROR
-#define PF_LOGD(fmt, arg...)
-#define PF_LOGI(fmt, arg...)
-#define PF_LOGE(fmt, arg...) LOGE(fmt, ##arg)
+#define PG_LOGD(fmt, arg...)
+#define PG_LOGI(fmt, arg...)
+#define PG_LOGE(fmt, arg...) LOGE(fmt, ##arg)
#endif
#else
-#define PF_LOGD(fmt, arg...)
-#define PF_LOGI(fmt, arg...)
-#define PF_LOGE(fmt, arg...)
+#define PG_LOGD(fmt, arg...)
+#define PG_LOGI(fmt, arg...)
+#define PG_LOGE(fmt, arg...)
#endif
//////////////////////////////////////////////////////////////////////////
#define IF_MATCH_RET_ERROR(condition, msgFormat, error) \
if (condition) { \
- PF_LOGE(msgFormat, error); \
+ PG_LOGE(msgFormat, error); \
return error; \
} else {;}
#define TryCatchLogReturn(condition, expr, r, logFormat) if (!(condition)) { \
{\
/*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_FLTR_ERROR_DB_ERROR, "db_util_open_with_options : %d", res);\
+ TryCatchResLogReturn(res == SQLITE_OK, , PRIV_GUARD_ERROR_DB_ERROR, "db_util_open_with_options : %d", res);\
}\
setDbToUniquePtr(pHandler, pHandler##Temp);\
usleep(SLEEP_TIME);\
}\
}\
- TryCatchResLogReturn(res == SQLITE_OK, , PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);\
+ TryCatchResLogReturn(res == SQLITE_OK, , PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);\
}\
setStmtToUniquePtr(pStmt, pStmt##Temp);
* limitations under the License.
*/
-#include <dlog.h>
#include <set>
#include <libintl.h>
#include <system_info.h>
prepareDb(pDbHandler, sqlPrivacyInfo.c_str(), pStmtPrivacyInfo);
res = sqlite3_bind_text(pStmtPrivacyInfo.get(), 1, privacyId, -1, SQLITE_TRANSIENT);
- TryReturn(res == SQLITE_OK, PRIV_FLTR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
+ TryReturn(res == SQLITE_OK, PRIV_GUARD_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
res = sqlite3_step(pStmtPrivacyInfo.get());
- LOGD("privacy id : %s", privacyId);
- TryReturn(res == SQLITE_DONE || res == SQLITE_ROW, PRIV_FLTR_ERROR_DB_ERROR, , "sqlite3_step : %d", res);
+ PG_LOGD("privacy id : %s", privacyId);
+ TryReturn(res == SQLITE_DONE || res == SQLITE_ROW, PRIV_GUARD_ERROR_DB_ERROR, , "sqlite3_step : %d", res);
const char* feature = reinterpret_cast < const char* > (sqlite3_column_text(pStmtPrivacyInfo.get(), 0));
if (feature != NULL)
bool isSupported = false;
res = isFeatureEnabled(feature, isSupported);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "isFeatureEnabled : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "isFeatureEnabled : %d", res);
if (!isSupported)
{
m_isInitialized = true;
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
std::map< std::string, std::string >::iterator iter = m_privilegeToPrivacyMap.find(privilege);
if (iter == m_privilegeToPrivacyMap.end())
{
- return PRIV_FLTR_ERROR_NO_DATA;
+ return PRIV_GUARD_ERROR_NO_DATA;
}
privacyId = iter->second;
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
if (privilegeList.size() == 0)
{
- LOGE("PrivilegeList of %s privacy is empty!", privacyId.c_str());
- return PRIV_FLTR_ERROR_NO_DATA;
+ PG_LOGE("PrivilegeList of %s privacy is empty!", privacyId.c_str());
+ return PRIV_GUARD_ERROR_NO_DATA;
}
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
{
std::string privacyId;
int res = getPrivacyIdFromPrivilege(*iter, privacyId);
- if (res == PRIV_FLTR_ERROR_SUCCESS)
+ if (res == PRIV_GUARD_ERROR_SUCCESS)
{
privacyIdSet.insert(privacyId);
}
privacyIdList.push_back(*iter);
}
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
bool
{
const char* privacyId = reinterpret_cast < const char* > (sqlite3_column_text(pStmt.get(), 0));
const char* feature = reinterpret_cast < const char* > (sqlite3_column_text(pStmt.get(), 1));
- LOGD("privacy: %s, feature: %s", privacyId, feature);
+ PG_LOGD("privacy: %s, feature: %s", privacyId, feature);
if (feature != NULL)
{
bool isSupported = false;
res = isFeatureEnabled(feature, isSupported);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "isFeatureEnabled : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "isFeatureEnabled : %d", res);
if (!isSupported)
{
continue;
}
privacyIdList.push_back(std::string(privacyId));
- SECURE_LOGD(" privacy Id : %s", privacyId);
+ PG_LOGD("privacy Id : %s", privacyId);
}
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
prepareDb(pDbHandler, sql.c_str(), pStmt);
int res = sqlite3_bind_text(pStmt.get(), 1, privacyId.c_str(), -1, SQLITE_TRANSIENT);
- TryReturn(res == SQLITE_OK, PRIV_FLTR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
+ TryReturn(res == SQLITE_OK, PRIV_GUARD_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
if (sqlite3_step(pStmt.get()) == SQLITE_ROW)
{
}
else
{
- LOGI("Cannot find privacy string %s ", privacyId.c_str());
- return PRIV_FLTR_ERROR_NO_DATA;
+ PG_LOGI("Cannot find privacy string %s ", privacyId.c_str());
+ return PRIV_GUARD_ERROR_NO_DATA;
}
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
prepareDb(pDbHandler, sql.c_str(), pStmt);
int res = sqlite3_bind_text(pStmt.get(), 1, privacyId.c_str(), -1, SQLITE_TRANSIENT);
- TryReturn(res == SQLITE_OK, PRIV_FLTR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
+ TryReturn(res == SQLITE_OK, PRIV_GUARD_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
if (sqlite3_step(pStmt.get()) == SQLITE_ROW)
{
}
else
{
- LOGI("Cannot find privacy string %s ", privacyId.c_str());
- return PRIV_FLTR_ERROR_NO_DATA;
+ PG_LOGI("Cannot find privacy string %s ", privacyId.c_str());
+ return PRIV_GUARD_ERROR_NO_DATA;
}
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
PrivacyIdInfo::isFeatureEnabled(const char* feature, bool& enabled)
{
- int res = PRIV_FLTR_ERROR_SUCCESS;
+ int res = PRIV_GUARD_ERROR_SUCCESS;
if (feature == NULL)
{
}
res = system_info_get_platform_bool(feature, &enabled);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, PRIV_FLTR_ERROR_SYSTEM_ERROR, , "system_info_get_platform_bool : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, PRIV_GUARD_ERROR_SYSTEM_ERROR, , "system_info_get_platform_bool : %d", res);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
#include <errno.h>
#include <cstring>
#include <unistd.h>
-#include <dlog.h>
#include "Utils.h"
#include "SocketStream.h"
int
SocketStream::throwWithErrnoMessage(std::string function_name)
{
- LOGE("%s : %s", function_name.c_str(), strerror(errno));
+ PG_LOGE("%s : %s", function_name.c_str(), strerror(errno));
return errno;
}
TryReturn(pBytes != NULL, -1, , "Null pointer to buffer");
m_bytesRead += num;
-
+
TryReturn(m_bytesRead <= MAX_BUFFER, -1, , "Too big buffer requested!");
char partBuffer[MAX_BUFFER];
{
if (errno == EINTR)
continue;
- LOGD("pselect : %s", strerror(errno));
+ PG_LOGD("pselect : %s", strerror(errno));
return -1;
}
//This means pselect got timedout
{
if(errno == ECONNRESET || errno == ENOTCONN || errno == ETIMEDOUT)
{
- LOGI("Connection closed : %s", strerror(errno));
+ PG_LOGI("Connection closed : %s", strerror(errno));
return -1;
}
else if (errno != EAGAIN && errno != EWOULDBLOCK){
- LOGI("read()");
+ PG_LOGI("read()");
return -1;
}
}
}
memcpy(pBytes, wholeBuffer.c_str(), num);
-
+
return 0;
}
SocketStream::writeStream(size_t num, const void* pBytes)
{
TryReturn(pBytes != NULL, -1, , "Null pointer to buffer");
-
+
m_bytesWrote += num;
-
+
TryReturn(m_bytesRead <= MAX_BUFFER, -1, , "Too big buffer requested!");
fd_set wset, allset;
{
if(errno == EINTR)
continue;
- LOGD("pselect : %s", strerror(errno));
+ PG_LOGD("pselect : %s", strerror(errno));
return -1;
}
{
if(errno == ECONNRESET || errno == EPIPE)
{
- LOGI("Connection closed : %s", strerror(errno));
+ PG_LOGI("Connection closed : %s", strerror(errno));
return -1;
}
else if(errno != EAGAIN && errno != EWOULDBLOCK)
{
- LOGE("write()");
+ PG_LOGE("write()");
return -1;
}
}
* 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.
+ * limitations under the License.
*/
-
+
/**
* @file privacy_guard_client.h
* @brief APIs for privacy-guard-client
* @brief Called when the reply of the monitor policy request is delivered.
* @since tizen 3.0
*
- * @param[in] privacy_id The privacy ID
+ * @param[in] privacy_id The privacy ID
* @param[in] monitor_policy The monitor policy (0 or 1)
* @param[in] user_data The user data passed from the callback registration function
*
* @brief Called when the reply of the package id request is delivered.
* @since tizen 3.0
*
- * @param[in] package_id The package ID
+ * @param[in] package_id The package ID
* @param[in] user_data The user data passed from the callback registration function
*
* @returns: true to continue with the next iteration of the loop, otherwise return false to break out of the loop
* @brief Called when the reply of the privacy count request is delivered.
* @since tizen 3.0
*
- * @param[in] privacy_id The privacy ID
+ * @param[in] privacy_id The privacy ID
* @param[in] count The privacy count
* @param[in] user_data The user data passed from the callback registration function
*
* @brief Called when the reply of the privacy count request of package is delivered.
* @since tizen 3.0
*
- * @param[in] privacy_id The privacy ID
+ * @param[in] privacy_id The privacy ID
* @param[in] count The privacy count of a package
* @param[in] user_data The user data passed from the callback registration function
*
* 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.
+ * limitations under the License.
*/
#ifndef _PRIVACY_GUARD_CLIENT_TYPES_H_
#endif
enum {
- PRIV_FLTR_ERROR_SUCCESS = 0,
-
- PRIV_FLTR_ERROR_NOT_INITIALIZED = -10,
- PRIV_FLTR_ERROR_INVALID_PARAMETER = -11,
- PRIV_FLTR_ERROR_OUT_OF_MEMORY = -12,
- PRIV_FLTR_ERROR_IO_ERROR = -13,
- PRIV_FLTR_ERROR_NO_DATA = -14,
- PRIV_FLTR_ERROR_DB_ERROR = -15,
- PRIV_FLTR_ERROR_IPC_ERROR = -16,
- PRIV_FLTR_ERROR_INVALID_STATE = -17,
- PRIV_FLTR_ERROR_SYSTEM_ERROR = -18,
- PRIV_FLTR_ERROR_USER_NOT_CONSENTED = -19,
-
- PRIV_FLTR_ERROR_UNKNOWN = -(0x99),
+ PRIV_GUARD_ERROR_SUCCESS = 0,
+
+ PRIV_GUARD_ERROR_NOT_INITIALIZED = -10,
+ PRIV_GUARD_ERROR_INVALID_PARAMETER = -11,
+ PRIV_GUARD_ERROR_OUT_OF_MEMORY = -12,
+ PRIV_GUARD_ERROR_IO_ERROR = -13,
+ PRIV_GUARD_ERROR_NO_DATA = -14,
+ PRIV_GUARD_ERROR_DB_ERROR = -15,
+ PRIV_GUARD_ERROR_IPC_ERROR = -16,
+ PRIV_GUARD_ERROR_INVALID_STATE = -17,
+ PRIV_GUARD_ERROR_SYSTEM_ERROR = -18,
+ PRIV_GUARD_ERROR_USER_NOT_CONSENTED = -19,
+
+ PRIV_GUARD_ERROR_UNKNOWN = -(0x99),
};
SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/cmake_build_tmp/output)
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkg REQUIRED glib-2.0 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}")
INCLUDE_DIRECTORIES(
/usr/include
- /usr/include/glib-2.0
+ /usr/include/glib-2.0
/usr/include/libxml2
/usr/include/package_manager
/usr/include/dlog
COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}
COMMAND ${CMAKE_STRIP} --strip-unneeded ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}
COMMENT "strip ${this_target}"
- )
+ )
#INSTALL(TARGETS ${this_target} DESTINATION "../etc/package-manager/parserlib")
if (xmlStrcmp(curPtr->name, _NODE_PRIVILEGE) == 0)
{
xmlChar* pPrivilege = xmlNodeListGetString(docPtr, curPtr->xmlChildrenNode, 1);
-
+
if (pPrivilege == NULL)
{
LOGE("Failed to get value");
return -EINVAL;
}
- else
+ else
{
privilegeList.push_back(std::string( reinterpret_cast<char*> (pPrivilege)));
}
int monitor_policy = 1;
if (user_id < 0 || packageId == NULL)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
PrivacyGuardClient *pInst = PrivacyGuardClient::getInstance();
std::list < std::string > privilege_List;
destroy_char_list(ppPrivilegeList, privilegeList.size() + 1);
- if (ret != PRIV_FLTR_ERROR_SUCCESS)
+ if (ret != PRIV_GUARD_ERROR_SUCCESS)
{
LOGD("Failed to install monitor policy: %d", ret);
return -EINVAL;
int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr docPtr, const char* packageId)
{
if (packageId == NULL)
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
PrivacyGuardClient *pInst = PrivacyGuardClient::getInstance();
-
+
int res = pInst->PgDeleteLogsByPackageId(std::string(packageId));
- if (res != PRIV_FLTR_ERROR_SUCCESS)
+ if (res != PRIV_GUARD_ERROR_SUCCESS)
{
LOGD("Failed to delete logs");
return 0;
}
res = pInst->PgDeleteMonitorPolicyByPackageId(std::string(packageId));
- if (res != PRIV_FLTR_ERROR_SUCCESS)
+ if (res != PRIV_GUARD_ERROR_SUCCESS)
{
LOGD("Failed to delete monitor policy");
}
int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr docPtr, const char* packageId)
{
int res = 0;
-
+
LOGD("Update privacy Info");
res = PKGMGR_PARSER_PLUGIN_UNINSTALL(docPtr, packageId);
Version: @VERSION@
Libs: -L${libdir} @PC_LDFLAGS@
Cflags: @PC_CFLAGS@
-Requires:
+Requires:
Version: @VERSION@
Libs: -L${libdir} @PC_LDFLAGS@
Cflags: @PC_CFLAGS@
-Requires:
+Requires:
#include <unistd.h>
#include <fcntl.h>
#include <memory>
-#include <dlog.h>
#include <thread>
#include <cynara-monitor.h>
#include "PrivacyGuardTypes.h"
int
CynaraService::initialize(void)
{
- LOGI("CynaraService initializing");
+ PG_LOGI("CynaraService initializing");
int res = cynara_monitor_configuration_create(&p_conf);
if(res != CYNARA_API_SUCCESS){
- LOGE("cynara_monitor_configuration_create FAIL");
- return PRIV_FLTR_ERROR_SYSTEM_ERROR;
+ PG_LOGE("cynara_monitor_configuration_create FAIL");
+ return PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
// cynara_monitor_configuration_set_buffer_size(p_conf, buffer_size);
// res = cynara_monitor_initialize(&p_cynara_monitor, p_conf);
res = cynara_monitor_initialize(&p_cynara_monitor, nullptr);
if(res != CYNARA_API_SUCCESS){
- LOGE("cynara_monitor_initialize FAIL");
- return PRIV_FLTR_ERROR_SYSTEM_ERROR;
+ PG_LOGE("cynara_monitor_initialize FAIL");
+ return PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
// cynara_monitor_configuration_set_filter
- LOGI("CynaraService initialized");
+ PG_LOGI("CynaraService initialized");
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
CynaraService::start(void)
{
- LOGI("CynaraService starting");
+ PG_LOGI("CynaraService starting");
int res = 0;
sigset_t sigset;
sigemptyset(&sigset);
res = pthread_sigmask(SIG_BLOCK, &sigset, NULL);
- TryReturn( res >= 0, PRIV_FLTR_ERROR_SYSTEM_ERROR, , "pthread_sigmask : %s", strerror(errno));
+ TryReturn( res >= 0, PRIV_GUARD_ERROR_SYSTEM_ERROR, , "pthread_sigmask : %s", strerror(errno));
pthread_t cynaraThread;
res = pthread_create(&cynaraThread, NULL, &getEntriesThread, this);
- TryReturn( res >= 0, PRIV_FLTR_ERROR_SYSTEM_ERROR, errno = res, "pthread_create : %s", strerror(res));
+ TryReturn( res >= 0, PRIV_GUARD_ERROR_SYSTEM_ERROR, errno = res, "pthread_create : %s", strerror(res));
m_cynaraThread = cynaraThread;
- LOGI("CynaraService started");
+ PG_LOGI("CynaraService started");
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
void*
CynaraService::getEntriesThread(void* pData)
{
pthread_detach(pthread_self());
- LOGI("Running get entries thread");
+ PG_LOGI("Running get entries thread");
pthread_t testThread;
int result = pthread_create(&testThread, NULL, &flushThread, NULL);
if(result){
- LOGE("pthread_create FAIL");
- return (void*) PRIV_FLTR_ERROR_SYSTEM_ERROR;
+ PG_LOGE("pthread_create FAIL");
+ return (void*) PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
// while(1)
// cynara_monitor_entries_get
int res = cynara_monitor_entries_get(p_cynara_monitor, &monitor_entries);
if(res != CYNARA_API_SUCCESS){
- LOGE("cynara_monitor_entries_get FAIL");
- return (void*) PRIV_FLTR_ERROR_SYSTEM_ERROR;
+ PG_LOGE("cynara_monitor_entries_get FAIL");
+ return (void*) PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
res = CynaraService::updateDb(monitor_entries);
- if(res != PRIV_FLTR_ERROR_SUCCESS){
- LOGE("updateDb FAIL");
+ if(res != PRIV_GUARD_ERROR_SUCCESS){
+ PG_LOGE("updateDb FAIL");
return (void*) res;
}
// }
void*
CynaraService::flushThread(void* pData)
- {
+{
pthread_detach(pthread_self());
- LOGI("Running get flush thread");
+ PG_LOGI("Running get flush thread");
for(int i = 0; i < 1000000000;i++);
-
+
int ret= cynara_monitor_entries_flush(p_cynara_monitor);
if(ret != CYNARA_API_SUCCESS){
- LOGE("cynara_monitor_entries_flush FAIL");
- return (void*) PRIV_FLTR_ERROR_SYSTEM_ERROR;
+ PG_LOGE("cynara_monitor_entries_flush FAIL");
+ return (void*) PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
else{
- LOGI("cynara_monitor_entries_flush SUCCESS");
+ PG_LOGI("cynara_monitor_entries_flush SUCCESS");
}
-
+
return (void*) 0;
}
{
cynara_monitor_entry **entryIter = monitor_entries;
- LOGI("entryIter = %x", entryIter);
+ PG_LOGI("entryIter = %x", entryIter);
// DB update
int userId = 0;
timestamp = cynara_monitor_entry_get_timestamp(*entryIter);
int ret = PrivacyGuardDb::getInstance()->PgAddPrivacyAccessLogForCynara(userId, packageId, privilege, timestamp);
- if(ret != PRIV_FLTR_ERROR_SUCCESS){
- LOGE("PgAddPrivacyAccessLogForCynara FAIL");
+ if(ret != PRIV_GUARD_ERROR_SUCCESS){
+ PG_LOGE("PgAddPrivacyAccessLogForCynara FAIL");
}
else{
- LOGI("PgAddPrivacyAccessLogForCynara SUCCESS");
+ PG_LOGI("PgAddPrivacyAccessLogForCynara SUCCESS");
}
++entryIter;
}
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
CynaraService::stop(void)
{
- LOGI("Stopping");
+ PG_LOGI("Stopping");
int returned_value;
if((returned_value = pthread_kill(m_cynaraThread, m_signalToClose)) < 0)
{
errno = returned_value;
- LOGE("pthread_kill() : %s", strerror(errno));
- return PRIV_FLTR_ERROR_IPC_ERROR;
+ PG_LOGE("pthread_kill() : %s", strerror(errno));
+ return PRIV_GUARD_ERROR_IPC_ERROR;
}
- pthread_join(m_cynaraThread, NULL);
+ pthread_join(m_cynaraThread, NULL);
- LOGI("Stopped");
- return PRIV_FLTR_ERROR_SUCCESS;
+ PG_LOGI("Stopped");
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
CynaraService::shutdown(void)
{
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
NotificationServer::initialize(void)
{
if (m_initialized)
- return PRIV_FLTR_ERROR_SUCCESS;
-
+ return PRIV_GUARD_ERROR_SUCCESS;
+
DBusError error;
dbus_error_init(&error);
m_pDBusConnection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
- TryReturn(m_pDBusConnection != NULL, PRIV_FLTR_ERROR_SYSTEM_ERROR, dbus_error_free(&error), "dbus_bus_get_private : %s", error.message);
+ TryReturn(m_pDBusConnection != NULL, PRIV_GUARD_ERROR_SYSTEM_ERROR, dbus_error_free(&error), "dbus_bus_get_private : %s", error.message);
dbus_connection_setup_with_g_main(m_pDBusConnection, NULL);
std::unique_ptr < char[] > pRule(new char[MAX_LOCAL_BUF_SIZE]);
snprintf(pRule.get(), MAX_LOCAL_BUF_SIZE, "path='%s',type='signal',interface='%s'", DBUS_PATH.c_str(), DBUS_SIGNAL_INTERFACE.c_str());
dbus_bus_add_match(m_pDBusConnection, pRule.get(), &error);
- TryReturn(!dbus_error_is_set(&error), PRIV_FLTR_ERROR_SYSTEM_ERROR, dbus_error_free(&error), "dbus_bus_add_match : %s", error.message);
+ 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_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
NotificationServer::notifySettingChanged(const std::string pkgId, const std::string privacyId)
{
if (!m_initialized)
- return PRIV_FLTR_ERROR_INVALID_STATE;
+ return PRIV_GUARD_ERROR_INVALID_STATE;
char* pPkgId = const_cast <char*> (pkgId.c_str());
char* pPrivacyId = const_cast <char*> (privacyId.c_str());
DBusMessage* pMessage = dbus_message_new_signal(DBUS_PATH.c_str(), DBUS_SIGNAL_INTERFACE.c_str(), DBUS_SIGNAL_SETTING_CHANGED.c_str());
- TryReturn(pMessage != NULL, PRIV_FLTR_ERROR_IPC_ERROR, , "dbus_message_new_signal");
+ TryReturn(pMessage != NULL, PRIV_GUARD_ERROR_IPC_ERROR, , "dbus_message_new_signal");
dbus_bool_t r;
r = dbus_message_append_args(pMessage,
DBUS_TYPE_STRING, &pPkgId,
DBUS_TYPE_STRING, &pPrivacyId,
DBUS_TYPE_INVALID);
- TryReturn(r, PRIV_FLTR_ERROR_IPC_ERROR, , "dbus_message_append_args");
+ TryReturn(r, PRIV_GUARD_ERROR_IPC_ERROR, , "dbus_message_append_args");
r = dbus_connection_send(m_pDBusConnection, pMessage, NULL);
- TryReturn(r, PRIV_FLTR_ERROR_IPC_ERROR, dbus_message_unref(pMessage);, "dbus_connection_send");
+ TryReturn(r, PRIV_GUARD_ERROR_IPC_ERROR, dbus_message_unref(pMessage);, "dbus_connection_send");
dbus_connection_flush(m_pDBusConnection);
dbus_message_unref(pMessage);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
NotificationServer::notifyPkgRemoved(const std::string pkgId)
{
if (!m_initialized)
- return PRIV_FLTR_ERROR_INVALID_STATE;
+ return PRIV_GUARD_ERROR_INVALID_STATE;
char* pPkgId = const_cast <char*> (pkgId.c_str());
DBusMessage* pMessage = dbus_message_new_signal(DBUS_PATH.c_str(), DBUS_SIGNAL_INTERFACE.c_str(), DBUS_SIGNAL_PKG_REMOVED.c_str());
- TryReturn(pMessage != NULL, PRIV_FLTR_ERROR_IPC_ERROR, , "dbus_message_new_signal");
+ TryReturn(pMessage != NULL, PRIV_GUARD_ERROR_IPC_ERROR, , "dbus_message_new_signal");
dbus_bool_t r;
r = dbus_message_append_args(pMessage,
DBUS_TYPE_STRING, &pPkgId,
DBUS_TYPE_INVALID);
- TryReturn(r, PRIV_FLTR_ERROR_IPC_ERROR, , "dbus_message_append_args");
+ TryReturn(r, PRIV_GUARD_ERROR_IPC_ERROR, , "dbus_message_append_args");
r = dbus_connection_send(m_pDBusConnection, pMessage, NULL);
- TryReturn(r, PRIV_FLTR_ERROR_IPC_ERROR, dbus_message_unref(pMessage);, "dbus_connection_send");
+ TryReturn(r, PRIV_GUARD_ERROR_IPC_ERROR, dbus_message_unref(pMessage);, "dbus_connection_send");
dbus_connection_flush(m_pDBusConnection);
dbus_message_unref(pMessage);
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
PrivacyGuardDaemon::start(void)
{
int res = 0;
-
+
if (pSocketService == NULL)
- return PRIV_FLTR_ERROR_NOT_INITIALIZED;
+ return PRIV_GUARD_ERROR_NOT_INITIALIZED;
res = pSocketService->start();
- if(res != PRIV_FLTR_ERROR_SUCCESS){
- PF_LOGE("FAIL");
+ if(res != PRIV_GUARD_ERROR_SUCCESS){
+ PG_LOGE("FAIL");
}
#if 0
// [CYNARA]
if (pCynaraService == NULL)
- return PRIV_FLTR_ERROR_NOT_INITIALIZED;
+ return PRIV_GUARD_ERROR_NOT_INITIALIZED;
res = pCynaraService->start();
- if(res != PRIV_FLTR_ERROR_SUCCESS){
- PF_LOGE("FAIL");
- }
+ if(res != PRIV_GUARD_ERROR_SUCCESS){
+ PG_LOGE("FAIL");
+ }
#endif
return res;
}
{
pSocketService->stop();
#if 0
- // [CYNARA]
+ // [CYNARA]
pCynaraService->stop();
#endif
-
+
return 0;
}
#include <sstream>
#include <fstream>
-#include <dlog.h>
#include <sqlite3.h>
#include <pkgmgr-info.h>
#include <time.h>
int res = -1;
res = sqlite3_open_v2(PRIVACY_DB_PATH, &m_sqlHandler, SQLITE_OPEN_READWRITE, NULL);
if(res == SQLITE_OK) {
- PF_LOGI("monitor db is opened successfully");
+ PG_LOGI("monitor db is opened successfully");
// sqlite3_wal_autocheckpoint(m_sqlHandler, 1);
m_bDBOpen = true;
}
else {
- PF_LOGE("fail : monitor db open(%d)", res);
+ PG_LOGE("fail : monitor db open(%d)", res);
}
}
localtime(¤t_date);
if(current_date <= 0) {
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
}
int res = -1;
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
- PF_LOGD("addlogToDb m_sqlHandler : %p", m_sqlHandler);
+ PG_LOGD("addlogToDb m_sqlHandler : %p", m_sqlHandler);
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, QUERY_INSERT.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
for (std::list <std::pair <std::string, std::string>>::iterator iter = logInfoList.begin(); iter != logInfoList.end(); ++iter) {
- PF_LOGD("packageID : %s, PrivacyID : %s", iter->first.c_str(), iter->second.c_str());
+ PG_LOGD("packageID : %s, PrivacyID : %s", iter->first.c_str(), iter->second.c_str());
// bind
res = sqlite3_bind_int(m_stmt, 1, userId);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_bind_text(m_stmt, 2, iter->first.c_str(), -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
res = sqlite3_bind_text(m_stmt, 3, iter->second.c_str(), -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
res = sqlite3_bind_int(m_stmt, 4, current_date);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_step(m_stmt);
- TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_step : %d", res);
+ TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_step : %d", res);
sqlite3_reset(m_stmt);
}
m_dbMutex.unlock();
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
PrivacyGuardDb::PgAddPrivacyAccessLogForCynara(const int userId, const std::string packageId, const std::string privilege, const timespec* timestamp)
{
if(timestamp->tv_sec <= 0) {
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
}
int res = SQLITE_OK;
// change from privilege to privacy
std::string privacyId;
res = PrivacyIdInfo::getPrivacyIdFromPrivilege(privilege, privacyId);
- if (res == PRIV_FLTR_ERROR_NO_DATA) {
- return PRIV_FLTR_ERROR_SUCCESS;
+ if (res == PRIV_GUARD_ERROR_NO_DATA) {
+ return PRIV_GUARD_ERROR_SUCCESS;
}
- TryReturn( res == PRIV_FLTR_ERROR_SUCCESS, res, , "getPrivacyIdFromPrivilege : %d", res);
+ TryReturn( res == PRIV_GUARD_ERROR_SUCCESS, res, , "getPrivacyIdFromPrivilege : %d", res);
// change from timespec to time_t
time_t logging_date;
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
- PF_LOGD("addlogToDb m_sqlHandler : %p", m_sqlHandler);
+ PG_LOGD("addlogToDb m_sqlHandler : %p", m_sqlHandler);
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, QUERY_INSERT.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
// bind
res = sqlite3_bind_int(m_stmt, 1, userId);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_bind_text(m_stmt, 2, packageId.c_str(), -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
res = sqlite3_bind_text(m_stmt, 3, privacyId.c_str(), -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
res = sqlite3_bind_int(m_stmt, 4, logging_date);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_step(m_stmt);
- TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_step : %d", res);
+ TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_step : %d", res);
sqlite3_reset(m_stmt);
m_dbMutex.unlock();
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
localtime(¤t_date);
if(current_date <= 0) {
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
}
int res = SQLITE_OK;
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
- PF_LOGD("addlogToDb m_sqlHandler : %p", m_sqlHandler);
+ PG_LOGD("addlogToDb m_sqlHandler : %p", m_sqlHandler);
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, QUERY_INSERT.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
// bind
res = sqlite3_bind_int(m_stmt, 1, userId);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_bind_text(m_stmt, 2, packageId.c_str(), -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
res = sqlite3_bind_text(m_stmt, 3, privacyId.c_str(), -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
res = sqlite3_bind_int(m_stmt, 4, current_date);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_step(m_stmt);
- TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_step : %d", res);
+ TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_step : %d", res);
sqlite3_reset(m_stmt);
m_dbMutex.unlock();
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
- PF_LOGD("addlogToDb m_sqlHandler : %p", m_sqlHandler);
+ PG_LOGD("addlogToDb m_sqlHandler : %p", m_sqlHandler);
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, QUERY_INSERT.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
for (std::list <std::string>::const_iterator iter = privacyList.begin(); iter != privacyList.end(); ++iter) {
- PF_LOGD("PrivacyID : %s", iter->c_str());
+ PG_LOGD("PrivacyID : %s", iter->c_str());
// bind
res = sqlite3_bind_int(m_stmt, 1, userId);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_bind_text(m_stmt, 2, packageId.c_str(), -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
res = sqlite3_bind_text(m_stmt, 3, iter->c_str(), -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
res = sqlite3_bind_int(m_stmt, 4, monitorPolicy);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_step(m_stmt);
- TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_step : %d", res);
+ TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_step : %d", res);
sqlite3_reset(m_stmt);
}
m_dbMutex.unlock();
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, query.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn( res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn( res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
// bind
res = sqlite3_bind_int(m_stmt, 1, userId);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_bind_text(m_stmt, 2, packageId.c_str(), -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
int count = -1;
isPrivacyPackage = false;
}
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
PrivacyGuardDb::PgDeleteAllLogsAndMonitorPolicy(void)
{
- PF_LOGD("PgDeleteAllLogsAndMonitorPolicy");
+ PG_LOGD("PgDeleteAllLogsAndMonitorPolicy");
int res = -1;
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, LOG_DELETE.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
res = sqlite3_step(m_stmt);
- TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_step : %d", res);
+ TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_step : %d", res);
res = sqlite3_prepare_v2(m_sqlHandler, POLICY_DELETE.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
res = sqlite3_step(m_stmt);
- TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_step : %d", res);
+ TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_step : %d", res);
res = sqlite3_prepare_v2(m_sqlHandler, MAIN_POLICY_DELETE.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
res = sqlite3_step(m_stmt);
- TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_step : %d", res);
+ TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_step : %d", res);
m_dbMutex.unlock();
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
PrivacyGuardDb::PgDeleteLogsByPackageId(const std::string packageId)
{
- PF_LOGD("PrivacyGuardDb::PgDeleteLogsByPackageId packageid : %s", packageId.c_str());
+ PG_LOGD("PrivacyGuardDb::PgDeleteLogsByPackageId packageid : %s", packageId.c_str());
int res = -1;
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, QUERY_DELETE.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
// bind
res = sqlite3_bind_text(m_stmt, 1, packageId.c_str(), -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
// step
res = sqlite3_step(m_stmt);
- TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_step : %d", res);
+ TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_step : %d", res);
m_dbMutex.unlock();
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
PrivacyGuardDb::PgDeleteMonitorPolicyByPackageId(const std::string packageId)
{
- PF_LOGD("PrivacyGuardDb::PgDeleteMonitorPolicyByPackageId packageid : %s", packageId.c_str());
+ PG_LOGD("PrivacyGuardDb::PgDeleteMonitorPolicyByPackageId packageid : %s", packageId.c_str());
int res = -1;
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, QUERY_DELETE.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
// bind
res = sqlite3_bind_text(m_stmt, 1, packageId.c_str(), -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
// step
res = sqlite3_step(m_stmt);
- TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_step : %d", res);
+ TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_step : %d", res);
m_dbMutex.unlock();
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
// [CYNARA] Fluch Entries
int ret= cynara_monitor_entries_flush(p_cynara_monitor);
if(ret != CYNARA_API_SUCCESS){
- LOGE("cynara_monitor_entries_flush FAIL");
- return PRIV_FLTR_ERROR_SYSTEM_ERROR;
+ PG_LOGE("cynara_monitor_entries_flush FAIL");
+ return PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
// [CYNARA] Get Entries
ret = cynara_monitor_entries_get(p_cynara_monitor, &monitor_entries);
if(ret != CYNARA_API_SUCCESS){
- LOGE("cynara_monitor_entries_get FAIL");
- return PRIV_FLTR_ERROR_SYSTEM_ERROR;
+ PG_LOGE("cynara_monitor_entries_get FAIL");
+ return PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
- // [CYNARA] Update DB
+ // [CYNARA] Update DB
ret = CynaraService::updateDb(monitor_entries);
- if(ret != PRIV_FLTR_ERROR_SUCCESS){
- LOGE("updateDb FAIL");
+ if(ret != PRIV_GUARD_ERROR_SUCCESS){
+ PG_LOGE("updateDb FAIL");
return ret;
}
#endif
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, PKGID_SELECT.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
res = sqlite3_bind_int(m_stmt, 1, userId);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_bind_int(m_stmt, 2, startDate);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_bind_int(m_stmt, 3, endDate);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
while ((res = sqlite3_step(m_stmt)) == SQLITE_ROW) {
const char* packageId = reinterpret_cast < const char* > (sqlite3_column_text(m_stmt, 0));
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, PKGINFO_SELECT.c_str(), -1, &infoStmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
res = sqlite3_bind_int(infoStmt, 1, userId);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_bind_text(infoStmt, 2, packageId, -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
res = sqlite3_bind_int(infoStmt, 3, startDate);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_bind_int(infoStmt, 4, endDate);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
while ((res = sqlite3_step(infoStmt)) == SQLITE_ROW) {
int count = sqlite3_column_int(infoStmt, 0);
}
m_dbMutex.unlock();
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
// [CYNARA] Fluch Entries
int ret= cynara_monitor_entries_flush(p_cynara_monitor);
if(ret != CYNARA_API_SUCCESS){
- LOGE("cynara_monitor_entries_flush FAIL");
- return PRIV_FLTR_ERROR_SYSTEM_ERROR;
+ PG_LOGE("cynara_monitor_entries_flush FAIL");
+ return PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
// [CYNARA] Get Entries
ret = cynara_monitor_entries_get(p_cynara_monitor, &monitor_entries);
if(ret != CYNARA_API_SUCCESS){
- LOGE("cynara_monitor_entries_get FAIL");
- return PRIV_FLTR_ERROR_SYSTEM_ERROR;
+ PG_LOGE("cynara_monitor_entries_get FAIL");
+ return PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
- // [CYNARA] Update DB
+ // [CYNARA] Update DB
ret = CynaraService::updateDb(monitor_entries);
- if(ret != PRIV_FLTR_ERROR_SUCCESS){
- LOGE("updateDb FAIL");
+ if(ret != PRIV_GUARD_ERROR_SUCCESS){
+ PG_LOGE("updateDb FAIL");
return ret;
}
#endif
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
int i;
int cnt_privacy = sizeof(privacy_list) / sizeof(privacy_list[0]);
for (i = 0; i < cnt_privacy; i++) {
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, PRIVACY_SELECT.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
// bind
res = sqlite3_bind_int(m_stmt, 1, userId);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_bind_text(m_stmt, 2, privacy_list[i], -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
res = sqlite3_bind_int(m_stmt, 3, startDate);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_bind_int(m_stmt, 4, endDate);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
// step
if ((res = sqlite3_step(m_stmt)) == SQLITE_ROW) {
m_dbMutex.unlock();
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
// [CYNARA] Fluch Entries
int ret= cynara_monitor_entries_flush(p_cynara_monitor);
if(ret != CYNARA_API_SUCCESS){
- LOGE("cynara_monitor_entries_flush FAIL");
- return PRIV_FLTR_ERROR_SYSTEM_ERROR;
+ PG_LOGE("cynara_monitor_entries_flush FAIL");
+ return PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
// [CYNARA] Get Entries
ret = cynara_monitor_entries_get(p_cynara_monitor, &monitor_entries);
if(ret != CYNARA_API_SUCCESS){
- LOGE("cynara_monitor_entries_get FAIL");
- return PRIV_FLTR_ERROR_SYSTEM_ERROR;
+ PG_LOGE("cynara_monitor_entries_get FAIL");
+ return PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
- // [CYNARA] Update DB
+ // [CYNARA] Update DB
ret = CynaraService::updateDb(monitor_entries);
- if(ret != PRIV_FLTR_ERROR_SUCCESS){
- LOGE("updateDb FAIL");
+ if(ret != PRIV_GUARD_ERROR_SUCCESS){
+ PG_LOGE("updateDb FAIL");
return ret;
}
#endif
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, PKGID_SELECT.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
// bind
res = sqlite3_bind_int(m_stmt, 1, userId);
- TryReturn(res == SQLITE_OK, PRIV_FLTR_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);
+ TryReturn(res == SQLITE_OK, PRIV_GUARD_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);
res = sqlite3_bind_text(m_stmt, 2, privacyId.c_str(), -1, SQLITE_TRANSIENT);
- TryReturn(res == SQLITE_OK, PRIV_FLTR_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
+ TryReturn(res == SQLITE_OK, PRIV_GUARD_ERROR_DB_ERROR, , "sqlite3_bind_text : %d", res);
res = sqlite3_bind_int(m_stmt, 3, startDate);
- TryReturn(res == SQLITE_OK, PRIV_FLTR_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);
+ TryReturn(res == SQLITE_OK, PRIV_GUARD_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);
res = sqlite3_bind_int(m_stmt, 4, endDate);
- TryReturn(res == SQLITE_OK, PRIV_FLTR_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);
+ TryReturn(res == SQLITE_OK, PRIV_GUARD_ERROR_DB_ERROR, , "sqlite3_bind_int : %d", res);
while ((res = sqlite3_step(m_stmt)) == SQLITE_ROW) {
const char* packageId = reinterpret_cast < const char* > (sqlite3_column_text(m_stmt, 0));
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, PKGINFO_SELECT.c_str(), -1, &infoStmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
// bind
res = sqlite3_bind_int(infoStmt, 1, userId);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_bind_text(infoStmt, 2, packageId, -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
res = sqlite3_bind_text(infoStmt, 3, privacyId.c_str(), -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
res = sqlite3_bind_int(infoStmt, 4, startDate);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_bind_int(infoStmt, 5, endDate);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
if ((res = sqlite3_step(infoStmt)) == SQLITE_ROW) {
int count = sqlite3_column_int(infoStmt, 0);
m_dbMutex.unlock();
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
// [CYNARA] Fluch Entries
int ret= cynara_monitor_entries_flush(p_cynara_monitor);
if(ret != CYNARA_API_SUCCESS){
- LOGE("cynara_monitor_entries_flush FAIL");
- return PRIV_FLTR_ERROR_SYSTEM_ERROR;
+ PG_LOGE("cynara_monitor_entries_flush FAIL");
+ return PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
// [CYNARA] Get Entries
ret = cynara_monitor_entries_get(p_cynara_monitor, &monitor_entries);
if(ret != CYNARA_API_SUCCESS){
- LOGE("cynara_monitor_entries_get FAIL");
- return PRIV_FLTR_ERROR_SYSTEM_ERROR;
+ PG_LOGE("cynara_monitor_entries_get FAIL");
+ return PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
- // [CYNARA] Update DB
+ // [CYNARA] Update DB
ret = CynaraService::updateDb(monitor_entries);
- if(ret != PRIV_FLTR_ERROR_SUCCESS){
- LOGE("updateDb FAIL");
+ if(ret != PRIV_GUARD_ERROR_SUCCESS){
+ PG_LOGE("updateDb FAIL");
return ret;
}
#endif
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
int i;
int cnt_privacy = sizeof(privacy_list) / sizeof(privacy_list[0]);
for (i = 0; i < cnt_privacy; i++) {
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, PRIVACY_SELECT.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
//bind
res = sqlite3_bind_int(m_stmt, 1, userId);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_bind_text(m_stmt, 2, packageId.c_str(), -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
res = sqlite3_bind_text(m_stmt, 3, privacy_list[i], -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
res = sqlite3_bind_int(m_stmt, 4, startDate);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_bind_int(m_stmt, 5, endDate);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
if ((res = sqlite3_step(m_stmt)) == SQLITE_ROW) {
int count = sqlite3_column_int(m_stmt, 0);
m_dbMutex.unlock();
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, query.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
// bind
res = sqlite3_bind_int(m_stmt, 1, userId);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
-
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+
res = sqlite3_bind_text(m_stmt, 2, packageId.c_str(), -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
res = sqlite3_bind_text(m_stmt, 3, privacyId.c_str(), -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
// step
monitorPolicy = 0;
}
m_dbMutex.unlock();
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, MONITOR_POLICY_SELECT.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
// step
int monitorPolicy = 0;
m_dbMutex.unlock();
if(monitorPolicyList.size() > 0) {
- res = PRIV_FLTR_ERROR_SUCCESS;
+ res = PRIV_GUARD_ERROR_SUCCESS;
}
else {
- res = PRIV_FLTR_ERROR_NO_DATA;
+ res = PRIV_GUARD_ERROR_NO_DATA;
}
return res;
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, query.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock();, PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock();, PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
// bind
res = sqlite3_bind_int(m_stmt, 1, userId);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_bind_text(m_stmt, 2, packageId.c_str(), -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
// step
while ((res = sqlite3_step(m_stmt)) == SQLITE_ROW) {
}
m_dbMutex.unlock();
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, query.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock();, PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock();, PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
// bind
res = sqlite3_bind_int(m_stmt, 1, userId);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
// step
while ((res = sqlite3_step(m_stmt)) == SQLITE_ROW) {
}
m_dbMutex.unlock();
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, query.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock();, PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock();, PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
// bind
res = sqlite3_bind_int(m_stmt, 1, userId);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_bind_text(m_stmt, 2, privacyId.c_str(), -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
// step
while ((res = sqlite3_step(m_stmt)) == SQLITE_ROW) {
}
m_dbMutex.unlock();
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, query.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
// bind
res = sqlite3_bind_int(m_stmt, 1, monitorPolicy);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_bind_int(m_stmt, 2, userId);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_bind_text(m_stmt, 3, packageId.c_str(), -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
res = sqlite3_bind_text(m_stmt, 4, privacyId.c_str(), -1, SQLITE_TRANSIENT);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
// step
res = sqlite3_step(m_stmt);
- TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_step : %d", res);
+ TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_step : %d", res);
m_dbMutex.unlock();
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
- PF_LOGD("addlogToDb m_sqlHandler : %p", m_sqlHandler);
+ PG_LOGD("addlogToDb m_sqlHandler : %p", m_sqlHandler);
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, QUERY_INSERT.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
//bind
res = sqlite3_bind_int(m_stmt, 1, userId);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
//step
res = sqlite3_step(m_stmt);
- TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_step : %d", res);
+ TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_step : %d", res);
m_dbMutex.unlock();
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, query.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
// bind
res = sqlite3_bind_int(m_stmt, 1, mainMonitorPolicy);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_bind_int(m_stmt, 2, userId);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
// step
res = sqlite3_step(m_stmt);
- TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_step : %d", res);
+ TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_step : %d", res);
m_dbMutex.unlock();
cynara_monitor_configuration_set_filter();
#endif
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, query.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
// bind
res = sqlite3_bind_int(m_stmt, 1, userId);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
// step
mainMonitorPolicy = false;
else {
m_dbMutex.unlock();
res = PgAddMainMonitorPolicy(userId);
- TryReturn(res == PRIV_FLTR_ERROR_SUCCESS, res, , "PgAddMainMonitorPolicy failed : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "PgAddMainMonitorPolicy failed : %d", res);
}
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
if(m_bDBOpen == false) {
openSqliteDB();
}
- TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_FLTR_ERROR_IO_ERROR, "openSqliteDB : %d", res);
+ TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, QUERY_DELETE.c_str(), -1, &m_stmt, NULL);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
// bind
res = sqlite3_bind_int(m_stmt, 1, userId);
- TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
// step
res = sqlite3_step(m_stmt);
- TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_FLTR_ERROR_DB_ERROR, "sqlite3_step : %d", res);
+ TryCatchResLogReturn(res == SQLITE_DONE, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_step : %d", res);
m_dbMutex.unlock();
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
PrivacyGuardDb::PrivacyGuardDb(void)
#include <unistd.h>
#include <fcntl.h>
#include <memory>
-#include <dlog.h>
#include "PrivacyGuardTypes.h"
#include "Utils.h"
#include "SocketService.h"
int
SocketService::initialize(void)
{
- LOGI("SocketService initializing");
+ PG_LOGI("SocketService initializing");
m_listenFd = socket(AF_UNIX, SOCK_STREAM, 0);
- TryReturn( m_listenFd != -1, PRIV_FLTR_ERROR_SYSTEM_ERROR, , "socket : %s", strerror(errno));
+ TryReturn( m_listenFd != -1, PRIV_GUARD_ERROR_SYSTEM_ERROR, , "socket : %s", strerror(errno));
int flags = -1;
int res;
if ( (flags = fcntl(m_listenFd, F_GETFL, 0)) == -1)
flags = 0;
res = fcntl(m_listenFd, F_SETFL, flags | O_NONBLOCK);
- TryReturn( res != -1, PRIV_FLTR_ERROR_SYSTEM_ERROR, , "fcntl : %s", strerror(errno));
+ TryReturn( res != -1, PRIV_GUARD_ERROR_SYSTEM_ERROR, , "fcntl : %s", strerror(errno));
sockaddr_un server_address;
bzero(&server_address, sizeof(server_address));
original_umask = umask(socket_umask);
res = bind(m_listenFd, (struct sockaddr*)&server_address, SUN_LEN(&server_address));
- TryReturn( res != -1, PRIV_FLTR_ERROR_SYSTEM_ERROR, , "bind : %s", strerror(errno));
+ TryReturn( res != -1, PRIV_GUARD_ERROR_SYSTEM_ERROR, , "bind : %s", strerror(errno));
umask(original_umask);
- LOGI("SocketService initialized");
+ PG_LOGI("SocketService initialized");
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
SocketService::start(void)
{
- LOGI("SocketService starting");
+ PG_LOGI("SocketService starting");
sigset_t sigset;
sigemptyset(&sigset);
// if ( sigaddset(&sigset, m_signalToClose) == -1 )
// {
-// LOGE("Failed to sigaddset : %s", strerror(errno));
+// PG_LOGE("Failed to sigaddset : %s", strerror(errno));
// return -1;
// }
int res = 0;
res = pthread_sigmask(SIG_BLOCK, &sigset, NULL);
- TryReturn( res >= 0, PRIV_FLTR_ERROR_SYSTEM_ERROR, , "pthread_sigmask : %s", strerror(errno));
+ TryReturn( res >= 0, PRIV_GUARD_ERROR_SYSTEM_ERROR, , "pthread_sigmask : %s", strerror(errno));
pthread_t mainThread;
res = pthread_create(&mainThread, NULL, &serverThread, this);
- TryReturn( res >= 0, PRIV_FLTR_ERROR_SYSTEM_ERROR, errno = res, "pthread_create : %s", strerror(res));
+ TryReturn( res >= 0, PRIV_GUARD_ERROR_SYSTEM_ERROR, errno = res, "pthread_create : %s", strerror(res));
m_mainThread = mainThread;
- LOGI("SocketService started");
+ PG_LOGI("SocketService started");
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
void*
{
pthread_detach(pthread_self());
SocketService &t = *static_cast< SocketService* > (pData);
- LOGI("Running main thread");
+ PG_LOGI("Running main thread");
int ret = t.mainloop();
if (ret < 0)
{
SocketService::mainloop(void)
{
if( listen(m_listenFd, MAX_LISTEN) == -1 ){
- LOGE("listen : %s", strerror(errno));
- return PRIV_FLTR_ERROR_IPC_ERROR;
+ PG_LOGE("listen : %s", strerror(errno));
+ return PRIV_GUARD_ERROR_IPC_ERROR;
}
//Settings to catch closing signal in select
sigset_t sigset;
int res;
res = sigemptyset(&sigset);
- TryReturn( res != -1, PRIV_FLTR_ERROR_SYSTEM_ERROR, , "sigemptyset : %s", strerror(errno));
+ TryReturn( res != -1, PRIV_GUARD_ERROR_SYSTEM_ERROR, , "sigemptyset : %s", strerror(errno));
// if( sigaddset(&sigset, m_signalToClose) == -1) {
-// LOGE("sigaddset : %s", strerror(errno));
+// PG_LOGE("sigaddset : %s", strerror(errno));
// return -1;
// }
signal_fd = signalfd(-1, &sigset, 0);
- TryReturn( signal_fd >= 0, PRIV_FLTR_ERROR_SYSTEM_ERROR, , "signalfd : %s", strerror(errno));
+ TryReturn( signal_fd >= 0, PRIV_GUARD_ERROR_SYSTEM_ERROR, , "signalfd : %s", strerror(errno));
//Setting descriptors for pselect
fd_set allset, rset;
if(pselect(maxfd, &rset, NULL, NULL, NULL, NULL) == -1)
{
closeConnections();
- LOGE("pselect()");
- return PRIV_FLTR_ERROR_SYSTEM_ERROR;
+ PG_LOGE("pselect()");
+ return PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
if(FD_ISSET(signal_fd, &rset))
{
- LOGI("Got signal to close");
+ PG_LOGI("Got signal to close");
signalfd_siginfo siginfo;
ssize_t res;
res = read(signal_fd, &siginfo, sizeof(siginfo));
- TryReturn( res > 0, PRIV_FLTR_ERROR_IPC_ERROR, closeConnections();, "read : %s", strerror(errno));
- TryReturn( (size_t)res == sizeof(siginfo), PRIV_FLTR_ERROR_IPC_ERROR, closeConnections();, "couldn't read whole siginfo");
+ TryReturn( res > 0, PRIV_GUARD_ERROR_IPC_ERROR, closeConnections();, "read : %s", strerror(errno));
+ TryReturn( (size_t)res == sizeof(siginfo), PRIV_GUARD_ERROR_IPC_ERROR, closeConnections();, "couldn't read whole siginfo");
if((int)siginfo.ssi_signo == m_signalToClose)
{
- LOGI("Server thread got signal to close");
+ PG_LOGI("Server thread got signal to close");
closeConnections();
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
else
{
- LOGI("Got not handled signal");
+ PG_LOGI("Got not handled signal");
}
}
if(FD_ISSET(m_listenFd, &rset))
{
int clientFd;
clientFd = accept(m_listenFd, NULL, NULL);
- TryReturn( clientFd != -1, PRIV_FLTR_ERROR_IPC_ERROR, closeConnections();, "accept : %s", strerror(errno));
+ TryReturn( clientFd != -1, PRIV_GUARD_ERROR_IPC_ERROR, closeConnections();, "accept : %s", strerror(errno));
- LOGI("Got incoming connection");
+ PG_LOGI("Got incoming connection");
ConnectionInfo * connection = new ConnectionInfo(clientFd, (void *)this);
int res;
pthread_t client_thread;
delete connection;
errno = res;
closeConnections();
- LOGE("pthread_create()");
- return PRIV_FLTR_ERROR_SYSTEM_ERROR;
+ PG_LOGE("pthread_create()");
+ return PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
addClientSocket(clientFd);
}
pthread_detach(pthread_self());
std::unique_ptr<ConnectionInfo> connectionInfo (static_cast<ConnectionInfo *>(pData));
SocketService &t = *static_cast<SocketService *>(connectionInfo->pData);
- LOGI("Starting connection thread");
+ PG_LOGI("Starting connection thread");
int ret = t.connectionService(connectionInfo->connFd);
if (ret < 0)
{
- LOGE("Connection thread error");
+ PG_LOGE("Connection thread error");
t.removeClientSocket(connectionInfo->connFd);
close(connectionInfo->connFd);
return (void*)1;
}
- LOGI("Client serviced");
+ PG_LOGI("Client serviced");
return (void*)0;
}
std::string interfaceName, methodName;
int res = connector.read(&interfaceName, &methodName);
- if (res != PRIV_FLTR_ERROR_SUCCESS)
+ if (res != PRIV_GUARD_ERROR_SUCCESS)
{
- LOGE("read : %d", res);
+ PG_LOGE("read : %d", res);
return res;
}
- LOGD("Got interface : %s", interfaceName.c_str());
- LOGD("Got method : %s", methodName.c_str());
+ PG_LOGD("Got interface : %s", interfaceName.c_str());
+ PG_LOGD("Got method : %s", methodName.c_str());
if( m_callbackMap.find(interfaceName) == m_callbackMap.end())
{
- LOGE("Unknown interface : %s", interfaceName.c_str());
- return PRIV_FLTR_ERROR_NO_DATA;
+ PG_LOGE("Unknown interface : %s", interfaceName.c_str());
+ return PRIV_GUARD_ERROR_NO_DATA;
}
if(m_callbackMap[interfaceName].find(methodName) == m_callbackMap[interfaceName].end())
{
- LOGE("Unknown method : %s", methodName.c_str());
- return PRIV_FLTR_ERROR_NO_DATA;
+ PG_LOGE("Unknown method : %s", methodName.c_str());
+ return PRIV_GUARD_ERROR_NO_DATA;
}
// if(m_callbackMap[interfaceName][methodName]->securityCallback != NULL){
// if(!m_callbackMap[interfaceName][methodName]->securityCallback(fd)){
-// LOGE("Security check returned false");
+// PG_LOGE("Security check returned false");
// return -1;
// }
// }
- LOGI("Calling service");
+ PG_LOGI("Calling service");
m_callbackMap[interfaceName][methodName]->serviceCallback(&connector);
-
- LOGI("Removing client");
+
+ PG_LOGI("Removing client");
removeClientSocket(fd);
close(fd);
- LOGI("Call served");
+ PG_LOGI("Call served");
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
SocketService::stop(void)
{
- LOGI("Stopping");
+ PG_LOGI("Stopping");
if(close(m_listenFd) == -1)
if(errno != ENOTCONN)
{
- LOGE("close() : %s", strerror(errno));
- return PRIV_FLTR_ERROR_IPC_ERROR;
+ PG_LOGE("close() : %s", strerror(errno));
+ return PRIV_GUARD_ERROR_IPC_ERROR;
}
int returned_value;
if((returned_value = pthread_kill(m_mainThread, m_signalToClose)) < 0)
{
errno = returned_value;
- LOGE("pthread_kill() : %s", strerror(errno));
- return PRIV_FLTR_ERROR_IPC_ERROR;
+ PG_LOGE("pthread_kill() : %s", strerror(errno));
+ return PRIV_GUARD_ERROR_IPC_ERROR;
}
pthread_join(m_mainThread, NULL);
- LOGI("Stopped");
- return PRIV_FLTR_ERROR_SUCCESS;
+ PG_LOGI("Stopped");
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
SocketService::shutdown(void)
{
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
int
{
if(NULL == callbackMethod)
{
- LOGE("Null callback");
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ PG_LOGE("Null callback");
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
}
if(interfaceName.empty() || methodName.empty())
{
- LOGE("Interface and method name cannot be empty");
- return PRIV_FLTR_ERROR_INVALID_PARAMETER;
+ PG_LOGE("Interface and method name cannot be empty");
+ return PRIV_GUARD_ERROR_INVALID_PARAMETER;
}
auto serviceCallbackPtr = std::make_shared<ServiceCallback>(ServiceCallback(callbackMethod));
m_callbackMap[interfaceName][methodName] = serviceCallbackPtr;
- return PRIV_FLTR_ERROR_SUCCESS;
+ return PRIV_GUARD_ERROR_SUCCESS;
}
void
SocketService::closeConnections(void)
{
int clientSocket;
- LOGI("Closing client sockets");
+ PG_LOGI("Closing client sockets");
while(popClientSocket(&clientSocket))
{
if(close(clientSocket) == -1)
{
- LOGE("close() : %s", strerror(errno));
+ PG_LOGE("close() : %s", strerror(errno));
}
}
- LOGI("Connections closed");
+ PG_LOGI("Connections closed");
}
* limitations under the License.
*/
-#include <dlog.h>
#include "PrivacyInfoService.h"
#include "PrivacyGuardDb.h"
#include "Utils.h"
void
PrivacyInfoService::PgAddPrivacyAccessLog(SocketConnection* pConnector)
{
- LOGI("PRIVACY PrivacyInfoService PgAddPrivacyAccessLog");
+ PG_LOGI("PRIVACY PrivacyInfoService PgAddPrivacyAccessLog");
int userId = 0;
std::list <std::pair<std::string, std::string>> logInfoList;
pConnector->read(&userId, &logInfoList);
- PF_LOGD("PrivacyInfoService PgAddPrivacyAccessLog userId : %d", userId);
+ PG_LOGD("PrivacyInfoService PgAddPrivacyAccessLog userId : %d", userId);
int result = PrivacyGuardDb::getInstance()->PgAddPrivacyAccessLog(userId, logInfoList);
void
PrivacyInfoService::PgAddPrivacyAccessLogTest(SocketConnection* pConnector)
{
- LOGI("PRIVACY PrivacyInfoService PgAddPrivacyAccessLogTest");
+ PG_LOGI("PRIVACY PrivacyInfoService PgAddPrivacyAccessLogTest");
int userId = 0;
std::string packageId;
std::string privacyId;
pConnector->read(&userId, &packageId, &privacyId);
- PF_LOGD("PrivacyInfoService PgAddPrivacyAccessLogTest userId : %d", userId);
+ PG_LOGD("PrivacyInfoService PgAddPrivacyAccessLogTest userId : %d", userId);
int result = PrivacyGuardDb::getInstance()->PgAddPrivacyAccessLogTest(userId, packageId, privacyId);
std::list < std::pair < std::string, int > > packageInfoList;
pConnector->read(&userId, &startDate, &endDate);
- PF_LOGD("requested > userId : %d, startDate : %d, endDate : %d", userId, startDate, endDate);
+ PG_LOGD("requested > userId : %d, startDate : %d, endDate : %d", userId, startDate, endDate);
int result = PrivacyGuardDb::getInstance()->PgForeachTotalPrivacyCountOfPackage(userId, startDate, endDate, packageInfoList);
- PF_LOGD("response > packageInfoList size : %d", packageInfoList.size());
+ PG_LOGD("response > packageInfoList size : %d", packageInfoList.size());
pConnector->write(result);
pConnector->write(packageInfoList);
std::list < std::pair < std::string, int > > privacyInfoList;
pConnector->read(&userId, &startDate, &endDate);
- PF_LOGD("requested > startDate : %d, endDate : %d", startDate, endDate);
+ PG_LOGD("requested > startDate : %d, endDate : %d", startDate, endDate);
int result = PrivacyGuardDb::getInstance()->PgForeachTotalPrivacyCountOfPrivacy(userId, startDate, endDate, privacyInfoList);
- PF_LOGD("response > privacyInfoList size : %d", privacyInfoList.size());
+ PG_LOGD("response > privacyInfoList size : %d", privacyInfoList.size());
pConnector->write(result);
pConnector->write(privacyInfoList);
std::list < std::pair < std::string, int > > packageInfoList;
pConnector->read(&userId, &startDate, &endDate, &privacyId);
- PF_LOGD("requested > startDate : %d, endDate : %d, privacyId : %s",
+ PG_LOGD("requested > startDate : %d, endDate : %d, privacyId : %s",
startDate, endDate, privacyId.c_str());
int result = PrivacyGuardDb::getInstance()->PgForeachPrivacyCountByPrivacyId(userId, startDate, endDate,
privacyId, packageInfoList);
- PF_LOGD("response > packageInfoList size : %d", packageInfoList.size());
+ PG_LOGD("response > packageInfoList size : %d", packageInfoList.size());
pConnector->write(result);
pConnector->write(packageInfoList);
std::list < std::pair < std::string, int > > privacyInfoList;
pConnector->read(&userId, &startDate, &endDate, &packageId);
- PF_LOGD("requested > startDate : %d, endDate : %d, packageId : %s",
+ PG_LOGD("requested > startDate : %d, endDate : %d, packageId : %s",
startDate, endDate, packageId.c_str());
int result = PrivacyGuardDb::getInstance()->PgForeachPrivacyCountByPackageId(userId, startDate, endDate,
packageId, privacyInfoList);
- PF_LOGD("response > privacyInfoList size : %d", privacyInfoList.size());
+ PG_LOGD("response > privacyInfoList size : %d", privacyInfoList.size());
pConnector->write(result);
pConnector->write(privacyInfoList);
std::list < std::string > packageList;
pConnector->read(&userId);
- PF_LOGD("requested > userId : %d", userId);
+ PG_LOGD("requested > userId : %d", userId);
int result = PrivacyGuardDb::getInstance()->PgForeachPrivacyPackageId(userId, packageList);
- PF_LOGD("response > packageList size : %d", packageList.size());
+ PG_LOGD("response > packageList size : %d", packageList.size());
pConnector->write(result);
pConnector->write(packageList);
int result = -1;
result = PrivacyGuardDb::getInstance()->PgForeachMonitorPolicyByPackageId(userId, packageId, privacyInfoList);
- PF_LOGD("response > privacyInfoList size : %d", privacyInfoList.size());
+ PG_LOGD("response > privacyInfoList size : %d", privacyInfoList.size());
pConnector->write(result);
pConnector->write(privacyInfoList);
std::string privacyId;
pConnector->read(&userId, &packageId, &privacyId);
- PF_LOGD("requested > packageId : %s, privacyId : %s", packageId.c_str(), privacyId.c_str());
+ PG_LOGD("requested > packageId : %s, privacyId : %s", packageId.c_str(), privacyId.c_str());
int monitorPolicy = 1;
int result = -1;
result = PrivacyGuardDb::getInstance()->PgGetMonitorPolicy(userId, packageId, privacyId, monitorPolicy);
- PF_LOGD("response > monitorPolicy : %d", monitorPolicy);
+ PG_LOGD("response > monitorPolicy : %d", monitorPolicy);
pConnector->write(result);
pConnector->write(monitorPolicy);
std::list < std::string > packageList;
pConnector->read(&userId, &privacyId);
- PF_LOGD("requested > userId : %d, privacyId : %s", userId, privacyId.c_str());
+ PG_LOGD("requested > userId : %d, privacyId : %s", userId, privacyId.c_str());
int result = PrivacyGuardDb::getInstance()->PgForeachPackageByPrivacyId(userId, privacyId, packageList);
- PF_LOGD("response > packageList size : %d", packageList.size());
+ PG_LOGD("response > packageList size : %d", packageList.size());
pConnector->write(result);
pConnector->write(packageList);
bool isPrivacyPackage = false;
pConnector->read(&userId, &packageId);
- PF_LOGD("requested > packageId : %s", packageId.c_str());
+ PG_LOGD("requested > packageId : %s", packageId.c_str());
int result = PrivacyGuardDb::getInstance()->PgCheckPrivacyPackage(userId, packageId, isPrivacyPackage);
pConnector->write(result);
int monitorPolicy = 1;
pConnector->read(&userId, &packageId, &privacyId, &monitorPolicy);
- PF_LOGD("requested > packageId : %s, privacyId : %s, monitorPolicy : %d",
+ PG_LOGD("requested > packageId : %s, privacyId : %s, monitorPolicy : %d",
packageId.c_str(), privacyId.c_str(), monitorPolicy);
int result = PrivacyGuardDb::getInstance()->PgUpdateMonitorPolicy(userId, packageId, privacyId, monitorPolicy);
bool mainMonitorPolicy = false;
pConnector->read(&userId, &mainMonitorPolicy);
- PF_LOGD("requested > mainMonitorPolicy : %d", mainMonitorPolicy);
+ PG_LOGD("requested > mainMonitorPolicy : %d", mainMonitorPolicy);
int result = PrivacyGuardDb::getInstance()->PgUpdateMainMonitorPolicy(userId, mainMonitorPolicy);
pConnector->write(result);
int userId = 0;
pConnector->read(&userId);
- PF_LOGD("PgGetMainMonitorPolicy userId : %d", userId);
+ PG_LOGD("PgGetMainMonitorPolicy userId : %d", userId);
bool mainMonitorPolicy = false;
int result = -1;
result = PrivacyGuardDb::getInstance()->PgGetMainMonitorPolicy(userId, mainMonitorPolicy);
- PF_LOGD("response > mainMonitorPolicy : %d", mainMonitorPolicy);
+ PG_LOGD("response > mainMonitorPolicy : %d", mainMonitorPolicy);
pConnector->write(result);
pConnector->write(mainMonitorPolicy);