From: Somin Kim Date: Mon, 4 Sep 2017 12:21:51 +0000 (+0900) Subject: [Trigger] Add contextual_trigger feature to Context Trigger API X-Git-Tag: accepted/tizen/unified/20170920.065410~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F44%2F150144%2F1;p=platform%2Fcore%2Fapi%2Fcontext.git [Trigger] Add contextual_trigger feature to Context Trigger API Change-Id: Ib3c243a0ef24f0d153d19b5509b49ff70598a8f6 Signed-off-by: Somin Kim (cherry picked from commit 805115e2b6224ec279a51939817349ad6d501551) --- diff --git a/doc/context_trigger_doc.h b/doc/context_trigger_doc.h index 457a951..caa4734 100644 --- a/doc/context_trigger_doc.h +++ b/doc/context_trigger_doc.h @@ -63,11 +63,19 @@ * * @section CAPI_CONTEXT_TRIGGER_MODULE_FEATURE Related Features * - * Some of the event and condition items in this API are related with one of the following features:@n - * - http://tizen.org/feature/network.telephony + * This API is related with the following features:@n + * - http://tizen.org/feature/contextual_trigger + * And some of the event and condition items in this API are related with one of the following features:@n + * - http://tizen.org/feature/battery + * - http://tizen.org/feature/contact * - http://tizen.org/feature/location.gps + * - http://tizen.org/feature/location.geofence * - http://tizen.org/feature/network.bluetooth + * - http://tizen.org/feature/network.telephony + * - http://tizen.org/feature/network.wifi * - http://tizen.org/feature/network.wifi + * - http://tizen.org/feature/sensor.activity_recognition + * - http://tizen.org/feature/usb.host * * It is recommended to design feature related code in your application for reliability.@n * For your convenience, context_trigger_rule_event_is_supported() and context_trigger_rule_condition_is_supported() diff --git a/include/context_trigger.h b/include/context_trigger.h index b3780c1..c12b7d0 100644 --- a/include/context_trigger.h +++ b/include/context_trigger.h @@ -646,7 +646,7 @@ typedef struct _context_trigger_rule_entry_s* context_trigger_rule_entry_h; * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_PERMISSION_DENIED Permission denied - * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Unsupported event/condition contained + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Out of memory * @retval #CONTEXT_TRIGGER_ERROR_OPERATION_FAILED Operation failed * @retval #CONTEXT_TRIGGER_ERROR_INVALID_RULE Invalid rule @@ -686,7 +686,7 @@ int context_trigger_remove_rule(int rule_id); * @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_TRIGGER_ERROR_NOT_SUPPORTED Unsupported event/condition contained + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Out of memory * @retval #CONTEXT_TRIGGER_ERROR_OPERATION_FAILED Operation failed * @retval #CONTEXT_TRIGGER_ERROR_RULE_ENABLED Rule is enabled already @@ -707,6 +707,7 @@ int context_trigger_enable_rule(int rule_id); * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * @retval #CONTEXT_TRIGGER_ERROR_OPERATION_FAILED Operation failed * @retval #CONTEXT_TRIGGER_ERROR_RULE_NOT_ENABLED Rule is not enabled * @retval #CONTEXT_TRIGGER_ERROR_RULE_NOT_EXIST Rule does not exist @@ -730,6 +731,7 @@ int context_trigger_disable_rule(int rule_id); * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * @retval #CONTEXT_TRIGGER_ERROR_OPERATION_FAILED Operation failed * */ @@ -748,6 +750,7 @@ int context_trigger_get_own_rule_ids(int** enabled_rule_ids, int* enabled_rule_c * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * @retval #CONTEXT_TRIGGER_ERROR_OPERATION_FAILED Operation failed * @retval #CONTEXT_TRIGGER_ERROR_RULE_NOT_EXIST Rule does not exist */ @@ -772,6 +775,7 @@ int context_trigger_get_rule_by_id(int rule_id, context_trigger_rule_h* rule); * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Memory allocation failed + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * * @see context_trigger_rule_destroy() */ @@ -786,6 +790,7 @@ int context_trigger_rule_create(context_trigger_logical_type_e logical_type, con * @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_TRIGGER_ERROR_NOT_SUPPORTED Not supported * * @pre context_trigger_rule_create() * @see context_trigger_get_rule_by_id() @@ -803,6 +808,7 @@ int context_trigger_rule_destroy(context_trigger_rule_h rule); * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * @retval #CONTEXT_TRIGGER_ERROR_OPERATION_FAILED Operation failed * @retval #CONTEXT_TRIGGER_ERROR_INVALID_RULE Invalid rule */ @@ -832,6 +838,7 @@ int context_trigger_rule_add_entry(context_trigger_rule_h rule, context_trigger_ * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_PERMISSION_DENIED Permission denied * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * @retval #CONTEXT_TRIGGER_ERROR_OPERATION_FAILED Operation failed * @retval #CONTEXT_TRIGGER_ERROR_INVALID_RULE Invalid rule */ @@ -859,6 +866,7 @@ int context_trigger_rule_set_action_app_control(context_trigger_rule_h rule, app * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_PERMISSION_DENIED Permission denied * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * @retval #CONTEXT_TRIGGER_ERROR_OPERATION_FAILED Operation failed * @retval #CONTEXT_TRIGGER_ERROR_INVALID_RULE Invalid rule */ @@ -875,6 +883,7 @@ int context_trigger_rule_set_action_notification(context_trigger_rule_h rule, co * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * @retval #CONTEXT_TRIGGER_ERROR_OPERATION_FAILED Operation failed * * @see context_trigger_rule_get_description() @@ -894,6 +903,7 @@ int context_trigger_rule_set_description(context_trigger_rule_h rule, const char * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * @retval #CONTEXT_TRIGGER_ERROR_OPERATION_FAILED Operation failed * * @see context_trigger_rule_set_description() @@ -925,7 +935,7 @@ int context_trigger_rule_get_description(context_trigger_rule_h rule, char** des * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Memory allocation failed - * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Unsupported event contained + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * * @see context_trigger_rule_entry_destroy() */ @@ -942,6 +952,7 @@ int context_trigger_rule_event_create(context_trigger_event_e event_item, contex * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OPERATION_FAILED Operation failed + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported */ int context_trigger_rule_event_is_supported(context_trigger_event_e event_item, bool* supported); @@ -969,7 +980,7 @@ int context_trigger_rule_event_is_supported(context_trigger_event_e event_item, * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Memory allocation failed - * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Unsupported condition contained + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * * @see context_trigger_rule_entry_destroy() */ @@ -986,6 +997,7 @@ int context_trigger_rule_condition_create(context_trigger_condition_e condition_ * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OPERATION_FAILED Operation failed + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported */ int context_trigger_rule_condition_is_supported(context_trigger_condition_e condition_item, bool* supported); @@ -998,6 +1010,7 @@ int context_trigger_rule_condition_is_supported(context_trigger_condition_e cond * @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_TRIGGER_ERROR_NOT_SUPPORTED Not supported * * @pre context_trigger_rule_event_create() * @pre context_trigger_rule_condition_create() @@ -1017,6 +1030,7 @@ int context_trigger_rule_entry_destroy(context_trigger_rule_entry_h entry); * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * @retval #CONTEXT_TRIGGER_ERROR_INVALID_RULE Invalid rule * * @see context_trigger_rule_entry_add_option() @@ -1038,6 +1052,7 @@ int context_trigger_rule_entry_add_option_int(context_trigger_rule_entry_h entry * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * @retval #CONTEXT_TRIGGER_ERROR_INVALID_RULE Invalid rule * * @see context_trigger_rule_entry_add_option() @@ -1059,6 +1074,7 @@ int context_trigger_rule_entry_add_option_string(context_trigger_rule_entry_h en * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * @retval #CONTEXT_TRIGGER_ERROR_INVALID_RULE Invalid rule * * @see context_trigger_rule_entry_add_option_int() @@ -1080,6 +1096,7 @@ int context_trigger_rule_entry_add_option(context_trigger_rule_entry_h entry, co * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * @retval #CONTEXT_TRIGGER_ERROR_INVALID_RULE Invalid rule * * @post context_trigger_rule_entry_add_comparison() @@ -1106,6 +1123,7 @@ int context_trigger_rule_entry_add_key(context_trigger_rule_entry_h entry, conte * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * @retval #CONTEXT_TRIGGER_ERROR_NO_DATA The key was not added in the entry * @retval #CONTEXT_TRIGGER_ERROR_INVALID_RULE Invalid rule * @@ -1131,6 +1149,7 @@ int context_trigger_rule_entry_add_comparison_int(context_trigger_rule_entry_h e * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * @retval #CONTEXT_TRIGGER_ERROR_NO_DATA The key was not added in the entry * @retval #CONTEXT_TRIGGER_ERROR_INVALID_RULE Invalid rule * @@ -1155,6 +1174,7 @@ int context_trigger_rule_entry_add_comparison_string(context_trigger_rule_entry_ * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * @retval #CONTEXT_TRIGGER_ERROR_NO_DATA The key was not added in the entry * @retval #CONTEXT_TRIGGER_ERROR_INVALID_RULE Invalid rule * @@ -1178,6 +1198,7 @@ int context_trigger_rule_entry_add_comparison(context_trigger_rule_entry_h entry * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * @retval #CONTEXT_TRIGGER_ERROR_OPERATION_FAILED Operation failed * @retval #CONTEXT_TRIGGER_ERROR_DATA_EXIST Data exist * @retval #CONTEXT_TRIGGER_ERROR_INVALID_DATA Invalid data @@ -1198,7 +1219,7 @@ int context_trigger_custom_register(const char* name, const char* attr_template) * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OPERATION_FAILED Operation failed - * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Unsupported event/condition item + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * * @see context_trigger_custom_register() */ @@ -1220,7 +1241,7 @@ int context_trigger_custom_unregister(const char* name); * @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_TRIGGER_ERROR_NOT_SUPPORTED Unsupported event/condition contained + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * @retval #CONTEXT_TRIGGER_ERROR_INVALID_DATA Invalid data */ int context_trigger_custom_publish(const char* name, const char* fact); @@ -1241,7 +1262,7 @@ int context_trigger_custom_publish(const char* name, const char* fact); * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Memory allocation failed - * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Unsupported event contained + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * * @see context_trigger_rule_event_create() * @see context_trigger_rule_entry_destroy() @@ -1265,7 +1286,7 @@ int context_trigger_rule_custom_event_create(const char* event_item, const char* * @retval #CONTEXT_TRIGGER_ERROR_NONE Successful * @retval #CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONTEXT_TRIGGER_ERROR_OUT_OF_MEMORY Memory allocation failed - * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Unsupported condition contained + * @retval #CONTEXT_TRIGGER_ERROR_NOT_SUPPORTED Not supported * * @see context_trigger_rule_condition_create() * @see context_trigger_rule_entry_destroy() diff --git a/src/trigger/context_trigger.cpp b/src/trigger/context_trigger.cpp index 2fffe25..b78fc7b 100644 --- a/src/trigger/context_trigger.cpp +++ b/src/trigger/context_trigger.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -46,6 +47,18 @@ #define PKG_ID_LENGTH 128 +#define CONTEXT_TRIGGER_FEATURE "http://tizen.org/feature/contextual_trigger" +#define CHECK_CONTEXT_TRIGGER_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_TRIGGER_ERROR_NOT_SUPPORTED; \ + } \ + } \ + } while (0) + enum EntryCategory { CATEGORY_EVENT = 1, CATEGORY_CONDITION = 2 @@ -223,6 +236,7 @@ static Scheduler __scheduler; EXPORT_API int context_trigger_add_rule(context_trigger_rule_h rule, int* rule_id) { INIT_SCHED; + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); ASSERT_NOT_NULL(rule && rule_id); int err = ctx_sched_add_job(SCHED, rule->job, rule_id); @@ -235,6 +249,7 @@ EXPORT_API int context_trigger_add_rule(context_trigger_rule_h rule, int* rule_i EXPORT_API int context_trigger_remove_rule(int rule_id) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); INIT_SCHED; if (rule_id <= 0) return CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER; @@ -251,6 +266,7 @@ EXPORT_API int context_trigger_remove_rule(int rule_id) EXPORT_API int context_trigger_enable_rule(int rule_id) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); INIT_SCHED; if (rule_id <= 0) return CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER; @@ -265,6 +281,7 @@ EXPORT_API int context_trigger_enable_rule(int rule_id) EXPORT_API int context_trigger_disable_rule(int rule_id) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); INIT_SCHED; if (rule_id <= 0) return CONTEXT_TRIGGER_ERROR_INVALID_PARAMETER; @@ -286,6 +303,7 @@ static bool __foreach_job_cb(ctx_sched_h scheduler, ctx_sched_job_h job, void *u EXPORT_API int context_trigger_get_own_rule_ids(int** enabled_rule_ids, int* enabled_rule_count, int** disabled_rule_ids, int* disabled_rule_count) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); INIT_SCHED; ASSERT_NOT_NULL(enabled_rule_ids && enabled_rule_count && disabled_rule_ids && disabled_rule_count); @@ -339,6 +357,7 @@ EXPORT_API int context_trigger_get_own_rule_ids(int** enabled_rule_ids, int* ena EXPORT_API int context_trigger_get_rule_by_id(int rule_id, context_trigger_rule_h* rule) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); INIT_SCHED; ASSERT_NOT_NULL(rule); if (rule_id <= 0) @@ -365,6 +384,7 @@ EXPORT_API int context_trigger_get_rule_by_id(int rule_id, context_trigger_rule_ EXPORT_API int context_trigger_rule_create(context_trigger_logical_type_e logical_type, context_trigger_rule_h* rule) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); ASSERT_NOT_NULL(rule); IF_FAIL_RETURN(logical_type == CONTEXT_TRIGGER_LOGICAL_CONJUNCTION || logical_type == CONTEXT_TRIGGER_LOGICAL_DISJUNCTION, E_PARAM); @@ -384,6 +404,7 @@ EXPORT_API int context_trigger_rule_create(context_trigger_logical_type_e logica EXPORT_API int context_trigger_rule_destroy(context_trigger_rule_h rule) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); INIT_SCHED; ASSERT_NOT_NULL(rule); @@ -394,6 +415,7 @@ EXPORT_API int context_trigger_rule_destroy(context_trigger_rule_h rule) static int __set_event(context_trigger_rule_h rule, context_trigger_rule_entry_h event) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); IF_FAIL_RETURN(event->jobContext, E_PARAM); IF_FAIL_RETURN_TAG(!rule->hasEvent, E_INV_RULE, _E, "The rule already has the event"); @@ -416,6 +438,7 @@ static int __set_event(context_trigger_rule_h rule, context_trigger_rule_entry_h static int __add_condition(context_trigger_rule_h rule, context_trigger_rule_entry_h condition) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); IF_FAIL_RETURN(condition->jobContext, E_PARAM); bool exist = (rule->conditions.find(condition->uri) != rule->conditions.end()); @@ -438,6 +461,7 @@ static int __add_condition(context_trigger_rule_h rule, context_trigger_rule_ent EXPORT_API int context_trigger_rule_add_entry(context_trigger_rule_h rule, context_trigger_rule_entry_h entry) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); ASSERT_NOT_NULL(rule && entry); IF_FAIL_RETURN_TAG(!rule->readOnly, E_PARAM, _E, "A rule acquired by context_trigger_get_rule_by_id() is not allowed to be modified."); @@ -485,6 +509,7 @@ static bool __is_ui_app(app_control_h ctrl) EXPORT_API int context_trigger_rule_set_action_app_control(context_trigger_rule_h rule, app_control_h app_control) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); INIT_SCHED; ASSERT_NOT_NULL(rule && app_control); @@ -537,6 +562,7 @@ static bool __is_valid_app_control(app_control_h ctrl) EXPORT_API int context_trigger_rule_set_action_notification(context_trigger_rule_h rule, const char* title, const char* content, const char* icon_path, app_control_h app_control) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); INIT_SCHED; ASSERT_NOT_NULL(rule && title && content); @@ -568,6 +594,7 @@ EXPORT_API int context_trigger_rule_set_action_notification(context_trigger_rule EXPORT_API int context_trigger_rule_set_action_dbus_call(context_trigger_rule_h rule, const char *bus_name, const char *object_path, const char *interface_name, const char *method_name, GVariant *param) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); ASSERT_NOT_NULL(rule && bus_name && object_path && interface_name && method_name); IF_FAIL_RETURN_TAG(!rule->hasAction, E_INV_RULE, _E, "The rule has an action"); @@ -582,6 +609,7 @@ EXPORT_API int context_trigger_rule_set_action_dbus_call(context_trigger_rule_h EXPORT_API int context_trigger_rule_set_description(context_trigger_rule_h rule, const char* description) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); ASSERT_NOT_NULL(rule && description); IF_FAIL_RETURN(strlen(description) > 0, E_PARAM); @@ -590,6 +618,7 @@ EXPORT_API int context_trigger_rule_set_description(context_trigger_rule_h rule, EXPORT_API int context_trigger_rule_get_description(context_trigger_rule_h rule, char** description) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); ASSERT_NOT_NULL(rule && description); char* val = NULL; @@ -605,6 +634,7 @@ EXPORT_API int context_trigger_rule_get_description(context_trigger_rule_h rule, EXPORT_API int context_trigger_rule_event_create(context_trigger_event_e event_item, context_trigger_logical_type_e logical_type, context_trigger_rule_entry_h* entry) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); INIT_SCHED; ASSERT_NOT_NULL(entry); IF_FAIL_RETURN(logical_type == CONTEXT_TRIGGER_LOGICAL_CONJUNCTION || logical_type == CONTEXT_TRIGGER_LOGICAL_DISJUNCTION, E_PARAM); @@ -631,6 +661,7 @@ EXPORT_API int context_trigger_rule_event_create(context_trigger_event_e event_i static bool __is_valid_pkg_id(const char* pkgId) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); IF_FAIL_RETURN(pkgId, false); pkgmgrinfo_pkginfo_h pkgInfo; @@ -642,6 +673,7 @@ static bool __is_valid_pkg_id(const char* pkgId) EXPORT_API int context_trigger_rule_custom_event_create(const char* event_item, const char* provider, context_trigger_logical_type_e logical_type, context_trigger_rule_entry_h* entry) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); INIT_SCHED; ASSERT_NOT_NULL(event_item && provider && entry); IF_FAIL_RETURN_TAG(__is_valid_pkg_id(provider), CONTEXT_TRIGGER_ERROR_INVALID_DATA, _E, "No such package"); @@ -660,6 +692,7 @@ EXPORT_API int context_trigger_rule_custom_event_create(const char* event_item, EXPORT_API int context_trigger_rule_event_is_supported(context_trigger_event_e event_item, bool* supported) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); INIT_SCHED; ASSERT_NOT_NULL(supported); @@ -671,6 +704,7 @@ EXPORT_API int context_trigger_rule_event_is_supported(context_trigger_event_e e EXPORT_API int context_trigger_rule_condition_create(context_trigger_condition_e condition_item, context_trigger_logical_type_e logical_type, context_trigger_rule_entry_h* entry) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); INIT_SCHED; ASSERT_NOT_NULL(entry); IF_FAIL_RETURN(logical_type == CONTEXT_TRIGGER_LOGICAL_CONJUNCTION || logical_type == CONTEXT_TRIGGER_LOGICAL_DISJUNCTION, E_PARAM); @@ -697,6 +731,7 @@ EXPORT_API int context_trigger_rule_condition_create(context_trigger_condition_e EXPORT_API int context_trigger_rule_custom_condition_create(const char* condition_item, const char* provider, context_trigger_logical_type_e logical_type, context_trigger_rule_entry_h* entry) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); INIT_SCHED; ASSERT_NOT_NULL(condition_item && provider && entry); IF_FAIL_RETURN(logical_type == CONTEXT_TRIGGER_LOGICAL_CONJUNCTION || logical_type == CONTEXT_TRIGGER_LOGICAL_DISJUNCTION, E_PARAM); @@ -716,6 +751,7 @@ EXPORT_API int context_trigger_rule_custom_condition_create(const char* conditio EXPORT_API int context_trigger_rule_condition_is_supported(context_trigger_condition_e condition_item, bool* supported) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); INIT_SCHED; ASSERT_NOT_NULL(supported); @@ -727,6 +763,7 @@ EXPORT_API int context_trigger_rule_condition_is_supported(context_trigger_condi EXPORT_API int context_trigger_rule_entry_destroy(context_trigger_rule_entry_h entry) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); INIT_SCHED; ASSERT_NOT_NULL(entry); @@ -737,6 +774,7 @@ EXPORT_API int context_trigger_rule_entry_destroy(context_trigger_rule_entry_h e EXPORT_API int context_trigger_rule_entry_add_option_int(context_trigger_rule_entry_h entry, const char* option_key, int value) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); ASSERT_NOT_NULL(entry && option_key); ContextItem* contextItem = __get_context_item(entry); @@ -753,6 +791,7 @@ EXPORT_API int context_trigger_rule_entry_add_option_int(context_trigger_rule_en EXPORT_API int context_trigger_rule_entry_add_option_string(context_trigger_rule_entry_h entry, const char* option_key, const char* value) { _DEPRECATED_FUNC; + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); ASSERT_NOT_NULL(entry && option_key && value); ContextItem* contextItem = __get_context_item(entry); @@ -769,6 +808,7 @@ EXPORT_API int context_trigger_rule_entry_add_option_string(context_trigger_rule EXPORT_API int context_trigger_rule_entry_add_option(context_trigger_rule_entry_h entry, const char* option_key, const char* event_data_key) { _DEPRECATED_FUNC; + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); ASSERT_NOT_NULL(entry && option_key && event_data_key); IF_FAIL_RETURN(entry->category == CATEGORY_CONDITION, E_INV_RULE); @@ -792,6 +832,7 @@ static bool __is_member_key(context_trigger_rule_entry_h entry, const char* key) EXPORT_API int context_trigger_rule_entry_add_key(context_trigger_rule_entry_h entry, context_trigger_logical_type_e logical_type, const char* key) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); ASSERT_NOT_NULL(entry && key); IF_FAIL_RETURN(logical_type == CONTEXT_TRIGGER_LOGICAL_CONJUNCTION || logical_type == CONTEXT_TRIGGER_LOGICAL_DISJUNCTION, E_PARAM); @@ -811,6 +852,7 @@ EXPORT_API int context_trigger_rule_entry_add_key(context_trigger_rule_entry_h e EXPORT_API int context_trigger_rule_entry_add_comparison(context_trigger_rule_entry_h entry, const char* key, const char* op, const char* event_data_key) { _DEPRECATED_FUNC; + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); ASSERT_NOT_NULL(entry && key && op && event_data_key); IF_FAIL_RETURN(entry->category == CATEGORY_CONDITION, E_INV_RULE); @@ -832,6 +874,7 @@ EXPORT_API int context_trigger_rule_entry_add_comparison(context_trigger_rule_en EXPORT_API int context_trigger_rule_entry_add_comparison_int(context_trigger_rule_entry_h entry, const char* key, const char* op, int value) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); ASSERT_NOT_NULL(entry && key && op); ContextItem* contextItem = __get_context_item(entry); @@ -882,6 +925,7 @@ EXPORT_API int context_trigger_rule_entry_add_comparison_int(context_trigger_rul EXPORT_API int context_trigger_rule_entry_add_comparison_string(context_trigger_rule_entry_h entry, const char* key, const char* op, const char* value) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); ASSERT_NOT_NULL(entry && key && op && value); ContextItem* contextItem = __get_context_item(entry); @@ -906,6 +950,7 @@ EXPORT_API int context_trigger_rule_entry_add_comparison_string(context_trigger_ EXPORT_API int context_trigger_custom_register(const char* name, const char* attr_template) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); INIT_SCHED; ASSERT_NOT_NULL(name && attr_template); @@ -925,6 +970,7 @@ EXPORT_API int context_trigger_custom_register(const char* name, const char* att EXPORT_API int context_trigger_custom_unregister(const char* name) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); INIT_SCHED; ASSERT_NOT_NULL(name); @@ -945,6 +991,7 @@ EXPORT_API int context_trigger_custom_unregister(const char* name) EXPORT_API int context_trigger_custom_publish(const char* name, const char* fact) { + CHECK_CONTEXT_TRIGGER_SUPPORTED(CONTEXT_TRIGGER_FEATURE); INIT_SCHED; ASSERT_NOT_NULL(name && fact);