summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShuhrat Dehkanov <sh.dehkanov@samsung.com>2015-05-21 20:49:33 +0900
committerShuhrat Dehkanov <sh.dehkanov@samsung.com>2015-05-21 20:53:49 +0900
commit3d2eb7e26dc71139bbb42c237b8ca2f47a6247be (patch)
treed43c0315b5de2983bb3344819cc9006be3b8a48f
parent9cf5038fe319ea1cb88b4e05a7be1159e77d5663 (diff)
downloadsettings-3d2eb7e26dc71139bbb42c237b8ca2f47a6247be.tar.gz
settings-3d2eb7e26dc71139bbb42c237b8ca2f47a6247be.tar.bz2
settings-3d2eb7e26dc71139bbb42c237b8ca2f47a6247be.zip
Revert to original C impl
I tried to go as way back as possible, so there are couple things that need to re-applied: - accessibility menu - PNG image warnings - edje/edc warnings - test cases Change-Id: I5c79b244a27a365bdd4d784670cd43d0a38c8e12
-rw-r--r--CMakeLists.txt31
-rw-r--r--data/images/allbrowser_menu_bg.pngbin183 -> 17782 bytes
-rw-r--r--data/images/btn_down.pngbin249 -> 17853 bytes
-rw-r--r--data/images/btn_text_foc.pngbin248 -> 17864 bytes
-rw-r--r--data/images/btn_text_nor.pngbin248 -> 17860 bytes
-rw-r--r--data/images/btn_up.pngbin245 -> 17851 bytes
-rw-r--r--data/images/checkbox_check_foc.pngbin365 -> 18058 bytes
-rw-r--r--data/images/checkbox_check_nor.pngbin373 -> 18051 bytes
-rw-r--r--data/images/checkbox_uncheck_foc.pngbin228 -> 17866 bytes
-rw-r--r--data/images/checkbox_uncheck_nor.pngbin265 -> 17882 bytes
-rw-r--r--data/images/ico_arrow_down.pngbin532 -> 15473 bytes
-rw-r--r--data/images/ico_arrow_up.pngbin516 -> 15473 bytes
-rw-r--r--data/images/ico_hyperlink_arrow.pngbin235 -> 15115 bytes
-rw-r--r--data/images/ico_settings.pngbin4072 -> 21525 bytes
-rw-r--r--data/images/ico_settings_accessibility.pngbin3788 -> 0 bytes
-rw-r--r--data/images/ico_settings_channel.pngbin755 -> 18483 bytes
-rw-r--r--data/images/ico_settings_device.pngbin250 -> 17841 bytes
-rw-r--r--data/images/ico_settings_network.pngbin1036 -> 18793 bytes
-rw-r--r--data/images/ico_settings_picture.pngbin439 -> 18088 bytes
-rw-r--r--data/images/ico_settings_sound.pngbin551 -> 18239 bytes
-rw-r--r--data/images/ico_settings_support.pngbin848 -> 18628 bytes
-rw-r--r--data/images/ico_settings_system.pngbin691 -> 18371 bytes
-rw-r--r--data/images/ico_spincontrol_check.pngbin222 -> 18264 bytes
-rw-r--r--data/images/input_box_highlight.pngbin7730 -> 10237 bytes
-rw-r--r--data/images/input_box_nor.pngbin1349 -> 4567 bytes
-rw-r--r--data/images/list_highlight.pngbin9249 -> 9239 bytes
-rw-r--r--data/images/listview_menu_bg.pngbin379 -> 18418 bytes
-rw-r--r--data/images/modal_dialogs_bg.pngbin875 -> 18657 bytes
-rw-r--r--data/images/progress_wheel.pngbin1198 -> 18939 bytes
-rw-r--r--data/images/radiobtn_br_off_nor.pngbin553 -> 18307 bytes
-rw-r--r--data/images/radiobtn_on_foc.pngbin511 -> 18282 bytes
-rw-r--r--data/images/round_rectangle_4X4.pngbin146 -> 18179 bytes
-rw-r--r--data/images/round_rectangle_8X8_top.pngbin166 -> 17774 bytes
-rw-r--r--data/images/scrollbar_horizontal.pngbin143 -> 17735 bytes
-rw-r--r--data/images/scrollbar_vertical.pngbin150 -> 17745 bytes
-rw-r--r--data/images/search_searchbar_bg_foc.pngbin173 -> 17789 bytes
-rw-r--r--data/images/search_searchbar_bg_nor.pngbin149 -> 17740 bytes
-rw-r--r--data/images/search_searchbar_small_bg_foc.pngbin90 -> 17688 bytes
-rw-r--r--data/images/search_searchbar_small_bg_nor.pngbin91 -> 17688 bytes
-rw-r--r--data/images/second_depth_bg.pngbin3115 -> 22286 bytes
-rw-r--r--data/images/setting_highlight.pngbin2660 -> 5209 bytes
-rw-r--r--data/images/setting_list_dot.pngbin156 -> 2869 bytes
-rw-r--r--data/images/setting_list_dot_s.pngbin221 -> 2899 bytes
-rw-r--r--data/images/settings_bg.pngbin77190 -> 117649 bytes
-rw-r--r--data/images/settings_bg_shadow.pngbin99 -> 17691 bytes
-rw-r--r--data/images/slider_thumb.pngbin1395 -> 18869 bytes
-rw-r--r--data/images/tooltip_arrow.pngbin219 -> 17852 bytes
-rw-r--r--data/images/tooltip_bg.pngbin275 -> 17912 bytes
-rw-r--r--data/org.tizen.settings-tv-ref-theme.edc2
-rw-r--r--data/org.tizen.settings-tv-ref.edc2
-rw-r--r--data/viewer/change_passcode.edc5
-rw-r--r--data/viewer/icon.edc60
-rw-r--r--data/viewer/maincatalog.edc1
-rw-r--r--data/widget/progressbar.edc1
-rw-r--r--include/dbg.h40
-rw-r--r--include/def.h (renamed from include/common_defs.h)65
-rw-r--r--include/settingviewmgr.h154
-rw-r--r--include/timeout_handler.h26
-rw-r--r--include/utils.h3
-rw-r--r--include/view_bottomslider.h24
-rw-r--r--include/view_bottomsublist.h24
-rw-r--r--include/view_device_manager.h24
-rw-r--r--include/view_maincatalog.h53
-rw-r--r--include/view_need_pwd.h31
-rw-r--r--include/view_pwd_popup.h27
-rw-r--r--include/view_resetpopup.h24
-rw-r--r--include/view_sublist.h50
-rw-r--r--include/view_system_clock.h51
-rw-r--r--include/view_uigadget.h54
-rw-r--r--include/view_upgrade_popup.h45
-rw-r--r--include/viewmgr.h95
-rw-r--r--json/accessibility.json57
-rw-r--r--json/maincatalog.json8
-rw-r--r--org.tizen.settings-tv-ref.pngbin4072 -> 21525 bytes
-rw-r--r--org.tizen.settings-tv-ref_4x2.pngbin91860 -> 89073 bytes
-rw-r--r--src/data_wrapper.c (renamed from src/data_wrapper.cpp)73
-rw-r--r--src/main.c324
-rw-r--r--src/main.cpp243
-rw-r--r--src/parser.c (renamed from src/parser.cpp)65
-rw-r--r--src/settings_provider.c (renamed from src/settings_provider.cpp)126
-rw-r--r--src/timeout_handler.c (renamed from src/timeout_handler.cpp)116
-rw-r--r--src/utils.c (renamed from src/utils.cpp)47
-rw-r--r--src/view_bottomslider.c88
-rw-r--r--src/view_bottomsublist.c88
-rw-r--r--src/view_device_manager.c58
-rw-r--r--src/view_maincatalog.c2111
-rw-r--r--src/view_maincatalog.cpp1557
-rw-r--r--src/view_need_pwd.c (renamed from src/view_need_pwd.cpp)310
-rw-r--r--src/view_pwd_popup.c (renamed from src/view_pwd_popup.cpp)250
-rw-r--r--src/view_resetpopup.c88
-rw-r--r--src/view_sublist.c775
-rw-r--r--src/view_sublist.cpp655
-rw-r--r--src/view_system_clock.c (renamed from src/view_system_clock.cpp)616
-rw-r--r--src/view_uigadget.c352
-rw-r--r--src/view_uigadget.cpp346
-rw-r--r--src/view_upgrade_popup.c50
-rw-r--r--src/viewmgr.c (renamed from src/settingviewmgr.cpp)557
-rw-r--r--testcase/settings.txt1
-rw-r--r--testcase/settings_all.txt462
-rw-r--r--ug/channel/CMakeLists.txt18
-rw-r--r--ug/channel/edje/images/btn_text_foc.pngbin248 -> 17864 bytes
-rw-r--r--ug/channel/edje/images/btn_text_nor.pngbin248 -> 17860 bytes
-rw-r--r--ug/channel/edje/images/list_highlight.pngbin9249 -> 9239 bytes
-rw-r--r--ug/channel/edje/images/radiobtn_off_br.pngbin593 -> 18295 bytes
-rw-r--r--ug/channel/edje/images/radiobtn_off_dark.pngbin482 -> 18125 bytes
-rw-r--r--ug/channel/edje/images/radiobtn_on_br.pngbin750 -> 18488 bytes
-rw-r--r--ug/channel/edje/images/radiobtn_on_dark.pngbin655 -> 18330 bytes
-rw-r--r--ug/channel/edje/images/round_rectangle_4X4.pngbin146 -> 18179 bytes
-rw-r--r--ug/channel/edje/images/second_depth_bg.pngbin3115 -> 22286 bytes
-rw-r--r--ug/channel/edje/images/thumbnail_highlight_glowrect.pngbin8909 -> 11341 bytes
-rw-r--r--ug/channel/edje/images/wi_progress_bar.pngbin339 -> 3171 bytes
-rw-r--r--ug/channel/edje/images/wi_progress_bg.pngbin628 -> 3537 bytes
-rw-r--r--ug/channel/edje/widgets/progressbar.edc1
-rw-r--r--ug/channel/include/ChannelMainView.h34
-rw-r--r--ug/channel/include/ChannelResultView.h25
-rw-r--r--ug/channel/include/ChannelSearchView.h26
-rw-r--r--ug/channel/include/dbg.h36
-rw-r--r--ug/channel/include/defs.h3
-rw-r--r--ug/channel/include/tv_scan.h65
-rw-r--r--ug/channel/include/ug_auto_program.h10
-rw-r--r--ug/channel/include/util.h9
-rw-r--r--ug/channel/include/view_result_page.h24
-rw-r--r--ug/channel/include/view_scan_start.h25
-rw-r--r--ug/channel/include/view_search_page.h25
-rw-r--r--ug/channel/include/viewmgr_auto_program.h46
-rw-r--r--ug/channel/src/ChannelMainView.cpp356
-rw-r--r--ug/channel/src/ChannelResultView.cpp136
-rw-r--r--ug/channel/src/ChannelSearchView.cpp364
-rw-r--r--ug/channel/src/tv_scan.c669
-rw-r--r--ug/channel/src/ug_auto_program.c (renamed from ug/channel/src/ug_auto_program.cpp)91
-rw-r--r--ug/channel/src/util.c (renamed from ug/channel/src/util.cpp)2
-rw-r--r--ug/channel/src/view_result_page.c240
-rw-r--r--ug/channel/src/view_scan_start.c697
-rw-r--r--ug/channel/src/view_search_page.c614
-rw-r--r--ug/channel/src/viewmgr_auto_program.c279
-rw-r--r--ug/include/NetConMgr.h57
-rw-r--r--ug/include/TVServiceMgr.h34
-rw-r--r--ug/include/UgCommon.h22
-rw-r--r--ug/include/WifiDirectMgr.h52
-rw-r--r--ug/include/WifiMgr.h83
-rw-r--r--ug/network/CMakeLists.txt23
-rw-r--r--ug/network/edje/images/btn_down.pngbin249 -> 17853 bytes
-rw-r--r--ug/network/edje/images/btn_focused.pngbin171 -> 275 bytes
-rw-r--r--ug/network/edje/images/btn_normal.pngbin1404 -> 4033 bytes
-rw-r--r--ug/network/edje/images/btn_up.pngbin245 -> 17851 bytes
-rw-r--r--ug/network/edje/images/check_foc.pngbin647 -> 18316 bytes
-rw-r--r--ug/network/edje/images/check_nor.pngbin639 -> 18363 bytes
-rw-r--r--ug/network/edje/images/ico_dropdown_menu_check.pngbin244 -> 17850 bytes
-rw-r--r--ug/network/edje/images/ico_spincontrol_check.pngbin222 -> 18264 bytes
-rw-r--r--ug/network/edje/images/ico_spincontrol_down.pngbin275 -> 17890 bytes
-rw-r--r--ug/network/edje/images/ico_spincontrol_up.pngbin257 -> 17871 bytes
-rw-r--r--ug/network/edje/images/ico_wifi.pngbin550 -> 18239 bytes
-rw-r--r--ug/network/edje/images/ico_wifi_lock.pngbin609 -> 18310 bytes
-rw-r--r--ug/network/edje/images/modal_dialogs_bg.pngbin875 -> 18657 bytes
-rw-r--r--ug/network/edje/images/progress_wheel.pngbin1198 -> 18939 bytes
-rw-r--r--ug/network/edje/images/radiobtn_br_off_nor.pngbin553 -> 18307 bytes
-rw-r--r--ug/network/edje/images/radiobtn_off_foc.pngbin482 -> 18125 bytes
-rw-r--r--ug/network/edje/images/radiobtn_off_nor.pngbin593 -> 18295 bytes
-rw-r--r--ug/network/edje/images/radiobtn_on_foc.pngbin511 -> 18282 bytes
-rw-r--r--ug/network/edje/images/radiobtn_on_nor.pngbin502 -> 18195 bytes
-rw-r--r--ug/network/edje/images/round_rectangle_4X4.pngbin146 -> 18179 bytes
-rw-r--r--ug/network/edje/images/round_rectangle_4X4_bottom.pngbin123 -> 17711 bytes
-rw-r--r--ug/network/edje/images/round_rectangle_4X4_top.pngbin122 -> 17710 bytes
-rw-r--r--ug/network/edje/images/round_rectangle_8X8_top.pngbin166 -> 17774 bytes
-rw-r--r--ug/network/edje/images/second_depth_bg.pngbin3115 -> 22286 bytes
-rw-r--r--ug/network/edje/images/setting_ico_no_network.pngbin1946 -> 20127 bytes
-rw-r--r--ug/network/edje/images/setting_ico_no_network.png.pngbin1946 -> 20127 bytes
-rw-r--r--ug/network/edje/images/setting_ico_plug_network_Cable.pngbin1064 -> 19103 bytes
-rw-r--r--ug/network/edje/images/sub_popup_bg.pngbin789 -> 3615 bytes
-rw-r--r--ug/network/include/IpSettingView.h71
-rw-r--r--ug/network/include/NetworkMainView.h99
-rw-r--r--ug/network/include/WifiPasscodeView.h43
-rw-r--r--ug/network/include/common.h49
-rw-r--r--ug/network/include/connection_mgr.h57
-rw-r--r--ug/network/include/dbg.h40
-rw-r--r--ug/network/include/defs.h40
-rw-r--r--ug/network/include/ip_setting_view.h25
-rw-r--r--ug/network/include/main_view.h28
-rw-r--r--ug/network/include/network_viewmgr.h61
-rw-r--r--ug/network/include/util.h15
-rw-r--r--ug/network/include/vconf_mgr.h39
-rw-r--r--ug/network/include/wifi_mgr.h69
-rw-r--r--ug/network/include/wifi_passcode_view.h28
-rw-r--r--ug/network/src/IpSettingView.cpp1691
-rw-r--r--ug/network/src/NetworkMainView.cpp1710
-rw-r--r--ug/network/src/WifiPasscodeView.cpp584
-rw-r--r--ug/network/src/connection_mgr.c650
-rw-r--r--ug/network/src/ip_setting_view.c2629
-rw-r--r--ug/network/src/main_view.c2543
-rw-r--r--ug/network/src/network_viewmgr.c259
-rw-r--r--ug/network/src/ug_network_settings.c (renamed from ug/network/src/ug_network_settings.cpp)71
-rw-r--r--ug/network/src/util.c (renamed from ug/network/src/util.cpp)2
-rw-r--r--ug/network/src/vconf_mgr.c404
-rw-r--r--ug/network/src/wifi_mgr.c615
-rw-r--r--ug/network/src/wifi_passcode_view.c956
-rw-r--r--ug/proxy/CMakeLists.txt17
-rw-r--r--ug/proxy/edje/images/ico_dropdown_menu_check.pngbin244 -> 17850 bytes
-rw-r--r--ug/proxy/edje/images/ico_spincontrol_down.pngbin275 -> 17890 bytes
-rw-r--r--ug/proxy/edje/images/ico_spincontrol_up.pngbin257 -> 17871 bytes
-rw-r--r--ug/proxy/edje/images/modal_dialogs_bg.pngbin875 -> 18657 bytes
-rw-r--r--ug/proxy/edje/images/round_rectangle_4X4.pngbin146 -> 18179 bytes
-rw-r--r--ug/proxy/edje/images/round_rectangle_8X8_top.pngbin166 -> 17774 bytes
-rw-r--r--ug/proxy/include/ProxyMainView.h55
-rw-r--r--ug/proxy/include/common.h35
-rw-r--r--ug/proxy/include/connection_mgr.h37
-rw-r--r--ug/proxy/include/dbg.h40
-rw-r--r--ug/proxy/include/defs.h35
-rw-r--r--ug/proxy/include/main_view.h25
-rw-r--r--ug/proxy/include/util.h13
-rw-r--r--ug/proxy/include/vconf_mgr.h28
-rw-r--r--ug/proxy/include/wifi_mgr.h31
-rw-r--r--ug/proxy/src/ProxyMainView.cpp1165
-rw-r--r--ug/proxy/src/connection_mgr.c369
-rw-r--r--ug/proxy/src/main_view.c2068
-rw-r--r--ug/proxy/src/ug_proxy_settings.c (renamed from ug/proxy/src/ug_proxy_settings.cpp)62
-rw-r--r--ug/proxy/src/util.c (renamed from ug/proxy/src/util.cpp)2
-rw-r--r--ug/proxy/src/vconf_mgr.c111
-rw-r--r--ug/proxy/src/wifi_mgr.c287
-rw-r--r--ug/src/NetConMgr.cpp614
-rw-r--r--ug/src/TVServiceMgr.cpp295
-rw-r--r--ug/src/WifiDirectMgr.cpp476
-rw-r--r--ug/src/WifiMgr.cpp533
-rw-r--r--ug/system/clock/CMakeLists.txt14
-rw-r--r--ug/system/clock/edje/images/ico_dropdown_menu_check.pngbin244 -> 17850 bytes
-rw-r--r--ug/system/clock/edje/images/round_rectangle_4X4.pngbin146 -> 18179 bytes
-rw-r--r--ug/system/clock/edje/images/second_depth_bg.pngbin3115 -> 22286 bytes
-rw-r--r--ug/system/clock/edje/images/spincontrol_arrow_down.pngbin279 -> 17900 bytes
-rw-r--r--ug/system/clock/edje/images/spincontrol_arrow_up.pngbin264 -> 17881 bytes
-rw-r--r--ug/system/clock/edje/ug_clock.edc2
-rw-r--r--ug/system/clock/edje/ug_clock_theme.edc2
-rw-r--r--ug/system/clock/include/ClockMainView.h31
-rw-r--r--ug/system/clock/include/ClockSpinControlView.h33
-rw-r--r--ug/system/clock/include/ClockSublistView.h30
-rw-r--r--ug/system/clock/include/ClockTimeSpinControlView.h33
-rw-r--r--ug/system/clock/include/dbg.h33
-rw-r--r--ug/system/clock/include/ug_clock.h8
-rw-r--r--ug/system/clock/include/ug_clock_define.h (renamed from ug/system/clock/include/defs.h)23
-rw-r--r--ug/system/clock/include/ug_clock_spin_control.h26
-rw-r--r--ug/system/clock/include/ug_clock_sublist.h24
-rw-r--r--ug/system/clock/include/ug_clock_time_spin_control.h25
-rw-r--r--ug/system/clock/include/ug_clock_utils.h (renamed from ug/system/clock/include/util.h)0
-rw-r--r--ug/system/clock/src/ClockMainView.cpp459
-rw-r--r--ug/system/clock/src/ClockSpinControlView.cpp529
-rw-r--r--ug/system/clock/src/ClockSublistView.cpp358
-rw-r--r--ug/system/clock/src/ClockTimeSpinControlView.cpp624
-rw-r--r--ug/system/clock/src/ug_clock.c1189
-rw-r--r--ug/system/clock/src/ug_clock.cpp177
-rw-r--r--ug/system/clock/src/ug_clock_spin_control.c797
-rw-r--r--ug/system/clock/src/ug_clock_sublist.c516
-rw-r--r--ug/system/clock/src/ug_clock_time_spin_control.c842
-rw-r--r--ug/system/clock/src/ug_clock_utils.c (renamed from ug/system/clock/src/util.cpp)12
-rw-r--r--ug/wifi-direct/CMakeLists.txt15
-rw-r--r--ug/wifi-direct/edje/images/ico_dropdown_menu_check.pngbin244 -> 17850 bytes
-rw-r--r--ug/wifi-direct/edje/images/loading_96_01.pngbin12311 -> 14922 bytes
-rw-r--r--ug/wifi-direct/edje/images/loading_96_02.pngbin12383 -> 14977 bytes
-rw-r--r--ug/wifi-direct/edje/images/loading_96_03.pngbin12496 -> 15099 bytes
-rw-r--r--ug/wifi-direct/edje/images/loading_96_04.pngbin12497 -> 15112 bytes
-rw-r--r--ug/wifi-direct/edje/images/loading_96_05.pngbin12384 -> 15010 bytes
-rw-r--r--ug/wifi-direct/edje/images/loading_96_06.pngbin12205 -> 14824 bytes
-rw-r--r--ug/wifi-direct/edje/images/loading_96_07.pngbin12339 -> 14980 bytes
-rw-r--r--ug/wifi-direct/edje/images/loading_96_08.pngbin12470 -> 15089 bytes
-rw-r--r--ug/wifi-direct/edje/images/loading_96_09.pngbin12445 -> 15054 bytes
-rw-r--r--ug/wifi-direct/edje/images/loading_96_10.pngbin12189 -> 14752 bytes
-rw-r--r--ug/wifi-direct/edje/images/loading_96_11.pngbin12282 -> 14882 bytes
-rw-r--r--ug/wifi-direct/edje/images/loading_96_12.pngbin12401 -> 14976 bytes
-rw-r--r--ug/wifi-direct/edje/images/loading_96_13.pngbin12447 -> 15052 bytes
-rw-r--r--ug/wifi-direct/edje/images/loading_96_14.pngbin12368 -> 14991 bytes
-rw-r--r--ug/wifi-direct/edje/images/loading_96_15.pngbin12195 -> 14803 bytes
-rw-r--r--ug/wifi-direct/edje/images/loading_96_16.pngbin12376 -> 14991 bytes
-rw-r--r--ug/wifi-direct/edje/images/loading_96_17.pngbin12510 -> 15112 bytes
-rw-r--r--ug/wifi-direct/edje/images/loading_96_18.pngbin12555 -> 15135 bytes
-rw-r--r--ug/wifi-direct/edje/images/round_rectangle_4X4.pngbin146 -> 18179 bytes
-rw-r--r--ug/wifi-direct/edje/images/second_depth_bg.pngbin3115 -> 22286 bytes
-rw-r--r--ug/wifi-direct/include/WifiDirectMainView.h81
-rw-r--r--ug/wifi-direct/include/dbg.h38
-rw-r--r--ug/wifi-direct/include/defs.h21
-rw-r--r--ug/wifi-direct/include/util.h9
-rw-r--r--ug/wifi-direct/include/wifi_direct_mgr.h81
-rw-r--r--ug/wifi-direct/include/wifi_direct_view.h25
-rw-r--r--ug/wifi-direct/src/WifiDirectMainView.cpp1553
-rw-r--r--ug/wifi-direct/src/ug_wifi_direct.c (renamed from ug/wifi-direct/src/ug_wifi_direct.cpp)48
-rw-r--r--ug/wifi-direct/src/util.c (renamed from ug/wifi-direct/src/util.cpp)2
-rw-r--r--ug/wifi-direct/src/wifi_direct_mgr.c612
-rw-r--r--ug/wifi-direct/src/wifi_direct_view.c2040
284 files changed, 26072 insertions, 17697 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8356404..bc5f3ff 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -80,19 +80,24 @@ ADD_DEFINITIONS("-DJSON_HELPER_FILE=\"${JSONHELPERFILE}\"")
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
ADD_EXECUTABLE(${PROJECT_NAME}
- src/main.cpp
- src/settingviewmgr.cpp
- src/parser.cpp
- src/data_wrapper.cpp
- src/utils.cpp
- src/view_maincatalog.cpp
- src/view_uigadget.cpp
- src/view_sublist.cpp
- src/settings_provider.cpp
- src/view_pwd_popup.cpp
- src/view_system_clock.cpp
- src/view_need_pwd.cpp
- src/timeout_handler.cpp
+ src/main.c
+ src/parser.c
+ src/data_wrapper.c
+ src/utils.c
+ src/viewmgr.c
+ src/view_maincatalog.c
+ src/view_uigadget.c
+ src/view_sublist.c
+ src/view_bottomsublist.c
+ src/view_bottomslider.c
+ src/settings_provider.c
+ src/view_pwd_popup.c
+ src/view_device_manager.c
+ src/view_resetpopup.c
+ src/view_upgrade_popup.c
+ src/view_system_clock.c
+ src/view_need_pwd.c
+ src/timeout_handler.c
)
FOREACH (flag ${HOMEPANEL_PKGS_CFLAGS})
diff --git a/data/images/allbrowser_menu_bg.png b/data/images/allbrowser_menu_bg.png
index 5ea56f4..55a4ed8 100644
--- a/data/images/allbrowser_menu_bg.png
+++ b/data/images/allbrowser_menu_bg.png
Binary files differ
diff --git a/data/images/btn_down.png b/data/images/btn_down.png
index 44a3166..91946d8 100644
--- a/data/images/btn_down.png
+++ b/data/images/btn_down.png
Binary files differ
diff --git a/data/images/btn_text_foc.png b/data/images/btn_text_foc.png
index 4a30fec..c43ca3c 100644
--- a/data/images/btn_text_foc.png
+++ b/data/images/btn_text_foc.png
Binary files differ
diff --git a/data/images/btn_text_nor.png b/data/images/btn_text_nor.png
index 4834090..b643016 100644
--- a/data/images/btn_text_nor.png
+++ b/data/images/btn_text_nor.png
Binary files differ
diff --git a/data/images/btn_up.png b/data/images/btn_up.png
index 788bf67..4609691 100644
--- a/data/images/btn_up.png
+++ b/data/images/btn_up.png
Binary files differ
diff --git a/data/images/checkbox_check_foc.png b/data/images/checkbox_check_foc.png
index 08ccc25..3880414 100644
--- a/data/images/checkbox_check_foc.png
+++ b/data/images/checkbox_check_foc.png
Binary files differ
diff --git a/data/images/checkbox_check_nor.png b/data/images/checkbox_check_nor.png
index 543ad01..8e954b8 100644
--- a/data/images/checkbox_check_nor.png
+++ b/data/images/checkbox_check_nor.png
Binary files differ
diff --git a/data/images/checkbox_uncheck_foc.png b/data/images/checkbox_uncheck_foc.png
index 00d1286..f7c57a3 100644
--- a/data/images/checkbox_uncheck_foc.png
+++ b/data/images/checkbox_uncheck_foc.png
Binary files differ
diff --git a/data/images/checkbox_uncheck_nor.png b/data/images/checkbox_uncheck_nor.png
index b12ab21..a8edf54 100644
--- a/data/images/checkbox_uncheck_nor.png
+++ b/data/images/checkbox_uncheck_nor.png
Binary files differ
diff --git a/data/images/ico_arrow_down.png b/data/images/ico_arrow_down.png
index 999a45e..5b55a18 100644
--- a/data/images/ico_arrow_down.png
+++ b/data/images/ico_arrow_down.png
Binary files differ
diff --git a/data/images/ico_arrow_up.png b/data/images/ico_arrow_up.png
index c155154..6286bcc 100644
--- a/data/images/ico_arrow_up.png
+++ b/data/images/ico_arrow_up.png
Binary files differ
diff --git a/data/images/ico_hyperlink_arrow.png b/data/images/ico_hyperlink_arrow.png
index 5a80a5b..ff4fadf 100644
--- a/data/images/ico_hyperlink_arrow.png
+++ b/data/images/ico_hyperlink_arrow.png
Binary files differ
diff --git a/data/images/ico_settings.png b/data/images/ico_settings.png
index a29a76d..8b143f3 100644
--- a/data/images/ico_settings.png
+++ b/data/images/ico_settings.png
Binary files differ
diff --git a/data/images/ico_settings_accessibility.png b/data/images/ico_settings_accessibility.png
deleted file mode 100644
index 3b9e710..0000000
--- a/data/images/ico_settings_accessibility.png
+++ /dev/null
Binary files differ
diff --git a/data/images/ico_settings_channel.png b/data/images/ico_settings_channel.png
index c57fee9..1886f43 100644
--- a/data/images/ico_settings_channel.png
+++ b/data/images/ico_settings_channel.png
Binary files differ
diff --git a/data/images/ico_settings_device.png b/data/images/ico_settings_device.png
index dc870ed..6d94247 100644
--- a/data/images/ico_settings_device.png
+++ b/data/images/ico_settings_device.png
Binary files differ
diff --git a/data/images/ico_settings_network.png b/data/images/ico_settings_network.png
index ca5525b..e56dee8 100644
--- a/data/images/ico_settings_network.png
+++ b/data/images/ico_settings_network.png
Binary files differ
diff --git a/data/images/ico_settings_picture.png b/data/images/ico_settings_picture.png
index 0a858be..b6c097b 100644
--- a/data/images/ico_settings_picture.png
+++ b/data/images/ico_settings_picture.png
Binary files differ
diff --git a/data/images/ico_settings_sound.png b/data/images/ico_settings_sound.png
index 7ce35a2..7988155 100644
--- a/data/images/ico_settings_sound.png
+++ b/data/images/ico_settings_sound.png
Binary files differ
diff --git a/data/images/ico_settings_support.png b/data/images/ico_settings_support.png
index 99feb46..31e676c 100644
--- a/data/images/ico_settings_support.png
+++ b/data/images/ico_settings_support.png
Binary files differ
diff --git a/data/images/ico_settings_system.png b/data/images/ico_settings_system.png
index 4114348..63c78b1 100644
--- a/data/images/ico_settings_system.png
+++ b/data/images/ico_settings_system.png
Binary files differ
diff --git a/data/images/ico_spincontrol_check.png b/data/images/ico_spincontrol_check.png
index 16599e9..3b57522 100644
--- a/data/images/ico_spincontrol_check.png
+++ b/data/images/ico_spincontrol_check.png
Binary files differ
diff --git a/data/images/input_box_highlight.png b/data/images/input_box_highlight.png
index 4c195cf..8420123 100644
--- a/data/images/input_box_highlight.png
+++ b/data/images/input_box_highlight.png
Binary files differ
diff --git a/data/images/input_box_nor.png b/data/images/input_box_nor.png
index 5bd788e..5d137a2 100644
--- a/data/images/input_box_nor.png
+++ b/data/images/input_box_nor.png
Binary files differ
diff --git a/data/images/list_highlight.png b/data/images/list_highlight.png
index bf105b8..2dbf246 100644
--- a/data/images/list_highlight.png
+++ b/data/images/list_highlight.png
Binary files differ
diff --git a/data/images/listview_menu_bg.png b/data/images/listview_menu_bg.png
index b8ee750..bb007f7 100644
--- a/data/images/listview_menu_bg.png
+++ b/data/images/listview_menu_bg.png
Binary files differ
diff --git a/data/images/modal_dialogs_bg.png b/data/images/modal_dialogs_bg.png
index b825c26..0ae9c58 100644
--- a/data/images/modal_dialogs_bg.png
+++ b/data/images/modal_dialogs_bg.png
Binary files differ
diff --git a/data/images/progress_wheel.png b/data/images/progress_wheel.png
index ce53880..9e5b177 100644
--- a/data/images/progress_wheel.png
+++ b/data/images/progress_wheel.png
Binary files differ
diff --git a/data/images/radiobtn_br_off_nor.png b/data/images/radiobtn_br_off_nor.png
index e619dee..6087f23 100644
--- a/data/images/radiobtn_br_off_nor.png
+++ b/data/images/radiobtn_br_off_nor.png
Binary files differ
diff --git a/data/images/radiobtn_on_foc.png b/data/images/radiobtn_on_foc.png
index f9d9db2..109efb1 100644
--- a/data/images/radiobtn_on_foc.png
+++ b/data/images/radiobtn_on_foc.png
Binary files differ
diff --git a/data/images/round_rectangle_4X4.png b/data/images/round_rectangle_4X4.png
index b0c09a8..5a1f51d 100644
--- a/data/images/round_rectangle_4X4.png
+++ b/data/images/round_rectangle_4X4.png
Binary files differ
diff --git a/data/images/round_rectangle_8X8_top.png b/data/images/round_rectangle_8X8_top.png
index 3ab184f..dc618e3 100644
--- a/data/images/round_rectangle_8X8_top.png
+++ b/data/images/round_rectangle_8X8_top.png
Binary files differ
diff --git a/data/images/scrollbar_horizontal.png b/data/images/scrollbar_horizontal.png
index b533612..227ddc2 100644
--- a/data/images/scrollbar_horizontal.png
+++ b/data/images/scrollbar_horizontal.png
Binary files differ
diff --git a/data/images/scrollbar_vertical.png b/data/images/scrollbar_vertical.png
index 8dd91f1..ccc9be0 100644
--- a/data/images/scrollbar_vertical.png
+++ b/data/images/scrollbar_vertical.png
Binary files differ
diff --git a/data/images/search_searchbar_bg_foc.png b/data/images/search_searchbar_bg_foc.png
index f065c44..cb5d15f 100644
--- a/data/images/search_searchbar_bg_foc.png
+++ b/data/images/search_searchbar_bg_foc.png
Binary files differ
diff --git a/data/images/search_searchbar_bg_nor.png b/data/images/search_searchbar_bg_nor.png
index 3faae22..ad1a285 100644
--- a/data/images/search_searchbar_bg_nor.png
+++ b/data/images/search_searchbar_bg_nor.png
Binary files differ
diff --git a/data/images/search_searchbar_small_bg_foc.png b/data/images/search_searchbar_small_bg_foc.png
index 8c1c0c9..0a81cdc 100644
--- a/data/images/search_searchbar_small_bg_foc.png
+++ b/data/images/search_searchbar_small_bg_foc.png
Binary files differ
diff --git a/data/images/search_searchbar_small_bg_nor.png b/data/images/search_searchbar_small_bg_nor.png
index 6bb01f8..7212144 100644
--- a/data/images/search_searchbar_small_bg_nor.png
+++ b/data/images/search_searchbar_small_bg_nor.png
Binary files differ
diff --git a/data/images/second_depth_bg.png b/data/images/second_depth_bg.png
index 602e272..5b3c624 100644
--- a/data/images/second_depth_bg.png
+++ b/data/images/second_depth_bg.png
Binary files differ
diff --git a/data/images/setting_highlight.png b/data/images/setting_highlight.png
index 3b60340..a958308 100644
--- a/data/images/setting_highlight.png
+++ b/data/images/setting_highlight.png
Binary files differ
diff --git a/data/images/setting_list_dot.png b/data/images/setting_list_dot.png
index 8d30f3d..35d2f0c 100644
--- a/data/images/setting_list_dot.png
+++ b/data/images/setting_list_dot.png
Binary files differ
diff --git a/data/images/setting_list_dot_s.png b/data/images/setting_list_dot_s.png
index 81b6efd..76f5e78 100644
--- a/data/images/setting_list_dot_s.png
+++ b/data/images/setting_list_dot_s.png
Binary files differ
diff --git a/data/images/settings_bg.png b/data/images/settings_bg.png
index 4de3ac9..72e6b0b 100644
--- a/data/images/settings_bg.png
+++ b/data/images/settings_bg.png
Binary files differ
diff --git a/data/images/settings_bg_shadow.png b/data/images/settings_bg_shadow.png
index 6713c95..e38f2a4 100644
--- a/data/images/settings_bg_shadow.png
+++ b/data/images/settings_bg_shadow.png
Binary files differ
diff --git a/data/images/slider_thumb.png b/data/images/slider_thumb.png
index 93971c1..ae976f0 100644
--- a/data/images/slider_thumb.png
+++ b/data/images/slider_thumb.png
Binary files differ
diff --git a/data/images/tooltip_arrow.png b/data/images/tooltip_arrow.png
index eeace2c..78f85aa 100644
--- a/data/images/tooltip_arrow.png
+++ b/data/images/tooltip_arrow.png
Binary files differ
diff --git a/data/images/tooltip_bg.png b/data/images/tooltip_bg.png
index 8381930..f7c6412 100644
--- a/data/images/tooltip_bg.png
+++ b/data/images/tooltip_bg.png
Binary files differ
diff --git a/data/org.tizen.settings-tv-ref-theme.edc b/data/org.tizen.settings-tv-ref-theme.edc
index 610d8fc..f8ece3b 100644
--- a/data/org.tizen.settings-tv-ref-theme.edc
+++ b/data/org.tizen.settings-tv-ref-theme.edc
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "../include/common_defs.h"
+#include "../include/def.h"
collections {
#include "widget/button.edc"
#include "widget/progressbar.edc"
diff --git a/data/org.tizen.settings-tv-ref.edc b/data/org.tizen.settings-tv-ref.edc
index 976f7ee..aef0b96 100644
--- a/data/org.tizen.settings-tv-ref.edc
+++ b/data/org.tizen.settings-tv-ref.edc
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "../include/common_defs.h"
+#include "../include/def.h"
collections {
#include "viewer/maincatalog.edc"
diff --git a/data/viewer/change_passcode.edc b/data/viewer/change_passcode.edc
index fe9cb05..a26f3c9 100644
--- a/data/viewer/change_passcode.edc
+++ b/data/viewer/change_passcode.edc
@@ -183,7 +183,6 @@ group {
rel2 {
to: "cancel_btn_swallow_padding";
}
- fixed: 1 1;
align: 0.0 0.0;
}
}
@@ -261,7 +260,6 @@ group {
rel2 {
to: "service_content_area_padding";
}
- fixed: 1 1;
align: 0.0 0.0;
visible: 0;
}
@@ -299,7 +297,6 @@ group {
rel2 {
to: "service_content_area_swallow_padding";
}
- fixed: 1 1;
align: 0.0 0.0;
}
}
@@ -413,4 +410,4 @@ group {
target: "bg";
}
}
-}
+} \ No newline at end of file
diff --git a/data/viewer/icon.edc b/data/viewer/icon.edc
index 44f67a3..c4b673e 100644
--- a/data/viewer/icon.edc
+++ b/data/viewer/icon.edc
@@ -418,62 +418,4 @@ group {
target: "icon";
}
}
-}
-
-group {
- name: "accessibility";
- images {
- image: "ico_settings_accessibility.png" COMP;
- }
- parts {
- part {
- name: "icon";
- type: IMAGE;
- scale: 1;
- description {
- state: "default" 0.0;
- image.normal: "ico_settings_accessibility.png";
- color: 255 255 255 153;
- }
- description {
- state: "focused" 0.0;
- image.normal: "ico_settings_accessibility.png";
- }
- description {
- state: "highlight" 0.0;
- inherit: "focused" 0.0;
- color: 255 255 255 255;
- }
- }
- }
- programs {
- program {
- name: MAIN_BTN_NORMAL;
- signal: MAIN_BTN_NORMAL;
- source: MAIN_BTN;
- action: STATE_SET "default" 0.0;
- target: "icon";
- }
- program {
- name: MAIN_BTN_FOCUSED;
- signal: MAIN_BTN_FOCUSED;
- source: MAIN_BTN;
- action: STATE_SET "focused" 0.0;
- target: "icon";
- }
- program {
- name: MAIN_BTN_UNFOCUSED;
- signal: MAIN_BTN_UNFOCUSED;
- source: MAIN_BTN;
- action: STATE_SET "default" 0.0;
- target: "icon";
- }
- program {
- name: MAIN_BTN_HIGHLIGHT;
- signal: MAIN_BTN_HIGHLIGHT;
- source: MAIN_BTN;
- action: STATE_SET "highlight" 0.0;
- target: "icon";
- }
- }
-}
+} \ No newline at end of file
diff --git a/data/viewer/maincatalog.edc b/data/viewer/maincatalog.edc
index c5c65b0..92be2bb 100644
--- a/data/viewer/maincatalog.edc
+++ b/data/viewer/maincatalog.edc
@@ -153,7 +153,6 @@ group {
to: MAIN_VIEW_PADDING_ICON;
}
align: 0.0 0.0;
- fixed: 1 1;
}
}
part {
diff --git a/data/widget/progressbar.edc b/data/widget/progressbar.edc
index 3c65992..75109b9 100644
--- a/data/widget/progressbar.edc
+++ b/data/widget/progressbar.edc
@@ -348,7 +348,6 @@ group {
size: 18*2;
min: 1 0;
text_class: "tizen";
- ellipsis: -1;
}
fixed: 1 1;
}
diff --git a/include/dbg.h b/include/dbg.h
new file mode 100644
index 0000000..5641211
--- /dev/null
+++ b/include/dbg.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __DBG_H__
+#define __DBG_H__
+
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "org.tizen.settings-tv-ref"
+
+#ifndef _ERR
+#define _ERR(fmt, args...) (LOGE("[%s:%d] "fmt"\n", __func__, __LINE__, ##args))
+#endif
+
+#ifndef _DBG
+#define _DBG(fmt, args...) (LOGD("[%s:%d] "fmt"\n", __func__, __LINE__, ##args))
+#endif
+
+#ifndef _INFO
+#define _INFO(fmt, args...) \
+ (LOGI("[%s:%d] "fmt"\n", __func__, __LINE__, ##args))
+#endif
+
+#endif /* __DBG_H__ */
diff --git a/include/common_defs.h b/include/def.h
index fa0519e..fed4bd5 100644
--- a/include/common_defs.h
+++ b/include/def.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef __COMMON_DEFS_H__
-#define __COMMON_DEFS_H__
+#ifndef __DEF_H__
+#define __DEF_H__
#define WIN_WIDTH 1920
#define WIN_HEIGHT 1080
@@ -266,44 +266,23 @@
#define TEXT_STYLE_MEDIUM "Tizen Sans:style=Medium"
#define TEXT_STYLE_BOLD "Tizen Sans:style=Bold"
-/* VCONF KEYS */
-
-/* Proxy */
-#define VCONF_NETWORK_TYPE "db/menu/network/network_type"
-#define VCONF_PROXY_METHOD "db/menu/proxy/method"
-#define VCONF_PROXY_IP "db/menu/proxy/ip"
-#define VCONF_PROXY_URL "db/menu/proxy/url"
-
-/* Network */
-#define WIRED_DNS_KEY "db/menu/network/wired_dns"
-#define WIRED_GATEWAY_KEY "db/menu/network/wired_gateway"
-#define WIRED_IP_LAST_MODE "db/menu/network/wired_ip_mode"
-#define WIRED_DNS_LAST_MODE "db/menu/network/wired_dns_mode"
-#define WIRED_IP_KEY "db/menu/network/wired_ip"
-#define WIRED_SUBMASK_KEY "db/menu/network/wired_subnet"
-
-#define WIRELESS_DNS_KEY "db/menu/network/wireless_dns"
-#define WIRELESS_GATEWAY_KEY "db/menu/network/wireless_gateway"
-#define WIRELESS_IP_LAST_MODE "db/menu/network/wireless_ip_mode"
-#define WIRELESS_DNS_LAST_MODE "db/menu/network/wireless_dns_mode"
-#define WIRELESS_IP_KEY "db/menu/network/wireless_ip"
-#define WIRELESS_SUBMASK_KEY "db/menu/network/wireless_subnet"
-
-/* Time */
-#define KEY_SYSTEM_CLOCK_MODE "db/menu/system/time/clock/clock_mode"
-#define KEY_SLEEPTIMER "db/menu/system/time/sleeptimer/value"
-#define KEY_SLEEPTIMER_TIMERID "db/menu/system/time/sleeptimer/timer_id"
-#define KEY_WAKEUP_TIMER_SETUP "db/menu/system/time/ontimer1/setup"
-
-#define VCONF_KEY_24HOUR_MODE "db/menu/system/clock/24hour_mode"
-#define KEY_CHANGE_PASSCODE "db/menu/system/change_pin"
-#define KEY_SUBTITLE_LANGUAGE "db/menu/subtitle/subtitlelanguage"
-
-/* Broadcasting */
-#define KEY_CHANNEL_LOCK "db/menu/broadcasting/channel_lock"
-
-/* Lang and Region */
-#define KEY_SYSTEM_LANGUAGE "db/menu_widget/language"
-#define KEY_SYSTEM_COUNTRY "db/menu_widget/regionformat"
-
-#endif /* __COMMON_DEFS_H__ */
+/* Key defines */
+#define KEY_UP "Up"
+#define KEY_DOWN "Down"
+#define KEY_LEFT "Left"
+#define KEY_RIGHT "Right"
+#define KEY_ENTER "Return"
+#define KEY_EXIT "XF86Close"
+
+#define KEY_0 "0"
+#define KEY_1 "1"
+#define KEY_2 "2"
+#define KEY_3 "3"
+#define KEY_4 "4"
+#define KEY_5 "5"
+#define KEY_6 "6"
+#define KEY_7 "7"
+#define KEY_8 "8"
+#define KEY_9 "9"
+
+#endif /* __DEF_H__ */
diff --git a/include/settingviewmgr.h b/include/settingviewmgr.h
deleted file mode 100644
index 3acf9d2..0000000
--- a/include/settingviewmgr.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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.
- */
-
-#ifndef __SETTING_VIEW_MGR_H__
-#define __SETTING_VIEW_MGR_H__
-
-
-#include <Elementary.h>
-#include "data_wrapper.h"
-//#include "viewmgr.h"
-
-
-#define SELECTED_ITEM_ID "bottomslider_selected_item"
-
-#define VCLASS_TITLE_MAIN_VIEW "Main View"
-#define VCLASS_TITLE_BOTTOM_SLIDER "Bottom Slider"
-#define VCLASS_TITLE_BOTTOM_SUBLIST "Bottom Sublist"
-#define VCLASS_TITLE_DEVICE_MANAGER "Device Manager"
-#define VCLASS_TITLE_CHANGE_PASSCODE "Change Passcode"
-#define VCLASS_TITLE_RESET_POPUP "Reset Popup"
-#define VCLASS_TITLE_SUBLIST "Sublist"
-#define VCLASS_TITLE_SYSTEM_CLOCK "System Clock"
-#define VCLASS_TITLE_UG "UI Gadget"
-#define VCLASS_TITLE_UPGRADE "Upgrade Software"
-#define VCLASS_TITLE_NEED_PASSCODE "Need Passcode"
-
-
-struct evas_obj_data {
- Evas_Object *subitem_box;
- Evas_Object *cur_btn;
-
- const char *display_name;
-};
-
-struct obj_geometry_data {
- int width;
- int height;
- int x;
- int y;
-};
-
-class CSettingMgr;
-
-
-class CSettingBaseView {
-private:
- char *m_title;
-
-public:
- CSettingBaseView(const char *pViewId);
- virtual ~CSettingBaseView();
- const char *ViewId(void) { return m_title; }
-
- virtual bool Create(struct settingview_data *view, void *prev) { return false; }
- virtual void Show(void) {}
- virtual void Pause(void) {}
- virtual void Resume(void) {}
- virtual void Refresh(void) {}
- virtual void Update(void) {}
- virtual void Hide(void) {}
- virtual void Destroy(void) {}
- virtual void LangChanged(void) {}
- virtual void Frozen(void) {}
- virtual void Active(void) {}
-
- const char *Title(void) { return m_title; }
- virtual Evas_Object *Base(void);
-
- int hide_view;
-
-
- /*void(*show)(Evas_Object *base);
- void(*pause)(Evas_Object *base);
- void(*resume)(Evas_Object *base);
- void(*refresh)(Evas_Object *base);
- void(*update)(Evas_Object *base);
- void(*hide)(Evas_Object *base);
- void(*destroy)(Evas_Object *base);
- void(*lang_changed)(Evas_Object *base);
- void(*frozen)(Evas_Object *base);
- void(*active)(Evas_Object *base);
- int hide_view;*/
-};
-
-/*
-struct setting_class {
- const char *title;
- Evas_Object * (*create)(CSettingMgr *mgr,
- struct settingview_data *view, void *prev);
- void (*show)(Evas_Object *base);
- void (*pause)(Evas_Object *base);
- void (*resume)(Evas_Object *base);
- void (*refresh)(Evas_Object *base);
- void (*update)(Evas_Object *base);
- void (*hide)(Evas_Object *base);
- void (*destroy)(Evas_Object *base);
- void (*lang_changed)(Evas_Object *base);
- void (*frozen)(Evas_Object *base);
- void (*active)(Evas_Object *base);
- int hide_view;
-};*/
-
-
-class CSettingMgr {
-private:
- static CSettingMgr *instance;
- struct SSettingMgr *m;
-
-protected:
- CSettingMgr() : m(0) {}
- virtual ~CSettingMgr() {}
-
-public:
- static bool Initialize(Evas_Object *win);
- static void Finalize(void);
-
- static CSettingMgr *GetInstance(void);
-
- bool ViewPush(const char *name, void *data);
- void ViewPop(void);
- Evas_Object *Window(void);
-
- settingview_data *GetView(const char *name);
- settingmgr_data *GetData(void);
- Eina_List *GetViewList(void);
-
- bool LaunchItem(const char *name);
- Eina_Array *GetItemPath(void);
- void ViewRefresh(void);
- void SetRefreshFlag(unsigned int val);
- unsigned int GetRefreshFlag(void);
- void SetRelaunchFlag(unsigned int val);
- unsigned int GetRelaunchFlag(void);
- void FreezeTimeout(void);
- void ThawTimeout(void);
- Eina_Bool GetTimeoutFreezeState(void);
- void LangChanged(void);
-};
-
-
-#endif /* __SETTING_VIEW_MGR_H__ */
diff --git a/include/timeout_handler.h b/include/timeout_handler.h
index ee94854..5b0aaad 100644
--- a/include/timeout_handler.h
+++ b/include/timeout_handler.h
@@ -17,33 +17,15 @@
#ifndef __TIMEOUT_HANDLER_H__
#define __TIMEOUT_HANDLER_H__
-
#define TIMEOUT_SECS 60
-
-class CTimeoutHandler {
-private:
- struct STimeoutHandler *m;
-
-public:
- CTimeoutHandler() : m(0) {}
- virtual ~CTimeoutHandler() {}
-
- bool Create(double val);
- virtual void Destroy(void);
-
- void FreezeTimer(void);
- void ThawTimer(void);
- void ChangeInterval(double val);
-};
-/*struct timeout_handler;
+struct timeout_handler;
void timeout_handler_freeze_timer(struct timeout_handler *data);
void timeout_handler_thaw_timer(struct timeout_handler *data);
-void timeout_handler_change_interval(struct timeout_handler *data, double val);
-
+void timeout_handler_change_interval(struct timeout_handler *data,
+ double val);
struct timeout_handler *timeout_handler_init(double val);
-void timeout_handler_fini(struct timeout_handler *data);*/
-
+void timeout_handler_fini(struct timeout_handler *data);
#endif /* __TIMEOUT_HANDLER_H__ */
diff --git a/include/utils.h b/include/utils.h
index cd7e1b4..f303486 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -23,7 +23,8 @@
#define i18n_init() bindtextdomain(PACKAGE, LOCALEDIR)
char *utils_get_translation_str(const char *msgid);
-Evas_Object *utils_add_btn(Evas_Object *parent, const char *style, const char *text, Eina_Bool event);
+Evas_Object *utils_add_btn(Evas_Object *parent,
+ char *style, const char *text, Eina_Bool event);
Evas_Object *utils_add_scroller(Evas_Object *base);
Evas_Object *utils_add_box(Evas_Object *base);
Evas_Object *utils_add_ctxpopup(Evas_Object *base, char *style);
diff --git a/include/view_bottomslider.h b/include/view_bottomslider.h
new file mode 100644
index 0000000..bff6532
--- /dev/null
+++ b/include/view_bottomslider.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __VIEW_BOTTOMSLIDER_H__
+#define __VIEW_BOTTOMSLIDER_H__
+
+#include "viewmgr.h"
+
+struct setting_class *view_bottomslider_get_vclass(void);
+
+#endif /* __VIEW_BOTTOMSLIDER_H__ */
diff --git a/include/view_bottomsublist.h b/include/view_bottomsublist.h
new file mode 100644
index 0000000..ad32007
--- /dev/null
+++ b/include/view_bottomsublist.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __VIEW_BOTTOMSUBLIST_H__
+#define __VIEW_BOTTOMSUBLIST_H__
+
+#include "viewmgr.h"
+
+struct setting_class *view_bottomsublist_get_vclass(void);
+
+#endif /* __VIEW_BOTTOMSUBLIST_H__ */
diff --git a/include/view_device_manager.h b/include/view_device_manager.h
new file mode 100644
index 0000000..09d9ee1
--- /dev/null
+++ b/include/view_device_manager.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __VIEW_DEVICE_MANAGER_H__
+#define __VIEW_DEVICE_MANAGER_H__
+
+#include "viewmgr.h"
+
+struct setting_class *view_device_manager_get_vclass(void);
+
+#endif /* __VIEW_DEVICE_MANAGER_H__ */
diff --git a/include/view_maincatalog.h b/include/view_maincatalog.h
index 0124b7c..675379a 100644
--- a/include/view_maincatalog.h
+++ b/include/view_maincatalog.h
@@ -17,57 +17,8 @@
#ifndef __VIEW_MAINMENU_H__
#define __VIEW_MAINMENU_H__
+#include "viewmgr.h"
-#include "settingviewmgr.h"
-
-
-class CMainCatalogView :
- public CSettingBaseView,
- public CListenerMgr,
- public IMouseClickedListener,
- public IKeyUpListener,
- public IKeyDownListener
-{
-private:
- struct SMainCatalog *m;
-
- static void sm_CbViewAniFinish(void *data, Evas_Object *obj, const char *emission, const char *source);
- void m_OnViewAniFinish(Evas_Object *obj, const char *emission, const char *source);
-
- static void sm_CbMainItemBtnMouseIN(void *data, Evas *e, Evas_Object *obj, void *ei);
- void m_OnMainItemMouseIN(Evas *e, Evas_Object *obj, void *ei);
-
- void m_SubItemClicked(Evas_Object *obj);
- bool m_DrawSubItems(const char *name);
- void m_MoveFromMainitemToSubitem(Evas_Object *mainbtn);
- void m_MoveFromSubitemToMainitem(Evas_Object *btn);
- bool m_AddIconBtns(Eina_List *list);
- void m_DrawMainItems(void);
-
-public:
- CMainCatalogView(const char *pViewId) :
- CSettingBaseView(pViewId),
- IMouseClickedListener(this),
- IKeyUpListener(this),
- IKeyDownListener(this),
- m(0) {}
- virtual ~CMainCatalogView() {}
-
- Evas_Object *Base(void);
-
- virtual bool Create(struct settingview_data *view, void *prev);
- virtual void Show(void);
- virtual void Refresh(void);
- virtual void Hide(void);
- virtual void Destroy(void);
- virtual void LangChanged(void);
- virtual void Frozen(void);
- virtual void Active(void);
-
- virtual void OnMouseClicked(int id, Evas_Object *obj);
- virtual void OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev);
- virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev);
-};
-
+struct setting_class *view_maincatalog_get_vclass(void);
#endif /* __VIEW_MAINMENU_H__ */
diff --git a/include/view_need_pwd.h b/include/view_need_pwd.h
index 0ae50bc..7dafdf2 100644
--- a/include/view_need_pwd.h
+++ b/include/view_need_pwd.h
@@ -17,35 +17,8 @@
#ifndef __VIEW_NEED_PASSCODE_H__
#define __VIEW_NEED_PASSCODE_H__
+#include "viewmgr.h"
-#include "settingviewmgr.h"
-
-
-class CNeedPasscodeView :
- public CSettingBaseView {
-private:
- struct SNeedPasscodeView *m;
-
-private:
- static void sm_CbCtxpopupDismissed(void *priv, Evas_Object *obj, void *ev);
- void m_OnCtxpopupDismissed(Evas_Object *obj, void *ev);
-
- static void sm_CbKeyDown(void *priv, Evas *e, Evas_Object *obj, void *ei);
- void m_OnKeyDown(Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev);
-
- int m_AddViewEntries(void);
-
-public:
- CNeedPasscodeView(const char *pViewId) : CSettingBaseView(pViewId), m(0) {}
- virtual ~CNeedPasscodeView() {}
-
- Evas_Object *Base(void);
-
- virtual bool Create(struct settingview_data *view, void *prev);
- virtual void Show(void);
- virtual void Refresh(void);
- virtual void Hide(void);
- virtual void Destroy(void);
-};
+struct setting_class *view_need_passcode_get_vclass(void);
#endif /* __VIEW_NEED_PASSCODE_H__ */
diff --git a/include/view_pwd_popup.h b/include/view_pwd_popup.h
index 9a40adf..58cb88f 100644
--- a/include/view_pwd_popup.h
+++ b/include/view_pwd_popup.h
@@ -17,31 +17,8 @@
#ifndef __VIEW_PASSCODE_POPUP_H__
#define __VIEW_PASSCODE_POPUP_H__
+#include "viewmgr.h"
-#include "settingviewmgr.h"
-
-
-//struct setting_class *view_passcode_popup_get_vclass(void);
-class CPasscodePopupView :
- public CSettingBaseView {
-private:
- struct SPasscodePopupView *m;
-
-private:
- static void sm_CbCtxpopupDismissed(void *priv, Evas_Object *obj, void *ev);
- void m_OnCtxpopupDismissed(Evas_Object *obj, void *ev);
-
-public:
- CPasscodePopupView(const char *pViewId) : CSettingBaseView(pViewId), m(0) {}
- virtual ~CPasscodePopupView() {}
-
- Evas_Object *Base(void);
-
- virtual bool Create(struct settingview_data *view, void *prev);
- virtual void Show(void);
- virtual void Hide(void);
- virtual void Destroy(void);
-};
-
+struct setting_class *view_passcode_popup_get_vclass(void);
#endif /* __VIEW_PASSCODE_POPUP_H__ */
diff --git a/include/view_resetpopup.h b/include/view_resetpopup.h
new file mode 100644
index 0000000..d9673d9
--- /dev/null
+++ b/include/view_resetpopup.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __VIEW_RESETPOPUP_H__
+#define __VIEW_RESETPOPUP_H__
+
+#include "viewmgr.h"
+
+struct setting_class *view_resetpopup_get_vclass(void);
+
+#endif /* __VIEW_RESETPOPUP_H__ */
diff --git a/include/view_sublist.h b/include/view_sublist.h
index 81dd8c1..930faaa 100644
--- a/include/view_sublist.h
+++ b/include/view_sublist.h
@@ -17,54 +17,8 @@
#ifndef __VIEW_SUBLIST_H__
#define __VIEW_SUBLIST_H__
+#include "viewmgr.h"
-#include "settingviewmgr.h"
-
-
-class CSublistView :
- public CSettingBaseView,
- public CListenerMgr,
- public IFocusedListener,
- public IUnfocusedListener,
- public IMouseClickedListener,
- public IKeyDownListener
-{
-private:
- struct SSublistView *m;
-
-private:
- static void sm_CbCtxpopupDismissed(void *data, Evas_Object *obj, void *ev);
- void m_OnCtxpopupDismissed(Evas_Object *obj, void *ev);
-
- bool m_DrawCtxpopupLayout(void);
- bool m_DrawSublist(void);
- void m_ExitView(void);
- void m_SetSelectedValue(Evas_Object *obj);
- bool m_DrawListItems(Eina_List *list);
-
-public:
- CSublistView(const char *pViewId) :
- CSettingBaseView(pViewId),
- IFocusedListener(this),
- IUnfocusedListener(this),
- IMouseClickedListener(this),
- IKeyDownListener(this),
- m(0) {}
- virtual ~CSublistView() {}
-
- Evas_Object *Base(void);
-
- virtual bool Create(struct settingview_data *view, void *prev);
- virtual void Show(void);
- virtual void Hide(void);
- virtual void Destroy(void);
-
-public:
- virtual void OnMouseClicked(int id, Evas_Object *obj);
- virtual void OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item);
- virtual void OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item);
- virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev);
-};
-
+struct setting_class *view_sublist_get_vclass(void);
#endif /* __VIEW_SUBLIST_H__ */
diff --git a/include/view_system_clock.h b/include/view_system_clock.h
index 80175aa..2e9eb3f 100644
--- a/include/view_system_clock.h
+++ b/include/view_system_clock.h
@@ -17,55 +17,8 @@
#ifndef _VIEW_SYSTEM_CLOCK_H__
#define _VIEW_SYSTEM_CLOCK_H__
+#include "viewmgr.h"
-#include "settingviewmgr.h"
-
-
-class CSystemClockView :
- public CSettingBaseView,
- public CListenerMgr,
- public IFocusedListener,
- public IUnfocusedListener,
- public IMouseClickedListener,
- public IKeyDownListener
-{
-private:
- struct SSystemClockView *m;
-
-private:
- static void sm_CbCtxpopupDismissed(void *priv, Evas_Object *obj, void *ev);
- void m_OnCtxpopupDismissed(Evas_Object *obj, void *ev);
-
- void m_ExitView(void);
-
- bool m_DrawSysclkSublist(void);
- bool m_AddSysclkSublistItem(Eina_List *list, const char *selval);
-
-public:
- CSystemClockView(const char *pViewId) :
- CSettingBaseView(pViewId),
- IFocusedListener(this),
- IUnfocusedListener(this),
- IMouseClickedListener(this),
- IKeyDownListener(this),
- m(0) {}
- virtual ~CSystemClockView() {}
-
- Evas_Object *Base(void);
-
- virtual bool Create(struct settingview_data *view, void *prev);
- virtual void Show(void);
- virtual void Refresh(void);
- virtual void Hide(void);
- virtual void Destroy(void);
-
-public:
- // If buttons are clicked
- virtual void OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item);
- virtual void OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item);
- virtual void OnMouseClicked(int id, Evas_Object *obj);
- virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev);
-};
-
+struct setting_class *view_system_clock_get_vclass(void);
#endif /* _VIEW_SYSTEM_CLOCK_H__ */
diff --git a/include/view_uigadget.h b/include/view_uigadget.h
index 367c256..d35ee8b 100644
--- a/include/view_uigadget.h
+++ b/include/view_uigadget.h
@@ -17,58 +17,8 @@
#ifndef __VIEW_UIGADGET_H__
#define __VIEW_UIGADGET_H__
+#include "viewmgr.h"
-#include <ui-gadget.h>
-#include "settingviewmgr.h"
-
-
-class CUiGadget {
-private:
- ui_gadget_h m_handler;
-private:
- static void sm_CbLayout(ui_gadget_h ug, enum ug_mode mode, void *priv);
- static void sm_CbResult(ui_gadget_h ug, service_h result, void *priv);
- static void sm_CbDestroy(ui_gadget_h ug, void *priv);
- static void sm_CbEnd(ui_gadget_h ug, void *priv);
-
-protected:
-
- virtual void t_OnLayout(ui_gadget_h ug, ug_mode mode) {}
- virtual void t_OnResult(ui_gadget_h ug, service_h result) {}
- virtual void t_OnDestroy(ui_gadget_h ug) {}
- virtual void t_OnEnd(ui_gadget_h ug) {}
-
-public:
- CUiGadget() : m_handler(0) {}
-
- bool Create(ui_gadget_h parent, const char *name, ug_mode mode, service_h service);
- virtual void Destroy(void);
-};
-
-class CUiGadgetView :
- public CSettingBaseView,
- public CUiGadget {
-private:
- struct SUiGadgetView *m;
-
-protected:
- virtual void t_OnDestroy(ui_gadget_h ug);
-
-private:
- bool m_Load(void);
- void m_BackToMainview(void);
-
-public:
- CUiGadgetView(const char *pViewId) : CSettingBaseView(pViewId), m(0) {}
- virtual ~CUiGadgetView() {}
-
- Evas_Object *Base(void);
-
- virtual bool Create(struct settingview_data *view, void *prev);
- virtual void Show(void);
- virtual void Hide(void);
- virtual void Destroy(void);
-};
-
+struct setting_class *view_uigadget_get_vclass(void);
#endif /* __VIEW_UIGADGET_H__ */
diff --git a/include/view_upgrade_popup.h b/include/view_upgrade_popup.h
new file mode 100644
index 0000000..9364ead
--- /dev/null
+++ b/include/view_upgrade_popup.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __VIEW_UPGRADE_POPUP_H__
+#define __VIEW_UPGRADE_POPUP_H__
+
+#include "viewmgr.h"
+
+#define UPGRADE_SW_TITLE "Software upgrade"
+#define UPGRADE_SW_NOW "Update now"
+#define UPGRADE_SW_AVAIL_TEXT "A new software update is available.\
+ <br>Upgrade from version A to version B?"
+#define UPGRADE_SW_UNAVAIL_TEXT "There are no new updates\
+ <br>for you at the moment."
+#define NETWORK_DISCONNECTED_TEXT "Please check that your network \
+ <br>has been configured."
+#define INTERNET_DISCONNECTED_TEXT "Fail to connect.\
+ <br>Please contact your Internet Service Provider."
+#define UPDATE_UP_TEXT "Checking for updates..."
+#define UPDATE_MIDDLE_TEXT "Last checked for updates<br>"
+#define DYNAMIC_TEXT "Checking for network..."
+
+#define UPGRADE_BTN_BOX_PADDING 20
+
+enum {
+ UPGRADE_BTN_0,
+ UPGRADE_BTN_1,
+ UPGRADE_BTN_MAX
+};
+struct setting_class *view_upgrade_popup_get_vclass(void);
+
+#endif /* __VIEW_UPGRADE_POPUP_H__ */ \ No newline at end of file
diff --git a/include/viewmgr.h b/include/viewmgr.h
new file mode 100644
index 0000000..40843aa
--- /dev/null
+++ b/include/viewmgr.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __VIEWMGR_H__
+#define __VIEWMGR_H__
+
+#include <Elementary.h>
+#include "data_wrapper.h"
+
+#define SELECTED_ITEM_ID "bottomslider_selected_item"
+
+#define VCLASS_TITLE_MAIN_VIEW "Main View"
+#define VCLASS_TITLE_BOTTOM_SLIDER "Bottom Slider"
+#define VCLASS_TITLE_BOTTOM_SUBLIST "Bottom Sublist"
+#define VCLASS_TITLE_DEVICE_MANAGER "Device Manager"
+#define VCLASS_TITLE_CHANGE_PASSCODE "Change Passcode"
+#define VCLASS_TITLE_RESET_POPUP "Reset Popup"
+#define VCLASS_TITLE_SUBLIST "Sublist"
+#define VCLASS_TITLE_SYSTEM_CLOCK "System Clock"
+#define VCLASS_TITLE_UG "UI Gadget"
+#define VCLASS_TITLE_UPGRADE "Upgrade Software"
+#define VCLASS_TITLE_NEED_PASSCODE "Need Passcode"
+
+struct setting_mgr;
+
+struct evas_obj_data {
+ Evas_Object *subitem_box;
+ Evas_Object *cur_btn;
+
+ const char *display_name;
+};
+
+struct obj_geometry_data {
+ int width;
+ int height;
+ int x;
+ int y;
+};
+
+struct setting_class {
+ const char *title;
+ Evas_Object * (*create)(struct setting_mgr *mgr,
+ struct settingview_data *view, void *prev);
+ void (*show)(Evas_Object *base);
+ void (*pause)(Evas_Object *base);
+ void (*resume)(Evas_Object *base);
+ void (*refresh)(Evas_Object *base);
+ void (*update)(Evas_Object *base);
+ void (*hide)(Evas_Object *base);
+ void (*destroy)(Evas_Object *base);
+ void (*lang_changed)(Evas_Object *base);
+ void (*frozen)(Evas_Object *base);
+ void (*active)(Evas_Object *base);
+ int hide_view;
+};
+
+struct setting_mgr *settingmgr_init(Evas_Object *win);
+void settingmgr_fini(struct setting_mgr *mgr);
+int settingmgr_view_push(struct setting_mgr *mgr,
+ const char *name, void *data);
+void settingmgr_view_pop(struct setting_mgr *mgr);
+Evas_Object *settingmgr_get_win(struct setting_mgr *mgr);
+struct settingview_data *settingmgr_get_view(struct setting_mgr *mgr,
+ const char *name);
+struct settingmgr_data *settingmgr_get_data(struct setting_mgr *mgr);
+Eina_List *settingmgr_get_view_list(struct setting_mgr *mgr);
+int settingmgr_launch_item(struct setting_mgr *mgr,
+ const char *name);
+Eina_Array *settingmgr_get_item_path(struct setting_mgr *mgr);
+void settingmgr_view_refresh(struct setting_mgr *mgr);
+void settingmgr_set_refresh_flag(struct setting_mgr *mgr,
+ unsigned int val);
+unsigned int settingmgr_get_refresh_flag(struct setting_mgr *mgr);
+void settingmgr_set_relaunch_flag(struct setting_mgr *mgr,
+ unsigned int val);
+unsigned int settingmgr_get_relaunch_flag(struct setting_mgr *mgr);
+void settingmgr_freeze_timeout(struct setting_mgr *mgr);
+void settingmgr_thaw_timeout(struct setting_mgr *mgr);
+Eina_Bool settingmgr_get_timeout_freeze_state(struct setting_mgr *mgr);
+void settingmgr_lang_changed(struct setting_mgr *mgr);
+
+#endif /* __VIEWMGR_H__ */
diff --git a/json/accessibility.json b/json/accessibility.json
deleted file mode 100644
index ecf70d5..0000000
--- a/json/accessibility.json
+++ /dev/null
@@ -1,57 +0,0 @@
-{
- "settingitems": {
- "screen-reader": {
- "display-name": "Screen Reader",
- "style": "title.value",
- "setting-ui": {
- "style": "ctxpopup"
- },
- "data": {
- "key": "settings/accessibility/screen_reader",
- "type": "bool",
- "list": [
- {
- "display-value": "OFF",
- "value": "0"
- },
- {
- "display-value": "ON",
- "value": "1"
- }
- ]
- }
- },
- "magnifier": {
- "display-name": "Magnifier",
- "style": "title.value",
- "status": "disabled",
- "setting-ui": {
- "style": "ctxpopup"
- },
- "data": {
- "key": "settings/accessibility/magnifier",
- "type": "bool",
- "list": [
- {
- "display-value": "OFF",
- "value": "0"
- },
- {
- "display-value": "ON",
- "value": "1"
- }
- ]
- }
- }
- },
- "settingtree": {
- "accessibility": {
- "subsettingitems": [
- "screen-reader",
- "magnifier"
- ],
- "parentitem": "maincatalog"
- }
- }
-}
-
diff --git a/json/maincatalog.json b/json/maincatalog.json
index 887a747..85aa908 100644
--- a/json/maincatalog.json
+++ b/json/maincatalog.json
@@ -34,11 +34,6 @@
"display-name": "SUPPORT",
"style": "animicon",
"resource-file": "support.edj"
- },
- "accessibility": {
- "display-name": "ACCESSIBILITY",
- "style": "animicon",
- "resource-file": "accessibility.edj"
}
},
"settingtree": {
@@ -50,8 +45,7 @@
"network",
"device-manager",
"system",
- "support",
- "accessibility"
+ "support"
],
"parentitem": "maincatalog"
}
diff --git a/org.tizen.settings-tv-ref.png b/org.tizen.settings-tv-ref.png
index a29a76d..8b143f3 100644
--- a/org.tizen.settings-tv-ref.png
+++ b/org.tizen.settings-tv-ref.png
Binary files differ
diff --git a/org.tizen.settings-tv-ref_4x2.png b/org.tizen.settings-tv-ref_4x2.png
index f9c5887..a02e5e7 100644
--- a/org.tizen.settings-tv-ref_4x2.png
+++ b/org.tizen.settings-tv-ref_4x2.png
Binary files differ
diff --git a/src/data_wrapper.cpp b/src/data_wrapper.c
index e4fe18a..59327bf 100644
--- a/src/data_wrapper.cpp
+++ b/src/data_wrapper.c
@@ -14,12 +14,11 @@
* limitations under the License.
*/
-#include <cstring>
#include <Eina.h>
#include <glib-object.h>
#include <json-glib/json-glib.h>
#include "data_wrapper.h"
-#include <MacroDefine.h>
+#include "dbg.h"
struct settingui_args {
char *keyname;
@@ -106,15 +105,13 @@ static void _free_slider_item(struct slideritem *item)
static void _free_list_item(Eina_List *list)
{
struct listitem *litem;
- void* obj;
if (!list) {
_ERR("Invalid argument");
return;
}
- EINA_LIST_FREE(list, obj) {
- litem = (struct listitem *) obj;
+ EINA_LIST_FREE(list, litem) {
free(litem->display_name);
free(litem->value);
free(litem);
@@ -150,15 +147,13 @@ static void _free_uidata(struct uidata *data)
static void _free_ui_args(Eina_List *list)
{
struct settingui_args *args;
- void* obj;
if (!list) {
_ERR("Invalid argument");
return;
}
- EINA_LIST_FREE(list, obj) {
- args = (struct settingui_args *) obj;
+ EINA_LIST_FREE(list, args) {
free(args->keyname);
free(args->value);
free(args);
@@ -192,19 +187,15 @@ static void _free_setting_ui(struct setting_ui *data)
*/
static void _free_str_list(Eina_List *list)
{
- void* obj;
- char* item;
+ char *item;
if (!list) {
_ERR("Invalid argument");
return;
}
- EINA_LIST_FREE(list, obj)
- {
- item = (char *) obj;
+ EINA_LIST_FREE(list, item)
free(item);
- }
}
/**
@@ -223,7 +214,7 @@ static void _free_settingitem_cb(void *data)
return;
}
- item = (struct settingitem *)data;
+ item = data;
free(item->display_name);
free(item->style);
@@ -283,7 +274,7 @@ static struct slideritem *_read_slider_data_from_json(
return NULL;
}
- item = (struct slideritem *) calloc(1, sizeof(struct slideritem));
+ item = calloc(1, sizeof(struct slideritem));
if (!item)
return NULL;
@@ -347,7 +338,7 @@ static Eina_List *_read_list_data_from_json(
list = NULL;
for (i = 0; i < length; i++) {
- item = (struct listitem *) calloc(1, sizeof(struct listitem));
+ item = calloc(1, sizeof(struct listitem));
if (!item) {
_free_list_item(list);
return NULL;
@@ -405,13 +396,13 @@ static Eina_List *_get_settingui_args_list(
goto error;
}
- data = (struct settingui_args *) calloc(1, sizeof(*data));
+ data = calloc(1, sizeof(*data));
if (!data) {
_ERR("Allocate memory failed");
goto error;
}
- data->keyname = (char *) calloc(1, sizeof(char) * ARRAY_SIZE);
+ data->keyname = calloc(1, sizeof(char) * ARRAY_SIZE);
if (!data->keyname) {
_ERR("Allocate memory failed");
free(data);
@@ -459,7 +450,7 @@ static struct uidata *_get_datainfo_from_json(
return NULL;
}
- data = (struct uidata *) calloc(1, sizeof(struct uidata));
+ data = calloc(1, sizeof(struct uidata));
if (!data)
return NULL;
@@ -556,7 +547,7 @@ static void _get_iteminfo_from_json(struct json_parser *jparser,
jparser, buf);
} else if (!strncmp(list[i], JSONSTR_SETTINGUI,
strlen(list[i]))) {
- item->setting_ui = (struct setting_ui *) calloc(1, sizeof(struct setting_ui));
+ item->setting_ui = calloc(1, sizeof(struct setting_ui));
if (!item->setting_ui)
continue;
@@ -659,7 +650,7 @@ static struct settingitem *_get_settingitem_from_json(
return NULL;
}
- item = (struct settingitem *) calloc(1, sizeof(*item));
+ item = calloc(1, sizeof(*item));
if (!item)
return NULL;
@@ -760,7 +751,6 @@ static int _write_settingitems_to_hash(Eina_Hash *hash,
_ERR("parser_init failed!\n");
return -1;
}
- _DBG("CREATED Parser [Path = %s]",path);
reader = parser_get_json_reader(jparser);
if (!reader) {
@@ -779,7 +769,7 @@ static int _write_settingitems_to_hash(Eina_Hash *hash,
if (!newer)
continue;
- existed = (struct settingitem *) eina_hash_find(hash, list[i]);
+ existed = eina_hash_find(hash, list[i]);
if (!existed)
eina_hash_add(hash, list[i], newer);
else
@@ -787,7 +777,7 @@ static int _write_settingitems_to_hash(Eina_Hash *hash,
}
newer = _get_settingitem_from_json(jparser, name);
- existed = (struct settingitem *) eina_hash_find(hash, name);
+ existed = eina_hash_find(hash, name);
if (!existed)
eina_hash_add(hash, name, newer);
else
@@ -855,7 +845,7 @@ struct settingmgr_data *viewmgr_data_init(void)
{
struct settingmgr_data *data;
- data = (struct settingmgr_data *) calloc(1, sizeof(struct settingmgr_data));
+ data = calloc(1, sizeof(struct settingmgr_data));
if (!data) {
_ERR("calloc data failed\n");
return NULL;
@@ -880,8 +870,7 @@ struct settingmgr_data *viewmgr_data_init(void)
*/
void viewmgr_data_fini(struct settingmgr_data *data)
{
- char* node;
- void* obj;
+ char *node;
if (!data) {
_ERR("Parameter error!");
@@ -891,11 +880,8 @@ void viewmgr_data_fini(struct settingmgr_data *data)
_hash_fini(data->jsonhash);
if (data->parsed_json_file) {
- EINA_LIST_FREE(data->parsed_json_file, obj)
- {
- node = (char *) obj;
+ EINA_LIST_FREE(data->parsed_json_file, node)
free(node);
- }
}
free(data);
@@ -916,7 +902,7 @@ struct settingitem *viewmgr_data_get_settingitem(
if (!name || !data)
return NULL;
- item = (struct settingitem *) eina_hash_find(data->jsonhash, name);
+ item = eina_hash_find(data->jsonhash, name);
return item;
}
@@ -931,8 +917,7 @@ struct settingitem *viewmgr_data_get_settingitem(
int viewmgr_data_read_jsonfile_into_hash(
struct settingmgr_data *data, const char *name)
{
- char* tmp;
- void* obj;
+ char *tmp;
const char *style, *ui_name;
struct settingitem *item;
Eina_Hash *hash;
@@ -959,8 +944,7 @@ int viewmgr_data_read_jsonfile_into_hash(
if (style && ui_name && !strncmp(style, STYLE_UIGADGET, strlen(style)))
return 0;
- EINA_LIST_FOREACH(list, l, obj) {
- tmp = (char *) obj;
+ EINA_LIST_FOREACH(list, l, tmp) {
if (!strncmp(tmp, name, BUF_SIZE))
flag = 0;
}
@@ -993,7 +977,6 @@ struct settingview_data *viewmgr_data_build_view(
Eina_List *list, *l;
struct settingitem *item;
const char *node;
- void* obj;
struct settingview_data *vdata;
if (!sdata || !name) {
@@ -1014,8 +997,7 @@ struct settingview_data *viewmgr_data_build_view(
list = settingitem_get_subitems(vdata->parentitem);
if (list) {
vdata->childitems = eina_array_new(1);
- EINA_LIST_FOREACH(list, l, obj) {
- node = (const char *) obj;
+ EINA_LIST_FOREACH(list, l, node) {
item = viewmgr_data_get_settingitem(sdata, node);
if (!item) {
_ERR("childitem not found, continuing");
@@ -1461,7 +1443,7 @@ Eina_List *viewdata_get_childitems_list(struct settingview_data *view)
list = NULL;
cnt = eina_list_count(subitems);
for (i = 0; i < cnt; i++) {
- subitem = (struct settingitem *) eina_array_data_get(view->childitems, i);
+ subitem = eina_array_data_get(view->childitems, i);
list = eina_list_append(list, subitem);
}
@@ -1494,7 +1476,7 @@ struct settingview_data *viewdata_allocate(void)
{
struct settingview_data *vdata;
- vdata = (struct settingview_data *) calloc(1, sizeof(*vdata));
+ vdata = calloc(1, sizeof(*vdata));
if (!vdata) {
_ERR("Allocate memory failed\n");
return NULL;
@@ -1537,7 +1519,6 @@ Eina_List *settingitem_get_slider_group_list(struct settingitem *item,
Eina_List *l, *group, *result;
struct settingitem *sitem;
const char *node;
- void* obj;
int found;
if (!item || !sdata || !name) {
@@ -1551,8 +1532,7 @@ Eina_List *settingitem_get_slider_group_list(struct settingitem *item,
found = 0;
- EINA_LIST_FOREACH(group, l, obj) {
- node = (const char *) obj;
+ EINA_LIST_FOREACH(group, l, node) {
if (!strncmp(name, node, strlen(name))) {
found = 1;
break;
@@ -1564,8 +1544,7 @@ Eina_List *settingitem_get_slider_group_list(struct settingitem *item,
result = NULL;
- EINA_LIST_FOREACH(group, l, obj) {
- node = (const char *) obj;
+ EINA_LIST_FOREACH(group, l, node) {
sitem = viewmgr_data_get_settingitem(sdata, node);
if (_check_slider_item(sitem))
result = eina_list_append(result, node);
diff --git a/src/main.c b/src/main.c
new file mode 100644
index 0000000..c833162
--- /dev/null
+++ b/src/main.c
@@ -0,0 +1,324 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <app.h>
+#include <Elementary.h>
+#include <dlog.h>
+#include <ui-gadget.h>
+#include "dbg.h"
+#include "def.h"
+#include "viewmgr.h"
+#include "utils.h"
+#include "json_marco.h"
+#include "settings_provider.h"
+
+#define PARAM_SETTINGS_ITEM "settings-item"
+#define MAIN_CATALOG "maincatalog"
+
+struct _appdata {
+ Evas_Object *win;
+ struct setting_mgr *mgr;
+ const char *name;
+ char *item;
+ unsigned int service;
+};
+
+/**
+* Refresh first view stored in view list.
+*
+* Get first _settinginfo from view_list of setting_mgr, then call vclass->refresh
+* and vclass-update to refresh.
+*
+* @param priv [in] The function specific data which holds _appdata pointer.
+* @return void.
+*/
+static void _refresh(void *priv)
+{
+ struct _appdata *data;
+
+ if (!priv)
+ return;
+
+ data = priv;
+
+ if (!data->mgr)
+ return;
+
+ settingmgr_view_refresh(data->mgr);
+}
+
+/**
+* Add a basic win for settings app.
+*
+* @param name [in] Window name.
+* @return Window evas object, NULL on error.
+*/
+static Evas_Object *_add_win(const char *name)
+{
+ Evas_Object *win;
+
+ win = elm_win_add(NULL, name, ELM_WIN_BASIC);
+ if (!win) {
+ _ERR("failed to create window!");
+ return NULL;
+ }
+
+ elm_win_title_set(win, name);
+ elm_win_alpha_set(win, EINA_TRUE);
+
+ elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
+ elm_win_focus_highlight_style_set(win, DEFAULT_FOCUS_INVISIBLE);
+
+ evas_object_show(win);
+
+ return win;
+}
+
+/**
+* An app event callback for app_efl_main.
+*
+* This callback is invoked once as app is launched, this function will
+* initialize app.
+*
+* @param data [in] The function specific data passed by app_efl_main.
+* @return true if success, false if fail.
+*/
+static bool _create(void *data)
+{
+ struct _appdata *ad;
+ Evas_Object *win;
+ int r;
+
+ ad = data;
+ if (!ad)
+ return false;
+
+ elm_theme_overlay_add(NULL, EDJ_THEME);
+
+ win = _add_win(ad->name);
+ if (!win)
+ return false;
+
+ r = UG_INIT_EFL(win, UG_OPT_INDICATOR_ENABLE);
+ if (r == -1) {
+ _ERR("ug init efl failed.");
+ evas_object_del(win);
+ return false;
+ }
+
+ r = provider_init();
+ if (r != 0) {
+ _ERR("Fail to init provider module");
+ evas_object_del(win);
+ return false;
+ }
+
+ ad->win = win;
+ ad->service = 0;
+
+ return true;
+}
+
+/**
+* An app event callback for app_efl_main.
+*
+* This callback is invoked once just before app is terminated,
+* this functions will release all resources.
+*
+* @param data [in] The function specific data passed by app_efl_main.
+* @return void.
+*/
+static void _terminate(void *data)
+{
+ struct _appdata *ad;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ ad = data;
+
+ settingmgr_fini(ad->mgr);
+
+ provider_fini();
+
+ if (ad->win)
+ evas_object_del(ad->win);
+
+ free(ad->item);
+}
+
+/**
+* An app event callback for app_efl_main.
+*
+* This callback is invoked when the window of app become invisible.
+*
+* @param data [in] The function specific data passed by app_efl_main.
+* @return void.
+*/
+static void _pause(void *data)
+{
+}
+
+/**
+* An app event callback for app_efl_main.
+*
+* This callback is invoked when the window of app become visible.
+*
+* @param data [in] The function specific data passed by app_efl_main.
+* @return void.
+*/
+static void _resume(void *data)
+{
+}
+
+/**
+* An app event callback for app_efl_main.
+*
+* This callback is invoked after _create callback (just after app enters main loop)
+* or after "re-launch".
+*
+* @param service [in] The launching arguments.
+* @param data [in] The function specific data passed by app_efl_main.
+* @return void.
+*/
+static void _service(service_h service, void *data)
+{
+ struct _appdata *ad;
+ struct setting_mgr *mgr;
+ int r;
+ char *param;
+ unsigned int relaunch, refresh;
+
+ if (!data)
+ return;
+
+ ad = data;
+ param = NULL;
+
+ if (ad->service) {
+ service_get_extra_data(service, PARAM_SETTINGS_ITEM, &param);
+ if ((!param && !ad->item) ||
+ (param && ad->item &&
+ !strcmp(ad->item, param))) {
+ refresh = 1;
+ relaunch = 0;
+ } else {
+ refresh = 0;
+ relaunch = 1;
+ }
+
+ if (relaunch) {
+ settingmgr_fini(ad->mgr);
+ } else {
+ if (refresh)
+ _refresh(ad);
+
+ return;
+ }
+ }
+
+ mgr = settingmgr_init(ad->win);
+ if (!mgr)
+ app_efl_exit();
+
+ r = service_get_extra_data(service, PARAM_SETTINGS_ITEM, &param);
+ if (r == SERVICE_ERROR_NONE && param) {
+ r = settingmgr_launch_item(mgr, param);
+ if (r != 0) {
+ _ERR("the item is not exist.");
+ app_efl_exit();
+ }
+ } else {
+ settingmgr_view_push(mgr, MAIN_CATALOG, NULL);
+ }
+
+ ad->mgr = mgr;
+ ad->service = 1;
+
+ free(ad->item);
+ ad->item = param;
+}
+
+/**
+* An app event callback for app_efl_main.
+*
+* This callback is invoked when system language is changed.
+*
+* @param data [in] The function specific data passed by app_efl_main.
+* @return void.
+*/
+static void _lang_changed(void *data)
+{
+ struct _appdata *ad;
+
+ if (!data) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ ad = data;
+ if (!ad->mgr)
+ return;
+
+ settingmgr_lang_changed(ad->mgr);
+}
+
+/**
+* An app event callback for app_efl_main.
+*
+* This callback is invoked when system region is changed.
+*
+* @param data [in] The function specific data passed by app_efl_main.
+* @return void.
+*/
+static void _region_changed(void *data)
+{
+}
+
+/**
+* App launching entry.
+*
+* @param argc [in] The launching argument numbers.
+* @param argv [in] The launching argument array.
+* @return 0 if success.
+*/
+int main(int argc, char **argv)
+{
+ struct _appdata ad;
+ app_event_callback_s cbs = {
+ .create = _create,
+ .terminate = _terminate,
+ .pause = _pause,
+ .resume = _resume,
+ .service = _service,
+ .low_memory = NULL,
+ .low_battery = NULL,
+ .device_orientation = NULL,
+ .language_changed = _lang_changed,
+ .region_format_changed = _region_changed,
+ };
+
+ memset(&ad, 0x00, sizeof(ad));
+ ad.name = PACKAGE;
+
+ i18n_init();
+
+ app_efl_main(&argc, &argv, &cbs, &ad);
+
+ return 0;
+}
diff --git a/src/main.cpp b/src/main.cpp
deleted file mode 100644
index 2885fc0..0000000
--- a/src/main.cpp
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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 <ui-gadget.h>
-#include <vconf.h>
-#include <AppCommon.h>
-
-#include "common_defs.h"
-#include "json_marco.h"
-#include "settings_provider.h"
-#include "settingviewmgr.h"
-#include "utils.h"
-
-
-#define PARAM_SETTINGS_ITEM "settings-item"
-#define MAIN_CATALOG "maincatalog"
-
-SET_TAG("org.tizen.settings-tv-ref");
-
-Evas_Object *_add_win(const char *name)
-{
- Evas_Object *win;
-
- win = elm_win_add(NULL, name, ELM_WIN_BASIC);
- if (!win) {
- _ERR("failed to create window!");
- return NULL;
- }
-
- elm_win_title_set(win, name);
- elm_win_alpha_set(win, EINA_TRUE);
-
- elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
- elm_win_focus_highlight_style_set(win, DEFAULT_FOCUS_INVISIBLE);
-
- evas_object_show(win);
-
- return win;
-}
-
-class CApp : public CBaseApp {
- struct _appdata {
- Evas_Object *win;
- CSettingMgr *mgr;
- const char *name;
- char *item;
- unsigned int app_control;
- } ad;
-
-protected:
- virtual bool OnCreate(void) {
- Evas_Object *win;
- int r;
-
- elm_theme_overlay_add(NULL, EDJ_THEME);
-
- win = _add_win(ad.name);
- if (!win)
- return false;
-
- r = UG_INIT_EFL(win, UG_OPT_INDICATOR_ENABLE);
- if (r == -1) {
- _ERR("ug init efl failed.");
- evas_object_del(win);
- return false;
- }
-
- r = provider_init();
- if (r != 0) {
- _ERR("Fail to init provider module");
- evas_object_del(win);
- return false;
- }
-
- ad.win = win;
- ad.item = NULL;
- ad.app_control = 0;
-
- /* Set default vconf values */
-
- /* Proxy */
- if (vconf_set_int(VCONF_PROXY_METHOD, 0))
- _DBG("Fail to set vconf");
- if (vconf_set_str(VCONF_PROXY_IP, "0.0.0.0"))
- _DBG("Fail to set vconf");
- if (vconf_set_str(VCONF_PROXY_URL, ""))
- _DBG("Fail to set vconf");
-
- /* Network */
- if (vconf_set_str(WIRED_DNS_KEY, "0.0.0.0"))
- _DBG("Fail to set vconf");
- if (vconf_set_str(WIRED_GATEWAY_KEY, "0.0.0.0"))
- _DBG("Fail to set vconf");
- if (vconf_set_str(WIRED_IP_LAST_MODE, "Obtain automatically"))
- _DBG("Fail to set vconf");
- if (vconf_set_str(WIRED_DNS_LAST_MODE, "Obtain automatically"))
- _DBG("Fail to set vconf");
- if (vconf_set_str(WIRED_IP_KEY, "0.0.0.0"))
- _DBG("Fail to set vconf");
- if (vconf_set_str(WIRED_SUBMASK_KEY, "0.0.0.0"))
- _DBG("Fail to set vconf");
-
- if (vconf_set_str(WIRELESS_DNS_KEY, "0.0.0.0"))
- _DBG("Fail to set vconf");
- if (vconf_set_str(WIRELESS_GATEWAY_KEY, "0.0.0.0"))
- _DBG("Fail to set vconf");
- if (vconf_set_str(WIRELESS_IP_LAST_MODE, "Obtain automatically"))
- _DBG("Fail to set vconf");
- if (vconf_set_str(WIRELESS_DNS_LAST_MODE, "Obtain automatically"))
- _DBG("Fail to set vconf");
- if (vconf_set_str(WIRELESS_IP_KEY, "0.0.0.0"))
- _DBG("Fail to set vconf");
- if (vconf_set_str(WIRELESS_SUBMASK_KEY, "0.0.0.0"))
- _DBG("Fail to set vconf");
-
- /* Time */
- if (vconf_set_int(KEY_SYSTEM_CLOCK_MODE, 0))
- _DBG("Fail to set vconf");
- if (vconf_set_int(KEY_SLEEPTIMER, 0))
- _DBG("Fail to set vconf");
- if (vconf_set_int(KEY_SLEEPTIMER_TIMERID, 0))
- _DBG("Fail to set vconf");
- if (vconf_set_str(KEY_WAKEUP_TIMER_SETUP, "OFF"))
- _DBG("Fail to set vconf");
-
- if (vconf_set_int(VCONF_KEY_24HOUR_MODE, 0))
- _DBG("Fail to set vconf");
- if (vconf_set_str(KEY_CHANGE_PASSCODE, "0000"))
- _DBG("Fail to set vconf");
- if (vconf_set_int(KEY_SUBTITLE_LANGUAGE, 0))
- _DBG("Fail to set vconf");
-
- /* Broadcasting */
- if (vconf_set_bool(KEY_CHANNEL_LOCK, false))
- _DBG("Fail to set vconf");
-
- /* Lang and Region */
- if (vconf_set_str(KEY_SYSTEM_LANGUAGE, "en_US.UTF-8"))
- _DBG("Fail to set vconf");
- if (vconf_set_str(KEY_SYSTEM_COUNTRY, "en_US.UTF-8"))
- _DBG("Fail to set vconf");
-
- return true;
- }
-
- virtual void OnTerminate(void) {
- CSettingMgr::Finalize();
- ad.mgr = NULL;
-
- provider_fini();
-
- if (ad.win)
- evas_object_del(ad.win);
-
- if(ad.item)
- free(ad.item);
- }
-
- virtual void OnAppControl(app_control_h app_control) {
- _DBG(" ******************* OnAppControl *********************");
- CSettingMgr *mgr;
- int r;
- char *param;
- unsigned int relaunch, refresh;
-
- param = NULL;
-
- if (ad.app_control) {
- app_control_get_extra_data(app_control, PARAM_SETTINGS_ITEM, &param);
- if ((!param && !ad.item) ||
- (param && ad.item && !strcmp(ad.item, param))) {
- refresh = 1;
- relaunch = 0;
- } else {
- refresh = 0;
- relaunch = 1;
- }
-
- if (relaunch) {
- CSettingMgr::Finalize();
- } else {
- if (refresh) {
- if (!ad.mgr)
- return;
-
- ad.mgr->ViewRefresh();
- }
- }
- }
-
- if (!CSettingMgr::Initialize(ad.win))
- app_efl_exit();
- mgr = CSettingMgr::GetInstance();
-
- r = app_control_get_extra_data(app_control, PARAM_SETTINGS_ITEM, &param);
- if (r == APP_CONTROL_ERROR_NONE && param) {
- if (!mgr->LaunchItem(param)) {
- _ERR("the item is not exist.");
- app_efl_exit();
- }
- } else {
- mgr->ViewPush(MAIN_CATALOG, NULL);
- }
-
- ad.mgr = mgr;
- ad.app_control = 1;
-
- free(ad.item);
- ad.item = param;
- }
-
-public:
- virtual int Run(int argc, char **argv) {
- memset(&ad, 0x00, sizeof(_appdata));
- ad.name = PACKAGE;
-
- return CBaseApp::Run(argc, argv);
- }
-
- virtual ~CApp(void){}
-};
-
-int main(int argc, char **argv)
-{
- CApp app;
- app.Run(argc, argv);
-
- return 0;
-}
-
diff --git a/src/parser.cpp b/src/parser.c
index 22088ac..2ffb44b 100644
--- a/src/parser.cpp
+++ b/src/parser.c
@@ -14,10 +14,9 @@
* limitations under the License.
*/
-#include <cstring>
#include <Eina.h>
#include "parser.h"
-#include <MacroDefine.h>
+#include "dbg.h"
#include "stdlib.h"
struct json_parser {
@@ -103,7 +102,7 @@ struct json_parser *parser_init(const char *path)
return NULL;
}
- jparser = (struct json_parser *) calloc(1, sizeof(*jparser));
+ jparser = calloc(1, sizeof(*jparser));
if (!jparser)
return NULL;
@@ -256,22 +255,14 @@ char **parser_get_itemlist_from_json(struct json_parser *jparser,
cursor = 0;
- // For Debugging
- //_DBG("[START][ name = %s ][Parser = %x][Reader = %x]",name, jparser, jparser->reader);
- //_DBG("Member cnt = %d", json_reader_count_members(jparser->reader));
- //_DBG("Current Member = %s", json_reader_get_member_name(jparser->reader));
if (flag == DRAWING_INFO) {
- if (!json_reader_read_member(jparser->reader, JSONSTR_SETTING_ITEMS))
- {
- cursor++;
+ if (!json_reader_read_member(jparser->reader,
+ JSONSTR_SETTING_ITEMS))
goto error;
- }
} else if (flag == SUBMENU_INFO) {
- if (!json_reader_read_member(jparser->reader, JSONSTR_SETTING_TREE))
- {
- cursor++;
+ if (!json_reader_read_member(jparser->reader,
+ JSONSTR_SETTING_TREE))
goto error;
- }
} else {
goto error;
}
@@ -279,10 +270,7 @@ char **parser_get_itemlist_from_json(struct json_parser *jparser,
cursor++;
if (!json_reader_read_member(jparser->reader, name))
- {
- cursor++;
goto error;
- }
cursor++;
@@ -293,6 +281,7 @@ char **parser_get_itemlist_from_json(struct json_parser *jparser,
return list;
error:
+ cursor++;
_restore_json_reader_location(jparser, cursor);
*cnt = 0;
@@ -323,38 +312,22 @@ char **parser_get_settingui_args_from_json(struct json_parser *jparser,
cursor = 0;
if (!json_reader_read_member(jparser->reader, JSONSTR_SETTING_ITEMS))
- {
- cursor++;
- _DBG("[%s] Fail to read member from json", JSONSTR_SETTING_ITEMS);
goto error;
- }
cursor++;
if (!json_reader_read_member(jparser->reader, name))
- {
- cursor++;
- _DBG("[%s] Fail to read member from json", name);
goto error;
- }
cursor++;
if (!json_reader_read_member(jparser->reader, pnode))
- {
- cursor++;
- _DBG("[%s] Fail to read member from json", pnode);
goto error;
- }
cursor++;
if (!json_reader_read_member(jparser->reader, JSONSTR_SETTINGUI_ARGS))
- {
- cursor++;
- _DBG("[%s] Fail to read member from json", JSONSTR_SETTINGUI_ARGS);
goto error;
- }
cursor++;
@@ -365,6 +338,7 @@ char **parser_get_settingui_args_from_json(struct json_parser *jparser,
return list;
error:
+ cursor++;
_restore_json_reader_location(jparser, cursor);
*cnt = 0;
@@ -394,27 +368,18 @@ char **parser_get_data_list_from_json(struct json_parser *jparser,
cursor = 0;
if (!json_reader_read_member(jparser->reader, JSONSTR_SETTING_ITEMS))
- {
- cursor++;
- _DBG("[%s] Fail to read member from json", JSONSTR_SETTING_ITEMS);
goto error;
- }
+
cursor++;
if (!json_reader_read_member(jparser->reader, name))
- {
- cursor++;
- _DBG("[%s] Fail to read member from json", name);
goto error;
- }
+
cursor++;
if (!json_reader_read_member(jparser->reader, JSONSTR_DATA))
- {
- cursor++;
- _DBG("[%s] Fail to read member from json", JSONSTR_DATA);
goto error;
- }
+
cursor++;
*cnt = json_reader_count_members(jparser->reader);
@@ -424,6 +389,7 @@ char **parser_get_data_list_from_json(struct json_parser *jparser,
return list;
error:
+ cursor++;
_restore_json_reader_location(jparser, cursor);
*cnt = 0;
@@ -465,7 +431,7 @@ char *parser_get_string_value_from_json(struct json_parser *jparser,
return NULL;
}
- result = (char *) calloc(1, sizeof(char) * ARRAY_SIZE);
+ result = calloc(1, sizeof(char) * ARRAY_SIZE);
if (!result) {
g_free(output);
return NULL;
@@ -527,7 +493,7 @@ Eina_List *parser_get_string_list_from_json(struct json_parser *jparser,
list = NULL;
for (i = 0; i < cnt; i++) {
- result = (char *) calloc(1, sizeof(char) * ARRAY_SIZE);
+ result = calloc(1, sizeof(char) * ARRAY_SIZE);
if (!result) {
free(arr[0]);
free(arr);
@@ -570,11 +536,10 @@ int parser_get_array_length_from_json(struct json_parser *jparser,
for (i = 1; i < cnt; i++) {
if (!json_reader_read_member(jparser->reader, arr[i])) {
- while(i){
+ while(i) {
json_reader_end_member(jparser->reader);
i--;
}
-
free(arr[0]);
free(arr);
return 0;
diff --git a/src/settings_provider.cpp b/src/settings_provider.c
index 3ad54cd..8e9ad3c 100644
--- a/src/settings_provider.cpp
+++ b/src/settings_provider.c
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-#include <cstring>
-#include <MacroDefine.h>
+#include "dbg.h"
#include "settings_provider.h"
#include <vconf.h>
//#include "tvtimer.h"
@@ -42,8 +41,6 @@
#define KEY_SUBTITLE_LANGUAGE "db/menu/subtitle/subtitlelanguage"
#define KEY_SYSTEM_LANGUAGE "db/menu_widget/language"
#define KEY_SYSTEM_COUNTRY "db/menu_widget/regionformat"
-#define KEY_ACCESSIBILITY_SCREEN_READER "db/menu/accessibility/screen_reader"
-#define KEY_ACCESSIBILITY_MAGNIFIER "db/menu/accessibility/magnifier"
#define SYSTEM_LANGUAGE_DEFAULT_VALUE "en_US.utf8"
#define WAKEUP_TIMER_SETUP_DEFAULT_VALUE "OFF"
@@ -69,9 +66,7 @@ enum item_type {
SYSTEM_RESET,
SYSTEM_PASSCODE,
SYSTEM_CLOCK_MODE,
- CHANNEL_LOCK,
- SCREEN_READER,
- MAGNIFIER,
+ CHANNEL_LOCK
};
struct keymap {
@@ -81,88 +76,80 @@ struct keymap {
static struct keymap item_keymap[] = {
{
- "settings/picture/picturemode",
- PICTURE_MODE
+ .key = "settings/picture/picturemode",
+ .type = PICTURE_MODE
},
{
- "settings/picture/contrast",
- PICTURE_CONTRAST
+ .key = "settings/picture/contrast",
+ .type = PICTURE_CONTRAST
},
{
- "settings/picture/brightness",
- PICTURE_BRIGHTNESS
+ .key = "settings/picture/brightness",
+ .type = PICTURE_BRIGHTNESS
},
{
- "settings/picture/sharpness",
- PICTURE_SHARPNESS
+ .key = "settings/picture/sharpness",
+ .type = PICTURE_SHARPNESS
},
{
- "settings/picture/color",
- PICTURE_COLOR
+ .key = "settings/picture/color",
+ .type = PICTURE_COLOR
},
{
- "settings/picture/tint",
- PICTURE_TINT
+ .key = "settings/picture/tint",
+ .type = PICTURE_TINT
},
{
- "settings/picture/homebaropacity",
- PICTURE_HOMEBAR_OPACITY
+ .key = "settings/picture/homebaropacity",
+ .type = PICTURE_HOMEBAR_OPACITY
},
{
- "settings/picture/screenadjustment",
- PICTURE_SCREEN_ADJUSTMENT
+ .key = "settings/picture/screenadjustment",
+ .type = PICTURE_SCREEN_ADJUSTMENT
},
{
- "settings/sound/soundmode",
- SOUND_MODE
+ .key = "settings/sound/soundmode",
+ .type = SOUND_MODE
},
{
- "settings/sound/speakersettings",
- SPEAKER_SETTINGS
+ .key = "settings/sound/speakersettings",
+ .type = SPEAKER_SETTINGS
},
{
- "settings/system/sleeptimer",
- SYSTEM_SLEEPTIMER
+ .key = "settings/system/sleeptimer",
+ .type = SYSTEM_SLEEPTIMER
},
{
- "settings/system/wakeup_timer_setup",
- SYSTEM_WAKEUPTIMER
+ .key = "settings/system/wakeup_timer_setup",
+ .type = SYSTEM_WAKEUPTIMER
},
{
- "settings/system/subtitle",
- SYSTEM_SUBTITLE
+ .key = "settings/system/subtitle",
+ .type = SYSTEM_SUBTITLE
},
{
- "settings/system/country",
- SYSTEM_COUNTRY
+ .key = "settings/system/country",
+ .type = SYSTEM_COUNTRY
},
{
- "settings/system/language",
- SYSTEM_LANGUAGE
+ .key = "settings/system/language",
+ .type = SYSTEM_LANGUAGE
},
{
- "settings/system/reset",
- SYSTEM_RESET
+ .key = "settings/system/reset",
+ .type = SYSTEM_RESET
},
{
- "settings/system/change_passcode",
- SYSTEM_PASSCODE
+ .key = "settings/system/change_passcode",
+ .type = SYSTEM_PASSCODE
},
{
- "settings/system/clock_mode",
- SYSTEM_CLOCK_MODE
+ .key = "settings/system/clock_mode",
+ .type = SYSTEM_CLOCK_MODE
},
{
- "settings/channel/channel_lock",
- CHANNEL_LOCK
- },
- {
- "settings/accessibility/screen_reader",
- SCREEN_READER
- },
- {
- "settings/accessibility/magnifier",
- MAGNIFIER
+ .key = "settings/channel/channel_lock",
+ .type = CHANNEL_LOCK
}
};
@@ -180,7 +167,6 @@ struct sleeptimer_data {
//tvtimer_h timer;
};
-#if 0
static unsigned int sleeptimer_value[] = {
0,
30,
@@ -190,7 +176,6 @@ static unsigned int sleeptimer_value[] = {
150,
180
};
-#endif
/**
* An timer foreach iteration callback for tvtimer_foreach_item.
@@ -316,7 +301,6 @@ static enum item_type _find_type(const char *key)
return result;
}
-#if 0
/**
* Find array index according to given array value and size.
*
@@ -342,7 +326,6 @@ static int _find_index(unsigned int *array, int size, int val, int *index)
return -1;
}
-#endif
/**
* Set data with integer value.
@@ -417,7 +400,7 @@ static int _set_int(const char *key, int val)
static int _get_int(const char *key, int *val)
{
enum item_type type;
- int status;
+ int status, size, index;
if (!key || !val) {
_ERR("Invalid argument");
@@ -455,7 +438,6 @@ static int _get_int(const char *key, int *val)
break;
#if 0
- int size, idex;
size = _ARRAY_SIZE(speakersettings_item);
if (_find_index(speakersettings_item,
size, *val, &index) == -1) {
@@ -531,13 +513,13 @@ static int _set_string(const char *key, const char *val)
switch (type) {
case SYSTEM_LANGUAGE:
- status = vconf_set_str(KEY_SYSTEM_LANGUAGE, (char *) val);
+ status = vconf_set_str(KEY_SYSTEM_LANGUAGE, val);
break;
case SYSTEM_COUNTRY:
- status = vconf_set_str(KEY_SYSTEM_COUNTRY, (char *)val);
+ status = vconf_set_str(KEY_SYSTEM_COUNTRY, val);
break;
case SYSTEM_PASSCODE:
- status = vconf_set_str(KEY_CHANGE_PASSCODE, (char *)val);
+ status = vconf_set_str(KEY_CHANGE_PASSCODE, val);
break;
default:
break;
@@ -623,12 +605,6 @@ static int _set_bool(const char *key, const int val)
case CHANNEL_LOCK:
r = vconf_set_bool(KEY_CHANNEL_LOCK, val);
break;
- case SCREEN_READER:
- r = vconf_set_bool(KEY_ACCESSIBILITY_SCREEN_READER, val);
- break;
- case MAGNIFIER:
- r = vconf_set_bool(KEY_ACCESSIBILITY_MAGNIFIER, val);
- break;
default:
break;
}
@@ -658,12 +634,6 @@ static int _get_bool(const char *key, int *val)
case CHANNEL_LOCK:
r = vconf_get_bool(KEY_CHANNEL_LOCK, val);
break;
- case SCREEN_READER:
- r = vconf_get_bool(KEY_ACCESSIBILITY_SCREEN_READER, val);
- break;
- case MAGNIFIER:
- r = vconf_get_bool(KEY_ACCESSIBILITY_MAGNIFIER, val);
- break;
default:
break;
}
@@ -744,7 +714,7 @@ char *provider_get_list_value(struct settingitem *item)
return NULL;
}
- result = (char *) calloc(1, ARRAY_SIZE);
+ result = calloc(1, ARRAY_SIZE);
if (!result) {
_ERR("Fail to allocate memory");
return NULL;
@@ -857,7 +827,6 @@ char *provider_get_selected_display_name(struct settingitem *item)
const char *val, *disp;
Eina_List *list, *tmp;
struct listitem *litem;
- void* obj;
if (!item) {
_ERR("Invalid argument");
@@ -878,8 +847,7 @@ char *provider_get_selected_display_name(struct settingitem *item)
disp = NULL;
- EINA_LIST_FOREACH(list, tmp, obj) {
- litem = (struct listitem *) obj;
+ EINA_LIST_FOREACH(list, tmp, litem) {
val = listitem_get_value(litem);
if (val && !strncmp(sel, val, strlen(sel))) {
disp = listitem_get_display_name(litem);
@@ -888,7 +856,7 @@ char *provider_get_selected_display_name(struct settingitem *item)
}
if (!disp)
- disp = listitem_get_display_name((struct listitem *) eina_list_nth(list, 0));
+ disp = listitem_get_display_name(eina_list_nth(list, 0));
provider_release_list_value(sel);
diff --git a/src/timeout_handler.cpp b/src/timeout_handler.c
index 9a06a1e..66c4734 100644
--- a/src/timeout_handler.cpp
+++ b/src/timeout_handler.c
@@ -14,16 +14,16 @@
* limitations under the License.
*/
-#include <AppCommon.h>
+#include <app.h>
+#include <Elementary.h>
+#include "dbg.h"
#include "stdlib.h"
#include "stdbool.h"
#include "timeout_handler.h"
-
#define EVENT_HANDLER_NUM 6
-
-struct STimeoutHandler {
+struct timeout_handler {
Ecore_Event_Handler * event_handler[EVENT_HANDLER_NUM];
Ecore_Timer *timer;
};
@@ -45,14 +45,14 @@ struct STimeoutHandler {
*/
static Eina_Bool _event_occrued_cb(void *data, int type, void *event)
{
- struct STimeoutHandler *handler;
+ struct timeout_handler *handler;
if (!data) {
_ERR("Invalid argument");
return EINA_FALSE;
}
- handler = (struct STimeoutHandler *) data;
+ handler = data;
ecore_timer_reset(handler->timer);
@@ -79,104 +79,114 @@ static Eina_Bool _timer_expired_cb(void *data)
/**
* Freeze given ecore timer.
*
-* @param data [in] The STimeoutHandler data pointer, it include given ecore timer pointer.
+* @param data [in] The timeout_handler data pointer, it include given ecore timer pointer.
* @return void.
*/
-void CTimeoutHandler::FreezeTimer(void)
+void timeout_handler_freeze_timer(struct timeout_handler *data)
{
- ASSERT(m);
-
- if (!m->timer) {
+ if (!data || !data->timer) {
_ERR("Invalid argument");
return;
}
- ecore_timer_freeze(m->timer);
+ ecore_timer_freeze(data->timer);
}
/**
* Thaw given ecore timer.
*
-* @param data [in] The STimeoutHandler data pointer, it include given ecore timer pointer.
+* @param data [in] The timeout_handler data pointer, it include given ecore timer pointer.
* @return void.
*/
-void CTimeoutHandler::ThawTimer(void)
+void timeout_handler_thaw_timer(struct timeout_handler *data)
{
- ASSERT(m);
-
- if (!m->timer) {
+ if (!data || !data->timer) {
_ERR("Invalid argument");
return;
}
- ecore_timer_thaw(m->timer);
- ecore_timer_reset(m->timer);
+ ecore_timer_thaw(data->timer);
+ ecore_timer_reset(data->timer);
}
/**
* Change timer interval value.
*
-* @param data [in] The STimeoutHandler data pointer, it include given ecore timer pointer.
+* @param data [in] The timeout_handler data pointer, it include given ecore timer pointer.
* @param val [in] New interval value to be set.
* @return void.
*/
-void CTimeoutHandler::ChangeInterval(double val)
+void timeout_handler_change_interval(struct timeout_handler *data,
+ double val)
{
- ASSERT(m);
-
- if (!m->timer) {
+ if (!data || !data->timer) {
_ERR("Invalid argument");
return;
}
if (val == 0.0) {
- ecore_timer_freeze(m->timer);
+ ecore_timer_freeze(data->timer);
} else if (val > 0.0) {
- ecore_timer_interval_set(m->timer, val);
- ecore_timer_reset(m->timer);
- ecore_timer_thaw(m->timer);
+ ecore_timer_interval_set(data->timer, val);
+ ecore_timer_reset(data->timer);
+ ecore_timer_thaw(data->timer);
}
}
/**
-* Create and init STimeoutHandler data.
+* Create and init timeout_handler data.
*
* @param val [in] Timer interval value.
-* @return The STimeoutHandler data pointer, NULL if error.
+* @return The timeout_handler data pointer, NULL if error.
*/
-bool CTimeoutHandler::Create(double val)
+struct timeout_handler *timeout_handler_init(double val)
{
- ASSERT(!m);
+ struct timeout_handler *data;
- m = new STimeoutHandler;
- if (!m) {
+ data = calloc(1, sizeof(*data));
+ if (!data) {
_ERR("Fail to allocate memory for timeout handler");
- return false;
+ return NULL;
}
- m->event_handler[0] = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _event_occrued_cb, m);
- m->event_handler[1] = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _event_occrued_cb, m);
- m->event_handler[2] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN,_event_occrued_cb, m);
- m->event_handler[3] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, _event_occrued_cb, m);
- m->event_handler[4] = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, _event_occrued_cb, m);
- m->event_handler[5] = ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, _event_occrued_cb, m);
-
- m->timer = ecore_timer_add(val, _timer_expired_cb, NULL);
-
- return true;
+ data->event_handler[0] = ecore_event_handler_add(
+ ECORE_EVENT_KEY_DOWN, _event_occrued_cb, data);
+ data->event_handler[1] = ecore_event_handler_add(
+ ECORE_EVENT_KEY_UP, _event_occrued_cb, data);
+ data->event_handler[2] = ecore_event_handler_add(
+ ECORE_EVENT_MOUSE_BUTTON_DOWN,
+ _event_occrued_cb, data);
+ data->event_handler[3] = ecore_event_handler_add(
+ ECORE_EVENT_MOUSE_BUTTON_UP,
+ _event_occrued_cb, data);
+ data->event_handler[4] = ecore_event_handler_add(
+ ECORE_EVENT_MOUSE_MOVE, _event_occrued_cb, data);
+ data->event_handler[5] = ecore_event_handler_add(
+ ECORE_EVENT_MOUSE_WHEEL, _event_occrued_cb, data);
+
+ data->timer = ecore_timer_add(val, _timer_expired_cb, NULL);
+
+ return data;
}
-
-void CTimeoutHandler::Destroy(void)
+/**
+* Release given timeout_handler data.
+*
+* @param data [in] The timeout_handler data pointer.
+* @return void.
+*/
+void timeout_handler_fini(struct timeout_handler *data)
{
- ASSERT(m);
-
int i;
+ if (!data) {
+ _ERR("Invalid argument");
+ return;
+ }
+
for (i = 0; i < EVENT_HANDLER_NUM; i++)
- ecore_event_handler_del(m->event_handler[i]);
+ ecore_event_handler_del(data->event_handler[i]);
- ecore_timer_del(m->timer);
- delete m;
- m = NULL;
+ ecore_timer_del(data->timer);
+ free(data);
}
diff --git a/src/utils.cpp b/src/utils.c
index da5ab94..3184ddf 100644
--- a/src/utils.cpp
+++ b/src/utils.c
@@ -17,7 +17,7 @@
#include <Elementary.h>
#include <libintl.h>
#include <glib-object.h>
-#include <MacroDefine.h>
+#include "dbg.h"
#include "utils.h"
#include "data_wrapper.h"
@@ -36,8 +36,8 @@ static void _set_focus_down(Eina_Array *btns, int p, int n)
if (!btns)
return;
- cur = (Evas_Object *) eina_array_data_get(btns, p);
- next = (Evas_Object *) eina_array_data_get(btns, n);
+ cur = eina_array_data_get(btns, p);
+ next = eina_array_data_get(btns, n);
if (!cur || !next)
return;
@@ -61,8 +61,8 @@ static void _set_focus_up(Eina_Array *btns, int p, int n)
if (!btns)
return;
- cur = (Evas_Object *) eina_array_data_get(btns, p);
- next = (Evas_Object *) eina_array_data_get(btns, n);
+ cur = eina_array_data_get(btns, p);
+ next = eina_array_data_get(btns, n);
if (!cur || !next)
return;
@@ -126,7 +126,8 @@ char *utils_get_translation_str(const char *msgid)
* callback or not.
* @return The button's evas object, NULL on error.
*/
-Evas_Object *utils_add_btn(Evas_Object *base, const char *style, const char *text, Eina_Bool event)
+Evas_Object *utils_add_btn(Evas_Object *base,
+ char *style, const char *text, Eina_Bool event)
{
Evas_Object *btn;
@@ -139,8 +140,10 @@ Evas_Object *utils_add_btn(Evas_Object *base, const char *style, const char *tex
if (!btn)
return NULL;
- evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND,
+ EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(btn, EVAS_HINT_FILL,
+ EVAS_HINT_FILL);
if (style)
elm_object_style_set(btn, style);
@@ -149,8 +152,10 @@ Evas_Object *utils_add_btn(Evas_Object *base, const char *style, const char *tex
elm_object_text_set(btn, utils_get_translation_str(text));
if (event == EINA_TRUE) {
- evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, _btn_mouse_in_cb, NULL);
- evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_OUT, _btn_mouse_out_cb, NULL);
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN,
+ _btn_mouse_in_cb, NULL);
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_OUT,
+ _btn_mouse_out_cb, NULL);
}
evas_object_show(btn);
@@ -177,16 +182,17 @@ Evas_Object *utils_add_scroller(Evas_Object *base)
if (!scroller)
return NULL;
- 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);
+ 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);
-#if 0
elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_FALSE);
- elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
+ elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF,
+ ELM_SCROLLER_POLICY_OFF);
elm_object_focus_allow_set(scroller, EINA_FALSE);
evas_object_show(scroller);
-#endif
return scroller;
}
@@ -210,8 +216,10 @@ Evas_Object *utils_add_box(Evas_Object *base)
if (!box)
return NULL;
- evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_size_hint_weight_set(box,
+ EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(box,
+ EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_focus_allow_set(box, EINA_FALSE);
evas_object_show(box);
@@ -241,6 +249,9 @@ Evas_Object *utils_add_ctxpopup(Evas_Object *base, char *style)
return NULL;
}
+ if (style)
+ elm_object_style_set(ctxpopup, style);
+
return ctxpopup;
}
@@ -349,7 +360,7 @@ void utils_set_focus_directions(Eina_Array *btns, int cnt)
return;
if (cnt == 1) {
- btn = (Evas_Object *) eina_array_data_get(btns, 0);
+ btn = eina_array_data_get(btns, 0);
if (!btn)
return;
diff --git a/src/view_bottomslider.c b/src/view_bottomslider.c
new file mode 100644
index 0000000..4c75d0b
--- /dev/null
+++ b/src/view_bottomslider.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "dbg.h"
+#include "def.h"
+#include "stdbool.h"
+#include "viewmgr.h"
+#include "utils.h"
+#include "data_wrapper.h"
+#include "settings_provider.h"
+#include "view_bottomslider.h"
+
+/**
+* This function is invoked to create view layout.
+*
+* @param mgr [in] The setting_mgr data pointer passed by @settingmgr_view_push.
+* @param view [in] The settingview_data data pointer passed by @settingmgr_view_push.
+* @param prev [in] The parameter data which passed by prev view or NULL.
+* @return View layout evas object, NULL on error.
+*/
+static Evas_Object *_create(struct setting_mgr *mgr,
+ struct settingview_data *view, void *prev)
+{
+ /*TODO:Implement this function*/
+ return NULL;
+}
+
+/**
+* This function is invoked to show view layout.
+*
+* @param base [in] The view layout evas object.
+* @return void.
+*/
+static void _show(Evas_Object *base)
+{
+}
+
+/**
+* This function is invoked to destroy view layout.
+*
+* @param base [in] The view layout evas object.
+* @return void.
+*/
+static void _destroy(Evas_Object *base)
+{
+}
+
+/**
+* This function is invoked to hide view layout.
+*
+* @param base [in] The view layout evas object.
+* @return void.
+*/
+static void _hide(Evas_Object *base)
+{
+}
+
+static struct setting_class _vclass = {
+ .title = VCLASS_TITLE_BOTTOM_SLIDER,
+ .create = _create,
+ .show = _show,
+ .destroy = _destroy,
+ .hide = _hide,
+ .hide_view = 1
+};
+
+/**
+* This function is invoked to get bottom slider view class object.
+*
+* @return The setting_class data static pointer, NULL on error.
+*/
+struct setting_class *view_bottomslider_get_vclass(void)
+{
+ return &_vclass;
+}
diff --git a/src/view_bottomsublist.c b/src/view_bottomsublist.c
new file mode 100644
index 0000000..6c64141
--- /dev/null
+++ b/src/view_bottomsublist.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "dbg.h"
+#include "def.h"
+#include "stdbool.h"
+#include "viewmgr.h"
+#include "utils.h"
+#include "data_wrapper.h"
+#include "settings_provider.h"
+#include "view_bottomsublist.h"
+
+/**
+* This function is invoked to create view layout.
+*
+* @param mgr [in] The setting_mgr data pointer passed by @settingmgr_view_push.
+* @param view [in] The settingview_data data pointer passed by @settingmgr_view_push.
+* @param prev [in] The parameter data which passed by prev view or NULL.
+* @return View layout evas object, NULL on error.
+*/
+static Evas_Object *_create(struct setting_mgr *mgr,
+ struct settingview_data *view, void *prev)
+{
+ /*TODO:Implement this function*/
+ return NULL;
+}
+
+/**
+* This function is invoked to show view layout.
+*
+* @param base [in] The view layout evas object.
+* @return void.
+*/
+static void _show(Evas_Object *base)
+{
+}
+
+/**
+* This function is invoked to destroy view layout.
+*
+* @param base [in] The view layout evas object.
+* @return void.
+*/
+static void _destroy(Evas_Object *base)
+{
+}
+
+/**
+* This function is invoked to destroy view layout.
+*
+* @param base [in] The view layout evas object.
+* @return void.
+*/
+static void _hide(Evas_Object *base)
+{
+}
+
+static struct setting_class _vclass = {
+ .title = VCLASS_TITLE_BOTTOM_SUBLIST,
+ .create = _create,
+ .show = _show,
+ .destroy = _destroy,
+ .hide = _hide,
+ .hide_view = 1
+};
+
+/**
+* This function is invoked to get bottom sublist view class object.
+*
+* @return The setting_class data static pointer, NULL on error.
+*/
+struct setting_class *view_bottomsublist_get_vclass(void)
+{
+ return &_vclass;
+}
diff --git a/src/view_device_manager.c b/src/view_device_manager.c
new file mode 100644
index 0000000..c5543e8
--- /dev/null
+++ b/src/view_device_manager.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "dbg.h"
+#include "def.h"
+#include "stdbool.h"
+#include "viewmgr.h"
+#include "utils.h"
+#include "data_wrapper.h"
+#include "settings_provider.h"
+#include "view_maincatalog.h"
+#include "view_device_manager.h"
+
+static Evas_Object *_create(struct setting_mgr *mgr,
+ struct settingview_data *view, void *prev)
+{
+ /*TODO:Implement this function*/
+ return NULL;
+}
+
+static void _show(Evas_Object *base)
+{
+}
+
+static void _destroy(Evas_Object *base)
+{
+}
+
+static void _hide(Evas_Object *base)
+{
+}
+
+static struct setting_class _vclass = {
+ .title = VCLASS_TITLE_DEVICE_MANAGER,
+ .create = _create,
+ .show = _show,
+ .destroy = _destroy,
+ .hide = _hide,
+ .hide_view = 0
+};
+
+struct setting_class *view_device_manager_get_vclass(void)
+{
+ return &_vclass;
+}
diff --git a/src/view_maincatalog.c b/src/view_maincatalog.c
new file mode 100644
index 0000000..b2cfe58
--- /dev/null
+++ b/src/view_maincatalog.c
@@ -0,0 +1,2111 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <app.h>
+
+#include <KeyDefine.h>
+
+#include "dbg.h"
+#include "def.h"
+#include "stdbool.h"
+#include "viewmgr.h"
+#include "utils.h"
+#include "view_maincatalog.h"
+#include "data_wrapper.h"
+#include "settings_provider.h"
+
+#define DATA_ID "main_setting_data"
+#define SUBITEM_DATA_ID "subitem_data_id"
+#define SYSTEM_CLOCK_DATA "system_clock_data"
+#define ICON_PART "iconpart"
+#define PROGRESS_BAR_DATA "progressbar"
+
+#define SETTING_ID "setting_id"
+#define E_CREATE_ITEMS 0
+
+#define MAX_PROGRESS_VALUE 100.0
+#define MIN_PROGRESS_VALUE 0.0
+#define ICON_BUTTON_NO_DISP_NAME "No Display Name"
+#define CHANGE_PASSCODE_NAME "change-passcode"
+#define PASSCODE_MASK "****"
+#define DISABLED "disabled"
+#define ENABLED "enabled"
+#define SIG_CLICKED "clicked"
+
+enum focused_state {
+ FOCUS_MAIN_ITEM = 1,
+ FOCUS_SUB_ITEM
+};
+
+struct _view_data {
+ Evas_Object *win;
+ Evas_Object *base;
+ Eina_Array *sub_item_btn;
+ Eina_Array *main_item_btn;
+ Eina_Array *main_icon_base;
+ Eina_Array *item_path;
+ Evas_Object *focused_sub_item_btn;
+ Evas_Object *focused_main_item_btn;
+ Evas_Object *subitem_box;
+ Evas_Object *mainitem_box;
+
+ int focus_status;
+ int main_item_count;
+ int sub_item_count;
+
+ struct setting_mgr *mgr;
+ struct settingview_data *main_setting_view;
+ struct settingview_data *subsetting_view;
+};
+
+/**
+* This function will be invoked when focus moves from subitem to main item.
+*
+* @param[in]: data : the user data.
+* @param[in]: btn : subitem which focus is on.
+*
+* @return: void.
+*/
+static void _move_from_subitem_to_main_item(struct _view_data *data,
+ Evas_Object *btn)
+{
+ if (!data || !btn)
+ return;
+
+ data->focus_status = FOCUS_MAIN_ITEM;
+ data->focused_sub_item_btn = btn;
+
+ elm_object_focus_set(data->focused_main_item_btn, EINA_TRUE);
+}
+
+/**
+* Evas_Object_Event_Cb type callback for handling key press event.
+*
+* @param[in]: data : the user data.
+* @param[in]: e : the evas canvas.
+* @param[in]: obj : the corresponding object which the key press event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _subitem_key_pressed_cb(void *data, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _view_data *priv;
+ Evas_Object *pb;
+ Evas_Object *next;
+
+ if (!data || !ei || !obj)
+ return;
+
+ ev = ei;
+ if (!ev->keyname)
+ return;
+
+ priv = data;
+
+ if (!strcmp(ev->keyname, KEY_LEFT) ||
+ !strcmp(ev->keyname, KEY_BACK)) {
+ pb = evas_object_data_get(obj, PROGRESS_BAR_DATA);
+ if (pb)
+ elm_object_signal_emit(pb,
+ SIG_UNCTRL_PB_UNFOCUSED, SRC_PB_PROG);
+
+ _move_from_subitem_to_main_item(priv, obj);
+ } else if (!strncmp(ev->keyname, KEY_DOWN, strlen(ev->keyname))) {
+ pb = evas_object_data_get(obj, PROGRESS_BAR_DATA);
+ if (pb)
+ elm_object_signal_emit(pb,
+ SIG_UNCTRL_PB_UNFOCUSED, SRC_PB_PROG);
+
+ next = elm_object_focus_next_object_get(obj,
+ ELM_FOCUS_DOWN);
+ if (!next) {
+ _ERR("focus next object get failed.");
+ return;
+ }
+
+ pb = evas_object_data_get(next, PROGRESS_BAR_DATA);
+ if (pb)
+ elm_object_signal_emit(pb,
+ SIG_UNCTRL_PB_FOCUSED, SRC_PB_PROG);
+ } else if (!strncmp(ev->keyname, KEY_UP, strlen(ev->keyname))) {
+ pb = evas_object_data_get(obj, PROGRESS_BAR_DATA);
+ if (pb)
+ elm_object_signal_emit(pb,
+ SIG_UNCTRL_PB_UNFOCUSED, SRC_PB_PROG);
+
+ next = elm_object_focus_next_object_get(obj, ELM_FOCUS_UP);
+ if (!next) {
+ _ERR("focus next object get failed.");
+ return;
+ }
+
+ pb = evas_object_data_get(next, PROGRESS_BAR_DATA);
+ if (pb)
+ elm_object_signal_emit(pb,
+ SIG_UNCTRL_PB_FOCUSED, SRC_PB_PROG);
+ } else if (!strncmp(ev->keyname, KEY_EXIT, strlen(ev->keyname))) {
+ app_efl_exit();
+ }
+}
+
+/**
+* Get geometry data of object such as width, height.
+*
+* @param[in]: obj : the object which you want to get geometry data from.
+* @param[out]: param : the geometry data.
+*
+* @return: void.
+*/
+static void _get_geometry_data(Evas_Object *obj,
+ struct obj_geometry_data *param)
+{
+ int x, y, w, h;
+
+ if (!param || !obj) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ x = y = w = h = 0;
+
+ evas_object_geometry_get(obj, &x, &y, &w, &h);
+
+ param->x = x;
+ param->y = y;
+ param->width = w;
+ param->height = h;
+}
+
+/**
+* Entry of showing UI gadget views.
+*
+* param[in]: data : the user data.
+* param[in]: item : item data.
+* param[in]: obj : object whose next view is UI gadget.
+*
+* @return: 0 - success, -1 - fail.
+*/
+static int _push_ug_view(struct _view_data *data,
+ struct settingitem *item, Evas_Object *obj)
+{
+ const char *id;
+ struct evas_obj_data param;
+ int r;
+
+ if (!data || !item || !obj) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ id = settingitem_get_id(item);
+ if (!id) {
+ _ERR("Fail to get item id");
+ return -1;
+ }
+
+ param.subitem_box = data->subitem_box;
+ param.display_name = settingitem_get_display_name(item);
+ param.cur_btn = obj;
+
+ r = settingmgr_view_push(data->mgr, id, (void *)&param);
+ if (r != 0) {
+ _ERR("Fail to push view");
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+* Entry of showing sublist views.
+*
+* param[in]: data : the user data.
+* param[in]: item : item data.
+* param[in]: obj : object whose next view is sublist.
+*
+* @return: 0 - success, -1 - fail.
+*/
+static int _push_sublist_view(struct _view_data *data,
+ struct settingitem *item, Evas_Object *obj)
+{
+ const char *id;
+ int r;
+ struct obj_geometry_data ogd;
+
+ if (!data || !item || !obj) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ id = settingitem_get_id(item);
+ if (!id) {
+ _ERR("Fail to get item id");
+ return -1;
+ }
+
+ _get_geometry_data(obj, &ogd);
+
+ r = settingmgr_view_push(data->mgr, id, (void *)&ogd);
+ if (r != 0) {
+ _ERR("Fail to push view");
+ return -1;
+ }
+
+ elm_object_signal_emit(obj, SUBITEMBTN_BUTTON_CLICKED,
+ SUBITEMBTN_BUTTON_SOURCE);
+
+ return 0;
+}
+
+/**
+* Entry of showing bottom sublist views.
+*
+* param[in]: data : the user data.
+* param[in]: item : item data.
+*
+* @return: 0 - success, -1 - fail.
+*/
+static int _push_bottom_sublist_view(struct _view_data *data,
+ struct settingitem *item)
+{
+ const char *id;
+ int r;
+
+ if (!data || !item) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ id = settingitem_get_id(item);
+ if (!id) {
+ _ERR("Fail to get item id");
+ return -1;
+ }
+
+ r = settingmgr_view_push(data->mgr, id, NULL);
+ if (r != 0) {
+ _ERR("Fail to push view");
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+* Entry of showing bottom slider views.
+*
+* param[in]: data : the user data.
+* param[in]: item : item data.
+* param[in]: obj : object whose next view bottom slider.
+*
+* @return: 0 - success, -1 - fail.
+*/
+static int _push_bottom_slider_view(struct _view_data *data,
+ struct settingitem *item, Evas_Object *obj)
+{
+ const char *id;
+ int r;
+ Eina_List *list;
+ Evas_Object *pb;
+
+ if (!data || !item || !obj) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ id = settingitem_get_id(item);
+ if (!id) {
+ _ERR("Fail to get item id");
+ return -1;
+ }
+
+ pb = evas_object_data_get(obj, PROGRESS_BAR_DATA);
+ if (pb)
+ elm_object_signal_emit(pb,
+ SIG_UNCTRL_PB_UNFOCUSED, SRC_PB_PROG);
+
+ list = settingitem_get_slider_group_list(
+ viewdata_get_parentitem(data->subsetting_view),
+ settingmgr_get_data(data->mgr), id);
+
+ r = settingmgr_view_push(data->mgr, id, list);
+ if (r != 0) {
+ _ERR("Fail to push view");
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+* Entry of showing passcode popup views.
+*
+* param[in]: data : the user data.
+* param[in]: item : item data.
+*
+* @return: 0 - success, -1 - fail.
+*/
+static int _push_passcode_popup_view(struct _view_data *data,
+ struct settingitem *item)
+{
+ const char *id;
+ int r;
+
+ if (!data || !item) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ id = settingitem_get_id(item);
+ if (!id) {
+ _ERR("Fail to get item id");
+ return -1;
+ }
+
+ r = settingmgr_view_push(data->mgr, id, NULL);
+ if (r != 0) {
+ _ERR("Fail to push view");
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+* Entry of showing device manager view.
+*
+* param[in]: data : the user data.
+* param[in]: item : item data read from json file.
+*
+* @return: 0 - success, -1 - fail.
+*/
+static int _push_device_manager_view(struct _view_data *data,
+ struct settingitem *item)
+{
+ const char *id;
+ struct evas_obj_data param;
+ int r;
+
+ if (!data || !item) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ id = settingitem_get_id(item);
+ if (!id) {
+ _ERR("Fail to get item id");
+ return -1;
+ }
+
+ param.display_name = settingitem_get_display_name(item);
+ param.subitem_box = data->subitem_box;
+
+ r = settingmgr_view_push(data->mgr, id, &param);
+ if (r != 0) {
+ _ERR("Fail to push view");
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+* Entry of showing reset popup view.
+*
+* param[in]: data : the user data.
+* param[in]: item : item data read from json file.
+*
+* @return: 0 - success, -1 - fail.
+*/
+static int _push_reset_popup_view(struct _view_data *data,
+ struct settingitem *item)
+{
+ const char *id;
+ int r;
+
+ if (!data || !item) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ id = settingitem_get_id(item);
+ if (!id) {
+ _ERR("Fail to get item id");
+ return -1;
+ }
+
+ r = settingmgr_view_push(data->mgr, id, NULL);
+ if (r != 0) {
+ _ERR("Fail to push view");
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+* Entry of showing software upgrade popup view.
+*
+* param[in]: data : the user data.
+* param[in]: item : item data read from json file.
+*
+* @return: 0 - success, -1 - fail.
+*/
+static int _push_upgrade_popup_view(struct _view_data *data,
+ struct settingitem *item)
+{
+ const char *id;
+ int r;
+
+ if (!data || !item) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ id = settingitem_get_id(item);
+ if (!id) {
+ _ERR("Fail to get item id");
+ return -1;
+ }
+
+ r = settingmgr_view_push(data->mgr, id, NULL);
+ if (r != 0) {
+ _ERR("Fail to push view");
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+* Entry of showing clock sublist view.
+*
+* param[in]: data : the user data.
+* param[in]: item : item data read from json file.
+* param[in]: obj : object whose next view is clock sublist view.
+*
+* @return: 0 - success, -1 - fail.
+*/
+static int _push_clock_sublist_view(struct _view_data *data,
+ struct settingitem *item, Evas_Object *obj)
+{
+ const char *id;
+ struct evas_obj_data param;
+ struct obj_geometry_data ogd;
+ int r;
+
+ if (!data || !item || !obj) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ id = settingitem_get_id(item);
+ if (!id) {
+ _ERR("Fail to get item id");
+ return -1;
+ }
+
+ _get_geometry_data(obj, &ogd);
+
+ param.display_name = settingitem_get_display_name(item);
+ param.subitem_box = data->subitem_box;
+ param.cur_btn = obj;
+
+ evas_object_data_set(obj, SYSTEM_CLOCK_DATA, (void *)&ogd);
+
+ r = settingmgr_view_push(data->mgr, id, &param);
+ if (r != 0) {
+ _ERR("Fail to push view");
+ return -1;
+ }
+
+ elm_object_signal_emit(obj,
+ SUBITEMBTN_BUTTON_CLICKED, SUBITEMBTN_BUTTON_SOURCE);
+
+ return 0;
+}
+/**
+* Entry of showing channel lock view.
+*
+* param[in]: data : the user data.
+* param[in]: item : item data read from json file.
+* param[in]: obj : the channel lock object.
+*
+* @return: 0 - success, -1 - fail.
+*/
+static int _push_need_passcode_view(struct _view_data *data,
+ struct settingitem *item, Evas_Object *obj)
+{
+ const char *id;
+ int r;
+ struct obj_geometry_data ogd;
+
+ if (!data || !item || !obj) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ id = settingitem_get_id(item);
+ if (!id) {
+ _ERR("Fail to get item id");
+ return -1;
+ }
+
+ _get_geometry_data(obj, &ogd);
+
+ r = settingmgr_view_push(data->mgr, id, &ogd);
+ if (r != 0) {
+ _ERR("Fail to push view");
+ return -1;
+ }
+
+ elm_object_signal_emit(obj, SUBITEMBTN_BUTTON_CLICKED,
+ SUBITEMBTN_BUTTON_SOURCE);
+
+ return 0;
+}
+
+/**
+* This function will be invoked when subitem is clicked.
+*
+* @param[in]: data : the user data.
+* @param[in]: obj : the subitem object.
+*
+* @return: void.
+*/
+static void _submenu_item_clicked(void *data, Evas_Object *obj)
+{
+ struct _view_data *priv;
+ const char *style;
+ struct settingitem *item;
+
+ if (!data || !obj) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = data;
+
+ if (priv->focus_status != FOCUS_SUB_ITEM)
+ return;
+
+ item = evas_object_data_get(obj, SUBITEM_DATA_ID);
+ if (!item) {
+ _ERR("Get sub item failed");
+ return;
+ }
+
+ style = settingitem_get_settingui_style(item);
+ if (!style) {
+ _ERR("setting-ui style is null.");
+ return;
+ }
+
+ if (!strncmp(style, STYLE_UIGADGET, strlen(style))) {
+ if (_push_ug_view(priv, item, obj) != 0)
+ _ERR("Fail to push ug");
+ } else if (!strncmp(style, STYLE_CTXPOPUP,
+ strlen(style))) {
+ if (_push_sublist_view(priv, item, obj) != 0)
+ _ERR("Fail to push sublist");
+ } else if (!strncmp(style, STYLE_BOTTOM_CTXPOPUP,
+ strlen(style))) {
+ if (_push_bottom_sublist_view(priv, item) != 0)
+ _ERR("Fail to push bottom sublist");
+ } else if (!strncmp(style, STYLE_BOTTOMSLIDER,
+ strlen(style)) || !strncmp(style,
+ STYLE_BOTTOM2WAYSLIDER,
+ strlen(style))) {
+ if (_push_bottom_slider_view(priv,
+ item, obj) != 0)
+ _ERR("Fail to push bottom slider");
+ } else if (!strncmp(style, STYLE_PASSCODE_POPUP,
+ strlen(style))) {
+ if (_push_passcode_popup_view(priv, item) != 0)
+ _ERR("Fail to push passcode popup");
+ } else if (!strncmp(style, STYLE_DEVICE_MANAGER,
+ strlen(style))) {
+ if (_push_device_manager_view(priv, item) != 0)
+ _ERR("Fail to push device mgr view");
+ } else if (!strncmp(style, STYLE_RESET_POPUP,
+ strlen(style))) {
+ if (_push_reset_popup_view(priv, item) != 0)
+ _ERR("Fail to push reset popup");
+ } else if (!strncmp(style, STYLE_UPGRADE_POPUP,
+ strlen(style))) {
+ if (_push_upgrade_popup_view(priv, item) != 0)
+ _ERR("Fail to push upgrade popup");
+ } else if (!strncmp(style, STYLE_CLOCK_CTXPOPUP,
+ strlen(style))) {
+ if (_push_clock_sublist_view(
+ priv, item, obj) != 0)
+ _ERR("Fail to push clock sublist");
+ } else if (!strncmp(style, STYLE_NEED_PASSCODE,
+ strlen(style))) {
+ if (_push_need_passcode_view(
+ priv, item, obj) != 0)
+ _ERR("Fail to push need passcode view");
+ }
+
+ priv->focused_sub_item_btn = obj;
+}
+
+/**
+* Evas_Smart_Cb type callback for handling click event.
+*
+* @param[in]: data : the user data.
+* @param[in]: obj : the corresponding object which the click event occurred.
+* @param[in]: ev : event info.
+*
+* @return: void.
+*/
+static void _subitem_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *ev)
+{
+ struct _view_data *priv;
+ Evas_Object *icon;
+
+ if (!data || !obj) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = data;
+
+ _submenu_item_clicked(priv, obj);
+
+ elm_object_signal_emit(priv->focused_main_item_btn,
+ MAINICONBTN_FOCUSED_ON_SUBITEM,
+ MAINICONBTN_MAIN_ITEM_SOURCE);
+
+ icon = elm_object_part_content_get(priv->focused_main_item_btn,
+ MAINICONBTN_ICON_SWALLOW);
+ if (icon)
+ elm_object_signal_emit(icon, MAIN_BTN_HIGHLIGHT, MAIN_BTN);
+}
+
+/**
+* Get item value from item.
+*
+* @param[in]: item : the item data read from json file.
+*
+* @return: the value of item or null if error occurred.
+*/
+static char *_settingitems_get_value(struct settingitem *item)
+{
+ char *result;
+ const char *name, *style;
+
+ if (!item) {
+ _ERR("Invalid argument");
+ return NULL;
+ }
+
+ result = NULL;
+
+ name = settingitem_get_id(item);
+ if (name && !strncmp(name, CHANGE_PASSCODE_NAME, strlen(name))) {
+ result = strdup(PASSCODE_MASK);
+ return result;
+ }
+
+ style = settingitem_get_settingui_style(item);
+ if (!style) {
+ _ERR("Fail to get setting ui style");
+ return NULL;
+ }
+
+ if (!strncmp(style, STYLE_UIGADGET, strlen(style)))
+ return provider_get_list_value(item);
+ else
+ return provider_get_selected_display_name(item);
+}
+
+/**
+* Get percentage value of progress from item data.
+*
+* @param[in]: item : item data read from json file.
+*
+* @return: the percentage value or -1.0 if error occurred.
+*/
+static double _get_progress_percentage(struct settingitem *item)
+{
+ struct slideritem *sitem;
+ double val, persent;
+
+ if (!item) {
+ _ERR("Invalid argument");
+ return -1.0;
+ }
+
+ sitem = settingitem_get_data_slideritem(item);
+ if (!sitem) {
+ _ERR("Get slider item failed");
+ return -1.0;
+ }
+
+ val = provider_get_slider_value(item);
+ persent = slideritem_find_slider_value(val, sitem);
+
+ return persent;
+}
+
+/**
+* Get displaying value of item.
+*
+* @param[in]: item : item data read from json file.
+* @param[in]: value : the percentage value.
+*
+* @return: the display value.
+*/
+static double _get_display_value(struct settingitem *item, double value)
+{
+ struct slideritem *sitem;
+ double disp;
+
+ if (!item) {
+ _ERR("Invalid argument");
+ return -1.0;
+ }
+
+ sitem = settingitem_get_data_slideritem(item);
+ if (!sitem) {
+ _ERR("Get slider item failed");
+ return -1.0;
+ }
+
+ disp = slideritem_find_slider_display_value(value, sitem);
+
+ return disp;
+}
+
+/**
+* Create slider of subitem.
+*
+* @param[in]: item : the item data read from json file.
+* @param[in]: base : the base layout of subitems.
+* @param[in]: btn : the subitem the slider will be created on.
+*
+* @return: void.
+*/
+static void _set_subitem_btn_slider(struct settingitem *item,
+ Evas_Object *base, Evas_Object *btn)
+{
+ Evas_Object *pb;
+ double val, percent;
+ char buf[BUF_SIZE];
+
+ if (!item || !base || !btn) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ elm_object_style_set(btn, SUBITEMBTN_TITLE_SLIDER_VALUE);
+
+ pb = elm_progressbar_add(base);
+ if (!pb) {
+ _ERR("Add progress bar failed.");
+ return;
+ }
+
+ elm_object_style_set(pb, SUBITEMBTN_TITILE_SLIDER);
+
+ percent = _get_progress_percentage(item);
+ val = _get_display_value(item, percent);
+ elm_progressbar_value_set(pb, percent);
+
+ snprintf(buf, sizeof(buf), "%d", (int)val);
+ elm_object_part_text_set(btn, SUBITEMBTN_VALUE, buf);
+ elm_object_part_content_set(btn, SUBITEMBTN_SLIDER_SWALLOW, pb);
+
+ evas_object_data_set(btn, PROGRESS_BAR_DATA, pb);
+}
+
+/**
+* Get tint g-value.
+*
+* @param[in]: item : the item data read from json file.
+* @param[in]: tint_r : the tint r-value.
+*
+* @return: the tint g-value.
+*/
+static double _get_disp_tint_g_val(struct settingitem *item, double tint_r)
+{
+ const char *strval;
+ struct slideritem *sitem;
+ double val;
+
+ if (!item) {
+ _ERR("Invalid argument");
+ return -1.0;
+ }
+
+ sitem = settingitem_get_data_slideritem(item);
+ if (!sitem) {
+ _ERR("Get slider item failed");
+ return -1.0;
+ }
+
+ strval = slideritem_get_max_display_value(sitem);
+ if (strval)
+ val = atof(strval);
+ else
+ val = 100;
+
+ return val - tint_r;
+}
+
+/**
+* Create two way slider.
+*
+* @param[in]: item : the item data read from json file.
+* @param[in]: base : the base layout of subitems.
+* @param[in]: btn : the subitem which the two way slider will be created on.
+*
+* @return: void.
+*/
+static void _set_subitem_btn_value_slider(struct settingitem *item,
+ Evas_Object *base, Evas_Object *btn)
+{
+ Evas_Object *pb;
+ double tint_r, tint_g, percent;
+ char buf[BUF_SIZE];
+
+ if (!item || !base || !btn) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ elm_object_style_set(btn, SUBITEMBTN_TITLE_SLIDER_VALUE);
+
+ pb = elm_progressbar_add(base);
+ if (!pb) {
+ _ERR("Add progress bar failed.");
+ return;
+ }
+
+ elm_object_style_set(pb, SUBITEMBTN_TITILE_SLIDER);
+ percent = _get_progress_percentage(item);
+ elm_progressbar_value_set(pb, percent);
+
+ tint_r = _get_display_value(item, percent);
+ tint_g = _get_disp_tint_g_val(item, tint_r);
+
+ snprintf(buf, sizeof(buf), "R%d", (int)tint_r);
+ elm_object_part_text_set(btn, SUBITEMBTN_VALUE,
+ utils_get_translation_str(buf));
+ snprintf(buf, sizeof(buf), "G%d", (int)tint_g);
+ elm_object_part_text_set(btn, SUBITEMBTN_G_VALUE,
+ utils_get_translation_str(buf));
+
+ elm_object_part_content_set(btn, SUBITEMBTN_SLIDER_SWALLOW, pb);
+
+ evas_object_data_set(btn, PROGRESS_BAR_DATA, pb);
+}
+
+/**
+* Create style for subitem.
+*
+* @param[in]: base : the base layout of subitems.
+* @param[in]: obj : the subitem which the style will be created on.
+* @param[in]: style : the style read from json file.
+* @param[in]: item : the item data read from json file.
+*
+* @return: void.
+*/
+static void _draw_subitem_with_style(Evas_Object *base, Evas_Object *obj,
+ const char *style, struct settingitem *item)
+{
+ char *val;
+
+ if (!style || !base || !obj || !item)
+ return;
+
+ if (!strncmp(style, STYLE_SUBBUTTON_TITLE_VALUE, strlen(style))) {
+ val = _settingitems_get_value(item);
+ elm_object_part_text_set(obj, SUBITEMBTN_VALUE,
+ utils_get_translation_str(val));
+ free(val);
+ } else if (!strncmp(style, STYLE_SUBBUTTON_TITLE_ICON, strlen(style))) {
+ elm_object_style_set(obj, SUBITEMBTN_TITLE_ICON);
+ } else if (!strncmp(style, STYLE_SUBBUTTON_TITLE_SLIDER_VALUE,
+ strlen(style))) {
+ _set_subitem_btn_slider(item, base, obj);
+ } else if (!strncmp(style, STYLE_SUBBUTTON_TITLE_2WAYSLIDER_VALUE,
+ strlen(style))) {
+ _set_subitem_btn_value_slider(item, base, obj);
+ }
+}
+
+/**
+* Release resources of subitems.
+*
+* @param[in]: data : the user data.
+*
+* @return: void.
+*/
+static void _release_subitems(struct _view_data *data)
+{
+ Evas_Object *btn;
+ Eina_Array_Iterator a;
+ unsigned int i;
+
+ if (!data) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ if (data->sub_item_btn) {
+ EINA_ARRAY_ITER_NEXT(data->sub_item_btn, i, btn, a)
+ evas_object_del(btn);
+ eina_array_free(data->sub_item_btn);
+ }
+
+ if (data->subsetting_view)
+ viewdata_release(data->subsetting_view);
+
+ if (data->subitem_box)
+ evas_object_del(data->subitem_box);
+}
+
+/**
+* Refresh subitems when subitems are changed.
+*
+* @param[in]: data : the user data.
+*
+* @return: 0 - success, -1 - fail.
+*/
+static int _refresh_subitems(struct _view_data *data)
+{
+ Evas_Object *btn;
+ Eina_Array_Iterator a;
+ unsigned int i;
+ struct settingitem *item;
+ const char *style;
+
+ if (!data) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ EINA_ARRAY_ITER_NEXT(data->sub_item_btn, i, btn, a) {
+ item = evas_object_data_get(btn, SUBITEM_DATA_ID);
+ style = settingitem_get_style(item);
+ if (style)
+ _draw_subitem_with_style(data->base, btn, style, item);
+ }
+
+ return 0;
+}
+
+/**
+* Evas_Object_Event_Cb type callback for handling mouse out event.
+*
+* @param[in]: data : the user data.
+* @param[in]: e : the evas.
+* @param[in]: obj : the corresponding object which the mouse out event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _subitem_btn_mouse_out_cb(void *data, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ /* TODO: Add necessary operations if needed. */
+}
+
+/**
+* Evas_Object_Event_Cb type callback for handling mouse in event.
+*
+* @param[in]: data : the user data.
+* @param[in]: e : the evas.
+* @param[in]: obj : the corresponding object which the mouse in event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _subitem_btn_mouse_in_cb(void *data, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ struct _view_data *priv;
+ Evas_Object *icon, *pb;
+
+ if (!obj || !data)
+ return;
+
+ priv = data;
+
+ elm_object_focus_set(obj, EINA_TRUE);
+
+ if (priv->focus_status == FOCUS_MAIN_ITEM) {
+ priv->focus_status = FOCUS_SUB_ITEM;
+ elm_object_signal_emit(priv->focused_main_item_btn,
+ MAINICONBTN_FOCUSED_ON_SUBITEM,
+ MAINICONBTN_MAIN_ITEM_SOURCE);
+
+ icon = elm_object_part_content_get(priv->focused_main_item_btn,
+ MAINICONBTN_ICON_SWALLOW);
+ if (icon)
+ elm_object_signal_emit(icon,
+ MAIN_BTN_HIGHLIGHT, MAIN_BTN);
+ }
+
+ pb = evas_object_data_get(priv->focused_sub_item_btn,
+ PROGRESS_BAR_DATA);
+ if (pb)
+ elm_object_signal_emit(pb, SIG_UNCTRL_PB_UNFOCUSED,
+ SRC_PB_PROG);
+
+ pb = evas_object_data_get(obj, PROGRESS_BAR_DATA);
+ if (pb)
+ elm_object_signal_emit(pb, SIG_UNCTRL_PB_FOCUSED, SRC_PB_PROG);
+
+ priv->focused_sub_item_btn = obj;
+}
+
+/**
+* Create subitems of settings.
+*
+* @param[in]: data : the user data.
+* @param[in]: name : the name of subitem.
+*
+* @return: 0 - success, -1 - fail.
+*/
+static int _draw_subitems(struct _view_data *data, const char *name)
+{
+ Evas_Object *box, *btn, *tmp;
+ struct settingview_data *view;
+ struct settingitem *item;
+ Eina_List *list, *l;
+ int cnt;
+ Eina_Array_Iterator a;
+ unsigned int i;
+ const char *style, *status;
+ Eina_Array *enabled;
+
+ if (!data || !name || !data->base) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ view = settingmgr_get_view(data->mgr, name);
+ if (!view) {
+ _ERR("get subview failed\n");
+ return -1;
+ }
+
+ list = viewdata_get_childitems_list(view);
+ if (!list) {
+ _ERR("childitem list is empty!");
+ if (view)
+ viewdata_release(view);
+ return -1;
+ }
+
+ cnt = eina_list_count(list);
+
+ data->sub_item_btn = eina_array_new(1);
+ enabled = eina_array_new(1);
+ if (!data->sub_item_btn || !enabled) {
+ _ERR("Create Eina Array failed\n");
+ EINA_LIST_FREE(list, item);
+ if (view)
+ viewdata_release(view);
+ return -1;
+ }
+
+ box = utils_add_box(data->base);
+ if (!box) {
+ _ERR("Add box failed\n");
+ EINA_LIST_FREE(list, item);
+ eina_array_free(data->sub_item_btn);
+ if (view)
+ viewdata_release(view);
+ return -1;
+ }
+
+ EINA_LIST_FOREACH(list, l, item) {
+ btn = utils_add_btn(data->base, SUBITEMBTN_STYLE,
+ settingitem_get_display_name(item), EINA_FALSE);
+ if (!btn) {
+ _ERR("Add btn failed");
+ evas_object_del(box);
+ EINA_LIST_FREE(list, item);
+ EINA_ARRAY_ITER_NEXT(data->sub_item_btn, i, tmp, a)
+ evas_object_del(tmp);
+ eina_array_free(data->sub_item_btn);
+ if (view)
+ viewdata_release(view);
+ return -1;
+ }
+
+ style = settingitem_get_style(item);
+ if (style)
+ _draw_subitem_with_style(data->base, btn, style, item);
+
+ evas_object_smart_callback_add(btn, "clicked",
+ _subitem_btn_clicked_cb, data);
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN,
+ _subitem_key_pressed_cb, data);
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN,
+ _subitem_btn_mouse_in_cb, data);
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_OUT,
+ _subitem_btn_mouse_out_cb, data);
+
+ elm_box_pack_end(box, btn);
+ eina_array_push(data->sub_item_btn, btn);
+
+ evas_object_data_set(btn, SUBITEM_DATA_ID, item);
+
+ status = settingitem_get_status(item);
+ if (status && !strncmp(status, DISABLED, strlen(status))) {
+ elm_object_disabled_set(btn, EINA_TRUE);
+ evas_object_freeze_events_set(btn, EINA_TRUE);
+ } else {
+ eina_array_push(enabled, btn);
+ }
+ }
+
+ data->subsetting_view = view;
+ data->sub_item_count = cnt;
+ data->subitem_box = box;
+
+ elm_object_part_content_set(data->base, MAIN_VIEW_SUBITEM_SWALLOW, box);
+
+ utils_set_focus_directions(enabled, eina_array_count(enabled));
+
+ EINA_LIST_FREE(list, item);
+ eina_array_free(enabled);
+
+ return 0;
+}
+
+/**
+* This function will be invoked when the main item is clicked.
+*
+* @param[in]: data : the user data.
+* @param[in]: mainbtn : the main item which the clicked event is occurred.
+*
+* @return: void.
+*/
+static void _move_from_main_item_to_subitem(struct _view_data *data,
+ Evas_Object *mainbtn)
+{
+ Evas_Object *btn, *pb, *icon;
+ int i;
+
+ if (!data || !mainbtn)
+ return;
+
+ data->focus_status = FOCUS_SUB_ITEM;
+
+ for (i = 0; i < data->sub_item_count; i++) {
+ btn = eina_array_data_get(data->sub_item_btn, i);
+ if (!btn) {
+ _ERR("Get subitem btn failed\n");
+ data->focus_status = FOCUS_MAIN_ITEM;
+ return;
+ }
+
+ if (elm_object_disabled_get(btn) != EINA_TRUE)
+ break;
+ }
+
+ if (i >= data->sub_item_count) {
+ data->focus_status = FOCUS_MAIN_ITEM;
+ return;
+ }
+
+ pb = evas_object_data_get(btn, PROGRESS_BAR_DATA);
+ if (pb)
+ elm_object_signal_emit(pb, SIG_UNCTRL_PB_FOCUSED, SRC_PB_PROG);
+
+ elm_object_focus_set(btn, EINA_TRUE);
+
+ data->focused_main_item_btn = mainbtn;
+ elm_object_signal_emit(mainbtn, MAINICONBTN_FOCUSED_ON_SUBITEM,
+ MAINICONBTN_MAIN_ITEM_SOURCE);
+
+ icon = elm_object_part_content_get(mainbtn, MAINICONBTN_ICON_SWALLOW);
+ if (icon)
+ elm_object_signal_emit(icon, MAIN_BTN_HIGHLIGHT, MAIN_BTN);
+}
+
+/**
+* Evas_Object_Event_Cb type callback for handling key press event.
+*
+* @param[in]: data : the user data.
+* @param[in]: e : the evas.
+* @param[in]: obj : the corresponding object which the key press event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _main_setting_key_pressed_cb(void *data, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _view_data *priv;
+ Evas_Object *next, *icon;
+ const char *name;
+
+ if (!data || !ei || !obj)
+ return;
+
+ ev = ei;
+ if (!ev->keyname)
+ return;
+
+ priv = data;
+
+ if (!strcmp(ev->keyname, KEY_DOWN)) {
+ icon = elm_object_part_content_get(obj,
+ MAINICONBTN_ICON_SWALLOW);
+ if (!icon) {
+ _ERR("part %s content get failed.",
+ MAINICONBTN_ICON_SWALLOW);
+ return;
+ }
+
+ elm_object_signal_emit(icon, MAIN_BTN_UNFOCUSED, MAIN_BTN);
+
+ next = elm_object_focus_next_object_get(obj, ELM_FOCUS_DOWN);
+ if (!next) {
+ _ERR("next object get failed.");
+ return;
+ }
+
+ priv->focused_main_item_btn = next;
+
+ icon = elm_object_part_content_get(next,
+ MAINICONBTN_ICON_SWALLOW);
+ if (!icon) {
+ _ERR("part %s content get failed.",
+ MAINICONBTN_ICON_SWALLOW);
+ return;
+ }
+
+ elm_object_signal_emit(icon, MAIN_BTN_FOCUSED, MAIN_BTN);
+
+ _release_subitems(priv);
+
+ name = evas_object_data_get(next, SETTING_ID);
+ if (name)
+ _draw_subitems(priv, name);
+ } else if (!strcmp(ev->keyname, KEY_UP)) {
+ icon = elm_object_part_content_get(obj,
+ MAINICONBTN_ICON_SWALLOW);
+ if (!icon) {
+ _ERR("part %s content get failed.",
+ MAINICONBTN_ICON_SWALLOW);
+ return;
+ }
+
+ elm_object_signal_emit(icon, MAIN_BTN_UNFOCUSED, MAIN_BTN);
+
+ next = elm_object_focus_next_object_get(obj, ELM_FOCUS_UP);
+ if (!next) {
+ _ERR("next object get failed.");
+ return;
+ }
+
+ priv->focused_main_item_btn = next;
+
+ icon = elm_object_part_content_get(next,
+ MAINICONBTN_ICON_SWALLOW);
+ if (!icon) {
+ _ERR("part %s content get failed.",
+ MAINICONBTN_ICON_SWALLOW);
+ return;
+ }
+
+ elm_object_signal_emit(icon, MAIN_BTN_FOCUSED, MAIN_BTN);
+
+ _release_subitems(priv);
+
+ name = evas_object_data_get(next, SETTING_ID);
+ if (name)
+ _draw_subitems(priv, name);
+ } else if (!strcmp(ev->keyname, KEY_RIGHT)) {
+ _move_from_main_item_to_subitem(priv, obj);
+ } else if (!strcmp(ev->keyname, KEY_EXIT) ||
+ !strcmp(ev->keyname, KEY_BACK)) {
+ app_efl_exit();
+ }
+}
+
+/**
+* Evas_Object_Event_Cb type callback for handling mouse in event.
+*
+* @param[in]: data : the user data.
+* @param[in]: e : the evas.
+* @param[in]: obj : the corresponding object which the mouse in event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _mainitem_btn_mouse_in_cb(void *data, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ struct _view_data *priv;
+ const char *name;
+ Evas_Object *icon;
+
+ if (!data || !obj) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = data;
+
+ if (priv->focus_status == FOCUS_SUB_ITEM)
+ _move_from_subitem_to_main_item(priv,
+ priv->focused_sub_item_btn);
+
+ icon = elm_object_part_content_get(priv->focused_main_item_btn,
+ MAINICONBTN_ICON_SWALLOW);
+ if (icon)
+ elm_object_signal_emit(icon, MAIN_BTN_UNFOCUSED, MAIN_BTN);
+
+ icon = elm_object_part_content_get(obj, MAINICONBTN_ICON_SWALLOW);
+ if (icon)
+ elm_object_signal_emit(icon, MAIN_BTN_FOCUSED, MAIN_BTN);
+
+ _release_subitems(priv);
+
+ name = evas_object_data_get(obj, SETTING_ID);
+ if (name)
+ _draw_subitems(priv, name);
+
+ elm_object_focus_set(obj, EINA_TRUE);
+ priv->focused_main_item_btn = obj;
+}
+
+/**
+* Evas_Object_Event_Cb type callback for handling mouse out event.
+*
+* @param[in]: data : the user data.
+* @param[in]: e : the evas.
+* @param[in]: obj : the corresponding object which the mouse out event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _mainitem_btn_mouse_out_cb(void *data, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ /* TODO: Add necessary operations if needed. */
+}
+
+/**
+* Evas_Smart_Cb type callback for handling click event.
+*
+* @param[in]: data : the user data.
+* @param[in]: obj : the corresponding object which the click event occurred.
+* @param[in]: ev : event info.
+*
+* @return: void.
+*/
+static void _mainitem_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *ev)
+{
+ struct _view_data *priv;
+
+ if (!data || !obj) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = data;
+ _move_from_main_item_to_subitem(priv, obj);
+}
+
+/**
+* Create main items of settings.
+*
+* @param[in]: data : the user data.
+* @param[in]: list : the eina list containing data of main items.
+*
+* @return: 0 - success, -1 - fail.
+*/
+static int _add_icon_btns(struct _view_data *data, Eina_List *list)
+{
+ Evas_Object *btn, *icon;
+ const char *id, *name;
+ struct settingitem *item;
+ char buf[BUF_SIZE];
+ int i;
+
+ if (!data || !list || !data->base) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ for (i = 0; i < data->main_item_count; i++) {
+ btn = utils_add_btn(data->base, MAINICONBTN_STYLE,
+ NULL, EINA_FALSE);
+ if (!btn) {
+ _ERR("Add btn failed\n");
+ return -1;
+ }
+
+ item = eina_list_nth(list, i);
+ if (item) {
+ name = settingitem_get_display_name(item);
+ elm_object_text_set(btn,
+ utils_get_translation_str(name));
+ } else {
+ elm_object_text_set(btn, ICON_BUTTON_NO_DISP_NAME);
+ }
+
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN,
+ _main_setting_key_pressed_cb, data);
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN,
+ _mainitem_btn_mouse_in_cb, data);
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_OUT,
+ _mainitem_btn_mouse_out_cb, data);
+ evas_object_smart_callback_add(btn, SIG_CLICKED,
+ _mainitem_btn_clicked_cb, data);
+
+ icon = elm_layout_add(btn);
+ if (icon) {
+ id = settingitem_get_id(item);
+ if (!id) {
+ _ERR("get item name failed.");
+ evas_object_del(btn);
+ return -1;
+ }
+
+ snprintf(buf, sizeof(buf), "%s/%s.edj",
+ EDJEDIR, PACKAGE);
+ elm_layout_file_set(icon, buf, id);
+ elm_object_part_content_set(btn,
+ MAINICONBTN_ICON_SWALLOW, icon);
+ elm_object_signal_emit(icon, MAIN_BTN_NORMAL, MAIN_BTN);
+ eina_array_push(data->main_icon_base, icon);
+ }
+
+ elm_box_pack_end(data->mainitem_box, btn);
+ evas_object_data_set(btn, SETTING_ID, settingitem_get_id(item));
+ eina_array_push(data->main_item_btn, btn);
+ }
+
+ return 0;
+}
+
+/**
+* Create all the UI components of settings.
+*
+* @param[in]: data : the user data.
+*
+* @return: 0 - success, -1 - fail.
+*/
+static int _draw_main_items(struct _view_data *data)
+{
+ Evas_Object *box, *btn, *tmp, *icon;
+ Eina_Array *btns, *icons;
+ Eina_List *list;
+ int cnt, i;
+ Eina_Array_Iterator a;
+
+ if (!data || !data->base)
+ return -1;
+
+ box = utils_add_box(data->base);
+ if (!box)
+ return -1;
+
+ data->mainitem_box = box;
+
+ cnt = 0;
+ list = viewdata_get_childitems_list(data->main_setting_view);
+ if (list)
+ cnt = eina_list_count(list);
+
+ if (cnt == 0) {
+ _ERR("There is no child item");
+ evas_object_del(box);
+ viewdata_free_childitems_list(list);
+ return -1;
+ }
+
+ data->main_item_count = cnt;
+
+ btns = eina_array_new(1);
+ if (!btns) {
+ _ERR("Create Eina Array failed\n");
+ evas_object_del(box);
+ viewdata_free_childitems_list(list);
+ return -1;
+ }
+
+ data->main_item_btn = btns;
+
+ icons = eina_array_new(1);
+ if (!icons) {
+ _ERR("new array for icon base failed.");
+ evas_object_del(box);
+ viewdata_free_childitems_list(list);
+ eina_array_free(btns);
+ return -1;
+ }
+
+ data->main_icon_base = icons;
+
+ if (_add_icon_btns(data, list) == -1) {
+ _ERR("Fail to add icon buttons");
+ goto error;
+ }
+
+ elm_object_part_content_set(data->base, MAIN_VIEW_ICON_SWALLOW, box);
+
+ if (!data->item_path) {
+ btn = eina_array_data_get(btns, 0);
+ if (!btn)
+ goto error;
+
+ if (_draw_subitems(data,
+ evas_object_data_get(btn, SETTING_ID)) == -1)
+ goto error;
+
+ icon = eina_array_data_get(icons, 0);
+ if (!icon) {
+ if (data->subsetting_view)
+ viewdata_release(data->subsetting_view);
+ goto error;
+ }
+
+ elm_object_signal_emit(icon, MAIN_BTN_FOCUSED, MAIN_BTN);
+
+ data->focus_status = FOCUS_MAIN_ITEM;
+
+ elm_object_focus_set(btn, EINA_TRUE);
+ data->focused_main_item_btn = btn;
+ }
+
+ utils_set_focus_directions(data->main_item_btn, cnt);
+
+ viewdata_free_childitems_list(list);
+
+ return 0;
+
+error:
+ evas_object_del(box);
+ viewdata_free_childitems_list(list);
+ EINA_ARRAY_ITER_NEXT(btns, i, tmp, a)
+ evas_object_del(tmp);
+ eina_array_free(btns);
+
+ EINA_ARRAY_ITER_NEXT(icons, i, tmp, a)
+ evas_object_del(tmp);
+ eina_array_free(icons);
+
+ return -1;
+}
+
+/**
+* Edje_Signal_Cb type callback for handling signal.
+*
+* @param[in]: data : the user data.
+* @param[in]: obj : the object signal occurred on.
+* @param[in]: emission : the signal name.
+* @param[in]: source : the source name.
+*
+* @return: void.
+*/
+static void _view_anim_finish(void *data, Evas_Object *obj,
+ const char *emission, const char *source)
+{
+ struct _view_data *priv;
+
+ if (!data)
+ return;
+
+ priv = data;
+
+ _draw_main_items(priv);
+}
+
+/**
+* This function moves focus from main item to subitem and
+* does corresponding operations.
+*
+* @param[in]: data : the user data.
+*
+* @return: void.
+*/
+void _move_focus_on_subitem(struct _view_data *data)
+{
+ const char *path, *id;
+ unsigned int i;
+ Evas_Object *icon, *subbtn, *pb;
+ Eina_Array *subbtns;
+ Eina_Array_Iterator a;
+ struct settingitem *item;
+
+ if (!data)
+ return;
+
+ subbtns = data->sub_item_btn;
+
+ path = eina_array_data_get(data->item_path, 0);
+
+ EINA_ARRAY_ITER_NEXT(subbtns, i, subbtn, a) {
+ item = evas_object_data_get(subbtn, SUBITEM_DATA_ID);
+ id = settingitem_get_id(item);
+ if (!id)
+ return;
+
+ if (!strncmp(id, path, ARRAY_SIZE)) {
+ icon = elm_object_part_content_get(
+ data->focused_main_item_btn,
+ MAINICONBTN_ICON_SWALLOW);
+ if (icon)
+ elm_object_signal_emit(icon,
+ MAIN_BTN_HIGHLIGHT, MAIN_BTN);
+
+ data->focus_status = FOCUS_SUB_ITEM;
+ data->focused_sub_item_btn = subbtn;
+
+ elm_object_focus_set(subbtn, EINA_TRUE);
+ elm_object_signal_emit(data->focused_main_item_btn,
+ MAINICONBTN_FOCUSED_ON_SUBITEM,
+ MAINICONBTN_MAIN_ITEM_SOURCE);
+
+ pb = evas_object_data_get(subbtn, PROGRESS_BAR_DATA);
+ if (pb)
+ elm_object_signal_emit(pb,
+ SIG_UNCTRL_PB_FOCUSED,
+ SRC_PB_PROG);
+ }
+ }
+}
+
+/**
+* Change the language of names of buttons.
+*
+* @param[in]: list : eina list of item data.
+* @param[in]: btns : eina array containing buttons.
+* @param[in]: cnt : number of buttons.
+*
+* @return: void.
+*/
+static void _change_buttons_name(Eina_List *list,
+ Eina_Array *btns, int cnt)
+{
+ struct settingitem *item;
+ Evas_Object *btn;
+ const char *name;
+ int i;
+
+ if (!list || !btns || !cnt) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ for (i = 0; i < cnt; i++) {
+ item = eina_list_nth(list, i);
+ btn = eina_array_data_get(btns, i);
+ if (!item || !btn)
+ return;
+
+ name = settingitem_get_display_name(item);
+ if (name)
+ elm_object_text_set(btn,
+ utils_get_translation_str(name));
+ }
+}
+
+/**
+* Create all UI components of settings view.
+*
+* @param[in]: mgr : the view manager of settings.
+* @param[in]: view : the view data.
+* @param[in]: prev : the user data.
+*
+* @return: the base layout of settings or null if error occurred.
+*/
+static Evas_Object *_create(struct setting_mgr *mgr,
+ struct settingview_data *view, void *prev)
+{
+ Evas_Object *base, *win;
+ struct _view_data *data;
+
+ if (!mgr || !view) {
+ _ERR("Invalid argument");
+ return NULL;
+ }
+
+ win = settingmgr_get_win(mgr);
+ if (!win) {
+ _ERR("Fail to get win");
+ return NULL;
+ }
+
+ data = calloc(1, sizeof(*data));
+ if (!data)
+ return NULL;
+
+ base = elm_layout_add(win);
+ if (!base) {
+ free(data);
+ return NULL;
+ }
+
+ if (!elm_layout_file_set(base, EDJ_FILE, MAIN_VIEW_PAGE))
+ goto error;
+
+ data->mgr = mgr;
+ data->win = win;
+ data->base = base;
+ data->main_setting_view = view;
+ data->subsetting_view = NULL;
+ data->item_path = settingmgr_get_item_path(mgr);
+
+ evas_object_data_set(base, DATA_ID, data);
+
+ elm_object_signal_callback_add(base, MAIN_VIEW_ANIM_FINISH,
+ MAIN_VIEW_SOURCE, _view_anim_finish, data);
+
+ if (!data->item_path)
+ elm_object_signal_emit(data->base, MAIN_VIEW_LOAD, "");
+ else
+ _view_anim_finish(data, NULL, NULL, NULL);
+
+ return base;
+
+error:
+ evas_object_del(base);
+ free(data);
+
+ return NULL;
+}
+
+/**
+* Show the view of settings.
+*
+* @param[in]: base : the base layout of settings.
+*
+* @return: void.
+*/
+static void _show(Evas_Object *base)
+{
+ struct _view_data *data;
+ unsigned int cnt, i;
+ const char *name, *path;
+ Evas_Object *btn, *icon;
+ Eina_Array *btns;
+ Eina_Array_Iterator a;
+
+ if (!base) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ data = evas_object_data_get(base, DATA_ID);
+ if (!data) {
+ _ERR("evas object data get failed. id: %s", DATA_ID);
+ return;
+ }
+
+ path = NULL;
+
+ if (data->item_path) {
+ btns = data->main_item_btn;
+
+ cnt = eina_array_count(data->item_path);
+ if (cnt > 1) {
+ path = eina_array_data_get(data->item_path, cnt - 2);
+ if (!path)
+ return;
+ }
+
+ EINA_ARRAY_ITER_NEXT(btns, i, btn, a) {
+ name = evas_object_data_get(btn, SETTING_ID);
+ if (!name)
+ return;
+
+ if (!strncmp(name, path, ARRAY_SIZE)) {
+ _draw_subitems(data, name);
+
+ icon = eina_array_data_get(
+ data->main_icon_base, i);
+ if (icon)
+ elm_object_signal_emit(icon,
+ MAIN_BTN_FOCUSED,
+ MAIN_BTN);
+
+ elm_object_focus_set(btn, EINA_TRUE);
+
+ data->focus_status = FOCUS_MAIN_ITEM;
+ data->focused_main_item_btn = btn;
+
+ _move_focus_on_subitem(data);
+ }
+ }
+ }
+
+ evas_object_show(base);
+}
+
+/**
+* Hide the view of settings.
+*
+* @param[in]: base : the base layout of settings.
+*
+* @return: void.
+*/
+static void _hide(Evas_Object *base)
+{
+ if (!base) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ evas_object_hide(base);
+}
+
+/**
+* Refresh the view of settings.
+*
+* @param[in]: base : the base layout of settings.
+*
+* @return: void.
+*/
+static void _refresh(Evas_Object *base)
+{
+ struct _view_data *data;
+ char *sld;
+ const char *id;
+ int i;
+ struct settingitem *item;
+ Eina_Array_Iterator a;
+ Evas_Object *btn, *pb, *icon;
+
+ if (!base)
+ return;
+
+ data = evas_object_data_get(base, DATA_ID);
+ if (!data)
+ return;
+
+ sld = evas_object_data_del(base, SELECTED_ITEM_ID);
+ if (sld) {
+ EINA_ARRAY_ITER_NEXT(data->sub_item_btn, i, btn, a) {
+ item = evas_object_data_get(btn, SUBITEM_DATA_ID);
+ id = settingitem_get_id(item);
+ if (!id)
+ continue;
+
+ if (item && !strncmp(sld, id, strlen(sld))) {
+ data->focused_sub_item_btn = btn;
+ break;
+ }
+ }
+ }
+
+ if (data->focus_status == FOCUS_SUB_ITEM) {
+ elm_object_focus_set(data->focused_sub_item_btn, EINA_TRUE);
+
+ elm_object_signal_emit(data->focused_main_item_btn,
+ MAINICONBTN_FOCUSED_ON_SUBITEM,
+ MAINICONBTN_MAIN_ITEM_SOURCE);
+
+ icon = elm_object_part_content_get(data->focused_main_item_btn,
+ MAINICONBTN_ICON_SWALLOW);
+ if (icon)
+ elm_object_signal_emit(icon,
+ MAIN_BTN_HIGHLIGHT, MAIN_BTN);
+
+ if (_refresh_subitems(data) == -1)
+ _ERR("Refresh subitems failed");
+
+ pb = evas_object_data_get(data->focused_sub_item_btn,
+ PROGRESS_BAR_DATA);
+ if (pb)
+ elm_object_signal_emit(pb,
+ SIG_UNCTRL_PB_FOCUSED, SRC_PB_PROG);
+ }
+
+ if (settingmgr_get_timeout_freeze_state(data->mgr) == EINA_TRUE)
+ settingmgr_thaw_timeout(data->mgr);
+}
+
+/**
+* Destroy the view of settings.
+*
+* @param[in]: base : the base layout of settings.
+*
+* @return: void.
+*/
+static void _destroy(Evas_Object *base)
+{
+ struct _view_data *data;
+ Eina_Array_Iterator a;
+ Evas_Object *tmp;
+ unsigned int i;
+
+ if (!base) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ data = evas_object_data_get(base, DATA_ID);
+
+ if (data->sub_item_btn) {
+ EINA_ARRAY_ITER_NEXT(data->sub_item_btn, i, tmp, a)
+ evas_object_del(tmp);
+ eina_array_free(data->sub_item_btn);
+ }
+
+ if (data->main_item_btn) {
+ EINA_ARRAY_ITER_NEXT(data->main_item_btn, i, tmp, a)
+ evas_object_del(tmp);
+ eina_array_free(data->main_item_btn);
+ }
+
+ if (data->main_icon_base) {
+ EINA_ARRAY_ITER_NEXT(data->main_icon_base, i, tmp, a)
+ evas_object_del(tmp);
+ eina_array_free(data->main_icon_base);
+ }
+
+ if (data->main_setting_view)
+ viewdata_release(data->main_setting_view);
+
+ if (data->subsetting_view)
+ viewdata_release(data->subsetting_view);
+
+ free(data);
+ evas_object_del(base);
+}
+
+/**
+* Change the language of view of settings.
+*
+* @param[in]: base : the base layout of settings.
+*
+* @return: void.
+*/
+static void _lang_changed(Evas_Object *base)
+{
+ struct _view_data *data;
+ Eina_List *l;
+ int cnt;
+
+ if (!base) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ data = evas_object_data_get(base, DATA_ID);
+ if (!data)
+ return;
+
+ cnt = 0;
+ l = viewdata_get_childitems_list(data->main_setting_view);
+ if (l)
+ cnt = eina_list_count(l);
+
+ _change_buttons_name(l, data->main_item_btn, cnt);
+
+ cnt = 0;
+ l = viewdata_get_childitems_list(data->subsetting_view);
+ if (l)
+ cnt = eina_list_count(l);
+
+ _change_buttons_name(l, data->sub_item_btn, cnt);
+}
+
+/**
+* Froze the view of settings.
+*
+* @param[in]: base : the base layout of settings.
+*
+* @return: void.
+*/
+static void _frozen(Evas_Object *base)
+{
+ struct _view_data *data;
+
+ if (!base) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ data = evas_object_data_get(base, DATA_ID);
+ if (!data) {
+ _ERR("Fail to get mainview data");
+ return;
+ }
+
+ evas_object_freeze_events_set(data->mainitem_box, EINA_TRUE);
+ evas_object_freeze_events_set(data->subitem_box, EINA_TRUE);
+}
+
+/**
+* Activate the view of settings.
+*
+* @param[in]: base : the base layout of settings.
+*
+* @return: void.
+*/
+static void _active(Evas_Object *base)
+{
+ struct _view_data *data;
+
+ if (!base) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ data = evas_object_data_get(base, DATA_ID);
+ if (!data) {
+ _ERR("Fail to get mainview data");
+ return;
+ }
+
+ evas_object_freeze_events_set(data->mainitem_box, EINA_FALSE);
+ evas_object_freeze_events_set(data->subitem_box, EINA_FALSE);
+}
+
+static struct setting_class _vclass = {
+ .title = VCLASS_TITLE_MAIN_VIEW,
+ .create = _create,
+ .show = _show,
+ .destroy = _destroy,
+ .hide = _hide,
+ .refresh = _refresh,
+ .frozen = _frozen,
+ .active = _active,
+ .lang_changed = _lang_changed,
+ .hide_view = 0
+};
+
+/**
+* Return view class of settings view.
+*
+* @param: void.
+*
+* @return: the view class of settings view.
+*/
+struct setting_class *view_maincatalog_get_vclass(void)
+{
+ return &_vclass;
+}
diff --git a/src/view_maincatalog.cpp b/src/view_maincatalog.cpp
deleted file mode 100644
index 591efcd..0000000
--- a/src/view_maincatalog.cpp
+++ /dev/null
@@ -1,1557 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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 <AppCommon.h>
-#include "common_defs.h"
-#include "stdbool.h"
-#include "settingviewmgr.h"
-#include "utils.h"
-#include "view_maincatalog.h"
-#include "data_wrapper.h"
-#include "settings_provider.h"
-#include "settingviewmgr.h"
-
-#define DATA_ID "main_setting_data"
-#define SUBITEM_DATA_ID "subitem_data_id"
-#define SYSTEM_CLOCK_DATA "system_clock_data"
-#define ICON_PART "iconpart"
-#define PROGRESS_BAR_DATA "progressbar"
-
-#define SETTING_ID "setting_id"
-#define E_CREATE_ITEMS 0
-
-#define MAX_PROGRESS_VALUE 100.0
-#define MIN_PROGRESS_VALUE 0.0
-#define ICON_BUTTON_NO_DISP_NAME "No Display Name"
-#define CHANGE_PASSCODE_NAME "change-passcode"
-#define PASSCODE_MASK "****"
-#define DISABLED "disabled"
-#define ENABLED "enabled"
-#define SIG_CLICKED "clicked"
-
-enum KeyID {
- MAIN_ITEM_BTNS,
- SUB_ITEM_BTNS
-};
-
-enum focused_state {
- FOCUS_MAIN_ITEM = 1,
- FOCUS_SUB_ITEM
-};
-
-struct SMainCatalog {
- Evas_Object *win;
- Evas_Object *base;
- Eina_Array *sub_item_btn;
- Eina_Array *main_item_btn;
- Eina_Array *main_icon_base;
- Eina_Array *item_path;
- Evas_Object *focused_sub_item_btn;
- Evas_Object *focused_main_item_btn;
- Evas_Object *subitem_box;
- Evas_Object *mainitem_box;
-
- int focus_status;
- int main_item_count;
- int sub_item_count;
-
- CSettingMgr *mgr;
- struct settingview_data *main_setting_view;
- struct settingview_data *subsetting_view;
-
- SMainCatalog() {
- memset(this, 0, sizeof(*this));
- }
-};
-
-/**
-* This function will be invoked when focus moves from subitem to main item.
-*
-* @param[in]: data : the user data.
-* @param[in]: btn : subitem which focus is on.
-*
-* @return: void.
-*/
-void CMainCatalogView::m_MoveFromSubitemToMainitem(Evas_Object *btn)
-{
- if(!btn) return;
- m->focus_status = FOCUS_MAIN_ITEM;
- m->focused_sub_item_btn = btn;
-
- elm_object_focus_set(m->focused_main_item_btn, EINA_TRUE);
-}
-
-
-static void _get_geometry_data(Evas_Object *obj,
- struct obj_geometry_data *param)
-{
- int x, y, w, h;
-
- if (!param || !obj) {
- _ERR("Invalid argument");
- return;
- }
-
- x = y = w = h = 0;
-
- evas_object_geometry_get(obj, &x, &y, &w, &h);
-
- param->x = x;
- param->y = y;
- param->width = w;
- param->height = h;
-}
-
-
-void CMainCatalogView::m_SubItemClicked(Evas_Object *obj)
-{
- const char *style;
- struct settingitem *item;
-
- if (m->focus_status != FOCUS_SUB_ITEM)
- return;
-
- item =(struct settingitem *) evas_object_data_get(obj, SUBITEM_DATA_ID);
- if (!item) {
- _ERR("Get sub item failed");
- return;
- }
-
- style = settingitem_get_settingui_style(item);
- if (!style) {
- _ERR("setting-ui style is null.");
- return;
- }
-
- const char *id;
- id = settingitem_get_id(item);
- if (!id) {
- _ERR("Fail to get item id");
- return ;
- }
-
- if (!strncmp(style, STYLE_UIGADGET, strlen(style))) {
-
- struct evas_obj_data param;
- param.subitem_box = m->subitem_box;
- param.display_name = settingitem_get_display_name(item);
- param.cur_btn = obj;
-
- if (!m->mgr->ViewPush(id, (void *)&param))
- _ERR("Fail to push ug view");
-
- } else if (!strncmp(style, STYLE_CTXPOPUP, strlen(style))) {
-
- struct obj_geometry_data ogd;
- _get_geometry_data(obj, &ogd);
-
- if (!m->mgr->ViewPush(id, (void *)&ogd))
- _ERR("Fail to push sublist");
- else
- elm_object_signal_emit(obj, SUBITEMBTN_BUTTON_CLICKED, SUBITEMBTN_BUTTON_SOURCE);
-
- } else if (!strncmp(style, STYLE_BOTTOM_CTXPOPUP, strlen(style))) {
-
- if (!m->mgr->ViewPush(id, NULL))
- _ERR("Fail to push view");
-
- } else if (!strncmp(style, STYLE_BOTTOMSLIDER, strlen(style)) || !strncmp(style, STYLE_BOTTOM2WAYSLIDER, strlen(style))) {
-
- Eina_List *list;
- Evas_Object *pb;
- pb = (Evas_Object *)evas_object_data_get(obj, PROGRESS_BAR_DATA);
- if (pb)
- elm_object_signal_emit(pb, SIG_UNCTRL_PB_UNFOCUSED, SRC_PB_PROG);
- list = settingitem_get_slider_group_list(viewdata_get_parentitem(m->subsetting_view), m->mgr->GetData(), id);
- if (!m->mgr->ViewPush(id, list))
- _ERR("Fail to push bottom slider view");
-
- } else if (!strncmp(style, STYLE_PASSCODE_POPUP, strlen(style))) {
-
- if (!m->mgr->ViewPush(id, NULL))
- _ERR("Fail to push passcode view");
-
- } else if (!strncmp(style, STYLE_DEVICE_MANAGER, strlen(style))) {
-
- struct evas_obj_data param;
- param.display_name = settingitem_get_display_name(item);
- param.subitem_box = m->subitem_box;
-
- if (!m->mgr->ViewPush(id, &param))
- _ERR("Fail to push device_manager view");
-
- } else if (!strncmp(style, STYLE_RESET_POPUP, strlen(style))) {
-
- if (!m->mgr->ViewPush(id, NULL))
- _ERR("Fail to push reset_popup view");
-
- } else if (!strncmp(style, STYLE_UPGRADE_POPUP, strlen(style))) {
-
- if (!m->mgr->ViewPush(id, NULL))
- _ERR("Fail to push reset_popup view");
-
- } else if (!strncmp(style, STYLE_CLOCK_CTXPOPUP, strlen(style))) {
-
- struct evas_obj_data param;
- struct obj_geometry_data ogd;
-
- _get_geometry_data(obj, &ogd);
-
- param.display_name = settingitem_get_display_name(item);
- param.subitem_box = m->subitem_box;
- param.cur_btn = obj;
-
- evas_object_data_set(obj, SYSTEM_CLOCK_DATA, (void *)&ogd);
-
- if (!m->mgr->ViewPush(id, &param))
- _ERR("Fail to push view");
- else
- elm_object_signal_emit(obj, SUBITEMBTN_BUTTON_CLICKED, SUBITEMBTN_BUTTON_SOURCE);
-
- } else if (!strncmp(style, STYLE_NEED_PASSCODE, strlen(style))) {
-
- struct obj_geometry_data ogd;
- _get_geometry_data(obj, &ogd);
-
- if (!m->mgr->ViewPush(id, &ogd))
- _ERR("Fail to push view");
- else
- elm_object_signal_emit(obj, SUBITEMBTN_BUTTON_CLICKED, SUBITEMBTN_BUTTON_SOURCE);
-
- }
-
- m->focused_sub_item_btn = obj;
-}
-
-static char *_settingitems_get_value(struct settingitem *item)
-{
- char *result;
- const char *name, *style;
-
- if (!item) {
- _ERR("Invalid argument");
- return NULL;
- }
-
- result = NULL;
-
- name = settingitem_get_id(item);
- if (name && !strncmp(name, CHANGE_PASSCODE_NAME, strlen(name))) {
- result = strdup(PASSCODE_MASK);
- return result;
- }
-
- style = settingitem_get_settingui_style(item);
- if (!style) {
- _ERR("Fail to get setting ui style");
- return NULL;
- }
-
- if (!strncmp(style, STYLE_UIGADGET, strlen(style)))
- return provider_get_list_value(item);
- else
- return provider_get_selected_display_name(item);
-}
-
-/**
-* Get percentage value of progress from item data.
-*
-* @param[in]: item : item data read from json file.
-*
-* @return: the percentage value or -1.0 if error occurred.
-*/
-static double _get_progress_percentage(struct settingitem *item)
-{
- struct slideritem *sitem;
- double val, persent;
-
- if (!item) {
- _ERR("Invalid argument");
- return -1.0;
- }
-
- sitem = settingitem_get_data_slideritem(item);
- if (!sitem) {
- _ERR("Get slider item failed");
- return -1.0;
- }
-
- val = provider_get_slider_value(item);
- persent = slideritem_find_slider_value(val, sitem);
-
- return persent;
-}
-
-/**
-* Get displaying value of item.
-*
-* @param[in]: item : item data read from json file.
-* @param[in]: value : the percentage value.
-*
-* @return: the display value.
-*/
-static double _get_display_value(struct settingitem *item, double value)
-{
- struct slideritem *sitem;
- double disp;
-
- if (!item) {
- _ERR("Invalid argument");
- return -1.0;
- }
-
- sitem = settingitem_get_data_slideritem(item);
- if (!sitem) {
- _ERR("Get slider item failed");
- return -1.0;
- }
-
- disp = slideritem_find_slider_display_value(value, sitem);
-
- return disp;
-}
-
-/**
-* Create slider of subitem.
-*
-* @param[in]: item : the item data read from json file.
-* @param[in]: base : the base layout of subitems.
-* @param[in]: btn : the subitem the slider will be created on.
-*
-* @return: void.
-*/
-static void _set_subitem_btn_slider(struct settingitem *item,
- Evas_Object *base, Evas_Object *btn)
-{
- Evas_Object *pb;
- double val, percent;
- char buf[BUF_SIZE];
-
- if (!item || !base || !btn) {
- _ERR("Invalid argument");
- return;
- }
-
- elm_object_style_set(btn, SUBITEMBTN_TITLE_SLIDER_VALUE);
-
- pb = elm_progressbar_add(base);
- if (!pb) {
- _ERR("Add progress bar failed.");
- return;
- }
-
- elm_object_style_set(pb, SUBITEMBTN_TITILE_SLIDER);
-
- percent = _get_progress_percentage(item);
- val = _get_display_value(item, percent);
- elm_progressbar_value_set(pb, percent);
-
- snprintf(buf, sizeof(buf), "%d", (int)val);
- elm_object_part_text_set(btn, SUBITEMBTN_VALUE, buf);
- elm_object_part_content_set(btn, SUBITEMBTN_SLIDER_SWALLOW, pb);
-
- evas_object_data_set(btn, PROGRESS_BAR_DATA, pb);
-}
-
-/**
-* Get tint g-value.
-*
-* @param[in]: item : the item data read from json file.
-* @param[in]: tint_r : the tint r-value.
-*
-* @return: the tint g-value.
-*/
-static double _get_disp_tint_g_val(struct settingitem *item, double tint_r)
-{
- const char *strval;
- struct slideritem *sitem;
- double val;
-
- if (!item) {
- _ERR("Invalid argument");
- return -1.0;
- }
-
- sitem = settingitem_get_data_slideritem(item);
- if (!sitem) {
- _ERR("Get slider item failed");
- return -1.0;
- }
-
- strval = slideritem_get_max_display_value(sitem);
- if (strval)
- val = atof(strval);
- else
- val = 100;
-
- return val - tint_r;
-}
-
-/**
-* Create two way slider.
-*
-* @param[in]: item : the item data read from json file.
-* @param[in]: base : the base layout of subitems.
-* @param[in]: btn : the subitem which the two way slider will be created on.
-*
-* @return: void.
-*/
-static void _set_subitem_btn_value_slider(struct settingitem *item,
- Evas_Object *base, Evas_Object *btn)
-{
- Evas_Object *pb;
- double tint_r, tint_g, percent;
- char buf[BUF_SIZE];
-
- if (!item || !base || !btn) {
- _ERR("Invalid argument");
- return;
- }
-
- elm_object_style_set(btn, SUBITEMBTN_TITLE_SLIDER_VALUE);
-
- pb = elm_progressbar_add(base);
- if (!pb) {
- _ERR("Add progress bar failed.");
- return;
- }
-
- elm_object_style_set(pb, SUBITEMBTN_TITILE_SLIDER);
- percent = _get_progress_percentage(item);
- elm_progressbar_value_set(pb, percent);
-
- tint_r = _get_display_value(item, percent);
- tint_g = _get_disp_tint_g_val(item, tint_r);
-
- snprintf(buf, sizeof(buf), "R%d", (int)tint_r);
- elm_object_part_text_set(btn, SUBITEMBTN_VALUE,
- utils_get_translation_str(buf));
- snprintf(buf, sizeof(buf), "G%d", (int)tint_g);
- elm_object_part_text_set(btn, SUBITEMBTN_G_VALUE,
- utils_get_translation_str(buf));
-
- elm_object_part_content_set(btn, SUBITEMBTN_SLIDER_SWALLOW, pb);
-
- evas_object_data_set(btn, PROGRESS_BAR_DATA, pb);
-}
-
-/**
-* Create style for subitem.
-*
-* @param[in]: base : the base layout of subitems.
-* @param[in]: obj : the subitem which the style will be created on.
-* @param[in]: style : the style read from json file.
-* @param[in]: item : the item data read from json file.
-*
-* @return: void.
-*/
-static void _draw_subitem_with_style(Evas_Object *base, Evas_Object *obj,
- const char *style, struct settingitem *item)
-{
- char *val;
-
- if (!style || !base || !obj || !item)
- return;
-
- if (!strncmp(style, STYLE_SUBBUTTON_TITLE_VALUE, strlen(style))) {
- val = _settingitems_get_value(item);
- elm_object_part_text_set(obj, SUBITEMBTN_VALUE,
- utils_get_translation_str(val));
- free(val);
- } else if (!strncmp(style, STYLE_SUBBUTTON_TITLE_ICON, strlen(style))) {
- elm_object_style_set(obj, SUBITEMBTN_TITLE_ICON);
- } else if (!strncmp(style, STYLE_SUBBUTTON_TITLE_SLIDER_VALUE,
- strlen(style))) {
- _set_subitem_btn_slider(item, base, obj);
- } else if (!strncmp(style, STYLE_SUBBUTTON_TITLE_2WAYSLIDER_VALUE,
- strlen(style))) {
- _set_subitem_btn_value_slider(item, base, obj);
- }
-}
-
-/**
-* Release resources of subitems.
-*
-* @param[in]: data : the user data.
-*
-* @return: void.
-*/
-static void _release_subitems(SMainCatalog *data)
-{
- Evas_Object *btn;
- void* obj;
- Eina_Array_Iterator a;
- unsigned int i;
-
- if (!data) {
- _ERR("Invalid argument");
- return;
- }
-
- if (data->sub_item_btn) {
- EINA_ARRAY_ITER_NEXT(data->sub_item_btn, i, obj, a)
- {
- btn = (Evas_Object *) obj;
- evas_object_del(btn);
- }
- eina_array_free(data->sub_item_btn);
- }
-
- if (data->subsetting_view)
- viewdata_release(data->subsetting_view);
-
- if (data->subitem_box)
- evas_object_del(data->subitem_box);
-}
-
-/**
-* Refresh subitems when subitems are changed.
-*
-* @param[in]: data : the user data.
-*
-* @return: 0 - success, -1 - fail.
-*/
-static int _refresh_subitems(SMainCatalog *data)
-{
- Evas_Object *btn;
- void* obj;
- Eina_Array_Iterator a;
- unsigned int i;
- struct settingitem *item;
- const char *style;
-
- if (!data) {
- _ERR("Invalid argument");
- return -1;
- }
-
- EINA_ARRAY_ITER_NEXT(data->sub_item_btn, i, obj, a) {
- btn = (Evas_Object *) obj;
- item = (struct settingitem *)evas_object_data_get(btn, SUBITEM_DATA_ID);
- style = settingitem_get_style(item);
- if (style)
- _draw_subitem_with_style(data->base, btn, style, item);
- }
-
- return 0;
-}
-
-static void _subitem_btn_mouse_in_cb(void *data, Evas *e, Evas_Object *obj, void *ei)
-{
- SMainCatalog *priv;
- Evas_Object *icon, *pb;
-
- if (!obj || !data)
- return;
-
- priv = (SMainCatalog *)data;
-
- elm_object_focus_set(obj, EINA_TRUE);
-
- if (priv->focus_status == FOCUS_MAIN_ITEM) {
- priv->focus_status = FOCUS_SUB_ITEM;
- elm_object_signal_emit(priv->focused_main_item_btn,
- MAINICONBTN_FOCUSED_ON_SUBITEM,
- MAINICONBTN_MAIN_ITEM_SOURCE);
-
- icon = elm_object_part_content_get(priv->focused_main_item_btn,
- MAINICONBTN_ICON_SWALLOW);
- if (icon)
- elm_object_signal_emit(icon,
- MAIN_BTN_HIGHLIGHT, MAIN_BTN);
- }
-
- pb =(Evas_Object *) evas_object_data_get(priv->focused_sub_item_btn,
- PROGRESS_BAR_DATA);
- if (pb)
- elm_object_signal_emit(pb, SIG_UNCTRL_PB_UNFOCUSED,
- SRC_PB_PROG);
-
- pb = (Evas_Object *)evas_object_data_get(obj, PROGRESS_BAR_DATA);
- if (pb)
- elm_object_signal_emit(pb, SIG_UNCTRL_PB_FOCUSED, SRC_PB_PROG);
-
- priv->focused_sub_item_btn = obj;
-}
-
-/**
-* Create subitems of settings.
-*
-* @param[in]: data : the user data.
-* @param[in]: name : the name of subitem.
-*
-* @return: 0 - success, -1 - fail.
-*/
-bool CMainCatalogView::m_DrawSubItems(const char *name)
-{
- struct settingview_data *view;
- Eina_List *list, *l;
- void* obj;
-
- Evas_Object *btn, *tmp;
- struct settingitem *item;
- Eina_Array_Iterator a;
- unsigned int i;
- const char *style, *status;
- Eina_Array *enabled;
-
- if (!name) {
- _ERR("Invalid argument");
- return false;
- }
-
- view = m->mgr->GetView(name);
- if (!view) {
- _ERR("get subview failed");
- return false;
- }
-
- list = viewdata_get_childitems_list(view);
- if (!list) {
- _ERR("childitem list is empty!");
- if (view)
- viewdata_release(view);
- return false;
- }
-
- m->sub_item_count = eina_list_count(list);
-
- m->sub_item_btn = eina_array_new(1);
- enabled = eina_array_new(1);
- if (!m->sub_item_btn || !enabled) {
- _ERR("Create Eina Array failed");
- EINA_LIST_FREE(list, obj);
- {
- item = (struct settingitem *) obj;
- free(item);
- }
- if (view)
- viewdata_release(view);
- return false;
- }
-
- m->subitem_box = utils_add_box(m->base);
- if (!m->subitem_box) {
- _ERR("Add m->subitem_box failed");
- EINA_LIST_FREE(list, obj);
- {
- item = (struct settingitem *) obj;
- free(item);
- }
- eina_array_free(m->sub_item_btn);
- if (view)
- viewdata_release(view);
- return false;
- }
-
- EINA_LIST_FOREACH(list, l, obj) {
- item = (struct settingitem *) obj;
- btn = utils_add_btn(m->base, SUBITEMBTN_STYLE, settingitem_get_display_name(item), EINA_FALSE);
- if (!btn) {
- _ERR("Add btn failed");
- evas_object_del(m->subitem_box);
- EINA_LIST_FREE(list, obj);
- {
- item = (struct settingitem *) obj;
- free(item);
- }
- EINA_ARRAY_ITER_NEXT(m->sub_item_btn, i, obj, a)
- {
- tmp = (Evas_Object *) obj;
- evas_object_del(tmp);
- }
- eina_array_free(m->sub_item_btn);
- if (view)
- viewdata_release(view);
- return false;
- }
-
- style = settingitem_get_style(item);
- if (style)
- _draw_subitem_with_style(m->base, btn, style, item);
-
- Connect(btn, SUB_ITEM_BTNS, TYPE_CLICKED | TYPE_KEY_DOWN);
- //evas_object_smart_callback_add(btn, "clicked", _subitem_btn_clicked_cb, data);
- //evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, _subitem_key_pressed_cb, data);
- evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, _subitem_btn_mouse_in_cb, m);
-
- elm_box_pack_end(m->subitem_box, btn);
- eina_array_push(m->sub_item_btn, btn);
-
- evas_object_data_set(btn, SUBITEM_DATA_ID, item);
-
- status = settingitem_get_status(item);
- if (status && !strncmp(status, DISABLED, strlen(status))) {
- elm_object_disabled_set(btn, EINA_TRUE);
- evas_object_freeze_events_set(btn, EINA_TRUE);
- } else {
- eina_array_push(enabled, btn);
- }
- }
-
- m->subsetting_view = view;
-
- elm_object_part_content_set(m->base, MAIN_VIEW_SUBITEM_SWALLOW, m->subitem_box);
- utils_set_focus_directions(enabled, eina_array_count(enabled));
-
- EINA_LIST_FREE(list, obj);
- {
- item = (struct settingitem *) obj;
- free(item);
- }
- eina_array_free(enabled);
-
- return true;
-}
-
-void CMainCatalogView::m_MoveFromMainitemToSubitem(Evas_Object *mainbtn)
-{
- Evas_Object *btn = NULL, *pb, *icon;
- int i;
-
- if (!mainbtn)
- return;
-
- m->focus_status = FOCUS_SUB_ITEM;
-
- for (i = 0; i < m->sub_item_count; i++) {
- btn = (Evas_Object *) eina_array_data_get(m->sub_item_btn, i);
- if (!btn) {
- _ERR("Get subitem btn failed");
- m->focus_status = FOCUS_MAIN_ITEM;
- return;
- }
-
- if (elm_object_disabled_get(btn) != EINA_TRUE)
- break;
- }
-
- if (i >= m->sub_item_count) {
- m->focus_status = FOCUS_MAIN_ITEM;
- return;
- }
-
- pb = (Evas_Object *)evas_object_data_get(btn, PROGRESS_BAR_DATA);
- if (pb)
- elm_object_signal_emit(pb, SIG_UNCTRL_PB_FOCUSED, SRC_PB_PROG);
-
- elm_object_focus_set(btn, EINA_TRUE);
-
- m->focused_main_item_btn = mainbtn;
- elm_object_signal_emit(mainbtn, MAINICONBTN_FOCUSED_ON_SUBITEM, MAINICONBTN_MAIN_ITEM_SOURCE);
-
- icon = elm_object_part_content_get(mainbtn, MAINICONBTN_ICON_SWALLOW);
- if (icon)
- elm_object_signal_emit(icon, MAIN_BTN_HIGHLIGHT, MAIN_BTN);
-}
-
-void CMainCatalogView::sm_CbMainItemBtnMouseIN(void *data, Evas *e, Evas_Object *obj, void *ei)
-{
- CMainCatalogView *instance;
-
- if(!data){_ERR("Invaild Parameter"); return;}
- instance = (CMainCatalogView *)data;
- instance->m_OnMainItemMouseIN(e, obj, ei);
-}
-
-void CMainCatalogView::m_OnMainItemMouseIN(Evas *e, Evas_Object *obj, void *ei)
-{
- const char *name;
- Evas_Object *icon;
-
- if (!obj) {
- _ERR("Invalid argument");
- return;
- }
-
- if (m->focus_status == FOCUS_SUB_ITEM)
- m_MoveFromSubitemToMainitem(m->focused_sub_item_btn);
-
- icon = elm_object_part_content_get(m->focused_main_item_btn, MAINICONBTN_ICON_SWALLOW);
- if (icon)
- elm_object_signal_emit(icon, MAIN_BTN_UNFOCUSED, MAIN_BTN);
-
- icon = elm_object_part_content_get(obj, MAINICONBTN_ICON_SWALLOW);
- if (icon)
- elm_object_signal_emit(icon, MAIN_BTN_FOCUSED, MAIN_BTN);
-
- _release_subitems(m);
-
- name =(const char *) evas_object_data_get(obj, SETTING_ID);
- if (name)
- m_DrawSubItems(name);
-
- elm_object_focus_set(obj, EINA_TRUE);
- m->focused_main_item_btn = obj;
-}
-
-
-bool CMainCatalogView::m_AddIconBtns(Eina_List *list)
-{
- Evas_Object *btn, *icon;
- const char *id, *name;
- struct settingitem *item;
- char buf[BUF_SIZE];
-
- if (!list) {
- _ERR("Invalid argument");
- return false;
- }
-
- for (int i = 0; i < m->main_item_count; i++) {
- btn = utils_add_btn(m->base, MAINICONBTN_STYLE, NULL, EINA_FALSE);
- if (!btn) {
- _ERR("Add btn failed");
- return false;
- }
-
- item = (struct settingitem *) eina_list_nth(list, i);
- if (item) {
- name = settingitem_get_display_name(item);
- elm_object_text_set(btn, utils_get_translation_str(name));
- } else {
- elm_object_text_set(btn, ICON_BUTTON_NO_DISP_NAME);
- }
-
- Connect(btn, MAIN_ITEM_BTNS, TYPE_CLICKED | TYPE_KEY_DOWN);
- evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, sm_CbMainItemBtnMouseIN, this);
- //evas_object_smart_callback_add(btn, SIG_CLICKED, _mainitem_btn_clicked_cb, data);
- //evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, _main_setting_key_pressed_cb, data);
-
- icon = elm_layout_add(btn);
- if (icon) {
- id = settingitem_get_id(item);
- if (!id) {
- _ERR("get item name failed.");
- evas_object_del(btn);
- return false;
- }
-
- snprintf(buf, sizeof(buf), "%s/%s.edj", EDJEDIR, PACKAGE);
- elm_layout_file_set(icon, buf, id);
- elm_object_part_content_set(btn, MAINICONBTN_ICON_SWALLOW, icon);
- elm_object_signal_emit(icon, MAIN_BTN_NORMAL, MAIN_BTN);
- eina_array_push(m->main_icon_base, icon);
- }
-
- elm_box_pack_end(m->mainitem_box, btn);
- evas_object_data_set(btn, SETTING_ID, settingitem_get_id(item));
- eina_array_push(m->main_item_btn, btn);
- }
-
- return true;
-}
-
-/**
-* Create all the UI components of settings.
-*
-* @param[in]: data : the user data.
-*
-* @return: 0 - success, -1 - fail.
-*/
-void CMainCatalogView::m_DrawMainItems(void)
-{
- Evas_Object *btn, *icon;
- Eina_List *list = NULL;
- bool ret = true;
-
- _CREATE_BEGIN {
- _CHECK(m->mainitem_box = utils_add_box(m->base))
- _CHECK(list = viewdata_get_childitems_list(m->main_setting_view))
- _COMMAND{
- m->main_item_count = 0;
- m->main_item_count = eina_list_count(list);
- }
- _CHECK(m->main_item_count)
- _CHECK(m->main_item_btn = eina_array_new(1))
- _CHECK(m->main_icon_base = eina_array_new(1))
- _CHECK(m_AddIconBtns(list))
- _COMMAND {
- elm_object_part_content_set(m->base, MAIN_VIEW_ICON_SWALLOW, m->mainitem_box);
-
- if (!m->item_path) {
- btn = (Evas_Object *)eina_array_data_get(m->main_item_btn, 0);
- if (btn) {
- if (m_DrawSubItems((const char *) evas_object_data_get(btn, SETTING_ID))) {
- icon = (Evas_Object *)eina_array_data_get(m->main_icon_base, 0);
- if (icon) {
- elm_object_signal_emit(icon, MAIN_BTN_FOCUSED, MAIN_BTN);
-
- m->focus_status = FOCUS_MAIN_ITEM;
- elm_object_focus_set(btn, EINA_TRUE);
- m->focused_main_item_btn = btn;
- }
- else {
- if (m->subsetting_view)
- viewdata_release(m->subsetting_view);
- ret = false;
- }
- }
- else
- ret = false;
- }
- else
- ret = false;
- }
-
- utils_set_focus_directions(m->main_item_btn, m->main_item_count);
- viewdata_free_childitems_list(list);
- }
- _CHECK(ret)
- _WHEN_SUCCESS { }
- _CHECK_FAIL{/* ret */}
- _CHECK_FAIL{/*_add_icon_btns(m, list) != -1*/}
- _CHECK_FAIL{if(m->main_icon_base) eina_array_free(m->main_icon_base);}
- _CHECK_FAIL{if(m->main_item_btn) eina_array_free(m->main_item_btn);}
- _CHECK_FAIL{/* m->main_item_count */}
- _CHECK_FAIL{if(list) viewdata_free_childitems_list(list);}
- _CHECK_FAIL{if(m->mainitem_box) evas_object_del(m->mainitem_box);}
- } _CREATE_END_AND_CATCH { return; }
-}
-
-/**
-* Edje_Signal_Cb type callback for handling signal.
-*
-* @param[in]: data : the user data.
-* @param[in]: obj : the object signal occurred on.
-* @param[in]: emission : the signal name.
-* @param[in]: source : the source name.
-*
-* @return: void.
-*/
-void CMainCatalogView::sm_CbViewAniFinish(void *data, Evas_Object *obj, const char *emission, const char *source)
-{
- if(!data){ _ERR("Invalid Param"); return;}
- CMainCatalogView *root;
- root = (CMainCatalogView *) data;
- root->m_OnViewAniFinish(obj, emission, source);
-}
-
-
-void CMainCatalogView::m_OnViewAniFinish(Evas_Object *obj, const char *emission, const char *source)
-{
- m_DrawMainItems();
-}
-
-
-/**
-* This function moves focus from main item to subitem and
-* does corresponding operations.
-*
-* @param[in]: data : the user data.
-*
-* @return: void.
-*/
-void _move_focus_on_subitem(SMainCatalog *data)
-{
- const char *path, *id;
- unsigned int i;
- Evas_Object *icon, *subbtn, *pb;
- Eina_Array *subbtns;
- void* obj;
- Eina_Array_Iterator a;
- struct settingitem *item;
-
- if (!data)
- return;
-
- subbtns = data->sub_item_btn;
-
- path = (const char*) eina_array_data_get(data->item_path, 0);
-
- EINA_ARRAY_ITER_NEXT(subbtns, i, obj, a) {
- subbtn = (Evas_Object *) obj;
- item = (struct settingitem *) evas_object_data_get(subbtn, SUBITEM_DATA_ID);
- id = settingitem_get_id(item);
- if (!id)
- return;
-
- if (!strncmp(id, path, ARRAY_SIZE)) {
- icon = elm_object_part_content_get(
- data->focused_main_item_btn,
- MAINICONBTN_ICON_SWALLOW);
- if (icon)
- elm_object_signal_emit(icon,
- MAIN_BTN_HIGHLIGHT, MAIN_BTN);
-
- data->focus_status = FOCUS_SUB_ITEM;
- data->focused_sub_item_btn = subbtn;
-
- elm_object_focus_set(subbtn, EINA_TRUE);
- elm_object_signal_emit(data->focused_main_item_btn,
- MAINICONBTN_FOCUSED_ON_SUBITEM,
- MAINICONBTN_MAIN_ITEM_SOURCE);
-
- pb = (Evas_Object *) evas_object_data_get(subbtn, PROGRESS_BAR_DATA);
- if (pb)
- elm_object_signal_emit(pb,
- SIG_UNCTRL_PB_FOCUSED,
- SRC_PB_PROG);
- }
- }
-}
-
-/**
-* Change the language of names of buttons.
-*
-* @param[in]: list : eina list of item data.
-* @param[in]: btns : eina array containing buttons.
-* @param[in]: cnt : number of buttons.
-*
-* @return: void.
-*/
-static void _change_buttons_name(Eina_List *list,
- Eina_Array *btns, int cnt)
-{
- struct settingitem *item;
- Evas_Object *btn;
- const char *name;
- int i;
-
- if (!list || !btns || !cnt) {
- _ERR("Invalid argument");
- return;
- }
-
- for (i = 0; i < cnt; i++) {
- item = (struct settingitem *)eina_list_nth(list, i);
- btn = (Evas_Object *)eina_array_data_get(btns, i);
- if (!item || !btn)
- return;
-
- name = settingitem_get_display_name(item);
- if (name)
- elm_object_text_set(btn,
- utils_get_translation_str(name));
- }
-}
-
-
-Evas_Object* CMainCatalogView::Base(void)
-{
- ASSERT(m);
-
- return m->base;
-}
-
-
-/**
-* Create all UI components of settings view.
-*
-* @param[in]: mgr : the view manager of settings.
-* @param[in]: view : the view data.
-* @param[in]: prev : the user data.
-*
-* @return: the base layout of settings or null if error occurred.
-*/
-bool CMainCatalogView::Create(struct settingview_data *view, void *prev)
-{
- ASSERT(!m);
- ASSERT(view);
-
- _CREATE_BEGIN{
- _CHECK(m = new SMainCatalog)
- _CHECK(m->mgr = CSettingMgr::GetInstance())
- _CHECK(m->win = m->mgr->Window())
- _CHECK(m->base = elm_layout_add(m->win))
- _COMMAND {
- evas_object_size_hint_weight_set(m->base,
- EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_win_resize_object_add(m->win, m->base);
- }
- _WHEN_SUCCESS {
- elm_layout_file_set(m->base, EDJ_FILE, MAIN_VIEW_PAGE);
- m->main_setting_view = view;
- m->subsetting_view = NULL;
- m->item_path = m->mgr->GetItemPath();
- evas_object_data_set(m->base, DATA_ID, m);
- elm_object_signal_callback_add(m->base, MAIN_VIEW_ANIM_FINISH, MAIN_VIEW_SOURCE, sm_CbViewAniFinish, this);
-
- if (!m->item_path)
- elm_object_signal_emit(m->base, MAIN_VIEW_LOAD, "");
- else
- m_OnViewAniFinish(NULL, NULL, NULL);
- }
- _CHECK_FAIL{if(m->base) evas_object_del(m->base);}
- _CHECK_FAIL{/* m->win = m->mgr->Window() */}
- _CHECK_FAIL{/* m->mgr = CSettingMgr::GetInstance() */}
- _CHECK_FAIL{ delete m; m = NULL; }
- } _CREATE_END_AND_CATCH{ return false; }
-
- return true;
-}
-
-
-/**
-* Show the view of settings.
-*
-* @param[in]: base : the base layout of settings.
-*
-* @return: void.
-*/
-void CMainCatalogView::Show(void)
-{
- ASSERT(m);
-
- unsigned int cnt, i;
- const char *name, *path;
- Evas_Object *btn, *icon;
- void* obj;
- Eina_Array *btns;
- Eina_Array_Iterator a;
-
- path = NULL;
-
- if (m->item_path) {
- btns = m->main_item_btn;
-
- cnt = eina_array_count(m->item_path);
- if (cnt > 1) {
- path = (const char *) eina_array_data_get(m->item_path, cnt - 2);
- if (!path)
- return;
- }
-
- EINA_ARRAY_ITER_NEXT(btns, i, obj, a) {
- btn = (Evas_Object *) obj;
- name = (const char *) evas_object_data_get(btn, SETTING_ID);
- if (!name)
- return;
-
- if (!strncmp(name, path, ARRAY_SIZE)) {
- m_DrawSubItems(name);
-
- icon = (Evas_Object *)eina_array_data_get(
- m->main_icon_base, i);
- if (icon)
- elm_object_signal_emit(icon,
- MAIN_BTN_FOCUSED,
- MAIN_BTN);
-
- elm_object_focus_set(btn, EINA_TRUE);
-
- m->focus_status = FOCUS_MAIN_ITEM;
- m->focused_main_item_btn = btn;
-
- _move_focus_on_subitem(m);
- }
- }
- }
-
- evas_object_show(m->base);
-}
-
-/**
-* Hide the view of settings.
-*
-* @param[in]: base : the base layout of settings.
-*
-* @return: void.
-*/
-void CMainCatalogView::Hide(void)
-{
- ASSERT(m);
-
- evas_object_hide(m->base);
-}
-
-/**
-* Refresh the view of settings.
-*
-* @param[in]: base : the base layout of settings.
-*
-* @return: void.
-*/
-void CMainCatalogView::Refresh(void)
-{
- ASSERT(m);
-
- char *sld;
- const char *id;
- unsigned int i;
- struct settingitem *item;
- Eina_Array_Iterator a;
- Evas_Object *btn, *pb, *icon;
- void* obj;
-
- sld = (char *) evas_object_data_del(m->base, SELECTED_ITEM_ID);
- if (sld) {
- EINA_ARRAY_ITER_NEXT(m->sub_item_btn, i, obj, a) {
- btn = (Evas_Object *) obj;
- item = (struct settingitem *) evas_object_data_get(btn, SUBITEM_DATA_ID);
- id = settingitem_get_id(item);
- if (!id)
- continue;
-
- if (item && !strncmp(sld, id, strlen(sld))) {
- m->focused_sub_item_btn = btn;
- break;
- }
- }
- }
-
- if (m->focus_status == FOCUS_SUB_ITEM) {
- elm_object_focus_set(m->focused_sub_item_btn, EINA_TRUE);
-
- elm_object_signal_emit(m->focused_main_item_btn,
- MAINICONBTN_FOCUSED_ON_SUBITEM,
- MAINICONBTN_MAIN_ITEM_SOURCE);
-
- icon = elm_object_part_content_get(m->focused_main_item_btn,
- MAINICONBTN_ICON_SWALLOW);
- if (icon)
- elm_object_signal_emit(icon,
- MAIN_BTN_HIGHLIGHT, MAIN_BTN);
-
- if (_refresh_subitems(m) == -1)
- _ERR("Refresh subitems failed");
-
- pb = (Evas_Object *) evas_object_data_get(m->focused_sub_item_btn,
- PROGRESS_BAR_DATA);
- if (pb)
- elm_object_signal_emit(pb,
- SIG_UNCTRL_PB_FOCUSED, SRC_PB_PROG);
- }
-
- if (m->mgr->GetTimeoutFreezeState() == EINA_TRUE)
- m->mgr->ThawTimeout();
-}
-
-/**
-* Destroy the view of settings.
-*
-* @param[in]: base : the base layout of settings.
-*
-* @return: void.
-*/
-void CMainCatalogView::Destroy(void)
-{
- ASSERT(m);
-
- Eina_Array_Iterator a;
- Evas_Object *tmp;
- void* obj;
- unsigned int i;
-
- if (m->sub_item_btn) {
- EINA_ARRAY_ITER_NEXT(m->sub_item_btn, i, obj, a)
- {
- tmp = (Evas_Object *) obj;
- evas_object_del(tmp);
- }
- eina_array_free(m->sub_item_btn);
- }
-
- if (m->main_item_btn) {
- EINA_ARRAY_ITER_NEXT(m->main_item_btn, i, obj, a)
- {
- tmp = (Evas_Object *) obj;
- evas_object_del(tmp);
- }
- eina_array_free(m->main_item_btn);
- }
-
- if (m->main_icon_base) {
- EINA_ARRAY_ITER_NEXT(m->main_icon_base, i, obj, a)
- {
- tmp = (Evas_Object *) obj;
- evas_object_del(tmp);
- }
- eina_array_free(m->main_icon_base);
- }
-
- if (m->main_setting_view)
- viewdata_release(m->main_setting_view);
-
- if (m->subsetting_view)
- viewdata_release(m->subsetting_view);
-
- evas_object_del(m->base);
- delete m;
- m = NULL;
-}
-
-/**
-* Change the language of view of settings.
-*
-* @param[in]: base : the base layout of settings.
-*
-* @return: void.
-*/
-void CMainCatalogView::LangChanged(void)
-{
- ASSERT(m);
-
- Eina_List *l;
- int cnt;
-
- cnt = 0;
- l = viewdata_get_childitems_list(m->main_setting_view);
- if (l)
- cnt = eina_list_count(l);
-
- _change_buttons_name(l, m->main_item_btn, cnt);
-
- cnt = 0;
- l = viewdata_get_childitems_list(m->subsetting_view);
- if (l)
- cnt = eina_list_count(l);
-
- _change_buttons_name(l, m->sub_item_btn, cnt);
-}
-
-/**
-* Froze the view of settings.
-*
-* @param[in]: base : the base layout of settings.
-*
-* @return: void.
-*/
-void CMainCatalogView::Frozen(void)
-{
- ASSERT(m);
-
- evas_object_freeze_events_set(m->mainitem_box, EINA_TRUE);
- evas_object_freeze_events_set(m->subitem_box, EINA_TRUE);
-}
-
-/**
-* Activate the view of settings.
-*
-* @param[in]: base : the base layout of settings.
-*
-* @return: void.
-*/
-void CMainCatalogView::Active(void)
-{
- ASSERT(m);
-
- evas_object_freeze_events_set(m->mainitem_box, EINA_FALSE);
- evas_object_freeze_events_set(m->subitem_box, EINA_FALSE);
-}
-
-
-void CMainCatalogView::OnMouseClicked(int id, Evas_Object *obj)
-{
- _DBG();
- if (!obj) {
- _ERR("Invalid argument");
- return;
- }
-
- switch(id) {
- case MAIN_ITEM_BTNS:
- m_MoveFromMainitemToSubitem(obj);
- break;
- case SUB_ITEM_BTNS:
- {
- Evas_Object *icon;
- m_SubItemClicked(obj);
-
- elm_object_signal_emit(m->focused_main_item_btn, MAINICONBTN_FOCUSED_ON_SUBITEM, MAINICONBTN_MAIN_ITEM_SOURCE);
-
- icon = elm_object_part_content_get(m->focused_main_item_btn, MAINICONBTN_ICON_SWALLOW);
- if (icon)
- elm_object_signal_emit(icon, MAIN_BTN_HIGHLIGHT, MAIN_BTN);
- }
- break;
- default:
- break;
- }
-}
-
-
-void CMainCatalogView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev)
-{
- if (!ev->keyname) {
- _ERR("ev->keyname is NULL.");
- return;
- }
- switch(id) {
- case MAIN_ITEM_BTNS:
- {
- Evas_Object *next, *icon;
- const char *name;
-
- if (!strcmp(ev->keyname, KEY_UP)) {
- icon = elm_object_part_content_get(obj, MAINICONBTN_ICON_SWALLOW);
- if (!icon) {
- _ERR("part %s content get failed.", MAINICONBTN_ICON_SWALLOW);
- return;
- }
-
- elm_object_signal_emit(icon, MAIN_BTN_UNFOCUSED, MAIN_BTN);
-
- next = elm_object_focus_next_object_get(obj, ELM_FOCUS_UP);
- if (!next) {
- _ERR("next object get failed.");
- return;
- }
-
- m->focused_main_item_btn = next;
-
- icon = elm_object_part_content_get(next, MAINICONBTN_ICON_SWALLOW);
- if (!icon) {
- _ERR("part %s content get failed.", MAINICONBTN_ICON_SWALLOW);
- return;
- }
-
- elm_object_signal_emit(icon, MAIN_BTN_FOCUSED, MAIN_BTN);
-
- _release_subitems(m);
-
- name =(const char *) evas_object_data_get(next, SETTING_ID);
- if (name)
- m_DrawSubItems(name);
- }
- }
- break;
- default:
- break;
- }
-}
-
-
-void CMainCatalogView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
-{
- if (!ev->keyname) {
- _ERR("ev->keyname is NULL.");
- return;
- }
-
- switch(id) {
- case MAIN_ITEM_BTNS:
- {
- Evas_Object *next, *icon;
- const char *name;
-
- if (!strcmp(ev->keyname, KEY_DOWN)) {
- icon = elm_object_part_content_get(obj, MAINICONBTN_ICON_SWALLOW);
- if (!icon) {
- _ERR("part %s content get failed.", MAINICONBTN_ICON_SWALLOW);
- return;
- }
-
- elm_object_signal_emit(icon, MAIN_BTN_UNFOCUSED, MAIN_BTN);
-
- next = elm_object_focus_next_object_get(obj, ELM_FOCUS_DOWN);
- if (!next) {
- _ERR("next object get failed.");
- return;
- }
-
- m->focused_main_item_btn = next;
-
- icon = elm_object_part_content_get(next, MAINICONBTN_ICON_SWALLOW);
- if (!icon) {
- _ERR("part %s content get failed.", MAINICONBTN_ICON_SWALLOW);
- return;
- }
-
- elm_object_signal_emit(icon, MAIN_BTN_FOCUSED, MAIN_BTN);
-
- _release_subitems(m);
- name =(const char *) evas_object_data_get(next, SETTING_ID);
- if (name)
- m_DrawSubItems(name);
- } else if (!strcmp(ev->keyname, KEY_RIGHT)) {
- m_MoveFromMainitemToSubitem(obj);
- } else if (!strcmp(ev->keyname, KEY_EXIT) || !strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
- app_efl_exit();
- }
- }
- break;
-
- case SUB_ITEM_BTNS:
- {
- Evas_Object *pb;
- Evas_Object *next;
-
- if (!strcmp(ev->keyname, KEY_LEFT) || !strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
- pb = (Evas_Object *) evas_object_data_get(obj, PROGRESS_BAR_DATA);
- if (pb)
- elm_object_signal_emit(pb, SIG_UNCTRL_PB_UNFOCUSED, SRC_PB_PROG);
-
- m_MoveFromSubitemToMainitem(obj);
- } else if (!strncmp(ev->keyname, KEY_DOWN, strlen(ev->keyname))) {
- pb = (Evas_Object *)evas_object_data_get(obj, PROGRESS_BAR_DATA);
- if (pb)
- elm_object_signal_emit(pb, SIG_UNCTRL_PB_UNFOCUSED, SRC_PB_PROG);
-
- next = elm_object_focus_next_object_get(obj, ELM_FOCUS_DOWN);
- if (!next) {
- _ERR("focus next object get failed.");
- return;
- }
-
- pb = (Evas_Object *)evas_object_data_get(next, PROGRESS_BAR_DATA);
- if (pb)
- elm_object_signal_emit(pb, SIG_UNCTRL_PB_FOCUSED, SRC_PB_PROG);
- } else if (!strncmp(ev->keyname, KEY_UP, strlen(ev->keyname))) {
- pb = (Evas_Object *)evas_object_data_get(obj, PROGRESS_BAR_DATA);
- if (pb)
- elm_object_signal_emit(pb, SIG_UNCTRL_PB_UNFOCUSED, SRC_PB_PROG);
-
- next = elm_object_focus_next_object_get(obj, ELM_FOCUS_UP);
- if (!next) {
- _ERR("focus next object get failed.");
- return;
- }
-
- pb = (Evas_Object *)evas_object_data_get(next, PROGRESS_BAR_DATA);
- if (pb)
- elm_object_signal_emit(pb, SIG_UNCTRL_PB_FOCUSED, SRC_PB_PROG);
- } else if (!strncmp(ev->keyname, KEY_EXIT, strlen(ev->keyname))) {
- app_efl_exit();
- }
- }
- break;
- default:
- break;
- }
-}
-
-
-#if 0
-static struct setting_class _vclass = {
- VCLASS_TITLE_MAIN_VIEW,
- _create,
- _show,
- NULL,
- NULL,
- _refresh,
- NULL,
- _hide,
- _destroy,
- _lang_changed,
- _frozen,
- _active,
- 0
-};
-
-/**
-* Return view class of settings view.
-*
-* @param: void.
-*
-* @return: the view class of settings view.
-*/
-struct setting_class *view_maincatalog_get_vclass(void)
-{
- return &_vclass;
-}
-#endif
diff --git a/src/view_need_pwd.cpp b/src/view_need_pwd.c
index dfa6fca..b1357ac 100644
--- a/src/view_need_pwd.cpp
+++ b/src/view_need_pwd.c
@@ -14,8 +14,10 @@
* limitations under the License.
*/
-#include <AppCommon.h>
-#include "common_defs.h"
+#include <KeyDefine.h>
+
+#include "dbg.h"
+#include "def.h"
#include "utils.h"
#include "settings_provider.h"
#include "view_need_pwd.h"
@@ -50,7 +52,7 @@ enum {
PWD_ENTRY_MAX
};
-struct SNeedPasscodeView {
+struct _chnllock_data {
Evas_Object *win;
Evas_Object *bg;
Evas_Object *base;
@@ -62,13 +64,13 @@ struct SNeedPasscodeView {
char passcode[BUF_SIZE];
- CSettingMgr *mgr;
+ struct setting_mgr *mgr;
struct settingview_data *view;
struct obj_geometry_data gd;
};
-static void _free_priv_data(SNeedPasscodeView *data);
-//static void _hide(Evas_Object *base);
+static void _free_priv_data(struct _chnllock_data *data);
+static void _hide(Evas_Object *base);
/**
* Free user data.
@@ -77,7 +79,7 @@ static void _free_priv_data(SNeedPasscodeView *data);
*
* @return: void.
*/
-static void _free_priv_data(SNeedPasscodeView *data)
+static void _free_priv_data(struct _chnllock_data *data)
{
if (!data)
return;
@@ -94,6 +96,7 @@ static void _free_priv_data(SNeedPasscodeView *data)
if (data->array)
eina_array_free(data->array);
+ free(data);
}
/**
@@ -165,14 +168,14 @@ static Evas_Object *_add_view_base(Evas_Object *ctxpopup)
static void _cancel_btn_clicked_cb(void *priv, Evas_Object *obj,
void *ev)
{
- SNeedPasscodeView *data;
+ struct _chnllock_data *data;
if (!priv || !obj)
return;
- data = (SNeedPasscodeView *) priv;
+ data = priv;
- data->mgr->ViewPop();
+ settingmgr_view_pop(data->mgr);
}
/**
@@ -182,14 +185,15 @@ static void _cancel_btn_clicked_cb(void *priv, Evas_Object *obj,
*
* @return: the created cancel button or null if error occurred.
*/
-static Evas_Object *_add_view_cancel_btn(SNeedPasscodeView *data)
+static Evas_Object *_add_view_cancel_btn(struct _chnllock_data *data)
{
Evas_Object *btn;
if (!data || !data->base)
return NULL;
- btn = utils_add_btn(data->base, PWD_BASIC_BTN, MSGID_CANCEL, EINA_TRUE);
+ btn = utils_add_btn(data->base, PWD_BASIC_BTN,
+ utils_get_translation_str(MSGID_CANCEL), EINA_TRUE);
if (!btn) {
_ERR("utils add button failed.");
return NULL;
@@ -209,7 +213,7 @@ static Evas_Object *_add_view_cancel_btn(SNeedPasscodeView *data)
*
* @return: 0 - wrong passcode, 1 - right passcode.
*/
-static int _check_passcode(SNeedPasscodeView *data)
+static int _check_passcode(struct _chnllock_data *data)
{
char *passcode;
@@ -236,7 +240,7 @@ static int _check_passcode(SNeedPasscodeView *data)
*
* @return: void.
*/
-static void _push_next_view(SNeedPasscodeView *data)
+static void _push_next_view(struct _chnllock_data *data)
{
struct settingitem *item;
Eina_List *list;
@@ -249,7 +253,7 @@ static void _push_next_view(SNeedPasscodeView *data)
if (!list)
return;
- item = (struct settingitem *) eina_list_nth(list, 0);
+ item = eina_list_nth(list, 0);
if (!item)
return;
@@ -257,7 +261,7 @@ static void _push_next_view(SNeedPasscodeView *data)
if (!id)
return;
- data->mgr->ViewPush(id, &data->gd);
+ settingmgr_view_push(data->mgr, id, &data->gd);
}
/**
@@ -270,30 +274,27 @@ static void _push_next_view(SNeedPasscodeView *data)
*
* @return: void.
*/
-void CNeedPasscodeView::sm_CbKeyDown(void *priv, Evas *e, Evas_Object *obj, void *ei)
-{
- CNeedPasscodeView *root = (CNeedPasscodeView*)priv;
- if (root)
- root->m_OnKeyDown(e, obj, (Evas_Event_Key_Down*)ei);
-}
-
-
-void CNeedPasscodeView::m_OnKeyDown(Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
+static void _key_down_cb(void *priv, Evas *e, Evas_Object *obj,
+ void *ei)
{
+ Evas_Event_Key_Down *event;
Eina_Array *array;
Evas_Object *entry, *next_entry;
+ struct _chnllock_data *data;
const char *keyname;
char *text;
int btn_num, i;
- if (!obj)
+ if (!priv || !ei || !obj)
return;
- array = m->array;
+ data = priv;
+ array = data->array;
if (!array)
return;
- keyname = ev->keyname;
+ event = ei;
+ keyname = event->keyname;
if (!keyname)
return;
@@ -308,10 +309,10 @@ void CNeedPasscodeView::m_OnKeyDown(Evas *e, Evas_Object *obj, Evas_Event_Key_Do
if (btn_num == -1)
return;
- if (!strncmp(keyname, KEY_BACK, strlen(keyname)) || !strncmp(keyname, KEY_BACK_REMOTE, strlen(keyname))) {
- m->mgr->ViewPop();
+ if (!strncmp(keyname, KEY_BACK, strlen(keyname))) {
+ settingmgr_view_pop(data->mgr);
} else if (!strncmp(keyname, KEY_DOWN, strlen(keyname))) {
- elm_object_focus_set(m->cancel_btn, EINA_TRUE);
+ elm_object_focus_set(data->cancel_btn, EINA_TRUE);
} else if (!strncmp(keyname, KEY_0, strlen(keyname)) ||
!strncmp(keyname, KEY_1, strlen(keyname)) ||
!strncmp(keyname, KEY_2, strlen(keyname)) ||
@@ -323,7 +324,7 @@ void CNeedPasscodeView::m_OnKeyDown(Evas *e, Evas_Object *obj, Evas_Event_Key_Do
!strncmp(keyname, KEY_8, strlen(keyname)) ||
!strncmp(keyname, KEY_9, strlen(keyname))) {
elm_entry_entry_set(obj, PWD_SYMBOL);
- m->passcode[btn_num] = keyname[0];
+ data->passcode[btn_num] = keyname[0];
if (btn_num < PWD_ENTRY_3) {
elm_object_focus_next(obj, ELM_FOCUS_NEXT);
@@ -332,26 +333,26 @@ void CNeedPasscodeView::m_OnKeyDown(Evas *e, Evas_Object *obj, Evas_Event_Key_Do
if (!next_entry)
return;
- elm_object_focus_next_object_set(m->cancel_btn,
+ elm_object_focus_next_object_set(data->cancel_btn,
next_entry, ELM_FOCUS_UP);
} else {
- if (_check_passcode(m)) {
- Hide();
- _push_next_view(m);
+ if (_check_passcode(data)) {
+ _hide(data->base);
+ _push_next_view(data);
} else {
text = utils_get_translation_str(
MSGID_WRONG_PWD);
- elm_object_part_text_set(m->base,
+ elm_object_part_text_set(data->base,
PART_UPTEXT, text);
- entry = (Evas_Object *) eina_array_data_get(array, PWD_ENTRY_0);
+ entry = eina_array_data_get(array, PWD_ENTRY_0);
if (!entry)
return;
elm_object_focus_set(entry, EINA_TRUE);
for (i = PWD_ENTRY_0; i < PWD_ENTRY_MAX; i++) {
- entry = (Evas_Object *)eina_array_data_get(array, i);
+ entry = eina_array_data_get(array, i);
if (!entry)
return;
@@ -381,19 +382,19 @@ static void _set_entry_directions(Eina_Array *array,
return;
for (idx = PWD_ENTRY_0; idx < PWD_ENTRY_3; idx++) {
- entry = (Evas_Object *)eina_array_data_get(array, idx);
+ entry = eina_array_data_get(array, idx);
if (!entry)
return;
elm_object_focus_next_object_set(entry,
- (Evas_Object *)eina_array_data_get(array, idx + 1),
+ eina_array_data_get(array, idx + 1),
ELM_FOCUS_NEXT);
elm_object_focus_next_object_set(entry,
cancel_btn, ELM_FOCUS_DOWN);
}
elm_object_focus_next_object_set(cancel_btn,
- (Evas_Object *)eina_array_data_get(array, PWD_ENTRY_0),
+ eina_array_data_get(array, PWD_ENTRY_0),
ELM_FOCUS_UP);
}
@@ -408,10 +409,10 @@ static Evas_Object *_add_entry(Evas_Object *parent)
{
Evas_Object *entry;
Elm_Entry_Filter_Limit_Size length = {
- 1
+ .max_char_count = 1
};
Elm_Entry_Filter_Accept_Set type = {
- PWD_RANGE
+ .accepted = PWD_RANGE
};
if (!parent)
@@ -443,14 +444,19 @@ static Evas_Object *_add_entry(Evas_Object *parent)
*
* @return: 0 - Success, -1 - Fail.
*/
-int CNeedPasscodeView::m_AddViewEntries(void)
+static int _add_view_entries(struct _chnllock_data *data)
{
Eina_Array *array;
Evas_Object *box;
Evas_Object *entry, *base;
int idx;
- box = utils_add_box(m->base);
+ if (!data || !data->base) {
+ _ERR("invalid arguments.");
+ return -1;
+ }
+
+ box = utils_add_box(data->base);
if (!box)
return -1;
@@ -464,7 +470,7 @@ int CNeedPasscodeView::m_AddViewEntries(void)
}
for (idx = PWD_ENTRY_0; idx < PWD_ENTRY_MAX; idx++) {
- base = utils_add_base(m->base);
+ base = utils_add_base(data->base);
if (!base) {
_ERR("utils add base failed.");
evas_object_del(box);
@@ -487,20 +493,20 @@ int CNeedPasscodeView::m_AddViewEntries(void)
elm_box_pack_end(box, base);
evas_object_event_callback_add(entry, EVAS_CALLBACK_KEY_DOWN,
- sm_CbKeyDown, this);
+ _key_down_cb, data);
}
- elm_object_focus_allow_set((Evas_Object*) eina_array_data_get(array, PWD_ENTRY_0),
+ elm_object_focus_allow_set(eina_array_data_get(array, PWD_ENTRY_0),
EINA_TRUE);
- elm_object_focus_set((Evas_Object *)eina_array_data_get(array, PWD_ENTRY_0),
+ elm_object_focus_set(eina_array_data_get(array, PWD_ENTRY_0),
EINA_TRUE);
- elm_object_part_content_set(m->base, SWALLOW_CONTENT_AREA, box);
+ elm_object_part_content_set(data->base, SWALLOW_CONTENT_AREA, box);
- _set_entry_directions(array, m->cancel_btn);
+ _set_entry_directions(array, data->cancel_btn);
- m->array = array;
- m->box = box;
+ data->array = array;
+ data->box = box;
return 0;
}
@@ -514,34 +520,23 @@ int CNeedPasscodeView::m_AddViewEntries(void)
*
* @return: void.
*/
-void CNeedPasscodeView::sm_CbCtxpopupDismissed(void *priv, Evas_Object *obj, void *ev)
+static void _ctxpopup_dismissed(void *priv, Evas_Object *obj,
+ void *ev)
{
- CNeedPasscodeView *root = (CNeedPasscodeView*)priv;
- if (root)
- root->m_OnCtxpopupDismissed(obj, ev);
-}
+ struct _chnllock_data *data;
-
-void CNeedPasscodeView::m_OnCtxpopupDismissed(Evas_Object *obj, void *ev)
-{
- if (!obj)
+ if (!priv || !obj)
return;
- Hide();
-
- m->mgr->ViewPop();
-}
-
-
+ data = priv;
+ if (!data->base || !data->mgr)
+ return;
-Evas_Object* CNeedPasscodeView::Base(void)
-{
- ASSERT(m);
+ _hide(data->base);
- return m->base;
+ settingmgr_view_pop(data->mgr);
}
-
/**
* Create all the UI components of channel lock view.
*
@@ -552,33 +547,37 @@ Evas_Object* CNeedPasscodeView::Base(void)
* @return: the base layout of channel lock view or null
* if error occurred.
*/
-bool CNeedPasscodeView::Create(struct settingview_data *view, void *prev)
+static Evas_Object *_create(struct setting_mgr *mgr,
+ struct settingview_data *view, void *prev)
{
- ASSERT(!m);
- ASSERT(view);
- ASSERT(prev);
-
- CSettingMgr *mgr = CSettingMgr::GetInstance();
-
Evas_Object *win, *base, *bg;
Evas_Object *ctxpopup;
Evas_Object *cancel_btn;
- int ret, width, height, xpos, ypos;
+ struct _chnllock_data *data;
+ int ret, xpos, ypos;
struct obj_geometry_data *tmp;
- win = mgr->Window();
- ASSERT(win);
+ if (!mgr || !view || !prev) {
+ _ERR("invalid argument.");
+ return NULL;
+ }
+
+ win = settingmgr_get_win(mgr);
+ if (!win) {
+ _ERR("settings manager get window failed.");
+ return NULL;
+ }
- m = new SNeedPasscodeView;
- if (!m) {
+ data = calloc(1, sizeof(*data));
+ if (!data) {
_ERR("calloc memory for _priv_data failed.");
- return false;
+ return NULL;
}
- tmp = (struct obj_geometry_data *) prev;
+ tmp = prev;
- m->win = win;
- m->gd = *tmp;
+ data->win = win;
+ data->gd = *tmp;
bg = _add_view_bg(win);
if (!bg) {
@@ -586,61 +585,56 @@ bool CNeedPasscodeView::Create(struct settingview_data *view, void *prev)
goto error;
}
- m->bg = bg;
+ data->bg = bg;
- ctxpopup = utils_add_ctxpopup(win, (char *)CHANGE_PWD_CTXPOPUP_STYLE);
+ ctxpopup = utils_add_ctxpopup(win, CHANGE_PWD_CTXPOPUP_STYLE);
if (!ctxpopup) {
_ERR("add ctxpopup failed.");
goto error;
}
- m->ctxpopup = ctxpopup;
+ data->ctxpopup = ctxpopup;
- base = _add_view_base(m->ctxpopup);
+ base = _add_view_base(data->ctxpopup);
if (!base) {
_ERR("add view base failed.");
goto error;
}
- m->base = base;
+ data->base = base;
elm_object_content_set(ctxpopup, base);
- width = WIN_WIDTH;
- height = WIN_HEIGHT;
-
- xpos = (width - CTXPOPUP_WIDTH) / 2;
- ypos = (height - CTXPOPUP_HEIGHT) / 2;
- evas_object_move(m->ctxpopup, xpos * ELM_SCALE,
+ xpos = (WIN_WIDTH - CTXPOPUP_WIDTH) / 2;
+ ypos = (WIN_HEIGHT - CTXPOPUP_HEIGHT) / 2;
+ evas_object_move(data->ctxpopup, xpos * ELM_SCALE,
ypos * ELM_SCALE);
- evas_object_smart_callback_add(m->ctxpopup,
- SIG_DISMISSED, sm_CbCtxpopupDismissed, this);
+ evas_object_smart_callback_add(data->ctxpopup,
+ SIG_DISMISSED, _ctxpopup_dismissed, data);
- cancel_btn = _add_view_cancel_btn(m);
+ cancel_btn = _add_view_cancel_btn(data);
if (!cancel_btn) {
_ERR("add cancel button faield.");
goto error;
}
- m->cancel_btn = cancel_btn;
+ data->cancel_btn = cancel_btn;
- ret = m_AddViewEntries();
+ ret = _add_view_entries(data);
if (ret != 0)
goto error;
- m->mgr = mgr;
- m->view = view;
+ data->mgr = mgr;
+ data->view = view;
- evas_object_data_set(base, CHNLLOCK_DATA_ID, m);
+ evas_object_data_set(base, CHNLLOCK_DATA_ID, data);
- return true;
+ return base;
error:
- _free_priv_data(m);
- delete m;
- m = NULL;
- return false;
+ _free_priv_data(data);
+ return NULL;
}
/**
@@ -650,13 +644,22 @@ error:
*
* @return: void.
*/
-void CNeedPasscodeView::Show(void)
+static void _show(Evas_Object *base)
{
- ASSERT(m);
+ struct _chnllock_data *data;
+
+ if (!base)
+ return;
- evas_object_show(m->ctxpopup);
- evas_object_show(m->bg);
- evas_object_show(m->base);
+ data = evas_object_data_get(base, CHNLLOCK_DATA_ID);
+ if (!data) {
+ _ERR("get data from base failed. ID: %s.", CHNLLOCK_DATA_ID);
+ return;
+ }
+
+ evas_object_show(data->ctxpopup);
+ evas_object_show(data->bg);
+ evas_object_show(data->base);
}
/**
@@ -666,13 +669,20 @@ void CNeedPasscodeView::Show(void)
*
* @return: void.
*/
-void CNeedPasscodeView::Destroy(void)
+static void _destroy(Evas_Object *base)
{
- ASSERT(m);
+ struct _chnllock_data *data;
+
+ if (!base)
+ return;
+
+ data = evas_object_data_get(base, CHNLLOCK_DATA_ID);
+ if (!data) {
+ _ERR("get data from base failed. ID: %s.", CHNLLOCK_DATA_ID);
+ return;
+ }
- _free_priv_data(m);
- delete m;
- m = NULL;
+ _free_priv_data(data);
}
/**
@@ -682,13 +692,20 @@ void CNeedPasscodeView::Destroy(void)
*
* @return: void.
*/
-void CNeedPasscodeView::Hide(void)
+static void _hide(Evas_Object *base)
{
- ASSERT(m);
+ struct _chnllock_data *data;
+
+ if (!base)
+ return;
+
+ data = evas_object_data_get(base, CHNLLOCK_DATA_ID);
+ if (!data)
+ return;
- evas_object_hide(m->base);
- evas_object_hide(m->ctxpopup);
- evas_object_hide(m->bg);
+ evas_object_hide(data->base);
+ evas_object_hide(data->ctxpopup);
+ evas_object_hide(data->bg);
}
/**
@@ -698,32 +715,30 @@ void CNeedPasscodeView::Hide(void)
*
* @return: void.
*/
-void CNeedPasscodeView::Refresh(void)
+static void _refresh(Evas_Object *base)
{
- ASSERT(m);
+ struct _chnllock_data *data;
- m->mgr->ViewPop();
-}
+ if (!base)
+ return;
+
+ data = evas_object_data_get(base, CHNLLOCK_DATA_ID);
+ if (!data)
+ return;
+ settingmgr_view_pop(data->mgr);
+}
-#if 0
/**
* view class of channel lock view.
*/
struct setting_class _vclass = {
- VCLASS_TITLE_NEED_PASSCODE,
- _create,
- _show,
- NULL,
- NULL,
- _refresh,
- NULL,
- _hide,
- _destroy,
- NULL,
- NULL,
- NULL,
- 0
+ .title = VCLASS_TITLE_NEED_PASSCODE,
+ .create = _create,
+ .show = _show,
+ .destroy = _destroy,
+ .hide = _hide,
+ .refresh = _refresh
};
/**
@@ -737,4 +752,3 @@ struct setting_class *view_need_passcode_get_vclass(void)
{
return &_vclass;
}
-#endif
diff --git a/src/view_pwd_popup.cpp b/src/view_pwd_popup.c
index 1ba5d15..8035306 100644
--- a/src/view_pwd_popup.cpp
+++ b/src/view_pwd_popup.c
@@ -14,12 +14,13 @@
* limitations under the License.
*/
-#include <AppCommon.h>
-#include "common_defs.h"
+#include <KeyDefine.h>
+
+#include "dbg.h"
+#include "def.h"
#include "view_pwd_popup.h"
#include "utils.h"
#include "settings_provider.h"
-#include "settingviewmgr.h"
#define PWD_DATA_ID "change_passcode_data"
#define CTXPOPUP_WIDTH 688
@@ -51,7 +52,7 @@ enum {
ENTRY_MAX
};
-struct SPasscodePopupView {
+struct _pwd_data {
Evas_Object *win;
Evas_Object *bg;
Evas_Object *base;
@@ -69,11 +70,11 @@ struct SPasscodePopupView {
int renew_flag;
int wrong_flag;
- CSettingMgr *mgr;
+ struct setting_mgr *mgr;
struct settingview_data *view;
};
-//static void _hide(Evas_Object *base);
+static void _hide(Evas_Object *base);
/**
* Free user data.
@@ -82,7 +83,7 @@ struct SPasscodePopupView {
*
* @return: void.
*/
-static void _free_pwd_data(SPasscodePopupView *data)
+static void _free_pwd_data(struct _pwd_data *data)
{
if (!data)
return;
@@ -98,6 +99,8 @@ static void _free_pwd_data(SPasscodePopupView *data)
if (data->array)
eina_array_free(data->array);
+
+ free(data);
}
/**
@@ -168,14 +171,14 @@ static Evas_Object *_add_pwd_base(Evas_Object *ctxpopup)
*/
static void _cancelbtn_clicked_cb(void *priv, Evas_Object *obj, void *ev)
{
- SPasscodePopupView *data;
+ struct _pwd_data *data;
if (!priv || !obj)
return;
- data = (SPasscodePopupView *) priv;
+ data = priv;
- data->mgr->ViewPop();
+ settingmgr_view_pop(data->mgr);
}
/**
@@ -185,14 +188,15 @@ static void _cancelbtn_clicked_cb(void *priv, Evas_Object *obj, void *ev)
*
* @return: the created cancel button or null if error occurred.
*/
-static Evas_Object *_add_pwd_cancel_btn(SPasscodePopupView *data)
+static Evas_Object *_add_pwd_cancel_btn(struct _pwd_data *data)
{
Evas_Object *btn;
if (!data || !data->base)
return NULL;
- btn = utils_add_btn(data->base, PWD_BASIC_BTN, MSGID_CANCEL, EINA_TRUE);
+ btn = utils_add_btn(data->base, PWD_BASIC_BTN,
+ utils_get_translation_str(MSGID_CANCEL), EINA_TRUE);
if (!btn) {
_ERR("utils add button failed.");
return NULL;
@@ -226,12 +230,12 @@ static void _set_entry_directions(Eina_Array *array, Evas_Object *cancel_btn)
return;
for (i = ENTRY_0; i < ENTRY_3; i++) {
- en = (Evas_Object *) eina_array_data_get(array, i);
+ en = eina_array_data_get(array, i);
if (!en)
return;
elm_object_focus_next_object_set(en,
- (Evas_Object *) eina_array_data_get(array, i + 1),
+ eina_array_data_get(array, i + 1),
ELM_FOCUS_NEXT);
elm_object_focus_next_object_set(en, en, ELM_FOCUS_LEFT);
elm_object_focus_next_object_set(en, en, ELM_FOCUS_RIGHT);
@@ -240,7 +244,7 @@ static void _set_entry_directions(Eina_Array *array, Evas_Object *cancel_btn)
ELM_FOCUS_DOWN);
}
- lasten = (Evas_Object *) eina_array_data_get(array, ENTRY_3);
+ lasten = eina_array_data_get(array, ENTRY_3);
elm_object_focus_next_object_set(lasten, lasten, ELM_FOCUS_UP);
elm_object_focus_next_object_set(lasten, cancel_btn, ELM_FOCUS_DOWN);
elm_object_focus_next_object_set(lasten, lasten, ELM_FOCUS_LEFT);
@@ -251,7 +255,7 @@ static void _set_entry_directions(Eina_Array *array, Evas_Object *cancel_btn)
elm_object_focus_next_object_set(cancel_btn, cancel_btn,
ELM_FOCUS_RIGHT);
elm_object_focus_next_object_set(cancel_btn,
- (Evas_Object *) eina_array_data_get(array, ENTRY_0), ELM_FOCUS_UP);
+ eina_array_data_get(array, ENTRY_0), ELM_FOCUS_UP);
elm_object_focus_next_object_set(cancel_btn, cancel_btn,
ELM_FOCUS_DOWN);
}
@@ -286,7 +290,7 @@ static char *_get_pwd(struct settingview_data *vdata)
*
* @return: 0 - wrong passcode, 1 - right passcode.
*/
-static int _check_pwd(SPasscodePopupView *data)
+static int _check_pwd(struct _pwd_data *data)
{
char *pwd;
@@ -340,7 +344,7 @@ static void _clear_pwd(char *pwd)
*
* @return: void.
*/
-static void _reset_pwd(SPasscodePopupView *data)
+static void _reset_pwd(struct _pwd_data *data)
{
Evas_Object *btn, *first;
Eina_Array *array;
@@ -351,7 +355,7 @@ static void _reset_pwd(SPasscodePopupView *data)
array = data->array;
- first = (Evas_Object *) eina_array_data_get(array, ENTRY_0);
+ first = eina_array_data_get(array, ENTRY_0);
if (!first)
return;
@@ -359,7 +363,7 @@ static void _reset_pwd(SPasscodePopupView *data)
elm_object_focus_next_object_set(data->cancel_btn, first, ELM_FOCUS_UP);
for (i = ENTRY_0; i < ENTRY_MAX; i++) {
- btn = (Evas_Object *)eina_array_data_get(array, i);
+ btn = eina_array_data_get(array, i);
if (!btn)
return;
@@ -374,7 +378,7 @@ static void _reset_pwd(SPasscodePopupView *data)
*
* @return: 0 - Success, -1 - Fail.
*/
-static int _set_pwd(SPasscodePopupView *data)
+static int _set_pwd(struct _pwd_data *data)
{
int ret;
struct settingitem *item;
@@ -404,7 +408,7 @@ static int _set_pwd(SPasscodePopupView *data)
*
* @return: 0 - Success, -1 - Fail.
*/
-static int _check_reentered_pwd(SPasscodePopupView *data)
+static int _check_reentered_pwd(struct _pwd_data *data)
{
if (!data)
return 0;
@@ -425,7 +429,7 @@ static int _check_reentered_pwd(SPasscodePopupView *data)
*
* @return: void.
*/
-static void _update_pwd_ui(SPasscodePopupView *data,
+static void _update_pwd_ui(struct _pwd_data *data,
const char *part, const char *msgid)
{
char *text;
@@ -455,19 +459,19 @@ static void _entry_keypress_cb(void *priv, Evas *e,
Evas_Event_Key_Down *event;
Eina_Array *array;
Evas_Object *next_entry;
- SPasscodePopupView *data;
+ struct _pwd_data *data;
const char *keyname;
int entry_idx, i;
if (!priv || !ei || !obj)
return;
- data = (SPasscodePopupView *) priv;
+ data = priv;
array = data->array;
if (!array)
return;
- event = (Evas_Event_Key_Down *) ei;
+ event = ei;
keyname = event->keyname;
if (!keyname)
return;
@@ -480,8 +484,8 @@ static void _entry_keypress_cb(void *priv, Evas *e,
}
}
- if (!strncmp(keyname, KEY_BACK, strlen(keyname)) || !strncmp(keyname, KEY_BACK_REMOTE, strlen(keyname))) {
- data->mgr->ViewPop();
+ if (!strncmp(keyname, KEY_BACK, strlen(keyname))) {
+ settingmgr_view_pop(data->mgr);
} else if (!strncmp(keyname, KEY_DOWN, strlen(keyname))) {
elm_object_focus_set(data->cancel_btn, EINA_TRUE);
} else if (!strncmp(keyname, KEY_0, strlen(keyname)) ||
@@ -541,7 +545,7 @@ static void _entry_keypress_cb(void *priv, Evas *e,
data->new_flag = 0;
data->renew_flag = 0;
- data->mgr->ViewPop();
+ settingmgr_view_pop(data->mgr);
} else {
_update_pwd_ui(data, PART_UPTEXT,
MSGID_DIFFER_PWD);
@@ -565,10 +569,10 @@ static Evas_Object *_add_entry(Evas_Object *parent)
{
Evas_Object *entry;
Elm_Entry_Filter_Limit_Size length = {
- 1
+ .max_char_count = 1
};
Elm_Entry_Filter_Accept_Set type = {
- PWD_RANGE
+ .accepted = PWD_RANGE
};
if (!parent)
@@ -600,7 +604,7 @@ static Evas_Object *_add_entry(Evas_Object *parent)
*
* @return: 0 - Success, -1 - Fail.
*/
-static int _add_pwd_entry(SPasscodePopupView *data)
+static int _add_pwd_entry(struct _pwd_data *data)
{
Eina_Array *array;
Evas_Object *box;
@@ -659,9 +663,9 @@ static int _add_pwd_entry(SPasscodePopupView *data)
elm_object_part_content_set(data->base, SWALLOW_CONTENT_AREA, box);
elm_object_focus_allow_set(
- (Evas_Object *) eina_array_data_get(array, ENTRY_0), EINA_TRUE);
+ eina_array_data_get(array, ENTRY_0), EINA_TRUE);
elm_object_focus_set(
- (Evas_Object *)eina_array_data_get(array, ENTRY_0), EINA_TRUE);
+ eina_array_data_get(array, ENTRY_0), EINA_TRUE);
_set_entry_directions(array, data->cancel_btn);
@@ -680,37 +684,24 @@ static int _add_pwd_entry(SPasscodePopupView *data)
*
* @return: void.
*/
-void CPasscodePopupView::sm_CbCtxpopupDismissed(void *priv, Evas_Object *obj, void *ev)
-{
- CPasscodePopupView *root = (CPasscodePopupView*)priv;
- if (root)
- root->m_OnCtxpopupDismissed(obj, ev);
-}
-
-
-void CPasscodePopupView::m_OnCtxpopupDismissed(Evas_Object *obj, void *ev)
+static void _ctxpopup_dismissed(void *priv, Evas_Object *obj,
+ void *ev)
{
- if (!obj)
- return;
+ struct _pwd_data *data;
- if (!m->base || !m->mgr)
+ if (!priv || !obj)
return;
- Hide();
-
- m->mgr->ViewPop();
-}
-
+ data = priv;
+ if (!data->base || !data->mgr)
+ return;
-Evas_Object* CPasscodePopupView::Base(void)
-{
- ASSERT(m);
+ _hide(data->base);
- return m->base;
+ settingmgr_view_pop(data->mgr);
}
-
/**
* Create all the UI components of change passcode view.
*
@@ -721,34 +712,37 @@ Evas_Object* CPasscodePopupView::Base(void)
* @return: the base layout of change passcode view or null
* if error occurred.
*/
-bool CPasscodePopupView::Create(struct settingview_data *view, void *prev)
+static Evas_Object *_create(struct setting_mgr *mgr,
+ struct settingview_data *view, void *prev)
{
- ASSERT(!m);
- ASSERT(view);
-
- CSettingMgr *mgr = CSettingMgr::GetInstance();
- ASSERT(mgr);
-
Evas_Object *base, *bg;
Evas_Object *win;
Evas_Object *cancel_btn;
Evas_Object *ctxpopup;
+ struct _pwd_data *data;
int ret;
- int width, height;
int xpos, ypos;
- win = mgr->Window();
- ASSERT(win);
+ if (!mgr || !view) {
+ _ERR("invalid argument.");
+ return NULL;
+ }
+
+ win = settingmgr_get_win(mgr);
+ if (!win) {
+ _ERR("settingmgr get window failed.");
+ return NULL;
+ }
- m = new SPasscodePopupView;
- if (!m) {
+ data = calloc(1, sizeof(*data));
+ if (!data) {
_ERR("calloc _change_passcode_data failed.");
- return false;
+ return NULL;
}
- m->win = win;
+ data->win = win;
- _clear_pwd(m->pwd);
+ _clear_pwd(data->pwd);
bg = _add_pwd_bg(win);
if (!bg) {
@@ -756,61 +750,56 @@ bool CPasscodePopupView::Create(struct settingview_data *view, void *prev)
goto error;
}
- ctxpopup = utils_add_ctxpopup(win, (char *) CHANGE_PWD_CTXPOPUP_STYLE);
+ ctxpopup = utils_add_ctxpopup(win, CHANGE_PWD_CTXPOPUP_STYLE);
if (!ctxpopup) {
_ERR("add ctxpopup failed.");
goto error;
}
- m->ctxpopup = ctxpopup;
+ data->ctxpopup = ctxpopup;
- base = _add_pwd_base(m->ctxpopup);
+ base = _add_pwd_base(data->ctxpopup);
if (!base) {
_ERR("add change passcode base layout failed.");
goto error;
}
- m->base = base;
+ data->base = base;
elm_object_content_set(ctxpopup, base);
- width = WIN_WIDTH;
- height = WIN_HEIGHT;
-
- xpos = (width - CTXPOPUP_WIDTH) / 2;
- ypos = (height - CTXPOPUP_HEIGHT) / 2;
- evas_object_move(m->ctxpopup, xpos * ELM_SCALE, ypos * ELM_SCALE);
+ xpos = (WIN_WIDTH - CTXPOPUP_WIDTH) / 2;
+ ypos = (WIN_HEIGHT - CTXPOPUP_HEIGHT) / 2;
+ evas_object_move(data->ctxpopup, xpos * ELM_SCALE, ypos * ELM_SCALE);
- cancel_btn = _add_pwd_cancel_btn(m);
+ cancel_btn = _add_pwd_cancel_btn(data);
if (!cancel_btn) {
_ERR("add change passcode cancel button failed.");
goto error;
}
- m->cancel_btn = cancel_btn;
+ data->cancel_btn = cancel_btn;
- ret = _add_pwd_entry(m);
+ ret = _add_pwd_entry(data);
if (ret != 0) {
_ERR("add change passcode input buttons failed.");
goto error;
}
- m->mgr = mgr;
- m->bg = bg;
- m->view = view;
+ data->mgr = mgr;
+ data->bg = bg;
+ data->view = view;
- evas_object_smart_callback_add(m->ctxpopup,
- SIG_DISMISSED, sm_CbCtxpopupDismissed, this);
+ evas_object_smart_callback_add(data->ctxpopup,
+ SIG_DISMISSED, _ctxpopup_dismissed, data);
- evas_object_data_set(base, PWD_DATA_ID, m);
+ evas_object_data_set(base, PWD_DATA_ID, data);
- return true;
+ return base;
error:
- _free_pwd_data(m);
- delete m;
- m = NULL;
- return false;
+ _free_pwd_data(data);
+ return NULL;
}
/**
@@ -820,11 +809,20 @@ error:
*
* @return: void.
*/
-void CPasscodePopupView::Show(void)
+static void _show(Evas_Object *base)
{
- ASSERT(m);
+ struct _pwd_data *data;
+
+ if (!base)
+ return;
- evas_object_show(m->ctxpopup);
+ data = evas_object_data_get(base, PWD_DATA_ID);
+ if (!data) {
+ _ERR("get data from base failed. ID: %s.", PWD_DATA_ID);
+ return;
+ }
+
+ evas_object_show(data->ctxpopup);
}
/**
@@ -834,13 +832,20 @@ void CPasscodePopupView::Show(void)
*
* @return: void.
*/
-void CPasscodePopupView::Destroy(void)
+static void _destroy(Evas_Object *base)
{
- ASSERT(m);
+ struct _pwd_data *data;
+
+ if (!base)
+ return;
- _free_pwd_data(m);
- delete m;
- m = NULL;
+ data = evas_object_data_get(base, PWD_DATA_ID);
+ if (!data) {
+ _ERR("get data from base failed. ID: %s.", PWD_DATA_ID);
+ return;
+ }
+
+ _free_pwd_data(data);
}
/**
@@ -850,33 +855,33 @@ void CPasscodePopupView::Destroy(void)
*
* @return: void.
*/
-void CPasscodePopupView::Hide(void)
+static void _hide(Evas_Object *base)
{
- ASSERT(m);
+ struct _pwd_data *data;
- evas_object_hide(m->bg);
- evas_object_hide(m->ctxpopup);
-}
+ if (!base)
+ return;
+ data = evas_object_data_get(base, PWD_DATA_ID);
+ if (!data) {
+ _ERR("get data from base failed. ID: %s.",
+ PWD_DATA_ID);
+ return;
+ }
+
+ evas_object_hide(data->bg);
+ evas_object_hide(data->ctxpopup);
+}
-#if 0
/**
* view class of change passcode view.
*/
static struct setting_class _vclass = {
- VCLASS_TITLE_CHANGE_PASSCODE,
- _create,
- _show,
- NULL,
- NULL,
- NULL,
- NULL,
- _hide,
- _destroy,
- NULL,
- NULL,
- NULL,
- 0
+ .title = VCLASS_TITLE_CHANGE_PASSCODE,
+ .create = _create,
+ .show = _show,
+ .destroy = _destroy,
+ .hide = _hide
};
/**
@@ -890,4 +895,3 @@ struct setting_class *view_passcode_popup_get_vclass(void)
{
return &_vclass;
}
-#endif
diff --git a/src/view_resetpopup.c b/src/view_resetpopup.c
new file mode 100644
index 0000000..b53bc33
--- /dev/null
+++ b/src/view_resetpopup.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "dbg.h"
+#include "def.h"
+#include "stdbool.h"
+#include "viewmgr.h"
+#include "utils.h"
+#include "data_wrapper.h"
+#include "settings_provider.h"
+#include "view_resetpopup.h"
+
+/**
+* This function is invoked to create view layout.
+*
+* @param mgr [in] The setting_mgr data pointer passed by @settingmgr_view_push.
+* @param view [in] The settingview_data data pointer passed by @settingmgr_view_push.
+* @param prev [in] The parameter data which passed by prev view or NULL.
+* @return View layout evas object, NULL on error.
+*/
+static Evas_Object *_create(struct setting_mgr *mgr,
+ struct settingview_data *view, void *prev)
+{
+ /*TODO:Implement this function*/
+ return NULL;
+}
+
+/**
+* This function is invoked to show view layout.
+*
+* @param base [in] The view layout evas object.
+* @return void.
+*/
+static void _show(Evas_Object *base)
+{
+}
+
+/**
+* This function is invoked to destroy view layout.
+*
+* @param base [in] The view layout evas object.
+* @return void.
+*/
+static void _destroy(Evas_Object *base)
+{
+}
+
+/**
+* This function is invoked to hide view layout.
+*
+* @param base [in] The view layout evas object.
+* @return void.
+*/
+static void _hide(Evas_Object *base)
+{
+}
+
+static struct setting_class _vclass = {
+ .title = VCLASS_TITLE_RESET_POPUP,
+ .create = _create,
+ .show = _show,
+ .destroy = _destroy,
+ .hide = _hide,
+ .hide_view = 0
+};
+
+/**
+* This function is invoked to get reset popup view class object.
+*
+* @return The setting_class data static pointer, NULL on error.
+*/
+struct setting_class *view_resetpopup_get_vclass(void)
+{
+ return &_vclass;
+}
diff --git a/src/view_sublist.c b/src/view_sublist.c
new file mode 100644
index 0000000..7b9f203
--- /dev/null
+++ b/src/view_sublist.c
@@ -0,0 +1,775 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <KeyDefine.h>
+
+#include "dbg.h"
+#include "def.h"
+#include "stdbool.h"
+#include "viewmgr.h"
+#include "utils.h"
+#include "data_wrapper.h"
+#include "settings_provider.h"
+#include "view_sublist.h"
+
+#define DATA_ID "SUBLISTDATA"
+#define MAX_ITEMS 8
+#define ITEMID "itemdata"
+
+#define SUBLIST_OFFSET 70.0
+#define SUBLIST_WIDTH 310.0
+#define ITEM_HEIGHT 82
+#define ITEM_OFFSET (39 * 2)
+
+#define SIG_SCROLL_BOTTOM "edge,bottom"
+#define SIG_SCROLL_TOP "edge,top"
+#define SIG_SCROLL "scroll"
+#define SIG_ITEM_FOCUSED "focused"
+#define SIG_ITEM_UNFOCUSED "unfocused"
+#define SIG_ITEM_CLICKED "clicked"
+#define SIG_CTXPOPUP_DISMISSED "dismissed"
+
+struct _sublist_data {
+ Evas_Object *win;
+ Evas_Object *base;
+ Evas_Object *ctxpopup;
+ Evas_Object *popup_box;
+ Evas_Object *scroller;
+ Eina_Array *sub_btn_array;
+
+ int sub_items_count;
+ int selected_index;
+ struct obj_geometry_data *geometry_data;
+ struct settingview_data *sublist_view;
+ struct setting_mgr *mgr;
+};
+
+static void _destroy(Evas_Object *base);
+static void _hide(Evas_Object *base);
+
+/**
+* This function is invoked to exit and pop current view.
+*
+* @param data [in] The _sublist_data data pointer.
+* @return void.
+*/
+static void _exit_view(struct _sublist_data *data)
+{
+ if (!data)
+ return;
+
+ _hide(data->base);
+ settingmgr_view_pop(data->mgr);
+}
+
+/**
+* This function is invoked to get item's data list.
+*
+* @param data [in] The settingview_data data pointer.
+* @param cnt [out] The list element numbers
+* @return The Eina_List data pointer, NULL on error.
+*/
+static Eina_List *_get_list_data(struct settingview_data *data, int *cnt)
+{
+ Eina_List *list;
+
+ if (!data || !cnt) {
+ _ERR("Invalid arguments");
+ return NULL;
+ }
+
+ list = settingitem_get_data_list(viewdata_get_parentitem(data));
+ if (!list) {
+ *cnt = 0;
+ return NULL;
+ }
+
+ *cnt = eina_list_count(list);
+
+ return list;
+}
+
+/**
+* This function is invoked to get current selected value.
+*
+* @param data [in] The _sublist_data data pointer.
+* @return The selected string value, NULL on error.
+*/
+static char *_get_selected_value(struct _sublist_data *data)
+{
+ struct settingitem *item;
+
+ if (!data || !data->sublist_view) {
+ _ERR("Invalid argument");
+ return NULL;
+ }
+
+ item = viewdata_get_parentitem(data->sublist_view);
+ if (!item) {
+ _ERR("Get item failed");
+ return NULL;
+ }
+
+ return provider_get_list_value(item);
+}
+
+/**
+* This function is invoked to set selected value to middleware.
+*
+* @param data [in] The _sublist_data data pointer.
+* @param obj [in] The evas object user selected.
+* @return void.
+*/
+static void _set_selected_value(struct _sublist_data *data,
+ Evas_Object *obj)
+{
+ struct settingitem *item;
+ char *val;
+ int r;
+
+ if (!data || !data->sublist_view || !obj) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ item = viewdata_get_parentitem(data->sublist_view);
+ if (!item) {
+ _ERR("Get item failed");
+ return;
+ }
+
+ val = evas_object_data_get(obj, ITEMID);
+ if (val) {
+ r = provider_set_list_value(item, val);
+ if (r == -1)
+ _ERR("Set list value failed");
+ }
+}
+
+/**
+* This function is a @Evas_Smart_Cb type callback, it will be invoked if scroller go to bottom.
+*
+* @param data [in] The user data.
+* @param obj [in] The corresponding object which event occurred.
+* @param event [in] The event infomation.
+* @return void.
+*/
+static void _scroller_bottom_cb(void *data, Evas_Object *obj, void *event)
+{
+ struct _sublist_data *priv;
+
+ if (!data) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = data;
+
+ elm_object_signal_emit(priv->ctxpopup, SUBLIST_SHOW_UP_ARROW, "");
+}
+
+/**
+* This function is a @Evas_Smart_Cb type callback, it will be invoked if scroller go to top.
+*
+* @param data [in] The user data.
+* @param obj [in] The corresponding object which event occurred.
+* @param event [in] The event infomation.
+* @return void.
+*/
+static void _scroller_top_cb(void *data, Evas_Object *obj, void *event)
+{
+ struct _sublist_data *priv;
+
+ if (!data) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = data;
+
+ elm_object_signal_emit(priv->ctxpopup, SUBLIST_SHOW_DOWN_ARROW, "");
+}
+
+/**
+* This function is a @Evas_Smart_Cb type callback, it will be invoked if scroller is scrolling.
+*
+* @param data [in] The user data.
+* @param obj [in] The corresponding object which event occurred.
+* @param event [in] The event infomation.
+* @return void.
+*/
+static void _scroll_event_cb(void *data, Evas_Object *obj, void *event)
+{
+ struct _sublist_data *priv;
+
+ if (!data) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = data;
+
+ elm_object_signal_emit(priv->ctxpopup, SUBLIST_SHOW_BOTH_ARROW, "");
+}
+
+/**
+* This function is a @Evas_Smart_Cb type callback, it will be invoked if evas object get focus.
+*
+* @param data [in] The user data.
+* @param obj [in] The corresponding object which event occurred.
+* @param ev [in] The event infomation.
+* @return void.
+*/
+static void _subitem_focus_in_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _sublist_data *priv;
+ char *val, *sel;
+
+ if (!obj || !data) {
+ _ERR("Invalid arguments\n");
+ return;
+ }
+
+ priv = data;
+
+ val = evas_object_data_get(obj, ITEMID);
+ if (!val) {
+ _ERR("Get value from btn failed\n");
+ return;
+ }
+
+ sel = _get_selected_value(priv);
+ if (!sel) {
+ _ERR("_get_selected_value failed\n");
+ return;
+ }
+
+ if (!strncmp(sel, val, strlen(sel)))
+ elm_object_signal_emit(obj, CTXPOPUPBTN_ICON_FOCUSED,
+ CTXPOPUPBTN_ICON_SOURCE);
+
+ elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_FOCUSED,
+ CTXPOPUPBTN_BUTTON_SOURCE);
+
+ provider_release_list_value(sel);
+}
+
+/**
+* This function is a @Evas_Smart_Cb type callback, it will be invoked if evas object lose focus.
+*
+* @param data [in] The user data.
+* @param obj [in] The corresponding object which event occurred.
+* @param ev [in] The event infomation.
+* @return void.
+*/
+static void _subitem_focus_out_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _sublist_data *priv;
+ char *val, *sel;
+
+ if (!obj || !data) {
+ _ERR("Invalid arguments\n");
+ return;
+ }
+
+ priv = data;
+
+ val = evas_object_data_get(obj, ITEMID);
+ if (!val) {
+ _ERR("Get value from btn failed\n");
+ return;
+ }
+
+ sel = _get_selected_value(priv);
+ if (!sel) {
+ _ERR("_get_selected_value failed\n");
+ return;
+ }
+
+ if (!strncmp(sel, val, strlen(sel)))
+ elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_HIGHLIGHT,
+ CTXPOPUPBTN_BUTTON_SOURCE);
+ else
+ elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_UNFOCUSED,
+ CTXPOPUPBTN_BUTTON_SOURCE);
+
+ provider_release_list_value(sel);
+}
+
+/**
+* This function is a @Evas_Smart_Cb type callback, it will be invoked if evas object be clicked.
+*
+* @param data [in] The user data.
+* @param obj [in] The corresponding object which event occurred.
+* @param ev [in] The event infomation.
+* @return void.
+*/
+static void _subitem_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _sublist_data *priv;
+
+ if (!data || !obj)
+ return;
+
+ priv = data;
+
+ _set_selected_value(priv, obj);
+
+ _exit_view(priv);
+}
+
+/**
+* This function is a @Evas_Smart_Cb type callback, it will be invoked if
+* ctxpopup dismissed.
+*
+* @param data [in] The user data.
+* @param obj [in] The corresponding object which event occurred.
+* @param ev [in] The event infomation.
+* @return void.
+*/
+static void _ctxpopup_dismissed_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _sublist_data *priv;
+
+ if (!data)
+ return;
+
+ priv = data;
+
+ _exit_view(priv);
+}
+
+/**
+* This function is a @Evas_Smart_Cb type callback, it will be invoked if occurred
+* key press event.
+*
+* @param data [in] The user data.
+* @param e [in] The evas handler.
+* @param obj [in] The corresponding object which event occurred.
+* @param ei [in] The event infomation.
+* @return void.
+*/
+static void _subitem_key_pressed_cb(void *data, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _sublist_data *priv;
+
+ if (!data || !ei)
+ return;
+
+ ev = ei;
+ priv = data;
+
+ if (!strcmp(ev->keyname, KEY_BACK))
+ _exit_view(priv);
+}
+
+/**
+* This function is invoked to draw ctxpopup layout.
+*
+* @param data [in] The _sublist_data data pointer.
+* @return 0 if success, -1 if fail.
+*/
+static int _draw_ctxpopup_layout(struct _sublist_data *data)
+{
+ Evas_Object *box, *ctxpopup, *scroller;
+
+ if (!data || !data->ctxpopup) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ ctxpopup = data->ctxpopup;
+ scroller = NULL;
+
+ if (data->sub_items_count > MAX_ITEMS) {
+ scroller = utils_add_scroller(ctxpopup);
+ if (!scroller) {
+ _ERR("elm_scroller_add failed\n");
+ return -1;
+ }
+
+ elm_object_style_set(scroller, SUBLIST_SCROLLER_STYLE);
+ elm_object_content_set(ctxpopup, scroller);
+
+ box = utils_add_box(ctxpopup);
+ if (!box) {
+ _ERR("elm_box_add failed\n");
+ evas_object_del(scroller);
+ return -1;
+ }
+
+ elm_object_content_set(scroller, box);
+
+ evas_object_smart_callback_add(scroller, SIG_SCROLL_BOTTOM,
+ _scroller_bottom_cb, data);
+ evas_object_smart_callback_add(scroller, SIG_SCROLL_TOP,
+ _scroller_top_cb, data);
+ evas_object_smart_callback_add(scroller, SIG_SCROLL,
+ _scroll_event_cb, data);
+
+ elm_object_signal_emit(ctxpopup, SUBLIST_SHOW_DOWN_ARROW, "");
+ } else {
+ box = utils_add_box(ctxpopup);
+ if (!box) {
+ _ERR("elm_box_add failed\n");
+ return -1;
+ }
+
+ elm_object_content_set(ctxpopup, box);
+
+ elm_object_signal_emit(ctxpopup, SUBLIST_HIDE_BOTH_ARROW, "");
+ }
+
+ data->popup_box = box;
+ data->scroller = scroller;
+
+ return 0;
+}
+
+/**
+* This function is invoked to draw list items.
+*
+* @param data [in] The _sublist_data data pointer.
+* @param list [in] The eina list data pointer.
+* @return 0 if success, -1 if fail.
+*/
+static int _draw_list_items(struct _sublist_data *data, Eina_List *list)
+{
+ struct listitem *ldata;
+ Eina_List *l;
+ Eina_Array *btns;
+ Eina_Array_Iterator a;
+ Evas_Object *btn, *tmp;
+ char *sel;
+ const char *name, *val;
+ int check, i, j;
+
+ if (!data || !list || !data->popup_box) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ sel = _get_selected_value(data);
+ if (!sel) {
+ _ERR("Get selected value failed");
+ return -1;
+ }
+
+ btns = eina_array_new(1);
+ if (!btns) {
+ _ERR("Allocate array failed\n");
+ provider_release_list_value(sel);
+ return -1;
+ }
+
+ i = 0;
+ j = 0;
+ check = 0;
+
+ EINA_LIST_FOREACH(list, l, ldata) {
+ name = listitem_get_display_name(ldata);
+
+ btn = utils_add_btn(data->popup_box, CTXPOPUPBTN_STYLE,
+ name, EINA_TRUE);
+ if (!btn) {
+ _ERR("Add button failed\n");
+ EINA_ARRAY_ITER_NEXT(btns, j, tmp, a)
+ evas_object_del(tmp);
+ eina_array_free(btns);
+ provider_release_list_value(sel);
+ return -1;
+ }
+
+ val = listitem_get_value(ldata);
+ if (!strncmp(sel, val, strlen(sel))) {
+ elm_object_signal_emit(btn,
+ CTXPOPUPBTN_BUTTON_HIGHLIGHT,
+ CTXPOPUPBTN_BUTTON_SOURCE);
+ check = i;
+ }
+
+ evas_object_data_set(btn, ITEMID, val);
+
+ evas_object_smart_callback_add(btn, SIG_ITEM_FOCUSED,
+ _subitem_focus_in_cb, data);
+ evas_object_smart_callback_add(btn, SIG_ITEM_UNFOCUSED,
+ _subitem_focus_out_cb, data);
+ evas_object_smart_callback_add(btn, SIG_ITEM_CLICKED,
+ _subitem_btn_clicked_cb, data);
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN,
+ _subitem_key_pressed_cb, data);
+
+ elm_box_pack_end(data->popup_box, btn);
+ eina_array_push(btns, btn);
+
+ if (i == 0)
+ elm_object_focus_set(btn, EINA_TRUE);
+
+ i++;
+ }
+
+ data->sub_btn_array = btns;
+ data->selected_index = check;
+
+ provider_release_list_value(sel);
+
+ return 0;
+}
+
+/**
+* This function is invoked to draw sub list view.
+*
+* @param data [in] The _sublist_data data pointer.
+* @return 0 if success, -1 if fail.
+*/
+static int _draw_sublist(struct _sublist_data *data)
+{
+ struct settingview_data *view;
+ Eina_List *list;
+ double ratio, w;
+ int cnt, x, y, height;
+ struct obj_geometry_data *param;
+
+ if (!data || !data->sublist_view || !data->geometry_data) {
+ _ERR("Invalid argument\n");
+ return -1;
+ }
+
+ view = data->sublist_view;
+
+ cnt = 0;
+ list = _get_list_data(view, &cnt);
+ if (!list) {
+ _ERR("Get item list failed");
+ return -1;
+ }
+
+ data->sub_items_count = cnt;
+
+ if (_draw_ctxpopup_layout(data) == -1) {
+ _ERR("Fail to draw ctxpopup layout");
+ return -1;
+ }
+
+ if (_draw_list_items(data, list) == -1) {
+ _ERR("Fail to draw list items");
+ return -1;
+ }
+
+ param = data->geometry_data;
+
+ w = param->width;
+ if (w <= 0) {
+ _ERR("Fail to get clicked button width");
+ return -1;
+ }
+
+ ratio = (w - SUBLIST_WIDTH - SUBLIST_OFFSET) / w;
+
+ x = param->x + param->width * ratio;
+ y = param->y;
+
+ if (data->sub_items_count < MAX_ITEMS)
+ height = data->sub_items_count * ITEM_HEIGHT;
+ else
+ height = MAX_ITEMS * ITEM_HEIGHT + ITEM_OFFSET;
+
+ if (y > WIN_HEIGHT)
+ y = y - height;
+
+ evas_object_move(data->ctxpopup, x * ELM_SCALE, y * ELM_SCALE);
+
+ utils_set_focus_directions(data->sub_btn_array, data->sub_items_count);
+
+ return 0;
+}
+
+/**
+* This function is invoked to create view layout.
+*
+* @param mgr [in] The setting_mgr data pointer passed by @settingmgr_view_push.
+* @param view [in] The settingview_data data pointer passed by @settingmgr_view_push.
+* @param prev [in] The parameter data which passed by prev view or NULL.
+* @return View layout evas object, NULL on error.
+*/
+static Evas_Object *_create(struct setting_mgr *mgr,
+ struct settingview_data *view, void *prev)
+{
+ Evas_Object *base, *ctxpopup, *win;
+ struct _sublist_data *data;
+
+ if (!mgr || !view || !prev) {
+ _ERR("Invalid argument!\n");
+ return NULL;
+ }
+
+ win = settingmgr_get_win(mgr);
+ if (!win) {
+ _ERR("Fail to get win");
+ return NULL;
+ }
+
+ data = calloc(1, sizeof(*data));
+ if (!data) {
+ _ERR("Unable to allocate memory\n");
+ return NULL;
+ }
+
+ base = elm_layout_add(win);
+ if (!base) {
+ free(data);
+ return NULL;
+ }
+
+ elm_layout_file_set(base, EDJ_FILE, SUBLIST_VIEW_PAGE);
+
+ ctxpopup = utils_add_ctxpopup(win, SUBLIST_CTXPOPUP_STYLE1);
+ if (!ctxpopup) {
+ _ERR("Fail to add ctxpopup");
+ evas_object_del(base);
+ free(data);
+ return NULL;
+ }
+
+ evas_object_smart_callback_add(ctxpopup, SIG_CTXPOPUP_DISMISSED,
+ _ctxpopup_dismissed_cb, data);
+
+ data->geometry_data = prev;
+
+ data->mgr = mgr;
+ data->win = win;
+ data->base = base;
+ data->ctxpopup = ctxpopup;
+ data->sublist_view = view;
+
+ evas_object_data_set(base, DATA_ID, data);
+
+ if (_draw_sublist(data) == -1) {
+ _ERR("Error in drawing items function\n");
+ evas_object_del(base);
+ evas_object_del(ctxpopup);
+ if (data->sub_btn_array)
+ eina_array_free(data->sub_btn_array);
+
+ free(data);
+ return NULL;
+ }
+
+ return base;
+
+}
+
+/**
+* This function is invoked to show view layout.
+*
+* @param base [in] The view layout evas object.
+* @return void.
+*/
+static void _show(Evas_Object *base)
+{
+ struct _sublist_data *data;
+
+ if (!base) {
+ _ERR("Invalid argument\n");
+ return;
+ }
+
+ data = evas_object_data_get(base, DATA_ID);
+ if (!data) {
+ _ERR("Get sublist data failed\n");
+ return;
+ }
+
+ evas_object_show(data->ctxpopup);
+ evas_object_show(base);
+}
+
+/**
+* This function is invoked to destroy view layout.
+*
+* @param base [in] The view layout evas object.
+* @return void.
+*/
+static void _destroy(Evas_Object *base)
+{
+ struct _sublist_data *data;
+
+ if (!base)
+ return;
+
+ data = evas_object_data_get(base, DATA_ID);
+ if (!data) {
+ _ERR("Invalid arguments");
+ evas_object_del(data->ctxpopup);
+ evas_object_del(base);
+ return;
+ }
+
+ if (data->sub_btn_array)
+ eina_array_free(data->sub_btn_array);
+
+ evas_object_del(data->ctxpopup);
+ evas_object_del(base);
+
+ if (data->sublist_view)
+ viewdata_release(data->sublist_view);
+
+ free(data);
+}
+
+/**
+* This function is invoked to hide view layout.
+*
+* @param base [in] The view layout evas object.
+* @return void.
+*/
+static void _hide(Evas_Object *base)
+{
+ struct _sublist_data *data;
+
+ if (!base)
+ return;
+
+ data = evas_object_data_get(base, DATA_ID);
+ if (!data) {
+ _ERR("Invalid arguments");
+ return;
+ }
+
+ evas_object_hide(base);
+ evas_object_hide(data->ctxpopup);
+}
+
+static struct setting_class _vclass = {
+ .title = VCLASS_TITLE_SUBLIST,
+ .create = _create,
+ .show = _show,
+ .destroy = _destroy,
+ .hide = _hide,
+ .hide_view = 0
+};
+
+/**
+* This function is invoked to get sub list view class object.
+*
+* @return The setting_class data static pointer, NULL on error.
+*/
+struct setting_class *view_sublist_get_vclass(void)
+{
+ return &_vclass;
+}
diff --git a/src/view_sublist.cpp b/src/view_sublist.cpp
deleted file mode 100644
index 52f14ed..0000000
--- a/src/view_sublist.cpp
+++ /dev/null
@@ -1,655 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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 <AppCommon.h>
-#include "common_defs.h"
-#include "stdbool.h"
-#include "settingviewmgr.h"
-#include "utils.h"
-#include "data_wrapper.h"
-#include "settings_provider.h"
-#include "view_sublist.h"
-#include "settingviewmgr.h"
-
-
-enum EId {
- ID_BTNS,
-};
-
-#define MAX_ITEMS 8
-#define ITEMID "itemdata"
-
-#define SUBLIST_OFFSET 70.0
-#define SUBLIST_WIDTH 310.0
-#define ITEM_HEIGHT 82
-#define ITEM_OFFSET (39 * 2)
-
-#define SIG_SCROLL_BOTTOM "edge,bottom"
-#define SIG_SCROLL_TOP "edge,top"
-#define SIG_SCROLL "scroll"
-#define SIG_ITEM_FOCUSED "focused"
-#define SIG_ITEM_UNFOCUSED "unfocused"
-#define SIG_ITEM_CLICKED "clicked"
-#define SIG_CTXPOPUP_DISMISSED "dismissed"
-
-struct SSublistView {
- Evas_Object *win;
- Evas_Object *base;
- Evas_Object *ctxpopup;
- Evas_Object *popup_box;
- Evas_Object *scroller;
- Eina_Array *sub_btn_array;
-
- int sub_items_count;
- int selected_index;
- struct obj_geometry_data *geometry_data;
- struct settingview_data *sublist_view;
- CSettingMgr *mgr;
-};
-
-//static void _destroy(Evas_Object *base);
-//static void _hide(Evas_Object *base);
-
-/**
-* This function is invoked to exit and pop current view.
-*
-* @param data [in] The _sublist_data data pointer.
-* @return void.
-*/
-void CSublistView::m_ExitView(void)
-{
- _DBG();
-
- Hide();
-
- m->mgr->ViewPop();
-}
-
-/**
-* This function is invoked to get item's data list.
-*
-* @param data [in] The settingview_data data pointer.
-* @param cnt [out] The list element numbers
-* @return The Eina_List data pointer, NULL on error.
-*/
-static Eina_List *_get_list_data(struct settingview_data *data, int *cnt)
-{
- Eina_List *list;
-
- if (!data || !cnt) {
- _ERR("Invalid arguments");
- return NULL;
- }
-
- list = settingitem_get_data_list(viewdata_get_parentitem(data));
- if (!list) {
- *cnt = 0;
- return NULL;
- }
-
- *cnt = eina_list_count(list);
-
- return list;
-}
-
-/**
-* This function is invoked to get current selected value.
-*
-* @param data [in] The _sublist_data data pointer.
-* @return The selected string value, NULL on error.
-*/
-static char *_get_selected_value(SSublistView *data)
-{
- struct settingitem *item;
-
- if (!data || !data->sublist_view) {
- _ERR("Invalid argument");
- return NULL;
- }
-
- item = viewdata_get_parentitem(data->sublist_view);
- if (!item) {
- _ERR("Get item failed");
- return NULL;
- }
-
- return provider_get_list_value(item);
-}
-
-/**
-* This function is invoked to set selected value to middleware.
-*
-* @param data [in] The _sublist_data data pointer.
-* @param obj [in] The evas object user selected.
-* @return void.
-*/
-void CSublistView::m_SetSelectedValue(Evas_Object *obj)
-{
- struct settingitem *item;
- char *val;
- int r;
-
- if (!m->sublist_view || !obj) {
- _ERR("Invalid argument");
- return;
- }
-
- item = viewdata_get_parentitem(m->sublist_view);
- if (!item) {
- _ERR("Get item failed");
- return;
- }
-
- val = (char *) evas_object_data_get(obj, ITEMID);
- if (val) {
- r = provider_set_list_value(item, val);
- if (r == -1)
- _ERR("Set list value failed");
- }
-}
-
-/**
-* This function is a @Evas_Smart_Cb type callback, it will be invoked if scroller go to bottom.
-*
-* @param data [in] The user data.
-* @param obj [in] The corresponding object which event occurred.
-* @param event [in] The event infomation.
-* @return void.
-*/
-static void _scroller_bottom_cb(void *data, Evas_Object *obj, void *event)
-{
- SSublistView *priv;
-
- if (!data) {
- _ERR("Invalid argument");
- return;
- }
-
- priv = (SSublistView *) data;
-
- elm_object_signal_emit(priv->ctxpopup, SUBLIST_SHOW_UP_ARROW, "");
-}
-
-/**
-* This function is a @Evas_Smart_Cb type callback, it will be invoked if scroller go to top.
-*
-* @param data [in] The user data.
-* @param obj [in] The corresponding object which event occurred.
-* @param event [in] The event infomation.
-* @return void.
-*/
-static void _scroller_top_cb(void *data, Evas_Object *obj, void *event)
-{
- SSublistView *priv;
-
- if (!data) {
- _ERR("Invalid argument");
- return;
- }
-
- priv = (SSublistView *) data;
-
- elm_object_signal_emit(priv->ctxpopup, SUBLIST_SHOW_DOWN_ARROW, "");
-}
-
-/**
-* This function is a @Evas_Smart_Cb type callback, it will be invoked if scroller is scrolling.
-*
-* @param data [in] The user data.
-* @param obj [in] The corresponding object which event occurred.
-* @param event [in] The event infomation.
-* @return void.
-*/
-static void _scroll_event_cb(void *data, Evas_Object *obj, void *event)
-{
- SSublistView *priv;
-
- if (!data) {
- _ERR("Invalid argument");
- return;
- }
-
- priv = (SSublistView *) data;
-
- elm_object_signal_emit(priv->ctxpopup, SUBLIST_SHOW_BOTH_ARROW, "");
-}
-
-
-/**
-* This function is a @Evas_Smart_Cb type callback, it will be invoked if
-* ctxpopup dismissed.
-*
-* @param data [in] The user data.
-* @param obj [in] The corresponding object which event occurred.
-* @param ev [in] The event infomation.
-* @return void.
-*/
-void CSublistView::sm_CbCtxpopupDismissed(void *data, Evas_Object *obj, void *ev)
-{
- _DBG();
- CSublistView *root = (CSublistView*)data;
- if (root)
- root->m_OnCtxpopupDismissed(obj, ev);
-}
-
-
-void CSublistView::m_OnCtxpopupDismissed(Evas_Object *obj, void *ev)
-{
- _DBG();
- m_ExitView();
-}
-
-
-/**
-* This function is invoked to draw ctxpopup layout.
-*
-* @param data [in] The _sublist_data data pointer.
-* @return 0 if success, -1 if fail.
-*/
-bool CSublistView::m_DrawCtxpopupLayout()
-{
- _DBG();
- if (!m->ctxpopup) {
- _ERR("Invalid argument");
- return false;
- }
-
- if (m->sub_items_count > MAX_ITEMS) {
- _DBG();
- m->scroller = utils_add_scroller(m->ctxpopup);
- if (!m->scroller) {
- _ERR("elm_scroller_add failed");
- return false;
- }
-
- //elm_object_style_set(m->scroller, SUBLIST_SCROLLER_STYLE);
- elm_object_content_set(m->ctxpopup, m->scroller);
-
- m->popup_box = utils_add_box(m->ctxpopup);
- if (!m->popup_box) {
- _ERR("elm_box_add failed");
- evas_object_del(m->scroller);
- return false;
- }
-
- elm_object_content_set(m->scroller, m->popup_box);
-
- evas_object_smart_callback_add(m->scroller, SIG_SCROLL_BOTTOM, _scroller_bottom_cb, m);
- evas_object_smart_callback_add(m->scroller, SIG_SCROLL_TOP, _scroller_top_cb, m);
- evas_object_smart_callback_add(m->scroller, SIG_SCROLL, _scroll_event_cb, m);
-
- elm_object_signal_emit(m->ctxpopup, SUBLIST_SHOW_DOWN_ARROW, "");
- } else {
- m->popup_box = utils_add_box(m->ctxpopup);
- if (!m->popup_box) {
- _ERR("elm_box_add failed");
- return false;
- }
-
- elm_object_content_set(m->ctxpopup, m->popup_box);
-
- elm_object_signal_emit(m->ctxpopup, SUBLIST_HIDE_BOTH_ARROW, "");
- }
-
- return true;
-}
-
-/**
-* This function is invoked to draw list items.
-*
-* @param data [in] The _sublist_data data pointer.
-* @param list [in] The eina list data pointer.
-* @return 0 if success, -1 if fail.
-*/
-bool CSublistView::m_DrawListItems(Eina_List *list)
-{
- _DBG();
- struct listitem *ldata;
- void* obj;
- Eina_List *l;
- Eina_Array *btns;
- Eina_Array_Iterator a;
- Evas_Object *btn, *tmp;
- char *sel;
- const char *name, *val;
- unsigned int check, i, j;
-
- if (!list || !m->popup_box) {
- _ERR("Invalid argument");
- return false;
- }
-
- sel = _get_selected_value(m);
- if (!sel) {
- _ERR("Get selected value failed");
- return false;
- }
-
- btns = eina_array_new(1);
- if (!btns) {
- _ERR("Allocate array failed");
- provider_release_list_value(sel);
- return false;
- }
-
- i = 0;
- j = 0;
- check = 0;
-
- EINA_LIST_FOREACH(list, l, obj) {
- ldata = (struct listitem *) obj;
- name = listitem_get_display_name(ldata);
-
- btn = utils_add_btn(m->popup_box, CTXPOPUPBTN_STYLE, name, EINA_TRUE);
- if (!btn) {
- _ERR("Add button failed");
- EINA_ARRAY_ITER_NEXT(btns, j, obj, a)
- {
- tmp = (Evas_Object *) obj;
- evas_object_del(tmp);
- }
- eina_array_free(btns);
- provider_release_list_value(sel);
- return false;
- }
-
- val = listitem_get_value(ldata);
- if (!strncmp(sel, val, strlen(sel))) {
- elm_object_signal_emit(btn, CTXPOPUPBTN_BUTTON_HIGHLIGHT, CTXPOPUPBTN_BUTTON_SOURCE);
- check = i;
- }
-
- evas_object_data_set(btn, ITEMID, val);
-
- _DBG("[%s] Connected", name);
- Connect(btn, ID_BTNS, TYPE_FOCUSED | TYPE_UNFOCUSED | TYPE_CLICKED | TYPE_KEY_DOWN);
-
- //evas_object_smart_callback_add(btn, SIG_ITEM_FOCUSED, sm_CbSubitemFocusIn, this);
- //evas_object_smart_callback_add(btn, SIG_ITEM_UNFOCUSED, sm_CbSubitemFocusOut, this);
- //evas_object_smart_callback_add(btn, SIG_ITEM_CLICKED, sm_CbSubitemBtnClicked, this);
- //evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, sm_CbSubitemKeyPressed, this);
-
- elm_box_pack_end(m->popup_box, btn);
- eina_array_push(btns, btn);
-
- if (i == 0)
- elm_object_focus_set(btn, EINA_TRUE);
-
- i++;
- }
-
- m->sub_btn_array = btns;
- m->selected_index = check;
-
- provider_release_list_value(sel);
-
- return true;
-}
-
-/**
-* This function is invoked to draw sub list view.
-*
-* @param data [in] The _sublist_data data pointer.
-* @return 0 if success, -1 if fail.
-*/
-bool CSublistView::m_DrawSublist(void)
-{
- _DBG();
- Eina_List *list;
- int cnt;
-
- if (!m->sublist_view || !m->geometry_data) {
- _ERR("Invalid argument\n");
- return false;
- }
-
- cnt = 0;
- list = _get_list_data(m->sublist_view, &cnt);
- if (!list) {
- _ERR("Get item list failed");
- return false;
- }
-
- m->sub_items_count = cnt;
-
- if (!m_DrawCtxpopupLayout()) {
- _ERR("Fail to draw ctxpopup layout");
- return false;
- }
-
- if (!m_DrawListItems(list)) {
- _ERR("Fail to draw list items");
- return false;
- }
-
- evas_object_move(m->ctxpopup, m->geometry_data->x + m->geometry_data->width , m->geometry_data->y);
-
- utils_set_focus_directions(m->sub_btn_array, m->sub_items_count);
-
- return true;
-}
-
-
-
-Evas_Object* CSublistView::Base(void)
-{
- ASSERT(m);
-
- return m->base;
-}
-
-
-/**
-* This function is invoked to create view layout.
-*
-* @param mgr [in] The setting_mgr data pointer passed by @settingmgr_view_push.
-* @param view [in] The settingview_data data pointer passed by @settingmgr_view_push.
-* @param prev [in] The parameter data which passed by prev view or NULL.
-* @return View layout evas object, NULL on error.
-*/
-bool CSublistView::Create(struct settingview_data *view, void *prev)
-{
- ASSERT(!m);
- ASSERT(view);
- ASSERT(prev);
- _DBG();
-
- _CREATE_BEGIN {
- _CHECK(m = new SSublistView)
- _CHECK(m->mgr = CSettingMgr::GetInstance())
- _CHECK(m->win = m->mgr->Window())
- _CHECK(m->base = elm_layout_add(m->win))
- _COMMAND {
- elm_layout_file_set(m->base, EDJ_FILE, SUBLIST_VIEW_PAGE);
- }
- //_CHECK(m->ctxpopup = utils_add_ctxpopup(m->win, (char *) SUBLIST_CTXPOPUP_STYLE1))
- _CHECK(m->ctxpopup = utils_add_ctxpopup(m->win, NULL))
- _COMMAND {
- evas_object_smart_callback_add(m->ctxpopup, SIG_CTXPOPUP_DISMISSED, sm_CbCtxpopupDismissed, this);
- m->geometry_data = (struct obj_geometry_data *) prev;
- _DBG("m-geometry_data w:%d, h:%d, x:%d, y:%d",
- m->geometry_data->width,
- m->geometry_data->height,
- m->geometry_data->x,
- m->geometry_data->y
- );
-
- m->sublist_view = view;
- }
- _CHECK(m_DrawSublist())
- _WHEN_SUCCESS { }
- _CHECK_FAIL{ if (m->sub_btn_array) eina_array_free(m->sub_btn_array); }
- _CHECK_FAIL{ if(m->ctxpopup) evas_object_del(m->ctxpopup); }
- _CHECK_FAIL{ if(m->base) evas_object_del(m->base); }
- _CHECK_FAIL{/* m->win = m->mgr->Window() */}
- _CHECK_FAIL{/* m->mgr = CSettingMgr::GetInstance() */}
- _CHECK_FAIL{ delete m; m = NULL; }
- } _CREATE_END_AND_CATCH{ return false; }
-
- return true;
-}
-
-/**
-* This function is invoked to show view layout.
-*
-* @param base [in] The view layout evas object.
-* @return void.
-*/
-void CSublistView::Show(void)
-{
- ASSERT(m);
- _DBG();
-
- evas_object_show(m->ctxpopup);
- evas_object_show(m->base);
-}
-
-/**
-* This function is invoked to destroy view layout.
-*
-* @param base [in] The view layout evas object.
-* @return void.
-*/
-void CSublistView::Destroy(void)
-{
- ASSERT(m);
- _DBG();
-
- if (m->sub_btn_array)
- eina_array_free(m->sub_btn_array);
-
- evas_object_del(m->ctxpopup);
- evas_object_del(m->base);
-
- if (m->sublist_view)
- viewdata_release(m->sublist_view);
-
- delete m;
- m = NULL;
-}
-
-/**
-* This function is invoked to hide view layout.
-*
-* @param base [in] The view layout evas object.
-* @return void.
-*/
-void CSublistView::Hide(void)
-{
- ASSERT(m);
- _DBG();
-
- evas_object_hide(m->base);
- evas_object_hide(m->ctxpopup);
-}
-
-
-void CSublistView::OnMouseClicked(int id, Evas_Object *obj)
-{
- _DBG();
- if (id != ID_BTNS)
- return;
-
- if (!obj)
- return;
-
- m_SetSelectedValue(obj);
-
- m_ExitView();
-}
-
-
-void CSublistView::OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item)
-{
- _DBG();
- if (id != ID_BTNS)
- return;
-
- char *val, *sel;
-
- if (!obj) {
- _ERR("Invalid arguments\n");
- return;
- }
-
- val = (char *)evas_object_data_get(obj, ITEMID);
- if (!val) {
- _ERR("Get value from btn failed\n");
- return;
- }
-
- sel = _get_selected_value(m);
- if (!sel) {
- _ERR("_get_selected_value failed\n");
- return;
- }
-
- if (!strncmp(sel, val, strlen(sel)))
- elm_object_signal_emit(obj, CTXPOPUPBTN_ICON_FOCUSED,
- CTXPOPUPBTN_ICON_SOURCE);
-
- elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_FOCUSED,
- CTXPOPUPBTN_BUTTON_SOURCE);
-
- provider_release_list_value(sel);
-}
-
-
-void CSublistView::OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item)
-{
- _DBG();
- if (id != ID_BTNS)
- return;
-
- char *val, *sel;
-
- if (!obj) {
- _ERR("Invalid arguments\n");
- return;
- }
-
- val = (char *)evas_object_data_get(obj, ITEMID);
- if (!val) {
- _ERR("Get value from btn failed\n");
- return;
- }
-
- sel = _get_selected_value(m);
- if (!sel) {
- _ERR("_get_selected_value failed\n");
- return;
- }
-
- if (!strncmp(sel, val, strlen(sel)))
- elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_HIGHLIGHT,
- CTXPOPUPBTN_BUTTON_SOURCE);
- else
- elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_UNFOCUSED,
- CTXPOPUPBTN_BUTTON_SOURCE);
-
- provider_release_list_value(sel);
-}
-
-
-void CSublistView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
-{
- _DBG();
- if (id != ID_BTNS)
- return;
-
- if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE))
- m_ExitView();
-}
diff --git a/src/view_system_clock.cpp b/src/view_system_clock.c
index ecab021..4ca6666 100644
--- a/src/view_system_clock.cpp
+++ b/src/view_system_clock.c
@@ -14,10 +14,12 @@
* limitations under the License.
*/
-#include <AppCommon.h>
-#include "common_defs.h"
+#include <KeyDefine.h>
+
+#include "dbg.h"
+#include "def.h"
#include "stdbool.h"
-#include "settingviewmgr.h"
+#include "viewmgr.h"
#include "utils.h"
#include "data_wrapper.h"
#include "settings_provider.h"
@@ -40,11 +42,7 @@
#define SIG_UNFOCUSED "unfocused"
#define SIG_CLICKED "clicked"
-enum EId {
- ID_BTNS,
-};
-
-struct SSystemClockView {
+struct _sysclk_data {
Evas_Object *win;
Evas_Object *base;
Evas_Object *ctxpopup;
@@ -54,12 +52,14 @@ struct SSystemClockView {
int count;
int sel_idx;
struct settingview_data *vdata;
- CSettingMgr *mgr;
+ struct setting_mgr *mgr;
struct evas_obj_data ugd;
struct obj_geometry_data *ogd;
};
+static void _destroy(Evas_Object *base);
+static void _hide(Evas_Object *base);
/**
* Exit system clock sublist view.
@@ -68,13 +68,14 @@ struct SSystemClockView {
*
* @return: void.
*/
-void CSystemClockView::m_ExitView(void)
+static void _exit_view(struct _sysclk_data *data)
{
- ASSERT(m);
+ if (!data || !data->base)
+ return;
- Hide();
+ _hide(data->base);
- m->mgr->ViewPop();
+ settingmgr_view_pop(data->mgr);
}
/**
@@ -112,7 +113,7 @@ static Eina_List *_get_item_list(struct settingview_data *vdata, int *count)
*
* @return: the selected value or null if error occurred.
*/
-static char *_get_selected_value(SSystemClockView *data)
+static char *_get_selected_value(struct _sysclk_data *data)
{
struct settingitem *item;
@@ -138,7 +139,7 @@ static char *_get_selected_value(SSystemClockView *data)
*
* @return: void.
*/
-static void _set_selected_value(SSystemClockView *data, Evas_Object *obj)
+static void _set_selected_value(struct _sysclk_data *data, Evas_Object *obj)
{
struct settingitem *item;
char *selval;
@@ -155,7 +156,7 @@ static void _set_selected_value(SSystemClockView *data, Evas_Object *obj)
return;
}
- selval = (char *) evas_object_data_get(obj, ITEMID);
+ selval = evas_object_data_get(obj, ITEMID);
if (selval) {
ret = provider_set_list_value(item, selval);
if (ret != 0)
@@ -163,7 +164,189 @@ static void _set_selected_value(SSystemClockView *data, Evas_Object *obj)
}
}
+/**
+* Evas_Smart_Cb type callback for handling foucs in event.
+*
+* @param[in]: priv : the user data.
+* @param[in]: obj : the corresponding object which the foucs in event occurred.
+* @param[in]: ev : event info.
+*
+* @return: void.
+*/
+static void _subitem_focusin_cb(void *priv, Evas_Object *obj, void *ev)
+{
+ struct _sysclk_data *data;
+ char *value;
+ char *selval;
+
+ if (!obj || !priv) {
+ _ERR("Invalid arguments\n");
+ return;
+ }
+
+ data = priv;
+
+ value = evas_object_data_get(obj, ITEMID);
+ if (!value) {
+ _ERR("Get value from btn failed\n");
+ return;
+ }
+
+ selval = _get_selected_value(data);
+ if (!selval) {
+ _ERR("_get_selected_value failed\n");
+ return;
+ }
+
+ if (!strncmp(selval, value, strlen(selval))) {
+ elm_object_signal_emit(obj, CTXPOPUPBTN_ICON_FOCUSED,
+ CTXPOPUPBTN_ICON_SOURCE);
+ }
+
+ elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_FOCUSED,
+ CTXPOPUPBTN_BUTTON_SOURCE);
+
+ provider_release_list_value(selval);
+}
+
+/**
+* Evas_Smart_Cb type callback for handling focus out event.
+*
+* @param[in]: priv : the user data.
+* @param[in]: obj : the corresponding object which the focus out event occurred.
+* @param[in]: ev : event info.
+*
+* @return: void.
+*/
+static void _subitem_focusout_cb(void *priv, Evas_Object *obj, void *ev)
+{
+ struct _sysclk_data *data;
+ char *value;
+ char *selval;
+
+ if (!obj || !priv) {
+ _ERR("Invalid arguments\n");
+ return;
+ }
+
+ data = priv;
+
+ value = evas_object_data_get(obj, ITEMID);
+ if (!value) {
+ _ERR("Get value from btn failed\n");
+ return;
+ }
+
+ selval = _get_selected_value(data);
+ if (!selval) {
+ _ERR("_get_selected_value failed\n");
+ return;
+ }
+
+ if (!strncmp(selval, value, strlen(selval)))
+ elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_HIGHLIGHT,
+ CTXPOPUPBTN_BUTTON_SOURCE);
+ else
+ elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_UNFOCUSED,
+ CTXPOPUPBTN_BUTTON_SOURCE);
+
+ provider_release_list_value(selval);
+}
+
+/**
+* Evas_Smart_Cb type callback for handling click event.
+*
+* @param[in]: priv : the user data.
+* @param[in]: obj : the corresponding object which the click event occurred.
+* @param[in]: ev : event info.
+*
+* @return: void.
+*/
+static void _subitem_clicked_cb(void *priv, Evas_Object *obj, void *ev)
+{
+ struct _sysclk_data *data;
+ struct settingitem *item;
+ Eina_List *list;
+ char *value;
+ const char *id;
+ const char *name;
+
+ if (!priv || !obj)
+ return;
+
+ data = priv;
+
+ _set_selected_value(data, obj);
+
+ value = evas_object_data_get(obj, ITEMID);
+ if (!value) {
+ _ERR("get value from obj failed. DATA_ID: %s", ITEMID);
+ return;
+ }
+
+ if (!strncmp(value, MANUAL, BUF_SIZE)) {
+ _hide(data->base);
+
+ list = viewdata_get_childitems_list(data->vdata);
+ if (!list) {
+ _ERR("list of clock is null.");
+ return;
+ }
+
+ item = eina_list_nth(list, CLOCK_ITEM);
+ if (!item) {
+ _ERR("there is no clock_mode item in list.");
+ return;
+ }
+
+ id = settingitem_get_id(item);
+ if (!id) {
+ _ERR("get item id failed.");
+ return;
+ }
+
+ name = settingitem_get_display_name(item);
+ if (!name) {
+ _ERR("get display_name failed.");
+ return;
+ }
+
+ data->ugd.display_name = name;
+
+ settingmgr_view_push(data->mgr, id, (void *)&data->ugd);
+ } else {
+ _exit_view(data);
+ }
+}
+
+/**
+* Evas_Object_Event_Cb type callback for handling key press event.
+*
+* @param[in]: priv : the user data.
+* @param[in]: e : the evas canvas.
+* @param[in]: obj : the corresponding object which the key press event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _subitem_keypress_cb(void *priv, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _sysclk_data *data;
+
+ if (!priv || !ei)
+ return;
+
+ data = priv;
+ ev = ei;
+
+ if (!ev->keyname)
+ return;
+ if (!strncmp(ev->keyname, KEY_BACK, BUF_SIZE))
+ _exit_view(data);
+}
/**
* Create system clock sublist items.
@@ -174,28 +357,28 @@ static void _set_selected_value(SSystemClockView *data, Evas_Object *obj)
*
* @return: 0 - Success, -1 - Fail.
*/
-bool CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selval)
+static int _add_sysclk_sublist_item(struct _sysclk_data *data,
+ Eina_List *list, const char *selval)
{
Evas_Object *box, *cp, *btn, *del_btn;
Eina_Array *array;
Eina_Array_Iterator aiter;
struct listitem *li;
- void* obj;
Eina_List *iter;
const char *disp, *value;
- unsigned int idx, i, j;
+ int idx, i, j;
- if (!list || !m->ctxpopup || !selval) {
+ if (!data || !list || !data->ctxpopup || !selval) {
_ERR("invalid arguments.");
- return false;
+ return -1;
}
- cp = m->ctxpopup;
+ cp = data->ctxpopup;
box = utils_add_box(cp);
if (!box) {
_ERR("utils add box to ctxpopup failed.");
- return false;
+ return -1;
}
elm_object_content_set(cp, box);
@@ -204,12 +387,11 @@ bool CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selva
if (!array) {
_ERR("eina array new failed.");
evas_object_del(box);
- return false;
+ return -1;
}
i = idx = 0;
- EINA_LIST_FOREACH(list, iter, obj) {
- li = (struct listitem *) obj;
+ EINA_LIST_FOREACH(list, iter, li) {
disp = listitem_get_display_name(li);
if (!disp) {
_ERR("display name of list item is null.");
@@ -236,7 +418,15 @@ bool CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selva
}
evas_object_data_set(btn, ITEMID, value);
- Connect(btn, ID_BTNS, TYPE_FOCUSED | TYPE_UNFOCUSED | TYPE_CLICKED | TYPE_KEY_DOWN);
+
+ evas_object_smart_callback_add(btn, SIG_FOCUSED,
+ _subitem_focusin_cb, data);
+ evas_object_smart_callback_add(btn, SIG_UNFOCUSED,
+ _subitem_focusout_cb, data);
+ evas_object_smart_callback_add(btn, SIG_CLICKED,
+ _subitem_clicked_cb, data);
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN,
+ _subitem_keypress_cb, data);
elm_box_pack_end(box, btn);
eina_array_push(array, btn);
@@ -247,15 +437,14 @@ bool CSystemClockView::m_AddSysclkSublistItem(Eina_List *list, const char *selva
i++;
}
- m->box = box;
- m->array = array;
- m->sel_idx = idx;
+ data->box = box;
+ data->array = array;
+ data->sel_idx = idx;
- return true;
+ return 0;
error:
- EINA_ARRAY_ITER_NEXT(array, j, obj, aiter) {
- del_btn = (Evas_Object *) obj;
+ EINA_ARRAY_ITER_NEXT(array, j, del_btn, aiter) {
if (del_btn)
evas_object_del(del_btn);
}
@@ -263,7 +452,7 @@ error:
evas_object_del(box);
eina_array_free(array);
- return false;
+ return -1;
}
/**
@@ -273,38 +462,38 @@ error:
*
* @return: 0 - Success, -1 - Fail.
*/
-bool CSystemClockView::m_DrawSysclkSublist(void)
+static int _draw_sysclk_sublist(struct _sysclk_data *data)
{
Evas_Object *ctxpopup;
char *selval;
struct settingview_data *vdata;
struct obj_geometry_data *ogd;
Eina_List *itlist;
- int xpos, ypos, height, count;
+ int xpos, ypos, height, count, r;
double ratio;
- if (!m->ctxpopup || !m->ogd || !m->vdata) {
+ if (!data || !data->ctxpopup || !data->ogd || !data->vdata) {
_ERR("Invalid argument\n");
- return false;
+ return -1;
}
- ctxpopup = m->ctxpopup;
- vdata = m->vdata;
- ogd = m->ogd;
+ ctxpopup = data->ctxpopup;
+ vdata = data->vdata;
+ ogd = data->ogd;
count = 0;
itlist = _get_item_list(vdata, &count);
if (!itlist) {
_ERR("Get item list failed");
- return false;
+ return -1;
}
- m->count = count;
+ data->count = count;
- selval = _get_selected_value(m);
+ selval = _get_selected_value(data);
if (!selval) {
_ERR("Get selected value failed");
- return false;
+ return -1;
}
if (count > MAX_ITEMS) {
@@ -312,7 +501,8 @@ bool CSystemClockView::m_DrawSysclkSublist(void)
goto error;
}
- if (!m_AddSysclkSublistItem(itlist, selval)) {
+ r = _add_sysclk_sublist_item(data, itlist, selval);
+ if (r != 0) {
_ERR("add system clock sublist items failed.");
goto error;
}
@@ -326,22 +516,22 @@ bool CSystemClockView::m_DrawSysclkSublist(void)
xpos = ogd->x + ogd->width * ratio;
ypos = ogd->y;
- height = m->count * ITEM_HEIGHT;
+ height = data->count * ITEM_HEIGHT;
if (ypos > WIN_HEIGHT)
ypos = ypos - height;
evas_object_move(ctxpopup, xpos * ELM_SCALE, ypos * ELM_SCALE);
- utils_set_focus_directions(m->array, m->count);
+ utils_set_focus_directions(data->array, data->count);
provider_release_list_value(selval);
- return true;
+ return 0;
error:
provider_release_list_value(selval);
- return false;
+ return -1;
}
/**
@@ -353,34 +543,21 @@ error:
*
* @return: void.
*/
-void CSystemClockView::sm_CbCtxpopupDismissed(void *priv, Evas_Object *obj, void *ev)
+static void _ctxpopup_dismissed(void *priv, Evas_Object *obj,
+ void *ev)
{
- CSystemClockView *root = (CSystemClockView*)priv;
+ struct _sysclk_data *data;
- if (root)
- root->m_OnCtxpopupDismissed(obj, ev);
-}
-
-
-void CSystemClockView::m_OnCtxpopupDismissed(Evas_Object *obj, void *ev)
-{
- if (!obj)
+ if (!priv || !obj)
return;
- Hide();
-
- m->mgr->ViewPop();
-}
-
+ data = priv;
-Evas_Object* CSystemClockView::Base(void)
-{
- ASSERT(m);
+ _hide(data->base);
- return m->base;
+ settingmgr_view_pop(data->mgr);
}
-
/**
* Create all the UI components of system clock sublist view.
*
@@ -391,74 +568,75 @@ Evas_Object* CSystemClockView::Base(void)
* @return: the base layout of system clock view or null
* if error occurred.
*/
-bool CSystemClockView::Create(struct settingview_data *view, void *prev)
+static Evas_Object *_create(struct setting_mgr *mgr,
+ struct settingview_data *view, void *prev)
{
- ASSERT(!m);
- ASSERT(view);
- ASSERT(prev);
-
Evas_Object *base;
Evas_Object *ctxpopup;
Evas_Object *win;
+ struct _sysclk_data *data;
struct evas_obj_data *ugd;
struct obj_geometry_data *ogd;
- CSettingMgr *mgr = CSettingMgr::GetInstance();
+ if (!mgr || !view || !prev) {
+ _ERR("Invalid argument!\n");
+ return NULL;
+ }
- ugd = (struct evas_obj_data *) prev;
- ogd = (struct obj_geometry_data *) evas_object_data_get(ugd->cur_btn, DATA_ID);
+ ugd = prev;
+ ogd = evas_object_data_get(ugd->cur_btn, DATA_ID);
- win = mgr->Window();
- ASSERT(win);
+ win = settingmgr_get_win(mgr);
+ if (!win) {
+ _ERR("settingmgr get window failed.");
+ return NULL;
+ }
- m = new SSystemClockView;
- if (!m) {
+ data = calloc(1, sizeof(*data));
+ if (!data) {
_ERR("Unable to allocate memory.");
- return false;
+ return NULL;
}
- m->ugd = *ugd;
+ data->ugd = *ugd;
base = elm_layout_add(win);
if (!base) {
- delete m;
- m = NULL;
- return false;
+ free(data);
+ return NULL;
}
elm_layout_file_set(base, EDJ_FILE, SUBLIST_VIEW_PAGE);
- ctxpopup = utils_add_ctxpopup(win, (char *) SUBLIST_CTXPOPUP_STYLE1);
+ ctxpopup = utils_add_ctxpopup(win, SUBLIST_CTXPOPUP_STYLE1);
if (!ctxpopup) {
_ERR("Fail to add ctxpopup");
evas_object_del(base);
- delete m;
- m = NULL;
- return false;
+ free(data);
+ return NULL;
}
evas_object_smart_callback_add(ctxpopup, SIG_DISMISSED,
- sm_CbCtxpopupDismissed, this);
+ _ctxpopup_dismissed, data);
- m->mgr = mgr;
- m->win = win;
- m->base = base;
- m->ctxpopup = ctxpopup;
- m->vdata = view;
- m->ogd = ogd;
+ data->mgr = mgr;
+ data->win = win;
+ data->base = base;
+ data->ctxpopup = ctxpopup;
+ data->vdata = view;
+ data->ogd = ogd;
- evas_object_data_set(base, DATA_ID, m);
+ evas_object_data_set(base, DATA_ID, data);
- if (!m_DrawSysclkSublist()) {
+ if (_draw_sysclk_sublist(data) == -1) {
_ERR("Error in drawing items function\n");
evas_object_del(base);
evas_object_del(ctxpopup);
- delete m;
- m = NULL;
- return false;
+ free(data);
+ return NULL;
}
- return true;
+ return base;
}
/**
@@ -468,12 +646,23 @@ bool CSystemClockView::Create(struct settingview_data *view, void *prev)
*
* @return: void.
*/
-void CSystemClockView::Show(void)
+static void _show(Evas_Object *base)
{
- ASSERT(m);
+ struct _sysclk_data *data;
+
+ if (!base) {
+ _ERR("Invalid argument\n");
+ return;
+ }
- evas_object_show(m->ctxpopup);
- evas_object_show(m->base);
+ data = evas_object_data_get(base, DATA_ID);
+ if (!data) {
+ _ERR("Get sublist data failed\n");
+ return;
+ }
+
+ evas_object_show(data->ctxpopup);
+ evas_object_show(base);
}
/**
@@ -483,23 +672,33 @@ void CSystemClockView::Show(void)
*
* @return: void.
*/
-void CSystemClockView::Destroy(void)
+static void _destroy(Evas_Object *base)
{
- ASSERT(m);
+ struct _sysclk_data *data;
+
+ if (!base)
+ return;
+
+ data = evas_object_data_get(base, DATA_ID);
+ if (!data) {
+ _ERR("Invalid arguments");
+ evas_object_del(data->ctxpopup);
+ evas_object_del(base);
+ return;
+ }
- if (m->array) {
- eina_array_free(m->array);
- m->array = NULL;
+ if (data->array) {
+ eina_array_free(data->array);
+ data->array = NULL;
}
- evas_object_del(m->ctxpopup);
- evas_object_del(m->base);
+ evas_object_del(data->ctxpopup);
+ evas_object_del(base);
- if (m->vdata)
- viewdata_release(m->vdata);
+ if (data->vdata)
+ viewdata_release(data->vdata);
- delete m;
- m = NULL;
+ free(data);
}
/**
@@ -509,12 +708,21 @@ void CSystemClockView::Destroy(void)
*
* @return: void.
*/
-void CSystemClockView::Hide(void)
+static void _hide(Evas_Object *base)
{
- ASSERT(m);
+ struct _sysclk_data *data;
+
+ if (!base)
+ return;
- evas_object_hide(m->base);
- evas_object_hide(m->ctxpopup);
+ data = evas_object_data_get(base, DATA_ID);
+ if (!data) {
+ _ERR("Invalid arguments");
+ return;
+ }
+
+ evas_object_hide(base);
+ evas_object_hide(data->ctxpopup);
}
/**
@@ -524,149 +732,45 @@ void CSystemClockView::Hide(void)
*
* @return: void.
*/
-void CSystemClockView::Refresh(void)
-{
- ASSERT(m);
-
- m_ExitView();
-}
-
-
-void CSystemClockView::OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item)
-{
- char *value;
- char *selval;
-
- if (!obj) {
- _ERR("Invalid arguments\n");
- return;
- }
-
- value = (char *)evas_object_data_get(obj, ITEMID);
- if (!value) {
- _ERR("Get value from btn failed\n");
- return;
- }
-
- selval = _get_selected_value(m);
- if (!selval) {
- _ERR("_get_selected_value failed\n");
- return;
- }
-
- if (!strncmp(selval, value, strlen(selval))) {
- elm_object_signal_emit(obj, CTXPOPUPBTN_ICON_FOCUSED,
- CTXPOPUPBTN_ICON_SOURCE);
- }
-
- elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_FOCUSED,
- CTXPOPUPBTN_BUTTON_SOURCE);
-
- provider_release_list_value(selval);
-}
-
-
-void CSystemClockView::OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item)
+static void _refresh(Evas_Object *base)
{
- char *value;
- char *selval;
-
- if (!obj) {
- _ERR("Invalid arguments\n");
- return;
- }
+ struct _sysclk_data *data;
- value = (char *)evas_object_data_get(obj, ITEMID);
- if (!value) {
- _ERR("Get value from btn failed\n");
- return;
- }
-
- selval = _get_selected_value(m);
- if (!selval) {
- _ERR("_get_selected_value failed\n");
+ if (!base) {
+ _ERR("the base of system clock is null.");
return;
}
- if (!strncmp(selval, value, strlen(selval)))
- elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_HIGHLIGHT,
- CTXPOPUPBTN_BUTTON_SOURCE);
- else
- elm_object_signal_emit(obj, CTXPOPUPBTN_BUTTON_UNFOCUSED,
- CTXPOPUPBTN_BUTTON_SOURCE);
-
- provider_release_list_value(selval);
-}
-
-
-void CSystemClockView::OnMouseClicked(int oid, Evas_Object *obj)
-{
- if (oid != ID_BTNS)
- return;
-
- struct settingitem *item;
- Eina_List *list;
- char *value;
- const char *id;
- const char *name;
-
- if (!obj)
- return;
-
- _set_selected_value(m, obj);
-
- value = (char *)evas_object_data_get(obj, ITEMID);
- if (!value) {
- _ERR("get value from obj failed. DATA_ID: %s", ITEMID);
+ data = evas_object_data_get(base, DATA_ID);
+ if (!data) {
+ _ERR("data get failed. DATA_ID: %s", DATA_ID);
return;
}
- if (!strncmp(value, MANUAL, BUF_SIZE)) {
- Hide();
-
- list = viewdata_get_childitems_list(m->vdata);
- if (!list) {
- _ERR("list of clock is null.");
- return;
- }
-
- item = (struct settingitem *) eina_list_nth(list, CLOCK_ITEM);
- if (!item) {
- _ERR("there is no clock_mode item in list.");
- return;
- }
-
- id = settingitem_get_id(item);
- if (!id) {
- _ERR("get item id failed.");
- return;
- }
-
- name = settingitem_get_display_name(item);
- if (!name) {
- _ERR("get display_name failed.");
- return;
- }
-
- m->ugd.display_name = name;
-
- m->mgr->ViewPush(id, (void *)&m->ugd);
- }
- else {
- m_ExitView();
- }
+ _exit_view(data);
}
+/**
+* view class of system clock view.
+*/
+static struct setting_class _vclass = {
+ .title = VCLASS_TITLE_SYSTEM_CLOCK,
+ .create = _create,
+ .show = _show,
+ .destroy = _destroy,
+ .hide = _hide,
+ .refresh = _refresh,
+ .hide_view = 0
+};
-void CSystemClockView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
+/**
+* Return view class of system clock view.
+*
+* @param: void.
+*
+* @return: the view class of system clock view.
+*/
+struct setting_class *view_system_clock_get_vclass(void)
{
- if (id != ID_BTNS)
- return;
-
- if (!ev->keyname)
- return;
-
- if (!strncmp(ev->keyname, KEY_BACK, BUF_SIZE) || !strncmp(ev->keyname, KEY_BACK_REMOTE, BUF_SIZE))
- m_ExitView();
+ return &_vclass;
}
-
diff --git a/src/view_uigadget.c b/src/view_uigadget.c
new file mode 100644
index 0000000..7a722a8
--- /dev/null
+++ b/src/view_uigadget.c
@@ -0,0 +1,352 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <ui-gadget.h>
+#include "view_uigadget.h"
+#include "dbg.h"
+#include "def.h"
+
+#define DATA_ID "ugdata"
+
+struct _data {
+ Evas_Object *win;
+ Evas_Object *base;
+ Evas_Object *subbtn;
+ Evas_Object *main_item_box;
+ Evas_Object *subitem_box;
+
+ const char *display_name;
+ ui_gadget_h ug_handler;
+ Eina_Bool ug_is_existed;
+ struct setting_mgr *mgr;
+ struct settingview_data *view;
+};
+
+/**
+* This function is invoked to hide view layout.
+*
+* @param base [in] The view layout evas object.
+* @return void.
+*/
+static void _hide(Evas_Object *base)
+{
+ if (!base)
+ return;
+
+ evas_object_hide(base);
+}
+
+/**
+* Hide current ug launcher view, then pop this view from view list and return to main view.
+*
+* @param data [in] The function specific data which hold _data pointer.
+* @return void.
+*/
+static void _back_to_mainview(struct _data *data)
+{
+ if (!data)
+ return;
+
+ _hide(data->base);
+ settingmgr_view_pop(data->mgr);
+}
+
+/**
+* This callback function is invoked with base layout for layout arrangement
+* after UI Gadget create create operation is completed.
+*
+* @param ug [in] The handler data representing a UI gadget.
+* @param mode [in] The UI gadget mode.
+* @param priv [in] The function specific data passed by UG caller.
+* @return void.
+*/
+static void _ug_layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
+{
+}
+
+/**
+* After UG module invoke ug_send_message to send result,
+* UG library call this callback function registered by calling ug_create.
+*
+* @param ug [in] The handler data representing a UI gadget.
+* @param result [in] The Service handler.
+* @param priv [in] The function specific data passed by UG caller.
+* @return void.
+*/
+static void _ug_result_cb(ui_gadget_h ug, service_h result, void *priv)
+{
+}
+
+/**
+* This function is invoked to show sub item buttons evas object.
+*
+* @param box [in] The box evas object contained sub item buttons.
+* @return void.
+*/
+static void _show_item_btns(Evas_Object *box)
+{
+ Eina_List *list, *l;
+ Evas_Object *btn;
+
+ if (!box)
+ return;
+
+ list = elm_box_children_get(box);
+ if (!list) {
+ _ERR("button list is null.");
+ return;
+ }
+
+ EINA_LIST_FOREACH(list, l, btn)
+ evas_object_show(btn);
+
+ eina_list_free(list);
+}
+
+/**
+* Send the destroy request, use ug_destroy_me,
+* then UG library calls this callback function registered by UG caller.
+*
+* @param ug [in] The handler data representing a UI gadget.
+* @param priv [in] The function specific data passed by UG caller.
+* @return void.
+*/
+static void _ug_destroy_cb(ui_gadget_h ug, void *priv)
+{
+ struct _data *data;
+
+ if (!ug || !priv) {
+ _ERR("Invalid parameters in ug destroy callback.");
+ return;
+ }
+
+ data = priv;
+
+ _show_item_btns(data->subitem_box);
+
+ elm_object_focus_set(data->subbtn, EINA_TRUE);
+ elm_object_part_text_set(data->base, UG_TITLE_TEXT, "");
+
+ ug_destroy(ug);
+ data->ug_is_existed = EINA_FALSE;
+ _back_to_mainview(data);
+}
+
+/**
+* This function is invoked to create UI Gadget with specific UG name.
+*
+* @param data [in] The function specific data which hold _data pointer.
+* @return 0 if success, -1 if fail.
+*/
+static int _load_uigadget(struct _data *data)
+{
+ ui_gadget_h ug;
+ const char *name;
+ struct settingitem *parent;
+
+ struct ug_cbs cbs = {
+ .layout_cb = _ug_layout_cb,
+ .result_cb = _ug_result_cb,
+ .destroy_cb = _ug_destroy_cb,
+ .end_cb = NULL
+ };
+
+ if (!data) {
+ _ERR("private data is null.");
+ return -1;
+ }
+
+ cbs.priv = data;
+
+ parent = viewdata_get_parentitem(data->view);
+ name = settingitem_get_settingui_name(parent);
+ elm_object_part_text_set(data->base,
+ UG_TITLE_TEXT, data->display_name);
+
+ ug = ug_create(NULL, name, UG_MODE_FRAMEVIEW, NULL, &cbs);
+ if (!ug) {
+ _ERR("ug create failed.");
+ return -1;
+ } else {
+ data->ug_is_existed = EINA_TRUE;
+ data->ug_handler = ug;
+ settingmgr_freeze_timeout(data->mgr);
+ }
+
+ return 0;
+}
+
+/**
+* This function is invoked to hide sub item buttons evas object.
+*
+* @param box [in] The box evas object contained sub item buttons.
+* @return void.
+*/
+static void _hide_item_btns(Evas_Object *box)
+{
+ Eina_List *list, *l;
+ Evas_Object *btn;
+
+ if (!box) {
+ _ERR("item box is null.");
+ return;
+ }
+
+ list = elm_box_children_get(box);
+ if (!list) {
+ _ERR("button list is null.");
+ return;
+ }
+
+ EINA_LIST_FOREACH(list, l, btn)
+ evas_object_hide(btn);
+
+ eina_list_free(list);
+}
+
+/**
+* This function is invoked to create UG launcher view layout.
+*
+* @param mgr [in] The setting_mgr data pointer passed by @settingmgr_view_push.
+* @param view [in] The settingview_data data pointer passed by @settingmgr_view_push.
+* @param prev [in] The parameter data which passed by prev view or NULL.
+* @return View layout evas object, NULL on error.
+*/
+static Evas_Object *_create(struct setting_mgr *mgr,
+ struct settingview_data *view, void *prev)
+{
+ Evas_Object *win, *base;
+ struct _data *data;
+ struct evas_obj_data *param;
+ int r;
+
+ if (!mgr || !prev || !view) {
+ _ERR("mgr is null.");
+ return NULL;
+ }
+
+ param = prev;
+
+ _hide_item_btns(param->subitem_box);
+
+ win = settingmgr_get_win(mgr);
+ if (!win) {
+ _ERR("Invalid argument");
+ return NULL;
+ }
+
+ data = calloc(1, sizeof(struct _data));
+ if (!data) {
+ _ERR("calloc struct _data failed.");
+ return NULL;
+ }
+
+ base = elm_layout_add(win);
+ if (!base) {
+ _ERR("add base layout failed.");
+ free(data);
+ return NULL;
+ }
+
+ elm_layout_file_set(base, EDJ_FILE, UG_GROUP);
+
+ data->win = win;
+ data->base = base;
+ data->mgr = mgr;
+ data->view = view;
+ data->subitem_box = param->subitem_box;
+ data->display_name = param->display_name;
+ data->subbtn = param->cur_btn;
+ data->ug_is_existed = EINA_FALSE;
+
+ evas_object_data_set(base, DATA_ID, data);
+
+ r = _load_uigadget(data);
+ if (r == -1) {
+ _ERR("load ui gadget failed.");
+ free(data);
+ evas_object_del(base);
+ return NULL;
+ }
+
+ return base;
+}
+
+/**
+* This function is invoked to show view layout.
+*
+* @param base [in] The view layout evas object.
+* @return void.
+*/
+static void _show(Evas_Object *base)
+{
+ if (!base) {
+ _ERR("Invalid argument!");
+ return;
+ }
+
+ evas_object_show(base);
+}
+
+/**
+* This function is invoked to destroy view layout.
+*
+* @param base [in] The view layout evas object.
+* @return void.
+*/
+static void _destroy(Evas_Object *base)
+{
+ struct _data *data;
+
+ if (!base) {
+ _ERR("Invalid argument!");
+ return;
+ }
+
+ data = evas_object_data_get(base, DATA_ID);
+ if (!data) {
+ _ERR("Fail to get uglauncher data");
+ return;
+ }
+
+ if (data->ug_is_existed == EINA_TRUE)
+ ug_destroy(data->ug_handler);
+
+ if (data->view)
+ viewdata_release(data->view);
+
+ evas_object_del(base);
+ free(data);
+}
+
+static struct setting_class _vclass = {
+ .title = VCLASS_TITLE_UG,
+ .create = _create,
+ .show = _show,
+ .destroy = _destroy,
+ .hide = _hide,
+ .hide_view = 0
+};
+
+/**
+* This function is invoked to get UI Gadget launcher view class object.
+*
+* @return The setting_class data static pointer, NULL on error.
+*/
+struct setting_class *view_uigadget_get_vclass(void)
+{
+ return &_vclass;
+}
diff --git a/src/view_uigadget.cpp b/src/view_uigadget.cpp
deleted file mode 100644
index c0ccdb1..0000000
--- a/src/view_uigadget.cpp
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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 <ui-gadget.h>
-#include "view_uigadget.h"
-#include <AppCommon.h>
-#include "common_defs.h"
-#include "settingviewmgr.h"
-
-
-/**
- * This callback function is invoked with base layout for layout arrangement
- * after UI Gadget create create operation is completed.
- *
- * @param ug [in] The handler data representing a UI gadget.
- * @param mode [in] The UI gadget mode.
- * @param priv [in] The function specific data passed by UG caller.
- * @return void.
- */
-void CUiGadget::sm_CbLayout(ui_gadget_h ug, enum ug_mode mode, void *priv)
-{
- CUiGadget *root = (CUiGadget*)priv;
- if (root)
- root->t_OnLayout(ug, mode);
-}
-
-
-/**
- * After UG module invoke ug_send_message to send result,
- * UG library call this callback function registered by calling ug_create.
- *
- * @param ug [in] The handler data representing a UI gadget.
- * @param result [in] The Service handler.
- * @param priv [in] The function specific data passed by UG caller.
- * @return void.
- */
-void CUiGadget::sm_CbResult(ui_gadget_h ug, service_h result, void *priv)
-{
- CUiGadget *root = (CUiGadget*)priv;
- if (root)
- root->t_OnResult(ug, result);
-}
-
-
-
-/**
- * Send the destroy request, use ug_destroy_me,
- * then UG library calls this callback function registered by UG caller.
- *
- * @param ug [in] The handler data representing a UI gadget.
- * @param priv [in] The function specific data passed by UG caller.
- * @return void.
- */
-void CUiGadget::sm_CbDestroy(ui_gadget_h ug, void *priv)
-{
- CUiGadget *root = (CUiGadget*)priv;
- if (root)
- root->t_OnDestroy(ug);
-}
-
-
-void CUiGadget::sm_CbEnd(ui_gadget_h ug, void *priv)
-{
- CUiGadget *root = (CUiGadget*)priv;
- if (root)
- root->t_OnEnd(ug);
-}
-
-
-bool CUiGadget::Create(ui_gadget_h parent, const char *name, ug_mode mode, service_h service)
-{
- ASSERT(!m_handler);
-
- struct ug_cbs cbs = {
- sm_CbLayout,
- sm_CbResult,
- sm_CbDestroy,
- sm_CbEnd
- };
- cbs.priv = this;
-
- m_handler = ug_create(NULL, name, UG_MODE_FRAMEVIEW, NULL, &cbs);
-
- return m_handler ? true : false;
-}
-
-
-void CUiGadget::Destroy(void)
-{
- if (!m_handler)
- return;
-
- ug_destroy(m_handler);
- m_handler = NULL;
-}
-
-
-struct SUiGadgetView {
- Evas_Object *win;
- Evas_Object *base;
- Evas_Object *subbtn;
- Evas_Object *main_item_box;
- Evas_Object *subitem_box;
-
- const char *display_name;
- CSettingMgr *mgr;
- struct settingview_data *view;
-};
-
-/**
-* This function is invoked to hide view layout.
-*
-* @param base [in] The view layout evas object.
-* @return void.
-*/
-void CUiGadgetView::Hide(void)
-{
- ASSERT(m);
-
- evas_object_hide(m->base);
-}
-
-/**
-* Hide current ug launcher view, then pop this view from view list and return to main view.
-*
-* @param data [in] The function specific data which hold _data pointer.
-* @return void.
-*/
-void CUiGadgetView::m_BackToMainview(void)
-{
- Hide();
-
- m->mgr->ViewPop();
-}
-
-
-/**
-* This function is invoked to show sub item buttons evas object.
-*
-* @param box [in] The box evas object contained sub item buttons.
-* @return void.
-*/
-static void _show_item_btns(Evas_Object *box)
-{
- Eina_List *list, *l;
- Evas_Object *btn;
- void* obj;
-
- if (!box)
- return;
-
- list = elm_box_children_get(box);
- if (!list) {
- _ERR("button list is null.");
- return;
- }
-
- EINA_LIST_FOREACH(list, l, obj)
- {
- btn = (Evas_Object *) obj;
- evas_object_show(btn);
- }
-
- eina_list_free(list);
-}
-
-
-void CUiGadgetView::t_OnDestroy(ui_gadget_h ug)
-{
- if (!ug) {
- _ERR("Invalid parameters in ug destroy callback.");
- return;
- }
-
- _show_item_btns(m->subitem_box);
-
- elm_object_focus_set(m->subbtn, EINA_TRUE);
- elm_object_part_text_set(m->base, UG_TITLE_TEXT, "");
-
- CUiGadget::Destroy();
-
- m_BackToMainview();
-}
-
-/**
-* This function is invoked to create UI Gadget with specific UG name.
-*
-* @param data [in] The function specific data which hold _data pointer.
-* @return 0 if success, -1 if fail.
-*/
-bool CUiGadgetView::m_Load(void)
-{
- const char *name;
- struct settingitem *parent;
-
- parent = viewdata_get_parentitem(m->view);
- name = settingitem_get_settingui_name(parent);
- elm_object_part_text_set(m->base, UG_TITLE_TEXT, m->display_name);
-
- if (!CUiGadget::Create(NULL, name, UG_MODE_FRAMEVIEW, NULL)) {
- return false;
- }
-
- m->mgr->FreezeTimeout();
-
- return true;
-}
-
-
-/**
-* This function is invoked to hide sub item buttons evas object.
-*
-* @param box [in] The box evas object contained sub item buttons.
-* @return void.
-*/
-static void _hide_item_btns(Evas_Object *box)
-{
- Eina_List *list, *l;
- Evas_Object *btn;
- void* obj;
-
- if (!box) {
- _ERR("item box is null.");
- return;
- }
-
- list = elm_box_children_get(box);
- if (!list) {
- _ERR("button list is null.");
- return;
- }
-
- EINA_LIST_FOREACH(list, l, obj)
- {
- btn = (Evas_Object *) obj;
- evas_object_hide(btn);
- }
-
- eina_list_free(list);
-}
-
-
-Evas_Object *CUiGadgetView::Base(void)
-{
- ASSERT(m);
-
- return m->base;
-}
-
-
-/**
-* This function is invoked to create UG launcher view layout.
-*
-* @param mgr [in] The setting_mgr data pointer passed by @settingmgr_view_push.
-* @param view [in] The settingview_data data pointer passed by @settingmgr_view_push.
-* @param prev [in] The parameter data which passed by prev view or NULL.
-* @return View layout evas object, NULL on error.
-*/
-bool CUiGadgetView::Create(struct settingview_data *view, void *prev)
-{
- ASSERT(!m);
- ASSERT(view);
- ASSERT(prev);
-
- Evas_Object *win, *base;
- struct evas_obj_data *param;
-
- CSettingMgr *mgr = CSettingMgr::GetInstance();
-
- param = (struct evas_obj_data *) prev;
- _hide_item_btns(param->subitem_box);
-
- win = mgr->Window();
- ASSERT(win);
-
- m = new SUiGadgetView;
- if (!m) {
- _ERR("calloc SUiGadgetView failed.");
- return false;
- }
-
- base = elm_layout_add(win);
- if (!base) {
- _ERR("add base layout failed.");
- delete m;
- m = NULL;
- return false;
- }
-
- elm_layout_file_set(base, EDJ_FILE, UG_GROUP);
-
- m->win = win;
- m->base = base;
- m->mgr = mgr;
- m->view = view;
- m->subitem_box = param->subitem_box;
- m->display_name = param->display_name;
- m->subbtn = param->cur_btn;
-
- if (!m_Load()) {
- _ERR("load ui gadget failed.");
- evas_object_del(base);
- delete m;
- m = NULL;
-
- return false;
- }
-
- return true;
-}
-
-
-void CUiGadgetView::Show(void)
-{
- ASSERT(m);
-
- evas_object_show(m->base);
-}
-
-
-void CUiGadgetView::Destroy(void)
-{
- ASSERT(m);
-
- CUiGadget::Destroy();
-
- if (m->view)
- viewdata_release(m->view);
-
- evas_object_del(m->base);
- delete m;
- m = NULL;
-}
diff --git a/src/view_upgrade_popup.c b/src/view_upgrade_popup.c
new file mode 100644
index 0000000..c98ede9
--- /dev/null
+++ b/src/view_upgrade_popup.c
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "dbg.h"
+#include "utils.h"
+#include "view_upgrade_popup.h"
+
+static Evas_Object *_create(struct setting_mgr *mgr,
+ struct settingview_data *view, void *prev)
+{
+ return NULL;
+}
+
+static void _show(Evas_Object *base)
+{
+}
+
+static void _destroy(Evas_Object *base)
+{
+}
+
+static void _hide(Evas_Object *base)
+{
+}
+
+static struct setting_class _vclass = {
+ .title = VCLASS_TITLE_UPGRADE,
+ .create = _create,
+ .show = _show,
+ .destroy = _destroy,
+ .hide = _hide
+};
+
+struct setting_class *view_upgrade_popup_get_vclass(void)
+{
+ return &_vclass;
+}
diff --git a/src/settingviewmgr.cpp b/src/viewmgr.c
index c42637a..4bd4f6e 100644
--- a/src/settingviewmgr.cpp
+++ b/src/viewmgr.c
@@ -14,22 +14,28 @@
* limitations under the License.
*/
-#include <AppCommon.h>
-#include "settingviewmgr.h"
+#include <Elementary.h>
+#include <Eina.h>
+#include "viewmgr.h"
#include "data_wrapper.h"
+#include "dbg.h"
#include "timeout_handler.h"
#include "view_maincatalog.h"
#include "view_uigadget.h"
#include "view_sublist.h"
+#include "view_bottomsublist.h"
+#include "view_bottomslider.h"
#include "view_pwd_popup.h"
+#include "view_device_manager.h"
+#include "view_resetpopup.h"
+#include "view_upgrade_popup.h"
#include "view_system_clock.h"
#include "view_need_pwd.h"
-//#include "settingviewmgr.h"
#define MAINCATALOG "maincatalog"
#define PATH_FACTOR 3
-struct SSettingMgr {
+struct setting_mgr {
Evas_Object *win;
int depth;
@@ -38,43 +44,22 @@ struct SSettingMgr {
Eina_List *view_list;
struct settingmgr_data *data;
Eina_Array *item_path;
- CTimeoutHandler *handler;
+ struct timeout_handler *handler;
Eina_Bool is_freeze;
};
struct _settinginfo {
Evas_Object *base;
- CSettingBaseView *sclass;
+ struct setting_class *sclass;
struct settingview_data *sview;
};
struct settingui_func_map {
const char *style;
- CSettingBaseView *view;
- //struct setting_class* (*get_vclass)(void);
+ struct setting_class* (*get_vclass)(void);
};
-
-CSettingBaseView::CSettingBaseView(const char *pViewId)
-{
- m_title = new char[strlen(pViewId) + 1];
- strcpy(m_title, pViewId);
-}
-
-
-CSettingBaseView::~CSettingBaseView()
-{
- delete[] m_title;
-}
-
-
-Evas_Object *CSettingBaseView::Base(void)
-{
- return NULL;
-}
-
-
-static struct settingui_func_map g_func_map[5];/* = {
+static struct settingui_func_map g_func_map[] = {
{
.style = STYLE_UIGADGET,
.get_vclass = view_uigadget_get_vclass
@@ -84,28 +69,52 @@ static struct settingui_func_map g_func_map[5];/* = {
.get_vclass = view_sublist_get_vclass
},
{
+ .style = STYLE_BOTTOM_CTXPOPUP,
+ .get_vclass = view_bottomsublist_get_vclass
+ },
+ {
+ .style = STYLE_BOTTOMSLIDER,
+ .get_vclass = view_bottomslider_get_vclass
+ },
+ {
+ .style = STYLE_BOTTOM2WAYSLIDER,
+ .get_vclass = view_bottomslider_get_vclass
+ },
+ {
.style = STYLE_PASSCODE_POPUP,
.get_vclass = view_passcode_popup_get_vclass
},
{
+ .style = STYLE_DEVICE_MANAGER,
+ .get_vclass = view_device_manager_get_vclass
+ },
+ {
+ .style = STYLE_RESET_POPUP,
+ .get_vclass = view_resetpopup_get_vclass
+ },
+ {
+ .style = STYLE_UPGRADE_POPUP,
+ .get_vclass = view_upgrade_popup_get_vclass
+ },
+ {
.style = STYLE_CLOCK_CTXPOPUP,
.get_vclass = view_system_clock_get_vclass
},
{
.style = STYLE_NEED_PASSCODE,
.get_vclass = view_need_passcode_get_vclass
- }*/
-//};
+ }
+};
/**
* This function is invoked to build setting view data.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @param name[in] The item name to be created view.
* @return The settingview_data data pointer, NULL on error.
*/
static struct settingview_data *_build_setting_view(
- struct SSettingMgr *mgr, const char *name)
+ struct setting_mgr *mgr, const char *name)
{
struct settingview_data *data;
int r;
@@ -130,19 +139,17 @@ static struct settingview_data *_build_setting_view(
return data;
}
-
-CMainCatalogView *g_maincatalog;
/**
* This function is invoked to get setting_class data pointer, this data stand for a kind of view.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @param view[in] The settingview_data data pointer.
* @return The setting_class data pointer, NULL on error.
*/
-static CSettingBaseView *_get_view_class(SSettingMgr *mgr,
+static struct setting_class *_get_view_class(struct setting_mgr *mgr,
struct settingview_data *view)
{
- CSettingBaseView *vclass;
+ struct setting_class *vclass;
struct settingitem *parent;
Eina_List *list;
const char *style;
@@ -164,16 +171,14 @@ static CSettingBaseView *_get_view_class(SSettingMgr *mgr,
vclass = NULL;
if (list && !style) {
- if (mgr->depth == 1){
- g_maincatalog = new CMainCatalogView(VCLASS_TITLE_MAIN_VIEW);
- vclass = (CSettingBaseView *) g_maincatalog;// view_maincatalog_get_vclass();
- }
+ if (mgr->depth == 1)
+ vclass = view_maincatalog_get_vclass();
} else {
size = sizeof(g_func_map) / sizeof(*g_func_map);
for (i = 0; i < size; i++) {
if (!strncmp(style, g_func_map[i].style, strlen(style))
- && g_func_map[i].view) {
- vclass = g_func_map[i].view;// get_vclass();
+ && g_func_map[i].get_vclass) {
+ vclass = g_func_map[i].get_vclass();
break;
}
}
@@ -185,290 +190,251 @@ static CSettingBaseView *_get_view_class(SSettingMgr *mgr,
/**
* This function is invoked to hide all views stored in view list.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @return void.
*/
-void _hide_view_in_list(struct SSettingMgr *mgr)
+void _hide_view_in_list(struct setting_mgr *mgr)
{
Eina_List *l;
struct _settinginfo *sinfo;
- void* obj;
if (!mgr) {
_ERR("Invalid arguments\n");
return;
}
- EINA_LIST_FOREACH(mgr->view_list, l, obj) {
- sinfo = (struct _settinginfo *) obj;
- sinfo->sclass->Hide();
- //if (sinfo->sclass->hide)
- // sinfo->sclass->hide(sinfo->base);
+ EINA_LIST_FOREACH(mgr->view_list, l, sinfo) {
+ if (sinfo->sclass->hide)
+ sinfo->sclass->hide(sinfo->base);
}
}
/**
* This function is invoked to show all views stored in view list.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @return void.
*/
-void _show_view_in_list(struct SSettingMgr *mgr)
+void _show_view_in_list(struct setting_mgr *mgr)
{
Eina_List *l;
struct _settinginfo *sinfo;
- void* obj;
if (!mgr) {
_ERR("Invalid arguments\n");
return;
}
- EINA_LIST_FOREACH(mgr->view_list, l, obj) {
- sinfo = (struct _settinginfo *) obj;
- sinfo->sclass->Show();
- //if (sinfo->sclass->show)
- // sinfo->sclass->show(sinfo->base);
+ EINA_LIST_FOREACH(mgr->view_list, l, sinfo) {
+ if (sinfo->sclass->show)
+ sinfo->sclass->show(sinfo->base);
}
}
/**
* This function is invoked to destroy all views stored in view list.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @return void.
*/
-void _destroy_views_in_list(struct SSettingMgr *mgr)
+void _destroy_views_in_list(struct setting_mgr *mgr)
{
Eina_List *l;
struct _settinginfo *sinfo;
- void* obj;
if (!mgr) {
_ERR("Invalid arguments\n");
return;
}
- EINA_LIST_FOREACH(mgr->view_list, l, obj) {
- sinfo = (struct _settinginfo *) obj;
- sinfo->sclass->Destroy();
- //if (sinfo->sclass->destroy)
- // sinfo->sclass->destroy(sinfo->base);
+ EINA_LIST_FOREACH(mgr->view_list, l, sinfo) {
+ if (sinfo->sclass->destroy)
+ sinfo->sclass->destroy(sinfo->base);
}
}
/**
* This function is invoked to freeze all views's event stored in view list.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @return void.
*/
-void _frozen_view_in_list(struct SSettingMgr *mgr)
+void _frozen_view_in_list(struct setting_mgr *mgr)
{
Eina_List *l;
struct _settinginfo *sinfo;
- void* obj;
if (!mgr) {
_ERR("Invalid argument");
return;
}
- if(mgr->view_list) {
- EINA_LIST_REVERSE_FOREACH(mgr->view_list, l, obj) {
- sinfo = (struct _settinginfo *)obj;
- sinfo->sclass->Frozen();
- //if (sinfo->sclass->frozen)
- // sinfo->sclass->frozen(sinfo->base);
- }
+ EINA_LIST_REVERSE_FOREACH(mgr->view_list, l, sinfo) {
+ if (sinfo->sclass->frozen)
+ sinfo->sclass->frozen(sinfo->base);
}
}
/**
* This function is invoked to activate all views's event stored in view list.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @return void.
*/
-void _active_view_in_list(struct SSettingMgr *mgr)
+void _active_view_in_list(struct setting_mgr *mgr)
{
Eina_List *l;
struct _settinginfo *sinfo;
- void* obj;
if (!mgr) {
_ERR("Invalid argument");
return;
}
- EINA_LIST_REVERSE_FOREACH(mgr->view_list, l, obj) {
- sinfo = (struct _settinginfo *)obj;
- sinfo->sclass->Active();
- //if (sinfo->sclass->active)
- // sinfo->sclass->active(sinfo->base);
+ EINA_LIST_REVERSE_FOREACH(mgr->view_list, l, sinfo) {
+ if (sinfo->sclass->active)
+ sinfo->sclass->active(sinfo->base);
}
}
-
-
-CSettingMgr *CSettingMgr::instance = NULL;
-
/**
* This function is invoked to initialize setting manager.
*
* @param win [in] The window's evas object.
-* @return The SSettingMgr data pointer.
+* @return The setting_mgr data pointer.
*/
-bool CSettingMgr::Initialize(Evas_Object *win)
+struct setting_mgr *settingmgr_init(Evas_Object *win)
{
- ASSERT(!instance);
- ASSERT(win);
-
- //struct settingmgr_data *data;
- //CTimeoutHandler *handler;
-
- _CREATE_BEGIN{
- _CHECK(instance = new CSettingMgr);
- _CHECK(instance->m = new SSettingMgr);
- _CHECK(instance->m->data = viewmgr_data_init());
- _CHECK(instance->m->handler = new CTimeoutHandler);
- _CHECK(instance->m->handler->Create(TIMEOUT_SECS));
-
- _CHECK_FAIL{ instance->m->handler->Destroy(); }
- _CHECK_FAIL{ delete instance->m->handler; }
- _CHECK_FAIL{ viewmgr_data_fini(instance->m->data); }
- _CHECK_FAIL{ delete instance->m; }
- _CHECK_FAIL{ delete instance; instance = NULL; }
- } _CREATE_END_AND_CATCH{ return false; }
-
- g_func_map[0].style = STYLE_UIGADGET;
- g_func_map[0].view = new CUiGadgetView(VCLASS_TITLE_UG);
-
- g_func_map[1].style = STYLE_CTXPOPUP;
- g_func_map[1].view = new CSublistView(VCLASS_TITLE_SUBLIST);
-
- g_func_map[2].style = STYLE_PASSCODE_POPUP;
- g_func_map[2].view = new CPasscodePopupView(VCLASS_TITLE_CHANGE_PASSCODE);
-
- g_func_map[3].style = STYLE_CLOCK_CTXPOPUP;
- g_func_map[3].view = new CSystemClockView(VCLASS_TITLE_SYSTEM_CLOCK);
-
- g_func_map[4].style = STYLE_NEED_PASSCODE;
- g_func_map[4].view = new CNeedPasscodeView(VCLASS_TITLE_NEED_PASSCODE);
-
- instance->m->win = win;
- instance->m->depth = 0;
- instance->m->is_freeze = EINA_FALSE;
- instance->m->view_list = NULL;
- instance->m->item_path = NULL;
-
- return true;
-}
+ struct setting_mgr *mgr;
+ struct settingmgr_data *data;
+ struct timeout_handler *handler;
+ if (!win)
+ return NULL;
+
+ mgr = calloc(1, sizeof(*mgr));
+ if (!mgr)
+ return NULL;
+
+ data = viewmgr_data_init();
+ if (!data) {
+ _ERR("viewmgr_data_init failed!");
+ free(mgr);
+ return NULL;
+ }
+
+ handler = timeout_handler_init(TIMEOUT_SECS);
+ if (!handler) {
+ _ERR("Fail to init timeout handler");
+ viewmgr_data_fini(data);
+ free(mgr);
+ return NULL;
+ }
+
+ mgr->win = win;
+ mgr->depth = 0;
+ mgr->data = data;
+ mgr->handler = handler;
+ mgr->is_freeze = EINA_FALSE;
+
+ return mgr;
+}
/**
* This function is invoked to destroy all views stored in view list and release
-* SSettingMgr data structure.
+* setting_mgr data structure.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @return void.
*/
-void CSettingMgr::Finalize(void)
+void settingmgr_fini(struct setting_mgr *mgr)
{
- ASSERT(instance);
- ASSERT(instance->m);
-
struct _settinginfo *sinfo;
- void* obj;
-
- _hide_view_in_list(instance->m);
- _destroy_views_in_list(instance->m);
- EINA_LIST_FREE(instance->m->view_list, obj)
- {
- sinfo = (struct _settinginfo *)obj;
- free(sinfo);
+ if (!mgr) {
+ _ERR("Parameter error!");
+ return;
}
- if (instance->m->item_path)
- eina_array_free(instance->m->item_path);
+ _hide_view_in_list(mgr);
+ _destroy_views_in_list(mgr);
- viewmgr_data_fini(instance->m->data);
- instance->m->handler->Destroy();
- delete instance->m->handler;
+ EINA_LIST_FREE(mgr->view_list, sinfo)
+ free(sinfo);
- delete instance->m;
- delete instance;
- instance = NULL;
-}
+ if (mgr->item_path)
+ eina_array_free(mgr->item_path);
+ viewmgr_data_fini(mgr->data);
+ timeout_handler_fini(mgr->handler);
-CSettingMgr *CSettingMgr::GetInstance(void)
-{
- return instance;
+ free(mgr);
}
-
/**
* This function is invoked to push a view with specific name and data.
*
* Firstly, it will build view data, then get specific view class to create view.
* Otherwise, it will freeze or hide background view and store _settinginfo data into view list.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @param name [in] The item name to be pushed view.
* @param data [in] The function specific data passed by caller.
* @return 0 if success, -1 if fail.
*/
-bool CSettingMgr::ViewPush(const char *name, void *data)
+int settingmgr_view_push(struct setting_mgr *mgr,
+ const char *name, void *data)
{
- ASSERT(m);
- ASSERT(name);
+ Evas_Object *base;
+ struct _settinginfo *sinfo;
+ struct setting_class *sclass;
+ struct settingview_data *view;
- struct _settinginfo *sinfo = NULL;
- CSettingBaseView *sclass = NULL;
- struct settingview_data *view = NULL;
+ if (!mgr || !name)
+ return -1;
- m->depth++;
+ mgr->depth++;
- sinfo = new _settinginfo;
+ sinfo = calloc(1, sizeof(*sinfo));
if (!sinfo)
- return false;
+ return -1;
- view = _build_setting_view(m, name);
+ view = _build_setting_view(mgr, name);
if (!view) {
_ERR("Build setting view data failed\n");
goto error;
}
- sclass = _get_view_class(m, view);
+ sclass = _get_view_class(mgr, view);
if (!sclass) {
_ERR("failed to get view class.");
goto error;
}
- if (!sclass->Create(view, data)) {
+ base = sclass->create(mgr, view, data);
+ if (!base) {
_ERR("failed to create base layout.");
goto error;
}
- _frozen_view_in_list(m);
+ _frozen_view_in_list(mgr);
if (sclass->hide_view)
- _hide_view_in_list(m);
+ _hide_view_in_list(mgr);
- sclass->Show();
+ if (sclass->show)
+ sclass->show(base);
- sinfo->base = sclass->Base();
+ sinfo->base = base;
sinfo->sclass = sclass;
sinfo->sview = view;
- m->view_list = eina_list_prepend(m->view_list, sinfo);
+ mgr->view_list = eina_list_prepend(mgr->view_list, sinfo);
return 0;
error:
- m->depth--;
+ mgr->depth--;
free(sinfo);
viewdata_release(view);
@@ -481,21 +447,24 @@ error:
* Firstly, get top view's _settinginfo data from view list, then call destroy interface of
* view class, finally it will refresh second view, activate and show all views behind top view.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @return void.
*/
-void CSettingMgr::ViewPop(void)
+void settingmgr_view_pop(struct setting_mgr *mgr)
{
- ASSERT(m);
-
struct _settinginfo *sinfo, *prev;
- CSettingBaseView *sclass;
+ struct setting_class *sclass;
int hide;
char *item;
const char *title;
- m->depth--;
- sinfo = (struct _settinginfo *) eina_list_data_get(m->view_list);
+ if (!mgr) {
+ _ERR("Invalid arguments\n");
+ return;
+ }
+
+ mgr->depth--;
+ sinfo = eina_list_data_get(mgr->view_list);
if (!sinfo) {
_DBG("get sinfo failed\n");
return;
@@ -503,22 +472,23 @@ void CSettingMgr::ViewPop(void)
sclass = sinfo->sclass;
hide = sclass->hide_view;
- title = sclass->Title();
+ title = sclass->title;
item = NULL;
if (!strncmp(title, VCLASS_TITLE_BOTTOM_SLIDER, strlen(title)))
- item = (char *)evas_object_data_del(sinfo->base, SELECTED_ITEM_ID);
+ item = evas_object_data_del(sinfo->base, SELECTED_ITEM_ID);
- sclass->Destroy();
+ if (sclass->destroy && sinfo->base)
+ sclass->destroy(sinfo->base);
- m->view_list = eina_list_remove_list(m->view_list, m->view_list);
+ mgr->view_list = eina_list_remove_list(mgr->view_list, mgr->view_list);
free(sinfo);
- if (!m->view_list)
+ if (!mgr->view_list)
return;
- prev = (struct _settinginfo *) eina_list_data_get(m->view_list);
+ prev = eina_list_data_get(mgr->view_list);
if (!prev || !prev->sclass)
return;
@@ -527,67 +497,75 @@ void CSettingMgr::ViewPop(void)
if (item && !strncmp(title, VCLASS_TITLE_BOTTOM_SLIDER, strlen(title)))
evas_object_data_set(prev->base, SELECTED_ITEM_ID, item);
- sclass->Refresh();
- sclass->Update();
+ if (sclass->refresh)
+ sclass->refresh(prev->base);
+
+ if (sclass->update)
+ sclass->update(prev->base);
- _active_view_in_list(m);
+ _active_view_in_list(mgr);
if (hide)
- _show_view_in_list(m);
+ _show_view_in_list(mgr);
}
/**
* This function is invoked to get window's evas object.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @return The window's evas object, NULL on error.
*/
-Evas_Object *CSettingMgr::Window(void)
+Evas_Object *settingmgr_get_win(struct setting_mgr *mgr)
{
- ASSERT(m);
+ if (!mgr)
+ return NULL;
- return m->win;
+ return mgr->win;
}
/**
* This function is invoked to get view data with specific name.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @param name [in] The view name to be got.
* @return The settingview_data data pointer, NULL on error.
*/
-settingview_data *CSettingMgr::GetView(const char *name)
+struct settingview_data *settingmgr_get_view(struct setting_mgr *mgr,
+ const char *name)
{
- ASSERT(m);
-
- return _build_setting_view(m, name);
+ return _build_setting_view(mgr, name);
}
/**
* This function is invoked to get setting manager data.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @return The settingmgr_data data pointer, NULL on error.
*/
-settingmgr_data *CSettingMgr::GetData(void)
+struct settingmgr_data *settingmgr_get_data(struct setting_mgr *mgr)
{
- ASSERT(m);
+ if (!mgr) {
+ _ERR("Parameter error!");
+ return NULL;
+ }
- return m->data;
+ return mgr->data;
}
/**
* This function is invoked to get view list.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @return The Eina_List data pointer, NULL on error.
*/
-Eina_List *CSettingMgr::GetViewList(void)
+Eina_List *settingmgr_get_view_list(struct setting_mgr *mgr)
{
- ASSERT(m);
-
+ if (!mgr) {
+ _ERR("Parameter error!");
+ return NULL;
+ }
- return m->view_list;
+ return mgr->view_list;
}
/**
@@ -596,24 +574,25 @@ Eina_List *CSettingMgr::GetViewList(void)
* When launch setting by command-line, this function will be invoked. In this launching
* way, setting will be launched and move focus to specific item.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @param name [in] The item name.
* @return 0 if success, -1 if fail.
*/
-bool CSettingMgr::LaunchItem(const char *name)
+int settingmgr_launch_item(struct setting_mgr *mgr,
+ const char *name)
{
- ASSERT(m);
- ASSERT(name);
-
const char *parent;
struct settingitem *item;
Eina_Array *path;
int i, cnt;
+ if (!mgr || !name)
+ return -1;
+
path = eina_array_new(1);
if (!path) {
_ERR("new eina array failed.");
- return false;
+ return -1;
}
eina_array_push(path, name);
@@ -622,15 +601,15 @@ bool CSettingMgr::LaunchItem(const char *name)
if (!parent) {
_ERR("get parent item name failed.");
eina_array_free(path);
- return false;
+ return -1;
}
eina_array_push(path, parent);
do {
- viewmgr_data_read_jsonfile_into_hash(m->data, parent);
+ viewmgr_data_read_jsonfile_into_hash(mgr->data, parent);
- item = viewmgr_data_get_settingitem(m->data, parent);
+ item = viewmgr_data_get_settingitem(mgr->data, parent);
if (!item)
break;
@@ -638,18 +617,16 @@ bool CSettingMgr::LaunchItem(const char *name)
eina_array_push(path, parent);
} while (parent && strncmp(parent, MAINCATALOG, strlen(parent)));
- m->item_path = path;
-
-
- ViewPush(MAINCATALOG, NULL);
+ mgr->item_path = path;
+ settingmgr_view_push(mgr, MAINCATALOG, NULL);
cnt = eina_array_count(path);
for (i = cnt - PATH_FACTOR; i > 0; i--)
- ViewPush((const char *) eina_array_data_get(path, i), NULL);
+ settingmgr_view_push(mgr, eina_array_data_get(path, i), NULL);
- return true;
+ return 0;
}
/**
@@ -658,164 +635,178 @@ bool CSettingMgr::LaunchItem(const char *name)
* Item path is a value described all node value from root node to item
* in setting tree of json files.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @return The Eina_Array data pointer, NULL on error.
*/
-Eina_Array *CSettingMgr::GetItemPath(void)
+Eina_Array *settingmgr_get_item_path(struct setting_mgr *mgr)
{
- ASSERT(m);
+ if (!mgr || !mgr->item_path)
+ return NULL;
- return m->item_path;
+ return mgr->item_path;
}
/**
* This function is invoked to refresh all view stored in view list.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @return void.
*/
-void CSettingMgr::ViewRefresh(void)
+void settingmgr_view_refresh(struct setting_mgr *mgr)
{
- ASSERT(m);
-
struct _settinginfo *info;
- CSettingBaseView *vclass;
+ struct setting_class *vclass;
- if (!m->view_list)
+ if (!mgr || !mgr->view_list)
return;
- info = (struct _settinginfo *) eina_list_data_get(m->view_list);
+ info = eina_list_data_get(mgr->view_list);
if (!info)
return;
vclass = info->sclass;
- vclass->Refresh();
- vclass->Update();
+ if (vclass->refresh)
+ vclass->refresh(info->base);
+
+ if (vclass->update)
+ vclass->update(info->base);
}
/**
* This function is invoked to set refresh flag.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @param val [in] The value to be set.
* @return void.
*/
-void CSettingMgr::SetRefreshFlag(unsigned int val)
+void settingmgr_set_refresh_flag(struct setting_mgr *mgr,
+ unsigned int val)
{
- ASSERT(m);
+ if (!mgr)
+ return;
- m->refresh = val;
+ mgr->refresh = val;
}
/**
* This function is invoked to get refresh flag.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @return The refresh flag value, -1 if fail.
*/
-unsigned int CSettingMgr::GetRefreshFlag(void)
+unsigned int settingmgr_get_refresh_flag(struct setting_mgr *mgr)
{
- ASSERT(m);
+ if (!mgr)
+ return -1;
- return m->refresh;
+ return mgr->refresh;
}
/**
* This function is invoked to set relaunch flag.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @param val [in] The value to be set.
* @return void.
*/
-void CSettingMgr::SetRelaunchFlag(unsigned int val)
+void settingmgr_set_relaunch_flag(struct setting_mgr *mgr,
+ unsigned int val)
{
- ASSERT(m);
+ if (!mgr)
+ return;
- m->relaunch = val;
+ mgr->relaunch = val;
}
/**
* This function is invoked to get relaunch flag.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @return The refresh flag value, -1 if fail.
*/
-unsigned int CSettingMgr::GetRelaunchFlag(void)
+unsigned int settingmgr_get_relaunch_flag(struct setting_mgr *mgr)
{
- ASSERT(m);
+ if (!mgr)
+ return -1;
- return m->relaunch;
+ return mgr->relaunch;
}
/**
* This function wrapped timeout_handler interface to freeze timer.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @return void.
*/
-void CSettingMgr::FreezeTimeout(void)
+void settingmgr_freeze_timeout(struct setting_mgr *mgr)
{
- ASSERT(m);
+ if (!mgr) {
+ _ERR("Invalid argument");
+ return;
+ }
- m->is_freeze = EINA_TRUE;
- m->handler->FreezeTimer();
+ mgr->is_freeze = EINA_TRUE;
+ timeout_handler_freeze_timer(mgr->handler);
}
/**
* This function wrapped timeout_handler interface to thaw timer.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @return void.
*/
-void CSettingMgr::ThawTimeout(void)
+void settingmgr_thaw_timeout(struct setting_mgr *mgr)
{
- ASSERT(m);
+ if (!mgr) {
+ _ERR("Invalid argument");
+ return;
+ }
- m->handler->ThawTimer();
- m->is_freeze = EINA_FALSE;
+ timeout_handler_thaw_timer(mgr->handler);
+ mgr->is_freeze = EINA_FALSE;
}
/**
* This function is invoked to get timeout freeze state.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @return EINA_TRUE if current state is frozen
* EINA_FALSE if current state is normal or occurred error.
*/
-Eina_Bool CSettingMgr::GetTimeoutFreezeState(void)
+Eina_Bool settingmgr_get_timeout_freeze_state(struct setting_mgr *mgr)
{
- ASSERT(m);
+ if (!mgr) {
+ _ERR("Invalid argument");
+ return EINA_FALSE;
+ }
- return m->is_freeze;
+ return mgr->is_freeze;
}
/**
* This function is invoked to refresh all views when system language changed.
*
-* @param mgr [in] The SSettingMgr data pointer.
+* @param mgr [in] The setting_mgr data pointer.
* @return void.
*/
-void CSettingMgr::LangChanged(void)
+void settingmgr_lang_changed(struct setting_mgr *mgr)
{
- ASSERT(m);
-
struct _settinginfo *sinfo;
Eina_List *l;
- void* obj;
- if (!m->view_list) {
+ if (!mgr || !mgr->view_list) {
_ERR("Invalid argument");
return;
}
- EINA_LIST_FOREACH(m->view_list, l, obj) {
- sinfo = (struct _settinginfo *) obj;
+ EINA_LIST_FOREACH(mgr->view_list, l, sinfo) {
if (!sinfo || !sinfo->sclass) {
_ERR("settings info is NULL");
return;
}
- sinfo->sclass->LangChanged();
+ if (sinfo->sclass->lang_changed)
+ sinfo->sclass->lang_changed(sinfo->base);
}
}
diff --git a/testcase/settings.txt b/testcase/settings.txt
deleted file mode 100644
index e8805fd..0000000
--- a/testcase/settings.txt
+++ /dev/null
@@ -1 +0,0 @@
-settings_all.txt
diff --git a/testcase/settings_all.txt b/testcase/settings_all.txt
deleted file mode 100644
index 62a33ea..0000000
--- a/testcase/settings_all.txt
+++ /dev/null
@@ -1,462 +0,0 @@
-# Sound
-Key Pressed
-Down 1000
-Key Released
-Down 104
-Key Pressed
-Right 2168
-Key Released
-Right 112
-Key Pressed
-Return 1096
-Key Released
-Return 80
-Key Pressed
-Down 664
-Key Released
-Down 96
-Key Pressed
-Return 848
-Key Released
-Return 80
-Key Pressed
-Return 1040
-Key Released
-Return 80
-Key Pressed
-Down 576
-Key Released
-Down 104
-Key Pressed
-Down 128
-Key Released
-Down 112
-Key Pressed
-Return 680
-Key Released
-Return 80
-Key Pressed
-Return 904
-Key Released
-Return 88
-Key Pressed
-Down 584
-Key Released
-Down 104
-Key Pressed
-Down 96
-Key Released
-Down 112
-Key Pressed
-Down 144
-Key Released
-Down 96
-Key Pressed
-Return 848
-Key Released
-Return 72
-Key Pressed
-Left 1304
-Key Released
-Left 112
-# Systems
-Key Pressed
-Down 1000
-Key Released
-Down 104
-Key Pressed
-Right 616
-Key Released
-Right 96
-Key Pressed
-Down 255
-Key Released
-Down 137
-Key Pressed
-Left 416
-Key Released
-Left 120
-Key Pressed
-Down 456
-Key Released
-Down 112
-Key Pressed
-Right 336
-Key Released
-Right 138
-Key Pressed
-Down 334
-Key Released
-Down 112
-Key Pressed
-Down 280
-Key Released
-Down 120
-Key Pressed
-Left 392
-Key Released
-Left 120
-Key Pressed
-Down 336
-Key Released
-Down 144
-Key Pressed
-Right 360
-Key Released
-Right 136
-Key Pressed
-Down 1168
-Key Released
-Down 120
-Key Pressed
-Right 1824
-Key Released
-Right 168
-Key Pressed
-Down 2216
-Key Released
-Down 152
-Key Pressed
-Down 2568
-Key Released
-Down 160
-Key Pressed
-Down 392
-Key Released
-Down 136
-Key Pressed
-Down 760
-Key Released
-Down 152
-Key Pressed
-Return 4488
-Key Released
-Return 112
-Key Pressed
-Down 1424
-Key Released
-Down 136
-Key Pressed
-Return 424
-Key Released
-Return 96
-Key Pressed
-Escape 1720
-Key Released
-Escape 96
-Key Pressed
-Up 880
-Key Released
-Up 96
-Key Pressed
-Return 800
-Key Released
-Return 72
-Key Pressed
-Down 448
-Key Released
-Down 96
-Key Pressed
-Return 136
-Key Released
-Return 88
-Key Pressed
-Escape 1120
-Key Released
-Escape 104
-Key Pressed
-Right 1576
-Key Released
-Right 136
-Key Pressed
-Down 448
-Key Released
-Down 136
-Key Pressed
-Down 335
-Key Released
-Down 153
-Key Pressed
-Down 272
-Key Released
-Down 152
-Key Pressed
-Return 576
-Key Released
-Return 72
-Key Pressed
-Down 520
-Key Released
-Down 96
-Key Pressed
-Return 24
-Key Released
-Return 64
-Key Pressed
-Down 664
-Key Released
-Down 80
-Key Pressed
-Down 136
-Key Released
-Down 144
-Key Pressed
-Return 120
-Key Released
-Return 104
-Key Pressed
-Down 368
-Key Released
-Down 104
-Key Pressed
-Return 88
-Key Released
-Return 112
-Key Pressed
-Down 352
-Key Released
-Down 88
-Key Pressed
-Down 80
-Key Released
-Down 96
-Key Pressed
-Down 88
-Key Released
-Down 152
-Key Pressed
-Return 216
-Key Released
-Return 104
-Key Pressed
-Down 296
-Key Released
-Down 112
-Key Pressed
-Return 248
-Key Released
-Return 120
-Key Pressed
-Down 496
-Key Released
-Down 104
-Key Pressed
-Down 80
-Key Released
-Down 112
-Key Pressed
-Down 80
-Key Released
-Down 152
-Key Pressed
-Return 256
-Key Released
-Return 104
-Key Pressed
-Down 128
-Key Released
-Down 104
-Key Pressed
-Down 72
-Key Released
-Down 96
-Key Pressed
-Return 144
-Key Released
-Return 104
-Key Pressed
-Down 448
-Key Released
-Down 104
-Key Pressed
-Down 248
-Key Released
-Down 104
-Key Pressed
-Return 24
-Key Released
-Return 112
-Key Pressed
-Down 416
-Key Released
-Down 112
-Key Pressed
-Return 24
-Key Released
-Return 96
-Key Pressed
-Down 720
-Key Released
-Down 112
-Key Pressed
-Return 24
-Key Released
-Return 96
-Key Pressed
-Down 440
-Key Released
-Down 72
-Key Pressed
-Down 104
-Key Released
-Down 88
-Key Pressed
-Return 104
-Key Released
-Return 112
-Key Pressed
-Up 584
-Key Released
-Up 88
-Key Pressed
-Up 88
-Key Released
-Up 104
-Key Pressed
-Down 352
-Key Released
-Down 96
-Key Pressed
-Return 16
-Key Released
-Return 80
-Key Pressed
-Down 56
-Key Released
-Down 104
-Key Pressed
-Down 80
-Key Released
-Down 96
-Key Pressed
-Down 80
-Key Released
-Down 88
-Key Pressed
-Down 80
-Key Released
-Down 96
-Key Pressed
-Down 64
-Key Released
-Down 104
-Key Pressed
-Down 72
-Key Released
-Down 128
-Key Pressed
-Down 232
-Key Released
-Down 96
-Key Pressed
-Return 24
-Key Released
-Return 72
-Key Pressed
-Up 976
-Key Released
-Up 112
-Key Pressed
-Return 256
-Key Released
-Return 120
-Key Pressed
-Up 352
-Key Released
-Up 128
-Key Pressed
-Return 168
-Key Released
-Return 112
-Key Pressed
-Up 328
-Key Released
-Up 88
-Key Pressed
-Up 104
-Key Released
-Up 72
-Key Pressed
-Return 360
-Key Released
-Return 104
-Key Pressed
-Down 24
-Key Released
-Down 88
-Key Pressed
-Up 752
-Key Released
-Up 104
-Key Pressed
-Return 24
-Key Released
-Return 72
-Key Pressed
-Down 480
-Key Released
-Down 104
-Key Pressed
-Up 152
-Key Released
-Up 88
-Key Pressed
-Up 80
-Key Released
-Up 112
-Key Pressed
-Up 80
-Key Released
-Up 104
-Key Pressed
-Down 336
-Key Released
-Down 104
-Key Pressed
-Return 272
-Key Released
-Return 112
-Key Pressed
-Down 328
-Key Released
-Down 120
-Key Pressed
-Down 72
-Key Released
-Down 80
-Key Pressed
-Down 80
-Key Released
-Down 104
-Key Pressed
-Down 64
-Key Released
-Down 80
-Key Pressed
-Down 72
-Key Released
-Down 104
-Key Pressed
-Down 88
-Key Released
-Down 120
-Key Pressed
-Up 216
-Key Released
-Up 96
-Key Pressed
-Return 24
-Key Released
-Return 64
-Key Pressed
-Escape 1600
-Key Released
-Escape 96
-Key Pressed
-Down 72
-Key Released
-Down 160
-Key Pressed
-Escape 1000
-Key Released
-Escape 88
diff --git a/ug/channel/CMakeLists.txt b/ug/channel/CMakeLists.txt
index 66cddc8..a90911e 100644
--- a/ug/channel/CMakeLists.txt
+++ b/ug/channel/CMakeLists.txt
@@ -25,6 +25,7 @@ SET(AUTO_PRGM_EDJ_THEME "ug_auto_program_theme.edj")
INCLUDE(FindPkgConfig)
pkg_check_modules(AUTO_PRGM_UG_PKGS REQUIRED
+ dlog
eina
edje
evas
@@ -34,6 +35,7 @@ pkg_check_modules(AUTO_PRGM_UG_PKGS REQUIRED
aul
ui-gadget-1
)
+ #ecore-x
#tv-service
#tv-player-core
@@ -46,18 +48,16 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fvisibility=hidden -Wall")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
SET(SRCS
- src/ug_auto_program.cpp
- src/util.cpp
- src/ChannelMainView.cpp
- src/ChannelResultView.cpp
- src/ChannelSearchView.cpp
- ../src/TVServiceMgr.cpp
+ src/ug_auto_program.c
+ src/util.c
+ src/viewmgr_auto_program.c
+ src/view_scan_start.c
+ src/view_search_page.c
+ src/view_result_page.c
+ src/tv_scan.c
)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../include)
-
ADD_DEFINITIONS("-DPKGNAME=\"${PROJECT_NAME}\"")
ADD_DEFINITIONS("-DAUTO_PRGM_EDJ_FILE=\"${AUTO_PRGM_EDJEDIR}/${AUTO_PRGM_EDJ_FILE}\"")
diff --git a/ug/channel/edje/images/btn_text_foc.png b/ug/channel/edje/images/btn_text_foc.png
index 4a30fec..c43ca3c 100644
--- a/ug/channel/edje/images/btn_text_foc.png
+++ b/ug/channel/edje/images/btn_text_foc.png
Binary files differ
diff --git a/ug/channel/edje/images/btn_text_nor.png b/ug/channel/edje/images/btn_text_nor.png
index 4834090..b643016 100644
--- a/ug/channel/edje/images/btn_text_nor.png
+++ b/ug/channel/edje/images/btn_text_nor.png
Binary files differ
diff --git a/ug/channel/edje/images/list_highlight.png b/ug/channel/edje/images/list_highlight.png
index bf105b8..2dbf246 100644
--- a/ug/channel/edje/images/list_highlight.png
+++ b/ug/channel/edje/images/list_highlight.png
Binary files differ
diff --git a/ug/channel/edje/images/radiobtn_off_br.png b/ug/channel/edje/images/radiobtn_off_br.png
index e7e58cc..ddebc8c 100644
--- a/ug/channel/edje/images/radiobtn_off_br.png
+++ b/ug/channel/edje/images/radiobtn_off_br.png
Binary files differ
diff --git a/ug/channel/edje/images/radiobtn_off_dark.png b/ug/channel/edje/images/radiobtn_off_dark.png
index 909c02d..66ef3f6 100644
--- a/ug/channel/edje/images/radiobtn_off_dark.png
+++ b/ug/channel/edje/images/radiobtn_off_dark.png
Binary files differ
diff --git a/ug/channel/edje/images/radiobtn_on_br.png b/ug/channel/edje/images/radiobtn_on_br.png
index f74c505..f14d5bb 100644
--- a/ug/channel/edje/images/radiobtn_on_br.png
+++ b/ug/channel/edje/images/radiobtn_on_br.png
Binary files differ
diff --git a/ug/channel/edje/images/radiobtn_on_dark.png b/ug/channel/edje/images/radiobtn_on_dark.png
index 3e52579..7b630ea 100644
--- a/ug/channel/edje/images/radiobtn_on_dark.png
+++ b/ug/channel/edje/images/radiobtn_on_dark.png
Binary files differ
diff --git a/ug/channel/edje/images/round_rectangle_4X4.png b/ug/channel/edje/images/round_rectangle_4X4.png
index b0c09a8..5a1f51d 100644
--- a/ug/channel/edje/images/round_rectangle_4X4.png
+++ b/ug/channel/edje/images/round_rectangle_4X4.png
Binary files differ
diff --git a/ug/channel/edje/images/second_depth_bg.png b/ug/channel/edje/images/second_depth_bg.png
index 602e272..5b3c624 100644
--- a/ug/channel/edje/images/second_depth_bg.png
+++ b/ug/channel/edje/images/second_depth_bg.png
Binary files differ
diff --git a/ug/channel/edje/images/thumbnail_highlight_glowrect.png b/ug/channel/edje/images/thumbnail_highlight_glowrect.png
index 1fb8748..b7c9dbe 100644
--- a/ug/channel/edje/images/thumbnail_highlight_glowrect.png
+++ b/ug/channel/edje/images/thumbnail_highlight_glowrect.png
Binary files differ
diff --git a/ug/channel/edje/images/wi_progress_bar.png b/ug/channel/edje/images/wi_progress_bar.png
index d178ffe..01f58d1 100644
--- a/ug/channel/edje/images/wi_progress_bar.png
+++ b/ug/channel/edje/images/wi_progress_bar.png
Binary files differ
diff --git a/ug/channel/edje/images/wi_progress_bg.png b/ug/channel/edje/images/wi_progress_bg.png
index 5adf01c..4eb107e 100644
--- a/ug/channel/edje/images/wi_progress_bg.png
+++ b/ug/channel/edje/images/wi_progress_bg.png
Binary files differ
diff --git a/ug/channel/edje/widgets/progressbar.edc b/ug/channel/edje/widgets/progressbar.edc
index b9c6c25..51b0c83 100644
--- a/ug/channel/edje/widgets/progressbar.edc
+++ b/ug/channel/edje/widgets/progressbar.edc
@@ -194,7 +194,6 @@ group {
size: 18*2;
min: 1 0;
text_class: "tizen";
- ellipsis: -1;
}
fixed: 1 1;
}
diff --git a/ug/channel/include/ChannelMainView.h b/ug/channel/include/ChannelMainView.h
deleted file mode 100644
index 2ff73b2..0000000
--- a/ug/channel/include/ChannelMainView.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef __CHANNEL_MAIN_VIEW_H__
-#define __CHANNEL_MAIN_VIEW_H__
-
-
-class CChannelMainView : public CBaseView, public IMouseClickedListener, public IFocusedListener, public IUnfocusedListener {
-private :
- struct SChannelMainView *m;
- bool m_CreateBox(void);
- bool m_UpdateAntennaList(void);
- void m_UpdateFocus(void);
-
-
-protected :
- virtual void t_OnShow(void);
- virtual void t_OnUpdate(void *data);
- virtual void t_OnHide(void);
-
-public :
- CChannelMainView(const char *szViewId) : CBaseView(szViewId), IMouseClickedListener(this), IFocusedListener(this), IUnfocusedListener(this), m(0) {}
- virtual ~CChannelMainView() {}
-
- virtual bool Create(void *data);
- virtual void Destroy(void);
- virtual Evas_Object* Base(void);
-
- virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev);
- virtual void OnMouseClicked(int id, Evas_Object *obj);
- virtual void OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item);
- virtual void OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item);
-};
-
-#endif /* __CHANNEL_MAIN_VIEW_H__ */
-
-
diff --git a/ug/channel/include/ChannelResultView.h b/ug/channel/include/ChannelResultView.h
deleted file mode 100644
index f73410d..0000000
--- a/ug/channel/include/ChannelResultView.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef __CHANNEL_RESULT_VIEW_H__
-#define __CHANNEL_RESULT_VIEW_H__
-
-
-class CChannelResultView : public CBaseView, public IMouseClickedListener{
-private :
- struct SChannelResultView *m;
-
-protected :
- virtual void t_OnShow(void);
- virtual void t_OnUpdate(void *data);
- virtual void t_OnHide(void);
-
-public :
- CChannelResultView(const char *szViewId) : CBaseView(szViewId), IMouseClickedListener(this), m(0) {}
- virtual ~CChannelResultView() {}
-
- virtual bool Create(void *data);
- virtual void Destroy(void);
- virtual Evas_Object* Base(void);
-
- virtual void OnMouseClicked(int id, Evas_Object *obj);
-};
-
-#endif /* __CHANNEL_RESULT_VIEW_H__ */
diff --git a/ug/channel/include/ChannelSearchView.h b/ug/channel/include/ChannelSearchView.h
deleted file mode 100644
index 9031f6b..0000000
--- a/ug/channel/include/ChannelSearchView.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef __CHANNEL_SEARCH_VIEW_H__
-#define __CHANNEL_SEARCH_VIEW_H__
-
-
-class CChannelSearchView : public CBaseView, public IMouseClickedListener{
-private :
- struct SChannelSearchView *m;
- bool m_StartScan(void);
-
-protected :
- virtual void t_OnShow(void);
- virtual void t_OnUpdate(void *data);
- virtual void t_OnHide(void);
-
-public :
- CChannelSearchView(const char *szViewId) : CBaseView(szViewId), IMouseClickedListener(this), m(0) {}
- virtual ~CChannelSearchView() {}
-
- virtual bool Create(void *data);
- virtual void Destroy(void);
- virtual Evas_Object* Base(void);
-
- virtual void OnMouseClicked(int id, Evas_Object *obj);
-};
-
-#endif /* __CHANNEL_SEARCH_VIEW_H__ */
diff --git a/ug/channel/include/dbg.h b/ug/channel/include/dbg.h
new file mode 100644
index 0000000..6e6cd9d
--- /dev/null
+++ b/ug/channel/include/dbg.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __DBG_H__
+
+
+#include <dlog.h>
+
+
+#ifndef _ERR
+#define _ERR(fmt, args...) LOGE("[%s:%d] "fmt"\n", __func__, __LINE__, ##args)
+#endif
+
+#ifndef _DBG
+#define _DBG(fmt, args...) LOGD("[%s:%d] "fmt"\n", __func__, __LINE__, ##args)
+#endif
+
+#ifndef _INFO
+#define _INFO(fmt, args...) LOGI("[%s:%d] "fmt"\n", __func__, __LINE__, ##args)
+#endif
+
+
+#endif /* __DBG_H__ */
diff --git a/ug/channel/include/defs.h b/ug/channel/include/defs.h
index b265101..3962ad3 100644
--- a/ug/channel/include/defs.h
+++ b/ug/channel/include/defs.h
@@ -17,9 +17,6 @@
#ifndef __DEFS_H__
#define __DEFS_H__
-/* View */
-#define CHANNEL_MAINVIEW "CHANNEL_MAINVIEW"
-
#define VIEW_START "scanstart"
#define VIEW_SEARCH "searchpage"
#define VIEW_RESULT "resultpage"
diff --git a/ug/channel/include/tv_scan.h b/ug/channel/include/tv_scan.h
new file mode 100644
index 0000000..ddbf461
--- /dev/null
+++ b/ug/channel/include/tv_scan.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __TV_SCAN_H__
+#define __TV_SCAN_H__
+
+struct tv_scan;
+
+enum local_mode {
+ INVALID_LOCAL = -1,
+ KR_MODE,
+ US_MODE,
+ MAX_LOCAL
+};
+
+enum antenna_mode {
+ SCAN_TYPE_INVALID = -1,
+ SCAN_TYPE_ALL,
+ SCAN_TYPE_CABLE,
+ SCAN_TYPE_AIR
+};
+
+struct tv_scan_result {
+ unsigned int air_dtv;
+ unsigned int cable_dtv;
+ unsigned int air_atv;
+ unsigned int cable_atv;
+};
+
+struct tv_scan_cbs {
+ void (*progress_cb)(struct tv_scan *tvs, enum antenna_mode mode,
+ int count, int num, void *arg);
+ void (*found_cb)(struct tv_scan *tvs, int count, int num,
+ const struct tv_scan_result *result, void *arg);
+ void (*done_cb)(struct tv_scan *tvs,
+ const struct tv_scan_result *result, void *arg);
+
+ void *data;
+};
+
+struct tv_scan *tv_scan_init(enum antenna_mode scan_mode);
+int tv_scan_fini(struct tv_scan *tvs);
+int tv_scan_set_callbacks(struct tv_scan *tvs, struct tv_scan_cbs *cbs);
+int tv_scan_start(struct tv_scan *tvs);
+int tv_scan_pause(struct tv_scan *tvs);
+int tv_scan_resume(struct tv_scan *tvs);
+int tv_scan_stop(struct tv_scan *tvs);
+int tv_scan_get_total_channel(struct tv_scan *tvs);
+struct tv_scan_result *tv_scan_get_result(struct tv_scan *tvs);
+int tv_scan_is_stopped(struct tv_scan *tvs);
+
+#endif /* __TV_SCAN_H__ */
diff --git a/ug/channel/include/ug_auto_program.h b/ug/channel/include/ug_auto_program.h
index 3b5ba7b..c1c4240 100644
--- a/ug/channel/include/ug_auto_program.h
+++ b/ug/channel/include/ug_auto_program.h
@@ -18,5 +18,15 @@
#define __UG_CHANNEL_SEARCH_VIEW_H_
#include <ui-gadget-module.h>
+#include "tv_scan.h"
+
+struct _ugdata {
+ Evas_Object *win;
+ Evas_Object *ugd_base;
+ ui_gadget_h ug;
+ struct viewmgr *vmgr;
+ enum antenna_mode scan_type;
+ int find_chs;
+};
#endif/*__UG_CHANNEL_SEARCH_VIEW_H_*/
diff --git a/ug/channel/include/util.h b/ug/channel/include/util.h
index fe2bab9..6630dcf 100644
--- a/ug/channel/include/util.h
+++ b/ug/channel/include/util.h
@@ -17,10 +17,13 @@
#ifndef __UTIL_H__
#define __UTIL_H__
-Evas_Object *util_add_layout(Evas_Object *parent, const char *file, const char *group);
-Evas_Object *util_add_scroller(Evas_Object *parent, Eina_Bool h_bounce, Eina_Bool v_bounce);
+Evas_Object *util_add_layout(Evas_Object *parent, const char *file,
+ const char *group);
+Evas_Object *util_add_scroller(Evas_Object *parent, Eina_Bool h_bounce,
+ Eina_Bool v_bounce);
Evas_Object *util_add_box(Evas_Object *parent, double h, double v);
-Evas_Object *util_add_button(Evas_Object *parent, const char *btnstyle, const char *btnpart, const char *btntext, Eina_Bool flag);
+Evas_Object *util_add_button(Evas_Object *parent, const char *btnstyle,
+ const char *btnpart, const char *btntext, Eina_Bool flag);
void util_focus_next_set(Evas_Object *obj);
#endif /* __UTIL_H__ */
diff --git a/ug/channel/include/view_result_page.h b/ug/channel/include/view_result_page.h
new file mode 100644
index 0000000..19a49b2
--- /dev/null
+++ b/ug/channel/include/view_result_page.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+#ifndef __VIEW_RESULT_PAGE_H__
+#define __VIEW_RESULT_PAGE_H__
+
+#include "ug_auto_program.h"
+#include "viewmgr_auto_program.h"
+
+struct view_class *view_resultpage_get_vclass(void);
+
+#endif /* __VIEW_RESULT_PAGE_H__ */
diff --git a/ug/channel/include/view_scan_start.h b/ug/channel/include/view_scan_start.h
new file mode 100644
index 0000000..2625744
--- /dev/null
+++ b/ug/channel/include/view_scan_start.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __VIEW_SCAN_START_H__
+#define __VIEW_SCAN_START_H__
+
+#include "ug_auto_program.h"
+#include "viewmgr_auto_program.h"
+
+struct view_class *view_scanstart_get_vclass(void);
+
+#endif /* __VIEW_SCAN_START_H__ */
diff --git a/ug/channel/include/view_search_page.h b/ug/channel/include/view_search_page.h
new file mode 100644
index 0000000..4b9cf21
--- /dev/null
+++ b/ug/channel/include/view_search_page.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __VIEW_SEARCHPAGE_H__
+#define __VIEW_SEARCHPAGE_H__
+
+#include "ug_auto_program.h"
+#include "viewmgr_auto_program.h"
+
+struct view_class *view_searchpage_get_vclass(void);
+
+#endif /* __VIEW_SEARCHPAGE_H__ */
diff --git a/ug/channel/include/viewmgr_auto_program.h b/ug/channel/include/viewmgr_auto_program.h
new file mode 100644
index 0000000..3815a4d
--- /dev/null
+++ b/ug/channel/include/viewmgr_auto_program.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __VIEWMGR_AUTO_PROGRAM_H__
+#define __VIEWMGR_AUTO_PROGRAM_H__
+
+#include <Elementary.h>
+#include <Evas.h>
+
+struct viewmgr {
+ Eina_List *vlist;
+ Evas_Object *win;
+ int count;
+};
+
+struct view_class {
+ char *title;
+ Evas_Object* (*create)(struct viewmgr *vmgr, void *data);
+ void (*update)(Evas_Object *base);
+ void (*resume)(Evas_Object *base);
+ void (*pause)(Evas_Object *base);
+ void (*terminate)(Evas_Object *base);
+};
+
+struct viewmgr *viewmgr_init(Evas_Object *win);
+void viewmgr_fini(struct viewmgr *vmgr);
+int viewmgr_push(struct viewmgr *vmgr, struct view_class *vclass, void *data);
+int viewmgr_pop(struct viewmgr *vmgr);
+int viewmgr_resume(struct viewmgr *vmgr);
+int viewmgr_pause(struct viewmgr *vmgr);
+Evas_Object *viewmgr_get_win(struct viewmgr *vmgr);
+
+#endif /* __VIEWMGR_AUTO_PROGRAM_H__ */
diff --git a/ug/channel/src/ChannelMainView.cpp b/ug/channel/src/ChannelMainView.cpp
deleted file mode 100644
index c11f459..0000000
--- a/ug/channel/src/ChannelMainView.cpp
+++ /dev/null
@@ -1,356 +0,0 @@
-#include <ui-gadget-module.h>
-#include <AppCommon.h>
-#include "util.h"
-#include "defs.h"
-#include "TVServiceMgr.h"
-
-#include "ChannelMainView.h"
-
-#define HORIZONTAL_ALIGN 0.5
-#define VERTICAL_ALIGN 0.0
-#define MAX_ITEMS 3
-#define ALL "All"
-#define CABLE "Cable"
-#define AIR "Air"
-
-enum antenna_type {
- ALL_ITEM,
- CABLE_ITEM,
- AIR_ITEM
-};
-
-struct SChannelMainView {
- ui_gadget_h ug;
-
- Evas_Object *win;
- Evas_Object *base;
- Evas_Object *start_btn;
- Evas_Object *cancel_btn;
- Evas_Object *box;
- Evas_Object *last_focus_item;
- Evas_Object *selected_item;
- Evas_Object *atn_btn[MAX_ITEMS];
- enum antenna_mode scan_type;
-
- CViewMgr *pViewMgr;
-};
-
-bool CChannelMainView::m_CreateBox(void)
-{
- m->box = util_add_box(m->base, HORIZONTAL_ALIGN, VERTICAL_ALIGN);
- if (!m->box) {
- _ERR("box add failed");
- return false;
- }
-
- elm_object_part_content_set(m->base, PART_ANTENNA_LIST, m->box);
- evas_object_size_hint_weight_set(m->box, EVAS_HINT_EXPAND, 0);
-
- return true;
-}
-
-
-bool CChannelMainView::m_UpdateAntennaList(void)
-{
- Evas_Object *btn;
- int i;
- const char *temp[MAX_ITEMS] = { ALL, CABLE, AIR };
-
- elm_box_clear(m->box);
- m->last_focus_item = NULL;
- m->selected_item = NULL;
-
- for (i = 0; i < MAX_ITEMS; i++) {
- btn = util_add_button(m->box, (char *) ITEM_STYLE, NULL, temp[i], EINA_TRUE);
- if (!btn) {
- _ERR("Fail to add button");
- return false;
- }
- elm_box_pack_end(m->box, btn);
- //evas_object_smart_callback_add(btn, SIGNAL_CLICKED, atninfo[i].cb, data);
- //elm_object_signal_callback_add(btn, SIGNAL_FOCUSED, ELM_SOURCE, _btn_focused_cb, data);
- //elm_object_signal_callback_add(btn, SIGNAL_UNFOCUSED, ELM_SOURCE, _btn_unfocused_cb, data);
- Connect(btn, 100+i);
-
- m->atn_btn[i] = btn;
-
- if (i == 0) {
- elm_object_focus_set(btn, EINA_TRUE);
- elm_object_signal_emit(btn, SIGNAL_SELECTED, CHANNEL_SOURCE);
- m->selected_item = btn;
- }
- }
-
- m_UpdateFocus();
- return true;
-}
-
-
-void CChannelMainView::m_UpdateFocus(void)
-{
- elm_object_focus_next_object_set(m->atn_btn[ALL_ITEM], m->start_btn, ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(m->atn_btn[CABLE_ITEM], m->start_btn, ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(m->atn_btn[AIR_ITEM], m->start_btn, ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(m->atn_btn[ALL_ITEM], m->atn_btn[ALL_ITEM], ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(m->atn_btn[CABLE_ITEM], m->atn_btn[CABLE_ITEM], ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(m->atn_btn[AIR_ITEM], m->atn_btn[AIR_ITEM], ELM_FOCUS_LEFT);
-
- if (m->selected_item) {
- elm_object_focus_next_object_set(m->start_btn, m->selected_item, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(m->cancel_btn, m->selected_item, ELM_FOCUS_LEFT);
- } else {
- elm_object_focus_next_object_set(m->start_btn, m->atn_btn[ALL_ITEM], ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(m->cancel_btn, m->atn_btn[ALL_ITEM], ELM_FOCUS_LEFT);
- }
-
- elm_object_focus_next_object_set(m->start_btn, m->cancel_btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(m->cancel_btn, m->start_btn, ELM_FOCUS_DOWN);
- elm_object_focus_next_object_set(m->cancel_btn, m->start_btn, ELM_FOCUS_UP);
-}
-
-
-void CChannelMainView::t_OnShow(void)
-{
- _DBG();
-
- evas_object_show(m->base);
-
- CBaseView::t_OnShow();
-}
-
-
-void CChannelMainView::t_OnUpdate(void *data)
-{
- _DBG();
-
- evas_object_show(m->base);
-}
-
-
-void CChannelMainView::t_OnHide(void)
-{
- _DBG();
-
- evas_object_hide(m->base);
-
- CBaseView::t_OnHide();
-}
-
-
-bool CChannelMainView::Create(void *data)
-{
- _DBG();
- ASSERT(!m);
-
- ui_gadget_h ug;
- if (!data) {
- _ERR("Invalid argument");
- return false;
- }
- ug = (ui_gadget_h)data;
-
- _CREATE_BEGIN{
- _CHECK(m = new SChannelMainView)
- _CHECK(m->win = CViewMgr::GetInstance()->Window())
- _CHECK(m->base = util_add_layout(m->win, AUTO_PRGM_EDJ_FILE, GRP_SCAN_START))
- _COMMAND{
- //evas_object_event_callback_add(base, EVAS_CALLBACK_KEY_DOWN, _key_pressed_cb, priv);
- Connect(m->base, 0);
- elm_object_part_text_set(m->base, PART_STAR_MAIN_TITLE_BLOCK, START_MAIN_TITLE);
- }
- _CHECK(m->start_btn = util_add_button(m->base, BTN_STYLE, PART_START_BTN, TEXT_BTN_START, EINA_TRUE))
- _CHECK(m->cancel_btn = util_add_button(m->base, BTN_STYLE, PART_CANCEL_BTN, TEXT_BTN_CANCEL, EINA_TRUE))
- _COMMAND{
-#if 0
- evas_object_data_set(m->base, "SCANSTARTDATA", m);
-#endif
- //evas_object_smart_callback_add(start_btn, SIGNAL_CLICKED, _start_btn_clicked_cb, priv);
- //evas_object_smart_callback_add(cancel_btn, SIGNAL_CLICKED, _cancel_btn_clicked_cb, priv);
- Connect(m->start_btn, 1);
- Connect(m->cancel_btn, 2);
- evas_object_raise(m->base);
- }
- _CHECK(m_CreateBox())
- _CHECK(m_UpdateAntennaList())
- _WHEN_SUCCESS {
- m->ug = ug;
- m->pViewMgr = CViewMgr::GetInstance();
- }
- _CHECK_FAIL{for(int i = 0; i < MAX_ITEMS ; i++) evas_object_del(m->atn_btn[i]);}
- _CHECK_FAIL{evas_object_del(m->box);}
- _CHECK_FAIL{evas_object_del(m->cancel_btn);}
- _CHECK_FAIL{evas_object_del(m->start_btn);}
- _CHECK_FAIL{evas_object_del(m->base);}
- _CHECK_FAIL{/* m->win = CViewMgr::GetInstance()->Window() */}
- _CHECK_FAIL{ delete m; m = NULL; }
- } _CREATE_END_AND_CATCH{ return false; }
-
- return true;
-}
-
-
-void CChannelMainView::Destroy(void)
-{
- ASSERT(m);
-
- if(m->atn_btn[0]) {
- for(int i = 0; i < MAX_ITEMS ; i++) evas_object_del(m->atn_btn[i]);
- }
-
- if(m->box)
- evas_object_del(m->box);
- if(m->cancel_btn)
- evas_object_del(m->cancel_btn);
- if(m->start_btn)
- evas_object_del(m->start_btn);
- if(m->base)
- evas_object_del(m->base);
-
- delete m;
- m = NULL;
-}
-
-
-Evas_Object* CChannelMainView::Base(void)
-{
- ASSERT(m);
-
- return m->base;
-}
-
-
-
-void CChannelMainView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
-{
- if (!ev->keyname) {
- _ERR("ev->keyname NULL!");
- return;
- }
-
- switch(id) {
- case 0:
- if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE))
- ug_destroy_me(m->ug);
- break;
- default:
- break;
- }
-
-}
-
-
-void CChannelMainView::OnMouseClicked(int id, Evas_Object *obj)
-{
- switch(id) {
- case 1:
- {
- Eina_Bool tuner_exist;
-
- /*
- * TODO: add the interface when TV service provider the related API.
- * Here is a pseudo-data.
- */
- tuner_exist = EINA_TRUE;
- if (!tuner_exist) {
- /*
- * TODO: popup the notification iniformation:
- * there is no tuner
- */
- return;
- }
-
-#if 0
- if (viewmgr_push(m->vmgr, view_searchpage_get_vclass(), m->ugd) == -1) {
- _ERR("search view push failed");
- return;
- }
-#endif
- }
- break;
- case 2:
- {
- ug_destroy_me(m->ug);
- }
- break;
- case 100:
- case 101:
- case 102:
- {
- const char *text;
-
- if (!m->selected_item) {
- elm_object_focus_set(obj, EINA_TRUE);
- elm_object_signal_emit(obj, SIGNAL_SELECTED, CHANNEL_SOURCE);
- m->selected_item = obj;
- } else {
- if (m->selected_item != obj) {
- elm_object_signal_emit(m->selected_item, SIGNAL_UNSELECTED, CHANNEL_SOURCE);
- elm_object_signal_emit(obj, SIGNAL_SELECTED, CHANNEL_SOURCE);
- m->selected_item = obj;
- }
- }
-
- text = elm_object_text_get(m->selected_item);
- if (text && !strcmp(text, ALL))
- m->scan_type = SCAN_TYPE_ALL;
- else if (text && !strcmp(text, CABLE))
- m->scan_type = SCAN_TYPE_CABLE;
- else if (text && !strcmp(text, AIR))
- m->scan_type = SCAN_TYPE_AIR;
- else
- m->scan_type = SCAN_TYPE_INVALID;
-
-#if 0
- m->ugd->scan_type = m->scan_type;
-#endif
-
- m_UpdateFocus();
- }
- break;
- default:
- break;
- }
-}
-
-
-void CChannelMainView::OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item)
-{
- switch(id) {
- case 100:
- case 101:
- case 102:
- {
- if (m->last_focus_item) {
- elm_object_signal_emit(m->last_focus_item,
- SIGNAL_SHOWLINE, CHANNEL_SOURCE);
- elm_object_signal_emit(obj, SIGNAL_HIDELINE, CHANNEL_SOURCE);
- } else {
- elm_object_signal_emit(obj, SIGNAL_SHOWLINE, CHANNEL_SOURCE);
- }
-
- m->last_focus_item = obj;
- }
- break;
- default:
- break;
- }
-}
-
-
-void CChannelMainView::OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item)
-{
- switch(id) {
- case 100:
- case 101:
- case 102:
- {
- elm_object_signal_emit(m->last_focus_item, SIGNAL_SHOWLINE, CHANNEL_SOURCE);
- }
- break;
- default:
- break;
- }
-
-}
-
-
diff --git a/ug/channel/src/ChannelResultView.cpp b/ug/channel/src/ChannelResultView.cpp
deleted file mode 100644
index d90e7e0..0000000
--- a/ug/channel/src/ChannelResultView.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-#include <ui-gadget-module.h>
-#include <system_info.h>
-#include <AppCommon.h>
-#include "defs.h"
-#include "util.h"
-
-#include "ChannelResultView.h"
-
-#define RESULT_MSG_SIZE 60
-
-struct SChannelResultView {
- ui_gadget_h ug;
-
- Evas_Object *win;
- Evas_Object *base;
- Evas_Object *ok_btn;
-
- CViewMgr *pViewMgr;
-};
-
-void CChannelResultView::t_OnShow(void)
-{
- _DBG();
-
- evas_object_show(m->base);
-
- CBaseView::t_OnShow();
-}
-
-
-void CChannelResultView::t_OnUpdate(void *data)
-{
- _DBG();
- Evas_Object *ok_btn;
- char msg[RESULT_MSG_SIZE];
- int chs = -1;
-
-#if 0
- chs = m->ugd->find_chs;
-#endif
-
- snprintf(msg, sizeof(msg), "%s<br>%d %s", COMPLETE_MAIN_TITLE, chs, TEXT_CH_MEMORIZED);
- elm_object_part_text_set(m->base, PART_RES_MAIN_TITLE, msg);
-
- ok_btn = util_add_button(m->base, BTN_STYLE, PART_OK_BTN, TEXT_BUTTON_OK, EINA_TRUE);
- if (!ok_btn) {
- _ERR("ok_btn is NULL");
- return;
- }
-
- m->ok_btn = ok_btn;
- elm_object_focus_set(ok_btn, EINA_TRUE);
- //evas_object_smart_callback_add(ok_btn, SIGNAL_CLICKED, _ok_btn_clicked_cb, priv);
- Connect(ok_btn,1);
-
- util_focus_next_set(ok_btn);
-
- evas_object_show(m->base);
-}
-
-
-void CChannelResultView::t_OnHide(void)
-{
- _DBG();
-
- evas_object_hide(m->base);
-
- CBaseView::t_OnHide();
-}
-
-
-
-bool CChannelResultView::Create(void *data)
-{
- _DBG();
- ASSERT(!m);
-
- ui_gadget_h ug;
- if (!data) {
- _ERR("Invalid argument");
- return false;
- }
- ug = (ui_gadget_h)data;
-
- _CREATE_BEGIN{
- _CHECK(m = new SChannelResultView)
- _CHECK(m->win = CViewMgr::GetInstance()->Window())
- _CHECK(m->base = util_add_layout(m->win, AUTO_PRGM_EDJ_FILE, GROUP_RES))
-
- _WHEN_SUCCESS {
- elm_win_resize_object_add(m->win, m->base);
-#if 0
- evas_object_data_set(m->base, "RESDATA", m);
-#endif
- m->ug = ug;
- m->pViewMgr = CViewMgr::GetInstance();
- }
-
- _CHECK_FAIL{evas_object_del(m->base);}
- _CHECK_FAIL{/* m->win = CViewMgr::GetInstance()->Window() */}
- _CHECK_FAIL{ delete m; m = NULL; }
- } _CREATE_END_AND_CATCH{ return false; }
-
- return true;
-}
-
-
-void CChannelResultView::Destroy(void)
-{
- ASSERT(m);
-
- if(m->base)
- evas_object_del(m->base);
-
- delete m;
- m = NULL;
-}
-
-
-Evas_Object* CChannelResultView::Base(void)
-{
- ASSERT(m);
-
- return m->base;
-}
-
-void CChannelResultView::OnMouseClicked(int id, Evas_Object *obj)
-{
- switch(id) {
- case 1:
- ug_destroy_me(m->ug);
- break;
- default:
- break;
- }
-}
diff --git a/ug/channel/src/ChannelSearchView.cpp b/ug/channel/src/ChannelSearchView.cpp
deleted file mode 100644
index 4912d3c..0000000
--- a/ug/channel/src/ChannelSearchView.cpp
+++ /dev/null
@@ -1,364 +0,0 @@
-#include <ui-gadget-module.h>
-#include <system_info.h>
-#include <AppCommon.h>
-#include "defs.h"
-#include "util.h"
-
-#include "TVServiceMgr.h"
-#include "ChannelSearchView.h"
-
-#define MAX_BUF_SIZE 30
-#define CH_NAME_SIZE 30
-#define INITIAL_CH_NUMS 0
-#define PERCENT 100
-#define INITIAL_TEXT "0%"
-#define INITIAL_VALUE 0.0
-
-struct SChannelSearchView {
- ui_gadget_h ug;
-
- Evas_Object *win;
- Evas_Object *base;
- Evas_Object *pb;
- Evas_Object *stop_btn;
- Evas_Object *exit_btn;
- Evas_Object *cancel_btn;
-
- CTVServiceMgr *pTVServiceMgr;
- CViewMgr *pViewMgr;
-};
-
-#if 0
-static void _progress_cb(struct tv_scan *tvs, enum antenna_mode mode,
- int count, int num, void *arg)
-{
- struct _data *priv;
- char buf[CH_NAME_SIZE];
- int total;
- int ratio;
-
- if (!tvs || !arg) {
- _ERR("Invalid argument");
- return;
- }
-
- priv = (struct _data *) arg;
-
- snprintf(buf, sizeof(buf), "CH. %d", count);
- elm_object_part_text_set(m->base, PART_CH_NAME, buf);
- elm_object_signal_emit(m->base, SEARCHCHANNEL, SUBTEXT_SOURCE);
-
- total = tv_scan_get_total_channel(tvs);
- if (total <= 0) {
- _ERR("Invalid Total value");
- return;
- }
-
- ratio = count * PERCENT / total;
- snprintf(buf, sizeof(buf), "%d%%", ratio);
- elm_object_part_text_set(m->base, PART_PGBAR_NUM, buf);
- elm_progressbar_value_set(m->pb, (float)ratio / PERCENT);
-}
-
-/**
- * Dealing with the scanning result.
- *
- * When finishing scanning, the total found channels will be calculated and the
- * scan result view will be invoked in this function.
- *
- * @param[in] tvs: The tv service structure for managering the scanning
- * @param[in] res: The structure for saving the number of ATV air, DTV air,
- * ATV cable and DTV cable channel.
- * @param[in] arg: A pointer to current data structure.
- */
-static void _done_cb(struct tv_scan *tvs,
- const struct tv_scan_result *res, void *arg)
-{
- struct _data *priv;
- struct _ugdata *ugd;
- struct viewmgr *vmgr;
-
- if (!arg) {
- _ERR("Invalid argument");
- return;
- }
-
- priv = (struct _data *)arg;
-
- if (!m->tvs || !m->vmgr || !m->ugd) {
- _ERR("Invalid argument");
- return;
- }
-
- vmgr = m->vmgr;
- ugd = m->ugd;
-
- ugd->find_chs = res->air_dtv + res->cable_dtv +
- res->air_atv + res->cable_atv;
-
- if (viewmgr_push(vmgr, view_resultpage_get_vclass(), ugd) == -1)
- _ERR("result view push failed");
-}
-
-/**
- * Deal with the found channel signal.
- *
- * @param[in] tvs: The tv service structure for managering the scanning
- * @param[in] count: The number of channel signal received up to now
- * @param[in] num: The physical channel number
- * @param[in] res: The structure for saving the number of ATV air, DTV air,
- * ATV cable and DTV cable channel.
- * @param[in] arg: A pointer to the current data structure.
- * @return 0 on success, and -1 on fail
- */
-static void _found_cb(struct tv_scan *tvs, int count, int num,
- const struct tv_scan_result *res, void *arg)
-{
- struct _data *priv;
- char buf[CH_NAME_SIZE];
- int found;
-
- if (!arg) {
- _ERR("Invalid argument");
- return;
- }
-
- priv = (struct _data *)arg;
- snprintf(buf, sizeof(buf), "CH. %d", count);
-
- elm_object_part_text_set(m->base, PART_CH_NAME, buf);
- elm_object_signal_emit(m->base, CHANNELFOUND, SUBTEXT_SOURCE);
-
- found = res->air_dtv + res->cable_dtv + res->air_atv + res->cable_atv;
- snprintf(buf, sizeof(buf), "%d %s", found, TEXT_CH_FOUND);
- elm_object_part_text_set(m->base, PART_SRCH_SEARCH_RESULT, buf);
-
- m->ugd->find_chs = found;
-}
-#endif
-
-bool CChannelSearchView::m_StartScan(void)
-{
-
-#if 0
- if(!m->pTVServiceMgr->SetCallback(&cbs)) {
- _ERR("tv_scan_set_callbacks failed");
- return -1;
- }
-#endif
-
- if(!m->pTVServiceMgr->Start()) {
- _ERR("tv_scan_start failed.");
- return -1;
- }
-
- return false;
-}
-
-
-void CChannelSearchView::t_OnShow(void)
-{
- _DBG();
-
- evas_object_show(m->base);
-
- CBaseView::t_OnShow();
-}
-
-
-void CChannelSearchView::t_OnUpdate(void *data)
-{
- _DBG();
-
- m->stop_btn = util_add_button(m->base, BTN_STYLE, PART_STOP_BTN, TEXT_BTN_STOP, EINA_TRUE);
- if (!m->stop_btn) {
- _ERR("stop_btn is NULL");
- return;
- }
-
- elm_object_focus_set(m->stop_btn, EINA_TRUE);
- //evas_object_smart_callback_add(m->stop_btn, SIGNAL_CLICKED, _stop_btn_clicked_cb, priv);
- Connect(m->stop_btn, 1);
- util_focus_next_set(m->stop_btn);
-
- m->pb = elm_progressbar_add(m->base);
- if (!m->pb) {
- _ERR("pb is NULL");
- evas_object_del(m->stop_btn);
- return;
- }
-
- elm_object_style_set(m->pb, PRGBAR_STYLE);
- elm_object_part_text_set(m->base, PART_PGBAR_NUM, INITIAL_TEXT);
- elm_progressbar_value_set(m->pb, INITIAL_VALUE);
- elm_object_part_content_set(m->base, PART_PROGRESSBAR, m->pb);
- evas_object_show(m->pb);
-
- if (m_StartScan() != true) {
- _ERR("start scan failed");
- return;
- }
-
- evas_object_show(m->base);
-}
-
-
-void CChannelSearchView::t_OnHide(void)
-{
- _DBG();
-
- evas_object_hide(m->base);
-
- CBaseView::t_OnHide();
-}
-
-
-
-bool CChannelSearchView::Create(void *data)
-{
- _DBG();
- ASSERT(!m);
- char buf[MAX_BUF_SIZE];
-
- ui_gadget_h ug;
- if (!data) {
- _ERR("Invalid argument");
- return false;
- }
- ug = (ui_gadget_h)data;
-
- _CREATE_BEGIN{
- _CHECK(m = new SChannelSearchView)
- _CHECK(m->win = CViewMgr::GetInstance()->Window())
- _CHECK(CTVServiceMgr::Initialize())
- _CHECK(m->pTVServiceMgr = CTVServiceMgr::GetInstance())
- _CHECK(m->base = util_add_layout(m->win, AUTO_PRGM_EDJ_FILE, GROUP_SRCH))
-
- _WHEN_SUCCESS {
- elm_win_resize_object_add(m->win, m->base);
- elm_object_part_text_set(m->base, PART_SRCH_MAIN_TITLE, SEARCH_MAIN_TITLE);
- elm_object_part_text_set(m->base, PART_CH_NAME, SCAN_CH_NAME);
- snprintf(buf, sizeof(buf), "%d %s", INITIAL_CH_NUMS, TEXT_CH_FOUND);
- elm_object_part_text_set(m->base, PART_SRCH_SEARCH_RESULT, buf);
-#if 0
- evas_object_data_set(m->base, "SRCHDATA", m);
-#endif
- m->ug = ug;
- m->pViewMgr = CViewMgr::GetInstance();
- }
-
- _CHECK_FAIL{evas_object_del(m->base);}
- _CHECK_FAIL{/* m->pTVServiceMgr = CTVServiceMgr::GetInstance() */}
- _CHECK_FAIL{CTVServiceMgr::Finalize();}
- _CHECK_FAIL{/* m->win = CViewMgr::GetInstance()->Window() */}
- _CHECK_FAIL{ delete m; m = NULL; }
- } _CREATE_END_AND_CATCH{ return false; }
-
- return true;
-}
-
-
-void CChannelSearchView::Destroy(void)
-{
- ASSERT(m);
-
- if(m->base)
- evas_object_del(m->base);
-
- CTVServiceMgr::Finalize();
-
- delete m;
- m = NULL;
-}
-
-
-Evas_Object* CChannelSearchView::Base(void)
-{
- ASSERT(m);
-
- return m->base;
-}
-
-void CChannelSearchView::OnMouseClicked(int id, Evas_Object *obj)
-{
- switch(id) {
- case 1:
- case 4:
- {
- if(!m->pTVServiceMgr->Pause()) {
- _ERR("tv_scan_pause failed");
- return;
- }
-
- elm_object_part_text_set(m->base, PART_SRCH_MAIN_TITLE, PAUSE_MAIN_TITLE);
-
- m->exit_btn = util_add_button(m->base, BTN_STYLE, PART_EXIT_BTN, TEXT_BTN_STOP, EINA_TRUE);
- if (!m->exit_btn) {
- _ERR("exit_btn is NULL");
- return;
- }
-
- //evas_object_smart_callback_add(m->exit_btn, SIGNAL_CLICKED, _destroy_search_page_cb, priv);
- Connect(m->exit_btn, 2);
-
- m->cancel_btn = util_add_button(m->base, BTN_STYLE, PART_SRCH_CANCEL_BTN, TEXT_BTN_CANCEL, EINA_TRUE);
- if (!m->cancel_btn) {
- _ERR("cancel_btn is NULL");
- evas_object_del(m->exit_btn);
- m->exit_btn = NULL;
- return;
- }
-
- //evas_object_smart_callback_add(m->cancel_btn, SIGNAL_CLICKED, _cancel_btn_clicked_cb, priv);
- Connect(m->cancel_btn, 3);
-
- elm_object_focus_allow_set(m->exit_btn, EINA_TRUE);
- elm_object_focus_set(m->exit_btn, EINA_TRUE);
- util_focus_next_set(m->exit_btn);
-
- evas_object_del(m->stop_btn);
- m->stop_btn = NULL;
- }
- break;
- case 2:
- {
- if(!m->pTVServiceMgr->Stop()) {
- _ERR("tv_scan_stop failed");
- return;
- }
-
- ug_destroy_me(m->ug);
- }
- break;
- case 3:
- {
- elm_object_part_text_set(m->base, PART_SRCH_MAIN_TITLE, SEARCH_MAIN_TITLE);
-
- if(!m->pTVServiceMgr->Resume()) {
- _ERR("resume tv scan failed.");
- return;
- }
-
- m->stop_btn = util_add_button(m->base, BTN_STYLE, PART_STOP_BTN, TEXT_BTN_STOP, EINA_TRUE);
- if (!m->stop_btn) {
- _ERR("stop_btn is NULL");
- return;
- }
-
- elm_object_focus_allow_set(m->stop_btn, EINA_TRUE);
- elm_object_focus_set(m->stop_btn, EINA_TRUE);
- //evas_object_smart_callback_add(m->stop_btn, SIGNAL_CLICKED, _stop_btn_clicked_cb, priv);
- Connect(m->stop_btn, 4);
-
- util_focus_next_set(m->stop_btn);
-
- evas_object_del(m->exit_btn);
- evas_object_del(m->cancel_btn);
- m->exit_btn = NULL;
- m->cancel_btn = NULL;
- }
- break;
- default:
- break;
- }
-}
diff --git a/ug/channel/src/tv_scan.c b/ug/channel/src/tv_scan.c
new file mode 100644
index 0000000..7d105b2
--- /dev/null
+++ b/ug/channel/src/tv_scan.c
@@ -0,0 +1,669 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <stdlib.h>
+#include <Ecore.h>
+#include "dbg.h"
+//#include "tv_service_proxy.h"
+#include "tv_scan.h"
+
+#define SIGNAL_HANDLER_INTERVAL 0.1
+
+enum tv_scan_state {
+ SCAN_STATE_READY,
+ SCAN_STATE_SEARCHING,
+ SCAN_STATE_PAUSED,
+ SCAN_STATE_STOPPING,
+ SCAN_STATE_MAX
+};
+
+struct tv_scan {
+ struct tv_scan_cbs cbs;
+ enum tv_scan_state state;
+ enum antenna_mode set_mode;
+#if 0
+ TvServiceScan service_scan;
+ TvServiceScanType scan_type;
+#endif
+ int ch_count;
+ int ch_num;
+ int total_ch;
+ struct tv_scan_result res;
+ int is_stopped;
+ Eina_List *signal_queue;
+ Ecore_Timer *signal_timer;
+};
+
+struct _signal_info {
+#if 0
+ TvServiceScanType scan_type;
+ TvServiceScanEvent signal;
+ TvServiceScanEventData signal_data;
+#endif
+};
+
+/**
+ * Get the scan type according to the setting of scanning mode in the beginning
+ *
+ * In this function, it will find the scan state the tv service provided
+ * accordding to the setting of scanning mode by user
+ *
+ * @param[in] mode: The setting of scanning mode in view_scan_start
+ * @param[out] type: The corresponding scan type provided by tv service
+ * @return 0 on success otherwise -1
+ */
+#if 0
+static int _get_scan_mode(enum antenna_mode mode, TvServiceScanType *type)
+{
+ switch (mode) {
+ case SCAN_TYPE_ALL:
+ *type = TVS_SCAN_ALL_ANALOG_DIGITAL;
+ break;
+ case SCAN_TYPE_CABLE:
+ *type = TVS_SCAN_CABLE_ANALOG_DIGITAL;
+ break;
+ case SCAN_TYPE_AIR:
+ *type = TVS_SCAN_AIR_ANALOG_DIGITAL;
+ break;
+ default:
+ _ERR("Invalid scan mode: %d", mode);
+ return -1;
+ }
+
+ return 0;
+}
+#endif
+
+/**
+ * Handling the beginning signal.
+ *
+ * When user press the button "start", it will begin scanning, and the tv
+ * service will return the total number of channels in the first for
+ * calculating the progress of the progressbar
+ *
+ * In this function, it will find the total number of channel signal according
+ * to the scanning type.
+ *
+ * @param[in] tvs: Data handler for tv scan manager.
+ * @param[in] sinfo: The channel signal information.
+ */
+static void _handle_begin_signal(struct tv_scan *tvs,
+ struct _signal_info *sinfo)
+{
+#if 0
+ if (!tvs || !sinfo) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ switch (sinfo->scan_type) {
+ case TVS_SCAN_ALL_ANALOG_DIGITAL:
+ tvs->total_ch = sinfo->signal_data.data.l[0] +
+ sinfo->signal_data.data.l[1];
+ break;
+ case TVS_SCAN_AIR_ANALOG_DIGITAL:
+ tvs->total_ch = sinfo->signal_data.data.l[0];
+ break;
+ case TVS_SCAN_CABLE_ANALOG_DIGITAL:
+ tvs->total_ch = sinfo->signal_data.data.l[1];
+ break;
+ default:
+ _ERR("Invalid scan type");
+ break;
+ }
+#endif
+}
+
+/**
+ * Handle the receiving channel signal.
+ *
+ * @param[in] tvs: Data handler for tv scan manager.
+ * @param[in] sinfo: The channel signal information.
+ */
+static void _handle_progress_signal(struct tv_scan *tvs,
+ struct _signal_info *sinfo)
+{
+#if 0
+ if (!tvs || !sinfo) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ tvs->ch_count++;
+ tvs->ch_num = sinfo->signal_data.data.l[0];
+
+ if (tvs->cbs.progress_cb)
+ tvs->cbs.progress_cb(tvs, tvs->set_mode, tvs->ch_count,
+ tvs->ch_num, tvs->cbs.data);
+#endif
+}
+
+/**
+ * Calculating the number of ATV channle signal or DTV channel signal.
+ *
+ * @param[in] atv: A pointer for saving the number of ATV channel signal.
+ * @param[in] dtv: A pointer for saving the number of DTV channel signal.
+ * @param[in] sinfo: The channel signal information.
+ */
+static void _channel_count(unsigned int *atv, unsigned int *dtv,
+ struct _signal_info *sinfo)
+{
+#if 0
+ if (!sinfo || !atv || !dtv) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ switch (sinfo->signal_data.data.s[1]) {
+ case TVS_CHANNEL_TYPE_ATV:
+ *atv += sinfo->signal_data.data.s[2];
+ break;
+ case TVS_CHANNEL_TYPE_DTV:
+ *dtv += sinfo->signal_data.data.s[3];
+ break;
+ default:
+ _ERR("Invalid TVS_CHANNEL_TYPE");
+ break;
+ }
+#endif
+}
+
+/**
+ * Handle the found channel signal when tune lock success.
+ *
+ * @param[in] tvs: Data handler for tv scan manager.
+ * @param[in] sinfo: The channel signal information.
+ */
+static void _handle_found_signal(struct tv_scan *tvs,
+ struct _signal_info *sinfo)
+{
+#if 0
+ if (!tvs || !sinfo) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ /* judge *param.s[0]: antenna type */
+ switch (sinfo->signal_data.data.s[0]) {
+ case TV_SERVICE_ANTENNA_TYPE_AIR:
+ _channel_count(&tvs->res.air_atv,
+ &tvs->res.air_dtv, sinfo);
+ break;
+ case TV_SERVICE_ANTENNA_TYPE_CABLE:
+ _channel_count(&tvs->res.cable_atv,
+ &tvs->res.cable_dtv, sinfo);
+ break;
+ default:
+ _ERR("Invalid channel type");
+ return;
+ }
+
+ if ((sinfo->signal_data.data.s[2] > 0 ||
+ sinfo->signal_data.data.s[3] > 0) && tvs->cbs.found_cb)
+ tvs->cbs.found_cb(tvs, tvs->ch_count, tvs->ch_num, &tvs->res,
+ tvs->cbs.data);
+#endif
+}
+
+/**
+ * Handle the result when scanning is finished.
+ *
+ * @param[in] tvs: Data handler for tv scan manager.
+ * @param[in] sinfo: The channel signal information.
+ */
+static void _handle_done_signal(struct tv_scan *tvs,
+ struct _signal_info *sinfo)
+{
+#if 0
+ if (!tvs || !sinfo) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ if (sinfo->signal_data.data.l[0] == TVS_SCAN_SEARCH_FINISH_COMPLETE) {
+ tvs->state = SCAN_STATE_READY;
+
+ if (tvs->cbs.done_cb)
+ tvs->cbs.done_cb(tvs, &tvs->res, tvs->cbs.data);
+ }
+#endif
+}
+
+/**
+ * Handle the receiving signal saved in tvs->signal_queue.
+ *
+ * @param[in] data: Data handler for tv scan manager.
+ */
+static Eina_Bool _handle_signal(void *data)
+{
+#if 0
+ struct tv_scan *tvs;
+ struct _signal_info *sinfo;
+
+ if (!data)
+ return ECORE_CALLBACK_CANCEL;
+
+ tvs = data;
+
+ if (!tvs->signal_queue)
+ goto stop;
+
+ sinfo = eina_list_data_get(tvs->signal_queue);
+ if (!sinfo)
+ goto stop;
+
+ tvs->signal_queue = eina_list_remove_list(
+ tvs->signal_queue, tvs->signal_queue);
+
+ switch (sinfo->signal) {
+ case TVS_SCAN_EVENT_SEARCH_BEGIN:
+ _handle_begin_signal(tvs, sinfo);
+ break;
+ case TVS_SCAN_EVENT_SEARCH_CHANNEL:
+ _handle_progress_signal(tvs, sinfo);
+ break;
+ case TVS_SCAN_EVENT_CHANNEL_FOUND:
+ _handle_found_signal(tvs, sinfo);
+ break;
+ case TVS_SCAN_EVENT_SEARCH_FINISH:
+ _handle_done_signal(tvs, sinfo);
+ break;
+ default:
+ _ERR("Invalid signal");
+ break;
+ }
+
+ free(sinfo);
+
+ if (!tvs->signal_queue)
+ goto stop;
+
+ return ECORE_CALLBACK_RENEW;
+
+stop:
+ tvs->signal_timer = NULL;
+ return ECORE_CALLBACK_CANCEL;
+#endif
+}
+
+/**
+ * Handle the receiving signal from tv service.
+ *
+ * Tv service will send the signal one by one, and the variable Ecore_Timer:
+ * signal_timer is set for setting the time for dealing with the signal in
+ * signal_queue at regular intervals.
+ *
+ * @param[in] signal: Signal from Tv service.
+ * @param[in] signal_data: Data handler for tv service sacn event.
+ * @param[in] data: Data handler for tv scan manager.
+ */
+#if 0
+static void _signal_received(TvServiceScanEvent signal,
+ TvServiceScanEventData *signal_data, gpointer data)
+{
+ struct tv_scan *tvs;
+ struct _signal_info *sinfo;
+
+ if (!data) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ tvs = data;
+
+ sinfo = calloc(1, sizeof(*sinfo));
+ if (!sinfo) {
+ _ERR("calloc failed");
+ return;
+ }
+
+ sinfo->signal = signal;
+ sinfo->signal_data = *signal_data;
+ sinfo->scan_type = tvs->scan_type;
+
+ tvs->signal_queue = eina_list_append(
+ tvs->signal_queue, sinfo);
+
+ if (!tvs->signal_timer) {
+ tvs->signal_timer = ecore_timer_add(SIGNAL_HANDLER_INTERVAL,
+ _handle_signal, tvs);
+ if (!tvs->signal_timer) {
+ _ERR("add timer failed.");
+ tvs->signal_queue = eina_list_remove(tvs->signal_queue,
+ sinfo);
+ free(sinfo);
+ return;
+ }
+ }
+}
+#endif
+
+/**
+ * Initialize the tv scan manager object
+ *
+ * In this function, it will create tv_scan struct object, and get the related
+ * scan mode (one of TVS_SCAN_ALL_ANALOG_DIGITAL /
+ * TVS_SCAN_CABLE_ANALOG_DIGITAL / TVS_SCAN_AIR_ANALOG_DIGITAL)
+ * fron tv service according to the optional setting mode
+ * (one of AIR / CABLE / ALL) in scan_start view,
+ * and register TvServiceScan object and set it for variable service_scan,
+ * and set the initial scan state SCAN_STATE_READY.
+ *
+ * @param[in] mode: the setting mode (one of AIR / CABLE / ALL) in
+ * view_scan_start
+ * @return The struct tvs or NULL if initialize failed
+ */
+struct tv_scan *tv_scan_init(enum antenna_mode mode)
+{
+#if 0
+ struct tv_scan *tvs;
+ TvServiceScan scan;
+ TvServiceScanType type;
+ gint result;
+ int r;
+
+ tvs = calloc(1, sizeof(*tvs));
+ if (!tvs) {
+ _ERR("calloc failed");
+ return NULL;
+ }
+
+ r = _get_scan_mode(mode, &type);
+ if (r == -1) {
+ _ERR("Get scan mode failed");
+ free(tvs);
+ return NULL;
+ }
+
+ result = tv_service_scan_create(&scan, type);
+ if (result != TVS_ERROR_OK) {
+ _ERR("Create Scan failed");
+ free(tvs);
+ return NULL;
+ }
+
+ tvs->service_scan = scan;
+ tvs->scan_type = type;
+ tvs->set_mode = mode;
+ tvs->state = SCAN_STATE_READY;
+
+ return tvs;
+#endif
+ return NULL;
+}
+
+/**
+ * Release tv_scan struct resource
+ *
+ * In this function, it will release the object in tv_scan struct object,
+ * include channel information saved in signal_queue and the Ecore_Timer object
+ * and so on.
+ *
+ * @param[in] tvs: Data handler for tv scan manager.
+ * @return 0 on success otherwise -1
+ */
+int tv_scan_fini(struct tv_scan *tvs)
+{
+#if 0
+ struct _signal_info *sinfo;
+
+ if (!tvs) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ if (tvs->state != SCAN_STATE_READY)
+ tv_scan_stop(tvs);
+
+ if (tvs->signal_timer)
+ ecore_timer_del(tvs->signal_timer);
+
+ EINA_LIST_FREE(tvs->signal_queue, sinfo)
+ free(sinfo);
+
+ tv_service_scan_destroy(tvs->service_scan);
+ free(tvs);
+
+#endif
+ return 0;
+}
+
+/**
+ * Register callbacks for tvs struct
+ *
+ * @param[in] tvs: Data handler for tv scan manager.
+ * @param[in] cbs: The registered callbacks for control the scan state
+ * @return 0 on success otherwise -1
+ */
+int tv_scan_set_callbacks(struct tv_scan *tvs, struct tv_scan_cbs *cbs)
+{
+ if (!tvs || !cbs) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ tvs->cbs = *cbs;
+
+ return 0;
+}
+
+/**
+ * Start scanning channels
+ *
+ * @param[in] tvs: Data handler for tv scan manager.
+ * @return 0 on success otherwise -1
+ */
+int tv_scan_start(struct tv_scan *tvs)
+{
+#if 0
+ gint result;
+
+ if (!tvs || !tvs->service_scan) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ if (tvs->state != SCAN_STATE_READY) {
+ _ERR("unable state to start scan");
+ return -1;
+ }
+
+ result = tv_service_scan_register_callback(tvs->service_scan,
+ _signal_received, (gpointer)tvs);
+ if (result != TVS_ERROR_OK) {
+ _ERR("register callback failed");
+ return -1;
+ }
+
+ result = tv_service_scan_start(tvs->service_scan);
+ if (result != TVS_ERROR_OK) {
+ _ERR("scan start failed");
+ return -1;
+ }
+
+ tvs->state = SCAN_STATE_SEARCHING;
+ tvs->is_stopped = 0;
+ tvs->ch_count = 0;
+ memset(&tvs->res, 0x00, sizeof(tvs->res));
+
+ return 0;
+#endif
+ return -1;
+}
+
+/**
+ * Pause the scanning of channels
+ *
+ * In this function, it will invoke the pausing function from tv service
+ * for pausing the scaning and stop sending channel signals.
+ *
+ * @param[in] tvs: Data handler for tv scan manager.
+ * @return 0 on success otherwise -1
+ */
+int tv_scan_pause(struct tv_scan *tvs)
+{
+#if 0
+ gint result;
+
+ if (!tvs || !tvs->service_scan) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ if (tvs->state != SCAN_STATE_SEARCHING) {
+ _ERR("unable state to pause scan");
+ return -1;
+ }
+
+ result = tv_service_scan_pause(tvs->service_scan);
+ if (result != TVS_ERROR_OK) {
+ _ERR("Pause Scan failed");
+ return -1;
+ }
+
+ tvs->state = SCAN_STATE_PAUSED;
+
+ return 0;
+#endif
+}
+
+
+/**
+ * Resume the paused scanning of channels
+ *
+ * @param[in] tvs: Data handler for tv scan manager.
+ * @return 0 on success otherwise -1
+ */
+int tv_scan_resume(struct tv_scan *tvs)
+{
+#if 0
+ gint result;
+
+ if (!tvs || !tvs->service_scan) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ if (tvs->state != SCAN_STATE_PAUSED) {
+ _ERR("unable state to resume scan");
+ return -1;
+ }
+
+ result = tv_service_scan_resume(tvs->service_scan);
+ if (result != TVS_ERROR_OK) {
+ _ERR("resume Scan failed");
+ return -1;
+ }
+
+ tvs->state = SCAN_STATE_SEARCHING;
+
+ return 0;
+#endif
+ return -1;
+}
+
+/**
+ * Stop the scanning of channels
+ *
+ * Stop the scanning and stop receiving channel signal
+ *
+ * @param[in] tvs: Data handler for tv scan manager.
+ * @return 0 on success otherwise -1
+ */
+int tv_scan_stop(struct tv_scan *tvs)
+{
+#if 0
+ gint result;
+
+ if (!tvs) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ if (tvs->state == SCAN_STATE_READY) {
+ _ERR("unable state to stop scan");
+ return -1;
+ }
+
+ result = tv_service_scan_stop(tvs->service_scan);
+ if (result != TVS_ERROR_OK) {
+ _ERR("Create Scan failed");
+ return -1;
+ }
+
+ tvs->state = SCAN_STATE_STOPPING;
+ tvs->is_stopped = 1;
+
+ return 0;
+#endif
+ return -1;
+}
+
+/**
+ * Get the total number of channel signals saved in
+ * data handler for tv scan manager
+ *
+ * @param[in] tvs: Data handler for tv scan manager.
+ * @return 0 on success otherwise -1
+ */
+int tv_scan_get_total_channel(struct tv_scan *tvs)
+{
+ if (!tvs) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ return tvs->total_ch;
+}
+
+/**
+ * Get the scanning result of channel signals
+ *
+ * There are four kinds of channel signals: ATV air, ATV cable, DTV air and
+ * DTV cable, and the numner of the channel signal is saved in variable
+ * tvs->res.
+ *
+ * @param[in] tvs: Data handler for tv scan manager.
+ * @return The tv_scan_result struct
+ */
+struct tv_scan_result *tv_scan_get_result(struct tv_scan *tvs)
+{
+ if (!tvs) {
+ _ERR("Invalid argument");
+ return NULL;
+ }
+
+ return &tvs->res;
+}
+
+/**
+ * Get the state of scanning of channels
+ *
+ * Get the state of scanning of channels to judge whether the scanning
+ * is stopped.
+ *
+ * @param[in] tvs: Data handler for tv scan manager.
+ * @return 0 on success otherwise -1
+ */
+int tv_scan_is_stopped(struct tv_scan *tvs)
+{
+ if (!tvs) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ return tvs->is_stopped;
+}
diff --git a/ug/channel/src/ug_auto_program.cpp b/ug/channel/src/ug_auto_program.c
index b0cc25e..6097aa6 100644
--- a/ug/channel/src/ug_auto_program.cpp
+++ b/ug/channel/src/ug_auto_program.c
@@ -18,30 +18,17 @@
#define UG_MODULE_API __attribute__ ((visibility("default")))
#endif
+#include <Elementary.h>
+#include <app.h>
#include "defs.h"
-#include <AppCommon.h>
+#include "dbg.h"
+#include "viewmgr_auto_program.h"
#include "ug_auto_program.h"
+#include "view_scan_start.h"
+#include "view_search_page.h"
+#include "view_result_page.h"
#include "util.h"
-#include "TVServiceMgr.h"
-#include "ChannelMainView.h"
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
-struct _ug_data {
- ui_gadget_h ug;
-
- Evas_Object *win;
- Evas_Object *base;
-
- enum antenna_mode scan_type;
- int find_chs;
-
- CViewMgr *pViewMgr;
- CChannelMainView *pChannelMainView;
-};
-
/**
* Creates the base layout for channel UI gadget
*
@@ -64,48 +51,45 @@ struct _ug_data {
static void *_on_create(ui_gadget_h ug, enum ug_mode mode,
service_h service, void *priv)
{
- struct _ug_data *ugd;
Evas_Object *win;
+ struct _ugdata *ugd;
+ struct viewmgr *vmgr;
if (!ug || !priv) {
- _ERR("Parameter error!");
+ _ERR("ug: %p , priv: %p ", ug, priv);
return NULL;
}
- ugd = (struct _ug_data *) priv;
- ugd->ug = ug;
+ ugd = priv;
elm_theme_extension_add(NULL, AUTO_PRGM_EDJ_THEME);
- win = (Evas_Object *) ug_get_window();
+ win = ug_get_window();
if (!win) {
_ERR("window get failed");
return NULL;
}
- ugd->win = win;
-
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
elm_win_focus_highlight_style_set(win, INVISIBLE);
- CViewMgr::Initialize(ugd->win, NULL);
- ugd->pViewMgr = CViewMgr::GetInstance();
- if(!ugd->pViewMgr) {
- CViewMgr::Finalize();
- _ERR("Fail to get CViewMgr instance");
+ vmgr = viewmgr_init(win);
+ if (!vmgr) {
+ _ERR("viewmgr init failed");
return NULL;
}
- ugd->pChannelMainView = new CChannelMainView(CHANNEL_MAINVIEW);
- if(!ugd->pViewMgr->AddView(ugd->pChannelMainView)) {
- _ERR("Fail to add pFbBaseView");
- CViewMgr::Finalize();
- return false;
- }
- ugd->pViewMgr->PushView(CHANNEL_MAINVIEW, ugd->ug);
- ugd->base = ugd->pChannelMainView->Base();
+ ugd->ug = ug;
+ ugd->win = win;
+ ugd->vmgr = vmgr;
- return ugd->base;
+ if (viewmgr_push(vmgr, view_scanstart_get_vclass(), ugd) == -1) {
+ _ERR("scan view push failed");
+ viewmgr_fini(vmgr);
+ return NULL;
+ }
+
+ return ugd->ugd_base;
}
/**
@@ -167,7 +151,18 @@ static void _on_resume(ui_gadget_h ug, service_h service, void *priv)
*/
static void _on_destroy(ui_gadget_h ug, service_h service, void *priv)
{
- CViewMgr::Finalize();
+ struct _ugdata *ugd;
+
+ if (!ug || !priv) {
+ _ERR("Invalid parameter.");
+ return;
+ }
+
+ ugd = priv;
+
+ viewmgr_fini(ugd->vmgr);
+
+ return;
}
/**
@@ -235,12 +230,12 @@ static void _on_event(ui_gadget_h ug, enum ug_event event,
*/
UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
{
- struct _ug_data *ugd;
+ struct _ugdata *ugd;
if (!ops)
return -1;
- ugd = (struct _ug_data *) calloc(1, sizeof(*ugd));
+ ugd = calloc(1, sizeof(*ugd));
if (!ugd)
return -1;
@@ -267,15 +262,11 @@ UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
*/
UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
{
- struct _ug_data *ugd;
+ struct _ugdata *ugd;
if (!ops)
return;
- ugd = (struct _ug_data *)ops->priv;
+ ugd = ops->priv;
free(ugd);
}
-
-#if defined (__cplusplus)
-};
-#endif
diff --git a/ug/channel/src/util.cpp b/ug/channel/src/util.c
index b1e52da..140fe1b 100644
--- a/ug/channel/src/util.cpp
+++ b/ug/channel/src/util.c
@@ -19,7 +19,7 @@
#include <aul.h>
#include <app.h>
#include "defs.h"
-#include <MacroDefine.h>
+#include "dbg.h"
#include "util.h"
/**
diff --git a/ug/channel/src/view_result_page.c b/ug/channel/src/view_result_page.c
new file mode 100644
index 0000000..2bb6bbb
--- /dev/null
+++ b/ug/channel/src/view_result_page.c
@@ -0,0 +1,240 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <Elementary.h>
+#include <app.h>
+#include <system_info.h>
+#include "dbg.h"
+#include "defs.h"
+#include "util.h"
+#include "viewmgr_auto_program.h"
+#include "ug_auto_program.h"
+#include "view_search_page.h"
+#include "view_result_page.h"
+
+#define RESULT_MSG_SIZE 60
+
+#define _GET_PRIV(o) evas_object_data_get(o, "RESDATA")
+#define _SET_PRIV(o, data) evas_object_data_set(o, "RESDATA", data)
+
+struct _data {
+ Evas_Object *win;
+ Evas_Object *base;
+ Evas_Object *ok_btn;
+ struct viewmgr *vmgr;
+ struct _ugdata *ugd;
+};
+
+/**
+ * @Evas_Smart_Cb type callback for handling the click callback event for
+ * "OK" button.
+ *
+ * When "OK" button is clicked, channel ug will exit.
+ *
+ * @param[in] data: the user data related to current view
+ * @param[in] obj: the corresponding object on which the button click event
+ * occurred
+ *
+ * @param[in] ev: event information
+ */
+static void _ok_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _ugdata *ugd;
+ struct _data *priv;
+
+ if (!data) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = data;
+ ugd = priv->ugd;
+
+ if (!ugd || !ugd->ug) {
+ _ERR("ugd->ug is NULL");
+ return;
+ }
+
+ ug_destroy_me(ugd->ug);
+}
+
+/**
+ * Initializes the base layout for scanning result view.
+ *
+ * Create the layout of scanning result view.
+ *
+ * @param[in] vmgr: the handler to the struct object for managing the view
+ * @param[in] data: the user data related to current view
+ * @return The base or NULL if creatting failed
+ */
+static Evas_Object *_create(struct viewmgr *vmgr, void *data)
+{
+ Evas_Object *base;
+ Evas_Object *win;
+ struct _data *priv;
+ struct _ugdata *ugd;
+
+ if (!vmgr || !data) {
+ _ERR("Invalid argument");
+ return NULL;
+ }
+
+ ugd = data;
+
+ win = viewmgr_get_win(vmgr);
+ if (!win)
+ return NULL;
+
+ priv = calloc(1, sizeof(*priv));
+ if (!priv)
+ return NULL;
+
+ base = util_add_layout(win, AUTO_PRGM_EDJ_FILE, GROUP_RES);
+ if (!base) {
+ free(priv);
+ return NULL;
+ }
+
+ elm_win_resize_object_add(win, base);
+
+ priv->win = win;
+ priv->base = base;
+ priv->ugd = ugd;
+ priv->vmgr = vmgr;
+
+ _SET_PRIV(base, priv);
+
+ return base;
+}
+
+/**
+ * Invoked after _create() function as defined in viewmgr_push().
+ *
+ * Create the button in result view, and show the information about the
+ * number of found channels.
+ *
+ * @param[in] base: the layout of the view
+ */
+static void _update(Evas_Object *base)
+{
+ Evas_Object *ok_btn;
+ struct _data *priv;
+ char msg[RESULT_MSG_SIZE];
+ int chs;
+
+ if (!base) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = _GET_PRIV(base);
+ if (!priv) {
+ _ERR("Data get failed");
+ return;
+ }
+
+ chs = priv->ugd->find_chs;
+
+ snprintf(msg, sizeof(msg), "%s<br>%d %s", COMPLETE_MAIN_TITLE,
+ chs, TEXT_CH_MEMORIZED);
+ elm_object_part_text_set(priv->base, PART_RES_MAIN_TITLE, msg);
+
+ ok_btn = util_add_button(priv->base, BTN_STYLE,
+ PART_OK_BTN, TEXT_BUTTON_OK, EINA_TRUE);
+ if (!ok_btn) {
+ _ERR("ok_btn is NULL");
+ return;
+ }
+
+ priv->ok_btn = ok_btn;
+ elm_object_focus_set(ok_btn, EINA_TRUE);
+ evas_object_smart_callback_add(ok_btn, SIGNAL_CLICKED,
+ _ok_btn_clicked_cb, priv);
+
+ util_focus_next_set(ok_btn);
+}
+
+/**
+ * Resume the application.
+ *
+ * @param[in] base: the layout of the view
+ */
+static void _resume(Evas_Object *base)
+{
+ evas_object_show(base);
+}
+
+/**
+ * Pause the application.
+ *
+ * Hide the layout
+ *
+ * @param[in] base: the layout of the view
+ */
+static void _pause(Evas_Object *base)
+{
+ evas_object_hide(base);
+}
+
+/**
+ * Called after the main loop of the view exits.
+ *
+ * Delete the layout and release the resourse
+ *
+ * @param[in] base: the layout of the view
+ */
+static void _terminate(Evas_Object *base)
+{
+ struct _data *priv;
+
+ if (!base) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = _GET_PRIV(base);
+ if (!priv) {
+ _ERR("Data get failed");
+ return;
+ }
+
+ if (priv->base)
+ evas_object_del(priv->base);
+
+ free(priv);
+}
+
+/**
+ * This struct is for registering the callbacks for the view
+ */
+static struct view_class _vclass = {
+ .title = VIEW_RESULT,
+ .create = _create,
+ .update = _update,
+ .resume = _resume,
+ .pause = _pause,
+ .terminate = _terminate,
+};
+
+ /**
+ * Returns current view_class which implements the result view's life cycle
+ *
+ * @return view_class
+ */
+struct view_class *view_resultpage_get_vclass(void)
+{
+ return &_vclass;
+}
diff --git a/ug/channel/src/view_scan_start.c b/ug/channel/src/view_scan_start.c
new file mode 100644
index 0000000..aca992e
--- /dev/null
+++ b/ug/channel/src/view_scan_start.c
@@ -0,0 +1,697 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co. Ltd All Rights Reserved
+ *
+ * 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 <Elementary.h>
+#include <Ecore_Evas.h>
+#include <system_info.h>
+#include <app.h>
+
+#include <KeyDefine.h>
+
+#include "ug_auto_program.h"
+#include "view_scan_start.h"
+#include "view_search_page.h"
+#include "view_result_page.h"
+#include "viewmgr_auto_program.h"
+#include "dbg.h"
+#include "defs.h"
+#include "tv_scan.h"
+#include "util.h"
+
+#define HORIZONTAL_ALIGN 0.5
+#define VERTICAL_ALIGN 0.0
+#define MAX_ITEMS 3
+#define ALL "All"
+#define CABLE "Cable"
+#define AIR "Air"
+
+#define _GET_PRIV(o) evas_object_data_get(o, "SCANSTARTDATA")
+#define _SET_PRIV(o, data) evas_object_data_set(o, "SCANSTARTDATA", data)
+
+enum antenna_type {
+ ALL_ITEM,
+ CABLE_ITEM,
+ AIR_ITEM
+};
+
+struct _data {
+ Evas_Object *win;
+ Evas_Object *base;
+ Evas_Object *start_btn;
+ Evas_Object *cancel_btn;
+ Evas_Object *box;
+ Evas_Object *last_focus_item;
+ Evas_Object *selected_item;
+ Evas_Object *atn_btn[MAX_ITEMS];
+ struct viewmgr *vmgr;
+ struct _ugdata *ugd;
+ enum antenna_mode scan_type;
+};
+
+struct _antenna_info {
+ char *style;
+ Evas_Smart_Cb cb;
+ char *text;
+};
+
+/**
+ * @EVAS_CALLBACK_KEY_DOWN type callback for handling key pressed callback
+ * event
+ *
+ * @param[in] data: user data related to current view
+ * @param[in] e: evas handler
+ * @param[in] obj: the corresponding object on which the key pressed event
+ * occurred
+ * @param[in] ei: event information
+ */
+static void _key_pressed_cb(void *data, Evas *e, Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _data *priv;
+ struct _ugdata *ugd;
+
+ if (!data || !ei) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+ ev = ei;
+
+ if (!priv->ugd) {
+ _ERR("priv->ugd is NULL");
+ return;
+ }
+
+ ugd = priv->ugd;
+
+ if (!ugd->ug) {
+ _ERR("ugd->ug is NULL");
+ return;
+ }
+
+ if (!ev->keyname) {
+ _ERR("ev->keyname NULL!");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_BACK))
+ ug_destroy_me(ugd->ug);
+}
+
+/**
+ * @Evas_Smart_Cb type callback for handling the click callback event for
+ * "start" button.
+ *
+ * @param[in] data: user data related to current view
+ * @param[in] obj: the corresponding object on which the button click event
+ * occurred
+ * @param[in] ev: event information
+ */
+static void _start_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _data *priv;
+ Eina_Bool tuner_exist;
+
+ if (!data) {
+ _ERR("data is NULL");
+ return;
+ }
+
+ priv = data;
+
+ if (!priv->ugd || !priv->vmgr) {
+ _ERR("parameter is NULL");
+ return;
+ }
+
+ /*
+ * TODO: add the interface when TV service provider the related API.
+ * Here is a pseudo-data.
+ */
+ tuner_exist = EINA_TRUE;
+ if (!tuner_exist) {
+ /*
+ * TODO: popup the notification iniformation:
+ * there is no tuner
+ */
+ return;
+ }
+
+ if (viewmgr_push(priv->vmgr, view_searchpage_get_vclass(),
+ priv->ugd) == -1) {
+ _ERR("search view push failed");
+ return;
+ }
+}
+
+ /**
+ * @Evas_Smart_Cb type callback for handling the click callback event for
+ * "cancel" button.
+ *
+ * @param[in] data: user data related to current view
+ * @param[in] obj: the corresponding object on which the button click event
+ * occurred
+ * @param[in] ev: event information
+ */
+static void _cancel_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _data *priv;
+ struct _ugdata *ugd;
+
+ if (!data) {
+ _ERR("data is NULL");
+ return;
+ }
+
+ priv = data;
+
+ if (!priv->ugd) {
+ _ERR("priv->ugd is NULL");
+ return;
+ }
+
+ ugd = priv->ugd;
+
+ if (!ugd->ug) {
+ _ERR("ugd->ug is NULL");
+ return;
+ }
+
+ ug_destroy_me(ugd->ug);
+}
+
+/**
+ * Callback function for button focus event.
+ *
+ * @param[in] data: user data related to current view
+ * @param[in] obj: the corresponding object on which the button focus event
+ * occurred
+ * @param[in] emission: the signal's name.
+ * @param[in] source: the signal's source.
+ */
+static void _btn_focused_cb(void *data, Evas_Object *obj,
+ const char *emission, const char *source)
+{
+ struct _data *priv;
+
+ if (!obj || !data) {
+ _ERR("Invalid parameter");
+ return;
+ }
+
+ priv = data;
+
+ if (priv->last_focus_item) {
+ elm_object_signal_emit(priv->last_focus_item,
+ SIGNAL_SHOWLINE, CHANNEL_SOURCE);
+ elm_object_signal_emit(obj, SIGNAL_HIDELINE, CHANNEL_SOURCE);
+ } else {
+ elm_object_signal_emit(obj, SIGNAL_SHOWLINE, CHANNEL_SOURCE);
+ }
+
+ priv->last_focus_item = obj;
+}
+
+/**
+ * Callback function for button unfocus event.
+ *
+ * @param[in] data: user data related to current view
+ * @param[in] obj: the corresponding object on which the button focus event
+ * occurred
+ * @param[in] emission: the signal's name.
+ * @param[in] source: the signal's source.
+ */
+static void _btn_unfocused_cb(void *data, Evas_Object *obj,
+ const char *emission, const char *source)
+{
+ struct _data *priv;
+
+ if (!obj || !data) {
+ _ERR("Invalid parameter");
+ return;
+ }
+
+ priv = data;
+ elm_object_signal_emit(priv->last_focus_item,
+ SIGNAL_SHOWLINE, CHANNEL_SOURCE);
+}
+
+/**
+ * Set the focus sequence for the objects in the layout.
+ *
+ * @param[in] data: user data related to current view
+ */
+static void _update_focus_sequence(struct _data *priv)
+{
+ if (!priv) {
+ _ERR("Invalid parameter");
+ return;
+ }
+
+ elm_object_focus_next_object_set(priv->atn_btn[ALL_ITEM],
+ priv->start_btn, ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(priv->atn_btn[CABLE_ITEM],
+ priv->start_btn, ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(priv->atn_btn[AIR_ITEM],
+ priv->start_btn, ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(priv->atn_btn[ALL_ITEM],
+ priv->atn_btn[ALL_ITEM], ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(priv->atn_btn[CABLE_ITEM],
+ priv->atn_btn[CABLE_ITEM], ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(priv->atn_btn[AIR_ITEM],
+ priv->atn_btn[AIR_ITEM], ELM_FOCUS_LEFT);
+
+ if (priv->selected_item) {
+ elm_object_focus_next_object_set(priv->start_btn,
+ priv->selected_item, ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(priv->cancel_btn,
+ priv->selected_item, ELM_FOCUS_LEFT);
+ } else {
+ elm_object_focus_next_object_set(priv->start_btn,
+ priv->atn_btn[ALL_ITEM], ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(priv->cancel_btn,
+ priv->atn_btn[ALL_ITEM], ELM_FOCUS_LEFT);
+ }
+
+ elm_object_focus_next_object_set(priv->start_btn,
+ priv->cancel_btn, ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(priv->cancel_btn,
+ priv->start_btn, ELM_FOCUS_DOWN);
+ elm_object_focus_next_object_set(priv->cancel_btn,
+ priv->start_btn, ELM_FOCUS_UP);
+}
+
+/**
+ * @Evas_Smart_Cb type callback for handling the click callback event.
+ *
+ * @param[in] data: user data related to current view
+ * @param[in] obj: the corresponding object on which the button click event
+ * occurred
+ * @param[in] ev: event information
+ */
+static void _item_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _data *priv;
+ const char *text;
+
+ if (!data || !obj) {
+ _ERR("Invalid parameter");
+ return;
+ }
+
+ priv = data;
+
+ if (!priv->selected_item) {
+ elm_object_focus_set(obj, EINA_TRUE);
+ elm_object_signal_emit(obj, SIGNAL_SELECTED, CHANNEL_SOURCE);
+ priv->selected_item = obj;
+ } else {
+ if (priv->selected_item != obj) {
+ elm_object_signal_emit(priv->selected_item,
+ SIGNAL_UNSELECTED, CHANNEL_SOURCE);
+ elm_object_signal_emit(obj, SIGNAL_SELECTED,
+ CHANNEL_SOURCE);
+ priv->selected_item = obj;
+ }
+ }
+
+ text = elm_object_text_get(priv->selected_item);
+ if (text && !strcmp(text, ALL))
+ priv->scan_type = SCAN_TYPE_ALL;
+ else if (text && !strcmp(text, CABLE))
+ priv->scan_type = SCAN_TYPE_CABLE;
+ else if (text && !strcmp(text, AIR))
+ priv->scan_type = SCAN_TYPE_AIR;
+ else
+ priv->scan_type = SCAN_TYPE_INVALID;
+
+ priv->ugd->scan_type = priv->scan_type;
+
+ _update_focus_sequence(priv);
+}
+
+/**
+ * Clear the content of the box.
+ *
+ * @param[in] data: user data related to current view
+ */
+static void _clear_box(struct _data *data)
+{
+ if (!data) {
+ _ERR("Invalid parameter.");
+ return;
+ }
+
+ if (!data->box) {
+ _ERR("data->box is NULL");
+ return;
+ }
+
+ elm_box_clear(data->box);
+
+ data->last_focus_item = NULL;
+ data->selected_item = NULL;
+}
+
+/**
+ * Add items in the box of the layout.
+ *
+ * @param[in] parent: the box created in the layout.
+ * @param[in] btnstyle: the style of the button
+ * @param[in] btntext: the text shown in button
+ * @param[in] fun_cb: the click callback function for the button
+ * @param[in] data: user data related to current view
+ * @return Button or NULL if creatting failed
+ */
+static Evas_Object *_add_exit_item(Evas_Object *parent, const char *btnstyle,
+ const char *btntext, Evas_Smart_Cb fun_cb, struct _data *data)
+{
+ Evas_Object *btn;
+
+ if (!data) {
+ _ERR("Invalid parameter.");
+ return NULL;
+ }
+
+ if (!parent || !btnstyle || !btntext || !fun_cb) {
+ _ERR("Invalid parameter.");
+ return NULL;
+ }
+
+ btn = util_add_button(parent, btnstyle, NULL, btntext, EINA_TRUE);
+ if (!btn) {
+ _ERR("add item failed");
+ return NULL;
+ }
+
+ elm_box_pack_end(parent, btn);
+ evas_object_smart_callback_add(btn, SIGNAL_CLICKED,
+ fun_cb, data);
+ elm_object_signal_callback_add(btn, SIGNAL_FOCUSED,
+ ELM_SOURCE, _btn_focused_cb, data);
+ elm_object_signal_callback_add(btn, SIGNAL_UNFOCUSED,
+ ELM_SOURCE, _btn_unfocused_cb, data);
+
+ return btn;
+}
+
+/**
+ * Create the item list of antenna type .
+ *
+ * @param[in] data: user data related to current view
+ */
+static void _update_antenna_list(struct _data *data)
+{
+ Evas_Object *btn;
+ int i;
+ struct _antenna_info atninfo[] = {
+ [ALL_ITEM] = {
+ .style = ITEM_STYLE,
+ .cb = _item_clicked_cb,
+ .text = ALL
+ },
+ [CABLE_ITEM] = {
+ .style = ITEM_STYLE,
+ .cb = _item_clicked_cb,
+ .text = CABLE
+ },
+ [AIR_ITEM] = {
+ .style = ITEM_STYLE,
+ .cb = _item_clicked_cb,
+ .text = AIR
+ }
+ };
+
+ if (!data) {
+ _ERR("Invalid parameter.");
+ return;
+ }
+
+ if (!data->base || !data->box) {
+ _ERR("Invalid parameter.");
+ return;
+ }
+
+ _clear_box(data);
+
+ for (i = 0; i < MAX_ITEMS; i++) {
+ btn = _add_exit_item(data->box, atninfo[i].style,
+ atninfo[i].text, atninfo[i].cb, data);
+ if (!btn) {
+ _ERR("add exist item failed.");
+ return;
+ }
+
+ data->atn_btn[i] = btn;
+
+ if (i == 0) {
+ elm_object_focus_set(btn, EINA_TRUE);
+ elm_object_signal_emit(btn,
+ SIGNAL_SELECTED, CHANNEL_SOURCE);
+ data->selected_item = btn;
+ }
+ }
+
+ _update_focus_sequence(data);
+}
+
+/**
+ * Create box in the layout for adding item in it.
+ *
+ * @param[in] base: the layout created in _creat() of current view
+ * @return The box or NULL if creatting failed
+ */
+static Evas_Object *_create_box(Evas_Object *base)
+{
+ Evas_Object *box;
+ struct _data *priv;
+
+ if (!base) {
+ _ERR("base is NULL");
+ return NULL;
+ }
+
+ priv = _GET_PRIV(base);
+ if (!priv) {
+ _ERR("Data get failed");
+ return NULL;
+ }
+
+ box = util_add_box(base, HORIZONTAL_ALIGN, VERTICAL_ALIGN);
+ if (!box) {
+ _ERR("box add failed");
+ return NULL;
+ }
+
+ elm_object_part_content_set(base, PART_ANTENNA_LIST, box);
+ evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0);
+
+ return box;
+}
+
+/**
+ * Initializes the base layout for scanning start view.
+ *
+ * Create the beginning view layout based on window
+ *
+ * @param[in] vmgr: the handler to the struct object for managing the view
+ * @param[in] data: the user data related to current view
+ * @return The base or NULL if creatting failed
+ */
+static Evas_Object *_create(struct viewmgr *vmgr, void *data)
+{
+ Evas_Object *base;
+ Evas_Object *win;
+ Evas_Object *start_btn;
+ Evas_Object *cancel_btn;
+ Evas_Object *box;
+ struct _data *priv;
+ struct _ugdata *ugd;
+
+ if (!vmgr || !data) {
+ _ERR("Invalid argument");
+ return NULL;
+ }
+
+ ugd = (struct _ugdata *)data;
+
+ win = viewmgr_get_win(vmgr);
+ if (!win) {
+ _ERR("get win failed.");
+ return NULL;
+ }
+
+ priv = calloc(1, sizeof(*priv));
+ if (!priv) {
+ _ERR("calloc memory failed.");
+ return NULL;
+ }
+
+ base = util_add_layout(win, AUTO_PRGM_EDJ_FILE, GRP_SCAN_START);
+ if (!base) {
+ _ERR("scan start layout creat failed!");
+ free(priv);
+ return NULL;
+ }
+
+ elm_win_resize_object_add(win, base);
+ evas_object_event_callback_add(base, EVAS_CALLBACK_KEY_DOWN,
+ _key_pressed_cb, priv);
+ elm_object_part_text_set(base, PART_STAR_MAIN_TITLE_BLOCK,
+ START_MAIN_TITLE);
+
+ start_btn = util_add_button(base, BTN_STYLE,
+ PART_START_BTN, TEXT_BTN_START, EINA_TRUE);
+ if (!start_btn) {
+ _ERR("create start_btn failed");
+ goto aborting;
+ }
+
+ cancel_btn = util_add_button(base, BTN_STYLE,
+ PART_CANCEL_BTN, TEXT_BTN_CANCEL, EINA_TRUE);
+ if (!cancel_btn) {
+ _ERR("create cancel_btn failed");
+ goto aborting;
+ }
+
+ priv->base = base;
+ priv->start_btn = start_btn;
+ priv->cancel_btn = cancel_btn;
+ priv->ugd = ugd;
+ priv->ugd->ugd_base = base;
+ priv->vmgr = vmgr;
+ priv->win = win;
+
+ _SET_PRIV(base, priv);
+
+ evas_object_smart_callback_add(start_btn, SIGNAL_CLICKED,
+ _start_btn_clicked_cb, priv);
+ evas_object_smart_callback_add(cancel_btn, SIGNAL_CLICKED,
+ _cancel_btn_clicked_cb, priv);
+
+ evas_object_raise(base);
+
+ box = _create_box(base);
+ if (!box) {
+ _ERR("create box failed.");
+ goto aborting;
+ }
+
+ priv->box = box;
+
+ _update_antenna_list(priv);
+
+ return base;
+
+aborting:
+ evas_object_del(base);
+ free(priv);
+ return NULL;
+}
+
+/**
+ * Invoked when refresh the window of application.
+ *
+ * @param[in] base: the layout of the view
+ *
+ * There is no action in this application.
+ */
+static void _update(Evas_Object *base)
+{
+}
+
+/**
+ * Resume the application.
+ *
+ * @param[in] base: the layout of the view
+ */
+static void _resume(Evas_Object *base)
+{
+ if (!base) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ evas_object_show(base);
+}
+
+/**
+ * Pause the view.
+ *
+ * Hide the layout
+ *
+ * @param[in] base: the layout of the view
+ */
+static void _pause(Evas_Object *base)
+{
+ if (!base) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ evas_object_hide(base);
+}
+
+/**
+ * Called after the main loop of the view exits.
+ *
+ * Delete the layout and release the resourse
+ *
+ * @param[in] base: the layout of the view
+ */
+static void _terminate(Evas_Object *base)
+{
+ struct _data *priv;
+
+ if (!base) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = _GET_PRIV(base);
+ if (!priv) {
+ _ERR("Data get failed");
+ return;
+ }
+
+ if (priv->base)
+ evas_object_del(priv->base);
+
+ free(priv);
+}
+
+/**
+ * This struct is for registering the callbacks for the view
+ */
+static struct view_class _vclass = {
+ .title = VIEW_START,
+ .create = _create,
+ .update = _update,
+ .resume = _resume,
+ .pause = _pause,
+ .terminate = _terminate,
+};
+
+ /**
+ * Returns current view_class which implements the scan start view's life cycle
+ *
+ * @return view_class
+ */
+struct view_class *view_scanstart_get_vclass(void)
+{
+ return &_vclass;
+}
diff --git a/ug/channel/src/view_search_page.c b/ug/channel/src/view_search_page.c
new file mode 100644
index 0000000..d9c1a37
--- /dev/null
+++ b/ug/channel/src/view_search_page.c
@@ -0,0 +1,614 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <Elementary.h>
+#include <Ecore_Evas.h>
+#include <system_info.h>
+#include <app.h>
+#include "ug_auto_program.h"
+#include "view_search_page.h"
+#include "view_result_page.h"
+#include "viewmgr_auto_program.h"
+#include "dbg.h"
+#include "defs.h"
+#include "tv_scan.h"
+#include "util.h"
+
+#define _GET_PRIV(o) evas_object_data_get(o, "SRCHDATA")
+#define _SET_PRIV(o, data) evas_object_data_set(o, "SRCHDATA", data)
+#define MAX_BUF_SIZE 30
+#define CH_NAME_SIZE 30
+#define INITIAL_CH_NUMS 0
+#define PERCENT 100
+#define INITIAL_TEXT "0%"
+#define INITIAL_VALUE 0.0
+
+struct _data {
+ Evas_Object *win;
+ Evas_Object *base;
+ Evas_Object *pb;
+ Evas_Object *stop_btn;
+ Evas_Object *exit_btn;
+ Evas_Object *cancel_btn;
+ struct viewmgr *vmgr;
+ struct tv_scan *tvs;
+ struct _ugdata *ugd;
+};
+
+/**
+ * The statement for "stop" button for clicking callback event, for
+ * there are two buttons with the same text "stop".
+ */
+static void _stop_btn_clicked_cb(void *data, Evas_Object *obj, void *ev);
+
+/**
+ * The click callback event for the "cancel" button.
+ *
+ * When "cancel" button is clicked, the scanning will be resumed.
+ *
+ * @param[in] data: user data related to current view
+ * @param[in] obj: a pointer to the object on which click event occurred
+ * @param[in] ev: event information
+ */
+static void _cancel_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _data *priv;
+ int r;
+
+ if (!data) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = data;
+
+ if (!priv->cancel_btn || !priv->exit_btn) {
+ _ERR("priv->cancel_btn or priv->exit_btn is NULL");
+ return;
+ }
+
+ elm_object_part_text_set(priv->base, PART_SRCH_MAIN_TITLE,
+ SEARCH_MAIN_TITLE);
+
+ r = tv_scan_resume(priv->tvs);
+ if (r != 0) {
+ _ERR("resume tv scan failed.");
+ return;
+ }
+
+ priv->stop_btn = util_add_button(priv->base, BTN_STYLE,
+ PART_STOP_BTN, TEXT_BTN_STOP, EINA_TRUE);
+ if (!priv->stop_btn) {
+ _ERR("stop_btn is NULL");
+ return;
+ }
+
+ elm_object_focus_allow_set(priv->stop_btn, EINA_TRUE);
+ elm_object_focus_set(priv->stop_btn, EINA_TRUE);
+ evas_object_smart_callback_add(priv->stop_btn, SIGNAL_CLICKED,
+ _stop_btn_clicked_cb, priv);
+
+ util_focus_next_set(priv->stop_btn);
+
+ evas_object_del(priv->exit_btn);
+ evas_object_del(priv->cancel_btn);
+ priv->exit_btn = NULL;
+ priv->cancel_btn = NULL;
+}
+
+/**
+ * @Evas_Smart_Cb type callback for handling the click callback event for
+ * "stop" button.
+ *
+ * The click callback event for the "stop" button in paused view.
+ * When the "stop" button in paused view is clicked, the scanning will
+ * be stopped, and channel ug will be exited.
+ *
+ * @param[in] data: user data related to current view
+ * @param[in] obj: a pointer to the object on which click event occurred
+ * @param[in] ev: event information
+ */
+static void _destroy_search_page_cb(void *data, Evas_Object *obj,
+ void *ev)
+{
+ struct _ugdata *ugd;
+ struct _data *priv;
+ int r;
+
+ if (!data) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = data;
+
+ if (!priv->ugd || !priv->tvs) {
+ _ERR("priv->ugd or priv->tvs is NULL");
+ return;
+ }
+
+ ugd = priv->ugd;
+
+ r = tv_scan_stop(priv->tvs);
+ if (r != 0) {
+ _ERR("tv_scan_stop failed");
+ return;
+ }
+
+ if (!ugd->ug) {
+ _ERR("ugd->ug is NULL");
+ return;
+ }
+
+ ug_destroy_me(ugd->ug);
+}
+
+/**
+ * @Evas_Smart_Cb type callback for handling the click callback event for
+ * "stop" button.
+ *
+ * When the "stop" button is clicked, the scanning will be paused, the view
+ * will be changed into paused state.
+ *
+ * @param[in] data: user data related to current view
+ * @param[in] obj: a pointer to the object on which click event occurred
+ * @param[in] ev: event information
+ */
+static void _stop_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _data *priv;
+ int r;
+
+ if (!data || !obj) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = data;
+
+ if (!priv->base || !priv->tvs) {
+ _ERR("priv->base or priv->tvs is NULL");
+ return;
+ }
+
+ r = tv_scan_pause(priv->tvs);
+ if (r != 0) {
+ _ERR("tv_scan_pause failed");
+ return;
+ }
+
+ elm_object_part_text_set(priv->base, PART_SRCH_MAIN_TITLE,
+ PAUSE_MAIN_TITLE);
+
+ priv->exit_btn = util_add_button(priv->base, BTN_STYLE,
+ PART_EXIT_BTN, TEXT_BTN_STOP, EINA_TRUE);
+ if (!priv->exit_btn) {
+ _ERR("exit_btn is NULL");
+ return;
+ }
+
+ evas_object_smart_callback_add(priv->exit_btn, SIGNAL_CLICKED,
+ _destroy_search_page_cb, priv);
+
+ priv->cancel_btn = util_add_button(priv->base, BTN_STYLE,
+ PART_SRCH_CANCEL_BTN, TEXT_BTN_CANCEL, EINA_TRUE);
+ if (!priv->cancel_btn) {
+ _ERR("cancel_btn is NULL");
+ evas_object_del(priv->exit_btn);
+ priv->exit_btn = NULL;
+ return;
+ }
+
+ evas_object_smart_callback_add(priv->cancel_btn, SIGNAL_CLICKED,
+ _cancel_btn_clicked_cb, priv);
+
+ elm_object_focus_allow_set(priv->exit_btn, EINA_TRUE);
+ elm_object_focus_set(priv->exit_btn, EINA_TRUE);
+ util_focus_next_set(priv->exit_btn);
+
+ evas_object_del(priv->stop_btn);
+ priv->stop_btn = NULL;
+}
+
+/**
+ * Dealing with the receving signal.
+ *
+ * When receiving a channel signal, update the progress of the progressbar
+ * and the number of channel signal.
+ *
+ * @param[in] tvs: The tv service data structure
+ * @param[in] mode: The setting scan mode in view_scan_start.c
+ * @param[in] count: The number of channel signal received up to now
+ * @param[in] num: The physical channel number of current channel
+ * @param[in] arg: A pointer to current data structure.
+ */
+static void _progress_cb(struct tv_scan *tvs, enum antenna_mode mode,
+ int count, int num, void *arg)
+{
+ struct _data *priv;
+ char buf[CH_NAME_SIZE];
+ int total;
+ int ratio;
+
+ if (!tvs || !arg) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = arg;
+
+ snprintf(buf, sizeof(buf), "CH. %d", count);
+ elm_object_part_text_set(priv->base, PART_CH_NAME, buf);
+ elm_object_signal_emit(priv->base, SEARCHCHANNEL, SUBTEXT_SOURCE);
+
+ total = tv_scan_get_total_channel(tvs);
+ if (total <= 0) {
+ _ERR("Invalid Total value");
+ return;
+ }
+
+ ratio = count * PERCENT / total;
+ snprintf(buf, sizeof(buf), "%d%%", ratio);
+ elm_object_part_text_set(priv->base, PART_PGBAR_NUM, buf);
+ elm_progressbar_value_set(priv->pb, (float)ratio / PERCENT);
+}
+
+/**
+ * Dealing with the scanning result.
+ *
+ * When finishing scanning, the total found channels will be calculated and the
+ * scan result view will be invoked in this function.
+ *
+ * @param[in] tvs: The tv service structure for managering the scanning
+ * @param[in] res: The structure for saving the number of ATV air, DTV air,
+ * ATV cable and DTV cable channel.
+ * @param[in] arg: A pointer to current data structure.
+ */
+static void _done_cb(struct tv_scan *tvs,
+ const struct tv_scan_result *res, void *arg)
+{
+ struct _data *priv;
+ struct _ugdata *ugd;
+ struct viewmgr *vmgr;
+
+ if (!arg) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = arg;
+
+ if (!priv->tvs || !priv->vmgr || !priv->ugd) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ vmgr = priv->vmgr;
+ ugd = priv->ugd;
+
+ ugd->find_chs = res->air_dtv + res->cable_dtv +
+ res->air_atv + res->cable_atv;
+
+ if (viewmgr_push(vmgr, view_resultpage_get_vclass(), ugd) == -1)
+ _ERR("result view push failed");
+}
+
+/**
+ * Deal with the found channel signal.
+ *
+ * @param[in] tvs: The tv service structure for managering the scanning
+ * @param[in] count: The number of channel signal received up to now
+ * @param[in] num: The physical channel number
+ * @param[in] res: The structure for saving the number of ATV air, DTV air,
+ * ATV cable and DTV cable channel.
+ * @param[in] arg: A pointer to the current data structure.
+ * @return 0 on success, and -1 on fail
+ */
+static void _found_cb(struct tv_scan *tvs, int count, int num,
+ const struct tv_scan_result *res, void *arg)
+{
+ struct _data *priv;
+ char buf[CH_NAME_SIZE];
+ int found;
+
+ if (!arg) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = arg;
+ snprintf(buf, sizeof(buf), "CH. %d", count);
+
+ elm_object_part_text_set(priv->base, PART_CH_NAME, buf);
+ elm_object_signal_emit(priv->base, CHANNELFOUND, SUBTEXT_SOURCE);
+
+ found = res->air_dtv + res->cable_dtv + res->air_atv + res->cable_atv;
+ snprintf(buf, sizeof(buf), "%d %s", found, TEXT_CH_FOUND);
+ elm_object_part_text_set(priv->base, PART_SRCH_SEARCH_RESULT, buf);
+
+ priv->ugd->find_chs = found;
+}
+
+/**
+ * Register callback functions for tvs scan manager and begin scanning.
+ *
+ * It registers the callback functions and private data.
+ * _progress_cb When receiving a channle signal, _progress_cb will be invoked;
+ * _found_cb When finding a channel, _found_cb will be invoked.
+ * _done_cb When finishing scanning, _done_cb will be invoked.
+ *
+ * @param[in] data: user data related to current view
+ * @return 0 on success, and -1 on fail
+ */
+static int _start_scan(struct _data *data)
+{
+ struct tv_scan_cbs cbs;
+ int r;
+
+ if (!data) {
+ _ERR("Invalid argument data: %p", data);
+ return -1;
+ }
+
+ if (!data->tvs) {
+ _ERR("Invalid argumentdata->tvs: %p", data->tvs);
+ return -1;
+ }
+
+ cbs.data = data;
+ cbs.progress_cb = _progress_cb;
+ cbs.found_cb = _found_cb;
+ cbs.done_cb = _done_cb;
+
+ r = tv_scan_set_callbacks(data->tvs, &cbs);
+ if (r != 0) {
+ _ERR("tv_scan_set_callbacks failed");
+ return -1;
+ }
+
+ r = tv_scan_start(data->tvs);
+ if (r != 0) {
+ _ERR("tv_scan_start failed.");
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+ * Initializes the base layout for searching view.
+ *
+ * Invoked as soon as "start" button is clicked in view_scan_start
+ *
+ * @param[in] vmgr: the handler to the struct object for managing the view
+ * @param[in] data: user data related to current view
+ * @return The base or NULL if creatting failed
+ */
+static Evas_Object *_create(struct viewmgr *vmgr, void *data)
+{
+ Evas_Object *base;
+ Evas_Object *win;
+ struct _data *priv;
+ struct _ugdata *ugd;
+ struct tv_scan *tvs;
+ char buf[MAX_BUF_SIZE];
+
+ if (!vmgr) {
+ _ERR("Invalid argument");
+ return NULL;
+ }
+
+ if (!data) {
+ _ERR("Invalid argument.");
+ return NULL;
+ }
+
+ ugd = data;
+
+ win = viewmgr_get_win(vmgr);
+ if (!win) {
+ _ERR("get win failed.");
+ return NULL;
+ }
+
+ priv = calloc(1, sizeof(*priv));
+ if (!priv) {
+ _ERR("calloc memory failed");
+ return NULL;
+ }
+
+ tvs = tv_scan_init(ugd->scan_type);
+ if (!tvs) {
+ _ERR("tvs init failed, set scan_type: %d", ugd->scan_type);
+ free(priv);
+ return NULL;
+ }
+
+ base = util_add_layout(win, AUTO_PRGM_EDJ_FILE, GROUP_SRCH);
+ if (!base) {
+ _ERR("base is NULL");
+ tv_scan_fini(tvs);
+ free(priv);
+ return NULL;
+ }
+
+ elm_win_resize_object_add(win, base);
+ elm_object_part_text_set(base, PART_SRCH_MAIN_TITLE,
+ SEARCH_MAIN_TITLE);
+ elm_object_part_text_set(base, PART_CH_NAME, SCAN_CH_NAME);
+
+ snprintf(buf, sizeof(buf), "%d %s", INITIAL_CH_NUMS, TEXT_CH_FOUND);
+ elm_object_part_text_set(base, PART_SRCH_SEARCH_RESULT, buf);
+
+ priv->vmgr = vmgr;
+ priv->win = win;
+ priv->ugd = ugd;
+ priv->tvs = tvs;
+ priv->base = base;
+
+ _SET_PRIV(base, priv);
+
+ return base;
+}
+
+/**
+ * Invoked when refresh the window of application.
+ *
+ * @param[in] base: the layout of the view
+ *
+ * There is no action in this application.
+ */
+static void _update(Evas_Object *base)
+{
+ Evas_Object *stop_btn;
+ Evas_Object *pb;
+ struct _data *priv;
+ int r;
+
+ if (!base) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = _GET_PRIV(base);
+ if (!priv) {
+ _ERR("Data get failed");
+ return;
+ }
+
+ stop_btn = util_add_button(base, BTN_STYLE,
+ PART_STOP_BTN, TEXT_BTN_STOP, EINA_TRUE);
+ if (!stop_btn) {
+ _ERR("stop_btn is NULL");
+ evas_object_del(base);
+ free(priv);
+ return;
+ }
+
+ priv->stop_btn = stop_btn;
+ elm_object_focus_set(stop_btn, EINA_TRUE);
+ evas_object_smart_callback_add(stop_btn, SIGNAL_CLICKED,
+ _stop_btn_clicked_cb, priv);
+ util_focus_next_set(stop_btn);
+
+ pb = elm_progressbar_add(base);
+ if (!pb) {
+ _ERR("pb is NULL");
+ evas_object_del(base);
+ free(priv);
+ return;
+ }
+
+ priv->pb = pb;
+ elm_object_style_set(pb, PRGBAR_STYLE);
+ elm_object_part_text_set(base, PART_PGBAR_NUM, INITIAL_TEXT);
+ elm_progressbar_value_set(pb, INITIAL_VALUE);
+ elm_object_part_content_set(base, PART_PROGRESSBAR, pb);
+ evas_object_show(pb);
+
+ r = _start_scan(priv);
+ if (r != 0) {
+ _ERR("start scan failed");
+ return;
+ }
+}
+
+/**
+ * Resume the application.
+ *
+ * @param[in] base: the layout of the view
+ */
+static void _resume(Evas_Object *base)
+{
+ if (!base) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ evas_object_show(base);
+}
+
+/**
+ * Pause the view.
+ *
+ * Hide the layout
+ *
+ * @param[in] base: the layout of the view
+ */
+static void _pause(Evas_Object *base)
+{
+ if (!base) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ evas_object_hide(base);
+}
+
+/**
+ * Called after the main loop of the view exits.
+ *
+ * Delete the layout and release the resourse
+ *
+ * @param[in] base: the layout of the view
+ */
+static void _terminate(Evas_Object *base)
+{
+ struct _data *priv;
+ int r;
+
+ if (!base) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ priv = _GET_PRIV(base);
+ if (!priv) {
+ _ERR("Data get failed");
+ return;
+ }
+
+ r = tv_scan_fini(priv->tvs);
+ if (r != 0)
+ _ERR("tv_scan_fini failed");
+
+ if (priv->base)
+ evas_object_del(priv->base);
+
+ free(priv);
+}
+
+/**
+ * This struct is for registering the callbacks for the view
+ */
+static struct view_class _vclass = {
+ .title = VIEW_SEARCH,
+ .create = _create,
+ .update = _update,
+ .resume = _resume,
+ .pause = _pause,
+ .terminate = _terminate,
+};
+
+ /**
+ * Returns current view_class which implements the search view's life cycle
+ *
+ * @return view_class
+ */
+struct view_class *view_searchpage_get_vclass(void)
+{
+ return &_vclass;
+}
diff --git a/ug/channel/src/viewmgr_auto_program.c b/ug/channel/src/viewmgr_auto_program.c
new file mode 100644
index 0000000..fa16da0
--- /dev/null
+++ b/ug/channel/src/viewmgr_auto_program.c
@@ -0,0 +1,279 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <Elementary.h>
+#include <Eina.h>
+#include "ug_auto_program.h"
+#include "viewmgr_auto_program.h"
+#include "dbg.h"
+#include "defs.h"
+
+struct _viewinfo {
+ struct view_class *vclass;
+ Evas_Object *base;
+};
+
+/**
+ * Initialize the data handler view manager
+ *
+ * Viewmgr struct will be created.
+ *
+ * @param[in] win: window object
+ * @return The handler to the struct object of managing the view.
+ */
+struct viewmgr *viewmgr_init(Evas_Object *win)
+{
+ struct viewmgr *vmgr;
+
+ if (!win) {
+ _ERR("Invalid argument");
+ return NULL;
+ }
+
+ vmgr = calloc(1, sizeof(*vmgr));
+ if (!vmgr) {
+ _ERR("calloc vmgr failed.");
+ return NULL;
+ }
+
+ vmgr->win = win;
+
+ return vmgr;
+}
+
+/**
+ * Invoked before channel ug is terminated
+ * Each view will be poped, and the related info about each view will be
+ * released in this function, and the viewmgr struct will be released.
+ *
+ * @param[in] vmgr: the handler to the struct object of managing the view
+ */
+void viewmgr_fini(struct viewmgr *vmgr)
+{
+ int i;
+ int count;
+
+ if (!vmgr) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ count = eina_list_count(vmgr->vlist);
+ for (i = count; i > 0; i--)
+ viewmgr_pop(vmgr);
+
+ free(vmgr);
+}
+
+/**
+ * Evas_Object_Event_Cb type callback for handling deletion event
+ *
+ * Delete the layout and release the resouse
+ *
+ * @param[in] data: the data handler for view
+ * @param[in] e: evas handler
+ * @param[in] obj: the corresponding object which the deletion event occurred
+ * @param[in] ev : event information
+ */
+static void _view_deleted(void *data, Evas *e, Evas_Object *obj, void *ev)
+{
+ struct view_class *vclass;
+
+ if (!data || !obj) {
+ _ERR("Invalid argument");
+ return;
+ }
+
+ vclass = data;
+
+ if (vclass->terminate)
+ vclass->terminate(obj);
+}
+
+/**
+ * Push the view in the top
+ *
+ * In push function, layout of current view will be deleted,
+ * and the related info will be released in this channel ug,
+ * and a new view will be created.
+ *
+ * @param[in] vmgr: the handler to the struct object of managing the view
+ * @param[in] vclass: the basic struct for managing each view, it contains both
+ * functions and variables requried in each view. It has basic functions like
+ * create/show/hide/terminate
+ * @param[in] data: data handler of each view
+ * @return 0 on success otherwise -1
+ */
+int viewmgr_push(struct viewmgr *vmgr, struct view_class *vclass, void *data)
+{
+ Evas_Object *base;
+ struct _viewinfo *vinfo;
+
+ if (!vmgr || !vmgr->win ||
+ !vclass || !vclass->create || !data) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ base = vclass->create(vmgr, data);
+ if (!base) {
+ _ERR("create base failed");
+ return -1;
+ }
+
+ evas_object_event_callback_add(base, EVAS_CALLBACK_DEL,
+ _view_deleted, vclass);
+
+ if (vclass->update)
+ vclass->update(base);
+
+ vinfo = eina_list_data_get(vmgr->vlist);
+ if (vinfo && vinfo->base)
+ vinfo->vclass->pause(vinfo->base);
+
+ vinfo = calloc(1, sizeof(*vinfo));
+ if (!vinfo) {
+ _ERR("calloc failed.");
+ return -1;
+ }
+
+ vinfo->base = base;
+ vinfo->vclass = vclass;
+
+ vmgr->vlist = eina_list_prepend(vmgr->vlist, vinfo);
+
+ return 0;
+}
+
+/**
+ * Pop the view and remove the view information of the popped item in Eina_List
+ *
+ * In pop function, current view layout will be deleted,
+ * and the related resource will be released in this channel ug.
+ *
+ * @param[in] vmgr: the handler to the struct object of managing the view
+ * @return 0 on success otherwise -1
+ */
+int viewmgr_pop(struct viewmgr *vmgr)
+{
+ struct _viewinfo *vinfo;
+
+ if (!vmgr || !vmgr->vlist) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ vinfo = eina_list_data_get(vmgr->vlist);
+ if (!vinfo || !vinfo->base)
+ return -1;
+
+ evas_object_del(vinfo->base);
+ vinfo->base = NULL;
+
+ vmgr->vlist = eina_list_remove_list(vmgr->vlist, vmgr->vlist);
+ free(vinfo);
+
+ viewmgr_resume(vmgr);
+
+ return 0;
+}
+
+/**
+ * Resume the paused view
+ *
+ * @param[in] vmgr: the handler to the struct object of managing the view
+ * @return 0 on success otherwise -1
+ */
+int viewmgr_resume(struct viewmgr *vmgr)
+{
+ struct _viewinfo *vinfo;
+ struct view_class *vclass;
+
+ if (!vmgr || !vmgr->vlist) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ vinfo = eina_list_data_get(vmgr->vlist);
+ if (!vinfo || !vinfo->vclass || !vinfo->base)
+ return -1;
+
+ vclass = vinfo->vclass;
+ if (vclass->resume)
+ vclass->resume(vinfo->base);
+
+ return 0;
+}
+
+/**
+ * Pause the view
+ *
+ * @param[in] vmgr: the handler to the struct object of managing the view
+ * @return 0 on success otherwise -1
+ */
+int viewmgr_pause(struct viewmgr *vmgr)
+{
+ struct _viewinfo *vinfo;
+ struct view_class *vclass;
+
+ if (!vmgr || !vmgr->vlist) {
+ _ERR("Invalid argument");
+ return -1;
+ }
+
+ vinfo = eina_list_data_get(vmgr->vlist);
+
+ if (!vinfo || !vinfo->vclass || !vinfo->base)
+ return -1;
+
+ vclass = vinfo->vclass;
+ if (vclass->pause)
+ vclass->pause(vinfo->base);
+
+ return 0;
+}
+
+/**
+ * Get the eina list from viewmgr
+ *
+ * @param[in] vmgr: the handler to the struct object of managing the view
+ * @return The eina list in viewmgr
+ */
+Eina_List *viewmgr_get_list(struct viewmgr *vmgr)
+{
+ if (!vmgr) {
+ _ERR("Invalid argument");
+ return NULL;
+ }
+
+ return vmgr->vlist;
+}
+
+/**
+ * Get the window object from viewmgr struct
+ *
+ * @param[in] vmgr: the handler to the struct object of managing the view
+ * @return The window object on success otherwise NULL
+ */
+Evas_Object *viewmgr_get_win(struct viewmgr *vmgr)
+{
+ if (!vmgr) {
+ _ERR("Invalid argument");
+ return NULL;
+ }
+
+ return vmgr->win;
+}
diff --git a/ug/include/NetConMgr.h b/ug/include/NetConMgr.h
deleted file mode 100644
index 38c0498..0000000
--- a/ug/include/NetConMgr.h
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef __NETCONMGR_H__
-#define __NETCONMGR_H__
-
-#include "UgCommon.h"
-#include "net_connection.h"
-
-class CNetConMgr {
-private:
- static CNetConMgr *instance;
- struct SNetConMgr *m;
-
-private:
- static void sm_CbIpAddrChanged(const char *ipv4, const char *ipv6, void* data);
- void m_OnIpAddrChanged(void *data);
-
- static void sm_CbProfileStateChanged(connection_profile_state_e state, void *data);
- bool m_GetEthernetProfile(void);
- bool m_UpdateProfile(void);
-
-private:
- CNetConMgr(void) : m(0) {}
- virtual ~CNetConMgr() {}
-
-public:
- static bool Initialize(void);
- static void Finalize(void);
- static CNetConMgr *GetInstance(void);
-
- void RefreshEthernetProfile(void);
- bool GetEthernetState(bool *state);
-
- bool GetProfileName(char *out_name);
- bool IsConnected(void);
-
- bool SetIpConfType(connection_ip_config_type_e);
- bool SetIpAddr(char *ip);
- bool SetSubnetMask(char *submask);
- bool SetGateway(char *gateway);
- bool SetDNS(char *dns);
-
- bool GetIpAddr(char *ip);
- bool GetSubnetMask(char *submask);
- bool GetGateway(char *gateway);
- bool GetDNS(char *dns);
-
- bool SetProxyType(EProxyMethod method);
- bool GetProxyType(EProxyMethod *method);
- bool SetProxyAddr(char *ip);
- bool GetProxyAddr(char *ip);
-
- const char *GetErrorMsg(connection_error_e err);
-
- bool RegisterIpChangedCallback(void(*ip_changed_cb)(bool change_state, void *data), void *data);
-
-};
-
-#endif /* __NETCONMGR_H__ */
diff --git a/ug/include/TVServiceMgr.h b/ug/include/TVServiceMgr.h
deleted file mode 100644
index 550e01c..0000000
--- a/ug/include/TVServiceMgr.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef __TVSERVICEMGR_H__
-#define __TVSERVICEMGR_H__
-
-enum antenna_mode {
- SCAN_TYPE_INVALID = -1,
- SCAN_TYPE_ALL,
- SCAN_TYPE_CABLE,
- SCAN_TYPE_AIR
-};
-
-class CTVServiceMgr {
-private:
- static CTVServiceMgr *instance;
- struct STVServiceMgr *m;
-
-private:
- CTVServiceMgr(void) : m(0) {}
- virtual ~CTVServiceMgr() {}
-
-public:
- static bool Initialize(void);
- static void Finalize(void);
- static CTVServiceMgr *GetInstance(void);
-
- bool Start(void);
- bool Pause(void);
- bool Resume(void);
- bool Stop(void);
- bool GetAllChannel(void);
- unsigned int GetServiceType(void);
- bool IsStopped(void);
-};
-
-#endif /* __TVSERVICEMGR_H__ */
diff --git a/ug/include/UgCommon.h b/ug/include/UgCommon.h
deleted file mode 100644
index 3102b9f..0000000
--- a/ug/include/UgCommon.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef __UG_COMMON_H__
-#define __UG_COMMON_H__
-
-
-#define WIFI_DIRECT_DEFAULT_BUF_LEN 256
-#define WIFI_DIRECT_STATE_BUF_LEN 32
-
-enum EProxyMethod {
- PROXY_METHOD_NONE = 0,
- PROXY_METHOD_MANUAL,
- PROXY_METHOD_AUTO
-};
-
-struct device_info {
- char dev_name[WIFI_DIRECT_DEFAULT_BUF_LEN];
- char mac_addr[WIFI_DIRECT_DEFAULT_BUF_LEN];
- bool is_conn;
- int wps_types;
- char wps_pin[WIFI_DIRECT_STATE_BUF_LEN];
- char state[WIFI_DIRECT_STATE_BUF_LEN];
-};
-#endif /* __UG_COMMON_H__ */
diff --git a/ug/include/WifiDirectMgr.h b/ug/include/WifiDirectMgr.h
deleted file mode 100644
index c6e5d8d..0000000
--- a/ug/include/WifiDirectMgr.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef __WIFIDIRECTMGR_H__
-#define __WIFIDIRECTMGR_H__
-
-#include "UgCommon.h"
-#include "wifi-direct.h"
-
-class CWifiDirectMgr {
-private:
- static CWifiDirectMgr *instance;
- struct SWifiDirectMgr *m;
-
-private:
- CWifiDirectMgr(void) : m(0) {}
- virtual ~CWifiDirectMgr() {}
-
-public:
- static bool Initialize(void);
- static void Finalize(void);
- static CWifiDirectMgr* GetInstance(void);
-
- char* GetDevieName(void);
- char* GetMacAddr(void);
- bool GetState(wifi_direct_state_e *status);
- bool Activate(void);
- bool Deactivate(void);
- bool SetMaxClient(void); // set_configure_num
-
- bool GetAllDicoveredPeerInfo(wifi_direct_discovered_peer_cb cb, void *data);
- bool GetAllConnectedPeerInfo(wifi_direct_connected_peer_cb cb, void *data);
-
- bool StartDiscovery(void);
- bool CancelDiscovery(void);
- bool Connect(const char *macaddr);
- bool Disconnect(const char *macaddr);
- bool AcceptConnection(char *macaddr);
- bool GetWPStype(Eina_Bool *is_pbc);
- bool SetWPStype(wifi_direct_wps_type_e *type);
-
- bool SetDeviceStateChangedCb(wifi_direct_device_state_changed_cb cb, void *data);
- bool UnSetDeviceStateChangedCb(void);
- bool SetDiscoveryStateChangedCb(wifi_direct_discovery_state_chagned_cb cb, void *data);
- bool UnSetDiscoveryStateChangedCb(void);
- bool SetConnectionStateChangedCb(wifi_direct_connection_state_changed_cb cb, void *data);
- bool UnSetConnectionStateChangedCb(void);
-
- bool UnSetClientIpAddrAssignedCb(void);
-
-
- const char* GetErrorMsg(int err);
-};
-
-#endif /* __WIFIDIRECTMGR_H__ */
diff --git a/ug/include/WifiMgr.h b/ug/include/WifiMgr.h
deleted file mode 100644
index ceaea96..0000000
--- a/ug/include/WifiMgr.h
+++ /dev/null
@@ -1,83 +0,0 @@
-#ifndef __WIFIMGR_H__
-#define __WIFIMGR_H__
-
-#include "UgCommon.h"
-#include "wifi.h"
-
-
-class CWifiAp {
- friend class CWifiMgr;
-private:
- wifi_ap_h m_handle;
-
-private:
- bool m_CheckErr(const char *func, int ret);
-
-protected:
- void t_SetHandle(wifi_ap_h handle);
-
-public:
- CWifiAp(wifi_ap_h handle);
- virtual ~CWifiAp();
-
- wifi_ap_h Handle(void);
-
- bool AllocConnectedAp(void);
- void Destroy(void);
-
- bool GetEssid(char *essid, int size);
- bool GetConnectionState(wifi_connection_state_e *state);
- bool GetSecurityType(wifi_security_type_e *type);
- bool SetPassPhrase(const char *passcode);
-
- bool Connect(void(*wifi_connected_cb)(wifi_error_e err, void *data), void *data);
- bool SetIpType(wifi_ip_config_type_e type);
-
- bool GetIp(char *ip, int size);
- bool GetSubnetMask(char *submask);
- bool GetGateway(char *gateway);
- bool GetDNS(char *dns);
-
- bool SetIp(char *ip);
- bool SetSubnetMask(char *submask);
- bool SetGateway(char *gateway);
- bool SetDNS(char *dns);
-
- bool CloneAP(wifi_ap_h *cloned_ap, wifi_ap_h origin);
-
- static bool ForgetAP(void);
-
- bool SetProxyType(EProxyMethod pm);
- bool GetProxyType(EProxyMethod *pm);
-
- bool SetProxyAddr(const char *addr);
- bool GetProxyAddr(char **addr);
-};
-
-
-class CWifiMgr {
-private:
- static CWifiMgr *instance;
- struct SWifiMgr *m;
-
-private:
- CWifiMgr(void) : m(0) {}
- virtual ~CWifiMgr() {}
-
-public:
- static bool Initialize(void);
- static void Finalize(void);
- static CWifiMgr * GetInstance(void);
-
- bool Activate(void(*cbActivated)(wifi_error_e err, void *data), void *data);
-
- bool IsActivated(bool *activated);
-
- bool Scan(void (*cbFinish)(wifi_error_e err, void *data), void *data);
- bool FoundAps(bool(*FoundCb)(CWifiAp *ap, void *data), void *data);
-
- static const char * ErrorMsg(wifi_error_e err);
-};
-
-
-#endif /* __WIFIMGR_H__ */
diff --git a/ug/network/CMakeLists.txt b/ug/network/CMakeLists.txt
index 0fac965..b3854a2 100644
--- a/ug/network/CMakeLists.txt
+++ b/ug/network/CMakeLists.txt
@@ -24,6 +24,7 @@ SET(UG_NETWORK_EDJ_THEME "ug-network-settings-theme.edj")
INCLUDE(FindPkgConfig)
pkg_check_modules(UG_NETWORK_PKGS REQUIRED
+ dlog
eina
edje
evas
@@ -35,8 +36,9 @@ pkg_check_modules(UG_NETWORK_PKGS REQUIRED
capi-appfw-application
capi-network-wifi
capi-network-connection
- application-common
)
+ #ecore-x
+
SET(PKGS_LDFLAGS "${PKGS_LDFLAGS} ${UG_NETWORK_PKGS_LDFLAGS}")
FOREACH(FLAG ${UG_NETWORK_PKGS_CFLAGS})
@@ -46,19 +48,18 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fvisibility=hidden -Wall -W
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
SET(SRCS
- src/ug_network_settings.cpp
- src/NetworkMainView.cpp
- src/IpSettingView.cpp
- src/WifiPasscodeView.cpp
- src/util.cpp
- ../src/WifiMgr.cpp
- ../src/NetConMgr.cpp
+ src/ug_network_settings.c
+ src/main_view.c
+ src/network_viewmgr.c
+ src/ip_setting_view.c
+ src/vconf_mgr.c
+ src/wifi_mgr.c
+ src/connection_mgr.c
+ src/util.c
+ src/wifi_passcode_view.c
)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../include)
-
ADD_DEFINITIONS("-DPKGNAME=\"${PROJECT_NAME}\"")
ADD_DEFINITIONS("-DUG_NETWORK_EDJ_FILE=\"${UG_NETWORK_EDJE_DIR}/${UG_NETWORK_EDJ_FILE}\"")
diff --git a/ug/network/edje/images/btn_down.png b/ug/network/edje/images/btn_down.png
index 44a3166..91946d8 100644
--- a/ug/network/edje/images/btn_down.png
+++ b/ug/network/edje/images/btn_down.png
Binary files differ
diff --git a/ug/network/edje/images/btn_focused.png b/ug/network/edje/images/btn_focused.png
index 76ade5d..23bf311 100644
--- a/ug/network/edje/images/btn_focused.png
+++ b/ug/network/edje/images/btn_focused.png
Binary files differ
diff --git a/ug/network/edje/images/btn_normal.png b/ug/network/edje/images/btn_normal.png
index d09ecf7..a889523 100644
--- a/ug/network/edje/images/btn_normal.png
+++ b/ug/network/edje/images/btn_normal.png
Binary files differ
diff --git a/ug/network/edje/images/btn_up.png b/ug/network/edje/images/btn_up.png
index 788bf67..4609691 100644
--- a/ug/network/edje/images/btn_up.png
+++ b/ug/network/edje/images/btn_up.png
Binary files differ
diff --git a/ug/network/edje/images/check_foc.png b/ug/network/edje/images/check_foc.png
index 92456ad..95b02f0 100644
--- a/ug/network/edje/images/check_foc.png
+++ b/ug/network/edje/images/check_foc.png
Binary files differ
diff --git a/ug/network/edje/images/check_nor.png b/ug/network/edje/images/check_nor.png
index 810a678..2a3e5d9 100644
--- a/ug/network/edje/images/check_nor.png
+++ b/ug/network/edje/images/check_nor.png
Binary files differ
diff --git a/ug/network/edje/images/ico_dropdown_menu_check.png b/ug/network/edje/images/ico_dropdown_menu_check.png
index d32061e..9e7d114 100644
--- a/ug/network/edje/images/ico_dropdown_menu_check.png
+++ b/ug/network/edje/images/ico_dropdown_menu_check.png
Binary files differ
diff --git a/ug/network/edje/images/ico_spincontrol_check.png b/ug/network/edje/images/ico_spincontrol_check.png
index 16599e9..3b57522 100644
--- a/ug/network/edje/images/ico_spincontrol_check.png
+++ b/ug/network/edje/images/ico_spincontrol_check.png
Binary files differ
diff --git a/ug/network/edje/images/ico_spincontrol_down.png b/ug/network/edje/images/ico_spincontrol_down.png
index 0b7ff54..fbeb94b 100644
--- a/ug/network/edje/images/ico_spincontrol_down.png
+++ b/ug/network/edje/images/ico_spincontrol_down.png
Binary files differ
diff --git a/ug/network/edje/images/ico_spincontrol_up.png b/ug/network/edje/images/ico_spincontrol_up.png
index 9adb165..f5b2587 100644
--- a/ug/network/edje/images/ico_spincontrol_up.png
+++ b/ug/network/edje/images/ico_spincontrol_up.png
Binary files differ
diff --git a/ug/network/edje/images/ico_wifi.png b/ug/network/edje/images/ico_wifi.png
index 2a24aaa..16032e9 100644
--- a/ug/network/edje/images/ico_wifi.png
+++ b/ug/network/edje/images/ico_wifi.png
Binary files differ
diff --git a/ug/network/edje/images/ico_wifi_lock.png b/ug/network/edje/images/ico_wifi_lock.png
index 0370d67..b485a2d 100644
--- a/ug/network/edje/images/ico_wifi_lock.png
+++ b/ug/network/edje/images/ico_wifi_lock.png
Binary files differ
diff --git a/ug/network/edje/images/modal_dialogs_bg.png b/ug/network/edje/images/modal_dialogs_bg.png
index b825c26..0ae9c58 100644
--- a/ug/network/edje/images/modal_dialogs_bg.png
+++ b/ug/network/edje/images/modal_dialogs_bg.png
Binary files differ
diff --git a/ug/network/edje/images/progress_wheel.png b/ug/network/edje/images/progress_wheel.png
index ce53880..9e5b177 100644
--- a/ug/network/edje/images/progress_wheel.png
+++ b/ug/network/edje/images/progress_wheel.png
Binary files differ
diff --git a/ug/network/edje/images/radiobtn_br_off_nor.png b/ug/network/edje/images/radiobtn_br_off_nor.png
index e619dee..6087f23 100644
--- a/ug/network/edje/images/radiobtn_br_off_nor.png
+++ b/ug/network/edje/images/radiobtn_br_off_nor.png
Binary files differ
diff --git a/ug/network/edje/images/radiobtn_off_foc.png b/ug/network/edje/images/radiobtn_off_foc.png
index 909c02d..ae25533 100644
--- a/ug/network/edje/images/radiobtn_off_foc.png
+++ b/ug/network/edje/images/radiobtn_off_foc.png
Binary files differ
diff --git a/ug/network/edje/images/radiobtn_off_nor.png b/ug/network/edje/images/radiobtn_off_nor.png
index e7e58cc..f6c3522 100644
--- a/ug/network/edje/images/radiobtn_off_nor.png
+++ b/ug/network/edje/images/radiobtn_off_nor.png
Binary files differ
diff --git a/ug/network/edje/images/radiobtn_on_foc.png b/ug/network/edje/images/radiobtn_on_foc.png
index f9d9db2..109efb1 100644
--- a/ug/network/edje/images/radiobtn_on_foc.png
+++ b/ug/network/edje/images/radiobtn_on_foc.png
Binary files differ
diff --git a/ug/network/edje/images/radiobtn_on_nor.png b/ug/network/edje/images/radiobtn_on_nor.png
index 6d185e3..c6e9dff 100644
--- a/ug/network/edje/images/radiobtn_on_nor.png
+++ b/ug/network/edje/images/radiobtn_on_nor.png
Binary files differ
diff --git a/ug/network/edje/images/round_rectangle_4X4.png b/ug/network/edje/images/round_rectangle_4X4.png
index b0c09a8..5a1f51d 100644
--- a/ug/network/edje/images/round_rectangle_4X4.png
+++ b/ug/network/edje/images/round_rectangle_4X4.png
Binary files differ
diff --git a/ug/network/edje/images/round_rectangle_4X4_bottom.png b/ug/network/edje/images/round_rectangle_4X4_bottom.png
index e168995..8037cb8 100644
--- a/ug/network/edje/images/round_rectangle_4X4_bottom.png
+++ b/ug/network/edje/images/round_rectangle_4X4_bottom.png
Binary files differ
diff --git a/ug/network/edje/images/round_rectangle_4X4_top.png b/ug/network/edje/images/round_rectangle_4X4_top.png
index 4b12cd9..de8b5ca 100644
--- a/ug/network/edje/images/round_rectangle_4X4_top.png
+++ b/ug/network/edje/images/round_rectangle_4X4_top.png
Binary files differ
diff --git a/ug/network/edje/images/round_rectangle_8X8_top.png b/ug/network/edje/images/round_rectangle_8X8_top.png
index 3ab184f..dc618e3 100644
--- a/ug/network/edje/images/round_rectangle_8X8_top.png
+++ b/ug/network/edje/images/round_rectangle_8X8_top.png
Binary files differ
diff --git a/ug/network/edje/images/second_depth_bg.png b/ug/network/edje/images/second_depth_bg.png
index 602e272..5b3c624 100644
--- a/ug/network/edje/images/second_depth_bg.png
+++ b/ug/network/edje/images/second_depth_bg.png
Binary files differ
diff --git a/ug/network/edje/images/setting_ico_no_network.png b/ug/network/edje/images/setting_ico_no_network.png
index 6c60adf..a0de373 100644
--- a/ug/network/edje/images/setting_ico_no_network.png
+++ b/ug/network/edje/images/setting_ico_no_network.png
Binary files differ
diff --git a/ug/network/edje/images/setting_ico_no_network.png.png b/ug/network/edje/images/setting_ico_no_network.png.png
index 6c60adf..a0de373 100644
--- a/ug/network/edje/images/setting_ico_no_network.png.png
+++ b/ug/network/edje/images/setting_ico_no_network.png.png
Binary files differ
diff --git a/ug/network/edje/images/setting_ico_plug_network_Cable.png b/ug/network/edje/images/setting_ico_plug_network_Cable.png
index e657d2f..5b40814 100644
--- a/ug/network/edje/images/setting_ico_plug_network_Cable.png
+++ b/ug/network/edje/images/setting_ico_plug_network_Cable.png
Binary files differ
diff --git a/ug/network/edje/images/sub_popup_bg.png b/ug/network/edje/images/sub_popup_bg.png
index 9c1cc56..d4e4175 100644
--- a/ug/network/edje/images/sub_popup_bg.png
+++ b/ug/network/edje/images/sub_popup_bg.png
Binary files differ
diff --git a/ug/network/include/IpSettingView.h b/ug/network/include/IpSettingView.h
deleted file mode 100644
index 4e5828c..0000000
--- a/ug/network/include/IpSettingView.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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.
- */
-
-#ifndef __IP_SETTING_VIEW_H__
-#define __IP_SETTING_VIEW_H__
-
-class CIpSettingView : public CBaseView, public IMouseClickedListener, public IUnfocusedListener {
-private :
- struct SIpSettingView *m;
-
- bool m_InitConnectionMgr();
- void m_FinalizeConnectionMgr();
- Evas_Object* m_CreateMainLayout();
-
- bool m_GetCurConnectionMode(void);
- bool m_GetCurIpInfo(void);
-
- void m_GetIpInfo(char *des, const char *key);
- bool m_CreateDNSSetting(void);
- bool m_CreateBtns(void);
- bool m_CreateIpSetting(void);
- bool m_CreateDimLayout(void);
- Evas_Object* m_CreateSettingBtn(char *key, char *txt, Evas_Smart_Cb cb, void *data);
- void m_SetupDownCycleFocus(Evas_Object **obj, int count);
- void m_KeepBtnFocused(void);
- void m_CreateValuePopup(void);
- Evas_Object* m_CreateValueBtn(Evas_Object *base, int num, char *txt, void *data);
- void m_SetLeftRightCycleFocus(Evas_Object **obj, int count);
- bool m_GetValuePopupPos(Evas_Coord *pos_x, Evas_Coord *pos_y);
- void m_ConfigNetwork(void);
- void m_ShowConfirmPopup(void);
- bool m_ConfigNetworkDynamic(void);
- bool m_ConfigNetworkManually(void);
- bool m_CheckIpValid(void);
- void m_ShowInvalidIpPopup(void);
- void m_SaveMode(void);
- void m_SetTheValue(void);
-
-protected :
- virtual void t_OnShow(void);
- virtual void t_OnUpdate(void *data);
- virtual void t_OnHide(void);
-
-public :
- CIpSettingView(const char *szViewId) : CBaseView(szViewId), IMouseClickedListener(this), IUnfocusedListener(this), m(0) {}
- virtual ~CIpSettingView() {}
-
- virtual bool Create(void *data);
- virtual void Destroy(void);
- virtual Evas_Object* Base(void);
-
- virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev);
- virtual void OnMouseClicked(int id, Evas_Object *obj);
- virtual void OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item);
-};
-
-#endif /* __IP_SETTING_VIEW_H__ */
-
diff --git a/ug/network/include/NetworkMainView.h b/ug/network/include/NetworkMainView.h
deleted file mode 100644
index 961c900..0000000
--- a/ug/network/include/NetworkMainView.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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.
- */
-
-#ifndef __NETWORK_MAIN_VIEW_H__
-#define __NETWORK_MAIN_VIEW_H__
-
-
-#include "WifiMgr.h"
-
-class CNetworkMainView : public CBaseView {
-private :
- struct SNetworkMainView *m;
-
- static void sm_CbGenlistItemSelected(void *data, Evas_Object *obj, void *ei);
- static Eina_Bool sm_CbSelectConnected(void *data);
-
- static bool sm_CbWifiFoundAP(CWifiAp *ap, void *data);
- bool m_OnWifiFoundAP(CWifiAp *ap);
-
- static void sm_CbWifiScanRequest(wifi_error_e err, void *data);
- void m_OnWifiScanRequest(wifi_error_e err);
-
- static void sm_CbConnectionOnlineAsync(bool state, void *data);
- void m_OnConnectionOnlineAync(bool state);
-
- static void sm_CbCheckGatewayAsync(bool state, void *data);
- void m_OnCheckGatewayAsync(bool state);
-
- static void sm_CbWifiActivated(wifi_error_e err, void *data);
- void m_OnWifiActivated(wifi_error_e err);
-
- static char* sm_GetApName(void *data, Evas_Object *obj, const char *part);
- static void sm_CbEthernetStateChanged(bool state, void *data);
- void m_OnEthernetStateChanged(bool state);
-
- bool m_InitConnectionMgr(void);
- void m_FinalizeConnectionMgr();
-
- Evas_Object *m_CreateMainLayout(void);
- bool m_CreateUpperLayout(void);
-
- bool m_CreateActionBtns(void);
- void m_DestroyActionBtns();
-
- bool m_CreateDimLayout(void);
- void m_SetNetTypeBtnText(void);
-
- bool m_SetWireless(void);
- bool m_SetWired(void);
-
- void m_FillContentPart(Evas_Object *obj);
- void m_SetActionBtnPos(void);
-
- void m_CreateWirelessDisconnectPart(void);
- bool m_CreateWiredConnectPart(void);
- bool m_CreateWiredDisconnectPart(void);
- Evas_Object* m_CreateGenlistView(void);
- void m_ClearGenlist(void);
-
- static void sm_CbWifiConnected(wifi_error_e err, void *data);
- void m_OnWifiConnected(wifi_error_e err);
- void m_ConnectNetwork(void);
- bool m_WifiConnectAP(int index);
- bool m_WiredConnectAP();
- bool m_ConnectionSetLastNetwork(void);
- void m_GetIpInfo(char *des, const char *key);
-
- void m_ShowConfirmPopup(void);
- void m_ShowProgressPopup(void);
-public :
-
-protected :
- virtual void t_OnShow(void);
- virtual void t_OnUpdate(void *data);
- virtual void t_OnHide(void);
-
-public :
- CNetworkMainView(const char *szViewId) : CBaseView(szViewId), m(0) {}
- virtual ~CNetworkMainView() {}
-
- virtual bool Create(void *data);
- virtual void Destroy(void);
- virtual Evas_Object* Base(void);
-};
-
-#endif /* __NETWORK_MAIN_VIEW_H__ */
diff --git a/ug/network/include/WifiPasscodeView.h b/ug/network/include/WifiPasscodeView.h
deleted file mode 100644
index 9bc399b..0000000
--- a/ug/network/include/WifiPasscodeView.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef __WIFI_PASSCODE_VIEW_H__
-#define __WIFI_PASSCODE_VIEW_H__
-
-class CWifiPasscodeView : public CBaseView, public IMouseClickedListener, public IUnfocusedListener {
-private :
- struct SWifiPasscodeView *m;
-
- static void sm_CbWifiConnected(wifi_error_e err, void *data);
- void m_OnWifiConnected(wifi_error_e err);
-
- static bool sm_CbWifiFoundAP(CWifiAp *ap, void *data);
- void m_OnWifiFoundAP(CWifiAp *ap);
-
- static void sm_CbWifiScanRequest(wifi_error_e err, void *data);
- void m_OnWifiScanRequest(wifi_error_e err, void *data);
-
- void m_AddEntry(void);
- bool m_CreateDimLayout(void);
- void m_ShowInvalidPwdPopup(void);
- bool m_WifiConnectAP(void);
- void m_ShowProgressPopup(void);
- void m_ShowConfirmPopup(void);
-
-protected :
- virtual void t_OnShow(void);
- virtual void t_OnUpdate(void *data);
- virtual void t_OnHide(void);
-
-public :
- CWifiPasscodeView(const char *szViewId) : CBaseView(szViewId), IMouseClickedListener(this), IUnfocusedListener(this), m(0) {}
- virtual ~CWifiPasscodeView() {}
-
- virtual bool Create(void *data);
- virtual void Destroy(void);
- virtual Evas_Object* Base(void);
-
- virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev);
- virtual void OnMouseClicked(int id, Evas_Object *obj);
- virtual void OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item);
-};
-
-#endif /* __WIFI_PASSCODE_VIEW_H__ */
-
diff --git a/ug/network/include/common.h b/ug/network/include/common.h
index 06b9c4c..1f158ee 100644
--- a/ug/network/include/common.h
+++ b/ug/network/include/common.h
@@ -17,10 +17,8 @@
#ifndef __NETWORK_COMMON_H__
#define __NETWORK_COMMON_H__
-
+#include <net_connection.h>
#include <wifi.h>
-#include "WifiMgr.h"
-
#define IP_STRING_MAX_SIZE 20
#define MAX_NAME_SIZE 256
@@ -37,21 +35,10 @@ enum setting_mode {
MODE_MAN
};
-enum action_btn_enum {
- CONNECT = 0,
- REFRESH,
- OTHER,
- CLOSE
-};
-
-enum view_type {
- NETWORK_MAIN_VIEW = 0,
- NETWORK_WIFI_PASSCODE_VIEW,
- NETWORK_IP_SETTING_VIEW
-};
-
struct connection_info {
enum network_type_enum cur_type;
+ connection_h connection;
+ connection_profile_h profile;
char name[MAX_NAME_SIZE];
wifi_ap_h ap;
};
@@ -63,34 +50,4 @@ struct network_info {
char dns[IP_STRING_MAX_SIZE + 1];
};
-#define SSID_MAX_LENTH 256
-#define PWD_MAX_LENTH 256
-
-#define BTN_ACT 4
-#define BTN_TYPE 2
-#define TIMER_INTERNAL 0.1
-#define KEY_PRIV "priv"
-#define TYPE_POPUP_X_OFFSET 190
-
-struct wifi_ap_info {
- char essid[SSID_MAX_LENTH];
- char bssid[SSID_MAX_LENTH];
- int rssi;
- int frequency;
- int max_speed;
- wifi_security_type_e secure_type;
- wifi_encryption_type_e encryption_type;
- bool passphrase_required;
- int wps_supported;
- wifi_connection_state_e state;
-
- wifi_ip_config_type_e ip_type;
- wifi_proxy_type_e proxy_type;
- wifi_encryption_type_e enc_type;
- wifi_eap_type_e eap_type;
- wifi_eap_auth_type_e eap_auth_type;
-
- CWifiAp *ap;
- void *user_data;
-};
#endif /* __NETWORK_COMMON_H__ */
diff --git a/ug/network/include/connection_mgr.h b/ug/network/include/connection_mgr.h
new file mode 100644
index 0000000..8967901
--- /dev/null
+++ b/ug/network/include/connection_mgr.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __CONNECTION_MGR_H__
+#define __CONNECTION_MGR_H__
+
+#include <Elementary.h>
+#include <net_connection.h>
+#include "common.h"
+
+int connection_mgr_set_profile(
+ connection_h connection,
+ connection_profile_h profile,
+ struct network_info *info);
+connection_h connection_mgr_create(void);
+int connection_mgr_destroy(connection_h connection);
+int connection_mgr_uninit(connection_h connection);
+int connection_mgr_get_profile_info(
+ connection_h connection, struct connection_info *info);
+Eina_Bool connection_mgr_is_connected(connection_h connection);
+int connection_mgr_ip_dynamic_config(connection_h connection,
+ connection_profile_h profile);
+int connection_mgr_get_ethernet_state(
+ connection_h connection,
+ Eina_Bool *plugin);
+int connection_mgr_get_ip_info(
+ connection_profile_h profile,
+ struct network_info *info);
+#if 0
+int connection_mgr_register_ethernet_state_cb(
+ connection_h connection,
+ connection_ethernet_state_chaged_cb cb, void *data);
+int connection_mgr_set_profile_state_changed_cb(
+ connection_profile_h profile,
+ connection_profile_state_changed_cb cb, void *data);
+int connection_mgr_get_is_online_async(
+ connection_h connection,
+ connection_is_online_async_cb cb, void *data);
+int connection_mgr_check_gateway_async(
+ connection_profile_h profile,
+ connection_profile_check_gateway_async_cb cb, void *data);
+#endif
+
+#endif /* __CONNECTION_MGR_H__ */
diff --git a/ug/network/include/dbg.h b/ug/network/include/dbg.h
new file mode 100644
index 0000000..faf282c
--- /dev/null
+++ b/ug/network/include/dbg.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __DBG_H__
+#define __DBG_H__
+
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "ug-network-settings"
+
+#ifndef _ERR
+#define _ERR(fmt, args...) (LOGE("[%s:%d] "fmt"\n", __func__, __LINE__, ##args))
+#endif
+
+#ifndef _DBG
+#define _DBG(fmt, args...) (LOGD("[%s:%d] "fmt"\n", __func__, __LINE__, ##args))
+#endif
+
+#ifndef _INFO
+#define _INFO(fmt, args...) \
+ (LOGI("[%s:%d] "fmt"\n", __func__, __LINE__, ##args))
+#endif
+
+#endif /* __DBG_H__ */
diff --git a/ug/network/include/defs.h b/ug/network/include/defs.h
index 866bf11..dc58d0f 100644
--- a/ug/network/include/defs.h
+++ b/ug/network/include/defs.h
@@ -23,9 +23,6 @@
#define RET_FAILED -1
#define RET_IP_INVALID -2
-/* VIEW */
-#define NETWORK_MAINVIEW "NETWORK_MAIN_VIEW"
-
/*GROUP*/
#define GRP_MAIN "main"
#define GRP_NETWORK_TYPE_SELECT "popup_select"
@@ -140,24 +137,27 @@
#define POPUP_WIDTH 688
#define POPUP_HEIGHT 411
-/* Width Height */
+/* Key defines */
+#define KEY_UP "Up"
+#define KEY_DOWN "Down"
+#define KEY_LEFT "Left"
+#define KEY_RIGHT "Right"
+#define KEY_ENTER "Return"
+#define KEY_EXIT "XF86Close"
+
+#define KEY_0 "0"
+#define KEY_1 "1"
+#define KEY_2 "2"
+#define KEY_3 "3"
+#define KEY_4 "4"
+#define KEY_5 "5"
+#define KEY_6 "6"
+#define KEY_7 "7"
+#define KEY_8 "8"
+#define KEY_9 "9"
+
+/* FIXME: do not pre-define */
#define DEFAULT_WIN_WIDTH 1920
#define DEFAULT_WIN_HEIGHT 1080
-/* vconf value */
-#define WIRED_DNS_LAST_MODE "db/menu/network/wired_dns_mode"
-#define WIRED_IP_LAST_MODE "db/menu/network/wired_ip_mode"
-#define WIRED_IP_KEY "db/menu/network/wired_ip"
-#define WIRED_SUBMASK_KEY "db/menu/network/wired_subnet"
-#define WIRED_GATEWAY_KEY "db/menu/network/wired_gateway"
-#define WIRED_DNS_KEY "db/menu/network/wired_dns"
-
-#define WIRELESS_IP_LAST_MODE "db/menu/network/wireless_ip_mode"
-#define WIRELESS_DNS_LAST_MODE "db/menu/network/wireless_dns_mode"
-#define WIRELESS_IP_KEY "db/menu/network/wireless_ip"
-#define WIRELESS_SUBMASK_KEY "db/menu/network/wireless_subnet"
-#define WIRELESS_GATEWAY_KEY "db/menu/network/wireless_gateway"
-#define WIRELESS_DNS_KEY "db/menu/network/wireless_dns"
-
-#define SELECTED_NETWORK_TYPE_KEY "db/menu/network/network_type"
#endif /* __DEFS_H__ */
diff --git a/ug/network/include/ip_setting_view.h b/ug/network/include/ip_setting_view.h
new file mode 100644
index 0000000..0e85c27
--- /dev/null
+++ b/ug/network/include/ip_setting_view.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __CONNECTION_VIEW_H__
+#define __CONNECTION_VIEW_H__
+
+#include <Elementary.h>
+#include "network_viewmgr.h"
+
+struct view_class *ip_setting_view_vclass_get(void);
+
+#endif /* __CONNECTION_VIEW_H__ */
diff --git a/ug/network/include/main_view.h b/ug/network/include/main_view.h
new file mode 100644
index 0000000..018af4b
--- /dev/null
+++ b/ug/network/include/main_view.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __MAIN_VIEW_H__
+#define __MAIN_VIEW_H__
+
+#include <Elementary.h>
+#include <wifi.h>
+#include <net_connection.h>
+#include <ui-gadget-module.h>
+#include "network_viewmgr.h"
+
+struct view_class *main_view_vclass_get(void);
+
+#endif /* __MAIN_VIEW_H__ */
diff --git a/ug/network/include/network_viewmgr.h b/ug/network/include/network_viewmgr.h
new file mode 100644
index 0000000..fd5d0f4
--- /dev/null
+++ b/ug/network/include/network_viewmgr.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __NETVIEWMGR_H__
+#define __NETVIEWMGR_H__
+
+#include <Elementary.h>
+#include <ui-gadget-module.h>
+
+enum view_type {
+ NETWORK_MAIN_VIEW = 0,
+ NETWORK_WIFI_PASSCODE_VIEW,
+ NETWORK_IP_SETTING_VIEW
+};
+
+enum message_id {
+ PASSCODE_DEVIVER = 0
+};
+
+struct viewmgr {
+ Eina_List *vlist;
+ Evas_Object *win;
+ ui_gadget_h ug;
+};
+
+struct view_class {
+ Evas_Object * (*create)(struct viewmgr *vmgr, void *data);
+ void (*pause)(Evas_Object *base);
+ void (*resume)(Evas_Object *base);
+ void (*terminate)(Evas_Object *base);
+ void (*message_handler)(Evas_Object *base,
+ enum message_id msg_id, void *data);
+ enum view_type (*get_view_type)(void);
+};
+
+struct viewmgr *viewmgr_init();
+void viewmgr_fini(struct viewmgr *vmgr);
+Evas_Object *viewmgr_push(struct viewmgr *vmgr,
+ struct view_class *vclass, void *data);
+int viewmgr_send_message(struct viewmgr *vmgr,
+ enum view_type view_type,
+ enum message_id msg_id, void *data);
+int viewmgr_pop(struct viewmgr *vmgr);
+int viewmgr_resume(struct viewmgr *vmgr);
+Evas_Object *viewmgr_win_get(struct viewmgr *vmgr);
+
+#endif /* __VIEWMGR_H__ */
+
diff --git a/ug/network/include/util.h b/ug/network/include/util.h
index 80606d9..8e21037 100644
--- a/ug/network/include/util.h
+++ b/ug/network/include/util.h
@@ -17,13 +17,18 @@
#ifndef __UTIL_H__
#define __UTIL_H__
-Evas_Object *util_add_layout(Evas_Object *parent, const char *file, const char *group);
-Evas_Object *util_add_button(Evas_Object *parent, const char *style, const char *part, const char *text);
-Evas_Object *util_add_key_value_button(Evas_Object *parent, const char *part, const char *text_key, const char *text_value);
+Evas_Object *util_add_layout(Evas_Object *parent, const char *file,
+ const char *group);
+Evas_Object *util_add_button(Evas_Object *parent, const char *style,
+ const char *part, const char *text);
+Evas_Object *util_add_key_value_button(Evas_Object *parent,
+ const char *part, const char *text_key, const char *text_value);
Evas_Object *util_add_scroll(Evas_Object *parent, const char *part);
Evas_Object *util_add_box(Evas_Object *parent, const char *part);
-Evas_Object *util_add_image(Evas_Object *parent, const char *file, const char *part);
-Evas_Object *util_add_entry(Evas_Object *parent, const char *style, const char *part);
+Evas_Object *util_add_image(Evas_Object *parent,
+ const char *file, const char *part);
+Evas_Object *util_add_entry(Evas_Object *parent,
+ const char *style, const char *part);
Evas_Object *util_add_genlist(Evas_Object *parent);
void util_focus_next_set(Evas_Object *obj);
diff --git a/ug/network/include/vconf_mgr.h b/ug/network/include/vconf_mgr.h
new file mode 100644
index 0000000..e3335c2
--- /dev/null
+++ b/ug/network/include/vconf_mgr.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __VCONF_MGR_H__
+#define __VCONF_MGR_H__
+
+#include <vconf.h>
+#include "connection_mgr.h"
+#include "common.h"
+
+int vconf_mgr_get_network_type(enum network_type_enum *network_type);
+int vconf_mgr_set_network_type(enum network_type_enum network_type);
+int vconf_mgr_get_wired_network_info(struct network_info *info);
+int vconf_mgr_get_wireless_network_info(struct network_info *info);
+int vconf_mgr_save_wired_config_info(struct network_info *info);
+int vconf_mgr_save_wireless_config_info(struct network_info *info);
+int vconf_mgr_get_wired_ip_mode(enum setting_mode *mode);
+int vconf_mgr_set_wired_ip_mode(enum setting_mode mode);
+int vconf_mgr_get_wired_dns_mode(enum setting_mode *mode);
+int vconf_mgr_set_wired_dns_mode(enum setting_mode mode);
+int vconf_mgr_get_wireless_ip_mode(enum setting_mode *mode);
+int vconf_mgr_set_wireless_ip_mode(enum setting_mode mode);
+int vconf_mgr_get_wireless_dns_mode(enum setting_mode *mode);
+int vconf_mgr_set_wireless_dns_mode(enum setting_mode mode);
+
+#endif /* __VCONF_MGR_H__ */
diff --git a/ug/network/include/wifi_mgr.h b/ug/network/include/wifi_mgr.h
new file mode 100644
index 0000000..d9048cf
--- /dev/null
+++ b/ug/network/include/wifi_mgr.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_MGR_H__
+#define __WIFI_MGR_H__
+
+#include <wifi.h>
+#include "common.h"
+
+#define SSID_MAX_LENTH 256
+#define PWD_MAX_LENTH 256
+
+struct wifi_ap_info {
+ char essid[SSID_MAX_LENTH];
+ char bssid[SSID_MAX_LENTH];
+ int rssi;
+ int frequency;
+ int max_speed;
+ wifi_security_type_e secure_type;
+ wifi_encryption_type_e encryption_type;
+ bool passphrase_required;
+ int wps_supported;
+ wifi_connection_state_e state;
+
+ wifi_ip_config_type_e ip_type;
+ wifi_proxy_type_e proxy_type;
+ wifi_encryption_type_e enc_type;
+ wifi_eap_type_e eap_type;
+ wifi_eap_auth_type_e eap_auth_type;
+
+ wifi_ap_h ap;
+ void *user_data;
+};
+
+const char *wifi_mgr_error_dbg(wifi_error_e err_type);
+int wifi_mgr_init(void);
+int wifi_mgr_deinit(void);
+int wifi_mgr_ap_destroy(wifi_ap_h ap);
+int wifi_mgr_ap_clone(wifi_ap_h *cloned_ap, wifi_ap_h origin);
+int wifi_mgr_is_activated(bool *activated);
+int wifi_mgr_scan_request(wifi_scan_finished_cb cb, void *data);
+int wifi_mgr_foreach_found_aps(wifi_found_ap_cb cb, void *data);
+int wifi_mgr_activate(wifi_activated_cb cb, void *data);
+int wifi_mgr_get_ap_info(wifi_ap_h ap, struct wifi_ap_info *ap_info);
+int wifi_mgr_get_connected_ap(wifi_ap_h *ap);
+int wifi_mgr_forget_last_ap(void);
+int wifi_mgr_connect(wifi_ap_h ap, wifi_connected_cb cb, void *data);
+int wifi_mgr_set_passphrase(wifi_ap_h ap, const char *passcode);
+int wifi_mgr_get_ip_info(wifi_ap_h ap, struct network_info *info);
+int wifi_mgr_ap_set_ip_config_type(wifi_ap_h ap,
+ wifi_ip_config_type_e type);
+int wifi_mgr_set_ip_config(wifi_ap_h ap, struct network_info *info);
+int wifi_mgr_set_dns_config(wifi_ap_h ap, struct network_info *info);
+//int wifi_mgr_get_is_online_async(wifi_get_is_online_async_cb cb, void *data);
+
+#endif /* __WIFI_MGR_H__ */
diff --git a/ug/network/include/wifi_passcode_view.h b/ug/network/include/wifi_passcode_view.h
new file mode 100644
index 0000000..5805235
--- /dev/null
+++ b/ug/network/include/wifi_passcode_view.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_PASSWORD_VIEW_H__
+#define __WIFI_PASSWORD_VIEW_H__
+
+#include <Elementary.h>
+#include <wifi.h>
+#include <net_connection.h>
+#include <ui-gadget-module.h>
+#include "network_viewmgr.h"
+
+struct view_class *wifi_passcode_view_vclass_get(void);
+
+#endif /* __WIFI_PASSWORD_VIEW_H__ */
diff --git a/ug/network/src/IpSettingView.cpp b/ug/network/src/IpSettingView.cpp
deleted file mode 100644
index 7ee215d..0000000
--- a/ug/network/src/IpSettingView.cpp
+++ /dev/null
@@ -1,1691 +0,0 @@
-#include <ui-gadget-module.h>
-#include "defs.h"
-#include <AppCommon.h>
-#include <vconf.h>
-#include "i18n.h"
-#include "util.h"
-#include "common.h"
-#include "WifiMgr.h"
-#include "NetConMgr.h"
-
-#include "IpSettingView.h"
-
-#define MODE_BTN_NUM 2
-#define MAX_IP_NUM 255
-#define IP_SET_MAX_NUM 4
-#define STRING_MAX_SIZE 50
-#define SETTING_MODE_OFFSET_X 448
-#define SETTING_MODE_OFFSET_Y 0
-#define SETTING_VALUE_OFFSET_X 162
-#define SETTING_VALUE_OFFSET_Y 20
-#define CENTER_ALIGN 0.5
-#define BOX_PAD_X 0
-#define BOX_PAD_Y 2
-#define RATIO 10
-
-#define IP_VALUE1 "value1"
-#define IP_VALUE2 "value2"
-#define IP_VALUE3 "value3"
-#define IP_VALUE4 "value4"
-
-#define TXT_MAKE_OTHER_NETWORK _("You can make other network"\
- "<br>Enter the IP address to use.")
-
-enum connection_setting_enum {
- SETTING_INVALID,
- SETTING_IP,
- SETTING_IP_ADDRESS,
- SETTING_SUBNET_MASK,
- SETTING_GATEWAY,
- SETTING_DNS,
- SETTING_DNS_SERVER
-};
-
-struct SIpSettingView {
- ui_gadget_h ug;
-
- Evas_Object *win;
- Evas_Object *base;
- Evas_Object *dim_ly;
- Evas_Object *ip_mode_btn;
- Evas_Object *ip_addr_btn;
- Evas_Object *subnet_mask_btn;
- Evas_Object *gateway_btn;
- Evas_Object *dns_mode_btn;
- Evas_Object *dns_server_btn;
- Evas_Object *ip_mode_ly;
- Evas_Object *dns_mode_ly;
- Evas_Object *config_popup;
- Evas_Object *cur_ip_btn[IP_SET_MAX_NUM];
- Evas_Object *confirm_popup;
- Evas_Object *ok_btn;
- Evas_Object *cancel_btn;
-
- struct network_info info;
- enum setting_mode ip_mode;
- enum setting_mode dns_mode;
-
- enum connection_setting_enum cur_type;
- enum network_type_enum network_type;
-
- CWifiAp *ap;
-
- char profile_name[MAX_NAME_SIZE];
-
- CWifiMgr *pWifiMgr;
- CNetConMgr *pNetConMgr;
- CViewMgr *pViewMgr;
-};
-
-
-bool CIpSettingView::m_InitConnectionMgr()
-{
- _DBG();
- if(!CNetConMgr::Initialize()) {
- _ERR("Fail to init CNetConMgr");
- }
-
- m->pNetConMgr = CNetConMgr::GetInstance();
- if (!m->pNetConMgr) {
- _ERR("Fail to get instance");
- return false;
- }
-
- if(!m->pNetConMgr->GetProfileName(m->profile_name)) {
- _ERR("Fail to get profilename");
- return false;
- }
-
- return true;
-}
-
-void CIpSettingView::m_FinalizeConnectionMgr()
-{
- _DBG();
- CNetConMgr::Finalize();
- m->pNetConMgr = NULL;
-}
-
-
-bool CIpSettingView::m_GetCurConnectionMode(void)
-{
- const char *str = NULL;
- if (m->network_type == TYPE_WIRED) {
- str = vconf_get_str(WIRED_IP_LAST_MODE);
- if (str && !strcmp(str, _(TXT_OBTAIN_AUTO)))
- m->ip_mode = MODE_AUTO;
- else
- m->ip_mode = MODE_MAN;
-
- str = NULL;
- str = vconf_get_str(WIRED_DNS_LAST_MODE);
- if (str && !strcmp(str, _(TXT_OBTAIN_AUTO)))
- m->dns_mode = MODE_AUTO;
- else
- m->dns_mode = MODE_MAN;
- } else if (m->network_type == TYPE_WIRELESS) {
- str = vconf_get_str(WIRELESS_IP_LAST_MODE);
- if (str && !strcmp(str, _(TXT_OBTAIN_AUTO)))
- m->ip_mode = MODE_AUTO;
- else
- m->ip_mode = MODE_MAN;
-
- str = NULL;
- str = vconf_get_str(WIRELESS_DNS_LAST_MODE);
- if (str && !strcmp(str, _(TXT_OBTAIN_AUTO)))
- m->dns_mode = MODE_AUTO;
- else
- m->dns_mode = MODE_MAN;
- } else {
- _ERR("the network type is invalid.");
- return false;
- }
-
- return true;
-}
-
-
-bool CIpSettingView::m_GetCurIpInfo(void)
-{
- struct network_info info;
- bool result = false;
-
- if (m->network_type == TYPE_WIRED) {
- if (m->ip_mode == MODE_AUTO) {
- if (!m->pNetConMgr->GetIpAddr(info.ip_addr)) {
- _ERR("connection_mgr_get_ip_info() failed.");
- return false;
- }
- if (!m->pNetConMgr->GetSubnetMask(info.submask)) {
- _ERR("connection_mgr_get_ip_info() failed.");
- return false;
- }
- if (!m->pNetConMgr->GetGateway(info.gateway)) {
- _ERR("connection_mgr_get_ip_info() failed.");
- return false;
- }
- if (!m->pNetConMgr->GetDNS(info.dns)) {
- _ERR("connection_mgr_get_ip_info() failed.");
- return false;
- }
- } else if (m->ip_mode == MODE_MAN) {
- m_GetIpInfo(info.ip_addr, WIRED_IP_KEY);
- m_GetIpInfo(info.submask, WIRED_SUBMASK_KEY);
- m_GetIpInfo(info.gateway, WIRED_GATEWAY_KEY);
- m_GetIpInfo(info.dns, WIRED_DNS_KEY);
- } else {
- _ERR("ip mode is invalid.");
- return false;
- }
- } else if (m->network_type == TYPE_WIRELESS) {
- if (m->ip_mode == MODE_AUTO) {
- result = m->ap->GetIp(m->info.ip_addr, sizeof(m->info.ip_addr));
- if(result != true) {
- _ERR("wifi_mgr_get_ip_info() failed.");
- return false;
- }
- result = m->ap->GetSubnetMask(m->info.submask);
- if(result != true) {
- _ERR("wifi_mgr_get_ip_info() failed.");
- return false;
- }
- result = m->ap->GetGateway(m->info.gateway);
- if(result != true) {
- _ERR("wifi_mgr_get_ip_info() failed.");
- return false;
- }
- result = m->ap->GetDNS(m->info.dns);
- if(result != true) {
- _ERR("wifi_mgr_get_ip_info() failed.");
- return false;
- }
- } else if (m->ip_mode == MODE_MAN) {
- m_GetIpInfo(info.ip_addr, WIRELESS_IP_KEY);
- m_GetIpInfo(info.submask, WIRELESS_SUBMASK_KEY);
- m_GetIpInfo(info.gateway, WIRELESS_GATEWAY_KEY);
- m_GetIpInfo(info.dns, WIRELESS_DNS_KEY);
- } else {
- _ERR("ip mode is invalid.");
- return false;
- }
- } else {
- _ERR("network type is invalid.");
- return false;
- }
-
- strncpy(m->info.ip_addr, info.ip_addr, IP_STRING_MAX_SIZE);
- strncpy(m->info.submask, info.submask, IP_STRING_MAX_SIZE);
- strncpy(m->info.gateway, info.gateway, IP_STRING_MAX_SIZE);
- strncpy(m->info.dns, info.dns, IP_STRING_MAX_SIZE);
-
- return true;
-}
-
-
-void CIpSettingView::m_GetIpInfo(char *des, const char *key)
-{
- _DBG();
- const char *str;
-
- if (!des || !key)
- return;
-
- str = vconf_get_str(key);
- if (!str)
- return;
-
- if (str == '\0' || !strncmp(str, NULL_STRING, IP_STRING_MAX_SIZE))
- strncpy(des, _(ZERO_IP), IP_STRING_MAX_SIZE);
- else
- strncpy(des, str, IP_STRING_MAX_SIZE);
-}
-
-
-bool CIpSettingView::m_CreateDNSSetting(void)
-{
- Evas_Object *base = NULL;
- Evas_Object *btn;
- Evas_Object *box;
- char mode[STRING_MAX_SIZE];
-
- box = util_add_box(base, PART_CONNECTION_DNS_SETTING);
- if (!box) {
- _ERR("add box failed.");
- return false;
- }
-
- elm_box_horizontal_set(box, EINA_FALSE);
- elm_box_padding_set(box, BOX_PAD_X, BOX_PAD_Y);
-
- memset(mode, 0, STRING_MAX_SIZE);
- if (m->dns_mode == MODE_AUTO)
- snprintf(mode, STRING_MAX_SIZE - 1, "%s", _(TXT_OBTAIN_AUTO));
- else
- snprintf(mode, STRING_MAX_SIZE - 1, "%s", _(TXT_ENTER_MAN));
-
- btn = util_add_key_value_button(base, NULL, _(TXT_DNS_SETING), mode);
- if (!btn) {
- _ERR("Add button failed.");
- evas_object_del(box);
- return false;
- }
-
- //evas_object_smart_callback_add(btn, SIG_CLICKED, _dns_setting_btn_clicked_cb, priv);
- Connect(btn, 1);
-
- elm_box_pack_end(box, btn);
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT);
-
- m->dns_mode_btn = btn;
-
- btn = util_add_key_value_button(base, NULL, _(TXT_DNS_SERVER), m->info.dns);
- if (!btn) {
- _ERR("Add btn failed.");
- evas_object_del(box);
- return false;
- }
-
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT);
-
- //evas_object_smart_callback_add(btn, SIG_CLICKED, _dns_server_btn_clicked_cb, priv);
- Connect(btn, 2);
-
- elm_object_signal_emit(btn, SIG_HIDE_BOTTOME_LINE, PROG);
- elm_box_pack_end(box, btn);
-
- m->dns_server_btn = btn;
-
- if (m->dns_mode == MODE_AUTO)
- elm_object_disabled_set(m->dns_server_btn, EINA_TRUE);
-
- return true;
-}
-
-
-bool CIpSettingView::m_CreateBtns(void)
-{
- Evas_Object *base = NULL;
- Evas_Object *ok_btn;
- Evas_Object *cancel_btn;
-
- ok_btn = util_add_button(base, STYLE_SETTING_BTN, NULL, _(TXT_OK));
- if (!ok_btn) {
- _ERR("Add button failed.");
- return false;
- }
-
- elm_object_part_content_set(base, PART_CONNECTION_OK_BTN, ok_btn);
- m->ok_btn = ok_btn;
-
- //evas_object_smart_callback_add(ok_btn, SIG_CLICKED, _ok_btn_clicked_cb, priv);
- Connect(ok_btn, 3);
-
- cancel_btn = util_add_button(base, STYLE_SETTING_BTN, PART_CONNECTION_CANCEL_BTN, _(TXT_CANCEL));
- if (!cancel_btn) {
- _ERR("Add button failed.");
- evas_object_del(ok_btn);
- return false;
- }
-
- //evas_object_smart_callback_add(cancel_btn, SIG_CLICKED, _cancel_btn_clicked_cb, priv);
- Connect(cancel_btn, 4);
-
- m->cancel_btn = cancel_btn;
-
- return true;
-}
-
-
-bool CIpSettingView::m_CreateIpSetting(void)
-{
- Evas_Object *base = NULL;
- Evas_Object *scroll;
- Evas_Object *box;
- Evas_Object *btn;
- char mode[STRING_MAX_SIZE];
-
- scroll = util_add_scroll(base, PART_CONNECTION_IP_SETTING);
- if (!scroll) {
- _ERR("add scroll failed.");
- return false;
- }
-
- box = util_add_box(scroll, NULL);
- if (!box) {
- _ERR("add box failed.");
- evas_object_del(scroll);
- return false;
- }
-
- elm_box_horizontal_set(box, EINA_FALSE);
- elm_box_padding_set(box, BOX_PAD_X, BOX_PAD_Y);
-
- memset(mode, 0, STRING_MAX_SIZE);
- if (m->ip_mode == MODE_AUTO)
- snprintf(mode, STRING_MAX_SIZE - 1, "%s", _(TXT_OBTAIN_AUTO));
- else
- snprintf(mode, STRING_MAX_SIZE - 1, "%s", _(TXT_ENTER_MAN));
-
- btn = util_add_key_value_button(base, NULL, _(TXT_IP_SETTING), mode);
- if (!btn) {
- _ERR("Add button failed.");
- evas_object_del(scroll);
- return false;
- }
- //evas_object_smart_callback_add(btn, SIG_CLICKED, cb, data);
- Connect(btn, 5);
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT);
-
- elm_box_pack_end(box, btn);
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_UP);
- elm_object_focus_set(btn, EINA_TRUE);
- m->ip_mode_btn = btn;
-
- btn = util_add_key_value_button(base, NULL, _(TXT_IP_ADDR), m->info.ip_addr);
- if (!btn) {
- _ERR("Add btn failed.");
- evas_object_del(scroll);
- return false;
- }
- //evas_object_smart_callback_add(btn, SIG_CLICKED, _ip_address_btn_clicked_cb, data);
- Connect(btn, 6);
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT);
-
- elm_box_pack_end(box, btn);
- m->ip_addr_btn = btn;
-
- btn = util_add_key_value_button(base, NULL, _(TXT_SUBNET_MASK), m->info.submask);
- if (!btn) {
- _ERR("Add btn failed.");
- evas_object_del(scroll);
- return false;
- }
- //evas_object_smart_callback_add(btn, SIG_CLICKED, _sub_mask_btn_clicked_cb, data);
- Connect(btn, 7);
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT);
-
- elm_box_pack_end(box, btn);
- m->subnet_mask_btn = btn;
-
- btn = util_add_key_value_button(base, NULL, _(TXT_GATEWAY), m->info.gateway);
- if (!btn) {
- _ERR("Add btn failed.");
- evas_object_del(scroll);
- return false;
- }
- //evas_object_smart_callback_add(btn, SIG_CLICKED, _gateway_btn_clicked_cb, data);
- Connect(btn, 8);
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT);
-
- elm_object_signal_emit(btn, SIG_HIDE_BOTTOME_LINE, PROG);
-
- elm_box_pack_end(box, btn);
- m->gateway_btn = btn;
-
- elm_object_content_set(scroll, box);
-
- if (m->ip_mode == MODE_AUTO){
- elm_object_disabled_set(m->ip_addr_btn, EINA_TRUE);
- elm_object_disabled_set(m->subnet_mask_btn, EINA_TRUE);
- elm_object_disabled_set(m->gateway_btn, EINA_TRUE);
- }
-
- return true;
-}
-
-
-bool CIpSettingView::m_CreateDimLayout(void)
-{
- Evas_Object *dim_ly;
-
- dim_ly = util_add_layout(m->win, UG_NETWORK_EDJ_FILE,
- GRP_DIM_LY);
- if (!dim_ly) {
- _ERR("elm_layout_add() failed.");
- return false;
- }
-
- m->dim_ly = dim_ly;
- evas_object_hide(m->dim_ly);
-
- return true;
-}
-
-Evas_Object* CIpSettingView::m_CreateMainLayout()
-{
- _DBG();
- Evas_Object *base;
-
- base = elm_layout_add(m->win);
- if (!base) {
- _ERR("elm_layout_add() failed.");
- return NULL;
- }
-
- elm_layout_file_set(base, UG_NETWORK_EDJ_FILE, GRP_CONNECTION_SETTING);
-
- evas_object_show(base);
-
- return base;
-}
-
-
-void CIpSettingView::t_OnShow()
-{
- _DBG();
-
- evas_object_show(m->base);
-
- CBaseView::t_OnShow();
-}
-
-
-void CIpSettingView::t_OnUpdate(void *data)
-{
- _DBG();
-
- evas_object_show(m->base);
-
-#if 0
- switch (m->cur_view) {
- case NETWORK_IP_SETTING_VIEW:
- elm_object_focus_set(m->other_btn, EINA_TRUE);
- break;
- case NETWORK_WIFI_PASSCODE_VIEW:
- elm_object_focus_set(m->connect_btn, EINA_TRUE);
- break;
- default:
- break;
- }
-#endif
-}
-
-
-void CIpSettingView::t_OnHide()
-{
- _DBG();
-
- evas_object_hide(m->base);
-
- CBaseView::t_OnHide();
-}
-
-
-bool CIpSettingView::Create(void *data)
-{
- _DBG();
- ASSERT(!m);
-
- struct connection_info *info;
-
- _CREATE_BEGIN{
- _CHECK(m = new SIpSettingView)
- _CHECK(m->win = CViewMgr::GetInstance()->Window())
- _CHECK(m_InitConnectionMgr())
- _COMMAND{
- if(data) {
- info = (struct connection_info *) data;
- m->network_type = info->cur_type;
- m->ap = m->ap;
- strncpy(m->profile_name, info->name, MAX_NAME_SIZE - 1);
- }
- }
- _CHECK(m->base = m_CreateMainLayout())
- _COMMAND{
- //evas_object_event_callback_add(base, EVAS_CALLBACK_KEY_DOWN, _base_key_pressed_cb, priv);
- Connect(m->base, 0);
- elm_object_part_text_set(m->base, PART_CONNECTION_DESCRITION, TXT_MAKE_OTHER_NETWORK);
- }
- _CHECK(m_GetCurConnectionMode())
- _CHECK(m_GetCurIpInfo())
- _CHECK(m_CreateDNSSetting())
- _CHECK(m_CreateBtns())
- _CHECK(m_CreateIpSetting())
- _CHECK(m_CreateDimLayout())
- _WHEN_SUCCESS{
- m->pViewMgr = CViewMgr::GetInstance();
- }
- _CHECK_FAIL{ /* m_CreateDimLayout() */ }
- _CHECK_FAIL{ /* m_CreateIpSetting() */ }
- _CHECK_FAIL{ /* m_CreateBtns() */ }
- _CHECK_FAIL{ /* m_CreateDNSSetting() */ }
- _CHECK_FAIL{ /* m_GetCurIpInfo() */ }
- _CHECK_FAIL{ /* m_GetCurConnectionMode() */ }
- _CHECK_FAIL{ evas_object_del(m->base); }
- _CHECK_FAIL{ m_FinalizeConnectionMgr(); }
- _CHECK_FAIL{ /* m->win = CViewMgr::GetInstance()->Window() */ }
- _CHECK_FAIL{ delete m; m = NULL; }
- } _CREATE_END_AND_CATCH{ return false; }
-
- _DBG("Done");
- return true;
-}
-
-
-void CIpSettingView::Destroy()
-{
- ASSERT(m);
- _DBG();
-
- if (m->dim_ly)
- evas_object_del(m->dim_ly);
-
- CBaseView::Destroy();
- delete m;
- m = NULL;
-}
-
-Evas_Object* CIpSettingView::Base()
-{
- ASSERT(m);
- _DBG();
-
- return m->base;
-}
-
-
-void CIpSettingView::m_SetupDownCycleFocus(Evas_Object **obj, int count)
-{
- int i;
-
- if (!*obj || !obj)
- return;
-
- for (i = 0; i < count; i++) {
- if (i == count - 1)
- elm_object_focus_next_object_set(obj[i], obj[0], ELM_FOCUS_DOWN);
- else
- elm_object_focus_next_object_set(obj[i], obj[i + 1], ELM_FOCUS_DOWN);
-
- if (i == 0)
- elm_object_focus_next_object_set(obj[i], obj[count - 1], ELM_FOCUS_UP);
- else
- elm_object_focus_next_object_set(obj[i], obj[i - 1], ELM_FOCUS_UP);
- }
-}
-
-
-void CIpSettingView::m_KeepBtnFocused(void)
-{
- Evas_Object *obj;
-
- switch (m->cur_type) {
- case SETTING_IP:
- obj = m->ip_mode_btn;
- break;
- case SETTING_IP_ADDRESS:
- obj = m->ip_addr_btn;
- break;
- case SETTING_SUBNET_MASK:
- obj = m->subnet_mask_btn;
- break;
- case SETTING_GATEWAY:
- obj = m->gateway_btn;
- break;
- case SETTING_DNS:
- obj = m->dns_mode_btn;
- break;
- case SETTING_DNS_SERVER:
- obj = m->dns_server_btn;
- break;
- default:
- return;
- }
-
- elm_object_signal_emit(obj, SIG_BTN_SELECTED, PROG);
-}
-
-
-void CIpSettingView::m_CreateValuePopup(void)
-{
- Evas_Object *base = NULL, *ctxpopup, *btn;
- Evas_Coord pos_x, pos_y;
- int i;
-
- ctxpopup = util_add_layout(base, UG_NETWORK_EDJ_FILE,
- GRP_NETWORK_VALUE_SETTING);
- if (!ctxpopup) {
- _ERR("elm_ctxpopup_add() failed.");
- return;
- }
-
- elm_object_focus_allow_set(ctxpopup, EINA_TRUE);
- //evas_object_smart_callback_add(ctxpopup, SIG_UNFOCUSED, _ctxpopup_unfocused_cb, priv);
- Connect(ctxpopup, 15);
-
- m->config_popup = ctxpopup;
-
- evas_object_show(m->dim_ly);
-
- for (i = 0; i < IP_SET_MAX_NUM; i++) {
- btn = m_CreateValueBtn(ctxpopup, i, _(TXT_ZERO), NULL);
- if (!btn) {
- _ERR("_create_value_btn() failed.");
- evas_object_del(ctxpopup);
- m->config_popup = NULL;
- return;
- }
-
- m->cur_ip_btn[i] = btn;
- }
- //evas_object_smart_callback_add(btn, SIG_CLICKED, _popup_dismissed_cb, data);
- //evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, _ip_btn_key_pressed_cb, data);
- Connect(m->cur_ip_btn[0], 16);
- Connect(m->cur_ip_btn[1], 17);
- Connect(m->cur_ip_btn[2], 18);
- Connect(m->cur_ip_btn[3], 19);
-
- //evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_KEY_DOWN, _value_ctxpopup_key_pressed_cb, priv);
- m_SetLeftRightCycleFocus(m->cur_ip_btn, IP_SET_MAX_NUM);
-
- m_KeepBtnFocused();
-
- pos_x = 0;
- pos_y = 0;
- m_GetValuePopupPos(&pos_x, &pos_y);
- evas_object_move(ctxpopup, pos_x * ELM_SCALE, pos_y * ELM_SCALE);
-
-}
-
-
-Evas_Object* CIpSettingView::m_CreateValueBtn(Evas_Object *base, int num, char *txt, void *data)
-{
- Evas_Object *btn;
-
- if (!base || !txt || !data) {
- _ERR("The param is invalid.");
- return NULL;
- }
-
- btn = util_add_button(base, STYLE_VALUE_BTN, NULL, txt);
- if (!btn) {
- _ERR("add button failed.");
- return NULL;
- }
-
- switch (num) {
- case 0:
- elm_object_part_content_set(base, PART_IP_FIRST, btn);
- evas_object_data_set(base, IP_VALUE1, btn);
- elm_object_focus_set(btn, EINA_TRUE);
- break;
- case 1:
- elm_object_part_content_set(base, PART_IP_SECOND, btn);
- evas_object_data_set(base, IP_VALUE2, btn);
- break;
- case 2:
- elm_object_part_content_set(base, PART_IP_THIRD, btn);
- evas_object_data_set(base, IP_VALUE3, btn);
- break;
- case 3:
- elm_object_part_content_set(base, PART_IP_FORTH, btn);
- evas_object_data_set(base, IP_VALUE4, btn);
- break;
- default:
- break;
- }
-
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_DOWN);
-
- return btn;
-}
-
-
-void CIpSettingView::m_SetLeftRightCycleFocus(Evas_Object **obj, int count)
-{
- int i;
-
- if (!obj || !*obj) {
- _ERR("the param is invalid.");
- return;
- }
-
- for (i = 0; i < count; i++) {
- if (i == count - 1)
- elm_object_focus_next_object_set(obj[i], obj[0], ELM_FOCUS_RIGHT);
- else
- elm_object_focus_next_object_set(obj[i], obj[i + 1], ELM_FOCUS_RIGHT);
-
- if (i == 0)
- elm_object_focus_next_object_set(obj[i], obj[count - 1], ELM_FOCUS_LEFT);
- else
- elm_object_focus_next_object_set(obj[i], obj[i - 1], ELM_FOCUS_LEFT);
- }
-}
-
-
-bool CIpSettingView::m_GetValuePopupPos(Evas_Coord *pos_x, Evas_Coord *pos_y)
-{
- Evas_Coord x;
- Evas_Coord y;
- Evas_Coord w;
- Evas_Coord h;
-
- if (!pos_x || !pos_y) {
- _ERR("the param is invalid.");
- return false;
- }
-
- switch (m->cur_type) {
- case SETTING_IP_ADDRESS:
- evas_object_geometry_get(m->ip_addr_btn, &x, &y, &w, &h);
- *pos_x = x + SETTING_VALUE_OFFSET_X;
- *pos_y = y - SETTING_VALUE_OFFSET_Y;
- break;
- case SETTING_SUBNET_MASK:
- evas_object_geometry_get(m->subnet_mask_btn, &x, &y, &w, &h);
- *pos_x = x + SETTING_VALUE_OFFSET_X;
- *pos_y = y - SETTING_VALUE_OFFSET_Y;
- break;
- case SETTING_GATEWAY:
- evas_object_geometry_get(m->gateway_btn, &x, &y, &w, &h);
- *pos_x = x + SETTING_VALUE_OFFSET_X;
- *pos_y = y - SETTING_VALUE_OFFSET_Y;
- break;
- case SETTING_DNS_SERVER:
- evas_object_geometry_get(m->dns_server_btn, &x, &y, &w, &h);
- *pos_x = x + SETTING_VALUE_OFFSET_X;
- *pos_y = y - 2 * SETTING_VALUE_OFFSET_Y;
- break;
- default:
- return false;
- }
-
- return true;
-}
-
-
-void CIpSettingView::m_ConfigNetwork(void)
-{
- bool ret;
-
- switch (m->ip_mode) {
- case MODE_AUTO:
- ret = m_ConfigNetworkDynamic();
- if (ret != true) {
- _ERR("config network automatically failed.");
- m_ShowConfirmPopup();
- return;
- }
-
- break;
- case MODE_MAN:
- ret = m_ConfigNetworkManually();
- if (ret == false) {
- _ERR("invalid IP.");
- return;
- } else if (ret != true) {
- _ERR("config network manually failed.");
- m_ShowConfirmPopup();
- return;
- }
-
- break;
- default:
- m_ShowConfirmPopup();
- return;
- }
-
- m_SaveMode();
-
-#if 0
- viewmgr_pop(m->vmgr);
-#endif
-}
-
-
-void CIpSettingView::m_ShowConfirmPopup(void)
-{
- Evas_Object *layout;
- Evas_Object *retry_btn, *cancel_btn;
- Evas_Coord w;
- Evas_Coord h;
- char content[CONTENT_TXT_SIZE];
-
- evas_object_show(m->dim_ly);
-
- layout = util_add_layout(m->base, UG_NETWORK_EDJ_FILE,
- GRP_CONFIRM_LAYOUT);
- if (!layout) {
- _ERR("add layout failed.");
- evas_object_hide(m->dim_ly);
- return;
- }
-
- m->confirm_popup = layout;
-
- if (m->network_type == TYPE_WIRED)
- elm_object_part_text_set(layout, PART_TEXT_TITLE, _(TXT_WIRED_LY));
- else
- elm_object_part_text_set(layout, PART_TEXT_TITLE, _(TXT_WIRELESS_LY));
-
- memset(content, 0, CONTENT_TXT_SIZE);
- snprintf(content, CONTENT_TXT_SIZE - 1, "%s %s", _(TXT_FAILED_CONNECT), m->profile_name);
- elm_object_part_text_set(layout, PART_TEXT_CONTENT, content);
-
- retry_btn = util_add_button(layout, STYLE_SETTING_BTN, PART_RETRY_BTN, _(TXT_RETRY));
- if (!retry_btn) {
- _ERR("util add button failed.");
- evas_object_del(layout);
- evas_object_hide(m->dim_ly);
- return;
- }
-
- cancel_btn = util_add_button(layout, STYLE_SETTING_BTN, PART_CANCEL_BTN, _(TXT_CANCEL));
- if (!cancel_btn) {
- _ERR("util add button failed.");
- evas_object_del(layout);
- evas_object_hide(m->dim_ly);
- return;
- }
-
- elm_object_focus_next_object_set(retry_btn, cancel_btn, ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(cancel_btn, retry_btn, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(cancel_btn, cancel_btn, ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(retry_btn, retry_btn, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(cancel_btn, cancel_btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(retry_btn, retry_btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(cancel_btn, cancel_btn, ELM_FOCUS_DOWN);
- elm_object_focus_next_object_set(retry_btn, retry_btn, ELM_FOCUS_DOWN);
-
- //evas_object_smart_callback_add(retry_btn, SIG_CLICKED, _retry_btn_clicked_cb, priv);
- //evas_object_smart_callback_add(cancel_btn, SIG_CLICKED, _popup_ok_cancel_btn_clicked_cb, priv);
- Connect(retry_btn, 20);
- Connect(cancel_btn, 21);
-
- elm_object_focus_set(retry_btn, EINA_TRUE);
-
- elm_object_focus_allow_set(layout, EINA_TRUE);
- //evas_object_smart_callback_add(layout, SIG_UNFOCUSED, _ctxpopup_unfocused_cb, priv);
- //evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN, _ctxpopup_pressed_cb, priv);
- Connect(layout, 22);
-
- w = DEFAULT_WIN_WIDTH;
- h = DEFAULT_WIN_HEIGHT;
-
- evas_object_move(layout, CENTER_ALIGN * (w - POPUP_WIDTH) * ELM_SCALE, CENTER_ALIGN * (h - POPUP_HEIGHT) * ELM_SCALE);
-}
-
-
-bool CIpSettingView::m_ConfigNetworkDynamic(void)
-{
- bool result = false;
-
- switch (m->network_type) {
- case TYPE_WIRED:
- if(!m->pNetConMgr->SetIpConfType(CONNECTION_IP_CONFIG_TYPE_DYNAMIC)) {
- _ERR("connection_mgr_ip_dynamic_config() failed.");
- return false;
- }
-
- break;
- case TYPE_WIRELESS:
- result = m->ap->SetIpType(WIFI_IP_CONFIG_TYPE_DYNAMIC);
- if(result != false) {
- _ERR("connection_mgr_ip_dynamic_config() failed.");
- return false;
- }
-
- break;
- default:
- break;
- }
-
- return true;
-}
-
-
-bool CIpSettingView::m_ConfigNetworkManually(void)
-{
- bool result = false;
-
- result = m_CheckIpValid();
- if (result != true) {
- _ERR("the ip is invalid.");
- m_ShowInvalidIpPopup();
- return false;
- }
-
- result = false;
- switch (m->network_type) {
- case TYPE_WIRED:
- if (!m->pNetConMgr->SetIpAddr(m->info.ip_addr)) {
- _ERR("set profile failed.");
- return false;
- }
- if (!m->pNetConMgr->SetSubnetMask(m->info.submask)) {
- _ERR("set profile failed.");
- return false;
- }
- if (!m->pNetConMgr->SetGateway(m->info.gateway)) {
- _ERR("set profile failed.");
- return false;
- }
- if (!m->pNetConMgr->SetDNS(m->info.dns)) {
- _ERR("set profile failed.");
- return false;
- }
-
- vconf_set_str(WIRED_IP_KEY, m->info.ip_addr);
- vconf_set_str(WIRED_SUBMASK_KEY, m->info.submask);
- vconf_set_str(WIRED_GATEWAY_KEY, m->info.gateway);
- vconf_set_str(WIRED_DNS_KEY, m->info.dns);
- break;
- case TYPE_WIRELESS:
- result = m->ap->SetIp(m->info.ip_addr);
- if(result != true) {
- _ERR("set wifi dns config failed.");
- return false;
- }
- result = m->ap->SetSubnetMask(m->info.submask);
- if(result != true) {
- _ERR("set wifi dns config failed.");
- return false;
- }
- result = m->ap->SetGateway(m->info.gateway);
- if(result != true) {
- _ERR("set wifi dns config failed.");
- return false;
- }
- result = m->ap->SetDNS(m->info.dns);
- if(result != true) {
- _ERR("set wifi dns config failed.");
- return false;
- }
-
- vconf_set_str(WIRELESS_IP_KEY, m->info.ip_addr);
- vconf_set_str(WIRELESS_SUBMASK_KEY, m->info.submask);
- vconf_set_str(WIRELESS_GATEWAY_KEY, m->info.gateway);
- vconf_set_str(WIRELESS_DNS_KEY, m->info.dns);
- break;
- default:
- break;
- }
-
- return true;
-}
-
-
-bool CIpSettingView::m_CheckIpValid(void)
-{
- if (!strncmp(m->info.ip_addr, ZERO_IP, IP_STRING_MAX_SIZE)) {
- _ERR("IP addr is invalid.");
- return false;
- }
-
- if (!strncmp(m->info.submask, ZERO_IP, IP_STRING_MAX_SIZE)) {
- _ERR("submask addr is invalid.");
- return false;
- }
-
- if (!strncmp(m->info.gateway, ZERO_IP, IP_STRING_MAX_SIZE)) {
- _ERR("gateway addr is invalid.");
- return false;
- }
-
- if (!strncmp(m->info.dns, ZERO_IP, IP_STRING_MAX_SIZE)) {
- _ERR("dns addr is invalid.");
- return false;
- }
-
- return true;
-}
-
-
-void CIpSettingView::m_ShowInvalidIpPopup(void)
-{
- Evas_Object *layout;
- Evas_Object *ok_btn;
- Evas_Coord w;
- Evas_Coord h;
- char content[CONTENT_TXT_SIZE];
-
- if (m->confirm_popup) {
- evas_object_del(m->confirm_popup);
- m->confirm_popup = NULL;
- }
-
- evas_object_show(m->dim_ly);
-
- layout = util_add_layout(m->base, UG_NETWORK_EDJ_FILE, GRP_CONFIRM_LAYOUT);
- if (!layout) {
- _ERR("add layout failed.");
- evas_object_hide(m->dim_ly);
- return;
- }
-
- evas_object_show(layout);
-
- if (m->network_type == TYPE_WIRED)
- elm_object_part_text_set(layout, PART_TEXT_TITLE, _(TXT_WIRED_LY));
- else
- elm_object_part_text_set(layout, PART_TEXT_TITLE, _(TXT_WIRELESS_LY));
-
- memset(content, 0, CONTENT_TXT_SIZE);
- snprintf(content, CONTENT_TXT_SIZE - 1, "%s", _(TXT_INVALID_IP));
- elm_object_part_text_set(layout, PART_TEXT_CONTENT, content);
-
- ok_btn = util_add_button(layout, STYLE_SETTING_BTN, PART_OK_BTN, _(TXT_OK));
- if (!ok_btn) {
- _ERR("util add button failed.");
- evas_object_del(layout);
- evas_object_hide(m->dim_ly);
- return;
- }
-
- elm_object_focus_next_object_set(ok_btn, ok_btn, ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(ok_btn, ok_btn, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(ok_btn, ok_btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(ok_btn, ok_btn, ELM_FOCUS_DOWN);
- //evas_object_smart_callback_add(ok_btn, SIG_CLICKED, _popup_ok_cancel_btn_clicked_cb, priv);
- Connect(ok_btn, 23);
-
- elm_object_focus_set(ok_btn, EINA_TRUE);
-
- elm_object_focus_allow_set(layout, EINA_TRUE);
- //evas_object_smart_callback_add(layout, SIG_UNFOCUSED, _ctxpopup_unfocused_cb, priv);
- //evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN, _ctxpopup_pressed_cb, priv);
- Connect(layout, 24);
-
- w = DEFAULT_WIN_WIDTH;
- h = DEFAULT_WIN_HEIGHT;
-
- evas_object_move(layout, CENTER_ALIGN * (w - POPUP_WIDTH) * ELM_SCALE, CENTER_ALIGN * (h - POPUP_HEIGHT) * ELM_SCALE);
-
- m->confirm_popup = layout;
-}
-
-
-void CIpSettingView::m_SaveMode(void)
-{
- switch (m->network_type) {
- case TYPE_WIRED:
- if(m->ip_mode == MODE_AUTO) {
- vconf_set_str(WIRED_IP_LAST_MODE, _(TXT_OBTAIN_AUTO));
- }
- else if(m->ip_mode == MODE_MAN) {
- vconf_set_str(WIRED_IP_LAST_MODE, _(TXT_ENTER_MAN));
- }
-
- if(m->dns_mode == MODE_AUTO) {
- vconf_set_str(WIRED_DNS_LAST_MODE, _(TXT_OBTAIN_AUTO));
- }
- else if(m->dns_mode == MODE_MAN) {
- vconf_set_str(WIRED_DNS_LAST_MODE, _(TXT_ENTER_MAN));
- }
- break;
- case TYPE_WIRELESS:
- if(m->ip_mode == MODE_AUTO) {
- vconf_set_str(WIRELESS_IP_LAST_MODE, _(TXT_OBTAIN_AUTO));
- }
- else if(m->ip_mode == MODE_MAN) {
- vconf_set_str(WIRELESS_IP_LAST_MODE, _(TXT_ENTER_MAN));
- }
-
- if(m->dns_mode == MODE_AUTO) {
- vconf_set_str(WIRELESS_DNS_LAST_MODE, _(TXT_OBTAIN_AUTO));
- }
- else if(m->dns_mode == MODE_MAN) {
- vconf_set_str(WIRELESS_DNS_LAST_MODE, _(TXT_ENTER_MAN));
- }
- break;
- default:
- break;
- }
-}
-
-
-void CIpSettingView::m_SetTheValue(void)
-{
- Evas_Object *btn;
- const char *value1;
- const char *value2;
- const char *value3;
- const char *value4;
- char value[IP_STRING_MAX_SIZE];
-
- value1 = NULL;
- btn = (Evas_Object *) evas_object_data_get(m->config_popup, IP_VALUE1);
- if (btn)
- value1 = elm_object_text_get(btn);
-
- value2 = NULL;
- btn = (Evas_Object *) evas_object_data_get(m->config_popup, IP_VALUE2);
- if (btn)
- value2 = elm_object_text_get(btn);
-
- value3 = NULL;
- btn = (Evas_Object *) evas_object_data_get(m->config_popup, IP_VALUE3);
- if (btn)
- value3 = elm_object_text_get(btn);
-
- value4 = NULL;
- btn = (Evas_Object *) evas_object_data_get(m->config_popup, IP_VALUE4);
- if (btn)
- value4 = elm_object_text_get(btn);
-
- memset(value, 0, IP_STRING_MAX_SIZE);
- snprintf(value, IP_STRING_MAX_SIZE, "%s.%s.%s.%s",
- value1 ? value1 : "\\0", value2 ? value2 : "\\0",
- value3 ? value3 : "\\0", value4 ? value4 : "\\0");
-
- switch (m->cur_type) {
- case SETTING_IP_ADDRESS:
- elm_object_part_text_set(m->ip_addr_btn, PART_VALUE, value);
- strncpy(m->info.ip_addr, value, IP_STRING_MAX_SIZE);
- break;
- case SETTING_SUBNET_MASK:
- elm_object_part_text_set(m->subnet_mask_btn, PART_VALUE, value);
- strncpy(m->info.submask, value, IP_STRING_MAX_SIZE);
- break;
- case SETTING_GATEWAY:
- elm_object_part_text_set(m->gateway_btn, PART_VALUE, value);
- strncpy(m->info.gateway, value, IP_STRING_MAX_SIZE);
- break;
- case SETTING_DNS_SERVER:
- elm_object_part_text_set(m->dns_server_btn, PART_VALUE, value);
- strncpy(m->info.dns, value, IP_STRING_MAX_SIZE);
- break;
- default:
- return;
- }
-
- evas_object_del(m->config_popup);
- m->config_popup = NULL;
-}
-
-
-void CIpSettingView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
-{
- /* ID list */
- /* 0 m->base */
- /* 1 m->dns_mode_btn */
- /* 2 m->dns_setting_btn */
- /* 3 m->ok_btn */
- /* 4 m->cancel_btn */
- /* 5 m->ip_mode_btn */
- /* 6 m->ip_addr_btn */
- /* 7 m->subnet_mask_btn */
- /* 8 m->gateway_btn */
- /* 9 btn_auto */
- /* 10 btn_man */
- /* 11 m->dns_mode_ly */
- /* 12 ctxpopup auto_btn*/
- /* 13 ctxpopup man_btn*/
- /* 14 m->ip_mode_ly */
- /* 15 m->config_popup */
- /* 16 m->cur_ip_btn[0] */
- /* 17 m->cur_ip_btn[1] */
- /* 18 m->cur_ip_btn[2] */
- /* 19 m->cur_ip_btn[3] */
- /* 20 showpopup retry_btn */
- /* 21 showpopup cancel_btn */
- /* 22 showpopup */
- /* 23 showInvalidIpPopup ok_btn */
- /* 24 showInvalidIpPopup layout */
-
-
- if (!ev->keyname) {
- _ERR("ev->keyname is NULL.");
- return;
- }
-
- switch(id) {
- case 0:
- if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
-#if 0
- viewmgr_pop(m->vmgr);
-#endif
- return;
- }
- break;
- case 9:
- case 10:
- case 12:
- case 13:
- if (!strcmp(ev->keyname, KEY_LEFT) || !strcmp(ev->keyname, KEY_RIGHT)) {
- evas_object_hide(m->dim_ly);
- if (m->cur_type == SETTING_IP) {
- evas_object_del(m->ip_mode_ly);
- m->ip_mode_ly = NULL;
- } else if (m->cur_type == SETTING_DNS) {
- evas_object_del(m->dns_mode_ly);
- m->dns_mode_ly = NULL;
- }
- }
- break;
- case 11:
- if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
- evas_object_hide(m->dim_ly);
- evas_object_del(m->dns_mode_ly);
- m->dns_mode_ly = NULL;
- } else if (!strcmp(ev->keyname, KEY_EXIT)) {
- ug_destroy_me(m->ug);
- }
- break;
- case 14:
- if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
- evas_object_hide(m->dim_ly);
- evas_object_del(m->ip_mode_ly);
- m->ip_mode_ly = NULL;
- }
- break;
- case 15:
- if (!strcmp(ev->keyname, KEY_ENTER) || !strcmp(ev->keyname, KEY_ENTER_REMOTE)) {
- evas_object_hide(m->dim_ly);
- m_SetTheValue();
- evas_object_del(obj);
- } else if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
- evas_object_hide(m->dim_ly);
- evas_object_del(obj);
- }
- break;
- case 16:
- case 17:
- case 18:
- case 19:
- const char *value;
- int num, new_num;
-
- if (!strcmp(ev->keyname, KEY_UP)) {
- value = elm_object_text_get(obj);
- num = atoi(value);
- num++;
- if (num > MAX_IP_NUM)
- num = 0;
- } else if (!strcmp(ev->keyname, KEY_DOWN)) {
- value = elm_object_text_get(obj);
- num = atoi(value);
- num--;
- if (num < 0)
- num = MAX_IP_NUM;
- } else if (!strcmp(ev->keyname, KEY_0) ||
- !strcmp(ev->keyname, KEY_1) ||
- !strcmp(ev->keyname, KEY_2) ||
- !strcmp(ev->keyname, KEY_3) ||
- !strcmp(ev->keyname, KEY_4) ||
- !strcmp(ev->keyname, KEY_5) ||
- !strcmp(ev->keyname, KEY_6) ||
- !strcmp(ev->keyname, KEY_7) ||
- !strcmp(ev->keyname, KEY_8) ||
- !strcmp(ev->keyname, KEY_9)) {
- value = elm_object_text_get(obj);
- if (!value)
- elm_object_text_set(obj, ev->keyname);
-
- new_num = atoi(ev->keyname);
-
- num = atoi(value);
- if (!num || (num * RATIO + new_num) > MAX_IP_NUM) {
- elm_object_text_set(obj, ev->keyname);
- return;
- }
-
- num = num * RATIO + new_num;
- } else {
- return;
- }
-
- char temp_value[IP_STRING_MAX_SIZE];
-
- memset(temp_value, 0, IP_STRING_MAX_SIZE);
- snprintf(temp_value, IP_STRING_MAX_SIZE - 1, "%d", num);
- elm_object_text_set(obj, temp_value);
- break;
- case 22:
- case 24:
- if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
- evas_object_hide(m->dim_ly);
- evas_object_del(obj);
- }
- break;
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- default:
- break;
- }
-}
-
-
-void CIpSettingView::OnMouseClicked(int id, Evas_Object *obj)
-{
- /* ID list */
- /* 0 m->base */
- /* 1 m->dns_mode_btn */
- /* 2 m->dns_setting_btn */
- /* 3 m->ok_btn */
- /* 4 m->cancel_btn */
- /* 5 m->ip_mode_btn */
- /* 6 m->ip_addr_btn */
- /* 7 m->subnet_mask_btn */
- /* 8 m->gateway_btn */
- /* 9 btn_auto */
- /* 10 btn_man */
- /* 11 m->dns_mode_ly */
- /* 12 ctxpopup auto_btn*/
- /* 13 ctxpopup man_btn*/
- /* 14 m->ip_mode_ly */
- /* 15 m->config_popup */
- /* 16 m->cur_ip_btn[0] */
- /* 17 m->cur_ip_btn[1] */
- /* 18 m->cur_ip_btn[2] */
- /* 19 m->cur_ip_btn[3] */
- /* 20 showpopup retry_btn */
- /* 21 showpopup cancel_btn */
- /* 22 showpopup */
- /* 23 showInvalidIpPopup ok_btn */
- /* 24 showInvalidIpPopup layout */
-
- switch(id) {
- case 0:
- break;
- case 1:
- {
- Evas_Object *ctxpopup, *box, *btn_auto, *btn_man;
- Evas_Coord x, y, w, h;
- Evas_Object *btn[2];
-
- m->cur_type = SETTING_DNS;
-
- if (m->dns_mode == MODE_INVALID)
- m->dns_mode = MODE_MAN;
-
- ctxpopup = util_add_layout(m->base, UG_NETWORK_EDJ_FILE, GRP_NETWORK_MODE_SETTING);
- if (!ctxpopup) {
- _ERR("elm_layout_add() failed.");
- return;
- }
-
- box = util_add_box(ctxpopup, PART_SWALLOW_CONTENT);
- if (!box) {
- _ERR("add box failed.");
- evas_object_del(ctxpopup);
- return;
- }
-
- elm_box_horizontal_set(box, EINA_FALSE);
-
- btn_auto = util_add_button(m->base, STYLE_MODE_SELECT_BTN, NULL, _(TXT_OBTAIN_AUTO));
- if (!btn_auto) {
- _ERR("Add btn failed.");
- evas_object_del(ctxpopup);
- return;
- }
-#if 0
- evas_object_smart_callback_add(btn_auto, SIG_DISMISSED, _mode_sub_popup_dismissed_cb, data);
-#endif
- //evas_object_smart_callback_add(btn_auto, SIG_CLICKED, _dns_auto_mode_btn_clicked_cb, data);
- //evas_object_event_callback_add(btn_auto, EVAS_CALLBACK_KEY_DOWN, _mode_sub_popup_key_pressed_cb, data);
- Connect(btn_auto, 9);
-
- elm_box_pack_end(box, btn_auto);
- elm_object_focus_set(btn_auto, EINA_TRUE);
- btn[0] = btn_auto;
-
- btn_man = util_add_button(m->base, STYLE_MODE_SELECT_BTN, NULL, _(TXT_ENTER_MAN));
- if (!btn_man) {
- _ERR("Add btn failed.");
- evas_object_del(ctxpopup);
- return;
- }
-#if 0
- evas_object_smart_callback_add(btn, SIG_DISMISSED, _mode_sub_popup_dismissed_cb, data);
-#endif
- //evas_object_smart_callback_add(btn, SIG_CLICKED, _dns_manual_mode_btn_clicked_cb, data);
- //evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, _mode_sub_popup_key_pressed_cb, data);
- Connect(btn_man, 10);
-
- elm_box_pack_end(box, btn_man);
- btn[1] = btn_man;
-
- m_SetupDownCycleFocus(btn, 2);
-#if 0
-
- evas_object_smart_callback_add(ctxpopup, SIG_DISMISSED, _dns_ctxpopup_dismissed_cb, priv);
-#endif
- //evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_KEY_DOWN, _dns_ctxpopup_key_pressed_cb, priv);
- //evas_object_smart_callback_add(ctxpopup, SIG_UNFOCUSED, _ctxpopup_unfocused_cb, priv);
- Connect(ctxpopup, 11);
-
- evas_object_geometry_get(m->dns_mode_btn, &x, &y, &w, &h);
- m->dns_mode_ly = ctxpopup;
-
- evas_object_move(ctxpopup, (x + SETTING_MODE_OFFSET_X) * ELM_SCALE,
- (y + h) * ELM_SCALE);
-
- if (m->dns_mode == MODE_AUTO)
- elm_object_signal_emit(btn_auto, SIG_BTN_SELECTED, PROG);
- else if (m->dns_mode == MODE_MAN)
- elm_object_signal_emit(btn_man, SIG_BTN_SELECTED, PROG);
-
- evas_object_show(m->dim_ly);
-
- m_KeepBtnFocused();
- }
- break;
- case 2:
- m->cur_type = SETTING_DNS_SERVER;
- m_CreateValuePopup();
- break;
- case 3:
- m_ConfigNetwork();
- break;
- case 4:
-#if 0
- if (m->vmgr)
- viewmgr_pop(m->vmgr);
-#endif
- break;
- case 5:
- {
- Evas_Object *ctxpopup, *box, *auto_btn, *man_btn;
- Evas_Coord x, y, w, h;
- Evas_Object *btn[MODE_BTN_NUM];
-
- m->cur_type = SETTING_IP;
-
- if (m->ip_mode == MODE_INVALID)
- m->ip_mode = MODE_MAN;
-
- ctxpopup = util_add_layout(m->base, UG_NETWORK_EDJ_FILE, GRP_NETWORK_MODE_SETTING);
- if (!ctxpopup) {
- _ERR("elm_layout_add() failed.");
- return;
- }
-
- evas_object_show(m->dim_ly);
- m_KeepBtnFocused();
-
- box = util_add_box(ctxpopup, PART_SWALLOW_CONTENT);
- if (!box) {
- _ERR("create box failed.");
- evas_object_del(ctxpopup);
- return;
- }
-
- elm_box_horizontal_set(box, EINA_FALSE);
-
- auto_btn = util_add_button(ctxpopup, STYLE_MODE_SELECT_BTN, NULL, _(TXT_OBTAIN_AUTO));
- if (!auto_btn) {
- _ERR("Add btn failed.");
- evas_object_del(ctxpopup);
- return;
- }
-#if 0
- evas_object_smart_callback_add(auto_btn, SIG_DISMISSED, _mode_sub_popup_dismissed_cb, NULL);
-#endif
- //evas_object_smart_callback_add(auto_btn, SIG_CLICKED, _ip_auto_mode_btn_clicked_cb, NULL);
- //evas_object_event_callback_add(auto_btn, EVAS_CALLBACK_KEY_DOWN, _mode_sub_popup_key_pressed_cb, NULL);
- Connect(auto_btn, 12);
-
- elm_box_pack_end(box, auto_btn);
- elm_object_focus_set(auto_btn, EINA_TRUE);
- btn[0] = auto_btn;
-
- man_btn = util_add_button(ctxpopup, STYLE_MODE_SELECT_BTN, NULL, _(TXT_ENTER_MAN));
- if (!man_btn) {
- _ERR("Add btn failed.");
- evas_object_del(ctxpopup);
- return;
- }
-#if 0
- evas_object_smart_callback_add(man_btn, SIG_DISMISSED, _mode_sub_popup_dismissed_cb, NULL);
-#endif
- //evas_object_smart_callback_add(man_btn, SIG_CLICKED, _ip_manual_mode_btn_clicked_cb, NULL);
- //evas_object_event_callback_add(man_btn, EVAS_CALLBACK_KEY_DOWN, _mode_sub_popup_key_pressed_cb, NULL);
- Connect(man_btn, 13);
-
- elm_box_pack_end(box, man_btn);
- btn[1] = man_btn;
-
- m_SetupDownCycleFocus(btn, 2);
- //evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_KEY_DOWN, _ip_ctxpopup_key_pressed_cb, priv);
- //evas_object_smart_callback_add(ctxpopup, SIG_UNFOCUSED, _ctxpopup_unfocused_cb, priv);
- Connect(man_btn, 14);
-
- m->ip_mode_ly = ctxpopup;
-
- if (m->ip_mode == MODE_AUTO)
- elm_object_signal_emit(auto_btn, SIG_BTN_SELECTED, PROG);
- else if (m->ip_mode == MODE_MAN)
- elm_object_signal_emit(man_btn, SIG_BTN_SELECTED, PROG);
-
- evas_object_geometry_get(m->ip_mode_btn, &x, &y, &w, &h);
- evas_object_move(ctxpopup, (x + SETTING_MODE_OFFSET_X) * ELM_SCALE, (y + h) * ELM_SCALE);
- }
- break;
- case 6:
- m->cur_type = SETTING_IP_ADDRESS;
- m_CreateValuePopup();
- break;
- case 7:
- m->cur_type = SETTING_SUBNET_MASK;
- m_CreateValuePopup();
- break;
- case 8:
- m->cur_type = SETTING_GATEWAY;
- m_CreateValuePopup();
- break;
- case 9:
- elm_object_disabled_set(m->dns_server_btn, EINA_TRUE);
- elm_object_part_text_set(m->dns_mode_btn, PART_VALUE, _(TXT_OBTAIN_AUTO));
- evas_object_del(m->dns_mode_ly);
- m->dns_mode_ly = NULL;
- m->dns_mode = MODE_AUTO;
- evas_object_hide(m->dim_ly);
- break;
- case 10:
- elm_object_disabled_set(m->dns_server_btn, EINA_FALSE);
- elm_object_part_text_set(m->dns_mode_btn, PART_VALUE, _(TXT_ENTER_MAN));
- evas_object_del(m->dns_mode_ly);
- m->dns_mode_ly = NULL;
- m->dns_mode = MODE_MAN;
- evas_object_hide(m->dim_ly);
- break;
- case 11:
- break;
- case 12:
- elm_object_disabled_set(m->ip_addr_btn, EINA_TRUE);
- elm_object_disabled_set(m->subnet_mask_btn, EINA_TRUE);
- elm_object_disabled_set(m->gateway_btn, EINA_TRUE);
-
- if (m->ip_mode_btn)
- elm_object_part_text_set(m->ip_mode_btn, PART_VALUE, _(TXT_OBTAIN_AUTO));
-
- evas_object_del(m->ip_mode_ly);
- m->ip_mode_ly = NULL;
- m->ip_mode = MODE_AUTO;
-
- evas_object_hide(m->dim_ly);
- break;
- case 13:
- elm_object_disabled_set(m->ip_addr_btn, EINA_FALSE);
- elm_object_disabled_set(m->subnet_mask_btn, EINA_FALSE);
- elm_object_disabled_set(m->gateway_btn, EINA_FALSE);
-
- elm_object_part_text_set(m->ip_mode_btn,
- PART_VALUE, _(TXT_ENTER_MAN));
-
- evas_object_del(m->ip_mode_ly);
- m->ip_mode_ly = NULL;
- m->ip_mode = MODE_MAN;
-
- evas_object_hide(m->dim_ly);
- break;
- case 16:
- case 17:
- case 18:
- case 19:
- evas_object_hide(m->dim_ly);
- if (m->confirm_popup)
- evas_object_del(m->confirm_popup);
- break;
- case 20:
- if (m->confirm_popup)
- evas_object_del(m->confirm_popup);
- evas_object_hide(m->dim_ly);
- elm_object_focus_set(m->ok_btn, EINA_TRUE);
- m_ConfigNetwork();
- break;
- case 21:
- case 23:
- if (m->confirm_popup)
- evas_object_del(m->confirm_popup);
- evas_object_hide(m->dim_ly);
- elm_object_focus_set(m->ok_btn, EINA_TRUE);
- break;
- default:
- break;
- }
-}
-
-void CIpSettingView::OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item)
-{
- /* ID list */
- /* 0 m->base */
- /* 1 m->dns_mode_btn */
- /* 2 m->dns_setting_btn */
- /* 3 m->ok_btn */
- /* 4 m->cancel_btn */
- /* 5 m->ip_mode_btn */
- /* 6 m->ip_addr_btn */
- /* 7 m->subnet_mask_btn */
- /* 8 m->gateway_btn */
- /* 9 btn_auto */
- /* 10 btn_man */
- /* 11 m->dns_mode_ly */
- /* 12 ctxpopup auto_btn*/
- /* 13 ctxpopup man_btn*/
- /* 14 m->ip_mode_ly */
- /* 15 m->config_popup */
- /* 16 m->cur_ip_btn[0] */
- /* 17 m->cur_ip_btn[1] */
- /* 18 m->cur_ip_btn[2] */
- /* 19 m->cur_ip_btn[3] */
- /* 20 showpopup retry_btn */
- /* 21 showpopup cancel_btn */
- /* 22 showpopup */
- /* 23 showInvalidIpPopup ok_btn */
- /* 24 showInvalidIpPopup layout */
-
- switch(id) {
- case 11:
- case 14:
- case 15:
- case 22:
- case 24:
- evas_object_hide(m->dim_ly);
- evas_object_del(obj);
- break;
- default:
- break;
- }
-}
-
-
diff --git a/ug/network/src/NetworkMainView.cpp b/ug/network/src/NetworkMainView.cpp
deleted file mode 100644
index e2b3133..0000000
--- a/ug/network/src/NetworkMainView.cpp
+++ /dev/null
@@ -1,1710 +0,0 @@
-#include <AppCommon.h>
-#include "util.h"
-#include "defs.h"
-#include "i18n.h"
-#include "common.h"
-#include <vconf.h>
-#include <ui-gadget-module.h>
-#include "WifiMgr.h"
-#include "NetConMgr.h"
-
-#include "NetworkMainView.h"
-
-static const char *action_button[4] = {
- TXT_CONNECT_BTN,
- TXT_REFRESH_BTN,
- TXT_OTHER_BTN,
- TXT_CLOSE_BTN
-};
-
-static const char *button_swallow[4] = {
- PART_CONNECT_BTN,
- PART_REFRESH_BTN,
- PART_OTHER_BTN,
- PART_CLOSE_BTN
-};
-
-static const char *popup_button[2] = {
- TXT_WIRELESS,
- TXT_WIRED
-};
-
-struct SNetworkMainView {
- ui_gadget_h ug;
-
- Evas_Object *win;
- Evas_Object *base;
- Evas_Object *type_btn;
- Evas_Object *network_ctxpopup;
- Evas_Object *dim_ly;
- Evas_Object *connect_btn;
- Evas_Object *refresh_btn;
- Evas_Object *other_btn;
- Evas_Object *close_btn;
- Evas_Object *genlist;
- Evas_Object *wired_con_box;
- Evas_Object *wireless_discon_ly;
- Evas_Object *wired_discon_ly;
- Evas_Object *status_popup;
-
- Elm_Genlist_Item_Class *lock_ic;
- Elm_Genlist_Item_Class *nolock_ic;
- Elm_Object_Item *last_item;
-
- Eina_List *ap_list;
- Ecore_Timer *timer;
-
- enum network_type_enum network_type;
- enum view_type cur_view;
-
- int wifi_init;
- Eina_Bool wifi_conn;
- Eina_Bool wired_conn;
-
- char profile_name[MAX_NAME_SIZE];
-
- CWifiAp *ap;
- char *ap_name;
- char *ap_pwd;
-
- CWifiMgr *pWifiMgr;
- CNetConMgr *pNetConMgr;
- CViewMgr *pViewMgr;
-
- SNetworkMainView() {
- pHandlerBase = new CHandlerBase(this);
- pHandlerTypeButton = new CHandlerTypeButton(this);
- pHandlerPopupButton = new CHandlerPopupButton(this);
- pHandlerWiredConBox = new CHandlerWiredConBox(this);
- pHandlerActionBtns = new CHandlerActionBtns(this);
- pHandlerConfirmPopup = new CHandlerConfirmPopup(this);
- }
- virtual ~SNetworkMainView() {
- delete pHandlerConfirmPopup;
- delete pHandlerActionBtns;
- delete pHandlerWiredConBox;
- delete pHandlerPopupButton;
- delete pHandlerTypeButton;
- delete pHandlerBase;
- }
-
- class CHandlerBase : public CListenerMgr, public IKeyDownListener {
- private:
- SNetworkMainView *m;
-
- public:
- CHandlerBase(SNetworkMainView *ins) : IKeyDownListener(this) { m = ins; }
-
- virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) {
- _DBG();
- switch (id) {
- case 0:
- if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
- ug_destroy_me(m->ug);
- }
- break;
- case 1:
- if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
- //_unset_layout_dim(priv);
- evas_object_hide(m->dim_ly);
- if (m->network_ctxpopup) {
- evas_object_del(m->network_ctxpopup);
- m->network_ctxpopup = NULL;
- }
- }
- break;
- default:
- break;
- }
- }
- } *pHandlerBase;
-
- class CHandlerTypeButton : public CListenerMgr, IMouseClickedListener {
- private:
- SNetworkMainView *m;
-
- public:
- CHandlerTypeButton(SNetworkMainView *ins) : IMouseClickedListener(this) { m = ins; }
-
- virtual void OnMouseClicked(int id, Evas_Object *obj) {
- _DBG();
- Evas_Object *base = NULL;
- Evas_Object *layout, *box;
- Evas_Object *btn[BTN_TYPE];
- Evas_Coord x;
- Evas_Coord y;
- Evas_Coord w;
- Evas_Coord h;
- int i;
-
- evas_object_show(m->dim_ly);
-
- layout = util_add_layout(base, UG_NETWORK_EDJ_FILE, GRP_NETWORK_TYPE_SELECT);
- if (!layout) {
- _ERR("util_add_layout() failed.");
- return;
- }
-
- box = util_add_box(layout, PART_SWALLOW_CONTENT);
- if (!box) {
- evas_object_del(layout);
- return;
- }
-
- evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0);
-
- for (i = 0; i < BTN_TYPE; i++) {
- btn[i] = util_add_button(box, STYLE_POPUP_BTN, NULL, _(popup_button[i]));
- if (!btn[i]) {
- evas_object_del(layout);
- return;
- }
-
- elm_box_pack_end(box, btn[i]);
-
- //evas_object_smart_callback_add(btn[i], SIG_CLICKED, _type_select_btn_cb, priv);
- m->pHandlerPopupButton->Connect(btn[i],i);
- }
-
- if (m->network_type == TYPE_WIRELESS)
- elm_object_signal_emit(btn[TYPE_WIRELESS], SIG_BTN_SELECTED, PROG);
- else
- elm_object_signal_emit(btn[TYPE_WIRED], SIG_BTN_SELECTED, PROG);
-
- elm_object_part_content_set(layout, PART_SWALLOW_CONTENT, box);
-
- elm_object_focus_next_object_set(btn[1], btn[0], ELM_FOCUS_DOWN);
- elm_object_focus_next_object_set(btn[0], btn[1], ELM_FOCUS_UP);
- elm_object_focus_next_object_set(btn[1], btn[0], ELM_FOCUS_UP);
- elm_object_focus_next_object_set(btn[0], btn[1], ELM_FOCUS_DOWN);
- elm_object_focus_next_object_set(btn[0], btn[0], ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(btn[0], btn[0], ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(btn[1], btn[1], ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(btn[1], btn[1], ELM_FOCUS_RIGHT);
-
- x = 0; y = 0; w = 0; h = 0;
-
- evas_object_geometry_get(m->type_btn, &x, &y, &w, &h);
- evas_object_move(layout, (x + w - TYPE_POPUP_X_OFFSET) * ELM_SCALE, (y + h) * ELM_SCALE);
-
- m->network_ctxpopup = layout;
-
- //evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN, _type_key_pressed_cb, priv);
- m->pHandlerBase->Connect(layout, 1);
-
- elm_object_focus_set(btn[0], EINA_TRUE);
- evas_object_show(layout);
- }
- } *pHandlerTypeButton;
-
- class CHandlerPopupButton : public CListenerMgr, IMouseClickedListener {
- private:
- SNetworkMainView *m;
- public:
- CHandlerPopupButton(SNetworkMainView *ins) : IMouseClickedListener(this) { m = ins; }
-
- virtual void OnMouseClicked(int id, Evas_Object *obj) {
- _DBG();
- const char *value;
-
- value = elm_object_text_get(obj);
- if (!value) {
- _ERR("get text from network type btn is NULL.");
- return;
- }
-
- if ((!strcmp(value, _(popup_button[TYPE_WIRELESS]))) && m->network_type == TYPE_WIRED) {
- m->network_type = TYPE_WIRELESS;
- //m_SetWireless();
- vconf_set_str(SELECTED_NETWORK_TYPE_KEY, TXT_WIRELESS);
- } else if ((!strcmp(value, _(popup_button[TYPE_WIRED]))) && m->network_type == TYPE_WIRELESS) {
- m->network_type = TYPE_WIRED;
- //m_SetWired();
- vconf_set_str(SELECTED_NETWORK_TYPE_KEY, TXT_WIRED);
- }
-
- //m_SetNetTypeBtnText();
-
- if (m->network_ctxpopup) {
- evas_object_del(m->network_ctxpopup);
- m->network_ctxpopup = NULL;
- }
-
- evas_object_hide(m->dim_ly);
- }
- } *pHandlerPopupButton;
-
- class CHandlerWiredConBox : public CListenerMgr, IMouseClickedListener {
- private:
- SNetworkMainView *m;
- public:
- CHandlerWiredConBox(SNetworkMainView *ins) : IMouseClickedListener(this) { m = ins; }
-
- virtual void OnMouseClicked(int id, Evas_Object *obj) {
- _DBG();
- if (m->wired_conn) {
- elm_object_signal_emit(obj, SIG_STATE_UNSELECTED, ELM);
- m->wired_conn = EINA_FALSE;
- elm_object_disabled_set(m->connect_btn, EINA_TRUE);
- elm_object_disabled_set(m->other_btn, EINA_TRUE);
- } else {
- elm_object_signal_emit(obj, SIG_STATE_SELECTED, ELM);
- m->wired_conn = EINA_TRUE;
- elm_object_disabled_set(m->connect_btn, EINA_FALSE);
- elm_object_disabled_set(m->other_btn, EINA_FALSE);
- }
- }
- } *pHandlerWiredConBox;
-
- class CHandlerActionBtns : public CListenerMgr, IMouseClickedListener {
- private:
- SNetworkMainView *m;
- public:
- CHandlerActionBtns(SNetworkMainView *ins) : IMouseClickedListener(this) { m = ins; }
-
- virtual void OnMouseClicked(int id, Evas_Object *obj) {
- _DBG();
- switch (id) {
- case 0: /* CONNECT */
- //m_ConnectNetwork();
- break;
- case 1: /* REFRESH */
- //m_ClearGenlist();
- //m_SetWireless();
- break;
- case 2: /* OTHER */
- struct connection_info info;
-
- m->cur_view = NETWORK_IP_SETTING_VIEW;
-
- info.cur_type = m->network_type;
-
- if (m->network_type == TYPE_WIRED) {
- strncpy(info.name, m->profile_name,
- MAX_NAME_SIZE - 1);
- } else {
- if (!m->ap) {
- _ERR("selected ap is NULL.");
- return;
- }
-
- info.ap = m->ap;
-
- if (m->ap_name)
- strncpy(info.name, m->ap_name,
- MAX_NAME_SIZE - 1);
- }
-
-#if 0
- base = viewmgr_push(m->vmgr, ip_setting_view_vclass_get(), &info);
- if (!base)
- _ERR("add connection layout failed.");
-#endif
- break;
- case 3: /* CLOSE */
- if (m->ug)
- ug_destroy_me(m->ug);
- break;
- default:
- break;
- }
- }
- } *pHandlerActionBtns;
-
- class CHandlerConfirmPopup : public CListenerMgr, IKeyDownListener, IMouseClickedListener, IUnfocusedListener {
- private:
- SNetworkMainView *m;
- public:
- CHandlerConfirmPopup(SNetworkMainView *ins) : IKeyDownListener(this), IMouseClickedListener(this), IUnfocusedListener(this) { m = ins; }
-
- virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) {
- _DBG();
- switch(id) {
- case 0: /* retry_btn */
- break;
- case 1: /* cancel_btn */
- break;
- case 2: /* layout */
- case 5: /* layout of progress popup */
- if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
- evas_object_hide(m->dim_ly);
- evas_object_del(obj);
- }
- break;
- default:
- break;
- }
- }
- virtual void OnMouseClicked(int id, Evas_Object *obj) {
- _DBG();
- switch(id) {
- case 0:
- evas_object_hide(m->dim_ly);
- if (m->status_popup)
- evas_object_del(m->status_popup);
- m->status_popup = NULL;
- //m_ConnectNetwork();
- break;
- case 1:
- case 4: /* cancel_btn of progress popup */
- evas_object_hide(m->dim_ly);
- if (m->status_popup)
- evas_object_del(m->status_popup);
- m->status_popup = NULL;
- elm_object_focus_set(m->connect_btn, EINA_TRUE);
- break;
- case 2:
- break;
- default:
- break;
- }
- }
- virtual void OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item){
- _DBG();
- switch(id) {
- case 0:
- break;
- case 1:
- break;
- case 2:
- case 5: /* layout of progress popup */
- evas_object_hide(m->dim_ly);
- evas_object_del(obj);
- break;
- default:
- break;
- }
- }
- } *pHandlerConfirmPopup;
-};
-
-
-void CNetworkMainView::sm_CbGenlistItemSelected(void *data, Evas_Object *obj, void *ei)
-{
- _DBG();
- struct SNetworkMainView *priv;
- Elm_Object_Item *gen_item;
- struct wifi_ap_info *ap_info;
- int index;
-
- if (!data || !ei) {
- _ERR("Parameter error!");
- return;
- }
-
- priv = (struct SNetworkMainView *) data;
- gen_item = (Elm_Object_Item *) ei;
-
- if (priv->last_item == gen_item) {
- elm_object_item_signal_emit(gen_item, SIG_STATE_UNSELECTED, ELM);
-
- elm_object_disabled_set(priv->connect_btn, EINA_TRUE);
- elm_object_disabled_set(priv->other_btn, EINA_TRUE);
-
- priv->last_item = NULL;
-
- return;
- }
-
- elm_object_item_signal_emit(gen_item, SIG_STATE_SELECTED, ELM);
- if (priv->last_item)
- elm_object_item_signal_emit(priv->last_item, SIG_STATE_UNSELECTED, ELM);
- priv->last_item = gen_item;
-
- elm_object_disabled_set(priv->connect_btn, EINA_FALSE);
- elm_object_disabled_set(priv->other_btn, EINA_FALSE);
-
- index = elm_genlist_item_index_get(priv->last_item);
- if (index < 0) {
- _ERR("the index of item is invalid.");
- return;
- }
-
- ap_info = (struct wifi_ap_info *) eina_list_nth(priv->ap_list, index);
- if (!ap_info) {
- _ERR("ap info is NULL.");
- return;
- }
-
- if (priv->ap_name) {
- free(priv->ap_name);
- priv->ap_name = NULL;
- }
-
- priv->ap_name = strdup(ap_info->essid);
- if (!priv->ap_name) {
- _ERR("ap name gets failed.");
- return;
- }
-
- if (priv->ap) {
- delete priv->ap;
- priv->ap = NULL;
- }
-
- priv->ap = new CWifiAp(ap_info->ap->Handle());
- if (!priv->ap) {
- _ERR("ap clone failed.");
- return;
- }
-
- if (ap_info->secure_type == WIFI_SECURITY_TYPE_NONE) {
- if (priv->ap_pwd) {
- free(priv->ap_pwd);
- priv->ap_pwd = NULL;
- }
- }
-}
-
-
-Eina_Bool CNetworkMainView::sm_CbSelectConnected(void *data)
-{
- _DBG();
- struct SNetworkMainView *priv;
-
- if (!data) {
- _ERR("Parameter error!");
- return ECORE_CALLBACK_CANCEL;
- }
-
- priv = (struct SNetworkMainView *) data;
-
- elm_object_item_signal_emit(priv->last_item, SIG_STATE_SELECTED, ELM);
- elm_object_disabled_set(priv->connect_btn, EINA_FALSE);
- elm_object_disabled_set(priv->other_btn, EINA_FALSE);
-
- priv->timer = NULL;
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-bool CNetworkMainView::sm_CbWifiFoundAP(CWifiAp *ap, void *data)
-{
- CNetworkMainView *root = (CNetworkMainView*)data;
- bool ret = false;
-
- if (root)
- ret = root->m_OnWifiFoundAP(ap);
-
- return ret;
-}
-
-
-bool CNetworkMainView::m_OnWifiFoundAP(CWifiAp *ap)
-{
- bool ret;
- bool state;
- struct wifi_ap_info *ap_info;
- Elm_Object_Item *item;
-
- ret = m->pWifiMgr->IsActivated(&state);
- if (ret != true || state == 0) {
- _ERR("failt to wifi_is_activated");
- return false;
- }
-
- ap_info = new wifi_ap_info;
- if (!ap_info) {
- _ERR("calloc failed");
- return false;
- }
-
- if (!ap->GetEssid(ap_info->essid, sizeof(ap_info->essid))) {
- _ERR("Fail to get info");
- return false;
- }
-
- if (!ap->GetConnectionState(&ap_info->state)) {
- _ERR("Fail to get info");
- return false;
- }
-
- if (!ap->GetSecurityType(&ap_info->secure_type)) {
- _ERR("Fail to get info");
- return false;
- }
-
- ap_info->ap = new CWifiAp(ap->Handle());
- ap_info->user_data = m;
- m->ap_list = eina_list_append(m->ap_list, ap_info);
-
- m_FillContentPart(m->genlist);
-
- if (ap_info->secure_type == WIFI_SECURITY_TYPE_NONE)
- item = elm_genlist_item_append(m->genlist, m->nolock_ic, ap_info, NULL, ELM_GENLIST_ITEM_NONE, sm_CbGenlistItemSelected, m);
- else
- item = elm_genlist_item_append(m->genlist, m->lock_ic, ap_info, NULL, ELM_GENLIST_ITEM_NONE, sm_CbGenlistItemSelected, m);
- if (!item) {
- _ERR("genlist append item failed.");
- return false;
- }
-
- if (ap_info->state == WIFI_CONNECTION_STATE_CONNECTED) {
- m->last_item = item;
- if (m->ap) {
- delete m->ap;
- m->ap = NULL;
- }
-
- m->ap = new CWifiAp(ap->Handle());
- if (!m->ap) {
- _ERR("Fail to clone AP");
- }
-
- m->timer = ecore_timer_add(TIMER_INTERNAL, sm_CbSelectConnected, m);
- if (!m->timer) {
- _ERR("add timer failed.");
- return false;
- }
- }
-
- return false;
-}
-
-
-void CNetworkMainView::sm_CbWifiScanRequest(wifi_error_e err, void *data)
-{
- CNetworkMainView *root = (CNetworkMainView*)data;
- if (root)
- root->m_OnWifiScanRequest(err);
-}
-
-
-void CNetworkMainView::m_OnWifiScanRequest(wifi_error_e err)
-{
- _DBG();
- bool ret = false;
- ret = m->pWifiMgr->FoundAps(sm_CbWifiFoundAP, this);
- if (ret != true) {
- _ERR("wifi_mgr_foreach_found_aps() failed.");
- }
-}
-
-
-void CNetworkMainView::sm_CbConnectionOnlineAsync(bool state, void *data)
-{
- _DBG();
- CNetworkMainView *instance = NULL;
- instance = (CNetworkMainView *) data;
-
- instance->m_OnConnectionOnlineAync(state);
-}
-
-void CNetworkMainView::m_OnConnectionOnlineAync(bool state)
-{
- _DBG();
- if (state != true) {
- _ERR("connection result");
- m_ShowConfirmPopup();
- } else {
- ug_destroy_me(m->ug);
- }
-}
-
-void CNetworkMainView::sm_CbCheckGatewayAsync(bool state, void *data)
-{
- _DBG();
- CNetworkMainView *instance = NULL;
- instance = (CNetworkMainView *) data;
-
- instance->m_OnCheckGatewayAsync(state);
-}
-
-
-void CNetworkMainView::m_OnCheckGatewayAsync(bool state)
-{
- _DBG();
- bool ret;
-
- if (state != true) {
- _ERR("connection disconnected");
- m_ShowConfirmPopup();
- } else {
- ret = m->pNetConMgr->RegisterIpChangedCallback( sm_CbConnectionOnlineAsync, this);
- if (ret != true) {
- _ERR("connection_mgr_get_is_online_async() failed.");
- return;
- }
- }
-}
-
-
-void CNetworkMainView::sm_CbWifiActivated(wifi_error_e err, void *data)
-{
- _DBG();
- CNetworkMainView *instance = NULL;
- instance = (CNetworkMainView *) data;
-
- instance->m_OnWifiActivated(err);
-}
-
-
-void CNetworkMainView::m_OnWifiActivated(wifi_error_e err)
-{
- _DBG();
- bool ret;
-
- if (err != WIFI_ERROR_NONE) {
- _ERR("Wi-Fi Activation Failed! error == %s", CWifiMgr::ErrorMsg(err));
- return;
- }
-
- ret = m->pWifiMgr->Scan(sm_CbWifiScanRequest, this);
- if (ret != true) {
- _ERR("wifi_mgr_scan_request() failed.");
- m_FillContentPart(m->wireless_discon_ly);
- m_SetActionBtnPos();
- return;
- }
-
- m->wifi_conn = EINA_TRUE;
-
- m_SetActionBtnPos();
-
- m_FillContentPart(m->genlist);
-}
-
-
-char* CNetworkMainView::sm_GetApName(void *data, Evas_Object *obj, const char *part)
-{
- _DBG();
- struct wifi_ap_info *ap_info;
-
- if (!data || !obj || !part) {
- _ERR("Parameter error!");
- return NULL;
- }
-
- ap_info = (struct wifi_ap_info *) data;
-
- if (!strcmp(part, PART_ELM_TEXT))
- return strdup(ap_info->essid);
-
- return NULL;
-}
-
-
-void CNetworkMainView::sm_CbEthernetStateChanged(bool state, void *data)
-{
- _DBG();
- if (!data) {
- _ERR("data is NULL.");
- return;
- }
-
- CNetworkMainView *priv = (CNetworkMainView *) data;
-
- priv->m_OnEthernetStateChanged(state);
-}
-
-
-void CNetworkMainView::m_OnEthernetStateChanged(bool state)
-{
- _DBG();
- if (m->network_type != TYPE_WIRED) {
- _ERR("cur network type is wireless, return.");
- return;
- }
-
- if (state == true) { // ethernet connected
- m_FillContentPart(m->wired_con_box);
- } else {
- m_FillContentPart(m->wired_discon_ly);
-
- m->wired_conn = EINA_FALSE;
- }
-
- m_SetActionBtnPos();
-}
-
-
-bool CNetworkMainView::m_InitConnectionMgr()
-{
- _DBG();
- if(!CNetConMgr::Initialize()) {
- _ERR("Fail to init CNetConMgr");
- }
-
- m->pNetConMgr = CNetConMgr::GetInstance();
- if (!m->pNetConMgr) {
- _ERR("Fail to get instance");
- return false;
- }
-
- if(!m->pNetConMgr->GetProfileName(m->profile_name)) {
- _ERR("Fail to get profilename");
- return false;
- }
-
- if(!m->pNetConMgr->RegisterIpChangedCallback( sm_CbEthernetStateChanged, this)) {
- _ERR("register_ethernet_state_cb() failed.");
- return false;
- }
-
- return true;
-}
-
-
-void CNetworkMainView::m_FinalizeConnectionMgr()
-{
- _DBG();
- CNetConMgr::Finalize();
- m->pNetConMgr = NULL;
-}
-
-
-Evas_Object* CNetworkMainView::m_CreateMainLayout()
-{
- _DBG();
- Evas_Object *base;
-
- base = util_add_layout(m->win, UG_NETWORK_EDJ_FILE, GRP_MAIN);
- if (!base) {
- _ERR("Add pannel view failed.");
- return NULL;
- }
-
- //evas_object_event_callback_add(base, EVAS_CALLBACK_KEY_DOWN, _main_ly_key_pressed_cb, priv);
- m->pHandlerBase->Connect(base, 0);
-
- evas_object_show(base);
-
- return base;
-}
-
-
-bool CNetworkMainView::m_CreateUpperLayout()
-{
- _DBG();
- Evas_Object *type_btn;
-
- elm_object_part_text_set(m->base, PART_SELECT_TEXT, _(TXT_NETWORK_DISC));
-
- type_btn = util_add_button(m->base, STYLE_TYPE_BTN, PART_NETWORK_TYPE, _(TXT_TYPE_BTN));
- if (!type_btn)
- return false;
-
- m->pHandlerTypeButton->Connect(m->base);
-
- elm_object_focus_next_object_set(type_btn, type_btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(type_btn, type_btn, ELM_FOCUS_LEFT);
-
- m->type_btn = type_btn;
-
- elm_object_focus_set(type_btn, EINA_TRUE);
-
- m_SetNetTypeBtnText();
-
- return true;
-}
-
-
-bool CNetworkMainView::m_CreateActionBtns()
-{
- _DBG();
- Evas_Object *bt[BTN_ACT];
- int i;
-
- for (i = 0; i < BTN_ACT; i++) {
- bt[i] = util_add_button(m->base, STYLE_ACTION_BTN, button_swallow[i], _(action_button[i]));
- if (!bt[i])
- return false;
- }
-
- m->connect_btn = bt[CONNECT];
- m->refresh_btn = bt[REFRESH];
- m->other_btn = bt[OTHER];
- m->close_btn = bt[CLOSE];
-
- evas_object_hide(m->refresh_btn);
-
- //evas_object_smart_callback_add(bt[CONNECT], SIG_CLICKED, _connect_btn_clicked_cb, priv);
- //evas_object_smart_callback_add(bt[REFRESH], SIG_CLICKED, _refresh_btn_clicked_cb, priv);
- //evas_object_smart_callback_add(bt[OTHER], SIG_CLICKED, _other_btn_clicked_cb, priv);
- //evas_object_smart_callback_add(bt[CLOSE], SIG_CLICKED, _close_btn_clicked_cb, priv);
- m->pHandlerActionBtns->Connect(bt[CONNECT], 0);
- m->pHandlerActionBtns->Connect(bt[REFRESH], 1);
- m->pHandlerActionBtns->Connect(bt[OTHER], 2);
- m->pHandlerActionBtns->Connect(bt[CLOSE], 3);
-
- m_SetActionBtnPos();
-
- return true;
-}
-
-
-void CNetworkMainView::m_DestroyActionBtns()
-{
- _DBG();
- if(m->close_btn) evas_object_del(m->close_btn);
- if(m->other_btn) evas_object_del(m->other_btn);
- if(m->refresh_btn) evas_object_del(m->refresh_btn);
- if(m->connect_btn) evas_object_del(m->connect_btn);
-}
-
-
-bool CNetworkMainView::m_CreateDimLayout()
-{
- _DBG();
- Evas_Object *dim_ly;
-
- dim_ly = util_add_layout(m->win, UG_NETWORK_EDJ_FILE, GRP_DIM_LY);
- if (!dim_ly) {
- _ERR("elm_layout_add() failed.\n");
- return false;
- }
-
- m->dim_ly = dim_ly;
-
- evas_object_hide(m->dim_ly);
-
- return true;
-}
-
-
-void CNetworkMainView::m_SetNetTypeBtnText()
-{
- _DBG();
- switch (m->network_type) {
- case TYPE_WIRELESS:
- elm_object_part_text_set(m->base, PART_CUR_TYPE_TEXT, _(TXT_WIRELESS_NETWORK));
- elm_object_part_text_set(m->type_btn, PART_NETWORK_TYPE_SELECTED, _(TXT_WIRELESS));
- break;
- case TYPE_WIRED:
- elm_object_part_text_set(m->base, PART_CUR_TYPE_TEXT, _(TXT_WIRED_NETWORK));
- elm_object_part_text_set(m->type_btn, PART_NETWORK_TYPE_SELECTED, _(TXT_WIRED));
- break;
- default:
- break;
- }
-}
-
-
-bool CNetworkMainView::m_SetWireless()
-{
- _DBG();
- Evas_Object *obj;
- bool activated;
- bool ret = false;
-
- m_CreateWirelessDisconnectPart();
-
- if (!m->wifi_init) {
- obj = m_CreateGenlistView();
- if (!obj) {
- _ERR("fail to create genlist");
- return false;
- }
-
- ret = CWifiMgr::Initialize();
- if(ret != true) {
- _ERR("Fail to initialize WifiMgr");
- return false;
- }
- m->pWifiMgr = CWifiMgr::GetInstance();
- if(!m->pWifiMgr) {
- _ERR("Fail to get instance");
- return false;
- }
-
- m->wifi_init = 1;
- }
-
- m_ClearGenlist();
-
- activated = EINA_FALSE;
- ret = m->pWifiMgr->IsActivated(&activated);
- if (ret != true) {
- _ERR("the wifi is not activated.");
- return false;
- }
-
- if (activated) {
- if (m->ap) {
- delete m->ap;
- m->ap = NULL;
- }
-
- ret = m->pWifiMgr->Scan(sm_CbWifiScanRequest, this);
- if (ret != true) {
- _ERR("wifi_mgr_scan_request() failed.");
- goto _wireless_finish;
- }
-
- m->wifi_conn = EINA_TRUE;
- } else {
- m->wifi_conn = EINA_FALSE;
-
- ret = m->pWifiMgr->Activate(sm_CbWifiActivated, this);
- if (ret != true)
- _ERR("wifi_mgr_activate() failed.");
- }
-
-_wireless_finish:
- m_FillContentPart(m->wireless_discon_ly);
- m_SetActionBtnPos();
-
- return true;
-}
-
-
-bool CNetworkMainView::m_SetWired()
-{
- _DBG();
- bool plugin;
-
- m_CreateWiredConnectPart();
-
- m_CreateWiredDisconnectPart();
-
- if(!m->pNetConMgr->GetEthernetState(&plugin)) {
- _ERR("connection_mgr_get_ethernet_state() failed.");
- plugin = false;
- }
-
- if (plugin) {
- m_FillContentPart(m->wired_con_box);
- } else {
- m->wired_conn = EINA_FALSE;
- m_FillContentPart(m->wired_discon_ly);
- }
-
- m_SetActionBtnPos();
-
- return true;
-}
-
-
-void CNetworkMainView::m_FillContentPart(Evas_Object *obj)
-{
- _DBG();
- Evas_Object *old_obj;
-
- if (!obj) {
- _ERR("The param is invalid.");
- return;
- }
-
- old_obj = elm_object_part_content_get(m->base, PART_NETLIST_PANNEL);
- if (old_obj == obj) {
- _ERR("PART_NETLIST_PANNEL already filled with this object.");
- return;
- }
-
- if (old_obj) {
- evas_object_hide(old_obj);
- }
-
- elm_object_part_content_unset(m->base, PART_NETLIST_PANNEL);
- elm_object_part_content_set(m->base, PART_NETLIST_PANNEL, obj);
-
- evas_object_show(obj);
-}
-
-
-void CNetworkMainView::m_SetActionBtnPos()
-{
- _DBG();
- Evas_Object *btn;
-
- btn = elm_object_part_content_get(m->base, button_swallow[CONNECT]);
- if (!btn) {
- elm_object_part_content_unset(m->base, button_swallow[CONNECT]);
- elm_object_part_content_set(m->base, button_swallow[CONNECT], m->connect_btn);
- evas_object_show(m->connect_btn);
- }
-
- btn = elm_object_part_content_get(m->base, button_swallow[REFRESH]);
- if (btn) {
- elm_object_part_content_unset(m->base, button_swallow[REFRESH]);
- evas_object_hide(btn);
- }
-
- btn = elm_object_part_content_get(m->base, button_swallow[OTHER]);
- if (btn) {
- elm_object_part_content_unset(m->base, button_swallow[OTHER]);
- evas_object_hide(btn);
- }
-
- btn = elm_object_part_content_get(m->base, button_swallow[CLOSE]);
- if (btn) {
- elm_object_part_content_unset(m->base, button_swallow[CLOSE]);
- evas_object_hide(btn);
- }
-
- if (m->network_type == TYPE_WIRELESS) {
- if (!m->wifi_conn) {
- elm_object_part_content_set(m->base, button_swallow[REFRESH], m->other_btn);
- evas_object_show(m->other_btn);
-
- elm_object_part_content_set(m->base, button_swallow[OTHER], m->close_btn);
- evas_object_show(m->close_btn);
- } else {
- elm_object_part_content_set(m->base, button_swallow[REFRESH], m->refresh_btn);
- evas_object_show(m->refresh_btn);
-
- elm_object_part_content_set(m->base, button_swallow[OTHER], m->other_btn);
- evas_object_show(m->other_btn);
-
- elm_object_part_content_set(m->base, button_swallow[CLOSE], m->close_btn);
- evas_object_show(m->close_btn);
- }
-
- if (m->ap) {
- elm_object_disabled_set(m->other_btn, EINA_FALSE);
- elm_object_disabled_set(m->connect_btn, EINA_FALSE);
- } else {
- elm_object_disabled_set(m->connect_btn, EINA_TRUE);
- elm_object_disabled_set(m->other_btn, EINA_TRUE);
- }
- } else if (m->network_type == TYPE_WIRED) {
- if (!m->wired_conn) {
- elm_object_disabled_set(m->connect_btn, EINA_TRUE);
- elm_object_disabled_set(m->other_btn, EINA_TRUE);
- } else {
- elm_object_disabled_set(m->connect_btn, EINA_FALSE);
- elm_object_disabled_set(m->other_btn, EINA_FALSE);
- }
-
- elm_object_part_content_set(m->base, button_swallow[REFRESH], m->other_btn);
- evas_object_show(m->other_btn);
-
- elm_object_part_content_set(m->base, button_swallow[OTHER], m->close_btn);
- evas_object_show(m->close_btn);
- }
-}
-
-
-void CNetworkMainView::m_CreateWirelessDisconnectPart(void)
-{
- _DBG();
- Evas_Object *disconnect_ly;
-
- if (m->wireless_discon_ly)
- return;
-
- disconnect_ly = util_add_layout(m->base, UG_NETWORK_EDJ_FILE, GRP_WIRELESS_DISCONNECT_LY);
- if (!disconnect_ly) {
- _ERR("call elm_layout_add() failed.");
- return;
- }
-
- elm_object_part_text_set(disconnect_ly, PART_DISCONNECT_TEXT, TXT_NO_NETWORK);
-
- evas_object_hide(disconnect_ly);
-
- m->wireless_discon_ly = disconnect_ly;
-}
-
-
-bool CNetworkMainView::m_CreateWiredConnectPart(void)
-{
- _DBG();
- Evas_Object *box;
- Evas_Object *btn;
-
- box = util_add_box(m->base, NULL);
- if (!box) {
- _ERR("add wired connect box failed.");
- return false;
- }
-
- elm_box_horizontal_set(box, EINA_FALSE);
-
- btn = util_add_button(box, STYLE_WIRED_LIST_BTN, NULL, _(m->profile_name));
- if (!btn) {
- _ERR("elm_button_add failed.");
- evas_object_del(box);
- return false;
- }
-
- evas_object_size_hint_align_set(btn, 0, 0);
- m->pHandlerWiredConBox->Connect(btn);
- if (m->wired_conn)
- elm_object_signal_emit(btn, SIG_STATE_SELECTED, ELM);
- elm_box_pack_end(box, btn);
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT);
- evas_object_hide(box);
-
- m->wired_con_box = box;
-
- return true;
-}
-
-
-bool CNetworkMainView::m_CreateWiredDisconnectPart(void)
-{
- _DBG();
- Evas_Object *disconnect_ly;
-
- disconnect_ly = util_add_layout(m->base, UG_NETWORK_EDJ_FILE, GRP_WIRED_DISCONNECTED_LY);
- if (!disconnect_ly) {
- _ERR("call elm_layout_add() failed.");
- return false;
- }
-
- elm_object_part_text_set(disconnect_ly, PART_DISCONNECT_TEXT, _(TXT_PLUG_CABLE));
-
- evas_object_hide(disconnect_ly);
-
- m->wired_discon_ly = disconnect_ly;
-
- return true;
-}
-
-
-Evas_Object* CNetworkMainView::m_CreateGenlistView(void)
-{
- _DBG();
- Evas_Object *genlist;
-
- Elm_Genlist_Item_Class *ic;
-
- ic = elm_genlist_item_class_new();
- if (!ic) {
- _ERR("elm_genlist_item_class_new() failed.");
- return NULL;
- }
-
- ic->item_style = STYLE_ITEM_LOCK;
- ic->func.text_get = sm_GetApName;
- ic->func.content_get = NULL;
- ic->func.state_get = NULL;
- ic->func.del = NULL;
-
- m->lock_ic = ic;
-
- ic = NULL;
- ic = elm_genlist_item_class_new();
- if (!ic) {
- _ERR("elm_genlist_item_class_new() failed.");
- return NULL;
- }
-
- ic->item_style = STYLE_ITEM_NOLOCK;
- ic->func.text_get = sm_GetApName;
- ic->func.content_get = NULL;
- ic->func.state_get = NULL;
- ic->func.del = NULL;
- if (!ic) {
- _ERR("get item class failed.");
- return NULL;
- }
-
- m->nolock_ic = ic;
-
- genlist = util_add_genlist(m->base);
- if (!genlist) {
- _ERR("util_add_genlist() failed.");
- return NULL;
- }
-
- m->genlist = genlist;
-
- elm_object_focus_next_object_set(genlist, genlist, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(genlist, m->close_btn, ELM_FOCUS_RIGHT);
-
- return genlist;
-}
-
-
-void CNetworkMainView::m_ClearGenlist(void)
-{
- _DBG();
- struct wifi_ap_info *ap;
- void *temp;
-
- elm_genlist_clear(m->genlist);
-
- if (m->ap_list)
- EINA_LIST_FREE(m->ap_list, temp)
- {
- ap = (struct wifi_ap_info *) temp;
- free(ap);
- }
-}
-
-
-void CNetworkMainView::sm_CbWifiConnected(wifi_error_e err, void *data)
-{
- CNetworkMainView *root = (CNetworkMainView*)data;
- if (root)
- root->m_OnWifiConnected(err);
-}
-
-
-void CNetworkMainView::m_OnWifiConnected(wifi_error_e err)
-{
- _DBG();
- if (!m->status_popup)
- return;
-
- if (err != WIFI_ERROR_NONE) {
- _ERR("connect AP failed.");
- m_ShowConfirmPopup();
- return;
- }
-
- ug_destroy_me(m->ug);
-}
-
-
-void CNetworkMainView::m_ConnectNetwork(void)
-{
- _DBG();
- int index;
- bool ret = false;
-
- if (m->network_type == TYPE_WIRELESS) {
- if (m->last_item) {
- index = elm_genlist_item_index_get(m->last_item);
-
- ret = m_WifiConnectAP(index);
- if (ret != true) {
- _ERR("connect ap");
- m_ShowConfirmPopup();
- return;
- }
- }
- } else {
- ret = m_WiredConnectAP();
- if (ret != true) {
- _ERR("connect ap");
- m_ShowConfirmPopup();
- return;
- }
- }
-}
-
-
-bool CNetworkMainView::m_WifiConnectAP(int index)
-{
- _DBG();
- struct wifi_ap_info *ap_info;
- bool ret = false;
-
- if (index < 0) {
- _ERR("Parameter error!");
- return false;
- }
-
- m_ShowProgressPopup();
-
- ap_info = (struct wifi_ap_info *) eina_list_nth(m->ap_list, index);
- if (!ap_info) {
- _ERR("ap info is NULL.");
- return false;
- }
-
- if (m->ap_name) {
- free(m->ap_name);
- m->ap_name = NULL;
- }
-
- m->ap_name = strdup(ap_info->essid);
- if (!m->ap_name) {
- _ERR("ap name gets failed.");
- return false;
- }
-
- if (ap_info->secure_type == WIFI_SECURITY_TYPE_NONE) {
- if (m->ap_pwd) {
- free(m->ap_pwd);
- m->ap_pwd = NULL;
- }
- } else {
- m->cur_view = NETWORK_WIFI_PASSCODE_VIEW;
-#if 0
- //m->pViewMgr->PushView(~~~)
- //viewmgr_push(m->vmgr, wifi_passcode_view_vclass_get(), ap_info);
-#endif
-
- return true;
- }
-
- ret = CWifiAp::ForgetAP();
- if (ret != true) {
- _ERR("forget last ap failed.");
- return false;
- }
-
- if (m->ap_pwd) {
- m->ap->SetPassPhrase(m->ap_pwd);
- if (ret != true) {
- _ERR("wifi_mgr_set_passphrase() failed.");
- return false;
- }
- }
-
- ret = m->ap->Connect(sm_CbWifiConnected, this);
- if (ret != true) {
- _ERR("Fail to connection request.");
- return false;
- }
- return true;
-}
-
-
-bool CNetworkMainView::m_WiredConnectAP()
-{
- _DBG();
- bool ret = false;
-
- m_ShowProgressPopup();
-
- m->pNetConMgr->RefreshEthernetProfile();
- if(!m->pNetConMgr->GetProfileName(m->profile_name)) {
- _ERR("Fail to get profile name");
- return false;
- }
-
- ret = m_ConnectionSetLastNetwork();
- if (ret != true) {
- _ERR("_connection_set_last_network() failed.");
- return ret;
- }
-
- ret = m->pNetConMgr->RegisterIpChangedCallback( sm_CbCheckGatewayAsync, this);
- if (ret != true) {
- _ERR("connection_mgr_get_is_online_async() failed.");
- return false;
- }
-
- return true;
-}
-
-
-bool CNetworkMainView::m_ConnectionSetLastNetwork(void)
-{
- _DBG();
- enum setting_mode ip_mode;
- struct network_info info;
-
- const char *str = NULL;
- str = vconf_get_str(WIRED_IP_LAST_MODE);
- if (str && !strcmp(str, _(TXT_OBTAIN_AUTO)))
- ip_mode = MODE_AUTO;
- else
- ip_mode = MODE_MAN;
-
- bool result = false;
- if (ip_mode == MODE_AUTO) {
- result = m->pNetConMgr->SetIpConfType(CONNECTION_IP_CONFIG_TYPE_DYNAMIC);
- if (result != true) {
- _ERR("connection_mgr_ip_dynamic_config() failed.");
- return false;
- }
- } else {
- m_GetIpInfo(info.ip_addr, WIRED_IP_KEY);
- m_GetIpInfo(info.submask, WIRED_SUBMASK_KEY);
- m_GetIpInfo(info.gateway, WIRED_GATEWAY_KEY);
- m_GetIpInfo(info.dns, WIRED_DNS_KEY);
- }
-
- return true;
-}
-
-
-void CNetworkMainView::m_GetIpInfo(char *des, const char *key)
-{
- _DBG();
- const char *str;
-
- if (!des || !key)
- return;
-
- str = vconf_get_str(key);
- if (!str)
- return;
-
- if (str == '\0' || !strncmp(str, NULL_STRING, IP_STRING_MAX_SIZE))
- strncpy(des, _(ZERO_IP), IP_STRING_MAX_SIZE);
- else
- strncpy(des, str, IP_STRING_MAX_SIZE);
-}
-
-
-void CNetworkMainView::m_ShowConfirmPopup(void)
-{
- _DBG();
- Evas_Object *layout;
- Evas_Object *retry_btn;
- Evas_Object *cancel_btn;
- Evas_Coord w;
- Evas_Coord h;
- char content[CONTENT_TXT_SIZE];
-
- if (m->status_popup) {
- evas_object_hide(m->dim_ly);
- evas_object_del(m->status_popup);
- }
-
- evas_object_show(m->dim_ly);
-
- layout = util_add_layout(m->base, UG_NETWORK_EDJ_FILE, GRP_CONFIRM_LAYOUT);
- if (!layout) {
- _ERR("add layout failed.");
- evas_object_hide(m->dim_ly);
- return;
- }
-
- evas_object_show(layout);
-
- memset(content, 0, CONTENT_TXT_SIZE);
- if (m->network_type == TYPE_WIRED) {
- elm_object_part_text_set(layout, PART_TEXT_TITLE, _(TXT_WIRED_LY));
- snprintf(content, CONTENT_TXT_SIZE - 1, "%s %s", _(TXT_FAILED_CONNECT), _(m->profile_name));
- } else {
- elm_object_part_text_set(layout, PART_TEXT_TITLE, _(TXT_WIRELESS_LY));
- snprintf(content, CONTENT_TXT_SIZE - 1, "%s %s", _(TXT_FAILED_CONNECT), m->ap_name);
- }
-
- elm_object_part_text_set(layout, PART_TEXT_CONTENT, content);
-
- retry_btn = util_add_button(layout, STYLE_SETTING_BTN, PART_RETRY_BTN, _(TXT_RETRY));
- if (!retry_btn) {
- _ERR("util add button failed.");
- evas_object_del(layout);
- evas_object_hide(m->dim_ly);
- return;
- }
-
- cancel_btn = util_add_button(layout, STYLE_SETTING_BTN, PART_CANCEL_BTN, _(TXT_CANCEL));
- if (!cancel_btn) {
- _ERR("util add button failed.");
- evas_object_del(layout);
- evas_object_hide(m->dim_ly);
- return;
- }
-
- elm_object_focus_next_object_set(retry_btn, cancel_btn, ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(cancel_btn, retry_btn, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(cancel_btn, cancel_btn, ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(retry_btn, retry_btn, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(cancel_btn, cancel_btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(retry_btn, retry_btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(cancel_btn, cancel_btn, ELM_FOCUS_DOWN);
- elm_object_focus_next_object_set(retry_btn, retry_btn, ELM_FOCUS_DOWN);
-
- //evas_object_smart_callback_add(retry_btn, SIG_CLICKED, _retry_btn_clicked_cb, priv);
- //evas_object_smart_callback_add(cancel_btn, SIG_CLICKED, _cancel_btn_clicked_cb, priv);
- m->pHandlerConfirmPopup->Connect(retry_btn, 0);
- m->pHandlerConfirmPopup->Connect(cancel_btn, 1);
-
- elm_object_focus_set(retry_btn, EINA_TRUE);
-
- elm_object_focus_allow_set(layout, EINA_TRUE);
- //evas_object_smart_callback_add(layout, SIG_UNFOCUSED, _ctxpopup_unfocused_cb, priv);
- //evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN, _ctxpopup_pressed_cb, priv);
- m->pHandlerConfirmPopup->Connect(layout, 2);
-
- w = DEFAULT_WIN_WIDTH;
- h = DEFAULT_WIN_HEIGHT;
-
- evas_object_move(layout, CENTER_ALIGN * (w - POPUP_WIDTH) * ELM_SCALE, CENTER_ALIGN * (h - POPUP_HEIGHT) * ELM_SCALE);
-
- m->status_popup = layout;
-}
-
-void CNetworkMainView::m_ShowProgressPopup(void)
-{
- _DBG();
- Evas_Object *layout;
- Evas_Object *cancel_btn;
- Evas_Coord w;
- Evas_Coord h;
- char content[CONTENT_TXT_SIZE];
-
- if (m->status_popup) {
- evas_object_hide(m->dim_ly);
- evas_object_del(m->status_popup);
- }
-
- evas_object_show(m->dim_ly);
-
- layout = util_add_layout(m->base, UG_NETWORK_EDJ_FILE, GRP_PROCESSING_LAYOUT);
- if (!layout) {
- _ERR("add layout failed.");
- evas_object_hide(m->dim_ly);
- return;
- }
-
- evas_object_show(layout);
-
- m->status_popup = layout;
-
- memset(content, 0, CONTENT_TXT_SIZE);
- if (m->network_type == TYPE_WIRED) {
- elm_object_part_text_set(layout, PART_TEXT_TITLE, _(TXT_WIRED_LY));
- snprintf(content, CONTENT_TXT_SIZE - 1, "%s %s", _(TXT_CONNECTTING), _(m->profile_name));
- } else {
- elm_object_part_text_set(layout, PART_TEXT_TITLE, _(TXT_WIRELESS_LY));
- snprintf(content, CONTENT_TXT_SIZE - 1, "%s %s", _(TXT_CONNECTTING), m->ap_name);
- }
-
- elm_object_part_text_set(layout, PART_TEXT_CONTENT, content);
-
- cancel_btn = util_add_button(layout, STYLE_SETTING_BTN, PART_CANCEL_BTN, _(TXT_CANCEL));
- if (!cancel_btn) {
- _ERR("util add button failed.");
- evas_object_del(layout);
- evas_object_hide(m->dim_ly);
- return;
- }
-
- evas_object_show(cancel_btn);
-
- elm_object_focus_next_object_set(cancel_btn, cancel_btn, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(cancel_btn, cancel_btn, ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(cancel_btn, cancel_btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(cancel_btn, cancel_btn, ELM_FOCUS_DOWN);
-
- //evas_object_smart_callback_add(cancel_btn, SIG_CLICKED, _cancel_btn_clicked_cb, priv);
- m->pHandlerConfirmPopup->Connect(cancel_btn, 4);
- elm_object_focus_set(cancel_btn, EINA_TRUE);
- elm_object_focus_allow_set(layout, EINA_TRUE);
- //evas_object_smart_callback_add(layout, SIG_UNFOCUSED, _ctxpopup_unfocused_cb, priv);
- //evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN, _ctxpopup_pressed_cb, priv);
- m->pHandlerConfirmPopup->Connect(layout, 5);
-
- w = DEFAULT_WIN_WIDTH;
- h = DEFAULT_WIN_HEIGHT;
-
- evas_object_move(layout, CENTER_ALIGN * (w - POPUP_WIDTH) * ELM_SCALE, CENTER_ALIGN * (h - POPUP_HEIGHT) * ELM_SCALE);
-}
-
-
-void CNetworkMainView::t_OnShow()
-{
- _DBG();
-
- evas_object_show(m->base);
-
- CBaseView::t_OnShow();
-}
-
-
-void CNetworkMainView::t_OnUpdate(void *data)
-{
- _DBG();
-
- evas_object_show(m->base);
-
- switch (m->cur_view) {
- case NETWORK_IP_SETTING_VIEW:
- elm_object_focus_set(m->other_btn, EINA_TRUE);
- break;
- case NETWORK_WIFI_PASSCODE_VIEW:
- elm_object_focus_set(m->connect_btn, EINA_TRUE);
- break;
- default:
- break;
- }
-}
-
-
-void CNetworkMainView::t_OnHide()
-{
- _DBG();
-
- evas_object_hide(m->base);
-
- CBaseView::t_OnHide();
-}
-
-
-bool CNetworkMainView::Create(void *data)
-{
- _DBG();
- ASSERT(!m);
-
- bool ret = false;
-
- _CREATE_BEGIN{
- _CHECK(m = new SNetworkMainView)
- _CHECK(m->win = CViewMgr::GetInstance()->Window())
- _CHECK(m_InitConnectionMgr())
- _CHECK(m->base = m_CreateMainLayout())
- _COMMAND{
- m->ap_list = NULL;
- const char *str = NULL;
- str = vconf_get_str(SELECTED_NETWORK_TYPE_KEY);
- if (str && !strcmp(str, TXT_WIRED))
- m->network_type = TYPE_WIRED;
- else
- m->network_type = TYPE_WIRELESS;
- }
- _CHECK(m_CreateUpperLayout())
- _COMMAND{
- m->wireless_discon_ly = NULL;
-
- if (m->network_type == TYPE_WIRELESS)
- ret = m_SetWireless();
- else if (m->network_type == TYPE_WIRED)
- ret = m_SetWired();
- else
- ret = false;
- }
- _CHECK(ret)
- _CHECK(m_CreateActionBtns())
- _CHECK(m_CreateDimLayout())
-
- _WHEN_SUCCESS{
- m->pViewMgr = CViewMgr::GetInstance();
- }
-
- _CHECK_FAIL{ if(m->dim_ly) evas_object_del(m->dim_ly); }
- _CHECK_FAIL{ m_DestroyActionBtns(); }
- _CHECK_FAIL{ /* ret */
- if (m->lock_ic)
- elm_genlist_item_class_free(m->lock_ic);
- if (m->nolock_ic)
- elm_genlist_item_class_free(m->nolock_ic);
- if (m->ap_list) {
- EINA_LIST_FREE(m->ap_list, data)
- free(data);
- }
- if (m->timer)
- ecore_timer_del(m->timer);
-
- delete m->ap;
-
- free(m->ap_name);
- free(m->ap_pwd);
-
- if(m->pWifiMgr) {
- CWifiMgr::Finalize();
- m->pWifiMgr = NULL;
- }
- }
- _CHECK_FAIL{ /* m_CreateUpperLayout() */ }
- _CHECK_FAIL{ evas_object_del(m->base); }
- _CHECK_FAIL{ m_FinalizeConnectionMgr(); }
- _CHECK_FAIL{ /* m->win = CViewMgr::GetInstance()->Window() */ }
- _CHECK_FAIL{ delete m; m = NULL; }
- } _CREATE_END_AND_CATCH{ return false; }
-
- _DBG("Done");
- return true;
-}
-
-
-void CNetworkMainView::Destroy()
-{
- ASSERT(m);
- _DBG();
-
- CBaseView::Destroy();
- delete m;
- m = NULL;
-}
-
-Evas_Object* CNetworkMainView::Base()
-{
- ASSERT(m);
- _DBG();
-
- return m->base;
-}
-
diff --git a/ug/network/src/WifiPasscodeView.cpp b/ug/network/src/WifiPasscodeView.cpp
deleted file mode 100644
index c71407a..0000000
--- a/ug/network/src/WifiPasscodeView.cpp
+++ /dev/null
@@ -1,584 +0,0 @@
-#include <ui-gadget-module.h>
-#include <cstring>
-#include "defs.h"
-#include <AppCommon.h>
-#include "i18n.h"
-#include "util.h"
-#include "common.h"
-
-#include "WifiMgr.h"
-#include "WifiPasscodeView.h"
-
-#define KEY_PRIV "priv"
-#define KEY_NETWORK_ENTER "Select"
-
-#define AP_NAME_LENTH 256
-
-#define TXT_PASSCODE "Network passcode"
-#define TXT_ENTER_PASSCODE "Enter the network password"
-
-#define STYLE_ENTRY_FOCUS "focus"
-#define STYLE_ENTRY_TXT "DEFAULT='font_size=30 linesize=40'"
-
-struct SWifiPasscodeView {
- ui_gadget_h ug;
-
- Evas_Object *win;
- Evas_Object *base;
- Evas_Object *entry;
- Evas_Object *dim_ly;
- Evas_Object *ctxpopup;
- char ap_name[AP_NAME_LENTH + 1];
- char *ap_pwd;
-
- CWifiMgr *pWifiMgr;
- CViewMgr *pViewMgr;
-};
-
-
-void CWifiPasscodeView::sm_CbWifiConnected(wifi_error_e err, void *data)
-{
- _DBG();
- CWifiPasscodeView *root = (CWifiPasscodeView *)data;
-
- if (root)
- root->m_OnWifiConnected(err);
-}
-
-
-void CWifiPasscodeView::m_OnWifiConnected(wifi_error_e err)
-{
- if (!m->ctxpopup)
- return;
-
- if (err!= WIFI_ERROR_NONE) {
- _ERR("connect AP failed, ret: %s.", CWifiMgr::ErrorMsg(err));
- m_ShowConfirmPopup();
- return;
- }
-
- ug_destroy_me(m->ug);
-}
-
-
-bool CWifiPasscodeView::sm_CbWifiFoundAP(CWifiAp *ap, void *data)
-{
- _DBG();
- CWifiPasscodeView *root = (CWifiPasscodeView *)data;
-
- if (root)
- root->m_OnWifiFoundAP(ap);
-
- return true;
-}
-
-
-void CWifiPasscodeView::m_OnWifiFoundAP(CWifiAp *ap)
-{
- bool ret;
- struct wifi_ap_info ap_info;
-
- ret = ap->GetEssid(ap_info.essid, sizeof(ap_info.essid));
- if(ret != true) {
- _ERR("Fail to get info");
- return ;
- }
- ret = ap->GetConnectionState(&ap_info.state);
- if(ret != true) {
- _ERR("Fail to get info");
- return ;
- }
- ret = ap->GetSecurityType(&ap_info.secure_type);
- if(ret != true) {
- _ERR("Fail to get info");
- return ;
- }
-
- if (!strncmp(m->ap_name, ap_info.essid, AP_NAME_LENTH)) {
- ret = ap->SetPassPhrase(m->ap_pwd);
- if (ret != true) {
- _ERR("wifi_mgr_set_passphrase() failed.");
- m_ShowConfirmPopup();
- return ;
- }
-
- ret = ap->Connect(sm_CbWifiConnected, this);
- if (ret != true) {
- _ERR("Fail to connection request.");
- m_ShowConfirmPopup();
- return ;
- }
- }
- return ;
-}
-
-
-void CWifiPasscodeView::sm_CbWifiScanRequest(wifi_error_e err, void *data)
-{
- CWifiPasscodeView *root = (CWifiPasscodeView *)data;
-
- if (root)
- root->m_OnWifiScanRequest(err, data);
-}
-
-
-void CWifiPasscodeView::m_OnWifiScanRequest(wifi_error_e err, void *data)
-{
- if(err != WIFI_ERROR_NONE)
- _ERR("parameter error = %s", CWifiMgr::ErrorMsg(err));
-
- if(!m->pWifiMgr->FoundAps(sm_CbWifiFoundAP, data)) {
- _ERR("wifi_mgr_foreach_found_aps() failed.");
- m_ShowConfirmPopup();
- return;
- }
-}
-
-
-void CWifiPasscodeView::m_AddEntry(void)
-{
- Evas_Object *entry;
-
- entry = util_add_entry(m->base, STYLE_ENTRY_FOCUS, PART_WIFI_PASSCODE_ENTRY);
- if (!entry) {
- _ERR("util_add_entry failed.");
- evas_object_del(m->base);
- return;
- }
-
- elm_entry_password_set(entry, EINA_TRUE);
- elm_entry_text_style_user_push(entry, STYLE_ENTRY_TXT);
-
- //evas_object_event_callback_add(entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_press_cb, priv);
- Connect(entry, 1);
-
- elm_entry_input_panel_enabled_set(entry, EINA_TRUE);
-
- elm_object_focus_next_object_set(entry, entry, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(entry, entry, ELM_FOCUS_LEFT);
-
- elm_object_focus_set(entry, EINA_TRUE);
-
- m->entry = entry;
-}
-
-
-bool CWifiPasscodeView::m_CreateDimLayout(void)
-{
- Evas_Object *dim_ly;
-
- dim_ly = util_add_layout(m->win, UG_NETWORK_EDJ_FILE, GRP_DIM_LY);
- if (!dim_ly) {
- _ERR("elm_layout_add() failed.");
- return false;
- }
-
- m->dim_ly = dim_ly;
- evas_object_hide(m->dim_ly);
-
- return true;
-}
-
-
-void CWifiPasscodeView::m_ShowInvalidPwdPopup(void)
-{
- Evas_Object *layout;
- Evas_Object *ok_btn;
- Evas_Coord w;
- Evas_Coord h;
- char content[CONTENT_TXT_SIZE];
-
- if (m->ctxpopup) {
- evas_object_del(m->ctxpopup);
- m->ctxpopup = NULL;
- }
-
- evas_object_show(m->dim_ly);
-
- layout = util_add_layout(m->base, UG_NETWORK_EDJ_FILE, GRP_CONFIRM_LAYOUT);
- if (!layout) {
- _ERR("add layout failed.");
- evas_object_hide(m->dim_ly);
- return;
- }
-
- elm_object_part_text_set(layout, PART_TEXT_TITLE, _(TXT_WIRELESS_LY));
-
- memset(content, 0, CONTENT_TXT_SIZE);
- snprintf(content, CONTENT_TXT_SIZE - 1, "%s", _(TXT_INVALID_PWD));
- elm_object_part_text_set(layout, PART_TEXT_CONTENT, content);
-
- ok_btn = util_add_button(layout, STYLE_SETTING_BTN, PART_OK_BTN, _(TXT_OK));
- if (!ok_btn) {
- _ERR("util add button failed.");
- evas_object_del(layout);
- evas_object_hide(m->dim_ly);
- return;
- }
-
- elm_object_focus_next_object_set(ok_btn, ok_btn, ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(ok_btn, ok_btn, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(ok_btn, ok_btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(ok_btn, ok_btn, ELM_FOCUS_DOWN);
- //evas_object_smart_callback_add(ok_btn, SIG_CLICKED, _popup_ok_btn_clicked_cb, priv);
- Connect(ok_btn, 2);
-
- elm_object_focus_set(ok_btn, EINA_TRUE);
-
- elm_object_focus_allow_set(layout, EINA_TRUE);
- //evas_object_smart_callback_add(layout, SIG_UNFOCUSED, _ctxpopup_unfocused_cb, priv);
- //evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN, _ctxpopup_pressed_cb, priv);
- Connect(layout, 3);
-
-
- w = DEFAULT_WIN_WIDTH;
- h = DEFAULT_WIN_HEIGHT;
-
- evas_object_move(layout, CENTER_ALIGN * (w - POPUP_WIDTH) * ELM_SCALE, CENTER_ALIGN * (h - POPUP_HEIGHT) * ELM_SCALE);
-
- m->ctxpopup = layout;
-}
-
-
-bool CWifiPasscodeView::m_WifiConnectAP(void)
-{
- bool ret;
-
- m_ShowProgressPopup();
-
- ret = CWifiAp::ForgetAP();
- if (ret != true) {
- _ERR("forget last ap failed.");
- return false;
- }
-
- ret = m->pWifiMgr->Scan(sm_CbWifiScanRequest, this);
- if (ret != true) {
- _ERR("wifi_mgr_scan_request() failed.");
- return false;
- }
-
- return true;
-}
-
-
-void CWifiPasscodeView::m_ShowProgressPopup(void)
-{
- Evas_Object *layout;
- Evas_Object *cancel_btn;
- Evas_Coord w;
- Evas_Coord h;
- char content[CONTENT_TXT_SIZE];
-
- if (m->ctxpopup) {
- evas_object_del(m->ctxpopup);
- m->ctxpopup = NULL;
- }
-
- evas_object_show(m->dim_ly);
-
- layout = util_add_layout(m->base, UG_NETWORK_EDJ_FILE, GRP_PROCESSING_LAYOUT);
- if (!layout) {
- _ERR("add layout failed.");
- evas_object_hide(m->dim_ly);
- return;
- }
-
- memset(content, 0, CONTENT_TXT_SIZE);
- elm_object_part_text_set(layout, PART_TEXT_TITLE, _(TXT_WIRELESS_LY));
- snprintf(content, CONTENT_TXT_SIZE - 1, "%s %s", _(TXT_CONNECTTING), m->ap_name);
- elm_object_part_text_set(layout, PART_TEXT_CONTENT, content);
-
- cancel_btn = util_add_button(layout, STYLE_SETTING_BTN, PART_CANCEL_BTN, _(TXT_CANCEL));
- if (!cancel_btn) {
- _ERR("util add button failed.");
- evas_object_del(layout);
- evas_object_hide(m->dim_ly);
- return;
- }
-
- elm_object_focus_next_object_set(cancel_btn, cancel_btn, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(cancel_btn, cancel_btn, ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(cancel_btn, cancel_btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(cancel_btn, cancel_btn, ELM_FOCUS_DOWN);
-
- //evas_object_smart_callback_add(cancel_btn, SIG_CLICKED, _cancel_btn_clicked_cb, priv);
- Connect(cancel_btn, 4);
-
- elm_object_focus_set(cancel_btn, EINA_TRUE);
-
- elm_object_focus_allow_set(layout, EINA_TRUE);
- //evas_object_smart_callback_add(layout, SIG_UNFOCUSED, _ctxpopup_unfocused_cb, priv);
- //evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN, _ctxpopup_pressed_cb, priv);
- Connect(layout, 5);
-
- w = DEFAULT_WIN_WIDTH;
- h = DEFAULT_WIN_HEIGHT;
-
- evas_object_move(layout, CENTER_ALIGN * (w - POPUP_WIDTH) * ELM_SCALE, CENTER_ALIGN * (h - POPUP_HEIGHT) * ELM_SCALE);
-
- m->ctxpopup = layout;
-}
-
-
-void CWifiPasscodeView::m_ShowConfirmPopup(void)
-{
- Evas_Object *layout;
- Evas_Object *retry_btn;
- Evas_Object *cancel_btn;
- Evas_Coord w;
- Evas_Coord h;
- char content[CONTENT_TXT_SIZE];
-
- if (m->ctxpopup) {
- evas_object_del(m->ctxpopup);
- m->ctxpopup = NULL;
- }
-
- evas_object_show(m->dim_ly);
-
- layout = util_add_layout(m->base, UG_NETWORK_EDJ_FILE, GRP_CONFIRM_LAYOUT);
- if (!layout) {
- _ERR("add layout failed.");
- evas_object_hide(m->dim_ly);
- return;
- }
-
- memset(content, 0, CONTENT_TXT_SIZE);
- elm_object_part_text_set(layout, PART_TEXT_TITLE, _(TXT_WIRELESS_LY));
- snprintf(content, CONTENT_TXT_SIZE - 1, "%s %s", _(TXT_FAILED_CONNECT), m->ap_name);
-
- elm_object_part_text_set(layout, PART_TEXT_CONTENT, content);
-
- retry_btn = util_add_button(layout, STYLE_SETTING_BTN, PART_RETRY_BTN, _(TXT_RETRY));
- if (!retry_btn) {
- _ERR("util add button failed.");
- evas_object_del(layout);
- evas_object_hide(m->dim_ly);
- return;
- }
-
- cancel_btn = util_add_button(layout, STYLE_SETTING_BTN, PART_CANCEL_BTN, _(TXT_CANCEL));
- if (!cancel_btn) {
- _ERR("util add button failed.");
- evas_object_del(layout);
- evas_object_hide(m->dim_ly);
- return;
- }
-
- elm_object_focus_next_object_set(retry_btn, cancel_btn, ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(cancel_btn, retry_btn, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(cancel_btn, cancel_btn, ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(retry_btn, retry_btn, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(cancel_btn, cancel_btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(retry_btn, retry_btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(cancel_btn, cancel_btn, ELM_FOCUS_DOWN);
- elm_object_focus_next_object_set(retry_btn, retry_btn, ELM_FOCUS_DOWN);
-
- //evas_object_smart_callback_add(retry_btn, SIG_CLICKED, _retry_btn_clicked_cb, priv);
- Connect(retry_btn, 6);
- //evas_object_smart_callback_add(cancel_btn, SIG_CLICKED, _cancel_btn_clicked_cb, priv);
- Connect(cancel_btn, 7);
-
- elm_object_focus_set(retry_btn, EINA_TRUE);
-
- elm_object_focus_allow_set(layout, EINA_TRUE);
- //evas_object_smart_callback_add(layout, SIG_UNFOCUSED, _ctxpopup_unfocused_cb, priv);
- //evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN, _ctxpopup_pressed_cb, priv);
- Connect(layout, 8);
-
- w = DEFAULT_WIN_WIDTH;
- h = DEFAULT_WIN_HEIGHT;
-
- evas_object_move(layout, CENTER_ALIGN * (w - POPUP_WIDTH) * ELM_SCALE, CENTER_ALIGN * (h - POPUP_HEIGHT) * ELM_SCALE);
-
- m->ctxpopup = layout;
-}
-
-
-bool CWifiPasscodeView::Create(void *data)
-{
- _DBG();
- ASSERT(!m);
- struct wifi_ap_info *ap_info = NULL;
-
- if(data)
- ap_info = (struct wifi_ap_info *) data;
-
- _CREATE_BEGIN{
- _CHECK(m = new SWifiPasscodeView)
- _CHECK(m->win = CViewMgr::GetInstance()->Window())
-// _CHECK(m->ug = (ui_gadget_h) data)
- _CHECK(m->base = util_add_layout(m->win, UG_NETWORK_EDJ_FILE, GRP_WIFI_PASSCODE_BASE))
- _COMMAND {
- CWifiMgr::Initialize();
- strncpy(m->ap_name, ap_info->essid, AP_NAME_LENTH);
- }
- _CHECK(m->pWifiMgr = CWifiMgr::GetInstance())
-
- _WHEN_SUCCESS{
- //evas_object_event_callback_add(base, EVAS_CALLBACK_KEY_DOWN, _base_key_press_cb, priv);
- Connect(m->base, 0);
-
- elm_object_part_text_set(m->base, PART_WIFI_PASSCODE_TITLE, _(TXT_PASSCODE));
- elm_object_part_text_set(m->base, PART_WIFI_PASSCODE_TEXT, _(TXT_ENTER_PASSCODE));
- elm_object_part_text_set(m->base, PART_WIFI_PASSCODE_AP_NAME, m->ap_name);
-
- m_AddEntry();
- m_CreateDimLayout();
- m->pViewMgr = CViewMgr::GetInstance();
- }
-
- _CHECK_FAIL{ /*m->pWifiMgr = CWifiMgr::GetInstance() */ }
- _CHECK_FAIL{ evas_object_del(m->base); }
-// _CHECK_FAIL{ /* m->ug = (ui_gadget_h) data */ }
- _CHECK_FAIL{ /* m->win = CViewMgr::GetInstance()->Window() */ }
- _CHECK_FAIL{ delete m; m = NULL; }
- } _CREATE_END_AND_CATCH{ return false; }
-
- return true;
-}
-
-
-void CWifiPasscodeView::Destroy(void)
-{
- ASSERT(m);
- _DBG();
-
- if (m->dim_ly)
- evas_object_del(m->dim_ly);
-
- if(m->ap_pwd)
- delete (m->ap_pwd);
-
- CBaseView::Destroy();
- delete m;
- m = NULL;
-}
-
-
-Evas_Object* CWifiPasscodeView::Base(void)
-{
- ASSERT(m);
- _DBG();
-
- return m->base;
-}
-
-
-void CWifiPasscodeView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
-{
- /* ID list */
- /* 0 m->base */
- /* 1 entry */
- /* 2 invalidpwdpopup ok_btn */
- /* 3 invalidpwdpopup layout */
- /* 4 showprogresspopup cancel_btn */
- /* 5 showprogresspopup layout */
- /* 6 showconfirmpopup retry_btn */
- /* 7 showconfirmpopup cancel_btn */
- /* 8 showconfirmpopup layout */
-
- if (!ev->keyname) {
- _ERR("ev->keyname is NULL.");
- return;
- }
-
- switch(id) {
- case 0:
-#if 0
- if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE))
- viewmgr_pop(m->vmgr);
-#endif
- break;
- case 1:
- if (!strcmp(ev->keyname, KEY_NETWORK_ENTER)) {
- if (m->ap_pwd) {
- free(m->ap_pwd);
- m->ap_pwd = NULL;
- }
-
- m->ap_pwd = strdup(elm_entry_entry_get(obj));
- if (!m->ap_pwd) {
- _ERR("the passcode in entry is NULL.");
- m_ShowInvalidPwdPopup();
- return;
- }
-
- if(m_WifiConnectAP()) {
- _ERR("connect ap");
- m_ShowConfirmPopup();
- return;
- }
- }
- break;
- case 3:
- case 5:
- case 8:
- if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
- evas_object_hide(m->dim_ly);
- evas_object_del(obj);
- elm_object_focus_set(m->entry, EINA_TRUE);
- }
- break;
- default:
- break;
- }
-}
-
-
-void CWifiPasscodeView::OnMouseClicked(int id, Evas_Object *obj)
-{
- switch(id) {
- case 2:
- if (m->ctxpopup) {
- evas_object_del(m->ctxpopup);
- m->ctxpopup = NULL;
- }
- elm_object_focus_set(m->entry, EINA_TRUE);
- break;
- case 4:
- case 7:
- if (m->ctxpopup) {
- evas_object_del(m->ctxpopup);
- m->ctxpopup = NULL;
- }
-
- evas_object_hide(m->dim_ly);
-
- elm_object_focus_set(m->entry, EINA_TRUE);
- break;
- case 6:
- if (m->ctxpopup) {
- evas_object_del(m->ctxpopup);
- m->ctxpopup = NULL;
- }
-
- evas_object_hide(m->dim_ly);
-
- if(!m_WifiConnectAP()) {
- _ERR("connect ap");
- m_ShowConfirmPopup();
- return;
- }
- break;
- default:
- break;
- }
-}
-
-void CWifiPasscodeView::OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item)
-{
- switch(id) {
- case 3:
- case 5:
- case 8:
- evas_object_hide(m->dim_ly);
- evas_object_del(obj);
- break;
- default:
- break;
- }
-
-
-}
diff --git a/ug/network/src/connection_mgr.c b/ug/network/src/connection_mgr.c
new file mode 100644
index 0000000..0c54513
--- /dev/null
+++ b/ug/network/src/connection_mgr.c
@@ -0,0 +1,650 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <Elementary.h>
+#include <aul.h>
+#include "defs.h"
+#include "dbg.h"
+#include "connection_mgr.h"
+
+/**
+ * Converts the error type to string information.
+ *
+ * @param[in] err_type Error type
+ * @return error string information;
+ */
+static const char *_convert_error_to_string(connection_error_e err_type)
+{
+ _DBG("Not Yet");
+#if 0
+ switch (err_type) {
+ case CONNECTION_ERROR_NONE:
+ return "NONE";
+ case CONNECTION_ERROR_INVALID_PARAMETER:
+ return "INVALID_PARAMETER";
+ case CONNECTION_ERROR_OUT_OF_MEMORY:
+ return "OUT_OF_MEMORY";
+ case CONNECTION_ERROR_INVALID_OPERATION:
+ return "INVALID_OPERATION";
+ case CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
+ return "ADDRESS_FAMILY_NOT_SUPPORTED";
+ case CONNECTION_ERROR_OPERATION_FAILED:
+ return "OPERATION_FAILED";
+ case CONNECTION_ERROR_ITERATOR_END:
+ return "ITERATOR_END";
+ case CONNECTION_ERROR_NO_CONNECTION:
+ return "NO_CONNECTION";
+ case CONNECTION_ERROR_NOW_IN_PROGRESS:
+ return "NOW_IN_PROGRESS";
+ case CONNECTION_ERROR_ALREADY_EXISTS:
+ return "ALREADY_EXISTS";
+ case CONNECTION_ERROR_OPERATION_ABORTED:
+ return "OPERATION_ABORTED";
+ case CONNECTION_ERROR_DHCP_FAILED:
+ return "DHCP_FAILED";
+ case CONNECTION_ERROR_INVALID_KEY:
+ return "INVALID_KEY";
+ case CONNECTION_ERROR_NO_REPLY:
+ return "NO_REPLY";
+ case CONNECTION_ERROR_NO_KEYWORD:
+ return "NO_KEYWORD";
+ case CONNECTION_ERROR_TCP_RST:
+ return "RST_IN_TCP_RESPONSE";
+ case CONNECTION_ERROR_TCP_SYN_TIMEOUT:
+ return "TCP_SYN_TIMEOUT";
+ case CONNECTION_ERROR_OFFLINE:
+ return "CONNECTION_OFFLINE";
+ case CONNECTION_ERROR_NETWORK_MONITOR_FAILURE:
+ return "monitor failer";
+ case CONNECTION_ERROR_INVALID_GATEWAY:
+ return "invalid gateway";
+ case CONNECTION_ERROR_INVALID_MACADDRESS:
+ return "invalid mac addr";
+ default:
+ break;
+ }
+#endif
+
+ return "Unknown";
+}
+
+/**
+ * Creates a handle for managing data connections.
+ *
+ * The handle must be released with connection_destroy().
+ *
+ * @return connetcion if the operation is successful; NULL if failed;
+ */
+connection_h connection_mgr_create(void)
+{
+ int ret;
+ connection_h connection;
+
+ connection = NULL;
+ ret = connection_create(&connection);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_create failed");
+ connection = NULL;
+ }
+
+ return connection;
+}
+
+/**
+ * Destroys the connection handle.
+ *
+ * @param[in] connection The handle of the connection
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int connection_mgr_destroy(connection_h connection)
+{
+ int ret;
+
+ if (!connection) {
+ _ERR("connection is NULL.");
+ return RET_FAILED;
+ }
+
+ ret = connection_destroy(connection);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_destroy() failed.");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets the ethernet profile information.
+ *
+ * Iterates all the profile in the connection, and gets the ethernet one.
+ *
+ * @param[in] connection The handle of the connection
+ * @param[out] info The structure to store profile information
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int connection_mgr_get_profile_info(
+ connection_h connection, struct connection_info *info)
+{
+ connection_profile_iterator_h iter;
+ connection_profile_h profile;
+ connection_profile_type_e type;
+ char *name;
+ int ret;
+
+ if (!info || !connection) {
+ _ERR("param is NULL.");
+ return RET_FAILED;
+ }
+
+ ret = connection_get_profile_iterator(connection,
+ CONNECTION_ITERATOR_TYPE_REGISTERED, &iter);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("Fail to get profile iterator [%d]\n", ret);
+ return RET_FAILED;
+ }
+
+ while (connection_profile_iterator_has_next(iter)) {
+ profile = NULL;
+ if (connection_profile_iterator_next(iter,
+ &profile) != CONNECTION_ERROR_NONE) {
+ _ERR("Fail to get profile handle\n");
+ return RET_FAILED;
+ }
+
+ if (!profile) {
+ _ERR("get profile failed.");
+ return RET_FAILED;
+ }
+
+ if (connection_profile_get_type(profile,
+ &type) != CONNECTION_ERROR_NONE) {
+ _ERR("Fail to get profile type\n");
+ return RET_FAILED;
+ }
+
+ name = NULL;
+ if (connection_profile_get_name(profile,
+ &name) != CONNECTION_ERROR_NONE) {
+ _ERR("Fail to get profile name\n");
+ return RET_FAILED;
+ }
+
+ if (!name) {
+ _ERR("get name failed.");
+ return RET_FAILED;
+ }
+
+ if (type == CONNECTION_PROFILE_TYPE_ETHERNET) {
+ strncpy(info->name, name, MAX_NAME_SIZE - 1);
+ info->profile = profile;
+ }
+
+ free(name);
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Registers the callback called when the state of profile is changed.
+ *
+ * If the state of profile is changed, the registered callback will be called.
+ *
+ * @param[in] profile The handle of the profile
+ * @param[in] cb The callback function to be called
+ * @param[in] data User data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+#if 0
+int connection_mgr_set_profile_state_changed_cb(
+ connection_profile_h profile,
+ connection_profile_state_changed_cb cb, void *data)
+{
+ int ret;
+
+ if (!profile || !cb || !data) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ret = connection_profile_set_state_changed_cb(profile,
+ cb, data);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_profile_set_state_changed_cb() failed.");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+#endif
+
+/**
+ * Gets the state of the connection.
+ *
+ * @param[in] connection The handle of the connection
+ * @return EINA_TRUE if the connection is OK; EINA_FALSE otherwise;
+ */
+Eina_Bool connection_mgr_is_connected(connection_h connection)
+{
+ int ret;
+ connection_ethernet_state_e state;
+
+ if (!connection) {
+ _ERR("the connection is NULL.");
+ return EINA_FALSE;
+ }
+
+ ret = connection_get_ethernet_state(connection, &state);
+ if (ret == CONNECTION_ERROR_NONE &&
+ state == CONNECTION_ETHERNET_STATE_CONNECTED)
+ return EINA_TRUE;
+
+ return EINA_FALSE;
+}
+
+/**
+ * Sets the profile information.
+ *
+ * Sets the network information to profile.
+ *
+ * @param[in] connection The handle of the connection
+ * @param[in] profile The handle of the profile
+ * @param[in] info Network information
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int connection_mgr_set_profile(connection_h connection,
+ connection_profile_h profile,
+ struct network_info *info)
+{
+ int ret;
+
+ if (!connection || !profile || !info) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ret = connection_update_profile(connection, profile);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_update_profile failed.\n");
+ return RET_FAILED;
+ }
+
+ ret = connection_profile_set_ip_config_type(profile,
+ CONNECTION_ADDRESS_FAMILY_IPV4,
+ CONNECTION_IP_CONFIG_TYPE_STATIC);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_profile_set_ip_config_type() failed.");
+ return RET_FAILED;
+ }
+
+ ret = connection_profile_set_ip_address(profile,
+ CONNECTION_ADDRESS_FAMILY_IPV4,
+ info->ip_addr);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_profile_set_ip_address() failed.");
+ return RET_FAILED;
+ }
+
+ ret = connection_profile_set_subnet_mask(profile,
+ CONNECTION_ADDRESS_FAMILY_IPV4,
+ info->submask);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("fail to set_subnet_mask %d\n" , ret);
+ return RET_FAILED;
+ }
+
+ ret = connection_profile_set_gateway_address(profile,
+ CONNECTION_ADDRESS_FAMILY_IPV4,
+ info->gateway);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("fail to set_gateway_address %d\n" , ret);
+ return RET_FAILED;
+ }
+
+ ret = connection_profile_set_dns_address(profile, 1,
+ CONNECTION_ADDRESS_FAMILY_IPV4,
+ info->dns);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("fail to set_dns_address %d\n" , ret);
+ return RET_FAILED;
+ }
+
+ ret = connection_update_profile(connection, profile);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_update_profile failed.\n");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets whether the profile can access to the internet asynchronously.
+ *
+ * The result will return in the registered callback.
+ *
+ * @param[in] connection The handle of the connection
+ * @param[in] cb The callback function to be called
+ * @param[in] data User data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+#if 0
+int connection_mgr_get_is_online_async(
+ connection_h connection,
+ connection_is_online_async_cb cb, void *data)
+{
+ int ret;
+
+ if (!connection || !cb || !data) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ret = connection_get_is_online_async(connection, cb, data);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_get_is_online_async() failed.");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+#endif
+
+/**
+ * Validates gateway address set for Ethernet Asynchronusly.
+ *
+ * The result will return in the registered callback.
+ *
+ * @param[in] profile The handle of the profile
+ * @param[in] cb The callback function to be called
+ * @param[in] data User data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+#if 0
+int connection_mgr_check_gateway_async(
+ connection_profile_h profile,
+ connection_profile_check_gateway_async_cb cb, void *data)
+{
+ int ret;
+
+ if (!profile || !cb || !data) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ret = connection_profile_check_gateway_async(profile, cb, data);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_get_is_online_async() failed.");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+#endif
+
+/**
+ * Sets the IP config type into dynamic.
+ *
+ * Called when the profile need getting IP dynamically.
+ *
+ * @param[in] connection The handle of the connection
+ * @param[in] profile The handle of the profile
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int connection_mgr_ip_dynamic_config(
+ connection_h connection,
+ connection_profile_h profile)
+{
+ int ret;
+
+ if (!connection || !profile) {
+ _ERR("The param is invalid.\n");
+ return RET_FAILED;
+ }
+
+ ret = connection_update_profile(connection, profile);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_update_profile failed, ret: %s.\n",
+ _convert_error_to_string(ret));
+ return RET_FAILED;
+ }
+
+ ret = connection_profile_set_ip_config_type(profile,
+ CONNECTION_ADDRESS_FAMILY_IPV4,
+ CONNECTION_IP_CONFIG_TYPE_DYNAMIC);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("Fail to set ip method type[%s]\n",
+ _convert_error_to_string(ret));
+ return RET_FAILED;
+ }
+
+ ret = connection_update_profile(connection, profile);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_update_profile failed, ret: %s.\n",
+ _convert_error_to_string(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Registers callback for ethernet cable.
+ *
+ * Including cable plugged [in/out] event.
+ *
+ * @param[in] connection The handle of the connection
+ * @param[in] cb The callback function to be called
+ * @param[in] data User data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+#if 0
+int connection_mgr_register_ethernet_state_cb(
+ connection_h connection,
+ connection_ethernet_state_chaged_cb cb, void *data)
+{
+ int ret;
+
+ if (!connection || !cb || !data) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ret = connection_set_ethernet_state_chaged_cb(connection, cb, data);
+ if (ret != RET_SUCCESS) {
+ _ERR("connection_set_ethernet_state_chaged_cb() failed.");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+#endif
+
+/**
+ * Gets the state of ethernet.
+ *
+ * The returned state is for the ethernet connection state.
+ *
+ * @param[in] connection The handle of the connection
+ * @param[out] plugin The cable plugged state
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int connection_mgr_get_ethernet_state(
+ connection_h connection, Eina_Bool *plugin)
+{
+ int ret;
+ connection_ethernet_state_e state;
+
+ if (!connection || !plugin) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ret = connection_get_ethernet_state(connection, &state);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_get_ethernet_state() failed.");
+ return RET_FAILED;
+ }
+
+ if (state == CONNECTION_ETHERNET_STATE_DEACTIVATED)
+ *plugin = EINA_FALSE;
+ else
+ *plugin = EINA_TRUE;
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets the network information.
+ *
+ * Including IP, submask and gateway.
+ *
+ * @param[in] profile The handle of the profile
+ * @param[in] info The structure of network
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int connection_mgr_set_ip_config(
+ connection_profile_h profile,
+ struct network_info *info)
+{
+ int ret;
+
+ if (!profile || !info) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ret = connection_profile_set_ip_address(profile,
+ CONNECTION_ADDRESS_FAMILY_IPV4,
+ info->ip_addr);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("set ip address fail, ret: %s\n",
+ _convert_error_to_string(ret));
+ return RET_FAILED;
+ }
+
+ ret = connection_profile_set_subnet_mask(profile,
+ CONNECTION_ADDRESS_FAMILY_IPV4,
+ info->submask);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("set subnet mask fail. %s\n",
+ _convert_error_to_string(ret));
+ return RET_FAILED;
+ }
+
+ ret = connection_profile_set_gateway_address(profile,
+ CONNECTION_ADDRESS_FAMILY_IPV4,
+ info->gateway);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("set gateway address fail %s\n",
+ _convert_error_to_string(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets the DNS.
+ *
+ * @param[in] profile The handle of the profile
+ * @param[in] info The structure of network
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int connection_mgr_set_dns_config(
+ connection_profile_h profile,
+ struct network_info *info)
+{
+ int ret;
+
+ if (!profile || !info) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ret = connection_profile_set_dns_address(profile, 1,
+ CONNECTION_ADDRESS_FAMILY_IPV4,
+ info->dns);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("set dns address fail %d\n",
+ _convert_error_to_string(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets the network information.
+ *
+ * @param[in] profile The handle of the profile
+ * @param[out] info The structure of network
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int connection_mgr_get_ip_info(
+ connection_profile_h profile,
+ struct network_info *info)
+{
+ char *str_value;
+
+ if (!profile || !info) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ if (connection_profile_get_ip_address(profile,
+ CONNECTION_ADDRESS_FAMILY_IPV4,
+ &str_value) != CONNECTION_ERROR_NONE) {
+ _ERR("Fail to get IP address!\n");
+ strncpy(info->ip_addr, ZERO_IP, IP_STRING_MAX_SIZE);
+ } else {
+ strncpy(info->ip_addr, str_value, IP_STRING_MAX_SIZE);
+ free(str_value);
+ }
+
+ if (connection_profile_get_subnet_mask(profile,
+ CONNECTION_ADDRESS_FAMILY_IPV4,
+ &str_value) != CONNECTION_ERROR_NONE) {
+ _ERR("Fail to get subnet mask!\n");
+ strncpy(info->submask, ZERO_IP, IP_STRING_MAX_SIZE);
+ } else {
+ strncpy(info->submask, str_value, IP_STRING_MAX_SIZE);
+ free(str_value);
+ }
+
+ if (connection_profile_get_gateway_address(profile,
+ CONNECTION_ADDRESS_FAMILY_IPV4,
+ &str_value) != CONNECTION_ERROR_NONE) {
+ _ERR("Fail to get gateway!\n");
+ strncpy(info->gateway, ZERO_IP, IP_STRING_MAX_SIZE);
+ } else {
+ strncpy(info->gateway, str_value, IP_STRING_MAX_SIZE);
+ free(str_value);
+ }
+
+ if (connection_profile_get_dns_address(profile, 1,
+ CONNECTION_ADDRESS_FAMILY_IPV4,
+ &str_value) != CONNECTION_ERROR_NONE) {
+ _ERR("Fail to get DNS1!\n");
+ strncpy(info->dns, ZERO_IP, IP_STRING_MAX_SIZE);
+ } else {
+ strncpy(info->dns, str_value, IP_STRING_MAX_SIZE);
+ free(str_value);
+ }
+
+ return RET_SUCCESS;
+}
diff --git a/ug/network/src/ip_setting_view.c b/ug/network/src/ip_setting_view.c
new file mode 100644
index 0000000..b02258b
--- /dev/null
+++ b/ug/network/src/ip_setting_view.c
@@ -0,0 +1,2629 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <Elementary.h>
+#include <aul.h>
+#include <ui-gadget-module.h>
+#include <net_connection.h>
+
+#include <KeyDefine.h>
+
+#include "defs.h"
+#include "dbg.h"
+#include "ip_setting_view.h"
+#include "vconf_mgr.h"
+#include "i18n.h"
+#include "util.h"
+#include "common.h"
+#include "util.h"
+#include "wifi_mgr.h"
+
+#define KEY_PRIV "priv"
+
+#define MODE_BTN_NUM 2
+#define MAX_IP_NUM 255
+#define IP_SET_MAX_NUM 4
+#define STRING_MAX_SIZE 50
+#define SETTING_MODE_OFFSET_X 448
+#define SETTING_MODE_OFFSET_Y 0
+#define SETTING_VALUE_OFFSET_X 162
+#define SETTING_VALUE_OFFSET_Y 20
+#define CENTER_ALIGN 0.5
+#define BOX_PAD_X 0
+#define BOX_PAD_Y 2
+#define RATIO 10
+
+#define IP_VALUE1 "value1"
+#define IP_VALUE2 "value2"
+#define IP_VALUE3 "value3"
+#define IP_VALUE4 "value4"
+
+#define TXT_MAKE_OTHER_NETWORK _("You can make other network"\
+ "<br>Enter the IP address to use.")
+
+enum connection_setting_enum {
+ SETTING_INVALID,
+ SETTING_IP,
+ SETTING_IP_ADDRESS,
+ SETTING_SUBNET_MASK,
+ SETTING_GATEWAY,
+ SETTING_DNS,
+ SETTING_DNS_SERVER
+};
+
+struct _priv {
+ Evas_Object *win;
+ ui_gadget_h ug;
+ struct viewmgr *vmgr;
+
+ Evas_Object *base;
+ Evas_Object *dim_ly;
+ Evas_Object *ip_mode_btn;
+ Evas_Object *ip_addr_btn;
+ Evas_Object *subnet_mask_btn;
+ Evas_Object *gateway_btn;
+ Evas_Object *dns_mode_btn;
+ Evas_Object *dns_server_btn;
+ Evas_Object *ip_mode_ly;
+ Evas_Object *dns_mode_ly;
+ Evas_Object *config_popup;
+ Evas_Object *cur_ip_btn[IP_SET_MAX_NUM];
+ Evas_Object *confirm_popup;
+ Evas_Object *ok_btn;
+ Evas_Object *cancel_btn;
+
+ struct network_info info;
+ enum setting_mode ip_mode;
+ enum setting_mode dns_mode;
+
+ enum connection_setting_enum cur_type;
+ enum network_type_enum network_type;
+
+ connection_h connection;
+ connection_profile_h profile;
+
+ wifi_ap_h ap;
+
+ char name[MAX_NAME_SIZE];
+};
+
+static void _show_confirm_popup(struct _priv *priv);
+static void _popup_dismissed_cb(void *data, Evas_Object *obj, void *ev);
+
+/**
+ * Initializes the private data.
+ *
+ * Called when the view is loaded.
+ *
+ * @return the handler of the private data;
+ */
+static struct _priv *_init_priv()
+{
+ struct _priv *priv;
+
+ priv = calloc(1, sizeof(*priv));
+
+ return priv;
+}
+
+/**
+ * Deinitializes the private data.
+ *
+ * Called when the view is deleted.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _fini_priv(struct _priv *priv)
+{
+ if (!priv)
+ return;
+
+ if (priv->dim_ly)
+ evas_object_del(priv->dim_ly);
+
+ free(priv);
+}
+
+/**
+ * Sets the cycle focus in the direction of up and down.
+ *
+ * Sets the cycle focus for an array of objects.
+ *
+ * @param[in] obj The handler of objects
+ * @param[in] count The count of objects
+ */
+static void _set_up_down_cycle_focus(Evas_Object **obj,
+ int count)
+{
+ int i;
+
+ if (!*obj || !obj)
+ return;
+
+ for (i = 0; i < count; i++) {
+ if (i == count - 1)
+ elm_object_focus_next_object_set(obj[i], obj[0],
+ ELM_FOCUS_DOWN);
+ else
+ elm_object_focus_next_object_set(obj[i], obj[i + 1],
+ ELM_FOCUS_DOWN);
+
+ if (i == 0)
+ elm_object_focus_next_object_set(obj[i], obj[count - 1],
+ ELM_FOCUS_UP);
+ else
+ elm_object_focus_next_object_set(obj[i], obj[i - 1],
+ ELM_FOCUS_UP);
+ }
+}
+
+/**
+ * Creates the basic layout of the view.
+ *
+ * @param[in] parent The parent object
+ * @return layout if the operation is successful; NULL if failed;
+ */
+static Evas_Object *_create_basic_layout(Evas_Object *parent)
+{
+ Evas_Object *base;
+
+ if (!parent) {
+ _ERR("parent is NULL.");
+ return NULL;
+ }
+
+ base = elm_layout_add(parent);
+ if (!base) {
+ _ERR("elm_layout_add() failed.");
+ return NULL;
+ }
+
+ elm_layout_file_set(base, UG_NETWORK_EDJ_FILE,
+ GRP_CONNECTION_SETTING);
+
+ evas_object_show(base);
+
+ return base;
+}
+
+/**
+ * Sets the description.
+ *
+ * Sets the description for the IP setting view.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _set_description(struct _priv *priv)
+{
+ if (!priv || !priv->base) {
+ _ERR("priv is invalid.");
+ return;
+ }
+
+ elm_object_part_text_set(priv->base,
+ PART_CONNECTION_DESCRITION,
+ TXT_MAKE_OTHER_NETWORK);
+}
+
+/**
+ * Gets the network type.
+ *
+ * For either wired or wireless.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _get_cur_mode(struct _priv *priv)
+{
+ int ret;
+
+ if (!priv) {
+ _ERR("The param is invalid.\n");
+ return RET_FAILED;
+ }
+
+ if (priv->network_type == TYPE_WIRED) {
+ ret = vconf_mgr_get_wired_ip_mode(&priv->ip_mode);
+ if (ret != RET_SUCCESS)
+ _ERR("get wired ip mode from vconf failed.");
+
+ ret = vconf_mgr_get_wired_dns_mode(&priv->dns_mode);
+ if (ret != RET_SUCCESS)
+ _ERR("get wired dns mode from vconf failed.");
+ } else if (priv->network_type == TYPE_WIRELESS) {
+ ret = vconf_mgr_get_wireless_ip_mode(&priv->ip_mode);
+ if (ret != RET_SUCCESS)
+ _ERR("get wireless ip mode from vconf failed.");
+
+ ret = vconf_mgr_get_wireless_dns_mode(&priv->dns_mode);
+ if (ret != RET_SUCCESS)
+ _ERR("get wireless dns mode from vconf failed.");
+ } else {
+ _ERR("the network type is invalid.");
+ ret = RET_FAILED;
+ }
+
+ return ret;
+}
+
+/**
+ * Gets the network information for the profile.
+ *
+ * For wired network.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _get_connection_profile_info(struct _priv *priv)
+{
+ struct connection_info info;
+ int ret;
+
+ if (!priv) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ret = connection_mgr_get_profile_info(priv->connection, &info);
+ if (ret != RET_SUCCESS) {
+ _ERR("connection_mgr_get_profile_info() failed.");
+ return RET_FAILED;
+ }
+
+ priv->profile = info.profile;
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets the network information for the profile.
+ *
+ * For either wired network or wireless network.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _get_cur_ip_info(struct _priv *priv)
+{
+ struct network_info info;
+ int ret;
+
+ if (!priv) {
+ _ERR("The param is invalid.\n");
+ return RET_FAILED;
+ }
+
+ ret = _get_connection_profile_info(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("get profile failed.");
+ return RET_FAILED;
+ }
+
+ if (priv->network_type == TYPE_WIRED) {
+ if (priv->ip_mode == MODE_AUTO) {
+ ret = connection_mgr_get_ip_info(priv->profile, &info);
+ if (ret != RET_SUCCESS) {
+ _ERR("connection_mgr_get_ip_info() failed.");
+ return ret;
+ }
+ } else if (priv->ip_mode == MODE_MAN) {
+ ret = vconf_mgr_get_wired_network_info(&info);
+ if (ret != RET_SUCCESS) {
+ _ERR("get wired network info failed.");
+ return ret;
+ }
+ } else {
+ _ERR("ip mode is invalid.");
+ return RET_FAILED;
+ }
+ } else if (priv->network_type == TYPE_WIRELESS) {
+ if (priv->ip_mode == MODE_AUTO) {
+ ret = wifi_mgr_get_ip_info(priv->ap, &info);
+ if (ret != RET_SUCCESS) {
+ _ERR("wifi_mgr_get_ip_info() failed.");
+ return ret;
+ }
+ } else if (priv->ip_mode == MODE_MAN) {
+ ret = vconf_mgr_get_wireless_network_info(&info);
+ if (ret != RET_SUCCESS) {
+ _ERR("get wireless network info failed.");
+ return ret;
+ }
+ } else {
+ _ERR("ip mode is invalid.");
+ return RET_FAILED;
+ }
+ } else {
+ _ERR("network type is invalid.");
+ return RET_FAILED;
+ }
+
+ strncpy(priv->info.ip_addr, info.ip_addr, IP_STRING_MAX_SIZE);
+ strncpy(priv->info.submask, info.submask, IP_STRING_MAX_SIZE);
+ strncpy(priv->info.gateway, info.gateway, IP_STRING_MAX_SIZE);
+ strncpy(priv->info.dns, info.dns, IP_STRING_MAX_SIZE);
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Shows the dim layout.
+ *
+ * Called when there is a ctxpopup.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _set_layout_dim(struct _priv *priv)
+{
+ if (!priv || !priv->dim_ly) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ evas_object_show(priv->dim_ly);
+}
+
+/**
+ * Hides the dim layout.
+ *
+ * Called when the existing ctxpopup is deleted.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _unset_layout_dim(struct _priv *priv)
+{
+ if (!priv || !priv->dim_ly) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ evas_object_hide(priv->dim_ly);
+}
+
+/**
+ * Deletes the confirm popup.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _del_confirm_popup(struct _priv *priv)
+{
+ if (!priv || !priv->confirm_popup) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ evas_object_del(priv->confirm_popup);
+ priv->confirm_popup = NULL;
+
+ _unset_layout_dim(priv);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* When the 'OK' or 'Cancel' button is clicked, delete the popup,
+* and set the default focus.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] event Event information
+*/
+static void _popup_ok_cancel_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *event)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+
+ _del_confirm_popup(priv);
+
+ elm_object_focus_set(priv->ok_btn, EINA_TRUE);
+}
+
+/**
+ * Keeps the focused layout for the specific button.
+ *
+ * Emits a signal to edc to keep the focused state.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _keep_button_focused(struct _priv *priv)
+{
+ Evas_Object *obj;
+
+ if (!priv) {
+ _ERR("the param is invalid.");
+ return;
+ }
+
+ switch (priv->cur_type) {
+ case SETTING_IP:
+ obj = priv->ip_mode_btn;
+ break;
+ case SETTING_IP_ADDRESS:
+ obj = priv->ip_addr_btn;
+ break;
+ case SETTING_SUBNET_MASK:
+ obj = priv->subnet_mask_btn;
+ break;
+ case SETTING_GATEWAY:
+ obj = priv->gateway_btn;
+ break;
+ case SETTING_DNS:
+ obj = priv->dns_mode_btn;
+ break;
+ case SETTING_DNS_SERVER:
+ obj = priv->dns_server_btn;
+ break;
+ default:
+ return;
+ }
+
+ elm_object_signal_emit(obj, SIG_BTN_SELECTED, PROG);
+}
+
+/**
+ * Disables the IP buttons.
+ *
+ * If the mode is automatic, the IP buttons will be disabled.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _disable_ip_btns(struct _priv *priv)
+{
+ if (!priv) {
+ _ERR("the param is invalid.");
+ return;
+ }
+
+ elm_object_disabled_set(priv->ip_addr_btn, EINA_TRUE);
+ elm_object_disabled_set(priv->subnet_mask_btn, EINA_TRUE);
+ elm_object_disabled_set(priv->gateway_btn, EINA_TRUE);
+}
+
+/**
+ * Eables the IP buttons.
+ *
+ * If the mode is manual, the IP buttons will be eabled.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _enable_ip_btns(struct _priv *priv)
+{
+ if (!priv) {
+ _ERR("the param is invalid.");
+ return;
+ }
+
+ elm_object_disabled_set(priv->ip_addr_btn, EINA_FALSE);
+ elm_object_disabled_set(priv->subnet_mask_btn, EINA_FALSE);
+ elm_object_disabled_set(priv->gateway_btn, EINA_FALSE);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling dismissed event.
+*
+* When the ctxpopup is dismissed, delete the ctxpopup,
+* and set the default focus.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _popup_dismissed_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+
+ _unset_layout_dim(priv);
+
+ if (priv->confirm_popup)
+ evas_object_del(priv->confirm_popup);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* When the 'automatical' button is clicked, delete the popup,
+* and disable the IP buttons.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _ip_auto_mode_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+
+ _disable_ip_btns(priv);
+
+ if (priv->ip_mode_btn)
+ elm_object_part_text_set(priv->ip_mode_btn,
+ PART_VALUE, _(TXT_OBTAIN_AUTO));
+
+ evas_object_del(priv->ip_mode_ly);
+ priv->ip_mode_ly = NULL;
+ priv->ip_mode = MODE_AUTO;
+
+ _unset_layout_dim(priv);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling dismissed event.
+*
+* When the ctxpopup is dismissed, delete the ctxpopup.
+*
+* @param[in] data User data
+* @param[in] o The corresponding object which the focus event occurred
+* @param[in] ei Event information
+*/
+static void _mode_sub_popup_dismissed_cb(void *data,
+ Evas_Object *o, void *ei)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+
+ _unset_layout_dim(priv);
+
+ if (priv->cur_type == SETTING_IP) {
+ evas_object_del(priv->ip_mode_ly);
+ priv->ip_mode_ly = NULL;
+ } else if (priv->cur_type == SETTING_DNS) {
+ evas_object_del(priv->dns_mode_ly);
+ priv->dns_mode_ly = NULL;
+ }
+}
+
+/**
+ * Callback for key pressed event.
+ *
+ * If the key is KEY_BACK, delete the mode ctxpopup.
+ *
+ * @param[in] data User data
+ * @param[in] evas Evas handler
+ * @param[in] o The corresponding object which the deletion event occurred
+ * @param[in] ei Event information
+ */
+static void _mode_sub_popup_key_pressed_cb(void *data, Evas *evas,
+ Evas_Object *o, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _priv *priv;
+
+ if (!ei || !data) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+ ev = ei;
+
+ if (!ev->keyname) {
+ _ERR("ev->keyname is NULL.");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_LEFT) || !strcmp(ev->keyname, KEY_RIGHT)) {
+ _unset_layout_dim(priv);
+
+ if (priv->cur_type == SETTING_IP) {
+ evas_object_del(priv->ip_mode_ly);
+ priv->ip_mode_ly = NULL;
+ } else if (priv->cur_type == SETTING_DNS) {
+ evas_object_del(priv->dns_mode_ly);
+ priv->dns_mode_ly = NULL;
+ }
+ }
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* When the manual mode button is clicked, delete the popup,
+* and enable the IP buttons.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _ip_manual_mode_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+
+ _enable_ip_btns(priv);
+
+ elm_object_part_text_set(priv->ip_mode_btn,
+ PART_VALUE, _(TXT_ENTER_MAN));
+
+ evas_object_del(priv->ip_mode_ly);
+ priv->ip_mode_ly = NULL;
+ priv->ip_mode = MODE_MAN;
+
+ _unset_layout_dim(priv);
+}
+
+/**
+ * Callback for key pressed event.
+ *
+ * If the key is KEY_BACK, delete the IP value ctxpopup.
+ *
+ * @param[in] data User data
+ * @param[in] evas Evas handler
+ * @param[in] o The corresponding object which the deletion event occurred
+ * @param[in] ei Event information
+ */
+static void _ip_ctxpopup_key_pressed_cb(void *data, Evas *evas,
+ Evas_Object *o, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _priv *priv;
+
+ if (!ei || !data) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+ ev = ei;
+
+ if (!ev->keyname) {
+ _ERR("ev->keyname is NULL.");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_BACK)) {
+ _unset_layout_dim(priv);
+
+ evas_object_del(priv->ip_mode_ly);
+ priv->ip_mode_ly = NULL;
+ }
+}
+
+/**
+ * Callback for key pressed event.
+ *
+ * If the key is KEY_BACK, delete the ctxpopup.
+ *
+ * @param[in] data User data
+ * @param[in] e Evas handler
+ * @param[in] obj The corresponding object which the deletion event occurred
+ * @param[in] ei Event information
+ */
+static void _ctxpopup_pressed_cb(void *data, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _priv *priv;
+
+ if (!data || !ei) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+ ev = ei;
+
+ if (!ev->keyname) {
+ _ERR("ev->keyname is NULL.");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_BACK)) {
+ _unset_layout_dim(priv);
+ evas_object_del(obj);
+ }
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling unfocused event.
+*
+* When the ctxpopup is unfocused, hide the dim layout,
+* and delete the ctxpopup.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] source Event information
+*/
+static void _ctxpopup_unfocused_cb(void *data,
+ Evas_Object *obj, void *source)
+{
+ struct _priv *priv;
+
+ if (!data || !obj) {
+ _ERR("data is NULL.\n");
+ return;
+ }
+
+ priv = data;
+
+ _unset_layout_dim(priv);
+ evas_object_del(obj);
+}
+
+/**
+ * Creates the mode button.
+ *
+ * Uses the style of 'mode_select'.
+ *
+ * @param[in] base The parent object
+ * @param[in] txt The text in button
+ * @param[in] cb The callback for clicked event
+ * @param[in] data User data
+ * @return button if the operation is successful; NULL if failed;
+ */
+static Evas_Object *_create_mode_setting_btn(Evas_Object *base,
+ char *txt, Evas_Smart_Cb cb, void *data)
+{
+ Evas_Object *btn;
+
+ if (!base || !txt || !cb || !data) {
+ _ERR("The param is invalid.\n");
+ return NULL;
+ }
+
+ btn = util_add_button(base, STYLE_MODE_SELECT_BTN, NULL, txt);
+ if (!btn) {
+ _ERR("Add btn failed.\n");
+ return NULL;
+ }
+
+ evas_object_smart_callback_add(btn, SIG_DISMISSED,
+ _mode_sub_popup_dismissed_cb, data);
+ evas_object_smart_callback_add(btn, SIG_CLICKED, cb, data);
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN,
+ _mode_sub_popup_key_pressed_cb, data);
+
+ return btn;
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* Creates the IP value ctxpopup.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _ip_setting_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+ Evas_Object *base;
+ Evas_Object *ctxpopup;
+ Evas_Object *box;
+ Evas_Object *auto_btn;
+ Evas_Object *man_btn;
+ Evas_Coord x;
+ Evas_Coord y;
+ Evas_Coord w;
+ Evas_Coord h;
+ Evas_Object *btn[MODE_BTN_NUM];
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+ priv->cur_type = SETTING_IP;
+ base = priv->base;
+
+ if (priv->ip_mode == MODE_INVALID)
+ priv->ip_mode = MODE_MAN;
+
+ ctxpopup = util_add_layout(base, UG_NETWORK_EDJ_FILE,
+ GRP_NETWORK_MODE_SETTING);
+ if (!ctxpopup) {
+ _ERR("elm_layout_add() failed.\n");
+ return;
+ }
+
+ _set_layout_dim(priv);
+ _keep_button_focused(priv);
+
+ box = util_add_box(ctxpopup, PART_SWALLOW_CONTENT);
+ if (!box) {
+ _ERR("create box failed.");
+ evas_object_del(ctxpopup);
+ return;
+ }
+
+ elm_box_horizontal_set(box, EINA_FALSE);
+
+ auto_btn = _create_mode_setting_btn(ctxpopup, _(TXT_OBTAIN_AUTO),
+ _ip_auto_mode_btn_clicked_cb, (void *)priv);
+ if (!auto_btn) {
+ _ERR("Add btn failed.\n");
+ evas_object_del(ctxpopup);
+ return;
+ }
+
+ elm_box_pack_end(box, auto_btn);
+ elm_object_focus_set(auto_btn, EINA_TRUE);
+ btn[0] = auto_btn;
+
+ man_btn = _create_mode_setting_btn(ctxpopup, _(TXT_ENTER_MAN),
+ _ip_manual_mode_btn_clicked_cb, (void *)priv);
+ if (!man_btn) {
+ _ERR("Add btn failed.\n");
+ evas_object_del(ctxpopup);
+ return;
+ }
+
+ elm_box_pack_end(box, man_btn);
+ btn[1] = man_btn;
+
+ _set_up_down_cycle_focus(btn, 2);
+
+ evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_KEY_DOWN,
+ _ip_ctxpopup_key_pressed_cb, priv);
+ evas_object_smart_callback_add(ctxpopup, SIG_UNFOCUSED,
+ _ctxpopup_unfocused_cb, priv);
+
+ priv->ip_mode_ly = ctxpopup;
+
+ if (priv->ip_mode == MODE_AUTO)
+ elm_object_signal_emit(auto_btn, SIG_BTN_SELECTED, PROG);
+ else if (priv->ip_mode == MODE_MAN)
+ elm_object_signal_emit(man_btn, SIG_BTN_SELECTED, PROG);
+
+ evas_object_geometry_get(priv->ip_mode_btn, &x, &y, &w, &h);
+ evas_object_move(ctxpopup, (x + SETTING_MODE_OFFSET_X) * ELM_SCALE,
+ (y + h) * ELM_SCALE);
+}
+
+/**
+ * Gets the position of IP value ctxpopup.
+ *
+ * Gets the specific position by the current type.
+ *
+ * @param[in] priv The handler of the private data
+ * @param[out] pos_x X position
+ * @param[out] pos_y Y position
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _get_value_popup_pos(struct _priv *priv,
+ Evas_Coord *pos_x, Evas_Coord *pos_y)
+{
+ Evas_Coord x;
+ Evas_Coord y;
+ Evas_Coord w;
+ Evas_Coord h;
+
+ if (!priv || !pos_x || !pos_y) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ switch (priv->cur_type) {
+ case SETTING_IP_ADDRESS:
+ evas_object_geometry_get(priv->ip_addr_btn, &x, &y, &w, &h);
+ *pos_x = x + SETTING_VALUE_OFFSET_X;
+ *pos_y = y - SETTING_VALUE_OFFSET_Y;
+ break;
+ case SETTING_SUBNET_MASK:
+ evas_object_geometry_get(priv->subnet_mask_btn, &x, &y, &w, &h);
+ *pos_x = x + SETTING_VALUE_OFFSET_X;
+ *pos_y = y - SETTING_VALUE_OFFSET_Y;
+ break;
+ case SETTING_GATEWAY:
+ evas_object_geometry_get(priv->gateway_btn, &x, &y, &w, &h);
+ *pos_x = x + SETTING_VALUE_OFFSET_X;
+ *pos_y = y - SETTING_VALUE_OFFSET_Y;
+ break;
+ case SETTING_DNS_SERVER:
+ evas_object_geometry_get(priv->dns_server_btn, &x, &y, &w, &h);
+ *pos_x = x + SETTING_VALUE_OFFSET_X;
+ *pos_y = y - 2 * SETTING_VALUE_OFFSET_Y;
+ break;
+ default:
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets the number to the object text.
+ *
+ * @param[in] obj The handler of the object
+ * @param[in] num The number
+ */
+static void _set_text_num(Evas_Object *obj, int num)
+{
+ char value[IP_STRING_MAX_SIZE];
+
+ if (!obj) {
+ _ERR("The param is invalid.");
+ return;
+ }
+
+ memset(value, 0, IP_STRING_MAX_SIZE);
+ snprintf(value, IP_STRING_MAX_SIZE - 1, "%d", num);
+ elm_object_text_set(obj, value);
+}
+
+/**
+ * Callback for key pressed event.
+ *
+ * The button responds the key, and sets the number for the button.
+ *
+ * @param[in] data User data
+ * @param[in] evas Evas handler
+ * @param[in] obj The corresponding object which the deletion event occurred
+ * @param[in] ei Event information
+ */
+static void _ip_btn_key_pressed_cb(void *data, Evas *evas,
+ Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ const char *value;
+ int num, new_num;
+
+ if (!ei || !data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ ev = ei;
+
+ if (!ev->keyname) {
+ _ERR("ev->keyname is NULL.");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_UP)) {
+ value = elm_object_text_get(obj);
+ num = atoi(value);
+ num++;
+ if (num > MAX_IP_NUM)
+ num = 0;
+ } else if (!strcmp(ev->keyname, KEY_DOWN)) {
+ value = elm_object_text_get(obj);
+ num = atoi(value);
+ num--;
+ if (num < 0)
+ num = MAX_IP_NUM;
+ } else if (!strcmp(ev->keyname, KEY_0) ||
+ !strcmp(ev->keyname, KEY_1) ||
+ !strcmp(ev->keyname, KEY_2) ||
+ !strcmp(ev->keyname, KEY_3) ||
+ !strcmp(ev->keyname, KEY_4) ||
+ !strcmp(ev->keyname, KEY_5) ||
+ !strcmp(ev->keyname, KEY_6) ||
+ !strcmp(ev->keyname, KEY_7) ||
+ !strcmp(ev->keyname, KEY_8) ||
+ !strcmp(ev->keyname, KEY_9)) {
+ value = elm_object_text_get(obj);
+ if (!value)
+ elm_object_text_set(obj, ev->keyname);
+
+ new_num = atoi(ev->keyname);
+
+ num = atoi(value);
+ if (!num || (num * RATIO + new_num) > MAX_IP_NUM) {
+ elm_object_text_set(obj, ev->keyname);
+ return;
+ }
+
+ num = num * RATIO + new_num;
+ } else {
+ return;
+ }
+
+ _set_text_num(obj, num);
+}
+
+/**
+ * Sets the value to the object text.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _set_the_value(struct _priv *priv)
+{
+ Evas_Object *btn;
+ const char *value1;
+ const char *value2;
+ const char *value3;
+ const char *value4;
+ char value[IP_STRING_MAX_SIZE];
+
+ if (!priv || !priv->config_popup) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ value1 = NULL;
+ btn = evas_object_data_get(priv->config_popup, IP_VALUE1);
+ if (btn)
+ value1 = elm_object_text_get(btn);
+
+ value2 = NULL;
+ btn = evas_object_data_get(priv->config_popup, IP_VALUE2);
+ if (btn)
+ value2 = elm_object_text_get(btn);
+
+ value3 = NULL;
+ btn = evas_object_data_get(priv->config_popup, IP_VALUE3);
+ if (btn)
+ value3 = elm_object_text_get(btn);
+
+ value4 = NULL;
+ btn = evas_object_data_get(priv->config_popup, IP_VALUE4);
+ if (btn)
+ value4 = elm_object_text_get(btn);
+
+ memset(value, 0, IP_STRING_MAX_SIZE);
+ snprintf(value, IP_STRING_MAX_SIZE, "%s.%s.%s.%s",
+ value1 ? value1 : "\\0", value2 ? value2 : "\\0",
+ value3 ? value3 : "\\0", value4 ? value4 : "\\0");
+
+ switch (priv->cur_type) {
+ case SETTING_IP_ADDRESS:
+ elm_object_part_text_set(priv->ip_addr_btn,
+ PART_VALUE, value);
+ strncpy(priv->info.ip_addr, value, IP_STRING_MAX_SIZE);
+ break;
+ case SETTING_SUBNET_MASK:
+ elm_object_part_text_set(priv->subnet_mask_btn,
+ PART_VALUE, value);
+ strncpy(priv->info.submask, value, IP_STRING_MAX_SIZE);
+ break;
+ case SETTING_GATEWAY:
+ elm_object_part_text_set(priv->gateway_btn,
+ PART_VALUE, value);
+ strncpy(priv->info.gateway, value, IP_STRING_MAX_SIZE);
+ break;
+ case SETTING_DNS_SERVER:
+ elm_object_part_text_set(priv->dns_server_btn,
+ PART_VALUE, value);
+ strncpy(priv->info.dns, value, IP_STRING_MAX_SIZE);
+ break;
+ default:
+ return;
+ }
+
+ evas_object_del(priv->config_popup);
+ priv->config_popup = NULL;
+}
+
+/**
+ * Callback for key pressed event.
+ *
+ * If the key is KEY_BACK, delete the IP value ctxpopup.
+ * If the key is KEY_ENTER, set the value into the button.
+ *
+ * @param[in] data User data
+ * @param[in] evas Evas handler
+ * @param[in] obj The corresponding object which the deletion event occurred
+ * @param[in] ei Event information
+ */
+static void _value_ctxpopup_key_pressed_cb(void *data, Evas *evas,
+ Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _priv *priv;
+
+ if (!ei || !data) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ ev = ei;
+ priv = data;
+
+ if (!ev->keyname) {
+ _ERR("ev->keyname is NULL.");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_ENTER)) {
+ _unset_layout_dim(priv);
+ _set_the_value(priv);
+ evas_object_del(obj);
+ } else if (!strcmp(ev->keyname, KEY_BACK)) {
+ _unset_layout_dim(priv);
+ evas_object_del(obj);
+ }
+}
+
+/**
+ * Sets the cycle focus in the direction of left and right.
+ *
+ * Sets the cycle focus for an array of objects.
+ *
+ * @param[in] obj The handler of objects
+ * @param[in] count The count of objects
+ */
+static void _set_left_right_cycle_focus(Evas_Object **obj, int count)
+{
+ int i;
+
+ if (!obj || !*obj) {
+ _ERR("the param is invalid.");
+ return;
+ }
+
+ for (i = 0; i < count; i++) {
+ if (i == count - 1)
+ elm_object_focus_next_object_set(obj[i],
+ obj[0], ELM_FOCUS_RIGHT);
+ else
+ elm_object_focus_next_object_set(obj[i],
+ obj[i + 1], ELM_FOCUS_RIGHT);
+
+ if (i == 0)
+ elm_object_focus_next_object_set(obj[i],
+ obj[count - 1], ELM_FOCUS_LEFT);
+ else
+ elm_object_focus_next_object_set(obj[i],
+ obj[i - 1], ELM_FOCUS_LEFT);
+ }
+}
+
+/**
+ * Creates the value button for IP setting.
+ *
+ * @param[in] base The parent object
+ * @param[in] num The sequence number of the button
+ * @param[in] txt The text in the button
+ * @param[in] data User data
+ * @return button if the operation is successful; NULL if failed;
+ */
+static Evas_Object *_create_value_btn(Evas_Object *base, int num,
+ char *txt, void *data)
+{
+ Evas_Object *btn;
+
+ if (!base || !txt || !data) {
+ _ERR("The param is invalid.\n");
+ return NULL;
+ }
+
+ btn = util_add_button(base, STYLE_VALUE_BTN, NULL, txt);
+ if (!btn) {
+ _ERR("add button failed.\n");
+ return NULL;
+ }
+
+ switch (num) {
+ case 0:
+ elm_object_part_content_set(base, PART_IP_FIRST, btn);
+ evas_object_data_set(base, IP_VALUE1, btn);
+ elm_object_focus_set(btn, EINA_TRUE);
+ break;
+ case 1:
+ elm_object_part_content_set(base, PART_IP_SECOND, btn);
+ evas_object_data_set(base, IP_VALUE2, btn);
+ break;
+ case 2:
+ elm_object_part_content_set(base, PART_IP_THIRD, btn);
+ evas_object_data_set(base, IP_VALUE3, btn);
+ break;
+ case 3:
+ elm_object_part_content_set(base, PART_IP_FORTH, btn);
+ evas_object_data_set(base, IP_VALUE4, btn);
+ break;
+ default:
+ break;
+ }
+
+ evas_object_smart_callback_add(btn, SIG_CLICKED,
+ _popup_dismissed_cb, data);
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN,
+ _ip_btn_key_pressed_cb, data);
+ elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_DOWN);
+
+ return btn;
+}
+
+/**
+ * Creates value ctxpopup.
+ *
+ * User can set number in the ctxpopup.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _create_value_popup(struct _priv *priv)
+{
+ Evas_Object *base;
+ Evas_Object *ctxpopup;
+ Evas_Object *btn;
+ Evas_Coord pos_x;
+ Evas_Coord pos_y;
+ int i;
+
+ if (!priv || !priv->base) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ base = priv->base;
+
+ ctxpopup = util_add_layout(base, UG_NETWORK_EDJ_FILE,
+ GRP_NETWORK_VALUE_SETTING);
+ if (!ctxpopup) {
+ _ERR("elm_ctxpopup_add() failed.\n");
+ return;
+ }
+
+ elm_object_focus_allow_set(ctxpopup, EINA_TRUE);
+ evas_object_smart_callback_add(ctxpopup, SIG_UNFOCUSED,
+ _ctxpopup_unfocused_cb, priv);
+ priv->config_popup = ctxpopup;
+
+ _set_layout_dim(priv);
+
+ for (i = 0; i < IP_SET_MAX_NUM; i++) {
+ btn = _create_value_btn(ctxpopup, i, _(TXT_ZERO), (void *)priv);
+ if (!btn) {
+ _ERR("_create_value_btn() failed.\n");
+ evas_object_del(ctxpopup);
+ priv->config_popup = NULL;
+ return;
+ }
+
+ priv->cur_ip_btn[i] = btn;
+ }
+
+ evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_KEY_DOWN,
+ _value_ctxpopup_key_pressed_cb, priv);
+ _set_left_right_cycle_focus(priv->cur_ip_btn, IP_SET_MAX_NUM);
+
+ _keep_button_focused(priv);
+
+ pos_x = 0;
+ pos_y = 0;
+ _get_value_popup_pos(priv, &pos_x, &pos_y);
+ evas_object_move(ctxpopup, pos_x * ELM_SCALE, pos_y * ELM_SCALE);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* After the IP button is clicked, the value ctxpopup
+* will be created to set the value.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _ip_address_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+
+ priv->cur_type = SETTING_IP_ADDRESS;
+ _create_value_popup(priv);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* After the submask button is clicked, the value ctxpopup
+* will be created to set the value.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _sub_mask_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+
+ priv->cur_type = SETTING_SUBNET_MASK;
+ _create_value_popup(priv);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* After the gateway button is clicked, the value ctxpopup
+* will be created to set the value.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _gateway_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+ priv->cur_type = SETTING_GATEWAY;
+ _create_value_popup(priv);
+}
+
+/**
+ * Creates setting button.
+ *
+ * @param[in] base The parent object
+ * @param[in] key The key value
+ * @param[in] txt The text in the button
+ * @param[in] cb The callback for clicked event
+ * @param[in] data User data
+ * @return button if the operation is successful; NULL if failed;
+ */
+static Evas_Object *_create_setting_btn(Evas_Object *base,
+ char *key, char *txt, Evas_Smart_Cb cb, void *data)
+{
+ Evas_Object *btn;
+
+ if (!base || !key || !txt || !cb || !data) {
+ _ERR("The param is invalid.\n");
+ return NULL;
+ }
+
+ btn = util_add_key_value_button(base, NULL, key, txt);
+ if (!btn) {
+ _ERR("Add button failed.\n");
+ return NULL;
+ }
+
+ evas_object_smart_callback_add(btn, SIG_CLICKED, cb, data);
+ elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT);
+
+ return btn;
+}
+
+/**
+ * Creates IP setting layout.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _create_ip_setting(struct _priv *priv)
+{
+ Evas_Object *base;
+ Evas_Object *scroll;
+ Evas_Object *box;
+ Evas_Object *btn;
+ char mode[STRING_MAX_SIZE];
+
+ if (!priv || !priv->base) {
+ _ERR("The param is invalid.\n");
+ return RET_FAILED;
+ }
+
+ base = priv->base;
+
+ scroll = util_add_scroll(base, PART_CONNECTION_IP_SETTING);
+ if (!scroll) {
+ _ERR("add scroll failed.");
+ return RET_FAILED;
+ }
+
+ box = util_add_box(scroll, NULL);
+ if (!box) {
+ _ERR("add box failed.");
+ evas_object_del(scroll);
+ return RET_FAILED;
+ }
+
+ elm_box_horizontal_set(box, EINA_FALSE);
+ elm_box_padding_set(box, BOX_PAD_X, BOX_PAD_Y);
+
+ memset(mode, 0, STRING_MAX_SIZE);
+ if (priv->ip_mode == MODE_AUTO)
+ snprintf(mode, STRING_MAX_SIZE - 1,
+ "%s", _(TXT_OBTAIN_AUTO));
+ else
+ snprintf(mode, STRING_MAX_SIZE - 1,
+ "%s", _(TXT_ENTER_MAN));
+
+ btn = _create_setting_btn(base, _(TXT_IP_SETTING), mode,
+ _ip_setting_btn_clicked_cb, (void *)priv);
+ if (!btn) {
+ _ERR("Add button failed.\n");
+ evas_object_del(scroll);
+ return RET_FAILED;
+ }
+
+ elm_box_pack_end(box, btn);
+ elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_UP);
+ elm_object_focus_set(btn, EINA_TRUE);
+ priv->ip_mode_btn = btn;
+
+ btn = _create_setting_btn(base, _(TXT_IP_ADDR), priv->info.ip_addr,
+ _ip_address_btn_clicked_cb, (void *)priv);
+ if (!btn) {
+ _ERR("Add btn failed.\n");
+ evas_object_del(scroll);
+ return RET_FAILED;
+ }
+
+ elm_box_pack_end(box, btn);
+ priv->ip_addr_btn = btn;
+
+ btn = _create_setting_btn(base, _(TXT_SUBNET_MASK), priv->info.submask,
+ _sub_mask_btn_clicked_cb, (void *)priv);
+ if (!btn) {
+ _ERR("Add btn failed.\n");
+ evas_object_del(scroll);
+ return RET_FAILED;
+ }
+
+ elm_box_pack_end(box, btn);
+ priv->subnet_mask_btn = btn;
+
+ btn = _create_setting_btn(base, _(TXT_GATEWAY), priv->info.gateway,
+ _gateway_btn_clicked_cb, (void *)priv);
+ if (!btn) {
+ _ERR("Add btn failed.\n");
+ evas_object_del(scroll);
+ return RET_FAILED;
+ }
+
+ elm_object_signal_emit(btn, SIG_HIDE_BOTTOME_LINE, PROG);
+
+ elm_box_pack_end(box, btn);
+ priv->gateway_btn = btn;
+
+ elm_object_content_set(scroll, box);
+
+ if (priv->ip_mode == MODE_AUTO)
+ _disable_ip_btns(priv);
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Disables DNS setting button.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _disable_dns_btns(struct _priv *priv)
+{
+ if (!priv || !priv->dns_server_btn) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ elm_object_disabled_set(priv->dns_server_btn, EINA_TRUE);
+}
+
+/**
+ * Enables DNS setting button.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _enable_dns_btns(struct _priv *priv)
+{
+ if (!priv || !priv->dns_server_btn) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ elm_object_disabled_set(priv->dns_server_btn, EINA_FALSE);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* When the 'automatical' button is clicked, delete the popup,
+* and disable the DNS buttons.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _dns_auto_mode_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+
+ _disable_dns_btns(priv);
+
+ elm_object_part_text_set(priv->dns_mode_btn,
+ PART_VALUE, _(TXT_OBTAIN_AUTO));
+
+ evas_object_del(priv->dns_mode_ly);
+ priv->dns_mode_ly = NULL;
+ priv->dns_mode = MODE_AUTO;
+
+ _unset_layout_dim(priv);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* When the manual mode button is clicked, delete the popup,
+* and enable the DNS buttons.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _dns_manual_mode_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+
+ _enable_dns_btns(priv);
+
+ elm_object_part_text_set(priv->dns_mode_btn,
+ PART_VALUE, _(TXT_ENTER_MAN));
+
+ evas_object_del(priv->dns_mode_ly);
+ priv->dns_mode_ly = NULL;
+ priv->dns_mode = MODE_MAN;
+
+ _unset_layout_dim(priv);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling dismissed event.
+*
+* When the ctxpopup is dismissed, delete the ctxpopup.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _dns_ctxpopup_dismissed_cb(void *data,
+ Evas_Object *obj, void *source)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+
+ _unset_layout_dim(priv);
+
+ evas_object_del(priv->dns_mode_ly);
+ priv->dns_mode_ly = NULL;
+}
+
+/**
+ * Callback for key pressed event.
+ *
+ * If the key is KEY_BACK, delete the DNS ctxpopup.
+ * If the key is KEY_EXIT, destroy the ug.
+ *
+ * @param[in] data User data
+ * @param[in] evas Evas handler
+ * @param[in] o The corresponding object which the deletion event occurred
+ * @param[in] ei Event information
+ */
+static void _dns_ctxpopup_key_pressed_cb(void *data, Evas *evas,
+ Evas_Object *o, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _priv *priv;
+
+ if (!ei || !data) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+ ev = ei;
+
+ if (!ev->keyname) {
+ _ERR("ev->keyname is NULL.");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_BACK)) {
+ _unset_layout_dim(priv);
+ evas_object_del(priv->dns_mode_ly);
+ priv->dns_mode_ly = NULL;
+ } else if (!strcmp(ev->keyname, KEY_EXIT)) {
+ ug_destroy_me(priv->ug);
+ }
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* Creates the DNS mode ctxpopup.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _dns_setting_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+ Evas_Object *base;
+ Evas_Object *ctxpopup, *box;
+ Evas_Object *btn_auto, *btn_man;
+ Evas_Coord x, y, w, h;
+ Evas_Object *btn[2];
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+ priv->cur_type = SETTING_DNS;
+
+ base = priv->base;
+
+ if (priv->dns_mode == MODE_INVALID)
+ priv->dns_mode = MODE_MAN;
+
+ ctxpopup = util_add_layout(base, UG_NETWORK_EDJ_FILE,
+ GRP_NETWORK_MODE_SETTING);
+ if (!ctxpopup) {
+ _ERR("elm_layout_add() failed.\n");
+ return;
+ }
+
+ box = util_add_box(ctxpopup, PART_SWALLOW_CONTENT);
+ if (!box) {
+ _ERR("add box failed.");
+ evas_object_del(ctxpopup);
+ return;
+ }
+
+ elm_box_horizontal_set(box, EINA_FALSE);
+
+ btn_auto = _create_mode_setting_btn(ctxpopup, _(TXT_OBTAIN_AUTO),
+ _dns_auto_mode_btn_clicked_cb, priv);
+ if (!btn_auto) {
+ _ERR("Add btn failed.\n");
+ evas_object_del(ctxpopup);
+ return;
+ }
+
+ elm_box_pack_end(box, btn_auto);
+ elm_object_focus_set(btn_auto, EINA_TRUE);
+ btn[0] = btn_auto;
+
+ btn_man = _create_mode_setting_btn(ctxpopup, _(TXT_ENTER_MAN),
+ _dns_manual_mode_btn_clicked_cb, priv);
+ if (!btn_man) {
+ _ERR("Add btn failed.\n");
+ evas_object_del(ctxpopup);
+ return;
+ }
+
+ elm_box_pack_end(box, btn_man);
+ btn[1] = btn_man;
+
+ _set_up_down_cycle_focus(btn, 2);
+
+ evas_object_event_callback_add(ctxpopup,
+ EVAS_CALLBACK_KEY_DOWN,
+ _dns_ctxpopup_key_pressed_cb, priv);
+ evas_object_smart_callback_add(ctxpopup, SIG_UNFOCUSED,
+ _ctxpopup_unfocused_cb, priv);
+ evas_object_smart_callback_add(ctxpopup, SIG_DISMISSED,
+ _dns_ctxpopup_dismissed_cb, priv);
+
+ evas_object_geometry_get(priv->dns_mode_btn, &x, &y, &w, &h);
+ priv->dns_mode_ly = ctxpopup;
+
+ evas_object_move(ctxpopup, (x + SETTING_MODE_OFFSET_X) * ELM_SCALE,
+ (y + h) * ELM_SCALE);
+
+ if (priv->dns_mode == MODE_AUTO)
+ elm_object_signal_emit(btn_auto, SIG_BTN_SELECTED, PROG);
+ else if (priv->dns_mode == MODE_MAN)
+ elm_object_signal_emit(btn_man, SIG_BTN_SELECTED, PROG);
+
+ _set_layout_dim(priv);
+
+ _keep_button_focused(priv);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* After the DNS button is clicked, the value ctxpopup
+* will be created to set the value.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _dns_server_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+
+ priv->cur_type = SETTING_DNS_SERVER;
+ _create_value_popup(priv);
+}
+
+/**
+ * Creates DNS setting layout.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _create_dns_setting(struct _priv *priv)
+{
+ Evas_Object *base;
+ Evas_Object *btn;
+ Evas_Object *box;
+ char mode[STRING_MAX_SIZE];
+
+ if (!priv || !priv->base) {
+ _ERR("The param is invalid.\n");
+ return RET_FAILED;
+ }
+
+ base = priv->base;
+
+ box = util_add_box(base, PART_CONNECTION_DNS_SETTING);
+ if (!box) {
+ _ERR("add box failed.");
+ return RET_FAILED;
+ }
+
+ elm_box_horizontal_set(box, EINA_FALSE);
+ elm_box_padding_set(box, BOX_PAD_X, BOX_PAD_Y);
+
+ memset(mode, 0, STRING_MAX_SIZE);
+ if (priv->dns_mode == MODE_AUTO)
+ snprintf(mode, STRING_MAX_SIZE - 1,
+ "%s", _(TXT_OBTAIN_AUTO));
+ else
+ snprintf(mode, STRING_MAX_SIZE - 1,
+ "%s", _(TXT_ENTER_MAN));
+
+ btn = util_add_key_value_button(base, NULL,
+ _(TXT_DNS_SETING), mode);
+ if (!btn) {
+ _ERR("Add button failed.\n");
+ evas_object_del(box);
+ return RET_FAILED;
+ }
+
+ evas_object_smart_callback_add(btn,
+ SIG_CLICKED, _dns_setting_btn_clicked_cb, priv);
+ elm_box_pack_end(box, btn);
+ elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT);
+
+ priv->dns_mode_btn = btn;
+
+ btn = util_add_key_value_button(base, NULL,
+ _(TXT_DNS_SERVER), priv->info.dns);
+ if (!btn) {
+ _ERR("Add btn failed.\n");
+ evas_object_del(box);
+ return RET_FAILED;
+ }
+
+ elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT);
+ evas_object_smart_callback_add(btn, SIG_CLICKED,
+ _dns_server_btn_clicked_cb, priv);
+ elm_object_signal_emit(btn, SIG_HIDE_BOTTOME_LINE, PROG);
+ elm_box_pack_end(box, btn);
+
+ priv->dns_server_btn = btn;
+
+ if (priv->dns_mode == MODE_AUTO)
+ _disable_dns_btns(priv);
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Checks if IP is valid.
+ *
+ * Now only check if IP is '0.0.0.0'.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful;
+ * RET_IP_INVALID if the IP is '0.0.0.0'; RET_FAILED if failed;
+ */
+static int _check_is_ip_valid(struct _priv *priv)
+{
+ if (!priv) {
+ _ERR("The param is NULL.\n");
+ return RET_FAILED;
+ }
+
+ if (!strncmp(priv->info.ip_addr, ZERO_IP,
+ IP_STRING_MAX_SIZE)) {
+ _ERR("IP addr is invalid.");
+ return RET_IP_INVALID;
+ }
+
+ if (!strncmp(priv->info.submask, ZERO_IP,
+ IP_STRING_MAX_SIZE)) {
+ _ERR("submask addr is invalid.");
+ return RET_IP_INVALID;
+ }
+
+ if (!strncmp(priv->info.gateway, ZERO_IP,
+ IP_STRING_MAX_SIZE)) {
+ _ERR("gateway addr is invalid.");
+ return RET_IP_INVALID;
+ }
+
+ if (!strncmp(priv->info.dns, ZERO_IP,
+ IP_STRING_MAX_SIZE)) {
+ _ERR("dns addr is invalid.");
+ return RET_IP_INVALID;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Shows the invalid IP ctxpopup.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _show_invalid_ip_popup(struct _priv *priv)
+{
+ Evas_Object *layout;
+ Evas_Object *ok_btn;
+ char content[CONTENT_TXT_SIZE];
+
+ if (!priv) {
+ _ERR("The param is NULL.\n");
+ return;
+ }
+
+ if (priv->confirm_popup)
+ _del_confirm_popup(priv);
+
+ _set_layout_dim(priv);
+
+ layout = util_add_layout(priv->base, UG_NETWORK_EDJ_FILE,
+ GRP_CONFIRM_LAYOUT);
+ if (!layout) {
+ _ERR("add layout failed.");
+ _unset_layout_dim(priv);
+ return;
+ }
+
+ evas_object_show(layout);
+
+ if (priv->network_type == TYPE_WIRED)
+ elm_object_part_text_set(layout,
+ PART_TEXT_TITLE, _(TXT_WIRED_LY));
+ else
+ elm_object_part_text_set(layout,
+ PART_TEXT_TITLE, _(TXT_WIRELESS_LY));
+
+ memset(content, 0, CONTENT_TXT_SIZE);
+ snprintf(content, CONTENT_TXT_SIZE - 1, "%s",
+ _(TXT_INVALID_IP));
+ elm_object_part_text_set(layout,
+ PART_TEXT_CONTENT, content);
+
+ ok_btn = util_add_button(layout,
+ STYLE_SETTING_BTN, PART_OK_BTN, _(TXT_OK));
+ if (!ok_btn) {
+ _ERR("util add button failed.");
+ evas_object_del(layout);
+ _unset_layout_dim(priv);
+ return;
+ }
+
+ elm_object_focus_next_object_set(ok_btn, ok_btn, ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(ok_btn, ok_btn, ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(ok_btn, ok_btn, ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(ok_btn, ok_btn, ELM_FOCUS_DOWN);
+ evas_object_smart_callback_add(ok_btn, SIG_CLICKED,
+ _popup_ok_cancel_btn_clicked_cb, priv);
+
+ elm_object_focus_set(ok_btn, EINA_TRUE);
+
+ elm_object_focus_allow_set(layout, EINA_TRUE);
+ evas_object_smart_callback_add(layout, SIG_UNFOCUSED,
+ _ctxpopup_unfocused_cb, priv);
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN,
+ _ctxpopup_pressed_cb, priv);
+
+ evas_object_move(layout, CENTER_ALIGN * (DEFAULT_WIN_WIDTH - POPUP_WIDTH) * ELM_SCALE,
+ CENTER_ALIGN * (DEFAULT_WIN_HEIGHT - POPUP_HEIGHT) * ELM_SCALE);
+
+ priv->confirm_popup = layout;
+}
+
+/**
+ * Sets the mode as 'manually'.
+ *
+ * Depends on the network type.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _config_network_manually(struct _priv *priv)
+{
+ int ret;
+
+ if (!priv) {
+ _ERR("The param is NULL.\n");
+ return RET_FAILED;
+ }
+
+ ret = _check_is_ip_valid(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("the ip is invalid.");
+ _show_invalid_ip_popup(priv);
+ return ret;
+ }
+
+ _get_connection_profile_info(priv);
+
+ switch (priv->network_type) {
+ case TYPE_WIRED:
+ ret = connection_mgr_set_profile(priv->connection,
+ priv->profile, &priv->info);
+ if (ret != RET_SUCCESS) {
+ _ERR("set profile failed.");
+ return ret;
+ }
+
+ ret = vconf_mgr_save_wired_config_info(&priv->info);
+ if (ret != RET_SUCCESS) {
+ _ERR("saved wired ip info to vconf failed.");
+ return ret;
+ }
+
+ break;
+ case TYPE_WIRELESS:
+ ret = wifi_mgr_set_ip_config(priv->ap, &priv->info);
+ if (ret != RET_SUCCESS) {
+ _ERR("set wifi ip config failed.");
+ return ret;
+ }
+
+ ret = wifi_mgr_set_dns_config(priv->ap, &priv->info);
+ if (ret != RET_SUCCESS) {
+ _ERR("set wifi dns config failed.");
+ return ret;
+ }
+
+ ret = vconf_mgr_save_wireless_config_info(&priv->info);
+ if (ret != RET_SUCCESS) {
+ _ERR("saved wireless ip info to vconf failed.");
+ return ret;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets the mode as 'dynamic'.
+ *
+ * Depends on the network type.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _config_network_dynamic(struct _priv *priv)
+{
+ int ret;
+
+ if (!priv) {
+ _ERR("The param is NULL.\n");
+ return RET_FAILED;
+ }
+
+ _get_connection_profile_info(priv);
+
+ switch (priv->network_type) {
+ case TYPE_WIRED:
+ ret = connection_mgr_ip_dynamic_config(priv->connection,
+ priv->profile);
+ if (ret != RET_SUCCESS) {
+ _ERR("connection_mgr_ip_dynamic_config() failed.");
+ return RET_FAILED;
+ }
+
+ break;
+ case TYPE_WIRELESS:
+ ret = wifi_mgr_ap_set_ip_config_type(priv->ap,
+ WIFI_IP_CONFIG_TYPE_DYNAMIC);
+ if (ret != RET_SUCCESS) {
+ _ERR("connection_mgr_ip_dynamic_config() failed.");
+ return RET_FAILED;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Saves the mode to vconf.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _save_mode(struct _priv *priv)
+{
+ int ret;
+
+ if (!priv) {
+ _ERR("The param is NULL.\n");
+ return;
+ }
+
+ switch (priv->network_type) {
+ case TYPE_WIRED:
+ ret = vconf_mgr_set_wired_ip_mode(priv->ip_mode);
+ if (ret != RET_SUCCESS)
+ _ERR("vconf_mgr_set_wired_ip_mode() failed.");
+
+ ret = vconf_mgr_set_wired_dns_mode(priv->dns_mode);
+ if (ret != RET_SUCCESS)
+ _ERR("vconf_mgr_set_wired_dns_mode() failed.");
+
+ break;
+ case TYPE_WIRELESS:
+ ret = vconf_mgr_set_wireless_ip_mode(priv->ip_mode);
+ if (ret != RET_SUCCESS)
+ _ERR("vconf_mgr_set_wireless_ip_mode() failed.");
+
+ ret = vconf_mgr_set_wireless_dns_mode(priv->dns_mode);
+ if (ret != RET_SUCCESS)
+ _ERR("vconf_mgr_set_wireless_dns_mode() failed.");
+
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+ * Configs the network mode.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _config_network(struct _priv *priv)
+{
+ int ret;
+
+ if (!priv) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ switch (priv->ip_mode) {
+ case MODE_AUTO:
+ ret = _config_network_dynamic(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("config network automatically failed.");
+ goto error;
+ }
+
+ break;
+ case MODE_MAN:
+ ret = _config_network_manually(priv);
+ if (ret == RET_IP_INVALID) {
+ _ERR("invalid IP.");
+ return;
+ } else if (ret != RET_SUCCESS) {
+ _ERR("config network manually failed.");
+ goto error;
+ }
+
+ break;
+ default:
+ goto error;
+ }
+
+ _save_mode(priv);
+
+ viewmgr_pop(priv->vmgr);
+
+ return;
+
+error:
+ _show_confirm_popup(priv);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* When the 'Retry' button is clicked, retry to connect to the network.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] event Event information
+*/
+static void _retry_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *event)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+
+ _del_confirm_popup(priv);
+
+ elm_object_focus_set(priv->ok_btn, EINA_TRUE);
+
+ _config_network(priv);
+}
+
+/**
+ * Shows the confirm ctxpopup.
+ *
+ * Decides to connect the network again or cancel it.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _show_confirm_popup(struct _priv *priv)
+{
+ Evas_Object *layout;
+ Evas_Object *retry_btn, *cancel_btn;
+ char content[CONTENT_TXT_SIZE];
+
+ if (!priv) {
+ _ERR("the param is NULL.");
+ return;
+ }
+
+ _set_layout_dim(priv);
+
+ layout = util_add_layout(priv->base, UG_NETWORK_EDJ_FILE,
+ GRP_CONFIRM_LAYOUT);
+ if (!layout) {
+ _ERR("add layout failed.");
+ _unset_layout_dim(priv);
+ return;
+ }
+
+ priv->confirm_popup = layout;
+
+ if (priv->network_type == TYPE_WIRED)
+ elm_object_part_text_set(layout,
+ PART_TEXT_TITLE, _(TXT_WIRED_LY));
+ else
+ elm_object_part_text_set(layout,
+ PART_TEXT_TITLE, _(TXT_WIRELESS_LY));
+
+ memset(content, 0, CONTENT_TXT_SIZE);
+ snprintf(content, CONTENT_TXT_SIZE - 1, "%s %s",
+ _(TXT_FAILED_CONNECT), priv->name);
+ elm_object_part_text_set(layout,
+ PART_TEXT_CONTENT, content);
+
+ retry_btn = util_add_button(layout,
+ STYLE_SETTING_BTN, PART_RETRY_BTN, _(TXT_RETRY));
+ if (!retry_btn) {
+ _ERR("util add button failed.");
+ evas_object_del(layout);
+ _unset_layout_dim(priv);
+ return;
+ }
+
+ cancel_btn = util_add_button(layout,
+ STYLE_SETTING_BTN, PART_CANCEL_BTN, _(TXT_CANCEL));
+ if (!cancel_btn) {
+ _ERR("util add button failed.");
+ evas_object_del(layout);
+ _unset_layout_dim(priv);
+ return;
+ }
+
+ elm_object_focus_next_object_set(retry_btn, cancel_btn,
+ ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(cancel_btn, retry_btn,
+ ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(cancel_btn, cancel_btn,
+ ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(retry_btn, retry_btn,
+ ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(cancel_btn, cancel_btn,
+ ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(retry_btn, retry_btn,
+ ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(cancel_btn, cancel_btn,
+ ELM_FOCUS_DOWN);
+ elm_object_focus_next_object_set(retry_btn, retry_btn,
+ ELM_FOCUS_DOWN);
+
+ evas_object_smart_callback_add(retry_btn, SIG_CLICKED,
+ _retry_btn_clicked_cb, priv);
+ evas_object_smart_callback_add(cancel_btn, SIG_CLICKED,
+ _popup_ok_cancel_btn_clicked_cb, priv);
+
+ elm_object_focus_set(retry_btn, EINA_TRUE);
+
+ elm_object_focus_allow_set(layout, EINA_TRUE);
+ evas_object_smart_callback_add(layout, SIG_UNFOCUSED,
+ _ctxpopup_unfocused_cb, priv);
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN,
+ _ctxpopup_pressed_cb, priv);
+
+ evas_object_move(layout, CENTER_ALIGN * (DEFAULT_WIN_WIDTH - POPUP_WIDTH) * ELM_SCALE,
+ CENTER_ALIGN * (DEFAULT_WIN_HEIGHT - POPUP_HEIGHT) * ELM_SCALE);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* Configs the network.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _ok_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+
+ _config_network(priv);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* Cancels to config the network, and pops the view.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _cancel_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+
+ if (priv && priv->vmgr)
+ viewmgr_pop(priv->vmgr);
+}
+
+/**
+ * Creates the action buttons.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _create_btns(struct _priv *priv)
+{
+ Evas_Object *base;
+ Evas_Object *ok_btn;
+ Evas_Object *cancel_btn;
+
+ if (!priv) {
+ _ERR("The param is invalid.\n");
+ return RET_FAILED;
+ }
+
+ base = priv->base;
+
+ ok_btn = util_add_button(base, STYLE_SETTING_BTN, NULL, _(TXT_OK));
+ if (!ok_btn) {
+ _ERR("Add button failed.\n");
+ return RET_FAILED;
+ }
+
+ elm_object_part_content_set(base, PART_CONNECTION_OK_BTN, ok_btn);
+ priv->ok_btn = ok_btn;
+ evas_object_smart_callback_add(ok_btn, SIG_CLICKED,
+ _ok_btn_clicked_cb, priv);
+
+ cancel_btn = util_add_button(base, STYLE_SETTING_BTN,
+ PART_CONNECTION_CANCEL_BTN, _(TXT_CANCEL));
+ if (!cancel_btn) {
+ _ERR("Add button failed.\n");
+ evas_object_del(ok_btn);
+ return RET_FAILED;
+ }
+
+ evas_object_smart_callback_add(cancel_btn, SIG_CLICKED,
+ _cancel_btn_clicked_cb, priv);
+
+ priv->cancel_btn = cancel_btn;
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Creates the dim layout.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _create_dim_layout(struct _priv *priv)
+{
+ Evas_Object *dim_ly;
+
+ if (!priv || !priv->win) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ dim_ly = util_add_layout(priv->win, UG_NETWORK_EDJ_FILE,
+ GRP_DIM_LY);
+ if (!dim_ly) {
+ _ERR("elm_layout_add() failed.\n");
+ return RET_FAILED;
+ }
+
+ priv->dim_ly = dim_ly;
+ _unset_layout_dim(priv);
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Callback for key pressed event.
+ *
+ * If the key is KEY_BACK, pops the view.
+ *
+ * @param[in] data User data
+ * @param[in] evas Evas handler
+ * @param[in] obj The corresponding object which the deletion event occurred
+ * @param[in] ei Event information
+ */
+static void _base_key_pressed_cb(void *data, Evas *evas,
+ Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _priv *priv;
+
+ if (!ei || !data) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ ev = ei;
+ priv = data;
+
+ if (!ev->keyname) {
+ _ERR("ev->keyname is NULL.");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_BACK)) {
+ viewmgr_pop(priv->vmgr);
+ return;
+ }
+}
+
+/**
+ * Creates the layout of the view.
+ *
+ * Called when the view is pushed.
+ *
+ * @param[in] vmgr The handler of view manager
+ * @param[in] data The passed data from main view
+ * @return layout if the operation is successful; NULL if failed;
+ */
+static Evas_Object *_create(struct viewmgr *vmgr, void *data)
+{
+ struct _priv *priv;
+ Evas_Object *base;
+ struct connection_info *info;
+ int ret;
+
+ if (!vmgr || !vmgr->win || !vmgr->ug || !data) {
+ _ERR("Parameter error!");
+ return NULL;
+ }
+
+ priv = _init_priv();
+ if (!priv) {
+ _ERR("init priv failed.");
+ return NULL;
+ }
+
+ priv->win = vmgr->win;
+ priv->ug = vmgr->ug;
+ priv->vmgr = vmgr;
+
+ info = data;
+ priv->connection = info->connection;
+ priv->network_type = info->cur_type;
+ priv->ap = info->ap;
+ strncpy(priv->name, info->name, MAX_NAME_SIZE - 1);
+
+ base = _create_basic_layout(priv->win);
+ if (!base) {
+ _ERR("Add main view failed.\n");
+ _fini_priv(priv);
+ return NULL;
+ }
+
+ evas_object_event_callback_add(base, EVAS_CALLBACK_KEY_DOWN,
+ _base_key_pressed_cb, priv);
+
+ priv->base = base;
+
+ evas_object_data_set(base, KEY_PRIV, priv);
+
+ _set_description(priv);
+
+ ret = _get_cur_mode(priv);
+ if (ret != RET_SUCCESS)
+ goto error;
+
+ ret = _get_cur_ip_info(priv);
+ if (ret != RET_SUCCESS)
+ goto error;
+
+ ret = _create_dns_setting(priv);
+ if (ret != RET_SUCCESS)
+ goto error;
+
+ ret = _create_btns(priv);
+ if (ret != RET_SUCCESS)
+ goto error;
+
+ ret = _create_ip_setting(priv);
+ if (ret != RET_SUCCESS)
+ goto error;
+
+ ret = _create_dim_layout(priv);
+ if (ret != RET_SUCCESS)
+ goto error;
+
+ return base;
+
+error:
+ evas_object_del(base);
+ _fini_priv(priv);
+
+ return NULL;
+}
+
+/**
+ * Destroies the layout of the view.
+ *
+ * Called when the view is popped.
+ *
+ * @param[in] base The base layout
+ */
+static void _destroy(Evas_Object *base)
+{
+ struct _priv *priv;
+
+ if (!base) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = evas_object_data_get(base, KEY_PRIV);
+ if (!priv)
+ return;
+
+ _fini_priv(priv);
+}
+
+/**
+ * Gets the current view type.
+ *
+ * @return view type;
+ */
+static enum view_type _get_view_type(void)
+{
+ return NETWORK_IP_SETTING_VIEW;
+}
+
+static struct view_class _vclass = {
+ .create = _create,
+ .resume = NULL,
+ .pause = NULL,
+ .terminate = _destroy,
+ .message_handler = NULL,
+ .get_view_type = _get_view_type,
+};
+
+/**
+ * Gets the current view class.
+ *
+ * @return view class;
+ */
+struct view_class *ip_setting_view_vclass_get(void)
+{
+ return &_vclass;
+}
diff --git a/ug/network/src/main_view.c b/ug/network/src/main_view.c
new file mode 100644
index 0000000..54f32b3
--- /dev/null
+++ b/ug/network/src/main_view.c
@@ -0,0 +1,2543 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <Elementary.h>
+#include <aul.h>
+
+#include <KeyDefine.h>
+
+#include "defs.h"
+#include "dbg.h"
+#include "main_view.h"
+#include "vconf_mgr.h"
+#include "ip_setting_view.h"
+#include "connection_mgr.h"
+#include "i18n.h"
+#include "wifi_mgr.h"
+#include "common.h"
+#include "wifi_passcode_view.h"
+#include "util.h"
+
+#define BTN_ACT 4
+#define BTN_TYPE 2
+#define TIMER_INTERNAL 0.1
+
+#define KEY_PRIV "priv"
+
+#define TYPE_POPUP_X_OFFSET 190
+
+enum action_btn_enum {
+ CONNECT,
+ REFRESH,
+ OTHER,
+ CLOSE
+};
+
+static char *action_button[] = {
+ [CONNECT] = TXT_CONNECT_BTN,
+ [REFRESH] = TXT_REFRESH_BTN,
+ [OTHER] = TXT_OTHER_BTN,
+ [CLOSE] = TXT_CLOSE_BTN
+};
+
+static char *button_swallow[] = {
+ [CONNECT] = PART_CONNECT_BTN,
+ [REFRESH] = PART_REFRESH_BTN,
+ [OTHER] = PART_OTHER_BTN,
+ [CLOSE] = PART_CLOSE_BTN
+};
+
+static char *popup_button[] = {
+ [TYPE_WIRELESS] = TXT_WIRELESS,
+ [TYPE_WIRED] = TXT_WIRED
+};
+
+struct _priv {
+ ui_gadget_h ug;
+ struct viewmgr *vmgr;
+
+ Evas_Object *win;
+ Evas_Object *base;
+ Evas_Object *type_btn;
+ Evas_Object *network_ctxpopup;
+ Evas_Object *dim_ly;
+ Evas_Object *connect_btn;
+ Evas_Object *refresh_btn;
+ Evas_Object *other_btn;
+ Evas_Object *close_btn;
+ Evas_Object *genlist;
+ Evas_Object *wired_con_box;
+ Evas_Object *wireless_discon_ly;
+ Evas_Object *wired_discon_ly;
+ Evas_Object *status_popup;
+
+ Elm_Genlist_Item_Class *lock_ic;
+ Elm_Genlist_Item_Class *nolock_ic;
+ Elm_Object_Item *last_item;
+
+ Eina_List *ap_list;
+ Ecore_Timer *timer;
+
+ enum network_type_enum network_type;
+ enum view_type cur_view;
+
+ int wifi_init;
+ Eina_Bool wifi_conn;
+ Eina_Bool wired_conn;
+
+ connection_h connection;
+ connection_profile_h profile;
+ char profile_name[MAX_NAME_SIZE];
+
+ wifi_ap_h ap;
+ char *ap_name;
+ char *ap_pwd;
+};
+
+static void _show_confirm_popup(struct _priv *priv);
+static void _show_progress_popup(struct _priv *priv);
+
+/**
+* Initialize the priv
+*
+* Called when initialize the network
+*
+* @return the _priv object initialized
+*/
+static struct _priv *_init_priv()
+{
+ struct _priv *priv;
+
+ priv = calloc(1, sizeof(*priv));
+ if (!priv) {
+ _ERR("calloc priv failed.");
+ return NULL;
+ }
+
+ return priv;
+}
+
+/**
+* Finalize the priv
+*
+* Called when app is destroyed
+*
+* @param[in] priv the _priv object
+*/
+static void _fini_priv(struct _priv *priv)
+{
+ void *data;
+
+ if (!priv)
+ return;
+
+ if (priv->lock_ic)
+ elm_genlist_item_class_free(priv->lock_ic);
+
+ if (priv->nolock_ic)
+ elm_genlist_item_class_free(priv->nolock_ic);
+
+ if (priv->ap_list)
+ EINA_LIST_FREE(priv->ap_list, data)
+ free(data);
+
+ if (priv->dim_ly)
+ evas_object_del(priv->dim_ly);
+
+ if (priv->timer)
+ ecore_timer_del(priv->timer);
+
+ connection_mgr_destroy(priv->connection);
+
+ if (priv->ap)
+ wifi_mgr_ap_destroy(priv->ap);
+
+ free(priv->ap_name);
+ free(priv->ap_pwd);
+
+ wifi_mgr_deinit();
+
+ free(priv);
+}
+
+/**
+* Eable the "Connect" button
+*
+* @param[in] priv _priv object bypassed
+*/
+static void _enable_connect_btn(struct _priv *priv)
+{
+ if (!priv || !priv->connect_btn) {
+ _ERR("The param is invalid.");
+ return;
+ }
+
+ elm_object_disabled_set(priv->connect_btn, EINA_FALSE);
+}
+
+/**
+* Disable the "Connect" button
+*
+* @param[in] priv _priv object bypassed
+*/
+static void _disable_connect_btn(struct _priv *priv)
+{
+ if (!priv || !priv->connect_btn) {
+ _ERR("The param is invalid.");
+ return;
+ }
+
+ elm_object_disabled_set(priv->connect_btn, EINA_TRUE);
+}
+
+/**
+* Enable the "Other" button
+*
+* @param[in] priv _priv object bypassed
+*/
+static void _enable_other_btn(struct _priv *priv)
+{
+ if (!priv || !priv->other_btn) {
+ _ERR("The param is invalid.");
+ return;
+ }
+
+ elm_object_disabled_set(priv->other_btn, EINA_FALSE);
+}
+
+/**
+* Disable the "Other" button
+*
+* @param[in] priv _priv object bypassed
+*/
+static void _disable_other_btn(struct _priv *priv)
+{
+ if (!priv || !priv->other_btn) {
+ _ERR("The param is invalid.");
+ return;
+ }
+
+ elm_object_disabled_set(priv->other_btn, EINA_TRUE);
+}
+
+/**
+* Enable the dim effect
+*
+* Called when popup is displayed
+*
+* @param[in] priv _priv object bypassed
+*/
+static void _set_layout_dim(struct _priv *priv)
+{
+ if (!priv || !priv->dim_ly) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ evas_object_show(priv->dim_ly);
+}
+
+/**
+* Disable the dim effect
+*
+* This function is the opposite action of the set_layout_dim
+*
+* @param[in] priv _priv object bypassed
+*/
+static void _unset_layout_dim(struct _priv *priv)
+{
+ if (!priv || !priv->dim_ly) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ evas_object_hide(priv->dim_ly);
+}
+
+/**
+* Evas_object_Event_Cb type callback for handling delection event
+*
+* @param[in] data the user data
+* @param[in] e evas handler
+* @param[in] obj the corresponding object which clicked event occurred
+* @param[in] ei event information
+*/
+static void _ctxpopup_pressed_cb(void *data, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _priv *priv;
+
+ if (!data || !ei || !obj) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+ ev = ei;
+
+ if (!ev->keyname) {
+ _ERR("ev->keyname is NULL.");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_BACK)) {
+ _unset_layout_dim(priv);
+ evas_object_del(obj);
+ }
+}
+
+/**
+* Delete the connection progress popup when connection successed or failed
+*
+* @param[in] priv _priv object bypassed
+*/
+static void _del_status_popup(struct _priv *priv)
+{
+ if (!priv) {
+ _ERR("priv is NULL.");
+ return;
+ }
+
+ _unset_layout_dim(priv);
+
+ if (priv->status_popup)
+ evas_object_del(priv->status_popup);
+
+ priv->status_popup = NULL;
+}
+
+/**
+* Evas_Object_Event_Cb type callback for handling back event
+*
+* This function delete the ug when EVAS_CALLBACK_KEY_DOWN happens
+*
+* @param[in] data the user data
+* @param[in] e evas handler
+* @param[in] obj the corresponding object which clicked event occurred
+* @param[in] ei event information
+*/
+static void _main_ly_key_pressed_cb(void *data, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _priv *priv;
+
+ if (!data || !ei) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+ ev = ei;
+
+ if (!ev->keyname) {
+ _ERR("ev->keyname is NULL.");
+ return;
+ }
+
+ if (!priv->ug)
+ return;
+
+ if (!strcmp(ev->keyname, KEY_BACK))
+ ug_destroy_me(priv->ug);
+}
+
+/**
+* Create the base layout
+*
+* Called by _create when network is invoked
+*
+* @param[in] priv _priv object bypassed
+*/
+static Evas_Object *_create_main_layout(struct _priv *priv)
+{
+ Evas_Object *base;
+
+ if (!priv) {
+ _ERR("Parameter error!");
+ return NULL;
+ }
+
+ base = util_add_layout(priv->win, UG_NETWORK_EDJ_FILE, GRP_MAIN);
+ if (!base) {
+ _ERR("Add pannel view failed.\n");
+ return NULL;
+ }
+
+ evas_object_event_callback_add(base, EVAS_CALLBACK_KEY_DOWN,
+ _main_ly_key_pressed_cb, priv);
+
+ evas_object_show(base);
+
+ return base;
+}
+
+/**
+* Refresh the object of the defined part
+*
+* @param[in] priv _priv object bypassed
+* @param[in] obj the Evas_Object to be setted to the part
+*/
+static void _fill_content_part(struct _priv *priv, Evas_Object *obj)
+{
+ Evas_Object *old_obj;
+
+ if (!priv || !obj || !priv->base) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ old_obj = elm_object_part_content_get(priv->base, PART_NETLIST_PANNEL);
+ if (old_obj == obj) {
+ _ERR("PART_NETLIST_PANNEL already filled with this object.");
+ return;
+ }
+
+ if (old_obj) {
+ elm_object_part_content_unset(priv->base, PART_NETLIST_PANNEL);
+ evas_object_hide(old_obj);
+ }
+
+ elm_object_part_content_set(priv->base, PART_NETLIST_PANNEL, obj);
+
+ evas_object_show(obj);
+}
+
+/**
+* Refresh the buttons of the correct position
+*
+* Called when the view type is changed
+*
+* @param[in] priv _priv object bypassed
+*/
+static void _set_action_btn_pos(struct _priv *priv)
+{
+ Evas_Object *base;
+ Evas_Object *btn;
+
+ if (!priv || !priv->base) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ base = priv->base;
+
+ btn = elm_object_part_content_get(base, button_swallow[CONNECT]);
+ if (!btn) {
+ elm_object_part_content_set(base, button_swallow[CONNECT],
+ priv->connect_btn);
+ evas_object_show(priv->connect_btn);
+ }
+
+ btn = elm_object_part_content_get(base, button_swallow[REFRESH]);
+ if (btn) {
+ elm_object_part_content_unset(base, button_swallow[REFRESH]);
+ evas_object_hide(btn);
+ }
+
+ btn = elm_object_part_content_get(base, button_swallow[OTHER]);
+ if (btn) {
+ elm_object_part_content_unset(base, button_swallow[OTHER]);
+ evas_object_hide(btn);
+ }
+
+ btn = elm_object_part_content_get(base, button_swallow[CLOSE]);
+ if (btn) {
+ elm_object_part_content_unset(base, button_swallow[CLOSE]);
+ evas_object_hide(btn);
+ }
+
+ if (priv->network_type == TYPE_WIRELESS) {
+ if (!priv->wifi_conn) {
+ elm_object_part_content_set(base,
+ button_swallow[REFRESH],
+ priv->other_btn);
+ evas_object_show(priv->other_btn);
+
+ elm_object_part_content_set(base, button_swallow[OTHER],
+ priv->close_btn);
+ evas_object_show(priv->close_btn);
+ } else {
+ elm_object_part_content_set(base,
+ button_swallow[REFRESH],
+ priv->refresh_btn);
+ evas_object_show(priv->refresh_btn);
+
+ elm_object_part_content_set(base, button_swallow[OTHER],
+ priv->other_btn);
+ evas_object_show(priv->other_btn);
+
+ elm_object_part_content_set(base, button_swallow[CLOSE],
+ priv->close_btn);
+ evas_object_show(priv->close_btn);
+ }
+
+ if (priv->ap) {
+ elm_object_disabled_set(priv->other_btn, EINA_FALSE);
+ elm_object_disabled_set(priv->connect_btn, EINA_FALSE);
+ } else {
+ elm_object_disabled_set(priv->connect_btn, EINA_TRUE);
+ elm_object_disabled_set(priv->other_btn, EINA_TRUE);
+ }
+ } else if (priv->network_type == TYPE_WIRED) {
+ if (!priv->wired_conn) {
+ elm_object_disabled_set(priv->connect_btn, EINA_TRUE);
+ elm_object_disabled_set(priv->other_btn, EINA_TRUE);
+ } else {
+ elm_object_disabled_set(priv->connect_btn, EINA_FALSE);
+ elm_object_disabled_set(priv->other_btn, EINA_FALSE);
+ }
+
+ elm_object_part_content_set(base, button_swallow[REFRESH],
+ priv->other_btn);
+ evas_object_show(priv->other_btn);
+
+ elm_object_part_content_set(base, button_swallow[OTHER],
+ priv->close_btn);
+ evas_object_show(priv->close_btn);
+ }
+}
+
+/**
+* Get the connection profile infomation
+*
+* @param[in] priv _priv object bypassed
+* @return 0 on success,otherwise -1
+*/
+static int _get_connection_profile_info(struct _priv *priv)
+{
+ struct connection_info info;
+ int ret;
+
+ if (!priv) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ret = connection_mgr_get_profile_info(priv->connection, &info);
+ if (ret != RET_SUCCESS) {
+ _ERR("connection_mgr_get_profile_info() failed.");
+ return RET_FAILED;
+ }
+
+ priv->profile = info.profile;
+ strncpy(priv->profile_name, info.name, MAX_NAME_SIZE - 1);
+
+ return RET_SUCCESS;
+}
+
+/**
+* Callback function to set content to list panel
+*
+* Depending on different ethernet, set corresponding connection state
+* view to the list panel
+*
+* @param[in] priv _priv object bypassed
+*/
+#if 0
+static void _connection_ethernet_state_callback(
+ connection_ethernet_cable_state_e state, void *data)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("data is NULL.");
+ return;
+ }
+
+ priv = data;
+
+ if (priv->network_type != TYPE_WIRED) {
+ _ERR("cur network type is wireless, return.");
+ return;
+ }
+
+ if (state == CONNECTION_ETHERNET_CABLE_ATTACHED) {
+ _fill_content_part(priv, priv->wired_con_box);
+ } else if (state == CONNECTION_ETHERNET_CABLE_DETACHED) {
+ _fill_content_part(priv, priv->wired_discon_ly);
+
+ priv->wired_conn = EINA_FALSE;
+ }
+
+ _set_action_btn_pos(priv);
+}
+#endif
+
+/**
+* Initialize the connection information
+*
+* @param[in] priv _priv object bypassed
+* @return 0 on success,otherwise -1
+*/
+static int _init_connection(struct _priv *priv)
+{
+ int ret = RET_FAILED;
+
+ if (!priv) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ priv->connection = connection_mgr_create();
+ if (!priv->connection) {
+ _ERR("connection_mgr_create() failed.");
+ return RET_FAILED;
+ }
+
+#if 0
+ ret = connection_mgr_register_ethernet_state_cb
+ (priv->connection,
+ _connection_ethernet_state_callback,
+ priv);
+#endif
+ if (ret != RET_SUCCESS) {
+ _ERR("register_ethernet_state_cb() failed.");
+ return RET_FAILED;
+ }
+
+ ret = _get_connection_profile_info(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("_get_connection_profile_info() failed.");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* Create the layout when no network cable plugin
+*
+* @param[in] priv _priv object bypassed
+* @return 0 on success,otherwise -1
+*/
+static int _create_wired_disconnect_part(struct _priv *priv)
+{
+ Evas_Object *disconnect_ly;
+
+ if (!priv || !priv->base) {
+ _ERR("the param is NULL.\n");
+ return RET_FAILED;
+ }
+
+ disconnect_ly = util_add_layout(priv->base,
+ UG_NETWORK_EDJ_FILE, GRP_WIRED_DISCONNECTED_LY);
+ if (!disconnect_ly) {
+ _ERR("call elm_layout_add() failed.\n");
+ return RET_FAILED;
+ }
+
+ elm_object_part_text_set(disconnect_ly, PART_DISCONNECT_TEXT,
+ _(TXT_PLUG_CABLE));
+
+ evas_object_hide(disconnect_ly);
+
+ priv->wired_discon_ly = disconnect_ly;
+
+ return RET_SUCCESS;
+}
+
+/**
+* Callback function when profile button is clicked
+*
+* This function disable/enable the relating buttons according to the connection state
+*
+* @param[in] data the user data
+* @param[in] obj the corresponding object which clicked event occurred
+* @param[in] event_inf event information
+*/
+static void _profie_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *event_inf)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+
+ if (priv->wired_conn) {
+ elm_object_signal_emit(obj, SIG_STATE_UNSELECTED, ELM);
+ priv->wired_conn = EINA_FALSE;
+ _disable_connect_btn(priv);
+ _disable_other_btn(priv);
+ } else {
+ elm_object_signal_emit(obj, SIG_STATE_SELECTED, ELM);
+ priv->wired_conn = EINA_TRUE;
+ _enable_connect_btn(priv);
+ _enable_other_btn(priv);
+ }
+}
+
+/**
+* Create the layout when wired connect successful
+*
+* @param[in] priv _priv object bypassed
+* @return 0 on success,otherwise -1
+*/
+static int _create_wired_connect_part(struct _priv *priv)
+{
+ Evas_Object *box;
+ Evas_Object *btn;
+
+ if (!priv || !priv->base) {
+ _ERR("the param is NULL.\n");
+ return RET_FAILED;
+ }
+
+ box = util_add_box(priv->base, NULL);
+ if (!box) {
+ _ERR("add wired connect box failed.");
+ return RET_FAILED;
+ }
+
+ elm_box_horizontal_set(box, EINA_FALSE);
+
+ btn = util_add_button(box, STYLE_WIRED_LIST_BTN, NULL,
+ _(priv->profile_name));
+ if (!btn) {
+ _ERR("elm_button_add failed.\n");
+ evas_object_del(box);
+ return RET_FAILED;
+ }
+
+ evas_object_size_hint_align_set(btn, 0, 0);
+ evas_object_smart_callback_add(btn, SIG_CLICKED,
+ _profie_btn_clicked_cb, priv);
+ if (priv->wired_conn)
+ elm_object_signal_emit(btn, SIG_STATE_SELECTED, ELM);
+ elm_box_pack_end(box, btn);
+ elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT);
+ evas_object_hide(box);
+
+ priv->wired_con_box = box;
+
+ return RET_SUCCESS;
+}
+
+/**
+* Display the wired view when select the wired network type
+*
+* This fuction is called when the wired of the network type popup is clicked
+*
+* @param[in] priv _priv object bypassed
+* @return 0 on success,otherwise -1
+*/
+static int _display_wired_setting(struct _priv *priv)
+{
+ Eina_Bool plugin;
+ int ret;
+
+ if (!priv) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ _create_wired_connect_part(priv);
+
+ _create_wired_disconnect_part(priv);
+
+ ret = connection_mgr_get_ethernet_state(priv->connection,
+ &plugin);
+ if (ret != RET_SUCCESS) {
+ _ERR("connection_mgr_get_ethernet_state() failed.");
+ plugin = EINA_FALSE;
+ }
+
+ if (plugin) {
+ _fill_content_part(priv, priv->wired_con_box);
+ } else {
+ priv->wired_conn = EINA_FALSE;
+ _fill_content_part(priv, priv->wired_discon_ly);
+ }
+
+ _set_action_btn_pos(priv);
+
+ return RET_SUCCESS;
+}
+
+/**
+* Create the layout when wireless connect successful
+*
+* @param[in] priv _priv object bypassed
+* @return 0 on success,otherwise -1
+*/
+static void _create_wireless_disconnect_part(struct _priv *priv)
+{
+ Evas_Object *disconnect_ly;
+
+ if (!priv) {
+ _ERR("the param is invalid.");
+ return;
+ }
+
+ if (priv->wireless_discon_ly)
+ return;
+
+ disconnect_ly = util_add_layout(priv->base,
+ UG_NETWORK_EDJ_FILE, GRP_WIRELESS_DISCONNECT_LY);
+ if (!disconnect_ly) {
+ _ERR("call elm_layout_add() failed.\n");
+ return;
+ }
+
+ elm_object_part_text_set(disconnect_ly, PART_DISCONNECT_TEXT,
+ TXT_NO_NETWORK);
+
+ evas_object_hide(disconnect_ly);
+
+ priv->wireless_discon_ly = disconnect_ly;
+}
+
+/**
+* Callback funcion called to get the text name of the added item
+*
+* This function return the strdup'()ed string of the added genlist item
+*
+* @param[in] data the user data
+* @param[in] obj the genlist object
+* @param[in] part the part text
+* @return strdup'()ed string on success ,NULL otherwise
+*/
+static char *_item_ap_name_get(void *data, Evas_Object *obj, const char *part)
+{
+ struct wifi_ap_info *ap_info;
+
+ if (!data || !obj || !part) {
+ _ERR("Parameter error!");
+ return NULL;
+ }
+
+ ap_info = data;
+
+ if (!strcmp(part, PART_ELM_TEXT))
+ return strdup(ap_info->essid);
+
+ return NULL;
+}
+
+/**
+* Create a new genlist item class in a given genlist widget
+*
+* @param[in] style the genlist style set to the item
+* @return new allocated genlist item class
+*/
+static Elm_Genlist_Item_Class *_create_item_class(char *style)
+{
+ Elm_Genlist_Item_Class *ic;
+
+ if (!style) {
+ _ERR("the param is invalid.");
+ return NULL;
+ }
+
+ ic = elm_genlist_item_class_new();
+ if (!ic) {
+ _ERR("elm_genlist_item_class_new() failed.");
+ return NULL;
+ }
+
+ ic->item_style = style;
+ ic->func.text_get = _item_ap_name_get;
+ ic->func.content_get = NULL;
+ ic->func.state_get = NULL;
+ ic->func.del = NULL;
+
+ return ic;
+}
+
+/**
+* Create the genlist item class for both locked and unlocked
+*
+* @param[in] priv the data _priv structure bypassed
+*/
+static void _create_genlist_item_class(struct _priv *priv)
+{
+ Elm_Genlist_Item_Class *ic;
+
+ if (!priv) {
+ _ERR("the param is invalid.");
+ return;
+ }
+
+ ic = _create_item_class(STYLE_ITEM_LOCK);
+ if (!ic) {
+ _ERR("get item class failed.");
+ return;
+ }
+
+ priv->lock_ic = ic;
+
+ ic = _create_item_class(STYLE_ITEM_NOLOCK);
+ if (!ic) {
+ _ERR("get item class failed.");
+ return;
+ }
+
+ priv->nolock_ic = ic;
+}
+
+/**
+* Create the genlist view
+*
+* This function create the genlist item class and genlist widget
+*
+* @param[in] priv _priv object bypassed
+* @return the genlist object in success,NULL otherwise
+*/
+static Evas_Object *_create_genlist_view(struct _priv *priv)
+{
+ Evas_Object *genlist;
+
+ if (!priv) {
+ _ERR("Parameter error!");
+ return NULL;
+ }
+
+ _create_genlist_item_class(priv);
+
+ genlist = util_add_genlist(priv->base);
+ if (!genlist) {
+ _ERR("util_add_genlist() failed.\n");
+ return NULL;
+ }
+
+ priv->genlist = genlist;
+
+ elm_object_focus_next_object_set(genlist, genlist, ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(genlist, priv->close_btn,
+ ELM_FOCUS_RIGHT);
+
+ return genlist;
+}
+
+/**
+* Callback function called when a certain genlist item is clicked
+*
+* @param[in] data the user data
+* @param[in] obj the corresponding item which clicked event occurred
+* @param[in] event_inf event information
+*/
+static void _item_select_cb(void *data, Evas_Object *obj, void *ei)
+{
+ struct _priv *priv;
+ Elm_Object_Item *gen_item;
+ struct wifi_ap_info *ap_info;
+ int index;
+
+ if (!data || !ei) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+ gen_item = ei;
+
+ if (priv->last_item == gen_item) {
+ elm_object_item_signal_emit(gen_item, SIG_STATE_UNSELECTED, ELM);
+
+ _disable_connect_btn(priv);
+ _disable_other_btn(priv);
+
+ priv->last_item = NULL;
+
+ return;
+ }
+
+ elm_object_item_signal_emit(gen_item, SIG_STATE_SELECTED, ELM);
+ if (priv->last_item)
+ elm_object_item_signal_emit(priv->last_item,
+ SIG_STATE_UNSELECTED, ELM);
+ priv->last_item = gen_item;
+
+ _enable_connect_btn(priv);
+ _enable_other_btn(priv);
+
+ index = elm_genlist_item_index_get(priv->last_item);
+ if (index < 0) {
+ _ERR("the index of item is invalid.");
+ return;
+ }
+
+ ap_info = eina_list_nth(priv->ap_list, index);
+ if (!ap_info) {
+ _ERR("ap info is NULL.");
+ return;
+ }
+
+ if (priv->ap_name) {
+ free(priv->ap_name);
+ priv->ap_name = NULL;
+ }
+
+ priv->ap_name = strdup(ap_info->essid);
+ if (!priv->ap_name) {
+ _ERR("ap name gets failed.");
+ return;
+ }
+
+ if (priv->ap) {
+ wifi_mgr_ap_destroy(priv->ap);
+ priv->ap = NULL;
+ }
+
+ wifi_mgr_ap_clone(&priv->ap, ap_info->ap);
+ if (!priv->ap) {
+ _ERR("ap clone failed.");
+ return;
+ }
+
+ if (ap_info->secure_type == WIFI_SECURITY_TYPE_NONE) {
+ if (priv->ap_pwd) {
+ free(priv->ap_pwd);
+ priv->ap_pwd = NULL;
+ }
+ }
+}
+
+/**
+* Effect the connected state when timer is empired
+*
+* @param[in]data the user data
+* @return ECORE_CALLBACK_CANCEL returns to finish time
+*/
+static Eina_Bool _select_connected_cb(void *data)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ priv = data;
+
+ elm_object_item_signal_emit(priv->last_item, SIG_STATE_SELECTED, ELM);
+ _enable_connect_btn(priv);
+ _enable_other_btn(priv);
+
+ priv->timer = NULL;
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+/**
+*This is a callback function called when you get the found access point repeatedly
+*
+* The ap valid only here. if use outside the function, must wifi_mgr_ap_clone() to clone it
+*
+* @param[in] ap the access point
+* @param[in] data the user data
+* @return 0 to continue with the next iterator of the loop,-1 to break
+*/
+static bool _wifi_found_ap_cb(wifi_ap_h ap, void *data)
+{
+ int ret;
+ bool state;
+ struct _priv *priv;
+ struct wifi_ap_info *ap_info;
+ Elm_Object_Item *item;
+
+ if (!ap || !data) {
+ _ERR("Parameter error!");
+ return EINA_FALSE;
+ }
+
+ priv = data;
+
+ ret = wifi_mgr_is_activated(&state);
+ if (ret != WIFI_ERROR_NONE || state == 0) {
+ _ERR("failt to wifi_is_activated");
+ return EINA_FALSE;
+ }
+
+ ap_info = calloc(1, sizeof(*ap_info));
+ if (!ap_info) {
+ _ERR("calloc failed");
+ return EINA_FALSE;
+ }
+
+ wifi_mgr_get_ap_info(ap, ap_info);
+
+ ap_info->ap = ap;
+ ap_info->user_data = priv;
+ priv->ap_list = eina_list_append(priv->ap_list, ap_info);
+
+ _fill_content_part(priv, priv->genlist);
+
+ if (ap_info->secure_type == WIFI_SECURITY_TYPE_NONE)
+ item = elm_genlist_item_append(priv->genlist, priv->nolock_ic,
+ ap_info, NULL, ELM_GENLIST_ITEM_NONE,
+ _item_select_cb, priv);
+ else
+ item = elm_genlist_item_append(priv->genlist, priv->lock_ic,
+ ap_info, NULL, ELM_GENLIST_ITEM_NONE,
+ _item_select_cb, priv);
+ if (!item) {
+ _ERR("genlist append item failed.");
+ return EINA_FALSE;
+ }
+
+ if (ap_info->state == WIFI_CONNECTION_STATE_CONNECTED) {
+ priv->last_item = item;
+ if (priv->ap) {
+ wifi_mgr_ap_destroy(priv->ap);
+ priv->ap = NULL;
+ }
+
+ wifi_mgr_ap_clone(&priv->ap, ap);
+
+ priv->timer = ecore_timer_add(TIMER_INTERNAL,
+ _select_connected_cb, priv);
+ if (!priv->timer) {
+ _ERR("add timer failed.");
+ return EINA_FALSE;
+ }
+ }
+
+ return EINA_TRUE;
+}
+
+/**
+* Scan the wifi access point
+*
+* @param[in] error_code the wifi error type
+* @param[in] data the user data
+*/
+static void _wifi_scan_request_cb(wifi_error_e error_code, void *data)
+{
+ int ret;
+
+ if (!data) {
+ _ERR("data is NULL.");
+ return;
+ }
+
+ ret = wifi_mgr_foreach_found_aps(_wifi_found_ap_cb, data);
+ if (ret != RET_SUCCESS) {
+ _ERR("wifi_mgr_foreach_found_aps() failed.");
+ return;
+ }
+}
+
+/**
+* Callback function briefly called after wifi activated successfully
+*
+* @param[in] error_code the wifi activation error type
+* @param[in] data the user data
+*/
+static void _wifi_activated_cb(wifi_error_e result, void *data)
+{
+ struct _priv *priv;
+ int ret;
+
+ if (result != WIFI_ERROR_NONE) {
+ _ERR("Wi-Fi Activation Failed! error ==%s.\n",
+ wifi_mgr_error_dbg(result));
+ return;
+ }
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+
+ ret = wifi_mgr_scan_request(_wifi_scan_request_cb, data);
+ if (ret != RET_SUCCESS) {
+ _ERR("wifi_mgr_scan_request() failed.");
+ _fill_content_part(priv, priv->wireless_discon_ly);
+ _set_action_btn_pos(priv);
+ return;
+ }
+
+ priv->wifi_conn = EINA_TRUE;
+
+ _set_action_btn_pos(priv);
+
+ _fill_content_part(priv, priv->genlist);
+}
+
+/**
+* Clear the genlist item list.
+*
+* Called when need clear the ap list,eg.refrsh button is clicked
+*
+* @param[in] priv _priv object bypassed
+*/
+static void _clear_genlist_item_list(struct _priv *priv)
+{
+ void *temp;
+
+ if (!priv || !priv->genlist) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ elm_genlist_clear(priv->genlist);
+
+ if (priv->ap_list)
+ EINA_LIST_FREE(priv->ap_list, temp)
+ free(temp);
+}
+
+/**
+* Display the wireless view when select the wireless network type
+*
+* Called when the wireless of the network type popup is clicked
+*
+* @param[in] priv _priv object bypassed
+* @return 0 on success,otherwise -1
+*/
+static int _display_wireless_setting(struct _priv *priv)
+{
+ Evas_Object *obj;
+ bool activated;
+ int ret;
+
+ if (!priv) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ _create_wireless_disconnect_part(priv);
+
+ if (!priv->wifi_init) {
+ obj = _create_genlist_view(priv);
+ if (!obj) {
+ _ERR("fail to create genlist");
+ return RET_FAILED;
+ }
+
+ ret = wifi_mgr_init();
+ if (ret != RET_SUCCESS) {
+ _ERR("fail to init wifi network");
+ return RET_FAILED;
+ }
+
+ priv->wifi_init = 1;
+ }
+
+ _clear_genlist_item_list(priv);
+
+ activated = EINA_FALSE;
+ ret = wifi_mgr_is_activated(&activated);
+ if (ret != RET_SUCCESS) {
+ _ERR("the wifi is not activated.");
+ return RET_FAILED;
+ }
+
+ if (activated) {
+ if (priv->ap) {
+ wifi_mgr_ap_destroy(priv->ap);
+ priv->ap = NULL;
+ }
+
+ ret = wifi_mgr_scan_request(_wifi_scan_request_cb,
+ (void *)priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("wifi_mgr_scan_request() failed.");
+ goto _wireless_finish;
+ }
+
+ priv->wifi_conn = EINA_TRUE;
+ } else {
+ priv->wifi_conn = EINA_FALSE;
+
+ ret = wifi_mgr_activate(_wifi_activated_cb, (void *)priv);
+ if (ret != RET_SUCCESS)
+ _ERR("wifi_mgr_activate() failed.");
+ }
+
+_wireless_finish:
+ _fill_content_part(priv, priv->wireless_discon_ly);
+ _set_action_btn_pos(priv);
+
+ return RET_SUCCESS;
+}
+
+/**
+* Refresh the text content below the network type button
+*
+* Called to set the network type name according to the network type currently
+*
+* @param[in] priv _priv object bypassed
+*/
+static void _refresh_network_type_text(struct _priv *priv)
+{
+ if (!priv) {
+ _ERR("the param is invalid.");
+ return;
+ }
+
+ switch (priv->network_type) {
+ case TYPE_WIRELESS:
+ elm_object_part_text_set(priv->base,
+ PART_CUR_TYPE_TEXT,
+ _(TXT_WIRELESS_NETWORK));
+ elm_object_part_text_set(priv->type_btn,
+ PART_NETWORK_TYPE_SELECTED,
+ _(TXT_WIRELESS));
+ break;
+ case TYPE_WIRED:
+ elm_object_part_text_set(priv->base,
+ PART_CUR_TYPE_TEXT, _(TXT_WIRED_NETWORK));
+ elm_object_part_text_set(priv->type_btn,
+ PART_NETWORK_TYPE_SELECTED, _(TXT_WIRED));
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+* Callback function when popup type button is clicked
+*
+* This fuction set the current network type according to the clicked button text
+*
+* @param[in] priv _priv object bypassed
+*/
+static void _type_select_btn_cb(void *data,
+ Evas_Object *obj, void *event_inf)
+{
+ struct _priv *priv;
+ const char *value;
+
+ if (!data || !obj) {
+ _ERR("the param is invalid.");
+ return;
+ }
+
+ priv = data;
+
+ value = elm_object_text_get(obj);
+ if (!value) {
+ _ERR("get text from network type btn is NULL.");
+ return;
+ }
+
+ if ((!strcmp(value, _(popup_button[TYPE_WIRELESS])))
+ && priv->network_type == TYPE_WIRED) {
+ priv->network_type = TYPE_WIRELESS;
+
+ _display_wireless_setting(priv);
+ vconf_mgr_set_network_type(TYPE_WIRELESS);
+ } else if ((!strcmp(value, _(popup_button[TYPE_WIRED])))
+ && priv->network_type == TYPE_WIRELESS) {
+ priv->network_type = TYPE_WIRED;
+
+ _display_wired_setting(priv);
+ vconf_mgr_set_network_type(TYPE_WIRED);
+ }
+
+ _refresh_network_type_text(priv);
+
+ if (priv->network_ctxpopup) {
+ evas_object_del(priv->network_ctxpopup);
+ priv->network_ctxpopup = NULL;
+ }
+
+ _unset_layout_dim(priv);
+}
+
+/**
+* Evas_Object_Event_Cb type callback for handling back event
+*
+* @param[in] data the user data
+* @param[in] e evas handler
+* @param[in] o the corresponding object which clicked event occurred
+* @param[in] ei event information
+*/
+static void _type_key_pressed_cb(void *data,
+ Evas *evas, Evas_Object *o, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _priv *priv;
+
+ if (!ei || !data) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+ ev = ei;
+
+ if (!ev->keyname) {
+ _ERR("ev->keyname is NULL.");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_BACK)) {
+ _unset_layout_dim(priv);
+
+ if (priv->network_ctxpopup) {
+ evas_object_del(priv->network_ctxpopup);
+ priv->network_ctxpopup = NULL;
+ }
+
+ return;
+ }
+}
+
+/**
+* Evas_Smart_Cb type callback for handling clicked event
+*
+* @param[in] data the user data
+* @param[in] obj the corresponding object which clicked event occurred
+* @param[in] event_inf event information
+*/
+static void _network_type_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *event_inf)
+{
+ struct _priv *priv;
+ Evas_Object *base;
+ Evas_Object *layout, *box;
+ Evas_Object *btn[BTN_TYPE];
+ Evas_Coord x;
+ Evas_Coord y;
+ Evas_Coord w;
+ Evas_Coord h;
+ int i;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+ base = priv->base;
+
+ _set_layout_dim(priv);
+
+ layout = util_add_layout(base, UG_NETWORK_EDJ_FILE,
+ GRP_NETWORK_TYPE_SELECT);
+ if (!layout) {
+ _ERR("util_add_layout() failed.\n");
+ return;
+ }
+
+ box = util_add_box(layout, PART_SWALLOW_CONTENT);
+ if (!box) {
+ evas_object_del(layout);
+ return;
+ }
+
+ evas_object_size_hint_weight_set(box,
+ EVAS_HINT_EXPAND, 0);
+
+ for (i = 0; i < BTN_TYPE; i++) {
+ btn[i] = util_add_button(box, STYLE_POPUP_BTN, NULL,
+ _(popup_button[i]));
+ if (!btn[i]) {
+ evas_object_del(layout);
+ return;
+ }
+
+ elm_box_pack_end(box, btn[i]);
+
+ evas_object_smart_callback_add(btn[i], SIG_CLICKED,
+ _type_select_btn_cb, priv);
+ }
+
+ if (priv->network_type == TYPE_WIRELESS)
+ elm_object_signal_emit(btn[TYPE_WIRELESS],
+ SIG_BTN_SELECTED, PROG);
+ else
+ elm_object_signal_emit(btn[TYPE_WIRED],
+ SIG_BTN_SELECTED, PROG);
+
+ elm_object_part_content_set(layout, PART_SWALLOW_CONTENT, box);
+
+ elm_object_focus_next_object_set(btn[1], btn[0], ELM_FOCUS_DOWN);
+ elm_object_focus_next_object_set(btn[0], btn[1], ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(btn[1], btn[0], ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(btn[0], btn[1], ELM_FOCUS_DOWN);
+ elm_object_focus_next_object_set(btn[0], btn[0], ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(btn[0], btn[0], ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(btn[1], btn[1], ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(btn[1], btn[1], ELM_FOCUS_RIGHT);
+
+ x = 0;
+ y = 0;
+ w = 0;
+ h = 0;
+ evas_object_geometry_get(priv->type_btn, &x, &y, &w, &h);
+ evas_object_move(layout, (x + w - TYPE_POPUP_X_OFFSET) * ELM_SCALE,
+ (y + h) * ELM_SCALE);
+
+ priv->network_ctxpopup = layout;
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN,
+ _type_key_pressed_cb, priv);
+
+ elm_object_focus_set(btn[0], EINA_TRUE);
+ evas_object_show(layout);
+}
+
+/**
+* Create the upper part for the base view
+*
+* @param[in] priv _priv object bypassed
+* @return 0 on success,-1 otherwise
+*/
+static int _create_upper_layout(struct _priv *priv)
+{
+ Evas_Object *type_btn;
+ Evas_Object *base;
+
+ if (!priv || !priv->base) {
+ _ERR("Parameter error!");
+ return RET_FAILED;
+ }
+
+ base = priv->base;
+
+ elm_object_part_text_set(base, PART_SELECT_TEXT, _(TXT_NETWORK_DISC));
+
+ type_btn = util_add_button(base, STYLE_TYPE_BTN, PART_NETWORK_TYPE,
+ _(TXT_TYPE_BTN));
+ if (!type_btn)
+ return RET_FAILED;
+
+ evas_object_smart_callback_add(type_btn, SIG_CLICKED,
+ _network_type_btn_clicked_cb, priv);
+
+ elm_object_focus_next_object_set(type_btn, type_btn, ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(type_btn, type_btn, ELM_FOCUS_LEFT);
+
+ priv->type_btn = type_btn;
+
+ elm_object_focus_set(type_btn, EINA_TRUE);
+
+ _refresh_network_type_text(priv);
+
+ return RET_SUCCESS;
+}
+
+/**
+* Callback function briefly called after wifi connected successfully
+*
+* @param[in] error_code the wifi activation error type
+* @param[in] user_data the user data
+*/
+static void _wifi_connected_cb(wifi_error_e error_code, void *user_data)
+{
+ struct _priv *priv;
+
+ if (!user_data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = user_data;
+
+ if (!priv->status_popup)
+ return;
+
+ if (error_code != WIFI_ERROR_NONE) {
+ _ERR("connect AP failed.");
+ _show_confirm_popup(priv);
+ return;
+ }
+
+ ug_destroy_me(priv->ug);
+}
+
+/**
+* Connect to the selected wifi access point
+*
+* @param[in] priv _priv object bypassed
+* @param[in] index the index of the access point
+* @return 0 on success, otherwise -1
+*/
+static int _wifi_connect_ap(struct _priv *priv, int index)
+{
+ struct wifi_ap_info *ap_info;
+ int ret;
+
+ if (!priv || index < 0) {
+ _ERR("Parameter error!");
+ return RET_FAILED;
+ }
+
+ _show_progress_popup(priv);
+
+ ap_info = eina_list_nth(priv->ap_list, index);
+ if (!ap_info) {
+ _ERR("ap info is NULL.");
+ return RET_FAILED;
+ }
+
+ if (priv->ap_name) {
+ free(priv->ap_name);
+ priv->ap_name = NULL;
+ }
+
+ priv->ap_name = strdup(ap_info->essid);
+ if (!priv->ap_name) {
+ _ERR("ap name gets failed.");
+ return RET_FAILED;
+ }
+
+ if (ap_info->secure_type == WIFI_SECURITY_TYPE_NONE) {
+ if (priv->ap_pwd) {
+ free(priv->ap_pwd);
+ priv->ap_pwd = NULL;
+ }
+ } else {
+ priv->cur_view = NETWORK_WIFI_PASSCODE_VIEW;
+ viewmgr_push(priv->vmgr,
+ wifi_passcode_view_vclass_get(),
+ ap_info);
+
+ return RET_SUCCESS;
+ }
+
+ ret = wifi_mgr_forget_last_ap();
+ if (ret != RET_SUCCESS) {
+ _ERR("forget last ap failed.");
+ return RET_FAILED;
+ }
+
+ if (priv->ap_pwd) {
+ ret = wifi_mgr_set_passphrase(priv->ap,
+ priv->ap_pwd);
+ if (ret != RET_SUCCESS) {
+ _ERR("wifi_mgr_set_passphrase() failed.");
+ return RET_FAILED;
+ }
+ }
+
+ ret = wifi_mgr_connect(priv->ap, _wifi_connected_cb, priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("Fail to connection request.\n");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* Convert connection error type code to the corresponding string
+*
+* @param[in] err_code the connection error type
+* @return the error description string
+*/
+#if 0
+static const char *_convert_error_to_string(connection_error_e err_type)
+{
+ switch (err_type) {
+ case CONNECTION_ERROR_NONE:
+ return "NONE";
+ case CONNECTION_ERROR_INVALID_PARAMETER:
+ return "INVALID_PARAMETER";
+ case CONNECTION_ERROR_OUT_OF_MEMORY:
+ return "OUT_OF_MEMORY";
+ case CONNECTION_ERROR_INVALID_OPERATION:
+ return "INVALID_OPERATION";
+ case CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
+ return "ADDRESS_FAMILY_NOT_SUPPORTED";
+ case CONNECTION_ERROR_OPERATION_FAILED:
+ return "OPERATION_FAILED";
+ case CONNECTION_ERROR_ITERATOR_END:
+ return "ITERATOR_END";
+ case CONNECTION_ERROR_NO_CONNECTION:
+ return "NO_CONNECTION";
+ case CONNECTION_ERROR_NOW_IN_PROGRESS:
+ return "NOW_IN_PROGRESS";
+ case CONNECTION_ERROR_ALREADY_EXISTS:
+ return "ALREADY_EXISTS";
+ case CONNECTION_ERROR_OPERATION_ABORTED:
+ return "OPERATION_ABORTED";
+ case CONNECTION_ERROR_DHCP_FAILED:
+ return "DHCP_FAILED";
+ case CONNECTION_ERROR_INVALID_KEY:
+ return "INVALID_KEY";
+ case CONNECTION_ERROR_NO_REPLY:
+ return "NO_REPLY";
+ case CONNECTION_ERROR_NO_KEYWORD:
+ return "NO_KEYWORD";
+ case CONNECTION_ERROR_TCP_RST:
+ return "RST_IN_TCP_RESPONSE";
+ case CONNECTION_ERROR_TCP_SYN_TIMEOUT:
+ return "TCP_SYN_TIMEOUT";
+ case CONNECTION_ERROR_OFFLINE:
+ return "CONNECTION_OFFLINE";
+ case CONNECTION_ERROR_NETWORK_MONITOR_FAILURE:
+ return "monitor failer";
+ case CONNECTION_ERROR_INVALID_GATEWAY:
+ return "invalid gateway";
+ case CONNECTION_ERROR_INVALID_MACADDRESS:
+ return "invalid mac addr";
+ default:
+ break;
+ }
+
+ return "Unknown";
+}
+#endif
+
+/**
+* Callback function called by _connection_check_gateway_async_cb()
+*
+* Called after checking whether the profile can access to the internet asynchronously
+*
+* @param[in] result the connection error type
+* @param[in] data the user data
+*/
+#if 0
+static void _connection_get_is_online_async_cb(
+ connection_error_e result, void *data)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("the param is invalid.");
+ return;
+ }
+
+ priv = data;
+
+ if (result != CONNECTION_ERROR_NONE) {
+ _ERR("connection result: %s.",
+ _convert_error_to_string(result));
+ _show_confirm_popup(priv);
+ } else {
+ ug_destroy_me(priv->ug);
+ }
+}
+
+/**
+* Check whether the profile can access to the internet asynchronously
+*
+* @param[in] result the connection error type
+* @param[in] data the user data
+*/
+static void _connection_check_gateway_async_cb(
+ connection_error_e result, void *data)
+{
+ struct _priv *priv;
+ int ret;
+
+ if (!data) {
+ _ERR("the param is invalid.");
+ return;
+ }
+
+ priv = data;
+
+ if (result != CONNECTION_ERROR_NONE) {
+ _ERR("connection result: %s.",
+ _convert_error_to_string(result));
+ _show_confirm_popup(priv);
+ } else {
+ ret = connection_mgr_get_is_online_async(priv->connection,
+ _connection_get_is_online_async_cb,
+ (void *)priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("connection_mgr_get_is_online_async() failed.");
+ return;
+ }
+ }
+}
+#endif
+
+/**
+* Write the connection information saved last time to the profile
+*
+* @param[in] priv _priv object bypassed
+* @return 0 on success, otherwize -1
+*/
+static int _connection_set_last_network(struct _priv *priv)
+{
+ int ret;
+ enum setting_mode ip_mode;
+ struct network_info info;
+
+ if (!priv) {
+ _ERR("the param is NULL.");
+ return RET_FAILED;
+ }
+
+ ret = vconf_mgr_get_wired_ip_mode(&ip_mode);
+ if (ret != RET_SUCCESS) {
+ _ERR("get wired ip mode from vconf failed.");
+ return ret;
+ }
+
+ if (ip_mode == MODE_AUTO) {
+ ret = connection_mgr_ip_dynamic_config(priv->connection,
+ priv->profile);
+ if (ret != RET_SUCCESS) {
+ _ERR("connection_mgr_ip_dynamic_config() failed.");
+ return ret;
+ }
+ } else {
+ ret = vconf_mgr_get_wired_network_info(&info);
+ if (ret != RET_SUCCESS) {
+ _ERR("vconf_mgr_get_wired_network_info() failed.");
+ return ret;
+ }
+
+ ret = connection_mgr_set_profile(priv->connection,
+ priv->profile, &info);
+ if (ret != RET_SUCCESS) {
+ _ERR("set profile failed.");
+ return ret;
+ }
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* Proccess the wired network connection
+*
+* @param[in] priv _priv object bypassed
+* @return 0 on success, otherwise -1
+*/
+static int _wired_connect_proc(struct _priv *priv)
+{
+ int ret;
+
+ if (!priv) {
+ _ERR("the param is NULL.");
+ return RET_FAILED;
+ }
+
+ _show_progress_popup(priv);
+
+ _get_connection_profile_info(priv);
+
+ ret = _connection_set_last_network(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("_connection_set_last_network() failed.");
+ return ret;
+ }
+
+ _DBG("Not Yet");
+#if 0
+ ret = connection_mgr_check_gateway_async(priv->profile,
+ _connection_check_gateway_async_cb, (void *)priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("connection_mgr_get_is_online_async() failed.");
+ return ret;
+ }
+#endif
+
+ return RET_SUCCESS;
+}
+
+/**
+* Process the network connection
+*
+* @param[in] priv _priv object bypassed
+*/
+static void _connect_network(struct _priv *priv)
+{
+ int index;
+ int ret;
+
+ if (!priv) {
+ _ERR("the param is NULL.");
+ return;
+ }
+
+ if (priv->network_type == TYPE_WIRELESS) {
+ if (priv->last_item) {
+ index = elm_genlist_item_index_get(priv->last_item);
+
+ ret = _wifi_connect_ap(priv, index);
+ if (ret != RET_SUCCESS) {
+ _ERR("connect ap");
+ _show_confirm_popup(priv);
+ return;
+ }
+ }
+ } else {
+ ret = _wired_connect_proc(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("connect ap");
+ _show_confirm_popup(priv);
+ return;
+ }
+ }
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling click event
+*
+* @param[in] data the user data
+* @param[in] obj the corresponding object which the click event occurred
+* @param[in] event event information
+*/
+static void _retry_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *event)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+
+ _del_status_popup(priv);
+
+ _connect_network(priv);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling click event.
+*
+* @param[in] data the user data
+* @param[in] obj the corresponding object which the click event occurred
+* @param[in] event event information
+*/
+static void _cancel_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *event)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+
+ _del_status_popup(priv);
+
+ elm_object_focus_set(priv->connect_btn, EINA_TRUE);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling unfocus event
+*
+* @param[in] data the user data
+* @param[in] obj the corresponding object which the unfocus event occurred
+* @param[in] source event information
+*/
+static void _ctxpopup_unfocused_cb(void *data,
+ Evas_Object *obj, void *source)
+{
+ struct _priv *priv;
+
+ if (!data || !obj) {
+ _ERR("data is NULL.\n");
+ return;
+ }
+
+ priv = data;
+
+ _unset_layout_dim(priv);
+
+ evas_object_del(obj);
+}
+
+/**
+* Called when confirm information popup is shown
+*
+* @param[in] priv _priv object bypassed
+*/
+static void _show_confirm_popup(struct _priv *priv)
+{
+ Evas_Object *layout;
+ Evas_Object *retry_btn;
+ Evas_Object *cancel_btn;
+ // Evas_Coord w;
+ // Evas_Coord h;
+ char content[CONTENT_TXT_SIZE];
+
+ if (!priv) {
+ _ERR("the param is NULL.");
+ return;
+ }
+
+ if (priv->status_popup)
+ _del_status_popup(priv);
+
+ _set_layout_dim(priv);
+
+ layout = util_add_layout(priv->base, UG_NETWORK_EDJ_FILE,
+ GRP_CONFIRM_LAYOUT);
+ if (!layout) {
+ _ERR("add layout failed.");
+ _unset_layout_dim(priv);
+ return;
+ }
+
+ evas_object_show(layout);
+
+ memset(content, 0, CONTENT_TXT_SIZE);
+ if (priv->network_type == TYPE_WIRED) {
+ elm_object_part_text_set(layout,
+ PART_TEXT_TITLE, _(TXT_WIRED_LY));
+ snprintf(content, CONTENT_TXT_SIZE - 1, "%s %s",
+ _(TXT_FAILED_CONNECT), _(priv->profile_name));
+ } else {
+ elm_object_part_text_set(layout,
+ PART_TEXT_TITLE, _(TXT_WIRELESS_LY));
+ snprintf(content, CONTENT_TXT_SIZE - 1, "%s %s",
+ _(TXT_FAILED_CONNECT), priv->ap_name);
+ }
+
+ elm_object_part_text_set(layout,
+ PART_TEXT_CONTENT, content);
+
+ retry_btn = util_add_button(layout, STYLE_SETTING_BTN,
+ PART_RETRY_BTN, _(TXT_RETRY));
+ if (!retry_btn) {
+ _ERR("util add button failed.");
+ evas_object_del(layout);
+ _unset_layout_dim(priv);
+ return;
+ }
+
+ cancel_btn = util_add_button(layout, STYLE_SETTING_BTN,
+ PART_CANCEL_BTN, _(TXT_CANCEL));
+ if (!cancel_btn) {
+ _ERR("util add button failed.");
+ evas_object_del(layout);
+ _unset_layout_dim(priv);
+ return;
+ }
+
+ elm_object_focus_next_object_set(retry_btn, cancel_btn,
+ ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(cancel_btn, retry_btn,
+ ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(cancel_btn, cancel_btn,
+ ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(retry_btn, retry_btn,
+ ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(cancel_btn, cancel_btn,
+ ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(retry_btn, retry_btn,
+ ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(cancel_btn, cancel_btn,
+ ELM_FOCUS_DOWN);
+ elm_object_focus_next_object_set(retry_btn, retry_btn,
+ ELM_FOCUS_DOWN);
+
+ evas_object_smart_callback_add(retry_btn, SIG_CLICKED,
+ _retry_btn_clicked_cb, priv);
+ evas_object_smart_callback_add(cancel_btn, SIG_CLICKED,
+ _cancel_btn_clicked_cb, priv);
+
+ elm_object_focus_set(retry_btn, EINA_TRUE);
+
+ elm_object_focus_allow_set(layout, EINA_TRUE);
+ evas_object_smart_callback_add(layout, SIG_UNFOCUSED,
+ _ctxpopup_unfocused_cb, priv);
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN,
+ _ctxpopup_pressed_cb, priv);
+
+ evas_object_move(layout, CENTER_ALIGN * (DEFAULT_WIN_WIDTH - POPUP_WIDTH) * ELM_SCALE,
+ CENTER_ALIGN * (DEFAULT_WIN_HEIGHT - POPUP_HEIGHT) * ELM_SCALE);
+
+ priv->status_popup = layout;
+}
+
+/**
+* Called when connect a wifi device and show connection progress
+*
+* @param[in] priv _priv object to be finalized
+*/
+static void _show_progress_popup(struct _priv *priv)
+{
+ Evas_Object *layout;
+ Evas_Object *cancel_btn;
+ char content[CONTENT_TXT_SIZE];
+
+ if (!priv) {
+ _ERR("the param is NULL.");
+ return;
+ }
+
+ if (priv->status_popup)
+ _del_status_popup(priv);
+
+ _set_layout_dim(priv);
+
+ layout = util_add_layout(priv->base, UG_NETWORK_EDJ_FILE,
+ GRP_PROCESSING_LAYOUT);
+ if (!layout) {
+ _ERR("add layout failed.");
+ _unset_layout_dim(priv);
+ return;
+ }
+
+ evas_object_show(layout);
+
+ priv->status_popup = layout;
+
+ memset(content, 0, CONTENT_TXT_SIZE);
+ if (priv->network_type == TYPE_WIRED) {
+ elm_object_part_text_set(layout,
+ PART_TEXT_TITLE, _(TXT_WIRED_LY));
+ snprintf(content, CONTENT_TXT_SIZE - 1, "%s %s",
+ _(TXT_CONNECTTING), _(priv->profile_name));
+ } else {
+ elm_object_part_text_set(layout,
+ PART_TEXT_TITLE, _(TXT_WIRELESS_LY));
+ snprintf(content, CONTENT_TXT_SIZE - 1, "%s %s",
+ _(TXT_CONNECTTING), priv->ap_name);
+ }
+
+ elm_object_part_text_set(layout, PART_TEXT_CONTENT, content);
+
+ cancel_btn = util_add_button(layout, STYLE_SETTING_BTN,
+ PART_CANCEL_BTN, _(TXT_CANCEL));
+ if (!cancel_btn) {
+ _ERR("util add button failed.");
+ evas_object_del(layout);
+ _unset_layout_dim(priv);
+ return;
+ }
+
+ evas_object_show(cancel_btn);
+
+ elm_object_focus_next_object_set(cancel_btn, cancel_btn,
+ ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(cancel_btn, cancel_btn,
+ ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(cancel_btn, cancel_btn,
+ ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(cancel_btn, cancel_btn,
+ ELM_FOCUS_DOWN);
+
+ evas_object_smart_callback_add(cancel_btn, SIG_CLICKED,
+ _cancel_btn_clicked_cb, priv);
+
+ elm_object_focus_set(cancel_btn, EINA_TRUE);
+
+ elm_object_focus_allow_set(layout, EINA_TRUE);
+ evas_object_smart_callback_add(layout, SIG_UNFOCUSED,
+ _ctxpopup_unfocused_cb, priv);
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN,
+ _ctxpopup_pressed_cb, priv);
+
+ evas_object_move(layout, CENTER_ALIGN * (DEFAULT_WIN_WIDTH - POPUP_WIDTH) * ELM_SCALE,
+ CENTER_ALIGN * (DEFAULT_WIN_HEIGHT - POPUP_HEIGHT) * ELM_SCALE);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling click event
+*
+* @param[in] data the user data
+* @param[in] obj the corresponding object which the click event occurred
+* @param[in] event event information
+*/
+static void _connect_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *event)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+
+ _connect_network(priv);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling click event
+*
+* @param[in] data the user data
+* @param[in] obj the corresponding object which the click event occurred
+* @param[in] event event information
+*/
+static void _refresh_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *event)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+
+ _clear_genlist_item_list(priv);
+
+ _display_wireless_setting(priv);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling click event
+*
+* @param[in] data the user data
+* @param[in] obj the corresponding object which the click event occurred
+* @param[in] event event information
+*/
+static void _other_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *event)
+{
+ struct _priv *priv;
+ Evas_Object *base;
+ struct connection_info info;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+
+ priv->cur_view = NETWORK_IP_SETTING_VIEW;
+
+ info.cur_type = priv->network_type;
+ info.connection = priv->connection;
+
+ if (priv->network_type == TYPE_WIRED) {
+ strncpy(info.name, priv->profile_name,
+ MAX_NAME_SIZE - 1);
+ } else {
+ if (!priv->ap) {
+ _ERR("selected ap is NULL.");
+ return;
+ }
+
+ info.ap = priv->ap;
+
+ if (priv->ap_name)
+ strncpy(info.name, priv->ap_name,
+ MAX_NAME_SIZE - 1);
+ }
+
+ base = viewmgr_push(priv->vmgr,
+ ip_setting_view_vclass_get(), &info);
+ if (!base)
+ _ERR("add connection layout failed.");
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling click event
+*
+* @param[in] data the user data
+* @param[in] obj the corresponding object which the click event occurred
+* @param[in] event event information
+*/
+static void _close_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *event)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+
+ if (!priv->ug)
+ return;
+
+ ug_destroy_me(priv->ug);
+}
+
+/**
+* Create the action buttons such as "Connect" button and set to defined part
+*
+* @param[in] priv _priv object bypassed
+* @return 0 on success,otherwise -1
+*/
+static int _create_action_btns(struct _priv *priv)
+{
+ Evas_Object *bt[BTN_ACT];
+ Evas_Object *base;
+ int i;
+
+ if (!priv || !priv->base) {
+ _ERR("Parameter error!");
+ return RET_FAILED;
+ }
+
+ base = priv->base;
+
+ for (i = 0; i < BTN_ACT; i++) {
+ bt[i] = util_add_button(base, STYLE_ACTION_BTN,
+ button_swallow[i], _(action_button[i]));
+ if (!bt[i])
+ return RET_FAILED;
+ }
+
+ priv->connect_btn = bt[CONNECT];
+ priv->refresh_btn = bt[REFRESH];
+ priv->other_btn = bt[OTHER];
+ priv->close_btn = bt[CLOSE];
+
+ evas_object_hide(priv->refresh_btn);
+
+ evas_object_smart_callback_add(bt[CONNECT], SIG_CLICKED,
+ _connect_btn_clicked_cb, priv);
+ evas_object_smart_callback_add(bt[REFRESH], SIG_CLICKED,
+ _refresh_btn_clicked_cb, priv);
+ evas_object_smart_callback_add(bt[OTHER], SIG_CLICKED,
+ _other_btn_clicked_cb, priv);
+ evas_object_smart_callback_add(bt[CLOSE], SIG_CLICKED,
+ _close_btn_clicked_cb, priv);
+
+ _set_action_btn_pos(priv);
+
+ return RET_SUCCESS;
+}
+
+/**
+* Create the dim layout but didn't show it
+*
+* @param[in] priv _priv object bypassed
+* @return 0 on success,otherwise -1
+*/
+static int _create_dim_layout(struct _priv *priv)
+{
+ Evas_Object *dim_ly;
+
+ if (!priv || !priv->win) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ dim_ly = util_add_layout(priv->win, UG_NETWORK_EDJ_FILE, GRP_DIM_LY);
+ if (!dim_ly) {
+ _ERR("elm_layout_add() failed.\n");
+ return RET_FAILED;
+ }
+
+ priv->dim_ly = dim_ly;
+
+ _unset_layout_dim(priv);
+
+ return RET_SUCCESS;
+}
+
+/**
+* Create the base layout and initialize the network
+*
+* Called at the start of the application for initializing before the main loop start up
+*
+* @param[in] vmgr view manager object
+* @param[in] data the user data passed from the callback registration function
+* @return the base layout of network setting
+*/
+static Evas_Object *_create(struct viewmgr *vmgr, void *data)
+{
+ struct _priv *priv;
+ Evas_Object *base;
+ int ret;
+
+ if (!vmgr || !vmgr->win || !vmgr->ug) {
+ _ERR("Parameter error!");
+ return NULL;
+ }
+
+ priv = _init_priv();
+ if (!priv) {
+ _ERR("init priv failed.");
+ return NULL;
+ }
+
+ priv->win = vmgr->win;
+ priv->ug = vmgr->ug;
+ priv->vmgr = vmgr;
+
+ ret = _init_connection(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("create connection failed.");
+ _fini_priv(priv);
+ return NULL;
+ }
+
+ base = _create_main_layout(priv);
+ if (!base) {
+ _ERR("Add main view failed.\n");
+ _fini_priv(priv);
+ return NULL;
+ }
+
+ priv->base = base;
+
+ evas_object_data_set(base, KEY_PRIV, priv);
+
+ vconf_mgr_get_network_type(&priv->network_type);
+
+ ret = _create_upper_layout(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("create network type button failed.");
+ goto error;
+ }
+
+ if (priv->network_type == TYPE_WIRELESS)
+ ret = _display_wireless_setting(priv);
+ else if (priv->network_type == TYPE_WIRED)
+ ret = _display_wired_setting(priv);
+ else
+ ret = RET_FAILED;
+ if (ret != RET_SUCCESS)
+ goto error;
+
+ ret = _create_action_btns(priv);
+ if (ret != RET_SUCCESS)
+ goto error;
+
+ ret = _create_dim_layout(priv);
+ if (ret != RET_SUCCESS)
+ goto error;
+
+ return base;
+
+error:
+ evas_object_del(priv->base);
+ _fini_priv(priv);
+
+ return NULL;
+}
+
+/**
+* Resume the network ug
+*
+* @param[in] base the base layout which was initilized in the _create()
+*/
+static void _resume(Evas_Object *base)
+{
+ struct _priv *priv;
+
+ if (!base) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = evas_object_data_get(base, KEY_PRIV);
+ if (!priv) {
+ _ERR("priv got from base is NULL.");
+ return;
+ }
+
+ evas_object_show(base);
+
+ switch (priv->cur_view) {
+ case NETWORK_IP_SETTING_VIEW:
+ elm_object_focus_set(priv->other_btn, EINA_TRUE);
+ break;
+ case NETWORK_WIFI_PASSCODE_VIEW:
+ elm_object_focus_set(priv->connect_btn, EINA_TRUE);
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+* Handle the message sended
+*
+* @param[in] base the base layout which was initilized in the _create()
+* @param[in] message_id the id of the message sended
+* @param[in] data the user data
+*/
+static void _message_handler(Evas_Object *base,
+ enum message_id msg_id, void *data)
+{
+ struct _priv *priv;
+
+ if (!base) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = evas_object_data_get(base, KEY_PRIV);
+ if (!priv) {
+ _ERR("priv got from base is NULL.");
+ return;
+ }
+
+ if (msg_id == PASSCODE_DEVIVER) {
+ if (priv->ap_pwd)
+ free(priv->ap_pwd);
+ priv->ap_pwd = strdup((char *)data);
+ }
+}
+
+/**
+* Pause the network ug
+*
+* @param[in] base the base layout which was initilized in the _create()
+*/
+static void _pause(Evas_Object *base)
+{
+ if (!base) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ evas_object_hide(base);
+}
+
+/**
+* Destroy the network ug and release the resource
+*
+* @param[in] base the base layout which was initilized in the _create()
+*/
+static void _destroy(Evas_Object *base)
+{
+ struct _priv *priv;
+
+ if (!base) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = evas_object_data_get(base, KEY_PRIV);
+
+ _fini_priv(priv);
+}
+
+/**
+* Get the view type
+*
+* @return the view type
+*/
+static enum view_type _get_view_type(void)
+{
+ return NETWORK_MAIN_VIEW;
+}
+
+static struct view_class _vclass = {
+ .create = _create,
+ .pause = _pause,
+ .resume = _resume,
+ .terminate = _destroy,
+ .message_handler = _message_handler,
+ .get_view_type = _get_view_type,
+};
+
+/**
+* Get the network view class
+*
+* @return the view class
+*/
+struct view_class *main_view_vclass_get(void)
+{
+ return &_vclass;
+}
diff --git a/ug/network/src/network_viewmgr.c b/ug/network/src/network_viewmgr.c
new file mode 100644
index 0000000..4fe384c
--- /dev/null
+++ b/ug/network/src/network_viewmgr.c
@@ -0,0 +1,259 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <Elementary.h>
+#include <Eina.h>
+
+#include "network_viewmgr.h"
+#include "defs.h"
+#include "dbg.h"
+
+struct _viewinfo {
+ struct view_class *vclass;
+ Evas_Object *base;
+ enum view_type view_type;
+};
+
+/**
+ * Create and initialize the view manager.
+ *
+ * Called when app is created.
+ *
+ * @return View manager object
+ */
+struct viewmgr *viewmgr_init()
+{
+ struct viewmgr *vmgr;
+
+ vmgr = calloc(1, sizeof(*vmgr));
+ if (!vmgr) {
+ _ERR("calloc vmgr failed.");
+ return NULL;
+ }
+
+ return vmgr;
+}
+
+/**
+ * Finalize the view manager.
+ *
+ * Called when app is about to destroyed.
+ *
+ * @param[in] vmgr View manager object
+ */
+void viewmgr_fini(struct viewmgr *vmgr)
+{
+ int i;
+
+ if (!vmgr)
+ return;
+
+ for (i = eina_list_count(vmgr->vlist); i > 0; i--)
+ viewmgr_pop(vmgr);
+
+ free(vmgr);
+}
+
+/**
+ * Callback function for the view deleted event.
+ *
+ * Called when the view is deleted.
+ *
+ * @param[in] data The pointer to view class object
+ * @param[in] e The pointer of the evas canvas
+ * @param[in] obj The object that is deleted
+ * @param[in] ev The pointer of event info
+ */
+static void _view_deleted(void *data, Evas *e, Evas_Object *obj, void *ev)
+{
+ struct view_class *vclass;
+
+ if (!data || !obj)
+ return;
+
+ vclass = data;
+ if (vclass->terminate)
+ vclass->terminate(obj);
+}
+
+/**
+ * Push a view to the view manager.
+ *
+ * Called when one new view is to be pushed.
+ *
+ * @param[in] vmgr View manager object
+ * @param[in] vclass The specific view class for the view to be pushed
+ * @param[in] data User data
+ * @return base if the view is created successfully; NULL if failed;
+ */
+Evas_Object *viewmgr_push(struct viewmgr *vmgr,
+ struct view_class *vclass, void *data)
+{
+ struct _viewinfo *vinfo, *vinfo_pre;
+ Evas_Object *base;
+
+ if (!vmgr || !vmgr->win || !vclass || !vclass->create)
+ return NULL;
+
+ vinfo = calloc(1, sizeof(*vinfo));
+ if (!vinfo)
+ return NULL;
+
+ base = vclass->create(vmgr, data);
+ if (!base) {
+ free(vinfo);
+ return NULL;
+ }
+ evas_object_event_callback_add(base, EVAS_CALLBACK_DEL,
+ _view_deleted, vclass);
+
+ vinfo->base = base;
+ vinfo->vclass = vclass;
+ vinfo->view_type = vclass->get_view_type();
+
+ vinfo_pre = eina_list_data_get(vmgr->vlist);
+ if (vinfo_pre && vinfo_pre->base
+ && vinfo_pre->vclass->pause)
+ vinfo_pre->vclass->pause(vinfo_pre->base);
+
+ vmgr->vlist = eina_list_prepend(vmgr->vlist, vinfo);
+
+ return base;
+}
+
+/**
+ * Send a message between the views.
+ *
+ * Called when there is the information to pass.
+ *
+ * @param[in] vmgr View manager object
+ * @param[in] view_type The view type
+ * @param[in] msg_id Message ID
+ * @param[in] data User data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int viewmgr_send_message(struct viewmgr *vmgr,
+ enum view_type view_type,
+ enum message_id msg_id, void *data)
+{
+ struct _viewinfo *vinfo;
+ struct view_class *vclass;
+ Eina_List *list, *list_next;
+
+ if (!vmgr) {
+ _ERR("vmgr is NULL.");
+ return RET_FAILED;
+ }
+
+ EINA_LIST_FOREACH_SAFE(vmgr->vlist, list, list_next, vinfo) {
+ if (!vinfo) {
+ _ERR("vinfo is NULL.");
+ continue;
+ }
+
+ vclass = vinfo->vclass;
+
+ if (vinfo->view_type == view_type) {
+ if (vclass && vclass->message_handler)
+ vclass->message_handler(vinfo->base,
+ msg_id, data);
+
+ /*only support single message now, so break.*/
+ break;
+ }
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Pop a view from the view manager.
+ *
+ * Called when the top view is to be poped.
+ *
+ * @param[in] vmgr View manager object
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int viewmgr_pop(struct viewmgr *vmgr)
+{
+ struct _viewinfo *vinfo;
+
+ if (!vmgr || !vmgr->vlist) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ vinfo = eina_list_data_get(vmgr->vlist);
+ if (!vinfo) {
+ _ERR("eina_list_data_get() failed.");
+ return RET_FAILED;
+ }
+
+ vmgr->vlist = eina_list_remove_list(vmgr->vlist, vmgr->vlist);
+ viewmgr_resume(vmgr);
+
+ evas_object_del(vinfo->base);
+
+ free(vinfo);
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Resume a view with the view manager.
+ *
+ * When the top view is poped, and the next view has some
+ * specific state to be show, the function is called.
+ *
+ * @param[in] vmgr View manager object
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int viewmgr_resume(struct viewmgr *vmgr)
+{
+ struct _viewinfo *vinfo;
+ struct view_class *vclass;
+
+ if (!vmgr || !vmgr->vlist) {
+ _ERR("param is invalid.");
+ return RET_FAILED;
+ }
+
+ vinfo = eina_list_data_get(vmgr->vlist);
+ if (!vinfo || !vinfo->vclass || !vinfo->base) {
+ _ERR("vinfo, vinfo->vclass, or vinfo->base is NULL.");
+ return RET_FAILED;
+ }
+
+ vclass = vinfo->vclass;
+ if (vclass->resume)
+ vclass->resume(vinfo->base);
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Get the pointer of window.
+ *
+ * @param[in] vmgr View manager object
+ * @return win if the operation is successful; NULL if failed;
+ */
+Evas_Object *viewmgr_win_get(struct viewmgr *vmgr)
+{
+ if (!vmgr)
+ return NULL;
+
+ return vmgr->win;
+}
diff --git a/ug/network/src/ug_network_settings.cpp b/ug/network/src/ug_network_settings.c
index 78ad856..f3f38dc 100644
--- a/ug/network/src/ug_network_settings.cpp
+++ b/ug/network/src/ug_network_settings.c
@@ -18,25 +18,20 @@
#define UG_MODULE_API __attribute__ ((visibility("default")))
#endif
+#include <Elementary.h>
#include <ui-gadget-module.h>
#include "i18n.h"
#include "defs.h"
-#include <AppCommon.h>
-
-#include "wifi.h"
-#include "NetworkMainView.h"
-
-#if defined (__cplusplus)
-extern "C" {
-#endif
+#include "dbg.h"
+#include "main_view.h"
+#include "network_viewmgr.h"
struct _ug_data {
Evas_Object *win;
Evas_Object *base;
ui_gadget_h ug;
- CViewMgr *pViewMgr;
- CNetworkMainView *pNetworkMainView;
+ struct viewmgr *vmgr;
};
/**
@@ -62,19 +57,21 @@ static void *_on_create(ui_gadget_h ug, enum ug_mode mode,
service_h service, void *priv)
{
struct _ug_data *ugd;
+ Evas_Object *base;
Evas_Object *win;
+ struct viewmgr *vmgr;
if (!ug || !priv) {
_ERR("Parameter error!");
return NULL;
}
- ugd = (struct _ug_data *) priv;
+ ugd = priv;
ugd->ug = ug;
elm_theme_extension_add(NULL, UG_NETWORK_EDJ_THEME);
- win = (Evas_Object *) ug_get_window();
+ win = ug_get_window();
if (!win) {
_ERR("window get failed");
return NULL;
@@ -84,25 +81,27 @@ static void *_on_create(ui_gadget_h ug, enum ug_mode mode,
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
elm_win_focus_highlight_style_set(win, "invisible");
- CViewMgr::Initialize(ugd->win, NULL);
- ugd->pViewMgr = CViewMgr::GetInstance();
- if(!ugd->pViewMgr) {
- CViewMgr::Finalize();
- _ERR("Fail to get CViewMgr instance");
+ vmgr = viewmgr_init();
+ if (!vmgr) {
+ _ERR("init view mgr failed.\n");
return NULL;
}
- ugd->pNetworkMainView = new CNetworkMainView(NETWORK_MAINVIEW);
- if(!ugd->pViewMgr->AddView(ugd->pNetworkMainView)) {
- _ERR("Fail to add pFbBaseView");
- CViewMgr::Finalize();
- return false;
+ ugd->vmgr = vmgr;
+
+ vmgr->ug = ug;
+ vmgr->win = win;
+
+ base = viewmgr_push(vmgr, main_view_vclass_get(), NULL);
+ if (!base) {
+ _ERR("add base layout failed.");
+ viewmgr_fini(vmgr);
+ return NULL;
}
- ugd->pViewMgr->PushView(NETWORK_MAINVIEW, NULL);
- ugd->base = ugd->pNetworkMainView->Base();
- evas_object_raise(ugd->base);
+ ugd->base = base;
+ evas_object_raise(base);
- return ugd->base;
+ return base;
}
/**
@@ -173,7 +172,17 @@ static void _on_resume(ui_gadget_h ug, service_h service, void *priv)
*/
static void _on_destroy(ui_gadget_h ug, service_h service, void *priv)
{
- CViewMgr::Finalize();
+ struct _ug_data *ugd = priv;
+
+ if (!ug || !priv) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ if (!ugd || !ugd->base)
+ return;
+
+ viewmgr_fini(ugd->vmgr);
}
/**
@@ -250,7 +259,7 @@ UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
if (!ops)
return -1;
- ugd = (struct _ug_data *) calloc(1, sizeof(*ugd));
+ ugd = calloc(1, sizeof(*ugd));
if (!ugd)
return -1;
@@ -285,11 +294,7 @@ UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
if (!ops)
return;
- ugd = (struct _ug_data *) ops->priv;
+ ugd = ops->priv;
free(ugd);
}
-
-#if defined (__cplusplus)
-};
-#endif
diff --git a/ug/network/src/util.cpp b/ug/network/src/util.c
index a8888f8..926a634 100644
--- a/ug/network/src/util.cpp
+++ b/ug/network/src/util.c
@@ -19,7 +19,7 @@
#include <aul.h>
#include "i18n.h"
#include "defs.h"
-#include <MacroDefine.h>
+#include "dbg.h"
#include "util.h"
/**
diff --git a/ug/network/src/vconf_mgr.c b/ug/network/src/vconf_mgr.c
new file mode 100644
index 0000000..b4c72c8
--- /dev/null
+++ b/ug/network/src/vconf_mgr.c
@@ -0,0 +1,404 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "defs.h"
+#include "dbg.h"
+#include "vconf_mgr.h"
+#include "i18n.h"
+
+static const char *WIRED_DNS_LAST_MODE = "db/menu/network/wired_dns_mode";
+static const char *WIRED_IP_LAST_MODE = "db/menu/network/wired_ip_mode";
+static const char *WIRED_IP_KEY = "db/menu/network/wired_ip";
+static const char *WIRED_SUBMASK_KEY = "db/menu/network/wired_subnet";
+static const char *WIRED_GATEWAY_KEY = "db/menu/network/wired_gateway";
+static const char *WIRED_DNS_KEY = "db/menu/network/wired_dns";
+
+static const char *WIRELESS_IP_LAST_MODE = "db/menu/network/wireless_ip_mode";
+static const char *WIRELESS_DNS_LAST_MODE = "db/menu/network/wireless_dns_mode";
+static const char *WIRELESS_IP_KEY = "db/menu/network/wireless_ip";
+static const char *WIRELESS_SUBMASK_KEY = "db/menu/network/wireless_subnet";
+static const char *WIRELESS_GATEWAY_KEY = "db/menu/network/wireless_gateway";
+static const char *WIRELESS_DNS_KEY = "db/menu/network/wireless_dns";
+
+static const char *SELECTED_NETWORK_TYPE_KEY = "db/menu/network/network_type";
+
+/**
+ * Gets the network type.
+ *
+ * Gets the last network type from vconf.
+ *
+ * @param[out] network_type Network type
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int vconf_mgr_get_network_type(enum network_type_enum *network_type)
+{
+ const char *str;
+
+ if (!network_type) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ str = vconf_get_str(SELECTED_NETWORK_TYPE_KEY);
+ if (str && !strcmp(str, TXT_WIRED))
+ *network_type = TYPE_WIRED;
+ else
+ *network_type = TYPE_WIRELESS;
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets the network type.
+ *
+ * Sets the network type into vconf, so it can be used
+ * next time by calling vconf_mgr_get_network_type.
+ *
+ * @param[in] network_type Network type
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int vconf_mgr_set_network_type(enum network_type_enum network_type)
+{
+ switch (network_type) {
+ case TYPE_WIRED:
+ vconf_set_str(SELECTED_NETWORK_TYPE_KEY, TXT_WIRED);
+ break;
+ case TYPE_WIRELESS:
+ vconf_set_str(SELECTED_NETWORK_TYPE_KEY, TXT_WIRELESS);
+ break;
+ default:
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets the string value from the vconf.
+ *
+ * @param[out] des The string value
+ * @param[in] key Vconf key
+ */
+static void _get_info(char *des, const char *key)
+{
+ const char *str;
+
+ if (!des || !key)
+ return;
+
+ str = vconf_get_str(key);
+ if (!str)
+ return;
+
+ if (str == '\0' || !strncmp(str, NULL_STRING, IP_STRING_MAX_SIZE))
+ strncpy(des, _(ZERO_IP), IP_STRING_MAX_SIZE);
+ else
+ strncpy(des, str, IP_STRING_MAX_SIZE);
+}
+
+/**
+ * Gets wired network information.
+ *
+ * Including IP, submask, gateway and DNS.
+ *
+ * @param[out] info The structure of network information
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int vconf_mgr_get_wired_network_info(struct network_info *info)
+{
+ if (!info) {
+ _ERR("the param is NULL.");
+ return RET_FAILED;
+ }
+
+ _get_info(info->ip_addr, WIRED_IP_KEY);
+ _get_info(info->submask, WIRED_SUBMASK_KEY);
+ _get_info(info->gateway, WIRED_GATEWAY_KEY);
+ _get_info(info->dns, WIRED_DNS_KEY);
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets wireless network information.
+ *
+ * Including IP, submask, gateway and DNS.
+ *
+ * @param[out] info The structure of network information
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int vconf_mgr_get_wireless_network_info(struct network_info *info)
+{
+ if (!info) {
+ _ERR("the param is NULL.");
+ return RET_FAILED;
+ }
+
+ _get_info(info->ip_addr, WIRELESS_IP_KEY);
+ _get_info(info->submask, WIRELESS_SUBMASK_KEY);
+ _get_info(info->gateway, WIRELESS_GATEWAY_KEY);
+ _get_info(info->dns, WIRELESS_DNS_KEY);
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Saves wired network information into vconf.
+ *
+ * Including IP, submask, gateway and DNS.
+ *
+ * @param[in] info The structure of network information
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int vconf_mgr_save_wired_config_info(struct network_info *info)
+{
+ if (!info) {
+ _ERR("the param is NULL.");
+ return RET_FAILED;
+ }
+
+ vconf_set_str(WIRED_IP_KEY, info->ip_addr);
+ vconf_set_str(WIRED_SUBMASK_KEY, info->submask);
+ vconf_set_str(WIRED_GATEWAY_KEY, info->gateway);
+ vconf_set_str(WIRED_DNS_KEY, info->dns);
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Saves wireless network information into vconf.
+ *
+ * Including IP, submask, gateway and DNS.
+ *
+ * @param[in] info The structure of network information
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int vconf_mgr_save_wireless_config_info(struct network_info *info)
+{
+ if (!info) {
+ _ERR("the param is NULL.");
+ return RET_FAILED;
+ }
+
+ vconf_set_str(WIRELESS_IP_KEY, info->ip_addr);
+ vconf_set_str(WIRELESS_SUBMASK_KEY, info->submask);
+ vconf_set_str(WIRELESS_GATEWAY_KEY, info->gateway);
+ vconf_set_str(WIRELESS_DNS_KEY, info->dns);
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets the wired IP mode from vconf.
+ *
+ * The mode includes automatical and manual.
+ *
+ * @param[out] mode The enum of setting mode
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int vconf_mgr_get_wired_ip_mode(enum setting_mode *mode)
+{
+ const char *str;
+
+ if (!mode) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ str = vconf_get_str(WIRED_IP_LAST_MODE);
+ if (str && !strcmp(str, _(TXT_OBTAIN_AUTO)))
+ *mode = MODE_AUTO;
+ else
+ *mode = MODE_MAN;
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets the wired IP mode into vconf.
+ *
+ * The mode includes automatical and manual.
+ *
+ * @param[in] mode The enum of setting mode
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int vconf_mgr_set_wired_ip_mode(enum setting_mode mode)
+{
+ switch (mode) {
+ case MODE_AUTO:
+ vconf_set_str(WIRED_IP_LAST_MODE, _(TXT_OBTAIN_AUTO));
+ break;
+ case MODE_MAN:
+ vconf_set_str(WIRED_IP_LAST_MODE, _(TXT_ENTER_MAN));
+ break;
+ default:
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets the wired DNS mode from vconf.
+ *
+ * The mode includes automatical and manual.
+ *
+ * @param[out] mode The enum of setting mode
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int vconf_mgr_get_wired_dns_mode(enum setting_mode *mode)
+{
+ char *str;
+
+ if (!mode) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ str = vconf_get_str(WIRED_DNS_LAST_MODE);
+ if (str && !strcmp(str, _(TXT_OBTAIN_AUTO)))
+ *mode = MODE_AUTO;
+ else
+ *mode = MODE_MAN;
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets the wired DNS mode into vconf.
+ *
+ * The mode includes automatical and manual.
+ *
+ * @param[in] mode The enum of setting mode
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int vconf_mgr_set_wired_dns_mode(enum setting_mode mode)
+{
+ switch (mode) {
+ case MODE_AUTO:
+ vconf_set_str(WIRED_DNS_LAST_MODE, _(TXT_OBTAIN_AUTO));
+ break;
+ case MODE_MAN:
+ vconf_set_str(WIRED_DNS_LAST_MODE, _(TXT_ENTER_MAN));
+ break;
+ default:
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets the wireless IP mode from vconf.
+ *
+ * The mode includes automatical and manual.
+ *
+ * @param[out] mode The enum of setting mode
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int vconf_mgr_get_wireless_ip_mode(enum setting_mode *mode)
+{
+ char *str;
+
+ if (!mode) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ str = vconf_get_str(WIRELESS_IP_LAST_MODE);
+ if (str && !strcmp(str, _(TXT_OBTAIN_AUTO)))
+ *mode = MODE_AUTO;
+ else
+ *mode = MODE_MAN;
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets the wireless IP mode into vconf.
+ *
+ * The mode includes automatical and manual.
+ *
+ * @param[in] mode The enum of setting mode
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int vconf_mgr_set_wireless_ip_mode(enum setting_mode mode)
+{
+ switch (mode) {
+ case MODE_AUTO:
+ vconf_set_str(WIRELESS_IP_LAST_MODE, _(TXT_OBTAIN_AUTO));
+ break;
+ case MODE_MAN:
+ vconf_set_str(WIRELESS_IP_LAST_MODE, _(TXT_ENTER_MAN));
+ break;
+ default:
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets the wireless DNS mode from vconf.
+ *
+ * The mode includes automatical and manual.
+ *
+ * @param[out] mode The enum of setting mode
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int vconf_mgr_get_wireless_dns_mode(enum setting_mode *mode)
+{
+ char *str;
+
+ if (!mode) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ str = vconf_get_str(WIRELESS_DNS_LAST_MODE);
+ if (str && !strcmp(str, _(TXT_OBTAIN_AUTO)))
+ *mode = MODE_AUTO;
+ else
+ *mode = MODE_MAN;
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets the wireless DNS mode into vconf.
+ *
+ * The mode includes automatical and manual.
+ *
+ * @param[in] mode The enum of setting mode
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int vconf_mgr_set_wireless_dns_mode(enum setting_mode mode)
+{
+ switch (mode) {
+ case MODE_AUTO:
+ vconf_set_str(WIRELESS_DNS_LAST_MODE,
+ _(TXT_OBTAIN_AUTO));
+ break;
+ case MODE_MAN:
+ vconf_set_str(WIRELESS_DNS_LAST_MODE,
+ _(TXT_ENTER_MAN));
+ break;
+ default:
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
diff --git a/ug/network/src/wifi_mgr.c b/ug/network/src/wifi_mgr.c
new file mode 100644
index 0000000..7555aeb
--- /dev/null
+++ b/ug/network/src/wifi_mgr.c
@@ -0,0 +1,615 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <stdlib.h>
+#include "defs.h"
+#include "dbg.h"
+#include "wifi_mgr.h"
+
+/**
+ * Converts the error type to string information.
+ *
+ * @param[in] err_type Error type
+ * @return error string information;
+ */
+const char *wifi_mgr_error_dbg(wifi_error_e err_type)
+{
+ switch (err_type) {
+ case WIFI_ERROR_NONE:
+ return "NONE";
+ case WIFI_ERROR_INVALID_PARAMETER:
+ return "INVALID_PARAMETER";
+ case WIFI_ERROR_OUT_OF_MEMORY:
+ return "OUT_OF_MEMORY";
+ case WIFI_ERROR_INVALID_OPERATION:
+ return "INVALID_OPERATION";
+ case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
+ return "ADDRESS_FAMILY_NOT_SUPPORTED";
+ case WIFI_ERROR_OPERATION_FAILED:
+ return "OPERATION_FAILED";
+ case WIFI_ERROR_NO_CONNECTION:
+ return "NO_CONNECTION";
+ case WIFI_ERROR_NOW_IN_PROGRESS:
+ return "NOW_IN_PROGRESS";
+ case WIFI_ERROR_ALREADY_EXISTS:
+ return "ALREADY_EXISTS";
+ case WIFI_ERROR_OPERATION_ABORTED:
+ return "OPERATION_ABORTED";
+ case WIFI_ERROR_DHCP_FAILED:
+ return "DHCP_FAILED";
+ case WIFI_ERROR_INVALID_KEY:
+ return "INVALID_KEY";
+ case WIFI_ERROR_NO_REPLY:
+ return "NO_REPLY";
+ case WIFI_ERROR_SECURITY_RESTRICTED:
+ return "SECURITY_RESTRICTED";
+ default:
+ break;
+ }
+
+ return "UNKNOWN";
+}
+
+/**
+ * Initializes Wi-Fi.
+ *
+ * Called before using wifi APIs.
+ *
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_init(void)
+{
+ int ret;
+
+ ret = wifi_initialize();
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("Fail to wifi_initialize.\n");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Deinitializes Wi-Fi.
+ *
+ * Called when network setting is destroyed.
+ *
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_deinit(void)
+{
+ int ret;
+
+ ret = wifi_deinitialize();
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("Fail to wifi_deinitialize.\n");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Checks whether Wi-Fi is activated.
+ *
+ * @param[out] activated The activated value of wifi
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_is_activated(bool *activated)
+{
+ int ret;
+
+ ret = wifi_is_activated(activated);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("Fail to wifi_is_activated %s\n",
+ wifi_mgr_error_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Starts scan, asynchronously.
+ *
+ * Called if you want to get the ap list.
+ *
+ * @param[in] cb The callback function to be called
+ * @param[in] data User data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_scan_request(wifi_scan_finished_cb cb, void *data)
+{
+ int ret;
+
+ if (!cb || !data) {
+ _ERR("null pointer");
+ return RET_FAILED;
+ }
+
+ ret = wifi_scan(cb, data);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("Scan request failed [%s]\n",
+ wifi_mgr_error_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets the result of scan.
+ *
+ * Called in the callback of wifi_scan().
+ *
+ * @param[in] cb The callback function to be called
+ * @param[in] data User data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_foreach_found_aps(wifi_found_ap_cb cb, void *data)
+{
+ int ret;
+
+ if (!cb || !data) {
+ _ERR("null pointer");
+ return RET_FAILED;
+ }
+
+ ret = wifi_foreach_found_aps(cb, data);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("Fail to get AP list %s.\n", wifi_mgr_error_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Activates Wi-Fi, asynchronously.
+ *
+ * If the wireless adaptor is not activated, you should activate it first.
+ *
+ * @param[in] cb The callback function to be called
+ * @param[in] data User data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_activate(wifi_activated_cb cb, void *data)
+{
+ int ret;
+
+ if (!cb || !data) {
+ _ERR("null pointer");
+ return RET_FAILED;
+ }
+
+ ret = wifi_activate(cb, data);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("Fail to wifi_activate %s\n",
+ wifi_mgr_error_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets the handle of connected access point.
+ *
+ * You can get the connected access point and its configuration.
+ *
+ * @param[out] ap The handle of access point
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_get_connected_ap(wifi_ap_h *ap)
+{
+ int ret;
+
+ if (!ap) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ret = wifi_get_connected_ap(ap);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("wifi_get_connected_ap() failed.");
+ return ret;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Destroys the handle of access point.
+ *
+ * when you cloned an ap and don't use it later, you should destroy it.
+ *
+ * @param[in] ap The handle of access point
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_ap_destroy(wifi_ap_h ap)
+{
+ int ret;
+
+ if (!ap) {
+ _ERR("the ap is already NULL.");
+ return RET_SUCCESS;
+ }
+
+ ret = wifi_ap_destroy(ap);
+ if (ret != WIFI_ERROR_NONE)
+ ret = RET_FAILED;
+ else
+ ret = RET_SUCCESS;
+
+ return ret;
+}
+
+/**
+ * Clones the handle of access point.
+ *
+ * Copy the data of an ap.
+ *
+ * @param[out] cloned_ap The handle of access point to clone
+ * @param[in] origin The handle of access point to be cloned
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_ap_clone(wifi_ap_h *cloned_ap, wifi_ap_h origin)
+{
+ int ret;
+
+ if (!cloned_ap || !origin) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ret = wifi_ap_clone(cloned_ap, origin);
+ if (ret != WIFI_ERROR_NONE)
+ ret = RET_FAILED;
+ else
+ ret = RET_SUCCESS;
+
+ return ret;
+}
+
+/**
+ * Gets the data of access point.
+ *
+ * @param[in] ap The handle of access point
+ * @param[out] ap_info The structue to store the data of access point
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_get_ap_info(wifi_ap_h ap, struct wifi_ap_info *ap_info)
+{
+ char *str;
+
+ if (!ap || !ap_info) {
+ _ERR("null pointer");
+ return RET_FAILED;
+ }
+
+ str = NULL;
+ if (wifi_ap_get_essid(ap, &str) == WIFI_ERROR_NONE) {
+ _ERR("ESSID : %s\n", str);
+ strncpy(ap_info->essid, str, SSID_MAX_LENTH - 1);
+ free(str);
+ } else {
+ _ERR("Fail to get ESSID\n");
+ return RET_FAILED;
+ }
+
+ if (wifi_ap_get_connection_state(ap,
+ &ap_info->state) != WIFI_ERROR_NONE) {
+ _ERR("Fail to get Connection State\n");
+ return RET_FAILED;
+ }
+
+ if (wifi_ap_get_security_type(ap,
+ &ap_info->secure_type) != WIFI_ERROR_NONE) {
+ _ERR("Fail to get Security type\n");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Deletes the information of stored access point and disconnects it when it is connected.
+ *
+ * If an AP is connected, then connection information will be stored.
+ * This information is used when a connection to that AP is established automatically.
+ * If you want to connect another access point, you should desconnect the connected one.
+ *
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_forget_last_ap(void)
+{
+ int ret;
+ wifi_ap_h ap;
+ char *name;
+
+ ret = wifi_get_connected_ap(&ap);
+ if (ret == WIFI_ERROR_NO_CONNECTION) {
+ return RET_SUCCESS;
+ } else if (ret != WIFI_ERROR_NONE) {
+ _ERR("Fail to get connected AP [%s]\n",
+ wifi_mgr_error_dbg(ret));
+ return RET_FAILED;
+ }
+
+ ret = wifi_ap_get_essid(ap, &name);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("Fail to wifi_ap_get_essid AP [%s]\n",
+ wifi_mgr_error_dbg(ret));
+ wifi_ap_destroy(ap);
+ return RET_FAILED;
+ }
+
+ ret = wifi_forget_ap(ap);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("Fail to forget [%s],[%s].\n", name,
+ wifi_mgr_error_dbg(ret));
+ wifi_ap_destroy(ap);
+ free(name);
+ return RET_FAILED;
+ }
+
+ free(name);
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets the passphrase.
+ *
+ * When the access point is locked, you should set passphrase first.
+ *
+ * @param[in] ap The handle of access point
+ * @param[in] passcode The passcode
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_set_passphrase(wifi_ap_h ap, const char *passcode)
+{
+ int ret;
+
+ if (!ap || !passcode) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ret = wifi_ap_set_passphrase(ap, passcode);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("failed to set passcode. ret: %s.",
+ wifi_mgr_error_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Connects the access point, asynchronously.
+ *
+ * After you make the preprarion, such as setting passphrase,
+ * forgetting the connected ap, then you can connect the ap.
+ *
+ * @param[in] ap The handle of access point
+ * @param[in] cb The callback function to be called
+ * @param[in] data User data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_connect(wifi_ap_h ap, wifi_connected_cb cb, void *data)
+{
+ int ret;
+
+ if (!cb || !ap || !data) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ret = wifi_connect(ap, cb, data);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("failed to connect ap. ret: %s.",
+ wifi_mgr_error_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets the config type of IP.
+ *
+ * Only support IPV4 now.
+ *
+ * @param[in] ap The handle of access point
+ * @param[in] type The type of IP config
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_ap_set_ip_config_type(wifi_ap_h ap,
+ wifi_ip_config_type_e type)
+{
+ int ret;
+
+ if (!ap) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ret = wifi_ap_set_ip_config_type(ap, WIFI_ADDRESS_FAMILY_IPV4, type);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("failed to connect ap. ret: %s.",
+ wifi_mgr_error_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets the data of access point.
+ *
+ * Get ip, dns, submask, and gateway info.
+ *
+ * @param[in] ap The handle of access point
+ * @param[out] info The structure to store ip info
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_get_ip_info(wifi_ap_h ap, struct network_info *info)
+{
+ char *str_value;
+
+ if (!info || !ap) {
+ _ERR("null pointer");
+ return RET_FAILED;
+ }
+
+ str_value = NULL;
+ if (wifi_ap_get_ip_address(ap, WIFI_ADDRESS_FAMILY_IPV4,
+ &str_value) == WIFI_ERROR_NONE) {
+ strncpy(info->ip_addr, str_value, IP_STRING_MAX_SIZE);
+ free(str_value);
+ } else {
+ strncpy(info->ip_addr, ZERO_IP, IP_STRING_MAX_SIZE);
+ _ERR("Fail to get Gateway\n");
+ }
+
+ str_value = NULL;
+ if (wifi_ap_get_subnet_mask(ap, WIFI_ADDRESS_FAMILY_IPV4,
+ &str_value) == WIFI_ERROR_NONE) {
+ strncpy(info->submask, str_value, IP_STRING_MAX_SIZE);
+ free(str_value);
+ } else {
+ strncpy(info->submask, ZERO_IP, IP_STRING_MAX_SIZE);
+ _ERR("Fail to get Gateway\n");
+ }
+
+ str_value = NULL;
+ if (wifi_ap_get_gateway_address(ap, WIFI_ADDRESS_FAMILY_IPV4,
+ &str_value) == WIFI_ERROR_NONE) {
+ strncpy(info->gateway, str_value, IP_STRING_MAX_SIZE);
+ free(str_value);
+ } else {
+ strncpy(info->gateway, ZERO_IP, IP_STRING_MAX_SIZE);
+ _ERR("Fail to get Gateway\n");
+ }
+
+ str_value = NULL;
+ if (wifi_ap_get_dns_address(ap, 1, WIFI_ADDRESS_FAMILY_IPV4,
+ &str_value) == WIFI_ERROR_NONE) {
+ strncpy(info->dns, str_value, IP_STRING_MAX_SIZE);
+ free(str_value);
+ } else {
+ strncpy(info->dns, ZERO_IP, IP_STRING_MAX_SIZE);
+ _ERR("Fail to get DNS1\n");
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets the data of access point.
+ *
+ * Set ip, submask, and gateway info.
+ *
+ * @param[in] ap The handle of access point
+ * @param[in] info The structure of ip info
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_set_ip_config(wifi_ap_h ap, struct network_info *info)
+{
+ int ret;
+
+ if (!info || !ap) {
+ _ERR("null pointer");
+ return RET_FAILED;
+ }
+
+ ret = wifi_ap_set_ip_address(ap, WIFI_ADDRESS_FAMILY_IPV4,
+ info->ip_addr);
+ if (ret != WIFI_ERROR_NONE)
+ _ERR("Fail to set ip address[%s]\n",
+ wifi_mgr_error_dbg(ret));
+
+ ret = wifi_ap_set_subnet_mask(ap, WIFI_ADDRESS_FAMILY_IPV4,
+ info->submask);
+ if (ret != WIFI_ERROR_NONE)
+ _ERR("Fail to set subnet mask[%s]\n",
+ wifi_mgr_error_dbg(ret));
+
+ ret = wifi_ap_set_gateway_address(ap, WIFI_ADDRESS_FAMILY_IPV4,
+ info->gateway);
+ if (ret != WIFI_ERROR_NONE)
+ _ERR("Fail to set gateway address[%s]\n",
+ wifi_mgr_error_dbg(ret));
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets dns of access point.
+ *
+ * @param[in] ap The handle of access point
+ * @param[in] info The structure of ip info
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_set_dns_config(wifi_ap_h ap, struct network_info *info)
+{
+ int ret;
+
+ if (!info || !ap) {
+ _ERR("null pointer");
+ return RET_FAILED;
+ }
+
+ ret = wifi_ap_set_dns_address(ap, 1, WIFI_ADDRESS_FAMILY_IPV4,
+ info->dns);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("Fail to set dns address[%s]\n",
+ wifi_mgr_error_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets whether Wi-Fi can access to the internet asynchronously.
+ *
+ * @param[in] cb The callback function to be called
+ * @param[in] data User data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+#if 0
+int wifi_mgr_get_is_online_async(wifi_get_is_online_async_cb cb,
+ void *data)
+{
+ int ret;
+
+ if (!cb || !data) {
+ _ERR("the param is NULL.");
+ return RET_FAILED;
+ }
+
+ ret = wifi_get_is_online_async(cb, data);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("wifi_get_is_online_async() failed.");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+#endif
diff --git a/ug/network/src/wifi_passcode_view.c b/ug/network/src/wifi_passcode_view.c
new file mode 100644
index 0000000..e8a03b1
--- /dev/null
+++ b/ug/network/src/wifi_passcode_view.c
@@ -0,0 +1,956 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <Elementary.h>
+#include <aul.h>
+#include <ui-gadget-module.h>
+#include <string.h>
+
+#include <KeyDefine.h>
+
+#include "defs.h"
+#include "dbg.h"
+#include "i18n.h"
+#include "util.h"
+#include "common.h"
+#include "wifi_passcode_view.h"
+#include "util.h"
+#include "wifi_mgr.h"
+
+#define KEY_PRIV "priv"
+#define KEY_NETWORK_ENTER "Select"
+
+#define AP_NAME_LENTH 256
+
+#define TXT_PASSCODE "Network passcode"
+#define TXT_ENTER_PASSCODE "Enter the network password"
+
+#define STYLE_ENTRY_FOCUS "focus"
+#define STYLE_ENTRY_TXT "DEFAULT='font_size=30 linesize=40'"
+
+struct _priv {
+ Evas_Object *win;
+ ui_gadget_h ug;
+ struct viewmgr *vmgr;
+ Evas_Object *base;
+ Evas_Object *entry;
+ Evas_Object *dim_ly;
+ Evas_Object *ctxpopup;
+ char ap_name[AP_NAME_LENTH + 1];
+ char *ap_pwd;
+};
+
+static int _wifi_connect_ap(struct _priv *priv);
+static void _show_confirm_popup(struct _priv *priv);
+static void _show_progress_popup(struct _priv *priv);
+
+/**
+ * Initializes the private data.
+ *
+ * Called when the view is loaded.
+ *
+ * @return the handler of the private data;
+ */
+static struct _priv *_init_priv(void)
+{
+ struct _priv *priv;
+
+ priv = calloc(1, sizeof(*priv));
+
+ return priv;
+}
+
+/**
+ * Deinitializes the private data.
+ *
+ * Called when the view is deleted.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _fini_priv(struct _priv *priv)
+{
+ if (!priv) {
+ _ERR("priv is already NULL.");
+ return;
+ }
+
+ if (priv->dim_ly)
+ evas_object_del(priv->dim_ly);
+
+ free(priv->ap_pwd);
+ free(priv);
+}
+
+/**
+ * Shows the dim layout.
+ *
+ * Called when there is a ctxpopup.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _set_layout_dim(struct _priv *priv)
+{
+ if (!priv || !priv->dim_ly) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ evas_object_show(priv->dim_ly);
+}
+
+/**
+ * Hides the dim layout.
+ *
+ * Called when the existing ctxpopup is deleted.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _unset_layout_dim(struct _priv *priv)
+{
+ if (!priv || !priv->dim_ly) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ evas_object_hide(priv->dim_ly);
+}
+
+/**
+ * Creates the dim layout.
+ *
+ * Called when the view is created.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _create_dim_layout(struct _priv *priv)
+{
+ Evas_Object *dim_ly;
+
+ if (!priv || !priv->win) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ dim_ly = util_add_layout(priv->win, UG_NETWORK_EDJ_FILE, GRP_DIM_LY);
+ if (!dim_ly) {
+ _ERR("elm_layout_add() failed.\n");
+ return RET_FAILED;
+ }
+
+ priv->dim_ly = dim_ly;
+
+ _unset_layout_dim(priv);
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Callback for key pressed event.
+ *
+ * If the key is KEY_BACK, delete this view.
+ *
+ * @param[in] data User data
+ * @param[in] e Evas handler
+ * @param[in] obj The corresponding object which the deletion event occurred
+ * @param[in] ei Event information
+ */
+static void _base_key_press_cb(void *data, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _priv *priv;
+
+ if (!ei || !data) {
+ _ERR("ei or data is NULL");
+ return;
+ }
+
+ priv = data;
+ ev = ei;
+
+ if (!ev->keyname) {
+ _ERR("ev->keyname is NULL.");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_BACK))
+ viewmgr_pop(priv->vmgr);
+}
+
+/**
+ * Sets the description.
+ *
+ * Sets the description for the passcode view.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _set_description(struct _priv *priv)
+{
+ if (!priv || !priv->base) {
+ _ERR("priv is invalid.");
+ return;
+ }
+
+ elm_object_part_text_set(priv->base, PART_WIFI_PASSCODE_TITLE,
+ _(TXT_PASSCODE));
+ elm_object_part_text_set(priv->base, PART_WIFI_PASSCODE_TEXT,
+ _(TXT_ENTER_PASSCODE));
+ elm_object_part_text_set(priv->base, PART_WIFI_PASSCODE_AP_NAME,
+ priv->ap_name);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling click event.
+*
+* When the 'OK' button is clicked, delete the popup,
+* and set the default focus.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] event Event information
+*/
+static void _popup_ok_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *event)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+
+ if (priv->ctxpopup) {
+ evas_object_del(priv->ctxpopup);
+ priv->ctxpopup = NULL;
+ }
+
+ elm_object_focus_set(priv->entry, EINA_TRUE);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling unfocused event.
+*
+* When the ctxpopup is unfocused, hide the dim layout,
+* and delete the ctxpopup.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] source Event information
+*/
+static void _ctxpopup_unfocused_cb(void *data,
+ Evas_Object *obj, void *source)
+{
+ struct _priv *priv;
+
+ if (!data || !obj) {
+ _ERR("data is NULL.\n");
+ return;
+ }
+
+ priv = data;
+
+ _unset_layout_dim(priv);
+
+ evas_object_del(obj);
+}
+
+/**
+* @Evas_Object_Event_Cb type callback for handling pressed event.
+*
+* When KEY_BACK is pressed in the ctxpopup, delete the ctxpopup.
+*
+* @param[in] data User data
+* @param[in] e Evas handler
+* @param[in] obj The corresponding object which the deletion event occurred
+* @param[in] ei Event information
+*/
+static void _ctxpopup_pressed_cb(void *data, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _priv *priv;
+
+ if (!data || !ei || !obj) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+ ev = ei;
+
+ if (!ev->keyname) {
+ _ERR("ev->keyname is NULL.");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_BACK)) {
+ _unset_layout_dim(priv);
+ evas_object_del(obj);
+
+ elm_object_focus_set(priv->entry, EINA_TRUE);
+ }
+}
+
+/**
+ * Shows the invalid ctxpopup.
+ *
+ * The ctxpopup will show the invalid passcode information.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _show_invalid_pwd_popup(struct _priv *priv)
+{
+ Evas_Object *layout;
+ Evas_Object *ok_btn;
+ char content[CONTENT_TXT_SIZE];
+
+ if (!priv) {
+ _ERR("The param is NULL.\n");
+ return;
+ }
+
+ if (priv->ctxpopup) {
+ evas_object_del(priv->ctxpopup);
+ priv->ctxpopup = NULL;
+ }
+
+ _set_layout_dim(priv);
+
+ layout = util_add_layout(priv->base, UG_NETWORK_EDJ_FILE,
+ GRP_CONFIRM_LAYOUT);
+ if (!layout) {
+ _ERR("add layout failed.");
+ _unset_layout_dim(priv);
+ return;
+ }
+
+ elm_object_part_text_set(layout,
+ PART_TEXT_TITLE, _(TXT_WIRELESS_LY));
+
+ memset(content, 0, CONTENT_TXT_SIZE);
+ snprintf(content, CONTENT_TXT_SIZE - 1, "%s",
+ _(TXT_INVALID_PWD));
+ elm_object_part_text_set(layout,
+ PART_TEXT_CONTENT, content);
+
+ ok_btn = util_add_button(layout, STYLE_SETTING_BTN,
+ PART_OK_BTN, _(TXT_OK));
+ if (!ok_btn) {
+ _ERR("util add button failed.");
+ evas_object_del(layout);
+ _unset_layout_dim(priv);
+ return;
+ }
+
+ elm_object_focus_next_object_set(ok_btn, ok_btn, ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(ok_btn, ok_btn, ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(ok_btn, ok_btn, ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(ok_btn, ok_btn, ELM_FOCUS_DOWN);
+ evas_object_smart_callback_add(ok_btn, SIG_CLICKED,
+ _popup_ok_btn_clicked_cb, priv);
+
+ elm_object_focus_set(ok_btn, EINA_TRUE);
+
+ elm_object_focus_allow_set(layout, EINA_TRUE);
+ evas_object_smart_callback_add(layout, SIG_UNFOCUSED,
+ _ctxpopup_unfocused_cb, priv);
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN,
+ _ctxpopup_pressed_cb, priv);
+
+ evas_object_move(layout, CENTER_ALIGN * (DEFAULT_WIN_WIDTH - POPUP_WIDTH) * ELM_SCALE,
+ CENTER_ALIGN * (DEFAULT_WIN_HEIGHT - POPUP_HEIGHT) * ELM_SCALE);
+
+ priv->ctxpopup = layout;
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicking event.
+*
+* When the 'Retry' button is clicked, retry to connect the ap.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] event Event information
+*/
+static void _retry_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *event)
+{
+ struct _priv *priv;
+ int ret;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+
+ if (priv->ctxpopup) {
+ evas_object_del(priv->ctxpopup);
+ priv->ctxpopup = NULL;
+ }
+
+ _unset_layout_dim(priv);
+
+ ret = _wifi_connect_ap(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("connect ap");
+ _show_confirm_popup(priv);
+ return;
+ }
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicking event.
+*
+* When the 'Cancel' button is clicked, delete the ctxpopup
+* where the button is located.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] event Event information
+*/
+static void _cancel_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *event)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+
+ if (priv->ctxpopup) {
+ evas_object_del(priv->ctxpopup);
+ priv->ctxpopup = NULL;
+ }
+
+ _unset_layout_dim(priv);
+
+ elm_object_focus_set(priv->entry, EINA_TRUE);
+}
+
+/**
+ * Shows the confirm ctxpopup.
+ *
+ * The ctxpopup will show the result of connectting the ap.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _show_confirm_popup(struct _priv *priv)
+{
+ Evas_Object *layout;
+ Evas_Object *retry_btn;
+ Evas_Object *cancel_btn;
+ char content[CONTENT_TXT_SIZE];
+
+ if (!priv) {
+ _ERR("the param is NULL.");
+ return;
+ }
+
+ if (priv->ctxpopup) {
+ evas_object_del(priv->ctxpopup);
+ priv->ctxpopup = NULL;
+ }
+
+ _set_layout_dim(priv);
+
+ layout = util_add_layout(priv->base, UG_NETWORK_EDJ_FILE,
+ GRP_CONFIRM_LAYOUT);
+ if (!layout) {
+ _ERR("add layout failed.");
+ _unset_layout_dim(priv);
+ return;
+ }
+
+ memset(content, 0, CONTENT_TXT_SIZE);
+ elm_object_part_text_set(layout,
+ PART_TEXT_TITLE, _(TXT_WIRELESS_LY));
+ snprintf(content, CONTENT_TXT_SIZE - 1, "%s %s",
+ _(TXT_FAILED_CONNECT), priv->ap_name);
+
+ elm_object_part_text_set(layout,
+ PART_TEXT_CONTENT, content);
+
+ retry_btn = util_add_button(layout, STYLE_SETTING_BTN,
+ PART_RETRY_BTN, _(TXT_RETRY));
+ if (!retry_btn) {
+ _ERR("util add button failed.");
+ evas_object_del(layout);
+ _unset_layout_dim(priv);
+ return;
+ }
+
+ cancel_btn = util_add_button(layout, STYLE_SETTING_BTN,
+ PART_CANCEL_BTN, _(TXT_CANCEL));
+ if (!cancel_btn) {
+ _ERR("util add button failed.");
+ evas_object_del(layout);
+ _unset_layout_dim(priv);
+ return;
+ }
+
+ elm_object_focus_next_object_set(retry_btn, cancel_btn,
+ ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(cancel_btn, retry_btn,
+ ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(cancel_btn, cancel_btn,
+ ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(retry_btn, retry_btn,
+ ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(cancel_btn, cancel_btn,
+ ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(retry_btn, retry_btn,
+ ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(cancel_btn, cancel_btn,
+ ELM_FOCUS_DOWN);
+ elm_object_focus_next_object_set(retry_btn, retry_btn,
+ ELM_FOCUS_DOWN);
+
+ evas_object_smart_callback_add(retry_btn, SIG_CLICKED,
+ _retry_btn_clicked_cb, priv);
+ evas_object_smart_callback_add(cancel_btn, SIG_CLICKED,
+ _cancel_btn_clicked_cb, priv);
+
+ elm_object_focus_set(retry_btn, EINA_TRUE);
+
+ elm_object_focus_allow_set(layout, EINA_TRUE);
+ evas_object_smart_callback_add(layout, SIG_UNFOCUSED,
+ _ctxpopup_unfocused_cb, priv);
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN,
+ _ctxpopup_pressed_cb, priv);
+
+ evas_object_move(layout, CENTER_ALIGN * (DEFAULT_WIN_WIDTH - POPUP_WIDTH) * ELM_SCALE,
+ CENTER_ALIGN * (DEFAULT_WIN_HEIGHT - POPUP_HEIGHT) * ELM_SCALE);
+
+ priv->ctxpopup = layout;
+}
+
+/**
+ * Shows the progress ctxpopup.
+ *
+ * The ctxpopup will show the progress of connectting the ap.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _show_progress_popup(struct _priv *priv)
+{
+ Evas_Object *layout;
+ Evas_Object *cancel_btn;
+ char content[CONTENT_TXT_SIZE];
+
+ if (!priv) {
+ _ERR("the param is NULL.");
+ return;
+ }
+
+ if (priv->ctxpopup) {
+ evas_object_del(priv->ctxpopup);
+ priv->ctxpopup = NULL;
+ }
+
+ _set_layout_dim(priv);
+
+ layout = util_add_layout(priv->base, UG_NETWORK_EDJ_FILE,
+ GRP_PROCESSING_LAYOUT);
+ if (!layout) {
+ _ERR("add layout failed.");
+ _unset_layout_dim(priv);
+ return;
+ }
+
+ memset(content, 0, CONTENT_TXT_SIZE);
+ elm_object_part_text_set(layout,
+ PART_TEXT_TITLE, _(TXT_WIRELESS_LY));
+ snprintf(content, CONTENT_TXT_SIZE - 1, "%s %s",
+ _(TXT_CONNECTTING), priv->ap_name);
+ elm_object_part_text_set(layout, PART_TEXT_CONTENT, content);
+
+ cancel_btn = util_add_button(layout, STYLE_SETTING_BTN,
+ PART_CANCEL_BTN, _(TXT_CANCEL));
+ if (!cancel_btn) {
+ _ERR("util add button failed.");
+ evas_object_del(layout);
+ _unset_layout_dim(priv);
+ return;
+ }
+
+ elm_object_focus_next_object_set(cancel_btn, cancel_btn,
+ ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(cancel_btn, cancel_btn,
+ ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(cancel_btn, cancel_btn,
+ ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(cancel_btn, cancel_btn,
+ ELM_FOCUS_DOWN);
+
+ evas_object_smart_callback_add(cancel_btn, SIG_CLICKED,
+ _cancel_btn_clicked_cb, priv);
+
+ elm_object_focus_set(cancel_btn, EINA_TRUE);
+
+ elm_object_focus_allow_set(layout, EINA_TRUE);
+ evas_object_smart_callback_add(layout, SIG_UNFOCUSED,
+ _ctxpopup_unfocused_cb, priv);
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN,
+ _ctxpopup_pressed_cb, priv);
+
+ evas_object_move(layout, CENTER_ALIGN * (DEFAULT_WIN_WIDTH - POPUP_WIDTH) * ELM_SCALE,
+ CENTER_ALIGN * (DEFAULT_WIN_HEIGHT - POPUP_HEIGHT) * ELM_SCALE);
+
+ priv->ctxpopup = layout;
+}
+
+/**
+ * The callback of wifi connection.
+ *
+ * The result is in the error code.
+ *
+ * @param[in] error_code Error code
+ * @param[in] user_data User data
+ */
+static void _wifi_connected_cb(wifi_error_e error_code, void *user_data)
+{
+ struct _priv *priv;
+
+ if (!user_data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = user_data;
+
+ if (!priv->ctxpopup)
+ return;
+
+ if (error_code != WIFI_ERROR_NONE) {
+ _ERR("connect AP failed, ret: %s.",
+ wifi_mgr_error_dbg(error_code));
+ _show_confirm_popup(priv);
+ return;
+ }
+
+ ug_destroy_me(priv->ug);
+}
+
+/**
+ * The callback of finding ap.
+ *
+ * The callback will be called the same times as the ap count.
+ *
+ * @param[in] ap The hander of ap
+ * @param[in] data User data
+ */
+static bool _wifi_found_ap_cb(wifi_ap_h ap, void *data)
+{
+ int ret;
+ struct _priv *priv;
+ struct wifi_ap_info ap_info;
+
+ if (!ap || !data) {
+ _ERR("Parameter error!");
+ return false;
+ }
+
+ priv = data;
+
+ wifi_mgr_get_ap_info(ap, &ap_info);
+
+ if (!strncmp(priv->ap_name, ap_info.essid, AP_NAME_LENTH)) {
+ ret = wifi_mgr_set_passphrase(ap, priv->ap_pwd);
+ if (ret != RET_SUCCESS) {
+ _ERR("wifi_mgr_set_passphrase() failed.");
+ _show_confirm_popup(priv);
+ return false;
+ }
+
+ ret = wifi_mgr_connect(ap, _wifi_connected_cb, priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("Fail to connection request.\n");
+ _show_confirm_popup(priv);
+ return false;
+ }
+
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * The callback of ap scanning request.
+ *
+ * The callback will be called the same times as the ap count.
+ *
+ * @param[in] error_code Error code
+ * @param[in] data User data
+ */
+static void _wifi_scan_request_cb(wifi_error_e error_code, void *data)
+{
+ int ret;
+
+ if (!data) {
+ _ERR("data is NULL.");
+ return;
+ }
+
+ ret = wifi_mgr_foreach_found_aps(_wifi_found_ap_cb, data);
+ if (ret != RET_SUCCESS) {
+ _ERR("wifi_mgr_foreach_found_aps() failed.");
+ _show_confirm_popup(data);
+ return;
+ }
+}
+
+/**
+ * Connects the ap.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _wifi_connect_ap(struct _priv *priv)
+{
+ int ret;
+
+ if (!priv || !priv->ap_pwd) {
+ _ERR("Parameter error!");
+ return RET_FAILED;
+ }
+
+ _show_progress_popup(priv);
+
+ ret = wifi_mgr_forget_last_ap();
+ if (ret != RET_SUCCESS) {
+ _ERR("forget last ap failed.");
+ return false;
+ }
+
+ ret = wifi_mgr_scan_request(_wifi_scan_request_cb, priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("wifi_mgr_scan_request() failed.");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Callback for key pressed event.
+ *
+ * If the key is 'Select', connect the ap.
+ *
+ * @param[in] data User data
+ * @param[in] e Evas handler
+ * @param[in] obj The corresponding object which the deletion event occurred
+ * @param[in] ei Event information
+ */
+static void _entry_key_press_cb(void *data, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _priv *priv;
+ int ret;
+
+ if (!ei || !data) {
+ _ERR("ei or data is NULL");
+ return;
+ }
+
+ priv = data;
+ ev = ei;
+
+ if (!ev->keyname) {
+ _ERR("ev->keyname is NULL.");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_NETWORK_ENTER)) {
+ if (priv->ap_pwd) {
+ free(priv->ap_pwd);
+ priv->ap_pwd = NULL;
+ }
+
+ priv->ap_pwd = strdup(elm_entry_entry_get(obj));
+ if (!priv->ap_pwd) {
+ _ERR("the passcode in entry is NULL.");
+ _show_invalid_pwd_popup(priv);
+ return;
+ }
+
+ ret = _wifi_connect_ap(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("connect ap");
+ _show_confirm_popup(priv);
+ return;
+ }
+ }
+}
+
+/**
+ * Creates the entry.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _add_entry(struct _priv *priv)
+{
+ Evas_Object *base;
+ Evas_Object *entry;
+
+ if (!priv || !priv->base) {
+ _ERR("the param is invalid.");
+ return;
+ }
+
+ base = priv->base;
+
+ entry = util_add_entry(base, STYLE_ENTRY_FOCUS,
+ PART_WIFI_PASSCODE_ENTRY);
+ if (!entry) {
+ _ERR("util_add_entry failed.");
+ evas_object_del(base);
+ _fini_priv(priv);
+ return;
+ }
+
+ elm_entry_password_set(entry, EINA_TRUE);
+ elm_entry_text_style_user_push(entry, STYLE_ENTRY_TXT);
+ evas_object_event_callback_add(entry, EVAS_CALLBACK_KEY_DOWN,
+ _entry_key_press_cb, priv);
+
+ elm_entry_input_panel_enabled_set(entry, EINA_TRUE);
+
+ elm_object_focus_next_object_set(entry, entry, ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(entry, entry, ELM_FOCUS_LEFT);
+
+ elm_object_focus_set(entry, EINA_TRUE);
+
+ priv->entry = entry;
+}
+
+/**
+ * Creates the layout of the view.
+ *
+ * Called when the view is pushed.
+ *
+ * @param[in] vmgr View manager
+ * @param[in] data User data
+ * @return layout if the operation is successful; NULL if failed;
+ */
+static Evas_Object *_create(struct viewmgr *vmgr, void *data)
+{
+ struct _priv *priv;
+ struct wifi_ap_info *ap_info;
+ Evas_Object *base;
+
+ if (!vmgr || !vmgr->win || !vmgr->ug || !data) {
+ _ERR("Parameter error!");
+ return NULL;
+ }
+
+ priv = _init_priv();
+ if (!priv) {
+ _ERR("init priv failed.");
+ return NULL;
+ }
+
+ priv->win = vmgr->win;
+ priv->ug = vmgr->ug;
+ priv->vmgr = vmgr;
+
+ ap_info = data;
+ strncpy(priv->ap_name, ap_info->essid, AP_NAME_LENTH);
+
+ base = util_add_layout(priv->win, UG_NETWORK_EDJ_FILE,
+ GRP_WIFI_PASSCODE_BASE);
+ if (!base) {
+ _ERR("util_add_layout failed.");
+ _fini_priv(priv);
+ return NULL;
+ }
+
+ evas_object_data_set(base, KEY_PRIV, priv);
+
+ evas_object_event_callback_add(base, EVAS_CALLBACK_KEY_DOWN,
+ _base_key_press_cb, priv);
+
+ priv->base = base;
+
+ _set_description(priv);
+
+ _add_entry(priv);
+
+ _create_dim_layout(priv);
+
+ return base;
+}
+
+/**
+ * Destroies the layout of the view.
+ *
+ * Called when the view is popped.
+ *
+ * @param[in] base The base layout
+ */
+static void _destroy(Evas_Object *base)
+{
+ struct _priv *priv;
+
+ if (!base) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = evas_object_data_get(base, KEY_PRIV);
+ if (!priv)
+ return;
+
+ _fini_priv(priv);
+}
+
+/**
+ * Gets the current view type.
+ *
+ * @return view type;
+ */
+static enum view_type _get_view_type(void)
+{
+ return NETWORK_WIFI_PASSCODE_VIEW;
+}
+
+
+static struct view_class _vclass = {
+ .create = _create,
+ .resume = NULL,
+ .terminate = _destroy,
+ .message_handler = NULL,
+ .get_view_type = _get_view_type,
+};
+
+/**
+ * Gets the current view class.
+ *
+ * @return view class;
+ */
+struct view_class *wifi_passcode_view_vclass_get(void)
+{
+ return &_vclass;
+}
diff --git a/ug/proxy/CMakeLists.txt b/ug/proxy/CMakeLists.txt
index 20da480..7df799f 100644
--- a/ug/proxy/CMakeLists.txt
+++ b/ug/proxy/CMakeLists.txt
@@ -24,6 +24,7 @@ SET(UG_PROXY_EDJ_THEME "ug-proxy-settings-theme.edj")
INCLUDE(FindPkgConfig)
pkg_check_modules(UG_PROXY_PKGS REQUIRED
+ dlog
eina
edje
evas
@@ -36,6 +37,8 @@ pkg_check_modules(UG_PROXY_PKGS REQUIRED
capi-network-wifi
capi-network-connection
)
+ #ecore-x
+
SET(PKGS_LDFLAGS "${PKGS_LDFLAGS} ${UG_PROXY_PKGS_LDFLAGS}")
FOREACH(FLAG ${UG_PROXY_PKGS_CFLAGS})
@@ -45,17 +48,15 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fvisibility=hidden -Wall -W
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
SET(SRCS
- src/ug_proxy_settings.cpp
- src/ProxyMainView.cpp
- src/util.cpp
- ../src/WifiMgr.cpp
- ../src/NetConMgr.cpp
+ src/ug_proxy_settings.c
+ src/main_view.c
+ src/vconf_mgr.c
+ src/connection_mgr.c
+ src/wifi_mgr.c
+ src/util.c
)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../include)
-
ADD_DEFINITIONS("-DPKGNAME=\"${PROJECT_NAME}\"")
ADD_DEFINITIONS("-DUG_PROXY_EDJ_FILE=\"${UG_PROXY_EDJE_DIR}/${UG_PROXY_EDJ_FILE}\"")
diff --git a/ug/proxy/edje/images/ico_dropdown_menu_check.png b/ug/proxy/edje/images/ico_dropdown_menu_check.png
index d32061e..9e7d114 100644
--- a/ug/proxy/edje/images/ico_dropdown_menu_check.png
+++ b/ug/proxy/edje/images/ico_dropdown_menu_check.png
Binary files differ
diff --git a/ug/proxy/edje/images/ico_spincontrol_down.png b/ug/proxy/edje/images/ico_spincontrol_down.png
index 0b7ff54..fbeb94b 100644
--- a/ug/proxy/edje/images/ico_spincontrol_down.png
+++ b/ug/proxy/edje/images/ico_spincontrol_down.png
Binary files differ
diff --git a/ug/proxy/edje/images/ico_spincontrol_up.png b/ug/proxy/edje/images/ico_spincontrol_up.png
index 9adb165..f5b2587 100644
--- a/ug/proxy/edje/images/ico_spincontrol_up.png
+++ b/ug/proxy/edje/images/ico_spincontrol_up.png
Binary files differ
diff --git a/ug/proxy/edje/images/modal_dialogs_bg.png b/ug/proxy/edje/images/modal_dialogs_bg.png
index b825c26..0ae9c58 100644
--- a/ug/proxy/edje/images/modal_dialogs_bg.png
+++ b/ug/proxy/edje/images/modal_dialogs_bg.png
Binary files differ
diff --git a/ug/proxy/edje/images/round_rectangle_4X4.png b/ug/proxy/edje/images/round_rectangle_4X4.png
index b0c09a8..5a1f51d 100644
--- a/ug/proxy/edje/images/round_rectangle_4X4.png
+++ b/ug/proxy/edje/images/round_rectangle_4X4.png
Binary files differ
diff --git a/ug/proxy/edje/images/round_rectangle_8X8_top.png b/ug/proxy/edje/images/round_rectangle_8X8_top.png
index 3ab184f..dc618e3 100644
--- a/ug/proxy/edje/images/round_rectangle_8X8_top.png
+++ b/ug/proxy/edje/images/round_rectangle_8X8_top.png
Binary files differ
diff --git a/ug/proxy/include/ProxyMainView.h b/ug/proxy/include/ProxyMainView.h
deleted file mode 100644
index 7bd13dd..0000000
--- a/ug/proxy/include/ProxyMainView.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef __PROXY_MAIN_VIEW_H__
-#define __PROXY_MAIN_VIEW_H__
-
-#include "UgCommon.h"
-
-class CProxyMainView : public CBaseView, public IMouseClickedListener, public IUnfocusedListener {
-private :
- struct SProxyMainView *m;
-
- bool m_InitConnection(void);
- void m_FinalizeConnection(void);
- Evas_Object* m_CreateMainLayout(void);
-
- Evas_Object *m_CreateValueBtn(Evas_Object *parent, int num, char *txt);
- bool m_SetWifiProxy(void);
- bool m_SetConnectionProxy(void);
- bool m_SetProxy(void);
- void m_MethodBtnClicked(EProxyMethod method);
- void m_SetupDownCycleFocus(Evas_Object **obj, int count);
- void m_SetTheValue(void);
- void m_SetLeftRightCycleFocus(Evas_Object **obj, int count);
- void m_CreateValuePopup(void);
- void m_CreateInputEntry(void);
- void m_ShowInvalidInfoPopup(int status);
- bool m_CreateMethodBoxBtn(Evas_Object *btn, const char *key, char *value, int line);
-
- bool m_CreateMethodAutoBtn(void);
- bool m_CreateMethodManualBtn(void);
- bool m_CreateMethodNoneBtn(void);
-
- bool m_CreateDimLayout(void);
- bool m_CreateActionBtns(void);
- bool m_GetProxyMethod(void);
- bool m_CreateProxyLayout(void);
-
-protected :
- virtual void t_OnShow(void);
- virtual void t_OnUpdate(void *data);
- virtual void t_OnHide(void);
-
-public :
- CProxyMainView(const char *szViewId) : CBaseView(szViewId), IMouseClickedListener(this), IUnfocusedListener(this), m(0) {}
- virtual ~CProxyMainView() {}
-
- virtual bool Create(void *data);
- virtual void Destroy(void);
- virtual Evas_Object* Base(void);
-
- virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev);
- virtual void OnMouseClicked(int id, Evas_Object *obj);
- virtual void OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item);
-};
-
-#endif /* __PROXY_MAIN_VIEW_H__ */
-
diff --git a/ug/proxy/include/common.h b/ug/proxy/include/common.h
new file mode 100644
index 0000000..3f18331
--- /dev/null
+++ b/ug/proxy/include/common.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __PROXY_COMMON_H__
+#define __PROXY_COMMON_H__
+
+#define MOTHED_STRING_LEN 15
+#define IP_STRING_LEN 15
+#define MOTHED_URL_LEN 100
+#define STRING_MAX_LEN 100
+#define METHOD_NUM 3
+
+#define IP_ZERO "0.0.0.0"
+#define URL_BLANK ""
+
+enum method_enum {
+ METHOD_NONE = 0,
+ METHOD_MAN,
+ METHOD_AUTO
+};
+
+#endif /* __PROXY_COMMON_H__ */
diff --git a/ug/proxy/include/connection_mgr.h b/ug/proxy/include/connection_mgr.h
new file mode 100644
index 0000000..acd36a3
--- /dev/null
+++ b/ug/proxy/include/connection_mgr.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __CONNECTION_MGR_H__
+#define __CONNECTION_MGR_H__
+
+#include <net_connection.h>
+#include <connection_mgr.h>
+#include "common.h"
+
+connection_h connection_mgr_create(void);
+int connection_mgr_destroy(connection_h connection);
+int connection_mgr_get_profile_info(connection_h connection,
+ connection_profile_h *out_proflie);
+int connection_mgr_set_proxy_type(connection_h connection,
+ enum method_enum method);
+int connection_mgr_get_proxy_type(connection_h connection,
+ enum method_enum *method);
+int connection_mgr_set_proxy_address(connection_h connection,
+ const char *ip);
+int connection_mgr_get_proxy_address(connection_h connection,
+ char **ip);
+
+#endif /* __CONNECTION_MGR_H__ */
diff --git a/ug/proxy/include/dbg.h b/ug/proxy/include/dbg.h
new file mode 100644
index 0000000..faf282c
--- /dev/null
+++ b/ug/proxy/include/dbg.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __DBG_H__
+#define __DBG_H__
+
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "ug-network-settings"
+
+#ifndef _ERR
+#define _ERR(fmt, args...) (LOGE("[%s:%d] "fmt"\n", __func__, __LINE__, ##args))
+#endif
+
+#ifndef _DBG
+#define _DBG(fmt, args...) (LOGD("[%s:%d] "fmt"\n", __func__, __LINE__, ##args))
+#endif
+
+#ifndef _INFO
+#define _INFO(fmt, args...) \
+ (LOGI("[%s:%d] "fmt"\n", __func__, __LINE__, ##args))
+#endif
+
+#endif /* __DBG_H__ */
diff --git a/ug/proxy/include/defs.h b/ug/proxy/include/defs.h
index 1c6621f..4163f4f 100644
--- a/ug/proxy/include/defs.h
+++ b/ug/proxy/include/defs.h
@@ -17,19 +17,6 @@
#ifndef __DEFS_H__
#define __DEFS_H__
-/* View */
-#define PROXY_MAINVIEW "PROXY_MAINVIEW"
-
-/* Common */
-#define MOTHED_STRING_LEN 15
-#define IP_STRING_LEN 15
-#define MOTHED_URL_LEN 100
-#define STRING_MAX_LEN 100
-#define METHOD_NUM 3
-
-#define IP_ZERO "0.0.0.0"
-#define URL_BLANK ""
-
#define ELM_SCALE elm_config_scale_get()
#define RET_SUCCESS 0
@@ -107,7 +94,27 @@
#define PART_TEXT_CONTENT "content.txt"
#define PART_ENTRY "part.entry"
-/* Width Height */
+/* Key defines */
+#define KEY_UP "Up"
+#define KEY_DOWN "Down"
+#define KEY_LEFT "Left"
+#define KEY_RIGHT "Right"
+#define KEY_ENTER "Return"
+#define KEY_EXIT "XF86Close"
+
+#define KEY_0 "0"
+#define KEY_1 "1"
+#define KEY_2 "2"
+#define KEY_3 "3"
+#define KEY_4 "4"
+#define KEY_5 "5"
+#define KEY_6 "6"
+#define KEY_7 "7"
+#define KEY_8 "8"
+#define KEY_9 "9"
+
+/* FIXME: do not pre-define */
#define DEFAULT_WIN_WIDTH 1920
#define DEFAULT_WIN_HEIGHT 1080
+
#endif /* __DEFS_H__ */
diff --git a/ug/proxy/include/main_view.h b/ug/proxy/include/main_view.h
new file mode 100644
index 0000000..8f7a1f4
--- /dev/null
+++ b/ug/proxy/include/main_view.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __MAIN_VIEW_H__
+#define __MAIN_VIEW_H__
+
+#include <Elementary.h>
+
+Evas_Object *create_main_view(Evas_Object *win, ui_gadget_h ug);
+void destroy_main_view(Evas_Object *base);
+
+#endif /* __MAIN_VIEW_H__ */
diff --git a/ug/proxy/include/util.h b/ug/proxy/include/util.h
index 5b0a0b0..16b0647 100644
--- a/ug/proxy/include/util.h
+++ b/ug/proxy/include/util.h
@@ -17,11 +17,16 @@
#ifndef __UTIL_H__
#define __UTIL_H__
-Evas_Object *util_add_layout(Evas_Object *parent, const char *file, const char *group);
-Evas_Object *util_add_button(Evas_Object *parent, const char *style, const char *part, const char *text);
-Evas_Object *util_add_key_value_button(Evas_Object *parent, const char *style, const char *part, const char *text_key, const char *text_value);
+Evas_Object *util_add_layout(Evas_Object *parent, const char *file,
+ const char *group);
+Evas_Object *util_add_button(Evas_Object *parent, const char *style,
+ const char *part, const char *text);
+Evas_Object *util_add_key_value_button(Evas_Object *parent,
+ const char *style, const char *part,
+ const char *text_key, const char *text_value);
Evas_Object *util_add_box(Evas_Object *parent, const char *part);
-Evas_Object *util_add_entry(Evas_Object *parent, const char *style, const char *part);
+Evas_Object *util_add_entry(Evas_Object *parent,
+ const char *style, const char *part);
void util_set_focus_next_self(Evas_Object *obj);
#endif /* __UTIL_H__ */
diff --git a/ug/proxy/include/vconf_mgr.h b/ug/proxy/include/vconf_mgr.h
new file mode 100644
index 0000000..363a73a
--- /dev/null
+++ b/ug/proxy/include/vconf_mgr.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __VCONF_MGR_H__
+#define __VCONF_MGR_H__
+
+#include <vconf.h>
+#include "common.h"
+
+char *vconf_mgr_get_string_value(const char *key);
+int vconf_mgr_set_string_value(const char *key, const char *value);
+int vconf_mgr_get_int_value(const char *key, int *value);
+int vconf_mgr_set_int_value(const char *key, const int value);
+
+#endif /* __VCONF_MGR_H__ */
diff --git a/ug/proxy/include/wifi_mgr.h b/ug/proxy/include/wifi_mgr.h
new file mode 100644
index 0000000..43482a4
--- /dev/null
+++ b/ug/proxy/include/wifi_mgr.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_MGR_H__
+#define __WIFI_MGR_H__
+
+#include <wifi.h>
+#include "common.h"
+
+int wifi_mgr_init(void);
+int wifi_mgr_deinit(void);
+int wifi_mgr_get_connected_ap(wifi_ap_h *ap);
+int wifi_mgr_set_proxy_type(enum method_enum method);
+int wifi_mgr_get_proxy_type(enum method_enum *method);
+int wifi_mgr_set_proxy_address(const char *ip);
+int wifi_mgr_get_proxy_address(char **ip);
+
+#endif /* __WIFI_MGR_H__ */
diff --git a/ug/proxy/src/ProxyMainView.cpp b/ug/proxy/src/ProxyMainView.cpp
deleted file mode 100644
index c4245f4..0000000
--- a/ug/proxy/src/ProxyMainView.cpp
+++ /dev/null
@@ -1,1165 +0,0 @@
-#include <ui-gadget-module.h>
-#include <vconf.h>
-#include "defs.h"
-#include <AppCommon.h>
-#include "i18n.h"
-#include "util.h"
-
-#include "UgCommon.h"
-#include "WifiMgr.h"
-#include "NetConMgr.h"
-
-#include "ProxyMainView.h"
-
-#define KEY_PRIV "priv"
-#define KEY_PROXY_ENTER "Select"
-#define IP_VALUE1 "value1"
-#define IP_VALUE2 "value2"
-#define IP_VALUE3 "value3"
-#define IP_VALUE4 "value4"
-
-static const char *VCONF_NETWORK_TYPE = "db/menu/network/network_type";
-static const char *VCONF_PROXY_METHOD = "db/menu/proxy/method";
-static const char *VCONF_PROXY_IP = "db/menu/proxy/ip";
-static const char *VCONF_PROXY_URL = "db/menu/proxy/url";
-
-#define METHOD_CTXPOPUP_OFFSET_X 448
-#define VALUE_CTXPOPUP_OFFSET_X 162
-#define VALUE_CTXPOPUP_OFFSET_Y 20
-#define PROXY_CONFIG_MAX_NUM 4
-#define IP_MAX_NUM 255
-#define IP_RATIO 10
-#define PORT_MAX_NUM 65535
-#define PORT_INVALID_NUM 65536
-#define PORT_NO_NEED 65537
-#define CENTER_ALIGN 0.5
-#define CTXPOPUP_WIDTH 688
-#define CTXPOPUP_HEIGHT 411
-#define BTN_ONE_LINE 1
-#define BTN_TWO_LINE 2
-#define LINE_PAD 2
-#define ALIGH_RATIO 1.5
-
-enum network_type_enum {
- TYPE_WIRELESS = 0,
- TYPE_WIRED
-};
-
-struct SProxyMainView {
- ui_gadget_h ug;
-
- Evas_Object *win;
- Evas_Object *base;
- Evas_Object *dim_ly;
- Evas_Object *box;
- Evas_Object *method_btn;
- Evas_Object *proxy_btn;
- Evas_Object *url_btn;
- Evas_Object *ok_btn;
- Evas_Object *cancel_btn;
- Evas_Object *ctxpopup;
- Evas_Object *vaule_btns[PROXY_CONFIG_MAX_NUM];
-
- enum network_type_enum net_type;
-
- char ip[IP_STRING_LEN + 1];
- char url[MOTHED_URL_LEN + 1];
-
- enum EProxyMethod eMethod;
-
- CWifiMgr *pWifiMgr;
- CNetConMgr *pNetConMgr;
- CViewMgr *pViewMgr;
-};
-
-bool CProxyMainView::m_InitConnection(void)
-{
- bool ret = false;
-
- if(!CWifiMgr::Initialize()) {
- _ERR("Fail to initialize WifiMgr");
- return false;
- }
-
- m->pWifiMgr = CWifiMgr::GetInstance();
- if(!m->pWifiMgr) {
- _ERR("Fail to get instance");
- return false;
- }
-
- ret = CNetConMgr::Initialize();
- if(ret != true) {
- _ERR("Fail to initialize NetConMgr");
- return false;
- }
-
- m->pNetConMgr = CNetConMgr::GetInstance();
- if(!m->pNetConMgr) {
- _ERR("Fail to get instance");
- return false;
- }
-
- return true;
-}
-
-
-void CProxyMainView::m_FinalizeConnection()
-{
- CNetConMgr::Finalize();
- CWifiMgr::Finalize();
- m->pNetConMgr = NULL;
- m->pWifiMgr = NULL;
-}
-
-
-Evas_Object* CProxyMainView::m_CreateMainLayout(void)
-{
- Evas_Object *base;
-
- base = util_add_layout(m->win, UG_PROXY_EDJ_FILE, GRP_MAIN_VIEW);
- if (!base) {
- _ERR("elm_layout_add() failed.");
- return NULL;
- }
-
- //evas_object_event_callback_add(base, EVAS_CALLBACK_KEY_DOWN, _base_key_pressed_cb, priv);
- Connect(base, 0);
-
- evas_object_show(base);
-
- return base;
-}
-
-
-Evas_Object * CProxyMainView::m_CreateValueBtn(Evas_Object *parent, int num, char *txt)
-{
- Evas_Object *btn;
-
- btn = util_add_button(parent, STYLE_VALUE_BTN, NULL, txt);
- if (!btn) {
- _ERR("add button failed.");
- return NULL;
- }
-
- switch (num) {
- case 0:
- elm_object_part_content_set(parent, PART_IP_FIRST, btn);
- evas_object_data_set(parent, IP_VALUE1, btn);
- elm_object_focus_set(btn, EINA_TRUE);
- break;
- case 1:
- elm_object_part_content_set(parent, PART_IP_SECOND, btn);
- evas_object_data_set(parent, IP_VALUE2, btn);
- break;
- case 2:
- elm_object_part_content_set(parent, PART_IP_THIRD, btn);
- evas_object_data_set(parent, IP_VALUE3, btn);
- break;
- case 3:
- elm_object_part_content_set(parent, PART_IP_FORTH, btn);
- evas_object_data_set(parent, IP_VALUE4, btn);
- break;
- default:
- break;
- }
-
- //evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, _value_key_pressed_cb, data);
- Connect(btn, 14);
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_DOWN);
-
- return btn;
-
-}
-
-
-bool CProxyMainView::m_SetWifiProxy(void)
-{
- bool ret = false;
-
- if (!m->pWifiMgr) {
- _ERR("WifiMgr is not initialized.");
- return false;
- }
-
- CWifiAp ap(NULL);
- ap.AllocConnectedAp();
- ret = ap.SetProxyType(m->eMethod);
- if (ret != true) {
- _ERR("wifi_mgr_get_proxy_type() failed.");
- return ret;
- }
-
- switch (m->eMethod) {
- case PROXY_METHOD_NONE:
- ap.SetProxyAddr(NULL);
- break;
- case PROXY_METHOD_MANUAL:
- if (m->ip)
- ap.SetProxyAddr(m->ip);
- break;
- case PROXY_METHOD_AUTO:
- if (m->url)
- ap.SetProxyAddr(m->url);
- //m->pWifiMgr->SetProxyAddr(m->url);
- break;
- default:
- return false;
- }
-
- return true;
-}
-
-
-bool CProxyMainView::m_SetConnectionProxy(void)
-{
- bool ret;
- ret = m->pNetConMgr->SetProxyType(m->eMethod);
- if (ret != true) {
- _ERR("wifi_mgr_get_proxy_type() failed.");
- return false;
- }
-
- switch (m->eMethod) {
- case PROXY_METHOD_NONE:
- break;
- case PROXY_METHOD_MANUAL:
- if (m->ip)
- m->pNetConMgr->SetProxyAddr(m->ip);
- break;
- case PROXY_METHOD_AUTO:
- if (m->url)
- m->pNetConMgr->SetProxyAddr(m->url);
- break;
- default:
- return false;
- }
-
- return true;
-}
-
-
-bool CProxyMainView::m_SetProxy(void)
-{
- bool ret = false;
-
- if (m->net_type == TYPE_WIRED) {
- ret = m_SetConnectionProxy();
- if (ret != true) {
- _ERR("the ip or port is invalid.");
- return ret;
- }
- } else if (m->net_type == TYPE_WIRELESS) {
- ret = m_SetWifiProxy();
- if (ret != true) {
- _ERR("the ip or port is invalid.");
- return ret;
- }
- }
-
- return true;
-
-}
-
-
-void CProxyMainView::m_MethodBtnClicked(EProxyMethod method)
-{
- if (m->ctxpopup) {
- evas_object_del(m->ctxpopup);
- m->ctxpopup = NULL;
- }
-
- m->eMethod = method;
-
- elm_box_clear(m->box);
-
- m->method_btn = NULL;
- m->proxy_btn= NULL;
- m->url_btn = NULL;
-
- switch (m->eMethod) {
- case PROXY_METHOD_NONE:
- m_CreateMethodNoneBtn();
- break;
- case PROXY_METHOD_MANUAL:
- m_CreateMethodManualBtn();
- break;
- case PROXY_METHOD_AUTO:
- m_CreateMethodAutoBtn();
- break;
- default:
- break;
- }
-
- elm_object_focus_set(m->method_btn, EINA_TRUE);
-}
-
-
-void CProxyMainView::m_SetupDownCycleFocus(Evas_Object **obj, int count)
-{
- for (int i = 0; i < count; i++) {
- if (i == count - 1)
- elm_object_focus_next_object_set(obj[i], obj[0], ELM_FOCUS_DOWN);
- else
- elm_object_focus_next_object_set(obj[i], obj[i + 1], ELM_FOCUS_DOWN);
-
- if (i == 0)
- elm_object_focus_next_object_set(obj[i], obj[count - 1], ELM_FOCUS_UP);
- else
- elm_object_focus_next_object_set(obj[i], obj[i - 1], ELM_FOCUS_UP);
- }
-}
-
-
-void CProxyMainView::m_SetTheValue(void)
-{
- Evas_Object *btn;
- const char *value1;
- const char *value2;
- const char *value3;
- const char *value4;
- char ip[IP_STRING_LEN + 1];
-
- value1 = NULL;
- btn = (Evas_Object *) evas_object_data_get(m->ctxpopup, IP_VALUE1);
- if (btn)
- value1 = elm_object_text_get(btn);
-
- value2 = NULL;
- btn = (Evas_Object *) evas_object_data_get(m->ctxpopup, IP_VALUE2);
- if (btn)
- value2 = elm_object_text_get(btn);
-
- value3 = NULL;
- btn = (Evas_Object *) evas_object_data_get(m->ctxpopup, IP_VALUE3);
- if (btn)
- value3 = elm_object_text_get(btn);
-
- value4 = NULL;
- btn = (Evas_Object *) evas_object_data_get(m->ctxpopup, IP_VALUE4);
- if (btn)
- value4 = elm_object_text_get(btn);
-
- memset(ip, 0, IP_STRING_LEN + 1);
- snprintf(ip, IP_STRING_LEN, "%s.%s.%s.%s",
- value1 ? value1 : "\\0", value2 ? value2 : "\\0",
- value3 ? value3 : "\\0", value4 ? value4 : "\\0");
-
- strncpy(m->ip, ip, IP_STRING_LEN);
- elm_object_part_text_set(m->proxy_btn, PART_VALUE, ip);
-
- evas_object_del(m->ctxpopup);
- m->ctxpopup = NULL;
-}
-
-
-void CProxyMainView::m_SetLeftRightCycleFocus(Evas_Object **obj, int count)
-{
- int i;
-
- if (!obj || !*obj) {
- _ERR("the param is invalid.");
- return;
- }
-
- for (i = 0; i < count; i++) {
- if (i == count - 1)
- elm_object_focus_next_object_set(obj[i], obj[0], ELM_FOCUS_RIGHT);
- else
- elm_object_focus_next_object_set(obj[i], obj[i + 1], ELM_FOCUS_RIGHT);
-
- if (i == 0)
- elm_object_focus_next_object_set(obj[i], obj[count - 1], ELM_FOCUS_LEFT);
- else
- elm_object_focus_next_object_set(obj[i], obj[i - 1], ELM_FOCUS_LEFT);
- }
-}
-
-
-void CProxyMainView::m_CreateValuePopup(void)
-{
- Evas_Object *ctxpopup;
- Evas_Object *btn;
- Evas_Coord pos_x;
- Evas_Coord pos_y;
- int i;
-
- ctxpopup = util_add_layout(m->base, UG_PROXY_EDJ_FILE, GRP_PROXY_VALUE_SETTING);
- if (!ctxpopup) {
- _ERR("elm_ctxpopup_add() failed.");
- return;
- }
-
- m->ctxpopup = ctxpopup;
-
- evas_object_show(m->dim_ly);
-
- for (i = 0; i < PROXY_CONFIG_MAX_NUM; i++) {
- btn = m_CreateValueBtn(ctxpopup, i, _(TXT_ZERO));
- if (!btn) {
- _ERR("m_CreateValueBtn() failed.");
- evas_object_del(ctxpopup);
- return;
- }
-
- m->vaule_btns[i] = btn;
- }
-
- elm_object_part_text_set(ctxpopup, PART_TXT_SEPERATOR, _(TXT_COLON));
- //evas_object_smart_callback_add(ctxpopup, SIG_UNFOCUSED, _ctxpopup_unfocused_cb, priv);
- //evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_KEY_DOWN, _value_ctxpopup_key_pressed_cb, priv);
- Connect(ctxpopup, 10);
- m_SetLeftRightCycleFocus(m->vaule_btns, PROXY_CONFIG_MAX_NUM);
-
- pos_x = 0;
- pos_y = 0;
-
- Evas_Coord x;
- Evas_Coord y;
- evas_object_geometry_get(m->proxy_btn, &x, &y, NULL, NULL);
- pos_x = x + VALUE_CTXPOPUP_OFFSET_X;
- pos_y = y - VALUE_CTXPOPUP_OFFSET_Y;
-
- evas_object_move(ctxpopup, pos_x * ELM_SCALE, pos_y * ELM_SCALE);
-}
-
-
-void CProxyMainView::m_CreateInputEntry(void)
-{
- Evas_Object *entry;
- Evas_Object *layout;
-
- if (m->ctxpopup) {
- evas_object_del(m->ctxpopup);
- m->ctxpopup = NULL;
- }
-
- layout = util_add_layout(m->base, UG_PROXY_EDJ_FILE, GRP_ENTRY_POPUP);
- if (!layout) {
- _ERR("create layout fail.");
- return;
- }
-
- entry = util_add_entry(layout, STYLE_ENTRY, PART_ENTRY);
- if (!entry) {
- _ERR("add entry failed.");
- evas_object_del(layout);
- return;
- }
-
- util_set_focus_next_self(entry);
- //evas_object_event_callback_add(entry, EVAS_CALLBACK_KEY_DOWN, _entry_key_pressed_cb, priv);
- Connect(entry, 9);
- elm_object_focus_set(entry, EINA_TRUE);
-
- evas_object_show(m->dim_ly);
-
- m->ctxpopup = layout;
-}
-
-
-void CProxyMainView::m_ShowInvalidInfoPopup(int status)
-{
- Evas_Object *layout;
- Evas_Object *btn;
- Evas_Coord w;
- Evas_Coord h;
-
- if (m->ctxpopup) {
- evas_object_del(m->ctxpopup);
- m->ctxpopup = NULL;
- }
-
- evas_object_show(m->dim_ly);
-
- layout = util_add_layout(m->base, UG_PROXY_EDJ_FILE, GRP_CONFIRM_LAYOUT);
- if (!layout) {
- _ERR("add layout failed.");
- evas_object_hide(m->dim_ly);
- return;
- }
-
- switch (m->eMethod) {
- case PROXY_METHOD_MANUAL:
- elm_object_part_text_set(layout, PART_TEXT_TITLE, _(TXT_MANUAL_TITLE));
- break;
- case PROXY_METHOD_AUTO:
- elm_object_part_text_set(layout, PART_TEXT_TITLE, _(TXT_AUTO_TITLE));
- break;
- default:
- evas_object_del(layout);
- evas_object_hide(m->dim_ly);
- return;
- }
-
- elm_object_part_text_set(layout, PART_TEXT_TITLE, _(TXT_MANUAL_TITLE));
-
- if (status == RET_IP_INVALID)
- elm_object_part_text_set(layout, PART_TEXT_CONTENT, _(TXT_IP_INVALID));
- else if (status == RET_VCONF_FAILED)
- elm_object_part_text_set(layout, PART_TEXT_CONTENT, _(TXT_VCONF_FAILED));
- else if (status == RET_WIRED_PROXY_FAILED)
- elm_object_part_text_set(layout, PART_TEXT_CONTENT, _(TXT_WIRED_FAILED));
- else if (status == RET_WIRELESS_PROXY_FAILED)
- elm_object_part_text_set(layout, PART_TEXT_CONTENT, _(TXT_WIRELESS_FAILED));
-
- btn = util_add_button(layout, STYLE_ACTION_BTN, PART_OK_BTN, _(TXT_OK));
- if (!btn) {
- _ERR("util add button failed.");
- evas_object_del(layout);
- evas_object_hide(m->dim_ly);
- return;
- }
-
- elm_object_focus_set(btn, EINA_TRUE);
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_DOWN);
-
- //evas_object_smart_callback_add(btn, SIG_CLICKED, _ctxpopup_ok_btn_clicked_cb, priv);
- //evas_object_smart_callback_add(layout, SIG_UNFOCUSED, _ctxpopup_unfocused_cb, priv);
- //evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN, _ctxpopup_key_pressed_cb, priv);
- Connect(btn, 7);
- Connect(layout, 8);
-
- w = DEFAULT_WIN_WIDTH;
- h = DEFAULT_WIN_HEIGHT;
-
- evas_object_move(layout, CENTER_ALIGN * (w - CTXPOPUP_WIDTH) * ELM_SCALE, CENTER_ALIGN * (h - CTXPOPUP_HEIGHT) * ELM_SCALE);
-
- m->ctxpopup = layout;
-}
-
-
-bool CProxyMainView::m_CreateMethodBoxBtn(Evas_Object *btn, const char *key, char *value, int line)
-{
- if (btn) {
- evas_object_show(btn);
- elm_object_part_text_set(btn, PART_VALUE, value);
- } else {
- if (line == BTN_TWO_LINE)
- btn = util_add_key_value_button(m->box, STYLE_KEY_VALUE_TWO_LINES, NULL, key, value);
- else
- btn = util_add_key_value_button(m->box, STYLE_KEY_VALUE_BTN, NULL, key, value);
-
- if (!btn) {
- _ERR("add method btn failed.");
- return false;
- }
- }
- return true;
-}
-
-
-bool CProxyMainView::m_CreateMethodAutoBtn(void)
-{
- Evas_Object *box;
- box = m->box;
-
- if(!m_CreateMethodBoxBtn(m->method_btn, _(TXT_MOTHED), _(TXT_MOTHED_AUTO), BTN_ONE_LINE)) {
- _ERR("add method btn failed.");
- return false;
- }
- ASSERT(m->method_btn);
- //evas_object_smart_callback_add(btn, SIG_CLICKED, _method_btn_clicked_cb, priv);
- Connect(m->method_btn, 3);
- elm_object_focus_next_object_set(m->method_btn, m->method_btn, ELM_FOCUS_LEFT);
- elm_box_pack_end(box, m->method_btn);
-
- if(!m_CreateMethodBoxBtn(m->url_btn, _(TXT_CONFIG_URL), _(m->url), BTN_TWO_LINE)) {
- _ERR("add url btn failed.");
- return false;
- }
- ASSERT(m->url_btn);
- //evas_object_smart_callback_add(btn, SIG_CLICKED, _url_btn_clicked_cb, priv);
- Connect(m->url_btn, 4);
- elm_object_focus_next_object_set(m->url_btn, m->url_btn, ELM_FOCUS_LEFT);
- elm_box_pack_end(box, m->url_btn);
-
- return true;
-}
-
-
-bool CProxyMainView::m_CreateMethodManualBtn(void)
-{
- Evas_Object *box;
- box = m->box;
-
- if(!m_CreateMethodBoxBtn(m->method_btn, _(TXT_MOTHED), _(TXT_MOTHED_MAN), BTN_ONE_LINE)) {
- _ERR("add method btn failed.");
- return false;
- }
- ASSERT(m->method_btn);
- //evas_object_smart_callback_add(btn, SIG_CLICKED, _method_btn_clicked_cb, priv);
- Connect(m->method_btn, 3);
- elm_object_focus_next_object_set(m->method_btn, m->method_btn, ELM_FOCUS_LEFT);
- elm_box_pack_end(box, m->method_btn);
-
- if(!m_CreateMethodBoxBtn(m->proxy_btn, _(TXT_PROXY_IP), _(m->ip), BTN_ONE_LINE)) {
- _ERR("add http btn failed.");
- return false;
- }
- ASSERT(m->proxy_btn);
- //evas_object_smart_callback_add(btn, SIG_CLICKED, _proxy_ip_btn_clicked_cb, priv);
- Connect(m->proxy_btn, 5);
- elm_object_focus_next_object_set(m->proxy_btn, m->proxy_btn, ELM_FOCUS_LEFT);
- elm_box_pack_end(box, m->proxy_btn);
-
- return true;
-}
-
-
-bool CProxyMainView::m_CreateMethodNoneBtn(void)
-{
- if(!m_CreateMethodBoxBtn(m->method_btn, _(TXT_MOTHED), _(TXT_MOTHED_NONE), BTN_ONE_LINE)) {
- _ERR("add method btn failed.");
- return false;
- }
- //evas_object_smart_callback_add(btn, SIG_CLICKED, _method_btn_clicked_cb, priv);
- Connect(m->method_btn, 3);
- elm_object_focus_next_object_set(m->method_btn, m->method_btn, ELM_FOCUS_LEFT);
- elm_box_pack_end(m->box, m->method_btn);
-
- return true;
-}
-
-
-bool CProxyMainView::m_CreateDimLayout(void)
-{
- Evas_Object *dim_ly;
-
- dim_ly = util_add_layout(m->base, UG_PROXY_EDJ_FILE, GRP_DIM_LY);
- if (!dim_ly) {
- _ERR("elm_layout_add() failed.");
- return false;
- }
-
- m->dim_ly = dim_ly;
- evas_object_hide(m->dim_ly);
-
- return true;
-}
-
-
-bool CProxyMainView::m_CreateActionBtns(void)
-{
- Evas_Object *btn;
-
- btn = util_add_button(m->base, STYLE_ACTION_BTN, PART_OK_BTN, _(TXT_OK));
- if (!btn) {
- _ERR("add ok button failed.");
- return false;
- }
-
- //evas_object_smart_callback_add(btn, SIG_CLICKED, _ok_btn_clicked_cb, priv);
- Connect(btn, 1);
-
- elm_object_focus_set(btn, EINA_TRUE);
-
- btn = util_add_button(m->base, STYLE_ACTION_BTN, PART_CANCEL_BTN, _(TXT_CANCEL));
- if (!btn) {
- _ERR("add cancel button failed.");
- return false;
- }
-
- //evas_object_smart_callback_add(btn, SIG_CLICKED, _cancel_btn_clicked_cb, priv);
- Connect(btn, 2);
-
- return true;
-}
-
-
-bool CProxyMainView::m_GetProxyMethod(void)
-{
- int value;
- int ret;
- char *str;
-
- str = vconf_get_str(VCONF_NETWORK_TYPE);
- if (str && !strcmp(str, TXT_WIRED))
- m->net_type = TYPE_WIRED;
- else
- m->net_type = TYPE_WIRELESS;
-
- value = 0;
- ret = vconf_get_int((char*) VCONF_PROXY_METHOD, &value);
- if (ret != true) {
- _ERR("vconf_get_int() failed.");
- return false;
- }
-
- switch (value) {
- case 0:
- m->eMethod = PROXY_METHOD_NONE;
- break;
- case 1:
- m->eMethod = PROXY_METHOD_MANUAL;
- break;
- case 2:
- m->eMethod = PROXY_METHOD_AUTO;
- break;
- default:
- return false;
- }
-
- char *ip = NULL;
- ip = vconf_get_str(VCONF_PROXY_IP);
- if (!ip)
- snprintf(m->ip, IP_STRING_LEN, "%s", IP_ZERO);
- else
- snprintf(m->ip, IP_STRING_LEN, "%s", ip);
-
- str = vconf_get_str(VCONF_PROXY_URL);
- if (!str)
- snprintf(m->url, MOTHED_URL_LEN, "%s", URL_BLANK);
- else
- snprintf(m->url, MOTHED_URL_LEN, "%s", str);
-
- return true;
-}
-
-
-bool CProxyMainView::m_CreateProxyLayout(void)
-{
- Evas_Object *box;
- int ret;
-
- box = util_add_box(m->base, PART_PROXY_SETTING);
- if (!box) {
- _ERR("add box failed.");
- return false;
- }
-
- m->box = box;
-
- switch (m->eMethod) {
- case PROXY_METHOD_NONE:
- ret = m_CreateMethodNoneBtn();
- if (ret != true) {
- _ERR("add method none failed.");
- evas_object_del(box);
- return false;
- }
-
- break;
- case PROXY_METHOD_MANUAL:
- ret = m_CreateMethodManualBtn();
- if (ret != true) {
- _ERR("add method manual failed.");
- evas_object_del(box);
- return false;
- }
-
- break;
- case PROXY_METHOD_AUTO:
- ret = m_CreateMethodAutoBtn();
- if (ret != true) {
- _ERR("add method manual failed.");
- evas_object_del(box);
- return false;
- }
-
- break;
- default:
- break;
- }
-
- return true;
-}
-
-
-void CProxyMainView::t_OnShow()
-{
- _DBG();
-
- evas_object_show(m->base);
-
- CBaseView::t_OnShow();
-}
-
-
-void CProxyMainView::t_OnUpdate(void *data)
-{
- _DBG();
-
- evas_object_show(m->base);
-
-#if 0
- switch (m->cur_view) {
- case NETWORK_IP_SETTING_VIEW:
- elm_object_focus_set(m->other_btn, EINA_TRUE);
- break;
- case NETWORK_WIFI_PASSCODE_VIEW:
- elm_object_focus_set(m->connect_btn, EINA_TRUE);
- break;
- default:
- break;
- }
-#endif
-}
-
-
-void CProxyMainView::t_OnHide()
-{
- _DBG();
-
- evas_object_hide(m->base);
-
- CBaseView::t_OnHide();
-}
-
-
-bool CProxyMainView::Create(void *data)
-{
- _DBG();
- ASSERT(!m);
-
- _CREATE_BEGIN{
- _CHECK(m = new SProxyMainView)
- _CHECK(m->win = CViewMgr::GetInstance()->Window())
- _CHECK(m_InitConnection())
- _CHECK(m->base = m_CreateMainLayout())
- _CHECK(m_GetProxyMethod())
- _CHECK(m_CreateProxyLayout())
- _CHECK(m_CreateActionBtns())
- _CHECK(m_CreateDimLayout())
-
- _WHEN_SUCCESS {
- elm_object_part_text_set(m->base, PART_PROXY_DESCRITION, _(TXT_PROXY_DESCRIPTION));
- elm_object_focus_set(m->method_btn, EINA_TRUE);
- m->pViewMgr = CViewMgr::GetInstance();
- }
-
- _CHECK_FAIL{/* m_CreateDimLayout() */}
- _CHECK_FAIL{/* m_CreateActionBtns() */}
- _CHECK_FAIL{/* m_CreateProxyLayout() */}
- _CHECK_FAIL{/* m_GetProxyMethod() */}
- _CHECK_FAIL{evas_object_del(m->base);}
- _CHECK_FAIL{m_FinalizeConnection();}
- _CHECK_FAIL{/* m->win = CViewMgr::GetInstance()->Window() */}
- _CHECK_FAIL{ delete m; m = NULL; }
- } _CREATE_END_AND_CATCH{ return false; }
-
- return true;
-}
-
-void CProxyMainView::Destroy()
-{
- ASSERT(m);
- _DBG();
-
- CBaseView::Destroy();
- delete m;
- m = NULL;
-}
-
-
-Evas_Object* CProxyMainView::Base()
-{
- ASSERT(m);
- _DBG();
-
- return m->base;
-}
-
-
-void CProxyMainView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
-{
- /* ID list */
- /* 0 m->base */
- /* 1 action ok_btn */
- /* 2 action cancel_btn */
- /* 3 method_btn */
- /* 4 url_btn */
- /* 5 proxy_btn */
- /* 6 ctxpopup */
- /* 7 invalidinfo popup ok_btn */
- /* 8 invalidinfo popup layout */
- /* 9 input entry */
- /* 10 value popup */
-
- if (!ev->keyname) {
- _ERR("ev->keyname is NULL.");
- return;
- }
-
- switch(id) {
- case 0:
- if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
- ug_destroy_me(m->ug);
- return;
- }
- break;
- case 6:
- case 8:
- if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
- evas_object_hide(m->dim_ly);
- if (m->ctxpopup) {
- evas_object_del(m->ctxpopup);
- m->ctxpopup = NULL;
- }
- }
- break;
- case 9:
- elm_entry_input_panel_show(obj);
-
- if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
- if (m->ctxpopup) {
- evas_object_del(m->ctxpopup);
- m->ctxpopup = NULL;
- }
- evas_object_hide(m->dim_ly);
- } else if (!strcmp(ev->keyname, KEY_PROXY_ENTER)) {
- const char *value;
- value = elm_entry_entry_get(obj);
- elm_object_part_text_set(m->url_btn, PART_VALUE, value);
- memset(m->url, 0, MOTHED_URL_LEN + 1);
- strncpy(m->url, value, MOTHED_URL_LEN);
-
- if (m->ctxpopup) {
- evas_object_del(m->ctxpopup);
- m->ctxpopup = NULL;
- }
-
- elm_object_focus_set(m->url_btn, EINA_TRUE);
- evas_object_hide(m->dim_ly);
- }
- break;
- case 10:
- if (!strcmp(ev->keyname, KEY_ENTER) || !strcmp(ev->keyname, KEY_ENTER_REMOTE)) {
- evas_object_show(m->dim_ly);
- m_SetTheValue();
- evas_object_del(obj);
- } else if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
- evas_object_hide(m->dim_ly);
- evas_object_del(obj);
- }
- break;
- case 14:
- const char *value;
- int num, new_num, max_num;
- max_num = IP_MAX_NUM;
-
- if (!strcmp(ev->keyname, KEY_UP)) {
- value = elm_object_text_get(obj);
- num = atoi(value);
- num++;
- if (num > max_num)
- num = 0;
- } else if (!strcmp(ev->keyname, KEY_DOWN)) {
- value = elm_object_text_get(obj);
- num = atoi(value);
- num--;
- if (num < 0)
- num = max_num;
- } else if (!strcmp(ev->keyname, KEY_0) ||
- !strcmp(ev->keyname, KEY_1) ||
- !strcmp(ev->keyname, KEY_2) ||
- !strcmp(ev->keyname, KEY_3) ||
- !strcmp(ev->keyname, KEY_4) ||
- !strcmp(ev->keyname, KEY_5) ||
- !strcmp(ev->keyname, KEY_6) ||
- !strcmp(ev->keyname, KEY_7) ||
- !strcmp(ev->keyname, KEY_8) ||
- !strcmp(ev->keyname, KEY_9)) {
- value = elm_object_text_get(obj);
- if (!value)
- elm_object_text_set(obj, ev->keyname);
-
- new_num = atoi(ev->keyname);
-
- num = atoi(value);
- if (!num || (num * IP_RATIO + new_num) > max_num) {
- elm_object_text_set(obj, ev->keyname);
- return;
- }
-
- num = num * IP_RATIO + new_num;
- } else {
- return;
- }
-
- char temp_value[MOTHED_STRING_LEN];
-
- if (!obj) {
- _ERR("The param is invalid.");
- return;
- }
-
- memset(temp_value, 0, MOTHED_STRING_LEN);
- snprintf(temp_value, MOTHED_STRING_LEN - 1, "%d", num);
- elm_object_text_set(obj, temp_value);
- break;
- default:
- break;
- }
-}
-
-
-void CProxyMainView::OnMouseClicked(int id, Evas_Object *obj)
-{
- bool ret = false;
-
- switch(id) {
- case 1:
- ret = m_SetProxy();
- if (ret != true) {
- _ERR("the ip or port is invalid.");
- m_ShowInvalidInfoPopup(ret);
- return;
- }
-
- vconf_set_int((char*)VCONF_PROXY_METHOD, m->eMethod);
-
- if (m->eMethod == PROXY_METHOD_MANUAL) {
- if (!strncmp(m->ip, IP_ZERO, IP_STRING_LEN)) {
- _ERR("IP addr is invalid.");
- }
- vconf_set_str((char*)VCONF_PROXY_IP, m->ip);
- }
- else if(m->eMethod == PROXY_METHOD_AUTO) {
- vconf_set_str((char*)VCONF_PROXY_URL, m->url);
- }
- ug_destroy_me(m->ug);
- break;
- case 2:
- ug_destroy_me(m->ug);
- break;
- case 3:
- Evas_Object *ctxpopup;
- Evas_Object *box;
- Evas_Object *none_btn;
- Evas_Object *man_btn;
- Evas_Object *auto_btn;
- Evas_Object *btn[METHOD_NUM];
- Evas_Coord x;
- Evas_Coord y;
- Evas_Coord w;
- Evas_Coord h;
-
- ctxpopup = util_add_layout(m->base, UG_PROXY_EDJ_FILE, GRP_METHOD_SETTING);
- if (!ctxpopup) {
- _ERR("add method ctxpopup failed.");
- return;
- }
-
- //evas_object_smart_callback_add(ctxpopup, SIG_UNFOCUSED, _ctxpopup_unfocused_cb, priv);
- //evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_KEY_DOWN, _ctxpopup_key_pressed_cb, priv);
- Connect(ctxpopup, 6);
-
- m->ctxpopup = ctxpopup;
-
- elm_object_signal_emit(m->method_btn, SIG_BTN_SELECTED, PROG);
- evas_object_show(m->dim_ly);
-
- box = util_add_box(ctxpopup, PART_SWALLOW_CONTENT);
- if (!box) {
- _ERR("create box failed.");
- evas_object_del(ctxpopup);
- return;
- }
-
- none_btn = util_add_button(ctxpopup, STYLE_METHOD_SET, NULL, _(TXT_MOTHED_NONE));
- if (!none_btn) {
- _ERR("Add btn failed.");
- evas_object_del(ctxpopup);
- return;
- }
- //evas_object_smart_callback_add(none_btn, SIG_CLICKED, _method_none_btn_clicked_cb, NULL);
- Connect(none_btn, 11);
-
- elm_box_pack_end(box, none_btn);
- elm_object_focus_set(none_btn, EINA_TRUE);
- btn[PROXY_METHOD_NONE] = none_btn;
-
- man_btn = util_add_button(ctxpopup, STYLE_METHOD_SET, NULL, _(TXT_MOTHED_MAN));
- if (!man_btn) {
- _ERR("Add btn failed.");
- evas_object_del(ctxpopup);
- return;
- }
- //evas_object_smart_callback_add(man_btn, SIG_CLICKED, _method_man_btn_clicked_cb, NULL);
- Connect(man_btn, 12);
-
- elm_box_pack_end(box, man_btn);
- btn[PROXY_METHOD_MANUAL] = man_btn;
-
- auto_btn = util_add_button(ctxpopup, STYLE_METHOD_SET, NULL, _(TXT_MOTHED_AUTO));
- if (!auto_btn) {
- _ERR("Add btn failed.");
- evas_object_del(ctxpopup);
- return;
- }
- //evas_object_smart_callback_add(auto_btn, SIG_CLICKED, _method_auto_btn_clicked_cb, NULL);
- Connect(auto_btn, 13);
- elm_box_pack_end(box, auto_btn);
- btn[PROXY_METHOD_AUTO] = auto_btn;
- m_SetupDownCycleFocus(btn, METHOD_NUM);
- m_SetLeftRightCycleFocus(btn, METHOD_NUM);
-
- switch (m->eMethod) {
- case PROXY_METHOD_NONE:
- elm_object_signal_emit(none_btn, SIG_BTN_SELECTED, PROG);
- break;
- case PROXY_METHOD_MANUAL:
- elm_object_signal_emit(man_btn, SIG_BTN_SELECTED, PROG);
- break;
- case PROXY_METHOD_AUTO:
- elm_object_signal_emit(auto_btn, SIG_BTN_SELECTED, PROG);
- break;
- default:
- break;
- }
-
- evas_object_geometry_get(m->method_btn, &x, &y, &w, &h);
- evas_object_move(ctxpopup, (x + METHOD_CTXPOPUP_OFFSET_X) * ELM_SCALE, (y + ALIGH_RATIO * h + LINE_PAD) * ELM_SCALE);
- break;
- case 4:
- m_CreateInputEntry();
- break;
- case 5:
- elm_object_signal_emit(m->proxy_btn, SIG_BTN_SELECTED, PROG);
- m_CreateValuePopup();
- break;
- case 7:
- if (m->ctxpopup) {
- evas_object_del(m->ctxpopup);
- m->ctxpopup = NULL;
- }
- evas_object_hide(m->dim_ly);
- elm_object_focus_set(m->ok_btn, EINA_TRUE);
- break;
- case 11:
- m_MethodBtnClicked(PROXY_METHOD_NONE);
- break;
- case 12:
- m_MethodBtnClicked(PROXY_METHOD_MANUAL);
- break;
- case 13:
- m_MethodBtnClicked(PROXY_METHOD_AUTO);
- break;
- default:
- break;
- }
-}
-
-
-void CProxyMainView::OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item)
-{
- switch(id) {
- case 0:
- break;
- case 6:
- case 8:
- case 10:
- evas_object_hide(m->dim_ly);
- if (m->ctxpopup) {
- evas_object_del(m->ctxpopup);
- m->ctxpopup = NULL;
- }
- break;
- default:
- break;
- }
-}
diff --git a/ug/proxy/src/connection_mgr.c b/ug/proxy/src/connection_mgr.c
new file mode 100644
index 0000000..3726c84
--- /dev/null
+++ b/ug/proxy/src/connection_mgr.c
@@ -0,0 +1,369 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <Elementary.h>
+#include <aul.h>
+#include "defs.h"
+#include "dbg.h"
+#include "connection_mgr.h"
+
+/**
+ * Converts the error type to string information.
+ *
+ * @param[in] err_type Error type
+ * @return error string information;
+ */
+static const char *_convert_error_to_string(connection_error_e err_type)
+{
+ _DBG("Not Yet");
+#if 0
+ switch (err_type) {
+ case CONNECTION_ERROR_NONE:
+ return "NONE";
+ case CONNECTION_ERROR_INVALID_PARAMETER:
+ return "INVALID_PARAMETER";
+ case CONNECTION_ERROR_OUT_OF_MEMORY:
+ return "OUT_OF_MEMORY";
+ case CONNECTION_ERROR_INVALID_OPERATION:
+ return "INVALID_OPERATION";
+ case CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
+ return "ADDRESS_FAMILY_NOT_SUPPORTED";
+ case CONNECTION_ERROR_OPERATION_FAILED:
+ return "OPERATION_FAILED";
+ case CONNECTION_ERROR_ITERATOR_END:
+ return "ITERATOR_END";
+ case CONNECTION_ERROR_NO_CONNECTION:
+ return "NO_CONNECTION";
+ case CONNECTION_ERROR_NOW_IN_PROGRESS:
+ return "NOW_IN_PROGRESS";
+ case CONNECTION_ERROR_ALREADY_EXISTS:
+ return "ALREADY_EXISTS";
+ case CONNECTION_ERROR_OPERATION_ABORTED:
+ return "OPERATION_ABORTED";
+ case CONNECTION_ERROR_DHCP_FAILED:
+ return "DHCP_FAILED";
+ case CONNECTION_ERROR_INVALID_KEY:
+ return "INVALID_KEY";
+ case CONNECTION_ERROR_NO_REPLY:
+ return "NO_REPLY";
+ case CONNECTION_ERROR_NO_KEYWORD:
+ return "NO_KEYWORD";
+ case CONNECTION_ERROR_TCP_RST:
+ return "RST_IN_TCP_RESPONSE";
+ case CONNECTION_ERROR_TCP_SYN_TIMEOUT:
+ return "TCP_SYN_TIMEOUT";
+ case CONNECTION_ERROR_OFFLINE:
+ return "CONNECTION_OFFLINE";
+ case CONNECTION_ERROR_NETWORK_MONITOR_FAILURE:
+ return "monitor failer";
+ case CONNECTION_ERROR_INVALID_GATEWAY:
+ return "invalid gateway";
+ case CONNECTION_ERROR_INVALID_MACADDRESS:
+ return "invalid mac addr";
+ default:
+ break;
+ }
+
+#endif
+ return "Unknown";
+}
+
+/**
+ * Creates a handle for managing data connections.
+ *
+ * The handle must be released with connection_destroy().
+ *
+ * @return connetcion if the operation is successful; NULL if failed;
+ */
+connection_h connection_mgr_create(void)
+{
+ int ret;
+ connection_h connection;
+
+ connection = NULL;
+ ret = connection_create(&connection);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_create failed");
+ connection = NULL;
+ }
+
+ return connection;
+}
+
+/**
+ * Destroys the connection handle.
+ *
+ * @param[in] connection The handle of the connection
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int connection_mgr_destroy(connection_h connection)
+{
+ int ret;
+
+ if (!connection) {
+ _ERR("connection is NULL.");
+ return RET_FAILED;
+ }
+
+ ret = connection_destroy(connection);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_destroy() failed.");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets the ethernet profile information.
+ *
+ * Iterates all the profile in the connection, and gets the ethernet one.
+ *
+ * @param[in] connection The handle of the connection
+ * @param[out] info The structure to store profile information
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int connection_mgr_get_profile_info(connection_h connection,
+ connection_profile_h *out_profile)
+{
+ connection_profile_iterator_h iter;
+ connection_profile_h profile;
+ connection_profile_type_e type;
+ char *name;
+ int ret;
+
+ if (!connection || !out_profile) {
+ _ERR("param is NULL.");
+ return RET_FAILED;
+ }
+
+ ret = connection_get_profile_iterator(connection,
+ CONNECTION_ITERATOR_TYPE_REGISTERED, &iter);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("Fail to get profile iterator: %s.\n",
+ _convert_error_to_string(ret));
+ return RET_FAILED;
+ }
+
+ while (connection_profile_iterator_has_next(iter)) {
+ profile = NULL;
+ if (connection_profile_iterator_next(iter,
+ &profile) != CONNECTION_ERROR_NONE) {
+ _ERR("Fail to get profile handle\n");
+ return RET_FAILED;
+ }
+
+ if (!profile) {
+ _ERR("get profile failed.");
+ return RET_FAILED;
+ }
+
+ if (connection_profile_get_type(profile,
+ &type) != CONNECTION_ERROR_NONE) {
+ _ERR("Fail to get profile type\n");
+ return RET_FAILED;
+ }
+
+ name = NULL;
+ if (connection_profile_get_name(profile,
+ &name) != CONNECTION_ERROR_NONE) {
+ _ERR("Fail to get profile name\n");
+ return RET_FAILED;
+ }
+
+ if (!name) {
+ _ERR("get name failed.");
+ return RET_FAILED;
+ }
+
+ if (type == CONNECTION_PROFILE_TYPE_ETHERNET)
+ *out_profile = profile;
+
+ free(name);
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets the Proxy type.
+ *
+ * If you set Proxy type to #WIFI_PROXY_TYPE_AUTO or
+ * #WIFI_PROXY_TYPE_MANUAL, then Proxy will be restored.
+ *
+ * @param[in] connection The handle of the connection
+ * @param[in] method The proxy type
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int connection_mgr_set_proxy_type(connection_h connection,
+ enum method_enum method)
+{
+ connection_profile_h profile;
+ connection_proxy_type_e type;
+ int ret;
+
+ if (!connection) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ profile = NULL;
+ ret = connection_mgr_get_profile_info(connection, &profile);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_mgr_get_profile_info() failed.\n");
+ return RET_FAILED;
+ }
+
+ switch (method) {
+ case METHOD_NONE:
+ type = CONNECTION_PROXY_TYPE_DIRECT;
+ break;
+ case METHOD_MAN:
+ type = CONNECTION_PROXY_TYPE_MANUAL;
+ break;
+ case METHOD_AUTO:
+ type = CONNECTION_PROXY_TYPE_AUTO;
+ break;
+ default:
+ return RET_FAILED;
+ }
+
+ ret = connection_profile_set_proxy_type(profile, type);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_profile_set_proxy_type() failed.\n");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets the Proxy type.
+ *
+ * @param[in] connection The handle of the connection
+ * @param[out] method The proxy type
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int connection_mgr_get_proxy_type(connection_h connection,
+ enum method_enum *method)
+{
+ connection_profile_h profile;
+ connection_proxy_type_e type;
+ int ret;
+
+ if (!connection || !method) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ profile = NULL;
+ ret = connection_mgr_get_profile_info(connection, &profile);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_mgr_get_profile_info() failed.\n");
+ return RET_FAILED;
+ }
+
+ ret = connection_profile_get_proxy_type(profile, &type);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_profile_get_proxy_type() failed.\n");
+ return RET_FAILED;
+ }
+
+ switch (type) {
+ case CONNECTION_PROXY_TYPE_DIRECT:
+ *method = METHOD_NONE;
+ break;
+ case CONNECTION_PROXY_TYPE_MANUAL:
+ *method = METHOD_MAN;
+ break;
+ case CONNECTION_PROXY_TYPE_AUTO:
+ *method = METHOD_AUTO;
+ break;
+ default:
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets the Proxy address.
+ *
+ * @param[in] connection The handle of the connection
+ * @param[in] ip IP address
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int connection_mgr_set_proxy_address(connection_h connection,
+ const char *ip)
+{
+ connection_profile_h profile;
+ int ret;
+
+ if (!connection) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ profile = NULL;
+ ret = connection_mgr_get_profile_info(connection, &profile);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_mgr_get_profile_info() failed.\n");
+ return RET_FAILED;
+ }
+
+ ret = connection_profile_set_proxy_address(profile,
+ CONNECTION_ADDRESS_FAMILY_IPV4, ip);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_profile_set_proxy_address() failed.\n");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets the Proxy address.
+ *
+ * @param[in] connection The handle of the connection
+ * @param[out] ip IP address
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int connection_mgr_get_proxy_address(connection_h connection, char **ip)
+{
+ connection_profile_h profile;
+ int ret;
+
+ if (!connection || !ip || !*ip) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ profile = NULL;
+ ret = connection_mgr_get_profile_info(connection, &profile);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_mgr_get_profile_info() failed.\n");
+ return RET_FAILED;
+ }
+
+ ret = connection_profile_get_proxy_address(profile,
+ CONNECTION_ADDRESS_FAMILY_IPV4, ip);
+ if (ret != CONNECTION_ERROR_NONE) {
+ _ERR("connection_profile_get_proxy_address() failed.\n");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
diff --git a/ug/proxy/src/main_view.c b/ug/proxy/src/main_view.c
new file mode 100644
index 0000000..2096d8b
--- /dev/null
+++ b/ug/proxy/src/main_view.c
@@ -0,0 +1,2068 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <Elementary.h>
+#include <ui-gadget-module.h>
+
+#include <KeyDefine.h>
+
+#include "defs.h"
+#include "dbg.h"
+#include "main_view.h"
+#include "vconf_mgr.h"
+#include "wifi_mgr.h"
+#include "connection_mgr.h"
+#include "i18n.h"
+#include "util.h"
+#include "common.h"
+
+#define KEY_PRIV "priv"
+#define KEY_PROXY_ENTER "Select"
+#define IP_VALUE1 "value1"
+#define IP_VALUE2 "value2"
+#define IP_VALUE3 "value3"
+#define IP_VALUE4 "value4"
+
+static const char *VCONF_NETWORK_TYPE = "db/menu/network/network_type";
+static const char *VCONF_PROXY_METHOD = "db/menu/proxy/method";
+static const char *VCONF_PROXY_IP = "db/menu/proxy/ip";
+static const char *VCONF_PROXY_URL = "db/menu/proxy/url";
+
+#define METHOD_CTXPOPUP_OFFSET_X 448
+#define VALUE_CTXPOPUP_OFFSET_X 162
+#define VALUE_CTXPOPUP_OFFSET_Y 20
+#define PROXY_CONFIG_MAX_NUM 4
+#define IP_MAX_NUM 255
+#define IP_RATIO 10
+#define PORT_MAX_NUM 65535
+#define PORT_INVALID_NUM 65536
+#define PORT_NO_NEED 65537
+#define CENTER_ALIGN 0.5
+#define CTXPOPUP_WIDTH 688
+#define CTXPOPUP_HEIGHT 411
+#define BTN_ONE_LINE 1
+#define BTN_TWO_LINE 2
+#define LINE_PAD 2
+#define ALIGH_RATIO 1.5
+
+enum network_type_enum {
+ TYPE_WIRELESS = 0,
+ TYPE_WIRED
+};
+
+struct _priv {
+ Evas_Object *win;
+ ui_gadget_h ug;
+
+ Evas_Object *base;
+ Evas_Object *dim_ly;
+ Evas_Object *box;
+ Evas_Object *method_btn;
+ Evas_Object *proxy_btn;
+ Evas_Object *url_btn;
+ Evas_Object *ok_btn;
+ Evas_Object *cancel_btn;
+ Evas_Object *ctxpopup;
+ Evas_Object *vaule_btns[PROXY_CONFIG_MAX_NUM];
+
+ enum method_enum method;
+ enum network_type_enum net_type;
+
+ connection_h connection;
+
+ char ip[IP_STRING_LEN + 1];
+ char url[MOTHED_URL_LEN + 1];
+};
+
+static int _create_method_none_btn(struct _priv *priv);
+static int _create_method_manual_btns(struct _priv *priv);
+static int _create_method_auto_btns(struct _priv *priv);
+
+/**
+ * Initializes WI-FI for wireless network.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _init_wifi(struct _priv *priv)
+{
+ if (!priv) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ wifi_mgr_init();
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Initializes connection for wired network.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _init_connection(struct _priv *priv)
+{
+ if (!priv) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ priv->connection = connection_mgr_create();
+ if (!priv->connection) {
+ _ERR("connection_mgr_create() failed.");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Deinitializes WI-FI for wireless network.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _fini_wifi(struct _priv *priv)
+{
+ if (!priv) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ wifi_mgr_deinit();
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Deinitializes connection for wired network.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _fini_connection(struct _priv *priv)
+{
+ if (!priv) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ if (priv->connection)
+ connection_mgr_destroy(priv->connection);
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Initializes the private data.
+ *
+ * Called when the view is loaded.
+ *
+ * @return the handler of the private data;
+ */
+static struct _priv *_init_priv()
+{
+ struct _priv *priv;
+
+ priv = calloc(1, sizeof(*priv));
+ if (!priv) {
+ _ERR("calloc priv failed.");
+ return NULL;
+ }
+
+ _init_wifi(priv);
+ _init_connection(priv);
+
+ return priv;
+}
+
+/**
+ * Deinitializes the private data.
+ *
+ * Called when the view is deleted.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _fini_priv(struct _priv *priv)
+{
+ if (!priv)
+ return;
+
+ _fini_wifi(priv);
+ _fini_connection(priv);
+
+ if (priv->base)
+ evas_object_del(priv->base);
+
+ free(priv);
+}
+
+/**
+ * Callback for key pressed event.
+ *
+ * If the key is KEY_BACK, destroies the ug.
+ *
+ * @param[in] data User data
+ * @param[in] evas Evas handler
+ * @param[in] obj The corresponding object which the deletion event occurred
+ * @param[in] ei Event information
+ */
+static void _base_key_pressed_cb(void *data, Evas *evas,
+ Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _priv *priv;
+
+ if (!ei || !data) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ ev = ei;
+ priv = data;
+
+ if (!ev->keyname) {
+ _ERR("ev->keyname is NULL.");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_BACK)) {
+ ug_destroy_me(priv->ug);
+ return;
+ }
+}
+
+/**
+ * Shows the dim layout.
+ *
+ * Called when there is a ctxpopup.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _set_layout_dim(struct _priv *priv)
+{
+ if (!priv || !priv->dim_ly) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ evas_object_show(priv->dim_ly);
+}
+
+/**
+ * Hides the dim layout.
+ *
+ * Called when the existing ctxpopup is deleted.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _unset_layout_dim(struct _priv *priv)
+{
+ if (!priv || !priv->dim_ly) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ evas_object_hide(priv->dim_ly);
+}
+
+/**
+ * Sets the cycle focus in the direction of up and down.
+ *
+ * Sets the cycle focus for an array of objects.
+ *
+ * @param[in] obj The handler of objects
+ * @param[in] count The count of objects
+ */
+static void _set_up_down_cycle_focus(Evas_Object **obj,
+ int count)
+{
+ int i;
+
+ if (!*obj || !obj)
+ return;
+
+ for (i = 0; i < count; i++) {
+ if (i == count - 1)
+ elm_object_focus_next_object_set(obj[i], obj[0],
+ ELM_FOCUS_DOWN);
+ else
+ elm_object_focus_next_object_set(obj[i], obj[i + 1],
+ ELM_FOCUS_DOWN);
+
+ if (i == 0)
+ elm_object_focus_next_object_set(obj[i], obj[count - 1],
+ ELM_FOCUS_UP);
+ else
+ elm_object_focus_next_object_set(obj[i], obj[i - 1],
+ ELM_FOCUS_UP);
+ }
+}
+
+/**
+ * Sets the cycle focus in the direction of left and right.
+ *
+ * Sets the cycle focus for an array of objects.
+ *
+ * @param[in] obj The handler of objects
+ * @param[in] count The count of objects
+ */
+static void _set_left_right_cycle_focus(Evas_Object **obj, int count)
+{
+ int i;
+
+ if (!obj || !*obj) {
+ _ERR("the param is invalid.");
+ return;
+ }
+
+ for (i = 0; i < count; i++) {
+ if (i == count - 1)
+ elm_object_focus_next_object_set(obj[i],
+ obj[0], ELM_FOCUS_RIGHT);
+ else
+ elm_object_focus_next_object_set(obj[i],
+ obj[i + 1], ELM_FOCUS_RIGHT);
+
+ if (i == 0)
+ elm_object_focus_next_object_set(obj[i],
+ obj[count - 1], ELM_FOCUS_LEFT);
+ else
+ elm_object_focus_next_object_set(obj[i],
+ obj[i - 1], ELM_FOCUS_LEFT);
+ }
+}
+
+/**
+ * Creates the basic layout of the view.
+ *
+ * @param[in] parent The parent object
+ * @return layout if the operation is successful; NULL if failed;
+ */
+static Evas_Object *_create_basic_layout(struct _priv *priv)
+{
+ Evas_Object *base;
+
+ if (!priv || !priv->win) {
+ _ERR("priv is NULL.");
+ return NULL;
+ }
+
+ base = util_add_layout(priv->win, UG_PROXY_EDJ_FILE, GRP_MAIN_VIEW);
+ if (!base) {
+ _ERR("elm_layout_add() failed.");
+ return NULL;
+ }
+
+ evas_object_event_callback_add(base, EVAS_CALLBACK_KEY_DOWN,
+ _base_key_pressed_cb, priv);
+
+ evas_object_show(base);
+
+ return base;
+}
+
+/**
+ * Sets the description.
+ *
+ * Sets the description for the proxy setting view.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _set_description(struct _priv *priv)
+{
+ if (!priv || !priv->base) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ elm_object_part_text_set(priv->base, PART_PROXY_DESCRITION,
+ _(TXT_PROXY_DESCRIPTION));
+}
+
+/**
+ * Gets proxy IP from vconf.
+ *
+ * @param[out] des_ip Destination IP
+ * @param[in] key_ip The vconf key
+ */
+static void _get_man_saved_value(char *des_ip,
+ const char *key_ip)
+{
+ char *ip;
+
+ if (!des_ip || !key_ip) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ ip = vconf_mgr_get_string_value(key_ip);
+ if (!ip)
+ snprintf(des_ip, IP_STRING_LEN, "%s", IP_ZERO);
+ else
+ snprintf(des_ip, IP_STRING_LEN, "%s", ip);
+}
+
+/**
+ * Gets the proxy method from vconf.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _get_proxy_method(struct _priv *priv)
+{
+ int value;
+ int ret;
+ char *str;
+
+ if (!priv) {
+ _ERR("Parameter error!");
+ return RET_FAILED;
+ }
+
+ str = vconf_mgr_get_string_value(VCONF_NETWORK_TYPE);
+ if (str && !strcmp(str, TXT_WIRED))
+ priv->net_type = TYPE_WIRED;
+ else
+ priv->net_type = TYPE_WIRELESS;
+
+ value = 0;
+ ret = vconf_mgr_get_int_value(VCONF_PROXY_METHOD, &value);
+ if (ret != RET_SUCCESS) {
+ _ERR("vconf_mgr_get_int_value() failed.");
+ return RET_FAILED;
+ }
+
+ switch (value) {
+ case 0:
+ priv->method = METHOD_NONE;
+ break;
+ case 1:
+ priv->method = METHOD_MAN;
+ break;
+ case 2:
+ priv->method = METHOD_AUTO;
+ break;
+ default:
+ return RET_FAILED;
+ }
+
+ _get_man_saved_value(priv->ip, VCONF_PROXY_IP);
+
+ str = vconf_mgr_get_string_value(VCONF_PROXY_URL);
+ if (!str)
+ snprintf(priv->url, MOTHED_URL_LEN, "%s", URL_BLANK);
+ else
+ snprintf(priv->url, MOTHED_URL_LEN, "%s", str);
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Keeps the focused state for the button.
+ *
+ * @param[in] btn The object button
+ */
+static void _keep_btn_dim_focused(Evas_Object *btn)
+{
+ if (!btn) {
+ _ERR("the param is invalid.");
+ return;
+ }
+
+ elm_object_signal_emit(btn, SIG_BTN_SELECTED, PROG);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling unfocused event.
+*
+* When the ctxpopup is unfocused, hide the dim layout,
+* and delete the ctxpopup.
+*
+* @param[in] data User data
+* @param[in] o The corresponding object which the focus event occurred
+* @param[in] ei Event information
+*/
+static void _ctxpopup_unfocused_cb(void *data,
+ Evas_Object *o, void *ei)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+
+ _unset_layout_dim(priv);
+
+ if (priv->ctxpopup) {
+ evas_object_del(priv->ctxpopup);
+ priv->ctxpopup = NULL;
+ }
+}
+
+/**
+ * Clears the buttons in the box.
+ *
+ * When the method is changed, clear the box firstly.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _clear_method_btns(struct _priv *priv)
+{
+ if (!priv) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ elm_box_clear(priv->box);
+
+ priv->method_btn = NULL;
+ priv->proxy_btn= NULL;
+ priv->url_btn = NULL;
+}
+
+/**
+ * Creates the method select button.
+ *
+ * Uses the style of 'method_select'.
+ *
+ * @param[in] base The parent object
+ * @param[in] txt The text in button
+ * @param[in] cb The callback for clicked event
+ * @param[in] data User data
+ * @return button if the operation is successful; NULL if failed;
+ */
+static Evas_Object *_create_method_select_btn(Evas_Object *base,
+ char *txt, Evas_Smart_Cb cb, void *data)
+{
+ Evas_Object *btn;
+
+ if (!base || !txt || !cb || !data) {
+ _ERR("The param is invalid.\n");
+ return NULL;
+ }
+
+ btn = util_add_button(base, STYLE_METHOD_SET, NULL, txt);
+ if (!btn) {
+ _ERR("Add btn failed.\n");
+ return NULL;
+ }
+
+ evas_object_smart_callback_add(btn, SIG_CLICKED, cb, data);
+
+ return btn;
+}
+
+/**
+ * Callback for key pressed event.
+ *
+ * If the key is KEY_BACK, delete the ctxpopup.
+ *
+ * @param[in] data User data
+ * @param[in] evas Evas handler
+ * @param[in] o The corresponding object which the deletion event occurred
+ * @param[in] ei Event information
+ */
+static void _ctxpopup_key_pressed_cb(void *data, Evas *evas,
+ Evas_Object *o, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _priv *priv;
+
+ if (!ei || !data) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+ ev = ei;
+
+ if (!ev->keyname) {
+ _ERR("ev->keyname is NULL.");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_BACK)) {
+ _unset_layout_dim(priv);
+
+ if (priv->ctxpopup) {
+ evas_object_del(priv->ctxpopup);
+ priv->ctxpopup = NULL;
+ }
+ }
+}
+
+/**
+ * Handles the process of clicked event.
+ *
+ * According to the method.
+ *
+ * @param[in] priv The handler of the private data
+ * @param[in] method The proxy method
+ */
+static void _method_btn_click_proc(struct _priv *priv,
+ enum method_enum method)
+{
+ if (!priv) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ if (priv->ctxpopup) {
+ evas_object_del(priv->ctxpopup);
+ priv->ctxpopup = NULL;
+ }
+
+ priv->method = method;
+
+ _clear_method_btns(priv);
+
+ switch (priv->method) {
+ case METHOD_NONE:
+ _create_method_none_btn(priv);
+ break;
+ case METHOD_MAN:
+ _create_method_manual_btns(priv);
+ break;
+ case METHOD_AUTO:
+ _create_method_auto_btns(priv);
+ break;
+ default:
+ break;
+ }
+
+ elm_object_focus_set(priv->method_btn, EINA_TRUE);
+
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* For the 'METHOD_NONE' button.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _method_none_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+
+ _method_btn_click_proc(priv, METHOD_NONE);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* For the 'METHOD_MAN' button.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _method_man_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+
+ _method_btn_click_proc(priv, METHOD_MAN);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* For the 'METHOD_AUTO' button.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _method_auto_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+
+ _method_btn_click_proc(priv, METHOD_AUTO);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* For the method select button.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _method_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+ Evas_Object *base;
+ Evas_Object *ctxpopup;
+ Evas_Object *box;
+ Evas_Object *none_btn;
+ Evas_Object *man_btn;
+ Evas_Object *auto_btn;
+ Evas_Object *btn[METHOD_NUM];
+ Evas_Coord x;
+ Evas_Coord y;
+ Evas_Coord w;
+ Evas_Coord h;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+ base = priv->base;
+
+ ctxpopup = util_add_layout(base, UG_PROXY_EDJ_FILE,
+ GRP_METHOD_SETTING);
+ if (!ctxpopup) {
+ _ERR("add method ctxpopup failed.\n");
+ return;
+ }
+
+ evas_object_smart_callback_add(ctxpopup, SIG_UNFOCUSED,
+ _ctxpopup_unfocused_cb, priv);
+ evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_KEY_DOWN,
+ _ctxpopup_key_pressed_cb, priv);
+
+ priv->ctxpopup = ctxpopup;
+
+ _keep_btn_dim_focused(priv->method_btn);
+ _set_layout_dim(priv);
+
+ box = util_add_box(ctxpopup, PART_SWALLOW_CONTENT);
+ if (!box) {
+ _ERR("create box failed.");
+ evas_object_del(ctxpopup);
+ return;
+ }
+
+ none_btn = _create_method_select_btn(ctxpopup, _(TXT_MOTHED_NONE),
+ _method_none_btn_clicked_cb, priv);
+ if (!none_btn) {
+ _ERR("Add btn failed.\n");
+ evas_object_del(ctxpopup);
+ return;
+ }
+
+ elm_box_pack_end(box, none_btn);
+ elm_object_focus_set(none_btn, EINA_TRUE);
+ btn[METHOD_NONE] = none_btn;
+
+ man_btn = _create_method_select_btn(ctxpopup, _(TXT_MOTHED_MAN),
+ _method_man_btn_clicked_cb, priv);
+ if (!man_btn) {
+ _ERR("Add btn failed.\n");
+ evas_object_del(ctxpopup);
+ return;
+ }
+
+ elm_box_pack_end(box, man_btn);
+ btn[METHOD_MAN] = man_btn;
+
+ auto_btn = _create_method_select_btn(ctxpopup, _(TXT_MOTHED_AUTO),
+ _method_auto_btn_clicked_cb, priv);
+ if (!auto_btn) {
+ _ERR("Add btn failed.\n");
+ evas_object_del(ctxpopup);
+ return;
+ }
+
+ elm_box_pack_end(box, auto_btn);
+ btn[METHOD_AUTO] = auto_btn;
+
+ _set_up_down_cycle_focus(btn, METHOD_NUM);
+ _set_left_right_cycle_focus(btn, METHOD_NUM);
+
+ switch (priv->method) {
+ case METHOD_NONE:
+ elm_object_signal_emit(none_btn, SIG_BTN_SELECTED, PROG);
+ break;
+ case METHOD_MAN:
+ elm_object_signal_emit(man_btn, SIG_BTN_SELECTED, PROG);
+ break;
+ case METHOD_AUTO:
+ elm_object_signal_emit(auto_btn, SIG_BTN_SELECTED, PROG);
+ break;
+ default:
+ break;
+ }
+
+ evas_object_geometry_get(priv->method_btn, &x, &y, &w, &h);
+ evas_object_move(ctxpopup, (x + METHOD_CTXPOPUP_OFFSET_X) * ELM_SCALE,
+ (y + ALIGH_RATIO * h + LINE_PAD) * ELM_SCALE);
+}
+
+/**
+ * Gets the position of IP value ctxpopup.
+ *
+ * @param[in] priv The handler of the private data
+ * @param[out] pos_x X position
+ * @param[out] pos_y Y position
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _get_value_popup_pos(struct _priv *priv,
+ Evas_Coord *pos_x, Evas_Coord *pos_y)
+{
+ Evas_Coord x;
+ Evas_Coord y;
+
+ if (!priv || !pos_x || !pos_y) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ evas_object_geometry_get(priv->proxy_btn, &x, &y, NULL, NULL);
+ *pos_x = x + VALUE_CTXPOPUP_OFFSET_X;
+ *pos_y = y - VALUE_CTXPOPUP_OFFSET_Y;
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets the number to the object text.
+ *
+ * @param[in] obj The handler of the object
+ * @param[in] num The number
+ */
+static void _set_btn_vaule(Evas_Object *obj, int num)
+{
+ char value[MOTHED_STRING_LEN];
+
+ if (!obj) {
+ _ERR("The param is invalid.");
+ return;
+ }
+
+ memset(value, 0, MOTHED_STRING_LEN);
+ snprintf(value, MOTHED_STRING_LEN - 1, "%d", num);
+ elm_object_text_set(obj, value);
+}
+
+/**
+ * Callback for key pressed event.
+ *
+ * If the key is KEY_UP, increase the value.
+ * If the key is KEY_DOWN, decrease the value.
+ * If the key is a number, append the number.
+ *
+ * @param[in] data User data
+ * @param[in] evas Evas handler
+ * @param[in] obj The corresponding object which the deletion event occurred
+ * @param[in] ei Event information
+ */
+static void _value_key_pressed_cb(void *data, Evas *evas,
+ Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ const char *value;
+ int num, new_num, max_num;
+
+ if (!ei || !data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ ev = ei;
+
+ if (!ev->keyname) {
+ _ERR("ev->keyname is NULL.");
+ return;
+ }
+
+ max_num = IP_MAX_NUM;
+
+ if (!strcmp(ev->keyname, KEY_UP)) {
+ value = elm_object_text_get(obj);
+ num = atoi(value);
+ num++;
+ if (num > max_num)
+ num = 0;
+ } else if (!strcmp(ev->keyname, KEY_DOWN)) {
+ value = elm_object_text_get(obj);
+ num = atoi(value);
+ num--;
+ if (num < 0)
+ num = max_num;
+ } else if (!strcmp(ev->keyname, KEY_0) ||
+ !strcmp(ev->keyname, KEY_1) ||
+ !strcmp(ev->keyname, KEY_2) ||
+ !strcmp(ev->keyname, KEY_3) ||
+ !strcmp(ev->keyname, KEY_4) ||
+ !strcmp(ev->keyname, KEY_5) ||
+ !strcmp(ev->keyname, KEY_6) ||
+ !strcmp(ev->keyname, KEY_7) ||
+ !strcmp(ev->keyname, KEY_8) ||
+ !strcmp(ev->keyname, KEY_9)) {
+ value = elm_object_text_get(obj);
+ if (!value)
+ elm_object_text_set(obj, ev->keyname);
+
+ new_num = atoi(ev->keyname);
+
+ num = atoi(value);
+ if (!num || (num * IP_RATIO + new_num) > max_num) {
+ elm_object_text_set(obj, ev->keyname);
+ return;
+ }
+
+ num = num * IP_RATIO + new_num;
+ } else {
+ return;
+ }
+
+ _set_btn_vaule(obj, num);
+}
+
+/**
+ * Creates the value button for IP setting.
+ *
+ * @param[in] parent The parent object
+ * @param[in] num The sequence number of the button
+ * @param[in] txt The text in the button
+ * @param[in] data User data
+ * @return button if the operation is successful; NULL if failed;
+ */
+static Evas_Object *_create_value_btn(Evas_Object *parent, int num,
+ char *txt, void *data)
+{
+ Evas_Object *btn;
+
+ if (!parent || !txt || !data) {
+ _ERR("The param is invalid.\n");
+ return NULL;
+ }
+
+ btn = util_add_button(parent, STYLE_VALUE_BTN, NULL, txt);
+ if (!btn) {
+ _ERR("add button failed.\n");
+ return NULL;
+ }
+
+ switch (num) {
+ case 0:
+ elm_object_part_content_set(parent, PART_IP_FIRST, btn);
+ evas_object_data_set(parent, IP_VALUE1, btn);
+ elm_object_focus_set(btn, EINA_TRUE);
+ break;
+ case 1:
+ elm_object_part_content_set(parent, PART_IP_SECOND, btn);
+ evas_object_data_set(parent, IP_VALUE2, btn);
+ break;
+ case 2:
+ elm_object_part_content_set(parent, PART_IP_THIRD, btn);
+ evas_object_data_set(parent, IP_VALUE3, btn);
+ break;
+ case 3:
+ elm_object_part_content_set(parent, PART_IP_FORTH, btn);
+ evas_object_data_set(parent, IP_VALUE4, btn);
+ break;
+ default:
+ break;
+ }
+
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN,
+ _value_key_pressed_cb, data);
+ elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_DOWN);
+
+ return btn;
+}
+
+/**
+ * Sets the value to the object text.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _set_the_value(struct _priv *priv)
+{
+ Evas_Object *btn;
+ const char *value1;
+ const char *value2;
+ const char *value3;
+ const char *value4;
+ char ip[IP_STRING_LEN + 1];
+
+ if (!priv || !priv->ctxpopup) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ value1 = NULL;
+ btn = evas_object_data_get(priv->ctxpopup, IP_VALUE1);
+ if (btn)
+ value1 = elm_object_text_get(btn);
+
+ value2 = NULL;
+ btn = evas_object_data_get(priv->ctxpopup, IP_VALUE2);
+ if (btn)
+ value2 = elm_object_text_get(btn);
+
+ value3 = NULL;
+ btn = evas_object_data_get(priv->ctxpopup, IP_VALUE3);
+ if (btn)
+ value3 = elm_object_text_get(btn);
+
+ value4 = NULL;
+ btn = evas_object_data_get(priv->ctxpopup, IP_VALUE4);
+ if (btn)
+ value4 = elm_object_text_get(btn);
+
+ memset(ip, 0, IP_STRING_LEN + 1);
+ snprintf(ip, IP_STRING_LEN, "%s.%s.%s.%s",
+ value1 ? value1 : "\\0", value2 ? value2 : "\\0",
+ value3 ? value3 : "\\0", value4 ? value4 : "\\0");
+
+ strncpy(priv->ip, ip, IP_STRING_LEN);
+ elm_object_part_text_set(priv->proxy_btn, PART_VALUE, ip);
+
+ evas_object_del(priv->ctxpopup);
+ priv->ctxpopup = NULL;
+}
+
+/**
+ * Callback for key pressed event.
+ *
+ * If the key is KEY_BACK, delete the IP value ctxpopup.
+ * If the key is KEY_ENTER, set the value into the button.
+ *
+ * @param[in] data User data
+ * @param[in] evas Evas handler
+ * @param[in] obj The corresponding object which the deletion event occurred
+ * @param[in] ei Event information
+ */
+static void _value_ctxpopup_key_pressed_cb(void *data, Evas *evas,
+ Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _priv *priv;
+
+ if (!ei || !data) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ ev = ei;
+ priv = data;
+
+ if (!ev->keyname) {
+ _ERR("ev->keyname is NULL.");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_ENTER)) {
+ _unset_layout_dim(priv);
+ _set_the_value(priv);
+ evas_object_del(obj);
+ } else if (!strcmp(ev->keyname, KEY_BACK)) {
+ _unset_layout_dim(priv);
+ evas_object_del(obj);
+ }
+}
+
+/**
+ * Creates value ctxpopup.
+ *
+ * User can set number in the ctxpopup.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _create_value_popup(struct _priv *priv)
+{
+ Evas_Object *base;
+ Evas_Object *ctxpopup;
+ Evas_Object *btn;
+ Evas_Coord pos_x;
+ Evas_Coord pos_y;
+ int i;
+
+ if (!priv || !priv->base) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ base = priv->base;
+
+ ctxpopup = util_add_layout(base, UG_PROXY_EDJ_FILE,
+ GRP_PROXY_VALUE_SETTING);
+ if (!ctxpopup) {
+ _ERR("elm_ctxpopup_add() failed.\n");
+ return;
+ }
+
+ priv->ctxpopup = ctxpopup;
+
+ _set_layout_dim(priv);
+
+ for (i = 0; i < PROXY_CONFIG_MAX_NUM; i++) {
+ btn = _create_value_btn(ctxpopup, i, _(TXT_ZERO), priv);
+ if (!btn) {
+ _ERR("_create_value_btn() failed.\n");
+ evas_object_del(ctxpopup);
+ return;
+ }
+
+ priv->vaule_btns[i] = btn;
+ }
+
+ elm_object_part_text_set(ctxpopup, PART_TXT_SEPERATOR, _(TXT_COLON));
+ evas_object_smart_callback_add(ctxpopup, SIG_UNFOCUSED,
+ _ctxpopup_unfocused_cb, priv);
+ evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_KEY_DOWN,
+ _value_ctxpopup_key_pressed_cb, priv);
+ _set_left_right_cycle_focus(priv->vaule_btns, PROXY_CONFIG_MAX_NUM);
+
+ pos_x = 0;
+ pos_y = 0;
+ _get_value_popup_pos(priv, &pos_x, &pos_y);
+ evas_object_move(ctxpopup, pos_x * ELM_SCALE, pos_y * ELM_SCALE);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* After the proxy button is clicked, the value ctxpopup
+* will be created to set the value.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _proxy_ip_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+
+ _keep_btn_dim_focused(priv->proxy_btn);
+
+ _create_value_popup(priv);
+}
+
+/**
+ * Callback for key pressed event.
+ *
+ * If the key is 'Select', save the passcode.
+ * If the key is KEY_BACK, delete the layout.
+ *
+ * @param[in] data User data
+ * @param[in] e Evas handler
+ * @param[in] obj The corresponding object which the deletion event occurred
+ * @param[in] ei Event information
+ */
+static void _entry_key_pressed_cb(void *data, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _priv *priv;
+ const char *value;
+
+ if (!data || !ei) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+ ev = ei;
+
+ if (!ev->keyname) {
+ _ERR("ev->keyname is NULL.");
+ return;
+ }
+
+ elm_entry_input_panel_show(obj);
+
+ if (!strcmp(ev->keyname, KEY_BACK)) {
+ if (priv->ctxpopup) {
+ evas_object_del(priv->ctxpopup);
+ priv->ctxpopup = NULL;
+ }
+
+ _unset_layout_dim(priv);
+ } else if (!strcmp(ev->keyname, KEY_PROXY_ENTER)) {
+ value = elm_entry_entry_get(obj);
+ elm_object_part_text_set(priv->url_btn, PART_VALUE, value);
+ memset(priv->url, 0, MOTHED_URL_LEN + 1);
+ strncpy(priv->url, value, MOTHED_URL_LEN);
+
+ if (priv->ctxpopup) {
+ evas_object_del(priv->ctxpopup);
+ priv->ctxpopup = NULL;
+ }
+
+ elm_object_focus_set(priv->url_btn, EINA_TRUE);
+
+ _unset_layout_dim(priv);
+ }
+}
+
+/**
+ * Creates the entry to input passcode.
+ *
+ * @param[in] priv The handler of the private data
+ */
+static void _create_input_entry(struct _priv *priv)
+{
+ Evas_Object *entry;
+ Evas_Object *layout;
+
+ if (!priv || !priv->base) {
+ _ERR("the param is NULL.");
+ return;
+ }
+
+ if (priv->ctxpopup) {
+ evas_object_del(priv->ctxpopup);
+ priv->ctxpopup = NULL;
+ }
+
+ layout = util_add_layout(priv->base, UG_PROXY_EDJ_FILE,
+ GRP_ENTRY_POPUP);
+ if (!layout) {
+ _ERR("create layout fail.\n");
+ return;
+ }
+
+ entry = util_add_entry(layout, STYLE_ENTRY, PART_ENTRY);
+ if (!entry) {
+ _ERR("add entry failed.");
+ evas_object_del(layout);
+ return;
+ }
+
+ util_set_focus_next_self(entry);
+ evas_object_event_callback_add(entry, EVAS_CALLBACK_KEY_DOWN,
+ _entry_key_pressed_cb, priv);
+ elm_object_focus_set(entry, EINA_TRUE);
+
+ _set_layout_dim(priv);
+
+ priv->ctxpopup = layout;
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* After the URL button is clicked, the layout will be
+ * created to input the passcode.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _url_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+
+ _create_input_entry(priv);
+}
+
+/**
+ * Creates the method button.
+ *
+ * The common API for method button.
+ *
+ * @param[in] priv The handler of the private data
+ * @param[in] btn The handle of the button to be created
+ * @param[in] key The key value
+ * @param[in] value The value
+ * @param[in] line The number of lines
+ * @param[in] cb The callback for clicked event
+ * @return button if the operation is successful; NULL if failed;
+ */
+static Evas_Object *_create_method_box_btn(struct _priv *priv, Evas_Object *btn,
+ const char *key, char *value, int line, Evas_Smart_Cb cb)
+{
+ if (!priv || !priv->box || !key || !value || !cb) {
+ _ERR("Parameter error!");
+ return NULL;
+ }
+
+ if (btn) {
+ evas_object_show(btn);
+ elm_object_part_text_set(btn, PART_VALUE, value);
+ } else {
+ if (line == BTN_TWO_LINE)
+ btn = util_add_key_value_button(priv->box,
+ STYLE_KEY_VALUE_TWO_LINES,
+ NULL, key, value);
+ else
+ btn = util_add_key_value_button(priv->box,
+ STYLE_KEY_VALUE_BTN, NULL, key, value);
+ if (!btn) {
+ _ERR("add method btn failed.");
+ return NULL;
+ }
+
+ evas_object_smart_callback_add(btn, SIG_CLICKED, cb, priv);
+ }
+
+ elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT);
+
+ return btn;
+}
+
+/**
+ * Creates method none button.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _create_method_none_btn(struct _priv *priv)
+{
+ Evas_Object *box;
+ Evas_Object *btn;
+
+ if (!priv || !priv->box) {
+ _ERR("Parameter error!");
+ return RET_FAILED;
+ }
+
+ box = priv->box;
+
+ btn = _create_method_box_btn(priv, priv->method_btn,
+ _(TXT_MOTHED), _(TXT_MOTHED_NONE),
+ BTN_ONE_LINE, _method_btn_clicked_cb);
+ if (!btn) {
+ _ERR("add method btn failed.");
+ return RET_FAILED;
+ }
+
+ elm_box_pack_end(box, btn);
+
+ priv->method_btn = btn;
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Creates method manual button.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _create_method_manual_btns(struct _priv *priv)
+{
+ Evas_Object *box;
+ Evas_Object *btn;
+
+ if (!priv || !priv->box) {
+ _ERR("Parameter error!");
+ return RET_FAILED;
+ }
+
+ box = priv->box;
+
+ btn = _create_method_box_btn(priv, priv->method_btn,
+ _(TXT_MOTHED), _(TXT_MOTHED_MAN),
+ BTN_ONE_LINE, _method_btn_clicked_cb);
+ if (!btn) {
+ _ERR("add method btn failed.");
+ return RET_FAILED;
+ }
+
+ elm_box_pack_end(box, btn);
+ priv->method_btn = btn;
+
+ btn = _create_method_box_btn(priv, priv->proxy_btn,
+ _(TXT_PROXY_IP), _(priv->ip),
+ BTN_ONE_LINE, _proxy_ip_btn_clicked_cb);
+ if (!btn) {
+ _ERR("add http btn failed.");
+ return RET_FAILED;
+ }
+
+ elm_box_pack_end(box, btn);
+ priv->proxy_btn = btn;
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Creates method auto button.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _create_method_auto_btns(struct _priv *priv)
+{
+ Evas_Object *box;
+ Evas_Object *btn;
+
+ if (!priv || !priv->box) {
+ _ERR("Parameter error!");
+ return RET_FAILED;
+ }
+
+ box = priv->box;
+
+ btn = _create_method_box_btn(priv, priv->method_btn,
+ _(TXT_MOTHED), _(TXT_MOTHED_AUTO),
+ BTN_ONE_LINE, _method_btn_clicked_cb);
+ if (!btn) {
+ _ERR("add method btn failed.");
+ return RET_FAILED;
+ }
+
+ elm_box_pack_end(box, btn);
+ priv->method_btn = btn;
+
+ btn = _create_method_box_btn(priv, priv->url_btn,
+ _(TXT_CONFIG_URL), _(priv->url),
+ BTN_TWO_LINE, _url_btn_clicked_cb);
+ if (!btn) {
+ _ERR("add url btn failed.");
+ return RET_FAILED;
+ }
+
+ elm_box_pack_end(box, btn);
+ priv->url_btn = btn;
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Creates the proxy layout.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _create_proxy_ly(struct _priv *priv)
+{
+ Evas_Object *base;
+ Evas_Object *box;
+ int ret;
+
+ if (!priv || !priv->base) {
+ _ERR("Parameter error!");
+ return RET_FAILED;
+ }
+
+ base = priv->base;
+
+ box = util_add_box(base, PART_PROXY_SETTING);
+ if (!box) {
+ _ERR("add box failed.");
+ return RET_FAILED;
+ }
+
+ priv->box = box;
+
+ switch (priv->method) {
+ case METHOD_NONE:
+ ret = _create_method_none_btn(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("add method none failed.");
+ goto error;
+ }
+
+ break;
+ case METHOD_MAN:
+ ret = _create_method_manual_btns(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("add method manual failed.");
+ goto error;
+ }
+
+ break;
+ case METHOD_AUTO:
+ ret = _create_method_auto_btns(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("add method manual failed.");
+ goto error;
+ }
+
+ break;
+ default:
+ break;
+ }
+
+ return RET_SUCCESS;
+
+error:
+ evas_object_del(box);
+
+ return RET_FAILED;
+}
+
+/**
+ * Checks if IP is valid.
+ *
+ * Now only check if IP is '0.0.0.0'.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful;
+ * RET_IP_INVALID if the IP is '0.0.0.0'; RET_FAILED if failed;
+ */
+static int _check_ip_is_valid(struct _priv *priv)
+{
+ if (!priv) {
+ _ERR("The param is NULL.\n");
+ return RET_FAILED;
+ }
+
+ if (!strncmp(priv->ip, IP_ZERO, IP_STRING_LEN)) {
+ _ERR("IP addr is invalid.");
+ return RET_IP_INVALID;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* When the 'OK' button is clicked, delete the popup,
+* and set the default focus.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] event Event information
+*/
+static void _ctxpopup_ok_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *event)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+
+ if (priv->ctxpopup) {
+ evas_object_del(priv->ctxpopup);
+ priv->ctxpopup = NULL;
+ }
+
+ _unset_layout_dim(priv);
+
+ elm_object_focus_set(priv->ok_btn, EINA_TRUE);
+}
+
+/**
+ * Shows the invalid IP ctxpopup according to return value.
+ *
+ * @param[in] priv The handler of the private data
+ * @param[in] ret The return value from
+ */
+static void _show_invalid_info_ctxpopup(struct _priv *priv, int ret)
+{
+ Evas_Object *layout;
+ Evas_Object *btn;
+ // Evas_Coord w;
+ // Evas_Coord h;
+
+ if (!priv) {
+ _ERR("The param is NULL.\n");
+ return;
+ }
+
+ if (priv->ctxpopup) {
+ evas_object_del(priv->ctxpopup);
+ priv->ctxpopup = NULL;
+ }
+
+ _set_layout_dim(priv);
+
+ layout = util_add_layout(priv->base, UG_PROXY_EDJ_FILE,
+ GRP_CONFIRM_LAYOUT);
+ if (!layout) {
+ _ERR("add layout failed.");
+ _unset_layout_dim(priv);
+ return;
+ }
+
+ switch (priv->method) {
+ case METHOD_MAN:
+ elm_object_part_text_set(layout, PART_TEXT_TITLE,
+ _(TXT_MANUAL_TITLE));
+ break;
+ case METHOD_AUTO:
+ elm_object_part_text_set(layout, PART_TEXT_TITLE,
+ _(TXT_AUTO_TITLE));
+ break;
+ default:
+ evas_object_del(layout);
+ _unset_layout_dim(priv);
+ return;
+ }
+
+ elm_object_part_text_set(layout, PART_TEXT_TITLE, _(TXT_MANUAL_TITLE));
+
+ if (ret == RET_IP_INVALID)
+ elm_object_part_text_set(layout,
+ PART_TEXT_CONTENT, _(TXT_IP_INVALID));
+ else if (ret == RET_VCONF_FAILED)
+ elm_object_part_text_set(layout,
+ PART_TEXT_CONTENT, _(TXT_VCONF_FAILED));
+ else if (ret == RET_WIRED_PROXY_FAILED)
+ elm_object_part_text_set(layout,
+ PART_TEXT_CONTENT, _(TXT_WIRED_FAILED));
+ else if (ret == RET_WIRELESS_PROXY_FAILED)
+ elm_object_part_text_set(layout,
+ PART_TEXT_CONTENT, _(TXT_WIRELESS_FAILED));
+
+ btn = util_add_button(layout,
+ STYLE_ACTION_BTN, PART_OK_BTN, _(TXT_OK));
+ if (!btn) {
+ _ERR("util add button failed.");
+ evas_object_del(layout);
+ _unset_layout_dim(priv);
+ return;
+ }
+
+ elm_object_focus_set(btn, EINA_TRUE);
+ elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_DOWN);
+ evas_object_smart_callback_add(btn, SIG_CLICKED,
+ _ctxpopup_ok_btn_clicked_cb, priv);
+
+ evas_object_smart_callback_add(layout, SIG_UNFOCUSED,
+ _ctxpopup_unfocused_cb, priv);
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN,
+ _ctxpopup_key_pressed_cb, priv);
+
+ // w = DEFAULT_WIN_WIDTH;
+ // h = DEFAULT_WIN_HEIGHT;
+ evas_object_move(layout,
+ CENTER_ALIGN * (DEFAULT_WIN_WIDTH - CTXPOPUP_WIDTH) * ELM_SCALE,
+ CENTER_ALIGN * (DEFAULT_WIN_HEIGHT - CTXPOPUP_HEIGHT) * ELM_SCALE);
+
+ priv->ctxpopup = layout;
+}
+
+/**
+ * Saves the proxy information to vconf.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _save_to_vconf(struct _priv *priv)
+{
+ if (!priv) {
+ _ERR("The param is invalid.\n");
+ return RET_SUCCESS;
+ }
+
+ vconf_mgr_set_int_value(VCONF_PROXY_METHOD, priv->method);
+
+ switch (priv->method) {
+ case METHOD_NONE:
+ break;
+ case METHOD_MAN:
+ _check_ip_is_valid(priv);
+
+ vconf_mgr_set_string_value(VCONF_PROXY_IP, priv->ip);
+
+ break;
+ case METHOD_AUTO:
+ vconf_mgr_set_string_value(VCONF_PROXY_URL, priv->url);
+
+ break;
+ default:
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets the proxy information with connection api.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _set_connection_proxy(struct _priv *priv)
+{
+ int ret;
+
+ if (!priv) {
+ _ERR("The param is invalid.\n");
+ return RET_FAILED;
+ }
+
+ ret = connection_mgr_set_proxy_type(priv->connection, priv->method);
+ if (ret != RET_SUCCESS) {
+ _ERR("wifi_mgr_get_proxy_type() failed.");
+ return ret;
+ }
+
+ switch (priv->method) {
+ case METHOD_NONE:
+ connection_mgr_set_proxy_address(priv->connection,
+ NULL);
+ break;
+ case METHOD_MAN:
+ if (priv->ip)
+ connection_mgr_set_proxy_address(priv->connection,
+ priv->ip);
+ break;
+ case METHOD_AUTO:
+ if (priv->url)
+ connection_mgr_set_proxy_address(priv->connection,
+ priv->url);
+ break;
+ default:
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets the proxy information with wifi api.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _set_wifi_proxy(struct _priv *priv)
+{
+ int ret;
+
+ if (!priv) {
+ _ERR("The param is invalid.\n");
+ return RET_FAILED;
+ }
+
+ ret = wifi_mgr_set_proxy_type(priv->method);
+ if (ret != RET_SUCCESS) {
+ _ERR("wifi_mgr_get_proxy_type() failed.");
+ return ret;
+ }
+
+ switch (priv->method) {
+ case METHOD_NONE:
+ wifi_mgr_set_proxy_address(NULL);
+ break;
+ case METHOD_MAN:
+ if (priv->ip)
+ wifi_mgr_set_proxy_address(priv->ip);
+ break;
+ case METHOD_AUTO:
+ if (priv->url)
+ wifi_mgr_set_proxy_address(priv->url);
+ break;
+ default:
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets the proxy information.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _set_proxy(struct _priv *priv)
+{
+ int ret;
+
+ if (!priv) {
+ _ERR("The param is invalid.\n");
+ return RET_FAILED;
+ }
+
+ if (priv->net_type == TYPE_WIRED) {
+ ret = _set_connection_proxy(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("the ip or port is invalid.");
+ return ret;
+ }
+ } else if (priv->net_type == TYPE_WIRELESS) {
+ ret = _set_wifi_proxy(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("the ip or port is invalid.");
+ return ret;
+ }
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* When the 'OK' button is clicked, save the proxy information,
+* and destroy the ug.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _ok_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+ int ret;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+
+ ret = _set_proxy(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("the ip or port is invalid.");
+ _show_invalid_info_ctxpopup(priv, ret);
+ return;
+ }
+
+ ret = _save_to_vconf(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("the ip or port is invalid.");
+ _show_invalid_info_ctxpopup(priv, ret);
+ return;
+ }
+
+ ug_destroy_me(priv->ug);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling clicked event.
+*
+* When the 'OK' button is clicked, don't save the proxy information,
+* and destroy the ug.
+*
+* @param[in] data User data
+* @param[in] obj The corresponding object which the focus event occurred
+* @param[in] ev Event information
+*/
+static void _cancel_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+
+ ug_destroy_me(priv->ug);
+}
+
+/**
+ * Creates the action buttons.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _create_action_btns(struct _priv *priv)
+{
+ Evas_Object *base;
+ Evas_Object *btn;
+
+ if (!priv || !priv->base) {
+ _ERR("Parameter error!");
+ return RET_FAILED;
+ }
+
+ base = priv->base;
+
+ btn = util_add_button(base, STYLE_ACTION_BTN, PART_OK_BTN, _(TXT_OK));
+ if (!btn) {
+ _ERR("add ok button failed.");
+ return RET_FAILED;
+ }
+
+ evas_object_smart_callback_add(btn, SIG_CLICKED,
+ _ok_btn_clicked_cb, priv);
+
+ elm_object_focus_set(btn, EINA_TRUE);
+
+ btn = util_add_button(base, STYLE_ACTION_BTN,
+ PART_CANCEL_BTN, _(TXT_CANCEL));
+ if (!btn) {
+ _ERR("add cancel button failed.");
+ return RET_FAILED;
+ }
+
+ evas_object_smart_callback_add(btn, SIG_CLICKED,
+ _cancel_btn_clicked_cb, priv);
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Creates the dim layout.
+ *
+ * @param[in] priv The handler of the private data
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+static int _create_dim_layout(struct _priv *priv)
+{
+ Evas_Object *dim_ly;
+
+ if (!priv || !priv->base) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ dim_ly = util_add_layout(priv->base, UG_PROXY_EDJ_FILE,
+ GRP_DIM_LY);
+ if (!dim_ly) {
+ _ERR("elm_layout_add() failed.\n");
+ return RET_FAILED;
+ }
+
+ priv->dim_ly = dim_ly;
+ _unset_layout_dim(priv);
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Creates the layout of the view.
+ *
+ * Called when the ug is launched.
+ *
+ * @param[in] win The handler of view manager
+ * @param[in] data The passed data from main view
+ * @return layout if the operation is successful; NULL if failed;
+ */
+Evas_Object *create_main_view(Evas_Object *win, ui_gadget_h ug)
+{
+ struct _priv *priv;
+ Evas_Object *base;
+ int ret;
+
+ if (!win || !ug) {
+ _ERR("Parameter error!");
+ return NULL;
+ }
+
+ priv = _init_priv();
+ if (!priv) {
+ _ERR("init priv failed.");
+ return NULL;
+ }
+
+ priv->win = win;
+ priv->ug = ug;
+
+ base = _create_basic_layout(priv);
+ if (!base) {
+ _ERR("Add main view failed.\n");
+ _fini_priv(priv);
+ return NULL;
+ }
+
+ priv->base = base;
+
+ _set_description(priv);
+
+ ret = _get_proxy_method(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("get proxy method failed.\n");
+ goto error;
+ }
+
+ ret = _create_proxy_ly(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("get proxy method failed.\n");
+ goto error;
+ }
+
+ ret = _create_action_btns(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("create action buttons failed.\n");
+ goto error;
+ }
+
+ ret = _create_dim_layout(priv);
+ if (ret != RET_SUCCESS)
+ goto error;
+
+ elm_object_focus_set(priv->method_btn, EINA_TRUE);
+ evas_object_data_set(base, KEY_PRIV, priv);
+
+ return base;
+
+error:
+ _fini_priv(priv);
+ return NULL;
+}
+
+/**
+ * Destroies the layout of the view.
+ *
+ * Called when the ug is destroied.
+ *
+ * @param[in] base The base layout
+ */
+void destroy_main_view(Evas_Object *base)
+{
+ struct _priv *priv;
+
+ if (!base) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = evas_object_data_get(base, KEY_PRIV);
+ if (!priv)
+ return;
+
+ _fini_priv(priv);
+}
diff --git a/ug/proxy/src/ug_proxy_settings.cpp b/ug/proxy/src/ug_proxy_settings.c
index 15dc624..6ddb58c 100644
--- a/ug/proxy/src/ug_proxy_settings.cpp
+++ b/ug/proxy/src/ug_proxy_settings.c
@@ -18,26 +18,17 @@
#define UG_MODULE_API __attribute__ ((visibility("default")))
#endif
+#include <Elementary.h>
#include <ui-gadget-module.h>
+#include "main_view.h"
#include "i18n.h"
#include "defs.h"
-#include <AppCommon.h>
-
-#include "wifi.h"
-#include "ProxyMainView.h"
-
-#if defined (__cplusplus)
-extern "C" {
-#endif
+#include "dbg.h"
struct _ug_data {
- ui_gadget_h ug;
-
Evas_Object *win;
Evas_Object *base;
-
- CViewMgr *pViewMgr;
- CProxyMainView *pProxyMainView;
+ ui_gadget_h ug;
};
/**
@@ -63,6 +54,7 @@ static void *_on_create(ui_gadget_h ug, enum ug_mode mode,
service_h service, void *priv)
{
struct _ug_data *ugd;
+ Evas_Object *base;
Evas_Object *win;
if (!ug || !priv) {
@@ -70,12 +62,12 @@ static void *_on_create(ui_gadget_h ug, enum ug_mode mode,
return NULL;
}
- ugd = (struct _ug_data *) priv;
+ ugd = priv;
ugd->ug = ug;
elm_theme_extension_add(NULL, UG_PROXY_EDJ_THEME);
- win = (Evas_Object *) ug_get_window();
+ win = ug_get_window();
if (!win) {
_ERR("window get failed");
return NULL;
@@ -86,24 +78,16 @@ static void *_on_create(ui_gadget_h ug, enum ug_mode mode,
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
elm_win_focus_highlight_style_set(win, "invisible");
- CViewMgr::Initialize(ugd->win, NULL);
- ugd->pViewMgr = CViewMgr::GetInstance();
- if(!ugd->pViewMgr) {
- CViewMgr::Finalize();
- _ERR("Fail to get CViewMgr instance");
+ base = create_main_view(win, ug);
+ if (!base) {
+ _ERR("add base layout failed.");
return NULL;
}
- ugd->pProxyMainView = new CProxyMainView(PROXY_MAINVIEW);
- if(!ugd->pViewMgr->AddView(ugd->pProxyMainView)) {
- _ERR("Fail to add pFbBaseView");
- CViewMgr::Finalize();
- return false;
- }
- ugd->pViewMgr->PushView(PROXY_MAINVIEW, NULL);
- ugd->base = ugd->pProxyMainView->Base();
+ ugd->base = base;
+ evas_object_raise(base);
- return ugd->base;
+ return base;
}
/**
@@ -174,7 +158,17 @@ static void _on_resume(ui_gadget_h ug, service_h service, void *priv)
*/
static void _on_destroy(ui_gadget_h ug, service_h service, void *priv)
{
- CViewMgr::Finalize();
+ struct _ug_data *ugd = priv;
+
+ if (!ug || !priv) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ if (!ugd || !ugd->base)
+ return;
+
+ destroy_main_view(ugd->base);
}
/**
@@ -251,7 +245,7 @@ UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
if (!ops)
return -1;
- ugd = (struct _ug_data *) calloc(1, sizeof(*ugd));
+ ugd = calloc(1, sizeof(*ugd));
if (!ugd)
return -1;
@@ -286,11 +280,7 @@ UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
if (!ops)
return;
- ugd = (struct _ug_data *) ops->priv;
+ ugd = ops->priv;
free(ugd);
}
-
-#if defined (__cplusplus)
-};
-#endif
diff --git a/ug/proxy/src/util.cpp b/ug/proxy/src/util.c
index 714c0a9..a5969b8 100644
--- a/ug/proxy/src/util.cpp
+++ b/ug/proxy/src/util.c
@@ -19,7 +19,7 @@
#include <aul.h>
#include "i18n.h"
#include "defs.h"
-#include <MacroDefine.h>
+#include "dbg.h"
#include "util.h"
#define ALIGN_CENTER 0.5
diff --git a/ug/proxy/src/vconf_mgr.c b/ug/proxy/src/vconf_mgr.c
new file mode 100644
index 0000000..d018549
--- /dev/null
+++ b/ug/proxy/src/vconf_mgr.c
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "defs.h"
+#include "dbg.h"
+#include "vconf_mgr.h"
+#include "i18n.h"
+
+/**
+ * Gets the string value from vconf.
+ *
+ * @param[in] key Vconf key
+ * @return the value in vconf;
+ */
+char *vconf_mgr_get_string_value(const char *key)
+{
+ if (!key) {
+ _ERR("the param is invalid.");
+ return NULL;
+ }
+
+ return vconf_get_str(key);
+}
+
+/**
+ * Sets the string value to vconf.
+ *
+ * @param[in] key Vconf key
+ * @param[in] value The value
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int vconf_mgr_set_string_value(const char *key, const char *value)
+{
+ int ret;
+
+ if (!key || !value) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ret = vconf_set_str(key, value);
+ if (ret != 0) {
+ _ERR("vconf set str failed.");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets the integer value from vconf.
+ *
+ * @param[in] key Vconf key
+ * @param[out] value The value
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int vconf_mgr_get_int_value(const char *key, int *value)
+{
+ int ret;
+
+ if (!key || !value) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ret = vconf_get_int(key, value);
+ if (ret != 0) {
+ _ERR("vconf get int failed");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets the integer value to vconf.
+ *
+ * @param[in] key Vconf key
+ * @param[in] value The value
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int vconf_mgr_set_int_value(const char *key, const int value)
+{
+ int ret;
+
+ if (!key) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ret = vconf_set_int(key, value);
+ if (ret != 0) {
+ _ERR("vconf set int failed.");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
diff --git a/ug/proxy/src/wifi_mgr.c b/ug/proxy/src/wifi_mgr.c
new file mode 100644
index 0000000..88616a2
--- /dev/null
+++ b/ug/proxy/src/wifi_mgr.c
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <stdlib.h>
+#include "defs.h"
+#include "dbg.h"
+#include "wifi_mgr.h"
+
+/**
+ * Converts the error type to string information.
+ *
+ * @param[in] err_type Error type
+ * @return error string information;
+ */
+const char *wifi_mgr_error_dbg(wifi_error_e err_type)
+{
+ switch (err_type) {
+ case WIFI_ERROR_NONE:
+ return "NONE";
+ case WIFI_ERROR_INVALID_PARAMETER:
+ return "INVALID_PARAMETER";
+ case WIFI_ERROR_OUT_OF_MEMORY:
+ return "OUT_OF_MEMORY";
+ case WIFI_ERROR_INVALID_OPERATION:
+ return "INVALID_OPERATION";
+ case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
+ return "ADDRESS_FAMILY_NOT_SUPPORTED";
+ case WIFI_ERROR_OPERATION_FAILED:
+ return "OPERATION_FAILED";
+ case WIFI_ERROR_NO_CONNECTION:
+ return "NO_CONNECTION";
+ case WIFI_ERROR_NOW_IN_PROGRESS:
+ return "NOW_IN_PROGRESS";
+ case WIFI_ERROR_ALREADY_EXISTS:
+ return "ALREADY_EXISTS";
+ case WIFI_ERROR_OPERATION_ABORTED:
+ return "OPERATION_ABORTED";
+ case WIFI_ERROR_DHCP_FAILED:
+ return "DHCP_FAILED";
+ case WIFI_ERROR_INVALID_KEY:
+ return "INVALID_KEY";
+ case WIFI_ERROR_NO_REPLY:
+ return "NO_REPLY";
+ case WIFI_ERROR_SECURITY_RESTRICTED:
+ return "SECURITY_RESTRICTED";
+ default:
+ break;
+ }
+
+ return "UNKNOWN";
+}
+
+/**
+ * Initializes Wi-Fi.
+ *
+ * Called before using wifi APIs.
+ *
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_init(void)
+{
+ int ret;
+
+ ret = wifi_initialize();
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("Fail to wifi_initialize.\n");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Deinitializes Wi-Fi.
+ *
+ * Called when network setting is destroyed.
+ *
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_deinit(void)
+{
+ int ret;
+
+ ret = wifi_deinitialize();
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("Fail to wifi_deinitialize.\n");
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets the handle of connected access point.
+ *
+ * You can get the connected access point and its configuration.
+ *
+ * @param[out] ap The handle of access point
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_get_connected_ap(wifi_ap_h *ap)
+{
+ int ret;
+
+ if (!ap) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ret = wifi_get_connected_ap(ap);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("wifi_get_connected_ap() failed.");
+ return ret;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Sets the Proxy type.
+ *
+ * If you set Proxy type to #WIFI_PROXY_TYPE_AUTO or
+ * #WIFI_PROXY_TYPE_MANUAL, then Proxy will be restored.
+ *
+ * @param[in] method The proxy method
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_set_proxy_type(enum method_enum method)
+{
+ wifi_proxy_type_e type;
+ wifi_ap_h ap;
+ int ret;
+
+ if (method < 0 || method >= METHOD_NUM) {
+ _ERR("method is invalid.");
+ return RET_FAILED;
+ }
+
+ ap = NULL;
+ ret = wifi_get_connected_ap(ap);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("wifi_get_connected_ap() failed.");
+ return ret;
+ }
+
+ switch (method) {
+ case METHOD_NONE:
+ type = WIFI_PROXY_TYPE_DIRECT;
+ break;
+ case METHOD_MAN:
+ type = WIFI_PROXY_TYPE_MANUAL;
+ break;
+ case METHOD_AUTO:
+ type = WIFI_PROXY_TYPE_AUTO;
+ break;
+ default:
+ return RET_FAILED;
+ }
+
+ ret = wifi_ap_set_proxy_type(ap, type);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("wifi_ap_set_proxy_type() failed.");
+ return ret;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets the Proxy type.
+ *
+ * @param[out] method The proxy method
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_get_proxy_type(enum method_enum *method)
+{
+ wifi_proxy_type_e type;
+ wifi_ap_h ap;
+ int ret;
+
+ if (!method) {
+ _ERR("method is invalid.");
+ return RET_FAILED;
+ }
+
+ ap = NULL;
+ ret = wifi_get_connected_ap(ap);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("wifi_get_connected_ap() failed.");
+ return ret;
+ }
+
+ ret = wifi_ap_get_proxy_type(ap, &type);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("wifi_ap_get_proxy_type() failed.");
+ return ret;
+ }
+
+ switch (type) {
+ case WIFI_PROXY_TYPE_DIRECT:
+ *method = METHOD_NONE;
+ break;
+ case WIFI_PROXY_TYPE_MANUAL:
+ *method = METHOD_MAN;
+ break;
+ case WIFI_PROXY_TYPE_AUTO:
+ *method = METHOD_AUTO;
+ break;
+ default:
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+
+}
+
+/**
+ * Sets the proxy address.
+ *
+ * @param[in] ip The IP address
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_set_proxy_address(const char *ip)
+{
+ wifi_ap_h ap;
+ int ret;
+
+ ap = NULL;
+ ret = wifi_get_connected_ap(ap);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("wifi_get_connected_ap() failed.");
+ return ret;
+ }
+
+ ret = wifi_ap_set_proxy_address(ap, WIFI_ADDRESS_FAMILY_IPV4, ip);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("wifi_ap_set_proxy_address() failed.");
+ return ret;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+ * Gets the proxy address.
+ *
+ * @param[out] ip The IP address
+ * @return RET_SUCCESS if the operation is successful; RET_FAILED if failed;
+ */
+int wifi_mgr_get_proxy_address(char **ip)
+{
+ wifi_ap_h ap;
+ int ret;
+
+ if (!ip || !*ip) {
+ _ERR("ip is invalid.");
+ return RET_FAILED;
+ }
+
+ ap = NULL;
+ ret = wifi_get_connected_ap(ap);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("wifi_get_connected_ap() failed.");
+ return ret;
+ }
+
+ ret = wifi_ap_get_proxy_address(ap, WIFI_ADDRESS_FAMILY_IPV4, ip);
+ if (ret != WIFI_ERROR_NONE) {
+ _ERR("wifi_ap_get_proxy_address() failed.");
+ return ret;
+ }
+
+ return RET_SUCCESS;
+}
diff --git a/ug/src/NetConMgr.cpp b/ug/src/NetConMgr.cpp
deleted file mode 100644
index b5de2d0..0000000
--- a/ug/src/NetConMgr.cpp
+++ /dev/null
@@ -1,614 +0,0 @@
-#include <AppCommon.h>
-#include "NetConMgr.h"
-
-#define IP_STRING_MAX_SIZE 20
-#define MAX_NAME_SIZE 256
-#define CONTENT_TXT_SIZE 500
-#define ZERO_IP "0.0.0.0"
-
-CNetConMgr *CNetConMgr::instance = NULL;
-
-struct SNetConMgr {
- connection_h handle;
- connection_profile_h ethernet_profile_h;
- void(*ip_changed_cb)(bool change_state, void *data);
-};
-
-
-void CNetConMgr::sm_CbIpAddrChanged(const char *ipv4, const char *ipv6, void* data)
-{
- _DBG("IP addr is changed!! [IPv4:%s] [IPv6:%s]", ipv4, ipv6);
-
- CNetConMgr::GetInstance()->m_OnIpAddrChanged(data);
-}
-
-
-void CNetConMgr::m_OnIpAddrChanged(void *data)
-{
- if(m->ip_changed_cb)
- m->ip_changed_cb(true, data);
-}
-
-
-void CNetConMgr::sm_CbProfileStateChanged(connection_profile_state_e state, void *data)
-{
-
- _DBG("Profile is changed!!!!!!!!!!!!!!!!!!!!!!!!!");
-
- /* TODO : check the flow again */
- CNetConMgr::GetInstance()->RefreshEthernetProfile();
-}
-
-
-bool CNetConMgr::m_GetEthernetProfile(void)
-{
- ASSERT(m);
-
- connection_profile_iterator_h iter = NULL;
- connection_profile_type_e type;
-
- int ret;
- char name[MAX_NAME_SIZE] = {0};
-
- ret = connection_get_profile_iterator(m->handle, CONNECTION_ITERATOR_TYPE_REGISTERED, &iter);
- if (ret != CONNECTION_ERROR_NONE) {
- _ERR("Fail to get profile iterator: %s", GetErrorMsg((connection_error_e) ret));
- return false;
- }
-
- while (connection_profile_iterator_has_next(iter)) {
-
- m->ethernet_profile_h = NULL;
-
- if (connection_profile_iterator_next(iter, &m->ethernet_profile_h) != CONNECTION_ERROR_NONE) {
- _ERR("Fail to get profile handle");
- break;
- }
-
- if (connection_profile_get_type(m->ethernet_profile_h, &type) != CONNECTION_ERROR_NONE) {
- _ERR("Fail to get profile type");
- break;
- }
-
- if (type == CONNECTION_PROFILE_TYPE_ETHERNET)
- {
- /* FIXME : should check when there are same ethernet profiles. */
- break;
- }
- }
-
- if(!m->ethernet_profile_h) {
- _ERR("ethernet_profile_h is NULL");
- return false;
- }
-
- GetProfileName(name);
- _DBG("GetProfileName = %s", name);
-
- ret = connection_profile_set_state_changed_cb( m->ethernet_profile_h, sm_CbProfileStateChanged, (void *)instance);
- if (ret != CONNECTION_ERROR_NONE) {
- _ERR("connection_profile_set_state_changed_cb() failed.");
- return false;
- }
-
- return true;
-}
-
-
-bool CNetConMgr::m_UpdateProfile(void)
-{
- ASSERT(m);
-
- int ret = -1;
-
- ret = connection_update_profile( m->handle, m->ethernet_profile_h);
- if (ret != CONNECTION_ERROR_NONE) {
- _ERR("connection_update_profile failed");
- return false;
- }
-
- return true;
-}
-
-
-bool CNetConMgr::Initialize(void)
-{
- ASSERT(!instance);
-
- instance = new CNetConMgr;
- if(!instance) {
- _ERR("Fail to allocate memory");
- return false;
- }
-
- instance->m = new SNetConMgr;
- if(!instance->m) {
- _ERR("Fail to allocate memory");
- delete (instance);
- return false;
- }
-
- int ret = 0;
- ret = connection_create(&instance->m->handle);
- if( ret != CONNECTION_ERROR_NONE) {
- _ERR("Fail to create connection : error = %s", instance->GetErrorMsg((connection_error_e) ret));
- delete (instance->m);
- delete (instance);
- instance = NULL;
- return false;
- }
-
- if(!instance->m_GetEthernetProfile()) {
- _ERR("Fail to get ethernet_profile");
- }
-
- return true;
-}
-
-
-void CNetConMgr::Finalize(void)
-{
- if(!instance)
- return;
-
- ASSERT(instance->m);
-
- int ret = 0;
- ret = connection_destroy(instance->m->handle);
- if( ret != CONNECTION_ERROR_NONE) {
- _ERR("Fail to destroy connection : error = %s", instance->GetErrorMsg((connection_error_e) ret));
- }
-
- delete (instance->m);
- delete (instance);
- instance = NULL;
-}
-
-
-CNetConMgr *CNetConMgr::GetInstance(void)
-{
- return instance;
-}
-
-
-void CNetConMgr::RefreshEthernetProfile(void)
-{
- ASSERT(m);
-
- if(!m_GetEthernetProfile()) {
- _ERR("Fail to get ethernet_profile");
- }
-}
-
-
-bool CNetConMgr::GetEthernetState(bool *out_state)
-{
- ASSERT(m);
-
- int ret = -1;
- connection_ethernet_state_e state;
-
- if (!out_state) {
- _ERR("the param is invalid.");
- return false;
- }
-
- ret = connection_get_ethernet_state(m->handle, &state);
- if (ret != CONNECTION_ERROR_NONE) {
- _ERR("connection_get_ethernet_state() failed.");
- return false;
- }
-
- if (state == CONNECTION_ETHERNET_STATE_DEACTIVATED)
- *out_state = false;
- else
- *out_state = true;
-
- return true;
-}
-
-
-bool CNetConMgr::GetProfileName(char *out_name)
-{
- ASSERT(m);
-
- char *name;
-
- if(!m->ethernet_profile_h) {
- _ERR("There is no ethernet profile Try to call RefreshEthernetProfile()");
- return false;
- }
-
- if (connection_profile_get_name(m->ethernet_profile_h, &name) != CONNECTION_ERROR_NONE) {
- _ERR("Fail to get profile name\n");
- return false;
- }
-
- strncpy(out_name, name, MAX_NAME_SIZE - 1);
-
- delete (name);
- return true;
-}
-
-
-bool CNetConMgr::IsConnected(void)
-{
- ASSERT(m);
-
- int ret;
- connection_ethernet_state_e state;
-
- ret = connection_get_ethernet_state(m->handle, &state);
- if (ret == CONNECTION_ERROR_NONE && state == CONNECTION_ETHERNET_STATE_CONNECTED)
- return true;
-
- return false;
-}
-
-
-bool CNetConMgr::SetIpConfType(connection_ip_config_type_e type)
-{
- ASSERT(m);
-
- if(!m_UpdateProfile()) return false;
-
- int ret = -1;
-
- ret = connection_profile_set_ip_config_type( m->ethernet_profile_h, CONNECTION_ADDRESS_FAMILY_IPV4, type);
- if (ret != CONNECTION_ERROR_NONE) {
- _ERR("connection_profile_set_ip_config_type() failed.");
- return false;
- }
-
- if(!m_UpdateProfile()) return false;
-
- return true;
-}
-
-
-bool CNetConMgr::SetIpAddr(char *ip)
-{
- ASSERT(m);
-
- if(!m_UpdateProfile()) return false;
- if(!SetIpConfType(CONNECTION_IP_CONFIG_TYPE_STATIC)) return false;
-
- int ret = -1;
- ret = connection_profile_set_ip_address( m->ethernet_profile_h, CONNECTION_ADDRESS_FAMILY_IPV4, ip);
- if (ret != CONNECTION_ERROR_NONE) {
- _ERR("connection_profile_set_ip_address() failed.");
- return false;
- }
-
- if(!m_UpdateProfile()) return false;
-
- return true;
-}
-
-
-bool CNetConMgr::SetSubnetMask(char *submask)
-{
- ASSERT(m);
-
- if(!m_UpdateProfile()) return false;
- if(!SetIpConfType(CONNECTION_IP_CONFIG_TYPE_STATIC)) return false;
-
- int ret = -1;
- ret = connection_profile_set_subnet_mask( m->ethernet_profile_h, CONNECTION_ADDRESS_FAMILY_IPV4, submask);
- if (ret != CONNECTION_ERROR_NONE) {
- _ERR("fail to set_subnet_mask");
- return false;
- }
-
- if(!m_UpdateProfile()) return false;
- return true;
-}
-
-
-bool CNetConMgr::SetGateway(char *gateway)
-{
- ASSERT(m);
-
- if(!m_UpdateProfile()) return false;
- if(!SetIpConfType(CONNECTION_IP_CONFIG_TYPE_STATIC)) return false;
-
- int ret = -1;
- ret = connection_profile_set_gateway_address( m->ethernet_profile_h, CONNECTION_ADDRESS_FAMILY_IPV4, gateway);
- if (ret != CONNECTION_ERROR_NONE) {
- _ERR("fail to set_gateway_address");
- return false;
- }
-
- if(!m_UpdateProfile()) return false;
- return true;
-}
-
-
-bool CNetConMgr::SetDNS(char *dns)
-{
- ASSERT(m);
-
- if(!m_UpdateProfile()) return false;
- if(!SetIpConfType(CONNECTION_IP_CONFIG_TYPE_STATIC)) return false;
-
- int ret = -1;
- ret = connection_profile_set_dns_address( m->ethernet_profile_h, 1, CONNECTION_ADDRESS_FAMILY_IPV4, dns);
- if (ret != CONNECTION_ERROR_NONE) {
- _ERR("fail to set_dns_address");
- return false;
- }
-
- if(!m_UpdateProfile()) return false;
- return true;
-}
-
-
-bool CNetConMgr::GetIpAddr(char *ip)
-{
- ASSERT(m);
-
- if(!ip) {
- _ERR("Invalid parameter");
- return false;
- }
-
- char *str_value;
-
- if (connection_profile_get_ip_address( m->ethernet_profile_h, CONNECTION_ADDRESS_FAMILY_IPV4, &str_value) != CONNECTION_ERROR_NONE) {
- _ERR("Fail to get IP address!");
- strncpy(ip, ZERO_IP, IP_STRING_MAX_SIZE);
- } else {
- strncpy(ip, str_value, IP_STRING_MAX_SIZE);
- delete(str_value);
- }
-
- return true;
-}
-
-
-bool CNetConMgr::GetSubnetMask(char *submask)
-{
- ASSERT(m);
-
- if(!submask) {
- _ERR("Invalid parameter");
- return false;
- }
-
- char *str_value;
- if (connection_profile_get_subnet_mask( m->ethernet_profile_h, CONNECTION_ADDRESS_FAMILY_IPV4, &str_value) != CONNECTION_ERROR_NONE) {
- _ERR("Fail to get subnet mask!");
- strncpy(submask, ZERO_IP, IP_STRING_MAX_SIZE);
- } else {
- strncpy(submask, str_value, IP_STRING_MAX_SIZE);
- delete(str_value);
- }
-
- return true;
-}
-
-
-bool CNetConMgr::GetGateway(char *gateway)
-{
- ASSERT(m);
-
- if(!gateway) {
- _ERR("Invalid parameter");
- return false;
- }
-
- char *str_value;
- if (connection_profile_get_gateway_address( m->ethernet_profile_h, CONNECTION_ADDRESS_FAMILY_IPV4, &str_value) != CONNECTION_ERROR_NONE) {
- _ERR("Fail to get gateway!");
- strncpy(gateway, ZERO_IP, IP_STRING_MAX_SIZE);
- } else {
- strncpy(gateway, str_value, IP_STRING_MAX_SIZE);
- delete(str_value);
- }
-
- return true;
-}
-
-
-bool CNetConMgr::GetDNS(char *dns)
-{
- ASSERT(m);
-
- if(!dns) {
- _ERR("Invalid parameter");
- return false;
- }
-
- char *str_value;
- if (connection_profile_get_dns_address( m->ethernet_profile_h, 1, CONNECTION_ADDRESS_FAMILY_IPV4, &str_value) != CONNECTION_ERROR_NONE) {
- _ERR("Fail to get DNS1!");
- strncpy(dns, ZERO_IP, IP_STRING_MAX_SIZE);
- } else {
- strncpy(dns, str_value, IP_STRING_MAX_SIZE);
- delete(str_value);
- }
-
- return true;
-}
-
-
-bool CNetConMgr::SetProxyType(EProxyMethod method)
-{
- ASSERT(m);
- if(!m->ethernet_profile_h) {
- _ERR("There is no ethernet profile Try to call RefreshEthernetProfile()");
- return false;
- }
-
- connection_proxy_type_e type;
-
- int ret;
-
- switch (method) {
- case PROXY_METHOD_NONE:
- type = CONNECTION_PROXY_TYPE_DIRECT;
- break;
- case PROXY_METHOD_MANUAL:
- type = CONNECTION_PROXY_TYPE_MANUAL;
- break;
- case PROXY_METHOD_AUTO:
- type = CONNECTION_PROXY_TYPE_AUTO;
- break;
- default:
- return false;
- }
-
- ret = connection_profile_set_proxy_type( m->ethernet_profile_h, type);
- if (ret != CONNECTION_ERROR_NONE) {
- _ERR("connection_profile_set_proxy_type() failed");
- return false;
- }
-
- return true;
-}
-
-
-bool CNetConMgr::GetProxyType(EProxyMethod *method)
-{
- ASSERT(m);
- if(!m->ethernet_profile_h) {
- _ERR("There is no ethernet profile Try to call RefreshEthernetProfile()");
- return false;
- }
-
- connection_proxy_type_e type;
-
- int ret;
-
- if (!method) {
- _ERR("the param is invalid.");
- return false;
- }
-
- ret = connection_profile_get_proxy_type( m->ethernet_profile_h, &type);
- if (ret != CONNECTION_ERROR_NONE) {
- _ERR("connection_profile_get_proxy_type() failed");
- return false;
- }
-
- switch (type) {
- case CONNECTION_PROXY_TYPE_DIRECT:
- *method = PROXY_METHOD_NONE;
- break;
- case CONNECTION_PROXY_TYPE_MANUAL:
- *method = PROXY_METHOD_MANUAL;
- break;
- case CONNECTION_PROXY_TYPE_AUTO:
- *method = PROXY_METHOD_AUTO;
- break;
- default:
- return false;
- }
-
- return true;
-}
-
-
-bool CNetConMgr::SetProxyAddr(char *ip)
-{
- ASSERT(m);
- if(!m->ethernet_profile_h) {
- _ERR("There is no ethernet profile Try to call RefreshEthernetProfile()");
- return false;
- }
-
- int ret;
-
- ret = connection_profile_set_proxy_address( m->ethernet_profile_h, CONNECTION_ADDRESS_FAMILY_IPV4, ip);
- if (ret != CONNECTION_ERROR_NONE) {
- _ERR("connection_profile_set_proxy_address() failed");
- return false;
- }
-
- return true;
-}
-
-
-bool CNetConMgr::GetProxyAddr(char *ip)
-{
- ASSERT(m);
- if(!m->ethernet_profile_h) {
- _ERR("There is no ethernet profile Try to call RefreshEthernetProfile()");
- return false;
- }
-
- int ret;
- char *str;
-
- if (!ip) {
- _ERR("the param is invalid.");
- return false;
- }
-
- ret = connection_profile_get_proxy_address( m->ethernet_profile_h, CONNECTION_ADDRESS_FAMILY_IPV4, &str);
- if (ret != CONNECTION_ERROR_NONE) {
- _ERR("connection_profile_get_proxy_address() failed");
- return false;
- }
-
- strncpy(ip, str, IP_STRING_MAX_SIZE );
- delete (str);
-
- return true;
-}
-
-
-const char *CNetConMgr::GetErrorMsg(connection_error_e err)
-{
- switch (err) {
- case CONNECTION_ERROR_NONE:
- return "NONE";
- case CONNECTION_ERROR_INVALID_PARAMETER:
- return "INVALID_PARAMETER";
- case CONNECTION_ERROR_OUT_OF_MEMORY:
- return "OUT_OF_MEMORY";
- case CONNECTION_ERROR_INVALID_OPERATION:
- return "INVALID_OPERATION";
- case CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
- return "ADDRESS_FAMILY_NOT_SUPPORTED";
- case CONNECTION_ERROR_OPERATION_FAILED:
- return "OPERATION_FAILED";
- case CONNECTION_ERROR_ITERATOR_END:
- return "ITERATOR_END";
- case CONNECTION_ERROR_NO_CONNECTION:
- return "NO_CONNECTION";
- case CONNECTION_ERROR_NOW_IN_PROGRESS:
- return "NOW_IN_PROGRESS";
- case CONNECTION_ERROR_ALREADY_EXISTS:
- return "ALREADY_EXISTS";
- case CONNECTION_ERROR_OPERATION_ABORTED:
- return "OPERATION_ABORTED";
- case CONNECTION_ERROR_DHCP_FAILED:
- return "DHCP_FAILED";
- case CONNECTION_ERROR_INVALID_KEY:
- return "INVALID_KEY";
- case CONNECTION_ERROR_NO_REPLY:
- return "NO_REPLY";
- default:
- break;
- }
-
- return "Unknown";
-}
-
-
-bool CNetConMgr::RegisterIpChangedCallback(void(*ip_changed_cb)(bool connected, void *data), void *data)
-{
- ASSERT(m);
-
- int ret = -1;
-
- ret = connection_set_ip_address_changed_cb( m->handle, sm_CbIpAddrChanged, data);
- if (ret != CONNECTION_ERROR_NONE) {
- _ERR("connection_set_ip_address_changed_cb() failed.");
- return false;
- }
- m->ip_changed_cb = ip_changed_cb;
-
- return true;
-}
diff --git a/ug/src/TVServiceMgr.cpp b/ug/src/TVServiceMgr.cpp
deleted file mode 100644
index 1d4cd6f..0000000
--- a/ug/src/TVServiceMgr.cpp
+++ /dev/null
@@ -1,295 +0,0 @@
-#include <cstdlib>
-#include <Ecore.h>
-#include <AppCommon.h>
-//#include "tv_service_proxy.h"
-
-#include "TVServiceMgr.h"
-
-#define SIGNAL_HANDLER_INTERVAL 0.1
-
-CTVServiceMgr *CTVServiceMgr::instance = NULL;
-
-enum tv_scan_state {
- SCAN_STATE_READY,
- SCAN_STATE_SEARCHING,
- SCAN_STATE_PAUSED,
- SCAN_STATE_STOPPING,
- SCAN_STATE_MAX
-};
-
-
-struct tv_scan_result {
- unsigned int air_dtv;
- unsigned int cable_dtv;
- unsigned int air_atv;
- unsigned int cable_atv;
-};
-
-
-struct STVServiceMgr {
- //struct tv_scan_cbs cbs;
- enum tv_scan_state state;
- enum antenna_mode set_mode;
-#if 0
- TvServiceScan service_scan;
- TvServiceScanType scan_type;
-#endif
- int ch_count;
- int ch_num;
- int total_ch;
- struct tv_scan_result res;
- int is_stopped;
- Eina_List *signal_queue;
- Ecore_Timer *signal_timer;
-};
-
-struct _signal_info {
-#if 0
- TvServiceScanType scan_type;
- TvServiceScanEvent signal;
- TvServiceScanEventData signal_data;
-#endif
-};
-
-
-bool CTVServiceMgr::Initialize(void)
-{
- ASSERT(!instance);
-
- instance = new CTVServiceMgr;
- if(!instance)
- return false;
-
- instance->m = new STVServiceMgr;
- if(instance->m == NULL) return false;
-
-#if 0
- struct tv_scan *tvs;
- TvServiceScan scan;
- TvServiceScanType type;
- gint result;
- int r;
-
- tvs = calloc(1, sizeof(*tvs));
- if (!tvs) {
- _ERR("calloc failed");
- return NULL;
- }
-
- r = _get_scan_mode(mode, &type);
- if (r == -1) {
- _ERR("Get scan mode failed");
- free(tvs);
- return NULL;
- }
-
- result = tv_service_scan_create(&scan, type);
- if (result != TVS_ERROR_OK) {
- _ERR("Create Scan failed");
- free(tvs);
- return NULL;
- }
-
- tvs->service_scan = scan;
- tvs->scan_type = type;
- tvs->set_mode = mode;
- tvs->state = SCAN_STATE_READY;
-
- return tvs;
-#endif
- return NULL;
-
-}
-
-
-void CTVServiceMgr::Finalize(void)
-{
- if(!instance)
- return;
- ASSERT(instance->m);
-#if 0
- struct _signal_info *sinfo;
-
- if (!tvs) {
- _ERR("Invalid argument");
- return -1;
- }
-
- if (tvs->state != SCAN_STATE_READY)
- tv_scan_stop(tvs);
-
- if (tvs->signal_timer)
- ecore_timer_del(tvs->signal_timer);
-
- EINA_LIST_FREE(tvs->signal_queue, sinfo)
- free(sinfo);
-
- tv_service_scan_destroy(tvs->service_scan);
- free(tvs);
-
-#endif
- delete instance->m;
- delete instance;
- instance = NULL;
-}
-
-
-CTVServiceMgr *CTVServiceMgr::GetInstance(void)
-{
- return instance;
-}
-
-
-bool CTVServiceMgr::Start(void)
-{
- ASSERT(m);
-#if 0
- gint result;
-
- if (!tvs || !tvs->service_scan) {
- _ERR("Invalid argument");
- return -1;
- }
-
- if (tvs->state != SCAN_STATE_READY) {
- _ERR("unable state to start scan");
- return -1;
- }
-
- result = tv_service_scan_register_callback(tvs->service_scan,
- _signal_received, (gpointer)tvs);
- if (result != TVS_ERROR_OK) {
- _ERR("register callback failed");
- return -1;
- }
-
- result = tv_service_scan_start(tvs->service_scan);
- if (result != TVS_ERROR_OK) {
- _ERR("scan start failed");
- return -1;
- }
-
- tvs->state = SCAN_STATE_SEARCHING;
- tvs->is_stopped = 0;
- tvs->ch_count = 0;
- memset(&tvs->res, 0x00, sizeof(tvs->res));
-
- return 0;
-#endif
- return false;
-}
-
-
-bool CTVServiceMgr::Pause(void)
-{
- ASSERT(m);
-#if 0
- gint result;
-
- if (!tvs || !tvs->service_scan) {
- _ERR("Invalid argument");
- return -1;
- }
-
- if (tvs->state != SCAN_STATE_SEARCHING) {
- _ERR("unable state to pause scan");
- return -1;
- }
-
- result = tv_service_scan_pause(tvs->service_scan);
- if (result != TVS_ERROR_OK) {
- _ERR("Pause Scan failed");
- return -1;
- }
-
- tvs->state = SCAN_STATE_PAUSED;
-
-#endif
- return false;
-}
-
-
-bool CTVServiceMgr::Resume(void)
-{
- ASSERT(m);
-#if 0
- gint result;
-
- if (!tvs || !tvs->service_scan) {
- _ERR("Invalid argument");
- return -1;
- }
-
- if (tvs->state != SCAN_STATE_PAUSED) {
- _ERR("unable state to resume scan");
- return -1;
- }
-
- result = tv_service_scan_resume(tvs->service_scan);
- if (result != TVS_ERROR_OK) {
- _ERR("resume Scan failed");
- return -1;
- }
-
- tvs->state = SCAN_STATE_SEARCHING;
-
-#endif
- return false;
-}
-
-
-bool CTVServiceMgr::Stop(void)
-{
- ASSERT(m);
-#if 0
- gint result;
-
- if (!tvs) {
- _ERR("Invalid argument");
- return -1;
- }
-
- if (tvs->state == SCAN_STATE_READY) {
- _ERR("unable state to stop scan");
- return -1;
- }
-
- result = tv_service_scan_stop(tvs->service_scan);
- if (result != TVS_ERROR_OK) {
- _ERR("Create Scan failed");
- return -1;
- }
-
- tvs->state = SCAN_STATE_STOPPING;
- tvs->is_stopped = 1;
-
-#endif
- return false;
-}
-
-
-bool CTVServiceMgr::GetAllChannel(void)
-{
- ASSERT(m);
-
- return m->total_ch;
-}
-
-
-unsigned int CTVServiceMgr::GetServiceType(void)
-{
- ASSERT(m);
-
-#if 0
- return &tvs->res;
-#endif
- return -1;
-}
-
-
-bool CTVServiceMgr::IsStopped(void)
-{
- ASSERT(m);
-
- return m->is_stopped;
-}
diff --git a/ug/src/WifiDirectMgr.cpp b/ug/src/WifiDirectMgr.cpp
deleted file mode 100644
index 90697cb..0000000
--- a/ug/src/WifiDirectMgr.cpp
+++ /dev/null
@@ -1,476 +0,0 @@
-#include "defs.h"
-#include <AppCommon.h>
-#include "WifiMgr.h"
-#include "WifiDirectMgr.h"
-
-#define LOCAL_MAX_CLIENT 8
-
-#define WIFI_DIRECT_DISCOVERY_LISTEN_AND_SCAN 0
-#define WIFI_DIRECT_SCAN_TIMEOUT 3
-
-CWifiDirectMgr *CWifiDirectMgr::instance = NULL;
-
-struct SWifiDirectMgr {
- CWifiMgr *pWifiMgr;
-};
-
-bool CWifiDirectMgr::Initialize()
-{
- ASSERT(!instance);
-
- instance = new CWifiDirectMgr;
- if(!instance)
- return false;
-
- instance->m = new SWifiDirectMgr;
- if(instance->m == NULL) return false;
-
-
- if(CWifiMgr::Initialize()) {
- _ERR("Fail to init wifi");
- return false;
- }
-
- int ret = -1;
- ret = wifi_direct_initialize();
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("wifi_direct_initialize failed, ret:%s.", instance->GetErrorMsg(ret));
- CWifiMgr::Finalize();
- delete instance->m;
- delete instance;
- instance = NULL;
- return false;
- }
-
- return true;
-}
-
-
-void CWifiDirectMgr::Finalize()
-{
- if(!instance)
- return;
- ASSERT(instance->m);
-
- int ret = -1;
- ret = wifi_direct_deinitialize();
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("wifi_direct_deinitialize failed, ret:%s.", instance->GetErrorMsg(ret));
- }
-
- CWifiMgr::Finalize();
-
- delete instance->m;
- delete instance;
- instance = NULL;
-}
-
-
-CWifiDirectMgr * CWifiDirectMgr::GetInstance()
-{
- return instance;
-}
-
-
-char* CWifiDirectMgr::GetDevieName(void)
-{
- int ret;
- char *name = NULL;
-
- ret = wifi_direct_get_device_name(&name);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("get device name failed, ret: %s.", GetErrorMsg(ret));
- return NULL;
- }
-
- return name;
-}
-
-
-char* CWifiDirectMgr::GetMacAddr(void)
-{
- int ret;
- char *mac_addr = NULL;
-
- ret = wifi_direct_get_mac_address(&mac_addr);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("get mac address failed, ret: %s.", GetErrorMsg(ret));
- return NULL;
- }
-
- return mac_addr;
-}
-
-
-bool CWifiDirectMgr::GetState(wifi_direct_state_e *status)
-{
- int ret;
-
- if (!status) {
- _ERR("The param is NULL.");
- return false;
- }
-
- ret = wifi_direct_get_state(status);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("get state failed ret:%s.", GetErrorMsg(ret));
- return false;
- }
-
- return true;
-}
-
-
-bool CWifiDirectMgr::Activate(void)
-{
- int ret;
-
- ret = wifi_direct_activate();
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("wifi_direct_activate failed ret:%s.", GetErrorMsg(ret));
- return false;
- }
-
- return true;
-}
-
-
-bool CWifiDirectMgr::Deactivate(void)
-{
- int ret;
-
- ret = wifi_direct_deactivate();
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("wifi_direct_deactivate failed ret:%s.", GetErrorMsg(ret));
- return false;
- }
-
- return true;
-}
-
-
-bool CWifiDirectMgr::SetMaxClient(void)
-{
- int ret;
-
- ret = wifi_direct_set_max_clients(LOCAL_MAX_CLIENT);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("set max client failed ret:%s.", GetErrorMsg(ret));
- return false;
- }
-
- return true;
-}
-
-
-bool CWifiDirectMgr::GetAllDicoveredPeerInfo(wifi_direct_discovered_peer_cb cb, void *data)
-{
- int ret;
-
- if (!cb || !data) {
- _ERR("The parameter is NULL.");
- return false;
- }
-
- ret = wifi_direct_foreach_discovered_peers(cb, data);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("foreach connected pees failed ret:%s.", GetErrorMsg(ret));
- return false;
- }
-
- return true;
-}
-
-
-bool CWifiDirectMgr::GetAllConnectedPeerInfo(wifi_direct_connected_peer_cb cb, void *data)
-{
- int ret;
-
- if (!cb || !data) {
- _ERR("The parameter is NULL.");
- return false;
- }
-
- ret = wifi_direct_foreach_connected_peers(cb, data);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("foreach connected peers failed ret:%s.", GetErrorMsg(ret));
- return false;
- }
-
- return true;
-}
-
-
-bool CWifiDirectMgr::StartDiscovery(void)
-{
- int ret;
-
- ret = wifi_direct_start_discovery(WIFI_DIRECT_DISCOVERY_LISTEN_AND_SCAN, WIFI_DIRECT_SCAN_TIMEOUT);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("start discovery failed ret:%s.", GetErrorMsg(ret));
- return false;
- }
-
- return true;
-}
-
-
-bool CWifiDirectMgr::CancelDiscovery(void)
-{
- int ret;
-
- ret = wifi_direct_cancel_discovery();
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("wifi_direct_cancel_discovery failed ret:%s.", GetErrorMsg(ret));
- return false;
- }
-
- return true;
-}
-
-
-bool CWifiDirectMgr::Connect(const char *macaddr)
-{
- int ret;
-
- if (!macaddr) {
- _ERR("mac_address is NULL");
- return false;
- }
-
- ret = wifi_direct_connect(macaddr);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("wifi_direct_connect failed,%s.", GetErrorMsg(ret));
- return false;
- }
-
- return true;
-}
-
-
-bool CWifiDirectMgr::Disconnect(const char *macaddr)
-{
- int ret;
-
- if (!macaddr) {
- _ERR("mac_address is NULL");
- return false;
- }
-
- ret = wifi_direct_disconnect(macaddr);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("wifi_direct_disconnect failed,%s.", GetErrorMsg(ret));
- return false;
- }
-
- return true;
-}
-
-
-bool CWifiDirectMgr::AcceptConnection(char *macaddr)
-{
- int ret;
-
- if (!macaddr) {
- _ERR("mac_address is NULL");
- return false;
- }
-
- ret = wifi_direct_accept_connection(macaddr);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("wifi_direct_accept_connection failed,%s.", GetErrorMsg(ret));
- return false;
- }
-
- return true;
-}
-
-
-bool CWifiDirectMgr::GetWPStype(Eina_Bool *is_pbc)
-{
- _DBG("Not Yet");
-#if 0
- wifi_direct_wps_type_e type;
-
- if (!is_pbc) {
- _ERR("Parameter is NULL");
- return false;
- }
-
- int ret;
- ret = wifi_direct_get_wps_type(&type);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("wifi_direct_get_wps_type failed,%s.",
- wifi_direct_mgr_err_dbg(ret));
- return false;
- }
-
- if ((type & WIFI_DIRECT_WPS_TYPE_PBC) == WIFI_DIRECT_WPS_TYPE_PBC)
- *is_pbc = EINA_TRUE;
- else
- *is_pbc = EINA_FALSE;
-
- return true;
-#endif
- return false;
-}
-
-
-bool CWifiDirectMgr::SetWPStype(wifi_direct_wps_type_e *type)
-{
- if (!type) {
- _ERR("Parameter is NULL");
- return false;
- }
-
- _DBG("Not Yet");
-#if 0
- int ret;
- ret = wifi_direct_set_wps_type(*type);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("wifi_direct_get_wps_type failed,%s.",
- wifi_direct_mgr_err_dbg(ret));
- return false;
- }
-#endif
-
- return true;
-}
-
-
-bool CWifiDirectMgr::SetDeviceStateChangedCb(wifi_direct_device_state_changed_cb cb, void *data)
-{
- int ret = -1;
- ret = wifi_direct_set_device_state_changed_cb(cb, data);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("set device state changed cb failed ret:%s.", GetErrorMsg(ret));
- return false;
- }
- return true;
-}
-
-
-bool CWifiDirectMgr::UnSetDeviceStateChangedCb(void)
-{
- int ret = -1;
- ret = wifi_direct_unset_device_state_changed_cb();
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("unset device state changed cb failed ret:%s.", GetErrorMsg(ret));
- return false;
- }
- return true;
-}
-
-
-bool CWifiDirectMgr::SetDiscoveryStateChangedCb(wifi_direct_discovery_state_chagned_cb cb, void *data)
-{
- int ret = -1;
- ret = wifi_direct_set_discovery_state_changed_cb(cb, data);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("set discovery state changed cb failed ret:%s.", GetErrorMsg(ret));
- wifi_direct_unset_device_state_changed_cb();
- return false;
- }
- return true;
-}
-
-
-bool CWifiDirectMgr::UnSetDiscoveryStateChangedCb(void)
-{
- int ret = -1;
- ret = wifi_direct_unset_discovery_state_changed_cb();
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("unset discovery state changed cb failed ret:%s.", GetErrorMsg(ret));
- return false;
- }
- return true;
-}
-
-
-bool CWifiDirectMgr::SetConnectionStateChangedCb(wifi_direct_connection_state_changed_cb cb, void *data)
-{
- int ret = -1;
- ret = wifi_direct_set_connection_state_changed_cb(cb, data);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("set connection state changed cb failed ret:%s.", GetErrorMsg(ret));
- wifi_direct_unset_device_state_changed_cb();
- wifi_direct_unset_discovery_state_changed_cb();
- return false;
- }
- return true;
-}
-
-
-bool CWifiDirectMgr::UnSetConnectionStateChangedCb(void)
-{
- int ret = -1;
- ret = wifi_direct_unset_connection_state_changed_cb();
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("unset connection state changed cb failed ret:%s.", GetErrorMsg(ret));
- return false;
- }
- return true;
-}
-
-
-bool CWifiDirectMgr::UnSetClientIpAddrAssignedCb(void)
-{
- int ret = -1;
- ret = wifi_direct_unset_client_ip_address_assigned_cb();
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("unset device state changed cb failed ret:%s.", GetErrorMsg(ret));
- return false;
- }
- return true;
-}
-
-
-const char *CWifiDirectMgr::GetErrorMsg(int err)
-{
- switch (err) {
- case WIFI_DIRECT_ERROR_OUT_OF_MEMORY:
- return "WIFI_DIRECT_ERROR_OUT_OF_MEMORY";
- break;
- case WIFI_DIRECT_ERROR_NOT_PERMITTED:
- return "WIFI_DIRECT_ERROR_NOT_PERMITTED";
- break;
- case WIFI_DIRECT_ERROR_INVALID_PARAMETER:
- return "WIFI_DIRECT_ERROR_INVALID_PARAMETER";
- break;
- case WIFI_DIRECT_ERROR_RESOURCE_BUSY:
- return "WIFI_DIRECT_ERROR_RESOURCE_BUSY";
- break;
- case WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT:
- return "WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT";
- break;
- case WIFI_DIRECT_ERROR_NOT_INITIALIZED:
- return "WIFI_DIRECT_ERROR_NOT_INITIALIZED";
- break;
- case WIFI_DIRECT_ERROR_COMMUNICATION_FAILED:
- return "WIFI_DIRECT_ERROR_COMMUNICATION_FAILED";
- break;
- case WIFI_DIRECT_ERROR_WIFI_USED:
- return "WIFI_DIRECT_ERROR_WIFI_USED";
- break;
- case WIFI_DIRECT_ERROR_MOBILE_AP_USED:
- return "WIFI_DIRECT_ERROR_MOBILE_AP_USED";
- break;
- case WIFI_DIRECT_ERROR_CONNECTION_FAILED:
- return "WIFI_DIRECT_ERROR_CONNECTION_FAILED";
- break;
- case WIFI_DIRECT_ERROR_AUTH_FAILED:
- return "WIFI_DIRECT_ERROR_AUTH_FAILED";
- break;
- case WIFI_DIRECT_ERROR_OPERATION_FAILED:
- return "WIFI_DIRECT_ERROR_OPERATION_FAILED";
- break;
- case WIFI_DIRECT_ERROR_TOO_MANY_CLIENT:
- return "WIFI_DIRECT_ERROR_TOO_MANY_CLIENT";
- break;
- default:
- break;
- }
-
- return "UNKNOWN";
-}
-
diff --git a/ug/src/WifiMgr.cpp b/ug/src/WifiMgr.cpp
deleted file mode 100644
index f12b1a0..0000000
--- a/ug/src/WifiMgr.cpp
+++ /dev/null
@@ -1,533 +0,0 @@
-#include <cstdlib>
-#include <wifi.h>
-#include <AppCommon.h>
-#include "WifiMgr.h"
-
-
-#define IP_STRING_MAX_SIZE 20
-#define MAX_NAME_SIZE 256
-#define CONTENT_TXT_SIZE 500
-#define ZERO_IP "0.0.0.0"
-
-
-bool CWifiAp::m_CheckErr(const char *func, int ret)
-{
- if (ret != WIFI_ERROR_NONE) {
- _ERR("Fail to wifi_get_connected_ap %s", CWifiMgr::ErrorMsg((wifi_error_e)ret));
- }
-
- return ret == WIFI_ERROR_NONE ? true : false;
-}
-
-
-void CWifiAp::t_SetHandle(wifi_ap_h handle)
-{
- m_handle = handle;
-}
-
-
-CWifiAp::CWifiAp(wifi_ap_h handle)
-{
- m_handle = handle;
-
- int ret = wifi_ap_clone(&m_handle, handle);
- m_CheckErr(__FUNCTION__, ret);
-}
-
-
-CWifiAp::~CWifiAp()
-{
- wifi_ap_destroy(m_handle);
- m_handle = NULL;
-}
-
-
-#define WIFI_CHECK_RET(EXP) return m_CheckErr(__FUNCTION__, EXP);
-#define WIFI_CHECK(EXP) m_CheckErr(__FUNCTION__, EXP);
-
-
-wifi_ap_h CWifiAp::Handle(void)
-{
- return m_handle;
-}
-
-
-bool CWifiAp::AllocConnectedAp(void)
-{
- ASSERT(m_handle == NULL);
-
- WIFI_CHECK_RET(wifi_get_connected_ap(&m_handle));
-}
-
-
-void CWifiAp::Destroy(void)
-{
- if (m_handle == NULL)
- return;
-
- WIFI_CHECK(wifi_ap_destroy(m_handle));
- m_handle = NULL;
-}
-
-
-bool CWifiAp::GetEssid(char *essid, int size)
-{
- ASSERT(m_handle);
-
- char *str = NULL;
- int ret = wifi_ap_get_essid(m_handle, &str);
- if (ret == WIFI_ERROR_NONE) {
- strncpy(essid, str, size);
- _DBG("str : %s , ESSID : %s", str, essid);
- free(str);
- }
- else {
- _ERR("Fail to get ESSID");
- }
-
- return ret == WIFI_ERROR_NONE ? true : false;
-}
-
-
-bool CWifiAp::GetConnectionState(wifi_connection_state_e *state)
-{
- ASSERT(m_handle);
-
- WIFI_CHECK_RET(wifi_ap_get_connection_state(m_handle, state));
-}
-
-
-bool CWifiAp::GetSecurityType(wifi_security_type_e *type)
-{
- ASSERT(m_handle);
-
- WIFI_CHECK_RET(wifi_ap_get_security_type(m_handle, type));
-}
-
-
-bool CWifiAp::SetPassPhrase(const char *passcode)
-{
- ASSERT(m_handle);
- ASSERT(passcode);
-
- WIFI_CHECK_RET(wifi_ap_set_passphrase(m_handle, passcode));
-}
-
-
-bool CWifiAp::Connect(void(*wifi_connected_cb)(wifi_error_e err, void *data), void *data)
-{
- ASSERT(m_handle);
- ASSERT(wifi_connected_cb);
-
- WIFI_CHECK_RET(wifi_connect(m_handle, wifi_connected_cb, data));
-}
-
-
-bool CWifiAp::SetIpType(wifi_ip_config_type_e type)
-{
- ASSERT(m_handle);
-
- WIFI_CHECK_RET(wifi_ap_set_ip_config_type(m_handle, WIFI_ADDRESS_FAMILY_IPV4, type));
-}
-
-
-bool CWifiAp::GetIp(char *ip, int size)
-{
- ASSERT(m_handle);
-
- char *str_value = NULL;
- int ret = wifi_ap_get_ip_address(m_handle, WIFI_ADDRESS_FAMILY_IPV4, &str_value);
- if (ret == WIFI_ERROR_NONE) {
- strncpy(ip, str_value, IP_STRING_MAX_SIZE < size);
- free(str_value);
- }
- else {
- strncpy(ip, ZERO_IP, IP_STRING_MAX_SIZE);
- _ERR("Fail to get Gateway");
- }
- return ret == WIFI_ERROR_NONE ? true : false;
-}
-
-
-bool CWifiAp::GetSubnetMask(char *submask)
-{
- ASSERT(m_handle);
-
- char *str_value = NULL;
- int ret = wifi_ap_get_subnet_mask(m_handle, WIFI_ADDRESS_FAMILY_IPV4, &str_value);
- if (ret == WIFI_ERROR_NONE) {
- strncpy(submask, str_value, IP_STRING_MAX_SIZE);
- free(str_value);
- }
- else {
- strncpy(submask, ZERO_IP, IP_STRING_MAX_SIZE);
- _ERR("Fail to get Gateway");
- }
- return ret == WIFI_ERROR_NONE ? true : false;
-}
-
-
-bool CWifiAp::GetGateway(char *gateway)
-{
- ASSERT(m_handle);
-
- char *str_value;
-
- str_value = NULL;
- if (wifi_ap_get_gateway_address(m_handle, WIFI_ADDRESS_FAMILY_IPV4, &str_value) == WIFI_ERROR_NONE) {
- strncpy(gateway, str_value, IP_STRING_MAX_SIZE);
- free(str_value);
- return true;
- }
- else {
- strncpy(gateway, ZERO_IP, IP_STRING_MAX_SIZE);
- _ERR("Fail to get Gateway");
- return false;
- }
-}
-
-
-bool CWifiAp::GetDNS(char *dns)
-{
- ASSERT(m_handle);
-
- char *str_value;
-
- str_value = NULL;
- if (wifi_ap_get_dns_address(m_handle, 1, WIFI_ADDRESS_FAMILY_IPV4, &str_value) == WIFI_ERROR_NONE) {
- strncpy(dns, str_value, IP_STRING_MAX_SIZE);
- free(str_value);
- return true;
- }
- else {
- strncpy(dns, ZERO_IP, IP_STRING_MAX_SIZE);
- _ERR("Fail to get DNS1");
- return false;
- }
-}
-
-
-bool CWifiAp::SetIp(char *ip)
-{
- ASSERT(m_handle);
-
- WIFI_CHECK_RET(wifi_ap_set_ip_address(m_handle, WIFI_ADDRESS_FAMILY_IPV4, ip));
-}
-
-
-bool CWifiAp::SetSubnetMask(char *submask)
-{
- ASSERT(m_handle);
-
- WIFI_CHECK_RET(wifi_ap_set_subnet_mask(m_handle, WIFI_ADDRESS_FAMILY_IPV4, submask));
-}
-
-
-bool CWifiAp::SetGateway(char *gateway)
-{
- ASSERT(m_handle);
-
- WIFI_CHECK_RET(wifi_ap_set_gateway_address(m_handle, WIFI_ADDRESS_FAMILY_IPV4, gateway));
-}
-
-
-bool CWifiAp::SetDNS(char *dns)
-{
- ASSERT(m_handle);
-
- WIFI_CHECK_RET(wifi_ap_set_dns_address(m_handle, 1, WIFI_ADDRESS_FAMILY_IPV4, dns));
-}
-
-
-bool CWifiAp::CloneAP(wifi_ap_h *cloned_ap, wifi_ap_h origin)
-{
- int ret;
-
- if (!cloned_ap || !origin) {
- _ERR("the param is invalid.");
- return false;
- }
-
- ret = wifi_ap_clone(cloned_ap, origin);
- if (ret != WIFI_ERROR_NONE) {
- _ERR("Fail to wifi_ap_clone %s", CWifiMgr::ErrorMsg((wifi_error_e)ret));
- return false;
- }
-
- return true;
-}
-
-
-bool CWifiAp::ForgetAP(void)
-{
- int ret;
- wifi_ap_h handle;
- char *name;
-
- ret = wifi_get_connected_ap(&handle);
- if (ret == WIFI_ERROR_NO_CONNECTION) {
- return true;
- }
- else if (ret != WIFI_ERROR_NONE) {
- _ERR("Fail to get connected AP [%s]", CWifiMgr::ErrorMsg((wifi_error_e)ret));
- return false;
- }
-
- ret = wifi_ap_get_essid(handle, &name);
- if (ret != WIFI_ERROR_NONE) {
- _ERR("Fail to wifi_ap_get_essid AP [%s]", CWifiMgr::ErrorMsg((wifi_error_e)ret));
- wifi_ap_destroy(handle);
- return false;
- }
-
- ret = wifi_forget_ap(handle);
- if (ret != WIFI_ERROR_NONE) {
- _ERR("Fail to forget [%s],[%s].", name, CWifiMgr::ErrorMsg((wifi_error_e)ret));
- }
-
- wifi_ap_destroy(handle);
- free(name);
-
- return ret == WIFI_ERROR_NONE ? true : false;
-}
-
-
-bool CWifiAp::SetProxyType(EProxyMethod pm)
-{
- ASSERT(m_handle);
-
- wifi_proxy_type_e type;
-
- switch (pm) {
- case PROXY_METHOD_NONE:
- type = WIFI_PROXY_TYPE_DIRECT;
- break;
-
- case PROXY_METHOD_MANUAL:
- type = WIFI_PROXY_TYPE_MANUAL;
- break;
-
- case PROXY_METHOD_AUTO:
- type = WIFI_PROXY_TYPE_AUTO;
- break;
-
- default:
- return false;
- }
-
- int ret = wifi_ap_set_proxy_type(m_handle, type);
- return ret = WIFI_ERROR_NONE ? true : false;
-}
-
-
-bool CWifiAp::GetProxyType(EProxyMethod *pm)
-{
- ASSERT(m_handle);
-
- wifi_proxy_type_e type;
-
- int ret = wifi_ap_get_proxy_type(m_handle, &type);
- if (ret != WIFI_ERROR_NONE) {
- _ERR("wifi_ap_get_proxy_type() failed.");
- return false;
- }
-
- switch (type) {
- case WIFI_PROXY_TYPE_DIRECT:
- *pm = PROXY_METHOD_NONE;
- break;
-
- case WIFI_PROXY_TYPE_MANUAL:
- *pm = PROXY_METHOD_MANUAL;
- break;
-
- case WIFI_PROXY_TYPE_AUTO:
- *pm = PROXY_METHOD_AUTO;
- break;
-
- default:
- return false;
- }
-
- return ret;
-}
-
-
-bool CWifiAp::SetProxyAddr(const char *addr)
-{
- ASSERT(m_handle);
-
- WIFI_CHECK_RET(wifi_ap_set_proxy_address(m_handle, WIFI_ADDRESS_FAMILY_IPV4, addr));
-}
-
-
-bool CWifiAp::GetProxyAddr(char **addr)
-{
- ASSERT(m_handle);
- ASSERT(addr);
-
- WIFI_CHECK_RET(wifi_ap_get_proxy_address(m_handle, WIFI_ADDRESS_FAMILY_IPV4, addr));
-}
-
-
-CWifiMgr *CWifiMgr::instance = NULL;
-
-
-struct SWifiMgr {
- int a;
-};
-
-
-bool CWifiMgr::Initialize(void)
-{
- ASSERT(!instance);
-
- _CREATE_BEGIN{
- _CHECK(instance = new CWifiMgr);
- _CHECK(instance->m = new SWifiMgr);
- _CHECK(wifi_initialize() == WIFI_ERROR_NONE);
-
- _CHECK_FAIL{ wifi_deinitialize(); }
- _CHECK_FAIL{ delete instance->m; }
- _CHECK_FAIL{ delete instance; instance = NULL; }
- } _CREATE_END_AND_CATCH { return false; }
-
- return true;
-}
-
-
-void CWifiMgr::Finalize(void)
-{
- ASSERT(instance);
- ASSERT(instance->m);
-
- wifi_deinitialize();
-
- delete instance->m;
- delete instance;
- instance = NULL;
-}
-
-
-CWifiMgr *CWifiMgr::GetInstance(void)
-{
- return instance;
-}
-
-
-bool CWifiMgr::Activate(void (*cbActivated)(wifi_error_e err, void *data), void *data)
-{
- ASSERT(cbActivated);
-
- int ret = wifi_activate(cbActivated, data);
- if (ret != WIFI_ERROR_NONE) {
- _ERR("Fail to wifi_activate %s", CWifiMgr::ErrorMsg((wifi_error_e) ret));
- return false;
- }
-
- return true;
-}
-
-
-bool CWifiMgr::IsActivated(bool *activated)
-{
- int ret;
-
- ret = wifi_is_activated(activated);
- if (ret != WIFI_ERROR_NONE) {
- _ERR("Fail to wifi_is_activated %s",CWifiMgr::ErrorMsg((wifi_error_e) ret));
- return false;
- }
-
- return true;
-}
-
-
-bool CWifiMgr::Scan(void(*cbFinish)(wifi_error_e err, void* data), void *data)
-{
- ASSERT(cbFinish);
-
- int ret = wifi_scan(cbFinish, data);
- if (ret != WIFI_ERROR_NONE) {
- _ERR("Scan request failed [%s]", CWifiMgr::ErrorMsg((wifi_error_e) ret));
- return false;
- }
-
- return true;
-}
-
-
-struct SUserData
-{
- bool(*cb)(CWifiAp *ap, void *data);
- void *data;
- SUserData(bool(*c)(CWifiAp *ap, void *data), void *d) {
- cb = c;
- data = data;
- }
-};
-
-
-static bool g_CbFound(wifi_ap_h ap, void *data)
-{
- SUserData *ud = (SUserData*)data;
- CWifiAp ins(ap);
- ud->cb(&ins, ud->data);
- delete ud;
-
- return false;
-}
-
-
-bool CWifiMgr::FoundAps(bool(*cbFound)(CWifiAp *ap, void *data), void *data)
-{
- ASSERT(cbFound);
-
- SUserData *ud = new SUserData(cbFound, data);
- int ret = wifi_foreach_found_aps(g_CbFound, ud);
- if (ret != WIFI_ERROR_NONE) {
- _ERR("Fail to get AP list %s.", CWifiMgr::ErrorMsg((wifi_error_e) ret));
- return false;
- }
-
- return true;
-}
-
-
-const char * CWifiMgr::ErrorMsg(wifi_error_e err_type)
-{
- switch (err_type) {
- case WIFI_ERROR_NONE:
- return "NONE";
- case WIFI_ERROR_INVALID_PARAMETER:
- return "INVALID_PARAMETER";
- case WIFI_ERROR_OUT_OF_MEMORY:
- return "OUT_OF_MEMORY";
- case WIFI_ERROR_INVALID_OPERATION:
- return "INVALID_OPERATION";
- case WIFI_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
- return "ADDRESS_FAMILY_NOT_SUPPORTED";
- case WIFI_ERROR_OPERATION_FAILED:
- return "OPERATION_FAILED";
- case WIFI_ERROR_NO_CONNECTION:
- return "NO_CONNECTION";
- case WIFI_ERROR_NOW_IN_PROGRESS:
- return "NOW_IN_PROGRESS";
- case WIFI_ERROR_ALREADY_EXISTS:
- return "ALREADY_EXISTS";
- case WIFI_ERROR_OPERATION_ABORTED:
- return "OPERATION_ABORTED";
- case WIFI_ERROR_DHCP_FAILED:
- return "DHCP_FAILED";
- case WIFI_ERROR_INVALID_KEY:
- return "INVALID_KEY";
- case WIFI_ERROR_NO_REPLY:
- return "NO_REPLY";
- case WIFI_ERROR_SECURITY_RESTRICTED:
- return "SECURITY_RESTRICTED";
- default:
- break;
- }
-
- return "UNKNOWN";
-}
diff --git a/ug/system/clock/CMakeLists.txt b/ug/system/clock/CMakeLists.txt
index 2347d14..155d397 100644
--- a/ug/system/clock/CMakeLists.txt
+++ b/ug/system/clock/CMakeLists.txt
@@ -21,6 +21,7 @@ SET(UG_CLOCK_EDJ_THEME "ug_clock_theme.edj")
INCLUDE(FindPkgConfig)
pkg_check_modules(UG_CLOCK_PKGS REQUIRED
+ dlog
eina
edje
evas
@@ -29,6 +30,7 @@ pkg_check_modules(UG_CLOCK_PKGS REQUIRED
ui-gadget-1
sysman
)
+ #ecore-x
SET(PKGS_LDFLAGS "${PKGS_LDFLAGS} ${UG_CLOCK_PKGS_LDFLAGS}")
@@ -39,16 +41,14 @@ ENDFOREACH(FLAG)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fvisibility=hidden -Wall")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
SET(SRCS
- src/ug_clock.cpp
- src/util.cpp
- src/ClockMainView.cpp
- src/ClockSublistView.cpp
- src/ClockSpinControlView.cpp
- src/ClockTimeSpinControlView.cpp
+ src/ug_clock.c
+ src/ug_clock_spin_control.c
+ src/ug_clock_sublist.c
+ src/ug_clock_utils.c
+ src/ug_clock_time_spin_control.c
)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../include)
ADD_DEFINITIONS("-DUG_CLOCK_EDJFILE=\"${UG_CLOCK_EDJE_DIR}/${UG_CLOCK_EDJ_FILE}\"")
ADD_DEFINITIONS("-DUG_CLOCK_EDJTHEME=\"${UG_CLOCK_EDJE_DIR}/${UG_CLOCK_EDJ_THEME}\"")
diff --git a/ug/system/clock/edje/images/ico_dropdown_menu_check.png b/ug/system/clock/edje/images/ico_dropdown_menu_check.png
index d32061e..9e7d114 100644
--- a/ug/system/clock/edje/images/ico_dropdown_menu_check.png
+++ b/ug/system/clock/edje/images/ico_dropdown_menu_check.png
Binary files differ
diff --git a/ug/system/clock/edje/images/round_rectangle_4X4.png b/ug/system/clock/edje/images/round_rectangle_4X4.png
index b0c09a8..5a1f51d 100644
--- a/ug/system/clock/edje/images/round_rectangle_4X4.png
+++ b/ug/system/clock/edje/images/round_rectangle_4X4.png
Binary files differ
diff --git a/ug/system/clock/edje/images/second_depth_bg.png b/ug/system/clock/edje/images/second_depth_bg.png
index 602e272..5b3c624 100644
--- a/ug/system/clock/edje/images/second_depth_bg.png
+++ b/ug/system/clock/edje/images/second_depth_bg.png
Binary files differ
diff --git a/ug/system/clock/edje/images/spincontrol_arrow_down.png b/ug/system/clock/edje/images/spincontrol_arrow_down.png
index 6107bf1..a7c0493 100644
--- a/ug/system/clock/edje/images/spincontrol_arrow_down.png
+++ b/ug/system/clock/edje/images/spincontrol_arrow_down.png
Binary files differ
diff --git a/ug/system/clock/edje/images/spincontrol_arrow_up.png b/ug/system/clock/edje/images/spincontrol_arrow_up.png
index b706f8f..9205c67 100644
--- a/ug/system/clock/edje/images/spincontrol_arrow_up.png
+++ b/ug/system/clock/edje/images/spincontrol_arrow_up.png
Binary files differ
diff --git a/ug/system/clock/edje/ug_clock.edc b/ug/system/clock/edje/ug_clock.edc
index 96de190..dd8e5e0 100644
--- a/ug/system/clock/edje/ug_clock.edc
+++ b/ug/system/clock/edje/ug_clock.edc
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "../include/defs.h"
+#include "../include/ug_clock_define.h"
collections {
group {
diff --git a/ug/system/clock/edje/ug_clock_theme.edc b/ug/system/clock/edje/ug_clock_theme.edc
index 9a5cd8b..627e454 100644
--- a/ug/system/clock/edje/ug_clock_theme.edc
+++ b/ug/system/clock/edje/ug_clock_theme.edc
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "../include/defs.h"
+#include "../include/ug_clock_define.h"
collections {
#include "widgets/button.edc"
diff --git a/ug/system/clock/include/ClockMainView.h b/ug/system/clock/include/ClockMainView.h
deleted file mode 100644
index b9eb2f5..0000000
--- a/ug/system/clock/include/ClockMainView.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef __CLOCK_MAIN_VIEW_H__
-#define __CLOCK_MAIN_VIEW_H__
-
-class CClockMainView : public CBaseView, public IMouseClickedListener {
-private :
- struct SClockMainView *m;
-
- bool m_AddCloseBtn(void);
- bool m_AddClockSublist(void);
- void m_RefreshTimeBtnText(Evas_Object *btn, int *time);
- void m_RefreshBtnText(void);
-
-protected :
- virtual void t_OnShow(void);
- virtual void t_OnUpdate(void *data);
- virtual void t_OnHide(void);
-
-public :
- CClockMainView(const char *szViewId) : CBaseView(szViewId), IMouseClickedListener(this), m(0) {}
- virtual ~CClockMainView() {}
-
- virtual bool Create(void *data);
- virtual void Destroy(void);
- virtual Evas_Object* Base(void);
-
- virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev);
- virtual void OnMouseClicked(int id, Evas_Object *obj);
-};
-
-#endif /* __CLOCK_MAIN_VIEW_H__ */
-
diff --git a/ug/system/clock/include/ClockSpinControlView.h b/ug/system/clock/include/ClockSpinControlView.h
deleted file mode 100644
index 10a9eda..0000000
--- a/ug/system/clock/include/ClockSpinControlView.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef __CLOCK_SPINCONTROL_VIEW_H__
-#define __CLOCK_SPINCONTROL_VIEW_H__
-
-class CClockSpinControlView : public CBaseView, public IMouseClickedListener {
-private :
- struct SClockSpinControlView *m;
-
- Evas_Object *m_AddArrowBtn(Evas_Object *obj, int flag);
- bool m_AddDateSpin(void);
- void m_InitDateSpin(void);
-
- void m_UpdateDateValue(Evas_Object *spin, int spin_idx);
- bool m_AddSpin(void);
-
-protected :
- virtual void t_OnShow(void);
- virtual void t_OnUpdate(void *data);
- virtual void t_OnHide(void);
-
-public :
- CClockSpinControlView(const char *szViewId) : CBaseView(szViewId), IMouseClickedListener(this), m(0) {}
- virtual ~CClockSpinControlView() {}
-
- virtual bool Create(void *data);
- virtual void Destroy(void);
- virtual Evas_Object* Base(void);
-
- virtual void OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev);
- virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev);
- virtual void OnMouseClicked(int id, Evas_Object *obj);
-};
-
-#endif /* __CLOCK_SPINCONTROL_VIEW_H__ */
diff --git a/ug/system/clock/include/ClockSublistView.h b/ug/system/clock/include/ClockSublistView.h
deleted file mode 100644
index 90a76c1..0000000
--- a/ug/system/clock/include/ClockSublistView.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef __CLOCK_SUBLIST_VIEW_H__
-#define __CLOCK_SUBLIST_VIEW_H__
-
-class CClockSublistView : public CBaseView, public IMouseClickedListener {
-private :
- struct SClockSublistView *m;
-
- bool m_AddSublist(void);
- bool m_AddSublistBtns(void);
- void m_SetSublistInitValue(void);
-
-protected :
- virtual void t_OnShow(void);
- virtual void t_OnUpdate(void *data);
- virtual void t_OnHide(void);
-
-public :
- CClockSublistView(const char *szViewId) : CBaseView(szViewId), IMouseClickedListener(this), m(0) {}
- virtual ~CClockSublistView() {}
-
- virtual bool Create(void *data);
- virtual void Destroy(void);
- virtual Evas_Object* Base(void);
-
- virtual void OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev);
- virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev);
- virtual void OnMouseClicked(int id, Evas_Object *obj);
-};
-
-#endif /* __CLOCK_SUBLIST_VIEW_H__ */
diff --git a/ug/system/clock/include/ClockTimeSpinControlView.h b/ug/system/clock/include/ClockTimeSpinControlView.h
deleted file mode 100644
index cc8bd4e..0000000
--- a/ug/system/clock/include/ClockTimeSpinControlView.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef __CLOCK_TIME_SPINCONTROL_VIEW_H__
-#define __CLOCK_TIME_SPINCONTROL_VIEW_H__
-
-class CClockTimeSpinControlView : public CBaseView, public IMouseClickedListener {
-private :
- struct SClockTimeSpinControlView *m;
-
- Evas_Object *m_AddArrowBtn(Evas_Object *obj, int flag);
- void m_UpdateTimeValue(Evas_Object *btn, int btn_idx);
- bool m_AddTimeSpinWithAMPM(void);
- bool m_AddTimeSpinWithoutAMPM(void);
- bool m_AddTimeSpinBtns(void);
- bool m_AddTimeSpin(void);
-
-protected :
- virtual void t_OnShow(void);
- virtual void t_OnUpdate(void *data);
- virtual void t_OnHide(void);
-
-public :
- CClockTimeSpinControlView(const char *szViewId) : CBaseView(szViewId), IMouseClickedListener(this), m(0) {}
- virtual ~CClockTimeSpinControlView() {}
-
- virtual bool Create(void *data);
- virtual void Destroy(void);
- virtual Evas_Object* Base(void);
-
- virtual void OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev);
- virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev);
- virtual void OnMouseClicked(int id, Evas_Object *obj);
-};
-
-#endif /* __CLOCK_TIME_TimeSpinControl_VIEW_H__ */
diff --git a/ug/system/clock/include/dbg.h b/ug/system/clock/include/dbg.h
new file mode 100644
index 0000000..a2ff87a
--- /dev/null
+++ b/ug/system/clock/include/dbg.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __DBG_H__
+
+#include <dlog.h>
+
+#ifndef _ERR
+#define _ERR(fmt, args...) LOGE("[%s:%d] "fmt"\n", __func__, __LINE__, ##args)
+#endif
+
+#ifndef _DBG
+#define _DBG(fmt, args...) LOGD("[%s:%d] "fmt"\n", __func__, __LINE__, ##args)
+#endif
+
+#ifndef _INFO
+#define _INFO(fmt, args...) LOGI("[%s:%d] "fmt"\n", __func__, __LINE__, ##args)
+#endif
+
+#endif /* __DBG_H__ */
diff --git a/ug/system/clock/include/ug_clock.h b/ug/system/clock/include/ug_clock.h
index 11d8187..4c4e6b4 100644
--- a/ug/system/clock/include/ug_clock.h
+++ b/ug/system/clock/include/ug_clock.h
@@ -19,14 +19,6 @@
#include <Elementary.h>
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
void view_ug_clock_refresh(Evas_Object *base, unsigned int *date, int *time);
-#if defined (__cplusplus)
-};
-#endif
-
#endif /* __UG_CLOCK_H__ */
diff --git a/ug/system/clock/include/defs.h b/ug/system/clock/include/ug_clock_define.h
index a91193c..6b0527f 100644
--- a/ug/system/clock/include/defs.h
+++ b/ug/system/clock/include/ug_clock_define.h
@@ -22,12 +22,6 @@
#define AM "AM"
#define PM "PM"
-/* view */
-#define CLOCK_MAIN_VIEW "CLOCK_MAIN_VIEW"
-#define CLOCK_SUBLIST_VIEW "CLOCK_SUBLIST_VIEW"
-#define CLOCK_SPINCONTROL_VIEW "CLOCK_SPINCONTROL_VIEW"
-#define CLOCK_TIME_SPINCONTROL_VIEW "CLOCK_TIME_SPINCONTROL_VIEW"
-
/* definitions for ug_clock.edc */
/* UG_CLOCK_GRP */
#define UG_CLOCK_GRP "main"
@@ -87,4 +81,21 @@
#define SIG_SRC_FOC_HIDE_ICON "focus_hide_icon"
#define SIG_NAME_SUBLIST "sublist"
+/* Key defines */
+#define KEY_UP "Up"
+#define KEY_DOWN "Down"
+#define KEY_LEFT "Left"
+#define KEY_RIGHT "Right"
+
+#define KEY_0 "0"
+#define KEY_1 "1"
+#define KEY_2 "2"
+#define KEY_3 "3"
+#define KEY_4 "4"
+#define KEY_5 "5"
+#define KEY_6 "6"
+#define KEY_7 "7"
+#define KEY_8 "8"
+#define KEY_9 "9"
+
#endif /* __UG_CLOCK_DEFINE_H__ */
diff --git a/ug/system/clock/include/ug_clock_spin_control.h b/ug/system/clock/include/ug_clock_spin_control.h
new file mode 100644
index 0000000..e8b7f9c
--- /dev/null
+++ b/ug/system/clock/include/ug_clock_spin_control.h
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+
+#ifndef __UG_CLOCK_SPIN_CONTROL_H__
+#define __UG_CLOCK_SPIN_CONTROL_H__
+
+#include <Elementary.h>
+
+void view_spin_control_create(Evas_Object *win,
+ Evas_Object *ug_base);
+
+#endif /* __UG_CLOCK_SPIN_CONTROL_H__ */
diff --git a/ug/system/clock/include/ug_clock_sublist.h b/ug/system/clock/include/ug_clock_sublist.h
new file mode 100644
index 0000000..a71dea1
--- /dev/null
+++ b/ug/system/clock/include/ug_clock_sublist.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __UG_CLOCK_SUBLIST_H__
+#define __UG_CLOCK_SUBLIST_H__
+
+#include <Elementary.h>
+
+void view_sublist_create(Evas_Object *win, Evas_Object *ug_base);
+
+#endif /* __UG_CLOCK_SUBLIST_H__ */
diff --git a/ug/system/clock/include/ug_clock_time_spin_control.h b/ug/system/clock/include/ug_clock_time_spin_control.h
new file mode 100644
index 0000000..d9f920f
--- /dev/null
+++ b/ug/system/clock/include/ug_clock_time_spin_control.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __UG_CLOCK_TIME_SPIN_CONTROL_H__
+#define __UG_CLOCK_TIME_SPIN_CONTROL_H__
+
+#include <Elementary.h>
+
+void view_time_spin_ctrl_create(Evas_Object *win,
+ Evas_Object *ug_base);
+
+#endif /* __UG_CLOCK_TIME_SPIN_CONTROL_H__ */
diff --git a/ug/system/clock/include/util.h b/ug/system/clock/include/ug_clock_utils.h
index bfd87d5..bfd87d5 100644
--- a/ug/system/clock/include/util.h
+++ b/ug/system/clock/include/ug_clock_utils.h
diff --git a/ug/system/clock/src/ClockMainView.cpp b/ug/system/clock/src/ClockMainView.cpp
deleted file mode 100644
index 91c36d8..0000000
--- a/ug/system/clock/src/ClockMainView.cpp
+++ /dev/null
@@ -1,459 +0,0 @@
-#include <ui-gadget-module.h>
-#include <AppCommon.h>
-#include "defs.h"
-#include "util.h"
-
-#include "ClockMainView.h"
-
-#define CLOCK_SUBLIST_NULL_BTNS 2
-#define UG_CLOCK_DATA_ID "ug_clock_data"
-
-struct SClockMainView {
- ui_gadget_h ug;
-
- Evas_Object *win;
- Evas_Object *base;
- Evas_Object *close_btn;
- Evas_Object *date_btn;
- Evas_Object *switch_btn;
- Evas_Object *time_btn;
- Evas_Object *sublist_box;
- Evas_Object *cur_btn;
-
- unsigned int date[DATE_MAX];
- int mode;
- int time[TIME_MAX];
-
- CViewMgr *pViewMgr;
-};
-
-
-bool CClockMainView::m_AddCloseBtn(void)
-{
- m->close_btn = utils_add_button(m->base);
- if (!m->close_btn) {
- _ERR("elm add button failed.");
- return false;
- }
-
- elm_object_style_set(m->close_btn, BTN_STYLE_CLOSE_BTN);
- elm_object_text_set(m->close_btn, BTN_TEXT_CLOSE);
- elm_object_part_content_set(m->base, SWALLOW_CLOSE_BTN, m->close_btn);
-
- //evas_object_smart_callback_add(m->close_btn, "clicked", _close_btn_clicked_cb, data);
- //evas_object_event_callback_add(m->close_btn, EVAS_CALLBACK_KEY_DOWN, _key_down_on_close_btn_cb, data);
- Connect(m->close_btn, 1, TYPE_CLICKED | TYPE_KEY_DOWN);
-#if 0
- evas_object_event_callback_add(m->close_btn, EVAS_CALLBACK_MOUSE_IN, _close_btn_mouse_in_cb, data);
- evas_object_event_callback_add(m->close_btn, EVAS_CALLBACK_MOUSE_OUT, _close_btn_mouse_out_cb, data);
-#endif
- return true;
-}
-
-
-bool CClockMainView::m_AddClockSublist(void)
-{
- m->sublist_box = utils_add_box(m->base);
- if (!m->sublist_box) {
- _ERR("add clock sublist box failed.");
- return false;
- }
-
- m->date_btn = utils_add_button(m->base);
- if (!m->date_btn) {
- _ERR("add button failed.");
- evas_object_del(m->sublist_box);
- return NULL;
- }
-
- elm_object_style_set(m->date_btn, BTN_STYLE_LIST_BTN);
- elm_object_text_set(m->date_btn, BTN_TEXT_DATE);
-
- elm_box_pack_end(m->sublist_box, m->date_btn);
- elm_object_focus_set(m->date_btn, EINA_TRUE);
- utils_get_date_value(m->date);
-
- char buf[BUF_SIZE];
- snprintf(buf, sizeof(buf), "%02d / %02d / %04d", m->date[DATE_MONTH], m->date[DATE_DAY], m->date[DATE_YEAR]);
- elm_object_part_text_set(m->date_btn, BTN_PART_VALUE, (const char *)buf);
-
- //evas_object_event_callback_add(m->date_btn, EVAS_CALLBACK_KEY_DOWN, _key_down_on_btns_cb, data);
- //evas_object_smart_callback_add(m->date_btn, "clicked", _date_btn_clicked_cb, data);
- Connect(m->date_btn, 2, TYPE_CLICKED | TYPE_KEY_DOWN);
-#if 0
- evas_object_event_callback_add(m->date_btn, EVAS_CALLBACK_MOUSE_IN, _date_btn_mouse_in_cb, NULL);
- evas_object_event_callback_add(m->date_btn, EVAS_CALLBACK_MOUSE_OUT, _date_btn_mouse_out_cb, NULL);
-#endif
-
- m->switch_btn = utils_add_button(m->base);
- if (!m->switch_btn) {
- _ERR("add button failed.");
- evas_object_del(m->date_btn);
- evas_object_del(m->sublist_box);
- return NULL;
- }
-
- elm_object_style_set(m->switch_btn, BTN_STYLE_LIST_BTN);
- elm_object_text_set(m->switch_btn, BTN_TEXT_24HOUR_TIME);
-
- elm_box_pack_end(m->sublist_box, m->switch_btn);
-
- /* Set ON/OFF for switch button. */
- if(utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &m->mode)) {
- _ERR("vconf get value failed.");
- return false;
- }
-
- if (!m->mode)
- elm_object_part_text_set(m->switch_btn, BTN_PART_VALUE, OFF);
- else
- elm_object_part_text_set(m->switch_btn, BTN_PART_VALUE, ON);
-
- //evas_object_event_callback_add(m->switch_btn, EVAS_CALLBACK_KEY_DOWN, _key_down_on_btns_cb, data);
- //evas_object_smart_callback_add(m->switch_btn, "clicked", _switch_btn_clicked_cb, data);
- Connect(m->switch_btn, 3, TYPE_CLICKED | TYPE_KEY_DOWN);
-
-#if 0
- evas_object_event_callback_add(switch_btn, EVAS_CALLBACK_MOUSE_IN, _switch_btn_mouse_in_cb, NULL);
- evas_object_event_callback_add(switch_btn, EVAS_CALLBACK_MOUSE_OUT, _switch_btn_mouse_out_cb, NULL);
-#endif
-
- m->time_btn = utils_add_button(m->base);
- if (!m->time_btn) {
- _ERR("add time button failed.");
- evas_object_del(m->switch_btn);
- evas_object_del(m->date_btn);
- evas_object_del(m->sublist_box);
- return NULL;
- }
-
- elm_object_style_set(m->time_btn, BTN_STYLE_LIST_BTN);
- elm_object_text_set(m->time_btn, BTN_TEXT_TIME);
-
- elm_box_pack_end(m->sublist_box, m->time_btn);
-
- /* Set hour : minute : AM/PM for time button. */
- utils_get_time_value(m->time);
-
- m_RefreshTimeBtnText(m->time_btn, m->time);
-
- //evas_object_event_callback_add(m->time_btn, EVAS_CALLBACK_KEY_DOWN, _key_down_on_btns_cb, data);
- //evas_object_smart_callback_add(m->time_btn, "clicked", _time_btn_clicked_cb, data);
- Connect(m->time_btn, 4, TYPE_CLICKED | TYPE_KEY_DOWN);
-#if 0
- evas_object_event_callback_add(m->time_btn, EVAS_CALLBACK_MOUSE_IN, _time_btn_mouse_in_cb, NULL);
- evas_object_event_callback_add(m->time_btn, EVAS_CALLBACK_MOUSE_OUT, _time_btn_mouse_out_cb, NULL);
-#endif
-
- Evas_Object *null_btn;
- Evas_Object *last_btn;
-
- for (int idx = 0; idx < CLOCK_SUBLIST_NULL_BTNS; idx++) {
- null_btn = utils_add_button(m->base);
- if (!null_btn) {
- _ERR("add null button failed.");
- evas_object_del(m->time_btn);
- evas_object_del(m->switch_btn);
- evas_object_del(m->date_btn);
- evas_object_del(m->sublist_box);
- }
-
- elm_object_style_set(null_btn, BTN_STYLE_LIST_BTN);
- elm_box_pack_end(m->sublist_box, null_btn);
- }
-
- last_btn = utils_add_button(m->base);
- if (!last_btn) {
- _ERR("add last button failed.");
- evas_object_del(m->time_btn);
- evas_object_del(m->switch_btn);
- evas_object_del(m->date_btn);
- evas_object_del(m->sublist_box);
- }
-
- elm_object_style_set(last_btn, BTN_STYE_LAST_BTN);
- elm_object_part_content_set(m->base, SWALLOW_CLOCK_LAST, last_btn);
-
- Evas_Object *dbtn, *sbtn, *tbtn, *cbtn;
-
- dbtn = m->date_btn;
- sbtn = m->switch_btn;
- tbtn = m->time_btn;
- cbtn = m->close_btn;
-
- elm_object_focus_next_object_set(dbtn, dbtn, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(dbtn, dbtn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(dbtn, sbtn, ELM_FOCUS_DOWN);
- /* Maybe it's not necessary to set ELM_FOCUS_RIGHT for date_btn */
- elm_object_focus_next_object_set(dbtn, cbtn, ELM_FOCUS_RIGHT);
-
- elm_object_focus_next_object_set(sbtn, tbtn, ELM_FOCUS_DOWN);
- elm_object_focus_next_object_set(sbtn, dbtn, ELM_FOCUS_UP);
- /* Maybe it's not necessary to set ELM_FOCUS_RIGHT for switch_btn */
- elm_object_focus_next_object_set(sbtn, cbtn, ELM_FOCUS_RIGHT);
-
- elm_object_focus_next_object_set(tbtn, tbtn, ELM_FOCUS_DOWN);
- elm_object_focus_next_object_set(tbtn, sbtn, ELM_FOCUS_UP);
- /* Maybe it's not necessary to set ELM_FOCUS_RIGHT for time_btn */
- elm_object_focus_next_object_set(tbtn, cbtn, ELM_FOCUS_RIGHT);
-
- elm_object_focus_next_object_set(cbtn, cbtn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(cbtn, cbtn, ELM_FOCUS_DOWN);
- elm_object_focus_next_object_set(cbtn, dbtn, ELM_FOCUS_LEFT);
- elm_object_part_content_set(m->base, SWALLOW_CLOCK_LIST, m->sublist_box);
-
- return true;
-}
-
-
-void CClockMainView::m_RefreshTimeBtnText(Evas_Object *btn, int *time)
-{
- int mode;
- char buf[BUF_SIZE];
- int ret;
-
- if (!btn || !time)
- return;
-
- mode = 0;
- ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode);
- if (ret != 0) {
- _ERR("vconf get value failed.");
- return;
- }
-
- if (mode) {
- snprintf(buf, sizeof(buf), "%02d : %02d", time[TIME_HOUR], time[TIME_MINUTE]);
- } else {
- if (time[TIME_HOUR] >= 12) {
- time[TIME_HOUR] -= 12;
- time[TIME_AMPM] = 1;
- } else {
- time[TIME_AMPM] = 0;
- }
-
- snprintf(buf, sizeof(buf), "%02d : %02d : %s", time[TIME_HOUR], time[TIME_MINUTE], time[TIME_AMPM] == 1 ? PM : AM);
- }
-
- elm_object_part_text_set(btn, BTN_PART_VALUE, (const char *)buf);
-}
-
-
-void CClockMainView::m_RefreshBtnText(void)
-{
- int ret, mode;
- char buf[BUF_SIZE];
-
- if (m->date_btn == m->cur_btn) {
- snprintf(buf, sizeof(buf), "%02d / %02d / %04d", m->date[DATE_MONTH], m->date[DATE_DAY], m->date[DATE_YEAR]);
- elm_object_part_text_set(m->cur_btn, BTN_PART_VALUE, (const char *)buf);
- } else if (m->switch_btn == m->cur_btn) {
- ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &m->mode);
- if (ret != 0) {
- _ERR("vconf get value failed.");
- return;
- }
-
- if (m->mode)
- elm_object_part_text_set(m->cur_btn, BTN_PART_VALUE, ON);
- else
- elm_object_part_text_set(m->cur_btn, BTN_PART_VALUE, OFF);
-
- utils_get_time_value(m->time);
-
- ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode);
- if (ret != 0) {
- _ERR("vconf get value failed.");
- return;
- }
-
- if (mode)
- snprintf(buf, sizeof(buf), "%02d : %02d", m->time[TIME_HOUR], m->time[TIME_MINUTE]);
- else
- snprintf(buf, sizeof(buf), "%02d : %02d : %s", m->time[TIME_HOUR], m->time[TIME_MINUTE], m->time[TIME_AMPM] == 1 ? PM : AM);
-
- elm_object_part_text_set(m->time_btn, BTN_PART_VALUE, (const char *)buf);
- } else {
- m_RefreshTimeBtnText(m->cur_btn, m->time);
- }
-}
-
-
-void CClockMainView::t_OnShow(void)
-{
- _DBG();
-
- evas_object_show(m->base);
-
- CBaseView::t_OnShow();
-}
-
-
-void CClockMainView::t_OnUpdate(void *data)
-{
- _DBG();
- unsigned int *date = NULL;
- int *time = NULL;
- int idx = -1;
-
- if(!data) {
- _ERR("Invlid Parameter");
- return ;
- }
-
- date = (unsigned int *) data;
-
- elm_object_focus_set(m->cur_btn, EINA_TRUE);
-
- if (date)
- for (idx = DATE_MONTH; idx < DATE_MAX; idx++)
- m->date[idx] = date[idx];
-
- if (time)
- for (idx = TIME_HOUR; idx < TIME_MAX; idx++)
- m->time[idx] = time[idx];
-
- m_RefreshBtnText();
-
- evas_object_show(m->base);
-}
-
-
-void CClockMainView::t_OnHide(void)
-{
- _DBG();
-
- evas_object_hide(m->base);
-
- CBaseView::t_OnHide();
-}
-
-
-bool CClockMainView::Create(void *data)
-{
- _DBG();
- ASSERT(!m);
-
- ui_gadget_h ug;
- if (!data) {
- _ERR("Invalid argument");
- return false;
- }
- ug = (ui_gadget_h)data;
-
- _CREATE_BEGIN{
- _CHECK(m = new SClockMainView)
- _CHECK(m->win = CViewMgr::GetInstance()->Window())
- _CHECK(m->base = utils_add_layout(m->win))
- _COMMAND{
- elm_layout_file_set(m->base, UG_CLOCK_EDJFILE, UG_CLOCK_GRP);
- elm_object_part_text_set(m->base, TEXT_INTRO, STRINGS_INTRO);
-
- }
- _CHECK(m_AddCloseBtn())
- _CHECK(m_AddClockSublist())
-
- _WHEN_SUCCESS {
-#if 0
- evas_object_data_set(m->base, UG_CLOCK_DATA_ID, data);
-#endif
- m->ug = ug;
- m->pViewMgr = CViewMgr::GetInstance();
- }
-
- _CHECK_FAIL{evas_object_del(m->sublist_box);}
- _CHECK_FAIL{evas_object_del(m->close_btn);}
- _CHECK_FAIL{evas_object_del(m->base);}
- _CHECK_FAIL{/* m->win = CViewMgr::GetInstance()->Window() */}
- _CHECK_FAIL{ delete m; m = NULL; }
- } _CREATE_END_AND_CATCH{ return false; }
-
- return true;
-}
-
-
-void CClockMainView::Destroy(void)
-{
- ASSERT(m);
-
- if(m->sublist_box)
- evas_object_del(m->sublist_box);
-
- if(m->close_btn)
- evas_object_del(m->close_btn);
-
- if(m->base)
- evas_object_del(m->base);
-
- delete m;
- m = NULL;
-}
-
-
-Evas_Object* CClockMainView::Base(void)
-{
- ASSERT(m);
-
- return m->base;
-}
-
-void CClockMainView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
-{
- if (!ev->keyname) {
- _ERR("ev->keyname NULL!");
- return;
- }
-
- switch(id) {
- case 1:
- case 2:
- case 3:
- case 4:
- ug_destroy_me(m->ug);
- break;
- }
-}
-
-
-void CClockMainView::OnMouseClicked(int id, Evas_Object *obj)
-{
- switch(id) {
- case 1:
- ug_destroy_me(m->ug);
- break;
- case 2:
- {
- m->cur_btn = obj;
-#if 0
- view_spin_control_create(m->win, m->base);
-#endif
- m->pViewMgr->PushView(CLOCK_SPINCONTROL_VIEW, NULL);
- elm_object_signal_emit(obj, SIGNAL_NAME_AFTER_CLICK, SIGNAL_SOURCE_BTN);
- }
- break;
- case 3:
- {
- m->cur_btn = obj;
-
-#if 0
- view_sublist_create(data->win, data->base);
-#endif
- m->pViewMgr->PushView(CLOCK_SUBLIST_VIEW, NULL);
-
- elm_object_signal_emit(obj, SIGNAL_NAME_AFTER_CLICK, SIGNAL_SOURCE_BTN);
- }
- break;
- case 4:
- {
- m->cur_btn = obj;
-#if 0
- view_time_spin_ctrl_create(m->win, m->base);
-#endif
- m->pViewMgr->PushView(CLOCK_TIME_SPINCONTROL_VIEW, NULL);
- elm_object_signal_emit(obj, SIGNAL_NAME_AFTER_CLICK, SIGNAL_SOURCE_BTN);
- }
- break;
- default:
- break;
- }
-}
diff --git a/ug/system/clock/src/ClockSpinControlView.cpp b/ug/system/clock/src/ClockSpinControlView.cpp
deleted file mode 100644
index 02d48e7..0000000
--- a/ug/system/clock/src/ClockSpinControlView.cpp
+++ /dev/null
@@ -1,529 +0,0 @@
-#include <ui-gadget-module.h>
-#include <AppCommon.h>
-#include "defs.h"
-#include "util.h"
-
-#include "ClockSpinControlView.h"
-
-#define ARROW_BTN_DATA_ID "arrow_btn_data_id"
-#define DATE_SPIN_DATA_ID "spin_ctrl_data"
-#define YEAR_BTN (2)
-
-#define UP_ARROW (1)
-#define DOWN_ARROW (0)
-
-static const int days[] = {
- 31,
- 28,
- 31,
- 30,
- 31,
- 30,
- 31,
- 31,
- 30,
- 31,
- 30,
- 31
-};
-
-struct SClockSpinControlView {
- ui_gadget_h ug;
-
- Evas_Object *win;
- Evas_Object *base;
-
- unsigned int date[DATE_MAX];
- int entry[DATE_MAX];
-
- Eina_Array *spin_array;
- CViewMgr *pViewMgr;
-};
-
-
-Evas_Object * CClockSpinControlView::m_AddArrowBtn(Evas_Object *obj, int flag)
-{
- Evas_Object *btn;
-
- btn = utils_add_button(m->base);
- if (!btn) {
- _ERR("utils add button failed.");
- return NULL;
- }
-
- elm_object_style_set(btn, BTN_STYLE_ARROW_BTN);
-
- if (flag == UP_ARROW)
- elm_object_part_content_set(obj, UP_ARROW_SWALLOW, btn);
- else
- elm_object_part_content_set(obj, DOWN_ARROW_SWALLOW, btn);
-
- elm_object_focus_allow_set(btn, EINA_FALSE);
-
- evas_object_data_set(btn, ARROW_BTN_DATA_ID, obj);
- evas_object_raise(btn);
- evas_object_repeat_events_set(btn, EINA_FALSE);
-
- return btn;
-}
-
-
-bool CClockSpinControlView::m_AddDateSpin(void)
-{
- Evas_Object *btn, *uparrow, *downarrow;
- char buf[BUF_SIZE];
- int idx;
-
- m->spin_array = eina_array_new(1);
- if (!m->spin_array) {
- _ERR("new eina array failed.");
- return false;
- }
-
- for (idx = DATE_MONTH; idx < DATE_MAX; idx++) {
- btn = utils_add_button(m->base);
- if (!btn) {
- _ERR("add spin control button failed.");
- return false;
- }
-
- elm_object_style_set(btn, BTN_STYLE_SPIN_CTRL_BTN);
- if (idx == YEAR_BTN)
- elm_object_style_set(btn, BTN_STYLE_SPIN_CTRL_YEAR_BTN);
-
- snprintf(buf, sizeof(buf), "spin_ctrl_%d_swallow", idx + 1);
- elm_object_part_content_set(m->base, (const char *)buf, btn);
-
- eina_array_push(m->spin_array, btn);
-
- uparrow = m_AddArrowBtn( btn, UP_ARROW);
- if (!uparrow) {
- _ERR("add up arrow button failed.");
- evas_object_del(btn);
- return false;
- }
- //evas_object_smart_callback_add(btn, "clicked", _arrow_btn_clicked_cb, data);
- Connect(uparrow, 1, TYPE_CLICKED);
-
- downarrow = m_AddArrowBtn( btn, DOWN_ARROW);
- if (!downarrow) {
- _ERR("add down arrow button failed.");
- evas_object_del(btn);
- evas_object_del(uparrow);
- return false;
- }
- Connect(downarrow, 2, TYPE_CLICKED);
- }
-
- elm_object_focus_set((Evas_Object *) eina_array_data_get(m->spin_array, 0), EINA_TRUE);
-
- return true;
-}
-
-
-void CClockSpinControlView::m_InitDateSpin(void)
-{
- Evas_Object *spin;
- char buf[BUF_SIZE];
-
- utils_get_date_value(m->date);
-
- spin = (Evas_Object *) eina_array_data_get(m->spin_array, 0);
- if (!spin) {
- _ERR("month button is null.");
- return;
- }
-
- snprintf(buf, sizeof(buf), "%02d", m->date[DATE_MONTH]);
- elm_object_text_set(spin, buf);
-
- spin = (Evas_Object *) eina_array_data_get(m->spin_array, 1);
- if (!spin) {
- _ERR("month button is null.");
- return;
- }
-
- snprintf(buf, sizeof(buf), "%02d", m->date[DATE_DAY]);
- elm_object_text_set(spin, buf);
-
- spin = (Evas_Object *) eina_array_data_get(m->spin_array, 2);
- if (!spin) {
- _ERR("month button is null.");
- return;
- }
-
- m->date[DATE_YEAR] = m->date[DATE_YEAR] < 2000 ? 2000 : m->date[DATE_YEAR];
- snprintf(buf, sizeof(buf), "%04d", m->date[DATE_YEAR]);
- elm_object_text_set(spin, buf);
-
- int idx;
-
- for (idx = DATE_MONTH; idx < DATE_MAX; idx++) {
- spin = (Evas_Object *) eina_array_data_get(m->spin_array, idx);
- if (!spin) {
- _ERR("there is no button. idx: %d", idx);
- return;
- }
-
- elm_object_focus_next_object_set(spin, spin, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(spin, spin, ELM_FOCUS_DOWN);
-
- if (idx == DATE_MONTH) {
- elm_object_focus_next_object_set(spin, (Evas_Object *) eina_array_data_get(m->spin_array, idx+1), ELM_FOCUS_NEXT);
- elm_object_focus_next_object_set(spin, spin, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(spin, (Evas_Object *) eina_array_data_get(m->spin_array, idx + 1), ELM_FOCUS_RIGHT);
- } else if (idx == DATE_YEAR) {
- elm_object_focus_next_object_set(spin, spin, ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(spin, (Evas_Object *) eina_array_data_get(m->spin_array, idx - 1), ELM_FOCUS_LEFT);
- } else {
- elm_object_focus_next_object_set(spin, (Evas_Object *) eina_array_data_get(m->spin_array, idx + 1), ELM_FOCUS_NEXT);
- elm_object_focus_next_object_set(spin, (Evas_Object *) eina_array_data_get(m->spin_array, idx + 1), ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(spin, (Evas_Object *) eina_array_data_get(m->spin_array, idx - 1), ELM_FOCUS_LEFT);
- }
- }
-}
-
-
-void CClockSpinControlView::m_UpdateDateValue(Evas_Object *spin, int spin_idx)
-{
- char buf[BUF_SIZE];
-
- if (!spin)
- return;
- if (spin_idx < DATE_MONTH || spin_idx >= DATE_MAX)
- return;
-
- if (spin_idx == DATE_MONTH) {
- if (m->date[spin_idx] > 12)
- m->date[spin_idx] = 1;
- if (m->date[spin_idx] <= 0)
- m->date[spin_idx] = 12;
-
- snprintf(buf, sizeof(buf), "%02d", m->date[spin_idx]);
- } else if (spin_idx == DATE_DAY) {
- if ((int)m->date[spin_idx] > days[m->date[DATE_MONTH] - 1])
- m->date[spin_idx] = 1;
- if (m->date[spin_idx] <= 0)
- m->date[spin_idx] = days[m->date[DATE_MONTH] - 1];
-
- snprintf(buf, sizeof(buf), "%02d", m->date[spin_idx]);
- } else {
- if (m->date[spin_idx] > 2037)
- m->date[spin_idx] = 2000;
- if (m->date[spin_idx] < 2000)
- m->date[spin_idx] = 2037;
-
- snprintf(buf, sizeof(buf), "%04d", m->date[spin_idx]);
- }
-
- elm_object_text_set(spin, buf);
-}
-
-
-bool CClockSpinControlView::m_AddSpin(void)
-{
- if(!m_AddDateSpin()) {
- _ERR("add spin control buttons failed.");
- return false;
- }
-
- m_InitDateSpin();
-
- Evas_Object *spin;
-
- for (int idx = DATE_MONTH; idx < DATE_MAX; idx++) {
- spin = (Evas_Object *) eina_array_data_get(m->spin_array, idx);
- if (!spin) {
- _ERR("eina m->spin_array data get failed. spin index: %d", idx);
- return false;
- }
-
- //evas_object_smart_callback_add(spin, CLICKED, _date_spin_clicked_cb, data);
- //evas_object_event_callback_add(spin, EVAS_CALLBACK_KEY_DOWN, _date_spin_keydown_cb, data);
- Connect(spin, 100+idx, TYPE_CLICKED | TYPE_KEY_DOWN | TYPE_KEY_UP);
-#if 0
- evas_object_event_callback_add(spin, EVAS_CALLBACK_MOUSE_IN, _date_spin_mousein_cb, NULL);
- evas_object_event_callback_add(spin, EVAS_CALLBACK_MOUSE_OUT, _date_spin_mouseout_cb, NULL);
-#endif
- }
-
- return true;
-}
-
-
-void CClockSpinControlView::t_OnShow(void)
-{
- _DBG();
-
- evas_object_show(m->base);
-
- CBaseView::t_OnShow();
-}
-
-
-void CClockSpinControlView::t_OnUpdate(void *data)
-{
- _DBG();
-
- evas_object_show(m->base);
-}
-
-
-void CClockSpinControlView::t_OnHide(void)
-{
- _DBG();
-
- evas_object_hide(m->base);
-
- CBaseView::t_OnHide();
-}
-
-
-bool CClockSpinControlView::Create(void *data)
-{
- _DBG();
- ASSERT(!m);
-
- ui_gadget_h ug;
- if (!data) {
- _ERR("Invalid argument");
- return false;
- }
- ug = (ui_gadget_h)data;
-
- _CREATE_BEGIN{
- _CHECK(m = new SClockSpinControlView)
- _CHECK(m->win = CViewMgr::GetInstance()->Window())
- _CHECK(m->base = utils_add_layout(m->win))
- _CHECK(m_AddSpin())
-
- _WHEN_SUCCESS {
- elm_layout_file_set(m->base, UG_CLOCK_EDJFILE, SPIN_CTRL_GRP);
-#if 0
- evas_object_data_set(m->base, DATE_SPIN_DATA_ID, data);
-#endif
- m->ug = ug;
- m->pViewMgr = CViewMgr::GetInstance();
- }
-
- _CHECK_FAIL{if(m->spin_array) eina_array_free(m->spin_array);}
- _CHECK_FAIL{if(m->base) evas_object_del(m->base);}
- _CHECK_FAIL{/* m->win = CViewMgr::GetInstance()->Window() */}
- _CHECK_FAIL{ delete m; m = NULL; }
- } _CREATE_END_AND_CATCH{ return false; }
-
- return true;
-}
-
-
-void CClockSpinControlView::Destroy(void)
-{
- ASSERT(m);
-
- if(m->spin_array)
- eina_array_free(m->spin_array);
-
- if(m->base)
- evas_object_del(m->base);
-
- delete m;
- m = NULL;
-}
-
-
-Evas_Object* CClockSpinControlView::Base(void)
-{
- ASSERT(m);
-
- return m->base;
-}
-
-
-void CClockSpinControlView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev)
-{
- if (!ev->keyname) {
- _ERR("ev->keyname is NULL.");
- return;
- }
-
- switch(id) {
- case 100:
- case 101:
- case 102:
- {
- Evas_Object *spin;
- int idx = -1;
-
- for (int i = DATE_MONTH; i < DATE_MAX; i++) {
- spin = (Evas_Object *) eina_array_data_get(m->spin_array, i);
- if (!spin)
- return;
-
- if (obj == spin) {
- idx = i;
- break;
- }
- }
-
- if (idx == -1) {
- _ERR("can't get the right spin.");
- return;
- }
- if (!strncmp(ev->keyname, KEY_UP, strlen(ev->keyname))) {
- m->date[idx]++;
- m_UpdateDateValue(obj, idx);
- }
- }
- break;
- default:
- break;
- }
-}
-
-
-void CClockSpinControlView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
-{
- if (!ev->keyname) {
- _ERR("ev->keyname is NULL.");
- return;
- }
-
- switch(id) {
- case 100:
- case 101:
- case 102:
- {
- int idx = -1;
- Evas_Object *spin;
- char buf[BUF_SIZE];
-
- for (int i = DATE_MONTH; i < DATE_MAX; i++) {
- spin = (Evas_Object *) eina_array_data_get(m->spin_array, i);
- if (!spin)
- return;
-
- if (obj == spin) {
- idx = i;
- break;
- }
- }
-
- if (idx == -1) {
- _ERR("can't get the right spin.");
- return;
- }
-
- if (!strncmp(ev->keyname, KEY_DOWN, strlen(ev->keyname))) {
- m->date[idx]--;
- m_UpdateDateValue(obj, idx);
- } else if (!strncmp(ev->keyname, KEY_0, strlen(ev->keyname)) ||
- !strncmp(ev->keyname, KEY_1, strlen(ev->keyname)) ||
- !strncmp(ev->keyname, KEY_2, strlen(ev->keyname)) ||
- !strncmp(ev->keyname, KEY_3, strlen(ev->keyname)) ||
- !strncmp(ev->keyname, KEY_4, strlen(ev->keyname)) ||
- !strncmp(ev->keyname, KEY_5, strlen(ev->keyname)) ||
- !strncmp(ev->keyname, KEY_6, strlen(ev->keyname)) ||
- !strncmp(ev->keyname, KEY_7, strlen(ev->keyname)) ||
- !strncmp(ev->keyname, KEY_8, strlen(ev->keyname)) ||
- !strncmp(ev->keyname, KEY_9, strlen(ev->keyname))) {
- if (idx != DATE_YEAR) {
- if (m->entry[idx] == 0) {
- m->entry[idx]++;
- m->date[idx] = atoi(ev->keyname);
- } else {
- m->entry[idx]++;
- m->date[idx] = m->date[idx] * 10 + atoi(ev->keyname);
- m->entry[idx] = 0;
- elm_object_focus_next(obj, ELM_FOCUS_NEXT);
- }
- } else {
- if (m->entry[idx] == 0) {
- m->entry[idx]++;
- m->date[idx] = atoi(ev->keyname);
- snprintf(buf, sizeof(buf), "%04d", m->date[idx]);
- elm_object_text_set(obj, buf);
- return;
- } else if (m->entry[idx] == 3) {
- m->date[idx] = m->date[idx] * 10 + atoi(ev->keyname);
- m->entry[idx] = 0;
- } else {
- m->entry[idx]++;
- m->date[idx] = m->date[idx] * 10 + atoi(ev->keyname);
- snprintf(buf, sizeof(buf), "%04d", m->date[idx]);
- elm_object_text_set(obj, buf);
- return;
- }
- }
- m_UpdateDateValue(obj, idx);
- } else if (!strncmp(ev->keyname, KEY_RIGHT, strlen(ev->keyname)) || !strncmp(ev->keyname, KEY_LEFT, strlen(ev->keyname))) {
- m->entry[idx] = 0;
- } else if (!strncmp(ev->keyname, KEY_BACK, strlen(ev->keyname)) || !strncmp(ev->keyname, KEY_BACK_REMOTE, strlen(ev->keyname))) {
- Destroy();
- }
- }
- break;
- default:
- break;
- }
-}
-
-
-void CClockSpinControlView::OnMouseClicked(int id, Evas_Object *obj)
-{
- switch(id) {
- case 1:
- case 2:
- {
- Evas_Object *cur_btn, *btn, *up_btn;
- int idx;
-
- cur_btn = (Evas_Object *) evas_object_data_get(obj, ARROW_BTN_DATA_ID);
- if (!cur_btn) {
- _ERR("evas object data get failed. ID: %s", ARROW_BTN_DATA_ID);
- return;
- }
-
- up_btn = elm_object_part_content_get(cur_btn, UP_ARROW_SWALLOW);
- if (!up_btn) {
- _ERR("part %s content get failed.", UP_ARROW_SWALLOW);
- return;
- }
-
- idx = 0;
- for (int i = DATE_DAY; i < DATE_MAX; i++) {
- btn = (Evas_Object *) eina_array_data_get(m->spin_array, i);
- if (!btn) {
- _ERR("eina array data get failed. button index: %d", i);
- return;
- }
-
- if (cur_btn == btn) {
- idx = i;
- break;
- }
- }
-
- if (obj == up_btn)
- m->date[idx]++;
- else
- m->date[idx]--;
-
- m_UpdateDateValue(cur_btn, idx);
- }
- break;
- case 100:
- case 101:
- case 102:
- {
- utils_set_date_value(m->date);
-#if 0
- view_ug_clock_refresh(m->ug_base, m->date, NULL);
-#endif
- m->pViewMgr->UpdateView(CLOCK_MAIN_VIEW, m->date);
- Destroy();
- }
- break;
- default:
- break;
- }
-}
diff --git a/ug/system/clock/src/ClockSublistView.cpp b/ug/system/clock/src/ClockSublistView.cpp
deleted file mode 100644
index eb436ae..0000000
--- a/ug/system/clock/src/ClockSublistView.cpp
+++ /dev/null
@@ -1,358 +0,0 @@
-#include <ui-gadget-module.h>
-#include <AppCommon.h>
-#include "defs.h"
-#include "util.h"
-
-#include "ClockSublistView.h"
-
-#define SUBLIST_BTN_NUM 2
-#define SUBLIST_DATA_ID "sublist_data"
-
-#define BOX_HPADDING 0
-#define BOX_VPADDING 2
-
-#define CLICKED "clicked"
-
-struct SClockSublistView {
- ui_gadget_h ug;
-
- Evas_Object *win;
- Evas_Object *base;
- Evas_Object *box;
-
- unsigned int mode;
-
- Eina_Array *array;
- CViewMgr *pViewMgr;
-};
-
-bool CClockSublistView::m_AddSublist(void)
-{
- m->box = utils_add_box(m->base);
- if (!m->box) {
- _ERR("add sublist m->box failed.");
- return false;
- }
-
- if(!m_AddSublistBtns()) {
- _ERR("add sublist buttons failed.");
- evas_object_del(m->box);
- m->box = NULL;
- return false;
- }
-
- m_SetSublistInitValue();
-
- return true;
-}
-
-
-bool CClockSublistView::m_AddSublistBtns(void)
-{
- Evas_Object *btn;
-
- elm_box_padding_set(m->box, BOX_HPADDING, BOX_VPADDING);
-
- m->array = eina_array_new(1);
- if (!m->array) {
- _ERR("new array for sublist buttons failed.");
- return false;
- }
-
- for (int idx = 0; idx < SUBLIST_BTN_NUM; idx++) {
- btn = utils_add_button(m->base);
- if (!btn) {
- _ERR("add button failed.");
- eina_array_free(m->array);
- return false;
- }
-
- //evas_object_smart_callback_add(btn, CLICKED, _sublist_btn_clicked_cb, data);
- //evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, _key_down_on_sublist_btn_cb, data);
- Connect(btn, 100+idx, TYPE_CLICKED | TYPE_KEY_DOWN | TYPE_KEY_UP);
-#if 0
- evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, _sublist_btn_mouse_in_cb, NULL);
- evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_OUT, _sublist_btn_mouse_out_cb, NULL);
-#endif
-
- elm_object_style_set(btn, BTN_STYLE_SUBLIST_BTN);
-
- elm_box_pack_end(m->box, btn);
- eina_array_push(m->array, btn);
- }
-
- elm_object_part_content_set(m->base, SWALLOW_SUBLIST, m->box);
-
- return true;
-}
-
-
-void CClockSublistView::m_SetSublistInitValue(void)
-{
- Evas_Object *on_btn, *off_btn;
- int mode = 0;
- int ret;
-
- ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode);
- if (ret != 0) {
- _ERR("vconf get value failed.");
- return;
- }
-
- on_btn = (Evas_Object *) eina_array_data_get(m->array, 0);
- off_btn = (Evas_Object *) eina_array_data_get(m->array, 1);
- if (!on_btn || !off_btn) {
- _ERR("there is no button in sublist array.");
- return;
- }
-
- elm_object_focus_set(on_btn, EINA_TRUE);
-
- elm_object_text_set(on_btn, ON);
- elm_object_text_set(off_btn, OFF);
-
- if (mode) {
- elm_object_signal_emit(on_btn, SIG_SRC_FOC_SHOW_ICON, SIG_NAME_SUBLIST);
- elm_object_signal_emit(off_btn, SIG_SRC_UNFOC_HIDE_ICON, SIG_NAME_SUBLIST);
- } else {
- elm_object_signal_emit(off_btn, SIG_SRC_UNFOC_SHOW_ICON, SIG_NAME_SUBLIST);
- elm_object_signal_emit(on_btn, SIG_SRC_FOC_HIDE_ICON, SIG_NAME_SUBLIST);
- }
-
- elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(on_btn, off_btn, ELM_FOCUS_DOWN);
- elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_RIGHT);
-
- elm_object_focus_next_object_set(off_btn, on_btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(off_btn, off_btn, ELM_FOCUS_DOWN);
- elm_object_focus_next_object_set(off_btn, off_btn, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(off_btn, off_btn, ELM_FOCUS_RIGHT);
-}
-
-
-void CClockSublistView::t_OnShow(void)
-{
- _DBG();
-
- evas_object_show(m->base);
-
- CBaseView::t_OnShow();
-}
-
-
-void CClockSublistView::t_OnUpdate(void *data)
-{
- _DBG();
-
- evas_object_show(m->base);
-}
-
-
-void CClockSublistView::t_OnHide(void)
-{
- _DBG();
-
- evas_object_hide(m->base);
-
- CBaseView::t_OnHide();
-}
-
-
-bool CClockSublistView::Create(void *data)
-{
- _DBG();
- ASSERT(!m);
-
- ui_gadget_h ug;
- if (!data) {
- _ERR("Invalid argument");
- return false;
- }
- ug = (ui_gadget_h)data;
-
- _CREATE_BEGIN{
- _CHECK(m = new SClockSublistView)
- _CHECK(m->win = CViewMgr::GetInstance()->Window())
- _CHECK(m->base = utils_add_layout(m->win))
- _CHECK(m_AddSublist())
- _COMMAND{
- elm_layout_file_set(m->base, UG_CLOCK_EDJFILE, SUBLIST_GRP);
- }
-
- _WHEN_SUCCESS {
-#if 0
- evas_object_data_set(m->base, SUBLIST_DATA_ID, data);
-#endif
- m->ug = ug;
- m->pViewMgr = CViewMgr::GetInstance();
- }
-
- _CHECK_FAIL{if(m->array) eina_array_free(m->array); if(m->box) evas_object_del(m->box);}
- _CHECK_FAIL{evas_object_del(m->base);}
- _CHECK_FAIL{/* m->win = CViewMgr::GetInstance()->Window() */}
- _CHECK_FAIL{ delete m; m = NULL; }
- } _CREATE_END_AND_CATCH{ return false; }
-
- return true;
-}
-
-
-void CClockSublistView::Destroy(void)
-{
- ASSERT(m);
-
- if(m->array)
- eina_array_free(m->array);
-
- if(m->box)
- evas_object_del(m->box);
-
- if(m->base)
- evas_object_del(m->base);
-
- delete m;
- m = NULL;
-}
-
-
-Evas_Object* CClockSublistView::Base(void)
-{
- ASSERT(m);
-
- return m->base;
-}
-
-
-void CClockSublistView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev)
-{
- if (!ev->keyname) {
- _ERR("ev->keyname is NULL.");
- return;
- }
-
- switch(id) {
- case 100:
- case 101:
- {
- Evas_Object *on_btn = NULL;
- int mode, ret = -1;
- on_btn = (Evas_Object *) eina_array_data_get(m->array, 0);
-
- ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode);
- if (ret != 0) {
- _ERR("vconf get value failed.");
- return;
- }
-
- if (!strncmp(ev->keyname, KEY_UP, strlen(ev->keyname))) {
-
- if (obj == on_btn)
- return;
-
- elm_object_focus_set(on_btn, EINA_TRUE);
-
- if (mode) {
- elm_object_signal_emit(on_btn, SIG_SRC_FOC_SHOW_ICON, SIG_NAME_SUBLIST);
- elm_object_signal_emit(obj, SIG_SRC_UNFOC_HIDE_ICON, SIG_NAME_SUBLIST);
- } else {
- elm_object_signal_emit(obj, SIG_SRC_UNFOC_SHOW_ICON, SIG_NAME_SUBLIST);
- elm_object_signal_emit(on_btn, SIG_SRC_FOC_HIDE_ICON, SIG_NAME_SUBLIST);
- }
- }
- }
- break;
- }
-}
-
-
-void CClockSublistView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
-{
- if (!ev->keyname) {
- _ERR("ev->keyname is NULL.");
- return;
- }
-
- switch(id) {
- case 100:
- case 101:
- {
- Evas_Object *on_btn, *off_btn;
- Eina_Array *array = NULL;
- int mode;
- int ret;
-
- on_btn = (Evas_Object *) eina_array_data_get(array, 0);
- off_btn = (Evas_Object *) eina_array_data_get(array, 1);
- if (!on_btn || !off_btn) {
- _ERR("ON button or OFF button is null.");
- return;
- }
-
- ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode);
- if (ret != 0) {
- _ERR("vconf get value failed.");
- return;
- }
-
- if (!strcmp(ev->keyname, KEY_DOWN)) {
- if (obj != on_btn)
- return;
-
- elm_object_focus_set(off_btn, EINA_TRUE);
-
- if (mode) {
- elm_object_signal_emit(obj, SIG_SRC_UNFOC_SHOW_ICON, SIG_NAME_SUBLIST);
- elm_object_signal_emit(off_btn, SIG_SRC_FOC_HIDE_ICON, SIG_NAME_SUBLIST);
- } else {
- elm_object_signal_emit(obj, SIG_SRC_UNFOC_HIDE_ICON, SIG_NAME_SUBLIST);
- elm_object_signal_emit(off_btn, SIG_SRC_FOC_SHOW_ICON, SIG_NAME_SUBLIST);
- }
- } else if (!strncmp(ev->keyname, KEY_BACK, strlen(ev->keyname)) || !strncmp(ev->keyname, KEY_BACK_REMOTE, strlen(ev->keyname))) {
- Destroy();
- }
- }
- break;
- }
-}
-
-
-void CClockSublistView::OnMouseClicked(int id, Evas_Object *obj)
-{
- switch(id) {
- case 100:
- case 101:
- {
- Evas_Object *on_btn, *off_btn;
- int ret;
-
- if (!m->array)
- return;
-
- on_btn = (Evas_Object *) eina_array_data_get(m->array, 0);
- off_btn = (Evas_Object *) eina_array_data_get(m->array, 1);
- if (!on_btn || !off_btn) {
- _ERR("ON button or OFF button is null.");
- return;
- }
-
- if (obj == on_btn)
- ret = utils_set_vconf_value(VCONF_KEY_24HOUR_MODE, 1);
- else
- ret = utils_set_vconf_value(VCONF_KEY_24HOUR_MODE, 0);
-
- if (ret != 0) {
- _ERR("set 24hour mode failed.");
- return;
- }
-
-#if 0
- view_ug_clock_refresh(data->ug_base, NULL, NULL);
-#endif
- m->pViewMgr->UpdateView(CLOCK_MAIN_VIEW, NULL);
-
- Destroy();
- }
- break;
- }
-}
diff --git a/ug/system/clock/src/ClockTimeSpinControlView.cpp b/ug/system/clock/src/ClockTimeSpinControlView.cpp
deleted file mode 100644
index 8f193c3..0000000
--- a/ug/system/clock/src/ClockTimeSpinControlView.cpp
+++ /dev/null
@@ -1,624 +0,0 @@
-#include <ui-gadget-module.h>
-#include <AppCommon.h>
-#include "defs.h"
-#include "util.h"
-
-#include "ClockTimeSpinControlView.h"
-
-#define ARROW_BTN_DATA_ID "arrow_btn_data_id"
-#define TIME_SPIN_DATA_ID "time_spin_ctrl_data"
-
-#define BOX_HPADDING 2
-#define BOX_VPADDING 122
-
-#define UP_ARROW (1)
-#define DOWN_ARROW (0)
-
-struct SClockTimeSpinControlView {
- ui_gadget_h ug;
-
- Evas_Object *win;
- Evas_Object *base;
- Evas_Object *ug_base;
- Evas_Object *spin_box;
-
- int time[TIME_MAX];
- int entry[TIME_MAX];
-
- Eina_Array *spin_array;
-
- CViewMgr *pViewMgr;
-};
-
-
-Evas_Object * CClockTimeSpinControlView::m_AddArrowBtn(Evas_Object *obj, int flag)
-{
- Evas_Object *btn;
-
- btn = utils_add_button(m->base);
- if (!btn) {
- _ERR("utils add button failed.");
- return NULL;
- }
-
- elm_object_style_set(btn, BTN_STYLE_ARROW_BTN);
-
- if (flag == UP_ARROW)
- elm_object_part_content_set(obj, UP_ARROW_SWALLOW, btn);
- else
- elm_object_part_content_set(obj, DOWN_ARROW_SWALLOW, btn);
-
- elm_object_focus_allow_set(btn, EINA_FALSE);
-
- evas_object_data_set(btn, ARROW_BTN_DATA_ID, obj);
- evas_object_raise(btn);
- evas_object_repeat_events_set(btn, EINA_FALSE);
-
- return btn;
-}
-
-
-void CClockTimeSpinControlView::m_UpdateTimeValue(Evas_Object *btn, int btn_idx)
-{
- int mode;
- char buf[BUF_SIZE];
- int ret;
-
- if (!btn)
- return;
- if (btn_idx < TIME_HOUR || btn_idx >= TIME_MAX)
- return;
-
- mode = 0;
- ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode);
- if (ret != 0) {
- _ERR("vconf get value failed.");
- return;
- }
-
- if (btn_idx == TIME_HOUR) {
- if (mode) {
- if (m->time[btn_idx] > 23)
- m->time[btn_idx] = 0;
- if (m->time[btn_idx] < 0)
- m->time[btn_idx] = 23;
- } else {
- if (m->time[btn_idx] > 11)
- m->time[btn_idx] = 0;
- if (m->time[btn_idx] < 0)
- m->time[btn_idx] = 11;
- }
-
- snprintf(buf, sizeof(buf), "%02d", m->time[btn_idx]);
- } else if (btn_idx == TIME_MINUTE) {
- if (m->time[btn_idx] > 59)
- m->time[btn_idx] = 0;
- if (m->time[btn_idx] < 0)
- m->time[btn_idx] = 59;
-
- snprintf(buf, sizeof(buf), "%02d", m->time[btn_idx]);
- } else {
- if (m->time[btn_idx])
- snprintf(buf, sizeof(buf), "%s", PM);
- else
- snprintf(buf, sizeof(buf), "%s", AM);
- }
-
- elm_object_text_set(btn, buf);
-}
-
-
-bool CClockTimeSpinControlView::m_AddTimeSpinWithAMPM(void)
-{
- Evas_Object *btn;
- Evas_Object *uparrow, *downarrow;
- char buf[BUF_SIZE];
-
- elm_box_horizontal_set(m->spin_box, EINA_TRUE);
- elm_box_padding_set(m->spin_box, BOX_HPADDING, BOX_VPADDING);
-
- m->spin_array = eina_array_new(1);
- if (!m->spin_array) {
- _ERR("new eina m->spin_array failed.");
- return false;
- }
-
- for (int idx = TIME_HOUR; idx < TIME_AMPM; idx++) {
- btn = utils_add_button(m->base);
- if (!btn) {
- _ERR("add time spin control button failed.");
- return false;
- }
-
- //evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, _time_spin_keydown_cb, data);
- //evas_object_smart_callback_add(btn, "clicked", _time_spin_click_cb, data);
- Connect(btn, 100+idx, TYPE_CLICKED | TYPE_KEY_DOWN);
-#if 0
- evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, _time_spin_mousein_cb, NULL);
- evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_OUT, _time_spin_mouseout_cb, NULL);
-#endif
- elm_object_style_set(btn, BTN_STYLE_TIME_SPIN_BTN);
-
- snprintf(buf, sizeof(buf), "%02d", m->time[idx]);
- elm_object_text_set(btn, buf);
-
- eina_array_push(m->spin_array, btn);
- elm_box_pack_end(m->spin_box, btn);
-
- uparrow = m_AddArrowBtn(btn, UP_ARROW);
- if (!uparrow) {
- _ERR("add up arrow button failed.");
- evas_object_del(btn);
- return false;
- }
-
- downarrow = m_AddArrowBtn(btn, DOWN_ARROW);
- if (!downarrow) {
- _ERR("add down arrow button failed.");
- evas_object_del(btn);
- evas_object_del(uparrow);
- return false;
- }
- }
-
- elm_object_focus_set((Evas_Object *) eina_array_data_get(m->spin_array, TIME_HOUR), EINA_TRUE);
- elm_object_part_content_set(m->base, SWALLOW_TIME_SPIN_2, m->spin_box);
-
- return true;
-}
-
-
-bool CClockTimeSpinControlView::m_AddTimeSpinWithoutAMPM(void)
-{
- Evas_Object *btn;
- Evas_Object *uparrow, *downarrow;
- char buf[BUF_SIZE];
-
- elm_box_horizontal_set(m->spin_box, EINA_TRUE);
- elm_box_padding_set(m->spin_box, BOX_HPADDING, BOX_VPADDING);
-
- m->spin_array = eina_array_new(1);
- if (!m->spin_array) {
- _ERR("new eina m->spin_array failed.");
- return false;
- }
-
- for (int idx = TIME_HOUR; idx < TIME_AMPM; idx++) {
- btn = utils_add_button(m->base);
- if (!btn) {
- _ERR("add time spin control button failed.");
- return false;
- }
-
- //evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, _time_spin_keydown_cb, data);
- //evas_object_smart_callback_add(btn, "clicked", _time_spin_click_cb, data);
- Connect(btn, 100+idx, TYPE_CLICKED | TYPE_KEY_DOWN);
-#if 0
- evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN, _time_spin_mousein_cb, NULL);
- evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_OUT, _time_spin_mouseout_cb, NULL);
-#endif
-
- elm_object_style_set(btn, BTN_STYLE_TIME_SPIN_BTN);
-
- snprintf(buf, sizeof(buf), "%02d", m->time[idx]);
- elm_object_text_set(btn, buf);
-
- eina_array_push(m->spin_array, btn);
-
- elm_box_pack_end(m->spin_box, btn);
-
- uparrow = m_AddArrowBtn(btn, UP_ARROW);
- if (!uparrow) {
- _ERR("add up arrow button failed.");
- evas_object_del(btn);
- return false;
- }
- //evas_object_smart_callback_add(btn, "clicked", _arrow_btn_clicked_cb, data);
- Connect(uparrow, 1, TYPE_CLICKED);
-
- downarrow = m_AddArrowBtn(btn, DOWN_ARROW);
- if (!downarrow) {
- _ERR("add down arrow button failed.");
- evas_object_del(btn);
- evas_object_del(uparrow);
- return false;
- }
- Connect(downarrow, 2, TYPE_CLICKED);
- }
-
- elm_object_focus_set((Evas_Object *) eina_array_data_get(m->spin_array, TIME_HOUR), EINA_TRUE);
-
- elm_object_part_content_set( m->base, SWALLOW_TIME_SPIN_2, m->spin_box);
-
- return true;
-}
-
-
-bool CClockTimeSpinControlView::m_AddTimeSpinBtns(void)
-{
- int mode;
- int ret;
-
- utils_get_time_value(m->time);
-
- mode = 0;
- ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode);
- if (ret != 0) {
- _ERR("vconf get value failed.");
- return false;
- }
-
- if (mode) {
- ret = m_AddTimeSpinWithoutAMPM();
- if (ret != 0) {
- _ERR("add buttons without ampm failed.");
- return false;
- }
- } else {
- ret = m_AddTimeSpinWithAMPM();
- if (ret != 0) {
- _ERR("add buttons with ampm failed.");
- return false;
- }
- }
-
- return true;
-}
-
-
-bool CClockTimeSpinControlView::m_AddTimeSpin(void)
-{
- Evas_Object *btn;
- unsigned int count;
- int idx;
-
- m->spin_box = utils_add_box(m->base);
- if (!m->spin_box) {
- _ERR("add time spin control box failed.");
- return false;
- }
-
- if(!m_AddTimeSpinBtns()) {
- _ERR("add time spin control buttons failed.");
- return false;
- }
-
-
- count = eina_array_count(m->spin_array);
-
- for (idx = TIME_HOUR; idx < (int)count; idx++) {
- btn = (Evas_Object *) eina_array_data_get(m->spin_array, idx);
- if (!btn) {
- _ERR("there is no button. idx: %d", idx);
- return false;
- }
-
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_DOWN);
-
- if (idx == TIME_HOUR) {
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(btn, (Evas_Object *) eina_array_data_get(m->spin_array, idx + 1),
- ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(btn, (Evas_Object *) eina_array_data_get(m->spin_array, idx + 1),
- ELM_FOCUS_NEXT);
- } else if (idx == (int)count - 1) {
- elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(btn, (Evas_Object *) eina_array_data_get(m->spin_array, idx - 1), ELM_FOCUS_LEFT);
- } else {
- elm_object_focus_next_object_set(btn, (Evas_Object *) eina_array_data_get(m->spin_array, idx + 1), ELM_FOCUS_RIGHT);
- elm_object_focus_next_object_set(btn, (Evas_Object *) eina_array_data_get(m->spin_array, idx + 1), ELM_FOCUS_NEXT);
- elm_object_focus_next_object_set(btn, (Evas_Object *) eina_array_data_get(m->spin_array, idx - 1), ELM_FOCUS_LEFT);
- }
- }
- return true;
-}
-
-
-void CClockTimeSpinControlView::t_OnShow(void)
-{
- _DBG();
-
- evas_object_show(m->base);
-
- CBaseView::t_OnShow();
-}
-
-
-void CClockTimeSpinControlView::t_OnUpdate(void *data)
-{
- _DBG();
-
- evas_object_show(m->base);
-}
-
-
-void CClockTimeSpinControlView::t_OnHide(void)
-{
- _DBG();
-
- evas_object_hide(m->base);
-
- CBaseView::t_OnHide();
-}
-
-
-bool CClockTimeSpinControlView::Create(void *data)
-{
- _DBG();
- ASSERT(!m);
-
- bool ret = false;
-
- ui_gadget_h ug;
- if (!data) {
- _ERR("Invalid argument");
- return false;
- }
- ug = (ui_gadget_h)data;
-
- _CREATE_BEGIN{
- _CHECK(m = new SClockTimeSpinControlView)
- _CHECK(m->win = CViewMgr::GetInstance()->Window())
- _CHECK(m->base = utils_add_layout(m->win))
- _COMMAND {
- int onoff = 0;
- ret = true;
- if(utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &onoff) != 0) {
- _ERR("vconf get value failed.");
- ret = false;
- }
-
- if (onoff)
- elm_object_signal_emit(m->base, SIGNAL_NAME_TIME_SPIN_2, SIGNAL_SOURCE_TIME_SPIN);
- else
- elm_object_signal_emit(m->base, SIGNAL_NAME_TIME_SPIN_1, SIGNAL_SOURCE_TIME_SPIN);
-
- }
- _CHECK(ret)
- _CHECK(m_AddTimeSpin())
-
- _WHEN_SUCCESS {
- elm_layout_file_set(m->base, UG_CLOCK_EDJFILE, TIME_SPIN_CTRL_GRP);
-#if 0
- evas_object_data_set(m->base, TIME_SPIN_DATA_ID, data);
-#endif
- m->ug = ug;
- m->pViewMgr = CViewMgr::GetInstance();
- }
-
- _CHECK_FAIL{if(m->spin_array) eina_array_free(m->spin_array); if(m->spin_box) evas_object_del(m->spin_box);}
- _CHECK_FAIL{/* ret */}
- _CHECK_FAIL{if(m->base) evas_object_del(m->base);}
- _CHECK_FAIL{/* m->win = CViewMgr::GetInstance()->Window() */}
- _CHECK_FAIL{ delete m; m = NULL; }
- } _CREATE_END_AND_CATCH{ return false; }
-
- return true;
-}
-
-
-void CClockTimeSpinControlView::Destroy(void)
-{
- ASSERT(m);
-
- if(m->spin_array)
- eina_array_free(m->spin_array);
-
- if(m->spin_box)
- evas_object_del(m->spin_box);
-
- if(m->base)
- evas_object_del(m->base);
-
- delete m;
- m = NULL;
-}
-
-
-Evas_Object* CClockTimeSpinControlView::Base(void)
-{
- ASSERT(m);
-
- return m->base;
-}
-
-
-void CClockTimeSpinControlView::OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev)
-{
- if (!ev->keyname) {
- _ERR("ev->keyname is NULL.");
- return;
- }
-
- switch(id) {
- case 100:
- case 101:
- {
- Evas_Object *hour_btn, *minute_btn;
-
- hour_btn = (Evas_Object *) eina_array_data_get(m->spin_array, TIME_HOUR);
- minute_btn = (Evas_Object *) eina_array_data_get(m->spin_array, TIME_MINUTE);
- if (!hour_btn || !minute_btn) {
- _ERR("eina m->spin_array data get failed.");
- return;
- }
-
- if (!strncmp(ev->keyname, KEY_UP, strlen(ev->keyname))) {
- if (obj == hour_btn) {
- m->time[TIME_HOUR]++;
- m_UpdateTimeValue(obj, TIME_HOUR);
- } else if (obj == minute_btn) {
- m->time[TIME_MINUTE]++;
- m_UpdateTimeValue(obj, TIME_MINUTE);
- } else {
- if (m->time[TIME_AMPM] == 0)
- m->time[TIME_AMPM] = 1;
- else
- m->time[TIME_AMPM] = 0;
- m_UpdateTimeValue(obj, TIME_AMPM);
- }
- }
- }
- break;
- default:
- break;
- }
-}
-
-
-void CClockTimeSpinControlView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
-{
- if (!ev->keyname) {
- _ERR("ev->keyname is NULL.");
- return;
- }
-
- switch(id) {
- case 100:
- case 101:
- {
- Evas_Object *hour_btn, *minute_btn;
-
- hour_btn = (Evas_Object *) eina_array_data_get(m->spin_array, TIME_HOUR);
- minute_btn = (Evas_Object *) eina_array_data_get(m->spin_array, TIME_MINUTE);
- if (!hour_btn || !minute_btn) {
- _ERR("eina m->spin_array data get failed.");
- return;
- }
-
- if (!strncmp(ev->keyname, KEY_DOWN, strlen(ev->keyname))) {
- if (obj == hour_btn) {
- m->time[TIME_HOUR]--;
- m_UpdateTimeValue(obj, TIME_HOUR);
- } else if (obj == minute_btn) {
- m->time[TIME_MINUTE]--;
- m_UpdateTimeValue(obj, TIME_MINUTE);
- } else {
- if (m->time[TIME_AMPM] == 0)
- m->time[TIME_AMPM] = 1;
- else
- m->time[TIME_AMPM] = 0;
- m_UpdateTimeValue(obj, TIME_AMPM);
- }
- } else if (!strncmp(ev->keyname, KEY_0, strlen(ev->keyname)) ||
- !strncmp(ev->keyname, KEY_1, strlen(ev->keyname)) ||
- !strncmp(ev->keyname, KEY_2, strlen(ev->keyname)) ||
- !strncmp(ev->keyname, KEY_3, strlen(ev->keyname)) ||
- !strncmp(ev->keyname, KEY_4, strlen(ev->keyname)) ||
- !strncmp(ev->keyname, KEY_5, strlen(ev->keyname)) ||
- !strncmp(ev->keyname, KEY_6, strlen(ev->keyname)) ||
- !strncmp(ev->keyname, KEY_7, strlen(ev->keyname)) ||
- !strncmp(ev->keyname, KEY_8, strlen(ev->keyname)) ||
- !strncmp(ev->keyname, KEY_9, strlen(ev->keyname))) {
- if (obj == hour_btn) {
- if (m->entry[TIME_HOUR] == 0) {
- m->entry[TIME_HOUR]++;
- m->time[TIME_HOUR] = atoi(ev->keyname);
- } else {
- m->entry[TIME_HOUR]++;
- m->time[TIME_HOUR] =
- (m->time[TIME_HOUR] * 10) + atoi(ev->keyname);
- m->entry[TIME_HOUR] = 0;
-
- elm_object_focus_next(obj, ELM_FOCUS_NEXT);
- }
- m_UpdateTimeValue(obj, TIME_HOUR);
- } else if (obj == minute_btn) {
- if (m->entry[TIME_MINUTE] == 0) {
- m->entry[TIME_MINUTE]++;
- m->time[TIME_MINUTE] = atoi(ev->keyname);
- } else {
- m->entry[TIME_MINUTE]++;
- m->time[TIME_MINUTE] =
- (m->time[TIME_MINUTE] * 10) + atoi(ev->keyname);
- m->entry[TIME_MINUTE] = 0;
-
- elm_object_focus_next(obj, ELM_FOCUS_NEXT);
- }
- m_UpdateTimeValue(obj, TIME_MINUTE);
- } else {
- return;
- }
- } else if (!strncmp(ev->keyname, KEY_LEFT, strlen(ev->keyname)) ||
- !strncmp(ev->keyname, KEY_RIGHT, strlen(ev->keyname))) {
- if (obj == hour_btn)
- m->entry[TIME_HOUR] = 0;
- else if (obj == minute_btn)
- m->entry[TIME_MINUTE] = 0;
- else
- return;
- } else if (!strncmp(ev->keyname, KEY_BACK, strlen(ev->keyname)) || !strncmp(ev->keyname, KEY_BACK_REMOTE, strlen(ev->keyname))) {
- Destroy();
- }
- }
- break;
- default:
- break;
- }
-}
-
-
-void CClockTimeSpinControlView::OnMouseClicked(int id, Evas_Object *obj)
-{
- switch(id) {
- case 1:
- case 2:
- {
- Evas_Object *cur_btn, *btn, *up;
- int flag, idx = -1;
-
- cur_btn = (Evas_Object *) evas_object_data_get(obj, ARROW_BTN_DATA_ID);
- if (!cur_btn)
- return;
-
- up = elm_object_part_content_get(cur_btn, UP_ARROW_SWALLOW);
- if (!up)
- return;
-
- if (obj == up)
- flag = 1;
- else
- flag = 0;
-
- for (int i = TIME_HOUR; i < TIME_MAX; i++) {
- btn = (Evas_Object *) eina_array_data_get(m->spin_array, i);
-
- if (cur_btn == btn) {
- idx = i;
- break;
- }
- }
-
- if (idx != TIME_AMPM) {
- if (flag)
- m->time[idx]++;
- else
- m->time[idx]--;
- } else {
- if (m->time[idx] == 0)
- m->time[idx] = 1;
- else
- m->time[idx] = 0;
- }
-
- m_UpdateTimeValue(cur_btn, idx);
- }
- break;
- case 100:
- case 101:
- {
- utils_set_time_value(m->time);
-
-#if 0 /* FIXME: m->time should be passed */
- view_ug_clock_refresh(m->ug_base, NULL, m->time);
-#else
- m->pViewMgr->UpdateView(CLOCK_MAIN_VIEW, NULL);
-#endif
- Destroy();
- }
- break;
- default:
- break;
- }
-}
diff --git a/ug/system/clock/src/ug_clock.c b/ug/system/clock/src/ug_clock.c
new file mode 100644
index 0000000..53bffdf
--- /dev/null
+++ b/ug/system/clock/src/ug_clock.c
@@ -0,0 +1,1189 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef UG_MODULE_API
+#define UG_MODULE_API __attribute__ ((visibility("default")))
+#endif
+
+#include <ui-gadget-module.h>
+#include <Elementary.h>
+
+#include <KeyDefine.h>
+
+#include "ug_clock_utils.h"
+#include "ug_clock.h"
+#include "ug_clock_define.h"
+#include "dbg.h"
+#include "ug_clock_spin_control.h"
+#include "ug_clock_sublist.h"
+#include "ug_clock_time_spin_control.h"
+
+#define CLOCK_SUBLIST_NULL_BTNS 2
+#define UG_CLOCK_DATA_ID "ug_clock_data"
+
+struct _ug_data {
+ Evas_Object *win;
+ Evas_Object *base;
+ Evas_Object *close_btn;
+ Evas_Object *date_btn;
+ Evas_Object *switch_btn;
+ Evas_Object *time_btn;
+ Evas_Object *sublist_box;
+ Evas_Object *cur_btn;
+
+ unsigned int date[DATE_MAX];
+ int mode;
+ int time[TIME_MAX];
+
+ ui_gadget_h ug;
+};
+
+/**
+* Free allocated memory.
+*
+* This function frees allocated memory when needed.
+*
+* @param[in]: data : the user data of clock ug.
+*
+* @return: void.
+*/
+static void _free_ug_data(struct _ug_data *data)
+{
+ if (!data)
+ return;
+
+ if (data->base) {
+ evas_object_del(data->base);
+ data->base = NULL;
+ }
+
+ free(data);
+}
+
+/**
+* This function will be invoked when the BACK key is pressed.
+* When the BACK key is pressed, this UI gadget will be destroyed.
+*
+* @param[in]: keyname : the name of pressed key.
+* @param[in]: data : the user data of clock ug.
+*
+* @return: void.
+*/
+static void _key_down_cb(const char *keyname, struct _ug_data *data)
+{
+ if (!keyname || !data || !data->ug)
+ return;
+
+ if (!strncmp(keyname, KEY_BACK, strlen(keyname)))
+ ug_destroy_me(data->ug);
+}
+
+/**
+* Callback function for button click event.
+*
+* This function will be invoked when the close button is clicked or
+* the ENTER key is pressed.
+*
+* @param[in]: priv : the user data.
+* @param[in]: obj : the pointer of clicked evas object.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _close_btn_clicked_cb(void *priv, Evas_Object *obj, void *ei)
+{
+ struct _ug_data *data;
+
+ if (!priv) {
+ _ERR("private data is null.");
+ return;
+ }
+
+ data = priv;
+ ug_destroy_me(data->ug);
+}
+
+/**
+* Callback function for key pressed event.
+*
+* This function will be invoked when this the close button is focused
+* and the BACK key is pressed.
+*
+* @param[in]: priv : the user data.
+* @param[in]: e : the evas canvas.
+* @param[in]: obj : the current evas object.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _key_down_on_close_btn_cb(void *priv, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ struct _ug_data *data;
+ Evas_Event_Key_Down *event;
+ const char *keyname;
+
+ if (!priv || !ei) {
+ _ERR("invalid argument.");
+ return;
+ }
+
+ event = ei;
+ keyname = event->keyname;
+
+ if (!keyname)
+ return;
+
+ data = priv;
+
+ _key_down_cb(keyname, data);
+}
+
+/**
+* Callback function for key pressed event.
+*
+* This function will be invoked when BACK key is pressed.
+* When the BACK key is pressed, this UI gadget will be destroyed.
+*
+* @param[in]: priv : the user data.
+* @param[in]: e : the evas canvas.
+* @param[in]: obj : the current evas object.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _key_down_on_btns_cb(void *priv, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ struct _ug_data *data;
+ Evas_Event_Key_Down *event;
+ const char *keyname;
+
+ if (!priv || !ei) {
+ _ERR("invalid argument.");
+ return;
+ }
+
+ event = ei;
+ keyname = event->keyname;
+ if (!keyname)
+ return;
+
+ data = priv;
+
+ _key_down_cb(keyname, data);
+}
+
+/**
+* Mouse in event callback.
+*
+* This function will be invoked when the mouse moves in the region of
+* close button.
+*
+* @param[in]: dt : the user data.
+* @param[in]: e : the evas canvas.
+* @param[in]: obj : the current evas object.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _close_btn_mouse_in_cb(void *dt, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ if (!obj)
+ return;
+
+ elm_object_focus_set(obj, EINA_TRUE);
+}
+
+/**
+* Mouse out event callback.
+*
+* This function will be invoked when the mouse moves out the region of
+* close button.
+*
+* @param[in]: dt The pointer of private data.
+* @param[in]: e The evas canvas.
+* @param[in]: obj The current evas object.
+* @param[in]: ei The event info.
+*
+* @return: void.
+*/
+static void _close_btn_mouse_out_cb(void *dt, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ /* TODO: Add necessary operation when needed. */
+}
+
+/**
+* Add close button.
+*
+* This function adds close button for clock UI gadget.
+*
+* @param[in]: parent : the parent base layout of clock UI gadget.
+* @param[in]: data : the user data.
+*
+* @return: The pointer of created evas object button or NULL.
+*/
+static Evas_Object *_add_close_btn(Evas_Object *parent,
+ struct _ug_data *data)
+{
+ Evas_Object *btn;
+
+ if (!parent || !data) {
+ _ERR("parent of close button is null.");
+ return NULL;
+ }
+
+ btn = utils_add_button(parent);
+ if (!btn) {
+ _ERR("elm add button failed.");
+ return NULL;
+ }
+
+ data->close_btn = btn;
+
+ elm_object_style_set(btn, BTN_STYLE_CLOSE_BTN);
+ elm_object_text_set(btn, BTN_TEXT_CLOSE);
+ elm_object_part_content_set(parent, SWALLOW_CLOSE_BTN, btn);
+
+ evas_object_smart_callback_add(data->close_btn, "clicked",
+ _close_btn_clicked_cb, data);
+ evas_object_event_callback_add(data->close_btn, EVAS_CALLBACK_KEY_DOWN,
+ _key_down_on_close_btn_cb, data);
+ evas_object_event_callback_add(data->close_btn,
+ EVAS_CALLBACK_MOUSE_IN, _close_btn_mouse_in_cb, data);
+ evas_object_event_callback_add(data->close_btn,
+ EVAS_CALLBACK_MOUSE_OUT, _close_btn_mouse_out_cb, data);
+
+ return btn;
+}
+
+/**
+* CLICKED event callback.
+*
+* This is the CLICKED event callback function for 24 Hour mode button.
+* When user clicks the 24 Hour mode button or the ENTER key is pressed
+* on this button, this function will be triggered to show the sub UI of
+* 24 Hour mode button.
+*
+* @param[in]: priv : the user data.
+* @param[in]: obj : the 24 Hour mode button.
+* @param[in]: ei : the event info.
+*
+* @return: void.
+*/
+static void _switch_btn_clicked_cb(void *priv, Evas_Object *obj, void *ei)
+{
+ struct _ug_data *data;
+
+ if (!priv)
+ return;
+
+ data = priv;
+ data->cur_btn = obj;
+
+ view_sublist_create(data->win, data->base);
+
+ elm_object_signal_emit(obj, SIGNAL_NAME_AFTER_CLICK,
+ SIGNAL_SOURCE_BTN);
+}
+
+/**
+* MOUSEIN event callback function.
+*
+* This is the MOUSEIN event callback function for 24 Hour mode
+* button. When the mouse moves in the region of 24 Hour mode
+* button, this function will be called.
+*
+* @param[in]: dt : the user data.
+* @param[in]: e : the evas canvas.
+* @param[in]: obj : the 24 Hour mode button.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _switch_btn_mouse_in_cb(void *dt, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ if (!obj)
+ return;
+
+ elm_object_focus_set(obj, EINA_TRUE);
+}
+
+/**
+* MOUSEOUT event callback function.
+*
+* This is the MOUSEOUT event callback function for 24 Hour mode
+* button. When the mouse moves out of the region of 24 Hour mode
+* button, this function will be called. Till now there is no operation
+* in this function, and you can add operations here as needed.
+*
+* @param[in]: dt : the user data.
+* @param[in]: e : the evas canvas.
+* @param[in]: obj : the 24 Hour mode button.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _switch_btn_mouse_out_cb(void *dt, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ /* TODO: Add necessary operations when needed. */
+}
+
+/**
+* This function creates the 24 Hour mode item button.
+*
+* @param[in]: data : the user data.
+*
+* @return: The created evas object 24 Hour mode button or NULL.
+*/
+static Evas_Object *_add_clock_sublist_switch_btn(
+ struct _ug_data *data)
+{
+ Evas_Object *switch_btn;
+ const char *display;
+ int ret;
+
+ if (!data) {
+ _ERR("data is null.");
+ return NULL;
+ }
+
+ switch_btn = utils_add_button(data->base);
+ if (!switch_btn) {
+ _ERR("add button failed.");
+ return NULL;
+ }
+
+ elm_object_style_set(switch_btn, BTN_STYLE_LIST_BTN);
+ elm_object_text_set(switch_btn, BTN_TEXT_24HOUR_TIME);
+
+ elm_box_pack_end(data->sublist_box, switch_btn);
+
+ /* Set ON/OFF for switch button. */
+ ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &data->mode);
+ if (ret != 0) {
+ _ERR("vconf get value failed.");
+ return NULL;
+ }
+
+ if (!data->mode)
+ display = OFF;
+ else
+ display = ON;
+
+ elm_object_part_text_set(switch_btn, BTN_PART_VALUE, display);
+
+ evas_object_event_callback_add(switch_btn,
+ EVAS_CALLBACK_KEY_DOWN, _key_down_on_btns_cb, data);
+ evas_object_smart_callback_add(switch_btn,
+ "clicked", _switch_btn_clicked_cb, data);
+ evas_object_event_callback_add(switch_btn,
+ EVAS_CALLBACK_MOUSE_IN, _switch_btn_mouse_in_cb, NULL);
+ evas_object_event_callback_add(switch_btn, EVAS_CALLBACK_MOUSE_OUT,
+ _switch_btn_mouse_out_cb, NULL);
+
+ return switch_btn;
+}
+
+/**
+* CLICKED event callback function.
+*
+* This is the clicked event callback function for Date button.
+* When user clicks the Date button or ENTER key is pressed,
+* this function will be called to show sub UI of Date button.
+*
+* @param[in]: priv : the user data.
+* @param[in]: obj : the Date button.
+* @param[in]: ei : the event info.
+*
+* @return: void.
+*/
+static void _date_btn_clicked_cb(void *priv, Evas_Object *obj, void *ei)
+{
+ struct _ug_data *data;
+
+ if (!priv || !obj) {
+ _ERR("invalid argument.");
+ return;
+ }
+
+ data = priv;
+ data->cur_btn = obj;
+
+ view_spin_control_create(data->win, data->base);
+
+ elm_object_signal_emit(obj, SIGNAL_NAME_AFTER_CLICK,
+ SIGNAL_SOURCE_BTN);
+}
+
+/**
+* MOUSEIN event callback function.
+*
+* This is the MOUSEIN event callback function for Date button.
+* When the mouse moves in the region of Date button, this
+* function will be called.
+*
+* @param[in]: dt : the user data.
+* @param[in]: e : the evas canvas.
+* @param[in]: obj : the Date button.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _date_btn_mouse_in_cb(void *dt, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ if (!obj)
+ return;
+
+ elm_object_focus_set(obj, EINA_TRUE);
+}
+
+/**
+* MOUSEOUT event callback function.
+*
+* This is the MOUSEOUT event callback function for Date button.
+* When the mouse moves out of the region of Date button, this
+* function will be called. Till now there is no operation in this
+* function, and you can add operations here as needed.
+*
+* @param[in]: dt : the user data.
+* @param[in]: e : the evas canvas.
+* @param[in]: obj : the Date button.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _date_btn_mouse_out_cb(void *dt, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ /* TODO: Add necessary operations when needed. */
+}
+
+/**
+* This function creates the Date item button.
+*
+* @param[in]: data : the user data.
+*
+* @return: The created evas object Date button or NULL.
+*/
+static Evas_Object *_add_clock_sublist_date_btn(struct _ug_data *data)
+{
+ Evas_Object *date_btn;
+ char buf[BUF_SIZE];
+
+ if (!data) {
+ _ERR("data is null.");
+ return NULL;
+ }
+
+ date_btn = utils_add_button(data->base);
+ if (!date_btn) {
+ _ERR("add button failed.");
+ return NULL;
+ }
+
+ elm_object_style_set(date_btn, BTN_STYLE_LIST_BTN);
+ elm_object_text_set(date_btn, BTN_TEXT_DATE);
+
+ elm_box_pack_end(data->sublist_box, date_btn);
+
+ elm_object_focus_set(date_btn, EINA_TRUE);
+
+ utils_get_date_value(data->date);
+
+ snprintf(buf, sizeof(buf),
+ "%02d / %02d / %04d", data->date[DATE_MONTH],
+ data->date[DATE_DAY], data->date[DATE_YEAR]);
+
+ elm_object_part_text_set(date_btn, BTN_PART_VALUE, (const char *)buf);
+
+ evas_object_event_callback_add(date_btn,
+ EVAS_CALLBACK_KEY_DOWN, _key_down_on_btns_cb, data);
+ evas_object_smart_callback_add(date_btn,
+ "clicked", _date_btn_clicked_cb, data);
+ evas_object_event_callback_add(date_btn,
+ EVAS_CALLBACK_MOUSE_IN, _date_btn_mouse_in_cb, NULL);
+ evas_object_event_callback_add(date_btn,
+ EVAS_CALLBACK_MOUSE_OUT, _date_btn_mouse_out_cb, NULL);
+
+ return date_btn;
+}
+
+/**
+* CLICKED event callback function.
+*
+* This is the clicked event callback function for Time button.
+* When user clicks the Time button or ENTER key is pressed
+* on this button, this function will be called to show sub UI
+* of Time button.
+*
+* @param[in]: priv : the user data.
+* @param[in]: obj : the Time button.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _time_btn_clicked_cb(void *priv, Evas_Object *obj, void *ei)
+{
+ struct _ug_data *data;
+
+ if (!priv)
+ return;
+
+ data = priv;
+ data->cur_btn = obj;
+
+ view_time_spin_ctrl_create(data->win, data->base);
+
+ elm_object_signal_emit(obj, SIGNAL_NAME_AFTER_CLICK,
+ SIGNAL_SOURCE_BTN);
+}
+
+/**
+* Refresh text of Time button.
+*
+* @param[in]: btn : the Time button.
+* @param[in]: time : the refreshed value of time.
+*
+* @return: void.
+*/
+static void _refresh_time_btn_text(Evas_Object *btn, int *time)
+{
+ int mode;
+ char buf[BUF_SIZE];
+ int ret;
+
+ if (!btn || !time)
+ return;
+
+ mode = 0;
+ ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode);
+ if (ret != 0) {
+ _ERR("vconf get value failed.");
+ return;
+ }
+
+ if (mode) {
+ snprintf(buf, sizeof(buf), "%02d : %02d",
+ time[TIME_HOUR], time[TIME_MINUTE]);
+ } else {
+ if (time[TIME_HOUR] >= 12) {
+ time[TIME_HOUR] -= 12;
+ time[TIME_AMPM] = 1;
+ } else {
+ time[TIME_AMPM] = 0;
+ }
+
+ snprintf(buf, sizeof(buf), "%02d : %02d : %s",
+ time[TIME_HOUR], time[TIME_MINUTE],
+ time[TIME_AMPM] == 1 ? PM : AM);
+ }
+
+ elm_object_part_text_set(btn, BTN_PART_VALUE, (const char *)buf);
+}
+
+/**
+* MOUSEIN event callback function.
+*
+* This is the MOUSEIN event callback function for Time button.
+* When the mouse moves in the region of Time button, this
+* function will be called.
+*
+* @param[in]: dt : the user data.
+* @param[in]: e : the evas canvas.
+* @param[in]: obj : the Time button.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _time_btn_mouse_in_cb(void *dt, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ if (!obj)
+ return;
+
+ elm_object_focus_set(obj, EINA_TRUE);
+}
+
+/**
+* MOUSEOUT event callback function.
+*
+* This is the MOUSEOUT event callback function for Time button.
+* When the mouse moves out of the region of Time button, this
+* function will be called. Till now there is no operation in this
+* function, and you can add operations here as needed.
+*
+* @param[in]: dt : the user data.
+* @param[in]: e : the evas canvas.
+* @param[in]: obj : the Time button.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _time_btn_mouse_out_cb(void *dt, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ /* TODO: Add necessary operations when needed. */
+}
+
+/**
+* This function creates the Time item button.
+*
+* @param[in]: data : the user data.
+*
+* @return: The created evas object Date button or NULL.
+*/
+static Evas_Object *_add_clock_sublist_time_btn(
+ struct _ug_data *data)
+{
+ Evas_Object *time_btn;
+
+ if (!data || !data->base) {
+ _ERR("invalid argument.");
+ return NULL;
+ }
+
+ time_btn = utils_add_button(data->base);
+ if (!time_btn) {
+ _ERR("add time button failed.");
+ return NULL;
+ }
+
+ elm_object_style_set(time_btn, BTN_STYLE_LIST_BTN);
+ elm_object_text_set(time_btn, BTN_TEXT_TIME);
+
+ elm_box_pack_end(data->sublist_box, time_btn);
+
+ /* Set hour : minute : AM/PM for time button. */
+ utils_get_time_value(data->time);
+
+ _refresh_time_btn_text(time_btn, data->time);
+
+ evas_object_event_callback_add(time_btn,
+ EVAS_CALLBACK_KEY_DOWN, _key_down_on_btns_cb, data);
+ evas_object_smart_callback_add(time_btn,
+ "clicked", _time_btn_clicked_cb, data);
+ evas_object_event_callback_add(time_btn,
+ EVAS_CALLBACK_MOUSE_IN, _time_btn_mouse_in_cb, NULL);
+ evas_object_event_callback_add(time_btn,
+ EVAS_CALLBACK_MOUSE_OUT, _time_btn_mouse_out_cb, NULL);
+
+ return time_btn;
+}
+
+/**
+* Create unused buttons.
+*
+* There is a unused region of clock UI gadget. We use blank
+* buttons to implement this unused region. This function
+* creates the unused region.
+*
+* @param[in]: data : the user data.
+*
+* @return: 0 - Success, -1 - Fail.
+*/
+static int _add_clock_sublist_null_btn(struct _ug_data *data)
+{
+ Evas_Object *null_btn;
+ Evas_Object *last_btn;
+ int idx;
+
+ if (!data || !data->base) {
+ _ERR("invalid argument.");
+ return -1;
+ }
+
+ for (idx = 0; idx < CLOCK_SUBLIST_NULL_BTNS; idx++) {
+ null_btn = utils_add_button(data->base);
+ if (!null_btn) {
+ _ERR("add null button failed.");
+ return -1;
+ }
+
+ elm_object_style_set(null_btn, BTN_STYLE_LIST_BTN);
+ elm_box_pack_end(data->sublist_box, null_btn);
+ }
+
+ last_btn = utils_add_button(data->base);
+ if (!last_btn) {
+ _ERR("add last button failed.");
+ return -1;
+ }
+
+ elm_object_style_set(last_btn, BTN_STYE_LAST_BTN);
+ elm_object_part_content_set(
+ data->base, SWALLOW_CLOCK_LAST, last_btn);
+
+ return 0;
+}
+
+/**
+* Set moving directions of focus for created buttons.
+*
+* @param[in]: data : the user data.
+*
+* @return: void.
+*/
+static void _set_btn_directions(struct _ug_data *data)
+{
+ Evas_Object *dbtn, *sbtn, *tbtn, *cbtn;
+
+ if (!data || !data->date_btn ||
+ !data->switch_btn || !data->time_btn) {
+ _ERR("all the sublist buttons may null.");
+ return;
+ }
+
+ dbtn = data->date_btn;
+ sbtn = data->switch_btn;
+ tbtn = data->time_btn;
+ cbtn = data->close_btn;
+
+ elm_object_focus_next_object_set(dbtn, dbtn, ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(dbtn, dbtn, ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(dbtn, sbtn, ELM_FOCUS_DOWN);
+ /* Maybe it's not necessary to set ELM_FOCUS_RIGHT for date_btn */
+ elm_object_focus_next_object_set(dbtn, cbtn, ELM_FOCUS_RIGHT);
+
+ elm_object_focus_next_object_set(sbtn, tbtn, ELM_FOCUS_DOWN);
+ elm_object_focus_next_object_set(sbtn, dbtn, ELM_FOCUS_UP);
+ /* Maybe it's not necessary to set ELM_FOCUS_RIGHT for switch_btn */
+ elm_object_focus_next_object_set(sbtn, cbtn, ELM_FOCUS_RIGHT);
+
+ elm_object_focus_next_object_set(tbtn, tbtn, ELM_FOCUS_DOWN);
+ elm_object_focus_next_object_set(tbtn, sbtn, ELM_FOCUS_UP);
+ /* Maybe it's not necessary to set ELM_FOCUS_RIGHT for time_btn */
+ elm_object_focus_next_object_set(tbtn, cbtn, ELM_FOCUS_RIGHT);
+
+ elm_object_focus_next_object_set(cbtn, cbtn, ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(cbtn, cbtn, ELM_FOCUS_DOWN);
+ elm_object_focus_next_object_set(cbtn, dbtn, ELM_FOCUS_LEFT);
+}
+
+/**
+* Create buttons for clock UI gadget.
+*
+* The main UI of clock UI gadget contains three items which are Date,
+* 24 Hour mode and Time. And they are implemented using buttons.
+* This function is to create these three buttons.
+*
+* @param[in]: data : the user data.
+*
+* @return: 0 - Success, -1 - Fail.
+*/
+static int _add_clock_sublist_btn(struct _ug_data *data)
+{
+ Evas_Object *date_btn;
+ Evas_Object *switch_btn;
+ Evas_Object *time_btn;
+ int ret;
+
+ if (!data)
+ return -1;
+
+ date_btn = _add_clock_sublist_date_btn(data);
+ if (!date_btn) {
+ _ERR("add date button failed.");
+ return -1;
+ }
+
+ data->date_btn = date_btn;
+
+ switch_btn = _add_clock_sublist_switch_btn(data);
+ if (!switch_btn) {
+ _ERR("add switch button failed.");
+ evas_object_del(data->date_btn);
+ return -1;
+ }
+
+ data->switch_btn = switch_btn;
+
+ time_btn = _add_clock_sublist_time_btn(data);
+ if (!time_btn) {
+ _ERR("add time button failed.");
+ evas_object_del(data->date_btn);
+ evas_object_del(data->switch_btn);
+ return -1;
+ }
+
+ data->time_btn = time_btn;
+
+ ret = _add_clock_sublist_null_btn(data);
+ if (ret != 0) {
+ _ERR("add null buttons failed.");
+ evas_object_del(data->date_btn);
+ evas_object_del(data->switch_btn);
+ evas_object_del(data->time_btn);
+ return -1;
+ }
+
+ _set_btn_directions(data);
+
+ return 0;
+}
+
+/**
+* Create UI components of clock UI gadget.
+*
+* This function creates the three UI components of clock UI gadget:
+* Date, 24Hour mode and Time.
+*
+* @param[in]: data : the user data.
+*
+* @return: 0 - Success, -1 - Fail.
+*/
+static int _add_clock_sublist(struct _ug_data *data)
+{
+ Evas_Object *box;
+ int ret;
+
+ if (!data)
+ return -1;
+
+ box = utils_add_box(data->base);
+ if (!box) {
+ _ERR("add clock sublist box failed.");
+ return -1;
+ }
+
+ data->sublist_box = box;
+
+ ret = _add_clock_sublist_btn(data);
+ if (ret != 0) {
+ _ERR("add clock sublist btn failed.");
+ evas_object_del(data->sublist_box);
+ return -1;
+ }
+
+ elm_object_part_content_set(
+ data->base, SWALLOW_CLOCK_LIST, data->sublist_box);
+
+ return 0;
+}
+
+/**
+* Create the UI of this ui gadget.
+*
+* This function creates all the UI components of this UI gadget.
+*
+* @param[in]: ug : the UI gadget created by ug_create().
+* @param[in]: mode : the mode of ug, fullview or frameview.
+* @param[in]: service : argument for the UI gadget.
+* @param[in]: priv : the user data.
+*
+* @return: The base layout of this UI gadget.
+*/
+static void *_on_create(ui_gadget_h ug,
+ enum ug_mode mode, service_h service, void *priv)
+{
+ struct _ug_data *data;
+ Evas_Object *win;
+ Evas_Object *base;
+ Evas_Object *close_btn;
+ int ret;
+
+ if (!ug || !priv) {
+ _ERR("ug or private data is null.");
+ return NULL;
+ }
+
+ if ((mode == UG_MODE_INVALID) ||
+ (mode >= UG_MODE_MAX) || (mode < UG_MODE_FULLVIEW)) {
+ _ERR("invalid ug mode.");
+ return NULL;
+ }
+
+ elm_theme_overlay_add(NULL, UG_CLOCK_EDJTHEME);
+
+ data = priv;
+ data->ug = ug;
+
+ win = ug_get_window();
+ if (!win) {
+ _ERR("ug get window failed.");
+ _free_ug_data(data);
+ return NULL;
+ }
+
+ data->win = win;
+
+ elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
+
+ base = utils_add_layout(win);
+ if (!base) {
+ _ERR("add base layout failed.");
+ _free_ug_data(data);
+ return NULL;
+ }
+
+ elm_layout_file_set(base, UG_CLOCK_EDJFILE, UG_CLOCK_GRP);
+ elm_object_part_text_set(
+ base, TEXT_INTRO, STRINGS_INTRO);
+ data->base = base;
+
+ close_btn = _add_close_btn(base, data);
+ if (!close_btn) {
+ _ERR("add close button for ug clock failed.");
+ _free_ug_data(data);
+ return NULL;
+ }
+
+ ret = _add_clock_sublist(data);
+ if (ret == -1) {
+ _ERR("add clock sublist failed.");
+ evas_object_del(close_btn);
+ _free_ug_data(data);
+ return NULL;
+ }
+
+ evas_object_data_set(data->base, UG_CLOCK_DATA_ID, data);
+
+ return base;
+}
+
+/**
+* Destroy this UI gadget.
+*
+* This function destroyes all the UI components of this UI gadget.
+*
+* @param[in]: ug : UI gadget.
+* @param[in]: service : argument of this UI gadget.
+* @param[in]: priv : the user data.
+*
+* @return: void.
+*/
+static void _on_destroy(ui_gadget_h ug, service_h service, void *priv)
+{
+ struct _ug_data *data;
+
+ if (!ug || !priv) {
+ _ERR("ug or private data is null.");
+ return;
+ }
+
+ data = priv;
+
+ _free_ug_data(data);
+}
+
+/**
+* Refresh text of Date button.
+*
+* @param[in]: btn : the Date button.
+* @param[in]: date : the user data.
+*
+* @return: void.
+*/
+static void _refresh_date_btn_text(Evas_Object *btn, unsigned int *date)
+{
+ char buf[BUF_SIZE];
+
+ if (!btn || !date)
+ return;
+
+ snprintf(buf, sizeof(buf), "%02d / %02d / %04d",
+ date[DATE_MONTH], date[DATE_DAY], date[DATE_YEAR]);
+ elm_object_part_text_set(btn, BTN_PART_VALUE, (const char *)buf);
+}
+
+/**
+* Refresh text of 24 Hour mode button.
+*
+* @param[in]: btn : the 24 Hour mode button.
+* @param[in]: mode : the refreshed value of mode.
+*
+* @return: void.
+*/
+static void _refresh_switch_btn_text(Evas_Object *btn, int mode)
+{
+ if (!btn)
+ return;
+
+ if (mode)
+ elm_object_part_text_set(btn, BTN_PART_VALUE, ON);
+ else
+ elm_object_part_text_set(btn, BTN_PART_VALUE, OFF);
+}
+
+/**
+* Change the way of displayed time.
+*
+* This function displays time as the 24 Hour mode changes.
+* If 24 Hour mode is ON, we display the time using 24 hour mode.
+* If 24 Hour mode is OFF, we display the time using 12 hour mode.
+*
+* @param[in]: btn : the Time button.
+* @param[in]: time : the value of time.
+*
+* @return: void.
+*/
+static void _refresh_time_btn_as_mode(Evas_Object *btn, int *time)
+{
+ int mode;
+ int ret;
+ char buf[BUF_SIZE];
+
+ if (!btn || !time)
+ return;
+
+ mode = 0;
+ ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode);
+ if (ret != 0) {
+ _ERR("vconf get value failed.");
+ return;
+ }
+
+ if (mode)
+ snprintf(buf, sizeof(buf), "%02d : %02d",
+ time[TIME_HOUR], time[TIME_MINUTE]);
+ else
+ snprintf(buf, sizeof(buf), "%02d : %02d : %s",
+ time[TIME_HOUR], time[TIME_MINUTE],
+ time[TIME_AMPM] == 1 ? PM : AM);
+
+ elm_object_part_text_set(btn, BTN_PART_VALUE, (const char *)buf);
+}
+
+/**
+* Refresh text of buttons.
+*
+* @param[in]: data : the user data.
+*
+* @return: void.
+*/
+static void _refresh_btn_text(struct _ug_data *data)
+{
+ int ret;
+
+ if (!data || !data->cur_btn)
+ return;
+
+ if (data->date_btn == data->cur_btn) {
+ _refresh_date_btn_text(data->cur_btn, data->date);
+ } else if (data->switch_btn == data->cur_btn) {
+ ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &data->mode);
+ if (ret != 0) {
+ _ERR("vconf get value failed.");
+ return;
+ }
+
+ _refresh_switch_btn_text(data->cur_btn, data->mode);
+
+ utils_get_time_value(data->time);
+ _refresh_time_btn_as_mode(data->time_btn, data->time);
+ } else {
+ _refresh_time_btn_text(data->cur_btn, data->time);
+ }
+}
+
+/**
+* Refresh the UI of clock UI gadget.
+*
+* This function refreshes the UI of clock UI gadget. For example,
+* when the user sets a new date, this function will be called to refresh
+* the date item of clock UI gadget. They are the same as mode item
+* time item of clock UI gadget.
+*
+* @param[in]: base : the base layout of clock UI gadget.
+* @param[in]: date : the user data.
+* @param[in]: time : the new time need to be refreshed.
+*
+* @return: void.
+*/
+void view_ug_clock_refresh(Evas_Object *base, unsigned int *date, int *time)
+{
+ struct _ug_data *data;
+ int idx;
+
+ if (!base) {
+ _ERR("invalid argument.");
+ return;
+ }
+
+ data = evas_object_data_get(base, UG_CLOCK_DATA_ID);
+ if (!data) {
+ _ERR("evas object data get failed. ID: %s", UG_CLOCK_DATA_ID);
+ return;
+ }
+
+ elm_object_focus_set(data->cur_btn, EINA_TRUE);
+
+ if (date)
+ for (idx = DATE_MONTH; idx < DATE_MAX; idx++)
+ data->date[idx] = date[idx];
+
+ if (time)
+ for (idx = TIME_HOUR; idx < TIME_MAX; idx++)
+ data->time[idx] = time[idx];
+
+ _refresh_btn_text(data);
+}
+
+/**
+* ug module init function.
+*
+* This function is the first function which is called by caller
+* using dlopen() and dlsym().
+*
+* @param[in]: ops : the struct ug_module_ops including
+* callbacks which will be used in UI gadget module.
+*
+* @return: 0 - Success, -1 - Fail.
+*/
+UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
+{
+ struct _ug_data *priv;
+
+ if (!ops) {
+ _ERR("invalid argument ops.");
+ return -1;
+ }
+
+ priv = calloc(1, sizeof(*priv));
+ if (!priv) {
+ _ERR("calloc memory for ug private data failed.");
+ return -1;
+ }
+
+ ops->create = _on_create;
+ ops->destroy = _on_destroy;
+ ops->priv = priv;
+ ops->opt = UG_OPT_INDICATOR_ENABLE;
+
+ return 0;
+}
+
+/**
+* ug module exit function.
+*
+* This function will be called by the caller when ug is unloaded.
+*
+* @param[in]: ops : the pointer of struct ug_module_ops.
+*
+* @return: void.
+*/
+UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
+{
+ if (!ops) {
+ _ERR("invalid argument ops.");
+ return;
+ }
+}
diff --git a/ug/system/clock/src/ug_clock.cpp b/ug/system/clock/src/ug_clock.cpp
deleted file mode 100644
index 4037c28..0000000
--- a/ug/system/clock/src/ug_clock.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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.
- */
-
-#ifndef UG_MODULE_API
-#define UG_MODULE_API __attribute__ ((visibility("default")))
-#endif
-
-#include <ui-gadget-module.h>
-
-#include "util.h"
-#include "ug_clock.h"
-#include "defs.h"
-#include <AppCommon.h>
-
-#include "ClockMainView.h"
-#include "ClockSublistView.h"
-
-#define CLOCK_SUBLIST_NULL_BTNS 2
-#define UG_CLOCK_DATA_ID "ug_clock_data"
-
-#if defined (__cplusplus)
-extern "C" {
-#endif
-
-struct _ug_data {
- ui_gadget_h ug;
-
- Evas_Object *win;
- Evas_Object *base;
-
- CViewMgr *pViewMgr;
- CClockMainView *pClockMainView;
- CClockSublistView *pClockSublistView;
-};
-
-static void *_on_create(ui_gadget_h ug,
- enum ug_mode mode, service_h service, void *priv)
-{
- struct _ug_data *ugd;
- Evas_Object *win;
-
- if (!ug || !priv) {
- _ERR("ug or private data is null.");
- return NULL;
- }
-
- if ((mode == UG_MODE_INVALID) || (mode >= UG_MODE_MAX) || (mode < UG_MODE_FULLVIEW)) {
- _ERR("invalid ug mode.");
- return NULL;
- }
-
- elm_theme_overlay_add(NULL, UG_CLOCK_EDJTHEME);
-
- ugd = (struct _ug_data *) priv;
- ugd->ug = ug;
-
- win = (Evas_Object *) ug_get_window();
- if (!win) {
- _ERR("ug get window failed.");
- return NULL;
- }
-
- ugd->win = win;
-
- elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
-
-
- CViewMgr::Initialize(ugd->win, NULL);
- ugd->pViewMgr = CViewMgr::GetInstance();
- if(!ugd->pViewMgr) {
- CViewMgr::Finalize();
- _ERR("Fail to get CViewMgr instance");
- return NULL;
- }
- ugd->pClockMainView = new CClockMainView(CLOCK_MAIN_VIEW);
- if(!ugd->pViewMgr->AddView(ugd->pClockMainView)) {
- _ERR("Fail to add pFbBaseView");
- CViewMgr::Finalize();
- return false;
- }
-
- ugd->pClockSublistView = new CClockSublistView(CLOCK_SUBLIST_VIEW);
- if(!ugd->pViewMgr->AddView(ugd->pClockSublistView)) {
- _ERR("Fail to add pFbBaseView");
- CViewMgr::Finalize();
- return false;
- }
-
- ugd->pViewMgr->PushView(CLOCK_MAIN_VIEW, ugd->ug);
- ugd->base = ugd->pClockMainView->Base();
-
- return ugd->base;
-}
-
-/**
-* Destroy this UI gadget.
-*
-* This function destroyes all the UI components of this UI gadget.
-*
-* @param[in]: ug : UI gadget.
-* @param[in]: service : argument of this UI gadget.
-* @param[in]: priv : the user data.
-*
-* @return: void.
-*/
-static void _on_destroy(ui_gadget_h ug, service_h service, void *priv)
-{
- CViewMgr::Finalize();
-}
-
-/**
-* ug module init function.
-*
-* This function is the first function which is called by caller
-* using dlopen() and dlsym().
-*
-* @param[in]: ops : the struct ug_module_ops including
-* callbacks which will be used in UI gadget module.
-*
-* @return: 0 - Success, -1 - Fail.
-*/
-UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
-{
- struct _ug_data *priv;
-
- if (!ops) {
- _ERR("invalid argument ops.");
- return -1;
- }
-
- priv = (struct _ug_data *) calloc(1, sizeof(*priv));
- if (!priv) {
- _ERR("calloc memory for ug private data failed.");
- return -1;
- }
-
- ops->create = _on_create;
- ops->destroy = _on_destroy;
- ops->priv = priv;
- ops->opt = UG_OPT_INDICATOR_ENABLE;
-
- return 0;
-}
-
-/**
-* ug module exit function.
-*
-* This function will be called by the caller when ug is unloaded.
-*
-* @param[in]: ops : the pointer of struct ug_module_ops.
-*
-* @return: void.
-*/
-UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
-{
- if (!ops) {
- _ERR("invalid argument ops.");
- return;
- }
-}
-
-#if defined (__cplusplus)
-};
-#endif
diff --git a/ug/system/clock/src/ug_clock_spin_control.c b/ug/system/clock/src/ug_clock_spin_control.c
new file mode 100644
index 0000000..bf5f0d0
--- /dev/null
+++ b/ug/system/clock/src/ug_clock_spin_control.c
@@ -0,0 +1,797 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <KeyDefine.h>
+
+#include "dbg.h"
+#include "ug_clock_define.h"
+#include "ug_clock.h"
+#include "ug_clock_spin_control.h"
+#include "ug_clock_utils.h"
+
+#define ARROW_BTN_DATA_ID "arrow_btn_data_id"
+#define DATE_SPIN_DATA_ID "spin_ctrl_data"
+#define YEAR_BTN (2)
+
+#define UP_ARROW (1)
+#define DOWN_ARROW (0)
+
+#define CLICKED "clicked"
+
+struct _date_spin_data {
+ Evas_Object *win;
+ Evas_Object *base;
+ Evas_Object *ug_base;
+
+ unsigned int date[DATE_MAX];
+ int entry[DATE_MAX];
+
+ Eina_Array *spin_array;
+};
+
+static const int days[] = {
+ 31,
+ 28,
+ 31,
+ 30,
+ 31,
+ 30,
+ 31,
+ 31,
+ 30,
+ 31,
+ 30,
+ 31
+};
+
+static void _destroy(Evas_Object *base);
+static void _update_date_value(Evas_Object *spin,
+ unsigned int *date, int spin_idx);
+
+/**
+* Free user data of date spin.
+*
+* @param[in]: data : the user data.
+*
+* @return: void.
+*/
+static void _free_date_spin_data(struct _date_spin_data *data)
+{
+ if (!data)
+ return;
+
+ if (data->base) {
+ evas_object_del(data->base);
+ data->base = NULL;
+ }
+
+ if (data->spin_array)
+ eina_array_free(data->spin_array);
+
+ free(data);
+}
+
+/**
+* Evas_Smart_Cb type callback for handling click event.
+*
+* @param[in]: priv : the user data.
+* @param[in]: obj : the corresponding object which the click event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+void _arrow_btn_clicked_cb(void *priv, Evas_Object *obj, void *ev)
+{
+ struct _date_spin_data *data;
+ Evas_Object *cur_btn;
+ Evas_Object *btn;
+ Evas_Object *up_btn;
+ int i;
+ int idx;
+ int flag;
+
+ if (!priv || !obj)
+ return;
+
+ data = priv;
+ cur_btn = evas_object_data_get(obj, ARROW_BTN_DATA_ID);
+ if (!cur_btn) {
+ _ERR("evas object data get failed. ID: %s", ARROW_BTN_DATA_ID);
+ return;
+ }
+
+ up_btn = elm_object_part_content_get(cur_btn, UP_ARROW_SWALLOW);
+ if (!up_btn) {
+ _ERR("part %s content get failed.", UP_ARROW_SWALLOW);
+ return;
+ }
+
+ if (obj == up_btn)
+ flag = 1;
+ else
+ flag = 0;
+
+ idx = 0;
+ for (i = DATE_DAY; i < DATE_MAX; i++) {
+ btn = eina_array_data_get(data->spin_array, i);
+ if (!btn) {
+ _ERR("eina array data get failed. button index: %d", i);
+ return;
+ }
+
+ if (cur_btn == btn) {
+ idx = i;
+ break;
+ }
+ }
+
+ if (flag)
+ data->date[idx]++;
+ else
+ data->date[idx]--;
+
+ _update_date_value(cur_btn, data->date, idx);
+
+}
+
+/**
+* Create arrow buttons for date spin.
+*
+* @param[in]: data : the user data.
+* @param[in]: obj : the corresponding object which the arrow created on.
+* @param[in]: flag : 1 - up arrow button, 0 - down arrow button.
+*
+* @return: the created arrow button.
+*/
+static Evas_Object *_add_arrow_btn(struct _date_spin_data *data,
+ Evas_Object *obj, int flag)
+{
+ Evas_Object *btn;
+
+ if (!data || !data->base || !obj)
+ return NULL;
+
+ btn = utils_add_button(data->base);
+ if (!btn) {
+ _ERR("utils add button failed.");
+ return NULL;
+ }
+
+ elm_object_style_set(btn, BTN_STYLE_ARROW_BTN);
+
+ if (flag == UP_ARROW)
+ elm_object_part_content_set(obj, UP_ARROW_SWALLOW, btn);
+ else
+ elm_object_part_content_set(obj, DOWN_ARROW_SWALLOW, btn);
+
+ elm_object_focus_allow_set(btn, EINA_FALSE);
+
+ evas_object_smart_callback_add(btn, "clicked",
+ _arrow_btn_clicked_cb, data);
+
+ evas_object_data_set(btn, ARROW_BTN_DATA_ID, obj);
+ evas_object_raise(btn);
+ evas_object_repeat_events_set(btn, EINA_FALSE);
+
+ return btn;
+}
+
+/**
+* Create date spin.
+*
+* @param[in]: data : the user data.
+*
+* @return: 0 - Success, -1 - Fail.
+*/
+static int _add_date_spin(struct _date_spin_data *data)
+{
+ Evas_Object *btn, *uparrow, *downarrow;
+ Eina_Array *array;
+ char buf[BUF_SIZE];
+ int idx;
+
+ if (!data || !data->base) {
+ _ERR("invalid arguments.");
+ return -1;
+ }
+
+ array = eina_array_new(1);
+ if (!array) {
+ _ERR("new eina array failed.");
+ return -1;
+ }
+
+ for (idx = DATE_MONTH; idx < DATE_MAX; idx++) {
+ btn = utils_add_button(data->base);
+ if (!btn) {
+ _ERR("add spin control button failed.");
+ return -1;
+ }
+
+ elm_object_style_set(btn, BTN_STYLE_SPIN_CTRL_BTN);
+ if (idx == YEAR_BTN)
+ elm_object_style_set(btn, BTN_STYLE_SPIN_CTRL_YEAR_BTN);
+
+ snprintf(buf, sizeof(buf), "spin_ctrl_%d_swallow", idx + 1);
+ elm_object_part_content_set(
+ data->base, (const char *)buf, btn);
+
+ eina_array_push(array, btn);
+
+ uparrow = _add_arrow_btn(data, btn, UP_ARROW);
+ if (!uparrow) {
+ _ERR("add up arrow button failed.");
+ evas_object_del(btn);
+ return -1;
+ }
+
+ downarrow = _add_arrow_btn(data, btn, DOWN_ARROW);
+ if (!downarrow) {
+ _ERR("add down arrow button failed.");
+ evas_object_del(btn);
+ evas_object_del(uparrow);
+ return -1;
+ }
+ }
+
+ elm_object_focus_set(
+ eina_array_data_get(array, 0), EINA_TRUE);
+
+ data->spin_array = array;
+
+ return 0;
+}
+
+/**
+* Evas_Smart_Cb type callback for handling click event.
+*
+* @param[in]: priv : the user data.
+* @param[in]: obj : the corresponding object which the click event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _date_spin_clicked_cb(void *priv, Evas_Object *obj, void *ei)
+{
+ struct _date_spin_data *data;
+
+ if (!priv) {
+ _ERR("invalid argument.");
+ return;
+ }
+
+ data = priv;
+
+ utils_set_date_value(data->date);
+
+ view_ug_clock_refresh(data->ug_base, data->date, NULL);
+
+ _destroy(data->base);
+}
+
+/**
+* Evas_Object_Event_Cb type callback for handling mouse in event.
+*
+* @param[in]: dt : the user data.
+* @param[in]: e : the evas.
+* @param[in]: obj : the corresponding object which the mouse in event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _date_spin_mousein_cb(void *dt, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ if (!obj)
+ return;
+
+ elm_object_focus_set(obj, EINA_TRUE);
+}
+
+/**
+* Evas_Object_Event_Cb type callback for handling mouse out event.
+*
+* @param[in]: dt : the user data.
+* @param[in]: e : the evas.
+* @param[in]: obj : the corresponding object which the mouse out event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _date_spin_mouseout_cb(void *dt, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+}
+
+/**
+* Evas_Smart_Cb type callback for handling click event.
+*
+* @param[in]: priv : the user data.
+* @param[in]: obj : the corresponding object which the click event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static int _add_date_spin_click_event(struct _date_spin_data *data)
+{
+ Evas_Object *spin;
+ Eina_Array *array;
+ int idx;
+
+ if (!data || !data->spin_array) {
+ _ERR("no spin control buttons.");
+ return -1;
+ }
+
+ array = data->spin_array;
+
+ for (idx = DATE_MONTH; idx < DATE_MAX; idx++) {
+ spin = eina_array_data_get(array, idx);
+ if (!spin) {
+ _ERR("eina array data get failed. spin index: %d", idx);
+ return -1;
+ }
+
+ evas_object_smart_callback_add(spin, CLICKED,
+ _date_spin_clicked_cb, data);
+ evas_object_event_callback_add(spin, EVAS_CALLBACK_MOUSE_IN,
+ _date_spin_mousein_cb, NULL);
+ evas_object_event_callback_add(spin, EVAS_CALLBACK_MOUSE_OUT,
+ _date_spin_mouseout_cb, NULL);
+ }
+
+ return 0;
+}
+
+/**
+* Set focus move directions among buttons.
+*
+* @param[in]: array : the eina array including buttons.
+*
+* @return: void.
+*/
+static void _set_date_spin_direction(Eina_Array *array)
+{
+ Evas_Object *spin;
+ int idx;
+
+ if (!array) {
+ _ERR("spin control button array is null.");
+ return;
+ }
+
+ for (idx = DATE_MONTH; idx < DATE_MAX; idx++) {
+ spin = eina_array_data_get(array, idx);
+ if (!spin) {
+ _ERR("there is no button. idx: %d", idx);
+ return;
+ }
+
+ elm_object_focus_next_object_set(spin, spin, ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(spin, spin, ELM_FOCUS_DOWN);
+
+ if (idx == DATE_MONTH) {
+ elm_object_focus_next_object_set(spin,
+ eina_array_data_get(array, idx+1),
+ ELM_FOCUS_NEXT);
+ elm_object_focus_next_object_set(spin, spin,
+ ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(spin,
+ eina_array_data_get(array, idx + 1),
+ ELM_FOCUS_RIGHT);
+ } else if (idx == DATE_YEAR) {
+ elm_object_focus_next_object_set(spin, spin,
+ ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(spin,
+ eina_array_data_get(array, idx - 1),
+ ELM_FOCUS_LEFT);
+ } else {
+ elm_object_focus_next_object_set(spin,
+ eina_array_data_get(array, idx + 1),
+ ELM_FOCUS_NEXT);
+ elm_object_focus_next_object_set(spin,
+ eina_array_data_get(array, idx + 1),
+ ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(spin,
+ eina_array_data_get(array, idx - 1),
+ ELM_FOCUS_LEFT);
+ }
+ }
+}
+
+/**
+* Initialize value of date spin.
+*
+* @param[in]: data : the user data.
+*
+* @return: void.
+*/
+static void _init_date_spin(struct _date_spin_data *data)
+{
+ Evas_Object *spin;
+ Eina_Array *spin_array;
+ char buf[BUF_SIZE];
+
+ if (!data || !data->spin_array)
+ return;
+
+ spin_array = data->spin_array;
+
+ utils_get_date_value(data->date);
+
+ spin = eina_array_data_get(spin_array, 0);
+ if (!spin) {
+ _ERR("month button is null.");
+ return;
+ }
+
+ snprintf(buf, sizeof(buf), "%02d", data->date[DATE_MONTH]);
+ elm_object_text_set(spin, buf);
+
+ spin = eina_array_data_get(spin_array, 1);
+ if (!spin) {
+ _ERR("month button is null.");
+ return;
+ }
+
+ snprintf(buf, sizeof(buf), "%02d", data->date[DATE_DAY]);
+ elm_object_text_set(spin, buf);
+
+ spin = eina_array_data_get(spin_array, 2);
+ if (!spin) {
+ _ERR("month button is null.");
+ return;
+ }
+
+ data->date[DATE_YEAR] = data->date[DATE_YEAR] < 2000 ?
+ 2000 : data->date[DATE_YEAR];
+ snprintf(buf, sizeof(buf), "%04d", data->date[DATE_YEAR]);
+ elm_object_text_set(spin, buf);
+}
+
+/**
+* Update value of date spin.
+*
+* @param[in]: spin : the corresponding date spin whose value need to update.
+* @param[in]: date : the value to be updated.
+* @param[in]: spin_idx : the index of corresponding date spin.
+*
+* @return: void.
+*/
+static void _update_date_value(Evas_Object *spin,
+ unsigned int *date, int spin_idx)
+{
+ char buf[BUF_SIZE];
+
+ if (!spin || !date)
+ return;
+ if (spin_idx < DATE_MONTH || spin_idx >= DATE_MAX)
+ return;
+
+ if (spin_idx == DATE_MONTH) {
+ if (date[spin_idx] > 12)
+ date[spin_idx] = 1;
+ if (date[spin_idx] <= 0)
+ date[spin_idx] = 12;
+
+ snprintf(buf, sizeof(buf), "%02d", date[spin_idx]);
+ } else if (spin_idx == DATE_DAY) {
+ if (date[spin_idx] > days[date[DATE_MONTH] - 1])
+ date[spin_idx] = 1;
+ if (date[spin_idx] <= 0)
+ date[spin_idx] = days[date[DATE_MONTH] - 1];
+
+ snprintf(buf, sizeof(buf), "%02d", date[spin_idx]);
+ } else {
+ if (date[spin_idx] > 2037)
+ date[spin_idx] = 2000;
+ if (date[spin_idx] < 2000)
+ date[spin_idx] = 2037;
+
+ snprintf(buf, sizeof(buf), "%04d", date[spin_idx]);
+ }
+
+ elm_object_text_set(spin, buf);
+}
+
+/**
+* Evas_Object_Event_Cb type callback for handling key press event.
+*
+* @param[in]: dt : the user data.
+* @param[in]: e : the evas.
+* @param[in]: obj : the corresponding object which the key press event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _date_spin_keydown_cb(void *priv, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *event;
+ struct _date_spin_data *data;
+ const char *keyname;
+ int i, idx;
+ Evas_Object *spin;
+ Eina_Array *spin_array;
+ char buf[BUF_SIZE];
+
+ if (!priv || !ei || !obj) {
+ _ERR("invalid argument.");
+ return;
+ }
+
+ event = ei;
+ keyname = event->keyname;
+ if (!keyname)
+ return;
+
+ data = priv;
+
+ if (!data->spin_array)
+ return;
+
+ spin_array = data->spin_array;
+
+ idx = -1;
+ for (i = DATE_MONTH; i < DATE_MAX; i++) {
+ spin = eina_array_data_get(spin_array, i);
+ if (!spin)
+ return;
+
+ if (obj == spin) {
+ idx = i;
+ break;
+ }
+ }
+
+ if (idx == -1) {
+ _ERR("can't get the right spin.");
+ return;
+ }
+
+ if (!strncmp(keyname, KEY_UP, strlen(keyname))) {
+ data->date[idx]++;
+ _update_date_value(obj, data->date, idx);
+ } else if (!strncmp(keyname, KEY_DOWN, strlen(keyname))) {
+ data->date[idx]--;
+ _update_date_value(obj, data->date, idx);
+ } else if (!strncmp(keyname, KEY_0, strlen(keyname)) ||
+ !strncmp(keyname, KEY_1, strlen(keyname)) ||
+ !strncmp(keyname, KEY_2, strlen(keyname)) ||
+ !strncmp(keyname, KEY_3, strlen(keyname)) ||
+ !strncmp(keyname, KEY_4, strlen(keyname)) ||
+ !strncmp(keyname, KEY_5, strlen(keyname)) ||
+ !strncmp(keyname, KEY_6, strlen(keyname)) ||
+ !strncmp(keyname, KEY_7, strlen(keyname)) ||
+ !strncmp(keyname, KEY_8, strlen(keyname)) ||
+ !strncmp(keyname, KEY_9, strlen(keyname))) {
+ if (idx != DATE_YEAR) {
+ if (data->entry[idx] == 0) {
+ data->entry[idx]++;
+
+ data->date[idx] = atoi(keyname);
+ } else {
+ data->entry[idx]++;
+
+ data->date[idx] = data->date[idx] * 10
+ + atoi(keyname);
+ data->entry[idx] = 0;
+ elm_object_focus_next(obj, ELM_FOCUS_NEXT);
+ }
+ } else {
+ if (data->entry[idx] == 0) {
+ data->entry[idx]++;
+ data->date[idx] = atoi(keyname);
+
+ snprintf(buf, sizeof(buf), "%04d",
+ data->date[idx]);
+ elm_object_text_set(obj, buf);
+ return;
+ } else if (data->entry[idx] == 3) {
+ data->date[idx] = data->date[idx] * 10
+ + atoi(keyname);
+ data->entry[idx] = 0;
+ } else {
+ data->entry[idx]++;
+ data->date[idx] = data->date[idx] * 10
+ + atoi(keyname);
+
+ snprintf(buf, sizeof(buf), "%04d",
+ data->date[idx]);
+ elm_object_text_set(obj, buf);
+ return;
+ }
+ }
+
+ _update_date_value(obj, data->date, idx);
+ } else if (!strncmp(keyname, KEY_RIGHT, strlen(keyname)) ||
+ !strncmp(keyname, KEY_LEFT, strlen(keyname))) {
+ data->entry[idx] = 0;
+ } else if (!strncmp(keyname, KEY_BACK, strlen(keyname))) {
+ _destroy(data->base);
+ }
+}
+
+/**
+* Add key event for date spin.
+*
+* @param[in]: data : the user data.
+*
+* @return: 0 - Success, -1 - Fail.
+*/
+static int _add_date_spin_key_event(struct _date_spin_data *data)
+{
+ Evas_Object *spin;
+ int idx;
+
+ if (!data || !data->spin_array) {
+ _ERR("invalid argument.");
+ return -1;
+ }
+
+ for (idx = DATE_MONTH; idx < DATE_MAX; idx++) {
+ spin = eina_array_data_get(data->spin_array, idx);
+ if (!spin) {
+ _ERR("button is null.");
+ return -1;
+ }
+
+ evas_object_event_callback_add(spin, EVAS_CALLBACK_KEY_DOWN,
+ _date_spin_keydown_cb, data);
+ }
+
+ return 0;
+}
+
+/**
+* Create data spin.
+*
+* @param[in]: data : the user data.
+*
+* @return: 0 - Success, -1 - Fail.
+*/
+static int _add_spin(struct _date_spin_data *data)
+{
+ int ret;
+
+ if (!data || !data->base) {
+ _ERR("private data is null.");
+ return -1;
+ }
+
+ ret = _add_date_spin(data);
+ if (ret != 0) {
+ _ERR("add spin control buttons failed.");
+ return -1;
+ }
+
+ _init_date_spin(data);
+
+ _set_date_spin_direction(data->spin_array);
+
+ ret = _add_date_spin_click_event(data);
+ if (ret != 0) {
+ _ERR("add click event for spin control button failed.");
+ return -1;
+ }
+
+ ret = _add_date_spin_key_event(data);
+ if (ret != 0) {
+ _ERR("add key event for spin control button failed.");
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+* Create all UI components of date spin.
+*
+* @param[in]: data : the user data.
+*
+* @return: the base layout of date spin.
+*/
+static Evas_Object *_create(struct _date_spin_data *data)
+{
+ Evas_Object *base;
+ int ret;
+
+ if (!data || !data->win) {
+ _ERR("window for spin control base is null.");
+ return NULL;
+ }
+
+ base = utils_add_layout(data->win);
+ if (!base) {
+ _ERR("add base layout for spin control failed.");
+ return NULL;
+ }
+
+ data->base = base;
+ elm_layout_file_set(base, UG_CLOCK_EDJFILE, SPIN_CTRL_GRP);
+
+ ret = _add_spin(data);
+ if (ret != 0) {
+ _ERR("add spin control failed.");
+ evas_object_del(data->base);
+ data->base = NULL;
+ return NULL;
+ }
+
+ evas_object_data_set(data->base, DATE_SPIN_DATA_ID, data);
+
+ return base;
+}
+
+/**
+* Destroy all the UI componets of date spin.
+*
+* @param[in]: base : the base layout of date spin.
+*
+* @return: void.
+*/
+static void _destroy(Evas_Object *base)
+{
+ struct _date_spin_data *data;
+
+ if (!base) {
+ _ERR("base is null.");
+ return;
+ }
+
+ data = evas_object_data_get(base, DATE_SPIN_DATA_ID);
+ if (!data) {
+ _ERR("evas object get data failed. ID: %s", DATE_SPIN_DATA_ID);
+ return;
+ }
+
+ _free_date_spin_data(data);
+}
+
+/**
+* Entry of creating date spin UI.
+*
+* @param[in]: win : window.
+* @param[in]: ug_base : the base layout of clock UI gadget.
+*
+* @return: void.
+*/
+void view_spin_control_create(Evas_Object *win,
+ Evas_Object *ug_base)
+{
+ Evas_Object *base;
+ struct _date_spin_data *data;
+
+ if (!win || !ug_base) {
+ _ERR("the window of spin control is null.");
+ return;
+ }
+
+ data = calloc(1, sizeof(*data));
+ if (!data) {
+ _ERR("calloc spin control data memory failed.");
+ return;
+ }
+
+ data->win = win;
+ data->ug_base = ug_base;
+
+ base = _create(data);
+ if (!base) {
+ _ERR("create spin control failed.");
+ _free_date_spin_data(data);
+ }
+}
diff --git a/ug/system/clock/src/ug_clock_sublist.c b/ug/system/clock/src/ug_clock_sublist.c
new file mode 100644
index 0000000..47e93be
--- /dev/null
+++ b/ug/system/clock/src/ug_clock_sublist.c
@@ -0,0 +1,516 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <KeyDefine.h>
+
+#include "dbg.h"
+#include "ug_clock_define.h"
+#include "ug_clock_sublist.h"
+#include "ug_clock_utils.h"
+#include "ug_clock.h"
+
+#define SUBLIST_BTN_NUM 2
+#define SUBLIST_DATA_ID "sublist_data"
+
+#define BOX_HPADDING 0
+#define BOX_VPADDING 2
+
+#define CLICKED "clicked"
+
+struct _sublist_data {
+ Evas_Object *win;
+ Evas_Object *base;
+ Evas_Object *ug_base;
+ Evas_Object *box;
+
+ unsigned int mode;
+
+ Eina_Array *array;
+};
+
+static void _destroy(Evas_Object *base);
+
+/**
+* Free user data of mode sublist.
+*
+* @param[in]: data : the user data of mode sublist.
+*
+* @return: void.
+*/
+static void _free_sublist_data(struct _sublist_data *data)
+{
+ if (!data)
+ return;
+
+ if (data->base) {
+ evas_object_del(data->base);
+ data->base = NULL;
+ }
+
+ if (data->array)
+ eina_array_free(data->array);
+
+ free(data);
+}
+
+/**
+* Evas_Smart_Cb type callback for handling click event.
+*
+* @param[in]: priv : the user data.
+* @param[in]: obj : the corresponding object which the click event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _sublist_btn_clicked_cb(void *priv, Evas_Object *obj, void *ei)
+{
+ struct _sublist_data *data;
+ Eina_Array *array;
+ Evas_Object *on_btn, *off_btn;
+ int ret;
+
+ if (!priv || !obj) {
+ _ERR("invalid argument.");
+ return;
+ }
+
+ data = priv;
+
+ if (!data->array)
+ return;
+
+ array = data->array;
+
+ on_btn = eina_array_data_get(array, 0);
+ off_btn = eina_array_data_get(array, 1);
+ if (!on_btn || !off_btn) {
+ _ERR("ON button or OFF button is null.");
+ return;
+ }
+
+ if (obj == on_btn)
+ data->mode = 1;
+ else
+ data->mode = 0;
+
+ ret = utils_set_vconf_value(VCONF_KEY_24HOUR_MODE, data->mode);
+ if (ret != 0) {
+ _ERR("set 24hour mode failed.");
+ return;
+ }
+
+ view_ug_clock_refresh(data->ug_base, NULL, NULL);
+
+ _destroy(data->base);
+}
+
+/**
+* Evas_Object_Event_Cb type callback for handling key press event.
+*
+* @param[in]: dt : the user data.
+* @param[in]: e : the evas.
+* @param[in]: obj : the corresponding object which the key press event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _key_down_on_sublist_btn_cb(void *priv, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ Evas_Object *on_btn, *off_btn;
+ Eina_Array *array;
+ Evas_Event_Key_Down *event;
+ struct _sublist_data *data;
+ const char *keyname;
+ int mode;
+ int ret;
+
+ if (!priv || !ei || !obj)
+ return;
+
+ data = priv;
+
+ if (!data->array || !data->base)
+ return;
+
+ array = data->array;
+
+ event = ei;
+
+ if (!event->keyname)
+ return;
+
+ keyname = event->keyname;
+
+ on_btn = eina_array_data_get(array, 0);
+ off_btn = eina_array_data_get(array, 1);
+ if (!on_btn || !off_btn) {
+ _ERR("ON button or OFF button is null.");
+ return;
+ }
+
+ ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode);
+ if (ret != 0) {
+ _ERR("vconf get value failed.");
+ return;
+ }
+
+ if (!strncmp(keyname, KEY_DOWN, strlen(keyname))) {
+ if (obj != on_btn)
+ return;
+
+ elm_object_focus_set(off_btn, EINA_TRUE);
+
+ if (mode) {
+ elm_object_signal_emit(obj, SIG_SRC_UNFOC_SHOW_ICON,
+ SIG_NAME_SUBLIST);
+ elm_object_signal_emit(off_btn, SIG_SRC_FOC_HIDE_ICON,
+ SIG_NAME_SUBLIST);
+ } else {
+ elm_object_signal_emit(obj, SIG_SRC_UNFOC_HIDE_ICON,
+ SIG_NAME_SUBLIST);
+ elm_object_signal_emit(off_btn, SIG_SRC_FOC_SHOW_ICON,
+ SIG_NAME_SUBLIST);
+ }
+ } else if (!strncmp(keyname, KEY_UP, strlen(keyname))) {
+ if (obj == on_btn)
+ return;
+
+ elm_object_focus_set(on_btn, EINA_TRUE);
+
+ if (mode) {
+ elm_object_signal_emit(on_btn, SIG_SRC_FOC_SHOW_ICON,
+ SIG_NAME_SUBLIST);
+ elm_object_signal_emit(obj, SIG_SRC_UNFOC_HIDE_ICON,
+ SIG_NAME_SUBLIST);
+ } else {
+ elm_object_signal_emit(obj, SIG_SRC_UNFOC_SHOW_ICON,
+ SIG_NAME_SUBLIST);
+ elm_object_signal_emit(on_btn, SIG_SRC_FOC_HIDE_ICON,
+ SIG_NAME_SUBLIST);
+ }
+ } else if (!strncmp(keyname, KEY_BACK, strlen(keyname))) {
+ _destroy(data->base);
+ }
+}
+
+/**
+* Evas_Object_Event_Cb type callback for handling mouse in event.
+*
+* @param[in]: dt : the user data.
+* @param[in]: e : the evas.
+* @param[in]: obj : the corresponding object which the mouse in event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _sublist_btn_mouse_in_cb(void *dt, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ if (!obj)
+ return;
+
+ elm_object_focus_set(obj, EINA_TRUE);
+}
+
+/**
+* Evas_Object_Event_Cb type callback for handling mouse out event.
+*
+* @param[in]: dt : the user data.
+* @param[in]: e : the evas.
+* @param[in]: obj : the corresponding object which the mouse out event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _sublist_btn_mouse_out_cb(void *dt, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+}
+
+/**
+* Create mode sublist buttons.
+*
+* @param[in]: data : the user data.
+*
+* @return: 0 - Success, -1 - Fail.
+*/
+static int _add_sublist_btns(struct _sublist_data *data)
+{
+ Eina_Array *array;
+ Evas_Object *btn;
+ Evas_Object *box;
+ int idx;
+
+ if (!data || !data->base || !data->box) {
+ _ERR("invalid arguments.");
+ return -1;
+ }
+
+ box = data->box;
+ elm_box_padding_set(box, BOX_HPADDING, BOX_VPADDING);
+
+ array = eina_array_new(1);
+ if (!array) {
+ _ERR("new array for sublist buttons failed.");
+ return -1;
+ }
+
+ for (idx = 0; idx < SUBLIST_BTN_NUM; idx++) {
+ btn = utils_add_button(data->base);
+ if (!btn) {
+ _ERR("add button failed.");
+ eina_array_free(array);
+ return -1;
+ }
+
+ evas_object_smart_callback_add(btn, CLICKED,
+ _sublist_btn_clicked_cb, data);
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN,
+ _key_down_on_sublist_btn_cb, data);
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN,
+ _sublist_btn_mouse_in_cb, NULL);
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_OUT,
+ _sublist_btn_mouse_out_cb, NULL);
+
+ elm_object_style_set(btn, BTN_STYLE_SUBLIST_BTN);
+
+ elm_box_pack_end(box, btn);
+ eina_array_push(array, btn);
+ }
+
+ data->array = array;
+
+ elm_object_part_content_set(data->base,
+ SWALLOW_SUBLIST, data->box);
+
+ return 0;
+}
+
+/**
+* Initialize value of mode sublist.
+*
+* @param[in]: array : eina array including mode sublist buttons.
+*
+* @return: void.
+*/
+static void _set_sublist_init_value(Eina_Array *array)
+{
+ Evas_Object *on_btn, *off_btn;
+ int mode;
+ int ret;
+
+ if (!array)
+ return;
+
+ mode = 0;
+ ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode);
+ if (ret != 0) {
+ _ERR("vconf get value failed.");
+ return;
+ }
+
+ on_btn = eina_array_data_get(array, 0);
+ off_btn = eina_array_data_get(array, 1);
+ if (!on_btn || !off_btn) {
+ _ERR("there is no button in sublist array.");
+ return;
+ }
+
+ elm_object_focus_set(on_btn, EINA_TRUE);
+
+ elm_object_text_set(on_btn, ON);
+ elm_object_text_set(off_btn, OFF);
+
+ if (mode) {
+ elm_object_signal_emit(on_btn,
+ SIG_SRC_FOC_SHOW_ICON, SIG_NAME_SUBLIST);
+ elm_object_signal_emit(off_btn,
+ SIG_SRC_UNFOC_HIDE_ICON, SIG_NAME_SUBLIST);
+ } else {
+ elm_object_signal_emit(off_btn,
+ SIG_SRC_UNFOC_SHOW_ICON, SIG_NAME_SUBLIST);
+ elm_object_signal_emit(on_btn,
+ SIG_SRC_FOC_HIDE_ICON, SIG_NAME_SUBLIST);
+ }
+}
+
+/**
+* Set focus move directions among mode sublist buttons.
+*
+* @param[in]: array : the eina array including mode sublist buttons.
+*
+* @return: void.
+*/
+static void _set_sublist_btn_directions(Eina_Array *array)
+{
+ Evas_Object *on_btn, *off_btn;
+
+ if (!array)
+ return;
+
+ on_btn = eina_array_data_get(array, 0);
+ off_btn = eina_array_data_get(array, 1);
+ if (!on_btn || !off_btn) {
+ _ERR("get sublist button from array failed.");
+ return;
+ }
+
+ elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(on_btn, off_btn, ELM_FOCUS_DOWN);
+ elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_RIGHT);
+
+ elm_object_focus_next_object_set(off_btn, on_btn, ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(off_btn, off_btn, ELM_FOCUS_DOWN);
+ elm_object_focus_next_object_set(off_btn, off_btn, ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(off_btn, off_btn, ELM_FOCUS_RIGHT);
+}
+
+/**
+* Create mode sublist.
+*
+* @param[in]: data : the user data.
+*
+* @return: 0 - Success, -1 - Fail.
+*/
+static int _add_sublist(struct _sublist_data *data)
+{
+ int ret;
+ Evas_Object *box;
+
+ if (!data || !data->base) {
+ _ERR("invalid argument.");
+ return -1;
+ }
+
+ box = utils_add_box(data->base);
+ if (!box) {
+ _ERR("add sublist box failed.");
+ return -1;
+ }
+
+ data->box = box;
+
+ ret = _add_sublist_btns(data);
+ if (ret != 0) {
+ _ERR("add sublist buttons failed.");
+ evas_object_del(data->box);
+ data->box = NULL;
+ return -1;
+ }
+
+ _set_sublist_init_value(data->array);
+ _set_sublist_btn_directions(data->array);
+
+ return 0;
+}
+
+/**
+* Destroy all the UI componets of mode sublist.
+*
+* @param[in]: base : the base layout of mode sublist.
+*
+* @return: void.
+*/
+static void _destroy(Evas_Object *base)
+{
+ struct _sublist_data *data;
+
+ if (!base)
+ return;
+
+ data = evas_object_data_get(base, SUBLIST_DATA_ID);
+ if (!data) {
+ _ERR("evas object get data failed. ID: %s", SUBLIST_DATA_ID);
+ return;
+ }
+
+ _free_sublist_data(data);
+}
+
+/**
+* Create all the UI componets of mode sublist.
+*
+* @param[in]: data : the user data.
+*
+* @return: the base layout of mode sublist.
+*/
+static Evas_Object *_create(struct _sublist_data *data)
+{
+ Evas_Object *base;
+ int ret;
+
+ if (!data || !data->win) {
+ _ERR("invalid argument.");
+ return NULL;
+ }
+
+ base = utils_add_layout(data->win);
+ if (!base) {
+ _ERR("add base layout for sublist failed.");
+ return NULL;
+ }
+
+ data->base = base;
+
+ elm_layout_file_set(base, UG_CLOCK_EDJFILE, SUBLIST_GRP);
+
+ ret = _add_sublist(data);
+ if (ret != 0) {
+ _ERR("add sublist failed.");
+ evas_object_del(data->base);
+ data->base = NULL;
+ return NULL;
+ }
+
+ evas_object_data_set(data->base, SUBLIST_DATA_ID, data);
+
+ return base;
+}
+
+/**
+* Entry of creating mode sublist.
+*
+* @parma[in]: win : window.
+* @param[in]: ug_base : the base layout of clock UI gadget.
+*
+* @return: void.
+*/
+void view_sublist_create(Evas_Object *win, Evas_Object *ug_base)
+{
+ Evas_Object *base;
+ struct _sublist_data *data;
+
+ if (!win || !ug_base) {
+ _ERR("the window or base layout is null.");
+ return;
+ }
+
+ data = calloc(1, sizeof(*data));
+ if (!data) {
+ _ERR("calloc sublist data failed.");
+ return;
+ }
+ data->win = win;
+ data->ug_base = ug_base;
+
+ base = _create(data);
+ if (!base) {
+ _ERR("create sublist failed.");
+ _free_sublist_data(data);
+ }
+}
diff --git a/ug/system/clock/src/ug_clock_time_spin_control.c b/ug/system/clock/src/ug_clock_time_spin_control.c
new file mode 100644
index 0000000..1f956af
--- /dev/null
+++ b/ug/system/clock/src/ug_clock_time_spin_control.c
@@ -0,0 +1,842 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <KeyDefine.h>
+
+#include "dbg.h"
+#include "ug_clock_define.h"
+#include "ug_clock.h"
+#include "ug_clock_time_spin_control.h"
+#include "ug_clock_utils.h"
+
+#define ARROW_BTN_DATA_ID "arrow_btn_data_id"
+#define TIME_SPIN_DATA_ID "time_spin_ctrl_data"
+
+#define BOX_HPADDING 2
+#define BOX_VPADDING 122
+
+#define UP_ARROW (1)
+#define DOWN_ARROW (0)
+
+struct _time_spin_data {
+ Evas_Object *win;
+ Evas_Object *base;
+ Evas_Object *ug_base;
+ Evas_Object *spin_box;
+
+ int time[TIME_MAX];
+ int entry[TIME_MAX];
+
+ Eina_Array *spin_array;
+};
+
+static void _destroy(Evas_Object *base);
+
+/**
+* Free user data of time spin.
+*
+* @param[in]: data : the user data.
+*
+* @return: void.
+*/
+static void _free_time_spin_data(struct _time_spin_data *data)
+{
+ if (!data)
+ return;
+
+ if (data->base) {
+ evas_object_del(data->base);
+ data->base = NULL;
+ }
+
+ if (data->spin_array)
+ eina_array_free(data->spin_array);
+
+ free(data);
+}
+
+/**
+* Update value of time spin.
+*
+* @param[in]: spin : the corresponding date spin whose value need to update.
+* @param[in]: date : the value to be updated.
+* @param[in]: spin_idx : the index of corresponding time spin.
+*
+* @return: void.
+*/
+static void _update_time_value(Evas_Object *btn, int *time, int btn_idx)
+{
+ int mode;
+ char buf[BUF_SIZE];
+ int ret;
+
+ if (!btn || !time)
+ return;
+ if (btn_idx < TIME_HOUR || btn_idx >= TIME_MAX)
+ return;
+
+ mode = 0;
+ ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode);
+ if (ret != 0) {
+ _ERR("vconf get value failed.");
+ return;
+ }
+
+ if (btn_idx == TIME_HOUR) {
+ if (mode) {
+ if (time[btn_idx] > 23)
+ time[btn_idx] = 0;
+ if (time[btn_idx] < 0)
+ time[btn_idx] = 23;
+ } else {
+ if (time[btn_idx] > 11)
+ time[btn_idx] = 0;
+ if (time[btn_idx] < 0)
+ time[btn_idx] = 11;
+ }
+
+ snprintf(buf, sizeof(buf), "%02d", time[btn_idx]);
+ } else if (btn_idx == TIME_MINUTE) {
+ if (time[btn_idx] > 59)
+ time[btn_idx] = 0;
+ if (time[btn_idx] < 0)
+ time[btn_idx] = 59;
+
+ snprintf(buf, sizeof(buf), "%02d", time[btn_idx]);
+ } else {
+ if (time[btn_idx])
+ snprintf(buf, sizeof(buf), "%s", PM);
+ else
+ snprintf(buf, sizeof(buf), "%s", AM);
+ }
+
+ elm_object_text_set(btn, buf);
+}
+
+/**
+* Evas_Object_Event_Cb type callback for handling key press event.
+*
+* @param[in]: dt : the user data.
+* @param[in]: e : the evas.
+* @param[in]: obj : the corresponding object which the key press event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _time_spin_keydown_cb(void *priv,
+ Evas *e, Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *event;
+ struct _time_spin_data *data;
+ const char *keyname;
+ Eina_Array *array;
+ Evas_Object *hour_btn, *minute_btn;
+
+ if (!priv || !ei || !obj) {
+ _ERR("invalid argument.");
+ return;
+ }
+
+ data = priv;
+
+ if (!data->spin_array)
+ return;
+
+ array = data->spin_array;
+
+ hour_btn = eina_array_data_get(array, TIME_HOUR);
+ minute_btn = eina_array_data_get(array, TIME_MINUTE);
+ if (!hour_btn || !minute_btn) {
+ _ERR("eina array data get failed.");
+ return;
+ }
+
+ event = ei;
+
+ if (!event->keyname)
+ return;
+
+ keyname = event->keyname;
+
+ if (!strncmp(keyname, KEY_UP, strlen(keyname))) {
+ if (obj == hour_btn) {
+ data->time[TIME_HOUR]++;
+
+ _update_time_value(obj, data->time, TIME_HOUR);
+ } else if (obj == minute_btn) {
+ data->time[TIME_MINUTE]++;
+
+ _update_time_value(obj, data->time, TIME_MINUTE);
+ } else {
+ if (data->time[TIME_AMPM] == 0)
+ data->time[TIME_AMPM] = 1;
+ else
+ data->time[TIME_AMPM] = 0;
+
+ _update_time_value(obj, data->time, TIME_AMPM);
+ }
+ } else if (!strncmp(keyname, KEY_DOWN, strlen(keyname))) {
+ if (obj == hour_btn) {
+ data->time[TIME_HOUR]--;
+ _update_time_value(obj, data->time, TIME_HOUR);
+ } else if (obj == minute_btn) {
+ data->time[TIME_MINUTE]--;
+ _update_time_value(obj, data->time, TIME_MINUTE);
+ } else {
+ if (data->time[TIME_AMPM] == 0)
+ data->time[TIME_AMPM] = 1;
+ else
+ data->time[TIME_AMPM] = 0;
+
+ _update_time_value(obj, data->time, TIME_AMPM);
+ }
+ } else if (!strncmp(keyname, KEY_0, strlen(keyname)) ||
+ !strncmp(keyname, KEY_1, strlen(keyname)) ||
+ !strncmp(keyname, KEY_2, strlen(keyname)) ||
+ !strncmp(keyname, KEY_3, strlen(keyname)) ||
+ !strncmp(keyname, KEY_4, strlen(keyname)) ||
+ !strncmp(keyname, KEY_5, strlen(keyname)) ||
+ !strncmp(keyname, KEY_6, strlen(keyname)) ||
+ !strncmp(keyname, KEY_7, strlen(keyname)) ||
+ !strncmp(keyname, KEY_8, strlen(keyname)) ||
+ !strncmp(keyname, KEY_9, strlen(keyname))) {
+ if (obj == hour_btn) {
+ if (data->entry[TIME_HOUR] == 0) {
+ data->entry[TIME_HOUR]++;
+ data->time[TIME_HOUR] = atoi(keyname);
+ } else {
+ data->entry[TIME_HOUR]++;
+ data->time[TIME_HOUR] =
+ (data->time[TIME_HOUR] * 10) +
+ atoi(keyname);
+ data->entry[TIME_HOUR] = 0;
+
+ elm_object_focus_next(obj, ELM_FOCUS_NEXT);
+ }
+
+ _update_time_value(obj, data->time, TIME_HOUR);
+ } else if (obj == minute_btn) {
+ if (data->entry[TIME_MINUTE] == 0) {
+ data->entry[TIME_MINUTE]++;
+ data->time[TIME_MINUTE] = atoi(keyname);
+ } else {
+ data->entry[TIME_MINUTE]++;
+ data->time[TIME_MINUTE] =
+ (data->time[TIME_MINUTE] * 10) +
+ atoi(keyname);
+ data->entry[TIME_MINUTE] = 0;
+
+ elm_object_focus_next(obj, ELM_FOCUS_NEXT);
+ }
+
+ _update_time_value(obj, data->time, TIME_MINUTE);
+ } else {
+ return;
+ }
+ } else if (!strncmp(keyname, KEY_LEFT, strlen(keyname)) ||
+ !strncmp(keyname, KEY_RIGHT, strlen(keyname))) {
+ if (obj == hour_btn)
+ data->entry[TIME_HOUR] = 0;
+ else if (obj == minute_btn)
+ data->entry[TIME_MINUTE] = 0;
+ else
+ return;
+ } else if (!strncmp(keyname, KEY_BACK, strlen(keyname))) {
+ _destroy(data->base);
+ }
+}
+
+/**
+* Evas_Smart_Cb type callback for handling click event.
+*
+* @param[in]: priv : the user data.
+* @param[in]: obj : the corresponding object which the click event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _time_spin_click_cb(void *priv,
+ Evas_Object *obj, void *ei)
+{
+ struct _time_spin_data *data;
+
+ if (!priv)
+ return;
+
+ data = priv;
+
+ utils_set_time_value(data->time);
+ view_ug_clock_refresh(data->ug_base, NULL, data->time);
+ _destroy(data->base);
+}
+
+/**
+* Evas_Object_Event_Cb type callback for handling mouse in event.
+*
+* @param[in]: dt : the user data.
+* @param[in]: e : the evas.
+* @param[in]: obj : the corresponding object which the mouse in event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _time_spin_mousein_cb(void *dt, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ if (!obj)
+ return;
+
+ elm_object_focus_set(obj, EINA_TRUE);
+}
+
+/**
+* Evas_Object_Event_Cb type callback for handling mouse out event.
+*
+* @param[in]: dt : the user data.
+* @param[in]: e : the evas.
+* @param[in]: obj : the corresponding object which the mouse out event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _time_spin_mouseout_cb(void *dt, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ /* TODO: Add necessary operation when needed. */
+}
+
+/**
+* Evas_Smart_Cb type callback for handling click event.
+*
+* @param[in]: priv : the user data.
+* @param[in]: obj : the corresponding object which the click event occurred.
+* @param[in]: ei : event info.
+*
+* @return: void.
+*/
+static void _arrowbtn_clicked_cb(void *priv, Evas_Object *obj, void *ev)
+{
+ struct _time_spin_data *data;
+ Evas_Object *cur_btn;
+ Evas_Object *btn;
+ Evas_Object *up;
+ int i;
+ int idx;
+ int flag;
+
+ if (!priv || !obj)
+ return;
+
+ data = priv;
+ cur_btn = evas_object_data_get(obj, ARROW_BTN_DATA_ID);
+ if (!cur_btn)
+ return;
+
+ up = elm_object_part_content_get(cur_btn, UP_ARROW_SWALLOW);
+ if (!up)
+ return;
+
+ if (obj == up)
+ flag = 1;
+ else
+ flag = 0;
+
+ idx = 0;
+ for (i = TIME_HOUR; i < TIME_MAX; i++) {
+ btn = eina_array_data_get(data->spin_array, i);
+
+ if (cur_btn == btn) {
+ idx = i;
+ break;
+ }
+ }
+
+ if (idx != TIME_AMPM) {
+ if (flag)
+ data->time[idx]++;
+ else
+ data->time[idx]--;
+ } else {
+ if (data->time[idx] == 0)
+ data->time[idx] = 1;
+ else
+ data->time[idx] = 0;
+ }
+
+ _update_time_value(cur_btn, data->time, idx);
+}
+
+/**
+* Create arrow buttons for time spin.
+*
+* @param[in]: data : the user data.
+* @param[in]: obj : the corresponding object which the arrow created on.
+* @param[in]: flag : 1 - up arrow button, 0 - down arrow button.
+*
+* @return: the created arrow button.
+*/
+static Evas_Object *_add_arrow_btn(struct _time_spin_data *data,
+ Evas_Object *obj, int flag)
+{
+ Evas_Object *btn;
+
+ if (!data || !data->base || !obj)
+ return NULL;
+
+ btn = utils_add_button(data->base);
+ if (!btn) {
+ _ERR("utils add button failed.");
+ return NULL;
+ }
+
+ elm_object_style_set(btn, BTN_STYLE_ARROW_BTN);
+
+ if (flag == UP_ARROW)
+ elm_object_part_content_set(obj, UP_ARROW_SWALLOW, btn);
+ else
+ elm_object_part_content_set(obj, DOWN_ARROW_SWALLOW, btn);
+
+ elm_object_focus_allow_set(btn, EINA_FALSE);
+
+ evas_object_smart_callback_add(btn, "clicked",
+ _arrowbtn_clicked_cb, data);
+
+ evas_object_data_set(btn, ARROW_BTN_DATA_ID, obj);
+ evas_object_raise(btn);
+ evas_object_repeat_events_set(btn, EINA_FALSE);
+
+ return btn;
+}
+
+/**
+* Create time spin for 12 hour mode.
+*
+* @parma[in]: data : the user data.
+*
+* @return: 0 - Success, -1 - Fail.
+*/
+static int _add_time_spin_without_ampm(struct _time_spin_data *data)
+{
+ Evas_Object *box;
+ Evas_Object *btn;
+ Evas_Object *uparrow, *downarrow;
+ Eina_Array *array;
+ char buf[BUF_SIZE];
+ int idx;
+
+ if (!data || !data->base || !data->spin_box) {
+ _ERR("invalid argument.");
+ return -1;
+ }
+
+ box = data->spin_box;
+ elm_box_horizontal_set(box, EINA_TRUE);
+ elm_box_padding_set(box, BOX_HPADDING, BOX_VPADDING);
+
+ array = eina_array_new(1);
+ if (!array) {
+ _ERR("new eina array failed.");
+ return -1;
+ }
+
+ for (idx = TIME_HOUR; idx < TIME_AMPM; idx++) {
+ btn = utils_add_button(data->base);
+ if (!btn) {
+ _ERR("add time spin control button failed.");
+ return -1;
+ }
+
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN,
+ _time_spin_keydown_cb, data);
+ evas_object_smart_callback_add(
+ btn, "clicked", _time_spin_click_cb, data);
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN,
+ _time_spin_mousein_cb, NULL);
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_OUT,
+ _time_spin_mouseout_cb, NULL);
+
+ elm_object_style_set(btn, BTN_STYLE_TIME_SPIN_BTN);
+
+ snprintf(buf, sizeof(buf), "%02d", data->time[idx]);
+ elm_object_text_set(btn, buf);
+
+ eina_array_push(array, btn);
+
+ elm_box_pack_end(box, btn);
+
+ uparrow = _add_arrow_btn(data, btn, UP_ARROW);
+ if (!uparrow) {
+ _ERR("add up arrow button failed.");
+ evas_object_del(btn);
+ return -1;
+ }
+
+ downarrow = _add_arrow_btn(data, btn, DOWN_ARROW);
+ if (!downarrow) {
+ _ERR("add down arrow button failed.");
+ evas_object_del(btn);
+ evas_object_del(uparrow);
+ return -1;
+ }
+ }
+
+ elm_object_focus_set(eina_array_data_get(array, TIME_HOUR), EINA_TRUE);
+
+ data->spin_array = array;
+
+ elm_object_part_content_set(
+ data->base, SWALLOW_TIME_SPIN_2, box);
+
+ return 0;
+}
+
+/**
+* Create time spin for 24 hour mode.
+*
+* @parma[in]: data : the user data.
+*
+* @return: 0 - Success, -1 - Fail.
+*/
+static int _add_time_spin_with_ampm(struct _time_spin_data *data)
+{
+ Evas_Object *box;
+ Evas_Object *btn;
+ Evas_Object *uparrow, *downarrow;
+ Eina_Array *array;
+ char buf[BUF_SIZE];
+ int idx;
+
+ if (!data || !data->base || !data->spin_box) {
+ _ERR("invalid argument.");
+ return -1;
+ }
+
+ box = data->spin_box;
+ elm_box_horizontal_set(box, EINA_TRUE);
+ elm_box_padding_set(box, BOX_HPADDING, BOX_VPADDING);
+
+ array = eina_array_new(1);
+ if (!array) {
+ _ERR("new eina array failed.");
+ return -1;
+ }
+
+ for (idx = TIME_HOUR; idx < TIME_MAX; idx++) {
+ btn = utils_add_button(data->base);
+ if (!btn) {
+ _ERR("add time spin control button failed.");
+ return -1;
+ }
+
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN,
+ _time_spin_keydown_cb, data);
+ evas_object_smart_callback_add(
+ btn, "clicked", _time_spin_click_cb, data);
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_IN,
+ _time_spin_mousein_cb, NULL);
+ evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_OUT,
+ _time_spin_mouseout_cb, NULL);
+
+ elm_object_style_set(btn, BTN_STYLE_TIME_SPIN_BTN);
+
+ if (idx != TIME_AMPM) {
+ snprintf(buf, sizeof(buf), "%02d", data->time[idx]);
+ elm_object_text_set(btn, buf);
+ } else {
+ if (data->time[idx])
+ elm_object_text_set(btn, PM);
+ else
+ elm_object_text_set(btn, AM);
+ }
+
+ eina_array_push(array, btn);
+
+ elm_box_pack_end(box, btn);
+
+ uparrow = _add_arrow_btn(data, btn, UP_ARROW);
+ if (!uparrow) {
+ _ERR("add up arrow button failed.");
+ evas_object_del(btn);
+ return -1;
+ }
+
+ downarrow = _add_arrow_btn(data, btn, DOWN_ARROW);
+ if (!downarrow) {
+ _ERR("add down arrow button failed.");
+ evas_object_del(btn);
+ evas_object_del(uparrow);
+ return -1;
+ }
+ }
+
+ elm_object_focus_set(eina_array_data_get(array, TIME_HOUR), EINA_TRUE);
+
+ data->spin_array = array;
+
+ elm_object_part_content_set(
+ data->base, SWALLOW_TIME_SPIN_1, box);
+
+ return 0;
+}
+
+/**
+* Create buttons for time spin.
+*
+* @param[in]: data : the user data.
+*
+* @return: 0 - Success, -1 - Fail.
+*/
+static int _add_time_spin_btns(struct _time_spin_data *data)
+{
+ int mode;
+ int ret;
+
+ if (!data || !data->base ||
+ !data->spin_box) {
+ _ERR("invalid argument.");
+ return -1;
+ }
+
+ utils_get_time_value(data->time);
+
+ mode = 0;
+ ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &mode);
+ if (ret != 0) {
+ _ERR("vconf get value failed.");
+ return -1;
+ }
+
+ if (mode) {
+ ret = _add_time_spin_without_ampm(data);
+ if (ret != 0) {
+ _ERR("add buttons without ampm failed.");
+ return -1;
+ }
+ } else {
+ ret = _add_time_spin_with_ampm(data);
+ if (ret != 0) {
+ _ERR("add buttons with ampm failed.");
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+/**
+* Set focus move directions among time spin buttons.
+*
+* @param[in]: btn_array : eina array of time spin buttons.
+*
+* @return: void.
+*/
+static void _set_time_spin_btn_directions(Eina_Array *btn_array)
+{
+ Evas_Object *btn;
+ unsigned int count;
+ int idx;
+
+ if (!btn_array) {
+ _ERR("time spin control button array is null.");
+ return;
+ }
+
+ count = eina_array_count(btn_array);
+
+ for (idx = TIME_HOUR; idx < count; idx++) {
+ btn = eina_array_data_get(btn_array, idx);
+ if (!btn) {
+ _ERR("there is no button. idx: %d", idx);
+ return;
+ }
+
+ elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(btn, btn, ELM_FOCUS_DOWN);
+
+ if (idx == TIME_HOUR) {
+ elm_object_focus_next_object_set(btn, btn,
+ ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(btn,
+ eina_array_data_get(btn_array, idx + 1),
+ ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(btn,
+ eina_array_data_get(btn_array, idx + 1),
+ ELM_FOCUS_NEXT);
+ } else if (idx == count - 1) {
+ elm_object_focus_next_object_set(btn, btn,
+ ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(btn,
+ eina_array_data_get(btn_array, idx - 1),
+ ELM_FOCUS_LEFT);
+ } else {
+ elm_object_focus_next_object_set(btn,
+ eina_array_data_get(btn_array, idx + 1),
+ ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(btn,
+ eina_array_data_get(btn_array, idx + 1),
+ ELM_FOCUS_NEXT);
+ elm_object_focus_next_object_set(btn,
+ eina_array_data_get(btn_array, idx - 1),
+ ELM_FOCUS_LEFT);
+ }
+ }
+}
+
+/**
+* Create time spin.
+*
+* @param[in]: data : the user data.
+*
+* @return: 0 - Success, -1 - Fail.
+*/
+static int _add_time_spin(struct _time_spin_data *data)
+{
+ Evas_Object *box;
+ int ret;
+
+ if (!data || !data->base) {
+ _ERR("private data is null.");
+ return -1;
+ }
+
+ box = utils_add_box(data->base);
+ if (!box) {
+ _ERR("add time spin control box failed.");
+ return -1;
+ }
+ data->spin_box = box;
+
+ ret = _add_time_spin_btns(data);
+ if (ret != 0) {
+ _ERR("add time spin control buttons failed.");
+ return -1;
+ }
+
+ _set_time_spin_btn_directions(data->spin_array);
+
+ return 0;
+}
+
+/**
+* Create all UI components of time spin.
+*
+* @param[in]: data : the user data.
+*
+* @return: the base layout of time spin.
+*/
+static Evas_Object *_create(struct _time_spin_data *data)
+{
+ Evas_Object *base;
+ int onoff;
+ int ret;
+
+ if (!data || !data->win) {
+ _ERR("window for time spin control base is null.");
+ return NULL;
+ }
+
+ base = utils_add_layout(data->win);
+ if (!base) {
+ _ERR("add base layout for spin control failed.");
+ return NULL;
+ }
+ data->base = base;
+ elm_layout_file_set(base, UG_CLOCK_EDJFILE, TIME_SPIN_CTRL_GRP);
+
+ onoff = 0;
+ ret = utils_get_vconf_value(VCONF_KEY_24HOUR_MODE, &onoff);
+ if (ret != 0) {
+ _ERR("vconf get value failed.");
+ return NULL;
+ }
+
+ if (onoff)
+ elm_object_signal_emit(base, SIGNAL_NAME_TIME_SPIN_2,
+ SIGNAL_SOURCE_TIME_SPIN);
+ else
+ elm_object_signal_emit(base, SIGNAL_NAME_TIME_SPIN_1,
+ SIGNAL_SOURCE_TIME_SPIN);
+
+ ret = _add_time_spin(data);
+ if (ret != 0) {
+ _ERR("add time spin control failed.");
+ return NULL;
+ }
+
+ evas_object_data_set(data->base, TIME_SPIN_DATA_ID, data);
+
+ return base;
+}
+
+/**
+* Destroy all the UI componets of time spin.
+*
+* @param[in]: base : the base layout of time spin.
+*
+* @return: void.
+*/
+void _destroy(Evas_Object *base)
+{
+ struct _time_spin_data *data;
+
+ if (!base) {
+ _ERR("invalid argument.");
+ return;
+ }
+
+ data = evas_object_data_get(base, TIME_SPIN_DATA_ID);
+ if (!data) {
+ _ERR("evas object get data failed. ID: %s", TIME_SPIN_DATA_ID);
+ return;
+ }
+
+ _free_time_spin_data(data);
+}
+
+/**
+* Entry of creating time spin UI.
+*
+* @param[in]: win : window.
+* @param[in]: ug_base : the base layout of clock UI gadget.
+*
+* @return: void.
+*/
+void view_time_spin_ctrl_create(Evas_Object *win,
+ Evas_Object *ug_base)
+{
+ Evas_Object *base;
+ struct _time_spin_data *data;
+
+ if (!win || !ug_base) {
+ _ERR("the window of time spin control is null.");
+ return;
+ }
+
+ data = calloc(1, sizeof(*data));
+ if (!data) {
+ _ERR("calloc time spin control data memory failed.");
+ return;
+ }
+
+ data->win = win;
+ data->ug_base = ug_base;
+
+ base = _create(data);
+ if (!base) {
+ _ERR("create time spin control failed.");
+ _free_time_spin_data(data);
+ }
+}
diff --git a/ug/system/clock/src/util.cpp b/ug/system/clock/src/ug_clock_utils.c
index 795a27c..4cb0969 100644
--- a/ug/system/clock/src/util.cpp
+++ b/ug/system/clock/src/ug_clock_utils.c
@@ -17,8 +17,8 @@
#include <vconf.h>
#include <sysman_managed.h>
-#include <MacroDefine.h>
-#include "util.h"
+#include "dbg.h"
+#include "ug_clock_utils.h"
static struct tm *_get_current_time();
static void _set_datetime(struct tm *t);
@@ -257,7 +257,7 @@ int utils_set_vconf_value(const char *key, int value)
return -1;
}
- ret = vconf_set_int((char*) key, value);
+ ret = vconf_set_int(key, value);
if (ret != 0) {
_ERR("vconf set int failed.");
return -1;
@@ -283,7 +283,7 @@ int utils_get_vconf_value(const char *key, int *value)
return -1;
}
- ret = vconf_get_int((char*)key, value);
+ ret = vconf_get_int(key, value);
if (ret != 0) {
_ERR("vconf get int failed.");
return -1;
@@ -302,13 +302,11 @@ int utils_get_vconf_value(const char *key, int *value)
static struct tm *_get_current_time()
{
time_t tt;
- struct tm *t = NULL;
+ struct tm *t;
tt = 0;
time(&tt);
- /* FIXME: memory of *t is not allocated ?? */
-
t = localtime(&tt);
return t;
diff --git a/ug/wifi-direct/CMakeLists.txt b/ug/wifi-direct/CMakeLists.txt
index e6717bd..6e427e9 100644
--- a/ug/wifi-direct/CMakeLists.txt
+++ b/ug/wifi-direct/CMakeLists.txt
@@ -25,6 +25,7 @@ SET(UG_WIFI_DIRECT_EDJ_THEME "ug-wifi-direct-theme.edj")
INCLUDE(FindPkgConfig)
pkg_check_modules(UG_WIFI_DIRECT_PKGS REQUIRED
+ dlog
eina
edje
evas
@@ -38,6 +39,8 @@ pkg_check_modules(UG_WIFI_DIRECT_PKGS REQUIRED
capi-network-connection
wifi-direct
)
+ #ecore-x
+
SET(PKGS_LDFLAGS "${PKGS_LDFLAGS} ${UG_WIFI_DIRECT_PKGS_LDFLAGS}")
FOREACH(FLAG ${UG_WIFI_DIRECT_PKGS_CFLAGS})
@@ -47,17 +50,13 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fvisibility=hidden -Wall -W
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
SET(SRCS
- src/ug_wifi_direct.cpp
- src/WifiDirectMainView.cpp
- src/util.cpp
- ../src/WifiMgr.cpp
- ../src/WifiDirectMgr.cpp
+ src/ug_wifi_direct.c
+ src/wifi_direct_mgr.c
+ src/wifi_direct_view.c
+ src/util.c
)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../include)
-
ADD_DEFINITIONS("-DPKGNAME=\"${PROJECT_NAME}\"")
ADD_DEFINITIONS("-DUG_WIFI_DIRECT_EDJ_FILE=\"${UG_WIFI_DIRECT_EDJE_DIR}/${UG_WIFI_DIRECT_EDJ_FILE}\"")
diff --git a/ug/wifi-direct/edje/images/ico_dropdown_menu_check.png b/ug/wifi-direct/edje/images/ico_dropdown_menu_check.png
index d32061e..9e7d114 100644
--- a/ug/wifi-direct/edje/images/ico_dropdown_menu_check.png
+++ b/ug/wifi-direct/edje/images/ico_dropdown_menu_check.png
Binary files differ
diff --git a/ug/wifi-direct/edje/images/loading_96_01.png b/ug/wifi-direct/edje/images/loading_96_01.png
index 5cf78be..f8023c6 100644
--- a/ug/wifi-direct/edje/images/loading_96_01.png
+++ b/ug/wifi-direct/edje/images/loading_96_01.png
Binary files differ
diff --git a/ug/wifi-direct/edje/images/loading_96_02.png b/ug/wifi-direct/edje/images/loading_96_02.png
index 3dad5ff..c9c3cfa 100644
--- a/ug/wifi-direct/edje/images/loading_96_02.png
+++ b/ug/wifi-direct/edje/images/loading_96_02.png
Binary files differ
diff --git a/ug/wifi-direct/edje/images/loading_96_03.png b/ug/wifi-direct/edje/images/loading_96_03.png
index 982c520..c4044c0 100644
--- a/ug/wifi-direct/edje/images/loading_96_03.png
+++ b/ug/wifi-direct/edje/images/loading_96_03.png
Binary files differ
diff --git a/ug/wifi-direct/edje/images/loading_96_04.png b/ug/wifi-direct/edje/images/loading_96_04.png
index 6a98e2d..66be9d6 100644
--- a/ug/wifi-direct/edje/images/loading_96_04.png
+++ b/ug/wifi-direct/edje/images/loading_96_04.png
Binary files differ
diff --git a/ug/wifi-direct/edje/images/loading_96_05.png b/ug/wifi-direct/edje/images/loading_96_05.png
index 88310dd..1ac21a0 100644
--- a/ug/wifi-direct/edje/images/loading_96_05.png
+++ b/ug/wifi-direct/edje/images/loading_96_05.png
Binary files differ
diff --git a/ug/wifi-direct/edje/images/loading_96_06.png b/ug/wifi-direct/edje/images/loading_96_06.png
index 4244260..c6b7baa 100644
--- a/ug/wifi-direct/edje/images/loading_96_06.png
+++ b/ug/wifi-direct/edje/images/loading_96_06.png
Binary files differ
diff --git a/ug/wifi-direct/edje/images/loading_96_07.png b/ug/wifi-direct/edje/images/loading_96_07.png
index ce85169..8e0c7d4 100644
--- a/ug/wifi-direct/edje/images/loading_96_07.png
+++ b/ug/wifi-direct/edje/images/loading_96_07.png
Binary files differ
diff --git a/ug/wifi-direct/edje/images/loading_96_08.png b/ug/wifi-direct/edje/images/loading_96_08.png
index a1a5f49..722669f 100644
--- a/ug/wifi-direct/edje/images/loading_96_08.png
+++ b/ug/wifi-direct/edje/images/loading_96_08.png
Binary files differ
diff --git a/ug/wifi-direct/edje/images/loading_96_09.png b/ug/wifi-direct/edje/images/loading_96_09.png
index 095f3a9..ef0900e 100644
--- a/ug/wifi-direct/edje/images/loading_96_09.png
+++ b/ug/wifi-direct/edje/images/loading_96_09.png
Binary files differ
diff --git a/ug/wifi-direct/edje/images/loading_96_10.png b/ug/wifi-direct/edje/images/loading_96_10.png
index e213401..0c5528c 100644
--- a/ug/wifi-direct/edje/images/loading_96_10.png
+++ b/ug/wifi-direct/edje/images/loading_96_10.png
Binary files differ
diff --git a/ug/wifi-direct/edje/images/loading_96_11.png b/ug/wifi-direct/edje/images/loading_96_11.png
index dd77fa8..41ef66f 100644
--- a/ug/wifi-direct/edje/images/loading_96_11.png
+++ b/ug/wifi-direct/edje/images/loading_96_11.png
Binary files differ
diff --git a/ug/wifi-direct/edje/images/loading_96_12.png b/ug/wifi-direct/edje/images/loading_96_12.png
index 4d0c76c..30f29e0 100644
--- a/ug/wifi-direct/edje/images/loading_96_12.png
+++ b/ug/wifi-direct/edje/images/loading_96_12.png
Binary files differ
diff --git a/ug/wifi-direct/edje/images/loading_96_13.png b/ug/wifi-direct/edje/images/loading_96_13.png
index d878419..2e38a95 100644
--- a/ug/wifi-direct/edje/images/loading_96_13.png
+++ b/ug/wifi-direct/edje/images/loading_96_13.png
Binary files differ
diff --git a/ug/wifi-direct/edje/images/loading_96_14.png b/ug/wifi-direct/edje/images/loading_96_14.png
index af6e449..e648437 100644
--- a/ug/wifi-direct/edje/images/loading_96_14.png
+++ b/ug/wifi-direct/edje/images/loading_96_14.png
Binary files differ
diff --git a/ug/wifi-direct/edje/images/loading_96_15.png b/ug/wifi-direct/edje/images/loading_96_15.png
index 21e36f5..a3f80e6 100644
--- a/ug/wifi-direct/edje/images/loading_96_15.png
+++ b/ug/wifi-direct/edje/images/loading_96_15.png
Binary files differ
diff --git a/ug/wifi-direct/edje/images/loading_96_16.png b/ug/wifi-direct/edje/images/loading_96_16.png
index 7504c97..9596a3a 100644
--- a/ug/wifi-direct/edje/images/loading_96_16.png
+++ b/ug/wifi-direct/edje/images/loading_96_16.png
Binary files differ
diff --git a/ug/wifi-direct/edje/images/loading_96_17.png b/ug/wifi-direct/edje/images/loading_96_17.png
index 260f1e7..5f93920 100644
--- a/ug/wifi-direct/edje/images/loading_96_17.png
+++ b/ug/wifi-direct/edje/images/loading_96_17.png
Binary files differ
diff --git a/ug/wifi-direct/edje/images/loading_96_18.png b/ug/wifi-direct/edje/images/loading_96_18.png
index 76c4cff..9d44952 100644
--- a/ug/wifi-direct/edje/images/loading_96_18.png
+++ b/ug/wifi-direct/edje/images/loading_96_18.png
Binary files differ
diff --git a/ug/wifi-direct/edje/images/round_rectangle_4X4.png b/ug/wifi-direct/edje/images/round_rectangle_4X4.png
index b0c09a8..5a1f51d 100644
--- a/ug/wifi-direct/edje/images/round_rectangle_4X4.png
+++ b/ug/wifi-direct/edje/images/round_rectangle_4X4.png
Binary files differ
diff --git a/ug/wifi-direct/edje/images/second_depth_bg.png b/ug/wifi-direct/edje/images/second_depth_bg.png
index 602e272..5b3c624 100644
--- a/ug/wifi-direct/edje/images/second_depth_bg.png
+++ b/ug/wifi-direct/edje/images/second_depth_bg.png
Binary files differ
diff --git a/ug/wifi-direct/include/WifiDirectMainView.h b/ug/wifi-direct/include/WifiDirectMainView.h
deleted file mode 100644
index 69c1f2b..0000000
--- a/ug/wifi-direct/include/WifiDirectMainView.h
+++ /dev/null
@@ -1,81 +0,0 @@
-#ifndef __WIFI_DIRECT_MAIN_VIEW_H__
-#define __WIFI_DIRECT_MAIN_VIEW_H__
-
-#include "UgCommon.h"
-#include "wifi-direct.h"
-
-class CWifiDirectMainView : public CBaseView, public IMouseClickedListener, public IUnfocusedListener {
-private :
- struct SWifiDirectMainView *m;
-
- static void sm_CbDeviceStateChanged(int errcode, wifi_direct_device_state_e state, void *data);
- static void sm_CbDiscoveryStateChanged(int errcode, wifi_direct_discovery_state_e state, void *data);
- void m_OnDiscoveryStateChanged(int errcode, wifi_direct_discovery_state_e state);
-
- static void sm_CbConnectionStateChanged(int errcode, wifi_direct_connection_state_e state, const char *addr, void *data);
- void m_OnConnectionStateChanged(int errcode, wifi_direct_connection_state_e state, const char *addr);
-
- static bool sm_CbConnectedPeers(wifi_direct_connected_peer_info_s *conn_info, void *data);
- bool m_OnConnectedPeers(wifi_direct_connected_peer_info_s *conn_info);
-
- static bool sm_CbDiscoverdPeers(wifi_direct_discovered_peer_info_s * discov_info, void *data);
- bool m_OnDiscoverdPeers(wifi_direct_discovered_peer_info_s * discov_info);
-
- static char *sm_GetItemLabel(void *data, Evas_Object *obj, const char *part);
-
- static Eina_Bool sm_CbConnectionInd(void *data);
-
- static void sm_CbGenlistItemSelected(void *data, Evas_Object *obj, void *event_info);
- void m_OnGenlistItemSelected(Evas_Object *obj, void *event_info);
-
- bool m_WifiDirectInit(void);
- bool m_RegisterWifiDirectCallback(void);
- void m_UnRegisterWifiDirectCallback(void);
- bool m_CreateButton(void);
- bool m_CreateGenlist(void);
- bool m_CreateActionBtns(void);
- bool m_CreateDeviceListView(void);
- void m_FillContentPart(Evas_Object *obj);
- bool m_DisplayDisconnect(void);
- bool m_CreateDisconnectPart(void);
- void m_RefreshOnText(void);
-
- void m_ProcessDiscoveryStart(void);
- void m_ProcessDiscoveryFound(void);
- void m_ProcessDiscoveryFinish(void);
-
- void m_ProcessConnectionReq(const char *addr);
- void m_ProcessConnectionProg(void);
- void m_ProcessConnectionRsp(void);
- void m_ProcessConnectionInd(void);
-
- bool m_CreateWifiDirectScan(void);
- void m_ShowActionBtn(void);
- bool m_UpdateGenlistItem(device_info *info);
-
- bool m_IsPeerExist(device_info *info);
- bool m_CreateReqPopupLayout(void);
- bool m_UpdateDeviceConnState(bool conn);
- bool m_WifiDirectCbBtnConnect(device_info *info, int is_conn);
- bool m_CreateWifiDirectDim(void);
-
-protected :
- virtual void t_OnShow(void);
- virtual void t_OnUpdate(void *data);
- virtual void t_OnHide(void);
-
-public :
- CWifiDirectMainView(const char *szViewId) : CBaseView(szViewId), IMouseClickedListener(this), IUnfocusedListener(this), m(0) {}
- virtual ~CWifiDirectMainView() {}
-
- virtual bool Create(void *data);
- virtual void Destroy(void);
- virtual Evas_Object* Base(void);
-
- virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev);
- virtual void OnMouseClicked(int id, Evas_Object *obj);
- virtual void OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item);
-};
-
-#endif /* __WIFI_DIRECT_MAIN_VIEW_H__ */
-
diff --git a/ug/wifi-direct/include/dbg.h b/ug/wifi-direct/include/dbg.h
new file mode 100644
index 0000000..0e63b49
--- /dev/null
+++ b/ug/wifi-direct/include/dbg.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __DBG_H__
+
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "ug-wifi-direct"
+
+#ifndef _ERR
+#define _ERR(fmt, args...) LOGE("[%s:%d] "fmt"\n", __func__, __LINE__, ##args)
+#endif
+
+#ifndef _DBG
+#define _DBG(fmt, args...) LOGD("[%s:%d] "fmt"\n", __func__, __LINE__, ##args)
+#endif
+
+#ifndef _INFO
+#define _INFO(fmt, args...) LOGI("[%s:%d] "fmt"\n", __func__, __LINE__, ##args)
+#endif
+
+#endif /* __DBG_H__ */
diff --git a/ug/wifi-direct/include/defs.h b/ug/wifi-direct/include/defs.h
index 48db63a..a40c295 100644
--- a/ug/wifi-direct/include/defs.h
+++ b/ug/wifi-direct/include/defs.h
@@ -37,9 +37,6 @@
#define ELM_SCALE elm_config_scale_get()
-/* View */
-#define WIFI_DIRECT_MAINVIEW "WIFI_DIRECT_MAINVIEW"
-
/*GROUP*/
#define GRP_MAIN "main_view"
#define GRP_WIFI_DIRECT_SELECT "grp_wifi_direct_select"
@@ -94,4 +91,22 @@
#define SIG_CLICKED "clicked"
#define SIG_BTN_SELECTED "btn,selected"
+/* Key defines */
+#define KEY_UP "Up"
+#define KEY_DOWN "Down"
+#define KEY_LEFT "Left"
+#define KEY_RIGHT "Right"
+#define KEY_EXIT "XF86Close"
+
+#define KEY_0 "0"
+#define KEY_1 "1"
+#define KEY_2 "2"
+#define KEY_3 "3"
+#define KEY_4 "4"
+#define KEY_5 "5"
+#define KEY_6 "6"
+#define KEY_7 "7"
+#define KEY_8 "8"
+#define KEY_9 "9"
+
#endif /* __DEFS_H__ */
diff --git a/ug/wifi-direct/include/util.h b/ug/wifi-direct/include/util.h
index 871e775..1de093a 100644
--- a/ug/wifi-direct/include/util.h
+++ b/ug/wifi-direct/include/util.h
@@ -17,10 +17,13 @@
#ifndef __UTIL_H__
#define __UTIL_H__
-Evas_Object *util_add_layout(Evas_Object *parent, const char *file, const char *group);
-Evas_Object *util_add_button(Evas_Object *parent, const char *style, const char *part, const char *text);
+Evas_Object *util_add_layout(Evas_Object *parent, const char *file,
+ const char *group);
+Evas_Object *util_add_button(Evas_Object *parent, const char *style,
+ const char *part, const char *text);
Evas_Object *util_add_box(Evas_Object *parent, const char *part);
-Evas_Object *util_add_progressbar(Evas_Object *parent, const char *style, const char *part);
+Evas_Object *util_add_progressbar(Evas_Object *parent,
+ const char *style, const char *part);
void util_set_cycle_focus(Evas_Object **obj, int count);
#endif /* __UTIL_H__ */
diff --git a/ug/wifi-direct/include/wifi_direct_mgr.h b/ug/wifi-direct/include/wifi_direct_mgr.h
new file mode 100644
index 0000000..d448ed4
--- /dev/null
+++ b/ug/wifi-direct/include/wifi_direct_mgr.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_DIRECT_MGR_H__
+#define __WIFI_DIRECT_MGR_H__
+
+#include "defs.h"
+#include <wifi.h>
+#include <net_connection.h>
+#include <wifi-direct.h>
+#include <Elementary.h>
+#include <Eina.h>
+
+#define WIFI_DIRECT_DISCOVERY_LISTEN_AND_SCAN 0
+#define WIFI_DIRECT_SCAN_TIMEOUT 3
+
+struct device_info {
+ char dev_name[WIFI_DIRECT_DEFAULT_BUF_LEN];
+ char mac_addr[WIFI_DIRECT_DEFAULT_BUF_LEN];
+ Eina_Bool is_conn;
+ int wps_types;
+ char wps_pin[WIFI_DIRECT_STATE_BUF_LEN];
+ char state[WIFI_DIRECT_STATE_BUF_LEN];
+};
+
+struct discovered_device_info {
+ char mac_addr[WIFI_DIRECT_DEFAULT_BUF_LEN];
+ int conn_status;
+ int wps_types;
+ char wps_pin[WIFI_DIRECT_STATE_BUF_LEN];
+};
+
+struct wifi_direct_cbs {
+ wifi_direct_device_state_changed_cb device_state_cb;
+ wifi_direct_discovery_state_chagned_cb discovery_state_cb;
+ wifi_direct_connection_state_changed_cb connection_state_cb;
+ wifi_direct_connected_peer_cb connected_peer_cb;
+ wifi_direct_discovered_peer_cb discovered_peer_cb;
+};
+
+const char *wifi_direct_mgr_err_dbg(int errcode);
+char *wifi_direct_mgr_get_device_name(void);
+char *wifi_direct_mgr_get_mac_address(void);
+int wifi_direct_mgr_register_callback(struct wifi_direct_cbs *cbs,
+ void *data);
+int wifi_direct_mgr_unregister_callback(void);
+int wifi_direct_mgr_wifi_init(void);
+int wifi_direct_mgr_wifi_fini(void);
+int wifi_direct_mgr_wifi_direct_init(void);
+int wifi_direct_mgr_wifi_direct_fini(void);
+int wifi_direct_mgr_get_state(wifi_direct_state_e *status);
+int wifi_direct_mgr_activate(void);
+int wifi_direct_mgr_deactivate(void);
+int wifi_direct_mgr_set_configure_num(void);
+int wifi_direct_mgr_foreach_discovered_peers(
+ wifi_direct_discovered_peer_cb cb, void *data);
+int wifi_direct_mgr_foreach_connected_peers(
+ wifi_direct_connected_peer_cb cb, void *data);
+int wifi_direct_mgr_start_discovery(void);
+int wifi_direct_mgr_cancel_discovery(void);
+int wifi_direct_mgr_connect(const char *mac_addr);
+int wifi_direct_mgr_disconnect(const char *mac_addr);
+int wifi_direct_mgr_reject_connection(const char *mac_addr);
+int wifi_direct_mgr_accept_connection(char *mac_addr);
+int wifi_direct_mgr_get_wps_type(Eina_Bool *is_pbc);
+int wifi_direct_mgr_set_wps_type(wifi_direct_wps_type_e *type);
+
+#endif /* __WIFI_DIRECT_MGR_H__ */
diff --git a/ug/wifi-direct/include/wifi_direct_view.h b/ug/wifi-direct/include/wifi_direct_view.h
new file mode 100644
index 0000000..1fb28b4
--- /dev/null
+++ b/ug/wifi-direct/include/wifi_direct_view.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __WIFI_DIRECT_VIEW_H__
+#define __WIFI_DIRECT_VIEW_H__
+
+#include <Elementary.h>
+#include <ui-gadget-module.h>
+
+Evas_Object *wifi_direct_view_create(Evas_Object *win, ui_gadget_h ug);
+
+#endif /* __WIFI_DIRECT_VIEW_H__ */
diff --git a/ug/wifi-direct/src/WifiDirectMainView.cpp b/ug/wifi-direct/src/WifiDirectMainView.cpp
deleted file mode 100644
index 2a230f1..0000000
--- a/ug/wifi-direct/src/WifiDirectMainView.cpp
+++ /dev/null
@@ -1,1553 +0,0 @@
-#include <ui-gadget-module.h>
-#include "defs.h"
-#include <AppCommon.h>
-#include "util.h"
-
-#include "WifiDirectMgr.h"
-
-
-#include "WifiDirectMainView.h"
-
-const char *action_button[] = {
- TXT_REFRESH_BTN,
- TXT_CLOSE_BTN,
- TXT_STOP_BTN
-};
-
-const char *popup_button_on[] = {
- TXT_ON_BTN,
- TXT_OFF_BTN
-};
-
-static const char *popup_button_conn[] = {
- TXT_CONNECT,
- TXT_DISCONNECT
-};
-
-static const char *popup_button_req[] = {
- TXT_YES,
- TXT_NO
-};
-
-static const char *part_req[] = {
- PART_YES,
- PART_NO
-};
-
-enum action_btn_enum {
- ACTION_BTN_REFRESH,
- ACTION_BTN_CLOSE,
- ACTION_BTN_STOP
-};
-enum direct_swith_enum {
- DIRECT_ON = 0,
- DIRECT_OFF
-};
-
-struct SWifiDirectMainView {
- ui_gadget_h ug;
-
- Evas_Object *win;
- Evas_Object *base;
- Evas_Object *genlist;
- Evas_Object *on_btn;
- Evas_Object *direct_popup;
- Evas_Object *connect_popup;
- Evas_Object *dim_ly;
- Evas_Object *btn_refresh;
- Evas_Object *btn_close;
- Evas_Object *btn_stop;
- Evas_Object *scan_ly;
- Evas_Object *scan_pb;
- Evas_Object *no_conn_ly;
- Evas_Object *prog_popup;
- Evas_Object *req_popup;
-
- Elm_Genlist_Item_Class *itc;
- Elm_Object_Item *popup_item;
- Eina_List *item_list;
- Ecore_Timer *timer;
-
- int conn_idx;
- int direct_on_flag;
- int finish_flag;
- char *req_addr;
-
-
- CViewMgr *pViewMgr;
- CWifiDirectMgr *pWifiDirectMgr;
-};
-
-
-void CWifiDirectMainView::sm_CbDeviceStateChanged(int errcode, wifi_direct_device_state_e state, void *data)
-{
- bool ret = false;
- SWifiDirectMainView *m;
-
- if (!data) {
- _ERR("The param is invalid.");
- return;
- }
-
- m = (SWifiDirectMainView *) data;
-
- if (state != WIFI_DIRECT_DEVICE_STATE_ACTIVATED) {
- elm_genlist_clear(m->genlist);
- return;
- }
-
- ret = m->pWifiDirectMgr->SetMaxClient();
- if (ret != true) {
- _ERR("set configure num failed.");
- return;
- }
-
- ret = m->pWifiDirectMgr->StartDiscovery();
- if (ret != true)
- _ERR("start discovery failed.");
-}
-
-
-void CWifiDirectMainView::sm_CbDiscoveryStateChanged(int errcode, wifi_direct_discovery_state_e state, void *data)
-{
- CWifiDirectMainView *instance = NULL;
-
- if (!state || !data) {
- _ERR("data is invalid.");
- return;
- }
-
- instance = (CWifiDirectMainView *) data;
- instance->m_OnDiscoveryStateChanged(errcode, state);
-}
-
-
-void CWifiDirectMainView::m_OnDiscoveryStateChanged(int errcode, wifi_direct_discovery_state_e state)
-{
- switch (state) {
- case WIFI_DIRECT_DISCOVERY_STARTED:
- m_ProcessDiscoveryStart();
- break;
- case WIFI_DIRECT_DISCOVERY_FOUND:
- m_ProcessDiscoveryFound();
- break;
- case WIFI_DIRECT_DISCOVERY_FINISHED:
- m_ProcessDiscoveryFinish();
- break;
- default:
- break;
- }
-}
-
-
-void CWifiDirectMainView::sm_CbConnectionStateChanged(int errcode, wifi_direct_connection_state_e state, const char *addr, void *data)
-{
- CWifiDirectMainView *instance = NULL;
-
- if (!state || !data) {
- _ERR("data is invalid.");
- return;
- }
-
- instance = (CWifiDirectMainView *) data;
- instance->m_OnConnectionStateChanged(errcode, state, addr);
-}
-
-
-void CWifiDirectMainView::m_OnConnectionStateChanged(int errcode, wifi_direct_connection_state_e state, const char *addr)
-{
- if (!state || !addr) {
- _ERR("The param is invalid.");
- return;
- }
-
- switch (state) {
- case WIFI_DIRECT_CONNECTION_REQ:
- m_ProcessConnectionReq(addr);
- break;
- case WIFI_DIRECT_CONNECTION_IN_PROGRESS:
- m_ProcessConnectionProg();
- break;
- case WIFI_DIRECT_CONNECTION_RSP:
- m_ProcessConnectionRsp();
- break;
- case WIFI_DIRECT_DISCONNECTION_IND:
- m_ProcessConnectionInd();
- break;
- default:
- break;
- }
-}
-
-
-bool CWifiDirectMainView::sm_CbConnectedPeers(wifi_direct_connected_peer_info_s *conn_info, void *data)
-{
- CWifiDirectMainView *instance = NULL;
-
- if (!data) {
- _ERR("data is invalid.");
- return false;
- }
-
- instance = (CWifiDirectMainView *) data;
- return instance->m_OnConnectedPeers(conn_info);
-}
-
-
-bool CWifiDirectMainView::m_OnConnectedPeers(wifi_direct_connected_peer_info_s *conn_info)
-{
- struct device_info *info;
- bool ret = false;
-
- if (!conn_info) {
- _ERR("The param is NULL.");
- return false;
- }
-
- info = (struct device_info *) calloc(1, sizeof(*info));
- if (!info) {
- _ERR("calloc failed.");
- return false;
- }
-
- strncpy(info->dev_name, conn_info->device_name, WIFI_DIRECT_DEFAULT_BUF_LEN);
- strncpy(info->mac_addr, conn_info->mac_address, WIFI_DIRECT_DEFAULT_BUF_LEN);
- info->is_conn = true;
-
- ret = m_UpdateGenlistItem(info);
- if (ret != true) {
- _ERR("update genlist view failed.");
- free(info);
- return false;
- }
-
- return true;
-}
-
-
-bool CWifiDirectMainView::sm_CbDiscoverdPeers(wifi_direct_discovered_peer_info_s * discov_info, void *data)
-{
- CWifiDirectMainView *instance = NULL;
-
- if (!data) {
- _ERR("data is invalid.");
- return false;
- }
-
- instance = (CWifiDirectMainView *) data;
- instance->m_OnDiscoverdPeers(discov_info);
- return true;
-}
-
-
-bool CWifiDirectMainView::m_OnDiscoverdPeers(wifi_direct_discovered_peer_info_s * discov_info)
-{
- struct device_info *info;
- bool ret = false;
-
- if (!discov_info) {
- _ERR("The param is invalid.");
- return false;
- }
-
- info = (struct device_info *) calloc(1, sizeof(*info));
- if (!info) {
- _ERR("calloc failed.");
- return false;
- }
-
- strncpy(info->dev_name, discov_info->device_name, WIFI_DIRECT_DEFAULT_BUF_LEN);
- strncpy(info->mac_addr, discov_info->mac_address, WIFI_DIRECT_DEFAULT_BUF_LEN);
- info->is_conn = (Eina_Bool) discov_info->is_connected;
- info->wps_types = discov_info->supported_wps_types;
-
- ret = m_UpdateGenlistItem(info);
- if (ret != true) {
- _ERR("update genlist view failed.");
- free(info);
- return false;
- }
-
- return true;
-}
-
-
-char *CWifiDirectMainView::sm_GetItemLabel(void *data, Evas_Object *obj, const char *part)
-{
- struct device_info *info;
- char buf_name[WIFI_DIRECT_DEFAULT_BUF_LEN];
-
- if (!data) {
- _ERR("data is NULL.");
- return NULL;
- }
-
- info = (struct device_info *) data;
-
- memset(&buf_name, 0x00, WIFI_DIRECT_DEFAULT_BUF_LEN);
- if (!strcmp(part, TXT_ELM_TEXT)) {
- strncpy(buf_name, info->dev_name, WIFI_DIRECT_HALF_BUF_LEN);
- strncat(buf_name, TXT_COLON, WIFI_DIRECT_COLON_LEN);
- strncat(buf_name, info->state, WIFI_DIRECT_HALF_BUF_LEN);
-
- return strdup(buf_name);
- }
-
- return NULL;
-}
-
-
-void CWifiDirectMainView::t_OnShow()
-{
- _DBG();
-
- evas_object_show(m->base);
-
- CBaseView::t_OnShow();
-}
-
-
-void CWifiDirectMainView::t_OnUpdate(void *data)
-{
- _DBG();
-
- evas_object_show(m->base);
-}
-
-
-void CWifiDirectMainView::t_OnHide()
-{
- _DBG();
-
- evas_object_hide(m->base);
-
- CBaseView::t_OnHide();
-}
-
-
-Eina_Bool CWifiDirectMainView::sm_CbConnectionInd(void *data)
-{
- bool ret = false;
- SWifiDirectMainView *m;
-
- if (!data) {
- _ERR("the param is invalid.");
- return ECORE_CALLBACK_CANCEL;
- }
-
- m = (SWifiDirectMainView *) data;
-
- ret = m->pWifiDirectMgr->StartDiscovery();
- if (ret != true)
- _ERR("start discovery failed.");
-
- m->timer = NULL;
-
- return ECORE_CALLBACK_CANCEL;
-}
-
-
-void CWifiDirectMainView::sm_CbGenlistItemSelected(void *data, Evas_Object *obj, void *event_info)
-{
- CWifiDirectMainView *instance = NULL;
-
- if (!data) {
- _ERR("data is invalid.");
- return;
- }
-
- instance = (CWifiDirectMainView *) data;
- instance->m_OnGenlistItemSelected(obj, event_info);
-}
-
-
-void CWifiDirectMainView::m_OnGenlistItemSelected(Evas_Object *obj, void *event_info)
-{
- Elm_Object_Item *gen_item;
- Evas_Object *layout, *box, *item_btn;
- Evas_Object *btn[BTN_DIRECT];
- struct device_info *info;
- int cur_idx;
- int i;
- bool ret = false;
- int btn_x, btn_y, btn_w, btn_h;
- int move_x, move_y;
-
- if (!obj || !event_info) {
- _ERR("The param is invalid.");
- return;
- }
-
- if (!m->dim_ly) {
- ret = m_CreateWifiDirectDim();
- if (ret != true) {
- Destroy();
- return;
- }
- }
-
- evas_object_show(m->dim_ly);
-
- gen_item = (Elm_Object_Item *) event_info;
- m->popup_item = gen_item;
-
- layout = util_add_layout(m->base, UG_WIFI_DIRECT_EDJ_FILE, GRP_WIFI_DIRECT_SELECT);
- if (!layout) {
- _ERR("add connect popup failed.");
- return;
- }
-
- box = util_add_box(layout, PART_SWALLOW_CONTENT);
- if (!box) {
- _ERR("add box failed.");
- evas_object_del(layout);
- return;
- }
-
- for (i = 0; i < BTN_DIRECT; i++) {
- btn[i] = util_add_button(box, STYLE_POPUP_BUTTON, NULL, _(popup_button_conn[i]));
- if (!btn[i]) {
- _ERR("add connect btn failed.");
- evas_object_del(layout);
- return;
- }
-
- elm_box_pack_end(box, btn[i]);
-#if 0
- evas_object_event_callback_add(btn[i], EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv);
-#endif
- }
- //evas_object_smart_callback_add(btn[i], SIG_CLICKED, _item_conn_btn_clicked_cb, priv);
- Connect(btn[0], 13);
- Connect(btn[1], 14);
-
- cur_idx = elm_genlist_item_index_get(gen_item);
- if (cur_idx < 0)
- return;
-
- info = (struct device_info *) eina_list_nth(m->item_list, cur_idx);
- if (!info)
- return;
-
- if (info->is_conn)
- elm_object_signal_emit(btn[DIRECT_ON], SIG_BTN_SELECTED, PROG);
- else
- elm_object_signal_emit(btn[DIRECT_OFF], SIG_BTN_SELECTED, PROG);
-
- util_set_cycle_focus(btn, BTN_DIRECT);
-
- item_btn = elm_object_item_track(gen_item);
- if (!item_btn) {
- _ERR("get genlist item track failed.");
- evas_object_del(layout);
- return;
- }
-
- evas_object_geometry_get(item_btn, &btn_x, &btn_y, &btn_w, &btn_h);
-
- move_x = btn_x + btn_w - POPUP_WIDTH * HALF_SCALE - POPUP_RIGHT;
- move_y = btn_y + btn_h;
- evas_object_move(layout, move_x * ELM_SCALE, move_y * ELM_SCALE);
- m->connect_popup = layout;
-
- //evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN, _popup_back_pressed_cb, priv);
- Connect(layout, 15);
-
- elm_object_focus_set(btn[0], EINA_TRUE);
-}
-
-
-bool CWifiDirectMainView::m_WifiDirectInit(void)
-{
-
- if(!CWifiDirectMgr::Initialize()) {
- return false;
- }
-
- m->pWifiDirectMgr = NULL;
- m->pWifiDirectMgr = CWifiDirectMgr::GetInstance();
- ASSERT(m->pWifiDirectMgr);
-
- return true;
-}
-
-
-bool CWifiDirectMainView::m_RegisterWifiDirectCallback(void)
-{
- if(!m->pWifiDirectMgr->SetDeviceStateChangedCb(sm_CbDeviceStateChanged, m)) {
- return false;
- }
-
- if(!m->pWifiDirectMgr->SetDiscoveryStateChangedCb(sm_CbDiscoveryStateChanged, this)) {
- return false;
- }
-
- if(!m->pWifiDirectMgr->SetConnectionStateChangedCb(sm_CbConnectionStateChanged, this)) {
- return false;
- }
- return true;
-}
-
-
-void CWifiDirectMainView::m_UnRegisterWifiDirectCallback(void)
-{
- m->pWifiDirectMgr->UnSetConnectionStateChangedCb();
- m->pWifiDirectMgr->UnSetDiscoveryStateChangedCb();
- m->pWifiDirectMgr->UnSetDeviceStateChangedCb();
- m->pWifiDirectMgr->UnSetClientIpAddrAssignedCb();
-}
-
-
-bool CWifiDirectMainView::m_CreateButton(void)
-{
- Evas_Object *on_btn;
-
- on_btn = util_add_button(m->base, STYLE_WIFI_DIRECT_BTN, PART_WIFI_DIRECT_ON, TXT_WIFI_DIRECT);
- if (!on_btn) {
- _ERR("Add wifi direct button failed.");
- return false;
- }
-
- elm_object_focus_allow_set(on_btn, EINA_TRUE);
- elm_object_focus_set(on_btn, EINA_TRUE);
- elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_UP);
- elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_LEFT);
-
- //evas_object_smart_callback_add(on_btn, SIG_CLICKED, _wifi_direct_btn_clicked_cb, priv);
-#if 0
- evas_object_event_callback_add(on_btn, EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv);
-#endif
- Connect(m->on_btn, 1);
- m->on_btn = on_btn;
-
- m_RefreshOnText();
-
- return true;
-}
-
-
-bool CWifiDirectMainView::m_CreateGenlist(void)
-{
- Evas_Object *genlist;
- Elm_Genlist_Item_Class *itc;
-
- genlist = elm_genlist_add(m->base);
- if (!genlist) {
- _ERR("add genlist failed.");
- return false;
- }
-
- itc = elm_genlist_item_class_new();
- if (!itc) {
- _ERR("genlist item class new failed.");
- evas_object_del(genlist);
- return false;
- }
-
- m->genlist = genlist;
-
- itc->item_style = STYLE_TEXT_ICON;
- itc->func.text_get = sm_GetItemLabel;
- itc->func.content_get = NULL;
- itc->func.state_get = NULL;
- itc->func.del = NULL;
-
- m->itc = itc;
-
- evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_object_focus_next_object_set(genlist, genlist, ELM_FOCUS_LEFT);
-
- return true;
-}
-
-
-bool CWifiDirectMainView::m_CreateActionBtns(void)
-{
- Evas_Object *btn_refresh;
- Evas_Object *btn_close;
-
- btn_refresh = util_add_button(m->base, STYLE_ACTION_BUTTON, PART_REFRESH_BTN, _(action_button[ACTION_BTN_REFRESH]));
- btn_close = util_add_button(m->base, STYLE_ACTION_BUTTON, PART_CLOSE_BTN, _(action_button[ACTION_BTN_CLOSE]));
-
- m->btn_refresh = btn_refresh;
- m->btn_close = btn_close;
-
-#if 0
- evas_object_event_callback_add(m->btn_refresh, EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv);
- evas_object_event_callback_add(m->btn_close, EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv);
-#endif
- //evas_object_smart_callback_add(m->btn_refresh, SIG_CLICKED, _refresh_btn_clicked_cb, priv);
- //evas_object_smart_callback_add(m->btn_close, SIG_CLICKED, _close_btn_clicked_cb, priv);
- Connect(m->btn_refresh, 4);
- Connect(m->btn_close, 5);
-
- return true;
-}
-
-
-bool CWifiDirectMainView::m_CreateDeviceListView(void)
-{
- wifi_direct_state_e status;
- bool ret = false;
-
- if (m->no_conn_ly)
- evas_object_hide(m->no_conn_ly);
-
- ret = m->pWifiDirectMgr->GetState(&status);
- if (ret != true) {
- _ERR("get state failed.");
- return false;
- }
-
- if (status < WIFI_DIRECT_STATE_ACTIVATED) {
- ret = m->pWifiDirectMgr->Activate();
- if (ret != true) {
- _ERR("activate failed.");
- return false;
- }
- } else {
- ret = m->pWifiDirectMgr->SetMaxClient();
- if (ret != true) {
- _ERR("set configure num failed.");
- return false;
- }
-
- ret = m->pWifiDirectMgr->StartDiscovery();
- if (ret != true) {
- _ERR("start discovery failed.");
- return false;
- }
- }
-
- m_FillContentPart(m->genlist);
-
- elm_object_focus_set(m->btn_refresh, EINA_TRUE);
- return true;
-}
-
-
-void CWifiDirectMainView::m_FillContentPart(Evas_Object *obj)
-{
- Evas_Object *old_obj;
-
- old_obj = elm_object_part_content_get(m->base, PART_GENLIST_ITEMS);
- if (old_obj) {
- elm_object_part_content_unset(m->base, PART_GENLIST_ITEMS);
- evas_object_hide(old_obj);
- }
-
- elm_object_part_content_set(m->base, PART_GENLIST_ITEMS, obj);
- evas_object_show(obj);
-}
-
-
-bool CWifiDirectMainView::m_DisplayDisconnect(void)
-{
- bool ret = false;
-
- if (!m->no_conn_ly) {
- ret = m_CreateDisconnectPart();
- if (ret != true) {
- _ERR("m_CreateDisconnectPart() failed.");
- return false;
- }
- }
-
- m_FillContentPart(m->no_conn_ly);
-
- elm_object_part_content_unset(m->base, PART_REFRESH_BTN);
- evas_object_hide(m->btn_refresh);
- elm_object_part_content_set(m->base, PART_REFRESH_BTN, m->btn_close);
- evas_object_show(m->btn_close);
-
- //evas_object_smart_callback_add(m->btn_close, SIG_CLICKED, _close_btn_clicked_cb, priv);
- Connect(m->btn_close, 6);
-#if 0
- evas_object_event_callback_add(m->btn_close, EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv);
-#endif
- return true;
-}
-
-
-bool CWifiDirectMainView::m_CreateDisconnectPart(void)
-{
- Evas_Object *ly;
-
- ly = util_add_layout(m->base, UG_WIFI_DIRECT_EDJ_FILE, GRP_WIFIDIRECT_DISCONNECT_LY);
- if (!ly) {
- _ERR("Add noconnect_ly failed.");
- return false;
- }
-
- elm_object_part_text_set(ly, PART_DISCONNECT_TEXT, TXT_WIFIDIRECT_NONE);
-
- m->no_conn_ly = ly;
- evas_object_hide(ly);
-
- return true;
-}
-
-
-void CWifiDirectMainView::m_RefreshOnText(void)
-{
- if (m->scan_ly)
- evas_object_hide(m->scan_ly);
-
- if (m->direct_on_flag == DIRECT_ON)
- elm_object_part_text_set(m->on_btn, PART_WIFI_DIRECT_SELECT, _(popup_button_on[DIRECT_ON]));
- else
- elm_object_part_text_set(m->on_btn, PART_WIFI_DIRECT_SELECT, _(popup_button_on[DIRECT_OFF]));
-}
-
-
-void CWifiDirectMainView::m_ProcessDiscoveryStart(void)
-{
- bool ret = false;
- struct device_info *info;
- void *obj;
-
- if (m->genlist)
- elm_genlist_clear(m->genlist);
-
- if (m->item_list)
- EINA_LIST_FREE(m->item_list, obj)
- {
- info = (struct device_info *) obj;
- free(info);
- }
-
- ret = m->pWifiDirectMgr->GetAllConnectedPeerInfo(sm_CbConnectedPeers, this);
- if (ret != true) {
- _ERR("foreach connected peers failed ");
- return;
- }
-
- ret = m_CreateWifiDirectScan();
- if (ret != true)
- _ERR("m_CreateWifiDirectScan() failed ");
-}
-
-
-void CWifiDirectMainView::m_ProcessDiscoveryFound(void)
-{
- bool ret = false;
-
- ret = m->pWifiDirectMgr->GetAllDicoveredPeerInfo(sm_CbDiscoverdPeers, this);
- if (ret != true)
- _ERR("foreach connected peers failed ");
-}
-
-
-void CWifiDirectMainView::m_ProcessDiscoveryFinish(void)
-{
- elm_object_part_content_unset(m->base, PART_REFRESH_BTN);
- evas_object_hide(m->btn_stop);
-
- m_ShowActionBtn();
-
- m_FillContentPart(m->genlist);
-}
-
-
-void CWifiDirectMainView::m_ProcessConnectionReq(const char *addr)
-{
- Eina_Bool is_pbc;
- bool ret = false;
-
- if (!addr) {
- _ERR("the param is invalid.");
- return;
- }
-
- ret = m->pWifiDirectMgr->GetWPStype(&is_pbc);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("Get wps type failed.");
- return;
- }
-
- m->req_addr = strdup(addr);
- if (!m->req_addr) {
- _ERR("strdup wrong.");
- return;
- }
-
- if (is_pbc) {
- ret = m_CreateReqPopupLayout();
- if (ret != true)
- _ERR("Create rep popup failed.");
- }
-}
-
-
-void CWifiDirectMainView::m_ProcessConnectionProg(void)
-{
- Evas_Object *layout;
- char title[MAX_STRING_LENTH];
- int x, y, w, h;
- int move_x, move_y;
-
- if (m->dim_ly)
- evas_object_show(m->dim_ly);
-
- layout = util_add_layout(m->base, UG_WIFI_DIRECT_EDJ_FILE, GRP_CONNECT_ACCEPT);
- if (!layout) {
- _ERR("add con_popup layout failed.");
- return;
- }
-
- memset(&title, 0x00, MAX_STRING_LENTH);
- snprintf(title, MAX_STRING_LENTH - 1, "%s", TXT_CONN_PROG);
- elm_object_part_text_set(layout, PART_TITLE, title);
-
- evas_object_geometry_get(m->on_btn, &x, &y, &w, &h);
- move_x = x + w - POPUP_WIDTH * HALF_SCALE - POPUP_RIGHT;
- move_y = y + CENTER_HEIGHT;
- evas_object_move(layout, move_x * ELM_SCALE, move_y * ELM_SCALE);
-
- m->prog_popup = layout;
-}
-
-
-void CWifiDirectMainView::m_ProcessConnectionRsp(void)
-{
- struct device_info *info;
- int cur_index;
-
- cur_index = m->conn_idx;
- info = (struct device_info *) eina_list_nth(m->item_list, cur_index);
- if (!info)
- return;
-
- info->is_conn = true;
- strncpy(info->state, TXT_CONNECT, WIFI_DIRECT_STATE_BUF_LEN);
-
- elm_genlist_item_update(m->popup_item);
-
- if (m->dim_ly)
- evas_object_hide(m->dim_ly);
-
- if (m->prog_popup) {
- evas_object_del(m->prog_popup);
- m->prog_popup = NULL;
- }
-
- if (m->connect_popup) {
- evas_object_del(m->connect_popup);
- m->connect_popup = NULL;
- }
-}
-
-
-void CWifiDirectMainView::m_ProcessConnectionInd(void)
-{
- Ecore_Timer *timer;
-
- timer = ecore_timer_add(HANDLER_INTERVAL, sm_CbConnectionInd, m);
- if (!timer) {
- _ERR("add timer failed.");
- return;
- }
-
- m->timer = timer;
-}
-
-
-bool CWifiDirectMainView::m_CreateWifiDirectScan(void)
-{
- Evas_Object *ly;
- Evas_Object *pb;
- Evas_Object *btn;
-
-
- ly = util_add_layout(m->base, UG_WIFI_DIRECT_EDJ_FILE,
- GRP_WIFIDIRECT_SCAN_LY);
- if (!ly) {
- _ERR("Add scan_ly failed.");
- return false;
- }
-
- m->scan_ly = ly;
-
- elm_object_part_content_unset(m->base, PART_REFRESH_BTN);
- evas_object_hide(m->btn_refresh);
-
- elm_object_part_content_unset(m->base, PART_CLOSE_BTN);
- evas_object_hide(m->btn_close);
-
- pb = util_add_progressbar(ly, STYLE_SEARCH_PROGRESS, PART_SEARCH_IMAGE);
- if (!pb) {
- _ERR("Add progressbar failed.");
- goto error;
- }
-
- btn = util_add_button(m->base, STYLE_ACTION_BUTTON, PART_REFRESH_BTN, _(action_button[ACTION_BTN_STOP]));
- if (!btn) {
- _ERR("Add stop button failed.");
- goto error;
- }
-
- m->scan_pb = pb;
- m->btn_stop = btn;
-
- elm_object_focus_set(m->btn_stop, EINA_TRUE);
-#if 0
- evas_object_event_callback_add(m->btn_stop, EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv);
-#endif
- //evas_object_smart_callback_add(m->btn_stop, SIG_CLICKED, _stop_btn_clicked_cb, priv);
- Connect(m->btn_stop, 7);
-
- m_FillContentPart(m->scan_ly);
-
- return true;
-
-error:
- evas_object_del(ly);
- return false;
-}
-
-
-void CWifiDirectMainView::m_ShowActionBtn(void)
-{
- Evas_Object *btn;
-
- if (!m->btn_refresh || !m->btn_close) {
- _ERR("action btn NULL!");
- return;
- }
-
- btn = elm_object_part_content_get(m->base, PART_REFRESH_BTN);
- if (btn) {
- elm_object_part_content_unset(m->base, PART_REFRESH_BTN);
- evas_object_hide(btn);
- }
-
- elm_object_part_content_set(m->base, PART_REFRESH_BTN, m->btn_refresh);
- evas_object_show(m->btn_refresh);
-
- elm_object_part_content_set(m->base, PART_CLOSE_BTN, m->btn_close);
- evas_object_show(m->btn_close);
-
- //evas_object_smart_callback_add(m->btn_refresh, SIG_CLICKED, _refresh_btn_clicked_cb, priv);
- //evas_object_smart_callback_add(m->btn_close, SIG_CLICKED, _close_btn_clicked_cb, priv);
- Connect(m->btn_refresh, 8);
- Connect(m->btn_close, 9);
-#if 0
- evas_object_event_callback_add(m->btn_refresh, EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv);
- evas_object_event_callback_add(m->btn_close, EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv);
-#endif
-}
-
-
-bool CWifiDirectMainView::m_UpdateGenlistItem(device_info *info)
-{
- bool exist;
-
- if (!info) {
- _ERR("The param is invalid.");
- return false;
- }
-
- exist = m_IsPeerExist(info);
- if (!exist) {
- m->item_list = eina_list_append(m->item_list, info);
-
- if (info->is_conn)
- strncpy(info->state, TXT_CONNECT, WIFI_DIRECT_STATE_BUF_LEN);
- else
- strncpy(info->state, TXT_DISCONNECT, WIFI_DIRECT_STATE_BUF_LEN);
-
- elm_genlist_item_append(m->genlist, m->itc, info, NULL, ELM_GENLIST_ITEM_NONE, sm_CbGenlistItemSelected, (void *)this);
- }
-
- return true;
-}
-
-
-bool CWifiDirectMainView::m_IsPeerExist(device_info *new_info)
-{
- struct device_info *cur_info;
- void *obj;
- Eina_List *l;
-
- if (!new_info) {
- _ERR("The param is invalid.");
- return false;
- }
-
- if (!m->item_list) {
- _ERR("The list is NULL now.");
- return false;
- }
-
- EINA_LIST_FOREACH(m->item_list, l, obj) {
- cur_info = (struct device_info *) obj;
- if (!strncmp(cur_info->mac_addr, new_info->mac_addr, WIFI_DIRECT_DEFAULT_BUF_LEN - 1))
- return true;
- }
-
- return false;
-}
-
-
-bool CWifiDirectMainView::m_CreateReqPopupLayout(void)
-{
- Evas_Object *layout;
- Evas_Object *btn[BTN_DIRECT];
- int i, x, y, w, h;
-
- if (!m->base) {
- _ERR("the param is invalid.");
- return false;
- }
-
- layout = util_add_layout(m->base, UG_WIFI_DIRECT_EDJ_FILE, GRP_CONNECT_ACCEPT);
- if (!layout) {
- _ERR("elm_layout_add() failed.");
- return false;
- }
-
- for (i = 0; i < BTN_DIRECT; i++) {
- btn[i] = util_add_button(layout, STYLE_POPUP_BUTTON, part_req[i], _(popup_button_req[i]));
- if (!btn[i]) {
- _ERR("add btn req failed.");
- evas_object_del(layout);
- return false;
- }
-
-#if 0
- evas_object_event_callback_add(btn[i], EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv);
-#endif
- }
- //evas_object_smart_callback_add(btn[i], SIG_CLICKED, _req_btn_clicked_cb, priv);
- Connect(btn[0], 10);
- Connect(btn[1], 11);
-
- evas_object_geometry_get(m->genlist, &x, &y, &w, &h);
- evas_object_move(layout, (x + RSP_X) * ELM_SCALE, (y + RSP_Y) * ELM_SCALE);
-
- m->req_popup = layout;
-
- elm_object_focus_set(btn[DIRECT_ON], EINA_TRUE);
-
- //evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN, _popup_back_pressed_cb, priv);
- Connect(layout, 12);
-
- return true;
-}
-
-
-bool CWifiDirectMainView::m_UpdateDeviceConnState(bool conn)
-{
- struct device_info *cur_info;
- void *obj;
- Eina_List *l;
-
- EINA_LIST_FOREACH(m->item_list, l, obj) {
- cur_info = (struct device_info *) obj;
- if (!strncmp(cur_info->mac_addr, m->req_addr, WIFI_DIRECT_DEFAULT_BUF_LEN - 1)) {
- cur_info->is_conn = conn;
- return true;
- }
- }
-
- return false;
-}
-
-
-bool CWifiDirectMainView::m_WifiDirectCbBtnConnect(struct device_info *info, int is_conn)
-{
- int ret = -1;
- wifi_direct_wps_type_e wps_type;
-
- if (!info) {
- _ERR("parameter is NULL!");
- return false;
- }
-
- if (is_conn) {
- if ((info->wps_types & WIFI_DIRECT_WPS_TYPE_PBC) == WIFI_DIRECT_WPS_TYPE_PBC)
- wps_type = WIFI_DIRECT_WPS_TYPE_PBC;
- else if ((info->wps_types & WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD) == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD)
- wps_type = WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD;
- else if ((info->wps_types & WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY) == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY)
- wps_type = WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY;
-
- ret = m->pWifiDirectMgr->SetWPStype(&wps_type);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("wifi_direct set wps type failev!");
- return false;
- }
-
- ret = m->pWifiDirectMgr->Connect(info->mac_addr);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("wifi_direct_connect:%s fail!", info->dev_name);
- return false;
- }
- } else {
- ret = m->pWifiDirectMgr->Disconnect(info->mac_addr);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("wifi_direct_disconnect:%s fail!", info->dev_name);
- return false;
- }
- }
- return true;
-}
-
-
-bool CWifiDirectMainView::m_CreateWifiDirectDim(void)
-{
- Evas_Object *ly;
-
- ly = util_add_layout(m->base, UG_WIFI_DIRECT_EDJ_FILE, GRP_DIM_LY);
- if (!ly) {
- _ERR("Add dim layout failed.");
- return false;
- }
-
- m->dim_ly = ly;
-
- evas_object_hide(ly);
-
- return true;
-}
-
-
-bool CWifiDirectMainView::Create(void *data)
-{
- _DBG();
- ASSERT(!m);
-
- _CREATE_BEGIN{
- _CHECK(m = new SWifiDirectMainView)
- _CHECK(m->win = CViewMgr::GetInstance()->Window())
- _CHECK(m_WifiDirectInit())
- _CHECK(m_RegisterWifiDirectCallback())
- _CHECK(m->base = util_add_layout(m->win, UG_WIFI_DIRECT_EDJ_FILE, GRP_MAIN))
- _CHECK(m_CreateButton())
- _CHECK(m_CreateGenlist())
- _CHECK(m_CreateActionBtns())
- _CHECK(m_CreateDeviceListView())
- _COMMAND {
- char descrption[MAX_STRING_LENTH];
- memset(&descrption, 0x00, MAX_STRING_LENTH);
- snprintf(descrption, MAX_STRING_LENTH - 1, "%s", TXT_WIFI_DIRECT_DISC);
- elm_object_part_text_set(m->base, PART_DESCRIPTION, descrption);
- }
- _WHEN_SUCCESS {
- m->pViewMgr = CViewMgr::GetInstance();
- //evas_object_event_callback_add(base, EVAS_CALLBACK_KEY_DOWN, _base_layout_key_down_cb, priv);
- Connect(m->base, 0);
- evas_object_show(m->base);
- }
- _CHECK_FAIL{/* m_CreateDeviceListView() */}
- _CHECK_FAIL{/* m_CreateActionBtns() */}
- _CHECK_FAIL{/* m_CreateGenlist() */}
- _CHECK_FAIL{/* m_CreateButton() */}
- _CHECK_FAIL{ evas_object_del(m->base); }
- _CHECK_FAIL{m_UnRegisterWifiDirectCallback();}
- _CHECK_FAIL{CWifiDirectMgr::Finalize();}
- _CHECK_FAIL{/* m->win = CViewMgr::GetInstance()->Window() */}
- _CHECK_FAIL{ delete m; m = NULL; }
- } _CREATE_END_AND_CATCH{ return false; }
-
- return true;
-}
-
-
-void CWifiDirectMainView::Destroy()
-{
- ASSERT(m);
- _DBG();
-
- struct device_info *info;
- void *obj;
-
- if (!m->item_list)
- EINA_LIST_FREE(m->item_list, obj)
- {
- info = (struct device_info *) obj;
- free(info);
- }
-
- if (m->dim_ly)
- evas_object_del(m->dim_ly);
-
- if (m->scan_ly)
- evas_object_del(m->scan_ly);
-
- if (m->timer)
- ecore_timer_del(m->timer);
-
- m_UnRegisterWifiDirectCallback();
- CWifiDirectMgr::Finalize();
-
- if (m->base)
- evas_object_del(m->base);
-
- CBaseView::Destroy();
- delete m;
- m = NULL;
-}
-
-
-Evas_Object* CWifiDirectMainView::Base(void)
-{
- ASSERT(m);
-
- return m->base;
-}
-
-
-void CWifiDirectMainView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
-{
- /* ID list */
- /* 0 m->base */
- /* 1 */
-
- if (!ev->keyname) {
- _ERR("ev->keyname is NULL.");
- return;
- }
-
- switch(id) {
- case 0:
- if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE) || !strcmp(ev->keyname, KEY_EXIT)) {
- ug_destroy_me(m->ug);
- }
- break;
- case 12:
- case 15:
- case 16:
- if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
- if (m->dim_ly)
- evas_object_hide(m->dim_ly);
-
- evas_object_del(obj);
- }
- break;
- default:
- break;
- }
-}
-
-
-void CWifiDirectMainView::OnMouseClicked(int id, Evas_Object *obj)
-{
- switch(id) {
- case 1:
- {
- Evas_Object *layout;
- Evas_Object *box;
- Evas_Object *btn[BTN_DIRECT];
- int i;
- int btn_x, btn_y, btn_w, btn_h;
- int move_x, move_y;
-
- if (!m->dim_ly) {
- m->dim_ly = util_add_layout(m->base, UG_WIFI_DIRECT_EDJ_FILE, GRP_DIM_LY);
- if (!m->dim_ly) {
- _ERR("Add dim layout failed.");
- Destroy();
- return ;
- }
- evas_object_hide(m->dim_ly);
- }
-
- evas_object_show(m->dim_ly);
-
- layout = util_add_layout(m->base, UG_WIFI_DIRECT_EDJ_FILE, GRP_WIFI_DIRECT_SELECT);
- if (!layout){
- _ERR("Fail to add layout");
- return;
- }
-
- elm_object_focus_allow_set(layout, EINA_TRUE);
-
- box = util_add_box(layout, PART_SWALLOW_CONTENT);
- if (!box) {
- _ERR("Fail to add box");
- evas_object_del(layout);
- return;
- }
-
- for (i = 0; i < BTN_DIRECT; i++) {
- btn[i] = util_add_button(box, STYLE_POPUP_BUTTON, NULL, _(popup_button_on[i]));
- if (!btn[i]) {
- _ERR("add btn direct failed.");
- evas_object_del(layout);
- return;
- }
-
- elm_box_pack_end(box, btn[i]);
-#if 0
- evas_object_event_callback_add(btn[i], EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv);
-#endif
- }
- //evas_object_smart_callback_add(btn[0], SIG_CLICKED, _wifi_direct_select_btn_cb, priv);
- //evas_object_smart_callback_add(btn[1], SIG_CLICKED, _wifi_direct_select_btn_cb, priv);
- Connect(btn[0], 2);
- Connect(btn[1], 3);
-
- if (m->direct_on_flag == DIRECT_ON)
- elm_object_signal_emit(btn[DIRECT_ON], SIG_BTN_SELECTED, PROG);
- else
- elm_object_signal_emit(btn[DIRECT_OFF], SIG_BTN_SELECTED, PROG);
-
- util_set_cycle_focus(btn, BTN_DIRECT);
-
- evas_object_geometry_get(m->on_btn, &btn_x, &btn_y, &btn_w, &btn_h);
- move_x = btn_x + btn_w - POPUP_WIDTH * HALF_SCALE - POPUP_RIGHT;
- move_y = btn_y + btn_h;
- evas_object_move(layout, move_x * ELM_SCALE, move_y * ELM_SCALE);
-
- m->direct_popup = layout;
-
- //evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN, _popup_back_pressed_cb, priv);
- Connect(layout, 16);
-
- elm_object_focus_set(btn[0], EINA_TRUE);
- }
- break;
- case 2:
- case 3:
- {
- struct device_info *info;
- void *temp_obj;
- const char *value;
- bool ret = false;
-
- value = (const char *) elm_object_text_get(obj);
- if (!value) {
- _ERR("get text from network type btn is NULL.");
- return;
- }
-
- if (!strcmp(value, popup_button_on[DIRECT_ON])) {
- if (m->direct_on_flag == DIRECT_OFF) {
- m->direct_on_flag = DIRECT_ON;
-
- elm_genlist_clear(m->genlist);
-
- if (m->item_list)
- EINA_LIST_FREE(m->item_list, temp_obj)
- {
- info = (struct device_info *) temp_obj;
- free(info);
- }
-
- m_CreateDeviceListView();
-
- m_ShowActionBtn();
- }
- } else {
- m->direct_on_flag = DIRECT_OFF;
-
- ret = m_DisplayDisconnect();
- if (ret != true) {
- _ERR("m_DisplayDisconnect() failed.");
- return;
- }
-
- ret = m->pWifiDirectMgr->Deactivate();
- if (ret != true) {
- _ERR("wif direct deactivate failed.");
- return;
- }
- }
-
- m_RefreshOnText();
-
- if (m->direct_popup) {
- evas_object_del(m->direct_popup);
- m->direct_popup = NULL;
- }
-
- if (m->dim_ly)
- evas_object_hide(m->dim_ly);
-
- }
- break;
- case 4:
- case 8:
- {
- struct device_info *info;
- void *temp_obj;
-
- if (m->scan_ly)
- evas_object_hide(m->scan_ly);
-
- elm_genlist_clear(m->genlist);
-
- if (m->item_list)
- EINA_LIST_FREE(m->item_list, temp_obj)
- {
- info = (struct device_info *) temp_obj;
- free(info);
- }
-
- m_CreateDeviceListView();
- }
- break;
- case 5:
- case 6:
- case 9:
- ug_destroy_me(m->ug);
- Destroy();
- break;
- case 7:
- {
- bool ret = false;
- Evas_Object *btn;
-
- ret = m->pWifiDirectMgr->CancelDiscovery();
- if (ret != true) {
- _ERR("Cancel disconery failed.");
- return;
- }
-
- btn = elm_object_part_content_get(m->base, PART_REFRESH_BTN);
- if (btn) {
- elm_object_part_content_unset(m->base, PART_REFRESH_BTN);
- evas_object_hide(btn);
- }
-
- m_ShowActionBtn();
-
- m_FillContentPart(m->genlist);
- }
- break;
- case 10:
- case 11:
- {
- const char *value;
- bool ret = false;
-
- if (!obj) {
- _ERR("The param is invalid.");
- return;
- }
-
- value = elm_object_text_get(obj);
- if (!value) {
- _ERR("get text from network type btn is NULL.");
- return;
- }
-
- if (!strcmp(value, popup_button_req[DIRECT_ON])) {
- ret = m->pWifiDirectMgr->AcceptConnection(m->req_addr);
- if (ret != true) {
- _ERR("Disconnection failed.");
- return;
- }
-
- ret = m_UpdateDeviceConnState(true);
- if (ret != true)
- _ERR("m_UpdateDeviceConnState() failed.");
- } else {
-#if 0
- ret = m->pWifiDirectMgr->RejectConnection(m->req_addr);
- if (ret != true) {
- _ERR("Accept connection failed.");
- return;
- }
-#endif
-
- ret = m_UpdateDeviceConnState(false);
- if (ret != true)
- _ERR("m_UpdateDeviceConnState() failed.");
- }
-
- free(m->req_addr);
- m->req_addr = NULL;
-
- if (m->req_popup) {
- evas_object_del(m->req_popup);
- m->req_popup = NULL;
- }
-
- if (m->dim_ly)
- evas_object_hide(m->dim_ly);
-
- }
- break;
- case 13:
- case 14:
- {
- const char *value;
- bool ret = false;
- Elm_Object_Item *gen_item;
- struct device_info *info;
- int cur_idx;
-
- if (!obj) {
- _ERR("the param is invalid.");
- return;
- }
-
- value = elm_object_text_get(obj);
- if (!value) {
- _ERR("get text from wifi_direct device btn is NULL.");
- return;
- }
-
- gen_item = m->popup_item;
-
- cur_idx = elm_genlist_item_index_get(gen_item);
- if (cur_idx < 0)
- return;
-
- info = (struct device_info *) eina_list_nth(m->item_list, cur_idx);
- if (!info)
- return;
-
- if (!strcmp(value, TXT_CONNECT)) {
- ret = m_WifiDirectCbBtnConnect(info, CONN_YES);
- if (ret == false) {
- _ERR("Connect failed");
- return;
- }
-
- info->is_conn = true;
- } else if (!strcmp(value, TXT_DISCONNECT)) {
- ret = m_WifiDirectCbBtnConnect(info, CONN_NO);
- if (ret != WIFI_DIRECT_ERROR_NONE) {
- _ERR("wifi_direct_mgr_disconnect failed,,%s",
- info->mac_addr);
- return;
- }
-
- strncpy(info->state, TXT_DISCONNECT, WIFI_DIRECT_STATE_BUF_LEN);
- info->is_conn = false;
- }
-
- if (m->direct_popup) {
- evas_object_del(m->direct_popup);
- m->direct_popup = NULL;
- }
-
- if (m->connect_popup) {
- evas_object_del(m->connect_popup);
- m->connect_popup = NULL;
- }
-
- if (m->dim_ly)
- evas_object_hide(m->dim_ly);
- }
- break;
- default:
- break;
- }
-}
-
-
-void CWifiDirectMainView::OnUnfocused(int id, Evas_Object *obj, Elm_Object_Item *item)
-{
- switch(id) {
- case 0:
- break;
- default:
- break;
- }
-}
-
diff --git a/ug/wifi-direct/src/ug_wifi_direct.cpp b/ug/wifi-direct/src/ug_wifi_direct.c
index c14014b..6a5d359 100644
--- a/ug/wifi-direct/src/ug_wifi_direct.cpp
+++ b/ug/wifi-direct/src/ug_wifi_direct.c
@@ -18,24 +18,16 @@
#define UG_MODULE_API __attribute__ ((visibility("default")))
#endif
+#include <Elementary.h>
#include <ui-gadget-module.h>
-#include <AppCommon.h>
-#include "defs.h"
#include "i18n.h"
-
-#include "wifi.h"
-#include "WifiDirectMainView.h"
-
-#if defined (__cplusplus)
-extern "C" {
-#endif
+#include "dbg.h"
+#include "wifi_direct_view.h"
struct _ug_data {
Evas_Object *win;
Evas_Object *base;
ui_gadget_h ug;
- CViewMgr *pViewMgr;
- CWifiDirectMainView *pWifiDirectMainView;
};
/**
@@ -55,6 +47,7 @@ static void *_on_create(ui_gadget_h ug, enum ug_mode mode,
service_h service, void *priv)
{
struct _ug_data *ugd;
+ Evas_Object *base;
Evas_Object *win;
if (!ug || !priv) {
@@ -62,12 +55,12 @@ static void *_on_create(ui_gadget_h ug, enum ug_mode mode,
return NULL;
}
- ugd = (struct _ug_data *) priv;
+ ugd = priv;
ugd->ug = ug;
elm_theme_extension_add(NULL, UG_WIFI_DIRECT_EDJ_THEME);
- win = (Evas_Object *) ug_get_window();
+ win = ug_get_window();
if (!win) {
_ERR("window get failed");
return NULL;
@@ -77,24 +70,16 @@ static void *_on_create(ui_gadget_h ug, enum ug_mode mode,
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
elm_win_focus_highlight_style_set(win, "invisible");
- CViewMgr::Initialize(ugd->win, NULL);
- ugd->pViewMgr = CViewMgr::GetInstance();
- if(!ugd->pViewMgr) {
- CViewMgr::Finalize();
- _ERR("Fail to get CViewMgr instance");
+ base = wifi_direct_view_create(win, ug);
+ if (!base) {
+ _ERR("add base layout failed.");
return NULL;
}
- ugd->pWifiDirectMainView = new CWifiDirectMainView(WIFI_DIRECT_MAINVIEW);
- if(!ugd->pViewMgr->AddView(ugd->pWifiDirectMainView)) {
- _ERR("Fail to add pFbBaseView");
- CViewMgr::Finalize();
- return false;
- }
- ugd->pViewMgr->PushView(WIFI_DIRECT_MAINVIEW, NULL);
- ugd->base = ugd->pWifiDirectMainView->Base();
+ ugd->base = base;
+ evas_object_raise(base);
- return ugd->base;
+ return base;
}
/**
@@ -147,7 +132,6 @@ static void _on_resume(ui_gadget_h ug, service_h service, void *priv)
*/
static void _on_destroy(ui_gadget_h ug, service_h service, void *priv)
{
- CViewMgr::Finalize();
}
/**
@@ -217,7 +201,7 @@ UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
if (!ops)
return -1;
- ugd = (struct _ug_data *) calloc(1, sizeof(*ugd));
+ ugd = calloc(1, sizeof(*ugd));
if (!ugd)
return -1;
@@ -252,10 +236,6 @@ UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
if (!ops)
return;
- ugd = (struct _ug_data *) ops->priv;
+ ugd = ops->priv;
free(ugd);
}
-
-#if defined (__cplusplus)
-};
-#endif
diff --git a/ug/wifi-direct/src/util.cpp b/ug/wifi-direct/src/util.c
index 0d9fe6b..961c90b 100644
--- a/ug/wifi-direct/src/util.cpp
+++ b/ug/wifi-direct/src/util.c
@@ -19,7 +19,7 @@
#include <aul.h>
#include "i18n.h"
#include "defs.h"
-#include <MacroDefine.h>
+#include "dbg.h"
#include "util.h"
/**
diff --git a/ug/wifi-direct/src/wifi_direct_mgr.c b/ug/wifi-direct/src/wifi_direct_mgr.c
new file mode 100644
index 0000000..02cf4a3
--- /dev/null
+++ b/ug/wifi-direct/src/wifi_direct_mgr.c
@@ -0,0 +1,612 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <Elementary.h>
+#include <aul.h>
+#include <wifi-direct.h>
+#include "defs.h"
+#include "dbg.h"
+#include "wifi_direct_mgr.h"
+
+#define LOCAL_MAX_CLIENT 8
+
+/**
+* Convert the error code to the corresponding string.
+*
+* @param[in] errcode the wifi direct error code bypassed
+* @return the error description
+*/
+const char *wifi_direct_mgr_err_dbg(int errcode)
+{
+ switch (errcode) {
+ case WIFI_DIRECT_ERROR_OUT_OF_MEMORY:
+ return "WIFI_DIRECT_ERROR_OUT_OF_MEMORY";
+ break;
+ case WIFI_DIRECT_ERROR_NOT_PERMITTED:
+ return "WIFI_DIRECT_ERROR_NOT_PERMITTED";
+ break;
+ case WIFI_DIRECT_ERROR_INVALID_PARAMETER:
+ return "WIFI_DIRECT_ERROR_INVALID_PARAMETER";
+ break;
+ case WIFI_DIRECT_ERROR_RESOURCE_BUSY:
+ return "WIFI_DIRECT_ERROR_RESOURCE_BUSY";
+ break;
+ case WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT:
+ return "WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT";
+ break;
+ case WIFI_DIRECT_ERROR_NOT_INITIALIZED:
+ return "WIFI_DIRECT_ERROR_NOT_INITIALIZED";
+ break;
+ case WIFI_DIRECT_ERROR_COMMUNICATION_FAILED:
+ return "WIFI_DIRECT_ERROR_COMMUNICATION_FAILED";
+ break;
+ case WIFI_DIRECT_ERROR_WIFI_USED:
+ return "WIFI_DIRECT_ERROR_WIFI_USED";
+ break;
+ case WIFI_DIRECT_ERROR_MOBILE_AP_USED:
+ return "WIFI_DIRECT_ERROR_MOBILE_AP_USED";
+ break;
+ case WIFI_DIRECT_ERROR_CONNECTION_FAILED:
+ return "WIFI_DIRECT_ERROR_CONNECTION_FAILED";
+ break;
+ case WIFI_DIRECT_ERROR_AUTH_FAILED:
+ return "WIFI_DIRECT_ERROR_AUTH_FAILED";
+ break;
+ case WIFI_DIRECT_ERROR_OPERATION_FAILED:
+ return "WIFI_DIRECT_ERROR_OPERATION_FAILED";
+ break;
+ case WIFI_DIRECT_ERROR_TOO_MANY_CLIENT:
+ return "WIFI_DIRECT_ERROR_TOO_MANY_CLIENT";
+ break;
+ default:
+ break;
+ }
+
+ return "UNKNOWN";
+}
+
+/**
+* Get device name.
+*
+* @return device name on success,otherwise NULL
+*/
+char *wifi_direct_mgr_get_device_name(void)
+{
+ int ret;
+ char *name;
+
+ name = NULL;
+ ret = wifi_direct_get_device_name(&name);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("get device name failed, ret: %s.",
+ wifi_direct_mgr_err_dbg(ret));
+ return NULL;
+ }
+
+ return name;
+}
+
+/**
+* Get local MAC address.
+*
+* @return MAC address string on success, otherwise NULL
+*/
+char *wifi_direct_mgr_get_mac_address(void)
+{
+ int ret;
+ char *mac_addr;
+
+ mac_addr = NULL;
+ ret = wifi_direct_get_mac_address(&mac_addr);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("get mac address failed, ret: %s.",
+ wifi_direct_mgr_err_dbg(ret));
+ return NULL;
+ }
+
+ return mac_addr;
+}
+
+/**
+* Initialize WiFi server.
+*
+* @return 0 on success, otherwise -1
+*/
+int wifi_direct_mgr_wifi_init(void)
+{
+ int ret;
+
+ ret = wifi_initialize();
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("wifi_initialize failed, ret:%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* Finalize WiFi server
+*
+* @return 0 on success, otherwise -1
+*/
+int wifi_direct_mgr_wifi_fini(void)
+{
+ int ret;
+
+ ret = wifi_deinitialize();
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("wifi_deinitialize failed, ret:%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* Initialize WiFi Direct server
+*
+* @return 0 on success, otherwise -1
+*/
+int wifi_direct_mgr_wifi_direct_init(void)
+{
+ int ret;
+
+ ret = wifi_direct_initialize();
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("wifi_direct_initialize failed, ret:%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* Finalize Wi-Fi Direct server.
+*
+* Uses the midware API to deregister the client application with the Wi-Fi Direct server.
+* and releases all resources. Pre Application must be already registered to the Wi-Fi Direct server.
+*
+* @return 0 on success, otherwise -1
+*/
+int wifi_direct_mgr_wifi_direct_fini(void)
+{
+ int ret;
+
+ ret = wifi_direct_deinitialize();
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("wifi_direct_deinitialize failed, ret:%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* Register the callback functions called.
+*
+* Each callback function is synchronous.
+*
+* @param[in] cbs The fuction struct contains the action callback fuctions
+* @param[in] data the user data
+* @return 0 on success, otherwise -1
+*/
+int wifi_direct_mgr_register_callback(struct wifi_direct_cbs *cbs,
+ void *data)
+{
+ int ret;
+
+ if (!cbs || !data) {
+ _ERR("The parameter is NULL.");
+ return RET_FAILED;
+ }
+
+ ret = wifi_direct_set_device_state_changed_cb(cbs->device_state_cb,
+ data);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("set device state changed cb failed ret:%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ return RET_FAILED;
+ }
+
+ ret = wifi_direct_set_discovery_state_changed_cb(
+ cbs->discovery_state_cb, data);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("set discovery state changed cb failed ret:%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ wifi_direct_unset_device_state_changed_cb();
+ return RET_FAILED;
+ }
+
+ ret = wifi_direct_set_connection_state_changed_cb(
+ cbs->connection_state_cb, data);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("set connection state changed cb failed ret:%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ wifi_direct_unset_device_state_changed_cb();
+ wifi_direct_unset_discovery_state_changed_cb();
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* Unregister the action callback fuctions.
+*
+* Opposite action to wifi_direct_mgr_register_callback.
+*
+* @return 0 on success, otherwise -1
+*/
+int wifi_direct_mgr_unregister_callback(void)
+{
+ int ret;
+ int result;
+
+ result = RET_SUCCESS;
+ ret = wifi_direct_unset_device_state_changed_cb();
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("unset device state changed cb failed ret:%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ result = RET_FAILED;
+ }
+
+ ret = wifi_direct_unset_discovery_state_changed_cb();
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("unset discovery state changed cb failed ret:%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ result = RET_FAILED;
+ }
+
+ ret = wifi_direct_unset_connection_state_changed_cb();
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("unset connection state changed cb failed ret:%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ result = RET_FAILED;
+ }
+
+ ret = wifi_direct_unset_client_ip_address_assigned_cb();
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("unset device state changed cb failed ret:%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ result = RET_FAILED;
+ }
+
+ return result;
+}
+
+/**
+* Get the state of Wi-Fi Direct server
+*
+* @param[in] status The param bypassed used to save the status of the Wi-Fi Direct server
+* @return 0 on success, otherwise -1
+*/
+int wifi_direct_mgr_get_state(wifi_direct_state_e *status)
+{
+ int ret;
+
+ if (!status) {
+ _ERR("The param is NULL.");
+ return RET_FAILED;
+ }
+
+ ret = wifi_direct_get_state(status);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("get state failed ret:%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* Activate Wi-Fi Direct server
+*
+* @return 0 on success, otherwise -1
+*/
+int wifi_direct_mgr_activate(void)
+{
+ int ret;
+
+ ret = wifi_direct_activate();
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("wifi_direct_activate failed ret:%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* Deactivate Wi-Fi Direct server
+*
+* @return 0 on success, otherwise -1
+*/
+int wifi_direct_mgr_deactivate(void)
+{
+ int ret;
+
+ ret = wifi_direct_deactivate();
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("wifi_direct_deactivate failed ret:%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* Set the number of the clients.
+*
+* @return 0 on success, otherwise -1
+*/
+int wifi_direct_mgr_set_configure_num(void)
+{
+ int ret;
+
+ ret = wifi_direct_set_max_clients(LOCAL_MAX_CLIENT);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("set max client failed ret:%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* Get the information of all discovered peers.Synchronous.
+*
+* @param[in] cb the callback function
+* @param[in] data the user data
+* @return 0 on success, otherwise -1
+*/
+int wifi_direct_mgr_foreach_discovered_peers(
+ wifi_direct_discovered_peer_cb cb, void *data)
+{
+ int ret;
+
+ if (!cb || !data) {
+ _ERR("The parameter is NULL.");
+ return RET_FAILED;
+ }
+
+ ret = wifi_direct_foreach_discovered_peers(cb, data);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("foreach connected pees failed ret:%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* Get the information of the connected peers.Synchronous.
+*
+* @param[in] cd the callback function
+* @param[in] data the user data
+* @return 0 on success, otherwise -1
+*/
+int wifi_direct_mgr_foreach_connected_peers(
+ wifi_direct_connected_peer_cb cb, void *data)
+{
+ int ret;
+
+ if (!cb || !data) {
+ _ERR("The parameter is NULL.");
+ return RET_FAILED;
+ }
+
+ ret = wifi_direct_foreach_connected_peers(cb, data);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("foreach connected peers failed ret:%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* Start discovery process.Asynchronous.
+*
+* @return 0 on success, otherwise -1
+*/
+int wifi_direct_mgr_start_discovery(void)
+{
+ int ret;
+
+ ret = wifi_direct_start_discovery(WIFI_DIRECT_DISCOVERY_LISTEN_AND_SCAN,
+ WIFI_DIRECT_SCAN_TIMEOUT);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("start discovery failed ret:%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* Cancel discovery process
+*
+* The oppsite action to wifi_direct_mgr_start_discovery
+*
+* @return 0 on success, otherwise -1
+*/
+int wifi_direct_mgr_cancel_discovery(void)
+{
+ int ret;
+
+ ret = wifi_direct_cancel_discovery();
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("wifi_direct_cancel_discovery failed ret:%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* Connect the peer specified by MAC address. Asynchronous.
+*
+* @param[in] mac_adrr the MAC address
+* @return 0 on success, otherwise -1
+*/
+int wifi_direct_mgr_connect(const char *mac_addr)
+{
+ int ret;
+
+ if (!mac_addr) {
+ _ERR("mac_address is NULL");
+ return RET_FAILED;
+ }
+
+ ret = wifi_direct_connect(mac_addr);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("wifi_direct_connect failed,%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* Disconnect to a peer.
+*
+* @param[in] mac_adrr the MAC address
+* @return 0 on success, otherwise -1
+*/
+int wifi_direct_mgr_disconnect(const char *mac_addr)
+{
+ int ret;
+
+ if (!mac_addr) {
+ _ERR("mac_address is NULL");
+ return RET_FAILED;
+ }
+
+ ret = wifi_direct_disconnect(mac_addr);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("wifi_direct_disconnect failed,%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* Accept connection requested by a peer.
+*
+* Called for request event,WIFI_DIRECT_CONNECTION_REQ
+*
+* @param[in] mac_adrr the MAC address of the request peer
+* @return[in] 0 on success, otherwise -1
+*/
+int wifi_direct_mgr_accept_connection(char *mac_addr)
+{
+ int ret;
+
+ if (!mac_addr) {
+ _ERR("mac_address is NULL");
+ return RET_FAILED;
+ }
+
+ ret = wifi_direct_accept_connection(mac_addr);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("wifi_direct_accept_connection failed,%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ return RET_FAILED;
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* Verify the WPS type.
+*
+* This function get the WPS(Wi-Fi Protected Setup) type and check if it is equal to PBC type,
+* if equal, set EINA_TRUE to is_pbc, otherwise set EINA_FALSE,and return it.
+*
+* @param[in] is_pbc The point pointing to mark if WPS is PBC
+* @return[in] 0 on success, otherwise -1
+*/
+int wifi_direct_mgr_get_wps_type(Eina_Bool *is_pbc)
+{
+ _DBG("Not Yet");
+#if 0
+ wifi_direct_wps_type_e type;
+
+ if (!is_pbc) {
+ _ERR("Parameter is NULL");
+ return RET_FAILED;
+ }
+
+ int ret;
+ ret = wifi_direct_get_wps_type(&type);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("wifi_direct_get_wps_type failed,%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ return RET_FAILED;
+ }
+
+ if ((type & WIFI_DIRECT_WPS_TYPE_PBC) == WIFI_DIRECT_WPS_TYPE_PBC)
+ *is_pbc = EINA_TRUE;
+ else
+ *is_pbc = EINA_FALSE;
+
+ return RET_SUCCESS;
+#endif
+ return RET_FAILED;
+}
+
+/**
+* Set the WPS(Wi-Fi Protected Setyup) type.
+*
+* @param[in] type The WPS type
+* @return 0 on success, otherwise -1
+*/
+int wifi_direct_mgr_set_wps_type(wifi_direct_wps_type_e *type)
+{
+ if (!type) {
+ _ERR("Parameter is NULL");
+ return RET_FAILED;
+ }
+
+ _DBG("Not Yet");
+#if 0
+ int ret;
+ ret = wifi_direct_set_wps_type(*type);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("wifi_direct_get_wps_type failed,%s.",
+ wifi_direct_mgr_err_dbg(ret));
+ return RET_FAILED;
+ }
+#endif
+
+ return RET_SUCCESS;
+}
diff --git a/ug/wifi-direct/src/wifi_direct_view.c b/ug/wifi-direct/src/wifi_direct_view.c
new file mode 100644
index 0000000..913be55
--- /dev/null
+++ b/ug/wifi-direct/src/wifi_direct_view.c
@@ -0,0 +1,2040 @@
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <Elementary.h>
+#include <aul.h>
+#include <Eina.h>
+
+#include <KeyDefine.h>
+
+#include "defs.h"
+#include "dbg.h"
+#include "wifi_direct_view.h"
+#include "wifi_direct_mgr.h"
+#include "util.h"
+
+struct _priv {
+ Evas_Object *win;
+ Evas_Object *base;
+ Evas_Object *genlist;
+ Evas_Object *on_btn;
+ Evas_Object *direct_popup;
+ Evas_Object *connect_popup;
+ Evas_Object *dim_ly;
+ Evas_Object *btn_refresh;
+ Evas_Object *btn_close;
+ Evas_Object *btn_stop;
+ Evas_Object *scan_ly;
+ Evas_Object *scan_pb;
+ Evas_Object *no_conn_ly;
+ Evas_Object *prog_popup;
+ Evas_Object *req_popup;
+
+ ui_gadget_h ug;
+ Elm_Genlist_Item_Class *itc;
+ Elm_Object_Item *popup_item;
+ Eina_List *item_list;
+ Ecore_Timer *timer;
+
+ int conn_idx;
+ int direct_on_flag;
+ int finish_flag;
+ char *req_addr;
+};
+
+enum action_btn_enum {
+ ACTION_BTN_REFRESH,
+ ACTION_BTN_CLOSE,
+ ACTION_BTN_STOP
+};
+
+enum direct_swith_enum {
+ DIRECT_ON = 0,
+ DIRECT_OFF
+};
+
+const char *action_button[] = {
+ [ACTION_BTN_REFRESH] = TXT_REFRESH_BTN,
+ [ACTION_BTN_CLOSE] = TXT_CLOSE_BTN,
+ [ACTION_BTN_STOP] = TXT_STOP_BTN
+};
+
+const char *popup_button_on[] = {
+ [DIRECT_OFF] = TXT_OFF_BTN,
+ [DIRECT_ON] = TXT_ON_BTN
+};
+
+static char *popup_button_conn[] = {
+ [DIRECT_ON] = TXT_CONNECT,
+ [DIRECT_OFF] = TXT_DISCONNECT
+};
+
+static char *popup_button_req[] = {
+ [DIRECT_ON] = TXT_YES,
+ [DIRECT_OFF] = TXT_NO
+};
+
+static char *part_req[] = {
+ [DIRECT_ON] = PART_YES,
+ [DIRECT_OFF] = PART_NO
+};
+
+static void _device_state_changed_cb(int errcode,
+ wifi_direct_device_state_e state, void *data);
+static void _discovery_state_changed_cb(int errcode,
+ wifi_direct_discovery_state_e state, void *data);
+static void _connection_state_changed_cb(int errcode,
+ wifi_direct_connection_state_e state, const char *addr,
+ void *data);
+static bool _connected_peer_cb(
+ wifi_direct_connected_peer_info_s * conn_info, void *data);
+static bool _discoverd_peers_cb(
+ wifi_direct_discovered_peer_info_s * discov_info,
+ void *data);
+
+static struct wifi_direct_cbs cbs = {
+ .device_state_cb = _device_state_changed_cb,
+ .discovery_state_cb = _discovery_state_changed_cb,
+ .connection_state_cb = _connection_state_changed_cb,
+ .connected_peer_cb = _connected_peer_cb,
+ .discovered_peer_cb = _discoverd_peers_cb
+};
+
+static void _fill_content_part(struct _priv *priv, Evas_Object *obj);
+static int _create_wifi_direct_scan(struct _priv *priv);
+static void _create_device_list_view(struct _priv *priv);
+static void _show_action_btn(struct _priv *priv);
+
+/**
+* Initialize the priv.
+*
+* @return _priv _priv object initialized
+*/
+static struct _priv *_init_priv(void)
+{
+ struct _priv *priv;
+
+ priv = calloc(1, sizeof(*priv));
+ if (!priv) {
+ _ERR("calloc failed.");
+ return NULL;
+ }
+
+ return priv;
+}
+
+/**
+* Finalize the priv.
+*
+* Recycles memory allocated for the priv and free the point.
+*
+* @param[in] priv _priv object to be finalized
+*/
+static void _fini_priv(struct _priv *priv)
+{
+ struct device_info *info;
+
+ if (!priv) {
+ _ERR("priv is already NULL.");
+ return;
+ }
+
+ if (!priv->item_list)
+ EINA_LIST_FREE(priv->item_list, info)
+ free(info);
+
+ if (priv->dim_ly)
+ evas_object_del(priv->dim_ly);
+
+ if (priv->scan_ly)
+ evas_object_del(priv->scan_ly);
+
+ if (priv->timer)
+ ecore_timer_del(priv->timer);
+
+ wifi_direct_mgr_wifi_fini();
+ wifi_direct_mgr_unregister_callback();
+ wifi_direct_mgr_wifi_direct_fini();
+
+ if (priv->base)
+ evas_object_del(priv->base);
+
+ free(priv);
+}
+
+/**
+* It is a callback function responding mouse event
+*
+* This function set focus on the object when mouse is put on it
+*
+* @param[in] dt the user data
+* @param[in] e evas handler
+* @param[in] obj the corresponding object which the mouse event occurred
+* @param[in] ei event information
+*/
+static void _list_btn_mouse_in_cb(void *dt, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ if (!obj) {
+ _ERR("Invalid argument obj");
+ return;
+ }
+
+ elm_object_focus_set(obj, EINA_TRUE);
+}
+
+/**
+* Evas_Smart_Cb type callback for handling click event
+*
+* @param[in] data the user data
+* @param[in] obj the corresponding object which the click event occurred
+* @param[in] event event information
+*/
+static void _refresh_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+ struct device_info *info;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+
+ if (priv->scan_ly)
+ evas_object_hide(priv->scan_ly);
+
+ elm_genlist_clear(priv->genlist);
+
+ if (priv->item_list)
+ EINA_LIST_FREE(priv->item_list, info)
+ free(info);
+
+ _create_device_list_view(priv);
+}
+
+/**
+* Evas_Smart_Cb type callback for handling click event
+*
+* @param[in] data the user data
+* @param[in] obj the corresponding object which the click event occurred
+* @param[in] event event information
+*/
+static void _close_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+
+ if (!priv->ug) {
+ _ERR("priv->ug is NULL.");
+ return;
+ }
+
+ ug_destroy_me(priv->ug);
+
+ _fini_priv(priv);
+}
+
+/**
+* Create the action buttons.
+*
+* @param[in] priv _priv object bypassed
+*/
+static void _show_action_btn(struct _priv *priv)
+{
+ Evas_Object *btn;
+
+ if (!priv || !priv->base) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ if (!priv->btn_refresh || !priv->btn_close) {
+ _ERR("action btn NULL!");
+ return;
+ }
+
+ btn = elm_object_part_content_get(priv->base, PART_REFRESH_BTN);
+ if (btn) {
+ elm_object_part_content_unset(priv->base, PART_REFRESH_BTN);
+ evas_object_hide(btn);
+ }
+
+ elm_object_part_content_set(priv->base, PART_REFRESH_BTN,
+ priv->btn_refresh);
+ evas_object_show(priv->btn_refresh);
+
+ elm_object_part_content_set(priv->base, PART_CLOSE_BTN,
+ priv->btn_close);
+ evas_object_show(priv->btn_close);
+
+ evas_object_smart_callback_add(priv->btn_refresh, SIG_CLICKED,
+ _refresh_btn_clicked_cb, priv);
+ evas_object_event_callback_add(priv->btn_refresh,
+ EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv);
+ evas_object_smart_callback_add(priv->btn_close, SIG_CLICKED,
+ _close_btn_clicked_cb, priv);
+ evas_object_event_callback_add(priv->btn_close,
+ EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv);
+}
+
+/**
+* Create the dim layout but did not show it.
+*
+* @param[in] priv _priv object bypassed
+* @return on success, otherwise -1.
+*/
+static int _create_wifi_direct_dim(struct _priv *priv)
+{
+ Evas_Object *base;
+ Evas_Object *ly;
+
+ if (!priv || !priv->base) {
+ _ERR("Parameter error!");
+ return RET_FAILED;
+ }
+
+ base = priv->base;
+
+ ly = util_add_layout(base, UG_WIFI_DIRECT_EDJ_FILE, GRP_DIM_LY);
+ if (!ly) {
+ _ERR("Add dim layout failed.");
+ return RET_FAILED;
+ }
+
+ priv->dim_ly = ly;
+
+ evas_object_hide(ly);
+
+ return RET_SUCCESS;
+}
+
+/**
+* Evas_Smart_Cb type callback for handling click event
+*
+* @param[in] data the user data
+* @param[in] obj the corresponding object which the click event occurred
+* @param[in] ev event information
+*/
+static void _stop_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *ev)
+{
+ int ret;
+ struct _priv *priv;
+ Evas_Object *btn;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+
+ ret = wifi_direct_mgr_cancel_discovery();
+ if (ret != RET_SUCCESS) {
+ _ERR("Cancel disconery failed.");
+ return;
+ }
+
+ btn = elm_object_part_content_get(priv->base, PART_REFRESH_BTN);
+ if (btn) {
+ elm_object_part_content_unset(priv->base, PART_REFRESH_BTN);
+ evas_object_hide(btn);
+ }
+
+ _show_action_btn(priv);
+
+ _fill_content_part(priv, priv->genlist);
+}
+
+/**
+* Create the scan process view
+*
+* @param[in] priv _priv object bypassed
+*/
+static int _create_wifi_direct_scan(struct _priv *priv)
+{
+ Evas_Object *ly;
+ Evas_Object *pb;
+ Evas_Object *btn;
+
+ if (!priv || !priv->base) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ly = util_add_layout(priv->base, UG_WIFI_DIRECT_EDJ_FILE,
+ GRP_WIFIDIRECT_SCAN_LY);
+ if (!ly) {
+ _ERR("Add scan_ly failed.\n");
+ return RET_FAILED;
+ }
+
+ priv->scan_ly = ly;
+
+ elm_object_part_content_unset(priv->base, PART_REFRESH_BTN);
+ evas_object_hide(priv->btn_refresh);
+
+ elm_object_part_content_unset(priv->base, PART_CLOSE_BTN);
+ evas_object_hide(priv->btn_close);
+
+ pb = util_add_progressbar(ly, STYLE_SEARCH_PROGRESS, PART_SEARCH_IMAGE);
+ if (!pb) {
+ _ERR("Add progressbar failed.\n");
+ goto error;
+ }
+
+ btn = util_add_button(priv->base, STYLE_ACTION_BUTTON, PART_REFRESH_BTN,
+ _(action_button[ACTION_BTN_STOP]));
+ if (!btn) {
+ _ERR("Add stop button failed.");
+ goto error;
+ }
+
+ priv->scan_pb = pb;
+ priv->btn_stop = btn;
+
+ elm_object_focus_set(priv->btn_stop, EINA_TRUE);
+ evas_object_event_callback_add(priv->btn_stop, EVAS_CALLBACK_MOUSE_IN,
+ _list_btn_mouse_in_cb, priv);
+ evas_object_smart_callback_add(priv->btn_stop, SIG_CLICKED,
+ _stop_btn_clicked_cb, priv);
+
+ _fill_content_part(priv, priv->scan_ly);
+
+ return RET_SUCCESS;
+
+error:
+ evas_object_del(ly);
+ return RET_FAILED;
+}
+
+/**
+* Display device list view.
+*
+* Called when start or refresh the WiFi direct
+*
+* @param[in] priv the _priv object
+*/
+static void _create_device_list_view(struct _priv *priv)
+{
+ wifi_direct_state_e status;
+ int ret;
+
+ if (!priv) {
+ _ERR("parameter is invalid.");
+ return;
+ }
+
+ if (priv->no_conn_ly)
+ evas_object_hide(priv->no_conn_ly);
+
+ ret = wifi_direct_mgr_get_state(&status);
+ if (ret != RET_SUCCESS) {
+ _ERR("get state failed.");
+ return;
+ }
+
+ if (status < WIFI_DIRECT_STATE_ACTIVATED) {
+ ret = wifi_direct_mgr_activate();
+ if (ret != RET_SUCCESS) {
+ _ERR("activate failed.");
+ return;
+ }
+ } else {
+ ret = wifi_direct_mgr_set_configure_num();
+ if (ret != RET_SUCCESS) {
+ _ERR("set configure num failed.");
+ return;
+ }
+
+ ret = wifi_direct_mgr_start_discovery();
+ if (ret != RET_SUCCESS) {
+ _ERR("start discovery failed.");
+ return;
+ }
+ }
+
+ _fill_content_part(priv, priv->genlist);
+
+ elm_object_focus_set(priv->btn_refresh, EINA_TRUE);
+}
+
+/**
+* Evas_object_Event_Cb type callback for handling delection event
+*
+* @param[in] data the user data
+* @param[in] e evas handler
+* @param[in] obj the corresponding object which clicked event occurred
+* @param[in] ei event information
+*/
+static void _popup_back_pressed_cb(void *data, Evas *e,
+ Evas_Object *obj, void *ei)
+{
+ Evas_Event_Key_Down *ev;
+ struct _priv *priv;
+
+ if (!data || !obj || !ei) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+ ev = ei;
+
+ if (!ev->keyname) {
+ _ERR("ev->keyname is NULL.");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_BACK)) {
+ if (priv->dim_ly)
+ evas_object_hide(priv->dim_ly);
+
+ evas_object_del(obj);
+ }
+}
+
+/**
+* Handle connection request.
+*
+* @param[in] info the target device infomation
+* @param[in] is_conn request type
+* @return 0 on success,otherwize -1
+*/
+int wifi_direct_cbbutton_connect(
+ struct device_info *info, int is_conn)
+{
+ int ret;
+ wifi_direct_wps_type_e wps_type;
+
+ if (!info) {
+ _ERR("parameter is NULL!");
+ return RET_FAILED;
+ }
+
+ if (is_conn) {
+ if ((info->wps_types & WIFI_DIRECT_WPS_TYPE_PBC)
+ == WIFI_DIRECT_WPS_TYPE_PBC)
+ wps_type = WIFI_DIRECT_WPS_TYPE_PBC;
+ else if ((info->wps_types & WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD) ==
+ WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD)
+ wps_type = WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD;
+ else if ((info->wps_types & WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY) ==
+ WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY)
+ wps_type = WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY;
+
+ ret = wifi_direct_mgr_set_wps_type(&wps_type);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("wifi_direct set wps type failev!");
+ return RET_FAILED;
+ }
+
+ ret = wifi_direct_mgr_connect(info->mac_addr);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("wifi_direct_connect:%s fail!", info->dev_name);
+ return RET_FAILED;
+ }
+ } else {
+ ret = wifi_direct_mgr_disconnect(info->mac_addr);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("wifi_direct_disconnect:%s fail!", info->dev_name);
+ return RET_FAILED;
+ }
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling click event.
+*
+* @param[in] data the user data
+* @param[in] obj the corresponding object which the click event occurred
+* @param[in] event_info event information
+*/
+static void _item_conn_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *event_inf)
+{
+ struct _priv *priv;
+ const char *value;
+ int ret;
+ Elm_Object_Item *gen_item;
+ struct device_info *info;
+ int cur_idx;
+
+ if (!data || !obj) {
+ _ERR("the param is invalid.");
+ return;
+ }
+
+ value = elm_object_text_get(obj);
+ if (!value) {
+ _ERR("get text from wifi_direct device btn is NULL.");
+ return;
+ }
+
+ priv = data;
+
+ gen_item = priv->popup_item;
+
+ cur_idx = elm_genlist_item_index_get(gen_item);
+ if (cur_idx < 0)
+ return;
+
+ info = eina_list_nth(priv->item_list, cur_idx);
+ if (!info)
+ return;
+
+ if (!strcmp(value, TXT_CONNECT)) {
+ ret = wifi_direct_cbbutton_connect(info, CONN_YES);
+ if (ret == RET_FAILED) {
+ _ERR("Connect failed");
+ return;
+ }
+
+ info->is_conn = EINA_TRUE;
+ } else if (!strcmp(value, TXT_DISCONNECT)) {
+ ret = wifi_direct_cbbutton_connect(info, CONN_NO);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("wifi_direct_mgr_disconnect failed,,%s",
+ info->mac_addr);
+ return;
+ }
+
+ strncpy(info->state, TXT_DISCONNECT, WIFI_DIRECT_STATE_BUF_LEN);
+ info->is_conn = EINA_FALSE;
+ }
+
+ if (priv->direct_popup) {
+ evas_object_del(priv->direct_popup);
+ priv->direct_popup = NULL;
+ }
+
+ if (priv->connect_popup) {
+ evas_object_del(priv->connect_popup);
+ priv->connect_popup = NULL;
+ }
+
+ if (priv->dim_ly)
+ evas_object_hide(priv->dim_ly);
+}
+
+/**
+* @Evas_Smart_Cb type callback for handling click event.
+*
+* @param[in] data the user data
+* @param[in] obj the corresponding object which the click event occurred
+* @param[in] event_info event information
+*/
+static void _genlist_item_select_cb(void *data,
+ Evas_Object *obj, void *event_info)
+{
+ struct _priv *priv;
+ Elm_Object_Item *gen_item;
+ Evas_Object *layout;
+ Evas_Object *box;
+ Evas_Object *item_btn;
+ Evas_Object *btn[BTN_DIRECT];
+ struct device_info *info;
+ int cur_idx;
+ int i;
+ int ret;
+ int btn_x;
+ int btn_y;
+ int btn_w;
+ int btn_h;
+ int move_x;
+ int move_y;
+
+ if (!data || !obj || !event_info) {
+ _ERR("The param is invalid.");
+ return;
+ }
+
+ priv = data;
+
+ if (!priv->dim_ly) {
+ ret = _create_wifi_direct_dim(priv);
+ if (ret != RET_SUCCESS) {
+ _fini_priv(priv);
+ return;
+ }
+ }
+
+ evas_object_show(priv->dim_ly);
+
+ gen_item = event_info;
+ priv->popup_item = gen_item;
+
+ layout = util_add_layout(priv->base, UG_WIFI_DIRECT_EDJ_FILE,
+ GRP_WIFI_DIRECT_SELECT);
+ if (!layout) {
+ _ERR("add connect popup failed.\n");
+ return;
+ }
+
+ box = util_add_box(layout, PART_SWALLOW_CONTENT);
+ if (!box) {
+ _ERR("add box failed.");
+ evas_object_del(layout);
+ return;
+ }
+
+ for (i = 0; i < BTN_DIRECT; i++) {
+ btn[i] = util_add_button(box, STYLE_POPUP_BUTTON, NULL,
+ _(popup_button_conn[i]));
+ if (!btn[i]) {
+ _ERR("add connect btn failed.");
+ evas_object_del(layout);
+ return;
+ }
+
+ elm_box_pack_end(box, btn[i]);
+ evas_object_smart_callback_add(btn[i], SIG_CLICKED,
+ _item_conn_btn_clicked_cb, priv);
+ evas_object_event_callback_add(btn[i],
+ EVAS_CALLBACK_MOUSE_IN,
+ _list_btn_mouse_in_cb, priv);
+ }
+
+ cur_idx = elm_genlist_item_index_get(gen_item);
+ if (cur_idx < 0)
+ return;
+
+ info = eina_list_nth(priv->item_list, cur_idx);
+ if (!info)
+ return;
+
+ if (info->is_conn)
+ elm_object_signal_emit(btn[DIRECT_ON],
+ SIG_BTN_SELECTED, PROG);
+ else
+ elm_object_signal_emit(btn[DIRECT_OFF],
+ SIG_BTN_SELECTED, PROG);
+
+ util_set_cycle_focus(btn, BTN_DIRECT);
+
+ item_btn = elm_object_item_track(gen_item);
+ if (!item_btn) {
+ _ERR("get genlist item track failed.");
+ evas_object_del(layout);
+ return;
+ }
+
+ evas_object_geometry_get(item_btn, &btn_x, &btn_y, &btn_w, &btn_h);
+
+ move_x = btn_x + btn_w - POPUP_WIDTH * HALF_SCALE - POPUP_RIGHT;
+ move_y = btn_y + btn_h;
+ evas_object_move(layout, move_x * ELM_SCALE, move_y * ELM_SCALE);
+ priv->connect_popup = layout;
+
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN,
+ _popup_back_pressed_cb, priv);
+
+ elm_object_focus_set(btn[0], EINA_TRUE);
+}
+
+/**
+* Check if the peer discovered is already in the list.
+*
+* @param[in] priv the _priv object bypassed
+* @param[in] new_info device_info object to be checked
+* @return 0 if exist,otherwise -1
+*/
+static Eina_Bool _is_peer_exist(struct _priv *priv,
+ struct device_info *new_info)
+{
+ struct device_info *cur_info;
+ Eina_List *l;
+
+ if (!priv || !new_info) {
+ _ERR("The param is invalid.");
+ return EINA_FALSE;
+ }
+
+ if (!priv->item_list) {
+ _ERR("The list is NULL now.");
+ return EINA_FALSE;
+ }
+
+ EINA_LIST_FOREACH(priv->item_list, l, cur_info) {
+ if (!strncmp(cur_info->mac_addr, new_info->mac_addr,
+ WIFI_DIRECT_DEFAULT_BUF_LEN - 1))
+ return EINA_TRUE;
+ }
+
+ return EINA_FALSE;
+}
+
+/**
+* Update the device connection state.
+*
+* @param[in] priv the _priv object bypassed
+* @param[in] conn connection type
+* @return 0 if exist,otherwise -1
+*/
+static Eina_Bool _update_device_conn_state(struct _priv *priv,
+ Eina_Bool conn)
+{
+ struct device_info *cur_info;
+ Eina_List *l;
+
+ EINA_LIST_FOREACH(priv->item_list, l, cur_info) {
+ if (!strncmp(cur_info->mac_addr, priv->req_addr,
+ WIFI_DIRECT_DEFAULT_BUF_LEN - 1)) {
+ cur_info->is_conn = conn;
+ return EINA_TRUE;
+ }
+ }
+
+ return EINA_FALSE;
+}
+
+/**
+* Update the device list.
+*
+* @param[in] priv the _priv object bypassed
+* @param[in] device_info new device infomation
+* @return 0 in success,otherwise -1
+*/
+static int _update_genlist_item(struct _priv *priv,
+ struct device_info *info)
+{
+ Eina_Bool exist;
+
+ if (!priv || !info || !priv->genlist) {
+ _ERR("The param is invalid.");
+ return RET_FAILED;
+ }
+
+ exist = _is_peer_exist(priv, info);
+ if (!exist) {
+ priv->item_list = eina_list_append(priv->item_list, info);
+
+ if (info->is_conn)
+ strncpy(info->state, TXT_CONNECT,
+ WIFI_DIRECT_STATE_BUF_LEN);
+ else
+ strncpy(info->state, TXT_DISCONNECT,
+ WIFI_DIRECT_STATE_BUF_LEN);
+
+ elm_genlist_item_append(priv->genlist, priv->itc, info, NULL,
+ ELM_GENLIST_ITEM_NONE, _genlist_item_select_cb,
+ (void *)priv);
+ }
+
+ return RET_SUCCESS;
+}
+
+/**
+* Called when the device state is WIFI_DIRECT_DISCOVERY_STARTED.
+*
+* @param[in] cd the callback functions to invoke
+* @param[in] data the user data
+*/
+static void _process_discovery_start(struct wifi_direct_cbs cbs,
+ void *data)
+{
+ int ret;
+ struct _priv *priv;
+ struct device_info *info;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+
+ if (priv->genlist)
+ elm_genlist_clear(priv->genlist);
+
+ if (priv->item_list)
+ EINA_LIST_FREE(priv->item_list, info)
+ free(info);
+
+ ret = wifi_direct_mgr_foreach_connected_peers(
+ cbs.connected_peer_cb, data);
+ if (ret != RET_SUCCESS) {
+ _ERR("foreach connected peers failed ");
+ return;
+ }
+
+ ret = _create_wifi_direct_scan(priv);
+ if (ret != RET_SUCCESS)
+ _ERR("_create_wifi_direct_scan failed ");
+}
+
+/**
+* Called when the device state is WIFI_DIRECT_DISCOVERY_FOUND.
+*
+* @param[in] cbs the callback functions
+* @param[in] data the user data
+*/
+static void _process_discovery_found(struct wifi_direct_cbs cbs,
+ void *data)
+{
+ int ret;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ ret = wifi_direct_mgr_foreach_discovered_peers(
+ cbs.discovered_peer_cb, data);
+ if (ret != RET_SUCCESS)
+ _ERR("foreach connected peers failed ");
+}
+
+/**
+* Called when the device state is WIFI_DIRECT_DISCOVERY_FINISHED.
+*
+* @param[in] data the user data
+*/
+static void _process_discovery_finished(void *data)
+{
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("Parameter is NULL.");
+ return;
+ }
+
+ priv = data;
+
+ elm_object_part_content_unset(priv->base, PART_REFRESH_BTN);
+ evas_object_hide(priv->btn_stop);
+
+ _show_action_btn(priv);
+
+ _fill_content_part(priv, priv->genlist);
+}
+
+/**
+* Evas_Smart_Cb type callback for handling click event.
+*
+* @param[in] data the user data
+* @param[in] obj the corresponding object which the click event occurred
+* @param[in] ev event information
+*/
+static void _req_btn_clicked_cb(void *data, Evas_Object *obj, void *ev)
+{
+ struct _priv *priv;
+ const char *value;
+ int ret;
+
+ if (!data || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ priv = data;
+
+ value = elm_object_text_get(obj);
+ if (!value) {
+ _ERR("get text from network type btn is NULL.");
+ return;
+ }
+
+ if (!strcmp(value, popup_button_req[DIRECT_ON])) {
+ ret = wifi_direct_mgr_accept_connection(priv->req_addr);
+ if (ret != RET_SUCCESS) {
+ _ERR("Disconnection failed.");
+ return;
+ }
+
+ ret = _update_device_conn_state(priv, EINA_TRUE);
+ if (ret != EINA_TRUE)
+ _ERR("_update_device_conn_state failed.");
+ } else {
+ ret = wifi_direct_mgr_reject_connection(priv->req_addr);
+ if (ret != RET_SUCCESS) {
+ _ERR("Accept connection failed.");
+ return;
+ }
+
+ ret = _update_device_conn_state(priv, EINA_FALSE);
+ if (ret != EINA_TRUE)
+ _ERR("_update_device_conn_state failed.");
+ }
+
+ free(priv->req_addr);
+ priv->req_addr = NULL;
+
+ if (priv->req_popup) {
+ evas_object_del(priv->req_popup);
+ priv->req_popup = NULL;
+ }
+
+ if (priv->dim_ly)
+ evas_object_hide(priv->dim_ly);
+}
+
+/**
+* Create the reqest popup when has connection request by other devices.
+*
+* @param[in] priv the _priv object bypassed
+* @return 0 on sucess, otherwise -1
+*/
+static int _create_req_popup_ly(struct _priv *priv)
+{
+ Evas_Object *layout;
+ Evas_Object *btn[BTN_DIRECT];
+ int i;
+ int x;
+ int y;
+ int w;
+ int h;
+
+ if (!priv || !priv->base) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ layout = util_add_layout(priv->base, UG_WIFI_DIRECT_EDJ_FILE,
+ GRP_CONNECT_ACCEPT);
+ if (!layout) {
+ _ERR("elm_layout_add() failed.\n");
+ return RET_FAILED;
+ }
+
+ for (i = 0; i < BTN_DIRECT; i++) {
+ btn[i] = util_add_button(layout, STYLE_POPUP_BUTTON,
+ part_req[i], _(popup_button_req[i]));
+ if (!btn[i]) {
+ _ERR("add btn req failed.");
+ evas_object_del(layout);
+ return RET_FAILED;
+ }
+
+ evas_object_smart_callback_add(btn[i],
+ SIG_CLICKED, _req_btn_clicked_cb, priv);
+ evas_object_event_callback_add(btn[i],
+ EVAS_CALLBACK_MOUSE_IN,
+ _list_btn_mouse_in_cb, priv);
+ }
+
+ evas_object_geometry_get(priv->genlist, &x, &y, &w, &h);
+ evas_object_move(layout, (x + RSP_X) * ELM_SCALE,
+ (y + RSP_Y) * ELM_SCALE);
+
+ priv->req_popup = layout;
+
+ elm_object_focus_set(btn[DIRECT_ON], EINA_TRUE);
+
+ evas_object_event_callback_add(layout,
+ EVAS_CALLBACK_KEY_DOWN, _popup_back_pressed_cb, priv);
+
+ return RET_SUCCESS;
+}
+
+/**
+* Process the connection request when the device state is WIFI_DIRECT_CONNECTION_REQ.
+*
+* @param[in] addr the MAC address
+* @param[in] data the user data
+*/
+static void _process_connection_req(const char *addr, void *data)
+{
+ struct _priv *priv;
+ Eina_Bool is_pbc;
+ int ret;
+
+ if (!data || !addr) {
+ _ERR("the param is invalid.");
+ return;
+ }
+
+ priv = data;
+
+ ret = wifi_direct_mgr_get_wps_type(&is_pbc);
+ if (ret != WIFI_DIRECT_ERROR_NONE) {
+ _ERR("Get wps type failed.");
+ return;
+ }
+
+ priv->req_addr = strdup(addr);
+ if (!priv->req_addr) {
+ _ERR("strdup wrong.");
+ return;
+ }
+
+ if (is_pbc == EINA_TRUE) {
+ ret = _create_req_popup_ly(priv);
+ if (ret != RET_SUCCESS)
+ _ERR("Create rep popup failed.");
+ }
+}
+
+/**
+* Called when the device state is WIFI_DIRECT_CONNECTION_PROG.
+*
+* @param[in] data The data to be passed to the function
+*/
+static void _process_connection_prog(void *data)
+{
+ struct _priv *priv;
+ Evas_Object *layout;
+ char title[MAX_STRING_LENTH];
+ int x;
+ int y;
+ int w;
+ int h;
+ int move_x;
+ int move_y;
+
+ if (!data) {
+ _ERR("the param is invalid.");
+ return;
+ }
+
+ priv = data;
+
+ if (priv->dim_ly)
+ evas_object_show(priv->dim_ly);
+
+ layout = util_add_layout(priv->base, UG_WIFI_DIRECT_EDJ_FILE,
+ GRP_CONNECT_ACCEPT);
+ if (!layout) {
+ _ERR("add con_popup layout failed.");
+ return;
+ }
+
+ memset(&title, 0x00, MAX_STRING_LENTH);
+ snprintf(title, MAX_STRING_LENTH - 1, "%s", TXT_CONN_PROG);
+ elm_object_part_text_set(layout, PART_TITLE, title);
+
+ evas_object_geometry_get(priv->on_btn, &x, &y, &w, &h);
+ move_x = x + w - POPUP_WIDTH * HALF_SCALE - POPUP_RIGHT;
+ move_y = y + CENTER_HEIGHT;
+ evas_object_move(layout, move_x * ELM_SCALE, move_y * ELM_SCALE);
+
+ priv->prog_popup = layout;
+}
+
+/**
+* Starts the device discovery when timer is empired.
+*
+* @param[in] data the user data
+* @return ECORE_CALLBACK_CANCEL returns to finish time
+*/
+static Eina_Bool _connection_ind_cb(void *data)
+{
+ int ret;
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("the param is invalid.");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ priv = data;
+
+ ret = wifi_direct_mgr_start_discovery();
+ if (ret != RET_SUCCESS)
+ _ERR("start discovery failed.");
+
+ priv->timer = NULL;
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+/**
+* Called when the device state is WIFI_DIRECT_DISCONNECTION_IND.
+*
+* @param[in] data The data to be passed to the function
+*/
+static void _process_connection_ind(void *data)
+{
+ struct _priv *priv;
+ Ecore_Timer *timer;
+
+ if (!data) {
+ _ERR("parameter is invalid.");
+ return;
+ }
+
+ priv = data;
+
+ timer = ecore_timer_add(HANDLER_INTERVAL, _connection_ind_cb, priv);
+ if (!timer) {
+ _ERR("add timer failed.");
+ return;
+ }
+
+ priv->timer = timer;
+}
+
+/**
+* Called when the device state is WIFI_DIRECT_CONNECTION_RSP
+*
+* @param[in] data the user data
+*/
+static void _process_connection_rsp(void *data)
+{
+ struct _priv *priv;
+ struct device_info *info;
+ int cur_index;
+
+ if (!data) {
+ _ERR("the param is invalid.");
+ return;
+ }
+
+ priv = data;
+
+ cur_index = priv->conn_idx;
+ info = eina_list_nth(priv->item_list, cur_index);
+ if (!info)
+ return;
+
+ info->is_conn = EINA_TRUE;
+ strncpy(info->state, TXT_CONNECT, WIFI_DIRECT_STATE_BUF_LEN);
+
+ elm_genlist_item_update(priv->popup_item);
+
+ if (priv->dim_ly)
+ evas_object_hide(priv->dim_ly);
+
+ if (priv->prog_popup) {
+ evas_object_del(priv->prog_popup);
+ priv->prog_popup = NULL;
+ }
+
+ if (priv->connect_popup) {
+ evas_object_del(priv->connect_popup);
+ priv->connect_popup = NULL;
+ }
+}
+
+/**
+* Callback function is called when device state is changed.
+*
+* @param[in] errcode error code
+* @param[in] state WiFi Direct device state
+* @param[in] data the user data
+*/
+static void _device_state_changed_cb(int errcode,
+ wifi_direct_device_state_e state, void *data)
+{
+ int ret;
+ struct _priv *priv;
+
+ if (!data) {
+ _ERR("The param is invalid.");
+ return;
+ }
+
+ priv = data;
+
+ if (state != WIFI_DIRECT_DEVICE_STATE_ACTIVATED) {
+ elm_genlist_clear(priv->genlist);
+ return;
+ }
+
+ ret = wifi_direct_mgr_set_configure_num();
+ if (ret != RET_SUCCESS) {
+ _ERR("set configure num failed.");
+ return;
+ }
+
+ ret = wifi_direct_mgr_start_discovery();
+ if (ret != RET_SUCCESS)
+ _ERR("start discovery failed.");
+}
+
+/**
+* Callback function is called when discovery state is changed.
+*
+* discovery state:
+* WIFI_DIRECT_DISCOVERY_STARTED
+* WIFI_DIRECT_DISCOVERY_FOUND
+* WIFI_DIRECT_DISCOVERY_FINISHED
+*
+* @param[in] errcode error code
+* @param[in] state WiFi Direct descovery state
+* @param[in] data the user data
+*/
+static void _discovery_state_changed_cb(
+ int errcode, wifi_direct_discovery_state_e state, void *data)
+{
+ if (!state || !data) {
+ _ERR("data is invalid.");
+ return;
+ }
+
+ switch (state) {
+ case WIFI_DIRECT_DISCOVERY_STARTED:
+ _process_discovery_start(cbs, data);
+ break;
+ case WIFI_DIRECT_DISCOVERY_FOUND:
+ _process_discovery_found(cbs, data);
+ break;
+ case WIFI_DIRECT_DISCOVERY_FINISHED:
+ _process_discovery_finished(data);
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+* Callback function is called when connection state is changed.
+*
+* connection state:
+* WIFI_DIRECT_CONNECTION_REQ
+* WIFI_DIRECT_CONNECTION_IN_PROGRESS
+* WIFI_DIRECT_CONNECTION_RSP
+* WIFI_DIRECT_DISCONNECTION_IND
+* ...
+*
+* @param[in] errcode error code
+* @param[in] state WiFi Direct descovery state
+* @param[in] data the user data passed
+*/
+static void _connection_state_changed_cb(int errcode,
+ wifi_direct_connection_state_e state,
+ const char *addr, void *data)
+{
+ if (!state || !addr || !data) {
+ _ERR("The param is invalid.");
+ return;
+ }
+
+ switch (state) {
+ case WIFI_DIRECT_CONNECTION_REQ:
+ _process_connection_req(addr, data);
+ break;
+ case WIFI_DIRECT_CONNECTION_IN_PROGRESS:
+ _process_connection_prog(data);
+ break;
+ case WIFI_DIRECT_CONNECTION_RSP:
+ _process_connection_rsp(data);
+ break;
+ case WIFI_DIRECT_DISCONNECTION_IND:
+ _process_connection_ind(data);
+ break;
+ default:
+ break;
+ }
+}
+
+/**
+* Called for each connected peer and save its information.
+*
+* @param[in] conn_info wifi_direct_connected_peer_info_s store info of connected peer
+* @param[in] data the user data
+* @return EINA_TURE on success, otherwise EINA_FALSE
+*/
+static bool _connected_peer_cb(
+ wifi_direct_connected_peer_info_s * conn_info, void *data)
+{
+ struct _priv *priv;
+ struct device_info *info;
+ int ret;
+
+ if (!conn_info || !data) {
+ _ERR("The param is NULL.");
+ return EINA_FALSE;
+ }
+
+ priv = data;
+
+ info = calloc(1, sizeof(*info));
+ if (!info) {
+ _ERR("calloc failed.");
+ return EINA_FALSE;
+ }
+
+ strncpy(info->dev_name, conn_info->device_name,
+ WIFI_DIRECT_DEFAULT_BUF_LEN);
+ strncpy(info->mac_addr, conn_info->mac_address,
+ WIFI_DIRECT_DEFAULT_BUF_LEN);
+ info->is_conn = EINA_TRUE;
+
+ ret = _update_genlist_item(priv, info);
+ if (ret != RET_SUCCESS) {
+ _ERR("update genlist view failed.");
+ free(info);
+ return EINA_FALSE;
+ }
+
+ return EINA_TRUE;
+}
+
+/**
+* Called for each discovered peer and save its information.
+*
+* @param[in] discov_info wifi_direct_discovered_peer_info_s store info of discovered peer
+* @param[in] data the user data passed to the callback function
+* @return EINA_TURE on success, otherwise EINA_FALSE
+*/
+static bool _discoverd_peers_cb(
+ wifi_direct_discovered_peer_info_s * discov_info,
+ void *data)
+{
+ struct _priv *priv;
+ struct device_info *info;
+ int ret;
+
+ if (!discov_info || !data) {
+ _ERR("The param is invalid.");
+ return EINA_FALSE;
+ }
+
+ priv = data;
+ info = calloc(1, sizeof(*info));
+ if (!info) {
+ _ERR("calloc failed.");
+ return EINA_FALSE;
+ }
+
+ strncpy(info->dev_name, discov_info->device_name,
+ WIFI_DIRECT_DEFAULT_BUF_LEN);
+ strncpy(info->mac_addr, discov_info->mac_address,
+ WIFI_DIRECT_DEFAULT_BUF_LEN);
+ info->is_conn = discov_info->is_connected;
+ info->wps_types = discov_info->supported_wps_types;
+
+ ret = _update_genlist_item(priv, info);
+ if (ret != RET_SUCCESS) {
+ _ERR("update genlist view failed.");
+ free(info);
+ return EINA_FALSE;
+ }
+
+ return EINA_TRUE;
+}
+
+/**
+* Refresh the ON/OFF sign on the Wi-Fi Direct button when popup button is clicked.
+*
+* @param[in] priv _priv object bypassed
+*/
+static void _refresh_wifi_direct_on_text(struct _priv *priv)
+{
+ if (!priv) {
+ _ERR("the param is invalid.");
+ return;
+ }
+
+ if (priv->scan_ly)
+ evas_object_hide(priv->scan_ly);
+
+ if (priv->direct_on_flag == DIRECT_ON)
+ elm_object_part_text_set(priv->on_btn, PART_WIFI_DIRECT_SELECT,
+ _(popup_button_on[DIRECT_ON]));
+ else
+ elm_object_part_text_set(priv->on_btn, PART_WIFI_DIRECT_SELECT,
+ _(popup_button_on[DIRECT_OFF]));
+}
+
+/**
+* Set the object to the specified part.
+*
+* @param[in] priv _priv object bypassed
+* @param[in] obj Evas_Object to be set to the part
+*/
+static void _fill_content_part(struct _priv *priv, Evas_Object *obj)
+{
+ Evas_Object *old_obj;
+
+ if (!priv || !obj) {
+ _ERR("The param is invalid.\n");
+ return;
+ }
+
+ old_obj = elm_object_part_content_get(priv->base, PART_GENLIST_ITEMS);
+ if (old_obj) {
+ elm_object_part_content_unset(priv->base, PART_GENLIST_ITEMS);
+ evas_object_hide(old_obj);
+ }
+
+ elm_object_part_content_set(priv->base, PART_GENLIST_ITEMS, obj);
+ evas_object_show(obj);
+}
+
+/**
+* Create the Wi-Fi Direct off layout, but does not show here.
+*
+* @param[in] priv _priv object bypassed
+* @return 0 on success,otherwise -1
+*/
+static int _create_wifi_direct_disconnect_part(struct _priv *priv)
+{
+ Evas_Object *ly;
+
+ if (!priv || !priv->base) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ ly = util_add_layout(priv->base,
+ UG_WIFI_DIRECT_EDJ_FILE, GRP_WIFIDIRECT_DISCONNECT_LY);
+ if (!ly) {
+ _ERR("Add noconnect_ly failed.\n");
+ return RET_FAILED;
+ }
+
+ elm_object_part_text_set(ly, PART_DISCONNECT_TEXT,
+ TXT_WIFIDIRECT_NONE);
+
+ priv->no_conn_ly = ly;
+ evas_object_hide(ly);
+
+ return RET_SUCCESS;
+}
+
+/**
+* Called when WiFi Direct is off .
+*
+* @param[in] priv _priv object bypassed
+* @return 0 on success, otherwise -1
+*/
+static int _display_wifi_direct_disconnect(struct _priv *priv)
+{
+ int ret;
+
+ if (!priv) {
+ _ERR("the param is invalid.");
+ return RET_FAILED;
+ }
+
+ if (!priv->no_conn_ly) {
+ ret = _create_wifi_direct_disconnect_part(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("_create_wifi_direct_disconnect_part failed.");
+ return RET_FAILED;
+ }
+ }
+
+ _fill_content_part(priv, priv->no_conn_ly);
+
+ elm_object_part_content_unset(priv->base, PART_REFRESH_BTN);
+ evas_object_hide(priv->btn_refresh);
+ elm_object_part_content_set(priv->base, PART_REFRESH_BTN,
+ priv->btn_close);
+ evas_object_show(priv->btn_close);
+
+ evas_object_smart_callback_add(priv->btn_close,
+ SIG_CLICKED, _close_btn_clicked_cb, priv);
+ evas_object_event_callback_add(priv->btn_close,
+ EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv);
+
+ return RET_SUCCESS;
+}
+
+/**
+* Evas_Smart_Cb type callback for handling on/off button click event.
+*
+* @param[in] data the user data
+* @param[in] obj the corresponding object which the click event occurred
+* @param[in] event_inf event information
+*/
+static void _wifi_direct_select_btn_cb(void *data,
+ Evas_Object *obj, void *event_inf)
+{
+ struct _priv *priv;
+ struct device_info *info;
+ const char *value;
+ int ret;
+
+ if (!data || !obj) {
+ _ERR("the param is invalid.");
+ return;
+ }
+
+ priv = data;
+
+ value = elm_object_text_get(obj);
+ if (!value) {
+ _ERR("get text from network type btn is NULL.");
+ return;
+ }
+
+ if (!strcmp(value, popup_button_on[DIRECT_ON])) {
+ if (priv->direct_on_flag == DIRECT_OFF) {
+ priv->direct_on_flag = DIRECT_ON;
+
+ elm_genlist_clear(priv->genlist);
+
+ if (priv->item_list)
+ EINA_LIST_FREE(priv->item_list, info)
+ free(info);
+
+ _create_device_list_view(priv);
+
+ _show_action_btn(priv);
+ }
+ } else {
+ priv->direct_on_flag = DIRECT_OFF;
+
+ ret = _display_wifi_direct_disconnect(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("_display_wifi_direct_disconnect failed.");
+ return;
+ }
+
+ ret = wifi_direct_mgr_deactivate();
+ if (ret != RET_SUCCESS) {
+ _ERR("wif direct deactivate failed.");
+ return;
+ }
+ }
+
+ _refresh_wifi_direct_on_text(priv);
+
+ if (priv->direct_popup) {
+ evas_object_del(priv->direct_popup);
+ priv->direct_popup = NULL;
+ }
+
+ if (priv->dim_ly)
+ evas_object_hide(priv->dim_ly);
+}
+
+/**
+* Evas_Smart_Cb type callback for handling click event.
+*
+* @param[in] data the user data
+* @param[in] obj the corresponding object which the click event occurred
+* @param[in] event_inf event information
+*/
+static void _wifi_direct_btn_clicked_cb(void *data,
+ Evas_Object *obj, void *event_inf)
+{
+ Evas_Object *layout;
+ Evas_Object *box;
+ Evas_Object *btn[BTN_DIRECT];
+ struct _priv *priv;
+ int ret;
+ int i;
+ int btn_x;
+ int btn_y;
+ int btn_w;
+ int btn_h;
+ int move_x;
+ int move_y;
+
+ if (!data) {
+ _ERR("Parameter error!");
+ return;
+ }
+
+ priv = data;
+
+ if (!priv->dim_ly) {
+ ret = _create_wifi_direct_dim(priv);
+ if (ret != RET_SUCCESS) {
+ _fini_priv(priv);
+ return;
+ }
+ }
+
+ evas_object_show(priv->dim_ly);
+
+ layout = util_add_layout(priv->base, UG_WIFI_DIRECT_EDJ_FILE,
+ GRP_WIFI_DIRECT_SELECT);
+ if (!layout)
+ return;
+
+ elm_object_focus_allow_set(layout, EINA_TRUE);
+
+ box = util_add_box(layout, PART_SWALLOW_CONTENT);
+ if (!box) {
+ evas_object_del(layout);
+ return;
+ }
+
+ for (i = 0; i < BTN_DIRECT; i++) {
+ btn[i] = util_add_button(box, STYLE_POPUP_BUTTON, NULL,
+ _(popup_button_on[i]));
+ if (!btn[i]) {
+ _ERR("add btn direct failed.");
+ evas_object_del(layout);
+ return;
+ }
+
+ elm_box_pack_end(box, btn[i]);
+ evas_object_smart_callback_add(btn[i], SIG_CLICKED,
+ _wifi_direct_select_btn_cb, priv);
+ evas_object_event_callback_add(btn[i],
+ EVAS_CALLBACK_MOUSE_IN,
+ _list_btn_mouse_in_cb, priv);
+ }
+
+ if (priv->direct_on_flag == DIRECT_ON)
+ elm_object_signal_emit(btn[DIRECT_ON],
+ SIG_BTN_SELECTED, PROG);
+ else
+ elm_object_signal_emit(btn[DIRECT_OFF],
+ SIG_BTN_SELECTED, PROG);
+
+ util_set_cycle_focus(btn, BTN_DIRECT);
+
+ evas_object_geometry_get(priv->on_btn, &btn_x, &btn_y, &btn_w, &btn_h);
+ move_x = btn_x + btn_w - POPUP_WIDTH * HALF_SCALE - POPUP_RIGHT;
+ move_y = btn_y + btn_h;
+ evas_object_move(layout, move_x * ELM_SCALE, move_y * ELM_SCALE);
+
+ priv->direct_popup = layout;
+
+ evas_object_event_callback_add(layout, EVAS_CALLBACK_KEY_DOWN,
+ _popup_back_pressed_cb, priv);
+
+ elm_object_focus_set(btn[0], EINA_TRUE);
+}
+
+/**
+* Set the Wi-Fi Direct description.
+*
+* @param[in] priv _priv object bypassed
+*/
+static void _set_description(struct _priv *priv)
+{
+ char descrption[MAX_STRING_LENTH];
+
+ if (!priv) {
+ _ERR("priv is invalid.");
+ return;
+ }
+
+ memset(&descrption, 0x00, MAX_STRING_LENTH);
+ snprintf(descrption, MAX_STRING_LENTH - 1, "%s", TXT_WIFI_DIRECT_DISC);
+ elm_object_part_text_set(priv->base, PART_DESCRIPTION, descrption);
+}
+
+/**
+* Create the Wi-Fi Direct state button.
+*
+* @param[in] priv _priv object bypassed
+* @return 0 on success, -1 otherwise
+*/
+static int _create_wifi_direct_button(struct _priv *priv)
+{
+ Evas_Object *on_btn;
+ Evas_Object *base;
+
+ if (!priv || !priv->base) {
+ _ERR("Parameter error!");
+ return RET_FAILED;
+ }
+
+ base = priv->base;
+
+ on_btn = util_add_button(base, STYLE_WIFI_DIRECT_BTN,
+ PART_WIFI_DIRECT_ON, TXT_WIFI_DIRECT);
+ if (!on_btn) {
+ _ERR("Add wifi direct button failed.");
+ return RET_FAILED;
+ }
+
+ elm_object_focus_allow_set(on_btn, EINA_TRUE);
+ elm_object_focus_set(on_btn, EINA_TRUE);
+ elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_UP);
+ elm_object_focus_next_object_set(on_btn, on_btn, ELM_FOCUS_LEFT);
+
+ evas_object_smart_callback_add(on_btn, SIG_CLICKED,
+ _wifi_direct_btn_clicked_cb, priv);
+ evas_object_event_callback_add(on_btn,
+ EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv);
+
+ priv->on_btn = on_btn;
+
+ _refresh_wifi_direct_on_text(priv);
+
+ return RET_SUCCESS;
+}
+
+/**
+* Create the genlist item text label.
+*
+* @param[in] data the user data
+* @return pointer pointing to the text label
+*/
+static char *_item_label_get(void *data, Evas_Object *obj,
+ const char *part)
+{
+ struct device_info *info;
+ char buf_name[WIFI_DIRECT_DEFAULT_BUF_LEN];
+
+ if (!data) {
+ _ERR("data is NULL.");
+ return NULL;
+ }
+
+ info = data;
+
+ memset(&buf_name, 0x00, WIFI_DIRECT_DEFAULT_BUF_LEN);
+ if (!strcmp(part, TXT_ELM_TEXT)) {
+ strncpy(buf_name, info->dev_name, WIFI_DIRECT_HALF_BUF_LEN);
+ strncat(buf_name, TXT_COLON, WIFI_DIRECT_COLON_LEN);
+ strncat(buf_name, info->state, WIFI_DIRECT_HALF_BUF_LEN);
+
+ return strdup(buf_name);
+ }
+
+ return NULL;
+}
+
+/**
+* Create the genlist object.
+*
+* @param[in] priv _priv object bypassed
+* @return genlist object on success, otherwise NULL
+*/
+static Evas_Object *_create_genlist(struct _priv *priv)
+{
+ Evas_Object *genlist;
+ Elm_Genlist_Item_Class *itc;
+
+ if (!priv || !priv->base) {
+ _ERR("priv is invalid.");
+ return NULL;
+ }
+
+ genlist = elm_genlist_add(priv->base);
+ if (!genlist) {
+ _ERR("add genlist failed.");
+ return NULL;
+ }
+
+ priv->genlist = genlist;
+
+ itc = elm_genlist_item_class_new();
+ if (!itc) {
+ _ERR("genlist item class new failed.");
+ evas_object_del(genlist);
+ return NULL;
+ }
+
+ itc->item_style = STYLE_TEXT_ICON;
+ itc->func.text_get = _item_label_get;
+ itc->func.content_get = NULL;
+ itc->func.state_get = NULL;
+ itc->func.del = NULL;
+
+ priv->itc = itc;
+
+ evas_object_size_hint_weight_set(genlist,
+ EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(genlist,
+ EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_object_focus_next_object_set(genlist, genlist, ELM_FOCUS_LEFT);
+
+ return genlist;
+}
+
+/**
+* Creates the action buttons including refresh button and close button.
+*
+* @param[in] priv _priv object bypassed
+* @return 0 on success, otherwise -1
+*/
+static int _create_action_btn(struct _priv *priv)
+{
+ Evas_Object *btn_refresh;
+ Evas_Object *btn_close;
+
+ if (!priv || !priv->base) {
+ _ERR("priv is invalid.");
+ return RET_FAILED;
+ }
+
+ btn_refresh = util_add_button(priv->base, STYLE_ACTION_BUTTON,
+ PART_REFRESH_BTN, _(action_button[ACTION_BTN_REFRESH]));
+ btn_close = util_add_button(priv->base, STYLE_ACTION_BUTTON,
+ PART_CLOSE_BTN, _(action_button[ACTION_BTN_CLOSE]));
+
+ priv->btn_refresh = btn_refresh;
+ priv->btn_close = btn_close;
+
+ evas_object_event_callback_add(priv->btn_refresh,
+ EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv);
+ evas_object_smart_callback_add(priv->btn_refresh,
+ SIG_CLICKED, _refresh_btn_clicked_cb, priv);
+ evas_object_event_callback_add(priv->btn_close,
+ EVAS_CALLBACK_MOUSE_IN, _list_btn_mouse_in_cb, priv);
+ evas_object_smart_callback_add(priv->btn_close,
+ SIG_CLICKED, _close_btn_clicked_cb, priv);
+
+ return RET_SUCCESS;
+}
+
+/**
+* Initialize Wi-Fi Direct stack.
+*
+* @param[in] priv _priv object bypassed
+* @return 0 on success, otherwise -1
+*/
+static int _wifi_direct_view_stack_init(struct _priv *priv)
+{
+ int ret;
+
+ if (!priv) {
+ _ERR("priv is NULL.");
+ return RET_FAILED;
+ }
+
+ ret = wifi_direct_mgr_wifi_init();
+ if (ret != RET_SUCCESS) {
+ _ERR("init wifi failed.");
+ return ret;
+ }
+
+ ret = wifi_direct_mgr_wifi_direct_init();
+ if (ret != RET_SUCCESS) {
+ _ERR("init wifi direct failed.");
+ wifi_direct_mgr_wifi_fini();
+ return ret;
+ }
+
+ ret = wifi_direct_mgr_register_callback(&cbs, (void *)priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("register callback failed.");
+ wifi_direct_mgr_wifi_fini();
+ wifi_direct_mgr_wifi_direct_fini();
+ return ret;
+ }
+
+ return ret;
+}
+
+/**
+* Evas_Object_Event_Cb type callback for handling deletion event.
+*
+* @param[in] data the user data
+* @param[in] e evas handler
+* @param[in] obj the corresponding object which the deletion event occurred
+* @param[in] event_info event information
+*/
+static void _base_layout_key_down_cb(void *data,
+ Evas *e, Evas_Object *obj, void *event_info)
+{
+ struct _priv *priv;
+ Evas_Event_Key_Down *ei;
+
+ if (!data || !event_info) {
+ _ERR("the param is invalid.");
+ return;
+ }
+
+ priv = data;
+ ei = event_info;
+
+ if (!ei->keyname) {
+ _ERR("ei->keyname is NULL.");
+ return;
+ }
+
+ if (!priv->ug) {
+ _ERR("priv->ug -s NULL.");
+ return;
+ }
+
+ if (!strcmp(ei->keyname, KEY_BACK) ||
+ !strcmp(ei->keyname, KEY_EXIT)) {
+ ug_destroy_me(priv->ug);
+ _fini_priv(priv);
+ }
+}
+
+/**
+* Create wifi direct main view.
+*
+* @param[in] win parent window
+* @param[in] ug UI gadget object
+* @return base layout
+*/
+Evas_Object *wifi_direct_view_create(Evas_Object *win, ui_gadget_h ug)
+{
+ Evas_Object *base;
+ Evas_Object *obj;
+ struct _priv *priv;
+ int ret;
+
+ if (!win || !ug) {
+ _ERR("The param is invalid.\n");
+ return NULL;
+ }
+
+ priv = _init_priv();
+ if (!priv) {
+ _ERR("calloc priv failed.\n");
+ return NULL;
+ }
+
+ priv->win = win;
+ priv->ug = ug;
+ priv->direct_on_flag = DIRECT_ON;
+
+ ret = _wifi_direct_view_stack_init(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("wifi direct view stack init failed.");
+ goto error;
+ }
+
+ base = util_add_layout(win, UG_WIFI_DIRECT_EDJ_FILE, GRP_MAIN);
+ if (!base) {
+ _ERR("Add base layout failed.\n");
+ goto error;
+ }
+
+ priv->base = base;
+
+ _set_description(priv);
+
+ ret = _create_wifi_direct_button(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("fail to create wifi direct button.");
+ goto error;
+ }
+
+ obj = _create_genlist(priv);
+ if (!obj) {
+ _ERR("fail to create genlist.");
+ goto error;
+ }
+
+ ret = _create_action_btn(priv);
+ if (ret != RET_SUCCESS) {
+ _ERR("fail to create action button.");
+ goto error;
+ }
+
+ _create_device_list_view(priv);
+
+ evas_object_event_callback_add(base, EVAS_CALLBACK_KEY_DOWN,
+ _base_layout_key_down_cb, priv);
+
+ evas_object_show(base);
+
+ return base;
+
+error:
+ _fini_priv(priv);
+ return NULL;
+}