apply FSL(Flora Software License)
authorKim Kibum <kb0929.kim@samsung.com>
Fri, 8 Jun 2012 05:54:03 +0000 (14:54 +0900)
committerKim Kibum <kb0929.kim@samsung.com>
Fri, 8 Jun 2012 05:54:03 +0000 (14:54 +0900)
30 files changed:
AUTHORS [new file with mode: 0644]
LICENSE [new file with mode: 0644]
Makefile.am [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
configure.ac [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/libnetwork-0.install.in [new file with mode: 0644]
debian/libnetwork-dev.install.in [new file with mode: 0644]
debian/rules [new file with mode: 0755]
include/common/network-cm-error.h [new file with mode: 0644]
include/common/network-cm-intf.h [new file with mode: 0644]
include/profile/network-pm-config.h [new file with mode: 0644]
include/profile/network-pm-intf.h [new file with mode: 0644]
include/profile/network-pm-wlan.h [new file with mode: 0644]
include/wifi/network-wifi-intf.h [new file with mode: 0644]
network.pc.in [new file with mode: 0644]
packaging/libnet-client.spec [new file with mode: 0644]
src/include/network-dbus-request.h [new file with mode: 0644]
src/include/network-internal.h [new file with mode: 0644]
src/include/network-signal-handler.h [new file with mode: 0644]
src/network-cm-intf.c [new file with mode: 0644]
src/network-dbus-request.c [new file with mode: 0644]
src/network-internal.c [new file with mode: 0644]
src/network-profile-intf.c [new file with mode: 0644]
src/network-signal-handler.c [new file with mode: 0644]
src/network-wifi-intf.c [new file with mode: 0644]
test/build.sh [new file with mode: 0755]
test/main.c [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..97f51db
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,2 @@
+Jeik Jaehyun Kim <jeik01.kim@samsung.com> 
+Danny Jeongseok Seo <s.seo@samsung.com>
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..7ccb5b5
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,75 @@
+Flora License
+
+Version 1.0, May, 2012
+
+http://www.tizenopensource.org/license
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
+
+"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
+
+"Tizen Certified Platform" shall mean a software platform that complies with the standards set forth in the Compatibility Definition Document and passes the Compatibility Test Suite as defined from time to time by the Tizen Technical Steering Group and certified by the Tizen Association or its designated agent.
+
+2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work solely as incorporated into a Tizen Certified Platform, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work solely as incorporated into a Tizen Certified Platform to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof pursuant to the copyright license above, in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
+
+  1. You must give any other recipients of the Work or Derivative Works a copy of this License; and
+
+  2. You must cause any modified files to carry prominent notices stating that You changed the files; and
+
+  3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
+
+  4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+
+APPENDIX: How to apply the Flora License to your work
+
+To apply the Flora License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Flora License, Version 1.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.tizenopensource.org/license
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..bcfa29f
--- /dev/null
@@ -0,0 +1,54 @@
+CPPFLAGS  =  $(DBUS_CFLAGS) $(GLIB_CFLAGS) $(DLOG_CFLAGS) $(VCONF_CFLAGS)
+
+ACLOCAL_AMFLAGS = -I m4
+
+####################################################################################
+#
+#                              network client library
+#
+####################################################################################
+
+lib_LTLIBRARIES = libnetwork.la
+
+CPPFLAGS += -DEXPORT_API="__attribute__((visibility(\"default\")))" -DPREFIX=\"$(PREFIX)\" -DVITA_FEATURE
+
+libnetwork_la_SOURCES = \
+                       src/network-wifi-intf.c \
+                       src/network-cm-intf.c \
+                       src/network-profile-intf.c \
+                       src/network-dbus-request.c \
+                       src/network-internal.c \
+                       src/network-signal-handler.c 
+
+libnetwork_la_CFLAGS = \
+              -I$(srcdir)/include \
+              -I$(srcdir)/include/wifi \
+              -I$(srcdir)/include/profile \
+              -I$(srcdir)/include/common \
+              -I$(srcdir)/src/include 
+
+libnetwork_la_CFLAGS += $(CPPFLAGS)
+
+libnetwork_la_LIBADD =  \
+                        $(DBUS_LIBS) $(GLIB_LIBS) $(VCONF_LIBS) \
+                        $(GTHREAD_LIBS) $(DLOG_LIBS) -lpthread -lrt
+
+includelibnetworkdir = $(includedir)/network
+
+includelibnetwork_HEADERS =  include/common/network-cm-intf.h \
+                       include/common/network-cm-error.h \
+                       include/profile/network-pm-intf.h \
+                       include/profile/network-pm-wlan.h \
+                       include/profile/network-pm-config.h \
+                       include/wifi/network-wifi-intf.h 
+
+libnetwork_la_CFLAGS += $(AM_FLAGS)
+
+pcfiles = network.pc 
+
+%.pc: %.pc
+       cp $< $@
+
+pkgconfigdir   = $(libdir)/pkgconfig
+
+pkgconfig_DATA = $(pcfiles)
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..db1e81a
--- /dev/null
@@ -0,0 +1,6 @@
+aclocal
+libtoolize
+autoheader
+autoconf
+automake --add-missing --copy --foreign
+
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..cfaf9b8
--- /dev/null
@@ -0,0 +1,73 @@
+#                                               -*- Autoconf -*-
+# Process this file with autoconf to produce a configure script.
+
+AC_PREREQ(2.61)
+AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
+AM_INIT_AUTOMAKE(src, 1.0)
+AC_CONFIG_HEADER([config.h])
+AC_CONFIG_MACRO_DIR([m4])
+
+# Checks for programs.
+AC_PROG_CC
+AC_PROG_INSTALL
+AC_PROG_MAKE_SET
+AC_PROG_LIBTOOL
+AC_PROG_CXX
+AC_PROG_AWK
+AC_PROG_CPP
+AC_PROG_LN_S
+
+LT_INIT
+
+# Checks for moduels.
+PKG_CHECK_MODULES(DBUS, dbus-glib-1)
+AC_SUBST(DBUS_CFLAGS)
+AC_SUBST(DBUS_LIBS)
+
+PKG_CHECK_MODULES(GTHREAD, gthread-2.0)
+AC_SUBST(GTHREAD_CFLAS)
+AC_SUBST(GTHREAD_LIBS)
+
+PKG_CHECK_MODULES(GLIB, glib-2.0 )
+AC_SUBST(GLIB_CFLAGS)
+AC_SUBST(GLIB_LIBS)
+
+PKG_CHECK_MODULES(DLOG, dlog )
+AC_SUBST(DLOG_CFLAGS)
+AC_SUBST(DLOG_LIBS)
+
+PKG_CHECK_MODULES(VCONF, vconf)
+AC_SUBST(VCONF_CFLAGS)
+AC_SUBST(VCONF_LIBS)
+
+if (!test $ARCH = "arm"); then
+       AM_CONDITIONAL(ARM_BUILD, false)
+else
+       AM_CONDITIONAL(ARM_BUILD, true)
+fi
+
+# Checks for header files.
+AC_HEADER_DIRENT
+AC_HEADER_STDC
+AC_CHECK_HEADERS([arpa/inet.h fcntl.h malloc.h netdb.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h syslog.h unistd.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_HEADER_STDBOOL
+AC_C_CONST
+AC_HEADER_TIME
+AC_STRUCT_TM
+AC_TYPE_UINT32_T
+
+# Checks for library functions.
+AC_FUNC_MALLOC
+AC_FUNC_REALLOC
+AC_FUNC_STAT
+AC_FUNC_VPRINTF
+AC_CHECK_FUNCS([getcwd gettimeofday memset mkdir socket dup2 gettimeofday inet_ntoa memset select socket strcasecmp strchr strerror strncasecmp strrchr strstr strtoul])
+
+AC_CONFIG_FILES(
+               [Makefile]
+               [network.pc]
+               )
+
+AC_OUTPUT
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..fb4501e
--- /dev/null
@@ -0,0 +1,8 @@
+libnet-client (0.1.64) unstable; urgency=low
+
+  * Update license
+  * Git: pkgs/l/libnet-client
+  * Tag: libnet-client_0.1.64
+
+ -- JaeHyun Kim <jeik01.kim@samsung.com>  Wed, 02 May 2012 17:13:07 +0900
+
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..11437f8
--- /dev/null
@@ -0,0 +1,24 @@
+Source: libnet-client
+Section: libs
+Priority: extra
+Maintainer: Jaehyun Kim <jeik01.kim@samsung.com>, Danny Jeongseok Seo <s.seo@samsung.com>
+Uploaders: Jaehyun Kim <jeik01.kim@samsung.com>, Misun Kim <ms0123.kim@samsung.com>, DongHoo Park <donghoo.park@samsung.com>
+Build-Depends: debhelper (>= 5), libslp-setting-dev, libglib2.0-dev, dlog-dev, libdbus-glib-1-dev
+Standards-Version: 3.7.2
+
+Package: libnetwork-0
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libglib2.0-0, libdbus-glib-1-2
+Description: network(connman) client library (Shared Library)
+
+Package: libnetwork-dev
+Section: libs
+Architecture: any
+Depends: libnetwork-0 (= ${Source-Version}), ${misc:Depends} 
+Description: network(connman) client library (Development)
+
+Package: libnetwork-dbg
+Architecture: any
+Depends: libnetwork-0 (= ${Source-Version}), ${misc:Depends}
+Description: debug symbols for network(connman) client library
diff --git a/debian/libnetwork-0.install.in b/debian/libnetwork-0.install.in
new file mode 100644 (file)
index 0000000..bf766f0
--- /dev/null
@@ -0,0 +1 @@
+@PREFIX@/lib/*.so*
diff --git a/debian/libnetwork-dev.install.in b/debian/libnetwork-dev.install.in
new file mode 100644 (file)
index 0000000..e021a29
--- /dev/null
@@ -0,0 +1,4 @@
+@PREFIX@/include/network/*.h
+@PREFIX@/lib/*.la
+@PREFIX@/lib/*.a
+@PREFIX@/lib/pkgconfig/network.pc
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..5c00620
--- /dev/null
@@ -0,0 +1,113 @@
+#!/usr/bin/make -f
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+
+# These are used for cross-compiling and for saving the configure script
+# from having to guess our platform (since we know it already)
+ DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+ DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+CFLAGS += -g -rdynamic
+CFLAGS += -Wall -Werror
+LDFLAGS ?=
+PREFIX ?= /usr
+DATADIR ?= /opt
+
+LDFLAGS += -Wl,--as-needed
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+       CFLAGS += -O0
+else
+       CFLAGS += -O2
+endif
+
+config.status: configure
+       dh_testdir
+       # Add here commands to configure the package.
+       DATAFS="$(PREFIX)" \
+       CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
+       ./configure --prefix=$(PREFIX)
+
+configure:
+       dh_testdir
+       ./autogen.sh
+                       
+build: build-stamp
+
+build-stamp: config.status 
+       dh_testdir
+
+       # Add here commands to compile the package.
+       $(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
+
+       # Add here commands to clean up after the build process.
+       -$(MAKE) distclean
+
+       find -name Makefile.in -exec rm -rf {} \;
+       rm -f aclocal.m4 config.guess config.h config.h.in config.sub configure depcomp install-sh ltmain.sh missing
+       rm -rf m4
+
+       for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+               rm -f $${f%.in}; \
+       done
+
+       rm -f ../libnetwork-*.deb    
+       rm -f ../network_*.dsc     
+       rm -f ../network_*.changes
+       rm -f ../libnetwork-*.deb  
+       rm -f ../network_*.tar.gz
+                                               
+       dh_clean 
+
+install: build
+       dh_testdir
+       dh_testroot
+       dh_clean -k 
+       dh_installdirs
+
+       # Add here commands to install the package into debian/.
+       $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+
+# 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_installman
+       dh_link
+       dh_strip --dbg-package=libnetwork-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
diff --git a/include/common/network-cm-error.h b/include/common/network-cm-error.h
new file mode 100644 (file)
index 0000000..3cb9975
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __NETWORK_CM_ERROR_H__
+#define __NETWORK_CM_ERROR_H__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @defgroup NETLIB Network Client Library
+ \{
+ <h1 class="pg">Introduction</h1>
+ Network Client Library provides specific APIs for interacting with the Network F/W.\n
+ Network F/W is based on ConnMan(Connection Manager), which provides cellular and Wi-Fi based network connection.
+ <h1 class="pg">Notice</h2>
+ Network Client Library doesn't provide certain thread-safety guarantees.\n
+ Application should use this library on a single thread only.
+ \}
+*/
+
+/**
+ * @defgroup NETLIB
+ \{
+ *     \defgroup common_basic  Basic APIs(connection, registration, etc...)
+ *     \defgroup common_info  APIs for get network information
+ *     \defgroup common_extended  Extended APIs
+ *     \defgroup profile_managing  profile managing APIs
+ *     \defgroup wifi_specific  Wi-Fi specific APIs
+ *     \defgroup pdp_specific  PDP specific APIs
+ \}
+*/
+
+/**
+ * @file network-cm-error.h
+ * @brief This file defines the common error code.
+*/
+
+/**
+ * \addtogroup  common_basic
+ * \{
+*/
+
+/*
+==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================
+*/
+
+/*
+==================================================================================================
+                                           CONSTANTS
+==================================================================================================
+*/
+/*
+==================================================================================================
+                                            MACROS
+==================================================================================================
+*/
+
+/*
+==================================================================================================
+                                            Enum
+==================================================================================================
+*/
+
+/**
+ * @enum net_err_t
+ * Error Definition
+ */
+
+typedef enum {
+       /** No error */
+       NET_ERR_NONE = 0x00,
+
+       /* Common Error value */
+
+       /** Error unknown */
+       NET_ERR_UNKNOWN = -999,
+
+       /* Client Register related Errors used in API return */
+
+       /** Application is already registered */
+       NET_ERR_APP_ALREADY_REGISTERED = -990,
+       /** Application is not registered */
+       NET_ERR_APP_NOT_REGISTERED = -989,
+
+       /* Connection Related Error */
+
+       /** No active connection exists for the given profile name */
+       NET_ERR_NO_ACTIVE_CONNECTIONS = -899,
+       /** Active connection already exists for the given profile name  */
+       NET_ERR_ACTIVE_CONNECTION_EXISTS = -898,
+
+       /** Connection failure : out of range */
+       NET_ERR_CONNECTION_OUT_OF_RANGE = -897,
+       /** Connection failure : pin missing */
+       NET_ERR_CONNECTION_PIN_MISSING = -896,
+       /** Connection failure : dhcp failed */
+       NET_ERR_CONNECTION_DHCP_FAILED = -895,
+       /** Connection failure */
+       NET_ERR_CONNECTION_CONNECT_FAILED = -894,
+       /** Connection failure : login failed */
+       NET_ERR_CONNECTION_LOGIN_FAILED = -893,
+       /** Connection failure : authentication failed */
+       NET_ERR_CONNECTION_AUTH_FAILED = -892,
+       /** Connection failure : invalid key */
+       NET_ERR_CONNECTION_INVALID_KEY = -891,
+
+       /* Other Error */
+
+       /** Access(permission) denied */
+       NET_ERR_ACCESS_DENIED = -799,
+       /** Operation is in progress */
+       NET_ERR_IN_PROGRESS = -798,
+       /** Operation was aborted by client or network*/
+       NET_ERR_OPERATION_ABORTED = -797,
+       /** Invalid value of API parameter */
+       NET_ERR_INVALID_PARAM = -796,
+       /** Invalid operation depending on current state */
+       NET_ERR_INVALID_OPERATION = -795,
+
+       /** Feature not supported */
+       NET_ERR_NOT_SUPPORTED = -794,
+       /** TimeOut Error */
+       NET_ERR_TIME_OUT = -793,
+       /** Network service is not available */
+       NET_ERR_NO_SERVICE = -792,
+       /** DBus can't find appropriate method */
+       NET_ERR_UNKNOWN_METHOD = -791,
+       /** Operation is restricted */
+       NET_ERR_SECURITY_RESTRICTED = -790,
+
+       /** WiFi driver on/off failed */
+       NET_ERR_WIFI_DRIVER_FAILURE = -699,
+} net_err_t;
+
+/*
+==================================================================================================
+                                 STRUCTURES AND OTHER TYPEDEFS
+==================================================================================================
+*/
+
+/*
+==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================
+*/
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+
diff --git a/include/common/network-cm-intf.h b/include/common/network-cm-intf.h
new file mode 100644 (file)
index 0000000..da20a58
--- /dev/null
@@ -0,0 +1,936 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __NETWORK_CM_INTF_H__        /* To prevent inclusion of a header file twice */
+#define __NETWORK_CM_INTF_H__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @file network-cm-intf.h
+ * @brief This file defines the interface of Connection Manager with the application.
+*/
+
+/**
+ * \addtogroup  common_basic
+ * \{
+*/
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+
+
+#include <sys/time.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <arpa/inet.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <sys/un.h>
+#include <errno.h>
+
+#include <netinet/in.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include <pthread.h>
+#include <signal.h>
+
+#include <sys/poll.h>
+
+#include <semaphore.h>
+#include <linux/unistd.h>
+
+#include "network-pm-intf.h"
+#include "network-cm-error.h"
+
+#ifndef DEPRECATED
+#define DEPRECATED __attribute__((deprecated))
+#endif
+
+/*==================================================================================================
+                                           CONSTANTS
+==================================================================================================*/
+
+/*==================================================================================================
+                                             ENUMS
+==================================================================================================*/
+
+/**
+ * @enum net_event_t
+ * Callback Event
+ */
+
+typedef enum
+{
+       /** Open Connection Response Event*/
+       NET_EVENT_OPEN_RSP,
+
+       /** Close Connection Response Event*/ 
+       NET_EVENT_CLOSE_RSP,
+       
+       /** Open connection Indication (auto join) */
+       NET_EVENT_OPEN_IND,
+
+       /** Connection Close Indication Event */
+       NET_EVENT_CLOSE_IND,
+
+       /** Network service(profile) state changed Indication Event*/
+       NET_EVENT_NET_STATE_IND,
+
+       /** Network IP change Indication Event\n
+        *  This is deprecated Event and maintained only for compatibility */
+       NET_EVENT_IP_CHANGE_IND,
+
+       /** Profile modify indication Event\n
+        *  This is deprecated Event and maintained only for compatibility */
+       NET_EVENT_PROFILE_MODIFY_IND,
+       
+       /** Network configuration changed Event\n
+        *  This is deprecated Event and maintained only for compatibility */
+       NET_EVENT_NET_CONFIGURE_RSP,
+
+       /* Wi-Fi Specific events */
+
+       /** Wi-Fi interface Scan Response Event */
+       NET_EVENT_WIFI_SCAN_RSP,
+       
+       /** Wi-Fi interface Scan Indication Event(BG scan) */
+       NET_EVENT_WIFI_SCAN_IND,
+
+       /** Wi-Fi interface MAC changed Event\n
+        *  This is deprecated Event and maintained only for compatibility */
+       NET_EVENT_WIFI_MAC_ID_IND,
+       
+       /** Wi-Fi interface Power On/Off Response Event */
+       NET_EVENT_WIFI_POWER_RSP,
+
+       /** Wi-Fi interface Power On/Off Indication Event */
+       NET_EVENT_WIFI_POWER_IND,
+
+       /** Wi-Fi interface WPS Response Event */
+       NET_EVENT_WIFI_WPS_RSP,
+
+} net_event_t;
+
+/**
+ * \}
+ */
+
+/**
+ * \addtogroup  common_info
+ * \{
+*/
+
+/**
+* @enum net_cm_network_status_t
+* This enum indicates network status
+*/
+typedef enum
+{
+       /** Service unknown */
+       NET_STATUS_UNKNOWN,
+       /** Not connected / Suspended / Idle / Connecting/ Disconnecting/ Killing*/
+       NET_STATUS_UNAVAILABLE,
+       /** Active */
+       NET_STATUS_AVAILABLE,
+} net_cm_network_status_t;
+
+/**
+ * \}
+ */
+
+/**
+ * \addtogroup  common_basic
+ * \{
+*/
+
+/*==================================================================================================
+                                 STRUCTURES AND OTHER TYPEDEFS
+==================================================================================================*/
+
+/**
+ * Event Info with Event on callback
+ */
+
+typedef struct
+{
+       /** CM Asynchronous event */
+       net_event_t     Event;
+       /** Profile Identifier corresponding to the event */
+       char            ProfileName[NET_PROFILE_NAME_LEN_MAX+1];
+       /** Event Status */
+       net_err_t       Error;
+       /** Event data length */
+       int             Datalength;
+       /** Event data: Depending on the event, Event Data will be
+       type-casted to the appropriate event info data structure */
+       void *          Data;
+} net_event_info_t;
+
+/*****************************************************************************************/
+/* Callback function prototype
+ * typedef void (*net_event_cb_t ) ( const net_event_info_t* net_event, void* user_data);
+ */
+
+/**
+ * \brief callback function: used to notify client application about Asynchronous events.
+ * This callback function will be called in the Network Client Library(NCL) context.
+ *
+ * \par Important Notes:
+ * NCL will allocate the memory for event data.
+ * Once Context will return from callback then NCL will free the memory allocated to event data.
+ * Application is not supposed to free the memory pointed by net_event
+ *
+ * \param[out] net_event    Pointer to net_event_info_t structure
+ * \param[out] user_data    User can transfer the user specific data in callback
+ *
+ * \par Description of each event type(net_event->Event) :
+ *
+ * - NET_EVENT_OPEN_RSP \n
+ *     Response event for (net_open_connection_with_profile(), net_open_connection_with_preference(), net_open_connection_with_wifi_info())
+ *     to notify the result of open connection request.
+ *   - net_event->ProfileName : Profile Identifier corresponding to the event
+ *   - net_event->Error       : Its value will be NET_ERR_NONE in case of success and error cause in case of failure
+ *   - net_event->Data        : Pointer to net_profile_info_t (valid at NET_ERR_NONE, NET_ERR_ACTIVE_CONNECTION_EXISTS)
+ *     - If the connection open successfully or already exists for the given profile name,\n
+ *       application can get the connected profile information \n
+ *       If the connection is failed to establish, net_profile_info_t also contains NULL value
+ *
+ * - NET_EVENT_CLOSE_RSP \n
+ *     Response event for net_close_connection() to notify the result of close connection request.
+ *   - net_event->ProfileName : Profile Identifier corresponding to the event
+ *   - net_event->Error       : Its value will be NET_ERR_NONE in case of success and error cause in case of failure
+ *   - net_event->Data        : NULL (not used in this event)
+ *
+ * - NET_EVENT_OPEN_IND \n
+ *     Indication to notify the activation of a connection by any other application or auto-connection.
+ *   - net_event->ProfileName : Profile Identifier corresponding to the event
+ *   - net_event->Error       : Its value will be NET_ERR_NONE in case of success and error cause in case of failure
+ *   - net_event->Data        : Pointer to net_profile_info_t
+ *     - If NCL can't get profile info from ConnMan, net_profile_info_t contains NULL value
+ *
+ * - NET_EVENT_CLOSE_IND \n
+ *     Indication to notify the closure of an active connection due to network initiated termination or any other transport connectivity loss.
+ *   - net_event->ProfileName : Profile Identifier corresponding to the event
+ *   - net_event->Error       : Its value will be NET_ERR_NONE always
+ *   - net_event->Data        : NULL (not used in this event)
+ *
+ * - NET_EVENT_NET_STATE_IND \n
+ *     Indication to notify that state of each serivce(profile) changed.\n
+ *     You can use this event to get more detailed state, but should be used carefully.\n
+ *     This event comes from ConnMan daemon via NCL, so you have to understand ConnMan's state.\n
+ *     There is no need to handle this event except under special circumstances.
+ *   - net_event->ProfileName : Profile Identifier corresponding to the event
+ *   - net_event->Error       : Its value will be NET_ERR_NONE always
+ *   - net_event->Data        : Pointer to net_state_type_t
+ *
+ * - NET_EVENT_WIFI_SCAN_RSP \n
+ *     Response event for net_scan_wifi() to notify the result of scan request.
+ *   - net_event->ProfileName : NULL (not used in this event)
+ *   - net_event->Error       : NET_ERR_NONE on success, negative values for errors
+ *   - net_event->Data        : NULL (not used in this event)
+ *
+ * - NET_EVENT_WIFI_SCAN_IND \n
+ *     Indication to notify that BG scan has been completed.
+ *   - net_event->ProfileName : NULL (not used in this event)
+ *   - net_event->Error       : NET_ERR_NONE on success, negative values for errors
+ *   - net_event->Data        : NULL (not used in this event)
+ *
+ * - NET_EVENT_WIFI_POWER_RSP \n
+ *     Response event for (net_wifi_power_on(), net_wifi_power_off()) to notify the result of Wi-Fi power on request.
+ *   - net_event->ProfileName : NULL (not used in this event)
+ *   - net_event->Error       : NET_ERR_NONE on success, negative values for errors
+ *   - net_event->Data        : Pointer to net_wifi_state_t (only WIFI_OFF/WIFI_ON/WIFI_UNKNOWN will be set)
+ *
+ * - NET_EVENT_WIFI_POWER_IND \n
+ *     Indication to notify that Wi-Fi power state has been changed.
+ *   - net_event->ProfileName : NULL (not used in this event)
+ *   - net_event->Error       : NET_ERR_NONE on success, negative values for errors
+ *   - net_event->Data        : Pointer to net_wifi_state_t (only WIFI_OFF/WIFI_ON/WIFI_UNKNOWN will be set)
+ *
+ * - NET_EVENT_WIFI_WPS_RSP \n
+ *     Response event for net_wifi_enroll_wps() to notify the result of enroll wps request.
+ *   - net_event->ProfileName : Profile Identifier corresponding to the event
+ *   - net_event->Error       : Its value will be NET_ERR_NONE in case of success and error cause in case of failure
+ *   - net_event->Data        : Pointer to net_profile_info_t
+ *     - If the connection open successfully, application can get the connected profile information \n
+ *       If the connection is failed to establish, net_profile_info_t also contains NULL value
+ *
+ */
+
+typedef void (*net_event_cb_t ) ( const net_event_info_t* net_event, void* user_data);
+
+/*==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================*/
+
+/*****************************************************************************************/
+/* net_register_client API function prototype
+ * int net_register_client(net_event_cb_t event_cb, void *user_data);
+ */
+
+/**
+ * \brief      This API shall register the client application with the ConnMan.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important Notes:
+ *        It is mandatory for the client application to register with ConnMan with this API before using any of its services.\n
+ *        The value of event_cb cannot be NULL. Otherwise, error NET_ERR_INVALID_PARAM will be returned by the API.\n
+ *        All the Asynchronous Events from ConnMan will be sent to the client App through the callback function (event_cb) registered with this API.
+ *
+ * \warning
+ *  None
+ *
+ * \param[in] event_cb     Application Callback function pointer to receive ConnMan events
+ * \param[in] user_data    user data 
+ *
+ * \par Async Response Message:
+ *        None.
+ * \par Precondition:
+ *        None.
+ *
+ * \return Return Type (int) \n
+ * - NET_ERR_NONE  - indicating that the operation has completed successfully.\n
+ * - NET_ERR_INVALID_PARAM - indicating that API parameter value is invalid.\n
+ * - NET_ERR_APP_ALREADY_REGISTERED - indicating that client application is already registered,it can't be registered again.\n
+ * - NET_ERR_UNKNOWN - indicating that registration has failed.\n
+ *
+ * \par Prospective Clients:
+ * External Apps.
+ *
+ * \par Example Program:
+ *
+ * int result;
+ *
+ * result = net_register_client(event_cb , user_data);
+ *
+ * if(result == NET_ERR_NONE).........
+ *
+ *
+ *
+******************************************************************************************/
+int net_register_client(net_event_cb_t event_cb, void *user_data);
+
+/*****************************************************************************************/
+/* net_deregister_client API function prototype
+* int net_deregister_client(void);
+*/
+
+/**
+ * \brief This API shall deregister the client application with the ConnMan.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important Notes:
+ *        After deregistration, Application will be restricted from using other ConnMan APIs/Services.\n
+ *        De-register is not allowed when any connection is in active or transition state (activation or deactivation in progress).
+ *
+ * \warning
+ *  None
+ *
+ *
+ * \par Async Response Message:
+ *        None
+ *
+ * \par Precondition:
+ *        Application must already be registered with the ConnMan.
+ *
+ * \return Return Type (int) \n
+ * - NET_ERR_NONE  - indicating that the operation has completed successfully. \n
+ * - NET_ERR_APP_NOT_REGISTERED - indicating that client is not registered with CM and it cannot use CM services.\n
+ * - NET_ERR_UNKNOWN - indicating that an unknown error has occurred.\n
+ *
+ *
+ * \par Prospective Clients:
+ * External Apps.
+ *
+ * \par Example Program:
+ *
+ * int result;
+ *
+ * result = net_deregister_client();
+ *
+ * if(result == NET_ERR_NONE).........
+ *
+ *
+ *
+******************************************************************************************/
+int net_deregister_client(void);
+
+/*****************************************************************************************/
+/* net_open_connection_with_profile API function prototype
+ * int net_open_connection_with_profile(const char *profile_name);
+ */
+
+/**
+ * \brief  This API will establish a data connection with specific profile name
+ *
+ * \par Sync (or) Async:
+ * This is an Asynchronous API.
+ *
+ * \par Important Notes:
+ *        This API is a Non-Blocking API. Return value only implies whether the request is sent successfully or not. \n
+ *            Return value Success does not imply that the connection is established successfully. \n
+ *           If application needs to make a connection with specific profile name, it can make a connection with this api. \n
+ *           Get the profile name is referred to net_get_profile_list(). \n
+ *           If Connection is already existed, this API will share the active connection with the calling application. \n
+ *           If Connection is already existed, and same application is trying to open connection, this API will return error.
+ *
+ * \par Notes :
+ *
+ *     ConnMan requests transport plug-in interface to open a new connection only if connection is not already established. \n
+ *      If there is already a connection , then same connection will be shared.
+ *
+ * \warning
+ *  None
+ *
+ * \param [in] profile_name     specific profile name
+ *
+ * \par Async Response Message:
+ *        NET_EVENT_OPEN_RSP: Connection Establishment response will be sent asynchronously to the App in the callback function registered.\n
+ *        refer to net_event_cb_t()
+ *
+ * \par Precondition:
+ *        Application must already be registered with the ConnMan.
+ *
+ * \return Return Type (int) \n
+ * - NET_ERR_NONE  - indicating that the operation has completed successfully. \n
+ * - NET_ERR_APP_NOT_REGISTERED -indicating that client is not registered with CM and it cannot use CM services.\n
+ * - NET_ERR_INVALID_PARAM - indicating that API parameter value is invalid.\n
+ * - NET_ERR_INVALID_OPERATION  - indicating that open connection operation is not allowed in the current state.\n
+ * - NET_ERR_UNKNOWN - indicating that an unknown error has occurred.\n
+ *
+ *
+ * \par Prospective Clients:
+ * External Apps.
+ *
+ * \par Example Program:
+ *
+ * int result;
+ *
+ * result = net_open_connection_with_profile(profile_name);
+ *
+ * if(result == NET_ERR_NONE)......
+ *
+ *
+ *
+******************************************************************************************/
+int net_open_connection_with_profile(const char *profile_name);
+
+/*****************************************************************************************/
+/* net_open_connection_with_preference API function prototype
+ * int net_open_connection_with_preference(net_service_type_t service_type);
+ */
+
+/**
+ * \brief  This API will establish a data connection with specific service type
+ *
+ * \par Sync (or) Async:
+ * This is an Asynchronous API.
+ *
+ * \par Important Notes:
+ *        This API is a Non-Blocking API. Return value only implies whether the request is sent successfully or not. \n
+ *            Return value Success does not imply that the connection is established successfully. \n
+ *           If application needs to make a connection with specific service type, it can make a connection with this api. \n
+ *           If Connection is already existed, this API will share the active connection with the calling application. \n
+ *           If Connection is already exited, and same application is trying to open connection, this API will return error.
+ *
+ * \par Notes :
+ *
+ *     ConnMan requests transport plug-in interface to open a new connection only if connection is not already established. \n
+ *      If there is already a connection , then same connection will be shared.
+ *
+ * \warning
+ *  None
+ *
+ * \param [in] service_type     specific service type
+ *
+ * \par Async Response Message:
+ *        NET_EVENT_OPEN_RSP: Connection Establishment response will be sent asynchronously to the App in the callback function registered.\n
+ *        refer to net_event_cb_t()
+ *
+ * \par Precondition:
+ *        Application must already be registered with the ConnMan.
+ *
+ * \return Return Type (int) \n
+ * - NET_ERR_NONE - indicating that the operation has completed successfully. \n
+ * - NET_ERR_APP_NOT_REGISTERED - indicating that client is not registered with CM and it cannot use CM services.\n
+ * - NET_ERR_INVALID_PARAM - indicating that API parameter value is invalid.\n
+ * - NET_ERR_INVALID_OPERATION - indicating that open connection operation is not allowed in the current state.\n
+ * - NET_ERR_NO_SERVICE - indicating that service is not found.\n
+ * - NET_ERR_UNKNOWN - indicating that an unknown error has occurred.\n
+ *
+ *
+ * \par Prospective Clients:
+ * External Apps.
+ *
+ * \par Example Program:
+ *
+ * int result;
+ *
+ * result = net_open_connection_with_preference(service_type);
+ *
+ * if(result == NET_ERR_NONE)......
+ *
+ *
+ *
+******************************************************************************************/
+int net_open_connection_with_preference(net_service_type_t service_type);
+
+/*****************************************************************************************/
+/* net_close_connection API function prototype
+ * int net_close_connection(const char *profile_name);
+ */
+
+/**
+ * \brief      This API will terminate the connection. This API can also be used to abort a connection in progress.
+ *
+ * \par Sync (or) Async:
+ * This is an Asynchronous API.
+ *
+ * \par Important Notes:
+ *        This API is an Asynchronous API. Return value only implies whether the request is sent successfully or not. Return value Success doesn't imply that the connection is disconnected successfully.\n
+ *
+ * \warning
+ *  None
+ *
+ * \par Notes :
+ *             Application must be already registered with the ConnMan. \n
+ *
+ * \param [in] profile_name     specific profile name
+ *
+ * \par Async Response Message:
+ *        NET_EVENT_CLOSE_RSP: Connection Close response will be sent asynchronously to the App in the callback function registered\n
+ *        refer to net_event_cb_t()
+ *
+ * \par Precondition:
+ *        Application must have an active data connection
+ *
+ * \return Return Type (int) \n
+ * - NET_ERR_NONE  - indicating that the operation has completed successfully. \n
+ * - NET_ERR_APP_NOT_REGISTERED - indicating that client is not registered with CM and it cannot use CM services.\n
+ * - NET_ERR_INVALID_OPERATION  - indicating that close connection operation is not allowed in the current state.\n
+ * - NET_ERR_UNKNOWN - indicating that an unknown error has occurred.\n
+ *
+ * \par Prospective Clients:
+ * External Apps.
+ *
+ * \par Example Program:
+ *
+ * int result;
+ *
+ * result = net_close_connection(profile_name);
+ *
+ * if(result == NET_ERR_NONE).........
+ *
+ *
+ *
+******************************************************************************************/
+int net_close_connection(const char *profile_name);
+
+/**
+ * \}
+ */
+
+/**
+ * \addtogroup  common_info
+ * \{
+*/
+
+/*****************************************************************************************/
+/* net_get_active_net_info API function prototype
+ * int net_get_active_net_info(net_profile_info_t *active_profile_info);
+ */
+
+/**
+ * \brief  This API returns the information of active(default) network profile.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important Notes:
+ *             On success, profile information shall be copied to active_profile_info parameter in net_profile_info_t format.
+ *
+ * \par Notes :
+ *  None
+ *
+ * \warning
+ *  None
+ *
+ * \param[out]         active_profile_info     The information of active(default) network profile.
+ *
+ * \par Async Response Message:
+ *  None
+ *
+ * \par Precondition:
+ *        Application must already be registered with the CM server.
+ *
+ * \return Return Type (int) \n
+ * - NET_ERR_NONE  - indicating that the status of queried network interface is retrieved. \n
+ * - NET_ERR_APP_NOT_REGISTERED - indicating that client is not registered with CM and it cannot use CM services.\n
+ * - NET_ERR_UNKNOWN - indicating that an unknown error has occurred.\n
+ * - NET_ERR_INVALID_PARAM - indicating that API parameter value is invalid.\n
+ * - NET_ERR_NO_SERVICE - indicating that there is no active network.\n
+ *
+ * \par Prospective Clients:
+ * External Apps.
+ *
+ * \par Example Program:
+ *
+ * net_profile_info_t active_profile_info;
+ *
+ * int result = net_get_active_net_info(&active_profile_info);
+ *
+ * if(result == NET_ERR_NONE)......
+ *
+ *
+ *
+******************************************************************************************/
+int net_get_active_net_info(net_profile_info_t *active_profile_info);
+
+/*****************************************************************************************/
+/**
+ * \brief  This API returns ip address of active(default) network profile.
+ *
+ * \par Sync (or) Async:
+ * These is a Synchronous API.
+ *
+ * \par Important Notes:
+ *             On success, the information shall be copied to the parameter in each format.
+ *
+ * \param[out]         ip_address  ip address of active(default) network profile.
+ *
+ * \par Precondition:
+ *        Application must already be registered with the CM server.
+ *
+ * \return Return Type (int) \n
+ * - NET_ERR_NONE  - indicating that the status of queried network interface is retrieved. \n
+ * - NET_ERR_APP_NOT_REGISTERED - indicating that client is not registered with CM and it cannot use CM services.\n
+ * - NET_ERR_UNKNOWN - indicating that an unknown error has occurred.\n
+ * - NET_ERR_INVALID_PARAM - indicating that API parameter value is invalid.\n
+ * - NET_ERR_NO_SERVICE - indicating that there is no active network.\n
+ *
+ * \par Prospective Clients:
+ * External Apps.
+ *
+ * \par Example Program:
+ *
+ * net_addr_t ip_address;
+ *
+ * int result = net_get_active_ipaddress(&ip_address);
+ *
+ * if(result == NET_ERR_NONE)......
+ *
+******************************************************************************************/
+int net_get_active_ipaddress(net_addr_t *ip_address);
+
+/*****************************************************************************************/
+/**
+ * \brief  This API returns netmask address of active(default) network profile.
+ *
+ * \par Sync (or) Async:
+ * These is a Synchronous API.
+ *
+ * \par Important Notes:
+ *             On success, the information shall be copied to the parameter in each format.
+ *
+ * \param[out]         netmask  netmask address of active(default) network profile.
+ *
+ * \par Precondition:
+ *        Application must already be registered with the CM server.
+ *
+ * \return Return Type (int) \n
+ * - NET_ERR_NONE  - indicating that the status of queried network interface is retrieved. \n
+ * - NET_ERR_APP_NOT_REGISTERED - indicating that client is not registered with CM and it cannot use CM services.\n
+ * - NET_ERR_UNKNOWN - indicating that an unknown error has occurred.\n
+ * - NET_ERR_INVALID_PARAM - indicating that API parameter value is invalid.\n
+ * - NET_ERR_NO_SERVICE - indicating that there is no active network.\n
+ *
+ * \par Prospective Clients:
+ * External Apps.
+ *
+ * \par Example Program:
+ *
+ * net_addr_t netmask;
+ *
+ * int result = net_get_active_netmask(&netmask);
+ *
+ * if(result == NET_ERR_NONE)......
+ *
+******************************************************************************************/
+int net_get_active_netmask(net_addr_t *netmask);
+
+/*****************************************************************************************/
+/**
+ * \brief  This API returns gateway address of active(default) network profile.
+ *
+ * \par Sync (or) Async:
+ * These is a Synchronous API.
+ *
+ * \par Important Notes:
+ *             On success, the information shall be copied to the parameter in each format.
+ *
+ * \param[out]         gateway  gateway address of active(default) network profile.
+ *
+ * \par Precondition:
+ *        Application must already be registered with the CM server.
+ *
+ * \return Return Type (int) \n
+ * - NET_ERR_NONE  - indicating that the status of queried network interface is retrieved. \n
+ * - NET_ERR_APP_NOT_REGISTERED - indicating that client is not registered with CM and it cannot use CM services.\n
+ * - NET_ERR_UNKNOWN - indicating that an unknown error has occurred.\n
+ * - NET_ERR_INVALID_PARAM - indicating that API parameter value is invalid.\n
+ * - NET_ERR_NO_SERVICE - indicating that there is no active network.\n
+ *
+ * \par Prospective Clients:
+ * External Apps.
+ *
+ * \par Example Program:
+ *
+ * net_addr_t gateway;
+ *
+ * int result = net_get_active_gateway(&gateway);
+ *
+ * if(result == NET_ERR_NONE)......
+ *
+******************************************************************************************/
+int net_get_active_gateway(net_addr_t *gateway);
+
+/*****************************************************************************************/
+/**
+ * \brief  This API returns DNS address of active(default) network profile.
+ *
+ * \par Sync (or) Async:
+ * These is a Synchronous API.
+ *
+ * \par Important Notes:
+ *             On success, the information shall be copied to the parameter in each format.
+ *
+ * \param[out]         dns  DNS address of active(default) network profile.
+ *
+ * \par Precondition:
+ *        Application must already be registered with the CM server.
+ *
+ * \return Return Type (int) \n
+ * - NET_ERR_NONE  - indicating that the status of queried network interface is retrieved. \n
+ * - NET_ERR_APP_NOT_REGISTERED - indicating that client is not registered with CM and it cannot use CM services.\n
+ * - NET_ERR_UNKNOWN - indicating that an unknown error has occurred.\n
+ * - NET_ERR_INVALID_PARAM - indicating that API parameter value is invalid.\n
+ * - NET_ERR_NO_SERVICE - indicating that there is no active network.\n
+ *
+ * \par Prospective Clients:
+ * External Apps.
+ *
+ * \par Example Program:
+ *
+ * net_addr_t dns;
+ *
+ * int result = net_get_active_dns(&dns);
+ *
+ * if(result == NET_ERR_NONE)......
+ *
+******************************************************************************************/
+int net_get_active_dns(net_addr_t *dns);
+
+/*****************************************************************************************/
+/**
+ * \brief  This API returns ESSID of active(default) network profile.
+ *
+ * \par Sync (or) Async:
+ * These is a Synchronous API.
+ *
+ * \par Important Notes:
+ *             On success, the information shall be copied to the parameter in each format.
+ *
+ * \param[out]         essid  ESSID of active(default) network profile.
+ *
+ * \par Precondition:
+ *        Application must already be registered with the CM server and wifi is connected.
+ *
+ * \return Return Type (int) \n
+ * - NET_ERR_NONE  - indicating that the status of queried network interface is retrieved. \n
+ * - NET_ERR_APP_NOT_REGISTERED - indicating that client is not registered with CM and it cannot use CM services.\n
+ * - NET_ERR_UNKNOWN - indicating that an unknown error has occurred.\n
+ * - NET_ERR_INVALID_PARAM - indicating that API parameter value is invalid.\n
+ * - NET_ERR_NO_SERVICE - indicating that there is no active network.\n
+ *
+ * \par Prospective Clients:
+ * External Apps.
+ *
+ * \par Example Program:
+ *
+ * net_essid_t essid;
+ *
+ * int result = net_get_active_essid(&essid);
+ *
+ * if(result == NET_ERR_NONE)......
+ *
+******************************************************************************************/
+int net_get_active_essid(net_essid_t *essid);
+
+/*****************************************************************************************/
+/**
+ * \brief  This API returns proxy string of active(default) network profile.
+ *
+ * \par Sync (or) Async:
+ * These is a Synchronous API.
+ *
+ * \par Important Notes:
+ *             On success, the information shall be copied to the parameter in each format.
+ *
+ * \param[out]         proxy  proxy string of active(default) network profile.
+ *
+ * \par Precondition:
+ *        Application must already be registered with the CM server.
+ *
+ * \return Return Type (int) \n
+ * - NET_ERR_NONE  - indicating that the status of queried network interface is retrieved. \n
+ * - NET_ERR_APP_NOT_REGISTERED - indicating that client is not registered with CM and it cannot use CM services.\n
+ * - NET_ERR_UNKNOWN - indicating that an unknown error has occurred.\n
+ * - NET_ERR_INVALID_PARAM - indicating that API parameter value is invalid.\n
+ * - NET_ERR_NO_SERVICE - indicating that there is no active network.\n
+ *
+ * \par Prospective Clients:
+ * External Apps.
+ *
+ * \par Example Program:
+ *
+ * net_proxy_t proxy;
+ *
+ * int result = net_get_active_proxy(&proxy);
+ *
+ * if(result == NET_ERR_NONE)......
+ *
+******************************************************************************************/
+int net_get_active_proxy(net_proxy_t *proxy);
+
+/*****************************************************************************************/
+/* net_get_network_status API function prototype
+ * int net_get_network_status(net_device_t device_type, net_cm_network_status_t* network_status);
+ */
+
+/**
+ * \brief  This API returns The status of a specific network interface passed as a parameter.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important Notes:
+ *  None
+ *
+ * \par Notes :
+ *  None
+ *
+ * \warning
+ *  None
+ *
+ * \param[in]  device_type     Queried network interface.
+ * \param[out]         network_status  The status of Queried network interface.
+ *
+ * \par Async Response Message:
+ *  None
+ *
+ * \par Precondition:
+ *        Application must already be registered with the CM server.
+ *
+ * \return Return Type (int) \n
+ * - NET_ERR_NONE  - indicating that the status of queried network interface is retrieved. \n
+ * - NET_ERR_APP_NOT_REGISTERED - indicating that client is not registered with CM and it cannot use CM services.\n
+ * - NET_ERR_UNKNOWN - indicating that an unknown error has occurred.\n
+ * - NET_ERR_INVALID_PARAM - indicating that API parameter value is invalid.\n
+ *
+ * \par Prospective Clients:
+ * External Apps.
+ *
+ * \par Example Program:
+ *
+ * net_cm_network_status_t status;
+ *
+ * int result = net_get_network_status(NET_MOBILE_TYPE, &status);
+ *
+ * if(result == TRUE)......
+ *
+ *
+ *
+******************************************************************************************/
+int net_get_network_status(net_device_t device_type, net_cm_network_status_t* network_status);
+
+/*****************************************************************************************/
+/* net_is_connected API function prototype
+ * int net_is_connected(void);
+ */
+
+/**
+ * \brief  This API returns the connection status of process
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important Notes:
+ *  None
+ *
+ * \par Notes :
+ *  None
+ *
+ * \warning
+ *  None
+ *
+ *
+ * \par Async Response Message:
+ *  None
+ *
+ * \par Precondition:
+ *        Application must already be registered with the CM server.
+ *
+ * \return Return Type (int) \n
+ * - 1  - connected
+ * - 0 - not connected
+ *
+ * \par Prospective Clients:
+ * External Apps.
+ *
+ * \par Example Program:
+ *
+ * int result = net_is_connected();
+ *
+ * if(result == 1)......
+ *
+ *
+ *
+******************************************************************************************/
+int net_is_connected(void);
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
diff --git a/include/profile/network-pm-config.h b/include/profile/network-pm-config.h
new file mode 100644 (file)
index 0000000..591d3df
--- /dev/null
@@ -0,0 +1,334 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __NETWORK_PM_CONFIG_H__
+#define __NETWORK_PM_CONFIG_H__
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+/**
+ * @file network-pm-config.h
+ * @brief This file defines the constants and enumerations used by Profile Manager with the application/Connection Manager.
+*/
+
+/**
+ * \addtogroup  profile_managing
+ * \{
+*/
+
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+
+#include <netinet/in.h>
+
+#include "network-cm-error.h"
+
+/*==================================================================================================
+                                           CONSTANTS
+==================================================================================================*/
+
+/** Profile name max length */
+#define NET_PROFILE_NAME_LEN_MAX 512
+
+/** Home URL max length in profile account */
+#define NET_HOME_URL_LEN_MAX 512
+
+/** Maximum length of IPv4 string type e.g., "165.213.173.105". This length does not include NULL in the last byte. */
+#define NETPM_IPV4_STR_LEN_MAX 15
+
+/** Minimum length of IPv4 string type e.g., "0.0.0.0". This length does not include NULL in the last byte. */
+#define NETPM_IPV4_STR_LEN_MIN 7
+
+/** This is for MCC + MNC string */
+#define NET_SIM_INFO_LEN 10
+
+/** Maximum length of username in PDP profile. (used in authentication parameters) [3GPP Defined variable] */
+#define NET_PDP_AUTH_USERNAME_LEN_MAX 32 
+
+/** Maximum length of password in PDP profile (used in authentication parameters) [3GPP Defined variable] */
+#define NET_PDP_AUTH_PASSWORD_LEN_MAX 32
+
+/** Maximum length of APN in PDP profile [3GPP Defined variable] */
+#define NET_PDP_APN_LEN_MAX 100
+
+/** Maximum length of proxy string */
+#define NET_PROXY_LEN_MAX 64
+
+/** MAX number of DNS Address */
+#define        NET_DNS_ADDR_MAX 2
+
+/** Maximum length of device name  */
+#define        NET_MAX_DEVICE_NAME_LEN 32
+
+/** Maximum length of MAC address  */
+#define        NET_MAX_MAC_ADDR_LEN 32
+
+/*==================================================================================================
+                                             ENUMS
+==================================================================================================*/
+
+/**
+ * @enum net_device_t
+ * Profile Type
+ */
+typedef enum
+{
+       /** Unknown device */
+       NET_DEVICE_UNKNOWN = 0x0,
+
+       /** Default device */
+       NET_DEVICE_DEFAULT = 0x1,
+
+       /** GPRS & WCDMA device */
+       NET_DEVICE_CELLULAR = 0x2,
+
+       /** WLAN device */
+       NET_DEVICE_WIFI = 0x3,
+
+       /** Serial USB device */
+       NET_DEVICE_USB = 0x4,
+
+       /** Count of device type */
+       NET_DEVICE_MAX = 0x5,
+} net_device_t;
+
+/**
+ * @enum net_addr_type_t
+ * Address Type
+ */
+typedef enum
+{
+
+       /** IPV4 Address type */
+       NET_ADDR_IPV4 = 0x0,
+
+       /** IPV6 Address type */
+       NET_ADDR_IPV6 = 0x1,
+} net_addr_type_t;
+
+/**
+ * @enum net_auth_type_t
+ * PDP Authentication Type
+ */
+typedef enum
+{
+
+       /** No authentication */
+       NET_PDP_AUTH_NONE       = 0x0,
+
+       /** PAP authentication */
+       NET_PDP_AUTH_PAP        = 0x1,
+
+       /** CHAP authentication */
+       NET_PDP_AUTH_CHAP       = 0x2,
+} net_auth_type_t;
+
+/**
+ * @enum net_proxy_type_t
+ * This enumeration defines the proxy method type.
+ */
+typedef enum
+{
+       /** Not defined */
+       NET_PROXY_TYPE_UNKNOWN  = 0x00, 
+       /** Direct connection */
+       NET_PROXY_TYPE_DIRECT = 0x01,
+       /** Auto configuration(Use PAC file)
+        *  If URL property is not set, DHCP/WPAD auto-discover will be tried */
+       NET_PROXY_TYPE_AUTO = 0x02,
+       /** Manual configuration */
+       NET_PROXY_TYPE_MANUAL= 0x03,
+} net_proxy_type_t;
+
+/**
+* @enum net_service_type_t
+* This enum indicates network connection type
+*/
+typedef enum
+{
+       /** Unknown type \n
+       */
+       NET_SERVICE_UNKNOWN = 0x00,
+
+       /** Mobile Internet Type \n
+               Network connection is established in Cellular network for Internet \n
+       */
+       NET_SERVICE_INTERNET = 0x01,
+
+       /** Mobile MMS Type \n
+               Network connection is established in Cellular network for MMS \n
+       */
+       NET_SERVICE_MMS = 0x02,
+
+       /** Mobile WAP Type \n
+               Network connection is established in Cellular network for WAP \n
+       */
+       NET_SERVICE_WAP = 0x03,
+
+       /** Prepaid Mobile Internet Type \n
+               Network connection is established in Cellular network for prepaid internet service.\n
+               This service supports to establish network connection in prepaid sim case\n
+       */
+       NET_SERVICE_PREPAID_INTERNET = 0x04,
+
+       /** Prepaid Mobile MMS Type \n
+               Network Connection is established in Cellular network for prepaid MMS service. \n
+               This profile supports to establish network connection in prepaid sim case\n
+       */
+       NET_SERVICE_PREPAID_MMS = 0x05,
+} net_service_type_t;
+
+
+/**
+ * @enum net_ip_config_type_t
+ * Net IP configuration Type
+ */
+typedef enum
+{
+       /** Manual IP configuration */
+       NET_IP_CONFIG_TYPE_STATIC = 0x01,
+
+       /** Config ip using DHCP client*/
+       NET_IP_CONFIG_TYPE_DYNAMIC,
+
+       /** Config IP from Auto IP pool (169.254/16)
+        * Later with DHCP client, if available */
+       NET_IP_CONFIG_TYPE_AUTO_IP,
+
+       /** Indicates an IP address that can not be modified */
+       NET_IP_CONFIG_TYPE_FIXED,
+
+       /** Don't use any method */
+       NET_IP_CONFIG_TYPE_OFF,
+} net_ip_config_type_t;
+
+/*==================================================================================================
+                                 STRUCTURES AND OTHER TYPEDEFS
+==================================================================================================*/
+
+/**
+ * IP Address
+ */
+typedef union
+{
+       /** IP Version 4 address */
+       struct in_addr           Ipv4;
+
+       /** IP Version 6 address */
+       struct in6_addr          Ipv6;
+} ip_addr_t;
+
+/**
+ * Network Address information
+ */
+typedef struct
+{
+       /** Address Type: IPv4 or IPv6 */
+       net_addr_type_t Type;
+
+       /** IP Address */
+       ip_addr_t Data;
+} net_addr_t;
+
+/**
+ * Below structure is used to export proxy info
+ */
+typedef struct
+{
+       /** Proxy info */
+       char                    proxy_addr[NET_PROXY_LEN_MAX+1];
+} net_proxy_t;
+
+/**
+ * Below structure is used to export profile name
+ */
+typedef struct
+{
+       /** Profile name */
+       char                    ProfileName[NET_PROFILE_NAME_LEN_MAX+1];
+} net_profile_name_t;
+
+/**
+ * PDP Authentication Information
+ */
+typedef struct
+{
+       /** Authentication type  */
+       net_auth_type_t         AuthType;
+
+       /** UserName to be used during authentication */
+       char                    UserName[NET_PDP_AUTH_USERNAME_LEN_MAX+1];
+
+       /** Password to be used during authentication */
+       char                    Password[NET_PDP_AUTH_PASSWORD_LEN_MAX+1];
+} net_auth_info_t;
+
+/**
+ * Device Info in Connect response event
+ */
+typedef struct
+{
+       /** Profile Name of the connection link */
+       char            ProfileName[NET_PROFILE_NAME_LEN_MAX+1];
+
+       /** Device Name of the connection link */
+       char            DevName[NET_MAX_DEVICE_NAME_LEN+1];
+
+       /** Dns Server Address of the connection link */
+       net_addr_t      DnsAddr[NET_DNS_ADDR_MAX];
+       /** No of DNS Address for the connection link */
+       int                     DnsCount;
+
+       /** Net IP configuration Type */
+       net_ip_config_type_t IpConfigType;
+
+       /** IP Address for the connection link */
+       net_addr_t      IpAddr;
+       /** Whether subnet mask present or not. */
+       char            BNetmask;
+       /** Subnet mask */
+       net_addr_t      SubnetMask;
+       /** Whether gateway address present or not */
+       char            BDefGateway;
+       /** Gateway address */
+       net_addr_t      GatewayAddr;
+
+       /** Proxy Method type */
+       net_proxy_type_t        ProxyMethod;
+       /** Proxy address */
+       char            ProxyAddr[NET_PROXY_LEN_MAX+1];
+
+       /** MAC address */
+       char            MacAddr[NET_MAX_MAC_ADDR_LEN+1];
+} net_dev_info_t;
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
+
+
diff --git a/include/profile/network-pm-intf.h b/include/profile/network-pm-intf.h
new file mode 100644 (file)
index 0000000..d3c0943
--- /dev/null
@@ -0,0 +1,375 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __NETWORK_PM_INTF_H__
+#define __NETWORK_PM_INTF_H__
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+/**
+ * @file network-pm-intf.h
+ * @brief This file defines the interface of Profile Manager with the application/Connection Manager.
+*/
+
+/**
+ * \addtogroup  profile_managing
+ * \{
+*/
+
+#ifndef DEPRECATED
+#define DEPRECATED __attribute__((deprecated))
+#endif
+/*==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================*/
+
+#include "network-pm-wlan.h"
+
+/*==================================================================================================
+                                           CONSTANTS
+==================================================================================================*/
+
+/*==================================================================================================
+                                             ENUMS
+==================================================================================================*/
+
+/**
+ * @enum net_pdp_type_t
+ * This enumeration defines the pdp protocol type.
+ */
+typedef enum
+{
+       /** Not defined */
+       NET_PDP_TYPE_NONE       = 0x00,
+       /** PDP-GPRS type */
+       NET_PDP_TYPE_GPRS,
+       /** PDP-EDGE type */
+       NET_PDP_TYPE_EDGE,
+       /** PDP-UMTS type */
+       NET_PDP_TYPE_UMTS,
+} net_pdp_type_t;
+
+/**
+ * @enum net_state_type_t
+ * This enumeration defines the service state type.
+ */
+typedef enum
+{
+       /** Not defined */
+       NET_STATE_TYPE_UNKNOWN  = 0x00,
+       /** Idle state */
+       NET_STATE_TYPE_IDLE,
+       /** Failure state */
+       NET_STATE_TYPE_FAILURE,
+       /** Association state */
+       NET_STATE_TYPE_ASSOCIATION,
+       /** Configuration state */
+       NET_STATE_TYPE_CONFIGURATION,
+       /** Ready state */
+       NET_STATE_TYPE_READY,
+       /** Online state */
+       NET_STATE_TYPE_ONLINE,
+       /** Login state */
+       NET_STATE_TYPE_DISCONNECT,
+} net_state_type_t;
+
+
+/*==================================================================================================
+                                 STRUCTURES AND OTHER TYPEDEFS
+==================================================================================================*/
+
+
+/**
+ * Profile data structures: Used between Application and PM Plug-in Interface
+ */
+typedef struct
+{
+       /** Specifies a protocol type */
+       net_pdp_type_t  ProtocolType;
+       /** Specifies a service type(Internet, MMS, WAP, etc...) */
+       net_service_type_t ServiceType;
+       /** Network Access Point Name */
+       char            Apn[NET_PDP_APN_LEN_MAX+1];
+       /** Authentication info of the PDP profile */
+       net_auth_info_t AuthInfo;
+       /** Browser Home URL or MMS server URL */
+       char            HomeURL[NET_HOME_URL_LEN_MAX+1];
+       /** Sim Info Mcc */
+       char Mcc[NET_SIM_INFO_LEN+1];
+       /** Sim Info Mnc */
+       char Mnc[NET_SIM_INFO_LEN+1];
+       /** Indicates whether the use of static IP or not */
+       char IsStatic;
+
+       /** Indicates Roaming mode */
+       char Roaming;
+       /** This will be deprecated */
+       char SetupRequired;
+
+       /** network information */
+       net_dev_info_t net_info;
+} net_pdp_profile_info_t;
+
+/**
+ * Specific profile information related to each technology type
+ */
+typedef union
+{
+       /** PDP Profile Information */
+       net_pdp_profile_info_t       Pdp;
+       /** Wifi Profile Information */
+       net_wifi_profile_info_t      Wlan;
+} net_specific_profile_info_t;
+
+/**
+ * This is the profile structure exposed to applications.
+ */
+typedef struct
+{
+       /** Device Type of the profile */
+       net_device_t    profile_type;
+       /** Profile name */
+       char    ProfileName[NET_PROFILE_NAME_LEN_MAX+1];
+       /** Specific profile information */
+       net_specific_profile_info_t ProfileInfo;
+       /** Service state */
+       net_state_type_t        ProfileState;
+       /** Favourite flag */
+       char Favourite;
+} net_profile_info_t;
+
+/*
+==================================================================================================
+                                     FUNCTION PROTOTYPES
+==================================================================================================
+*/
+
+/*****************************************************************************************/
+/* net_add_profile API function prototype
+ * int net_add_profile(net_service_type_t network_type, net_profile_info_t *prof_info);
+ */
+
+/**
+ * \brief      Add new Profile.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important Notes:
+ *
+ * \warning
+ *  None
+ *
+ * \param[in]   network_type  A type of network service.
+ * \param[in]   prof_info     A pointer of New created Profile Information to be added.
+ *
+ * \par Async Response Message:
+ *        None.
+ *
+ * \return Return Type (int) \n
+ * - NET_ERR_NONE  - indicating that the operation has completed successfully. \n
+ * - NET_ERR_INVALID_PARAM - Invalid parameter\n
+ * - NET_ERR_UNKNOWN - Any other error\n
+ * - NET_ERR_APP_NOT_REGISTERED - Client is invalid may be unregistered\n
+ *
+ * \par Prospective Clients:
+ * Network Connection Setting Applet, WLAN Setting UI Applet.
+ *
+ * \par Example of how this function would be called:
+ *
+ * net_profile_info_t prof_info;\n
+ * int result; \n
+ * result = net_add_profile( NET_SERVICE_MMS, &prof_info ); \n
+ * if(result == NET_ERR_NONE)
+ *
+******************************************************************************************/
+int net_add_profile(net_service_type_t network_type, net_profile_info_t *prof_info);
+
+/*****************************************************************************************/
+/* net_delete_profile API function prototype
+ * int net_delete_profile(const char* profile_name);
+ */
+
+/**
+ * \brief      Delete a specific existing Profile.
+ *              (cellular : Delete profile, wifi : forgot AP)
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important Notes:
+ *
+ * \warning
+ *  None
+ *
+ * \param[in]   profile_name        Profile name to be deleted.
+ *
+ * \par Async Response Message:
+ *        None.
+ *
+ * \return Return Type (int) \n
+ * - NET_ERR_NONE  - indicating that the operation has completed successfully.
+ * - NET_ERR_INVALID_PARAM - Invalid parameter
+ * - NET_ERR_UNKNOWN - Any other error
+ * - NET_ERR_APP_NOT_REGISTERED - Client is invalid may be unregistered
+ *
+ * \par Prospective Clients:
+ * Network Connection Setting Applet, WLAN Setting UI Applet.
+ *
+ * \par Example of how this function would be called:
+ *
+ * int result;\n
+ *
+ * result = net_delete_profile(profile_name);
+ *
+ * if (result == NET_ERR_NONE)
+ *
+******************************************************************************************/
+int net_delete_profile(const char *profile_name);
+
+/*****************************************************************************************/
+/* net_get_profile_info API function prototype
+ * int net_get_profile_info(const char *profile_name, net_profile_info_t *prof_info);
+ */
+
+/**
+ * \brief      Return the profile information referred by Profile Name.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important Notes:
+ *             On success, profile information shall be copied to prof_info parameter in net_profile_info_t format.
+ *             If profile doesn't exist, error shall be returned.
+ *
+ * \warning
+ *  None
+ *
+ * \param[in]   profile_name  Profile Identifier.
+ * \param[out]  prof_info     Buffer containing the profile.
+ *
+ * \par Async Response Message:
+ *        None.
+ *
+ * \return Return Type (int) \n
+ * - NET_ERR_NONE  - indicating that the operation has completed successfully. \n
+ * - NET_ERR_INVALID_PARAM - Invalid parameter\n
+ * - NET_ERR_UNKNOWN - Any other error\n
+ * - NET_ERR_APP_NOT_REGISTERED - Client is invalid may be unregistered\n
+ *
+ * \par Prospective Clients:
+ * Profile Manager.
+ *
+ * \par Example of how this function would be called:
+ *
+ * net_profile_info_t prof_info;\n
+ * int result;\n
+ *
+ * result = net_get_profile_info(profile_name, &prof_info);\n
+ *
+ * if (result == NET_ERR_NONE)\n
+ *
+******************************************************************************************/
+int net_get_profile_info(const char *profile_name, net_profile_info_t *prof_info);
+
+/*****************************************************************************************/
+/* net_modify_profile API function prototype
+ * int net_modify_profile(const char* profile_name, net_profile_info_t* prof_info);
+ */
+
+/**
+ * \brief      Edit a specific existing Profile.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \par Important Notes:
+ *
+ * \warning
+ *  None
+ *
+ * \param[in]  profile_name  Profile Identifier.
+ * \param[in]  prof_info     Changed Profile Information to be updated.
+ *
+ *
+ * \par Async Response Message:
+ *        None.
+ *
+ * \return Return Type (int) \n
+ * - NET_ERR_NONE  - indicating that the operation has completed successfully. \n
+ * - NET_ERR_INVALID_PARAM - Invalid parameter\n
+ * - NET_ERR_UNKNOWN - Any other error\n
+ * - NET_ERR_APP_NOT_REGISTERED - Client is invalid may be unregistered\n
+ *
+ * \par Prospective Clients:
+ * Network Connection Setting Applet.
+ *
+ * \par Example of how this function would be called:
+ *
+ * net_profile_info_t prof_info;\n
+ * int result;\n
+ *
+ * result = net_get_profile_info(profile_name, &prof_info);\n
+ * ......(Modifying ProfInfo)\n
+ *
+ * result = net_modify_profile(profile_name, &prof_info);\n
+ *
+ * if (result == NET_ERR_NONE)\n
+ *
+******************************************************************************************/
+int net_modify_profile(const char *profile_name, net_profile_info_t *prof_info);
+
+/*****************************************************************************************/
+/**
+ * @fn   int net_get_profile_list(net_device_t device_type, net_profile_info_t **profile_list, int *count)
+ *
+ * This function request service list to ConnMan through dbus.
+ *
+ * \par Sync (or) Async:
+ * This is a Synchronous API.
+ *
+ * \param[in]  device_type     Type of device
+ * \param[out] profile_list    Profile list. After use this, it should be free()
+ * \param[out] count           Number of profile
+ *
+ * \return Return Type (int) \n
+ * - NET_ERR_NONE  - indicating that the operation has completed successfully. \n
+ * - NET_ERR_INVALID_PARAM - Invalid parameter\n
+ * - NET_ERR_UNKNOWN - Any other error\n
+ * - NET_ERR_APP_NOT_REGISTERED - Client is invalid may be unregistered\n
+ *
+ * \par Prospective Clients:
+ * External Apps.
+ *
+******************************************************************************************/
+int net_get_profile_list(net_device_t device_type, net_profile_info_t **profile_list, int *count);
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
+
+
diff --git a/include/profile/network-pm-wlan.h b/include/profile/network-pm-wlan.h
new file mode 100644 (file)
index 0000000..8641a2e
--- /dev/null
@@ -0,0 +1,358 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __NETWORK_PM_WLAN_H__
+#define __NETWORK_PM_WLAN_H__
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+/**  \file network-pm-wlan.h
+     \brief This file contains constants, enums, tructs, and function prototypes that are used by Wlan related sources internally. This File defines the WLAN exported Data Structures.
+
+*/
+
+/**
+ * \addtogroup  profile_managing
+ * \{
+*/
+
+/*
+==================================================================================================
+                                         INCLUDE FILES
+==================================================================================================
+*/
+
+#include "network-pm-config.h"
+
+/*
+==================================================================================================
+                                           CONSTANTS
+==================================================================================================
+*/
+
+/** Length of essid */
+#define NET_WLAN_ESSID_LEN      128
+
+
+/** 
+ * Length of WPS PIN code 
+ * WPS PIN code should be 4 or 8 digits
+ */
+#define NET_WLAN_MAX_WPSPIN_LEN                8       
+
+/**
+ * Passphrase length should be between 8..63,
+ * If we plan to use encrypted key(hex value generated by wpa_passphrase),
+ * then we have to set this value to some higher number
+ *
+ */
+#define NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN 65
+
+/**
+ * Length of WEP Key
+ * Max of 10 Hex digits allowed in case of 64 bit encryption
+ * Max of 26 Hex digits allowed in case of 128 bit encryption
+ */
+#define NETPM_WLAN_MAX_WEP_KEY_LEN        26
+
+
+/**
+ * These lengths depends on authentication server being used,
+ * In case of freeradius server Max allowed length for username/password is 255
+ * Let us restrict this value to some optimal value say 50.
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define NETPM_WLAN_USERNAME_LEN               50
+/**
+ * These lengths depends on authentication server being used,
+ * In case of freeradius server Max allowed length for username/password is 255
+ * Let us restrict this value to some optimal value say 50.
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define NETPM_WLAN_PASSWORD_LEN               50
+
+/**
+ * length of CA Cert file name
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define NETPM_WLAN_CA_CERT_FILENAME_LEN       50
+/**
+ * length of Client Cert file name
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define NETPM_WLAN_CLIENT_CERT_FILENAME_LEN   50
+/**
+ * length of private key file name
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define NETPM_WLAN_PRIVATE_KEY_FILENAME_LEN   50
+/**
+ * length of Private key password
+ * Used by EAP-TLS, optional for EAP-TTLS and EAP-PEAP
+ */
+#define NETPM_WLAN_PRIVATE_KEY_PASSWD_LEN     50
+
+/*==================================================================================================
+                                             ENUMS
+==================================================================================================*/
+
+/**
+ * @enum wlan_security_mode_type_t
+ * Below security modes are used in infrastructure and ad-hoc mode
+ * For now all EAP security mechanisms are provided only in infrastructure mode
+ */
+typedef enum
+{
+       /** Security disabled */
+       WLAN_SEC_MODE_NONE = 0x01,
+       /** WEP */
+       WLAN_SEC_MODE_WEP,
+       /** EAP */
+       WLAN_SEC_MODE_IEEE8021X,
+       /** WPA-PSK */
+       WLAN_SEC_MODE_WPA_PSK,
+       /** WPA2-PSK */
+       WLAN_SEC_MODE_WPA2_PSK,
+} wlan_security_mode_type_t;
+
+/**
+ * @enum wlan_encryption_mode_type_t
+ * Below encryption modes are used in infrastructure and ad-hoc mode
+ */
+typedef enum
+{
+       /** Encryption disabled */
+       WLAN_ENC_MODE_NONE = 0x01,
+       /** WEP */
+       WLAN_ENC_MODE_WEP,
+       /** TKIP */
+       WLAN_ENC_MODE_TKIP,
+       /** AES */
+       WLAN_ENC_MODE_AES,
+       /** TKIP and AES are both supported */
+       WLAN_ENC_MODE_TKIP_AES_MIXED,
+} wlan_encryption_mode_type_t;
+
+/**
+ * @enum wlan_connection_mode_type_t
+ * WLAN Operation Mode
+ * @see net_pm_wlan_profile_info_t
+ */
+typedef enum
+{
+       /** auto connection mode */
+       NETPM_WLAN_CONNMODE_AUTO = 0x01,
+       /** Connection mode Adhoc  */
+       NETPM_WLAN_CONNMODE_ADHOC,
+       /** Infra connection mode */
+       NETPM_WLAN_CONNMODE_INFRA,
+} wlan_connection_mode_type_t;
+
+
+/**
+ * @enum wlan_eap_type_t
+ * EAP type
+ * @see wlan_eap_info_t
+ */
+ typedef enum
+{
+       /** EAP PEAP type */
+       WLAN_SEC_EAP_TYPE_PEAP = 0x01,
+       /** EAP TLS type */
+       WLAN_SEC_EAP_TYPE_TLS,
+       /** EAP TTLS type */
+       WLAN_SEC_EAP_TYPE_TTLS,
+       /** EAP SIM type */
+       WLAN_SEC_EAP_TYPE_SIM,
+       /** EAP AKA type */
+       WLAN_SEC_EAP_TYPE_AKA,
+} wlan_eap_type_t;
+
+/**
+ * @enum wlan_eap_auth_type_t
+ * EAP phase2 authentication type
+ * @see wlan_eap_info_t
+ */
+typedef enum
+{
+       /** EAP phase2 authentication none */
+       WLAN_SEC_EAP_AUTH_NONE = 0x01,
+       /** EAP phase2 authentication PAP */
+       WLAN_SEC_EAP_AUTH_PAP,
+       /** EAP phase2 authentication MSCHAP */
+       WLAN_SEC_EAP_AUTH_MSCHAP,
+       /** EAP phase2 authentication MSCHAPv2 */
+       WLAN_SEC_EAP_AUTH_MSCHAPV2,
+       /** EAP phase2 authentication GTC */
+       WLAN_SEC_EAP_AUTH_GTC,
+       /** EAP phase2 authentication MD5 */
+       WLAN_SEC_EAP_AUTH_MD5,
+} wlan_eap_auth_type_t;
+
+/*
+==================================================================================================
+                                            MACROS
+==================================================================================================
+*/
+
+
+/*==================================================================================================
+                                 STRUCTURES AND OTHER TYPEDEFS
+==================================================================================================*/
+
+/**
+ * Below structure is used to export essid
+ */
+typedef struct
+{
+       /** ESSID */
+       char essid[NET_WLAN_ESSID_LEN+1];
+} net_essid_t;
+
+
+/**
+ * Below structure is used by WPA-PSK or WPA2-PSK
+ * @remark To see the maximum length of PSK passphrase key.
+ * @see wlan_auth_info_t
+ */
+typedef struct
+{
+       /** key value for WPA-PSK or WPA2-PSK */
+       char pskKey[NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN + 1];
+} wlan_psk_info_t;
+
+
+/**
+ * Below structure is used by WEP
+ * @remark To see the maximum length of WEP key.
+ * @see wlan_auth_info_t
+ */
+typedef struct
+{
+       /** key value for WEP */
+       char wepKey[NETPM_WLAN_MAX_WEP_KEY_LEN + 1];
+} wlan_wep_info_t;
+
+
+/**
+ * Below structure is used by EAP
+ * @see wlan_auth_info_t
+ */
+typedef struct
+{
+       /** User name */
+       char username[NETPM_WLAN_USERNAME_LEN+1];
+       /** Password */
+       char password[NETPM_WLAN_PASSWORD_LEN+1];
+
+       /**
+        * Following fields are mandatory for EAP-TLS,
+        * Optional for EAP-TTLS and EAP-PEAP
+        */
+       /**
+        * For EAP-TTLS and EAP-PEAP only ca_cert_filename[] can also be provided
+        */
+       char ca_cert_filename[NETPM_WLAN_CA_CERT_FILENAME_LEN+1]; /* Used to authenticate server */
+       /** client certificate file name */
+       char client_cert_filename[NETPM_WLAN_CLIENT_CERT_FILENAME_LEN+1];
+       /** private key file name */
+       char private_key_filename[NETPM_WLAN_PRIVATE_KEY_FILENAME_LEN+1];
+       /** private key password */
+       char private_key_passwd[NETPM_WLAN_PRIVATE_KEY_PASSWD_LEN+1];
+
+       /** eap type */
+       wlan_eap_type_t eap_type;
+       /** eap phase2 authentication type */
+       wlan_eap_auth_type_t eap_auth;
+} wlan_eap_info_t;
+
+
+/**
+ * At any point of time only one security mechanism is supported
+ * @see wlan_security_info_t
+ */
+typedef union
+{
+       /** Wep Authentication */
+       wlan_wep_info_t wep;
+       /** psk Authentication */
+       wlan_psk_info_t psk;
+       /** eap Authentication */
+       wlan_eap_info_t eap;
+} wlan_auth_info_t;
+
+
+/**
+ * This is main security information structure
+ * @see net_pm_wlan_profile_info_t
+ */
+typedef struct
+{
+       /** security mode type */
+       wlan_security_mode_type_t sec_mode;
+       /** encryption mode type */
+       wlan_encryption_mode_type_t enc_mode;
+       /** authentication information */
+       wlan_auth_info_t authentication;
+       /** If WPS is supported, then this property will be set to TRUE */
+       char wps_support;
+} wlan_security_info_t;
+
+
+/**
+ * AP Profile information
+ */
+typedef struct
+{
+       /** ESSID */
+       char essid[NET_WLAN_ESSID_LEN+1];
+       /** Basic service set identification */
+       char bssid[NET_MAX_MAC_ADDR_LEN+1];
+       /**  Strength : between 0 and 100 */
+       unsigned char Strength;
+       /** Frequency band(MHz) */
+       unsigned int frequency;
+       /** Maximum speed of the line(bps) */
+       unsigned int max_rate;
+       /** If a passphrase has been set already or if no
+               passphrase is needed, then this property will
+               be set to FALSE. */
+       char PassphraseRequired;
+       /** Infrastucture / ad-hoc / auto mode */
+       wlan_connection_mode_type_t wlan_mode;
+       /** Security mode and authentication info */
+       wlan_security_info_t security_info;
+
+       /** network information */
+       net_dev_info_t net_info;
+} net_wifi_profile_info_t;
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __NETPM_WLAN_H__ */
+
+
diff --git a/include/wifi/network-wifi-intf.h b/include/wifi/network-wifi-intf.h
new file mode 100644 (file)
index 0000000..d6c3c32
--- /dev/null
@@ -0,0 +1,301 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __NETWORK_WIFI_INTF_H_
+#define __NETWORK_WIFI_INTF_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file network-wifi-intf.h
+ * @brief This file defines the Wi-Fi specific interface with the application/Connection Manager.
+*/
+
+/**
+ * \addtogroup  wifi_specific
+ * \{
+*/
+/*****************************************************************************
+ *     Standard headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *     Platform headers
+ *****************************************************************************/
+
+#include "network-pm-wlan.h"
+#include "network-cm-intf.h"
+
+/*****************************************************************************
+ *     Macros and Typedefs
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ *     Global Enums 
+ *****************************************************************************/
+
+/**
+* @enum net_wifi_state_t
+* This enum indicates wifi state
+*/
+typedef enum {
+       /** Unknown state */
+       WIFI_UNKNOWN = 0x00,
+       /** Wi-Fi is Off */
+       WIFI_OFF,
+       /** Wi-Fi is On(idle/failure) */
+       WIFI_ON,
+       /** Trying to connect(association/configuration) */
+       WIFI_CONNECTING,
+       /** Wi-Fi is connected to an AP(ready/online) */
+       WIFI_CONNECTED,
+       /** Trying to disconnect(connected, but disconnecting process is on going) */
+       WIFI_DISCONNECTING,
+} net_wifi_state_t; 
+
+/**
+*@enum net_wifi_background_scan_mode_t
+* This enum indicates background scanning mode.
+*/
+typedef enum {
+       /** scan cycle : 300s */
+       WIFI_BGSCAN_MODE_DEFAULT = 0x00,
+       /** scan cycle : 10s */
+       WIFI_BGSCAN_MODE_PERIODIC,
+       /** scan cycle : 4, 8, 16, ...128s */
+       WIFI_BGSCAN_MODE_EXPONENTIAL,
+} net_wifi_background_scan_mode_t;
+
+/**
+*@enum net_wifi_wps_type_t
+* This enum indicates WPS type.
+*/
+typedef enum
+{
+       /** WPS type is PBC */
+       WIFI_WPS_PBC = 0x00,
+       /** WPS type is PIN */
+       WIFI_WPS_PIN
+} net_wifi_wps_type_t;
+
+/*****************************************************************************
+ *     Global Structures
+ *****************************************************************************/
+
+/**
+ * This is the structure to connect with WPS network.
+ */
+typedef struct {
+       /** PBC / PIN */
+       net_wifi_wps_type_t type;
+       
+       /** Optional. This pin is needed when the user input PIN code */
+       char pin[NET_WLAN_MAX_WPSPIN_LEN + 1];
+} net_wifi_wps_info_t;
+
+/**
+ * This is the profile structure to connect hidden WiFi network.
+ */
+typedef struct {
+       /** Basic feature */
+       char essid[NET_WLAN_ESSID_LEN + 1];
+
+       /** Infrastructure / ad-hoc / auto mode */
+       wlan_connection_mode_type_t wlan_mode;
+
+       /** Security mode and authentication info */
+       wlan_security_info_t security_info;
+} net_wifi_connection_info_t;
+
+/*****************************************************************************
+ *     Typedefs 
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ *     Global Functions 
+ *****************************************************************************/
+
+       
+/*****************************************************************************
+ *     ConnMan Wi-Fi Client Interface Synchronous API Declaration
+ *****************************************************************************/
+
+
+/**
+ * @fn   int net_get_wifi_state(net_wifi_state_t *current_state, net_profile_name_t *profile_name)
+ *
+ * This function requests current state of wifi.
+ *
+ * \par Sync (or) Async:
+ * These is a Synchronous API.
+ *
+ * @param[in]    none
+ * @param[out]   current_state  Current wifi state
+ * @param[out]   profile_name   Profile name of current Wi-Fi state\n
+ *                              (valid for WIFI_CONNECTING, WIFI_CONNECTED, WIFI_DISCONNECTING state only)
+ *
+ * @return       NET_ERR_NONE on success, negative values for errors
+ */
+
+int net_get_wifi_state(net_wifi_state_t *current_state, net_profile_name_t *profile_name);
+
+
+/**
+ * @fn   int net_wifi_set_background_scan_mode(net_wifi_background_scan_mode_t scan_mode)
+ *
+ * This function sends set background scan mode request to ConnMan daemon,
+ * with background scan mode - default/periodic/exponential
+ * Background scan trigger is restarted if the same mode is set again.
+ *
+ * \par Sync (or) Async:
+ * These is a Synchronous API.
+ *
+ * @param[in]    scan_mode  default/periodic/exponential
+ * @param[out]   none
+ *
+ * @return       NET_ERR_NONE on success, negative values for errors
+ */
+
+int net_wifi_set_background_scan_mode(net_wifi_background_scan_mode_t scan_mode);
+
+/*****************************************************************************
+ *     ConnMan Wi-Fi Client Interface Asynchronous Function Declaration
+ *****************************************************************************/
+
+/**
+ * @fn   int net_open_connection_with_wifi_info(const net_wifi_connection_info_t *wifi_info)
+ *
+ * This function requests Wi-Fi open connection. This should be used only for opening
+ * connection with hidden ap
+ *
+ * \par Sync (or) Async:
+ * This is an Asynchronous API.
+ *
+ * @param[in]    wifi_info  Pointer to connection information structure
+ * @param[out]   none
+ *
+ * \par Async Response Message:
+ *        NET_EVENT_OPEN_RSP: Connection Establishment response will be sent asynchronously to the App in the callback function registered.\n
+ *        refer to net_event_cb_t()
+ *
+ * @return       NET_ERR_NONE on success, negative values for errors
+ */
+
+int net_open_connection_with_wifi_info(const net_wifi_connection_info_t *wifi_info);
+
+
+/**
+ * @fn   int net_scan_wifi(void)
+ *
+ * This function sends scan request to ConnMan daemon.\n
+ * You can receive scan completion response(NET_EVENT_WIFI_SCAN_RSP) via the callback function registered,\n
+ * and then get scan result by using net_get_profile_list().
+ *
+ *\par Sync (or) Async:
+ * This is an Asynchronous API.
+ *
+ * @param[in]    none
+ * @param[out]   none
+ *
+ * \par Async Response Message:
+ *        NET_EVENT_WIFI_SCAN_RSP: Scan completion response will be sent asynchronously to the App in the callback function registered.\n
+ *        refer to net_event_cb_t()
+ *
+ * @return       NET_ERR_NONE on success, negative values for errors
+ */
+
+int net_scan_wifi(void);
+
+
+/**
+ * @fn   int net_wifi_power_on(void)
+ *
+ * This function requests wifi power on.
+ *
+ * \par Sync (or) Async:
+ * This is an Asynchronous API.
+ *
+ * @param[in]    none
+ * @param[out]   none
+ *
+ * \par Async Response Message:
+ *        NET_EVENT_WIFI_POWER_RSP: Wi-Fi Power on response will be sent asynchronously to the App in the callback function registered.\n
+ *        refer to net_event_cb_t()
+ *
+ * @return       NET_ERR_NONE on success, negative values for errors
+ */
+
+int net_wifi_power_on(void);
+
+
+/**
+ * @fn   int net_wifi_power_off(void)
+ *
+ * This function requests wifi power off.
+ *
+ * \par Sync (or) Async:
+ * This is an Asynchronous API.
+ *
+ * @param[in]    none
+ * @param[out]   none
+ *
+ * \par Async Response Message:
+ *        NET_EVENT_WIFI_POWER_RSP: Wi-Fi Power off response will be sent asynchronously to the App in the callback function registered.\n
+ *        refer to net_event_cb_t()
+ *
+ * @return       NET_ERR_NONE on success, negative values for errors
+ */
+
+int net_wifi_power_off(void);
+
+
+/**
+ * @fn   int net_wifi_enroll_wps(const char *profile_name, net_wifi_wps_info_t *wps_info)
+ *
+ * This function sends enroll wps request to ConnMan daemon,
+ * with profile name and wps information.
+ *
+ * \par Sync (or) Async:
+ * This is an Asynchronous API.
+ *
+ * @param[in]    profile_name  Profile Name to be connected
+ * @param[in]    wps_info      wps type and pin code for WPS PIN(optional)
+ * @param[out]   none
+ *
+ * \par Async Response Message:
+ *        NET_EVENT_WIFI_WPS_RSP : enroll wps response will be sent asynchronously to the App in the callback function registered.\n
+ *        refer to net_event_cb_t()
+ *
+ * @return       NET_ERR_NONE on success, negative values for errors
+ */
+
+int net_wifi_enroll_wps(const char *profile_name, net_wifi_wps_info_t *wps_info);
+
+
+/**
+ * \}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /** __NETWORK_WIFI_INTF_H_ */
diff --git a/network.pc.in b/network.pc.in
new file mode 100644 (file)
index 0000000..575b4ac
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=@prefix@\r
+exec_prefix=@prefix@\r
+libdir=@prefix@/lib\r
+includedir=@prefix@/include\r
+\r
+Name: network\r
+Description: ConnMan Client Library\r
+Requires: dlog dbus-1 dbus-glib-1\r
+Version: @VERSION@\r
+Libs: -L${libdir} -lnetwork\r
+Cflags: -I${includedir} -I${includedir}/network\r
+\r
diff --git a/packaging/libnet-client.spec b/packaging/libnet-client.spec
new file mode 100644 (file)
index 0000000..202bd97
--- /dev/null
@@ -0,0 +1,50 @@
+#sbs-git:slp/pkgs/l/libnet-client
+
+Name:       libnet-client
+Summary:    Network (ConnMan) Client library (Shared Library)
+Version:    0.1.64
+Release:    1
+Group:      System/Network
+License:    Flora Software License
+Source0:    %{name}-%{version}.tar.gz
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(dbus-glib-1)
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(vconf)
+
+%description
+Network (ConnMan) Client library (Shared Library)
+
+%package devel
+Summary:    Network (ConnMan) Client library (Development)
+Group:      Development/Libraries
+Requires:   %{name} = %{version}-%{release}
+
+%description devel
+Network (ConnMan) Client library (Development)
+
+%prep
+%setup -q
+
+./autogen.sh
+
+%build
+
+./configure --prefix=/usr
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%files
+%defattr(-,root,root,-)
+%{_libdir}/libnetwork.so
+%{_libdir}/libnetwork.so.0
+%attr(644,-,-) %{_libdir}/libnetwork.so.0.0.0
+
+%files devel
+%{_includedir}/network/*.h
+%{_libdir}/pkgconfig/network.pc
diff --git a/src/include/network-dbus-request.h b/src/include/network-dbus-request.h
new file mode 100644 (file)
index 0000000..69edd89
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __NETWORK_DBUS_REQUEST_H_
+#define __NETWORK_DBUS_REQUEST_H_
+
+/*****************************************************************************
+ *     Standard headers
+ *****************************************************************************/
+#include <stdio.h> 
+#include <errno.h> 
+#include <stdlib.h> 
+#include <string.h>
+#include <glib.h>
+
+#include <dbus/dbus.h> 
+
+
+/*****************************************************************************
+ *     Platform headers
+ *****************************************************************************/
+
+
+
+/*****************************************************************************
+ *     Macros and Typedefs
+ *****************************************************************************/
+       
+#define CONNMAN_CLIENT_DBUS_TYPE_STRING        "string"
+#define CONNMAN_CLIENT_DBUS_TYPE_INT16                 "int16"
+#define CONNMAN_CLIENT_DBUS_TYPE_UINT16                "uint16"
+#define CONNMAN_CLIENT_DBUS_TYPE_INT32         "int32"
+#define CONNMAN_CLIENT_DBUS_TYPE_UINT32                "uint32"
+#define CONNMAN_CLIENT_DBUS_TYPE_INT64         "int64"
+#define CONNMAN_CLIENT_DBUS_TYPE_UINT64                "uint64"
+#define CONNMAN_CLIENT_DBUS_TYPE_DOUBLE                "double"
+#define CONNMAN_CLIENT_DBUS_TYPE_BYTE          "byte"
+#define CONNMAN_CLIENT_DBUS_TYPE_BOOLEAN       "boolean"
+#define CONNMAN_CLIENT_DBUS_TYPE_OBJECT_PATH   "objpath"
+
+#define CONNMAN_CLIENT_DBUS_TYPE_VARIANT       "variant"
+#define CONNMAN_CLIENT_DBUS_TYPE_ARRAY         "array"
+#define CONNMAN_CLIENT_DBUS_TYPE_DICT_ENTRY    "dict"
+
+
+/*****************************************************************************
+ *     Global Structures
+ *****************************************************************************/
+
+typedef struct
+{
+       char* type;
+       char* mode;
+       char* ssid;
+       char* security;
+       char* passphrase; /** TODO handle EAP */
+} net_wifi_connect_service_info_t;
+
+
+/*****************************************************************************
+ *     Global Functions 
+ *****************************************************************************/
+int _net_dbus_scan_request(void);
+int _net_dbus_provision_service(gchar * config_str, int len);
+int _net_dbus_set_bgscan_mode(net_wifi_background_scan_mode_t mode);
+int _net_dbus_get_state(char* state);
+int _net_send_dbus_request(const char* destination, char *param_array[], DBusMessage** result);
+int _net_dbus_open_connection(const char* profile_name);
+int _net_dbus_close_connection(const char* profile_name);
+int _net_dbus_get_network_status (net_device_t device_type, net_cm_network_status_t* network_status);
+int _net_dbus_connect_service(const net_wifi_connect_service_info_t* wifi_connection_info);
+int _net_dbus_set_profile_ipv4(net_profile_info_t* prof_info, char* profile_name);
+int _net_dbus_set_profile_dns(net_profile_info_t* prof_info, char* profile_name);
+int _net_dbus_set_proxy(net_profile_info_t* prof_info, char* profile_name);
+int _net_dbus_get_technology_state(network_get_tech_state_info_t* tech_state);
+DBusMessage *_net_invoke_dbus_method(const char* dest, DBusConnection *connection,
+               const char* path, char* interface_name, char* method, int *dbus_error);
+int _net_dbus_load_wifi_driver(void);
+int _net_dbus_remove_wifi_driver(void);
+int _net_dbus_add_pdp_profile(net_profile_info_t *prof_info);
+int _net_dbus_modify_pdp_profile(net_profile_info_t *prof_info, const char *profile_name);
+dbus_bool_t _net_dbus_is_pending_call_used(void);
+void _net_dbus_set_pending_call_used(dbus_bool_t used);
+DBusPendingCall *_net_dbus_get_pending_call(void);
+void _net_dbus_set_pending_call(DBusPendingCall *call);
+
+#endif /** __NETWORK_SIGNAL_HANDLER_H_ */
diff --git a/src/include/network-internal.h b/src/include/network-internal.h
new file mode 100644 (file)
index 0000000..875d0a1
--- /dev/null
@@ -0,0 +1,216 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __NETWORK_INTERNAL_H_
+#define __NETWORK_INTERNAL_H_
+
+/*****************************************************************************
+ *     Standard headers
+ *****************************************************************************/
+#include <stdio.h> 
+#include <errno.h> 
+#include <stdlib.h> 
+#include <string.h>
+#include <glib.h>
+
+#include <dbus/dbus.h> 
+
+#include <net/if.h>                    /** for IFNAMSIZ and co... */
+
+/*****************************************************************************
+ *     Platform headers
+ *****************************************************************************/
+#include "network-pm-intf.h"
+#include "network-cm-intf.h"
+#include "network-wifi-intf.h"
+
+/*****************************************************************************
+ *     Macros and Typedefs
+ *****************************************************************************/
+
+/** Maximum Profile Count */
+#define NET_PROFILE_LIST_MAX 512
+
+#define NET_TECH_LENGTH_MAX 64
+
+#define CONNMAN_MAX_BUFLEN 512
+
+#define        NET_MEMFREE(x)  {if(x != NULL) free(x); x = NULL;}
+
+/** ConnMan Daemon Management interface */
+
+#define CONNMAN_SERVICE                 "net.connman" 
+
+#define CONNMAN_MANAGER_INTERFACE       CONNMAN_SERVICE ".Manager" 
+#define CONNMAN_TECHNOLOGY_INTERFACE    CONNMAN_SERVICE ".Technology"
+#define CONNMAN_SERVICE_INTERFACE       CONNMAN_SERVICE ".Service" 
+#define CONNMAN_PROFILE_INTERFACE       CONNMAN_SERVICE ".Profile" 
+#define CONNMAN_COUNTER_INTERFACE       CONNMAN_SERVICE ".Counter" 
+#define CONNMAN_ERROR_INTERFACE                CONNMAN_SERVICE ".Error"
+
+
+#define CONNMAN_MANAGER_PATH            "/" 
+#define CONNMAN_PROFILE_PATH            "/profile/default" 
+#define CONNMAN_TECHNOLOGY_PATH                        "/net/connman/technology"
+
+/** Network related Daemon interfaces */
+
+#define NETCONFIG_SERVICE                              "net.netconfig"
+#define NETCONFIG_WIFI_INTERFACE               NETCONFIG_SERVICE ".wifi"
+#define NETCONFIG_WIFI_PATH                            "/net/netconfig/wifi"
+
+#define TELEPHONY_SERVCE                               "com.tcore.ps"
+#define TELEPHONY_MASTER_INTERFACE             TELEPHONY_SERVCE ".master"
+#define TELEPHONY_NETWORK_INTERFACE            TELEPHONY_SERVCE ".network"
+#define TELEPHONY_PROFILE_INTERFACE            TELEPHONY_SERVCE ".context"
+#define TELEPHONY_MASTER_PATH                  "/"
+
+/** ConnMan Daemon Signal Filters */
+
+#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'"
+#define CONNMAN_PROFILE_SIGNAL_FILTER          "type='signal',interface='net.connman.Profile'"
+#define CONNMAN_NETWORK_COUNTER_FILTER         "type='signal',interface='net.connman.Counter'"
+
+/** ConnMan Daemon SignalS */
+
+#define CONNMAN_SIGNAL_PROPERTY_CHANGED                "PropertyChanged"
+#define CONNMAN_SIGNAL_STATE_CHANGED           "StateChanged"
+#define CONNMAN_SIGNAL_SCAN_COMPLETED          "ScanCompleted"
+
+#ifdef VITA_FEATURE
+#include <dlog.h>
+
+#define CONNMAN_CLIENT_MID "network"
+
+#define NETWORK_LOW            LOG_VERBOSE
+#define NETWORK_MED            LOG_VERBOSE
+#define NETWORK_HIGH           LOG_VERBOSE
+#define NETWORK_ERROR          LOG_ERROR
+#define NETWORK_EXCEPTION      LOG_WARN
+#define NETWORK_ASSERT         LOG_WARN
+
+
+#define NETWORK_LOG(log_level, format, args...) \
+       SLOG(log_level,CONNMAN_CLIENT_MID, "[%s][Ln: %d] " format, __FILE__, __LINE__, ##args) 
+#define __NETWORK_FUNC_ENTER__ /* NETWORK_LOG(NETWORK_HIGH, "Entering %s()\n", __func__) */
+#define __NETWORK_FUNC_EXIT__  /* NETWORK_LOG(NETWORK_HIGH, "Quit: %s()\n", __func__) */
+
+#else /** VITA_FEATURE */
+
+#define NETWORK_LOG(log_level, format, args...) printf("[%s][Ln: %d] " format, __FILE__, __LINE__, ##args)
+#define __NETWORK_FUNC_ENTER__ /* printf("Entering: %s:%d:%s()\n", __FILE__, __LINE__,__func__) */
+#define __NETWORK_FUNC_EXIT__  /* printf("Quit: %s:%d:%s()\n", __FILE__, __LINE__,__func__) */
+
+#endif /** VITA_FEATURE */
+
+#define NETWORK_CALLBACK(x,y) \
+       if (NetworkInfo.ClientEventCb != NULL) { \
+               NetworkInfo.ClientEventCb(x, y); \
+       } else { \
+               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! NetworkInfo.ClientEventCb is NULL\n"); \
+       }
+
+
+/*****************************************************************************
+ *     Global Enums
+ *****************************************************************************/
+
+typedef enum
+{
+       NETWORK_REQUEST_TYPE_SCAN = 0x00,
+       NETWORK_REQUEST_TYPE_OPEN_CONNECTION,
+       NETWORK_REQUEST_TYPE_CLOSE_CONNECTION,
+       NETWORK_REQUEST_TYPE_WIFI_POWER,
+       NETWORK_REQUEST_TYPE_ENROLL_WPS,
+       NETWORK_REQUEST_TYPE_MAX
+} network_async_request_type_t;
+
+
+typedef struct
+{
+       int flag; /** TRUE/FALSE */
+       char ProfileName[NET_PROFILE_NAME_LEN_MAX+1];
+} network_request_table_t;
+
+/*****************************************************************************
+ *     Global Structures
+ *****************************************************************************/
+
+typedef struct
+{
+       int num_of_services;
+       char* ProfileName[NET_PROFILE_LIST_MAX];
+} network_services_list_t;
+
+typedef struct {
+       net_wifi_state_t wifi_state;
+       net_event_cb_t ClientEventCb;
+       void* user_data;
+} network_info_t;
+
+typedef struct
+{
+       char technology[NET_TECH_LENGTH_MAX]; /** wifi, ethernet, cellular - strings */
+       char AvailableTechnology;
+       char EnabledTechnology;
+       char ConnectedTechnology;
+       char DefaultTechnology;
+} network_get_tech_state_info_t;
+
+/**
+ * This is the profile structure exposed from modman.
+ */
+typedef struct
+{
+       /** Profile name */
+       char                    ProfileName[NET_PROFILE_NAME_LEN_MAX+1];
+       /** Service type of this profile context */
+       net_service_type_t      ServiceType;
+       /** Network Access Point Name */
+       char                    Apn[NET_PDP_APN_LEN_MAX+1];
+       /** Authentication info of the PDP profile */
+       net_auth_info_t AuthInfo;
+       /**Proxy address */
+       char                    ProxyAddr[NET_PROXY_LEN_MAX+1];
+       /** Browser Home URL or MMS server URL */
+       char                    HomeURL[NET_HOME_URL_LEN_MAX+1];
+} net_telephony_profile_info_t;
+
+/*****************************************************************************
+ *     Global Functions 
+ *****************************************************************************/
+net_device_t _net_get_tech_type_from_path(const char *profile_name);
+char* _net_get_string(DBusMessage* msg);
+char* _net_get_object(DBusMessage* msg);
+int _net_get_boolean(DBusMessage* msg);
+int _net_get_path(DBusMessage *msg, char *profile_name);
+int _net_get_tech_state(DBusMessage* msg, network_get_tech_state_info_t* tech_state);
+char* _net_print_error(net_err_t error);
+int _net_open_connection_with_wifi_info(const net_wifi_connection_info_t* wifi_info);
+int _net_check_profile_name(const char* ProfileName);
+int _net_get_profile_list(net_device_t device_type, net_profile_info_t** profile_info, int* profile_count);
+int _net_mutex_init();
+void _net_mutex_destroy();
+void _net_client_callback(net_event_info_t *event_data);
+int _net_get_service_profile(net_service_type_t service_type, net_profile_name_t *profile_name);
+int _net_get_default_profile_info(net_profile_info_t *profile_info);
+net_wifi_state_t _net_get_wifi_state();
+void _net_clear_request_table();
+
+#endif /** __NETWORK_INTERNAL_H_ */
diff --git a/src/include/network-signal-handler.h b/src/include/network-signal-handler.h
new file mode 100644 (file)
index 0000000..7fb5a4e
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __NETWORK_SIGNAL_HANDLER_H_
+#define __NETWORK_SIGNAL_HANDLER_H_
+
+/*****************************************************************************
+ *     Standard headers
+ *****************************************************************************/
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+#include <dbus/dbus.h> 
+
+
+/*****************************************************************************
+ *     Platform headers
+ *****************************************************************************/
+
+/*****************************************************************************
+ *     Macros and Typedefs
+ *****************************************************************************/
+
+/*****************************************************************************
+ *     Global Structures
+ *****************************************************************************/
+
+/*****************************************************************************
+ *     Global Functions 
+ *****************************************************************************/
+int _net_deregister_signal(void);
+int network_register_and_recieve_signal(void);
+int _net_register_signal(void);
+int _net_init_service_state_table(void);
+
+
+#endif /** __NETWORK_SIGNAL_HANDLER_H_ */
+
diff --git a/src/network-cm-intf.c b/src/network-cm-intf.c
new file mode 100644 (file)
index 0000000..100a0cd
--- /dev/null
@@ -0,0 +1,727 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+
+/*****************************************************************************
+ *     Standard headers
+ *****************************************************************************/
+#include <stdio.h> 
+#include <errno.h> 
+#include <stdlib.h> 
+#include <string.h>
+#include <glib.h>
+
+#include <dbus/dbus.h> 
+
+
+/*****************************************************************************
+ *     Platform headers
+ *****************************************************************************/
+
+#include "network-internal.h"
+#include "network-signal-handler.h"
+#include "network-dbus-request.h"
+
+/*****************************************************************************
+ *     Macros and Typedefs
+ *****************************************************************************/
+
+/*****************************************************************************
+ *     Local Functions Declaration
+ *****************************************************************************/
+
+static int __net_get_default_profile(void *param, net_profile_info_t *active_profile_info);
+
+/*****************************************************************************
+ *     Global Functions
+ *****************************************************************************/
+
+/*****************************************************************************
+ *     Extern Variables
+ *****************************************************************************/
+
+extern network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX];
+
+/*****************************************************************************
+ *     Global Variables
+ *****************************************************************************/
+
+network_info_t NetworkInfo = {0, };
+
+/*****************************************************************************
+ *     Local Functions Definition
+ *****************************************************************************/
+
+static int __net_get_default_profile(void *param, net_profile_info_t *active_profile_info)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+
+       if (NetworkInfo.ClientEventCb == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+
+       if (param == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid parameter\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       Error = _net_get_default_profile_info(active_profile_info);
+
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR,
+                               "Error!!! _net_get_default_profile_info() failed. Error [%s]\n",
+                               _net_print_error(Error));
+
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+/*****************************************************************************
+ *     ConnMan Client Common Interface API Definition
+ *****************************************************************************/
+
+/**
+ * @fn  EXPORT_API int net_register_client(net_event_cb_t event_cb, void *user_data)
+ *
+ * This function registers callback with the network client
+ * This is Sync API.
+ *
+ * @return       int - NET_ERR_NONE on success, negative values for errors
+ * @param[in]    net_event_cb_t event_cb - Pointer to callback function
+ *              void* user_data - Pointer to user data 
+ * @param[out]   none 
+ */
+EXPORT_API int net_register_client(net_event_cb_t event_cb, void *user_data)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+
+       if (event_cb == NULL) {
+                NETWORK_LOG(NETWORK_ASSERT, "Error!! Invalid EventCb parameter\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+       
+       if (NetworkInfo.ClientEventCb != NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application Already registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_ALREADY_REGISTERED;
+       }
+
+       if (_net_mutex_init() != NET_ERR_NONE) {
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       Error = _net_register_signal();
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! _net_register_signal() failed. Error [%s]\n",
+                               _net_print_error(Error));
+               _net_mutex_destroy();
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       NetworkInfo.ClientEventCb = event_cb;
+       NetworkInfo.user_data = user_data;
+       NetworkInfo.wifi_state = _net_get_wifi_state();
+       _net_init_service_state_table();
+
+       NETWORK_LOG(NETWORK_HIGH, "Client Register Successfully\n");
+
+       __NETWORK_FUNC_EXIT__;  
+       return NET_ERR_NONE;
+}
+
+
+/**
+ * @fn  EXPORT_API int net_deregister_client(void)
+ *
+ * This function deregisters with network client 
+ * This is Sync API.
+ *
+ * @return       int - NET_ERR_NONE on success, negative values for errors
+ * @param[in]    none
+ * @param[out]   none
+ */
+
+EXPORT_API int net_deregister_client(void)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       
+       if (NetworkInfo.ClientEventCb == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+
+       Error = _net_deregister_signal();       
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Failed to deregister signal\n");
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       _net_mutex_destroy();
+       _net_clear_request_table();
+
+       NetworkInfo.ClientEventCb = NULL;
+       NetworkInfo.user_data = NULL;
+       
+       NETWORK_LOG(NETWORK_HIGH, "Client De-Register Successfull\n");
+       
+       __NETWORK_FUNC_EXIT__;  
+       return NET_ERR_NONE;
+}
+
+/**
+ * @fn  EXPORT_API int net_get_active_net_info(net_profile_info_t *active_profile_info)
+ *
+ * This API returns the information of active(default) network profile.
+ * This is Sync API.
+ *
+ * @return       int - NET_ERR_NONE on success, negative values for errors
+ * @param[in]    none
+ * @param[out]          active_profile_info    The information of active(default) network profile.
+ */
+EXPORT_API int net_get_active_net_info(net_profile_info_t *active_profile_info)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+
+       Error = __net_get_default_profile((void*)active_profile_info, active_profile_info);
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+/**
+ * @fn  EXPORT_API int net_get_active_ipaddress(net_addr_t *ip_address)
+ *
+ * This API returns a specific information of active(default) network profile.
+ * This is Sync API.
+ *
+ * @return       int - NET_ERR_NONE on success, negative values for errors
+ * @param[in]    none
+ * @param[out]          ip_address     Ip address of active(default) network profile.
+ */
+EXPORT_API int net_get_active_ipaddress(net_addr_t *ip_address)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       net_profile_info_t active_profile_info;
+       net_dev_info_t *net_info = NULL;
+
+       Error = __net_get_default_profile((void*)ip_address, &active_profile_info);
+       if (Error != NET_ERR_NONE) {
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       if (active_profile_info.profile_type == NET_DEVICE_CELLULAR)
+               net_info = &active_profile_info.ProfileInfo.Pdp.net_info;
+       else if (active_profile_info.profile_type == NET_DEVICE_WIFI)
+               net_info = &active_profile_info.ProfileInfo.Wlan.net_info;
+       else
+               Error = NET_ERR_UNKNOWN;
+
+       if (net_info != NULL)
+               memcpy(ip_address, &net_info->IpAddr, sizeof(net_addr_t));
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+/**
+ * @fn  EXPORT_API int net_get_active_netmask(net_addr_t *netmask)
+ *
+ * This API returns a specific information of active(default) network profile.
+ * This is Sync API.
+ *
+ * @return       int - NET_ERR_NONE on success, negative values for errors
+ * @param[in]    none
+ * @param[out]          netmask        Netmask of active(default) network profile.
+ */
+EXPORT_API int net_get_active_netmask(net_addr_t *netmask)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       net_profile_info_t active_profile_info;
+       net_dev_info_t *net_info = NULL;
+
+       Error = __net_get_default_profile((void*)netmask, &active_profile_info);
+       if (Error != NET_ERR_NONE) {
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       if (active_profile_info.profile_type == NET_DEVICE_CELLULAR)
+               net_info = &active_profile_info.ProfileInfo.Pdp.net_info;
+       else if (active_profile_info.profile_type == NET_DEVICE_WIFI)
+               net_info = &active_profile_info.ProfileInfo.Wlan.net_info;
+       else
+               Error = NET_ERR_UNKNOWN;
+
+       if (net_info != NULL)
+               memcpy(netmask, &net_info->SubnetMask, sizeof(net_addr_t));
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+/**
+ * @fn  EXPORT_API int net_get_active_gateway(net_addr_t *gateway)
+ *
+ * This API returns a specific information of active(default) network profile.
+ * This is Sync API.
+ *
+ * @return       int - NET_ERR_NONE on success, negative values for errors
+ * @param[in]    none
+ * @param[out]          gateway        Gateway address of active(default) network profile.
+ */
+EXPORT_API int net_get_active_gateway(net_addr_t *gateway)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       net_profile_info_t active_profile_info;
+       net_dev_info_t *net_info = NULL;
+
+       Error = __net_get_default_profile((void*)gateway, &active_profile_info);
+       if (Error != NET_ERR_NONE) {
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       if (active_profile_info.profile_type == NET_DEVICE_CELLULAR)
+               net_info = &active_profile_info.ProfileInfo.Pdp.net_info;
+       else if (active_profile_info.profile_type == NET_DEVICE_WIFI)
+               net_info = &active_profile_info.ProfileInfo.Wlan.net_info;
+       else
+               Error = NET_ERR_UNKNOWN;
+
+       if (net_info != NULL)
+               memcpy(gateway, &net_info->GatewayAddr, sizeof(net_addr_t));
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+/**
+ * @fn  EXPORT_API int net_get_active_dns(net_addr_t *dns)
+ *
+ * This API returns a specific information of active(default) network profile.
+ * This is Sync API.
+ *
+ * @return       int - NET_ERR_NONE on success, negative values for errors
+ * @param[in]    none
+ * @param[out]          dns    DNS address of active(default) network profile.
+ */
+EXPORT_API int net_get_active_dns(net_addr_t *dns)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       net_profile_info_t active_profile_info;
+       net_dev_info_t *net_info = NULL;
+
+       Error = __net_get_default_profile((void*)dns, &active_profile_info);
+       if (Error != NET_ERR_NONE) {
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       if (active_profile_info.profile_type == NET_DEVICE_CELLULAR)
+               net_info = &active_profile_info.ProfileInfo.Pdp.net_info;
+       else if (active_profile_info.profile_type == NET_DEVICE_WIFI)
+               net_info = &active_profile_info.ProfileInfo.Wlan.net_info;
+       else
+               Error = NET_ERR_UNKNOWN;
+
+       if (net_info != NULL)
+               memcpy(dns, &net_info->DnsAddr[0], sizeof(net_addr_t));
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+/**
+ * @fn  EXPORT_API int net_get_active_essid(net_essid_t *essid)
+ *
+ * This API returns a specific information of active(default) network profile.
+ * This is Sync API.
+ *
+ * @return       int - NET_ERR_NONE on success, negative values for errors
+ * @param[in]    none
+ * @param[out]          essid  ESSID of active(default) network profile.
+ */
+EXPORT_API int net_get_active_essid(net_essid_t *essid)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       net_profile_info_t active_profile_info;
+       net_wifi_profile_info_t *wlan_info = NULL;
+
+       Error = __net_get_default_profile((void*)essid, &active_profile_info);
+       if (Error != NET_ERR_NONE) {
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       if (active_profile_info.profile_type == NET_DEVICE_CELLULAR) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Active(default) network is cellular type.\n");
+               Error = NET_ERR_NO_SERVICE;
+       } else if (active_profile_info.profile_type == NET_DEVICE_WIFI) {
+               wlan_info = &active_profile_info.ProfileInfo.Wlan;
+               memcpy(essid->essid, wlan_info->essid, NET_WLAN_ESSID_LEN+1);
+       } else
+               Error = NET_ERR_UNKNOWN;
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+/**
+ * @fn  EXPORT_API int net_get_active_proxy(net_proxy_t *proxy)
+ *
+ * This API returns a specific information of active(default) network profile.
+ * This is Sync API.
+ *
+ * @return       int - NET_ERR_NONE on success, negative values for errors
+ * @param[in]    none
+ * @param[out]          proxy  Proxy of active(default) network profile.
+ */
+EXPORT_API int net_get_active_proxy(net_proxy_t *proxy)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       net_profile_info_t active_profile_info;
+       net_dev_info_t *net_info = NULL;
+
+       Error = __net_get_default_profile((void*)proxy, &active_profile_info);
+       if (Error != NET_ERR_NONE) {
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       if (active_profile_info.profile_type == NET_DEVICE_CELLULAR)
+               net_info = &active_profile_info.ProfileInfo.Pdp.net_info;
+       else if (active_profile_info.profile_type == NET_DEVICE_WIFI)
+               net_info = &active_profile_info.ProfileInfo.Wlan.net_info;
+       else
+               Error = NET_ERR_UNKNOWN;
+
+       if (net_info != NULL)
+               memcpy(proxy->proxy_addr, net_info->ProxyAddr, NET_PROXY_LEN_MAX+1);
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+/**
+ * @fn  EXPORT_API int net_is_connected(void)
+ *
+ * This function check's whether connection manager is connected or not
+ * This is Sync API.
+ *
+ * @return       int - TRUE if connected, else FALSE
+ * @param[in]    none
+ * @param[out]   none
+ */
+EXPORT_API int net_is_connected(void)
+{
+       char state[CONNMAN_MAX_BUFLEN] = ""; /** Possible value are "online", "offline" and "connected" */
+       net_err_t Error = NET_ERR_NONE;
+
+       __NETWORK_FUNC_ENTER__;
+       
+       if (NetworkInfo.ClientEventCb == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+
+       if ((Error = _net_dbus_get_state(state)) != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! failed to get state. Error [%s]\n",
+                               _net_print_error(Error));
+               __NETWORK_FUNC_EXIT__;
+               return FALSE;
+       }
+
+       if ((strcmp(state, "online") == 0) || (strcmp(state, "connected") == 0)) {
+               NETWORK_LOG(NETWORK_HIGH, "State [%s]\n", state);
+               __NETWORK_FUNC_EXIT__;
+               return TRUE; 
+       }
+
+       __NETWORK_FUNC_EXIT__;  
+       return FALSE;
+}
+
+
+/**
+ * @fn   EXPORT_API int net_get_network_status(net_service_type_t network_type, net_cm_network_status_t* pNetworkStatus)
+ *
+ * This function requests wifi/pdp network status 
+ * This is Sync API.
+ *
+ * @return       int - NET_ERR_NONE on success, negative values for errors
+ * @param[in]    net_service_type_t network_type - Network type (wlan/pdp/default), of whose status to be checked. 
+ * @param[out]   net_cm_network_status_t* pNetworkStatus - Status of the requested network.
+ */
+
+EXPORT_API int net_get_network_status(net_device_t device_type, net_cm_network_status_t* network_status)
+{
+       net_err_t Error = NET_ERR_NONE;
+
+       __NETWORK_FUNC_ENTER__;
+
+       if(NetworkInfo.ClientEventCb == NULL)
+       {
+               NETWORK_LOG( NETWORK_ERROR, "Error!!! Application was not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+       
+       if((Error = _net_dbus_get_network_status(device_type, network_status)) != NET_ERR_NONE)
+       {
+               NETWORK_LOG( NETWORK_ERROR, "Error!!! failed to get network status. Error [%s]\n",  
+                               _net_print_error(Error));
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+       
+       __NETWORK_FUNC_EXIT__;  
+       return NET_ERR_NONE;
+}
+
+
+/*****************************************************************************
+ *     ConnMan Wi-Fi Client Interface Async Function Definition
+ *****************************************************************************/
+
+
+/**
+ * @fn   EXPORT_API int net_open_connection_with_profile(const char *profile_name)
+ *
+ * This function request open connection for the given profile name.
+ * This is Async API.
+ *
+ * @return       int - NET_ERR_NONE on success, negative values for errors
+ * @param[in]    char *ProfileName - Profile Name to be connected
+ * @param[out]   none
+ */
+
+EXPORT_API int net_open_connection_with_profile(const char *profile_name)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+               
+       NETWORK_LOG(NETWORK_HIGH, "ProfileName [%s] passed\n", profile_name);
+
+       if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid ProfileName passed\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       if (NetworkInfo.ClientEventCb == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+       
+       if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE) {
+               NETWORK_LOG(NETWORK_ASSERT, "Error!! Request already in progress\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_OPERATION;
+       }
+       
+       request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag = TRUE;
+       snprintf(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName,
+                       NET_PROFILE_NAME_LEN_MAX+1, "%s", profile_name);
+
+       if ((Error = _net_dbus_open_connection(profile_name)) != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR,
+                               "Error!! Failed to request open connection, Error [%s]\n", 
+                               _net_print_error(Error));
+
+               if(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE)
+                       memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION],
+                                       0, sizeof(network_request_table_t));
+
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       NETWORK_LOG(NETWORK_HIGH, "Connect Request Success for ProfileName[%s]\n", profile_name);
+       __NETWORK_FUNC_EXIT__;  
+       return NET_ERR_NONE;
+}
+
+/**
+ * @fn   EXPORT_API int net_open_connection_with_preference(net_service_type_t service_type)
+ *
+ * This function request open connection for the given service type.
+ * This is Async API.
+ *
+ * @return       int - NET_ERR_NONE on success, negative values for errors
+ * @param[in]    net_service_type_t service_type - Service type to be connected
+ * @param[out]   none
+ */
+EXPORT_API int net_open_connection_with_preference(net_service_type_t service_type)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       net_profile_name_t profile_name;
+       memset(&profile_name, 0, sizeof(net_profile_name_t));
+
+       if (service_type != NET_SERVICE_INTERNET &&
+           service_type != NET_SERVICE_MMS &&
+           service_type != NET_SERVICE_WAP) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid Service Type passed\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       if (NetworkInfo.ClientEventCb == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+
+       if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE) {
+               NETWORK_LOG(NETWORK_ASSERT, "Error!! Request already in progress\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_OPERATION;
+       }
+
+       Error = _net_get_service_profile(service_type, &profile_name);
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ASSERT, "Error!! Failed to find service\n");
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag = TRUE;
+       snprintf(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName,
+                       NET_PROFILE_NAME_LEN_MAX+1, "%s", profile_name.ProfileName);
+
+       if ((Error = _net_dbus_open_connection(profile_name.ProfileName)) != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR,
+                               "Error!! Failed to request open connection, Error [%s]\n",
+                               _net_print_error(Error));
+
+               if(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE)
+                       memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION],
+                                       0, sizeof(network_request_table_t));
+
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       NETWORK_LOG(NETWORK_HIGH, "Connect Request Success for ProfileName[%s]\n",
+                       profile_name.ProfileName);
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+/**
+ * @fn   EXPORT_API int net_close_connection(const char *profile_name)
+ *
+ * This function requests close connection for the given profile name.
+ * This is Async API.
+ *
+ * @return       int - NET_ERR_NONE on success, negative values for errors
+ * @param[in]    char *profile_name - Connected profile Name
+ * @param[out]   none
+ */
+
+EXPORT_API int net_close_connection(const char *profile_name)
+{
+       __NETWORK_FUNC_ENTER__;
+       
+       net_err_t Error = NET_ERR_NONE;
+
+       NETWORK_LOG(NETWORK_HIGH, "ProfileName [%s] passed\n", profile_name);
+
+       if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
+                NETWORK_LOG(NETWORK_ERROR, "Error!! Invalid ProfileName parameter\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       if (NetworkInfo.ClientEventCb == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+       
+       if (request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE) {
+               NETWORK_LOG(NETWORK_ASSERT, "Error!!! Request already in progress\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_OPERATION;
+       }
+       
+       request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag = TRUE;
+       snprintf(request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].ProfileName,
+                       NET_PROFILE_NAME_LEN_MAX+1, "%s", profile_name);
+
+       if ((Error = _net_dbus_close_connection(profile_name)) != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR,
+                               "Error!! Failed to request close connection, Error [%s]\n", 
+                               _net_print_error(Error));
+       
+               if (request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE)
+                       memset(&request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION],
+                                       0, sizeof(network_request_table_t));
+
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+       
+       __NETWORK_FUNC_EXIT__;  
+       return NET_ERR_NONE;
+}
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
diff --git a/src/network-dbus-request.c b/src/network-dbus-request.c
new file mode 100644 (file)
index 0000000..c66e2a7
--- /dev/null
@@ -0,0 +1,2209 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+
+/*****************************************************************************
+ *     Standard headers
+ *****************************************************************************/
+#include <stdio.h> 
+#include <errno.h> 
+#include <stdlib.h> 
+#include <string.h> 
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <vconf.h>
+
+/*****************************************************************************
+ *     Platform headers
+ *****************************************************************************/
+
+#include "network-internal.h"
+#include "network-dbus-request.h"
+
+/*****************************************************************************
+ *     Macros and Typedefs
+ *****************************************************************************/
+
+#define DBUS_REPLY_TIMEOUT (120 * 1000)
+
+/*****************************************************************************
+ *     Local Functions Declaration
+ *****************************************************************************/
+
+static int __net_error_string_to_enum(const char* error);
+static int __net_netconfig_error_string_to_enum(const char* error);
+static int _net_get_error_from_message(DBusMessage *message);
+static int _net_get_error_from_netconfig_message(DBusMessage *message);
+static void __net_open_connection_reply(DBusPendingCall *call, void *user_data);
+static void __net_close_connection_reply(DBusPendingCall *call, void *user_data);
+static void __net_wifi_power_reply(DBusPendingCall *call, void *user_data);
+
+/*****************************************************************************
+ *     Global Functions
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ *     Global Variables
+ *****************************************************************************/
+
+struct dbus_pending_call_data {
+       DBusPendingCall *pcall;
+       dbus_bool_t is_used;
+};
+
+static struct dbus_pending_call_data network_dbus_pending_call_data = {
+       NULL,
+       FALSE
+};
+
+/*****************************************************************************
+ *     Extern Variables
+ *****************************************************************************/
+
+extern network_info_t NetworkInfo;
+extern network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX];
+
+
+/*****************************************************************************
+ *     Extern Functions 
+ *****************************************************************************/
+
+/*****************************************************************************
+ *     Local Functions Definition
+ *****************************************************************************/
+
+static int __net_error_string_to_enum(const char* error)
+{
+       NETWORK_LOG(NETWORK_HIGH, "Passed error value [%s]\n", error);
+
+       if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".NoReply"))
+               return NET_ERR_TIME_OUT;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".Failed"))
+               return NET_ERR_UNKNOWN;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".UnknownMethod"))
+               return NET_ERR_UNKNOWN_METHOD;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".InvalidArguments"))
+               return NET_ERR_INVALID_PARAM;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".PermissionDenied"))
+               return NET_ERR_ACCESS_DENIED;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".PassphraseRequired"))
+               return NET_ERR_INVALID_OPERATION;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".NotRegistered"))
+               return NET_ERR_INVALID_OPERATION;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".NotUnique"))
+               return NET_ERR_INVALID_OPERATION;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".NotSupported"))
+               return NET_ERR_NOT_SUPPORTED;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".NotImplemented"))
+               return NET_ERR_NOT_SUPPORTED;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".NotFound"))
+               return NET_ERR_NOT_SUPPORTED;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".NoCarrier"))
+               return NET_ERR_NOT_SUPPORTED;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".InProgress"))
+               return NET_ERR_IN_PROGRESS;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".AlreadyExists"))
+               return NET_ERR_INVALID_OPERATION;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".AlreadyEnabled"))
+               return NET_ERR_INVALID_OPERATION;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".AlreadyDisabled"))
+               return NET_ERR_INVALID_OPERATION;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".AlreadyConnected"))
+               return NET_ERR_ACTIVE_CONNECTION_EXISTS;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".NotConnected"))
+               return NET_ERR_NO_ACTIVE_CONNECTIONS;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".OperationAborted"))
+               return NET_ERR_OPERATION_ABORTED;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".OperationTimeout"))
+               return NET_ERR_TIME_OUT;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".InvalidService"))
+               return NET_ERR_NO_SERVICE;
+       else if (NULL != strstr(error, CONNMAN_ERROR_INTERFACE ".InvalidProperty"))
+               return NET_ERR_INVALID_OPERATION;
+       return NET_ERR_UNKNOWN;
+}
+
+static int __net_netconfig_error_string_to_enum(const char* error)
+{
+       NETWORK_LOG(NETWORK_HIGH, "Passed error value [%s]\n", error);
+
+       if (error == NULL)
+               return NET_ERR_UNKNOWN;
+
+       if (NULL != strstr(error, ".WifiDriverFailed"))
+               return NET_ERR_WIFI_DRIVER_FAILURE;
+       else if (NULL != strstr(error, ".SecurityRestricted"))
+               return NET_ERR_SECURITY_RESTRICTED;
+       return NET_ERR_UNKNOWN;
+}
+
+static int _net_get_error_from_message(DBusMessage *message)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       int MessageType = 0;
+
+       MessageType = dbus_message_get_type(message);
+
+       if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
+               const char* ptr = dbus_message_get_error_name(message);
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Error message received [%s]\n", ptr);
+               __NETWORK_FUNC_EXIT__;
+               return __net_error_string_to_enum(ptr);
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+static int _net_get_error_from_netconfig_message(DBusMessage *message)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       int MessageType = 0;
+
+       MessageType = dbus_message_get_type(message);
+
+       if (MessageType == DBUS_MESSAGE_TYPE_ERROR) {
+               const char* ptr = dbus_message_get_error_name(message);
+               const char* err_msg = _net_get_string(message);
+               NETWORK_LOG(NETWORK_ERROR,
+                               "Error!!! Error message received [%s] [%s]\n", ptr, err_msg);
+               __NETWORK_FUNC_EXIT__;
+               return __net_netconfig_error_string_to_enum(err_msg);
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+static void __net_open_connection_reply(DBusPendingCall *call, void *user_data)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       NETWORK_LOG(NETWORK_LOW, "__net_open_connection_reply() called\n");
+
+       net_event_info_t event_data = {0,};
+       net_profile_info_t prof_info;
+       network_request_table_t *open_info = &request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION];
+       network_request_table_t *wps_info = &request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS];
+
+       DBusMessage *reply = dbus_pending_call_steal_reply(call);
+       net_err_t Error = _net_get_error_from_message(reply);
+
+       if (Error == NET_ERR_NONE)
+               goto done;
+
+       NETWORK_LOG(NETWORK_ERROR,
+               "Error!!! Connection open failed. Error code : [%d]\n", Error);
+
+       if (open_info->flag == TRUE) {
+               net_device_t device_type = _net_get_tech_type_from_path(open_info->ProfileName);
+
+               if (Error == NET_ERR_IN_PROGRESS &&
+                   device_type == NET_DEVICE_CELLULAR)
+                       goto done;
+
+               snprintf(event_data.ProfileName,
+                       NET_PROFILE_NAME_LEN_MAX + 1, "%s",
+                       open_info->ProfileName);
+
+               memset(open_info, 0, sizeof(network_request_table_t));
+
+               event_data.Error = Error;
+
+               if (Error == NET_ERR_ACTIVE_CONNECTION_EXISTS) {
+                       Error = net_get_profile_info(event_data.ProfileName, &prof_info);
+
+                       if (device_type == NET_DEVICE_CELLULAR)
+                               event_data.Error = NET_ERR_NONE;
+
+                       if (Error != NET_ERR_NONE) {
+                               NETWORK_LOG(NETWORK_ERROR,
+                                       "Error!!! net_get_profile_info() failed [%s]\n",
+                                       _net_print_error(Error));
+                               event_data.Datalength = 0;
+                               event_data.Data = NULL;
+                       } else {
+                               event_data.Datalength = sizeof(net_profile_info_t);
+                               event_data.Data = &prof_info;
+                       }
+               }
+
+               event_data.Event = NET_EVENT_OPEN_RSP;
+               NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_OPEN_RSP Error = %s\n",
+                               _net_print_error(event_data.Error));
+               _net_client_callback(&event_data);
+       } else if (wps_info->flag == TRUE) {
+
+               snprintf(event_data.ProfileName,
+                       NET_PROFILE_NAME_LEN_MAX + 1, "%s",
+                       wps_info->ProfileName);
+
+               memset(wps_info, 0, sizeof(network_request_table_t));
+
+               event_data.Error = Error;
+
+               if (Error == NET_ERR_ACTIVE_CONNECTION_EXISTS) {
+                       Error = net_get_profile_info(event_data.ProfileName, &prof_info);
+                       if (Error != NET_ERR_NONE) {
+                               NETWORK_LOG(NETWORK_ERROR,
+                                       "Error!!! net_get_profile_info() failed [%s]\n",
+                                       _net_print_error(Error));
+                               event_data.Datalength = 0;
+                               event_data.Data = NULL;
+                       } else {
+                               event_data.Datalength = sizeof(net_profile_info_t);
+                               event_data.Data = &prof_info;
+                       }
+               }
+
+               event_data.Event = NET_EVENT_WIFI_WPS_RSP;
+
+               NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_WIFI_WPS_RSP Error = %s\n",
+                               _net_print_error(event_data.Error));
+               _net_client_callback(&event_data);
+       }
+
+done:
+       dbus_message_unref(reply);
+       dbus_pending_call_unref(call);
+
+       network_dbus_pending_call_data.is_used = FALSE;
+       network_dbus_pending_call_data.pcall = NULL;
+
+       __NETWORK_FUNC_EXIT__;
+}
+
+static void __net_close_connection_reply(DBusPendingCall *call, void *user_data)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       NETWORK_LOG(NETWORK_LOW, "__net_close_connection_reply() called\n");
+
+       net_event_info_t event_data = {0,};
+       network_request_table_t *close_info = &request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION];
+
+       DBusMessage *reply = dbus_pending_call_steal_reply(call);
+       net_err_t Error = _net_get_error_from_message(reply);
+
+       if (Error == NET_ERR_NONE)
+               goto done;
+
+       NETWORK_LOG(NETWORK_ERROR,
+               "Error!!! Connection close failed. Error code : [%d]\n", Error);
+
+       if (close_info->flag == TRUE) {
+               net_device_t device_type = _net_get_tech_type_from_path(close_info->ProfileName);
+
+               if (Error == NET_ERR_ACTIVE_CONNECTION_EXISTS &&
+                   device_type == NET_DEVICE_CELLULAR)
+                       Error = NET_ERR_NONE;
+
+               snprintf(event_data.ProfileName,
+                       NET_PROFILE_NAME_LEN_MAX + 1, "%s",
+                       close_info->ProfileName);
+
+               memset(close_info, 0, sizeof(network_request_table_t));
+
+               event_data.Error = Error;
+               event_data.Datalength = 0;
+               event_data.Data = NULL;
+               event_data.Event = NET_EVENT_CLOSE_RSP;
+               NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_CLOSE_RSP Error = %s\n",
+                               _net_print_error(event_data.Error));
+               _net_client_callback(&event_data);
+       }
+
+done:
+       dbus_message_unref(reply);
+       dbus_pending_call_unref(call);
+
+       network_dbus_pending_call_data.is_used = FALSE;
+       network_dbus_pending_call_data.pcall = NULL;
+
+       __NETWORK_FUNC_EXIT__;
+}
+
+static void __net_wifi_power_reply(DBusPendingCall *call, void *user_data)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       DBusMessage *reply = dbus_pending_call_steal_reply(call);
+       net_err_t Error = _net_get_error_from_netconfig_message(reply);
+
+       if (Error == NET_ERR_NONE)
+               goto done;
+
+       net_event_info_t event_data = {0,};
+       net_wifi_state_t wifi_state = WIFI_UNKNOWN;
+
+       NETWORK_LOG(NETWORK_ERROR,
+               "Error!!! Wifi Power on/off failed. Error code : [%d]\n", Error);
+
+       if (request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
+               memset(&request_table[NETWORK_REQUEST_TYPE_WIFI_POWER],
+                               0, sizeof(network_request_table_t));
+
+               event_data.Event = NET_EVENT_WIFI_POWER_RSP;
+               event_data.Error = Error;
+               event_data.Datalength = sizeof(net_wifi_state_t);
+               event_data.Data = &wifi_state;
+               NETWORK_LOG(NETWORK_LOW,
+                       "Sending NET_EVENT_WIFI_POWER_RSP Error = %d\n", event_data.Error);
+               _net_client_callback(&event_data);
+       }
+
+done:
+       dbus_message_unref(reply);
+       dbus_pending_call_unref(call);
+
+       network_dbus_pending_call_data.is_used = FALSE;
+       network_dbus_pending_call_data.pcall = NULL;
+
+       __NETWORK_FUNC_EXIT__;
+}
+
+static int __net_append_argument(DBusMessageIter *iter, int ArgType, const char *Value)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       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 {
+                       NETWORK_LOG(NETWORK_ERROR, "Error!!! Expected \"true\" or \"false\" instead of \"%s\"\n", Value);
+                       __NETWORK_FUNC_EXIT__;
+                       return NET_ERR_UNKNOWN;
+               }
+               break;
+
+       default:
+               NETWORK_LOG( NETWORK_ERROR, "Error!!! Unsupported data ArgType %c\n", (char) ArgType);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+static int __net_append_array(DBusMessageIter *iter, int ArgType, const char *Value)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       const char *Val = NULL;
+       char *saveptr = NULL;
+       char *DupValue = strdup(Value);
+
+       Val = strtok_r(DupValue, ",", &saveptr);
+       while(Val != NULL) {
+               if( __net_append_argument(iter, ArgType, Val) != NET_ERR_NONE ) {
+                       NET_MEMFREE(DupValue);
+                       __NETWORK_FUNC_EXIT__;
+                       return  NET_ERR_UNKNOWN;
+               }
+               Val = strtok_r(NULL, ",", &saveptr);
+       }
+       NET_MEMFREE(DupValue);
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+static int __net_append_dict(DBusMessageIter *iter, int KeyType, int ValueType, const char *Value)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       const char *Val = NULL;
+       char *saveptr = NULL;
+       char *DupValue = strdup(Value);
+
+       Val = strtok_r(DupValue, ",", &saveptr);
+       while(Val != NULL) {
+               DBusMessageIter SubIter;
+
+               dbus_message_iter_open_container(iter,
+                               DBUS_TYPE_DICT_ENTRY,
+                               NULL,
+                               &SubIter);
+
+               if( __net_append_argument (&SubIter, KeyType, Val) != NET_ERR_NONE ) {
+                       NETWORK_LOG(NETWORK_ERROR, "Error!!! __net_append_argument() failed\n");
+                       NET_MEMFREE(DupValue);
+                       __NETWORK_FUNC_EXIT__;
+                       return  NET_ERR_UNKNOWN;
+               }
+
+               Val = strtok_r(NULL, ",", &saveptr);
+               if(Val == NULL) {
+                       NETWORK_LOG(NETWORK_ERROR, "Error!!! Crashed dictionary data\n");
+                       NET_MEMFREE(DupValue);
+                       __NETWORK_FUNC_EXIT__;
+                       return NET_ERR_UNKNOWN;
+               }
+
+               if( __net_append_argument (&SubIter, ValueType, Val) != NET_ERR_NONE ) {
+                       NETWORK_LOG(NETWORK_ERROR, "Error!!! __net_append_argument() failed\n");
+                       NET_MEMFREE(DupValue);
+                       __NETWORK_FUNC_EXIT__;
+                       return  NET_ERR_UNKNOWN;
+               }
+
+               dbus_message_iter_close_container (iter, &SubIter);
+               Val = strtok_r(NULL, ",", &saveptr);
+       }
+       NET_MEMFREE(DupValue);
+       __NETWORK_FUNC_EXIT__;
+       return  NET_ERR_NONE;
+}
+
+static int __net_datatype_from_stringname(const char *Args)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       int ArgType = 0;
+
+       if( !strcmp(Args, CONNMAN_CLIENT_DBUS_TYPE_STRING) )
+               ArgType = DBUS_TYPE_STRING;
+       else if( !strcmp(Args, CONNMAN_CLIENT_DBUS_TYPE_INT16) )
+               ArgType = DBUS_TYPE_INT16;
+       else if( !strcmp(Args, CONNMAN_CLIENT_DBUS_TYPE_UINT16) )
+               ArgType = DBUS_TYPE_UINT16;
+       else if( !strcmp(Args, CONNMAN_CLIENT_DBUS_TYPE_INT32) )
+               ArgType = DBUS_TYPE_INT32;
+       else if( !strcmp(Args, CONNMAN_CLIENT_DBUS_TYPE_UINT32) )
+               ArgType = DBUS_TYPE_UINT32;
+       else if( !strcmp(Args, CONNMAN_CLIENT_DBUS_TYPE_INT64) )
+               ArgType = DBUS_TYPE_INT64;
+       else if( !strcmp(Args, CONNMAN_CLIENT_DBUS_TYPE_UINT64) )
+               ArgType = DBUS_TYPE_UINT64;
+       else if( !strcmp(Args, CONNMAN_CLIENT_DBUS_TYPE_DOUBLE) )
+               ArgType = DBUS_TYPE_DOUBLE;
+       else if( !strcmp(Args, CONNMAN_CLIENT_DBUS_TYPE_BYTE) )
+               ArgType = DBUS_TYPE_BYTE;
+       else if( !strcmp(Args, CONNMAN_CLIENT_DBUS_TYPE_BOOLEAN) )
+               ArgType = DBUS_TYPE_BOOLEAN;
+       else if( !strcmp(Args, CONNMAN_CLIENT_DBUS_TYPE_OBJECT_PATH) )
+               ArgType = DBUS_TYPE_OBJECT_PATH;
+       else {
+               NETWORK_LOG( NETWORK_ERROR, "Error!!! Unknown Argument Type \"%s\"\n", Args);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return ArgType;
+}
+  
+/*****************************************************************************
+ *     Global Functions Definition
+ *****************************************************************************/
+
+DBusMessage *_net_invoke_dbus_method(const char* dest, DBusConnection *connection,
+               const char* path, char* interface_name, char* method, int *dbus_error)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       DBusError error;
+       DBusMessage *reply = NULL;
+       DBusMessage *message = NULL;
+
+       *dbus_error = NET_ERR_NONE;
+
+       message = dbus_message_new_method_call(dest, path, interface_name, method);
+       if (message == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! dbus_message_new_method_call() failed\n");
+               __NETWORK_FUNC_EXIT__;
+               return NULL;
+       }
+
+       dbus_error_init(&error);
+
+       reply = dbus_connection_send_with_reply_and_block(connection,
+                       message, DBUS_REPLY_TIMEOUT, &error);
+       if (reply == NULL) {
+               if (dbus_error_is_set(&error) == TRUE) {
+                       NETWORK_LOG(NETWORK_ERROR,
+                                       "Error!!! dbus_connection_send_with_reply_and_block() failed. dbus error [%s: %s]\n",
+                                       error.name, error.message);
+                       *dbus_error = __net_error_string_to_enum(error.name);
+                       dbus_error_free(&error);
+               } else {
+                       NETWORK_LOG(NETWORK_ERROR, "Error!!! dbus_connection_send_with_reply_and_block() failed\n");
+                       *dbus_error = NET_ERR_UNKNOWN;
+               }
+
+               dbus_message_unref(message);
+               __NETWORK_FUNC_EXIT__;
+               return NULL;
+       }
+
+       dbus_message_unref(message);
+
+       __NETWORK_FUNC_EXIT__;
+       return reply;
+}
+
+int _net_invoke_dbus_method_nonblock(const char* dest, DBusConnection *connection,
+               const char* path, char* interface_name, char* method,
+               DBusPendingCallNotifyFunction notify_func)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       DBusMessage *message = NULL;
+       DBusPendingCall *call;
+       dbus_bool_t result;
+
+       message = dbus_message_new_method_call(dest, path, interface_name, method);
+       if (message == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! dbus_message_new_method_call() Failed\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       result = dbus_connection_send_with_reply(connection,
+                       message, &call, DBUS_REPLY_TIMEOUT);
+
+       if (result == FALSE || call == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! dbus_connection_send_with_reply() Failed\n");
+               dbus_message_unref(message);
+               return NET_ERR_UNKNOWN;
+       }
+
+       dbus_pending_call_set_notify(call, notify_func, NULL, NULL);
+       network_dbus_pending_call_data.pcall = call;
+       network_dbus_pending_call_data.is_used = TRUE;
+
+       dbus_message_unref(message);
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+
+int _net_send_dbus_request(const char* destination, char *param_array[], DBusMessage** result)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       DBusConnection *connection = NULL;
+       DBusError error;
+       DBusMessage *message = NULL;
+       net_err_t Error = NET_ERR_NONE;
+       char *RequestMethod = NULL;
+       int i = 0;
+       const char *path = NULL;
+       const char *name = NULL;
+       int param_count = 0;
+       // const char *destination = CONNMAN_SERVICE;
+       DBusMessageIter iter;
+
+       for (param_count = 0; param_array[param_count] != NULL; param_count++) {
+               NETWORK_LOG(NETWORK_HIGH, "[%s]\n", param_array[param_count]);
+       }
+       NETWORK_LOG(NETWORK_HIGH, "Total Arguments [%d]\n", param_count);
+
+       path = param_array[i++]; /** 0th is path */
+       name = param_array[i++]; /** 1st is request name */
+
+       if ((strlen(path) == 0) || (strlen(name) == 0) ) {
+               NETWORK_LOG(NETWORK_ASSERT, "Error!!! Invalid parameters passed path [%s], requested name [%s]\n",
+                               path, name);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       dbus_error_init(&error);
+
+       connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+       if (connection == NULL) {
+               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Failed to get system dbus, error [%s]\n",
+                               error.message);
+               dbus_error_free(&error);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       RequestMethod = strrchr(name, '.');
+       if (RequestMethod == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid method in \"%s\"\n", name);
+               dbus_connection_unref(connection);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       *RequestMethod = '\0';
+       message = dbus_message_new_method_call(NULL, path, name, RequestMethod + 1);
+
+       if (message == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! dbus_message_new_method_call() failed\n");
+               __NETWORK_FUNC_EXIT__;
+               Error = NET_ERR_UNKNOWN;
+               goto end_error;
+       }
+
+       if (destination && !dbus_message_set_destination(message, destination)) {
+               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! dbus_message_set_destination() failed\n");
+               __NETWORK_FUNC_EXIT__;
+               Error = NET_ERR_UNKNOWN;
+               goto end_error;
+       }
+
+       dbus_message_iter_init_append(message, &iter);
+
+       /** Two arguments 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) {
+                       NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid data format[\"%s\"]\n", Args);
+                       Error = NET_ERR_UNKNOWN;
+                       goto end_error;
+               }
+
+               *(Ch++) = 0;
+
+               if (strcmp(Args, CONNMAN_CLIENT_DBUS_TYPE_VARIANT) == 0) {
+                       ContainerType = DBUS_TYPE_VARIANT;
+               } else if (strcmp(Args, CONNMAN_CLIENT_DBUS_TYPE_ARRAY) == 0) {
+                       ContainerType = DBUS_TYPE_ARRAY;
+               } else if (strcmp(Args, CONNMAN_CLIENT_DBUS_TYPE_DICT_ENTRY) == 0) {
+                       ContainerType = DBUS_TYPE_DICT_ENTRY;
+               } else {
+                       ContainerType = DBUS_TYPE_INVALID;
+               }
+
+               if (ContainerType != DBUS_TYPE_INVALID) {
+                       Args = Ch;
+                       Ch = strchr(Args, ':');
+                       if (Ch == NULL) {
+                               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid data format[\"%s\"]\n", Args);
+                               Error = NET_ERR_UNKNOWN;
+                               goto end_error;
+                       }
+                       *(Ch++) = 0;
+               }
+
+               if (Args[0] == 0) {
+                       ArgType = DBUS_TYPE_STRING;
+               } else {
+                       ArgType = __net_datatype_from_stringname(Args);
+                       if (ArgType == NET_ERR_UNKNOWN) {
+                               NETWORK_LOG(NETWORK_ERROR, "Error!!! Unknown data type\n");
+                               Error = NET_ERR_UNKNOWN;
+                               goto end_error;
+                       }
+               }
+
+               if (ContainerType == DBUS_TYPE_DICT_ENTRY) {
+                       char Signature[5] = "";
+                       Args = Ch;
+                       Ch = strchr (Ch, ':');
+
+                       if (Ch == NULL) {
+                               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid data format[\"%s\"]\n", Args);
+                               Error = NET_ERR_UNKNOWN;
+                               goto end_error;
+                       }
+
+                       *(Ch++) = 0;
+                       SecondaryType = __net_datatype_from_stringname(Args);
+
+                       if (SecondaryType == NET_ERR_UNKNOWN) {
+                               NETWORK_LOG(NETWORK_ERROR, "Error!!! Unknown datatype\n");
+                               Error = NET_ERR_UNKNOWN;
+                               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 (__net_append_array(TargetIter, ArgType, Ch) != NET_ERR_NONE) {
+                               NETWORK_LOG(NETWORK_ERROR, "Error!!! __net_append_array() failed\n");
+                               Error = NET_ERR_UNKNOWN;
+                               goto end_error;
+                       }
+               } else if (ContainerType == DBUS_TYPE_DICT_ENTRY) {
+                       if (__net_append_dict(TargetIter, ArgType, SecondaryType, Ch) != NET_ERR_NONE) {
+                               NETWORK_LOG(NETWORK_ERROR, "Error!!! __net_append_dict() failed\n");
+                               Error = NET_ERR_UNKNOWN;
+                               goto end_error;
+                       }
+               } else {
+                       if (__net_append_argument(TargetIter, ArgType, Ch) != NET_ERR_NONE) {
+                               NETWORK_LOG(NETWORK_ERROR, "Error!!! __net_append_argument() failed\n");
+                               Error = NET_ERR_UNKNOWN;
+                               goto end_error;
+                       }
+               }
+
+               if (ContainerType != DBUS_TYPE_INVALID) {
+                       dbus_message_iter_close_container(&iter, &ContainerIter);
+               }
+       }
+
+       DBusMessage *reply = NULL;
+
+       dbus_error_init (&error);
+
+       reply = dbus_connection_send_with_reply_and_block(connection,
+                       message,
+                       DBUS_REPLY_TIMEOUT,
+                       &error);
+       if (reply == NULL) {
+               if (dbus_error_is_set(&error) == TRUE) {
+                       NETWORK_LOG(NETWORK_ERROR,
+                                       "Error!!! dbus_connection_send_with_reply_and_block() failed, Error[%s: %s]\n",
+                                       error.name,
+                                       error.message);
+                       Error = __net_error_string_to_enum(error.name);
+                       dbus_error_free(&error);
+               } else
+                       Error = NET_ERR_UNKNOWN;
+
+               goto end_error;
+       } else {
+               if (result != NULL) {
+                       *result = reply;
+               } else {
+                       dbus_message_unref(reply);
+               }
+       }
+
+end_error:
+       dbus_message_unref(message);
+       dbus_connection_unref(connection);
+
+       if (Error == NET_ERR_NONE)
+               NETWORK_LOG(NETWORK_HIGH, "Successfully requested\n");
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+
+int _net_dbus_open_connection(const char* profile_name)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusConnection* conn = NULL;
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+
+       if (conn == NULL) {
+               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Can't get on system bus\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       NETWORK_LOG(NETWORK_HIGH,  "Requesting [%s %s]\n",
+                       profile_name, CONNMAN_SERVICE_INTERFACE ".Connect");
+
+       Error = _net_invoke_dbus_method_nonblock(CONNMAN_SERVICE, conn, profile_name,
+                       CONNMAN_SERVICE_INTERFACE, "Connect", __net_open_connection_reply);
+
+       dbus_connection_unref(conn);
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+
+int _net_dbus_close_connection(const char* profile_name)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusConnection* conn = NULL;
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+
+       if (conn == NULL) {
+               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Can't get on system bus\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       NETWORK_LOG(NETWORK_HIGH,  "Requesting [%s %s]\n",
+                       profile_name, CONNMAN_SERVICE_INTERFACE ".Disconnect");
+
+       Error = _net_invoke_dbus_method_nonblock(CONNMAN_SERVICE, conn, profile_name,
+                       CONNMAN_SERVICE_INTERFACE, "Disconnect", __net_close_connection_reply);
+
+       dbus_connection_unref(conn);
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+
+int _net_dbus_scan_request(void)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+
+       /** dbus-send --system --print-reply --dest=net.connman / net.connman.Manager.RequestScan string:wifi */
+       char request[] = CONNMAN_MANAGER_INTERFACE ".RequestScan";
+       char param1[] = "string:wifi";
+       char path[CONNMAN_MAX_BUFLEN] = "/";
+       char* param_array[] = {NULL, NULL, NULL, NULL};
+       param_array[0] = path;
+       param_array[1] = request;
+       param_array[2] = param1;
+
+       NETWORK_LOG(NETWORK_HIGH, "path [%s]\n", path);
+       NETWORK_LOG(NETWORK_HIGH, "Requesting [%s %s %s]\n", param_array[0], param_array[1], param_array[2]);
+
+       if( (Error = _net_send_dbus_request(CONNMAN_SERVICE, param_array, NULL)) != NET_ERR_NONE ) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! _net_send_dbus_request failed\n");
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+int _net_dbus_provision_service(gchar * config_str, int len)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+
+       /** dbus-send --system --print-reply --dest=net.connman / net.connman.Manager.ProvisionService string:xxx..*/
+       char request[] = CONNMAN_MANAGER_INTERFACE ".ProvisionService";
+       char *param1 = NULL;
+       int param1_len = len + strlen("string:");
+       char path[CONNMAN_MAX_BUFLEN] = "/";
+       char* param_array[] = {NULL, NULL, NULL, NULL};
+
+       param1 = (char*)calloc(param1_len, sizeof(char));
+       if(param1 == NULL)
+               return NET_ERR_UNKNOWN;
+
+       snprintf(param1, param1_len, "string:%s", config_str);
+
+       param_array[0] = path;
+       param_array[1] = request;
+       param_array[2] = param1;
+
+       if( (Error = _net_send_dbus_request(CONNMAN_SERVICE, param_array, NULL)) != NET_ERR_NONE ) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! _net_send_dbus_request failed\n");
+               NET_MEMFREE(param1);
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       NET_MEMFREE(param1);
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+
+int _net_dbus_set_bgscan_mode(net_wifi_background_scan_mode_t mode)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       /** TODO device interface missing */
+
+       net_err_t Error = NET_ERR_NONE;
+       /** dbus-send --system --print-reply --dest=net.connman / net.connman.Manager.SetProperty string:ScanMode variant:uint16:0/1/2 */
+       char request[] = NETCONFIG_WIFI_INTERFACE ".SetBgscan";
+       char param1[64] = "";
+       char path[CONNMAN_MAX_BUFLEN] = NETCONFIG_WIFI_PATH;
+       char* param_array[] = {NULL, NULL, NULL, NULL};
+
+       NETWORK_LOG(NETWORK_HIGH, "path [%s]\n", path);
+
+       snprintf(param1, 64, "uint32:%d", mode);
+       
+       param_array[0] = path;
+       param_array[1] = request;
+       param_array[2] = param1;
+
+       NETWORK_LOG(NETWORK_HIGH,  "Requesting [%s %s %s]\n",
+               param_array[0],
+               param_array[1],
+               param_array[2]
+               );
+
+       Error = _net_send_dbus_request(NETCONFIG_SERVICE, param_array, NULL);
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR,  "Error!!! Request failed\n");
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+int _net_dbus_get_technology_state(network_get_tech_state_info_t* tech_state)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusConnection* conn = NULL;
+       DBusMessage *message = NULL;
+
+       if ((tech_state == NULL) || (strlen(tech_state->technology) == 0)) {
+               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Invalid parameter\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+       if (conn == NULL) {
+               NETWORK_LOG(NETWORK_EXCEPTION,
+                               "Error!!! Can't get on system bus\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       if (strcmp(tech_state->technology, "wifi") == 0) {
+               int hotspot_state = 0;
+               vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &hotspot_state);
+
+               if (hotspot_state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI)
+                       goto done;
+       }
+
+       message = _net_invoke_dbus_method(CONNMAN_SERVICE, conn, CONNMAN_MANAGER_PATH,
+                       CONNMAN_MANAGER_INTERFACE, "GetProperties", &Error);
+
+       if (message == NULL) {
+               NETWORK_LOG(NETWORK_ERROR,
+                               "Error!!! Failed to get technology info\n");
+               goto done;
+       }
+
+       Error = _net_get_tech_state(message, tech_state);
+
+       NETWORK_LOG(NETWORK_HIGH,
+                       "technology [%s]\n"
+                       "AvailableTechnology [%d]\n"
+                       "EnabledTechnology [%d]\n"
+                       "ConnectedTechnology [%d]\n"
+                       "DefaultTechnology [%d]\n",
+                       tech_state->technology, 
+                       tech_state->AvailableTechnology, 
+                       tech_state->EnabledTechnology, 
+                       tech_state->ConnectedTechnology, 
+                       tech_state->DefaultTechnology);
+
+       dbus_message_unref(message);
+
+done:
+       dbus_connection_unref(conn);
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+
+int _net_dbus_get_network_status(net_device_t device_type, net_cm_network_status_t* network_status)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       network_get_tech_state_info_t tech_state = {{0,},};
+
+       if (device_type == NET_DEVICE_WIFI)
+               snprintf(tech_state.technology, NET_TECH_LENGTH_MAX, "%s", "wifi");
+       else if (device_type == NET_DEVICE_CELLULAR)
+               snprintf(tech_state.technology, NET_TECH_LENGTH_MAX, "%s", "cellular");
+       else {
+               Error = NET_ERR_INVALID_PARAM;
+               goto done;
+       }
+
+       Error = _net_dbus_get_technology_state(&tech_state);
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR,
+                       "Error!!! _net_dbus_get_technology_state() failed. Error [%s]\n",
+                       _net_print_error(Error));
+               goto done;
+       }
+
+       if (tech_state.ConnectedTechnology == TRUE)
+               *network_status = NET_STATUS_AVAILABLE;
+       else
+               *network_status = NET_STATUS_UNAVAILABLE;
+
+done:
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+
+int _net_dbus_get_state(char* state)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusConnection* conn = NULL;
+       DBusMessage *message = NULL;
+       char *net_state = NULL;
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); 
+       if (conn == NULL) {
+               NETWORK_LOG(NETWORK_EXCEPTION,
+                               "Error!!! Can't get on system bus\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       message = _net_invoke_dbus_method(
+                       CONNMAN_SERVICE, conn, CONNMAN_MANAGER_PATH,
+                       CONNMAN_MANAGER_INTERFACE, "GetState", &Error);
+       if (message == NULL) {
+               NETWORK_LOG(NETWORK_ERROR,
+                               "Error!!! Failed to get service properties\n");
+               dbus_connection_unref(conn);
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       net_state = _net_get_string(message);
+       snprintf(state, strlen(net_state)+1, "%s", net_state);
+       
+       NETWORK_LOG( NETWORK_HIGH, "State : [%s]\n", state);
+
+       dbus_message_unref(message);
+       dbus_connection_unref(conn);
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+
+int _net_dbus_connect_service(const net_wifi_connect_service_info_t* wifi_connection_info)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusError error;
+
+       const char *prop_type = "Type";
+       const char *prop_mode = "Mode";
+       const char *prop_ssid = "SSID";
+       const char *prop_security = "Security";
+       const char *prop_passphrase = "Passphrase";
+
+       DBusMessage* msg = NULL;
+       DBusMessage* reply = NULL;
+       DBusMessageIter dict, entry, array,value;
+       DBusConnection* conn = NULL;
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); 
+       if(conn == NULL) {
+               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Can't get on system bus\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       msg = dbus_message_new_method_call(CONNMAN_SERVICE, CONNMAN_MANAGER_PATH, CONNMAN_MANAGER_INTERFACE, "ConnectService");
+       if(msg == NULL) {
+               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! dbus_message_new_method_call() failed\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       dbus_message_iter_init_append(msg, &array);
+       dbus_message_iter_open_container(&array, DBUS_TYPE_ARRAY, "{sv}", &dict);
+
+       dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, 0, &entry);
+       dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &prop_type);
+       dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &value);
+       dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING, &wifi_connection_info->type);
+       dbus_message_iter_close_container(&entry, &value);
+       dbus_message_iter_close_container(&dict, &entry);
+
+       dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, 0, &entry);
+       dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &prop_mode);
+       dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &value);
+       dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING, &wifi_connection_info->mode);
+       dbus_message_iter_close_container(&entry, &value);
+       dbus_message_iter_close_container(&dict, &entry);
+
+       dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, 0, &entry);
+       dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &prop_ssid);
+       dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &value);
+       dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING, &wifi_connection_info->ssid);
+       dbus_message_iter_close_container(&entry, &value);
+       dbus_message_iter_close_container(&dict, &entry);
+
+       dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, 0, &entry);
+       dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &prop_security);
+       dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &value);
+       dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING, &wifi_connection_info->security);
+       dbus_message_iter_close_container(&entry, &value);
+       dbus_message_iter_close_container(&dict, &entry);
+
+       if( strcmp(wifi_connection_info->security, "ieee8021x") == 0 ) {
+               /** TODO Handle EAP */
+       } else {
+               /** none, wep, psk, rsn */
+               dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, 0, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &prop_passphrase);
+               dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, DBUS_TYPE_STRING_AS_STRING, &value);
+               dbus_message_iter_append_basic(&value, DBUS_TYPE_STRING, &wifi_connection_info->passphrase);
+               dbus_message_iter_close_container(&entry, &value);
+               dbus_message_iter_close_container(&dict, &entry);
+       }
+
+       dbus_message_iter_close_container(&array, &dict);
+
+       dbus_error_init(&error);
+       reply = dbus_connection_send_with_reply_and_block(conn,
+                       msg,
+                       6 * DBUS_REPLY_TIMEOUT, /** Special case - here profile is created and returned so this need more time */
+                       &error);
+
+       if(reply == NULL) {
+               if( dbus_error_is_set(&error) == TRUE ) {
+                       NETWORK_LOG(NETWORK_ERROR,
+                                       "Error!!! dbus_connection_send_with_reply_and_block() failed, Error[%s: %s]\n",
+                                       error.name,
+                                       error.message);
+                       Error = __net_error_string_to_enum(error.name);
+                       dbus_error_free(&error);
+                       dbus_message_unref(msg);
+                       __NETWORK_FUNC_EXIT__;
+                       return Error;
+               }
+               dbus_message_unref(msg);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       } else {
+               char *ProfileName = NULL;
+               ProfileName = _net_get_object(reply);
+               NETWORK_LOG(NETWORK_HIGH, "ObjectPath/ProfileName [%s]\n", ProfileName);
+       }
+
+       dbus_message_unref(reply);
+       dbus_message_unref(msg);
+
+       NETWORK_LOG(NETWORK_HIGH, "Successfully configured\n");
+
+       dbus_connection_unref(conn);
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+
+int _net_dbus_set_profile_ipv4(net_profile_info_t* prof_info, char* profile_name)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusError error; 
+       const char *manual_method = "manual";
+       const char *dhcp_method = "dhcp";
+       const char *off_method = "off";
+
+       const char *prop_ipv4_configuration = "IPv4.Configuration";
+       const char *prop_method = "Method";
+       const char *prop_address = "Address";
+       const char *prop_gateway = "Gateway";
+       const char *prop_netmask = "Netmask";   
+
+       char ip_buffer[NETPM_IPV4_STR_LEN_MAX+1] = "";
+       char netmask_buffer[NETPM_IPV4_STR_LEN_MAX+1] = "";
+       char gateway_buffer[NETPM_IPV4_STR_LEN_MAX+1] = "";
+
+       char *ipaddress = ip_buffer;
+       char *netmask = netmask_buffer;
+       char *gateway = gateway_buffer; 
+
+       DBusMessage *msg = NULL;
+       DBusMessage *reply = NULL;
+       DBusMessageIter itr, variant, dict, entry;
+       DBusConnection* conn = NULL;
+
+       if ((prof_info == NULL) || (profile_name == NULL) || (strlen(profile_name) == 0)) {
+               NETWORK_LOG(NETWORK_ASSERT,  "Error!!! Invalid argument\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       snprintf(ip_buffer, NETPM_IPV4_STR_LEN_MAX + 1, "%s",
+                       inet_ntoa(prof_info->ProfileInfo.Wlan.net_info.IpAddr.Data.Ipv4));
+       snprintf(netmask_buffer, NETPM_IPV4_STR_LEN_MAX + 1, "%s",
+                       inet_ntoa(prof_info->ProfileInfo.Wlan.net_info.SubnetMask.Data.Ipv4));
+       snprintf(gateway_buffer, NETPM_IPV4_STR_LEN_MAX + 1, "%s",
+                       inet_ntoa(prof_info->ProfileInfo.Wlan.net_info.GatewayAddr.Data.Ipv4));
+
+       NETWORK_LOG(NETWORK_ASSERT, "ipaddress : %s, netmask : %s, gateway : %s\n",
+                       ipaddress, netmask, gateway);
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); 
+       if (conn == NULL) {
+               NETWORK_LOG(NETWORK_ERROR,  "Error!!! Can't get on system bus\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       /** Send ipaddress, netmask, gateway configuration */
+       msg = dbus_message_new_method_call(CONNMAN_SERVICE,
+                       profile_name, CONNMAN_SERVICE_INTERFACE, "SetProperty");
+       if (msg == NULL) {
+               NETWORK_LOG( NETWORK_ERROR,  "Error!!! dbus_message_new_method_call() failed\n");
+               dbus_connection_unref(conn);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+       NETWORK_LOG(NETWORK_ASSERT, "DBus Message 1/2 : %s %s %s %s\n", CONNMAN_SERVICE,
+                       profile_name, CONNMAN_SERVICE_INTERFACE, "SetProperty");
+
+       dbus_message_iter_init_append(msg, &itr);
+       dbus_message_iter_append_basic(&itr, DBUS_TYPE_STRING, &prop_ipv4_configuration);
+
+       dbus_message_iter_open_container
+               (&itr, DBUS_TYPE_VARIANT,
+                (DBUS_TYPE_ARRAY_AS_STRING
+                 DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+                 DBUS_TYPE_STRING_AS_STRING
+                 DBUS_TYPE_STRING_AS_STRING
+                 DBUS_DICT_ENTRY_END_CHAR_AS_STRING),
+                &variant);
+       dbus_message_iter_open_container
+               (&variant, DBUS_TYPE_ARRAY,
+                (DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+                 DBUS_TYPE_STRING_AS_STRING
+                 DBUS_TYPE_STRING_AS_STRING
+                 DBUS_DICT_ENTRY_END_CHAR_AS_STRING),
+                &dict);
+               
+       if (prof_info->ProfileInfo.Wlan.net_info.IpConfigType == NET_IP_CONFIG_TYPE_DYNAMIC ||
+           prof_info->ProfileInfo.Wlan.net_info.IpConfigType == NET_IP_CONFIG_TYPE_AUTO_IP) {
+               dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &prop_method);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &dhcp_method);
+               dbus_message_iter_close_container(&dict, &entry);
+               NETWORK_LOG(NETWORK_ASSERT,  "DBus Message 2/2 : %s %s\n", prop_method, dhcp_method);
+       } else if (prof_info->ProfileInfo.Wlan.net_info.IpConfigType == NET_IP_CONFIG_TYPE_OFF) {
+               dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &prop_method);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &off_method);
+               dbus_message_iter_close_container(&dict, &entry);
+               NETWORK_LOG(NETWORK_ASSERT,  "DBus Message 2/2 : %s %s\n", prop_method, off_method);
+       } else if (prof_info->ProfileInfo.Wlan.net_info.IpConfigType == NET_IP_CONFIG_TYPE_STATIC) {
+               dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &prop_method);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &manual_method);
+               dbus_message_iter_close_container(&dict, &entry);
+
+               if (strlen(ipaddress) >= NETPM_IPV4_STR_LEN_MIN) {
+                       dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+                       dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &prop_address);
+                       dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &ipaddress);
+                       dbus_message_iter_close_container(&dict, &entry);
+               }
+
+               if (strlen(netmask) >= NETPM_IPV4_STR_LEN_MIN) {
+                       dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+                       dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &prop_netmask);
+                       dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &netmask);
+                       dbus_message_iter_close_container(&dict, &entry);
+               }
+
+               if (strlen(gateway) >= NETPM_IPV4_STR_LEN_MIN) {
+                       dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+                       dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &prop_gateway);
+                       dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &gateway);
+                       dbus_message_iter_close_container(&dict, &entry);
+               }
+               NETWORK_LOG(NETWORK_ASSERT,  "DBus Message 2/2 : %s %s %s %s %s %s %s %s\n",
+                               prop_method, manual_method, prop_address, ipaddress,
+                               prop_netmask, netmask, prop_gateway, gateway);
+       } else {
+               NETWORK_LOG(NETWORK_ASSERT,  "Error!!! Invalid argument\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       dbus_message_iter_close_container(&variant, &dict);
+       dbus_message_iter_close_container(&itr, &variant);
+
+       dbus_error_init(&error);
+
+       reply = dbus_connection_send_with_reply_and_block(conn,
+                       msg, DBUS_REPLY_TIMEOUT,                        
+                       &error);
+
+       if (reply == NULL) {
+               if (dbus_error_is_set (&error) == TRUE) {
+                       NETWORK_LOG(NETWORK_ERROR,
+                               "Error!!! dbus_connection_send_with_reply_and_block() failed, Error[%s: %s]\n",
+                               error.name,
+                               error.message);
+                       Error = __net_error_string_to_enum(error.name);
+                       dbus_error_free(&error); 
+                       dbus_message_unref(msg);
+                       __NETWORK_FUNC_EXIT__;
+                       return Error;
+               }
+
+               dbus_message_unref(msg);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       dbus_message_unref(reply);
+       dbus_message_unref(msg);
+
+       NETWORK_LOG(NETWORK_HIGH, "Successfully configured IPv4.Configuration\n");
+       
+       dbus_connection_unref(conn);
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+int _net_dbus_set_profile_dns(net_profile_info_t* prof_info, char* profile_name)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusError error; 
+
+       const char *prop_nameserver_configuration = "Nameservers.Configuration";
+       char dns_buffer[NET_DNS_ADDR_MAX][NETPM_IPV4_STR_LEN_MAX+1];
+       char *dns_address[NET_DNS_ADDR_MAX];
+
+       DBusMessage *msg = NULL;
+       DBusMessage *reply = NULL;
+       DBusMessageIter itr;
+       DBusConnection* conn = NULL;
+       int i = 0;
+
+       if ((prof_info == NULL) || (profile_name == NULL) || (strlen(profile_name) == 0) ||
+           (prof_info->ProfileInfo.Wlan.net_info.DnsCount > NET_DNS_ADDR_MAX)) {
+               NETWORK_LOG(NETWORK_ASSERT,  "Error!!! Invalid parameter\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       for (i = 0;i < prof_info->ProfileInfo.Wlan.net_info.DnsCount;i++) {
+               dns_buffer[i][0] = '\0';
+               dns_address[i] = NULL;
+               
+               snprintf(dns_buffer[i],  NETPM_IPV4_STR_LEN_MAX + 1, "%s",
+                               inet_ntoa(prof_info->ProfileInfo.Wlan.net_info.DnsAddr[i].Data.Ipv4));
+               if (strlen(dns_buffer[i]) >= NETPM_IPV4_STR_LEN_MIN)
+                       dns_address[i] = dns_buffer[i];
+       }
+       
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); 
+       if (conn == NULL) {
+               NETWORK_LOG(NETWORK_ERROR,  "Error!!! Can't get on system bus\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       if (prof_info->ProfileInfo.Wlan.net_info.IpConfigType == NET_IP_CONFIG_TYPE_STATIC) {
+               msg = dbus_message_new_method_call(CONNMAN_SERVICE,
+                               profile_name, CONNMAN_SERVICE_INTERFACE, "SetProperty");
+
+               if (msg == NULL) {
+                       NETWORK_LOG(NETWORK_ERROR,
+                                       "Error!!! dbus_message_new_method_call() failed\n");
+                       __NETWORK_FUNC_EXIT__;
+                       return NET_ERR_UNKNOWN;
+               }
+
+               dbus_message_iter_init_append(msg, &itr);
+               dbus_message_iter_append_basic(&itr, DBUS_TYPE_STRING, &prop_nameserver_configuration);
+
+               DBusMessageIter value, array;
+               dbus_message_iter_open_container(&itr, DBUS_TYPE_VARIANT,
+                               DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING, &value);
+
+               dbus_message_iter_open_container(&value, DBUS_TYPE_ARRAY,
+                               DBUS_TYPE_STRING_AS_STRING, &array);
+
+               for (i = 0;i < prof_info->ProfileInfo.Wlan.net_info.DnsCount;i++) {
+                       dbus_message_iter_append_basic(&array, DBUS_TYPE_STRING, &(dns_address[i]));
+               }
+
+               dbus_message_iter_close_container(&value, &array);
+               dbus_message_iter_close_container(&itr, &value);
+
+               dbus_error_init(&error);
+
+               reply = dbus_connection_send_with_reply_and_block(conn,
+                               msg, DBUS_REPLY_TIMEOUT,
+                               &error);
+
+               if (reply == NULL) {
+                       if (dbus_error_is_set (&error) == TRUE) {
+                               NETWORK_LOG(NETWORK_ERROR,
+                                               "Error!!! dbus_connection_send_with_reply_and_block() failed, Error[%s: %s]\n",
+                                               error.name,
+                                               error.message);
+                               Error = __net_error_string_to_enum(error.name);
+                               dbus_error_free(&error);
+                               dbus_message_unref(msg);
+                               __NETWORK_FUNC_EXIT__;
+                               return Error;
+                       }
+                       dbus_message_unref(msg);
+                       __NETWORK_FUNC_EXIT__;
+                       return NET_ERR_UNKNOWN;
+               }
+               dbus_message_unref(reply);
+               dbus_message_unref(msg);
+               NETWORK_LOG(NETWORK_HIGH, "Successfully configured Nameservers.Configuration\n");
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+int _net_dbus_set_proxy(net_profile_info_t* prof_info, char* profile_name)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusError error;
+       
+       const char *direct_method = "direct"; /* not method[] as gcc screws it with dbus */
+       const char *auto_method = "auto"; /* not method[] as gcc screws it with dbus */
+       const char *manual_method = "manual"; /* not method[] as gcc screws it with dbus */
+
+       const char *prop_proxy_configuration = "Proxy.Configuration";
+       const char *prop_method = "Method";
+       const char *prop_url = "URL";
+       const char *prop_servers = "Servers";
+
+       char proxy_buffer[NET_PROXY_LEN_MAX+1] = "";
+       char *proxy_address = proxy_buffer;
+
+       DBusMessage *msg = NULL;
+       DBusMessage *reply = NULL;
+       DBusMessageIter itr, variant, dict, entry, sub_variant, str_array;
+       DBusConnection* conn = NULL;
+
+       snprintf(proxy_buffer, NET_PROXY_LEN_MAX + 1, "%s", prof_info->ProfileInfo.Wlan.net_info.ProxyAddr);
+
+       NETWORK_LOG(NETWORK_ASSERT, "Method : %d, proxy address : %s\n",
+                       prof_info->ProfileInfo.Wlan.net_info.ProxyMethod, proxy_address);
+
+       if ((prof_info == NULL) || (profile_name == NULL) || (strlen(profile_name) == 0)) {
+               NETWORK_LOG(NETWORK_ASSERT,  "Error!!! Invalid argument\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); 
+       if (conn == NULL) {
+               NETWORK_LOG(NETWORK_ERROR,  "Error!!! Can't get on system bus\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       /** Send proxy method, url, servers configuration */
+       msg = dbus_message_new_method_call(CONNMAN_SERVICE, profile_name,
+                       CONNMAN_SERVICE_INTERFACE, "SetProperty");
+       if (msg == NULL) {
+               NETWORK_LOG(NETWORK_ERROR,  "Error!!! dbus_message_new_method_call() failed\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       dbus_message_iter_init_append(msg, &itr);
+       dbus_message_iter_append_basic(&itr, DBUS_TYPE_STRING, &prop_proxy_configuration);
+
+       dbus_message_iter_open_container
+               (&itr, DBUS_TYPE_VARIANT,
+                (DBUS_TYPE_ARRAY_AS_STRING
+                 DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+                 DBUS_TYPE_STRING_AS_STRING
+                 DBUS_TYPE_VARIANT_AS_STRING
+                 DBUS_DICT_ENTRY_END_CHAR_AS_STRING),
+                &variant);
+       dbus_message_iter_open_container
+               (&variant, DBUS_TYPE_ARRAY,
+                (DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+                 DBUS_TYPE_STRING_AS_STRING
+                 DBUS_TYPE_VARIANT_AS_STRING
+                 DBUS_DICT_ENTRY_END_CHAR_AS_STRING),
+                &dict);
+
+       dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+       dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &prop_method);
+       
+       dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
+                       DBUS_TYPE_STRING_AS_STRING, &sub_variant);
+
+       switch (prof_info->ProfileInfo.Wlan.net_info.ProxyMethod) {
+       case NET_PROXY_TYPE_AUTO:
+               dbus_message_iter_append_basic(&sub_variant, DBUS_TYPE_STRING, &auto_method);
+               break;
+       case NET_PROXY_TYPE_MANUAL:
+               dbus_message_iter_append_basic(&sub_variant, DBUS_TYPE_STRING, &manual_method);
+               break;
+       default:
+               dbus_message_iter_append_basic(&sub_variant, DBUS_TYPE_STRING, &direct_method);
+               break;
+       }
+
+       dbus_message_iter_close_container(&entry, &sub_variant);
+       dbus_message_iter_close_container(&dict, &entry);       
+
+       if (prof_info->ProfileInfo.Wlan.net_info.ProxyMethod == NET_PROXY_TYPE_AUTO) {
+               dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &prop_url);
+               
+               dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
+                               DBUS_TYPE_STRING_AS_STRING, &sub_variant);
+               dbus_message_iter_append_basic(&sub_variant, DBUS_TYPE_STRING, &proxy_address);
+               
+               dbus_message_iter_close_container(&entry, &sub_variant);
+               dbus_message_iter_close_container(&dict, &entry);               
+       }
+
+       if (prof_info->ProfileInfo.Wlan.net_info.ProxyMethod == NET_PROXY_TYPE_MANUAL) {
+               dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &prop_servers);                
+               
+               dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT,
+                               DBUS_TYPE_ARRAY_AS_STRING DBUS_TYPE_STRING_AS_STRING, &sub_variant);
+               
+               dbus_message_iter_open_container(&sub_variant, DBUS_TYPE_ARRAY,
+                               DBUS_TYPE_STRING_AS_STRING, &str_array);                
+               dbus_message_iter_append_basic(&str_array, DBUS_TYPE_STRING, &proxy_address);
+
+               dbus_message_iter_close_container(&sub_variant, &str_array);
+               dbus_message_iter_close_container(&entry, &sub_variant);
+               dbus_message_iter_close_container(&dict, &entry);
+       }
+
+       dbus_message_iter_close_container(&variant, &dict);
+       dbus_message_iter_close_container(&itr, &variant);
+
+       dbus_error_init(&error);
+
+       reply = dbus_connection_send_with_reply_and_block(conn,
+                       msg, DBUS_REPLY_TIMEOUT,                        
+                       &error);
+
+       if (reply == NULL) {
+               if (dbus_error_is_set(&error) == TRUE) {
+                       NETWORK_LOG( NETWORK_ERROR,
+                                       "Error!!! dbus_connection_send_with_reply_and_block() failed, Error[%s: %s]\n",
+                                       error.name,
+                                       error.message);
+                       Error = __net_error_string_to_enum(error.name);
+                       dbus_error_free(&error); 
+                       dbus_message_unref(msg);
+                       __NETWORK_FUNC_EXIT__;
+                       return Error;
+               }
+
+               dbus_message_unref(msg);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       dbus_message_unref(reply);
+       dbus_message_unref(msg);
+
+       NETWORK_LOG( NETWORK_HIGH, "Successfully configured Proxy.Configuration\n");
+       
+       dbus_connection_unref(conn);
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+
+int _net_dbus_add_pdp_profile(net_profile_info_t *prof_info)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusError error;
+       const char *service_type = "svc_ctg_id";
+       const char *home_url = "home_url";
+       const char *proxy_addr = "proxy_addr";
+       const char *auth_pwd = "auth_pwd";
+       const char *auth_type = "auth_type";
+       const char *auth_id = "auth_id";
+       const char *apn = "apn";
+
+       char buff_svc_type[10] = "";
+       char buff_auth_type[10] = "";
+       char *temp_ptr = NULL;
+
+       DBusMessage *msg = NULL;
+       DBusMessage *reply = NULL;
+       DBusMessageIter iter, dict, entry;
+       DBusConnection* conn = NULL;
+
+       if (prof_info == NULL) {
+               NETWORK_LOG(NETWORK_ASSERT, "Error!!! Invalid argument\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+       if (conn == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Can't get on system bus\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       /** Create message */
+       msg = dbus_message_new_method_call(TELEPHONY_SERVCE,
+                       TELEPHONY_MASTER_PATH, TELEPHONY_MASTER_INTERFACE, "AddProfile");
+       if (msg == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! dbus_message_new_method_call() failed\n");
+               dbus_connection_unref(conn);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       NETWORK_LOG(NETWORK_ASSERT, "DBus Message 1/2 : %s %s %s %s\n", TELEPHONY_SERVCE,
+                       TELEPHONY_MASTER_PATH, TELEPHONY_MASTER_INTERFACE, ".AddProfile");
+
+       dbus_message_iter_init_append(msg, &iter);
+
+       dbus_message_iter_open_container
+               (&iter, DBUS_TYPE_ARRAY,
+                (DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+                 DBUS_TYPE_STRING_AS_STRING
+                 DBUS_TYPE_STRING_AS_STRING
+                 DBUS_DICT_ENTRY_END_CHAR_AS_STRING),
+                &dict);
+
+       if (prof_info->ProfileInfo.Pdp.ServiceType > NET_SERVICE_UNKNOWN &&
+           prof_info->ProfileInfo.Pdp.ServiceType <= NET_SERVICE_PREPAID_MMS) {
+               snprintf(buff_svc_type, 10, "%d", prof_info->ProfileInfo.Pdp.ServiceType);
+               temp_ptr = buff_svc_type;
+
+               dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &service_type);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &temp_ptr);
+               dbus_message_iter_close_container(&dict, &entry);
+
+               NETWORK_LOG(NETWORK_ASSERT, "DBus Message 2/2 : %s : %s\n",
+                               service_type, temp_ptr);
+       }
+
+       if (strlen(prof_info->ProfileInfo.Pdp.HomeURL) > 0) {
+               temp_ptr = prof_info->ProfileInfo.Pdp.HomeURL;
+
+               dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &home_url);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &temp_ptr);
+               dbus_message_iter_close_container(&dict, &entry);
+
+               NETWORK_LOG(NETWORK_ASSERT, "DBus Message 2/2 : %s : %s\n",
+                               home_url, temp_ptr);
+       }
+
+       if (strlen(prof_info->ProfileInfo.Pdp.net_info.ProxyAddr) > 0) {
+               temp_ptr = prof_info->ProfileInfo.Pdp.net_info.ProxyAddr;
+
+               dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &proxy_addr);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &temp_ptr);
+               dbus_message_iter_close_container(&dict, &entry);
+
+               NETWORK_LOG(NETWORK_ASSERT, "DBus Message 2/2 : %s : %s\n",
+                               proxy_addr, temp_ptr);
+       }
+
+       if (strlen(prof_info->ProfileInfo.Pdp.AuthInfo.Password) > 0) {
+               temp_ptr = prof_info->ProfileInfo.Pdp.AuthInfo.Password;
+
+               dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &auth_pwd);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &temp_ptr);
+               dbus_message_iter_close_container(&dict, &entry);
+
+               NETWORK_LOG(NETWORK_ASSERT, "DBus Message 2/2 : %s : %s\n",
+                               auth_pwd, temp_ptr);
+       }
+
+       if (strlen(prof_info->ProfileInfo.Pdp.AuthInfo.UserName) > 0) {
+               temp_ptr = prof_info->ProfileInfo.Pdp.AuthInfo.UserName;
+
+               dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &auth_id);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &temp_ptr);
+               dbus_message_iter_close_container(&dict, &entry);
+
+               NETWORK_LOG(NETWORK_ASSERT, "DBus Message 2/2 : %s : %s\n",
+                               auth_id, temp_ptr);
+       }
+
+       if (prof_info->ProfileInfo.Pdp.AuthInfo.AuthType >= NET_PDP_AUTH_NONE &&
+           prof_info->ProfileInfo.Pdp.AuthInfo.AuthType <= NET_PDP_AUTH_CHAP) {
+               snprintf(buff_auth_type, 10, "%d", prof_info->ProfileInfo.Pdp.AuthInfo.AuthType);
+               temp_ptr = buff_auth_type;
+
+               dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &auth_type);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &temp_ptr);
+               dbus_message_iter_close_container(&dict, &entry);
+
+               NETWORK_LOG(NETWORK_ASSERT, "DBus Message 2/2 : %s : %s\n",
+                               auth_type, temp_ptr);
+       }
+
+       if (strlen(prof_info->ProfileInfo.Pdp.Apn) > 0) {
+               temp_ptr = prof_info->ProfileInfo.Pdp.Apn;
+
+               dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &apn);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &temp_ptr);
+               dbus_message_iter_close_container(&dict, &entry);
+
+               NETWORK_LOG(NETWORK_ASSERT, "DBus Message 2/2 : %s : %s\n",
+                               apn, temp_ptr);
+       }
+
+       dbus_message_iter_close_container(&iter, &dict);
+       dbus_error_init(&error);
+
+       /** Send message */
+       reply = dbus_connection_send_with_reply_and_block(conn,
+                       msg, DBUS_REPLY_TIMEOUT,
+                       &error);
+
+       /** Check Error */
+       if (reply == NULL) {
+               if (dbus_error_is_set (&error) == TRUE) {
+                       NETWORK_LOG(NETWORK_ERROR,
+                               "Error!!! dbus_connection_send_with_reply_and_block() failed, Error[%s: %s]\n",
+                               error.name,
+                               error.message);
+                       Error = __net_error_string_to_enum(error.name);
+                       dbus_error_free(&error);
+                       dbus_message_unref(msg);
+                       __NETWORK_FUNC_EXIT__;
+                       return Error;
+               }
+
+               dbus_message_unref(msg);
+               dbus_connection_unref(conn);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       } else
+               NETWORK_LOG(NETWORK_HIGH, "Successfully requested : Add PDP profile\n");
+
+       /** Check Reply */
+       DBusMessageIter iter2;
+       int add_result = 0;
+
+       dbus_message_iter_init(reply, &iter2);
+       if (dbus_message_iter_get_arg_type(&iter2) == DBUS_TYPE_BOOLEAN) {
+               dbus_message_iter_get_basic(&iter2, &add_result);
+               NETWORK_LOG(NETWORK_HIGH, "Profile add result : %d\n", add_result);
+       }
+
+       if (add_result)
+               Error = NET_ERR_NONE;
+       else
+               Error = NET_ERR_UNKNOWN;
+
+       dbus_message_unref(reply);
+       dbus_message_unref(msg);
+       dbus_connection_unref(conn);
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+
+int _net_dbus_modify_pdp_profile(net_profile_info_t *prof_info, const char *profile_name)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+
+       DBusError error;
+       const char *service_type = "svc_ctg_id";
+       const char *home_url = "home_url";
+       const char *proxy_addr = "proxy_addr";
+       const char *auth_pwd = "auth_pwd";
+       const char *auth_type = "auth_type";
+       const char *auth_id = "auth_id";
+       const char *apn = "apn";
+
+       char buff_svc_type[10] = "";
+       char buff_auth_type[10] = "";
+       char *temp_ptr = NULL;
+
+       DBusMessage *msg = NULL;
+       DBusMessage *reply = NULL;
+       DBusMessageIter iter, dict, entry;
+       DBusConnection* conn = NULL;
+
+       if ((prof_info == NULL) || (profile_name == NULL)) {
+               NETWORK_LOG(NETWORK_ASSERT, "Error!!! Invalid argument\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+       if (conn == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Can't get on system bus\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       /** Create message */
+       msg = dbus_message_new_method_call(TELEPHONY_SERVCE,
+                       profile_name, TELEPHONY_PROFILE_INTERFACE, "ModifyProfile");
+       if (msg == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! dbus_message_new_method_call() failed\n");
+               dbus_connection_unref(conn);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       NETWORK_LOG(NETWORK_ASSERT, "DBus Message 1/2 : %s %s %s %s\n", TELEPHONY_SERVCE,
+                       profile_name, TELEPHONY_PROFILE_INTERFACE, ".ModifyProfile");
+
+       dbus_message_iter_init_append(msg, &iter);
+
+       dbus_message_iter_open_container
+               (&iter, DBUS_TYPE_ARRAY,
+                (DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+                 DBUS_TYPE_STRING_AS_STRING
+                 DBUS_TYPE_STRING_AS_STRING
+                 DBUS_DICT_ENTRY_END_CHAR_AS_STRING),
+                &dict);
+
+       if (prof_info->ProfileInfo.Pdp.ServiceType > NET_SERVICE_UNKNOWN &&
+           prof_info->ProfileInfo.Pdp.ServiceType <= NET_SERVICE_PREPAID_MMS) {
+               snprintf(buff_svc_type, 10, "%d", prof_info->ProfileInfo.Pdp.ServiceType);
+               temp_ptr = buff_svc_type;
+
+               dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &service_type);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &temp_ptr);
+               dbus_message_iter_close_container(&dict, &entry);
+
+               NETWORK_LOG(NETWORK_ASSERT, "DBus Message 2/2 : %s : %s\n",
+                               service_type, temp_ptr);
+       }
+
+       if (strlen(prof_info->ProfileInfo.Pdp.HomeURL) > 0) {
+               temp_ptr = prof_info->ProfileInfo.Pdp.HomeURL;
+
+               dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &home_url);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &temp_ptr);
+               dbus_message_iter_close_container(&dict, &entry);
+
+               NETWORK_LOG(NETWORK_ASSERT, "DBus Message 2/2 : %s : %s\n",
+                               home_url, temp_ptr);
+       }
+
+       if (strlen(prof_info->ProfileInfo.Pdp.net_info.ProxyAddr) > 0) {
+               temp_ptr = prof_info->ProfileInfo.Pdp.net_info.ProxyAddr;
+
+               dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &proxy_addr);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &temp_ptr);
+               dbus_message_iter_close_container(&dict, &entry);
+
+               NETWORK_LOG(NETWORK_ASSERT, "DBus Message 2/2 : %s : %s\n",
+                               proxy_addr, temp_ptr);
+       }
+
+       if (strlen(prof_info->ProfileInfo.Pdp.AuthInfo.Password) > 0) {
+               temp_ptr = prof_info->ProfileInfo.Pdp.AuthInfo.Password;
+
+               dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &auth_pwd);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &temp_ptr);
+               dbus_message_iter_close_container(&dict, &entry);
+
+               NETWORK_LOG(NETWORK_ASSERT, "DBus Message 2/2 : %s : %s\n",
+                               auth_pwd, temp_ptr);
+       }
+
+       if (strlen(prof_info->ProfileInfo.Pdp.AuthInfo.UserName) > 0) {
+               temp_ptr = prof_info->ProfileInfo.Pdp.AuthInfo.UserName;
+
+               dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &auth_id);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &temp_ptr);
+               dbus_message_iter_close_container(&dict, &entry);
+
+               NETWORK_LOG(NETWORK_ASSERT, "DBus Message 2/2 : %s : %s\n",
+                               auth_id, temp_ptr);
+       }
+
+       if (prof_info->ProfileInfo.Pdp.AuthInfo.AuthType >= NET_PDP_AUTH_NONE &&
+           prof_info->ProfileInfo.Pdp.AuthInfo.AuthType <= NET_PDP_AUTH_CHAP) {
+               snprintf(buff_auth_type, 10, "%d", prof_info->ProfileInfo.Pdp.AuthInfo.AuthType);
+               temp_ptr = buff_auth_type;
+
+               dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &auth_type);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &temp_ptr);
+               dbus_message_iter_close_container(&dict, &entry);
+
+               NETWORK_LOG(NETWORK_ASSERT, "DBus Message 2/2 : %s : %s\n",
+                               auth_type, temp_ptr);
+       }
+
+       if (strlen(prof_info->ProfileInfo.Pdp.Apn) > 0) {
+               temp_ptr = prof_info->ProfileInfo.Pdp.Apn;
+
+               dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, NULL, &entry);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &apn);
+               dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &temp_ptr);
+               dbus_message_iter_close_container(&dict, &entry);
+
+               NETWORK_LOG(NETWORK_ASSERT, "DBus Message 2/2 : %s : %s\n",
+                               apn, temp_ptr);
+       }
+
+       dbus_message_iter_close_container(&iter, &dict);
+       dbus_error_init(&error);
+
+       /** Send message */
+       reply = dbus_connection_send_with_reply_and_block(conn,
+                       msg, DBUS_REPLY_TIMEOUT,
+                       &error);
+
+       /** Check Error */
+       if (reply == NULL) {
+               if (dbus_error_is_set (&error) == TRUE) {
+                       NETWORK_LOG(NETWORK_ERROR,
+                               "Error!!! dbus_connection_send_with_reply_and_block() failed, Error[%s: %s]\n",
+                               error.name,
+                               error.message);
+                       Error = __net_error_string_to_enum(error.name);
+                       dbus_error_free(&error);
+                       dbus_message_unref(msg);
+                       __NETWORK_FUNC_EXIT__;
+                       return Error;
+               }
+
+               dbus_message_unref(msg);
+               dbus_connection_unref(conn);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       } else
+               NETWORK_LOG(NETWORK_HIGH, "Successfully requested : Modify PDP profile\n");
+
+       /** Check Reply */
+       DBusMessageIter iter2;
+       int add_result = 0;
+
+       dbus_message_iter_init(reply, &iter2);
+       if (dbus_message_iter_get_arg_type(&iter2) == DBUS_TYPE_BOOLEAN) {
+               dbus_message_iter_get_basic(&iter2, &add_result);
+               NETWORK_LOG(NETWORK_HIGH, "Profile modify result : %d\n", add_result);
+       }
+
+       if (add_result)
+               Error = NET_ERR_NONE;
+       else
+               Error = NET_ERR_UNKNOWN;
+
+       dbus_message_unref(reply);
+       dbus_message_unref(msg);
+       dbus_connection_unref(conn);
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+
+int _net_dbus_load_wifi_driver(void)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusConnection* conn = NULL;
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+
+       if (conn == NULL) {
+               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Can't get on system bus\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       NETWORK_LOG(NETWORK_HIGH,  "Requesting [%s %s]\n",
+                       NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE ".LoadDriver");
+
+       Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE, conn, NETCONFIG_WIFI_PATH,
+                       NETCONFIG_WIFI_INTERFACE, "LoadDriver", __net_wifi_power_reply);
+
+       dbus_connection_unref(conn);
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+int _net_dbus_remove_wifi_driver(void)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusConnection* conn = NULL;
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+
+       if (conn == NULL) {
+               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Can't get on system bus\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       NETWORK_LOG(NETWORK_HIGH,  "Requesting [%s %s]\n",
+                       NETCONFIG_WIFI_PATH, NETCONFIG_WIFI_INTERFACE ".RemoveDriver");
+
+       Error = _net_invoke_dbus_method_nonblock(NETCONFIG_SERVICE, conn, NETCONFIG_WIFI_PATH,
+                       NETCONFIG_WIFI_INTERFACE, "RemoveDriver", __net_wifi_power_reply);
+
+       dbus_connection_unref(conn);
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+dbus_bool_t _net_dbus_is_pending_call_used(void)
+{
+       return network_dbus_pending_call_data.is_used;
+}
+
+void _net_dbus_set_pending_call_used(dbus_bool_t used)
+{
+       network_dbus_pending_call_data.is_used = used;
+}
+
+DBusPendingCall *_net_dbus_get_pending_call(void)
+{
+       return network_dbus_pending_call_data.pcall;
+}
+
+void _net_dbus_set_pending_call(DBusPendingCall *call)
+{
+       network_dbus_pending_call_data.pcall = call;
+}
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
diff --git a/src/network-internal.c b/src/network-internal.c
new file mode 100644 (file)
index 0000000..c9bc0b2
--- /dev/null
@@ -0,0 +1,689 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+/*****************************************************************************
+ *     Standard headers
+ *****************************************************************************/
+#include <stdio.h> 
+#include <errno.h> 
+#include <stdlib.h> 
+#include <string.h> 
+#include <glib.h>
+
+#include <dbus/dbus.h> 
+
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <linux/if_ether.h>
+
+/*****************************************************************************
+ *     Platform headers
+ *****************************************************************************/
+
+#include "network-internal.h"
+#include "network-dbus-request.h"
+
+/*****************************************************************************
+ *     Macros and Typedefs
+ *****************************************************************************/
+
+#define EAP_CONFIG_KEY_TYPE                    "Type"
+#define EAP_CONFIG_KEY_NAME                    "Name"
+#define EAP_CONFIG_KEY_SSID                    "SSID"
+#define EAP_CONFIG_KEY_EAP                             "EAP"
+#define EAP_CONFIG_KEY_IDENTITY                "Identity"
+#define EAP_CONFIG_KEY_PASSPHRASE      "Passphrase"
+
+#define EAP_CONFIG_KEY_CA_CERT         "CACertFile"
+#define EAP_CONFIG_KEY_CL_CERT         "ClientCertFile"
+#define EAP_CONFIG_KEY_PRV_KEY         "PrivateKeyFile"
+#define EAP_CONFIG_KEY_PRV_KEY_PASS    "PrivateKeyPassphrase"
+#define EAP_CONFIG_KEY_PRV_KEY_PASS_TYPE  "PrivateKeyPassphraseType"
+#define EAP_CONFIG_KEY_PHASE2                  "Phase2"
+
+#define EAP_TYPE_LEN_MAX                       8               //tls / ttls / peap
+#define EAP_AUTH_TYPE_LEN_MAX          16
+#define EAP_TYPE_STR_TLS       "tls"
+#define EAP_TYPE_STR_TTLS      "ttls"
+#define EAP_TYPE_STR_PEAP      "peap"
+
+#define CONNMAN_STORAGE_DIR            "/var/lib/connman"
+
+/*****************************************************************************
+ *     Local Functions Declaration
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ *     Global Functions
+ *****************************************************************************/
+
+/*****************************************************************************
+ *     Extern Global Variables
+ *****************************************************************************/
+extern network_info_t NetworkInfo;
+
+
+/*****************************************************************************
+ *     Global Variables
+ *****************************************************************************/
+
+/** set all request to FALSE (0) */
+network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX] = {{0, }, };
+
+struct {
+       pthread_mutex_t callback_mutex;
+       pthread_mutex_t wifi_state_mutex;
+} networkinfo_mutex;
+
+/*****************************************************************************
+ *     Local Functions Definition
+ *****************************************************************************/
+
+gboolean __convert_eap_type_to_string(gchar eap_type, char * eap_str)
+{
+       switch(eap_type)
+       {
+               case WLAN_SEC_EAP_TYPE_PEAP:
+                       memcpy(eap_str, EAP_TYPE_STR_PEAP, EAP_TYPE_LEN_MAX);
+                       return TRUE;
+               case WLAN_SEC_EAP_TYPE_TLS:
+                       memcpy(eap_str, EAP_TYPE_STR_TLS, EAP_TYPE_LEN_MAX);
+                       return TRUE;
+               case WLAN_SEC_EAP_TYPE_TTLS:
+                       memcpy(eap_str, EAP_TYPE_STR_TTLS, EAP_TYPE_LEN_MAX);
+                       return TRUE;
+               case WLAN_SEC_EAP_TYPE_SIM:             //Not supported yet
+               case WLAN_SEC_EAP_TYPE_AKA:             //Not supported yet
+               default:
+                       return FALSE;
+       }
+
+}
+
+void __convert_eap_auth_to_string(gchar eap_auth, char * auth_str)
+{
+       switch(eap_auth)
+       {
+               case WLAN_SEC_EAP_AUTH_NONE:
+                       return ;
+               case WLAN_SEC_EAP_AUTH_PAP:
+                       memcpy(auth_str, "PAP", strlen("PAP")+1);
+                       break;
+               case WLAN_SEC_EAP_AUTH_MSCHAP:
+                       memcpy(auth_str, "MSCHAP", strlen("MSCHAP")+1);
+                       break;
+               case WLAN_SEC_EAP_AUTH_MSCHAPV2:
+                       memcpy(auth_str, "MSCHAPV2", strlen("MSCHAPV2")+1);
+                       break;
+               case WLAN_SEC_EAP_AUTH_GTC:
+                       memcpy(auth_str, "GTC", strlen("GTC")+1);
+                       break;
+               case WLAN_SEC_EAP_AUTH_MD5:
+                       memcpy(auth_str, "MD5", strlen("MD5")+1);
+                       break;
+               default:
+                       return ;
+
+       }
+}
+
+static void __update_config(GKeyFile * keyfile, char * group,
+                                                       const wlan_eap_info_t * eap_info, const char * essid,
+                                                       char * eap_type, char * auth_type)
+{
+       g_key_file_set_string(keyfile, group, EAP_CONFIG_KEY_TYPE, "wifi");
+
+       NETWORK_LOG(NETWORK_HIGH, "------------eap info------------------");
+       NETWORK_LOG(NETWORK_HIGH, "-essid : %s", essid);
+       NETWORK_LOG(NETWORK_HIGH, "-eap type : %s", eap_type);
+       NETWORK_LOG(NETWORK_HIGH, "-phase2 authentication type : %s", auth_type);
+       NETWORK_LOG(NETWORK_HIGH, "-username : %s", eap_info->username);
+       NETWORK_LOG(NETWORK_HIGH, "-password : %s", eap_info->password);
+       NETWORK_LOG(NETWORK_HIGH, "-ca certi filename : %s", eap_info->ca_cert_filename);
+       NETWORK_LOG(NETWORK_HIGH, "-client certi filename : %s", eap_info->client_cert_filename);
+       NETWORK_LOG(NETWORK_HIGH, "-private key filename : %s", eap_info->private_key_filename);
+       NETWORK_LOG(NETWORK_HIGH, "-private key password : %s", eap_info->private_key_passwd);
+       NETWORK_LOG(NETWORK_HIGH, "--------------------------------------");
+
+       if(essid != NULL)
+               g_key_file_set_string(keyfile, group, EAP_CONFIG_KEY_NAME, essid);
+
+       if(eap_type != NULL)
+               g_key_file_set_string(keyfile, group, EAP_CONFIG_KEY_EAP, eap_type);
+
+       if(auth_type != NULL)
+               g_key_file_set_string(keyfile, group, EAP_CONFIG_KEY_PHASE2, auth_type);
+
+       if((eap_info->username != NULL) && (strlen(eap_info->username) > 0))
+               g_key_file_set_string(keyfile, group, EAP_CONFIG_KEY_IDENTITY, eap_info->username);
+
+       if((eap_info->password != NULL) && (strlen(eap_info->password) > 0))
+               g_key_file_set_string(keyfile, group, EAP_CONFIG_KEY_PASSPHRASE, eap_info->password);
+
+       if((eap_info->ca_cert_filename != NULL) && (strlen(eap_info->ca_cert_filename) > 0))
+               g_key_file_set_string(keyfile, group, EAP_CONFIG_KEY_CA_CERT, eap_info->ca_cert_filename);
+
+       if((eap_info->client_cert_filename != NULL) && (strlen(eap_info->client_cert_filename) > 0))
+               g_key_file_set_string(keyfile, group, EAP_CONFIG_KEY_CL_CERT, eap_info->client_cert_filename);
+
+       if((eap_info->private_key_filename != NULL) && (strlen(eap_info->private_key_filename) > 0))
+               g_key_file_set_string(keyfile, group, EAP_CONFIG_KEY_PRV_KEY, eap_info->private_key_filename);
+
+       if((eap_info->private_key_passwd != NULL) && (strlen(eap_info->private_key_passwd) > 0))
+               g_key_file_set_string(keyfile, group, EAP_CONFIG_KEY_PRV_KEY_PASS, eap_info->private_key_passwd);
+}
+
+static net_err_t __net_add_eap_config(const wlan_eap_info_t * eap_info, const char * essid)
+{
+       GKeyFile * keyfile;
+       char group[16];
+       char * eap_str;
+       char * auth_str;
+       gchar *data = NULL;
+       gsize length = 0;
+       net_err_t Error = NET_ERR_NONE;
+
+       __NETWORK_FUNC_ENTER__;
+
+       if((eap_info->eap_type < WLAN_SEC_EAP_TYPE_PEAP) || (eap_info->eap_type > WLAN_SEC_EAP_TYPE_AKA)) {
+               NETWORK_LOG(NETWORK_HIGH, "Invalid EAP type (%d)\n", eap_info->eap_type);
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       eap_str = (char*)calloc(EAP_TYPE_LEN_MAX, sizeof(char));
+       if(eap_str == NULL)
+               return NET_ERR_UNKNOWN;
+
+       if(__convert_eap_type_to_string(eap_info->eap_type, eap_str) == FALSE) {
+               NETWORK_LOG(NETWORK_HIGH, "Invalid EAP type (%d)\n", eap_info->eap_type);
+               NET_MEMFREE(eap_str);
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       auth_str = (char*)calloc(EAP_AUTH_TYPE_LEN_MAX, sizeof(char));
+       if(auth_str == NULL) {
+               NET_MEMFREE(eap_str);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       __convert_eap_auth_to_string(eap_info->eap_auth, auth_str);
+
+       sprintf(group, "service_%s", eap_str);
+       NETWORK_LOG(NETWORK_HIGH, "group (%s)\n", group);
+
+       keyfile = g_key_file_new();
+
+       __update_config(keyfile, group, eap_info, essid, eap_str, auth_str);
+
+       data = g_key_file_to_data(keyfile, &length, NULL);
+
+       NETWORK_LOG(NETWORK_ERROR, "-----length of data : %d\n", length);
+       Error = _net_dbus_provision_service(data, length+1);
+       if(Error != NET_ERR_NONE)
+               NETWORK_LOG(NETWORK_ERROR, "Failed to update EAP info in ConnMan\n");
+
+       NET_MEMFREE(eap_str);
+       NET_MEMFREE(auth_str);
+
+       g_key_file_free(keyfile);
+       g_free(data);
+
+       return Error;
+
+}
+
+
+/*****************************************************************************
+ *     Global Functions Definition
+ *****************************************************************************/
+
+char* _net_print_error(net_err_t error)
+{
+       switch (error) {
+               /** No error */
+       case NET_ERR_NONE:
+               return "NET_ERR_NONE";
+
+               /* Common Error value */
+
+               /** Error unknown */
+       case NET_ERR_UNKNOWN:
+               return "NET_ERR_UNKNOWN";
+
+               /* Client Register related Errors used in API return */
+
+               /** Application is already registered */
+       case NET_ERR_APP_ALREADY_REGISTERED:
+               return "NET_ERR_APP_ALREADY_REGISTERED";
+               /** Application is not registered */
+       case NET_ERR_APP_NOT_REGISTERED:
+               return "NET_ERR_APP_NOT_REGISTERED";
+
+               /* Connection Related Error */
+
+               /** No active connection exists for the given profile name */
+       case NET_ERR_NO_ACTIVE_CONNECTIONS:
+               return "NET_ERR_NO_ACTIVE_CONNECTIONS";
+               /** Active connection already exists for the given profile name  */
+       case NET_ERR_ACTIVE_CONNECTION_EXISTS:
+               return "NET_ERR_ACTIVE_CONNECTION_EXISTS";
+
+               /** Connection failure : out of range */
+       case NET_ERR_CONNECTION_OUT_OF_RANGE:
+               return "NET_ERR_CONNECTION_OUT_OF_RANGE";
+               /** Connection failure : pin missing */
+       case NET_ERR_CONNECTION_PIN_MISSING:
+               return "NET_ERR_CONNECTION_PIN_MISSING";
+               /** Connection failure : dhcp failed */
+       case NET_ERR_CONNECTION_DHCP_FAILED:
+               return "NET_ERR_CONNECTION_DHCP_FAILED";
+               /** Connection failure */
+       case NET_ERR_CONNECTION_CONNECT_FAILED:
+               return "NET_ERR_CONNECTION_CONNECT_FAILED";
+               /** Connection failure : login failed */
+       case NET_ERR_CONNECTION_LOGIN_FAILED:
+               return "NET_ERR_CONNECTION_LOGIN_FAILED";
+               /** Connection failure : authentication failed */
+       case NET_ERR_CONNECTION_AUTH_FAILED:
+               return "NET_ERR_CONNECTION_AUTH_FAILED";
+               /** Connection failure : invalid key */
+       case NET_ERR_CONNECTION_INVALID_KEY:
+               return "NET_ERR_CONNECTION_INVALID_KEY";
+
+               /* Other Error */
+
+               /** Access is denied */
+       case NET_ERR_ACCESS_DENIED:
+               return "NET_ERR_ACCESS_DENIED";
+               /** Operation is in progress */
+       case NET_ERR_IN_PROGRESS:
+               return "NET_ERR_IN_PROGRESS";
+               /** Operation was aborted by client or network*/
+       case NET_ERR_OPERATION_ABORTED:
+               return "NET_ERR_OPERATION_ABORTED";
+               /** Invalid value of API parameter */
+       case NET_ERR_INVALID_PARAM:
+               return "NET_ERR_INVALID_PARAM";
+               /** invalid operation depending on current state */
+       case NET_ERR_INVALID_OPERATION:
+               return "NET_ERR_INVALID_OPERATION";
+
+               /** Feature not supported */
+       case NET_ERR_NOT_SUPPORTED:
+               return "NET_ERR_NOT_SUPPORTED";
+               /** TimeOut Error */
+       case NET_ERR_TIME_OUT:
+               return "NET_ERR_TIME_OUT";
+               /** Network service is not available*/
+       case NET_ERR_NO_SERVICE:
+               return "NET_ERR_NO_SERVICE";
+               /** DBus can't find appropriate method */
+       case NET_ERR_UNKNOWN_METHOD:
+               return "NET_ERR_UNKNOWN_METHOD";
+       default:
+               return "INVALID";
+       }
+}
+
+net_device_t _net_get_tech_type_from_path(const char *profile_name)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_device_t device_type = NET_DEVICE_UNKNOWN;
+
+       if (strstr(profile_name, "/wifi_") != NULL)
+               device_type = NET_DEVICE_WIFI;
+       else if (strstr(profile_name, "/cellular_") != NULL)
+               device_type = NET_DEVICE_CELLULAR;
+
+       __NETWORK_FUNC_EXIT__;
+       return device_type;
+}
+
+char* _net_get_string(DBusMessage* msg)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       DBusMessageIter args;
+       char* sigvalue = NULL;
+
+       if (!dbus_message_iter_init(msg, &args)) {
+               NETWORK_LOG(NETWORK_LOW, "Message does not have parameters\n");
+       } else if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING) {
+               NETWORK_LOG(NETWORK_LOW, "Argument is not string\n");
+       } else {
+               dbus_message_iter_get_basic(&args, &sigvalue);
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return sigvalue;
+}
+
+char* _net_get_object(DBusMessage* msg)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       DBusMessageIter args;
+       char* sigvalue = NULL;
+
+       if (!dbus_message_iter_init(msg, &args)) {
+               NETWORK_LOG(NETWORK_LOW, "Message does not have parameters\n");
+       } else if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_OBJECT_PATH) {
+               NETWORK_LOG(NETWORK_LOW, "Argument is not string\n");
+       } else {
+               dbus_message_iter_get_basic(&args, &sigvalue);
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return sigvalue;
+}
+
+int _net_get_boolean(DBusMessage* msg)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       DBusMessageIter args;
+       dbus_bool_t val = FALSE;
+       int retvalue = FALSE;
+
+       if (!dbus_message_iter_init(msg, &args)) {
+               NETWORK_LOG(NETWORK_LOW, "Message does not have parameters\n");
+       } else if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_BOOLEAN) {
+               NETWORK_LOG(NETWORK_LOW, "Argument is not boolean\n");
+       } else {
+               dbus_message_iter_get_basic(&args, &val);
+
+               if (val)
+                       retvalue = TRUE;
+               else
+                       retvalue = FALSE;
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return retvalue;
+}
+
+int _net_get_path(DBusMessage *msg, char *profile_name)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       char* ProfileName = NULL;
+
+       ProfileName = (char*)dbus_message_get_path(msg);
+       snprintf(profile_name, strlen(ProfileName) + 1, "%s", ProfileName);
+
+       __NETWORK_FUNC_EXIT__;
+
+       return NET_ERR_NONE;
+}
+
+int _net_get_tech_state(DBusMessage* msg, network_get_tech_state_info_t* tech_state)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusMessageIter args, dict;
+
+       if (!dbus_message_iter_init(msg, &args)) {
+               NETWORK_LOG(NETWORK_LOW, "Message does not have parameters\n");
+               Error = NET_ERR_UNKNOWN;
+               goto done;
+       }
+
+       dbus_message_iter_recurse(&args, &dict);
+
+       while (dbus_message_iter_get_arg_type(&dict) == DBUS_TYPE_DICT_ENTRY) {
+               DBusMessageIter key_iter, sub_iter1, sub_iter2;
+               const char *key = NULL;
+               const char *tech_name = NULL;
+
+               dbus_message_iter_recurse(&dict, &key_iter);
+               dbus_message_iter_get_basic(&key_iter, &key);
+
+               if (strcmp(key, "AvailableTechnologies") == 0 ||
+                   strcmp(key, "EnabledTechnologies") == 0 ||
+                   strcmp(key, "ConnectedTechnologies") == 0) {
+                       dbus_message_iter_next(&key_iter);
+                       dbus_message_iter_recurse(&key_iter, &sub_iter1);
+
+                       if (dbus_message_iter_get_arg_type(&sub_iter1) == DBUS_TYPE_ARRAY)
+                               dbus_message_iter_recurse(&sub_iter1, &sub_iter2);
+                       else
+                               goto next_dict;
+
+                       while (dbus_message_iter_get_arg_type(&sub_iter2) == DBUS_TYPE_STRING) {
+                               dbus_message_iter_get_basic(&sub_iter2, &tech_name);
+                               if (tech_name != NULL &&
+                                   strcmp(tech_name, tech_state->technology) == 0) {
+                                       if (strcmp(key, "AvailableTechnologies") == 0)
+                                               tech_state->AvailableTechnology = TRUE;
+                                       else if (strcmp(key, "EnabledTechnologies") == 0)
+                                               tech_state->EnabledTechnology = TRUE;
+                                       else
+                                               tech_state->ConnectedTechnology = TRUE;
+                               }
+
+                               dbus_message_iter_next(&sub_iter2);
+                       }
+               } else if (strcmp(key, "DefaultTechnology") == 0) {
+                       dbus_message_iter_next(&key_iter);
+                       dbus_message_iter_recurse(&key_iter, &sub_iter1);
+
+                       if (dbus_message_iter_get_arg_type(&sub_iter1) == DBUS_TYPE_STRING) {
+                               dbus_message_iter_get_basic(&sub_iter1, &tech_name);
+                               if (tech_name != NULL &&
+                                   strcmp(tech_name, tech_state->technology) == 0)
+                                       tech_state->AvailableTechnology = TRUE;
+                       }
+               }
+next_dict:
+               dbus_message_iter_next(&dict);
+       }
+
+done:
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+
+/** This function is used only to open Wi-Fi connection with hidden APs */
+int _net_open_connection_with_wifi_info(const net_wifi_connection_info_t* wifi_info)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       /** path = manager.ConnectService(({ "Type": "wifi", "Mode": "managed",
+        "SSID": sys.argv[1],
+        "Security": security,
+        "Passphrase": passphrase }));
+       */
+
+       net_err_t Error = NET_ERR_NONE;
+       char type[] = "wifi";
+       char mode[128] = "";
+       char essid[NET_WLAN_ESSID_LEN + 1] = "";
+       char security[128] = "";
+       char passphrase[NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN] = "";
+       net_wifi_connect_service_info_t wifi_connection_info;
+
+       snprintf(mode, 128, "%s", (wifi_info->wlan_mode == NETPM_WLAN_CONNMODE_ADHOC)?"adhoc":"managed");
+
+       switch(wifi_info->security_info.sec_mode) {
+       case WLAN_SEC_MODE_NONE:
+               snprintf(security, 128, "%s", "none");
+               snprintf(passphrase, NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN, "%s", "");
+               break;
+
+       case WLAN_SEC_MODE_WEP:
+               snprintf(security, 128, "%s", "wep");
+               snprintf(passphrase, NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN, "%s", wifi_info->security_info.authentication.wep.wepKey);
+               break;
+
+       /** WPA-PSK(equivalent to WPA-NONE in case of Ad-Hoc) */
+       case WLAN_SEC_MODE_WPA_PSK:
+               snprintf(security, 128, "%s", "psk");
+               snprintf(passphrase, NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN, "%s", wifi_info->security_info.authentication.psk.pskKey);
+               break;
+
+       /** WPA2-PSK */
+       /** WPA-PSK / WPA2-PSK supported */
+       case WLAN_SEC_MODE_WPA2_PSK:
+               snprintf(security, 128, "%s", "rsn");
+               snprintf(passphrase, NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN, "%s", wifi_info->security_info.authentication.psk.pskKey);
+               break;
+
+       case WLAN_SEC_MODE_IEEE8021X:
+               snprintf(security, 128, "%s", "ieee8021x");
+               snprintf(passphrase, NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN, "%s", "");
+               Error = __net_add_eap_config(&(wifi_info->security_info.authentication.eap), wifi_info->essid);
+               if(Error != NET_ERR_NONE) {
+                       __NETWORK_FUNC_EXIT__;
+                       return Error;
+               }
+               break;
+
+       default:
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid security type\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       snprintf(essid, NET_WLAN_ESSID_LEN + 1, "%s", wifi_info->essid);
+
+       wifi_connection_info.type = type;
+       wifi_connection_info.mode = mode;
+       wifi_connection_info.ssid = essid;
+       wifi_connection_info.security = security;
+       wifi_connection_info.passphrase = passphrase;
+
+       NETWORK_LOG( NETWORK_HIGH,
+                       "Parameters: type:\t%s\nmode:\t%s\nssid:\t%s\nsecurity:\t%s\npassphrase:\t%s\n",
+                       wifi_connection_info.type, wifi_connection_info.mode,
+                       wifi_connection_info.ssid, wifi_connection_info.security,
+                       wifi_connection_info.passphrase);
+
+       if( (Error = _net_dbus_connect_service(&wifi_connection_info)) != NET_ERR_NONE ) {
+               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Failed to request connect_service. Error [%s]\n",
+                               _net_print_error(Error));
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       NETWORK_LOG(NETWORK_HIGH, "Successfully requested to ConnMan\n");
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+int _net_mutex_init()
+{
+       __NETWORK_FUNC_ENTER__;
+
+       if (pthread_mutex_init(&networkinfo_mutex.callback_mutex, NULL) != 0) {
+               NETWORK_LOG(NETWORK_ERROR, "Mutex for callback initialization failed!\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       if (pthread_mutex_init(&networkinfo_mutex.wifi_state_mutex, NULL) != 0) {
+               NETWORK_LOG(NETWORK_ERROR, "Mutex for wifi state initialization failed!\n");
+               pthread_mutex_destroy(&networkinfo_mutex.callback_mutex);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+void _net_mutex_destroy()
+{
+       __NETWORK_FUNC_ENTER__;
+
+       pthread_mutex_destroy(&networkinfo_mutex.callback_mutex);
+       pthread_mutex_destroy(&networkinfo_mutex.wifi_state_mutex);
+
+       __NETWORK_FUNC_EXIT__;
+}
+
+void _net_client_callback(net_event_info_t *event_data)
+{
+       pthread_mutex_lock(&networkinfo_mutex.callback_mutex);
+       __NETWORK_FUNC_ENTER__;
+
+       NETWORK_CALLBACK(event_data, NetworkInfo.user_data);
+
+       __NETWORK_FUNC_EXIT__;
+       pthread_mutex_unlock(&networkinfo_mutex.callback_mutex);
+}
+
+net_wifi_state_t _net_get_wifi_state()
+{
+       pthread_mutex_lock(&networkinfo_mutex.wifi_state_mutex);
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       network_get_tech_state_info_t tech_state = {{0,},};
+       net_wifi_state_t wifi_state = WIFI_UNKNOWN;
+
+       snprintf(tech_state.technology, NET_TECH_LENGTH_MAX, "%s", "wifi");
+       Error = _net_dbus_get_technology_state(&tech_state);
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR,
+                       "Error!!! _net_dbus_get_technology_state() failed. Error [%s]\n",
+                       _net_print_error(Error));
+               goto state_done;
+       }
+
+       if (tech_state.EnabledTechnology == TRUE &&
+           tech_state.AvailableTechnology == TRUE)
+               wifi_state = WIFI_ON;
+       else
+               wifi_state = WIFI_OFF;
+
+state_done:
+       __NETWORK_FUNC_EXIT__;
+       pthread_mutex_unlock(&networkinfo_mutex.wifi_state_mutex);
+       return wifi_state;
+}
+
+void _net_clear_request_table()
+{
+       __NETWORK_FUNC_ENTER__;
+
+       int i = 0;
+
+       for (i = 0;i < NETWORK_REQUEST_TYPE_MAX;i++)
+               memset(&request_table[i], 0, sizeof(network_request_table_t));
+
+       __NETWORK_FUNC_EXIT__;
+}
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
diff --git a/src/network-profile-intf.c b/src/network-profile-intf.c
new file mode 100644 (file)
index 0000000..802df40
--- /dev/null
@@ -0,0 +1,2257 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+
+/*****************************************************************************
+ *     Standard headers
+ *****************************************************************************/
+#include <stdio.h> 
+#include <errno.h> 
+#include <stdlib.h> 
+#include <string.h> 
+#include <ctype.h> 
+
+
+
+/*****************************************************************************
+ *     Platform headers
+ *****************************************************************************/
+
+#include "network-internal.h"
+#include "network-dbus-request.h"
+
+/*****************************************************************************
+ *     Macros and Typedefs
+ *****************************************************************************/
+
+/*****************************************************************************
+ *     Local Functions Declaration
+ *****************************************************************************/
+static int __net_extract_wifi_info(DBusMessageIter *array, net_profile_info_t* ProfInfo);
+static int __net_get_profile_info(const char* ProfileName, net_profile_info_t* ProfInfo);
+static int __net_extract_service_info(const char* ProfileName,
+               DBusMessage *message, net_profile_info_t* ProfInfo);
+static int __net_pm_init_profile_info(net_device_t profile_type, net_profile_info_t* ProfInfo);
+static int __net_telephony_init_profile_info(net_telephony_profile_info_t* ProfInfo);
+static int __net_telephony_get_profile_info(net_profile_name_t* ProfileName,
+               net_telephony_profile_info_t* ProfileInfo);
+static int __net_telephony_get_profile_list(net_profile_name_t** ProfileName, int* ProfileCount);
+static int __net_extract_wifi_services(DBusMessage* message,
+               DBusMessageIter* dict, network_services_list_t* service_info);
+static int __net_extract_mobile_services(DBusMessage* message, DBusMessageIter* dict, 
+               network_services_list_t* service_info, net_service_type_t network_type);
+static int __net_extract_services(DBusMessage *message, net_device_t device_type,
+               net_profile_info_t** profile_info, int* profile_count);
+static int __net_extract_ip(DBusMessageIter *iter, net_addr_t *ipAddr);
+static int __net_extract_common_info(const char *key, DBusMessageIter *variant, net_profile_info_t* ProfInfo);
+static int __net_extract_mobile_info(DBusMessageIter *array, net_profile_info_t* ProfInfo);
+static int __net_telephony_search_pdp_profile(char* ProfileName, net_profile_name_t* PdpProfName);
+static int __net_telephony_modify_profile(const char* ProfileName,
+               net_profile_info_t* ProfInfo, net_profile_info_t* exProfInfo);
+static int __net_modify_wlan_profile_info(const char* ProfileName,
+               net_profile_info_t* ProfInfo, net_profile_info_t* exProfInfo);
+static int __net_telephony_delete_profile(net_profile_name_t* PdpProfName);
+static int __net_wifi_delete_profile(net_profile_name_t* WifiProfName);
+static int __net_telephony_add_profile(net_profile_info_t *ProfInfo, net_service_type_t network_type);
+static int __net_extract_defult_profile(DBusMessageIter* iter, net_profile_name_t *profile_name);
+static int __net_set_profile_property(char* path, char* key, char* value);
+
+/*****************************************************************************
+ *     Global Functions
+ *****************************************************************************/
+
+/*****************************************************************************
+ *     Extern Variables
+ *****************************************************************************/
+
+extern network_info_t NetworkInfo;
+
+/*****************************************************************************
+ *     Global Variables
+ *****************************************************************************/
+
+/*****************************************************************************
+ *     Local Functions Definition
+ *****************************************************************************/
+
+static int __net_pm_init_profile_info(net_device_t profile_type, net_profile_info_t* ProfInfo)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       int i = 0;
+       net_dev_info_t* net_info = NULL;
+       
+       if (ProfInfo == NULL ||
+               (profile_type != NET_DEVICE_WIFI && profile_type != NET_DEVICE_CELLULAR)) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid Parameter\n");
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       memset(ProfInfo->ProfileName, '\0', NET_PROFILE_NAME_LEN_MAX+1);
+       ProfInfo->Favourite = FALSE;
+
+       if (profile_type == NET_DEVICE_WIFI) {
+               ProfInfo->profile_type = NET_DEVICE_WIFI;
+               memset(ProfInfo->ProfileInfo.Wlan.essid, '\0', NET_WLAN_ESSID_LEN+1);
+               memset(ProfInfo->ProfileInfo.Wlan.bssid, '\0', NET_MAX_MAC_ADDR_LEN+1);
+               ProfInfo->ProfileInfo.Wlan.Strength = 0;
+               ProfInfo->ProfileInfo.Wlan.frequency = 0;
+               ProfInfo->ProfileInfo.Wlan.max_rate = 0;
+               ProfInfo->ProfileInfo.Wlan.wlan_mode = 0;
+               ProfInfo->ProfileInfo.Wlan.PassphraseRequired = FALSE;
+               
+               ProfInfo->ProfileInfo.Wlan.security_info.sec_mode = 0;
+               ProfInfo->ProfileInfo.Wlan.security_info.enc_mode = 0;
+
+               if (NETPM_WLAN_MAX_WEP_KEY_LEN >= NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN)
+                       memset(ProfInfo->ProfileInfo.Wlan.security_info.authentication.wep.wepKey,
+                                       '\0', NETPM_WLAN_MAX_WEP_KEY_LEN+1);
+               else
+                       memset(ProfInfo->ProfileInfo.Wlan.security_info.authentication.psk.pskKey,
+                                       '\0', NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN+1);
+
+               ProfInfo->ProfileInfo.Wlan.security_info.wps_support = FALSE;
+
+               net_info = &(ProfInfo->ProfileInfo.Wlan.net_info);
+       } else if(profile_type == NET_DEVICE_CELLULAR) {
+               ProfInfo->profile_type = NET_DEVICE_CELLULAR;
+               ProfInfo->ProfileInfo.Pdp.ProtocolType = NET_PDP_TYPE_NONE;
+               ProfInfo->ProfileInfo.Pdp.ServiceType = NET_SERVICE_UNKNOWN;
+               ProfInfo->ProfileInfo.Pdp.Apn[0] = '\0';
+               ProfInfo->ProfileInfo.Pdp.AuthInfo.AuthType = NET_PDP_AUTH_NONE;
+               ProfInfo->ProfileInfo.Pdp.AuthInfo.UserName[0] = '\0';
+               ProfInfo->ProfileInfo.Pdp.AuthInfo.Password[0] = '\0';
+               ProfInfo->ProfileInfo.Pdp.HomeURL[0] = '\0';
+               ProfInfo->ProfileInfo.Pdp.Mcc[0] = '\0';
+               ProfInfo->ProfileInfo.Pdp.Mnc[0] = '\0';
+               ProfInfo->ProfileInfo.Pdp.IsStatic = FALSE;
+               ProfInfo->ProfileInfo.Pdp.Roaming = FALSE;
+               ProfInfo->ProfileInfo.Pdp.SetupRequired = FALSE;
+
+               net_info = &(ProfInfo->ProfileInfo.Pdp.net_info);
+       }
+       
+       memset(net_info->ProfileName, '\0', NET_PROFILE_NAME_LEN_MAX+1);
+       memset(net_info->DevName, '\0', NET_MAX_DEVICE_NAME_LEN+1);
+       net_info->DnsCount = 0;
+
+       for (i = 0;i < NET_DNS_ADDR_MAX;i++) {
+               net_info->DnsAddr[i].Type = NET_ADDR_IPV4;
+               net_info->DnsAddr[i].Data.Ipv4.s_addr = 0;
+       }
+
+       net_info->IpConfigType = 0;
+       net_info->IpAddr.Type = NET_ADDR_IPV4;
+       net_info->IpAddr.Data.Ipv4.s_addr = 0;
+       net_info->BNetmask = FALSE;
+       net_info->SubnetMask.Type = NET_ADDR_IPV4;
+       net_info->SubnetMask.Data.Ipv4.s_addr = 0;
+       net_info->BDefGateway = FALSE;
+       net_info->GatewayAddr.Type = NET_ADDR_IPV4;
+       net_info->GatewayAddr.Data.Ipv4.s_addr = 0;
+       net_info->ProxyMethod = NET_PROXY_TYPE_UNKNOWN;
+       memset(net_info->ProxyAddr, '\0', NET_PROXY_LEN_MAX+1);
+       memset(net_info->MacAddr, '\0', NET_MAX_MAC_ADDR_LEN+1);
+       
+       __NETWORK_FUNC_EXIT__;
+       
+       return NET_ERR_NONE;
+}
+
+static int __net_telephony_init_profile_info(net_telephony_profile_info_t* ProfInfo)
+{
+       __NETWORK_FUNC_ENTER__;
+       
+       if (ProfInfo == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid Parameter\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       memset(ProfInfo->ProfileName, '\0', NET_PROFILE_NAME_LEN_MAX+1);
+       ProfInfo->ServiceType = NET_SERVICE_UNKNOWN;
+       memset(ProfInfo->Apn, '\0', NET_PDP_APN_LEN_MAX+1);
+
+       ProfInfo->AuthInfo.AuthType = NET_PDP_AUTH_NONE;
+       memset(ProfInfo->AuthInfo.UserName, '\0', NET_PDP_AUTH_USERNAME_LEN_MAX+1);
+       memset(ProfInfo->AuthInfo.Password, '\0', NET_PDP_AUTH_PASSWORD_LEN_MAX+1);
+
+       memset(ProfInfo->ProxyAddr, '\0', NET_PROXY_LEN_MAX+1);
+       memset(ProfInfo->HomeURL, '\0', NET_HOME_URL_LEN_MAX+1);
+       
+       __NETWORK_FUNC_EXIT__;
+       
+       return NET_ERR_NONE;
+}
+
+static int __net_telephony_get_profile_info(net_profile_name_t* ProfileName, net_telephony_profile_info_t* ProfileInfo)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusMessage* result = NULL;
+       DBusMessageIter iter, array;
+       
+       if (ProfileName == NULL || ProfileInfo == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid parameter!\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       char request[] = TELEPHONY_PROFILE_INTERFACE ".GetProfile";
+       char* param_array[] = {NULL, NULL, NULL};
+       
+       param_array[0] = ProfileName->ProfileName;
+       param_array[1] = request;
+
+       NETWORK_LOG(NETWORK_HIGH,  "Requesting [%s %s]\n",
+               param_array[0],
+               param_array[1]);
+       
+       if ((Error = _net_send_dbus_request(TELEPHONY_SERVCE, param_array, &result)) != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR,  "Error!!! _net_send_dbus_request failed\n");
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       /* Parsing profile info */
+       dbus_message_iter_init(result, &iter);
+       dbus_message_iter_recurse(&iter, &array);
+
+       Error = __net_telephony_init_profile_info(ProfileInfo);
+
+       if (Error != NET_ERR_NONE) {
+               dbus_message_unref(result);
+               __NETWORK_FUNC_EXIT__;
+
+               return Error;
+       }
+
+       while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
+               DBusMessageIter entry;
+               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);
+
+               if (strcmp(key, "path") == 0) {
+                       dbus_message_iter_get_basic(&entry, &value);
+                       
+                       if (value != NULL)
+                               g_strlcpy(ProfileInfo->ProfileName, value, NET_PROFILE_NAME_LEN_MAX);
+
+               } else if (strcmp(key, "svc_ctg_id") == 0) {
+                       net_service_type_t ServiceType = NET_SERVICE_UNKNOWN;
+                       dbus_message_iter_get_basic(&entry, &value);
+
+                       if (value != NULL)
+                               ServiceType = atoi(value);
+
+                       if (ServiceType > NET_SERVICE_UNKNOWN)
+                               ProfileInfo->ServiceType = ServiceType;
+
+               } else if (strcmp(key, "apn") == 0) {
+                       dbus_message_iter_get_basic(&entry, &value);
+                       
+                       if (value != NULL)
+                               g_strlcpy(ProfileInfo->Apn, value, NET_PDP_APN_LEN_MAX);
+
+               } else if (strcmp(key, "auth_type") == 0) {
+                       net_auth_type_t authType = NET_PDP_AUTH_NONE;
+                       dbus_message_iter_get_basic(&entry, &value);
+                       
+                       if (value != NULL)
+                               authType = atoi(value);
+
+                       if (authType == NET_PDP_AUTH_PAP)
+                               ProfileInfo->AuthInfo.AuthType = NET_PDP_AUTH_PAP;
+                       else if (authType == NET_PDP_AUTH_CHAP)
+                               ProfileInfo->AuthInfo.AuthType = NET_PDP_AUTH_CHAP;
+
+               } else if (strcmp(key, "auth_id") == 0) {
+                       dbus_message_iter_get_basic(&entry, &value);
+
+                       if (value != NULL)
+                               g_strlcpy(ProfileInfo->AuthInfo.UserName, value, NET_PDP_AUTH_USERNAME_LEN_MAX);
+
+               } else if (strcmp(key, "auth_pwd") == 0) {
+                       dbus_message_iter_get_basic(&entry, &value);
+
+                       if (value != NULL)
+                               g_strlcpy(ProfileInfo->AuthInfo.Password, value, NET_PDP_AUTH_PASSWORD_LEN_MAX);
+
+               } else if (strcmp(key, "proxy_addr") == 0) {
+                       dbus_message_iter_get_basic(&entry, &value);
+
+                       if (value != NULL)
+                               g_strlcpy(ProfileInfo->ProxyAddr, value, NET_PROXY_LEN_MAX);
+
+               } else if (strcmp(key, "home_url") == 0) {
+                       dbus_message_iter_get_basic(&entry, &value);
+
+                       if (value != NULL)
+                               g_strlcpy(ProfileInfo->HomeURL, value, NET_HOME_URL_LEN_MAX);
+               }
+               dbus_message_iter_next(&array);
+       }
+
+       dbus_message_unref(result);
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+static int __net_telephony_get_profile_list(net_profile_name_t** ProfileName, int* ProfileCount)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusMessage* result = NULL;
+       net_profile_name_t* profileList = NULL;
+       DBusMessageIter iter, array;
+       int count = 0;
+
+       char request[] = TELEPHONY_MASTER_INTERFACE ".GetProfileList";
+       char path[] = TELEPHONY_MASTER_PATH;
+       char* param_array[] = {NULL, NULL, NULL};
+       
+       param_array[0] = path;
+       param_array[1] = request;
+
+       NETWORK_LOG(NETWORK_HIGH,  "Requesting [%s %s]\n",
+               param_array[0],
+               param_array[1]);
+       
+       Error = _net_send_dbus_request(TELEPHONY_SERVCE, param_array, &result);
+
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR,  "Error!!! _net_send_dbus_request failed\n");
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       dbus_message_iter_init(result, &iter);
+       if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) {
+               NETWORK_LOG(NETWORK_HIGH,  "There is no profiles\n");
+               *ProfileCount = 0;
+               dbus_message_unref(result);
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       dbus_message_iter_recurse(&iter, &array);
+
+       /* Get count of profile name from reply message */
+       while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_STRING) {
+               count++;
+               dbus_message_iter_next(&array);
+       }
+
+       if (count > 0)
+               profileList = (net_profile_name_t*)malloc(sizeof(net_profile_name_t) * count);
+       else {
+               *ProfileCount = 0;
+               dbus_message_unref(result);
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       if (profileList == NULL) {
+               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Failed to allocate memory\n");
+               *ProfileCount = 0;
+               dbus_message_unref(result);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       count = 0;
+
+       /* Parsing to get profile name from reply message */
+       dbus_message_iter_init(result, &iter);
+       dbus_message_iter_recurse(&iter, &array);
+       while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_STRING) {
+               const char *key = NULL;
+
+               dbus_message_iter_get_basic(&array, &key);
+
+               if (key != NULL)
+                       g_strlcpy(profileList[count].ProfileName, key, NET_PROFILE_NAME_LEN_MAX);
+
+               count++;
+               dbus_message_iter_next(&array);
+       }
+
+       *ProfileName = profileList;
+       *ProfileCount = count;
+
+       dbus_message_unref(result);
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+static int __net_telephony_search_pdp_profile(char* ProfileName, net_profile_name_t* PdpProfName)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       net_profile_name_t* ProfileList = NULL;
+       char* connmanProfName = NULL;
+       char* telephonyProfName = NULL;
+       char* foundPtr = NULL;
+       int ProfileCount = 0;
+       int i = 0;
+
+       /* Get pdp profile list from telephony service */
+       Error = __net_telephony_get_profile_list(&ProfileList, &ProfileCount);
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR,  "Error!!! failed to get profile list from telephony service\n");
+               NET_MEMFREE(ProfileList);
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       if (ProfileList == NULL || ProfileCount <= 0) {
+               NETWORK_LOG(NETWORK_ERROR,  "Error!!! There is no PDP profiles\n");
+               NET_MEMFREE(ProfileList);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_NO_SERVICE;
+       }
+
+       /* Find matching profile */
+       connmanProfName = strrchr(ProfileName, '/') + 1;
+       for (i = 0;i < ProfileCount;i++) {
+               telephonyProfName = strrchr(ProfileList[i].ProfileName, '/') + 1;
+               foundPtr = strstr(connmanProfName, telephonyProfName);
+
+               if (foundPtr != NULL && strcmp(foundPtr, telephonyProfName) == 0) {
+                       g_strlcpy(PdpProfName->ProfileName,
+                                       ProfileList[i].ProfileName, NET_PROFILE_NAME_LEN_MAX);
+                       NETWORK_LOG(NETWORK_HIGH,
+                                       "PDP profile name found in cellular profile: %s\n",
+                                       PdpProfName->ProfileName);
+                       break;
+               }
+       }
+
+       if (i >= ProfileCount) {
+               NETWORK_LOG(NETWORK_ERROR,  "Error!!! There is no matching PDP profiles\n");
+               NET_MEMFREE(ProfileList);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_NO_SERVICE;
+       }
+
+       NET_MEMFREE(ProfileList);
+       __NETWORK_FUNC_EXIT__;
+
+       return Error;
+}
+
+static int __net_extract_wifi_services(DBusMessage* message,
+               DBusMessageIter* dict, network_services_list_t* service_info)
+{
+       int count = 0;
+       int i = 0;
+
+       __NETWORK_FUNC_ENTER__; 
+
+       if(message == NULL || dict == NULL || service_info == NULL)
+       {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid prarameter \n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+       
+       while(dbus_message_iter_get_arg_type(dict) == DBUS_TYPE_DICT_ENTRY)
+       {
+               DBusMessageIter keyValue, array, value;
+               const char *key = NULL;
+               const char *objPath = NULL;
+
+               dbus_message_iter_recurse(dict, &keyValue);
+               dbus_message_iter_get_basic(&keyValue, &key);
+
+               if(strcmp(key, "Services") == 0)
+               {
+                       dbus_message_iter_next(&keyValue);
+                       dbus_message_iter_recurse(&keyValue, &array);
+                       if(dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY)
+                       {
+                               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Can't get service list\n");
+                               __NETWORK_FUNC_EXIT__;
+                               return NET_ERR_NO_SERVICE;
+                       }
+                               
+                       dbus_message_iter_recurse(&array, &value);
+                       if(dbus_message_iter_get_arg_type(&value) != DBUS_TYPE_OBJECT_PATH)
+                       {
+                               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Can't get service list\n");
+                               __NETWORK_FUNC_EXIT__;
+                               return NET_ERR_NO_SERVICE;
+                       }
+
+                       while(dbus_message_iter_get_arg_type(&value) == DBUS_TYPE_OBJECT_PATH)
+                       {
+                               dbus_message_iter_get_basic(&value, &objPath);
+
+                               if(strstr(objPath, "wifi_") != NULL)
+                               {
+                                       service_info->ProfileName[count] = (char*)malloc(NET_PROFILE_NAME_LEN_MAX+1);
+                                       if(service_info->ProfileName[count] == NULL)
+                                       {
+                                               NETWORK_LOG(NETWORK_EXCEPTION,
+                                                               "Error!!! Failed to allocate memory\n");
+
+                                               for(i = 0;i < count;i++)
+                                                       NET_MEMFREE(service_info->ProfileName[i]);
+                                               
+                                               __NETWORK_FUNC_EXIT__;  
+                                               return NET_ERR_UNKNOWN;
+                                       }
+
+                                       g_strlcpy(service_info->ProfileName[count], objPath, NET_PROFILE_NAME_LEN_MAX);
+
+                                       count++;
+                               }
+
+                               dbus_message_iter_next(&value);
+                       }
+
+                       service_info->num_of_services = count;
+                       return NET_ERR_NONE;
+               }                               
+
+               dbus_message_iter_next(dict);
+       }               
+
+       __NETWORK_FUNC_EXIT__;
+
+       return NET_ERR_NONE;
+}
+
+static int __net_extract_mobile_services(DBusMessage* message, DBusMessageIter* dict,
+               network_services_list_t* service_info, net_service_type_t network_type)
+{
+       int count = 0;
+       int i = 0;
+       const char net_suffix[] = "_1";
+       const char mms_suffix[] = "_2";
+       const char wap_suffix[] = "_3";
+       char *suffix = NULL;
+
+       __NETWORK_FUNC_ENTER__; 
+       
+       if (message == NULL || dict == NULL || service_info == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid prarameter \n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       while (dbus_message_iter_get_arg_type(dict) == DBUS_TYPE_DICT_ENTRY) {
+               DBusMessageIter keyValue, array, value;
+               const char *key = NULL;
+               const char *objPath = NULL;
+               char found = FALSE;
+
+               dbus_message_iter_recurse(dict, &keyValue);
+               dbus_message_iter_get_basic(&keyValue, &key);
+
+               if (strcmp(key, "Services") == 0) {
+                       dbus_message_iter_next(&keyValue);
+                       dbus_message_iter_recurse(&keyValue, &array);
+
+                       if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY) {
+                               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Can't get service list\n");
+                               __NETWORK_FUNC_EXIT__;
+                               return NET_ERR_NO_SERVICE;
+                       }
+                               
+                       dbus_message_iter_recurse(&array, &value);
+
+                       if (dbus_message_iter_get_arg_type(&value) != DBUS_TYPE_OBJECT_PATH) {
+                               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Can't get service list\n");
+                               __NETWORK_FUNC_EXIT__;
+                               return NET_ERR_NO_SERVICE;
+                       }
+
+                       while (dbus_message_iter_get_arg_type(&value) == DBUS_TYPE_OBJECT_PATH) {
+                               dbus_message_iter_get_basic(&value, &objPath);
+
+                               if (strstr(objPath, "cellular_") != NULL) {
+                                       found = FALSE;
+
+                                       suffix = strrchr(objPath, '_');
+
+                                       if (network_type == NET_SERVICE_UNKNOWN)
+                                               found = TRUE;
+                                       else if (network_type == NET_SERVICE_MMS && strcmp(suffix, mms_suffix) == 0)
+                                               found = TRUE;
+                                       else if (network_type == NET_SERVICE_WAP && strcmp(suffix, wap_suffix) == 0)
+                                               found = TRUE;
+                                       else if (network_type == NET_SERVICE_INTERNET && strcmp(suffix, net_suffix) == 0)
+                                               found = TRUE;
+
+                                       if (found) {
+                                               service_info->ProfileName[count] = (char*)malloc(NET_PROFILE_NAME_LEN_MAX+1);
+                                               if (service_info->ProfileName[count] == NULL) {
+                                                       NETWORK_LOG(NETWORK_EXCEPTION,
+                                                                       "Error!!! Failed to allocate memory\n");
+
+                                                       for (i = 0;i < count;i++)
+                                                               NET_MEMFREE(service_info->ProfileName[i]);
+                                                       
+                                                       __NETWORK_FUNC_EXIT__;  
+                                                       return NET_ERR_UNKNOWN;
+                                               }
+
+                                               g_strlcpy(service_info->ProfileName[count], objPath, NET_PROFILE_NAME_LEN_MAX+1);
+                                               
+                                               NETWORK_LOG(NETWORK_HIGH, "index [%d] ProfileName [%s]\n",
+                                                               count, service_info->ProfileName[count]);
+
+                                               count++;
+                                       }
+                               }
+
+                               dbus_message_iter_next(&value);
+                       }
+                       service_info->num_of_services = count;
+               }
+
+               dbus_message_iter_next(dict);
+       }
+
+       __NETWORK_FUNC_EXIT__;
+
+       return NET_ERR_NONE;
+}
+
+static int __net_extract_services(DBusMessage *message, net_device_t device_type,
+               net_profile_info_t** profile_info, int* profile_count)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusMessageIter iter, dict;
+       network_services_list_t service_info = {0,};
+       net_profile_info_t ProfileInfo = {0, };
+       net_profile_info_t* ProfilePtr = NULL;
+       int i = 0;
+       int j = 0;      
+       int profiles = 0;
+
+       dbus_message_iter_init(message, &iter);
+       dbus_message_iter_recurse(&iter, &dict);
+
+       *profile_count = 0;
+
+       switch (device_type) {
+       case NET_DEVICE_WIFI :
+               Error = __net_extract_wifi_services(message, &dict, &service_info);
+               break;
+       case NET_DEVICE_CELLULAR :
+               Error = __net_extract_mobile_services(message, &dict, &service_info, NET_SERVICE_UNKNOWN);
+               break;
+       default :
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_NOT_SUPPORTED;
+               break;
+       }
+       
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Can't extract services from received message\n");
+               *profile_count = 0;
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       NETWORK_LOG(NETWORK_HIGH, "Num. of Profiles from Manager : [%d]\n", service_info.num_of_services);
+
+       profiles = 0;
+       for (i = 0; i < service_info.num_of_services; i++) {
+               memset(&ProfileInfo, 0, sizeof(net_profile_info_t));
+
+               Error = __net_get_profile_info(service_info.ProfileName[i], &ProfileInfo);
+               if (Error != NET_ERR_NONE) {
+                       NETWORK_LOG(NETWORK_ERROR, "Error!!! failed to get service(profile) information. Error [%s]\n",
+                                       _net_print_error(Error));
+                       NETWORK_LOG(NETWORK_HIGH, "Continuing with next profile\n");
+
+                       continue;
+               }
+
+               profiles++;
+               ProfilePtr = (net_profile_info_t*)realloc(ProfilePtr, (j + 1) * sizeof(net_profile_info_t));
+               if (ProfilePtr == NULL) {
+                       NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Failed to allocate memory\n");
+
+                       for (i = 0;i < service_info.num_of_services;i++)
+                               NET_MEMFREE(service_info.ProfileName[i]);
+
+                       __NETWORK_FUNC_EXIT__;
+                       return NET_ERR_UNKNOWN;
+               }
+
+               memcpy(ProfilePtr + j, &ProfileInfo, sizeof(net_profile_info_t));
+               j++;
+       }
+
+       for(i = 0;i < service_info.num_of_services;i++)
+               NET_MEMFREE(service_info.ProfileName[i]);
+
+       NETWORK_LOG(NETWORK_HIGH, "Total Num. of Profiles [%d]\n", profiles);
+
+       *profile_count = profiles;
+       *profile_info = ProfilePtr;
+
+       __NETWORK_FUNC_EXIT__;
+
+       return Error;
+}
+
+
+static int __net_extract_ip(DBusMessageIter *iter, net_addr_t *ipAddr)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       unsigned char *ipValue = NULL;
+       const char *value = NULL;
+       char *saveptr = NULL;
+       char ipString[NETPM_IPV4_STR_LEN_MAX+1];
+       char* ipToken[4];
+       
+       dbus_message_iter_get_basic(iter, &value);      
+
+       ipValue = (unsigned char *)&(ipAddr->Data.Ipv4.s_addr);
+
+       if(value != NULL) {
+               g_strlcpy(ipString, value, NETPM_IPV4_STR_LEN_MAX+1);
+
+               ipToken[0] = strtok_r(ipString, ".", &saveptr);
+
+               if(ipToken[0] != NULL) {
+                       ipToken[1] = strtok_r(NULL, ".", &saveptr);
+
+                       if(ipToken[1] != NULL) {
+                               ipToken[2] = strtok_r(NULL, ".", &saveptr);
+
+                               if(ipToken[2] != NULL) {
+                                       ipToken[3] = strtok_r(NULL, ".", &saveptr);
+
+                                       if(ipToken[3] != NULL) {
+                                               ipValue[0] = (unsigned char)atoi(ipToken[0]);
+                                               ipValue[1] = (unsigned char)atoi(ipToken[1]);
+                                               ipValue[2] = (unsigned char)atoi(ipToken[2]);
+                                               ipValue[3] = (unsigned char)atoi(ipToken[3]);
+                                       }
+                               }
+                       }
+               }
+       }
+
+       __NETWORK_FUNC_EXIT__;
+
+       return NET_ERR_NONE;
+}
+
+static int __net_extract_common_info(const char *key, DBusMessageIter *variant, net_profile_info_t* ProfInfo)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusMessageIter subIter1, subIter2, subIter3, subIter4;
+       const char *subKey = NULL;
+       const char *value = NULL;
+       net_dev_info_t* net_info = NULL;
+       
+       if (ProfInfo->profile_type == NET_DEVICE_CELLULAR) {
+               net_info = &(ProfInfo->ProfileInfo.Pdp.net_info);
+       } else if (ProfInfo->profile_type == NET_DEVICE_WIFI) {
+               net_info = &(ProfInfo->ProfileInfo.Wlan.net_info);
+       } else {
+               NETWORK_LOG(NETWORK_ERROR,
+                               "Error!!! Invalid Profile type. [%d]\n", ProfInfo->profile_type);
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       if (strcmp(key, "State") == 0) {
+               dbus_message_iter_get_basic(variant, &value);
+               
+               if (strcmp(value, "idle") == 0)
+                       ProfInfo->ProfileState = NET_STATE_TYPE_IDLE;
+               else if (strcmp(value, "failure") == 0)
+                       ProfInfo->ProfileState = NET_STATE_TYPE_FAILURE;
+               else if (strcmp(value, "association") == 0)
+                       ProfInfo->ProfileState = NET_STATE_TYPE_ASSOCIATION;
+               else if (strcmp(value, "configuration") == 0)
+                       ProfInfo->ProfileState = NET_STATE_TYPE_CONFIGURATION;
+               else if (strcmp(value, "ready") == 0)
+                       ProfInfo->ProfileState = NET_STATE_TYPE_READY;
+               else if (strcmp(value, "disconnect") == 0)
+                       ProfInfo->ProfileState = NET_STATE_TYPE_DISCONNECT;
+               else if (strcmp(value, "online") == 0)
+                       ProfInfo->ProfileState = NET_STATE_TYPE_ONLINE;
+               else
+                       ProfInfo->ProfileState = NET_STATE_TYPE_UNKNOWN;
+       } else if (strcmp(key, "Favorite") == 0) {
+               dbus_bool_t val;
+               
+               dbus_message_iter_get_basic(variant, &val);
+               
+               if(val)
+                       ProfInfo->Favourite = TRUE;
+               else
+                       ProfInfo->Favourite = FALSE;
+       } else if (strcmp(key, "Ethernet") == 0) {
+               dbus_message_iter_recurse(variant, &subIter1);
+               
+               while (dbus_message_iter_get_arg_type(&subIter1) == DBUS_TYPE_DICT_ENTRY) {
+                       dbus_message_iter_recurse(&subIter1, &subIter2);
+                       dbus_message_iter_get_basic(&subIter2, &subKey);
+
+                       if (strcmp(subKey, "Interface") == 0) {
+                               dbus_message_iter_next(&subIter2);
+                               dbus_message_iter_recurse(&subIter2, &subIter3);
+                               dbus_message_iter_get_basic(&subIter3, &value);
+
+                               if (value != NULL)
+                                       g_strlcpy(net_info->DevName, value, NET_MAX_DEVICE_NAME_LEN);
+
+                       } else if (strcmp(subKey, "Address") == 0) {
+                               dbus_message_iter_next(&subIter2);
+                               dbus_message_iter_recurse(&subIter2, &subIter3);
+                               dbus_message_iter_get_basic(&subIter3, &value);
+
+                               if (value != NULL)
+                                       g_strlcpy(net_info->MacAddr, value, NET_MAX_MAC_ADDR_LEN);
+                       }
+                       
+                       dbus_message_iter_next(&subIter1);
+               }
+       } else if (strcmp(key, "IPv4") == 0) {
+               dbus_message_iter_recurse(variant, &subIter1);
+               
+               while (dbus_message_iter_get_arg_type(&subIter1) == DBUS_TYPE_DICT_ENTRY) {
+                       dbus_message_iter_recurse(&subIter1, &subIter2);
+                       dbus_message_iter_get_basic(&subIter2, &subKey);
+
+                       if (strcmp(subKey, "Method") == 0) {
+                               dbus_message_iter_next(&subIter2);
+                               dbus_message_iter_recurse(&subIter2, &subIter3);
+                               dbus_message_iter_get_basic(&subIter3, &value);
+                               
+                               if (strcmp(value, "dhcp") == 0)
+                                       net_info->IpConfigType = NET_IP_CONFIG_TYPE_DYNAMIC;
+                               else if (strcmp(value, "manual") == 0)
+                                       net_info->IpConfigType = NET_IP_CONFIG_TYPE_STATIC;
+                               else if (strcmp(value, "fixed") == 0)
+                                       net_info->IpConfigType = NET_IP_CONFIG_TYPE_FIXED;
+                               else if (strcmp(value, "off") == 0)
+                                       net_info->IpConfigType = NET_IP_CONFIG_TYPE_OFF;
+
+                       } else if (strcmp(subKey, "Address") == 0) {
+                               dbus_message_iter_next(&subIter2);
+                               dbus_message_iter_recurse(&subIter2, &subIter3);
+                               __net_extract_ip(&subIter3, &net_info->IpAddr);
+                       } else if (strcmp(subKey, "Netmask") == 0) {
+                               dbus_message_iter_next(&subIter2);
+                               dbus_message_iter_recurse(&subIter2, &subIter3);
+                               __net_extract_ip(&subIter3, &net_info->SubnetMask);
+                               net_info->BNetmask = TRUE;
+                       } else if (strcmp(subKey, "Gateway") == 0) {
+                               dbus_message_iter_next(&subIter2);
+                               dbus_message_iter_recurse(&subIter2, &subIter3);
+                               __net_extract_ip(&subIter3, &net_info->GatewayAddr);
+                               net_info->BDefGateway = TRUE;
+                       }
+                       
+                       dbus_message_iter_next(&subIter1);
+               }
+       } else if (strcmp(key, "IPv4.Configuration") == 0) {
+
+               if (net_info->IpConfigType != NET_IP_CONFIG_TYPE_DYNAMIC &&
+                   net_info->IpConfigType != NET_IP_CONFIG_TYPE_STATIC &&
+                   net_info->IpConfigType != NET_IP_CONFIG_TYPE_OFF) {
+
+                       dbus_message_iter_recurse(variant, &subIter1);
+               
+                       while (dbus_message_iter_get_arg_type(&subIter1) == DBUS_TYPE_DICT_ENTRY) {
+                               dbus_message_iter_recurse(&subIter1, &subIter2);
+                               dbus_message_iter_get_basic(&subIter2, &subKey);
+
+                               if (strcmp(subKey, "Method") == 0) {
+                                       dbus_message_iter_next(&subIter2);
+                                       dbus_message_iter_recurse(&subIter2, &subIter3);
+                                       dbus_message_iter_get_basic(&subIter3, &value);
+                                       
+                                       if(strcmp(value, "dhcp") == 0)
+                                               net_info->IpConfigType = NET_IP_CONFIG_TYPE_DYNAMIC;
+                                       else if(strcmp(value, "manual") == 0)
+                                               net_info->IpConfigType = NET_IP_CONFIG_TYPE_STATIC;
+                                       else if(strcmp(value, "off") == 0)
+                                               net_info->IpConfigType = NET_IP_CONFIG_TYPE_OFF;
+
+                               } else if (strcmp(subKey, "Address") == 0 &&
+                                          net_info->IpAddr.Data.Ipv4.s_addr == 0) {
+                                       dbus_message_iter_next(&subIter2);
+                                       dbus_message_iter_recurse(&subIter2, &subIter3);
+                                       __net_extract_ip(&subIter3, &net_info->IpAddr);
+                               } else if (strcmp(subKey, "Netmask") == 0 &&
+                                          net_info->SubnetMask.Data.Ipv4.s_addr == 0) {
+                                       dbus_message_iter_next(&subIter2);
+                                       dbus_message_iter_recurse(&subIter2, &subIter3);
+                                       __net_extract_ip(&subIter3, &net_info->SubnetMask);
+                                       net_info->BNetmask = TRUE;
+                               } else if (strcmp(subKey, "Gateway") == 0 &&
+                                          net_info->GatewayAddr.Data.Ipv4.s_addr == 0) {
+                                       dbus_message_iter_next(&subIter2);
+                                       dbus_message_iter_recurse(&subIter2, &subIter3);
+                                       __net_extract_ip(&subIter3, &net_info->GatewayAddr);
+                                       net_info->BDefGateway = TRUE;
+                               }
+                               
+                               dbus_message_iter_next(&subIter1);
+                       }
+               }
+       } else if(strcmp(key, "Nameservers") == 0) {
+               int dnsCount = 0;
+               dbus_message_iter_recurse(variant, &subIter1);                  
+               
+               while (dbus_message_iter_get_arg_type(&subIter1) == DBUS_TYPE_STRING) {
+                       __net_extract_ip(&subIter1, &net_info->DnsAddr[dnsCount]);
+                       dnsCount++;
+                       if (dnsCount >= NET_DNS_ADDR_MAX)
+                               break;                                  
+                       
+                       dbus_message_iter_next(&subIter1);
+               }
+
+               net_info->DnsCount = dnsCount;
+       } else if (strcmp(key, "Nameservers.Configuration") == 0 && net_info->DnsCount == 0) {
+               int dnsCount = 0;
+               dbus_message_iter_recurse(variant, &subIter1);
+
+               while (dbus_message_iter_get_arg_type(&subIter1) == DBUS_TYPE_STRING) {
+                       __net_extract_ip(&subIter1, &net_info->DnsAddr[dnsCount]);
+                       dnsCount++;
+                       if(dnsCount >= NET_DNS_ADDR_MAX)
+                               break;
+                       
+                       dbus_message_iter_next(&subIter1);
+               }
+
+               net_info->DnsCount = dnsCount;
+       } else if (strcmp(key, "Domains") == 0) {
+       } else if (strcmp(key, "Domains.Configuration") == 0) {
+       } else if (strcmp(key, "Proxy") == 0) {
+               dbus_message_iter_recurse(variant, &subIter1);
+               
+               while (dbus_message_iter_get_arg_type(&subIter1) == DBUS_TYPE_DICT_ENTRY) {
+                       dbus_message_iter_recurse(&subIter1, &subIter2);
+                       dbus_message_iter_get_basic(&subIter2, &subKey);
+
+                       if (strcmp(subKey, "Method") == 0) {
+                               dbus_message_iter_next(&subIter2);
+                               dbus_message_iter_recurse(&subIter2, &subIter3);
+                               dbus_message_iter_get_basic(&subIter3, &value);
+                               
+                               if (strcmp(value, "direct") == 0)
+                                       net_info->ProxyMethod = NET_PROXY_TYPE_DIRECT;
+                               else if (strcmp(value, "auto") == 0)
+                                       net_info->ProxyMethod = NET_PROXY_TYPE_AUTO;
+                               else if (strcmp(value, "manual") == 0)
+                                       net_info->ProxyMethod = NET_PROXY_TYPE_MANUAL;
+                               else
+                                       net_info->ProxyMethod = NET_PROXY_TYPE_UNKNOWN;
+                       } else if (strcmp(subKey, "URL") == 0) {
+                               dbus_message_iter_next(&subIter2);
+                               dbus_message_iter_recurse(&subIter2, &subIter3);
+                               dbus_message_iter_get_basic(&subIter3, &value);
+
+                               if (value != NULL)
+                                       g_strlcpy(net_info->ProxyAddr, value, NET_PROXY_LEN_MAX);
+
+                       } else if (strcmp(subKey, "Servers") == 0) {
+                               dbus_message_iter_next(&subIter2);
+                               dbus_message_iter_recurse(&subIter2, &subIter3);
+
+                               if (dbus_message_iter_get_arg_type(&subIter3) == DBUS_TYPE_ARRAY) {
+                                       dbus_message_iter_recurse(&subIter3, &subIter4);
+
+                                       if (dbus_message_iter_get_arg_type(&subIter4) == DBUS_TYPE_STRING) {
+                                               dbus_message_iter_get_basic(&subIter4, &value);
+
+                                               if (value != NULL)
+                                                       g_strlcpy(net_info->ProxyAddr, value, NET_PROXY_LEN_MAX);
+                                       }
+                               }
+                       }
+                       
+                       dbus_message_iter_next(&subIter1);
+               }
+       } else if (strcmp(key, "Proxy.Configuration") == 0 &&
+                  (net_info->ProxyMethod == NET_PROXY_TYPE_UNKNOWN ||
+                   strlen(net_info->ProxyAddr) == 0)) {
+
+               dbus_message_iter_recurse(variant, &subIter1);
+
+               while (dbus_message_iter_get_arg_type(&subIter1) == DBUS_TYPE_DICT_ENTRY) {
+                       dbus_message_iter_recurse(&subIter1, &subIter2);
+                       dbus_message_iter_get_basic(&subIter2, &subKey);
+
+                       if (strcmp(subKey, "Method") == 0 &&
+                          net_info->ProxyMethod == NET_PROXY_TYPE_UNKNOWN) {
+                               dbus_message_iter_next(&subIter2);
+                               dbus_message_iter_recurse(&subIter2, &subIter3);
+                               dbus_message_iter_get_basic(&subIter3, &value);
+
+                               if (strcmp(value, "direct") == 0)
+                                       net_info->ProxyMethod = NET_PROXY_TYPE_DIRECT;
+                               else if (strcmp(value, "auto") == 0)
+                                       net_info->ProxyMethod = NET_PROXY_TYPE_AUTO;
+                               else if (strcmp(value, "manual") == 0)
+                                       net_info->ProxyMethod = NET_PROXY_TYPE_MANUAL;
+                               else
+                                       net_info->ProxyMethod = NET_PROXY_TYPE_UNKNOWN;
+                       } else if (strcmp(subKey, "URL") == 0 && strlen(net_info->ProxyAddr) == 0) {
+                               dbus_message_iter_next(&subIter2);
+                               dbus_message_iter_recurse(&subIter2, &subIter3);
+                               dbus_message_iter_get_basic(&subIter3, &value);
+
+                               if (value != NULL)
+                                       g_strlcpy(net_info->ProxyAddr, value, NET_PROXY_LEN_MAX+1);
+
+                       } else if (strcmp(subKey, "Servers") == 0 && strlen(net_info->ProxyAddr) == 0) {
+                               dbus_message_iter_next(&subIter2);
+                               dbus_message_iter_recurse(&subIter2, &subIter3);
+
+                               if (dbus_message_iter_get_arg_type(&subIter3) == DBUS_TYPE_ARRAY) {
+                                       dbus_message_iter_recurse(&subIter3, &subIter4);
+
+                                       if (dbus_message_iter_get_arg_type(&subIter4) == DBUS_TYPE_STRING) {
+                                               dbus_message_iter_get_basic(&subIter4, &value);
+
+                                               if (value != NULL)
+                                                       g_strlcpy(net_info->ProxyAddr, value, NET_PROXY_LEN_MAX+1);
+                                       }
+                               }
+                       }
+
+                       dbus_message_iter_next(&subIter1);
+               }
+       } else if(strcmp(key, "Provider") == 0) {
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       
+       return Error;
+}
+
+static int __net_extract_wifi_info(DBusMessageIter *array, net_profile_info_t* ProfInfo)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       net_wifi_profile_info_t *Wlan = &(ProfInfo->ProfileInfo.Wlan);
+
+       while (dbus_message_iter_get_arg_type(array) == DBUS_TYPE_DICT_ENTRY) {
+               DBusMessageIter entry, variant, sub_array;
+               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 (strcmp(key, "Mode") == 0) {
+                       dbus_message_iter_get_basic(&variant, &value);
+
+                       if (strcmp(value, "managed") == 0)
+                               Wlan->wlan_mode = NETPM_WLAN_CONNMODE_INFRA;
+                       else if (strcmp(value, "adhoc") == 0)
+                               Wlan->wlan_mode = NETPM_WLAN_CONNMODE_ADHOC;
+                       else
+                               Wlan->wlan_mode = NETPM_WLAN_CONNMODE_AUTO;
+               } else if (strcmp(key, "Security") == 0) {
+                       dbus_message_iter_recurse(&variant, &sub_array);
+
+                       while (dbus_message_iter_get_arg_type(&sub_array) == DBUS_TYPE_STRING) {
+                               dbus_message_iter_get_basic(&sub_array, &value);
+                               if (strcmp(value, "none") == 0 &&
+                                   Wlan->security_info.sec_mode < WLAN_SEC_MODE_NONE)
+                                       Wlan->security_info.sec_mode = WLAN_SEC_MODE_NONE;
+                               else if (strcmp(value, "wep") == 0 &&
+                                        Wlan->security_info.sec_mode < WLAN_SEC_MODE_WEP)
+                                       Wlan->security_info.sec_mode = WLAN_SEC_MODE_WEP;
+                               else if (strcmp(value, "psk") == 0 &&
+                                        Wlan->security_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
+                                       Wlan->security_info.sec_mode = WLAN_SEC_MODE_WPA_PSK;
+                               else if (strcmp(value, "ieee8021x") == 0 &&
+                                        Wlan->security_info.sec_mode < WLAN_SEC_MODE_IEEE8021X)
+                                       Wlan->security_info.sec_mode = WLAN_SEC_MODE_IEEE8021X;
+                               else if (strcmp(value, "wpa") == 0 &&
+                                        Wlan->security_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
+                                       Wlan->security_info.sec_mode = WLAN_SEC_MODE_WPA_PSK;
+                               else if (strcmp(value, "rsn") == 0 &&
+                                        Wlan->security_info.sec_mode < WLAN_SEC_MODE_WPA_PSK)
+                                       Wlan->security_info.sec_mode = WLAN_SEC_MODE_WPA2_PSK;
+                               else if (strcmp(value, "wps") == 0)
+                                       Wlan->security_info.wps_support = TRUE;
+                               else if (Wlan->security_info.sec_mode < WLAN_SEC_MODE_NONE)
+                                       Wlan->security_info.sec_mode = WLAN_SEC_MODE_NONE;
+
+                               dbus_message_iter_next(&sub_array);
+                       }
+               } else if (strcmp(key, "EncryptionMode") == 0) {
+                       dbus_message_iter_get_basic(&variant, &value);
+
+                       if (strcmp(value, "none") == 0)
+                               Wlan->security_info.enc_mode = WLAN_ENC_MODE_NONE;
+                       else if (strcmp(value, "wep") == 0)
+                               Wlan->security_info.enc_mode = WLAN_ENC_MODE_WEP;
+                       else if (strcmp(value, "tkip") == 0)
+                               Wlan->security_info.enc_mode = WLAN_ENC_MODE_TKIP;
+                       else if (strcmp(value, "aes") == 0)
+                               Wlan->security_info.enc_mode = WLAN_ENC_MODE_AES;
+                       else if (strcmp(value, "mixed") == 0)
+                               Wlan->security_info.enc_mode = WLAN_ENC_MODE_TKIP_AES_MIXED;
+
+                       dbus_message_iter_next(&sub_array);
+
+               } else if (strcmp(key, "Strength") == 0) {
+                       dbus_message_iter_get_basic(&variant, &(Wlan->Strength));
+               } else if (strcmp(key, "Name") == 0) {
+                       dbus_message_iter_get_basic(&variant, &value);
+
+                       if (value != NULL)
+                               g_strlcpy(Wlan->essid, value, NET_WLAN_ESSID_LEN);
+
+               } else if (strcmp(key, "Passphrase") == 0) {
+                       wlan_security_info_t *security_info = &(Wlan->security_info);
+                       dbus_message_iter_get_basic(&variant, &value);
+
+                       if (security_info->sec_mode == WLAN_SEC_MODE_WEP && value != NULL)
+                               g_strlcpy(security_info->authentication.wep.wepKey,
+                                               value, NETPM_WLAN_MAX_WEP_KEY_LEN+1);
+                       else if ((security_info->sec_mode == WLAN_SEC_MODE_WPA_PSK ||
+                                   security_info->sec_mode == WLAN_SEC_MODE_WPA2_PSK) &&
+                                   value != NULL)
+                               g_strlcpy(security_info->authentication.psk.pskKey,
+                                               value, NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN+1);
+
+               } else if (strcmp(key, "PassphraseRequired") == 0) {
+                       dbus_bool_t val;
+                       
+                       dbus_message_iter_get_basic(&variant, &val);
+
+                       if(val)
+                               Wlan->PassphraseRequired = TRUE;
+                       else
+                               Wlan->PassphraseRequired = FALSE;
+               } else if (strcmp(key, "BSSID") == 0) {
+                       dbus_message_iter_get_basic(&variant, &value);
+
+                       if (value != NULL)
+                               g_strlcpy(Wlan->bssid, value, NET_MAX_MAC_ADDR_LEN);
+
+               } else if (strcmp(key, "MaxRate") == 0) {
+                       unsigned int maxrate;
+                       dbus_message_iter_get_basic(&variant, &maxrate);
+
+                       Wlan->max_rate = maxrate;
+
+               } else if (strcmp(key, "Frequency") == 0) {
+                       unsigned short frequency;
+                       dbus_message_iter_get_basic(&variant, &frequency);
+
+                       Wlan->frequency = (unsigned int)frequency;
+
+               } else {
+                       __net_extract_common_info(key, &variant, ProfInfo);
+               }
+               
+               dbus_message_iter_next(array);
+       }
+
+       __NETWORK_FUNC_EXIT__;
+
+       return Error;
+}
+
+static int __net_extract_mobile_info(DBusMessageIter *array, net_profile_info_t* ProfInfo)
+{
+       net_err_t Error = NET_ERR_NONE;
+
+       __NETWORK_FUNC_ENTER__; 
+
+       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 (strcmp(key, "Mode") == 0) {
+                       dbus_message_iter_get_basic(&variant, &value);
+
+                       if (strcmp(value, "gprs") == 0)
+                               ProfInfo->ProfileInfo.Pdp.ProtocolType = NET_PDP_TYPE_GPRS;
+                       else if (strcmp(value, "edge") == 0)
+                               ProfInfo->ProfileInfo.Pdp.ProtocolType = NET_PDP_TYPE_EDGE;
+                       else if (strcmp(value, "umts") == 0)
+                               ProfInfo->ProfileInfo.Pdp.ProtocolType = NET_PDP_TYPE_UMTS;
+                       else
+                               ProfInfo->ProfileInfo.Pdp.ProtocolType = NET_PDP_TYPE_NONE;
+               } else if (strcmp(key, "Roaming") == 0) {
+                       dbus_bool_t val;
+                       
+                       dbus_message_iter_get_basic(&variant, &val);
+
+                       if (val)
+                               ProfInfo->ProfileInfo.Pdp.Roaming = TRUE;
+                       else
+                               ProfInfo->ProfileInfo.Pdp.Roaming = FALSE;
+               } else if (strcmp(key, "SetupRequired") == 0) {
+                       dbus_bool_t val;
+                       
+                       dbus_message_iter_get_basic(&variant, &val);
+
+                       if (val)
+                               ProfInfo->ProfileInfo.Pdp.SetupRequired = TRUE;
+                       else
+                               ProfInfo->ProfileInfo.Pdp.SetupRequired = FALSE;
+               } else
+                       __net_extract_common_info(key, &variant, ProfInfo);
+
+               dbus_message_iter_next(array);
+       }
+
+       /* Get Specific info from telephony service */
+       net_telephony_profile_info_t telephony_profinfo;
+       net_profile_name_t PdpProfName;
+
+       PdpProfName.ProfileName[0] = '\0';
+
+       __net_telephony_init_profile_info(&telephony_profinfo);
+
+       /* Find matching profile in telephony service */
+       Error = __net_telephony_search_pdp_profile(ProfInfo->ProfileName, &PdpProfName);
+
+       if (Error == NET_ERR_NONE && strlen(PdpProfName.ProfileName) > 0) {
+               /* Get profile info from telephony service */
+               Error = __net_telephony_get_profile_info(&PdpProfName, &telephony_profinfo);
+
+               if (Error == NET_ERR_NONE) {
+                       ProfInfo->ProfileInfo.Pdp.ServiceType = telephony_profinfo.ServiceType;
+
+                       if (strlen(telephony_profinfo.Apn) > 0)
+                               g_strlcpy(ProfInfo->ProfileInfo.Pdp.Apn,
+                                               telephony_profinfo.Apn, NET_PDP_APN_LEN_MAX);
+
+                       if (strlen(telephony_profinfo.ProxyAddr) > 0)
+                               g_strlcpy(ProfInfo->ProfileInfo.Pdp.net_info.ProxyAddr,
+                                               telephony_profinfo.ProxyAddr, NET_PROXY_LEN_MAX);
+
+                       if (strlen(telephony_profinfo.HomeURL) > 0)
+                               g_strlcpy(ProfInfo->ProfileInfo.Pdp.HomeURL,
+                                               telephony_profinfo.HomeURL, NET_HOME_URL_LEN_MAX);
+
+                       ProfInfo->ProfileInfo.Pdp.AuthInfo.AuthType = telephony_profinfo.AuthInfo.AuthType;
+
+                       if (strlen(telephony_profinfo.AuthInfo.UserName) > 0)
+                               g_strlcpy(ProfInfo->ProfileInfo.Pdp.AuthInfo.UserName,
+                                               telephony_profinfo.AuthInfo.UserName,
+                                               NET_PDP_AUTH_USERNAME_LEN_MAX);
+
+                       if (strlen(telephony_profinfo.AuthInfo.Password) > 0)
+                               g_strlcpy(ProfInfo->ProfileInfo.Pdp.AuthInfo.Password,
+                                               telephony_profinfo.AuthInfo.Password,
+                                               NET_PDP_AUTH_PASSWORD_LEN_MAX);
+               }
+       }
+
+       __NETWORK_FUNC_EXIT__;
+
+       return Error;
+}
+
+static int __net_extract_service_info(const char* ProfileName, DBusMessage *message, net_profile_info_t* ProfInfo)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusMessageIter iter, array;
+       net_device_t profileType = NET_DEVICE_UNKNOWN;
+
+       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 (strcmp(key, "Type") == 0) {
+                       dbus_message_iter_next(&entry);
+                       dbus_message_iter_recurse(&entry, &dict);
+                       dbus_message_iter_get_basic(&dict, &temp);
+                       if (strcmp(temp, "wifi") == 0)
+                               profileType = NET_DEVICE_WIFI;
+                       else if (strcmp(temp, "cellular") == 0)
+                               profileType = NET_DEVICE_CELLULAR;
+
+                       break;
+               }
+
+               dbus_message_iter_next(&array);
+       }
+
+       dbus_message_iter_init(message, &iter);
+       dbus_message_iter_recurse(&iter, &array);
+
+       if (profileType == NET_DEVICE_WIFI) {
+               if ((Error = __net_pm_init_profile_info(NET_DEVICE_WIFI, ProfInfo)) != NET_ERR_NONE) {
+                       NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Can't init profile\n");
+                       __NETWORK_FUNC_EXIT__;
+                       return Error;
+               }
+               
+               ProfInfo->profile_type = NET_DEVICE_WIFI;
+               g_strlcpy(ProfInfo->ProfileName, ProfileName, NET_PROFILE_NAME_LEN_MAX);
+               g_strlcpy(ProfInfo->ProfileInfo.Wlan.net_info.ProfileName,
+                               ProfileName, NET_PROFILE_NAME_LEN_MAX);
+
+               Error = __net_extract_wifi_info(&array, ProfInfo);
+
+       } else if (profileType == NET_DEVICE_CELLULAR) {
+               if ((Error = __net_pm_init_profile_info(NET_DEVICE_CELLULAR, ProfInfo)) != NET_ERR_NONE) {
+                       NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Can't init profile\n");
+                       __NETWORK_FUNC_EXIT__;
+                       return Error;
+               }
+               
+               ProfInfo->profile_type = NET_DEVICE_CELLULAR;
+               g_strlcpy(ProfInfo->ProfileName, ProfileName, NET_PROFILE_NAME_LEN_MAX);
+               g_strlcpy(ProfInfo->ProfileInfo.Pdp.net_info.ProfileName,
+                               ProfileName, NET_PROFILE_NAME_LEN_MAX);
+               
+               Error = __net_extract_mobile_info(&array, ProfInfo);
+       } else {
+               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Not supported profile type\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_NOT_SUPPORTED;
+       }               
+
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_EXCEPTION,
+                               "Error!!! Can't extract service information from received message\n");
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       __NETWORK_FUNC_EXIT__;
+
+       return Error;   
+}
+
+static int __net_get_profile_info(const char* ProfileName, net_profile_info_t* ProfInfo)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusConnection* conn = NULL;
+       DBusMessage *message = NULL;
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); 
+       
+       if (conn == NULL) {
+               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Can't get on system bus\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       message = _net_invoke_dbus_method(CONNMAN_SERVICE, conn, ProfileName,
+                       CONNMAN_SERVICE_INTERFACE, "GetProperties", &Error);
+
+       if (message == NULL) {
+               NETWORK_LOG(NETWORK_ERROR,
+                               "Error!!! Failed to get service(profile) information\n");
+               goto done;
+       }
+
+       Error = __net_extract_service_info(ProfileName, message, ProfInfo);
+
+       dbus_message_unref(message); 
+done:
+       dbus_connection_unref(conn); 
+
+       __NETWORK_FUNC_EXIT__;
+
+       return Error;
+}
+
+
+static int __net_set_profile_property(char* path, char* key, char* value)
+{
+       __NETWORK_FUNC_ENTER__;
+       
+       net_err_t Error = NET_ERR_NONE;
+
+       char request[] = CONNMAN_SERVICE_INTERFACE ".SetProperty";
+       char* param_array[] = {NULL, NULL, NULL, NULL, NULL};
+       
+       param_array[0] = path;
+       param_array[1] = request;
+       param_array[2] = key;
+       param_array[3] = value;
+
+       NETWORK_LOG(NETWORK_HIGH,  "Requesting [%s %s %s %s]\n",
+               param_array[0],
+               param_array[1],
+               param_array[2],
+               param_array[3]);
+       
+       Error = _net_send_dbus_request(CONNMAN_SERVICE, param_array, NULL);
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR,  "Error!!! _net_send_dbus_request failed\n");
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+static int __net_modify_wlan_profile_info(const char* ProfileName,
+               net_profile_info_t* ProfInfo, net_profile_info_t* exProfInfo)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       int i = 0;
+       char profilePath[NET_PROFILE_NAME_LEN_MAX+1] = "";
+       char propertyInfo[128] = "";
+       char keyString[64] = "";
+
+       wlan_security_info_t *security_info = &(ProfInfo->ProfileInfo.Wlan.security_info);
+       wlan_security_info_t *ex_security_info = &(exProfInfo->ProfileInfo.Wlan.security_info);
+
+       net_dev_info_t *net_info = &(ProfInfo->ProfileInfo.Wlan.net_info);
+       net_dev_info_t *ex_net_info = &(exProfInfo->ProfileInfo.Wlan.net_info);
+
+       snprintf(profilePath, NET_PROFILE_NAME_LEN_MAX+1, "%s", ProfileName);
+
+       /* Compare and Set 'Passphrase' */
+       if (ex_security_info->sec_mode == WLAN_SEC_MODE_WEP) {
+               if (strcmp(security_info->authentication.wep.wepKey
+                       , ex_security_info->authentication.wep.wepKey) != 0) {
+
+                       snprintf(keyString, 64, "string:Passphrase");
+                       snprintf(propertyInfo, 128, "variant:string:%s",
+                                       security_info->authentication.wep.wepKey);
+                       Error = __net_set_profile_property(profilePath, keyString, propertyInfo);
+                       if (Error != NET_ERR_NONE) {
+                               NETWORK_LOG(NETWORK_ERROR,
+                                               "Error!!! __net_set_profile_property() failed\n");
+                               __NETWORK_FUNC_EXIT__;
+                               return Error;
+                       }
+               }
+       } else if (ex_security_info->sec_mode == WLAN_SEC_MODE_WPA_PSK ||
+                  ex_security_info->sec_mode == WLAN_SEC_MODE_WPA2_PSK) {
+
+               if (strcmp(security_info->authentication.psk.pskKey,
+                          ex_security_info->authentication.psk.pskKey) != 0) {
+
+                       snprintf(keyString, 64, "string:Passphrase");
+                       snprintf(propertyInfo, 128, "variant:string:%s",
+                                       security_info->authentication.psk.pskKey);
+                       Error = __net_set_profile_property(profilePath, keyString, propertyInfo);
+                       
+                       if (Error != NET_ERR_NONE) {
+                               __NETWORK_FUNC_EXIT__;
+                               return Error;
+                       }
+               }
+       }
+
+       /* Compare and Set 'Proxy' */
+       if ((ex_net_info->ProxyMethod != net_info->ProxyMethod) ||
+           (strcmp(ex_net_info->ProxyAddr, net_info->ProxyAddr) != 0)) {
+
+               Error = _net_dbus_set_proxy(ProfInfo, profilePath);
+
+               if (Error != NET_ERR_NONE) {
+                       __NETWORK_FUNC_EXIT__;
+                       return Error;
+               }
+       }
+
+       /* Compare and Set 'IPv4 addresses' */
+       if ((ex_net_info->IpConfigType != net_info->IpConfigType) ||
+           (net_info->IpConfigType == NET_IP_CONFIG_TYPE_STATIC &&
+            (net_info->IpAddr.Data.Ipv4.s_addr != ex_net_info->IpAddr.Data.Ipv4.s_addr ||
+             net_info->SubnetMask.Data.Ipv4.s_addr != ex_net_info->SubnetMask.Data.Ipv4.s_addr ||
+             net_info->GatewayAddr.Data.Ipv4.s_addr != ex_net_info->GatewayAddr.Data.Ipv4.s_addr))) {
+
+               Error = _net_dbus_set_profile_ipv4(ProfInfo, profilePath);
+               
+               if (Error != NET_ERR_NONE) {
+                       NETWORK_LOG(NETWORK_ERROR,  "Error!!! Can't set IPv4\n");
+                       __NETWORK_FUNC_EXIT__;
+                       return Error;
+               }
+       }
+
+       /* Compare and Set 'DNS addresses' */
+       if (net_info->IpConfigType == NET_IP_CONFIG_TYPE_STATIC) {
+               for (i = 0;i < net_info->DnsCount;i++) {
+                       if(i >= NET_DNS_ADDR_MAX) {
+                               net_info->DnsCount = NET_DNS_ADDR_MAX;
+                               break;
+                       }
+
+                       if (net_info->DnsAddr[i].Data.Ipv4.s_addr !=
+                           ex_net_info->DnsAddr[i].Data.Ipv4.s_addr) break;
+               }
+
+               if (i < net_info->DnsCount) {
+                       Error = _net_dbus_set_profile_dns(ProfInfo, profilePath);
+
+                       if (Error != NET_ERR_NONE) {
+                               NETWORK_LOG(NETWORK_ERROR,  "Error!!! Can't set dns\n");
+                               __NETWORK_FUNC_EXIT__;
+                               return Error;
+                       }
+               }
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+static int __net_wifi_delete_profile(net_profile_name_t* WifiProfName)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusConnection* conn = NULL;
+       DBusMessage *message = NULL;
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+
+       if (conn == NULL) {
+               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Can't get on system bus\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       message = _net_invoke_dbus_method(CONNMAN_SERVICE, conn, WifiProfName->ProfileName,
+                       CONNMAN_SERVICE_INTERFACE, "Remove", &Error);
+
+       if (message == NULL) {
+               NETWORK_LOG(NETWORK_ERROR,
+                               "Error!!! Failed to Remove service(profile)\n");
+               goto done;
+       }
+
+       dbus_message_unref(message);
+done:
+       dbus_connection_unref(conn);
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+
+static int __net_telephony_add_profile(net_profile_info_t *ProfInfo, net_service_type_t network_type)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+
+       ProfInfo->ProfileInfo.Pdp.ServiceType = network_type;
+
+       Error = _net_dbus_add_pdp_profile(ProfInfo);
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_HIGH, "_net_dbus_add_pdp_profile() failed\n");
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+static int __net_telephony_modify_profile(const char *ProfileName,
+               net_profile_info_t *ProfInfo, net_profile_info_t* exProfInfo)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       net_profile_name_t telephony_profile;
+       char connman_profile[NET_PROFILE_NAME_LEN_MAX+1] = "";
+
+       g_strlcpy(connman_profile, ProfileName, NET_PROFILE_NAME_LEN_MAX+1);
+       ProfInfo->ProfileInfo.Pdp.ServiceType = exProfInfo->ProfileInfo.Pdp.ServiceType;
+
+       Error = __net_telephony_search_pdp_profile((char*)connman_profile, &telephony_profile);
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_HIGH, "__net_telephony_search_pdp_profile() failed\n");
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       Error = _net_dbus_modify_pdp_profile(ProfInfo, (char*)telephony_profile.ProfileName);
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_HIGH, "_net_dbus_modify_pdp_profile() failed\n");
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       __NETWORK_FUNC_EXIT__;
+
+       return Error;
+}
+
+static int __net_telephony_delete_profile(net_profile_name_t* PdpProfName)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusConnection* conn = NULL;
+       DBusMessage *message = NULL;
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+
+       if (conn == NULL) {
+               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Can't get on system bus\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       message = _net_invoke_dbus_method(TELEPHONY_SERVCE, conn, PdpProfName->ProfileName,
+                       TELEPHONY_PROFILE_INTERFACE, "RemoveProfile", &Error);
+
+       if (message == NULL) {
+               NETWORK_LOG(NETWORK_ERROR,
+                               "Error!!! Failed to Remove service(profile)\n");
+               goto done;
+       }
+
+       /** Check Reply */
+       DBusMessageIter iter;
+       int remove_result = 0;
+
+       dbus_message_iter_init(message, &iter);
+       if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_BOOLEAN) {
+               dbus_message_iter_get_basic(&iter, &remove_result);
+               NETWORK_LOG(NETWORK_HIGH, "Profile remove result : %d\n", remove_result);
+       }
+
+       if (remove_result)
+               Error = NET_ERR_NONE;
+       else
+               Error = NET_ERR_UNKNOWN;
+
+       dbus_message_unref(message);
+
+done:
+       dbus_connection_unref(conn);
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+static int __net_extract_defult_device(DBusMessageIter* dict, net_device_t *device_type)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+
+       if (dict == NULL || device_type == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid prarameter \n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       *device_type = NET_DEVICE_UNKNOWN;
+
+       while (dbus_message_iter_get_arg_type(dict) == DBUS_TYPE_DICT_ENTRY) {
+               DBusMessageIter keyValue, value;
+               const char *key = NULL;
+               const char *objPath = NULL;
+
+               dbus_message_iter_recurse(dict, &keyValue);
+               dbus_message_iter_get_basic(&keyValue, &key);
+
+               if (strcmp(key, "DefaultTechnology") == 0) {
+                       dbus_message_iter_next(&keyValue);
+                       dbus_message_iter_recurse(&keyValue, &value);
+
+                       if (dbus_message_iter_get_arg_type(&value) != DBUS_TYPE_STRING)
+                               break;
+
+                       dbus_message_iter_get_basic(&value, &objPath);
+                       if (objPath == NULL || strlen(objPath) == 0)
+                               break;
+
+                       if (strcmp(objPath, "wifi") == 0)
+                               *device_type = NET_DEVICE_WIFI;
+                       else if (strcmp(objPath, "cellular") == 0)
+                               *device_type = NET_DEVICE_CELLULAR;
+
+                       break;
+               }
+               dbus_message_iter_next(dict);
+       }
+
+       if (*device_type == NET_DEVICE_UNKNOWN)
+               Error = NET_ERR_NO_SERVICE;
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+static int __net_extract_defult_profile(DBusMessageIter* iter, net_profile_name_t *profile_name)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       net_device_t device_type = NET_DEVICE_UNKNOWN;
+       DBusMessageIter dict;
+       const char net_suffix[] = "_1";
+       char *suffix = NULL;
+       const char *objPath = NULL;
+
+       if (iter == NULL || profile_name == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid prarameter \n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       memset(profile_name, 0, sizeof(net_profile_name_t));
+
+       dbus_message_iter_recurse(iter, &dict);
+       Error = __net_extract_defult_device(&dict, &device_type);
+
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! There is no Default Technology\n");
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       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;
+
+               dbus_message_iter_recurse(&dict, &keyValue);
+               dbus_message_iter_get_basic(&keyValue, &key);
+
+               if (strcmp(key, "Services") == 0) {
+                       dbus_message_iter_next(&keyValue);
+                       dbus_message_iter_recurse(&keyValue, &array);
+
+                       if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY) {
+                               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Can't get service list\n");
+                               __NETWORK_FUNC_EXIT__;
+                               return NET_ERR_NO_SERVICE;
+                       }
+
+                       dbus_message_iter_recurse(&array, &value);
+
+                       while (dbus_message_iter_get_arg_type(&value) == DBUS_TYPE_OBJECT_PATH) {
+                               dbus_message_iter_get_basic(&value, &objPath);
+
+                               if (device_type == NET_DEVICE_CELLULAR &&
+                                   strstr(objPath, "/cellular_") != NULL) {
+
+                                       suffix = strrchr(objPath, '_');
+
+                                       if (strcmp(suffix, net_suffix) == 0) {
+                                               goto found;
+                                       }
+
+                               } else if (device_type == NET_DEVICE_WIFI &&
+                                          strstr(objPath, "/wifi_") != NULL)
+                                       goto found;
+                               else
+                                       break;
+
+                               dbus_message_iter_next(&value);
+                       }
+                       NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Can't find default service\n");
+                       __NETWORK_FUNC_EXIT__;
+                       return NET_ERR_NO_SERVICE;
+               }
+               dbus_message_iter_next(&dict);
+       }
+
+       NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Can't find default service\n");
+       Error = NET_ERR_NO_SERVICE;
+
+found:
+       if (Error == NET_ERR_NONE && objPath != NULL) {
+               g_strlcpy(profile_name->ProfileName, objPath, NET_PROFILE_NAME_LEN_MAX);
+               NETWORK_LOG(NETWORK_HIGH, "Default profile found : %s\n", profile_name->ProfileName);
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+
+int _net_check_profile_name(const char* ProfileName)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       const char *profileHeader = "/profile/";
+       int i = 0;
+       int stringLen = 0;
+
+       if (ProfileName == NULL || strlen(ProfileName) <= strlen(profileHeader)) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Profile name is invalid\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       stringLen = strlen(ProfileName);
+
+       if (strncmp(profileHeader, ProfileName, strlen(profileHeader)) == 0) {
+               for (i = 0;i < stringLen;i++) {
+                       if (isgraph(ProfileName[i]) == 0) {
+                               NETWORK_LOG(NETWORK_ERROR, "Error!!! Profile name is invalid\n");
+                               __NETWORK_FUNC_EXIT__;
+                               return NET_ERR_INVALID_PARAM;
+                       }
+               }
+       } else {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Profile name is invalid\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+int _net_get_profile_list(net_device_t device_type, net_profile_info_t** profile_info, int* profile_count)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusConnection* conn = NULL;
+       DBusMessage *message = NULL;
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); 
+       if (conn == NULL) {
+               NETWORK_LOG(NETWORK_EXCEPTION,
+                               "Error!!! Can't get on system bus\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       message = _net_invoke_dbus_method(CONNMAN_SERVICE, conn, CONNMAN_MANAGER_PATH,
+                       CONNMAN_MANAGER_INTERFACE, "GetProperties", &Error);
+       if (message == NULL) {
+               NETWORK_LOG(NETWORK_ERROR,
+                               "Error!!! Failed to get service(profile) list\n");
+               dbus_connection_unref(conn);
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       switch (device_type) {
+       case NET_DEVICE_CELLULAR:
+       case NET_DEVICE_WIFI:
+               Error = __net_extract_services(message, device_type, profile_info, profile_count);
+               break;
+       default :
+               Error = NET_ERR_UNKNOWN;
+               break;
+       }
+
+       NETWORK_LOG(NETWORK_HIGH, "Error = %d\n", Error);
+
+       dbus_message_unref(message); 
+       dbus_connection_unref(conn); 
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+int _net_get_service_profile(net_service_type_t service_type, net_profile_name_t *profile_name)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusConnection* conn = NULL;
+       DBusMessage *message = NULL;
+       DBusMessageIter iter, dict;
+       network_services_list_t service_info = {0,};
+       int i = 0;
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+       if (conn == NULL) {
+               NETWORK_LOG(NETWORK_EXCEPTION,
+                               "Error!!! Can't get on system bus\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       message = _net_invoke_dbus_method(CONNMAN_SERVICE, conn, CONNMAN_MANAGER_PATH,
+                       CONNMAN_MANAGER_INTERFACE, "GetProperties", &Error);
+       if (message == NULL) {
+               NETWORK_LOG(NETWORK_ERROR,
+                               "Error!!! Failed to get service(profile) list\n");
+               dbus_connection_unref(conn);
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       dbus_message_iter_init(message, &iter);
+       dbus_message_iter_recurse(&iter, &dict);
+
+       Error = __net_extract_mobile_services(message, &dict, &service_info, service_type);
+
+       if (Error != NET_ERR_NONE)
+               goto done;
+
+       if (service_info.num_of_services > 0) {
+               memcpy(profile_name->ProfileName, service_info.ProfileName[0], NET_PROFILE_NAME_LEN_MAX);
+               (profile_name->ProfileName)[NET_PROFILE_NAME_LEN_MAX] = '\0';
+       } else
+               Error = NET_ERR_NO_SERVICE;
+
+       for (i = 0;i < service_info.num_of_services;i++)
+               NET_MEMFREE(service_info.ProfileName[i]);
+
+done:
+       dbus_message_unref(message);
+       dbus_connection_unref(conn);
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+int _net_get_default_profile_info(net_profile_info_t *profile_info)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       DBusConnection* conn = NULL;
+       DBusMessage *message = NULL;
+       DBusMessageIter iter;
+       net_profile_name_t profile_name;
+       const char *prof_name = NULL;
+
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+       if (conn == NULL) {
+               NETWORK_LOG(NETWORK_EXCEPTION,
+                               "Error!!! Can't get on system bus\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       message = _net_invoke_dbus_method(CONNMAN_SERVICE, conn, CONNMAN_MANAGER_PATH,
+                       CONNMAN_MANAGER_INTERFACE, "GetProperties", &Error);
+       if (message == NULL) {
+               NETWORK_LOG(NETWORK_ERROR,
+                               "Error!!! Failed to get service(profile) list\n");
+               dbus_connection_unref(conn);
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       dbus_message_iter_init(message, &iter);
+       Error = __net_extract_defult_profile(&iter, &profile_name);
+
+       if (Error != NET_ERR_NONE)
+               goto done;
+
+       prof_name = (const char*)profile_name.ProfileName;
+       Error = __net_get_profile_info(prof_name, profile_info);
+
+done:
+       dbus_message_unref(message);
+       dbus_connection_unref(conn);
+
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+/*****************************************************************************
+ *     ConnMan Wi-Fi Client Interface Sync API Definition
+ *****************************************************************************/
+
+
+EXPORT_API int net_add_profile(net_service_type_t network_type, net_profile_info_t *prof_info)
+{
+       net_err_t Error = NET_ERR_NONE;
+       
+       __NETWORK_FUNC_ENTER__;
+       
+       if (NetworkInfo.ClientEventCb == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+
+       if (prof_info == NULL ||
+               (network_type != NET_SERVICE_INTERNET &&
+               network_type != NET_SERVICE_MMS &&
+               network_type != NET_SERVICE_WAP)) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid Parameter\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       Error = __net_telephony_add_profile(prof_info, network_type);
+
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! failed to add service(profile). Error [%s]\n",
+                               _net_print_error(Error));
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       __NETWORK_FUNC_EXIT__;  
+       return Error;
+}
+
+
+EXPORT_API int net_delete_profile(const char* profile_name)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       net_profile_name_t pdp_prof_name;
+       net_profile_name_t wifi_prof_name;
+       net_profile_info_t prof_info;
+       
+       if (NetworkInfo.ClientEventCb == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+
+       if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid Parameter\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       Error = __net_get_profile_info(profile_name, &prof_info);
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR,
+                               "Error!!! failed to get service(profile) information. Error [%s]\n",
+                               _net_print_error(Error));
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       g_strlcpy(wifi_prof_name.ProfileName, profile_name, NET_PROFILE_NAME_LEN_MAX + 1);
+
+       if (prof_info.profile_type == NET_DEVICE_WIFI) {
+               Error = __net_wifi_delete_profile(&wifi_prof_name);
+               if (Error != NET_ERR_NONE) {
+                       NETWORK_LOG(NETWORK_ERROR,
+                                       "Error!!! failed to delete service(profile). Error [%s]\n",
+                                       _net_print_error(Error));
+                       __NETWORK_FUNC_EXIT__;
+                       return Error;
+               }
+       } else if (prof_info.profile_type == NET_DEVICE_CELLULAR) {
+               Error = __net_telephony_search_pdp_profile(wifi_prof_name.ProfileName, &pdp_prof_name);
+               if (Error != NET_ERR_NONE) {
+                       NETWORK_LOG(NETWORK_ERROR,
+                                       "Error!!! failed to get service(profile) information. Error [%s]\n",
+                                       _net_print_error(Error));
+                       __NETWORK_FUNC_EXIT__;
+                       return Error;
+               }
+
+               Error = __net_telephony_delete_profile(&pdp_prof_name);
+               if (Error != NET_ERR_NONE) {
+                       NETWORK_LOG(NETWORK_ERROR,
+                                       "Error!!! failed to delete service(profile). Error [%s]\n",
+                                       _net_print_error(Error));
+                       __NETWORK_FUNC_EXIT__;
+                       return Error;
+               }
+       } else {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid Parameter\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       __NETWORK_FUNC_EXIT__;  
+       return NET_ERR_NONE;
+}
+
+
+EXPORT_API int net_get_profile_info(const char *profile_name, net_profile_info_t *prof_info)
+{
+       __NETWORK_FUNC_ENTER__;
+       
+       net_err_t Error = NET_ERR_NONE;
+       
+       if (NetworkInfo.ClientEventCb == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+
+       if (_net_check_profile_name(profile_name) != NET_ERR_NONE || prof_info == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid Parameter\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }       
+
+       Error = __net_get_profile_info(profile_name, prof_info);
+       if (Error != NET_ERR_NONE)
+               NETWORK_LOG(NETWORK_ERROR,
+                       "Error!!! failed to get service(profile) information. Error [%s]\n",
+                       _net_print_error(Error));
+       
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+
+EXPORT_API int net_modify_profile(const char* profile_name, net_profile_info_t* prof_info)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       net_profile_info_t exProfInfo;
+       
+       if (NetworkInfo.ClientEventCb == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }       
+
+       Error = net_get_profile_info(profile_name, &exProfInfo);
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR,
+                               "Error!!! failed to get service(profile) information. Error [%s]\n",
+                               _net_print_error(Error));
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       if (prof_info == NULL ||
+           (exProfInfo.profile_type != NET_DEVICE_WIFI &&
+            exProfInfo.profile_type != NET_DEVICE_CELLULAR)) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid Parameter\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       if (exProfInfo.profile_type == NET_DEVICE_WIFI)
+               Error = __net_modify_wlan_profile_info(profile_name, prof_info, &exProfInfo);
+       else if (exProfInfo.profile_type == NET_DEVICE_CELLULAR)
+               Error = __net_telephony_modify_profile(profile_name, prof_info, &exProfInfo);
+       
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR,
+                               "Error!!! failed to modify service(profile) information. Error [%s]\n",
+                               _net_print_error(Error));
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+       
+       __NETWORK_FUNC_EXIT__;  
+
+       return NET_ERR_NONE;
+}
+
+
+EXPORT_API int net_get_profile_list(net_device_t device_type, net_profile_info_t **profile_list, int *count)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       int profile_count = 0;
+       net_profile_info_t* profile_info = NULL;
+
+       if (count == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid Parameter\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+       
+       if (NetworkInfo.ClientEventCb == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }       
+
+       if (device_type != NET_DEVICE_CELLULAR && device_type != NET_DEVICE_WIFI) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Not Supported\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_NOT_SUPPORTED;
+       }
+       
+       Error = _net_get_profile_list(device_type, &profile_info, &profile_count);
+
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR,
+                               "Error!!! failed to get service(profile) list. Error [%s]\n",
+                               _net_print_error(Error));
+               
+               NET_MEMFREE(profile_info);
+               
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       } else {
+               *count = profile_count;
+               *profile_list = profile_info;
+       }
+       
+       __NETWORK_FUNC_EXIT__;  
+       return NET_ERR_NONE;    
+}
+
+
+/*****************************************************************************
+ *     ConnMan Wi-Fi Client Interface Async Function Definition
+ *****************************************************************************/
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
diff --git a/src/network-signal-handler.c b/src/network-signal-handler.c
new file mode 100644 (file)
index 0000000..5dcb426
--- /dev/null
@@ -0,0 +1,884 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+
+/*****************************************************************************
+ *     Standard headers
+ *****************************************************************************/
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+
+#include <vconf.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+/*****************************************************************************
+ *     Platform headers
+ *****************************************************************************/
+
+#include "network-internal.h"
+#include "network-signal-handler.h"
+#include "network-dbus-request.h"
+
+/*****************************************************************************
+ *     Macros and Typedefs
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ *     Local Functions Declaration
+ *****************************************************************************/
+static DBusHandlerResult __net_signal_filter
+      (DBusConnection *conn, DBusMessage *msg, void *user_data);
+
+static int __net_get_state(DBusMessage *msg, char *state, char *error);
+static char* __net_get_property(DBusMessage* msg, char** property);
+static int __net_handle_scan_rsp(DBusMessage* msg);
+static int __net_handle_wifi_power_rsp(const char *state);
+static int __net_svc_error_string_to_enum(const char *error);
+static void __net_handle_svc_failure_ind(const char *profile_name, const char *svc_error);
+static void __net_handle_state_ind(const char* profile_name, net_state_type_t profile_state);
+
+/*****************************************************************************
+ *     Global Functions
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ *     Extern Global Variables
+ *****************************************************************************/
+extern network_info_t NetworkInfo;
+extern network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX];
+
+/*****************************************************************************
+ *     Extern Functions Declarations 
+ *****************************************************************************/
+
+/*****************************************************************************
+ *     Global Variables
+ *****************************************************************************/
+DBusConnection* signal_conn = NULL;
+static net_state_type_t service_state_table[NET_DEVICE_MAX] = {NET_STATE_TYPE_UNKNOWN,};
+
+/*****************************************************************************
+ *     Local Functions Definition
+ *****************************************************************************/
+
+static int __net_get_state(DBusMessage *msg, char *state, char *error)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       char *key_name = NULL;
+       char *svc_state = NULL;
+       char *svc_error = NULL;
+       DBusMessageIter iter, sub_iter;
+       int Error = NET_ERR_UNKNOWN;
+
+       /* 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 = NET_ERR_NONE;
+
+       /* Get error */
+       dbus_message_iter_next(&iter);
+       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, "Error") != 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_error);
+       snprintf(error, strlen(svc_error) + 1, "%s", svc_error);
+
+done:
+       __NETWORK_FUNC_EXIT__;
+       return Error;
+}
+
+static char* __net_get_property(DBusMessage* msg, char** property)
+{
+       DBusMessageIter args, variant;
+       char* sigvalue = NULL;
+
+       __NETWORK_FUNC_ENTER__;
+
+       if (!dbus_message_iter_init(msg, &args))
+       {
+               NETWORK_LOG( NETWORK_LOW, "Message does not have parameters\n");
+       }
+       else if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
+       {
+               NETWORK_LOG( NETWORK_LOW, "Argument is not string\n");
+       }
+       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;
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return sigvalue;
+
+}
+
+static int __net_handle_scan_rsp(DBusMessage* msg)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       int boolvalue = FALSE;
+       net_event_info_t event_data = {0,};
+
+       boolvalue = _net_get_boolean(msg);
+       if(boolvalue == TRUE)
+               event_data.Error = NET_ERR_NONE;
+       else
+               event_data.Error = NET_ERR_UNKNOWN;
+
+       NETWORK_LOG( NETWORK_LOW, "[Manager : ScanCompleted] Got Signal with value [%d]\n", boolvalue);
+
+       if(request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE)
+       {
+               memset(&request_table[NETWORK_REQUEST_TYPE_SCAN], 0, sizeof(network_request_table_t));
+
+               event_data.Event = NET_EVENT_WIFI_SCAN_RSP;
+               event_data.Datalength = 0;
+               event_data.Data = NULL;
+               NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_WIFI_SCAN_RSP\n");
+               _net_client_callback(&event_data);
+       }
+       else
+       {
+               event_data.Event = NET_EVENT_WIFI_SCAN_IND;
+               event_data.Datalength = 0;
+               event_data.Data = NULL;
+               NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_WIFI_SCAN_IND\n");
+               _net_client_callback(&event_data);
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+static int __net_handle_wifi_power_rsp(const char *state)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       int wifi_state_flag = 0;
+       net_event_info_t event_data = {0,};
+       int hotspot_state = 0;
+
+       vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &hotspot_state);
+       if (hotspot_state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) {
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_NONE;
+       }
+
+       if (strcmp(state, "offline") == 0 && NetworkInfo.wifi_state != WIFI_OFF) {
+               NetworkInfo.wifi_state = WIFI_OFF;
+               wifi_state_flag = 1;
+               event_data.Error = NET_ERR_NONE;
+
+               if(request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE)
+                       memset(&request_table[NETWORK_REQUEST_TYPE_SCAN],
+                                       0, sizeof(network_request_table_t));
+
+       } else if (strcmp(state, "enabled") == 0 && NetworkInfo.wifi_state != WIFI_ON) {
+               NetworkInfo.wifi_state = WIFI_ON;
+               wifi_state_flag = 1;
+               event_data.Error = NET_ERR_NONE;
+               usleep(300000); /* This will be removed after connman upgrade */
+       }
+
+       if (wifi_state_flag != 0) {
+               if (request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
+                       memset(&request_table[NETWORK_REQUEST_TYPE_WIFI_POWER],
+                                       0, sizeof(network_request_table_t));
+
+                       event_data.Event = NET_EVENT_WIFI_POWER_RSP;
+                       NETWORK_LOG(NETWORK_LOW,
+                                       "Sending NET_EVENT_WIFI_POWER_RSP  wifi state : %d\n",
+                                       NetworkInfo.wifi_state);
+               } else {
+                       event_data.Event = NET_EVENT_WIFI_POWER_IND;
+                       NETWORK_LOG(NETWORK_LOW,
+                                       "Sending NET_EVENT_WIFI_POWER_IND  wifi state : %d\n",
+                                       NetworkInfo.wifi_state);
+               }
+
+               event_data.Datalength = sizeof(net_wifi_state_t);
+               event_data.Data = &(NetworkInfo.wifi_state);
+               _net_client_callback(&event_data);
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+static int __net_svc_error_string_to_enum(const char *error)
+{
+       if (strcmp(error, "out-of-range") == 0)
+               return NET_ERR_CONNECTION_OUT_OF_RANGE;
+       else if(strcmp(error, "pin-missing") == 0)
+               return NET_ERR_CONNECTION_PIN_MISSING;
+       else if(strcmp(error, "dhcp-failed") == 0)
+               return NET_ERR_CONNECTION_DHCP_FAILED;
+       else if(strcmp(error, "connect-failed") == 0)
+               return NET_ERR_CONNECTION_CONNECT_FAILED;
+       else if(strcmp(error, "login-failed") == 0)
+               return NET_ERR_CONNECTION_LOGIN_FAILED;
+       else if(strcmp(error, "auth-failed") == 0)
+               return NET_ERR_CONNECTION_AUTH_FAILED;
+       else if(strcmp(error, "invalid-key") == 0)
+               return NET_ERR_CONNECTION_INVALID_KEY;
+
+       return NET_ERR_UNKNOWN;
+}
+
+static void __net_handle_svc_failure_ind(const char *profile_name, const char *svc_error)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_event_info_t event_data = {0,};
+       char event_string[64] = {0,};
+
+       char *svc_name1 = request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
+       char *svc_name2 = request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
+
+       if (request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
+           strcmp(profile_name, svc_name1) == 0) {
+
+               memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0,
+                               sizeof(network_request_table_t));
+
+               event_data.Event = NET_EVENT_OPEN_RSP;
+               g_strlcpy(event_string, "Sending NET_EVENT_OPEN_RSP", 64);
+       } else if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
+                  strcmp(profile_name, svc_name2) == 0) {
+
+               memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
+                               sizeof(network_request_table_t));
+
+               event_data.Event = NET_EVENT_WIFI_WPS_RSP;
+               g_strlcpy(event_string, "Sending NET_EVENT_WIFI_WPS_RSP", 64);
+       } else {
+               __net_handle_state_ind(profile_name, NET_STATE_TYPE_FAILURE);
+               __NETWORK_FUNC_EXIT__;
+               return;
+       }
+
+       snprintf(event_data.ProfileName,
+                       NET_PROFILE_NAME_LEN_MAX+1, "%s", profile_name);
+
+       event_data.Error = __net_svc_error_string_to_enum(svc_error);
+       event_data.Datalength = 0;
+       event_data.Data = NULL;
+
+       NETWORK_LOG(NETWORK_LOW, "%s, Error : %d\n", event_string, event_data.Error);
+       _net_client_callback(&event_data);
+
+       __NETWORK_FUNC_EXIT__;
+}
+
+static void __net_handle_state_ind(const char* profile_name, net_state_type_t profile_state)
+{
+       __NETWORK_FUNC_ENTER__;
+       
+       net_event_info_t event_data = {0,};
+       
+       event_data.Error = NET_ERR_NONE;
+       event_data.Event = NET_EVENT_NET_STATE_IND;
+
+       g_strlcpy(event_data.ProfileName, profile_name,
+                       sizeof(event_data.ProfileName));
+       
+       event_data.Datalength = sizeof(net_state_type_t);
+       event_data.Data = &profile_state;
+       
+       NETWORK_LOG(NETWORK_LOW, "Sending NET_EVENT_NET_STATE_IND, state : %d, profile name : %s\n",
+                       profile_state, event_data.ProfileName);
+
+       _net_client_callback(&event_data);
+       
+       __NETWORK_FUNC_EXIT__;
+}
+
+static DBusHandlerResult
+__net_signal_filter (DBusConnection* conn, DBusMessage* msg, void* user_data)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       static char svc_state[CONNMAN_MAX_BUFLEN] = "";
+       static char svc_error[CONNMAN_MAX_BUFLEN] = "";
+       static char ProfileName[NET_PROFILE_NAME_LEN_MAX + 1] = "";
+
+       static int open_connection_rsp_sent = FALSE;
+
+       const char* sig_path = NULL;
+       const char* svc_name1 = NULL;
+       const char* svc_name2 = NULL;
+       const char* svc_name3 = NULL;
+       
+       char* sigvalue = NULL;
+       net_event_info_t event_data = {0,};
+       net_err_t Error = NET_ERR_NONE;
+       net_device_t device_type = NET_DEVICE_UNKNOWN;
+       
+       if(msg == NULL)
+       {
+               NETWORK_LOG( NETWORK_LOW, "Invalid Message. Ignore\n");
+               /* We have handled this message, don't pass it on */
+               __NETWORK_FUNC_EXIT__;
+               return DBUS_HANDLER_RESULT_HANDLED;
+       }
+                               
+       if (dbus_message_is_signal(msg, CONNMAN_MANAGER_INTERFACE, CONNMAN_SIGNAL_PROPERTY_CHANGED))
+       {
+               sigvalue = _net_get_string(msg);
+               if(sigvalue == NULL)
+               {
+                       /* We have handled this message, don't pass it on */
+                       __NETWORK_FUNC_EXIT__;
+                       return DBUS_HANDLER_RESULT_HANDLED;
+               }
+               NETWORK_LOG( NETWORK_LOW, "[Manager : PropertyChanged] Got Signal with value [%s]\n", sigvalue);
+
+               if(strcmp(sigvalue, "Services") == 0)
+               {
+                       /** Ignore - compared for future use */
+               }
+               else if(strcmp(sigvalue, "ConnectedTechnologies") == 0)
+               {
+                       /** Ignore - compared for future use */
+               }
+               else if(strcmp(sigvalue, "State") == 0)
+               {
+                       /** Ignore - compared for future use */
+               }
+               else if(strcmp(sigvalue, "DefaultTechnology") == 0)
+               {
+                       /** Ignore - compared for future use */
+               }
+               else
+               {
+                       NETWORK_LOG( NETWORK_LOW, "-------[Manager : PropertyChanged]--------\n");
+               }
+
+               /* We have handled this message, don't pass it on */
+               __NETWORK_FUNC_EXIT__;
+               return DBUS_HANDLER_RESULT_HANDLED;
+       }
+       else if (dbus_message_is_signal(msg, CONNMAN_MANAGER_INTERFACE, CONNMAN_SIGNAL_STATE_CHANGED))
+       {
+               sigvalue = _net_get_string(msg);
+               if(sigvalue == NULL)
+               {
+                       /* We have handled this message, don't pass it on */
+                       __NETWORK_FUNC_EXIT__;
+                       return DBUS_HANDLER_RESULT_HANDLED;
+               }
+               NETWORK_LOG( NETWORK_LOW, "[Manager : StateChanged] Got Signal with value [%s]\n", sigvalue);
+
+               if(strcmp(sigvalue, "online") == 0)
+               {
+                       /** Ignore - compared for future use */
+               }
+
+               /* We have handled this message, don't pass it on */
+               __NETWORK_FUNC_EXIT__;
+               return DBUS_HANDLER_RESULT_HANDLED;
+       }
+       else if (dbus_message_is_signal(msg, CONNMAN_MANAGER_INTERFACE, CONNMAN_SIGNAL_SCAN_COMPLETED))
+       {
+               __net_handle_scan_rsp(msg);
+
+               /* We have handled this message, don't pass it on */
+               __NETWORK_FUNC_EXIT__;
+               return DBUS_HANDLER_RESULT_HANDLED;
+       }
+       else if (dbus_message_is_signal(msg, CONNMAN_TECHNOLOGY_INTERFACE, CONNMAN_SIGNAL_PROPERTY_CHANGED))
+       {
+               char* property = NULL;
+
+               sigvalue = __net_get_property(msg, &property);
+               if(sigvalue == NULL)
+               {
+                       /* We have handled this message, don't pass it on */
+                       __NETWORK_FUNC_EXIT__;
+                       return DBUS_HANDLER_RESULT_HANDLED;
+               }
+               
+               memset(ProfileName, 0, sizeof(ProfileName));
+               _net_get_path(msg, ProfileName);
+
+               NETWORK_LOG( NETWORK_LOW,
+                               "[Technology : PropertyChanged] Got Signal with value [%s] path [%s] state [%s]\n",
+                               sigvalue, ProfileName, property);
+
+               if(strstr(ProfileName, "/wifi") == NULL)
+               {
+                       __NETWORK_FUNC_EXIT__;
+                       return DBUS_HANDLER_RESULT_HANDLED;
+               }
+
+               if(strcmp(sigvalue, "State") == 0 && property != NULL)
+               {
+                       __net_handle_wifi_power_rsp(property);
+               }
+               /* We have handled this message, don't pass it on */
+               __NETWORK_FUNC_EXIT__;
+               return DBUS_HANDLER_RESULT_HANDLED;
+       }
+       else if (dbus_message_is_signal(msg, CONNMAN_SERVICE_INTERFACE, CONNMAN_SIGNAL_PROPERTY_CHANGED))
+       {
+               sigvalue = _net_get_string(msg);
+               if(sigvalue == NULL)
+               {
+                       /* We have handled this message, don't pass it on */
+                       __NETWORK_FUNC_EXIT__;
+                       return DBUS_HANDLER_RESULT_HANDLED;
+               }
+               NETWORK_LOG( NETWORK_LOW, "[Service : PropertyChanged] Got Signal with value [%s]\n", sigvalue);
+
+               if(strcmp(sigvalue, "Strength") == 0)
+               {
+                       /** Ignore - compared for future use */
+               }
+               else if(strcmp(sigvalue, "PassphraseRequired") == 0)
+               {
+                       /** Ignore - compared for future use */
+               }
+               else if(strcmp(sigvalue, "State") == 0)
+               {
+                       memset(ProfileName, 0, sizeof(ProfileName));
+                       _net_get_path(msg, ProfileName);
+
+                       device_type = _net_get_tech_type_from_path(ProfileName);
+
+                       if(device_type == NET_DEVICE_UNKNOWN)
+                       {
+                               /* We have handled this message, don't pass it on */
+                               __NETWORK_FUNC_EXIT__;
+                               return DBUS_HANDLER_RESULT_HANDLED;
+                       }
+
+                       sig_path = ProfileName;
+
+                       memset(svc_state, 0, sizeof(svc_state));
+                       memset(svc_error, 0, sizeof(svc_error));
+                       __net_get_state(msg, svc_state, svc_error);
+                       NETWORK_LOG(NETWORK_LOW, "Current ConnMan svc_state [%s] and svc_error [%s] for ProfileName [%s]\n",
+                                       svc_state, svc_error, ProfileName);
+
+                       if (device_type == NET_DEVICE_WIFI &&
+                           NetworkInfo.wifi_state == WIFI_OFF) {
+                               NETWORK_LOG(NETWORK_LOW, "Warning!! Wi-Fi is already off!!\n");
+                               /* We have handled this message, don't pass it on */
+                               __NETWORK_FUNC_EXIT__;
+                               return DBUS_HANDLER_RESULT_HANDLED;;
+                       }
+               
+                       if(strcmp(svc_state, "idle") == 0)
+                       {
+                               service_state_table[device_type] = NET_STATE_TYPE_IDLE;
+                               __net_handle_state_ind(ProfileName, NET_STATE_TYPE_IDLE);
+                       }
+                       else if(strcmp(svc_state, "association") == 0)
+                       {
+                               service_state_table[device_type] = NET_STATE_TYPE_ASSOCIATION;
+                               __net_handle_state_ind(ProfileName, NET_STATE_TYPE_ASSOCIATION);
+                       }
+                       else if(strcmp(svc_state, "configuration") == 0)
+                       {
+                               service_state_table[device_type] = NET_STATE_TYPE_CONFIGURATION;
+                               __net_handle_state_ind(ProfileName, NET_STATE_TYPE_CONFIGURATION);
+                       }
+                       else if(strcmp(svc_state, "ready") == 0 ||
+                               strcmp(svc_state, "online") == 0)
+                       {
+                               if(service_state_table[device_type] != NET_STATE_TYPE_READY &&
+                                  service_state_table[device_type] != NET_STATE_TYPE_ONLINE)
+                               {
+                                       svc_name1 = request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
+                                       svc_name2 = request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
+                                       
+                                       if(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
+                                          strcmp(sig_path, svc_name1) == 0)
+                                       {
+                                               memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0,
+                                                               sizeof(network_request_table_t));
+
+                                               event_data.Event =  NET_EVENT_OPEN_RSP;
+                                               NETWORK_LOG( NETWORK_LOW, "Sending NET_EVENT_OPEN_RSP\n");
+                                       }
+                                       else if(request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
+                                          strcmp(sig_path, svc_name2) == 0)
+                                       {
+                                               memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
+                                                               sizeof(network_request_table_t));
+
+                                               event_data.Event =  NET_EVENT_WIFI_WPS_RSP;
+                                               NETWORK_LOG( NETWORK_LOW, "Sending NET_EVENT_WIFI_WPS_RSP\n");
+                                       }
+                                       else
+                                       {
+                                               event_data.Event =  NET_EVENT_OPEN_IND;
+                                               NETWORK_LOG( NETWORK_LOW, "Sending NET_EVENT_OPEN_IND\n");
+                                       }
+
+                                       net_profile_info_t prof_info;
+                                       if((Error = net_get_profile_info(ProfileName, &prof_info)) != NET_ERR_NONE)
+                                       {
+                                               NETWORK_LOG( NETWORK_ERROR, "Error!!! net_get_profile_info() failed [%s]\n",
+                                                               _net_print_error(Error));
+                                               event_data.Datalength = 0;
+                                               event_data.Data = NULL;
+                                       }
+                                       else
+                                       {
+                                               event_data.Datalength = sizeof(net_profile_info_t);
+                                               event_data.Data = &prof_info;
+                                       }
+
+                                       event_data.Error = Error;
+                                       snprintf(event_data.ProfileName, NET_PROFILE_NAME_LEN_MAX + 1, "%s", ProfileName);
+                                       open_connection_rsp_sent = TRUE;
+                                       _net_client_callback(&event_data);
+                               }
+                               else
+                               {
+                                       if (strcmp(svc_state, "ready") == 0)
+                                               __net_handle_state_ind(ProfileName, NET_STATE_TYPE_READY);
+                                       else
+                                               __net_handle_state_ind(ProfileName, NET_STATE_TYPE_ONLINE);
+                               }
+
+                               if (strcmp(svc_state, "ready") == 0)
+                                       service_state_table[device_type] = NET_STATE_TYPE_READY;
+                               else
+                                       service_state_table[device_type] = NET_STATE_TYPE_ONLINE;
+                       }
+                       else if(strcmp(svc_state, "disconnect") == 0)
+                       {
+                               svc_name1 = request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].ProfileName;
+                               svc_name2 = request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].ProfileName;
+                               svc_name3 = request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName;
+
+                               if(request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION].flag == TRUE &&
+                                  strcmp(sig_path, svc_name2) == 0)
+                               {
+                                       memset(&request_table[NETWORK_REQUEST_TYPE_OPEN_CONNECTION], 0,
+                                                       sizeof(network_request_table_t));
+
+                                       /** Send Open Resp */
+                                       event_data.Error = NET_ERR_OPERATION_ABORTED;
+                                       event_data.Event =  NET_EVENT_OPEN_RSP;
+                                       snprintf(event_data.ProfileName,
+                                                       NET_PROFILE_NAME_LEN_MAX+1, "%s", ProfileName);
+
+                                       event_data.Datalength = 0;
+                                       event_data.Data = NULL;
+                                       NETWORK_LOG( NETWORK_LOW, "Sending NET_EVENT_OPEN_RSP\n");
+                                       _net_client_callback(&event_data);
+                               }
+                               else if(request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE &&
+                                       strcmp(sig_path, svc_name3) == 0)
+                               {
+                                       memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0,
+                                                       sizeof(network_request_table_t));
+
+                                       /** Send WPS Resp */
+                                       event_data.Error = NET_ERR_OPERATION_ABORTED;
+                                       event_data.Event =  NET_EVENT_WIFI_WPS_RSP;
+                                       snprintf(event_data.ProfileName,
+                                                       NET_PROFILE_NAME_LEN_MAX+1, "%s", ProfileName);
+
+                                       event_data.Datalength = 0;
+                                       event_data.Data = NULL;
+                                       NETWORK_LOG( NETWORK_LOW, "Sending NET_EVENT_WIFI_WPS_RSP\n");
+                                       _net_client_callback(&event_data);
+                               }
+                               else if(request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE &&
+                                  strcmp(sig_path, svc_name1) == 0)
+                               {
+                                       memset(&request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION], 0, 
+                                                       sizeof(network_request_table_t));
+
+                                       /** Send Close Resp */
+                                       event_data.Error = Error;
+                                       event_data.Event =  NET_EVENT_CLOSE_RSP;
+                                       snprintf(event_data.ProfileName,
+                                                       NET_PROFILE_NAME_LEN_MAX+1, "%s", ProfileName);
+
+                                       event_data.Datalength = 0;
+                                       event_data.Data = NULL;
+                                       NETWORK_LOG( NETWORK_LOW, "Sending NET_EVENT_CLOSE_RSP\n");
+                                       _net_client_callback(&event_data);
+
+                               }
+                               else
+                               {
+                                       /** Send Close Ind */
+                                       event_data.Error = Error;
+                                       event_data.Event =  NET_EVENT_CLOSE_IND;
+                                       snprintf(event_data.ProfileName,
+                                                       NET_PROFILE_NAME_LEN_MAX+1, "%s", ProfileName);
+
+                                       event_data.Datalength = 0;
+                                       event_data.Data = NULL;
+                                       NETWORK_LOG( NETWORK_LOW, "Sending NET_EVENT_CLOSE_IND\n");
+                                       _net_client_callback(&event_data);
+                               }
+
+                               service_state_table[device_type] = NET_STATE_TYPE_DISCONNECT;
+                       }
+                       else if(strcmp(svc_state, "failure") == 0)
+                       {
+                               __net_handle_svc_failure_ind(sig_path, (char*)svc_error);
+                               service_state_table[device_type] = NET_STATE_TYPE_FAILURE;
+                               __NETWORK_FUNC_EXIT__;
+                               return DBUS_HANDLER_RESULT_HANDLED;
+                       }
+               }
+               else if(strcmp(sigvalue, "Nameservers") == 0)
+               {
+                       /* We have handled this message, don't pass it on */
+                       __NETWORK_FUNC_EXIT__;
+                       return DBUS_HANDLER_RESULT_HANDLED;
+               }
+               else if(strcmp(sigvalue, "IPv4") == 0)
+               {
+                       /** Ignore - compared for future use */
+               }
+               else if(strcmp(sigvalue, "Ethernet") == 0)
+               {
+                       /** Ignore - compared for future use */
+               }
+               else if(strcmp(sigvalue, "Domains") == 0)
+               {
+                       /** Ignore - compared for future use */
+               }
+               else if(strcmp(sigvalue, "IPv4.Configuration") == 0)
+               {
+                       /** Ignore - compared for future use */
+               }
+               else
+               {
+                       /** Ignore - compared for future use */
+               }
+
+               /* We have handled this message, don't pass it on */
+               __NETWORK_FUNC_EXIT__;
+               return DBUS_HANDLER_RESULT_HANDLED;
+       }
+
+       if (dbus_message_is_signal(msg, CONNMAN_COUNTER_INTERFACE, "Usage"))
+       {
+               NETWORK_LOG( NETWORK_LOW, "Received [COUNTER_USAGE_SIGNAL] signal from modman\n");
+       }
+       else if (dbus_message_is_signal(msg, CONNMAN_COUNTER_INTERFACE, "Release"))
+       {
+               NETWORK_LOG( NETWORK_LOW, "Received [COUNTER_RELEASE_SIGNAL] signal from modman\n");
+       }
+
+       NETWORK_LOG( NETWORK_LOW, "Useless signal. Ignored !!!\n");
+       __NETWORK_FUNC_EXIT__;
+       return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+/*****************************************************************************
+ *     Global Functions
+ *****************************************************************************/
+
+int _net_deregister_signal(void)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       if (signal_conn == NULL) {
+               NETWORK_LOG(NETWORK_HIGH, "Already de-registered. Nothing to be done\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_NONE;
+       }
+
+       dbus_connection_remove_filter(signal_conn, __net_signal_filter, NULL);
+       NETWORK_LOG(NETWORK_HIGH, "dbus_connection_remove_filter() successful\n");
+       NETWORK_LOG(NETWORK_LOW, "Successfully removed signal filter rules\n");
+
+       /* If DBusPendingCall remains, it should be released */
+       if (_net_dbus_is_pending_call_used() == TRUE)
+       {
+               dbus_pending_call_cancel(_net_dbus_get_pending_call());
+               _net_dbus_set_pending_call(NULL);
+               _net_dbus_set_pending_call_used(FALSE);
+               NETWORK_LOG(NETWORK_HIGH, "DBus pending call successfully removed\n");
+       }
+
+       dbus_connection_unref(signal_conn);
+       signal_conn = NULL;
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+int _net_register_signal(void)
+{
+       DBusConnection* conn = NULL;
+       DBusError err;
+
+       __NETWORK_FUNC_ENTER__;
+
+       dbus_error_init(&err);
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); 
+       if (conn == NULL) {
+               NETWORK_LOG(NETWORK_EXCEPTION, "Error!!! Failed to connect to the D-BUS daemon: [%s]\n", err.message);
+               dbus_error_free(&err);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       signal_conn = 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)) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Match Error (%s)\n", err.message);
+               dbus_error_free(&err);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       dbus_bus_add_match(conn, CONNMAN_TECHNOLOGY_SIGNAL_FILTER, &err); 
+       dbus_connection_flush(conn);
+       if (dbus_error_is_set(&err)) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Match Error (%s)\n", err.message);
+               dbus_error_free(&err);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       dbus_bus_add_match(conn, CONNMAN_SERVICE_SIGNAL_FILTER, &err);
+       dbus_connection_flush(conn);
+       if (dbus_error_is_set(&err)) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Match Error (%s)\n", err.message);
+               dbus_error_free(&err);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       dbus_bus_add_match(conn, CONNMAN_NETWORK_COUNTER_FILTER, &err); 
+       dbus_connection_flush(conn);
+       if (dbus_error_is_set(&err)) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Match Error (%s)\n", err.message);
+               dbus_error_free(&err);
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+
+       if (dbus_connection_add_filter(conn, __net_signal_filter, NULL, NULL) == FALSE) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! dbus_connection_add_filter() failed\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_UNKNOWN;
+       }
+       
+       NETWORK_LOG(NETWORK_LOW, "Successfully set signal filter rules\n");
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+int _net_init_service_state_table(void)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       net_cm_network_status_t network_status;
+
+       Error = net_get_network_status(NET_DEVICE_WIFI, &network_status);
+       if (Error != NET_ERR_NONE) {
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       if (network_status == NET_STATUS_AVAILABLE)
+               service_state_table[NET_DEVICE_WIFI] = NET_STATE_TYPE_READY;
+
+       Error = net_get_network_status(NET_DEVICE_CELLULAR, &network_status);
+       if (Error != NET_ERR_NONE) {
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       if (network_status == NET_STATUS_AVAILABLE)
+               service_state_table[NET_DEVICE_CELLULAR] = NET_STATE_TYPE_READY;
+
+       NETWORK_LOG(NETWORK_HIGH, "init service state table. wifi:%d, cellular:%d\n",
+                       service_state_table[NET_DEVICE_WIFI],
+                       service_state_table[NET_DEVICE_CELLULAR]);
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
diff --git a/src/network-wifi-intf.c b/src/network-wifi-intf.c
new file mode 100644 (file)
index 0000000..8e2f260
--- /dev/null
@@ -0,0 +1,444 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+
+/*****************************************************************************
+ *     Standard headers
+ *****************************************************************************/
+#include <stdio.h> 
+#include <errno.h> 
+#include <stdlib.h> 
+#include <string.h>
+#include <glib.h>
+
+#include <vconf.h>
+#include <dbus/dbus.h> 
+
+/*****************************************************************************
+ *     Platform headers
+ *****************************************************************************/
+
+#include "network-internal.h"
+#include "network-signal-handler.h"
+#include "network-dbus-request.h"
+
+/*****************************************************************************
+ *     Macros and Typedefs
+ *****************************************************************************/
+
+/*****************************************************************************
+ *     Local Functions Declaration
+ *****************************************************************************/
+
+static net_wifi_state_t __net_get_wifi_service_state();
+
+/*****************************************************************************
+ *     Global Functions
+ *****************************************************************************/
+
+
+/*****************************************************************************
+ *     Extern Variables
+ *****************************************************************************/
+
+extern network_info_t NetworkInfo;
+extern network_request_table_t request_table[NETWORK_REQUEST_TYPE_MAX];
+
+/*****************************************************************************
+ *     Global Variables
+ *****************************************************************************/
+
+/*****************************************************************************
+ *     Local Functions Definition
+ *****************************************************************************/
+
+static net_wifi_state_t __net_get_wifi_service_state(char *profile_name)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       net_wifi_state_t wifi_state = NetworkInfo.wifi_state;
+       int profile_count = 0;
+       int i = 0;
+       net_profile_info_t* profile_info = NULL;
+
+       Error = _net_get_profile_list(NET_DEVICE_WIFI, &profile_info, &profile_count);
+
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR,
+                               "Error!!! failed to get service(profile) list. Error [%s]\n",
+                               _net_print_error(Error));
+
+               NET_MEMFREE(profile_info);
+
+               __NETWORK_FUNC_EXIT__;
+               return wifi_state;
+       }
+
+       for (i = 0;i < profile_count;i++) {
+               switch (profile_info->ProfileState) {
+               case NET_STATE_TYPE_ASSOCIATION :
+               case NET_STATE_TYPE_CONFIGURATION :
+                       wifi_state = WIFI_CONNECTING;
+                       g_strlcpy(profile_name, profile_info->ProfileName,
+                                       sizeof(profile_info->ProfileName));
+                       break;
+               case NET_STATE_TYPE_READY :
+               case NET_STATE_TYPE_ONLINE :
+                       wifi_state = WIFI_CONNECTED;
+                       g_strlcpy(profile_name, profile_info->ProfileName,
+                                       sizeof(profile_info->ProfileName));
+                       break;
+               case NET_STATE_TYPE_UNKNOWN :
+               case NET_STATE_TYPE_IDLE :
+               case NET_STATE_TYPE_FAILURE :
+               case NET_STATE_TYPE_DISCONNECT :
+                       break;
+               }
+               profile_info++;
+       }
+
+       if (wifi_state == WIFI_CONNECTED &&
+           request_table[NETWORK_REQUEST_TYPE_CLOSE_CONNECTION].flag == TRUE)
+               wifi_state = WIFI_DISCONNECTING;
+
+       __NETWORK_FUNC_EXIT__;
+       return wifi_state;
+}
+
+/*****************************************************************************
+ *     ConnMan Wi-Fi Client Interface Async API Definition
+ *****************************************************************************/
+
+EXPORT_API int net_open_connection_with_wifi_info(const net_wifi_connection_info_t *wifi_info)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+
+       if (wifi_info == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid parameter\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       if (NetworkInfo.ClientEventCb == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+
+       if (_net_get_wifi_state() != WIFI_ON) {
+               NETWORK_LOG( NETWORK_ERROR, "Error!!! wifi is powered off!\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_OPERATION;
+       }
+
+       Error = _net_open_connection_with_wifi_info(wifi_info);
+       if (Error != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! net_open_connection_with_wifi_info() failed. Error [%s]\n",
+                               _net_print_error(Error));
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+
+EXPORT_API int net_wifi_power_on(void)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+       int hotspot_state = 0;
+
+       if (NetworkInfo.ClientEventCb == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+
+       vconf_get_int(VCONFKEY_MOBILE_HOTSPOT_MODE, &hotspot_state);
+       if (hotspot_state & VCONFKEY_MOBILE_HOTSPOT_MODE_WIFI) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Wi-Fi hotspot is enabled!\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_OPERATION;
+       }
+
+       if (NetworkInfo.wifi_state != WIFI_OFF) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! wifi is powered on already!\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_OPERATION;
+       }
+
+       if (request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
+               NETWORK_LOG(NETWORK_ASSERT, "Error!! Request already in progress\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_OPERATION;
+       }
+
+       request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag = TRUE;
+
+       Error = _net_dbus_load_wifi_driver();
+       if (Error != NET_ERR_NONE ) {
+               NETWORK_LOG(NETWORK_EXCEPTION,
+                               "Error!!! Failed to request wifi power on/off. Error [%s]\n",
+                               _net_print_error(Error));
+               memset(&request_table[NETWORK_REQUEST_TYPE_WIFI_POWER], 0, sizeof(network_request_table_t));
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+
+EXPORT_API int net_wifi_power_off(void)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+
+       if(NetworkInfo.ClientEventCb == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+
+       if(NetworkInfo.wifi_state == WIFI_OFF) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! wifi is powered off already!\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_OPERATION;
+       }
+
+       if (request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag == TRUE) {
+               NETWORK_LOG(NETWORK_ASSERT, "Error!! Request already in progress\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_OPERATION;
+       }
+
+       request_table[NETWORK_REQUEST_TYPE_WIFI_POWER].flag = TRUE;
+
+       Error = _net_dbus_remove_wifi_driver();
+       if (Error != NET_ERR_NONE ) {
+               NETWORK_LOG(NETWORK_EXCEPTION,
+                               "Error!!! Failed to request wifi power on/off. Error [%s]\n",
+                               _net_print_error(Error));
+               memset(&request_table[NETWORK_REQUEST_TYPE_WIFI_POWER], 0, sizeof(network_request_table_t));
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+
+       NETWORK_LOG(NETWORK_HIGH, "Driver remove successfully\n");
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+
+EXPORT_API int net_scan_wifi(void)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+
+       if(NetworkInfo.ClientEventCb == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+
+       if(request_table[NETWORK_REQUEST_TYPE_SCAN].flag == TRUE) {
+               NETWORK_LOG(NETWORK_ASSERT, "Error!! Request already in progress\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_OPERATION;
+       }
+
+       if (_net_get_wifi_state() != WIFI_ON) {
+               NETWORK_LOG( NETWORK_ERROR, "Error!!! wifi is powered off!\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_OPERATION;
+       }
+
+       request_table[NETWORK_REQUEST_TYPE_SCAN].flag = TRUE;
+
+       if ((Error = _net_dbus_scan_request()) != NET_ERR_NONE ) {
+               NETWORK_LOG(NETWORK_EXCEPTION,
+                               "Error!!! Failed to request scan. Error [%s]\n",
+                               _net_print_error(Error));
+               memset(&request_table[NETWORK_REQUEST_TYPE_SCAN], 0, sizeof(network_request_table_t));
+               __NETWORK_FUNC_EXIT__;
+               return Error;;
+       }
+
+       NETWORK_LOG(NETWORK_HIGH, "ConnMan successfully finished Wi-Fi scanning\n");
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+
+EXPORT_API int net_wifi_enroll_wps(const char *profile_name, net_wifi_wps_info_t *wps_info)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+
+       if (_net_check_profile_name(profile_name) != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Invalid ProfileName passed\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       if (NetworkInfo.ClientEventCb == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+
+       if (_net_get_wifi_state() != WIFI_ON) {
+               NETWORK_LOG( NETWORK_ERROR, "Error!!! wifi is powered off!\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_OPERATION;
+       }
+
+       if (request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag == TRUE) {
+               NETWORK_LOG(NETWORK_ASSERT, "Error!! Request already in progress\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_OPERATION;
+       }
+       
+       request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].flag = TRUE;
+       snprintf(request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS].ProfileName,
+                       NET_PROFILE_NAME_LEN_MAX+1, "%s", profile_name);
+
+       if(wps_info->type == WIFI_WPS_PBC) {
+               Error = _net_dbus_open_connection(profile_name);
+               if(Error != NET_ERR_NONE)
+               {
+                       NETWORK_LOG(NETWORK_ERROR,
+                                       "Error!! Failed to request open connection, Error [%s]\n", 
+                                       _net_print_error(Error));
+                       
+                       memset(&request_table[NETWORK_REQUEST_TYPE_ENROLL_WPS], 0, sizeof(network_request_table_t));
+                       
+                       __NETWORK_FUNC_EXIT__;
+                       return Error;
+               }
+       }
+       else if(wps_info->type == WIFI_WPS_PIN) {
+               // TODO: handle wps pin
+       }
+       else {
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_PARAM;
+       }
+       
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+/*****************************************************************************
+ *     ConnMan Wi-Fi Client Interface Sync Function Definition
+ *****************************************************************************/
+
+
+EXPORT_API int net_get_wifi_state(net_wifi_state_t *current_state, net_profile_name_t *profile_name)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_wifi_state_t wifi_state;
+
+       if (NetworkInfo.ClientEventCb == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application was not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+
+       if (profile_name == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! profile_name is NULL\n");
+               return NET_ERR_INVALID_PARAM;
+       }
+
+       memset(profile_name, 0, sizeof(net_profile_name_t));
+
+       wifi_state = _net_get_wifi_state();
+
+       if (wifi_state == WIFI_OFF) {
+               *current_state = WIFI_OFF;
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_NONE;
+       }
+
+       *current_state = __net_get_wifi_service_state(profile_name->ProfileName);
+       
+       NETWORK_LOG(NETWORK_HIGH, "current state : %d, profile name : %s\n",
+                       *current_state, profile_name->ProfileName);
+
+       __NETWORK_FUNC_EXIT__;
+       return NET_ERR_NONE;
+}
+
+
+EXPORT_API int net_wifi_set_background_scan_mode(net_wifi_background_scan_mode_t scan_mode)
+{
+       __NETWORK_FUNC_ENTER__;
+
+       net_err_t Error = NET_ERR_NONE;
+               
+       if (NetworkInfo.ClientEventCb == NULL) {
+               NETWORK_LOG(NETWORK_ERROR, "Error!!! Application not registered\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_APP_NOT_REGISTERED;
+       }
+
+       if (_net_get_wifi_state() != WIFI_ON) {
+               NETWORK_LOG( NETWORK_ERROR, "Error!!! wifi is powered off!\n");
+               __NETWORK_FUNC_EXIT__;
+               return NET_ERR_INVALID_OPERATION;
+       }
+
+       NETWORK_LOG(NETWORK_HIGH,  "BGScan Mode [%d]\n", scan_mode);
+
+       if ((Error = _net_dbus_set_bgscan_mode(scan_mode)) != NET_ERR_NONE) {
+               NETWORK_LOG(NETWORK_EXCEPTION,
+                               "Error!!! Failed to set bgscan mode. Error [%s]\n",
+                               _net_print_error(Error));
+
+               __NETWORK_FUNC_EXIT__;
+               return Error;
+       }
+               
+       NETWORK_LOG(NETWORK_HIGH, "Set BGScan mode Request to connman is successfull\n");
+       
+       __NETWORK_FUNC_EXIT__;  
+       return NET_ERR_NONE;
+}
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
diff --git a/test/build.sh b/test/build.sh
new file mode 100755 (executable)
index 0000000..7b02dbb
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+rm -f network_client
+
+gcc -Wall -g -O2 -o ./network_client ./main.c `pkg-config dbus-1 glib-2.0 dbus-glib-1 network --cflags --libs` 
+
diff --git a/test/main.c b/test/main.c
new file mode 100644 (file)
index 0000000..54c7eac
--- /dev/null
@@ -0,0 +1,1434 @@
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.tizenopensource.org/license
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifdef HAVE_CONFIG_H 
+#include <config.h> 
+#endif 
+#include <stdio.h> 
+#include <errno.h> 
+#include <stdlib.h> 
+#include <string.h> 
+#include <glib.h>
+
+#include <dbus/dbus.h> 
+
+#include <network-pm-config.h>
+#include <network-cm-intf.h>
+#include <network-pm-intf.h>
+#include <network-wifi-intf.h>
+
+#define debug_print(format, args...) printf("[%s][Ln: %d] " format, __FILE__, __LINE__, ##args)
+
+#define Convert_time2double(timevar) ((double)timevar.tv_sec+(double)timevar.tv_usec/1000000.0)
+
+#define        MAIN_MEMFREE(x) do {if (x != NULL) free(x); x = NULL;} while(0)
+
+typedef enum {
+       PROFILE_FULL_INFO = 0x01,
+       PROFILE_PARTIAL_INFO,
+       PROFILE_BASIC_INFO
+} profile_print_type_t;
+
+double start_time = 0;
+double finish_time = 0;
+double async_time = 0;
+struct timeval timevar;
+
+GMainLoop *mainloop = NULL;
+
+static void __print_profile_list(int num_of_profile,
+               net_profile_info_t* profile_table, profile_print_type_t print_type);
+static void __network_print_profile(net_profile_info_t* ProfInfo, profile_print_type_t print_type);
+static void __network_print_ipaddress(net_addr_t* ip_address);
+
+static void __network_evt_cb (net_event_info_t*  event_cb, void* user_data);
+
+static void __network_print_ipaddress(net_addr_t* ip_address)
+{
+       unsigned char *ipaddr;
+       ipaddr = (unsigned char *)&ip_address->Data.Ipv4.s_addr;
+       debug_print("Profile IP Address = [%d.%d.%d.%d]\n",
+                       ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]);
+}
+
+static void __network_print_profile(net_profile_info_t* ProfInfo, profile_print_type_t print_type)
+{
+       net_pdp_profile_info_t *pdp_info = &ProfInfo->ProfileInfo.Pdp;
+       net_wifi_profile_info_t *wlan_info = &ProfInfo->ProfileInfo.Wlan;
+
+       int di = 0;
+       unsigned char *ipaddr;
+       unsigned char *netmaskaddr;
+       unsigned char *gwaddr;
+       net_dev_info_t *net_info;
+
+       if (ProfInfo->profile_type == NET_DEVICE_WIFI) {
+               ipaddr = (unsigned char *)&wlan_info->net_info.IpAddr.Data.Ipv4.s_addr;
+               netmaskaddr = (unsigned char *)&wlan_info->net_info.SubnetMask.Data.Ipv4.s_addr;
+               gwaddr = (unsigned char *)&wlan_info->net_info.GatewayAddr.Data.Ipv4.s_addr;
+               net_info = &(wlan_info->net_info);
+       } else if (ProfInfo->profile_type == NET_DEVICE_CELLULAR) {
+               ipaddr = (unsigned char *)&pdp_info->net_info.IpAddr.Data.Ipv4.s_addr;
+               netmaskaddr = (unsigned char *)&pdp_info->net_info.SubnetMask.Data.Ipv4.s_addr;
+               gwaddr = (unsigned char *)&pdp_info->net_info.GatewayAddr.Data.Ipv4.s_addr;
+               net_info = &(pdp_info->net_info);
+       } else {
+               debug_print("Error!!! Invalid profile type\n");
+               return ;
+       }
+
+       debug_print("Profile Name = [%s]\n", ProfInfo->ProfileName);
+       
+       if (ProfInfo->ProfileState == NET_STATE_TYPE_IDLE)
+               debug_print("Profile State = [idle]\n");
+       else if (ProfInfo->ProfileState == NET_STATE_TYPE_FAILURE)
+               debug_print("Profile State = [failure]\n");
+       else if (ProfInfo->ProfileState == NET_STATE_TYPE_ASSOCIATION)
+               debug_print("Profile State = [association]\n");
+       else if (ProfInfo->ProfileState == NET_STATE_TYPE_CONFIGURATION)
+               debug_print("Profile State = [configuration]\n");
+       else if (ProfInfo->ProfileState == NET_STATE_TYPE_READY)
+               debug_print("Profile State = [ready]\n");
+       else if (ProfInfo->ProfileState == NET_STATE_TYPE_ONLINE)
+               debug_print("Profile State = [online]\n");
+       else if (ProfInfo->ProfileState == NET_STATE_TYPE_DISCONNECT)
+               debug_print("Profile State = [disconnect]\n");
+       else 
+               debug_print("Profile State = [unknown]\n");
+
+       if (ProfInfo->profile_type == NET_DEVICE_WIFI) {
+               debug_print("Profile Type = [wifi]\n");
+               debug_print("Profile ESSID = [%s]\n", wlan_info->essid);
+               debug_print("Profile BSSID = [%s]\n", wlan_info->bssid);
+
+               if (print_type == PROFILE_PARTIAL_INFO ||
+                   print_type == PROFILE_FULL_INFO) {
+                       debug_print("Profile Strength = [%d]\n", (int)wlan_info->Strength);
+                       debug_print("Profile Frequency = [%d]\n", (int)wlan_info->frequency);
+                       debug_print("Profile Max Rate = [%d]\n", (int)wlan_info->max_rate);
+                       debug_print("Profile Passphrase Required = [%d]\n",
+                                       (int)wlan_info->PassphraseRequired);
+
+                       if (wlan_info->wlan_mode == NETPM_WLAN_CONNMODE_INFRA)
+                               debug_print("Profile Wlan mode = [NETPM_WLAN_CONNMODE_INFRA]\n");
+                       else if (wlan_info->wlan_mode == NETPM_WLAN_CONNMODE_ADHOC)
+                               debug_print("Profile Wlan mode = [NETPM_WLAN_CONNMODE_ADHOC]\n");
+                       else
+                               debug_print("Profile Wlan mode = [NETPM_WLAN_CONNMODE_AUTO]\n");
+
+                       debug_print("Profile Security mode = [%d]\n",
+                                       (int)wlan_info->security_info.sec_mode);
+                       debug_print("Profile Encryption mode = [%d]\n",
+                                       (int)wlan_info->security_info.enc_mode);
+                       debug_print("Profile Security key = [%s]\n",
+                                       wlan_info->security_info.authentication.psk.pskKey);
+                       debug_print("Profile WPS support = [%d]\n",
+                                       (int)wlan_info->security_info.wps_support);
+               }
+       } else if (ProfInfo->profile_type == NET_DEVICE_CELLULAR) {
+               debug_print("Profile Type = [pdp]\n");
+               
+               if (print_type == PROFILE_PARTIAL_INFO ||
+                   print_type == PROFILE_FULL_INFO) {
+
+                       if (pdp_info->ProtocolType == NET_PDP_TYPE_GPRS)
+                               debug_print("Profile Protocol Type = [GPRS]\n");
+                       else if (pdp_info->ProtocolType == NET_PDP_TYPE_EDGE)
+                               debug_print("Profile Protocol Type = [EDGE]\n");
+                       else if (pdp_info->ProtocolType == NET_PDP_TYPE_UMTS)
+                               debug_print("Profile Protocol Type = [UMTS]\n");
+                       else
+                               debug_print("Profile Protocol Type = [NONE]\n");
+
+                       if (pdp_info->ServiceType == NET_SERVICE_INTERNET)
+                               debug_print("Profile Service Type = [Internet]\n");
+                       else if (pdp_info->ServiceType == NET_SERVICE_MMS)
+                               debug_print("Profile Service Type = [MMS]\n");
+                       else if (pdp_info->ServiceType == NET_SERVICE_WAP)
+                               debug_print("Profile Service Type = [WAP]\n");
+                       else if (pdp_info->ServiceType == NET_SERVICE_PREPAID_INTERNET)
+                               debug_print("Profile Service Type = [Prepaid Internet]\n");
+                       else if (pdp_info->ServiceType == NET_SERVICE_PREPAID_MMS)
+                               debug_print("Profile Service Type = [Prepaid MMS]\n");
+                       else
+                               debug_print("Profile Service Type = [Unknown]\n");
+
+                       debug_print("Profile APN = [%s]\n", pdp_info->Apn);
+
+                       if (pdp_info->AuthInfo.AuthType == NET_PDP_AUTH_PAP)
+                               debug_print("Profile Auth Type = [PAP]\n");
+                       else if (pdp_info->AuthInfo.AuthType == NET_PDP_AUTH_CHAP)
+                               debug_print("Profile Auth Type = [CHAP]\n");
+                       else
+                               debug_print("Profile Auth Type = [NONE]\n");
+
+                       debug_print("Profile Auth UserName = [%s]\n", pdp_info->AuthInfo.UserName);
+                       debug_print("Profile Auth Password = [%s]\n", pdp_info->AuthInfo.Password);
+
+                       debug_print("Profile Home URL = [%s]\n", pdp_info->HomeURL);
+                       debug_print("Profile MCC = [%s]\n", pdp_info->Mcc);
+                       debug_print("Profile MNC = [%s]\n", pdp_info->Mnc);
+                       debug_print("Profile Roaming = [%d]\n", (int)pdp_info->Roaming);
+                       debug_print("Profile Setup Required = [%d]\n",
+                                       (int)pdp_info->SetupRequired);
+               }
+       }
+
+       if (print_type == PROFILE_FULL_INFO) {
+               unsigned char *dns = (unsigned char *)&net_info->DnsAddr[di].Data.Ipv4.s_addr;
+
+               debug_print("Profile Favourite = [%d]\n", (int)ProfInfo->Favourite);
+               debug_print("Profile Device Name = [%s]\n", net_info->DevName);
+               debug_print("Profile DNS Count = [%d]\n", net_info->DnsCount);
+
+               for (di = 0;di < net_info->DnsCount;di++)
+                       debug_print("Profile DNS Address %d = [%d.%d.%d.%d]\n",
+                                       di+1, dns[0], dns[1], dns[2], dns[3]);
+
+               if (net_info->IpConfigType == NET_IP_CONFIG_TYPE_DYNAMIC)
+                       debug_print("Profile IPv4 Method = [NET_IP_CONFIG_TYPE_DYNAMIC]\n");
+               else if (net_info->IpConfigType == NET_IP_CONFIG_TYPE_STATIC)
+                       debug_print("Profile IPv4 Method = [NET_IP_CONFIG_TYPE_STATIC]\n");
+               else if (net_info->IpConfigType == NET_IP_CONFIG_TYPE_FIXED)
+                       debug_print("Profile IPv4 Method = [NET_IP_CONFIG_TYPE_FIXED]\n");
+               else if (net_info->IpConfigType == NET_IP_CONFIG_TYPE_OFF)
+                       debug_print("Profile IPv4 Method = [NET_IP_CONFIG_TYPE_OFF]\n");
+               else
+                       debug_print("Profile IPv4 Method = [UNKNOWN]\n");
+
+               debug_print("Profile IP Address = [%d.%d.%d.%d]\n",
+                               ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]);
+               debug_print("Profile Netmask = [%d.%d.%d.%d]\n",
+                               netmaskaddr[0], netmaskaddr[1], netmaskaddr[2], netmaskaddr[3]);
+               debug_print("Profile Gateway = [%d.%d.%d.%d]\n",
+                               gwaddr[0], gwaddr[1], gwaddr[2], gwaddr[3]);
+
+               if (net_info->ProxyMethod == NET_PROXY_TYPE_DIRECT)
+                       debug_print("Proxy Method = [direct]\n");
+               else if (net_info->ProxyMethod == NET_PROXY_TYPE_AUTO)
+                       debug_print("Proxy Method = [auto]\n");
+               else if (net_info->ProxyMethod == NET_PROXY_TYPE_MANUAL)
+                       debug_print("Proxy Method = [manual]\n");
+               else
+                       debug_print("Proxy Method = [unknown]\n");
+
+               debug_print("Profile Proxy = [%s]\n", net_info->ProxyAddr);
+               debug_print("Profile MAC = [%s]\n", net_info->MacAddr);
+       }
+}
+
+static void __print_profile_list(int num_of_profile,
+               net_profile_info_t* profile_table, profile_print_type_t print_type)
+{
+       debug_print("num_of_profile [%d], Profiles [%p]\n",
+                       num_of_profile, profile_table);
+
+       if (num_of_profile > 0 && profile_table != NULL) {
+               int ci = 0;
+               for (ci = 0;ci < num_of_profile;ci++)
+                       __network_print_profile(profile_table + ci, print_type);
+       }
+}
+
+static void __network_evt_cb (net_event_info_t*  event_cb, void* user_data)
+{
+       net_profile_info_t *prof_info = NULL;
+
+       debug_print("==CM Event callback==\n");
+
+       switch (event_cb->Event)        {
+       case NET_EVENT_WIFI_SCAN_IND:
+               if (event_cb->Error != NET_ERR_NONE) {
+                       debug_print("Got NET_EVENT_WIFI_SCAN_IND. Scan failed!, Error [%d]\n",
+                                       event_cb->Error);
+                       break;
+               }
+
+               debug_print("Got NET_EVENT_WIFI_SCAN_IND\n");
+               break;
+
+       case NET_EVENT_WIFI_SCAN_RSP:
+               if (event_cb->Error != NET_ERR_NONE) {
+                       debug_print("Got NET_EVENT_WIFI_SCAN_RSP. Scan failed!, Error [%d]\n",
+                                       event_cb->Error);
+                       break;
+               }
+
+               debug_print("Got NET_EVENT_WIFI_SCAN_RSP\n");
+
+               int num_of_profile = 0;
+               int Error;
+               net_profile_info_t* Profiles = NULL;
+
+               Error = net_get_profile_list(NET_DEVICE_WIFI, &Profiles, &num_of_profile);
+               if (Error != NET_ERR_NONE) {
+                       debug_print("Error!!! failed to get service(profile) list. Error [%d]\n",
+                                       Error);
+               } else {
+                       debug_print("network_dbus_get_scan_result() successfull\n");
+                       debug_print("........................Scan Table.......................\n");
+                       __print_profile_list(num_of_profile, Profiles, PROFILE_BASIC_INFO);
+                       debug_print(".........................................................\n");
+               }
+
+               MAIN_MEMFREE(Profiles);
+
+               gettimeofday(&timevar, NULL);
+               async_time = Convert_time2double(timevar);
+               debug_print("Async Resp total time taken = [%f]\n", async_time - finish_time);
+
+               break;
+
+       case NET_EVENT_IP_CHANGE_IND:
+               debug_print("Got IP Change Indication.\n");
+               break;
+
+       case NET_EVENT_OPEN_IND:
+       case NET_EVENT_OPEN_RSP:
+               if (event_cb->Event == NET_EVENT_OPEN_RSP)
+                       debug_print("Got Open RSP\n");
+               else
+                       debug_print("Got Open Indication. Auto Joined\n");
+
+               gettimeofday(&timevar, NULL);
+               async_time = Convert_time2double(timevar);
+               debug_print("Async Resp total time taken = [%f]\n", async_time - finish_time);
+
+               debug_print("Received ACTIVATION response: %d \n", event_cb->Error);
+
+               switch (event_cb->Error) {
+               case NET_ERR_NONE:
+                       /* Successful PDP Activation */
+                       if (event_cb->Datalength != sizeof(net_profile_info_t)) {
+                               debug_print("Activation succeeded, but can't get profile info\n");
+                       } else {
+                               prof_info = (net_profile_info_t*)event_cb->Data;
+                               __network_print_profile(prof_info, PROFILE_FULL_INFO);
+                       }
+                       break;
+               case NET_ERR_TIME_OUT:
+                       debug_print("Request time out!\n");
+                       break;
+               case NET_ERR_IN_PROGRESS:
+                       debug_print("Connction is in progress!\n");
+                       break;
+               case NET_ERR_ACTIVE_CONNECTION_EXISTS:
+                       /* Successful PDP Activation(share the existing connection) */
+                       if (event_cb->Datalength != sizeof(net_profile_info_t)) {
+                               debug_print("Activation succeeded, but can't get profile info\n");
+                       } else {
+                               prof_info = (net_profile_info_t*)event_cb->Data;
+                               __network_print_profile(prof_info, PROFILE_FULL_INFO);
+                       }
+                       break;
+               case NET_ERR_OPERATION_ABORTED:
+                       debug_print("Connction is aborted!\n");
+                       break;
+               case NET_ERR_UNKNOWN_METHOD:
+                       debug_print("Service not found!\n");
+                       break;
+               case NET_ERR_UNKNOWN:
+                       debug_print("Activation Failed!\n");
+                       break;
+               default:
+                       debug_print("Unknown Error!\n");
+                       break;
+               }
+
+               break;
+
+       case NET_EVENT_CLOSE_RSP:
+               debug_print("Got Close RSP\n");
+
+               gettimeofday(&timevar, NULL);
+               async_time = Convert_time2double(timevar);
+               debug_print("Async Resp total time taken = [%f]\n", async_time - finish_time);
+
+               switch (event_cb->Error) {
+               case NET_ERR_NONE:
+                       /* Successful PDP Deactivation */
+                       debug_print("Deactivation succeeded!\n");
+                       break;
+               case NET_ERR_TIME_OUT:
+                       debug_print("Request time out!\n");
+                       break;
+               case NET_ERR_IN_PROGRESS:
+                       debug_print("Disconncting is in progress!\n");
+                       break;
+               case NET_ERR_OPERATION_ABORTED:
+                       debug_print("Disconnction is aborted!\n");
+                       break;
+               case NET_ERR_UNKNOWN_METHOD:
+                       debug_print("Service not found!\n");
+                       break;
+               case NET_ERR_UNKNOWN:
+                       debug_print("Deactivation Failed!\n");
+                       break;
+               default:
+                       debug_print("Unknown Error!\n");
+                       break;
+               }
+
+               break;
+
+       case NET_EVENT_CLOSE_IND:
+               debug_print("Got Close IND\n");
+               break;
+
+       case NET_EVENT_WIFI_POWER_IND:
+       case NET_EVENT_WIFI_POWER_RSP:
+               if (event_cb->Event == NET_EVENT_WIFI_POWER_RSP)
+                       debug_print("Got Wi-Fi Power RSP\n");
+               else
+                       debug_print("Got Wi-Fi Power IND\n");
+
+               net_wifi_state_t *wifi_state = (net_wifi_state_t*)event_cb->Data;
+
+               if (event_cb->Error == NET_ERR_NONE &&
+                   event_cb->Datalength == sizeof(net_wifi_state_t)) {
+                       if (*wifi_state == WIFI_ON)
+                               debug_print("Wi-Fi State : Power ON\n");
+                       else if (*wifi_state == WIFI_OFF)
+                               debug_print("Wi-Fi State : Power OFF\n");
+                       else
+                               debug_print("Wi-Fi State : Unknown\n");
+               } else
+                       debug_print("Wi-Fi Power on/off request failed! Error [%d]\n",
+                                       event_cb->Error);
+
+               break;
+
+       case NET_EVENT_NET_STATE_IND:
+               debug_print("Got State changed IND\n");
+               net_state_type_t *profile_state = (net_state_type_t*)event_cb->Data;
+
+               if (event_cb->Error == NET_ERR_NONE &&
+                   event_cb->Datalength == sizeof(net_state_type_t)) {
+                       switch (*profile_state) {
+                       case NET_STATE_TYPE_IDLE:
+                               debug_print("Wi-Fi State : Idle, profile name : %s\n",
+                                               event_cb->ProfileName);
+                               break;
+                       case NET_STATE_TYPE_FAILURE:
+                               debug_print("Wi-Fi State : Failure, profile name : %s\n",
+                                               event_cb->ProfileName);
+                               break;
+                       case NET_STATE_TYPE_ASSOCIATION:
+                               debug_print("Wi-Fi State : Association, profile name : %s\n",
+                                               event_cb->ProfileName);
+                               break;
+                       case NET_STATE_TYPE_CONFIGURATION:
+                               debug_print("Wi-Fi State : Configuration, profile name : %s\n",
+                                               event_cb->ProfileName);
+                               break;
+                       case NET_STATE_TYPE_READY:
+                               debug_print("Wi-Fi State : Ready, profile name : %s\n",
+                                               event_cb->ProfileName);
+                               break;
+                       case NET_STATE_TYPE_ONLINE:
+                               debug_print("Wi-Fi State : Online, profile name : %s\n",
+                                               event_cb->ProfileName);
+                               break;
+                       case NET_STATE_TYPE_DISCONNECT:
+                               debug_print("Wi-Fi State : Disconnect, profile name : %s\n",
+                                               event_cb->ProfileName);
+                               break;
+                       default :
+                               debug_print("Wi-Fi State : unknown\n");
+                               break;
+                       }
+               }
+               break;
+
+       case NET_EVENT_WIFI_WPS_RSP:
+               debug_print("Got WPS Rsp\n");
+               break;
+
+       default :
+               debug_print("Error! Unknown Event\n\n");
+               break;
+       }
+
+}
+
+int __network_modify_profile_info(net_profile_info_t *profile_info)
+{
+       net_dev_info_t *net_info2 = &profile_info->ProfileInfo.Wlan.net_info;
+       wlan_security_info_t *security_info2 =
+                       &profile_info->ProfileInfo.Wlan.security_info;
+       net_pdp_profile_info_t *pdp_info = &profile_info->ProfileInfo.Pdp;
+       char input_str[100] = {0,};
+       int ei = 0;
+
+       if (profile_info->profile_type == NET_DEVICE_WIFI) {
+               debug_print("\nInput Passphrase(Enter for skip) :\n");
+
+               memset(input_str, '\0', 100);
+               read(0, input_str, 100);
+
+               input_str[strlen(input_str) - 1] = '\0';
+
+               if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
+                       g_strlcpy(security_info2->authentication.psk.pskKey,
+                                       input_str, NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN + 1);
+
+               debug_print("\nInput Proxy Type(1:direct, 2:auto, 3:manual - current:%d)"
+                               " - (Enter for skip) :\n", net_info2->ProxyMethod);
+
+               memset(input_str, '\0', 100);
+               read(0, input_str, 100);
+
+               input_str[strlen(input_str) - 1] = '\0';
+
+               if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r') {
+                       int proxyType = 0;
+                       proxyType = atoi(input_str);
+
+                       if (proxyType == NET_PROXY_TYPE_DIRECT)
+                               net_info2->ProxyMethod = NET_PROXY_TYPE_DIRECT;
+                       else if (proxyType == NET_PROXY_TYPE_AUTO)
+                               net_info2->ProxyMethod = NET_PROXY_TYPE_AUTO;
+                       else if (proxyType == NET_PROXY_TYPE_MANUAL)
+                               net_info2->ProxyMethod = NET_PROXY_TYPE_MANUAL;
+
+                       if (net_info2->ProxyMethod == NET_PROXY_TYPE_AUTO ||
+                           net_info2->ProxyMethod == NET_PROXY_TYPE_MANUAL) {
+
+                               if (net_info2->ProxyMethod == NET_PROXY_TYPE_AUTO)
+                                       debug_print("\nInput auto Proxy URL - "
+                                                       "(Enter for DHCP/WPAD auto-discover) :\n");
+                               else
+                                       debug_print("\nInput manual Proxy address - "
+                                                       "(Enter for skip) :\n");
+
+                               memset(input_str, '\0', 100);
+                               read(0, input_str, 100);
+
+                               if (input_str[0] != '\0' &&
+                                   *input_str != '\n' &&
+                                   *input_str != '\r') {
+                                       input_str[strlen(input_str)-1] = '\0';
+                                       g_strlcpy(net_info2->ProxyAddr,
+                                                       input_str, NET_PROXY_LEN_MAX + 1);
+                               } else {
+                                       net_info2->ProxyAddr[0] = '\0';
+                               }
+                       }
+               }
+
+               debug_print("\nInput IPv4 Address Type dhcp/manual (Enter for skip) :\n");
+
+               memset(input_str, '\0', 100);
+               read(0, input_str, 100);
+
+               input_str[strlen(input_str) - 1] = '\0';
+
+               if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r') {
+                       if (strcmp(input_str, "dhcp") == 0) {
+                               net_info2->IpConfigType = NET_IP_CONFIG_TYPE_DYNAMIC;
+                       } else if (strcmp(input_str, "manual") == 0) {
+                               net_info2->IpConfigType = NET_IP_CONFIG_TYPE_STATIC;
+
+                               debug_print("\nInput IP Address (Enter for skip) :\n");
+
+                               memset(input_str, '\0', 100);
+                               read(0, input_str, 100);
+
+                               input_str[strlen(input_str) - 1] = '\0';
+
+                               if ((input_str[0] != '\0' &&
+                                    *input_str != '\n' &&
+                                    *input_str != '\r') &&
+                                   strlen(input_str) >= NETPM_IPV4_STR_LEN_MIN) {
+                                       inet_aton(input_str, &(net_info2->IpAddr.Data.Ipv4));
+                               }
+
+                               debug_print("\nInput Netmask (Enter for skip) :\n");
+
+                               memset(input_str, '\0', 100);
+                               read(0, input_str, 100);
+
+                               input_str[strlen(input_str) - 1] = '\0';
+
+                               if ((input_str[0] != '\0' &&
+                                    *input_str != '\n' &&
+                                    *input_str != '\r') &&
+                                   strlen(input_str) >= NETPM_IPV4_STR_LEN_MIN) {
+                                       inet_aton(input_str, &(net_info2->SubnetMask.Data.Ipv4));
+                               }
+
+                               debug_print("\nInput Gateway (Enter for skip) :\n");
+
+                               memset(input_str, '\0', 100);
+                               read(0, input_str, 100);
+
+                               input_str[strlen(input_str)-1] = '\0';
+
+                               if ((input_str[0] != '\0' &&
+                                    *input_str != '\n' &&
+                                    *input_str != '\r') &&
+                                   strlen(input_str) >= NETPM_IPV4_STR_LEN_MIN) {
+                                       inet_aton(input_str, &(net_info2->GatewayAddr.Data.Ipv4));
+                               }
+                       }
+               }
+
+               if (net_info2->IpConfigType == NET_IP_CONFIG_TYPE_STATIC) {
+                       for (ei = 0;ei < NET_DNS_ADDR_MAX;ei++) {
+                               debug_print("\nInput DNS %d Address(Enter for skip) :\n", ei);
+
+                               memset(input_str, '\0', 100);
+                               read(0, input_str, 100);
+
+                               input_str[strlen(input_str)-1] = '\0';
+
+                               if (input_str[0] != '\0' &&
+                                   *input_str != '\n' &&
+                                   *input_str != '\r') {
+                                       inet_aton(input_str, &(net_info2->DnsAddr[ei].Data.Ipv4));
+                                       net_info2->DnsCount = ei+1;
+                               } else {
+                                       return FALSE;
+                               }
+                       }
+               }
+       } else if (profile_info->profile_type == NET_DEVICE_CELLULAR) {
+               debug_print("\nInput Apn(current:%s) - (Enter for skip) :\n", pdp_info->Apn);
+
+               memset(input_str, '\0', 100);
+               read(0, input_str, 100);
+
+               input_str[strlen(input_str)-1] = '\0';
+
+               if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
+                       g_strlcpy(pdp_info->Apn, input_str, NET_PDP_APN_LEN_MAX+1);
+
+               debug_print("\nInput Proxy(current:%s) - (Enter for skip) :\n",
+                               pdp_info->net_info.ProxyAddr);
+
+               memset(input_str, '\0', 100);
+               read(0, input_str, 100);
+
+               input_str[strlen(input_str)-1] = '\0';
+
+               if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
+                       g_strlcpy(pdp_info->net_info.ProxyAddr, input_str, NET_PROXY_LEN_MAX+1);
+
+               debug_print("\nInput HomeURL(current:%s) - (Enter for skip) :\n",
+                               pdp_info->HomeURL);
+
+               memset(input_str, '\0', 100);
+               read(0, input_str, 100);
+
+               input_str[strlen(input_str)-1] = '\0';
+
+               if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
+                       g_strlcpy(pdp_info->HomeURL, input_str, NET_HOME_URL_LEN_MAX+1);
+
+               debug_print("\nInput AuthType(0:None, 1:PAP, 2:CHAP - current:%d)"
+                               " - (Enter for skip) :\n", pdp_info->AuthInfo.AuthType);
+
+               memset(input_str, '\0', 100);
+               read(0, input_str, 100);
+
+               if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r') {
+                       int typeValue = 0;
+                       typeValue = atoi(input_str);
+
+                       if(typeValue == NET_PDP_AUTH_PAP)
+                               pdp_info->AuthInfo.AuthType = NET_PDP_AUTH_PAP;
+                       else if(typeValue == NET_PDP_AUTH_CHAP)
+                               pdp_info->AuthInfo.AuthType = NET_PDP_AUTH_CHAP;
+                       else
+                               pdp_info->AuthInfo.AuthType = NET_PDP_AUTH_NONE;
+               }
+
+               if (pdp_info->AuthInfo.AuthType == NET_PDP_AUTH_PAP ||
+                   pdp_info->AuthInfo.AuthType == NET_PDP_AUTH_CHAP) {
+                       debug_print("\nInput AuthId(current:%s) - (Enter for skip) :\n",
+                                       pdp_info->AuthInfo.UserName);
+
+                       memset(input_str, '\0', 100);
+                       read(0, input_str, 100);
+
+                       input_str[strlen(input_str)-1] = '\0';
+
+                       if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
+                               g_strlcpy(pdp_info->AuthInfo.UserName,
+                                               input_str, NET_PDP_AUTH_USERNAME_LEN_MAX+1);
+
+                       debug_print("\nInput AuthPwd(current:%s) - (Enter for skip) :\n",
+                                       pdp_info->AuthInfo.Password);
+
+                       memset(input_str, '\0', 100);
+                       read(0, input_str, 100);
+
+                       input_str[strlen(input_str)-1] = '\0';
+
+                       if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
+                               g_strlcpy(pdp_info->AuthInfo.Password,
+                                               input_str, NET_PDP_AUTH_PASSWORD_LEN_MAX+1);
+               }
+       }
+       return TRUE;
+}
+
+int __network_add_profile_info(net_profile_info_t *profile_info)
+{
+       net_pdp_profile_info_t *pdp_info = &profile_info->ProfileInfo.Pdp;
+       char input_str[100] = {0,};
+
+       debug_print("\nInput Apn - (Enter for skip) :\n");
+
+       memset(input_str, '\0', 100);
+       read(0, input_str, 100);
+
+       input_str[strlen(input_str)-1] = '\0';
+
+       if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
+               g_strlcpy(pdp_info->Apn, input_str, NET_PDP_APN_LEN_MAX+1);
+       else
+               pdp_info->Apn[0] = '\0';
+
+       debug_print("\nInput Proxy - (Enter for skip) :\n");
+
+       memset(input_str, '\0', 100);
+       read(0, input_str, 100);
+
+       input_str[strlen(input_str)-1] = '\0';
+
+       if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
+               g_strlcpy(pdp_info->net_info.ProxyAddr, input_str, NET_PROXY_LEN_MAX+1);
+       else
+               pdp_info->net_info.ProxyAddr[0] = '\0';
+
+       debug_print("\nInput HomeURL - (Enter for skip) :\n");
+
+       memset(input_str, '\0', 100);
+       read(0, input_str, 100);
+
+       input_str[strlen(input_str)-1] = '\0';
+
+       if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
+               g_strlcpy(pdp_info->HomeURL, input_str, NET_HOME_URL_LEN_MAX+1);
+       else
+               pdp_info->HomeURL[0] = '\0';
+
+       debug_print("\nInput AuthType(0:NONE 1:PAP 2:CHAP) - (Enter for skip) :\n");
+
+       memset(input_str, '\0', 100);
+       read(0, input_str, 100);
+
+       if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r') {
+               int typeValue = 0;
+               typeValue = atoi(input_str);
+
+               if (typeValue == NET_PDP_AUTH_PAP)
+                       pdp_info->AuthInfo.AuthType = NET_PDP_AUTH_PAP;
+               else if (typeValue == NET_PDP_AUTH_CHAP)
+                       pdp_info->AuthInfo.AuthType = NET_PDP_AUTH_CHAP;
+               else
+                       pdp_info->AuthInfo.AuthType = NET_PDP_AUTH_NONE;
+       } else {
+               pdp_info->AuthInfo.AuthType = NET_PDP_AUTH_NONE;
+       }
+
+       if (pdp_info->AuthInfo.AuthType == NET_PDP_AUTH_PAP ||
+           pdp_info->AuthInfo.AuthType == NET_PDP_AUTH_CHAP) {
+               debug_print("\nInput AuthId - (Enter for skip) :\n");
+
+               memset(input_str, '\0', 100);
+               read(0, input_str, 100);
+
+               input_str[strlen(input_str)-1] = '\0';
+
+               if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
+                       g_strlcpy(pdp_info->AuthInfo.UserName,
+                                       input_str, NET_PDP_AUTH_USERNAME_LEN_MAX+1);
+               else
+                       pdp_info->AuthInfo.UserName[0] = '\0';
+
+               debug_print("\nInput AuthPwd - (Enter for skip) :\n");
+
+               memset(input_str, '\0', 100);
+               read(0, input_str, 100);
+
+               input_str[strlen(input_str)-1] = '\0';
+
+               if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r')
+                       g_strlcpy(pdp_info->AuthInfo.Password,
+                                       input_str, NET_PDP_AUTH_PASSWORD_LEN_MAX+1);
+               else
+                       pdp_info->AuthInfo.Password[0] = '\0';
+       }
+
+       return TRUE;
+}
+
+static gpointer network_main_gthread(gpointer data)
+{
+       char ProfileName[NET_PROFILE_NAME_LEN_MAX+1] = {0,};
+       int input_int = 0;
+       char input_str[100] = {0,};
+       int net_error = 0;
+       net_profile_info_t profile_info;
+
+       if (net_register_client ((net_event_cb_t) __network_evt_cb, NULL) != NET_ERR_NONE) {
+               debug_print("Error!! net_register_client() failed.\n");
+               return NULL;
+       }
+
+       debug_print( "net_register_client() successfull\n");
+
+       while (TRUE) {
+               fd_set rfds;
+
+               int retval;
+               FD_ZERO(&rfds);
+               FD_SET(0, &rfds);
+
+               retval = select((0+1), &rfds, NULL, NULL, NULL);
+
+               if (retval <= 0)
+                       continue;
+
+               if (!FD_ISSET(0, &rfds))
+                       continue;
+
+               debug_print("Event received from stdin \n");
+               char user_input[100];
+
+               memset(user_input, '\0', 100);
+               read(0, user_input, 100);
+
+               if (user_input[0] == '9')
+                       exit(1);
+
+               if (*user_input == '\n' || *user_input == '\r') {
+                       debug_print("\nDatanetworking Test .......\n\n");
+                       debug_print("Options..\n");
+                       debug_print("0  - WLAN Power On request\n");
+                       debug_print("1  - WLAN Power Off request\n");
+                       debug_print("2  - WLAN Start scan request\n");
+                       debug_print("3  - WLAN Set BG Scan Mode\n");
+                       debug_print("4  - Open Connection with service type\n");
+                       debug_print("5  - Open Connection with profile name\n");
+                       debug_print("6  - Close Connection\n");
+                       debug_print("7  - Get WiFi State\n");
+                       debug_print("a  - Check whether connected?\n");
+                       debug_print("b  - Get Network Status\n");
+                       debug_print("c  - Get Active(default) profile information\n");
+                       debug_print("d  - Get Profile list\n");
+                       debug_print("e  - Get Profile info\n");
+                       debug_print("f  - Modify Profile info\n");
+                       debug_print("g  - Delete Profile(PDP:delete, WiFi:forgot) \n");
+                       debug_print("h  - Add Profile(PDP only) \n");
+                       debug_print("i  - Connect to Specific SSID\n");
+                       debug_print("k  - Enroll WPS PBC \n");
+                       debug_print("l  - Connect with EAP\n");
+                       debug_print("z  - Exit \n");
+
+                       debug_print("ENTER      - Show options menu.......\n");
+               }
+
+               switch (user_input[0]) {
+               case '0':
+                       gettimeofday(&timevar, NULL);
+                       start_time = Convert_time2double(timevar);
+
+                       if (net_wifi_power_on() != NET_ERR_NONE) {
+                               debug_print("Error!! net_wifi_power_on() failed.\n");
+                               break;
+                       }
+
+                       gettimeofday(&timevar, NULL);
+                       finish_time = Convert_time2double(timevar);
+                       debug_print("Total time taken = [%f]\n", finish_time - start_time);
+
+                       debug_print("net_wifi_power_on() success\n");
+                       break;
+
+               case '1':
+                       gettimeofday(&timevar, NULL);
+                       start_time = Convert_time2double(timevar);
+
+                       if (net_wifi_power_off() != NET_ERR_NONE ) {
+                               debug_print("Error!! net_wifi_power_off() failed.\n");
+                               break;
+                       }
+
+                       gettimeofday(&timevar, NULL);
+                       finish_time = Convert_time2double(timevar);
+                       debug_print("Total time taken = [%f]\n", finish_time - start_time);
+
+                       debug_print("net_wifi_power_off() success\n");
+                       break;
+
+               case '2':
+                       gettimeofday(&timevar, NULL);
+                       start_time = Convert_time2double(timevar);
+
+                       if (net_scan_wifi() != NET_ERR_NONE ) {
+                               debug_print("Error!! net_scan_wifi() failed.\n");
+                               break;
+                       }
+
+                       gettimeofday(&timevar, NULL);
+                       finish_time = Convert_time2double(timevar);
+                       debug_print("Total time taken = [%f]\n", finish_time - start_time);
+
+                       debug_print("net_scan_wifi() success\n");
+                       break;
+
+               case '3':
+                       debug_print("Enter BG Scan Mode(0:default, 1:periodic, 2:exponential):");
+                       scanf("%d", &input_int);
+
+                       gettimeofday(&timevar, NULL);
+                       start_time = Convert_time2double(timevar);
+
+                       if (net_wifi_set_background_scan_mode(input_int) != NET_ERR_NONE) {
+                               debug_print(
+                                       "Error!! network_wifi_set_scan_interval() failed.\n");
+                               break;
+                       }
+
+                       gettimeofday(&timevar, NULL);
+                       finish_time = Convert_time2double(timevar);
+                       debug_print("Total time taken = [%f]\n", finish_time - start_time);
+
+                       debug_print("network_wifi_set_background_scan_mode() success\n");
+                       break;
+
+               case '4':
+                       debug_print( "Enter Service Type(1:Internet, 2:MMS, 3:WAP): \n");
+                       scanf("%d", &input_int);
+
+                       net_service_type_t service_type = NET_SERVICE_UNKNOWN;
+
+                       gettimeofday(&timevar, NULL);
+                       start_time = Convert_time2double(timevar);
+
+                       switch (input_int) {
+                       case 1:
+                               service_type = NET_SERVICE_INTERNET;
+                               break;
+                       case 2:
+                               service_type = NET_SERVICE_MMS;
+                               break;
+                       case 3:
+                               service_type = NET_SERVICE_WAP;
+                               break;
+                       }
+
+                       if (service_type != NET_SERVICE_UNKNOWN) {
+                               net_error = net_open_connection_with_preference(service_type);
+                               if (net_error != NET_ERR_NONE) {
+                                       debug_print(
+                                         "Error!! net_open_connection_with_profile() failed.\n");
+                                       break;
+                               }
+                       }
+
+                       gettimeofday(&timevar, NULL);
+                       finish_time = Convert_time2double(timevar);
+                       debug_print("Total time taken = [%f]\n", finish_time - start_time);
+
+                       debug_print("net_open_connection_with_profile() success\n");
+                       break;
+
+               case '5':
+                       debug_print( "Enter Profile Name: \n");
+                       scanf("%s", ProfileName);
+
+                       gettimeofday(&timevar, NULL);
+                       start_time = Convert_time2double(timevar);
+
+                       if (net_open_connection_with_profile(ProfileName) != NET_ERR_NONE) {
+                               debug_print(
+                                       "Error!! net_open_connection_with_profile() failed.\n");
+                               break;
+                       }
+
+                       gettimeofday(&timevar, NULL);
+                       finish_time = Convert_time2double(timevar);
+                       debug_print("Total time taken = [%f]\n", finish_time - start_time);
+
+                       debug_print("net_open_connection_with_profile() success\n");
+                       break;
+
+               case '6':
+                       debug_print( "Enter Profile Name: \n");
+                       scanf("%s", ProfileName);
+
+                       gettimeofday(&timevar, NULL);
+                       start_time = Convert_time2double(timevar);
+
+                       if (net_close_connection(ProfileName) != NET_ERR_NONE) {
+                               debug_print(
+                                       "Error!! net_close_connection() failed.\n");
+                               break;
+                       }
+
+                       gettimeofday(&timevar, NULL);
+                       finish_time = Convert_time2double(timevar);
+                       debug_print("Total time taken = [%f]\n", finish_time - start_time);
+
+                       debug_print("net_close_connection() success\n");
+                       break;
+
+               case '7':
+                       gettimeofday(&timevar, NULL);
+                       start_time = Convert_time2double(timevar);
+
+                       net_wifi_state_t wlanstate = 0;
+                       net_profile_name_t profile_name;
+
+                       if (net_get_wifi_state(&wlanstate, &profile_name) != NET_ERR_NONE) {
+                               debug_print("Error!! net_get_wifi_state() failed.\n");
+                               break;
+                       }
+
+                       gettimeofday(&timevar, NULL);
+                       finish_time = Convert_time2double(timevar);
+                       debug_print("net_get_wifi_state() success. wlanstate [%d]\n", wlanstate);
+                       debug_print("Total time taken = [%f]\n", finish_time - start_time);
+
+                       switch (wlanstate) {
+                       case WIFI_OFF:
+                               debug_print("wlanstate : WIFI_OFF\n");
+                               break;
+                       case WIFI_ON:
+                               debug_print("wlanstate : WIFI_ON\n");
+                               break;
+                       case WIFI_CONNECTING:
+                               debug_print("wlanstate : WIFI_CONNECTING, profile name : %s\n",
+                                               profile_name.ProfileName);
+                               break;
+                       case WIFI_CONNECTED:
+                               debug_print("wlanstate : WIFI_CONNECTED, profile name : %s\n",
+                                               profile_name.ProfileName);
+                               break;
+                       case WIFI_DISCONNECTING:
+                               debug_print("wlanstate : WIFI_DISCONNECTING, profile name : %s\n",
+                                               profile_name.ProfileName);
+                               break;
+                       default :
+                               debug_print("wlanstate : Unknown\n");
+                       }
+                       break;
+
+               case 'a':
+                       gettimeofday(&timevar, NULL);
+                       start_time = Convert_time2double(timevar);
+
+                       int flag = FALSE;
+
+                       flag = net_is_connected();
+                       debug_print("[%s]\n", (flag == TRUE)? "connected":"not connected");
+
+                       gettimeofday(&timevar, NULL);
+                       finish_time = Convert_time2double(timevar);
+                       debug_print("Total time taken = [%f]\n", finish_time - start_time);
+
+                       break;
+
+               case 'b':
+                       debug_print("Enter network type (wifi/pdp): \n");
+                       scanf("%s", input_str);
+
+                       net_device_t device_type = NET_DEVICE_UNKNOWN;
+                       net_cm_network_status_t NetworkStatus;
+
+                       if (strcmp(input_str, "wifi") == 0)
+                               device_type = NET_DEVICE_WIFI;
+                       else
+                               device_type = NET_DEVICE_CELLULAR;
+
+                       gettimeofday(&timevar, NULL);
+                       start_time = Convert_time2double(timevar);
+
+                       if (net_get_network_status(device_type, &NetworkStatus) != NET_ERR_NONE) {
+                               debug_print("Error!!! net_get_network_status() failed\n");
+                               break;
+                       }
+
+                       debug_print("[%s]\n", (NET_STATUS_AVAILABLE == NetworkStatus) ?
+                                       "NET_STATUS_AVAILABLE":"NET_STATUS_UNAVAILABLE");
+
+                       gettimeofday(&timevar, NULL);
+                       finish_time = Convert_time2double(timevar);
+                       debug_print("Total time taken = [%f]\n", finish_time - start_time);
+
+                       break;
+
+               case 'c':
+                       debug_print("Enter info Type(1:Full, 2:ip, 3:netmask, 4:gateway,"
+                                                  " 5:DNS, 6:ESSID, 7:Proxy):\n");
+                       scanf("%d", &input_int);
+
+                       memset(&profile_info, 0, sizeof(net_profile_info_t));
+
+                       net_addr_t ip_address;
+                       net_essid_t essid;
+                       net_proxy_t proxy;
+
+                       gettimeofday(&timevar, NULL);
+                       start_time = Convert_time2double(timevar);
+
+                       switch (input_int) {
+                       case 1:
+                               if (net_get_active_net_info(&profile_info) != NET_ERR_NONE)
+                                       debug_print("Error!!! net_get_active_net_info() failed\n");
+                               else
+                                       __network_print_profile(&profile_info, PROFILE_FULL_INFO);
+                               break;
+                       case 2:
+                               if (net_get_active_ipaddress(&ip_address) != NET_ERR_NONE)
+                                       debug_print("Error!!! net_get_active_ipaddress() failed\n");
+                               else
+                                       __network_print_ipaddress(&ip_address);
+                               break;
+                       case 3:
+                               if (net_get_active_netmask(&ip_address) != NET_ERR_NONE)
+                                       debug_print("Error!!! net_get_active_netmask() failed\n");
+                               else
+                                       __network_print_ipaddress(&ip_address);
+                               break;
+                       case 4:
+                               if (net_get_active_gateway(&ip_address) != NET_ERR_NONE)
+                                       debug_print("Error!!! net_get_active_gateway() failed\n");
+                               else
+                                       __network_print_ipaddress(&ip_address);
+                               break;
+                       case 5:
+                               if (net_get_active_dns(&ip_address) != NET_ERR_NONE)
+                                       debug_print("Error!!! net_get_active_dns() failed\n");
+                               else
+                                       __network_print_ipaddress(&ip_address);
+                               break;
+                       case 6:
+                               if (net_get_active_essid(&essid) != NET_ERR_NONE)
+                                       debug_print("Error!!! net_get_active_essid() failed\n");
+                               else
+                                       debug_print("Profile ESSID = [%s]\n", essid.essid);
+                               break;
+                       case 7:
+                               if (net_get_active_proxy(&proxy) != NET_ERR_NONE)
+                                       debug_print("Error!!! net_get_active_proxy() failed\n");
+                               else
+                                       debug_print("Profile Proxy = [%s]\n", proxy.proxy_addr);
+                               break;
+                       }
+
+                       gettimeofday(&timevar, NULL);
+                       finish_time = Convert_time2double(timevar);
+                       debug_print("Total time taken = [%f]\n", finish_time - start_time);
+                       break;
+
+               case 'd':
+                       debug_print("\nInput profile type - 1:wifi, 2:mobile (Enter for skip):\n");
+                       memset(input_str, 0, 100);
+                       read(0, input_str, 100);
+
+                       net_device_t deviceType = NET_DEVICE_UNKNOWN;
+                       int profListCount = 0;
+                       net_profile_info_t *profList;
+
+                       gettimeofday(&timevar, NULL);
+                       start_time = Convert_time2double(timevar);
+
+                       if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r') {
+                               input_str[strlen(input_str)-1] = '\0';
+
+                               if (strcmp(input_str, "1") == 0)
+                                       deviceType = NET_DEVICE_WIFI;
+                               else if (strcmp(input_str, "2") == 0)
+                                       deviceType = NET_DEVICE_CELLULAR;
+
+                               net_error = net_get_profile_list(deviceType,
+                                               &profList, &profListCount);
+
+                               if (net_error != NET_ERR_NONE) {
+                                       debug_print("Error!!! net_get_profile_list() failed\n");
+                                       break;
+                               }
+
+                               __print_profile_list(profListCount, profList, PROFILE_BASIC_INFO);
+                               MAIN_MEMFREE(profList);
+                       }
+
+                       gettimeofday(&timevar, NULL);
+                       finish_time = Convert_time2double(timevar);
+                       debug_print("Total time taken = [%f]\n", finish_time - start_time);
+
+                       break;
+
+               case 'e':
+                       debug_print("\nInput profile Name((Enter for skip) :\n");
+                       memset(ProfileName, 0, NET_PROFILE_NAME_LEN_MAX);
+                       read(0, ProfileName, NET_PROFILE_NAME_LEN_MAX);
+
+                       if (ProfileName[0] == '\0' || *ProfileName == '\n' || *ProfileName == '\r')
+                               debug_print("\nCanceled!\n\n");
+
+                       ProfileName[strlen(ProfileName)-1] = '\0';
+
+                       gettimeofday(&timevar, NULL);
+                       start_time = Convert_time2double(timevar);
+
+                       if (net_get_profile_info(ProfileName, &profile_info) != NET_ERR_NONE) {
+                               debug_print("Error!!! net_get_profile_info() failed\n");
+                               break;
+                       }
+
+                       __network_print_profile(&profile_info, PROFILE_FULL_INFO);
+
+                       gettimeofday(&timevar, NULL);
+                       finish_time = Convert_time2double(timevar);
+                       debug_print("Total time taken = [%f]\n", finish_time - start_time);
+
+                       break;
+
+               case 'f':
+                       debug_print("\nInput profile Name(Enter for skip) :\n");
+                       memset(ProfileName, '\0', NET_PROFILE_NAME_LEN_MAX);
+                       read(0, ProfileName, NET_PROFILE_NAME_LEN_MAX);
+
+                       if (ProfileName[0] != '\0' &&
+                           *ProfileName != '\n' &&
+                           *ProfileName != '\r') {
+                               ProfileName[strlen(ProfileName) - 1] = '\0';
+
+                               net_error = net_get_profile_info(ProfileName, &profile_info);
+                               if (net_error != NET_ERR_NONE) {
+                                       debug_print("Error!!! net_get_profile_info() failed\n");
+                                       break;
+                               }
+                       } else {
+                               debug_print("\nCanceled!\n\n");
+                               break;
+                       }
+
+                       if (!__network_modify_profile_info(&profile_info))
+                               continue;
+
+                       gettimeofday(&timevar, NULL);
+                       start_time = Convert_time2double(timevar);
+
+                       if (net_modify_profile(ProfileName, &profile_info) != NET_ERR_NONE) {
+                               debug_print("Error!!! net_modify_profile() failed\n");
+                               break;
+                       }
+
+                       gettimeofday(&timevar, NULL);
+                       finish_time = Convert_time2double(timevar);
+                       debug_print("Total time taken = [%f]\n", finish_time - start_time);
+
+                       break;
+
+               case 'g':
+                       debug_print("\nInput profile Name(Enter for skip) :\n");
+
+                       memset(ProfileName, '\0', NET_PROFILE_NAME_LEN_MAX);
+                       read(0, ProfileName, NET_PROFILE_NAME_LEN_MAX);
+
+                       gettimeofday(&timevar, NULL);
+                       start_time = Convert_time2double(timevar);
+
+                       if (ProfileName[0] == '\0' || *ProfileName == '\n' || *ProfileName == '\r')
+                               debug_print("\nCanceled!\n\n");
+
+                       ProfileName[strlen(ProfileName)-1] = '\0';
+
+                       if (net_delete_profile(ProfileName) != NET_ERR_NONE) {
+                               debug_print("Error!!! net_delete_profile() failed\n");
+                               break;
+                       }
+
+                       gettimeofday(&timevar, NULL);
+                       finish_time = Convert_time2double(timevar);
+                       debug_print("Total time taken = [%f]\n", finish_time - start_time);
+
+                       break;
+
+               case 'h':
+                       debug_print("\nInput Network Type(internet:1, MMS:2, WAP:3)"
+                                       " - (Enter for skip) :\n");
+
+                       memset(input_str, '\0', 100);
+                       read(0, input_str, 100);
+
+                       net_service_type_t network_type = NET_SERVICE_INTERNET;
+                       memset(&profile_info, 0, sizeof(net_profile_info_t));
+
+                       if (input_str[0] != '\0' && *input_str != '\n' && *input_str != '\r') {
+                               int typeValue = 0;
+                               typeValue = atoi(input_str);
+
+                               if (typeValue > NET_SERVICE_UNKNOWN &&
+                                   typeValue <= NET_SERVICE_PREPAID_MMS)
+                                       network_type = typeValue;
+                               else
+                                       break;
+                       } else {
+                               break;
+                       }
+
+                       __network_add_profile_info(&profile_info);
+
+                       gettimeofday(&timevar, NULL);
+                       start_time = Convert_time2double(timevar);
+
+                       if (net_add_profile(network_type, &profile_info) != NET_ERR_NONE) {
+                               debug_print("Error!!! net_add_profile() failed\n");
+                               break;
+                       }
+
+                       gettimeofday(&timevar, NULL);
+                       finish_time = Convert_time2double(timevar);
+                       debug_print("Total time taken = [%f]\n", finish_time - start_time);
+
+                       break;
+
+               case 'i': {
+                       net_wifi_connection_info_t wifi_info = {{0,}, };
+
+                       debug_print("Enter essid: \n");
+                       scanf("%s", wifi_info.essid);
+
+                       wifi_info.wlan_mode = NETPM_WLAN_CONNMODE_INFRA;
+                       wifi_info.security_info.sec_mode = WLAN_SEC_MODE_WPA_PSK;
+
+                       debug_print("Enter psk key:\n");
+                       scanf("%s", wifi_info.security_info.authentication.psk.pskKey);
+
+                       gettimeofday(&timevar, NULL);
+                       start_time = Convert_time2double(timevar);
+
+                       net_error = net_open_connection_with_wifi_info(&wifi_info);
+
+                       if (net_error != NET_ERR_NONE) {
+                               debug_print("Error!!! "
+                                           "net_open_connection_with_wifi_info() failed.\n");
+                               break;
+                       }
+
+                       gettimeofday(&timevar, NULL);
+                       finish_time = Convert_time2double(timevar);
+                       debug_print("Total time taken = [%f]\n", finish_time - start_time);
+
+                       debug_print("net_open_connection_with_wifi_info() success\n");
+               }
+
+                       break;
+
+               case 'k': {
+                       debug_print( "Enter Profile Name: \n");
+                       scanf("%s", ProfileName);
+
+                       gettimeofday(&timevar, NULL);
+                       start_time = Convert_time2double(timevar);
+                       net_wifi_wps_info_t wps_info;
+                       memset(&wps_info, 0, sizeof(net_wifi_wps_info_t));
+
+                       wps_info.type = WIFI_WPS_PBC;
+
+                       if (net_wifi_enroll_wps(ProfileName, &wps_info) != NET_ERR_NONE) {
+                               debug_print(    "Error!! net_wifi_enroll_wps() failed.\n");
+                               break;
+                       }
+
+                       gettimeofday(&timevar, NULL);
+                       finish_time = Convert_time2double(timevar);
+                       debug_print("Total time taken = [%f]\n", finish_time - start_time);
+
+                       debug_print("net_wifi_enroll_wps() success\n");
+               }
+                       break;
+
+               case 'l': {
+                       net_wifi_connection_info_t info;
+                       memset(&info, 0, sizeof(net_wifi_connection_info_t));
+
+                       info.wlan_mode = NETPM_WLAN_CONNMODE_INFRA;
+                       info.security_info.sec_mode = WLAN_SEC_MODE_IEEE8021X;
+                       memcpy(info.essid,  "test01", strlen("test01")+1);
+
+                       info.security_info.authentication.eap.eap_type = WLAN_SEC_EAP_TYPE_TLS;
+                       info.security_info.authentication.eap.eap_auth = WLAN_SEC_EAP_AUTH_MSCHAP;
+                       memcpy(info.security_info.authentication.eap.username, "test01", strlen("test01")+1);
+                       memcpy(info.security_info.authentication.eap.password, "test01", strlen("test01")+1);
+
+                       net_open_connection_with_wifi_info(&info);
+               }
+                       break;
+
+               case 'z':
+                       debug_print( "Exiting...!!!\n");
+
+                       if (net_deregister_client () != NET_ERR_NONE) {
+                               debug_print("Error!! net_deregister_client() failed.\n");
+                               return NULL;
+                       }
+
+                       debug_print( "net_deregister_client() success\n");
+
+                       exit(0);
+
+               default:
+                       debug_print( "default...!!!\n");
+                       break;
+               }
+       }
+
+       if (net_deregister_client () != NET_ERR_NONE) {
+               debug_print("Error!! net_deregister_client() failed.\n");
+               return NULL;
+       }
+
+       debug_print( "net_deregister_client() success\n");
+
+       return NULL;
+}
+
+
+int main(int argc, char *argv[])
+{
+       GMainLoop* mainloop = NULL;
+       GThread * main_gthread_ptr = NULL;
+
+       /* First thing initialze the thread system */
+        g_thread_init(NULL);
+
+       /** This thread is used to recieve signals from ConnMan */
+       main_gthread_ptr = g_thread_create(network_main_gthread, NULL, FALSE, NULL);
+       if (main_gthread_ptr == NULL) {
+               debug_print("Error!!! g_thread_create() failed.\n");
+               return -1;
+       }
+
+       debug_print("Entering gmainloop\n");
+       mainloop = g_main_loop_new(NULL, FALSE);
+       g_main_loop_run(mainloop);
+
+       debug_print("Returned from gmainloop\n");
+
+       return 0;
+}
+