modify API to get the latest access time 65/96265/2
authorSEUNGTAEK HAN <s.t.han@samsung.com>
Tue, 8 Nov 2016 09:51:26 +0000 (18:51 +0900)
committerSEUNGTAEK HAN <s.t.han@samsung.com>
Tue, 8 Nov 2016 09:54:56 +0000 (18:54 +0900)
Change-Id: I7253a974ecfd9b8d29c2ff8bb5ef740916f7c4db

client/src/privacy_guard_client.cpp [changed mode: 0644->0755]
common/inc/PrivacyGuardTypes.h [changed mode: 0644->0755]
include/privacy_guard_client.h
server/src/PrivacyGuardDb.cpp [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 734ac43..639c560
@@ -379,7 +379,7 @@ int privacy_guard_client_foreach_package_info_by_privacy_id(const int user_id, c
        }
 
        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);
+               bool ret = callback(iter->package_id, iter->count, iter->time, iter->monitor_policy, user_data);
                if (ret == false)
                        break;
        }
old mode 100644 (file)
new mode 100755 (executable)
index b7a6cec..0483cae
@@ -38,6 +38,7 @@ typedef struct _privacy_data_s {
 typedef struct _package_data_s {
        char *package_id;
        int count;
+       time_t time;
        int monitor_policy;
 } package_data_s;
 
index be7c74f..55c6ec9 100755 (executable)
@@ -62,6 +62,7 @@ typedef bool (*privacy_guard_client_package_id_cb) (const char *package_id, void
  *
  * @param[in] package_id               The package ID
  * @param[in] count                            The privacy count
+ * @param[in] time                     The latest access time
  * @param[in] monitor_policy   The monitor policy (0 or 1)
  * @param[in] user_data        The user data passed from the callback registration function
  *
@@ -69,7 +70,7 @@ typedef bool (*privacy_guard_client_package_id_cb) (const char *package_id, void
  *
  * @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);
+typedef bool (*privacy_guard_client_package_info_cb) (const char *package_id, const int count, const time_t time, const int monitor_policy, void *user_data);
 
 
 /**
old mode 100644 (file)
new mode 100755 (executable)
index 0fcdc79..3d07b76
@@ -898,7 +898,7 @@ PrivacyGuardDb::PgForeachPackageInfoByPrivacyId(const int userId, const std::str
        snprintf(buf, BUF_SIZE, "SELECT DISTINCT PKG_ID, MONITOR_POLICY FROM MonitorPolicy WHERE (USER_ID=? OR USER_ID=%d) AND PRIVACY_ID=?", GLOBAL_USER);
        static const std::string query = std::string(buf);
 
-       snprintf(buf, BUF_SIZE, "SELECT COUNT(*) FROM StatisticsMonitorInfo WHERE (USER_ID=? OR USER_ID=%d) AND PKG_ID=? AND PRIVACY_ID=? AND USE_DATE>=? AND USE_DATE<=?", GLOBAL_USER);
+       snprintf(buf, BUF_SIZE, "SELECT COUNT(*), MAX(USE_DATE) FROM StatisticsMonitorInfo WHERE (USER_ID=? OR USER_ID=%d) AND PKG_ID=? AND PRIVACY_ID=? AND USE_DATE>=? AND USE_DATE<=?", GLOBAL_USER);
        static const std::string PKGINFO_SELECT = std::string(buf);
 
        // get start~end date (for 7 days)
@@ -985,6 +985,11 @@ PrivacyGuardDb::PgForeachPackageInfoByPrivacyId(const int userId, const std::str
 //                     if (count == 0)
 //                             continue;
                        p_data.count = count;
+
+                       time_t time = sqlite3_column_int(infoStmt, 1);
+                       PG_LOGD("## time[%d]", time);
+                       p_data.time = time;
+
                        packageInfoList.push_back(p_data);
                }