static std::mutex m_singletonMutex;
- std::list <std::pair<std::string, std::string>> logInfoList;
+ std::list <std::pair<std::string, std::string>> m_logInfoList;
PrivacyGuardClient();
~PrivacyGuardClient();
int PgForeachPrivacyPackageId(const int userId, std::list < std::string > & packageList) const;
- int PgForeachPackageByPrivacyId(const int userId, const std::string privacyId, std::list < std::string > & packageList) const;
+ int PgForeachPackageInfoByPrivacyId(const int userId, const std::string privacyId, std::list < package_data_s > & packageList) const;
int PgForeachMonitorPolicyByPackageId(const int userId, const std::string packageId,
std::list <privacy_data_s> & privacyInfoList) const;
#include <dbus/dbus-glib-lowlevel.h>
#include <sys/types.h>
#include <unistd.h>
+#include <privilege_info.h>
#include "PrivacyChecker.h"
#include "PrivacyIdInfo.h"
#include "PrivacyGuardClient.h"
int
PrivacyChecker::initMonitorPolicyCache(void)
{
- PG_LOGD("PrivacyChecker::initCache");
-
std::list < std::pair < std::string, int > > monitorPolicyList;
+
int retval = PrivacyGuardClient::getInstance()->PgGetAllMonitorPolicy(monitorPolicyList);
if(retval == PRIV_GUARD_ERROR_SUCCESS && !monitorPolicyList.empty()) {
m_monitorPolicyCache.insert(monitorPolicyList.begin(), monitorPolicyList.end());
+ } else {
+ PG_LOGD("ret: [%d], monitorPolicyList size: [%d]", retval, monitorPolicyList.size());
}
+
return retval;
}
int
PrivacyChecker::getMonitorPolicy(const int userId, const std::string packageId, const std::string privacyId, int &monitorPolicy)
{
- PG_LOGD("getMonitorPolicy m_isInitialized : %d", m_isInitialized);
+ PG_LOGD("m_isInitialized: %d", m_isInitialized);
if (m_isInitialized == false) {
initialize();
// printMonitorPolicyCache();
std::string userPkgIdPrivacyId = std::to_string(userId) + std::string("|") + packageId + std::string("|") + privacyId;
- PG_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_GUARD_ERROR_SUCCESS;
if(itr != m_monitorPolicyCache.end()) {
void
PrivacyChecker::checkMonitorByPrivilege(const std::string privilegeId)
{
- PG_LOGD("checkMonitorByPrivilege");
-
- if(privilegeId.compare("http://tizen.org/privilege/calendar.read") == 0 ||
- privilegeId.compare("http://tizen.org/privilege/calendar.write") == 0 ||
- privilegeId.compare("http://tizen.org/privilege/contact.read") == 0 ||
- privilegeId.compare("http://tizen.org/privilege/contact.write") == 0 ||
- privilegeId.compare("http://tizen.org/privilege/location") == 0 ||
- privilegeId.compare("http://tizen.org/privilege/messaging.write") == 0 ||
- privilegeId.compare("http://tizen.org/privilege/messaging.read") == 0 ||
- privilegeId.compare("http://tizen.org/privilege/messaging.send") == 0 ||
- privilegeId.compare("http://tizen.org/privilege/messaging.sms") == 0 ||
- privilegeId.compare("http://tizen.org/privilege/messaging.mms") == 0 ||
- privilegeId.compare("http://tizen.org/privilege/messaging.email") == 0) {
+ PG_LOGD("checkMonitorByPrivilege called with privilege: [%s]", privilegeId.c_str());
+
+ if (privilege_info_is_privacy(privilegeId.c_str())) {
m_isMonitorEnable = true;
}
else {
+ PG_LOGD("[%s] is not related to a privacy.", privilegeId.c_str());
m_isMonitorEnable = false;
}
}
#include "SocketClient.h"
#include "PrivacyIdInfo.h"
-#define COUNT 10
+//#define COUNT 10
+#define COUNT 1
#undef __READ_DB_IPC__
PrivacyGuardClient::PgAddPrivacyAccessLog(const int userId, const std::string packageId, const std::string privacyId)
{
int result = PRIV_GUARD_ERROR_SUCCESS;
- logInfoList.push_back(std::pair <std::string, std::string> (packageId, privacyId));
- PG_LOGD("PrivacyGuardClient userId : %d, PgAddPrivacyAccessLog logInfoList.size() : %d", userId, logInfoList.size());
+ m_logInfoList.push_back(std::pair <std::string, std::string> (packageId, privacyId));
+ PG_LOGD("PrivacyGuardClient userId : %d, PgAddPrivacyAccessLog m_logInfoList.size() : %d", userId, m_logInfoList.size());
- if(logInfoList.size() >= COUNT) {
+ if(m_logInfoList.size() >= COUNT) {
int res = m_pSocketClient->connect();
TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
- res = m_pSocketClient->call("PgAddPrivacyAccessLog", userId, logInfoList, &result);
+ res = m_pSocketClient->call("PgAddPrivacyAccessLog", userId, m_logInfoList, &result);
TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "disconnect : %d", res);
- logInfoList.clear();
+ m_logInfoList.clear();
}
return result;
PrivacyGuardClient::PgAddPrivacyAccessLogBeforeTerminate(void)
{
int result = PRIV_GUARD_ERROR_SUCCESS;
- PG_LOGD("PgAddPrivacyAccessLogBeforeTerminate, logInfoList.size() : %d", logInfoList.size());
+ PG_LOGD("PgAddPrivacyAccessLogBeforeTerminate, m_logInfoList.size() : %d", m_logInfoList.size());
- if(logInfoList.size() > 0) {
+ if(m_logInfoList.size() > 0) {
int res = m_pSocketClient->connect();
TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
- res = m_pSocketClient->call("PgAddPrivacyAccessLog", logInfoList, &result);
+ res = m_pSocketClient->call("PgAddPrivacyAccessLog", m_logInfoList, &result);
TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "disconnect : %d", res);
- logInfoList.clear();
+ m_logInfoList.clear();
}
return result;
int
PrivacyGuardClient::PgAddMonitorPolicy(const int userId, const std::string pkgId, const std::list < std::string >& list, int monitorPolicy)
{
+ PG_LOGD("userID: [%d], packageID[%s], monitorPolicy: [%d]", userId, pkgId.c_str(), monitorPolicy);
+
std::list < std::string > privacyList;
int res = PrivacyIdInfo::getPrivacyIdListFromPrivilegeList(list, privacyList);
}
int
-PrivacyGuardClient::PgForeachPackageByPrivacyId(const int userId, const std::string privacyId, std::list < std::string > & packageList) const
+PrivacyGuardClient::PgForeachPackageInfoByPrivacyId(const int userId, const std::string privacyId, std::list < package_data_s > & packageInfoList) const
{
int result = PRIV_GUARD_ERROR_SUCCESS;
int res = m_pSocketClient->connect();
TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "connect : %d", res);
- res = m_pSocketClient->call("PgForeachPackageByPrivacyId", userId, privacyId, &result, &packageList);
+ res = m_pSocketClient->call("PgForeachPackageInfoByPrivacyId", userId, privacyId, &result, &packageInfoList);
TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, m_pSocketClient->disconnect(), "call : %d", res);
res = m_pSocketClient->disconnect();
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) {
+ PG_LOGD("user_id: [%d], package_id: [%s], monitor_policy: [%d]", user_id, package_id, monitor_policy);
+
+ if (user_id < 0 || package_id == NULL || privilege_list == NULL) {
PG_LOGE("Invalid parameters.");
return PRIV_GUARD_ERROR_INVALID_PARAMETER;
}
return PRIV_GUARD_ERROR_SUCCESS;
}
-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)
+int privacy_guard_client_foreach_package_info_by_privacy_id(const int user_id, const char *privacy_id, privacy_guard_client_package_info_cb callback, void *user_data)
{
if (user_id < 0 || privacy_id == NULL) {
PG_LOGE("Invalid parameters.");
PrivacyGuardClient* pInst = PrivacyGuardClient::getInstance();
- std::list < std::string > packageList;
+ std::list <package_data_s> packageInfoList;
- int retval = pInst->PgForeachPackageByPrivacyId(user_id, std::string(privacy_id), packageList);
+ int retval = pInst->PgForeachPackageInfoByPrivacyId(user_id, std::string(privacy_id), packageInfoList);
if (retval != PRIV_GUARD_ERROR_SUCCESS) {
- PG_LOGE("Failed to do PrivacyGuardClient::PgForeachPackageByPrivacyId(). [%d]", retval);
+ PG_LOGE("Failed to do PrivacyGuardClient::PgForeachPackageInfoByPrivacyId(). [%d]", retval);
return retval;
}
- if (packageList.size() == 0)
+ if (packageInfoList.size() == 0)
return PRIV_GUARD_ERROR_NO_DATA;
- for (std::list < std::string >::iterator iter = packageList.begin(); iter != packageList.end(); ++iter) {
- PG_LOGD("package_id: %s", iter->c_str());
- bool ret = callback(iter->c_str(), user_data);
+ for (std::list < package_data_s >::iterator iter = packageInfoList.begin(); iter != packageInfoList.end(); ++iter) {
+ bool ret = callback(iter->package_id, iter->count, iter->monitor_policy, user_data);
if (ret == false)
break;
}
#define PRIVACY_DB_PATH tzplatform_mkpath(TZ_SYS_DB,".privacy_guard.db")
typedef struct _privacy_data_s {
- char* privacy_id;
+ char *privacy_id;
int monitor_policy;
} privacy_data_s;
+typedef struct _package_data_s {
+ char *package_id;
+ int count;
+ int monitor_policy;
+} package_data_s;
+
+
static const std::string SERVER_ADDRESS ("/tmp/privacy_guard_server");
static const std::string DBUS_PATH("/privacy_guard/dbus_notification");
static const std::string DBUS_SIGNAL_INTERFACE("org.tizen.privacy_guard.signal");
return PRIV_GUARD_ERROR_SUCCESS;
}
+
+ int read(package_data_s& out)
+ {
+ int length = 0;
+ int res = 0;
+ char* pBuf;
+
+ // package id
+ res = m_socketStream.readStream(sizeof(length), &length);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "readStream : %d", res);
+ pBuf = new (std::nothrow) char[length + 1];
+ 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_GUARD_ERROR_SUCCESS, res, delete[] pBuf, "readStream : %d", res);
+ pBuf[length] = 0;
+ out.package_id = strdup(pBuf);
+ delete[] pBuf;
+
+ // monitor policy
+ res = read(&(out.monitor_policy));
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "readStream : %d", res);
+
+ // count
+ res = read(&(out.count));
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "readStream : %d", res);
+
+ return PRIV_GUARD_ERROR_SUCCESS;
+ }
+
template < typename T >
int read (std::list<T>& list)
{
return PRIV_GUARD_ERROR_SUCCESS;
}
+
+ int write(const package_data_s& in)
+ {
+ // package id
+ int length = strlen(in.package_id);
+ int res = 0;
+ res = m_socketStream.writeStream(sizeof(length), &length);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "writeStream : %d", res);
+ res = m_socketStream.writeStream(length, in.package_id);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "writeStream : %d", res);
+
+ // monitor policy
+ res = write(in.monitor_policy);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "write : %d", res);
+
+ // count
+ res = write(in.count);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "write : %d", res);
+
+ return PRIV_GUARD_ERROR_SUCCESS;
+ }
+
template<typename T, typename ...Args>
int write(const T* in, const Args&... args)
{
for (l = privacy_list; l != NULL; l = l->next) {
char *privacy_id = (char*)l->data;
- PG_LOGD("privacy_id: %s", privacy_id);
-
ret = privilege_info_get_privilege_list_by_privacy(privacy_id, &privilege_list);
if (ret != PRVMGR_ERR_NONE) {
PG_LOGE("Failed to get privilege list from security-privilege-manager [%d] using privacy[%s].", ret, privacy_id);
std::string privacyId;
int res = getPrivacyIdFromPrivilege(*iter, privacyId);
if (res == PRIV_GUARD_ERROR_SUCCESS) {
- PG_LOGD("Privacy[%s] from Privilege[%s]", privacyId.c_str(), iter->c_str());
+ PG_LOGD("Privacy ID [%s] from Privilege [%s]", privacyId.c_str(), iter->c_str());
privacyIdSet.insert(privacyId);
}
}
typedef bool (*privacy_guard_client_package_id_cb) (const char *package_id, void *user_data);
/**
+ * @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] count The privacy count
+ * @param[in] monitor_policy The monitor policy (0 or 1)
+ * @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
+ *
+ * @see privacy_guard_client_foreach_package_info_by_privacy_id()
+ */
+typedef bool (*privacy_guard_client_package_info_cb) (const char *package_id, const int count, const int monitor_policy, void *user_data);
+
+
+/**
* @brief Called when the reply of the privacy count request is delivered.
* @since tizen 3.0
*
/**
* @fn 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)
- * @brief get package using specified privacy
+ * @brief get package info (package_id, count, monitor_enable) using specified privacy
* @param[in] user_id The user ID
* @param[in] privacy_id The privacy ID
* @param[in] callback The callback function to invoke
* @param[in] user_data The user data to be passed to the callback function
*/
-EXTERN_API 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);
+EXTERN_API int privacy_guard_client_foreach_package_info_by_privacy_id(const int user_id, const char *privacy_id, privacy_guard_client_package_info_cb callback, void *user_data);
/**
* @fn int privacy_guard_client_update_main_monitor_policy(const int user_id, const bool main_monitor_policy)
BuildRequires: pkgconfig(capi-system-info)
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(security-privilege-manager)
-#BuildRequires: pkgconfig(cynara-monitor)
+BuildRequires: pkgconfig(cynara-monitor)
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
SET(INCLUDEDIR "\${prefix}/include")
INCLUDE(FindPkgConfig)
-#pkg_check_modules(pkgs REQUIRED dlog sqlite3 dbus-1 dbus-glib-1 db-util pkgmgr-info capi-system-info libtzplatform-config security-privilege-manager cynara-monitor)
-pkg_check_modules(pkgs REQUIRED dlog sqlite3 dbus-1 dbus-glib-1 db-util pkgmgr-info capi-system-info libtzplatform-config security-privilege-manager)
+pkg_check_modules(pkgs REQUIRED dlog sqlite3 dbus-1 dbus-glib-1 db-util pkgmgr-info capi-system-info libtzplatform-config security-privilege-manager cynara-monitor)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
int PgForeachPrivacyPackageId(const int userId, std::list < std::string > & packageList);
- int PgForeachPackageByPrivacyId(const int userId, const std::string privacyId, std::list < std::string > &packageList);
+ int PgForeachPackageInfoByPrivacyId(const int userId, const std::string privacyId, std::list < package_data_s > &packageList);
int PgUpdateMonitorPolicy(const int userId, const std::string packageId, const std::string privacyId, const int monitorPolicy);
pSocketService->registerServiceCallback(getInterfaceName(), std::string("PgForeachPrivacyCountByPrivacyId"), PgForeachPrivacyCountByPrivacyId);
pSocketService->registerServiceCallback(getInterfaceName(), std::string("PgForeachPrivacyCountByPackageId"), PgForeachPrivacyCountByPackageId);
pSocketService->registerServiceCallback(getInterfaceName(), std::string("PgForeachPrivacyPackageId"), PgForeachPrivacyPackageId);
- pSocketService->registerServiceCallback(getInterfaceName(), std::string("PgForeachPackageByPrivacyId"), PgForeachPackageByPrivacyId);
+ pSocketService->registerServiceCallback(getInterfaceName(), std::string("PgForeachPackageInfoByPrivacyId"), PgForeachPackageInfoByPrivacyId);
pSocketService->registerServiceCallback(getInterfaceName(), std::string("PgForeachMonitorPolicyByPackageId"), PgForeachMonitorPolicyByPackageId);
pSocketService->registerServiceCallback(getInterfaceName(), std::string("PgGetMonitorPolicy"), PgGetMonitorPolicy);
pSocketService->registerServiceCallback(getInterfaceName(), std::string("PgGetAllMonitorPolicy"), PgGetAllMonitorPolicy);
static void PgForeachPrivacyCountByPrivacyId(SocketConnection* pConnector);
static void PgForeachPrivacyCountByPackageId(SocketConnection* pConnector);
static void PgForeachPrivacyPackageId(SocketConnection* pConnector);
- static void PgForeachPackageByPrivacyId(SocketConnection* pConnector);
+ static void PgForeachPackageInfoByPrivacyId(SocketConnection* pConnector);
static void PgForeachMonitorPolicyByPackageId(SocketConnection* pConnector);
static void PgGetMonitorPolicy(SocketConnection* pConnector);
static void PgGetAllMonitorPolicy(SocketConnection* pConnector);
#include "PrivacyGuardDb.h"
#include "PrivacyIdInfo.h"
+#define PRIVACY_GUARD_DAYS 7
+#define UNIX_TIME_ONE_DAY (24 * 60 * 60) // 86400 secs
+
#if 0
// [CYNARA]
#include "CynaraService.h"
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) {
- PG_LOGD("PrivacyID : %s", iter->c_str());
+ PG_LOGD("User ID: [%d], Package ID: [%s], PrivacyID: [%s], Monitor Policy: [%d]", userId, packageId.c_str(), iter->c_str(), monitorPolicy);
// bind
res = sqlite3_bind_int(m_stmt, 1, userId);
continue;
}
const char* privacyId = (char*)l->data;
- PG_LOGD("[kylee] privacy ID: %s", privacyId);
privacyInfoList.push_back(std::pair <std::string, int> (std::string(privacyId), count));
}
sqlite3_reset(m_stmt);
}
m_dbMutex.unlock();
+ PG_LOGD("monitorPolicyList.size() is [%d]", monitorPolicyList.size());
if(monitorPolicyList.size() > 0) {
res = PRIV_GUARD_ERROR_SUCCESS;
}
}
int
-PrivacyGuardDb::PgForeachPackageByPrivacyId(const int userId, const std::string privacyId, std::list < std::string > &packageList)
+PrivacyGuardDb::PgForeachPackageInfoByPrivacyId(const int userId, const std::string privacyId, std::list < package_data_s > &packageInfoList)
{
int res = -1;
- static const std::string query = std::string("SELECT DISTINCT PKG_ID FROM MonitorPolicy WHERE USER_ID=? AND PRIVACY_ID=?");
+ static const std::string query = std::string("SELECT DISTINCT PKG_ID, MONITOR_POLICY FROM MonitorPolicy WHERE USER_ID=? AND PRIVACY_ID=?");
+ static const std::string PKGINFO_SELECT = std::string("SELECT COUNT(*) FROM StatisticsMonitorInfo WHERE USER_ID=? AND PKG_ID=? AND PRIVACY_ID=? AND USE_DATE>=? AND USE_DATE<=?");
+ sqlite3_stmt* infoStmt;
+ time_t start_date, today_midnight, end_date;
+ struct tm *date = NULL;
+
+ // get start~end date (for 7 days)
+ end_date = time(NULL);
+ date = localtime(&end_date);
+ PG_LOGD("current (end) time [%d]: %4d/%2d/%2d %2d:%2d", end_date, date->tm_year + 1900, date->tm_mon + 1, date->tm_mday, date->tm_hour, date->tm_min);
+ date->tm_hour = 0;
+ date->tm_min = 0;
+ date->tm_sec = 0;
+ today_midnight = mktime(date);
+ start_date = today_midnight - (UNIX_TIME_ONE_DAY * (PRIVACY_GUARD_DAYS - 1));
+ date = localtime(&start_date);
+ PG_LOGD("start time [%d]: %4d/%2d/%2d %2d:%2d", start_date, date->tm_year + 1900, date->tm_mon + 1, date->tm_mday, date->tm_hour, date->tm_min);
m_dbMutex.lock();
// step
while ((res = sqlite3_step(m_stmt)) == SQLITE_ROW) {
- char* p_data = (char*)sqlite3_column_text(m_stmt, 0);
- if(p_data == NULL) {
+ char* tmp_data = (char*)sqlite3_column_text(m_stmt, 0);
+ if(tmp_data == NULL) {
continue;
}
- packageList.push_back(std::string(p_data));
+ package_data_s p_data;
+ p_data.package_id = strdup(tmp_data);
+ p_data.monitor_policy = sqlite3_column_int(m_stmt, 1);
+ PG_LOGD("## package_id[%s]", p_data.package_id);
+ PG_LOGD("## monitor_policy[%d]", p_data.monitor_policy);
+
+ // prepare
+ res = sqlite3_prepare_v2(m_sqlHandler, PKGINFO_SELECT.c_str(), -1, &infoStmt, NULL);
+ 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_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+
+ res = sqlite3_bind_text(infoStmt, 2, p_data.package_id, -1, SQLITE_TRANSIENT);
+ 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_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
+
+ res = sqlite3_bind_int(infoStmt, 4, start_date);
+ TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
+
+ res = sqlite3_bind_int(infoStmt, 5, end_date);
+ 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);
+ PG_LOGD("## count[%d]", count);
+// if (count == 0)
+// continue;
+ p_data.count = count;
+ packageInfoList.push_back(p_data);
+ }
+ sqlite3_reset(infoStmt);
}
+
m_dbMutex.unlock();
return PRIV_GUARD_ERROR_SUCCESS;
}
void
-PrivacyInfoService::PgForeachPackageByPrivacyId(SocketConnection* pConnector)
+PrivacyInfoService::PgForeachPackageInfoByPrivacyId(SocketConnection* pConnector)
{
int userId = 0;
std::string privacyId;
- std::list < std::string > packageList;
+ std::list < package_data_s > packageInfoList;
pConnector->read(&userId, &privacyId);
- int result = PrivacyGuardDb::getInstance()->PgForeachPackageByPrivacyId(userId, privacyId, packageList);
+ int result = PrivacyGuardDb::getInstance()->PgForeachPackageInfoByPrivacyId(userId, privacyId, packageInfoList);
pConnector->write(result);
- pConnector->write(packageList);
+ pConnector->write(packageInfoList);
}
void