summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsegwon <segwon.han@samsung.com>2016-11-24 16:22:16 +0900
committersegwon <segwon.han@samsung.com>2016-11-24 16:22:52 +0900
commit51a6f643a57c4f9f37ac8ad66a3c64d6322ffd41 (patch)
treec04b62e934e662658791684d429269ccb0e23747 /src
parent7478c9ed5cfdb7fc3dbc717b3c8022bfa9ce0d6f (diff)
downloadd2d-conv-setting-51a6f643a57c4f9f37ac8ad66a3c64d6322ffd41.tar.gz
d2d-conv-setting-51a6f643a57c4f9f37ac8ad66a3c64d6322ffd41.tar.bz2
d2d-conv-setting-51a6f643a57c4f9f37ac8ad66a3c64d6322ffd41.zip
Development the Wearable Setting Application
Signed-off-by: segwon <segwon.han@samsung.com> Change-Id: Ia7506a7d28a6e1e0eeb21b4153f88910530152b2
Diffstat (limited to 'src')
-rw-r--r--src/convergence/convergence_power_manager.c28
-rw-r--r--src/main.c90
-rw-r--r--src/ui/setting_home.c171
-rw-r--r--src/ui/setting_item_allowed_device_list.c274
-rw-r--r--src/ui/setting_item_denied_device_list.c274
-rw-r--r--src/ui/setting_item_device_list.c109
-rw-r--r--src/ui/setting_item_discovery.c312
-rw-r--r--src/ui/setting_item_power.c90
-rw-r--r--src/ui/setting_item_sign.c100
-rw-r--r--src/util.c24
10 files changed, 1237 insertions, 235 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/main.c b/src/main.c
index bf099bc..5e92872 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,26 +1,51 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "main.h"
static bool app_create(void *data)
{
- Evas_Object *win = elm_win_util_standard_add(PACKAGE, PACKAGE);
- elm_win_conformant_set(win, EINA_TRUE);
- elm_win_autodel_set(win, EINA_TRUE);
- evas_object_show(win);
-
- Evas_Object *conform = elm_conformant_add(win);
- elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW);
- elm_win_indicator_opacity_set(win, ELM_WIN_INDICATOR_OPAQUE);
- evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_win_resize_object_add(win, conform);
- evas_object_show(conform);
-
- Evas_Object *nf = elm_naviframe_add(conform);
- eext_object_event_callback_add(nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
- evas_object_size_hint_weight_set(nf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_object_content_set(conform, nf);
- evas_object_show(nf);
-
- create_setting_menu(nf);
+ /* Window */
+ ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE);
+ elm_win_conformant_set(ad->win, EINA_TRUE);
+ elm_win_autodel_set(ad->win, EINA_TRUE);
+ if (elm_win_wm_rotation_supported_get(ad->win)) {
+ int rots[4] = { 0, 90, 180, 270 };
+ elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4);
+ }
+ evas_object_show(ad->win);
+
+ /* Conformant */
+ ad->conform = elm_conformant_add(ad->win);
+ evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(ad->win, ad->conform);
+ evas_object_show(ad->conform);
+
+ /* Circle Surface */
+ ad->circle_surface = eext_circle_surface_conformant_add(ad->conform);
+
+ /* Naviframe */
+ ad->nf = elm_naviframe_add(ad->conform);
+ eext_object_event_callback_add(ad->nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
+ evas_object_size_hint_weight_set(ad->nf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_content_set(ad->conform, ad->nf);
+ evas_object_show(ad->nf);
+
+ /* Setting Menu */
+ show_setting_menu(ad->nf);
return true;
}
@@ -45,15 +70,28 @@ static void app_terminate(void *data)
// Empty
}
-int main(int argc, char *argv[])
+static void init_appdata()
{
- ui_app_lifecycle_callback_s event_callback = {0,};
+ ad = (appdata_s*)malloc(sizeof(appdata_s));
+ {
+ ad->win = NULL;
+ ad->conform = NULL;
+ ad->nf = NULL;
+ ad->circle_surface = NULL;
+ }
+}
- event_callback.create = app_create;
- event_callback.app_control = app_control;
- event_callback.pause = app_pause;
- event_callback.resume = app_resume;
- event_callback.terminate = app_terminate;
+int main(int argc, char *argv[])
+{
+ init_appdata();
+ ui_app_lifecycle_callback_s event_callback = {0,};
+ {
+ event_callback.create = app_create;
+ event_callback.app_control = app_control;
+ event_callback.pause = app_pause;
+ event_callback.resume = app_resume;
+ event_callback.terminate = app_terminate;
+ }
return ui_app_main(argc, argv, &event_callback, NULL);
}
diff --git a/src/ui/setting_home.c b/src/ui/setting_home.c
index 9c5c1fb..ac5b3a8 100644
--- a/src/ui/setting_home.c
+++ b/src/ui/setting_home.c
@@ -1,68 +1,163 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
#include "main.h"
-static int listener_num = 0;
-static event_listener listeners[4];
+#define MENU_SIZE 3
-extern void add_state_change_event_listener(event_listener listener)
+static Eina_Bool setting_menu_pop_cb(void *data, Elm_Object_Item *it)
{
- listeners[listener_num++] = listener;
+ do_haptic(50);
+ ui_app_exit();
+ return EINA_FALSE;
}
-extern void state_change_event(state_e state)
+static void convergence_power_on()
{
- int index;
+ 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);
+ }
+}
- for (index = 0; index < listener_num; index++) {
- listeners[index](state);
+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 Eina_Bool setting_menu_pop_cb(void *data, Elm_Object_Item *it)
+extern int get_convergence_power_state()
{
- ui_app_exit();
- return EINA_FALSE;
+ 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 app_language_changed(app_event_info_h event_info, void *user_data)
+typedef struct menu_info {
+ int index;
+ Elm_Object_Item *item;
+ char *text;
+ char *subtext;
+} menu_info_s;
+
+static menu_info_s **menu_info = NULL;
+
+static char *text_get_cb(void *data, Evas_Object *obj, const char *part)
{
- char *language;
+ int index = *(int*)data;
- int ret = app_event_get_language(event_info, &language);
- if (ret != APP_ERROR_NONE) {
- dlog_print(DLOG_ERROR, LOG_TAG, "app_event_get_language() failed. Err = %d.", ret);
- return;
+ if (!strcmp(part, "elm.text")) {
+ if (menu_info[index]->text == NULL){
+ return NULL;
+ }
+ return strdup((char*)menu_info[index]->text);
+
+ } else if (!strcmp(part, "elm.text.1")) {
+
+ if (get_convergence_power_state() == 0) {
+ menu_info[index]->subtext = "off";
+ } else {
+ menu_info[index]->subtext = "on";
+ }
+ return strdup((char*)menu_info[index]->subtext);
}
- dlog_print(DLOG_ERROR, LOG_TAG, "language = %s.", language);
+ return NULL;
+}
+
+static void menu_item_selected_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ int index = *(int*)data;
- if (language != NULL) {
- elm_language_set(language);
- free(language);
+ if(index == 3) {
+ return;
}
- dlog_print(DLOG_ERROR, LOG_TAG, "language = %s.", language);
+ do_haptic(50);
+
+ if (index == 0) {
+ if (get_convergence_power_state() == 0) {
+ convergence_power_on();
+ } else {
+ convergence_power_off();
+ }
+ elm_genlist_item_update(menu_info[index]->item);
- state_change_event(CHANGE_LANGUAGE);
+ } else if (index == 1) {
+ show_setting_item_device_list();
+
+ } else if (index == 2) {
+ show_setting_item_sign();
+ }
}
-extern void create_setting_menu(Evas_Object *parent)
+static void menu_item_append(Elm_Genlist_Item_Class *item_builder, Evas_Object *genlist, char *text, int index)
{
- app_event_handler_h handle = NULL;
- ui_app_add_event_handler(&handle, APP_EVENT_LANGUAGE_CHANGED, app_language_changed, NULL);
+ menu_info[index] = (menu_info_s *)calloc(sizeof(menu_info_s), 1);
+ {
+ menu_info[index]->index = index;
+ menu_info[index]->text = text;
+ menu_info[index]->item = elm_genlist_item_append(genlist, item_builder, &(menu_info[index]->index), NULL, ELM_GENLIST_ITEM_NONE, menu_item_selected_cb, &(menu_info[index]->index));
+ }
+}
- Evas_Object *background = elm_bg_add(parent);
- elm_object_content_set(parent, background);
- elm_bg_color_set(background, 255, 255, 255);
- evas_object_show(background);
+extern void show_setting_menu()
+{
+ menu_info = (menu_info_s **)calloc(sizeof(menu_info_s *), MENU_SIZE);
+
+ Evas_Object *menu = elm_genlist_add(ad->nf);
+ elm_genlist_mode_set(menu, ELM_LIST_COMPRESS);
- Evas_Object *layout = elm_grid_add(background);
- elm_object_content_set(background, layout);
- evas_object_show(layout);
+ Evas_Object *circle_genlist = eext_circle_object_genlist_add(menu, ad->circle_surface);
+ eext_circle_object_genlist_scroller_policy_set(circle_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
+ eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
{
- create_setting_item_power(layout);
- create_setting_item_sign(layout);
+ Elm_Genlist_Item_Class *style_1text_item_builder = elm_genlist_item_class_new();
+ {
+ style_1text_item_builder->item_style = "1text";
+ style_1text_item_builder->func.text_get = text_get_cb;
+ }
+
+ Elm_Genlist_Item_Class *style_2text_item_builder = elm_genlist_item_class_new();
+ {
+ style_2text_item_builder->item_style = "2text";
+ style_2text_item_builder->func.text_get = text_get_cb;
+ }
+
+ if(get_convergence_power_state() == 0){
+ menu_item_append(style_2text_item_builder, menu, "Power", 0);
+ } else {
+ menu_item_append(style_2text_item_builder, menu, "Power", 0);
+ }
+
+ menu_item_append(style_1text_item_builder, menu, ACCESS_CONTROL_TEXT, 1);
+ menu_item_append(style_1text_item_builder, menu, NOTICE_TEXT, 2);
+ menu_item_append(style_1text_item_builder, menu, NULL, 3);
+
+ elm_genlist_item_class_free(style_1text_item_builder);
+ elm_genlist_item_class_free(style_2text_item_builder);
+
}
+ evas_object_show(menu);
- Elm_Object_Item *menu = elm_naviframe_item_push(parent, "Convergence", NULL, NULL, background, NULL);
- elm_naviframe_item_pop_cb_set(menu, setting_menu_pop_cb, NULL);
-}
+ Elm_Object_Item *it = elm_naviframe_item_push(ad->nf, TITLE_TEXT, NULL, NULL, menu, NULL);
+ elm_naviframe_item_pop_cb_set(it, setting_menu_pop_cb, NULL);
+} \ No newline at end of file
diff --git a/src/ui/setting_item_allowed_device_list.c b/src/ui/setting_item_allowed_device_list.c
new file mode 100644
index 0000000..03b412d
--- /dev/null
+++ b/src/ui/setting_item_allowed_device_list.c
@@ -0,0 +1,274 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "main.h"
+
+static Elm_Genlist_Item_Class *item_builder = NULL;
+static Evas_Object *allowed_list = NULL;
+
+static int allowed_devices_index = -1;
+static device_info_s **allowed_devices_info = NULL;
+
+static Evas_Object *allowed_deivce_selected_menu = NULL;
+static device_info_s *selected_device = NULL;
+
+static Evas_Object *popup = NULL;
+
+static void cancel_btn_click_event(void *data, Evas_Object *obj, void *event_info)
+{
+ evas_object_del(popup);
+}
+
+static void ok_btn_click_event(void *data, Evas_Object *obj, void *event_info)
+{
+ do_haptic(50);
+
+ char *type = (char *)data;
+ if (!strcmp("Remove", type)) {
+ conv_internal_remove_acl_device(selected_device->mac_address);
+ } else if (!strcmp("Deny", type)) {
+ conv_internal_set_acl_state(selected_device->mac_address, selected_device->type, selected_device->name, 1);
+ }
+
+ evas_object_del(popup);
+}
+
+static void show_popup(char *type)
+{
+ popup = elm_popup_add(ad->win);
+ elm_object_style_set(popup, "circle");
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ {
+ Evas_Object *layout = elm_layout_add(popup);
+ elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons2");
+ {
+ elm_object_part_text_set(layout, "elm.text.title", "Access Control");
+
+ char text[1000];
+ if (!strcmp("Remove", type)) {
+ snprintf(text, sizeof(text), "%s '%s'?", REMOVE_SELECT_POPUP_TEXT, selected_device->name);
+ } else if (!strcmp("Deny", type)) {
+ snprintf(text, sizeof(text), "%s '%s'?", DENY_SELECT_POPUP_TEXT, selected_device->name);
+ }
+
+ elm_object_part_text_set(layout, "elm.text", text);
+ elm_object_content_set(popup, layout);
+ }
+
+ Evas_Object *cancel_btn = elm_button_add(popup);
+ elm_object_style_set(cancel_btn, "popup/circle/left");
+ evas_object_size_hint_weight_set(cancel_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ {
+ Evas_Object *cancel_btn_icon = elm_image_add(cancel_btn);
+ elm_image_file_set(cancel_btn_icon, ICON_DIR"/popup_btn_cancel.png", NULL);
+ evas_object_size_hint_weight_set(cancel_btn_icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_part_content_set(cancel_btn, "elm.swallow.content", cancel_btn_icon);
+ evas_object_show(cancel_btn_icon);
+ }
+ elm_object_part_content_set(popup, "button1", cancel_btn);
+ evas_object_smart_callback_add(cancel_btn, "clicked", cancel_btn_click_event, type);
+
+ Evas_Object *ok_btn = elm_button_add(popup);
+ elm_object_style_set(ok_btn, "popup/circle/right");
+ evas_object_size_hint_weight_set(ok_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ {
+ Evas_Object *ok_btn_icon = elm_image_add(ok_btn);
+ elm_image_file_set(ok_btn_icon, ICON_DIR"/popup_btn_check.png", NULL);
+ evas_object_size_hint_weight_set(ok_btn_icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_part_content_set(ok_btn, "elm.swallow.content", ok_btn_icon);
+ evas_object_show(ok_btn_icon);
+ }
+ elm_object_part_content_set(popup, "button2", ok_btn);
+ evas_object_smart_callback_add(ok_btn, "clicked", ok_btn_click_event, type);
+ }
+ evas_object_show(popup);
+}
+
+static void set_acl_device_list();
+
+static Eina_Bool allowed_deivce_selected_menu_popup_cb(void *data, Elm_Object_Item *it)
+{
+ do_haptic(50);
+ elm_genlist_clear(allowed_list);
+ set_acl_device_list();
+ return EINA_TRUE;
+}
+
+static void allowed_deivce_selected_menu_selected_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ do_haptic(50);
+ char *type = (char *)data;
+ show_popup(type);
+}
+
+static char *selected_menu_text_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ if((char*)data == NULL) return NULL;
+ return strdup((char*)data);
+}
+
+static void show_allowed_device_selected_popup(void *data, Evas_Object *obj, void *event_info)
+{
+ 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;
+
+ allowed_deivce_selected_menu = elm_genlist_add(ad->nf);
+ elm_genlist_mode_set(allowed_deivce_selected_menu, ELM_LIST_COMPRESS);
+
+ Evas_Object *circle_genlist = eext_circle_object_genlist_add(allowed_deivce_selected_menu, ad->circle_surface);
+ eext_circle_object_genlist_scroller_policy_set(circle_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
+ eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
+ {
+ Elm_Genlist_Item_Class *item_builder = elm_genlist_item_class_new();
+ {
+ item_builder->item_style = "1text";
+ item_builder->func.text_get = selected_menu_text_get_cb;
+ }
+
+ elm_genlist_item_append(allowed_deivce_selected_menu, item_builder, REMOVE_BUTTON_TEXT, NULL, ELM_GENLIST_ITEM_NONE, allowed_deivce_selected_menu_selected_cb, "Remove");
+ elm_genlist_item_append(allowed_deivce_selected_menu, item_builder, DENY_BUTTON_TEXT, NULL, ELM_GENLIST_ITEM_NONE, allowed_deivce_selected_menu_selected_cb, "Deny");
+ elm_genlist_item_class_free(item_builder);
+ }
+ evas_object_show(allowed_deivce_selected_menu);
+
+ Elm_Object_Item *it = elm_naviframe_item_push(ad->nf, ACCESS_CONTROL_TEXT, NULL, NULL, allowed_deivce_selected_menu, NULL);
+ elm_naviframe_item_pop_cb_set(it, allowed_deivce_selected_menu_popup_cb, NULL);
+}
+
+static char* text_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ dlog_print(DLOG_ERROR, LOG_TAG, "text_get_cb part = %s", part);
+
+ device_info_s *info = (device_info_s *)data;
+
+ if (!strcmp(part, "elm.text")) {
+ if (info->name == NULL) return NULL;
+ return strdup((char*)info->name);
+ } else if (!strcmp(part, "elm.text.1")) {
+ if (info->mac_address == NULL) return NULL;
+ return strdup((char*)info->mac_address);
+ }
+
+ return NULL;
+}
+
+static Evas_Object* content_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ dlog_print(DLOG_ERROR, LOG_TAG, "content_get_cb part = %s", part);
+
+ device_info_s *info = (device_info_s *)data;
+
+ if (!strcmp(part, "elm.icon")) {
+
+ Evas_Object *img = elm_image_add(obj);
+
+ if (info->type != NULL) {
+ if (!strcmp(DEVICE_TYPE_MOBILE, info->type)) {
+ elm_image_file_set(img, ICON_DIR"/device_type_icon_mobilephone.png", NULL);
+ } else if (!strcmp(DEVICE_TYPE_TV, info->type)) {
+ elm_image_file_set(img, ICON_DIR"/device_type_icon_display.png", NULL);
+ } else if (!strcmp(DEVICE_TYPE_WEARABLE, info->type)) {
+ elm_image_file_set(img, ICON_DIR"/device_type_icon_wrist.png", NULL);
+ } else {
+ elm_image_file_set(img, ICON_DIR"/device_type_icon_multimedia.png", NULL);
+ }
+
+ } else {
+ elm_image_file_set(img, ICON_DIR"/device_type_icon_multimedia.png", NULL);
+ }
+
+ return img;
+
+ } else {
+ return NULL;
+ }
+}
+
+static void acl_device_info(char *mac_address, char *device_type, char *device_name, int access_control_state, void *user_data)
+{
+ if(access_control_state == 0) {
+ int index = ++allowed_devices_index;
+ allowed_devices_info[index] = (device_info_s *) calloc(sizeof(device_info_s), 1);
+ allowed_devices_info[index]->list_type = LIST_TYPE_PERMITTED;
+ allowed_devices_info[index]->index = index;
+ allowed_devices_info[index]->name = strdup(device_name);
+ allowed_devices_info[index]->type = strdup(device_type);
+ allowed_devices_info[index]->mac_address = strdup(mac_address);
+
+ elm_genlist_item_append(allowed_list, item_builder, allowed_devices_info[index], NULL, ELM_GENLIST_ITEM_NONE, show_allowed_device_selected_popup, allowed_devices_info[index]);
+ }
+}
+
+static void set_acl_device_list()
+{
+ int index;
+
+ if (allowed_devices_info != NULL) {
+
+ for (index = 0; index < STORAGE_SIZE; index++) {
+ if(allowed_devices_info[index] == NULL) break;
+ free(allowed_devices_info[index]);
+ allowed_devices_info[index] = NULL;
+ }
+
+ free(allowed_devices_info);
+ allowed_devices_info = NULL;
+ }
+
+ allowed_devices_index = -1;
+ allowed_devices_info = (device_info_s **) calloc(STORAGE_SIZE, sizeof(device_info_s *));
+
+ conv_internal_get_acl_list(acl_device_info, NULL);
+}
+
+static Eina_Bool setting_menu_pop_cb(void *data, Elm_Object_Item *it)
+{
+ do_haptic(50);
+ return EINA_TRUE;
+}
+
+extern void show_setting_item_allowed_device_list()
+{
+ selected_device = (device_info_s *) calloc(sizeof(device_info_s), 1);
+
+ allowed_list = elm_genlist_add(ad->nf);
+ elm_genlist_mode_set(allowed_list, ELM_LIST_COMPRESS);
+
+ Evas_Object *circle_genlist = eext_circle_object_genlist_add(allowed_list, ad->circle_surface);
+ eext_circle_object_genlist_scroller_policy_set(circle_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
+ eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
+ {
+ item_builder = elm_genlist_item_class_new();
+ {
+ item_builder->item_style = "2text.1icon.divider";
+ item_builder->func.text_get = text_get_cb;
+ item_builder->func.content_get = content_get_cb;
+ }
+ }
+ evas_object_show(allowed_list);
+
+ Elm_Object_Item *it = elm_naviframe_item_push(ad->nf, ALLOWED_DEVICE_LIST_TEXT, NULL, NULL, allowed_list, NULL);
+ elm_naviframe_item_pop_cb_set(it, setting_menu_pop_cb, NULL);
+
+ set_acl_device_list();
+}
+
diff --git a/src/ui/setting_item_denied_device_list.c b/src/ui/setting_item_denied_device_list.c
new file mode 100644
index 0000000..21852c2
--- /dev/null
+++ b/src/ui/setting_item_denied_device_list.c
@@ -0,0 +1,274 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "main.h"
+
+static Elm_Genlist_Item_Class *item_builder = NULL;
+static Evas_Object *denied_list = NULL;
+
+static int denied_devices_index = -1;
+static device_info_s **denied_devices_info = NULL;
+
+static Evas_Object *denied_deivce_selected_menu = NULL;
+static device_info_s *selected_device = NULL;
+
+static Evas_Object *popup = NULL;
+
+static void cancel_btn_click_event(void *data, Evas_Object *obj, void *event_info)
+{
+ evas_object_del(popup);
+}
+
+static void ok_btn_click_event(void *data, Evas_Object *obj, void *event_info)
+{
+ do_haptic(50);
+
+ char *type = (char *)data;
+ if (!strcmp("Remove", type)) {
+ conv_internal_remove_acl_device(selected_device->mac_address);
+ } else if (!strcmp("Allow", type)) {
+ conv_internal_set_acl_state(selected_device->mac_address, selected_device->type, selected_device->name, 1);
+ }
+
+ evas_object_del(popup);
+}
+
+static void show_popup(char *type)
+{
+ popup = elm_popup_add(ad->win);
+ elm_object_style_set(popup, "circle");
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ {
+ Evas_Object *layout = elm_layout_add(popup);
+ elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons2");
+ {
+ elm_object_part_text_set(layout, "elm.text.title", "Access Control");
+
+ char text[1000];
+ if (!strcmp("Remove", type)) {
+ snprintf(text, sizeof(text), "%s '%s'?", REMOVE_SELECT_POPUP_TEXT, selected_device->name);
+ } else if (!strcmp("Allow", type)) {
+ snprintf(text, sizeof(text), "%s '%s'?", ALLOW_SELECT_POPUP_TEXT, selected_device->name);
+ }
+
+ elm_object_part_text_set(layout, "elm.text", text);
+ elm_object_content_set(popup, layout);
+ }
+
+ Evas_Object *cancel_btn = elm_button_add(popup);
+ elm_object_style_set(cancel_btn, "popup/circle/left");
+ evas_object_size_hint_weight_set(cancel_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ {
+ Evas_Object *cancel_btn_icon = elm_image_add(cancel_btn);
+ elm_image_file_set(cancel_btn_icon, ICON_DIR"/popup_btn_cancel.png", NULL);
+ evas_object_size_hint_weight_set(cancel_btn_icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_part_content_set(cancel_btn, "elm.swallow.content", cancel_btn_icon);
+ evas_object_show(cancel_btn_icon);
+ }
+ elm_object_part_content_set(popup, "button1", cancel_btn);
+ evas_object_smart_callback_add(cancel_btn, "clicked", cancel_btn_click_event, type);
+
+ Evas_Object *ok_btn = elm_button_add(popup);
+ elm_object_style_set(ok_btn, "popup/circle/right");
+ evas_object_size_hint_weight_set(ok_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ {
+ Evas_Object *ok_btn_icon = elm_image_add(ok_btn);
+ elm_image_file_set(ok_btn_icon, ICON_DIR"/popup_btn_check.png", NULL);
+ evas_object_size_hint_weight_set(ok_btn_icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_part_content_set(ok_btn, "elm.swallow.content", ok_btn_icon);
+ evas_object_show(ok_btn_icon);
+ }
+ elm_object_part_content_set(popup, "button2", ok_btn);
+ evas_object_smart_callback_add(ok_btn, "clicked", ok_btn_click_event, type);
+ }
+ evas_object_show(popup);
+}
+
+static void set_acl_device_list();
+
+static Eina_Bool denied_deivce_selected_menu_popup_cb(void *data, Elm_Object_Item *it)
+{
+ do_haptic(50);
+ elm_genlist_clear(denied_list);
+ set_acl_device_list();
+ return EINA_TRUE;
+}
+
+static void denied_deivce_selected_menu_selected_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ do_haptic(50);
+ char *type = (char *)data;
+ show_popup(type);
+}
+
+static char *selected_menu_text_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ if((char*)data == NULL) return NULL;
+ return strdup((char*)data);
+}
+
+static void show_denied_device_selected_popup(void *data, Evas_Object *obj, void *event_info)
+{
+ 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;
+
+ denied_deivce_selected_menu = elm_genlist_add(ad->nf);
+ elm_genlist_mode_set(denied_deivce_selected_menu, ELM_LIST_COMPRESS);
+
+ Evas_Object *circle_genlist = eext_circle_object_genlist_add(denied_deivce_selected_menu, ad->circle_surface);
+ eext_circle_object_genlist_scroller_policy_set(circle_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
+ eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
+ {
+ Elm_Genlist_Item_Class *item_builder = elm_genlist_item_class_new();
+ {
+ item_builder->item_style = "1text";
+ item_builder->func.text_get = selected_menu_text_get_cb;
+ }
+
+ elm_genlist_item_append(denied_deivce_selected_menu, item_builder, REMOVE_BUTTON_TEXT, NULL, ELM_GENLIST_ITEM_NONE, denied_deivce_selected_menu_selected_cb, "Remove");
+ elm_genlist_item_append(denied_deivce_selected_menu, item_builder, ALLOW_BUTTON_TEXT, NULL, ELM_GENLIST_ITEM_NONE, denied_deivce_selected_menu_selected_cb, "Allow");
+ elm_genlist_item_class_free(item_builder);
+ }
+ evas_object_show(denied_deivce_selected_menu);
+
+ Elm_Object_Item *it = elm_naviframe_item_push(ad->nf, ACCESS_CONTROL_TEXT, NULL, NULL, denied_deivce_selected_menu, NULL);
+ elm_naviframe_item_pop_cb_set(it, denied_deivce_selected_menu_popup_cb, NULL);
+}
+
+static char* text_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ dlog_print(DLOG_ERROR, LOG_TAG, "text_get_cb part = %s", part);
+
+ device_info_s *info = (device_info_s *)data;
+
+ if (!strcmp(part, "elm.text")) {
+ if (info->name == NULL) return NULL;
+ return strdup((char*)info->name);
+ } else if (!strcmp(part, "elm.text.1")) {
+ if (info->mac_address == NULL) return NULL;
+ return strdup((char*)info->mac_address);
+ }
+
+ return NULL;
+}
+
+static Evas_Object* content_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ dlog_print(DLOG_ERROR, LOG_TAG, "content_get_cb part = %s", part);
+
+ device_info_s *info = (device_info_s *)data;
+
+ if (!strcmp(part, "elm.icon")) {
+
+ Evas_Object *img = elm_image_add(obj);
+
+ if (info->type != NULL) {
+ if (!strcmp(DEVICE_TYPE_MOBILE, info->type)) {
+ elm_image_file_set(img, ICON_DIR"/device_type_icon_mobilephone.png", NULL);
+ } else if (!strcmp(DEVICE_TYPE_TV, info->type)) {
+ elm_image_file_set(img, ICON_DIR"/device_type_icon_display.png", NULL);
+ } else if (!strcmp(DEVICE_TYPE_WEARABLE, info->type)) {
+ elm_image_file_set(img, ICON_DIR"/device_type_icon_wrist.png", NULL);
+ } else {
+ elm_image_file_set(img, ICON_DIR"/device_type_icon_multimedia.png", NULL);
+ }
+
+ } else {
+ elm_image_file_set(img, ICON_DIR"/device_type_icon_multimedia.png", NULL);
+ }
+
+ return img;
+
+ } else {
+ return NULL;
+ }
+}
+
+static void acl_device_info(char *mac_address, char *device_type, char *device_name, int access_control_state, void *user_data)
+{
+ 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, item_builder, denied_devices_info[index], NULL, ELM_GENLIST_ITEM_NONE, show_denied_device_selected_popup, denied_devices_info[index]);
+ }
+}
+
+static void set_acl_device_list()
+{
+ int index;
+
+ 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 *));
+
+ conv_internal_get_acl_list(acl_device_info, NULL);
+}
+
+static Eina_Bool setting_menu_pop_cb(void *data, Elm_Object_Item *it)
+{
+ do_haptic(50);
+ return EINA_TRUE;
+}
+
+extern void show_setting_item_denied_device_list()
+{
+ selected_device = (device_info_s *) calloc(sizeof(device_info_s), 1);
+
+ denied_list = elm_genlist_add(ad->nf);
+ elm_genlist_mode_set(denied_list, ELM_LIST_COMPRESS);
+
+ Evas_Object *circle_genlist = eext_circle_object_genlist_add(denied_list, ad->circle_surface);
+ eext_circle_object_genlist_scroller_policy_set(circle_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
+ eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
+ {
+ item_builder = elm_genlist_item_class_new();
+ {
+ item_builder->item_style = "2text.1icon.divider";
+ item_builder->func.text_get = text_get_cb;
+ item_builder->func.content_get = content_get_cb;
+ }
+ }
+ evas_object_show(denied_list);
+
+ Elm_Object_Item *it = elm_naviframe_item_push(ad->nf, DENIED_DEVICE_LIST_TEXT, NULL, NULL, denied_list, NULL);
+ elm_naviframe_item_pop_cb_set(it, setting_menu_pop_cb, NULL);
+
+ set_acl_device_list();
+}
+
diff --git a/src/ui/setting_item_device_list.c b/src/ui/setting_item_device_list.c
new file mode 100644
index 0000000..0c78567
--- /dev/null
+++ b/src/ui/setting_item_device_list.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "main.h"
+
+static Eina_Bool setting_menu_pop_cb(void *data, Elm_Object_Item *it)
+{
+ do_haptic(50);
+ return EINA_TRUE;
+}
+
+static char *text_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ if((char*)data == NULL) return NULL;
+ return strdup((char*)data);
+}
+
+static void menu_item_selected_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ char *menu = (char*)data;
+
+ if(menu == NULL) return;
+
+ do_haptic(50);
+
+ if (!strcmp(ALLOWED_DEVICE_LIST_TEXT, menu)) {
+ show_setting_item_allowed_device_list();
+ } else if (!strcmp(DENIED_DEVICE_LIST_TEXT, menu)) {
+ show_setting_item_denied_device_list();
+ } else if (!strcmp(AVAILABLE_DEVICE_LIST_TEXT, menu)) {
+ show_setting_item_discovery();
+ }
+}
+
+extern void show_setting_item_device_list()
+{
+ Elm_Object_Item *it = NULL;
+
+ if(get_convergence_power_state() == 0){
+
+ Evas_Object *box = elm_box_add(ad->nf);
+ elm_box_horizontal_set(box, EINA_FALSE);
+ {
+ Evas_Object *scroller = elm_scroller_add(box);
+ evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
+ elm_object_style_set(scroller, "effect");
+ {
+ char buf[1024];
+ snprintf(buf, sizeof(buf), "<align=center><br>%s<br></align>", TURN_ON_THE_POWER_TEXT);
+
+ Evas_Object *sign_item = elm_label_add(scroller);
+ elm_object_text_set(sign_item, buf);
+ evas_object_size_hint_weight_set(sign_item, 0.5, 0.5);
+ elm_label_line_wrap_set(sign_item, ELM_WRAP_WORD);
+ // elm_label_wrap_width_set(sign_item, 200);
+ // evas_object_size_hint_min_set(sign_item, 100, 100);
+ elm_object_content_set(scroller, sign_item);
+ }
+ evas_object_show(scroller);
+ elm_box_pack_end(box, scroller);
+ }
+ evas_object_show(box);
+
+ it = elm_naviframe_item_push(ad->nf, TITLE_TEXT, NULL, NULL, box, NULL);
+
+ } else {
+
+ Evas_Object *menu = elm_genlist_add(ad->nf);
+ elm_genlist_mode_set(menu, ELM_LIST_COMPRESS);
+
+ Evas_Object *circle_genlist = eext_circle_object_genlist_add(menu, ad->circle_surface);
+ eext_circle_object_genlist_scroller_policy_set(circle_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
+ eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
+ {
+ Elm_Genlist_Item_Class *item_builder = elm_genlist_item_class_new();
+ {
+ item_builder->item_style = "1text";
+ item_builder->func.text_get = text_get_cb;
+ }
+
+ elm_genlist_item_append(menu, item_builder, ALLOWED_DEVICE_LIST_TEXT, NULL, ELM_GENLIST_ITEM_NONE, menu_item_selected_cb, ALLOWED_DEVICE_LIST_TEXT);
+ elm_genlist_item_append(menu, item_builder, DENIED_DEVICE_LIST_TEXT, NULL, ELM_GENLIST_ITEM_NONE, menu_item_selected_cb, DENIED_DEVICE_LIST_TEXT);
+ elm_genlist_item_append(menu, item_builder, AVAILABLE_DEVICE_LIST_TEXT, NULL, ELM_GENLIST_ITEM_NONE, menu_item_selected_cb, AVAILABLE_DEVICE_LIST_TEXT);
+ elm_genlist_item_append(menu, item_builder, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
+
+ elm_genlist_item_class_free(item_builder);
+ }
+ evas_object_show(menu);
+
+ it = elm_naviframe_item_push(ad->nf, TITLE_TEXT, NULL, NULL, menu, NULL);
+ }
+
+ elm_naviframe_item_pop_cb_set(it, setting_menu_pop_cb, NULL);
+}
diff --git a/src/ui/setting_item_discovery.c b/src/ui/setting_item_discovery.c
new file mode 100644
index 0000000..45e911d
--- /dev/null
+++ b/src/ui/setting_item_discovery.c
@@ -0,0 +1,312 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "main.h"
+
+#define DISCOVERY_TIME 100
+
+static conv_h conv_handle = NULL;
+
+static Elm_Genlist_Item_Class *item_builder = NULL;
+static Evas_Object *discovered_list = NULL;
+
+static int discovered_devices_index = -1;
+static device_info_s **discovered_devices_info = NULL;
+
+static Evas_Object *discovery_deivce_selected_menu = NULL;
+static device_info_s *selected_device = NULL;
+
+static Evas_Object *popup = NULL;
+
+static void cancel_btn_click_event(void *data, Evas_Object *obj, void *event_info)
+{
+ evas_object_del(popup);
+}
+
+static void ok_btn_click_event(void *data, Evas_Object *obj, void *event_info)
+{
+ do_haptic(50);
+
+ char *type = (char *)data;
+ if (!strcmp("Allow", type)) {
+ conv_internal_set_acl_state(selected_device->mac_address, selected_device->type, selected_device->name, 0);
+ } else if (!strcmp("Deny", type)) {
+ conv_internal_set_acl_state(selected_device->mac_address, selected_device->type, selected_device->name, 1);
+ }
+
+ evas_object_del(popup);
+}
+
+static void show_popup(char *type)
+{
+ popup = elm_popup_add(ad->win);
+ elm_object_style_set(popup, "circle");
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ {
+ Evas_Object *layout = elm_layout_add(popup);
+ elm_layout_theme_set(layout, "layout", "popup", "content/circle/buttons2");
+ {
+ elm_object_part_text_set(layout, "elm.text.title", ACCESS_CONTROL_TEXT);
+
+ char text[1000];
+ if (!strcmp("Allow", type)) {
+ snprintf(text, sizeof(text), "%s '%s'?", ALLOW_SELECT_POPUP_TEXT, selected_device->name);
+ } else if (!strcmp("Deny", type)) {
+ snprintf(text, sizeof(text), "%s '%s'?", DENY_SELECT_POPUP_TEXT, selected_device->name);
+ }
+
+ elm_object_part_text_set(layout, "elm.text", text);
+ elm_object_content_set(popup, layout);
+ }
+
+ Evas_Object *cancel_btn = elm_button_add(popup);
+ elm_object_style_set(cancel_btn, "popup/circle/left");
+ evas_object_size_hint_weight_set(cancel_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ {
+ Evas_Object *cancel_btn_icon = elm_image_add(cancel_btn);
+ elm_image_file_set(cancel_btn_icon, ICON_DIR"/popup_btn_cancel.png", NULL);
+ evas_object_size_hint_weight_set(cancel_btn_icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_part_content_set(cancel_btn, "elm.swallow.content", cancel_btn_icon);
+ evas_object_show(cancel_btn_icon);
+ }
+ elm_object_part_content_set(popup, "button1", cancel_btn);
+ evas_object_smart_callback_add(cancel_btn, "clicked", cancel_btn_click_event, type);
+
+ Evas_Object *ok_btn = elm_button_add(popup);
+ elm_object_style_set(ok_btn, "popup/circle/right");
+ evas_object_size_hint_weight_set(ok_btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ {
+ Evas_Object *ok_btn_icon = elm_image_add(ok_btn);
+ elm_image_file_set(ok_btn_icon, ICON_DIR"/popup_btn_check.png", NULL);
+ evas_object_size_hint_weight_set(ok_btn_icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_object_part_content_set(ok_btn, "elm.swallow.content", ok_btn_icon);
+ evas_object_show(ok_btn_icon);
+ }
+ elm_object_part_content_set(popup, "button2", ok_btn);
+ evas_object_smart_callback_add(ok_btn, "clicked", ok_btn_click_event, type);
+ }
+ evas_object_show(popup);
+}
+
+static Eina_Bool discovery_deivce_selected_menu_popup_cb(void *data, Elm_Object_Item *it)
+{
+ do_haptic(50);
+ return EINA_TRUE;
+}
+
+static void discovery_deivce_selected_menu_selected_cb(void *data, Evas_Object *obj, void *event_info)
+{
+ do_haptic(50);
+ char *type = (char *)data;
+ show_popup(type);
+}
+
+static char *selected_menu_text_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ if((char*)data == NULL) return NULL;
+ return strdup((char*)data);
+}
+
+static void show_discovery_deivce_selected_menu(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;
+
+ discovery_deivce_selected_menu = elm_genlist_add(ad->nf);
+ elm_genlist_mode_set(discovery_deivce_selected_menu, ELM_LIST_COMPRESS);
+
+ Evas_Object *circle_genlist = eext_circle_object_genlist_add(discovery_deivce_selected_menu, ad->circle_surface);
+ eext_circle_object_genlist_scroller_policy_set(circle_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
+ eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
+ {
+ Elm_Genlist_Item_Class *item_builder = elm_genlist_item_class_new();
+ {
+ item_builder->item_style = "1text";
+ item_builder->func.text_get = selected_menu_text_get_cb;
+ }
+
+ elm_genlist_item_append(discovery_deivce_selected_menu, item_builder, ALLOW_BUTTON_TEXT, NULL, ELM_GENLIST_ITEM_NONE, discovery_deivce_selected_menu_selected_cb, "Allow");
+ elm_genlist_item_append(discovery_deivce_selected_menu, item_builder, DENY_BUTTON_TEXT, NULL, ELM_GENLIST_ITEM_NONE, discovery_deivce_selected_menu_selected_cb, "Deny");
+ elm_genlist_item_class_free(item_builder);
+ }
+ evas_object_show(discovery_deivce_selected_menu);
+
+ Elm_Object_Item *it = elm_naviframe_item_push(ad->nf, ACCESS_CONTROL_TEXT, NULL, NULL, discovery_deivce_selected_menu, NULL);
+ elm_naviframe_item_pop_cb_set(it, discovery_deivce_selected_menu_popup_cb, NULL);
+}
+
+static char* text_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ device_info_s *info = (device_info_s *)data;
+
+ if (!strcmp(part, "elm.text")) {
+ if (info->name == NULL) return NULL;
+ return strdup((char*)info->name);
+ } else if (!strcmp(part, "elm.text.1")) {
+ if (info->mac_address == NULL) return NULL;
+ return strdup((char*)info->mac_address);
+ }
+
+ return NULL;
+}
+
+static Evas_Object* content_get_cb(void *data, Evas_Object *obj, const char *part)
+{
+ device_info_s *info = (device_info_s *)data;
+
+ if (!strcmp(part, "elm.icon")) {
+
+ Evas_Object *img = elm_image_add(obj);
+
+ if (info->type != NULL) {
+ if (!strcmp(DEVICE_TYPE_MOBILE, info->type)) {
+ elm_image_file_set(img, ICON_DIR"/device_type_icon_mobilephone.png", NULL);
+ } else if (!strcmp(DEVICE_TYPE_TV, info->type)) {
+ elm_image_file_set(img, ICON_DIR"/device_type_icon_display.png", NULL);
+ } else if (!strcmp(DEVICE_TYPE_WEARABLE, info->type)) {
+ elm_image_file_set(img, ICON_DIR"/device_type_icon_wrist.png", NULL);
+ } else {
+ elm_image_file_set(img, ICON_DIR"/device_type_icon_multimedia.png", NULL);
+ }
+
+ } else {
+ elm_image_file_set(img, ICON_DIR"/device_type_icon_multimedia.png", NULL);
+ }
+
+ return img;
+
+ } 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, item_builder, discovered_devices_info[index], NULL, ELM_GENLIST_ITEM_NONE, show_discovery_deivce_selected_menu, discovered_devices_info[index]);
+
+ break;
+
+ case CONV_DISCOVERY_RESULT_FINISHED :
+ conv_destroy(conv_handle);
+ conv_handle = NULL;
+ return;
+ }
+}
+
+static void discovery_start()
+{
+ if(conv_handle == NULL) {
+
+ int index;
+
+ 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 *));
+
+ 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 Eina_Bool setting_menu_pop_cb(void *data, Elm_Object_Item *it)
+{
+ discovery_stop();
+ do_haptic(50);
+ return EINA_TRUE;
+}
+
+extern void show_setting_item_discovery()
+{
+ selected_device = (device_info_s *) calloc(sizeof(device_info_s), 1);
+
+ discovered_list = elm_genlist_add(ad->nf);
+ elm_genlist_mode_set(discovered_list, ELM_LIST_COMPRESS);
+
+ Evas_Object *circle_genlist = eext_circle_object_genlist_add(discovered_list, ad->circle_surface);
+ eext_circle_object_genlist_scroller_policy_set(circle_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
+ eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
+ {
+ item_builder = elm_genlist_item_class_new();
+ {
+ item_builder->item_style = "2text.1icon.divider";
+ item_builder->func.text_get = text_get_cb;
+ item_builder->func.content_get = content_get_cb;
+ }
+ }
+ evas_object_show(discovered_list);
+
+ Elm_Object_Item *it = elm_naviframe_item_push(ad->nf, ALLOWED_DEVICE_LIST_TEXT, NULL, NULL, discovered_list, NULL);
+ elm_naviframe_item_pop_cb_set(it, setting_menu_pop_cb, NULL);
+
+ discovery_start();
+}
diff --git a/src/ui/setting_item_power.c b/src/ui/setting_item_power.c
deleted file mode 100644
index 068abf6..0000000
--- a/src/ui/setting_item_power.c
+++ /dev/null
@@ -1,90 +0,0 @@
-#include "main.h"
-
-static Evas_Object *power_switch = NULL;
-
-static void state_change_event_listener (state_e state)
-{
- switch (state)
- {
- case POWER_ON :
- elm_check_state_set(power_switch, EINA_TRUE);
- break;
-
- case POWER_OFF :
- elm_check_state_set(power_switch, EINA_FALSE);
- break;
-
- default :
- break;
- }
-}
-
-static void power_switch_changed_cb(void *data, Evas_Object *obj, void *event_info)
-{
- if (elm_check_state_get(obj) == EINA_TRUE) {
- convergence_power_on();
- state_change_event(POWER_ON);
- } else {
- convergence_power_off();
- state_change_event(POWER_OFF);
- }
-}
-
-static Evas_Object* content_get_cb(void *data, Evas_Object *obj, const char *part)
-{
- if (!strcmp("elm.swallow.end", part)) {
-
- power_switch = elm_check_add(obj);
- elm_object_style_set(power_switch, "on&off");
- evas_object_smart_callback_add(power_switch, "changed", power_switch_changed_cb, NULL);
- return power_switch;
- }
-
- return NULL;
-}
-
-static char* text_get_cb(void *data, Evas_Object *obj, const char *part)
-{
- if (!strcmp("elm.text", part)) {
- return strdup("Convergence");
- }
-
- return NULL;
-}
-
-static void power_item_realized_cb(void *data, Evas_Object *obj, void *event_info)
-{
- if (get_convergence_power_state() == 1) {
- convergence_power_on();
- state_change_event(POWER_ON);
- }
-
- else {
- convergence_power_off();
- state_change_event(POWER_OFF);
- }
-}
-
-extern void create_setting_item_power(Evas_Object *parent)
-{
- add_state_change_event_listener(state_change_event_listener);
-
- Evas_Object *power_item = elm_genlist_add(parent);
- elm_genlist_mode_set(power_item, ELM_LIST_COMPRESS);
- evas_object_smart_callback_add(power_item, "realized", power_item_realized_cb, NULL);
- elm_grid_pack(parent, power_item, 0, 0, 100, 10);
- evas_object_show(power_item);
- {
- Elm_Genlist_Item_Class *item_builder = elm_genlist_item_class_new();
- {
- item_builder->item_style = "default";
- item_builder->func.content_get = content_get_cb;
- item_builder->func.text_get = text_get_cb;
- }
-
- Elm_Object_Item *item = elm_genlist_item_append(power_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/ui/setting_item_sign.c b/src/ui/setting_item_sign.c
index 3356d85..669f2a7 100644
--- a/src/ui/setting_item_sign.c
+++ b/src/ui/setting_item_sign.c
@@ -1,65 +1,59 @@
-#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);
- break;
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
- case POWER_OFF :
- notice = POWER_OFF_SIGN_TEXT;
- elm_genlist_realized_items_update(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;
- }
-}
+#include "main.h"
-static char* text_get_cb(void *data, Evas_Object *obj, const char *part)
+static Eina_Bool setting_menu_pop_cb(void *data, Elm_Object_Item *it)
{
- if (!strcmp("elm.text.multiline", part)) {
- char buf[1024];
- snprintf(buf, sizeof(buf), "<font color=#3DB9CCFF>Notice</font><br>%s", notice);
- return strdup(buf);
- }
-
- return NULL;
+ do_haptic(50);
+ return EINA_TRUE;
}
-extern void create_setting_item_sign(Evas_Object *parent)
+extern void show_setting_item_sign()
{
- add_state_change_event_listener(state_change_event_listener);
-
- 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);
+ Evas_Object *box = elm_box_add(ad->nf);
+ elm_box_horizontal_set(box, EINA_FALSE);
{
- Elm_Genlist_Item_Class *item_builder = elm_genlist_item_class_new();
+ Evas_Object *scroller = elm_scroller_add(box);
+ evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
+ elm_object_style_set(scroller, "effect");
{
- item_builder->item_style = "multiline";
- item_builder->func.text_get = text_get_cb;
- }
+ char buf[1024];
+ if (get_convergence_power_state() == 0) {
+ snprintf(buf, sizeof(buf), "<align=center><br>[%s]<br><br>%s</align>", NOTICE_TEXT, POWER_OFF_NOTICE_TEXT);
+ } else {
+ snprintf(buf, sizeof(buf), "<align=center><br>[%s]<br><br>%s</align>", NOTICE_TEXT, POWER_ON_NOTICE_TEXT);
+ }
- 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);
+ Evas_Object *sign_item = elm_label_add(scroller);
+ elm_object_text_set(sign_item, buf);
+ evas_object_size_hint_weight_set(sign_item, 0.5, 0.5);
+ elm_label_line_wrap_set(sign_item, ELM_WRAP_WORD);
+ // elm_label_wrap_width_set(sign_item, 200);
+ // evas_object_size_hint_min_set(sign_item, 100, 100);
+ elm_object_content_set(scroller, sign_item);
+ }
- elm_genlist_item_class_free(item_builder);
+ evas_object_show(scroller);
+ elm_box_pack_end(box, scroller);
}
+ evas_object_show(box);
+
+ Elm_Object_Item *it = elm_naviframe_item_push(ad->nf, TITLE_TEXT, NULL, NULL, box, NULL);
+ elm_naviframe_item_pop_cb_set(it, setting_menu_pop_cb, NULL);
}
diff --git a/src/util.c b/src/util.c
new file mode 100644
index 0000000..ef5ac0b
--- /dev/null
+++ b/src/util.c
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#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