diff options
Diffstat (limited to 'mobile')
-rw-r--r-- | mobile/AUTHORS | 2 | ||||
-rw-r--r-- | mobile/CMakeLists.txt | 95 | ||||
-rw-r--r-- | mobile/LICENSE.APLv2 | 202 | ||||
-rw-r--r-- | mobile/NOTICE | 3 | ||||
-rw-r--r-- | mobile/capi-network-connection.manifest | 5 | ||||
-rw-r--r-- | mobile/capi-network-connection.pc.in | 13 | ||||
-rw-r--r-- | mobile/debian/capi-network-connection-dev.install | 4 | ||||
-rw-r--r-- | mobile/debian/capi-network-connection-dev.postinst | 1 | ||||
-rw-r--r-- | mobile/debian/capi-network-connection.install | 1 | ||||
-rw-r--r-- | mobile/debian/capi-network-connection.postinst | 1 | ||||
-rw-r--r-- | mobile/debian/changelog | 514 | ||||
-rw-r--r-- | mobile/debian/compat | 1 | ||||
-rw-r--r-- | mobile/debian/control | 21 | ||||
-rwxr-xr-x | mobile/debian/rules | 67 | ||||
-rw-r--r-- | mobile/include/connection_profile.h | 772 | ||||
-rw-r--r-- | mobile/include/net_connection.h | 611 | ||||
-rw-r--r-- | mobile/include/net_connection_private.h | 104 | ||||
-rw-r--r-- | mobile/src/connection.c | 844 | ||||
-rwxr-xr-x | mobile/src/connection_profile.c | 1354 | ||||
-rwxr-xr-x | mobile/src/internal.c | 35 | ||||
-rwxr-xr-x | mobile/src/libnetwork.c | 820 | ||||
-rw-r--r-- | mobile/test/CMakeLists.txt | 19 | ||||
-rw-r--r-- | mobile/test/connection_test.c | 1522 |
23 files changed, 0 insertions, 7011 deletions
diff --git a/mobile/AUTHORS b/mobile/AUTHORS deleted file mode 100644 index 5c2063d..0000000 --- a/mobile/AUTHORS +++ /dev/null @@ -1,2 +0,0 @@ -Jeik Jaehyun Kim <jeik01.kim@samsung.com> -ByungWoo Lee <bw1212.lee@samsung.com> diff --git a/mobile/CMakeLists.txt b/mobile/CMakeLists.txt deleted file mode 100644 index b09dcb9..0000000 --- a/mobile/CMakeLists.txt +++ /dev/null @@ -1,95 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -SET(fw_name "capi-network-connection") - -PROJECT(${fw_name}) - -SET(CMAKE_INSTALL_PREFIX /usr) -SET(PREFIX ${CMAKE_INSTALL_PREFIX}) - -SET(INC_DIR include) -INCLUDE_DIRECTORIES(${INC_DIR}) - -SET(dependents "dlog vconf capi-base-common glib-2.0 network") -SET(pc_dependents "capi-base-common") - -INCLUDE(FindPkgConfig) -pkg_check_modules(${fw_name} REQUIRED ${dependents}) -FOREACH(flag ${${fw_name}_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -fvisibility=hidden") -SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") - -IF("${ARCH}" STREQUAL "arm") - ADD_DEFINITIONS("-DTARGET") -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}") - -aux_source_directory(src SOURCES) -ADD_LIBRARY(${fw_name} SHARED ${SOURCES}) - -TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS}) - -SET_TARGET_PROPERTIES(${fw_name} - PROPERTIES - VERSION ${FULLVER} - SOVERSION ${MAJORVER} - CLEAN_DIRECT_OUTPUT 1 -) - -INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR}) -INSTALL( - DIRECTORY ${INC_DIR}/ DESTINATION include/network - FILES_MATCHING - PATTERN "*_private.h" EXCLUDE - PATTERN "${INC_DIR}/*.h" - ) - -SET(PC_NAME ${fw_name}) -SET(PC_REQUIRED ${pc_dependents}) -SET(PC_LDFLAGS -l${fw_name}) - -CONFIGURE_FILE( - ${fw_name}.pc.in - ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc - @ONLY -) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) - -#ADD_SUBDIRECTORY(test) - -IF(UNIX) - -ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution) -ADD_CUSTOM_COMMAND( - DEPENDS clean - COMMENT "distribution clean" - COMMAND find - ARGS . - -not -name config.cmake -and \( - -name tester.c -or - -name Testing -or - -name CMakeFiles -or - -name cmake.depends -or - -name cmake.check_depends -or - -name CMakeCache.txt -or - -name cmake.check_cache -or - -name *.cmake -or - -name Makefile -or - -name core -or - -name core.* -or - -name gmon.out -or - -name install_manifest.txt -or - -name *.pc -or - -name *~ \) - | grep -v TC | xargs rm -rf - TARGET distclean - VERBATIM -) - -ENDIF(UNIX) diff --git a/mobile/LICENSE.APLv2 b/mobile/LICENSE.APLv2 deleted file mode 100644 index d645695..0000000 --- a/mobile/LICENSE.APLv2 +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the 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. diff --git a/mobile/NOTICE b/mobile/NOTICE deleted file mode 100644 index 0e0f016..0000000 --- a/mobile/NOTICE +++ /dev/null @@ -1,3 +0,0 @@ -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. diff --git a/mobile/capi-network-connection.manifest b/mobile/capi-network-connection.manifest deleted file mode 100644 index 97e8c31..0000000 --- a/mobile/capi-network-connection.manifest +++ /dev/null @@ -1,5 +0,0 @@ -<manifest> - <request> - <domain name="_"/> - </request> -</manifest> diff --git a/mobile/capi-network-connection.pc.in b/mobile/capi-network-connection.pc.in deleted file mode 100644 index ee6db75..0000000 --- a/mobile/capi-network-connection.pc.in +++ /dev/null @@ -1,13 +0,0 @@ -# Package Information for pkg-config - -prefix=@PREFIX@ -exec_prefix=/usr -libdir=/usr/lib -includedir=/usr/include/network - -Name: @PC_NAME@ -Description: @PACKAGE_DESCRIPTION@ -Version: @VERSION@ -Requires: @PC_REQUIRED@ -Libs: -L${libdir} @PC_LDFLAGS@ -Cflags: -I${includedir} diff --git a/mobile/debian/capi-network-connection-dev.install b/mobile/debian/capi-network-connection-dev.install deleted file mode 100644 index 761a28b..0000000 --- a/mobile/debian/capi-network-connection-dev.install +++ /dev/null @@ -1,4 +0,0 @@ -/usr/include/* -/usr/include/*/* -/usr/lib/pkgconfig/*.pc - diff --git a/mobile/debian/capi-network-connection-dev.postinst b/mobile/debian/capi-network-connection-dev.postinst deleted file mode 100644 index 1a24852..0000000 --- a/mobile/debian/capi-network-connection-dev.postinst +++ /dev/null @@ -1 +0,0 @@ -#!/bin/sh diff --git a/mobile/debian/capi-network-connection.install b/mobile/debian/capi-network-connection.install deleted file mode 100644 index 4a755a4..0000000 --- a/mobile/debian/capi-network-connection.install +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/lib*.so* diff --git a/mobile/debian/capi-network-connection.postinst b/mobile/debian/capi-network-connection.postinst deleted file mode 100644 index 1a24852..0000000 --- a/mobile/debian/capi-network-connection.postinst +++ /dev/null @@ -1 +0,0 @@ -#!/bin/sh diff --git a/mobile/debian/changelog b/mobile/debian/changelog deleted file mode 100644 index 9be7540..0000000 --- a/mobile/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 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Fri, 10 May 2013 17:59:58 +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 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Fri, 10 May 2013 17:34:40 +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 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Thu, 09 May 2013 21:19: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 <jeik01.kim@samsung.com> 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 <jeik01.kim@samsung.com> 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 <jeik01.kim@samsung.com> 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 <jeik01.kim@samsung.com> 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 <jeik01.kim@samsung.com> 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 <jeik01.kim@samsung.com> 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 <jeik01.kim@samsung.com> 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 <jeik01.kim@samsung.com> 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 <s.seo@samsung.com> 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 <jeik01.kim@samsung.com> 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 <jeik01.kim@samsung.com> 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 <jeik01.kim@samsung.com> 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 <jeik01.kim@samsung.com> 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 <s.seo@samsung.com> 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 <jeik01.kim@samsung.com> 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 <s.seo@samsung.com> 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 <jeik01.kim@samsung.com> 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 <jeik01.kim@samsung.com> 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 <jeik01.kim@samsung.com> Fri, 03 Aug 2012 16:51:25 +0900 - -capi-network-connection (0.1.1-8) unstable; urgency=low - - * Modify connection_create() and connection_destroy() API to assure thread safety - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.1-8 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Fri, 27 Jul 2012 12:36:54 +0900 - -capi-network-connection (0.1.1-7) unstable; urgency=low - - * Modify set/get statistics API to support dbus interface of net-config - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.1-7 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Fri, 06 Jul 2012 18:13:11 +0900 - -capi-network-connection (0.1.1-6) unstable; urgency=low - - * Modify connection_reset_statistics() to avoid vconf permission error - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.1-6 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Wed, 27 Jun 2012 19:06:32 +0900 - -capi-network-connection (0.1.1-5) unstable; urgency=low - - * Update TC - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.1-5 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Tue, 12 Jun 2012 18:49:08 +0900 - -capi-network-connection (0.1.1-4) unstable; urgency=low - - * Add profile initialization functions for user creation - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.1-4 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Tue, 12 Jun 2012 17:17:00 +0900 - -capi-network-connection (0.1.1-3) unstable; urgency=low - - * Implementation of connection_reset_statistics() - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.1-3 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Tue, 12 Jun 2012 16:34:52 +0900 - -capi-network-connection (0.1.1-2) unstable; urgency=low - - * Implementation of extened APIs again - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.1-2 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Tue, 29 May 2012 17:00:36 +0900 - -capi-network-connection (0.1.1-1) unstable; urgency=low - - * Rollback to capi-network-connection_0.1.0-23 - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.1-1 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Wed, 23 May 2012 20:56:07 +0900 - -capi-network-connection (0.1.1-0) unstable; urgency=low - - * Implementation of extened APIs - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.1-0 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Fri, 18 May 2012 14:57:49 +0900 - -capi-network-connection (0.1.0-23) unstable; urgency=low - - * Fix a bug which don't set user data in proxy callback setter - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-23 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Mon, 16 Apr 2012 12:02:47 +0900 - -capi-network-connection (0.1.0-22) unstable; urgency=low - - * Fix connection destroy bug - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-22 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Mon, 09 Apr 2012 20:54:57 +0900 - -capi-network-connection (0.1.0-21) unstable; urgency=low - - * Add ipv6 feature and update DTS code - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-21 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Fri, 30 Mar 2012 18:15:20 +0900 - -capi-network-connection (0.1.0-20) unstable; urgency=low - - * Update DTS code - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-20 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Tue, 20 Mar 2012 16:08:10 +0900 - -capi-network-connection (0.1.0-19) unstable; urgency=low - - * Revise spec for OBS - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-19 - - -- Danny Jeongseok Seo <s.seo@samsung.com> Sat, 17 Mar 2012 18:31:44 +0900 - -capi-network-connection (0.1.0-18) unstable; urgency=low - - * Implementation of new APIs and TC code - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-18 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Fri, 16 Mar 2012 18:46:37 +0900 - -capi-network-connection (0.1.0-17) unstable; urgency=low - - * Convert internal function to static function - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-17 - - -- ByungWoo Lee <bw1212.lee@samsung.com> Mon, 20 Feb 2012 17:55:42 +0900 - -capi-network-connection (0.1.0-16) unstable; urgency=low - - * Add versioning of library - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-16 - - -- ByungWoo Lee <bw1212.lee@samsung.com> Tue, 14 Feb 2012 17:23:56 +0900 - -capi-network-connection (0.1.0-15) unstable; urgency=low - - * Fix bugs and related DTS - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-15 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Tue, 07 Feb 2012 19:09:07 +0900 - -capi-network-connection (0.1.0-14) unstable; urgency=low - - * Update DTS - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-14 - - -- ByungWoo Lee <bw1212.lee@samsung.com> Fri, 27 Jan 2012 18:18:29 +0900 - -capi-network-connection (0.1.0-13) unstable; urgency=low - - * License and Boilerplate update. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-13 - - -- Sanjeev BA <as2902.b@samsung.com> Tue, 06 Dec 2011 18:48:48 +0900 - -capi-network-connection (0.1.0-12) unstable; urgency=low - - * Bump up version. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-12 - - -- Sanjeev BA <as2902.b@samsung.com> Thu, 01 Dec 2011 19:40:16 +0900 - -capi-network-connection (0.1.0-11) unstable; urgency=low - - * Add data connection statistics. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-11 - - -- Sanjeev BA <as2902.b@samsung.com> Thu, 01 Dec 2011 19:18:24 +0900 - -capi-network-connection (0.1.0-10) unstable; urgency=low - - * Cleanup of vconf notifications. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-10 - - -- Sanjeev BA <as2902.b@samsung.com> Thu, 01 Dec 2011 11:08:59 +0900 - -capi-network-connection (0.1.0-9) unstable; urgency=low - - * Renaming for tizen. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-9 - - -- Sanjeev BA <as2902.b@samsung.com> Wed, 30 Nov 2011 15:10:59 +0900 - -capi-network-connection (0.1.0-8) unstable; urgency=low - - * Renaming for tizen. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-8 - - -- Sanjeev BA <as2902.b@samsung.com> Wed, 23 Nov 2011 15:07:23 +0900 - -capi-network-connection (0.1.0-7) unstable; urgency=low - - * Correct status updates. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-7 - - -- Sanjeev BA <as2902.b@samsung.com> Wed, 23 Nov 2011 13:46:23 +0900 - -capi-network-connection (0.1.0-6) unstable; urgency=low - - * Correct status updates. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-6 - - -- Sanjeev BA <as2902.b@samsung.com> Thu, 17 Nov 2011 15:10:55 +0900 - -capi-network-connection (0.1.0-5) unstable; urgency=low - - * Correct status updates. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-5 - - -- Sanjeev BA <as2902.b@samsung.com> Fri, 04 Nov 2011 17:55:49 +0900 - -capi-network-connection (0.1.0-4) unstable; urgency=low - - * Fix boilerplate. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-4 - - -- Sanjeev BA <as2902.b@samsung.com> Fri, 04 Nov 2011 11:22:10 +0900 - -capi-network-connection (0.1.0-3) unstable; urgency=low - - * Fix doxygen comments. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-3 - - -- Sanjeev BA <as2902.b@samsung.com> Mon, 31 Oct 2011 20:13:02 +0900 - -capi-network-connection (0.1.0-2) unstable; urgency=low - - * Add new mappings between vconf and connection_network_param_e. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-2 - - -- Sanjeev BA <as2902.b@samsung.com> Fri, 14 Oct 2011 19:37:05 +0900 - -capi-network-connection (0.1.0-1) unstable; urgency=low - - * Alpha Release - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.0-1 - - -- Kangho Hur <kangho.hur@samsung.com> Tue, 27 Sep 2011 20:35:08 +0900 - -capi-network-connection (0.0.1-11) unstable; urgency=low - - * Fix build error from sbs using (sbs --clean-build). - * Updated debian/control file to add build depedency. - * Git: framework/api/connection - * Tag: capi-network-connection_0.0.1-11 - - -- Sanjeev BA <as2902.b@samsung.com> Thu, 08 Sep 2011 17:36:05 +0900 - -capi-network-connection (0.0.1-10) unstable; urgency=low - - * Fix as per new libnetwork API. - * remove dnet dependency, use only vconf. - * Git: framework/api/connection - * Tag: capi-network-connection_0.0.1-10 - - -- Sanjeev BA <as2902.b@samsung.com> Wed, 07 Sep 2011 14:19:30 +0900 - -capi-network-connection (0.0.1-9) unstable; urgency=low - - * Add param_name to callbacks. Will help apps identify what has changed. - * Git: framework/api/connection - * Tag: capi-network-connection_0.0.1-9 - - -- Sanjeev BA <as2902.b@samsung.com> Fri, 02 Sep 2011 10:20:09 +0900 - -capi-network-connection (0.0.1-8) unstable; urgency=low - - * Cleanup unused code. Fix documentation. - * Git: framework/api/connection - * Tag: capi-network-connection_0.0.1-8 - - -- Sanjeev BA <as2902.b@samsung.com> Thu, 01 Sep 2011 20:03:11 +0900 - -capi-network-connection (0.0.1-7) unstable; urgency=low - - * Fix handles. - * Git: framework/api/connection - * Tag: capi-network-connection_0.0.1-7 - - - -- Sanjeev BA <as2902.b@samsung.com> Mon, 22 Aug 2011 14:31:53 +0900 - -capi-network-connection (0.0.1-6) unstable; urgency=low - - * Fix handles. - * Git: framework/api/connection - * Tag: capi-network-connection_0.0.1-6 - - -- Sanjeev BA <as2902.b@samsung.com> Thu, 18 Aug 2011 09:50:20 +0900 - -capi-network-connection (0.0.1-5) unstable; urgency=low - - * Fix debain packaging issue. - * Git: framework/api/connection - * Tag: capi-network-connection_0.0.1-5 - - -- Sanjeev BA <as2902.b@samsung.com> Thu, 11 Aug 2011 19:28:50 +0900 - -capi-network-connection (0.0.1-4) unstable; urgency=low - - * Fix regression test case that was never used before. - * Git: framework/api/connection - * Tag: capi-network-connection_0.0.1-4 - - -- Sanjeev BA <as2902.b@samsung.com> Thu, 04 Aug 2011 19:04:04 +0900 - -capi-network-connection (0.0.1-3) unstable; urgency=low - - * Add missing pc.in file. - * Git: framework/api/connection - * Tag: capi-network-connection_0.0.1-3 - - -- Sanjeev BA <as2902.b@samsung.com> Thu, 04 Aug 2011 18:04:33 +0900 - -capi-network-connection (0.0.1-2) unstable; urgency=low - - * Initial Upload - * Git: framework/api/connection - * Tag: capi-network-connection_0.0.1-2 - - -- Sanjeev BA <as2902.b@samsung.com> Thu, 04 Aug 2011 17:32:41 +0900 diff --git a/mobile/debian/compat b/mobile/debian/compat deleted file mode 100644 index 7f8f011..0000000 --- a/mobile/debian/compat +++ /dev/null @@ -1 +0,0 @@ -7 diff --git a/mobile/debian/control b/mobile/debian/control deleted file mode 100644 index bfc5f03..0000000 --- a/mobile/debian/control +++ /dev/null @@ -1,21 +0,0 @@ -Source: capi-network-connection -Section: libs -Priority: extra -Maintainer: JaeHyun Kim <jeik01.kim@samsung.com> -Build-Depends: debhelper (>= 5), dlog-dev, capi-base-common-dev, libvconf-dev, libglib2.0-dev, 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/mobile/debian/rules b/mobile/debian/rules deleted file mode 100755 index 678a339..0000000 --- a/mobile/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/mobile/include/connection_profile.h b/mobile/include/connection_profile.h deleted file mode 100644 index 1f37c06..0000000 --- a/mobile/include/connection_profile.h +++ /dev/null @@ -1,772 +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. - */ - -#ifndef __TIZEN_NETWORK_CONNECTION_PROFILE_H__ -#define __TIZEN_NETWORK_CONNECTION_PROFILE_H__ - -#include <tizen.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/** -* @addtogroup CAPI_NETWORK_CONNECTION_WIFI_PROFILE_MODULE -* @{ -*/ - -/** -* @brief Security type of Wi-Fi -*/ -typedef enum -{ - CONNECTION_WIFI_SECURITY_TYPE_NONE = 0, /**< Security disabled */ - CONNECTION_WIFI_SECURITY_TYPE_WEP = 1, /**< WEP */ - CONNECTION_WIFI_SECURITY_TYPE_WPA_PSK = 2, /**< WPA-PSK */ - CONNECTION_WIFI_SECURITY_TYPE_WPA2_PSK = 3, /**< WPA2-PSK */ - CONNECTION_WIFI_SECURITY_TYPE_EAP = 4, /**< EAP */ -} connection_wifi_security_type_e; - -/** -* @brief Below encryption modes are used in infrastructure and ad-hoc mode -*/ -typedef enum -{ - CONNECTION_WIFI_ENCRYPTION_TYPE_NONE = 0, /**< Encryption disabled */ - CONNECTION_WIFI_ENCRYPTION_TYPE_WEP = 1, /**< WEP */ - CONNECTION_WIFI_ENCRYPTION_TYPE_TKIP = 2, /**< TKIP */ - CONNECTION_WIFI_ENCRYPTION_TYPE_AES = 3, /**< AES */ - CONNECTION_WIFI_ENCRYPTION_TYPE_TKIP_AES_MIXED = 4, /**< TKIP and AES are both supported */ -} connection_wifi_encryption_type_e; - -/** -* @} -*/ - - -/** -* @addtogroup CAPI_NETWORK_CONNECTION_CELLULAR_PROFILE_MODULE -* @{ -*/ - -/** -* @brief This enumeration defines the cellular protocol type. -*/ -typedef enum -{ - CONNECTION_CELLULAR_NETWORK_TYPE_UNKNOWN = 0, /**< Not defined */ - CONNECTION_CELLULAR_NETWORK_TYPE_GPRS = 1, /**< GPRS type */ - CONNECTION_CELLULAR_NETWORK_TYPE_EDGE = 2, /**< EDGE type */ - CONNECTION_CELLULAR_NETWORK_TYPE_UMTS = 3, /**< UMTS type */ -} connection_cellular_network_type_e; - -/** -* @breif This enum indicates cellular service type -*/ -typedef enum -{ - CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN = 0, /**< Unknown */ - CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET = 1, /**< Internet */ - CONNECTION_CELLULAR_SERVICE_TYPE_MMS = 2, /**< MMS */ - CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET = 3, /**< Prepaid internet */ - CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS = 4, /**< Prepaid MMS */ - CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING = 5, /**< Tethering */ - CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION = 6, /**< Specific application */ -} connection_cellular_service_type_e; - -/** -* @brief Cellular Authentication Type -*/ -typedef enum -{ - CONNECTION_CELLULAR_AUTH_TYPE_NONE = 0, /**< No authentication */ - CONNECTION_CELLULAR_AUTH_TYPE_PAP = 1, /**< PAP authentication */ - CONNECTION_CELLULAR_AUTH_TYPE_CHAP = 2, /**< CHAP authentication */ -} connection_cellular_auth_type_e; - -/** -* @} -*/ - - -/** -* @addtogroup CAPI_NETWORK_CONNECTION_PROFILE_MODULE -* @{ -*/ - -/** -* @brief The handle of profile -*/ -typedef void* connection_profile_h; - -/** -* @brief This enumeration defines the profile state type. -*/ -typedef enum -{ - CONNECTION_PROFILE_STATE_DISCONNECTED = 0, /**< Disconnected state */ - CONNECTION_PROFILE_STATE_ASSOCIATION = 1, /**< Association state */ - CONNECTION_PROFILE_STATE_CONFIGURATION = 2, /**< Configuration state */ - CONNECTION_PROFILE_STATE_CONNECTED = 3, /**< Connected state */ -} connection_profile_state_e; - -/** -* @brief Enumerations of Address family -*/ -typedef enum -{ - CONNECTION_ADDRESS_FAMILY_IPV4 = 0, /**< IPV4 Address type */ - CONNECTION_ADDRESS_FAMILY_IPV6 = 1, /**< IPV6 Address type */ -} connection_address_family_e; - -/** -* @brief Net IP configuration Type -*/ -typedef enum -{ - CONNECTION_IP_CONFIG_TYPE_NONE = 0, /**< Not defined */ - CONNECTION_IP_CONFIG_TYPE_STATIC = 1, /**< Manual IP configuration */ - CONNECTION_IP_CONFIG_TYPE_DYNAMIC = 2, /**< Config IP using DHCP client*/ - CONNECTION_IP_CONFIG_TYPE_AUTO = 3, /**< Config IP from Auto IP pool (169.254/16). Later with DHCP client, if available */ - CONNECTION_IP_CONFIG_TYPE_FIXED = 4, /**< Indicates an IP address that can not be modified */ -} connection_ip_config_type_e; - -/** -* @brief This enumeration defines the proxy method type. -*/ -typedef enum -{ - CONNECTION_PROXY_TYPE_DIRECT = 0, /**< Direct connection */ - CONNECTION_PROXY_TYPE_AUTO = 1, /**< Auto configuration(Use PAC file). If URL property is not set, DHCP/WPAD auto-discover will be tried */ - CONNECTION_PROXY_TYPE_MANUAL = 2, /**< Manual configuration */ -} connection_proxy_type_e; - -/** -* @enum connection_profile_type_e -* @brief Enumerations of network connection type. -*/ -typedef enum{ - CONNECTION_PROFILE_TYPE_CELLULAR = 0, /**< Cellular type */ - CONNECTION_PROFILE_TYPE_WIFI = 1, /**< Wi-Fi type */ - CONNECTION_PROFILE_TYPE_ETHERNET = 2, /**< Ethernet type */ - CONNECTION_PROFILE_TYPE_BT = 3, /**< Bluetooth type */ -} connection_profile_type_e; - -/** -* @brief Creates the profile handle. -* @details The profile name, which is got from connection_profile_get_name(), will include the keyword you set. -* @remarks @a profile must be released with connection_profile_destroy(). -* @param[in] type The type of profile. #CONNECTION_PROFILE_TYPE_CELLULAR is only supported. -* @param[in] keyword The keyword included in profile name -* @param[out] profile The handle of the profile -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory -* @see connection_profile_destroy() -* @see connection_profile_get_name() -*/ -int connection_profile_create(connection_profile_type_e type, const char* keyword, connection_profile_h* profile); - -/** -* @brief Destroys the profile handle. -* @param[out] connection The handle to the connection -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @see connection_profile_create() -*/ -int connection_profile_destroy(connection_profile_h profile); - -/** -* @brief Clons the profile handle. -* @remarks @a cloned_profile must be released with connection_profile_destroy(). -* @param[in] origin_profile The handle of origin profile -* @param[out] cloned_profile The handle of cloned profile -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory -* @see connection_profile_destroy() -*/ -int connection_profile_clone(connection_profile_h* cloned_profile, connection_profile_h origin_profile); - -/** -* @brief Gets the profile ID. -* @details The separate profiles can have the same name. -* So, you must use this API instead of connection_profile_get_name() if you want to get the unique identification. -* In case that you create a profile, this value will be determined when you add the profile. -* @remarks @a profile_id must be released with free() by you. -* @param[in] profile The handle of profile -* @param[out] profile_id The ID of profile -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory -* @see connection_profile_get_name() -* @see connection_add_profile() -*/ -int connection_profile_get_id(connection_profile_h profile, char** profile_id); - -/** -* @brief Gets the profile name. -* @remarks @a profile_name must be released with free() by you. -* @param[in] profile The handle of profile -* @param[out] profile_name The name of profile -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory -* @see connection_profile_get_id() -*/ -int connection_profile_get_name(connection_profile_h profile, char** profile_name); - -/** -* @brief Gets the network type. -* @param[in] profile The handle of profile -* @param[out] type The type of profile -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -*/ -int connection_profile_get_type(connection_profile_h profile, connection_profile_type_e* type); - -/** -* @brief Gets the name of network interface. For example, eth0 and pdp0. -* @remarks @a interface_name must be released with free() by you. -* @param[in] profile The handle of profile -* @param[out] interface_name The name of network interface -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory -*/ -int connection_profile_get_network_interface_name(connection_profile_h profile, char** interface_name); - -/** -* @brief Refresh the profile information. -* @remarks You should call this function in order to get the current information because the profile information can be changed. -* @param[in] profile The handle of profile -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory -*/ -int connection_profile_refresh(connection_profile_h profile); - -/** -* @brief Gets the network type. -* @param[in] profile The handle of profile -* @param[out] state The state of profile -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -*/ -int connection_profile_get_state(connection_profile_h profile, connection_profile_state_e* state); - -/** -* @brief Gets the IP config type. -* @param[in] profile The handle of profile -* @param[in] address_family The address family -* @param[out] type The type of IP config -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -*/ -int connection_profile_get_ip_config_type(connection_profile_h profile, connection_address_family_e address_family, connection_ip_config_type_e* type); - -/** -* @brief Gets the IP address. -* @remarks @a ip_address must be released with free() by you. -* @param[in] profile The handle of profile -* @param[in] address_family The address family -* @param[out] ip_address The IP address -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory -* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -*/ -int connection_profile_get_ip_address(connection_profile_h profile, connection_address_family_e address_family, char** ip_address); - -/** -* @brief Gets the Subnet Mask. -* @remarks @a subnet_mask must be released with free() by you. -* @param[in] profile The handle of profile -* @param[in] address_family The address family -* @param[out] subnet_mask The subnet mask -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory -* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -*/ -int connection_profile_get_subnet_mask(connection_profile_h profile, connection_address_family_e address_family, char** subnet_mask); - -/** -* @brief Gets the Gateway address. -* @remarks @a gateway_address must be released with free() by you. -* @param[in] profile The handle of profile -* @param[in] address_family The address family -* @param[out] gateway_address The gateway address -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory -* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -*/ -int connection_profile_get_gateway_address(connection_profile_h profile, connection_address_family_e address_family, char** gateway_address); - -/** -* @brief Gets the DNS address. -* @remarks The allowance of DNS address is 2. @a dns_address must be released with free() by you. -* @param[in] profile The handle of profile -* @param[in] order The order of DNS address. It starts from 1, which means first DNS address. -* @param[in] address_family The address family -* @param[out] dns_address The DNS address -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory -* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -*/ -int connection_profile_get_dns_address(connection_profile_h profile, int order, connection_address_family_e address_family, char** dns_address); - -/** -* @brief Gets the Proxy type. -* @param[in] profile The handle of profile -* @param[out] type The type of proxy -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -*/ -int connection_profile_get_proxy_type(connection_profile_h profile, connection_proxy_type_e* type); - -/** -* @brief Gets the Proxy address. -* @remarks @a proxy_address must be released with free() by you. -* @param[in] profile The handle of profile -* @param[in] address_family The address family -* @param[out] proxy_address The proxy address -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory -* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -*/ -int connection_profile_get_proxy_address(connection_profile_h profile, connection_address_family_e address_family, char** proxy_address); - -/** -* @brief Sets the IP config type. -* @details If you set IP config type to #WIFI_IP_CONFIG_TYPE_STATIC, -* then IP address, Gateway and Subnet mask will be set to the initial value "0.0.0.0". -* @param[in] profile The handle of profile -* @param[in] address_family The address family -* @param[in] type The type of IP config -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -*/ -int connection_profile_set_ip_config_type(connection_profile_h profile, connection_address_family_e address_family, connection_ip_config_type_e type); - -/** -* @brief Sets the IP address. -* @param[in] profile The handle of profile -* @param[in] address_family The address family -* @param[in] ip_address The IP address. If you set this value to NULL, then the existing value will be deleted. -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -* @see connection_update_profile() -*/ -int connection_profile_set_ip_address(connection_profile_h profile, connection_address_family_e address_family, const char* ip_address); - -/** -* @brief Sets the Subnet Mask. -* @param[in] profile The handle of profile -* @param[in] address_family The address family -* @param[in] subnet_mask The subnet mask. If you set this value to NULL, then the existing value will be deleted. -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -* @see connection_update_profile() -*/ -int connection_profile_set_subnet_mask(connection_profile_h profile, connection_address_family_e address_family, const char* subnet_mask); - -/** -* @brief Sets the Gateway address. -* @param[in] profile The handle of profile -* @param[in] address_family The address family -* @param[in] gateway_address The gateway address. If you set this value to NULL, then the existing value will be deleted. -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -* @see connection_update_profile() -*/ -int connection_profile_set_gateway_address(connection_profile_h profile, connection_address_family_e address_family, const char* gateway_address); - -/** -* @brief Sets the DNS address. -* @remarks The allowance of DNS address is 2. -* @param[in] profile The handle of profile -* @param[in] order The order of DNS address. It starts from 1, which means first DNS address. -* @param[in] address_family The address family -* @param[in] dns_address The DNS address. If you set this value to NULL, then the existing value will be deleted. -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -* @see connection_update_profile() -*/ -int connection_profile_set_dns_address(connection_profile_h profile, int order, connection_address_family_e address_family, const char* dns_address); - -/** -* @brief Sets the Proxy type. -* @details If you set Proxy type to #WIFI_PROXY_TYPE_AUTO or #WIFI_PROXY_TYPE_MANUAL, then Proxy will be restored. -* @param[in] profile The handle of profile -* @param[in] type The type of proxy -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -* @see connection_update_profile() -*/ -int connection_profile_set_proxy_type(connection_profile_h profile, connection_proxy_type_e type); - -/** -* @brief Sets the Proxy address. -* @param[in] profile The handle of profile -* @param[in] address_family The address family -* @param[in] proxy_address The proxy address. If you set this value to NULL, then the existing value will be deleted. -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -* @see connection_update_profile() -*/ -int connection_profile_set_proxy_address(connection_profile_h profile, connection_address_family_e address_family, const char* proxy_address); - -/** -* @brief Called when the state of profile is changed. -* @param[in] state The state -* @param[in] user_data The user data passed from the callback registration function -* @see connection_profile_set_state_changed_cb() -* @see connection_profile_unset_state_changed_cb() -*/ -typedef void(*connection_profile_state_changed_cb)(connection_profile_state_e state, void* user_data); - -/** -* @brief Registers the callback called when the state of profile is changed. -* @param[in] profile The handle of profile -* @param[in] callback The callback function to be called -* @param[in] user_data The user data passed to the callback function -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -* @post connection_opened_cb() is invoked when the state of profile is changed. -* @see connection_profile_state_changed_cb() -* @see connection_profile_unset_state_changed_cb() -*/ -int connection_profile_set_state_changed_cb(connection_profile_h profile, connection_profile_state_changed_cb callback, void* user_data); - -/** -* @brief Unregisters the callback called when the state of profile is changed. -* @param[in] profile The handle of profile -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @see connection_profile_state_changed_cb() -* @see connection_profile_set_state_changed_cb() -*/ -int connection_profile_unset_state_changed_cb(connection_profile_h profile); - -/** -* @} -*/ - - -/** -* @addtogroup CAPI_NETWORK_CONNECTION_WIFI_PROFILE_MODULE -* @{ -*/ - -/** -* @brief Gets the ESSID(Extended Service Set Identifier). -* @remarks @a essid must be released with free() by you. -* @param[in] profile The handle of profile -* @param[out] essid The ESSID -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory -*/ -int connection_profile_get_wifi_essid(connection_profile_h profile, char** essid); - -/** -* @brief Gets the BSSID(Basic Service Set Identifier). -* @remarks @a bssid must be released with free() by you. -* @param[in] profile The handle of profile -* @param[out] bssid The BSSID -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory -*/ -int connection_profile_get_wifi_bssid(connection_profile_h profile, char** bssid); - -/** -* @brief Gets the RSSI. -* @param[in] profile The handle of profile -* @param[out] rssi The RSSI -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -*/ -int connection_profile_get_wifi_rssi(connection_profile_h profile, int* rssi); - -/** -* @brief Gets the frequency (MHz). -* @param[in] profile The handle of profile -* @param[out] frequency The frequency -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -*/ -int connection_profile_get_wifi_frequency(connection_profile_h profile, int* frequency); - -/** -* @brief Gets the max speed (Mbps). -* @param[in] profile The handle of profile -* @param[out] max_speed The max speed -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -*/ -int connection_profile_get_wifi_max_speed(connection_profile_h profile, int* max_speed); - -/** -* @brief Gets the security mode of Wi-Fi. -* @param[in] profile The handle of profile -* @param[out] type The type of Wi-Fi security -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -*/ -int connection_profile_get_wifi_security_type(connection_profile_h profile, connection_wifi_security_type_e* type); - -/** -* @brief Gets the security mode of Wi-Fi. -* @param[in] profile The handle of profile -* @param[out] type The type of Wi-Fi security -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -*/ -int connection_profile_get_wifi_encryption_type(connection_profile_h profile, connection_wifi_encryption_type_e* type); - -/** -* @brief Checks whether passphrase is required. -* @remarks This function is not valid if security type is #WIFI_SECURITY_TYPE_EAP. -* @param[in] profile The handle of profile -* @param[out] required Indicates whether passphrase is required or not -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -*/ -int connection_profile_is_wifi_passphrase_required(connection_profile_h profile, bool* required); - -/** -* @brief Sets the passphrase of Wi-Fi WPA. -* @param[in] profile The handle of profile -* @param[in] passphrase The passphrase of Wi-Fi security -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @see connection_update_profile() -*/ -int connection_profile_set_wifi_passphrase(connection_profile_h profile, const char* passphrase); - -/** -* @brief Checks whether WPS(Wi-Fi Protected Setup) is supported. -* @remarks If WPS is supported, you can connect access point with WPS by wifi_connect_with_wps(). -* @param[in] profile The handle of profile -* @param[out] supported Indicates whether WPS is supported or not -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -*/ -int connection_profile_is_wifi_wps_supported(connection_profile_h profile, bool* supported); - -/** -* @} -*/ - - -/** -* @addtogroup CAPI_NETWORK_CONNECTION_CELLULAR_PROFILE_MODULE -* @{ -*/ - -/** -* @brief Gets the cellular network type. -* @param[in] profile The handle of profile -* @param[out] type The type of cellular -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -*/ -int connection_profile_get_cellular_network_type(connection_profile_h profile, connection_cellular_network_type_e* type); - -/** -* @brief Gets the service type. -* @param[in] profile The handle of profile -* @param[out] type The type of cellular service -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -*/ -int connection_profile_get_cellular_service_type(connection_profile_h profile, connection_cellular_service_type_e* type); - -/** -* @brief Gets the APN(access point name). -* @remarks @a apn must be released with free() by you. -* @param[in] profile The handle of profile -* @param[out] apn The name of APN -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory -*/ -int connection_profile_get_cellular_apn(connection_profile_h profile, char** apn); - -/** -* @brief Gets the authentication information. -* @remarks @a user_name and @a password must be released with free() by you. -* @param[in] profile The handle of profile -* @param[out] type The type of authentication -* @param[out] user_name The user name -* @param[out] password The password -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory -* @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed -*/ -int connection_profile_get_cellular_auth_info(connection_profile_h profile, connection_cellular_auth_type_e* type, char** user_name, char** password); - -/** -* @brief Gets the home URL. -* @remarks @a home_url must be released with free() by you. -* @param[in] profile The handle of profile -* @param[out] home_url The home URL -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory -*/ -int connection_profile_get_cellular_home_url(connection_profile_h profile, char** home_url); - -/** -* @brief Gets the state of roaming. -* @param[in] profile The handle of profile -* @param[out] is_roaming Indicates whether cellular is in roaming or not -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -*/ -int connection_profile_is_cellular_roaming(connection_profile_h profile, bool* is_roaming); - -/** -* @brief Sets the service type. -* @param[in] profile The handle of profile -* @param[out] type The type of cellular service -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @see connection_update_profile() -*/ -int connection_profile_set_cellular_service_type(connection_profile_h profile, connection_cellular_service_type_e service_type); - -/** -* @brief Sets the APN(Access Point Name). -* @param[in] profile The handle of profile -* @param[out] apn The name of APN -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @see connection_update_profile() -*/ -int connection_profile_set_cellular_apn(connection_profile_h profile, const char* apn); - -/** -* @brief Sets the Athentication information. -* @param[in] profile The handle of profile -* @param[out] type The type of authentication -* @param[out] user_name The user name -* @param[out] password The password -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @see connection_update_profile() -*/ -int connection_profile_set_cellular_auth_info(connection_profile_h profile, connection_cellular_auth_type_e type, const char* user_name, const char* password); - -/** -* @brief Sets the home URL. -* @param[in] profile The handle of profile -* @param[out] home_url The home URL -* @return 0 on success, otherwise negative error value. -* @retval #CONNECTION_ERROR_NONE Successful -* @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter -* @see connection_update_profile() -*/ -int connection_profile_set_cellular_home_url(connection_profile_h profile, const char* home_url); - -/** -* @} -*/ - - -#ifdef __cplusplus -} - -#endif - -#endif /* __TIZEN_NETWORK_CONNECTION_PROFILE_H__ */ diff --git a/mobile/include/net_connection.h b/mobile/include/net_connection.h deleted file mode 100644 index 20fe740..0000000 --- a/mobile/include/net_connection.h +++ /dev/null @@ -1,611 +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. - */ - -#ifndef __NET_CONNECTION_INTF_H__ -#define __NET_CONNECTION_INTF_H__ - -#include "connection_profile.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/** - * @addtogroup CAPI_NETWORK_CONNECTION_MANAGER_MODULE - * @{ - */ - -/** - * @brief The connection handle for all connection functions. -*/ -typedef void* connection_h; - -/** - * @brief The iterator handle for profiles. -*/ -typedef void* connection_profile_iterator_h; - -/** - * @brief Enumerations of connection type. - */ -typedef enum -{ - CONNECTION_TYPE_DISCONNECTED = 0, /**< Disconnected */ - CONNECTION_TYPE_WIFI = 1, /**< Wi-Fi type */ - CONNECTION_TYPE_CELLULAR = 2, /**< Cellular type */ - CONNECTION_TYPE_ETHERNET = 3, /**< Ethernet type */ - CONNECTION_TYPE_BT = 4, /**< Bluetooth type */ -} connection_type_e; - -/** - * @brief Enumerations of cellular network state. - */ -typedef enum -{ - CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE = 0, /**< Out of service */ - CONNECTION_CELLULAR_STATE_FLIGHT_MODE = 1, /**< Flight mode */ - CONNECTION_CELLULAR_STATE_ROAMING_OFF = 2, /**< Roaming is turned off */ - CONNECTION_CELLULAR_STATE_CALL_ONLY_AVAILABLE = 3, /**< Call is only available */ - CONNECTION_CELLULAR_STATE_AVAILABLE = 4, /**< Available but not connected yet */ - CONNECTION_CELLULAR_STATE_CONNECTED = 5, /**< Connected */ -} connection_cellular_state_e; - -/** - * @brief This enumeration defines the Wi-Fi state. - */ -typedef enum -{ - CONNECTION_WIFI_STATE_DEACTIVATED = 0, /**< Wi-Fi is deactivated */ - CONNECTION_WIFI_STATE_DISCONNECTED = 1, /**< Disconnected */ - CONNECTION_WIFI_STATE_CONNECTED = 2, /**< Connected */ -} connection_wifi_state_e; - -/** - * @brief This enumeration defines the ethernet state. - */ -typedef enum -{ - CONNECTION_ETHERNET_STATE_DEACTIVATED = 0, /**< There is no Ethernet profile to open */ - CONNECTION_ETHERNET_STATE_DISCONNECTED = 1, /**< Disconnected */ - CONNECTION_ETHERNET_STATE_CONNECTED = 2, /**< Connected */ -} connection_ethernet_state_e; - -/** - * @brief This enumeration defines the Bluetooth state. - */ -typedef enum -{ - CONNECTION_BT_STATE_DEACTIVATED = 0, /**< There is no Bluetooth profile to open */ - CONNECTION_BT_STATE_DISCONNECTED = 1, /**< Disconnected */ - CONNECTION_BT_STATE_CONNECTED = 2, /**< Connected */ -} connection_bt_state_e; - -/** - * @brief This enumeration defines the type of connection iterator. - */ -typedef enum -{ - CONNECTION_ITERATOR_TYPE_REGISTERED = 0, /**< The iterator of registered profile */ - CONNECTION_ITERATOR_TYPE_CONNECTED = 1, /**< The iterator of connected profile */ -} connection_iterator_type_e; - -/** - * @brief Enumerations of connection errors. - */ -typedef enum -{ - CONNECTION_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - CONNECTION_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - CONNECTION_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory error */ - CONNECTION_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid Operation */ - CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED = TIZEN_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED, /**< Address family not supported */ - CONNECTION_ERROR_OPERATION_FAILED = TIZEN_ERROR_NETWORK_CLASS|0x0401, /**< Operation failed */ - CONNECTION_ERROR_ITERATOR_END = TIZEN_ERROR_NETWORK_CLASS|0x0402, /**< End of iteration */ - CONNECTION_ERROR_NO_CONNECTION = TIZEN_ERROR_NETWORK_CLASS|0x0403, /**< There is no connection */ - CONNECTION_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /** Now in progress */ - CONNECTION_ERROR_ALREADY_EXISTS = TIZEN_ERROR_NETWORK_CLASS|0x0404, /**< Already exists */ - CONNECTION_ERROR_OPERATION_ABORTED = TIZEN_ERROR_NETWORK_CLASS|0x0405, /**< Operation is aborted */ - CONNECTION_ERROR_DHCP_FAILED = TIZEN_ERROR_NETWORK_CLASS|0x0406, /**< DHCP failed */ - CONNECTION_ERROR_INVALID_KEY = TIZEN_ERROR_NETWORK_CLASS|0x0407, /**< Invalid key */ - CONNECTION_ERROR_NO_REPLY = TIZEN_ERROR_NETWORK_CLASS|0x0408, /**< No reply */ -} connection_error_e; - -/** - * @} -*/ - -/** - * @addtogroup CAPI_NETWORK_CONNECTION_STATISTICS_MODULE - * @{ -*/ - -/** - * @brief Enumerations of statistics type. - */ -typedef enum -{ - CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA = 0, /**< Last received data */ - CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA = 1, /**< Last sent data */ - CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA = 2, /**< Total received data */ - CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA = 3, /**< Total sent data */ -} connection_statistics_type_e; - -/** - * @} -*/ - -/** - * @addtogroup CAPI_NETWORK_CONNECTION_MANAGER_MODULE - * @{ -*/ - - -/** - * @brief Creates a handle for managing data connections. - * @remarks @a handle must be released with connection_destroy(). - * @param[out] connection The handle of the connection - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory - * @see connection_destroy() - */ -int connection_create(connection_h* connection); - -/** - * @brief Destroys the connection handle. - * @param[in] connection The handle of the connection - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @see connection_create() - */ -int connection_destroy(connection_h connection); - -/** - * @brief Called when the type of connection is changed. - * @param[in] type The type of current network connection - * @param[in] user_data The user data passed from the callback registration function - * @see connection_set_network_type_changed_cb() - * @see connection_unset_network_type_changed_cb() - */ -typedef void(*connection_type_changed_cb)(connection_type_e type, void* user_data); - -/** - * @brief Called when the address is changed. - * @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 - * @see connection_set_ip_address_changed_cb() - * @see connection_unset_ip_address_changed_cb() - * @see connection_set_proxy_address_changed_cb() - * @see connection_unset_proxy_address_changed_cb() - */ -typedef void(*connection_address_changed_cb)(const char* ipv4_address, const char* ipv6_address, void* user_data); - -/** -* @brief Called after connection_set_default_cellular_service_profile_async() is completed. -* @param[in] result The result -* @param[in] user_data The user data passed from connection_open_profile() -* @pre connection_set_default_cellular_service_profile_async() will invoke this callback function. -* @see connection_set_default_cellular_service_profile_async() -*/ -typedef void(*connection_set_default_cb)(connection_error_e result, void* user_data); - -/** - * @brief Gets the type of the current profile for data connection. - * @param[in] connection The handle of the connection - * @param[out] state The state of network - * @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_get_type(connection_h connection, connection_type_e* type); - -/** - * @brief Gets the IP address of the current connection. - * @remarks @a ip_address must be released with free() by you. - * @param[in] connection The handle of the connection - * @param[in] address_family The address family - * @param[out] ip_address The pointer to IP address string. - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family - */ -int connection_get_ip_address(connection_h connection, connection_address_family_e address_family, char** ip_address); - -/** - * @brief Gets the proxy address of the current connection. - * @remarks @a proxy must be released with free() by you. - * @param[in] connection The handle of the connection - * @param[in] address_family The address family - * @param[out] proxy The proxy address - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family - */ -int connection_get_proxy(connection_h connection, connection_address_family_e address_family, char** proxy); - -/** - * @brief Gets the state of celluar connection. - * @details The returned state is for the cellular connection state. - * @param[in] connection The handle of connection - * @param[out] state The state of cellular connection - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - */ -int connection_get_cellular_state(connection_h connection, connection_cellular_state_e* state); - -/** - * @brief Gets the state of Wi-Fi. - * @details The returned state is for the Wi-Fi connection state. - * @param[in] connection The handle of connection - * @param[out] state The state of Wi-Fi connection - * @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_get_wifi_state(connection_h connection, connection_wifi_state_e* state); - -/** - * @brief Gets the state of ethernet. - * @details The returned state is for the ethernet connection state. - * @param[in] connection The handle of connection - * @param[out] state The state of Ethernet connection - * @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_get_ethernet_state(connection_h connection, connection_ethernet_state_e* state); - -/** - * @brief Gets the state of Bluetooth. - * @details The returned state is for the Bluetooth connection state. - * @param[in] connection The handle of connection - * @param[out] state The state of Ethernet connection - * @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_get_bt_state(connection_h connection, connection_bt_state_e* state); - -/** - * @brief Registers the callback called when the type of current connection is changed. - * @param[in] connection The handle of connection - * @param[in] callback The callback function to be called - * @param[in] user_data The user data passed to the callback function - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - */ -int connection_set_type_changed_cb(connection_h connection, connection_type_changed_cb callback, void* user_data); - -/** - * @brief Unregisters the callback called when the type of current connection is changed. - * @param[in] connection The handle of connection - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - */ -int connection_unset_type_changed_cb(connection_h connection); - -/** - * @brief Registers the callback called when the IP address is changed. - * @param[in] connection The handle of connection - * @param[in] callback The callback function to be called - * @param[in] user_data The user data passed to the callback function - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - */ -int connection_set_ip_address_changed_cb(connection_h connection, connection_address_changed_cb callback, void* user_data); - -/** - * @brief Unregisters the callback called when the IP address is changed. - * @param[in] connection The handle of connection - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - */ -int connection_unset_ip_address_changed_cb(connection_h connection); - -/** - * @brief Registers the callback called when the proxy address is changed. - * @param[in] connection The handle of connection - * @param[in] callback The callback function to be called - * @param[in] user_data The user data passed to the callback function - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - */ -int connection_set_proxy_address_changed_cb(connection_h connection, connection_address_changed_cb callback, void* user_data); - -/** - * @brief Unregisters the callback called when the proxy address is changed. - * @param[in] connection The handle of connection - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - */ -int connection_unset_proxy_address_changed_cb(connection_h connection); - -/** - * @brief Adds new profile which is created by connection_profile_created(). - * @remarks You can only add a profile of cellular type. - * @param[in] connection The handle of connection - * @param[in] profile The handle of profile - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - */ -int connection_add_profile(connection_h connection, connection_profile_h profile); - -/** - * @brief Removes existing profile. - * @param[in] connection The handle of connection - * @param[in] profile The handle of profile - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - */ -int connection_remove_profile(connection_h connection, connection_profile_h profile); - -/** - * @brief Updates existing profile. - * @details If you change somethings of a profile, this 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(). - * @param[in] connection The handle of connection - * @param[in] profile The handle of profile - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - * @see connection_open_profile() - */ -int connection_update_profile(connection_h connection, connection_profile_h profile); - -/** - * @brief Gets a iterator of the profiles. - * @remarks @a profile_iterator must be released with connection_destroy_profile_iterator(). - * @param[in] connection The handle of connection - * @param[in] type The type of connetion iterator - * @param[out] profile_iterator The iterator of profile - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - */ -int connection_get_profile_iterator(connection_h connection, connection_iterator_type_e type, connection_profile_iterator_h* profile_iterator); - -/** - * @brief Moves the profile iterator to the next position and gets a profile handle. - * @param[in] profile_iterator The iterator of profile - * @param[out] profile The handle of profile - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_ITERATOR_END End of iteration - */ -int connection_profile_iterator_next(connection_profile_iterator_h profile_iterator, connection_profile_h* profile); - -/** - * @brief Checks whether the next element of profile iterator exists or not. - * @param[in] profile_iterator The iterator of profile - * @return @c true if next element exists, \n @c false if next element doesn't exist - */ -bool connection_profile_iterator_has_next(connection_profile_iterator_h profile_iterator); - -/** - * @brief Destroys a iterator of the profiles. - * @param[in] profile_iterator The iterator of profile - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - */ -int connection_destroy_profile_iterator(connection_profile_iterator_h profile_iterator); - -/** - * @brief Gets the name of default profile. - * @remarks @a profile must be released with connection_profile_destroy(). - * @param[in] connection The handle of connection - * @param[out] profile The handle of profile - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - * @retval #CONNECTION_ERROR_NO_CONNECTION There is no connection - */ -int connection_get_current_profile(connection_h connection, connection_profile_h* profile); - -/** - * @brief Gets the default profile which provides the given cellular service. - * @remarks @a profile must be released with connection_profile_destroy(). - * @param[in] connection The handle of connection - * @param[in] type The type of cellular service. #CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION is not permitted - * @param[out] profile The handle of profile - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - */ -int connection_get_default_cellular_service_profile(connection_h connection, connection_cellular_service_type_e type, connection_profile_h* profile); - -/** - * @brief Sets the default profile which provides the given cellular service. - * @param[in] connection The handle of connection - * @param[in] type The type of cellular service. - * #CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET and #CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET are only permitted. - * @param[in] profile The handle of profile - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - */ -int connection_set_default_cellular_service_profile(connection_h connection, connection_cellular_service_type_e type, connection_profile_h profile); - -/** - * @brief Sets the default profile which provides the given cellular service, asynchronously. - * @param[in] connection The handle of connection - * @param[in] type The type of cellular service. - * #CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET and #CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET are only permitted. - * @param[in] profile The handle of profile - * @param[in] callback The callback function to be called - * @param[in] user_data The user data passed to the callback function - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - */ -int connection_set_default_cellular_service_profile_async(connection_h connection, - connection_cellular_service_type_e type, connection_profile_h profile, connection_set_default_cb callback, void* user_data); - -/** -* @brief Called after connection_open_profile() is completed. -* @param[in] result The result -* @param[in] user_data The user data passed from connection_open_profile() -* @pre connection_open_profile() will invoke this callback function. -* @see connection_open_profile() -*/ -typedef void(*connection_opened_cb)(connection_error_e result, void* user_data); - -/** -* @brief Called after connection_close_profile() is completed. -* @param[in] result The result -* @param[in] user_data The user data passed from connection_close_profile() -* @pre connection_close_profile() will invoke this callback function. -* @see connection_close_profile() -*/ -typedef void(*connection_closed_cb)(connection_error_e result, void* user_data); - -/** - * @brief Opens a connection of profile, asynchronously. - * @param[in] connection The handle of connection - * @param[in] profile The handle of profile - * @param[in] callback The callback function to be called - * @param[in] user_data The user data passed to the callback function - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - * @post connection_opened_cb() will be invoked. - * @see connection_opened_cb() - * @see connection_close_profile() - * @see connection_profile_set_state_changed_cb() - * @see connection_profile_unset_state_changed_cb() - * @see connection_profile_state_changed_cb() - */ -int connection_open_profile(connection_h connection, connection_profile_h profile, connection_opened_cb callback, void* user_data); - -/** - * @brief Closes a connection of profile. - * @param[in] connection The handle of connection - * @param[in] profile The handle of profile - * @param[in] callback The callback function to be called - * @param[in] user_data The user data passed to the callback function - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - * @post connection_closed_cb() will be invoked. - * @see connection_closed_cb() - * @see connection_open_profile() - * @see connection_profile_set_state_changed_cb() - * @see connection_profile_unset_state_changed_cb() - * @see connection_profile_state_changed_cb() - */ -int connection_close_profile(connection_h connection, connection_profile_h profile, connection_closed_cb callback, void* user_data); - -/** - * @brief Add a route to routing table. - * @details You can get the @a interface_name from connection_profile_get_network_interface_name() of opened profile. - * @param[in] connection The handle of connection - * @param[in] interface_name The name of network interface - * @param[in] host_address The IP address of the host - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_ALREADY_EXISTS Already exists - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - * @see connection_profile_get_network_interface_name() - */ -int connection_add_route(connection_h connection, const char* interface_name, const char* host_address); - -/** - * @} -*/ - -/** - * @addtogroup CAPI_NETWORK_CONNECTION_STATISTICS_MODULE - * @{ -*/ - -/** - * @brief Gets the statistics information. - * @param[in] connection The handle of connection - * @param[in] connection_type The type of connection. CONNECTION_TYPE_WIFI and CONNECTION_TYPE_CELLULAR are only supported. - * @param[in] statistics_type The type of statistics - * @param[out] size The received data size of the last cellular packet data connection (bytes) - * @return 0 on success, otherwise negative error value. - * @retval #CONNECTION_ERROR_NONE Successful - * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed - */ -int connection_get_statistics(connection_h connection, connection_type_e connection_type, connection_statistics_type_e statistics_type, long long* size); - -/** - * @brief Resets the statistics information - * @param[in] connection The handle of connection - * @param[in] connection_type The type of connection. CONNECTION_TYPE_WIFI and CONNECTION_TYPE_CELLULAR are only supported. - * @param[in] statistics_type The type of statistics - * @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_reset_statistics(connection_h connection, connection_type_e connection_type, connection_statistics_type_e statistics_type); - -/** - * @} - */ - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/mobile/include/net_connection_private.h b/mobile/include/net_connection_private.h deleted file mode 100644 index ddfdcd3..0000000 --- a/mobile/include/net_connection_private.h +++ /dev/null @@ -1,104 +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. - */ - -#ifndef __NET_CONNECTION_PRIVATE_H__ -#define __NET_CONNECTION_PRIVATE_H__ - -#include <dlog.h> -#include <network-cm-intf.h> -#include <network-wifi-intf.h> -#include "net_connection.h" - -#undef LOG_TAG -#define LOG_TAG "CAPI_NETWORK_CONNECTION" - -#define CONNECTION_INFO 1 -#define CONNECTION_ERROR 2 -#define CONNECTION_WARN 3 - -#define CONNECTION_LOG(log_level, format, args...) \ - do { \ - switch (log_level) { \ - case CONNECTION_ERROR: \ - LOGE(format, ## args); \ - break; \ - case CONNECTION_WARN: \ - LOGW(format, ## args); \ - break; \ - default: \ - LOGI(format, ## args); \ - } \ - } while(0) - -#define CONNECTION_MUTEX_LOCK _connection_inter_mutex_lock() -#define CONNECTION_MUTEX_UNLOCK _connection_inter_mutex_unlock() - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -typedef struct _connection_handle_s -{ - connection_type_changed_cb type_changed_callback; - connection_address_changed_cb ip_changed_callback; - connection_address_changed_cb proxy_changed_callback; - void *state_changed_user_data; - void *ip_changed_user_data; - void *proxy_changed_user_data; -} connection_handle_s; - - -bool _connection_libnet_init(void); -bool _connection_libnet_deinit(void); -bool _connection_libnet_get_wifi_state(connection_wifi_state_e *state); -bool _connection_libnet_get_ethernet_state(connection_ethernet_state_e *state); -bool _connection_libnet_get_bluetooth_state(connection_bt_state_e* state); -bool _connection_libnet_check_profile_validity(connection_profile_h profile); -bool _connection_libnet_check_profile_cb_validity(connection_profile_h profile); -int _connection_libnet_get_profile_iterator(connection_iterator_type_e type, - connection_profile_iterator_h *profile_iterator); -bool _connection_libnet_iterator_has_next(connection_profile_iterator_h profile_iterator); -int _connection_libnet_get_iterator_next(connection_profile_iterator_h profile_iter_h, connection_profile_h *profile); -int _connection_libnet_destroy_iterator(connection_profile_iterator_h profile_iter_h); -int _connection_libnet_get_current_profile(connection_profile_h *profile); -int _connection_libnet_open_profile(connection_profile_h profile, connection_opened_cb callback, void *user_data); -int _connection_libnet_get_cellular_service_profile(connection_cellular_service_type_e type, connection_profile_h *profile); -int _connection_libnet_set_cellular_service_profile_sync(connection_cellular_service_type_e type, connection_profile_h profile); -int _connection_libnet_set_cellular_service_profile_async(connection_cellular_service_type_e type, - connection_profile_h profile, connection_set_default_cb callback, void* user_data); -int _connection_libnet_close_profile(connection_profile_h profile, connection_closed_cb callback, void *user_data); -int _connection_libnet_add_route(const char *interface_name, const char *host_address); -void _connection_libnet_add_to_profile_list(connection_profile_h profile); -void _connection_libnet_remove_from_profile_list(connection_profile_h profile); -bool _connection_libnet_add_to_profile_cb_list(connection_profile_h profile, - connection_profile_state_changed_cb callback, void *user_data); -void _connection_libnet_remove_from_profile_cb_list(connection_profile_h profile); -int _connection_libnet_set_statistics(net_device_t device_type, net_statistics_type_e statistics_type); -int _connection_libnet_get_statistics(net_statistics_type_e statistics_type, unsigned long long *size); - -connection_cellular_service_type_e _profile_convert_to_connection_cellular_service_type(net_service_type_t svc_type); -connection_profile_state_e _profile_convert_to_cp_state(net_state_type_t state); -net_service_type_t _connection_profile_convert_to_libnet_cellular_service_type(connection_cellular_service_type_e svc_type); -net_state_type_t _connection_profile_convert_to_net_state(connection_profile_state_e state); - -void _connection_inter_mutex_lock(void); -void _connection_inter_mutex_unlock(void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/mobile/src/connection.c b/mobile/src/connection.c deleted file mode 100644 index 66b371e..0000000 --- a/mobile/src/connection.c +++ /dev/null @@ -1,844 +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 <stdio.h> -#include <string.h> -#include <glib.h> -#include <vconf/vconf.h> -#include "net_connection_private.h" - -static GSList *conn_handle_list = NULL; - -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 int __connection_convert_net_state(int status) -{ - switch (status) { - case VCONFKEY_NETWORK_CELLULAR: - return CONNECTION_TYPE_CELLULAR; - case VCONFKEY_NETWORK_WIFI: - return CONNECTION_TYPE_WIFI; - case VCONFKEY_NETWORK_ETHERNET: - return CONNECTION_TYPE_ETHERNET; - case VCONFKEY_NETWORK_BLUETOOTH: - return CONNECTION_TYPE_BT; - default: - return CONNECTION_TYPE_DISCONNECTED; - } -} - -static int __connection_convert_cellular_state(int status) -{ - switch (status) { - case VCONFKEY_NETWORK_CELLULAR_ON: - return CONNECTION_CELLULAR_STATE_AVAILABLE; - case VCONFKEY_NETWORK_CELLULAR_3G_OPTION_OFF: - return CONNECTION_CELLULAR_STATE_CALL_ONLY_AVAILABLE; - case VCONFKEY_NETWORK_CELLULAR_ROAMING_OFF: - return CONNECTION_CELLULAR_STATE_ROAMING_OFF; - case VCONFKEY_NETWORK_CELLULAR_FLIGHT_MODE: - return CONNECTION_CELLULAR_STATE_FLIGHT_MODE; - default: - return CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE; - } -} - -static int __connection_get_type_changed_callback_count(void) -{ - GSList *list; - int count = 0; - - for (list = conn_handle_list; list; list = list->next) { - connection_handle_s *local_handle = (connection_handle_s *)list->data; - if (local_handle->type_changed_callback) count++; - } - - return count; -} - -static int __connection_get_ip_changed_callback_count(void) -{ - GSList *list; - int count = 0; - - for (list = conn_handle_list; list; list = list->next) { - connection_handle_s *local_handle = (connection_handle_s *)list->data; - if (local_handle->ip_changed_callback) count++; - } - - return count; -} - -static int __connection_get_proxy_changed_callback_count(void) -{ - GSList *list; - int count = 0; - - for (list = conn_handle_list; list; list = list->next) { - connection_handle_s *local_handle = (connection_handle_s *)list->data; - if (local_handle->proxy_changed_callback) count++; - } - - return count; -} - -static int __connection_set_type_changed_callback(connection_h connection, - void *callback, void *user_data) -{ - connection_handle_s *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; - - local_handle->state_changed_user_data = user_data; - } 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; - } - - 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) -{ - connection_handle_s *local_handle = (connection_handle_s *)connection; - - 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; - - 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; - } - - local_handle->ip_changed_callback = callback; - return CONNECTION_ERROR_NONE; -} - -static int __connection_set_proxy_changed_callback(connection_h connection, - void *callback, void *user_data) -{ - connection_handle_s *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; - - local_handle->proxy_changed_user_data = user_data; - } 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; - } - - local_handle->proxy_changed_callback = callback; - return CONNECTION_ERROR_NONE; -} - -static void __connection_cb_state_change_cb(keynode_t *node, void *user_data) -{ - CONNECTION_LOG(CONNECTION_INFO, "Net Status Changed Indication\n"); - - GSList *list; - int state = vconf_keynode_get_int(node); - - 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->state_changed_user_data); - } -} - -static void __connection_cb_ip_change_cb(keynode_t *node, void *user_data) -{ - CONNECTION_LOG(CONNECTION_INFO, "Net IP Changed Indication\n"); - - GSList *list; - char *ip_addr = vconf_keynode_get_str(node); - - 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); - } -} - -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); - - 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); - } -} - -static bool __connection_check_handle_validity(connection_h connection) -{ - GSList *list; - - for (list = conn_handle_list; list; list = list->next) - if (connection == list->data) return true; - - return false; -} - -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; -} - -/* Connection Manager ********************************************************/ -EXPORT_API int connection_create(connection_h* connection) -{ - CONNECTION_MUTEX_LOCK; - - if (connection == NULL || __connection_check_handle_validity(*connection)) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - CONNECTION_MUTEX_UNLOCK; - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - if (_connection_libnet_init() == false) { - CONNECTION_LOG(CONNECTION_ERROR, "Creation failed!\n"); - CONNECTION_MUTEX_UNLOCK; - return CONNECTION_ERROR_OPERATION_FAILED; - } - - CONNECTION_LOG(CONNECTION_ERROR, "Connection successfully created!\n"); - - *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; - return CONNECTION_ERROR_OUT_OF_MEMORY; - } - - conn_handle_list = g_slist_append(conn_handle_list, *connection); - - CONNECTION_MUTEX_UNLOCK; - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_destroy(connection_h connection) -{ - CONNECTION_MUTEX_LOCK; - - if (connection == NULL || !(__connection_check_handle_validity(connection))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - CONNECTION_MUTEX_UNLOCK; - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - CONNECTION_LOG(CONNECTION_INFO, "Destroy Handle : %p\n", connection); - - __connection_set_type_changed_callback(connection, NULL, NULL); - __connection_set_ip_changed_callback(connection, NULL, NULL); - __connection_set_proxy_changed_callback(connection, NULL, NULL); - - conn_handle_list = g_slist_remove(conn_handle_list, connection); - - g_free(connection); - - if (__connection_get_handle_count() == 0) - _connection_libnet_deinit(); - - CONNECTION_MUTEX_UNLOCK; - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_get_type(connection_h connection, connection_type_e* type) -{ - int status = 0; - - if (type == NULL || !(__connection_check_handle_validity(connection))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - if (vconf_get_int(VCONFKEY_NETWORK_STATUS, &status)) { - CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_int Failed = %d\n", status); - return CONNECTION_ERROR_OPERATION_FAILED; - } - - CONNECTION_LOG(CONNECTION_INFO, "Connected Network = %d\n", status); - - *type = __connection_convert_net_state(status); - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_get_ip_address(connection_h connection, - connection_address_family_e address_family, char** ip_address) -{ - if (ip_address == NULL || !(__connection_check_handle_validity(connection))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - switch (address_family) { - case CONNECTION_ADDRESS_FAMILY_IPV4: - *ip_address = vconf_get_str(VCONFKEY_NETWORK_IP); - break; - case CONNECTION_ADDRESS_FAMILY_IPV6: - CONNECTION_LOG(CONNECTION_ERROR, "Not supported yet\n"); - return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; - break; - default: - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - if (*ip_address == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_str Failed\n"); - return CONNECTION_ERROR_OPERATION_FAILED; - } - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_get_proxy(connection_h connection, - connection_address_family_e address_family, char** proxy) -{ - if (proxy == NULL || !(__connection_check_handle_validity(connection))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - switch (address_family) { - case CONNECTION_ADDRESS_FAMILY_IPV4: - *proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY); - break; - case CONNECTION_ADDRESS_FAMILY_IPV6: - CONNECTION_LOG(CONNECTION_ERROR, "Not supported yet\n"); - return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; - break; - default: - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - if (*proxy == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_str Failed\n"); - return CONNECTION_ERROR_OPERATION_FAILED; - } - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_get_cellular_state(connection_h connection, connection_cellular_state_e* state) -{ - int status = 0; - int cellular_state = 0; - - if (state == NULL || !(__connection_check_handle_validity(connection))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - 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); - - 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, "Connection state = %d\n", 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; - } else { - CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_int Failed = %d\n", status); - return CONNECTION_ERROR_OPERATION_FAILED; - } -} - -EXPORT_API int connection_get_wifi_state(connection_h connection, connection_wifi_state_e* state) -{ - if (state == NULL || !(__connection_check_handle_validity(connection))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - if (_connection_libnet_get_wifi_state(state) == false) { - CONNECTION_LOG(CONNECTION_ERROR, "Fail to get wifi state\n"); - return CONNECTION_ERROR_OPERATION_FAILED; - } - - CONNECTION_LOG(CONNECTION_INFO, "WiFi state = %d\n", *state); - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_get_ethernet_state(connection_h connection, connection_ethernet_state_e* state) -{ - if (state == NULL || !(__connection_check_handle_validity(connection))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - if (_connection_libnet_get_ethernet_state(state) == false) - return CONNECTION_ERROR_OPERATION_FAILED; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_get_bt_state(connection_h connection, connection_bt_state_e* state) -{ - if (state == NULL || !(__connection_check_handle_validity(connection))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - if (_connection_libnet_get_bluetooth_state(state) == false) - return CONNECTION_ERROR_OPERATION_FAILED; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_set_type_changed_cb(connection_h connection, - connection_type_changed_cb callback, void* user_data) -{ - if (callback == NULL || !(__connection_check_handle_validity(connection))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - return __connection_set_type_changed_callback(connection, callback, user_data); -} - -EXPORT_API int connection_unset_type_changed_cb(connection_h connection) -{ - if (!(__connection_check_handle_validity(connection))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - return __connection_set_type_changed_callback(connection, NULL, NULL); -} - -EXPORT_API int connection_set_ip_address_changed_cb(connection_h connection, - connection_address_changed_cb callback, void* user_data) -{ - if (callback == NULL || !(__connection_check_handle_validity(connection))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - return __connection_set_ip_changed_callback(connection, callback, user_data); -} - -EXPORT_API int connection_unset_ip_address_changed_cb(connection_h connection) -{ - if (!(__connection_check_handle_validity(connection))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - return __connection_set_ip_changed_callback(connection, NULL, NULL); -} - -EXPORT_API int connection_set_proxy_address_changed_cb(connection_h connection, - connection_address_changed_cb callback, void* user_data) -{ - if (callback == NULL || !(__connection_check_handle_validity(connection))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - return __connection_set_proxy_changed_callback(connection, callback, user_data); -} - -EXPORT_API int connection_unset_proxy_address_changed_cb(connection_h connection) -{ - if (!(__connection_check_handle_validity(connection))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - return __connection_set_proxy_changed_callback(connection, NULL, NULL); -} - -EXPORT_API int connection_add_profile(connection_h connection, connection_profile_h profile) -{ - if (!(__connection_check_handle_validity(connection)) || - !(_connection_libnet_check_profile_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - 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"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - rv = net_add_profile(profile_info->ProfileInfo.Pdp.ServiceType, (net_profile_info_t*)profile); - if (rv != NET_ERR_NONE) { - CONNECTION_LOG(CONNECTION_ERROR, "net_add_profile Failed = %d\n", rv); - return CONNECTION_ERROR_OPERATION_FAILED; - } - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_remove_profile(connection_h connection, connection_profile_h profile) -{ - if (!(__connection_check_handle_validity(connection)) || - !(_connection_libnet_check_profile_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - 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"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - rv = net_delete_profile(profile_info->ProfileName); - if (rv != NET_ERR_NONE) { - CONNECTION_LOG(CONNECTION_ERROR, "net_delete_profile Failed = %d\n", rv); - return CONNECTION_ERROR_OPERATION_FAILED; - } - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_update_profile(connection_h connection, connection_profile_h profile) -{ - if (!(__connection_check_handle_validity(connection)) || - !(_connection_libnet_check_profile_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - int rv = 0; - net_profile_info_t *profile_info = profile; - - rv = net_modify_profile(profile_info->ProfileName, (net_profile_info_t*)profile); - if (rv != NET_ERR_NONE) { - CONNECTION_LOG(CONNECTION_ERROR, "net_modify_profile Failed = %d\n", rv); - return CONNECTION_ERROR_OPERATION_FAILED; - } - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_get_profile_iterator(connection_h connection, - connection_iterator_type_e type, connection_profile_iterator_h* profile_iterator) -{ - if (!(__connection_check_handle_validity(connection)) || - (type != CONNECTION_ITERATOR_TYPE_REGISTERED && - type != CONNECTION_ITERATOR_TYPE_CONNECTED)) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - return _connection_libnet_get_profile_iterator(type, profile_iterator); -} - -EXPORT_API int connection_profile_iterator_next(connection_profile_iterator_h profile_iterator, - connection_profile_h* profile) -{ - return _connection_libnet_get_iterator_next(profile_iterator, profile); -} - -EXPORT_API bool connection_profile_iterator_has_next(connection_profile_iterator_h profile_iterator) -{ - return _connection_libnet_iterator_has_next(profile_iterator); -} - -EXPORT_API int connection_destroy_profile_iterator(connection_profile_iterator_h profile_iterator) -{ - return _connection_libnet_destroy_iterator(profile_iterator); -} - -EXPORT_API int connection_get_current_profile(connection_h connection, connection_profile_h* profile) -{ - if (!(__connection_check_handle_validity(connection)) || profile == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - 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) -{ - if (!(__connection_check_handle_validity(connection)) || profile == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - return _connection_libnet_get_cellular_service_profile(type, profile); -} - -EXPORT_API int connection_set_default_cellular_service_profile(connection_h connection, - connection_cellular_service_type_e type, connection_profile_h profile) -{ - if (!(__connection_check_handle_validity(connection)) || profile == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - return _connection_libnet_set_cellular_service_profile_sync(type, profile); -} - -EXPORT_API int connection_set_default_cellular_service_profile_async(connection_h connection, - connection_cellular_service_type_e type, connection_profile_h profile, - connection_set_default_cb callback, void* user_data) -{ - if (!(__connection_check_handle_validity(connection)) || - profile == NULL || callback == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - return _connection_libnet_set_cellular_service_profile_async(type, profile, callback, user_data); -} - -EXPORT_API int connection_open_profile(connection_h connection, connection_profile_h profile, - connection_opened_cb callback, void* user_data) -{ - if (!(__connection_check_handle_validity(connection)) || - profile == NULL || callback == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - return _connection_libnet_open_profile(profile, callback, user_data); -} - -EXPORT_API int connection_close_profile(connection_h connection, connection_profile_h profile, - connection_closed_cb callback, void* user_data) -{ - if (!(__connection_check_handle_validity(connection)) || - profile == NULL || callback == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - return _connection_libnet_close_profile(profile, callback, user_data); -} - -EXPORT_API int connection_add_route(connection_h connection, const char* interface_name, const char* host_address) -{ - if (!(__connection_check_handle_validity(connection)) || - interface_name == NULL || host_address == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - return _connection_libnet_add_route(interface_name, host_address); -} - - -/* Connection Statistics module ******************************************************************/ - -static int __get_statistic(connection_type_e connection_type, - connection_statistics_type_e statistics_type, long long* llsize) -{ - int size; - unsigned long long ull_size; - int stat_type; - char *key = NULL; - - if (llsize == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - if (connection_type == CONNECTION_TYPE_CELLULAR) { - switch (statistics_type) { - case CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA: - key = VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT; - break; - case CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA: - key = VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV; - break; - case CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA: - key = VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT; - break; - case CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA: - key = VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV; - 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; - } - - CONNECTION_LOG(CONNECTION_INFO,"%s:%d bytes\n", key, size); - *llsize = (long long)size; - } 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; - break; - case CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA: - stat_type = NET_STATISTICS_TYPE_LAST_RECEIVED_DATA; - break; - case CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA: - stat_type = NET_STATISTICS_TYPE_TOTAL_SENT_DATA; - break; - case CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA: - stat_type = NET_STATISTICS_TYPE_TOTAL_RECEIVED_DATA; - break; - default: - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - if (_connection_libnet_get_statistics(stat_type, &ull_size) != CONNECTION_ERROR_NONE) { - CONNECTION_LOG(CONNECTION_ERROR, "Cannot Get Wi-Fi statistics : %d\n", ull_size); - *llsize = 0; - return CONNECTION_ERROR_OPERATION_FAILED; - } - - CONNECTION_LOG(CONNECTION_INFO,"%d bytes\n", ull_size); - *llsize = (long long)ull_size; - } else - return CONNECTION_ERROR_INVALID_PARAMETER; - - return CONNECTION_ERROR_NONE; -} - -static int __reset_statistic(connection_type_e connection_type, - connection_statistics_type_e statistics_type) -{ - int conn_type; - int stat_type; - int rv; - - if (connection_type == CONNECTION_TYPE_CELLULAR) - conn_type = NET_DEVICE_CELLULAR; - else if (connection_type == CONNECTION_TYPE_WIFI) - conn_type = NET_DEVICE_WIFI; - else - return CONNECTION_ERROR_INVALID_PARAMETER; - - switch (statistics_type) { - case CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA: - stat_type = NET_STATISTICS_TYPE_LAST_SENT_DATA; - break; - case CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA: - stat_type = NET_STATISTICS_TYPE_LAST_RECEIVED_DATA; - break; - case CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA: - stat_type = NET_STATISTICS_TYPE_TOTAL_SENT_DATA; - break; - case CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA: - stat_type = NET_STATISTICS_TYPE_TOTAL_RECEIVED_DATA; - break; - default: - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - rv = _connection_libnet_set_statistics(conn_type, stat_type); - if(rv != CONNECTION_ERROR_NONE) - return rv; - - - CONNECTION_LOG(CONNECTION_INFO,"connection_reset_statistics success\n"); - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_get_statistics(connection_h connection, - connection_type_e connection_type, - connection_statistics_type_e statistics_type, long long* size) -{ - if (!(__connection_check_handle_validity(connection)) || size == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - return __get_statistic(connection_type, statistics_type, size); -} - - -EXPORT_API int connection_reset_statistics(connection_h connection, - connection_type_e connection_type, - connection_statistics_type_e statistics_type) -{ - if (!__connection_check_handle_validity(connection)) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - return __reset_statistic(connection_type, statistics_type); -} - diff --git a/mobile/src/connection_profile.c b/mobile/src/connection_profile.c deleted file mode 100755 index 6d0bfe3..0000000 --- a/mobile/src/connection_profile.c +++ /dev/null @@ -1,1354 +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 <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <arpa/inet.h> -#include <glib.h> -#include <vconf/vconf.h> -#include "net_connection_private.h" - -#define HTTP_PROXY "http_proxy" - -static net_dev_info_t* __profile_get_net_info(net_profile_info_t *profile_info) -{ - switch (profile_info->profile_type) { - case NET_DEVICE_CELLULAR: - return &profile_info->ProfileInfo.Pdp.net_info; - case NET_DEVICE_WIFI: - return &profile_info->ProfileInfo.Wlan.net_info; - case NET_DEVICE_ETHERNET: - return &profile_info->ProfileInfo.Ethernet.net_info; - case NET_DEVICE_BLUETOOTH: - return &profile_info->ProfileInfo.Bluetooth.net_info; - case NET_DEVICE_DEFAULT: - case NET_DEVICE_USB: - case NET_DEVICE_UNKNOWN: - case NET_DEVICE_MAX: - default: - return NULL; - } -} - -static char* __profile_convert_ip_to_string(net_addr_t *ip_addr) -{ - unsigned char *ipaddr = (unsigned char *)&ip_addr->Data.Ipv4.s_addr; - - char *ipstr = g_try_malloc0(16); - if (ipstr == NULL) - return NULL; - - snprintf(ipstr, 16, "%d.%d.%d.%d", ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]); - - return ipstr; -} - -static void __profile_init_cellular_profile(net_profile_info_t *profile_info, const char *keyword) -{ - profile_info->profile_type = NET_DEVICE_CELLULAR; - profile_info->ProfileState = NET_STATE_TYPE_IDLE; - profile_info->ProfileInfo.Pdp.net_info.IpConfigType = NET_IP_CONFIG_TYPE_OFF; - profile_info->ProfileInfo.Pdp.net_info.ProxyMethod = NET_PROXY_TYPE_DIRECT; - g_strlcpy(profile_info->ProfileInfo.Pdp.Keyword, keyword, NET_PDP_APN_LEN_MAX); -} - -static void __profile_init_wifi_profile(net_profile_info_t *profile_info) -{ - profile_info->profile_type = NET_DEVICE_WIFI; - profile_info->ProfileState = NET_STATE_TYPE_IDLE; - profile_info->ProfileInfo.Wlan.net_info.IpConfigType = NET_IP_CONFIG_TYPE_OFF; - profile_info->ProfileInfo.Wlan.net_info.ProxyMethod = NET_PROXY_TYPE_DIRECT; - profile_info->ProfileInfo.Wlan.wlan_mode = NETPM_WLAN_CONNMODE_AUTO; - profile_info->ProfileInfo.Wlan.security_info.sec_mode = WLAN_SEC_MODE_NONE; - profile_info->ProfileInfo.Wlan.security_info.enc_mode = WLAN_ENC_MODE_NONE; -} - -static const char* __profile_get_ethernet_proxy(void) -{ - char *proxy; - - proxy = getenv(HTTP_PROXY); - - if(proxy == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Fail to get system proxy"); - return NULL; - } - - return proxy; -} - -connection_cellular_service_type_e _profile_convert_to_connection_cellular_service_type(net_service_type_t svc_type) -{ - switch (svc_type) { - case NET_SERVICE_INTERNET: - return CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET; - case NET_SERVICE_MMS: - return CONNECTION_CELLULAR_SERVICE_TYPE_MMS; - case NET_SERVICE_PREPAID_INTERNET: - return CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET; - case NET_SERVICE_PREPAID_MMS: - return CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS; - case NET_SERVICE_TETHERING: - return CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING; - case NET_SERVICE_APPLICATION: - return CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION; - default: - return CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN; - } -} - -connection_profile_state_e _profile_convert_to_cp_state(net_state_type_t state) -{ - connection_profile_state_e cp_state; - - switch (state) { - case NET_STATE_TYPE_ONLINE: - case NET_STATE_TYPE_READY: - cp_state = CONNECTION_PROFILE_STATE_CONNECTED; - break; - case NET_STATE_TYPE_IDLE: - case NET_STATE_TYPE_FAILURE: - case NET_STATE_TYPE_DISCONNECT: - cp_state = CONNECTION_PROFILE_STATE_DISCONNECTED; - break; - case NET_STATE_TYPE_ASSOCIATION: - cp_state = CONNECTION_PROFILE_STATE_ASSOCIATION; - break; - case NET_STATE_TYPE_CONFIGURATION: - cp_state = CONNECTION_PROFILE_STATE_CONFIGURATION; - break; - default: - cp_state = -1; - } - - return cp_state; -} - -net_service_type_t _connection_profile_convert_to_libnet_cellular_service_type(connection_cellular_service_type_e svc_type) -{ - switch (svc_type) { - case CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET: - return NET_SERVICE_INTERNET; - case CONNECTION_CELLULAR_SERVICE_TYPE_MMS: - return NET_SERVICE_MMS; - case CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET: - return NET_SERVICE_PREPAID_INTERNET; - case CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS: - return NET_SERVICE_PREPAID_MMS; - case CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING: - return NET_SERVICE_TETHERING; - case CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION: - return NET_SERVICE_APPLICATION; - default: - return NET_SERVICE_UNKNOWN; - } -} - -net_state_type_t _connection_profile_convert_to_net_state(connection_profile_state_e state) -{ - net_state_type_t libnet_state = NET_STATE_TYPE_UNKNOWN; - - switch (state) { - case CONNECTION_PROFILE_STATE_CONNECTED: - libnet_state = NET_STATE_TYPE_ONLINE; - break; - case CONNECTION_PROFILE_STATE_DISCONNECTED: - libnet_state = NET_STATE_TYPE_IDLE; - break; - case CONNECTION_PROFILE_STATE_ASSOCIATION: - libnet_state = NET_STATE_TYPE_ASSOCIATION; - break; - case CONNECTION_PROFILE_STATE_CONFIGURATION: - libnet_state = NET_STATE_TYPE_CONFIGURATION; - break; - } - - return libnet_state; -} - - -/* Connection profile ********************************************************/ -EXPORT_API int connection_profile_create(connection_profile_type_e type, const char* keyword, connection_profile_h* profile) -{ - if ((type != CONNECTION_PROFILE_TYPE_CELLULAR && - type != CONNECTION_PROFILE_TYPE_WIFI) || profile == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = g_try_malloc0(sizeof(net_profile_info_t)); - if (profile_info == NULL) - return CONNECTION_ERROR_OUT_OF_MEMORY; - - switch (type) { - case CONNECTION_PROFILE_TYPE_CELLULAR: - if (keyword == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - g_free(profile_info); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - __profile_init_cellular_profile(profile_info, keyword); - break; - case CONNECTION_PROFILE_TYPE_WIFI: - __profile_init_wifi_profile(profile_info); - break; - default: - break; - } - - *profile = (connection_profile_h)profile_info; - _connection_libnet_add_to_profile_list(*profile); - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_destroy(connection_profile_h profile) -{ - if (!(_connection_libnet_check_profile_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - _connection_libnet_remove_from_profile_list(profile); - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_clone(connection_profile_h* cloned_profile, connection_profile_h origin_profile) -{ - if (!(_connection_libnet_check_profile_validity(origin_profile)) || cloned_profile == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - *cloned_profile = g_try_malloc0(sizeof(net_profile_info_t)); - if (*cloned_profile == NULL) - return CONNECTION_ERROR_OUT_OF_MEMORY; - - memcpy(*cloned_profile, origin_profile, sizeof(net_profile_info_t)); - _connection_libnet_add_to_profile_list(*cloned_profile); - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_get_id(connection_profile_h profile, char** profile_id) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || profile_id == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - char *prof_id = strrchr(profile_info->ProfileName, '/'); - if (prof_id == NULL) - return CONNECTION_ERROR_INVALID_PARAMETER; - - prof_id++; - *profile_id = g_strdup(prof_id); - - if (*profile_id == NULL) - return CONNECTION_ERROR_OUT_OF_MEMORY; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_get_name(connection_profile_h profile, char** profile_name) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || profile_name == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - switch (profile_info->profile_type) { - case NET_DEVICE_CELLULAR: - *profile_name = g_strdup(profile_info->ProfileInfo.Pdp.Keyword); - break; - case NET_DEVICE_WIFI: - *profile_name = g_strdup(profile_info->ProfileInfo.Wlan.essid); - break; - case NET_DEVICE_ETHERNET: - *profile_name = g_strdup(profile_info->ProfileInfo.Ethernet.net_info.DevName); - break; - case NET_DEVICE_BLUETOOTH: { - char *bt_name = strrchr(profile_info->ProfileName, '/'); - if (bt_name == NULL) - return CONNECTION_ERROR_INVALID_PARAMETER; - - bt_name++; - *profile_name = g_strdup(bt_name); - } break; - default: - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - if (*profile_name == NULL) - return CONNECTION_ERROR_OUT_OF_MEMORY; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_get_type(connection_profile_h profile, connection_profile_type_e* type) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - switch (profile_info->profile_type) { - case NET_DEVICE_CELLULAR: - *type = CONNECTION_PROFILE_TYPE_CELLULAR; - break; - case NET_DEVICE_WIFI: - *type = CONNECTION_PROFILE_TYPE_WIFI; - break; - case NET_DEVICE_ETHERNET: - *type = CONNECTION_PROFILE_TYPE_ETHERNET; - break; - case NET_DEVICE_BLUETOOTH: - *type = CONNECTION_PROFILE_TYPE_BT; - break; - default: - CONNECTION_LOG(CONNECTION_ERROR, "Invalid profile type\n"); - return CONNECTION_ERROR_OPERATION_FAILED; - } - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_get_network_interface_name(connection_profile_h profile, char** interface_name) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || interface_name == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (net_info == NULL) - return CONNECTION_ERROR_INVALID_PARAMETER; - - *interface_name = g_strdup(net_info->DevName); - if (*interface_name == NULL) - return CONNECTION_ERROR_OUT_OF_MEMORY; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_refresh(connection_profile_h profile) -{ - if (!(_connection_libnet_check_profile_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t profile_info_local; - net_profile_info_t *profile_info = profile; - - if (net_get_profile_info(profile_info->ProfileName, &profile_info_local) != NET_ERR_NONE) { - CONNECTION_LOG(CONNECTION_ERROR, "Error!!! net_get_profile_info() failed\n"); - return CONNECTION_ERROR_OPERATION_FAILED; - } - - memcpy(profile, &profile_info_local, sizeof(net_profile_info_t)); - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_get_state(connection_profile_h profile, connection_profile_state_e* state) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || state == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - 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_NONE; -} - -EXPORT_API int connection_profile_get_ip_config_type(connection_profile_h profile, - connection_address_family_e address_family, connection_ip_config_type_e* type) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || - (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && - address_family != CONNECTION_ADDRESS_FAMILY_IPV6) || - type == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) - return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; - - net_profile_info_t *profile_info = profile; - net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (net_info == NULL) - return CONNECTION_ERROR_OPERATION_FAILED; - - switch (net_info->IpConfigType) { - case NET_IP_CONFIG_TYPE_STATIC: - *type = CONNECTION_IP_CONFIG_TYPE_STATIC; - break; - case NET_IP_CONFIG_TYPE_DYNAMIC: - *type = CONNECTION_IP_CONFIG_TYPE_DYNAMIC; - break; - case NET_IP_CONFIG_TYPE_AUTO_IP: - *type = CONNECTION_IP_CONFIG_TYPE_AUTO; - break; - case NET_IP_CONFIG_TYPE_FIXED: - *type = CONNECTION_IP_CONFIG_TYPE_FIXED; - break; - case NET_IP_CONFIG_TYPE_OFF: - *type = CONNECTION_IP_CONFIG_TYPE_NONE; - break; - default: - return CONNECTION_ERROR_OPERATION_FAILED; - } - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_get_ip_address(connection_profile_h profile, - connection_address_family_e address_family, char** ip_address) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || - (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && - address_family != CONNECTION_ADDRESS_FAMILY_IPV6) || - ip_address == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (net_info == NULL) - return CONNECTION_ERROR_OPERATION_FAILED; - - if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) - return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; - - *ip_address = __profile_convert_ip_to_string(&net_info->IpAddr); - if (*ip_address == NULL) - return CONNECTION_ERROR_OUT_OF_MEMORY; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_get_subnet_mask(connection_profile_h profile, - connection_address_family_e address_family, char** subnet_mask) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || - (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && - address_family != CONNECTION_ADDRESS_FAMILY_IPV6) || - subnet_mask == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (net_info == NULL) - return CONNECTION_ERROR_OPERATION_FAILED; - - if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) - return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; - - *subnet_mask = __profile_convert_ip_to_string(&net_info->SubnetMask); - if (*subnet_mask == NULL) - return CONNECTION_ERROR_OUT_OF_MEMORY; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_get_gateway_address(connection_profile_h profile, - connection_address_family_e address_family, char** gateway_address) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || - (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && - address_family != CONNECTION_ADDRESS_FAMILY_IPV6) || - gateway_address == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (net_info == NULL) - return CONNECTION_ERROR_OPERATION_FAILED; - - if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) - return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; - - *gateway_address = __profile_convert_ip_to_string(&net_info->GatewayAddr); - if (*gateway_address == NULL) - return CONNECTION_ERROR_OUT_OF_MEMORY; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_get_dns_address(connection_profile_h profile, int order, - connection_address_family_e address_family, char** dns_address) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || - (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && - address_family != CONNECTION_ADDRESS_FAMILY_IPV6) || - dns_address == NULL || - order <= 0 || - order > NET_DNS_ADDR_MAX) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (net_info == NULL) - return CONNECTION_ERROR_OPERATION_FAILED; - - if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) - return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; - - *dns_address = __profile_convert_ip_to_string(&net_info->DnsAddr[order-1]); - if (*dns_address == NULL) - return CONNECTION_ERROR_OUT_OF_MEMORY; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_get_proxy_type(connection_profile_h profile, connection_proxy_type_e* type) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - const char *proxy; - net_profile_info_t *profile_info = profile; - net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (net_info == NULL) - return CONNECTION_ERROR_OPERATION_FAILED; - - if (profile_info->profile_type == NET_DEVICE_ETHERNET) { - proxy = __profile_get_ethernet_proxy(); - if (proxy == NULL) - *type = CONNECTION_PROXY_TYPE_DIRECT; - else - *type = CONNECTION_PROXY_TYPE_MANUAL; - - return CONNECTION_ERROR_NONE; - } - - switch (net_info->ProxyMethod) { - case NET_PROXY_TYPE_DIRECT: - *type = CONNECTION_PROXY_TYPE_DIRECT; - break; - case NET_PROXY_TYPE_AUTO: - *type = CONNECTION_PROXY_TYPE_AUTO; - break; - case NET_PROXY_TYPE_MANUAL: - *type = CONNECTION_PROXY_TYPE_MANUAL; - break; - case NET_PROXY_TYPE_UNKNOWN: - default: - return CONNECTION_ERROR_OPERATION_FAILED; - } - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_get_proxy_address(connection_profile_h profile, - connection_address_family_e address_family, char** proxy_address) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || - (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && - address_family != CONNECTION_ADDRESS_FAMILY_IPV6) || - proxy_address == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - const char *proxy; - net_profile_info_t *profile_info = profile; - net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (net_info == NULL) - return CONNECTION_ERROR_OPERATION_FAILED; - - if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) - return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; - - if (profile_info->profile_type == NET_DEVICE_ETHERNET) { - proxy = __profile_get_ethernet_proxy(); - if (proxy == NULL) - return CONNECTION_ERROR_OPERATION_FAILED; - - *proxy_address = g_strdup(proxy); - } else - *proxy_address = g_strdup(net_info->ProxyAddr); - - if (*proxy_address == NULL) - return CONNECTION_ERROR_OUT_OF_MEMORY; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_set_ip_config_type(connection_profile_h profile, - connection_address_family_e address_family, connection_ip_config_type_e type) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || - (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && - address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (net_info == NULL) - return CONNECTION_ERROR_OPERATION_FAILED; - - if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) - return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; - - switch (type) { - case CONNECTION_IP_CONFIG_TYPE_STATIC: - net_info->IpConfigType = NET_IP_CONFIG_TYPE_STATIC; - net_info->IpAddr.Data.Ipv4.s_addr = 0; - net_info->SubnetMask.Data.Ipv4.s_addr = 0; - net_info->GatewayAddr.Data.Ipv4.s_addr = 0; - break; - case CONNECTION_IP_CONFIG_TYPE_DYNAMIC: - net_info->IpConfigType = NET_IP_CONFIG_TYPE_DYNAMIC; - break; - case CONNECTION_IP_CONFIG_TYPE_AUTO: - net_info->IpConfigType = NET_IP_CONFIG_TYPE_AUTO_IP; - break; - case CONNECTION_IP_CONFIG_TYPE_FIXED: - net_info->IpConfigType = NET_IP_CONFIG_TYPE_FIXED; - break; - case CONNECTION_IP_CONFIG_TYPE_NONE: - net_info->IpConfigType = NET_IP_CONFIG_TYPE_OFF; - break; - default: - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_set_ip_address(connection_profile_h profile, - connection_address_family_e address_family, const char* ip_address) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || - (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && - address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (net_info == NULL) - return CONNECTION_ERROR_OPERATION_FAILED; - - if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) - return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; - - if (ip_address == NULL) - net_info->IpAddr.Data.Ipv4.s_addr = 0; - else if (inet_aton(ip_address, &(net_info->IpAddr.Data.Ipv4)) == 0) - return CONNECTION_ERROR_INVALID_PARAMETER; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_set_subnet_mask(connection_profile_h profile, - connection_address_family_e address_family, const char* subnet_mask) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || - (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && - address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (net_info == NULL) - return CONNECTION_ERROR_OPERATION_FAILED; - - if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) - return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; - - if (subnet_mask == NULL) - net_info->SubnetMask.Data.Ipv4.s_addr = 0; - else if (inet_aton(subnet_mask, &(net_info->SubnetMask.Data.Ipv4)) == 0) - return CONNECTION_ERROR_INVALID_PARAMETER; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_set_gateway_address(connection_profile_h profile, - connection_address_family_e address_family, const char* gateway_address) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || - (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && - address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (net_info == NULL) - return CONNECTION_ERROR_OPERATION_FAILED; - - if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) - return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; - - if (gateway_address == NULL) - net_info->GatewayAddr.Data.Ipv4.s_addr = 0; - else if (inet_aton(gateway_address, &(net_info->GatewayAddr.Data.Ipv4)) == 0) - return CONNECTION_ERROR_INVALID_PARAMETER; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_set_dns_address(connection_profile_h profile, int order, - connection_address_family_e address_family, const char* dns_address) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || - (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && - address_family != CONNECTION_ADDRESS_FAMILY_IPV6) || - order <= 0 || - order > NET_DNS_ADDR_MAX) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (net_info == NULL) - return CONNECTION_ERROR_OPERATION_FAILED; - - if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) - return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; - - if (dns_address == NULL) - net_info->DnsAddr[order-1].Data.Ipv4.s_addr = 0; - else if (inet_aton(dns_address, &(net_info->DnsAddr[order-1].Data.Ipv4)) == 0) - return CONNECTION_ERROR_INVALID_PARAMETER; - - if (net_info->DnsCount < order) - net_info->DnsCount = order; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_set_proxy_type(connection_profile_h profile, connection_proxy_type_e type) -{ - if (!(_connection_libnet_check_profile_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (net_info == NULL) - return CONNECTION_ERROR_OPERATION_FAILED; - - switch (type) { - case CONNECTION_PROXY_TYPE_DIRECT: - net_info->ProxyMethod = NET_PROXY_TYPE_DIRECT; - break; - case CONNECTION_PROXY_TYPE_AUTO: - net_info->ProxyMethod = NET_PROXY_TYPE_AUTO; - break; - case CONNECTION_PROXY_TYPE_MANUAL: - net_info->ProxyMethod = NET_PROXY_TYPE_MANUAL; - break; - default: - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_set_proxy_address(connection_profile_h profile, - connection_address_family_e address_family, const char* proxy_address) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || - (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && - address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - net_dev_info_t *net_info = __profile_get_net_info(profile_info); - if (net_info == NULL) - return CONNECTION_ERROR_OPERATION_FAILED; - - if (address_family == CONNECTION_ADDRESS_FAMILY_IPV6) - return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; - - if (proxy_address == NULL) - net_info->ProxyAddr[0] = '\0'; - else - g_strlcpy(net_info->ProxyAddr, proxy_address, NET_PROXY_LEN_MAX); - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_set_state_changed_cb(connection_profile_h profile, - connection_profile_state_changed_cb callback, void* user_data) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || callback == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - if (_connection_libnet_add_to_profile_cb_list(profile, callback, user_data)) - return CONNECTION_ERROR_NONE; - - return CONNECTION_ERROR_OPERATION_FAILED; -} - -EXPORT_API int connection_profile_unset_state_changed_cb(connection_profile_h profile) -{ - if (!(_connection_libnet_check_profile_cb_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - _connection_libnet_remove_from_profile_cb_list(profile); - - return CONNECTION_ERROR_NONE; -} - - -/* Wi-Fi profile *************************************************************/ -EXPORT_API int connection_profile_get_wifi_essid(connection_profile_h profile, char** essid) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || essid == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - if (profile_info->profile_type != NET_DEVICE_WIFI) - return CONNECTION_ERROR_INVALID_PARAMETER; - - *essid = g_strdup(profile_info->ProfileInfo.Wlan.essid); - if (*essid == NULL) - return CONNECTION_ERROR_OUT_OF_MEMORY; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_get_wifi_bssid(connection_profile_h profile, char** bssid) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || bssid == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - if (profile_info->profile_type != NET_DEVICE_WIFI) - return CONNECTION_ERROR_INVALID_PARAMETER; - - *bssid = g_strdup(profile_info->ProfileInfo.Wlan.bssid); - if (*bssid == NULL) - return CONNECTION_ERROR_OUT_OF_MEMORY; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_get_wifi_rssi(connection_profile_h profile, int* rssi) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || rssi == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - if (profile_info->profile_type != NET_DEVICE_WIFI) - return CONNECTION_ERROR_INVALID_PARAMETER; - - *rssi = (int)profile_info->ProfileInfo.Wlan.Strength; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_get_wifi_frequency(connection_profile_h profile, int* frequency) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || frequency == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - if (profile_info->profile_type != NET_DEVICE_WIFI) - return CONNECTION_ERROR_INVALID_PARAMETER; - - *frequency = (int)profile_info->ProfileInfo.Wlan.frequency; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_get_wifi_max_speed(connection_profile_h profile, int* max_speed) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || max_speed == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - if (profile_info->profile_type != NET_DEVICE_WIFI) - return CONNECTION_ERROR_INVALID_PARAMETER; - - *max_speed = (int)profile_info->ProfileInfo.Wlan.max_rate; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_get_wifi_security_type(connection_profile_h profile, connection_wifi_security_type_e* type) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - if (profile_info->profile_type != NET_DEVICE_WIFI) - return CONNECTION_ERROR_INVALID_PARAMETER; - - switch (profile_info->ProfileInfo.Wlan.security_info.sec_mode) { - case WLAN_SEC_MODE_NONE: - *type = CONNECTION_WIFI_SECURITY_TYPE_NONE; - break; - case WLAN_SEC_MODE_WEP: - *type = CONNECTION_WIFI_SECURITY_TYPE_WEP; - break; - case WLAN_SEC_MODE_IEEE8021X: - *type = CONNECTION_WIFI_SECURITY_TYPE_EAP; - break; - case WLAN_SEC_MODE_WPA_PSK: - *type = CONNECTION_WIFI_SECURITY_TYPE_WPA_PSK; - break; - case WLAN_SEC_MODE_WPA2_PSK: - *type = CONNECTION_WIFI_SECURITY_TYPE_WPA2_PSK; - break; - default: - return CONNECTION_ERROR_OPERATION_FAILED; - } - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_get_wifi_encryption_type(connection_profile_h profile, connection_wifi_encryption_type_e* type) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - if (profile_info->profile_type != NET_DEVICE_WIFI) - return CONNECTION_ERROR_INVALID_PARAMETER; - - switch (profile_info->ProfileInfo.Wlan.security_info.enc_mode) { - case WLAN_ENC_MODE_NONE: - *type = CONNECTION_WIFI_ENCRYPTION_TYPE_NONE; - break; - case WLAN_ENC_MODE_WEP: - *type = CONNECTION_WIFI_ENCRYPTION_TYPE_WEP; - break; - case WLAN_ENC_MODE_TKIP: - *type = CONNECTION_WIFI_ENCRYPTION_TYPE_TKIP; - break; - case WLAN_ENC_MODE_AES: - *type = CONNECTION_WIFI_ENCRYPTION_TYPE_AES; - break; - case WLAN_ENC_MODE_TKIP_AES_MIXED: - *type = CONNECTION_WIFI_ENCRYPTION_TYPE_TKIP_AES_MIXED; - break; - default: - return CONNECTION_ERROR_OPERATION_FAILED; - } - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_is_wifi_passphrase_required(connection_profile_h profile, bool* required) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || required == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - if (profile_info->profile_type != NET_DEVICE_WIFI) - return CONNECTION_ERROR_INVALID_PARAMETER; - - if (profile_info->Favourite) { - *required = false; - return CONNECTION_ERROR_NONE; - } - - switch (profile_info->ProfileInfo.Wlan.security_info.sec_mode) { - case WLAN_SEC_MODE_NONE: - *required = false; - break; - case WLAN_SEC_MODE_WEP: - case WLAN_SEC_MODE_IEEE8021X: - case WLAN_SEC_MODE_WPA_PSK: - case WLAN_SEC_MODE_WPA2_PSK: - *required = true; - break; - default: - return CONNECTION_ERROR_OPERATION_FAILED; - } - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_set_wifi_passphrase(connection_profile_h profile, const char* passphrase) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || passphrase == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - if (profile_info->profile_type != NET_DEVICE_WIFI) - return CONNECTION_ERROR_INVALID_PARAMETER; - - g_strlcpy(profile_info->ProfileInfo.Wlan.security_info.authentication.psk.pskKey, - passphrase, NETPM_WLAN_MAX_PSK_PASSPHRASE_LEN); - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_is_wifi_wps_supported(connection_profile_h profile, bool* supported) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || supported == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - if (profile_info->profile_type != NET_DEVICE_WIFI) - return CONNECTION_ERROR_INVALID_PARAMETER; - - if (profile_info->ProfileInfo.Wlan.security_info.wps_support) - *supported = true; - else - *supported = false; - - return CONNECTION_ERROR_NONE; -} - - -/* Cellular profile **********************************************************/ -EXPORT_API int connection_profile_get_cellular_network_type(connection_profile_h profile, connection_cellular_network_type_e* type) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - 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) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - if (profile_info->profile_type != NET_DEVICE_CELLULAR) { - CONNECTION_LOG(CONNECTION_ERROR, "Invalid profile type Passed\n"); - 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"); - return CONNECTION_ERROR_OPERATION_FAILED; - } - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_get_cellular_apn(connection_profile_h profile, char** apn) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || apn == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - if (profile_info->profile_type != NET_DEVICE_CELLULAR) - return CONNECTION_ERROR_INVALID_PARAMETER; - - *apn = g_strdup(profile_info->ProfileInfo.Pdp.Apn); - if (*apn == NULL) - return CONNECTION_ERROR_OUT_OF_MEMORY; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_get_cellular_auth_info(connection_profile_h profile, - connection_cellular_auth_type_e* type, char** user_name, char** password) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || - type == NULL || user_name == NULL || password == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - if (profile_info->profile_type != NET_DEVICE_CELLULAR) - return CONNECTION_ERROR_INVALID_PARAMETER; - - switch (profile_info->ProfileInfo.Pdp.AuthInfo.AuthType) { - case NET_PDP_AUTH_NONE: - *type = CONNECTION_CELLULAR_AUTH_TYPE_NONE; - break; - case NET_PDP_AUTH_PAP: - *type = CONNECTION_CELLULAR_AUTH_TYPE_PAP; - break; - case NET_PDP_AUTH_CHAP: - *type = CONNECTION_CELLULAR_AUTH_TYPE_CHAP; - break; - default: - return CONNECTION_ERROR_OPERATION_FAILED; - } - - *user_name = g_strdup(profile_info->ProfileInfo.Pdp.AuthInfo.UserName); - if (*user_name == NULL) - return CONNECTION_ERROR_OUT_OF_MEMORY; - - *password = g_strdup(profile_info->ProfileInfo.Pdp.AuthInfo.Password); - if (*password == NULL) { - g_free(*user_name); - return CONNECTION_ERROR_OUT_OF_MEMORY; - } - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_get_cellular_home_url(connection_profile_h profile, char** home_url) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || home_url == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - if (profile_info->profile_type != NET_DEVICE_CELLULAR) - return CONNECTION_ERROR_INVALID_PARAMETER; - - *home_url = g_strdup(profile_info->ProfileInfo.Pdp.HomeURL); - if (*home_url == NULL) - return CONNECTION_ERROR_OUT_OF_MEMORY; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_is_cellular_roaming(connection_profile_h profile, bool* is_roaming) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || is_roaming == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - if (profile_info->profile_type != NET_DEVICE_CELLULAR) - return CONNECTION_ERROR_INVALID_PARAMETER; - - if (profile_info->ProfileInfo.Pdp.Roaming) - *is_roaming = true; - else - *is_roaming = false; - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_set_cellular_service_type(connection_profile_h profile, - connection_cellular_service_type_e service_type) -{ - if (!(_connection_libnet_check_profile_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - if (profile_info->profile_type != NET_DEVICE_CELLULAR) - return CONNECTION_ERROR_INVALID_PARAMETER; - - switch (service_type) { - case CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET: - profile_info->ProfileInfo.Pdp.ServiceType = NET_SERVICE_INTERNET; - break; - case CONNECTION_CELLULAR_SERVICE_TYPE_MMS: - profile_info->ProfileInfo.Pdp.ServiceType = NET_SERVICE_MMS; - break; - case CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET: - profile_info->ProfileInfo.Pdp.ServiceType = NET_SERVICE_PREPAID_INTERNET; - break; - case CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS: - profile_info->ProfileInfo.Pdp.ServiceType = NET_SERVICE_PREPAID_MMS; - break; - case CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING: - profile_info->ProfileInfo.Pdp.ServiceType = NET_SERVICE_TETHERING; - break; - case CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION: - profile_info->ProfileInfo.Pdp.ServiceType = NET_SERVICE_APPLICATION; - break; - case CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN: - default: - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_set_cellular_apn(connection_profile_h profile, const char* apn) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || apn == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - if (profile_info->profile_type != NET_DEVICE_CELLULAR) - return CONNECTION_ERROR_INVALID_PARAMETER; - - g_strlcpy(profile_info->ProfileInfo.Pdp.Apn, apn, NET_PDP_APN_LEN_MAX+1); - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_set_cellular_auth_info(connection_profile_h profile, - connection_cellular_auth_type_e type, const char* user_name, const char* password) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || - user_name == NULL || password == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - if (profile_info->profile_type != NET_DEVICE_CELLULAR) - return CONNECTION_ERROR_INVALID_PARAMETER; - - switch (type) { - case CONNECTION_CELLULAR_AUTH_TYPE_NONE: - profile_info->ProfileInfo.Pdp.AuthInfo.AuthType = NET_PDP_AUTH_NONE; - break; - case CONNECTION_CELLULAR_AUTH_TYPE_PAP: - profile_info->ProfileInfo.Pdp.AuthInfo.AuthType = NET_PDP_AUTH_PAP; - break; - case CONNECTION_CELLULAR_AUTH_TYPE_CHAP: - profile_info->ProfileInfo.Pdp.AuthInfo.AuthType = NET_PDP_AUTH_CHAP; - break; - default: - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - g_strlcpy(profile_info->ProfileInfo.Pdp.AuthInfo.UserName, user_name, NET_PDP_AUTH_USERNAME_LEN_MAX+1); - g_strlcpy(profile_info->ProfileInfo.Pdp.AuthInfo.Password, password, NET_PDP_AUTH_PASSWORD_LEN_MAX+1); - - return CONNECTION_ERROR_NONE; -} - -EXPORT_API int connection_profile_set_cellular_home_url(connection_profile_h profile, const char* home_url) -{ - if (!(_connection_libnet_check_profile_validity(profile)) || home_url == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - if (profile_info->profile_type != NET_DEVICE_CELLULAR) - return CONNECTION_ERROR_INVALID_PARAMETER; - - g_strlcpy(profile_info->ProfileInfo.Pdp.HomeURL, home_url, NET_HOME_URL_LEN_MAX); - - return CONNECTION_ERROR_NONE; -} diff --git a/mobile/src/internal.c b/mobile/src/internal.c deleted file mode 100755 index ad0b88f..0000000 --- a/mobile/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 <stdio.h> -#include <string.h> -#include <glib.h> -#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/mobile/src/libnetwork.c b/mobile/src/libnetwork.c deleted file mode 100755 index 1a8390d..0000000 --- a/mobile/src/libnetwork.c +++ /dev/null @@ -1,820 +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 <stdio.h> -#include <string.h> -#include <glib.h> -#include <vconf/vconf.h> -#include "net_connection_private.h" - -static GSList *prof_handle_list = NULL; -static GHashTable *profile_cb_table = NULL; - -struct _profile_cb_s { - connection_profile_state_changed_cb callback; - connection_profile_state_e state; - void *user_data; -}; - -struct _profile_list_s { - int count; - int next; - net_profile_info_t *profiles; -}; - -struct _libnet_s { - connection_opened_cb opened_cb; - connection_closed_cb closed_cb; - connection_set_default_cb set_default_cb; - void *opened_user_data; - void *closed_user_data; - void *set_default_user_data; - bool registered; -}; - -static struct _profile_list_s profile_iterator = {0, 0, NULL}; -static struct _libnet_s libnet = {NULL, NULL, NULL, NULL, NULL, NULL, false}; - -static connection_error_e __libnet_convert_to_cp_error_type(net_err_t err_type) -{ - switch (err_type) { - case NET_ERR_NONE: - return CONNECTION_ERROR_NONE; - case NET_ERR_APP_ALREADY_REGISTERED: - return CONNECTION_ERROR_INVALID_OPERATION; - case NET_ERR_APP_NOT_REGISTERED: - return CONNECTION_ERROR_INVALID_OPERATION; - case NET_ERR_NO_ACTIVE_CONNECTIONS: - return CONNECTION_ERROR_NO_CONNECTION; - case NET_ERR_ACTIVE_CONNECTION_EXISTS: - return CONNECTION_ERROR_ALREADY_EXISTS; - case NET_ERR_CONNECTION_DHCP_FAILED: - return CONNECTION_ERROR_DHCP_FAILED; - case NET_ERR_CONNECTION_INVALID_KEY: - return CONNECTION_ERROR_INVALID_KEY; - case NET_ERR_IN_PROGRESS: - return CONNECTION_ERROR_NOW_IN_PROGRESS; - case NET_ERR_OPERATION_ABORTED: - return CONNECTION_ERROR_OPERATION_ABORTED; - case NET_ERR_TIME_OUT: - return CONNECTION_ERROR_NO_REPLY; - default: - return CONNECTION_ERROR_OPERATION_FAILED; - } -} - -static const char *__libnet_convert_cp_error_type_to_string(connection_error_e err_type) -{ - switch (err_type) { - case CONNECTION_ERROR_NONE: - return "NONE"; - case CONNECTION_ERROR_INVALID_PARAMETER: - return "INVALID_PARAMETER"; - case CONNECTION_ERROR_OUT_OF_MEMORY: - return "OUT_OF_MEMORY"; - case CONNECTION_ERROR_INVALID_OPERATION: - return "INVALID_OPERATION"; - case CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED: - return "ADDRESS_FAMILY_NOT_SUPPORTED"; - case CONNECTION_ERROR_OPERATION_FAILED: - return "OPERATION_FAILED"; - case CONNECTION_ERROR_ITERATOR_END: - return "ITERATOR_END"; - case CONNECTION_ERROR_NO_CONNECTION: - return "NO_CONNECTION"; - case CONNECTION_ERROR_NOW_IN_PROGRESS: - return "NOW_IN_PROGRESS"; - case CONNECTION_ERROR_ALREADY_EXISTS: - return "ALREADY_EXISTS"; - case CONNECTION_ERROR_OPERATION_ABORTED: - return "OPERATION_ABORTED"; - case CONNECTION_ERROR_DHCP_FAILED: - return "DHCP_FAILED"; - case CONNECTION_ERROR_INVALID_KEY: - return "INVALID_KEY"; - case CONNECTION_ERROR_NO_REPLY: - return "NO_REPLY"; - } - - return "UNKNOWN"; -} - -static const char *__libnet_convert_cp_state_to_string(connection_profile_state_e state) -{ - switch (state) { - case CONNECTION_PROFILE_STATE_DISCONNECTED: - return "DISCONNECTED"; - case CONNECTION_PROFILE_STATE_ASSOCIATION: - return "ASSOCIATION"; - case CONNECTION_PROFILE_STATE_CONFIGURATION: - return "CONFIGURATION"; - case CONNECTION_PROFILE_STATE_CONNECTED: - return "CONNECTED"; - default: - return "UNKNOWN"; - } -} - -static void __libnet_set_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 void __libnet_opened_cb(connection_error_e result) -{ - if (libnet.opened_cb) - libnet.opened_cb(result, libnet.opened_user_data); - - libnet.opened_cb = NULL; - libnet.opened_user_data = NULL; -} - -static void __libnet_set_closed_cb(connection_closed_cb user_cb, void *user_data) -{ - if (user_cb) { - libnet.closed_cb = user_cb; - libnet.closed_user_data = user_data; - } -} - -static void __libnet_closed_cb(connection_error_e result) -{ - if (libnet.closed_cb) - libnet.closed_cb(result, libnet.closed_user_data); - - libnet.closed_cb = NULL; - libnet.closed_user_data = NULL; -} - -static void __libnet_set_default_cb(connection_set_default_cb user_cb, void *user_data) -{ - if (user_cb) { - libnet.set_default_cb = user_cb; - libnet.set_default_user_data = user_data; - } -} - -static void __libnet_default_cb(connection_error_e result) -{ - if (libnet.set_default_cb) - libnet.set_default_cb(result, libnet.set_default_user_data); - - libnet.set_default_cb = NULL; - libnet.set_default_user_data = NULL; -} - -static void __libnet_state_changed_cb(char *profile_name, connection_profile_state_e state) -{ - 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; - - if (cb_info->state == state) - return; - - cb_info->state = state; - - if (state >= 0 && cb_info->callback) - cb_info->callback(state, cb_info->user_data); -} - -static void __libnet_clear_profile_list(struct _profile_list_s *profile_list) -{ - if (profile_list->count > 0) - g_free(profile_list->profiles); - - profile_list->count = 0; - profile_list->next = 0; - profile_list->profiles = NULL; -} - -static void __libnet_evt_cb(net_event_info_t* event_cb, void* user_data) -{ - bool is_requested = false; - connection_error_e result = CONNECTION_ERROR_NONE; - - switch (event_cb->Event) { - case NET_EVENT_OPEN_RSP: - is_requested = true; - /* fall through */ - case NET_EVENT_OPEN_IND: - result = __libnet_convert_to_cp_error_type(event_cb->Error); - CONNECTION_LOG(CONNECTION_INFO, "Got connection open %s : %s\n", - (is_requested) ? "RSP":"IND", - __libnet_convert_cp_error_type_to_string(result)); - - if (is_requested) - __libnet_opened_cb(result); - - switch (event_cb->Error) { - case NET_ERR_NONE: - case NET_ERR_ACTIVE_CONNECTION_EXISTS: - CONNECTION_LOG(CONNECTION_INFO, "'Open connection' succeeded\n"); - - __libnet_state_changed_cb(event_cb->ProfileName, CONNECTION_PROFILE_STATE_CONNECTED); - return; - default: - CONNECTION_LOG(CONNECTION_ERROR, "'Open connection' failed!! [%s]\n", - __libnet_convert_cp_error_type_to_string(result)); - } - - __libnet_state_changed_cb(event_cb->ProfileName, CONNECTION_PROFILE_STATE_DISCONNECTED); - - break; - case NET_EVENT_CLOSE_RSP: - is_requested = true; - /* fall through */ - case NET_EVENT_CLOSE_IND: - result = __libnet_convert_to_cp_error_type(event_cb->Error); - CONNECTION_LOG(CONNECTION_INFO, "Got connection close %s : %s\n", - (is_requested) ? "RSP":"IND", - __libnet_convert_cp_error_type_to_string(result)); - - if (is_requested) - __libnet_closed_cb(result); - - switch (event_cb->Error) { - case NET_ERR_NONE: - CONNECTION_LOG(CONNECTION_INFO, "'Close connection' succeeded!\n"); - - __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)); - } - - break; - case NET_EVENT_NET_STATE_IND: - CONNECTION_LOG(CONNECTION_INFO, "Got State changed IND\n"); - - if (event_cb->Datalength != sizeof(net_state_type_t)) - return; - - net_state_type_t *profile_state = (net_state_type_t*)event_cb->Data; - connection_profile_state_e cp_state = _profile_convert_to_cp_state(*profile_state); - - CONNECTION_LOG(CONNECTION_INFO, - "Profile State : %s, profile name : %s\n", - __libnet_convert_cp_state_to_string(cp_state), - 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); - __libnet_default_cb(result); - break; - case NET_EVENT_WIFI_WPS_RSP: - CONNECTION_LOG(CONNECTION_INFO, "Got wifi WPS RSP\n"); - /* fall through */ - default : - CONNECTION_LOG(CONNECTION_ERROR, "Error! Unknown Event\n\n"); - break; - } -} - -int __libnet_get_connected_count(struct _profile_list_s *profile_list) -{ - int count = 0; - int i = 0; - - for (;i < profile_list->count;i++) { - if (profile_list->profiles[i].ProfileState == NET_STATE_TYPE_ONLINE || - profile_list->profiles[i].ProfileState == NET_STATE_TYPE_READY) - count++; - } - - return count; -} - -void __libnet_copy_connected_profile(net_profile_info_t **dest, struct _profile_list_s *source) -{ - int i = 0; - - for (;i < source->count;i++) { - if (source->profiles[i].ProfileState == NET_STATE_TYPE_ONLINE || - source->profiles[i].ProfileState == NET_STATE_TYPE_READY) { - memcpy(*dest, &source->profiles[i], sizeof(net_profile_info_t)); - (*dest)++; - } - } -} - -bool _connection_libnet_init(void) -{ - int rv; - - if (!libnet.registered) { - rv = net_register_client_ext((net_event_cb_t)__libnet_evt_cb, NET_DEVICE_DEFAULT, NULL); - if (rv != NET_ERR_NONE) - return false; - - libnet.registered = true; - - if (profile_cb_table == NULL) - profile_cb_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); - } - - return true; -} - -bool _connection_libnet_deinit(void) -{ - if (libnet.registered) { - if (net_deregister_client_ext(NET_DEVICE_DEFAULT) != NET_ERR_NONE) - return false; - - libnet.registered = false; - - if (profile_cb_table) { - g_hash_table_destroy(profile_cb_table); - profile_cb_table = NULL; - } - - __libnet_clear_profile_list(&profile_iterator); - - if (prof_handle_list) { - g_slist_free_full(prof_handle_list, g_free); - prof_handle_list = NULL; - } - } - - return true; -} - -bool _connection_libnet_check_profile_validity(connection_profile_h profile) -{ - GSList *list; - int i = 0; - - for (list = prof_handle_list; list; list = list->next) - if (profile == list->data) return true; - - for (;i < profile_iterator.count;i++) - if (profile == &profile_iterator.profiles[i]) return true; - - return false; -} - -bool _connection_libnet_check_profile_cb_validity(connection_profile_h profile) -{ - struct _profile_cb_s *cb_info; - net_profile_info_t *profile_info = profile; - - if (profile == NULL) - return false; - - cb_info = g_hash_table_lookup(profile_cb_table, profile_info->ProfileName); - if (cb_info != NULL) - return true; - - return false; -} - - -bool _connection_libnet_get_wifi_state(connection_wifi_state_e *state) -{ - net_wifi_state_t wlan_state; - net_profile_name_t profile_name; - - if (net_get_wifi_state(&wlan_state, &profile_name) != NET_ERR_NONE) { - CONNECTION_LOG(CONNECTION_ERROR, "Error!! net_get_wifi_state() failed.\n"); - return false; - } - - switch (wlan_state) { - case WIFI_OFF: - *state = CONNECTION_WIFI_STATE_DEACTIVATED; - break; - case WIFI_ON: - case WIFI_CONNECTING: - *state = CONNECTION_WIFI_STATE_DISCONNECTED; - break; - case WIFI_CONNECTED: - case WIFI_DISCONNECTING: - *state = CONNECTION_WIFI_STATE_CONNECTED; - break; - default : - CONNECTION_LOG(CONNECTION_ERROR, "Error!! Unknown state\n"); - return false; - } - - return true; -} - -bool _connection_libnet_get_ethernet_state(connection_ethernet_state_e* state) -{ - struct _profile_list_s ethernet_profiles = {0, 0, NULL}; - net_get_profile_list(NET_DEVICE_ETHERNET, ðernet_profiles.profiles, ðernet_profiles.count); - - if (ethernet_profiles.count == 0) { - *state = CONNECTION_ETHERNET_STATE_DEACTIVATED; - return true; - } - - switch (ethernet_profiles.profiles->ProfileState) { - case NET_STATE_TYPE_ONLINE: - case NET_STATE_TYPE_READY: - *state = CONNECTION_ETHERNET_STATE_CONNECTED; - break; - case NET_STATE_TYPE_IDLE: - case NET_STATE_TYPE_FAILURE: - case NET_STATE_TYPE_ASSOCIATION: - case NET_STATE_TYPE_CONFIGURATION: - case NET_STATE_TYPE_DISCONNECT: - *state = CONNECTION_ETHERNET_STATE_DISCONNECTED; - break; - default: - return false; - } - - __libnet_clear_profile_list(ðernet_profiles); - - return true; -} - -bool _connection_libnet_get_bluetooth_state(connection_bt_state_e* state) -{ - int i = 0; - struct _profile_list_s bluetooth_profiles = {0, 0, NULL}; - net_get_profile_list(NET_DEVICE_BLUETOOTH, &bluetooth_profiles.profiles, &bluetooth_profiles.count); - - if (bluetooth_profiles.count == 0) { - *state = CONNECTION_BT_STATE_DEACTIVATED; - return true; - } - - for (; i < bluetooth_profiles.count; i++) { - switch (bluetooth_profiles.profiles[i].ProfileState) { - case NET_STATE_TYPE_ONLINE: - case NET_STATE_TYPE_READY: - *state = CONNECTION_BT_STATE_CONNECTED; - goto done; - case NET_STATE_TYPE_IDLE: - case NET_STATE_TYPE_FAILURE: - case NET_STATE_TYPE_ASSOCIATION: - case NET_STATE_TYPE_CONFIGURATION: - case NET_STATE_TYPE_DISCONNECT: - *state = CONNECTION_BT_STATE_DISCONNECTED; - break; - default: - __libnet_clear_profile_list(&bluetooth_profiles); - return false; - } - } - -done: - __libnet_clear_profile_list(&bluetooth_profiles); - - return true; -} - -int _connection_libnet_get_profile_iterator(connection_iterator_type_e type, connection_profile_iterator_h* profile_iter_h) -{ - int count = 0; - int rv; - net_profile_info_t *profiles = NULL; - - struct _profile_list_s all_profiles = {0, 0, NULL}; - - __libnet_clear_profile_list(&profile_iterator); - - rv = net_get_profile_list(NET_DEVICE_MAX, &all_profiles.profiles, &all_profiles.count); - - 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; - } - - *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); - - if (count == 0) - return CONNECTION_ERROR_NONE; - - profile_iterator.profiles = all_profiles.profiles; - - break; - case CONNECTION_ITERATOR_TYPE_CONNECTED: - count = __libnet_get_connected_count(&all_profiles); - CONNECTION_LOG(CONNECTION_INFO, "Total connected profile count : %d\n", 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); - return CONNECTION_ERROR_OUT_OF_MEMORY; - } - - profile_iterator.profiles = profiles; - - __libnet_copy_connected_profile(&profiles, &all_profiles); - - __libnet_clear_profile_list(&all_profiles); - } - - profile_iterator.count = count; - - return CONNECTION_ERROR_NONE; -} - -int _connection_libnet_get_iterator_next(connection_profile_iterator_h profile_iter_h, connection_profile_h *profile) -{ - if (profile_iter_h != &profile_iterator) - return CONNECTION_ERROR_INVALID_PARAMETER; - - if (profile_iterator.count <= profile_iterator.next) - return CONNECTION_ERROR_ITERATOR_END; - - *profile = &profile_iterator.profiles[profile_iterator.next]; - profile_iterator.next++; - - return CONNECTION_ERROR_NONE; -} - -bool _connection_libnet_iterator_has_next(connection_profile_iterator_h profile_iter_h) -{ - if (profile_iter_h != &profile_iterator) - return false; - - if (profile_iterator.count <= profile_iterator.next) - return false; - - return true; -} - -int _connection_libnet_destroy_iterator(connection_profile_iterator_h profile_iter_h) -{ - if (profile_iter_h != &profile_iterator) - return CONNECTION_ERROR_INVALID_PARAMETER; - - __libnet_clear_profile_list(&profile_iterator); - - return CONNECTION_ERROR_NONE; -} - -int _connection_libnet_get_current_profile(connection_profile_h *profile) -{ - net_profile_info_t active_profile; - int rv; - - rv = net_get_active_net_info(&active_profile); - if (rv == NET_ERR_NO_SERVICE) - return CONNECTION_ERROR_NO_CONNECTION; - else if (rv != NET_ERR_NONE) - return CONNECTION_ERROR_OPERATION_FAILED; - - *profile = g_try_malloc0(sizeof(net_profile_info_t)); - if (*profile == NULL) - return CONNECTION_ERROR_OUT_OF_MEMORY; - - memcpy(*profile, &active_profile, sizeof(net_profile_info_t)); - prof_handle_list = g_slist_append(prof_handle_list, *profile); - - return CONNECTION_ERROR_NONE; -} - -int _connection_libnet_open_profile(connection_profile_h profile, connection_opened_cb callback, void* user_data) -{ - if (!(_connection_libnet_check_profile_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - if (net_open_connection_with_profile(profile_info->ProfileName) != NET_ERR_NONE) - return CONNECTION_ERROR_OPERATION_FAILED; - - __libnet_set_opened_cb(callback, user_data); - - return CONNECTION_ERROR_NONE; -} - -int _connection_libnet_get_cellular_service_profile(connection_cellular_service_type_e type, connection_profile_h *profile) -{ - int i = 0; - int j = 0; - int rv = NET_ERR_NONE; - net_service_type_t service_type = _connection_profile_convert_to_libnet_cellular_service_type(type); - - struct _profile_list_s cellular_profiles = {0, 0, NULL}; - - rv = net_get_profile_list(NET_DEVICE_CELLULAR, &cellular_profiles.profiles, &cellular_profiles.count); - if (rv != NET_ERR_NONE) - return CONNECTION_ERROR_OPERATION_FAILED; - - for (;i < cellular_profiles.count;i++) - if (cellular_profiles.profiles[i].ProfileInfo.Pdp.ServiceType == service_type) - break; - - if (i >= cellular_profiles.count) - return CONNECTION_ERROR_OPERATION_FAILED; - - *profile = g_try_malloc0(sizeof(net_profile_info_t)); - if (*profile == NULL) - return CONNECTION_ERROR_OUT_OF_MEMORY; - - memcpy(*profile, &cellular_profiles.profiles[i], sizeof(net_profile_info_t)); - - if (cellular_profiles.profiles[i].ProfileInfo.Pdp.DefaultConn) - goto done; - - if (type != CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET && - type != CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET) - goto done; - - for (;j < cellular_profiles.count;j++) { - if (i == j) - continue; - - if (cellular_profiles.profiles[j].ProfileInfo.Pdp.ServiceType != service_type) - continue; - - if (cellular_profiles.profiles[j].ProfileInfo.Pdp.DefaultConn) { - memcpy(*profile, &cellular_profiles.profiles[j], sizeof(net_profile_info_t)); - goto done; - } - } - -done: - prof_handle_list = g_slist_append(prof_handle_list, *profile); - - return CONNECTION_ERROR_NONE; -} - -int _connection_libnet_set_cellular_service_profile_sync(connection_cellular_service_type_e type, connection_profile_h profile) -{ - if (!(_connection_libnet_check_profile_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - connection_cellular_service_type_e service_type; - - service_type = _profile_convert_to_connection_cellular_service_type(profile_info->ProfileInfo.Pdp.ServiceType); - - if (service_type != type) - return CONNECTION_ERROR_INVALID_PARAMETER; - - if (net_set_default_cellular_service_profile(profile_info->ProfileName) != NET_ERR_NONE) - return CONNECTION_ERROR_OPERATION_FAILED; - - return CONNECTION_ERROR_NONE; -} - -int _connection_libnet_set_cellular_service_profile_async(connection_cellular_service_type_e type, - connection_profile_h profile, connection_set_default_cb callback, void* user_data) -{ - if (!(_connection_libnet_check_profile_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - connection_cellular_service_type_e service_type; - - service_type = _profile_convert_to_connection_cellular_service_type(profile_info->ProfileInfo.Pdp.ServiceType); - - if (service_type != type) - return CONNECTION_ERROR_INVALID_PARAMETER; - - if (net_set_default_cellular_service_profile_async(profile_info->ProfileName) != NET_ERR_NONE) - return CONNECTION_ERROR_OPERATION_FAILED; - - __libnet_set_default_cb(callback, user_data); - - return CONNECTION_ERROR_NONE; -} - -int _connection_libnet_close_profile(connection_profile_h profile, connection_closed_cb callback, void *user_data) -{ - if (!(_connection_libnet_check_profile_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - net_profile_info_t *profile_info = profile; - - 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; -} - -int _connection_libnet_add_route(const char *interface_name, const char *host_address) -{ - char *endstr = strrchr(host_address, '.'); - - if (endstr == NULL || - strcmp(endstr, ".0") == 0 || - strncmp(host_address, "0.", 2) == 0 || - strstr(host_address, ".0.") != NULL || - strstr(host_address, "255") != NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed\n"); - return CONNECTION_ERROR_INVALID_PARAMETER; - } - - if (net_add_route(host_address, interface_name) != NET_ERR_NONE) - return CONNECTION_ERROR_OPERATION_FAILED; - - return CONNECTION_ERROR_NONE; -} - -void _connection_libnet_add_to_profile_list(connection_profile_h profile) -{ - prof_handle_list = g_slist_append(prof_handle_list, profile); -} - -void _connection_libnet_remove_from_profile_list(connection_profile_h profile) -{ - prof_handle_list = g_slist_remove(prof_handle_list, profile); - g_free(profile); -} - -bool _connection_libnet_add_to_profile_cb_list(connection_profile_h profile, - connection_profile_state_changed_cb callback, void *user_data) -{ - net_profile_info_t *profile_info = profile; - char *profile_name = g_strdup(profile_info->ProfileName); - - struct _profile_cb_s *profile_cb_info = g_try_malloc0(sizeof(struct _profile_cb_s)); - if (profile_cb_info == NULL) { - g_free(profile_name); - return false; - } - - profile_cb_info->callback = callback; - profile_cb_info->user_data = user_data; - - g_hash_table_insert(profile_cb_table, profile_name, profile_cb_info); - - return true; -} - -void _connection_libnet_remove_from_profile_cb_list(connection_profile_h profile) -{ - net_profile_info_t *profile_info = profile; - g_hash_table_remove(profile_cb_table, profile_info->ProfileName); -} - -int _connection_libnet_set_statistics(net_device_t device_type, net_statistics_type_e statistics_type) -{ - if (net_set_statistics(device_type, statistics_type) != NET_ERR_NONE) - return CONNECTION_ERROR_OPERATION_FAILED; - - return CONNECTION_ERROR_NONE; -} - -int _connection_libnet_get_statistics(net_statistics_type_e statistics_type, unsigned long long *size) -{ - if (net_get_statistics(NET_DEVICE_WIFI, statistics_type, size) != NET_ERR_NONE) - return CONNECTION_ERROR_OPERATION_FAILED; - - return CONNECTION_ERROR_NONE; -} - diff --git a/mobile/test/CMakeLists.txt b/mobile/test/CMakeLists.txt deleted file mode 100644 index 7f2f801..0000000 --- a/mobile/test/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -SET(fw_test "${fw_name}-test") - -SET(dependents "capi-base-common glib-2.0 network") - -INCLUDE(FindPkgConfig) -pkg_check_modules(${fw_test} REQUIRED ${dependents}) -FOREACH(flag ${${fw_test}_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall") - -aux_source_directory(. sources) -FOREACH(src ${sources}) - GET_FILENAME_COMPONENT(src_name ${src} NAME_WE) - MESSAGE("${src_name}") - ADD_EXECUTABLE(${src_name} ${src}) - TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS}) -ENDFOREACH() diff --git a/mobile/test/connection_test.c b/mobile/test/connection_test.c deleted file mode 100644 index 3af6842..0000000 --- a/mobile/test/connection_test.c +++ /dev/null @@ -1,1522 +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 <stdio.h> -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <glib.h> - -#include "net_connection.h" -#include <tizen_error.h> - -#define RETURN_FAIL_DESTROY(x) {connection_profile_destroy(x); return -1;} - -gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data); - -connection_h connection = NULL; -static GSList *state_cb_list = NULL; - - -static bool test_get_user_string(const char *msg, char *buf, int buf_size) -{ - if (msg == NULL || buf == NULL || buf_size < 2) - return false; - - int rv; - printf("%s\n", msg); - memset(buf, 0, buf_size); - rv = read(0, buf, buf_size - 1); - - if (rv < 0 || buf[0] == '\0' || buf[0] == '\n' || buf[0] == '\r') { - buf[0] = '\0'; - return false; - } - - buf[strlen(buf) - 1] = '\0'; - - return true; -} - -static bool test_get_user_int(const char *msg, int *num) -{ - if (msg == NULL || num == NULL) - return false; - - int rv; - char buf[32] = {0,}; - printf("%s\n", msg); - rv = read(0, buf, 32); - - if (rv < 0 || *buf == 0 || *buf == '\n' || *buf == '\r') - return false; - - *num = atoi(buf); - return true; -} - -static const char *test_print_state(connection_profile_state_e state) -{ - switch (state) { - case CONNECTION_PROFILE_STATE_DISCONNECTED: - return "Disconnected"; - case CONNECTION_PROFILE_STATE_ASSOCIATION: - return "Association"; - case CONNECTION_PROFILE_STATE_CONFIGURATION: - return "Configuration"; - case CONNECTION_PROFILE_STATE_CONNECTED: - return "Connected"; - default: - return "Unknown"; - } -} - -static void test_type_changed_callback(connection_type_e type, void* user_data) -{ - printf("Type changed callback, connection type : %d\n", type); -} - -static void test_ip_changed_callback(const char* ipv4_address, const char* ipv6_address, void* user_data) -{ - printf("IP changed callback, IPv4 address : %s, IPv6 address : %s\n", - ipv4_address, (ipv6_address ? ipv6_address : "NULL")); -} - -static void test_proxy_changed_callback(const char* ipv4_address, const char* ipv6_address, void* user_data) -{ - printf("Proxy changed callback, IPv4 address : %s, IPv6 address : %s\n", - ipv4_address, (ipv6_address ? ipv6_address : "NULL")); -} - -static void test_profile_state_callback(connection_profile_state_e state, void* user_data) -{ - char *profile_name; - connection_profile_h profile = user_data; - - if (profile == NULL) - return; - - if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) - return; - - printf("[%s] : %s\n", test_print_state(state), profile_name); - g_free(profile_name); -} - -static void test_connection_opened_callback(connection_error_e result, void* user_data) -{ - if (result == CONNECTION_ERROR_NONE) - printf("Connection open Succeeded\n"); - else - printf("Connection open Failed, err : %d\n", result); -} - -static void test_connection_closed_callback(connection_error_e result, void* user_data) -{ - if (result == CONNECTION_ERROR_NONE) - printf("Connection close Succeeded\n"); - else - printf("Connection close Failed, err : %d\n", result); -} - -static void test_connection_set_default_callback(connection_error_e result, void* user_data) -{ - if (result == CONNECTION_ERROR_NONE) - printf("Default profile setting Succeeded\n"); - else - printf("Default profile setting Failed, err : %d\n", result); -} - -static bool test_get_user_selected_profile(connection_profile_h *profile, bool select) -{ - int rv = 0; - int input = 0; - char *profile_name; - connection_profile_type_e profile_type; - connection_profile_state_e profile_state; - connection_profile_iterator_h profile_iter; - connection_profile_h profile_h; - - connection_profile_h profile_list[100] = {0,}; - int profile_count = 0; - - 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); - return false; - } - - while (connection_profile_iterator_has_next(profile_iter)) { - if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) { - printf("Fail to get profile handle\n"); - return false; - } - - if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) { - printf("Fail to get profile name\n"); - return false; - } - - if (connection_profile_get_type(profile_h, &profile_type) != CONNECTION_ERROR_NONE) { - printf("Fail to get profile type\n"); - g_free(profile_name); - return false; - } - - if (connection_profile_get_state(profile_h, &profile_state) != CONNECTION_ERROR_NONE) { - printf("Fail to get profile state\n"); - g_free(profile_name); - return false; - } - - if (profile_type == CONNECTION_PROFILE_TYPE_WIFI) { - char *essid; - connection_profile_get_wifi_essid(profile_h, &essid); - printf("%d. state:[%s], profile name:%s, essid:%s\n", - profile_count, test_print_state(profile_state), - profile_name, (essid)? essid : ""); - g_free(essid); - - profile_list[profile_count] = profile_h; - profile_count++; - } else { - printf("%d. state:[%s], profile name : %s\n", - profile_count, test_print_state(profile_state), profile_name); - - profile_list[profile_count] = profile_h; - profile_count++; - } - - g_free(profile_name); - if (profile_count >= 100) - break; - } - - if (select == false) - return true; - - if (test_get_user_int("Input profile number(Enter for cancel) :", &input) == false || - input >= profile_count || - input < 0) { - printf("Wrong number!!\n"); - return false; - } - - if (profile) - *profile = profile_list[input]; - - return true; -} - -static int test_update_cellular_info(connection_profile_h profile) -{ - int rv = 0; - char input_str1[100] = {0,}; - char input_str2[100] = {0,}; - int input_int = 0; - int type_val = 0; - - if (test_get_user_int("Input Network Type (internet:1, MMS:2, Prepaid internet:3, " - "Prepaid MMS:4, Tethering:5, Application:6)" - " - (Enter for skip) :", &input_int)) { - switch (input_int) { - case 1: - rv = connection_profile_set_cellular_service_type(profile, - CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET); - break; - case 2: - rv = connection_profile_set_cellular_service_type(profile, - CONNECTION_CELLULAR_SERVICE_TYPE_MMS); - break; - case 3: - rv = connection_profile_set_cellular_service_type(profile, - CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET); - break; - case 4: - rv = connection_profile_set_cellular_service_type(profile, - CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS); - break; - case 5: - rv = connection_profile_set_cellular_service_type(profile, - CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING); - break; - case 6: - rv = connection_profile_set_cellular_service_type(profile, - CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION); - break; - default: - return -1; - } - - if (rv != CONNECTION_ERROR_NONE) - return -1; - } else - return -1; - - if (test_get_user_string("Input Apn - (Enter for skip) :", input_str1, 100)) { - 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)) { - 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)) { - rv = connection_profile_set_cellular_home_url(profile, input_str1); - if (rv != CONNECTION_ERROR_NONE) - return -1; - } - - if (test_get_user_int("Input AuthType(0:NONE 1:PAP 2:CHAP) - (Enter for skip) :", &input_int)) { - switch (input_int) { - case 0: - rv = connection_profile_set_cellular_auth_info(profile, - CONNECTION_CELLULAR_AUTH_TYPE_NONE, "", ""); - if (rv != CONNECTION_ERROR_NONE) - return -1; - - break; - case 1: - type_val = CONNECTION_CELLULAR_AUTH_TYPE_PAP; - /* fall through */ - case 2: - if (input_int == 2) type_val = CONNECTION_CELLULAR_AUTH_TYPE_CHAP; - - if (test_get_user_string("Input AuthId(Enter for skip) :", input_str1, 100) == false) - input_str1[0] = 0; - if (test_get_user_string("Input AuthPwd(Enter for skip) :", input_str2, 100) == false) - input_str2[0] = 0; - - rv = connection_profile_set_cellular_auth_info(profile, type_val, input_str1, input_str2); - if (rv != CONNECTION_ERROR_NONE) - return -1; - } - } - - return 1; -} - -static int test_update_wifi_info(connection_profile_h profile) -{ - int rv = 0; - char input_str[100] = {0,}; - - if (test_get_user_string("Input Passphrase - (Enter for skip) :", input_str, 100)) { - rv = connection_profile_set_wifi_passphrase(profile, input_str); - if (rv != CONNECTION_ERROR_NONE) - return -1; - } - - return 1; -} - -static int test_update_ip_info(connection_profile_h profile) -{ - int rv = 0; - char input_str[100] = {0,}; - - if (test_get_user_string("Input IP Address - (Enter for skip) :", input_str, 100)) { - rv = connection_profile_set_ip_address(profile, - CONNECTION_ADDRESS_FAMILY_IPV4, - input_str); - if (rv != CONNECTION_ERROR_NONE) - return -1; - } - - if (test_get_user_string("Input Netmask - (Enter for skip) :", input_str, 100)) { - rv = connection_profile_set_subnet_mask(profile, - CONNECTION_ADDRESS_FAMILY_IPV4, - input_str); - if (rv != CONNECTION_ERROR_NONE) - return -1; - } - - if (test_get_user_string("Input Gateway - (Enter for skip) :", input_str, 100)) { - rv = connection_profile_set_gateway_address(profile, - CONNECTION_ADDRESS_FAMILY_IPV4, - input_str); - if (rv != CONNECTION_ERROR_NONE) - return -1; - } - - if (test_get_user_string("Input DNS 1 Address - (Enter for skip) :", input_str, 100)) { - rv = connection_profile_set_dns_address(profile, - 1, - CONNECTION_ADDRESS_FAMILY_IPV4, - input_str); - if (rv != CONNECTION_ERROR_NONE) - return -1; - - if (test_get_user_string("Input DNS 2 Address - (Enter for skip) :", input_str, 100)) { - rv = connection_profile_set_dns_address(profile, - 2, - CONNECTION_ADDRESS_FAMILY_IPV4, - input_str); - if (rv != CONNECTION_ERROR_NONE) - return -1; - } - } - - return 1; -} - -static int test_update_proxy_info(connection_profile_h profile) -{ - int rv = 0; - int input_int = 0; - char input_str[100] = {0,}; - - if (test_get_user_int("Input Proxy Type (1:direct, 2:auto, 3:manual)" - " - (Enter for skip) :", &input_int)) { - switch (input_int) { - case 1: - rv = connection_profile_set_proxy_type(profile, - CONNECTION_PROXY_TYPE_DIRECT); - - if (rv != CONNECTION_ERROR_NONE) - return -1; - else - return 1; - case 2: - rv = connection_profile_set_proxy_type(profile, - CONNECTION_PROXY_TYPE_AUTO); - break; - case 3: - rv = connection_profile_set_proxy_type(profile, - CONNECTION_PROXY_TYPE_MANUAL); - break; - default: - return -1; - } - - if (rv != CONNECTION_ERROR_NONE) - return -1; - - if (test_get_user_string("Input auto Proxy URL or Proxy address" - " - (Enter for skip) :", input_str, 100)) { - rv = connection_profile_set_proxy_address(profile, - CONNECTION_ADDRESS_FAMILY_IPV4, - input_str); - if (rv != CONNECTION_ERROR_NONE) - return -1; - } - - } else - return -1; - - return 1; -} - -static int test_update_network_info(connection_profile_h profile) -{ - int rv = 0; - int input_int = 0; - - if (test_get_user_int("Input IPv4 Address Type (DHCP:1, Static:2)" - " - (Enter for skip) :", &input_int)) { - switch (input_int) { - case 1: - rv = connection_profile_set_ip_config_type(profile, - CONNECTION_ADDRESS_FAMILY_IPV4, - CONNECTION_IP_CONFIG_TYPE_DYNAMIC); - break; - case 2: - rv = connection_profile_set_ip_config_type(profile, - CONNECTION_ADDRESS_FAMILY_IPV4, - CONNECTION_IP_CONFIG_TYPE_STATIC); - if (rv != CONNECTION_ERROR_NONE) - return -1; - - if (test_update_ip_info(profile) == -1) - return -1; - - if (test_update_proxy_info(profile) == -1) - return -1; - break; - default: - return -1; - } - - if (rv != CONNECTION_ERROR_NONE) - return -1; - } else - return -1; - - return 1; -} - -static void test_print_cellular_info(connection_profile_h profile) -{ - connection_cellular_network_type_e network_type; - connection_cellular_service_type_e service_type; - char *apn = NULL; - connection_cellular_auth_type_e auth_type; - char *user_name = NULL; - char *password = NULL; - char *home_url = NULL; - bool roaming = false; - - 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 - printf("Cellular service type : %d\n", service_type); - - if (connection_profile_get_cellular_apn(profile, &apn) != CONNECTION_ERROR_NONE) - printf("Fail to get cellular APN!\n"); - else { - printf("Cellular APN : %s\n", apn); - g_free(apn); - } - - if (connection_profile_get_cellular_auth_info(profile, &auth_type, &user_name, &password) != CONNECTION_ERROR_NONE) - printf("Fail to get auth info!\n"); - else { - printf("Cellular auth type : %d\n", auth_type); - printf("Cellular user_name : %s\n", user_name); - printf("Cellular password : %s\n", password); - g_free(user_name); - g_free(password); - } - - if (connection_profile_get_cellular_home_url(profile, &home_url) != CONNECTION_ERROR_NONE) - printf("Fail to get cellular home url!\n"); - else { - printf("Cellular home url : %s\n", home_url); - g_free(home_url); - } - - if (connection_profile_is_cellular_roaming(profile, &roaming) != CONNECTION_ERROR_NONE) - printf("Fail to get cellular is roaming!\n"); - else - printf("Cellular roaming : %s\n", roaming ? "true" : "false"); -} - -static void test_print_wifi_info(connection_profile_h profile) -{ - char *essid = NULL; - char *bssid = NULL; - int rssi = 0; - int frequency = 0; - int max_speed = 0; - connection_wifi_security_type_e security_type; - connection_wifi_encryption_type_e encryption_type; - bool pass_required = false; - bool wps_supported = false; - - if (connection_profile_get_wifi_essid(profile, &essid) != CONNECTION_ERROR_NONE) - printf("Fail to get Wi-Fi essid!\n"); - else { - printf("Wi-Fi essid : %s\n", essid); - g_free(essid); - } - - if (connection_profile_get_wifi_bssid(profile, &bssid) != CONNECTION_ERROR_NONE) - printf("Fail to get Wi-Fi bssid!\n"); - else { - printf("Wi-Fi bssid : %s\n", bssid); - g_free(bssid); - } - - if (connection_profile_get_wifi_rssi(profile, &rssi) != CONNECTION_ERROR_NONE) - printf("Fail to get Wi-Fi rssi!\n"); - else - printf("Wi-Fi rssi : %d\n", rssi); - - if (connection_profile_get_wifi_frequency(profile, &frequency) != CONNECTION_ERROR_NONE) - printf("Fail to get Wi-Fi frequency!\n"); - else - printf("Wi-Fi frequency : %d\n", frequency); - - if (connection_profile_get_wifi_max_speed(profile, &max_speed) != CONNECTION_ERROR_NONE) - printf("Fail to get Wi-Fi max speed!\n"); - else - printf("Wi-Fi max speed : %d\n", max_speed); - - if (connection_profile_get_wifi_security_type(profile, &security_type) != CONNECTION_ERROR_NONE) - printf("Fail to get Wi-Fi security type!\n"); - else - printf("Wi-Fi security type : %d\n", security_type); - - if (connection_profile_get_wifi_encryption_type(profile, &encryption_type) != CONNECTION_ERROR_NONE) - printf("Fail to get Wi-Fi encryption type!\n"); - else - printf("Wi-Fi encryption type : %d\n", encryption_type); - - if (connection_profile_is_wifi_passphrase_required(profile, &pass_required) != CONNECTION_ERROR_NONE) - printf("Fail to get Wi-Fi passphrase required!\n"); - else - printf("Wi-Fi passphrase required : %s\n", pass_required ? "true" : "false"); - - if (connection_profile_is_wifi_wps_supported(profile, &wps_supported) != CONNECTION_ERROR_NONE) - printf("Fail to get Wi-Fi wps info\n"); - else - printf("Wi-Fi wps supported : %s\n", wps_supported ? "true" : "false"); -} - -static void test_print_network_info(connection_profile_h profile) -{ - char *interface_name = NULL; - connection_ip_config_type_e ip_type; - char *ip = NULL; - char *subnet = NULL; - char *gateway = NULL; - char *dns1 = NULL; - char *dns2 = NULL; - connection_proxy_type_e proxy_type; - char *proxy = NULL; - - if (connection_profile_get_network_interface_name(profile, &interface_name) != CONNECTION_ERROR_NONE) - printf("Fail to get interface name!\n"); - else { - printf("Interface name : %s\n", interface_name); - g_free(interface_name); - } - - if (connection_profile_get_ip_config_type(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_type) != CONNECTION_ERROR_NONE) - printf("Fail to get ipconfig type!\n"); - else - printf("Ipconfig type : %d\n", ip_type); - - if (connection_profile_get_ip_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &ip) != CONNECTION_ERROR_NONE) - printf("Fail to get IP address!\n"); - else { - printf("IP address : %s\n", ip); - g_free(ip); - } - - if (connection_profile_get_subnet_mask(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &subnet) != CONNECTION_ERROR_NONE) - printf("Fail to get subnet mask!\n"); - else { - printf("Subnet mask : %s\n", subnet); - g_free(subnet); - } - - if (connection_profile_get_gateway_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &gateway) != CONNECTION_ERROR_NONE) - printf("Fail to get gateway!\n"); - else { - printf("Gateway : %s\n", gateway); - g_free(gateway); - } - - if (connection_profile_get_dns_address(profile, 1, CONNECTION_ADDRESS_FAMILY_IPV4, &dns1) != CONNECTION_ERROR_NONE) - printf("Fail to get DNS1!\n"); - else { - printf("DNS1 : %s\n", dns1); - g_free(dns1); - } - - if (connection_profile_get_dns_address(profile, 2, CONNECTION_ADDRESS_FAMILY_IPV4, &dns2) != CONNECTION_ERROR_NONE) - printf("Fail to get DNS2!\n"); - else { - printf("DNS2 : %s\n", dns2); - g_free(dns2); - } - - if (connection_profile_get_proxy_type(profile, &proxy_type) != CONNECTION_ERROR_NONE) - printf("Fail to get proxy type!\n"); - else - printf("Proxy type : %d\n", proxy_type); - - if (connection_profile_get_proxy_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy) != CONNECTION_ERROR_NONE) - printf("Fail to get proxy!\n"); - else { - printf("Proxy : %s\n", proxy); - g_free(proxy); - } -} - -int test_register_client(void) -{ - - int err = connection_create(&connection); - - if (CONNECTION_ERROR_NONE == err) { - connection_set_type_changed_cb(connection, test_type_changed_callback, NULL); - connection_set_ip_address_changed_cb(connection, test_ip_changed_callback, NULL); - connection_set_proxy_address_changed_cb(connection, test_proxy_changed_callback, NULL); - } else { - printf("Client registration failed %d\n", err); - return -1; - } - - printf("Client registration success\n"); - return 1; -} - -int test_deregister_client(void) -{ - int rv = 0; - GSList *list; - connection_profile_h profile; - - if (connection != NULL) - rv = connection_destroy(connection); - else { - printf("Cannot deregister : Handle is NULL\n"); - rv = CONNECTION_ERROR_INVALID_OPERATION; - } - - if (rv != CONNECTION_ERROR_NONE){ - printf("Client deregistration fail [%d]\n", rv); - return -1; - } - - if (state_cb_list) { - for (list = state_cb_list; list; list = list->next) { - profile = list->data; - connection_profile_destroy(profile); - } - - g_slist_free(state_cb_list); - state_cb_list = NULL; - } - - connection = NULL; - printf("Client deregistration success\n"); - - return 1; -} - -int test_get_network_state(void) -{ - int rv = 0; - connection_type_e net_state; - - rv = connection_get_type(connection, &net_state); - - if (rv != CONNECTION_ERROR_NONE) { - printf("Fail to get network state [%d]\n", rv); - return -1; - } - - printf("Retval = %d network connection state [%d]\n", rv, net_state); - - return 1; -} - -int test_get_cellular_state(void) -{ - int rv = 0; - connection_cellular_state_e cellular_state; - - rv = connection_get_cellular_state(connection, &cellular_state); - - if (rv != CONNECTION_ERROR_NONE) { - printf("Fail to get Cellular state [%d]\n", rv); - return -1; - } - - printf("Retval = %d Cellular state [%d]\n", rv, cellular_state); - - return 1; -} - -int test_get_wifi_state(void) -{ - int rv = 0; - connection_wifi_state_e wifi_state; - - rv = connection_get_wifi_state(connection, &wifi_state); - - if (rv != CONNECTION_ERROR_NONE) { - printf("Fail to get WiFi state [%d]\n", rv); - return -1; - } - - printf("Retval = %d WiFi state [%d]\n", rv, wifi_state); - - return 1; -} - -int test_get_current_proxy(void) -{ - char *proxy_addr = NULL; - - connection_get_proxy(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy_addr); - - if (proxy_addr == NULL) { - printf("Proxy address does not exist\n"); - return -1; - } - - printf("Current Proxy [%s]\n", proxy_addr); - g_free(proxy_addr); - - return 1; -} - -int test_get_current_ip(void) -{ - char *ip_addr = NULL; - - connection_get_ip_address(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &ip_addr); - - if (ip_addr == NULL) { - printf("IP address does not exist\n"); - return -1; - } - - printf("IPv4 address : %s\n", ip_addr); - g_free(ip_addr); - - return 1; -} - -int test_get_call_statistics_info(void) -{ - long long rv = 0; - - connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv); - printf("last recv data size [%lld]\n", rv); - connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv); - printf("last sent data size [%lld]\n",rv ); - connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv); - printf("total received data size [%lld]\n",rv ); - connection_get_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv); - printf("total sent data size [%lld]\n", rv); - - return 1; -} - -int test_get_wifi_call_statistics_info(void) -{ - long long rv = 0; - - connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA, &rv); - printf("WiFi last recv data size [%lld]\n", rv); - connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA, &rv); - printf("WiFi last sent data size [%lld]\n",rv ); - connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA, &rv); - printf("WiFi total received data size [%lld]\n",rv ); - connection_get_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA, &rv); - printf("WiFi total sent data size [%lld]\n", rv); - - return 1; -} - -int test_get_profile_list(void) -{ - if (test_get_user_selected_profile(NULL, false) == false) - return -1; - - return 1; -} - -int test_get_connected_profile_list(void) -{ - int rv = 0; - char *profile_name = NULL; - connection_profile_iterator_h profile_iter; - connection_profile_h profile_h; - - 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); - return -1; - } - - while (connection_profile_iterator_has_next(profile_iter)) { - if (connection_profile_iterator_next(profile_iter, &profile_h) != CONNECTION_ERROR_NONE) { - printf("Fail to get profile handle\n"); - return -1; - } - - if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) { - printf("Fail to get profile name\n"); - return -1; - } - printf("profile name : %s\n", profile_name); - g_free(profile_name); - } - - return 1; -} - -int test_get_current_profile(void) -{ - int rv = 0; - char *profile_name = NULL; - connection_profile_h profile_h; - - rv = connection_get_current_profile(connection, &profile_h); - if (rv != CONNECTION_ERROR_NONE) { - printf("Fail to get profile iterator [%d]\n", rv); - return -1; - } - - if (connection_profile_get_name(profile_h, &profile_name) != CONNECTION_ERROR_NONE) { - printf("Fail to get profile name\n"); - return -1; - } - printf("profile name : %s\n", profile_name); - g_free(profile_name); - - connection_profile_destroy(profile_h); - - return 1; -} - -int test_open_profile(void) -{ - connection_profile_h profile; - - printf("\n** Choose a profile to open. **\n"); - - if (test_get_user_selected_profile(&profile, true) == false) - return -1; - - if (connection_open_profile(connection, profile, test_connection_opened_callback, NULL) != CONNECTION_ERROR_NONE) { - printf("Connection open Failed!!\n"); - return -1; - } - - return 1; -} - -int test_get_default_cellular_service_type(void) -{ - int input; - int rv; - int service_type; - connection_profile_h profile; - char *profile_name = NULL; - - rv = test_get_user_int("Input profile type to get" - "(1:Internet, 2:MMS, 3:Prepaid internet, 4:Prepaid MMS, 5:Tethering):", &input); - - if (rv == false) { - printf("Invalid input!!\n"); - return -1; - } - - switch (input) { - case 1: - service_type = CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET; - break; - case 2: - service_type = CONNECTION_CELLULAR_SERVICE_TYPE_MMS; - break; - case 3: - service_type = CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET; - break; - case 4: - service_type = CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_MMS; - break; - case 5: - service_type = CONNECTION_CELLULAR_SERVICE_TYPE_TETHERING; - break; - default: - printf("Wrong number!!\n"); - return -1; - } - - if (connection_get_default_cellular_service_profile(connection, service_type, &profile) != CONNECTION_ERROR_NONE) - return -1; - - if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) { - printf("Fail to get profile name\n"); - connection_profile_destroy(profile); - return -1; - } - printf("Default profile name : %s\n", profile_name); - g_free(profile_name); - - connection_profile_destroy(profile); - - return 1; -} - -int test_set_default_cellular_service_type(void) -{ - connection_profile_h profile; - connection_cellular_service_type_e type; - int input, rv; - - rv = test_get_user_int("Input API type (1:sync, 2:async)", &input); - - if (rv == false || (input != 1 && input != 2)) { - printf("Invalid input!!\n"); - return -1; - } - - printf("\n** Choose a profile to set default service(internet or prepaid internet type only). **\n"); - - if (test_get_user_selected_profile(&profile, true) == false) - return -1; - - if (connection_profile_get_cellular_service_type(profile, &type) != CONNECTION_ERROR_NONE) { - printf("Fail to get cellular service type\n"); - return -1; - } - - if (input == 1) { - if (connection_set_default_cellular_service_profile(connection, type, profile) != CONNECTION_ERROR_NONE) - return -1; - } else { - if (connection_set_default_cellular_service_profile_async(connection, - type, profile, test_connection_set_default_callback, NULL) != CONNECTION_ERROR_NONE) - return -1; - } - - return 1; -} - -int test_close_profile(void) -{ - connection_profile_h profile; - - printf("\n** Choose a profile to close. **\n"); - - if (test_get_user_selected_profile(&profile, true) == false) - return -1; - - if (connection_close_profile(connection, profile, test_connection_closed_callback, NULL) != CONNECTION_ERROR_NONE) { - printf("Connection close Failed!!\n"); - return -1; - } - - return 1; -} - -int test_add_profile(void) -{ - int rv = 0; - connection_profile_h profile; - char input_str[100] = {0,}; - - if (test_get_user_string("Input Keyword - (Enter for skip) :", input_str, 100) == false) - return -1; - - rv = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, input_str, &profile); - if (rv != CONNECTION_ERROR_NONE) - RETURN_FAIL_DESTROY(profile); - - if (test_update_cellular_info(profile) == -1) - RETURN_FAIL_DESTROY(profile); - - rv = connection_add_profile(connection, profile); - if (rv != CONNECTION_ERROR_NONE) - RETURN_FAIL_DESTROY(profile); - - connection_profile_destroy(profile); - return 1; -} - -int test_remove_profile(void) -{ - connection_profile_h profile; - - printf("\n** Choose a profile to remove. **\n"); - if (test_get_user_selected_profile(&profile, true) == false) - return -1; - - if (connection_remove_profile(connection, profile) != CONNECTION_ERROR_NONE) { - printf("Remove profile Failed!!\n"); - return -1; - } - - return 1; -} - -int test_update_profile(void) -{ - int rv = 0; - - connection_profile_type_e prof_type; - connection_profile_h profile; - - printf("\n** Choose a profile to update. **\n"); - if (test_get_user_selected_profile(&profile, true) == false) - return -1; - - if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE) - return -1; - - switch (prof_type) { - case CONNECTION_PROFILE_TYPE_CELLULAR: - if (test_update_cellular_info(profile) == -1) - return -1; - - break; - case CONNECTION_PROFILE_TYPE_WIFI: - if (test_update_wifi_info(profile) == -1) - return -1; - - if (test_update_network_info(profile) == -1) - return -1; - - break; - case CONNECTION_PROFILE_TYPE_ETHERNET: - case CONNECTION_PROFILE_TYPE_BT: - printf("Not supported!\n"); - /* fall through */ - default: - return -1; - } - - rv = connection_update_profile(connection, profile); - if (rv != CONNECTION_ERROR_NONE) - return -1; - - return 1; -} - -int test_get_profile_info(void) -{ - connection_profile_type_e prof_type; - connection_profile_state_e profile_state; - connection_profile_h profile; - char *profile_name = NULL; - - printf("\n** Choose a profile to print. **\n"); - if (test_get_user_selected_profile(&profile, true) == false) - return -1; - - if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) { - printf("Fail to get profile name\n"); - return -1; - } else { - printf("Profile Name : %s\n", profile_name); - g_free(profile_name); - } - - if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) { - printf("Fail to get profile state\n"); - return -1; - } else - printf("Profile State : %s\n", test_print_state(profile_state)); - - - if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE) - return -1; - - switch (prof_type) { - case CONNECTION_PROFILE_TYPE_CELLULAR: - printf("Profile Type : Cellular\n"); - test_print_cellular_info(profile); - break; - case CONNECTION_PROFILE_TYPE_WIFI: - printf("Profile Type : Wi-Fi\n"); - test_print_wifi_info(profile); - break; - case CONNECTION_PROFILE_TYPE_ETHERNET: - printf("Profile Type : Ethernet\n"); - break; - case CONNECTION_PROFILE_TYPE_BT: - printf("Profile Type : Bluetooth\n"); - break; - default: - return -1; - } - - test_print_network_info(profile); - - return 1; -} - -int test_refresh_profile_info(void) -{ - connection_profile_type_e prof_type; - connection_profile_state_e profile_state; - connection_profile_h profile; - char *profile_name = NULL; - - printf("\n** Choose a profile to refresh. **\n"); - if (test_get_user_selected_profile(&profile, true) == false) - return -1; - - if (connection_profile_refresh(profile) != CONNECTION_ERROR_NONE) - return -1; - - if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) { - printf("Fail to get profile name\n"); - return -1; - } else { - printf("Profile Name : %s\n", profile_name); - g_free(profile_name); - } - - if (connection_profile_get_state(profile, &profile_state) != CONNECTION_ERROR_NONE) { - printf("Fail to get profile state\n"); - return -1; - } else - printf("Profile State : %s\n", test_print_state(profile_state)); - - - if (connection_profile_get_type(profile, &prof_type) != CONNECTION_ERROR_NONE) - return -1; - - switch (prof_type) { - case CONNECTION_PROFILE_TYPE_CELLULAR: - printf("Profile Type : Cellular\n"); - test_print_cellular_info(profile); - break; - case CONNECTION_PROFILE_TYPE_WIFI: - printf("Profile Type : Wi-Fi\n"); - test_print_wifi_info(profile); - break; - case CONNECTION_PROFILE_TYPE_ETHERNET: - printf("Profile Type : Ethernet\n"); - break; - case CONNECTION_PROFILE_TYPE_BT: - printf("Profile Type : Bluetooth\n"); - break; - default: - return -1; - } - - test_print_network_info(profile); - - return 1; -} - -int test_set_state_changed_callback() -{ - connection_profile_h profile; - connection_profile_h profile_clone; - - printf("\n** Choose a profile to set callback. **\n"); - if (test_get_user_selected_profile(&profile, true) == false) - return -1; - - if (connection_profile_clone(&profile_clone, profile) != CONNECTION_ERROR_NONE) - return -1; - - if (connection_profile_set_state_changed_cb(profile, - test_profile_state_callback, profile_clone) != CONNECTION_ERROR_NONE) { - connection_profile_destroy(profile_clone); - return -1; - } - - state_cb_list = g_slist_append(state_cb_list, profile_clone); - - return 1; -} - -int test_unset_state_changed_callback() -{ - connection_profile_h profile; - GSList *list; - char *profile_name = NULL; - int count = 0; - int input = 0; - - printf("\n** Choose a profile to unset callback. **\n"); - for (list = state_cb_list; list; list = list->next) { - profile = list->data; - if (connection_profile_get_name(profile, &profile_name) != CONNECTION_ERROR_NONE) { - printf("Fail to get profile name!\n"); - return -1; - } else { - printf("%d. %s\n", count, profile_name); - g_free(profile_name); - } - - count++; - } - - if (test_get_user_int("Input profile number(Enter for cancel) :", &input) == false || - input >= count || - input < 0) { - printf("Wrong number!!\n"); - return -1; - } - - count = 0; - for (list = state_cb_list; list; list = list->next) { - if (count == input) { - profile = list->data; - goto unset; - } - - count++; - } - - return -1; - -unset: - if (connection_profile_unset_state_changed_cb(profile) != CONNECTION_ERROR_NONE) - return -1; - - state_cb_list = g_slist_remove(state_cb_list, profile); - connection_profile_destroy(profile); - - return 1; -} - -int test_reset_call_statistics_info(void) -{ - int ret = CONNECTION_ERROR_NONE; - - ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA); - printf("reset last recv data size [%d]\n", ret); - ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA); - printf("last sent data size [%d]\n", ret); - ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA); - printf("total received data size [%d]\n", ret); - ret = connection_reset_statistics(connection, CONNECTION_TYPE_CELLULAR, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA); - printf("total sent data size [%d]\n", ret); - - return 1; -} - -int test_reset_wifi_call_statistics_info(void) -{ - int ret = CONNECTION_ERROR_NONE; - - ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA); - printf("WiFi last sent data size [%d]\n", ret); - ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA); - printf("WiFi last recv data size [%d]\n", ret); - ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA); - printf("WiFi total sent data size [%d]\n", ret); - ret = connection_reset_statistics(connection, CONNECTION_TYPE_WIFI, CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA); - printf("WiFi total received data size [%d]\n", ret); - - return 1; -} - - -int test_add_route(void) -{ - int rv = 0; - char ip_addr[30]; - char if_name[40]; - - if (test_get_user_string("Input IP - (Enter for skip) :", ip_addr, 30) == false) - return -1; - - if (test_get_user_string("Input Interface name - (Enter for skip) :", if_name, 40) == false) - return -1; - - rv = connection_add_route(connection, if_name, ip_addr); - if (rv != CONNECTION_ERROR_NONE) { - printf("Fail to get add new route [%d]\n", rv); - return -1; - } - - return 1; -} - -int test_get_bt_state(void) -{ - int rv = 0; - connection_bt_state_e bt_state; - - rv = connection_get_bt_state(connection, &bt_state); - - if (rv != CONNECTION_ERROR_NONE) { - printf("Fail to get Bluetooth state [%d]\n", rv); - return -1; - } - - printf("Retval = %d, Bluetooth state [%d]\n", rv, bt_state); - - return 1; -} - -int test_get_profile_id(void) -{ - connection_profile_h profile; - char *profile_id; - - printf("\n** Choose a profile to see profile id. **\n"); - if (test_get_user_selected_profile(&profile, true) == false) - return -1; - - if (connection_profile_get_id(profile, &profile_id) != CONNECTION_ERROR_NONE) { - printf("Fail to get profile name\n"); - return -1; - } else { - printf("Profile id : %s\n", profile_id); - g_free(profile_id); - } - - return 1; -} - -int main(int argc, char **argv) -{ - - GMainLoop *mainloop; - mainloop = g_main_loop_new (NULL, FALSE); - - GIOChannel *channel = g_io_channel_unix_new(0); - g_io_add_watch(channel, (G_IO_IN|G_IO_ERR|G_IO_HUP|G_IO_NVAL), test_thread,NULL ); - - printf("Test Thread created...\n"); - - g_main_loop_run (mainloop); - - return 0; -} - -gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) -{ - int rv = 0; - char a[100]; - - memset(a, '\0', 100); - printf("Event received from stdin\n"); - - rv = read(0, a, 100); - - if (rv < 0 || a[0] == '0') { - if (connection != NULL) - test_deregister_client(); - - exit(1); - } - - if (*a == '\n' || *a == '\r'){ - printf("\n\n Network Connection API Test App\n\n"); - printf("Options..\n"); - printf("1 - Create Handle and set callbacks\n"); - printf("2 - Destroy Handle(unset callbacks automatically)\n"); - printf("3 - Get network state\n"); - printf("4 - Get cellular state (please insert SIM Card)\n"); - printf("5 - Get wifi state (please turn on WiFi)\n"); - printf("6 - Get current proxy address \n"); - printf("7 - Get current Ip address\n"); - printf("8 - Get cellular data call statistics\n"); - printf("9 - Get WiFi data call statistics\n"); - printf("a - Get Profile list\n"); - printf("b - Get Connected Profile list\n"); - printf("c - Get Current profile\n"); - printf("d - Open connection with profile\n"); - printf("e - Get default cellular service by type\n"); - printf("f - Set default cellular service by type\n"); - printf("g - Close connection with profile\n"); - printf("h - Add profile(Cellular only)\n"); - printf("i - Remove profile(Cellular:delete, WiFi:forgot)\n"); - printf("j - Update profile\n"); - printf("k - Get profile info\n"); - printf("l - Refresh profile info\n"); - printf("m - Set state changed callback\n"); - printf("n - Unset state changed callback\n"); - printf("o - Reset cellular data call statistics\n"); - printf("p - Reset WiFi data call statistics\n"); - printf("q - Add new route\n"); - printf("r - Get Bluetooth state\n"); - printf("s - Get profile id\n"); - printf("0 - Exit \n"); - printf("ENTER - Show options menu.......\n"); - } - - switch (a[0]) { - case '1': - rv = test_register_client(); - break; - case '2': - rv = test_deregister_client(); - break; - case '3': - rv = test_get_network_state(); - break; - case '4': - rv = test_get_cellular_state(); - break; - case '5': - rv = test_get_wifi_state(); - break; - case '6': - rv = test_get_current_proxy(); - break; - case '7': - rv = test_get_current_ip(); - break; - case '8': - rv = test_get_call_statistics_info(); - break; - case '9': - rv = test_get_wifi_call_statistics_info(); - break; - case 'a': - rv = test_get_profile_list(); - break; - case 'b': - rv = test_get_connected_profile_list(); - break; - case 'c': - rv = test_get_current_profile(); - break; - case 'd': - rv = test_open_profile(); - break; - case 'e': - rv = test_get_default_cellular_service_type(); - break; - case 'f': - rv = test_set_default_cellular_service_type(); - break; - case 'g': - rv = test_close_profile(); - break; - case 'h': - rv = test_add_profile(); - break; - case 'i': - rv = test_remove_profile(); - break; - case 'j': - rv = test_update_profile(); - break; - case 'k': - rv = test_get_profile_info(); - break; - case 'l': - rv = test_refresh_profile_info(); - break; - case 'm': - rv = test_set_state_changed_callback(); - break; - case 'n': - rv = test_unset_state_changed_callback(); - break; - case 'o': - rv = test_reset_call_statistics_info(); - break; - case 'p': - rv = test_reset_wifi_call_statistics_info(); - break; - case 'q': - rv = test_add_route(); - break; - case 'r': - rv = test_get_bt_state(); - break; - case 's': - rv = test_get_profile_id(); - break; - } - - if (rv == 1) - printf("Operation succeeded!\n"); - else - printf("Operation failed!\n"); - - return TRUE; -} |