--- /dev/null
+Danny Jeongseok Seo <s.seo@samsung.com>
+Jeik Jaehyun Kim <jeik01.kim@samsung.com>
+Sunkey Lee <yuvjjang.lee@samsung.com>
+Sanghoon Cho <sanghoon80.cho@samsung.com>
+DongHoo Park <donghoo.park@samsung.com>
\ No newline at end of file
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(net-config C)
+SET(VENDOR "samsung")
+SET(PACKAGE ${PROJECT_NAME})
+SET(PKGNAME "com.${VENDOR}.${PACKAGE}")
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(BINDIR "${PREFIX}/sbin")
+SET(DATADIR "${PREFIX}/share")
+SET(LIBDIR "${PREFIX}/lib")
+# SET(PROFDIR "${PREFIX}/var/lib/${PROJECT_NAME}")
+
+SET(SRCS
+ src/main.c
+ src/dbus.c
+ src/util.c
+ src/neterror.c
+ src/emulator.c
+ src/wifi-power.c
+ src/wifi-state.c
+ src/wifi-indicator.c
+ src/signal-handler.c
+ src/network-state.c
+ src/wifi-background-scan.c
+ )
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+ SET(CMAKE_BUILD_TYPE "Release")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(pkgs REQUIRED
+ dbus-1
+ glib-2.0
+ dbus-glib-1
+ vconf
+ dlog
+ wifi-direct
+ syspopup-caller)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m"
+OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+ ADD_DEFINITIONS("-DEMBEDDED_TARGET")
+ MESSAGE("add -DEMBEDDED_TARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DVENDOR=\"${VENDOR}\"")
+ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"")
+ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"")
+ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"")
+ADD_DEFINITIONS("-DPROFILE_DIR=\"${PROFDIR}\"")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+
+ADD_CUSTOM_TARGET(netconfig-iface-network-state-glue.h
+ COMMAND dbus-binding-tool --mode=glib-server --prefix=netconfig_iface_network_state
+ --output=${CMAKE_SOURCE_DIR}/include/netconfig-iface-network-state-glue.h
+ ${CMAKE_SOURCE_DIR}/interfaces/netconfig-iface-network-state.xml
+ DEPENDS ${CMAKE_SOURCE_DIR}/interfaces/netconfig-iface-network-state.xml
+)
+ADD_CUSTOM_TARGET(netconfig-iface-wifi-glue.h
+ COMMAND dbus-binding-tool --mode=glib-server --prefix=netconfig_iface_wifi
+ --output=${CMAKE_SOURCE_DIR}/include/netconfig-iface-wifi-glue.h
+ ${CMAKE_SOURCE_DIR}/interfaces/netconfig-iface-wifi.xml
+ DEPENDS ${CMAKE_SOURCE_DIR}/interfaces/netconfig-iface-wifi.xml
+)
+
+ADD_DEPENDENCIES(${PROJECT_NAME} netconfig-iface-network-state-glue.h)
+ADD_DEPENDENCIES(${PROJECT_NAME} netconfig-iface-wifi-glue.h)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
--- /dev/null
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+ Apache License\r
+ Version 2.0, January 2004\r
+ http://www.apache.org/licenses/\r
+\r
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+ 1. Definitions.\r
+\r
+ "License" shall mean the terms and conditions for use, reproduction,\r
+ and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+ "Licensor" shall mean the copyright owner or entity authorized by\r
+ the copyright owner that is granting the License.\r
+\r
+ "Legal Entity" shall mean the union of the acting entity and all\r
+ other entities that control, are controlled by, or are under common\r
+ control with that entity. For the purposes of this definition,\r
+ "control" means (i) the power, direct or indirect, to cause the\r
+ direction or management of such entity, whether by contract or\r
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+ outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+ "You" (or "Your") shall mean an individual or Legal Entity\r
+ exercising permissions granted by this License.\r
+\r
+ "Source" form shall mean the preferred form for making modifications,\r
+ including but not limited to software source code, documentation\r
+ source, and configuration files.\r
+\r
+ "Object" form shall mean any form resulting from mechanical\r
+ transformation or translation of a Source form, including but\r
+ not limited to compiled object code, generated documentation,\r
+ and conversions to other media types.\r
+\r
+ "Work" shall mean the work of authorship, whether in Source or\r
+ Object form, made available under the License, as indicated by a\r
+ copyright notice that is included in or attached to the work\r
+ (an example is provided in the Appendix below).\r
+\r
+ "Derivative Works" shall mean any work, whether in Source or Object\r
+ form, that is based on (or derived from) the Work and for which the\r
+ editorial revisions, annotations, elaborations, or other modifications\r
+ represent, as a whole, an original work of authorship. For the purposes\r
+ of this License, Derivative Works shall not include works that remain\r
+ separable from, or merely link (or bind by name) to the interfaces of,\r
+ the Work and Derivative Works thereof.\r
+\r
+ "Contribution" shall mean any work of authorship, including\r
+ the original version of the Work and any modifications or additions\r
+ to that Work or Derivative Works thereof, that is intentionally\r
+ submitted to Licensor for inclusion in the Work by the copyright owner\r
+ or by an individual or Legal Entity authorized to submit on behalf of\r
+ the copyright owner. For the purposes of this definition, "submitted"\r
+ means any form of electronic, verbal, or written communication sent\r
+ to the Licensor or its representatives, including but not limited to\r
+ communication on electronic mailing lists, source code control systems,\r
+ and issue tracking systems that are managed by, or on behalf of, the\r
+ Licensor for the purpose of discussing and improving the Work, but\r
+ excluding communication that is conspicuously marked or otherwise\r
+ designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+ "Contributor" shall mean Licensor and any individual or Legal Entity\r
+ on behalf of whom a Contribution has been received by Licensor and\r
+ subsequently incorporated within the Work.\r
+\r
+ 2. Grant of Copyright License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ copyright license to reproduce, prepare Derivative Works of,\r
+ publicly display, publicly perform, sublicense, and distribute the\r
+ Work and such Derivative Works in Source or Object form.\r
+\r
+ 3. Grant of Patent License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ (except as stated in this section) patent license to make, have made,\r
+ use, offer to sell, sell, import, and otherwise transfer the Work,\r
+ where such license applies only to those patent claims licensable\r
+ by such Contributor that are necessarily infringed by their\r
+ Contribution(s) alone or by combination of their Contribution(s)\r
+ with the Work to which such Contribution(s) was submitted. If You\r
+ institute patent litigation against any entity (including a\r
+ cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+ or a Contribution incorporated within the Work constitutes direct\r
+ or contributory patent infringement, then any patent licenses\r
+ granted to You under this License for that Work shall terminate\r
+ as of the date such litigation is filed.\r
+\r
+ 4. Redistribution. You may reproduce and distribute copies of the\r
+ Work or Derivative Works thereof in any medium, with or without\r
+ modifications, and in Source or Object form, provided that You\r
+ meet the following conditions:\r
+\r
+ (a) You must give any other recipients of the Work or\r
+ Derivative Works a copy of this License; and\r
+\r
+ (b) You must cause any modified files to carry prominent notices\r
+ stating that You changed the files; and\r
+\r
+ (c) You must retain, in the Source form of any Derivative Works\r
+ that You distribute, all copyright, patent, trademark, and\r
+ attribution notices from the Source form of the Work,\r
+ excluding those notices that do not pertain to any part of\r
+ the Derivative Works; and\r
+\r
+ (d) If the Work includes a "NOTICE" text file as part of its\r
+ distribution, then any Derivative Works that You distribute must\r
+ include a readable copy of the attribution notices contained\r
+ within such NOTICE file, excluding those notices that do not\r
+ pertain to any part of the Derivative Works, in at least one\r
+ of the following places: within a NOTICE text file distributed\r
+ as part of the Derivative Works; within the Source form or\r
+ documentation, if provided along with the Derivative Works; or,\r
+ within a display generated by the Derivative Works, if and\r
+ wherever such third-party notices normally appear. The contents\r
+ of the NOTICE file are for informational purposes only and\r
+ do not modify the License. You may add Your own attribution\r
+ notices within Derivative Works that You distribute, alongside\r
+ or as an addendum to the NOTICE text from the Work, provided\r
+ that such additional attribution notices cannot be construed\r
+ as modifying the License.\r
+\r
+ You may add Your own copyright statement to Your modifications and\r
+ may provide additional or different license terms and conditions\r
+ for use, reproduction, or distribution of Your modifications, or\r
+ for any such Derivative Works as a whole, provided Your use,\r
+ reproduction, and distribution of the Work otherwise complies with\r
+ the conditions stated in this License.\r
+\r
+ 5. Submission of Contributions. Unless You explicitly state otherwise,\r
+ any Contribution intentionally submitted for inclusion in the Work\r
+ by You to the Licensor shall be under the terms and conditions of\r
+ this License, without any additional terms or conditions.\r
+ Notwithstanding the above, nothing herein shall supersede or modify\r
+ the terms of any separate license agreement you may have executed\r
+ with Licensor regarding such Contributions.\r
+\r
+ 6. Trademarks. This License does not grant permission to use the trade\r
+ names, trademarks, service marks, or product names of the Licensor,\r
+ except as required for reasonable and customary use in describing the\r
+ origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+ 7. Disclaimer of Warranty. Unless required by applicable law or\r
+ agreed to in writing, Licensor provides the Work (and each\r
+ Contributor provides its Contributions) on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+ implied, including, without limitation, any warranties or conditions\r
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+ PARTICULAR PURPOSE. You are solely responsible for determining the\r
+ appropriateness of using or redistributing the Work and assume any\r
+ risks associated with Your exercise of permissions under this License.\r
+\r
+ 8. Limitation of Liability. In no event and under no legal theory,\r
+ whether in tort (including negligence), contract, or otherwise,\r
+ unless required by applicable law (such as deliberate and grossly\r
+ negligent acts) or agreed to in writing, shall any Contributor be\r
+ liable to You for damages, including any direct, indirect, special,\r
+ incidental, or consequential damages of any character arising as a\r
+ result of this License or out of the use or inability to use the\r
+ Work (including but not limited to damages for loss of goodwill,\r
+ work stoppage, computer failure or malfunction, or any and all\r
+ other commercial damages or losses), even if such Contributor\r
+ has been advised of the possibility of such damages.\r
+\r
+ 9. Accepting Warranty or Additional Liability. While redistributing\r
+ the Work or Derivative Works thereof, You may choose to offer,\r
+ and charge a fee for, acceptance of support, warranty, indemnity,\r
+ or other liability obligations and/or rights consistent with this\r
+ License. However, in accepting such obligations, You may act only\r
+ on Your own behalf and on Your sole responsibility, not on behalf\r
+ of any other Contributor, and only if You agree to indemnify,\r
+ defend, and hold each Contributor harmless for any liability\r
+ incurred by, or claims asserted against, such Contributor by reason\r
+ of your accepting any such warranty or additional liability.\r
+\r
+ END OF TERMS AND CONDITIONS\r
+\r
+ APPENDIX: How to apply the Apache License to your work.\r
+\r
+ To apply the Apache License to your work, attach the following\r
+ boilerplate notice, with the fields enclosed by brackets "[]"\r
+ replaced with your own identifying information. (Don't include\r
+ the brackets!) The text should be enclosed in the appropriate\r
+ comment syntax for the file format. We also recommend that a\r
+ file or class name and description of purpose be included on the\r
+ same "printed page" as the copyright notice for easier\r
+ identification within third-party archives.\r
+\r
+ Copyright [yyyy] [name of copyright owner]\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
--- /dev/null
+net-config (0.1.74) unstable; urgency=low
+
+ * Fix Wi-Fi power bug when Wi-Fi direct is on
+ * Git: pkgs/n/net-config
+ * Tag: net-config_0.1.74
+
+ -- Sanghoon Cho <sanghoon80.cho@samsung.com> Thu, 12 Apr 2012 22:06:27 +0900
+
+net-config (0.1.73) unstable; urgency=low
+
+ * Fix Wi-Fi tethering state bugs
+ * Git: pkgs/n/net-config
+ * Tag: net-config_0.1.73
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com> Mon, 02 Apr 2012 17:27:06 +0900
+
+net-config (0.1.72) unstable; urgency=low
+
+ * Fix emulator proxy setting
+ * Git: pkgs/n/net-config
+ * Tag: net-config_0.1.72
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com> Thu, 29 Mar 2012 10:45:15 +0900
+
+net-config (0.1.71) unstable; urgency=low
+
+ * Enable DBus auto-activation
+ * Git: pkgs/n/net-config
+ * Tag: net-config_0.1.71
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 27 Mar 2012 14:01:40 +0900
+
+net-config (0.1.70) unstable; urgency=low
+
+ * Implement Wi-Fi device picker service
+ * Git: pkgs/n/net-config
+ * Tag: net-config_0.1.70
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com> Fri, 23 Mar 2012 19:28:01 +0900
+
+net-config (0.1.69) unstable; urgency=low
+
+ * Change alert popup name to "net-popup"
+ * Git: pkgs/n/net-config
+ * Tag: net-config_0.1.69
+
+ -- Sunkey Lee <yuvjjang.lee@samsung.com> Fri, 16 Mar 2012 10:21:53 +0900
+
+net-config (0.1.68) unstable; urgency=low
+
+ * Revise Network State update DBus interface name (object path)
+ * Git: pkgs/n/net-config
+ * Tag: net-config_0.1.68
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com> Thu, 15 Mar 2012 13:33:17 +0900
+
+net-config (0.1.67) unstable; urgency=low
+
+ * Write update default connection information
+ * Git: pkgs/n/net-config
+ * Tag: net-config_0.1.67
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com> Wed, 14 Mar 2012 21:31:57 +0900
+
+net-config (0.1.66) unstable; urgency=low
+
+ * Write initial Network Configuration Module based on exist sonet
+ * Git: pkgs/n/net-config
+ * Tag: net-config_0.1.66
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com> Wed, 14 Mar 2012 19:00:26 +0900
+
+net-config (0.1.65) unstable; urgency=low
+
+ * Fix network status update
+ * Git: pkgs/n/net-config
+ * Tag: net-config_0.1.65
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com> Thu, 08 Mar 2012 22:17:24 +0900
+
+net-config (0.1.64) unstable; urgency=low
+
+ * Fix vconf memory backend to be installed
+ * Git: pkgs/n/net-config
+ * Tag: net-config_0.1.64
+
+ -- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 06 Mar 2012 21:11:08 +0900
+
+sonet (0.1.0) unstable; urgency=low
+
+ * Initial Release
+
+ -- DongHoo Park <donghoo.park@samsung.com> Tue, 23 Aug 2011 11:22:04 +0900
--- /dev/null
+Source: net-config
+Section: net
+Priority: extra
+Maintainer: Danny Jeongseok Seo <s.seo@samsung.com>
+Uploaders: Danny Jeongseok Seo <s.seo@samsung.com>, Jeik Jaehyun Kim <jeik01.kim@samsung.com>, Misun Kim <ms0123.kim@samsung.com>, Sunkey Lee <yuvjjang.lee@samsung.com>, Sanghoon Cho <sanghoon80.cho@samsung.com>
+Build-Depends: debhelper (>= 5), libdbus-1-dev (>= 1.1.1), libglib2.0-dev, libdbus-glib-1-dev, dlog-dev, syspopup-caller-dev, libwifi-direct-dev
+Standards-Version: 3.7.2
+
+Package: net-config
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: TIZEN Network Configuration Module
+
+Package: net-config-dbg
+Architecture: any
+Depends: net-config (= ${Source-Version}), ${shlibs:Depends}, ${misc:Depends}
+Description: debug symbols for TIZEN Network Configuration Module
--- /dev/null
+@PREFIX@/sbin/*
+@PREFIX@/share/dbus-1/services/*
+@PREFIX@/etc/dbus-1/system.d/*
+/opt/etc/resolv.conf
+/etc/rc.d/init.d/net-config
+/etc/rc.d/rc3.d/S60net-config
+/etc/rc.d/rc5.d/S60net-config
--- /dev/null
+#!/bin/sh
+
+vconftool set -t int memory/dnet/state 0 -i
+vconftool set -t int memory/wifi/state 0 -i
+vconftool set -t int memory/wifi/strength 0 -i
+
+vconftool set -t int memory/dnet/cellular 0 -i
+vconftool set -t int memory/dnet/wifi 0 -i
+vconftool set -t int memory/dnet/network_config 0 -i
+vconftool set -t int memory/dnet/status 0 -i
+vconftool set -t string memory/dnet/ip "" -i
+vconftool set -t string memory/dnet/proxy "" -i
+
+vconftool set -t string memory/wifi/connected_ap_name "" -i
+
+#Default Call Statistics
+vconftool set -t int db/dnet/statistics/cellular/totalsnt "0"
+vconftool set -t int db/dnet/statistics/cellular/totalrcv "0"
+vconftool set -t int db/dnet/statistics/cellular/lastsnt "0"
+vconftool set -t int db/dnet/statistics/cellular/lastrcv "0"
+vconftool set -t int db/dnet/statistics/wifi/totalsnt "0"
+vconftool set -t int db/dnet/statistics/wifi/totalrcv "0"
+vconftool set -t int db/dnet/statistics/wifi/lastsnt "0"
+vconftool set -t int db/dnet/statistics/wifi/lastrcv "0"
+vconftool set -t int db/wifi/LastPowerOnState "0"
+
+#Change File Permission
+#Resource
+chmod 644 /opt/etc/resolv.conf
+
--- /dev/null
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+CFLAGS += -g -rdynamic
+CFLAGS += -Wall -Werror
+LDFLAGS ?=
+PREFIX ?= /usr
+DATADIR ?= /usr/share
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+else
+ CFLAGS += -O2
+endif
+
+LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed
+
+CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ # Add here commands to configure the package.
+ mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && \
+ CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" cmake .. -DCMAKE_INSTALL_PREFIX="$(PREFIX)"
+
+ touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp
+ dh_testdir
+
+ # Add here commands to compile the package.
+ cd $(CMAKE_BUILD_DIR) && $(MAKE)
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ cat $$f > $${f%.in}; \
+ sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
+ sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
+ done
+
+ touch $@
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp configure-stamp
+ rm -f $(CURDIR)/src/*.service
+ rm -f $(CURDIR)/include/*-glue.h
+
+ # Add here commands to clean up after the build process.
+ rm -rf $(CMAKE_BUILD_DIR)
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ rm -f $${f%.in}; \
+ done
+
+ rm -f ../net-config_*.deb
+ rm -f ../net-config-*.deb
+ rm -f ../net-config_*.changes
+ rm -f ../net-config_*.dsc
+ rm -f ../net-config_*.tar.gz
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package into debian/wavplayer.
+ cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+ mkdir -p $(CURDIR)/debian/tmp$(PREFIX)/share/dbus-1/services
+ cp -f $(CURDIR)/resources$(PREFIX)/share/dbus-1/services/net.netconfig.service \
+ $(CURDIR)/debian/tmp$(PREFIX)/share/dbus-1/services/net.netconfig.service
+ mkdir -p $(CURDIR)/debian/tmp$(PREFIX)/etc/dbus-1/system.d
+ cp -f $(CURDIR)/resources$(PREFIX)/etc/dbus-1/system.d/net-config.conf \
+ $(CURDIR)/debian/tmp$(PREFIX)/etc/dbus-1/system.d/net-config.conf
+ mkdir -p $(CURDIR)/debian/tmp/opt/etc
+ cp -f $(CURDIR)/resources/opt/etc/resolv.conf $(CURDIR)/debian/tmp/opt/etc/resolv.conf
+ mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/init.d
+ cp -f $(CURDIR)/resources/etc/rc.d/init.d/net-config $(CURDIR)/debian/tmp/etc/rc.d/init.d/net-config
+ mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc3.d
+ ln -s ../init.d/net-config $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/S60net-config
+ mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc5.d
+ ln -s ../init.d/net-config $(CURDIR)/debian/tmp/etc/rc.d/rc5.d/S60net-config
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+# dh_installchangelogs
+# dh_installdocs
+# dh_installexamples
+ dh_install --sourcedir=debian/tmp
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_python
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+# dh_installman
+ dh_link
+ dh_strip --dbg-package=net-config-dbg
+ dh_compress
+ dh_fixperms
+# dh_perl
+ dh_makeshlibs
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
--- /dev/null
+/*\r
+ * Network Configuration Module\r
+ *\r
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: Danny JS Seo <S.Seo@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ *\r
+ */\r
+\r
+#ifndef __NETCONFIG_DBUS_H__\r
+#define __NETCONFIG_DBUS_H__\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+#include <glib.h>\r
+#include <dbus/dbus.h>\r
+#include <dbus/dbus-glib.h>\r
+\r
+#define CONNMAN_SERVICE "net.connman"\r
+#define CONNMAN_PATH "/net/connman"\r
+\r
+#define SUPPLICANT_SERVICE "fi.w1.wpa_supplicant1"\r
+#define SUPPLICANT_INTERFACE "fi.w1.wpa_supplicant1"\r
+#define SUPPLICANT_PATH "/fi/w1/wpa_supplicant1"\r
+#define SUPPLICANT_GLOBAL_INTERFACE "org.freedesktop.DBus.Properties"\r
+\r
+#define CONNMAN_MANAGER_INTERFACE CONNMAN_SERVICE ".Manager"\r
+#define CONNMAN_SERVICE_INTERFACE CONNMAN_SERVICE ".Service"\r
+#define CONNMAN_TECHNOLOGY_INTERFACE CONNMAN_SERVICE ".Technology"\r
+#define CONNMAN_MANAGER_PATH "/"\r
+\r
+#define DBUS_PATH_MAX_BUFLEN 512\r
+#define DBUS_STATE_MAX_BUFLEN 64\r
+\r
+typedef enum {\r
+ NETCONFIG_DBUS_RESULT_GET_BGSCAN_MODE,\r
+ NETCONFIG_DBUS_RESULT_DEFAULT_TECHNOLOGY,\r
+} netconfig_dbus_result_type;\r
+\r
+struct dbus_input_arguments {\r
+ int type;\r
+ void *data;\r
+};\r
+\r
+int netconfig_extract_service_state(DBusMessage *message, char **essid);\r
+int netconfig_extract_services_profile(DBusMessage *message, char **essid);\r
+DBusMessage *netconfig_invoke_dbus_method(const char *dest, DBusConnection *connection,\r
+ const char *path, const char *interface_name, const char *method);\r
+DBusMessage *netconfig_supplicant_invoke_dbus_method(const char *dest,\r
+ DBusConnection *connection,\r
+ const char *path, const char *interface_name,\r
+ const char *method, GList *args);\r
+DBusMessage *netconfig_dbus_send_request(const char *destination, char *param_array[]);\r
+void netconfig_dbus_parse_recursive(DBusMessageIter *iter,\r
+ netconfig_dbus_result_type result_type, void *data);\r
+char *netconfig_dbus_get_string(DBusMessage *msg);\r
+\r
+DBusGConnection *netconfig_setup_dbus(void);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* __NETCONFIG_DBUS_H__ */\r
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __NETCONFIG_EMULATOR_H_
+#define __NETCONFIG_EMULATOR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib.h>
+
+gboolean netconfig_emulator_is_emulated(void);
+void netconfig_emulator_test_and_start(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_EMULATOR_H_ */
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __NETCONFIG_LOG_H__
+#define __NETCONFIG_LOG_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <dlog.h>
+
+#define _SLOG(level, format, arg...) \
+ do { \
+ SLOG(level, "net-config", "(%s:%d)"format"\n", __FILE__, __LINE__, ##arg); \
+ } while(0)
+
+#define _PRT(level, format, arg...) \
+ do { \
+ fprintf(stderr, "["PACKAGE"](%s:%d)"format"\n", __FILE__, __LINE__, ##arg); \
+ } while(0)
+
+#define _NO_LOG(level, format, arg...) do {} while (0)
+#define _LOG _SLOG
+
+#define DBG(format, arg...) _LOG(LOG_DEBUG, format, ##arg)
+#define WARN(format, arg...) _LOG(LOG_WARN, format, ##arg)
+#define INFO(format, arg...) _LOG(LOG_INFO, format, ##arg)
+#define ERR(format, arg...) _LOG(LOG_ERROR, format, ##arg)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_LOG_H__ */
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __NETCONFIG_H__
+#define __NETCONFIG_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define NETCONFIG_SERVICE "net.netconfig"
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_H__ */
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __NETCONFIG_ERROR_H__
+#define __NETCONFIG_ERROR_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "glib.h"
+
+G_BEGIN_DECLS
+
+typedef enum {
+ NETCONFIG_NO_ERROR = 0x00,
+ NETCONFIG_ERROR_INTERNAL = 0x01,
+ NETCONFIG_ERROR_NO_SERVICE = 0x02,
+ NETCONFIG_ERROR_TRASPORT = 0x03,
+ NETCONFIG_ERROR_NO_PROFILE = 0x04,
+ NETCONFIG_ERROR_WRONG_PROFILE = 0x05,
+ NETCONFIG_ERROR_WIFI_DRIVER_FAILURE = 0x06,
+ NETCONFIG_ERROR_SECURITY_RESTRICTED = 0x07,
+ NETCONFIG_ERROR_MAX = 0x08,
+} NETCONFIG_ERROR;
+
+GQuark netconfig_error_quark(void);
+
+#define NETCONFIG_ERROR_QUARK (netconfig_error_quark())
+
+G_END_DECLS
+
+#ifdef __cplusplus
+}
+#endif
+
+void netconfig_error_wifi_driver_failed(GError **error);
+void netconfig_error_security_restricted(GError **error);
+void netconfig_error_wifi_direct_failed(GError **error);
+
+#endif /* __NETCONFIG_ERROR_H__ */
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __NETCONFIG_NETWORK_STATE_H__
+#define __NETCONFIG_NETWORK_STATE_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib-object.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+typedef struct NetconfigNetworkState NetconfigNetworkState;
+typedef struct NetconfigNetworkStateClass NetconfigNetworkStateClass;
+
+#define NETCONFIG_TYPE_NETWORK_STATE ( netconfig_network_state_get_type() )
+#define NETCONFIG_NETWORK_STATE(obj) ( G_TYPE_CHECK_INSTANCE_CAST( (obj),NETCONFIG_TYPE_NETWORK_STATE, NetconfigNetworkState ) )
+#define NETCONFIG_IS_NETWORK_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE( (obj), NETCONFIG_TYPE_NETWORK_STATE) )
+
+#define NETCONFIG_NETWORK_STATE_CLASS(klass) ( G_TYPE_CHECK_CLASS_CAST( (klass), NETCONFIG_TYPE_NETWORK_STATE, NetconfigNetworkStateClass) )
+#define NETCONFIG_IS_NETWORK_STATE_CLASS(klass) ( G_TYPE_CHECK_CLASS_TYPE( (klass), NETCONFIG_TYPE_NETWORK_STATE) )
+#define NETCONFIG_NETWORK_STATE_GET_CLASS(obj) ( G_TYPE_INSTANCE_GET_CLASS( (obj), NETCONFIG_TYPE_NETWORK_STATE, NetconfigNetworkStateClass ) )
+
+GType netconfig_network_state_get_type(void);
+
+
+gpointer netconfig_network_state_create_and_init(DBusGConnection *conn);
+
+G_END_DECLS
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_NETWORK_STATE_H__ */
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __NETCONFIG_SIGNAL_HANDLER_H__
+#define __NETCONFIG_SIGNAL_HANDLER_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void netconfig_register_signal(void);
+void netconfig_deregister_signal(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_SIGNAL_HANDLER_H__ */
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __NETCONFIG_UTIL_H_
+#define __NETCONFIG_UTIL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib.h>
+
+#include "wifi.h"
+
+void netconfig_start_timer_seconds(int secs,
+ gboolean(*callback) (gpointer), void *user_data, guint *timer_id);
+void netconfig_start_timer(int msecs,
+ gboolean(*callback) (gpointer), void *user_data, guint *timer_id);
+void netconfig_stop_timer(guint *timer_id);
+
+void netconfig_wifi_device_picker_service_start(void);
+void netconfig_wifi_device_picker_service_stop(void);
+
+gboolean netconfig_is_wifi_direct_on(void);
+gboolean netconfig_is_wifi_tethering_on(void);
+
+void netconfig_wifi_check_local_bssid(void);
+gboolean netconfig_execute_file(const char *file_path,
+ char *const args[], char *const env[]);
+
+gboolean netconfig_iface_wifi_launch_direct(NetconfigWifi *wifi, GError **error);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_UTIL_H_ */
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __NETCONFIG_WIFIBACKGROUNDSCAN_H_
+#define __NETCONFIG_WIFIBACKGROUNDSCAN_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void netconfig_wifi_bgscan_start(void);
+void netconfig_wifi_bgscan_stop(void);
+
+gboolean netconfig_iface_wifi_set_bgscan(NetconfigWifi *wifi, guint scan_mode, GError **error);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_WIFIBACKGROUNDSCAN_H_ */
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __NETCONFIG_WIFIINDICATOR_H_
+#define __NETCONFIG_WIFIINDICATOR_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void netconfig_wifi_indicator_start(void);
+void netconfig_wifi_indicator_stop(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_WIFIINDICATOR_H_ */
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __NETCONFIG_WIFISTATE_H_
+#define __NETCONFIG_WIFISTATE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum netconfig_wifi_service_state {
+ NETCONFIG_WIFI_UNKNOWN = 0x00,
+ NETCONFIG_WIFI_IDLE = 0x01,
+ NETCONFIG_WIFI_CONNECTING = 0x02,
+ NETCONFIG_WIFI_CONNECTED = 0x03,
+};
+
+void netconfig_wifi_state_set_service_state(
+ enum netconfig_wifi_service_state state);
+enum netconfig_wifi_service_state
+ netconfig_wifi_state_get_service_state(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_WIFISTATE_H_ */
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __NETCONFIG_WIFI_H__
+#define __NETCONFIG_WIFI_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <glib.h>
+#include <glib-object.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+typedef struct NetconfigWifi NetconfigWifi;
+typedef struct NetconfigWifiClass NetconfigWifiClass;
+
+#define NETCONFIG_TYPE_WIFI (netconfig_wifi_get_type())
+#define NETCONFIG_WIFI(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), NETCONFIG_TYPE_WIFI, NetconfigWifi))
+#define NETCONFIG_IS_WIFI(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NETCONFIG_TYPE_WIFI))
+#define NETCONFIG_WIFI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), NETCONFIG_TYPE_WIFI, NetconfigWifiClass))
+#define NETCONFIG_IS_WIFI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NETCONFIG_TYPE_WIFI))
+#define NETCONFIG_WIFI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), NETCONFIG_TYPE_WIFI, NetconfigWifiClass))
+
+#define VCONF_WIFI_LAST_POWER_ON_STATE "db/wifi/LastPowerOnState"
+
+enum netconfig_wifi_power_state {
+ WIFI_POWER_OFF = 0x00,
+ WIFI_POWER_ON = 0x01,
+};
+
+enum netconfig_wifi_power_triggering_state {
+ WIFI_NON_OF_TRIGGERING = 0x01,
+
+ WIFI_ACTIVATING = 0x02,
+ WIFI_DEACTIVATING = 0x03,
+};
+
+GType netconfig_wifi_get_type(void);
+
+
+gpointer netconfig_wifi_create_and_init(DBusGConnection *conn);
+
+gboolean netconfig_wifi_remove_driver(void);
+
+gboolean netconfig_wifi_enable_technology(void);
+gboolean netconfig_wifi_disable_technology(void);
+void netconfig_wifi_set_power_triggering_state(
+ enum netconfig_wifi_power_triggering_state state);
+enum netconfig_wifi_power_triggering_state
+ netconfig_wifi_get_power_triggering_state(void);
+
+gboolean netconfig_iface_wifi_load_driver(NetconfigWifi *wifi, GError **error);
+gboolean netconfig_iface_wifi_remove_driver(NetconfigWifi *wifi, GError **error);
+
+G_END_DECLS
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __NETCONFIG_WIFI_H__ */
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<node name="/">
+ <interface name="net.netconfig.network">
+ <method name="UpdateDefaultConnectionInfo">
+ <arg type="s" name="connection_type" direction="in" />
+ <arg type="s" name="connection_state" direction="in" />
+ <arg type="s" name="ip_addr" direction="in" />
+ <arg type="s" name="proxy_addr" direction="in" />
+ </method>
+ </interface>
+</node>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<node name="/">
+ <interface name="net.netconfig.wifi">
+ <method name="LoadDriver">
+ </method>
+ <method name="RemoveDriver">
+ </method>
+ <method name="LaunchDirect">
+ </method>
+ <method name="SetBgscan">
+ <arg type="u" name="ScanMode" direction="in"/>
+ </method>
+ <signal name="DriverLoaded">
+ <arg name="mac" type="s"/>
+ </signal>
+ <signal name="PowerOn">
+ <arg name="error" type="s"/>
+ </signal>
+ </interface>
+</node>
\ No newline at end of file
--- /dev/null
+#sbs-git:pkgs/n/net-config
+
+Name: net-config
+Summary: TIZEN Network Configuration Module
+Version: 0.1.74
+Release: 1
+Group: System/Network
+License: Apache License Version 2.0
+Source0: %{name}-%{version}.tar.gz
+
+BuildRequires: cmake
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(dbus-glib-1)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(tapi)
+BuildRequires: pkgconfig(db-util)
+BuildRequires: pkgconfig(wifi-direct)
+BuildRequires: pkgconfig(syspopup-caller)
+
+%description
+TIZEN Network Configuration Module
+
+
+%prep
+%setup -q
+
+%build
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+mkdir -p %{buildroot}/usr/share/dbus-1/services
+cp resources/usr/share/dbus-1/services/net.netconfig.service %{buildroot}/usr/share/dbus-1/services/net.netconfig.service
+mkdir -p %{buildroot}/usr/etc/dbus-1/system.d
+cp resources/usr/etc/dbus-1/system.d/net-config.conf %{buildroot}/usr/etc/dbus-1/system.d/net-config.conf
+mkdir -p %{buildroot}/opt/etc
+cp resources/opt/etc/resolv.conf %{buildroot}/opt/etc/resolv.conf
+mkdir -p %{buildroot}/etc/rc.d/init.d
+cp resources/etc/rc.d/init.d/net-config %{buildroot}/etc/rc.d/init.d/net-config
+mkdir -p %{buildroot}/etc/rc.d/rc3.d
+ln -s ../init.d/net-config %{buildroot}/etc/rc.d/rc3.d/S60net-config
+mkdir -p %{buildroot}/etc/rc.d/rc5.d
+ln -s ../init.d/net-config %{buildroot}/etc/rc.d/rc5.d/S60net-config
+
+
+%post
+
+vconftool set -t int memory/dnet/state 0 -i
+vconftool set -t int memory/wifi/state 0 -i
+vconftool set -t int memory/wifi/strength 0 -i
+
+vconftool set -t int memory/dnet/cellular 0 -i
+vconftool set -t int memory/dnet/wifi 0 -i
+vconftool set -t int memory/dnet/network_config 0 -i
+vconftool set -t int memory/dnet/status 0 -i
+vconftool set -t string memory/dnet/ip "" -i
+vconftool set -t string memory/dnet/proxy "" -i
+
+vconftool set -t string memory/wifi/connected_ap_name "" -i
+
+vconftool set -t string db/wifi/bssid_address ""
+
+#Default Call Statistics
+vconftool set -t int db/dnet/statistics/cellular/totalsnt "0"
+vconftool set -t int db/dnet/statistics/cellular/totalrcv "0"
+vconftool set -t int db/dnet/statistics/cellular/lastsnt "0"
+vconftool set -t int db/dnet/statistics/cellular/lastrcv "0"
+vconftool set -t int db/dnet/statistics/wifi/totalsnt "0"
+vconftool set -t int db/dnet/statistics/wifi/totalrcv "0"
+vconftool set -t int db/dnet/statistics/wifi/lastsnt "0"
+vconftool set -t int db/dnet/statistics/wifi/lastrcv "0"
+vconftool set -t int db/wifi/LastPowerOnState "0"
+
+#Change File Permission
+#Resource
+chmod 644 /opt/etc/resolv.conf
+
+%postun
+
+
+%files
+%defattr(-,root,root,-)
+%{_sbindir}/*
+%{_datadir}/dbus-1/services/*
+/opt/etc/resolv.conf
+%{_prefix}/etc/dbus-1/system.d/*
+%{_sysconfdir}/rc.d/init.d/net-config
+%{_sysconfdir}/rc.d/rc3.d/S60net-config
+%{_sysconfdir}/rc.d/rc5.d/S60net-config
--- /dev/null
+#!/bin/sh
+
+dlogutil -v threadtime -f /var/log/libnetwork.log -r 1000 -n 10 network &
+dlogutil -v threadtime -f /var/log/net-config.log -r 1000 -n 10 net-config &
+
+/usr/sbin/net-config &
--- /dev/null
+search localdomain
+nameserver 127.0.0.1
\ No newline at end of file
--- /dev/null
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <policy user="0">
+ <allow own="net.netconfig"/>
+ <allow send_destination="net.netconfig"/>
+ <allow send_interface="net.netconfig.network"/>
+ <allow send_interface="net.netconfig.wifi"/>
+ </policy>
+ <policy user="5000">
+ <allow own="net.netconfig"/>
+ <allow send_destination="net.netconfig"/>
+ <allow send_interface="net.netconfig.network"/>
+ <allow send_interface="net.netconfig.wifi"/>
+ </policy>
+ <policy at_console="true">
+ <allow send_destination="net.netconfig"/>
+ </policy>
+ <policy context="default">
+ <deny send_destination="net.netconfig"/>
+ </policy>
+</busconfig>
\ No newline at end of file
--- /dev/null
+[D-BUS Service]
+Name=net.netconfig
+Exec=/usr/sbin/net-config
+User=root
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "dbus.h"
+#include "log.h"
+#include "netconfig.h"
+
+#define NETCONFIG_DBUS_REPLY_TIMEOUT (10 * 1000)
+
+#define DBUS_PARAM_TYPE_STRING "string"
+#define DBUS_PARAM_TYPE_INT16 "int16"
+#define DBUS_PARAM_TYPE_UINT16 "uint16"
+#define DBUS_PARAM_TYPE_INT32 "int32"
+#define DBUS_PARAM_TYPE_UINT32 "uint32"
+#define DBUS_PARAM_TYPE_INT64 "int64"
+#define DBUS_PARAM_TYPE_UINT64 "uint64"
+#define DBUS_PARAM_TYPE_DOUBLE "double"
+#define DBUS_PARAM_TYPE_BYTE "byte"
+#define DBUS_PARAM_TYPE_BOOLEAN "boolean"
+#define DBUS_PARAM_TYPE_OBJECT_PATH "objpath"
+
+static int __neconfig_dbus_datatype_from_stringname(const char *Args)
+{
+ int ArgType = 0;
+
+ if (!strcmp(Args, DBUS_PARAM_TYPE_STRING))
+ ArgType = DBUS_TYPE_STRING;
+ else if (!strcmp(Args, DBUS_PARAM_TYPE_INT16))
+ ArgType = DBUS_TYPE_INT16;
+ else if (!strcmp(Args, DBUS_PARAM_TYPE_UINT16))
+ ArgType = DBUS_TYPE_UINT16;
+ else if (!strcmp(Args, DBUS_PARAM_TYPE_INT32))
+ ArgType = DBUS_TYPE_INT32;
+ else if (!strcmp(Args, DBUS_PARAM_TYPE_UINT32))
+ ArgType = DBUS_TYPE_UINT32;
+ else if (!strcmp(Args, DBUS_PARAM_TYPE_INT64))
+ ArgType = DBUS_TYPE_INT64;
+ else if (!strcmp(Args, DBUS_PARAM_TYPE_UINT64))
+ ArgType = DBUS_TYPE_UINT64;
+ else if (!strcmp(Args, DBUS_PARAM_TYPE_DOUBLE))
+ ArgType = DBUS_TYPE_DOUBLE;
+ else if (!strcmp(Args, DBUS_PARAM_TYPE_BYTE))
+ ArgType = DBUS_TYPE_BYTE;
+ else if (!strcmp(Args, DBUS_PARAM_TYPE_BOOLEAN))
+ ArgType = DBUS_TYPE_BOOLEAN;
+ else if (!strcmp(Args, DBUS_PARAM_TYPE_OBJECT_PATH))
+ ArgType = DBUS_TYPE_OBJECT_PATH;
+ else {
+ ERR("Error!!! Unknown Argument Type \"%s\"", Args);
+
+ return -1;
+ }
+
+ return ArgType;
+}
+
+static int __netconfig_dbus_append_argument(DBusMessageIter *iter, int ArgType,
+ const char *Value)
+{
+ double Double = 0;
+ unsigned char ByteValue = 0;
+ dbus_bool_t booleanvalue = 0;
+ dbus_uint16_t Uint16 = 0;
+ dbus_int16_t Int16 = 0;
+ dbus_uint32_t Uint32 = 0;
+ dbus_int32_t Int32 = 0;
+
+ switch (ArgType) {
+ case DBUS_TYPE_BYTE:
+ ByteValue = strtoul(Value, NULL, 0);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, &ByteValue);
+ break;
+
+ case DBUS_TYPE_DOUBLE:
+ Double = strtod(Value, NULL);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_DOUBLE, &Double);
+ break;
+
+ case DBUS_TYPE_INT16:
+ Int16 = strtol(Value, NULL, 0);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_INT16, &Int16);
+ break;
+
+ case DBUS_TYPE_UINT16:
+ Uint16 = strtoul(Value, NULL, 0);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &Uint16);
+ break;
+
+ case DBUS_TYPE_INT32:
+ Int32 = strtol(Value, NULL, 0);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &Int32);
+ break;
+
+ case DBUS_TYPE_UINT32:
+ Uint32 = strtoul(Value, NULL, 0);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &Uint32);
+ break;
+
+ case DBUS_TYPE_STRING:
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &Value);
+ break;
+
+ case DBUS_TYPE_OBJECT_PATH:
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &Value);
+ break;
+
+ case DBUS_TYPE_BOOLEAN:
+ if (strcmp(Value, "true") == 0) {
+ booleanvalue = TRUE;
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &booleanvalue);
+ } else if (strcmp(Value, "false") == 0) {
+ booleanvalue = FALSE;
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &booleanvalue);
+ } else {
+ ERR("Error!!! Expected \"true\" or \"false\" instead of \"%s\"", Value);
+
+ return -1;
+ }
+ break;
+
+ default:
+ ERR("Error!!! Unsupported data ArgType %c", (char)ArgType);
+
+ return -1;
+ }
+
+ return 0;
+}
+
+static int __netconfig_dbus_append_array(DBusMessageIter *iter, int ArgType,
+ const char *Value)
+{
+ const char *Val = NULL;
+ char *DupValue = strdup(Value);
+ Val = strtok(DupValue, ",");
+
+ while (Val != NULL) {
+ if (__netconfig_dbus_append_argument(iter, ArgType, Val) != 0) {
+ g_free(DupValue);
+ DupValue = NULL;
+
+ return -1;
+ }
+
+ Val = strtok(NULL, ",");
+ }
+
+ g_free(DupValue);
+ DupValue = NULL;
+ return 0;
+}
+
+static int __netconfig_dbus_append_dict(DBusMessageIter *iter, int KeyType,
+ int ValueType, const char *Value)
+{
+ const char *Val = NULL;
+ char *DupValue = strdup(Value);
+ Val = strtok(DupValue, ",");
+
+ while (Val != NULL) {
+ DBusMessageIter SubIter;
+ dbus_message_iter_open_container(iter, DBUS_TYPE_DICT_ENTRY,
+ NULL, &SubIter);
+
+ if (__netconfig_dbus_append_argument(&SubIter, KeyType, Val) != 0) {
+ ERR("Error!!! network_append_argument() failed");
+ g_free(DupValue);
+ DupValue = NULL;
+ return -1;
+ }
+
+ Val = strtok(NULL, ",");
+ if (Val == NULL) {
+ ERR("Error!!! Mal-formed dictionary data");
+ g_free(DupValue);
+ DupValue = NULL;
+ return -1;
+ }
+
+ if (__netconfig_dbus_append_argument(&SubIter, ValueType, Val) != 0) {
+ ERR("Error!!! network_append_argument() failed");
+ g_free(DupValue);
+ DupValue = NULL;
+ return -1;
+ }
+
+ dbus_message_iter_close_container(iter, &SubIter);
+
+ Val = strtok(NULL, ",");
+ }
+
+ g_free(DupValue);
+ DupValue = NULL;
+ return 0;
+}
+
+char *netconfig_dbus_get_string(DBusMessage * msg)
+{
+ DBusMessageIter args;
+ char *sigvalue = NULL;
+
+ /** read these parameters */
+ if (!dbus_message_iter_init(msg, &args))
+ DBG("Message does not have parameters");
+ else if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&args))
+ DBG("Argument is not string");
+ else
+ dbus_message_iter_get_basic(&args, &sigvalue);
+
+ return sigvalue;
+}
+
+DBusMessage *netconfig_dbus_send_request(const char *destination, char *param_array[])
+{
+ DBusConnection *connection = NULL;
+ DBusError error;
+ DBusMessage *message = NULL;
+ char *RequestMethod = NULL;
+ int i = 0;
+ const char *path = NULL;
+ const char *name = NULL;
+ int param_count = 0;
+ DBusMessageIter iter;
+ DBusMessage *reply = NULL;
+
+ DBG("Send DBus request to %s", destination);
+
+ for (param_count = 0; param_array[param_count] != NULL;
+ param_count++)
+ DBG("[%s]", param_array[param_count]);
+
+ DBG("Total Arguments [%d]", param_count);
+ path = param_array[i++];
+
+ /** 0th is path */
+ name = param_array[i++];/** 1st is request name */
+ if ((strlen(path) == 0) || (strlen(name) == 0)) {
+ ERR("Error!!! Invalid parameters passed path [%s], request name [%s]",
+ path, name);
+
+ goto end_error;
+ }
+
+ dbus_error_init(&error);
+
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+ if (connection == NULL) {
+ ERR("Error!!! Failed to get system DBus, error [%s]",
+ error.message);
+ dbus_error_free(&error);
+
+ goto end_error;
+ }
+
+ RequestMethod = strrchr(name, '.');
+ if (RequestMethod == NULL) {
+ ERR("Error!!! Invalid method in \"%s\"", name);
+
+ goto end_error;
+ }
+
+ *RequestMethod = '\0';
+ message = dbus_message_new_method_call(NULL, path, name,
+ RequestMethod + 1);
+ if (message == NULL) {
+ ERR("Error!!! dbus_message_new_method_call() failed");
+
+ goto end_error;
+ }
+
+ if (destination && !dbus_message_set_destination(message, destination)) {
+ ERR("Error!!! dbus_message_set_destination() failed");
+
+ goto end_error;
+ }
+
+ dbus_message_iter_init_append(message, &iter);
+
+ /** Two args name and path already extracted, so i == 2 */
+ while (i < param_count) {
+ char *Args = NULL;
+ char *Ch = NULL;
+ int ArgType = 0;
+ int SecondaryType = 0;
+ int ContainerType = 0;
+ DBusMessageIter *TargetIter = NULL;
+ DBusMessageIter ContainerIter;
+ ArgType = DBUS_TYPE_INVALID;
+
+ Args = param_array[i++];
+ Ch = strchr(Args, ':');
+ if (Ch == NULL) {
+ ERR("Error!!! Invalid data format[\"%s\"]", Args);
+
+ goto end_error;
+ }
+
+ *(Ch++) = 0;
+ if (strcmp(Args, "variant") == 0)
+ ContainerType = DBUS_TYPE_VARIANT;
+ else if (strcmp(Args, "array") == 0)
+ ContainerType = DBUS_TYPE_ARRAY;
+ else if (strcmp(Args, "dict") == 0)
+ ContainerType = DBUS_TYPE_DICT_ENTRY;
+ else
+ ContainerType = DBUS_TYPE_INVALID;
+
+ if (ContainerType != DBUS_TYPE_INVALID) {
+ Args = Ch;
+ Ch = strchr(Args, ':');
+ if (Ch == NULL) {
+ ERR("Error!!! Invalid data format[\"%s\"]", Args);
+
+ goto end_error;
+ }
+
+ *(Ch++) = 0;
+ }
+
+ if (Args[0] == 0)
+ ArgType = DBUS_TYPE_STRING;
+ else {
+ ArgType = __neconfig_dbus_datatype_from_stringname(Args);
+
+ if (ArgType == -1) {
+ ERR("Error!!! Unknown data type");
+
+ goto end_error;
+ }
+ }
+
+ if (ContainerType == DBUS_TYPE_DICT_ENTRY) {
+ char Signature[5] = "";
+ Args = Ch;
+ Ch = strchr(Ch, ':');
+ if (Ch == NULL) {
+ ERR("Error!!! Invalid data format[\"%s\"]", Args);
+
+ goto end_error;
+ }
+
+ *(Ch++) = 0;
+ SecondaryType = __neconfig_dbus_datatype_from_stringname(Args);
+ if (SecondaryType == -1) {
+ ERR("Error!!! Unknown data type");
+
+ goto end_error;
+ }
+
+ Signature[0] = DBUS_DICT_ENTRY_BEGIN_CHAR;
+ Signature[1] = ArgType;
+ Signature[2] = SecondaryType;
+ Signature[3] = DBUS_DICT_ENTRY_END_CHAR;
+ Signature[4] = '\0';
+
+ dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+ Signature, &ContainerIter);
+
+ TargetIter = &ContainerIter;
+ } else if (ContainerType != DBUS_TYPE_INVALID) {
+ char Signature[2] = "";
+ Signature[0] = ArgType;
+ Signature[1] = '\0';
+
+ dbus_message_iter_open_container(&iter, ContainerType,
+ Signature, &ContainerIter);
+
+ TargetIter = &ContainerIter;
+ } else
+ TargetIter = &iter;
+
+ if (ContainerType == DBUS_TYPE_ARRAY) {
+ if (__netconfig_dbus_append_array(TargetIter, ArgType, Ch) != 0) {
+ ERR("Error!!! network_append_array() failed");
+
+ goto end_error;
+ }
+ } else if (ContainerType == DBUS_TYPE_DICT_ENTRY) {
+ if (__netconfig_dbus_append_dict(TargetIter, ArgType, SecondaryType, Ch) != 0) {
+ ERR("Error!!! network_append_dict() failed");
+
+ goto end_error;
+ }
+ } else {
+ if (__netconfig_dbus_append_argument(TargetIter, ArgType, Ch) != 0) {
+ ERR("Error!!! network_append_array() failed");
+
+ goto end_error;
+ }
+ }
+
+ if (ContainerType != DBUS_TYPE_INVALID) {
+ dbus_message_iter_close_container(&iter, &ContainerIter);
+ }
+ }
+
+ dbus_error_init(&error);
+
+ reply = dbus_connection_send_with_reply_and_block(connection, message,
+ NETCONFIG_DBUS_REPLY_TIMEOUT, &error);
+
+ if (reply == NULL) {
+ if (dbus_error_is_set(&error) == TRUE) {
+ ERR("Error!!! dbus_connection_send_with_reply_and_block() failed, Error[%s: %s]",
+ error.name, error.message);
+
+ dbus_error_free(&error);
+
+ goto end_error;
+ }
+ }
+
+ dbus_message_unref(message);
+ dbus_connection_unref(connection);
+
+ return reply;
+
+end_error:
+
+ if (message != NULL)
+ dbus_message_unref(message);
+ if (connection != NULL)
+ dbus_connection_unref(connection);
+
+ return NULL;
+}
+
+DBusMessage *netconfig_invoke_dbus_method(const char *dest, DBusConnection *connection,
+ const char *path, const char *interface_name, const char *method)
+{
+ DBusError error;
+ DBusMessage *reply = NULL;
+ DBusMessage *message = NULL;
+
+ message = dbus_message_new_method_call(dest, path, interface_name, method);
+ if (message == NULL) {
+ ERR("Error!!! Failed to GetProperties");
+ return NULL;
+ }
+
+ dbus_error_init(&error);
+
+ reply = dbus_connection_send_with_reply_and_block(connection, message,
+ NETCONFIG_DBUS_REPLY_TIMEOUT, &error);
+
+ if (reply == NULL) {
+ if (dbus_error_is_set(&error) == TRUE) {
+ ERR("Error!!! dbus_connection_send_with_reply_and_block() failed. DBus error [%s: %s]",
+ error.name, error.message);
+
+ dbus_error_free(&error);
+ } else
+ ERR("Error!!! Failed to get properties");
+
+ dbus_message_unref(message);
+
+ return NULL;
+ }
+
+ dbus_message_unref(message);
+
+ return reply;
+}
+
+void setup_dbus(gpointer data, gpointer user_data)
+{
+ struct dbus_input_arguments *args;
+ DBusMessageIter *iter;
+
+ if (data != NULL && user_data != NULL) {
+ args = (struct dbus_input_arguments *)data;
+ iter = (DBusMessageIter *) user_data;
+
+ dbus_message_iter_append_basic(iter, args->type,
+ &(args->data));
+ }
+}
+
+DBusMessage *netconfig_supplicant_invoke_dbus_method(const char *dest,
+ DBusConnection *connection,
+ const char *path, const char *interface_name,
+ const char *method, GList *args)
+{
+ DBusError error;
+ DBusMessageIter iter;
+ DBusMessage *reply = NULL;
+ DBusMessage *message = NULL;
+
+ message = dbus_message_new_method_call(dest, path, interface_name, method);
+ if (message == NULL) {
+ ERR("Error!!! DBus method call fail");
+ return NULL;
+ }
+
+ dbus_message_iter_init_append(message, &iter);
+
+ if (args != NULL)
+ g_list_foreach(args, setup_dbus, (gpointer) &iter);
+
+ dbus_error_init(&error);
+
+ reply = dbus_connection_send_with_reply_and_block(connection, message,
+ NETCONFIG_DBUS_REPLY_TIMEOUT, &error);
+
+ if (reply == NULL) {
+ if (dbus_error_is_set(&error) == TRUE) {
+ ERR("Error!!! dbus_connection_send_with_reply_and_block() failed. DBus error [%s: %s]",
+ error.name, error.message);
+
+ dbus_error_free(&error);
+ } else
+ ERR("Error!!! Failed to get properties");
+
+ dbus_message_unref(message);
+
+ return NULL;
+ }
+
+ dbus_message_unref(message);
+
+ return reply;
+}
+
+int netconfig_extract_service_state(DBusMessage *message, char **essid)
+{
+ int state = -1;
+ DBusMessageIter iter, array;
+
+ dbus_message_iter_init(message, &iter);
+ dbus_message_iter_recurse(&iter, &array);
+
+ while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter entry, string;
+ const char *key = NULL;
+
+ dbus_message_iter_recurse(&array, &entry);
+ dbus_message_iter_get_basic(&entry, &key);
+
+ if (strcmp(key, "State") == 0 && state - 1) {
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &string);
+
+ if (dbus_message_iter_get_arg_type(&string) == DBUS_TYPE_STRING) {
+ dbus_message_iter_get_basic(&string, &key);
+
+ if (strcmp(key, "ready") == 0 || strcmp(key, "online") == 0) {
+ state = 1;
+ continue;
+ }
+
+ return -1;
+ }
+ } else if (strcmp(key, "Name") == 0 && state == 1) {
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &string);
+
+ if (dbus_message_iter_get_arg_type(&string) == DBUS_TYPE_STRING) {
+ dbus_message_iter_get_basic(&string, &key);
+
+ if (*essid != NULL)
+ return -1;
+
+ *essid = malloc(sizeof(char)*128);
+ strcpy(*essid, key);
+
+ return 0;
+ }
+ }
+
+ dbus_message_iter_next(&array);
+ }
+
+ return -1;
+}
+
+int netconfig_extract_services_profile(DBusMessage *message, char **profile)
+{
+ DBusMessageIter iter, array;
+
+ dbus_message_iter_init(message, &iter);
+ dbus_message_iter_recurse(&iter, &array);
+
+ while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter entry, array2, object_path;
+ const char *key = NULL;
+ const char *temp = NULL;
+
+ dbus_message_iter_recurse(&array, &entry);
+ dbus_message_iter_get_basic(&entry, &key);
+
+ if (strcmp(key, "Services") == 0) {
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &array2);
+
+ if (dbus_message_iter_get_arg_type(&array2) == DBUS_TYPE_ARRAY) {
+ dbus_message_iter_recurse(&array2, &object_path);
+
+ if (dbus_message_iter_get_arg_type(&object_path)
+ == DBUS_TYPE_OBJECT_PATH) {
+ dbus_message_iter_get_basic(&object_path, &temp);
+
+ if (strstr(temp, "wifi_") != NULL) {
+ if (*profile != NULL)
+ return -1;
+
+ *profile = malloc(sizeof(char)*128);
+ strcpy(*profile, temp);
+
+ return 0;
+ }
+ }
+ }
+ }
+
+ dbus_message_iter_next(&array);
+ }
+
+ return -1;
+}
+
+void netconfig_dbus_parse_recursive(DBusMessageIter *iter,
+ netconfig_dbus_result_type result_type, void *data)
+{
+ unsigned char *bgscan_mode = NULL;
+ static dbus_bool_t default_tech_flag = FALSE;
+ char *default_tech = NULL;
+
+ if (result_type == NETCONFIG_DBUS_RESULT_GET_BGSCAN_MODE)
+ bgscan_mode = (unsigned char *)data;
+ else if (result_type == NETCONFIG_DBUS_RESULT_DEFAULT_TECHNOLOGY)
+ default_tech = (char *)data;
+
+ do {
+ int ArgType = dbus_message_iter_get_arg_type(iter);
+
+ if (ArgType == DBUS_TYPE_INVALID)
+ break;
+
+ switch (ArgType) {
+ case DBUS_TYPE_BYTE:
+ {
+ unsigned char Value = 0;
+
+ dbus_message_iter_get_basic(iter, &Value);
+
+ *bgscan_mode = Value;
+ INFO("BG scan mode: %d, %d", *bgscan_mode, Value);
+ break;
+ }
+
+ case DBUS_TYPE_STRING:
+ {
+ char *Value = NULL;
+
+ dbus_message_iter_get_basic(iter, &Value);
+
+ INFO("result type: %d, string: %s", result_type, Value);
+ if (result_type == NETCONFIG_DBUS_RESULT_DEFAULT_TECHNOLOGY) {
+ if (strcmp(Value, "DefaultTechnology") == 0) {
+ default_tech_flag = TRUE;
+ } else {
+ if (default_tech_flag == TRUE) {
+ sprintf(default_tech, "%s", Value);
+ INFO("default technology: %s", default_tech);
+ default_tech_flag = FALSE;
+ }
+ }
+ }
+ break;
+ }
+
+ case DBUS_TYPE_SIGNATURE:
+ {
+ char *Value = NULL;
+
+ dbus_message_iter_get_basic(iter, &Value);
+ break;
+ }
+
+ case DBUS_TYPE_OBJECT_PATH:
+ {
+ char *Value = NULL;
+
+ dbus_message_iter_get_basic(iter, &Value);
+ break;
+ }
+
+ case DBUS_TYPE_INT16:
+ {
+ dbus_int16_t Value = 0;
+
+ dbus_message_iter_get_basic(iter, &Value);
+ break;
+ }
+
+ case DBUS_TYPE_UINT16:
+ {
+ dbus_uint16_t Value = 0;
+
+ dbus_message_iter_get_basic(iter, &Value);
+ break;
+ }
+
+ case DBUS_TYPE_INT32:
+ {
+ dbus_int32_t Value = 0;
+
+ dbus_message_iter_get_basic(iter, &Value);
+ break;
+ }
+
+ case DBUS_TYPE_UINT32:
+ {
+ dbus_uint32_t Value = 0;
+
+ dbus_message_iter_get_basic(iter, &Value);
+ break;
+ }
+
+ case DBUS_TYPE_INT64:
+ {
+ dbus_int64_t Value = 0;
+
+ dbus_message_iter_get_basic(iter, &Value);
+ break;
+ }
+
+ case DBUS_TYPE_UINT64:
+ {
+ dbus_uint64_t Value = 0;
+
+ dbus_message_iter_get_basic(iter, &Value);
+ break;
+ }
+
+ case DBUS_TYPE_DOUBLE:
+ {
+ double Value = 0;
+
+ dbus_message_iter_get_basic(iter, &Value);
+ break;
+ }
+
+ case DBUS_TYPE_BOOLEAN:
+ {
+ dbus_bool_t Value = 0;
+
+ dbus_message_iter_get_basic(iter, &Value);
+ break;
+ }
+
+ case DBUS_TYPE_VARIANT:
+ {
+ DBusMessageIter SubIter;
+
+ dbus_message_iter_recurse(iter, &SubIter);
+ netconfig_dbus_parse_recursive(&SubIter,
+ result_type, data);
+ break;
+ }
+
+ case DBUS_TYPE_ARRAY:
+ {
+ int CurrentType = 0;
+ DBusMessageIter SubIter;
+
+ dbus_message_iter_recurse(iter, &SubIter);
+ CurrentType = dbus_message_iter_get_arg_type(&SubIter);
+
+ while (CurrentType != DBUS_TYPE_INVALID) {
+ netconfig_dbus_parse_recursive(&SubIter,
+ result_type, data);
+
+ dbus_message_iter_next(&SubIter);
+ CurrentType = dbus_message_iter_get_arg_type(&SubIter);
+ }
+ break;
+ }
+
+ case DBUS_TYPE_DICT_ENTRY:
+ {
+ DBusMessageIter SubIter;
+
+ dbus_message_iter_recurse(iter, &SubIter);
+ netconfig_dbus_parse_recursive(&SubIter, result_type, data);
+
+ dbus_message_iter_next(&SubIter);
+ netconfig_dbus_parse_recursive(&SubIter, result_type, data);
+ break;
+ }
+
+ case DBUS_TYPE_STRUCT:
+ {
+ int CurrentType = 0;
+ DBusMessageIter SubIter;
+
+ dbus_message_iter_recurse(iter, &SubIter);
+
+ while ((CurrentType = dbus_message_iter_get_arg_type(&SubIter))
+ != DBUS_TYPE_INVALID) {
+ netconfig_dbus_parse_recursive(&SubIter, result_type, data);
+
+ dbus_message_iter_next(&SubIter);
+ }
+ break;
+ }
+
+ default:
+ ERR("Error!!! Invalid Argument Type [%c]", ArgType);
+ }
+ } while (dbus_message_iter_next(iter));
+}
+
+DBusGConnection *netconfig_setup_dbus(void)
+{
+ DBusGConnection* connection = NULL;
+ GError *error = NULL;
+ DBusGProxy *proxy;
+ guint rv = 0;
+
+ connection = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error);
+ if (connection == NULL) {
+ ERR("Fail to get DBus(%s)", error->message);
+ return connection;
+ }
+
+ INFO("Successfully get system DBus connection(%p)", connection);
+
+ proxy = dbus_g_proxy_new_for_name(connection, "org.freedesktop.DBus",
+ "/org/freedesktop/DBus",
+ "org.freedesktop.DBus");
+
+ if (!dbus_g_proxy_call(proxy, "RequestName", &error,
+ G_TYPE_STRING, NETCONFIG_SERVICE, G_TYPE_UINT, 0,
+ G_TYPE_INVALID, G_TYPE_UINT, &rv,
+ G_TYPE_INVALID)) {
+ ERR("Failed to acquire service(%s) error(%s)",
+ NETCONFIG_SERVICE, error->message);
+
+ dbus_g_connection_unref(connection);
+
+ return NULL;
+ }
+
+ if (rv != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+ ERR("Service name is already in use");
+
+ dbus_g_connection_unref(connection);
+
+ return NULL;
+ }
+
+ return connection;
+}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <arpa/inet.h>
+#include <net/if.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include "log.h"
+#include "emulator.h"
+
+static gboolean netconfig_is_emulated = FALSE;
+
+static gboolean __netconfig_emulator_test_emulation_env(void)
+{
+ /* TODO: this module contains exact keyword of Emulator virtual CPU.
+ * It will be revised with emulator "uname" system information.
+ */
+ const char CPUINFO[] = "/proc/cpuinfo";
+ const char EMUL_VIRTUAL_CPU[] = "QEMU Virtual CPU";
+ const int BUF_LEN_MAX = 255;
+ char buf[BUF_LEN_MAX];
+ char *model_name = NULL;
+ gboolean ret = FALSE;
+ FILE* fp = NULL;
+
+ DBG("Test emulation environment");
+
+ if ((fp = fopen(CPUINFO, "r")) == NULL) {
+ ERR("Failed to open %s", CPUINFO);
+ return FALSE;
+ }
+
+ while (fgets(buf, BUF_LEN_MAX, fp)) {
+ if (g_ascii_strncasecmp(buf, "model name", 10) != 0)
+ continue;
+
+ model_name = g_strstr_len(buf, BUF_LEN_MAX-1, EMUL_VIRTUAL_CPU);
+
+ if (model_name != NULL)
+ ret = TRUE;
+
+ break;
+ }
+
+ fclose(fp);
+
+ return ret;
+}
+
+static void __netconfig_emulator_set_ip(void)
+{
+ const int BUF_LEN_MAX = 255;
+ const char EMUL_IFNAME[] = "eth0";
+ char ip[BUF_LEN_MAX];
+ int sockfd = 0;
+ struct ifreq ifr;
+
+ if ((sockfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
+ ERR("Failed to open socket");
+ return;
+ }
+
+ memset(&ifr, 0, sizeof(struct ifreq));
+ g_strlcpy((char*)&ifr.ifr_name, EMUL_IFNAME, sizeof(EMUL_IFNAME));
+
+ if (ioctl(sockfd, SIOCGIFADDR, &ifr) < 0) {
+ ERR("Error getting IP address");
+
+ close(sockfd);
+ return;
+ }
+
+ g_strlcpy(ip, (char*)inet_ntoa(((struct sockaddr_in*)&ifr.ifr_addr)->sin_addr), BUF_LEN_MAX);
+
+ vconf_set_str(VCONFKEY_NETWORK_IP, ip);
+
+ close(sockfd);
+}
+
+static void __netconfig_emulator_set_proxy(void)
+{
+ const char HTTP_PROXY[] = "http_proxy";
+ char *proxy = NULL;
+
+ proxy = getenv(HTTP_PROXY);
+ DBG("Get system proxy: %s", proxy);
+
+ if(proxy != NULL)
+ vconf_set_str(VCONFKEY_NETWORK_PROXY, proxy);
+}
+
+static void __netconfig_emulator_set_network_state(void)
+{
+ vconf_set_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, 1);
+ vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_CELLULAR);
+ vconf_set_int(VCONFKEY_DNET_STATE, VCONFKEY_DNET_NORMAL_CONNECTED);
+}
+
+static void __netconfig_emulator_config_emul_env(void)
+{
+ __netconfig_emulator_set_ip();
+ __netconfig_emulator_set_proxy();
+ __netconfig_emulator_set_network_state();
+}
+
+gboolean netconfig_emulator_is_emulated(void)
+{
+ return netconfig_is_emulated;
+}
+
+void netconfig_emulator_test_and_start(void)
+{
+ netconfig_is_emulated = __netconfig_emulator_test_emulation_env();
+
+ DBG("Emulation environment tested: %s", netconfig_is_emulated ? "It's emulated" : "Not emulated");
+
+ if (netconfig_is_emulated == TRUE)
+ __netconfig_emulator_config_emul_env();
+}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <unistd.h>
+
+#include "log.h"
+#include "dbus.h"
+#include "wifi.h"
+#include "emulator.h"
+#include "network-state.h"
+#include "signal-handler.h"
+
+static GMainLoop *main_loop = NULL;
+
+int main(int argc, char* argv[])
+{
+ DBusGConnection *connection;
+
+ DBG("Network Configuration Module");
+
+ if (daemon(0, 0) != 0)
+ DBG("Cannot start daemon");
+
+ g_type_init();
+
+ main_loop = g_main_loop_new(NULL, FALSE);
+
+ connection = netconfig_setup_dbus();
+ if (connection == NULL)
+ return -1;
+
+ if (netconfig_network_state_create_and_init(connection) == NULL)
+ return -1;
+
+ netconfig_register_signal();
+
+ if (netconfig_wifi_create_and_init(connection) == NULL)
+ return -1;
+
+ /* If its environment uses Emulator, network configuration is set by emulator default */
+ netconfig_emulator_test_and_start();
+
+ g_main_loop_run(main_loop);
+
+ netconfig_deregister_signal();
+
+ return 0;
+}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <glib.h>
+
+#include "neterror.h"
+#include "netconfig.h"
+
+#define NETCONFIG_ERROR_INTERFACE NETCONFIG_SERVICE ".Error"
+
+GQuark netconfig_error_quark(void)
+{
+ static GQuark quark = 0;
+
+ if (!quark)
+ quark = g_quark_from_static_string("netconfig_error");
+
+ return quark;
+}
+
+void netconfig_error_wifi_driver_failed(GError **error)
+{
+ g_set_error(error, netconfig_error_quark(), NETCONFIG_ERROR_WIFI_DRIVER_FAILURE,
+ NETCONFIG_ERROR_INTERFACE ".WifiDriverFailed");
+}
+
+void netconfig_error_security_restricted(GError **error)
+{
+ g_set_error(error, netconfig_error_quark(), NETCONFIG_ERROR_SECURITY_RESTRICTED,
+ NETCONFIG_ERROR_INTERFACE ".SecurityRestricted");
+}
+
+void netconfig_error_wifi_direct_failed(GError **error)
+{
+ g_set_error(error, netconfig_error_quark(), NETCONFIG_ERROR_WIFI_DRIVER_FAILURE,
+ NETCONFIG_ERROR_INTERFACE ".WifiDirectFailed");
+}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "log.h"
+#include "neterror.h"
+#include "network-state.h"
+
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <syspopup_caller.h>
+
+#define NETCONFIG_NETWORK_STATE_PATH "/net/netconfig/network"
+
+#define PROP_DEFAULT FALSE
+#define PROP_DEFAULT_STR NULL
+
+
+gboolean netconfig_iface_network_state_update_default_connection_info(
+ NetconfigNetworkState *master,
+ gchar *connection_type, gchar *connection_state,
+ gchar *ip_addr, gchar *proxy_addr, GError **error);
+
+#include "netconfig-iface-network-state-glue.h"
+
+enum {
+ PROP_O,
+ PROP_NETWORK_STATE_CONN,
+ PROP_NETWORK_STATE_PATH,
+};
+
+struct NetconfigNetworkStateClass {
+ GObjectClass parent;
+};
+
+struct NetconfigNetworkState {
+ GObject parent;
+
+ DBusGConnection *conn;
+ gchar *path;
+};
+
+G_DEFINE_TYPE(NetconfigNetworkState, netconfig_network_state, G_TYPE_OBJECT);
+
+
+static void __netconfig_network_state_gobject_get_property(GObject *object,
+ guint prop_id, GValue *value, GParamSpec *pspec)
+{
+ return;
+}
+
+static void __netconfig_network_state_gobject_set_property(GObject *object,
+ guint prop_id, const GValue *value, GParamSpec *pspec)
+{
+ NetconfigNetworkState *network_state = NETCONFIG_NETWORK_STATE(object);
+
+ switch (prop_id) {
+ case PROP_NETWORK_STATE_CONN:
+ {
+ network_state->conn = g_value_get_boxed(value);
+ INFO("network_state(%p) set conn(%p)", network_state, network_state->conn);
+ break;
+ }
+
+ case PROP_NETWORK_STATE_PATH:
+ {
+ if (network_state->path)
+ g_free(network_state->path);
+
+ network_state->path = g_value_dup_string(value);
+ INFO("network_state(%p) path(%s)", network_state, network_state->path);
+
+ break;
+ }
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ }
+}
+
+static void netconfig_network_state_init(NetconfigNetworkState *network_state)
+{
+ DBG("network_state initialize");
+
+ network_state->conn = NULL;
+ network_state->path = g_strdup(PROP_DEFAULT_STR);
+}
+
+static void netconfig_network_state_class_init(NetconfigNetworkStateClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ DBG("class initialize");
+
+ object_class->get_property = __netconfig_network_state_gobject_get_property;
+ object_class->set_property = __netconfig_network_state_gobject_set_property;
+
+ /* DBus register */
+ dbus_g_object_type_install_info(NETCONFIG_TYPE_NETWORK_STATE,
+ &dbus_glib_netconfig_iface_network_state_object_info);
+
+ /* property */
+ g_object_class_install_property(object_class, PROP_NETWORK_STATE_CONN,
+ g_param_spec_boxed("conn", "CONNECTION", "DBus connection",
+ DBUS_TYPE_G_CONNECTION,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property(object_class, PROP_NETWORK_STATE_PATH,
+ g_param_spec_string("path", "Path", "Object path",
+ PROP_DEFAULT_STR,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+}
+
+
+static void __netconfig_pop_3g_alert_syspoppup(void)
+{
+ int rv = 0;
+ bundle *b = NULL;
+ int wifi_ug_state = 0;
+
+ vconf_get_int(VCONFKEY_WIFI_UG_RUN_STATE,&wifi_ug_state);
+ if (wifi_ug_state == VCONFKEY_WIFI_UG_RUN_STATE_ON_FOREGROUND)
+ return;
+
+ b = bundle_create();
+
+ bundle_add(b, "_SYSPOPUP_TITLE_", "Cellular connection popup");
+ bundle_add(b, "_SYSPOPUP_CONTENT_", "connected");
+
+ DBG("Launch 3G alert network popup");
+ rv = syspopup_launch("net-popup", b);
+
+ bundle_free(b);
+}
+
+gboolean netconfig_iface_network_state_update_default_connection_info(
+ NetconfigNetworkState *master,
+ gchar *connection_type, gchar *connection_state,
+ gchar *ip_addr, gchar *proxy_addr, GError **error)
+{
+ char *ip = NULL;
+ char *proxy = NULL;
+ int wifi_state = 0;
+ int previous_network_status = 0;
+
+ DBG("connection type (%s), connection state(%s), ip_addr(%s), proxy_addr(%s)",
+ connection_type, connection_state, ip_addr, proxy_addr);
+
+ vconf_get_int(VCONFKEY_NETWORK_WIFI_STATE, &wifi_state);
+ vconf_get_int(VCONFKEY_NETWORK_STATUS, &previous_network_status);
+
+ if (g_str_equal(connection_state, "idle") == TRUE &&
+ previous_network_status != VCONFKEY_NETWORK_OFF) {
+ vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_OFF);
+
+ if (g_str_equal(connection_type, "wifi") == TRUE)
+ if (wifi_state != VCONFKEY_NETWORK_WIFI_OFF)
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_STATE,
+ VCONFKEY_NETWORK_WIFI_NOT_CONNECTED);
+
+ vconf_set_str(VCONFKEY_NETWORK_IP, "");
+ vconf_set_str(VCONFKEY_NETWORK_PROXY, "");
+
+ vconf_set_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, 0);
+ } else if (g_str_equal(connection_state, "ready") == TRUE ||
+ g_str_equal(connection_state, "online") == TRUE) {
+ ip = vconf_get_str(VCONFKEY_NETWORK_IP);
+ proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
+
+ DBG("existed ip (%s), proxy (%s)", ip, proxy);
+
+ if (g_str_equal(connection_type, "wifi") == TRUE) {
+ vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_WIFI);
+
+ if (wifi_state != VCONFKEY_NETWORK_WIFI_OFF)
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_STATE,
+ VCONFKEY_NETWORK_WIFI_CONNECTED);
+ } else if (g_str_equal(connection_type, "cellular") == TRUE) {
+ vconf_set_int(VCONFKEY_NETWORK_STATUS, VCONFKEY_NETWORK_CELLULAR);
+
+ if (wifi_state != VCONFKEY_NETWORK_WIFI_OFF)
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_STATE,
+ VCONFKEY_NETWORK_WIFI_NOT_CONNECTED);
+
+ if (previous_network_status != VCONFKEY_NETWORK_CELLULAR)
+ __netconfig_pop_3g_alert_syspoppup();
+ }
+
+ if (g_str_equal(ip, ip_addr) != TRUE)
+ vconf_set_str(VCONFKEY_NETWORK_IP, ip_addr);
+
+ if (g_str_equal(proxy, proxy_addr) != TRUE)
+ vconf_set_str(VCONFKEY_NETWORK_PROXY, proxy_addr);
+
+ vconf_set_int(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, 1);
+ }
+
+ return TRUE;
+}
+
+gpointer netconfig_network_state_create_and_init(DBusGConnection *conn)
+{
+ GObject *object;
+
+ g_return_val_if_fail(conn != NULL, NULL);
+
+ object = g_object_new(NETCONFIG_TYPE_NETWORK_STATE, "conn", conn, "path",
+ NETCONFIG_NETWORK_STATE_PATH, NULL);
+
+ INFO("create network_state(%p)", object);
+
+ dbus_g_connection_register_g_object(conn, NETCONFIG_NETWORK_STATE_PATH, object);
+
+ INFO("network_state(%p) register DBus path(%s)", object, NETCONFIG_NETWORK_STATE_PATH);
+
+ return object;
+}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include "log.h"
+#include "dbus.h"
+#include "util.h"
+#include "wifi.h"
+#include "wifi-state.h"
+#include "wifi-indicator.h"
+#include "wifi-background-scan.h"
+#include "neterror.h"
+
+#define CONNMAN_SIGNAL_PROPERTY_CHANGED "PropertyChanged"
+
+#define CONNMAN_MANAGER_SIGNAL_FILTER "type='signal',interface='net.connman.Manager'"
+#define CONNMAN_TECHNOLOGY_SIGNAL_FILTER "type='signal',interface='net.connman.Technology'"
+#define CONNMAN_SERVICE_SIGNAL_FILTER "type='signal',interface='net.connman.Service'"
+
+static DBusConnection *signal_connection = NULL;
+
+static int __netconfig_get_state(DBusMessage *msg, char *state)
+{
+ char *key_name = NULL;
+ char *svc_state = NULL;
+ DBusMessageIter iter, sub_iter;
+ int Error = NETCONFIG_ERROR_INTERNAL;
+
+ /* Get state */
+ dbus_message_iter_init(msg, &iter);
+ int ArgType = dbus_message_iter_get_arg_type(&iter);
+
+ if (ArgType != DBUS_TYPE_STRING)
+ goto done;
+
+ dbus_message_iter_get_basic(&iter, &key_name);
+ if (strcmp(key_name, "State") != 0)
+ goto done;
+
+ dbus_message_iter_next(&iter);
+ ArgType = dbus_message_iter_get_arg_type(&iter);
+ if (ArgType != DBUS_TYPE_VARIANT)
+ goto done;
+
+ dbus_message_iter_recurse(&iter, &sub_iter);
+ ArgType = dbus_message_iter_get_arg_type(&sub_iter);
+ if (ArgType != DBUS_TYPE_STRING)
+ goto done;
+
+ dbus_message_iter_get_basic(&sub_iter, &svc_state);
+ snprintf(state, strlen(svc_state) + 1, "%s", svc_state);
+ Error = NETCONFIG_NO_ERROR;
+
+done:
+ return Error;
+}
+
+static char *__netconfig_get_property(DBusMessage * msg, char **property)
+{
+ DBusMessageIter args, variant;
+ char *sigvalue = NULL;
+
+ /** read these parameters */
+ if (!dbus_message_iter_init(msg, &args))
+ ERR("Message does not have parameters");
+ else if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
+ ERR("Argument is not string");
+ else {
+ dbus_message_iter_get_basic(&args, &sigvalue);
+ dbus_message_iter_next(&args);
+ dbus_message_iter_recurse(&args, &variant);
+ if (dbus_message_iter_get_arg_type(&variant) == DBUS_TYPE_STRING)
+ dbus_message_iter_get_basic(&variant, property);
+ else
+ *property = NULL;
+ }
+
+ return sigvalue;
+}
+
+static void __netconfig_wifi_technology_state_signal_handler(
+ const char *sigvalue, const char *property)
+{
+ int wifi_state = 0;
+ static char previous_technology_state[DBUS_STATE_MAX_BUFLEN] = {0};
+
+ if (sigvalue == NULL || property == NULL)
+ return;
+
+ if (g_str_equal(sigvalue, "State") != TRUE)
+ return;
+
+ if (g_str_equal(property, "unknown") == TRUE)
+ return;
+
+ if (g_str_equal(previous_technology_state, property) == TRUE)
+ return;
+
+ g_strlcpy(previous_technology_state, property, sizeof(previous_technology_state));
+
+ vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
+
+ INFO("Technology state value is %s, property %s", sigvalue, property);
+ if (g_str_equal(property, "offline") == TRUE) {
+ if (netconfig_wifi_get_power_triggering_state() == WIFI_DEACTIVATING)
+ netconfig_wifi_set_power_triggering_state(WIFI_NON_OF_TRIGGERING);
+
+ if (wifi_state != VCONFKEY_WIFI_OFF) {
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_STATE, VCONFKEY_NETWORK_WIFI_OFF);
+
+ vconf_set_int(VCONF_WIFI_LAST_POWER_ON_STATE, WIFI_POWER_OFF);
+
+ vconf_set_int(VCONFKEY_WIFI_STATE, VCONFKEY_WIFI_OFF);
+ }
+ netconfig_wifi_bgscan_stop();
+ } else if (g_str_equal(property, "available") == TRUE) {
+ switch (netconfig_wifi_get_power_triggering_state()) {
+ case WIFI_ACTIVATING:
+ /* Wi-Fi power on triggered */
+ netconfig_wifi_enable_technology();
+
+ netconfig_wifi_device_picker_service_start();
+
+ netconfig_wifi_check_local_bssid();
+
+ break;
+
+ case WIFI_DEACTIVATING:
+ /* Wi-Fi power off triggered */
+ netconfig_wifi_remove_driver();
+
+ break;
+
+ default:
+ DBG("Wi-Fi tethering or direct enabled");
+ }
+ } else if (g_str_equal(property, "enabled") == TRUE) {
+ if (netconfig_wifi_get_power_triggering_state() == WIFI_ACTIVATING) {
+ netconfig_wifi_set_power_triggering_state(WIFI_NON_OF_TRIGGERING);
+
+ if (wifi_state == VCONFKEY_WIFI_OFF) {
+ vconf_set_int(VCONFKEY_NETWORK_WIFI_STATE, VCONFKEY_NETWORK_WIFI_NOT_CONNECTED);
+
+ vconf_set_int(VCONF_WIFI_LAST_POWER_ON_STATE, WIFI_POWER_ON);
+
+ vconf_set_int(VCONFKEY_WIFI_STATE, VCONFKEY_WIFI_UNCONNECTED);
+ }
+
+ netconfig_wifi_bgscan_start();
+ }
+ }
+}
+
+static void netconfig_wifi_set_essid(const char *active_profile)
+{
+ int err;
+ int state = -1;
+ char *essid_name = NULL;
+ DBusConnection *conn = NULL;
+ DBusMessage *message = NULL;
+ int MessageType = 0;
+
+ if (active_profile == NULL) {
+ ERR("Can't get active_profile");
+ return;
+ }
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (conn == NULL) {
+ ERR("Error!!! Can't get on system bus");
+ return;
+ }
+
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE, conn, active_profile,
+ CONNMAN_SERVICE_INTERFACE, "GetProperties");
+
+ if (message == NULL) {
+ ERR("Error!!! Failed to get service properties");
+ dbus_connection_unref(conn);
+ return;
+ }
+
+ MessageType = dbus_message_get_type(message);
+
+ if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
+ const char *ptr = dbus_message_get_error_name(message);
+ ERR("Error!!! Error message received [%s]", ptr);
+ goto done;
+ }
+
+ state = netconfig_extract_service_state(message, &essid_name);
+
+ if (state < 0) {
+ ERR("state is not ready");
+ goto done;
+ }
+
+ err = vconf_set_str(VCONFKEY_WIFI_CONNECTED_AP_NAME, essid_name);
+ if (err != 0) {
+ ERR("Can't set essid [%d]", err);
+ }
+
+done:
+ g_free(essid_name);
+ essid_name = NULL;
+
+ dbus_message_unref(message);
+
+ dbus_connection_unref(conn);
+}
+
+static void netconfig_wifi_unset_essid(void)
+{
+ vconf_set_str(VCONFKEY_WIFI_CONNECTED_AP_NAME, "");
+}
+
+static void __netconfig_wifi_service_state_signal_handler(DBusMessage *msg, const char *profile)
+{
+ char state[DBUS_STATE_MAX_BUFLEN] = {0};
+ static char current_profile[DBUS_PATH_MAX_BUFLEN] = {0};
+
+ if (profile == NULL)
+ return;
+
+ if (__netconfig_get_state(msg, state) == NETCONFIG_NO_ERROR) {
+ int value = 0;
+
+ DBG("Signaled profile [%s] ==> state %s", profile, state);
+
+ vconf_get_int(VCONFKEY_WIFI_STATE, &value);
+
+ if (strcmp(state, "ready") == 0 || strcmp(state, "online") == 0) {
+ if (value > VCONFKEY_WIFI_OFF && value != VCONFKEY_WIFI_CONNECTED) {
+
+ INFO("Wifi connected");
+
+ if ((vconf_set_int(VCONFKEY_WIFI_STATE, VCONFKEY_WIFI_CONNECTED)) < 0)
+ ERR("Error!!! vconf_set_int failed");
+
+ netconfig_wifi_state_set_service_state(NETCONFIG_WIFI_CONNECTED);
+
+ netconfig_wifi_set_essid(profile);
+
+ netconfig_wifi_indicator_start();
+
+ g_strlcpy(current_profile, profile, sizeof(current_profile));
+ }
+ } else if (strcmp(state, "failure") == 0 || strcmp(state, "disconnect") == 0 || strcmp(state, "idle") == 0) {
+ if (value > VCONFKEY_WIFI_UNCONNECTED) {
+
+ INFO("Wifi [%s] Disconnected", profile);
+ DBG("Current profile is %s", current_profile);
+
+ if ((strcmp(profile, current_profile)) == 0) {
+ if ((vconf_set_int (VCONFKEY_WIFI_STATE, VCONFKEY_WIFI_UNCONNECTED)) < 0)
+ ERR("Error!!! vconf_set_int failed");
+
+ netconfig_wifi_state_set_service_state(NETCONFIG_WIFI_IDLE);
+
+ netconfig_wifi_unset_essid();
+
+ netconfig_wifi_indicator_stop();
+
+ memset(current_profile, 0, sizeof(current_profile));
+ }
+ }
+ } else if (strcmp(state, "association") == 0 || strcmp(state, "configuration") == 0) {
+ netconfig_wifi_state_set_service_state(NETCONFIG_WIFI_CONNECTING);
+ }
+ } else
+ DBG("Signaled profile [%s] has error to get its state", profile);
+}
+
+static DBusHandlerResult __netconfig_signal_filter_handler(
+ DBusConnection *conn, DBusMessage *msg, void *user_data)
+{
+ char *sigvalue = NULL;
+
+ if (msg == NULL) {
+ INFO("Invalid Message. Ignore");
+
+ /* We have handled this message, don't pass it on */
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ if (dbus_message_is_signal(msg, CONNMAN_MANAGER_INTERFACE,
+ CONNMAN_SIGNAL_PROPERTY_CHANGED)) {
+ /* We have handled this message, don't pass it on */
+ return DBUS_HANDLER_RESULT_HANDLED;
+ } else if (dbus_message_is_signal(msg, CONNMAN_TECHNOLOGY_INTERFACE,
+ CONNMAN_SIGNAL_PROPERTY_CHANGED)) {
+ char *property = NULL;
+ char *tech_path = NULL;
+
+ sigvalue = __netconfig_get_property(msg, &property);
+ if (sigvalue == NULL)
+ return DBUS_HANDLER_RESULT_HANDLED;
+
+ tech_path = (char *)dbus_message_get_path(msg);
+
+ if (strstr(tech_path, "/wifi") != NULL) {
+ __netconfig_wifi_technology_state_signal_handler((const char *)sigvalue, (const char *)property);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ /* We have handled this message, don't pass it on */
+ return DBUS_HANDLER_RESULT_HANDLED;
+ } else if (dbus_message_is_signal(msg, CONNMAN_SERVICE_INTERFACE, CONNMAN_SIGNAL_PROPERTY_CHANGED)) {
+ sigvalue = netconfig_dbus_get_string(msg);
+
+ if (sigvalue == NULL)
+ return DBUS_HANDLER_RESULT_HANDLED;
+
+ if (strcmp(sigvalue, "State") == 0) {
+ char *profile = NULL;
+
+ profile = (char *)dbus_message_get_path(msg);
+
+ if (strstr(profile, "wifi_") != NULL) {
+ __netconfig_wifi_service_state_signal_handler(msg, profile);
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+ }
+ }
+
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+void netconfig_register_signal(void)
+{
+ DBusConnection *conn = NULL;
+ DBusError err;
+
+ DBG("Register DBus signal filters");
+
+ dbus_error_init(&err);
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (conn == NULL) {
+ ERR("Error! Failed to connect to the D-BUS daemon: [%s]",
+ err.message);
+ dbus_error_free(&err);
+ return;
+ }
+
+ signal_connection = conn;
+
+ dbus_connection_setup_with_g_main(conn, NULL);
+
+ /* listening to messages from all objects as no path is specified */
+ /* see signals from the given interface */
+ dbus_bus_add_match(conn, CONNMAN_MANAGER_SIGNAL_FILTER, &err);
+ dbus_connection_flush(conn);
+ if (dbus_error_is_set(&err)) {
+ ERR("Error! Match Error (%s)", err.message);
+ dbus_error_free(&err);
+ return;
+ }
+
+ dbus_bus_add_match(conn, CONNMAN_TECHNOLOGY_SIGNAL_FILTER, &err);
+ dbus_connection_flush(conn);
+ if (dbus_error_is_set(&err)) {
+ ERR("Error! Match Error (%s)", err.message);
+ dbus_error_free(&err);
+ return;
+ }
+
+ dbus_bus_add_match(conn, CONNMAN_SERVICE_SIGNAL_FILTER, &err);
+ dbus_connection_flush(conn);
+ if (dbus_error_is_set(&err)) {
+ ERR("Error! Match Error (%s)", err.message);
+ dbus_error_free(&err);
+ return;
+ }
+
+ if (dbus_connection_add_filter(conn, __netconfig_signal_filter_handler, NULL, NULL)
+ == FALSE) {
+ ERR("Error! dbus_connection_add_filter() failed");
+ return;
+ }
+
+ INFO("Successfully register signal filters");
+}
+
+void netconfig_deregister_signal(void)
+{
+ if (signal_connection == NULL) {
+ ERR("Error! Already de-registered. Nothing to be done");
+ return;
+ }
+
+ dbus_connection_remove_filter(signal_connection, __netconfig_signal_filter_handler,
+ NULL);
+ INFO("Successfully remove DBus signal filters");
+
+ dbus_connection_unref(signal_connection);
+ signal_connection = NULL;
+}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <unistd.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <wifi-direct.h>
+#include <syspopup_caller.h>
+
+#include "log.h"
+#include "util.h"
+#include "neterror.h"
+#include "wifi-state.h"
+
+void netconfig_start_timer_seconds(int secs,
+ gboolean(*callback) (gpointer), void *user_data, guint *timer_id)
+{
+ guint t_id = 0;
+
+ INFO("Register timer with callback pointer (%p)", callback);
+
+ if (callback == NULL) {
+ ERR("callback function is NULL");
+ return;
+ }
+
+ if ((timer_id != NULL && *timer_id != 0)) {
+ ERR("timer already is registered");
+ return;
+ }
+
+ t_id = g_timeout_add_seconds(secs, callback, user_data);
+
+ if (t_id == 0) {
+ ERR("Can't add timer");
+ return;
+ }
+
+ if (timer_id != NULL)
+ *timer_id = t_id;
+}
+
+void netconfig_start_timer(int msecs,
+ gboolean(*callback) (gpointer), void *user_data, guint *timer_id)
+{
+ guint t_id = 0;
+
+ INFO("Register timer with callback pointer (%p)", callback);
+
+ if (callback == NULL) {
+ ERR("callback function is NULL");
+ return;
+ }
+
+ if ((timer_id != NULL && *timer_id != 0)) {
+ ERR("timer already is registered");
+ return;
+ }
+
+ t_id = g_timeout_add(msecs, callback, user_data);
+
+ if (t_id == 0) {
+ ERR("Can't add timer");
+ return;
+ }
+
+ if (timer_id != NULL)
+ *timer_id = t_id;
+}
+
+void netconfig_stop_timer(guint *timer_id)
+{
+ if (timer_id == NULL) {
+ ERR("timer is NULL");
+ return;
+ }
+
+ if (*timer_id != 0) {
+ g_source_remove(*timer_id);
+ *timer_id = 0;
+ }
+}
+
+static gboolean __netconfig_wifi_state_device_picker_trials(gboolean is_clear_mode)
+{
+ static int netconfig_device_picker_trials = 0;
+ const int MAX_DEVICE_PICKER_TRIALS = 20;
+
+ if (is_clear_mode != TRUE) {
+ netconfig_device_picker_trials++;
+
+ if (netconfig_device_picker_trials > MAX_DEVICE_PICKER_TRIALS)
+ return TRUE;
+ else
+ return FALSE;
+ }
+
+ netconfig_device_picker_trials = 0;
+
+ return FALSE;
+}
+
+static gboolean __netconfig_wifi_state_inc_and_test_trials(void)
+{
+ return __netconfig_wifi_state_device_picker_trials(FALSE);
+}
+
+static void __netconfig_wifi_state_clear_trials(void)
+{
+ __netconfig_wifi_state_device_picker_trials(TRUE);
+}
+
+static gboolean __netconfig_test_device_picker(enum netconfig_wifi_service_state *wifi_state)
+{
+ *wifi_state = netconfig_wifi_state_get_service_state();
+
+ DBG("Current Wi-Fi state: %d", *wifi_state);
+
+ if (*wifi_state == NETCONFIG_WIFI_CONNECTING ||
+ *wifi_state == NETCONFIG_WIFI_UNKNOWN) {
+ if (__netconfig_wifi_state_inc_and_test_trials() == FALSE)
+ return FALSE;
+ }
+
+ if (*wifi_state == NETCONFIG_WIFI_CONNECTED)
+ return FALSE;
+
+ return TRUE;
+}
+
+static gboolean __netconfig_pop_device_picker(void)
+{
+ int rv = 0;
+ bundle *b = NULL;
+ int wifi_ug_state = 0;
+ enum netconfig_wifi_service_state wifi_state;
+
+ /* It's double checked,
+ * because ConnMan state stops by IDLE in a short time.
+ */
+ if (__netconfig_test_device_picker(&wifi_state) != TRUE) {
+ if (wifi_state == NETCONFIG_WIFI_CONNECTED)
+ return TRUE;
+
+ return FALSE;
+ }
+
+ vconf_get_int(VCONFKEY_WIFI_UG_RUN_STATE, &wifi_ug_state);
+ if (wifi_ug_state == VCONFKEY_WIFI_UG_RUN_STATE_ON_FOREGROUND)
+ return TRUE;
+
+ b = bundle_create();
+
+ DBG("Launch Wi-Fi device picker");
+ rv = syspopup_launch("wifi-qs", b);
+
+ bundle_free(b);
+
+ return TRUE;
+}
+
+static gboolean __netconfig_wifi_try_device_picker(gpointer data)
+{
+ enum netconfig_wifi_service_state wifi_state;
+
+ if (__netconfig_test_device_picker(&wifi_state) != TRUE) {
+ if (wifi_state == NETCONFIG_WIFI_CONNECTED)
+ return FALSE;
+
+ return TRUE;
+ }
+
+ if (__netconfig_pop_device_picker() != TRUE)
+ return TRUE;
+
+ __netconfig_wifi_state_clear_trials();
+
+ return FALSE;
+}
+
+static guint __netconfig_wifi_device_picker_timer_id(gboolean is_set_method,
+ guint timer_id)
+{
+ static guint netconfig_wifi_device_picker_service_timer = 0;
+
+ if (is_set_method != TRUE)
+ return netconfig_wifi_device_picker_service_timer;
+
+ if (netconfig_wifi_device_picker_service_timer != timer_id)
+ netconfig_wifi_device_picker_service_timer = timer_id;
+
+ return netconfig_wifi_device_picker_service_timer;
+}
+
+static void __netconfig_wifi_device_picker_set_timer_id(guint timer_id)
+{
+ __netconfig_wifi_device_picker_timer_id(TRUE, timer_id);
+}
+
+static guint __netconfig_wifi_device_picker_get_timer_id(void)
+{
+ return __netconfig_wifi_device_picker_timer_id(FALSE, -1);
+}
+
+void netconfig_wifi_device_picker_service_start(void)
+{
+ int wifi_ug_state;
+ const int NETCONFIG_WIFI_DEVICE_PICKER_INTERVAL = 700;
+ guint timer_id = 0;
+
+ vconf_get_int(VCONFKEY_WIFI_UG_RUN_STATE, &wifi_ug_state);
+ if (wifi_ug_state == VCONFKEY_WIFI_UG_RUN_STATE_ON_FOREGROUND)
+ return;
+
+ DBG("Register device picker timer with %d milliseconds",
+ NETCONFIG_WIFI_DEVICE_PICKER_INTERVAL);
+
+ netconfig_start_timer(NETCONFIG_WIFI_DEVICE_PICKER_INTERVAL,
+ __netconfig_wifi_try_device_picker, NULL, &timer_id);
+
+ __netconfig_wifi_state_clear_trials();
+ __netconfig_wifi_device_picker_set_timer_id(timer_id);
+}
+
+void netconfig_wifi_device_picker_service_stop(void)
+{
+ guint timer_id = 0;
+
+ timer_id = __netconfig_wifi_device_picker_get_timer_id();
+ if (timer_id == 0)
+ return;
+
+ DBG("Clear device picker timer with timer_id %d", timer_id);
+
+ netconfig_stop_timer(&timer_id);
+
+ __netconfig_wifi_device_picker_set_timer_id(timer_id);
+ __netconfig_wifi_state_clear_trials();
+}
+
+gboolean netconfig_is_wifi_direct_on(void)
+{
+ int wifi_direct_state = 0;
+
+ vconf_get_int(VCONFKEY_WIFI_DIRECT_STATE, &wifi_direct_state);
+
+ DBG("Wi-Fi direct mode %d", wifi_direct_state);
+ return (wifi_direct_state != 0) ? TRUE : FALSE;
+}
+
+gboolean netconfig_is_wifi_tethering_on(void)
+{
+ int wifi_tethering_state = 0;
+
+ vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &wifi_tethering_state);
+
+ DBG("Wi-Ti tethering mode %d", wifi_tethering_state);
+ if (wifi_tethering_state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI)
+ return TRUE;
+
+ return FALSE;
+}
+
+void netconfig_wifi_check_local_bssid(void)
+{
+}
+
+gboolean netconfig_execute_file(const char *file_path,
+ char *const args[], char *const env[])
+{
+ pid_t pid = 0;
+ int rv = 0;
+ errno = 0;
+
+ if (!(pid = fork())) {
+ register unsigned int index = 0;
+ DBG("pid(%d), ppid (%d)", getpid(), getppid());
+ DBG("Inside child, exec (%s) command", file_path);
+
+ index = 0;
+ while (args[index] != NULL) {
+ INFO(" %s", args[index]);
+ index++;
+ }
+
+ errno = 0;
+ if (execve(file_path, args, env) == -1) {
+ DBG("Fail to execute command...(%s)",
+ strerror(errno));
+ return FALSE;
+ }
+ } else if (pid > 0) {
+ if (waitpid(pid, &rv, 0) == -1) {
+ DBG("wait pid (%u) rv (%d)", pid, rv);
+
+ if (WIFEXITED(rv)) {
+ DBG("exited, rv=%d", WEXITSTATUS(rv));
+ } else if (WIFSIGNALED(rv)) {
+ DBG("killed by signal %d", WTERMSIG(rv));
+ } else if (WIFSTOPPED(rv)) {
+ DBG("stopped by signal %d", WSTOPSIG(rv));
+ } else if (WIFCONTINUED(rv)) {
+ DBG("continued");
+ }
+ }
+ return TRUE;
+ }
+
+ DBG("failed to fork()...(%s)", strerror(errno));
+ return FALSE;
+}
+
+gboolean netconfig_iface_wifi_launch_direct(NetconfigWifi *wifi, GError **error)
+{
+ gboolean ret = TRUE;
+
+ DBG("Launch Wi-Fi direct daemon");
+
+ const char *path = "/usr/bin/wifi-direct-server.sh";
+ char *const args[] = { "wifi-direct-server.sh", "start" };
+ char *const env[] = { NULL };
+
+ ret = netconfig_execute_file(path, args, env);
+
+ if (ret != TRUE) {
+ INFO("Failed to launch Wi-Fi direct daemon");
+
+ netconfig_error_wifi_direct_failed(error);
+ }
+
+ return ret;
+}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <glib.h>
+
+#include "log.h"
+#include "dbus.h"
+#include "util.h"
+#include "wifi.h"
+#include "wifi-background-scan.h"
+
+#define SCAN_INITIAL_DELAY 10
+#define SCAN_PERIODIC_DELAY 10
+#define SCAN_EXPONENTIAL_MIN 4
+#define SCAN_EXPONENTIAL_MAX 128
+
+enum {
+ WIFI_BGSCAN_MODE_DEFAULT = 0x00,
+ WIFI_BGSCAN_MODE_PERIODIC,
+ WIFI_BGSCAN_MODE_EXPONENTIAL,
+ WIFI_BGSCAN_MODE_MAX,
+};
+
+struct bgscan_timer_data {
+ guint time;
+ guint mode;
+ guint timer_id;
+};
+
+static struct bgscan_timer_data *__netconfig_wifi_bgscan_get_bgscan_data(void)
+{
+ static struct bgscan_timer_data timer_data = {SCAN_INITIAL_DELAY, WIFI_BGSCAN_MODE_EXPONENTIAL, 0};
+
+ return &timer_data;
+}
+
+static guint __netconfig_wifi_bgscan_mode(gboolean is_set_mode, guint mode)
+{
+ static guint bgscan_mode = WIFI_BGSCAN_MODE_DEFAULT;
+
+ if (is_set_mode != TRUE)
+ return bgscan_mode;
+
+ if (mode < WIFI_BGSCAN_MODE_MAX && mode > WIFI_BGSCAN_MODE_DEFAULT)
+ bgscan_mode = mode;
+
+ DBG("Wi-Fi background scan mode set %d", bgscan_mode);
+
+ return bgscan_mode;
+}
+
+static void __netconfig_wifi_bgscan_set_mode(guint mode)
+{
+ __netconfig_wifi_bgscan_mode(TRUE, mode);
+}
+
+static guint __netconfig_wifi_bgscan_get_mode(void)
+{
+ return __netconfig_wifi_bgscan_mode(FALSE, -1);
+}
+
+static gboolean __netconfig_wifi_bgscan_request_connman_scan(void)
+{
+ DBusMessage *reply = NULL;
+ /** dbus-send --system --print-reply --dest=net.connman / net.connman.Manager.SetProperty string:ScanMode variant:uint16:0/1/2/3 */
+ char request[] = CONNMAN_MANAGER_INTERFACE ".RequestScan";
+ char param1[] = "string:wifi";
+ char path[DBUS_PATH_MAX_BUFLEN] = "/";
+ char *param_array[] = {
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ };
+
+ param_array[0] = path;
+ param_array[1] = request;
+ param_array[2] = param1;
+
+ DBG("Requesting [%s %s %s]", param_array[0], param_array[1], param_array[2]);
+
+ reply = netconfig_dbus_send_request(CONNMAN_SERVICE, param_array);
+ if (reply == NULL) {
+ ERR("Error!!! Request failed");
+
+ return FALSE;
+ }
+
+ dbus_message_unref(reply);
+
+ return TRUE;
+}
+
+static gboolean __netconfig_wifi_bgscan_request_scan(gpointer data);
+
+static void __netconfig_wifi_bgscan_start_timer(struct bgscan_timer_data *data)
+{
+ if (data == NULL)
+ return;
+
+ DBG("[%s]", __FUNCTION__);
+ netconfig_stop_timer(&(data->timer_id));
+
+ data->mode = __netconfig_wifi_bgscan_get_mode();
+
+ switch (data->mode) {
+ case WIFI_BGSCAN_MODE_EXPONENTIAL:
+ if (data->time == 0)
+ data->time = SCAN_EXPONENTIAL_MIN;
+ else if ((data->time >= SCAN_EXPONENTIAL_MAX) || (data->time > SCAN_EXPONENTIAL_MAX / 2))
+ data->time = SCAN_EXPONENTIAL_MAX;
+ else
+ data->time = data->time * 2;
+ break;
+ case WIFI_BGSCAN_MODE_PERIODIC:
+ data->time = SCAN_PERIODIC_DELAY;
+ break;
+ default:
+ data->time = SCAN_INITIAL_DELAY;
+ break;
+ }
+ switch (data->mode) {
+ case WIFI_BGSCAN_MODE_PERIODIC:
+ DBG("[%s]BG scan mode is periodic", __FUNCTION__);
+ break;
+ case WIFI_BGSCAN_MODE_EXPONENTIAL:
+ DBG("[%s]BG scan mode is exponential", __FUNCTION__);
+ break;
+ default:
+ DBG("[%s]strange value [%d]", __FUNCTION__, data->mode);
+ break;
+ }
+
+ DBG("Register background scan timer with %d seconds", data->time);
+ netconfig_start_timer_seconds(data->time, __netconfig_wifi_bgscan_request_scan, data, &(data->timer_id));
+}
+
+static void __netconfig_wifi_bgscan_stop_timer(struct bgscan_timer_data *data)
+{
+ if (data == NULL)
+ return;
+
+ DBG("[%s]", __FUNCTION__);
+ netconfig_stop_timer(&(data->timer_id));
+}
+
+static gboolean __netconfig_wifi_bgscan_request_scan(gpointer data)
+{
+ struct bgscan_timer_data *timer = (struct bgscan_timer_data *)data;
+
+ if (timer == NULL)
+ return FALSE;
+
+ DBG("[%s] Try to send a scan request to ConnMan", __FUNCTION__);
+
+ __netconfig_wifi_bgscan_stop_timer(timer);
+
+ __netconfig_wifi_bgscan_request_connman_scan();
+
+ __netconfig_wifi_bgscan_start_timer(timer);
+
+ return FALSE;
+}
+
+void netconfig_wifi_bgscan_start(void)
+{
+ struct bgscan_timer_data *timer_data = __netconfig_wifi_bgscan_get_bgscan_data();
+
+ if (timer_data == NULL)
+ return;
+
+ DBG("Wi-Fi background scan start");
+
+ __netconfig_wifi_bgscan_request_connman_scan();
+
+ __netconfig_wifi_bgscan_start_timer(timer_data);
+}
+
+void netconfig_wifi_bgscan_stop(void)
+{
+ struct bgscan_timer_data *timer_data = __netconfig_wifi_bgscan_get_bgscan_data();
+
+ if (timer_data == NULL)
+ return;
+
+ DBG("Wi-Fi background scan stop");
+
+ timer_data->time = SCAN_EXPONENTIAL_MIN;
+
+ __netconfig_wifi_bgscan_stop_timer(timer_data);
+}
+
+gboolean netconfig_iface_wifi_set_bgscan(NetconfigWifi *wifi, guint scan_mode, GError **error)
+{
+ struct bgscan_timer_data *timer_data = __netconfig_wifi_bgscan_get_bgscan_data();
+
+ DBG("Wi-Fi background scan mode set: %d", scan_mode);
+
+ if (scan_mode >= WIFI_BGSCAN_MODE_MAX || scan_mode == WIFI_BGSCAN_MODE_DEFAULT)
+ return FALSE;
+
+ switch (scan_mode) {
+ case WIFI_BGSCAN_MODE_PERIODIC:
+ DBG("[%s]BG scan mode is periodic", __FUNCTION__);
+ break;
+ case WIFI_BGSCAN_MODE_EXPONENTIAL:
+ DBG("[%s]BG scan mode is exponential", __FUNCTION__);
+ break;
+ default:
+ DBG("[%s]strange value [%d]", __FUNCTION__, scan_mode);
+ break;
+ }
+
+ __netconfig_wifi_bgscan_set_mode(scan_mode);
+
+ if (timer_data->timer_id != 0) {
+ netconfig_wifi_bgscan_stop();
+ netconfig_wifi_bgscan_start();
+ }
+
+ return TRUE;
+}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <string.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <netinet/in.h>
+#include <netinet/ip.h>
+#include <linux/wireless.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+
+#include "log.h"
+#include "dbus.h"
+#include "util.h"
+#include "wifi-indicator.h"
+
+#define NETCONFIG_WIFI_INDICATOR_UPDATE_INTERVAL 1
+
+#define VCONFKEY_WIFI_SNR_MIN -85
+#define VCONFKEY_WIFI_SNR_MAX -55
+#define NETCONFIG_WIFI_WEAK_SIGNAL -85
+
+static guint netconfig_wifi_indicator_timer = 0;
+
+static GList *__netconfig_wifi_supplicant_setup(GList * list,
+ struct dbus_input_arguments *items)
+{
+ struct dbus_input_arguments *iter = items;
+
+ if (iter == NULL)
+ return NULL;
+
+ while (iter->data) {
+ list = g_list_append(list, iter);
+ iter++;
+ }
+
+ return list;
+}
+
+static int __netconfig_wifi_get_interface(const char **path)
+{
+ char *ptr = (char *)*path;
+ DBusConnection *conn = NULL;
+ DBusMessage *message = NULL;
+ DBusMessageIter iter;
+ int MessageType = 0;
+ const char *temp = NULL;
+
+ GList *input_args = NULL;
+ struct dbus_input_arguments inserted_items[] = {
+ {DBUS_TYPE_STRING, SUPPLICANT_INTERFACE},
+ {DBUS_TYPE_STRING, "Interfaces"},
+ {0, NULL}
+ };
+
+ if (ptr == NULL) {
+ ERR("Error!!! path is NULL");
+ return -1;
+ }
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (conn == NULL) {
+ ERR("Error!!! Can't get on system bus");
+ return -1;
+ }
+
+ input_args = __netconfig_wifi_supplicant_setup(input_args, inserted_items);
+
+ message = netconfig_supplicant_invoke_dbus_method(SUPPLICANT_SERVICE, conn,
+ SUPPLICANT_PATH,
+ SUPPLICANT_GLOBAL_INTERFACE, "Get",
+ input_args);
+
+ g_list_free(input_args);
+
+ if (message == NULL) {
+ ERR("Error!!! Failed to get service properties");
+ goto err;
+ }
+
+ MessageType = dbus_message_get_type(message);
+
+ if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
+ const char *err_msg = dbus_message_get_error_name(message);
+ ERR("Error!!! Error message received [%s]", err_msg);
+ goto err;
+ }
+
+ dbus_message_iter_init(message, &iter);
+ if ((MessageType = dbus_message_iter_get_arg_type(&iter)) == DBUS_TYPE_VARIANT) {
+ DBusMessageIter array;
+ dbus_message_iter_recurse(&iter, &array);
+
+ if ((MessageType = dbus_message_iter_get_arg_type(&array)) == DBUS_TYPE_ARRAY) {
+ DBusMessageIter object_path;
+ dbus_message_iter_recurse(&array, &object_path);
+
+ if ((MessageType = dbus_message_iter_get_arg_type(&object_path)) == DBUS_TYPE_OBJECT_PATH)
+ dbus_message_iter_get_basic(&object_path, &temp);
+ else
+ goto err;
+
+ } else
+ goto err;
+
+ } else
+ goto err;
+
+ INFO("interface %s, path pointer %p", temp, *path);
+ g_strlcpy(ptr, temp, DBUS_PATH_MAX_BUFLEN);
+
+ dbus_message_unref(message);
+ dbus_connection_unref(conn);
+
+ return 0;
+
+err:
+ if (message != NULL)
+ dbus_message_unref(message);
+
+ if (conn != NULL)
+ dbus_connection_unref(conn);
+
+ return -1;
+}
+
+static void __netconfig_wifi_service_disconnect(void)
+{
+ int MessageType = 0;
+ DBusConnection *conn = NULL;
+ DBusMessage *message = NULL;
+ char *path_ptr = NULL;
+ char path[DBUS_PATH_MAX_BUFLEN] = { 0 };
+
+ path_ptr = &path[0];
+
+ if (__netconfig_wifi_get_interface((const char **)(&path_ptr)) < 0) {
+ ERR("ERR fail to get interface");
+ return;
+ }
+
+ INFO("interface name is [%s]", path_ptr);
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (conn == NULL) {
+ ERR("Error!!! Can't get on system bus");
+ return;
+ }
+
+ message = netconfig_invoke_dbus_method(SUPPLICANT_SERVICE, conn, (char *)path,
+ SUPPLICANT_INTERFACE ".Interface", "Disconnect");
+
+ if (message == NULL) {
+ ERR("Error!!! Failed to get service properties");
+ dbus_connection_unref(conn);
+ return;
+ }
+
+ MessageType = dbus_message_get_type(message);
+
+ if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
+ const char *ptr = dbus_message_get_error_name(message);
+ ERR("Error!!! Error message received [%s]", ptr);
+ }
+
+ dbus_message_unref(message);
+
+ dbus_connection_unref(conn);
+}
+
+#ifdef NL80211
+static int __netconfig_wifi_get_signal(const char *path, int *sig)
+{
+ DBusConnection *conn = NULL;
+ DBusMessage *message = NULL;
+ DBusMessageIter iter;
+ int MessageType = 0;
+
+ if (path == NULL || sig == NULL) {
+ ERR("Error!!! path is NULL");
+ return -1;
+ }
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (conn == NULL) {
+ ERR("Error!!! Can't get on system bus");
+ return -1;
+ }
+
+ INFO("supplicant path is [%s]", path);
+
+ message = netconfig_supplicant_invoke_dbus_method(SUPPLICANT_SERVICE, conn,
+ path,
+ SUPPLICANT_INTERFACE".Interface", "GetLinkSignal",
+ NULL);
+
+ if (message == NULL) {
+ ERR("Error!!! Failed to get service properties");
+ goto err;
+ }
+
+ MessageType = dbus_message_get_type(message);
+
+ if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
+ const char *err_msg = dbus_message_get_error_name(message);
+ ERR("Error!!! Error message received [%s]", err_msg);
+ goto err;
+ }
+
+ dbus_message_iter_init(message, &iter);
+
+ if ((MessageType = dbus_message_iter_get_arg_type(&iter)) == DBUS_TYPE_INT32) {
+ dbus_message_iter_get_basic(&iter, sig);
+ INFO("signal value is [%d]", *sig);
+ } else {
+ ERR("message type is %d", MessageType);
+ goto err;
+ }
+
+ dbus_message_unref(message);
+
+ dbus_connection_unref(conn);
+
+ return 0;
+
+err:
+ if (message != NULL)
+ dbus_message_unref(message);
+
+ if (conn != NULL)
+ dbus_connection_unref(conn);
+
+ return -1;
+}
+#endif
+
+static int __netconfig_wifi_set_rssi_level(gboolean is_start, const char *ifname)
+{
+ int rssi_dbm = 0;
+ static int last_snr = 0;
+ int snr_level_interval = 0;
+ int snr_level = 0;
+
+#ifndef NL80211
+ int fd = -1;
+ struct iwreq wifi_req;
+ struct iw_statistics stats;
+
+ unsigned int iw_stats_len = sizeof(struct iw_statistics);
+
+ /* Set device name */
+ memset(wifi_req.ifr_name, 0, sizeof(wifi_req.ifr_name));
+ strncpy(wifi_req.ifr_name, ifname, sizeof(wifi_req.ifr_name) - 1);
+ wifi_req.ifr_name[sizeof(wifi_req.ifr_name) - 1] = '\0';
+
+ wifi_req.u.data.pointer = (caddr_t) &stats;
+ wifi_req.u.data.length = iw_stats_len;
+ wifi_req.u.data.flags = 1; /* Clear updated flag */
+
+ if (is_start == TRUE) {
+ last_snr = VCONFKEY_WIFI_STRENGTH_MAX;
+ vconf_set_int(VCONFKEY_WIFI_STRENGTH, last_snr);
+ return 0;
+ }
+
+ if ((fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP)) < 0) {
+ DBG("Fail to open socket to get rssi");
+ return -1;
+ }
+
+ memset(&stats, 0, iw_stats_len);
+
+ if (ioctl(fd, SIOCGIWSTATS, &wifi_req) < 0) {
+ DBG("Fail to execute ioctl for SIOCGIWSTATS");
+ close(fd);
+ return -1;
+ }
+ close(fd);
+
+ rssi_dbm = stats.qual.level - 255; /** signed integer, so 255 */
+#else
+ if (is_start == TRUE) {
+ last_snr = VCONFKEY_WIFI_STRENGTH_MAX;
+ vconf_set_int(VCONFKEY_WIFI_STRENGTH, last_snr);
+ return 0;
+ }
+ __netconfig_wifi_get_signal(ifname, &rssi_dbm);
+#endif
+
+ snr_level_interval =
+ (VCONFKEY_WIFI_SNR_MAX -
+ VCONFKEY_WIFI_SNR_MIN) / (VCONFKEY_WIFI_STRENGTH_MAX - 2);
+
+ snr_level =
+ ((rssi_dbm - VCONFKEY_WIFI_SNR_MIN) / snr_level_interval) + 2;
+
+ if (rssi_dbm <= VCONFKEY_WIFI_SNR_MIN)
+ snr_level = VCONFKEY_WIFI_STRENGTH_MIN + 1;
+ else if (rssi_dbm >= VCONFKEY_WIFI_SNR_MAX)
+ snr_level = VCONFKEY_WIFI_STRENGTH_MAX;
+
+ if (snr_level != last_snr) {
+ INFO("rssi (%d)", rssi_dbm);
+ vconf_set_int(VCONFKEY_WIFI_STRENGTH, snr_level);
+ last_snr = snr_level;
+ }
+
+ if (rssi_dbm < NETCONFIG_WIFI_WEAK_SIGNAL) {
+ INFO("rssi (%d) is under (%d)", rssi_dbm,
+ VCONFKEY_WIFI_SNR_MIN);
+
+ __netconfig_wifi_service_disconnect();
+ }
+
+ return 0;
+}
+
+#ifndef NL80211
+static int __netconfig_wifi_get_ifname(const char *supp_inf, const char **ifname)
+{
+ char *ptr = (char *)*ifname;
+ DBusConnection *conn = NULL;
+ DBusMessage *message = NULL;
+ DBusMessageIter iter;
+ int MessageType = 0;
+ const char *temp = NULL;
+
+ GList *input_args = NULL;
+
+ struct dbus_input_arguments inserted_items[] = {
+ { DBUS_TYPE_STRING, SUPPLICANT_INTERFACE ".Interface" },
+ { DBUS_TYPE_STRING, "Ifname" },
+ { 0, NULL }
+ };
+
+ if (ptr == NULL) {
+ ERR("Error!!! Path is NULL");
+ return -1;
+ }
+
+ if (supp_inf == NULL) {
+ ERR("Error!!! Supplicant DBus interface is NULL");
+ return -1;
+ }
+
+ conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+
+ if (conn == NULL) {
+ ERR("Fail to get DBus *p", conn);
+ return -1;
+ }
+
+ input_args = __netconfig_wifi_supplicant_setup(input_args, inserted_items);
+
+ message = netconfig_supplicant_invoke_dbus_method(SUPPLICANT_SERVICE, conn, (char *)supp_inf,
+ SUPPLICANT_GLOBAL_INTERFACE, "Get",
+ input_args);
+
+ g_list_free(input_args);
+
+ if (message == NULL) {
+ ERR("Error!!! Failed to get service properties");
+ goto err;
+ }
+
+ if (message == NULL) {
+ ERR("Error!!! Failed to get service properties");
+ goto err;
+ }
+
+ MessageType = dbus_message_get_type(message);
+
+ if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
+ const char *err_ptr = dbus_message_get_error_name(message);
+ ERR("Error!!! Error message received [%s]", err_ptr);
+ goto err;
+ }
+
+ dbus_message_iter_init(message, &iter);
+
+ if ((MessageType = dbus_message_iter_get_arg_type(&iter)) == DBUS_TYPE_VARIANT) {
+ DBusMessageIter string_type;
+ dbus_message_iter_recurse(&iter, &string_type);
+
+ if ((MessageType = dbus_message_iter_get_arg_type(&string_type)) ==
+ DBUS_TYPE_STRING) {
+ dbus_message_iter_get_basic(&string_type, &temp);
+ } else
+ goto err;
+
+ } else
+ goto err;
+
+ INFO("interface %s, ifname pointer %p", temp, *ifname);
+
+ g_strlcpy(ptr, temp, IFNAMSIZ);
+
+ dbus_message_unref(message);
+ dbus_connection_unref(conn);
+
+ return 0;
+
+err:
+ if (message != NULL)
+ dbus_message_unref(message);
+
+ if (conn != NULL)
+ dbus_connection_unref(conn);
+
+ return -1;
+}
+#endif
+
+static gboolean __netconfig_wifi_monitor_rssi(gpointer data)
+{
+ int rssi_result = 0;
+
+ if (data == NULL)
+ return FALSE;
+
+ rssi_result = __netconfig_wifi_set_rssi_level(FALSE, (char *)data);
+
+ if (rssi_result == -1)
+ vconf_set_int(VCONFKEY_WIFI_STRENGTH, VCONFKEY_WIFI_STRENGTH_MIN);
+
+ return TRUE;
+}
+
+void netconfig_wifi_indicator_start(void)
+{
+ char *path_ptr = NULL;
+ static char path[DBUS_PATH_MAX_BUFLEN] = { 0 };
+#ifndef NL80211
+ char *ifname_ptr = NULL;
+ static char ifname[IFNAMSIZ] = { 0 };
+#endif
+
+ INFO("Start Wi-Fi indicator");
+
+ netconfig_stop_timer(&netconfig_wifi_indicator_timer);
+
+#ifndef NL80211
+ memset(ifname, 0, sizeof(ifname));
+ ifname_ptr = &ifname[0];
+#endif
+ path_ptr = &path[0];
+
+ if (__netconfig_wifi_get_interface((const char **)(&path_ptr)) == 0) {
+#ifndef NL80211
+ INFO("Success to get DBus interface %s", path_ptr);
+
+ if (__netconfig_wifi_get_ifname(path_ptr, (const char **)(&ifname_ptr)) == 0) {
+ INFO("Success to get wifi ifname %s", ifname_ptr);
+
+ __netconfig_wifi_set_rssi_level(TRUE, (const char *)ifname);
+
+ DBG("Register Wi-Fi indicator timer with %d seconds",
+ NETCONFIG_WIFI_INDICATOR_UPDATE_INTERVAL);
+ netconfig_start_timer_seconds(NETCONFIG_WIFI_INDICATOR_UPDATE_INTERVAL,
+ __netconfig_wifi_monitor_rssi, ifname, &netconfig_wifi_indicator_timer);
+ }
+
+ return;
+#else
+ INFO("interface is [%s]", path_ptr);
+
+ __netconfig_wifi_set_rssi_level(TRUE, (const char *)path_ptr);
+
+ DBG("Register Wi-Fi indicator timer with %d seconds",
+ NETCONFIG_WIFI_INDICATOR_UPDATE_INTERVAL);
+ netconfig_start_timer_seconds(NETCONFIG_WIFI_INDICATOR_UPDATE_INTERVAL,
+ __netconfig_wifi_monitor_rssi, path_ptr, &netconfig_wifi_indicator_timer);
+
+ return;
+#endif
+ }
+}
+
+void netconfig_wifi_indicator_stop(void)
+{
+ INFO("Stop Wi-Fi indicator");
+
+ vconf_set_int(VCONFKEY_WIFI_STRENGTH, VCONFKEY_WIFI_STRENGTH_MAX);
+
+ netconfig_stop_timer(&netconfig_wifi_indicator_timer);
+}
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <wifi-direct.h>
+
+#include "log.h"
+#include "wifi.h"
+#include "dbus.h"
+#include "util.h"
+#include "neterror.h"
+#include "netconfig.h"
+#include "emulator.h"
+#include "wifi-background-scan.h"
+
+#include "netconfig-iface-wifi-glue.h"
+
+#define NETCONFIG_WIFI_PATH "/net/netconfig/wifi"
+
+#define WLAN_DRIVER_SCRIPT "/usr/bin/wlan.sh"
+
+#define PROP_DEFAULT FALSE
+#define PROP_DEFAULT_STR NULL
+
+enum {
+ PROP_O,
+ PROP_WIFI_CONN,
+ PROP_WIFI_PATH,
+};
+
+enum {
+ SIG_WIFI_DRIVER,
+ SIG_LAST
+};
+
+struct NetconfigWifiClass {
+ GObjectClass parent;
+
+ /* method and signals */
+ void (*driver_loaded) (NetconfigWifi *wifi, gchar *mac);
+};
+
+struct NetconfigWifi {
+ GObject parent;
+
+ /* member variable */
+ DBusGConnection *conn;
+ gchar *path;
+};
+
+static guint32 signals[SIG_LAST] = { 0, };
+
+G_DEFINE_TYPE(NetconfigWifi, netconfig_wifi, G_TYPE_OBJECT);
+
+
+static void __netconfig_wifi_gobject_get_property(GObject *object, guint prop_id,
+ GValue *value, GParamSpec *pspec)
+{
+ return;
+}
+
+static void __netconfig_wifi_gobject_set_property(GObject *object, guint prop_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ NetconfigWifi *wifi = NETCONFIG_WIFI(object);
+
+ switch (prop_id) {
+ case PROP_WIFI_CONN:
+ {
+ wifi->conn = g_value_get_boxed(value);
+ INFO("wifi(%p) set conn(%p)", wifi, wifi->conn);
+ break;
+ }
+
+ case PROP_WIFI_PATH:
+ {
+ if (wifi->path)
+ g_free(wifi->path);
+
+ wifi->path = g_value_dup_string(value);
+ INFO("wifi(%p) path(%s)", wifi, wifi->path);
+
+ break;
+ }
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ }
+}
+
+static void netconfig_wifi_init(NetconfigWifi *wifi)
+{
+ DBG("wifi initialize");
+
+ wifi->conn = NULL;
+ wifi->path = g_strdup(PROP_DEFAULT_STR);
+}
+
+static void netconfig_wifi_class_init(NetconfigWifiClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS(klass);
+
+ DBG("class initialize");
+
+ object_class->get_property = __netconfig_wifi_gobject_get_property;
+ object_class->set_property = __netconfig_wifi_gobject_set_property;
+
+ /* DBus register */
+ dbus_g_object_type_install_info(NETCONFIG_TYPE_WIFI,
+ &dbus_glib_netconfig_iface_wifi_object_info);
+
+ /* property */
+ g_object_class_install_property(object_class, PROP_WIFI_CONN,
+ g_param_spec_boxed("conn", "CONNECTION", "DBus connection",
+ DBUS_TYPE_G_CONNECTION,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ g_object_class_install_property(object_class, PROP_WIFI_PATH,
+ g_param_spec_string("path", "PATH", "Object Path",
+ PROP_DEFAULT_STR,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ /* signal */
+ signals[SIG_WIFI_DRIVER] = g_signal_new("driver-loaded",
+ G_OBJECT_CLASS_TYPE(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(NetconfigWifiClass,
+ driver_loaded),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
+}
+
+
+static enum netconfig_wifi_power_triggering_state
+__netconfig_wifi_triggering_state(gboolean is_set_method,
+ enum netconfig_wifi_power_triggering_state state)
+{
+ static enum netconfig_wifi_power_triggering_state wifi_state =
+ WIFI_NON_OF_TRIGGERING;
+
+ if (is_set_method != TRUE)
+ return wifi_state;
+
+ if (wifi_state != state)
+ wifi_state = state;
+
+ DBG("Wi-Fi power triggering state set %d", wifi_state);
+
+ return wifi_state;
+}
+
+void netconfig_wifi_set_power_triggering_state(
+ enum netconfig_wifi_power_triggering_state state)
+{
+ __netconfig_wifi_triggering_state(TRUE, state);
+}
+
+enum netconfig_wifi_power_triggering_state
+ netconfig_wifi_get_power_triggering_state(void)
+{
+ return __netconfig_wifi_triggering_state(FALSE, -1);
+}
+
+gboolean netconfig_wifi_enable_technology(void)
+{
+ DBusMessage *reply = NULL;
+ char path[DBUS_PATH_MAX_BUFLEN] = "/";
+ char request[] = CONNMAN_MANAGER_INTERFACE ".EnableTechnology";
+ char param1[] = "string:wifi";
+ char *param_array[] = {
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ };
+
+ param_array[0] = path;
+ param_array[1] = request;
+ param_array[2] = param1;
+
+ reply = netconfig_dbus_send_request(CONNMAN_SERVICE, param_array);
+ if (reply == NULL) {
+ ERR("Error!!! Request failed");
+
+ return FALSE;
+ }
+
+ dbus_message_unref(reply);
+
+ return TRUE;
+}
+
+gboolean netconfig_wifi_disable_technology(void)
+{
+ DBusMessage *reply = NULL;
+ char path[DBUS_PATH_MAX_BUFLEN] = "/";
+ char request[] = CONNMAN_MANAGER_INTERFACE ".DisableTechnology";
+ char param1[] = "string:wifi";
+ char *param_array[] = {
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ };
+
+ param_array[0] = path;
+ param_array[1] = request;
+ param_array[2] = param1;
+
+ reply = netconfig_dbus_send_request(CONNMAN_SERVICE, param_array);
+ if (reply == NULL) {
+ ERR("Error!!! Request failed");
+
+ return FALSE;
+ }
+
+ dbus_message_unref(reply);
+
+ return TRUE;
+}
+
+static gboolean __netconfig_wifi_load_driver(void)
+{
+ gboolean rv = FALSE;
+ const char *path = WLAN_DRIVER_SCRIPT;
+ char *const args[] = { "wlan.sh", "start" };
+ char *const envs[] = { NULL };
+
+ if (netconfig_emulator_is_emulated() == TRUE)
+ return rv;
+
+ rv = netconfig_execute_file(path, args, envs);
+ if (rv != TRUE) {
+ DBG("failed to load wireless device driver");
+ return FALSE;
+ }
+
+ DBG("Successfully loaded wireless device drivers");
+ return TRUE;
+}
+
+static gboolean __netconfig_wifi_remove_driver(void)
+{
+ gboolean rv = FALSE;
+ const char *path = WLAN_DRIVER_SCRIPT;
+ char *const args[] = { "wlan.sh", "stop" };
+ char *const env[] = { NULL };
+
+ if (netconfig_emulator_is_emulated() == TRUE)
+ return rv;
+
+ rv = netconfig_execute_file(path, args, env);
+ if (rv != TRUE) {
+ DBG("failed to remove(unload) driver for wireless device");
+ return FALSE;
+ }
+
+ DBG("Successfully removed(unloaded) wireless driver");
+ return TRUE;
+}
+
+gboolean netconfig_wifi_remove_driver(void)
+{
+ return __netconfig_wifi_remove_driver();
+}
+
+
+static gboolean __netconfig_wifi_try_to_load_driver(void)
+{
+ gboolean ret = FALSE;
+
+ netconfig_wifi_set_power_triggering_state(WIFI_ACTIVATING);
+
+ ret = __netconfig_wifi_load_driver();
+
+ if (ret == FALSE) {
+ DBG("Fail to load Wi-Fi driver");
+
+ __netconfig_wifi_remove_driver();
+
+ netconfig_wifi_set_power_triggering_state(WIFI_NON_OF_TRIGGERING);
+ }
+
+ return ret;
+}
+
+static gboolean __netconfig_wifi_try_to_remove_driver(void)
+{
+ gboolean ret = FALSE;
+
+ netconfig_wifi_set_power_triggering_state(WIFI_DEACTIVATING);
+
+ netconfig_wifi_device_picker_service_stop();
+
+ ret = netconfig_wifi_disable_technology();
+
+ if (ret == FALSE) {
+ DBG("Fail to disable Wi-Fi technology");
+
+ netconfig_wifi_set_power_triggering_state(WIFI_NON_OF_TRIGGERING);
+ }
+
+ return ret;
+}
+
+static void __netconfig_wifi_direct_state_cb(int error_code,
+ wifi_direct_device_state_e device_state, void *user_data)
+{
+ wifi_direct_unset_device_state_changed_cb();
+ wifi_direct_deinitialize();
+
+ if (device_state == WIFI_DIRECT_DEVICE_STATE_DEACTIVATED) {
+ __netconfig_wifi_try_to_load_driver();
+
+ return;
+ }
+
+ /* TODO: error report */
+}
+
+static gboolean __netconfig_wifi_direct_power_off(void)
+{
+ DBG("Wi-Fi direct is turning off");
+
+ if (wifi_direct_initialize() < 0)
+ return FALSE;
+
+ if (wifi_direct_set_device_state_changed_cb(
+ __netconfig_wifi_direct_state_cb, NULL) < 0)
+ return FALSE;
+
+ if (wifi_direct_deactivate() < 0)
+ return FALSE;
+
+ return TRUE;
+}
+
+static void __netconfig_wifi_airplane_mode(keynode_t* node,
+ void* user_data)
+{
+ int value = 0;
+ int wifi_state = 0;
+ static gboolean powered_off_by_flightmode = FALSE;
+
+ vconf_get_bool(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL, &value);
+ vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state);
+
+ DBG("flight mode %s", value > 0 ? "ON" : "OFF");
+ DBG("Wi-Fi state %d, Wi-Fi was off by flight mode %s",
+ wifi_state, powered_off_by_flightmode == TRUE ? "Yes" : "No");
+
+ if (value > 0) {
+ /* flight mode enabled */
+ if (wifi_state == VCONFKEY_WIFI_OFF)
+ return;
+
+ DBG("Turning Wi-Fi off");
+ __netconfig_wifi_try_to_remove_driver();
+
+ powered_off_by_flightmode = TRUE;
+ } else if (value == 0) {
+ /* flight mode disabled */
+ if (wifi_state > VCONFKEY_WIFI_OFF)
+ return;
+
+ if (powered_off_by_flightmode != TRUE)
+ return;
+
+ DBG("Turning Wi-Fi on");
+
+ if (netconfig_is_wifi_tethering_on() == TRUE) {
+ /* TODO: Wi-Fi tethering turns off here */
+
+ return;
+ }
+
+ if (netconfig_is_wifi_direct_on() == TRUE) {
+ __netconfig_wifi_direct_power_off();
+
+ return;
+ }
+
+ __netconfig_wifi_try_to_load_driver();
+
+ powered_off_by_flightmode = FALSE;
+ } else
+ DBG("Invalid value (%d)", value);
+}
+
+static void __netconfig_wifi_pm_state_mode(keynode_t* node,
+ void* user_data)
+{
+ int value = -1;
+ int wifi_state = 0;
+ static int prev_state = VCONFKEY_PM_STATE_NORMAL;
+
+ /*** vconf-keys.h ***
+ * VCONFKEY_PM_STATE_NORMAL = 1,
+ * VCONFKEY_PM_STATE_LCDDIM,
+ * VCONFKEY_PM_STATE_LCDOFF,
+ * VCONFKEY_PM_STATE_SLEEP
+ */
+
+ if(vconf_get_int(VCONFKEY_WIFI_STATE, &wifi_state) == 0) {
+ DBG("wifi state : %d (0 off / 1 on / 2 connected)", wifi_state);
+ if(wifi_state <= VCONFKEY_WIFI_OFF)
+ return;
+ }
+
+ if(vconf_get_int(VCONFKEY_PM_STATE, &value) < 0) {
+ ERR("VCONFKEY_PM_STATE get failed");
+ return;
+ }
+
+ DBG("Old state: %d, current: %d", prev_state, value);
+
+ if((value == VCONFKEY_PM_STATE_NORMAL) && (prev_state >= VCONFKEY_PM_STATE_LCDOFF)) {
+ DBG("PM state : Wake UP!");
+
+ netconfig_wifi_bgscan_stop();
+ netconfig_wifi_bgscan_start();
+ }
+
+ prev_state = value;
+}
+
+static void __netconfig_wifi_power_configuration(void)
+{
+ int wifi_last_state = 0;
+
+ vconf_notify_key_changed(VCONFKEY_SETAPPL_FLIGHT_MODE_BOOL,
+ __netconfig_wifi_airplane_mode, NULL);
+
+ vconf_notify_key_changed(VCONFKEY_PM_STATE,
+ __netconfig_wifi_pm_state_mode, NULL);
+
+ vconf_get_int(VCONF_WIFI_LAST_POWER_ON_STATE, &wifi_last_state);
+
+ if (wifi_last_state == WIFI_POWER_ON) {
+ if (netconfig_is_wifi_tethering_on() != TRUE &&
+ netconfig_is_wifi_direct_on() != TRUE) {
+ DBG("Turn Wi-Fi on automatically");
+
+ __netconfig_wifi_try_to_load_driver();
+ }
+ }
+}
+
+gpointer netconfig_wifi_create_and_init(DBusGConnection *conn)
+{
+ GObject *object;
+
+ g_return_val_if_fail(conn != NULL, NULL);
+
+ object = g_object_new(NETCONFIG_TYPE_WIFI, "conn", conn, "path",
+ NETCONFIG_WIFI_PATH, NULL);
+
+ INFO("create wifi(%p)", object);
+
+ dbus_g_connection_register_g_object(conn, NETCONFIG_WIFI_PATH, object);
+
+ INFO("wifi(%p) register DBus path(%s)", object, NETCONFIG_WIFI_PATH);
+
+ __netconfig_wifi_power_configuration();
+
+ return object;
+}
+
+gboolean netconfig_iface_wifi_load_driver(NetconfigWifi *wifi, GError **error)
+{
+ DBG("Check pre-condition to load Wi-Fi driver");
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ if (netconfig_is_wifi_tethering_on() == TRUE) {
+ /* TODO: Wi-Fi tethering turns off here */
+
+ /* return TRUE; */
+ return FALSE;
+ }
+
+ if (netconfig_is_wifi_direct_on() == TRUE) {
+ if (__netconfig_wifi_direct_power_off() == TRUE)
+ return TRUE;
+ else {
+ netconfig_error_wifi_direct_failed(error);
+ return FALSE;
+ }
+ }
+
+ DBG("Loading Wi-Fi driver");
+
+ if (__netconfig_wifi_try_to_load_driver() != TRUE) {
+ netconfig_error_wifi_driver_failed(error);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+gboolean netconfig_iface_wifi_remove_driver(NetconfigWifi *wifi, GError **error)
+{
+ DBG("Removing Wi-Fi driver");
+
+ g_return_val_if_fail(wifi != NULL, FALSE);
+
+ if (__netconfig_wifi_try_to_remove_driver() != TRUE)
+ {
+ netconfig_error_wifi_driver_failed(error);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
--- /dev/null
+/*
+ * Network Configuration Module
+ *
+ * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Danny JS Seo <S.Seo@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "log.h"
+#include "dbus.h"
+#include "wifi-state.h"
+
+static enum netconfig_wifi_service_state
+ wifi_service_state = NETCONFIG_WIFI_UNKNOWN;
+
+void netconfig_wifi_state_set_service_state(
+ enum netconfig_wifi_service_state state)
+{
+ if (wifi_service_state != state)
+ wifi_service_state = state;
+}
+
+static GSList *__netconfig_wifi_state_get_service_profiles(DBusMessage *message)
+{
+ GSList *service_profiles = NULL;
+ DBusMessageIter iter, dict;
+
+ dbus_message_iter_init(message, &iter);
+ dbus_message_iter_recurse(&iter, &dict);
+
+ while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter keyValue, array, value;
+ const char *key = NULL;
+ const char *object_path = NULL;
+
+ dbus_message_iter_recurse(&dict, &keyValue);
+ dbus_message_iter_get_basic(&keyValue, &key);
+
+ if (g_str_equal(key, "Services") != TRUE) {
+ dbus_message_iter_next(&dict);
+ continue;
+ }
+
+ dbus_message_iter_next(&keyValue);
+ dbus_message_iter_recurse(&keyValue, &array);
+ if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY)
+ return service_profiles;
+
+ dbus_message_iter_recurse(&array, &value);
+ if (dbus_message_iter_get_arg_type(&value) != DBUS_TYPE_OBJECT_PATH)
+ return service_profiles;
+
+ while (dbus_message_iter_get_arg_type(&value) == DBUS_TYPE_OBJECT_PATH) {
+ dbus_message_iter_get_basic(&value, &object_path);
+
+ if (g_str_has_prefix(object_path, "/profile/default/wifi_") ==TRUE)
+ service_profiles = g_slist_append(service_profiles, g_strdup(object_path));
+
+ dbus_message_iter_next(&value);
+ }
+
+ dbus_message_iter_next(&dict);
+ }
+
+ return service_profiles;
+}
+
+static enum netconfig_wifi_service_state
+__netconfig_wifi_state_get_state_from_service(DBusMessage *message)
+{
+ enum netconfig_wifi_service_state wifi_state = NETCONFIG_WIFI_UNKNOWN;
+ DBusMessageIter iter, array;
+
+ dbus_message_iter_init(message, &iter);
+ dbus_message_iter_recurse(&iter, &array);
+
+ while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter entry, dict;
+ const char *key = NULL;
+ const char *temp = NULL;
+
+ dbus_message_iter_recurse(&array, &entry);
+ dbus_message_iter_get_basic(&entry, &key);
+
+ if (g_str_equal(key, "Type") == TRUE) {
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &dict);
+ dbus_message_iter_get_basic(&dict, &temp);
+
+ if (g_str_equal(temp, "wifi") == TRUE)
+ break;
+ else
+ return wifi_state;
+ }
+
+ dbus_message_iter_next(&array);
+ }
+
+ dbus_message_iter_init(message, &iter);
+ dbus_message_iter_recurse(&iter, &array);
+
+ while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter entry, variant;
+ const char *key = NULL;
+ const char *value = NULL;
+
+ dbus_message_iter_recurse(&array, &entry);
+ dbus_message_iter_get_basic(&entry, &key);
+
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &variant);
+
+ if (g_str_equal(key, "State") != TRUE) {
+ dbus_message_iter_next(&array);
+ continue;
+ }
+
+ dbus_message_iter_get_basic(&variant, &value);
+
+ if (g_str_equal(value, "idle") == TRUE)
+ wifi_state = NETCONFIG_WIFI_IDLE;
+ else if (g_str_equal(value, "failure") == TRUE)
+ wifi_state = NETCONFIG_WIFI_IDLE;
+ else if (g_str_equal(value, "association") == TRUE)
+ wifi_state = NETCONFIG_WIFI_CONNECTING;
+ else if (g_str_equal(value, "configuration") == TRUE)
+ wifi_state = NETCONFIG_WIFI_CONNECTING;
+ else if (g_str_equal(value, "ready") == TRUE)
+ wifi_state = NETCONFIG_WIFI_CONNECTED;
+ else if (g_str_equal(value, "disconnect") == TRUE)
+ wifi_state = NETCONFIG_WIFI_IDLE;
+ else if (g_str_equal(value, "online") == TRUE)
+ wifi_state = NETCONFIG_WIFI_CONNECTED;
+ else
+ wifi_state = NETCONFIG_WIFI_UNKNOWN;
+
+ break;
+ }
+
+ return wifi_state;
+}
+
+static enum netconfig_wifi_service_state
+__netconfig_wifi_state_get_connman_service_state(void)
+{
+ enum netconfig_wifi_service_state wifi_state = NETCONFIG_WIFI_UNKNOWN;
+ DBusConnection *connection = NULL;
+ DBusMessage *message = NULL;
+ GSList *service_profiles = NULL;
+ GSList *list = NULL;
+
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (connection == NULL) {
+ ERR("Failed to get system bus");
+
+ return wifi_state;
+ }
+
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE, connection,
+ CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE, "GetProperties");
+ if (message == NULL) {
+ ERR("Failed to get service list");
+ dbus_connection_unref(connection);
+
+ return wifi_state;
+ }
+
+ /* Get service profiles from ConnMan Manager */
+ service_profiles = __netconfig_wifi_state_get_service_profiles(message);
+ dbus_message_unref(message);
+
+ for (list = service_profiles; list != NULL; list = list->next) {
+ char *profile_path = list->data;
+ enum netconfig_wifi_service_state wifi_service_state = wifi_state;
+
+ message = netconfig_invoke_dbus_method(CONNMAN_SERVICE, connection,
+ profile_path, CONNMAN_SERVICE_INTERFACE, "GetProperties");
+
+ if (message == NULL) {
+ ERR("Failed to get service information of %s", profile_path);
+ continue;
+ }
+
+ /* Get service information from ConnMan Service */
+ wifi_service_state = __netconfig_wifi_state_get_state_from_service(message);
+ if (wifi_state < wifi_service_state)
+ wifi_state = wifi_service_state;
+
+ dbus_message_unref(message);
+ }
+
+ g_slist_free(service_profiles);
+ dbus_connection_unref(connection);
+
+ return wifi_state;
+}
+
+enum netconfig_wifi_service_state
+netconfig_wifi_state_get_service_state(void)
+{
+ if (wifi_service_state == NETCONFIG_WIFI_CONNECTED)
+ return NETCONFIG_WIFI_CONNECTED;
+
+ return __netconfig_wifi_state_get_connman_service_state();
+}