From: JinWang An Date: Fri, 12 Jun 2020 07:29:24 +0000 (+0900) Subject: Add mode ID X-Git-Tag: submit/tizen/20200615.073011~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f8989abe620a85ad5e92973a9af37ed59db94eee;p=platform%2Fcore%2Fsystem%2Fmodes.git Add mode ID Change-Id: Iecf198e21ce8b17bb8c2d4958e58aa0cf629f6cd --- diff --git a/client/mdsc_add_remove.c b/client/mdsc_add_remove.c index b2cdfb1..3e92786 100644 --- a/client/mdsc_add_remove.c +++ b/client/mdsc_add_remove.c @@ -28,6 +28,7 @@ struct mds_action_handle { }; struct mds_mode_handle { + char *id; char *name; modes_type_mode_e type; bool hidden; @@ -97,21 +98,22 @@ static GVariant* _mdsc_create_mode_data(modes_mode_h mode) } GVariant *action = g_variant_new(MODES_DBUS_ACTION_LIST_SIG, action_builder); - GVariant *mode_data = g_variant_new(MODES_DBUS_MODE_SIG, mode->name, mode->type, mode->hidden, action); + GVariant *mode_data = g_variant_new(MODES_DBUS_MODE_SIG, mode->id, mode->name, mode->type, mode->hidden, action); g_variant_builder_unref(action_builder); return mode_data; } -API modes_mode_h modes_create_mode(const char *name, modes_type_mode_e type) +API modes_mode_h modes_create_mode(const char *id, const char *name, modes_type_mode_e type) { struct mds_mode_handle *mode; - RETV_IF(NULL == name, NULL); + RETV_IF(NULL == id, NULL); mode = malloc(sizeof(struct mds_mode_handle)); RETV_IF(NULL == mode, NULL); + mode->id = strdup(id); mode->name = strdup(name); mode->type = type; mode->hidden = false; @@ -175,13 +177,13 @@ API int modes_add_mode(modes_h handle, modes_mode_h mode) return MODES_ERROR_NONE; } -API int modes_remove_mode(modes_h handle, const char *name) +API int modes_remove_mode(modes_h handle, const char *id) { int ret; RETV_IF(NULL == handle, MODES_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == name, MODES_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == id, MODES_ERROR_INVALID_PARAMETER); - ret = _mdsc_dbus_remove_mode_sync(handle->conn, name); + ret = _mdsc_dbus_remove_mode_sync(handle->conn, id); if (MODES_ERROR_NONE != ret) { ERR("_mdsc_dbus_remove_mode_sync() Fail(%d)", ret); return ret; @@ -194,6 +196,7 @@ API void modes_destroy_mode(modes_mode_h mode) { RET_IF(NULL == mode); + free(mode->id); free(mode->name); g_list_free_full(mode->action_list, _mdsc_free_action); diff --git a/client/mdsc_apply.c b/client/mdsc_apply.c index 2dda682..737843e 100644 --- a/client/mdsc_apply.c +++ b/client/mdsc_apply.c @@ -37,13 +37,13 @@ static int _mdsc_dbus_apply_mode_sync(mdsDbus *mdsc_dbus, const char *mode) return result; } -API int modes_apply_mode(modes_h handle, const char *name) +API int modes_apply_mode(modes_h handle, const char *id) { int ret; RETV_IF(NULL == handle, MODES_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == name, MODES_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == id, MODES_ERROR_INVALID_PARAMETER); - ret = _mdsc_dbus_apply_mode_sync(handle->conn, name); + ret = _mdsc_dbus_apply_mode_sync(handle->conn, id); if (MODES_ERROR_NONE != ret) { ERR("_mdsc_bus_client_change_mode_sync() Fail(%d)", ret); return ret; diff --git a/client/mdsc_can_apply.c b/client/mdsc_can_apply.c index 6452549..19bad9f 100644 --- a/client/mdsc_can_apply.c +++ b/client/mdsc_can_apply.c @@ -37,13 +37,13 @@ static int _mdsc_dbus_can_apply_sync(mdsDbus *mdsc_dbus, const char *mode) return result; } -API int modes_can_apply(modes_h handle, const char *name) +API int modes_can_apply(modes_h handle, const char *id) { int ret; RETV_IF(NULL == handle, MODES_ERROR_INVALID_PARAMETER); - RETV_IF(NULL == name, MODES_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == id, MODES_ERROR_INVALID_PARAMETER); - ret = _mdsc_dbus_can_apply_sync(handle->conn, name); + ret = _mdsc_dbus_can_apply_sync(handle->conn, id); if (MODES_ERROR_NONE != ret) { ERR("_mdsc_dbus_precheck_mode_sync() Fail(%d)", ret); return ret; diff --git a/client/mdsc_get_modes.c b/client/mdsc_get_modes.c index 17e9ec3..bf1fd15 100644 --- a/client/mdsc_get_modes.c +++ b/client/mdsc_get_modes.c @@ -21,6 +21,7 @@ #include "common/dbus_def.h" struct mds_list_data_handle { + char *id; char *name; modes_type_mode_e type; int state; @@ -28,6 +29,7 @@ struct mds_list_data_handle { static GList* _get_mode_list(GVariant *in_data) { + gchar *mode_id; gchar *mode_name; gint32 state; gint32 type; @@ -35,13 +37,14 @@ static GList* _get_mode_list(GVariant *in_data) GList *mode_list = NULL;; g_variant_get(in_data, MODES_DBUS_GET_MODES_SIG, &iter); - while (g_variant_iter_loop(iter, MODES_DBUS_GET_MODES_MODE_SIG, &mode_name, &type, &state)) { - DBG("mode(%s) : state(%d)", mode_name, state); + while (g_variant_iter_loop(iter, MODES_DBUS_GET_MODES_MODE_SIG, &mode_id, &mode_name, &type, &state)) { + DBG("mode(%s) : state(%d)", mode_id, state); mode_list_data_h mode = malloc(sizeof(struct mds_list_data_handle)); if (NULL == mode) { ERR("malloc() Fail"); return NULL; } + mode->id = strdup(mode_id); mode->name = strdup(mode_name); mode->state = state; mode->type = type; @@ -92,6 +95,7 @@ API int modes_get_modes(modes_h handle, GList **list) static void _free_mode(gpointer data, gpointer user_data) { mode_list_data_h mode = data; + free(mode->id); free(mode->name); free(mode); } @@ -102,6 +106,12 @@ API void modes_free_modes(GList *list) g_list_free(list); } +API const char* modes_get_mode_id(mode_list_data_h data) +{ + RETV_IF(NULL == data, NULL); + return data->id; +} + API const char* modes_get_mode_name(mode_list_data_h data) { RETV_IF(NULL == data, NULL); diff --git a/common/dbus.xml b/common/dbus.xml index 15e8abf..69e1692 100644 --- a/common/dbus.xml +++ b/common/dbus.xml @@ -13,7 +13,7 @@ - + @@ -21,7 +21,7 @@ - + diff --git a/common/dbus_def.h b/common/dbus_def.h index 21486ef..78486cc 100644 --- a/common/dbus_def.h +++ b/common/dbus_def.h @@ -22,11 +22,11 @@ #define MODES_DBUS_OBJPATH "/org/tizen/modes/dbus" -#define MODES_DBUS_MODE_SIG "(sibv)" +#define MODES_DBUS_MODE_SIG "(ssibv)" #define MODES_DBUS_ACTION_SIG "(sss)" #define MODES_DBUS_ACTION_LIST_SIG "a" MODES_DBUS_ACTION_SIG -#define MODES_DBUS_GET_MODES_MODE_SIG "(sii)" +#define MODES_DBUS_GET_MODES_MODE_SIG "(ssii)" #define MODES_DBUS_GET_MODES_SIG "a" MODES_DBUS_GET_MODES_MODE_SIG #define MODES_DBUS_SAFE_STR(x) x ? x : "" diff --git a/common/definitions.h b/common/definitions.h index 994b4c5..38840f6 100644 --- a/common/definitions.h +++ b/common/definitions.h @@ -62,3 +62,4 @@ #warning "MODES_UNDO_INFO_DEFAULT_DIR is redefined" #endif #define MODES_UNDO_FILE_SUFFIX "_undo.xml" +#define MODES_ID_PREFIX "http://tizen.org/mode/" diff --git a/common/gen.sh b/common/gen.sh old mode 100755 new mode 100644 diff --git a/example/mode/tizen_asyncEx1_mode.xml b/example/mode/tizen_asyncEx1_mode.xml index 06dac5a..6a97f2e 100644 --- a/example/mode/tizen_asyncEx1_mode.xml +++ b/example/mode/tizen_asyncEx1_mode.xml @@ -1,6 +1,6 @@ - + 5 5 5 diff --git a/example/mode/tizen_asyncEx2_mode.xml b/example/mode/tizen_asyncEx2_mode.xml index 8310a2a..1429fc0 100644 --- a/example/mode/tizen_asyncEx2_mode.xml +++ b/example/mode/tizen_asyncEx2_mode.xml @@ -1,6 +1,6 @@ - + 5 5 5 diff --git a/example/mode/tizen_asyncFailEx1_mode.xml b/example/mode/tizen_asyncFailEx1_mode.xml index b764ffa..6b6207a 100644 --- a/example/mode/tizen_asyncFailEx1_mode.xml +++ b/example/mode/tizen_asyncFailEx1_mode.xml @@ -1,6 +1,6 @@ - + 5 5 5 diff --git a/example/mode/tizen_asyncFailEx2_mode.xml b/example/mode/tizen_asyncFailEx2_mode.xml index 74c4263..340b1a6 100644 --- a/example/mode/tizen_asyncFailEx2_mode.xml +++ b/example/mode/tizen_asyncFailEx2_mode.xml @@ -1,6 +1,6 @@ - + 5 5 5 diff --git a/example/mode/tizen_asyncValidErr_mode.xml b/example/mode/tizen_asyncValidErr_mode.xml index 9ef4ab3..71347fd 100644 --- a/example/mode/tizen_asyncValidErr_mode.xml +++ b/example/mode/tizen_asyncValidErr_mode.xml @@ -1,6 +1,6 @@ - diff --git a/example/mode/tizen_conflictErrBase_mode.xml b/example/mode/tizen_conflictErrBase_mode.xml index 5da4429..31893bf 100644 --- a/example/mode/tizen_conflictErrBase_mode.xml +++ b/example/mode/tizen_conflictErrBase_mode.xml @@ -1,6 +1,6 @@ - + 1 diff --git a/example/mode/tizen_conflictErrExclusive_mode.xml b/example/mode/tizen_conflictErrExclusive_mode.xml index b4d7858..47d6f9f 100644 --- a/example/mode/tizen_conflictErrExclusive_mode.xml +++ b/example/mode/tizen_conflictErrExclusive_mode.xml @@ -1,6 +1,6 @@ - + true diff --git a/example/mode/tizen_conflictErr_mode.xml b/example/mode/tizen_conflictErr_mode.xml index 0c21e0a..16fb283 100644 --- a/example/mode/tizen_conflictErr_mode.xml +++ b/example/mode/tizen_conflictErr_mode.xml @@ -1,6 +1,6 @@ - + 2 diff --git a/example/mode/tizen_essentialEx_mode.xml b/example/mode/tizen_essentialEx_mode.xml index 1a6c3af..f2e4609 100644 --- a/example/mode/tizen_essentialEx_mode.xml +++ b/example/mode/tizen_essentialEx_mode.xml @@ -1,6 +1,6 @@ - + on Modes-JBL 3 diff --git a/example/mode/tizen_invalidValErr1_mode.xml b/example/mode/tizen_invalidValErr1_mode.xml index 134df11..bd65605 100644 --- a/example/mode/tizen_invalidValErr1_mode.xml +++ b/example/mode/tizen_invalidValErr1_mode.xml @@ -1,6 +1,6 @@ - + 123 diff --git a/example/mode/tizen_invalidValErr2_mode.xml b/example/mode/tizen_invalidValErr2_mode.xml index 0078fff..c0d46c1 100644 --- a/example/mode/tizen_invalidValErr2_mode.xml +++ b/example/mode/tizen_invalidValErr2_mode.xml @@ -1,6 +1,6 @@ - + PRINT_TREE diff --git a/example/mode/tizen_normalEx1_mode.xml b/example/mode/tizen_normalEx1_mode.xml index fb1f7b1..e122738 100644 --- a/example/mode/tizen_normalEx1_mode.xml +++ b/example/mode/tizen_normalEx1_mode.xml @@ -1,6 +1,6 @@ - + on com.vpn.usa123 https://pbskids.org/ diff --git a/example/mode/tizen_normalEx2_mode.xml b/example/mode/tizen_normalEx2_mode.xml index 227ec5a..6d30f71 100644 --- a/example/mode/tizen_normalEx2_mode.xml +++ b/example/mode/tizen_normalEx2_mode.xml @@ -1,6 +1,6 @@ -