From: sungsik jang Date: Wed, 22 Aug 2012 06:04:19 +0000 (+0900) Subject: tizen 2.0beta X-Git-Tag: 2.0_alpha~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2862180e1407377dd19d90f46291e95fa57b5979;p=apps%2Fnative%2Fug-wifi-direct.git tizen 2.0beta Change-Id: Ibd5455c39cb9f809e0518f481c13356d1a4ea37e --- diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index d688359..0000000 --- a/AUTHORS +++ /dev/null @@ -1,3 +0,0 @@ -Dongwook Lee -Sungsik Jang -Gibyoung Kim diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index 0110117..e1ffdd1 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,13 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs REQUIRED appcore-efl appsvc ui-gadget x11 dlog +pkg_check_modules(pkgs REQUIRED appcore-efl appsvc ui-gadget-1 x11 dlog elementary ecore-x - network pmapi + capi-network-tethering network pmapi wifi-direct + notification + capi-appfw-application + syspopup-caller ) FOREACH(flag ${pkgs_CFLAGS}) @@ -13,4 +16,5 @@ ENDFOREACH(flag) ADD_SUBDIRECTORY(popup-wifidirect) ADD_SUBDIRECTORY(ug-wifidirect) +ADD_SUBDIRECTORY(ugapp-wifidirect) diff --git a/LICENSE b/LICENSE index bbc9fc3..7ccb5b5 100644 --- a/LICENSE +++ b/LICENSE @@ -73,5 +73,3 @@ To apply the Flora License to your work, attach the following boilerplate notice 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. - - diff --git a/NOTICE b/NOTICE index e69de29..4297ee3 100644 --- a/NOTICE +++ b/NOTICE @@ -0,0 +1 @@ +Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. diff --git a/debian/changelog b/debian/changelog old mode 100644 new mode 100755 index 2492f00..4598de6 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,236 @@ +ug-setting-wifidirect-efl (0.7.4) unstable; urgency=low + + * Update package & file name for tizen_2.0 beta. + * Git: apps/home/ug-wifi-direct + * Tag: libug-setting-wifidirect-efl_0.7.4 + + -- Wang Gu Wed, 16 Aug 2012 17:30:00 +0900 + +ug-setting-wifidirect-efl (0.7.3) unstable; urgency=low + + * modified the crash problerm when disabling Tethering. + * Git: apps/home/ug-wifi-direct + * Tag: libug-setting-wifidirect-efl_0.7.3 + + -- Sungsik Jang Thu, 16 Aug 2012 14:38:06 +0900 + +ug-setting-wifidirect-efl (0.7.2) unstable; urgency=low + + * Add padding in dialogue group + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.7.2 + + -- Wang Gu Wed, 15 Aug 2012 18:00:00 +0900 + +ug-setting-wifidirect-efl (0.7.1) unstable; urgency=low + + * Adjusted the margin of genlist. + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.7.1 + + -- Sungsik Jang Mon, 13 Aug 2012 10:25:15 +0900 + +ug-setting-wifidirect-efl (0.7.0) unstable; urgency=low + + * Update automatic turn off and about genlist + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.7.0 + + -- Wang Gu Fri, 10 Aug 2012 16:05:00 +0900 + +ug-setting-wifidirect-efl (0.6.9) unstable; urgency=low + + * Fix the white icons and cutted progressbar + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.6.9 + + -- Wang Gu Thu, 09 Aug 2012 15:30:00 +0900 + +ug-setting-wifidirect-efl (0.6.8) unstable; urgency=low + + * Update conn_status field and fix grey color pop-up buttons + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.6.8 + + -- Wang Gu Wed, 08 Aug 2012 16:50:00 +0900 + +ug-setting-wifidirect-efl (0.6.7) unstable; urgency=low + + * Fix the blank about genlist + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.6.7 + + -- Wang Gu Tue, 07 Aug 2012 16:40:00 +0900 + +ug-setting-wifidirect-efl (0.6.6) unstable; urgency=low + + * tag updated. + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.6.6 + + -- Sungsik Jang Tue, 07 Aug 2012 14:22:32 +0900 + +ug-setting-wifidirect-efl (0.6.5) unstable; urgency=low + + * applied the managed API of Tethering. + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.6.5 + + -- Sungsik Jang Tue, 07 Aug 2012 13:04:00 +0900 + +ug-setting-wifidirect-efl (0.6.4) unstable; urgency=low + + * Fix display bug about stop button and apply winset GUI guideline + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.6.4 + + -- Wang Gu Mon, 06 Aug 2012 15:40:00 +0900 + +ug-setting-wifidirect-efl (0.6.3) unstable; urgency=low + + * Applied the Manifest #2 + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.6.3 + + -- Sungsik Jang Wed, 01 Aug 2012 17:35:45 +0900 + +ug-setting-wifidirect-efl (0.6.2) unstable; urgency=low + + * Applied the Manifest + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.6.2 + + -- Sungsik Jang Tue, 31 Jul 2012 13:54:48 +0900 + +ug-setting-wifidirect-efl (0.6.1) unstable; urgency=low + + * Remove the string when complete to active + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.6.1 + + -- Wang Gu Fri, 20 July 2012 17:00:00 +0900 + +ug-setting-wifidirect-efl (0.6.0) unstable; urgency=low + + * Remove activated notification and verify the strings + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.6.0 + + -- Wang Gu Thu, 19 July 2012 16:40:00 +0900 + +ug-setting-wifidirect-efl (0.5.9) unstable; urgency=low + + * Add failed device list and remove 'Multi connect' button when only one device + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.5.9 + + -- Wang Gu Thu, 19 July 2012 09:30:00 +0900 + +ug-setting-wifidirect-efl (0.5.8) unstable; urgency=low + + * Update UG by UG Modification Guide + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.5.8 + + -- Wang Gu Wed, 18 July 2012 18:55:52 +0900 + +ug-setting-wifidirect-efl (0.5.7) unstable; urgency=low + + * stripped package + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.5.7 + + -- Sungsik Jang Mon, 16 Jul 2012 13:26:19 +0900 + +ug-setting-wifidirect-efl (0.5.6) unstable; urgency=low + + * Enable 'scan' button when WFD is off and sync popup and UG when connection + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.5.6 + + -- Wang Gu Thu, 12 July 2012 10:00:52 +0900 + +ug-setting-wifidirect-efl (0.5.5) unstable; urgency=low + + * Add searching progressbar and selected(n) in multi connect view + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.5.5 + + -- Wang Gu Wed, 11 July 2012 10:50:52 +0900 + +ug-setting-wifidirect-efl (0.5.4) unstable; urgency=low + + * WPS Keypad/Display bug fix + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.5.4 + + -- Dongwook Lee Sat, 7 July 2012 04:23:02 +0900 + +ug-setting-wifidirect-efl (0.5.3) unstable; urgency=low + + * Launch WiFi direct UG from notification + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.5.3 + + -- Dongwook Lee Fri, 15 June 2012 16:30:52 +0900 + +ug-setting-wifidirect-efl (0.5.2) unstable; urgency=low + + * Add notification and perfect the scan operation + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.5.2 + + -- Wang Gu Fri, 8 June 2012 18:30:52 +0900 + +ug-setting-wifidirect-efl (0.5.1) unstable; urgency=low + + * UI bug is fixed in the Multi connect view + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.5.1 + + -- Gibyoung Kim Thu, 24 May 2012 01:50:52 +0900 + +ug-setting-wifidirect-efl (0.5.0) unstable; urgency=low + + * New UX is implemented. + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.5.0 + + -- Dongwook Lee Mon, 21 May 2012 12:40:52 +0900 + +ug-setting-wifidirect-efl (0.4.6) unstable; urgency=low + + * Remove unused vconf keys + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.4.6 + + -- Gibyoung Kim Tue, 15 May 2012 19:22:51 +0900 + +ug-setting-wifidirect-efl (0.4.5) unstable; urgency=low + + * changed enum of WPS type + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.4.5 + + -- Sungsik Jang Fri, 11 May 2012 14:57:50 +0900 + +ug-setting-wifidirect-efl (0.4.4) unstable; urgency=low + + * UG can be used for SLP_PQ from now on. + * bug fix from Dongwook Lee + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.4.4 + + -- Gibyoung Kim Fri, 04 May 2012 13:45:05 +0900 + +ug-setting-wifidirect-efl (0.4.3) unstable; urgency=low + + * API to get window is changed(request from Qing Yang) + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.4.3 + + -- Gibyoung Kim Wed, 25 Apr 2012 20:32:26 +0900 + ug-setting-wifidirect-efl (0.4.2) unstable; urgency=low * Connection error popup of WFD UG is removed @@ -7,3 +240,172 @@ ug-setting-wifidirect-efl (0.4.2) unstable; urgency=low * Tag: ug-setting-wifidirect-efl_0.4.2 -- Gibyoung Kim Thu, 19 Apr 2012 20:50:38 +0900 + +ug-setting-wifidirect-efl (0.4.1) unstable; urgency=low + + * Connected peer should be displayed, when view is reloaded + * bug fix for S1-2549 and header list selection is enabled + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.4.1 + + -- Gibyoung Kim Fri, 13 Apr 2012 20:19:17 +0900 + +ug-setting-wifidirect-efl (0.4.0) unstable; urgency=low + + * Blocking WFD service for specific device + * String is modified + * Setting view will be destroyed when driver error is occured + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.4.0 + + -- Gibyoung Kim Thu, 12 Apr 2012 22:16:59 +0900 + +ug-setting-wifidirect-efl (0.3.9) unstable; urgency=low + + * Bug fix and code cleaning + * Connection popup should show SSID instead of MAC address + * Wi-Fi Direct service should be blocked on specific device + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.3.9 + + -- Gibyoung Kim Tue, 27 Mar 2012 20:01:04 +0900 + +ug-setting-wifidirect-efl (0.3.8) unstable; urgency=low + + * UI resource should be removed, when WFD initialization is failed + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.3.8 + + -- Gibyoung Kim Tue, 20 Mar 2012 13:19:09 +0900 + +ug-setting-wifidirect-efl (0.3.7) unstable; urgency=low + + * desktop file is modified + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.3.7 + + -- Gibyoung Kim Mon, 19 Mar 2012 22:23:27 +0900 + +ug-setting-wifidirect-efl (0.3.6) unstable; urgency=low + + * Stablizing Elementary 1.0 migration + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.3.6 + + -- Gibyoung Kim Sat, 17 Mar 2012 20:08:28 +0900 + +ug-setting-wifidirect-efl (0.3.5) unstable; urgency=low + + * Changes from Mobile-AP library are applyed + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.3.5 + + -- Gibyoung Kim Wed, 14 Mar 2012 17:07:25 +0900 + +ug-setting-wifidirect-efl (0.3.4) unstable; urgency=low + + * Elementary 1.0 migration is applyed + * WiFi-Direct API changes are applyed + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.3.4 + + -- Gibyoung Kim Wed, 14 Mar 2012 15:33:07 +0900 + +ug-setting-wifidirect-efl (0.3.3) unstable; urgency=low + + * EDC file for popup application is removed + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.3.3 + + -- Gibyoung Kim Wed, 29 Feb 2012 11:28:24 +0900 + +ug-setting-wifidirect-efl (0.3.2) unstable; urgency=low + + * to apply changes from wifi-direct client library + * to add codes that turn off wifi or mobile ap + * to support multi language(English, Korean) + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.3.2 + + -- Gibyoung Kim Tue, 28 Feb 2012 16:36:11 +0900 + +ug-setting-wifidirect-efl (0.3.1) unstable; urgency=low + + * to modify CMakeLists.txt and rules files + * to hide Direct On/Off button when activate ro decativate + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.3.1 + + -- Gibyoung Kim Wed, 22 Feb 2012 16:43:51 +0900 + +ug-setting-wifidirect-efl (0.3.0) unstable; urgency=low + + * Merge wifi-direct popup and setting ug in a single source tree. + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.3.0 + + -- Dongwook Lee Fri, 17 Feb 2012 17:40:18 +0900 + +ug-setting-wifidirect-efl (0.2.1) unstable; urgency=low + + * to apply changes from UIFW + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.2.1 + + -- Gibyoung Kim Thu, 16 Feb 2012 12:51:04 +0900 + +ug-setting-wifidirect-efl (0.2.0) unstable; urgency=low + + * Renewal all of UI + * Apply changes from WiFi Direct API + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.2.0 + + -- Gibyoung Kim Tue, 14 Feb 2012 17:20:17 +0900 + +ug-setting-wifidirect-efl (0.1.6) unstable; urgency=low + + * LCD on when a connection request come. Follow up the wifi-direct API change. + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.1.6 + + -- Dongwook Lee Wed, 01 Feb 2012 21:21:54 +0900 + +ug-setting-wifidirect-efl (0.1.5) unstable; urgency=low + + * Change control to support any arch + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.1.5 + + -- Dongwook Lee Thu, 19 Jan 2012 14:29:45 +0900 + +ug-setting-wifidirect-efl (0.1.4) unstable; urgency=low + + * package upload + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.1.4 + + -- Dongwook Lee Wed, 18 Jan 2012 12:37:54 +0900 + +ug-setting-wifidirect-efl (0.1.3) unstable; urgency=low + + * Tag update and fix email address in changelog + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.1.3 + + -- Dongwook Lee Tue, 17 Jan 2012 19:23:56 +0900 + +ug-setting-wifidirect-efl (0.1.2) unstable; urgency=low + + * Tag update and fix email address in changelog + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.1.2 + -- Dongwook Lee Tue, 17 Jan 2012 17:10:04 +0900 + +ug-setting-wifidirect-efl (0.1.1) unstable; urgency=low + + * Tag update and fix email address in changelog + * Git: slp/pkgs/u/ug-wifi-direct + * Tag: ug-setting-wifidirect-efl_0.1.1 + + -- Dongwook Lee Tue, 17 Jan 2012 01:21:37 +0900 diff --git a/debian/control b/debian/control old mode 100644 new mode 100755 index 91b2bc8..23b9ae2 --- a/debian/control +++ b/debian/control @@ -10,6 +10,7 @@ Build-Depends: debhelper (>= 5), libslp-utilx-dev, libui-gadget-dev, libwifi-direct-dev, + libmobile-ap-dev, libnetwork-dev, libslp-pm-dev Standards-Version: 3.7.2 @@ -17,7 +18,7 @@ Standards-Version: 3.7.2 Package: libug-setting-wifidirect-efl Section: net Architecture: any -Depends: ${misc:Depends}, libappcore-efl-0, libslp-utilx-0, libui-gadget-0, libvconf-0, libwifi-direct, libnetwork-0 +Depends: ${misc:Depends}, libappcore-efl-0, libslp-utilx-0, libui-gadget-0, libvconf-0, libwifi-direct, libmobile-ap-0, libnetwork-0 Description: Wi-Fi Direct Setting application Package: libug-setting-wifidirect-efl-dbg @@ -37,3 +38,10 @@ Section: net-debug Architecture: any Depends: org.tizen.wifi-direct-popup Description: WiFi Direct popup application Debug pkg + +Package: org.tizen.wifi-direct-ugapp +Section: net +Architecture: any +Depends: libug-setting-wifidirect-efl, ${misc:Depends} +Description: WiFi Direct UG Launcher + diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..a0f0008 --- /dev/null +++ b/debian/docs @@ -0,0 +1 @@ +CMakeLists.txt diff --git a/debian/libug-setting-wifidirect-efl.postinst b/debian/libug-setting-wifidirect-efl.postinst index ed6e4cf..381705c 100644 --- a/debian/libug-setting-wifidirect-efl.postinst +++ b/debian/libug-setting-wifidirect-efl.postinst @@ -1,12 +1,5 @@ #!/bin/sh # Automatically added by dh_makeshlibs -if [ ${USER} == "root" ] -then - /usr/bin/vconftool set -t int db/wifi_direct/onoff 0 -u apps - /usr/bin/vconftool set -t int db/wifi_direct/connection_status 0 -u apps - /usr/bin/vconftool set -t string db/wifi_direct/id "" -u apps - /usr/bin/vconftool set -t string db/wifi_direct/password "" -u apps -fi # End automatically added section diff --git a/debian/org.tizen.wifi-direct-popup.install.in b/debian/org.tizen.wifi-direct-popup.install.in old mode 100644 new mode 100755 index f7097cd..d34027f --- a/debian/org.tizen.wifi-direct-popup.install.in +++ b/debian/org.tizen.wifi-direct-popup.install.in @@ -1,3 +1,4 @@ -/opt/apps/org.tizen.wifi-direct-popup/bin/* -/opt/apps/org.tizen.wifi-direct-popup/res/* -/opt/share/applications/* +/opt/apps/org.tizen.wifi-direct-popup/bin/* +/opt/apps/org.tizen.wifi-direct-popup/res/* +/opt/apps/org.tizen.wifi-direct-popup/res/images/* +/opt/share/applications/org.tizen.wifi-direct-popup.* diff --git a/debian/org.tizen.wifi-direct-ugapp.install.in b/debian/org.tizen.wifi-direct-ugapp.install.in new file mode 100755 index 0000000..a16c473 --- /dev/null +++ b/debian/org.tizen.wifi-direct-ugapp.install.in @@ -0,0 +1,2 @@ +/opt/apps/org.tizen.wifi-direct-ugapp/bin/* +/opt/share/applications/org.tizen.wifi-direct-ugapp.* diff --git a/debian/rules b/debian/rules index 8153a00..57e8a3b 100755 --- a/debian/rules +++ b/debian/rules @@ -63,6 +63,13 @@ clean: rm -rf popup-wifidirect/install_manifest.txt rm -rf popup-wifidirect/*.so + rm -rf ugapp-wifidirect/CMakeCache.txt + rm -rf ugapp-wifidirect/CMakeFiles + rm -rf ugapp-wifidirect/cmake_install.cmake + rm -rf ugapp-wifidirect/Makefile + rm -rf ugapp-wifidirect/install_manifest.txt + rm -rf ugapp-wifidirect/*.so + rm -rf ug-wifidirect/CMakeCache.txt rm -rf ug-wifidirect/CMakeFiles rm -rf ug-wifidirect/cmake_install.cmake diff --git a/packaging/ug-wifi-direct.spec b/packaging/libug-setting-wifidirect-efl.spec similarity index 59% rename from packaging/ug-wifi-direct.spec rename to packaging/libug-setting-wifidirect-efl.spec index 91f2085..d5d4dd9 100755 --- a/packaging/ug-wifi-direct.spec +++ b/packaging/libug-setting-wifidirect-efl.spec @@ -1,11 +1,12 @@ +#sbs-git:slp/apps/u/ug-wifi-direct libug-setting-wifidirect-efl 0.3.4 82f07b22ef73127a446c49e00b8dca37010b3ee2 %define PREFIX /opt/ug Name: libug-setting-wifidirect-efl Summary: Wi-Fi Direct setting UI gadget -Version: 0.4.2 +Version: 0.7.4 Release: 1 Group: TO_BE_FILLED -License: Flora Software License +License: Samsung Proprietary License Source0: %{name}-%{version}.tar.gz Requires(post): /sbin/ldconfig Requires(post): /usr/bin/sqlite3 @@ -17,9 +18,11 @@ BuildRequires: pkgconfig(dbus-glib-1) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(appcore-efl) -BuildRequires: pkgconfig(ui-gadget) +BuildRequires: pkgconfig(bundle) +BuildRequires: pkgconfig(ui-gadget-1) BuildRequires: pkgconfig(wifi-direct) BuildRequires: pkgconfig(network) +BuildRequires: pkgconfig(capi-network-tethering) BuildRequires: pkgconfig(utilX) BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(edje) @@ -38,11 +41,12 @@ BuildRequires: pkgconfig(pmapi) BuildRequires: pkgconfig(capi-appfw-application) BuildRequires: pkgconfig(capi-system-runtime-info) BuildRequires: pkgconfig(capi-system-device) - +BuildRequires: pkgconfig(notification) +BuildRequires: pkgconfig(syspopup-caller) BuildRequires: cmake BuildRequires: gettext-devel -%define debug_package %{nil} +#%define debug_package %{nil} %description wifi direct client library (Shared Library) @@ -51,11 +55,18 @@ wifi direct client library (Shared Library) %package -n org.tizen.wifi-direct-popup Summary: Wifi-Wirect system popup Requires: %{name} = %{version}-%{release} + +%package -n org.tizen.wifi-direct-ugapp +Summary: Wifi-Wirect application launching UG +Requires: %{name} = %{version}-%{release} %description -n org.tizen.wifi-direct-popup Wi-Fi Direct system popup. +%description -n org.tizen.wifi-direct-ugapp +Wi-Fi Direct application launching UG. + %prep %setup -q @@ -65,12 +76,14 @@ make %{?jobs:-j%jobs} %install rm -rf %{buildroot} - %make_install +%__strip %{buildroot}/opt/ug/lib/libug-setting-wifidirect-efl.so.0.1.0 +%__strip %{buildroot}/opt/apps/org.tizen.wifi-direct-ugapp/bin/wifi-direct-ugapp +%__strip %{buildroot}/opt/apps/org.tizen.wifi-direct-popup/bin/wifi-direct-popup %post -vconftool set -t int db/wifi_direct/onoff 0 -u apps -i - +mkdir -p /opt/ug/bin/ +ln -sf /usr/bin/ug-client /opt/ug/bin/ug-setting-wifidirect-efl %postun @@ -84,5 +97,16 @@ vconftool set -t int db/wifi_direct/onoff 0 -u apps -i %files -n org.tizen.wifi-direct-popup %defattr(-,root,root,-) /opt/apps/org.tizen.wifi-direct-popup/bin/* +/opt/apps/org.tizen.wifi-direct-popup/res/images/* /opt/apps/org.tizen.wifi-direct-popup/res/locale/*/*/* -/opt/share/applications/* +#/opt/share/applications/org.tizen.wifi-direct-popup.desktop +#for appfw new manifest +/opt/share/packages/org.tizen.wifi-direct-popup.xml + +%files -n org.tizen.wifi-direct-ugapp +%defattr(-,root,root,-) +/opt/apps/org.tizen.wifi-direct-ugapp/bin/* +#/opt/share/applications/org.tizen.wifi-direct-ugapp.desktop +#for appfw new manifest +/opt/share/packages/org.tizen.wifi-direct-ugapp.xml + diff --git a/popup-wifidirect/CMakeLists.txt b/popup-wifidirect/CMakeLists.txt old mode 100644 new mode 100755 index b2fbb9e..0b993db --- a/popup-wifidirect/CMakeLists.txt +++ b/popup-wifidirect/CMakeLists.txt @@ -7,6 +7,7 @@ SET(BINDIR "${PREFIX}/bin") SET(RESDIR "${PREFIX}/res") SET(LOCALEDIR "${RESDIR}/locale") SET(EDJDIR "${RESDIR}/edje") +SET(IMGDIR "${RESDIR}/images") SET(SRCS src/wfd-app-main.c @@ -35,7 +36,11 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS}) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR}) -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${PACKAGE_NAME}.desktop.in ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}.desktop) -INSTALL(FILES ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}.desktop DESTINATION /opt/share/applications) +#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${PACKAGE_NAME}.desktop.in ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}.desktop) +#INSTALL(FILES ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}.desktop DESTINATION /opt/share/applications) +#for appfw new manifest +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${PACKAGE_NAME}.xml ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}.xml) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PACKAGE_NAME}.xml DESTINATION "/opt/share/packages/") +INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/resources/images/ DESTINATION ${IMGDIR}) ADD_SUBDIRECTORY(po) diff --git a/popup-wifidirect/include/wfd-app-strings.h b/popup-wifidirect/include/wfd-app-strings.h old mode 100644 new mode 100755 index e58a799..6ccf7b9 --- a/popup-wifidirect/include/wfd-app-strings.h +++ b/popup-wifidirect/include/wfd-app-strings.h @@ -1,33 +1,29 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd + +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license + +* 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. +* +*/ + -/* - * This file declares strings for wifi direct popup application. - * - * @file wfd-app-strings.h - * @author Sungsik Jang (sungsik.jang@samsung.com) - * @version 0.1 - */ #ifndef __WFD_APP_STRING_H__ #define __WFD_APP_STRING_H__ #ifdef __cplusplus -extern "C" -{ +extern "C" { #endif #define WFD_STR_HEADER _("WiFi Direct") @@ -57,6 +53,7 @@ extern "C" "connecting" #define WFD_STR_POP_FAIL_TIMEOUT "Connection timeout" +/* Not included in excel file, but it exist in STMS */ #define WFD_STR_TITLE_MAIN _("WiFi Direct") @@ -64,4 +61,4 @@ extern "C" } #endif -#endif /* __WFD_APP_STRING_H__ */ +#endif /* __WFD_APP_STRING_H__ */ diff --git a/popup-wifidirect/include/wfd-app-util.h b/popup-wifidirect/include/wfd-app-util.h old mode 100644 new mode 100755 index 40c0084..890e374 --- a/popup-wifidirect/include/wfd-app-util.h +++ b/popup-wifidirect/include/wfd-app-util.h @@ -1,18 +1,21 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd + +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license + +* 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. +* +*/ /** * This file declares wifi direct application util functions. @@ -41,8 +44,10 @@ #define WFD_APP_LOG_WARN LOG_WARN #define WFD_APP_LOG_ASSERT LOG_FATAL #define WFD_APP_LOG_EXCEPTION LOG_FATAL +#define WFD_MAX_SIZE 128 +#define WFD_MAC_ADDRESS_SIZE 18 -char *wfd_app_trim_path(const char *filewithpath); +char * wfd_app_trim_path(const char* filewithpath); int wfd_app_gettid(); #define WFD_APP_LOG(log_level, format, args...) \ @@ -65,8 +70,8 @@ int wfd_app_gettid(); WFD_APP_LOG(WFD_APP_LOG_ASSERT, " ##(%s) -> %s() assert!!## "fmt, #expr, __FUNCTION__, ##arg); \ exit(1); \ } \ -} while (0) +} while (0) // retvm if -#endif /* __WFD_APP_UTIL_H__ */ +#endif /* __WFD_APP_UTIL_H__ */ diff --git a/popup-wifidirect/include/wfd-app.h b/popup-wifidirect/include/wfd-app.h old mode 100644 new mode 100755 index 1299a05..6dccacd --- a/popup-wifidirect/include/wfd-app.h +++ b/popup-wifidirect/include/wfd-app.h @@ -1,21 +1,24 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ - -/* - * This file declares wifi direct popup application functions. +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd + +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license + +* 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. +* +*/ + +/** + * This file declares wifi direct application functions. * * @file wfd-app.h * @author Sungsik Jang (sungsik.jang@samsung.com) @@ -31,11 +34,28 @@ #include #include #include +#include +#include -#define PACKAGE "wifi-direct-popup" +#define PACKAGE "org.tizen.wifi-direct-popup" #define EDJ_NAME RESDIR"/edje/wifi-direct-popup.edj" +#define WFD_MAX_PEER_NUM 10 +#define WFD_POP_STR_MAX_LEN 256 +#define NO_ACTION_TIME_OUT 300 /*5min*/ + +#define NOTIFICATION_BUNDLE_PARAM "NotiType" +#define NOTIFICATION_BUNDLE_VALUE "WiFi-Direct" +#define TICKERNOTI_SYSPOPUP "tickernoti-syspopup" + + +#define LOCALE_FILE_NAME "wifi-direct-popup" #define LOCALEDIR "/opt/apps/org.tizen.wifi-direct-popup/res/locale" -#define WFD_POP_STR_MAX_LEN 128 + +#define _(s) dgettext(LOCALE_FILE_NAME, s) +#define N_(s) dgettext_noop(s) +#define S_(s) dgettext("sys_string", s) + + enum { @@ -63,6 +83,9 @@ enum WFD_POP_FAIL_CONNECT, WFD_POP_INCORRECT_PIN, + //Automatic turn off wfd + WFD_POP_AUTOMATIC_TURN_OFF, + }; enum @@ -77,6 +100,7 @@ enum WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK, WFD_POP_RESP_APRV_ENTER_PIN_YES, WFD_POP_RESP_APRV_ENTER_PIN_NO, + WFD_POP_RESP_AUTOMATIC_TURNOFF_OK, }; typedef struct @@ -109,11 +133,31 @@ typedef struct char peer_name[32]; wfd_device_info_t *discovered_peers; int discovered_peer_count; + + /* notification */ + notification_h noti; + wfd_device_info_t raw_connected_peers[WFD_MAX_PEER_NUM]; + int raw_connected_peer_cnt; + + /* used for automatic turn off */ + int wfd_status; + int last_wfd_status; + int last_wfd_time; + int last_wfd_transmit_time; + Ecore_Timer *monitor_timer; + Ecore_Timer *transmit_timer; } wfd_appdata_t; +typedef struct +{ + int step; + Evas_Object *progressbar; + Evas_Object *time; +} wfd_wps_display_popup_t; extern wfd_appdata_t *wfd_get_appdata(); extern void wfd_destroy_popup(); extern void wfd_prepare_popup(int type, void *userdata); +extern void wfd_tickernoti_popup(char *msg); #endif /* __WFD_SYS_POPAPP_MAIN_H__ */ diff --git a/popup-wifidirect/org.tizen.wifi-direct-popup.desktop.in b/popup-wifidirect/org.tizen.wifi-direct-popup.desktop.in deleted file mode 100644 index 3ccbdd1..0000000 --- a/popup-wifidirect/org.tizen.wifi-direct-popup.desktop.in +++ /dev/null @@ -1,8 +0,0 @@ -Name=org.tizen.wifi-direct-popup -Type=Application -Exec=/opt/apps/org.tizen.wifi-direct-popup/bin/wifi-direct-popup -Icon=NULL -Comment=WiFi Direct UI Application -nodisplay=TRUE -X-Tizen-TaskManage=False -X-Tizen-Removable=False diff --git a/popup-wifidirect/org.tizen.wifi-direct-popup.xml b/popup-wifidirect/org.tizen.wifi-direct-popup.xml new file mode 100755 index 0000000..bd41bf5 --- /dev/null +++ b/popup-wifidirect/org.tizen.wifi-direct-popup.xml @@ -0,0 +1,11 @@ + + + + Sungsik Jang + Dongwook Lee + WiFi Direct Popup Application + + + + + diff --git a/popup-wifidirect/po/CMakeLists.txt b/popup-wifidirect/po/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/popup-wifidirect/po/en.po b/popup-wifidirect/po/en.po old mode 100644 new mode 100755 index f36f9ac..ed143ac --- a/popup-wifidirect/po/en.po +++ b/popup-wifidirect/po/en.po @@ -2,13 +2,16 @@ msgid "IDS_WFD_HEADER_WIFI_DIRECT" msgstr "Wi-Fi Direct" msgid "IDS_WFD_POP_CONNECT_WITH_PIN_Q" -msgstr "Connect with %s?
PIN:%s" +msgstr "Connect with %s in %d
secs.PIN:%s" msgid "IDS_WFD_POP_CONNECT_Q" msgstr "Connect with %s?" +msgid "IDS_WFD_POP_TITILE_CONNECTION" +msgstr "Wi-Fi Direct connection" + msgid "IDS_WFD_POP_ENTER_PIN" -msgstr "Enter PIN" +msgstr "Connect with %s in %d secs. Enter PIN to connect %s." msgid "IDS_WFD_POP_PIN_INVALID" msgstr "PIN is not valid" @@ -17,14 +20,28 @@ msgid "IDS_WFD_POP_CONNECTING" msgstr "Connecting..." msgid "IDS_WFD_POP_CONNECTING_WITH_PIN" -msgstr "Connecting...
PIN:%s" +msgstr "Connecting...PIN:" msgid "IDS_WFD_POP_CANCELING" msgstr "Canceling..." msgid "IDS_WFD_POP_CONNECTED" -msgstr "Connected" +msgstr "Connected to %s" + +msgid "IDS_WFD_POP_CONNECT_FAILED" +msgstr "Failed to connect %s" + +msgid "IDS_WFD_POP_DISCONNECTING" +msgstr "Disconnecting..." + +msgid "IDS_WFD_POP_DISCONNECTED" +msgstr "Disconnected to %s" + +msgid "IDS_WFD_POP_DISCONNECT_FAILED" +msgstr "Failed to disconnect %s" -msgid "IDS_WFD_POP_ERROR_OCCURRED" -msgstr "An error has occurred during connecting" +msgid "IDS_WFD_POP_EXPIRED_CONNECTION" +msgstr "Wi-Fi direct disconnected" +msgid "IDS_WFD_POP_AUTOMATIC_TURN_OFF" +msgstr "There has been no activity for 5 minutes since Wi-Fi Direct was enabled. To extend battery life, Wi-Fi Direct has been disabled." \ No newline at end of file diff --git a/popup-wifidirect/po/en_GB.po b/popup-wifidirect/po/en_GB.po old mode 100644 new mode 100755 index f36f9ac..6c6df7c --- a/popup-wifidirect/po/en_GB.po +++ b/popup-wifidirect/po/en_GB.po @@ -23,8 +23,22 @@ msgid "IDS_WFD_POP_CANCELING" msgstr "Canceling..." msgid "IDS_WFD_POP_CONNECTED" -msgstr "Connected" +msgstr "Connected to %s" -msgid "IDS_WFD_POP_ERROR_OCCURRED" -msgstr "An error has occurred during connecting" +msgid "IDS_WFD_POP_CONNECT_FAILED" +msgstr "Failed to connect %s" +msgid "IDS_WFD_POP_DISCONNECTING" +msgstr "Disconnecting..." + +msgid "IDS_WFD_POP_DISCONNECTED" +msgstr "Disconnected to %s" + +msgid "IDS_WFD_POP_DISCONNECT_FAILED" +msgstr "Failed to disconnect %s" + +msgid "IDS_WFD_POP_EXPIRED_CONNECTION" +msgstr "Wi-Fi direct disconnected" + +msgid "IDS_WFD_POP_AUTOMATIC_TURN_OFF" +msgstr "There has been no actions for
5 minutes since Wi-Fi direct
was activated. Turning off
Wi-Fi direct can extend battery
life. Continue?" \ No newline at end of file diff --git a/popup-wifidirect/po/en_US.po b/popup-wifidirect/po/en_US.po old mode 100644 new mode 100755 index f36f9ac..6c6df7c --- a/popup-wifidirect/po/en_US.po +++ b/popup-wifidirect/po/en_US.po @@ -23,8 +23,22 @@ msgid "IDS_WFD_POP_CANCELING" msgstr "Canceling..." msgid "IDS_WFD_POP_CONNECTED" -msgstr "Connected" +msgstr "Connected to %s" -msgid "IDS_WFD_POP_ERROR_OCCURRED" -msgstr "An error has occurred during connecting" +msgid "IDS_WFD_POP_CONNECT_FAILED" +msgstr "Failed to connect %s" +msgid "IDS_WFD_POP_DISCONNECTING" +msgstr "Disconnecting..." + +msgid "IDS_WFD_POP_DISCONNECTED" +msgstr "Disconnected to %s" + +msgid "IDS_WFD_POP_DISCONNECT_FAILED" +msgstr "Failed to disconnect %s" + +msgid "IDS_WFD_POP_EXPIRED_CONNECTION" +msgstr "Wi-Fi direct disconnected" + +msgid "IDS_WFD_POP_AUTOMATIC_TURN_OFF" +msgstr "There has been no actions for
5 minutes since Wi-Fi direct
was activated. Turning off
Wi-Fi direct can extend battery
life. Continue?" \ No newline at end of file diff --git a/popup-wifidirect/po/ja.po b/popup-wifidirect/po/ja.po old mode 100644 new mode 100755 index f36f9ac..6c6df7c --- a/popup-wifidirect/po/ja.po +++ b/popup-wifidirect/po/ja.po @@ -23,8 +23,22 @@ msgid "IDS_WFD_POP_CANCELING" msgstr "Canceling..." msgid "IDS_WFD_POP_CONNECTED" -msgstr "Connected" +msgstr "Connected to %s" -msgid "IDS_WFD_POP_ERROR_OCCURRED" -msgstr "An error has occurred during connecting" +msgid "IDS_WFD_POP_CONNECT_FAILED" +msgstr "Failed to connect %s" +msgid "IDS_WFD_POP_DISCONNECTING" +msgstr "Disconnecting..." + +msgid "IDS_WFD_POP_DISCONNECTED" +msgstr "Disconnected to %s" + +msgid "IDS_WFD_POP_DISCONNECT_FAILED" +msgstr "Failed to disconnect %s" + +msgid "IDS_WFD_POP_EXPIRED_CONNECTION" +msgstr "Wi-Fi direct disconnected" + +msgid "IDS_WFD_POP_AUTOMATIC_TURN_OFF" +msgstr "There has been no actions for
5 minutes since Wi-Fi direct
was activated. Turning off
Wi-Fi direct can extend battery
life. Continue?" \ No newline at end of file diff --git a/popup-wifidirect/po/ko_KR.po b/popup-wifidirect/po/ko_KR.po old mode 100644 new mode 100755 index eef280e..2d4d83c --- a/popup-wifidirect/po/ko_KR.po +++ b/popup-wifidirect/po/ko_KR.po @@ -27,3 +27,18 @@ msgstr "연결되었습니다." msgid "IDS_WFD_POP_ERROR_OCCURRED" msgstr "연결중에 오류가 발생하였습니다." + +msgid "IDS_WFD_POP_DISCONNECTING" +msgstr "Disconnecting..." + +msgid "IDS_WFD_POP_DISCONNECTED" +msgstr "Disconnected to %s" + +msgid "IDS_WFD_POP_DISCONNECT_FAILED" +msgstr "Failed to disconnect %s" + +msgid "IDS_WFD_POP_EXPIRED_CONNECTION" +msgstr "Wi-Fi direct disconnected" + +msgid "IDS_WFD_POP_AUTOMATIC_TURN_OFF" +msgstr "There has been no actions for
5 minutes since Wi-Fi direct
was activated. Turning off
Wi-Fi direct can extend battery
life. Continue?" \ No newline at end of file diff --git a/popup-wifidirect/po/zh_CN.po b/popup-wifidirect/po/zh_CN.po old mode 100644 new mode 100755 index f36f9ac..9f55a6a --- a/popup-wifidirect/po/zh_CN.po +++ b/popup-wifidirect/po/zh_CN.po @@ -2,29 +2,43 @@ msgid "IDS_WFD_HEADER_WIFI_DIRECT" msgstr "Wi-Fi Direct" msgid "IDS_WFD_POP_CONNECT_WITH_PIN_Q" -msgstr "Connect with %s?
PIN:%s" +msgstr "Á¬½Ó%s?
PIN:%s" msgid "IDS_WFD_POP_CONNECT_Q" -msgstr "Connect with %s?" +msgstr "Á¬½Ó%s?" msgid "IDS_WFD_POP_ENTER_PIN" -msgstr "Enter PIN" +msgstr "ÊäÈëPIN" msgid "IDS_WFD_POP_PIN_INVALID" -msgstr "PIN is not valid" +msgstr "PINÎÞЧ" msgid "IDS_WFD_POP_CONNECTING" -msgstr "Connecting..." +msgstr "Á¬½ÓÖÐ..." msgid "IDS_WFD_POP_CONNECTING_WITH_PIN" -msgstr "Connecting...
PIN:%s" +msgstr "Á¬½ÓÖÐ...
PIN:%s" msgid "IDS_WFD_POP_CANCELING" -msgstr "Canceling..." +msgstr "È¡ÏûÖÐ..." msgid "IDS_WFD_POP_CONNECTED" -msgstr "Connected" +msgstr "ÒÑÁ¬½Ó %s" -msgid "IDS_WFD_POP_ERROR_OCCURRED" -msgstr "An error has occurred during connecting" +msgid "IDS_WFD_POP_CONNECT_FAILED" +msgstr "ÎÞ·¨Á¬½Ó %s" +msgid "IDS_WFD_POP_DISCONNECTING" +msgstr "¶Ï¿ªÁ¬½ÓÖÐ..." + +msgid "IDS_WFD_POP_DISCONNECTED" +msgstr "ÒѶϿª%sµÄÁ¬½Ó" + +msgid "IDS_WFD_POP_DISCONNECT_FAILED" +msgstr "ÎÞ·¨¶Ï¿ª%sµÄÁ¬½Ó" + +msgid "IDS_WFD_POP_EXPIRED_CONNECTION" +msgstr "ÒѶϿªWi-Fi Direct" + +msgid "IDS_WFD_POP_AUTOMATIC_TURN_OFF" +msgstr "×ÔWi-Fi Direct´ò¿ªºó,
ÒÑÓÐ5·ÖÖÓÎÞ²Ù×÷.¹Ø±Õ
Wi-Fi Direct,ÒÔ½ÚÊ¡µçÁ¦.
ÊÇ·ñ¼ÌÐø?" \ No newline at end of file diff --git a/popup-wifidirect/resources/images/A09_notification_icon.png b/popup-wifidirect/resources/images/A09_notification_icon.png new file mode 100644 index 0000000..5d241f8 Binary files /dev/null and b/popup-wifidirect/resources/images/A09_notification_icon.png differ diff --git a/popup-wifidirect/src/wfd-app-client.c b/popup-wifidirect/src/wfd-app-client.c old mode 100644 new mode 100755 index a4c9c98..3fbbbdb --- a/popup-wifidirect/src/wfd-app-client.c +++ b/popup-wifidirect/src/wfd-app-client.c @@ -1,18 +1,21 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd + +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license + +* 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. +* +*/ /** * This file implements wifi direct application client functions. @@ -23,11 +26,374 @@ */ #include +#include #include #include "wifi-direct.h" #include "wfd-app.h" #include "wfd-app-util.h" +#include "vconf.h" + + +bool _wfd_connected_peer_cb(wifi_direct_connected_peer_info_s *peer, void *user_data) +{ + __WFD_APP_FUNC_ENTER__; + + wfd_appdata_t *ad = (wfd_appdata_t *) user_data; + if (NULL == ad || NULL == peer || NULL == peer->ssid || NULL == peer->mac_address) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "NULL parameters.\n"); + return FALSE; + } + + int peer_cnt = ad->raw_connected_peer_cnt; + WFD_APP_LOG(WFD_APP_LOG_LOW, "%dth connected peer. [%s]\n", peer_cnt, peer->ssid); + + strncpy(ad->raw_connected_peers[peer_cnt].ssid, peer->ssid, sizeof(ad->raw_connected_peers[peer_cnt].ssid)); + strncpy(ad->raw_connected_peers[peer_cnt].mac_address, peer->mac_address, WFD_MAC_ADDRESS_SIZE); + WFD_APP_LOG(WFD_APP_LOG_LOW, "\tSSID: [%s]\n", ad->raw_connected_peers[peer_cnt].ssid); + ad->raw_connected_peer_cnt++; + + free(peer->ssid); + free(peer->mac_address); + free(peer); + + __WFD_APP_FUNC_EXIT__; + return TRUE; +} + +int _wfd_app_get_connected_peers(void *user_data) +{ + __WFD_APP_FUNC_ENTER__; + + wfd_appdata_t *ad = (wfd_appdata_t *) user_data; + if (NULL == ad) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "NULL parameters.\n"); + return -1; + } + + int res = 0; + + ad->raw_connected_peer_cnt = 0; + res = wifi_direct_foreach_connected_peers(_wfd_connected_peer_cb, (void *)ad); + if (res != WIFI_DIRECT_ERROR_NONE) { + ad->raw_connected_peer_cnt = 0; + WFD_APP_LOG(WFD_APP_LOG_LOW, "Get connected peer failed: %d\n", res); + } + __WFD_APP_FUNC_EXIT__; + return 0; +} + +void _del_wfd_notification() +{ + __WFD_APP_FUNC_ENTER__; + + /* delete the notification */ + notification_error_e noti_err = NOTIFICATION_ERROR_NONE; + noti_err = notification_delete_all_by_type(NULL, NOTIFICATION_TYPE_NOTI); + if(noti_err != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_delete_all_by_type.(%d)\n", noti_err); + return; + } + + __WFD_APP_FUNC_EXIT__; +} + +#if 0 +void _add_wfd_actived_notification(void *user_data) +{ + __WFD_APP_FUNC_ENTER__; + + wfd_appdata_t *ad = (wfd_appdata_t *) user_data; + if (NULL == ad || NULL == ad->noti) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "NULL parameters.\n"); + return; + } + + notification_error_e noti_err = NOTIFICATION_ERROR_NONE; + + /* set the icon */ + noti_err = notification_set_image(ad->noti, NOTIFICATION_IMAGE_TYPE_ICON, RESDIR"/images/A09_notification_icon.png"); + if (noti_err != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_set_image. (%d)\n", noti_err); + return; + } + + /* set the title and content */ + noti_err = notification_set_text(ad->noti, NOTIFICATION_TEXT_TYPE_TITLE, + "Wi-Fi Direct activated", NULL, NOTIFICATION_VARIABLE_TYPE_NONE); + if (noti_err != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_set_text. (%d)\n", noti_err); + return; + } + + noti_err = notification_set_text(ad->noti, NOTIFICATION_TEXT_TYPE_CONTENT, + "Tap to change settings", NULL, NOTIFICATION_VARIABLE_TYPE_NONE); + if (noti_err != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_set_text. (%d)\n", noti_err); + return; + } + + bundle *b = NULL; + b = bundle_create(); + appsvc_set_pkgname(b, PACKAGE); + appsvc_add_data(b, NOTIFICATION_BUNDLE_PARAM, NOTIFICATION_BUNDLE_VALUE); + + int res = NOTIFICATION_ERROR_NONE; + res = notification_set_execute_option(ad->noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, /*Button Text*/NULL, NULL, b); + if (res != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW,"Failed to notification_set_execute_option. [%d]", res); + return; + } + + bundle_free(b); + + /* set display application list */ + noti_err = notification_set_display_applist(ad->noti, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY); + if(noti_err != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_set_display_applist : %d\n", noti_err); + return; + } + + /* notify the quick panel */ + if (0 == ad->is_insert) { + noti_err = notification_insert(ad->noti, NULL); + if (noti_err != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_insert.(%d)\n", noti_err); + return; + } + + ad->is_insert= 1; + } else { + noti_err = notification_update(ad->noti); + if (noti_err != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_update. (%d)\n", noti_err); + return; + } + } + + __WFD_APP_FUNC_EXIT__; +} +#endif + +void _add_wfd_peers_connected_notification(void *user_data) +{ + __WFD_APP_FUNC_ENTER__; + + wfd_appdata_t *ad = (wfd_appdata_t *) user_data; + if (NULL == ad || NULL == ad->noti) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "NULL parameters.\n"); + return; + } + + char msg[WFD_MAX_SIZE] = {0}; + notification_error_e noti_err = NOTIFICATION_ERROR_NONE; + + /* delete all notifications */ + _del_wfd_notification(); + + /* set the icon */ + noti_err = notification_set_image(ad->noti, NOTIFICATION_IMAGE_TYPE_ICON, RESDIR"/images/A09_notification_icon.png"); + if (noti_err != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_set_image. (%d)\n", noti_err); + return; + } + + /* set the title and content */ + _wfd_app_get_connected_peers(ad); + snprintf(msg, WFD_MAX_SIZE, "Connected with %d devices via Wi-Fi Direct", ad->raw_connected_peer_cnt); + noti_err = notification_set_text(ad->noti, NOTIFICATION_TEXT_TYPE_TITLE, msg, NULL, NOTIFICATION_VARIABLE_TYPE_NONE); + if (noti_err != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_set_text. (%d)\n", noti_err); + return; + } + + noti_err = notification_set_text(ad->noti, NOTIFICATION_TEXT_TYPE_CONTENT, + "Tap to change settings", NULL, NOTIFICATION_VARIABLE_TYPE_NONE); + if (noti_err != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_set_text. (%d)\n", noti_err); + return; + } + + bundle *b = NULL; + b = bundle_create(); + appsvc_set_pkgname(b, PACKAGE); + appsvc_add_data(b, NOTIFICATION_BUNDLE_PARAM, NOTIFICATION_BUNDLE_VALUE); + + int res = NOTIFICATION_ERROR_NONE; + res = notification_set_execute_option(ad->noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, /*Button Text*/NULL, NULL, b); + if (res != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW,"Failed to notification_set_execute_option. [%d]", res); + return; + } + + bundle_free(b); + + /* set display application list */ + noti_err = notification_set_display_applist(ad->noti, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY); + if(noti_err != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_set_display_applist : %d\n", noti_err); + return; + } + + /* notify the quick panel */ + noti_err = notification_insert(ad->noti, NULL); + if (noti_err != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_insert.(%d)\n", noti_err); + return; + } + + __WFD_APP_FUNC_EXIT__; +} + +void _add_wfd_turn_off_notification(void *user_data) +{ + __WFD_APP_FUNC_ENTER__; + + wfd_appdata_t *ad = (wfd_appdata_t *) user_data; + if (NULL == ad || NULL == ad->noti) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "NULL parameters.\n"); + return; + } + + notification_error_e noti_err = NOTIFICATION_ERROR_NONE; + + /* delete all notifications */ + _del_wfd_notification(); + + /* set the icon */ + noti_err = notification_set_image(ad->noti, NOTIFICATION_IMAGE_TYPE_ICON, RESDIR"/images/A09_notification_icon.png"); + if (noti_err != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_set_image. (%d)\n", noti_err); + return; + } + + /* set the title and content */ + noti_err = notification_set_text(ad->noti, NOTIFICATION_TEXT_TYPE_TITLE, + "Turn off Wi-Fi direct after using", NULL, NOTIFICATION_VARIABLE_TYPE_NONE); + if (noti_err != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_set_text. (%d)\n", noti_err); + return; + } + + noti_err = notification_set_text(ad->noti, NOTIFICATION_TEXT_TYPE_CONTENT, + "To save battery turn off Wi-Fi direct after using", NULL, NOTIFICATION_VARIABLE_TYPE_NONE); + if (noti_err != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_set_text. (%d)\n", noti_err); + return; + } + + bundle *b = NULL; + b = bundle_create(); + appsvc_set_pkgname(b, PACKAGE); + appsvc_add_data(b, NOTIFICATION_BUNDLE_PARAM, NOTIFICATION_BUNDLE_VALUE); + + int res = NOTIFICATION_ERROR_NONE; + res = notification_set_execute_option(ad->noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, /*Button Text*/NULL, NULL, b); + if (res != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW,"Failed to notification_set_execute_option. [%d]", res); + return; + } + + bundle_free(b); + + /* set display application list */ + noti_err = notification_set_display_applist(ad->noti, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY); + if(noti_err != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_set_display_applist : %d\n", noti_err); + return; + } + + /* notify the quick panel */ + noti_err = notification_insert(ad->noti, NULL); + if (noti_err != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_insert.(%d)\n", noti_err); + return; + } + + __WFD_APP_FUNC_EXIT__; +} + +static Eina_Bool _wfd_automatic_deactivated_for_connection_cb(void *user_data) +{ + int interval = 0; + unsigned int transmit_packet = 0; + int wfd_transfer_state = 0; + wfd_appdata_t *ad = (wfd_appdata_t*) user_data; + + if (NULL == ad) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "NULL parameters.\n"); + return ECORE_CALLBACK_CANCEL; + } + + /* check the timeout, if not timeout, keep the cb */ + interval = time(NULL) - ad->last_wfd_transmit_time; + if (interval < NO_ACTION_TIME_OUT) { + return ECORE_CALLBACK_RENEW; + } + + /* get transfer state */ + if (vconf_get_int(VCONFKEY_WIFI_DIRECT_TRANSFER_STATE, &wfd_transfer_state) < 0) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Error reading vconf (%s)\n", + VCONFKEY_WIFI_DIRECT_TRANSFER_STATE); + return ECORE_CALLBACK_CANCEL; + } + + /* show tickernoti*/ + if (wfd_transfer_state > VCONFKEY_WIFI_DIRECT_TRANSFER_START) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "No RX/TX packet, turn off WFD automatically.\n"); + _add_wfd_turn_off_notification(ad); + } else { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Has RX/TX packet, restart.\n"); + ad->last_wfd_transmit_time = time(NULL); + return ECORE_CALLBACK_RENEW; + } + + return ECORE_CALLBACK_CANCEL; +} + +/* automatic deactivated wfd callback*/ +static Eina_Bool _wfd_automatic_deactivated_for_no_connection_cb(void *user_data) +{ + int res = -1; + int interval = 0; + wfd_appdata_t *ad = (wfd_appdata_t*) user_data; + + if (NULL == ad) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "NULL parameters.\n"); + return ECORE_CALLBACK_CANCEL; + } + + /* check the action, if action is exist, keep the cb */ + res = wifi_direct_get_state(&ad->wfd_status); + if (res != WIFI_DIRECT_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Failed to get link status. [%d]\n", res); + return ECORE_CALLBACK_CANCEL; + } + + if (ad->last_wfd_status != ad->wfd_status) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Action is exist, last status: %d\n", + ad->last_wfd_status); + ad->last_wfd_status = ad->wfd_status; + ad->last_wfd_time = time(NULL); + return ECORE_CALLBACK_RENEW; + } + + /* check the timeout, if not timeout, keep the cb */ + interval = time(NULL) - ad->last_wfd_time; + if (interval < NO_ACTION_TIME_OUT) { + return ECORE_CALLBACK_RENEW; + } + + /* turn off the Wi-Fi Direct */ + wifi_direct_get_state(&ad->wfd_status); + if (ad->wfd_status < WIFI_DIRECT_STATE_ACTIVATING) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Wi-Fi Direct is already deactivated\n"); + } else { + wfd_prepare_popup(WFD_POP_AUTOMATIC_TURN_OFF, NULL); + } + + return ECORE_CALLBACK_CANCEL; +} void _cb_activation(int error_code, wifi_direct_device_state_e device_state, void *user_data) @@ -48,6 +414,18 @@ void _cb_activation(int error_code, wifi_direct_device_state_e device_state, "event ------------------ WIFI_DIRECT_DEVICE_STATE_DEACTIVATED\n"); WFD_APP_LOG(WFD_APP_LOG_LOW, "Termination process of wifi-direct popup begins...\n"); + + /* when deactivated, stop the timer */ + if (ad->transmit_timer) { + ecore_timer_del(ad->transmit_timer); + ad->transmit_timer = NULL; + } + + if (ad->monitor_timer) { + ecore_timer_del(ad->monitor_timer); + ad->monitor_timer = NULL; + } + elm_exit(); break; @@ -187,211 +565,272 @@ void _cb_connection(int error_code, wifi_direct_connection_state_e connection_state, const char *mac_address, void *user_data) { - __WFD_APP_FUNC_ENTER__; + __WFD_APP_FUNC_ENTER__; - wfd_appdata_t *ad = (wfd_appdata_t *) user_data; - int result; + wfd_appdata_t *ad = (wfd_appdata_t *) user_data; + int result = -1; + char msg[WFD_POP_STR_MAX_LEN] = {0}; + wfd_device_info_t *peer_info = NULL; + + /* find the peer's name by the mac address */ + if (NULL == mac_address) { + WFD_APP_LOG(WFD_APP_LOG_ERROR, "ERROR : mac address is NULL !!\n"); + return; + } - switch (connection_state) - { - case WIFI_DIRECT_CONNECTION_RSP: - { - WFD_APP_LOG(WFD_APP_LOG_LOW, - "event ------------------ WIFI_DIRECT_CONNECTION_RSP\n"); - - if (error_code == WIFI_DIRECT_ERROR_NONE) - { - WFD_APP_LOG(WFD_APP_LOG_LOW, "Link Complete!\n"); - wfd_prepare_popup(WFD_POP_NOTI_CONNECTED, NULL); - } - else - { - if (error_code == WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT) - WFD_APP_LOG(WFD_APP_LOG_LOW, - "Error Code - WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT\n"); - else if (error_code == WIFI_DIRECT_ERROR_AUTH_FAILED) - WFD_APP_LOG(WFD_APP_LOG_LOW, - "Error Code - WIFI_DIRECT_ERROR_AUTH_FAILED\n"); - else if (error_code == WIFI_DIRECT_ERROR_CONNECTION_FAILED) - WFD_APP_LOG(WFD_APP_LOG_LOW, - "Error Code - WIFI_DIRECT_ERROR_CONNECTION_FAILED\n"); - - wfd_prepare_popup(WFD_POP_FAIL_CONNECT, NULL); - - result = wifi_direct_start_discovery(FALSE, 0); - WFD_APP_LOG(WFD_APP_LOG_LOW, - "wifi_direct_start_discovery() result=[%d]\n", - result); - } - } - break; + strncpy(ad->peer_mac, mac_address, strlen(mac_address)); - case WIFI_DIRECT_CONNECTION_WPS_REQ: - { - wifi_direct_config_data_s *config = NULL; - - memcpy(ad->peer_mac, mac_address, sizeof(ad->peer_mac)); - - WFD_APP_LOG(WFD_APP_LOG_LOW, - "event ------------------ WIFI_DIRECT_CONNECTION_WPS_REQ\n"); - result = wifi_direct_get_config_data(&config); - WFD_APP_LOG(WFD_APP_LOG_LOW, - "wifi_direct_client_get_config_data() result=[%d]\n", - result); - - if (config->wps_config == WIFI_DIRECT_WPS_PUSHBUTTON) - { - WFD_APP_LOG(WFD_APP_LOG_LOW, - "wps_config is WFD_WPS_PUSHBUTTON. Ignore it..\n"); - } - else if (config->wps_config == WIFI_DIRECT_WPS_KEYPAD) - { - WFD_APP_LOG(WFD_APP_LOG_LOW, "wps_config is WFD_WPS_KEYPAD\n"); - - result = wifi_direct_generate_wps_pin(); - WFD_APP_LOG(WFD_APP_LOG_LOW, - "wifi_direct_client_generate_wps_pin() result=[%d]\n", - result); - - char *pin_number = NULL; - result = wifi_direct_get_wps_pin(&pin_number); - WFD_APP_LOG(WFD_APP_LOG_LOW, - "wifi_direct_client_get_wps_pin() result=[%d]. pin=[%s]\n", - result, ad->pin_number); - - strncpy(ad->pin_number, pin_number, 32); - - result = wifi_direct_accept_connection(ad->peer_mac); - WFD_APP_LOG(WFD_APP_LOG_LOW, - "wifi_direct_accept_connection[%s] result=[%d].\n", - ad->peer_mac, result); - - result = wifi_direct_activate_pushbutton(); - wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_PIN, NULL); - - if (pin_number != NULL) - free(pin_number); - } - else if (config->wps_config == WIFI_DIRECT_WPS_DISPLAY) - { - WFD_APP_LOG(WFD_APP_LOG_LOW, "wps_config is WFD_WPS_DISPLAY\n"); - wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_KEYPAD, - (void *) NULL); - } - else - { - WFD_APP_LOG(WFD_APP_LOG_LOW, "wps_config is unkown!\n"); - - } - if (config != NULL) - free(config); - } - break; + peer_info = _wfd_app_find_peer_by_mac_address(ad, mac_address); - case WIFI_DIRECT_CONNECTION_REQ: - { - WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_CONNECTION_REQ\n"); + if (NULL == peer_info) + { + WFD_APP_LOG(WFD_APP_LOG_LOW, "peer_info is NULL !!\n"); + } + else if (NULL == peer_info->ssid) + { + WFD_APP_LOG(WFD_APP_LOG_LOW, "SSID from connection is NULL !!\n"); + } + else + { + WFD_APP_LOG(WFD_APP_LOG_LOW, "SSID from connection is %s.\n", peer_info->ssid); + strncpy(ad->peer_name, peer_info->ssid, strlen(peer_info->ssid)); + } - wifi_direct_config_data_s *config = NULL; - wfd_device_info_t *peer_info = NULL; + if (ad->peer_name == NULL || strlen(ad->peer_name) == 0) { + strncpy(ad->peer_name, ad->peer_mac, strlen(ad->peer_mac)); + } - if (NULL == mac_address) - { - WFD_APP_LOG(WFD_APP_LOG_LOW, "ERROR : incomming_peer_mac is NULL !!\n"); - return; - } + switch (connection_state) + { + case WIFI_DIRECT_CONNECTION_RSP: + { + WFD_APP_LOG(WFD_APP_LOG_LOW, + "event ------------------ WIFI_DIRECT_CONNECTION_RSP\n"); + wfd_destroy_popup(); - WFD_APP_LOG(WFD_APP_LOG_LOW, "Connection Request from MAC[%s]\n", mac_address); - strncpy(ad->peer_mac, mac_address, strlen(mac_address)); + if (error_code == WIFI_DIRECT_ERROR_NONE) + { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Link Complete!\n"); - peer_info = _wfd_app_find_peer_by_mac_address(ad, mac_address); + /* add connected notification */ + _add_wfd_peers_connected_notification(ad); - if (NULL != peer_info->ssid) - { - WFD_APP_LOG(WFD_APP_LOG_LOW, "Connection Request from SSID[%s]\n", peer_info->ssid); - strncpy(ad->peer_name, peer_info->ssid, strlen(peer_info->ssid)); + /* tickernoti popup */ + snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WFD_POP_CONNECTED"), ad->peer_name); + wfd_tickernoti_popup(msg); } else { - WFD_APP_LOG(WFD_APP_LOG_LOW, "incomming_peer SSID is NULL !!\n"); + if (error_code == WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT) + WFD_APP_LOG(WFD_APP_LOG_LOW, + "Error Code - WIFI_DIRECT_ERROR_CONNECTION_TIME_OUT\n"); + else if (error_code == WIFI_DIRECT_ERROR_AUTH_FAILED) + WFD_APP_LOG(WFD_APP_LOG_LOW, + "Error Code - WIFI_DIRECT_ERROR_AUTH_FAILED\n"); + else if (error_code == WIFI_DIRECT_ERROR_CONNECTION_FAILED) + WFD_APP_LOG(WFD_APP_LOG_LOW, + "Error Code - WIFI_DIRECT_ERROR_CONNECTION_FAILED\n"); + + result = wifi_direct_start_discovery(FALSE, 0); + WFD_APP_LOG(WFD_APP_LOG_LOW, + "wifi_direct_start_discovery() result=[%d]\n", + result); } + } + break; + + case WIFI_DIRECT_CONNECTION_WPS_REQ: + { + wifi_direct_config_data_s *config = NULL; - if (ad->peer_name == NULL || strlen(ad->peer_name) == 0) - strncpy(ad->peer_name, ad->peer_mac, strlen(ad->peer_mac)); + memcpy(ad->peer_mac, mac_address, sizeof(ad->peer_mac)); + WFD_APP_LOG(WFD_APP_LOG_LOW, + "event ------------------ WIFI_DIRECT_CONNECTION_WPS_REQ\n"); result = wifi_direct_get_config_data(&config); - WFD_APP_LOG(WFD_APP_LOG_LOW, "wifi_direct_client_get_config_data() result=[%d]\n", result); + WFD_APP_LOG(WFD_APP_LOG_LOW, + "wifi_direct_client_get_config_data() result=[%d]\n", + result); - if (config->wps_config == WIFI_DIRECT_WPS_PUSHBUTTON) + if (config->wps_config == WIFI_DIRECT_WPS_TYPE_PBC) { - char pushbutton; - WFD_APP_LOG(WFD_APP_LOG_LOW, "wps_config is WFD_WPS_PUSHBUTTON\n"); - - wfd_prepare_popup(WFD_POP_APRV_CONNECTION_WPS_PUSHBUTTON_REQ, NULL); + WFD_APP_LOG(WFD_APP_LOG_LOW, + "wps_config is WIFI_DIRECT_WPS_TYPE_PBC. Ignore it..\n"); } - else if (config->wps_config == WIFI_DIRECT_WPS_DISPLAY) + else if (config->wps_config == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD) { - WFD_APP_LOG(WFD_APP_LOG_LOW, "wps_config is WFD_WPS_DISPLAY\n"); - - result = wifi_direct_generate_wps_pin(); - WFD_APP_LOG(WFD_APP_LOG_LOW, "wifi_direct_client_generate_wps_pin() result=[%d]\n", result); - - char *pin_number = NULL; - result = wifi_direct_get_wps_pin(&pin_number); - WFD_APP_LOG(WFD_APP_LOG_LOW, "wifi_direct_get_wps_pin() result=[%d]\n", result); - - strncpy(ad->pin_number, pin_number, 32); - - wfd_prepare_popup(WFD_POP_APRV_CONNECTION_WPS_DISPLAY_REQ, NULL); - - if (pin_number != NULL) - free(pin_number); + char *pin; + WFD_APP_LOG(WFD_APP_LOG_LOW, "wps_config is WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD\n"); + + if (wifi_direct_generate_wps_pin() != WIFI_DIRECT_ERROR_NONE) + { + WFD_APP_LOG(WFD_APP_LOG_LOW, "wifi_direct_generate_wps_pin() is failed\n"); + return; + } + + if (wifi_direct_get_wps_pin(&pin) != WIFI_DIRECT_ERROR_NONE) + { + WFD_APP_LOG(WFD_APP_LOG_LOW, "wifi_direct_generate_wps_pin() is failed\n"); + return; + } + strncpy(ad->pin_number, pin, 32); + free(pin); + pin=NULL; + + WFD_APP_LOG(WFD_APP_LOG_LOW, "pin=[%s]\n", ad->pin_number); + + wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_PIN, NULL); } - else if (config->wps_config == WIFI_DIRECT_WPS_KEYPAD) + else if (config->wps_config == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY) { - WFD_APP_LOG(WFD_APP_LOG_LOW, "wps_config is WFD_WPS_KEYPAD\n"); - wfd_prepare_popup(WFD_POP_APRV_CONNECTION_WPS_KEYPAD_REQ, (void *) NULL); + WFD_APP_LOG(WFD_APP_LOG_LOW, "wps_config is WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY\n"); + wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_KEYPAD, (void *) NULL); } else { WFD_APP_LOG(WFD_APP_LOG_LOW, "wps_config is unkown!\n"); + } - if (config != NULL) free(config); - } - break; + } + break; - case WIFI_DIRECT_DISCONNECTION_IND: - { - WFD_APP_LOG(WFD_APP_LOG_LOW, - "event ------------------ WIFI_DIRECT_DISCONNECTION_IND\n"); - } - break; + case WIFI_DIRECT_CONNECTION_REQ: + { + WFD_APP_LOG(WFD_APP_LOG_LOW, "event ------------------ WIFI_DIRECT_CONNECTION_REQ\n"); - case WIFI_DIRECT_DISCONNECTION_RSP: - { - wfd_destroy_popup(); + wifi_direct_config_data_s *config = NULL; - result = wifi_direct_start_discovery(FALSE, 0); - WFD_APP_LOG(WFD_APP_LOG_LOW, - "wifi_direct_start_discovery() result=[%d]\n", result); - } - break; + result = wifi_direct_get_config_data(&config); + WFD_APP_LOG(WFD_APP_LOG_LOW, "wifi_direct_client_get_config_data() result=[%d]\n", result); - default: - break; + if(config->auto_connection == TRUE) + { + result = wifi_direct_accept_connection(ad->peer_mac); + printf("wifi_direct_accept_connection() result=[%d]\n", result); + } + else + { - } + if (config->wps_config == WIFI_DIRECT_WPS_TYPE_PBC) + { + char pushbutton; + WFD_APP_LOG(WFD_APP_LOG_LOW, "wps_config is WIFI_DIRECT_WPS_TYPE_PBC\n"); + + wfd_prepare_popup(WFD_POP_APRV_CONNECTION_WPS_PUSHBUTTON_REQ, NULL); + } + else if (config->wps_config == WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY) + { + WFD_APP_LOG(WFD_APP_LOG_LOW, "wps_config is WIFI_DIRECT_WPS_TYPE_PIN_DISPLAY\n"); + + wfd_prepare_popup(WFD_POP_APRV_CONNECTION_WPS_DISPLAY_REQ, NULL); + } + else if (config->wps_config == WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD) + { + WFD_APP_LOG(WFD_APP_LOG_LOW, "wps_config is WIFI_DIRECT_WPS_TYPE_PIN_KEYPAD\n"); + wfd_prepare_popup(WFD_POP_APRV_CONNECTION_WPS_KEYPAD_REQ, (void *) NULL); + } + else + { + WFD_APP_LOG(WFD_APP_LOG_LOW, "wps_config is unkown!\n"); + } + + if (config != NULL) + free(config); - __WFD_APP_FUNC_EXIT__; + } + } + break; + + case WIFI_DIRECT_DISCONNECTION_IND: + { + _del_wfd_notification(); + WFD_APP_LOG(WFD_APP_LOG_LOW, + "event ------------------ WIFI_DIRECT_DISCONNECTION_IND\n"); + + result = wifi_direct_set_autoconnection_mode(false); + WFD_APP_LOG(WFD_APP_LOG_LOW,"wifi_direct_set_autoconnection_mode() result=[%d]\n", result); + + /* tickernoti popup */ + snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WFD_POP_DISCONNECTED"), ad->peer_name); + wfd_tickernoti_popup(msg); + } + break; + + case WIFI_DIRECT_DISCONNECTION_RSP: + { + _del_wfd_notification(); + wfd_destroy_popup(); + + result = wifi_direct_set_autoconnection_mode(false); + WFD_APP_LOG(WFD_APP_LOG_LOW,"wifi_direct_set_autoconnection_mode() result=[%d]\n", result); + + result = wifi_direct_start_discovery(FALSE, 0); + WFD_APP_LOG(WFD_APP_LOG_LOW, + "wifi_direct_start_discovery() result=[%d]\n", result); + + /* tickernoti popup */ + snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WFD_POP_DISCONNECTED"), ad->peer_name); + wfd_tickernoti_popup(msg); + } + break; + case WIFI_DIRECT_CONNECTION_IN_PROGRESS: + { + WFD_APP_LOG(WFD_APP_LOG_LOW, + "event ------------------ WIFI_DIRECT_CONNECTION_IN_PROGRESS\n"); + /* tickernoti popup */ + wfd_tickernoti_popup(_("IDS_WFD_POP_CONNECTING")); + } + default: + break; + + } + + /* if connected, switch to the transmit timer; Otherwise, switch to monitor timer */ + wifi_direct_get_state(&ad->wfd_status); + WFD_APP_LOG(WFD_APP_LOG_LOW,"status: %d", ad->wfd_status); + + if (ad->wfd_status > WIFI_DIRECT_STATE_CONNECTING) { + if (ad->monitor_timer) { + ecore_timer_del(ad->monitor_timer); + ad->monitor_timer = NULL; + } + + if (NULL == ad->transmit_timer) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "switch to the transmit timer\n"); + ad->last_wfd_transmit_time = time(NULL); + ad->transmit_timer = ecore_timer_add(5.0, + (Ecore_Task_Cb)_wfd_automatic_deactivated_for_connection_cb, ad); + } + } else { + if (ad->transmit_timer) { + ecore_timer_del(ad->transmit_timer); + ad->transmit_timer = NULL; + } + + if (NULL == ad->monitor_timer) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "switch to the monitor timer\n"); + ad->last_wfd_time = time(NULL); + ad->monitor_timer = ecore_timer_add(5.0, + (Ecore_Task_Cb)_wfd_automatic_deactivated_for_no_connection_cb, ad); + } + } + + __WFD_APP_FUNC_EXIT__; } int init_wfd_popup_client(wfd_appdata_t * ad) { __WFD_APP_FUNC_ENTER__; - int ret; + + if (NULL == ad) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "NULL parameters.\n"); + return FALSE; + } + + int ret = -1; ret = wifi_direct_initialize(); @@ -401,25 +840,64 @@ int init_wfd_popup_client(wfd_appdata_t * ad) wifi_direct_set_connection_state_changed_cb(_cb_connection, (void *) ad); + /* initialize notification */ + ad->noti = NULL; + ad->raw_connected_peer_cnt = 0; + + ad->noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE); + if (NULL == ad->noti) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "notification_new failed.\n"); + return FALSE; + } + + /* start the monitor timer */ + ad->last_wfd_time = time(NULL); + ad->last_wfd_status = WIFI_DIRECT_STATE_DEACTIVATED; + ad->monitor_timer = ecore_timer_add(5.0, (Ecore_Task_Cb)_wfd_automatic_deactivated_for_no_connection_cb, ad); + __WFD_APP_FUNC_EXIT__; - if (ret) + if (ret == WIFI_DIRECT_ERROR_NONE) return TRUE; else return FALSE; } -int deinit_wfd_popup_client(void) +int deinit_wfd_popup_client(wfd_appdata_t * ad) { __WFD_APP_FUNC_ENTER__; - int ret; + if (NULL == ad || NULL == ad->noti) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "NULL parameters.\n"); + return FALSE; + } + + int ret = -1; ret = wifi_direct_deinitialize(); + _del_wfd_notification(ad); + + notification_error_e noti_err = NOTIFICATION_ERROR_NONE; + noti_err = notification_free(ad->noti); + if (noti_err != NOTIFICATION_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to notification_free.(%d)\n", noti_err); + ret = WIFI_DIRECT_ERROR_RESOURCE_BUSY; + } + + if (ad->transmit_timer) { + ecore_timer_del(ad->transmit_timer); + ad->transmit_timer = NULL; + } + + if (ad->monitor_timer) { + ecore_timer_del(ad->monitor_timer); + ad->monitor_timer = NULL; + } + __WFD_APP_FUNC_EXIT__; - if (ret) + if (ret == WIFI_DIRECT_ERROR_NONE) return TRUE; else return FALSE; diff --git a/popup-wifidirect/src/wfd-app-main.c b/popup-wifidirect/src/wfd-app-main.c old mode 100644 new mode 100755 index 33ecc2a..16dd365 --- a/popup-wifidirect/src/wfd-app-main.c +++ b/popup-wifidirect/src/wfd-app-main.c @@ -1,18 +1,21 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd + +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license + +* 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. +* +*/ /** * This file implements wifi direct application main functions. @@ -23,6 +26,9 @@ */ #include +#include +#include +#include #include "wfd-app.h" #include "wfd-app-util.h" @@ -45,7 +51,8 @@ static Evas_Object *_create_win(Evas_Object * parent, const char *name) Evas_Object *eo; int w, h; - eo = elm_win_add(parent, name, ELM_WIN_BASIC); + /* eo = elm_win_add(parent, name, ELM_WIN_BASIC); */ + eo = elm_win_add(NULL, name, ELM_WIN_NOTIFICATION); if (eo) { elm_win_title_set(eo, name); @@ -73,7 +80,7 @@ static int _app_create(void *data) return -1; } - bindtextdomain(PACKAGE, LOCALEDIR); + bindtextdomain(LOCALE_FILE_NAME, LOCALEDIR); ad->popup_data = (wfd_popup_t *) malloc(sizeof(wfd_popup_t)); if (!ad->popup_data) @@ -121,7 +128,7 @@ static int _app_terminate(void *data) wfd_appdata_t *ad = (wfd_appdata_t *) data; - if (deinit_wfd_popup_client() == FALSE) + if (deinit_wfd_popup_client(ad) == FALSE) { WFD_APP_LOG(WFD_APP_LOG_ERROR, "deinit_wfd_popup_client error\n"); } @@ -166,6 +173,35 @@ static int _app_resume(void *data) static int _app_reset(bundle * b, void *data) { __WFD_APP_FUNC_ENTER__; + + wfd_appdata_t *ad = (wfd_appdata_t*) data; + + if(b == NULL) + { + WFD_APP_LOG(WFD_APP_LOG_LOW,"Bundle is NULL"); + return -1; + } + // From Notification + char *noti_type = NULL; + noti_type = (char*) appsvc_get_data(b, NOTIFICATION_BUNDLE_PARAM); + if (noti_type == NULL) + { + WFD_APP_LOG(WFD_APP_LOG_LOW,"Notification type is wrong."); + return -1; + } + WFD_APP_LOG(WFD_APP_LOG_LOW,"Notification type is [%s]", noti_type); + if (strncmp(noti_type, NOTIFICATION_BUNDLE_VALUE, strlen(NOTIFICATION_BUNDLE_PARAM))==0) + { + WFD_APP_LOG(WFD_APP_LOG_LOW,"Launch wifidirect-ugapp"); + service_h service; + service_create(&service); + service_set_operation(service, SERVICE_OPERATION_DEFAULT); + service_set_package(service, "org.tizen.wifi-direct-ugapp"); + service_send_launch_request(service, NULL, NULL); + service_destroy(service); + } + + __WFD_APP_FUNC_EXIT__; return 0; } diff --git a/popup-wifidirect/src/wfd-app-popup-view.c b/popup-wifidirect/src/wfd-app-popup-view.c old mode 100644 new mode 100755 index a0cc286..9eadc6c --- a/popup-wifidirect/src/wfd-app-popup-view.c +++ b/popup-wifidirect/src/wfd-app-popup-view.c @@ -1,18 +1,21 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd + +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license + +* 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. +* +*/ /** * This file implements wifi direct system popup view functions. @@ -34,152 +37,235 @@ extern wfd_appdata_t *g_wfd_ad; extern wfd_popup_t *g_wfd_pop; extern unsigned char g_wfd_peer_mac[6]; extern unsigned char g_wfd_peer_name[32]; +static Ecore_Timer *pb_timer = NULL; + +void wfd_tickernoti_popup(char *msg); static void __popup_resp_cb(void *data, Evas_Object * obj, void *event_info) { - __WFD_APP_FUNC_ENTER__; - - wfd_appdata_t *ad = wfd_get_appdata(); - int result = -1; - int resp = (int) data; - Evas_Object *btn = obj; - - WFD_APP_LOG(WFD_APP_LOG_HIGH, "popup resp : %d\n", resp); - - switch (resp) - { - case WFD_POP_RESP_APRV_CONNECT_PBC_YES: - { - WFD_APP_LOG(WFD_APP_LOG_HIGH, - "WFD_POP_RESP_APRV_CONNECT_PBC_YES\n"); - - result = wifi_direct_accept_connection(ad->peer_mac); - WFD_APP_LOG(WFD_APP_LOG_LOW, - "wifi_direct_accept_connection() result=[%d]\n", - result); - if (result == WIFI_DIRECT_ERROR_NONE) - { - wfd_prepare_popup(WFD_POP_PROG_CONNECT, NULL); - } - else - { - WFD_APP_LOG(WFD_APP_LOG_ERROR, - "wifi_direct_accept_connection() FAILED!!\n"); - evas_object_hide(ad->win); - } - } - break; - - case WFD_POP_RESP_APRV_CONNECT_DISPLAY_YES: - { - WFD_APP_LOG(WFD_APP_LOG_HIGH, - "WFD_POP_RESP_APRV_CONNECT_DISPLAY_YES\n"); - - result = wifi_direct_accept_connection(ad->peer_mac); - WFD_APP_LOG(WFD_APP_LOG_LOW, - "wifi_direct_accept_connection() result=[%d]\n", - result); - if (result == WIFI_DIRECT_ERROR_NONE) - { - wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_PIN, - ad->pin_number); - } - else - { - WFD_APP_LOG(WFD_APP_LOG_ERROR, - "wifi_direct_client_send_connect_request() FAILED!!\n"); - evas_object_hide(ad->win); - } - } - break; - - case WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK: - case WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES: - { - WFD_APP_LOG(WFD_APP_LOG_HIGH, - "WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES\n"); - - int len = strlen(ad->pin_number); - WFD_APP_LOG(WFD_APP_LOG_LOW, "button ok: pin [%s]", ad->pin_number); - - if (len > 7 && len < 64) - { - int result = 0; - WFD_APP_LOG(WFD_APP_LOG_LOW, "pin=[%s]\n", ad->pin_number); - - result = wifi_direct_set_wps_pin(ad->pin_number); - - if (result != WIFI_DIRECT_ERROR_NONE) - { - wfd_prepare_popup(WFD_POP_FAIL_CONNECT, NULL); - return; - } - - result = wifi_direct_activate_pushbutton(); - result = wifi_direct_accept_connection(ad->peer_mac); - WFD_APP_LOG(WFD_APP_LOG_LOW, - "wifi_direct_accept_connection(%s) result=[%d]\n", - ad->peer_mac, result); - if (result == WIFI_DIRECT_ERROR_NONE) - { - wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_PIN, - ad->pin_number); - } - else - { - WFD_APP_LOG(WFD_APP_LOG_ERROR, - "wifi_direct_accept_connection() FAILED!!\n"); - evas_object_hide(ad->win); - } - } - else - { - WFD_APP_LOG(WFD_APP_LOG_ERROR, "Error, Incorrect PIN!!\n"); - wfd_prepare_popup(WFD_POP_INCORRECT_PIN, NULL); - return; - } - } - break; - - case WFD_POP_RESP_APRV_CONNECT_NO: - { - WFD_APP_LOG(WFD_APP_LOG_HIGH, - "WFD_POP_RESP_APRV_CONNECT_NO: destroy_popup...\n"); - - wfd_destroy_popup(); - } - break; - - case WFD_POP_RESP_PROG_CONNECT_CANCEL: - { - WFD_APP_LOG(WFD_APP_LOG_HIGH, "WFD_POP_RESP_PROG_CONNECT_CANCEL\n"); - result = wifi_direct_disconnect(ad->peer_mac); - WFD_APP_LOG(WFD_APP_LOG_LOW, - "wifi_direct_disconnect[%s] result=[%d]\n", - ad->peer_mac, result); - - if (result == WIFI_DIRECT_ERROR_NONE) - { - wfd_prepare_popup(WFD_POP_PROG_CONNECT_CANCEL, NULL); - } - else - { - WFD_APP_LOG(WFD_APP_LOG_ERROR, - "wifi_direct_disconnect() FAILED!!\n"); - wfd_prepare_popup(WFD_POP_FAIL_CONNECT, NULL); - } - } - break; - - default: - { - WFD_APP_LOG(WFD_APP_LOG_ERROR, "Unknown respone\n"); - evas_object_hide(ad->win); - } - break; - } - - __WFD_APP_FUNC_EXIT__; + __WFD_APP_FUNC_ENTER__; + + wfd_appdata_t *ad = wfd_get_appdata(); + int result = -1; + int resp = (int) data; + Evas_Object *btn = obj; + char msg[WFD_POP_STR_MAX_LEN] = {0}; + + WFD_APP_LOG(WFD_APP_LOG_HIGH, "popup resp : %d\n", resp); + + switch (resp) + { + case /* MT */ WFD_POP_RESP_APRV_CONNECT_PBC_YES: + { + WFD_APP_LOG(WFD_APP_LOG_HIGH, + "WFD_POP_RESP_APRV_CONNECT_PBC_YES\n"); + wfd_destroy_popup(); + + result = wifi_direct_accept_connection(ad->peer_mac); + WFD_APP_LOG(WFD_APP_LOG_LOW, + "wifi_direct_accept_connection() result=[%d]\n", + result); + if (result == WIFI_DIRECT_ERROR_NONE) + { + /* tickernoti popup */ + wfd_tickernoti_popup(_("IDS_WFD_POP_CONNECTING")); + } + else + { + WFD_APP_LOG(WFD_APP_LOG_ERROR, + "wifi_direct_accept_connection() FAILED!!\n"); + evas_object_hide(ad->win); + + /* tickernoti popup */ + snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WFD_POP_CONNECT_FAILED"), ad->peer_name); + wfd_tickernoti_popup(msg); + } + } + break; + + case /* MT */ WFD_POP_RESP_APRV_CONNECT_DISPLAY_YES: + { + char *pin = NULL; + + WFD_APP_LOG(WFD_APP_LOG_HIGH, + "WFD_POP_RESP_APRV_CONNECT_DISPLAY_YES\n"); + wfd_destroy_popup(); + if (pb_timer) { + ecore_timer_del(pb_timer); + pb_timer = NULL; + } + + if (wifi_direct_generate_wps_pin() != WIFI_DIRECT_ERROR_NONE) + { + WFD_APP_LOG(WFD_APP_LOG_LOW, "wifi_direct_generate_wps_pin() is failed\n"); + return; + } + + if (wifi_direct_get_wps_pin(&pin) != WIFI_DIRECT_ERROR_NONE) + { + WFD_APP_LOG(WFD_APP_LOG_LOW, "wifi_direct_generate_wps_pin() is failed\n"); + return; + } + strncpy(ad->pin_number, pin, 32); + free(pin); + pin = NULL; + + WFD_APP_LOG(WFD_APP_LOG_LOW, "button ok: pin [%s]", ad->pin_number); + + result = wifi_direct_accept_connection(ad->peer_mac); + WFD_APP_LOG(WFD_APP_LOG_LOW, + "wifi_direct_accept_connection() failed. result=[%d]\n", + result); + if (result == WIFI_DIRECT_ERROR_NONE) + { + evas_object_hide(ad->win); + wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_PIN, NULL); + } + else + { + /* tickernoti popup */ + wfd_tickernoti_popup(_("IDS_WFD_POP_CONNECT_FAILED")); + } + } + break; + + case /* MO */ WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK: + case /* MT */ WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES: + { + WFD_APP_LOG(WFD_APP_LOG_HIGH, + "WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES\n"); + wfd_destroy_popup(); + + int len = strlen(ad->pin_number); + WFD_APP_LOG(WFD_APP_LOG_LOW, "button ok: pin [%s]", ad->pin_number); + + if (len > 7 && len < 64) + { + int result = 0; + WFD_APP_LOG(WFD_APP_LOG_LOW, "pin=[%s]\n", ad->pin_number); + + result = wifi_direct_set_wps_pin(ad->pin_number); + + if (result != WIFI_DIRECT_ERROR_NONE) + { + /* tickernoti popup */ + snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WFD_POP_CONNECT_FAILED"), ad->peer_name); + wfd_tickernoti_popup(msg); + return; + } + + //result = wifi_direct_activate_pushbutton(); + result = wifi_direct_accept_connection(ad->peer_mac); + WFD_APP_LOG(WFD_APP_LOG_LOW, + "wifi_direct_accept_connection(%s) result=[%d]\n", + ad->peer_mac, result); + if (result != WIFI_DIRECT_ERROR_NONE) + { + WFD_APP_LOG(WFD_APP_LOG_ERROR, + "wifi_direct_accept_connection() FAILED!!\n"); + evas_object_hide(ad->win); + + /* tickernoti popup */ + snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WFD_POP_CONNECT_FAILED"), ad->peer_name); + wfd_tickernoti_popup(msg); + } + } + else + { + WFD_APP_LOG(WFD_APP_LOG_ERROR, "Error, Incorrect PIN!!\n"); + + /* tickernoti popup */ + wfd_tickernoti_popup(_("IDS_WFD_POP_PIN_INVALID")); + + /* redraw the popup */ + if (WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK == resp) { + wfd_prepare_popup(WFD_POP_PROG_CONNECT_WITH_KEYPAD, (void *) NULL); + } else { + wfd_prepare_popup(WFD_POP_APRV_CONNECTION_WPS_KEYPAD_REQ, (void *) NULL); + } + + return; + } + } + break; + + case /* MT */ WFD_POP_RESP_APRV_CONNECT_NO: + { + WFD_APP_LOG(WFD_APP_LOG_HIGH, + "WFD_POP_RESP_APRV_CONNECT_NO: destroy_popup...\n"); + + wfd_destroy_popup(); + if (pb_timer) { + ecore_timer_del(pb_timer); + pb_timer = NULL; + } + + result = wifi_direct_disconnect(ad->peer_mac); + WFD_APP_LOG(WFD_APP_LOG_LOW, + "wifi_direct_disconnect[%s] result=[%d]\n", + ad->peer_mac, result); + } + break; + + case WFD_POP_RESP_PROG_CONNECT_CANCEL: + { + WFD_APP_LOG(WFD_APP_LOG_HIGH, "WFD_POP_RESP_PROG_CONNECT_CANCEL\n"); + wfd_destroy_popup(); + + result = wifi_direct_disconnect(ad->peer_mac); + WFD_APP_LOG(WFD_APP_LOG_LOW, + "wifi_direct_disconnect[%s] result=[%d]\n", + ad->peer_mac, result); + + if (result == WIFI_DIRECT_ERROR_NONE) + { + /* tickernoti popup */ + snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WFD_POP_DISCONNECTED"), ad->peer_name); + wfd_tickernoti_popup(msg); + } + else + { + WFD_APP_LOG(WFD_APP_LOG_ERROR, + "wifi_direct_disconnect() FAILED!!\n"); + + /* tickernoti popup */ + snprintf(msg, WFD_POP_STR_MAX_LEN, _("IDS_WFD_POP_DISCONNECT_FAILED"), ad->peer_name); + wfd_tickernoti_popup(msg); + } + } + break; + + case WFD_POP_RESP_AUTOMATIC_TURNOFF_OK: + { + WFD_APP_LOG(WFD_APP_LOG_HIGH, "WFD_POP_RESP_AUTOMATIC_TURNOFF_OK\n"); + + /* turn off the Wi-Fi Direct */ + result = wifi_direct_get_state(&ad->wfd_status); + if (result != WIFI_DIRECT_ERROR_NONE) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Failed to get link status. [%d]\n", result); + return; + } + + if (ad->wfd_status < WIFI_DIRECT_STATE_ACTIVATING) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Wi-Fi Direct is already deactivated\n"); + } else { + ad->wfd_status = WIFI_DIRECT_STATE_DEACTIVATING; + wifi_direct_deactivate(); + } + + wfd_destroy_popup(); + } + break; + + default: + { + WFD_APP_LOG(WFD_APP_LOG_ERROR, "Unknown respone\n"); + evas_object_hide(ad->win); + } + break; + } + + __WFD_APP_FUNC_EXIT__; } static Evas_Object *__create_progress_layout(Evas_Object * parent, @@ -260,7 +346,6 @@ void wfd_destroy_popup() if (ad->popup) { - //evas_object_smart_callback_del(ad->popup, "response", __popup_resp_cb); evas_object_del(ad->popup); ad->popup = NULL; } @@ -278,7 +363,7 @@ void wfd_destroy_popup() } static Evas_Object *wfd_draw_pop_type_a(Evas_Object * win, wfd_popup_t * pop) -{ +{ //no button with spin __WFD_APP_FUNC_ENTER__; Evas_Object *popup; @@ -295,7 +380,7 @@ static Evas_Object *wfd_draw_pop_type_a(Evas_Object * win, wfd_popup_t * pop) } static Evas_Object *wfd_draw_pop_type_b(Evas_Object * win, wfd_popup_t * pop) -{ +{ //one button with spin __WFD_APP_FUNC_ENTER__; Evas_Object *popup = NULL; @@ -306,6 +391,7 @@ static Evas_Object *wfd_draw_pop_type_b(Evas_Object * win, wfd_popup_t * pop) elm_object_text_set(popup, pop->text); btn = elm_button_add(popup); + elm_object_style_set(btn, "popup_button/default"); elm_object_text_set(btn, pop->label1); elm_object_part_content_set(popup, "button1", btn); evas_object_smart_callback_add(btn, "clicked", __popup_resp_cb, @@ -319,7 +405,7 @@ static Evas_Object *wfd_draw_pop_type_b(Evas_Object * win, wfd_popup_t * pop) } static Evas_Object *wfd_draw_pop_type_c(Evas_Object * win, wfd_popup_t * pop) -{ +{ //two button __WFD_APP_FUNC_ENTER__; Evas_Object *popup = NULL; @@ -330,12 +416,14 @@ static Evas_Object *wfd_draw_pop_type_c(Evas_Object * win, wfd_popup_t * pop) elm_object_text_set(popup, pop->text); btn1 = elm_button_add(popup); + elm_object_style_set(btn1, "popup_button/default"); elm_object_text_set(btn1, pop->label1); elm_object_part_content_set(popup, "button1", btn1); evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb, (void *) pop->resp_data1); btn2 = elm_button_add(popup); + elm_object_style_set(btn2, "popup_button/default"); elm_object_text_set(btn2, pop->label2); elm_object_part_content_set(popup, "button2", btn2); evas_object_smart_callback_add(btn2, "clicked", __popup_resp_cb, @@ -349,7 +437,7 @@ static Evas_Object *wfd_draw_pop_type_c(Evas_Object * win, wfd_popup_t * pop) } static Evas_Object *wfd_draw_pop_type_d(Evas_Object * win, wfd_popup_t * pop) -{ +{ //text with spin __WFD_APP_FUNC_ENTER__; Evas_Object *popup; @@ -463,6 +551,192 @@ static void _smart_ime_cb(void *data, Evas_Object * obj, void *event_info) __WFD_APP_FUNC_EXIT__; } + +//#ifdef HIDE_PIN_NUMBER +#if 1 +static void _check_changed_cb(void *data, Evas_Object * obj, void *event_info) +{ + wfd_appdata_t *ad = wfd_get_appdata(); + + if (obj == NULL) + return; + + Eina_Bool state = elm_check_state_get(obj); + elm_entry_password_set(ad->pin_entry, !state); +} +#endif + +static Eina_Bool _fn_pb_timer(void *data) +{ + int step = 0; + double value = 0.0; + char time_label[32] = {0}; + wfd_wps_display_popup_t *wps_display_popup = (wfd_wps_display_popup_t*) data; + + if (NULL == wps_display_popup) { + WFD_APP_LOG(WFD_APP_LOG_ERROR, "Param is NULL.\n"); + return ECORE_CALLBACK_CANCEL; + } + + Evas_Object *progressbar = NULL; + Evas_Object *time = NULL; + + progressbar = wps_display_popup->progressbar; + time = wps_display_popup->time; + value = elm_progressbar_value_get(progressbar); + + if (value >= 1.0) { + WFD_APP_LOG(WFD_APP_LOG_ERROR, "Progress end.\n"); + return ECORE_CALLBACK_CANCEL; + } + + wps_display_popup->step++; + step = wps_display_popup->step; + value = ((double)step) / WFD_POP_TIMER_120; + elm_progressbar_value_set(progressbar, value); + WFD_APP_LOG(WFD_APP_LOG_LOW, "step: %d, value: %f\n", wps_display_popup->step, value); + + /* show the time label */ + if (step < 60) { + if (step < 10) { + snprintf(time_label, 32, "00:0%d", step); + } else { + snprintf(time_label, 32, "00:%d", step); + } + } else { + if (step%60 < 10) { + snprintf(time_label, 32, "0%d:0%d", step/60, step%60); + } else { + snprintf(time_label, 32, "0%d:%d", step/60, step%60); + } + } + + elm_object_text_set(time, time_label); + + return ECORE_CALLBACK_RENEW; +} + +static Evas_Object * _add_edit_field(Evas_Object *parent, const char *title, const char *guide, Eina_Bool single_line, Eina_Bool is_editable) +{ + assertm_if(NULL == parent, "parent is NULL!!"); + + Evas_Object *layout = elm_layout_add(parent); + assertm_if(NULL == layout, "layout is NULL!!"); + + if (title && title[0] != '\0') { + elm_layout_theme_set(layout, "layout", "editfield", "title"); + elm_object_part_text_set(layout, "elm.text", title); + } + else { + elm_layout_theme_set(layout, "layout", "editfield", "default"); + } + + Evas_Object *entry = elm_entry_add(parent); + assertm_if(NULL == entry, "entry is NULL!!"); + + elm_object_part_content_set(layout, "elm.swallow.content", entry); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + if (guide && guide[0] != '\0') { + elm_object_part_text_set(layout, "elm.guidetext", guide); + } + + elm_entry_single_line_set(entry, single_line); + elm_entry_scrollable_set(entry, single_line); + elm_entry_editable_set(entry, is_editable); + elm_object_signal_emit(layout, "elm,state,eraser,hide", "elm"); + evas_object_show(layout); + + return layout; +} + +Evas_Object *wfd_draw_pop_type_display(Evas_Object * win, wfd_popup_t * pop) +{ + __WFD_APP_FUNC_ENTER__; + + Evas_Object *popup = NULL; + Evas_Object *label = NULL; + Evas_Object *layout = NULL; + Evas_Object *progressbar = NULL; + Evas_Object *time = NULL; + Evas_Object *btn1 = NULL; + Evas_Object *btn2 = NULL; + static wfd_wps_display_popup_t wps_display_popup; + + popup = elm_popup_add(win); + elm_object_style_set(popup, "customstyle"); + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, 0.0); + + Evas_Object *box = elm_box_add(popup); + if (!box) { + evas_object_del(popup); + popup = NULL; + return NULL; + } + + evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0.0); + elm_object_part_content_set(popup, NULL, box); + evas_object_show(box); + + /* add label */ + label = elm_label_add(box); + elm_object_style_set(label, "popup/default"); + elm_label_line_wrap_set(label, ELM_WRAP_MIXED); + elm_object_text_set(label, pop->text); + evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(label, EVAS_HINT_FILL, 0.0); + elm_box_pack_end(box, label); + evas_object_show(label); + + /* add progressbar */ + progressbar = elm_progressbar_add(box); + elm_object_style_set(progressbar, "list_progress"); + elm_progressbar_horizontal_set(progressbar, EINA_TRUE); + evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, 0.0); + evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, 0.0); + elm_progressbar_value_set(progressbar, 0.0); + elm_box_pack_end(box, progressbar); + evas_object_show(progressbar); + + /* add time */ + time = elm_label_add(box); + elm_object_style_set(time, "popup/default"); + elm_object_text_set(time, "00:00"); + evas_object_size_hint_weight_set(time, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(time, EVAS_HINT_FILL, 0.0); + elm_box_pack_end(box, time); + evas_object_show(time); + + /* start progressbar timer */ + wps_display_popup.step = 0; + wps_display_popup.progressbar= progressbar; + wps_display_popup.time = time; + pb_timer = ecore_timer_add(1, _fn_pb_timer, &wps_display_popup); + + /* add cancel buttons */ + btn1 = elm_button_add(popup); + elm_object_style_set(btn1, "popup_button/default"); + elm_object_text_set(btn1, pop->label1); + elm_object_part_content_set(popup, "button1", btn1); + evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb, + (void *) pop->resp_data1); + + btn2 = elm_button_add(popup); + elm_object_style_set(btn2, "popup_button/default"); + elm_object_text_set(btn2, pop->label2); + elm_object_part_content_set(popup, "button2", btn2); + evas_object_smart_callback_add(btn2, "clicked", __popup_resp_cb, + (void *) pop->resp_data2); + + elm_object_content_set(popup, box); + evas_object_show(popup); + evas_object_show(win); + + __WFD_APP_FUNC_EXIT__; + return popup; +} + Evas_Object *wfd_draw_pop_type_keypad(Evas_Object * win, wfd_popup_t * pop) { __WFD_APP_FUNC_ENTER__; @@ -471,61 +745,98 @@ Evas_Object *wfd_draw_pop_type_keypad(Evas_Object * win, wfd_popup_t * pop) Evas_Object *conformant = NULL; Evas_Object *layout = NULL; Evas_Object *pinpopup = NULL; + Evas_Object *label = NULL; Evas_Object *btn1 = NULL, *btn2 = NULL; conformant = elm_conformant_add(win); assertm_if(NULL == conformant, "conformant is NULL!!"); elm_win_conformant_set(win, EINA_TRUE); elm_win_resize_object_add(win, conformant); - evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(conformant, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(conformant, EVAS_HINT_FILL, 0.0); evas_object_show(conformant); - pinpopup = NULL; layout = elm_layout_add(conformant); elm_object_content_set(conformant, layout); + pinpopup = elm_popup_add(layout); assertm_if(NULL == pinpopup, "pinpopup is NULL!!"); - elm_object_part_text_set(pinpopup, "title,text", pop->text); + elm_object_style_set(pinpopup, "customstyle"); + evas_object_size_hint_weight_set(pinpopup, EVAS_HINT_EXPAND, 0.0); + elm_object_part_text_set(pinpopup, "title,text", _("IDS_WFD_POP_TITILE_CONNECTION")); Evas_Object *box = elm_box_add(pinpopup); - 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_show(box); + if (!box) { + evas_object_del(pinpopup); + pinpopup = NULL; + return NULL; + } - Evas_Object *editfield = elm_layout_add(box); - elm_layout_theme_set(editfield, "layout", "editfield", "default"); - Evas_Object *editfield_entry = elm_layout_add(box); - elm_object_part_content_set(editfield, "elm.swallow.content", - editfield_entry); - elm_object_part_text_set(editfield, "elm.text", _("Enter PIN")); - elm_entry_single_line_set(editfield_entry, EINA_TRUE); - elm_entry_scrollable_set(editfield_entry, EINA_TRUE); - elm_object_signal_emit(editfield_entry, "elm,state,eraser,show", "elm"); - evas_object_size_hint_weight_set(editfield, EVAS_HINT_EXPAND, - EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(editfield, EVAS_HINT_FILL, EVAS_HINT_FILL); - ad->pin_entry = editfield_entry; - evas_object_smart_callback_add(ad->pin_entry, "changed", _smart_ime_cb, - NULL); - evas_object_show(editfield); - elm_box_pack_end(box, editfield); + evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0.0); + elm_object_part_content_set(pinpopup, NULL, box); + evas_object_show(box); - elm_object_content_set(pinpopup, box); + /* add label */ + label = elm_label_add(box); + elm_object_style_set(label, "popup/default"); + elm_label_line_wrap_set(label, ELM_WRAP_MIXED); + elm_object_text_set(label, pop->text); + evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_box_pack_end(box, label); + evas_object_show(label); + + /* add password */ + Evas_Object *body = elm_layout_add(box); + if (!body) { + evas_object_del(pinpopup); + pinpopup = NULL; + return NULL; + } + elm_layout_theme_set(body, "layout", "dialogue", "1icon"); + evas_object_size_hint_weight_set(body, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(body, EVAS_HINT_FILL, 0.0); + + Evas_Object *editfield_pin = _add_edit_field(body, NULL, NULL, EINA_TRUE, EINA_TRUE); + Evas_Object *entry_pin = elm_object_part_content_get(editfield_pin, "elm.swallow.content"); + ad->pin_entry = entry_pin; + evas_object_smart_callback_add(ad->pin_entry, "changed", _smart_ime_cb, NULL); + elm_object_part_content_set(body, "elm.icon", editfield_pin); + elm_box_pack_end(box, body); + evas_object_show(body); + +//#ifdef HIDE_PIN_NUMBER +#if 1 + elm_entry_password_set(ad->pin_entry, TRUE); + + Evas_Object *check = elm_check_add(box); + elm_object_text_set(check, _("Show password")); + elm_object_focus_allow_set(check, EINA_FALSE); + evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(check, EVAS_HINT_FILL, 0.0); + evas_object_smart_callback_add(check, "changed", _check_changed_cb, NULL); + evas_object_show(check); + elm_box_pack_end(box, check); +#endif + + /* add buttons */ btn1 = elm_button_add(pinpopup); - elm_object_text_set(pinpopup, pop->label1); + elm_object_style_set(btn1, "popup_button/default"); + elm_object_text_set(btn1, pop->label1); elm_object_part_content_set(pinpopup, "button1", btn1); evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb, (void *) pop->resp_data1); btn2 = elm_button_add(pinpopup); + elm_object_style_set(btn2, "popup_button/default"); elm_object_text_set(btn2, pop->label2); elm_object_part_content_set(pinpopup, "button2", btn2); - evas_object_smart_callback_add(btn1, "clicked", __popup_resp_cb, + evas_object_smart_callback_add(btn2, "clicked", __popup_resp_cb, (void *) pop->resp_data2); + elm_object_content_set(pinpopup, box); evas_object_show(pinpopup); evas_object_show(win); elm_object_focus_set(ad->pin_entry, EINA_TRUE); @@ -537,146 +848,193 @@ Evas_Object *wfd_draw_pop_type_keypad(Evas_Object * win, wfd_popup_t * pop) void wfd_prepare_popup(int type, void *userdata) { - __WFD_APP_FUNC_ENTER__; - wfd_appdata_t *ad = wfd_get_appdata(); - wfd_popup_t *pop = ad->popup_data; - - wfd_destroy_popup(); - - memset(pop, 0, sizeof(wfd_popup_t)); - - pop->type = type; - - switch (pop->type) - { - - case WFD_POP_APRV_CONNECTION_WPS_PUSHBUTTON_REQ: - { - snprintf(pop->text, sizeof(pop->text), _("IDS_WFD_POP_CONNECT_Q"), - ad->peer_name); - snprintf(pop->label1, sizeof(pop->label1), "%s", - dgettext("sys_string", "IDS_COM_SK_YES")); - snprintf(pop->label2, sizeof(pop->label2), "%s", - dgettext("sys_string", "IDS_COM_SK_NO")); - pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_PBC_YES; - pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO; - - ad->popup = wfd_draw_pop_type_c(ad->win, pop); - } - break; - - case WFD_POP_APRV_CONNECTION_WPS_DISPLAY_REQ: - { - char *pin = (char *) userdata; - snprintf(pop->text, sizeof(pop->text), - _("IDS_WFD_POP_CONNECT_WITH_PIN_Q"), ad->peer_name, - ad->pin_number); - snprintf(pop->label1, sizeof(pop->label1), "%s", - dgettext("sys_string", "IDS_COM_SK_YES")); - snprintf(pop->label2, sizeof(pop->label2), "%s", - dgettext("sys_string", "IDS_COM_SK_NO")); - - pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_DISPLAY_YES; - pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO; - - ad->popup = wfd_draw_pop_type_c(ad->win, pop); - } - break; - - case WFD_POP_APRV_CONNECTION_WPS_KEYPAD_REQ: - { - char *pin = (char *) userdata; - snprintf(pop->text, sizeof(pop->text), _("IDS_WFD_POP_CONNECT_Q"), - ad->peer_name); - snprintf(pop->label1, sizeof(pop->label1), "%s", - dgettext("sys_string", "IDS_COM_SK_YES")); - snprintf(pop->label2, sizeof(pop->label2), "%s", - dgettext("sys_string", "IDS_COM_SK_NO")); - pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES; - pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO; - - ad->popup = wfd_draw_pop_type_keypad(ad->win, pop); - } - break; - - case WFD_POP_PROG_CONNECT: - { - snprintf(pop->text, sizeof(pop->text), "%s", - _("IDS_WFD_POP_CONNECTING")); - snprintf(pop->label1, sizeof(pop->label1), "%s", - dgettext("sys_string", "IDS_COM_POP_CANCEL")); - pop->timeout = WFD_POP_TIMER_120; - pop->resp_data1 = WFD_POP_RESP_PROG_CONNECT_CANCEL; - - ad->popup = wfd_draw_pop_type_b(ad->win, pop); - } - break; - - case WFD_POP_PROG_CONNECT_WITH_KEYPAD: - { - snprintf(pop->text, sizeof(pop->text), "%s", - _("IDS_WFD_POP_ENTER_PIN")); - snprintf(pop->label1, sizeof(pop->label1), "%s", - dgettext("sys_string", "IDS_COM_SK_OK")); - snprintf(pop->label2, sizeof(pop->label2), "%s", - dgettext("sys_string", "IDS_COM_POP_CANCEL")); - pop->timeout = WFD_POP_TIMER_120; - pop->resp_data1 = WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK; - pop->resp_data2 = WFD_POP_RESP_PROG_CONNECT_CANCEL; - - ad->popup = wfd_draw_pop_type_keypad(ad->win, pop); - } - break; - - case WFD_POP_PROG_CONNECT_WITH_PIN: - snprintf(pop->text, sizeof(pop->text), "%s %s", - _("IDS_WFD_POP_CONNECTING_WITH_PIN"), ad->pin_number); - snprintf(pop->label1, sizeof(pop->label1), "%s", - dgettext("sys_string", "IDS_COM_POP_CANCEL")); - pop->timeout = WFD_POP_TIMER_120; - pop->resp_data1 = WFD_POP_RESP_PROG_CONNECT_CANCEL; - - ad->popup = wfd_draw_pop_type_c(ad->win, pop); - break; - - case WFD_POP_PROG_CONNECT_CANCEL: - { - snprintf(pop->text, sizeof(pop->text), "%s", - dgettext("sys_string", "IDS_COM_POP_CANCEL")); - pop->timeout = WFD_POP_TIMER_120; - ad->popup = wfd_draw_pop_type_a(ad->win, pop); - } - break; - - case WFD_POP_INCORRECT_PIN: - snprintf(pop->text, sizeof(pop->text), "%s", - _("IDS_WFD_POP_PIN_INVALID")); - snprintf(pop->label1, sizeof(pop->label1), "%s", - dgettext("sys_string", "IDS_COM_SK_OK")); - pop->timeout = WFD_POP_TIMER_3; - pop->resp_data1 = WFD_POP_RESP_OK; - break; - - case WFD_POP_NOTI_CONNECTED: - snprintf(pop->text, sizeof(pop->text), "%s", - _("IDS_WFD_POP_CONNECTED")); - pop->timeout = WFD_POP_TIMER_3; - - ad->popup = wfd_draw_pop_type_e(ad->win, pop); - break; - - case WFD_POP_FAIL_CONNECT: - snprintf(pop->text, sizeof(pop->text), "%s", - _("IDS_WFD_POP_ERROR_OCCURRED")); - pop->timeout = WFD_POP_TIMER_3; - - ad->popup = wfd_draw_pop_type_e(ad->win, pop); - break; - - default: - break; - } + __WFD_APP_FUNC_ENTER__; + wfd_appdata_t *ad = wfd_get_appdata(); + wfd_popup_t *pop = ad->popup_data; + + wfd_destroy_popup(); + + memset(pop, 0, sizeof(wfd_popup_t)); + + pop->type = type; + + switch (pop->type) + { + + case /* MT */ WFD_POP_APRV_CONNECTION_WPS_PUSHBUTTON_REQ: + { + snprintf(pop->text, sizeof(pop->text), _("IDS_WFD_POP_CONNECT_Q"), // WFD_STR_POP_APRV_CONNECT4 + ad->peer_name); + snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_YES")); // WFD_STR_BUTN_YES + snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_SK_NO")); // WFD_STR_BUTN_NO + pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_PBC_YES; + pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO; + + ad->popup = wfd_draw_pop_type_c(ad->win, pop); + } + break; + + case /* MT */ WFD_POP_APRV_CONNECTION_WPS_DISPLAY_REQ: + { + char *pin = (char *) userdata; + snprintf(pop->text, sizeof(pop->text), _("IDS_WFD_POP_CONNECT_Q"), //WFD_STR_POP_APRV_CONNECT4"
PIN:%s" + ad->peer_name, WFD_POP_TIMER_120, ad->pin_number); + snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_YES")); // WFD_STR_BUTN_YES + snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_SK_NO")); // WFD_STR_BUTN_NO + pop->timeout = WFD_POP_TIMER_120; + pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_DISPLAY_YES; + pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO; + + ad->popup = wfd_draw_pop_type_display(ad->win, pop); + } + break; + + case /*MO/MT */ WFD_POP_APRV_CONNECTION_WPS_KEYPAD_REQ: + { + snprintf(pop->text, sizeof(pop->text), _("IDS_WFD_POP_ENTER_PIN"), // WFD_STR_POP_APRV_CONNECT4 + ad->peer_name, WFD_POP_TIMER_120, ad->peer_name); + snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_YES")); // WFD_STR_BUTN_YES + snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_SK_NO")); // WFD_STR_BUTN_NO + pop->timeout = WFD_POP_TIMER_120; + pop->resp_data1 = WFD_POP_RESP_APRV_CONNECT_KEYPAD_YES; + pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO; + + ad->popup = wfd_draw_pop_type_keypad(ad->win, pop); + } + break; + + case /* MT */ WFD_POP_PROG_CONNECT: + { + snprintf(pop->text, sizeof(pop->text), "%s", _("IDS_WFD_POP_CONNECTING")); // WFD_STR_POP_PROG_CONNECT + snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL")); // WFD_STR_BTN_CANCEL + pop->timeout = WFD_POP_TIMER_120; + pop->resp_data1 = WFD_POP_RESP_PROG_CONNECT_CANCEL; + + ad->popup = wfd_draw_pop_type_b(ad->win, pop); + } + break; + + case /* MO */ WFD_POP_PROG_CONNECT_WITH_KEYPAD: + { + snprintf(pop->text, sizeof(pop->text), _("IDS_WFD_POP_ENTER_PIN"), // WFD_STR_POP_ENTER_PIN + ad->peer_name, WFD_POP_TIMER_120, ad->peer_name); + snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_OK")); // WFD_STR_BTN_OK + snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL")); // WFD_STR_BTN_CANCEL + pop->timeout = WFD_POP_TIMER_120; + pop->resp_data1 = WFD_POP_RESP_PROG_CONNECT_KEYPAD_OK; + pop->resp_data2 = WFD_POP_RESP_APRV_CONNECT_NO; + + ad->popup = wfd_draw_pop_type_keypad(ad->win, pop); + } + break; + + case /* MO/MT */ WFD_POP_PROG_CONNECT_WITH_PIN: + snprintf(pop->text, sizeof(pop->text), "%s %s", _("IDS_WFD_POP_CONNECTING_WITH_PIN"), ad->pin_number); // WFD_STR_POP_PROG_CONNECT_WITH_PIN + snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL")); // WFD_STR_BTN_CANCEL + pop->timeout = WFD_POP_TIMER_120; + pop->resp_data1 = WFD_POP_RESP_PROG_CONNECT_CANCEL; + + ad->popup = wfd_draw_pop_type_b(ad->win, pop); + break; + + case WFD_POP_PROG_CONNECT_CANCEL: + { + snprintf(pop->text, sizeof(pop->text), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL")); // WFD_STR_POP_PROG_CANCEL + pop->timeout = WFD_POP_TIMER_120; + ad->popup = wfd_draw_pop_type_a(ad->win, pop); + } + break; + + case WFD_POP_INCORRECT_PIN: + snprintf(pop->text, sizeof(pop->text), "%s", _("IDS_WFD_POP_PIN_INVALID")); // WFD_STR_POP_INVALID_PIN + snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_OK")); // WFD_STR_BTN_OK + pop->timeout = WFD_POP_TIMER_3; + pop->resp_data1 = WFD_POP_RESP_OK; + break; + + case WFD_POP_NOTI_CONNECTED: + snprintf(pop->text, sizeof(pop->text), "%s", _("IDS_WFD_POP_CONNECTED")); // WFD_STR_POP_NOTI_CONNECTED + pop->timeout = WFD_POP_TIMER_3; + + ad->popup = wfd_draw_pop_type_e(ad->win, pop); + break; + + case WFD_POP_FAIL_CONNECT: + snprintf(pop->text, sizeof(pop->text), "%s", _("IDS_WFD_POP_DISCONNECT_FAILED")); // IDS_WFD_POP_DISCONNECT_FAILED + pop->timeout = WFD_POP_TIMER_3; + + ad->popup = wfd_draw_pop_type_e(ad->win, pop); + break; + case WFD_POP_AUTOMATIC_TURN_OFF: + snprintf(pop->text, sizeof(pop->text), "%s", _("IDS_WFD_POP_AUTOMATIC_TURN_OFF")); + snprintf(pop->label1, sizeof(pop->label1), "%s", dgettext("sys_string", "IDS_COM_SK_OK")); + snprintf(pop->label2, sizeof(pop->label2), "%s", dgettext("sys_string", "IDS_COM_POP_CANCEL")); + pop->timeout = WFD_POP_TIMER_120; + pop->resp_data1 = WFD_POP_RESP_AUTOMATIC_TURNOFF_OK; + + ad->popup = wfd_draw_pop_type_b(ad->win, pop); + + break; + default: + break; + } + + __WFD_APP_FUNC_EXIT__; + return; +} - __WFD_APP_FUNC_EXIT__; - return; +void wfd_tickernoti_popup(char *msg) +{ + __WFD_APP_FUNC_ENTER__; + + int ret = -1; + bundle *b = NULL; + + b = bundle_create(); + if (!b) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "FAIL: bundle_create()\n"); + return; + } + + /* tickernoti style */ + ret = bundle_add(b, "0", "info"); + if (ret) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to add tickernoti style\n"); + bundle_free(b); + return; + } + + /* popup text */ + ret = bundle_add(b, "1", msg); + if (ret) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to add popup text\n"); + bundle_free(b); + return; + } + + /* orientation of tickernoti */ + ret = bundle_add(b, "2", "0"); + if (ret) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to add orientation of tickernoti\n"); + bundle_free(b); + return; + } + + /* timeout(second) of tickernoti */ + ret = bundle_add(b, "3", "3"); + if (ret) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to add timeout of tickernoti\n"); + bundle_free(b); + return; + } + + /* launch tickernoti */ + ret = syspopup_launch(TICKERNOTI_SYSPOPUP, b); + if (ret) { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Fail to launch syspopup\n"); + } + + bundle_free(b); + __WFD_APP_FUNC_EXIT__; } + diff --git a/popup-wifidirect/src/wfd-app-util.c b/popup-wifidirect/src/wfd-app-util.c index 592eabf..d584917 100644 --- a/popup-wifidirect/src/wfd-app-util.c +++ b/popup-wifidirect/src/wfd-app-util.c @@ -1,18 +1,21 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd + +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license + +* 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. +* +*/ /** * This file implements wifi direct application utils functions. @@ -30,6 +33,13 @@ char *wfd_app_trim_path(const char *filewithpath) { +#if 0 + char *filename = NULL; + if ((filename = strrchr(filewithpath, '/')) == NULL) + return (char *) filewithpath; + else + return (filename + 1); +#else static char *filename[100]; char *strptr = NULL; int start = 0; @@ -50,6 +60,7 @@ char *wfd_app_trim_path(const char *filewithpath) strncpy((char *) filename + start, strptr, 50); return (char *) filename; +#endif } diff --git a/ug-wifidirect/CMakeLists.txt b/ug-wifidirect/CMakeLists.txt old mode 100644 new mode 100755 index 5f901e3..e10920f --- a/ug-wifidirect/CMakeLists.txt +++ b/ug-wifidirect/CMakeLists.txt @@ -1,5 +1,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(ug-setting-wifidirect-efl C) +SET(PACKAGE_NAME ug-setting-wifidirect-efl) SET(PREFIX "/opt/ug") SET(LIBDIR "${PREFIX}/lib") @@ -9,8 +10,12 @@ SET(IMGDIR "${RESDIR}/images/${PROJECT_NAME}") SET(SRCS src/wfd_ug.c - src/wfd_ug_view.c src/wfd_client.c + src/wfd_ug_popup.c + src/wfd_ug_genlist.c + src/wfd_ug_main_view.c + src/wfd_ug_multiconnect_view.c + src/wfd_ug_about_view.c ) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/ug-wifidirect/include/wfd_client.h b/ug-wifidirect/include/wfd_client.h index fb7bf72..59eed60 100644 --- a/ug-wifidirect/include/wfd_client.h +++ b/ug-wifidirect/include/wfd_client.h @@ -1,26 +1,21 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd -/* - * This file declares Wi-Fi direct client functions. - * - * @file wfd_client.h - * @author Gibyoung Kim (lastkgb.kim@samsung.com) - * @version 0.1 - */ +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license + +* 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 __WFD_CLIENT_H__ @@ -29,52 +24,43 @@ typedef enum { - WFD_DEVICE_TYPE_COMPUTER = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_COMPUTER, - WFD_DEVICE_TYPE_INPUT_DEVICE = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_INPUT_DEVICE, + WFD_DEVICE_TYPE_COMPUTER = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_COMPUTER, // 1 + WFD_DEVICE_TYPE_INPUT_DEVICE= WIFI_DIRECT_PRIMARY_DEVICE_TYPE_INPUT_DEVICE, WFD_DEVICE_TYPE_PRINTER = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_PRINTER, WFD_DEVICE_TYPE_CAMERA = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_CAMERA, - WFD_DEVICE_TYPE_STORAGE = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_STORAGE, + WFD_DEVICE_TYPE_STORAGE = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_STORAGE, // 5 WFD_DEVICE_TYPE_NW_INFRA = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_NETWORK_INFRA, WFD_DEVICE_TYPE_DISPLAYS = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_DISPLAY, - WFD_DEVICE_TYPE_MM_DEVICES = - WIFI_DIRECT_PRIMARY_DEVICE_TYPE_MULTIMEDIA_DEVICE, + WFD_DEVICE_TYPE_MM_DEVICES = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_MULTIMEDIA_DEVICE, WFD_DEVICE_TYPE_GAME_DEVICES = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_GAME_DEVICE, - WFD_DEVICE_TYPE_TELEPHONE = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_TELEPHONE, + WFD_DEVICE_TYPE_TELEPHONE = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_TELEPHONE, // 10 WFD_DEVICE_TYPE_AUDIO = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_AUDIO, - WFD_DEVICE_TYPE_OTHER = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_OTHER, + WFD_DEVICE_TYPE_OTHER = WIFI_DIRECT_PRIMARY_DEVICE_TYPE_OTHER, // 255 } device_type_e; -typedef enum -{ - WFD_LINK_STATUS_DEACTIVATED = WIFI_DIRECT_STATE_DEACTIVATED, +typedef enum { + WFD_LINK_STATUS_DEACTIVATED = WIFI_DIRECT_STATE_DEACTIVATED, // 0 WFD_LINK_STATUS_DEACTIVATING = WIFI_DIRECT_STATE_DEACTIVATING, WFD_LINK_STATUS_ACTIVATING = WIFI_DIRECT_STATE_ACTIVATING, WFD_LINK_STATUS_ACTIVATED = WIFI_DIRECT_STATE_ACTIVATED, WFD_LINK_STATUS_DISCOVERING = WIFI_DIRECT_STATE_DISCOVERING, - WFD_LINK_STATUS_CONNECTING = WIFI_DIRECT_STATE_CONNECTING, + WFD_LINK_STATUS_CONNECTING = WIFI_DIRECT_STATE_CONNECTING, // 5 WFD_LINK_STATUS_DISCONNECTING = WIFI_DIRECT_STATE_DISCONNECTING, WFD_LINK_STATUS_CONNECTED = WIFI_DIRECT_STATE_CONNECTED, WFD_LINK_STATUS_GROUP_OWNER = WIFI_DIRECT_STATE_GROUP_OWNER, } link_status_e; -typedef enum -{ - PEER_CONN_STATUS_DISCONNECTED, - PEER_CONN_STATUS_DISCONNECTING, - PEER_CONN_STATUS_CONNECTING = PEER_CONN_STATUS_DISCONNECTING, - PEER_CONN_STATUS_CONNECTED, -} conn_status_e; - int wfd_get_vconf_status(void *data); -int wfd_wifi_off(); +int wfd_wifi_off(void *data); +int wfd_mobile_ap_off(void *data); int init_wfd_client(void *data); int deinit_wfd_client(void *data); -int wfd_client_get_link_status(void); int wfd_client_start_discovery(void *data); int wfd_client_switch_on(void *data); int wfd_client_switch_off(void *data); int wfd_client_swtch_force(void *data, int onoff); int wfd_client_connect(const char *mac_addr); int wfd_client_disconnect(const char *mac_addr); +int wfd_client_set_p2p_group_owner_intent(int go_intent); -#endif /* __WFD_CLIENT_H__ */ +#endif /* __WFD_CLIENT_H__ */ diff --git a/ug-wifidirect/include/wfd_ug.h b/ug-wifidirect/include/wfd_ug.h old mode 100644 new mode 100755 index 8918654..ba26de9 --- a/ug-wifidirect/include/wfd_ug.h +++ b/ug-wifidirect/include/wfd_ug.h @@ -1,32 +1,29 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd -/* - * This file declares structure for Wi-Fi direct UI Gadget. - * - * @file wfd_ug.h - * @author Gibyoung Kim (lastkgb.kim@samsung.com) - * @version 0.1 - */ +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license + +* 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 __WFD_UG_H__ #define __WFD_UG_H__ #include +#include +#include #define PACKAGE "ug-setting-wifidirect-efl" #define LOCALEDIR "/opt/ug/res/locale" @@ -38,73 +35,216 @@ #define __FUNC_ENTER__ DBG(LOG_VERBOSE, "+\n") #define __FUNC_EXIT__ DBG(LOG_VERBOSE, "-\n") -#define VCONF_WFD_ONOFF "db/wifi_direct/onoff" -#define VCONF_WFD_CONNECTION_STATUS "db/wifi_direct/connection_status" #define VCONF_WFD_APNAME "db/setting/device_name" -#define VCONF_WFD_PASSWORD "db/mobile_hotspot/wifi_key" -#define VCONF_WFD_PREV_STATUS "db/wifi_direct/prev_status" #define assertm_if(expr, fmt, arg...) do { \ if(expr) { \ DBG(LOG_VERBOSE, " ##(%s) -> %s() assert!!## "fmt, #expr, __FUNCTION__, ##arg); \ assert(1); \ } \ -} while (0) +} while (0) // retvm if #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x" -#define AP_NAME_LENGTH_MAX 32 -#define AP_PASSWORD_LENGTH_MAX 64 -#define AP_PASSWORD_LENGTH_MIN 8 +#define AP_NAME_LENGTH_MAX 32 //allowed lenght is 31 + '\0' +#define AP_PASSWORD_LENGTH_MAX 64 //allowed lenght is 63 + '\0' +#define AP_PASSWORD_LENGTH_MIN 8 //min limit #define AP_REJECT_CHAR_LIST "=," -#define DEFAULT_DEV_NAME "Tizen" +#define DEFAULT_DEV_NAME "GT_I9500" #define MAC_LENGTH 18 #define SSID_LENGTH 32 #define MAX_PEER_NUM 10 +#define MAX_POPUP_PEER_NUM 7 +#define MAX_POPUP_TEXT_SIZE 256 +#define MAX_DISPLAY_TIME_OUT 30 #define _(s) dgettext(PACKAGE, s) #define N_(s) dgettext_noop(s) #define S_(s) dgettext("sys_string", s) +#define IDS_WFD_TITLE_ABOUT_WIFI "About Wi-Fi Direct" +#define IDS_WFD_BODY_ABOUT_WIFI "Wi-Fi Direct enables Wi-Fi devices to
connect directly, making printing,"\ + " file
sharing, synchronising, and screen
sharing much simpler and more
convenient.
"\ + "Connecting to devices that support
Wi-Fi Direct makes it possible to share
your content,"\ + " synchronise your data,
socialise with friends, play games,
audio, videos, and more, using various
applications." +#define IDS_WFD_BODY_CONNECTED_DEVICES "Connected Devices" +#define IDS_WFD_BODY_BUSY_DEVICES "Busy Devices" +#define IDS_WFD_BODY_FAILED_DEVICES "Failed Devices" +#define IDS_WFD_TAP_TO_CONNECT "Tap to connect" +#define IDS_WFD_CONNECTED_WITH_OTHER_DEVICE "Connected with another device" +#define IDS_WFD_CONNECTED "Connected" +#define IDS_WFD_CONNECTING "Connecting ..." +#define IDS_WFD_WAITING_FOR_CONNECT "Waiting for connect" +#define IDS_WFD_FAILED_TO_CONNECT "Failed to connect" +#define IDS_WFD_DISCONNECTING "Disconnecting ..." +#define IDS_WFD_NOCONTENT "No device found" +#define IDS_WFD_BUTTON_MULTI "Multi connect" +#define IDS_WFD_BUTTON_CANCEL "Cancel connect" +#define IDS_WFD_BUTTON_DISCONNECT_ALL "Disconnect all" +#define IDS_WFD_BUTTON_DISCONNECT "Disconnect" + +#define WFD_GLOBALIZATION_STR_LENGTH 256 + +typedef enum { + WFD_MULTI_CONNECT_MODE_NONE, + WFD_MULTI_CONNECT_MODE_IN_PROGRESS, + WFD_MULTI_CONNECT_MODE_COMPLETED, +} wfd_multi_connect_mode_e; + +typedef enum +{ + PEER_CONN_STATUS_DISCONNECTED, + PEER_CONN_STATUS_DISCONNECTING, + PEER_CONN_STATUS_CONNECTING = PEER_CONN_STATUS_DISCONNECTING, + PEER_CONN_STATUS_CONNECTED, + PEER_CONN_STATUS_FAILED_TO_CONNECT, + PEER_CONN_STATUS_WAIT_FOR_CONNECT, +} conn_status_e; + typedef struct { - char ssid[SSID_LENGTH]; + char ssid[SSID_LENGTH]; // 31 + 1('\0') unsigned int category; char mac_addr[MAC_LENGTH]; char if_addr[MAC_LENGTH]; - int conn_status; + conn_status_e conn_status; + bool is_group_owner; /** Is an active P2P Group Owner */ + bool is_persistent_group_owner; /** Is a stored Persistent GO */ + bool is_connected; /** Is peer connected*/ Elm_Object_Item *gl_item; } device_type_s; +typedef struct +{ + bool dev_sel_state; + device_type_s peer; +} wfd_multi_sel_data_s; + struct ug_data { Evas_Object *base; - struct ui_gadget *ug; + ui_gadget_h ug; Evas_Object *win; Evas_Object *bg; Evas_Object *naviframe; Evas_Object *genlist; - Elm_Object_Item *head; - Elm_Object_Item *noitem; - Elm_Object_Item *scan_btn; + Evas_Object *multiconn_view_genlist; Evas_Object *popup; Evas_Object *act_popup; Evas_Object *warn_popup; + Elm_Object_Item *head; + Elm_Object_Item *scan_btn; + Elm_Object_Item *multi_scan_btn; + Elm_Object_Item *multi_connect_btn; + + Elm_Object_Item *nodevice_title_item; + Elm_Object_Item *nodevice_item; + Elm_Object_Item *nodevice_sep_low_item; + + Elm_Object_Item *about_wfd_item; + Elm_Object_Item *about_wfdsp_sep_end_item; + + Elm_Object_Item *conn_wfd_item; + + Elm_Object_Item *conn_failed_wfd_item; + Elm_Object_Item *conn_failed_wfd_sep_item; + + Elm_Object_Item *avlbl_wfd_item; + + Elm_Object_Item *busy_wfd_item; + Elm_Object_Item *busy_wfd_sep_item; + + Elm_Object_Item *multi_connect_wfd_item; + + Elm_Object_Item *multi_button_item; + Elm_Object_Item *multi_button_sep_high_item; + Elm_Object_Item *multi_button_sep_low_item; + + + Elm_Object_Item *mcview_select_all_item; + Elm_Object_Item *mcview_title_item; + Elm_Object_Item *mcview_nodevice_item; + + + Evas_Object *multi_btn; + int head_text_mode; - device_type_s *peers; - int peer_cnt; + // Raw peer data + device_type_s raw_connected_peers[MAX_PEER_NUM]; + int raw_connected_peer_cnt; + device_type_s raw_discovered_peers[MAX_PEER_NUM]; + int raw_discovered_peer_cnt; + + // Peer data in the Genlist + device_type_s gl_connected_peers[MAX_PEER_NUM]; + int gl_connected_peer_cnt; + + device_type_s gl_connected_failed_peers[MAX_PEER_NUM]; + int gl_connected_failed_peer_cnt; + + device_type_s gl_available_peers[MAX_PEER_NUM]; + int gl_available_peer_cnt; + + device_type_s gl_busy_peers[MAX_PEER_NUM]; + int gl_busy_peer_cnt; + + device_type_s raw_multi_selected_peers[MAX_PEER_NUM]; + int raw_multi_selected_peer_cnt; + + device_type_s gl_multi_connect_peers[MAX_PEER_NUM]; + int gl_multi_connect_peer_cnt; + + // My status + bool I_am_group_owner; + bool I_am_connected; + + // Following variables are used at the Multi connect view. + wfd_multi_connect_mode_e multi_connect_mode; + wfd_multi_sel_data_s multi_conn_dev_list[MAX_PEER_NUM]; + int gl_available_dev_cnt_at_multiconn_view; + int g_source_multi_connect_next; int wfd_onoff; int wfd_status; char *dev_name; char *dev_pass; + + // For connect failed peers + int last_display_time; + Ecore_Timer *display_timer; + + //tethering + tethering_h hotspot_handle; + }; +extern Elm_Gen_Item_Class sep_itc; +extern Elm_Gen_Item_Class sep_itc_end; +extern Elm_Gen_Item_Class head_itc; +extern Elm_Gen_Item_Class name_itc; +extern Elm_Gen_Item_Class title_itc; +extern Elm_Gen_Item_Class peer_itc; +extern Elm_Gen_Item_Class noitem_itc; +extern Elm_Gen_Item_Class help_itc; +extern Elm_Gen_Item_Class button_itc; + +extern Elm_Gen_Item_Class title_conn_itc; +extern Elm_Gen_Item_Class peer_conn_itc; + +extern Elm_Gen_Item_Class title_busy_itc; +extern Elm_Gen_Item_Class peer_busy_itc; + +extern Elm_Gen_Item_Class title_multi_connect_itc; +extern Elm_Gen_Item_Class peer_multi_connect_itc; + +extern Elm_Gen_Item_Class title_conn_failed_itc; +extern Elm_Gen_Item_Class peer_conn_failed_itc; + -#endif /* __WFD_UG_H__ */ +#endif /* __WFD_UG_H__ */ diff --git a/ug-wifidirect/include/wfd_ug_view.h b/ug-wifidirect/include/wfd_ug_view.h old mode 100644 new mode 100755 index 755dd37..2a35949 --- a/ug-wifidirect/include/wfd_ug_view.h +++ b/ug-wifidirect/include/wfd_ug_view.h @@ -1,45 +1,61 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd -/* - * This file declares functions for view of Wi-Fi direct UI Gadget. - * - * @file wfd_ug_view.h - * @author Gibyoung Kim (lastkgb.kim@samsung.com) - * @version 0.1 - */ +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license +* 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 __WFD_UG_VIEW_H__ #define __WFD_UG_VIEW_H__ +#include +#include + #define EDJDIR "/opt/ug/res/edje/ug-setting-wifidirect-efl" #define WFD_UG_EDJ_PATH EDJDIR"/wfd_ug.edj" #define WFD_IMG_DIR "/opt/ug/res/images/ug-setting-wifidirect-efl" +#define TICKERNOTI_SYSPOPUP "tickernoti-syspopup" + + +/* Define icons */ -#define WFD_ICON_DEVICE_PC WFD_IMG_DIR"/A09_device_computer.png" -#define WFD_ICON_DEVICE_KEYBOARD WFD_IMG_DIR"/31_BT_device_keyboard.png" -#define WFD_ICON_DEVICE_PRINTER WFD_IMG_DIR"/31_BT_device_printer.png" -#define WFD_ICON_DEVICE_UNKNOWN WFD_IMG_DIR"/31_BT_device_unknown.png" -#define WFD_ICON_DEVICE_PHONE WFD_IMG_DIR"/A09_device_mobile.png" -#define WFD_ICON_DEVICE_HEADSET WFD_IMG_DIR"/31_BT_device_headset.png" +#define WFD_ICON_DEVICE_COMPUTER WFD_IMG_DIR"/A09_device_computer.png" +#define WFD_ICON_DEVICE_INPUT_DEVICE WFD_IMG_DIR"/A09_device_input_device.png" +#define WFD_ICON_DEVICE_PRINTER WFD_IMG_DIR"/A09_device_printer.png" +#define WFD_ICON_DEVICE_CAMERA WFD_IMG_DIR"/A09_device_camera.png" +#define WFD_ICON_DEVICE_STORAGE WFD_IMG_DIR"/A09_device_storage.png" +#define WFD_ICON_DEVICE_NETWORK_INFRA WFD_IMG_DIR"/A09_device_network_infrastructure.png" +#define WFD_ICON_DEVICE_DISPLAY WFD_IMG_DIR"/A09_device_display.png" +#define WFD_ICON_DEVICE_MULTIMEDIA_DEVICE WFD_IMG_DIR"/A09_device_multimedia_devices.png" +#define WFD_ICON_DEVICE_GAMING_DEVICE WFD_IMG_DIR"/A09_device_gaming_devices.png" +#define WFD_ICON_DEVICE_TELEPHONE WFD_IMG_DIR"/A09_device_telephone.png" +#define WFD_ICON_DEVICE_AUDIO_DEVICE WFD_IMG_DIR"/A09_device_audio_devices.png" -#define WFD_ICON_DEVICE_MOUSE WFD_IMG_DIR"/31_BT_device_mouse.png" +#define WFD_ICON_DEVICE_COMPUTER_CONNECT WFD_IMG_DIR"/A09_device_computer_connect.png" +#define WFD_ICON_DEVICE_INPUT_DEVICE_CONNECT WFD_IMG_DIR"/A09_device_input_device_connect.png" +#define WFD_ICON_DEVICE_PRINTER_CONNECT WFD_IMG_DIR"/A09_device_printer_connect.png" +#define WFD_ICON_DEVICE_CAMERA_CONNECT WFD_IMG_DIR"/A09_device_camera_connect.png" +#define WFD_ICON_DEVICE_STORAGE_CONNECT WFD_IMG_DIR"/A09_device_storage_connect.png" +#define WFD_ICON_DEVICE_NETWORK_INFRA_CONNECT WFD_IMG_DIR"/A09_device_network_infrastructure_connect.png" +#define WFD_ICON_DEVICE_DISPLAY_CONNECT WFD_IMG_DIR"/A09_device_display_connect.png" +#define WFD_ICON_DEVICE_MULTIMEDIA_DEVICE_CONNECT WFD_IMG_DIR"/A09_device_multimedia_devices_connect.png" +#define WFD_ICON_DEVICE_GAMING_DEVICE_CONNECT WFD_IMG_DIR"/A09_device_gaming_devices_connect.png" +#define WFD_ICON_DEVICE_TELEPHONE_CONNECT WFD_IMG_DIR"/A09_device_telephone_connect.png" +#define WFD_ICON_DEVICE_AUDIO_DEVICE_CONNECT WFD_IMG_DIR"/A09_device_audio_devices_connect.png" -#define WFD_ICON_CONNECTED WFD_IMG_DIR"/A09_Connect.png" +#define WFD_ICON_CONNECTED WFD_IMG_DIR"/A09_Connect.png" enum @@ -53,29 +69,71 @@ enum enum { + /* User confirm */ POPUP_TYPE_WIFI_OFF, POPUP_TYPE_HOTSPOT_OFF, + /* Activation */ POPUP_TYPE_ACTIVATE_FAIL, POPUP_TYPE_DEACTIVATE_FAIL, + /* Connection */ POPUP_TYPE_LINK_TIMEOUT, POPUP_TYPE_AUTH_FAIL, POPUP_TYPE_LINK_FAIL, POPUP_TYPE_UNKNOWN_ERROR, POPUP_TYPE_TERMINATE, + + /* Disconnect */ + POP_TYPE_DISCONNECT, + + /* Disconnect All*/ + POP_TYPE_DISCONNECT_ALL, + + /* Scan again */ + POP_TYPE_SCAN_AGAIN, + + /* multi connect */ + POP_TYPE_MULTI_CONNECT_POPUP, + + /* Busy device */ + POP_TYPE_BUSY_DEVICE_POPUP, }; +struct ug_data *wfd_get_ug_data(); void create_wfd_ug_view(void *data); void destroy_wfd_ug_view(void *data); void wfd_ug_view_refresh_glitem(void *obj); -void wfd_ug_view_refresh_button(void *obj, int enable); +void wfd_ug_view_refresh_button(void *obj, const char *text, int enable); void wfd_ug_view_update_peers(void *data); void wfd_ug_view_free_peers(void *data); void wfd_ug_act_popup(void *data, const char *message, int popup_type); void wfg_ug_act_popup_remove(void *data); void wfd_ug_warn_popup(void *data, const char *message, int popup_type); void wfg_ug_warn_popup_remove(void *data); +int _create_connected_dev_list(void *data); +int _change_multi_button_title(void *data); + +void _wifid_create_about_view(struct ug_data *ugd); +void _wifid_create_multiconnect_view(struct ug_data *ugd); + +void _sub_view_back_btn_cb(void *data, Evas_Object * obj, void *event_info); +void _back_btn_cb(void *data, Evas_Object * obj, void *event_info); +void _scan_btn_cb(void *data, Evas_Object * obj, void *event_info); + +void _wfd_onoff_btn_cb(void *data, Evas_Object *obj, void *event_info); +void _wifid_create_multibutton_cb(void *data, Evas_Object * obj, void *event_info); + +int wfd_ug_get_discovered_peers(struct ug_data *ugd); +int wfd_ug_get_connected_peers(struct ug_data *ugd); +int wfd_refresh_wifi_direct_state(void* data); + +int wfd_multi_connect_next(void* data); +int wfd_stop_multi_connect(void *data); + +gboolean wfd_multi_connect_next_cb(void* data); + +void wfd_ug_tickernoti_popup(char *msg); -#endif /* __WFD_UG_VIEW_H__ */ +#endif /* __WFD_UG_VIEW_H__ */ diff --git a/ug-wifidirect/po/en.po b/ug-wifidirect/po/en.po old mode 100644 new mode 100755 index 2dbaeb8..a7b10da --- a/ug-wifidirect/po/en.po +++ b/ug-wifidirect/po/en.po @@ -7,15 +7,6 @@ msgstr "Deactivating Wi-Fi Direct..." msgid "IDS_WFD_BODY_ACTIVATING" msgstr "Activating Wi-Fi Direct..." -msgid "IDS_WFD_BODY_SCANNING" -msgstr "Scanning..." - -msgid "IDS_WFD_BODY_ACTIVATED" -msgstr "Wi-Fi Direct activated" - -msgid "IDS_WFD_BODY_DEVICE_NAME" -msgstr "Device name" - msgid "IDS_WFD_BODY_AVAILABLE_DEVICES" msgstr "Available Devices" @@ -34,6 +25,9 @@ msgstr "Connecting..." msgid "IDS_WFD_POP_CONNECTED" msgstr "Connected" +msgid "IDS_WFD_BUTTON_CONNECT" +msgstr "Connect" + msgid "IDS_WFD_BUTTON_SCAN" msgstr "Scan" @@ -59,13 +53,31 @@ msgid "IDS_WFD_POP_UNKNOWN_ERROR" msgstr "Unknown error" msgid "IDS_WFD_POP_WIFI_OFF" -msgstr "This will turn off Wi-Fi client operation.
Continue?" +msgstr "Enabling Wi-Fi Direct will disable Wi-Fi.
Continue?" msgid "IDS_WFD_POP_HOTSPOT_OFF" -msgstr "This will turn off Portable Wi-Fi hotspots operation.
Continue?" +msgstr "Enabling Wi-Fi Direct will disable Wi-Fi tethering.
Continue?" msgid "IDS_WFD_POP_NOT_SUPPORTED_DEVICE" msgstr "This device do not support
Wi-Fi Direct Service" msgid "IDS_WFD_POP_PROBLEM_WITH_WFD" msgstr "This device have some problem with
Wi-Fi Direct Service" + +msgid "IDS_WFD_POP_CANCEL_CONNECT" +msgstr "Cancel Wi-Fi direct connection.
Continue?" + +msgid "IDS_WFD_POP_DISCONNECT" +msgstr "Current connect will be disconnected." + +msgid "IDS_WFD_POP_SCAN_AGAIN" +msgstr "To start new scanning,
current connection will be
ended.Continue?" + +msgid "IDS_WFD_POP_MULTI_CONNECT" +msgstr "You can connect up to
%d devices at the same time." + +msgid "IDS_WFD_POP_WARN_BUSY_DEVICE" +msgstr "Unavailable device. Device is connected to another device." + +msgid "IDS_WFD_POP_SELECTED_DEVICE_NUM" +msgstr "Selected(%d)" \ No newline at end of file diff --git a/ug-wifidirect/po/en_GB.po b/ug-wifidirect/po/en_GB.po old mode 100644 new mode 100755 index 2dbaeb8..d214083 --- a/ug-wifidirect/po/en_GB.po +++ b/ug-wifidirect/po/en_GB.po @@ -34,6 +34,9 @@ msgstr "Connecting..." msgid "IDS_WFD_POP_CONNECTED" msgstr "Connected" +msgid "IDS_WFD_BUTTON_CONNECT" +msgstr "Connect" + msgid "IDS_WFD_BUTTON_SCAN" msgstr "Scan" @@ -59,7 +62,7 @@ msgid "IDS_WFD_POP_UNKNOWN_ERROR" msgstr "Unknown error" msgid "IDS_WFD_POP_WIFI_OFF" -msgstr "This will turn off Wi-Fi client operation.
Continue?" +msgstr "Enabling Wi-Fi Direct will disable Wi-Fi.
Continue?" msgid "IDS_WFD_POP_HOTSPOT_OFF" msgstr "This will turn off Portable Wi-Fi hotspots operation.
Continue?" @@ -69,3 +72,18 @@ msgstr "This device do not support
Wi-Fi Direct Service" msgid "IDS_WFD_POP_PROBLEM_WITH_WFD" msgstr "This device have some problem with
Wi-Fi Direct Service" + +msgid "IDS_WFD_POP_CANCEL_CONNECT" +msgstr "Cancel Wi-Fi direct connection.
Continue?" + +msgid "IDS_WFD_POP_DISCONNECT" +msgstr "Current connect wil be disconnected." + +msgid "IDS_WFD_POP_SCAN_AGAIN" +msgstr "To start new scanning,
current connection will be
ended.Continue?" + +msgid "IDS_WFD_POP_MULTI_CONNECT" +msgstr "You can connect up to
%d devices at the same time." + +msgid "IDS_WFD_POP_WARN_BUSY_DEVICE" +msgstr "Unavailable device. Device is connected to another device." \ No newline at end of file diff --git a/ug-wifidirect/po/en_US.po b/ug-wifidirect/po/en_US.po old mode 100644 new mode 100755 index 2dbaeb8..d214083 --- a/ug-wifidirect/po/en_US.po +++ b/ug-wifidirect/po/en_US.po @@ -34,6 +34,9 @@ msgstr "Connecting..." msgid "IDS_WFD_POP_CONNECTED" msgstr "Connected" +msgid "IDS_WFD_BUTTON_CONNECT" +msgstr "Connect" + msgid "IDS_WFD_BUTTON_SCAN" msgstr "Scan" @@ -59,7 +62,7 @@ msgid "IDS_WFD_POP_UNKNOWN_ERROR" msgstr "Unknown error" msgid "IDS_WFD_POP_WIFI_OFF" -msgstr "This will turn off Wi-Fi client operation.
Continue?" +msgstr "Enabling Wi-Fi Direct will disable Wi-Fi.
Continue?" msgid "IDS_WFD_POP_HOTSPOT_OFF" msgstr "This will turn off Portable Wi-Fi hotspots operation.
Continue?" @@ -69,3 +72,18 @@ msgstr "This device do not support
Wi-Fi Direct Service" msgid "IDS_WFD_POP_PROBLEM_WITH_WFD" msgstr "This device have some problem with
Wi-Fi Direct Service" + +msgid "IDS_WFD_POP_CANCEL_CONNECT" +msgstr "Cancel Wi-Fi direct connection.
Continue?" + +msgid "IDS_WFD_POP_DISCONNECT" +msgstr "Current connect wil be disconnected." + +msgid "IDS_WFD_POP_SCAN_AGAIN" +msgstr "To start new scanning,
current connection will be
ended.Continue?" + +msgid "IDS_WFD_POP_MULTI_CONNECT" +msgstr "You can connect up to
%d devices at the same time." + +msgid "IDS_WFD_POP_WARN_BUSY_DEVICE" +msgstr "Unavailable device. Device is connected to another device." \ No newline at end of file diff --git a/ug-wifidirect/po/ja.po b/ug-wifidirect/po/ja.po old mode 100644 new mode 100755 index 2dbaeb8..d214083 --- a/ug-wifidirect/po/ja.po +++ b/ug-wifidirect/po/ja.po @@ -34,6 +34,9 @@ msgstr "Connecting..." msgid "IDS_WFD_POP_CONNECTED" msgstr "Connected" +msgid "IDS_WFD_BUTTON_CONNECT" +msgstr "Connect" + msgid "IDS_WFD_BUTTON_SCAN" msgstr "Scan" @@ -59,7 +62,7 @@ msgid "IDS_WFD_POP_UNKNOWN_ERROR" msgstr "Unknown error" msgid "IDS_WFD_POP_WIFI_OFF" -msgstr "This will turn off Wi-Fi client operation.
Continue?" +msgstr "Enabling Wi-Fi Direct will disable Wi-Fi.
Continue?" msgid "IDS_WFD_POP_HOTSPOT_OFF" msgstr "This will turn off Portable Wi-Fi hotspots operation.
Continue?" @@ -69,3 +72,18 @@ msgstr "This device do not support
Wi-Fi Direct Service" msgid "IDS_WFD_POP_PROBLEM_WITH_WFD" msgstr "This device have some problem with
Wi-Fi Direct Service" + +msgid "IDS_WFD_POP_CANCEL_CONNECT" +msgstr "Cancel Wi-Fi direct connection.
Continue?" + +msgid "IDS_WFD_POP_DISCONNECT" +msgstr "Current connect wil be disconnected." + +msgid "IDS_WFD_POP_SCAN_AGAIN" +msgstr "To start new scanning,
current connection will be
ended.Continue?" + +msgid "IDS_WFD_POP_MULTI_CONNECT" +msgstr "You can connect up to
%d devices at the same time." + +msgid "IDS_WFD_POP_WARN_BUSY_DEVICE" +msgstr "Unavailable device. Device is connected to another device." \ No newline at end of file diff --git a/ug-wifidirect/po/ko_KR.po b/ug-wifidirect/po/ko_KR.po old mode 100644 new mode 100755 index f4525a2..147a5fb --- a/ug-wifidirect/po/ko_KR.po +++ b/ug-wifidirect/po/ko_KR.po @@ -34,6 +34,9 @@ msgstr "연결중..." msgid "IDS_WFD_POP_CONNECTED" msgstr "연결되었습니다." +msgid "IDS_WFD_BUTTON_CONNECT" +msgstr "Connect" + msgid "IDS_WFD_BUTTON_SCAN" msgstr "검색" @@ -69,3 +72,18 @@ msgstr "Wi-Fi Direct Service를 지원하지 않는 장치입니다." msgid "IDS_WFD_POP_PROBLEM_WITH_WFD" msgstr "Wi-Fi Direct Service에 문제가 있습니다." + +msgid "IDS_WFD_POP_CANCEL_CONNECT" +msgstr "Cancel Wi-Fi direct connection.
Continue?" + +msgid "IDS_WFD_POP_DISCONNECT" +msgstr "Current connect wil be disconnected." + +msgid "IDS_WFD_POP_SCAN_AGAIN" +msgstr "To start new scanning,
current connection will be
ended.Continue?" + +msgid "IDS_WFD_POP_MULTI_CONNECT" +msgstr "You can connect up to
%d devices at the same time." + +msgid "IDS_WFD_POP_WARN_BUSY_DEVICE" +msgstr "Unavailable device. Device is connected to another device." \ No newline at end of file diff --git a/ug-wifidirect/po/zh_CN.po b/ug-wifidirect/po/zh_CN.po old mode 100644 new mode 100755 index 2dbaeb8..2a0de42 --- a/ug-wifidirect/po/zh_CN.po +++ b/ug-wifidirect/po/zh_CN.po @@ -2,70 +2,88 @@ msgid "IDS_WFD_HEADER_WIFI_DIRECT" msgstr "Wi-Fi Direct" msgid "IDS_WFD_BODY_DEACTIVATING" -msgstr "Deactivating Wi-Fi Direct..." +msgstr "ÕýÔڹرÕWi-Fi Direct..." msgid "IDS_WFD_BODY_ACTIVATING" -msgstr "Activating Wi-Fi Direct..." +msgstr "ÕýÔÚ´ò¿ªWi-Fi Direct..." msgid "IDS_WFD_BODY_SCANNING" -msgstr "Scanning..." +msgstr "ɨÃèÖÐ..." msgid "IDS_WFD_BODY_ACTIVATED" -msgstr "Wi-Fi Direct activated" +msgstr "ÒѹرÕWi-Fi Direct" msgid "IDS_WFD_BODY_DEVICE_NAME" -msgstr "Device name" +msgstr "É豸Ãû" msgid "IDS_WFD_BODY_AVAILABLE_DEVICES" -msgstr "Available Devices" +msgstr "ÓÐЧÉ豸" msgid "IDS_WFD_BODY_WIFI_DIRECT_DEVICES" -msgstr "Wi-Fi Direct Devices" +msgstr "Wi-Fi DirectÉ豸" msgid "IDS_WFD_BODY_NO_DEVICES" -msgstr "No devices" +msgstr "ûÓÐÉ豸" msgid "IDS_WFD_BODY_HELP" -msgstr "HELP" +msgstr "°ïÖú" msgid "IDS_WFD_POP_CONNECTING" -msgstr "Connecting..." +msgstr "Á¬½ÓÖÐ..." msgid "IDS_WFD_POP_CONNECTED" -msgstr "Connected" +msgstr "ÒÑÁ¬½Ó" + +msgid "IDS_WFD_BUTTON_CONNECT" +msgstr "Á¬½Ó" msgid "IDS_WFD_BUTTON_SCAN" -msgstr "Scan" +msgstr "ɨÃè" msgid "IDS_WFD_BUTTON_STOPSCAN" -msgstr "Stop" +msgstr "Í£Ö¹" msgid "IDS_WFD_POP_ACTIVATE_FAIL" -msgstr "Failed to activate Wi-Fi Direct" +msgstr "´ò¿ªWi-Fi Directʧ°Ü" msgid "IDS_WFD_POP_DEACTIVATE_FAIL" -msgstr "Failed to deactivate Wi-Fi Direct" +msgstr "¹Ø±ÕWi-Fi Directʧ°Ü" msgid "IDS_WFD_POP_CONNECTING_TIMEOUT" -msgstr "Connecting is timeout" +msgstr "Á¬½Ó³¬Ê±" msgid "IDS_WFD_POP_AUTH_FAIL" -msgstr "Authentication failure" +msgstr "ÈÏ֤ʧ°Ü" msgid "IDS_WFD_POP_LINK_FAIL" -msgstr "Link creation failure" +msgstr "´´½¨Á¬½Óʧ°Ü" msgid "IDS_WFD_POP_UNKNOWN_ERROR" -msgstr "Unknown error" +msgstr "δ֪´íÎó" msgid "IDS_WFD_POP_WIFI_OFF" -msgstr "This will turn off Wi-Fi client operation.
Continue?" +msgstr "´ò¿ªWi-Fi Direct½«¹Ø±ÕWi-Fi.
ÊÇ·ñ¼ÌÐø?" msgid "IDS_WFD_POP_HOTSPOT_OFF" -msgstr "This will turn off Portable Wi-Fi hotspots operation.
Continue?" +msgstr "Õ⽫¹Ø±Õ¶ÔWi-FiÈȵãµÄ²Ù×÷.
ÊÇ·ñ¼ÌÐø?" msgid "IDS_WFD_POP_NOT_SUPPORTED_DEVICE" -msgstr "This device do not support
Wi-Fi Direct Service" +msgstr "¸ÃÉ豸²»Ö§³Ö
Wi-Fi Direct·þÎñ" msgid "IDS_WFD_POP_PROBLEM_WITH_WFD" -msgstr "This device have some problem with
Wi-Fi Direct Service" +msgstr "¸ÃÉ豸
Wi-Fi Direct Service" + +msgid "IDS_WFD_POP_CANCEL_CONNECT" +msgstr "È¡ÏûWi-Fi directÁ¬½Ó.
ÊÇ·ñ¼ÌÐø?" + +msgid "IDS_WFD_POP_DISCONNECT" +msgstr "µ±Ç°Á¬½Ó½«±»¹Ø±Õ." + +msgid "IDS_WFD_POP_SCAN_AGAIN" +msgstr "½«¿ªÊ¼ÖØÐÂɨÃè,
µ±Ç°Á¬½Ó½«±»
¹Ø±Õ.ÊÇ·ñ¼ÌÐø?" + +msgid "IDS_WFD_POP_MULTI_CONNECT" +msgstr "Ä㽫ͬʱÁ¬½Ó
%d̨É豸." + +msgid "IDS_WFD_POP_WARN_BUSY_DEVICE" +msgstr "ÎÞЧµÄÉ豸. ¸ÃÉ豸Òѱ»ÆäËüÉ豸Á¬½Ó." \ No newline at end of file diff --git a/ug-wifidirect/resources/images/31_BT_device_headset.png b/ug-wifidirect/resources/images/31_BT_device_headset.png deleted file mode 100755 index 0150a55..0000000 Binary files a/ug-wifidirect/resources/images/31_BT_device_headset.png and /dev/null differ diff --git a/ug-wifidirect/resources/images/31_BT_device_keyboard.png b/ug-wifidirect/resources/images/31_BT_device_keyboard.png deleted file mode 100755 index 8d16510..0000000 Binary files a/ug-wifidirect/resources/images/31_BT_device_keyboard.png and /dev/null differ diff --git a/ug-wifidirect/resources/images/31_BT_device_mouse.png b/ug-wifidirect/resources/images/31_BT_device_mouse.png deleted file mode 100755 index a994030..0000000 Binary files a/ug-wifidirect/resources/images/31_BT_device_mouse.png and /dev/null differ diff --git a/ug-wifidirect/resources/images/31_BT_device_printer.png b/ug-wifidirect/resources/images/31_BT_device_printer.png deleted file mode 100755 index ea025b1..0000000 Binary files a/ug-wifidirect/resources/images/31_BT_device_printer.png and /dev/null differ diff --git a/ug-wifidirect/resources/images/31_BT_device_unknown.png b/ug-wifidirect/resources/images/31_BT_device_unknown.png deleted file mode 100755 index 70699f1..0000000 Binary files a/ug-wifidirect/resources/images/31_BT_device_unknown.png and /dev/null differ diff --git a/ug-wifidirect/resources/images/A09_device_My_laptop.png b/ug-wifidirect/resources/images/A09_device_My_laptop.png deleted file mode 100755 index 5e2f10a..0000000 Binary files a/ug-wifidirect/resources/images/A09_device_My_laptop.png and /dev/null differ diff --git a/ug-wifidirect/resources/images/A09_device_audio_devices.png b/ug-wifidirect/resources/images/A09_device_audio_devices.png new file mode 100755 index 0000000..a9eddde Binary files /dev/null and b/ug-wifidirect/resources/images/A09_device_audio_devices.png differ diff --git a/ug-wifidirect/resources/images/A09_device_audio_devices_connect.png b/ug-wifidirect/resources/images/A09_device_audio_devices_connect.png new file mode 100644 index 0000000..afc8967 Binary files /dev/null and b/ug-wifidirect/resources/images/A09_device_audio_devices_connect.png differ diff --git a/ug-wifidirect/resources/images/A09_device_camera.png b/ug-wifidirect/resources/images/A09_device_camera.png new file mode 100755 index 0000000..ee1cc73 Binary files /dev/null and b/ug-wifidirect/resources/images/A09_device_camera.png differ diff --git a/ug-wifidirect/resources/images/A09_device_camera_connect.png b/ug-wifidirect/resources/images/A09_device_camera_connect.png new file mode 100644 index 0000000..623056a Binary files /dev/null and b/ug-wifidirect/resources/images/A09_device_camera_connect.png differ diff --git a/ug-wifidirect/resources/images/A09_device_computer.png b/ug-wifidirect/resources/images/A09_device_computer.png index 6c4a633..293deb7 100755 Binary files a/ug-wifidirect/resources/images/A09_device_computer.png and b/ug-wifidirect/resources/images/A09_device_computer.png differ diff --git a/ug-wifidirect/resources/images/A09_device_computer_connect.png b/ug-wifidirect/resources/images/A09_device_computer_connect.png new file mode 100644 index 0000000..8968996 Binary files /dev/null and b/ug-wifidirect/resources/images/A09_device_computer_connect.png differ diff --git a/ug-wifidirect/resources/images/A09_device_display.png b/ug-wifidirect/resources/images/A09_device_display.png new file mode 100755 index 0000000..87aa317 Binary files /dev/null and b/ug-wifidirect/resources/images/A09_device_display.png differ diff --git a/ug-wifidirect/resources/images/A09_device_display_connect.png b/ug-wifidirect/resources/images/A09_device_display_connect.png new file mode 100644 index 0000000..361009a Binary files /dev/null and b/ug-wifidirect/resources/images/A09_device_display_connect.png differ diff --git a/ug-wifidirect/resources/images/A09_device_gaming_devices.png b/ug-wifidirect/resources/images/A09_device_gaming_devices.png new file mode 100755 index 0000000..8672a46 Binary files /dev/null and b/ug-wifidirect/resources/images/A09_device_gaming_devices.png differ diff --git a/ug-wifidirect/resources/images/A09_device_input_device.png b/ug-wifidirect/resources/images/A09_device_input_device.png new file mode 100755 index 0000000..4130993 Binary files /dev/null and b/ug-wifidirect/resources/images/A09_device_input_device.png differ diff --git a/ug-wifidirect/resources/images/A09_device_input_device_connect.png b/ug-wifidirect/resources/images/A09_device_input_device_connect.png new file mode 100644 index 0000000..5de49c3 Binary files /dev/null and b/ug-wifidirect/resources/images/A09_device_input_device_connect.png differ diff --git a/ug-wifidirect/resources/images/A09_device_mobile.png b/ug-wifidirect/resources/images/A09_device_mobile.png deleted file mode 100755 index a671a84..0000000 Binary files a/ug-wifidirect/resources/images/A09_device_mobile.png and /dev/null differ diff --git a/ug-wifidirect/resources/images/A09_device_multimedia_devices.png b/ug-wifidirect/resources/images/A09_device_multimedia_devices.png new file mode 100755 index 0000000..0d10f38 Binary files /dev/null and b/ug-wifidirect/resources/images/A09_device_multimedia_devices.png differ diff --git a/ug-wifidirect/resources/images/A09_device_multimedia_devices_connect.png b/ug-wifidirect/resources/images/A09_device_multimedia_devices_connect.png new file mode 100644 index 0000000..367209f Binary files /dev/null and b/ug-wifidirect/resources/images/A09_device_multimedia_devices_connect.png differ diff --git a/ug-wifidirect/resources/images/A09_device_network_infrastructure.png b/ug-wifidirect/resources/images/A09_device_network_infrastructure.png new file mode 100755 index 0000000..f0ef92c Binary files /dev/null and b/ug-wifidirect/resources/images/A09_device_network_infrastructure.png differ diff --git a/ug-wifidirect/resources/images/A09_device_network_infrastructure_connect.png b/ug-wifidirect/resources/images/A09_device_network_infrastructure_connect.png new file mode 100644 index 0000000..8699a57 Binary files /dev/null and b/ug-wifidirect/resources/images/A09_device_network_infrastructure_connect.png differ diff --git a/ug-wifidirect/resources/images/A09_device_printer.png b/ug-wifidirect/resources/images/A09_device_printer.png new file mode 100755 index 0000000..3b36c01 Binary files /dev/null and b/ug-wifidirect/resources/images/A09_device_printer.png differ diff --git a/ug-wifidirect/resources/images/A09_device_printer_connect.png b/ug-wifidirect/resources/images/A09_device_printer_connect.png new file mode 100644 index 0000000..13d860f Binary files /dev/null and b/ug-wifidirect/resources/images/A09_device_printer_connect.png differ diff --git a/ug-wifidirect/resources/images/A09_device_storage.png b/ug-wifidirect/resources/images/A09_device_storage.png new file mode 100755 index 0000000..d0d94e9 Binary files /dev/null and b/ug-wifidirect/resources/images/A09_device_storage.png differ diff --git a/ug-wifidirect/resources/images/A09_device_storage_connect.png b/ug-wifidirect/resources/images/A09_device_storage_connect.png new file mode 100644 index 0000000..c63de69 Binary files /dev/null and b/ug-wifidirect/resources/images/A09_device_storage_connect.png differ diff --git a/ug-wifidirect/resources/images/A09_device_telephone.png b/ug-wifidirect/resources/images/A09_device_telephone.png new file mode 100755 index 0000000..83d7507 Binary files /dev/null and b/ug-wifidirect/resources/images/A09_device_telephone.png differ diff --git a/ug-wifidirect/resources/images/A09_device_telephone_connect.png b/ug-wifidirect/resources/images/A09_device_telephone_connect.png new file mode 100644 index 0000000..b6a7e14 Binary files /dev/null and b/ug-wifidirect/resources/images/A09_device_telephone_connect.png differ diff --git a/ug-wifidirect/src/wfd_client.c b/ug-wifidirect/src/wfd_client.c old mode 100644 new mode 100755 index 255baa9..e565b52 --- a/ug-wifidirect/src/wfd_client.c +++ b/ug-wifidirect/src/wfd_client.c @@ -1,26 +1,21 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd -/* - * This file implements Wi-Fi direct client functions. - * - * @file wfd_client.c - * @author Gibyoung Kim (lastkgb.kim@samsung.com) - * @version 0.1 - */ +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license + +* 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 #include @@ -29,6 +24,8 @@ #include #include #include +//#include +#include #include #include #include @@ -37,9 +34,6 @@ #include "wfd_ug_view.h" #include "wfd_client.h" - - - static void _wifi_state_cb(keynode_t *key, void *data) { __FUNC_ENTER__; @@ -51,10 +45,11 @@ static void _wifi_state_cb(keynode_t *key, void *data) if (res != 0) { DBG(LOG_ERROR, "Failed to get wifi state from vconf. [%d]\n", res); + // TODO: set genlist head item as "WiFi Direct" return; } - if (wifi_state == VCONFKEY_WIFI_OFF) + if(wifi_state == VCONFKEY_WIFI_OFF) { DBG(LOG_VERBOSE, "WiFi is turned off\n"); wfd_client_swtch_force(ugd, TRUE); @@ -65,7 +60,7 @@ static void _wifi_state_cb(keynode_t *key, void *data) } res = net_deregister_client(); - if (res != NET_ERR_NONE) + if(res != NET_ERR_NONE) { DBG(LOG_ERROR, "Failed to deregister network client. [%d]\n", res); } @@ -94,14 +89,14 @@ int wfd_wifi_off(void *data) } DBG(LOG_VERBOSE, "Vconf key callback is registered\n"); res = net_register_client((net_event_cb_t) _network_event_cb, NULL); - if (res != NET_ERR_NONE) + if(res != NET_ERR_NONE) { DBG(LOG_ERROR, "Failed to register network client. [%d]\n", res); return -1; } DBG(LOG_VERBOSE, "Network client is registered\n"); res = net_wifi_power_off(); - if (res != NET_ERR_NONE) + if(res != NET_ERR_NONE) { DBG(LOG_ERROR, "Failed to turn off wifi. [%d]\n", res); return -1; @@ -111,194 +106,350 @@ int wfd_wifi_off(void *data) return 0; } +static void _hotspot_state_cb(keynode_t *key, void *data) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + int res; + int hotspot_mode; + tethering_error_e ret = TETHERING_ERROR_NONE; + tethering_h th = NULL; + + res = vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &hotspot_mode); + if (res != 0) + { + DBG(LOG_ERROR, "Failed to get mobile hotspot state from vconf. [%d]\n", res); + // TODO: set genlist head item as "WiFi Direct" + return; + } + + if(hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) + { + DBG(LOG_VERBOSE, " Mobile hotspot is activated\n"); + } + else + { + DBG(LOG_VERBOSE, " Mobile hotspot is deactivated\n"); + wfd_client_swtch_force(ugd, TRUE); + } + + th = ugd->hotspot_handle; + + if(th != NULL) + { + /* Deregister cbs */ + ret = tethering_unset_disabled_cb(th, TETHERING_TYPE_WIFI); + if(ret != TETHERING_ERROR_NONE) + DBG(LOG_ERROR, "tethering_unset_disabled_cb is failed(%d)\n", ret); + + /* Destroy tethering handle */ + ret = tethering_destroy(th); + if(ret != TETHERING_ERROR_NONE) + DBG(LOG_ERROR, "tethering_destroy is failed(%d)\n", ret); + + ugd->hotspot_handle = NULL; + } + + __FUNC_EXIT__; +} + +static void __disabled_cb(tethering_error_e error, tethering_type_e type, tethering_disabled_cause_e code, void *data) +{ + __FUNC_ENTER__; + + if (error != TETHERING_ERROR_NONE) { + + if (code != TETHERING_DISABLED_BY_REQUEST) { + return; + } + DBG(LOG_ERROR, "error !!! TETHERING is not disabled.\n"); + return; + } + + DBG(LOG_VERBOSE, "TETHERING is disabled.\n"); + + __FUNC_EXIT__; + + return; +} + + +int wfd_mobile_ap_off(void *data) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + int res; + tethering_error_e ret = TETHERING_ERROR_NONE; + tethering_h th = NULL; + + res = vconf_notify_key_changed(VCONFKEY_MOBILE_HOTSPOT_MODE, _hotspot_state_cb, ugd); + if (res == -1) + { + DBG(LOG_ERROR, "Failed to register vconf callback\n"); + return -1; + } + + /* Create tethering handle */ + ret = tethering_create(&th); + if(ret != TETHERING_ERROR_NONE) + { + DBG(LOG_ERROR, "Failed to tethering_create() [%d]\n", ret); + return -1; + } + else + { + DBG(LOG_VERBOSE, "Succeeded to tethering_create()\n"); + } + + /* Register cbs */ + ret = tethering_set_disabled_cb(th, TETHERING_TYPE_WIFI, + __disabled_cb, NULL); + if(ret != TETHERING_ERROR_NONE) + { + DBG(LOG_ERROR, "tethering_set_disabled_cb is failed\n", ret); + return -1; + } + + /* Disable tethering */ + ret = tethering_disable(th, TETHERING_TYPE_WIFI); + if(ret != TETHERING_ERROR_NONE) + { + DBG(LOG_ERROR, "Failed to turn off mobile hotspot. [%d]\n", ret); + return -1; + } + else + { + DBG(LOG_VERBOSE, "Succeeded to turn off mobile hotspot\n"); + } + + ugd->hotspot_handle = th; + + + __FUNC_EXIT__; + return 0; +} + +#if 0 static device_type_s *wfd_client_find_peer_by_ssid(void *data, const char *ssid) { __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data *) data; + struct ug_data *ugd = (struct ug_data*) data; int i; - if (ugd == NULL) + if(ugd == NULL) { DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); return NULL; } - for (i = 0; i < ugd->peer_cnt; i++) + for(i=0; igl_available_peer_cnt; i++) { DBG(LOG_VERBOSE, "check %dth peer\n", i); - if (!strcmp(ugd->peers[i].ssid, ssid)) + if(!strcmp(ugd->gl_available_peers[i].ssid, ssid)) { DBG(LOG_VERBOSE, "found peer. [%d]\n", i); __FUNC_EXIT__; - return &ugd->peers[i]; + return &ugd->gl_available_peers[i]; } } __FUNC_EXIT__; return NULL; } +#endif -static device_type_s *wfd_client_find_peer_by_mac(void *data, - const char *mac_addr) +static device_type_s *wfd_client_find_peer_by_mac(void *data, const char *mac_addr) { __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data *) data; + struct ug_data *ugd = (struct ug_data*) data; int i; - if (ugd == NULL) + if(ugd == NULL) { DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); return NULL; } - for (i = 0; i < ugd->peer_cnt; i++) + if (ugd->multi_connect_mode != WFD_MULTI_CONNECT_MODE_NONE) { - DBG(LOG_VERBOSE, "check %dth peer\n", i); - if (!strncmp - (mac_addr, (const char *) ugd->peers[i].mac_addr, MAC_LENGTH)) - { - DBG(LOG_VERBOSE, "found peer. [%d]\n", i); - __FUNC_EXIT__; - return &ugd->peers[i]; - } + for(i=0; iraw_multi_selected_peer_cnt; i++) + { + DBG(LOG_VERBOSE, "[Multi Connect] check %dth peer\n", i); + if(!strncmp(mac_addr, (const char*) ugd->raw_multi_selected_peers[i].mac_addr, MAC_LENGTH)) + { + DBG(LOG_VERBOSE, "selected found peer. [%d]\n", i); + __FUNC_EXIT__; + return &ugd->raw_multi_selected_peers[i]; + } + } + } + else + { + for(i=0; iraw_discovered_peer_cnt; i++) + { + DBG(LOG_VERBOSE, "check %dth peer\n", i); + if(!strncmp(mac_addr, (const char*) ugd->raw_discovered_peers[i].mac_addr, MAC_LENGTH)) + { + DBG(LOG_VERBOSE, "found peer. [%d]\n", i); + __FUNC_EXIT__; + return &ugd->raw_discovered_peers[i]; + } + } + } __FUNC_EXIT__; return NULL; } -void _activation_cb(int error_code, wifi_direct_device_state_e device_state, - void *user_data) +int _wfd_ug_view_clean_on_off(struct ug_data *ugd) +{ + wfd_ug_view_update_peers(ugd); + return 0; +} + +void _activation_cb(int error_code, wifi_direct_device_state_e device_state, void *user_data) { __FUNC_ENTER__; int res; - wifi_direct_state_e wfd_status; - struct ug_data *ugd = (struct ug_data *) user_data; + struct ug_data *ugd = (struct ug_data*) user_data; - wifi_direct_get_state(&wfd_status); - DBG(LOG_VERBOSE, "WFD status [%d]", wfd_status); - ugd->wfd_status = wfd_status; + wfd_refresh_wifi_direct_state(ugd); - switch (device_state) + switch(device_state) { - case WIFI_DIRECT_DEVICE_STATE_ACTIVATED: - DBG(LOG_VERBOSE, "WIFI_DIRECT_DEVICE_STATE_ACTIVATED\n"); - if(error_code != WIFI_DIRECT_ERROR_NONE) - { - DBG(LOG_ERROR, "Error in Activation/Deactivation [%d]\n", error_code); - wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_ACTIVATE_FAIL"), POPUP_TYPE_ACTIVATE_FAIL); + case WIFI_DIRECT_DEVICE_STATE_ACTIVATED: + DBG(LOG_VERBOSE, "WIFI_DIRECT_DEVICE_STATE_ACTIVATED\n"); + if(error_code != WIFI_DIRECT_ERROR_NONE) + { + DBG(LOG_ERROR, "Error in Activation/Deactivation [%d]\n", error_code); + wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_ACTIVATE_FAIL"), POPUP_TYPE_ACTIVATE_FAIL); - ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT; - ugd->wfd_onoff = 0; + ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT; + ugd->wfd_onoff = 0; + wfd_ug_view_refresh_glitem(ugd->head); + return; + } + + ugd->head_text_mode = HEAD_TEXT_TYPE_ACTIVATED; + ugd->wfd_onoff = 1; wfd_ug_view_refresh_glitem(ugd->head); - return; - } - ugd->head_text_mode = HEAD_TEXT_TYPE_ACTIVATED; - ugd->wfd_onoff = 1; - wfd_ug_view_refresh_glitem(ugd->head); - res = vconf_set_int("db/wifi_direct/onoff", ugd->wfd_onoff); - if (res != 0) - { - DBG(LOG_ERROR, "Failed to set vconf value for WFD onoff status\n"); - } - wfg_ug_act_popup_remove(ugd); + wfg_ug_act_popup_remove(ugd); - res = vconf_ignore_key_changed(VCONFKEY_WIFI_STATE, _wifi_state_cb); - if (res == -1) - { - DBG(LOG_ERROR, - "Failed to ignore vconf key callback for wifi state\n"); - } + res = vconf_ignore_key_changed(VCONFKEY_WIFI_STATE, _wifi_state_cb); + if(res == -1) + { + DBG(LOG_ERROR, "Failed to ignore vconf key callback for wifi state\n"); + } + + res = vconf_ignore_key_changed(VCONFKEY_MOBILE_HOTSPOT_MODE, _hotspot_state_cb); + if(res == -1) + { + DBG(LOG_ERROR, "Failed to ignore vconf key callback for hotspot state\n"); + } + + res = wifi_direct_start_discovery(FALSE, 0); + if(res != WIFI_DIRECT_ERROR_NONE) + { + DBG(LOG_ERROR, "Failed to start discovery. [%d]\n", res); + } + DBG(LOG_VERBOSE, "Discovery is started\n"); + break; + + case WIFI_DIRECT_DEVICE_STATE_DEACTIVATED: + DBG(LOG_VERBOSE, "WIFI_DIRECT_DEVICE_STATE_DEACTIVATED\n"); + if(error_code != WIFI_DIRECT_ERROR_NONE) + { + DBG(LOG_ERROR, "Error in Activation/Deactivation [%d]\n", error_code); + wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_DEACTIVATE_FAIL"), POPUP_TYPE_DEACTIVATE_FAIL); + ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT; + ugd->wfd_onoff = 1; + wfd_ug_view_refresh_glitem(ugd->head); + return; + } - res = wifi_direct_start_discovery(FALSE, 0); - if (res != WIFI_DIRECT_ERROR_NONE) - { - DBG(LOG_ERROR, "Failed to start discovery. [%d]\n", res); - } - break; - DBG(LOG_VERBOSE, "Discovery is started\n"); - case WIFI_DIRECT_DEVICE_STATE_DEACTIVATED: - DBG(LOG_VERBOSE, "WIFI_DIRECT_DEVICE_STATE_DEACTIVATED\n"); - if(error_code != WIFI_DIRECT_ERROR_NONE) - { - DBG(LOG_ERROR, "Error in Activation/Deactivation [%d]\n", error_code); - wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_DEACTIVATE_FAIL"), POPUP_TYPE_DEACTIVATE_FAIL); ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT; - ugd->wfd_onoff = 1; - wfd_ug_view_refresh_glitem(ugd->head); - return; - } + ugd->wfd_onoff = 0; - ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT; - ugd->wfd_onoff = 0; - wfd_ug_view_refresh_glitem(ugd->head); - res = vconf_set_int("db/wifi_direct/onoff", ugd->wfd_onoff); - if (res != 0) - { - DBG(LOG_ERROR, "Failed to set vconf value for WFD onoff status\n"); - } - wfd_ug_view_free_peers(ugd); - wfd_ug_view_update_peers(ugd); - break; - default: - break; + wfd_ug_view_update_peers(ugd); + + break; + default: + break; + } + + wfd_ug_view_refresh_glitem(ugd->head); + + if (ugd->scan_btn) { + wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"), TRUE); + } + + if (ugd->multi_connect_btn) { + wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_SCAN"), TRUE); } - wfd_ug_view_refresh_button(ugd->scan_btn, ugd->wfd_onoff); __FUNC_EXIT__; return; } -static int peer_cnt; -static int connected_cnt; -static int discovered_cnt; - -bool _wfd_discoverd_peer_cb(wifi_direct_discovered_peer_info_s * peer, - void *user_data) +bool _wfd_discoverd_peer_cb(wifi_direct_discovered_peer_info_s* peer, void *user_data) { __FUNC_ENTER__; - device_type_s *peers = (device_type_s *) user_data; - - DBG(LOG_VERBOSE, "%dth discovered peer. [%s]\n", peer_cnt, peer->ssid); - if (peer->is_connected == TRUE) - return FALSE; - memcpy(peers[peer_cnt].ssid, peer->ssid, SSID_LENGTH); - peers[peer_cnt].ssid[31] = '\0'; - DBG(LOG_VERBOSE, "\tSSID: [%s]\n", peers[peer_cnt].ssid); - peers[peer_cnt].category = peer->primary_device_type; - DBG(LOG_VERBOSE, "\tPeer category [%d] -> [%d]\n", peer->primary_device_type, peers[peer_cnt].category); - strncpy(peers[peer_cnt].mac_addr, peer->mac_address, MAC_LENGTH); - strncpy(peers[peer_cnt].if_addr, peer->interface_address, MAC_LENGTH); - peers[peer_cnt].conn_status = PEER_CONN_STATUS_DISCONNECTED; - DBG(LOG_VERBOSE, "\tStatus: [%d]\n", peers[peer_cnt].conn_status); - peer_cnt++; + + struct ug_data *ugd = (struct ug_data*) user_data; + int peer_cnt = ugd->raw_discovered_peer_cnt; + + DBG(LOG_VERBOSE, "%dth discovered peer. [%s] [%s]\n", peer_cnt, peer->ssid, peer->mac_address); + + strncpy(ugd->raw_discovered_peers[peer_cnt].ssid, peer->ssid, sizeof(ugd->raw_discovered_peers[peer_cnt].ssid)); + ugd->raw_discovered_peers[peer_cnt].category = peer->primary_device_type; + strncpy(ugd->raw_discovered_peers[peer_cnt].mac_addr, peer->mac_address, MAC_LENGTH); + strncpy(ugd->raw_discovered_peers[peer_cnt].if_addr, peer->interface_address, MAC_LENGTH); + ugd->raw_discovered_peers[peer_cnt].is_group_owner = peer->is_group_owner; + ugd->raw_discovered_peers[peer_cnt].is_persistent_group_owner = peer->is_persistent_group_owner; + ugd->raw_discovered_peers[peer_cnt].is_connected = peer->is_connected; + + if (TRUE == peer->is_connected) { + ugd->raw_discovered_peers[peer_cnt].conn_status = PEER_CONN_STATUS_CONNECTED; + } else { + ugd->raw_discovered_peers[peer_cnt].conn_status = PEER_CONN_STATUS_DISCONNECTED; + } + + DBG(LOG_VERBOSE, "\tSSID: [%s]\n", ugd->raw_discovered_peers[peer_cnt].ssid); + DBG(LOG_VERBOSE, "\tPeer category [%d] -> [%d]\n", peer->primary_device_type, ugd->raw_discovered_peers[peer_cnt].category); + DBG(LOG_VERBOSE, "\tStatus: [%d]\n", ugd->raw_discovered_peers[peer_cnt].conn_status); + + ugd->raw_discovered_peer_cnt ++; free(peer->ssid); free(peer->mac_address); free(peer->interface_address); free(peer); + __FUNC_EXIT__; return TRUE; } -bool _wfd_connected_peer_cb(wifi_direct_connected_peer_info_s * peer, - void *user_data) +bool _wfd_connected_peer_cb(wifi_direct_connected_peer_info_s* peer, void *user_data) { __FUNC_ENTER__; - device_type_s *peers = (device_type_s *) user_data; - - DBG(LOG_VERBOSE, "%dth connected peer. [%s]\n", peer_cnt, peer->ssid); - memcpy(peers[peer_cnt].ssid, peer->ssid, SSID_LENGTH); - peers[peer_cnt].ssid[31] = '\0'; - DBG(LOG_VERBOSE, "\tSSID: [%s]\n", peers[peer_cnt].ssid); - peers[peer_cnt].category = peer->primary_device_type; - DBG(LOG_VERBOSE, "\tCategory: [%d]\n", peers[peer_cnt].category); - strncpy(peers[peer_cnt].mac_addr, peer->mac_address, MAC_LENGTH); - strncpy(peers[peer_cnt].if_addr, peer->interface_address, MAC_LENGTH); - peers[peer_cnt].conn_status = PEER_CONN_STATUS_CONNECTED; - DBG(LOG_VERBOSE, "\tStatus: [%d]\n", peers[peer_cnt].conn_status); - peer_cnt++; + struct ug_data *ugd = (struct ug_data*) user_data; + int peer_cnt = ugd->raw_connected_peer_cnt; + + DBG(LOG_VERBOSE, "%dth connected peer. [%s] [%s]\n", peer_cnt, peer->ssid, peer->mac_address); + + strncpy(ugd->raw_connected_peers[peer_cnt].ssid, peer->ssid, sizeof(ugd->raw_connected_peers[peer_cnt].ssid)); + ugd->raw_connected_peers[peer_cnt].category = peer->primary_device_type; + strncpy(ugd->raw_connected_peers[peer_cnt].mac_addr, peer->mac_address, MAC_LENGTH); + strncpy(ugd->raw_connected_peers[peer_cnt].if_addr, peer->interface_address, MAC_LENGTH); + ugd->raw_connected_peers[peer_cnt].conn_status = PEER_CONN_STATUS_CONNECTED; + + DBG(LOG_VERBOSE, "\tStatus: [%d]\n", ugd->raw_connected_peers[peer_cnt].conn_status); + DBG(LOG_VERBOSE, "\tCategory: [%d]\n", ugd->raw_connected_peers[peer_cnt].category); + DBG(LOG_VERBOSE, "\tSSID: [%s]\n", ugd->raw_connected_peers[peer_cnt].ssid); + + ugd->raw_connected_peer_cnt++; free(peer->ssid); free(peer->mac_address); @@ -308,175 +459,250 @@ bool _wfd_connected_peer_cb(wifi_direct_connected_peer_info_s * peer, return TRUE; } -void _discover_cb(int error_code, wifi_direct_discovery_state_e discovery_state, - void *user_data) +int wfd_ug_get_discovered_peers(struct ug_data *ugd) +{ + int res = 0; + + if (ugd==NULL) + return -1; + + ugd->raw_discovered_peer_cnt = 0; + res = wifi_direct_foreach_discovered_peers(_wfd_discoverd_peer_cb, (void*) ugd); + if (res != WIFI_DIRECT_ERROR_NONE) + { + ugd->raw_discovered_peer_cnt = 0; + DBG(LOG_ERROR, "Get discovery result failed: %d\n", res); + } + + return 0; +} + + +int wfd_ug_get_connected_peers(struct ug_data *ugd) +{ + int res = 0; + + if (ugd==NULL) + return -1; + + ugd->raw_connected_peer_cnt = 0; + res = wifi_direct_foreach_connected_peers(_wfd_connected_peer_cb, (void*) ugd); + if(res != WIFI_DIRECT_ERROR_NONE) + { + ugd->raw_connected_peer_cnt = 0; + DBG(LOG_ERROR, "Get connected peer failed: %d\n", res); + } + return 0; +} + +void _discover_cb(int error_code, wifi_direct_discovery_state_e discovery_state, void *user_data) { __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data *) user_data; - int res; - device_type_s *peers = NULL; + struct ug_data *ugd = (struct ug_data*) user_data; - if (ugd == NULL) + if(ugd == NULL) { DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); return; } - peers = calloc(MAX_PEER_NUM, sizeof(device_type_s)); - - if (discovery_state == WIFI_DIRECT_ONLY_LISTEN_STARTED) + if(discovery_state == WIFI_DIRECT_ONLY_LISTEN_STARTED) { ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT; } - else if (discovery_state == WIFI_DIRECT_DISCOVERY_STARTED) + else if(discovery_state == WIFI_DIRECT_DISCOVERY_STARTED) { ugd->head_text_mode = HEAD_TEXT_TYPE_SCANING; } - wfd_ug_view_refresh_glitem(ugd->head); - - if (ugd->wfd_status < WFD_LINK_STATUS_ACTIVATED - || ugd->wfd_status > WFD_LINK_STATUS_GROUP_OWNER) - { - return; - } - else - { - peer_cnt = 0; - } - - if (ugd->wfd_status >= WFD_LINK_STATUS_CONNECTED) + else if(discovery_state == WIFI_DIRECT_DISCOVERY_FOUND) { - DBG(LOG_VERBOSE, "getting connected peer..\n"); - res = - wifi_direct_foreach_connected_peers(_wfd_connected_peer_cb, - (void *) peers); - if (res != WIFI_DIRECT_ERROR_NONE) - { - connected_cnt = 0; - DBG(LOG_ERROR, "get discovery result failed: %d\n", res); - } + ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT; } - if (discovery_state == WIFI_DIRECT_DISCOVERY_FOUND) - { - DBG(LOG_VERBOSE, "Peer is found\n"); - ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT; - wfd_ug_view_refresh_glitem(ugd->head); + wfd_ug_view_refresh_glitem(ugd->head); - if (ugd->wfd_status >= WFD_LINK_STATUS_ACTIVATED) - { - DBG(LOG_VERBOSE, "getting discovered peer..\n"); - res = - wifi_direct_foreach_discovered_peers(_wfd_discoverd_peer_cb, - (void *) peers); - if (res != WIFI_DIRECT_ERROR_NONE) - { - discovered_cnt = 0; - DBG(LOG_ERROR, "get discovery result failed: %d\n", res); - } - } + if (WIFI_DIRECT_DISCOVERY_STARTED == discovery_state) { + if (ugd->scan_btn) { + wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_STOPSCAN"), TRUE); + } + + if (ugd->multi_connect_btn) { + wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_STOPSCAN"), TRUE); + } + } else { + if (ugd->scan_btn) { + wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"), TRUE); + } + + if (ugd->multi_connect_btn) { + wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_SCAN"), TRUE); + } } - wfd_ug_view_free_peers(ugd); - - ugd->peers = peers; - ugd->peer_cnt = peer_cnt; + wfd_ug_get_discovered_peers(ugd); + wfd_ug_get_connected_peers(ugd); wfd_ug_view_update_peers(ugd); - DBG(LOG_VERBOSE, "%d peers are updated\n", peer_cnt); + + _wfd_free_multiconnect_device(ugd); + _wfd_update_multiconnect_device(ugd); + //_change_multi_button_title(ugd); __FUNC_EXIT__; return; } -void _connection_cb(int error_code, - wifi_direct_connection_state_e connection_state, - const char *mac_address, void *user_data) +void _connection_cb(int error_code, wifi_direct_connection_state_e connection_state, const char *mac_address, void *user_data) { __FUNC_ENTER__; - DBG(LOG_VERBOSE, "Connection event [%d], error_code [%d]\n", - connection_state, error_code); - struct ug_data *ugd = (struct ug_data *) user_data; + + struct ug_data *ugd = (struct ug_data*) user_data; device_type_s *peer = NULL; bool owner = FALSE; int res = 0; - if (mac_address == NULL) + DBG(LOG_VERBOSE, "Connection event [%d], error_code [%d]\n", connection_state, error_code); + + if(mac_address == NULL) { DBG(LOG_ERROR, "Incorrect parameter(peer mac is NULL)\n"); return; } DBG(LOG_VERBOSE, "Connection event from %s", mac_address); - peer = wfd_client_find_peer_by_mac(ugd, mac_address); - if (peer == NULL) + if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS) { - DBG(LOG_ERROR, "Failed to find peer [mac: %s]\n", mac_address); - return; + peer = wfd_client_find_peer_by_mac(ugd, mac_address); + if (peer != NULL) + { + switch(connection_state) + { + case WIFI_DIRECT_CONNECTION_RSP: + if(error_code == WIFI_DIRECT_ERROR_NONE) + { + ugd->wfd_status = WFD_LINK_STATUS_CONNECTED; + peer->conn_status = PEER_CONN_STATUS_CONNECTED; + } + else + { + peer->conn_status = PEER_CONN_STATUS_FAILED_TO_CONNECT; + } + ugd->g_source_multi_connect_next = g_timeout_add(1000, wfd_multi_connect_next_cb, ugd); + break; + default: + break; + } + wfd_ug_get_connected_peers(ugd); + wfd_ug_view_update_peers(ugd); + } + else + { + DBG(LOG_VERBOSE, "peer is not found [%s]", mac_address); + } + goto refresh_button; + } + + + peer = wfd_client_find_peer_by_mac(ugd, mac_address); + + if (NULL == peer || NULL == peer->ssid) { + DBG(LOG_ERROR, "SSID from connection is NULL !!\n"); + goto refresh_button; } - switch (connection_state) + switch(connection_state) { - case WIFI_DIRECT_CONNECTION_RSP: - DBG(LOG_VERBOSE, "WIFI_DIRECT_CONNECTION_RSP\n"); + case WIFI_DIRECT_CONNECTION_RSP: + DBG(LOG_VERBOSE, "WIFI_DIRECT_CONNECTION_RSP\n"); - if (error_code == WIFI_DIRECT_ERROR_NONE) - { - ugd->wfd_status = WFD_LINK_STATUS_CONNECTED; - peer->conn_status = PEER_CONN_STATUS_CONNECTED; - res = wifi_direct_is_group_owner(&owner); - if (res == WIFI_DIRECT_ERROR_NONE) + if(error_code == WIFI_DIRECT_ERROR_NONE) { - if (!owner) - wfd_ug_view_refresh_button(ugd->scan_btn, FALSE); + ugd->wfd_status = WFD_LINK_STATUS_CONNECTED; + peer->conn_status = PEER_CONN_STATUS_CONNECTED; } else { - DBG(LOG_ERROR, - "Failed to get whether client is group owner. [%d]\n", res); + peer->conn_status = PEER_CONN_STATUS_FAILED_TO_CONNECT; } - } - else - { - peer->conn_status = PEER_CONN_STATUS_DISCONNECTED; + + wfd_ug_get_connected_peers(ugd); + wfd_ug_view_update_peers(ugd); + break; + case WIFI_DIRECT_DISCONNECTION_RSP: + case WIFI_DIRECT_DISCONNECTION_IND: + case WIFI_DIRECT_DISASSOCIATION_IND: + DBG(LOG_VERBOSE, "WIFI_DIRECT_DISCONNECTION_X\n"); + if(error_code != WIFI_DIRECT_ERROR_NONE) + { + // TODO: show disconnection error popup + return; + } + + if (peer!=NULL) + peer->conn_status = PEER_CONN_STATUS_DISCONNECTED; + else + { + // In case of disconnect_all(), no specific peer is found. + } + wifi_direct_start_discovery(FALSE, 0); - } - break; - case WIFI_DIRECT_DISCONNECTION_RSP: - case WIFI_DIRECT_DISCONNECTION_IND: - case WIFI_DIRECT_DISASSOCIATION_IND: - DBG(LOG_VERBOSE, "WIFI_DIRECT_DISCONNECTION_X\n"); - if (error_code != WIFI_DIRECT_ERROR_NONE) - { - return; - } + ugd->wfd_status = WFD_LINK_STATUS_DISCOVERING; + ugd->head_text_mode = HEAD_TEXT_TYPE_SCANING; - peer->conn_status = PEER_CONN_STATUS_DISCONNECTED; + wfd_ug_view_refresh_glitem(ugd->head); - ugd->wfd_status = WFD_LINK_STATUS_ACTIVATED; - ugd->head_text_mode = HEAD_TEXT_TYPE_ACTIVATED; + wfd_ug_get_discovered_peers(ugd); + wfd_ug_get_connected_peers(ugd); + wfd_ug_view_update_peers(ugd); + break; + + case WIFI_DIRECT_CONNECTION_IN_PROGRESS: + DBG(LOG_VERBOSE, "WIFI_DIRECT_CONNECTION_IN_PROGRESS\n"); + peer->conn_status = PEER_CONN_STATUS_CONNECTING; + break; + case WIFI_DIRECT_CONNECTION_REQ: + case WIFI_DIRECT_CONNECTION_WPS_REQ: + DBG(LOG_VERBOSE, "WIFI_DIRECT_CLI_EVENT_CONNECTION_REQ\n"); + break; + default: + break; + } - wfd_ug_view_refresh_button(ugd->scan_btn, TRUE); - wifi_direct_start_discovery(FALSE, 0); - ugd->wfd_status = WFD_LINK_STATUS_DISCOVERING; - ugd->head_text_mode = HEAD_TEXT_TYPE_SCANING; - wfd_ug_view_refresh_glitem(ugd->head); - break; - case WIFI_DIRECT_CONNECTION_IN_PROGRESS: - DBG(LOG_VERBOSE, "WIFI_DIRECT_CONNECTION_IN_PROGRESS\n"); - peer->conn_status = PEER_CONN_STATUS_CONNECTING; - break; - case WIFI_DIRECT_CONNECTION_REQ: - case WIFI_DIRECT_CONNECTION_WPS_REQ: - DBG(LOG_VERBOSE, "WIFI_DIRECT_CLI_EVENT_CONNECTION_REQ\n"); - break; - default: - break; - } - - if (peer != NULL) + if(peer != NULL) wfd_ug_view_refresh_glitem(peer->gl_item); + _change_multi_button_title(ugd); + +refresh_button: + /* refresh the scan button */ + wfd_refresh_wifi_direct_state(ugd); + if (WIFI_DIRECT_STATE_CONNECTING == ugd->wfd_status || + WIFI_DIRECT_STATE_DISCONNECTING == ugd->wfd_status) { + + res = wifi_direct_is_group_owner(&owner); + if (res == WIFI_DIRECT_ERROR_NONE) { + if (!owner) { + if (ugd->scan_btn) { + wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"), FALSE); + } + + if (ugd->multi_connect_btn) { + wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_SCAN"), FALSE); + } + } + } else { + DBG(LOG_ERROR, "Failed to get whether client is group owner. [%d]\n", res); + } + } else { + if (ugd->scan_btn) { + wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"), TRUE); + } + + if (ugd->multi_connect_btn) { + wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_SCAN"), TRUE); + } + } + __FUNC_EXIT__; return; } @@ -484,18 +710,13 @@ void _connection_cb(int error_code, int wfd_get_vconf_status(void *data) { __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data *) data; - int res; + struct ug_data *ugd = (struct ug_data*) data; char *dev_name; - res = vconf_get_int("db/wifi_direct/onoff", &ugd->wfd_onoff); - if (res != 0) - { - DBG(LOG_ERROR, "vconf_get_int is failed\n"); - } - DBG(LOG_VERBOSE, "VCONF_WFD_ONOFF : %d\n", ugd->wfd_onoff); + // TODO: get wifi direct status from vconf + // db/mobile_hotspot/wifi_key (string) - dev_name = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR); + dev_name = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR); // "db/setting/device_name" (VCONF_WFD_APNAME) if (dev_name == NULL) { ugd->dev_name = strdup(DEFAULT_DEV_NAME); @@ -512,159 +733,125 @@ int wfd_get_vconf_status(void *data) return 0; } -int init_wfd_client(void *data) +int wfd_refresh_wifi_direct_state(void *data) { - __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data *) data; - int res = 0; - wifi_direct_state_e wfd_status; - - res = wifi_direct_initialize(); - if (res != WIFI_DIRECT_ERROR_NONE) - { - DBG(LOG_ERROR, "Failed to initialize wifi direct. [%d]\n", res); - return -1; - } - - res = wifi_direct_set_device_state_changed_cb(_activation_cb, (void *) ugd); - res = - wifi_direct_set_discovery_state_changed_cb(_discover_cb, (void *) ugd); - res = - wifi_direct_set_connection_state_changed_cb(_connection_cb, - (void *) ugd); - + struct ug_data *ugd = (struct ug_data*) data; + int res; + wifi_direct_state_e wfd_status; res = wifi_direct_get_state(&wfd_status); - if (res != WIFI_DIRECT_ERROR_NONE) + if(res != WIFI_DIRECT_ERROR_NONE) { DBG(LOG_ERROR, "Failed to get link status. [%d]\n", res); return -1; } + DBG(LOG_VERBOSE, "WFD status [%d]", wfd_status); ugd->wfd_status = wfd_status; - DBG(LOG_VERBOSE, "WFD link status. [%d]\n", wfd_status); - - if (wfd_status > WIFI_DIRECT_STATE_ACTIVATING) - { - vconf_set_int("db/wifi_direct/onoff", 1); - ugd->wfd_onoff = 1; - } - else - { - vconf_set_int("db/wifi_direct/onoff", 0); - ugd->wfd_onoff = 0; - } - wfd_ug_view_refresh_glitem(ugd->head); - wfd_ug_view_refresh_button(ugd->scan_btn, ugd->wfd_onoff); - - if(wfd_status >= WIFI_DIRECT_STATE_CONNECTED) - { - device_type_s *peers = NULL; - - peers = calloc(MAX_PEER_NUM, sizeof(device_type_s)); - res = wifi_direct_foreach_connected_peers(_wfd_connected_peer_cb, (void*) peers); - if(res != WIFI_DIRECT_ERROR_NONE) - { - connected_cnt = 0; - DBG(LOG_ERROR, "get discovery result failed: %d\n", res); - } - wfd_ug_view_free_peers(ugd); - - ugd->peers = peers; - ugd->peer_cnt = peer_cnt; - - wfd_ug_view_update_peers(ugd); - DBG(LOG_VERBOSE, "%d peers are updated\n", peer_cnt); - } - - if (wfd_status > WIFI_DIRECT_STATE_ACTIVATING) - { - int wifi_state; - vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state); - - if (wifi_state < VCONFKEY_WIFI_CONNECTED) - { - res = wifi_direct_start_discovery(FALSE, 0); - if (res != WIFI_DIRECT_ERROR_NONE) - { - DBG(LOG_ERROR, "Failed to start discovery. [%d]\n", res); - } - DBG(LOG_VERBOSE, "Discovery is started\n"); - } - else - { - wfd_ug_act_popup(ugd, _("IDS_WFD_POP_WIFI_OFF"), - POPUP_TYPE_WIFI_OFF); - } - } - - __FUNC_EXIT__; - return 0; } -int deinit_wfd_client(void *data) +int init_wfd_client(void *data) { __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; int res = 0; - wifi_direct_state_e status = 0; - - wifi_direct_get_state(&status); - if (status == WIFI_DIRECT_STATE_DISCOVERING) - { - DBG(LOG_VERBOSE, "Stop discovery before deregister client\n"); - wifi_direct_cancel_discovery(); - } - - res = wifi_direct_deinitialize(); - if (res != WIFI_DIRECT_ERROR_NONE) + res = wifi_direct_initialize(); + if(res != WIFI_DIRECT_ERROR_NONE) { - DBG(LOG_ERROR, "Failed to deregister client. [%d]\n", res); + DBG(LOG_ERROR, "Failed to initialize wifi direct. [%d]\n", res); + return -1; } - res = vconf_ignore_key_changed(VCONFKEY_WIFI_STATE, _wifi_state_cb); - if (res == -1) - { - DBG(LOG_ERROR, "Failed to ignore vconf key callback for wifi state\n"); - } + res = wifi_direct_set_device_state_changed_cb(_activation_cb, (void*) ugd); + res = wifi_direct_set_discovery_state_changed_cb(_discover_cb, (void*) ugd); + res = wifi_direct_set_connection_state_changed_cb(_connection_cb, (void*) ugd); - res = net_deregister_client(); - if (res != NET_ERR_NONE) - { - DBG(LOG_ERROR, "Failed to deregister network client. [%d]\n", res); - } + /* update WFD status */ + wfd_refresh_wifi_direct_state(ugd); + if (ugd->wfd_status > WIFI_DIRECT_STATE_ACTIVATING) + ugd->wfd_onoff = 1; + else + ugd->wfd_onoff = 0; + DBG(LOG_VERBOSE, "WFD link status. [%d]\n", ugd->wfd_status); __FUNC_EXIT__; return 0; } -int wfd_client_get_link_status() +int deinit_wfd_client(void *data) { - __FUNC_ENTER__; - wifi_direct_state_e status; - int res; - - res = wifi_direct_get_state(&status); - if (res != WIFI_DIRECT_ERROR_NONE) - { - DBG(LOG_ERROR, "Failed to get link status from wfd-server. [%d]", res); - return -1; - } - - __FUNC_EXIT__; - return status; + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + int res = 0; + tethering_error_e ret = TETHERING_ERROR_NONE; + tethering_h th = NULL; + + wfd_refresh_wifi_direct_state(ugd); + + if(ugd->wfd_status == WIFI_DIRECT_STATE_DISCOVERING) + { + DBG(LOG_VERBOSE, "Stop discovery before deregister client\n"); + wifi_direct_cancel_discovery(); + } + + res = wifi_direct_deinitialize(); + if(res != WIFI_DIRECT_ERROR_NONE) + { + DBG(LOG_ERROR, "Failed to deregister client. [%d]\n", res); + } + + res = vconf_ignore_key_changed(VCONFKEY_WIFI_STATE, _wifi_state_cb); + if(res == -1) + { + DBG(LOG_ERROR, "Failed to ignore vconf key callback for wifi state\n"); + } + + res = net_deregister_client(); + if(res != NET_ERR_NONE) + { + DBG(LOG_ERROR, "Failed to deregister network client. [%d]\n", res); + } + + res = vconf_ignore_key_changed(VCONFKEY_MOBILE_HOTSPOT_MODE, _hotspot_state_cb); + if(res == -1) + { + DBG(LOG_ERROR, "Failed to ignore vconf key callback for hotspot state\n"); + } + + th = ugd->hotspot_handle; + + if(th != NULL) + { + /* Deregister cbs */ + ret = tethering_unset_disabled_cb(th, TETHERING_TYPE_WIFI); + if(ret != TETHERING_ERROR_NONE) + DBG(LOG_ERROR, "tethering_unset_disabled_cb is failed(%d)\n", ret); + + /* Destroy tethering handle */ + ret = tethering_destroy(th); + if(ret != TETHERING_ERROR_NONE) + DBG(LOG_ERROR, "tethering_destroy is failed(%d)\n", ret); + + ugd->hotspot_handle = NULL; + + } + + __FUNC_EXIT__; + + return 0; } int wfd_client_switch_on(void *data) { __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data *) data; + struct ug_data *ugd = (struct ug_data*) data; int res; DBG(LOG_VERBOSE, "WFD status [%d]\n", ugd->wfd_status); - if (ugd->wfd_status < WFD_LINK_STATUS_ACTIVATING) + if(ugd->wfd_status < WFD_LINK_STATUS_ACTIVATING) { ugd->wfd_status = WFD_LINK_STATUS_ACTIVATING; @@ -673,23 +860,35 @@ int wfd_client_switch_on(void *data) if (res != 0) { DBG(LOG_ERROR, "Failed to get wifi state from vconf. [%d]\n", res); + // TODO: set genlist head item as "WiFi Direct" + return -1; + } + + int hotspot_mode; + res = vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &hotspot_mode); + if (res != 0) + { + DBG(LOG_ERROR, "Failed to get mobile hotspot state from vconf. [%d]\n", res); + // TODO: set genlist head item as "WiFi Direct" return -1; } - if (wifi_state > VCONFKEY_WIFI_OFF) + if(wifi_state > VCONFKEY_WIFI_OFF) { DBG(LOG_VERBOSE, "WiFi is connected, so have to turn off WiFi"); - wfd_ug_act_popup(ugd, _("IDS_WFD_POP_WIFI_OFF"), - POPUP_TYPE_WIFI_OFF); + wfd_ug_act_popup(ugd, _("IDS_WFD_POP_WIFI_OFF"), POPUP_TYPE_WIFI_OFF); // "This will turn off Wi-Fi client operation.
Continue?" } - else + else if(hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) + { + DBG(LOG_VERBOSE, "WiFi is connected, so have to turn off WiFi"); + wfd_ug_act_popup(ugd, _("IDS_WFD_POP_HOTSPOT_OFF"), POPUP_TYPE_HOTSPOT_OFF); // "This will turn off Portable Wi-Fi hotspots operation.
Continue?" + } + else // (wifi_state < VCONFKEY_WIFI_CONNECTED && !(hotspot_mode & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI)) { res = wifi_direct_activate(); - if (res != WIFI_DIRECT_ERROR_NONE) + if(res != WIFI_DIRECT_ERROR_NONE) { - DBG(LOG_ERROR, - "Failed to activate Wi-Fi Direct. error code = [%d]\n", - res); + DBG(LOG_ERROR, "Failed to activate Wi-Fi Direct. error code = [%d]\n", res); wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_ACTIVATE_FAIL"), POPUP_TYPE_TERMINATE); ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT; @@ -710,12 +909,12 @@ int wfd_client_switch_on(void *data) int wfd_client_switch_off(void *data) { __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data *) data; + struct ug_data *ugd = (struct ug_data*) data; int res; DBG(LOG_VERBOSE, "WFD status [%d]\n", ugd->wfd_status); - if (ugd->wfd_status < WFD_LINK_STATUS_ACTIVATING) + if(ugd->wfd_status < WFD_LINK_STATUS_ACTIVATING) { DBG(LOG_VERBOSE, "Wi-Fi Direct is already deactivated\n"); } @@ -724,10 +923,9 @@ int wfd_client_switch_off(void *data) ugd->wfd_status = WFD_LINK_STATUS_DEACTIVATING; res = wifi_direct_deactivate(); - if (res != WIFI_DIRECT_ERROR_NONE) + if(res != WIFI_DIRECT_ERROR_NONE) { - DBG(LOG_ERROR, - "Failed to deactivate Wi-Fi Direct. error code = [%d]\n", res); + DBG(LOG_ERROR, "Failed to deactivate Wi-Fi Direct. error code = [%d]\n", res); wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_DEACTIVATE_FAIL"), POPUP_TYPE_TERMINATE); ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT; @@ -746,13 +944,12 @@ int wfd_client_swtch_force(void *data, int onoff) struct ug_data *ugd = (struct ug_data*) data; int res; - if (onoff) + if(onoff) { res = wifi_direct_activate(); - if (res != WIFI_DIRECT_ERROR_NONE) + if(res != WIFI_DIRECT_ERROR_NONE) { - DBG(LOG_ERROR, - "Failed to activate Wi-Fi Direct. error code = [%d]\n", res); + DBG(LOG_ERROR, "Failed to activate Wi-Fi Direct. error code = [%d]\n", res); wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_ACTIVATE_FAIL"), POPUP_TYPE_TERMINATE); ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT; @@ -763,10 +960,9 @@ int wfd_client_swtch_force(void *data, int onoff) else { res = wifi_direct_deactivate(); - if (res != WIFI_DIRECT_ERROR_NONE) + if(res != WIFI_DIRECT_ERROR_NONE) { - DBG(LOG_ERROR, - "Failed to deactivate Wi-Fi Direct. error code = [%d]\n", res); + DBG(LOG_ERROR, "Failed to deactivate Wi-Fi Direct. error code = [%d]\n", res); wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_DEACTIVATE_FAIL"), POPUP_TYPE_TERMINATE); ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT; @@ -781,20 +977,45 @@ int wfd_client_swtch_force(void *data, int onoff) int wfd_client_start_discovery(void *data) { __FUNC_ENTER__; - int res; - wifi_direct_state_e status; + struct ug_data *ugd = (struct ug_data*) data; + int res = -1; + +#if 0 + ret = wifi_direct_cancel_discovery(); +// ret = wifi_direct_cancel_discovery(); + if (ret != WIFI_DIRECT_ERROR_NONE) { + DBG(LOG_ERROR, "Failed wfd discover() : %d", ret); + return FALSE; + } + - wifi_direct_get_state(&status); - if (status >= WIFI_DIRECT_STATE_ACTIVATED) + if(ugd->wfd_status >= WIFI_DIRECT_STATE_ACTIVATED) { - res = wifi_direct_start_discovery(FALSE, 0); + res = wifi_direct_start_discovery(FALSE, 30); if (res != WIFI_DIRECT_ERROR_NONE) { DBG(LOG_ERROR, "Failed to start wfd discovery. [%d]", res); + return -1; } } - __FUNC_EXIT__; +#endif + + ugd->wfd_status = WIFI_DIRECT_DISCOVERY_STARTED; + wfd_refresh_wifi_direct_state(ugd); + ugd->head_text_mode = HEAD_TEXT_TYPE_SCANING; + wfd_ug_view_refresh_glitem(ugd->head); + wifi_direct_cancel_discovery(); + + res = wifi_direct_start_discovery(FALSE, 0); + if (res != WIFI_DIRECT_ERROR_NONE) { + DBG(LOG_ERROR, "Fail to restart scanning. %d\n", res); + return -1; + } + + ugd->wfd_status = WIFI_DIRECT_DISCOVERY_FOUND; + wfd_refresh_wifi_direct_state(ugd); + __FUNC_EXIT__; return 0; } @@ -803,8 +1024,9 @@ int wfd_client_connect(const char *mac_addr) __FUNC_ENTER__; int res; + DBG(LOG_ERROR, "connect to peer=[%s]\n", mac_addr); res = wifi_direct_connect(mac_addr); - if (res != WIFI_DIRECT_ERROR_NONE) + if(res != WIFI_DIRECT_ERROR_NONE) { DBG(LOG_ERROR, "Failed to send connection request. [%d]\n", res); return -1; @@ -818,20 +1040,19 @@ int wfd_client_disconnect(const char *mac_addr) __FUNC_ENTER__; int res; - if (mac_addr == NULL) + if(mac_addr == NULL) { res = wifi_direct_disconnect_all(); - if (res != WIFI_DIRECT_ERROR_NONE) + if(res != WIFI_DIRECT_ERROR_NONE) { - DBG(LOG_ERROR, - "Failed to send disconnection request to all. [%d]\n", res); + DBG(LOG_ERROR, "Failed to send disconnection request to all. [%d]\n", res); return -1; } } else { res = wifi_direct_disconnect(mac_addr); - if (res != WIFI_DIRECT_ERROR_NONE) + if(res != WIFI_DIRECT_ERROR_NONE) { DBG(LOG_ERROR, "Failed to send disconnection request. [%d]\n", res); return -1; @@ -840,3 +1061,43 @@ int wfd_client_disconnect(const char *mac_addr) __FUNC_EXIT__; return 0; } + +int wfd_client_set_p2p_group_owner_intent(int go_intent) +{ + __FUNC_ENTER__; + int res; + + res = wifi_direct_set_group_owner_intent(go_intent); + if(res != WIFI_DIRECT_ERROR_NONE) + { + DBG(LOG_ERROR, "Failed to wifi_direct_set_go_intent(%d). [%d]\n", go_intent, res); + return -1; + } + __FUNC_EXIT__; + return 0; +} + +int wfd_client_get_peers(struct ug_data *ugd) +{ + + if(ugd->wfd_status < WFD_LINK_STATUS_ACTIVATED) + { + ugd->raw_discovered_peer_cnt = 0; + ugd->raw_connected_peer_cnt = 0; + return 0; + } + + if(ugd->wfd_status > WIFI_DIRECT_STATE_ACTIVATING) + { + wfd_ug_get_discovered_peers(ugd); + } + + if(ugd->wfd_status >= WIFI_DIRECT_STATE_CONNECTED) + { + wfd_ug_get_connected_peers(ugd); + } + + wfd_ug_view_update_peers(ugd); + _change_multi_button_title(ugd); + return 0; +} diff --git a/ug-wifidirect/src/wfd_ug.c b/ug-wifidirect/src/wfd_ug.c old mode 100644 new mode 100755 index cfbbf49..9c43fca --- a/ug-wifidirect/src/wfd_ug.c +++ b/ug-wifidirect/src/wfd_ug.c @@ -1,26 +1,21 @@ /* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd -/* - * This file implements Wi-Fi direct UI Gadget. - * - * @file wfd_ug.c - * @author Gibyoung Kim (lastkgb.kim@samsung.com) - * @version 0.1 - */ +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license + +* 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 @@ -40,6 +35,15 @@ #include "wfd_ug_view.h" #include "wfd_client.h" +void initialize_gen_item_class(); + +struct ug_data *global_ugd = NULL; + +struct ug_data *wfd_get_ug_data() +{ + return global_ugd; +} + static Evas_Object *_create_bg(Evas_Object *parent, char *style) { @@ -61,14 +65,15 @@ static Evas_Object *_create_fullview(Evas_Object *parent, struct ug_data *ugd) __FUNC_ENTER__; Evas_Object *base; - if (parent == NULL) + if(parent == NULL) { DBG(LOG_ERROR, "Incorrenct parameter"); return NULL; } + /* Create Full view */ base = elm_layout_add(parent); - if (!base) + if(!base) { DBG(LOG_ERROR, "Failed to add layout"); return NULL; @@ -82,19 +87,20 @@ static Evas_Object *_create_fullview(Evas_Object *parent, struct ug_data *ugd) return base; } -static Evas_Object *_create_frameview(Evas_Object * parent, struct ug_data *ugd) +static Evas_Object *_create_frameview(Evas_Object *parent, struct ug_data *ugd) { __FUNC_ENTER__; Evas_Object *base; - if (parent == NULL) + if(parent == NULL) { DBG(LOG_ERROR, "Incorrenct parameter"); return NULL; } + /* Create Frame view */ base = elm_layout_add(parent); - if (!base) + if(!base) { DBG(LOG_ERROR, "Failed to add layout"); return NULL; @@ -108,11 +114,34 @@ static Evas_Object *_create_frameview(Evas_Object * parent, struct ug_data *ugd) return base; } -static void *on_create(struct ui_gadget *ug, enum ug_mode mode, bundle * data, - void *priv) + +void destroy_wfd_ug_view(void *data) +{ + __FUNC_ENTER__; + + struct ug_data *ugd = (struct ug_data*) data; + + if(ugd->genlist) + { + evas_object_del(ugd->genlist); + ugd->genlist = NULL; + } + + if(ugd->naviframe) + { + evas_object_del(ugd->naviframe); + ugd->naviframe = NULL; + } + + __FUNC_EXIT__; +} + +static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h service, + void *priv) { __FUNC_ENTER__; struct ug_data *ugd; + int res = 0; if (!ug || !priv) return NULL; @@ -122,7 +151,7 @@ static void *on_create(struct ui_gadget *ug, enum ug_mode mode, bundle * data, bindtextdomain(PACKAGE, LOCALEDIR); - ugd->win = ug_get_parent_layout(ug); + ugd->win = ug_get_window(); if (!ugd->win) return NULL; @@ -131,7 +160,7 @@ static void *on_create(struct ui_gadget *ug, enum ug_mode mode, bundle * data, else ugd->base = _create_frameview(ugd->win, ugd); - if (ugd->base) + if(ugd->base) { ugd->bg = _create_bg(ugd->win, "group_list"); elm_object_part_content_set(ugd->base, "elm.swallow.bg", ugd->bg); @@ -144,18 +173,55 @@ static void *on_create(struct ui_gadget *ug, enum ug_mode mode, bundle * data, wfd_get_vconf_status(ugd); + initialize_gen_item_class(); + + res = init_wfd_client(ugd); + if(res != 0) + { + DBG(LOG_ERROR, "Failed to initialize WFD client library\n"); + wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_PROBLEM_WITH_WFD"), POPUP_TYPE_TERMINATE); + } + create_wfd_ug_view(ugd); + + wfd_ug_view_refresh_glitem(ugd->head); + if (ugd->scan_btn) { + wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"), TRUE); + } + + if(ugd->wfd_status > WIFI_DIRECT_STATE_ACTIVATING) + { + wfd_ug_get_discovered_peers(ugd); + } + + if(ugd->wfd_status >= WIFI_DIRECT_STATE_CONNECTED) + { + wfd_ug_get_connected_peers(ugd); + } + + wfd_ug_view_update_peers(ugd); + + if (ugd->wfd_status == WIFI_DIRECT_STATE_ACTIVATED) + { + res = wifi_direct_start_discovery(FALSE, 0); + if(res != WIFI_DIRECT_ERROR_NONE) + { + DBG(LOG_ERROR, "Failed to start discovery. [%d]\n", res); + } + DBG(LOG_VERBOSE, "Discovery is started\n"); + } + evas_object_show(ugd->base); __FUNC_EXIT__; return ugd->base; } -static void on_start(struct ui_gadget *ug, bundle * data, void *priv) +static void on_start(ui_gadget_h ug, service_h service, void *priv) { __FUNC_ENTER__; struct ug_data *ugd; - int res; + int res; if (!ug || !priv) return; @@ -170,39 +236,29 @@ static void on_start(struct ui_gadget *ug, bundle * data, void *priv) } else { - DBG(LOG_VERBOSE, "Node name of this device [%s]\n", kernel_info.nodename); DBG(LOG_VERBOSE, "HW ID of this device [%s]\n", kernel_info.machine); - if(strcmp(kernel_info.nodename, "SLP_PQ") == 0 || - strncmp(kernel_info.machine, "arm", 3) != 0) + if(strncmp(kernel_info.machine, "arm", 3) != 0) { wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_NOT_SUPPORTED_DEVICE"), POPUP_TYPE_TERMINATE); return; } } - - res = init_wfd_client(ugd); - if(res != 0) - { - DBG(LOG_ERROR, "Failed to initialize WFD client library\n"); - wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_PROBLEM_WITH_WFD"), POPUP_TYPE_TERMINATE); - } - __FUNC_EXIT__; } -static void on_pause(struct ui_gadget *ug, bundle * data, void *priv) +static void on_pause(ui_gadget_h ug, service_h service, void *priv) { __FUNC_ENTER__; __FUNC_EXIT__; } -static void on_resume(struct ui_gadget *ug, bundle * data, void *priv) +static void on_resume(ui_gadget_h ug, service_h service, void *priv) { __FUNC_ENTER__; __FUNC_EXIT__; } -static void on_destroy(struct ui_gadget *ug, bundle * data, void *priv) +static void on_destroy(ui_gadget_h ug, service_h service, void *priv) { __FUNC_ENTER__; @@ -223,14 +279,19 @@ static void on_destroy(struct ui_gadget *ug, bundle * data, void *priv) DBG(LOG_VERBOSE, "WFD client deregistered"); destroy_wfd_ug_view(ugd); + DBG(LOG_VERBOSE, "Destroying About item"); + + wfd_ug_view_free_peers(ugd); - if (ugd->bg) + DBG(LOG_VERBOSE, "WFD client deregistered"); + if(ugd->bg) { evas_object_del(ugd->bg); ugd->bg = NULL; } + DBG(LOG_VERBOSE, "WFD client deregistered"); - if (ugd->base) + if(ugd->base) { evas_object_del(ugd->base); ugd->base = NULL; @@ -240,15 +301,15 @@ static void on_destroy(struct ui_gadget *ug, bundle * data, void *priv) return; } -static void on_message(struct ui_gadget *ug, bundle * msg, bundle * data, - void *priv) +static void on_message(ui_gadget_h ug, service_h msg, service_h service, + void *priv) { __FUNC_ENTER__; __FUNC_EXIT__; } -static void on_event(struct ui_gadget *ug, enum ug_event event, bundle * data, - void *priv) +static void on_event(ui_gadget_h ug, enum ug_event event, service_h service, + void *priv) { __FUNC_ENTER__; @@ -260,37 +321,37 @@ static void on_event(struct ui_gadget *ug, enum ug_event event, bundle * data, switch (event) { - case UG_EVENT_LOW_MEMORY: - DBG(LOG_VERBOSE, "UG_EVENT_LOW_MEMORY\n"); - break; - case UG_EVENT_LOW_BATTERY: - DBG(LOG_VERBOSE, "UG_EVENT_LOW_BATTERY\n"); - break; - case UG_EVENT_LANG_CHANGE: - DBG(LOG_VERBOSE, "UG_EVENT_LANG_CHANGE\n"); - break; - case UG_EVENT_ROTATE_PORTRAIT: - DBG(LOG_VERBOSE, "UG_EVENT_ROTATE_PORTRAIT\n"); - break; - case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN: - DBG(LOG_VERBOSE, "UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN\n"); - break; - case UG_EVENT_ROTATE_LANDSCAPE: - DBG(LOG_VERBOSE, "UG_EVENT_ROTATE_LANDSCAPE\n"); - break; - case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN: - DBG(LOG_VERBOSE, "UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN\n"); - break; - default: - DBG(LOG_VERBOSE, "default\n"); - break; + case UG_EVENT_LOW_MEMORY: + DBG(LOG_VERBOSE, "UG_EVENT_LOW_MEMORY\n"); + break; + case UG_EVENT_LOW_BATTERY: + DBG(LOG_VERBOSE, "UG_EVENT_LOW_BATTERY\n"); + break; + case UG_EVENT_LANG_CHANGE: + DBG(LOG_VERBOSE, "UG_EVENT_LANG_CHANGE\n"); + break; + case UG_EVENT_ROTATE_PORTRAIT: + DBG(LOG_VERBOSE, "UG_EVENT_ROTATE_PORTRAIT\n"); + break; + case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN: + DBG(LOG_VERBOSE, "UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN\n"); + break; + case UG_EVENT_ROTATE_LANDSCAPE: + DBG(LOG_VERBOSE, "UG_EVENT_ROTATE_LANDSCAPE\n"); + break; + case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN: + DBG(LOG_VERBOSE, "UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN\n"); + break; + default: + DBG(LOG_VERBOSE, "default\n"); + break; } __FUNC_EXIT__; } -static void on_key_event(struct ui_gadget *ug, enum ug_key_event event, - bundle * data, void *priv) +static void on_key_event(ui_gadget_h ug, enum ug_key_event event, + service_h service, void *priv) { __FUNC_ENTER__; @@ -302,11 +363,11 @@ static void on_key_event(struct ui_gadget *ug, enum ug_key_event event, switch (event) { - case UG_KEY_EVENT_END: - DBG(LOG_VERBOSE, "UG_KEY_EVENT_END\n"); - break; - default: - break; + case UG_KEY_EVENT_END: + DBG(LOG_VERBOSE, "UG_KEY_EVENT_END\n"); + break; + default: + break; } __FUNC_EXIT__; @@ -330,6 +391,8 @@ UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops) return -1; } + global_ugd = ugd; + ops->create = on_create; ops->start = on_start; ops->pause = on_pause; diff --git a/ug-wifidirect/src/wfd_ug_about_view.c b/ug-wifidirect/src/wfd_ug_about_view.c new file mode 100644 index 0000000..5139920 --- /dev/null +++ b/ug-wifidirect/src/wfd_ug_about_view.c @@ -0,0 +1,128 @@ +/* +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd + +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license + +* 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 + +#include +#include + +#include +#include +#include +#include + +#include "wfd_ug.h" +#include "wfd_ug_view.h" +#include "wfd_client.h" + +static Elm_Genlist_Item_Class itc; + +static char *_wfd_gl_label_help_dialogue_get(void *data, Evas_Object *obj, const char *part) +{ + DBG(LOG_VERBOSE, "Adding text"); + + if (!strcmp(part, "elm.text.2")) { + return strdup(IDS_WFD_BODY_ABOUT_WIFI); + } + return NULL; +} + +static Evas_Object *_wfd_gl_help_icon_get(void *data, Evas_Object * obj, const char *part) +{ + __FUNC_ENTER__; + + DBG(LOG_VERBOSE, "Current part: %s\n", part); + Evas_Object *label = NULL; + char content[1024] = {0}; + + label = elm_label_add(obj); + snprintf(content, 1024, "%s", IDS_WFD_BODY_ABOUT_WIFI); + elm_label_line_wrap_set(label, ELM_WRAP_WORD); + elm_object_text_set(label, content); + evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0); + evas_object_size_hint_align_set(label, EVAS_HINT_FILL, 0.0); + evas_object_show(label); + + __FUNC_EXIT__; + return label; +} + +void _about_view_back_btn_cb(void *data, Evas_Object * obj, void *event_info) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + if(!ugd) + { + DBG(LOG_ERROR, "The param is NULL\n"); + return; + } + + elm_naviframe_item_pop(ugd->naviframe); + + __FUNC_EXIT__; + return; +} + +void _wifid_create_about_view(struct ug_data *ugd) +{ + + Evas_Object *back_btn = NULL; + Elm_Object_Item *navi_item = NULL; + Evas_Object *control_bar = NULL; + Elm_Object_Item *item = NULL; + Evas_Object *genlist = NULL; + if(ugd == NULL) + { + DBG(LOG_ERROR, "Incorrect parameter(NULL)"); + return; + } + + genlist = elm_genlist_add(ugd->naviframe); + elm_object_style_set(genlist, "dialogue"); + + DBG(LOG_VERBOSE, "creating about view"); + elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS); +#if 0 + itc.item_style = "multiline/1text"; + itc.func.text_get = _wfd_gl_label_help_dialogue_get; + itc.func.content_get = NULL; +#else + itc.item_style = "1icon"; + itc.func.text_get = NULL; + itc.func.content_get = _wfd_gl_help_icon_get; +#endif + itc.func.state_get = NULL; + itc.func.del = NULL; + back_btn = elm_button_add(ugd->naviframe); + elm_object_style_set(back_btn, "naviframe/back_btn/default"); + evas_object_smart_callback_add(back_btn, "clicked", _about_view_back_btn_cb, (void*) ugd); + elm_object_focus_allow_set(back_btn, EINA_FALSE); + + item = elm_genlist_item_append(genlist, &itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + evas_object_show(genlist); + navi_item = elm_naviframe_item_push(ugd->naviframe, IDS_WFD_TITLE_ABOUT_WIFI, back_btn, NULL, genlist, NULL); + + control_bar = elm_toolbar_add(ugd->naviframe); + elm_toolbar_shrink_mode_set(control_bar, ELM_TOOLBAR_SHRINK_EXPAND); + evas_object_show(control_bar); + elm_object_item_part_content_set(navi_item, "controlbar", control_bar); + +} diff --git a/ug-wifidirect/src/wfd_ug_genlist.c b/ug-wifidirect/src/wfd_ug_genlist.c new file mode 100755 index 0000000..fc5aa93 --- /dev/null +++ b/ug-wifidirect/src/wfd_ug_genlist.c @@ -0,0 +1,802 @@ +/* +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd + +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license + +* 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 + +#include +#include + +#include +#include +#include +#include + +#include "wfd_ug.h" +#include "wfd_ug_view.h" +#include "wfd_client.h" + +Elm_Gen_Item_Class sep_itc; +Elm_Gen_Item_Class sep_itc_end; +Elm_Gen_Item_Class head_itc; +Elm_Gen_Item_Class name_itc; +Elm_Gen_Item_Class title_itc; +Elm_Gen_Item_Class peer_itc; +Elm_Gen_Item_Class noitem_itc; +Elm_Gen_Item_Class help_itc; +Elm_Gen_Item_Class button_itc; + +Elm_Gen_Item_Class title_conn_itc; +Elm_Gen_Item_Class peer_conn_itc; + +Elm_Gen_Item_Class title_busy_itc; +Elm_Gen_Item_Class peer_busy_itc; + +Elm_Gen_Item_Class title_multi_connect_itc; +Elm_Gen_Item_Class peer_multi_connect_itc; + +Elm_Gen_Item_Class title_conn_failed_itc; +Elm_Gen_Item_Class peer_conn_failed_itc; + + +static char *_gl_header_label_get(void *data, Evas_Object * obj, const char *part) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + DBG(LOG_VERBOSE, "%s", part); + + if(data == NULL) + { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return NULL; + } + + if(!strcmp(part, "elm.text.1")) + { + DBG(LOG_VERBOSE, "Current text mode [%d]\n", ugd->head_text_mode); + switch(ugd->head_text_mode) + { + case HEAD_TEXT_TYPE_DIRECT: + case HEAD_TEXT_TYPE_ACTIVATED: + case HEAD_TEXT_TYPE_SCANING: + return strdup(dgettext("sys_string", "IDS_COM_OPT1_WI_FI_DIRECT")); + break; + case HEAD_TEXT_TYPE_DEACTIVATING: + return strdup(_("IDS_WFD_BODY_DEACTIVATING")); // "Deactivating Wi-Fi Direct..." + break; + case HEAD_TEXT_TYPE_ACTIVATING: + return strdup(_("IDS_WFD_BODY_ACTIVATING")); //"Activating Wi-Fi Direct..." + break; + default: + break; + } + } + else if(!strcmp(part, "elm.text.1")) + { + return strdup(dgettext("sys_string", "IDS_COM_OPT1_WI_FI_DIRECT")); + } else if(!strcmp(part, "elm.text.2")) + { + return strdup(ugd->dev_name); + } + + __FUNC_EXIT__; + return NULL; +} + +static Evas_Object *_gl_header_icon_get(void *data, Evas_Object * obj, const char *part) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + Evas_Object *onoff = NULL; + + if(data == NULL) + { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return NULL; + } + + if(ugd->head_text_mode == HEAD_TEXT_TYPE_ACTIVATING || + ugd->head_text_mode == HEAD_TEXT_TYPE_DEACTIVATING) + return NULL; + + DBG(LOG_VERBOSE, "%s", part); + onoff = elm_check_add(obj); + elm_object_style_set(onoff, "on&off"); + elm_check_state_set(onoff, ugd->wfd_onoff); + evas_object_smart_callback_add(onoff, "changed", _wfd_onoff_btn_cb, ugd); + evas_object_show(onoff); + + __FUNC_EXIT__; + + return onoff; +} + + +static char *_gl_name_label_get(void *data, Evas_Object *obj, const char *part) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + if(data == NULL) + { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return NULL; + } + + DBG(LOG_VERBOSE, "%s", part); + + if(!strcmp(part, "elm.text")) + { + return strdup(IDS_WFD_TITLE_ABOUT_WIFI); // "Device name" + } + else if(!strcmp(part, "elm.text.2")) + { + return strdup(ugd->dev_name); + } + + __FUNC_EXIT__; + + return NULL; +} + + +static char *_gl_title_label_get(void *data, Evas_Object *obj, + const char *part) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + if(data == NULL) + { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return NULL; + } + + if (!strcmp(part, "elm.text")) + { + if (ugd->multiconn_view_genlist != NULL) + { + // It's called at Multi connect view... + if(ugd->gl_available_dev_cnt_at_multiconn_view > 0) + return strdup(_("IDS_WFD_BODY_AVAILABLE_DEVICES")); // "Available devices" + else + return strdup(_("IDS_WFD_BODY_WIFI_DIRECT_DEVICES")); // "Wi-Fi Direct devices" + } + else + { + // It's called at Main View + if(ugd->gl_available_peer_cnt > 0) + return strdup(_("IDS_WFD_BODY_AVAILABLE_DEVICES")); // "Available devices" + else + return strdup(_("IDS_WFD_BODY_WIFI_DIRECT_DEVICES")); // "Wi-Fi Direct devices" + } + } + + __FUNC_EXIT__; + + return NULL; +} + +static Evas_Object *_gl_title_content_get(void *data, Evas_Object *obj, const char *part) +{ + Evas_Object *progressbar = NULL; + struct ug_data *ugd = (struct ug_data*) data; + + if (data == NULL) { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return NULL; + } + + if (!strcmp(part, "elm.icon")) { + if (HEAD_TEXT_TYPE_SCANING == ugd->head_text_mode) { + progressbar = elm_progressbar_add(obj); + elm_object_style_set(progressbar, "list_process_small"); + elm_progressbar_horizontal_set(progressbar, EINA_TRUE); + elm_progressbar_pulse(progressbar, EINA_TRUE); + evas_object_show(progressbar); + } else { + return NULL; + } + } + + return progressbar; +} + +static char *_gl_peer_label_get(void *data, Evas_Object * obj, const char *part) +{ + __FUNC_ENTER__; + assertm_if(NULL == obj, "NULL!!"); + assertm_if(NULL == part, "NULL!!"); + + device_type_s *peer = (device_type_s*) data; + char buf[WFD_GLOBALIZATION_STR_LENGTH] = { 0, }; + DBG(LOG_VERBOSE, "%s", part); + if(data == NULL) + { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return NULL; + } + + if (!strcmp(part, "elm.text.1")) + { + __FUNC_EXIT__; + return strdup(peer->ssid); + } + else if (!strcmp(part, "elm.text.2")) + { + switch (peer->conn_status) { + case PEER_CONN_STATUS_DISCONNECTED: + g_strlcpy(buf, IDS_WFD_TAP_TO_CONNECT, + WFD_GLOBALIZATION_STR_LENGTH); + break; + + case PEER_CONN_STATUS_CONNECTING: + g_strlcpy(buf, IDS_WFD_CONNECTING, + WFD_GLOBALIZATION_STR_LENGTH); + break; + + case PEER_CONN_STATUS_CONNECTED: + g_strlcpy(buf, IDS_WFD_CONNECTED, + WFD_GLOBALIZATION_STR_LENGTH); + break; + + case PEER_CONN_STATUS_FAILED_TO_CONNECT: + g_strlcpy(buf, IDS_WFD_FAILED_TO_CONNECT, + WFD_GLOBALIZATION_STR_LENGTH); + break; + + case PEER_CONN_STATUS_WAIT_FOR_CONNECT: + g_strlcpy(buf, IDS_WFD_WAITING_FOR_CONNECT, + WFD_GLOBALIZATION_STR_LENGTH); + break; + + default: + g_strlcpy(buf, IDS_WFD_TAP_TO_CONNECT, + WFD_GLOBALIZATION_STR_LENGTH); + break; + } + } + else + { + __FUNC_EXIT__; + return NULL; + } + + __FUNC_EXIT__; + return strdup(buf); +} + +static Evas_Object *_gl_peer_icon_get(void *data, Evas_Object * obj, const char *part) +{ + __FUNC_ENTER__; + assertm_if(NULL == obj, "NULL!!"); + assertm_if(NULL == part, "NULL!!"); + + device_type_s *peer = (device_type_s*) data; + Evas_Object *icon = NULL; + + if(data == NULL) + { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return NULL; + } + + if(!strcmp(part, "elm.icon.2")) + { + DBG(LOG_VERBOSE, "elm.icon.2 - connection status [%d]\n", peer->conn_status); + if(peer->conn_status == PEER_CONN_STATUS_CONNECTING) + { + icon = elm_progressbar_add(obj); + elm_object_style_set(icon, "list_process"); + elm_progressbar_pulse(icon, EINA_TRUE); + } + else if(peer->conn_status == PEER_CONN_STATUS_CONNECTED) + { +#if 0 + icon = elm_icon_add(obj); + elm_icon_file_set(icon, WFD_ICON_CONNECTED, NULL); +#endif + return NULL; + } + + evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); + elm_icon_resizable_set(icon, 1, 1); + evas_object_show(icon); + } + else if(!strcmp(part, "elm.icon.1")) + { + DBG(LOG_VERBOSE, "elm.icon.1 - category [%d]\n", peer->category); + char *img_path = NULL; + switch(peer->category) + { + case WFD_DEVICE_TYPE_COMPUTER: + if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) { + img_path = WFD_ICON_DEVICE_COMPUTER_CONNECT; + } else { + img_path = WFD_ICON_DEVICE_COMPUTER; + } + break; + case WFD_DEVICE_TYPE_INPUT_DEVICE: + if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) { + img_path = WFD_ICON_DEVICE_INPUT_DEVICE_CONNECT; + } else { + img_path = WFD_ICON_DEVICE_INPUT_DEVICE; + } + break; + case WFD_DEVICE_TYPE_PRINTER: + if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) { + img_path = WFD_ICON_DEVICE_PRINTER_CONNECT; + } else { + img_path = WFD_ICON_DEVICE_PRINTER; + } + break; + case WFD_DEVICE_TYPE_CAMERA: + if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) { + img_path = WFD_ICON_DEVICE_CAMERA_CONNECT; + } else { + img_path = WFD_ICON_DEVICE_CAMERA; + } + break; + case WFD_DEVICE_TYPE_STORAGE: + if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) { + img_path = WFD_ICON_DEVICE_STORAGE_CONNECT; + } else { + img_path = WFD_ICON_DEVICE_STORAGE; + } + break; + case WFD_DEVICE_TYPE_NW_INFRA: + if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) { + img_path = WFD_ICON_DEVICE_NETWORK_INFRA_CONNECT; + } else { + img_path = WFD_ICON_DEVICE_NETWORK_INFRA; + } + break; + case WFD_DEVICE_TYPE_DISPLAYS: + if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) { + img_path = WFD_ICON_DEVICE_DISPLAY_CONNECT; + } else { + img_path = WFD_ICON_DEVICE_DISPLAY; + } + break; + case WFD_DEVICE_TYPE_MM_DEVICES: + if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) { + img_path = WFD_ICON_DEVICE_MULTIMEDIA_DEVICE_CONNECT; + } else { + img_path = WFD_ICON_DEVICE_MULTIMEDIA_DEVICE; + } + break; + case WFD_DEVICE_TYPE_GAME_DEVICES: + if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) { + img_path = WFD_ICON_DEVICE_GAMING_DEVICE_CONNECT; + } else { + img_path = WFD_ICON_DEVICE_GAMING_DEVICE; + } + break; + case WFD_DEVICE_TYPE_TELEPHONE: + if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) { + img_path = WFD_ICON_DEVICE_TELEPHONE_CONNECT; + } else { + img_path = WFD_ICON_DEVICE_TELEPHONE; + } + break; + case WFD_DEVICE_TYPE_AUDIO: + if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) { + img_path = WFD_ICON_DEVICE_AUDIO_DEVICE_CONNECT; + } else { + img_path = WFD_ICON_DEVICE_AUDIO_DEVICE; + } + break; + default: + if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) { + img_path = WFD_ICON_DEVICE_COMPUTER_CONNECT; + } else { + img_path = WFD_ICON_DEVICE_COMPUTER; + } + break; + } + + if(img_path != NULL) + { + icon = elm_icon_add(obj); + elm_icon_file_set(icon, img_path, NULL); + evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); + elm_icon_resizable_set(icon, 1, 1); + evas_object_show(icon); + } + else + { + return NULL; + } + } + + __FUNC_EXIT__; + return icon; +} + + +static char *_gl_noitem_text_get(void *data, Evas_Object * obj, + const char *part) +{ + __FUNC_ENTER__; + + if(data == NULL) + { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return NULL; + } + + __FUNC_EXIT__; + return strdup(IDS_WFD_NOCONTENT); +} + + +static char *_gl_help_label_get(void *data, Evas_Object * obj, const char *part) +{ + __FUNC_ENTER__; + DBG(LOG_VERBOSE, "%s", part); + __FUNC_EXIT__; + return strdup("Help"); +} + + +static Evas_Object *_gl_button_get(void *data, Evas_Object * obj, const char *part) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + + DBG(LOG_VERBOSE, "%s", part); + + ugd->multi_btn = elm_button_add(obj); + + wfd_refresh_wifi_direct_state(ugd); + + if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_COMPLETED) + { + elm_object_text_set(ugd->multi_btn, IDS_WFD_BUTTON_DISCONNECT); + DBG(LOG_VERBOSE, "button: Disconnect\n"); + + // Don't connect "clicked" callback. + return ugd->multi_btn; + } + + if (ugd->wfd_status == WFD_LINK_STATUS_CONNECTING) + { + elm_object_text_set(ugd->multi_btn, IDS_WFD_BUTTON_CANCEL); + DBG(LOG_VERBOSE, "button: Cancel connect\n"); + } + else if (ugd->wfd_status >= WFD_LINK_STATUS_CONNECTED) + { + if (ugd->gl_connected_peer_cnt > 1) + { + elm_object_text_set(ugd->multi_btn, IDS_WFD_BUTTON_DISCONNECT_ALL); + DBG(LOG_VERBOSE, "button: Disconnect All\n"); + } + else + { + elm_object_text_set(ugd->multi_btn, IDS_WFD_BUTTON_DISCONNECT); + DBG(LOG_VERBOSE, "button: Disconnect\n"); + } + } + else + { + elm_object_text_set(ugd->multi_btn, IDS_WFD_BUTTON_MULTI); + DBG(LOG_VERBOSE, "button: Multi connect\n"); + } + + evas_object_smart_callback_add(ugd->multi_btn, "clicked", _wifid_create_multibutton_cb, ugd); + evas_object_show(ugd->multi_btn); + + __FUNC_EXIT__; + + return ugd->multi_btn; +} + + +static char *_gl_conn_dev_title_label_get(void *data, Evas_Object *obj, + const char *part) +{ + __FUNC_ENTER__; + + if(data == NULL) + { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return NULL; + } + + if (!strcmp(part, "elm.text")) + { + return strdup(IDS_WFD_BODY_CONNECTED_DEVICES); + } + + __FUNC_EXIT__; + + return NULL; +} + + +static char *_gl_peer_conn_dev_label_get(void *data, Evas_Object * obj, const char *part) +{ + __FUNC_ENTER__; + assertm_if(NULL == obj, "NULL!!"); + assertm_if(NULL == part, "NULL!!"); + + device_type_s *peer = (device_type_s*) data; + + char buf[WFD_GLOBALIZATION_STR_LENGTH] = { 0, }; + DBG(LOG_VERBOSE, "%s", part); + if(data == NULL) + { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return NULL; + } + + if (!strcmp(part, "elm.text.1")) + { + return strdup(peer->ssid); + } + else + { + g_strlcpy(buf, IDS_WFD_CONNECTED, + WFD_GLOBALIZATION_STR_LENGTH); + __FUNC_EXIT__; + return strdup(buf); + } +} + +static char *_gl_conn_failed_dev_title_label_get(void *data, Evas_Object *obj, + const char *part) +{ + __FUNC_ENTER__; + + if(data == NULL) + { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return NULL; + } + + if (!strcmp(part, "elm.text")) + { + return strdup(IDS_WFD_BODY_FAILED_DEVICES); + } + + __FUNC_EXIT__; + + return NULL; +} + + +static char *_gl_peer_conn_failed_dev_label_get(void *data, Evas_Object * obj, const char *part) +{ + __FUNC_ENTER__; + assertm_if(NULL == obj, "NULL!!"); + assertm_if(NULL == part, "NULL!!"); + + device_type_s *peer = (device_type_s*) data; + + char buf[WFD_GLOBALIZATION_STR_LENGTH] = { 0, }; + DBG(LOG_VERBOSE, "%s", part); + if(data == NULL) + { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return NULL; + } + + if (!strcmp(part, "elm.text.1")) + { + return strdup(peer->ssid); + } + else + { + g_strlcpy(buf, IDS_WFD_FAILED_TO_CONNECT, + WFD_GLOBALIZATION_STR_LENGTH); + __FUNC_EXIT__; + return strdup(buf); + } +} + +static char *_gl_multi_connect_dev_title_label_get(void *data, Evas_Object *obj, + const char *part) +{ + __FUNC_ENTER__; + struct ug_data *ugd = wfd_get_ug_data(); + + if(data == NULL) + { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return NULL; + } + + if (!strcmp(part, "elm.text")) + { + if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS) + return strdup(_("IDS_WFD_BODY_AVAILABLE_DEVICES")); // "Available devices" + else if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_COMPLETED) + return strdup(IDS_WFD_BODY_FAILED_DEVICES); // "Available devices" + } + + __FUNC_EXIT__; + + return NULL; +} + + +static char *_gl_busy_dev_title_label_get(void *data, Evas_Object *obj, + const char *part) +{ + __FUNC_ENTER__; + + if(data == NULL) + { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return NULL; + } + + if (!strcmp(part, "elm.text")) + { + return strdup(IDS_WFD_BODY_BUSY_DEVICES); + } + + __FUNC_EXIT__; + + return NULL; +} + + +static char *_gl_peer_busy_dev_label_get(void *data, Evas_Object * obj, const char *part) +{ + __FUNC_ENTER__; + assertm_if(NULL == obj, "NULL!!"); + assertm_if(NULL == part, "NULL!!"); + device_type_s *peer = (device_type_s*) data; + char buf[WFD_GLOBALIZATION_STR_LENGTH] = { 0, }; + DBG(LOG_VERBOSE, "%s", part); + if(data == NULL) + { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return NULL; + } + DBG(LOG_VERBOSE, "peer->ssid = %s", peer->ssid); + if (!strcmp(part, "elm.text.1")) + { + return strdup(peer->ssid); + } + else + { + g_strlcpy(buf, IDS_WFD_CONNECTED_WITH_OTHER_DEVICE, + WFD_GLOBALIZATION_STR_LENGTH); + __FUNC_EXIT__; + return strdup(buf); + } +} + +static void _gl_peer_del(void *data, Evas_Object * obj) +{ + __FUNC_ENTER__; + assertm_if(NULL == obj, "NULL!!"); + assertm_if(NULL == data, "NULL!!"); + + __FUNC_EXIT__; + return; +} + +void initialize_gen_item_class() +{ + sep_itc.item_style = "dialogue/separator"; + sep_itc.func.text_get = NULL; + sep_itc.func.content_get = NULL; + sep_itc.func.state_get = NULL; + sep_itc.func.del = NULL; + + sep_itc_end.item_style = "dialogue/separator/end"; + sep_itc_end.func.text_get = NULL; + sep_itc_end.func.content_get = NULL; + sep_itc_end.func.state_get = NULL; + sep_itc_end.func.del = NULL; + + head_itc.item_style = "dialogue/2text.1icon.6"; + head_itc.func.text_get = _gl_header_label_get; + head_itc.func.content_get = _gl_header_icon_get; + head_itc.func.state_get = NULL; + + name_itc.item_style = "dialogue/1text"; + name_itc.func.text_get = _gl_name_label_get; + name_itc.func.content_get = NULL; + name_itc.func.state_get = NULL; + name_itc.func.del = NULL; + + title_itc.item_style = "dialogue/title"; + title_itc.func.text_get = _gl_title_label_get; + title_itc.func.content_get = _gl_title_content_get; + title_itc.func.state_get = NULL; + title_itc.func.del = NULL; + + peer_itc.item_style = "dialogue/2text.2icon.3"; + peer_itc.func.text_get = _gl_peer_label_get; + peer_itc.func.content_get = _gl_peer_icon_get; + peer_itc.func.state_get = NULL; + peer_itc.func.del = _gl_peer_del; + + noitem_itc.item_style ="dialogue/1text"; + noitem_itc.func.text_get = _gl_noitem_text_get; + noitem_itc.func.content_get = NULL; + noitem_itc.func.state_get = NULL; + noitem_itc.func.del = NULL; + + help_itc.item_style = "dialogue/1text"; + help_itc.func.text_get = _gl_help_label_get; + help_itc.func.content_get = NULL; + help_itc.func.state_get = NULL; + help_itc.func.del = NULL; + + button_itc.item_style = "1icon"; + button_itc.func.text_get = NULL; + button_itc.func.content_get = _gl_button_get; + button_itc.func.state_get = NULL; + button_itc.func.del = NULL; + + title_conn_itc.item_style = "dialogue/title"; + title_conn_itc.func.text_get = _gl_conn_dev_title_label_get; + title_conn_itc.func.content_get = NULL; + title_conn_itc.func.state_get = NULL; + title_conn_itc.func.del = NULL; + + peer_conn_itc.item_style = "dialogue/2text.2icon.3"; + peer_conn_itc.func.text_get = _gl_peer_conn_dev_label_get; + peer_conn_itc.func.content_get = _gl_peer_icon_get; + peer_conn_itc.func.state_get = NULL; + peer_conn_itc.func.del = _gl_peer_del; + + title_conn_failed_itc.item_style = "dialogue/title"; + title_conn_failed_itc.func.text_get = _gl_conn_failed_dev_title_label_get; + title_conn_failed_itc.func.content_get = NULL; + title_conn_failed_itc.func.state_get = NULL; + title_conn_failed_itc.func.del = NULL; + + peer_conn_failed_itc.item_style = "dialogue/2text.2icon.3"; + peer_conn_failed_itc.func.text_get = _gl_peer_conn_failed_dev_label_get; + peer_conn_failed_itc.func.content_get = _gl_peer_icon_get; + peer_conn_failed_itc.func.state_get = NULL; + peer_conn_failed_itc.func.del = _gl_peer_del; + + title_busy_itc.item_style = "dialogue/title"; + title_busy_itc.func.text_get = _gl_busy_dev_title_label_get; + title_busy_itc.func.content_get = NULL; + title_busy_itc.func.state_get = NULL; + title_busy_itc.func.del = NULL; + + peer_busy_itc.item_style = "dialogue/2text.2icon.3"; + peer_busy_itc.func.text_get = _gl_peer_busy_dev_label_get; + peer_busy_itc.func.content_get = _gl_peer_icon_get; + peer_busy_itc.func.state_get = NULL; + peer_busy_itc.func.del = _gl_peer_del; + + title_multi_connect_itc.item_style = "dialogue/title"; + title_multi_connect_itc.func.text_get = _gl_multi_connect_dev_title_label_get; + title_multi_connect_itc.func.content_get = NULL; + title_multi_connect_itc.func.state_get = NULL; + title_multi_connect_itc.func.del = NULL; + +#if 0 + peer_multi_connect_itc.item_style = "dialogue/2text.2icon.3"; + peer_multi_connect_itc.func.text_get = _gl_peer_label_get; + peer_multi_connect_itc.func.content_get = _gl_peer_icon_get; + peer_multi_connect_itc.func.state_get = NULL; + peer_multi_connect_itc.func.del = _gl_peer_del; +#endif +} diff --git a/ug-wifidirect/src/wfd_ug_main_view.c b/ug-wifidirect/src/wfd_ug_main_view.c new file mode 100755 index 0000000..e502ad6 --- /dev/null +++ b/ug-wifidirect/src/wfd_ug_main_view.c @@ -0,0 +1,1153 @@ +/* +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd + +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license + +* 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 + +#include +#include + +#include +#include +#include +#include + +#include "wfd_ug.h" +#include "wfd_ug_view.h" +#include "wfd_client.h" + +void _wfd_onoff_btn_cb(void *data, Evas_Object *obj, void *event_info); + + +void _back_btn_cb(void *data, Evas_Object * obj, void *event_info) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + if(!ugd) + { + DBG(LOG_ERROR, "The param is NULL\n"); + return; + } + + wfd_ug_view_free_peers(ugd); +#if 0 + bundle *b; + b = bundle_create(); + if(!b) + { + DBG(LOG_ERROR, "Failed to create bundle"); + return; + } + + wfd_refresh_wifi_direct_state(ugd); + if (ugd->wfd_status > WIFI_DIRECT_STATE_CONNECTING) + bundle_add(b, "Connection", "TRUE"); + else + bundle_add(b, "Connection", "FALSE"); + + ug_send_result(ugd->ug, b); + + bundle_free(b); +#else + int ret = -1; + service_h service = NULL; + ret = service_create(&service); + if(ret) + { + DBG(LOG_ERROR, "Failed to create service"); + return; + } + + wfd_refresh_wifi_direct_state(ugd); + if (ugd->wfd_status > WIFI_DIRECT_STATE_CONNECTING) + service_add_extra_data(service, "Connection", "TRUE"); + else + service_add_extra_data(service, "Connection", "FALSE"); + + ug_send_result(ugd->ug, service); + service_destroy(service); +#endif + ug_destroy_me(ugd->ug); + + __FUNC_EXIT__; + return; +} + +void _scan_btn_cb(void *data, Evas_Object * obj, void *event_info) +{ + __FUNC_ENTER__; + + struct ug_data *ugd = (struct ug_data*) data; + Elm_Object_Item *btn = event_info; + char *btn_text = NULL; + + if (NULL == ugd || NULL == btn) { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return; + } + + btn_text = elm_object_item_text_get(btn); + if (0 == strcmp(btn_text, _("IDS_WFD_BUTTON_SCAN"))) { + wfd_refresh_wifi_direct_state(ugd); + DBG(LOG_VERBOSE, "Start discovery again, status: %d\n", ugd->wfd_status); + + /* if connected, show the popup*/ + if (ugd->wfd_status >= WIFI_DIRECT_STATE_CONNECTED) { + wfd_ug_act_popup(ugd, _("IDS_WFD_POP_SCAN_AGAIN"), POP_TYPE_SCAN_AGAIN); + } else if (WIFI_DIRECT_STATE_ACTIVATED == ugd->wfd_status) { + wfd_client_start_discovery(ugd); + } else if (WIFI_DIRECT_STATE_DEACTIVATED == ugd->wfd_status) { + _wfd_onoff_btn_cb(ugd, NULL, NULL); + __FUNC_EXIT__; + return; + } + + if (ugd->scan_btn) { + wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_STOPSCAN"), TRUE); + } + + if (ugd->multi_scan_btn) { + wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_STOPSCAN"), TRUE); + } + } else if (0 == strcmp(btn_text, _("IDS_WFD_BUTTON_STOPSCAN"))) { + DBG(LOG_VERBOSE, "Stop discoverying.\n"); + ugd->wfd_status = WIFI_DIRECT_STATE_ACTIVATED; + wfd_refresh_wifi_direct_state(ugd); + ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT; + wfd_ug_view_refresh_glitem(ugd->head); + wifi_direct_cancel_discovery(); + } + + __FUNC_EXIT__; + return; +} + +Eina_Bool _is_wifi_on() +{ + __FUNC_ENTER__; + int wifi_state; + + vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state); + + if (wifi_state >= VCONFKEY_WIFI_CONNECTED) + { + return TRUE; + } + else + { + return FALSE; + } + __FUNC_EXIT__; +} + +void _wfd_onoff_btn_cb(void *data, Evas_Object *obj, void *event_info) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + wfd_refresh_wifi_direct_state(ugd); + + if(!ugd->wfd_onoff) + { + if(ugd->wfd_status < 0) + { + DBG(LOG_VERBOSE, "bad wfd status\n"); + wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_ACTIVATE_FAIL"), POPUP_TYPE_TERMINATE); + + ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT; + wfd_ug_view_refresh_glitem(ugd->head); + return; + } + DBG(LOG_VERBOSE, "wifi-direct switch on\n"); + ugd->head_text_mode = HEAD_TEXT_TYPE_ACTIVATING; + wfd_client_switch_on(ugd); + } + else + { + if(ugd->wfd_status < 0) + { + DBG(LOG_VERBOSE, "bad wfd status\n"); + wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_DEACTIVATE_FAIL"), POPUP_TYPE_TERMINATE); + + ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT; + wfd_ug_view_refresh_glitem(ugd->head); + return; + } + DBG(LOG_VERBOSE, "wifi-direct switch off\n"); + ugd->head_text_mode = HEAD_TEXT_TYPE_DEACTIVATING; + wfd_client_switch_off(ugd); + } + + wfd_ug_view_refresh_glitem(ugd->head); + + if (ugd->scan_btn) { + wfd_ug_view_refresh_button(ugd->scan_btn, _("IDS_WFD_BUTTON_SCAN"), FALSE); + } + + if (ugd->multi_scan_btn) { + wfd_ug_view_refresh_button(ugd->multi_scan_btn, _("IDS_WFD_BUTTON_SCAN"), FALSE); + } + + + __FUNC_EXIT__; +} + + +static void _gl_header_sel(void *data, Evas_Object *obj, void *event_info) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + Elm_Object_Item *item = (Elm_Object_Item *)event_info; + + if(data == NULL) + { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return; + } + + if(item != NULL) + elm_genlist_item_selected_set(item, EINA_FALSE); + + _wfd_onoff_btn_cb(ugd, NULL, NULL); + + __FUNC_EXIT__; +} + +#if 0 +static Evas_Object *_gl_noitem_icon_get(void *data, Evas_Object * obj, + const char *part) +{ + __FUNC_ENTER__; + Evas_Object *nocontent; + + if(data == NULL) + { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return NULL; + } + +#if 1 // use nocontent + nocontent = elm_layout_add(obj); + if(nocontent == NULL) + { + DBG(LOG_ERROR, "Failed to add nocontent"); + return NULL; + } + elm_layout_theme_set(nocontent, "layout", "nocontents", "unnamed"); + elm_object_part_text_set(nocontent, "elm.text", _("IDS_WFD_BODY_NO_DEVICES")); + evas_object_size_hint_min_set(nocontent, 400, 200); + evas_object_size_hint_max_set(nocontent, 400, 200); + evas_object_resize(nocontent, 400, 200); + + __FUNC_EXIT__; + + return nocontent; +#else // use image + Evas_Object *icon; + icon = elm_icon_add(obj); + elm_icon_file_set(icon, "/opt/ug/res/images/ug-wifi-direct/A09_NoDevice.png", NULL); + evas_object_size_hint_min_set(icon, 400, 200); + evas_object_size_hint_max_set(icon, 400, 200); + evas_object_resize(icon, 400, 200); + + return icon; +#endif +} +#endif + +static void _gl_peer_sel(void *data, Evas_Object *obj, void *event_info) +{ + __FUNC_ENTER__; + assertm_if(NULL == obj, "NULL!!"); + assertm_if(NULL == data, "NULL!!"); + device_type_s *peer = (device_type_s*) data; + Elm_Object_Item *item = (Elm_Object_Item *)event_info; + struct ug_data* ugd = wfd_get_ug_data(); + int res; + + if(data == NULL) + { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return; + } + + if(item != NULL) + elm_genlist_item_selected_set(item, EINA_FALSE); + + if(peer->conn_status == PEER_CONN_STATUS_DISCONNECTED) + { +#if 0 // for new connection during link_status is CONNECTING + wfd_refresh_wifi_direct_state(ugd); + if(ugd->wfd_status == WFD_LINK_STATUS_CONNECTING) + { + res = wfd_client_disconnect(NULL); + if(res != 0) + { + DBG(LOG_ERROR, "Failed to send disconnection request. [%d]\n", res); + return; + } + } +#endif + DBG(LOG_VERBOSE, "Connect with peer [%s]\n", peer->mac_addr); + res = wfd_client_connect((const char*) peer->mac_addr); + if(res != 0) + { + DBG(LOG_ERROR, "Failed to send connection request. [%d]\n", res); + return; + } + peer->conn_status = PEER_CONN_STATUS_CONNECTING; + } + else // PEER_CONN_STATUS_CONNECTED or PEER_CONN_STATUS_CONNECTING) + { + res = wfd_client_disconnect((const char*) peer->mac_addr); + if(res != 0) + { + DBG(LOG_ERROR, "Failed to send disconnection request. [%d]\n", res); + return; + } + peer->conn_status = PEER_CONN_STATUS_DISCONNECTED; + } + + wfd_ug_view_refresh_glitem(peer->gl_item); + wfd_ug_view_refresh_glitem(ugd->multi_button_item); + + __FUNC_EXIT__; + return; +} + +static void _gl_busy_peer_sel(void *data, Evas_Object *obj, void *event_info) +{ + __FUNC_ENTER__; + + struct ug_data *ugd = (struct ug_data*) data; + + elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); + + DBG(LOG_VERBOSE, "Busy device is clicked"); + + wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_WARN_BUSY_DEVICE"), POP_TYPE_BUSY_DEVICE_POPUP); + + __FUNC_EXIT__; +} + +static void _gl_about_wifi_sel(void *data, Evas_Object *obj, void *event_info) +{ + struct ug_data *ugd = (struct ug_data*) data; + + DBG(LOG_VERBOSE, "About wifi clicked"); + + _wifid_create_about_view(ugd); + elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); +} + +void _wifid_create_multibutton_cb(void *data, Evas_Object * obj, void *event_info) +{ + struct ug_data *ugd = (struct ug_data*) data; + const char *text_lbl = NULL; + + text_lbl = elm_object_text_get(ugd->multi_btn); + DBG(LOG_VERBOSE, "text_lbl = %s", text_lbl); + + if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS) + { + ugd->multi_connect_mode = WFD_MULTI_CONNECT_MODE_NONE; + if (0 == strcmp(IDS_WFD_BUTTON_CANCEL, text_lbl)) + { + wfd_ug_act_popup(ugd, _("IDS_WFD_POP_CANCEL_CONNECT"), POP_TYPE_DISCONNECT_ALL); + } + else + { + DBG(LOG_VERBOSE, "Invalid Case\n"); + } + } + else + { + if (0 == strcmp(IDS_WFD_BUTTON_MULTI, text_lbl)) + { + _wifid_create_multiconnect_view(ugd); + } + else if (0 == strcmp(IDS_WFD_BUTTON_CANCEL, text_lbl)) + { + wfd_ug_act_popup(ugd, _("IDS_WFD_POP_CANCEL_CONNECT"), POP_TYPE_DISCONNECT_ALL); + } + else if (0 == strcmp(IDS_WFD_BUTTON_DISCONNECT_ALL, text_lbl)) + { + wfd_ug_act_popup(ugd, _("IDS_WFD_POP_DISCONNECT"), POP_TYPE_DISCONNECT_ALL); + } + else if (0 == strcmp(IDS_WFD_BUTTON_DISCONNECT, text_lbl)) + { + wfd_ug_act_popup(ugd, _("IDS_WFD_POP_DISCONNECT"), POP_TYPE_DISCONNECT); + } + else + { + DBG(LOG_VERBOSE, "Invalid Case\n"); + } + } +} + + +int _change_multi_button_title(void *data) +{ + struct ug_data *ugd = (struct ug_data*) data; + + if(ugd->multi_button_item == NULL) /*Needs to be check as the peer count is not getting updated*/ + { + return -1; + } + + wfd_refresh_wifi_direct_state(ugd); + if (ugd->wfd_status == WFD_LINK_STATUS_CONNECTING) + { + //if (conn_prog_count > 0) + elm_object_text_set(ugd->multi_btn, IDS_WFD_BUTTON_CANCEL); + } + else if (ugd->wfd_status > WFD_LINK_STATUS_CONNECTING) + { + if (ugd->gl_connected_peer_cnt > 1) + elm_object_text_set(ugd->multi_btn, IDS_WFD_BUTTON_DISCONNECT_ALL); + else + elm_object_text_set(ugd->multi_btn, IDS_WFD_BUTTON_DISCONNECT); + } + else + { + elm_object_text_set(ugd->multi_btn, IDS_WFD_BUTTON_MULTI); + } + + evas_object_show(ugd->multi_btn); + + return 0; +} + + +void wfd_ug_view_refresh_glitem(void *obj) +{ + __FUNC_ENTER__; + elm_genlist_item_update(obj); + __FUNC_EXIT__; +} + +void wfd_ug_view_refresh_button(void *obj, const char *text, int enable) +{ + __FUNC_ENTER__; + + if (NULL == obj || NULL == text) { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return; + } + + DBG(LOG_VERBOSE, "Set the attributes of button: text[%s], enabled[%d]\n", text, enable); + elm_object_item_text_set(obj, text); + elm_object_item_disabled_set(obj, !enable); + + __FUNC_EXIT__; +} + +static bool __wfd_is_device_connected_with_me(struct ug_data *ugd, device_type_s *dev) +{ + int i; + + for(i=0; iraw_connected_peer_cnt; i++) + { + if (strncmp(ugd->raw_connected_peers[i].mac_addr, dev->mac_addr, strlen(ugd->raw_connected_peers[i].mac_addr)) == 0) + return TRUE; + } + return FALSE; +} + +static bool __wfd_is_device_busy(struct ug_data *ugd, device_type_s *dev) +{ + if (__wfd_is_device_connected_with_me(ugd, dev) == TRUE) + return FALSE; + + if (ugd->I_am_group_owner == TRUE) + { + if (dev->is_connected || dev->is_group_owner) + return TRUE; + else + return FALSE; + } + else + { + if (dev->is_connected == TRUE && dev->is_group_owner == TRUE) + return FALSE; + if (dev->is_connected == TRUE && dev->is_group_owner == FALSE) + return TRUE; + if (dev->is_connected == FALSE) + return FALSE; + } + + return FALSE; +} + +static bool __wfd_is_any_device_available(struct ug_data *ugd, int* no_of_available_dev) +{ + int i =0 ; + for (i = 0; i < ugd->raw_discovered_peer_cnt; i++) + { + if (!__wfd_is_device_busy(ugd, &ugd->raw_discovered_peers[i]) && + ugd->raw_discovered_peers[i].conn_status == PEER_CONN_STATUS_DISCONNECTED) + (*no_of_available_dev)++; + } + return TRUE; +} + +static bool __wfd_is_any_device_busy(struct ug_data *ugd, int* no_of_busy_dev) +{ + int i =0 ; + for (i = 0; i < ugd->raw_discovered_peer_cnt; i++) + { + if (__wfd_is_device_busy(ugd, &ugd->raw_discovered_peers[i])) + (*no_of_busy_dev)++; + } + return TRUE; +} + +static bool __wfd_is_any_device_connect_failed(struct ug_data *ugd, int* no_of_connect_failed_dev) +{ + int i =0 ; + for (i = 0; i < ugd->raw_discovered_peer_cnt; i++) + { + if (!__wfd_is_device_busy(ugd, &ugd->raw_discovered_peers[i]) && + ugd->raw_discovered_peers[i].conn_status == PEER_CONN_STATUS_FAILED_TO_CONNECT) + (*no_of_connect_failed_dev)++; + + } + return TRUE; +} + +static Evas_Object *_create_basic_genlist(void *data) +{ + __FUNC_ENTER__; + + struct ug_data *ugd = (struct ug_data*) data; + Evas_Object *genlist; + Elm_Object_Item *separator_item; + + + genlist = elm_genlist_add(ugd->naviframe); + + + separator_item = elm_genlist_item_append(genlist, &sep_itc, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(separator_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + ugd->head = elm_genlist_item_append(genlist, &head_itc, ugd, NULL, ELM_GENLIST_ITEM_NONE, _gl_header_sel, (void*) ugd); + + //elm_genlist_item_select_mode_set(ugd->head, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + __FUNC_EXIT__; + + return genlist; +} + +static Evas_Object *_create_about_genlist(void *data) +{ + __FUNC_ENTER__; + + struct ug_data *ugd = (struct ug_data*) data; + + ugd->about_wfd_item = elm_genlist_item_append(ugd->genlist, &name_itc, ugd, NULL, ELM_GENLIST_ITEM_NONE, _gl_about_wifi_sel, (void*) ugd); + + /* add end separator */ + ugd->about_wfdsp_sep_end_item = elm_genlist_item_append(ugd->genlist, &sep_itc_end, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(ugd->about_wfdsp_sep_end_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + __FUNC_EXIT__; + + return ugd->genlist; +} + +static Evas_Object *_create_no_device_genlist(void *data) +{ + __FUNC_ENTER__; + + struct ug_data *ugd = (struct ug_data*) data; + + ugd->nodevice_title_item = elm_genlist_item_append(ugd->genlist, &title_itc, (void*)ugd, NULL, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + + ugd->nodevice_item = elm_genlist_item_append(ugd->genlist, &noitem_itc, (void*)ugd, NULL, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + + ugd->nodevice_sep_low_item = elm_genlist_item_append(ugd->genlist, &sep_itc, NULL, NULL, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + + elm_genlist_item_select_mode_set(ugd->nodevice_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + __FUNC_EXIT__; + return ugd->genlist; +} + +int _create_multi_button_genlist(void *data) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + ugd->multi_button_sep_high_item = elm_genlist_item_append(ugd->genlist, &sep_itc, NULL, NULL, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + + /* if not connected and number of devices is less than 2, don't show the button */ + if (ugd->raw_multi_selected_peer_cnt > 1 || + ugd->gl_available_peer_cnt > 1 || + ugd->gl_connected_peer_cnt > 0) { + ugd->multi_button_item = elm_genlist_item_append(ugd->genlist, &button_itc, ugd, NULL, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + ugd->multi_button_sep_low_item = elm_genlist_item_append(ugd->genlist, &sep_itc, NULL, NULL, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + } + + evas_object_show(ugd->multi_btn); + __FUNC_EXIT__; + return 0; +} + + +int _create_busy_dev_list(void *data) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + ugd->busy_wfd_item = elm_genlist_item_append(ugd->genlist, &title_busy_itc, (void*)ugd, NULL, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + + elm_genlist_item_select_mode_set(ugd->busy_wfd_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + + __FUNC_EXIT__; + return 0; +} + +static int _create_available_dev_genlist(void *data) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + ugd->avlbl_wfd_item = elm_genlist_item_append(ugd->genlist, &title_itc, (void*)ugd, NULL, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + + // elm_genlist_item_select_mode_set(ugd->avlbl_wfd_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + __FUNC_EXIT__; + return 0; +} + +static int _create_multi_connect_dev_genlist(void *data) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + ugd->multi_connect_wfd_item = elm_genlist_item_append(ugd->genlist, &title_multi_connect_itc, (void*)ugd, NULL, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + + // elm_genlist_item_select_mode_set(ugd->avlbl_wfd_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + __FUNC_EXIT__; + return 0; +} + +int _create_connected_dev_genlist(void *data) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + ugd->conn_wfd_item = elm_genlist_item_append(ugd->genlist, &title_conn_itc, (void*)ugd, NULL, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + + elm_genlist_item_select_mode_set(ugd->conn_wfd_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + __FUNC_EXIT__; + return 0; +} + +int _create_connected_failed_dev_genlist(void *data) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + ugd->conn_failed_wfd_item = elm_genlist_item_append(ugd->genlist, &title_conn_failed_itc, (void*)ugd, NULL, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + + elm_genlist_item_select_mode_set(ugd->conn_failed_wfd_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + __FUNC_EXIT__; + return 0; +} + +static Eina_Bool _connect_failed_peers_display_cb(void *user_data) +{ + int interval = 0; + struct ug_data *ugd = (struct ug_data*) user_data; + + if (NULL == ugd) { + DBG(LOG_ERROR, "NULL parameters.\n"); + return ECORE_CALLBACK_CANCEL; + } + + /* check the timeout, if not timeout, keep the cb */ + interval = time(NULL) - ugd->last_display_time; + if (interval < MAX_DISPLAY_TIME_OUT) { + return ECORE_CALLBACK_RENEW; + } + + /* re-discovery */ + wfd_client_start_discovery(ugd); + + /* get peers and update the view */ + wfd_ug_get_discovered_peers(ugd); + wfd_ug_get_connected_peers(ugd); + wfd_ug_view_update_peers(ugd); + + return ECORE_CALLBACK_CANCEL; +} + +void wfd_ug_view_free_peers(void *data) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + int i; + + for(i = 0; i < ugd->gl_connected_peer_cnt; i++) + { + DBG(LOG_VERBOSE, "%dth connected peer = %x is deleted\n", i, ugd->gl_connected_peers[i]); + if (ugd->gl_connected_peers[i].gl_item != NULL) + { + elm_object_item_del(ugd->gl_connected_peers[i].gl_item); + ugd->gl_connected_peers[i].gl_item = NULL; + DBG(LOG_VERBOSE, "Deleted item\n"); + } + } + ugd->gl_connected_peer_cnt = 0; + + for(i = 0; i < ugd->gl_connected_failed_peer_cnt; i++) + { + DBG(LOG_VERBOSE, "%dth connected failed peer = %x is deleted\n", i, ugd->gl_connected_failed_peers[i]); + if (ugd->gl_connected_failed_peers[i].gl_item != NULL) + { + elm_object_item_del(ugd->gl_connected_failed_peers[i].gl_item); + ugd->gl_connected_failed_peers[i].gl_item = NULL; + DBG(LOG_VERBOSE, "Deleted item\n"); + } + } + + ugd->gl_connected_failed_peer_cnt = 0; + + for(i = 0; i < ugd->gl_available_peer_cnt; i++) + { + DBG(LOG_VERBOSE, "%dth discovered peer = %x is deleted\n", i, ugd->gl_available_peers[i]); + if (ugd->gl_available_peers[i].gl_item != NULL) + { + elm_object_item_del(ugd->gl_available_peers[i].gl_item); + ugd->gl_available_peers[i].gl_item = NULL; + DBG(LOG_VERBOSE, "Deleted item\n"); + } + } + ugd->gl_available_peer_cnt = 0; + + for(i = 0; i < ugd->gl_busy_peer_cnt; i++) + { + DBG(LOG_VERBOSE, "%dth busy peer = %x is deleted\n", i, ugd->gl_busy_peers[i]); + if (ugd->gl_busy_peers[i].gl_item != NULL) + { + elm_object_item_del(ugd->gl_busy_peers[i].gl_item); + ugd->gl_busy_peers[i].gl_item = NULL; + DBG(LOG_VERBOSE, "Deleted item\n"); + } + } + ugd->gl_busy_peer_cnt = 0; + + for(i = 0; i < ugd->gl_multi_connect_peer_cnt; i++) + { + DBG(LOG_VERBOSE, "%dth busy peer = %x is deleted\n", i, ugd->gl_multi_connect_peers[i]); + if (ugd->gl_multi_connect_peers[i].gl_item != NULL) + { + elm_object_item_del(ugd->gl_multi_connect_peers[i].gl_item); + ugd->gl_multi_connect_peers[i].gl_item = NULL; + DBG(LOG_VERBOSE, "Deleted item\n"); + } + } + ugd->gl_multi_connect_peer_cnt = 0; + + if(ugd->nodevice_title_item != NULL) + { + elm_object_item_del(ugd->nodevice_title_item); + ugd->nodevice_title_item = NULL; + } + if(ugd->nodevice_item != NULL) + { + elm_object_item_del(ugd->nodevice_item); + ugd->nodevice_item = NULL; + } + if(ugd->nodevice_sep_low_item != NULL) + { + elm_object_item_del(ugd->nodevice_sep_low_item); + ugd->nodevice_sep_low_item = NULL; + } + if(ugd->about_wfd_item != NULL) + { + elm_object_item_del(ugd->about_wfd_item); + ugd->about_wfd_item = NULL; + } + + if(ugd->conn_wfd_item != NULL) + { + elm_object_item_del(ugd->conn_wfd_item); + ugd->conn_wfd_item = NULL; + } + if(ugd->conn_failed_wfd_item != NULL) + { + elm_object_item_del(ugd->conn_failed_wfd_item); + ugd->conn_failed_wfd_item = NULL; + } + if(ugd->conn_failed_wfd_sep_item != NULL) + { + elm_object_item_del(ugd->conn_failed_wfd_sep_item); + ugd->conn_failed_wfd_sep_item = NULL; + } + if(ugd->display_timer != NULL) + { + elm_object_item_del(ugd->display_timer); + ugd->display_timer = NULL; + } + if(ugd->multi_connect_wfd_item != NULL) + { + elm_object_item_del(ugd->multi_connect_wfd_item); + ugd->multi_connect_wfd_item = NULL; + } + if(ugd->avlbl_wfd_item != NULL) + { + elm_object_item_del(ugd->avlbl_wfd_item); + ugd->avlbl_wfd_item = NULL; + } + if(ugd->busy_wfd_item != NULL) + { + elm_object_item_del(ugd->busy_wfd_item); + ugd->busy_wfd_item = NULL; + } + if(ugd->busy_wfd_sep_item != NULL) + { + elm_object_item_del(ugd->busy_wfd_sep_item); + ugd->busy_wfd_sep_item = NULL; + } + + if(ugd->multi_button_item != NULL) + { + elm_object_item_del(ugd->multi_button_item); + ugd->multi_button_item = NULL; + } + if(ugd->multi_button_sep_high_item != NULL) + { + elm_object_item_del(ugd->multi_button_sep_high_item); + ugd->multi_button_sep_high_item = NULL; + } + if(ugd->multi_button_sep_low_item != NULL) + { + elm_object_item_del(ugd->multi_button_sep_low_item); + ugd->multi_button_sep_low_item = NULL; + } + if(ugd->about_wfdsp_sep_end_item != NULL) + { + elm_object_item_del(ugd->about_wfdsp_sep_end_item); + ugd->about_wfdsp_sep_end_item = NULL; + } + + __FUNC_EXIT__; +} + + +void wfd_ug_view_update_peers(void *data) +{ + __FUNC_ENTER__; + + struct ug_data *ugd = (struct ug_data*) data; + int no_of_busy_dev = 0; + int no_of_available_dev = 0; + int no_of_conn_dev = 0; + int no_of_conn_failed_dev = 0; + int i = 0 ; + int res = 0; + bool is_group_owner = FALSE; + int count = 0; + + wfd_ug_view_free_peers(ugd); + + if(ugd->wfd_status == WFD_LINK_STATUS_DEACTIVATED) + { + DBG(LOG_VERBOSE, "Device is deactivated, no need to update UI."); + // Add seperator... + ugd->multi_button_sep_high_item = elm_genlist_item_append(ugd->genlist, &sep_itc, NULL, NULL, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + _create_about_genlist(ugd); + return; + } + + res = wifi_direct_is_group_owner(&is_group_owner); + if (res != WIFI_DIRECT_ERROR_NONE) + { + DBG(LOG_VERBOSE, "Fail to get group_owner_state. ret=[%d]", res); + ugd->I_am_group_owner = FALSE; + // continue... + } + else + { + ugd->I_am_group_owner = is_group_owner; + } + + __wfd_is_any_device_busy(ugd, &no_of_busy_dev); + __wfd_is_any_device_available(ugd, &no_of_available_dev); + __wfd_is_any_device_connect_failed(ugd, &no_of_conn_failed_dev); + no_of_conn_dev = ugd->raw_connected_peer_cnt; + + ugd->gl_available_peer_cnt = no_of_available_dev; + ugd->gl_connected_peer_cnt = no_of_conn_dev; + ugd->gl_connected_failed_peer_cnt = no_of_conn_failed_dev; + ugd->gl_busy_peer_cnt = no_of_busy_dev; + + DBG(LOG_VERBOSE, "conn_dev=[%d], conn_failed_dev=[%d], avail_dev=[%d], busy_dev=[%d], GO=[%d]\n", + no_of_conn_dev, no_of_conn_failed_dev, no_of_available_dev, no_of_busy_dev, is_group_owner); + + if (no_of_conn_dev == 0 && no_of_conn_failed_dev == 0 && + no_of_available_dev == 0 && no_of_busy_dev == 0) + { + DBG(LOG_ERROR, "There are No peers\n"); + _create_no_device_genlist(ugd); + _create_about_genlist(ugd); + return; + } + + if (no_of_conn_dev > 0) + { + if (!ugd->conn_wfd_item) + _create_connected_dev_genlist(ugd); + + count = 0; + for(i = 0; i < ugd->raw_connected_peer_cnt; i++) + { + if (ugd->gl_connected_peers[count].gl_item) + elm_object_item_del(ugd->gl_connected_peers[count].gl_item); + + memcpy(&ugd->gl_connected_peers[count], &ugd->raw_connected_peers[i], sizeof(device_type_s)); + + ugd->gl_connected_peers[count].gl_item = + elm_genlist_item_append(ugd->genlist, &peer_conn_itc, (void*) &(ugd->gl_connected_peers[i]), NULL, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(ugd->gl_connected_peers[count].gl_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + count++; + } + } + + if (ugd->multi_connect_mode != WFD_MULTI_CONNECT_MODE_NONE) + { + if (ugd->raw_multi_selected_peer_cnt > 0) + { + if (ugd->avlbl_wfd_item == NULL) + _create_multi_connect_dev_genlist(ugd); + + count = 0; + for (i = 0; i < ugd->raw_multi_selected_peer_cnt; i++) + { + if (ugd->raw_multi_selected_peers[i].conn_status != PEER_CONN_STATUS_CONNECTED) + { + if (ugd->gl_multi_connect_peers[count].gl_item) + elm_object_item_del(ugd->gl_multi_connect_peers[count].gl_item); + + memcpy(&ugd->gl_multi_connect_peers[count], &ugd->raw_multi_selected_peers[i], sizeof(device_type_s)); + + ugd->gl_multi_connect_peers[count].gl_item = + elm_genlist_item_append(ugd->genlist, &peer_itc, (void*) &(ugd->gl_multi_connect_peers[count]), NULL, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + count++; + } + else + { + // device is connected.. + // skip it... + } + } + ugd->gl_multi_connect_peer_cnt = count; + } + + _create_multi_button_genlist(ugd); + } + else + { + // Note that + // If GC, no display available peers + // Otherwise, display available peers +#if 0 + if (no_of_available_dev > 0 && (no_of_conn_dev == 0 || is_group_owner==TRUE)) +#else + // display available peers + if (no_of_available_dev > 0) +#endif + { + if (ugd->avlbl_wfd_item == NULL) + _create_available_dev_genlist(ugd); + + count = 0; + for (i = 0; i < ugd->raw_discovered_peer_cnt; i++) + { + if (!__wfd_is_device_busy(ugd, &ugd->raw_discovered_peers[i]) && + ugd->raw_discovered_peers[i].conn_status == PEER_CONN_STATUS_DISCONNECTED) + { + if (ugd->gl_available_peers[count].gl_item) + elm_object_item_del(ugd->gl_available_peers[count].gl_item); + + memcpy(&ugd->gl_available_peers[count], &ugd->raw_discovered_peers[i], sizeof(device_type_s)); + + ugd->gl_available_peers[count].gl_item = + elm_genlist_item_append(ugd->genlist, &peer_itc, (void*) &(ugd->gl_available_peers[count]), NULL, + ELM_GENLIST_ITEM_NONE, _gl_peer_sel, (void*) &(ugd->gl_available_peers[count])); + count++; + } + else + { + // device is busy or connected.. + // skip it... + } + } + } + + _create_multi_button_genlist(ugd); + + // If connected, not display busy device... + if (no_of_conn_dev == 0 && no_of_busy_dev > 0) + { + if (ugd->busy_wfd_item == NULL) + _create_busy_dev_list(ugd); + + count = 0; + for (i = 0; i < ugd->raw_discovered_peer_cnt; i++) + { + if (__wfd_is_device_busy(ugd, &ugd->raw_discovered_peers[i]) == TRUE) + { + if (ugd->gl_busy_peers[count].gl_item) + elm_object_item_del(ugd->gl_busy_peers[count].gl_item); + + memcpy(&ugd->gl_busy_peers[count], &ugd->raw_discovered_peers[i], sizeof(device_type_s)); + + ugd->gl_busy_peers[count].gl_item = + elm_genlist_item_append(ugd->genlist, &peer_busy_itc, (void*) &(ugd->gl_busy_peers[count]), NULL, + ELM_GENLIST_ITEM_NONE, _gl_busy_peer_sel, ugd); + //elm_genlist_item_select_mode_set(ugd->gl_busy_peers[count].gl_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + count++; + } + else + { + // device is available or connected.. + // skip it... + } + } + ugd->busy_wfd_sep_item = elm_genlist_item_append(ugd->genlist, &sep_itc, NULL, NULL, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + } + + /* display connect failed peers */ + if (no_of_conn_failed_dev > 0) + { + if (!ugd->conn_failed_wfd_item) + _create_connected_failed_dev_genlist(ugd); + + /* add timer for disappearing failed peers after N secs */ + if (NULL == ugd->display_timer) { + ugd->last_display_time = time(NULL); + ugd->display_timer = ecore_timer_add(5.0, (Ecore_Task_Cb)_connect_failed_peers_display_cb, ugd); + } + + count = 0; + for (i = 0; i < ugd->raw_discovered_peer_cnt; i++) + { + if (!__wfd_is_device_busy(ugd, &ugd->raw_discovered_peers[i]) && + ugd->raw_discovered_peers[i].conn_status == PEER_CONN_STATUS_FAILED_TO_CONNECT) + { + if (ugd->gl_connected_failed_peers[count].gl_item) + elm_object_item_del(ugd->gl_connected_failed_peers[count].gl_item); + + memcpy(&ugd->gl_connected_failed_peers[count], &ugd->raw_discovered_peers[i], sizeof(device_type_s)); + + ugd->gl_connected_failed_peers[count].gl_item = + elm_genlist_item_append(ugd->genlist, &peer_conn_failed_itc, (void*) &(ugd->gl_connected_failed_peers[count]), NULL, + ELM_GENLIST_ITEM_NONE, NULL, ugd); + elm_genlist_item_select_mode_set(ugd->gl_connected_failed_peers[count].gl_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + count++; + } + } + + ugd->conn_failed_wfd_sep_item = elm_genlist_item_append(ugd->genlist, &sep_itc, NULL, NULL, + ELM_GENLIST_ITEM_NONE, NULL, NULL); + + } + } + _create_about_genlist(ugd); + + __FUNC_EXIT__; +} + + +void create_wfd_ug_view(void *data) +{ + __FUNC_ENTER__; + + struct ug_data *ugd = (struct ug_data*) data; + Evas_Object *back_btn = NULL; + Elm_Object_Item *navi_item = NULL; + Evas_Object *control_bar = NULL; + Elm_Object_Item *item = NULL; + + if(ugd == NULL) + { + DBG(LOG_ERROR, "Incorrect parameter(NULL)"); + return; + } + + ugd->naviframe = elm_naviframe_add(ugd->base); + elm_object_part_content_set(ugd->base, "elm.swallow.content", ugd->naviframe); + evas_object_show(ugd->naviframe); + + back_btn = elm_button_add(ugd->naviframe); + elm_object_style_set(back_btn, "naviframe/back_btn/default"); + evas_object_smart_callback_add(back_btn, "clicked", _back_btn_cb, (void*) ugd); + elm_object_focus_allow_set(back_btn, EINA_FALSE); + + + ugd->genlist = _create_basic_genlist(ugd); + if(ugd->genlist == NULL) + { + DBG(LOG_ERROR, "Failed to create basic genlist"); + return; + } + elm_object_style_set (ugd->genlist, "dialogue"); + evas_object_show(ugd->genlist); + wfd_refresh_wifi_direct_state(ugd); + if (ugd->wfd_status > WIFI_DIRECT_STATE_ACTIVATING) + ugd->wfd_onoff = TRUE; + + navi_item = elm_naviframe_item_push(ugd->naviframe, _("IDS_WFD_HEADER_WIFI_DIRECT"), back_btn, NULL, ugd->genlist, NULL); // dgettext("sys_string", "IDS_COM_OPT1_WI_FI_DIRECT") + + control_bar = elm_toolbar_add(ugd->naviframe); + elm_toolbar_shrink_mode_set(control_bar, ELM_TOOLBAR_SHRINK_EXPAND); + evas_object_show(control_bar); + + ugd->scan_btn = elm_toolbar_item_append(control_bar, NULL, _("IDS_WFD_BUTTON_SCAN"), _scan_btn_cb, (void*) ugd); + item = elm_toolbar_item_append(control_bar, NULL, NULL, NULL, NULL); + elm_object_item_disabled_set(item, EINA_TRUE); + + elm_object_item_disabled_set(ugd->scan_btn, !ugd->wfd_onoff); + + elm_object_item_part_content_set(navi_item, "controlbar", control_bar); + + __FUNC_EXIT__; +} diff --git a/ug-wifidirect/src/wfd_ug_multiconnect_view.c b/ug-wifidirect/src/wfd_ug_multiconnect_view.c new file mode 100755 index 0000000..aea5ce5 --- /dev/null +++ b/ug-wifidirect/src/wfd_ug_multiconnect_view.c @@ -0,0 +1,695 @@ +/* +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd + +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license + +* 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 + +#include +#include + +#include +#include +#include +#include + +#include "wfd_ug.h" +#include "wfd_ug_view.h" +#include "wfd_client.h" + +Elm_Gen_Item_Class select_all_itc; +Elm_Gen_Item_Class device_itc; + + +void _multiconnect_view_back_btn_cb(void *data, Evas_Object * obj, void *event_info) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + if(!ugd) + { + DBG(LOG_ERROR, "The param is NULL\n"); + return; + } + + ugd->multiconn_view_genlist = NULL; + elm_naviframe_item_pop(ugd->naviframe); + + __FUNC_EXIT__; + return; +} + +void reset_multi_conn_dev_list(void *data) +{ + struct ug_data *ugd = (struct ug_data*) data; + int i; + for (i = 0; i < MAX_PEER_NUM; i++) + { + ugd->multi_conn_dev_list[i].dev_sel_state = FALSE; + ugd->multi_conn_dev_list[i].peer.gl_item = NULL; + } + ugd->gl_available_dev_cnt_at_multiconn_view = 0; +} + +gboolean __wfd_multi_connect_reset_cb(void *data) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + ugd->multi_connect_mode = WFD_MULTI_CONNECT_MODE_NONE; + ugd->raw_multi_selected_peer_cnt = 0; + wfd_ug_view_update_peers(ugd); + + __FUNC_EXIT__; + return false; +} + +int wfd_stop_multi_connect(void *data) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + ugd->multi_connect_mode = WFD_MULTI_CONNECT_MODE_COMPLETED; + wfd_client_set_p2p_group_owner_intent(7); + + g_timeout_add(1000 /*ms*/, __wfd_multi_connect_reset_cb, ugd); + + __FUNC_EXIT__; + return 0; +} + +int wfd_start_multi_connect(void* data) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + int i; + int res; + + if (ugd->raw_multi_selected_peer_cnt > 0) + { + ugd->multi_connect_mode = WFD_MULTI_CONNECT_MODE_IN_PROGRESS; + if (wfd_client_set_p2p_group_owner_intent(15) == WIFI_DIRECT_ERROR_NONE) + { + for (i=0;iraw_multi_selected_peer_cnt; i++) + { + res = wfd_client_connect(ugd->raw_multi_selected_peers[i].mac_addr); + if (res == -1) + { + DBG(LOG_VERBOSE, "Failed to connect [%s].\n", ugd->raw_multi_selected_peers[i].ssid); + ugd->raw_multi_selected_peers[i].conn_status = PEER_CONN_STATUS_FAILED_TO_CONNECT; + } + else + { + ugd->raw_multi_selected_peers[i].conn_status = PEER_CONN_STATUS_CONNECTING; + break; + } + } + + if (i >= ugd->raw_multi_selected_peer_cnt) + { + wfd_client_set_p2p_group_owner_intent(7); + + DBG(LOG_VERBOSE, "All connect trails are failed.\n"); + return -1; + } + } + else + { + // error popup... + DBG(LOG_VERBOSE, "Setting GO intent is failed.\n"); + return -1; + } + + } + else + { + DBG(LOG_VERBOSE, "No selected peers.\n"); + return -1; + } + + __FUNC_EXIT__; + return 0; +} + +gboolean wfd_multi_connect_next_cb(void* data) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + int i; + int res; + + // Reset g_source handler.. + ugd->g_source_multi_connect_next = 0; + + if (ugd->raw_multi_selected_peer_cnt > 0) + { + ugd->multi_connect_mode = WFD_MULTI_CONNECT_MODE_IN_PROGRESS; + for (i=0;iraw_multi_selected_peer_cnt; i++) + { + if (ugd->raw_multi_selected_peers[i].conn_status == PEER_CONN_STATUS_WAIT_FOR_CONNECT) + { + res = wfd_client_connect(ugd->raw_multi_selected_peers[i].mac_addr); + if (res == -1) + { + DBG(LOG_VERBOSE, "Failed to connect [%s].\n", ugd->raw_multi_selected_peers[i].ssid); + ugd->raw_multi_selected_peers[i].conn_status = PEER_CONN_STATUS_FAILED_TO_CONNECT; + } + else + { + ugd->raw_multi_selected_peers[i].conn_status = PEER_CONN_STATUS_CONNECTING; + break; + } + } + } + + if (i >= ugd->raw_multi_selected_peer_cnt) + { + // All selected peers are touched. + DBG(LOG_VERBOSE, "Stop Multi Connect...\n"); + wfd_stop_multi_connect(ugd); + } + } + else + { + DBG(LOG_VERBOSE, "No selected peers.\n"); + return -1; + } + + __FUNC_EXIT__; + return false; +} + + +void _connect_btn_cb(void *data, Evas_Object * obj, void *event_info) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + int i = 0; + int count = 0; + char popup_text[MAX_POPUP_TEXT_SIZE] = {0}; + DBG(LOG_VERBOSE, "_connect_btn_cb \n"); + + for (i = 0; i < ugd->gl_available_peer_cnt ; i++) + { + if (TRUE == ugd->multi_conn_dev_list[i].dev_sel_state) + { + DBG(LOG_VERBOSE, "ugd->peers[i].mac_addr = %s, i = %d\n", ugd->multi_conn_dev_list[i].peer.mac_addr, i); + + memcpy(&ugd->raw_multi_selected_peers[count], &ugd->multi_conn_dev_list[i].peer,sizeof(device_type_s)); + ugd->raw_multi_selected_peers[count].conn_status = PEER_CONN_STATUS_WAIT_FOR_CONNECT; + count++; + } + } + + ugd->raw_multi_selected_peer_cnt = count; + + /* if more than 7 device selected, show the popup */ + if (count > MAX_POPUP_PEER_NUM) { + snprintf(popup_text, MAX_POPUP_TEXT_SIZE, _("IDS_WFD_POP_MULTI_CONNECT"), count); + wfd_ug_warn_popup(ugd, popup_text, POP_TYPE_MULTI_CONNECT_POPUP); + } + + if (wfd_start_multi_connect(ugd) != -1) + { + wfd_ug_view_update_peers(ugd); + } + + elm_naviframe_item_pop(ugd->naviframe); + + //ToDo: Do we need to free multiconn_view_genlist? + ugd->multiconn_view_genlist = NULL; + _change_multi_button_title(ugd); + + __FUNC_EXIT__; + return; +} + + + +static void _wfd_gl_multi_sel_cb(void *data, Evas_Object *obj, void *event_info) +{ + __FUNC_ENTER__; + + int i = 0; + int index = 0; + int sel_count = 0; + bool is_sel = FALSE; + bool is_selct_all = TRUE; + Eina_Bool state = 0; + Evas_Object *chk_box = NULL; + char msg[MAX_POPUP_TEXT_SIZE] = {0}; + struct ug_data *ugd = (struct ug_data*) data; + Elm_Object_Item *item = (Elm_Object_Item *)event_info; + + if (NULL == ugd || NULL == item) { + DBG(LOG_ERROR, "The param is NULL\n"); + return; + } + + elm_genlist_item_selected_set(item, EINA_FALSE); + index = elm_genlist_item_index_get(item) - 3; /* subtract the previous items */ + DBG(LOG_VERBOSE, "selected index = %d \n", index); + if (index < 0) { + DBG(LOG_ERROR, "The index is invalid.\n"); + return; + } + + chk_box = elm_object_item_part_content_get((Elm_Object_Item *)event_info, "elm.icon.1"); + state = elm_check_state_get(chk_box); + DBG(LOG_VERBOSE, "state = %d \n", state); + elm_check_state_set(chk_box, !state); + + ugd->multi_conn_dev_list[index].dev_sel_state = !state; + DBG(LOG_VERBOSE, "ptr->dev_sel_state = %d \n", ugd->multi_conn_dev_list[index].dev_sel_state); + DBG(LOG_VERBOSE, "ptr->peer.mac_addr = %s \n", ugd->multi_conn_dev_list[index].peer.mac_addr); + + /* update the checkbox and button */ + for (; i < ugd->gl_available_dev_cnt_at_multiconn_view; i++) { + if (ugd->multi_conn_dev_list[i].dev_sel_state) { + is_sel = TRUE; + sel_count++; + } else { + is_selct_all = FALSE; + } + } + + chk_box = elm_object_item_part_content_get(ugd->mcview_select_all_item, "elm.icon"); + elm_check_state_set(chk_box, is_selct_all); + + if (ugd->multi_connect_btn) { + wfd_ug_view_refresh_button(ugd->multi_connect_btn, _("IDS_WFD_BUTTON_CONNECT"), is_sel); + } + + if (sel_count > 0) { + snprintf(msg, MAX_POPUP_TEXT_SIZE, _("IDS_WFD_POP_SELECTED_DEVICE_NUM"), sel_count); + wfd_ug_tickernoti_popup(msg); + } + + __FUNC_EXIT__; +} + +static void _wfd_gl_sel_cb(void *data, Evas_Object *obj, void *event_info) +{ + int sel_count = 0; + char msg[MAX_POPUP_TEXT_SIZE] = {0}; + struct ug_data *ugd = (struct ug_data*) data; + + elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE); + + if (NULL == ugd || NULL == obj) { + DBG(LOG_ERROR, "NULL parameters.\n"); + return; + } + + Evas_Object *sel_chkbox = elm_object_item_part_content_get(ugd->mcview_select_all_item, "elm.icon"); + if (sel_chkbox==NULL) + { + DBG(LOG_VERBOSE, "select-all chkbox is NULL\n"); + return; + } + Eina_Bool state = elm_check_state_get(sel_chkbox); + + if (state==TRUE) + state = FALSE; + else + state = TRUE; + elm_check_state_set(sel_chkbox, state); + + DBG(LOG_VERBOSE, "state = %d \n", state); + + int i = 0; + bool is_sel = FALSE; + Elm_Object_Item *item = NULL; + Evas_Object *chk_box = NULL; + + /* set the state of all the available devices */ + for (i = 0; i < ugd->gl_available_dev_cnt_at_multiconn_view; i++) { + is_sel = state; + ugd->multi_conn_dev_list[i].dev_sel_state = state; + item = ugd->multi_conn_dev_list[i].peer.gl_item; + chk_box = elm_object_item_part_content_get(item, "elm.icon.1"); + elm_check_state_set(chk_box, state); + + if (state) { + sel_count++; + } + } + + /* update the connect button */ + if (ugd->multi_connect_btn) { + wfd_ug_view_refresh_button(ugd->multi_connect_btn, _("IDS_WFD_BUTTON_CONNECT"), is_sel); + } + + /* tickernoti popup */ + if (sel_count > 0) { + snprintf(msg, MAX_POPUP_TEXT_SIZE, _("IDS_WFD_POP_SELECTED_DEVICE_NUM"), sel_count); + wfd_ug_tickernoti_popup(msg); + } + + //elm_check_state_set(ugd->mcview_select_all_icon, EINA_FALSE); +} + + +static char *_wfd_gl_device_label_get(void *data, Evas_Object *obj, const char *part) +{ + DBG(LOG_VERBOSE, "part %s", part); + device_type_s *peer = (device_type_s*) data; + + if (NULL == peer) + return NULL; + + if (!strcmp(part, "elm.text")) { + return strdup(peer->ssid); + } + return NULL; +} + + +static char *__wfd_get_device_icon_path(device_type_s *peer) +{ + char *img_path = NULL; + + switch(peer->category) + { + case WFD_DEVICE_TYPE_COMPUTER: + img_path = WFD_ICON_DEVICE_COMPUTER; + break; + case WFD_DEVICE_TYPE_INPUT_DEVICE: + img_path = WFD_ICON_DEVICE_INPUT_DEVICE; + break; + case WFD_DEVICE_TYPE_PRINTER: + img_path = WFD_ICON_DEVICE_PRINTER; + break; + case WFD_DEVICE_TYPE_CAMERA: + img_path = WFD_ICON_DEVICE_CAMERA; + break; + case WFD_DEVICE_TYPE_STORAGE: + img_path = WFD_ICON_DEVICE_STORAGE; + break; + case WFD_DEVICE_TYPE_NW_INFRA: + img_path = WFD_ICON_DEVICE_NETWORK_INFRA; + break; + case WFD_DEVICE_TYPE_DISPLAYS: + img_path = WFD_ICON_DEVICE_DISPLAY; + break; + case WFD_DEVICE_TYPE_MM_DEVICES: + img_path = WFD_ICON_DEVICE_MULTIMEDIA_DEVICE; + break; + case WFD_DEVICE_TYPE_GAME_DEVICES: + img_path = WFD_ICON_DEVICE_GAMING_DEVICE; + break; + case WFD_DEVICE_TYPE_TELEPHONE: + img_path = WFD_ICON_DEVICE_TELEPHONE; + break; + case WFD_DEVICE_TYPE_AUDIO: + img_path = WFD_ICON_DEVICE_AUDIO_DEVICE; + break; + default: + img_path = WFD_ICON_DEVICE_COMPUTER; + break; + } + + return img_path; +} + + + +static void _wfd_check_clicked_cb(void *data, Evas_Object *obj, void *event_info) +{ + struct ug_data *ugd = (struct ug_data*) data; + if (NULL == ugd || NULL == obj) { + DBG(LOG_ERROR, "NULL parameters.\n"); + return; + } + + int i = 0; + bool is_sel = FALSE; + Elm_Object_Item *item = NULL; + Evas_Object *chk_box = NULL; + Eina_Bool state = elm_check_state_get(obj); + elm_check_state_set(obj, !state); + + DBG(LOG_VERBOSE, "state = %d \n", state); + +#if 0 + /* set the state of all the available devices */ + for (i = 0; i < ugd->gl_available_dev_cnt_at_multiconn_view; i++) { + is_sel = state; + ugd->multi_conn_dev_list[i].dev_sel_state = state; + item = ugd->multi_conn_dev_list[i].peer.gl_item; + chk_box = elm_object_item_part_content_get(item, "elm.icon.1"); + elm_check_state_set(chk_box, state); + } + + /* update the connect button */ + wfd_ug_view_refresh_button(ugd->multi_connect_btn, _("IDS_WFD_BUTTON_CONNECT"), is_sel); +#endif +} + + +static Evas_Object *_wfd_gl_device_icon_get(void *data, Evas_Object *obj, const char *part) +{ + char *img_path = NULL; + device_type_s *peer = (device_type_s*) data; + Evas_Object* icon = NULL; + + DBG(LOG_VERBOSE, "Part %s", part); + + if (!strcmp(part, "elm.icon.1")) { + DBG(LOG_VERBOSE, "Part %s", part); + icon = elm_check_add(obj); + elm_check_state_set(icon, EINA_FALSE); + evas_object_smart_callback_add(icon, "changed", _wfd_check_clicked_cb, (void *)data); + } else if (!strcmp(part, "elm.icon.2")) { + img_path = __wfd_get_device_icon_path(peer); + icon = elm_icon_add(obj); + elm_icon_file_set(icon, img_path, NULL); + evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); + elm_icon_resizable_set(icon, 1, 1); + evas_object_show(icon); + } + + return icon; +} + + +static char *_wfd_gl_select_all_label_get(void *data, Evas_Object *obj, const char *part) +{ + if (!strcmp(part, "elm.text")) { + DBG(LOG_VERBOSE, "Adding text %s", part); + return strdup("Select all"); + } + return NULL; +} + +static Evas_Object *_wfd_gl_select_all_icon_get(void *data, Evas_Object *obj, const char *part) +{ + struct ug_data *ugd = (struct ug_data*) data; + Evas_Object* icon = NULL; + + if (!strcmp(part, "elm.icon")) { + DBG(LOG_VERBOSE, "Part %s", part); + icon = elm_check_add(obj); + elm_check_state_set(icon, EINA_FALSE); + evas_object_smart_callback_add(icon, "changed", _wfd_check_clicked_cb, (void *)data); + } + + return icon; +} + + + + +int _wfd_free_multiconnect_device(struct ug_data *ugd) +{ + __FUNC_ENTER__; + + int count = 0; + int i = 0; + + if (ugd->multiconn_view_genlist == NULL) + { + return 0; + } + + if (ugd->mcview_title_item != NULL) + { + elm_object_item_del(ugd->mcview_title_item); + ugd->mcview_title_item = NULL; + } + + if (ugd->mcview_select_all_item != NULL) + { + elm_object_item_del(ugd->mcview_select_all_item); + ugd->mcview_select_all_item = NULL; + } + + if (ugd->mcview_nodevice_item != NULL) + { + elm_object_item_del(ugd->mcview_nodevice_item); + ugd->mcview_nodevice_item = NULL; + } + + for(i = 0; i < ugd->gl_available_dev_cnt_at_multiconn_view; i++) + { + if (ugd->multi_conn_dev_list[i].peer.gl_item != NULL) + { + elm_object_item_del(ugd->multi_conn_dev_list[i].peer.gl_item); + ugd->multi_conn_dev_list[i].peer.gl_item = NULL; + } + } + ugd->gl_available_dev_cnt_at_multiconn_view = 0; + + __FUNC_EXIT__; + return 0; +} + +int _wfd_update_multiconnect_device(struct ug_data *ugd) +{ + __FUNC_ENTER__; + + int count = 0; + device_type_s *device = NULL; + Evas_Object *genlist = NULL; + int i = 0; + + genlist = ugd->multiconn_view_genlist; + if (ugd->multiconn_view_genlist == NULL) + { + return 0; + } + + _wfd_free_multiconnect_device(ugd); + + count = 0; + for(i = 0; i < ugd->raw_discovered_peer_cnt; i++) + { + device = &ugd->raw_discovered_peers[i]; + if (device->is_connected == FALSE) + { + count++; + } + } + ugd->gl_available_dev_cnt_at_multiconn_view = count; + + if (ugd->gl_available_dev_cnt_at_multiconn_view == 0) + { + DBG(LOG_ERROR, "There are No peers\n"); + ugd->mcview_title_item = elm_genlist_item_append(genlist, &title_itc, ugd, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(ugd->mcview_title_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + ugd->mcview_nodevice_item = elm_genlist_item_append(genlist, &noitem_itc, (void*)ugd, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(ugd->mcview_nodevice_item , ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + } + else + { + ugd->mcview_title_item = elm_genlist_item_append(genlist, &title_itc, ugd, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + elm_genlist_item_select_mode_set(ugd->mcview_title_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + ugd->mcview_select_all_item = elm_genlist_item_append(genlist, &select_all_itc, ugd, NULL, ELM_GENLIST_ITEM_NONE, _wfd_gl_sel_cb, ugd); + + count = 0; + for(i = 0; i < ugd->raw_discovered_peer_cnt; i++) + { + device = &ugd->raw_discovered_peers[i]; + if (device->is_connected == FALSE) + { + DBG(LOG_VERBOSE, "%dth peer being added on genlist\n", i); + + if (ugd->multi_conn_dev_list[count].peer.gl_item != NULL) + elm_object_item_del(ugd->multi_conn_dev_list[count].peer.gl_item); + ugd->multi_conn_dev_list[count].peer.gl_item = NULL; + + memcpy(&ugd->multi_conn_dev_list[count].peer, device, sizeof(device_type_s)); + + ugd->multi_conn_dev_list[count].dev_sel_state = FALSE; + ugd->multi_conn_dev_list[count].peer.gl_item = + elm_genlist_item_append(genlist, &device_itc, (void*) &ugd->multi_conn_dev_list[count].peer, + NULL, ELM_GENLIST_ITEM_NONE, _wfd_gl_multi_sel_cb, ugd); + count++; + } + } + } + + __FUNC_EXIT__; + return 0; +} + +void _wifid_create_multiconnect_view(struct ug_data *ugd) +{ + __FUNC_ENTER__; + + Evas_Object *back_btn = NULL; + Evas_Object *control_bar = NULL; + Evas_Object *genlist = NULL; + + Elm_Object_Item *navi_item = NULL; + Elm_Object_Item *item = NULL; + + if(ugd == NULL) + { + DBG(LOG_ERROR, "Incorrect parameter(NULL)"); + return; + } + + select_all_itc.item_style = "1text.1icon.3"; + select_all_itc.func.text_get = _wfd_gl_select_all_label_get; + select_all_itc.func.content_get = _wfd_gl_select_all_icon_get; + select_all_itc.func.state_get = NULL; + select_all_itc.func.del = NULL; + + device_itc.item_style = "1text.2icon.2"; + device_itc.func.text_get = _wfd_gl_device_label_get; + device_itc.func.content_get = _wfd_gl_device_icon_get; + device_itc.func.state_get = NULL; + device_itc.func.del = NULL; + + DBG(LOG_VERBOSE, "_wifid_create_multiconnect_view"); + back_btn = elm_button_add(ugd->naviframe); + elm_object_style_set(back_btn, "naviframe/back_btn/default"); + evas_object_smart_callback_add(back_btn, "clicked", _multiconnect_view_back_btn_cb, (void*) ugd); + elm_object_focus_allow_set(back_btn, EINA_FALSE); + + genlist = elm_genlist_add(ugd->naviframe); + ugd->multiconn_view_genlist = genlist; + elm_object_style_set(ugd->multiconn_view_genlist, "dialogue"); + + ugd->mcview_title_item = NULL; + + _wfd_update_multiconnect_device(ugd); + + evas_object_show(genlist); + + navi_item = elm_naviframe_item_push(ugd->naviframe, _("Multi connect"), back_btn, NULL, genlist, NULL); + + control_bar = elm_toolbar_add(ugd->naviframe); + elm_toolbar_shrink_mode_set(control_bar, ELM_TOOLBAR_SHRINK_EXPAND); + evas_object_show(control_bar); + + ugd->multi_scan_btn = elm_toolbar_item_append(control_bar, NULL, _("IDS_WFD_BUTTON_SCAN"), _scan_btn_cb, (void*) ugd); + item = elm_toolbar_item_append(control_bar, NULL, NULL, NULL, NULL); + elm_object_item_disabled_set(item, EINA_TRUE); + ugd->multi_connect_btn = elm_toolbar_item_append(control_bar, NULL, _("IDS_WFD_BUTTON_CONNECT"), _connect_btn_cb, (void*) ugd); + + if (ugd->multi_connect_btn) { + wfd_ug_view_refresh_button(ugd->multi_connect_btn, _("IDS_WFD_BUTTON_CONNECT"), FALSE); + } + + item = elm_toolbar_item_append(control_bar, NULL, NULL, NULL, NULL); + elm_object_item_disabled_set(item, EINA_TRUE); + elm_object_item_part_content_set(navi_item, "controlbar", control_bar); + + __FUNC_EXIT__; +} diff --git a/ug-wifidirect/src/wfd_ug_popup.c b/ug-wifidirect/src/wfd_ug_popup.c new file mode 100755 index 0000000..0c20c0f --- /dev/null +++ b/ug-wifidirect/src/wfd_ug_popup.c @@ -0,0 +1,399 @@ +/* +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd + +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license + +* 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 + +#include +#include + +#include +#include +#include +#include + +#include "wfd_ug.h" +#include "wfd_ug_view.h" +#include "wfd_client.h" + +static void _wfd_ug_act_popup_hotspot_ok_cb(void *data, Evas_Object *obj, void *event_info) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + // TODO: Turn off Hotspot + ugd->wfd_status = WFD_LINK_STATUS_DEACTIVATED; + wfd_mobile_ap_off(ugd); + + evas_object_del(ugd->act_popup); + ugd->act_popup = NULL; + __FUNC_EXIT__; +} + +static void _wfd_ug_act_popup_hotspot_cancel_cb(void *data, Evas_Object *obj, void *event_info) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + // TODO: set genlist head item as "WiFi Direct" + ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT; + wfd_ug_view_refresh_glitem(ugd->head); + + evas_object_del(ugd->act_popup); + ugd->act_popup = NULL; + __FUNC_EXIT__; +} + +static void _wfd_ug_act_popup_wifi_ok_cb(void *data, Evas_Object *obj, void *event_info) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + // TODO: Turn off WiFi + ugd->wfd_status = WFD_LINK_STATUS_DEACTIVATED; + wfd_wifi_off(ugd); + + evas_object_del(ugd->act_popup); + ugd->act_popup = NULL; + __FUNC_EXIT__; +} + +static void _wfd_ug_act_popup_wifi_cancel_cb(void *data, Evas_Object *obj, void *event_info) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + // TODO: set genlist head item as "WiFi Direct" + ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT; + wfd_ug_view_refresh_glitem(ugd->head); + + evas_object_del(ugd->act_popup); + ugd->act_popup = NULL; + __FUNC_EXIT__; +} + +static void _wfd_ug_act_popup_disconnect_ok_cb(void *data, Evas_Object *obj, void *event_info) +{ + __FUNC_ENTER__; + + char *mac_addr = NULL; + struct ug_data *ugd = (struct ug_data*) data; + + if (NULL == ugd) { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return; + } + + if (ugd->gl_connected_peer_cnt < 1) { + DBG(LOG_ERROR, "No connected peer\n"); + evas_object_del(ugd->act_popup); + ugd->act_popup = NULL; + return; + } + + /* just one peer */ + mac_addr = ugd->gl_connected_peers[0].mac_addr; + wfd_client_disconnect(mac_addr); + if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS) { + wfd_stop_multi_connect(ugd); + } + + evas_object_del(ugd->act_popup); + ugd->act_popup = NULL; + + __FUNC_EXIT__; +} + +static void _wfd_ug_act_popup_disconnect_cancel_cb(void *data, Evas_Object *obj, void *event_info) +{ + __FUNC_ENTER__; + + struct ug_data *ugd = (struct ug_data*) data; + if (NULL == ugd) { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return; + } + + evas_object_del(ugd->act_popup); + ugd->act_popup = NULL; + + __FUNC_EXIT__; +} + +static void _wfd_ug_act_popup_disconnect_all_ok_cb(void *data, Evas_Object *obj, void *event_info) +{ + __FUNC_ENTER__; + + struct ug_data *ugd = (struct ug_data*) data; + if (NULL == ugd) { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return; + } + + wfd_client_disconnect(NULL); + if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS) { + wfd_stop_multi_connect(ugd); + } + + evas_object_del(ugd->act_popup); + ugd->act_popup = NULL; + + __FUNC_EXIT__; +} + +static void _wfd_ug_act_popup_disconnect_all_cancel_cb(void *data, Evas_Object *obj, void *event_info) +{ + __FUNC_ENTER__; + + struct ug_data *ugd = (struct ug_data*) data; + if (NULL == ugd) { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return; + } + + evas_object_del(ugd->act_popup); + ugd->act_popup = NULL; + + __FUNC_EXIT__; +} + +static void _wfd_ug_act_popup_scan_again_ok_cb(void *data, Evas_Object *obj, void *event_info) +{ + __FUNC_ENTER__; + + struct ug_data *ugd = (struct ug_data*) data; + if (NULL == ugd) { + DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); + return; + } + + if (ugd->conn_wfd_item != NULL) { + elm_object_item_del(ugd->conn_wfd_item); + ugd->conn_wfd_item = NULL; + } + + /* cancel the current connection */ + wfd_client_disconnect(NULL); + if (ugd->multi_connect_mode == WFD_MULTI_CONNECT_MODE_IN_PROGRESS) { + wfd_stop_multi_connect(ugd); + } + + /* start discovery again */ + wfd_client_start_discovery(ugd); + evas_object_del(ugd->act_popup); + ugd->act_popup = NULL; + + __FUNC_EXIT__; +} + +static void _wfd_ug_act_popup_scan_again_cancel_cb(void *data, Evas_Object *obj, void *event_info) +{ + __FUNC_ENTER__; + + struct ug_data *ugd = (struct ug_data*) data; + + evas_object_del(ugd->act_popup); + ugd->act_popup = NULL; + + __FUNC_EXIT__; +} + +void wfd_ug_act_popup(void *data, const char *message, int popup_type) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + Evas_Object *popup = NULL; + Evas_Object *btn1 = NULL, *btn2 = NULL; + + popup = elm_popup_add(ugd->base); + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_text_set(popup, message); + + btn1 = elm_button_add(popup); + btn2 = elm_button_add(popup); + elm_object_style_set(btn1, "popup_button/default"); + elm_object_style_set(btn2, "popup_button/default"); + + /* set the different text by type */ + if (popup_type == POPUP_TYPE_WIFI_OFF || popup_type == POPUP_TYPE_HOTSPOT_OFF) { + elm_object_text_set(btn1, S_("IDS_COM_SK_YES")); + elm_object_text_set(btn2, S_("IDS_COM_SK_NO")); + } else { + elm_object_text_set(btn1, S_("IDS_COM_SK_OK")); + elm_object_text_set(btn2, S_("IDS_COM_SK_CANCEL")); + } + + elm_object_part_content_set(popup, "button1", btn1); + elm_object_part_content_set(popup, "button2", btn2); + + /* set the different callback by type */ + if (popup_type == POPUP_TYPE_WIFI_OFF) { + evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_wifi_ok_cb, (void*) ugd); + evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_wifi_cancel_cb, (void*) ugd); + } else if (popup_type == POPUP_TYPE_HOTSPOT_OFF) { + evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_hotspot_ok_cb, (void*) ugd); + evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_hotspot_cancel_cb, (void*) ugd); + } else if (popup_type == POP_TYPE_DISCONNECT) { + //evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_disconnect_ok_cb, (void*) ugd); + evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_disconnect_all_ok_cb, (void*) ugd); + evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_disconnect_cancel_cb, (void*) ugd); + } else if (popup_type == POP_TYPE_DISCONNECT_ALL) { + evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_disconnect_all_ok_cb, (void*) ugd); + evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_disconnect_all_cancel_cb, (void*) ugd); + } else if (popup_type == POP_TYPE_SCAN_AGAIN) { + evas_object_smart_callback_add(btn1, "clicked", _wfd_ug_act_popup_scan_again_ok_cb, (void*) ugd); + evas_object_smart_callback_add(btn2, "clicked", _wfd_ug_act_popup_scan_again_cancel_cb, (void*) ugd); + } + + evas_object_show(popup); + ugd->act_popup = popup; + __FUNC_EXIT__; +} + +void wfg_ug_act_popup_remove(void *data) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + if(ugd->act_popup) + { + evas_object_del(ugd->act_popup); + ugd->act_popup = NULL; + } + __FUNC_EXIT__; +} + +static void _wfd_ug_terminate_popup_cb(void *data, Evas_Object *obj, void *event_info) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + evas_object_del(ugd->warn_popup); + ugd->warn_popup = NULL; + + wfd_ug_view_free_peers(ugd); + + ug_destroy_me(ugd->ug); + __FUNC_EXIT__; +} + +static void _wfd_ug_warn_popup_cb(void *data, Evas_Object *obj, void *event_info) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + evas_object_del(ugd->warn_popup); + ugd->warn_popup = NULL; + + __FUNC_EXIT__; +} + +void wfd_ug_warn_popup(void *data, const char *message, int popup_type) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + Evas_Object *popup = NULL; + Evas_Object *btn = NULL; + + popup = elm_popup_add(ugd->base); + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_text_set(popup, message); + + btn = elm_button_add(popup); + elm_object_style_set(btn, "popup_button/default"); + elm_object_text_set(btn, S_("IDS_COM_SK_OK")); + elm_object_part_content_set(popup, "button1", btn); + if(popup_type == POPUP_TYPE_TERMINATE) + evas_object_smart_callback_add(btn, "clicked", _wfd_ug_terminate_popup_cb, (void*) ugd); + else + evas_object_smart_callback_add(btn, "clicked", _wfd_ug_warn_popup_cb, (void*) ugd); + + evas_object_show(popup); + ugd->warn_popup = popup; + __FUNC_EXIT__; +} + +void wfg_ug_warn_popup_remove(void *data) +{ + __FUNC_ENTER__; + struct ug_data *ugd = (struct ug_data*) data; + + if(ugd->warn_popup) + { + evas_object_del(ugd->warn_popup); + ugd->warn_popup = NULL; + } + __FUNC_EXIT__; +} + + +void wfd_ug_tickernoti_popup(char *msg) +{ + __FUNC_ENTER__; + + int ret = -1; + bundle *b = NULL; + + b = bundle_create(); + if (!b) { + DBG(LOG_ERROR, "FAIL: bundle_create()\n"); + return; + } + + /* tickernoti style */ + ret = bundle_add(b, "0", "info"); + if (ret) { + DBG(LOG_ERROR, "Fail to add tickernoti style\n"); + bundle_free(b); + return; + } + + /* popup text */ + ret = bundle_add(b, "1", msg); + if (ret) { + DBG(LOG_ERROR, "Fail to add popup text\n"); + bundle_free(b); + return; + } + + /* orientation of tickernoti */ + ret = bundle_add(b, "2", "1"); + if (ret) { + DBG(LOG_ERROR, "Fail to add orientation of tickernoti\n"); + bundle_free(b); + return; + } + + /* timeout(second) of tickernoti */ + ret = bundle_add(b, "3", "3"); + if (ret) { + DBG(LOG_ERROR, "Fail to add timeout of tickernoti\n"); + bundle_free(b); + return; + } + + /* launch tickernoti */ + ret = syspopup_launch(TICKERNOTI_SYSPOPUP, b); + if (ret) { + DBG(LOG_ERROR, "Fail to launch syspopup\n"); + } + + bundle_free(b); + __FUNC_EXIT__; +} + diff --git a/ug-wifidirect/src/wfd_ug_view.c b/ug-wifidirect/src/wfd_ug_view.c deleted file mode 100644 index 7322477..0000000 --- a/ug-wifidirect/src/wfd_ug_view.c +++ /dev/null @@ -1,874 +0,0 @@ -/* - * Copyright 2012 Samsung Electronics Co., Ltd - * - * Licensed under the Flora License, Version 1.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.tizenopensource.org/license - * - * 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. - */ - -/* - * This file implements view of Wi-Fi direct UI Gadget. - * - * @file wfd_ug_view.c - * @author Gibyoung Kim (lastkgb.kim@samsung.com) - * @version 0.1 - */ - - -#include - -#include -#include - -#include -#include -#include -#include - -#include "wfd_ug.h" -#include "wfd_ug_view.h" -#include "wfd_client.h" - - -Elm_Gen_Item_Class sep_itc; -Elm_Gen_Item_Class head_itc; -Elm_Gen_Item_Class name_itc; -Elm_Gen_Item_Class title_itc; -Elm_Gen_Item_Class peer_itc; -Elm_Gen_Item_Class noitem_itc; -Elm_Gen_Item_Class help_itc; - - -void _back_btn_cb(void *data, Evas_Object * obj, void *event_info) -{ - __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data*) data; - - if (!ugd) - { - DBG(LOG_ERROR, "The param is NULL\n"); - return; - } - - wfd_ug_view_free_peers(ugd); - - ug_destroy_me(ugd->ug); - - __FUNC_EXIT__; - return; -} - -void _scan_btn_cb(void *data, Evas_Object * obj, void *event_info) -{ - __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data*) data; - int res; - - res = wfd_client_start_discovery(ugd); - - __FUNC_EXIT__; - return; -} - -Eina_Bool _is_wifi_on() -{ - __FUNC_ENTER__; - int wifi_state; - - vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state); - - if (wifi_state >= VCONFKEY_WIFI_CONNECTED) - { - return TRUE; - } - else - { - return FALSE; - } - __FUNC_EXIT__; -} - -static void _wfd_onoff_btn_cb(void *data, Evas_Object *obj, void *event_info) -{ - __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data*) data; - - ugd->wfd_status = wfd_client_get_link_status(); - DBG(LOG_VERBOSE, "WFD state is [%d]", ugd->wfd_status); - - if (!ugd->wfd_onoff) - { - if(ugd->wfd_status < 0) - { - DBG(LOG_VERBOSE, "bad wfd status\n"); - wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_ACTIVATE_FAIL"), POPUP_TYPE_TERMINATE); - - ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT; - wfd_ug_view_refresh_glitem(ugd->head); - return; - } - - ugd->head_text_mode = HEAD_TEXT_TYPE_ACTIVATING; - wfd_client_switch_on(ugd); - } - else - { - if(ugd->wfd_status < 0) - { - DBG(LOG_VERBOSE, "bad wfd status\n"); - wfd_ug_warn_popup(ugd, _("IDS_WFD_POP_DEACTIVATE_FAIL"), POPUP_TYPE_TERMINATE); - - ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT; - wfd_ug_view_refresh_glitem(ugd->head); - return; - } - - ugd->head_text_mode = HEAD_TEXT_TYPE_DEACTIVATING; - wfd_client_switch_off(ugd); - } - wfd_ug_view_refresh_glitem(ugd->head); - - __FUNC_EXIT__; -} - -static void _gl_header_sel(void *data, Evas_Object *obj, void *event_info) -{ - __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data*) data; - Elm_Object_Item *item = (Elm_Object_Item *)event_info; - int res; - - if(data == NULL) - { - DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); - return; - } - - if(item != NULL) - elm_genlist_item_selected_set(item, EINA_FALSE); - - _wfd_onoff_btn_cb(ugd, NULL, NULL); - - __FUNC_EXIT__; -} - -static char *_gl_header_label_get(void *data, Evas_Object * obj, - const char *part) -{ - __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data *) data; - DBG(LOG_VERBOSE, "%s", part); - - if (data == NULL) - { - DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); - return NULL; - } - - if (!strcmp(part, "elm.text")) - { - DBG(LOG_VERBOSE, "Current text mode [%d]\n", ugd->head_text_mode); - switch (ugd->head_text_mode) - { - case HEAD_TEXT_TYPE_DIRECT: - return strdup(dgettext("sys_string", "IDS_COM_OPT1_WI_FI_DIRECT")); - break; - case HEAD_TEXT_TYPE_DEACTIVATING: - return strdup(_("IDS_WFD_BODY_DEACTIVATING")); - break; - case HEAD_TEXT_TYPE_ACTIVATING: - return strdup(_("IDS_WFD_BODY_ACTIVATING")); - break; - case HEAD_TEXT_TYPE_ACTIVATED: - return strdup(_("IDS_WFD_BODY_ACTIVATED")); - break; - case HEAD_TEXT_TYPE_SCANING: - return strdup(_("IDS_WFD_BODY_SCANNING")); - break; - default: - break; - } - } - - __FUNC_EXIT__; - return NULL; -} - -static Evas_Object *_gl_header_icon_get(void *data, Evas_Object * obj, - const char *part) -{ - __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data *) data; - Evas_Object *onoff = NULL; - - if (data == NULL) - { - DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); - return NULL; - } - - if (ugd->head_text_mode == HEAD_TEXT_TYPE_ACTIVATING || - ugd->head_text_mode == HEAD_TEXT_TYPE_DEACTIVATING) - return NULL; - - DBG(LOG_VERBOSE, "%s", part); - onoff = elm_check_add(obj); - elm_object_style_set(onoff, "on&off"); - elm_check_state_set(onoff, ugd->wfd_onoff); - evas_object_smart_callback_add(onoff, "changed", _wfd_onoff_btn_cb, ugd); - evas_object_show(onoff); - - __FUNC_EXIT__; - - return onoff; -} - -static char *_gl_name_label_get(void *data, Evas_Object * obj, const char *part) -{ - __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data *) data; - - if (data == NULL) - { - DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); - return NULL; - } - - DBG(LOG_VERBOSE, "%s", part); - - if (!strcmp(part, "elm.text.1")) - { - return strdup(_("IDS_WFD_BODY_DEVICE_NAME")); - } - else if (!strcmp(part, "elm.text.2")) - { - return strdup(ugd->dev_name); - } - - __FUNC_EXIT__; - - return NULL; -} - -static char *_gl_title_label_get(void *data, Evas_Object * obj, - const char *part) -{ - __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data *) data; - - if (data == NULL) - { - DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); - return NULL; - } - - if (!strcmp(part, "elm.text")) - { - if (ugd->peer_cnt) - return strdup(_("IDS_WFD_BODY_AVAILABLE_DEVICES")); - else - return strdup(_("IDS_WFD_BODY_WIFI_DIRECT_DEVICES")); - } - - __FUNC_EXIT__; - - return NULL; -} - -static Evas_Object *_gl_noitem_icon_get(void *data, Evas_Object * obj, - const char *part) -{ - __FUNC_ENTER__; - Evas_Object *nocontent; - - if (data == NULL) - { - DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); - return NULL; - } - - nocontent = elm_layout_add(obj); - if (nocontent == NULL) - { - DBG(LOG_ERROR, "Failed to add nocontent"); - return NULL; - } - elm_layout_theme_set(nocontent, "layout", "nocontents", "unnamed"); - elm_object_part_text_set(nocontent, "elm.text", - _("IDS_WFD_BODY_NO_DEVICES")); - evas_object_size_hint_min_set(nocontent, 400, 200); - evas_object_size_hint_max_set(nocontent, 400, 200); - evas_object_resize(nocontent, 400, 200); - - __FUNC_EXIT__; - - return nocontent; -} - -static void _gl_noitem_del(void *data, Evas_Object * obj) -{ - __FUNC_ENTER__; - - __FUNC_EXIT__; - return; -} - -static char *_gl_peer_label_get(void *data, Evas_Object * obj, const char *part) -{ - __FUNC_ENTER__; - assertm_if(NULL == obj, "NULL!!"); - assertm_if(NULL == part, "NULL!!"); - - device_type_s *peer = (device_type_s *) data; - - if (data == NULL) - { - DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); - return NULL; - } - - __FUNC_EXIT__; - return strdup(peer->ssid); -} - -static Evas_Object *_gl_peer_icon_get(void *data, Evas_Object * obj, - const char *part) -{ - __FUNC_ENTER__; - assertm_if(NULL == obj, "NULL!!"); - assertm_if(NULL == part, "NULL!!"); - - device_type_s *peer = (device_type_s *) data; - Evas_Object *icon = NULL; - - if (data == NULL) - { - DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); - return NULL; - } - - if (!strcmp(part, "elm.icon.2")) - { - DBG(LOG_VERBOSE, "elm.icon.2 - connection status [%d]\n", - peer->conn_status); - if (peer->conn_status == PEER_CONN_STATUS_CONNECTING) - { - icon = elm_progressbar_add(obj); - elm_object_style_set(icon, "list_process"); - elm_progressbar_pulse(icon, EINA_TRUE); - } - else if (peer->conn_status == PEER_CONN_STATUS_CONNECTED) - { - icon = elm_icon_add(obj); - elm_icon_file_set(icon, WFD_ICON_CONNECTED, NULL); - } - - evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); - elm_icon_resizable_set(icon, 1, 1); - evas_object_show(icon); - } - else if (!strcmp(part, "elm.icon.1")) - { - DBG(LOG_VERBOSE, "elm.icon.1 - category [%d]\n", peer->category); - char *img_path = NULL; - switch (peer->category) - { - case WFD_DEVICE_TYPE_COMPUTER: - img_path = WFD_ICON_DEVICE_PC; - break; - case WFD_DEVICE_TYPE_INPUT_DEVICE: - img_path = WFD_ICON_DEVICE_KEYBOARD; - break; - case WFD_DEVICE_TYPE_PRINTER: - img_path = WFD_ICON_DEVICE_PRINTER; - break; - case WFD_DEVICE_TYPE_CAMERA: - img_path = WFD_ICON_DEVICE_UNKNOWN; - break; - case WFD_DEVICE_TYPE_STORAGE: - case WFD_DEVICE_TYPE_NW_INFRA: - case WFD_DEVICE_TYPE_DISPLAYS: - case WFD_DEVICE_TYPE_MM_DEVICES: - case WFD_DEVICE_TYPE_GAME_DEVICES: - case WFD_DEVICE_TYPE_OTHER: - img_path = WFD_ICON_DEVICE_UNKNOWN; - break; - case WFD_DEVICE_TYPE_TELEPHONE: - img_path = WFD_ICON_DEVICE_PHONE; - break; - case WFD_DEVICE_TYPE_AUDIO: - img_path = WFD_ICON_DEVICE_HEADSET; - break; - default: - break; - } - - if (img_path != NULL) - { - icon = elm_icon_add(obj); - elm_icon_file_set(icon, img_path, NULL); - evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, - 1, 1); - elm_icon_resizable_set(icon, 1, 1); - evas_object_show(icon); - } - } - - __FUNC_EXIT__; - return icon; -} - -static void _gl_peer_del(void *data, Evas_Object * obj) -{ - __FUNC_ENTER__; - assertm_if(NULL == obj, "NULL!!"); - assertm_if(NULL == data, "NULL!!"); - - __FUNC_EXIT__; - return; -} - -static void _gl_peer_sel(void *data, Evas_Object * obj, void *event_info) -{ - __FUNC_ENTER__; - assertm_if(NULL == obj, "NULL!!"); - assertm_if(NULL == data, "NULL!!"); - device_type_s *peer = (device_type_s *) data; - Elm_Object_Item *item = (Elm_Object_Item *) event_info; - int res; - - if (data == NULL) - { - DBG(LOG_ERROR, "Incorrect parameter(NULL)\n"); - return; - } - - if (item != NULL) - elm_genlist_item_selected_set(item, EINA_FALSE); - - if (peer->conn_status == PEER_CONN_STATUS_DISCONNECTED) - { - DBG(LOG_VERBOSE, "Connect with peer [%s]\n", peer->mac_addr); - res = wfd_client_connect((const char *) peer->mac_addr); - if (res != 0) - { - DBG(LOG_ERROR, "Failed to send connection request. [%d]\n", res); - return; - } - peer->conn_status = PEER_CONN_STATUS_CONNECTING; - } - else - { - res = wfd_client_disconnect((const char *) peer->mac_addr); - if (res != 0) - { - DBG(LOG_ERROR, "Failed to send disconnection request. [%d]\n", res); - return; - } - peer->conn_status = PEER_CONN_STATUS_DISCONNECTED; - } - - wfd_ug_view_refresh_glitem(peer->gl_item); - - __FUNC_EXIT__; - return; -} - -static char *_gl_help_label_get(void *data, Evas_Object * obj, const char *part) -{ - __FUNC_ENTER__; - DBG(LOG_VERBOSE, "%s", part); - __FUNC_ENTER__; - return strdup("Help"); -} - -static Evas_Object *_create_basic_genlist(void *data) -{ - __FUNC_ENTER__; - - struct ug_data *ugd = (struct ug_data *) data; - Evas_Object *genlist; - - genlist = elm_genlist_add(ugd->naviframe); - - sep_itc.item_style = "grouptitle.dialogue.seperator"; - sep_itc.func.text_get = NULL; - sep_itc.func.content_get = NULL; - sep_itc.func.state_get = NULL; - sep_itc.func.del = NULL; - - head_itc.item_style = "dialogue/1text.1icon"; - head_itc.func.text_get = _gl_header_label_get; - head_itc.func.content_get = _gl_header_icon_get; - head_itc.func.state_get = NULL; - - name_itc.item_style = "dialogue/2text.3"; - name_itc.func.text_get = _gl_name_label_get; - name_itc.func.content_get = NULL; - name_itc.func.state_get = NULL; - name_itc.func.del = NULL; - - Elm_Object_Item *item; - elm_genlist_item_append(genlist, &sep_itc, NULL, NULL, - ELM_GENLIST_ITEM_NONE, NULL, NULL); - ugd->head = - elm_genlist_item_append(genlist, &head_itc, ugd, NULL, - ELM_GENLIST_ITEM_NONE, _gl_header_sel, (void*) ugd); - item = - elm_genlist_item_append(genlist, &name_itc, ugd, NULL, - ELM_GENLIST_ITEM_NONE, NULL, NULL); - elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); - - __FUNC_EXIT__; - - return genlist; -} - -static int _create_device_genlist(void *data) -{ - __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data *) data; - - title_itc.item_style = "dialogue/title"; - title_itc.func.text_get = _gl_title_label_get; - title_itc.func.content_get = NULL; - title_itc.func.state_get = NULL; - title_itc.func.del = NULL; - - peer_itc.item_style = "dialogue/1text.2icon.2"; - peer_itc.func.text_get = _gl_peer_label_get; - peer_itc.func.content_get = _gl_peer_icon_get; - peer_itc.func.state_get = NULL; - peer_itc.func.del = _gl_peer_del; - - noitem_itc.item_style = "dialogue/bg/1icon"; - noitem_itc.func.text_get = NULL; - noitem_itc.func.content_get = _gl_noitem_icon_get; - noitem_itc.func.state_get = NULL; - noitem_itc.func.del = _gl_noitem_del; - - sep_itc.item_style = "grouptitle.dialogue.seperator"; - sep_itc.func.text_get = NULL; - sep_itc.func.content_get = NULL; - sep_itc.func.state_get = NULL; - sep_itc.func.del = NULL; - - help_itc.item_style = "dialogue/1text"; - help_itc.func.text_get = _gl_help_label_get; - help_itc.func.content_get = NULL; - help_itc.func.state_get = NULL; - help_itc.func.del = NULL; - - Elm_Object_Item *item; - item = - elm_genlist_item_append(ugd->genlist, &title_itc, (void *) ugd, NULL, - ELM_GENLIST_ITEM_NONE, NULL, NULL); - elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); - ugd->noitem = - elm_genlist_item_append(ugd->genlist, &noitem_itc, (void *) ugd, NULL, - ELM_GENLIST_ITEM_NONE, NULL, NULL); - elm_genlist_item_select_mode_set(ugd->noitem, - ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); - - __FUNC_EXIT__; - return 0; -} - -void create_wfd_ug_view(void *data) -{ - __FUNC_ENTER__; - - struct ug_data *ugd = (struct ug_data *) data; - Evas_Object *back_btn = NULL; - Elm_Object_Item *navi_item = NULL; - Evas_Object *control_bar = NULL; - - if (ugd == NULL) - { - DBG(LOG_ERROR, "Incorrect parameter(NULL)"); - return; - } - - ugd->naviframe = elm_naviframe_add(ugd->base); - elm_object_part_content_set(ugd->base, "elm.swallow.content", - ugd->naviframe); - evas_object_show(ugd->naviframe); - - back_btn = elm_button_add(ugd->naviframe); - elm_object_style_set(back_btn, "naviframe/back_btn/default"); - evas_object_smart_callback_add(back_btn, "clicked", _back_btn_cb, - (void *) ugd); - elm_object_focus_allow_set(back_btn, EINA_FALSE); - - ugd->genlist = _create_basic_genlist(ugd); - if (ugd->genlist == NULL) - { - DBG(LOG_ERROR, "Failed to create basic genlist"); - return; - } - evas_object_show(ugd->genlist); - _create_device_genlist(ugd); - - back_btn = elm_button_add(ugd->naviframe); - elm_object_style_set(back_btn, "naviframe/back_btn/default"); - evas_object_smart_callback_add(back_btn, "clicked", _back_btn_cb, - (void *) ugd); - elm_object_focus_allow_set(back_btn, EINA_FALSE); - - navi_item = - elm_naviframe_item_push(ugd->naviframe, _("IDS_WFD_HEADER_WIFI_DIRECT"), - back_btn, NULL, ugd->genlist, NULL); - - control_bar = elm_toolbar_add(ugd->naviframe); - elm_toolbar_shrink_mode_set(control_bar, ELM_TOOLBAR_SHRINK_EXPAND); - evas_object_show(control_bar); - - ugd->scan_btn = - elm_toolbar_item_append(control_bar, NULL, _("IDS_WFD_BUTTON_SCAN"), - _scan_btn_cb, (void *) ugd); - elm_object_item_disabled_set(ugd->scan_btn, !ugd->wfd_onoff); - - elm_object_item_part_content_set(navi_item, "controlbar", control_bar); - - __FUNC_EXIT__; -} - -void destroy_wfd_ug_view(void *data) -{ - __FUNC_ENTER__; - - struct ug_data *ugd = (struct ug_data *) data; - - if (ugd->genlist) - { - evas_object_del(ugd->genlist); - ugd->genlist = NULL; - } - - if (ugd->naviframe) - { - evas_object_del(ugd->naviframe); - ugd->naviframe = NULL; - } - - __FUNC_EXIT__; -} - -void wfd_ug_view_refresh_glitem(void *obj) -{ - __FUNC_ENTER__; - elm_genlist_item_update(obj); - __FUNC_EXIT__; -} - -void wfd_ug_view_refresh_button(void *obj, int enable) -{ - __FUNC_ENTER__; - DBG(LOG_VERBOSE, "scan button is enabling. [%d]\n", enable); - elm_object_item_disabled_set(obj, !enable); - __FUNC_EXIT__; -} - -void wfd_ug_view_update_peers(void *data) -{ - __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data *) data; - int i; - - DBG(LOG_VERBOSE, "peer count [%d], peer instance [%x]\n", ugd->peer_cnt, - ugd->peers); - - if (ugd->peer_cnt == 0) - { - DBG(LOG_ERROR, "There are No peers\n"); - if (ugd->noitem == NULL) - ugd->noitem = - elm_genlist_item_append(ugd->genlist, &noitem_itc, (void *) ugd, - NULL, ELM_GENLIST_ITEM_NONE, NULL, - NULL); - return; - } - else if (ugd->peer_cnt > 0) - { - if (ugd->noitem) - { - elm_object_item_del(ugd->noitem); - ugd->noitem = NULL; - DBG(LOG_VERBOSE, "Noitem list is removed\n"); - } - - for (i = 0; i < ugd->peer_cnt; i++) - { - DBG(LOG_VERBOSE, "%dth peer being added on genlist\n", i); - ugd->peers[i].gl_item = - elm_genlist_item_append(ugd->genlist, &peer_itc, - (void *) &(ugd->peers[i]), NULL, - ELM_GENLIST_ITEM_NONE, _gl_peer_sel, - (void *) &(ugd->peers[i])); - } - } - - __FUNC_EXIT__; -} - -void wfd_ug_view_free_peers(void *data) -{ - __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data *) data; - int i; - - for (i = 0; i < ugd->peer_cnt; i++) - { - DBG(LOG_VERBOSE, "%dth peer is deleted\n", i); - elm_object_item_del(ugd->peers[i].gl_item); - } - - if (ugd->peer_cnt > 0 && ugd->peers != NULL) - { - DBG(LOG_VERBOSE, "peers will be destroyed\n"); - free(ugd->peers); - ugd->peers = NULL; - ugd->peer_cnt = 0; - } - - __FUNC_EXIT__; -} - -static void _wfd_ug_act_popup_wifi_ok_cb(void *data, Evas_Object * obj, - void *event_info) -{ - __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data *) data; - - ugd->wfd_status = WFD_LINK_STATUS_DEACTIVATED; - wfd_wifi_off(); - - evas_object_del(ugd->act_popup); - ugd->act_popup = NULL; - __FUNC_EXIT__; -} - -static void _wfd_ug_act_popup_wifi_cancel_cb(void *data, Evas_Object * obj, - void *event_info) -{ - __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data *) data; - - ugd->head_text_mode = HEAD_TEXT_TYPE_DIRECT; - wfd_ug_view_refresh_glitem(ugd->head); - - evas_object_del(ugd->act_popup); - ugd->act_popup = NULL; - __FUNC_EXIT__; -} - -void wfd_ug_act_popup(void *data, const char *message, int popup_type) -{ - __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data *) data; - Evas_Object *popup = NULL; - Evas_Object *btn1 = NULL, *btn2 = NULL; - - popup = elm_popup_add(ugd->base); - evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_object_text_set(popup, message); - - btn1 = elm_button_add(popup); - elm_object_text_set(btn1, S_("IDS_COM_SK_YES")); - elm_object_part_content_set(popup, "button1", btn1); - evas_object_smart_callback_add(btn1, "clicked", - _wfd_ug_act_popup_wifi_ok_cb, (void *) ugd); - - btn2 = elm_button_add(popup); - elm_object_text_set(btn2, S_("IDS_COM_SK_NO")); - elm_object_part_content_set(popup, "button2", btn2); - evas_object_smart_callback_add(btn2, "clicked", - _wfd_ug_act_popup_wifi_cancel_cb, - (void *) ugd); - - evas_object_show(popup); - ugd->act_popup = popup; - __FUNC_EXIT__; -} - -void wfg_ug_act_popup_remove(void *data) -{ - __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data *) data; - - if (ugd->act_popup) - { - evas_object_del(ugd->act_popup); - ugd->act_popup = NULL; - } - __FUNC_EXIT__; -} - -static void _wfd_ug_terminate_popup_cb(void *data, Evas_Object *obj, void *event_info) -{ - __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data*) data; - - evas_object_del(ugd->warn_popup); - ugd->warn_popup = NULL; - - wfd_ug_view_free_peers(ugd); - - ug_destroy_me(ugd->ug); - __FUNC_EXIT__; -} - -static void _wfd_ug_warn_popup_cb(void *data, Evas_Object *obj, void *event_info) -{ - __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data*) data; - - evas_object_del(ugd->warn_popup); - ugd->warn_popup = NULL; - __FUNC_EXIT__; -} - -void wfd_ug_warn_popup(void *data, const char *message, int popup_type) -{ - __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data *) data; - Evas_Object *popup = NULL; - Evas_Object *btn = NULL; - - popup = elm_popup_add(ugd->base); - evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_object_text_set(popup, message); - - btn = elm_button_add(popup); - elm_object_text_set(btn, S_("IDS_COM_SK_OK")); - elm_object_part_content_set(popup, "button1", btn); - if(popup_type == POPUP_TYPE_TERMINATE) - evas_object_smart_callback_add(btn, "clicked", _wfd_ug_terminate_popup_cb, (void*) ugd); - else - evas_object_smart_callback_add(btn, "clicked", _wfd_ug_warn_popup_cb, (void*) ugd); - - evas_object_show(popup); - ugd->warn_popup = popup; - __FUNC_EXIT__; -} - -void wfg_ug_warn_popup_remove(void *data) -{ - __FUNC_ENTER__; - struct ug_data *ugd = (struct ug_data *) data; - - if (ugd->warn_popup) - { - evas_object_del(ugd->warn_popup); - ugd->warn_popup = NULL; - } - __FUNC_EXIT__; -} diff --git a/ugapp-wifidirect/CMakeLists.txt b/ugapp-wifidirect/CMakeLists.txt new file mode 100755 index 0000000..de7d5ee --- /dev/null +++ b/ugapp-wifidirect/CMakeLists.txt @@ -0,0 +1,41 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(wifi-direct-ugapp C) +SET(PACKAGE_NAME org.tizen.wifi-direct-ugapp) + +SET(PREFIX /opt/apps/${PACKAGE_NAME}) +SET(BINDIR "${PREFIX}/bin") +SET(RESDIR "${PREFIX}/res") +SET(LOCALEDIR "${RESDIR}/locale") +SET(EDJDIR "${RESDIR}/edje") +SET(IMGDIR "${RESDIR}/images") + +SET(SRCS + src/wfd-ugapp-main.c + src/wfd-ugapp-util.c +) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) + + +SET(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -DVITA_FEATURE") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") +SET(CMAKE_C_FLAGS_RELEASE "-O2") + +IF("${ARCH}" STREQUAL "arm") + ADD_DEFINITIONS("-DTARGET") + MESSAGE("add -DTARGET") +ENDIF("${ARCH}" STREQUAL "arm") + +ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") +ADD_DEFINITIONS("-DRESDIR=\"${RESDIR}\"") + +ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS}) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR}) + +#CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${PACKAGE_NAME}.desktop.in ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}.desktop) +#INSTALL(FILES ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}.desktop DESTINATION /opt/share/applications) +#for appfw new manifest +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${PACKAGE_NAME}.xml ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}.xml) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PACKAGE_NAME}.xml DESTINATION "/opt/share/packages/") diff --git a/ugapp-wifidirect/include/wfd-ugapp-util.h b/ugapp-wifidirect/include/wfd-ugapp-util.h new file mode 100755 index 0000000..ec6ebd5 --- /dev/null +++ b/ugapp-wifidirect/include/wfd-ugapp-util.h @@ -0,0 +1,77 @@ +/* +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd + +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license + +* 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. +* +*/ + +/** + * This file declares wifi direct application util functions. + * + * @file wfd-app-util.h + * @author Sungsik Jang (sungsik.jang@samsung.com) + * @version 0.1 + */ + + +#ifndef __WFD_APP_UTIL_H__ +#define __WFD_APP_UTIL_H__ + + +#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5] +#define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x" + +#ifdef VITA_FEATURE +#include + +#define WIFI_DIRECT_APP_MID "wfd-ugapp" + +#define WFD_APP_LOG_LOW LOG_VERBOSE +#define WFD_APP_LOG_HIGH LOG_INFO +#define WFD_APP_LOG_ERROR LOG_ERROR +#define WFD_APP_LOG_WARN LOG_WARN +#define WFD_APP_LOG_ASSERT LOG_FATAL +#define WFD_APP_LOG_EXCEPTION LOG_FATAL +#define WFD_MAX_SIZE 128 +#define WFD_MAC_ADDRESS_SIZE 18 + +char * wfd_app_trim_path(const char* filewithpath); +int wfd_app_gettid(); + +#define WFD_APP_LOG(log_level, format, args...) \ + LOG(log_level, WIFI_DIRECT_APP_MID, "[%s:%04d,%d] " format, wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),##args) +#define __WFD_APP_FUNC_ENTER__ LOG(LOG_VERBOSE, WIFI_DIRECT_APP_MID, "[%s:%04d,%d] Enter: %s()\n", wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),__func__) +#define __WFD_APP_FUNC_EXIT__ LOG(LOG_VERBOSE, WIFI_DIRECT_APP_MID, "[%s:%04d,%d] Quit: %s()\n", wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),__func__) + +#else /** _DLOG_UTIL */ + +#define WFD_APP_LOG(log_level, format, args...) printf("[%s:%04d,%d] " format, wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(), ##args) +#define __WFD_APP_FUNC_ENTER__ printf("[%s:%04d,%d] Entering: %s()\n", wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),__func__) +#define __WFD_APP_FUNC_EXIT__ printf("[%s:%04d,%d] Quit: %s()\n", wfd_app_trim_path(__FILE__), __LINE__,wfd_app_gettid(),__func__) + +#endif /** _USE_DLOG_UTIL */ + + + +#define assertm_if(expr, fmt, arg...) do { \ + if(expr) { \ + WFD_APP_LOG(WFD_APP_LOG_ASSERT, " ##(%s) -> %s() assert!!## "fmt, #expr, __FUNCTION__, ##arg); \ + exit(1); \ + } \ +} while (0) // retvm if + + + +#endif /* __WFD_APP_UTIL_H__ */ diff --git a/ugapp-wifidirect/include/wfd-ugapp.h b/ugapp-wifidirect/include/wfd-ugapp.h new file mode 100755 index 0000000..96c3d47 --- /dev/null +++ b/ugapp-wifidirect/include/wfd-ugapp.h @@ -0,0 +1,48 @@ +/* +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd + +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license + +* 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. +* +*/ + +/** + * This file declares wifi direct application functions. + * + * @file wfd-app.h + * @author Sungsik Jang (sungsik.jang@samsung.com) + * @version 0.1 + */ + + +#ifndef __WFD_UG_APP_MAIN_H__ +#define __WFD_UG_APP_MAIN_H__ + +#include +#include +#include +#include +#include + + +#define PACKAGE "org.tizen.wifi-direct-ugapp" +#define LOCALEDIR "/opt/apps/org.tizen.wifi-direct-ugapp" + +typedef struct +{ + Evas_Object *win; + struct ui_gadget *wifi_direct_ug; +} wfd_appdata_t; + +#endif /* __WFD_UG_APP_MAIN_H__ */ diff --git a/ugapp-wifidirect/org.tizen.wifi-direct-ugapp.xml b/ugapp-wifidirect/org.tizen.wifi-direct-ugapp.xml new file mode 100755 index 0000000..94e77be --- /dev/null +++ b/ugapp-wifidirect/org.tizen.wifi-direct-ugapp.xml @@ -0,0 +1,11 @@ + + + + Sungsik Jang + Dongwook Lee + WiFi Direct UG Application + + + + + diff --git a/ugapp-wifidirect/src/wfd-ugapp-main.c b/ugapp-wifidirect/src/wfd-ugapp-main.c new file mode 100755 index 0000000..b0d35d6 --- /dev/null +++ b/ugapp-wifidirect/src/wfd-ugapp-main.c @@ -0,0 +1,238 @@ +/* +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd + +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license + +* 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. +* +*/ + +/** + * This file implements wifi direct application main functions. + * + * @file wfd-ug-app-main.c + * @author Dongwook Lee (dwmax.lee@samsung.com) + * @version 0.1 + */ + +#include +#include + +#include "wfd-ugapp.h" +#include "wfd-ugapp-util.h" + + +wfd_appdata_t *g_wfd_ad = NULL; +static struct ug_cbs wifi_direct_cbs; + +wfd_appdata_t *wfd_get_appdata() +{ + return g_wfd_ad; +} + +void +_ug_layout_cb(struct ui_gadget *ug, enum ug_mode mode, void *priv) +{ + __WFD_APP_FUNC_ENTER__; + + Evas_Object *base = NULL; + base = ug_get_layout(ug); + + if (!base) + { + WFD_APP_LOG(WFD_APP_LOG_LOW,"ug_get_layout failed!"); + ug_destroy(ug); + return; + } + + switch (mode) + { + case UG_MODE_FULLVIEW: + evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(ug_get_window(), base); + evas_object_show(base); + break; + default: + break; + } +} + +void +_ug_destroy_cb(struct ui_gadget *ug, void *priv) +{ + __WFD_APP_FUNC_ENTER__; + + // TODO: free all memory allocation + + ug_destroy(ug); + elm_exit(); +} + +void ug_result_cb(struct ui_gadget *ug, bundle * result, void *priv) +{ + __WFD_APP_FUNC_ENTER__; + + // TODO: free all memory allocation + +} + +static int load_wifi_direct_ug(struct ui_gadget *parent_ug, void *data) +{ + __WFD_APP_FUNC_ENTER__; + wfd_appdata_t *ugd = (wfd_appdata_t *)data; + bundle *param = NULL; + + UG_INIT_EFL(ugd->win, UG_OPT_INDICATOR_ENABLE); + + memset(&wifi_direct_cbs, 0, sizeof(struct ug_cbs)); + + wifi_direct_cbs.layout_cb = _ug_layout_cb; + wifi_direct_cbs.result_cb = ug_result_cb; + wifi_direct_cbs.destroy_cb = _ug_destroy_cb; + wifi_direct_cbs.priv = ugd; + + ugd->wifi_direct_ug = ug_create(parent_ug, "setting-wifidirect-efl", UG_MODE_FULLVIEW, param, &wifi_direct_cbs); + if (ugd->wifi_direct_ug) + return TRUE; + else + return FALSE; +} + + +static void _win_del(void *data, Evas_Object * obj, void *event) +{ + elm_exit(); +} + +static Evas_Object *_create_win(Evas_Object * parent, const char *name) +{ + Evas_Object *eo; + int w, h; + + eo = elm_win_add(parent, name, ELM_WIN_BASIC); + if (eo) + { + elm_win_title_set(eo, name); + elm_win_borderless_set(eo, EINA_TRUE); + elm_win_alpha_set(eo, EINA_TRUE); + evas_object_smart_callback_add(eo, "delete,request", _win_del, NULL); + ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h); + evas_object_resize(eo, w, h); + evas_object_show(eo); + //evas_object_raise(eo); + } + + return eo; +} + + +static int _app_create(void *data) +{ + __WFD_APP_FUNC_ENTER__; + + wfd_appdata_t *ad = wfd_get_appdata(); + + if (data == NULL) + { + WFD_APP_LOG(WFD_APP_LOG_LOW, "Incorrect parameter\n"); + return -1; + } + + bindtextdomain(PACKAGE, LOCALEDIR); + + ad->win = _create_win(NULL, PACKAGE); + elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW); + + int r; + + if (!ecore_x_display_get()) + return -1; + + r = appcore_set_i18n(PACKAGE, NULL); + if (r != 0) + { + WFD_APP_LOG(WFD_APP_LOG_LOW, "appcore_set_i18n error\n"); + return -1; + } + + __WFD_APP_FUNC_EXIT__; + + return 0; +} + +static int _app_terminate(void *data) +{ + __WFD_APP_FUNC_ENTER__; + + if (data == NULL) + { + WFD_APP_LOG(WFD_APP_LOG_ERROR, "Incorrect parameter\n"); + return -1; + } + + wfd_appdata_t *ad = (wfd_appdata_t *) data; + + if (ad->win) + { + evas_object_del(ad->win); + ad->win = NULL; + } + + __WFD_APP_FUNC_EXIT__; + + return 0; +} + +static int _app_pause(void *data) +{ + __WFD_APP_FUNC_ENTER__; + __WFD_APP_FUNC_EXIT__; + return 0; +} + +static int _app_resume(void *data) +{ + __WFD_APP_FUNC_ENTER__; + __WFD_APP_FUNC_EXIT__; + return 0; +} + +static int _app_reset(bundle * b, void *data) +{ + __WFD_APP_FUNC_ENTER__; + + wfd_appdata_t *ad = wfd_get_appdata(); + + load_wifi_direct_ug(NULL, ad); + + __WFD_APP_FUNC_EXIT__; + return 0; +} + +int main(int argc, char *argv[]) +{ + wfd_appdata_t ad; + struct appcore_ops ops = { + .create = _app_create, + .terminate = _app_terminate, + .pause = _app_pause, + .resume = _app_resume, + .reset = _app_reset, + }; + + memset(&ad, 0x0, sizeof(wfd_appdata_t)); + ops.data = &ad; + g_wfd_ad = &ad; + + return appcore_efl_main(PACKAGE, &argc, &argv, &ops); +} diff --git a/ugapp-wifidirect/src/wfd-ugapp-util.c b/ugapp-wifidirect/src/wfd-ugapp-util.c new file mode 100644 index 0000000..94fb896 --- /dev/null +++ b/ugapp-wifidirect/src/wfd-ugapp-util.c @@ -0,0 +1,76 @@ +/* +* WiFi-Direct UG +* +* Copyright 2012 Samsung Electronics Co., Ltd + +* Licensed under the Flora License, Version 1.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.tizenopensource.org/license + +* 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. +* +*/ + +/** + * This file implements wifi direct application utils functions. + * + * @file wfd-app-util.c + * @author Sungsik Jang (sungsik.jang@samsung.com) + * @version 0.1 + */ + + +#include +#include +#include "wfd-ugapp-util.h" + + +char *wfd_app_trim_path(const char *filewithpath) +{ +#if 0 + char *filename = NULL; + if ((filename = strrchr(filewithpath, '/')) == NULL) + return (char *) filewithpath; + else + return (filename + 1); +#else + static char *filename[100]; + char *strptr = NULL; + int start = 0; + const char *space = " "; + int len = strlen(filewithpath); + + if (len > 20) + { + strptr = (char *) filewithpath + (len - 20); + start = 0; + } + else if (len < 20) + { + strptr = (char *) filewithpath; + start = 20 - len; + } + strncpy((char *) filename, space, strlen(space)); + strncpy((char *) filename + start, strptr, 50); + + return (char *) filename; +#endif +} + + +int wfd_app_gettid() +{ +#ifdef __NR_gettid + return syscall(__NR_gettid); +#else + fprintf(stderr, + "__NR_gettid is not defined, please include linux/unistd.h "); + return -1; +#endif +}