summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjk7744.park <jk7744.park@samsung.com>2015-09-08 22:08:56 +0900
committerjk7744.park <jk7744.park@samsung.com>2015-09-08 22:08:56 +0900
commit3b319fd12772adcf57d31b5f4fc564af6ed7ff4e (patch)
tree294cafdc338c6f0ffbbed10247c2bbe67e5bab85
parent606285b0e52ab9a390f3659d3aca940eb4d2094f (diff)
downloadconnection-tizen_2.3.1.tar.gz
connection-tizen_2.3.1.tar.bz2
connection-tizen_2.3.1.zip
-rw-r--r--.gitignore1
-rw-r--r--AUTHORS2
-rw-r--r--CMakeLists.txt19
-rw-r--r--LICENSE2
-rw-r--r--NOTICE3
-rw-r--r--capi-network-connection.manifest8
-rw-r--r--capi-network-connection.pc.in3
-rw-r--r--debian/capi-network-connection-dev.install4
-rw-r--r--debian/capi-network-connection-dev.postinst1
-rw-r--r--debian/capi-network-connection.install1
-rw-r--r--debian/capi-network-connection.postinst1
-rw-r--r--debian/changelog346
-rw-r--r--debian/compat1
-rw-r--r--debian/control21
-rwxr-xr-xdebian/rules67
-rwxr-xr-xdoc/net_connection_doc.h168
-rw-r--r--include/connection_profile.h957
-rwxr-xr-xinclude/net_connection.h626
-rwxr-xr-x[-rw-r--r--]include/net_connection_private.h121
-rw-r--r--packaging/capi-network-connection.spec69
-rwxr-xr-xsrc/connection.c984
-rwxr-xr-xsrc/connection_profile.c1001
-rwxr-xr-xsrc/internal.c53
-rwxr-xr-xsrc/libnetwork.c1224
-rw-r--r--test/CMakeLists.txt12
-rwxr-xr-x[-rw-r--r--]test/connection_test.c1569
26 files changed, 5237 insertions, 2027 deletions
diff --git a/.gitignore b/.gitignore
index 85209fb..94dddad 100644
--- a/.gitignore
+++ b/.gitignore
@@ -48,4 +48,3 @@ debian/capi-network-connection.substvars
debian/capi-network-connection/
test/connection_test
test/connection_test_regress
-
diff --git a/AUTHORS b/AUTHORS
deleted file mode 100644
index ee5aeac..0000000
--- a/AUTHORS
+++ /dev/null
@@ -1,2 +0,0 @@
-JaeHyun Kim <jeik01.kim@samsung.com>
-ByungWoo Lee <bw1212.lee@samsung.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 30ba177..2473b3d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,16 +9,26 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX})
SET(INC_DIR include)
INCLUDE_DIRECTORIES(${INC_DIR})
-SET(dependents "dlog vconf capi-base-common glib-2.0 network")
+SET(dependents "dlog vconf capi-base-common glib-2.0 network capi-system-info")
SET(pc_dependents "capi-base-common")
+IF(TIZEN_DUALSIM_ENABLE)
+ ADD_DEFINITIONS(-DTIZEN_DUALSIM_ENABLE)
+ENDIF(TIZEN_DUALSIM_ENABLE)
+IF(TIZEN_WEARABLE)
+ ADD_DEFINITIONS(-DTIZEN_WEARABLE)
+ENDIF(TIZEN_WEARABLE)
+IF(TIZEN_MOBILE)
+ ADD_DEFINITIONS(-DTIZEN_MOBILE)
+ENDIF(TIZEN_MOBILE)
+
INCLUDE(FindPkgConfig)
pkg_check_modules(${fw_name} REQUIRED ${dependents})
FOREACH(flag ${${fw_name}_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -fvisibility=hidden")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
IF("${ARCH}" STREQUAL "arm")
@@ -67,10 +77,10 @@ IF(UNIX)
ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
ADD_CUSTOM_COMMAND(
- DEPENDS clean
+ DEPENDS clean
COMMENT "distribution clean"
COMMAND find
- ARGS .
+ ARGS .
-not -name config.cmake -and \(
-name tester.c -or
-name Testing -or
@@ -93,4 +103,3 @@ ADD_CUSTOM_COMMAND(
)
ENDIF(UNIX)
-
diff --git a/LICENSE b/LICENSE
index a06208b..56ea2f0 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved.
Apache License
Version 2.0, January 2004
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000..ccdad52
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE file for Apache License terms and conditions.
diff --git a/capi-network-connection.manifest b/capi-network-connection.manifest
new file mode 100644
index 0000000..3ca8395
--- /dev/null
+++ b/capi-network-connection.manifest
@@ -0,0 +1,8 @@
+<manifest>
+ <assign>
+ <filesystem path="/usr/bin/connection_test" exec_label="connman"/>
+ </assign>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
diff --git a/capi-network-connection.pc.in b/capi-network-connection.pc.in
index 097a2d1..ee6db75 100644
--- a/capi-network-connection.pc.in
+++ b/capi-network-connection.pc.in
@@ -8,7 +8,6 @@ includedir=/usr/include/network
Name: @PC_NAME@
Description: @PACKAGE_DESCRIPTION@
Version: @VERSION@
-Requires: @PC_REQUIRED@
+Requires: @PC_REQUIRED@
Libs: -L${libdir} @PC_LDFLAGS@
Cflags: -I${includedir}
-
diff --git a/debian/capi-network-connection-dev.install b/debian/capi-network-connection-dev.install
deleted file mode 100644
index 761a28b..0000000
--- a/debian/capi-network-connection-dev.install
+++ /dev/null
@@ -1,4 +0,0 @@
-/usr/include/*
-/usr/include/*/*
-/usr/lib/pkgconfig/*.pc
-
diff --git a/debian/capi-network-connection-dev.postinst b/debian/capi-network-connection-dev.postinst
deleted file mode 100644
index 1a24852..0000000
--- a/debian/capi-network-connection-dev.postinst
+++ /dev/null
@@ -1 +0,0 @@
-#!/bin/sh
diff --git a/debian/capi-network-connection.install b/debian/capi-network-connection.install
deleted file mode 100644
index 4a755a4..0000000
--- a/debian/capi-network-connection.install
+++ /dev/null
@@ -1 +0,0 @@
-/usr/lib/lib*.so*
diff --git a/debian/capi-network-connection.postinst b/debian/capi-network-connection.postinst
deleted file mode 100644
index 1a24852..0000000
--- a/debian/capi-network-connection.postinst
+++ /dev/null
@@ -1 +0,0 @@
-#!/bin/sh
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644
index edc96c5..0000000
--- a/debian/changelog
+++ /dev/null
@@ -1,346 +0,0 @@
-capi-network-connection (0.1.1-9) unstable; urgency=low
-
- * Remove deprecated APIs
- * Git: api/connection
- * Tag: capi-network-connection_0.1.1-9
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Fri, 03 Aug 2012 16:51:25 +0900
-
-capi-network-connection (0.1.1-8) unstable; urgency=low
-
- * Modify connection_create() and connection_destroy() API to assure thread safety
- * Git: api/connection
- * Tag: capi-network-connection_0.1.1-8
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Fri, 27 Jul 2012 12:36:54 +0900
-
-capi-network-connection (0.1.1-7) unstable; urgency=low
-
- * Modify set/get statistics API to support dbus interface of net-config
- * Git: api/connection
- * Tag: capi-network-connection_0.1.1-7
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Fri, 06 Jul 2012 18:13:11 +0900
-
-capi-network-connection (0.1.1-6) unstable; urgency=low
-
- * Modify connection_reset_statistics() to avoid vconf permission error
- * Git: api/connection
- * Tag: capi-network-connection_0.1.1-6
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Wed, 27 Jun 2012 19:06:32 +0900
-
-capi-network-connection (0.1.1-5) unstable; urgency=low
-
- * Update TC
- * Git: api/connection
- * Tag: capi-network-connection_0.1.1-5
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Tue, 12 Jun 2012 18:49:08 +0900
-
-capi-network-connection (0.1.1-4) unstable; urgency=low
-
- * Add profile initialization functions for user creation
- * Git: api/connection
- * Tag: capi-network-connection_0.1.1-4
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Tue, 12 Jun 2012 17:17:00 +0900
-
-capi-network-connection (0.1.1-3) unstable; urgency=low
-
- * Implementation of connection_reset_statistics()
- * Git: api/connection
- * Tag: capi-network-connection_0.1.1-3
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Tue, 12 Jun 2012 16:34:52 +0900
-
-capi-network-connection (0.1.1-2) unstable; urgency=low
-
- * Implementation of extened APIs again
- * Git: api/connection
- * Tag: capi-network-connection_0.1.1-2
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Tue, 29 May 2012 17:00:36 +0900
-
-capi-network-connection (0.1.1-1) unstable; urgency=low
-
- * Rollback to capi-network-connection_0.1.0-23
- * Git: api/connection
- * Tag: capi-network-connection_0.1.1-1
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Wed, 23 May 2012 20:56:07 +0900
-
-capi-network-connection (0.1.1-0) unstable; urgency=low
-
- * Implementation of extened APIs
- * Git: api/connection
- * Tag: capi-network-connection_0.1.1-0
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Fri, 18 May 2012 14:57:49 +0900
-
-capi-network-connection (0.1.0-23) unstable; urgency=low
-
- * Fix a bug which don't set user data in proxy callback setter
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-23
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Mon, 16 Apr 2012 12:02:47 +0900
-
-capi-network-connection (0.1.0-22) unstable; urgency=low
-
- * Fix connection destroy bug
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-22
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Mon, 09 Apr 2012 20:54:57 +0900
-
-capi-network-connection (0.1.0-21) unstable; urgency=low
-
- * Add ipv6 feature and update DTS code
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-21
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Fri, 30 Mar 2012 18:15:20 +0900
-
-capi-network-connection (0.1.0-20) unstable; urgency=low
-
- * Update DTS code
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-20
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Tue, 20 Mar 2012 16:08:10 +0900
-
-capi-network-connection (0.1.0-19) unstable; urgency=low
-
- * Revise spec for OBS
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-19
-
- -- Danny Jeongseok Seo <s.seo@samsung.com> Sat, 17 Mar 2012 18:31:44 +0900
-
-capi-network-connection (0.1.0-18) unstable; urgency=low
-
- * Implementation of new APIs and TC code
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-18
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Fri, 16 Mar 2012 18:46:37 +0900
-
-capi-network-connection (0.1.0-17) unstable; urgency=low
-
- * Convert internal function to static function
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-17
-
- -- ByungWoo Lee <bw1212.lee@samsung.com> Mon, 20 Feb 2012 17:55:42 +0900
-
-capi-network-connection (0.1.0-16) unstable; urgency=low
-
- * Add versioning of library
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-16
-
- -- ByungWoo Lee <bw1212.lee@samsung.com> Tue, 14 Feb 2012 17:23:56 +0900
-
-capi-network-connection (0.1.0-15) unstable; urgency=low
-
- * Fix bugs and related DTS
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-15
-
- -- JaeHyun Kim <jeik01.kim@samsung.com> Tue, 07 Feb 2012 19:09:07 +0900
-
-capi-network-connection (0.1.0-14) unstable; urgency=low
-
- * Update DTS
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-14
-
- -- ByungWoo Lee <bw1212.lee@samsung.com> Fri, 27 Jan 2012 18:18:29 +0900
-
-capi-network-connection (0.1.0-13) unstable; urgency=low
-
- * License and Boilerplate update.
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-13
-
- -- Sanjeev BA <as2902.b@samsung.com> Tue, 06 Dec 2011 18:48:48 +0900
-
-capi-network-connection (0.1.0-12) unstable; urgency=low
-
- * Bump up version.
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-12
-
- -- Sanjeev BA <as2902.b@samsung.com> Thu, 01 Dec 2011 19:40:16 +0900
-
-capi-network-connection (0.1.0-11) unstable; urgency=low
-
- * Add data connection statistics.
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-11
-
- -- Sanjeev BA <as2902.b@samsung.com> Thu, 01 Dec 2011 19:18:24 +0900
-
-capi-network-connection (0.1.0-10) unstable; urgency=low
-
- * Cleanup of vconf notifications.
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-10
-
- -- Sanjeev BA <as2902.b@samsung.com> Thu, 01 Dec 2011 11:08:59 +0900
-
-capi-network-connection (0.1.0-9) unstable; urgency=low
-
- * Renaming for tizen.
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-9
-
- -- Sanjeev BA <as2902.b@samsung.com> Wed, 30 Nov 2011 15:10:59 +0900
-
-capi-network-connection (0.1.0-8) unstable; urgency=low
-
- * Renaming for tizen.
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-8
-
- -- Sanjeev BA <as2902.b@samsung.com> Wed, 23 Nov 2011 15:07:23 +0900
-
-capi-network-connection (0.1.0-7) unstable; urgency=low
-
- * Correct status updates.
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-7
-
- -- Sanjeev BA <as2902.b@samsung.com> Wed, 23 Nov 2011 13:46:23 +0900
-
-capi-network-connection (0.1.0-6) unstable; urgency=low
-
- * Correct status updates.
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-6
-
- -- Sanjeev BA <as2902.b@samsung.com> Thu, 17 Nov 2011 15:10:55 +0900
-
-capi-network-connection (0.1.0-5) unstable; urgency=low
-
- * Correct status updates.
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-5
-
- -- Sanjeev BA <as2902.b@samsung.com> Fri, 04 Nov 2011 17:55:49 +0900
-
-capi-network-connection (0.1.0-4) unstable; urgency=low
-
- * Fix boilerplate.
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-4
-
- -- Sanjeev BA <as2902.b@samsung.com> Fri, 04 Nov 2011 11:22:10 +0900
-
-capi-network-connection (0.1.0-3) unstable; urgency=low
-
- * Fix doxygen comments.
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-3
-
- -- Sanjeev BA <as2902.b@samsung.com> Mon, 31 Oct 2011 20:13:02 +0900
-
-capi-network-connection (0.1.0-2) unstable; urgency=low
-
- * Add new mappings between vconf and connection_network_param_e.
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-2
-
- -- Sanjeev BA <as2902.b@samsung.com> Fri, 14 Oct 2011 19:37:05 +0900
-
-capi-network-connection (0.1.0-1) unstable; urgency=low
-
- * Alpha Release
- * Git: api/connection
- * Tag: capi-network-connection_0.1.0-1
-
- -- Kangho Hur <kangho.hur@samsung.com> Tue, 27 Sep 2011 20:35:08 +0900
-
-capi-network-connection (0.0.1-11) unstable; urgency=low
-
- * Fix build error from sbs using (sbs --clean-build).
- * Updated debian/control file to add build depedency.
- * Git: api/connection
- * Tag: capi-network-connection_0.0.1-11
-
- -- Sanjeev BA <as2902.b@samsung.com> Thu, 08 Sep 2011 17:36:05 +0900
-
-capi-network-connection (0.0.1-10) unstable; urgency=low
-
- * Fix as per new libnetwork API.
- * remove dnet dependency, use only vconf.
- * Git: api/connection
- * Tag: capi-network-connection_0.0.1-10
-
- -- Sanjeev BA <as2902.b@samsung.com> Wed, 07 Sep 2011 14:19:30 +0900
-
-capi-network-connection (0.0.1-9) unstable; urgency=low
-
- * Add param_name to callbacks. Will help apps identify what has changed.
- * Git: api/connection
- * Tag: capi-network-connection_0.0.1-9
-
- -- Sanjeev BA <as2902.b@samsung.com> Fri, 02 Sep 2011 10:20:09 +0900
-
-capi-network-connection (0.0.1-8) unstable; urgency=low
-
- * Cleanup unused code. Fix documentation.
- * Git: api/connection
- * Tag: capi-network-connection_0.0.1-8
-
- -- Sanjeev BA <as2902.b@samsung.com> Thu, 01 Sep 2011 20:03:11 +0900
-
-capi-network-connection (0.0.1-7) unstable; urgency=low
-
- * Fix handles.
- * Git: api/connection
- * Tag: capi-network-connection_0.0.1-7
-
-
- -- Sanjeev BA <as2902.b@samsung.com> Mon, 22 Aug 2011 14:31:53 +0900
-
-capi-network-connection (0.0.1-6) unstable; urgency=low
-
- * Fix handles.
- * Git: api/connection
- * Tag: capi-network-connection_0.0.1-6
-
- -- Sanjeev BA <as2902.b@samsung.com> Thu, 18 Aug 2011 09:50:20 +0900
-
-capi-network-connection (0.0.1-5) unstable; urgency=low
-
- * Fix debain packaging issue.
- * Git: api/connection
- * Tag: capi-network-connection_0.0.1-5
-
- -- Sanjeev BA <as2902.b@samsung.com> Thu, 11 Aug 2011 19:28:50 +0900
-
-capi-network-connection (0.0.1-4) unstable; urgency=low
-
- * Fix regression test case that was never used before.
- * Git: api/connection
- * Tag: capi-network-connection_0.0.1-4
-
- -- Sanjeev BA <as2902.b@samsung.com> Thu, 04 Aug 2011 19:04:04 +0900
-
-capi-network-connection (0.0.1-3) unstable; urgency=low
-
- * Add missing pc.in file.
- * Git: api/connection
- * Tag: capi-network-connection_0.0.1-3
-
- -- Sanjeev BA <as2902.b@samsung.com> Thu, 04 Aug 2011 18:04:33 +0900
-
-capi-network-connection (0.0.1-2) unstable; urgency=low
-
- * Initial Upload
- * Git: api/connection
- * Tag: capi-network-connection_0.0.1-2
-
- -- Sanjeev BA <as2902.b@samsung.com> Thu, 04 Aug 2011 17:32:41 +0900
diff --git a/debian/compat b/debian/compat
deleted file mode 100644
index 7f8f011..0000000
--- a/debian/compat
+++ /dev/null
@@ -1 +0,0 @@
-7
diff --git a/debian/control b/debian/control
deleted file mode 100644
index 085178b..0000000
--- a/debian/control
+++ /dev/null
@@ -1,21 +0,0 @@
-Source: capi-network-connection
-Section: libs
-Priority: extra
-Maintainer: JaeHyun Kim <jeik01.kim@samsung.com>
-Build-Depends: debhelper (>= 5), dlog-dev, capi-base-common-dev, libvconf-dev, libglib2.0-dev, libdbus-glib-1-dev, libnetwork-dev
-
-Package: capi-network-connection
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: Network Connection library in TIZEN C API
-
-Package: capi-network-connection-dev
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, capi-network-connection (= ${Source-Version}), capi-base-common-dev
-Description: Network Connection library in TIZEN C API (DEV)
-
-Package: capi-network-connection-dbg
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, capi-network-connection (= ${Source-Version})
-Description: Network Connection library in TIZEN C API (DBG)
-
diff --git a/debian/rules b/debian/rules
deleted file mode 100755
index 678a339..0000000
--- a/debian/rules
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/usr/bin/make -f
-
-CFLAGS = -Wall -g
-FULLVER ?= $(shell dpkg-parsechangelog | grep Version: | cut -d ' ' -f 2 | cut -d '-' -f 1)
-MAJORVER ?= $(shell echo $(FULLVER) | cut -d '.' -f 1)
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
- CFLAGS += -O0
-else
- CFLAGS += -O2
-endif
-CMAKE_ROOT_DIR ?= $(CURDIR)
-CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp
-
-configure: configure-stamp
-configure-stamp:
- dh_testdir
- mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && cmake .. -DFULLVER=${FULLVER} -DMAJORVER=${MAJORVER}
- touch configure-stamp
-
-
-build: build-stamp
-build-stamp: configure-stamp
- dh_testdir
- cd $(CMAKE_BUILD_DIR) && $(MAKE)
- touch $@
-
-clean:
- cd $(CMAKE_ROOT_DIR)
- dh_testdir
- dh_testroot
- rm -f build-stamp configure-stamp
- rm -f `find . -name *.pc`
- rm -rf $(CMAKE_BUILD_DIR)
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
-
- cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
-
-binary-indep: build install
-
-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=capi-network-connection-dbg
- dh_fixperms
- dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
-
diff --git a/doc/net_connection_doc.h b/doc/net_connection_doc.h
new file mode 100755
index 0000000..d88113f
--- /dev/null
+++ b/doc/net_connection_doc.h
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_NETWORK_CONNECTION_DOC_H__
+#define __TIZEN_NETWORK_CONNECTION_DOC_H__
+
+/**
+ * @defgroup CAPI_NETWORK_CONNECTION_MODULE Connection
+ * @brief The Connection API provides functions for managing modem data connections.
+ * @ingroup CAPI_NETWORK_FRAMEWORK
+ *
+ * @section CAPI_NETWORK_CONNECTION_MODULE_HEADER Required Header
+ * \#include <net_connection.h>
+ *
+ * @section CAPI_NETWORK_CONNECTION_MODULE_OVERVIEW Overview
+ * The Connection API provides functions used to create a network connection and to perform other operations on the
+ * connection. With these functions, the application can get details such as the IP address, proxy information, gateway information, and connection
+ * statistics.
+ *
+ */
+
+/**
+ * @defgroup CAPI_NETWORK_CONNECTION_MANAGER_MODULE Connection Manager
+ * @brief The Connection Manager API provides functions for managing data connections.
+ * @ingroup CAPI_NETWORK_CONNECTION_MODULE
+ *
+ * @section CAPI_NETWORK_CONNECTION_MANAGER_MODULE_HEADER Required Header
+ * \#include <net_connection.h>
+ *
+ * @section CAPI_NETWORK_CONNECTION_MANAGER_MODULE_OVERVIEW Overview
+ * To use Connection Manager API, first create a connection handle using connection_create(). After that, you can obtain network information.
+ * You should destroy the created connection handle if you do not need it anymore.
+ * This API is related with libsoup and sockets. It allows you to create a socket on the kernel Linux stack, which can be used directly or by libsoup
+ * or any other network library.
+ * @section CAPI_NETWORK_CONNECTION_MANAGER_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/network.wifi\n
+ * - http://tizen.org/feature/network.telephony\n
+ * - http://tizen.org/feature/network.tethering.bluetooth\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.gettingstarted/html/native/details/app_filtering_n.htm"><b>Feature List</b>.</a>
+ *
+ */
+
+/**
+ * @defgroup CAPI_NETWORK_CONNECTION_PROFILE_MODULE Connection Profile
+ * @brief The Connection Profile API provides functions for managing the connection profile.
+ * @ingroup CAPI_NETWORK_CONNECTION_MANAGER_MODULE
+ *
+ * @section CAPI_NETWORK_CONNECTION_PROFILE_MODULE_HEADER Required Header
+ * \#include <net_connection.h>
+ *
+ * @section CAPI_NETWORK_CONNECTION_PROFILE_MODULE_OVERVIEW Overview
+ * The Connection Profile provides functions for mapping connection profile.
+ * It allows you to use a handle for dealing with a connection profile. You can get details about connection using ‘connection_profile_h’ handle.
+ * @section CAPI_NETWORK_CONNECTION_PROFILE_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/network.wifi\n
+ * - http://tizen.org/feature/network.telephony\n
+ * - http://tizen.org/feature/network.tethering.bluetooth\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.gettingstarted/html/native/details/app_filtering_n.htm"><b>Feature List</b>.</a>
+ *
+ */
+
+/**
+ * @defgroup CAPI_NETWORK_CONNECTION_CELLULAR_PROFILE_MODULE Cellular Profile
+ * @brief The Connection Cellular Profile API provides functions for managing the cellular profile.
+ * @ingroup CAPI_NETWORK_CONNECTION_PROFILE_MODULE
+ *
+ * @section CAPI_NETWORK_CONNECTION_CELLULAR_PROFILE_MODULE_HEADER Required Header
+ * \#include <net_connection.h>
+ * @section CAPI_NETWORK_CONNECTION_CELLULAR_PROFILE_MODULE_OVERVIEW Overview
+ * The Connection Cellular Profile API provides functions for managing the cellular profile. You can manage the cellular profile using the functions.
+ * @section CAPI_NETWORK_CONNECTION_CELLULAR_PROFILE_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/network.telephony\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.gettingstarted/html/native/details/app_filtering_n.htm"><b>Feature List</b>.</a>
+ *
+ */
+
+/**
+ * @defgroup CAPI_NETWORK_CONNECTION_WIFI_PROFILE_MODULE Wi-Fi Profile
+ * @brief The Connection Wi-Fi Profile API provides functions for managing the WiFi profile.
+ * @ingroup CAPI_NETWORK_CONNECTION_PROFILE_MODULE
+ *
+ * @section CAPI_NETWORK_CONNECTION_WIFI_PROFILE_MODULE_HEADER Required Header
+ * \#include <net_connection.h>
+ * @section CAPI_NETWORK_CONNECTION_WIFI_PROFILE_MODULE_OVERVIEW Overview
+ * The Connection Wi-Fi Profile API provides functions for managing the wi-fi profile. You can manage the wi-fi profile using the functions.
+ * @section CAPI_NETWORK_CONNECTION_WIFI_PROFILE_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/network.wifi\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.gettingstarted/html/native/details/app_filtering_n.htm"><b>Feature List</b>.</a>
+ *
+ */
+
+/**
+ * @defgroup CAPI_NETWORK_CONNECTION_STATISTICS_MODULE Connection Statistics
+ * @brief The Connection Statistics API provides functions for getting the statistical information.
+ * @ingroup CAPI_NETWORK_CONNECTION_MODULE
+ *
+ * @section CAPI_NETWORK_CONNECTION_STATISTICS_MODULE_HEADER Required Header
+ * \#include <net_connection.h>
+ *
+ * @section CAPI_NETWORK_CONNECTION_STATISTICS_MODULE_HEADER_OVERVIEW Overview
+ * The Connection allows you to track the data transfer information.
+ * Use the Connection statistics to gather and reset statistics on network usage, such as the size of the sent or received data, in bytes.
+ * It also provides methods for getting the cumulative size of packets sent or received.
+ * @section CAPI_NETWORK_CONNECTION_STATISTICS_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/network.wifi\n
+ * - http://tizen.org/feature/network.telephony\n
+ *
+ * It is recommended to design feature related codes in your application for reliability.\n
+ *
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
+ *
+ * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ *
+ * More details on featuring your application can be found from <a href="../org.tizen.gettingstarted/html/native/details/app_filtering_n.htm"><b>Feature List</b>.</a>
+ *
+ */
+
+
+
+
+#endif /* __TIZEN_NETWORK_CONNECTION_DOC_H__ */
diff --git a/include/connection_profile.h b/include/connection_profile.h
index 02cc11d..86860b0 100644
--- a/include/connection_profile.h
+++ b/include/connection_profile.h
@@ -1,18 +1,18 @@
/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
#ifndef __TIZEN_NETWORK_CONNECTION_PROFILE_H__
#define __TIZEN_NETWORK_CONNECTION_PROFILE_H__
@@ -24,12 +24,17 @@ extern "C" {
#endif
/**
+ * @file connection_profile.h
+ */
+
+/**
* @addtogroup CAPI_NETWORK_CONNECTION_WIFI_PROFILE_MODULE
* @{
*/
/**
-* @brief Security type of Wi-Fi
+ * @brief Enumeration for security type of Wi-Fi.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
@@ -41,7 +46,8 @@ typedef enum
} connection_wifi_security_type_e;
/**
-* @brief Below encryption modes are used in infrastructure and ad-hoc mode
+ * @brief Enumeration for encryption modes.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
@@ -63,31 +69,23 @@ typedef enum
*/
/**
-* @brief This enumeration defines the cellular protocol type.
-*/
-typedef enum
-{
- CONNECTION_CELLULAR_NETWORK_TYPE_UNKNOWN = 0, /**< Not defined */
- CONNECTION_CELLULAR_NETWORK_TYPE_GPRS = 1, /**< GPRS type */
- CONNECTION_CELLULAR_NETWORK_TYPE_EDGE = 2, /**< EDGE type */
- CONNECTION_CELLULAR_NETWORK_TYPE_UMTS = 3, /**< UMTS type */
-} connection_cellular_network_type_e;
-
-/**
-* @breif This enum indicates cellular service type
+ * @brief Enumeration for cellular service type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN = 0, /**< Unknown */
- CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET = 1, /**< Established for Internet */
- CONNECTION_CELLULAR_SERVICE_TYPE_MMS = 2, /**< Established for MMS */
- CONNECTION_CELLULAR_SERVICE_TYPE_WAP = 3, /**< Established for WAP */
- CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET = 4, /**< Established for prepaid internet service */
- CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS = 5, /**< Established for prepaid MMS service */
+ CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET = 1, /**< Internet */
+ CONNECTION_CELLULAR_SERVICE_TYPE_MMS = 2, /**< MMS */
+ CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET = 3, /**< Prepaid internet */
+ CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS = 4, /**< Prepaid MMS */
+ CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING = 5, /**< Tethering */
+ CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION = 6, /**< Specific application */
} connection_cellular_service_type_e;
/**
-* @brief Cellular Authentication Type
+ * @brief Enumeration for cellular authentication type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
@@ -107,12 +105,14 @@ typedef enum
*/
/**
-* @brief The handle of profile
+ * @brief The profile handle.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef void* connection_profile_h;
/**
-* @brief This enumeration defines the profile state type.
+ * @brief Enumeration for profile state type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
@@ -123,7 +123,8 @@ typedef enum
} connection_profile_state_e;
/**
-* @brief Enumerations of Address family
+ * @brief Enumeration for address family.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
@@ -132,7 +133,8 @@ typedef enum
} connection_address_family_e;
/**
-* @brief Net IP configuration Type
+ * @brief Enumeration for IP configuration type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
@@ -144,7 +146,8 @@ typedef enum
} connection_ip_config_type_e;
/**
-* @brief This enumeration defines the proxy method type.
+ * @brief Enumeration for proxy method type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
@@ -154,318 +157,403 @@ typedef enum
} connection_proxy_type_e;
/**
-* @enum connection_profile_type_e
-* @brief Enumerations of network connection type.
+ * @brief Enumeration for network connection type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum{
CONNECTION_PROFILE_TYPE_CELLULAR = 0, /**< Cellular type */
CONNECTION_PROFILE_TYPE_WIFI = 1, /**< Wi-Fi type */
CONNECTION_PROFILE_TYPE_ETHERNET = 2, /**< Ethernet type */
+ CONNECTION_PROFILE_TYPE_BT = 3, /**< Bluetooth type */
} connection_profile_type_e;
/**
-* @brief Creates the profile handle.
-* @remarks @a profile must be released with connection_profile_destroy().
-* @param[in] type The type of profile
-* @param[out] profile The handle of the profile
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
-* @see connection_profile_destroy()
-*/
-int connection_profile_create(connection_profile_type_e type, connection_profile_h* profile);
-
-/**
-* @brief Destroys the profile handle.
-* @param[out] connection The handle to the connection
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @see connection_profile_create()
+ * @brief Creates a profile handle.
+ * @details The profile name, which you get from connection_profile_get_name(), will include the keyword you set.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile \n
+ * %http://tizen.org/privilege/network.get
+ * @remarks You must release @a profile using connection_profile_destroy(). \n
+ * This API needs both privileges.
+ * @param[in] type The type of profile\n
+ * #CONNECTION_PROFILE_TYPE_CELLULAR and #CONNECTION_PROFILE_TYPE_WIFI are supported.
+ * @param[in] keyword The keyword included in profile name
+ * @param[out] profile The handle of the profile
+ * @return @c 0 on success, otherwise negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
+ * @see connection_profile_destroy()
+ * @see connection_profile_get_name()
+*/
+int connection_profile_create(connection_profile_type_e type, const char* keyword, connection_profile_h* profile);
+
+/**
+ * @brief Destroys a profile handle.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[out] profile The handle to the profile
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see connection_profile_create()
*/
int connection_profile_destroy(connection_profile_h profile);
/**
-* @brief Clons the profile handle.
-* @remarks @a cloned_profile must be released with connection_profile_destroy().
-* @param[in] origin_profile The handle of origin profile
-* @param[out] cloned_profile The handle of cloned profile
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
-* @see connection_profile_destroy()
+ * @brief Clones a profile handle.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks You must release @a cloned_profile using connection_profile_destroy().
+ * @param[out] cloned_profile The handle of the cloned profile
+ * @param[in] origin_profile The handle of the origin profile
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @see connection_profile_destroy()
*/
int connection_profile_clone(connection_profile_h* cloned_profile, connection_profile_h origin_profile);
/**
-* @brief Gets the profile name.
-* @remarks @a profile_name must be released with free() by you.
-* @param[in] profile The handle of profile
-* @param[out] profile_name The name of profile
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @brief Gets the profile ID.
+ * @details The separate profiles can have the same name.
+ * So, you must use this API instead of connection_profile_get_name() if you want to get the unique identification.
+ * In case you create a profile, this value will be determined when you add the profile.
+ *
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks You must release @a profile_id using free().
+ * @param[in] profile The profile handle
+ * @param[out] profile_id The ID of the profile
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @see connection_profile_get_name()
+ * @see connection_add_profile()
+*/
+int connection_profile_get_id(connection_profile_h profile, char** profile_id);
+
+/**
+ * @brief Gets the profile name.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks You must release @a profile_name using free().
+ * @param[in] profile The profile handle
+ * @param[out] profile_name The name of the profile
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @see connection_profile_get_id()
*/
int connection_profile_get_name(connection_profile_h profile, char** profile_name);
/**
-* @brief Gets the network type.
-* @param[in] profile The handle of profile
-* @param[out] type The type of profile
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Gets the network type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[out] type The type of the profile
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
*/
int connection_profile_get_type(connection_profile_h profile, connection_profile_type_e* type);
/**
-* @brief Gets the name of network interface. For example, eth0 and pdp0.
-* @remarks @a interface_name must be released with free() by you.
-* @param[in] profile The handle of profile
-* @param[out] interface_name The name of network interface
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @brief Gets the name of the network interface, e.g. eth0 and pdp0.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks You must release @a interface_name using free().
+ * @param[in] profile The profile handle
+ * @param[out] interface_name The name of the network interface
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
*/
int connection_profile_get_network_interface_name(connection_profile_h profile, char** interface_name);
/**
-* @brief Gets the network type.
-* @param[in] profile The handle of profile
-* @param[out] state The state of profile
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Refreshes the profile information.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @remarks You should call this function in order to get the current information because the profile information can be changed.
+ * @param[in] profile The profile handle
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
+*/
+int connection_profile_refresh(connection_profile_h profile);
+
+/**
+ * @brief Gets the network type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[out] state The state of the profile
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
*/
int connection_profile_get_state(connection_profile_h profile, connection_profile_state_e* state);
/**
-* @brief Gets the IP config type.
-* @param[in] profile The handle of profile
-* @param[in] address_family The address family
-* @param[out] type The type of IP config
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Gets the IP config type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[in] address_family The address family
+ * @param[out] type The type of the IP config
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
*/
int connection_profile_get_ip_config_type(connection_profile_h profile, connection_address_family_e address_family, connection_ip_config_type_e* type);
/**
-* @brief Gets the IP address.
-* @remarks @a ip_address must be released with free() by you.
-* @param[in] profile The handle of profile
-* @param[in] address_family The address family
-* @param[out] ip_address The IP address
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
-* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Gets the IP address.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks You must release @a ip_address using free().
+ * @param[in] profile The profile handle
+ * @param[in] address_family The address family
+ * @param[out] ip_address The IP address
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
*/
int connection_profile_get_ip_address(connection_profile_h profile, connection_address_family_e address_family, char** ip_address);
/**
-* @brief Gets the Subnet Mask.
-* @remarks @a subnet_mask must be released with free() by you.
-* @param[in] profile The handle of profile
-* @param[in] address_family The address family
-* @param[out] subnet_mask The subnet mask
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
-* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Gets the Subnet Mask.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks You must release @a subnet_mask using free().
+ * @param[in] profile The profile handle
+ * @param[in] address_family The address family
+ * @param[out] subnet_mask The subnet mask
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
*/
int connection_profile_get_subnet_mask(connection_profile_h profile, connection_address_family_e address_family, char** subnet_mask);
/**
-* @brief Gets the Gateway address.
-* @remarks @a gateway_address must be released with free() by you.
-* @param[in] profile The handle of profile
-* @param[in] address_family The address family
-* @param[out] gateway_address The gateway address
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
-* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Gets the Gateway address.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks You must release @a gateway_address using free().
+ * @param[in] profile The profile handle
+ * @param[in] address_family The address family
+ * @param[out] gateway_address The gateway address
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
*/
int connection_profile_get_gateway_address(connection_profile_h profile, connection_address_family_e address_family, char** gateway_address);
/**
-* @brief Gets the DNS address.
-* @remarks The allowance of DNS address is 2. @a dns_address must be released with free() by you.
-* @param[in] profile The handle of profile
-* @param[in] order The order of DNS address. It starts from 1, which means first DNS address.
-* @param[in] address_family The address family
-* @param[out] dns_address The DNS address
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
-* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Gets the DNS address.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks The allowance of the DNS address is @c 2. You must release @a dns_address using free().
+ * @param[in] profile The profile handle
+ * @param[in] order The order of DNS address \n
+ * it starts from 1, which means first DNS address.
+ * @param[in] address_family The address family
+ * @param[out] dns_address The DNS address
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
*/
int connection_profile_get_dns_address(connection_profile_h profile, int order, connection_address_family_e address_family, char** dns_address);
/**
-* @brief Gets the Proxy type.
-* @param[in] profile The handle of profile
-* @param[out] type The type of proxy
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Gets the Proxy type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[out] type The type of the proxy
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
*/
int connection_profile_get_proxy_type(connection_profile_h profile, connection_proxy_type_e* type);
/**
-* @brief Gets the Proxy address.
-* @remarks @a proxy_address must be released with free() by you.
-* @param[in] profile The handle of profile
-* @param[in] address_family The address family
-* @param[out] proxy_address The proxy address
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
-* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Gets the Proxy address.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks You must release @a proxy_address using free().
+ * @param[in] profile The profile handle
+ * @param[in] address_family The address family
+ * @param[out] proxy_address The proxy address
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
*/
int connection_profile_get_proxy_address(connection_profile_h profile, connection_address_family_e address_family, char** proxy_address);
/**
-* @brief Sets the IP config type.
-* @param[in] profile The handle of profile
-* @param[in] address_family The address family
-* @param[in] type The type of IP config
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Sets the IP config type.
+ * @details If you set IP config type to #CONNECTION_IP_CONFIG_TYPE_STATIC,
+ * then IP address, Gateway and Subnet mask will be set to the initial value "0.0.0.0".
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[in] address_family The address family
+ * @param[in] type The type of the IP config
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
*/
int connection_profile_set_ip_config_type(connection_profile_h profile, connection_address_family_e address_family, connection_ip_config_type_e type);
/**
-* @brief Sets the IP address.
-* @param[in] profile The handle of profile
-* @param[in] address_family The address family
-* @param[in] ip_address The IP address
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Sets the IP address.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[in] address_family The address family
+ * @param[in] ip_address The IP address.\n
+ * If you set this value to @c NULL, then the existing value will be deleted.
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @see connection_update_profile()
*/
int connection_profile_set_ip_address(connection_profile_h profile, connection_address_family_e address_family, const char* ip_address);
/**
-* @brief Sets the Subnet Mask.
-* @param[in] profile The handle of profile
-* @param[in] address_family The address family
-* @param[in] subnet_mask The subnet mask
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Sets the Subnet Mask.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[in] address_family The address family
+ * @param[in] subnet_mask The subnet mask. \n
+ * If you set this value to @c NULL, then the existing value will be deleted.
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @see connection_update_profile()
*/
int connection_profile_set_subnet_mask(connection_profile_h profile, connection_address_family_e address_family, const char* subnet_mask);
/**
-* @brief Sets the Gateway address.
-* @param[in] profile The handle of profile
-* @param[in] address_family The address family
-* @param[in] gateway_address The gateway address
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Sets the Gateway address.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[in] address_family The address family
+ * @param[in] gateway_address The gateway address. \n
+ * If you set this value to @c NULL, then the existing value will be deleted.
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @see connection_update_profile()
*/
int connection_profile_set_gateway_address(connection_profile_h profile, connection_address_family_e address_family, const char* gateway_address);
/**
-* @brief Sets the DNS address.
-* @remarks The allowance of DNS address is 2.
-* @param[in] profile The handle of profile
-* @param[in] order The order of DNS address. It starts from 1, which means first DNS address.
-* @param[in] address_family The address family
-* @param[in] dns_address The DNS address
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Sets the DNS address.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks The allowance of the DNS address is @c 2.
+ * @param[in] profile The profile handle
+ * @param[in] order The order of the DNS address. \n
+ * It starts from @c 1, which means first DNS address.
+ * @param[in] address_family The address family
+ * @param[in] dns_address The DNS address; if you set this value to NULL, then the existing value will be deleted
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @see connection_update_profile()
*/
int connection_profile_set_dns_address(connection_profile_h profile, int order, connection_address_family_e address_family, const char* dns_address);
/**
-* @brief Sets the Proxy type.
-* @param[in] profile The handle of profile
-* @param[in] type The type of proxy
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Sets the Proxy type.
+ * @details If you set the Proxy type to #CONNECTION_PROXY_TYPE_AUTO or #CONNECTION_PROXY_TYPE_MANUAL, then Proxy will be restored.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[in] type The type of the proxy
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @see connection_update_profile()
*/
int connection_profile_set_proxy_type(connection_profile_h profile, connection_proxy_type_e type);
/**
-* @brief Sets the Proxy address.
-* @param[in] profile The handle of profile
-* @param[in] address_family The address family
-* @param[in] gateway_address The gateway address
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Sets the Proxy address.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[in] address_family The address family
+ * @param[in] proxy_address The proxy address. \n
+ * if you set this value to @c NULL, then the existing value will be deleted.
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @see connection_update_profile()
*/
int connection_profile_set_proxy_address(connection_profile_h profile, connection_address_family_e address_family, const char* proxy_address);
/**
-* @brief Called when the state of profile is changed.
-* @param[in] profile The handle of profile
-* @param[in] is_requested Indicates whether this change is requested or not
-* @param[in] user_data The user data passed from the callback registration function
-* @see connection_profile_set_state_changed_cb()
-* @see connection_profile_unset_state_changed_cb()
+ * @brief Called when the state of the profile is changed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] state The state
+ * @param[in] user_data The user data passed from the callback registration function
+ * @see connection_profile_set_state_changed_cb()
+ * @see connection_profile_unset_state_changed_cb()
*/
-typedef void(*connection_profile_state_changed_cb)(connection_profile_h profile, bool is_requested, void* user_data);
+typedef void(*connection_profile_state_changed_cb)(connection_profile_state_e state, void* user_data);
/**
-* @brief Registers the callback called when the state of profile is changed.
-* @param[in] profile The handle of profile
-* @param[in] callback The callback function to be called
-* @param[in] user_data The user data passed to the callback function
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @see connection_profile_state_changed_cb()
-* @see connection_profile_unset_state_changed_cb()
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Registers the callback that is called when the state of profile is changed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[in] callback The callback function to be called
+ * @param[in] user_data The user data passed to the callback function
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @post connection_opened_cb() is invoked when the state of profile is changed.
+ * @see connection_profile_state_changed_cb()
+ * @see connection_profile_unset_state_changed_cb()
*/
int connection_profile_set_state_changed_cb(connection_profile_h profile, connection_profile_state_changed_cb callback, void* user_data);
/**
-* @brief Unregisters the callback called when the state of profile is changed.
-* @param[in] profile The handle of profile
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @see connection_profile_state_changed_cb()
-* @see connection_profile_set_state_changed_cb()
+ * @brief Unregisters the callback that is called when the state of profile is changed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see connection_profile_state_changed_cb()
+ * @see connection_profile_set_state_changed_cb()
*/
int connection_profile_unset_state_changed_cb(connection_profile_h profile);
@@ -480,109 +568,131 @@ int connection_profile_unset_state_changed_cb(connection_profile_h profile);
*/
/**
-* @brief Gets the ESSID(Extended Service Set Identifier).
-* @remarks @a essid must be released with free() by you.
-* @param[in] profile The handle of profile
-* @param[out] essid The ESSID
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @brief Gets the ESSID (Extended Service Set Identifier).
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks You must release @a essid using free().
+ * @param[in] profile The profile handle
+ * @param[out] essid The ESSID
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
*/
int connection_profile_get_wifi_essid(connection_profile_h profile, char** essid);
/**
-* @brief Gets the BSSID(Basic Service Set Identifier).
-* @remarks @a bssid must be released with free() by you.
-* @param[in] profile The handle of profile
-* @param[out] bssid The BSSID
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @brief Gets the BSSID (Basic Service Set Identifier).
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks You must release @a bssid using free().
+ * @param[in] profile The profile handle
+ * @param[out] bssid The BSSID
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
*/
int connection_profile_get_wifi_bssid(connection_profile_h profile, char** bssid);
/**
-* @brief Gets the RSSI.
-* @param[in] profile The handle of profile
-* @param[out] rssi The RSSI
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @brief Gets the RSSI.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[out] rssi The RSSI
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
*/
int connection_profile_get_wifi_rssi(connection_profile_h profile, int* rssi);
/**
-* @brief Gets the frequency (MHz).
-* @param[in] profile The handle of profile
-* @param[out] frequency The frequency
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @brief Gets the frequency (MHz).
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[out] frequency The frequency
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
*/
int connection_profile_get_wifi_frequency(connection_profile_h profile, int* frequency);
/**
-* @brief Gets the max speed (Mbps).
-* @param[in] profile The handle of profile
-* @param[out] max_speed The max speed
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @brief Gets the max speed (Mbps).
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[out] max_speed The max speed
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
*/
int connection_profile_get_wifi_max_speed(connection_profile_h profile, int* max_speed);
/**
-* @brief Gets the security mode of Wi-Fi.
-* @param[in] profile The handle of profile
-* @param[out] type The type of Wi-Fi security
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Gets the security mode of Wi-Fi.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[out] type The type of Wi-Fi security
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
*/
int connection_profile_get_wifi_security_type(connection_profile_h profile, connection_wifi_security_type_e* type);
/**
-* @brief Gets the security mode of Wi-Fi.
-* @param[in] profile The handle of profile
-* @param[out] type The type of Wi-Fi security
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Gets the security mode of Wi-Fi.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[out] type The type of Wi-Fi security
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
*/
int connection_profile_get_wifi_encryption_type(connection_profile_h profile, connection_wifi_encryption_type_e* type);
/**
-* @brief Checks whether passphrase is required.
-* @param[in] profile The handle of profile
-* @param[out] required Indicates whether passphrase is required or not
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @brief Checks whether passphrase is required.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks This function is not valid if security type is #CONNECTION_WIFI_SECURITY_TYPE_EAP.
+ * @param[in] profile The profile handle
+ * @param[out] required @c true if a passphrase is required, otherwise @c false if a passphrase is not required.
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
*/
int connection_profile_is_wifi_passphrase_required(connection_profile_h profile, bool* required);
/**
-* @brief Sets the passphrase of Wi-Fi WPA.
-* @param[in] profile The handle of profile
-* @param[in] passphrase The passphrase of Wi-Fi security
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @brief Sets the passphrase of the Wi-Fi WPA.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[in] passphrase The passphrase of Wi-Fi security
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
+ * @see connection_update_profile()
*/
int connection_profile_set_wifi_passphrase(connection_profile_h profile, const char* passphrase);
/**
-* @brief Checks whether WPS(Wi-Fi Protected Setup) is supported.
-* @remarks If WPS is supported, you can connect access point with WPS by wifi_connect_with_wps().
-* @param[in] profile The handle of profile
-* @param[out] supported Indicates whether WPS is supported or not
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @brief Checks whether the WPS (Wi-Fi Protected Setup) is supported.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks If WPS is supported, you can connect the access point with WPS by wifi_connect_with_wps().
+ * @param[in] profile The profile handle
+ * @param[out] supported @c true if WPS is supported, otherwise @c false if WPS is not supported.
+ * @return @c 0 on success, otherwise negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
*/
int connection_profile_is_wifi_wps_supported(connection_profile_h profile, bool* supported);
@@ -597,115 +707,162 @@ int connection_profile_is_wifi_wps_supported(connection_profile_h profile, bool*
*/
/**
-* @brief Gets the cellular network type.
-* @param[in] profile The handle of profile
-* @param[out] type The type of cellular
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
-*/
-int connection_profile_get_cellular_network_type(connection_profile_h profile, connection_cellular_network_type_e* type);
-
-/**
-* @brief Gets the service type.
-* @param[in] profile The handle of profile
-* @param[out] type The type of cellular service
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Gets the service type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[out] type The type of the cellular service
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
*/
int connection_profile_get_cellular_service_type(connection_profile_h profile, connection_cellular_service_type_e* type);
/**
-* @brief Gets the APN(access point name).
-* @remarks @a apn must be released with free() by you.
-* @param[in] profile The handle of profile
-* @param[out] apn The name of APN
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @brief Gets the APN (access point name).
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks You must release @a apn using free().
+ * @param[in] profile The profile handle
+ * @param[out] apn The name of the APN
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
*/
int connection_profile_get_cellular_apn(connection_profile_h profile, char** apn);
/**
-* @brief Gets the authentication information.
-* @remarks @a user_name and @a password must be released with free() by you.
-* @param[in] profile The handle of profile
-* @param[out] type The type of authentication
-* @param[out] user_name The user name
-* @param[out] password The password
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
-* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @brief Gets the authentication information.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks You must release @a user_name and @a password using free().
+ * @param[in] profile The profile handle
+ * @param[out] type The type of the authentication
+ * @param[out] user_name The user name
+ * @param[out] password The password
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
*/
int connection_profile_get_cellular_auth_info(connection_profile_h profile, connection_cellular_auth_type_e* type, char** user_name, char** password);
/**
-* @brief Gets the home URL.
-* @remarks @a home_url must be released with free() by you.
-* @param[in] profile The handle of profile
-* @param[out] home_url The home URL
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
-* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @brief Gets the home URL.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks You must release @a home_url using free().
+ * @param[in] profile The profile handle
+ * @param[out] home_url The home URL
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
*/
int connection_profile_get_cellular_home_url(connection_profile_h profile, char** home_url);
/**
-* @brief Gets the state of roaming.
-* @param[in] profile The handle of profile
-* @param[out] is_roaming Indicates whether cellular is in roaming or not
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @brief Checks wheter the connection is in roaming state.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[out] is_roaming @c true if the cellular is roaming, otherwise @c false if it is not roaming.
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
*/
int connection_profile_is_cellular_roaming(connection_profile_h profile, bool* is_roaming);
/**
-* @brief Sets the service type.
-* @param[in] profile The handle of profile
-* @param[out] type The type of cellular service
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @brief Checks whether the profile is hidden.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[out] is_hidden @c ture if the profile is in hidden, otherwise @c false if the profile is not hidden.
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
+*/
+int connection_profile_is_cellular_hidden(connection_profile_h profile, bool* is_hidden);
+
+/**
+ * @brief Checks whether the profile is editable.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[out] is_editable @c true if the profile is editable, otherwise @c false if the profile is not editable.
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
+*/
+int connection_profile_is_cellular_editable(connection_profile_h profile, bool* is_editable);
+
+/**
+ * @brief Checks whether the profile is default.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[out] is_default @c true if the profile is default, otherwise @c false if the profile is not default.
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
+*/
+int connection_profile_is_cellular_default(connection_profile_h profile, bool* is_default);
+
+/**
+ * @brief Sets the service type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[in] service_type The type of cellular service
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
+ * @see connection_update_profile()
*/
int connection_profile_set_cellular_service_type(connection_profile_h profile, connection_cellular_service_type_e service_type);
/**
-* @brief Sets the APN(Access Point Name).
-* @param[in] profile The handle of profile
-* @param[out] apn The name of APN
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @brief Sets the APN (Access Point Name).
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[in] apn The name of APN
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
+ * @see connection_update_profile()
*/
int connection_profile_set_cellular_apn(connection_profile_h profile, const char* apn);
/**
-* @brief Sets the Athentication information.
-* @param[in] profile The handle of profile
-* @param[out] type The type of authentication
-* @param[out] user_name The user name
-* @param[out] password The password
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @brief Sets the Authentication information.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[in] type The type of the authentication
+ * @param[in] user_name The user name
+ * @param[in] password The password
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
+ * @see connection_update_profile()
*/
int connection_profile_set_cellular_auth_info(connection_profile_h profile, connection_cellular_auth_type_e type, const char* user_name, const char* password);
/**
-* @brief Sets the home URL.
-* @param[in] profile The handle of profile
-* @param[out] home_url The home URL
-* @return 0 on success, otherwise negative error value.
-* @retval #CONNECTION_ERROR_NONE Successful
-* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @brief Sets the home URL.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile The profile handle
+ * @param[in] home_url The home URL
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
+ * @see connection_update_profile()
*/
int connection_profile_set_cellular_home_url(connection_profile_h profile, const char* home_url);
diff --git a/include/net_connection.h b/include/net_connection.h
index 3963d48..2087ea4 100755
--- a/include/net_connection.h
+++ b/include/net_connection.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-
-#ifndef __NET_CONNECTION_INTF_H__ /* To prevent inclusion of a header file twice */
+#ifndef __NET_CONNECTION_INTF_H__
#define __NET_CONNECTION_INTF_H__
#include "connection_profile.h"
@@ -24,9 +23,9 @@
extern "C" {
#endif /* __cplusplus */
-#ifndef DEPRECATED
-#define DEPRECATED __attribute__((deprecated))
-#endif
+/**
+ * @file net_connection.h
+ */
/**
* @addtogroup CAPI_NETWORK_CONNECTION_MANAGER_MODULE
@@ -34,69 +33,102 @@ extern "C" {
*/
/**
- * @brief The connection handle for all connection functions.
+ * @brief The connection handle.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef void* connection_h;
/**
- * @brief The iterator handle for profiles.
+ * @brief The profiles iterator handle.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef void* connection_profile_iterator_h;
/**
- * @brief Enumerations of connection type.
+ * @brief Enumeration for connection type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
CONNECTION_TYPE_DISCONNECTED = 0, /**< Disconnected */
- CONNECTION_TYPE_WIFI = 1, /**< Wi-Fi is used for default connection */
- CONNECTION_TYPE_CELLULAR = 2, /**< Cellular is used for default connection */
- CONNECTION_TYPE_ETHERNET = 3, /**< Ethernet is used for default connection */
+ CONNECTION_TYPE_WIFI = 1, /**< Wi-Fi type */
+ CONNECTION_TYPE_CELLULAR = 2, /**< Cellular type */
+ CONNECTION_TYPE_ETHERNET = 3, /**< Ethernet type */
+ CONNECTION_TYPE_BT = 4, /**< Bluetooth type */
} connection_type_e;
/**
- * @brief Enumerations of cellular network state.
+ * @brief Enumeration for cellular network state.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE = 0, /**< Out of service */
CONNECTION_CELLULAR_STATE_FLIGHT_MODE = 1, /**< Flight mode */
CONNECTION_CELLULAR_STATE_ROAMING_OFF = 2, /**< Roaming is turned off */
- CONNECTION_CELLULAR_STATE_CALL_ONLY_AVAILABLE = 3, /**< Call is only available. */
- CONNECTION_CELLULAR_STATE_AVAILABLE = 4, /**< Available */
+ CONNECTION_CELLULAR_STATE_CALL_ONLY_AVAILABLE = 3, /**< Call is only available */
+ CONNECTION_CELLULAR_STATE_AVAILABLE = 4, /**< Available but not connected yet */
+ CONNECTION_CELLULAR_STATE_CONNECTED = 5, /**< Connected */
} connection_cellular_state_e;
/**
- * @brief This enumeration defines the Wi-Fi state.
+ * @brief Enumeration for Wi-Fi state.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
- CONNECTION_WIFI_STATE_DEACTIVATED = 0, /**< Deactivated state */
- CONNECTION_WIFI_STATE_DISCONNECTED = 1, /**< disconnected state */
- CONNECTION_WIFI_STATE_CONNECTED = 2, /**< Connected state */
+ CONNECTION_WIFI_STATE_DEACTIVATED = 0, /**< Wi-Fi is deactivated */
+ CONNECTION_WIFI_STATE_DISCONNECTED = 1, /**< Disconnected */
+ CONNECTION_WIFI_STATE_CONNECTED = 2, /**< Connected */
} connection_wifi_state_e;
/**
- * @brief This enumeration defines the ethernet state.
+ * @internal
+ * @brief Enumeration for ethernet state.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
- CONNECTION_ETHERNET_STATE_DEACTIVATED = 0, /**< Deactivated state */
- CONNECTION_ETHERNET_STATE_DISCONNECTED = 1, /**< disconnected state */
- CONNECTION_ETHERNET_STATE_CONNECTED = 2, /**< Connected state */
+ CONNECTION_ETHERNET_STATE_DEACTIVATED = 0, /**< @internal There is no Ethernet profile to open */
+ CONNECTION_ETHERNET_STATE_DISCONNECTED = 1, /**< @internal Disconnected */
+ CONNECTION_ETHERNET_STATE_CONNECTED = 2, /**< @internal Connected */
} connection_ethernet_state_e;
/**
- * @brief This enumeration defines the type of connection iterator.
+ * @brief Enumeration for Bluetooth state.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
+typedef enum
+{
+ CONNECTION_BT_STATE_DEACTIVATED = 0, /**< There is no Bluetooth profile to open */
+ CONNECTION_BT_STATE_DISCONNECTED = 1, /**< Disconnected */
+ CONNECTION_BT_STATE_CONNECTED = 2, /**< Connected */
+} connection_bt_state_e;
+
+/**
+ * @brief Enumeration for connection iterator type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
- CONNECTION_ITERATOR_TYPE_REGISTERED = 0, /**< The iterator of registered profile */
- CONNECTION_ITERATOR_TYPE_CONNECTED = 1, /**< The iterator of connected profile */
+ CONNECTION_ITERATOR_TYPE_REGISTERED = 0, /**< The iterator of the registered profile */
+ CONNECTION_ITERATOR_TYPE_CONNECTED = 1, /**< The iterator of the connected profile */
+ CONNECTION_ITERATOR_TYPE_DEFAULT = 2, /**< The iterator of the default profile */
} connection_iterator_type_e;
/**
- * @brief Enumerations of connection errors.
+ * @brief Enumeration for reset profile type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+*/
+typedef enum
+{
+ CONNECTION_RESET_DEFAULT_PROFILE = 0, /**< Initialized with the default profile defined by csc */
+ CONNECTION_RESET_CLEAR_PROFILE = 1, /**< Remove all profiles */
+} connection_reset_option_e;
+
+/**
+ * @brief Enumeration for connection errors.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
@@ -105,9 +137,17 @@ typedef enum
CONNECTION_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory error */
CONNECTION_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid Operation */
CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED = TIZEN_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED, /**< Address family not supported */
- CONNECTION_ERROR_OPERATION_FAILED = TIZEN_ERROR_NETWORK_CLASS|0x0401, /**< Operation failed */
- CONNECTION_ERROR_ITERATOR_END = TIZEN_ERROR_NETWORK_CLASS|0x0402, /**< End of iteration */
- CONNECTION_ERROR_NO_CONNECTION = TIZEN_ERROR_NETWORK_CLASS|0x0403, /**< There is no connection */
+ CONNECTION_ERROR_OPERATION_FAILED = TIZEN_ERROR_CONNECTION|0x0401, /**< Operation failed */
+ CONNECTION_ERROR_ITERATOR_END = TIZEN_ERROR_CONNECTION|0x0402, /**< End of iteration */
+ CONNECTION_ERROR_NO_CONNECTION = TIZEN_ERROR_CONNECTION|0x0403, /**< There is no connection */
+ CONNECTION_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /** Now in progress */
+ CONNECTION_ERROR_ALREADY_EXISTS = TIZEN_ERROR_CONNECTION|0x0404, /**< Already exists */
+ CONNECTION_ERROR_OPERATION_ABORTED = TIZEN_ERROR_CONNECTION|0x0405, /**< Operation is aborted */
+ CONNECTION_ERROR_DHCP_FAILED = TIZEN_ERROR_CONNECTION|0x0406, /**< DHCP failed */
+ CONNECTION_ERROR_INVALID_KEY = TIZEN_ERROR_CONNECTION|0x0407, /**< Invalid key */
+ CONNECTION_ERROR_NO_REPLY = TIZEN_ERROR_CONNECTION|0x0408, /**< No reply */
+ CONNECTION_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
+ CONNECTION_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED /**< Not Supported */
} connection_error_e;
/**
@@ -120,7 +160,8 @@ typedef enum
*/
/**
- * @brief Enumerations of statistics type.
+ * @brief Enumeration for statistics type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
*/
typedef enum
{
@@ -142,9 +183,12 @@ typedef enum
/**
* @brief Creates a handle for managing data connections.
- * @remarks @a handle must be released with connection_destroy().
- * @param[out] connection The handle of the connection
- * @return 0 on success, otherwise negative error value.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @remarks You must release @a handle using connection_destroy().
+ * @param[out] connection The connection handle
+ * @return @c 0 on success, otherwise a negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
@@ -154,8 +198,9 @@ int connection_create(connection_h* connection);
/**
* @brief Destroys the connection handle.
- * @param[in] connection The handle of the connection
- * @return 0 on success, otherwise negative error value.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] connection The connection handle
+ * @return @c 0 on success, otherwise negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @see connection_create()
@@ -163,16 +208,18 @@ int connection_create(connection_h* connection);
int connection_destroy(connection_h connection);
/**
- * @brief Called when the type of connection is changed.
- * @param[in] type The type of current network connection
+ * @brief Called when the type of a connection is changed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] type The type of the current network connection
* @param[in] user_data The user data passed from the callback registration function
- * @see connection_set_network_type_changed_cb()
- * @see connection_unset_network_type_changed_cb()
+ * @see connection_set_type_changed_cb()
+ * @see connection_unset_type_changed_cb()
*/
typedef void(*connection_type_changed_cb)(connection_type_e type, void* user_data);
/**
* @brief Called when the address is changed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @param[in] ipv4_address The IP address for IPv4
* @param[in] ipv6_address The IP address for IPv6
* @param[in] user_data The user data passed from the callback registration function
@@ -183,13 +230,22 @@ typedef void(*connection_type_changed_cb)(connection_type_e type, void* user_dat
*/
typedef void(*connection_address_changed_cb)(const char* ipv4_address, const char* ipv6_address, void* user_data);
+/**
+ * @brief Called when connection_set_default_cellular_service_profile_async() finishes.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] result The result
+ * @param[in] user_data The user data passed from connection_open_profile()
+ * @pre connection_set_default_cellular_service_profile_async() will invoke this callback function.
+ * @see connection_set_default_cellular_service_profile_async()
+*/
+typedef void(*connection_set_default_cb)(connection_error_e result, void* user_data);
/**
- * @brief Gets the type.
- * @details The returned type is for the current connection.
- * @param[in] connection The handle of the connection
- * @param[out] state The state of network
- * @return 0 on success, otherwise negative error value.
+ * @brief Gets the type of the current profile for data connection.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] connection The connection handle
+ * @param[out] type The type of the network
+ * @return @c 0 on success, otherwise negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
@@ -198,11 +254,12 @@ int connection_get_type(connection_h connection, connection_type_e* type);
/**
* @brief Gets the IP address of the current connection.
- * @remarks @a ip_address must be released with free() by you.
- * @param[in] connection The handle of the connection
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks You must release @a ip_address using free().
+ * @param[in] connection The connection handle
* @param[in] address_family The address family
- * @param[out] ip_address The pointer to IP address string.
- * @return 0 on success, otherwise negative error value.
+ * @param[out] ip_address The pointer to the IP address string
+ * @return @c 0 on success, otherwise a negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
@@ -212,11 +269,12 @@ int connection_get_ip_address(connection_h connection, connection_address_family
/**
* @brief Gets the proxy address of the current connection.
- * @remarks @a proxy must be released with free() by you.
- * @param[in] connection The handle of the connection
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks You must release @a proxy using free().
+ * @param[in] connection The connection handle
* @param[in] address_family The address family
* @param[out] proxy The proxy address
- * @return 0 on success, otherwise negative error value.
+ * @return @c 0 on success, otherwise a negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
@@ -225,47 +283,78 @@ int connection_get_ip_address(connection_h connection, connection_address_family
int connection_get_proxy(connection_h connection, connection_address_family_e address_family, char** proxy);
/**
- * @brief Gets the state of celluar connection.
+ * @brief Gets the state of cellular connection.
* @details The returned state is for the cellular connection state.
- * @param[in] connection The handle of connection
- * @param[out] state The state of cellular connection
- * @return 0 on success, otherwise negative error value.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] connection The connection handle
+ * @param[out] state The state of the cellular connection
+ * @return @c 0 on success, otherwise a negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
*/
int connection_get_cellular_state(connection_h connection, connection_cellular_state_e* state);
/**
- * @brief Gets the state of Wi-Fi.
+ * @brief Gets the state of the Wi-Fi.
* @details The returned state is for the Wi-Fi connection state.
- * @param[in] connection The handle of connection
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @param[in] connection The connection handle
* @param[out] state The state of Wi-Fi connection
- * @return 0 on success, otherwise negative error value.
+ * @return @c 0 on success, otherwise a negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
*/
int connection_get_wifi_state(connection_h connection, connection_wifi_state_e* state);
/**
- * @brief Gets the state of ethernet.
- * @details The returned state is for the ethernet connection state.
- * @param[in] connection The handle of connection
+ * @internal
+ * @brief Gets the state of the Ethernet.
+ * @details The returned state is for the Ethernet connection state.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @param[in] connection The connection handle
* @param[out] state The state of Ethernet connection
- * @return 0 on success, otherwise negative error value.
+ * @return @c 0 on success, otherwise a negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
*/
int connection_get_ethernet_state(connection_h connection, connection_ethernet_state_e* state);
/**
- * @brief Registers the callback called when the type of current connection is changed.
- * @param[in] connection The handle of connection
+ * @brief Gets the state of the Bluetooth.
+ * @details The returned state is for the Bluetooth connection state.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @param[in] connection The connection handle
+ * @param[out] state The state of the Bluetooth connection
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported
+ */
+int connection_get_bt_state(connection_h connection, connection_bt_state_e* state);
+
+/**
+ * @brief Registers the callback that is called when the type of the current connection is changed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] connection The connection handle
* @param[in] callback The callback function to be called
* @param[in] user_data The user data passed to the callback function
- * @return 0 on success, otherwise negative error value.
+ * @return @c 0 on success, otherwise a negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
@@ -273,9 +362,10 @@ int connection_get_ethernet_state(connection_h connection, connection_ethernet_s
int connection_set_type_changed_cb(connection_h connection, connection_type_changed_cb callback, void* user_data);
/**
- * @brief Unregisters the callback called when the type of current connection is changed.
- * @param[in] connection The handle of connection
- * @return 0 on success, otherwise negative error value.
+ * @brief Unregisters the callback that is called when the type of current connection is changed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] connection The connection handle
+ * @return @c 0 on success, otherwise a negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
@@ -283,11 +373,12 @@ int connection_set_type_changed_cb(connection_h connection, connection_type_chan
int connection_unset_type_changed_cb(connection_h connection);
/**
- * @brief Registers the callback called when the IP address is changed.
- * @param[in] connection The handle of connection
+ * @brief Registers the callback that is called when the IP address is changed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] connection The connection handle
* @param[in] callback The callback function to be called
* @param[in] user_data The user data passed to the callback function
- * @return 0 on success, otherwise negative error value.
+ * @return @c 0 on success, otherwise a negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
@@ -295,9 +386,10 @@ int connection_unset_type_changed_cb(connection_h connection);
int connection_set_ip_address_changed_cb(connection_h connection, connection_address_changed_cb callback, void* user_data);
/**
- * @brief Unregisters the callback called when the IP address is changed.
- * @param[in] connection The handle of connection
- * @return 0 on success, otherwise negative error value.
+ * @brief Unregisters the callback that is called when the IP address is changed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] connection The connection handle
+ * @return @c 0 on success, otherwise a negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
@@ -305,11 +397,12 @@ int connection_set_ip_address_changed_cb(connection_h connection, connection_add
int connection_unset_ip_address_changed_cb(connection_h connection);
/**
- * @brief Registers the callback called when the proxy address is changed.
- * @param[in] connection The handle of connection
+ * @brief Registers the callback that is called when the proxy address is changed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] connection The connection handle
* @param[in] callback The callback function to be called
* @param[in] user_data The user data passed to the callback function
- * @return 0 on success, otherwise negative error value.
+ * @return @c 0 on success, otherwise a negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
@@ -317,9 +410,10 @@ int connection_unset_ip_address_changed_cb(connection_h connection);
int connection_set_proxy_address_changed_cb(connection_h connection, connection_address_changed_cb callback, void* user_data);
/**
- * @brief Unregisters the callback called when the proxy address is changed.
- * @param[in] connection The handle of connection
- * @return 0 on success, otherwise negative error value.
+ * @brief Unregisters the callback that is called when the proxy address is changed.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] connection The connection handle
+ * @return @c 0 on success, otherwise a negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
@@ -327,57 +421,88 @@ int connection_set_proxy_address_changed_cb(connection_h connection, connection_
int connection_unset_proxy_address_changed_cb(connection_h connection);
/**
- * @brief Adds new profile which is created by connection_profile_created().
- * @param[in] connection The handle of connection
- * @param[in] profile The handle of profile
- * @return 0 on success, otherwise negative error value.
+ * @brief Adds a new profile which is created by connection_profile_create().
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile \n
+ * %http://tizen.org/privilege/network.get
+ * @remarks You can only add a profile of the cellular type. \n
+ * This API needs both privileges.
+ * @param[in] connection The connection handle
+ * @param[in] profile The profile handle
+ * @return @c 0 on success, otherwise a negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not Supported
*/
int connection_add_profile(connection_h connection, connection_profile_h profile);
/**
- * @brief Removes existing profile.
- * @param[in] connection The handle of connection
- * @param[in] profile The handle of profile
- * @return 0 on success, otherwise negative error value.
+ * @brief Removes an existing profile.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile \n
+ * %http://tizen.org/privilege/network.get
+ * @remarks This API needs both privileges.
+ * @param[in] connection The connection handle
+ * @param[in] profile The profile handle
+ * @return @c 0 on success, otherwise a negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not Supported
*/
int connection_remove_profile(connection_h connection, connection_profile_h profile);
/**
- * @brief Updates existing profile.
- * @param[in] connection The handle of connection
- * @param[in] profile The handle of profile
- * @return 0 on success, otherwise negative error value.
+ * @brief Updates an existing profile.
+ * @details When a profile is changed, these changes will be not applied to the Connection Manager immediately.
+ * When you call this function, your changes affect the Connection Manager and the existing profile is updated.
+ * In addition, the existing profile will be updated if you call connection_open_profile().
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile \n
+ * %http://tizen.org/privilege/network.get
+ * @remarks This API needs both privileges.
+ * @param[in] connection The connection handle
+ * @param[in] profile The profile handle
+ * @return @c 0 on success, otherwise a negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not Supported
+ * @see connection_open_profile()
*/
int connection_update_profile(connection_h connection, connection_profile_h profile);
/**
- * @brief Gets a iterator of the profiles.
- * @remarks @a profile_iterator must be released with connection_destroy().
- * @param[in] connection The handle of connection
- * @param[in] type The type of connetion iterator
+ * @brief Gets a profiles iterator.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @remarks You must release @a profile_iterator using connection_destroy().
+ * @param[in] connection The connection handle
+ * @param[in] type The type of the connetion iterator
* @param[out] profile_iterator The iterator of profile
- * @return 0 on success, otherwise negative error value.
+ * @return @c 0 on success, otherwise a negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
*/
int connection_get_profile_iterator(connection_h connection, connection_iterator_type_e type, connection_profile_iterator_h* profile_iterator);
/**
* @brief Moves the profile iterator to the next position and gets a profile handle.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
* @param[in] profile_iterator The iterator of profile
- * @param[out] profile The handle of profile
- * @return 0 on success, otherwise negative error value.
+ * @param[out] profile The profile handle
+ * @return @c 0 on success, otherwise a negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_ITERATOR_END End of iteration
@@ -385,70 +510,285 @@ int connection_get_profile_iterator(connection_h connection, connection_iterator
int connection_profile_iterator_next(connection_profile_iterator_h profile_iterator, connection_profile_h* profile);
/**
- * @brief Checks whether the next element of profile iterator exists or not.
+ * @brief Checks whether the next element of a profile iterator exists or not.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
* @param[in] profile_iterator The iterator of profile
- * @return @c true if next element exists, \n @c false if next element doesn't exist
+ * @return @c true if next element exists, otherwise @c false if next element doesn't exist
*/
bool connection_profile_iterator_has_next(connection_profile_iterator_h profile_iterator);
/**
- * @brief Destroys a iterator of the profiles.
- * @param[in] profile_iterator The iterator of profile
- * @return 0 on success, otherwise negative error value.
+ * @brief Destroys a profiles iterator.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] profile_iterator The iterator of the profile
+ * @return @c 0 on success, otherwise a negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
*/
int connection_destroy_profile_iterator(connection_profile_iterator_h profile_iterator);
/**
- * @brief Gets the name of default profile.
- * @remarks @a profile must be released with connection_profile_destroy().
- * @param[in] connection The handle of connection
- * @param[out] profile The handle of profile
- * @return 0 on success, otherwise negative error value.
+ * @brief Gets the name of the default profile.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @remarks You must release @a profile using connection_profile_destroy().
+ * @param[in] connection The connection handle
+ * @param[out] profile The profile handle
+ * @return @c 0 on success, otherwise a negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
* @retval #CONNECTION_ERROR_NO_CONNECTION There is no connection
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
*/
int connection_get_current_profile(connection_h connection, connection_profile_h* profile);
/**
- * @brief Opens the connection with the profile, asynchronously.
- * @param[in] connection The handle of connection
- * @param[in] profile The handle of profile
- * @return 0 on success, otherwise negative error value.
+ * @brief Gets the default profile which provides the given cellular service.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @remarks You must release @a profile using connection_profile_destroy().
+ * @param[in] connection The connection handle
+ * @param[in] type The type of cellular service \n
+ * #CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION is not permitted.
+ * @param[out] profile The profile handle
+ * @return @c 0 on success, otherwise a negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denieda
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not Supported
+ */
+int connection_get_default_cellular_service_profile(connection_h connection, connection_cellular_service_type_e type, connection_profile_h* profile);
+
+/**
+ * @brief Sets the default profile which provides the given cellular service.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile \n
+ * %http://tizen.org/privilege/network.get
+ * @remarks This API needs both privileges.
+ * @param[in] connection The connection handle
+ * @param[in] type The type of cellular service \n
+ * only #CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET and #CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET are permitted.
+ * @param[in] profile The profile handle
+ * @return @c 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not Supported
*/
-int connection_open_profile(connection_h connection, connection_profile_h profile);
+int connection_set_default_cellular_service_profile(connection_h connection, connection_cellular_service_type_e type, connection_profile_h profile);
/**
- * @brief Opens the connection with service type, asynchronously.
- * @remarks @a profile must be released with connection_profile_destroy().
- * @param[in] connection The handle of connection
- * @param[in] type The type of cellular service
- * @param[out] profile The handle of profile
- * @return 0 on success, otherwise negative error value.
+ * @brief Sets the default profile which provides the given cellular service, asynchronously.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile \n
+ * %http://tizen.org/privilege/network.get
+ * @remarks This API needs both privileges.
+ * @param[in] connection The connection handle
+ * @param[in] type The type of cellular service (only #CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET and #CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET are permitted)
+ * @param[in] profile The profile handle
+ * @param[in] callback The callback function to be called
+ * @param[in] user_data The user data passed to the callback function
+ * @return @c 0 on success, otherwise negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not Supported
*/
-int connection_open_cellular_service_type(connection_h connection, connection_cellular_service_type_e type, connection_profile_h* profile);
+int connection_set_default_cellular_service_profile_async(connection_h connection,
+ connection_cellular_service_type_e type, connection_profile_h profile, connection_set_default_cb callback, void* user_data);
/**
- * @brief Closes the connection with the profile.
- * @param[in] connection The handle of connection
- * @param[in] profile The handle of profile
- * @return 0 on success, otherwise negative error value.
+ * @brief Called after connection_open_profile() is finished.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] result The result
+ * @param[in] user_data The user data passed from connection_open_profile()
+ * @pre connection_open_profile() will invoke this callback function.
+ * @see connection_open_profile()
+*/
+typedef void(*connection_opened_cb)(connection_error_e result, void* user_data);
+
+/**
+ * @brief Called after connection_close_profile() is finished.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] result The result
+ * @param[in] user_data The user data passed from connection_close_profile()
+ * @pre connection_close_profile() will invoke this callback function.
+ * @see connection_close_profile()
+*/
+typedef void(*connection_closed_cb)(connection_error_e result, void* user_data);
+
+/**
+ * @brief Called after connection_reset_profile() is finished.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in] result The result
+ * @param[in] user_data The user data passed from connection_reset_profile()
+ * @pre connection_reset_profile() will invoke this callback function.
+ * @see connection_reset_profile()
+*/
+typedef void(*connection_reset_cb)(connection_error_e result, void* user_data);
+
+/**
+ * @brief Opens a connection of profile, asynchronously.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.set \n
+ * %http://tizen.org/privilege/network.get
+ * @remarks This API needs both privileges.
+ * @param[in] connection The connection handle
+ * @param[in] profile The profile handle
+ * @param[in] callback The callback function to be called
+ * @param[in] user_data The user data passed to the callback function
+ * @return @c 0 on success, otherwise negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
+ * @post connection_opened_cb() will be invoked.
+ * @see connection_opened_cb()
+ * @see connection_close_profile()
+ * @see connection_profile_set_state_changed_cb()
+ * @see connection_profile_unset_state_changed_cb()
+ * @see connection_profile_state_changed_cb()
+ */
+int connection_open_profile(connection_h connection, connection_profile_h profile, connection_opened_cb callback, void* user_data);
+
+/**
+ * @brief Closes a connection of profile.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.set \n
+ * %http://tizen.org/privilege/network.get
+ * @remarks This API needs both privileges.
+ * @param[in] connection The connection handle
+ * @param[in] profile The profile handle
+ * @param[in] callback The callback function to be called
+ * @param[in] user_data The user data passed to the callback function
+ * @return @c 0 on success, otherwise negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
+ * @post connection_closed_cb() will be invoked.
+ * @see connection_closed_cb()
+ * @see connection_open_profile()
+ * @see connection_profile_set_state_changed_cb()
+ * @see connection_profile_unset_state_changed_cb()
+ * @see connection_profile_state_changed_cb()
+ */
+int connection_close_profile(connection_h connection, connection_profile_h profile, connection_closed_cb callback, void* user_data);
+
+/**
+ * @brief Resets the cellular profile.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.profile \n
+ * %http://tizen.org/privilege/network.get
+ * @remarks This API needs both privileges.
+ * @param[in] connection The connection handle
+ * @param[in] type The type of reset
+ * @param[in] id The subscriber identity module id to reset (The sim index starts from 0.)
+ * @param[in] callback The callback function to be called
+ * @param[in] user_data The user data passed to the callback function
+ * @return 0 on success, otherwise negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not Supported
+ * @post connection_reset_cb() will be invoked.
+*/
+int connection_reset_profile(connection_h connection, connection_reset_option_e type, int id, connection_reset_cb callback, void *user_data);
+
+/**
+ * @brief Adds a IPv4 route to the routing table.
+ * @details You can get the @a interface_name from connection_profile_get_network_interface_name() of opened profile.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.set \n
+ * %http://tizen.org/privilege/network.get
+ * @remarks This API needs both privileges.
+ * @param[in] connection The connection handle
+ * @param[in] interface_name The name of network interface
+ * @param[in] host_address The IP address of the host
+ * @return @c 0 on success, otherwise negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_ALREADY_EXISTS Already exists
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
+ * @see connection_profile_get_network_interface_name()
+ */
+int connection_add_route(connection_h connection, const char* interface_name, const char* host_address);
+
+/**
+ * @brief Removes a IPv4 route from the routing table.
+ * @details You can get the @a interface_name from connection_profile_get_network_interface_name() of opened profile.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.set \n
+ * %http://tizen.org/privilege/network.get
+ * @remarks This API needs both privileges.
+ * @param[in] connection The connection handle
+ * @param[in] interface_name The name of network interface
+ * @param[in] host_address The IP address of the host
+ * @return @c 0 on success, otherwise negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
+ * @see connection_profile_get_network_interface_name()
+ */
+int connection_remove_route(connection_h connection, const char* interface_name, const char* host_address);
+
+/**
+ * @brief Adds a IPv6 route to the routing table.
+ * @details You can get the @a interface_name from connection_profile_get_network_interface_name() of opened profile.
+ * @since_tizen 2.3.1
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.set
+ * @param[in] connection The connection handle
+ * @param[in] interface_name The name of network interface
+ * @param[in] host_address The IP address of the host
+ * @param[in] gateway The gateway address
+ * @return @c 0 on success, otherwise negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_ALREADY_EXISTS Already exists
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
+ * @see connection_profile_get_network_interface_name()
+ */
+int connection_add_route_ipv6(connection_h connection, const char *interface_name, const char *host_address, const char * gateway);
+
+/**
+ * @brief Removes a IPV6 route from the routing table.
+ * @details You can get the @a interface_name from connection_profile_get_network_interface_name() of opened profile.
+ * @since_tizen 2.3.1
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.set
+ * @param[in] connection The connection handle
+ * @param[in] interface_name The name of network interface
+ * @param[in] host_address The IP address of the host
+ * @param[in] gateway The gateway address
+ * @return @c 0 on success, otherwise negative error value
+ * @retval #CONNECTION_ERROR_NONE Successful
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
+ * @see connection_profile_get_network_interface_name()
*/
-int connection_close_profile(connection_h connection, connection_profile_h profile);
+int connection_remove_route_ipv6(connection_h connection, const char *interface_name, const char *host_address, const char * gateway);
/**
* @}
@@ -461,31 +801,43 @@ int connection_close_profile(connection_h connection, connection_profile_h profi
/**
* @brief Gets the statistics information.
- * @param[in] connection_type The type of connection. CONNECTION_TYPE_WIFI and CONNECTION_TYPE_CELLULAR are only supported.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.get
+ * @param[in] connection The connection handle
+ * @param[in] connection_type The type of connection (only CONNECTION_TYPE_WIFI and CONNECTION_TYPE_CELLULAR are supported)
* @param[in] statistics_type The type of statistics
* @param[out] size The received data size of the last cellular packet data connection (bytes)
- * @return 0 on success, otherwise negative error value.
+ * @return @c 0 on success, otherwise negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not Supported
*/
-int connection_get_statistics(connection_type_e connection_type, connection_statistics_type_e statistics_type, long long* size);
+int connection_get_statistics(connection_h connection, connection_type_e connection_type, connection_statistics_type_e statistics_type, long long* size);
/**
- * @brief Resets the statistics information
- * @param[in] connection_type The type of connection. CONNECTION_TYPE_WIFI and CONNECTION_TYPE_CELLULAR are only supported.
+ * @brief Resets the statistics information.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/network.set \n
+ * %http://tizen.org/privilege/network.get
+ * @remarks This API needs both privileges.
+ * @param[in] connection The connection handle
+ * @param[in] connection_type The type of connection (only CONNECTION_TYPE_WIFI and CONNECTION_TYPE_CELLULAR are supported)
* @param[in] statistics_type The type of statistics
- * @return 0 on success, otherwise negative error value.
+ * @return @c 0 on success, otherwise negative error value
* @retval #CONNECTION_ERROR_NONE Successful
* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter
* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not Supported
*/
-int connection_reset_statistics(connection_type_e connection_type, connection_statistics_type_e statistics_type);
+int connection_reset_statistics(connection_h connection, connection_type_e connection_type, connection_statistics_type_e statistics_type);
/**
* @}
- */
-
+*/
#ifdef __cplusplus
}
diff --git a/include/net_connection_private.h b/include/net_connection_private.h
index 40f198c..831ee54 100644..100755
--- a/include/net_connection_private.h
+++ b/include/net_connection_private.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,70 +14,123 @@
* limitations under the License.
*/
-
-
-#ifndef __NET_CONNECTION_PRIVATE_H__ /* To prevent inclusion of a header file twice */
+#ifndef __NET_CONNECTION_PRIVATE_H__
#define __NET_CONNECTION_PRIVATE_H__
#include <dlog.h>
#include <network-cm-intf.h>
#include <network-wifi-intf.h>
-#include "net_connection.h"
-
-#define TIZEN_NET_CONNECTION "net_connection"
-
-#define CONNECTION_INFO LOG_VERBOSE
-#define CONNECTION_ERROR LOG_ERROR
-#define CONNECTION_WARN LOG_WARN
-
-#define CONNECTION_LOG(log_level, format, args...) \
- SLOG(log_level,TIZEN_NET_CONNECTION, "[%s][Ln: %d] " format, __FILE__, __LINE__, ##args)
-
-#define CONNECTION_MUTEX_LOCK _connection_inter_mutex_lock()
-#define CONNECTION_MUTEX_UNLOCK _connection_inter_mutex_unlock()
+#include "net_connection.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
-typedef struct _connection_handle_s
+#undef LOG_TAG
+#define LOG_TAG "CAPI_NETWORK_CONNECTION"
+
+#define CONNECTION_INFO 1
+#define CONNECTION_ERROR 2
+#define CONNECTION_WARN 3
+
+#define TELEPHONY_FEATURE "http://tizen.org/feature/network.telephony"
+#define WIFI_FEATURE "http://tizen.org/feature/network.wifi"
+#define TETHERING_BLUETOOTH_FEATURE "http://tizen.org/feature/network.tethering.bluetooth"
+#define ETHERNET_FEATURE "http://tizen.org/feature/network.ethernet"
+
+typedef enum
{
- connection_type_changed_cb state_changed_callback;
- connection_address_changed_cb ip_changed_callback;
- connection_address_changed_cb proxy_changed_callback;
- void *state_changed_user_data;
- void *ip_changed_user_data;
- void *proxy_changed_user_data;
-} connection_handle_s;
+ CONNECTION_CELLULAR_SUBSCRIBER_1 = 0x00,
+ CONNECTION_CELLULAR_SUBSCRIBER_2 = 0x01,
+} connection_cellular_subscriber_id_e;
-bool _connection_libnet_init(void);
+#define CHECK_FEATURE_SUPPORTED(...) \
+ do { \
+ int rv = _connection_check_feature_supported(__VA_ARGS__, NULL); \
+ if( rv != CONNECTION_ERROR_NONE ) \
+ return rv; \
+ } while(0)
+
+#define CONNECTION_LOG(log_level, format, args...) \
+ do { \
+ switch (log_level) { \
+ case CONNECTION_ERROR: \
+ LOGE(format, ## args); \
+ break; \
+ case CONNECTION_WARN: \
+ LOGW(format, ## args); \
+ break; \
+ default: \
+ LOGI(format, ## args); \
+ } \
+ } while(0)
+
+#define SECURE_CONNECTION_LOG(log_level, format, args...) \
+ do { \
+ switch (log_level) { \
+ case CONNECTION_ERROR: \
+ SECURE_LOGE(format, ## args); \
+ break; \
+ case CONNECTION_WARN: \
+ SECURE_LOGW(format, ## args); \
+ break; \
+ default: \
+ SECURE_LOGI(format, ## args); \
+ } \
+ } while(0)
+
+#define VCONF_TELEPHONY_DEFAULT_DATA_SERVICE \
+ "db/telephony/dualsim/default_data_service"
+
+bool _connection_is_created(void);
+
+int _connection_libnet_init(void);
bool _connection_libnet_deinit(void);
-bool _connection_libnet_get_ethernet_state(connection_ethernet_state_e* state);
+int _connection_libnet_get_wifi_state(connection_wifi_state_e *state);
+int _connection_libnet_get_ethernet_state(connection_ethernet_state_e *state);
+int _connection_libnet_get_bluetooth_state(connection_bt_state_e* state);
bool _connection_libnet_check_profile_validity(connection_profile_h profile);
+bool _connection_libnet_check_profile_cb_validity(connection_profile_h profile);
int _connection_libnet_get_profile_iterator(connection_iterator_type_e type,
- connection_profile_iterator_h* profile_iterator);
+ connection_profile_iterator_h *profile_iterator);
bool _connection_libnet_iterator_has_next(connection_profile_iterator_h profile_iterator);
int _connection_libnet_get_iterator_next(connection_profile_iterator_h profile_iter_h, connection_profile_h *profile);
int _connection_libnet_destroy_iterator(connection_profile_iterator_h profile_iter_h);
int _connection_libnet_get_current_profile(connection_profile_h *profile);
-int _connection_libnet_open_profile(connection_profile_h profile);
-int _connection_libnet_open_cellular_service_type(connection_cellular_service_type_e type, connection_profile_h *profile);
-int _connection_libnet_close_profile(connection_profile_h profile);
+int _connection_libnet_reset_profile(connection_reset_option_e type, connection_cellular_subscriber_id_e id, connection_reset_cb callback, void *user_data);
+int _connection_libnet_open_profile(connection_profile_h profile, connection_opened_cb callback, void *user_data);
+int _connection_libnet_get_cellular_service_profile(connection_cellular_service_type_e type, connection_profile_h *profile);
+int _connection_libnet_set_cellular_service_profile_sync(connection_cellular_service_type_e type, connection_profile_h profile);
+int _connection_libnet_set_cellular_service_profile_async(connection_cellular_service_type_e type,
+ connection_profile_h profile, connection_set_default_cb callback, void* user_data);
+int _connection_libnet_close_profile(connection_profile_h profile, connection_closed_cb callback, void *user_data);
+int _connection_libnet_add_route(const char *interface_name, const char *host_address);
+int _connection_libnet_remove_route(const char *interface_name, const char *host_address);
+int _connection_libnet_add_route_ipv6(const char *interface_name, const char *host_address, const char * gateway);
+int _connection_libnet_remove_route_ipv6(const char *interface_name, const char *host_address, const char * gateway);
void _connection_libnet_add_to_profile_list(connection_profile_h profile);
void _connection_libnet_remove_from_profile_list(connection_profile_h profile);
bool _connection_libnet_add_to_profile_cb_list(connection_profile_h profile,
connection_profile_state_changed_cb callback, void *user_data);
-void _connection_libnet_remove_from_profile_cb_list(connection_profile_h profile);
+bool _connection_libnet_remove_from_profile_cb_list(connection_profile_h profile);
int _connection_libnet_set_statistics(net_device_t device_type, net_statistics_type_e statistics_type);
int _connection_libnet_get_statistics(net_statistics_type_e statistics_type, unsigned long long *size);
+int _connection_libnet_check_get_privilege();
+int _connection_libnet_check_profile_privilege();
+
+int _connection_check_feature_supported(const char *feature_name, ...);
+
+guint _connection_callback_add(GSourceFunc func, gpointer user_data);
+void _connection_callback_cleanup(void);
+connection_cellular_service_type_e _profile_convert_to_connection_cellular_service_type(net_service_type_t svc_type);
+connection_profile_state_e _profile_convert_to_cp_state(net_state_type_t state);
net_service_type_t _connection_profile_convert_to_libnet_cellular_service_type(connection_cellular_service_type_e svc_type);
net_state_type_t _connection_profile_convert_to_net_state(connection_profile_state_e state);
-void _connection_inter_mutex_lock(void);
-void _connection_inter_mutex_unlock(void);
+int _connection_libnet_set_cellular_subscriber_id(connection_profile_h profile, connection_cellular_subscriber_id_e sim_id);
#ifdef __cplusplus
}
diff --git a/packaging/capi-network-connection.spec b/packaging/capi-network-connection.spec
index 4a87075..298c472 100644
--- a/packaging/capi-network-connection.spec
+++ b/packaging/capi-network-connection.spec
@@ -1,55 +1,72 @@
-#sbs-git:api/connection
-
-Name: capi-network-connection
-Summary: Network Connection library in TIZEN C API
-Version: 0.1.1_9
-Release: 1
-Group: System/Network
-License: Apache License Version 2.0
-Source0: %{name}-%{version}.tar.gz
-BuildRequires: cmake
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(vconf)
-BuildRequires: pkgconfig(capi-base-common)
-BuildRequires: pkgconfig(network)
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
+Name: capi-network-connection
+Summary: Network Connection library in TIZEN C API
+Version: 1.0.58
+Release: 1
+Group: System/Network
+License: Apache-2.0
+Source0: %{name}-%{version}.tar.gz
+BuildRequires: cmake
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(network)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(capi-base-common)
+BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: model-build-features
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
%description
Network Connection library in Tizen C API
%package devel
-Summary: Network Connection library in Tizen C API (Development)
-Group: System/Network
-Requires: %{name} = %{version}-%{release}
+Summary: Network Connection library in Tizen C API (Development)
+Group: System/Network
+Requires: %{name} = %{version}-%{release}
%description devel
Network Connection library in Tizen C API (Development)
-
%prep
%setup -q
%build
+export CFLAGS+=' -Wno-unused-local-typedefs'
MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
-
+cmake -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \
+%if 0%{?model_build_feature_network_dsds} == 1
+ -DTIZEN_DUALSIM_ENABLE=1 \
+%endif
+%if "%{?tizen_profile_name}" == "wearable"
+ -DTIZEN_WEARABLE=1 \
+%else
+%if "%{?tizen_profile_name}" == "mobile"
+ -DTIZEN_MOBILE=1 \
+%endif
+%endif
+ .
+
+make %{?_smp_mflags}
-make %{?jobs:-j%jobs}
%install
-rm -rf %{buildroot}
%make_install
+#License
+mkdir -p %{buildroot}%{_datadir}/license
+cp LICENSE %{buildroot}%{_datadir}/license/capi-network-connection
+
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%files
-%{_libdir}/libcapi-network-connection.so.*
+%manifest capi-network-connection.manifest
+%attr(644,-,-) %{_libdir}/libcapi-network-connection.so.*
+%{_datadir}/license/capi-network-connection
+%{_bindir}/connection_test
%files devel
%{_includedir}/network/*.h
diff --git a/src/connection.c b/src/connection.c
index ffa0193..0cb4f82 100755
--- a/src/connection.c
+++ b/src/connection.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,18 +14,23 @@
* limitations under the License.
*/
+#include <glib.h>
#include <stdio.h>
#include <string.h>
-#include <glib.h>
#include <vconf/vconf.h>
-#include "net_connection_private.h"
-static GSList *conn_handle_list = NULL;
+#include "net_connection_private.h"
-static void __connection_cb_state_change_cb(keynode_t *node, void *user_data);
-static void __connection_cb_ip_change_cb(keynode_t *node, void *user_data);
-static void __connection_cb_proxy_change_cb(keynode_t *node, void *user_data);
+typedef struct _connection_handle_s {
+ connection_type_changed_cb type_changed_callback;
+ connection_address_changed_cb ip_changed_callback;
+ connection_address_changed_cb proxy_changed_callback;
+ void *type_changed_user_data;
+ void *ip_changed_user_data;
+ void *proxy_changed_user_data;
+} connection_handle_s;
+static __thread GSList *conn_handle_list = NULL;
static int __connection_convert_net_state(int status)
{
@@ -34,6 +39,10 @@ static int __connection_convert_net_state(int status)
return CONNECTION_TYPE_CELLULAR;
case VCONFKEY_NETWORK_WIFI:
return CONNECTION_TYPE_WIFI;
+ case VCONFKEY_NETWORK_ETHERNET:
+ return CONNECTION_TYPE_ETHERNET;
+ case VCONFKEY_NETWORK_BLUETOOTH:
+ return CONNECTION_TYPE_BT;
default:
return CONNECTION_TYPE_DISCONNECTED;
}
@@ -55,623 +64,999 @@ static int __connection_convert_cellular_state(int status)
}
}
-static int __connection_convert_wifi_state(int status)
+static bool __connection_check_handle_validity(connection_h connection)
{
- switch (status) {
- case VCONFKEY_NETWORK_WIFI_CONNECTED:
- return CONNECTION_WIFI_STATE_CONNECTED;
- case VCONFKEY_NETWORK_WIFI_NOT_CONNECTED:
- return CONNECTION_WIFI_STATE_DISCONNECTED;
- default:
- return CONNECTION_WIFI_STATE_DEACTIVATED;
- }
+ bool ret = false;
+
+ if (connection == NULL)
+ return false;
+
+ if (g_slist_find(conn_handle_list, connection) != NULL)
+ ret = true;
+
+ return ret;
}
-static int __connection_get_state_changed_callback_count(void)
+static connection_type_changed_cb
+__connection_get_type_changed_callback(connection_handle_s *local_handle)
{
- GSList *list;
- int count = 0;
-
- for (list = conn_handle_list; list; list = list->next) {
- connection_handle_s *local_handle = (connection_handle_s *)list->data;
- if (local_handle->state_changed_callback) count++;
- }
+ return local_handle->type_changed_callback;
+}
- return count;
+static void *__connection_get_type_changed_userdata(
+ connection_handle_s *local_handle)
+{
+ return local_handle->type_changed_user_data;
}
-static int __connection_get_ip_changed_callback_count(void)
+static gboolean __connection_cb_type_changed_cb_idle(gpointer user_data)
{
- GSList *list;
- int count = 0;
+ int state, status;
+ void *data;
+ connection_type_changed_cb callback;
+ connection_handle_s *local_handle = (connection_handle_s *)user_data;
- for (list = conn_handle_list; list; list = list->next) {
- connection_handle_s *local_handle = (connection_handle_s *)list->data;
- if (local_handle->ip_changed_callback) count++;
- }
+ if (__connection_check_handle_validity((connection_h)local_handle) != true)
+ return FALSE;
+
+ if (vconf_get_int(VCONFKEY_NETWORK_STATUS, &status) != 0)
+ return FALSE;
+
+ state = __connection_convert_net_state(status);
- return count;
+ callback = __connection_get_type_changed_callback(local_handle);
+ data = __connection_get_type_changed_userdata(local_handle);
+ if (callback)
+ callback(state, data);
+
+ return FALSE;
}
-static int __connection_get_proxy_changed_callback_count(void)
+static void __connection_cb_type_change_cb(keynode_t *node, void *user_data)
{
GSList *list;
- int count = 0;
+ connection_h handle;
- for (list = conn_handle_list; list; list = list->next) {
- connection_handle_s *local_handle = (connection_handle_s *)list->data;
- if (local_handle->proxy_changed_callback) count++;
+ if (_connection_is_created() != true) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered"
+ "If multi-threaded, thread integrity be broken.");
+ return;
}
- return count;
+ for (list = conn_handle_list; list; list = list->next) {
+ handle = (connection_h)list->data;
+ _connection_callback_add(__connection_cb_type_changed_cb_idle, (gpointer)handle);
+ }
}
-static int __connection_set_state_changed_callback(connection_h connection, void *callback, void *user_data)
+static int __connection_set_type_changed_callback(connection_h connection,
+ void *callback, void *user_data)
{
- connection_handle_s *local_handle = (connection_handle_s *)connection;
+ static __thread gint refcount = 0;
+ connection_handle_s *local_handle;
+
+ local_handle = (connection_handle_s *)connection;
if (callback) {
- if (__connection_get_state_changed_callback_count() == 0)
- if (vconf_notify_key_changed(VCONFKEY_NETWORK_STATUS ,
- __connection_cb_state_change_cb, NULL))
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (refcount == 0)
+ vconf_notify_key_changed(VCONFKEY_NETWORK_STATUS,
+ __connection_cb_type_change_cb, NULL);
- local_handle->state_changed_user_data = user_data;
+ refcount++;
+ CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)", refcount);
} else {
- if (local_handle->state_changed_callback &&
- __connection_get_state_changed_callback_count() == 1)
- if (vconf_ignore_key_changed(VCONFKEY_NETWORK_STATUS,
- __connection_cb_state_change_cb))
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (refcount > 0 &&
+ __connection_get_type_changed_callback(local_handle) != NULL) {
+ if (--refcount == 0) {
+ if (vconf_ignore_key_changed(VCONFKEY_NETWORK_STATUS,
+ __connection_cb_type_change_cb) < 0) {
+ CONNECTION_LOG(CONNECTION_ERROR,
+ "Error to de-register vconf callback(%d)", refcount);
+ } else {
+ CONNECTION_LOG(CONNECTION_INFO,
+ "Successfully de-registered(%d)", refcount);
+ }
+ }
+ }
}
- local_handle->state_changed_callback = callback;
+ local_handle->type_changed_user_data = user_data;
+ local_handle->type_changed_callback = callback;
+
return CONNECTION_ERROR_NONE;
}
-static int __connection_set_ip_changed_callback(connection_h connection, void *callback, void *user_data)
+static connection_address_changed_cb
+__connection_get_ip_changed_callback(connection_handle_s *local_handle)
{
- connection_handle_s *local_handle = (connection_handle_s *)connection;
+ return local_handle->ip_changed_callback;
+}
- if (callback) {
- if (__connection_get_ip_changed_callback_count() == 0)
- if (vconf_notify_key_changed(VCONFKEY_NETWORK_IP,
- __connection_cb_ip_change_cb, NULL))
- return CONNECTION_ERROR_OPERATION_FAILED;
+static void *__connection_get_ip_changed_userdata(
+ connection_handle_s *local_handle)
+{
+ return local_handle->ip_changed_user_data;
+}
- local_handle->ip_changed_user_data = user_data;
- } else {
- if (local_handle->ip_changed_callback &&
- __connection_get_ip_changed_callback_count() == 1)
- if (vconf_ignore_key_changed(VCONFKEY_NETWORK_IP,
- __connection_cb_ip_change_cb))
- return CONNECTION_ERROR_OPERATION_FAILED;
+static gboolean __connection_cb_ip_changed_cb_idle(gpointer user_data)
+{
+ char *ip_addr;
+ void *data;
+ connection_address_changed_cb callback;
+ connection_handle_s *local_handle = (connection_handle_s *)user_data;
+
+ if (__connection_check_handle_validity((connection_h)local_handle) != true)
+ return FALSE;
+
+ ip_addr = vconf_get_str(VCONFKEY_NETWORK_IP);
+
+ callback = __connection_get_ip_changed_callback(local_handle);
+ data = __connection_get_ip_changed_userdata(local_handle);
+ /* TODO: IPv6 should be supported */
+ if (callback)
+ callback(ip_addr, NULL, data);
+
+ return FALSE;
+}
+
+static void __connection_cb_ip_change_cb(keynode_t *node, void *user_data)
+{
+ GSList *list;
+ connection_h handle;
+
+ if (_connection_is_created() != true) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered"
+ "If multi-threaded, thread integrity be broken.");
+ return;
}
- local_handle->ip_changed_callback = callback;
- return CONNECTION_ERROR_NONE;
+ for (list = conn_handle_list; list; list = list->next) {
+ handle = (connection_h)list->data;
+ _connection_callback_add(__connection_cb_ip_changed_cb_idle, (gpointer)handle);
+ }
}
-static int __connection_set_proxy_changed_callback(connection_h connection, void *callback, void *user_data)
+static int __connection_set_ip_changed_callback(connection_h connection,
+ void *callback, void *user_data)
{
- connection_handle_s *local_handle = (connection_handle_s *)connection;
+ static __thread gint refcount = 0;
+ connection_handle_s *local_handle;
+
+ local_handle = (connection_handle_s *)connection;
if (callback) {
- if (__connection_get_proxy_changed_callback_count() == 0)
- if (vconf_notify_key_changed(VCONFKEY_NETWORK_PROXY,
- __connection_cb_proxy_change_cb, NULL))
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (refcount == 0)
+ vconf_notify_key_changed(VCONFKEY_NETWORK_IP,
+ __connection_cb_ip_change_cb, NULL);
- local_handle->proxy_changed_user_data = user_data;
+ refcount++;
+ CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)", refcount);
} else {
- if (local_handle->proxy_changed_callback &&
- __connection_get_proxy_changed_callback_count() == 1)
- if (vconf_ignore_key_changed(VCONFKEY_NETWORK_PROXY,
- __connection_cb_proxy_change_cb))
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (refcount > 0 &&
+ __connection_get_ip_changed_callback(local_handle) != NULL) {
+ if (--refcount == 0) {
+ if (vconf_ignore_key_changed(VCONFKEY_NETWORK_IP,
+ __connection_cb_ip_change_cb) < 0) {
+ CONNECTION_LOG(CONNECTION_ERROR,
+ "Error to de-register vconf callback(%d)", refcount);
+ } else {
+ CONNECTION_LOG(CONNECTION_INFO,
+ "Successfully de-registered(%d)", refcount);
+ }
+ }
+ }
}
- local_handle->proxy_changed_callback = callback;
+ local_handle->ip_changed_user_data = user_data;
+ local_handle->ip_changed_callback = callback;
+
return CONNECTION_ERROR_NONE;
}
-static void __connection_cb_state_change_cb(keynode_t *node, void *user_data)
+static connection_address_changed_cb
+__connection_get_proxy_changed_callback(connection_handle_s *local_handle)
{
- CONNECTION_LOG(CONNECTION_INFO, "Net Status Changed Indication\n");
-
- GSList *list;
- int state = vconf_keynode_get_int(node);
+ return local_handle->proxy_changed_callback;
+}
- for (list = conn_handle_list; list; list = list->next) {
- connection_handle_s *local_handle = (connection_handle_s *)list->data;
- if (local_handle->state_changed_callback)
- local_handle->state_changed_callback(
- __connection_convert_net_state(state),
- local_handle->state_changed_user_data);
- }
+static void *__connection_get_proxy_changed_userdata(
+ connection_handle_s *local_handle)
+{
+ return local_handle->proxy_changed_user_data;
}
-static void __connection_cb_ip_change_cb(keynode_t *node, void *user_data)
+static gboolean __connection_cb_proxy_changed_cb_idle(gpointer user_data)
{
- CONNECTION_LOG(CONNECTION_INFO, "Net IP Changed Indication\n");
+ char *proxy;
+ void *data;
+ connection_address_changed_cb callback;
+ connection_handle_s *local_handle = (connection_handle_s *)user_data;
- GSList *list;
- char *ip_addr = vconf_keynode_get_str(node);
+ if (__connection_check_handle_validity((connection_h)local_handle) != true)
+ return FALSE;
- for (list = conn_handle_list; list; list = list->next) {
- connection_handle_s *local_handle = (connection_handle_s *)list->data;
- if (local_handle->ip_changed_callback)
- local_handle->ip_changed_callback(
- ip_addr, NULL,
- local_handle->ip_changed_user_data);
- }
+ proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
+
+ callback = __connection_get_proxy_changed_callback(local_handle);
+ data = __connection_get_proxy_changed_userdata(local_handle);
+ /* TODO: IPv6 should be supported */
+ if (callback)
+ callback(proxy, NULL, data);
+
+ return FALSE;
}
static void __connection_cb_proxy_change_cb(keynode_t *node, void *user_data)
{
- CONNECTION_LOG(CONNECTION_INFO, "Net IP Changed Indication\n");
-
GSList *list;
- char *proxy = vconf_keynode_get_str(node);
+ connection_h handle;
+
+ if (_connection_is_created() != true) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered"
+ "If multi-threaded, thread integrity be broken.");
+ return;
+ }
for (list = conn_handle_list; list; list = list->next) {
- connection_handle_s *local_handle = (connection_handle_s *)list->data;
- if (local_handle->proxy_changed_callback)
- local_handle->proxy_changed_callback(
- proxy, NULL,
- local_handle->proxy_changed_user_data);
+ handle = (connection_h)list->data;
+ _connection_callback_add(__connection_cb_proxy_changed_cb_idle, (gpointer)handle);
}
}
-static bool __connection_check_handle_validity(connection_h connection)
+static int __connection_set_proxy_changed_callback(connection_h connection,
+ void *callback, void *user_data)
{
- GSList *list;
+ static __thread gint refcount = 0;
+ connection_handle_s *local_handle;
- for (list = conn_handle_list; list; list = list->next)
- if (connection == list->data) return true;
+ local_handle = (connection_handle_s *)connection;
- return false;
-}
-
-static int __connection_get_handle_count(void)
-{
- GSList *list;
- int count = 0;
+ if (callback) {
+ if (refcount == 0)
+ vconf_notify_key_changed(VCONFKEY_NETWORK_PROXY,
+ __connection_cb_proxy_change_cb, NULL);
- if (!conn_handle_list)
- return count;
+ refcount++;
+ CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)", refcount);
+ } else {
+ if (refcount > 0 &&
+ __connection_get_proxy_changed_callback(local_handle) != NULL) {
+ if (--refcount == 0) {
+ if (vconf_ignore_key_changed(VCONFKEY_NETWORK_PROXY,
+ __connection_cb_proxy_change_cb) < 0) {
+ CONNECTION_LOG(CONNECTION_ERROR,
+ "Error to de-register vconf callback(%d)", refcount);
+ } else {
+ CONNECTION_LOG(CONNECTION_INFO,
+ "Successfully de-registered(%d)", refcount);
+ }
+ }
+ }
+ }
- for (list = conn_handle_list; list; list = list->next) count++;
+ local_handle->proxy_changed_user_data = user_data;
+ local_handle->proxy_changed_callback = callback;
- return count;
+ return CONNECTION_ERROR_NONE;
}
-/* Connection Manager module ********************************************************************/
+static int __connection_get_handle_count(void)
+{
+ return ((int)g_slist_length(conn_handle_list));
+}
-int connection_create(connection_h* connection)
+/* Connection Manager ********************************************************/
+EXPORT_API int connection_create(connection_h *connection)
{
- CONNECTION_MUTEX_LOCK;
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (connection == NULL || __connection_check_handle_validity(*connection)) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
- CONNECTION_MUTEX_UNLOCK;
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- if (_connection_libnet_init() == false) {
- CONNECTION_LOG(CONNECTION_ERROR, "Creation failed!\n");
- CONNECTION_MUTEX_UNLOCK;
+ int rv = _connection_libnet_init();
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ }
+ else if (rv != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to create connection[%d]", rv);
return CONNECTION_ERROR_OPERATION_FAILED;
}
*connection = g_try_malloc0(sizeof(connection_handle_s));
- if (*connection != NULL) {
- CONNECTION_LOG(CONNECTION_INFO, "New Handle Created %p\n", *connection);
- } else {
- CONNECTION_MUTEX_UNLOCK;
+ if (*connection != NULL)
+ CONNECTION_LOG(CONNECTION_INFO, "New handle created[%p]", *connection);
+ else
return CONNECTION_ERROR_OUT_OF_MEMORY;
- }
- conn_handle_list = g_slist_append(conn_handle_list, *connection);
+ conn_handle_list = g_slist_prepend(conn_handle_list, *connection);
- CONNECTION_MUTEX_UNLOCK;
return CONNECTION_ERROR_NONE;
}
-int connection_destroy(connection_h connection)
+EXPORT_API int connection_destroy(connection_h connection)
{
- CONNECTION_MUTEX_LOCK;
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
- if (connection == NULL || !(__connection_check_handle_validity(connection))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
- CONNECTION_MUTEX_UNLOCK;
+ if (!(__connection_check_handle_validity(connection))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- CONNECTION_LOG(CONNECTION_INFO, "Destroy Handle : %p\n", connection);
+ CONNECTION_LOG(CONNECTION_INFO, "Destroy handle: %p", connection);
- __connection_set_state_changed_callback(connection, NULL, NULL);
+ __connection_set_type_changed_callback(connection, NULL, NULL);
__connection_set_ip_changed_callback(connection, NULL, NULL);
__connection_set_proxy_changed_callback(connection, NULL, NULL);
conn_handle_list = g_slist_remove(conn_handle_list, connection);
g_free(connection);
+ connection = NULL;
- if (__connection_get_handle_count() == 0)
+ if (__connection_get_handle_count() == 0) {
_connection_libnet_deinit();
+ _connection_callback_cleanup();
+ }
- CONNECTION_MUTEX_UNLOCK;
return CONNECTION_ERROR_NONE;
}
-int connection_get_type(connection_h connection, connection_type_e* type)
+EXPORT_API int connection_get_type(connection_h connection, connection_type_e* type)
{
- int status = 0;
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
if (type == NULL || !(__connection_check_handle_validity(connection))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
+ int status = 0;
if (vconf_get_int(VCONFKEY_NETWORK_STATUS, &status)) {
- CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_int Failed = %d\n", status);
+ CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_int Failed = %d", status);
return CONNECTION_ERROR_OPERATION_FAILED;
}
- CONNECTION_LOG(CONNECTION_INFO, "Connected Network = %d\n", status);
+ CONNECTION_LOG(CONNECTION_INFO, "Connected Network = %d", status);
*type = __connection_convert_net_state(status);
return CONNECTION_ERROR_NONE;
}
-int connection_get_ip_address(connection_h connection, connection_address_family_e address_family, char** ip_address)
+EXPORT_API int connection_get_ip_address(connection_h connection,
+ connection_address_family_e address_family, char** ip_address)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (ip_address == NULL || !(__connection_check_handle_validity(connection))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
switch (address_family) {
case CONNECTION_ADDRESS_FAMILY_IPV4:
- *ip_address = vconf_get_str(VCONFKEY_NETWORK_IP);
- break;
case CONNECTION_ADDRESS_FAMILY_IPV6:
- CONNECTION_LOG(CONNECTION_ERROR, "Not supported yet\n");
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+ *ip_address = vconf_get_str(VCONFKEY_NETWORK_IP);
break;
default:
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (*ip_address == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_str Failed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_str Failed");
return CONNECTION_ERROR_OPERATION_FAILED;
}
- CONNECTION_LOG(CONNECTION_INFO, "IP Address %s\n", *ip_address);
-
return CONNECTION_ERROR_NONE;
}
-int connection_get_proxy(connection_h connection, connection_address_family_e address_family, char** proxy)
+EXPORT_API int connection_get_proxy(connection_h connection,
+ connection_address_family_e address_family, char** proxy)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (proxy == NULL || !(__connection_check_handle_validity(connection))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
switch (address_family) {
case CONNECTION_ADDRESS_FAMILY_IPV4:
- *proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
- break;
case CONNECTION_ADDRESS_FAMILY_IPV6:
- CONNECTION_LOG(CONNECTION_ERROR, "Not supported yet\n");
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+ *proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
break;
default:
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
if (*proxy == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_str Failed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_str Failed");
return CONNECTION_ERROR_OPERATION_FAILED;
}
- CONNECTION_LOG(CONNECTION_INFO, "Proxy Address %s\n", *proxy);
-
return CONNECTION_ERROR_NONE;
}
-int connection_get_cellular_state(connection_h connection, connection_cellular_state_e* state)
+EXPORT_API int connection_get_cellular_state(connection_h connection, connection_cellular_state_e* state)
{
+ int rv = 0;
int status = 0;
+ int cellular_state = 0;
+#if defined TIZEN_DUALSIM_ENABLE
+ int sim_id = 0;
+#endif
+
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
if (state == NULL || !(__connection_check_handle_validity(connection))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- if (!vconf_get_int(VCONFKEY_NETWORK_CELLULAR_STATE, &status)) {
- CONNECTION_LOG(CONNECTION_INFO, "Cellular = %d\n", status);
- *state = __connection_convert_cellular_state(status);
- return CONNECTION_ERROR_NONE;
- } else {
- CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_int Failed = %d\n", status);
+ rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_STATE, &status);
+ if (rv != VCONF_OK) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get cellular state");
return CONNECTION_ERROR_OPERATION_FAILED;
}
+
+ CONNECTION_LOG(CONNECTION_INFO, "Cellular: %d", status);
+ *state = __connection_convert_cellular_state(status);
+
+ if (*state == CONNECTION_CELLULAR_STATE_AVAILABLE) {
+#if defined TIZEN_DUALSIM_ENABLE
+ rv = vconf_get_int(VCONF_TELEPHONY_DEFAULT_DATA_SERVICE, &sim_id);
+ if (rv != VCONF_OK) {
+ CONNECTION_LOG(CONNECTION_ERROR,
+ "Failed to get default subscriber id", sim_id);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ switch (sim_id) {
+ case CONNECTION_CELLULAR_SUBSCRIBER_1:
+#endif
+ rv = vconf_get_int(VCONFKEY_DNET_STATE, &cellular_state);
+#if defined TIZEN_DUALSIM_ENABLE
+ break;
+
+ case CONNECTION_CELLULAR_SUBSCRIBER_2:
+ rv = vconf_get_int(VCONFKEY_DNET_STATE2, &cellular_state);
+ break;
+
+ default:
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid subscriber id:%d", sim_id);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+#endif
+ if (rv != VCONF_OK) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get cellular state");
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+ }
+
+ CONNECTION_LOG(CONNECTION_INFO, "Cellular state: %d", cellular_state);
+
+ if (cellular_state == VCONFKEY_DNET_NORMAL_CONNECTED ||
+ cellular_state == VCONFKEY_DNET_SECURE_CONNECTED ||
+ cellular_state == VCONFKEY_DNET_TRANSFER)
+ *state = CONNECTION_CELLULAR_STATE_CONNECTED;
+
+ return CONNECTION_ERROR_NONE;
}
-int connection_get_wifi_state(connection_h connection, connection_wifi_state_e* state)
+EXPORT_API int connection_get_wifi_state(connection_h connection, connection_wifi_state_e* state)
{
- int status = 0;
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
if (state == NULL || !(__connection_check_handle_validity(connection))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- if (!vconf_get_int(VCONFKEY_NETWORK_WIFI_STATE, &status)) {
- CONNECTION_LOG(CONNECTION_INFO, "WiFi = %d\n", status);
- *state = __connection_convert_wifi_state(status);
- return CONNECTION_ERROR_NONE;
- } else {
- CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_int Failed = %d\n", status);
- return CONNECTION_ERROR_OPERATION_FAILED;
+ int rv = _connection_libnet_get_wifi_state(state);
+ if (rv != CONNECTION_ERROR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Fail to get Wi-Fi state[%d]", rv);
+ return rv;
}
+
+ CONNECTION_LOG(CONNECTION_INFO, "Wi-Fi state: %d", *state);
+
+ return CONNECTION_ERROR_NONE;
}
-int connection_get_ethernet_state(connection_h connection, connection_ethernet_state_e* state)
+EXPORT_API int connection_get_ethernet_state(connection_h connection, connection_ethernet_state_e* state)
{
+ CHECK_FEATURE_SUPPORTED(ETHERNET_FEATURE);
+
if (state == NULL || !(__connection_check_handle_validity(connection))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- if (_connection_libnet_get_ethernet_state(state) == false)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ return _connection_libnet_get_ethernet_state(state);
+}
- return CONNECTION_ERROR_NONE;
+EXPORT_API int connection_get_bt_state(connection_h connection, connection_bt_state_e* state)
+{
+ CHECK_FEATURE_SUPPORTED(TETHERING_BLUETOOTH_FEATURE);
+
+ if (state == NULL || !(__connection_check_handle_validity(connection))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ return _connection_libnet_get_bluetooth_state(state);
}
-int connection_set_type_changed_cb(connection_h connection,
+EXPORT_API int connection_set_type_changed_cb(connection_h connection,
connection_type_changed_cb callback, void* user_data)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (callback == NULL || !(__connection_check_handle_validity(connection))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- return __connection_set_state_changed_callback(connection, callback, user_data);
+ return __connection_set_type_changed_callback(connection, callback, user_data);
}
-int connection_unset_type_changed_cb(connection_h connection)
+EXPORT_API int connection_unset_type_changed_cb(connection_h connection)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(__connection_check_handle_validity(connection))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- return __connection_set_state_changed_callback(connection, NULL, NULL);
+ return __connection_set_type_changed_callback(connection, NULL, NULL);
}
-int connection_set_ip_address_changed_cb(connection_h connection,
+EXPORT_API int connection_set_ip_address_changed_cb(connection_h connection,
connection_address_changed_cb callback, void* user_data)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (callback == NULL || !(__connection_check_handle_validity(connection))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
return __connection_set_ip_changed_callback(connection, callback, user_data);
}
-int connection_unset_ip_address_changed_cb(connection_h connection)
+EXPORT_API int connection_unset_ip_address_changed_cb(connection_h connection)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(__connection_check_handle_validity(connection))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
return __connection_set_ip_changed_callback(connection, NULL, NULL);
}
-int connection_set_proxy_address_changed_cb(connection_h connection,
+EXPORT_API int connection_set_proxy_address_changed_cb(connection_h connection,
connection_address_changed_cb callback, void* user_data)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (callback == NULL || !(__connection_check_handle_validity(connection))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
return __connection_set_proxy_changed_callback(connection, callback, user_data);
}
-int connection_unset_proxy_address_changed_cb(connection_h connection)
+EXPORT_API int connection_unset_proxy_address_changed_cb(connection_h connection)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(__connection_check_handle_validity(connection))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
return __connection_set_proxy_changed_callback(connection, NULL, NULL);
}
-int connection_add_profile(connection_h connection, connection_profile_h profile)
+EXPORT_API int connection_add_profile(connection_h connection, connection_profile_h profile)
{
+ int rv = 0;
+ net_profile_info_t *profile_info = profile;
+
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
+
if (!(__connection_check_handle_validity(connection)) ||
!(_connection_libnet_check_profile_validity(profile))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- int rv = 0;
+ if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
- net_profile_info_t *profile_info = profile;
+ if (profile_info->ProfileInfo.Pdp.PSModemPath[0] != '/' ||
+ strlen(profile_info->ProfileInfo.Pdp.PSModemPath) < 2) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Modem object path is NULL");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
- rv = net_add_profile(profile_info->ProfileInfo.Pdp.ServiceType, (net_profile_info_t*)profile);
- if (rv != NET_ERR_NONE) {
- CONNECTION_LOG(CONNECTION_ERROR, "net_add_profile Failed = %d\n", rv);
+ rv = net_add_profile(profile_info->ProfileInfo.Pdp.ServiceType,
+ (net_profile_info_t*)profile);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to add profile[%d]", rv);
return CONNECTION_ERROR_OPERATION_FAILED;
}
return CONNECTION_ERROR_NONE;
}
-int connection_remove_profile(connection_h connection, connection_profile_h profile)
+EXPORT_API int connection_remove_profile(connection_h connection, connection_profile_h profile)
{
+ int rv = 0;
+ net_profile_info_t *profile_info = profile;
+
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE);
+
if (!(__connection_check_handle_validity(connection)) ||
- !(_connection_libnet_check_profile_validity(profile))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ !(_connection_libnet_check_profile_validity(profile))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- int rv = 0;
- net_profile_info_t *profile_info = profile;
+ if (profile_info->profile_type != NET_DEVICE_CELLULAR &&
+ profile_info->profile_type != NET_DEVICE_WIFI) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
rv = net_delete_profile(profile_info->ProfileName);
- if (rv != NET_ERR_NONE) {
- CONNECTION_LOG(CONNECTION_ERROR, "net_delete_profile Failed = %d\n", rv);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to delete profile[%d]", rv);
return CONNECTION_ERROR_OPERATION_FAILED;
}
return CONNECTION_ERROR_NONE;
}
-int connection_update_profile(connection_h connection, connection_profile_h profile)
+EXPORT_API int connection_update_profile(connection_h connection, connection_profile_h profile)
{
+ int rv = 0;
+ net_profile_info_t *profile_info = profile;
+
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE);
+
if (!(__connection_check_handle_validity(connection)) ||
!(_connection_libnet_check_profile_validity(profile))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- int rv = 0;
- net_profile_info_t *profile_info = profile;
-
rv = net_modify_profile(profile_info->ProfileName, (net_profile_info_t*)profile);
- if (rv != NET_ERR_NONE) {
- CONNECTION_LOG(CONNECTION_ERROR, "net_modify_profile Failed = %d\n", rv);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to modify profile[%d]", rv);
return CONNECTION_ERROR_OPERATION_FAILED;
}
return CONNECTION_ERROR_NONE;
}
-int connection_get_profile_iterator(connection_h connection,
+EXPORT_API int connection_get_profile_iterator(connection_h connection,
connection_iterator_type_e type, connection_profile_iterator_h* profile_iterator)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(__connection_check_handle_validity(connection)) ||
(type != CONNECTION_ITERATOR_TYPE_REGISTERED &&
- type != CONNECTION_ITERATOR_TYPE_CONNECTED)) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ type != CONNECTION_ITERATOR_TYPE_CONNECTED &&
+ type != CONNECTION_ITERATOR_TYPE_DEFAULT)) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
return _connection_libnet_get_profile_iterator(type, profile_iterator);
}
-int connection_profile_iterator_next(connection_profile_iterator_h profile_iterator, connection_profile_h* profile)
+EXPORT_API int connection_profile_iterator_next(connection_profile_iterator_h profile_iterator,
+ connection_profile_h* profile)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
return _connection_libnet_get_iterator_next(profile_iterator, profile);
}
-bool connection_profile_iterator_has_next(connection_profile_iterator_h profile_iterator)
+EXPORT_API bool connection_profile_iterator_has_next(connection_profile_iterator_h profile_iterator)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
return _connection_libnet_iterator_has_next(profile_iterator);
}
-int connection_destroy_profile_iterator(connection_profile_iterator_h profile_iterator)
+EXPORT_API int connection_destroy_profile_iterator(connection_profile_iterator_h profile_iterator)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
return _connection_libnet_destroy_iterator(profile_iterator);
}
-int connection_get_current_profile(connection_h connection, connection_profile_h* profile)
+EXPORT_API int connection_get_current_profile(connection_h connection, connection_profile_h* profile)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(__connection_check_handle_validity(connection)) || profile == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
return _connection_libnet_get_current_profile(profile);
}
-int connection_open_profile(connection_h connection, connection_profile_h profile)
+EXPORT_API int connection_get_default_cellular_service_profile(
+ connection_h connection, connection_cellular_service_type_e type,
+ connection_profile_h *profile)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
+
if (!(__connection_check_handle_validity(connection)) || profile == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- return _connection_libnet_open_profile(profile);
+ return _connection_libnet_get_cellular_service_profile(type, profile);
}
-int connection_open_cellular_service_type(connection_h connection,
- connection_cellular_service_type_e type, connection_profile_h* profile)
+EXPORT_API int connection_set_default_cellular_service_profile(connection_h connection,
+ connection_cellular_service_type_e type, connection_profile_h profile)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
+
if (!(__connection_check_handle_validity(connection)) || profile == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- return _connection_libnet_open_cellular_service_type(type, profile);
+ return _connection_libnet_set_cellular_service_profile_sync(type, profile);
}
-int connection_close_profile(connection_h connection, connection_profile_h profile)
+EXPORT_API int connection_set_default_cellular_service_profile_async(connection_h connection,
+ connection_cellular_service_type_e type, connection_profile_h profile,
+ connection_set_default_cb callback, void* user_data)
{
- if (!(__connection_check_handle_validity(connection)) || profile == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
+
+ if (!(__connection_check_handle_validity(connection)) ||
+ profile == NULL || callback == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- return _connection_libnet_close_profile(profile);
+ return _connection_libnet_set_cellular_service_profile_async(type, profile, callback, user_data);
}
+EXPORT_API int connection_open_profile(connection_h connection, connection_profile_h profile,
+ connection_opened_cb callback, void* user_data)
+{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE);
-/* Connection Statistics module ******************************************************************/
+ if (!(__connection_check_handle_validity(connection)) ||
+ profile == NULL || callback == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
-static int __get_statistic(connection_type_e connection_type, connection_statistics_type_e statistics_type, long long* llsize)
+ return _connection_libnet_open_profile(profile, callback, user_data);
+}
+
+EXPORT_API int connection_close_profile(connection_h connection, connection_profile_h profile,
+ connection_closed_cb callback, void* user_data)
{
- int size;
- unsigned long long ull_size;
- int stat_type;
- char *key = NULL;
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE);
+
+ if (!(__connection_check_handle_validity(connection)) ||
+ profile == NULL || callback == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ return _connection_libnet_close_profile(profile, callback, user_data);
+}
+
+EXPORT_API int connection_reset_profile(connection_h connection,
+ connection_reset_option_e type, int id, connection_reset_cb callback, void *user_data)
+{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
+
+ if (!(__connection_check_handle_validity(connection))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ if(id < 0 || id > 1) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ return _connection_libnet_reset_profile(type, id, callback, user_data);
+}
+
+EXPORT_API int connection_add_route(connection_h connection, const char* interface_name, const char* host_address)
+{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+ if (!(__connection_check_handle_validity(connection)) ||
+ interface_name == NULL || host_address == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ return _connection_libnet_add_route(interface_name, host_address);
+}
+
+EXPORT_API int connection_remove_route(connection_h connection, const char* interface_name, const char* host_address)
+{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+ if (!(__connection_check_handle_validity(connection)) ||
+ interface_name == NULL || host_address == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ return _connection_libnet_remove_route(interface_name, host_address);
+}
+
+EXPORT_API int connection_add_route_ipv6(connection_h connection, const char *interface_name, const char *host_address, const char * gateway)
+{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE);
+
+ if (!(__connection_check_handle_validity(connection)) ||
+ interface_name == NULL || host_address == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ return _connection_libnet_add_route_ipv6(interface_name, host_address, gateway);
+}
+
+EXPORT_API int connection_remove_route_ipv6(connection_h connection, const char *interface_name, const char *host_address, const char * gateway)
+{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE);
+
+ if (!(__connection_check_handle_validity(connection)) ||
+ interface_name == NULL || host_address == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ return _connection_libnet_remove_route_ipv6(interface_name, host_address, gateway);
+}
+
+static int __get_cellular_statistic(connection_statistics_type_e statistics_type, long long *llsize)
+{
+ int rv = VCONF_OK, rv1 = VCONF_OK;
+ int last_size = 0, size = 0;
+#if defined TIZEN_DUALSIM_ENABLE
+ int sim_id = 0;
+#endif
if (llsize == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ switch (statistics_type) {
+ case CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA:
+ case CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA:
+ case CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA:
+ case CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA:
+ break;
+ default:
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- if (connection_type == CONNECTION_TYPE_CELLULAR) {
+#if defined TIZEN_DUALSIM_ENABLE
+ rv = vconf_get_int(VCONF_TELEPHONY_DEFAULT_DATA_SERVICE, &sim_id);
+ if (rv != VCONF_OK) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get default subscriber id");
+ *llsize = 0;
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ switch (sim_id) {
+ case 0:
+#endif
switch (statistics_type) {
case CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA:
- key = VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT;
+ rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT, &last_size);
break;
case CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA:
- key = VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV;
+ rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV, &last_size);
break;
case CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA:
- key = VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT;
+ rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT, &last_size);
+ rv1 = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT, &size);
break;
case CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA:
- key = VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV;
+ rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV, &last_size);
+ rv1 = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV, &size);
break;
- default:
- return CONNECTION_ERROR_INVALID_PARAMETER;
}
-
- if (vconf_get_int(key, &size)) {
- CONNECTION_LOG(CONNECTION_ERROR, "Cannot Get %s = %d\n", key, size);
- *llsize = 0;
- return CONNECTION_ERROR_OPERATION_FAILED;
+#if defined TIZEN_DUALSIM_ENABLE
+ break;
+ case 1:
+ switch (statistics_type) {
+ case CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA:
+ rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT2, &last_size);
+ break;
+ case CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA:
+ rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV2, &last_size);
+ break;
+ case CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA:
+ rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT2, &last_size);
+ rv1 = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT2, &size);
+ break;
+ case CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA:
+ rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV2, &last_size);
+ rv1 = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV2, &size);
+ break;
}
+ break;
+ default:
+ *llsize = 0;
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid subscriber id:%d", sim_id);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+#endif
+
+ if (rv != VCONF_OK || rv1 != VCONF_OK) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get cellular statistics");
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
- CONNECTION_LOG(CONNECTION_INFO,"%s:%d bytes\n", key, size);
- *llsize = (long long)size;
- } else if (connection_type == CONNECTION_TYPE_WIFI) {
+ *llsize = (long long)(last_size * 1000 + size * 1000);
+ CONNECTION_LOG(CONNECTION_INFO,"%lld bytes", *llsize);
+
+ return CONNECTION_ERROR_NONE;
+}
+
+static int __get_statistic(connection_type_e connection_type,
+ connection_statistics_type_e statistics_type, long long *llsize)
+{
+ int rv, stat_type;
+ unsigned long long ull_size;
+
+ if (llsize == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ rv = _connection_libnet_check_get_privilege();
+ if (rv == CONNECTION_ERROR_PERMISSION_DENIED)
+ return rv;
+ else if (rv != CONNECTION_ERROR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get statistics");
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ if (connection_type == CONNECTION_TYPE_CELLULAR)
+ return __get_cellular_statistic(statistics_type, llsize);
+ else if (connection_type == CONNECTION_TYPE_WIFI) {
switch (statistics_type) {
case CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA:
stat_type = NET_STATISTICS_TYPE_LAST_SENT_DATA;
@@ -689,13 +1074,16 @@ static int __get_statistic(connection_type_e connection_type, connection_statist
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- if (_connection_libnet_get_statistics(stat_type, &ull_size) != CONNECTION_ERROR_NONE) {
- CONNECTION_LOG(CONNECTION_ERROR, "Cannot Get Wi-Fi statistics : %d\n", ull_size);
+ rv = _connection_libnet_get_statistics(stat_type, &ull_size);
+ if (rv == CONNECTION_ERROR_PERMISSION_DENIED)
+ return rv;
+ else if (rv != CONNECTION_ERROR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get Wi-Fi statistics");
*llsize = 0;
return CONNECTION_ERROR_OPERATION_FAILED;
}
- CONNECTION_LOG(CONNECTION_INFO,"%d bytes\n", ull_size);
+ CONNECTION_LOG(CONNECTION_INFO,"%lld bytes", ull_size);
*llsize = (long long)ull_size;
} else
return CONNECTION_ERROR_INVALID_PARAMETER;
@@ -703,7 +1091,8 @@ static int __get_statistic(connection_type_e connection_type, connection_statist
return CONNECTION_ERROR_NONE;
}
-static int __reset_statistic(connection_type_e connection_type, connection_statistics_type_e statistics_type)
+static int __reset_statistic(connection_type_e connection_type,
+ connection_statistics_type_e statistics_type)
{
int conn_type;
int stat_type;
@@ -734,22 +1123,49 @@ static int __reset_statistic(connection_type_e connection_type, connection_stati
}
rv = _connection_libnet_set_statistics(conn_type, stat_type);
- if(rv != CONNECTION_ERROR_NONE)
+ if (rv != CONNECTION_ERROR_NONE)
return rv;
-
- CONNECTION_LOG(CONNECTION_INFO,"connection_reset_statistics success\n");
+ CONNECTION_LOG(CONNECTION_INFO,"connection_reset_statistics success");
return CONNECTION_ERROR_NONE;
}
-int connection_get_statistics(connection_type_e connection_type, connection_statistics_type_e statistics_type, long long* size)
+EXPORT_API int connection_get_statistics(connection_h connection,
+ connection_type_e connection_type,
+ connection_statistics_type_e statistics_type, long long* size)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE);
+
+ if(connection_type == CONNECTION_TYPE_CELLULAR )
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
+ else if(connection_type == CONNECTION_TYPE_WIFI)
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!(__connection_check_handle_validity(connection)) || size == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
return __get_statistic(connection_type, statistics_type, size);
}
-int connection_reset_statistics(connection_type_e connection_type, connection_statistics_type_e statistics_type)
+EXPORT_API int connection_reset_statistics(connection_h connection,
+ connection_type_e connection_type,
+ connection_statistics_type_e statistics_type)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE);
+
+ if(connection_type == CONNECTION_TYPE_CELLULAR )
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
+ else if(connection_type == CONNECTION_TYPE_WIFI)
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
+ if (!__connection_check_handle_validity(connection)) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
return __reset_statistic(connection_type, statistics_type);
}
diff --git a/src/connection_profile.c b/src/connection_profile.c
index 6f4f9e9..d6a9f49 100755
--- a/src/connection_profile.c
+++ b/src/connection_profile.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -11,33 +11,20 @@
* 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.
+ * limitations under the License.
*/
+#include <glib.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <glib.h>
+#include <arpa/inet.h>
#include <vconf/vconf.h>
+
#include "net_connection_private.h"
-
-static connection_cellular_service_type_e __profile_convert_to_connection_cellular_service_type(net_service_type_t svc_type)
-{
- switch (svc_type) {
- case NET_SERVICE_INTERNET:
- return CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET;
- case NET_SERVICE_MMS:
- return CONNECTION_CELLULAR_SERVICE_TYPE_MMS;
- case NET_SERVICE_WAP:
- return CONNECTION_CELLULAR_SERVICE_TYPE_WAP;
- case NET_SERVICE_PREPAID_INTERNET:
- return CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET;
- case NET_SERVICE_PREPAID_MMS:
- return CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS;
- default:
- return CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN;
- }
-}
+#define HTTP_PROXY "http_proxy"
+#define MAX_PREFIX_LENGTH 6
static net_dev_info_t* __profile_get_net_info(net_profile_info_t *profile_info)
{
@@ -48,6 +35,8 @@ static net_dev_info_t* __profile_get_net_info(net_profile_info_t *profile_info)
return &profile_info->ProfileInfo.Wlan.net_info;
case NET_DEVICE_ETHERNET:
return &profile_info->ProfileInfo.Ethernet.net_info;
+ case NET_DEVICE_BLUETOOTH:
+ return &profile_info->ProfileInfo.Bluetooth.net_info;
case NET_DEVICE_DEFAULT:
case NET_DEVICE_USB:
case NET_DEVICE_UNKNOWN:
@@ -57,7 +46,96 @@ static net_dev_info_t* __profile_get_net_info(net_profile_info_t *profile_info)
}
}
-static connection_profile_state_e __profile_convert_to_cp_state(net_state_type_t state)
+static char *__profile_convert_ip_to_string(net_addr_t *ip_addr, connection_address_family_e address_family)
+{
+ unsigned char *ipaddr = NULL;
+ char *ipstr = NULL;
+
+ if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) {
+ ipaddr = (unsigned char *)&ip_addr->Data.Ipv4.s_addr;
+ ipstr = g_try_malloc0(INET_ADDRSTRLEN);
+ if (ipstr == NULL)
+ return NULL;
+
+ inet_ntop(AF_INET, ipaddr, ipstr, INET_ADDRSTRLEN);
+ } else {
+ ipaddr = (unsigned char *)&ip_addr->Data.Ipv6.s6_addr;
+ ipstr = g_try_malloc0(INET6_ADDRSTRLEN);
+ if (ipstr == NULL)
+ return NULL;
+
+ inet_ntop(AF_INET6, ipaddr, ipstr, INET6_ADDRSTRLEN);
+ }
+
+ return ipstr;
+}
+
+static void __profile_init_cellular_profile(net_profile_info_t *profile_info, const char *keyword)
+{
+ int default_subscriber_id = 0;
+ connection_profile_h profile = NULL;
+
+ profile_info->profile_type = NET_DEVICE_CELLULAR;
+ profile_info->ProfileState = NET_STATE_TYPE_IDLE;
+ profile_info->ProfileInfo.Pdp.net_info.IpConfigType = NET_IP_CONFIG_TYPE_OFF;
+ profile_info->ProfileInfo.Pdp.net_info.ProxyMethod = NET_PROXY_TYPE_DIRECT;
+ g_strlcpy(profile_info->ProfileInfo.Pdp.Keyword, keyword, NET_PDP_APN_LEN_MAX);
+
+ if (vconf_get_int(VCONF_TELEPHONY_DEFAULT_DATA_SERVICE,
+ &default_subscriber_id) != 0)
+ CONNECTION_LOG(CONNECTION_ERROR,
+ "Failed to get VCONF_TELEPHONY_DEFAULT_DATA_SERVICE");
+
+ profile = (connection_profile_h)profile_info;
+ _connection_libnet_set_cellular_subscriber_id(profile, default_subscriber_id);
+}
+
+static void __profile_init_wifi_profile(net_profile_info_t *profile_info)
+{
+ profile_info->profile_type = NET_DEVICE_WIFI;
+ profile_info->ProfileState = NET_STATE_TYPE_IDLE;
+ profile_info->ProfileInfo.Wlan.net_info.IpConfigType = NET_IP_CONFIG_TYPE_OFF;
+ profile_info->ProfileInfo.Wlan.net_info.ProxyMethod = NET_PROXY_TYPE_DIRECT;
+ profile_info->ProfileInfo.Wlan.wlan_mode = NETPM_WLAN_CONNMODE_AUTO;
+ profile_info->ProfileInfo.Wlan.security_info.sec_mode = WLAN_SEC_MODE_NONE;
+ profile_info->ProfileInfo.Wlan.security_info.enc_mode = WLAN_ENC_MODE_NONE;
+}
+
+static const char* __profile_get_ethernet_proxy(void)
+{
+ char *proxy;
+
+ proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY);
+
+ if (proxy == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Fail to get system proxy");
+ return NULL;
+ }
+
+ return proxy;
+}
+
+connection_cellular_service_type_e _profile_convert_to_connection_cellular_service_type(net_service_type_t svc_type)
+{
+ switch (svc_type) {
+ case NET_SERVICE_INTERNET:
+ return CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET;
+ case NET_SERVICE_MMS:
+ return CONNECTION_CELLULAR_SERVICE_TYPE_MMS;
+ case NET_SERVICE_PREPAID_INTERNET:
+ return CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET;
+ case NET_SERVICE_PREPAID_MMS:
+ return CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS;
+ case NET_SERVICE_TETHERING:
+ return CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING;
+ case NET_SERVICE_APPLICATION:
+ return CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION;
+ default:
+ return CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN;
+ }
+}
+
+connection_profile_state_e _profile_convert_to_cp_state(net_state_type_t state)
{
connection_profile_state_e cp_state;
@@ -84,19 +162,6 @@ static connection_profile_state_e __profile_convert_to_cp_state(net_state_type_t
return cp_state;
}
-static char* __profile_convert_ip_to_string(net_addr_t *ip_addr)
-{
- unsigned char *ipaddr = (unsigned char *)&ip_addr->Data.Ipv4.s_addr;
-
- char *ipstr = g_try_malloc0(16);
- if (ipstr == NULL)
- return NULL;
-
- snprintf(ipstr, 16, "%d.%d.%d.%d", ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]);
-
- return ipstr;
-}
-
net_service_type_t _connection_profile_convert_to_libnet_cellular_service_type(connection_cellular_service_type_e svc_type)
{
switch (svc_type) {
@@ -104,12 +169,14 @@ net_service_type_t _connection_profile_convert_to_libnet_cellular_service_type(c
return NET_SERVICE_INTERNET;
case CONNECTION_CELLULAR_SERVICE_TYPE_MMS:
return NET_SERVICE_MMS;
- case CONNECTION_CELLULAR_SERVICE_TYPE_WAP:
- return NET_SERVICE_WAP;
case CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET:
return NET_SERVICE_PREPAID_INTERNET;
case CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS:
return NET_SERVICE_PREPAID_MMS;
+ case CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING:
+ return NET_SERVICE_TETHERING;
+ case CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION:
+ return NET_SERVICE_APPLICATION;
default:
return NET_SERVICE_UNKNOWN;
}
@@ -137,57 +204,53 @@ net_state_type_t _connection_profile_convert_to_net_state(connection_profile_sta
return libnet_state;
}
-static void __profile_init_cellular_profile(net_profile_info_t *profile_info)
-{
- profile_info->profile_type = NET_DEVICE_CELLULAR;
- profile_info->ProfileState = NET_STATE_TYPE_IDLE;
- profile_info->ProfileInfo.Pdp.net_info.IpConfigType = NET_IP_CONFIG_TYPE_OFF;
- profile_info->ProfileInfo.Pdp.net_info.ProxyMethod = NET_PROXY_TYPE_DIRECT;
-}
-static void __profile_init_wifi_profile(net_profile_info_t *profile_info)
+/* Connection profile ********************************************************/
+EXPORT_API int connection_profile_create(connection_profile_type_e type, const char* keyword, connection_profile_h* profile)
{
- profile_info->profile_type = NET_DEVICE_WIFI;
- profile_info->ProfileState = NET_STATE_TYPE_IDLE;
- profile_info->ProfileInfo.Wlan.net_info.IpConfigType = NET_IP_CONFIG_TYPE_OFF;
- profile_info->ProfileInfo.Wlan.net_info.ProxyMethod = NET_PROXY_TYPE_DIRECT;
- profile_info->ProfileInfo.Wlan.wlan_mode = NETPM_WLAN_CONNMODE_AUTO;
- profile_info->ProfileInfo.Wlan.security_info.sec_mode = WLAN_SEC_MODE_NONE;
- profile_info->ProfileInfo.Wlan.security_info.enc_mode = WLAN_ENC_MODE_NONE;
-}
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE);
-static void __profile_init_ethernet_profile(net_profile_info_t *profile_info)
-{
- profile_info->profile_type = NET_DEVICE_ETHERNET;
- profile_info->ProfileState = NET_STATE_TYPE_IDLE;
- profile_info->ProfileInfo.Ethernet.net_info.IpConfigType = NET_IP_CONFIG_TYPE_OFF;
- profile_info->ProfileInfo.Ethernet.net_info.ProxyMethod = NET_PROXY_TYPE_DIRECT;
-}
+ if(type == CONNECTION_PROFILE_TYPE_CELLULAR)
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
+ else if(type == CONNECTION_PROFILE_TYPE_WIFI)
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
-/* Connection profile module *********************************************************************/
+ if (type != CONNECTION_PROFILE_TYPE_CELLULAR &&
+ type != CONNECTION_PROFILE_TYPE_WIFI) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
-int connection_profile_create(connection_profile_type_e type, connection_profile_h* profile)
-{
- if ((type != CONNECTION_PROFILE_TYPE_CELLULAR &&
- type != CONNECTION_PROFILE_TYPE_WIFI &&
- type != CONNECTION_PROFILE_TYPE_ETHERNET) || profile == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ if (profile == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
+ int rv = _connection_libnet_check_profile_privilege();
+ if (rv == CONNECTION_ERROR_PERMISSION_DENIED)
+ return rv;
+ else if (rv != CONNECTION_ERROR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to create profile");
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
net_profile_info_t *profile_info = g_try_malloc0(sizeof(net_profile_info_t));
if (profile_info == NULL)
return CONNECTION_ERROR_OUT_OF_MEMORY;
switch (type) {
case CONNECTION_PROFILE_TYPE_CELLULAR:
- __profile_init_cellular_profile(profile_info);
+ if (keyword == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ g_free(profile_info);
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+ __profile_init_cellular_profile(profile_info, keyword);
break;
case CONNECTION_PROFILE_TYPE_WIFI:
__profile_init_wifi_profile(profile_info);
break;
- case CONNECTION_PROFILE_TYPE_ETHERNET:
- __profile_init_ethernet_profile(profile_info);
+ default:
break;
}
@@ -197,10 +260,12 @@ int connection_profile_create(connection_profile_type_e type, connection_profile
return CONNECTION_ERROR_NONE;
}
-int connection_profile_destroy(connection_profile_h profile)
+EXPORT_API int connection_profile_destroy(connection_profile_h profile)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -209,10 +274,12 @@ int connection_profile_destroy(connection_profile_h profile)
return CONNECTION_ERROR_NONE;
}
-int connection_profile_clone(connection_profile_h* cloned_profile, connection_profile_h origin_profile)
+EXPORT_API int connection_profile_clone(connection_profile_h* cloned_profile, connection_profile_h origin_profile)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(origin_profile)) || cloned_profile == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -226,26 +293,75 @@ int connection_profile_clone(connection_profile_h* cloned_profile, connection_pr
return CONNECTION_ERROR_NONE;
}
-int connection_profile_get_name(connection_profile_h profile, char** profile_name)
+EXPORT_API int connection_profile_get_id(connection_profile_h profile, char** profile_id)
+{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+ if (!(_connection_libnet_check_profile_validity(profile)) || profile_id == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ net_profile_info_t *profile_info = profile;
+
+ char *prof_id = strrchr(profile_info->ProfileName, '/');
+ if (prof_id == NULL)
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+
+ prof_id++;
+ *profile_id = g_strdup(prof_id);
+
+ if (*profile_id == NULL)
+ return CONNECTION_ERROR_OUT_OF_MEMORY;
+
+ return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_get_name(connection_profile_h profile, char** profile_name)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || profile_name == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- *profile_name = g_strdup(profile_info->ProfileName);
+ switch (profile_info->profile_type) {
+ case NET_DEVICE_CELLULAR:
+ *profile_name = g_strdup(profile_info->ProfileInfo.Pdp.Keyword);
+ break;
+ case NET_DEVICE_WIFI:
+ *profile_name = g_strdup(profile_info->ProfileInfo.Wlan.essid);
+ break;
+ case NET_DEVICE_ETHERNET:
+ *profile_name = g_strdup(profile_info->ProfileInfo.Ethernet.net_info.DevName);
+ break;
+ case NET_DEVICE_BLUETOOTH: {
+ char *bt_name = strrchr(profile_info->ProfileName, '/');
+ if (bt_name == NULL)
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+
+ bt_name++;
+ *profile_name = g_strdup(bt_name);
+ } break;
+ default:
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
if (*profile_name == NULL)
return CONNECTION_ERROR_OUT_OF_MEMORY;
return CONNECTION_ERROR_NONE;
}
-int connection_profile_get_type(connection_profile_h profile, connection_profile_type_e* type)
+EXPORT_API int connection_profile_get_type(connection_profile_h profile, connection_profile_type_e* type)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -261,18 +377,23 @@ int connection_profile_get_type(connection_profile_h profile, connection_profile
case NET_DEVICE_ETHERNET:
*type = CONNECTION_PROFILE_TYPE_ETHERNET;
break;
+ case NET_DEVICE_BLUETOOTH:
+ *type = CONNECTION_PROFILE_TYPE_BT;
+ break;
default:
- CONNECTION_LOG(CONNECTION_ERROR, "Invalid profile type\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid profile type");
return CONNECTION_ERROR_OPERATION_FAILED;
}
return CONNECTION_ERROR_NONE;
}
-int connection_profile_get_network_interface_name(connection_profile_h profile, char** interface_name)
+EXPORT_API int connection_profile_get_network_interface_name(connection_profile_h profile, char** interface_name)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || interface_name == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -288,70 +409,130 @@ int connection_profile_get_network_interface_name(connection_profile_h profile,
return CONNECTION_ERROR_NONE;
}
-int connection_profile_get_state(connection_profile_h profile, connection_profile_state_e* state)
+EXPORT_API int connection_profile_refresh(connection_profile_h profile)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+ if (!(_connection_libnet_check_profile_validity(profile))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ net_profile_info_t profile_info_local;
+ net_profile_info_t *profile_info = profile;
+
+ int rv = net_get_profile_info(profile_info->ProfileName, &profile_info_local);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get profile information");
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ memcpy(profile, &profile_info_local, sizeof(net_profile_info_t));
+
+ return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_get_state(connection_profile_h profile, connection_profile_state_e* state)
+{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || state == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- *state = __profile_convert_to_cp_state(profile_info->ProfileState);
+ *state = _profile_convert_to_cp_state(profile_info->ProfileState);
if (*state < 0)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ return CONNECTION_ERROR_OPERATION_FAILED;
return CONNECTION_ERROR_NONE;
}
-int connection_profile_get_ip_config_type(connection_profile_h profile, connection_address_family_e address_family, connection_ip_config_type_e* type)
+EXPORT_API int connection_profile_get_ip_config_type(connection_profile_h profile,
+ connection_address_family_e address_family, connection_ip_config_type_e* type)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+ net_ip_config_type_t profile_type;
+
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
type == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- switch (net_info->IpConfigType) {
- case NET_IP_CONFIG_TYPE_STATIC:
- *type = CONNECTION_IP_CONFIG_TYPE_STATIC;
- break;
- case NET_IP_CONFIG_TYPE_DYNAMIC:
- *type = CONNECTION_IP_CONFIG_TYPE_DYNAMIC;
- break;
- case NET_IP_CONFIG_TYPE_AUTO_IP:
- *type = CONNECTION_IP_CONFIG_TYPE_AUTO;
- break;
- case NET_IP_CONFIG_TYPE_FIXED:
- *type = CONNECTION_IP_CONFIG_TYPE_FIXED;
- break;
- case NET_IP_CONFIG_TYPE_OFF:
- *type = CONNECTION_IP_CONFIG_TYPE_NONE;
- break;
- default:
- return CONNECTION_ERROR_OPERATION_FAILED;
+ if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
+ profile_type = net_info->IpConfigType;
+ else
+ profile_type = net_info->IpConfigType6;
+
+ if (address_family == CONNECTION_ADDRESS_FAMILY_IPV4) {
+ switch (profile_type) {
+ case NET_IP_CONFIG_TYPE_STATIC:
+ *type = CONNECTION_IP_CONFIG_TYPE_STATIC;
+ break;
+
+ case NET_IP_CONFIG_TYPE_DYNAMIC:
+ *type = CONNECTION_IP_CONFIG_TYPE_DYNAMIC;
+ break;
+
+ case NET_IP_CONFIG_TYPE_AUTO_IP:
+ *type = CONNECTION_IP_CONFIG_TYPE_AUTO;
+ break;
+
+ case NET_IP_CONFIG_TYPE_FIXED:
+ *type = CONNECTION_IP_CONFIG_TYPE_FIXED;
+ break;
+
+ case NET_IP_CONFIG_TYPE_OFF:
+ *type = CONNECTION_IP_CONFIG_TYPE_NONE;
+ break;
+ default:
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+ } else {
+ switch (profile_type) {
+ case NET_IP_CONFIG_TYPE_STATIC:
+ *type = CONNECTION_IP_CONFIG_TYPE_STATIC;
+ break;
+
+ case NET_IP_CONFIG_TYPE_AUTO_IP:
+ *type = CONNECTION_IP_CONFIG_TYPE_AUTO;
+ break;
+
+ case NET_IP_CONFIG_TYPE_OFF:
+ *type = CONNECTION_IP_CONFIG_TYPE_NONE;
+ break;
+
+ default:
+ return CONNECTION_ERROR_OPERATION_FAILED;
+
+ }
}
return CONNECTION_ERROR_NONE;
}
-int connection_profile_get_ip_address(connection_profile_h profile,
+EXPORT_API int connection_profile_get_ip_address(connection_profile_h profile,
connection_address_family_e address_family, char** ip_address)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
ip_address == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -361,23 +542,29 @@ int connection_profile_get_ip_address(connection_profile_h profile,
return CONNECTION_ERROR_OPERATION_FAILED;
if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+ *ip_address = __profile_convert_ip_to_string(&net_info->IpAddr6,
+ address_family);
+ else
+ *ip_address = __profile_convert_ip_to_string(&net_info->IpAddr,
+ address_family);
- *ip_address = __profile_convert_ip_to_string(&net_info->IpAddr);
if (*ip_address == NULL)
return CONNECTION_ERROR_OUT_OF_MEMORY;
return CONNECTION_ERROR_NONE;
}
-int connection_profile_get_subnet_mask(connection_profile_h profile,
+EXPORT_API int connection_profile_get_subnet_mask(connection_profile_h profile,
connection_address_family_e address_family, char** subnet_mask)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+ char* prefixlen;
+
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
subnet_mask == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -386,24 +573,30 @@ int connection_profile_get_subnet_mask(connection_profile_h profile,
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+ if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
+ prefixlen = g_try_malloc0(MAX_PREFIX_LENGTH);
+ snprintf(prefixlen, MAX_PREFIX_LENGTH, "%d", net_info->PrefixLen6);
+ *subnet_mask = prefixlen;
+ } else
+ *subnet_mask = __profile_convert_ip_to_string(&net_info->SubnetMask,
+ address_family);
- *subnet_mask = __profile_convert_ip_to_string(&net_info->SubnetMask);
if (*subnet_mask == NULL)
return CONNECTION_ERROR_OUT_OF_MEMORY;
return CONNECTION_ERROR_NONE;
}
-int connection_profile_get_gateway_address(connection_profile_h profile,
+EXPORT_API int connection_profile_get_gateway_address(connection_profile_h profile,
connection_address_family_e address_family, char** gateway_address)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
gateway_address == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -412,26 +605,31 @@ int connection_profile_get_gateway_address(connection_profile_h profile,
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+ if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
+ *gateway_address = __profile_convert_ip_to_string(
+ &net_info->GatewayAddr6, address_family);
+ else
+ *gateway_address = __profile_convert_ip_to_string(
+ &net_info->GatewayAddr, address_family);
- *gateway_address = __profile_convert_ip_to_string(&net_info->GatewayAddr);
if (*gateway_address == NULL)
return CONNECTION_ERROR_OUT_OF_MEMORY;
return CONNECTION_ERROR_NONE;
}
-int connection_profile_get_dns_address(connection_profile_h profile, int order,
+EXPORT_API int connection_profile_get_dns_address(connection_profile_h profile, int order,
connection_address_family_e address_family, char** dns_address)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
dns_address == NULL ||
order <= 0 ||
order > NET_DNS_ADDR_MAX) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -440,28 +638,46 @@ int connection_profile_get_dns_address(connection_profile_h profile, int order,
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
+ if(address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
+ *dns_address = __profile_convert_ip_to_string(&net_info->DnsAddr[order-1],
+ address_family);
+ else if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
+ *dns_address = __profile_convert_ip_to_string(&net_info->DnsAddr6[order-1],
+ address_family);
+ else
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid address family\n");
- *dns_address = __profile_convert_ip_to_string(&net_info->DnsAddr[order-1]);
if (*dns_address == NULL)
return CONNECTION_ERROR_OUT_OF_MEMORY;
return CONNECTION_ERROR_NONE;
}
-int connection_profile_get_proxy_type(connection_profile_h profile, connection_proxy_type_e* type)
+EXPORT_API int connection_profile_get_proxy_type(connection_profile_h profile, connection_proxy_type_e* type)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
+ const char *proxy;
net_profile_info_t *profile_info = profile;
net_dev_info_t *net_info = __profile_get_net_info(profile_info);
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
+ if (profile_info->profile_type == NET_DEVICE_ETHERNET) {
+ proxy = __profile_get_ethernet_proxy();
+ if (proxy == NULL)
+ *type = CONNECTION_PROXY_TYPE_DIRECT;
+ else
+ *type = CONNECTION_PROXY_TYPE_MANUAL;
+
+ return CONNECTION_ERROR_NONE;
+ }
+
switch (net_info->ProxyMethod) {
case NET_PROXY_TYPE_DIRECT:
*type = CONNECTION_PROXY_TYPE_DIRECT;
@@ -480,14 +696,16 @@ int connection_profile_get_proxy_type(connection_profile_h profile, connection_p
return CONNECTION_ERROR_NONE;
}
-int connection_profile_get_proxy_address(connection_profile_h profile,
+EXPORT_API int connection_profile_get_proxy_address(connection_profile_h profile,
connection_address_family_e address_family, char** proxy_address)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
proxy_address == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -496,22 +714,24 @@ int connection_profile_get_proxy_address(connection_profile_h profile,
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-
*proxy_address = g_strdup(net_info->ProxyAddr);
+
if (*proxy_address == NULL)
return CONNECTION_ERROR_OUT_OF_MEMORY;
return CONNECTION_ERROR_NONE;
}
-int connection_profile_set_ip_config_type(connection_profile_h profile, connection_address_family_e address_family, connection_ip_config_type_e type)
+EXPORT_API int connection_profile_set_ip_config_type(connection_profile_h profile,
+ connection_address_family_e address_family, connection_ip_config_type_e type)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+ net_ip_config_type_t *profile_type = NULL;
+
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -520,40 +740,74 @@ int connection_profile_set_ip_config_type(connection_profile_h profile, connecti
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-
- switch (type) {
- case CONNECTION_IP_CONFIG_TYPE_STATIC:
- net_info->IpConfigType = NET_IP_CONFIG_TYPE_STATIC;
- break;
- case CONNECTION_IP_CONFIG_TYPE_DYNAMIC:
- net_info->IpConfigType = NET_IP_CONFIG_TYPE_DYNAMIC;
- break;
- case CONNECTION_IP_CONFIG_TYPE_AUTO:
- net_info->IpConfigType = NET_IP_CONFIG_TYPE_AUTO_IP;
- break;
- case CONNECTION_IP_CONFIG_TYPE_FIXED:
- net_info->IpConfigType = NET_IP_CONFIG_TYPE_FIXED;
- break;
- case CONNECTION_IP_CONFIG_TYPE_NONE:
- net_info->IpConfigType = NET_IP_CONFIG_TYPE_OFF;
- break;
- default:
- return CONNECTION_ERROR_INVALID_PARAMETER;
+ if(address_family == CONNECTION_ADDRESS_FAMILY_IPV4)
+ profile_type = &net_info->IpConfigType ;
+ else
+ profile_type = &net_info->IpConfigType6 ;
+
+ if(address_family == CONNECTION_ADDRESS_FAMILY_IPV4) {
+ switch (type) {
+ case CONNECTION_IP_CONFIG_TYPE_STATIC:
+ *profile_type = NET_IP_CONFIG_TYPE_STATIC;
+ net_info->IpAddr.Data.Ipv4.s_addr = 0;
+ net_info->SubnetMask.Data.Ipv4.s_addr = 0;
+ net_info->GatewayAddr.Data.Ipv4.s_addr = 0 ;
+ break;
+
+ case CONNECTION_IP_CONFIG_TYPE_DYNAMIC:
+ *profile_type = NET_IP_CONFIG_TYPE_DYNAMIC;
+ break;
+
+ case CONNECTION_IP_CONFIG_TYPE_AUTO:
+ *profile_type = NET_IP_CONFIG_TYPE_AUTO_IP;
+ break;
+
+ case CONNECTION_IP_CONFIG_TYPE_FIXED:
+ net_info->IpConfigType = NET_IP_CONFIG_TYPE_FIXED;
+ break;
+
+ case CONNECTION_IP_CONFIG_TYPE_NONE:
+ *profile_type = NET_IP_CONFIG_TYPE_OFF;
+ break;
+
+ default:
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+ } else {
+ switch (type) {
+ case CONNECTION_IP_CONFIG_TYPE_STATIC:
+ *profile_type = NET_IP_CONFIG_TYPE_STATIC;
+ inet_pton(AF_INET6, "::", &net_info->IpAddr6.Data.Ipv6);
+ net_info->PrefixLen6 = 0 ;
+ inet_pton(AF_INET6, "::",
+ &net_info->GatewayAddr6.Data.Ipv6);
+ break;
+
+ case CONNECTION_IP_CONFIG_TYPE_AUTO:
+ *profile_type = NET_IP_CONFIG_TYPE_AUTO_IP;
+ break;
+
+ case CONNECTION_IP_CONFIG_TYPE_NONE:
+ *profile_type = NET_IP_CONFIG_TYPE_OFF;
+ break;
+
+ default:
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
}
return CONNECTION_ERROR_NONE;
}
-int connection_profile_set_ip_address(connection_profile_h profile,
+EXPORT_API int connection_profile_set_ip_address(connection_profile_h profile,
connection_address_family_e address_family, const char* ip_address)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
- address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
- ip_address == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -562,22 +816,32 @@ int connection_profile_set_ip_address(connection_profile_h profile,
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-
- inet_aton(ip_address, &(net_info->IpAddr.Data.Ipv4));
+ if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
+ if (ip_address == NULL)
+ inet_pton(AF_INET6, "::", &net_info->IpAddr6.Data.Ipv6);
+ else if (inet_pton(AF_INET6, ip_address,
+ &net_info->IpAddr6.Data.Ipv6) < 1)
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ } else {
+ if (ip_address == NULL)
+ net_info->IpAddr.Data.Ipv4.s_addr = 0;
+ else if (inet_pton(AF_INET, ip_address,
+ &net_info->IpAddr.Data.Ipv4) < 1)
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
return CONNECTION_ERROR_NONE;
}
-int connection_profile_set_subnet_mask(connection_profile_h profile,
+EXPORT_API int connection_profile_set_subnet_mask(connection_profile_h profile,
connection_address_family_e address_family, const char* subnet_mask)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
- address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
- subnet_mask == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -586,22 +850,30 @@ int connection_profile_set_subnet_mask(connection_profile_h profile,
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-
- inet_aton(subnet_mask, &(net_info->SubnetMask.Data.Ipv4));
+ if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
+ if (subnet_mask == NULL)
+ net_info->PrefixLen6 = 0 ;
+ else
+ net_info->PrefixLen6 = atoi(subnet_mask) ;
+ } else {
+ if (subnet_mask == NULL)
+ net_info->SubnetMask.Data.Ipv4.s_addr = 0;
+ else if (inet_pton(AF_INET, subnet_mask , &net_info->SubnetMask.Data.Ipv4) < 1 )
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
return CONNECTION_ERROR_NONE;
}
-int connection_profile_set_gateway_address(connection_profile_h profile,
+EXPORT_API int connection_profile_set_gateway_address(connection_profile_h profile,
connection_address_family_e address_family, const char* gateway_address)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
- address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
- gateway_address == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -610,24 +882,32 @@ int connection_profile_set_gateway_address(connection_profile_h profile,
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-
- inet_aton(gateway_address, &(net_info->GatewayAddr.Data.Ipv4));
+ if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
+ if (gateway_address == NULL)
+ inet_pton(AF_INET6, "::", &net_info->GatewayAddr6.Data.Ipv6);
+ else if (inet_pton(AF_INET6, gateway_address, &net_info->GatewayAddr6.Data.Ipv6) < 1)
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ } else {
+ if (gateway_address == NULL)
+ net_info->GatewayAddr.Data.Ipv4.s_addr = 0;
+ else if (inet_pton(AF_INET, gateway_address, &(net_info->GatewayAddr.Data.Ipv4)) < 1)
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
return CONNECTION_ERROR_NONE;
}
-int connection_profile_set_dns_address(connection_profile_h profile, int order,
+EXPORT_API int connection_profile_set_dns_address(connection_profile_h profile, int order,
connection_address_family_e address_family, const char* dns_address)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
- dns_address == NULL ||
order <= 0 ||
order > NET_DNS_ADDR_MAX) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -636,18 +916,33 @@ int connection_profile_set_dns_address(connection_profile_h profile, int order,
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-
- inet_aton(dns_address, &(net_info->DnsAddr[order-1].Data.Ipv4));
+ if(address_family == CONNECTION_ADDRESS_FAMILY_IPV6) {
+ net_info->DnsAddr6[order-1].Type = NET_ADDR_IPV6;
+ if (dns_address == NULL)
+ inet_pton(AF_INET6, "::", &net_info->DnsAddr6[order-1].Data.Ipv6);
+ else if (inet_pton(AF_INET6, dns_address, &net_info->DnsAddr6[order-1].Data.Ipv6) < 1)
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ if (net_info->DnsCount6 < order)
+ net_info->DnsCount6 = order;
+ } else {
+ net_info->DnsAddr[order-1].Type = NET_ADDR_IPV4;
+ if (dns_address == NULL)
+ net_info->DnsAddr[order-1].Data.Ipv4.s_addr = 0;
+ else if (inet_pton(AF_INET, dns_address, &(net_info->DnsAddr[order-1].Data.Ipv4)) < 1)
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ if (net_info->DnsCount < order)
+ net_info->DnsCount = order;
+ }
return CONNECTION_ERROR_NONE;
}
-int connection_profile_set_proxy_type(connection_profile_h profile, connection_proxy_type_e type)
+EXPORT_API int connection_profile_set_proxy_type(connection_profile_h profile, connection_proxy_type_e type)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -673,14 +968,15 @@ int connection_profile_set_proxy_type(connection_profile_h profile, connection_p
return CONNECTION_ERROR_NONE;
}
-int connection_profile_set_proxy_address(connection_profile_h profile,
+EXPORT_API int connection_profile_set_proxy_address(connection_profile_h profile,
connection_address_family_e address_family, const char* proxy_address)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) ||
(address_family != CONNECTION_ADDRESS_FAMILY_IPV4 &&
- address_family != CONNECTION_ADDRESS_FAMILY_IPV6) ||
- proxy_address == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -689,19 +985,21 @@ int connection_profile_set_proxy_address(connection_profile_h profile,
if (net_info == NULL)
return CONNECTION_ERROR_OPERATION_FAILED;
- if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6)
- return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED;
-
- g_strlcpy(net_info->ProxyAddr, proxy_address, NET_PROXY_LEN_MAX);
+ if (proxy_address == NULL)
+ net_info->ProxyAddr[0] = '\0';
+ else
+ g_strlcpy(net_info->ProxyAddr, proxy_address, NET_PROXY_LEN_MAX);
return CONNECTION_ERROR_NONE;
}
-int connection_profile_set_state_changed_cb(connection_profile_h profile,
+EXPORT_API int connection_profile_set_state_changed_cb(connection_profile_h profile,
connection_profile_state_changed_cb callback, void* user_data)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || callback == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -711,25 +1009,29 @@ int connection_profile_set_state_changed_cb(connection_profile_h profile,
return CONNECTION_ERROR_OPERATION_FAILED;
}
-int connection_profile_unset_state_changed_cb(connection_profile_h profile)
+EXPORT_API int connection_profile_unset_state_changed_cb(connection_profile_h profile)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- _connection_libnet_remove_from_profile_cb_list(profile);
+ if (_connection_libnet_remove_from_profile_cb_list(profile) != true)
+ return CONNECTION_ERROR_INVALID_PARAMETER;
return CONNECTION_ERROR_NONE;
}
-/* Wi-Fi profile module **************************************************************************/
-
-int connection_profile_get_wifi_essid(connection_profile_h profile, char** essid)
+/* Wi-Fi profile *************************************************************/
+EXPORT_API int connection_profile_get_wifi_essid(connection_profile_h profile, char** essid)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || essid == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -745,10 +1047,12 @@ int connection_profile_get_wifi_essid(connection_profile_h profile, char** essid
return CONNECTION_ERROR_NONE;
}
-int connection_profile_get_wifi_bssid(connection_profile_h profile, char** bssid)
+EXPORT_API int connection_profile_get_wifi_bssid(connection_profile_h profile, char** bssid)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || bssid == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -764,10 +1068,12 @@ int connection_profile_get_wifi_bssid(connection_profile_h profile, char** bssid
return CONNECTION_ERROR_NONE;
}
-int connection_profile_get_wifi_rssi(connection_profile_h profile, int* rssi)
+EXPORT_API int connection_profile_get_wifi_rssi(connection_profile_h profile, int* rssi)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || rssi == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -781,10 +1087,12 @@ int connection_profile_get_wifi_rssi(connection_profile_h profile, int* rssi)
return CONNECTION_ERROR_NONE;
}
-int connection_profile_get_wifi_frequency(connection_profile_h profile, int* frequency)
+EXPORT_API int connection_profile_get_wifi_frequency(connection_profile_h profile, int* frequency)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || frequency == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -798,10 +1106,12 @@ int connection_profile_get_wifi_frequency(connection_profile_h profile, int* fre
return CONNECTION_ERROR_NONE;
}
-int connection_profile_get_wifi_max_speed(connection_profile_h profile, int* max_speed)
+EXPORT_API int connection_profile_get_wifi_max_speed(connection_profile_h profile, int* max_speed)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || max_speed == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -815,10 +1125,12 @@ int connection_profile_get_wifi_max_speed(connection_profile_h profile, int* max
return CONNECTION_ERROR_NONE;
}
-int connection_profile_get_wifi_security_type(connection_profile_h profile, connection_wifi_security_type_e* type)
+EXPORT_API int connection_profile_get_wifi_security_type(connection_profile_h profile, connection_wifi_security_type_e* type)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -850,10 +1162,12 @@ int connection_profile_get_wifi_security_type(connection_profile_h profile, conn
return CONNECTION_ERROR_NONE;
}
-int connection_profile_get_wifi_encryption_type(connection_profile_h profile, connection_wifi_encryption_type_e* type)
+EXPORT_API int connection_profile_get_wifi_encryption_type(connection_profile_h profile, connection_wifi_encryption_type_e* type)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -885,10 +1199,12 @@ int connection_profile_get_wifi_encryption_type(connection_profile_h profile, co
return CONNECTION_ERROR_NONE;
}
-int connection_profile_is_wifi_passphrase_required(connection_profile_h profile, bool* required)
+EXPORT_API int connection_profile_is_wifi_passphrase_required(connection_profile_h profile, bool* required)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || required == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -897,18 +1213,34 @@ int connection_profile_is_wifi_passphrase_required(connection_profile_h profile,
if (profile_info->profile_type != NET_DEVICE_WIFI)
return CONNECTION_ERROR_INVALID_PARAMETER;
- if (profile_info->ProfileInfo.Wlan.PassphraseRequired)
- *required = true;
- else
+ if (profile_info->Favourite) {
+ *required = false;
+ return CONNECTION_ERROR_NONE;
+ }
+
+ switch (profile_info->ProfileInfo.Wlan.security_info.sec_mode) {
+ case WLAN_SEC_MODE_NONE:
*required = false;
+ break;
+ case WLAN_SEC_MODE_WEP:
+ case WLAN_SEC_MODE_IEEE8021X:
+ case WLAN_SEC_MODE_WPA_PSK:
+ case WLAN_SEC_MODE_WPA2_PSK:
+ *required = true;
+ break;
+ default:
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
return CONNECTION_ERROR_NONE;
}
-int connection_profile_set_wifi_passphrase(connection_profile_h profile, const char* passphrase)
+EXPORT_API int connection_profile_set_wifi_passphrase(connection_profile_h profile, const char* passphrase)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || passphrase == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -923,10 +1255,12 @@ int connection_profile_set_wifi_passphrase(connection_profile_h profile, const c
return CONNECTION_ERROR_NONE;
}
-int connection_profile_is_wifi_wps_supported(connection_profile_h profile, bool* supported)
+EXPORT_API int connection_profile_is_wifi_wps_supported(connection_profile_h profile, bool* supported)
{
+ CHECK_FEATURE_SUPPORTED(WIFI_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || supported == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
@@ -944,76 +1278,49 @@ int connection_profile_is_wifi_wps_supported(connection_profile_h profile, bool*
}
-/* Cellular profile module ***********************************************************************/
-
-int connection_profile_get_cellular_network_type(connection_profile_h profile, connection_cellular_network_type_e* type)
-{
- if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
- return CONNECTION_ERROR_INVALID_PARAMETER;
- }
-
- net_profile_info_t *profile_info = profile;
-
- if (profile_info->profile_type != NET_DEVICE_CELLULAR)
- return CONNECTION_ERROR_INVALID_PARAMETER;
-
- switch (profile_info->ProfileInfo.Pdp.ProtocolType) {
- case NET_PDP_TYPE_NONE:
- *type = CONNECTION_CELLULAR_NETWORK_TYPE_UNKNOWN;
- break;
- case NET_PDP_TYPE_GPRS:
- *type = CONNECTION_CELLULAR_NETWORK_TYPE_GPRS;
- break;
- case NET_PDP_TYPE_EDGE:
- *type = CONNECTION_CELLULAR_NETWORK_TYPE_EDGE;
- break;
- case NET_PDP_TYPE_UMTS:
- *type = CONNECTION_CELLULAR_NETWORK_TYPE_UMTS;
- break;
- default:
- return CONNECTION_ERROR_OPERATION_FAILED;
- }
-
- return CONNECTION_ERROR_NONE;
-}
-
-int connection_profile_get_cellular_service_type(connection_profile_h profile,
+/* Cellular profile **********************************************************/
+EXPORT_API int connection_profile_get_cellular_service_type(connection_profile_h profile,
connection_cellular_service_type_e* type)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
- CONNECTION_LOG(CONNECTION_ERROR, "Invalid profile type Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
- *type = __profile_convert_to_connection_cellular_service_type(profile_info->ProfileInfo.Pdp.ServiceType);
+ *type = _profile_convert_to_connection_cellular_service_type(profile_info->ProfileInfo.Pdp.ServiceType);
if (*type == CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN) {
- CONNECTION_LOG(CONNECTION_ERROR, "Invalid service type Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid service type Passed");
return CONNECTION_ERROR_OPERATION_FAILED;
}
return CONNECTION_ERROR_NONE;
}
-int connection_profile_get_cellular_apn(connection_profile_h profile, char** apn)
+EXPORT_API int connection_profile_get_cellular_apn(connection_profile_h profile, char** apn)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || apn == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- if (profile_info->profile_type != NET_DEVICE_CELLULAR)
+ if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
*apn = g_strdup(profile_info->ProfileInfo.Pdp.Apn);
if (*apn == NULL)
@@ -1022,19 +1329,23 @@ int connection_profile_get_cellular_apn(connection_profile_h profile, char** apn
return CONNECTION_ERROR_NONE;
}
-int connection_profile_get_cellular_auth_info(connection_profile_h profile,
+EXPORT_API int connection_profile_get_cellular_auth_info(connection_profile_h profile,
connection_cellular_auth_type_e* type, char** user_name, char** password)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) ||
type == NULL || user_name == NULL || password == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- if (profile_info->profile_type != NET_DEVICE_CELLULAR)
+ if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
switch (profile_info->ProfileInfo.Pdp.AuthInfo.AuthType) {
case NET_PDP_AUTH_NONE:
@@ -1063,17 +1374,21 @@ int connection_profile_get_cellular_auth_info(connection_profile_h profile,
return CONNECTION_ERROR_NONE;
}
-int connection_profile_get_cellular_home_url(connection_profile_h profile, char** home_url)
+EXPORT_API int connection_profile_get_cellular_home_url(connection_profile_h profile, char** home_url)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || home_url == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- if (profile_info->profile_type != NET_DEVICE_CELLULAR)
+ if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
*home_url = g_strdup(profile_info->ProfileInfo.Pdp.HomeURL);
if (*home_url == NULL)
@@ -1082,17 +1397,21 @@ int connection_profile_get_cellular_home_url(connection_profile_h profile, char*
return CONNECTION_ERROR_NONE;
}
-int connection_profile_is_cellular_roaming(connection_profile_h profile, bool* is_roaming)
+EXPORT_API int connection_profile_is_cellular_roaming(connection_profile_h profile, bool* is_roaming)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || is_roaming == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- if (profile_info->profile_type != NET_DEVICE_CELLULAR)
+ if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
if (profile_info->ProfileInfo.Pdp.Roaming)
*is_roaming = true;
@@ -1102,18 +1421,94 @@ int connection_profile_is_cellular_roaming(connection_profile_h profile, bool* i
return CONNECTION_ERROR_NONE;
}
-int connection_profile_set_cellular_service_type(connection_profile_h profile,
+EXPORT_API int connection_profile_is_cellular_hidden(connection_profile_h profile, bool* is_hidden)
+{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
+
+ if (!(_connection_libnet_check_profile_validity(profile)) || is_hidden == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ net_profile_info_t *profile_info = profile;
+
+ if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ if (profile_info->ProfileInfo.Pdp.Hidden)
+ *is_hidden = true;
+ else
+ *is_hidden = false;
+
+ return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_is_cellular_editable(connection_profile_h profile, bool* is_editable)
+{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
+
+ if (!(_connection_libnet_check_profile_validity(profile)) || is_editable == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ net_profile_info_t *profile_info = profile;
+
+ if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ if (profile_info->ProfileInfo.Pdp.Editable)
+ *is_editable = true;
+ else
+ *is_editable = false;
+
+ return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_is_cellular_default(connection_profile_h profile, bool* is_default)
+{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
+
+ if (!(_connection_libnet_check_profile_validity(profile)) || is_default == NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ net_profile_info_t *profile_info = profile;
+
+ if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ if (profile_info->ProfileInfo.Pdp.DefaultConn)
+ *is_default = true;
+ else
+ *is_default = false;
+
+ return CONNECTION_ERROR_NONE;
+}
+
+EXPORT_API int connection_profile_set_cellular_service_type(connection_profile_h profile,
connection_cellular_service_type_e service_type)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- if (profile_info->profile_type != NET_DEVICE_CELLULAR)
+ if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
switch (service_type) {
case CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET:
@@ -1122,15 +1517,18 @@ int connection_profile_set_cellular_service_type(connection_profile_h profile,
case CONNECTION_CELLULAR_SERVICE_TYPE_MMS:
profile_info->ProfileInfo.Pdp.ServiceType = NET_SERVICE_MMS;
break;
- case CONNECTION_CELLULAR_SERVICE_TYPE_WAP:
- profile_info->ProfileInfo.Pdp.ServiceType = NET_SERVICE_WAP;
- break;
case CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET:
profile_info->ProfileInfo.Pdp.ServiceType = NET_SERVICE_PREPAID_INTERNET;
break;
case CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS:
profile_info->ProfileInfo.Pdp.ServiceType = NET_SERVICE_PREPAID_MMS;
break;
+ case CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING:
+ profile_info->ProfileInfo.Pdp.ServiceType = NET_SERVICE_TETHERING;
+ break;
+ case CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION:
+ profile_info->ProfileInfo.Pdp.ServiceType = NET_SERVICE_APPLICATION;
+ break;
case CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN:
default:
return CONNECTION_ERROR_INVALID_PARAMETER;
@@ -1139,36 +1537,44 @@ int connection_profile_set_cellular_service_type(connection_profile_h profile,
return CONNECTION_ERROR_NONE;
}
-int connection_profile_set_cellular_apn(connection_profile_h profile, const char* apn)
+EXPORT_API int connection_profile_set_cellular_apn(connection_profile_h profile, const char* apn)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || apn == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- if (profile_info->profile_type != NET_DEVICE_CELLULAR)
+ if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
g_strlcpy(profile_info->ProfileInfo.Pdp.Apn, apn, NET_PDP_APN_LEN_MAX+1);
return CONNECTION_ERROR_NONE;
}
-int connection_profile_set_cellular_auth_info(connection_profile_h profile,
+EXPORT_API int connection_profile_set_cellular_auth_info(connection_profile_h profile,
connection_cellular_auth_type_e type, const char* user_name, const char* password)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) ||
user_name == NULL || password == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- if (profile_info->profile_type != NET_DEVICE_CELLULAR)
+ if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
switch (type) {
case CONNECTION_CELLULAR_AUTH_TYPE_NONE:
@@ -1190,20 +1596,23 @@ int connection_profile_set_cellular_auth_info(connection_profile_h profile,
return CONNECTION_ERROR_NONE;
}
-int connection_profile_set_cellular_home_url(connection_profile_h profile, const char* home_url)
+EXPORT_API int connection_profile_set_cellular_home_url(connection_profile_h profile, const char* home_url)
{
+ CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE);
+
if (!(_connection_libnet_check_profile_validity(profile)) || home_url == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- if (profile_info->profile_type != NET_DEVICE_CELLULAR)
+ if (profile_info->profile_type != NET_DEVICE_CELLULAR) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
g_strlcpy(profile_info->ProfileInfo.Pdp.HomeURL, home_url, NET_HOME_URL_LEN_MAX);
return CONNECTION_ERROR_NONE;
}
-
diff --git a/src/internal.c b/src/internal.c
deleted file mode 100755
index e104bcd..0000000
--- a/src/internal.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <glib.h>
-#include "net_connection_private.h"
-
-
-static pthread_mutex_t connection_mutex;
-static int connection_flag = 0;
-
-
-static void __inter_mutex_init(void)
-{
- if (g_atomic_int_get(&connection_flag) == 0)
- if (pthread_mutex_init(&connection_mutex, NULL) != 0)
- CONNECTION_LOG(CONNECTION_ERROR, "Mutex initialization failed!\n");
-
- g_atomic_int_inc(&connection_flag);
-}
-
-void __inter_mutex_destroy(void)
-{
- if (g_atomic_int_dec_and_test(&connection_flag))
- pthread_mutex_destroy(&connection_mutex);
-}
-
-void _connection_inter_mutex_lock(void)
-{
- __inter_mutex_init();
- pthread_mutex_lock(&connection_mutex);
-}
-
-void _connection_inter_mutex_unlock(void)
-{
- pthread_mutex_unlock(&connection_mutex);
- __inter_mutex_destroy();
-}
-
diff --git a/src/libnetwork.c b/src/libnetwork.c
index f92cceb..2ac48ba 100755
--- a/src/libnetwork.c
+++ b/src/libnetwork.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,19 +14,22 @@
* limitations under the License.
*/
+#include <glib.h>
#include <stdio.h>
+#include <stdarg.h>
#include <string.h>
-#include <glib.h>
#include <vconf/vconf.h>
+#include <system_info.h>
+#include <arpa/inet.h>
+
#include "net_connection_private.h"
-static GSList *prof_handle_list = NULL;
-static GHashTable *profile_cb_table = NULL;
-static bool registered = false;
+static __thread GSList *prof_handle_list = NULL;
+static __thread GHashTable *profile_cb_table = NULL;
struct _profile_cb_s {
connection_profile_state_changed_cb callback;
- net_profile_info_t profile;
+ connection_profile_state_e state;
void *user_data;
};
@@ -36,29 +39,316 @@ struct _profile_list_s {
net_profile_info_t *profiles;
};
-static struct _profile_list_s profile_iterator = {0, 0, NULL};
+struct _libnet_s {
+ connection_opened_cb opened_cb;
+ connection_closed_cb closed_cb;
+ connection_set_default_cb set_default_cb;
+ connection_reset_cb reset_profile_cb;
+ void *opened_user_data;
+ void *closed_user_data;
+ void *set_default_user_data;
+ void *reset_profile_user_data;
+ bool is_created;
+};
+struct _state_notify {
+ connection_profile_state_changed_cb callback;
+ connection_profile_state_e state;
+ void *user_data;
+};
-static void __libnet_state_changed_cb(char *profile_name, net_profile_info_t *profile_info,
- connection_profile_state_e state, bool is_requested)
+struct managed_idle_data {
+ GSourceFunc func;
+ gpointer user_data;
+ guint id;
+};
+
+static __thread struct _profile_list_s profile_iterator = {0, 0, NULL};
+static __thread struct _libnet_s libnet = {NULL, NULL, NULL, NULL, NULL, NULL, false};
+static __thread GSList *managed_idler_list = NULL;
+
+bool _connection_is_created(void)
{
- if (profile_name == NULL)
+ return libnet.is_created;
+}
+
+static void __connection_set_created(bool tag)
+{
+ libnet.is_created = tag;
+}
+
+static connection_error_e __libnet_convert_to_cp_error_type(net_err_t err_type)
+{
+ switch (err_type) {
+ case NET_ERR_NONE:
+ return CONNECTION_ERROR_NONE;
+ case NET_ERR_APP_ALREADY_REGISTERED:
+ return CONNECTION_ERROR_INVALID_OPERATION;
+ case NET_ERR_APP_NOT_REGISTERED:
+ return CONNECTION_ERROR_INVALID_OPERATION;
+ case NET_ERR_NO_ACTIVE_CONNECTIONS:
+ return CONNECTION_ERROR_NO_CONNECTION;
+ case NET_ERR_ACTIVE_CONNECTION_EXISTS:
+ return CONNECTION_ERROR_ALREADY_EXISTS;
+ case NET_ERR_CONNECTION_DHCP_FAILED:
+ return CONNECTION_ERROR_DHCP_FAILED;
+ case NET_ERR_CONNECTION_INVALID_KEY:
+ return CONNECTION_ERROR_INVALID_KEY;
+ case NET_ERR_IN_PROGRESS:
+ return CONNECTION_ERROR_NOW_IN_PROGRESS;
+ case NET_ERR_OPERATION_ABORTED:
+ return CONNECTION_ERROR_OPERATION_ABORTED;
+ case NET_ERR_TIME_OUT:
+ return CONNECTION_ERROR_NO_REPLY;
+ case NET_ERR_ACCESS_DENIED:
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ default:
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+}
+
+static const char *__libnet_convert_cp_error_type_to_string(connection_error_e err_type)
+{
+ switch (err_type) {
+ case CONNECTION_ERROR_NONE:
+ return "NONE";
+ case CONNECTION_ERROR_INVALID_PARAMETER:
+ return "INVALID_PARAMETER";
+ case CONNECTION_ERROR_OUT_OF_MEMORY:
+ return "OUT_OF_MEMORY";
+ case CONNECTION_ERROR_INVALID_OPERATION:
+ return "INVALID_OPERATION";
+ case CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
+ return "ADDRESS_FAMILY_NOT_SUPPORTED";
+ case CONNECTION_ERROR_OPERATION_FAILED:
+ return "OPERATION_FAILED";
+ case CONNECTION_ERROR_ITERATOR_END:
+ return "ITERATOR_END";
+ case CONNECTION_ERROR_NO_CONNECTION:
+ return "NO_CONNECTION";
+ case CONNECTION_ERROR_NOW_IN_PROGRESS:
+ return "NOW_IN_PROGRESS";
+ case CONNECTION_ERROR_ALREADY_EXISTS:
+ return "ALREADY_EXISTS";
+ case CONNECTION_ERROR_OPERATION_ABORTED:
+ return "OPERATION_ABORTED";
+ case CONNECTION_ERROR_DHCP_FAILED:
+ return "DHCP_FAILED";
+ case CONNECTION_ERROR_INVALID_KEY:
+ return "INVALID_KEY";
+ case CONNECTION_ERROR_NO_REPLY:
+ return "NO_REPLY";
+ case CONNECTION_ERROR_PERMISSION_DENIED:
+ return "PERMISSION_DENIED";
+ case CONNECTION_ERROR_NOT_SUPPORTED:
+ return "NOT_SUPPORTED";
+ }
+
+ return "UNKNOWN";
+}
+
+static const char *__libnet_convert_cp_state_to_string(connection_profile_state_e state)
+{
+ switch (state) {
+ case CONNECTION_PROFILE_STATE_DISCONNECTED:
+ return "DISCONNECTED";
+ case CONNECTION_PROFILE_STATE_ASSOCIATION:
+ return "ASSOCIATION";
+ case CONNECTION_PROFILE_STATE_CONFIGURATION:
+ return "CONFIGURATION";
+ case CONNECTION_PROFILE_STATE_CONNECTED:
+ return "CONNECTED";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+static void __libnet_set_reset_profile_cb(connection_opened_cb user_cb, void *user_data)
+{
+ if (user_cb != NULL) {
+ libnet.reset_profile_cb = user_cb;
+ libnet.reset_profile_user_data = user_data;
+ }
+}
+
+static gboolean __libnet_reset_profile_cb_idle(gpointer data)
+{
+ connection_error_e result = (connection_error_e)data;
+
+ if (libnet.reset_profile_cb != NULL)
+ libnet.reset_profile_cb(result, libnet.reset_profile_user_data);
+
+ libnet.reset_profile_cb = NULL;
+ libnet.reset_profile_user_data = NULL;
+
+ return FALSE;
+}
+
+static void __libnet_reset_profile_cb(connection_error_e result)
+{
+ if (_connection_is_created() != true) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered"
+ "If multi-threaded, thread integrity be broken.");
+ return;
+ }
+
+ if (libnet.reset_profile_cb != NULL)
+ _connection_callback_add(__libnet_reset_profile_cb_idle, (gpointer)result);
+}
+
+static void __libnet_set_opened_cb(connection_opened_cb user_cb, void *user_data)
+{
+ if (user_cb != NULL) {
+ libnet.opened_cb = user_cb;
+ libnet.opened_user_data = user_data;
+ }
+}
+
+static gboolean __libnet_opened_cb_idle(gpointer data)
+{
+ connection_error_e result = (connection_error_e)data;
+
+ if (libnet.opened_cb != NULL)
+ libnet.opened_cb(result, libnet.opened_user_data);
+
+ libnet.opened_cb = NULL;
+ libnet.opened_user_data = NULL;
+
+ return FALSE;
+}
+
+static void __libnet_opened_cb(connection_error_e result)
+{
+ if (_connection_is_created() != true) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered"
+ "If multi-threaded, thread integrity be broken.");
+ return;
+ }
+
+ if (libnet.opened_cb != NULL)
+ _connection_callback_add(__libnet_opened_cb_idle, (gpointer)result);
+}
+
+static void __libnet_set_closed_cb(connection_closed_cb user_cb, void *user_data)
+{
+ if (user_cb != NULL) {
+ libnet.closed_cb = user_cb;
+ libnet.closed_user_data = user_data;
+ }
+}
+
+static gboolean __libnet_closed_cb_idle(gpointer data)
+{
+ connection_error_e result = (connection_error_e)data;
+
+ if (libnet.closed_cb != NULL)
+ libnet.closed_cb(result, libnet.closed_user_data);
+
+ libnet.closed_cb = NULL;
+ libnet.closed_user_data = NULL;
+
+ return FALSE;
+}
+
+static void __libnet_closed_cb(connection_error_e result)
+{
+ if (_connection_is_created() != true) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered"
+ "If multi-threaded, thread integrity be broken.");
+ return;
+ }
+
+ if (libnet.closed_cb != NULL)
+ _connection_callback_add(__libnet_closed_cb_idle, (gpointer)result);
+}
+
+static void __libnet_set_default_cb(connection_set_default_cb user_cb, void *user_data)
+{
+ if (user_cb != NULL) {
+ libnet.set_default_cb = user_cb;
+ libnet.set_default_user_data = user_data;
+ }
+}
+
+static gboolean __libnet_default_cb_idle(gpointer data)
+{
+ connection_error_e result = (connection_error_e)data;
+
+ if (libnet.set_default_cb != NULL)
+ libnet.set_default_cb(result, libnet.set_default_user_data);
+
+ libnet.set_default_cb = NULL;
+ libnet.set_default_user_data = NULL;
+
+ return FALSE;
+}
+
+static void __libnet_default_cb(connection_error_e result)
+{
+ if (_connection_is_created() != true) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered"
+ "If multi-threaded, thread integrity be broken.");
return;
+ }
+ if (libnet.set_default_cb != NULL)
+ _connection_callback_add(__libnet_default_cb_idle, (gpointer)result);
+}
+
+static gboolean __libnet_state_changed_cb_idle(gpointer data)
+{
+ struct _state_notify *notify = (struct _state_notify *)data;
+
+ if (notify == NULL)
+ return FALSE;
+
+ if (notify->callback != NULL)
+ notify->callback(notify->state, notify->user_data);
+
+ g_free(notify);
+
+ return FALSE;
+}
+
+static void __libnet_state_changed_cb(char *profile_name, connection_profile_state_e state)
+{
+ guint id;
+ struct _state_notify *notify;
struct _profile_cb_s *cb_info;
- cb_info = g_hash_table_lookup(profile_cb_table, profile_name);
+ if (_connection_is_created() != true) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered"
+ "If multi-threaded, thread integrity be broken.");
+ return;
+ }
+
+ if (profile_name == NULL)
+ return;
+
+ cb_info = g_hash_table_lookup(profile_cb_table, profile_name);
if (cb_info == NULL)
return;
- if (profile_info)
- memcpy(&cb_info->profile, profile_info, sizeof(net_profile_info_t));
- else if (state >= 0)
- cb_info->profile.ProfileState = _connection_profile_convert_to_net_state(state);
+ if (cb_info->state == state)
+ return;
+
+ cb_info->state = state;
+
+ if (state < 0 || cb_info->callback == NULL)
+ return;
- if (cb_info->callback)
- cb_info->callback((connection_profile_h)&cb_info->profile,
- is_requested, cb_info->user_data);
+ notify = g_try_new0(struct _state_notify, 1);
+ if (notify == NULL)
+ return;
+
+ notify->callback = cb_info->callback;
+ notify->state = state;
+ notify->user_data = cb_info->user_data;
+
+ id = _connection_callback_add(__libnet_state_changed_cb_idle,
+ (gpointer)notify);
+ if (!id)
+ g_free(notify);
}
static void __libnet_clear_profile_list(struct _profile_list_s *profile_list)
@@ -71,146 +361,105 @@ static void __libnet_clear_profile_list(struct _profile_list_s *profile_list)
profile_list->profiles = NULL;
}
-static void __libnet_evt_cb(net_event_info_t* event_cb, void* user_data)
+static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data)
{
bool is_requested = false;
+ connection_error_e result = CONNECTION_ERROR_NONE;
switch (event_cb->Event) {
case NET_EVENT_OPEN_RSP:
is_requested = true;
+ /* fall through */
case NET_EVENT_OPEN_IND:
- CONNECTION_LOG(CONNECTION_INFO,
- "Received ACTIVATION(Open RSP/IND) response: %d \n", event_cb->Error);
+ result = __libnet_convert_to_cp_error_type(event_cb->Error);
+ CONNECTION_LOG(CONNECTION_INFO, "Connection opened %s[%s]",
+ (is_requested) ? "RSP":"IND",
+ __libnet_convert_cp_error_type_to_string(result));
+
+ if (is_requested)
+ __libnet_opened_cb(result);
switch (event_cb->Error) {
case NET_ERR_NONE:
case NET_ERR_ACTIVE_CONNECTION_EXISTS:
- CONNECTION_LOG(CONNECTION_INFO, "Activation succeeded\n");
+ CONNECTION_LOG(CONNECTION_INFO, "Successfully open connection");
- net_profile_info_t *prof_info = NULL;
-
- if (event_cb->Datalength == sizeof(net_profile_info_t))
- prof_info = (net_profile_info_t*)event_cb->Data;
-
- __libnet_state_changed_cb(event_cb->ProfileName, prof_info,
- CONNECTION_PROFILE_STATE_CONNECTED, is_requested);
+ __libnet_state_changed_cb(event_cb->ProfileName, CONNECTION_PROFILE_STATE_CONNECTED);
return;
- case NET_ERR_TIME_OUT:
- CONNECTION_LOG(CONNECTION_ERROR, "Request time out!\n");
- break;
- case NET_ERR_OPERATION_ABORTED:
- CONNECTION_LOG(CONNECTION_ERROR, "Connction is aborted!\n");
- break;
- case NET_ERR_UNKNOWN_METHOD:
- CONNECTION_LOG(CONNECTION_ERROR, "Method not found!\n");
- break;
- case NET_ERR_UNKNOWN:
- CONNECTION_LOG(CONNECTION_ERROR, "Activation Failed!\n");
- break;
default:
- CONNECTION_LOG(CONNECTION_ERROR, "Unknown Error!\n");
- break;
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to open connection[%s]",
+ __libnet_convert_cp_error_type_to_string(result));
}
- __libnet_state_changed_cb(event_cb->ProfileName, NULL,
- CONNECTION_PROFILE_STATE_DISCONNECTED, is_requested);
+ __libnet_state_changed_cb(event_cb->ProfileName, CONNECTION_PROFILE_STATE_DISCONNECTED);
break;
case NET_EVENT_CLOSE_RSP:
is_requested = true;
+ /* fall through */
case NET_EVENT_CLOSE_IND:
- CONNECTION_LOG(CONNECTION_INFO, "Got Close RSP/IND\n");
+ result = __libnet_convert_to_cp_error_type(event_cb->Error);
+ CONNECTION_LOG(CONNECTION_INFO, "Connection closed %s[%s]",
+ (is_requested) ? "RSP":"IND",
+ __libnet_convert_cp_error_type_to_string(result));
+
+ if (is_requested)
+ __libnet_closed_cb(result);
switch (event_cb->Error) {
case NET_ERR_NONE:
- /* Successful PDP Deactivation */
- CONNECTION_LOG(CONNECTION_INFO, "Deactivation succeeded!\n");
+ CONNECTION_LOG(CONNECTION_INFO, "Successfully closed connection");
- net_profile_info_t prof_info;
-
- if (net_get_profile_info(event_cb->ProfileName, &prof_info) == NET_ERR_NONE)
- __libnet_state_changed_cb(event_cb->ProfileName, &prof_info,
- CONNECTION_PROFILE_STATE_DISCONNECTED, is_requested);
- else
- __libnet_state_changed_cb(event_cb->ProfileName, NULL,
- CONNECTION_PROFILE_STATE_DISCONNECTED, is_requested);
+ __libnet_state_changed_cb(event_cb->ProfileName, CONNECTION_PROFILE_STATE_DISCONNECTED);
return;
- case NET_ERR_TIME_OUT:
- CONNECTION_LOG(CONNECTION_ERROR, "Request time out!\n");
- break;
- case NET_ERR_IN_PROGRESS:
- CONNECTION_LOG(CONNECTION_ERROR, "Disconncting is in progress!\n");
- break;
- case NET_ERR_OPERATION_ABORTED:
- CONNECTION_LOG(CONNECTION_ERROR, "Disconnction is aborted!\n");
- break;
- case NET_ERR_UNKNOWN_METHOD:
- CONNECTION_LOG(CONNECTION_ERROR, "Service not found!\n");
- break;
- case NET_ERR_UNKNOWN:
- CONNECTION_LOG(CONNECTION_ERROR, "Deactivation Failed!\n");
- break;
default:
- CONNECTION_LOG(CONNECTION_ERROR, "Unknown Error!\n");
- break;
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to close connection[%s]",
+ __libnet_convert_cp_error_type_to_string(result));
}
- __libnet_state_changed_cb(event_cb->ProfileName, NULL, -1, is_requested);
-
break;
case NET_EVENT_NET_STATE_IND:
- CONNECTION_LOG(CONNECTION_INFO, "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_ASSOCIATION:
- CONNECTION_LOG(CONNECTION_INFO,
- "Profile State : Association, profile name : %s\n",
- event_cb->ProfileName);
-
- __libnet_state_changed_cb(event_cb->ProfileName, NULL,
- CONNECTION_PROFILE_STATE_ASSOCIATION, is_requested);
- break;
- case NET_STATE_TYPE_CONFIGURATION:
- CONNECTION_LOG(CONNECTION_INFO,
- "Profile State : Configuration, profile name : %s\n",
- event_cb->ProfileName);
+ CONNECTION_LOG(CONNECTION_INFO, "State changed IND");
- __libnet_state_changed_cb(event_cb->ProfileName, NULL,
- CONNECTION_PROFILE_STATE_CONFIGURATION, is_requested);
- break;
- case NET_STATE_TYPE_IDLE:
- case NET_STATE_TYPE_FAILURE:
- case NET_STATE_TYPE_READY:
- case NET_STATE_TYPE_ONLINE:
- case NET_STATE_TYPE_DISCONNECT:
- case NET_STATE_TYPE_UNKNOWN:
- default:
- CONNECTION_LOG(CONNECTION_INFO,
- "Profile State : %d, profile name : %s\n", *profile_state,
- event_cb->ProfileName);
- }
- }
+ if (event_cb->Datalength != sizeof(net_state_type_t))
+ return;
+
+ net_state_type_t *profile_state = (net_state_type_t *)event_cb->Data;
+ connection_profile_state_e cp_state = _profile_convert_to_cp_state(*profile_state);
+
+ CONNECTION_LOG(CONNECTION_INFO, "state: %s", __libnet_convert_cp_state_to_string(cp_state));
+ SECURE_CONNECTION_LOG(CONNECTION_INFO, "profile name: %s", event_cb->ProfileName);
+
+ __libnet_state_changed_cb(event_cb->ProfileName, cp_state);
break;
- case NET_EVENT_WIFI_SCAN_IND:
- case NET_EVENT_WIFI_SCAN_RSP:
- CONNECTION_LOG(CONNECTION_ERROR, "Got wifi scan IND\n");
- break;
- case NET_EVENT_WIFI_POWER_IND:
- case NET_EVENT_WIFI_POWER_RSP:
- CONNECTION_LOG(CONNECTION_ERROR, "Got wifi power IND\n");
+ case NET_EVENT_CELLULAR_SET_DEFAULT_RSP:
+ result = __libnet_convert_to_cp_error_type(event_cb->Error);
+ CONNECTION_LOG(CONNECTION_INFO, "Got set default profile RSP %d", result);
+ __libnet_default_cb(result);
break;
- case NET_EVENT_WIFI_WPS_RSP:
- CONNECTION_LOG(CONNECTION_ERROR, "Got wifi WPS RSP\n");
+
+ case NET_EVENT_CELLULAR_RESET_DEFAULT_RSP:
+ result = __libnet_convert_to_cp_error_type(event_cb->Error);
+ CONNECTION_LOG(CONNECTION_INFO, "Got reset default profile RSP %d", result);
+ __libnet_reset_profile_cb(result);
default :
- CONNECTION_LOG(CONNECTION_ERROR, "Error! Unknown Event\n\n");
break;
}
}
+static int __libnet_check_address_type(int address_family, const char *address)
+{
+ struct in6_addr buf;
+ int err = 0;
+
+ err = inet_pton(address_family, address, &buf);
+ if(err > 0)
+ return 1;
+
+ return 0;
+}
+
int __libnet_get_connected_count(struct _profile_list_s *profile_list)
{
int count = 0;
@@ -238,31 +487,56 @@ void __libnet_copy_connected_profile(net_profile_info_t **dest, struct _profile_
}
}
-bool _connection_libnet_init(void)
+int __libnet_get_default_count(struct _profile_list_s *profile_list)
+{
+ int count = 0;
+ int i = 0;
+
+ for (;i < profile_list->count;i++) {
+ if (profile_list->profiles[i].ProfileInfo.Pdp.DefaultConn == TRUE)
+ count++;
+ }
+
+ return count;
+}
+
+void __libnet_copy_default_profile(net_profile_info_t **dest, struct _profile_list_s *source)
+{
+ int i = 0;
+
+ for (;i < source->count;i++) {
+ if (source->profiles[i].ProfileInfo.Pdp.DefaultConn == TRUE) {
+ memcpy(*dest, &source->profiles[i], sizeof(net_profile_info_t));
+ (*dest)++;
+ }
+ }
+}
+
+int _connection_libnet_init(void)
{
int rv;
- if (!registered) {
+ if (_connection_is_created() != true) {
rv = net_register_client_ext((net_event_cb_t)__libnet_evt_cb, NET_DEVICE_DEFAULT, NULL);
if (rv != NET_ERR_NONE)
- return false;
+ return rv;
- registered = true;
+ __connection_set_created(true);
if (profile_cb_table == NULL)
profile_cb_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
}
- return true;
+ return NET_ERR_NONE;
}
bool _connection_libnet_deinit(void)
{
- if (registered) {
+ if (_connection_is_created() == true) {
if (net_deregister_client_ext(NET_DEVICE_DEFAULT) != NET_ERR_NONE)
return false;
- registered = false;
+ __connection_set_created(false);
if (profile_cb_table) {
g_hash_table_destroy(profile_cb_table);
@@ -285,33 +559,83 @@ bool _connection_libnet_check_profile_validity(connection_profile_h profile)
GSList *list;
int i = 0;
+ if (profile == NULL)
+ return false;
+
for (list = prof_handle_list; list; list = list->next)
if (profile == list->data) return true;
for (;i < profile_iterator.count;i++)
if (profile == &profile_iterator.profiles[i]) return true;
+ return false;
+}
+
+bool _connection_libnet_check_profile_cb_validity(connection_profile_h profile)
+{
struct _profile_cb_s *cb_info;
net_profile_info_t *profile_info = profile;
- cb_info = g_hash_table_lookup(profile_cb_table, profile_info->ProfileName);
- if (cb_info == NULL)
+ if (profile == NULL)
return false;
- if (&cb_info->profile == profile)
+ cb_info = g_hash_table_lookup(profile_cb_table, profile_info->ProfileName);
+ if (cb_info != NULL)
return true;
return false;
}
-bool _connection_libnet_get_ethernet_state(connection_ethernet_state_e* state)
+
+int _connection_libnet_get_wifi_state(connection_wifi_state_e *state)
{
+ int rv;
+ net_wifi_state_t wlan_state;
+ net_profile_name_t profile_name;
+
+ rv = net_get_wifi_state(&wlan_state, &profile_name);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get Wi-Fi state[%d]", rv);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ switch (wlan_state) {
+ case WIFI_OFF:
+ *state = CONNECTION_WIFI_STATE_DEACTIVATED;
+ break;
+ case WIFI_ON:
+ case WIFI_ASSOCIATION:
+ case WIFI_CONFIGURATION:
+ *state = CONNECTION_WIFI_STATE_DISCONNECTED;
+ break;
+ case WIFI_CONNECTED:
+ case WIFI_DISCONNECTING:
+ *state = CONNECTION_WIFI_STATE_CONNECTED;
+ break;
+ default :
+ CONNECTION_LOG(CONNECTION_ERROR, "Unknown Wi-Fi state");
+ return CONNECTION_ERROR_INVALID_OPERATION;
+ }
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_get_ethernet_state(connection_ethernet_state_e* state)
+{
+ int rv;
struct _profile_list_s ethernet_profiles = {0, 0, NULL};
- net_get_profile_list(NET_DEVICE_ETHERNET, &ethernet_profiles.profiles, &ethernet_profiles.count);
+ rv = net_get_profile_list(NET_DEVICE_ETHERNET, &ethernet_profiles.profiles, &ethernet_profiles.count);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ }
if (ethernet_profiles.count == 0) {
*state = CONNECTION_ETHERNET_STATE_DEACTIVATED;
- return true;
+ return CONNECTION_ERROR_NONE;
}
switch (ethernet_profiles.profiles->ProfileState) {
@@ -327,53 +651,123 @@ bool _connection_libnet_get_ethernet_state(connection_ethernet_state_e* state)
*state = CONNECTION_ETHERNET_STATE_DISCONNECTED;
break;
default:
- return false;
+ __libnet_clear_profile_list(&ethernet_profiles);
+ return CONNECTION_ERROR_OPERATION_FAILED;
}
__libnet_clear_profile_list(&ethernet_profiles);
- return true;
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_get_bluetooth_state(connection_bt_state_e* state)
+{
+ int i = 0;
+ int rv = 0;
+ struct _profile_list_s bluetooth_profiles = {0, 0, NULL};
+ rv = net_get_profile_list(NET_DEVICE_BLUETOOTH, &bluetooth_profiles.profiles, &bluetooth_profiles.count);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ }
+
+ if (bluetooth_profiles.count == 0) {
+ *state = CONNECTION_BT_STATE_DEACTIVATED;
+ return CONNECTION_ERROR_NONE;
+ }
+
+ for (; i < bluetooth_profiles.count; i++) {
+ switch (bluetooth_profiles.profiles[i].ProfileState) {
+ case NET_STATE_TYPE_ONLINE:
+ case NET_STATE_TYPE_READY:
+ *state = CONNECTION_BT_STATE_CONNECTED;
+ goto done;
+ case NET_STATE_TYPE_IDLE:
+ case NET_STATE_TYPE_FAILURE:
+ case NET_STATE_TYPE_ASSOCIATION:
+ case NET_STATE_TYPE_CONFIGURATION:
+ case NET_STATE_TYPE_DISCONNECT:
+ *state = CONNECTION_BT_STATE_DISCONNECTED;
+ break;
+ default:
+ __libnet_clear_profile_list(&bluetooth_profiles);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+ }
+
+done:
+ __libnet_clear_profile_list(&bluetooth_profiles);
+
+ return CONNECTION_ERROR_NONE;
}
int _connection_libnet_get_profile_iterator(connection_iterator_type_e type, connection_profile_iterator_h* profile_iter_h)
{
int count = 0;
- int rv1, rv2, rv3;
+ int rv1, rv2, rv3, rv4;
net_profile_info_t *profiles = NULL;
struct _profile_list_s wifi_profiles = {0, 0, NULL};
struct _profile_list_s cellular_profiles = {0, 0, NULL};
struct _profile_list_s ethernet_profiles = {0, 0, NULL};
+ struct _profile_list_s bluetooth_profiles = {0, 0, NULL};
__libnet_clear_profile_list(&profile_iterator);
rv1 = net_get_profile_list(NET_DEVICE_WIFI, &wifi_profiles.profiles, &wifi_profiles.count);
- if (rv1 != NET_ERR_NO_SERVICE && rv1 != NET_ERR_NONE)
+ if (rv1 == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv1 != NET_ERR_NO_SERVICE && rv1 != NET_ERR_NONE)
return CONNECTION_ERROR_OPERATION_FAILED;
- CONNECTION_LOG(CONNECTION_INFO, "Wifi profile count : %d\n", wifi_profiles.count);
+ CONNECTION_LOG(CONNECTION_INFO, "Wi-Fi profile count: %d", wifi_profiles.count);
rv2 = net_get_profile_list(NET_DEVICE_CELLULAR, &cellular_profiles.profiles, &cellular_profiles.count);
- if (rv2 != NET_ERR_NO_SERVICE && rv2 != NET_ERR_NONE) {
+ if (rv2 == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ __libnet_clear_profile_list(&wifi_profiles);
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv2 != NET_ERR_NO_SERVICE && rv2 != NET_ERR_NONE) {
__libnet_clear_profile_list(&wifi_profiles);
return CONNECTION_ERROR_OPERATION_FAILED;
}
- CONNECTION_LOG(CONNECTION_INFO, "Cellular profile count : %d\n", cellular_profiles.count);
+ CONNECTION_LOG(CONNECTION_INFO, "Cellular profile count: %d", cellular_profiles.count);
rv3 = net_get_profile_list(NET_DEVICE_ETHERNET, &ethernet_profiles.profiles, &ethernet_profiles.count);
- if (rv3 != NET_ERR_NO_SERVICE && rv3 != NET_ERR_NONE) {
+ if (rv3 == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ __libnet_clear_profile_list(&wifi_profiles);
+ __libnet_clear_profile_list(&cellular_profiles);
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv3 != NET_ERR_NO_SERVICE && rv3 != NET_ERR_NONE) {
__libnet_clear_profile_list(&wifi_profiles);
__libnet_clear_profile_list(&cellular_profiles);
return CONNECTION_ERROR_OPERATION_FAILED;
}
- CONNECTION_LOG(CONNECTION_INFO, "Ethernet profile count : %d\n", ethernet_profiles.count);
+ CONNECTION_LOG(CONNECTION_INFO, "Ethernet profile count : %d", ethernet_profiles.count);
+
+ rv4 = net_get_profile_list(NET_DEVICE_BLUETOOTH, &bluetooth_profiles.profiles, &bluetooth_profiles.count);
+ if (rv4 == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ __libnet_clear_profile_list(&wifi_profiles);
+ __libnet_clear_profile_list(&cellular_profiles);
+ __libnet_clear_profile_list(&ethernet_profiles);
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv4 != NET_ERR_NO_SERVICE && rv4 != NET_ERR_NONE) {
+ __libnet_clear_profile_list(&wifi_profiles);
+ __libnet_clear_profile_list(&cellular_profiles);
+ __libnet_clear_profile_list(&ethernet_profiles);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+ CONNECTION_LOG(CONNECTION_INFO, "Bluetooth profile count : %d", bluetooth_profiles.count);
*profile_iter_h = &profile_iterator;
switch (type) {
case CONNECTION_ITERATOR_TYPE_REGISTERED:
- count = wifi_profiles.count + cellular_profiles.count + ethernet_profiles.count;
- CONNECTION_LOG(CONNECTION_INFO, "Total profile count : %d\n", count);
+ count = wifi_profiles.count + cellular_profiles.count + ethernet_profiles.count + bluetooth_profiles.count;
+ CONNECTION_LOG(CONNECTION_INFO, "Total profile count : %d", count);
if (count == 0)
return CONNECTION_ERROR_NONE;
@@ -382,6 +776,7 @@ int _connection_libnet_get_profile_iterator(connection_iterator_type_e type, con
__libnet_clear_profile_list(&wifi_profiles);
__libnet_clear_profile_list(&cellular_profiles);
__libnet_clear_profile_list(&ethernet_profiles);
+ __libnet_clear_profile_list(&bluetooth_profiles);
return CONNECTION_ERROR_OUT_OF_MEMORY;
}
@@ -399,16 +794,23 @@ int _connection_libnet_get_profile_iterator(connection_iterator_type_e type, con
profiles += cellular_profiles.count;
}
- if (ethernet_profiles.count > 0)
+ if (ethernet_profiles.count > 0) {
memcpy(profiles, ethernet_profiles.profiles,
sizeof(net_profile_info_t) * ethernet_profiles.count);
+ profiles += ethernet_profiles.count;
+ }
+
+ if (bluetooth_profiles.count > 0)
+ memcpy(profiles, bluetooth_profiles.profiles,
+ sizeof(net_profile_info_t) * bluetooth_profiles.count);
break;
case CONNECTION_ITERATOR_TYPE_CONNECTED:
count = __libnet_get_connected_count(&wifi_profiles);
count += __libnet_get_connected_count(&cellular_profiles);
count += __libnet_get_connected_count(&ethernet_profiles);
- CONNECTION_LOG(CONNECTION_INFO, "Total connected profile count : %d\n", count);
+ count += __libnet_get_connected_count(&bluetooth_profiles);
+ CONNECTION_LOG(CONNECTION_INFO, "Total connected profile count : %d", count);
if (count == 0)
return CONNECTION_ERROR_NONE;
@@ -417,6 +819,7 @@ int _connection_libnet_get_profile_iterator(connection_iterator_type_e type, con
__libnet_clear_profile_list(&wifi_profiles);
__libnet_clear_profile_list(&cellular_profiles);
__libnet_clear_profile_list(&ethernet_profiles);
+ __libnet_clear_profile_list(&bluetooth_profiles);
return CONNECTION_ERROR_OUT_OF_MEMORY;
}
@@ -431,12 +834,36 @@ int _connection_libnet_get_profile_iterator(connection_iterator_type_e type, con
if (ethernet_profiles.count > 0)
__libnet_copy_connected_profile(&profiles, &ethernet_profiles);
+ if (bluetooth_profiles.count > 0)
+ __libnet_copy_connected_profile(&profiles, &bluetooth_profiles);
+
+ break;
+ case CONNECTION_ITERATOR_TYPE_DEFAULT:
+ count = __libnet_get_default_count(&cellular_profiles);
+ CONNECTION_LOG(CONNECTION_INFO, "Total default profile count : %d", count);
+ if (count == 0)
+ return CONNECTION_ERROR_NONE;
+
+ profiles = g_try_new0(net_profile_info_t, count);
+ if (profiles == NULL) {
+ __libnet_clear_profile_list(&wifi_profiles);
+ __libnet_clear_profile_list(&cellular_profiles);
+ __libnet_clear_profile_list(&ethernet_profiles);
+ __libnet_clear_profile_list(&bluetooth_profiles);
+ return CONNECTION_ERROR_OUT_OF_MEMORY;
+ }
+
+ profile_iterator.profiles = profiles;
+
+ if (cellular_profiles.count > 0)
+ __libnet_copy_default_profile(&profiles, &cellular_profiles);
break;
}
__libnet_clear_profile_list(&wifi_profiles);
__libnet_clear_profile_list(&cellular_profiles);
__libnet_clear_profile_list(&ethernet_profiles);
+ __libnet_clear_profile_list(&bluetooth_profiles);
profile_iterator.count = count;
@@ -486,7 +913,10 @@ int _connection_libnet_get_current_profile(connection_profile_h *profile)
rv = net_get_active_net_info(&active_profile);
if (rv == NET_ERR_NO_SERVICE)
return CONNECTION_ERROR_NO_CONNECTION;
- else if (rv != NET_ERR_NONE)
+ else if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE)
return CONNECTION_ERROR_OPERATION_FAILED;
*profile = g_try_malloc0(sizeof(net_profile_info_t));
@@ -499,58 +929,347 @@ int _connection_libnet_get_current_profile(connection_profile_h *profile)
return CONNECTION_ERROR_NONE;
}
-int _connection_libnet_open_profile(connection_profile_h profile)
+int _connection_libnet_reset_profile(connection_reset_option_e type,
+ connection_cellular_subscriber_id_e id, connection_reset_cb callback, void *user_data)
+{
+ int rv;
+
+ rv = net_reset_profile(type, id);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to add profile[%d]", rv);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ __libnet_set_reset_profile_cb(callback, user_data);
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_open_profile(connection_profile_h profile,
+ connection_opened_cb callback, void* user_data)
{
+ int rv;
+
if (!(_connection_libnet_check_profile_validity(profile))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
- if (net_open_connection_with_profile(profile_info->ProfileName) != NET_ERR_NONE)
+ rv = net_open_connection_with_profile(profile_info->ProfileName);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE)
return CONNECTION_ERROR_OPERATION_FAILED;
+ __libnet_set_opened_cb(callback, user_data);
+
return CONNECTION_ERROR_NONE;
}
-int _connection_libnet_open_cellular_service_type(connection_cellular_service_type_e type, connection_profile_h *profile)
+int _connection_libnet_get_cellular_service_profile(
+ connection_cellular_service_type_e type, connection_profile_h *profile)
{
- if (profile == NULL) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
- return CONNECTION_ERROR_INVALID_PARAMETER;
- }
-
- net_profile_name_t profile_name;
- net_profile_info_t profile_info;
+ int i = 0, j = 0;
+ int rv = NET_ERR_NONE;
+#if defined TIZEN_DUALSIM_ENABLE
+ int default_subscriber_id = 0;
+ char subscriber_id[3];
+#endif
+
+ struct _profile_list_s cellular_profiles = { 0, 0, NULL };
net_service_type_t service_type = _connection_profile_convert_to_libnet_cellular_service_type(type);
- if (net_open_connection_with_preference_ext(service_type, &profile_name) != NET_ERR_NONE)
+ rv = net_get_profile_list(NET_DEVICE_CELLULAR, &cellular_profiles.profiles, &cellular_profiles.count);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get profile list (%d)", rv);
return CONNECTION_ERROR_OPERATION_FAILED;
+ }
- if (net_get_profile_info(profile_name.ProfileName, &profile_info) != NET_ERR_NONE)
+#if defined TIZEN_DUALSIM_ENABLE
+ if (vconf_get_int(VCONF_TELEPHONY_DEFAULT_DATA_SERVICE,
+ &default_subscriber_id) != 0) {
+ CONNECTION_LOG(CONNECTION_ERROR,
+ "Failed to get VCONF_TELEPHONY_DEFAULT_DATA_SERVICE");
+ __libnet_clear_profile_list(&cellular_profiles);
return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ g_snprintf(subscriber_id, sizeof(subscriber_id), "%d", default_subscriber_id);
+#endif
+
+ for (i = 0; i < cellular_profiles.count; i++)
+ if (cellular_profiles.profiles[i].ProfileInfo.Pdp.ServiceType == service_type)
+#if defined TIZEN_DUALSIM_ENABLE
+ if (g_str_has_suffix(
+ cellular_profiles.profiles[i].ProfileInfo.Pdp.PSModemPath,
+ subscriber_id) == TRUE)
+#endif
+ break;
+
+ if (i >= cellular_profiles.count) {
+ __libnet_clear_profile_list(&cellular_profiles);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
*profile = g_try_malloc0(sizeof(net_profile_info_t));
- if (*profile == NULL)
+ if (*profile == NULL) {
+ __libnet_clear_profile_list(&cellular_profiles);
return CONNECTION_ERROR_OUT_OF_MEMORY;
+ }
+
+ memcpy(*profile, &cellular_profiles.profiles[i], sizeof(net_profile_info_t));
+
+ if (cellular_profiles.profiles[i].ProfileInfo.Pdp.DefaultConn)
+ goto done;
+
+ if (type != CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET &&
+ type != CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET)
+ goto done;
+
+ for (j = 0; j < cellular_profiles.count; j++) {
+ if (i == j)
+ continue;
+
+ if (cellular_profiles.profiles[j].ProfileInfo.Pdp.ServiceType != service_type)
+ continue;
- memcpy(*profile, &profile_info, sizeof(net_profile_info_t));
+ if (cellular_profiles.profiles[j].ProfileInfo.Pdp.DefaultConn) {
+ memcpy(*profile, &cellular_profiles.profiles[j], sizeof(net_profile_info_t));
+ goto done;
+ }
+ }
+
+done:
+ __libnet_clear_profile_list(&cellular_profiles);
prof_handle_list = g_slist_append(prof_handle_list, *profile);
return CONNECTION_ERROR_NONE;
}
-int _connection_libnet_close_profile(connection_profile_h profile)
+int _connection_libnet_set_cellular_service_profile_sync(connection_cellular_service_type_e type, connection_profile_h profile)
{
+ int rv;
+
if (!(_connection_libnet_check_profile_validity(profile))) {
- CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n");
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
return CONNECTION_ERROR_INVALID_PARAMETER;
}
net_profile_info_t *profile_info = profile;
+ connection_cellular_service_type_e service_type;
+
+ service_type = _profile_convert_to_connection_cellular_service_type(profile_info->ProfileInfo.Pdp.ServiceType);
+
+ if (service_type != type)
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+
+ rv = net_set_default_cellular_service_profile(profile_info->ProfileName);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED;
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_set_cellular_service_profile_async(connection_cellular_service_type_e type,
+ connection_profile_h profile, connection_set_default_cb callback, void* user_data)
+{
+ int rv;
+
+ if (!(_connection_libnet_check_profile_validity(profile))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ net_profile_info_t *profile_info = profile;
+ connection_cellular_service_type_e service_type;
+
+ service_type = _profile_convert_to_connection_cellular_service_type(profile_info->ProfileInfo.Pdp.ServiceType);
+
+ if (service_type != type)
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+
+ rv = net_set_default_cellular_service_profile_async(profile_info->ProfileName);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED;
+
+ __libnet_set_default_cb(callback, user_data);
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_close_profile(connection_profile_h profile, connection_closed_cb callback, void *user_data)
+{
+ int rv;
+
+ if (!(_connection_libnet_check_profile_validity(profile))) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+
+ net_profile_info_t *profile_info = profile;
+
+ rv = net_close_connection(profile_info->ProfileName);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED;
+
+ __libnet_set_closed_cb(callback, user_data);
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_add_route(const char *interface_name, const char *host_address)
+{
+ int rv;
+ char *endstr = NULL;
+ int address_family = 0;
+
+ if(__libnet_check_address_type(AF_INET, host_address))
+ address_family = AF_INET;
+ else
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+
+ switch(address_family) {
+ case AF_INET:
+ endstr = strrchr(host_address, '.');
+ if (endstr == NULL ||
+ strcmp(endstr, ".0") == 0 ||
+ strncmp(host_address, "0.", 2) == 0 ||
+ strstr(host_address, "255") != NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ default:
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ rv = net_add_route(host_address, interface_name, address_family);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED;
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_remove_route(const char *interface_name, const char *host_address)
+{
+ int rv;
+ char *endstr = strrchr(host_address, '.');
+ int address_family = 0;
+
+ if (__libnet_check_address_type(AF_INET, host_address))
+ address_family = AF_INET;
+ else
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+
+ switch(address_family) {
+ case AF_INET:
+ endstr = strrchr(host_address, '.');
+ if (endstr == NULL ||
+ strcmp(endstr, ".0") == 0 ||
+ strncmp(host_address, "0.", 2) == 0 ||
+ strstr(host_address, ".0.") != NULL ||strstr(host_address, "255") != NULL) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ default:
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ rv = net_remove_route(host_address, interface_name, address_family);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED;
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_add_route_ipv6(const char *interface_name, const char *host_address, const char *gateway)
+{
+ int rv;
+ int address_family = 0;
+
+ address_family = AF_INET6;
+/* if(__libnet_check_address_type(AF_INET6, host_address))
+ address_family = AF_INET6;
+ else
+ return CONNECTION_ERROR_INVALID_PARAMETER;*/
+
+ switch(address_family) {
+ case AF_INET6:
+ if (strncmp(host_address, "fe80:", 5) == 0 ||
+ strncmp(host_address, "ff00:", 5) == 0 ||
+ strncmp(host_address, "::", 2) == 0) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ default:
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
- if (net_close_connection(profile_info->ProfileName) != NET_ERR_NONE)
+ rv = net_add_route_ipv6(host_address, interface_name, address_family, gateway);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED;
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_remove_route_ipv6(const char *interface_name, const char *host_address, const char *gateway)
+{
+ int rv;
+ int address_family = 0;
+
+ address_family = AF_INET6;
+/* if (__libnet_check_address_type(AF_INET6, host_address))
+ address_family = AF_INET6;
+ else
+ return CONNECTION_ERROR_INVALID_PARAMETER;*/
+
+ switch(address_family) {
+ case AF_INET6:
+ if (strncmp(host_address, "fe80:", 5) == 0 ||
+ strncmp(host_address, "ff00:", 5) == 0 ||
+ strncmp(host_address, "::", 2) == 0) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n");
+ return CONNECTION_ERROR_INVALID_PARAMETER;
+ }
+ break;
+ default:
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ rv = net_remove_route_ipv6(host_address, interface_name, address_family, gateway);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE)
return CONNECTION_ERROR_OPERATION_FAILED;
return CONNECTION_ERROR_NONE;
@@ -581,22 +1300,30 @@ bool _connection_libnet_add_to_profile_cb_list(connection_profile_h profile,
profile_cb_info->callback = callback;
profile_cb_info->user_data = user_data;
- memcpy(&profile_cb_info->profile, profile_info, sizeof(net_profile_info_t));
- g_hash_table_insert(profile_cb_table, profile_name, profile_cb_info);
+ g_hash_table_replace(profile_cb_table, profile_name, profile_cb_info);
return true;
}
-void _connection_libnet_remove_from_profile_cb_list(connection_profile_h profile)
+bool _connection_libnet_remove_from_profile_cb_list(connection_profile_h profile)
{
net_profile_info_t *profile_info = profile;
- g_hash_table_remove(profile_cb_table, profile_info->ProfileName);
+
+ if (g_hash_table_remove(profile_cb_table, profile_info->ProfileName) == TRUE)
+ return true;
+
+ return false;
}
int _connection_libnet_set_statistics(net_device_t device_type, net_statistics_type_e statistics_type)
{
- if (net_set_statistics(device_type, statistics_type) != NET_ERR_NONE)
+ int rv;
+ rv = net_set_statistics(device_type, statistics_type);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE)
return CONNECTION_ERROR_OPERATION_FAILED;
return CONNECTION_ERROR_NONE;
@@ -604,9 +1331,164 @@ int _connection_libnet_set_statistics(net_device_t device_type, net_statistics_t
int _connection_libnet_get_statistics(net_statistics_type_e statistics_type, unsigned long long *size)
{
- if (net_get_statistics(NET_DEVICE_WIFI, statistics_type, size) != NET_ERR_NONE)
- return CONNECTION_ERROR_OPERATION_FAILED;
+ int rv;
+ rv = net_get_statistics(NET_DEVICE_WIFI, statistics_type, size);
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ }else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED;
- return CONNECTION_ERROR_NONE;
+ return CONNECTION_ERROR_NONE;
}
+int _connection_libnet_set_cellular_subscriber_id(connection_profile_h profile,
+ connection_cellular_subscriber_id_e sim_id)
+{
+ char *modem_path = NULL;
+ net_profile_info_t *profile_info = (net_profile_info_t *)profile;
+
+ if (net_get_cellular_modem_object_path(&modem_path, sim_id) != NET_ERR_NONE) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Failed to get subscriber[%d]", sim_id);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ if (!modem_path) {
+ CONNECTION_LOG(CONNECTION_ERROR, "NULL modem object path");
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+
+ g_strlcpy(profile_info->ProfileInfo.Pdp.PSModemPath, modem_path,
+ NET_PROFILE_NAME_LEN_MAX);
+ g_free(modem_path);
+
+ return CONNECTION_ERROR_NONE;
+}
+
+static void __connection_idle_destroy_cb(gpointer data)
+{
+ if (!data)
+ return;
+
+ managed_idler_list = g_slist_remove(managed_idler_list, data);
+ g_free(data);
+}
+
+static gboolean __connection_idle_cb(gpointer user_data)
+{
+ struct managed_idle_data *data = (struct managed_idle_data *)user_data;
+
+ if (!data)
+ return FALSE;
+
+ return data->func(data->user_data);
+}
+
+guint _connection_callback_add(GSourceFunc func, gpointer user_data)
+{
+ guint id;
+ struct managed_idle_data *data;
+
+ if (!func)
+ return 0;
+
+ data = g_try_new0(struct managed_idle_data, 1);
+ if (!data)
+ return 0;
+
+ data->func = func;
+ data->user_data = user_data;
+
+ id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, __connection_idle_cb, data,
+ __connection_idle_destroy_cb);
+ if (!id) {
+ g_free(data);
+ return id;
+ }
+
+ data->id = id;
+
+ managed_idler_list = g_slist_append(managed_idler_list, data);
+
+ return id;
+}
+
+void _connection_callback_cleanup(void)
+{
+ GSList *cur = managed_idler_list;
+ GSource *src;
+ struct managed_idle_data *data;
+
+ while (cur) {
+ GSList *next = cur->next;
+ data = (struct managed_idle_data *)cur->data;
+
+ src = g_main_context_find_source_by_id(g_main_context_default(), data->id);
+ if (src) {
+ g_source_destroy(src);
+ cur = managed_idler_list;
+ } else
+ cur = next;
+ }
+
+ g_slist_free(managed_idler_list);
+ managed_idler_list = NULL;
+}
+
+int _connection_libnet_check_get_privilege()
+{
+ int rv;
+
+ rv = net_check_get_privilege();
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED;
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_libnet_check_profile_privilege()
+{
+ int rv;
+
+ rv = net_check_profile_privilege();
+ if (rv == NET_ERR_ACCESS_DENIED) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+ return CONNECTION_ERROR_PERMISSION_DENIED;
+ } else if (rv != NET_ERR_NONE)
+ return CONNECTION_ERROR_OPERATION_FAILED;
+
+ return CONNECTION_ERROR_NONE;
+}
+
+int _connection_check_feature_supported(const char *feature_name, ...)
+{
+ va_list list;
+ const char *key;
+ bool value, feature_supported = false;
+
+ va_start(list, feature_name);
+ key = feature_name;
+ while(1) {
+ if(system_info_get_platform_bool(key, &value) < 0) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Error - Feature getting from System Info");
+ set_last_result(CONNECTION_ERROR_OPERATION_FAILED);
+ return CONNECTION_ERROR_OPERATION_FAILED;
+ }
+ SECURE_CONNECTION_LOG(CONNECTION_INFO, "%s feature is %s", key, (value?"true":"false"));
+ feature_supported |= value;
+ key = va_arg(list, const char *);
+ if (!key) break;
+ }
+ if (!feature_supported) {
+ CONNECTION_LOG(CONNECTION_ERROR, "Error - Feature is not supported");
+ set_last_result(CONNECTION_ERROR_NOT_SUPPORTED);
+ return CONNECTION_ERROR_NOT_SUPPORTED;
+ }
+ va_end(list);
+
+ set_last_result(CONNECTION_ERROR_NONE);
+ return CONNECTION_ERROR_NONE;
+}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 7715cac..dea5547 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,12 +1,18 @@
+PROJECT(connection_test C)
+
SET(fw_test "${fw_name}-test")
+SET(dependents "capi-base-common glib-2.0 network")
+SET(pc_dependents "capi-base-common")
+
INCLUDE(FindPkgConfig)
-pkg_check_modules(${fw_test} REQUIRED glib-2.0)
+pkg_check_modules(${fw_test} REQUIRED ${dependents})
FOREACH(flag ${${fw_test}_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -fPIE")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
aux_source_directory(. sources)
FOREACH(src ${sources})
@@ -15,3 +21,5 @@ FOREACH(src ${sources})
ADD_EXECUTABLE(${src_name} ${src})
TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS})
ENDFOREACH()
+
+INSTALL(TARGETS connection_test RUNTIME DESTINATION bin/)
diff --git a/test/connection_test.c b/test/connection_test.c
index 46cfe30..381d0ad 100644..100755
--- a/test/connection_test.c
+++ b/test/connection_test.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -11,42 +11,123 @@
* 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.
+ * limitations under the License.
*/
-#include <glib.h>
#include <stdio.h>
+#include <errno.h>
#include <stdlib.h>
-#include <netdb.h>
-#include <sys/socket.h>
#include <string.h>
#include <unistd.h>
-#include <sys/un.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <signal.h>
-#include "assert.h"
-#include "glib.h"
+#include <glib.h>
+
#include "net_connection.h"
+
#include <tizen_error.h>
-
-gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data);
-int test_register_client(void);
-int test_deregister_client(void);
-int test_get_network_state(void);
-int test_get_cellular_state(void);
-int test_get_wifi_state(void);
-int test_get_current_proxy(void);
-int test_get_current_ip(void);
-int test_get_call_statistics_info(void);
-int test_get_wifi_call_statistics_info(void);
+#define RETURN_FAIL_DESTROY(x) {connection_profile_destroy(x); return -1;}
+gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data);
connection_h connection = NULL;
+static GSList *state_cb_list = NULL;
+
+
+static bool test_get_user_string(const char *msg, char *buf, int buf_size)
+{
+ if (msg == NULL || buf == NULL || buf_size < 2)
+ return false;
+
+ int rv;
+ printf("%s\n", msg);
+ memset(buf, 0, buf_size);
+ rv = read(0, buf, buf_size - 1);
+
+ if (rv < 0 || buf[0] == '\0' || buf[0] == '\n' || buf[0] == '\r') {
+ buf[0] = '\0';
+ return false;
+ }
+
+ if (rv >= 0)
+ buf[rv] = '\0';
+
+ return true;
+}
+
+static bool test_get_user_int(const char *msg, int *num)
+{
+ if (msg == NULL || num == NULL)
+ return false;
+
+ int rv;
+ char buf[32] = {0,};
+ printf("%s\n", msg);
+ rv = read(0, buf, 32);
+
+ if (rv < 0 || *buf == 0 || *buf == '\n' || *buf == '\r')
+ return false;
+
+ *num = atoi(buf);
+ return true;
+}
-static void test_state_changed_callback(connection_type_e type, void* user_data)
+static const char *test_print_state(connection_profile_state_e state)
+{
+ switch (state) {
+ case CONNECTION_PROFILE_STATE_DISCONNECTED:
+ return "Disconnected";
+ case CONNECTION_PROFILE_STATE_ASSOCIATION:
+ return "Association";
+ case CONNECTION_PROFILE_STATE_CONFIGURATION:
+ return "Configuration";
+ case CONNECTION_PROFILE_STATE_CONNECTED:
+ return "Connected";
+ default:
+ return "Unknown";
+ }
+}
+
+static const char *test_print_error(connection_error_e error)
+{
+ switch (error) {
+ case CONNECTION_ERROR_NONE:
+ return "CONNECTION_ERROR_NONE";
+ case CONNECTION_ERROR_INVALID_PARAMETER:
+ return "CONNECTION_ERROR_INVALID_PARAMETER";
+ case CONNECTION_ERROR_OUT_OF_MEMORY:
+ return "CONNECTION_ERROR_OUT_OF_MEMORY";
+ case CONNECTION_ERROR_INVALID_OPERATION:
+ return "CONNECTION_ERROR_INVALID_OPERATION";
+ case CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED:
+ return "CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED";
+ case CONNECTION_ERROR_OPERATION_FAILED:
+ return "CONNECTION_ERROR_OPERATION_FAILED";
+ case CONNECTION_ERROR_ITERATOR_END:
+ return "CONNECTION_ERROR_ITERATOR_END";
+ case CONNECTION_ERROR_NO_CONNECTION:
+ return "CONNECTION_ERROR_NO_CONNECTION";
+ case CONNECTION_ERROR_NOW_IN_PROGRESS:
+ return "CONNECTION_ERROR_NOW_IN_PROGRESS";
+ case CONNECTION_ERROR_ALREADY_EXISTS:
+ return "CONNECTION_ERROR_ALREADY_EXISTS";
+ case CONNECTION_ERROR_OPERATION_ABORTED:
+ return "CONNECTION_ERROR_OPERATION_ABORTED";
+ case CONNECTION_ERROR_DHCP_FAILED:
+ return "CONNECTION_ERROR_DHCP_FAILED";
+ case CONNECTION_ERROR_INVALID_KEY:
+ return "CONNECTION_ERROR_INVALID_KEY";
+ case CONNECTION_ERROR_NO_REPLY:
+ return "CONNECTION_ERROR_NO_REPLY";
+ case CONNECTION_ERROR_PERMISSION_DENIED:
+ return "CONNECTION_ERROR_PERMISSION_DENIED";
+ case CONNECTION_ERROR_NOT_SUPPORTED:
+ return "CONNECTION_ERROR_NOT_SUPPORTED";
+ default:
+ return "CONNECTION_ERROR_UNKNOWN";
+ }
+}
+
+static void test_type_changed_callback(connection_type_e type, void* user_data)
{
printf("Type changed callback, connection type : %d\n", type);
}
@@ -63,35 +144,54 @@ static void test_proxy_changed_callback(const char* ipv4_address, const char* ip
ipv4_address, (ipv6_address ? ipv6_address : "NULL"));
}
-static void test_profile_state_callback(connection_profile_h profile, bool is_requested, void* user_data)
+static void test_profile_state_callback(connection_profile_state_e state, void* user_data)
{
- connection_profile_state_e state;
char *profile_name;
+ connection_profile_h profile = user_data;
- if (connection_profile_get_state(profile, &state) != CONNECTION_ERROR_NONE)
+ if (profile == NULL)
return;
if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE)
return;
- switch (state) {
- case CONNECTION_PROFILE_STATE_DISCONNECTED:
- printf("[Disconnected] : %s\n", profile_name);
- break;
- case CONNECTION_PROFILE_STATE_ASSOCIATION:
- printf("[Association] : %s\n", profile_name);
- break;
- case CONNECTION_PROFILE_STATE_CONFIGURATION:
- printf("[Configuration] : %s\n", profile_name);
- break;
- case CONNECTION_PROFILE_STATE_CONNECTED:
- printf("[Connected] : %s\n", profile_name);
- }
-
+ printf("[%s] : %s\n", test_print_state(state), profile_name);
g_free(profile_name);
}
-static bool test_get_user_selected_profile(connection_profile_h *profile)
+static void test_connection_opened_callback(connection_error_e result, void* user_data)
+{
+ if (result == CONNECTION_ERROR_NONE)
+ printf("Connection open Succeeded\n");
+ else
+ printf("Connection open Failed, err : [%s]\n", test_print_error(result));
+}
+
+static void test_connection_closed_callback(connection_error_e result, void* user_data)
+{
+ if (result == CONNECTION_ERROR_NONE)
+ printf("Connection close Succeeded\n");
+ else
+ printf("Connection close Failed, err : [%s]\n", test_print_error(result));
+}
+
+static void test_connection_reset_profile_callback(connection_error_e result, void* user_data)
+{
+ if (result == CONNECTION_ERROR_NONE)
+ printf("Reset profile Succeeded\n");
+ else
+ printf("Reset profile Failed, err : [%s]\n", test_print_error(result));
+}
+
+static void test_connection_set_default_callback(connection_error_e result, void* user_data)
+{
+ if (result == CONNECTION_ERROR_NONE)
+ printf("Default profile setting Succeeded\n");
+ else
+ printf("Default profile setting Failed, err : [%s]\n", test_print_error(result));
+}
+
+static bool test_get_user_selected_profile(connection_profile_h *profile, bool select)
{
int rv = 0;
int input = 0;
@@ -106,7 +206,7 @@ static bool test_get_user_selected_profile(connection_profile_h *profile)
rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_REGISTERED, &profile_iter);
if (rv != CONNECTION_ERROR_NONE) {
- printf("Fail to get profile iterator [%d]\n", rv);
+ printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
return false;
}
@@ -127,73 +227,540 @@ static bool test_get_user_selected_profile(connection_profile_h *profile)
return false;
}
- connection_profile_get_state(profile_h, &profile_state);
+ if (connection_profile_get_state(profile_h, &profile_state) != CONNECTION_ERROR_NONE) {
+ printf("Fail to get profile state\n");
+ g_free(profile_name);
+ return false;
+ }
if (profile_type == CONNECTION_PROFILE_TYPE_WIFI) {
char *essid;
connection_profile_get_wifi_essid(profile_h, &essid);
- printf("%d. state:%d, profile name:%s, essid:%s\n",
- profile_count, profile_state, profile_name, (essid)? essid : "");
+ printf("%d. state:[%s], profile name:%s, essid:%s\n",
+ profile_count, test_print_state(profile_state),
+ profile_name, (essid)? essid : "");
g_free(essid);
- } else
- printf("%d. state:%d, profile name : %s\n",
- profile_count, profile_state, profile_name);
- g_free(profile_name);
+ profile_list[profile_count] = profile_h;
+ profile_count++;
+ } else {
+ printf("%d. state:[%s], profile name : %s\n",
+ profile_count, test_print_state(profile_state), profile_name);
+
+ profile_list[profile_count] = profile_h;
+ profile_count++;
+ }
+ g_free(profile_name);
if (profile_count >= 100)
break;
-
- profile_list[profile_count] = profile_h;
- profile_count++;
}
- printf("\nInput profile number : \n");
- rv = scanf("%d", &input);
+ if (select == false)
+ return true;
- if (input >= profile_count || input < 0) {
+ if (test_get_user_int("Input profile number(Enter for cancel) :", &input) == false ||
+ input >= profile_count ||
+ input < 0) {
printf("Wrong number!!\n");
return false;
}
- *profile = profile_list[input];
+ if (profile)
+ *profile = profile_list[input];
return true;
}
+static int test_update_cellular_info(connection_profile_h profile)
+{
+ int rv = 0;
+ char input_str1[100] = {0,};
+ char input_str2[100] = {0,};
+ int input_int = 0;
+ int type_val = 0;
+
+ if (test_get_user_int("Input Network Type (internet:1, MMS:2, Prepaid internet:3, "
+ "Prepaid MMS:4, Tethering:5, Application:6)"
+ " - (Enter for skip) :", &input_int)) {
+ switch (input_int) {
+ case 1:
+ rv = connection_profile_set_cellular_service_type(profile,
+ CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET);
+ break;
+ case 2:
+ rv = connection_profile_set_cellular_service_type(profile,
+ CONNECTION_CELLULAR_SERVICE_TYPE_MMS);
+ break;
+ case 3:
+ rv = connection_profile_set_cellular_service_type(profile,
+ CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET);
+ break;
+ case 4:
+ rv = connection_profile_set_cellular_service_type(profile,
+ CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS);
+ break;
+ case 5:
+ rv = connection_profile_set_cellular_service_type(profile,
+ CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING);
+ break;
+ case 6:
+ rv = connection_profile_set_cellular_service_type(profile,
+ CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION);
+ break;
+ default:
+ return -1;
+ }
+
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+ } else
+ return -1;
+
+ if (test_get_user_string("Input Apn - (Enter for skip) :", input_str1, 100)) {
+ g_strstrip(input_str1);
+ rv = connection_profile_set_cellular_apn(profile, input_str1);
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_string("Input Proxy - (Enter for skip) :", input_str1, 100)) {
+ g_strstrip(input_str1);
+ rv = connection_profile_set_proxy_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, input_str1);
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_string("Input HomeURL - (Enter for skip) :", input_str1, 100)) {
+ g_strstrip(input_str1);
+ rv = connection_profile_set_cellular_home_url(profile, input_str1);
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_int("Input AuthType(0:NONE 1:PAP 2:CHAP) - (Enter for skip) :", &input_int)) {
+ switch (input_int) {
+ case 0:
+ rv = connection_profile_set_cellular_auth_info(profile,
+ CONNECTION_CELLULAR_AUTH_TYPE_NONE, "", "");
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+
+ break;
+ case 1:
+ type_val = CONNECTION_CELLULAR_AUTH_TYPE_PAP;
+ /* fall through */
+ case 2:
+ if (input_int == 2) type_val = CONNECTION_CELLULAR_AUTH_TYPE_CHAP;
+
+ if (test_get_user_string("Input AuthId(Enter for skip) :", input_str1, 100) == false)
+ input_str1[0] = 0;
+ if (test_get_user_string("Input AuthPwd(Enter for skip) :", input_str2, 100) == false)
+ input_str2[0] = 0;
+
+ g_strstrip(input_str1);
+ g_strstrip(input_str2);
+ rv = connection_profile_set_cellular_auth_info(profile, type_val, input_str1, input_str2);
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+ }
+ }
+
+ return 1;
+}
+
+static int test_update_wifi_info(connection_profile_h profile)
+{
+ int rv = 0;
+ char input_str[100] = {0,};
+
+ if (test_get_user_string("Input Passphrase - (Enter for skip) :", input_str, 100)) {
+ rv = connection_profile_set_wifi_passphrase(profile, input_str);
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+ }
+
+ return 1;
+}
+
+static int test_update_ip_info(connection_profile_h profile, connection_address_family_e address_family)
+{
+ int rv = 0;
+ char input_str[100] = {0,};
+
+ if (test_get_user_string("Input IP Address - (Enter for skip) :", input_str, 100)) {
+ rv = connection_profile_set_ip_address(profile,
+ address_family,
+ input_str);
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_string("Input Netmask - (Enter for skip) :", input_str, 100)) {
+ rv = connection_profile_set_subnet_mask(profile,
+ address_family,
+ input_str);
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_string("Input Gateway - (Enter for skip) :", input_str, 100)) {
+ rv = connection_profile_set_gateway_address(profile,
+ address_family,
+ input_str);
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+ }
+
+ if (test_get_user_string("Input DNS 1 Address - (Enter for skip) :", input_str, 100)) {
+ rv = connection_profile_set_dns_address(profile,
+ 1,
+ address_family,
+ input_str);
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+
+ if (test_get_user_string("Input DNS 2 Address - (Enter for skip) :", input_str, 100)) {
+ rv = connection_profile_set_dns_address(profile,
+ 2,
+ address_family,
+ input_str);
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+ }
+ }
+
+ return 1;
+}
+
+static int test_update_proxy_info(connection_profile_h profile, connection_address_family_e address_family)
+{
+ int rv = 0;
+ int input_int = 0;
+ char input_str[100] = {0,};
+
+ if (test_get_user_int("Input Proxy Type (1:direct, 2:auto, 3:manual)"
+ " - (Enter for skip) :", &input_int)) {
+ switch (input_int) {
+ case 1:
+ rv = connection_profile_set_proxy_type(profile,
+ CONNECTION_PROXY_TYPE_DIRECT);
+
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+ else
+ return 1;
+ case 2:
+ rv = connection_profile_set_proxy_type(profile,
+ CONNECTION_PROXY_TYPE_AUTO);
+ break;
+ case 3:
+ rv = connection_profile_set_proxy_type(profile,
+ CONNECTION_PROXY_TYPE_MANUAL);
+ break;
+ default:
+ return -1;
+ }
+
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+
+ if (test_get_user_string("Input auto Proxy URL or Proxy address"
+ " - (Enter for skip) :", input_str, 100)) {
+ rv = connection_profile_set_proxy_address(profile,
+ address_family,
+ input_str);
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+ }
+
+ } else
+ return -1;
+
+ return 1;
+}
+
+static int test_update_network_info(connection_profile_h profile)
+{
+ int rv = 0;
+ int input_int = 0;
+ int address_family;
+
+ test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
+
+ if (test_get_user_int("Input IPv4 Address Type (DHCP:1, Static:2)"
+ " - (Enter for skip) :", &input_int)) {
+ switch (input_int) {
+ case 1:
+ rv = connection_profile_set_ip_config_type(profile,
+ address_family,
+ CONNECTION_IP_CONFIG_TYPE_DYNAMIC);
+ break;
+ case 2:
+ rv = connection_profile_set_ip_config_type(profile,
+ address_family,
+ CONNECTION_IP_CONFIG_TYPE_STATIC);
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+
+ if (test_update_ip_info(profile, address_family) == -1)
+ return -1;
+
+ if (test_update_proxy_info(profile, address_family) == -1)
+ return -1;
+ break;
+ default:
+ return -1;
+ }
+
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+ } else
+ return -1;
+
+ return 1;
+}
+
+static void test_print_cellular_info(connection_profile_h profile)
+{
+ connection_cellular_service_type_e service_type;
+ char *apn = NULL;
+ connection_cellular_auth_type_e auth_type;
+ char *user_name = NULL;
+ char *password = NULL;
+ char *home_url = NULL;
+ bool roaming = false;
+ bool hidden = false;
+ bool editable = false;
+
+ if (connection_profile_get_cellular_service_type(profile, &service_type) != CONNECTION_ERROR_NONE)
+ printf("Fail to get cellular service type!\n");
+ else
+ printf("Cellular service type : %d\n", service_type);
+
+ if (connection_profile_get_cellular_apn(profile, &apn) != CONNECTION_ERROR_NONE)
+ printf("Fail to get cellular APN!\n");
+ else {
+ printf("Cellular APN : %s\n", apn);
+ g_free(apn);
+ }
+
+ if (connection_profile_get_cellular_auth_info(profile, &auth_type, &user_name, &password) != CONNECTION_ERROR_NONE)
+ printf("Fail to get auth info!\n");
+ else {
+ printf("Cellular auth type : %d\n", auth_type);
+ printf("Cellular user_name : %s\n", user_name);
+ printf("Cellular password : %s\n", password);
+ g_free(user_name);
+ g_free(password);
+ }
+
+ if (connection_profile_get_cellular_home_url(profile, &home_url) != CONNECTION_ERROR_NONE)
+ printf("Fail to get cellular home url!\n");
+ else {
+ printf("Cellular home url : %s\n", home_url);
+ g_free(home_url);
+ }
+
+ if (connection_profile_is_cellular_roaming(profile, &roaming) != CONNECTION_ERROR_NONE)
+ printf("Fail to get cellular roaming state!\n");
+ else
+ printf("Cellular roaming : %s\n", roaming ? "true" : "false");
+
+ if (connection_profile_is_cellular_hidden(profile, &hidden) != CONNECTION_ERROR_NONE)
+ printf("Fail to get cellular hidden state!\n");
+ else
+ printf("Cellular hidden : %s\n", hidden ? "true" : "false");
+
+ if (connection_profile_is_cellular_editable(profile, &editable) != CONNECTION_ERROR_NONE)
+ printf("Fail to get cellular editing state!\n");
+ else
+ printf("Cellular editable : %s\n", editable ? "true" : "false");
+}
+
+static void test_print_wifi_info(connection_profile_h profile)
+{
+ char *essid = NULL;
+ char *bssid = NULL;
+ int rssi = 0;
+ int frequency = 0;
+ int max_speed = 0;
+ connection_wifi_security_type_e security_type;
+ connection_wifi_encryption_type_e encryption_type;
+ bool pass_required = false;
+ bool wps_supported = false;
+
+ if (connection_profile_get_wifi_essid(profile, &essid) != CONNECTION_ERROR_NONE)
+ printf("Fail to get Wi-Fi essid!\n");
+ else {
+ printf("Wi-Fi essid : %s\n", essid);
+ g_free(essid);
+ }
+
+ if (connection_profile_get_wifi_bssid(profile, &bssid) != CONNECTION_ERROR_NONE)
+ printf("Fail to get Wi-Fi bssid!\n");
+ else {
+ printf("Wi-Fi bssid : %s\n", bssid);
+ g_free(bssid);
+ }
+
+ if (connection_profile_get_wifi_rssi(profile, &rssi) != CONNECTION_ERROR_NONE)
+ printf("Fail to get Wi-Fi rssi!\n");
+ else
+ printf("Wi-Fi rssi : %d\n", rssi);
+
+ if (connection_profile_get_wifi_frequency(profile, &frequency) != CONNECTION_ERROR_NONE)
+ printf("Fail to get Wi-Fi frequency!\n");
+ else
+ printf("Wi-Fi frequency : %d\n", frequency);
+
+ if (connection_profile_get_wifi_max_speed(profile, &max_speed) != CONNECTION_ERROR_NONE)
+ printf("Fail to get Wi-Fi max speed!\n");
+ else
+ printf("Wi-Fi max speed : %d\n", max_speed);
+
+ if (connection_profile_get_wifi_security_type(profile, &security_type) != CONNECTION_ERROR_NONE)
+ printf("Fail to get Wi-Fi security type!\n");
+ else
+ printf("Wi-Fi security type : %d\n", security_type);
+
+ if (connection_profile_get_wifi_encryption_type(profile, &encryption_type) != CONNECTION_ERROR_NONE)
+ printf("Fail to get Wi-Fi encryption type!\n");
+ else
+ printf("Wi-Fi encryption type : %d\n", encryption_type);
+
+ if (connection_profile_is_wifi_passphrase_required(profile, &pass_required) != CONNECTION_ERROR_NONE)
+ printf("Fail to get Wi-Fi passphrase required!\n");
+ else
+ printf("Wi-Fi passphrase required : %s\n", pass_required ? "true" : "false");
+
+ if (connection_profile_is_wifi_wps_supported(profile, &wps_supported) != CONNECTION_ERROR_NONE)
+ printf("Fail to get Wi-Fi wps info\n");
+ else
+ printf("Wi-Fi wps supported : %s\n", wps_supported ? "true" : "false");
+}
+
+static void test_print_network_info(connection_profile_h profile, connection_address_family_e address_family)
+{
+ char *interface_name = NULL;
+ connection_ip_config_type_e ip_type;
+ char *ip = NULL;
+ char *subnet = NULL;
+ char *gateway = NULL;
+ char *dns1 = NULL;
+ char *dns2 = NULL;
+ connection_proxy_type_e proxy_type;
+ char *proxy = NULL;
+
+ if (connection_profile_get_network_interface_name(profile, &interface_name) != CONNECTION_ERROR_NONE)
+ printf("Fail to get interface name!\n");
+ else {
+ printf("Interface name : %s\n", interface_name);
+ g_free(interface_name);
+ }
+
+ if (connection_profile_get_ip_config_type(profile, address_family, &ip_type) != CONNECTION_ERROR_NONE)
+ printf("Fail to get ipconfig type!\n");
+ else
+ printf("Ipconfig type : %d\n", ip_type);
+
+ if (connection_profile_get_ip_address(profile, address_family, &ip) != CONNECTION_ERROR_NONE)
+ printf("Fail to get IP address!\n");
+ else {
+ printf("IP address : %s\n", ip);
+ g_free(ip);
+ }
+
+ if (connection_profile_get_subnet_mask(profile, address_family, &subnet) != CONNECTION_ERROR_NONE)
+ printf("Fail to get subnet mask!\n");
+ else {
+ printf("Subnet mask : %s\n", subnet);
+ g_free(subnet);
+ }
+
+ if (connection_profile_get_gateway_address(profile, address_family, &gateway) != CONNECTION_ERROR_NONE)
+ printf("Fail to get gateway!\n");
+ else {
+ printf("Gateway : %s\n", gateway);
+ g_free(gateway);
+ }
+
+ if (connection_profile_get_dns_address(profile, 1, address_family, &dns1) != CONNECTION_ERROR_NONE)
+ printf("Fail to get DNS1!\n");
+ else {
+ printf("DNS1 : %s\n", dns1);
+ g_free(dns1);
+ }
+
+ if (connection_profile_get_dns_address(profile, 2, address_family, &dns2) != CONNECTION_ERROR_NONE)
+ printf("Fail to get DNS2!\n");
+ else {
+ printf("DNS2 : %s\n", dns2);
+ g_free(dns2);
+ }
+
+ if (connection_profile_get_proxy_type(profile, &proxy_type) != CONNECTION_ERROR_NONE)
+ printf("Fail to get proxy type!\n");
+ else
+ printf("Proxy type : %d\n", proxy_type);
+
+ if (connection_profile_get_proxy_address(profile, address_family, &proxy) != CONNECTION_ERROR_NONE)
+ printf("Fail to get proxy!\n");
+ else {
+ printf("Proxy : %s\n", proxy);
+ g_free(proxy);
+ }
+}
+
int test_register_client(void)
{
int err = connection_create(&connection);
if (CONNECTION_ERROR_NONE == err) {
- connection_set_type_changed_cb(connection, test_state_changed_callback, NULL);
+ connection_set_type_changed_cb(connection, test_type_changed_callback, NULL);
connection_set_ip_address_changed_cb(connection, test_ip_changed_callback, NULL);
connection_set_proxy_address_changed_cb(connection, test_proxy_changed_callback, NULL);
} else {
- printf("Client registration failed %d\n", err);
+ printf("Client registration failed [%s]\n", test_print_error(err));
return -1;
}
printf("Client registration success\n");
return 1;
}
-
+
int test_deregister_client(void)
{
int rv = 0;
+ GSList *list;
+ connection_profile_h profile;
if (connection != NULL)
rv = connection_destroy(connection);
- else
+ else {
printf("Cannot deregister : Handle is NULL\n");
+ rv = CONNECTION_ERROR_INVALID_OPERATION;
+ }
- if (rv != CONNECTION_ERROR_NONE){
- printf("Client deregistration fail [%d]\n", rv);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Client deregistration fail [%s]\n", test_print_error(rv));
return -1;
}
+ if (state_cb_list) {
+ for (list = state_cb_list; list; list = list->next) {
+ profile = list->data;
+ connection_profile_destroy(profile);
+ }
+
+ g_slist_free(state_cb_list);
+ state_cb_list = NULL;
+ }
+
+ connection = NULL;
printf("Client deregistration success\n");
+
return 1;
}
@@ -205,11 +772,11 @@ int test_get_network_state(void)
rv = connection_get_type(connection, &net_state);
if (rv != CONNECTION_ERROR_NONE) {
- printf("Fail to get network state [%d]\n", rv);
+ printf("Fail to get network state [%s]\n", test_print_error(rv));
return -1;
}
- printf("Retval = %d network connection state [%d]\n", rv, net_state);
+ printf("Retval = [%s] network connection state [%d]\n", test_print_error(rv), net_state);
return 1;
}
@@ -222,11 +789,11 @@ int test_get_cellular_state(void)
rv = connection_get_cellular_state(connection, &cellular_state);
if (rv != CONNECTION_ERROR_NONE) {
- printf("Fail to get Cellular state [%d]\n", rv);
+ printf("Fail to get Cellular state [%s]\n", test_print_error(rv));
return -1;
}
- printf("Retval = %d Cellular state [%d]\n", rv, cellular_state);
+ printf("Retval = [%s] Cellular state [%d]\n", test_print_error(rv), cellular_state);
return 1;
}
@@ -239,11 +806,11 @@ int test_get_wifi_state(void)
rv = connection_get_wifi_state(connection, &wifi_state);
if (rv != CONNECTION_ERROR_NONE) {
- printf("Fail to get WiFi state [%d]\n", rv);
+ printf("Fail to get WiFi state [%s]\n", test_print_error(rv));
return -1;
}
- printf("Retval = %d WiFi state [%d]\n", rv, wifi_state);
+ printf("Retval = [%s] WiFi state [%d]\n", test_print_error(rv), wifi_state);
return 1;
}
@@ -268,31 +835,55 @@ int test_get_current_proxy(void)
int test_get_current_ip(void)
{
char *ip_addr = NULL;
+ int input;
+ bool rv;
- connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr);
+ rv = test_get_user_int("Input Address type to get"
+ "(1:IPV4, 2:IPV6):", &input);
- if (ip_addr == NULL) {
- printf("IP address does not exist\n");
+ if (rv == false) {
+ printf("Invalid input!!\n");
+ return -1;
+ }
+
+ switch (input) {
+ case 1:
+ connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr);
+ if (ip_addr == NULL) {
+ printf("IPv4 address does not exist\n");
+ return -1;
+ }
+ printf("IPv4 address : %s\n", ip_addr);
+ break;
+
+ case 2:
+ connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV6, &ip_addr);
+ if (ip_addr == NULL) {
+ printf("IPv6 address does not exist\n");
+ return -1;
+ }
+ printf("IPv6 address : %s\n", ip_addr);
+ break;
+ default:
+ printf("Wrong IP address family!!\n");
return -1;
}
- printf("IPv4 address : %s\n", ip_addr);
g_free(ip_addr);
-
- return 1;
+ return 1;
}
int test_get_call_statistics_info(void)
{
long long rv = 0;
- connection_get_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
+ connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
printf("last recv data size [%lld]\n", rv);
- connection_get_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
+ connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
printf("last sent data size [%lld]\n",rv );
- connection_get_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
+ connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
printf("total received data size [%lld]\n",rv );
- connection_get_statistics(CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
+ connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
printf("total sent data size [%lld]\n", rv);
return 1;
@@ -302,13 +893,13 @@ int test_get_wifi_call_statistics_info(void)
{
long long rv = 0;
- connection_get_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
+ connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv);
printf("WiFi last recv data size [%lld]\n", rv);
- connection_get_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
+ connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv);
printf("WiFi last sent data size [%lld]\n",rv );
- connection_get_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
+ connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv);
printf("WiFi total received data size [%lld]\n",rv );
- connection_get_statistics(CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
+ connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv);
printf("WiFi total sent data size [%lld]\n", rv);
return 1;
@@ -316,14 +907,24 @@ int test_get_wifi_call_statistics_info(void)
int test_get_profile_list(void)
{
+ if (test_get_user_selected_profile(NULL, false) == false)
+ return -1;
+
+ return 1;
+}
+
+int test_get_default_profile_list(void)
+{
int rv = 0;
- char *profile_name;
+ char *profile_name = NULL;
connection_profile_iterator_h profile_iter;
connection_profile_h profile_h;
+ connection_cellular_service_type_e service_type;
+ bool is_default = false;
- rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_REGISTERED, &profile_iter);
+ rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_DEFAULT, &profile_iter);
if (rv != CONNECTION_ERROR_NONE) {
- printf("Fail to get profile iterator [%d]\n", rv);
+ printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
return -1;
}
@@ -339,6 +940,18 @@ int test_get_profile_list(void)
}
printf("profile name : %s\n", profile_name);
g_free(profile_name);
+
+ if (connection_profile_get_cellular_service_type(profile_h, &service_type) != CONNECTION_ERROR_NONE) {
+ printf("Fail to get profile service type\n");
+ return -1;
+ }
+ printf("service type : %d\n", service_type);
+
+ if (connection_profile_is_cellular_default(profile_h, &is_default) != CONNECTION_ERROR_NONE) {
+ printf("Fail to get profile subscriber id\n");
+ return -1;
+ }
+ printf("Default : %d\n", is_default);
}
return 1;
@@ -347,13 +960,15 @@ int test_get_profile_list(void)
int test_get_connected_profile_list(void)
{
int rv = 0;
- char *profile_name;
+ char *profile_name = NULL;
connection_profile_iterator_h profile_iter;
connection_profile_h profile_h;
+ bool is_default = false;
+ connection_profile_type_e type;
rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_CONNECTED, &profile_iter);
if (rv != CONNECTION_ERROR_NONE) {
- printf("Fail to get profile iterator [%d]\n", rv);
+ printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
return -1;
}
@@ -367,8 +982,22 @@ int test_get_connected_profile_list(void)
printf("Fail to get profile name\n");
return -1;
}
- printf("profile name : %s\n", profile_name);
+ printf("profile name is %s\n", profile_name);
g_free(profile_name);
+
+ if (connection_profile_get_type(profile_h, &type) != CONNECTION_ERROR_NONE) {
+ printf("Fail to get profile type\n");
+ return -1;
+ }
+ printf("profile type is %d\n", type);
+
+ if (type == CONNECTION_PROFILE_TYPE_CELLULAR) {
+ if (connection_profile_is_cellular_default(profile_h, &is_default) != CONNECTION_ERROR_NONE) {
+ printf("Fail to get profile is default\n");
+ return -1;
+ }
+ printf("[%s]\n", is_default ? "default" : "not default");
+ }
}
return 1;
@@ -377,12 +1006,12 @@ int test_get_connected_profile_list(void)
int test_get_current_profile(void)
{
int rv = 0;
- char *profile_name;
+ char *profile_name = NULL;
connection_profile_h profile_h;
rv = connection_get_current_profile(connection, &profile_h);
if (rv != CONNECTION_ERROR_NONE) {
- printf("Fail to get profile iterator [%d]\n", rv);
+ printf("Fail to get profile iterator [%s]\n", test_print_error(rv));
return -1;
}
@@ -401,31 +1030,35 @@ int test_get_current_profile(void)
int test_open_profile(void)
{
connection_profile_h profile;
- if (test_get_user_selected_profile(&profile) == false)
- return -1;
- if (connection_open_profile(connection, profile) != CONNECTION_ERROR_NONE) {
- printf("Connection open Failed!!\n");
+ printf("\n** Choose a profile to open. **\n");
+
+ if (test_get_user_selected_profile(&profile, true) == false)
return -1;
- }
- if (connection_profile_set_state_changed_cb(profile,
- test_profile_state_callback, NULL) != CONNECTION_ERROR_NONE) {
- printf("Set profile callback Failed!!\n");
+ if (connection_open_profile(connection, profile, test_connection_opened_callback, NULL) != CONNECTION_ERROR_NONE) {
+ printf("Connection open Failed!!\n");
return -1;
}
return 1;
}
-int test_open_cellular_service_type(void)
+int test_get_default_cellular_service_type(void)
{
int input;
int rv;
int service_type;
connection_profile_h profile;
- printf("\nInput profile type(1:Internet, 2:MMS, 3:WAP, 4:Prepaid internet, 5:Prepaid MMS : \n");
- rv = scanf("%d", &input);
+ char *profile_name = NULL;
+
+ rv = test_get_user_int("Input profile type to get"
+ "(1:Internet, 2:MMS, 3:Prepaid internet, 4:Prepaid MMS, 5:Tethering):", &input);
+
+ if (rv == false) {
+ printf("Invalid input!!\n");
+ return -1;
+ }
switch (input) {
case 1:
@@ -435,43 +1068,80 @@ int test_open_cellular_service_type(void)
service_type = CONNECTION_CELLULAR_SERVICE_TYPE_MMS;
break;
case 3:
- service_type = CONNECTION_CELLULAR_SERVICE_TYPE_WAP;
+ service_type = CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET;
break;
case 4:
- service_type = CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET;
+ service_type = CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS;
break;
case 5:
- service_type = CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS;
+ service_type = CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING;
break;
default:
printf("Wrong number!!\n");
return -1;
}
- if (connection_open_cellular_service_type(connection, service_type, &profile) != CONNECTION_ERROR_NONE) {
- printf("Connection open Failed!!\n");
+ if (connection_get_default_cellular_service_profile(connection, service_type, &profile) != CONNECTION_ERROR_NONE)
return -1;
- }
- if (connection_profile_set_state_changed_cb(profile,
- test_profile_state_callback, NULL) != CONNECTION_ERROR_NONE) {
- printf("Set profile callback Failed!!\n");
+ if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
+ printf("Fail to get profile name\n");
connection_profile_destroy(profile);
return -1;
}
+ printf("Default profile name : %s\n", profile_name);
+ g_free(profile_name);
connection_profile_destroy(profile);
return 1;
}
+int test_set_default_cellular_service_type(void)
+{
+ connection_profile_h profile;
+ connection_cellular_service_type_e type;
+ int input, rv;
+
+ rv = test_get_user_int("Input API type (1:sync, 2:async)", &input);
+
+ if (rv == false || (input != 1 && input != 2)) {
+ printf("Invalid input!!\n");
+ return -1;
+ }
+
+ printf("\n** Choose a profile to set default service(internet or prepaid internet type only). **\n");
+
+ if (test_get_user_selected_profile(&profile, true) == false)
+ return -1;
+
+ if (connection_profile_get_cellular_service_type(profile, &type) != CONNECTION_ERROR_NONE) {
+ printf("Fail to get cellular service type\n");
+ return -1;
+ }
+
+ if (input == 1) {
+ if (connection_set_default_cellular_service_profile(connection, type, profile) != CONNECTION_ERROR_NONE)
+ return -1;
+ } else {
+ if (connection_set_default_cellular_service_profile_async(connection,
+ type, profile, test_connection_set_default_callback, NULL) != CONNECTION_ERROR_NONE)
+ return -1;
+ }
+
+ return 1;
+}
+
int test_close_profile(void)
{
connection_profile_h profile;
- if (test_get_user_selected_profile(&profile) == false)
+
+ printf("\n** Choose a profile to close. **\n");
+
+ if (test_get_user_selected_profile(&profile, true) == false)
return -1;
- if (connection_close_profile(connection, profile) != CONNECTION_ERROR_NONE) {
+ if (connection_close_profile(connection, profile, test_connection_closed_callback, NULL) != CONNECTION_ERROR_NONE) {
printf("Connection close Failed!!\n");
return -1;
}
@@ -479,9 +1149,484 @@ int test_close_profile(void)
return 1;
}
+int test_add_profile(void)
+{
+ int rv = 0;
+ connection_profile_h profile;
+ char input_str[100] = {0,};
+
+ if (test_get_user_string("Input Keyword - (Enter for skip) :", input_str, 100) == false)
+ return -1;
+
+ g_strstrip(input_str);
+ rv = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, input_str, &profile);
+ if (rv != CONNECTION_ERROR_NONE)
+ RETURN_FAIL_DESTROY(profile);
+
+ if (test_update_cellular_info(profile) == -1)
+ RETURN_FAIL_DESTROY(profile);
+
+ rv = connection_add_profile(connection, profile);
+ if (rv != CONNECTION_ERROR_NONE)
+ RETURN_FAIL_DESTROY(profile);
+
+ connection_profile_destroy(profile);
+ return 1;
+}
+
+int test_remove_profile(void)
+{
+ connection_profile_h profile;
+
+ printf("\n** Choose a profile to remove. **\n");
+ if (test_get_user_selected_profile(&profile, true) == false)
+ return -1;
+
+ if (connection_remove_profile(connection, profile) != CONNECTION_ERROR_NONE) {
+ printf("Remove profile Failed!!\n");
+ return -1;
+ }
+
+ return 1;
+}
+
+int test_update_profile(void)
+{
+ int rv = 0;
+
+ connection_profile_type_e prof_type;
+ connection_profile_h profile;
+
+ printf("\n** Choose a profile to update. **\n");
+ if (test_get_user_selected_profile(&profile, true) == false)
+ return -1;
+
+ if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
+ return -1;
+
+ switch (prof_type) {
+ case CONNECTION_PROFILE_TYPE_CELLULAR:
+ if (test_update_cellular_info(profile) == -1)
+ return -1;
+
+ break;
+ case CONNECTION_PROFILE_TYPE_WIFI:
+ if (test_update_wifi_info(profile) == -1)
+ return -1;
+
+ if (test_update_network_info(profile) == -1)
+ return -1;
+
+ break;
+ case CONNECTION_PROFILE_TYPE_ETHERNET:
+ if (test_update_network_info(profile) == -1)
+ return -1;
+ break;
+
+ case CONNECTION_PROFILE_TYPE_BT:
+ printf("Not supported!\n");
+ /* fall through */
+ default:
+ return -1;
+ }
+
+ rv = connection_update_profile(connection, profile);
+ if (rv != CONNECTION_ERROR_NONE)
+ return -1;
+
+ return 1;
+}
+
+int test_get_profile_info(void)
+{
+ connection_profile_type_e prof_type;
+ connection_profile_state_e profile_state;
+ connection_profile_h profile;
+ char *profile_name = NULL;
+ int address_family = 0;
+
+ printf("\n** Choose a profile to print. **\n");
+ if (test_get_user_selected_profile(&profile, true) == false)
+ return -1;
+
+ if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
+ printf("Fail to get profile name\n");
+ return -1;
+ } else {
+ printf("Profile Name : %s\n", profile_name);
+ g_free(profile_name);
+ }
+
+ if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) {
+ printf("Fail to get profile state\n");
+ return -1;
+ } else
+ printf("Profile State : %s\n", test_print_state(profile_state));
+
+ if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
+ return -1;
+
+ test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
+
+ switch (prof_type) {
+ case CONNECTION_PROFILE_TYPE_CELLULAR:
+ printf("Profile Type : Cellular\n");
+ test_print_cellular_info(profile);
+ break;
+ case CONNECTION_PROFILE_TYPE_WIFI:
+ printf("Profile Type : Wi-Fi\n");
+ test_print_wifi_info(profile);
+ break;
+ case CONNECTION_PROFILE_TYPE_ETHERNET:
+ printf("Profile Type : Ethernet\n");
+ break;
+ case CONNECTION_PROFILE_TYPE_BT:
+ printf("Profile Type : Bluetooth\n");
+ break;
+ default:
+ return -1;
+ }
+
+ test_print_network_info(profile, address_family);
+
+ return 1;
+}
+
+int test_refresh_profile_info(void)
+{
+ connection_profile_type_e prof_type;
+ connection_profile_state_e profile_state;
+ connection_profile_h profile;
+ char *profile_name = NULL;
+ int address_family = 0;
+
+ printf("\n** Choose a profile to refresh. **\n");
+ if (test_get_user_selected_profile(&profile, true) == false)
+ return -1;
+
+ if (connection_profile_refresh(profile) != CONNECTION_ERROR_NONE)
+ return -1;
+
+ if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
+ printf("Fail to get profile name\n");
+ return -1;
+ } else {
+ printf("Profile Name : %s\n", profile_name);
+ g_free(profile_name);
+ }
+
+ if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) {
+ printf("Fail to get profile state\n");
+ return -1;
+ } else
+ printf("Profile State : %s\n", test_print_state(profile_state));
+
+
+ if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE)
+ return -1;
+
+ test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family);
+
+ switch (prof_type) {
+ case CONNECTION_PROFILE_TYPE_CELLULAR:
+ printf("Profile Type : Cellular\n");
+ test_print_cellular_info(profile);
+ break;
+ case CONNECTION_PROFILE_TYPE_WIFI:
+ printf("Profile Type : Wi-Fi\n");
+ test_print_wifi_info(profile);
+ break;
+ case CONNECTION_PROFILE_TYPE_ETHERNET:
+ printf("Profile Type : Ethernet\n");
+ break;
+ case CONNECTION_PROFILE_TYPE_BT:
+ printf("Profile Type : Bluetooth\n");
+ break;
+ default:
+ return -1;
+ }
+
+ test_print_network_info(profile, address_family);
+
+ return 1;
+}
+
+int test_set_state_changed_callback()
+{
+ connection_profile_h profile;
+ connection_profile_h profile_clone;
+
+ printf("\n** Choose a profile to set callback. **\n");
+ if (test_get_user_selected_profile(&profile, true) == false)
+ return -1;
+
+ if (connection_profile_clone(&profile_clone, profile) != CONNECTION_ERROR_NONE)
+ return -1;
+
+ if (connection_profile_set_state_changed_cb(profile,
+ test_profile_state_callback, profile_clone) != CONNECTION_ERROR_NONE) {
+ connection_profile_destroy(profile_clone);
+ return -1;
+ }
+
+ state_cb_list = g_slist_append(state_cb_list, profile_clone);
+
+ return 1;
+}
+
+int test_unset_state_changed_callback()
+{
+ connection_profile_h profile;
+ GSList *list;
+ char *profile_name = NULL;
+ int count = 0;
+ int input = 0;
+
+ printf("\n** Choose a profile to unset callback. **\n");
+ for (list = state_cb_list; list; list = list->next) {
+ profile = list->data;
+ if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) {
+ printf("Fail to get profile name!\n");
+ return -1;
+ } else {
+ printf("%d. %s\n", count, profile_name);
+ g_free(profile_name);
+ }
+
+ count++;
+ }
+
+ if (test_get_user_int("Input profile number(Enter for cancel) :", &input) == false ||
+ input >= count ||
+ input < 0) {
+ printf("Wrong number!!\n");
+ return -1;
+ }
+
+ count = 0;
+ for (list = state_cb_list; list; list = list->next) {
+ if (count == input) {
+ profile = list->data;
+ goto unset;
+ }
+
+ count++;
+ }
+
+ return -1;
+
+unset:
+ if (connection_profile_unset_state_changed_cb(profile) != CONNECTION_ERROR_NONE)
+ return -1;
+
+ state_cb_list = g_slist_remove(state_cb_list, profile);
+ connection_profile_destroy(profile);
+
+ return 1;
+}
+
+int test_reset_call_statistics_info(void)
+{
+ int ret = CONNECTION_ERROR_NONE;
+
+ ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
+ printf("reset last recv data size [%d]\n", ret);
+ ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
+ printf("last sent data size [%d]\n", ret);
+ ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
+ printf("total received data size [%d]\n", ret);
+ ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
+ printf("total sent data size [%d]\n", ret);
+
+ return 1;
+}
+
+int test_reset_wifi_call_statistics_info(void)
+{
+ int ret = CONNECTION_ERROR_NONE;
+
+ ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA);
+ printf("WiFi last sent data size [%d]\n", ret);
+ ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA);
+ printf("WiFi last recv data size [%d]\n", ret);
+ ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA);
+ printf("WiFi total sent data size [%d]\n", ret);
+ ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA);
+ printf("WiFi total received data size [%d]\n", ret);
+
+ return 1;
+}
+
+int test_add_route(void)
+{
+ int rv = 0;
+ char ip_addr[100] = {0};
+ char if_name[40] = {0};
+
+ if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
+ return -1;
+
+ g_strstrip(ip_addr);
+ g_strstrip(if_name);
+ rv = connection_add_route(connection, if_name, ip_addr);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to get add new route [%d]\n", rv);
+ return -1;
+ }
+ printf("Add Route successfully\n");
+
+ return 1;
+}
+
+int test_remove_route(void)
+{
+ int rv = 0;
+ char ip_addr[100] = {0};
+ char if_name[40] = {0};
+
+ if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
+ return -1;
+
+ g_strstrip(ip_addr);
+ g_strstrip(if_name);
+ rv = connection_remove_route(connection, if_name, ip_addr);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to remove the route [%s]\n", test_print_error(rv));
+ return -1;
+ }
+ printf("Remove Route successfully\n");
+
+ return 1;
+}
+
+int test_add_route_ipv6(void)
+{
+ int rv = 0;
+ char ip_addr[100] = {0};
+ char gateway[100] = {0};
+ char if_name[40] = {0};
+
+ if (test_get_user_string("Input IPv6 - (Enter for skip) :", ip_addr, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
+ return -1;
+
+ g_strstrip(ip_addr);
+ g_strstrip(gateway);
+ g_strstrip(if_name);
+ rv = connection_add_route_ipv6(connection, if_name, ip_addr, gateway);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to get add new route [%d]\n", rv);
+ return -1;
+ }
+ printf("Add Route successfully\n");
+
+ return 1;
+}
+
+int test_remove_route_ipv6(void)
+{
+ int rv = 0;
+ char ip_addr[100] = {0};
+ char gateway[100] = {0};
+ char if_name[40] = {0};
+
+ if (test_get_user_string("Input IPv6 - (Enter for skip) :", ip_addr, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Gateway - (Enter for skip) :", gateway, 100) == false)
+ return -1;
+
+ if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false)
+ return -1;
+
+ g_strstrip(ip_addr);
+ g_strstrip(gateway);
+ g_strstrip(if_name);
+ rv = connection_remove_route_ipv6(connection, if_name, ip_addr, gateway);
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to remove the route [%d]\n", rv);
+ return -1;
+ }
+ printf("Remove Route successfully\n");
+
+ return 1;
+}
+
+int test_get_bt_state(void)
+{
+ int rv = 0;
+ connection_bt_state_e bt_state;
+
+ rv = connection_get_bt_state(connection, &bt_state);
+
+ if (rv != CONNECTION_ERROR_NONE) {
+ printf("Fail to get Bluetooth state [%s]\n", test_print_error(rv));
+ return -1;
+ }
+
+ printf("Retval = [%s], Bluetooth state [%d]\n", test_print_error(rv), bt_state);
+
+ return 1;
+}
+
+int test_get_profile_id(void)
+{
+ connection_profile_h profile;
+ char *profile_id;
+
+ printf("\n** Choose a profile to see profile id. **\n");
+ if (test_get_user_selected_profile(&profile, true) == false)
+ return -1;
+
+ if (connection_profile_get_id(profile, &profile_id) != CONNECTION_ERROR_NONE) {
+ printf("Fail to get profile name\n");
+ return -1;
+ } else {
+ printf("Profile id : %s\n", profile_id);
+ g_free(profile_id);
+ }
+
+ return 1;
+}
+
+int test_reset_profile(void)
+{
+ int type, sim_id, rv;
+
+ rv = test_get_user_int("Input reset type (0:default profile reset, 1:delete profile reset)", &type);
+
+ if (rv == false || (type != 0 && type != 1)) {
+ printf("Invalid input!!\n");
+ return -1;
+ }
+
+ rv = test_get_user_int("Input SIM id to reset (0:SIM1, 1:SIM2)", &sim_id);
+
+ if (rv == false || (sim_id != 0 && sim_id != 1)) {
+ printf("Invalid input!!\n");
+ return -1;
+ }
+
+ if (connection_reset_profile(connection, type, sim_id, test_connection_reset_profile_callback, NULL) != CONNECTION_ERROR_NONE) {
+ return -1;
+ }
+
+ return 1;
+}
+
int main(int argc, char **argv)
{
-
GMainLoop *mainloop;
mainloop = g_main_loop_new (NULL, FALSE);
@@ -499,23 +1644,28 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
{
int rv = 0;
char a[100];
-
+
memset(a, '\0', 100);
printf("Event received from stdin\n");
-
+
rv = read(0, a, 100);
-
- if (rv < 0 || a[0] == '0') exit(1);
- if (*a == '\n' || *a == '\r'){
+ if (rv < 0 || a[0] == '0') {
+ if (connection != NULL)
+ test_deregister_client();
+
+ exit(1);
+ }
+
+ if (*a == '\n' || *a == '\r') {
printf("\n\n Network Connection API Test App\n\n");
printf("Options..\n");
printf("1 - Create Handle and set callbacks\n");
printf("2 - Destroy Handle(unset callbacks automatically)\n");
- printf("3 - Get network state\n");
+ printf("3 - Get network state\n");
printf("4 - Get cellular state (please insert SIM Card)\n");
printf("5 - Get wifi state (please turn on WiFi)\n");
- printf("6 - Get current proxy address \n");
+ printf("6 - Get current proxy address \n");
printf("7 - Get current Ip address\n");
printf("8 - Get cellular data call statistics\n");
printf("9 - Get WiFi data call statistics\n");
@@ -523,59 +1673,136 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
printf("b - Get Connected Profile list\n");
printf("c - Get Current profile\n");
printf("d - Open connection with profile\n");
- printf("e - Open cellular service type\n");
- printf("f - Close connection with profile\n");
- printf("0 - Exit \n");
-
- printf("ENTER - Show options menu.......\n");
+ printf("e - Get default cellular service by type\n");
+ printf("f - Set default cellular service by type\n");
+ printf("g - Close connection with profile\n");
+ printf("h - Add profile(Cellular and Wifi only)\n");
+ printf("i - Remove profile(Cellular:delete, WiFi:forgot)\n");
+ printf("j - Update profile\n");
+ printf("k - Get profile info\n");
+ printf("l - Refresh profile info\n");
+ printf("m - Set state changed callback\n");
+ printf("n - Unset state changed callback\n");
+ printf("o - Reset cellular data call statistics\n");
+ printf("p - Reset WiFi data call statistics\n");
+ printf("q - Add new route\n");
+ printf("r - Remove a route\n");
+ printf("s - Get Bluetooth state\n");
+ printf("t - Get profile id\n");
+ printf("u - Reset profile\n");
+ printf("v - Get all cellular default profiles\n");
+ printf("B - Add IPv6 new route\n");
+ printf("C - Remove IPv6 route\n");
+ printf("0 - Exit \n");
+ printf("ENTER - Show options menu.......\n");
}
switch (a[0]) {
- case '1': {
- rv = test_register_client();
- } break;
- case '2': {
- rv = test_deregister_client();
- } break;
- case '3': {
- rv = test_get_network_state();
- } break;
- case '4': {
- rv = test_get_cellular_state();
- } break;
- case '5': {
- rv = test_get_wifi_state();
- } break;
- case '6': {
- rv = test_get_current_proxy();
- } break;
- case '7': {
- rv = test_get_current_ip();
- } break;
- case '8': {
- rv = test_get_call_statistics_info();
- } break;
- case '9': {
- rv = test_get_wifi_call_statistics_info();
- } break;
- case 'a': {
- rv = test_get_profile_list();
- } break;
- case 'b': {
- rv = test_get_connected_profile_list();
- } break;
- case 'c': {
- rv = test_get_current_profile();
- } break;
- case 'd': {
- rv = test_open_profile();
- } break;
- case 'e': {
- rv = test_open_cellular_service_type();
- } break;
- case 'f': {
- rv = test_close_profile();
- } break;
+ case '1':
+ rv = test_register_client();
+ break;
+ case '2':
+ rv = test_deregister_client();
+ break;
+ case '3':
+ rv = test_get_network_state();
+ break;
+ case '4':
+ rv = test_get_cellular_state();
+ break;
+ case '5':
+ rv = test_get_wifi_state();
+ break;
+ case '6':
+ rv = test_get_current_proxy();
+ break;
+ case '7':
+ rv = test_get_current_ip();
+ break;
+ case '8':
+ rv = test_get_call_statistics_info();
+ break;
+ case '9':
+ rv = test_get_wifi_call_statistics_info();
+ break;
+ case 'a':
+ rv = test_get_profile_list();
+ break;
+ case 'b':
+ rv = test_get_connected_profile_list();
+ break;
+ case 'c':
+ rv = test_get_current_profile();
+ break;
+ case 'd':
+ rv = test_open_profile();
+ break;
+ case 'e':
+ rv = test_get_default_cellular_service_type();
+ break;
+ case 'f':
+ rv = test_set_default_cellular_service_type();
+ break;
+ case 'g':
+ rv = test_close_profile();
+ break;
+ case 'h':
+ rv = test_add_profile();
+ break;
+ case 'i':
+ rv = test_remove_profile();
+ break;
+ case 'j':
+ rv = test_update_profile();
+ break;
+ case 'k':
+ rv = test_get_profile_info();
+ break;
+ case 'l':
+ rv = test_refresh_profile_info();
+ break;
+ case 'm':
+ rv = test_set_state_changed_callback();
+ break;
+ case 'n':
+ rv = test_unset_state_changed_callback();
+ break;
+ case 'o':
+ rv = test_reset_call_statistics_info();
+ break;
+ case 'p':
+ rv = test_reset_wifi_call_statistics_info();
+ break;
+ case 'q':
+ rv = test_add_route();
+ break;
+ case 'r':
+ rv = test_remove_route();
+ break;
+ case 's':
+ rv = test_get_bt_state();
+ break;
+ case 't':
+ rv = test_get_profile_id();
+ break;
+ case 'u':
+ rv = test_reset_profile();
+ break;
+ case 'v':
+ rv = test_get_default_profile_list();
+ break;
+ case 'B':
+ rv = test_add_route_ipv6();
+ break;
+ case 'C':
+ rv = test_remove_route_ipv6();
+ break;
}
+
+ if (rv == 1)
+ printf("Operation succeeded!\n");
+ else
+ printf("Operation failed!\n");
+
return TRUE;
}