diff options
author | jk7744.park <jk7744.park@samsung.com> | 2015-02-01 13:29:48 +0900 |
---|---|---|
committer | jk7744.park <jk7744.park@samsung.com> | 2015-02-01 13:29:48 +0900 |
commit | da7de62cd1e202f6101962b143e3b2dfb5353286 (patch) | |
tree | 8e6001d8496d7de3def5a4ea015745e202cbe3c4 | |
parent | 828e0ceca83efd5a2999b7cbd38ec1c0275d1173 (diff) | |
download | connection-tizen_2.3.tar.gz connection-tizen_2.3.tar.bz2 connection-tizen_2.3.zip |
tizen 2.3 releasetizen_2.3_releasesubmit/tizen_2.3/20150202.060802tizen_2.3
50 files changed, 2910 insertions, 9166 deletions
@@ -48,4 +48,3 @@ debian/capi-network-connection.substvars debian/capi-network-connection/ test/connection_test test/connection_test_regress - diff --git a/wearable/CMakeLists.txt b/CMakeLists.txt index 0ee7426..2473b3d 100644 --- a/wearable/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,9 +9,19 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(INC_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}) -SET(dependents "dlog vconf capi-base-common glib-2.0 network") +SET(dependents "dlog vconf capi-base-common glib-2.0 network capi-system-info") SET(pc_dependents "capi-base-common") +IF(TIZEN_DUALSIM_ENABLE) + ADD_DEFINITIONS(-DTIZEN_DUALSIM_ENABLE) +ENDIF(TIZEN_DUALSIM_ENABLE) +IF(TIZEN_WEARABLE) + ADD_DEFINITIONS(-DTIZEN_WEARABLE) +ENDIF(TIZEN_WEARABLE) +IF(TIZEN_MOBILE) + ADD_DEFINITIONS(-DTIZEN_MOBILE) +ENDIF(TIZEN_MOBILE) + INCLUDE(FindPkgConfig) pkg_check_modules(${fw_name} REQUIRED ${dependents}) FOREACH(flag ${${fw_name}_CFLAGS}) @@ -29,6 +39,7 @@ ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") ADD_DEFINITIONS("-DTIZEN_DEBUG") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib") + aux_source_directory(src SOURCES) ADD_LIBRARY(${fw_name} SHARED ${SOURCES}) @@ -60,7 +71,7 @@ CONFIGURE_FILE( ) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig) -#ADD_SUBDIRECTORY(test) +ADD_SUBDIRECTORY(test) IF(UNIX) diff --git a/mobile/LICENSE.APLv2 b/LICENSE index d645695..56ea2f0 100644 --- a/mobile/LICENSE.APLv2 +++ b/LICENSE @@ -1,3 +1,4 @@ +Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved. Apache License Version 2.0, January 2004 @@ -200,3 +201,4 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + @@ -1,3 +1,3 @@ Copyright (c) Samsung Electronics Co., Ltd. All rights reserved. Except as noted, this software is licensed under Apache License, Version 2. -Please, see the LICENSE.APLv2 file for Apache License terms and conditions. +Please, see the LICENSE file for Apache License terms and conditions. diff --git a/capi-network-connection.manifest b/capi-network-connection.manifest new file mode 100644 index 0000000..3ca8395 --- /dev/null +++ b/capi-network-connection.manifest @@ -0,0 +1,8 @@ +<manifest> + <assign> + <filesystem path="/usr/bin/connection_test" exec_label="connman"/> + </assign> + <request> + <domain name="_"/> + </request> +</manifest> diff --git a/mobile/capi-network-connection.pc.in b/capi-network-connection.pc.in index ee6db75..ee6db75 100644 --- a/mobile/capi-network-connection.pc.in +++ b/capi-network-connection.pc.in diff --git a/doc/net_connection_doc.h b/doc/net_connection_doc.h new file mode 100755 index 0000000..9f8db0e --- /dev/null +++ b/doc/net_connection_doc.h @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __TIZEN_NETWORK_CONNECTION_DOC_H__ +#define __TIZEN_NETWORK_CONNECTION_DOC_H__ + +/** + * @defgroup CAPI_NETWORK_CONNECTION_MODULE Connection + * @brief The Connection API provides functions for managing modem data connections. + * @ingroup CAPI_NETWORK_FRAMEWORK + * + * @section CAPI_NETWORK_CONNECTION_MODULE_HEADER Required Header + * \#include <net_connection.h> + * + * @section CAPI_NETWORK_CONNECTION_MODULE_OVERVIEW Overview + * The Connection API provides functions used to create a network connection and to perform other operations on the + * connection. With these functions, the application can get details such as the IP address, proxy information, gateway information, and connection + * statistics. + * + */ + +/** + * @defgroup CAPI_NETWORK_CONNECTION_MANAGER_MODULE Connection Manager + * @brief The Connection Manager API provides functions for managing data connections. + * @ingroup CAPI_NETWORK_CONNECTION_MODULE + * + * @section CAPI_NETWORK_CONNECTION_MANAGER_MODULE_HEADER Required Header + * \#include <net_connection.h> + * + * @section CAPI_NETWORK_CONNECTION_MANAGER_MODULE_OVERVIEW Overview + * To use Connection Manager API, first create a connection handle using connection_create(). After that, you can obtain network information. + * You should destroy the created connection handle if you do not need it anymore. + * This API is related with libsoup and sockets. It allows you to create a socket on the kernel Linux stack, which can be used directly or by libsoup + * or any other network library. + * @section CAPI_NETWORK_CONNECTION_MANAGER_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/network.bluetooth\n + * - http://tizen.org/feature/network.wifi\n + * - http://tizen.org/feature/network.telephony\n + * - http://tizen.org/feature/network.tethering.bluetooth\n + * + * It is recommended to design feature related codes in your application for reliability.\n + * + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * + * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * + */ + +/** + * @defgroup CAPI_NETWORK_CONNECTION_PROFILE_MODULE Connection Profile + * @brief The Connection Profile API provides functions for managing the connection profile. + * @ingroup CAPI_NETWORK_CONNECTION_MANAGER_MODULE + * + * @section CAPI_NETWORK_CONNECTION_PROFILE_MODULE_HEADER Required Header + * \#include <net_connection.h> + * + * @section CAPI_NETWORK_CONNECTION_PROFILE_MODULE_OVERVIEW Overview + * The Connection Profile provides functions for mapping connection profile. + * It allows you to use a handle for dealing with a connection profile. You can get details about connection using ‘connection_profile_h’ handle. + * @section CAPI_NETWORK_CONNECTION_PROFILE_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/network.bluetooth\n + * - http://tizen.org/feature/network.wifi\n + * - http://tizen.org/feature/network.telephony\n + * - http://tizen.org/feature/network.tethering.bluetooth\n + * + * It is recommended to design feature related codes in your application for reliability.\n + * + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * + * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * + */ + +/** + * @defgroup CAPI_NETWORK_CONNECTION_CELLULAR_PROFILE_MODULE Cellular Profile + * @brief The Connection Cellular Profile API provides functions for managing the cellular profile. + * @ingroup CAPI_NETWORK_CONNECTION_PROFILE_MODULE + * + * @section CAPI_NETWORK_CONNECTION_CELLULAR_PROFILE_MODULE_HEADER Required Header + * \#include <net_connection.h> + * @section CAPI_NETWORK_CONNECTION_CELLULAR_PROFILE_MODULE_OVERVIEW Overview + * The Connection Cellular Profile API provides functions for managing the cellular profile. You can manage the cellular profile using the functions. + * @section CAPI_NETWORK_CONNECTION_CELLULAR_PROFILE_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/network.telephony\n + * + * It is recommended to design feature related codes in your application for reliability.\n + * + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * + * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * + */ + +/** + * @defgroup CAPI_NETWORK_CONNECTION_WIFI_PROFILE_MODULE Wi-Fi Profile + * @brief The Connection Wi-Fi Profile API provides functions for managing the WiFi profile. + * @ingroup CAPI_NETWORK_CONNECTION_PROFILE_MODULE + * + * @section CAPI_NETWORK_CONNECTION_WIFI_PROFILE_MODULE_HEADER Required Header + * \#include <net_connection.h> + * @section CAPI_NETWORK_CONNECTION_WIFI_PROFILE_MODULE_OVERVIEW Overview + * The Connection Wi-Fi Profile API provides functions for managing the wi-fi profile. You can manage the wi-fi profile using the functions. + * @section CAPI_NETWORK_CONNECTION_WIFI_PROFILE_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/network.wifi\n + * + * It is recommended to design feature related codes in your application for reliability.\n + * + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * + * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * + */ + +/** + * @defgroup CAPI_NETWORK_CONNECTION_STATISTICS_MODULE Connection Statistics + * @brief The Connection Statistics API provides functions for getting the statistical information. + * @ingroup CAPI_NETWORK_CONNECTION_MODULE + * + * @section CAPI_NETWORK_CONNECTION_STATISTICS_MODULE_HEADER Required Header + * \#include <net_connection.h> + * + * @section CAPI_NETWORK_CONNECTION_STATISTICS_MODULE_HEADER_OVERVIEW Overview + * The Connection allows you to track the data transfer information. + * Use the Connection statistics to gather and reset statistics on network usage, such as the size of the sent or received data, in bytes. + * It also provides methods for getting the cumulative size of packets sent or received. + * @section CAPI_NETWORK_CONNECTION_STATISTICS_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/network.wifi\n + * - http://tizen.org/feature/network.telephony\n + * + * It is recommended to design feature related codes in your application for reliability.\n + * + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * + * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a> + * + */ + + + + +#endif /* __TIZEN_NETWORK_CONNECTION_DOC_H__ */ diff --git a/include/connection_profile.h b/include/connection_profile.h new file mode 100644 index 0000000..e45e072 --- /dev/null +++ b/include/connection_profile.h @@ -0,0 +1,879 @@ +/* + * 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 + +/** + * @file connection_profile.h + */ + +/** +* @addtogroup CAPI_NETWORK_CONNECTION_WIFI_PROFILE_MODULE +* @{ +*/ + +/** + * @brief Enumeration for security type of Wi-Fi. + * @since_tizen 2.3 +*/ +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 Enumeration for encryption modes. + * @since_tizen 2.3 +*/ +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 Enumeration for cellular service type. + * @since_tizen 2.3 +*/ +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 Enumeration for cellular authentication type. + * @since_tizen 2.3 +*/ +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 profile handle. + * @since_tizen 2.3 +*/ +typedef void* connection_profile_h; + +/** + * @brief Enumeration for profile state type. + * @since_tizen 2.3 +*/ +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 Enumeration for address family. + * @since_tizen 2.3 +*/ +typedef enum +{ + CONNECTION_ADDRESS_FAMILY_IPV4 = 0, /**< IPV4 Address type */ + CONNECTION_ADDRESS_FAMILY_IPV6 = 1, /**< IPV6 Address type */ +} connection_address_family_e; + +/** + * @brief Enumeration for IP configuration type. + * @since_tizen 2.3 +*/ +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 Enumeration for proxy method type. + * @since_tizen 2.3 +*/ +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; + +/** + * @brief Enumeration for network connection type. + * @since_tizen 2.3 +*/ +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 a profile handle. + * @details The profile name, which you get from connection_profile_get_name(), will include the keyword you set. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.profile \n + * %http://tizen.org/privilege/network.get + * @remarks You must release @a profile using connection_profile_destroy(). \n + * This API needs both privileges. + * @param[in] type The type of profile\n + * #CONNECTION_PROFILE_TYPE_CELLULAR and #CONNECTION_PROFILE_TYPE_WIFI are supported. + * @param[in] keyword The keyword included in profile name + * @param[out] profile The handle of the profile + * @return @c 0 on success, otherwise negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported + * @see connection_profile_destroy() + * @see connection_profile_get_name() +*/ +int connection_profile_create(connection_profile_type_e type, const char* keyword, connection_profile_h* profile); + +/** + * @brief Destroys a profile handle. + * @since_tizen 2.3 + * @param[out] profile The handle to the profile + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @see connection_profile_create() +*/ +int connection_profile_destroy(connection_profile_h profile); + +/** + * @brief Clones a profile handle. + * @since_tizen 2.3 + * @remarks You must release @a cloned_profile using connection_profile_destroy(). + * @param[out] cloned_profile The handle of the cloned profile + * @param[in] origin_profile The handle of the origin profile + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory + * @see connection_profile_destroy() +*/ +int connection_profile_clone(connection_profile_h* cloned_profile, connection_profile_h origin_profile); + +/** + * @brief Gets the profile ID. + * @details The separate profiles can have the same name. + * So, you must use this API instead of connection_profile_get_name() if you want to get the unique identification. + * In case you create a profile, this value will be determined when you add the profile. + * + * @since_tizen 2.3 + * @remarks You must release @a profile_id using free(). + * @param[in] profile The profile handle + * @param[out] profile_id The ID of the profile + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory + * @see connection_profile_get_name() + * @see connection_add_profile() +*/ +int connection_profile_get_id(connection_profile_h profile, char** profile_id); + +/** + * @brief Gets the profile name. + * @since_tizen 2.3 + * @remarks You must release @a profile_name using free(). + * @param[in] profile The profile handle + * @param[out] profile_name The name of the profile + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory + * @see connection_profile_get_id() +*/ +int connection_profile_get_name(connection_profile_h profile, char** profile_name); + +/** + * @brief Gets the network type. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[out] type The type of the profile + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_type(connection_profile_h profile, connection_profile_type_e* type); + +/** + * @brief Gets the name of the network interface, e.g. eth0 and pdp0. + * @since_tizen 2.3 + * @remarks You must release @a interface_name using free(). + * @param[in] profile The profile handle + * @param[out] interface_name The name of the network interface + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory +*/ +int connection_profile_get_network_interface_name(connection_profile_h profile, char** interface_name); + +/** + * @brief Refreshes the profile information. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * @remarks You should call this function in order to get the current information because the profile information can be changed. + * @param[in] profile The profile handle + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied +*/ +int connection_profile_refresh(connection_profile_h profile); + +/** + * @brief Gets the network type. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[out] state The state of the profile + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_state(connection_profile_h profile, connection_profile_state_e* state); + +/** + * @brief Gets the IP config type. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[in] address_family The address family + * @param[out] type The type of the IP config + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_ip_config_type(connection_profile_h profile, connection_address_family_e address_family, connection_ip_config_type_e* type); + +/** + * @brief Gets the IP address. + * @since_tizen 2.3 + * @remarks You must release @a ip_address using free(). + * @param[in] profile The profile handle + * @param[in] address_family The address family + * @param[out] ip_address The IP address + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_ip_address(connection_profile_h profile, connection_address_family_e address_family, char** ip_address); + +/** + * @brief Gets the Subnet Mask. + * @since_tizen 2.3 + * @remarks You must release @a subnet_mask using free(). + * @param[in] profile The profile handle + * @param[in] address_family The address family + * @param[out] subnet_mask The subnet mask + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_subnet_mask(connection_profile_h profile, connection_address_family_e address_family, char** subnet_mask); + +/** + * @brief Gets the Gateway address. + * @since_tizen 2.3 + * @remarks You must release @a gateway_address using free(). + * @param[in] profile The profile handle + * @param[in] address_family The address family + * @param[out] gateway_address The gateway address + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_gateway_address(connection_profile_h profile, connection_address_family_e address_family, char** gateway_address); + +/** + * @brief Gets the DNS address. + * @since_tizen 2.3 + * @remarks The allowance of the DNS address is @c 2. You must release @a dns_address using free(). + * @param[in] profile The profile handle + * @param[in] order The order of DNS address \n + * it starts from 1, which means first DNS address. + * @param[in] address_family The address family + * @param[out] dns_address The DNS address + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_dns_address(connection_profile_h profile, int order, connection_address_family_e address_family, char** dns_address); + +/** + * @brief Gets the Proxy type. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[out] type The type of the proxy + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_proxy_type(connection_profile_h profile, connection_proxy_type_e* type); + +/** + * @brief Gets the Proxy address. + * @since_tizen 2.3 + * @remarks You must release @a proxy_address using free(). + * @param[in] profile The profile handle + * @param[in] address_family The address family + * @param[out] proxy_address The proxy address + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_get_proxy_address(connection_profile_h profile, connection_address_family_e address_family, char** proxy_address); + +/** + * @brief Sets the IP config type. + * @details If you set IP config type to #CONNECTION_IP_CONFIG_TYPE_STATIC, + * then IP address, Gateway and Subnet mask will be set to the initial value "0.0.0.0". + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[in] address_family The address family + * @param[in] type The type of the IP config + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed +*/ +int connection_profile_set_ip_config_type(connection_profile_h profile, connection_address_family_e address_family, connection_ip_config_type_e type); + +/** + * @brief Sets the IP address. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[in] address_family The address family + * @param[in] ip_address The IP address.\n + * If you set this value to @c NULL, then the existing value will be deleted. + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @see connection_update_profile() +*/ +int connection_profile_set_ip_address(connection_profile_h profile, connection_address_family_e address_family, const char* ip_address); + +/** + * @brief Sets the Subnet Mask. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[in] address_family The address family + * @param[in] subnet_mask The subnet mask. \n + * If you set this value to @c NULL, then the existing value will be deleted. + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @see connection_update_profile() +*/ +int connection_profile_set_subnet_mask(connection_profile_h profile, connection_address_family_e address_family, const char* subnet_mask); + +/** + * @brief Sets the Gateway address. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[in] address_family The address family + * @param[in] gateway_address The gateway address. \n + * If you set this value to @c NULL, then the existing value will be deleted. + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @see connection_update_profile() +*/ +int connection_profile_set_gateway_address(connection_profile_h profile, connection_address_family_e address_family, const char* gateway_address); + +/** + * @brief Sets the DNS address. + * @since_tizen 2.3 + * @remarks The allowance of the DNS address is @c 2. + * @param[in] profile The profile handle + * @param[in] order The order of the DNS address. \n + * It starts from @c 1, which means first DNS address. + * @param[in] address_family The address family + * @param[in] dns_address The DNS address; if you set this value to NULL, then the existing value will be deleted + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @see connection_update_profile() +*/ +int connection_profile_set_dns_address(connection_profile_h profile, int order, connection_address_family_e address_family, const char* dns_address); + +/** + * @brief Sets the Proxy type. + * @details If you set the Proxy type to #CONNECTION_PROXY_TYPE_AUTO or #CONNECTION_PROXY_TYPE_MANUAL, then Proxy will be restored. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[in] type The type of the proxy + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @see connection_update_profile() +*/ +int connection_profile_set_proxy_type(connection_profile_h profile, connection_proxy_type_e type); + +/** + * @brief Sets the Proxy address. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[in] address_family The address family + * @param[in] proxy_address The proxy address. \n + * if you set this value to @c NULL, then the existing value will be deleted. + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED Not supported address family + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @see connection_update_profile() +*/ +int connection_profile_set_proxy_address(connection_profile_h profile, connection_address_family_e address_family, const char* proxy_address); + +/** + * @brief Called when the state of the profile is changed. + * @since_tizen 2.3 + * @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 that is called when the state of profile is changed. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[in] callback The callback function to be called + * @param[in] user_data The user data passed to the callback function + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @post connection_opened_cb() is invoked when the state of profile is changed. + * @see connection_profile_state_changed_cb() + * @see connection_profile_unset_state_changed_cb() +*/ +int connection_profile_set_state_changed_cb(connection_profile_h profile, connection_profile_state_changed_cb callback, void* user_data); + +/** + * @brief Unregisters the callback that is called when the state of profile is changed. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @see connection_profile_state_changed_cb() + * @see connection_profile_set_state_changed_cb() +*/ +int connection_profile_unset_state_changed_cb(connection_profile_h profile); + +/** +* @} +*/ + + +/** +* @addtogroup CAPI_NETWORK_CONNECTION_WIFI_PROFILE_MODULE +* @{ +*/ + +/** + * @brief Gets the ESSID (Extended Service Set Identifier). + * @since_tizen 2.3 + * @remarks You must release @a essid using free(). + * @param[in] profile The profile handle + * @param[out] essid The ESSID + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported +*/ +int connection_profile_get_wifi_essid(connection_profile_h profile, char** essid); + +/** + * @brief Gets the BSSID (Basic Service Set Identifier). + * @since_tizen 2.3 + * @remarks You must release @a bssid using free(). + * @param[in] profile The profile handle + * @param[out] bssid The BSSID + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported +*/ +int connection_profile_get_wifi_bssid(connection_profile_h profile, char** bssid); + +/** + * @brief Gets the RSSI. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[out] rssi The RSSI + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported +*/ +int connection_profile_get_wifi_rssi(connection_profile_h profile, int* rssi); + +/** + * @brief Gets the frequency (MHz). + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[out] frequency The frequency + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported +*/ +int connection_profile_get_wifi_frequency(connection_profile_h profile, int* frequency); + +/** + * @brief Gets the max speed (Mbps). + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[out] max_speed The max speed + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported +*/ +int connection_profile_get_wifi_max_speed(connection_profile_h profile, int* max_speed); + +/** + * @brief Gets the security mode of Wi-Fi. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[out] type The type of Wi-Fi security + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported +*/ +int connection_profile_get_wifi_security_type(connection_profile_h profile, connection_wifi_security_type_e* type); + +/** + * @brief Gets the security mode of Wi-Fi. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[out] type The type of Wi-Fi security + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported +*/ +int connection_profile_get_wifi_encryption_type(connection_profile_h profile, connection_wifi_encryption_type_e* type); + +/** + * @brief Checks whether passphrase is required. + * @since_tizen 2.3 + * @remarks This function is not valid if security type is #CONNECTION_WIFI_SECURITY_TYPE_EAP. + * @param[in] profile The profile handle + * @param[out] required @c true if a passphrase is required, otherwise @c false if a passphrase is not required. + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported +*/ +int connection_profile_is_wifi_passphrase_required(connection_profile_h profile, bool* required); + +/** + * @brief Sets the passphrase of the Wi-Fi WPA. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[in] passphrase The passphrase of Wi-Fi security + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported + * @see connection_update_profile() +*/ +int connection_profile_set_wifi_passphrase(connection_profile_h profile, const char* passphrase); + +/** + * @brief Checks whether the WPS (Wi-Fi Protected Setup) is supported. + * @since_tizen 2.3 + * @remarks If WPS is supported, you can connect the access point with WPS by wifi_connect_with_wps(). + * @param[in] profile The profile handle + * @param[out] supported @c true if WPS is supported, otherwise @c false if WPS is not supported. + * @return @c 0 on success, otherwise negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported +*/ +int connection_profile_is_wifi_wps_supported(connection_profile_h profile, bool* supported); + +/** +* @} +*/ + + +/** +* @addtogroup CAPI_NETWORK_CONNECTION_CELLULAR_PROFILE_MODULE +* @{ +*/ + +/** + * @brief Gets the service type. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[out] type The type of the cellular service + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported +*/ +int connection_profile_get_cellular_service_type(connection_profile_h profile, connection_cellular_service_type_e* type); + +/** + * @brief Gets the APN (access point name). + * @since_tizen 2.3 + * @remarks You must release @a apn using free(). + * @param[in] profile The profile handle + * @param[out] apn The name of the APN + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported +*/ +int connection_profile_get_cellular_apn(connection_profile_h profile, char** apn); + +/** + * @brief Gets the authentication information. + * @since_tizen 2.3 + * @remarks You must release @a user_name and @a password using free(). + * @param[in] profile The profile handle + * @param[out] type The type of the authentication + * @param[out] user_name The user name + * @param[out] password The password + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported +*/ +int connection_profile_get_cellular_auth_info(connection_profile_h profile, connection_cellular_auth_type_e* type, char** user_name, char** password); + +/** + * @brief Gets the home URL. + * @since_tizen 2.3 + * @remarks You must release @a home_url using free(). + * @param[in] profile The profile handle + * @param[out] home_url The home URL + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported +*/ +int connection_profile_get_cellular_home_url(connection_profile_h profile, char** home_url); + +/** + * @brief Checks wheter the connection is in roaming state. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[out] is_roaming @c true if the cellular is roaming, otherwise @c false if it is not roaming. + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported +*/ +int connection_profile_is_cellular_roaming(connection_profile_h profile, bool* is_roaming); + +/** + * @brief Checks whether the profile is hidden. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[out] is_hidden @c ture if the profile is in hidden, otherwise @c false if the profile is not hidden. + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported +*/ +int connection_profile_is_cellular_hidden(connection_profile_h profile, bool* is_hidden); + +/** + * @brief Checks whether the profile is editable. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[out] is_editable @c true if the profile is editable, otherwise @c false if the profile is not editable. + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported +*/ +int connection_profile_is_cellular_editable(connection_profile_h profile, bool* is_editable); + +/** + * @brief Checks whether the profile is default. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[out] is_default @c true if the profile is default, otherwise @c false if the profile is not default. + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported +*/ +int connection_profile_is_cellular_default(connection_profile_h profile, bool* is_default); + +/** + * @brief Sets the service type. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[in] service_type The type of cellular service + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported + * @see connection_update_profile() +*/ +int connection_profile_set_cellular_service_type(connection_profile_h profile, connection_cellular_service_type_e service_type); + +/** + * @brief Sets the APN (Access Point Name). + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[in] apn The name of APN + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported + * @see connection_update_profile() +*/ +int connection_profile_set_cellular_apn(connection_profile_h profile, const char* apn); + +/** + * @brief Sets the Authentication information. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[in] type The type of the authentication + * @param[in] user_name The user name + * @param[in] password The password + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported + * @see connection_update_profile() +*/ +int connection_profile_set_cellular_auth_info(connection_profile_h profile, connection_cellular_auth_type_e type, const char* user_name, const char* password); + +/** + * @brief Sets the home URL. + * @since_tizen 2.3 + * @param[in] profile The profile handle + * @param[in] home_url The home URL + * @return @c 0 on success, otherwise a negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported + * @see connection_update_profile() +*/ +int connection_profile_set_cellular_home_url(connection_profile_h profile, const char* home_url); + +/** +* @} +*/ + + +#ifdef __cplusplus +} + +#endif + +#endif /* __TIZEN_NETWORK_CONNECTION_PROFILE_H__ */ diff --git a/wearable/include/net_connection.h b/include/net_connection.h index e4f66dc..964f21a 100644..100755 --- a/wearable/include/net_connection.h +++ b/include/net_connection.h @@ -24,22 +24,29 @@ extern "C" { #endif /* __cplusplus */ /** + * @file net_connection.h + */ + +/** * @addtogroup CAPI_NETWORK_CONNECTION_MANAGER_MODULE * @{ */ /** - * @brief The connection handle for all connection functions. + * @brief The connection handle. + * @since_tizen 2.3 */ typedef void* connection_h; /** - * @brief The iterator handle for profiles. + * @brief The profiles iterator handle. + * @since_tizen 2.3 */ typedef void* connection_profile_iterator_h; /** - * @brief Enumerations of connection type. + * @brief Enumeration for connection type. + * @since_tizen 2.3 */ typedef enum { @@ -51,7 +58,8 @@ typedef enum } connection_type_e; /** - * @brief Enumerations of cellular network state. + * @brief Enumeration for cellular network state. + * @since_tizen 2.3 */ typedef enum { @@ -64,7 +72,8 @@ typedef enum } connection_cellular_state_e; /** - * @brief This enumeration defines the Wi-Fi state. + * @brief Enumeration for Wi-Fi state. + * @since_tizen 2.3 */ typedef enum { @@ -74,17 +83,20 @@ typedef enum } connection_wifi_state_e; /** - * @brief This enumeration defines the ethernet state. + * @internal + * @brief Enumeration for ethernet state. + * @since_tizen 2.3 */ 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_DEACTIVATED = 0, /**< @internal There is no Ethernet profile to open */ + CONNECTION_ETHERNET_STATE_DISCONNECTED = 1, /**< @internal Disconnected */ + CONNECTION_ETHERNET_STATE_CONNECTED = 2, /**< @internal Connected */ } connection_ethernet_state_e; /** - * @brief This enumeration defines the Bluetooth state. + * @brief Enumeration for Bluetooth state. + * @since_tizen 2.3 */ typedef enum { @@ -94,16 +106,29 @@ typedef enum } connection_bt_state_e; /** - * @brief This enumeration defines the type of connection iterator. + * @brief Enumeration for connection iterator type. + * @since_tizen 2.3 */ typedef enum { - CONNECTION_ITERATOR_TYPE_REGISTERED = 0, /**< The iterator of registered profile */ - CONNECTION_ITERATOR_TYPE_CONNECTED = 1, /**< The iterator of connected profile */ + CONNECTION_ITERATOR_TYPE_REGISTERED = 0, /**< The iterator of the registered profile */ + CONNECTION_ITERATOR_TYPE_CONNECTED = 1, /**< The iterator of the connected profile */ + CONNECTION_ITERATOR_TYPE_DEFAULT = 2, /**< The iterator of the default profile */ } connection_iterator_type_e; /** - * @brief Enumerations of connection errors. + * @brief Enumeration for reset profile type. + * @since_tizen 2.3 +*/ +typedef enum +{ + CONNECTION_RESET_DEFAULT_PROFILE = 0, /**< Initialized with the default profile defined by csc */ + CONNECTION_RESET_CLEAR_PROFILE = 1, /**< Remove all profiles */ +} connection_reset_option_e; + +/** + * @brief Enumeration for connection errors. + * @since_tizen 2.3 */ typedef enum { @@ -112,15 +137,17 @@ typedef enum CONNECTION_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory error */ CONNECTION_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid Operation */ CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED = TIZEN_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED, /**< Address family not supported */ - CONNECTION_ERROR_OPERATION_FAILED = TIZEN_ERROR_NETWORK_CLASS|0x0401, /**< Operation failed */ - CONNECTION_ERROR_ITERATOR_END = TIZEN_ERROR_NETWORK_CLASS|0x0402, /**< End of iteration */ - CONNECTION_ERROR_NO_CONNECTION = TIZEN_ERROR_NETWORK_CLASS|0x0403, /**< There is no connection */ + CONNECTION_ERROR_OPERATION_FAILED = TIZEN_ERROR_CONNECTION|0x0401, /**< Operation failed */ + CONNECTION_ERROR_ITERATOR_END = TIZEN_ERROR_CONNECTION|0x0402, /**< End of iteration */ + CONNECTION_ERROR_NO_CONNECTION = TIZEN_ERROR_CONNECTION|0x0403, /**< There is no connection */ CONNECTION_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /** Now in progress */ - CONNECTION_ERROR_ALREADY_EXISTS = TIZEN_ERROR_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_ALREADY_EXISTS = TIZEN_ERROR_CONNECTION|0x0404, /**< Already exists */ + CONNECTION_ERROR_OPERATION_ABORTED = TIZEN_ERROR_CONNECTION|0x0405, /**< Operation is aborted */ + CONNECTION_ERROR_DHCP_FAILED = TIZEN_ERROR_CONNECTION|0x0406, /**< DHCP failed */ + CONNECTION_ERROR_INVALID_KEY = TIZEN_ERROR_CONNECTION|0x0407, /**< Invalid key */ + CONNECTION_ERROR_NO_REPLY = TIZEN_ERROR_CONNECTION|0x0408, /**< No reply */ + CONNECTION_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + CONNECTION_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED /**< Not Supported */ } connection_error_e; /** @@ -133,7 +160,8 @@ typedef enum */ /** - * @brief Enumerations of statistics type. + * @brief Enumeration for statistics type. + * @since_tizen 2.3 */ typedef enum { @@ -155,9 +183,12 @@ typedef enum /** * @brief Creates a handle for managing data connections. - * @remarks @a handle must be released with connection_destroy(). - * @param[out] connection The handle of the connection - * @return 0 on success, otherwise negative error value. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * @remarks You must release @a handle using connection_destroy(). + * @param[out] connection The connection handle + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory @@ -167,8 +198,9 @@ int connection_create(connection_h* connection); /** * @brief Destroys the connection handle. - * @param[in] connection The handle of the connection - * @return 0 on success, otherwise negative error value. + * @since_tizen 2.3 + * @param[in] connection The connection handle + * @return @c 0 on success, otherwise negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @see connection_create() @@ -176,16 +208,18 @@ int connection_create(connection_h* connection); int connection_destroy(connection_h connection); /** - * @brief Called when the type of connection is changed. - * @param[in] type The type of current network connection + * @brief Called when the type of a connection is changed. + * @since_tizen 2.3 + * @param[in] type The type of the current network connection * @param[in] user_data The user data passed from the callback registration function - * @see connection_set_network_type_changed_cb() - * @see connection_unset_network_type_changed_cb() + * @see connection_set_type_changed_cb() + * @see connection_unset_type_changed_cb() */ typedef void(*connection_type_changed_cb)(connection_type_e type, void* user_data); /** * @brief Called when the address is changed. + * @since_tizen 2.3 * @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 @@ -197,19 +231,21 @@ typedef void(*connection_type_changed_cb)(connection_type_e type, void* user_dat typedef void(*connection_address_changed_cb)(const char* ipv4_address, const char* ipv6_address, void* user_data); /** -* @brief Called 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() + * @brief Called when connection_set_default_cellular_service_profile_async() finishes. + * @since_tizen 2.3 + * @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. + * @since_tizen 2.3 + * @param[in] connection The connection handle + * @param[out] type The type of the network + * @return @c 0 on success, otherwise negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed @@ -218,11 +254,12 @@ int connection_get_type(connection_h connection, connection_type_e* type); /** * @brief Gets the IP address of the current connection. - * @remarks @a ip_address must be released with free() by you. - * @param[in] connection The handle of the connection + * @since_tizen 2.3 + * @remarks You must release @a ip_address using free(). + * @param[in] connection The connection handle * @param[in] address_family The address family - * @param[out] ip_address The pointer to IP address string. - * @return 0 on success, otherwise negative error value. + * @param[out] ip_address The pointer to the IP address string + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed @@ -232,11 +269,12 @@ int connection_get_ip_address(connection_h connection, connection_address_family /** * @brief Gets the proxy address of the current connection. - * @remarks @a proxy must be released with free() by you. - * @param[in] connection The handle of the connection + * @since_tizen 2.3 + * @remarks You must release @a proxy using free(). + * @param[in] connection The connection handle * @param[in] address_family The address family * @param[out] proxy The proxy address - * @return 0 on success, otherwise negative error value. + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed @@ -245,59 +283,78 @@ int connection_get_ip_address(connection_h connection, connection_address_family int connection_get_proxy(connection_h connection, connection_address_family_e address_family, char** proxy); /** - * @brief Gets the state of celluar connection. + * @brief Gets the state of cellular connection. * @details The returned state is for the cellular connection state. - * @param[in] connection The handle of connection - * @param[out] state The state of cellular connection - * @return 0 on success, otherwise negative error value. + * @since_tizen 2.3 + * @param[in] connection The connection handle + * @param[out] state The state of the cellular connection + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported */ int connection_get_cellular_state(connection_h connection, connection_cellular_state_e* state); /** - * @brief Gets the state of Wi-Fi. + * @brief Gets the state of the Wi-Fi. * @details The returned state is for the Wi-Fi connection state. - * @param[in] connection The handle of connection + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * @param[in] connection The connection handle * @param[out] state The state of Wi-Fi connection - * @return 0 on success, otherwise negative error value. + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported */ int connection_get_wifi_state(connection_h connection, connection_wifi_state_e* state); /** - * @brief Gets the state of ethernet. - * @details The returned state is for the ethernet connection state. - * @param[in] connection The handle of connection + * @internal + * @brief Gets the state of the Ethernet. + * @details The returned state is for the Ethernet connection state. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * @param[in] connection The connection handle * @param[out] state The state of Ethernet connection - * @return 0 on success, otherwise negative error value. + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported */ int connection_get_ethernet_state(connection_h connection, connection_ethernet_state_e* state); /** - * @brief Gets the state of Bluetooth. + * @brief Gets the state of the 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. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * @param[in] connection The connection handle + * @param[out] state The state of the Bluetooth connection + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported */ int connection_get_bt_state(connection_h connection, connection_bt_state_e* state); /** - * @brief Registers the callback called when the type of current connection is changed. - * @param[in] connection The handle of connection + * @brief Registers the callback that is called when the type of the current connection is changed. + * @since_tizen 2.3 + * @param[in] connection The connection handle * @param[in] callback The callback function to be called * @param[in] user_data The user data passed to the callback function - * @return 0 on success, otherwise negative error value. + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed @@ -305,9 +362,10 @@ int connection_get_bt_state(connection_h connection, connection_bt_state_e* stat int connection_set_type_changed_cb(connection_h connection, connection_type_changed_cb callback, void* user_data); /** - * @brief Unregisters the callback called when the type of current connection is changed. - * @param[in] connection The handle of connection - * @return 0 on success, otherwise negative error value. + * @brief Unregisters the callback that is called when the type of current connection is changed. + * @since_tizen 2.3 + * @param[in] connection The connection handle + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed @@ -315,11 +373,12 @@ int connection_set_type_changed_cb(connection_h connection, connection_type_chan int connection_unset_type_changed_cb(connection_h connection); /** - * @brief Registers the callback called when the IP address is changed. - * @param[in] connection The handle of connection + * @brief Registers the callback that is called when the IP address is changed. + * @since_tizen 2.3 + * @param[in] connection The connection handle * @param[in] callback The callback function to be called * @param[in] user_data The user data passed to the callback function - * @return 0 on success, otherwise negative error value. + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed @@ -327,9 +386,10 @@ int connection_unset_type_changed_cb(connection_h connection); int connection_set_ip_address_changed_cb(connection_h connection, connection_address_changed_cb callback, void* user_data); /** - * @brief Unregisters the callback called when the IP address is changed. - * @param[in] connection The handle of connection - * @return 0 on success, otherwise negative error value. + * @brief Unregisters the callback that is called when the IP address is changed. + * @since_tizen 2.3 + * @param[in] connection The connection handle + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed @@ -337,11 +397,12 @@ int connection_set_ip_address_changed_cb(connection_h connection, connection_add int connection_unset_ip_address_changed_cb(connection_h connection); /** - * @brief Registers the callback called when the proxy address is changed. - * @param[in] connection The handle of connection + * @brief Registers the callback that is called when the proxy address is changed. + * @since_tizen 2.3 + * @param[in] connection The connection handle * @param[in] callback The callback function to be called * @param[in] user_data The user data passed to the callback function - * @return 0 on success, otherwise negative error value. + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed @@ -349,9 +410,10 @@ int connection_unset_ip_address_changed_cb(connection_h connection); int connection_set_proxy_address_changed_cb(connection_h connection, connection_address_changed_cb callback, void* user_data); /** - * @brief Unregisters the callback called when the proxy address is changed. - * @param[in] connection The handle of connection - * @return 0 on success, otherwise negative error value. + * @brief Unregisters the callback that is called when the proxy address is changed. + * @since_tizen 2.3 + * @param[in] connection The connection handle + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed @@ -359,62 +421,88 @@ int connection_set_proxy_address_changed_cb(connection_h connection, connection_ int connection_unset_proxy_address_changed_cb(connection_h connection); /** - * @brief Adds new profile which is created by connection_profile_created(). - * @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. + * @brief Adds a new profile which is created by connection_profile_create(). + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.profile \n + * %http://tizen.org/privilege/network.get + * @remarks You can only add a profile of the cellular type. \n + * This API needs both privileges. + * @param[in] connection The connection handle + * @param[in] profile The profile handle + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not Supported */ int connection_add_profile(connection_h connection, connection_profile_h profile); /** - * @brief Removes existing profile. - * @param[in] connection The handle of connection - * @param[in] profile The handle of profile - * @return 0 on success, otherwise negative error value. + * @brief Removes an existing profile. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.profile \n + * %http://tizen.org/privilege/network.get + * @remarks This API needs both privileges. + * @param[in] connection The connection handle + * @param[in] profile The profile handle + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not Supported */ int connection_remove_profile(connection_h connection, connection_profile_h profile); /** - * @brief Updates existing profile. - * @details If you change somethings of a profile, this changes will be not applied to the Connection Manager immediately. + * @brief Updates an existing profile. + * @details When a profile is changed, these changes will be not applied to the Connection Manager immediately. * When you call this function, your changes affect the Connection Manager and the existing profile is updated. * In addition, the existing profile will be updated if you call connection_open_profile(). - * @param[in] connection The handle of connection - * @param[in] profile The handle of profile - * @return 0 on success, otherwise negative error value. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.profile \n + * %http://tizen.org/privilege/network.get + * @remarks This API needs both privileges. + * @param[in] connection The connection handle + * @param[in] profile The profile handle + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not Supported * @see connection_open_profile() */ int connection_update_profile(connection_h connection, connection_profile_h profile); /** - * @brief Gets a iterator of the profiles. - * @remarks @a profile_iterator must be released with connection_destroy(). - * @param[in] connection The handle of connection - * @param[in] type The type of connetion iterator + * @brief Gets a profiles iterator. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * @remarks You must release @a profile_iterator using connection_destroy(). + * @param[in] connection The connection handle + * @param[in] type The type of the connetion iterator * @param[out] profile_iterator The iterator of profile - * @return 0 on success, otherwise negative error value. + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied */ int connection_get_profile_iterator(connection_h connection, connection_iterator_type_e type, connection_profile_iterator_h* profile_iterator); /** * @brief Moves the profile iterator to the next position and gets a profile handle. + * @since_tizen 2.3 * @param[in] profile_iterator The iterator of profile - * @param[out] profile The handle of profile - * @return 0 on success, otherwise negative error value. + * @param[out] profile The profile handle + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_ITERATOR_END End of iteration @@ -422,106 +510,150 @@ int connection_get_profile_iterator(connection_h connection, connection_iterator int connection_profile_iterator_next(connection_profile_iterator_h profile_iterator, connection_profile_h* profile); /** - * @brief Checks whether the next element of profile iterator exists or not. + * @brief Checks whether the next element of a profile iterator exists or not. + * @since_tizen 2.3 + * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section. * @param[in] profile_iterator The iterator of profile - * @return @c true if next element exists, \n @c false if next element doesn't exist + * @return @c true if next element exists, otherwise @c false if next element doesn't exist */ bool connection_profile_iterator_has_next(connection_profile_iterator_h profile_iterator); /** - * @brief Destroys a iterator of the profiles. - * @param[in] profile_iterator The iterator of profile - * @return 0 on success, otherwise negative error value. + * @brief Destroys a profiles iterator. + * @since_tizen 2.3 + * @param[in] profile_iterator The iterator of the profile + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter */ int connection_destroy_profile_iterator(connection_profile_iterator_h profile_iterator); /** - * @brief Gets the name of default profile. - * @remarks @a profile must be released with connection_profile_destroy(). - * @param[in] connection The handle of connection - * @param[out] profile The handle of profile - * @return 0 on success, otherwise negative error value. + * @brief Gets the name of the default profile. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * @remarks You must release @a profile using connection_profile_destroy(). + * @param[in] connection The connection handle + * @param[out] profile The profile handle + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed * @retval #CONNECTION_ERROR_NO_CONNECTION There is no connection + * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied */ int connection_get_current_profile(connection_h connection, connection_profile_h* profile); /** * @brief 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. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * @remarks You must release @a profile using connection_profile_destroy(). + * @param[in] connection The connection handle + * @param[in] type The type of cellular service \n + * #CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION is not permitted. + * @param[out] profile The profile handle + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denieda + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not Supported */ int connection_get_default_cellular_service_profile(connection_h connection, connection_cellular_service_type_e type, connection_profile_h* profile); /** * @brief Sets the default profile which provides the given cellular service. - * @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. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.profile \n + * %http://tizen.org/privilege/network.get + * @remarks This API needs both privileges. + * @param[in] connection The connection handle + * @param[in] type The type of cellular service \n + * only #CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET and #CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET are permitted. + * @param[in] profile The profile handle + * @return @c 0 on success, otherwise a negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not Supported */ int connection_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 + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.profile \n + * %http://tizen.org/privilege/network.get + * @remarks This API needs both privileges. + * @param[in] connection The connection handle + * @param[in] type The type of cellular service (only #CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET and #CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET are permitted) + * @param[in] profile The profile handle * @param[in] callback The callback function to be called * @param[in] user_data The user data passed to the callback function - * @return 0 on success, otherwise negative error value. + * @return @c 0 on success, otherwise negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not Supported */ int connection_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() + * @brief Called after connection_open_profile() is finished. + * @since_tizen 2.3 + * @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() + * @brief Called after connection_close_profile() is finished. + * @since_tizen 2.3 + * @param[in] result The result + * @param[in] user_data The user data passed from connection_close_profile() + * @pre connection_close_profile() will invoke this callback function. + * @see connection_close_profile() */ typedef void(*connection_closed_cb)(connection_error_e result, void* user_data); /** + * @brief Called after connection_reset_profile() is finished. + * @since_tizen 2.3 + * @param[in] result The result + * @param[in] user_data The user data passed from connection_reset_profile() + * @pre connection_reset_profile() will invoke this callback function. + * @see connection_reset_profile() +*/ +typedef void(*connection_reset_cb)(connection_error_e result, void* user_data); + +/** * @brief Opens a connection of profile, asynchronously. - * @param[in] connection The handle of connection - * @param[in] profile The handle of profile + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.set \n + * %http://tizen.org/privilege/network.get + * @remarks This API needs both privileges. + * @param[in] connection The connection handle + * @param[in] profile The profile handle * @param[in] callback The callback function to be called * @param[in] user_data The user data passed to the callback function - * @return 0 on success, otherwise negative error value. + * @return @c 0 on success, otherwise negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied * @post connection_opened_cb() will be invoked. * @see connection_opened_cb() * @see connection_close_profile() @@ -533,14 +665,20 @@ int connection_open_profile(connection_h connection, connection_profile_h profil /** * @brief Closes a connection of profile. - * @param[in] connection The handle of connection - * @param[in] profile The handle of profile + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.set \n + * %http://tizen.org/privilege/network.get + * @remarks This API needs both privileges. + * @param[in] connection The connection handle + * @param[in] profile The profile handle * @param[in] callback The callback function to be called * @param[in] user_data The user data passed to the callback function - * @return 0 on success, otherwise negative error value. + * @return @c 0 on success, otherwise negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied * @post connection_closed_cb() will be invoked. * @see connection_closed_cb() * @see connection_open_profile() @@ -551,31 +689,65 @@ int connection_open_profile(connection_h connection, connection_profile_h profil 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. + * @brief Resets the cellular profile. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.profile \n + * %http://tizen.org/privilege/network.get + * @remarks This API needs both privileges. + * @param[in] connection The connection handle + * @param[in] type The type of reset + * @param[in] id The subscriber identity module id to reset (The sim index starts from 0.) + * @param[in] callback The callback function to be called + * @param[in] user_data The user data passed to the callback function + * @return 0 on success, otherwise negative error value + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not Supported + * @post connection_reset_cb() will be invoked. +*/ +int connection_reset_profile(connection_h connection, connection_reset_option_e type, int id, connection_reset_cb callback, void *user_data); + +/** + * @brief Adds a route to the 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 + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.set \n + * %http://tizen.org/privilege/network.get + * @remarks This API needs both privileges. + * @param[in] connection The connection handle * @param[in] interface_name The name of network interface * @param[in] host_address The IP address of the host - * @return 0 on success, otherwise negative error value. + * @return @c 0 on success, otherwise negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_ALREADY_EXISTS Already exists * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied * @see connection_profile_get_network_interface_name() */ int connection_add_route(connection_h connection, const char* interface_name, const char* host_address); /** - * @brief Remove a route from routing table. + * @brief Removes a route from the 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 + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.set \n + * %http://tizen.org/privilege/network.get + * @remarks This API needs both privileges. + * @param[in] connection The connection handle * @param[in] interface_name The name of network interface * @param[in] host_address The IP address of the host - * @return 0 on success, otherwise negative error value. + * @return @c 0 on success, otherwise negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_ALREADY_EXISTS Already exists * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied * @see connection_profile_get_network_interface_name() */ int connection_remove_route(connection_h connection, const char* interface_name, const char* host_address); @@ -591,29 +763,44 @@ int connection_remove_route(connection_h connection, const char* interface_name, /** * @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. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.get + * @param[in] connection The connection handle + * @param[in] connection_type The type of connection (only CONNECTION_TYPE_WIFI and CONNECTION_TYPE_CELLULAR are supported) * @param[in] statistics_type The type of statistics * @param[out] size The received data size of the last cellular packet data connection (bytes) - * @return 0 on success, otherwise negative error value. + * @return @c 0 on success, otherwise negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not Supported */ int connection_get_statistics(connection_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. + * @brief Resets the statistics information. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/network.set \n + * %http://tizen.org/privilege/network.get + * @remarks This API needs both privileges. + * @param[in] connection The connection handle + * @param[in] connection_type The type of connection (only CONNECTION_TYPE_WIFI and CONNECTION_TYPE_CELLULAR are supported) * @param[in] statistics_type The type of statistics - * @return 0 on success, otherwise negative error value. + * @return @c 0 on success, otherwise negative error value * @retval #CONNECTION_ERROR_NONE Successful * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not Supported */ int connection_reset_statistics(connection_h connection, connection_type_e connection_type, connection_statistics_type_e statistics_type); +/** + * @} +*/ + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/wearable/include/net_connection_private.h b/include/net_connection_private.h index 0998eed..419347e 100644 --- a/wearable/include/net_connection_private.h +++ b/include/net_connection_private.h @@ -34,6 +34,19 @@ extern "C" { #define CONNECTION_ERROR 2 #define CONNECTION_WARN 3 +typedef enum +{ + FEATURE_TYPE_TELEPHONY = 0, + FEATURE_TYPE_WIFI = 1, + FEATURE_TYPE_TETHERING_BLUETOOTH = 2 +} enable_feature_type_e; + +typedef enum +{ + CONNECTION_CELLULAR_SUBSCRIBER_1 = 0x00, + CONNECTION_CELLULAR_SUBSCRIBER_2 = 0x01, +} connection_cellular_subscriber_id_e; + #define CONNECTION_LOG(log_level, format, args...) \ do { \ switch (log_level) { \ @@ -62,13 +75,16 @@ extern "C" { } \ } while(0) +#define VCONF_TELEPHONY_DEFAULT_DATA_SERVICE \ + "db/telephony/dualsim/default_data_service" + bool _connection_is_created(void); -bool _connection_libnet_init(void); +int _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); +int _connection_libnet_get_wifi_state(connection_wifi_state_e *state); +int _connection_libnet_get_ethernet_state(connection_ethernet_state_e *state); +int _connection_libnet_get_bluetooth_state(connection_bt_state_e* state); bool _connection_libnet_check_profile_validity(connection_profile_h profile); bool _connection_libnet_check_profile_cb_validity(connection_profile_h profile); int _connection_libnet_get_profile_iterator(connection_iterator_type_e type, @@ -77,6 +93,7 @@ bool _connection_libnet_iterator_has_next(connection_profile_iterator_h profile_ 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_reset_profile(connection_reset_option_e type, connection_cellular_subscriber_id_e id, connection_reset_cb callback, void *user_data); int _connection_libnet_open_profile(connection_profile_h profile, connection_opened_cb callback, void *user_data); int _connection_libnet_get_cellular_service_profile(connection_cellular_service_type_e type, connection_profile_h *profile); int _connection_libnet_set_cellular_service_profile_sync(connection_cellular_service_type_e type, connection_profile_h profile); @@ -92,8 +109,14 @@ bool _connection_libnet_add_to_profile_cb_list(connection_profile_h profile, bool _connection_libnet_remove_from_profile_cb_list(connection_profile_h profile); int _connection_libnet_set_statistics(net_device_t device_type, net_statistics_type_e statistics_type); int _connection_libnet_get_statistics(net_statistics_type_e statistics_type, unsigned long long *size); +int _connection_libnet_check_get_privilege(); +int _connection_libnet_check_profile_privilege(); -guint _connectioin_callback_add(GSourceFunc func, gpointer user_data); +bool _connection_libnet_get_is_check_enable_feature(); +bool _connection_libnet_get_enable_feature_state(enable_feature_type_e feature_type); +int _connection_libnet_check_enable_feature(); + +guint _connection_callback_add(GSourceFunc func, gpointer user_data); void _connection_callback_cleanup(void); connection_cellular_service_type_e _profile_convert_to_connection_cellular_service_type(net_service_type_t svc_type); @@ -101,6 +124,8 @@ 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); +int _connection_libnet_set_cellular_subscriber_id(connection_profile_h profile, connection_cellular_subscriber_id_e sim_id); + #ifdef __cplusplus } #endif /* __cplusplus */ 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/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/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; -} diff --git a/packaging/capi-network-connection.spec b/packaging/capi-network-connection.spec index 05e53a3..64fdfdf 100644 --- a/packaging/capi-network-connection.spec +++ b/packaging/capi-network-connection.spec @@ -1,36 +1,28 @@ -Name: capi-network-connection -Summary: Network Connection library in TIZEN C API -Version: 0.1.3_19 -Release: 1 -Group: System/Network -License: Apache License Version 2.0 -Source0: %{name}-%{version}.tar.gz - -%if %{_repository} == "wearable" -BuildRequires: cmake -BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(glib-2.0) -BuildRequires: pkgconfig(vconf) -BuildRequires: pkgconfig(capi-base-common) -BuildRequires: pkgconfig(network) -Requires(post): /sbin/ldconfig -Requires(postun): /sbin/ldconfig -%else -BuildRequires: cmake -BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(glib-2.0) -BuildRequires: pkgconfig(vconf) -BuildRequires: pkgconfig(capi-base-common) -BuildRequires: pkgconfig(network) -%endif +Name: capi-network-connection +Summary: Network Connection library in TIZEN C API +Version: 1.0.44 +Release: 1 +Group: System/Network +License: Apache License Version 2.0 +Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(vconf) +BuildRequires: pkgconfig(network) +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(capi-base-common) +BuildRequires: pkgconfig(capi-system-info) +BuildRequires: model-build-features +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig %description Network Connection library in Tizen C API %package devel -Summary: Network Connection library in Tizen C API (Development) -Group: System/Network -Requires: %{name} = %{version}-%{release} +Summary: Network Connection library in Tizen C API (Development) +Group: System/Network +Requires: %{name} = %{version}-%{release} %description devel Network Connection library in Tizen C API (Development) @@ -38,38 +30,30 @@ Network Connection library in Tizen C API (Development) %prep %setup -q + %build -%if %{_repository} == "wearable" -cd wearable -export CFLAGS+=' -Wno-unused-local-typedefs ' +export CFLAGS+=' -Wno-unused-local-typedefs' MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` -cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} +cmake -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \ +%if 0%{?model_build_feature_network_dsds} == 1 + -DTIZEN_DUALSIM_ENABLE=1 \ +%endif +%if "%{?tizen_profile_name}" == "wearable" + -DTIZEN_WEARABLE=1 \ +%elseif "%{?tizen_profile_name}" == "mobile" + -DTIZEN_MOBILE=1 \ +%endif + . make %{?_smp_mflags} -%else -cd mobile -MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` -%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -make %{?_smp_mflags} -%endif %install -%if %{_repository} == "wearable" -cd wearable %make_install #License mkdir -p %{buildroot}%{_datadir}/license -cp LICENSE.APLv2 %{buildroot}%{_datadir}/license/capi-network-connection -%else -cd mobile -%make_install - -#License -mkdir -p %{buildroot}%{_datadir}/license -cp LICENSE.APLv2 %{buildroot}%{_datadir}/license/capi-network-connection -%endif +cp LICENSE %{buildroot}%{_datadir}/license/capi-network-connection %post -p /sbin/ldconfig @@ -77,13 +61,10 @@ cp LICENSE.APLv2 %{buildroot}%{_datadir}/license/capi-network-connection %files -%if %{_repository} == "wearable" -%manifest wearable/capi-network-connection.manifest -%else -%manifest mobile/capi-network-connection.manifest -%endif +%manifest capi-network-connection.manifest %attr(644,-,-) %{_libdir}/libcapi-network-connection.so.* %{_datadir}/license/capi-network-connection +%{_bindir}/connection_test %files devel %{_includedir}/network/*.h diff --git a/wearable/src/connection.c b/src/connection.c index 9a1a391..a71b33a 100644..100755 --- a/wearable/src/connection.c +++ b/src/connection.c @@ -21,8 +21,7 @@ #include "net_connection_private.h" -typedef struct _connection_handle_s -{ +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; @@ -120,13 +119,13 @@ static void __connection_cb_type_change_cb(keynode_t *node, void *user_data) if (_connection_is_created() != true) { CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered" - "If multi-threaded, thread integrity be broken.\n"); + "If multi-threaded, thread integrity be broken."); return; } for (list = conn_handle_list; list; list = list->next) { handle = (connection_h)list->data; - _connectioin_callback_add(__connection_cb_type_changed_cb_idle, (gpointer)handle); + _connection_callback_add(__connection_cb_type_changed_cb_idle, (gpointer)handle); } } @@ -144,7 +143,7 @@ static int __connection_set_type_changed_callback(connection_h connection, __connection_cb_type_change_cb, NULL); refcount++; - CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)\n", refcount); + CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)", refcount); } else { if (refcount > 0 && __connection_get_type_changed_callback(local_handle) != NULL) { @@ -152,10 +151,10 @@ static int __connection_set_type_changed_callback(connection_h connection, if (vconf_ignore_key_changed(VCONFKEY_NETWORK_STATUS, __connection_cb_type_change_cb) < 0) { CONNECTION_LOG(CONNECTION_ERROR, - "Error to de-register vconf callback(%d)\n", refcount); + "Error to de-register vconf callback(%d)", refcount); } else { CONNECTION_LOG(CONNECTION_INFO, - "Successfully de-registered(%d)\n", refcount); + "Successfully de-registered(%d)", refcount); } } } @@ -207,13 +206,13 @@ static void __connection_cb_ip_change_cb(keynode_t *node, void *user_data) if (_connection_is_created() != true) { CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered" - "If multi-threaded, thread integrity be broken.\n"); + "If multi-threaded, thread integrity be broken."); return; } for (list = conn_handle_list; list; list = list->next) { handle = (connection_h)list->data; - _connectioin_callback_add(__connection_cb_ip_changed_cb_idle, (gpointer)handle); + _connection_callback_add(__connection_cb_ip_changed_cb_idle, (gpointer)handle); } } @@ -231,7 +230,7 @@ static int __connection_set_ip_changed_callback(connection_h connection, __connection_cb_ip_change_cb, NULL); refcount++; - CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)\n", refcount); + CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)", refcount); } else { if (refcount > 0 && __connection_get_ip_changed_callback(local_handle) != NULL) { @@ -239,10 +238,10 @@ static int __connection_set_ip_changed_callback(connection_h connection, if (vconf_ignore_key_changed(VCONFKEY_NETWORK_IP, __connection_cb_ip_change_cb) < 0) { CONNECTION_LOG(CONNECTION_ERROR, - "Error to de-register vconf callback(%d)\n", refcount); + "Error to de-register vconf callback(%d)", refcount); } else { CONNECTION_LOG(CONNECTION_INFO, - "Successfully de-registered(%d)\n", refcount); + "Successfully de-registered(%d)", refcount); } } } @@ -294,13 +293,13 @@ static void __connection_cb_proxy_change_cb(keynode_t *node, void *user_data) if (_connection_is_created() != true) { CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered" - "If multi-threaded, thread integrity be broken.\n"); + "If multi-threaded, thread integrity be broken."); return; } for (list = conn_handle_list; list; list = list->next) { handle = (connection_h)list->data; - _connectioin_callback_add(__connection_cb_proxy_changed_cb_idle, (gpointer)handle); + _connection_callback_add(__connection_cb_proxy_changed_cb_idle, (gpointer)handle); } } @@ -318,7 +317,7 @@ static int __connection_set_proxy_changed_callback(connection_h connection, __connection_cb_proxy_change_cb, NULL); refcount++; - CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)\n", refcount); + CONNECTION_LOG(CONNECTION_INFO, "Successfully registered(%d)", refcount); } else { if (refcount > 0 && __connection_get_proxy_changed_callback(local_handle) != NULL) { @@ -326,10 +325,10 @@ static int __connection_set_proxy_changed_callback(connection_h connection, if (vconf_ignore_key_changed(VCONFKEY_NETWORK_PROXY, __connection_cb_proxy_change_cb) < 0) { CONNECTION_LOG(CONNECTION_ERROR, - "Error to de-register vconf callback(%d)\n", refcount); + "Error to de-register vconf callback(%d)", refcount); } else { CONNECTION_LOG(CONNECTION_INFO, - "Successfully de-registered(%d)\n", refcount); + "Successfully de-registered(%d)", refcount); } } } @@ -349,19 +348,30 @@ static int __connection_get_handle_count(void) /* Connection Manager ********************************************************/ EXPORT_API int connection_create(connection_h *connection) { + int rv = _connection_libnet_check_enable_feature(); + if( rv != CONNECTION_ERROR_NONE) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to check enable feature"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + if (connection == NULL || __connection_check_handle_validity(*connection)) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } - if (_connection_libnet_init() == false) { - CONNECTION_LOG(CONNECTION_ERROR, "Creation failed!\n"); + rv = _connection_libnet_init(); + if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } + else if (rv != NET_ERR_NONE) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to create connection[%d]", rv); return CONNECTION_ERROR_OPERATION_FAILED; } *connection = g_try_malloc0(sizeof(connection_handle_s)); if (*connection != NULL) - CONNECTION_LOG(CONNECTION_INFO, "New Handle Created %p\n", *connection); + CONNECTION_LOG(CONNECTION_INFO, "New handle created[%p]", *connection); else return CONNECTION_ERROR_OUT_OF_MEMORY; @@ -373,11 +383,11 @@ EXPORT_API int connection_create(connection_h *connection) EXPORT_API int connection_destroy(connection_h connection) { if (!(__connection_check_handle_validity(connection))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } - CONNECTION_LOG(CONNECTION_INFO, "Destroy handle: %p\n", connection); + CONNECTION_LOG(CONNECTION_INFO, "Destroy handle: %p", connection); __connection_set_type_changed_callback(connection, NULL, NULL); __connection_set_ip_changed_callback(connection, NULL, NULL); @@ -401,16 +411,16 @@ EXPORT_API int connection_get_type(connection_h connection, connection_type_e* t int status = 0; if (type == NULL || !(__connection_check_handle_validity(connection))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } if (vconf_get_int(VCONFKEY_NETWORK_STATUS, &status)) { - CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_int Failed = %d\n", status); + CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_int Failed = %d", status); return CONNECTION_ERROR_OPERATION_FAILED; } - CONNECTION_LOG(CONNECTION_INFO, "Connected Network = %d\n", status); + CONNECTION_LOG(CONNECTION_INFO, "Connected Network = %d", status); *type = __connection_convert_net_state(status); @@ -421,7 +431,7 @@ 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -430,16 +440,16 @@ EXPORT_API int connection_get_ip_address(connection_h connection, *ip_address = vconf_get_str(VCONFKEY_NETWORK_IP); break; case CONNECTION_ADDRESS_FAMILY_IPV6: - CONNECTION_LOG(CONNECTION_ERROR, "Not supported yet\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Not supported yet"); return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; break; default: - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } if (*ip_address == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_str Failed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_str Failed"); return CONNECTION_ERROR_OPERATION_FAILED; } @@ -450,7 +460,7 @@ 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -459,16 +469,16 @@ EXPORT_API int connection_get_proxy(connection_h connection, *proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY); break; case CONNECTION_ADDRESS_FAMILY_IPV6: - CONNECTION_LOG(CONNECTION_ERROR, "Not supported yet\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Not supported yet"); return CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED; break; default: - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } if (*proxy == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_str Failed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_str Failed"); return CONNECTION_ERROR_OPERATION_FAILED; } @@ -477,53 +487,104 @@ EXPORT_API int connection_get_proxy(connection_h connection, EXPORT_API int connection_get_cellular_state(connection_h connection, connection_cellular_state_e* state) { + int rv = 0; int status = 0; int cellular_state = 0; +#if defined TIZEN_DUALSIM_ENABLE + int sim_id = 0; +#endif + + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported telephony feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } if (state == NULL || !(__connection_check_handle_validity(connection))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } - if (!vconf_get_int(VCONFKEY_NETWORK_CELLULAR_STATE, &status)) { - CONNECTION_LOG(CONNECTION_INFO, "Cellular = %d\n", status); - *state = __connection_convert_cellular_state(status); + rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_STATE, &status); + if (rv != VCONF_OK) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to get cellular state"); + return CONNECTION_ERROR_OPERATION_FAILED; + } - if (*state == CONNECTION_CELLULAR_STATE_AVAILABLE) { - if (vconf_get_int(VCONFKEY_DNET_STATE, &cellular_state)) { - CONNECTION_LOG(CONNECTION_ERROR, - "vconf_get_int Failed = %d\n", cellular_state); - return CONNECTION_ERROR_OPERATION_FAILED; - } + CONNECTION_LOG(CONNECTION_INFO, "Cellular: %d", status); + *state = __connection_convert_cellular_state(status); + + if (*state == CONNECTION_CELLULAR_STATE_AVAILABLE) { +#if defined TIZEN_DUALSIM_ENABLE + rv = vconf_get_int(VCONF_TELEPHONY_DEFAULT_DATA_SERVICE, &sim_id); + if (rv != VCONF_OK) { + CONNECTION_LOG(CONNECTION_ERROR, + "Failed to get default subscriber id", sim_id); + return CONNECTION_ERROR_OPERATION_FAILED; } - CONNECTION_LOG(CONNECTION_INFO, "Connection state = %d\n", cellular_state); + switch (sim_id) { + case CONNECTION_CELLULAR_SUBSCRIBER_1: +#endif + rv = vconf_get_int(VCONFKEY_DNET_STATE, &cellular_state); +#if defined TIZEN_DUALSIM_ENABLE + break; - if (cellular_state == VCONFKEY_DNET_NORMAL_CONNECTED || - cellular_state == VCONFKEY_DNET_SECURE_CONNECTED || - cellular_state == VCONFKEY_DNET_TRANSFER) - *state = CONNECTION_CELLULAR_STATE_CONNECTED; + case CONNECTION_CELLULAR_SUBSCRIBER_2: + rv = vconf_get_int(VCONFKEY_DNET_STATE2, &cellular_state); + break; - return CONNECTION_ERROR_NONE; - } else { - CONNECTION_LOG(CONNECTION_ERROR, "vconf_get_int Failed = %d\n", status); - return CONNECTION_ERROR_OPERATION_FAILED; + default: + CONNECTION_LOG(CONNECTION_ERROR, "Invalid subscriber id:%d", sim_id); + return CONNECTION_ERROR_OPERATION_FAILED; + } +#endif + if (rv != VCONF_OK) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to get cellular state"); + return CONNECTION_ERROR_OPERATION_FAILED; + } } + + CONNECTION_LOG(CONNECTION_INFO, "Cellular state: %d", cellular_state); + + if (cellular_state == VCONFKEY_DNET_NORMAL_CONNECTED || + cellular_state == VCONFKEY_DNET_SECURE_CONNECTED || + cellular_state == VCONFKEY_DNET_TRANSFER) + *state = CONNECTION_CELLULAR_STATE_CONNECTED; + + return CONNECTION_ERROR_NONE; } EXPORT_API int connection_get_wifi_state(connection_h connection, connection_wifi_state_e* state) { + int rv; + + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_WIFI))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported wifi feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (state == NULL || !(__connection_check_handle_validity(connection))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } - if (_connection_libnet_get_wifi_state(state) == false) { - CONNECTION_LOG(CONNECTION_ERROR, "Fail to get wifi state\n"); - return CONNECTION_ERROR_OPERATION_FAILED; + rv = _connection_libnet_get_wifi_state(state); + if (rv != CONNECTION_ERROR_NONE) { + CONNECTION_LOG(CONNECTION_ERROR, "Fail to get Wi-Fi state[%d]", rv); + return rv; } - CONNECTION_LOG(CONNECTION_INFO, "WiFi state = %d\n", *state); + CONNECTION_LOG(CONNECTION_INFO, "Wi-Fi state: %d", *state); return CONNECTION_ERROR_NONE; } @@ -531,34 +592,38 @@ EXPORT_API int connection_get_wifi_state(connection_h connection, connection_wif 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } - if (_connection_libnet_get_ethernet_state(state) == false) - return CONNECTION_ERROR_OPERATION_FAILED; - - return CONNECTION_ERROR_NONE; + return _connection_libnet_get_ethernet_state(state); } EXPORT_API int connection_get_bt_state(connection_h connection, connection_bt_state_e* state) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TETHERING_BLUETOOTH))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported bluetooth feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (state == NULL || !(__connection_check_handle_validity(connection))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } - if (_connection_libnet_get_bluetooth_state(state) == false) - return CONNECTION_ERROR_OPERATION_FAILED; - - return CONNECTION_ERROR_NONE; + return _connection_libnet_get_bluetooth_state(state); } 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -568,7 +633,7 @@ EXPORT_API int connection_set_type_changed_cb(connection_h connection, 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -579,7 +644,7 @@ 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -589,7 +654,7 @@ EXPORT_API int connection_set_ip_address_changed_cb(connection_h connection, 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -600,7 +665,7 @@ 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -610,7 +675,7 @@ EXPORT_API int connection_set_proxy_address_changed_cb(connection_h connection, 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -619,24 +684,43 @@ EXPORT_API int connection_unset_proxy_address_changed_cb(connection_h connection EXPORT_API int connection_add_profile(connection_h connection, connection_profile_h profile) { + int rv = 0; + net_profile_info_t *profile_info = profile; + + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported telephony feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(__connection_check_handle_validity(connection)) || !(_connection_libnet_check_profile_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } - int rv = 0; - - net_profile_info_t *profile_info = profile; - if (profile_info->profile_type != NET_DEVICE_CELLULAR) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } - 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); + if (profile_info->ProfileInfo.Pdp.PSModemPath[0] != '/' || + strlen(profile_info->ProfileInfo.Pdp.PSModemPath) < 2) { + CONNECTION_LOG(CONNECTION_ERROR, "Modem object path is NULL"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + rv = net_add_profile(profile_info->ProfileInfo.Pdp.ServiceType, + (net_profile_info_t*)profile); + if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to add profile[%d]", rv); return CONNECTION_ERROR_OPERATION_FAILED; } @@ -645,24 +729,38 @@ EXPORT_API int connection_add_profile(connection_h connection, connection_profil EXPORT_API int connection_remove_profile(connection_h connection, connection_profile_h profile) { + int rv = 0; + net_profile_info_t *profile_info = profile; + + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY)) && + !(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_WIFI))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(__connection_check_handle_validity(connection)) || - !(_connection_libnet_check_profile_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + !(_connection_libnet_check_profile_validity(profile))) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } - int rv = 0; - net_profile_info_t *profile_info = profile; - if (profile_info->profile_type != NET_DEVICE_CELLULAR && profile_info->profile_type != NET_DEVICE_WIFI) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } rv = net_delete_profile(profile_info->ProfileName); - if (rv != NET_ERR_NONE) { - CONNECTION_LOG(CONNECTION_ERROR, "net_delete_profile Failed = %d\n", rv); + if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to delete profile[%d]", rv); return CONNECTION_ERROR_OPERATION_FAILED; } @@ -671,18 +769,32 @@ EXPORT_API int connection_remove_profile(connection_h connection, connection_pro EXPORT_API int connection_update_profile(connection_h connection, connection_profile_h profile) { + int rv = 0; + net_profile_info_t *profile_info = profile; + + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY)) && + !(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_WIFI))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(__connection_check_handle_validity(connection)) || !(_connection_libnet_check_profile_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } - int rv = 0; - net_profile_info_t *profile_info = profile; - rv = net_modify_profile(profile_info->ProfileName, (net_profile_info_t*)profile); - if (rv != NET_ERR_NONE) { - CONNECTION_LOG(CONNECTION_ERROR, "net_modify_profile Failed = %d\n", rv); + if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to modify profile[%d]", rv); return CONNECTION_ERROR_OPERATION_FAILED; } @@ -694,8 +806,9 @@ EXPORT_API int connection_get_profile_iterator(connection_h connection, { if (!(__connection_check_handle_validity(connection)) || (type != CONNECTION_ITERATOR_TYPE_REGISTERED && - type != CONNECTION_ITERATOR_TYPE_CONNECTED)) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + type != CONNECTION_ITERATOR_TYPE_CONNECTED && + type != CONNECTION_ITERATOR_TYPE_DEFAULT)) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -721,18 +834,29 @@ EXPORT_API int connection_destroy_profile_iterator(connection_profile_iterator_h 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } return _connection_libnet_get_current_profile(profile); } -EXPORT_API int connection_get_default_cellular_service_profile(connection_h connection, - connection_cellular_service_type_e type, connection_profile_h* profile) +EXPORT_API int connection_get_default_cellular_service_profile( + connection_h connection, connection_cellular_service_type_e type, + connection_profile_h *profile) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported telephony feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(__connection_check_handle_validity(connection)) || profile == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -742,8 +866,18 @@ EXPORT_API int connection_get_default_cellular_service_profile(connection_h conn EXPORT_API int connection_set_default_cellular_service_profile(connection_h connection, connection_cellular_service_type_e type, connection_profile_h profile) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported telephony feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(__connection_check_handle_validity(connection)) || profile == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -754,9 +888,19 @@ EXPORT_API int connection_set_default_cellular_service_profile_async(connection_ connection_cellular_service_type_e type, connection_profile_h profile, connection_set_default_cb callback, void* user_data) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported telephony feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(__connection_check_handle_validity(connection)) || profile == NULL || callback == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -768,7 +912,7 @@ EXPORT_API int connection_open_profile(connection_h connection, connection_profi { if (!(__connection_check_handle_validity(connection)) || profile == NULL || callback == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -780,18 +924,44 @@ EXPORT_API int connection_close_profile(connection_h connection, connection_prof { if (!(__connection_check_handle_validity(connection)) || profile == NULL || callback == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } return _connection_libnet_close_profile(profile, callback, user_data); } +EXPORT_API int connection_reset_profile(connection_h connection, + connection_reset_option_e type, int id, connection_reset_cb callback, void *user_data) +{ + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported telephony feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + + if (!(__connection_check_handle_validity(connection))) { + CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + if(id < 0 || id > 1) { + CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + return _connection_libnet_reset_profile(type, id, callback, user_data); +} + EXPORT_API int connection_add_route(connection_h connection, const char* interface_name, const char* host_address) { if (!(__connection_check_handle_validity(connection)) || interface_name == NULL || host_address == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -802,85 +972,124 @@ EXPORT_API int connection_remove_route(connection_h connection, const char* inte { if (!(__connection_check_handle_validity(connection)) || interface_name == NULL || host_address == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } return _connection_libnet_remove_route(interface_name, host_address); } -static int __get_statistic(connection_type_e connection_type, - connection_statistics_type_e statistics_type, long long* llsize) +static int __get_cellular_statistic( + connection_statistics_type_e statistics_type, long long *llsize) { - int rv = 0; + int rv = VCONF_OK, rv1 = VCONF_OK; int last_size = 0, size = 0; - unsigned long long ull_size; - int stat_type; +#if defined TIZEN_DUALSIM_ENABLE + int sim_id = 0; +#endif if (llsize == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } - if (connection_type == CONNECTION_TYPE_CELLULAR) { + switch (statistics_type) { + case CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA: + case CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA: + case CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA: + case CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA: + break; + default: + return CONNECTION_ERROR_INVALID_PARAMETER; + } + +#if defined TIZEN_DUALSIM_ENABLE + rv = vconf_get_int(VCONF_TELEPHONY_DEFAULT_DATA_SERVICE, &sim_id); + if (rv != VCONF_OK) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to get default subscriber id"); + *llsize = 0; + return CONNECTION_ERROR_OPERATION_FAILED; + } + + switch (sim_id) { + case 0: +#endif switch (statistics_type) { case CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA: rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT, &last_size); - if (rv != 0) { - CONNECTION_LOG(CONNECTION_ERROR, "Cannot Get VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT = %d\n", last_size); - *llsize = 0; - return CONNECTION_ERROR_OPERATION_FAILED; - } - break; case CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA: rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV, &last_size); - if (rv != 0) { - CONNECTION_LOG(CONNECTION_ERROR, "Cannot Get VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV = %d\n", last_size); - *llsize = 0; - return CONNECTION_ERROR_OPERATION_FAILED; - } - break; case CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA: rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT, &last_size); - if (rv != 0) { - CONNECTION_LOG(CONNECTION_ERROR, "Cannot Get VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT = %d\n", last_size); - *llsize = 0; - return CONNECTION_ERROR_OPERATION_FAILED; - } - - rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT, &size); - if (rv != 0) { - CONNECTION_LOG(CONNECTION_ERROR, "Cannot Get VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT = %d\n", size); - *llsize = 0; - return CONNECTION_ERROR_OPERATION_FAILED; - } - + rv1 = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT, &size); break; case CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA: rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV, &last_size); - if (rv != 0) { - CONNECTION_LOG(CONNECTION_ERROR, "Cannot Get VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV = %d\n", last_size); - *llsize = 0; - return CONNECTION_ERROR_OPERATION_FAILED; - } - - rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV, &size); - if (rv != 0) { - CONNECTION_LOG(CONNECTION_ERROR, "Cannot Get VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV = %d\n", size); - *llsize = 0; - return CONNECTION_ERROR_OPERATION_FAILED; - } - + rv1 = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV, &size); break; - default: - return CONNECTION_ERROR_INVALID_PARAMETER; } +#if defined TIZEN_DUALSIM_ENABLE + break; + case 1: + switch (statistics_type) { + case CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA: + rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT2, &last_size); + break; + case CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA: + rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV2, &last_size); + break; + case CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA: + rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_SNT2, &last_size); + rv1 = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_SNT2, &size); + break; + case CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA: + rv = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_LAST_RCV2, &last_size); + rv1 = vconf_get_int(VCONFKEY_NETWORK_CELLULAR_PKT_TOTAL_RCV2, &size); + break; + } + break; + default: + *llsize = 0; + CONNECTION_LOG(CONNECTION_ERROR, "Invalid subscriber id:%d", sim_id); + return CONNECTION_ERROR_OPERATION_FAILED; + } +#endif + + if (rv != VCONF_OK || rv1 != VCONF_OK) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to get cellular statistics"); + return CONNECTION_ERROR_OPERATION_FAILED; + } - *llsize = (long long)(last_size * 1000 + size * 1000); - CONNECTION_LOG(CONNECTION_INFO,"%lld bytes\n", *llsize); - } else if (connection_type == CONNECTION_TYPE_WIFI) { + *llsize = (long long)(last_size * 1000 + size * 1000); + CONNECTION_LOG(CONNECTION_INFO,"%lld bytes", *llsize); + + return CONNECTION_ERROR_NONE; +} + +static int __get_statistic(connection_type_e connection_type, + connection_statistics_type_e statistics_type, long long *llsize) +{ + int rv, stat_type; + unsigned long long ull_size; + + if (llsize == NULL) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + rv = _connection_libnet_check_get_privilege(); + if (rv == CONNECTION_ERROR_PERMISSION_DENIED) + return rv; + else if (rv != CONNECTION_ERROR_NONE) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to get statistics"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if (connection_type == CONNECTION_TYPE_CELLULAR) + return __get_cellular_statistic(statistics_type, llsize); + else if (connection_type == CONNECTION_TYPE_WIFI) { switch (statistics_type) { case CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA: stat_type = NET_STATISTICS_TYPE_LAST_SENT_DATA; @@ -898,13 +1107,16 @@ static int __get_statistic(connection_type_e connection_type, return CONNECTION_ERROR_INVALID_PARAMETER; } - if (_connection_libnet_get_statistics(stat_type, &ull_size) != CONNECTION_ERROR_NONE) { - CONNECTION_LOG(CONNECTION_ERROR, "Cannot Get Wi-Fi statistics : %d\n", ull_size); + rv = _connection_libnet_get_statistics(stat_type, &ull_size); + if (rv == CONNECTION_ERROR_PERMISSION_DENIED) + return rv; + else if (rv != CONNECTION_ERROR_NONE) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to get Wi-Fi statistics"); *llsize = 0; return CONNECTION_ERROR_OPERATION_FAILED; } - CONNECTION_LOG(CONNECTION_INFO,"%lld bytes\n", ull_size); + CONNECTION_LOG(CONNECTION_INFO,"%lld bytes", ull_size); *llsize = (long long)ull_size; } else return CONNECTION_ERROR_INVALID_PARAMETER; @@ -913,7 +1125,7 @@ static int __get_statistic(connection_type_e connection_type, } static int __reset_statistic(connection_type_e connection_type, - connection_statistics_type_e statistics_type) + connection_statistics_type_e statistics_type) { int conn_type; int stat_type; @@ -947,7 +1159,7 @@ static int __reset_statistic(connection_type_e connection_type, if (rv != CONNECTION_ERROR_NONE) return rv; - CONNECTION_LOG(CONNECTION_INFO,"connection_reset_statistics success\n"); + CONNECTION_LOG(CONNECTION_INFO,"connection_reset_statistics success"); return CONNECTION_ERROR_NONE; } @@ -956,8 +1168,24 @@ 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_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if((connection_type == CONNECTION_TYPE_CELLULAR) && + !(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))) { + CONNECTION_LOG(CONNECTION_ERROR, "Not supported feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + else if((connection_type == CONNECTION_TYPE_WIFI) && + !(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_WIFI))) { + CONNECTION_LOG(CONNECTION_ERROR, "Not supported feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(__connection_check_handle_validity(connection)) || size == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -968,10 +1196,27 @@ EXPORT_API int connection_reset_statistics(connection_h connection, connection_type_e connection_type, connection_statistics_type_e statistics_type) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if((connection_type == CONNECTION_TYPE_CELLULAR) && + !(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))) { + CONNECTION_LOG(CONNECTION_ERROR, "Not supported feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + else if((connection_type == CONNECTION_TYPE_WIFI) && + !(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_WIFI))) { + CONNECTION_LOG(CONNECTION_ERROR, "Not supported feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!__connection_check_handle_validity(connection)) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } return __reset_statistic(connection_type, statistics_type); } + diff --git a/wearable/src/connection_profile.c b/src/connection_profile.c index 1f8e3f0..93643c6 100644..100755 --- a/wearable/src/connection_profile.c +++ b/src/connection_profile.c @@ -60,11 +60,22 @@ static char* __profile_convert_ip_to_string(net_addr_t *ip_addr) static void __profile_init_cellular_profile(net_profile_info_t *profile_info, const char *keyword) { + int default_subscriber_id = 0; + connection_profile_h profile = NULL; + profile_info->profile_type = NET_DEVICE_CELLULAR; profile_info->ProfileState = NET_STATE_TYPE_IDLE; profile_info->ProfileInfo.Pdp.net_info.IpConfigType = NET_IP_CONFIG_TYPE_OFF; profile_info->ProfileInfo.Pdp.net_info.ProxyMethod = NET_PROXY_TYPE_DIRECT; g_strlcpy(profile_info->ProfileInfo.Pdp.Keyword, keyword, NET_PDP_APN_LEN_MAX); + + if (vconf_get_int(VCONF_TELEPHONY_DEFAULT_DATA_SERVICE, + &default_subscriber_id) != 0) + CONNECTION_LOG(CONNECTION_ERROR, + "Failed to get VCONF_TELEPHONY_DEFAULT_DATA_SERVICE"); + + profile = (connection_profile_h)profile_info; + _connection_libnet_set_cellular_subscriber_id(profile, default_subscriber_id); } static void __profile_init_wifi_profile(net_profile_info_t *profile_info) @@ -82,7 +93,7 @@ static const char* __profile_get_ethernet_proxy(void) { char *proxy; - proxy = getenv(HTTP_PROXY); + proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY); if (proxy == NULL) { CONNECTION_LOG(CONNECTION_ERROR, "Fail to get system proxy"); @@ -185,12 +196,43 @@ net_state_type_t _connection_profile_convert_to_net_state(connection_profile_sta /* 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"); + int rv; + + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if((type == CONNECTION_PROFILE_TYPE_CELLULAR) && + !(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))) { + CONNECTION_LOG(CONNECTION_ERROR, "Not supported feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + else if((type == CONNECTION_PROFILE_TYPE_WIFI) && + !(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_WIFI))) { + CONNECTION_LOG(CONNECTION_ERROR, "Not supported feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + + if (type != CONNECTION_PROFILE_TYPE_CELLULAR && + type != CONNECTION_PROFILE_TYPE_WIFI) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } + if (profile == NULL) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + rv = _connection_libnet_check_profile_privilege(); + if (rv == CONNECTION_ERROR_PERMISSION_DENIED) + return rv; + else if (rv != CONNECTION_ERROR_NONE) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to create profile"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + net_profile_info_t *profile_info = g_try_malloc0(sizeof(net_profile_info_t)); if (profile_info == NULL) return CONNECTION_ERROR_OUT_OF_MEMORY; @@ -198,7 +240,7 @@ EXPORT_API int connection_profile_create(connection_profile_type_e type, const c switch (type) { case CONNECTION_PROFILE_TYPE_CELLULAR: if (keyword == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); g_free(profile_info); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -220,7 +262,7 @@ EXPORT_API int connection_profile_create(connection_profile_type_e type, const c 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -232,7 +274,7 @@ EXPORT_API int connection_profile_destroy(connection_profile_h profile) 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -249,7 +291,7 @@ EXPORT_API int connection_profile_clone(connection_profile_h* cloned_profile, co 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -271,7 +313,7 @@ EXPORT_API int connection_profile_get_id(connection_profile_h profile, char** pr 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -308,7 +350,7 @@ EXPORT_API int connection_profile_get_name(connection_profile_h profile, char** 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -328,7 +370,7 @@ EXPORT_API int connection_profile_get_type(connection_profile_h profile, connect *type = CONNECTION_PROFILE_TYPE_BT; break; default: - CONNECTION_LOG(CONNECTION_ERROR, "Invalid profile type\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid profile type"); return CONNECTION_ERROR_OPERATION_FAILED; } @@ -338,7 +380,7 @@ EXPORT_API int connection_profile_get_type(connection_profile_h profile, connect 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -356,16 +398,22 @@ EXPORT_API int connection_profile_get_network_interface_name(connection_profile_ EXPORT_API int connection_profile_refresh(connection_profile_h profile) { + int rv; + if (!(_connection_libnet_check_profile_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } net_profile_info_t profile_info_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"); + rv = net_get_profile_info(profile_info->ProfileName, &profile_info_local); + if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to get profile information"); return CONNECTION_ERROR_OPERATION_FAILED; } @@ -377,7 +425,7 @@ EXPORT_API int connection_profile_refresh(connection_profile_h profile) 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -396,7 +444,7 @@ EXPORT_API int connection_profile_get_ip_config_type(connection_profile_h profil (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && address_family != CONNECTION_ADDRESS_FAMILY_IPV6) || type == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -438,7 +486,7 @@ EXPORT_API int connection_profile_get_ip_address(connection_profile_h profile, (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && address_family != CONNECTION_ADDRESS_FAMILY_IPV6) || ip_address == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -464,7 +512,7 @@ EXPORT_API int connection_profile_get_subnet_mask(connection_profile_h profile, (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && address_family != CONNECTION_ADDRESS_FAMILY_IPV6) || subnet_mask == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -490,7 +538,7 @@ EXPORT_API int connection_profile_get_gateway_address(connection_profile_h profi (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && address_family != CONNECTION_ADDRESS_FAMILY_IPV6) || gateway_address == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -518,7 +566,7 @@ EXPORT_API int connection_profile_get_dns_address(connection_profile_h profile, dns_address == NULL || order <= 0 || order > NET_DNS_ADDR_MAX) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -540,7 +588,7 @@ EXPORT_API int connection_profile_get_dns_address(connection_profile_h profile, 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -585,7 +633,7 @@ EXPORT_API int connection_profile_get_proxy_address(connection_profile_h profile (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && address_family != CONNECTION_ADDRESS_FAMILY_IPV6) || proxy_address == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -619,7 +667,7 @@ EXPORT_API int connection_profile_set_ip_config_type(connection_profile_h profil if (!(_connection_libnet_check_profile_validity(profile)) || (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -663,7 +711,7 @@ EXPORT_API int connection_profile_set_ip_address(connection_profile_h profile, if (!(_connection_libnet_check_profile_validity(profile)) || (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -689,7 +737,7 @@ EXPORT_API int connection_profile_set_subnet_mask(connection_profile_h profile, if (!(_connection_libnet_check_profile_validity(profile)) || (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -715,7 +763,7 @@ EXPORT_API int connection_profile_set_gateway_address(connection_profile_h profi if (!(_connection_libnet_check_profile_validity(profile)) || (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -743,7 +791,7 @@ EXPORT_API int connection_profile_set_dns_address(connection_profile_h profile, address_family != CONNECTION_ADDRESS_FAMILY_IPV6) || order <= 0 || order > NET_DNS_ADDR_MAX) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -766,7 +814,7 @@ EXPORT_API int connection_profile_set_dns_address(connection_profile_h profile, 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -798,7 +846,7 @@ EXPORT_API int connection_profile_set_proxy_address(connection_profile_h profile if (!(_connection_libnet_check_profile_validity(profile)) || (address_family != CONNECTION_ADDRESS_FAMILY_IPV4 && address_family != CONNECTION_ADDRESS_FAMILY_IPV6)) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -822,7 +870,7 @@ EXPORT_API int connection_profile_set_state_changed_cb(connection_profile_h prof 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -834,6 +882,11 @@ EXPORT_API int connection_profile_set_state_changed_cb(connection_profile_h prof EXPORT_API int connection_profile_unset_state_changed_cb(connection_profile_h profile) { + if (!(_connection_libnet_check_profile_validity(profile))) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + if (_connection_libnet_remove_from_profile_cb_list(profile) != true) return CONNECTION_ERROR_INVALID_PARAMETER; @@ -844,8 +897,18 @@ EXPORT_API int connection_profile_unset_state_changed_cb(connection_profile_h pr /* Wi-Fi profile *************************************************************/ EXPORT_API int connection_profile_get_wifi_essid(connection_profile_h profile, char** essid) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_WIFI))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported wifi feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(_connection_libnet_check_profile_validity(profile)) || essid == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -863,8 +926,18 @@ EXPORT_API int connection_profile_get_wifi_essid(connection_profile_h profile, c EXPORT_API int connection_profile_get_wifi_bssid(connection_profile_h profile, char** bssid) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_WIFI))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported wifi feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(_connection_libnet_check_profile_validity(profile)) || bssid == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -882,8 +955,18 @@ EXPORT_API int connection_profile_get_wifi_bssid(connection_profile_h profile, c EXPORT_API int connection_profile_get_wifi_rssi(connection_profile_h profile, int* rssi) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_WIFI))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported wifi feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(_connection_libnet_check_profile_validity(profile)) || rssi == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -899,8 +982,18 @@ EXPORT_API int connection_profile_get_wifi_rssi(connection_profile_h profile, in EXPORT_API int connection_profile_get_wifi_frequency(connection_profile_h profile, int* frequency) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_WIFI))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported wifi feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(_connection_libnet_check_profile_validity(profile)) || frequency == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -916,8 +1009,18 @@ EXPORT_API int connection_profile_get_wifi_frequency(connection_profile_h profil EXPORT_API int connection_profile_get_wifi_max_speed(connection_profile_h profile, int* max_speed) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_WIFI))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported wifi feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(_connection_libnet_check_profile_validity(profile)) || max_speed == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -933,8 +1036,18 @@ EXPORT_API int connection_profile_get_wifi_max_speed(connection_profile_h profil EXPORT_API int connection_profile_get_wifi_security_type(connection_profile_h profile, connection_wifi_security_type_e* type) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_WIFI))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported wifi feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -968,8 +1081,18 @@ EXPORT_API int connection_profile_get_wifi_security_type(connection_profile_h pr EXPORT_API int connection_profile_get_wifi_encryption_type(connection_profile_h profile, connection_wifi_encryption_type_e* type) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_WIFI))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported wifi feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -1003,8 +1126,18 @@ EXPORT_API int connection_profile_get_wifi_encryption_type(connection_profile_h EXPORT_API int connection_profile_is_wifi_passphrase_required(connection_profile_h profile, bool* required) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_WIFI))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported wifi feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(_connection_libnet_check_profile_validity(profile)) || required == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -1037,8 +1170,18 @@ EXPORT_API int connection_profile_is_wifi_passphrase_required(connection_profile EXPORT_API int connection_profile_set_wifi_passphrase(connection_profile_h profile, const char* passphrase) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_WIFI))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported wifi feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(_connection_libnet_check_profile_validity(profile)) || passphrase == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -1055,8 +1198,18 @@ EXPORT_API int connection_profile_set_wifi_passphrase(connection_profile_h profi EXPORT_API int connection_profile_is_wifi_wps_supported(connection_profile_h profile, bool* supported) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_WIFI))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported wifi feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(_connection_libnet_check_profile_validity(profile)) || supported == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -1075,65 +1228,35 @@ EXPORT_API int connection_profile_is_wifi_wps_supported(connection_profile_h pro /* Cellular profile **********************************************************/ -EXPORT_API int connection_profile_get_cellular_network_type(connection_profile_h profile, connection_cellular_network_type_e* type) +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; - } - - 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"); + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); 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; + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported telephony feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; } - 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } net_profile_info_t *profile_info = profile; if (profile_info->profile_type != NET_DEVICE_CELLULAR) { - CONNECTION_LOG(CONNECTION_ERROR, "Invalid profile type Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } *type = _profile_convert_to_connection_cellular_service_type(profile_info->ProfileInfo.Pdp.ServiceType); if (*type == CONNECTION_CELLULAR_SERVICE_TYPE_UNKNOWN) { - CONNECTION_LOG(CONNECTION_ERROR, "Invalid service type Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid service type Passed"); return CONNECTION_ERROR_OPERATION_FAILED; } @@ -1142,15 +1265,27 @@ EXPORT_API int connection_profile_get_cellular_service_type(connection_profile_h EXPORT_API int connection_profile_get_cellular_apn(connection_profile_h profile, char** apn) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported telephony feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(_connection_libnet_check_profile_validity(profile)) || apn == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } net_profile_info_t *profile_info = profile; - if (profile_info->profile_type != NET_DEVICE_CELLULAR) + if (profile_info->profile_type != NET_DEVICE_CELLULAR) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; + } *apn = g_strdup(profile_info->ProfileInfo.Pdp.Apn); if (*apn == NULL) @@ -1162,16 +1297,28 @@ EXPORT_API int connection_profile_get_cellular_apn(connection_profile_h profile, EXPORT_API int connection_profile_get_cellular_auth_info(connection_profile_h profile, connection_cellular_auth_type_e* type, char** user_name, char** password) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported telephony feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(_connection_libnet_check_profile_validity(profile)) || type == NULL || user_name == NULL || password == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } net_profile_info_t *profile_info = profile; - if (profile_info->profile_type != NET_DEVICE_CELLULAR) + if (profile_info->profile_type != NET_DEVICE_CELLULAR) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; + } switch (profile_info->ProfileInfo.Pdp.AuthInfo.AuthType) { case NET_PDP_AUTH_NONE: @@ -1202,15 +1349,27 @@ EXPORT_API int connection_profile_get_cellular_auth_info(connection_profile_h pr EXPORT_API int connection_profile_get_cellular_home_url(connection_profile_h profile, char** home_url) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported telephony feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(_connection_libnet_check_profile_validity(profile)) || home_url == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } net_profile_info_t *profile_info = profile; - if (profile_info->profile_type != NET_DEVICE_CELLULAR) + if (profile_info->profile_type != NET_DEVICE_CELLULAR) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; + } *home_url = g_strdup(profile_info->ProfileInfo.Pdp.HomeURL); if (*home_url == NULL) @@ -1221,15 +1380,27 @@ EXPORT_API int connection_profile_get_cellular_home_url(connection_profile_h pro EXPORT_API int connection_profile_is_cellular_roaming(connection_profile_h profile, bool* is_roaming) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported telephony feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(_connection_libnet_check_profile_validity(profile)) || is_roaming == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } net_profile_info_t *profile_info = profile; - if (profile_info->profile_type != NET_DEVICE_CELLULAR) + if (profile_info->profile_type != NET_DEVICE_CELLULAR) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; + } if (profile_info->ProfileInfo.Pdp.Roaming) *is_roaming = true; @@ -1239,18 +1410,126 @@ EXPORT_API int connection_profile_is_cellular_roaming(connection_profile_h profi return CONNECTION_ERROR_NONE; } +EXPORT_API int connection_profile_is_cellular_hidden(connection_profile_h profile, bool* is_hidden) +{ + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported telephony feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + + if (!(_connection_libnet_check_profile_validity(profile)) || is_hidden == NULL) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + net_profile_info_t *profile_info = profile; + + if (profile_info->profile_type != NET_DEVICE_CELLULAR) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + if (profile_info->ProfileInfo.Pdp.Hidden) + *is_hidden = true; + else + *is_hidden = false; + + return CONNECTION_ERROR_NONE; +} + +EXPORT_API int connection_profile_is_cellular_editable(connection_profile_h profile, bool* is_editable) +{ + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported telephony feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + + if (!(_connection_libnet_check_profile_validity(profile)) || is_editable == NULL) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + net_profile_info_t *profile_info = profile; + + if (profile_info->profile_type != NET_DEVICE_CELLULAR) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + if (profile_info->ProfileInfo.Pdp.Editable) + *is_editable = true; + else + *is_editable = false; + + return CONNECTION_ERROR_NONE; +} + +EXPORT_API int connection_profile_is_cellular_default(connection_profile_h profile, bool* is_default) +{ + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported telephony feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + + if (!(_connection_libnet_check_profile_validity(profile)) || is_default == NULL) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + net_profile_info_t *profile_info = profile; + + if (profile_info->profile_type != NET_DEVICE_CELLULAR) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); + return CONNECTION_ERROR_INVALID_PARAMETER; + } + + if (profile_info->ProfileInfo.Pdp.DefaultConn) + *is_default = true; + else + *is_default = false; + + return CONNECTION_ERROR_NONE; +} + EXPORT_API int connection_profile_set_cellular_service_type(connection_profile_h profile, connection_cellular_service_type_e service_type) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported telephony feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(_connection_libnet_check_profile_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } net_profile_info_t *profile_info = profile; - if (profile_info->profile_type != NET_DEVICE_CELLULAR) + if (profile_info->profile_type != NET_DEVICE_CELLULAR) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; + } switch (service_type) { case CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET: @@ -1281,15 +1560,27 @@ EXPORT_API int connection_profile_set_cellular_service_type(connection_profile_h EXPORT_API int connection_profile_set_cellular_apn(connection_profile_h profile, const char* apn) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported telephony feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(_connection_libnet_check_profile_validity(profile)) || apn == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } net_profile_info_t *profile_info = profile; - if (profile_info->profile_type != NET_DEVICE_CELLULAR) + if (profile_info->profile_type != NET_DEVICE_CELLULAR) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; + } g_strlcpy(profile_info->ProfileInfo.Pdp.Apn, apn, NET_PDP_APN_LEN_MAX+1); @@ -1299,16 +1590,28 @@ EXPORT_API int connection_profile_set_cellular_apn(connection_profile_h profile, EXPORT_API int connection_profile_set_cellular_auth_info(connection_profile_h profile, connection_cellular_auth_type_e type, const char* user_name, const char* password) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported telephony feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(_connection_libnet_check_profile_validity(profile)) || user_name == NULL || password == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } net_profile_info_t *profile_info = profile; - if (profile_info->profile_type != NET_DEVICE_CELLULAR) + if (profile_info->profile_type != NET_DEVICE_CELLULAR) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; + } switch (type) { case CONNECTION_CELLULAR_AUTH_TYPE_NONE: @@ -1332,15 +1635,27 @@ EXPORT_API int connection_profile_set_cellular_auth_info(connection_profile_h pr EXPORT_API int connection_profile_set_cellular_home_url(connection_profile_h profile, const char* home_url) { + if(!(_connection_libnet_get_is_check_enable_feature())) { + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if(!(_connection_libnet_get_enable_feature_state(FEATURE_TYPE_TELEPHONY))){ + CONNECTION_LOG(CONNECTION_ERROR, "Not supported telephony feature"); + return CONNECTION_ERROR_NOT_SUPPORTED; + } + if (!(_connection_libnet_check_profile_validity(profile)) || home_url == NULL) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } net_profile_info_t *profile_info = profile; - if (profile_info->profile_type != NET_DEVICE_CELLULAR) + if (profile_info->profile_type != NET_DEVICE_CELLULAR) { + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; + } g_strlcpy(profile_info->ProfileInfo.Pdp.HomeURL, home_url, NET_HOME_URL_LEN_MAX); diff --git a/wearable/src/libnetwork.c b/src/libnetwork.c index 71f9bdf..b295fa5 100644..100755 --- a/wearable/src/libnetwork.c +++ b/src/libnetwork.c @@ -18,6 +18,7 @@ #include <stdio.h> #include <string.h> #include <vconf/vconf.h> +#include <system_info.h> #include "net_connection_private.h" @@ -40,9 +41,11 @@ struct _libnet_s { connection_opened_cb opened_cb; connection_closed_cb closed_cb; connection_set_default_cb set_default_cb; + connection_reset_cb reset_profile_cb; void *opened_user_data; void *closed_user_data; void *set_default_user_data; + void *reset_profile_user_data; bool is_created; }; @@ -58,9 +61,17 @@ struct managed_idle_data { guint id; }; +struct feature_type { + bool telephony; + bool wifi; + bool tethering_bluetooth; +}; + static __thread struct _profile_list_s profile_iterator = {0, 0, NULL}; static __thread struct _libnet_s libnet = {NULL, NULL, NULL, NULL, NULL, NULL, false}; static __thread GSList *managed_idler_list = NULL; +static __thread bool is_check_enable_feature = false; +static __thread struct feature_type enable_feature = {false, false, false}; bool _connection_is_created(void) { @@ -95,6 +106,8 @@ static connection_error_e __libnet_convert_to_cp_error_type(net_err_t err_type) return CONNECTION_ERROR_OPERATION_ABORTED; case NET_ERR_TIME_OUT: return CONNECTION_ERROR_NO_REPLY; + case NET_ERR_ACCESS_DENIED: + return CONNECTION_ERROR_PERMISSION_DENIED; default: return CONNECTION_ERROR_OPERATION_FAILED; } @@ -131,6 +144,10 @@ static const char *__libnet_convert_cp_error_type_to_string(connection_error_e e return "INVALID_KEY"; case CONNECTION_ERROR_NO_REPLY: return "NO_REPLY"; + case CONNECTION_ERROR_PERMISSION_DENIED: + return "PERMISSION_DENIED"; + case CONNECTION_ERROR_NOT_SUPPORTED: + return "NOT_SUPPORTED"; } return "UNKNOWN"; @@ -152,6 +169,39 @@ static const char *__libnet_convert_cp_state_to_string(connection_profile_state_ } } +static void __libnet_set_reset_profile_cb(connection_opened_cb user_cb, void *user_data) +{ + if (user_cb != NULL) { + libnet.reset_profile_cb = user_cb; + libnet.reset_profile_user_data = user_data; + } +} + +static gboolean __libnet_reset_profile_cb_idle(gpointer data) +{ + connection_error_e result = (connection_error_e)data; + + if (libnet.reset_profile_cb != NULL) + libnet.reset_profile_cb(result, libnet.reset_profile_user_data); + + libnet.reset_profile_cb = NULL; + libnet.reset_profile_user_data = NULL; + + return FALSE; +} + +static void __libnet_reset_profile_cb(connection_error_e result) +{ + if (_connection_is_created() != true) { + CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered" + "If multi-threaded, thread integrity be broken."); + return; + } + + if (libnet.reset_profile_cb != NULL) + _connection_callback_add(__libnet_reset_profile_cb_idle, (gpointer)result); +} + static void __libnet_set_opened_cb(connection_opened_cb user_cb, void *user_data) { if (user_cb != NULL) { @@ -177,12 +227,12 @@ static void __libnet_opened_cb(connection_error_e result) { if (_connection_is_created() != true) { CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered" - "If multi-threaded, thread integrity be broken.\n"); + "If multi-threaded, thread integrity be broken."); return; } if (libnet.opened_cb != NULL) - _connectioin_callback_add(__libnet_opened_cb_idle, (gpointer)result); + _connection_callback_add(__libnet_opened_cb_idle, (gpointer)result); } static void __libnet_set_closed_cb(connection_closed_cb user_cb, void *user_data) @@ -210,12 +260,12 @@ static void __libnet_closed_cb(connection_error_e result) { if (_connection_is_created() != true) { CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered" - "If multi-threaded, thread integrity be broken.\n"); + "If multi-threaded, thread integrity be broken."); return; } if (libnet.closed_cb != NULL) - _connectioin_callback_add(__libnet_closed_cb_idle, (gpointer)result); + _connection_callback_add(__libnet_closed_cb_idle, (gpointer)result); } static void __libnet_set_default_cb(connection_set_default_cb user_cb, void *user_data) @@ -243,12 +293,12 @@ static void __libnet_default_cb(connection_error_e result) { if (_connection_is_created() != true) { CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered" - "If multi-threaded, thread integrity be broken.\n"); + "If multi-threaded, thread integrity be broken."); return; } if (libnet.set_default_cb != NULL) - _connectioin_callback_add(__libnet_default_cb_idle, (gpointer)result); + _connection_callback_add(__libnet_default_cb_idle, (gpointer)result); } static gboolean __libnet_state_changed_cb_idle(gpointer data) @@ -274,7 +324,7 @@ static void __libnet_state_changed_cb(char *profile_name, connection_profile_sta if (_connection_is_created() != true) { CONNECTION_LOG(CONNECTION_ERROR, "Application is not registered" - "If multi-threaded, thread integrity be broken.\n"); + "If multi-threaded, thread integrity be broken."); return; } @@ -301,7 +351,7 @@ static void __libnet_state_changed_cb(char *profile_name, connection_profile_sta notify->state = state; notify->user_data = cb_info->user_data; - id = _connectioin_callback_add(__libnet_state_changed_cb_idle, + id = _connection_callback_add(__libnet_state_changed_cb_idle, (gpointer)notify); if (!id) g_free(notify); @@ -328,7 +378,7 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data) /* fall through */ case NET_EVENT_OPEN_IND: result = __libnet_convert_to_cp_error_type(event_cb->Error); - CONNECTION_LOG(CONNECTION_INFO, "Got connection open %s : %s\n", + CONNECTION_LOG(CONNECTION_INFO, "Connection opened %s[%s]", (is_requested) ? "RSP":"IND", __libnet_convert_cp_error_type_to_string(result)); @@ -338,12 +388,12 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data) switch (event_cb->Error) { case NET_ERR_NONE: case NET_ERR_ACTIVE_CONNECTION_EXISTS: - CONNECTION_LOG(CONNECTION_INFO, "'Open connection' succeeded\n"); + CONNECTION_LOG(CONNECTION_INFO, "Successfully open connection"); __libnet_state_changed_cb(event_cb->ProfileName, CONNECTION_PROFILE_STATE_CONNECTED); return; default: - CONNECTION_LOG(CONNECTION_ERROR, "'Open connection' failed!! [%s]\n", + CONNECTION_LOG(CONNECTION_ERROR, "Failed to open connection[%s]", __libnet_convert_cp_error_type_to_string(result)); } @@ -355,7 +405,7 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data) /* fall through */ case NET_EVENT_CLOSE_IND: result = __libnet_convert_to_cp_error_type(event_cb->Error); - CONNECTION_LOG(CONNECTION_INFO, "Got connection close %s : %s\n", + CONNECTION_LOG(CONNECTION_INFO, "Connection closed %s[%s]", (is_requested) ? "RSP":"IND", __libnet_convert_cp_error_type_to_string(result)); @@ -364,18 +414,18 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data) switch (event_cb->Error) { case NET_ERR_NONE: - CONNECTION_LOG(CONNECTION_INFO, "'Close connection' succeeded!\n"); + CONNECTION_LOG(CONNECTION_INFO, "Successfully closed connection"); __libnet_state_changed_cb(event_cb->ProfileName, CONNECTION_PROFILE_STATE_DISCONNECTED); return; default: - CONNECTION_LOG(CONNECTION_ERROR, "'Close connection' failed!! [%s]\n", - __libnet_convert_cp_error_type_to_string(result)); + CONNECTION_LOG(CONNECTION_ERROR, "Failed to close connection[%s]", + __libnet_convert_cp_error_type_to_string(result)); } break; case NET_EVENT_NET_STATE_IND: - CONNECTION_LOG(CONNECTION_INFO, "Got State changed IND\n"); + CONNECTION_LOG(CONNECTION_INFO, "State changed IND"); if (event_cb->Datalength != sizeof(net_state_type_t)) return; @@ -383,17 +433,22 @@ static void __libnet_evt_cb(net_event_info_t *event_cb, void *user_data) net_state_type_t *profile_state = (net_state_type_t *)event_cb->Data; connection_profile_state_e cp_state = _profile_convert_to_cp_state(*profile_state); - CONNECTION_LOG(CONNECTION_INFO, "state : %s\n", __libnet_convert_cp_state_to_string(cp_state)); - SECURE_CONNECTION_LOG(CONNECTION_INFO, "profile name : %s\n", event_cb->ProfileName); + CONNECTION_LOG(CONNECTION_INFO, "state: %s", __libnet_convert_cp_state_to_string(cp_state)); + SECURE_CONNECTION_LOG(CONNECTION_INFO, "profile name: %s", event_cb->ProfileName); __libnet_state_changed_cb(event_cb->ProfileName, cp_state); break; case NET_EVENT_CELLULAR_SET_DEFAULT_RSP: result = __libnet_convert_to_cp_error_type(event_cb->Error); - CONNECTION_LOG(CONNECTION_INFO, "Got set default profile RSP %d\n", result); + CONNECTION_LOG(CONNECTION_INFO, "Got set default profile RSP %d", result); __libnet_default_cb(result); break; + + case NET_EVENT_CELLULAR_RESET_DEFAULT_RSP: + result = __libnet_convert_to_cp_error_type(event_cb->Error); + CONNECTION_LOG(CONNECTION_INFO, "Got reset default profile RSP %d", result); + __libnet_reset_profile_cb(result); default : break; } @@ -426,14 +481,39 @@ void __libnet_copy_connected_profile(net_profile_info_t **dest, struct _profile_ } } -bool _connection_libnet_init(void) +int __libnet_get_default_count(struct _profile_list_s *profile_list) +{ + int count = 0; + int i = 0; + + for (;i < profile_list->count;i++) { + if (profile_list->profiles[i].ProfileInfo.Pdp.DefaultConn == TRUE) + count++; + } + + return count; +} + +void __libnet_copy_default_profile(net_profile_info_t **dest, struct _profile_list_s *source) +{ + int i = 0; + + for (;i < source->count;i++) { + if (source->profiles[i].ProfileInfo.Pdp.DefaultConn == TRUE) { + memcpy(*dest, &source->profiles[i], sizeof(net_profile_info_t)); + (*dest)++; + } + } +} + +int _connection_libnet_init(void) { int rv; if (_connection_is_created() != true) { rv = net_register_client_ext((net_event_cb_t)__libnet_evt_cb, NET_DEVICE_DEFAULT, NULL); if (rv != NET_ERR_NONE) - return false; + return rv; __connection_set_created(true); @@ -441,7 +521,7 @@ bool _connection_libnet_init(void) profile_cb_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); } - return true; + return NET_ERR_NONE; } bool _connection_libnet_deinit(void) @@ -473,6 +553,9 @@ bool _connection_libnet_check_profile_validity(connection_profile_h profile) GSList *list; int i = 0; + if (profile == NULL) + return false; + for (list = prof_handle_list; list; list = list->next) if (profile == list->data) return true; @@ -498,14 +581,19 @@ bool _connection_libnet_check_profile_cb_validity(connection_profile_h profile) } -bool _connection_libnet_get_wifi_state(connection_wifi_state_e *state) +int _connection_libnet_get_wifi_state(connection_wifi_state_e *state) { + int rv; net_wifi_state_t wlan_state; net_profile_name_t profile_name; - 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; + rv = net_get_wifi_state(&wlan_state, &profile_name); + if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to get Wi-Fi state[%d]", rv); + return CONNECTION_ERROR_OPERATION_FAILED; } switch (wlan_state) { @@ -513,7 +601,8 @@ bool _connection_libnet_get_wifi_state(connection_wifi_state_e *state) *state = CONNECTION_WIFI_STATE_DEACTIVATED; break; case WIFI_ON: - case WIFI_CONNECTING: + case WIFI_ASSOCIATION: + case WIFI_CONFIGURATION: *state = CONNECTION_WIFI_STATE_DISCONNECTED; break; case WIFI_CONNECTED: @@ -521,21 +610,26 @@ bool _connection_libnet_get_wifi_state(connection_wifi_state_e *state) *state = CONNECTION_WIFI_STATE_CONNECTED; break; default : - CONNECTION_LOG(CONNECTION_ERROR, "Error!! Unknown state\n"); - return false; + CONNECTION_LOG(CONNECTION_ERROR, "Unknown Wi-Fi state"); + return CONNECTION_ERROR_INVALID_OPERATION; } - return true; + return CONNECTION_ERROR_NONE; } -bool _connection_libnet_get_ethernet_state(connection_ethernet_state_e* state) +int _connection_libnet_get_ethernet_state(connection_ethernet_state_e* state) { + int rv; struct _profile_list_s ethernet_profiles = {0, 0, NULL}; - net_get_profile_list(NET_DEVICE_ETHERNET, ðernet_profiles.profiles, ðernet_profiles.count); + rv = net_get_profile_list(NET_DEVICE_ETHERNET, ðernet_profiles.profiles, ðernet_profiles.count); + if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } if (ethernet_profiles.count == 0) { *state = CONNECTION_ETHERNET_STATE_DEACTIVATED; - return true; + return CONNECTION_ERROR_NONE; } switch (ethernet_profiles.profiles->ProfileState) { @@ -551,23 +645,29 @@ bool _connection_libnet_get_ethernet_state(connection_ethernet_state_e* state) *state = CONNECTION_ETHERNET_STATE_DISCONNECTED; break; default: - return false; + __libnet_clear_profile_list(ðernet_profiles); + return CONNECTION_ERROR_OPERATION_FAILED; } __libnet_clear_profile_list(ðernet_profiles); - return true; + return CONNECTION_ERROR_NONE; } -bool _connection_libnet_get_bluetooth_state(connection_bt_state_e* state) +int _connection_libnet_get_bluetooth_state(connection_bt_state_e* state) { int i = 0; + int rv = 0; struct _profile_list_s bluetooth_profiles = {0, 0, NULL}; - net_get_profile_list(NET_DEVICE_BLUETOOTH, &bluetooth_profiles.profiles, &bluetooth_profiles.count); + rv = net_get_profile_list(NET_DEVICE_BLUETOOTH, &bluetooth_profiles.profiles, &bluetooth_profiles.count); + if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } if (bluetooth_profiles.count == 0) { *state = CONNECTION_BT_STATE_DEACTIVATED; - return true; + return CONNECTION_ERROR_NONE; } for (; i < bluetooth_profiles.count; i++) { @@ -585,14 +685,14 @@ bool _connection_libnet_get_bluetooth_state(connection_bt_state_e* state) break; default: __libnet_clear_profile_list(&bluetooth_profiles); - return false; + return CONNECTION_ERROR_OPERATION_FAILED; } } done: __libnet_clear_profile_list(&bluetooth_profiles); - return true; + return CONNECTION_ERROR_NONE; } int _connection_libnet_get_profile_iterator(connection_iterator_type_e type, connection_profile_iterator_h* profile_iter_h) @@ -609,41 +709,59 @@ int _connection_libnet_get_profile_iterator(connection_iterator_type_e type, con __libnet_clear_profile_list(&profile_iterator); rv1 = net_get_profile_list(NET_DEVICE_WIFI, &wifi_profiles.profiles, &wifi_profiles.count); - if (rv1 != NET_ERR_NO_SERVICE && rv1 != NET_ERR_NONE) + if (rv1 == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv1 != NET_ERR_NO_SERVICE && rv1 != NET_ERR_NONE) return CONNECTION_ERROR_OPERATION_FAILED; - CONNECTION_LOG(CONNECTION_INFO, "Wifi profile count : %d\n", wifi_profiles.count); + CONNECTION_LOG(CONNECTION_INFO, "Wi-Fi profile count: %d", wifi_profiles.count); rv2 = net_get_profile_list(NET_DEVICE_CELLULAR, &cellular_profiles.profiles, &cellular_profiles.count); - if (rv2 != NET_ERR_NO_SERVICE && rv2 != NET_ERR_NONE) { + if (rv2 == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + __libnet_clear_profile_list(&wifi_profiles); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv2 != NET_ERR_NO_SERVICE && rv2 != NET_ERR_NONE) { __libnet_clear_profile_list(&wifi_profiles); return CONNECTION_ERROR_OPERATION_FAILED; } - CONNECTION_LOG(CONNECTION_INFO, "Cellular profile count : %d\n", cellular_profiles.count); + CONNECTION_LOG(CONNECTION_INFO, "Cellular profile count: %d", cellular_profiles.count); rv3 = net_get_profile_list(NET_DEVICE_ETHERNET, ðernet_profiles.profiles, ðernet_profiles.count); - if (rv3 != NET_ERR_NO_SERVICE && rv3 != NET_ERR_NONE) { + if (rv3 == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + __libnet_clear_profile_list(&wifi_profiles); + __libnet_clear_profile_list(&cellular_profiles); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv3 != NET_ERR_NO_SERVICE && rv3 != NET_ERR_NONE) { __libnet_clear_profile_list(&wifi_profiles); __libnet_clear_profile_list(&cellular_profiles); return CONNECTION_ERROR_OPERATION_FAILED; } - CONNECTION_LOG(CONNECTION_INFO, "Ethernet profile count : %d\n", ethernet_profiles.count); + CONNECTION_LOG(CONNECTION_INFO, "Ethernet profile count : %d", ethernet_profiles.count); rv4 = net_get_profile_list(NET_DEVICE_BLUETOOTH, &bluetooth_profiles.profiles, &bluetooth_profiles.count); - if (rv4 != NET_ERR_NO_SERVICE && rv4 != NET_ERR_NONE) { + if (rv4 == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + __libnet_clear_profile_list(&wifi_profiles); + __libnet_clear_profile_list(&cellular_profiles); + __libnet_clear_profile_list(ðernet_profiles); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv4 != NET_ERR_NO_SERVICE && rv4 != NET_ERR_NONE) { __libnet_clear_profile_list(&wifi_profiles); __libnet_clear_profile_list(&cellular_profiles); __libnet_clear_profile_list(ðernet_profiles); return CONNECTION_ERROR_OPERATION_FAILED; } - CONNECTION_LOG(CONNECTION_INFO, "Bluetooth profile count : %d\n", bluetooth_profiles.count); + CONNECTION_LOG(CONNECTION_INFO, "Bluetooth profile count : %d", bluetooth_profiles.count); *profile_iter_h = &profile_iterator; switch (type) { case CONNECTION_ITERATOR_TYPE_REGISTERED: count = wifi_profiles.count + cellular_profiles.count + ethernet_profiles.count + bluetooth_profiles.count; - CONNECTION_LOG(CONNECTION_INFO, "Total profile count : %d\n", count); + CONNECTION_LOG(CONNECTION_INFO, "Total profile count : %d", count); if (count == 0) return CONNECTION_ERROR_NONE; @@ -686,7 +804,7 @@ int _connection_libnet_get_profile_iterator(connection_iterator_type_e type, con count += __libnet_get_connected_count(&cellular_profiles); count += __libnet_get_connected_count(ðernet_profiles); count += __libnet_get_connected_count(&bluetooth_profiles); - CONNECTION_LOG(CONNECTION_INFO, "Total connected profile count : %d\n", count); + CONNECTION_LOG(CONNECTION_INFO, "Total connected profile count : %d", count); if (count == 0) return CONNECTION_ERROR_NONE; @@ -714,6 +832,26 @@ int _connection_libnet_get_profile_iterator(connection_iterator_type_e type, con __libnet_copy_connected_profile(&profiles, &bluetooth_profiles); break; + case CONNECTION_ITERATOR_TYPE_DEFAULT: + count = __libnet_get_default_count(&cellular_profiles); + CONNECTION_LOG(CONNECTION_INFO, "Total default profile count : %d", count); + if (count == 0) + return CONNECTION_ERROR_NONE; + + profiles = g_try_new0(net_profile_info_t, count); + if (profiles == NULL) { + __libnet_clear_profile_list(&wifi_profiles); + __libnet_clear_profile_list(&cellular_profiles); + __libnet_clear_profile_list(ðernet_profiles); + __libnet_clear_profile_list(&bluetooth_profiles); + return CONNECTION_ERROR_OUT_OF_MEMORY; + } + + profile_iterator.profiles = profiles; + + if (cellular_profiles.count > 0) + __libnet_copy_default_profile(&profiles, &cellular_profiles); + break; } __libnet_clear_profile_list(&wifi_profiles); @@ -769,7 +907,10 @@ int _connection_libnet_get_current_profile(connection_profile_h *profile) rv = net_get_active_net_info(&active_profile); if (rv == NET_ERR_NO_SERVICE) return CONNECTION_ERROR_NO_CONNECTION; - else if (rv != NET_ERR_NONE) + else if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) return CONNECTION_ERROR_OPERATION_FAILED; *profile = g_try_malloc0(sizeof(net_profile_info_t)); @@ -782,16 +923,42 @@ int _connection_libnet_get_current_profile(connection_profile_h *profile) return CONNECTION_ERROR_NONE; } -int _connection_libnet_open_profile(connection_profile_h profile, connection_opened_cb callback, void* user_data) +int _connection_libnet_reset_profile(connection_reset_option_e type, + connection_cellular_subscriber_id_e id, connection_reset_cb callback, void *user_data) +{ + int rv; + + rv = net_reset_profile(type, id); + if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to add profile[%d]", rv); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + __libnet_set_reset_profile_cb(callback, user_data); + + return CONNECTION_ERROR_NONE; +} + +int _connection_libnet_open_profile(connection_profile_h profile, + connection_opened_cb callback, void* user_data) { + int rv; + if (!(_connection_libnet_check_profile_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } net_profile_info_t *profile_info = profile; - if (net_open_connection_with_profile(profile_info->ProfileName) != NET_ERR_NONE) + rv = net_open_connection_with_profile(profile_info->ProfileName); + if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) return CONNECTION_ERROR_OPERATION_FAILED; __libnet_set_opened_cb(callback, user_data); @@ -799,29 +966,59 @@ int _connection_libnet_open_profile(connection_profile_h profile, connection_ope return CONNECTION_ERROR_NONE; } -int _connection_libnet_get_cellular_service_profile(connection_cellular_service_type_e type, connection_profile_h *profile) +int _connection_libnet_get_cellular_service_profile( + connection_cellular_service_type_e type, connection_profile_h *profile) { - int i = 0; - int j = 0; + int i = 0, j = 0; int rv = NET_ERR_NONE; - net_service_type_t service_type = _connection_profile_convert_to_libnet_cellular_service_type(type); +#if defined TIZEN_DUALSIM_ENABLE + int default_subscriber_id = 0; + char subscriber_id[3]; +#endif - struct _profile_list_s cellular_profiles = {0, 0, NULL}; + struct _profile_list_s cellular_profiles = { 0, 0, NULL }; + net_service_type_t service_type = _connection_profile_convert_to_libnet_cellular_service_type(type); rv = net_get_profile_list(NET_DEVICE_CELLULAR, &cellular_profiles.profiles, &cellular_profiles.count); - if (rv != NET_ERR_NONE) + if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to get profile list (%d)", rv); + return CONNECTION_ERROR_OPERATION_FAILED; + } + +#if defined TIZEN_DUALSIM_ENABLE + if (vconf_get_int(VCONF_TELEPHONY_DEFAULT_DATA_SERVICE, + &default_subscriber_id) != 0) { + CONNECTION_LOG(CONNECTION_ERROR, + "Failed to get VCONF_TELEPHONY_DEFAULT_DATA_SERVICE"); + __libnet_clear_profile_list(&cellular_profiles); return CONNECTION_ERROR_OPERATION_FAILED; + } - for (;i < cellular_profiles.count;i++) - if (cellular_profiles.profiles[i].ProfileInfo.Pdp.ServiceType == service_type) - break; + g_snprintf(subscriber_id, sizeof(subscriber_id), "%d", default_subscriber_id); +#endif - if (i >= cellular_profiles.count) + for (i = 0; i < cellular_profiles.count; i++) + if (cellular_profiles.profiles[i].ProfileInfo.Pdp.ServiceType == service_type) +#if defined TIZEN_DUALSIM_ENABLE + if (g_str_has_suffix( + cellular_profiles.profiles[i].ProfileInfo.Pdp.PSModemPath, + subscriber_id) == TRUE) +#endif + break; + + if (i >= cellular_profiles.count) { + __libnet_clear_profile_list(&cellular_profiles); return CONNECTION_ERROR_OPERATION_FAILED; + } *profile = g_try_malloc0(sizeof(net_profile_info_t)); - if (*profile == NULL) + if (*profile == NULL) { + __libnet_clear_profile_list(&cellular_profiles); return CONNECTION_ERROR_OUT_OF_MEMORY; + } memcpy(*profile, &cellular_profiles.profiles[i], sizeof(net_profile_info_t)); @@ -832,7 +1029,7 @@ int _connection_libnet_get_cellular_service_profile(connection_cellular_service_ type != CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET) goto done; - for (;j < cellular_profiles.count;j++) { + for (j = 0; j < cellular_profiles.count; j++) { if (i == j) continue; @@ -846,6 +1043,7 @@ int _connection_libnet_get_cellular_service_profile(connection_cellular_service_ } done: + __libnet_clear_profile_list(&cellular_profiles); prof_handle_list = g_slist_append(prof_handle_list, *profile); return CONNECTION_ERROR_NONE; @@ -853,8 +1051,10 @@ done: int _connection_libnet_set_cellular_service_profile_sync(connection_cellular_service_type_e type, connection_profile_h profile) { + int rv; + if (!(_connection_libnet_check_profile_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -866,7 +1066,11 @@ int _connection_libnet_set_cellular_service_profile_sync(connection_cellular_ser if (service_type != type) return CONNECTION_ERROR_INVALID_PARAMETER; - if (net_set_default_cellular_service_profile(profile_info->ProfileName) != NET_ERR_NONE) + rv = net_set_default_cellular_service_profile(profile_info->ProfileName); + if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) return CONNECTION_ERROR_OPERATION_FAILED; return CONNECTION_ERROR_NONE; @@ -875,8 +1079,10 @@ int _connection_libnet_set_cellular_service_profile_sync(connection_cellular_ser int _connection_libnet_set_cellular_service_profile_async(connection_cellular_service_type_e type, connection_profile_h profile, connection_set_default_cb callback, void* user_data) { + int rv; + if (!(_connection_libnet_check_profile_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } @@ -888,7 +1094,11 @@ int _connection_libnet_set_cellular_service_profile_async(connection_cellular_se if (service_type != type) return CONNECTION_ERROR_INVALID_PARAMETER; - if (net_set_default_cellular_service_profile_async(profile_info->ProfileName) != NET_ERR_NONE) + rv = net_set_default_cellular_service_profile_async(profile_info->ProfileName); + if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) return CONNECTION_ERROR_OPERATION_FAILED; __libnet_set_default_cb(callback, user_data); @@ -898,14 +1108,20 @@ int _connection_libnet_set_cellular_service_profile_async(connection_cellular_se int _connection_libnet_close_profile(connection_profile_h profile, connection_closed_cb callback, void *user_data) { + int rv; + if (!(_connection_libnet_check_profile_validity(profile))) { - CONNECTION_LOG(CONNECTION_ERROR, "Wrong Parameter Passed\n"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); return CONNECTION_ERROR_INVALID_PARAMETER; } net_profile_info_t *profile_info = profile; - if (net_close_connection(profile_info->ProfileName) != NET_ERR_NONE) + rv = net_close_connection(profile_info->ProfileName); + if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) return CONNECTION_ERROR_OPERATION_FAILED; __libnet_set_closed_cb(callback, user_data); @@ -915,6 +1131,7 @@ int _connection_libnet_close_profile(connection_profile_h profile, connection_cl int _connection_libnet_add_route(const char *interface_name, const char *host_address) { + int rv; char *endstr = strrchr(host_address, '.'); if (endstr == NULL || @@ -922,11 +1139,15 @@ int _connection_libnet_add_route(const char *interface_name, const char *host_ad 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed"); return CONNECTION_ERROR_INVALID_PARAMETER; } - if (net_add_route(host_address, interface_name) != NET_ERR_NONE) + rv = net_add_route(host_address, interface_name); + if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) return CONNECTION_ERROR_OPERATION_FAILED; return CONNECTION_ERROR_NONE; @@ -934,6 +1155,7 @@ int _connection_libnet_add_route(const char *interface_name, const char *host_ad int _connection_libnet_remove_route(const char *interface_name, const char *host_address) { + int rv; char *endstr = strrchr(host_address, '.'); if (endstr == NULL || @@ -941,11 +1163,15 @@ int _connection_libnet_remove_route(const char *interface_name, const char *host 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"); + CONNECTION_LOG(CONNECTION_ERROR, "Invalid IP address Passed"); return CONNECTION_ERROR_INVALID_PARAMETER; } - if (net_remove_route(host_address, interface_name) != NET_ERR_NONE) + rv = net_remove_route(host_address, interface_name); + if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) return CONNECTION_ERROR_OPERATION_FAILED; return CONNECTION_ERROR_NONE; @@ -994,7 +1220,12 @@ bool _connection_libnet_remove_from_profile_cb_list(connection_profile_h profile int _connection_libnet_set_statistics(net_device_t device_type, net_statistics_type_e statistics_type) { - if (net_set_statistics(device_type, statistics_type) != NET_ERR_NONE) + int rv; + rv = net_set_statistics(device_type, statistics_type); + if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) return CONNECTION_ERROR_OPERATION_FAILED; return CONNECTION_ERROR_NONE; @@ -1002,8 +1233,36 @@ int _connection_libnet_set_statistics(net_device_t device_type, net_statistics_t int _connection_libnet_get_statistics(net_statistics_type_e statistics_type, unsigned long long *size) { - if (net_get_statistics(NET_DEVICE_WIFI, statistics_type, size) != NET_ERR_NONE) + int rv; + rv = net_get_statistics(NET_DEVICE_WIFI, statistics_type, size); + if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + }else if (rv != NET_ERR_NONE) + return CONNECTION_ERROR_OPERATION_FAILED; + + return CONNECTION_ERROR_NONE; +} + +int _connection_libnet_set_cellular_subscriber_id(connection_profile_h profile, + connection_cellular_subscriber_id_e sim_id) +{ + char *modem_path = NULL; + net_profile_info_t *profile_info = (net_profile_info_t *)profile; + + if (net_get_cellular_modem_object_path(&modem_path, sim_id) != NET_ERR_NONE) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to get subscriber[%d]", sim_id); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + if (!modem_path) { + CONNECTION_LOG(CONNECTION_ERROR, "NULL modem object path"); return CONNECTION_ERROR_OPERATION_FAILED; + } + + g_strlcpy(profile_info->ProfileInfo.Pdp.PSModemPath, modem_path, + NET_PROFILE_NAME_LEN_MAX); + g_free(modem_path); return CONNECTION_ERROR_NONE; } @@ -1027,7 +1286,7 @@ static gboolean __connection_idle_cb(gpointer user_data) return data->func(data->user_data); } -guint _connectioin_callback_add(GSourceFunc func, gpointer user_data) +guint _connection_callback_add(GSourceFunc func, gpointer user_data) { guint id; struct managed_idle_data *data; @@ -1077,3 +1336,86 @@ void _connection_callback_cleanup(void) g_slist_free(managed_idler_list); managed_idler_list = NULL; } + +int _connection_libnet_check_get_privilege() +{ + int rv; + + rv = net_check_get_privilege(); + if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) + return CONNECTION_ERROR_OPERATION_FAILED; + + return CONNECTION_ERROR_NONE; +} + +int _connection_libnet_check_profile_privilege() +{ + int rv; + + rv = net_check_profile_privilege(); + if (rv == NET_ERR_ACCESS_DENIED) { + CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); + return CONNECTION_ERROR_PERMISSION_DENIED; + } else if (rv != NET_ERR_NONE) + return CONNECTION_ERROR_OPERATION_FAILED; + + return CONNECTION_ERROR_NONE; +} + +bool _connection_libnet_get_is_check_enable_feature() +{ + return is_check_enable_feature; +} + +bool _connection_libnet_get_enable_feature_state(enable_feature_type_e feature_type) +{ + if(is_check_enable_feature){ + switch(feature_type) { + case FEATURE_TYPE_TELEPHONY: + return enable_feature.telephony; + case FEATURE_TYPE_WIFI: + return enable_feature.wifi; + case FEATURE_TYPE_TETHERING_BLUETOOTH: + return enable_feature.tethering_bluetooth; + default: + CONNECTION_LOG(CONNECTION_ERROR, "Invalid feature type"); + return false; + } + } + CONNECTION_LOG(CONNECTION_ERROR, "Not checked enable feature yet"); + return false; +} + +int _connection_libnet_check_enable_feature() +{ + int rv; + + if(!is_check_enable_feature){ + rv = system_info_get_platform_bool("tizen.org/feature/network.telephony", &enable_feature.telephony); + if(rv < 0) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to get system info for telephony feature"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + rv = system_info_get_platform_bool("tizen.org/feature/network.wifi", &enable_feature.wifi); + if(rv < 0) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to get system info for wifi feature"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + rv = system_info_get_platform_bool("tizen.org/feature/network.tethering.bluetooth", &enable_feature.tethering_bluetooth); + if(rv < 0) { + CONNECTION_LOG(CONNECTION_ERROR, "Failed to get system info for tethering bluetooth feature"); + return CONNECTION_ERROR_OPERATION_FAILED; + } + + CONNECTION_LOG(CONNECTION_INFO, "[Feature state] telephony : %d, wifi : %d, tethering bluetooth : %d", + enable_feature.telephony, enable_feature.wifi, enable_feature.tethering_bluetooth); + is_check_enable_feature = true; + } + + return CONNECTION_ERROR_NONE; +} diff --git a/wearable/test/CMakeLists.txt b/test/CMakeLists.txt index aef2fed..e0eccb7 100644 --- a/wearable/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,3 +1,5 @@ +PROJECT(connection_test C) + SET(fw_test "${fw_name}-test") SET(dependents "capi-base-common glib-2.0 network") @@ -18,3 +20,5 @@ FOREACH(src ${sources}) ADD_EXECUTABLE(${src_name} ${src}) TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS}) ENDFOREACH() + +INSTALL(TARGETS connection_test RUNTIME DESTINATION bin/) diff --git a/wearable/test/connection_test.c b/test/connection_test.c index 800653d..d964356 100644 --- a/wearable/test/connection_test.c +++ b/test/connection_test.c @@ -22,6 +22,7 @@ #include <glib.h> #include "net_connection.h" + #include <tizen_error.h> #define RETURN_FAIL_DESTROY(x) {connection_profile_destroy(x); return -1;} @@ -86,6 +87,46 @@ static const char *test_print_state(connection_profile_state_e state) } } +static const char *test_print_error(connection_error_e error) +{ + switch (error) { + case CONNECTION_ERROR_NONE: + return "CONNECTION_ERROR_NONE"; + case CONNECTION_ERROR_INVALID_PARAMETER: + return "CONNECTION_ERROR_INVALID_PARAMETER"; + case CONNECTION_ERROR_OUT_OF_MEMORY: + return "CONNECTION_ERROR_OUT_OF_MEMORY"; + case CONNECTION_ERROR_INVALID_OPERATION: + return "CONNECTION_ERROR_INVALID_OPERATION"; + case CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED: + return "CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED"; + case CONNECTION_ERROR_OPERATION_FAILED: + return "CONNECTION_ERROR_OPERATION_FAILED"; + case CONNECTION_ERROR_ITERATOR_END: + return "CONNECTION_ERROR_ITERATOR_END"; + case CONNECTION_ERROR_NO_CONNECTION: + return "CONNECTION_ERROR_NO_CONNECTION"; + case CONNECTION_ERROR_NOW_IN_PROGRESS: + return "CONNECTION_ERROR_NOW_IN_PROGRESS"; + case CONNECTION_ERROR_ALREADY_EXISTS: + return "CONNECTION_ERROR_ALREADY_EXISTS"; + case CONNECTION_ERROR_OPERATION_ABORTED: + return "CONNECTION_ERROR_OPERATION_ABORTED"; + case CONNECTION_ERROR_DHCP_FAILED: + return "CONNECTION_ERROR_DHCP_FAILED"; + case CONNECTION_ERROR_INVALID_KEY: + return "CONNECTION_ERROR_INVALID_KEY"; + case CONNECTION_ERROR_NO_REPLY: + return "CONNECTION_ERROR_NO_REPLY"; + case CONNECTION_ERROR_PERMISSION_DENIED: + return "CONNECTION_ERROR_PERMISSION_DENIED"; + case CONNECTION_ERROR_NOT_SUPPORTED: + return "CONNECTION_ERROR_NOT_SUPPORTED"; + default: + return "CONNECTION_ERROR_UNKNOWN"; + } +} + static void test_type_changed_callback(connection_type_e type, void* user_data) { printf("Type changed callback, connection type : %d\n", type); @@ -123,7 +164,7 @@ static void test_connection_opened_callback(connection_error_e result, void* use if (result == CONNECTION_ERROR_NONE) printf("Connection open Succeeded\n"); else - printf("Connection open Failed, err : %d\n", result); + printf("Connection open Failed, err : [%s]\n", test_print_error(result)); } static void test_connection_closed_callback(connection_error_e result, void* user_data) @@ -131,7 +172,15 @@ static void test_connection_closed_callback(connection_error_e result, void* use if (result == CONNECTION_ERROR_NONE) printf("Connection close Succeeded\n"); else - printf("Connection close Failed, err : %d\n", result); + printf("Connection close Failed, err : [%s]\n", test_print_error(result)); +} + +static void test_connection_reset_profile_callback(connection_error_e result, void* user_data) +{ + if (result == CONNECTION_ERROR_NONE) + printf("Reset profile Succeeded\n"); + else + printf("Reset profile Failed, err : [%s]\n", test_print_error(result)); } static void test_connection_set_default_callback(connection_error_e result, void* user_data) @@ -139,7 +188,7 @@ static void test_connection_set_default_callback(connection_error_e result, void if (result == CONNECTION_ERROR_NONE) printf("Default profile setting Succeeded\n"); else - printf("Default profile setting Failed, err : %d\n", result); + printf("Default profile setting Failed, err : [%s]\n", test_print_error(result)); } static bool test_get_user_selected_profile(connection_profile_h *profile, bool select) @@ -157,7 +206,7 @@ static bool test_get_user_selected_profile(connection_profile_h *profile, bool s rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_REGISTERED, &profile_iter); if (rv != CONNECTION_ERROR_NONE) { - printf("Fail to get profile iterator [%d]\n", rv); + printf("Fail to get profile iterator [%s]\n", test_print_error(rv)); return false; } @@ -268,19 +317,25 @@ static int test_update_cellular_info(connection_profile_h profile) } else return -1; + if (rv != CONNECTION_ERROR_NONE) + return -1; + if (test_get_user_string("Input Apn - (Enter for skip) :", input_str1, 100)) { + g_strstrip(input_str1); rv = connection_profile_set_cellular_apn(profile, input_str1); if (rv != CONNECTION_ERROR_NONE) return -1; } if (test_get_user_string("Input Proxy - (Enter for skip) :", input_str1, 100)) { + g_strstrip(input_str1); rv = connection_profile_set_proxy_address(profile, CONNECTION_ADDRESS_FAMILY_IPV4, input_str1); if (rv != CONNECTION_ERROR_NONE) return -1; } if (test_get_user_string("Input HomeURL - (Enter for skip) :", input_str1, 100)) { + g_strstrip(input_str1); rv = connection_profile_set_cellular_home_url(profile, input_str1); if (rv != CONNECTION_ERROR_NONE) return -1; @@ -306,6 +361,8 @@ static int test_update_cellular_info(connection_profile_h profile) if (test_get_user_string("Input AuthPwd(Enter for skip) :", input_str2, 100) == false) input_str2[0] = 0; + g_strstrip(input_str1); + g_strstrip(input_str2); rv = connection_profile_set_cellular_auth_info(profile, type_val, input_str1, input_str2); if (rv != CONNECTION_ERROR_NONE) return -1; @@ -466,7 +523,6 @@ static int test_update_network_info(connection_profile_h profile) static void test_print_cellular_info(connection_profile_h profile) { - connection_cellular_network_type_e network_type; connection_cellular_service_type_e service_type; char *apn = NULL; connection_cellular_auth_type_e auth_type; @@ -477,11 +533,6 @@ static void test_print_cellular_info(connection_profile_h profile) bool hidden = false; bool editable = false; - if (connection_profile_get_cellular_network_type(profile, &network_type) != CONNECTION_ERROR_NONE) - printf("Fail to get cellular network type!\n"); - else - printf("Cellular network type : %d\n", network_type); - if (connection_profile_get_cellular_service_type(profile, &service_type) != CONNECTION_ERROR_NONE) printf("Fail to get cellular service type!\n"); else @@ -515,6 +566,16 @@ static void test_print_cellular_info(connection_profile_h profile) printf("Fail to get cellular roaming state!\n"); else printf("Cellular roaming : %s\n", roaming ? "true" : "false"); + + if (connection_profile_is_cellular_hidden(profile, &hidden) != CONNECTION_ERROR_NONE) + printf("Fail to get cellular hidden state!\n"); + else + printf("Cellular hidden : %s\n", hidden ? "true" : "false"); + + if (connection_profile_is_cellular_editable(profile, &editable) != CONNECTION_ERROR_NONE) + printf("Fail to get cellular editing state!\n"); + else + printf("Cellular editable : %s\n", editable ? "true" : "false"); } static void test_print_wifi_info(connection_profile_h profile) @@ -661,7 +722,7 @@ int test_register_client(void) connection_set_ip_address_changed_cb(connection, test_ip_changed_callback, NULL); connection_set_proxy_address_changed_cb(connection, test_proxy_changed_callback, NULL); } else { - printf("Client registration failed %d\n", err); + printf("Client registration failed [%s]\n", test_print_error(err)); return -1; } @@ -682,8 +743,8 @@ int test_deregister_client(void) rv = CONNECTION_ERROR_INVALID_OPERATION; } - if (rv != CONNECTION_ERROR_NONE){ - printf("Client deregistration fail [%d]\n", rv); + if (rv != CONNECTION_ERROR_NONE) { + printf("Client deregistration fail [%s]\n", test_print_error(rv)); return -1; } @@ -711,11 +772,11 @@ int test_get_network_state(void) rv = connection_get_type(connection, &net_state); if (rv != CONNECTION_ERROR_NONE) { - printf("Fail to get network state [%d]\n", rv); + printf("Fail to get network state [%s]\n", test_print_error(rv)); return -1; } - printf("Retval = %d network connection state [%d]\n", rv, net_state); + printf("Retval = [%s] network connection state [%d]\n", test_print_error(rv), net_state); return 1; } @@ -728,11 +789,11 @@ int test_get_cellular_state(void) rv = connection_get_cellular_state(connection, &cellular_state); if (rv != CONNECTION_ERROR_NONE) { - printf("Fail to get Cellular state [%d]\n", rv); + printf("Fail to get Cellular state [%s]\n", test_print_error(rv)); return -1; } - printf("Retval = %d Cellular state [%d]\n", rv, cellular_state); + printf("Retval = [%s] Cellular state [%d]\n", test_print_error(rv), cellular_state); return 1; } @@ -745,11 +806,11 @@ int test_get_wifi_state(void) rv = connection_get_wifi_state(connection, &wifi_state); if (rv != CONNECTION_ERROR_NONE) { - printf("Fail to get WiFi state [%d]\n", rv); + printf("Fail to get WiFi state [%s]\n", test_print_error(rv)); return -1; } - printf("Retval = %d WiFi state [%d]\n", rv, wifi_state); + printf("Retval = [%s] WiFi state [%d]\n", test_print_error(rv), wifi_state); return 1; } @@ -828,16 +889,62 @@ int test_get_profile_list(void) return 1; } +int test_get_default_profile_list(void) +{ + int rv = 0; + char *profile_name = NULL; + connection_profile_iterator_h profile_iter; + connection_profile_h profile_h; + connection_cellular_service_type_e service_type; + bool is_default = false; + + rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_DEFAULT, &profile_iter); + if (rv != CONNECTION_ERROR_NONE) { + printf("Fail to get profile iterator [%s]\n", test_print_error(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); + + if (connection_profile_get_cellular_service_type(profile_h, &service_type) != CONNECTION_ERROR_NONE) { + printf("Fail to get profile service type\n"); + return -1; + } + printf("service type : %d\n", service_type); + + if (connection_profile_is_cellular_default(profile_h, &is_default) != CONNECTION_ERROR_NONE) { + printf("Fail to get profile subscriber id\n"); + return -1; + } + printf("Default : %d\n", is_default); + } + + return 1; +} + 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; + bool is_default = false; + connection_profile_type_e type; rv = connection_get_profile_iterator(connection, CONNECTION_ITERATOR_TYPE_CONNECTED, &profile_iter); if (rv != CONNECTION_ERROR_NONE) { - printf("Fail to get profile iterator [%d]\n", rv); + printf("Fail to get profile iterator [%s]\n", test_print_error(rv)); return -1; } @@ -851,8 +958,22 @@ int test_get_connected_profile_list(void) printf("Fail to get profile name\n"); return -1; } - printf("profile name : %s\n", profile_name); + printf("profile name is %s\n", profile_name); g_free(profile_name); + + if (connection_profile_get_type(profile_h, &type) != CONNECTION_ERROR_NONE) { + printf("Fail to get profile type\n"); + return -1; + } + printf("profile type is %d\n", type); + + if (type == CONNECTION_PROFILE_TYPE_CELLULAR) { + if (connection_profile_is_cellular_default(profile_h, &is_default) != CONNECTION_ERROR_NONE) { + printf("Fail to get profile is default\n"); + return -1; + } + printf("[%s]\n", is_default ? "default" : "not default"); + } } return 1; @@ -866,7 +987,7 @@ int test_get_current_profile(void) rv = connection_get_current_profile(connection, &profile_h); if (rv != CONNECTION_ERROR_NONE) { - printf("Fail to get profile iterator [%d]\n", rv); + printf("Fail to get profile iterator [%s]\n", test_print_error(rv)); return -1; } @@ -1013,6 +1134,7 @@ int test_add_profile(void) if (test_get_user_string("Input Keyword - (Enter for skip) :", input_str, 100) == false) return -1; + g_strstrip(input_str); rv = connection_profile_create(CONNECTION_PROFILE_TYPE_CELLULAR, input_str, &profile); if (rv != CONNECTION_ERROR_NONE) RETURN_FAIL_DESTROY(profile); @@ -1337,7 +1459,7 @@ int test_remove_route(void) rv = connection_remove_route(connection, if_name, ip_addr); if (rv != CONNECTION_ERROR_NONE) { - printf("Fail to remove the route [%d]\n", rv); + printf("Fail to remove the route [%s]\n", test_print_error(rv)); return -1; } @@ -1352,11 +1474,11 @@ int test_get_bt_state(void) rv = connection_get_bt_state(connection, &bt_state); if (rv != CONNECTION_ERROR_NONE) { - printf("Fail to get Bluetooth state [%d]\n", rv); + printf("Fail to get Bluetooth state [%s]\n", test_print_error(rv)); return -1; } - printf("Retval = %d, Bluetooth state [%d]\n", rv, bt_state); + printf("Retval = [%s], Bluetooth state [%d]\n", test_print_error(rv), bt_state); return 1; } @@ -1381,9 +1503,33 @@ int test_get_profile_id(void) return 1; } -int main(int argc, char **argv) +int test_reset_profile(void) { + int type, sim_id, rv; + + rv = test_get_user_int("Input reset type (0:default profile reset, 1:delete profile reset)", &type); + + if (rv == false || (type != 0 && type != 1)) { + printf("Invalid input!!\n"); + return -1; + } + + rv = test_get_user_int("Input SIM id to reset (0:SIM1, 1:SIM2)", &sim_id); + + if (rv == false || (sim_id != 0 && sim_id != 1)) { + printf("Invalid input!!\n"); + return -1; + } + if (connection_reset_profile(connection, type, sim_id, test_connection_reset_profile_callback, NULL) != CONNECTION_ERROR_NONE) { + return -1; + } + + return 1; +} + +int main(int argc, char **argv) +{ GMainLoop *mainloop; mainloop = g_main_loop_new (NULL, FALSE); @@ -1414,7 +1560,7 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) exit(1); } - if (*a == '\n' || *a == '\r'){ + if (*a == '\n' || *a == '\r') { printf("\n\n Network Connection API Test App\n\n"); printf("Options..\n"); printf("1 - Create Handle and set callbacks\n"); @@ -1433,7 +1579,7 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) printf("e - Get default cellular service by type\n"); printf("f - Set default cellular service by type\n"); printf("g - Close connection with profile\n"); - printf("h - Add profile(Cellular only)\n"); + printf("h - Add profile(Cellular and Wifi only)\n"); printf("i - Remove profile(Cellular:delete, WiFi:forgot)\n"); printf("j - Update profile\n"); printf("k - Get profile info\n"); @@ -1446,6 +1592,8 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) printf("r - Remove a route\n"); printf("s - Get Bluetooth state\n"); printf("t - Get profile id\n"); + printf("u - Reset profile\n"); + printf("v - Get all cellular default profiles\n"); printf("0 - Exit \n"); printf("ENTER - Show options menu.......\n"); } @@ -1538,6 +1686,12 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data) case 't': rv = test_get_profile_id(); break; + case 'u': + rv = test_reset_profile(); + break; + case 'v': + rv = test_get_default_profile_list(); + break; } if (rv == 1) diff --git a/wearable/AUTHORS b/wearable/AUTHORS deleted file mode 100644 index 5c2063d..0000000 --- a/wearable/AUTHORS +++ /dev/null @@ -1,2 +0,0 @@ -Jeik Jaehyun Kim <jeik01.kim@samsung.com> -ByungWoo Lee <bw1212.lee@samsung.com> diff --git a/wearable/LICENSE.APLv2 b/wearable/LICENSE.APLv2 deleted file mode 100644 index d645695..0000000 --- a/wearable/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/wearable/capi-network-connection.manifest b/wearable/capi-network-connection.manifest deleted file mode 100644 index 97e8c31..0000000 --- a/wearable/capi-network-connection.manifest +++ /dev/null @@ -1,5 +0,0 @@ -<manifest> - <request> - <domain name="_"/> - </request> -</manifest> diff --git a/wearable/capi-network-connection.pc.in b/wearable/capi-network-connection.pc.in deleted file mode 100644 index ee6db75..0000000 --- a/wearable/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/wearable/debian/capi-network-connection-dev.install b/wearable/debian/capi-network-connection-dev.install deleted file mode 100644 index 761a28b..0000000 --- a/wearable/debian/capi-network-connection-dev.install +++ /dev/null @@ -1,4 +0,0 @@ -/usr/include/* -/usr/include/*/* -/usr/lib/pkgconfig/*.pc - diff --git a/wearable/debian/capi-network-connection-dev.postinst b/wearable/debian/capi-network-connection-dev.postinst deleted file mode 100644 index 1a24852..0000000 --- a/wearable/debian/capi-network-connection-dev.postinst +++ /dev/null @@ -1 +0,0 @@ -#!/bin/sh diff --git a/wearable/debian/capi-network-connection.install b/wearable/debian/capi-network-connection.install deleted file mode 100644 index 4a755a4..0000000 --- a/wearable/debian/capi-network-connection.install +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/lib*.so* diff --git a/wearable/debian/capi-network-connection.postinst b/wearable/debian/capi-network-connection.postinst deleted file mode 100644 index 1a24852..0000000 --- a/wearable/debian/capi-network-connection.postinst +++ /dev/null @@ -1 +0,0 @@ -#!/bin/sh diff --git a/wearable/debian/changelog b/wearable/debian/changelog deleted file mode 100644 index 334f3b1..0000000 --- a/wearable/debian/changelog +++ /dev/null @@ -1,692 +0,0 @@ -capi-network-connection (0.1.20) unstable; urgency=low - - * Added config file in TC/ - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.20 - - -- Madhusmita Sahu <madhusmita.s@samsung.com> Mon, 28 Oct 2013 14:43:35 +0530 - -capi-network-connection (0.1.19) unstable; urgency=low - - * Added New TCs - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.19 - - -- Madhusmita Sahu <madhusmita.s@samsung.com> Mon, 03 Oct 2013 18:51:32 +0530 - -capi-network-connection (0.1.18) unstable; urgency=low - - * TC modification - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.18 - - -- Madhusmita Sahu <madhusmita.s@samsung.com> Mon, 23 Sep 2013 17:19:32 +0530 - -capi-network-connection (0.1.17) unstable; urgency=low - - * Remove unnecessary logs - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.17 - - -- Sanghoon Cho <sanghoon80.cho@samsung.com> Mon, 16 Sep 2013 22:19:32 +0900 - -capi-network-connection (0.1.16) unstable; urgency=low - - * Remove unnecessary and redundant logs - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.16 - - -- Danny Jeongseok Seo <s.seo@samsung.com> Thu, 08 Aug 2013 14:20:35 +0900 - -capi-network-connection (0.1.15) unstable; urgency=low - - * Add new API : connection_remove_route() - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.15 - - -- Sanghoon Cho <sanghoon80.cho@samsung.com> Tue, 06 Aug 2013 17:30:40 +0900 - -capi-network-connection (0.1.14) unstable; urgency=low - - * Fix build error for engineer mode - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.14 - - -- Sanghoon Cho <sanghoon80.cho@samsung.com> Tue, 06 Aug 2013 16:44:05 +0900 - -capi-network-connection (0.1.13) unstable; urgency=low - - * Clean asynchronous callbacks up when it de-registered - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.13 - - -- Danny Jeongseok Seo <s.seo@samsung.com> Fri, 05 Jul 2013 17:39:10 +0900 - -capi-network-connection (0.1.12) unstable; urgency=low - - * Fix minor prevent defects - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.12 - - -- Danny Jeongseok Seo <s.seo@samsung.com> Fri, 05 Jul 2013 10:55:27 +0900 - -capi-network-connection (0.1.11) unstable; urgency=low - - * Remove unnecessary logs, revise callback - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.11 - - -- Danny Jeongseok Seo <s.seo@samsung.com> Fri, 28 Jun 2013 18:23:37 +0900 - -capi-network-connection (0.1.10) unstable; urgency=low - - * Fix type, ip and proxy changed callback - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.10 - - -- Danny Jeongseok Seo <s.seo@samsung.com> Mon, 24 Jun 2013 13:41:14 +0900 - -capi-network-connection (0.1.9) unstable; urgency=low - - * Revise cellular data statistics - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.9 - - -- Danny Jeongseok Seo <s.seo@samsung.com> Wed, 12 Jun 2013 21:44:05 +0900 - -capi-network-connection (0.1.8) unstable; urgency=low - - * multi-thread: thread local storage support - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.8 - - -- Danny Jeongseok Seo <s.seo@samsung.com> Wed, 12 Jun 2013 21:21:55 +0900 - -capi-network-connection (0.1.7) unstable; urgency=low - - * Fix minor prevent issue - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.7 - - -- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 11 Jun 2013 15:06:31 +0900 - -capi-network-connection (0.1.6) unstable; urgency=low - - * Fix a crash of type_changed_cb - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.6 - - -- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 04 Jun 2013 12:40:15 +0900 - -capi-network-connection (0.1.5) unstable; urgency=low - - * Thread safety for connection handle management - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.5 - - -- Danny Jeongseok Seo <s.seo@samsung.com> Fri, 24 May 2013 12:56:20 +0900 - -capi-network-connection (0.1.4) unstable; urgency=low - - * Bug fix: release ip, proxy and type changed callback - * Thread safety - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.4 - - -- Danny Jeongseok Seo <s.seo@samsung.com> Thu, 23 May 2013 23:21:43 +0900 - -capi-network-connection (0.1.3-21) unstable; urgency=low - - * Use net-config and vconf method to retrieve statistics data - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-21 - - -- Ravi RK <ravi.rk@samsung.com> Thu, 09 May 2013 15:46:22 +0530 - -capi-network-connection (0.1.3-20) unstable; urgency=low - - * Add new API : connection_set_default_cellular_service_profile_async() - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-20 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Thu, 11 Apr 2013 23:47:32 +0900 - -capi-network-connection (0.1.3-19) unstable; urgency=low - - * Eliminate user privacy logs - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-19 - - -- Danny Jeongseok Seo <s.seo@samsung.com> Fri, 05 Apr 2013 21:18:51 +0900 - -capi-network-connection (0.1.3-18) unstable; urgency=low - - * Fix memory leak - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-18 - - -- Ravi RK <ravi.rk@samsung.com> Fri, 22 Mar 2013 14:47:28 +0530 - -capi-network-connection (0.1.3-17) unstable; urgency=low - - * Add new APIs to get hidden/editable state - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-17 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Thu, 14 Mar 2013 21:31:07 +0900 - -capi-network-connection (0.1.3-16) unstable; urgency=low - - * Set CFLAG fvisibility hidden - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-16 - - -- Danny Jeongseok Seo <s.seo@samsung.com> Thu, 21 Feb 2013 16:48:41 +0900 - -capi-network-connection (0.1.3-15) unstable; urgency=low - - * Use system resource manager api to get & set the statistics. - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-15 - - -- Praveen C <pravin.c@samsung.com> Fri, 15 Feb 2013 10:35:42 +0530 - -capi-network-connection (0.1.3-14) unstable; urgency=low - - * SMACK rules updated - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-14 - - -- Danny Jeongseok Seo <s.seo@samsung.com> Thu, 14 Feb 2013 22:32:23 +0900 - -capi-network-connection (0.1.3-13) unstable; urgency=low - - * SMACK rules updated - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-13 - - -- Danny Jeongseok Seo <s.seo@samsung.com> Tue, 05 Feb 2013 20:09:52 +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-5) unstable; urgency=low - - * Revise connection_profile_get_cellular_network_type(), connman doesn't provide this information anymore - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-5 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Fri, 04 Jan 2013 15:37:20 +0900 - -capi-network-connection (0.1.3-4) unstable; urgency=low - - * In case of setting IP address, Gateway, Subnet and proxy, it is allowed that a value is set to NULL - * Add connection_profile_get_id() - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-4 - - -- JaeHyun Kim <jeik01.kim@samsung.com> Thu, 03 Jan 2013 20:18:49 +0900 - -capi-network-connection (0.1.3-3) unstable; urgency=low - - * Checking return value and strict nul-terminated buffer - * Git: framework/api/connection - * Tag: capi-network-connection_0.1.3-3 - - -- 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/wearable/debian/compat b/wearable/debian/compat deleted file mode 100644 index 7f8f011..0000000 --- a/wearable/debian/compat +++ /dev/null @@ -1 +0,0 @@ -7 diff --git a/wearable/debian/control b/wearable/debian/control deleted file mode 100644 index bfc5f03..0000000 --- a/wearable/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/wearable/debian/rules b/wearable/debian/rules deleted file mode 100755 index 678a339..0000000 --- a/wearable/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/wearable/include/connection_profile.h b/wearable/include/connection_profile.h deleted file mode 100644 index 1f37c06..0000000 --- a/wearable/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__ */ |