From d03b1194e0939654a7c4bfca23fe26abe1ec7cf9 Mon Sep 17 00:00:00 2001 From: hyunuktak Date: Fri, 7 Aug 2015 17:06:09 +0900 Subject: [PATCH] Base Code merged to SPIN 2.4 Signed-off-by: hyunuktak Change-Id: I3d308cfc44f6809efef8e02a0c299971ae30eb60 --- AUTHORS | 2 - CMakeLists.txt | 24 +- LICENSE.APLv2 => LICENSE | 2 + NOTICE | 2 +- capi-network-connection.manifest | 8 + capi-network-connection.pc.in | 2 +- debian/capi-network-connection-dev.install | 4 - debian/capi-network-connection-dev.postinst | 1 - debian/capi-network-connection.install | 1 - debian/capi-network-connection.postinst | 1 - debian/changelog | 514 --------------------- debian/compat | 1 - debian/control | 21 - debian/rules | 67 --- doc/net_connection_doc.h | 10 +- include/connection_profile.h | 136 +++--- include/net_connection.h | 101 +++-- include/net_connection_private.h | 9 +- packaging/capi-network-connection.changes | 6 - packaging/capi-network-connection.manifest | 5 - packaging/capi-network-connection.spec | 64 ++- src/connection.c | 667 ++++++++++++++++++---------- src/connection_profile.c | 183 ++++---- src/internal.c | 35 -- src/libnetwork.c | 449 ++++++++++++++----- test/CMakeLists.txt | 6 +- test/connection_test.c | 78 ++-- 27 files changed, 1099 insertions(+), 1300 deletions(-) delete mode 100644 AUTHORS rename LICENSE.APLv2 => LICENSE (99%) create mode 100644 capi-network-connection.manifest delete mode 100644 debian/capi-network-connection-dev.install delete mode 100644 debian/capi-network-connection-dev.postinst delete mode 100644 debian/capi-network-connection.install delete mode 100644 debian/capi-network-connection.postinst delete mode 100644 debian/changelog delete mode 100644 debian/compat delete mode 100644 debian/control delete mode 100755 debian/rules mode change 100644 => 100755 include/net_connection.h mode change 100644 => 100755 include/net_connection_private.h delete mode 100644 packaging/capi-network-connection.changes delete mode 100644 packaging/capi-network-connection.manifest mode change 100644 => 100755 src/connection.c mode change 100644 => 100755 src/connection_profile.c delete mode 100644 src/internal.c diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 5c2063d..0000000 --- a/AUTHORS +++ /dev/null @@ -1,2 +0,0 @@ -Jeik Jaehyun Kim -ByungWoo Lee diff --git a/CMakeLists.txt b/CMakeLists.txt index 8364e95..2c6b06c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,15 +3,31 @@ SET(fw_name "capi-network-connection") PROJECT(${fw_name}) -SET(CMAKE_INSTALL_PREFIX /usr) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(LIB ${LIB_PATH}) +SET(LIBDIR ${PREFIX}/${LIB_PATH}) + SET(INC_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}) 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) +IF(TIZEN_TV) + ADD_DEFINITIONS(-DTIZEN_TV) +ENDIF(TIZEN_TV) + + INCLUDE(FindPkgConfig) pkg_check_modules(${fw_name} REQUIRED ${dependents}) FOREACH(flag ${${fw_name}_CFLAGS}) @@ -28,7 +44,7 @@ ENDIF("${ARCH}" STREQUAL "arm") ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") ADD_DEFINITIONS("-DTIZEN_DEBUG") -SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIBDIR}") aux_source_directory(src SOURCES) ADD_LIBRARY(${fw_name} SHARED ${SOURCES}) @@ -42,7 +58,7 @@ SET_TARGET_PROPERTIES(${fw_name} CLEAN_DIRECT_OUTPUT 1 ) -INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(TARGETS ${fw_name} DESTINATION ${LIB}) INSTALL( DIRECTORY ${INC_DIR}/ DESTINATION include/network FILES_MATCHING @@ -59,7 +75,7 @@ CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc @ONLY ) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB}/pkgconfig) ADD_SUBDIRECTORY(test) diff --git a/LICENSE.APLv2 b/LICENSE similarity index 99% rename from LICENSE.APLv2 rename to LICENSE index d645695..56ea2f0 100644 --- a/LICENSE.APLv2 +++ b/LICENSE @@ -1,3 +1,4 @@ +Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved. Apache License Version 2.0, January 2004 @@ -200,3 +201,4 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + diff --git a/NOTICE b/NOTICE index 0e0f016..ccdad52 100644 --- a/NOTICE +++ b/NOTICE @@ -1,3 +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.APLv2 file for Apache License terms and conditions. +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 @@ + + + + + + + + diff --git a/capi-network-connection.pc.in b/capi-network-connection.pc.in index 7f8ee09..ee6db75 100644 --- a/capi-network-connection.pc.in +++ b/capi-network-connection.pc.in @@ -2,7 +2,7 @@ prefix=@PREFIX@ exec_prefix=/usr -libdir=@LIB_INSTALL_DIR@ +libdir=/usr/lib includedir=/usr/include/network Name: @PC_NAME@ 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 3d47b87..0000000 --- a/debian/changelog +++ /dev/null @@ -1,514 +0,0 @@ -capi-network-connection (0.1.3-16) unstable; urgency=low - - * Eliminate user privacy information - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-16 - - -- Taesub Kim Fri, 29 Nov 2013 11:29:46 +0900 - -capi-network-connection (0.1.3-15) unstable; urgency=low - - * Fix memory leak - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-15 - - -- Taesub Kim Fri, 29 Nov 2013 10:52:46 +0900 - -capi-network-connection (0.1.3-14) unstable; urgency=low - - * Set CFLAGS fvisibility hidden - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-14 - - -- Taesub Kim Fri, 29 Nov 2013 10:36:46 +0900 - -capi-network-connection (0.1.3-12) unstable; urgency=low - - * Check return value of read() - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-12 - - -- JaeHyun Kim Thu, 24 Jan 2013 20:14:09 +0900 - -capi-network-connection (0.1.3-11) unstable; urgency=low - - * Revise connection_profile_is_wifi_passphrase_required() to fit connman 1.3 - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-11 - - -- JaeHyun Kim Wed, 16 Jan 2013 18:44:18 +0900 - -capi-network-connection (0.1.3-10) unstable; urgency=low - - * Revise connection_profile_get_proxy_address() to support ethernet proxy - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-10 - - -- JaeHyun Kim Tue, 15 Jan 2013 20:34:31 +0900 - -capi-network-connection (0.1.3-9) unstable; urgency=low - - * Support additional vconf keys for ethernet/bluetooth - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-9 - - -- JaeHyun Kim Tue, 15 Jan 2013 19:15:37 +0900 - -capi-network-connection (0.1.3-8) unstable; urgency=low - - * Use libnet-client API instead of vconf value to get Wi-Fi state in connection_get_wifi_state() API - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-8 - - -- JaeHyun Kim Mon, 14 Jan 2013 23:23:03 +0900 - -capi-network-connection (0.1.3-7) unstable; urgency=low - - * Revise connection_profile_get_cellular_network_type() because connman doesn't provide this information anymore - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-7 - - -- JaeHyun Kim Fri, 04 Jan 2013 16:05:28 +0900 - -capi-network-connection (0.1.3-6) unstable; urgency=low - - * Add connection_profile_get_id() - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-6 - - -- JaeHyun Kim Thu, 03 Jan 2013 20:36:29 +0900 - -capi-network-connection (0.1.3-5) unstable; urgency=low - - * In case of setting IP address, Gateway, Subnet and proxy, it is allowed that a value is set to NULL. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-5 - - -- JaeHyun Kim Wed, 02 Jan 2013 11:33:58 +0900 - -capi-network-connection (0.1.3-4) unstable; urgency=low - - * Checking return value and strict nul-terminated buffer - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-4 - - -- Danny Jeongseok Seo Tue, 13 Nov 2012 11:45:41 +0900 - -capi-network-connection (0.1.3-2) unstable; urgency=low - - * Revise connection_get_cellular_state() to support connected state - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-2 - - -- JaeHyun Kim Fri, 02 Nov 2012 20:23:04 +0900 - -capi-network-connection (0.1.3-1) unstable; urgency=low - - * Add bluetooth support - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-1 - - -- JaeHyun Kim Thu, 25 Oct 2012 14:30:14 +0900 - -capi-network-connection (0.1.2-4) unstable; urgency=low - - * Update UTC - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.2-4 - - -- JaeHyun Kim Mon, 15 Oct 2012 21:10:09 +0900 - -capi-network-connection (0.1.2-3) unstable; urgency=low - - * Add connection_add_route() - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.2-3 - - -- JaeHyun Kim Fri, 12 Oct 2012 20:13:52 +0900 - -capi-network-connection (0.1.2-2) unstable; urgency=low - - * Install license - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.2-2 - - -- Danny Jeongseok Seo Thu, 11 Oct 2012 18:09:07 +0900 - -capi-network-connection (0.1.2-1) unstable; urgency=low - - * Extend some APIs to fit requirements from setting and tethering - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.2-1 - - -- JaeHyun Kim Thu, 27 Sep 2012 16:30:42 +0900 - -capi-network-connection (0.1.1-12) unstable; urgency=low - - * update manifest - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.1-12 - - -- Danny Jeongseok Seo Fri, 21 Sep 2012 15:38:33 +0900 - -capi-network-connection (0.1.1-11) unstable; urgency=low - - * Use static mutex initializer to avoid runtime initialization tests and overhead - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.1-11 - - -- JaeHyun Kim Fri, 07 Sep 2012 11:21:04 +0900 - -capi-network-connection (0.1.1-10) unstable; urgency=low - - * Update UTC - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.1-10 - - -- JaeHyun Kim Tue, 04 Sep 2012 16:52:06 +0900 - -capi-network-connection (0.1.1-9) unstable; urgency=low - - * Remove deprecated APIs - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.1-9 - - -- JaeHyun Kim 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: framework/api/connection - * Tag: capi-network-connection_0.1.1-8 - - -- JaeHyun Kim 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: framework/api/connection - * Tag: capi-network-connection_0.1.1-7 - - -- JaeHyun Kim 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: framework/api/connection - * Tag: capi-network-connection_0.1.1-6 - - -- JaeHyun Kim Wed, 27 Jun 2012 19:06:32 +0900 - -capi-network-connection (0.1.1-5) unstable; urgency=low - - * Update TC - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.1-5 - - -- JaeHyun Kim 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: framework/api/connection - * Tag: capi-network-connection_0.1.1-4 - - -- JaeHyun Kim Tue, 12 Jun 2012 17:17:00 +0900 - -capi-network-connection (0.1.1-3) unstable; urgency=low - - * Implementation of connection_reset_statistics() - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.1-3 - - -- JaeHyun Kim Tue, 12 Jun 2012 16:34:52 +0900 - -capi-network-connection (0.1.1-2) unstable; urgency=low - - * Implementation of extened APIs again - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.1-2 - - -- JaeHyun Kim 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: framework/api/connection - * Tag: capi-network-connection_0.1.1-1 - - -- JaeHyun Kim Wed, 23 May 2012 20:56:07 +0900 - -capi-network-connection (0.1.1-0) unstable; urgency=low - - * Implementation of extened APIs - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.1-0 - - -- JaeHyun Kim 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: framework/api/connection - * Tag: capi-network-connection_0.1.0-23 - - -- JaeHyun Kim Mon, 16 Apr 2012 12:02:47 +0900 - -capi-network-connection (0.1.0-22) unstable; urgency=low - - * Fix connection destroy bug - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-22 - - -- JaeHyun Kim 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: framework/api/connection - * Tag: capi-network-connection_0.1.0-21 - - -- JaeHyun Kim Fri, 30 Mar 2012 18:15:20 +0900 - -capi-network-connection (0.1.0-20) unstable; urgency=low - - * Update DTS code - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-20 - - -- JaeHyun Kim Tue, 20 Mar 2012 16:08:10 +0900 - -capi-network-connection (0.1.0-19) unstable; urgency=low - - * Revise spec for OBS - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-19 - - -- Danny Jeongseok Seo 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: framework/api/connection - * Tag: capi-network-connection_0.1.0-18 - - -- JaeHyun Kim 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: framework/api/connection - * Tag: capi-network-connection_0.1.0-17 - - -- ByungWoo Lee Mon, 20 Feb 2012 17:55:42 +0900 - -capi-network-connection (0.1.0-16) unstable; urgency=low - - * Add versioning of library - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-16 - - -- ByungWoo Lee Tue, 14 Feb 2012 17:23:56 +0900 - -capi-network-connection (0.1.0-15) unstable; urgency=low - - * Fix bugs and related DTS - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-15 - - -- JaeHyun Kim Tue, 07 Feb 2012 19:09:07 +0900 - -capi-network-connection (0.1.0-14) unstable; urgency=low - - * Update DTS - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-14 - - -- ByungWoo Lee Fri, 27 Jan 2012 18:18:29 +0900 - -capi-network-connection (0.1.0-13) unstable; urgency=low - - * License and Boilerplate update. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-13 - - -- Sanjeev BA Tue, 06 Dec 2011 18:48:48 +0900 - -capi-network-connection (0.1.0-12) unstable; urgency=low - - * Bump up version. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-12 - - -- Sanjeev BA Thu, 01 Dec 2011 19:40:16 +0900 - -capi-network-connection (0.1.0-11) unstable; urgency=low - - * Add data connection statistics. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-11 - - -- Sanjeev BA Thu, 01 Dec 2011 19:18:24 +0900 - -capi-network-connection (0.1.0-10) unstable; urgency=low - - * Cleanup of vconf notifications. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-10 - - -- Sanjeev BA Thu, 01 Dec 2011 11:08:59 +0900 - -capi-network-connection (0.1.0-9) unstable; urgency=low - - * Renaming for tizen. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-9 - - -- Sanjeev BA Wed, 30 Nov 2011 15:10:59 +0900 - -capi-network-connection (0.1.0-8) unstable; urgency=low - - * Renaming for tizen. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-8 - - -- Sanjeev BA Wed, 23 Nov 2011 15:07:23 +0900 - -capi-network-connection (0.1.0-7) unstable; urgency=low - - * Correct status updates. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-7 - - -- Sanjeev BA Wed, 23 Nov 2011 13:46:23 +0900 - -capi-network-connection (0.1.0-6) unstable; urgency=low - - * Correct status updates. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-6 - - -- Sanjeev BA Thu, 17 Nov 2011 15:10:55 +0900 - -capi-network-connection (0.1.0-5) unstable; urgency=low - - * Correct status updates. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-5 - - -- Sanjeev BA Fri, 04 Nov 2011 17:55:49 +0900 - -capi-network-connection (0.1.0-4) unstable; urgency=low - - * Fix boilerplate. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-4 - - -- Sanjeev BA Fri, 04 Nov 2011 11:22:10 +0900 - -capi-network-connection (0.1.0-3) unstable; urgency=low - - * Fix doxygen comments. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-3 - - -- Sanjeev BA 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: framework/api/connection - * Tag: capi-network-connection_0.1.0-2 - - -- Sanjeev BA Fri, 14 Oct 2011 19:37:05 +0900 - -capi-network-connection (0.1.0-1) unstable; urgency=low - - * Alpha Release - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-1 - - -- Kangho Hur 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: framework/api/connection - * Tag: capi-network-connection_0.0.1-11 - - -- Sanjeev BA 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: framework/api/connection - * Tag: capi-network-connection_0.0.1-10 - - -- Sanjeev BA 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: framework/api/connection - * Tag: capi-network-connection_0.0.1-9 - - -- Sanjeev BA Fri, 02 Sep 2011 10:20:09 +0900 - -capi-network-connection (0.0.1-8) unstable; urgency=low - - * Cleanup unused code. Fix documentation. - * Git: framework/api/connection - * Tag: capi-network-connection_0.0.1-8 - - -- Sanjeev BA Thu, 01 Sep 2011 20:03:11 +0900 - -capi-network-connection (0.0.1-7) unstable; urgency=low - - * Fix handles. - * Git: framework/api/connection - * Tag: capi-network-connection_0.0.1-7 - - - -- Sanjeev BA Mon, 22 Aug 2011 14:31:53 +0900 - -capi-network-connection (0.0.1-6) unstable; urgency=low - - * Fix handles. - * Git: framework/api/connection - * Tag: capi-network-connection_0.0.1-6 - - -- Sanjeev BA Thu, 18 Aug 2011 09:50:20 +0900 - -capi-network-connection (0.0.1-5) unstable; urgency=low - - * Fix debain packaging issue. - * Git: framework/api/connection - * Tag: capi-network-connection_0.0.1-5 - - -- Sanjeev BA 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: framework/api/connection - * Tag: capi-network-connection_0.0.1-4 - - -- Sanjeev BA Thu, 04 Aug 2011 19:04:04 +0900 - -capi-network-connection (0.0.1-3) unstable; urgency=low - - * Add missing pc.in file. - * Git: framework/api/connection - * Tag: capi-network-connection_0.0.1-3 - - -- Sanjeev BA Thu, 04 Aug 2011 18:04:33 +0900 - -capi-network-connection (0.0.1-2) unstable; urgency=low - - * Initial Upload - * Git: framework/api/connection - * Tag: capi-network-connection_0.0.1-2 - - -- Sanjeev BA 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 bfc5f03..0000000 --- a/debian/control +++ /dev/null @@ -1,21 +0,0 @@ -Source: capi-network-connection -Section: libs -Priority: extra -Maintainer: JaeHyun Kim -Build-Depends: debhelper (>= 5), dlog-dev, capi-base-common-dev, libvconf-dev, libglib2.0-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 index 9f8db0e..8d02a01 100755 --- a/doc/net_connection_doc.h +++ b/doc/net_connection_doc.h @@ -59,7 +59,7 @@ * * 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 Feature Element. + * More details on featuring your application can be found from Feature List. * */ @@ -87,7 +87,7 @@ * * 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 Feature Element. + * More details on featuring your application can be found from Feature List. * */ @@ -110,7 +110,7 @@ * * 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 Feature Element. + * More details on featuring your application can be found from Feature List. * */ @@ -133,7 +133,7 @@ * * 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 Feature Element. + * More details on featuring your application can be found from Feature List. * */ @@ -160,7 +160,7 @@ * * 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 Feature Element. + * More details on featuring your application can be found from Feature List. * */ diff --git a/include/connection_profile.h b/include/connection_profile.h index ebcc3d8..433c4ca 100644 --- a/include/connection_profile.h +++ b/include/connection_profile.h @@ -34,7 +34,7 @@ extern "C" { /** * @brief Enumeration for security type of Wi-Fi. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -47,7 +47,7 @@ typedef enum /** * @brief Enumeration for encryption modes. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -69,19 +69,8 @@ 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; - -/** * @brief Enumeration for cellular service type. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -96,7 +85,7 @@ typedef enum /** * @brief Enumeration for cellular authentication type. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -117,13 +106,13 @@ typedef enum /** * @brief The profile handle. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef void* connection_profile_h; /** * @brief Enumeration for profile state type. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -135,7 +124,7 @@ typedef enum /** * @brief Enumeration for address family. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -145,7 +134,7 @@ typedef enum /** * @brief Enumeration for IP configuration type. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -158,7 +147,7 @@ typedef enum /** * @brief Enumeration for proxy method type. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -169,7 +158,7 @@ typedef enum /** * @brief Enumeration for network connection type. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum{ CONNECTION_PROFILE_TYPE_CELLULAR = 0, /**< Cellular type */ @@ -181,7 +170,7 @@ typedef enum{ /** * @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 2.3 + * @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(). @@ -201,7 +190,7 @@ int connection_profile_create(connection_profile_type_e type, const char* keywor /** * @brief Destroys a profile handle. - * @since_tizen 2.3 + * @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 @@ -230,7 +219,7 @@ int connection_profile_clone(connection_profile_h* cloned_profile, connection_pr * 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 2.3 + * @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 @@ -245,7 +234,7 @@ int connection_profile_get_id(connection_profile_h profile, char** profile_id); /** * @brief Gets the profile name. - * @since_tizen 2.3 + * @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 @@ -259,7 +248,7 @@ int connection_profile_get_name(connection_profile_h profile, char** profile_nam /** * @brief Gets the network type. - * @since_tizen 2.3 + * @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 @@ -271,7 +260,7 @@ int connection_profile_get_type(connection_profile_h profile, connection_profile /** * @brief Gets the name of the network interface, e.g. eth0 and pdp0. - * @since_tizen 2.3 + * @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 @@ -284,7 +273,7 @@ int connection_profile_get_network_interface_name(connection_profile_h profile, /** * @brief Refreshes the profile information. - * @since_tizen 2.3 + * @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. @@ -300,7 +289,7 @@ int connection_profile_refresh(connection_profile_h profile); /** * @brief Gets the network type. - * @since_tizen 2.3 + * @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 @@ -312,7 +301,7 @@ int connection_profile_get_state(connection_profile_h profile, connection_profil /** * @brief Gets the IP config type. - * @since_tizen 2.3 + * @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 @@ -325,7 +314,7 @@ int connection_profile_get_ip_config_type(connection_profile_h profile, connecti /** * @brief Gets the IP address. - * @since_tizen 2.3 + * @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 @@ -341,7 +330,7 @@ int connection_profile_get_ip_address(connection_profile_h profile, connection_a /** * @brief Gets the Subnet Mask. - * @since_tizen 2.3 + * @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 @@ -357,7 +346,7 @@ int connection_profile_get_subnet_mask(connection_profile_h profile, connection_ /** * @brief Gets the Gateway address. - * @since_tizen 2.3 + * @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 @@ -373,7 +362,7 @@ int connection_profile_get_gateway_address(connection_profile_h profile, connect /** * @brief Gets the DNS address. - * @since_tizen 2.3 + * @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 @@ -391,7 +380,7 @@ int connection_profile_get_dns_address(connection_profile_h profile, int order, /** * @brief Gets the Proxy type. - * @since_tizen 2.3 + * @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 @@ -403,7 +392,7 @@ int connection_profile_get_proxy_type(connection_profile_h profile, connection_p /** * @brief Gets the Proxy address. - * @since_tizen 2.3 + * @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 @@ -421,7 +410,7 @@ int connection_profile_get_proxy_address(connection_profile_h profile, connectio * @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 2.3 + * @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 @@ -434,7 +423,7 @@ int connection_profile_set_ip_config_type(connection_profile_h profile, connecti /** * @brief Sets the IP address. - * @since_tizen 2.3 + * @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 @@ -450,7 +439,7 @@ int connection_profile_set_ip_address(connection_profile_h profile, connection_a /** * @brief Sets the Subnet Mask. - * @since_tizen 2.3 + * @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 @@ -466,7 +455,7 @@ int connection_profile_set_subnet_mask(connection_profile_h profile, connection_ /** * @brief Sets the Gateway address. - * @since_tizen 2.3 + * @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 @@ -482,7 +471,7 @@ int connection_profile_set_gateway_address(connection_profile_h profile, connect /** * @brief Sets the DNS address. - * @since_tizen 2.3 + * @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 @@ -501,7 +490,7 @@ int connection_profile_set_dns_address(connection_profile_h profile, int order, /** * @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 2.3 + * @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 @@ -514,7 +503,7 @@ int connection_profile_set_proxy_type(connection_profile_h profile, connection_p /** * @brief Sets the Proxy address. - * @since_tizen 2.3 + * @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 @@ -530,7 +519,7 @@ int connection_profile_set_proxy_address(connection_profile_h profile, connectio /** * @brief Called when the state of the profile is changed. - * @since_tizen 2.3 + * @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() @@ -540,7 +529,7 @@ typedef void(*connection_profile_state_changed_cb)(connection_profile_state_e st /** * @brief Registers the callback that is called when the state of profile is changed. - * @since_tizen 2.3 + * @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 @@ -556,7 +545,7 @@ int connection_profile_set_state_changed_cb(connection_profile_h profile, connec /** * @brief Unregisters the callback that is called when the state of profile is changed. - * @since_tizen 2.3 + * @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 @@ -578,7 +567,7 @@ int connection_profile_unset_state_changed_cb(connection_profile_h profile); /** * @brief Gets the ESSID (Extended Service Set Identifier). - * @since_tizen 2.3 + * @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 @@ -592,7 +581,7 @@ int connection_profile_get_wifi_essid(connection_profile_h profile, char** essid /** * @brief Gets the BSSID (Basic Service Set Identifier). - * @since_tizen 2.3 + * @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 @@ -606,7 +595,7 @@ int connection_profile_get_wifi_bssid(connection_profile_h profile, char** bssid /** * @brief Gets the RSSI. - * @since_tizen 2.3 + * @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 @@ -618,7 +607,7 @@ int connection_profile_get_wifi_rssi(connection_profile_h profile, int* rssi); /** * @brief Gets the frequency (MHz). - * @since_tizen 2.3 + * @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 @@ -630,7 +619,7 @@ int connection_profile_get_wifi_frequency(connection_profile_h profile, int* fre /** * @brief Gets the max speed (Mbps). - * @since_tizen 2.3 + * @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 @@ -642,7 +631,7 @@ int connection_profile_get_wifi_max_speed(connection_profile_h profile, int* max /** * @brief Gets the security mode of Wi-Fi. - * @since_tizen 2.3 + * @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 @@ -655,7 +644,7 @@ int connection_profile_get_wifi_security_type(connection_profile_h profile, conn /** * @brief Gets the security mode of Wi-Fi. - * @since_tizen 2.3 + * @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 @@ -668,7 +657,7 @@ int connection_profile_get_wifi_encryption_type(connection_profile_h profile, co /** * @brief Checks whether passphrase is required. - * @since_tizen 2.3 + * @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. @@ -681,7 +670,7 @@ int connection_profile_is_wifi_passphrase_required(connection_profile_h profile, /** * @brief Sets the passphrase of the Wi-Fi WPA. - * @since_tizen 2.3 + * @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 @@ -694,7 +683,7 @@ int connection_profile_set_wifi_passphrase(connection_profile_h profile, const c /** * @brief Checks whether the WPS (Wi-Fi Protected Setup) is supported. - * @since_tizen 2.3 + * @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. @@ -716,19 +705,8 @@ 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. - * @since_tizen 2.3 + * @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 @@ -741,7 +719,7 @@ int connection_profile_get_cellular_service_type(connection_profile_h profile, c /** * @brief Gets the APN (access point name). - * @since_tizen 2.3 + * @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 @@ -755,7 +733,7 @@ int connection_profile_get_cellular_apn(connection_profile_h profile, char** apn /** * @brief Gets the authentication information. - * @since_tizen 2.3 + * @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 @@ -772,7 +750,7 @@ int connection_profile_get_cellular_auth_info(connection_profile_h profile, conn /** * @brief Gets the home URL. - * @since_tizen 2.3 + * @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 @@ -786,7 +764,7 @@ int connection_profile_get_cellular_home_url(connection_profile_h profile, char* /** * @brief Checks wheter the connection is in roaming state. - * @since_tizen 2.3 + * @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 @@ -798,7 +776,7 @@ int connection_profile_is_cellular_roaming(connection_profile_h profile, bool* i /** * @brief Checks whether the profile is hidden. - * @since_tizen 2.3 + * @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 @@ -810,7 +788,7 @@ int connection_profile_is_cellular_hidden(connection_profile_h profile, bool* is /** * @brief Checks whether the profile is editable. - * @since_tizen 2.3 + * @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 @@ -822,7 +800,7 @@ int connection_profile_is_cellular_editable(connection_profile_h profile, bool* /** * @brief Checks whether the profile is default. - * @since_tizen 2.3 + * @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 @@ -834,7 +812,7 @@ int connection_profile_is_cellular_default(connection_profile_h profile, bool* i /** * @brief Sets the service type. - * @since_tizen 2.3 + * @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 @@ -847,7 +825,7 @@ int connection_profile_set_cellular_service_type(connection_profile_h profile, c /** * @brief Sets the APN (Access Point Name). - * @since_tizen 2.3 + * @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 @@ -860,7 +838,7 @@ int connection_profile_set_cellular_apn(connection_profile_h profile, const char /** * @brief Sets the Authentication information. - * @since_tizen 2.3 + * @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 @@ -875,7 +853,7 @@ int connection_profile_set_cellular_auth_info(connection_profile_h profile, conn /** * @brief Sets the home URL. - * @since_tizen 2.3 + * @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 diff --git a/include/net_connection.h b/include/net_connection.h old mode 100644 new mode 100755 index 9573027..f658d50 --- a/include/net_connection.h +++ b/include/net_connection.h @@ -34,19 +34,19 @@ extern "C" { /** * @brief The connection handle. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef void* connection_h; /** * @brief The profiles iterator handle. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef void* connection_profile_iterator_h; /** * @brief Enumeration for connection type. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -59,7 +59,7 @@ typedef enum /** * @brief Enumeration for cellular network state. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -73,7 +73,7 @@ typedef enum /** * @brief Enumeration for Wi-Fi state. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -95,7 +95,7 @@ typedef enum /** * @brief Enumeration for Bluetooth state. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -106,7 +106,7 @@ typedef enum /** * @brief Enumeration for connection iterator type. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -117,7 +117,7 @@ typedef enum /** * @brief Enumeration for reset profile type. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -137,7 +137,7 @@ typedef enum /** * @brief Enumeration for connection errors. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -170,7 +170,7 @@ typedef enum /** * @brief Enumeration for statistics type. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { @@ -192,7 +192,7 @@ typedef enum /** * @brief Creates a handle for managing data connections. - * @since_tizen 2.3 + * @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(). @@ -207,7 +207,7 @@ int connection_create(connection_h* connection); /** * @brief Destroys the connection handle. - * @since_tizen 2.3 + * @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 @@ -218,7 +218,7 @@ int connection_destroy(connection_h connection); /** * @brief Called when the type of a connection is changed. - * @since_tizen 2.3 + * @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_type_changed_cb() @@ -228,7 +228,7 @@ typedef void(*connection_type_changed_cb)(connection_type_e type, void* user_dat /** * @brief Called when the address is changed. - * @since_tizen 2.3 + * @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 @@ -241,7 +241,7 @@ typedef void(*connection_address_changed_cb)(const char* ipv4_address, const cha /** * @brief Called when connection_set_default_cellular_service_profile_async() finishes. - * @since_tizen 2.3 + * @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. @@ -251,7 +251,7 @@ typedef void(*connection_set_default_cb)(connection_error_e result, void* user_d /** * @brief Gets the type of the current profile for data connection. - * @since_tizen 2.3 + * @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 @@ -263,7 +263,7 @@ int connection_get_type(connection_h connection, connection_type_e* type); /** * @brief Gets the IP address of the current connection. - * @since_tizen 2.3 + * @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 @@ -278,7 +278,7 @@ int connection_get_ip_address(connection_h connection, connection_address_family /** * @brief Gets the proxy address of the current connection. - * @since_tizen 2.3 + * @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 @@ -311,7 +311,7 @@ int connection_get_mac_address(connection_h connection, connection_type_e type, /** * @brief Gets the state of cellular connection. * @details The returned state is for the cellular connection state. - * @since_tizen 2.3 + * @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 @@ -325,7 +325,7 @@ int connection_get_cellular_state(connection_h connection, connection_cellular_s /** * @brief Gets the state of the Wi-Fi. * @details The returned state is for the Wi-Fi connection state. - * @since_tizen 2.3 + * @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 @@ -411,7 +411,7 @@ int connection_unset_ethernet_cable_state_chaged_cb(connection_h connection); /** * @brief Gets the state of the Bluetooth. * @details The returned state is for the Bluetooth connection state. - * @since_tizen 2.3 + * @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 @@ -427,7 +427,7 @@ int connection_get_bt_state(connection_h connection, connection_bt_state_e* stat /** * @brief Registers the callback that is called when the type of the current connection is changed. - * @since_tizen 2.3 + * @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 @@ -440,7 +440,7 @@ int connection_set_type_changed_cb(connection_h connection, connection_type_chan /** * @brief Unregisters the callback that is called when the type of current connection is changed. - * @since_tizen 2.3 + * @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 @@ -451,7 +451,7 @@ int connection_unset_type_changed_cb(connection_h connection); /** * @brief Registers the callback that is called when the IP address is changed. - * @since_tizen 2.3 + * @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 @@ -464,7 +464,7 @@ int connection_set_ip_address_changed_cb(connection_h connection, connection_add /** * @brief Unregisters the callback that is called when the IP address is changed. - * @since_tizen 2.3 + * @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 @@ -475,7 +475,7 @@ int connection_unset_ip_address_changed_cb(connection_h connection); /** * @brief Registers the callback that is called when the proxy address is changed. - * @since_tizen 2.3 + * @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 @@ -488,7 +488,7 @@ int connection_set_proxy_address_changed_cb(connection_h connection, connection_ /** * @brief Unregisters the callback that is called when the proxy address is changed. - * @since_tizen 2.3 + * @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 @@ -499,7 +499,7 @@ int connection_unset_proxy_address_changed_cb(connection_h connection); /** * @brief Adds a new profile which is created by connection_profile_create(). - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/network.profile * @remarks You can only add a profile of the cellular type. @@ -516,7 +516,7 @@ int connection_add_profile(connection_h connection, connection_profile_h profile /** * @brief Removes an existing profile. - * @since_tizen 2.3 + * @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 @@ -537,7 +537,7 @@ int connection_remove_profile(connection_h connection, connection_profile_h prof * @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 2.3 + * @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 @@ -556,7 +556,7 @@ int connection_update_profile(connection_h connection, connection_profile_h prof /** * @brief Gets a profiles iterator. - * @since_tizen 2.3 + * @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(). @@ -574,7 +574,7 @@ int connection_get_profile_iterator(connection_h connection, connection_iterator /** * @brief Moves the profile iterator to the next position and gets a profile handle. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @param[in] profile_iterator The iterator of profile * @param[out] profile The profile handle * @return @c 0 on success, otherwise a negative error value @@ -586,7 +586,7 @@ int connection_profile_iterator_next(connection_profile_iterator_h profile_itera /** * @brief Checks whether the next element of a profile iterator exists or not. - * @since_tizen 2.3 + * @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, otherwise @c false if next element doesn't exist @@ -595,7 +595,7 @@ bool connection_profile_iterator_has_next(connection_profile_iterator_h profile_ /** * @brief Destroys a profiles iterator. - * @since_tizen 2.3 + * @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 @@ -605,7 +605,7 @@ int connection_destroy_profile_iterator(connection_profile_iterator_h profile_it /** * @brief Gets the name of the default profile. - * @since_tizen 2.3 + * @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(). @@ -623,7 +623,7 @@ int connection_get_current_profile(connection_h connection, connection_profile_h /** * @brief Gets the default profile which provides the given cellular service. - * @since_tizen 2.3 + * @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(). @@ -643,7 +643,7 @@ int connection_get_default_cellular_service_profile(connection_h connection, con /** * @brief Sets the default profile which provides the given cellular service. - * @since_tizen 2.3 + * @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 @@ -663,7 +663,7 @@ int connection_set_default_cellular_service_profile(connection_h connection, con /** * @brief Sets the default profile which provides the given cellular service, asynchronously. - * @since_tizen 2.3 + * @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 @@ -685,7 +685,7 @@ int connection_set_default_cellular_service_profile_async(connection_h connectio /** * @brief Called after connection_open_profile() is finished. - * @since_tizen 2.3 + * @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. @@ -695,7 +695,7 @@ typedef void(*connection_opened_cb)(connection_error_e result, void* user_data); /** * @brief Called after connection_close_profile() is finished. - * @since_tizen 2.3 + * @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. @@ -705,7 +705,7 @@ typedef void(*connection_closed_cb)(connection_error_e result, void* user_data); /** * @brief Called after connection_reset_profile() is finished. - * @since_tizen 2.3 + * @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. @@ -715,7 +715,7 @@ typedef void(*connection_reset_cb)(connection_error_e result, void* user_data); /** * @brief Opens a connection of profile, asynchronously. - * @since_tizen 2.3 + * @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 @@ -740,7 +740,7 @@ int connection_open_profile(connection_h connection, connection_profile_h profil /** * @brief Closes a connection of profile. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/network.set * @param[in] connection The connection handle @@ -763,7 +763,7 @@ int connection_close_profile(connection_h connection, connection_profile_h profi /** * @brief Resets the cellular profile. - * @since_tizen 2.3 + * @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 @@ -786,7 +786,7 @@ int connection_reset_profile(connection_h connection, connection_reset_option_e /** * @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 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/network.set * @param[in] connection The connection handle @@ -805,7 +805,7 @@ int connection_add_route(connection_h connection, const char* interface_name, co /** * @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 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/network.set * @param[in] connection The connection handle @@ -838,7 +838,6 @@ int connection_remove_route(connection_h connection, const char* interface_name, * @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); /** @@ -849,11 +848,11 @@ int connection_add_route_ipv6(connection_h connection, const char *interface_nam * @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] 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_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() @@ -871,7 +870,7 @@ int connection_remove_route_ipv6(connection_h connection, const char *interface_ /** * @brief Gets the statistics information. - * @since_tizen 2.3 + * @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 @@ -888,7 +887,7 @@ int connection_get_statistics(connection_h connection, connection_type_e connect /** * @brief Resets the statistics information. - * @since_tizen 2.3 + * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public * @privilege %http://tizen.org/privilege/network.set * @remarks This API needs both privileges. diff --git a/include/net_connection_private.h b/include/net_connection_private.h old mode 100644 new mode 100755 index 041b304..ef8f841 --- a/include/net_connection_private.h +++ b/include/net_connection_private.h @@ -49,12 +49,16 @@ typedef enum CONNECTION_CELLULAR_SUBSCRIBER_2 = 0x01, } connection_cellular_subscriber_id_e; +#if !defined TIZEN_TV #define CHECK_FEATURE_SUPPORTED(...) \ do { \ int rv = _connection_check_feature_supported(__VA_ARGS__, NULL); \ if( rv != CONNECTION_ERROR_NONE ) \ return rv; \ } while(0) +#else +#define CHECK_FEATURE_SUPPORTED(...) +#endif #define CONNECTION_LOG(log_level, format, args...) \ do { \ @@ -70,9 +74,6 @@ typedef enum } \ } while(0) -#define CONNECTION_MUTEX_LOCK _connection_inter_mutex_lock() -#define CONNECTION_MUTEX_UNLOCK _connection_inter_mutex_unlock() - #define SECURE_CONNECTION_LOG(log_level, format, args...) \ do { \ switch (log_level) { \ @@ -154,8 +155,6 @@ net_service_type_t _connection_profile_convert_to_libnet_cellular_service_type(c net_state_type_t _connection_profile_convert_to_net_state(connection_profile_state_e state); int _connection_libnet_set_cellular_subscriber_id(connection_profile_h profile, connection_cellular_subscriber_id_e sim_id); -void _connection_inter_mutex_lock(void); -void _connection_inter_mutex_unlock(void); #ifdef __cplusplus } diff --git a/packaging/capi-network-connection.changes b/packaging/capi-network-connection.changes deleted file mode 100644 index 3e61151..0000000 --- a/packaging/capi-network-connection.changes +++ /dev/null @@ -1,6 +0,0 @@ -* Tue Jul 09 2013 Baptiste DURAND bd62c93 -- x86_64 compliance: Fix libdir variable in PC file - -* Mon May 20 2013 Rusty Lynch submit/tizen/20130520.200645@62a88ba -- Work around build breakages by unsetting LD_AS_NEEDED - diff --git a/packaging/capi-network-connection.manifest b/packaging/capi-network-connection.manifest deleted file mode 100644 index 017d22d..0000000 --- a/packaging/capi-network-connection.manifest +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/packaging/capi-network-connection.spec b/packaging/capi-network-connection.spec index b0842ed..a8e029e 100644 --- a/packaging/capi-network-connection.spec +++ b/packaging/capi-network-connection.spec @@ -1,39 +1,56 @@ -Name: capi-network-connection -Summary: Network Connection library in TIZEN C API -Version: 0.1.3_27 -Release: 1 -Group: System/Network -License: Apache-2.0 -Source0: %{name}-%{version}.tar.gz -Source1001: capi-network-connection.manifest -BuildRequires: cmake -BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(glib-2.0) -BuildRequires: pkgconfig(vconf) -BuildRequires: pkgconfig(capi-base-common) -BuildRequires: pkgconfig(capi-system-info) -BuildRequires: pkgconfig(network) +Name: capi-network-connection +Summary: Network Connection library in TIZEN C API +Version: 1.0.70 +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 -cp %{SOURCE1001} . %build -unset LD_AS_NEEDED +export CFLAGS+=' -Wno-unused-local-typedefs' MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` -%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} +cmake -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \ + -DLIB_PATH=%{_lib} \ +%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 \ +%else +%if "%{?tizen_profile_name}" == "tv" + -DTIZEN_TV=1 \ +%endif +%endif +%endif + . make %{?_smp_mflags} @@ -43,7 +60,7 @@ make %{?_smp_mflags} #License mkdir -p %{buildroot}%{_datadir}/license -cp LICENSE.APLv2 %{buildroot}%{_datadir}/license/capi-network-connection +cp LICENSE %{buildroot}%{_datadir}/license/capi-network-connection %post -p /sbin/ldconfig @@ -51,13 +68,12 @@ cp LICENSE.APLv2 %{buildroot}%{_datadir}/license/capi-network-connection %files -%manifest %{name}.manifest +%manifest capi-network-connection.manifest %attr(644,-,-) %{_libdir}/libcapi-network-connection.so.* %{_datadir}/license/capi-network-connection %{_bindir}/connection_test %files devel -%manifest %{name}.manifest %{_includedir}/network/*.h %{_libdir}/pkgconfig/*.pc %{_libdir}/libcapi-network-connection.so diff --git a/src/connection.c b/src/connection.c old mode 100644 new mode 100755 index 8dbe36a..da5e609 --- a/src/connection.c +++ b/src/connection.c @@ -14,17 +14,14 @@ * limitations under the License. */ +#include #include #include -#include #include -#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); +static __thread GSList *conn_handle_list = NULL; static int __connection_convert_net_state(int status) { @@ -58,43 +55,69 @@ static int __connection_convert_cellular_state(int status) } } -static int __connection_get_type_changed_callback_count(void) +static bool __connection_check_handle_validity(connection_h connection) { - GSList *list; - int count = 0; + bool ret = false; - for (list = conn_handle_list; list; list = list->next) { - connection_handle_s *local_handle = (connection_handle_s *)list->data; - if (local_handle->type_changed_callback) count++; - } + if (connection == NULL) + return false; - return count; + if (g_slist_find(conn_handle_list, connection) != NULL) + ret = true; + + return ret; } -static int __connection_get_ip_changed_callback_count(void) +static connection_type_changed_cb +__connection_get_type_changed_callback(connection_handle_s *local_handle) { - GSList *list; - int count = 0; + return local_handle->type_changed_callback; +} - 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++; - } +static void *__connection_get_type_changed_userdata( + connection_handle_s *local_handle) +{ + return local_handle->type_changed_user_data; +} - return count; +static gboolean __connection_cb_type_changed_cb_idle(gpointer user_data) +{ + int state, status; + void *data; + connection_type_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; + + if (vconf_get_int(VCONFKEY_NETWORK_STATUS, &status) != 0) + return FALSE; + + state = __connection_convert_net_state(status); + + 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 void __connection_cb_ethernet_cable_state_changed_cb(connection_ethernet_cable_state_e state) @@ -127,134 +150,212 @@ static int __connection_get_ethernet_cable_state_changed_callback_count(void) 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_type_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->type_changed_user_data = user_data; + refcount++; + CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)", refcount); } else { - if (local_handle->type_changed_callback && - __connection_get_type_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->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, +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->type_changed_callback) - local_handle->type_changed_callback( - __connection_convert_net_state(state), - local_handle->type_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) { - bool ret = false; + static __thread gint refcount = 0; + connection_handle_s *local_handle; - if (connection == NULL) - return false; + local_handle = (connection_handle_s *)connection; - if (g_slist_find(conn_handle_list, connection) != NULL) - ret = true; + if (callback) { + if (refcount == 0) + vconf_notify_key_changed(VCONFKEY_NETWORK_PROXY, + __connection_cb_proxy_change_cb, NULL); - return ret; + 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); + } + } + } + } + + local_handle->proxy_changed_user_data = user_data; + local_handle->proxy_changed_callback = callback; + + return CONNECTION_ERROR_NONE; } static int __connection_set_ethernet_cable_state_changed_cb(connection_h connection, @@ -279,53 +380,37 @@ static int __connection_set_ethernet_cable_state_changed_cb(connection_h connect static int __connection_get_handle_count(void) { - GSList *list; - int count = 0; - - if (!conn_handle_list) - return count; - - for (list = conn_handle_list; list; list = list->next) count++; - - return count; + return ((int)g_slist_length(conn_handle_list)); } /* Connection Manager ********************************************************/ -EXPORT_API int connection_create(connection_h* connection) +EXPORT_API int connection_create(connection_h *connection) { CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE); - CONNECTION_MUTEX_LOCK; - int rv; 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; } - rv = _connection_libnet_init(); + int rv = _connection_libnet_init(); if (rv == NET_ERR_ACCESS_DENIED) { CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); - CONNECTION_MUTEX_UNLOCK; return CONNECTION_ERROR_PERMISSION_DENIED; } else if (rv != NET_ERR_NONE) { CONNECTION_LOG(CONNECTION_ERROR, "Failed to create connection[%d]", rv); - CONNECTION_MUTEX_UNLOCK; 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; } @@ -333,15 +418,12 @@ EXPORT_API int connection_destroy(connection_h connection) { CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE); - CONNECTION_MUTEX_LOCK; - - 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_type_changed_callback(connection, NULL, NULL); __connection_set_ip_changed_callback(connection, NULL, NULL); @@ -351,31 +433,35 @@ EXPORT_API int connection_destroy(connection_h connection) 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; } EXPORT_API int connection_get_type(connection_h connection, connection_type_e* type) { + int rv = 0; 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; } - if (vconf_get_int(VCONFKEY_NETWORK_STATUS, &status)) { - CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_int Failed = %d\n", status); + rv = vconf_get_int(VCONFKEY_NETWORK_STATUS, &status); + if (rv != VCONF_OK) { + 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); @@ -383,7 +469,7 @@ EXPORT_API int connection_get_type(connection_h connection, connection_type_e* t } EXPORT_API int connection_get_ip_address(connection_h connection, - connection_address_family_e address_family, char **ip_address) + connection_address_family_e address_family, char** ip_address) { CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE); @@ -397,7 +483,6 @@ EXPORT_API int connection_get_ip_address(connection_h connection, case CONNECTION_ADDRESS_FAMILY_IPV6: *ip_address = vconf_get_str(VCONFKEY_NETWORK_IP); break; - default: CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; @@ -412,7 +497,7 @@ EXPORT_API int connection_get_ip_address(connection_h connection, } EXPORT_API int connection_get_proxy(connection_h connection, - connection_address_family_e address_family, char **proxy) + connection_address_family_e address_family, char** proxy) { CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE); @@ -426,7 +511,6 @@ EXPORT_API int connection_get_proxy(connection_h connection, case CONNECTION_ADDRESS_FAMILY_IPV6: *proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY); break; - default: CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; @@ -459,6 +543,7 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty switch (type) { case CONNECTION_TYPE_WIFI: +#if defined TIZEN_TV fp = fopen(WIFI_MAC_INFO_FILE, "r"); if (fp == NULL) { CONNECTION_LOG(CONNECTION_ERROR, "Failed to open file %s", WIFI_MAC_INFO_FILE); @@ -481,6 +566,14 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty } g_strlcpy(*mac_addr, buf, CONNECTION_MAC_INFO_LENGTH + 1); fclose(fp); +#else + *mac_addr = vconf_get_str(VCONFKEY_WIFI_BSSID_ADDRESS); + + if(*mac_addr == NULL) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to get vconf from %s", VCONFKEY_WIFI_BSSID_ADDRESS); + return CONNECTION_ERROR_OPERATION_FAILED; + } +#endif break; case CONNECTION_TYPE_ETHERNET: fp = fopen(ETHERNET_MAC_INFO_FILE, "r"); @@ -527,60 +620,86 @@ EXPORT_API int connection_get_mac_address(connection_h connection, connection_ty 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); + 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; + } - if (*state == CONNECTION_CELLULAR_STATE_AVAILABLE) { - if (vconf_get_int(VCONFKEY_DNET_STATE, &cellular_state)) { - CONNECTION_LOG(CONNECTION_ERROR, - "vconf_get_int Failed = %d\n", 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; } - CONNECTION_LOG(CONNECTION_INFO, "Connection state = %d\n", cellular_state); + switch (sim_id) { + case CONNECTION_CELLULAR_SUBSCRIBER_1: +#endif + rv = vconf_get_int(VCONFKEY_DNET_STATE, &cellular_state); +#if defined TIZEN_DUALSIM_ENABLE + break; - if (cellular_state == VCONFKEY_DNET_NORMAL_CONNECTED || - cellular_state == VCONFKEY_DNET_SECURE_CONNECTED || - cellular_state == VCONFKEY_DNET_TRANSFER) - *state = CONNECTION_CELLULAR_STATE_CONNECTED; + case CONNECTION_CELLULAR_SUBSCRIBER_2: + rv = vconf_get_int(VCONFKEY_DNET_STATE2, &cellular_state); + break; - return CONNECTION_ERROR_NONE; - } else { - CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_int Failed = %d\n", status); - return CONNECTION_ERROR_OPERATION_FAILED; + 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; } EXPORT_API int connection_get_wifi_state(connection_h connection, connection_wifi_state_e* state) { CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - int rv; - 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; } - rv = _connection_libnet_get_wifi_state(state); + 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, "WiFi state = %d\n", *state); + CONNECTION_LOG(CONNECTION_INFO, "Wi-Fi state: %d", *state); return CONNECTION_ERROR_NONE; } @@ -590,7 +709,7 @@ EXPORT_API int connection_get_ethernet_state(connection_h connection, connection 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; } @@ -641,12 +760,11 @@ EXPORT_API int connection_get_bt_state(connection_h connection, connection_bt_st CHECK_FEATURE_SUPPORTED(TETHERING_BLUETOOTH_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; } return _connection_libnet_get_bluetooth_state(state); - } EXPORT_API int connection_set_type_changed_cb(connection_h connection, @@ -655,7 +773,7 @@ EXPORT_API int connection_set_type_changed_cb(connection_h connection, 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; } @@ -667,7 +785,7 @@ 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; } @@ -680,7 +798,7 @@ EXPORT_API int connection_set_ip_address_changed_cb(connection_h connection, 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; } @@ -692,7 +810,7 @@ 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; } @@ -705,7 +823,7 @@ EXPORT_API int connection_set_proxy_address_changed_cb(connection_h connection, 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; } @@ -717,7 +835,7 @@ 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; } @@ -726,24 +844,30 @@ EXPORT_API int connection_unset_proxy_address_changed_cb(connection_h connection 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; - - net_profile_info_t *profile_info = profile; - if (profile_info->profile_type != NET_DEVICE_CELLULAR) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + 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); + 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; @@ -757,20 +881,20 @@ EXPORT_API int connection_add_profile(connection_h connection, connection_profil 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, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -788,17 +912,17 @@ EXPORT_API int connection_remove_profile(connection_h connection, connection_pro 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, ETHERNET_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_ACCESS_DENIED) { CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); @@ -854,20 +978,21 @@ EXPORT_API int connection_get_current_profile(connection_h connection, connectio 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); } -EXPORT_API int connection_get_default_cellular_service_profile(connection_h connection, - connection_cellular_service_type_e type, 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; } @@ -880,7 +1005,7 @@ EXPORT_API int connection_set_default_cellular_service_profile(connection_h conn 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; } @@ -895,7 +1020,7 @@ EXPORT_API int connection_set_default_cellular_service_profile_async(connection_ if (!(__connection_check_handle_validity(connection)) || profile == NULL || callback == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -909,7 +1034,7 @@ EXPORT_API int connection_open_profile(connection_h connection, connection_profi if (!(__connection_check_handle_validity(connection)) || profile == NULL || callback == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -923,7 +1048,7 @@ EXPORT_API int connection_close_profile(connection_h connection, connection_prof if (!(__connection_check_handle_validity(connection)) || profile == NULL || callback == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -954,7 +1079,7 @@ EXPORT_API int connection_add_route(connection_h connection, const char* interfa if (!(__connection_check_handle_validity(connection)) || interface_name == NULL || host_address == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -1000,48 +1125,116 @@ EXPORT_API int connection_remove_route_ipv6(connection_h connection, const char return _connection_libnet_remove_route_ipv6(interface_name, host_address, gateway); } -/* Connection Statistics module ******************************************************************/ - -static int __get_statistic(connection_type_e connection_type, - connection_statistics_type_e statistics_type, long long* llsize) +static int __get_cellular_statistic(connection_statistics_type_e statistics_type, long long *llsize) { - int rv, size; - unsigned long long ull_size; - int stat_type; - char *key = NULL; + 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; } - if (connection_type == CONNECTION_TYPE_CELLULAR) { + 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 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 - CONNECTION_LOG(CONNECTION_INFO,"%s:%d bytes\n", key, size); - *llsize = (long long)size; - } else if (connection_type == CONNECTION_TYPE_WIFI) { + if (rv != VCONF_OK || rv1 != VCONF_OK) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to get cellular statistics"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + *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; @@ -1068,7 +1261,7 @@ static int __get_statistic(connection_type_e connection_type, 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; @@ -1077,7 +1270,7 @@ static int __get_statistic(connection_type_e connection_type, } static int __reset_statistic(connection_type_e connection_type, - connection_statistics_type_e statistics_type) + connection_statistics_type_e statistics_type) { int conn_type; int stat_type; @@ -1108,11 +1301,10 @@ static int __reset_statistic(connection_type_e connection_type, } 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; } @@ -1147,10 +1339,11 @@ EXPORT_API int connection_reset_statistics(connection_h connection, else if(connection_type == CONNECTION_TYPE_WIFI) CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - if (!(__connection_check_handle_validity(connection))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed"); + 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 old mode 100644 new mode 100755 index cdd4be7..3005b69 --- a/src/connection_profile.c +++ b/src/connection_profile.c @@ -14,12 +14,13 @@ * limitations under the License. */ +#include #include -#include #include +#include #include -#include #include + #include "net_connection_private.h" #define HTTP_PROXY "http_proxy" @@ -104,9 +105,9 @@ static const char* __profile_get_ethernet_proxy(void) { char *proxy; - proxy = getenv(HTTP_PROXY); + proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY); - if(proxy == NULL) { + if (proxy == NULL) { CONNECTION_LOG(CONNECTION_ERROR, "Fail to get system proxy"); return NULL; } @@ -214,12 +215,25 @@ EXPORT_API int connection_profile_create(connection_profile_type_e type, const c else if(type == CONNECTION_PROFILE_TYPE_WIFI) CHECK_FEATURE_SUPPORTED(WIFI_FEATURE); - if ((type != CONNECTION_PROFILE_TYPE_CELLULAR && - type != CONNECTION_PROFILE_TYPE_WIFI) || profile == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + if (type != CONNECTION_PROFILE_TYPE_CELLULAR && + type != CONNECTION_PROFILE_TYPE_WIFI) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } + 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; @@ -227,7 +241,7 @@ EXPORT_API int connection_profile_create(connection_profile_type_e type, const c switch (type) { case CONNECTION_PROFILE_TYPE_CELLULAR: if (keyword == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); g_free(profile_info); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -251,7 +265,7 @@ 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; } @@ -265,7 +279,7 @@ EXPORT_API int connection_profile_clone(connection_profile_h* cloned_profile, co 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; } @@ -284,7 +298,7 @@ EXPORT_API int connection_profile_get_id(connection_profile_h profile, char** pr 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, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -308,7 +322,7 @@ EXPORT_API int connection_profile_get_name(connection_profile_h profile, char** 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; } @@ -347,7 +361,7 @@ EXPORT_API int connection_profile_get_type(connection_profile_h profile, connect 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; } @@ -367,7 +381,7 @@ EXPORT_API int connection_profile_get_type(connection_profile_h profile, connect *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; } @@ -379,7 +393,7 @@ EXPORT_API int connection_profile_get_network_interface_name(connection_profile_ 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; } @@ -402,7 +416,7 @@ 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, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -428,14 +442,14 @@ EXPORT_API int connection_profile_get_state(connection_profile_h profile, connec 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); if (*state < 0) - return CONNECTION_ERROR_OPERATION_FAILED; + return CONNECTION_ERROR_OPERATION_FAILED; return CONNECTION_ERROR_NONE; } @@ -565,8 +579,11 @@ EXPORT_API int connection_profile_get_subnet_mask(connection_profile_h profile, 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; + if (prefixlen != NULL) { + snprintf(prefixlen, MAX_PREFIX_LENGTH, "%d", net_info->PrefixLen6); + *subnet_mask = prefixlen; + } else + *subnet_mask = NULL; } else *subnet_mask = __profile_convert_ip_to_string(&net_info->SubnetMask, address_family); @@ -648,7 +665,7 @@ EXPORT_API int connection_profile_get_proxy_type(connection_profile_h profile, c 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; } @@ -933,7 +950,7 @@ EXPORT_API int connection_profile_set_proxy_type(connection_profile_h profile, c 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; } @@ -990,7 +1007,7 @@ EXPORT_API int connection_profile_set_state_changed_cb(connection_profile_h prof 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; } @@ -1004,8 +1021,8 @@ EXPORT_API int connection_profile_unset_state_changed_cb(connection_profile_h pr { CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE); - if (!(_connection_libnet_check_profile_cb_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + if (!(_connection_libnet_check_profile_validity(profile))) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -1022,7 +1039,7 @@ EXPORT_API int connection_profile_get_wifi_essid(connection_profile_h profile, c 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; } @@ -1043,7 +1060,7 @@ EXPORT_API int connection_profile_get_wifi_bssid(connection_profile_h profile, c 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; } @@ -1064,7 +1081,7 @@ EXPORT_API int connection_profile_get_wifi_rssi(connection_profile_h profile, in 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; } @@ -1083,7 +1100,7 @@ EXPORT_API int connection_profile_get_wifi_frequency(connection_profile_h profil 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; } @@ -1102,7 +1119,7 @@ EXPORT_API int connection_profile_get_wifi_max_speed(connection_profile_h profil 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; } @@ -1121,7 +1138,7 @@ EXPORT_API int connection_profile_get_wifi_security_type(connection_profile_h pr 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; } @@ -1158,7 +1175,7 @@ EXPORT_API int connection_profile_get_wifi_encryption_type(connection_profile_h 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; } @@ -1195,7 +1212,7 @@ EXPORT_API int connection_profile_is_wifi_passphrase_required(connection_profile 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; } @@ -1231,7 +1248,7 @@ EXPORT_API int connection_profile_set_wifi_passphrase(connection_profile_h profi 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; } @@ -1251,7 +1268,7 @@ EXPORT_API int connection_profile_is_wifi_wps_supported(connection_profile_h pro 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; } @@ -1270,69 +1287,27 @@ EXPORT_API int connection_profile_is_wifi_wps_supported(connection_profile_h pro /* Cellular profile **********************************************************/ -EXPORT_API int connection_profile_get_cellular_network_type(connection_profile_h profile, connection_cellular_network_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"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - int network_type; - net_profile_info_t *profile_info = profile; - - if (profile_info->profile_type != NET_DEVICE_CELLULAR) - return CONNECTION_ERROR_INVALID_PARAMETER; - - if (vconf_get_int(VCONFKEY_TELEPHONY_SVC_ACT, &network_type)) { - CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_int Failed\n"); - return CONNECTION_ERROR_OPERATION_FAILED; - } - - CONNECTION_LOG(CONNECTION_INFO, "Cellular network type = %d\n", network_type); - - switch (network_type) { - case VCONFKEY_TELEPHONY_SVC_ACT_NONE: - *type = CONNECTION_CELLULAR_NETWORK_TYPE_UNKNOWN; - break; - case VCONFKEY_TELEPHONY_SVC_ACT_GPRS: - *type = CONNECTION_CELLULAR_NETWORK_TYPE_GPRS; - break; - case VCONFKEY_TELEPHONY_SVC_ACT_EGPRS: - *type = CONNECTION_CELLULAR_NETWORK_TYPE_EDGE; - break; - case VCONFKEY_TELEPHONY_SVC_ACT_UMTS: - *type = CONNECTION_CELLULAR_NETWORK_TYPE_UMTS; - break; - default: - return CONNECTION_ERROR_OPERATION_FAILED; - } - - return CONNECTION_ERROR_NONE; -} - 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); 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; } @@ -1344,14 +1319,16 @@ EXPORT_API int connection_profile_get_cellular_apn(connection_profile_h profile, 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) @@ -1367,14 +1344,16 @@ EXPORT_API int connection_profile_get_cellular_auth_info(connection_profile_h pr 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: @@ -1408,14 +1387,16 @@ EXPORT_API int connection_profile_get_cellular_home_url(connection_profile_h pro 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) @@ -1429,14 +1410,16 @@ EXPORT_API int connection_profile_is_cellular_roaming(connection_profile_h profi 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; @@ -1524,14 +1507,16 @@ EXPORT_API int connection_profile_set_cellular_service_type(connection_profile_h 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: @@ -1565,14 +1550,16 @@ EXPORT_API int connection_profile_set_cellular_apn(connection_profile_h profile, 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); @@ -1586,14 +1573,16 @@ EXPORT_API int connection_profile_set_cellular_auth_info(connection_profile_h pr 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: @@ -1620,14 +1609,16 @@ EXPORT_API int connection_profile_set_cellular_home_url(connection_profile_h pro 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); diff --git a/src/internal.c b/src/internal.c deleted file mode 100644 index ad0b88f..0000000 --- a/src/internal.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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. - */ - -#include -#include -#include -#include "net_connection_private.h" - - -static pthread_mutex_t connection_mutex = PTHREAD_MUTEX_INITIALIZER; - - -void _connection_inter_mutex_lock(void) -{ - pthread_mutex_lock(&connection_mutex); -} - -void _connection_inter_mutex_unlock(void) -{ - pthread_mutex_unlock(&connection_mutex); -} - diff --git a/src/libnetwork.c b/src/libnetwork.c index 82c747d..f167480 100755 --- a/src/libnetwork.c +++ b/src/libnetwork.c @@ -14,17 +14,18 @@ * limitations under the License. */ +#include #include +#include #include -#include #include #include #include #include "net_connection_private.h" -static GSList *prof_handle_list = NULL; -static GHashTable *profile_cb_table = NULL; +static __thread GSList *prof_handle_list = NULL; +static __thread GHashTable *profile_cb_table = NULL; struct _profile_cb_s { connection_profile_state_changed_cb callback; @@ -48,18 +49,23 @@ struct _libnet_s { void *closed_user_data; void *set_default_user_data; void *reset_profile_user_data; - bool registered; bool is_created; }; +struct _state_notify { + connection_profile_state_changed_cb callback; + connection_profile_state_e state; + void *user_data; +}; + struct managed_idle_data { GSourceFunc func; gpointer user_data; guint id; }; -static struct _profile_list_s profile_iterator = {0, 0, NULL}; -static struct _libnet_s libnet = {NULL, NULL, NULL, NULL, NULL, NULL, false}; +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) @@ -67,6 +73,11 @@ bool _connection_is_created(void) 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) { @@ -161,14 +172,6 @@ static void __libnet_set_reset_profile_cb(connection_opened_cb user_cb, void *us } } -static void __libnet_set_opened_cb(connection_opened_cb user_cb, void *user_data) -{ - if (user_cb) { - libnet.opened_cb = user_cb; - libnet.opened_user_data = user_data; - } -} - static gboolean __libnet_reset_profile_cb_idle(gpointer data) { connection_error_e result = (connection_error_e)data; @@ -194,47 +197,103 @@ static void __libnet_reset_profile_cb(connection_error_e result) _connection_callback_add(__libnet_reset_profile_cb_idle, (gpointer)result); } -static void __libnet_opened_cb(connection_error_e result) +static void __libnet_set_opened_cb(connection_opened_cb user_cb, void *user_data) { - if (libnet.opened_cb) + 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) { + if (user_cb != NULL) { libnet.closed_cb = user_cb; libnet.closed_user_data = user_data; } } -static void __libnet_closed_cb(connection_error_e result) +static gboolean __libnet_closed_cb_idle(gpointer data) { - if (libnet.closed_cb) + 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) { + if (user_cb != NULL) { libnet.set_default_cb = user_cb; libnet.set_default_user_data = user_data; } } -static void __libnet_default_cb(connection_error_e result) +static gboolean __libnet_default_cb_idle(gpointer data) { - if (libnet.set_default_cb) + 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 void __libnet_set_ethernet_cable_state_changed_cb( @@ -250,14 +309,37 @@ static void __libnet_ethernet_cable_state_changed_cb( libnet.ethernet_cable_state_changed_cb(state); } +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; + + 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; - struct _profile_cb_s *cb_info; cb_info = g_hash_table_lookup(profile_cb_table, profile_name); - if (cb_info == NULL) return; @@ -266,8 +348,21 @@ static void __libnet_state_changed_cb(char *profile_name, connection_profile_sta cb_info->state = state; - if (state >= 0 && cb_info->callback) - cb_info->callback(state, cb_info->user_data); + if (state < 0 || cb_info->callback == NULL) + return; + + 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) @@ -280,7 +375,7 @@ 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; @@ -291,7 +386,7 @@ static void __libnet_evt_cb(net_event_info_t* event_cb, void* user_data) /* fall through */ case NET_EVENT_OPEN_IND: result = __libnet_convert_to_cp_error_type(event_cb->Error); - CONNECTION_LOG(CONNECTION_INFO, "Got connection open %s : %s\n", + CONNECTION_LOG(CONNECTION_INFO, "Connection opened %s[%s]", (is_requested) ? "RSP":"IND", __libnet_convert_cp_error_type_to_string(result)); @@ -301,12 +396,12 @@ static void __libnet_evt_cb(net_event_info_t* event_cb, void* user_data) switch (event_cb->Error) { case NET_ERR_NONE: case NET_ERR_ACTIVE_CONNECTION_EXISTS: - CONNECTION_LOG(CONNECTION_INFO, "'Open connection' succeeded\n"); + CONNECTION_LOG(CONNECTION_INFO, "Successfully open connection"); __libnet_state_changed_cb(event_cb->ProfileName, CONNECTION_PROFILE_STATE_CONNECTED); return; default: - CONNECTION_LOG(CONNECTION_ERROR, "'Open connection' failed!! [%s]\n", + CONNECTION_LOG(CONNECTION_ERROR, "Failed to open connection[%s]", __libnet_convert_cp_error_type_to_string(result)); } @@ -318,7 +413,7 @@ static void __libnet_evt_cb(net_event_info_t* event_cb, void* user_data) /* fall through */ case NET_EVENT_CLOSE_IND: result = __libnet_convert_to_cp_error_type(event_cb->Error); - CONNECTION_LOG(CONNECTION_INFO, "Got connection close %s : %s\n", + CONNECTION_LOG(CONNECTION_INFO, "Connection closed %s[%s]", (is_requested) ? "RSP":"IND", __libnet_convert_cp_error_type_to_string(result)); @@ -327,54 +422,42 @@ static void __libnet_evt_cb(net_event_info_t* event_cb, void* user_data) switch (event_cb->Error) { case NET_ERR_NONE: - CONNECTION_LOG(CONNECTION_INFO, "'Close connection' succeeded!\n"); + CONNECTION_LOG(CONNECTION_INFO, "Successfully closed connection"); __libnet_state_changed_cb(event_cb->ProfileName, CONNECTION_PROFILE_STATE_DISCONNECTED); return; default: - CONNECTION_LOG(CONNECTION_ERROR, "'Close connection' failed!! [%s]\n", - __libnet_convert_cp_error_type_to_string(result)); + CONNECTION_LOG(CONNECTION_ERROR, "Failed to close connection[%s]", + __libnet_convert_cp_error_type_to_string(result)); } break; case NET_EVENT_NET_STATE_IND: - CONNECTION_LOG(CONNECTION_INFO, "Got State changed IND\n"); + CONNECTION_LOG(CONNECTION_INFO, "State changed IND"); if (event_cb->Datalength != sizeof(net_state_type_t)) return; - net_state_type_t *profile_state = (net_state_type_t*)event_cb->Data; + 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, - "Profile State : %s, profile name : %s\n", - __libnet_convert_cp_state_to_string(cp_state), - event_cb->ProfileName); + 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_INFO, "Got wifi scan IND\n"); - break; - case NET_EVENT_WIFI_POWER_IND: - case NET_EVENT_WIFI_POWER_RSP: - CONNECTION_LOG(CONNECTION_INFO, "Got wifi power IND\n"); - break; 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\n", result); + 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_INFO, "Got wifi WPS RSP\n"); - /* fall through */ + 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); - + break; case NET_EVENT_ETHERNET_CABLE_ATTACHED: CONNECTION_LOG(CONNECTION_INFO, "Got Ethernet cable Attached Indication\n"); __libnet_ethernet_cable_state_changed_cb(CONNECTION_ETHERNET_CABLE_ATTACHED); @@ -383,8 +466,8 @@ static void __libnet_evt_cb(net_event_info_t* event_cb, void* user_data) CONNECTION_LOG(CONNECTION_INFO, "Got Ethernet cable detached Indication\n"); __libnet_ethernet_cable_state_changed_cb(CONNECTION_ETHERNET_CABLE_DETACHED); break; + default : - CONNECTION_LOG(CONNECTION_ERROR, "Error! Unknown Event\n\n"); break; } } @@ -428,16 +511,41 @@ void __libnet_copy_connected_profile(net_profile_info_t **dest, struct _profile_ } } +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 (!libnet.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; - libnet.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); @@ -448,11 +556,11 @@ int _connection_libnet_init(void) bool _connection_libnet_deinit(void) { - if (libnet.registered) { + if (_connection_is_created() == true) { if (net_deregister_client_ext(NET_DEVICE_DEFAULT) != NET_ERR_NONE) return false; - libnet.registered = false; + __connection_set_created(false); if (profile_cb_table) { g_hash_table_destroy(profile_cb_table); @@ -523,7 +631,8 @@ int _connection_libnet_get_wifi_state(connection_wifi_state_e *state) *state = CONNECTION_WIFI_STATE_DEACTIVATED; break; case WIFI_ON: - case WIFI_CONNECTING: + case WIFI_ASSOCIATION: + case WIFI_CONFIGURATION: *state = CONNECTION_WIFI_STATE_DISCONNECTED; break; case WIFI_CONNECTED: @@ -531,7 +640,7 @@ int _connection_libnet_get_wifi_state(connection_wifi_state_e *state) *state = CONNECTION_WIFI_STATE_CONNECTED; break; default : - CONNECTION_LOG(CONNECTION_ERROR, "Error!! Unknown state\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Unknown Wi-Fi state"); return CONNECTION_ERROR_INVALID_OPERATION; } @@ -549,7 +658,7 @@ int _connection_libnet_get_ethernet_state(connection_ethernet_state_e* state) } if (ethernet_profiles.count == 0) { - state = CONNECTION_ETHERNET_STATE_DEACTIVATED; + *state = CONNECTION_ETHERNET_STATE_DEACTIVATED; return CONNECTION_ERROR_NONE; } @@ -566,6 +675,7 @@ int _connection_libnet_get_ethernet_state(connection_ethernet_state_e* state) *state = CONNECTION_ETHERNET_STATE_DISCONNECTED; break; default: + __libnet_clear_profile_list(ðernet_profiles); return CONNECTION_ERROR_OPERATION_FAILED; } @@ -647,60 +757,167 @@ done: int _connection_libnet_get_profile_iterator(connection_iterator_type_e type, connection_profile_iterator_h* profile_iter_h) { int count = 0; - int rv; + int rv1, rv2, rv3, rv4; net_profile_info_t *profiles = NULL; - struct _profile_list_s all_profiles = {0, 0, 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); - rv = net_get_profile_list(NET_DEVICE_MAX, &all_profiles.profiles, &all_profiles.count); + rv1 = net_get_profile_list(NET_DEVICE_WIFI, &wifi_profiles.profiles, &wifi_profiles.count); + 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; - if (rv != NET_ERR_NONE) { - if (rv == NET_ERR_NO_SERVICE) { - *profile_iter_h = &profile_iterator; - return CONNECTION_ERROR_NONE; - } else - return CONNECTION_ERROR_OPERATION_FAILED; + 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_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", cellular_profiles.count); + + rv3 = net_get_profile_list(NET_DEVICE_ETHERNET, ðernet_profiles.profiles, ðernet_profiles.count); + 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", 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(ðernet_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(ðernet_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 = all_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; - profile_iterator.profiles = all_profiles.profiles; + 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(ðernet_profiles); + __libnet_clear_profile_list(&bluetooth_profiles); + return CONNECTION_ERROR_OUT_OF_MEMORY; + } + + profile_iterator.profiles = profiles; + + if (wifi_profiles.count > 0) { + memcpy(profiles, wifi_profiles.profiles, + sizeof(net_profile_info_t) * wifi_profiles.count); + profiles += wifi_profiles.count; + } + + if (cellular_profiles.count > 0) { + memcpy(profiles, cellular_profiles.profiles, + sizeof(net_profile_info_t) * cellular_profiles.count); + profiles += cellular_profiles.count; + } + + 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(&all_profiles); - CONNECTION_LOG(CONNECTION_INFO, "Total connected profile count : %d\n", count); - + count = __libnet_get_connected_count(&wifi_profiles); + count += __libnet_get_connected_count(&cellular_profiles); + count += __libnet_get_connected_count(ðernet_profiles); + count += __libnet_get_connected_count(&bluetooth_profiles); + CONNECTION_LOG(CONNECTION_INFO, "Total connected 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(&all_profiles); + __libnet_clear_profile_list(&wifi_profiles); + __libnet_clear_profile_list(&cellular_profiles); + __libnet_clear_profile_list(ðernet_profiles); + __libnet_clear_profile_list(&bluetooth_profiles); return CONNECTION_ERROR_OUT_OF_MEMORY; + } + + profile_iterator.profiles = profiles; + + if (wifi_profiles.count > 0) + __libnet_copy_connected_profile(&profiles, &wifi_profiles); + + if (cellular_profiles.count > 0) + __libnet_copy_connected_profile(&profiles, &cellular_profiles); + + if (ethernet_profiles.count > 0) + __libnet_copy_connected_profile(&profiles, ðernet_profiles); + + if (bluetooth_profiles.count > 0) + __libnet_copy_connected_profile(&profiles, &bluetooth_profiles); + break; case CONNECTION_ITERATOR_TYPE_DEFAULT: - /* To do : Not supported yet */ - break; + 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(ðernet_profiles); + __libnet_clear_profile_list(&bluetooth_profiles); + return CONNECTION_ERROR_OUT_OF_MEMORY; } profile_iterator.profiles = profiles; - __libnet_copy_connected_profile(&profiles, &all_profiles); - - __libnet_clear_profile_list(&all_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(ðernet_profiles); + __libnet_clear_profile_list(&bluetooth_profiles); + profile_iterator.count = count; return CONNECTION_ERROR_NONE; @@ -784,7 +1001,8 @@ int _connection_libnet_reset_profile(connection_reset_option_e type, return CONNECTION_ERROR_NONE; } -int _connection_libnet_open_profile(connection_profile_h profile, connection_opened_cb callback, void* user_data) +int _connection_libnet_open_profile(connection_profile_h profile, + connection_opened_cb callback, void* user_data) { int rv; @@ -807,14 +1025,18 @@ int _connection_libnet_open_profile(connection_profile_h profile, connection_ope return CONNECTION_ERROR_NONE; } -int _connection_libnet_get_cellular_service_profile(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) { - int i = 0; - int j = 0; + int i = 0, j = 0; int rv = NET_ERR_NONE; - net_service_type_t service_type = _connection_profile_convert_to_libnet_cellular_service_type(type); +#if defined TIZEN_DUALSIM_ENABLE + int default_subscriber_id = 0; + char subscriber_id[3]; +#endif - struct _profile_list_s cellular_profiles = {0, 0, NULL}; + struct _profile_list_s cellular_profiles = { 0, 0, NULL }; + net_service_type_t service_type = _connection_profile_convert_to_libnet_cellular_service_type(type); rv = net_get_profile_list(NET_DEVICE_CELLULAR, &cellular_profiles.profiles, &cellular_profiles.count); if (rv == NET_ERR_ACCESS_DENIED) { @@ -825,16 +1047,37 @@ int _connection_libnet_get_cellular_service_profile(connection_cellular_service_ return CONNECTION_ERROR_OPERATION_FAILED; } - for (;i < cellular_profiles.count;i++) - if (cellular_profiles.profiles[i].ProfileInfo.Pdp.ServiceType == service_type) - break; +#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; + } - if (i >= cellular_profiles.count) + 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)); @@ -845,7 +1088,7 @@ int _connection_libnet_get_cellular_service_profile(connection_cellular_service_ type != CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET) goto done; - for (;j < cellular_profiles.count;j++) { + for (j = 0; j < cellular_profiles.count; j++) { if (i == j) continue; @@ -859,6 +1102,7 @@ int _connection_libnet_get_cellular_service_profile(connection_cellular_service_ } done: + __libnet_clear_profile_list(&cellular_profiles); prof_handle_list = g_slist_append(prof_handle_list, *profile); return CONNECTION_ERROR_NONE; @@ -869,7 +1113,7 @@ int _connection_libnet_set_cellular_service_profile_sync(connection_cellular_ser 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; } @@ -897,7 +1141,7 @@ int _connection_libnet_set_cellular_service_profile_async(connection_cellular_se 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; } @@ -926,7 +1170,7 @@ int _connection_libnet_close_profile(connection_profile_h profile, connection_cl 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; } @@ -939,9 +1183,6 @@ int _connection_libnet_close_profile(connection_profile_h profile, connection_cl } else if (rv != NET_ERR_NONE) return CONNECTION_ERROR_OPERATION_FAILED; - if (net_close_connection(profile_info->ProfileName) != NET_ERR_NONE) - return CONNECTION_ERROR_OPERATION_FAILED; - __libnet_set_closed_cb(callback, user_data); return CONNECTION_ERROR_NONE; @@ -1112,8 +1353,9 @@ bool _connection_libnet_add_to_profile_cb_list(connection_profile_h profile, profile_cb_info->callback = callback; profile_cb_info->user_data = user_data; + profile_cb_info->state = _profile_convert_to_cp_state(profile_info->ProfileState); - 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; } @@ -1121,6 +1363,7 @@ bool _connection_libnet_add_to_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; + if (g_hash_table_remove(profile_cb_table, profile_info->ProfileName) == TRUE) return true; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c44ab56..dea5547 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,9 @@ +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 ${dependents}) @@ -8,7 +11,8 @@ 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}) diff --git a/test/connection_test.c b/test/connection_test.c index dbe83c9..dde3efd 100755 --- a/test/connection_test.c +++ b/test/connection_test.c @@ -22,6 +22,7 @@ #include #include "net_connection.h" + #include #define RETURN_FAIL_DESTROY(x) {connection_profile_destroy(x); return -1;} @@ -48,7 +49,6 @@ static bool test_get_user_string(const char *msg, char *buf, int buf_size) } buf[rv-1]='\0'; - return true; } @@ -162,7 +162,7 @@ static void test_connection_opened_callback(connection_error_e result, void* use if (result == CONNECTION_ERROR_NONE) printf("Connection open Succeeded\n"); else - printf("Connection open Failed, err : %d\n", result); + printf("Connection open Failed, err : [%s]\n", test_print_error(result)); } static void test_connection_closed_callback(connection_error_e result, void* user_data) @@ -170,7 +170,7 @@ static void test_connection_closed_callback(connection_error_e result, void* use if (result == CONNECTION_ERROR_NONE) printf("Connection close Succeeded\n"); else - printf("Connection close Failed, err : %d\n", result); + 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) @@ -186,7 +186,7 @@ static void test_connection_set_default_callback(connection_error_e result, void if (result == CONNECTION_ERROR_NONE) printf("Default profile setting Succeeded\n"); else - printf("Default profile setting Failed, err : %d\n", result); + printf("Default profile setting Failed, err : [%s]\n", test_print_error(result)); } void test_get_ethernet_cable_state_callback(connection_ethernet_cable_state_e state, @@ -213,7 +213,7 @@ static bool test_get_user_selected_profile(connection_profile_h *profile, bool s 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; } @@ -251,8 +251,13 @@ static bool test_get_user_selected_profile(connection_profile_h *profile, bool s 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); + connection_cellular_service_type_e service_type; + if (connection_profile_get_cellular_service_type(profile_h, &service_type) != CONNECTION_ERROR_NONE) { + printf("Fail to get cellular service type!\n"); + } + + printf("%d. state:[%s], profile name:%s[%d]\n", + profile_count, test_print_state(profile_state), profile_name, service_type); profile_list[profile_count] = profile_h; profile_count++; @@ -325,18 +330,21 @@ static int test_update_cellular_info(connection_profile_h profile) 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; @@ -362,6 +370,8 @@ static int test_update_cellular_info(connection_profile_h profile) 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; @@ -486,7 +496,7 @@ static int test_update_network_info(connection_profile_h profile) { int rv = 0; int input_int = 0; - int address_family = 0; + int address_family; test_get_user_int("Input Address Family (0:IPv4 1:IPv6) :", &address_family); @@ -525,7 +535,6 @@ static int test_update_network_info(connection_profile_h profile) static void test_print_cellular_info(connection_profile_h profile) { - connection_cellular_network_type_e network_type; connection_cellular_service_type_e service_type; char *apn = NULL; connection_cellular_auth_type_e auth_type; @@ -536,11 +545,6 @@ static void test_print_cellular_info(connection_profile_h profile) bool hidden = false; bool editable = false; - if (connection_profile_get_cellular_network_type(profile, &network_type) != CONNECTION_ERROR_NONE) - printf("Fail to get cellular network type!\n"); - else - printf("Cellular network type : %d\n", network_type); - if (connection_profile_get_cellular_service_type(profile, &service_type) != CONNECTION_ERROR_NONE) printf("Fail to get cellular service type!\n"); else @@ -571,7 +575,7 @@ static void test_print_cellular_info(connection_profile_h profile) } if (connection_profile_is_cellular_roaming(profile, &roaming) != CONNECTION_ERROR_NONE) - printf("Fail to get cellular is roaming!\n"); + printf("Fail to get cellular roaming state!\n"); else printf("Cellular roaming : %s\n", roaming ? "true" : "false"); @@ -732,7 +736,7 @@ int test_register_client(void) connection_set_ethernet_cable_state_chaged_cb(connection, test_get_ethernet_cable_state_callback, NULL); } else { - printf("Client registration failed %d\n", err); + printf("Client registration failed [%s]\n", test_print_error(err)); return -1; } @@ -753,8 +757,8 @@ int test_deregister_client(void) 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; } @@ -782,11 +786,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; } @@ -799,11 +803,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; } @@ -816,11 +820,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; } @@ -978,7 +982,7 @@ int test_get_connected_profile_list(void) 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; } @@ -992,7 +996,7 @@ 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) { @@ -1021,7 +1025,7 @@ int test_get_current_profile(void) 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; } @@ -1063,7 +1067,7 @@ int test_get_default_cellular_service_type(void) 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); + "(1:Internet, 2:MMS, 3:Prepaid internet, 4:Prepaid MMS, 5:Tethering, 6:Application):", &input); if (rv == false) { printf("Invalid input!!\n"); @@ -1086,6 +1090,9 @@ int test_get_default_cellular_service_type(void) case 5: service_type = CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING; break; + case 6: + service_type = CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION; + break; default: printf("Wrong number!!\n"); return -1; @@ -1168,6 +1175,7 @@ int test_add_profile(void) 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); @@ -1230,8 +1238,8 @@ int test_update_profile(void) 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 */ @@ -1580,11 +1588,11 @@ int test_get_bt_state(void) rv = connection_get_bt_state(connection, &bt_state); if (rv != CONNECTION_ERROR_NONE) { - printf("Fail to get Bluetooth state [%d]\n", rv); + printf("Fail to get Bluetooth state [%s]\n", test_print_error(rv)); return -1; } - printf("Retval = %d, Bluetooth state [%d]\n", rv, bt_state); + printf("Retval = [%s], Bluetooth state [%d]\n", test_print_error(rv), bt_state); return 1; } @@ -1717,7 +1725,7 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) exit(1); } - if (*a == '\n' || *a == '\r'){ + 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"); @@ -1736,7 +1744,7 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) 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 only)\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"); @@ -1755,8 +1763,8 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) printf("x - Get ethernet cable state\n"); printf("B - Add IPv6 new route\n"); printf("C - Remove IPv6 route\n"); - printf("0 - Exit \n"); - printf("ENTER - Show options menu.......\n"); + printf("0 - Exit \n"); + printf("ENTER - Show options menu.......\n"); } switch (a[0]) { -- 2.7.4