Add API(ethernet cable state)
[platform/core/api/connection.git] / include / net_connection.h
1 /*
2  * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __NET_CONNECTION_INTF_H__
18 #define __NET_CONNECTION_INTF_H__
19
20 #include "connection_profile.h"
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif /* __cplusplus */
25
26 /**
27  * @file net_connection.h
28  */
29
30 /**
31  * @addtogroup CAPI_NETWORK_CONNECTION_MANAGER_MODULE
32  * @{
33  */
34
35 /**
36  * @brief The connection handle.
37  * @since_tizen 2.3
38 */
39 typedef void* connection_h;
40
41 /**
42  * @brief The profiles iterator handle.
43  * @since_tizen 2.3
44 */
45 typedef void* connection_profile_iterator_h;
46
47 /**
48  * @brief Enumeration for connection type.
49  * @since_tizen 2.3
50  */
51 typedef enum
52 {
53     CONNECTION_TYPE_DISCONNECTED = 0,  /**< Disconnected */
54     CONNECTION_TYPE_WIFI = 1,  /**< Wi-Fi type */
55     CONNECTION_TYPE_CELLULAR = 2,  /**< Cellular type */
56     CONNECTION_TYPE_ETHERNET = 3,  /**< Ethernet type */
57     CONNECTION_TYPE_BT = 4,  /**< Bluetooth type */
58 } connection_type_e;
59
60 /**
61  * @brief Enumeration for cellular network state.
62  * @since_tizen 2.3
63  */
64 typedef enum
65 {
66     CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE = 0,  /**< Out of service */
67     CONNECTION_CELLULAR_STATE_FLIGHT_MODE = 1,  /**< Flight mode */
68     CONNECTION_CELLULAR_STATE_ROAMING_OFF = 2,  /**< Roaming is turned off */
69     CONNECTION_CELLULAR_STATE_CALL_ONLY_AVAILABLE = 3,  /**< Call is only available */
70     CONNECTION_CELLULAR_STATE_AVAILABLE = 4,  /**< Available but not connected yet */
71     CONNECTION_CELLULAR_STATE_CONNECTED = 5,  /**< Connected */
72 } connection_cellular_state_e;
73
74 /**
75  * @brief Enumeration for Wi-Fi state.
76  * @since_tizen 2.3
77  */
78 typedef enum
79 {
80     CONNECTION_WIFI_STATE_DEACTIVATED = 0,  /**< Wi-Fi is deactivated */
81     CONNECTION_WIFI_STATE_DISCONNECTED = 1,  /**< Disconnected */
82     CONNECTION_WIFI_STATE_CONNECTED = 2,  /**< Connected */
83 } connection_wifi_state_e;
84
85 /**
86  * @brief Enumeration for ethernet state.
87  * @since_tizen 2.4
88  */
89 typedef enum
90 {
91     CONNECTION_ETHERNET_STATE_DEACTIVATED = 0,  /**< There is no Ethernet profile to open */
92     CONNECTION_ETHERNET_STATE_DISCONNECTED = 1,  /**< Disconnected */
93     CONNECTION_ETHERNET_STATE_CONNECTED = 2,  /**< Connected */
94 } connection_ethernet_state_e;
95
96 /**
97  * @brief Enumeration for Bluetooth state.
98  * @since_tizen 2.3
99  */
100 typedef enum
101 {
102     CONNECTION_BT_STATE_DEACTIVATED = 0,  /**< There is no Bluetooth profile to open */
103     CONNECTION_BT_STATE_DISCONNECTED = 1,  /**< Disconnected */
104     CONNECTION_BT_STATE_CONNECTED = 2,  /**< Connected */
105 } connection_bt_state_e;
106
107 /**
108  * @brief Enumeration for connection iterator type.
109  * @since_tizen 2.3
110  */
111 typedef enum
112 {
113     CONNECTION_ITERATOR_TYPE_REGISTERED = 0,  /**< The iterator of the registered profile  */
114     CONNECTION_ITERATOR_TYPE_CONNECTED = 1,  /**< The iterator of the connected profile  */
115         CONNECTION_ITERATOR_TYPE_DEFAULT = 2,   /**< The iterator of the default profile  */
116 } connection_iterator_type_e;
117
118 /**
119  * @brief Enumeration for reset profile type.
120  * @since_tizen 2.3
121 */
122 typedef enum
123 {
124     CONNECTION_RESET_DEFAULT_PROFILE = 0,  /**< Initialized with the default profile defined by csc */
125     CONNECTION_RESET_CLEAR_PROFILE = 1,  /**< Remove all profiles */
126 } connection_reset_option_e;
127
128 /**
129  * @brief This enumeration defines the attached or detached state of ethernet cable.
130  * @since_tizen 2.4
131  */
132 typedef enum
133 {
134     CONNECTION_ETHERNET_CABLE_DETACHED = 0,  /**< Ethernet cable is detached */
135     CONNECTION_ETHERNET_CABLE_ATTACHED = 1,  /**< Ethernet cable is attached */
136 } connection_ethernet_cable_state_e;
137
138 /**
139  * @brief Enumeration for connection errors.
140  * @since_tizen 2.3
141  */
142 typedef enum
143 {
144     CONNECTION_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
145     CONNECTION_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
146     CONNECTION_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory error */
147     CONNECTION_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid Operation */
148     CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED = TIZEN_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED, /**< Address family not supported */
149     CONNECTION_ERROR_OPERATION_FAILED = TIZEN_ERROR_CONNECTION|0x0401, /**< Operation failed */
150     CONNECTION_ERROR_ITERATOR_END = TIZEN_ERROR_CONNECTION|0x0402, /**< End of iteration */
151     CONNECTION_ERROR_NO_CONNECTION = TIZEN_ERROR_CONNECTION|0x0403, /**< There is no connection */
152     CONNECTION_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /** Now in progress */
153     CONNECTION_ERROR_ALREADY_EXISTS = TIZEN_ERROR_CONNECTION|0x0404, /**< Already exists */
154     CONNECTION_ERROR_OPERATION_ABORTED = TIZEN_ERROR_CONNECTION|0x0405, /**< Operation is aborted */
155     CONNECTION_ERROR_DHCP_FAILED = TIZEN_ERROR_CONNECTION|0x0406, /**< DHCP failed  */
156     CONNECTION_ERROR_INVALID_KEY = TIZEN_ERROR_CONNECTION|0x0407, /**< Invalid key  */
157     CONNECTION_ERROR_NO_REPLY = TIZEN_ERROR_CONNECTION|0x0408, /**< No reply */
158     CONNECTION_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
159     CONNECTION_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED  /**< Not Supported */
160 } connection_error_e;
161
162 /**
163  * @}
164 */
165
166 /**
167  * @addtogroup CAPI_NETWORK_CONNECTION_STATISTICS_MODULE
168  * @{
169 */
170
171 /**
172  * @brief Enumeration for statistics type.
173  * @since_tizen 2.3
174  */
175 typedef enum
176 {
177     CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA = 0,  /**< Last received data */
178     CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA = 1,  /**< Last sent data */
179     CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA = 2,  /**< Total received data */
180     CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA = 3,  /**< Total sent data */
181 } connection_statistics_type_e;
182
183 /**
184  * @}
185 */
186
187 /**
188  * @addtogroup CAPI_NETWORK_CONNECTION_MANAGER_MODULE
189  * @{
190 */
191
192
193 /**
194  * @brief Creates a handle for managing data connections.
195  * @since_tizen 2.3
196  * @privlevel public
197  * @privilege %http://tizen.org/privilege/network.get
198  * @remarks You must release @a handle using connection_destroy().
199  * @param[out] connection  The connection handle
200  * @return @c 0 on success, otherwise a negative error value
201  * @retval #CONNECTION_ERROR_NONE  Successful
202  * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
203  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY  Out of memory
204  * @see connection_destroy()
205  */
206 int connection_create(connection_h* connection);
207
208 /**
209  * @brief Destroys the connection handle.
210  * @since_tizen 2.3
211  * @param[in] connection  The connection handle
212  * @return @c 0 on success, otherwise negative error value
213  * @retval #CONNECTION_ERROR_NONE  Successful
214  * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
215  * @see connection_create()
216  */
217 int connection_destroy(connection_h connection);
218
219 /**
220  * @brief Called when the type of a connection is changed.
221  * @since_tizen 2.3
222  * @param[in] type  The type of the current network connection
223  * @param[in] user_data The user data passed from the callback registration function
224  * @see connection_set_type_changed_cb()
225  * @see connection_unset_type_changed_cb()
226  */
227 typedef void(*connection_type_changed_cb)(connection_type_e type, void* user_data);
228
229 /**
230  * @brief Called when the address is changed.
231  * @since_tizen 2.3
232  * @param[in] ipv4_address  The IP address for IPv4
233  * @param[in] ipv6_address  The IP address for IPv6
234  * @param[in] user_data The user data passed from the callback registration function
235  * @see connection_set_ip_address_changed_cb()
236  * @see connection_unset_ip_address_changed_cb()
237  * @see connection_set_proxy_address_changed_cb()
238  * @see connection_unset_proxy_address_changed_cb()
239  */
240 typedef void(*connection_address_changed_cb)(const char* ipv4_address, const char* ipv6_address, void* user_data);
241
242 /**
243  * @brief Called when connection_set_default_cellular_service_profile_async() finishes.
244  * @since_tizen 2.3
245  * @param[in] result  The result
246  * @param[in] user_data The user data passed from connection_open_profile()
247  * @pre connection_set_default_cellular_service_profile_async() will invoke this callback function.
248  * @see connection_set_default_cellular_service_profile_async()
249 */
250 typedef void(*connection_set_default_cb)(connection_error_e result, void* user_data);
251
252 /**
253  * @brief Gets the type of the current profile for data connection.
254  * @since_tizen 2.3
255  * @param[in] connection  The connection handle
256  * @param[out] type  The type of the network
257  * @return @c 0 on success, otherwise negative error value
258  * @retval #CONNECTION_ERROR_NONE  Successful
259  * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
260  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
261  */
262 int connection_get_type(connection_h connection, connection_type_e* type);
263
264 /**
265  * @brief Gets the IP address of the current connection.
266  * @since_tizen 2.3
267  * @remarks You must release @a ip_address using free().
268  * @param[in] connection  The connection handle
269  * @param[in] address_family  The address family
270  * @param[out] ip_address  The pointer to the IP address string
271  * @return @c 0 on success, otherwise a negative error value
272  * @retval #CONNECTION_ERROR_NONE  Successful
273  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
274  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
275  * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED  Not supported address family
276  */
277 int connection_get_ip_address(connection_h connection, connection_address_family_e address_family, char** ip_address);
278
279 /**
280  * @brief Gets the proxy address of the current connection.
281  * @since_tizen 2.3
282  * @remarks You must release @a proxy using free().
283  * @param[in] connection  The connection handle
284  * @param[in] address_family  The address family
285  * @param[out] proxy  The proxy address
286  * @return @c 0 on success, otherwise a negative error value
287  * @retval #CONNECTION_ERROR_NONE  Successful
288  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
289  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
290  * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED  Not supported address family
291  */
292 int connection_get_proxy(connection_h connection, connection_address_family_e address_family, char** proxy);
293
294 /**
295  * @brief Gets the MAC address of the Wi-Fi or ethernet.
296  * @since_tizen 2.4
297  * @remarks @a mac_addr must be released with free() by you.
298  * @param[in] connection  The handle of the connection
299  * @param[in] type  The type of current network connection
300  * @param[out] mac_addr  The MAC address
301  * @return 0 on success, otherwise negative error value.
302  * @retval #CONNECTION_ERROR_NONE  Successful
303  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
304  * @retval #CONNECTION_ERROR_INVALID_OPERATION   Invalid operation
305  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
306  * @retval #CONNECTION_ERROR_NOT_SUPPORTED  Not supported
307  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY  Out of memory
308  */
309 int connection_get_mac_address(connection_h connection, connection_type_e type, char** mac_addr);
310
311 /**
312  * @brief Gets the state of cellular connection.
313  * @details The returned state is for the cellular connection state.
314  * @since_tizen 2.3
315  * @param[in] connection  The connection handle
316  * @param[out] state  The state of the cellular connection
317  * @return @c 0 on success, otherwise a negative error value
318  * @retval #CONNECTION_ERROR_NONE  Successful
319  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
320  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
321  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not supported
322  */
323 int connection_get_cellular_state(connection_h connection, connection_cellular_state_e* state);
324
325 /**
326  * @brief Gets the state of the Wi-Fi.
327  * @details The returned state is for the Wi-Fi connection state.
328  * @since_tizen 2.3
329  * @privlevel public
330  * @privilege %http://tizen.org/privilege/network.get
331  * @param[in] connection  The connection handle
332  * @param[out] state  The state of Wi-Fi connection
333  * @return @c 0 on success, otherwise a negative error value
334  * @retval #CONNECTION_ERROR_NONE  Successful
335  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
336  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
337  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
338  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not supported
339  */
340 int connection_get_wifi_state(connection_h connection, connection_wifi_state_e* state);
341
342 /**
343  * @brief Gets the state of the Ethernet.
344  * @details The returned state is for the Ethernet connection state.
345  * @since_tizen 2.4
346  * @privlevel public
347  * @privilege %http://tizen.org/privilege/network.get
348  * @param[in] connection  The connection handle
349  * @param[out] state  The state of Ethernet connection
350  * @return @c 0 on success, otherwise a negative error value
351  * @retval #CONNECTION_ERROR_NONE  Successful
352  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
353  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
354  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
355  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not supported
356  */
357 int connection_get_ethernet_state(connection_h connection, connection_ethernet_state_e* state);
358
359 /**
360 * @brief Checks for ethernet cable is attached or not.
361 * @details The returned state is for the ethernet cable state.
362 * @since_tizen 2.4
363 * @privlevel public
364 * @privilege %http://tizen.org/privilege/network.get
365 * @param[in] connection  The handle of the connection
366 * @param[in] state - Enum connection_ethernet_cable_state_e
367 * @return 0 on success, otherwise negative error value
368 * @retval #CONNECTION_ERROR_NONE  Successful
369 * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
370 * @retval #CONNECTION_ERROR_OPERATION_FAILED Operation failed
371 * @retval #CONNECTION_ERROR_NOT_SUPPORTED  Not supported
372 * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
373 */
374 int connection_get_ethernet_cable_state(connection_h connection, connection_ethernet_cable_state_e *state);
375
376 /**
377  * @brief Called when ethernet cable is plugged [in/out].
378  * @since_tizen 2.4
379  * @param[in] state The ethernet cable state (connection_ethernet_cable_state_e)
380  * @param[in] user_data The user data passed to callback registration function
381  */
382 typedef void(*connection_ethernet_cable_state_chaged_cb)(
383                         connection_ethernet_cable_state_e state, void* user_data);
384
385 /**
386  * @brief Registers callback for ethernet cable is plugged [in/out] event.
387  * @since_tizen 2.4
388  * @param[in] callback  The callback function to be called
389  * @param[in] user_data The user data passed to the callback function
390  * @return 0 on success, otherwise negative error value
391  * @retval #CONNECTION_ERROR_NONE   Successful
392  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
393  * @retval #CONNECTION_ERROR_OPERATION_FAILED   Operation failed
394  * @retval #CONNECTION_ERROR_NOT_SUPPORTED  Not supported
395  */
396 int connection_set_ethernet_cable_state_chaged_cb( connection_h connection,
397                 connection_ethernet_cable_state_chaged_cb callback, void *user_data);
398
399 /**
400  * @brief Unregisters callback for ethernet cable is plugged [in/out] event.
401  * @since_tizen 2.4
402  * @param[in] connection  The handle of connection
403  * @return 0 on success, otherwise negative error value
404  * @retval #CONNECTION_ERROR_NONE  Successful
405  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
406  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
407  * @retval #CONNECTION_ERROR_NOT_SUPPORTED  Not supported
408  */
409 int connection_unset_ethernet_cable_state_chaged_cb(connection_h connection);
410
411 /**
412  * @brief Gets the state of the Bluetooth.
413  * @details The returned state is for the Bluetooth connection state.
414  * @since_tizen 2.3
415  * @privlevel public
416  * @privilege %http://tizen.org/privilege/network.get
417  * @param[in] connection  The connection handle
418  * @param[out] state  The state of the Bluetooth connection
419  * @return @c 0 on success, otherwise a negative error value
420  * @retval #CONNECTION_ERROR_NONE  Successful
421  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
422  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
423  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
424  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not supported
425  */
426 int connection_get_bt_state(connection_h connection, connection_bt_state_e* state);
427
428 /**
429  * @brief Registers the callback that is called when the type of the current connection is changed.
430  * @since_tizen 2.3
431  * @param[in] connection  The connection handle
432  * @param[in] callback  The callback function to be called
433  * @param[in] user_data The user data passed to the callback function
434  * @return @c 0 on success, otherwise a negative error value
435  * @retval #CONNECTION_ERROR_NONE  Successful
436  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
437  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
438  */
439 int connection_set_type_changed_cb(connection_h connection, connection_type_changed_cb callback, void* user_data);
440
441 /**
442  * @brief Unregisters the callback that is called when the type of current connection is changed.
443  * @since_tizen 2.3
444  * @param[in] connection  The connection handle
445  * @return @c 0 on success, otherwise a negative error value
446  * @retval #CONNECTION_ERROR_NONE  Successful
447  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
448  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
449  */
450 int connection_unset_type_changed_cb(connection_h connection);
451
452 /**
453  * @brief Registers the callback that is called when the IP address is changed.
454  * @since_tizen 2.3
455  * @param[in] connection  The connection handle
456  * @param[in] callback  The callback function to be called
457  * @param[in] user_data The user data passed to the callback function
458  * @return @c 0 on success, otherwise a negative error value
459  * @retval #CONNECTION_ERROR_NONE  Successful
460  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
461  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
462  */
463 int connection_set_ip_address_changed_cb(connection_h connection, connection_address_changed_cb callback, void* user_data);
464
465 /**
466  * @brief Unregisters the callback that is called when the IP address is changed.
467  * @since_tizen 2.3
468  * @param[in] connection  The connection handle
469  * @return @c 0 on success, otherwise a negative error value
470  * @retval #CONNECTION_ERROR_NONE  Successful
471  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
472  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
473  */
474 int connection_unset_ip_address_changed_cb(connection_h connection);
475
476 /**
477  * @brief Registers the callback that is called when the proxy address is changed.
478  * @since_tizen 2.3
479  * @param[in] connection  The connection handle
480  * @param[in] callback  The callback function to be called
481  * @param[in] user_data The user data passed to the callback function
482  * @return @c 0 on success, otherwise a negative error value
483  * @retval #CONNECTION_ERROR_NONE  Successful
484  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
485  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
486  */
487 int connection_set_proxy_address_changed_cb(connection_h connection, connection_address_changed_cb callback, void* user_data);
488
489 /**
490  * @brief Unregisters the callback that is called when the proxy address is changed.
491  * @since_tizen 2.3
492  * @param[in] connection  The connection handle
493  * @return @c 0 on success, otherwise a negative error value
494  * @retval #CONNECTION_ERROR_NONE  Successful
495  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
496  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
497  */
498 int connection_unset_proxy_address_changed_cb(connection_h connection);
499
500 /**
501  * @brief Adds a new profile which is created by connection_profile_create().
502  * @since_tizen 2.3
503  * @privlevel public
504  * @privilege %http://tizen.org/privilege/network.profile
505  * @remarks You can only add a profile of the cellular type.
506  * @param[in] connection  The connection handle
507  * @param[in] profile  The profile handle
508  * @return @c 0 on success, otherwise a negative error value
509  * @retval #CONNECTION_ERROR_NONE  Successful
510  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
511  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
512  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
513  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not Supported
514  */
515 int connection_add_profile(connection_h connection, connection_profile_h profile);
516
517 /**
518  * @brief Removes an existing profile.
519  * @since_tizen 2.3
520  * @privlevel public
521  * @privilege %http://tizen.org/privilege/network.profile \n
522  *            %http://tizen.org/privilege/network.get
523  * @remarks This API needs both privileges.
524  * @param[in] connection  The connection handle
525  * @param[in] profile  The profile handle
526  * @return @c 0 on success, otherwise a negative error value
527  * @retval #CONNECTION_ERROR_NONE  Successful
528  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
529  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
530  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
531  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not Supported
532  */
533 int connection_remove_profile(connection_h connection, connection_profile_h profile);
534
535 /**
536  * @brief Updates an existing profile.
537  * @details When a profile is changed, these changes will be not applied to the Connection Manager immediately.
538  * When you call this function, your changes affect the Connection Manager and the existing profile is updated.
539  * In addition, the existing profile will be updated if you call connection_open_profile().
540  * @since_tizen 2.3
541  * @privlevel public
542  * @privilege %http://tizen.org/privilege/network.profile \n
543  *            %http://tizen.org/privilege/network.get
544  * @remarks This API needs both privileges.
545  * @param[in] connection  The connection handle
546  * @param[in] profile  The profile handle
547  * @return @c 0 on success, otherwise a negative error value
548  * @retval #CONNECTION_ERROR_NONE  Successful
549  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
550  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
551  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
552  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not Supported
553  * @see connection_open_profile()
554  */
555 int connection_update_profile(connection_h connection, connection_profile_h profile);
556
557 /**
558  * @brief Gets a profiles iterator.
559  * @since_tizen 2.3
560  * @privlevel public
561  * @privilege %http://tizen.org/privilege/network.get
562  * @remarks You must release @a profile_iterator using connection_destroy().
563  * @param[in] connection  The connection handle
564  * @param[in] type  The type of the connetion iterator
565  * @param[out] profile_iterator  The iterator of profile
566  * @return @c 0 on success, otherwise a negative error value
567  * @retval #CONNECTION_ERROR_NONE  Successful
568  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
569  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY  Out of memory
570  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
571  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
572  */
573 int connection_get_profile_iterator(connection_h connection, connection_iterator_type_e type, connection_profile_iterator_h* profile_iterator);
574
575 /**
576  * @brief Moves the profile iterator to the next position and gets a profile handle.
577  * @since_tizen 2.3
578  * @param[in] profile_iterator  The iterator of profile
579  * @param[out] profile  The profile handle
580  * @return @c 0 on success, otherwise a negative error value
581  * @retval #CONNECTION_ERROR_NONE  Successful
582  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
583  * @retval #CONNECTION_ERROR_ITERATOR_END  End of iteration
584  */
585 int connection_profile_iterator_next(connection_profile_iterator_h profile_iterator, connection_profile_h* profile);
586
587 /**
588  * @brief Checks whether the next element of a profile iterator exists or not.
589  * @since_tizen 2.3
590  * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
591  * @param[in] profile_iterator  The iterator of profile
592  * @return @c true if next element exists, otherwise @c false if next element doesn't exist
593  */
594 bool connection_profile_iterator_has_next(connection_profile_iterator_h profile_iterator);
595
596 /**
597  * @brief Destroys a profiles iterator.
598  * @since_tizen 2.3
599  * @param[in] profile_iterator  The iterator of the profile
600  * @return @c 0 on success, otherwise a negative error value
601  * @retval #CONNECTION_ERROR_NONE  Successful
602  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
603  */
604 int connection_destroy_profile_iterator(connection_profile_iterator_h profile_iterator);
605
606 /**
607  * @brief Gets the name of the default profile.
608  * @since_tizen 2.3
609  * @privlevel public
610  * @privilege %http://tizen.org/privilege/network.get
611  * @remarks You must release @a profile using connection_profile_destroy().
612  * @param[in] connection  The connection handle
613  * @param[out] profile  The profile handle
614  * @return @c 0 on success, otherwise a negative error value
615  * @retval #CONNECTION_ERROR_NONE  Successful
616  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
617  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY  Out of memory
618  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
619  * @retval #CONNECTION_ERROR_NO_CONNECTION  There is no connection
620  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
621  */
622 int connection_get_current_profile(connection_h connection, connection_profile_h* profile);
623
624 /**
625  * @brief Gets the default profile which provides the given cellular service.
626  * @since_tizen 2.3
627  * @privlevel public
628  * @privilege %http://tizen.org/privilege/network.get
629  * @remarks You must release @a profile using connection_profile_destroy().
630  * @param[in] connection  The connection handle
631  * @param[in] type  The type of cellular service \n
632  *                 #CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION is not permitted.
633  * @param[out] profile  The profile handle
634  * @return @c 0 on success, otherwise a negative error value
635  * @retval #CONNECTION_ERROR_NONE  Successful
636  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
637  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY  Out of memory
638  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
639  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denieda
640  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not Supported
641  */
642 int connection_get_default_cellular_service_profile(connection_h connection, connection_cellular_service_type_e type, connection_profile_h* profile);
643
644 /**
645  * @brief Sets the default profile which provides the given cellular service.
646  * @since_tizen 2.3
647  * @privlevel public
648  * @privilege %http://tizen.org/privilege/network.profile \n
649  *            %http://tizen.org/privilege/network.get
650  * @remarks This API needs both privileges.
651  * @param[in] connection  The connection handle
652  * @param[in] type  The type of cellular service \n
653  *                 only #CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET and #CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET are permitted.
654  * @param[in] profile  The profile handle
655  * @return @c 0 on success, otherwise a negative error value
656  * @retval #CONNECTION_ERROR_NONE  Successful
657  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
658  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
659  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
660  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not Supported
661  */
662 int connection_set_default_cellular_service_profile(connection_h connection, connection_cellular_service_type_e type, connection_profile_h profile);
663
664 /**
665  * @brief Sets the default profile which provides the given cellular service, asynchronously.
666  * @since_tizen 2.3
667  * @privlevel public
668  * @privilege %http://tizen.org/privilege/network.profile \n
669  *            %http://tizen.org/privilege/network.get
670  * @remarks This API needs both privileges.
671  * @param[in] connection  The connection handle
672  * @param[in] type  The type of cellular service (only #CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET and #CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET are permitted)
673  * @param[in] profile  The profile handle
674  * @param[in] callback  The callback function to be called
675  * @param[in] user_data The user data passed to the callback function
676  * @return @c 0 on success, otherwise negative error value
677  * @retval #CONNECTION_ERROR_NONE  Successful
678  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
679  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
680  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
681  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not Supported
682  */
683 int connection_set_default_cellular_service_profile_async(connection_h connection,
684                 connection_cellular_service_type_e type, connection_profile_h profile, connection_set_default_cb callback, void* user_data);
685
686 /**
687  * @brief Called after connection_open_profile() is finished.
688  * @since_tizen 2.3
689  * @param[in] result  The result
690  * @param[in] user_data The user data passed from connection_open_profile()
691  * @pre connection_open_profile() will invoke this callback function.
692  * @see connection_open_profile()
693 */
694 typedef void(*connection_opened_cb)(connection_error_e result, void* user_data);
695
696 /**
697  * @brief Called after connection_close_profile() is finished.
698  * @since_tizen 2.3
699  * @param[in] result  The result
700  * @param[in] user_data The user data passed from connection_close_profile()
701  * @pre connection_close_profile() will invoke this callback function.
702  * @see connection_close_profile()
703 */
704 typedef void(*connection_closed_cb)(connection_error_e result, void* user_data);
705
706 /**
707  * @brief Called after connection_reset_profile() is finished.
708  * @since_tizen 2.3
709  * @param[in] result  The result
710  * @param[in] user_data The user data passed from connection_reset_profile()
711  * @pre connection_reset_profile() will invoke this callback function.
712  * @see connection_reset_profile()
713 */
714 typedef void(*connection_reset_cb)(connection_error_e result, void* user_data);
715
716 /**
717  * @brief Opens a connection of profile, asynchronously.
718  * @since_tizen 2.3
719  * @privlevel public
720  * @privilege %http://tizen.org/privilege/network.set \n
721  *            %http://tizen.org/privilege/network.get
722  * @remarks This API needs both privileges.
723  * @param[in] connection  The connection handle
724  * @param[in] profile  The profile handle
725  * @param[in] callback  The callback function to be called
726  * @param[in] user_data The user data passed to the callback function
727  * @return @c 0 on success, otherwise negative error value
728  * @retval #CONNECTION_ERROR_NONE  Successful
729  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
730  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
731  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
732  * @post connection_opened_cb() will be invoked.
733  * @see connection_opened_cb()
734  * @see connection_close_profile()
735  * @see connection_profile_set_state_changed_cb()
736  * @see connection_profile_unset_state_changed_cb()
737  * @see connection_profile_state_changed_cb()
738  */
739 int connection_open_profile(connection_h connection, connection_profile_h profile, connection_opened_cb callback, void* user_data);
740
741 /**
742  * @brief Closes a connection of profile.
743  * @since_tizen 2.3
744  * @privlevel public
745  * @privilege %http://tizen.org/privilege/network.set
746  * @param[in] connection  The connection handle
747  * @param[in] profile  The profile handle
748  * @param[in] callback  The callback function to be called
749  * @param[in] user_data The user data passed to the callback function
750  * @return @c 0 on success, otherwise negative error value
751  * @retval #CONNECTION_ERROR_NONE  Successful
752  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
753  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
754  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
755  * @post connection_closed_cb() will be invoked.
756  * @see connection_closed_cb()
757  * @see connection_open_profile()
758  * @see connection_profile_set_state_changed_cb()
759  * @see connection_profile_unset_state_changed_cb()
760  * @see connection_profile_state_changed_cb()
761  */
762 int connection_close_profile(connection_h connection, connection_profile_h profile, connection_closed_cb callback, void* user_data);
763
764 /**
765  * @brief Resets the cellular profile.
766  * @since_tizen 2.3
767  * @privlevel public
768  * @privilege %http://tizen.org/privilege/network.profile \n
769  *            %http://tizen.org/privilege/network.get
770  * @remarks This API needs both privileges.
771  * @param[in] connection  The connection handle
772  * @param[in] type  The type of reset
773  * @param[in] id  The subscriber identity module id to reset (The sim index starts from 0.)
774  * @param[in] callback  The callback function to be called
775  * @param[in] user_data The user data passed to the callback function
776  * @return 0 on success, otherwise negative error value
777  * @retval #CONNECTION_ERROR_NONE Successful
778  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
779  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
780  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
781  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not Supported
782  * @post connection_reset_cb() will be invoked.
783 */
784 int connection_reset_profile(connection_h connection, connection_reset_option_e type, int id, connection_reset_cb callback, void *user_data);
785
786 /**
787  * @brief Adds a IPv4 route to the routing table.
788  * @details You can get the @a interface_name from connection_profile_get_network_interface_name() of opened profile.
789  * @since_tizen 2.3
790  * @privlevel public
791  * @privilege %http://tizen.org/privilege/network.set
792  * @param[in] connection  The connection handle
793  * @param[in] interface_name  The name of network interface
794  * @param[in] host_address  The IP address of the host
795  * @return @c 0 on success, otherwise negative error value
796  * @retval #CONNECTION_ERROR_NONE  Successful
797  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
798  * @retval #CONNECTION_ERROR_ALREADY_EXISTS  Already exists
799  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
800  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
801  * @see connection_profile_get_network_interface_name()
802  */
803 int connection_add_route(connection_h connection, const char* interface_name, const char* host_address);
804
805 /**
806  * @brief Removes a IPv4 route from the routing table.
807  * @details You can get the @a interface_name from connection_profile_get_network_interface_name() of opened profile.
808  * @since_tizen 2.3
809  * @privlevel public
810  * @privilege %http://tizen.org/privilege/network.set
811  * @param[in] connection  The connection handle
812  * @param[in] interface_name  The name of network interface
813  * @param[in] host_address  The IP address of the host
814  * @return @c 0 on success, otherwise negative error value
815  * @retval #CONNECTION_ERROR_NONE  Successful
816  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
817  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
818  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
819  * @see connection_profile_get_network_interface_name()
820  */
821 int connection_remove_route(connection_h connection, const char* interface_name, const char* host_address);
822
823 /**
824  * @brief Adds a IPv6 route to the routing table.
825  * @details You can get the @a interface_name from connection_profile_get_network_interface_name() of opened profile.
826  * @since_tizen 2.3.1
827  * @privlevel public
828  * @privilege %http://tizen.org/privilege/network.set
829  * @param[in] connection  The connection handle
830  * @param[in] interface_name  The name of network interface
831  * @param[in] host_address  The IP address of the host
832  * @param[in] gateway  The gateway address
833  * @return @c 0 on success, otherwise negative error value
834  * @retval #CONNECTION_ERROR_NONE  Successful
835  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
836  * @retval #CONNECTION_ERROR_ALREADY_EXISTS  Already exists
837  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
838  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
839  * @see connection_profile_get_network_interface_name()
840  */
841 int connection_remove_route(connection_h connection, const char* interface_name, const char* host_address);
842
843 /**
844  * @}
845 */
846
847 /**
848  * @addtogroup CAPI_NETWORK_CONNECTION_STATISTICS_MODULE
849  * @{
850 */
851
852 /**
853  * @brief Gets the statistics information.
854  * @since_tizen 2.3
855  * @privlevel public
856  * @privilege %http://tizen.org/privilege/network.get
857  * @param[in] connection  The connection handle
858  * @param[in] connection_type  The type of connection (only CONNECTION_TYPE_WIFI and CONNECTION_TYPE_CELLULAR are supported)
859  * @param[in] statistics_type  The type of statistics
860  * @param[out] size  The received data size of the last cellular packet data connection (bytes)
861  * @return @c 0 on success, otherwise negative error value
862  * @retval #CONNECTION_ERROR_NONE  Successful
863  * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
864  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
865  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not Supported
866  */
867 int connection_get_statistics(connection_h connection, connection_type_e connection_type, connection_statistics_type_e statistics_type, long long* size);
868
869 /**
870  * @brief Resets the statistics information.
871  * @since_tizen 2.3
872  * @privlevel public
873  * @privilege %http://tizen.org/privilege/network.set
874  * @remarks This API needs both privileges.
875  * @param[in] connection  The connection handle
876  * @param[in] connection_type  The type of connection (only CONNECTION_TYPE_WIFI and CONNECTION_TYPE_CELLULAR are supported)
877  * @param[in] statistics_type  The type of statistics
878  * @return @c 0 on success, otherwise negative error value
879  * @retval #CONNECTION_ERROR_NONE Successful
880  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
881  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
882  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
883  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not Supported
884  */
885 int connection_reset_statistics(connection_h connection, connection_type_e connection_type, connection_statistics_type_e statistics_type);
886
887 /**
888  * @}
889 */
890
891 #ifdef __cplusplus
892 }
893 #endif /* __cplusplus */
894
895 #endif