diff options
author | segwon <segwon.han@samsung.com> | 2016-11-15 21:41:28 +0900 |
---|---|---|
committer | segwon <segwon.han@samsung.com> | 2016-11-15 21:51:51 +0900 |
commit | a77400c0e118cf0c7369db1df11c630f769c2099 (patch) | |
tree | bed7336f3b058e83ec9064d294d42f3f4df75968 /src | |
parent | fa919adeb3e63090a45dfe4c53cfade1d7e190c8 (diff) | |
download | d2d-conv-setting-a77400c0e118cf0c7369db1df11c630f769c2099.tar.gz d2d-conv-setting-a77400c0e118cf0c7369db1df11c630f769c2099.tar.bz2 d2d-conv-setting-a77400c0e118cf0c7369db1df11c630f769c2099.zip |
Addition ACL(discovery/permit/deny) module.submit/tizen/20161121.012034accepted/tizen/mobile/20161121.234656
Signed-off-by: segwon <segwon.han@samsung.com>
Change-Id: Ic1229fd8e7a673726d88797e5df16cda55d6e17f
Diffstat (limited to 'src')
-rw-r--r-- | src/convergence/convergence_power_manager.c | 28 | ||||
-rw-r--r-- | src/ui/setting_home.c | 14 | ||||
-rw-r--r-- | src/ui/setting_item_device_list.c | 467 | ||||
-rw-r--r-- | src/ui/setting_item_discovery_button.c | 51 | ||||
-rw-r--r-- | src/ui/setting_item_power.c | 28 | ||||
-rw-r--r-- | src/ui/setting_item_sign.c | 19 | ||||
-rw-r--r-- | src/util.c | 8 |
7 files changed, 561 insertions, 54 deletions
diff --git a/src/convergence/convergence_power_manager.c b/src/convergence/convergence_power_manager.c deleted file mode 100644 index 80f31eb..0000000 --- a/src/convergence/convergence_power_manager.c +++ /dev/null @@ -1,28 +0,0 @@ -#include "convergence.h" - -extern void convergence_power_on() -{ - int ret = conv_internal_set_activation_state(1); - if (ret == CONV_ERROR_NONE) { - dlog_print(DLOG_INFO, LOG_TAG, "convergence_power_on error. ret = %d", ret); - } -} - -extern void convergence_power_off() -{ - int ret = conv_internal_set_activation_state(0); - if (ret == CONV_ERROR_NONE) { - dlog_print(DLOG_INFO, LOG_TAG, "convergence_power_off error. ret = %d", ret); - } -} - -extern int get_convergence_power_state() -{ - int state; - int ret = conv_internal_get_activation_state(&state); - if (ret == CONV_ERROR_NONE) { - dlog_print(DLOG_INFO, LOG_TAG, "get_convergence_power_state error. ret = %d", ret); - } - - return state; -} diff --git a/src/ui/setting_home.c b/src/ui/setting_home.c index 9c5c1fb..0146921 100644 --- a/src/ui/setting_home.c +++ b/src/ui/setting_home.c @@ -1,7 +1,7 @@ #include "main.h" static int listener_num = 0; -static event_listener listeners[4]; +static event_listener listeners[10]; extern void add_state_change_event_listener(event_listener listener) { @@ -11,10 +11,8 @@ extern void add_state_change_event_listener(event_listener listener) extern void state_change_event(state_e state) { int index; - - for (index = 0; index < listener_num; index++) { + for (index = 0; index < listener_num; index++) listeners[index](state); - } } static Eina_Bool setting_menu_pop_cb(void *data, Elm_Object_Item *it) @@ -33,15 +31,11 @@ static void app_language_changed(app_event_info_h event_info, void *user_data) return; } - dlog_print(DLOG_ERROR, LOG_TAG, "language = %s.", language); - if (language != NULL) { elm_language_set(language); free(language); } - dlog_print(DLOG_ERROR, LOG_TAG, "language = %s.", language); - state_change_event(CHANGE_LANGUAGE); } @@ -59,8 +53,10 @@ extern void create_setting_menu(Evas_Object *parent) elm_object_content_set(background, layout); evas_object_show(layout); { - create_setting_item_power(layout); create_setting_item_sign(layout); + create_setting_item_discovery_button(layout); + create_setting_item_device_list(layout); + create_setting_item_power(layout); } Elm_Object_Item *menu = elm_naviframe_item_push(parent, "Convergence", NULL, NULL, background, NULL); diff --git a/src/ui/setting_item_device_list.c b/src/ui/setting_item_device_list.c new file mode 100644 index 0000000..e76e195 --- /dev/null +++ b/src/ui/setting_item_device_list.c @@ -0,0 +1,467 @@ +#include "main.h" + +#define DISCOVERY_TIME 8 +#define STORAGE_SIZE 30 + +#define LIST_TYPE_PERMITTED "permitted_list" +#define LIST_TYPE_DENIED "denied_list" +#define LIST_TYPE_DISCOVERED "discovered_list" + +#define DEVICE_TYPE_MOBILE "MOBILE" +#define DEVICE_TYPE_WEARABLE "WEARABLE" +#define DEVICE_TYPE_TV "TV" + +typedef struct device_info { + int index; + char *list_type; + char *name; + char *type; + char *mac_address; +} device_info_s; + +device_info_s *selected_device = NULL; + +static Evas_Object *group_list_item = NULL; +static conv_h conv_handle = NULL; + +static Elm_Object_Item *discovered_device_group = NULL; +static Evas_Object *discovered_list = NULL; +static int discovered_devices_index = -1; +static device_info_s **discovered_devices_info = NULL; + +static Elm_Object_Item *permitted_device_group = NULL; +static Evas_Object *permitted_list = NULL; +static int permitted_devices_index = -1; +static device_info_s **permitted_devices_info = NULL; + +static Elm_Object_Item *denied_device_group = NULL; +static Evas_Object *denied_list = NULL; +static int denied_devices_index = -1; +static device_info_s **denied_devices_info = NULL; + +static Elm_Genlist_Item_Class *device_item_builder = NULL; + +static Evas_Object *popup = NULL; + +static void set_acl_device_list(); + +static void popup_btn_clicked_cb(void *data, Evas_Object *obj, void *event_info) +{ + do_haptic(50); + + char *button_name = (char *)data; + dlog_print(DLOG_INFO, LOG_TAG, "Button Name : %s", button_name); + + if (!strcmp(DEVICE_LIST_SELECT_POPUP_PERMIT_BUTTON_TEXT, button_name)) { + conv_internal_set_acl_state(selected_device->mac_address, selected_device->type, selected_device->name, 0); + } else if (!strcmp(DEVICE_LIST_SELECT_POPUP_DENY_BUTTON_TEXT, button_name)) { + conv_internal_set_acl_state(selected_device->mac_address, selected_device->type, selected_device->name, 1); + } else if (!strcmp(DEVICE_LIST_SELECT_POPUP_REMOVE_BUTTON_TEXT, button_name)) { + conv_internal_remove_acl_device(selected_device->mac_address); + } + + set_acl_device_list(); + evas_object_del(popup); +} + +static void show_device_list_selected_popup(char *title_name, char *content, char *left_button_name, char *center_button_name, char *right_button_name) +{ + Evas_Object *parent = evas_object_smart_parent_get(group_list_item); + + popup = elm_popup_add(parent); + elm_popup_align_set(popup, ELM_NOTIFY_ALIGN_FILL, 1.0); + elm_object_part_text_set(popup, "title,text", title_name); + elm_object_text_set(popup, content); + eext_object_event_callback_add(popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL); + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + Evas_Object *left_button = elm_button_add(popup); + elm_object_style_set(left_button, "popup"); + elm_object_text_set(left_button, left_button_name); + elm_object_part_content_set(popup, "button1", left_button); + evas_object_smart_callback_add(left_button, "clicked", popup_btn_clicked_cb, left_button_name); + + Evas_Object *center_button = elm_button_add(popup); + elm_object_style_set(center_button, "popup"); + elm_object_text_set(center_button, center_button_name); + elm_object_part_content_set(popup, "button2", center_button); + evas_object_smart_callback_add(center_button, "clicked", popup_btn_clicked_cb, center_button_name); + + Evas_Object *right_button = elm_button_add(popup); + elm_object_style_set(right_button, "popup"); + elm_object_text_set(right_button, right_button_name); + elm_object_part_content_set(popup, "button3", right_button); + evas_object_smart_callback_add(right_button, "clicked", popup_btn_clicked_cb, right_button_name); + + evas_object_show(popup); +} + +static void device_list_select_cb(void *data, Evas_Object *obj, void *event_info) +{ + do_haptic(50); + + device_info_s *info = (device_info_s *) data; + + selected_device = (device_info_s *) calloc(sizeof(device_info_s), 1); + selected_device->index = info->index; + selected_device->list_type = info->list_type; + selected_device->name = info->name; + selected_device->type = info->type; + selected_device->mac_address = info->mac_address; + + char *title = DEVICE_LIST_SELECT_POPUP_TITLE_TEXT; + char content[1024]; + char *left_button_text = NULL; + char *center_button_text = NULL; + char *right_button_text = NULL; + + if (!strcmp(selected_device->list_type, LIST_TYPE_PERMITTED)) { + snprintf(content, sizeof(content), "'%s'%s",selected_device->name ,PERMITTED_LIST_SELECT_POPUP_CONTENT_TEXT); + left_button_text = DEVICE_LIST_SELECT_POPUP_CANCEL_BUTTON_TEXT; + center_button_text = DEVICE_LIST_SELECT_POPUP_DENY_BUTTON_TEXT; + right_button_text = DEVICE_LIST_SELECT_POPUP_REMOVE_BUTTON_TEXT; + + } else if (!strcmp(selected_device->list_type, LIST_TYPE_DENIED)) { + snprintf(content, sizeof(content), "'%s'%s",selected_device->name ,DENIED_LIST_SELECT_POPUP_CONTENT_TEXT); + left_button_text = DEVICE_LIST_SELECT_POPUP_CANCEL_BUTTON_TEXT; + center_button_text = DEVICE_LIST_SELECT_POPUP_PERMIT_BUTTON_TEXT; + right_button_text = DEVICE_LIST_SELECT_POPUP_REMOVE_BUTTON_TEXT; + + } else if (!strcmp(selected_device->list_type, LIST_TYPE_DISCOVERED)) { + snprintf(content, sizeof(content), "'%s'%s",selected_device->name ,DISCOVERED_LIST_SELECT_POPUP_CONTENT_TEXT); + left_button_text = DEVICE_LIST_SELECT_POPUP_CANCEL_BUTTON_TEXT; + center_button_text = DEVICE_LIST_SELECT_POPUP_DENY_BUTTON_TEXT; + right_button_text = DEVICE_LIST_SELECT_POPUP_PERMIT_BUTTON_TEXT; + } + + show_device_list_selected_popup(title, content, left_button_text, center_button_text, right_button_text); +} + +static void gl_expanded_cb(void *data, Evas_Object *obj, void *event_info) +{ + int index; + + Elm_Object_Item *it = event_info; + Evas_Object *list = elm_object_item_widget_get(it); + + char *type = elm_object_item_data_get(it); + + if (!strcmp(LIST_TYPE_DISCOVERED, type)) { + for (index = 0; index <= discovered_devices_index; index++){ + if (discovered_devices_info[index] != NULL) { + elm_genlist_item_append(list, device_item_builder, discovered_devices_info[index], it, ELM_GENLIST_ITEM_NONE, device_list_select_cb, discovered_devices_info[index]); + } + } + } else if (!strcmp(LIST_TYPE_PERMITTED, type)) { + for (index = 0; index <= permitted_devices_index; index++){ + if (permitted_devices_info[index] != NULL) { + elm_genlist_item_append(list, device_item_builder, permitted_devices_info[index], it, ELM_GENLIST_ITEM_NONE, device_list_select_cb, discovered_devices_info[index]); + } + } + } else if (!strcmp(LIST_TYPE_DENIED, type)) { + for (index = 0; index <= denied_devices_index; index++){ + if (denied_devices_info[index] != NULL) { + elm_genlist_item_append(list, device_item_builder, denied_devices_info[index], it, ELM_GENLIST_ITEM_NONE, device_list_select_cb, discovered_devices_info[index]); + } + } + } + + elm_genlist_item_fields_update(it, "elm.swallow.end", ELM_GENLIST_ITEM_FIELD_CONTENT); +} + +static void gl_selected_cb(void *data, Evas_Object *obj, void *event_info) +{ + Elm_Object_Item *it = event_info; + elm_genlist_item_selected_set(it, EINA_FALSE); + + Eina_Bool expanded = elm_genlist_item_expanded_get(it); + elm_genlist_item_expanded_set(it, !expanded); +} + +static void gl_contracted_cb(void *data, Evas_Object *obj, void *event_info) +{ + Elm_Object_Item *it = event_info; + elm_genlist_item_subitems_clear(it); + elm_genlist_item_fields_update(it, "elm.swallow.end", ELM_GENLIST_ITEM_FIELD_CONTENT); +} + +static Evas_Object* create_image(Evas_Object *parent, Evas_Coord w, Evas_Coord h, char *type) +{ + Evas_Object *img; + img = elm_image_add(parent); + + if (type != NULL) { + if (!strcmp(DEVICE_TYPE_MOBILE, type)) { + elm_image_file_set(img, "usr/apps/org.tizen.d2d-conv-setting/res/images/device_type_icon_mobilephone.png", NULL); + } else if (!strcmp(DEVICE_TYPE_TV, type)) { + elm_image_file_set(img, "usr/apps/org.tizen.d2d-conv-setting/res/images/device_type_icon_display.png", NULL); + } else if (!strcmp(DEVICE_TYPE_WEARABLE, type)) { + elm_image_file_set(img, "usr/apps/org.tizen.d2d-conv-setting/res/images/device_type_icon_wrist.png", NULL); + } else { + elm_image_file_set(img, "usr/apps/org.tizen.d2d-conv-setting/res/images/device_type_icon_multimedia.png", NULL); + } + + } else { + elm_image_file_set(img, "usr/apps/org.tizen.d2d-conv-setting/res/images/device_type_icon_multimedia.png", NULL); + } + + evas_object_size_hint_min_set(img, ELM_SCALE_SIZE(w), ELM_SCALE_SIZE(h)); + return img; +} + +static Evas_Object* device_info_content_get_cb(void *data, Evas_Object *obj, const char *part) +{ + if (!strcmp("elm.swallow.icon", part)) { + device_info_s *item = (device_info_s *)data; + return create_image(obj, 32, 32, item->type); + } else { + return NULL; + } +} + +static char* device_info_text_cb(void *data, Evas_Object *obj, const char *part) +{ + device_info_s *item = (device_info_s *)data; + + if (!strcmp("elm.text", part)) { + return strdup(item->name); + } else if (!strcmp("elm.text.multiline", part)) { + return strdup(item->mac_address); + } else { + return NULL; + } +} + +static void discovery_foreach_cb(conv_device_h device_h, int result, void *data) +{ + char *device_id = NULL; + char *device_name = NULL; + char *device_type = NULL; + + switch (result) { + + case CONV_DISCOVERY_RESULT_ERROR : + return; + + case CONV_DISCOVERY_RESULT_LOST : + return; + + case CONV_DISCOVERY_RESULT_SUCCESS : + + conv_device_get_property_string(device_h, CONV_DEVICE_ID, &device_id); + int device_id_index; + for (device_id_index = 0; device_id_index < 5; device_id_index++) { + device_id[2+(device_id_index*3)] = '-'; + } + + conv_device_get_property_string(device_h, CONV_DEVICE_NAME, &device_name); + conv_device_get_property_string(device_h, CONV_DEVICE_TYPE, &device_type); + + int index = ++discovered_devices_index; + discovered_devices_info[index] = (device_info_s *) calloc(sizeof(device_info_s), 1); + discovered_devices_info[index]->list_type = LIST_TYPE_DISCOVERED; + discovered_devices_info[index]->index = index; + discovered_devices_info[index]->name = device_name; + discovered_devices_info[index]->type = device_type; + discovered_devices_info[index]->mac_address = device_id; + + elm_genlist_item_append(discovered_list, device_item_builder, discovered_devices_info[index], discovered_device_group, ELM_GENLIST_ITEM_NONE, device_list_select_cb, discovered_devices_info[index]); + elm_genlist_item_fields_update(discovered_device_group, "elm.swallow.end", ELM_GENLIST_ITEM_FIELD_CONTENT); + + break; + + case CONV_DISCOVERY_RESULT_FINISHED : + conv_destroy(conv_handle); + conv_handle = NULL; + state_change_event(DISCOVERY_STOP); + return; + } +} + +static void discovery_start() +{ + if(conv_handle == NULL) { + + int index; + + elm_genlist_item_subitems_clear(discovered_device_group); + elm_genlist_item_fields_update(discovered_device_group, "elm.swallow.end", ELM_GENLIST_ITEM_FIELD_CONTENT); + + if(discovered_devices_info != NULL) { + + for (index = 0; index < STORAGE_SIZE; index++) { + if(discovered_devices_info[index] == NULL) break; + free(discovered_devices_info[index]); + discovered_devices_info[index] = NULL; + } + + free(discovered_devices_info); + discovered_devices_info = NULL; + } + + discovered_devices_index = -1; + discovered_devices_info = (device_info_s **) calloc(STORAGE_SIZE, sizeof(device_info_s *)); + + elm_genlist_item_expanded_set(discovered_device_group, EINA_TRUE); + + conv_create(&conv_handle); + conv_discovery_start(conv_handle, DISCOVERY_TIME, discovery_foreach_cb, NULL); + } +} + +static void discovery_stop() +{ + if (conv_handle != NULL) { + conv_discovery_stop(conv_handle); + } +} + +static void state_change_event_listener (state_e state) +{ + switch (state) + { + case POWER_ON : + evas_object_show(group_list_item); + break; + case POWER_OFF : + evas_object_hide(group_list_item); + break; + case DISCOVERY_START : + discovery_start(); + break; + case DISCOVERY_STOP : + discovery_stop(); + break; + case CHANGE_LANGUAGE : + elm_genlist_realized_items_update(group_list_item); + break; + default : + break; + } +} + +static void acl_device_info(char *mac_address, char *device_type, char *device_name, int access_control_state, void *user_data) +{ + dlog_print(DLOG_ERROR, LOG_TAG, "Device_Type = %s", device_type); + + if(access_control_state == 0) { + int index = ++permitted_devices_index; + permitted_devices_info[index] = (device_info_s *) calloc(sizeof(device_info_s), 1); + permitted_devices_info[index]->list_type = LIST_TYPE_PERMITTED; + permitted_devices_info[index]->index = index; + permitted_devices_info[index]->name = strdup(device_name); + permitted_devices_info[index]->type = strdup(device_type); + permitted_devices_info[index]->mac_address = strdup(mac_address); + elm_genlist_item_append(permitted_list, device_item_builder, permitted_devices_info[index], permitted_device_group, ELM_GENLIST_ITEM_NONE, device_list_select_cb, permitted_devices_info[index]); + elm_genlist_item_fields_update(permitted_device_group, "elm.swallow.end", ELM_GENLIST_ITEM_FIELD_CONTENT); + + } else if (access_control_state == 1) { + int index = ++denied_devices_index; + denied_devices_info[index] = (device_info_s *) calloc(sizeof(device_info_s), 1); + denied_devices_info[index]->list_type = LIST_TYPE_DENIED; + denied_devices_info[index]->index = index; + denied_devices_info[index]->name = strdup(device_name); + denied_devices_info[index]->type = strdup(device_type); + denied_devices_info[index]->mac_address = strdup(mac_address); + elm_genlist_item_append(denied_list, device_item_builder, denied_devices_info[index], denied_device_group, ELM_GENLIST_ITEM_NONE, device_list_select_cb, denied_devices_info[index]); + elm_genlist_item_fields_update(denied_device_group, "elm.swallow.end", ELM_GENLIST_ITEM_FIELD_CONTENT); + } +} + +static void set_acl_device_list() +{ + int index; + + elm_genlist_item_subitems_clear(permitted_device_group); + elm_genlist_item_fields_update(permitted_device_group, "elm.swallow.end", ELM_GENLIST_ITEM_FIELD_CONTENT); + + if (permitted_devices_info != NULL) { + + for (index = 0; index < STORAGE_SIZE; index++) { + if(permitted_devices_info[index] == NULL) break; + free(permitted_devices_info[index]); + permitted_devices_info[index] = NULL; + } + + free(permitted_devices_info); + permitted_devices_info = NULL; + } + + permitted_devices_index = -1; + permitted_devices_info = (device_info_s **) calloc(STORAGE_SIZE, sizeof(device_info_s *)); + + elm_genlist_item_expanded_set(permitted_device_group, EINA_TRUE); + + elm_genlist_item_subitems_clear(denied_device_group); + elm_genlist_item_fields_update(denied_device_group, "elm.swallow.end", ELM_GENLIST_ITEM_FIELD_CONTENT); + + if (denied_devices_info != NULL) { + + for (index = 0; index < STORAGE_SIZE; index++) { + if(denied_devices_info[index] == NULL) break; + free(denied_devices_info[index]); + denied_devices_info[index] = NULL; + } + + free(denied_devices_info); + denied_devices_info = NULL; + } + + denied_devices_index = -1; + denied_devices_info = (device_info_s **) calloc(STORAGE_SIZE, sizeof(device_info_s *)); + + elm_genlist_item_expanded_set(denied_device_group, EINA_TRUE); + + conv_internal_get_acl_list(acl_device_info, NULL); +} + +static char* group_title_text_cb(void *data, Evas_Object *obj, const char *part) +{ + if (!strcmp("elm.text", part)) { + char buf[1024]; + snprintf(buf, sizeof(buf), "%s", (char *)data); + return strdup(buf); + } + return NULL; +} + +extern void create_setting_item_device_list(Evas_Object *parent) +{ + add_state_change_event_listener(state_change_event_listener); + + group_list_item = elm_genlist_add(parent); + elm_genlist_mode_set(group_list_item, ELM_LIST_COMPRESS); + + evas_object_smart_callback_add(group_list_item, "selected", gl_selected_cb, NULL); + evas_object_smart_callback_add(group_list_item, "expanded", gl_expanded_cb, NULL); + evas_object_smart_callback_add(group_list_item, "contracted", gl_contracted_cb, NULL); + + elm_grid_pack(parent, group_list_item, 0, 10, 100, 77); + { + Elm_Genlist_Item_Class *group_item_builder = elm_genlist_item_class_new(); + { + group_item_builder->item_style = "group_index/expandable"; + group_item_builder->func.text_get = group_title_text_cb; + } + + permitted_device_group = elm_genlist_item_append(group_list_item, group_item_builder, LIST_TYPE_PERMITTED, NULL, ELM_GENLIST_ITEM_TREE, NULL, NULL); + permitted_list = elm_object_item_widget_get(permitted_device_group); + + denied_device_group = elm_genlist_item_append(group_list_item, group_item_builder, LIST_TYPE_DENIED, NULL, ELM_GENLIST_ITEM_TREE, NULL, NULL); + denied_list = elm_object_item_widget_get(denied_device_group); + + discovered_device_group = elm_genlist_item_append(group_list_item, group_item_builder, LIST_TYPE_DISCOVERED, NULL, ELM_GENLIST_ITEM_TREE, NULL, NULL); + discovered_list = elm_object_item_widget_get(discovered_device_group); + + elm_genlist_item_class_free(group_item_builder); + } + + device_item_builder = elm_genlist_item_class_new(); + { + device_item_builder->item_style = "multiline"; + device_item_builder->func.content_get = device_info_content_get_cb; + device_item_builder->func.text_get = device_info_text_cb; + } + + set_acl_device_list(); +}
\ No newline at end of file diff --git a/src/ui/setting_item_discovery_button.c b/src/ui/setting_item_discovery_button.c new file mode 100644 index 0000000..f820f05 --- /dev/null +++ b/src/ui/setting_item_discovery_button.c @@ -0,0 +1,51 @@ +#include "main.h" + +static Evas_Object *discovery_button_item = NULL; +static state_e discovery_state; + +static void state_change_event_listener (state_e state) +{ + switch (state) + { + case POWER_ON : + elm_object_disabled_set(discovery_button_item, EINA_FALSE); + break; + case POWER_OFF : + elm_object_disabled_set(discovery_button_item, EINA_TRUE); + break; + case DISCOVERY_START : + discovery_state = DISCOVERY_START; + elm_object_text_set(discovery_button_item, "Discovery Stop"); + break; + case DISCOVERY_STOP : + discovery_state = DISCOVERY_STOP; + elm_object_text_set(discovery_button_item, "Discovery Start"); + break; + default : + break; + } +} + +static void discovery_button_click_cb(void *data, Evas_Object *obj, void *event_info) +{ + if (discovery_state == DISCOVERY_START) { + state_change_event(DISCOVERY_STOP); + } else if (discovery_state == DISCOVERY_STOP) { + state_change_event(DISCOVERY_START); + } +} + +extern void create_setting_item_discovery_button(Evas_Object *parent) +{ + add_state_change_event_listener(state_change_event_listener); + + discovery_state = DISCOVERY_STOP; + + discovery_button_item = elm_button_add(parent); + elm_object_style_set(discovery_button_item, "bottom"); + elm_object_text_set(discovery_button_item, "Discovery Start"); + evas_object_smart_callback_add(discovery_button_item, "clicked", discovery_button_click_cb, NULL); + + elm_grid_pack(parent, discovery_button_item, 0, 87, 100, 13); + evas_object_show(discovery_button_item); +} diff --git a/src/ui/setting_item_power.c b/src/ui/setting_item_power.c index 068abf6..3e1624d 100644 --- a/src/ui/setting_item_power.c +++ b/src/ui/setting_item_power.c @@ -2,6 +2,32 @@ static Evas_Object *power_switch = NULL; +static void convergence_power_on() +{ + int ret = conv_internal_set_activation_state(1); + if (ret != CONV_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "convergence_power_on error. ret = %d", ret); + } +} + +static void convergence_power_off() +{ + int ret = conv_internal_set_activation_state(0); + if (ret != CONV_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "convergence_power_off error. ret = %d", ret); + } +} + +static int get_convergence_power_state() +{ + int state = 0; + int ret = conv_internal_get_activation_state(&state); + if (ret != CONV_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "get_convergence_power_state error. ret = %d", ret); + } + return state; +} + static void state_change_event_listener (state_e state) { switch (state) @@ -87,4 +113,4 @@ extern void create_setting_item_power(Evas_Object *parent) elm_genlist_item_class_free(item_builder); } -} +}
\ No newline at end of file diff --git a/src/ui/setting_item_sign.c b/src/ui/setting_item_sign.c index 3356d85..f13bb9c 100644 --- a/src/ui/setting_item_sign.c +++ b/src/ui/setting_item_sign.c @@ -1,31 +1,20 @@ #include "main.h" static Evas_Object *sign_item = NULL; -static char *notice = NULL; static void state_change_event_listener (state_e state) { switch (state) { case POWER_ON : - notice = POWER_ON_SIGN_TEXT; - elm_genlist_realized_items_update(sign_item); + evas_object_hide(sign_item); break; - case POWER_OFF : - notice = POWER_OFF_SIGN_TEXT; - elm_genlist_realized_items_update(sign_item); + evas_object_show(sign_item); break; - case CHANGE_LANGUAGE : - if (get_convergence_power_state() == 1) { - notice = POWER_ON_SIGN_TEXT; - } else { - notice = POWER_OFF_SIGN_TEXT; - } elm_genlist_realized_items_update(sign_item); break; - default : break; } @@ -34,11 +23,11 @@ static void state_change_event_listener (state_e state) static char* text_get_cb(void *data, Evas_Object *obj, const char *part) { if (!strcmp("elm.text.multiline", part)) { + char *notice = POWER_ON_SIGN_TEXT; char buf[1024]; snprintf(buf, sizeof(buf), "<font color=#3DB9CCFF>Notice</font><br>%s", notice); return strdup(buf); } - return NULL; } @@ -49,7 +38,6 @@ extern void create_setting_item_sign(Evas_Object *parent) sign_item = elm_genlist_add(parent); elm_genlist_mode_set(sign_item, ELM_LIST_COMPRESS); elm_grid_pack(parent, sign_item, 0, 10, 100, 77); - evas_object_show(sign_item); { Elm_Genlist_Item_Class *item_builder = elm_genlist_item_class_new(); { @@ -59,7 +47,6 @@ extern void create_setting_item_sign(Evas_Object *parent) Elm_Object_Item *item = elm_genlist_item_append(sign_item, item_builder, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_NONE); - elm_genlist_item_class_free(item_builder); } } diff --git a/src/util.c b/src/util.c new file mode 100644 index 0000000..df0d6f5 --- /dev/null +++ b/src/util.c @@ -0,0 +1,8 @@ +#include "main.h" + +extern void do_haptic(int count) +{ + haptic_device_h handle; + device_haptic_open(0, &handle); + device_haptic_vibrate(handle, count, 0, 0); +}
\ No newline at end of file |