diff options
author | segwon <segwon.han@samsung.com> | 2016-11-15 21:48:37 +0900 |
---|---|---|
committer | segwon <segwon.han@samsung.com> | 2016-11-15 21:49:43 +0900 |
commit | 30f28b2dd68b92cf426a434a16bc5a101d164335 (patch) | |
tree | bed7336f3b058e83ec9064d294d42f3f4df75968 | |
parent | 8ff6034ef7db03343c7c3ecd9752102440a346cb (diff) | |
download | d2d-conv-setting-30f28b2dd68b92cf426a434a16bc5a101d164335.tar.gz d2d-conv-setting-30f28b2dd68b92cf426a434a16bc5a101d164335.tar.bz2 d2d-conv-setting-30f28b2dd68b92cf426a434a16bc5a101d164335.zip |
Addition ACL(discovery/permit/deny) module.submit/tizen_3.0/20161121.011946accepted/tizen/3.0/mobile/20161121.234516
Signed-off-by: segwon <segwon.han@samsung.com>
Change-Id: I5eaeca9461660527ed9ff17eeb4058f169198e0f
30 files changed, 646 insertions, 88 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index bc378ca..976bd87 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,6 @@ SET(PACKAGE org.tizen.d2d-conv-setting) FILE(GLOB SRCS src/*.c src/ui/*.c - src/convergence/*.c ) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/inc) @@ -26,9 +25,10 @@ ENDFOREACH(flag) pkg_check_modules(TIZEN_PKG REQUIRED dlog + appcore-efl capi-appfw-application capi-system-system-settings - appcore-efl + capi-system-device capi-appfw-app-manager d2d-conv-manager ) @@ -48,11 +48,13 @@ SET(BINDIR "${PREFIX}/bin") SET(SHDIR "${PREFIX}/shared") SET(RESDIR "${PREFIX}/res") SET(LOCALEDIR "${RESDIR}/locale") +SET(IMGDIR "${RESDIR}/images") ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"") ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"") ADD_DEFINITIONS("-DLOCALE_DIR=\"${LOCALEDIR}\"") +ADD_DEFINITIONS("-DICON_DIR=\"${IMGDIR}\"") ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${PKG_LDFLAGS}) @@ -64,5 +66,7 @@ INSTALL(FILES ${CMAKE_SOURCE_DIR}/${PACKAGE}.png DESTINATION ${SHDIR}/res/) CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/${PACKAGE}.xml ${CMAKE_SOURCE_DIR}/${PACKAGE}.xml @ONLY) INSTALL(FILES ${CMAKE_SOURCE_DIR}/${PACKAGE}.xml DESTINATION ${PKG_MANIFEST_PATH}) +INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/res/images/ DESTINATION ${IMGDIR} FILES_MATCHING PATTERN "*.png") + # i18n ADD_SUBDIRECTORY(po) diff --git a/inc/convergence.h b/inc/convergence.h deleted file mode 100644 index c190ece..0000000 --- a/inc/convergence.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef CONVERGENCE_H_ -#define CONVERGENCE_H_ - -#include <dlog.h> -#include <glib.h> -#include <d2d_conv_internal.h> - -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "D2D-CONV-SETTING" - -/* convergence power manager */ -extern void convergence_power_on(); -extern void convergence_power_off(); -extern int get_convergence_power_state(); - -#endif /* CONVERGENCE_H_ */ diff --git a/inc/language.h b/inc/language.h deleted file mode 100644 index 1150946..0000000 --- a/inc/language.h +++ /dev/null @@ -1,4 +0,0 @@ -#include <libintl.h> - -#define POWER_ON_SIGN_TEXT dgettext(PACKAGE, "CONV_SETTING_APP_POWER_ON") -#define POWER_OFF_SIGN_TEXT dgettext(PACKAGE, "CONV_SETTING_APP_POWER_OFF")
\ No newline at end of file @@ -1,42 +1,60 @@ #ifndef __main_H__ #define __main_H__ +#include <stdlib.h> #include <app.h> #include <Elementary.h> #include <system_settings.h> #include <efl_extension.h> +#include <device/haptic.h> #include <dlog.h> #include <glib.h> -#include "convergence.h" -#include "language.h" +#include <libintl.h> +#include <d2d_conv_manager.h> +#include <d2d_conv_internal.h> #ifdef LOG_TAG #undef LOG_TAG #endif #define LOG_TAG "D2D-CONV-SETTING" +#ifdef PACKAGE +#undef PACKAGE +#endif #define PACKAGE "org.tizen.d2d-conv-setting" -typedef enum state -{ +typedef enum state { POWER_OFF = 0, POWER_ON, - SCAN_START, - SCAN_STOP, + DISCOVERY_START, + DISCOVERY_STOP, CHANGE_LANGUAGE - } state_e; +#define POWER_ON_SIGN_TEXT dgettext(PACKAGE, "CONV_SETTING_APP_POWER_ON") +#define DEVICE_LIST_SELECT_POPUP_TITLE_TEXT dgettext(PACKAGE, "CONV_DEVICE_LIST_SELECT_POPUP_TITLE") +#define DISCOVERED_LIST_SELECT_POPUP_CONTENT_TEXT dgettext(PACKAGE, "CONV_DISCOVERED_LIST_SELECT_POPUP_CONTENT") +#define PERMITTED_LIST_SELECT_POPUP_CONTENT_TEXT dgettext(PACKAGE, "CONV_PERMITTED_LIST_SELECT_POPUP_CONTENT") +#define DENIED_LIST_SELECT_POPUP_CONTENT_TEXT dgettext(PACKAGE, "CONV_DENIED_LIST_SELECT_POPUP_CONTENT") +#define DEVICE_LIST_SELECT_POPUP_CANCEL_BUTTON_TEXT dgettext(PACKAGE, "CONV_DEVICE_LIST_SELECT_POPUP_CANCEL_BUTTON") +#define DEVICE_LIST_SELECT_POPUP_PERMIT_BUTTON_TEXT dgettext(PACKAGE, "CONV_DEVICE_LIST_SELECT_POPUP_PERMIT_BUTTON") +#define DEVICE_LIST_SELECT_POPUP_DENY_BUTTON_TEXT dgettext(PACKAGE, "CONV_DEVICE_LIST_SELECT_POPUP_DENY_BUTTON") +#define DEVICE_LIST_SELECT_POPUP_REMOVE_BUTTON_TEXT dgettext(PACKAGE, "CONV_DEVICE_LIST_SELECT_POPUP_REMOVE_BUTTON") /* state event lisetner */ typedef void (*event_listener)(state_e state); extern void add_state_change_event_listener(event_listener listener); extern void state_change_event(state_e state); - /* setting ui */ extern void create_setting_menu(Evas_Object *parent); extern void create_setting_item_power(Evas_Object *parent); extern void create_setting_item_sign(Evas_Object *parent); +extern void create_setting_item_discovery_button(Evas_Object *parent); +extern void create_setting_item_device_list(Evas_Object *parent); +extern void create_setting_item_popup(Evas_Object *parent); + +/* util */ +extern void do_haptic(int count); #endif /* __main_H__ */ diff --git a/org.tizen.d2d-conv-setting.xml b/org.tizen.d2d-conv-setting.xml index d996877..677c04b 100755 --- a/org.tizen.d2d-conv-setting.xml +++ b/org.tizen.d2d-conv-setting.xml @@ -18,6 +18,7 @@ <privilege>http://tizen.org/privilege/internet</privilege> <privilege>http://tizen.org/privilege/externalstorage</privilege> <privilege>http://tizen.org/privilege/content.write</privilege> + <privilege>http://tizen.org/privilege/haptic</privilege> </privileges> </manifest> diff --git a/packaging/d2d-conv-setting.spec b/packaging/d2d-conv-setting.spec index 8c8a53d..ff66a27 100644 --- a/packaging/d2d-conv-setting.spec +++ b/packaging/d2d-conv-setting.spec @@ -11,6 +11,7 @@ BuildRequires: pkgconfig(efl-extension) BuildRequires: pkgconfig(capi-appfw-application) BuildRequires: pkgconfig(capi-system-system-settings) BuildRequires: pkgconfig(capi-appfw-app-manager) +BuildRequires: pkgconfig(capi-system-device) BuildRequires: pkgconfig(d2d-conv-manager) BuildRequires: app-core-efl-devel BuildRequires: efl-extension-devel @@ -41,6 +42,7 @@ cp %{_builddir}/%{buildsubdir}/LICENSE %{buildroot}/%{_datadir}/license/%{name} %files %defattr(-,root,root,-) %{_pkg_dir}/bin/* +%{_pkg_dir}/res/* %{_pkg_dir}/shared/* %{_datadir}/locale/*/LC_MESSAGES/*.mo %{TZ_SYS_RO_PACKAGES}/%{name}.xml diff --git a/po/en_US.po b/po/en_US.po index 30ee3fe..815524f 100644 --- a/po/en_US.po +++ b/po/en_US.po @@ -2,4 +2,28 @@ msgid "CONV_SETTING_APP_POWER_ON" msgstr "Now, you can experience a variety of convergence features! Please be aware that a remote device can launch an application on your device or access data in your application. A notice will appear when your device is accessed by remote devices. You can disable this feature by clicking the button again." msgid "CONV_SETTING_APP_POWER_OFF" -msgstr "You can experience a variety of convergence feature, if you enable TIZEN Convergence - an application on a separate device can be launched remotely, or communicate between applications on separate devices. Please be aware that remote device can launch an application on your device or access data in your application. A notice will appear when your device is accessed by remote devices."
\ No newline at end of file +msgstr "You can experience a variety of convergence feature, if you enable TIZEN Convergence an application on a separate device can be launched remotely, or communicate between applications on separate devices. Please be aware that remote device can launch an application on your device or access data in your application. A notice will appear when your device is accessed by remote devices." + +msgid "CONV_DEVICE_LIST_SELECT_POPUP_TITLE" +msgstr "Access Device Control" + +msgid "CONV_DISCOVERED_LIST_SELECT_POPUP_CONTENT" +msgstr " device selected. How do you want this device control?" + +msgid "CONV_PERMITTED_LIST_SELECT_POPUP_CONTENT" +msgstr " device state is permitted. How do you want access state changed?" + +msgid "CONV_DENIED_LIST_SELECT_POPUP_CONTENT" +msgstr " device state is denied. How do you want access state changed?" + +msgid "CONV_DEVICE_LIST_SELECT_POPUP_CANCEL_BUTTON" +msgstr "Cancel" + +msgid "CONV_DEVICE_LIST_SELECT_POPUP_PERMIT_BUTTON" +msgstr "Permit" + +msgid "CONV_DEVICE_LIST_SELECT_POPUP_DENY_BUTTON" +msgstr "Deny" + +msgid "CONV_DEVICE_LIST_SELECT_POPUP_REMOVE_BUTTON" +msgstr "Remove" diff --git a/po/ko_KR.po b/po/ko_KR.po index 96e9465..b10f532 100644 --- a/po/ko_KR.po +++ b/po/ko_KR.po @@ -2,4 +2,28 @@ msgid "CONV_SETTING_APP_POWER_ON" msgstr "다양한 Convergence 기능을 경험할 수 있습니다! 단, 동일한 Wi-Fi 망 내 주변기기에서도 본 기기에 접근이 가능해지므로, 주변기기가 본 기기의 App을 실행하거나 data에 접근할 수도 있습니다. 주변기기 접근 시도 시 팝업창을 통해 이용자의 동의를 받아 본기능이 활성화 됩니다. 본 기능은 본 메뉴의 버튼을 다시 선택하여 끌 수 있습니다." msgid "CONV_SETTING_APP_POWER_OFF" -msgstr "TIZEN Convergence 기능을 켜면, 동일한 Wi-Fi 망 내의 주변기기의 App을 실행하거나 App 간 통신이 가능하게 되며, 다양한 Convergence 기능을 경험할 수 있습니다. 단, 동일한 Wi-Fi 망 내 주변기기에서 주변기기가 본 기기의 App을 실행하거나 data에 접근을 요청할 수 있습니다."
\ No newline at end of file +msgstr "TIZEN Convergence 기능을 켜면, 동일한 Wi-Fi 망 내의 주변기기의 App을 실행하거나 App 간 통신이 가능하게 되며, 다양한 Convergence 기능을 경험할 수 있습니다. 단, 동일한 Wi-Fi 망 내 주변기기에서 주변기기가 본 기기의 App을 실행하거나 data에 접근을 요청할 수 있습니다." + +msgid "CONV_DEVICE_LIST_SELECT_POPUP_TITLE" +msgstr "접근 디바이스 관리" + +msgid "CONV_DISCOVERED_LIST_SELECT_POPUP_CONTENT" +msgstr " 디바이스를 어떤 상태로 관리하시겠습니까?" + +msgid "CONV_PERMITTED_LIST_SELECT_POPUP_CONTENT" +msgstr " 디바이스는 현재 허용된 상태입니다. 어떤 상태로 변경하시겠습니까?" + +msgid "CONV_DENIED_LIST_SELECT_POPUP_CONTENT" +msgstr " 디바이스는 현재 거부된 상태입니다. 어떤 상태로 변경하시겠습니까?" + +msgid "CONV_DEVICE_LIST_SELECT_POPUP_CANCEL_BUTTON" +msgstr "취소" + +msgid "CONV_DEVICE_LIST_SELECT_POPUP_PERMIT_BUTTON" +msgstr "허용" + +msgid "CONV_DEVICE_LIST_SELECT_POPUP_DENY_BUTTON" +msgstr "거부" + +msgid "CONV_DEVICE_LIST_SELECT_POPUP_REMOVE_BUTTON" +msgstr "제거"
\ No newline at end of file diff --git a/res/images/device_type_icon_camera.png b/res/images/device_type_icon_camera.png Binary files differnew file mode 100644 index 0000000..0a53ae9 --- /dev/null +++ b/res/images/device_type_icon_camera.png diff --git a/res/images/device_type_icon_computer.png b/res/images/device_type_icon_computer.png Binary files differnew file mode 100644 index 0000000..d941e88 --- /dev/null +++ b/res/images/device_type_icon_computer.png diff --git a/res/images/device_type_icon_display.png b/res/images/device_type_icon_display.png Binary files differnew file mode 100644 index 0000000..448db2c --- /dev/null +++ b/res/images/device_type_icon_display.png diff --git a/res/images/device_type_icon_gaming.png b/res/images/device_type_icon_gaming.png Binary files differnew file mode 100644 index 0000000..db08feb --- /dev/null +++ b/res/images/device_type_icon_gaming.png diff --git a/res/images/device_type_icon_headphone.png b/res/images/device_type_icon_headphone.png Binary files differnew file mode 100644 index 0000000..b746dd8 --- /dev/null +++ b/res/images/device_type_icon_headphone.png diff --git a/res/images/device_type_icon_headset.png b/res/images/device_type_icon_headset.png Binary files differnew file mode 100644 index 0000000..a17e799 --- /dev/null +++ b/res/images/device_type_icon_headset.png diff --git a/res/images/device_type_icon_keyboard.png b/res/images/device_type_icon_keyboard.png Binary files differnew file mode 100644 index 0000000..62d62f5 --- /dev/null +++ b/res/images/device_type_icon_keyboard.png diff --git a/res/images/device_type_icon_medical.png b/res/images/device_type_icon_medical.png Binary files differnew file mode 100644 index 0000000..44ea23d --- /dev/null +++ b/res/images/device_type_icon_medical.png diff --git a/res/images/device_type_icon_mobilephone.png b/res/images/device_type_icon_mobilephone.png Binary files differnew file mode 100644 index 0000000..c2f5e46 --- /dev/null +++ b/res/images/device_type_icon_mobilephone.png diff --git a/res/images/device_type_icon_mouse.png b/res/images/device_type_icon_mouse.png Binary files differnew file mode 100644 index 0000000..463c19d --- /dev/null +++ b/res/images/device_type_icon_mouse.png diff --git a/res/images/device_type_icon_multimedia.png b/res/images/device_type_icon_multimedia.png Binary files differnew file mode 100644 index 0000000..126caf2 --- /dev/null +++ b/res/images/device_type_icon_multimedia.png diff --git a/res/images/device_type_icon_network_infrastructure.png b/res/images/device_type_icon_network_infrastructure.png Binary files differnew file mode 100644 index 0000000..424e974 --- /dev/null +++ b/res/images/device_type_icon_network_infrastructure.png diff --git a/res/images/device_type_icon_printer.png b/res/images/device_type_icon_printer.png Binary files differnew file mode 100644 index 0000000..59a2f12 --- /dev/null +++ b/res/images/device_type_icon_printer.png diff --git a/res/images/device_type_icon_storage.png b/res/images/device_type_icon_storage.png Binary files differnew file mode 100644 index 0000000..3f5f708 --- /dev/null +++ b/res/images/device_type_icon_storage.png diff --git a/res/images/device_type_icon_wrist.png b/res/images/device_type_icon_wrist.png Binary files differnew file mode 100644 index 0000000..19f100b --- /dev/null +++ b/res/images/device_type_icon_wrist.png 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 |