[History] Add apphistory feature to Context History API && version 1.0.5 24/145524/2
authorSomin Kim <somin926.kim@samsung.com>
Tue, 22 Aug 2017 14:28:50 +0000 (23:28 +0900)
committerSomin Kim <somin926.kim@samsung.com>
Tue, 22 Aug 2017 14:29:35 +0000 (23:29 +0900)
Change-Id: Ic0a8bbf45f10b95bb16f81f90c401b1573203ed7
Signed-off-by: Somin Kim <somin926.kim@samsung.com>
CMakeLists.txt
doc/context_history_doc.h
include/context_history.h
packaging/capi-context.spec
src/history/context_history.cpp

index 97e5d3f..4468749 100644 (file)
@@ -6,7 +6,7 @@ INCLUDE(GNUInstallDirs)
 SET(target ${PROJECT_NAME})
 
 # Dependencies
-SET(DEPS "gio-2.0 jsoncpp bundle aul pkgmgr-info capi-base-common capi-appfw-app-control")
+SET(DEPS "gio-2.0 jsoncpp bundle aul pkgmgr-info capi-base-common capi-appfw-app-control capi-system-info")
 SET(DEPS "${DEPS} cynara-creds-self cynara-session cynara-client")
 SET(DEPS "${DEPS} context-app-history-client context-job-scheduler-client")
 
index c8f9095..3691377 100644 (file)
@@ -36,8 +36,9 @@
  *
  *
  * @section CAPI_CONTEXT_HISTORY_MODULE_FEATURE Related Features
- *
- * Some of the statistic items in this API are related with one of the following features:@n
+ * This API is related with the following features:@n
+ * - http://tizen.org/feature/apphistory
+ * And some of the statistic items in this API are related with one of the following features:@n
  * - http://tizen.org/feature/battery
  *
  * It is recommended to design feature related code in your application for reliability.@n
index 9d82c2a..4a00f89 100644 (file)
@@ -229,6 +229,7 @@ typedef struct _context_history_record_handle_s* context_history_record_h;
  * @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
  * @retval             #CONTEXT_HISTORY_ERROR_OUT_OF_MEMORY            Out of memory
  *
  * @see context_history_destroy()
@@ -245,6 +246,7 @@ int context_history_create(context_history_h* handle);
  *
  * @return             @c 0 on success, otherwise a negative error value
  * @retval             #CONTEXT_HISTORY_ERROR_NONE                                     Successful
+ * @retval             #CONTEXT_HISTORY_ERROR_NOT_SUPPORTED            Not supported
  * @retval             #CONTEXT_HISTORY_ERROR_INVALID_PARAMETER        Invalid parameter
  *
  * @pre        context_history_create()
@@ -261,6 +263,7 @@ int context_history_destroy(context_history_h handle);
  * @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
  * @retval             #CONTEXT_HISTORY_ERROR_OUT_OF_MEMORY            Memory allocation failed
  *
  * @see                context_history_filter_destroy()
@@ -277,6 +280,7 @@ int context_history_filter_create(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
  *
  * @pre                context_history_filter_create()
  */
@@ -294,6 +298,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
  *
  * @pre                context_history_filter_create()
  * @see                context_history_filter_set_string()
@@ -313,6 +318,7 @@ 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
  *
  * @pre                context_history_filter_create()
  * @see                context_history_filter_set_int()
@@ -329,6 +335,7 @@ int context_history_filter_set_string(context_history_filter_h filter, context_h
  * @return             @c 0 on success, otherwise a negative error value
  * @retval             #CONTEXT_TRIGGER_ERROR_NONE                                     Successful
  * @retval             #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER        Invalid parameter
+ * @retval             #CONTEXT_HISTORY_ERROR_NOT_SUPPORTED            Not supported
  * @retval             #CONTEXT_TRIGGER_ERROR_OPERATION_FAILED         Operation failed
  */
 int context_history_is_supported(context_history_data_e data_type, bool* supported);
@@ -353,7 +360,7 @@ int context_history_is_supported(context_history_data_e data_type, bool* support
  * @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
+ * @retval             #CONTEXT_HISTORY_ERROR_NOT_SUPPORTED            Not supported
  * @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
@@ -373,6 +380,7 @@ int context_history_get_list(context_history_h handle, context_history_data_e da
  * @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
  * @retval             #CONTEXT_HISTORY_ERROR_OPERATION_FAILED         Operation failed
  *
  * @pre context_history_get_list()
@@ -393,6 +401,7 @@ int context_history_list_get_count(context_history_list_h list, int* count);
  * @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
  * @retval             #CONTEXT_HISTORY_ERROR_OPERATION_FAILED         Operation failed
  * @retval             #CONTEXT_HISTORY_ERROR_OUT_OF_MEMORY            Out of memory
  *
@@ -410,6 +419,7 @@ int context_history_list_get_current(context_history_list_h list, context_histor
  * @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
  *
  * @pre context_history_get_list()
  * @see context_history_list_get_count()
@@ -426,6 +436,7 @@ int context_history_list_move_first(context_history_list_h list);
  * @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
  * @retval             #CONTEXT_HISTORY_ERROR_NO_DATA                          Requested data does not exist
  *
  * @pre context_history_get_list()
@@ -443,6 +454,7 @@ int context_history_list_move_next(context_history_list_h list);
  * @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
  *
  * @pre context_history_get_list()
  */
@@ -461,6 +473,7 @@ int context_history_list_destroy(context_history_list_h list);
  * @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
  *
  * @pre                context_history_list_get_current()
  * @see                context_history_record_get_double()
@@ -482,6 +495,7 @@ int context_history_record_get_int(context_history_record_h record, const char*
  * @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
  *
  * @pre                context_history_list_get_current()
  * @see                context_history_record_get_int()
@@ -502,6 +516,7 @@ int context_history_record_get_string(context_history_record_h record, const cha
  * @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
  *
  * @pre                context_history_list_get_current()
  * @see                context_history_record_get_int()
@@ -518,6 +533,7 @@ int context_history_record_get_double(context_history_record_h record, const cha
  * @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
  *
  * @pre                context_history_list_get_current()
  */
index 1f04395..a8cea5e 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-context
 Summary:    Tizen Context Framework Native API
-Version:    1.0.4
+Version:    1.0.5
 Release:    1
 Group:      Service Framework/Context
 License:    Apache-2.0
@@ -14,6 +14,7 @@ BuildRequires: pkgconfig(aul)
 BuildRequires: pkgconfig(pkgmgr-info)
 BuildRequires: pkgconfig(capi-base-common)
 BuildRequires: pkgconfig(capi-appfw-app-control)
+BuildRequires: pkgconfig(capi-system-info)
 BuildRequires: pkgconfig(cynara-creds-self)
 BuildRequires: pkgconfig(cynara-session)
 BuildRequires: pkgconfig(cynara-client)
index 3770d2f..01a1e6c 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <map>
 #include <json/json.h>
+#include <system_info.h>
 #include <ContextTypes.h>
 #include <Tuple.h>
 #include <app_history_internal.h>
 #define ASSERT_ALLOC(X)                IF_FAIL_RETURN_TAG(X, E_NO_MEM, _E, "Memory allocation failed")
 #define ASSERT_NOT_NULL(X)     IF_FAIL_RETURN_TAG(X, E_PARAM, _E, "Parameter null")
 
+#define APP_HISTORY_FEATURE "http://tizen.org/feature/apphistory"
+#define CHECK_APP_HISTORY_SUPPORTED(feature_name) \
+       do { \
+               bool is_supported = false; \
+               if (!system_info_get_platform_bool(feature_name, &is_supported)) { \
+                       if (!is_supported) { \
+                               _E("[%s] feature is disabled", feature_name); \
+                               return CONTEXT_HISTORY_ERROR_NOT_SUPPORTED; \
+                       } \
+               } \
+       } while(0)
+
 // handles
 typedef struct _context_history_handle_s {
        /* At this point, this handle has no purpose.
@@ -70,6 +83,7 @@ static bool history_filter_is_deprecated(context_history_filter_e filter_type);
 // life-cycle
 EXPORT_API int context_history_create(context_history_h* handle)
 {
+       CHECK_APP_HISTORY_SUPPORTED(APP_HISTORY_FEATURE);
        ASSERT_NOT_NULL(handle);
 
        *handle = new(std::nothrow) _cx_history_handle();
@@ -80,6 +94,7 @@ EXPORT_API int context_history_create(context_history_h* handle)
 
 EXPORT_API int context_history_destroy(context_history_h handle)
 {
+       CHECK_APP_HISTORY_SUPPORTED(APP_HISTORY_FEATURE);
        ASSERT_NOT_NULL(handle);
        delete handle;
        return CONTEXT_HISTORY_ERROR_NONE;
@@ -88,6 +103,7 @@ EXPORT_API int context_history_destroy(context_history_h handle)
 // Read filter manipulation
 EXPORT_API int context_history_filter_create(context_history_filter_h* filter)
 {
+       CHECK_APP_HISTORY_SUPPORTED(APP_HISTORY_FEATURE);
        ASSERT_NOT_NULL(filter);
 
        *filter = new(std::nothrow) _cx_history_filter_handle();
@@ -98,6 +114,7 @@ EXPORT_API int context_history_filter_create(context_history_filter_h* filter)
 
 EXPORT_API int context_history_filter_destroy(context_history_filter_h filter)
 {
+       CHECK_APP_HISTORY_SUPPORTED(APP_HISTORY_FEATURE);
        ASSERT_NOT_NULL(filter);
        delete filter;
 
@@ -106,6 +123,7 @@ EXPORT_API int context_history_filter_destroy(context_history_filter_h filter)
 
 EXPORT_API int context_history_filter_set_int(context_history_filter_h filter, context_history_filter_e filter_type, int val)
 {
+       CHECK_APP_HISTORY_SUPPORTED(APP_HISTORY_FEATURE);
        ASSERT_NOT_NULL(filter);
 
        if (history_filter_is_deprecated(filter_type)) {
@@ -127,6 +145,7 @@ EXPORT_API int context_history_filter_set_int(context_history_filter_h filter, c
 
 EXPORT_API int context_history_filter_set_string(context_history_filter_h filter, context_history_filter_e filter_type, const char* val)
 {
+       CHECK_APP_HISTORY_SUPPORTED(APP_HISTORY_FEATURE);
        ASSERT_NOT_NULL(filter);
        ASSERT_NOT_NULL(val);
 
@@ -150,6 +169,7 @@ EXPORT_API int context_history_filter_set_string(context_history_filter_h filter
 
 EXPORT_API int context_history_is_supported(context_history_data_e data_type, bool* supported)
 {
+       CHECK_APP_HISTORY_SUPPORTED(APP_HISTORY_FEATURE);
        ASSERT_NOT_NULL(supported);
 
        if (history_is_deprecated(data_type)) {
@@ -166,6 +186,7 @@ EXPORT_API int context_history_is_supported(context_history_data_e data_type, bo
 
 EXPORT_API int context_history_get_list(context_history_h handle, context_history_data_e data_type, context_history_filter_h filter, context_history_list_h* list)
 {
+       CHECK_APP_HISTORY_SUPPORTED(APP_HISTORY_FEATURE);
        ASSERT_NOT_NULL(handle);
        ASSERT_NOT_NULL(list);
        *list = NULL;
@@ -203,6 +224,7 @@ EXPORT_API int context_history_get_list(context_history_h handle, context_histor
 // Data object manipulation
 EXPORT_API int context_history_list_get_count(context_history_list_h list, int* count)
 {
+       CHECK_APP_HISTORY_SUPPORTED(APP_HISTORY_FEATURE);
        ASSERT_NOT_NULL(list && count);
 
        unsigned int value;
@@ -216,6 +238,7 @@ EXPORT_API int context_history_list_get_count(context_history_list_h list, int*
 
 EXPORT_API int context_history_list_get_current(context_history_list_h list, context_history_record_h* record)
 {
+       CHECK_APP_HISTORY_SUPPORTED(APP_HISTORY_FEATURE);
        ASSERT_NOT_NULL(list);
        ASSERT_NOT_NULL(record);
        *record = NULL;
@@ -235,18 +258,21 @@ EXPORT_API int context_history_list_get_current(context_history_list_h list, con
 
 EXPORT_API int context_history_list_move_first(context_history_list_h list)
 {
+       CHECK_APP_HISTORY_SUPPORTED(APP_HISTORY_FEATURE);
        ASSERT_NOT_NULL(list);
        return ctx_history_cursor_first(list->cursor);
 }
 
 EXPORT_API int context_history_list_move_next(context_history_list_h list)
 {
+       CHECK_APP_HISTORY_SUPPORTED(APP_HISTORY_FEATURE);
        ASSERT_NOT_NULL(list);
        return ctx_history_cursor_next(list->cursor);
 }
 
 EXPORT_API int context_history_list_destroy(context_history_list_h list)
 {
+       CHECK_APP_HISTORY_SUPPORTED(APP_HISTORY_FEATURE);
        ASSERT_NOT_NULL(list);
        ctx_history_cursor_destroy(list->cursor);
        delete list;
@@ -256,6 +282,7 @@ EXPORT_API int context_history_list_destroy(context_history_list_h list)
 
 EXPORT_API int context_history_record_get_int(context_history_record_h record, const char* key, int* val)
 {
+       CHECK_APP_HISTORY_SUPPORTED(APP_HISTORY_FEATURE);
        ASSERT_NOT_NULL(record && val && key);
 
        // Check key and data type
@@ -274,6 +301,7 @@ EXPORT_API int context_history_record_get_int(context_history_record_h record, c
 
 EXPORT_API int context_history_record_get_double(context_history_record_h record, const char* key, double* val)
 {
+       CHECK_APP_HISTORY_SUPPORTED(APP_HISTORY_FEATURE);
        ASSERT_NOT_NULL(record && val && key);
 
        // Check key and data type
@@ -289,6 +317,7 @@ EXPORT_API int context_history_record_get_double(context_history_record_h record
 
 EXPORT_API int context_history_record_get_string(context_history_record_h record, const char* key, char** val)
 {
+       CHECK_APP_HISTORY_SUPPORTED(APP_HISTORY_FEATURE);
        ASSERT_NOT_NULL(record && val && key);
 
        // Check key and data type
@@ -308,6 +337,7 @@ EXPORT_API int context_history_record_get_string(context_history_record_h record
 
 EXPORT_API int context_history_record_destroy(context_history_record_h record)
 {
+       CHECK_APP_HISTORY_SUPPORTED(APP_HISTORY_FEATURE);
        ASSERT_NOT_NULL(record);
        delete record;