diff options
Diffstat (limited to 'include')
-rwxr-xr-x[-rw-r--r--] | include/connection_profile.h | 10 | ||||
-rwxr-xr-x | include/net_connection.h | 112 | ||||
-rwxr-xr-x | include/net_connection_private.h | 41 |
3 files changed, 131 insertions, 32 deletions
diff --git a/include/connection_profile.h b/include/connection_profile.h index 86860b0..433c4ca 100644..100755 --- a/include/connection_profile.h +++ b/include/connection_profile.h @@ -172,10 +172,8 @@ typedef enum{ * @details The profile name, which you get from connection_profile_get_name(), will include the keyword you set. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public - * @privilege %http://tizen.org/privilege/network.profile \n - * %http://tizen.org/privilege/network.get - * @remarks You must release @a profile using connection_profile_destroy(). \n - * This API needs both privileges. + * @privilege %http://tizen.org/privilege/network.get + * @remarks You must release @a profile using connection_profile_destroy(). * @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 @@ -203,7 +201,7 @@ int connection_profile_destroy(connection_profile_h profile); /** * @brief Clones a profile handle. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @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 @@ -476,7 +474,7 @@ int connection_profile_set_gateway_address(connection_profile_h profile, connect * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks The allowance of the DNS address is @c 2. * @param[in] profile The profile handle - * @param[in] order The order of the DNS address. \n + * @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 diff --git a/include/net_connection.h b/include/net_connection.h index 2087ea4..f658d50 100755 --- a/include/net_connection.h +++ b/include/net_connection.h @@ -83,15 +83,14 @@ typedef enum } connection_wifi_state_e; /** - * @internal * @brief Enumeration for ethernet state. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.4 */ typedef enum { - 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_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; /** @@ -127,6 +126,16 @@ typedef enum } connection_reset_option_e; /** + * @brief This enumeration defines the attached or detached state of ethernet cable. + * @since_tizen 2.4 + */ +typedef enum +{ + CONNECTION_ETHERNET_CABLE_DETACHED = 0, /**< Ethernet cable is detached */ + CONNECTION_ETHERNET_CABLE_ATTACHED = 1, /**< Ethernet cable is attached */ +} connection_ethernet_cable_state_e; + +/** * @brief Enumeration for connection errors. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ @@ -283,6 +292,23 @@ 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 MAC address of the Wi-Fi or ethernet. + * @since_tizen 2.4 + * @remarks @a mac_addr must be released with free() by you. + * @param[in] connection The handle of the connection + * @param[in] type The type of current network connection + * @param[out] mac_addr The MAC address + * @return 0 on success, otherwise negative error value. + * @retval #CONNECTION_ERROR_NONE Successful + * @retval #CONNECTION_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #CONNECTION_ERROR_INVALID_OPERATION Invalid operation + * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported + * @retval #CONNECTION_ERROR_OUT_OF_MEMORY Out of memory + */ +int connection_get_mac_address(connection_h connection, connection_type_e type, char** mac_addr); + +/** * @brief Gets the state of cellular connection. * @details The returned state is for the cellular connection state. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif @@ -314,10 +340,9 @@ int connection_get_cellular_state(connection_h connection, connection_cellular_s int connection_get_wifi_state(connection_h connection, connection_wifi_state_e* state); /** - * @internal * @brief Gets the state of the Ethernet. * @details The returned state is for the Ethernet connection state. - * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif + * @since_tizen 2.4 * @privlevel public * @privilege %http://tizen.org/privilege/network.get * @param[in] connection The connection handle @@ -332,6 +357,58 @@ int connection_get_wifi_state(connection_h connection, connection_wifi_state_e* int connection_get_ethernet_state(connection_h connection, connection_ethernet_state_e* state); /** +* @brief Checks for ethernet cable is attached or not. +* @details The returned state is for the ethernet cable state. +* @since_tizen 2.4 +* @privlevel public +* @privilege %http://tizen.org/privilege/network.get +* @param[in] connection The handle of the connection +* @param[in] state - Enum connection_ethernet_cable_state_e +* @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_NOT_SUPPORTED Not supported +* @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied +*/ +int connection_get_ethernet_cable_state(connection_h connection, connection_ethernet_cable_state_e *state); + +/** + * @brief Called when ethernet cable is plugged [in/out]. + * @since_tizen 2.4 + * @param[in] state The ethernet cable state (connection_ethernet_cable_state_e) + * @param[in] user_data The user data passed to callback registration function + */ +typedef void(*connection_ethernet_cable_state_chaged_cb)( + connection_ethernet_cable_state_e state, void* user_data); + +/** + * @brief Registers callback for ethernet cable is plugged [in/out] event. + * @since_tizen 2.4 + * @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_NOT_SUPPORTED Not supported + */ +int connection_set_ethernet_cable_state_chaged_cb( connection_h connection, + connection_ethernet_cable_state_chaged_cb callback, void *user_data); + +/** + * @brief Unregisters callback for ethernet cable is plugged [in/out] event. + * @since_tizen 2.4 + * @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 + * @retval #CONNECTION_ERROR_NOT_SUPPORTED Not supported + */ +int connection_unset_ethernet_cable_state_chaged_cb(connection_h connection); + +/** * @brief Gets the state of the Bluetooth. * @details The returned state is for the Bluetooth connection state. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif @@ -424,10 +501,8 @@ int connection_unset_proxy_address_changed_cb(connection_h connection); * @brief Adds a new profile which is created by connection_profile_create(). * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public - * @privilege %http://tizen.org/privilege/network.profile \n - * %http://tizen.org/privilege/network.get - * @remarks You can only add a profile of the cellular type. \n - * This API needs both privileges. + * @privilege %http://tizen.org/privilege/network.profile + * @remarks You can only add a profile of the cellular type. * @param[in] connection The connection handle * @param[in] profile The profile handle * @return @c 0 on success, otherwise a negative error value @@ -667,9 +742,7 @@ int connection_open_profile(connection_h connection, connection_profile_h profil * @brief Closes a connection of profile. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public - * @privilege %http://tizen.org/privilege/network.set \n - * %http://tizen.org/privilege/network.get - * @remarks This API needs both privileges. + * @privilege %http://tizen.org/privilege/network.set * @param[in] connection The connection handle * @param[in] profile The profile handle * @param[in] callback The callback function to be called @@ -715,9 +788,7 @@ int connection_reset_profile(connection_h connection, connection_reset_option_e * @details You can get the @a interface_name from connection_profile_get_network_interface_name() of opened profile. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public - * @privilege %http://tizen.org/privilege/network.set \n - * %http://tizen.org/privilege/network.get - * @remarks This API needs both privileges. + * @privilege %http://tizen.org/privilege/network.set * @param[in] connection The connection handle * @param[in] interface_name The name of network interface * @param[in] host_address The IP address of the host @@ -736,9 +807,7 @@ int connection_add_route(connection_h connection, const char* interface_name, co * @details You can get the @a interface_name from connection_profile_get_network_interface_name() of opened profile. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public - * @privilege %http://tizen.org/privilege/network.set \n - * %http://tizen.org/privilege/network.get - * @remarks This API needs both privileges. + * @privilege %http://tizen.org/privilege/network.set * @param[in] connection The connection handle * @param[in] interface_name The name of network interface * @param[in] host_address The IP address of the host @@ -820,8 +889,7 @@ int connection_get_statistics(connection_h connection, connection_type_e connect * @brief Resets the statistics information. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @privlevel public - * @privilege %http://tizen.org/privilege/network.set \n - * %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/network.set * @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) diff --git a/include/net_connection_private.h b/include/net_connection_private.h index 831ee54..0a389c4 100755 --- a/include/net_connection_private.h +++ b/include/net_connection_private.h @@ -11,7 +11,7 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License. + * limitations under the License. */ #ifndef __NET_CONNECTION_PRIVATE_H__ @@ -34,10 +34,14 @@ extern "C" { #define CONNECTION_ERROR 2 #define CONNECTION_WARN 3 +#define CONNECTION_MAC_INFO_LENGTH 17 +#define ETHERNET_MAC_INFO_FILE "/sys/class/net/eth0/address" +#define WIFI_MAC_INFO_FILE "/sys/class/net/wlan0/address" + #define TELEPHONY_FEATURE "http://tizen.org/feature/network.telephony" #define WIFI_FEATURE "http://tizen.org/feature/network.wifi" -#define TETHERING_BLUETOOTH_FEATURE "http://tizen.org/feature/network.tethering.bluetooth" -#define ETHERNET_FEATURE "http://tizen.org/feature/network.ethernet" +#define TETHERING_BLUETOOTH_FEATURE "http://tizen.org/feature/network.tethering.bluetooth" +#define ETHERNET_FEATURE "http://tizen.org/feature/network.ethernet" typedef enum { @@ -45,13 +49,25 @@ typedef enum CONNECTION_CELLULAR_SUBSCRIBER_2 = 0x01, } connection_cellular_subscriber_id_e; - +typedef enum +{ + CONNECTION_SUPPORTED_FEATURE_TELEPHONY, + CONNECTION_SUPPORTED_FEATURE_WIFI, + CONNECTION_SUPPORTED_FEATURE_TETHERING_BLUETOOTH, + CONNECTION_SUPPORTED_FEATURE_ETHERNET, + CONNECTION_SUPPORTED_FEATURE_MAX, +} connection_supported_feature_e; + +#if !defined TIZEN_TV #define CHECK_FEATURE_SUPPORTED(...) \ do { \ int rv = _connection_check_feature_supported(__VA_ARGS__, NULL); \ if( rv != CONNECTION_ERROR_NONE ) \ return rv; \ } while(0) +#else +#define CHECK_FEATURE_SUPPORTED(...) +#endif #define CONNECTION_LOG(log_level, format, args...) \ do { \ @@ -84,12 +100,29 @@ typedef enum #define VCONF_TELEPHONY_DEFAULT_DATA_SERVICE \ "db/telephony/dualsim/default_data_service" +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; + connection_ethernet_cable_state_chaged_cb ethernet_cable_state_changed_callback; + void *type_changed_user_data; + void *ip_changed_user_data; + void *proxy_changed_user_data; + void *ethernet_cable_state_changed_user_data; +} connection_handle_s; + +typedef void(*libnet_ethernet_cable_state_changed_cb) + (connection_ethernet_cable_state_e state); + bool _connection_is_created(void); int _connection_libnet_init(void); bool _connection_libnet_deinit(void); 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_ethernet_cable_state(connection_ethernet_cable_state_e* state); +int _connection_libnet_set_ethernet_cable_state_changed_cb( + libnet_ethernet_cable_state_changed_cb callback); 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); |