[History] Deprecate several history data & added NOT_SUPPORTED error code 07/125207/9
authorSomin Kim <somin926.kim@samsung.com>
Fri, 14 Apr 2017 06:34:54 +0000 (15:34 +0900)
committerSomin Kim <somin926.kim@samsung.com>
Tue, 18 Apr 2017 12:17:41 +0000 (21:17 +0900)
Change-Id: I755670a69acf0c834f1b2416f97fddfffe0a125d
Signed-off-by: Somin Kim <somin926.kim@samsung.com>
include/context_history.h
src/context_history.cpp

index 0c578ba..751c3e1 100644 (file)
@@ -18,7 +18,7 @@
 #define __TIZEN_CONTEXT_HISTORY_H__
 
 
-#include <tizen_error.h>
+#include <tizen.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -65,6 +65,7 @@ extern "C" {
 #define CONTEXT_HISTORY_LAST_TIME "LastTime"
 
 /**
+ * @deprecated Deprecated since 4.0.
  * @brief      Definition for the attribute key denoting "hour of day".
  * @details    This can be used as a key of context_history_record_get_int().
  * @since_tizen 2.4
@@ -72,6 +73,7 @@ extern "C" {
 #define CONTEXT_HISTORY_HOUR_OF_DAY "HourOfDay"
 
 /**
+ * @deprecated Deprecated since 4.0.
  * @brief      Definition for the attribute key denoting "audio jack status".
  * @details    This can be used as a key of context_history_record_get_int().
  * @since_tizen 2.4
@@ -79,6 +81,7 @@ extern "C" {
 #define CONTEXT_HISTORY_AUDIO_JACK "AudioJack"
 
 /**
+ * @deprecated Deprecated since 4.0.
  * @brief      Definition for the attribute key denoting "system volume".
  * @details    This can be used as a key of context_history_record_get_int().
  * @since_tizen 2.4
@@ -86,6 +89,7 @@ extern "C" {
 #define CONTEXT_HISTORY_SYSTEM_VOLUME "SystemVolume"
 
 /**
+ * @deprecated Deprecated since 4.0.
  * @brief      Definition for the attribute key denoting "media volume".
  * @details    This can be used as a key of context_history_record_get_int().
  * @since_tizen 2.4
@@ -93,6 +97,7 @@ extern "C" {
 #define CONTEXT_HISTORY_MEDIA_VOLUME "MediaVolume"
 
 /**
+ * @deprecated Deprecated since 4.0.
  * @brief      Definition for the attribute key denoting "address".
  * @details    This can be used as a key of context_history_record_get_string().
  * @since_tizen 2.4
@@ -121,14 +126,14 @@ typedef enum {
 typedef enum {
        CONTEXT_HISTORY_RECENTLY_USED_APP = 1,  /**< Recently used application.@n Privilege : http://tizen.org/privilege/apphistory.read*/
        CONTEXT_HISTORY_FREQUENTLY_USED_APP,    /**< Frequently used application.@n Privilege : http://tizen.org/privilege/apphistory.read*/
-       CONTEXT_HISTORY_RARELY_USED_APP,                /**< Rarely used application.@n Privilege : http://tizen.org/privilege/apphistory.read*/
-       CONTEXT_HISTORY_PEAK_TIME_FOR_APP,              /**< Peak time of application use activity.@n Privilege : http://tizen.org/privilege/apphistory.read*/
-       CONTEXT_HISTORY_PEAK_TIME_FOR_MUSIC,            /**< Peak time of music listening activity.@n Privilege : http://tizen.org/privilege/mediahistory.read*/
-       CONTEXT_HISTORY_PEAK_TIME_FOR_VIDEO,            /**< Peak time of video watching activity.@n Privilege : http://tizen.org/privilege/mediahistory.read*/
-       CONTEXT_HISTORY_COMMON_SETTING_FOR_APP,         /**< Common setting value of application use activity.@n Privilege : http://tizen.org/privilege/apphistory.read*/
-       CONTEXT_HISTORY_COMMON_SETTING_FOR_MUSIC,               /**< Common setting value of music listening activity.@n Privilege : http://tizen.org/privilege/mediahistory.read*/
-       CONTEXT_HISTORY_COMMON_SETTING_FOR_VIDEO,               /**< Common setting value of video watching activity.@n Privilege : http://tizen.org/privilege/mediahistory.read*/
-       CONTEXT_HISTORY_FREQUENTLY_COMMUNICATED_ADDRESS,                /**< Frequently communicated address.@n Privilege : http://tizen.org/privilege/callhistory.read*/
+       CONTEXT_HISTORY_RARELY_USED_APP,                /**< Rarely used application.@n Privilege : http://tizen.org/privilege/apphistory.read (Deprecated since 4.0)*/
+       CONTEXT_HISTORY_PEAK_TIME_FOR_APP,              /**< Peak time of application use activity.@n Privilege : http://tizen.org/privilege/apphistory.read (Deprecated since 4.0)*/
+       CONTEXT_HISTORY_PEAK_TIME_FOR_MUSIC,            /**< Peak time of music listening activity.@n Privilege : http://tizen.org/privilege/mediahistory.read (Deprecated since 4.0)*/
+       CONTEXT_HISTORY_PEAK_TIME_FOR_VIDEO,            /**< Peak time of video watching activity.@n Privilege : http://tizen.org/privilege/mediahistory.read (Deprecated since 4.0)*/
+       CONTEXT_HISTORY_COMMON_SETTING_FOR_APP,         /**< Common setting value of application use activity.@n Privilege : http://tizen.org/privilege/apphistory.read (Deprecated since 4.0)*/
+       CONTEXT_HISTORY_COMMON_SETTING_FOR_MUSIC,               /**< Common setting value of music listening activity.@n Privilege : http://tizen.org/privilege/mediahistory.read (Deprecated since 4.0)*/
+       CONTEXT_HISTORY_COMMON_SETTING_FOR_VIDEO,               /**< Common setting value of video watching activity.@n Privilege : http://tizen.org/privilege/mediahistory.read (Deprecated since 4.0)*/
+       CONTEXT_HISTORY_FREQUENTLY_COMMUNICATED_ADDRESS,                /**< Frequently communicated address.@n Privilege : http://tizen.org/privilege/callhistory.read (Deprecated since 4.0)*/
        CONTEXT_HISTORY_BATTERY_USAGE,          /**< Per-app battery usage in percentage (Since 3.0) @n Privilege : http://tizen.org/privilege/apphistory.read*/
        CONTEXT_HISTORY_RECENT_BATTERY_USAGE,           /**< Per-app battery usage in percentage since last charge (Since 3.0) @n Privilege : http://tizen.org/privilege/apphistory.read*/
 } context_history_data_e;
@@ -140,16 +145,17 @@ typedef enum {
 typedef enum {
        CONTEXT_HISTORY_FILTER_TIME_SPAN = 1,           /**< Time span of data in days*/
        CONTEXT_HISTORY_FILTER_RESULT_SIZE,                     /**< Result size of data records*/
-       CONTEXT_HISTORY_FILTER_APP_ID,                  /**< Application id*/
-       CONTEXT_HISTORY_FILTER_DAY_OF_WEEK,                     /**<  Weekdays, weekends*/
+       CONTEXT_HISTORY_FILTER_APP_ID,                  /**< Application id (Deprecated since 4.0)*/
+       CONTEXT_HISTORY_FILTER_DAY_OF_WEEK,                     /**< Weekdays, weekends (Deprecated since 4.0)*/
        CONTEXT_HISTORY_FILTER_START_TIME,                      /**< Start time of data in epoch time*/
        CONTEXT_HISTORY_FILTER_END_TIME,                        /**< End time of data in epoch time*/
-       CONTEXT_HISTORY_FILTER_WIFI_BSSID,                      /**< Wi-Fi BSSID value*/
+       CONTEXT_HISTORY_FILTER_WIFI_BSSID,                      /**< Wi-Fi BSSID value (Deprecated since 4.0)*/
        CONTEXT_HISTORY_FILTER_AUDIO_JACK,                      /**< Audio jack status value*/
-       CONTEXT_HISTORY_FILTER_COMMUNICATION_TYPE                       /**< Type of phone log*/
+       CONTEXT_HISTORY_FILTER_COMMUNICATION_TYPE                       /**< Type of phone log (Deprecated since 4.0)*/
 } context_history_filter_e;
 
 /**
+ * @deprecated Deprecated since 4.0.
  * @brief              Enumeration for day of week filter.
  * @since_tizen 2.4
  */
@@ -169,6 +175,7 @@ typedef enum {
 } context_history_filter_audio_jack_e;
 
 /**
+ * @deprecated Deprecated since 4.0.
  * @brief              Enumeration for log type filter.
  * @since_tizen 2.4
  */
@@ -277,6 +284,7 @@ int context_history_filter_destroy(context_history_filter_h filter);
  * @return             @c 0 on success, otherwise a negative error value
  * @retval             #CONTEXT_HISTORY_ERROR_NONE                                     Successful
  * @retval             #CONTEXT_HISTORY_ERROR_INVALID_PARAMETER        Invalid parameter
+ * @retval             #CONTEXT_HISTORY_ERROR_NOT_SUPPORTED            Not supported filter type contained
  *
  * @pre                context_history_filter_create()
  * @see                context_history_filter_set_string()
@@ -284,6 +292,7 @@ int context_history_filter_destroy(context_history_filter_h filter);
 int context_history_filter_set_int(context_history_filter_h filter, context_history_filter_e filter_type, int value);
 
 /**
+ * @deprecated Deprecate since 4.0.
  * @brief              Sets a string to a filter.
  * @details            This sets the value to a filter.
  * @since_tizen 2.4
@@ -295,11 +304,12 @@ int context_history_filter_set_int(context_history_filter_h filter, context_hist
  * @return             @c 0 on success, otherwise a negative error value
  * @retval             #CONTEXT_HISTORY_ERROR_NONE                                     Successful
  * @retval             #CONTEXT_HISTORY_ERROR_INVALID_PARAMETER        Invalid parameter
+ * @retval             #CONTEXT_HISTORY_ERROR_NOT_SUPPORTED            Not supported filter type contained
  *
  * @pre                context_history_filter_create()
  * @see                context_history_filter_set_int()
   */
-int context_history_filter_set_string(context_history_filter_h filter, context_history_filter_e filter_type, const char* value);
+int context_history_filter_set_string(context_history_filter_h filter, context_history_filter_e filter_type, const char* value) TIZEN_DEPRECATED_API;
 
 /**
  * @brief              Reads context statistics or patterns.
@@ -321,6 +331,7 @@ int context_history_filter_set_string(context_history_filter_h filter, context_h
  * @retval             #CONTEXT_HISTORY_ERROR_NONE                                     Successful
  * @retval             #CONTEXT_HISTORY_ERROR_INVALID_PARAMETER                Invalid parameter
  * @retval             #CONTEXT_HISTORY_ERROR_PERMISSION_DENIED                Permission denied
+ * @retval             #CONTEXT_HISTORY_ERROR_NOT_SUPPORTED            Unsupported history data contained
  * @retval             #CONTEXT_HISTORY_ERROR_OPERATION_FAILED         Operation failed
  * @retval             #CONTEXT_HISTORY_ERROR_OUT_OF_MEMORY                    Out of memory
  * @retval             #CONTEXT_HISTORY_ERROR_NO_DATA                  Requested data does not exist
index 74e17d7..e87a15d 100644 (file)
@@ -23,6 +23,7 @@
 #include <AppHistoryTypes.h>
 #include <context_history.h>
 
+#define HISTORY_DEPRECATED_DATA "DEPRECATION WARNING: This history data type is deprecated and will be removed from next release"
 #define TYPE_NUMERIC 0
 #define TYPE_STRING 1
 #define FILTER_KEY_LIMIT 10
@@ -62,6 +63,8 @@ static bool check_filter_data_int(context_history_filter_e filter_type, int val)
 static bool check_filter_data_string(context_history_filter_e filter_type, const char* val);
 static bool check_invalid_filter(context_history_data_e data_type, context_history_filter_h filter);
 static int __getIndexOf(context_history_record_h record, const std::string& key);
+static bool history_is_deprecated(context_history_data_e data_type);
+static bool history_filter_is_supported(context_history_filter_e filter_type);
 
 // life-cycle
 EXPORT_API int context_history_create(context_history_h* handle)
@@ -104,6 +107,8 @@ EXPORT_API int context_history_filter_set_int(context_history_filter_h filter, c
 {
        ASSERT_NOT_NULL(filter);
 
+       IF_FAIL_RETURN_TAG(history_filter_is_supported(filter_type), CONTEXT_HISTORY_ERROR_NOT_SUPPORTED, _E, "Filter not supported");
+
        std::string filter_str = convert_filter_to_string(filter_type);
        if (filter_str.empty()) {
                return CONTEXT_HISTORY_ERROR_INVALID_PARAMETER;
@@ -122,6 +127,10 @@ EXPORT_API int context_history_filter_set_string(context_history_filter_h filter
        ASSERT_NOT_NULL(filter);
        ASSERT_NOT_NULL(val);
 
+       _W("DEPRECATION WARNING: context_history_filter_set_string() is deprecated and will be removed from next release.");
+
+       IF_FAIL_RETURN_TAG(history_filter_is_supported(filter_type), CONTEXT_HISTORY_ERROR_NOT_SUPPORTED, _E, "Filter not supported");
+
        std::string filter_str = convert_filter_to_string(filter_type);
        if (filter_str.empty()) {
                return CONTEXT_HISTORY_ERROR_INVALID_PARAMETER;
@@ -141,6 +150,9 @@ EXPORT_API int context_history_get_list(context_history_h handle, context_histor
        ASSERT_NOT_NULL(list);
        *list = NULL;
 
+       if (history_is_deprecated(data_type)) {
+               _W(HISTORY_DEPRECATED_DATA);
+       }
        /*TODO: Boundary check for filter values has to be done*/
 
        std::string data_type_str = convert_data_to_string(data_type);
@@ -156,8 +168,6 @@ EXPORT_API int context_history_get_list(context_history_h handle, context_histor
        ASSERT_ALLOC(*list);
 
        int err = _ctx_history_query(data_type_str.c_str(), filter ? filter->jfilter.str().c_str() : "", &((*list)->cursor));
-       if (err == TIZEN_ERROR_NOT_SUPPORTED)
-               err = CONTEXT_HISTORY_ERROR_NO_DATA;
        IF_FAIL_RETURN_TAG(err == E_NONE, err, _E, "Query failed");
 
        return CONTEXT_HISTORY_ERROR_NONE;
@@ -532,3 +542,46 @@ int __getIndexOf(context_history_record_h record, const std::string& key)
        }
        return -1;
 }
+
+bool history_is_deprecated(context_history_data_e data_type)
+{
+       bool ret = false;
+       switch (data_type) {
+       case CONTEXT_HISTORY_RARELY_USED_APP:
+       case CONTEXT_HISTORY_PEAK_TIME_FOR_APP:
+       case CONTEXT_HISTORY_PEAK_TIME_FOR_MUSIC:
+       case CONTEXT_HISTORY_PEAK_TIME_FOR_VIDEO:
+       case CONTEXT_HISTORY_COMMON_SETTING_FOR_APP:
+       case CONTEXT_HISTORY_COMMON_SETTING_FOR_MUSIC:
+       case CONTEXT_HISTORY_COMMON_SETTING_FOR_VIDEO:
+       case CONTEXT_HISTORY_FREQUENTLY_COMMUNICATED_ADDRESS:
+               ret = true;
+               break;
+       default:
+               break;
+       }
+       return ret;
+}
+
+bool history_filter_is_supported(context_history_filter_e filter_type)
+{
+       bool ret = false;
+       switch (filter_type) {
+       case CONTEXT_HISTORY_FILTER_TIME_SPAN:
+       case CONTEXT_HISTORY_FILTER_RESULT_SIZE:
+       case CONTEXT_HISTORY_FILTER_START_TIME:
+       case CONTEXT_HISTORY_FILTER_END_TIME:
+       case CONTEXT_HISTORY_FILTER_AUDIO_JACK:
+               ret = true;
+               break;
+       case CONTEXT_HISTORY_FILTER_APP_ID:
+       case CONTEXT_HISTORY_FILTER_DAY_OF_WEEK:
+       case CONTEXT_HISTORY_FILTER_WIFI_BSSID:
+       case CONTEXT_HISTORY_FILTER_COMMUNICATION_TYPE:
+               break;
+       default:
+               break;
+       }
+
+       return ret;
+}