[tizen2.4 sync] Modified decription & privilege
[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 Enumeration for connection errors.
130  * @since_tizen 2.3
131  */
132 typedef enum
133 {
134     CONNECTION_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
135     CONNECTION_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
136     CONNECTION_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory error */
137     CONNECTION_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid Operation */
138     CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED = TIZEN_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED, /**< Address family not supported */
139     CONNECTION_ERROR_OPERATION_FAILED = TIZEN_ERROR_CONNECTION|0x0401, /**< Operation failed */
140     CONNECTION_ERROR_ITERATOR_END = TIZEN_ERROR_CONNECTION|0x0402, /**< End of iteration */
141     CONNECTION_ERROR_NO_CONNECTION = TIZEN_ERROR_CONNECTION|0x0403, /**< There is no connection */
142     CONNECTION_ERROR_NOW_IN_PROGRESS = TIZEN_ERROR_NOW_IN_PROGRESS, /** Now in progress */
143     CONNECTION_ERROR_ALREADY_EXISTS = TIZEN_ERROR_CONNECTION|0x0404, /**< Already exists */
144     CONNECTION_ERROR_OPERATION_ABORTED = TIZEN_ERROR_CONNECTION|0x0405, /**< Operation is aborted */
145     CONNECTION_ERROR_DHCP_FAILED = TIZEN_ERROR_CONNECTION|0x0406, /**< DHCP failed  */
146     CONNECTION_ERROR_INVALID_KEY = TIZEN_ERROR_CONNECTION|0x0407, /**< Invalid key  */
147     CONNECTION_ERROR_NO_REPLY = TIZEN_ERROR_CONNECTION|0x0408, /**< No reply */
148     CONNECTION_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
149     CONNECTION_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED  /**< Not Supported */
150 } connection_error_e;
151
152 /**
153  * @}
154 */
155
156 /**
157  * @addtogroup CAPI_NETWORK_CONNECTION_STATISTICS_MODULE
158  * @{
159 */
160
161 /**
162  * @brief Enumeration for statistics type.
163  * @since_tizen 2.3
164  */
165 typedef enum
166 {
167     CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA = 0,  /**< Last received data */
168     CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA = 1,  /**< Last sent data */
169     CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA = 2,  /**< Total received data */
170     CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA = 3,  /**< Total sent data */
171 } connection_statistics_type_e;
172
173 /**
174  * @}
175 */
176
177 /**
178  * @addtogroup CAPI_NETWORK_CONNECTION_MANAGER_MODULE
179  * @{
180 */
181
182
183 /**
184  * @brief Creates a handle for managing data connections.
185  * @since_tizen 2.3
186  * @privlevel public
187  * @privilege %http://tizen.org/privilege/network.get
188  * @remarks You must release @a handle using connection_destroy().
189  * @param[out] connection  The connection handle
190  * @return @c 0 on success, otherwise a negative error value
191  * @retval #CONNECTION_ERROR_NONE  Successful
192  * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
193  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY  Out of memory
194  * @see connection_destroy()
195  */
196 int connection_create(connection_h* connection);
197
198 /**
199  * @brief Destroys the connection handle.
200  * @since_tizen 2.3
201  * @param[in] connection  The connection handle
202  * @return @c 0 on success, otherwise negative error value
203  * @retval #CONNECTION_ERROR_NONE  Successful
204  * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
205  * @see connection_create()
206  */
207 int connection_destroy(connection_h connection);
208
209 /**
210  * @brief Called when the type of a connection is changed.
211  * @since_tizen 2.3
212  * @param[in] type  The type of the current network connection
213  * @param[in] user_data The user data passed from the callback registration function
214  * @see connection_set_type_changed_cb()
215  * @see connection_unset_type_changed_cb()
216  */
217 typedef void(*connection_type_changed_cb)(connection_type_e type, void* user_data);
218
219 /**
220  * @brief Called when the address is changed.
221  * @since_tizen 2.3
222  * @param[in] ipv4_address  The IP address for IPv4
223  * @param[in] ipv6_address  The IP address for IPv6
224  * @param[in] user_data The user data passed from the callback registration function
225  * @see connection_set_ip_address_changed_cb()
226  * @see connection_unset_ip_address_changed_cb()
227  * @see connection_set_proxy_address_changed_cb()
228  * @see connection_unset_proxy_address_changed_cb()
229  */
230 typedef void(*connection_address_changed_cb)(const char* ipv4_address, const char* ipv6_address, void* user_data);
231
232 /**
233  * @brief Called when connection_set_default_cellular_service_profile_async() finishes.
234  * @since_tizen 2.3
235  * @param[in] result  The result
236  * @param[in] user_data The user data passed from connection_open_profile()
237  * @pre connection_set_default_cellular_service_profile_async() will invoke this callback function.
238  * @see connection_set_default_cellular_service_profile_async()
239 */
240 typedef void(*connection_set_default_cb)(connection_error_e result, void* user_data);
241
242 /**
243  * @brief Gets the type of the current profile for data connection.
244  * @since_tizen 2.3
245  * @param[in] connection  The connection handle
246  * @param[out] type  The type of the network
247  * @return @c 0 on success, otherwise negative error value
248  * @retval #CONNECTION_ERROR_NONE  Successful
249  * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
250  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
251  */
252 int connection_get_type(connection_h connection, connection_type_e* type);
253
254 /**
255  * @brief Gets the IP address of the current connection.
256  * @since_tizen 2.3
257  * @remarks You must release @a ip_address using free().
258  * @param[in] connection  The connection handle
259  * @param[in] address_family  The address family
260  * @param[out] ip_address  The pointer to the IP address string
261  * @return @c 0 on success, otherwise a negative error value
262  * @retval #CONNECTION_ERROR_NONE  Successful
263  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
264  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
265  * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED  Not supported address family
266  */
267 int connection_get_ip_address(connection_h connection, connection_address_family_e address_family, char** ip_address);
268
269 /**
270  * @brief Gets the proxy address of the current connection.
271  * @since_tizen 2.3
272  * @remarks You must release @a proxy using free().
273  * @param[in] connection  The connection handle
274  * @param[in] address_family  The address family
275  * @param[out] proxy  The proxy address
276  * @return @c 0 on success, otherwise a negative error value
277  * @retval #CONNECTION_ERROR_NONE  Successful
278  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
279  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
280  * @retval #CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED  Not supported address family
281  */
282 int connection_get_proxy(connection_h connection, connection_address_family_e address_family, char** proxy);
283
284 /**
285  * @brief Gets the state of cellular connection.
286  * @details The returned state is for the cellular connection state.
287  * @since_tizen 2.3
288  * @param[in] connection  The connection handle
289  * @param[out] state  The state of the cellular connection
290  * @return @c 0 on success, otherwise a negative error value
291  * @retval #CONNECTION_ERROR_NONE  Successful
292  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
293  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
294  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not supported
295  */
296 int connection_get_cellular_state(connection_h connection, connection_cellular_state_e* state);
297
298 /**
299  * @brief Gets the state of the Wi-Fi.
300  * @details The returned state is for the Wi-Fi connection state.
301  * @since_tizen 2.3
302  * @privlevel public
303  * @privilege %http://tizen.org/privilege/network.get
304  * @param[in] connection  The connection handle
305  * @param[out] state  The state of Wi-Fi connection
306  * @return @c 0 on success, otherwise a negative error value
307  * @retval #CONNECTION_ERROR_NONE  Successful
308  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
309  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
310  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
311  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not supported
312  */
313 int connection_get_wifi_state(connection_h connection, connection_wifi_state_e* state);
314
315 /**
316  * @brief Gets the state of the Ethernet.
317  * @details The returned state is for the Ethernet connection state.
318  * @since_tizen 2.4
319  * @privlevel public
320  * @privilege %http://tizen.org/privilege/network.get
321  * @param[in] connection  The connection handle
322  * @param[out] state  The state of Ethernet connection
323  * @return @c 0 on success, otherwise a negative error value
324  * @retval #CONNECTION_ERROR_NONE  Successful
325  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
326  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
327  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
328  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not supported
329  */
330 int connection_get_ethernet_state(connection_h connection, connection_ethernet_state_e* state);
331
332 /**
333  * @brief Gets the state of the Bluetooth.
334  * @details The returned state is for the Bluetooth connection state.
335  * @since_tizen 2.3
336  * @privlevel public
337  * @privilege %http://tizen.org/privilege/network.get
338  * @param[in] connection  The connection handle
339  * @param[out] state  The state of the Bluetooth connection
340  * @return @c 0 on success, otherwise a negative error value
341  * @retval #CONNECTION_ERROR_NONE  Successful
342  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
343  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
344  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
345  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not supported
346  */
347 int connection_get_bt_state(connection_h connection, connection_bt_state_e* state);
348
349 /**
350  * @brief Registers the callback that is called when the type of the current connection is changed.
351  * @since_tizen 2.3
352  * @param[in] connection  The connection handle
353  * @param[in] callback  The callback function to be called
354  * @param[in] user_data The user data passed to the callback function
355  * @return @c 0 on success, otherwise a negative error value
356  * @retval #CONNECTION_ERROR_NONE  Successful
357  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
358  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
359  */
360 int connection_set_type_changed_cb(connection_h connection, connection_type_changed_cb callback, void* user_data);
361
362 /**
363  * @brief Unregisters the callback that is called when the type of current connection is changed.
364  * @since_tizen 2.3
365  * @param[in] connection  The connection handle
366  * @return @c 0 on success, otherwise a negative error value
367  * @retval #CONNECTION_ERROR_NONE  Successful
368  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
369  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
370  */
371 int connection_unset_type_changed_cb(connection_h connection);
372
373 /**
374  * @brief Registers the callback that is called when the IP address is changed.
375  * @since_tizen 2.3
376  * @param[in] connection  The connection handle
377  * @param[in] callback  The callback function to be called
378  * @param[in] user_data The user data passed to the callback function
379  * @return @c 0 on success, otherwise a negative error value
380  * @retval #CONNECTION_ERROR_NONE  Successful
381  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
382  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
383  */
384 int connection_set_ip_address_changed_cb(connection_h connection, connection_address_changed_cb callback, void* user_data);
385
386 /**
387  * @brief Unregisters the callback that is called when the IP address is changed.
388  * @since_tizen 2.3
389  * @param[in] connection  The connection handle
390  * @return @c 0 on success, otherwise a 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  */
395 int connection_unset_ip_address_changed_cb(connection_h connection);
396
397 /**
398  * @brief Registers the callback that is called when the proxy address is changed.
399  * @since_tizen 2.3
400  * @param[in] connection  The connection handle
401  * @param[in] callback  The callback function to be called
402  * @param[in] user_data The user data passed to the callback function
403  * @return @c 0 on success, otherwise a 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  */
408 int connection_set_proxy_address_changed_cb(connection_h connection, connection_address_changed_cb callback, void* user_data);
409
410 /**
411  * @brief Unregisters the callback that is called when the proxy address is changed.
412  * @since_tizen 2.3
413  * @param[in] connection  The connection handle
414  * @return @c 0 on success, otherwise a negative error value
415  * @retval #CONNECTION_ERROR_NONE  Successful
416  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
417  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
418  */
419 int connection_unset_proxy_address_changed_cb(connection_h connection);
420
421 /**
422  * @brief Adds a new profile which is created by connection_profile_create().
423  * @since_tizen 2.3
424  * @privlevel public
425  * @privilege %http://tizen.org/privilege/network.profile
426  * @remarks You can only add a profile of the cellular type.
427  * @param[in] connection  The connection handle
428  * @param[in] profile  The profile handle
429  * @return @c 0 on success, otherwise a negative error value
430  * @retval #CONNECTION_ERROR_NONE  Successful
431  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
432  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
433  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
434  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not Supported
435  */
436 int connection_add_profile(connection_h connection, connection_profile_h profile);
437
438 /**
439  * @brief Removes an existing profile.
440  * @since_tizen 2.3
441  * @privlevel public
442  * @privilege %http://tizen.org/privilege/network.profile \n
443  *            %http://tizen.org/privilege/network.get
444  * @remarks This API needs both privileges.
445  * @param[in] connection  The connection handle
446  * @param[in] profile  The profile handle
447  * @return @c 0 on success, otherwise a negative error value
448  * @retval #CONNECTION_ERROR_NONE  Successful
449  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
450  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
451  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
452  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not Supported
453  */
454 int connection_remove_profile(connection_h connection, connection_profile_h profile);
455
456 /**
457  * @brief Updates an existing profile.
458  * @details When a profile is changed, these changes will be not applied to the Connection Manager immediately.
459  * When you call this function, your changes affect the Connection Manager and the existing profile is updated.
460  * In addition, the existing profile will be updated if you call connection_open_profile().
461  * @since_tizen 2.3
462  * @privlevel public
463  * @privilege %http://tizen.org/privilege/network.profile \n
464  *            %http://tizen.org/privilege/network.get
465  * @remarks This API needs both privileges.
466  * @param[in] connection  The connection handle
467  * @param[in] profile  The profile handle
468  * @return @c 0 on success, otherwise a negative error value
469  * @retval #CONNECTION_ERROR_NONE  Successful
470  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
471  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
472  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
473  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not Supported
474  * @see connection_open_profile()
475  */
476 int connection_update_profile(connection_h connection, connection_profile_h profile);
477
478 /**
479  * @brief Gets a profiles iterator.
480  * @since_tizen 2.3
481  * @privlevel public
482  * @privilege %http://tizen.org/privilege/network.get
483  * @remarks You must release @a profile_iterator using connection_destroy().
484  * @param[in] connection  The connection handle
485  * @param[in] type  The type of the connetion iterator
486  * @param[out] profile_iterator  The iterator of profile
487  * @return @c 0 on success, otherwise a negative error value
488  * @retval #CONNECTION_ERROR_NONE  Successful
489  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
490  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY  Out of memory
491  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
492  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
493  */
494 int connection_get_profile_iterator(connection_h connection, connection_iterator_type_e type, connection_profile_iterator_h* profile_iterator);
495
496 /**
497  * @brief Moves the profile iterator to the next position and gets a profile handle.
498  * @since_tizen 2.3
499  * @param[in] profile_iterator  The iterator of profile
500  * @param[out] profile  The profile handle
501  * @return @c 0 on success, otherwise a negative error value
502  * @retval #CONNECTION_ERROR_NONE  Successful
503  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
504  * @retval #CONNECTION_ERROR_ITERATOR_END  End of iteration
505  */
506 int connection_profile_iterator_next(connection_profile_iterator_h profile_iterator, connection_profile_h* profile);
507
508 /**
509  * @brief Checks whether the next element of a profile iterator exists or not.
510  * @since_tizen 2.3
511  * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
512  * @param[in] profile_iterator  The iterator of profile
513  * @return @c true if next element exists, otherwise @c false if next element doesn't exist
514  */
515 bool connection_profile_iterator_has_next(connection_profile_iterator_h profile_iterator);
516
517 /**
518  * @brief Destroys a profiles iterator.
519  * @since_tizen 2.3
520  * @param[in] profile_iterator  The iterator of the profile
521  * @return @c 0 on success, otherwise a negative error value
522  * @retval #CONNECTION_ERROR_NONE  Successful
523  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
524  */
525 int connection_destroy_profile_iterator(connection_profile_iterator_h profile_iterator);
526
527 /**
528  * @brief Gets the name of the default profile.
529  * @since_tizen 2.3
530  * @privlevel public
531  * @privilege %http://tizen.org/privilege/network.get
532  * @remarks You must release @a profile using connection_profile_destroy().
533  * @param[in] connection  The connection handle
534  * @param[out] profile  The profile handle
535  * @return @c 0 on success, otherwise a negative error value
536  * @retval #CONNECTION_ERROR_NONE  Successful
537  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
538  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY  Out of memory
539  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
540  * @retval #CONNECTION_ERROR_NO_CONNECTION  There is no connection
541  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
542  */
543 int connection_get_current_profile(connection_h connection, connection_profile_h* profile);
544
545 /**
546  * @brief Gets the default profile which provides the given cellular service.
547  * @since_tizen 2.3
548  * @privlevel public
549  * @privilege %http://tizen.org/privilege/network.get
550  * @remarks You must release @a profile using connection_profile_destroy().
551  * @param[in] connection  The connection handle
552  * @param[in] type  The type of cellular service \n
553  *                 #CONNECTION_CELLULAR_SERVICE_TYPE_APPLICATION is not permitted.
554  * @param[out] profile  The profile handle
555  * @return @c 0 on success, otherwise a negative error value
556  * @retval #CONNECTION_ERROR_NONE  Successful
557  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
558  * @retval #CONNECTION_ERROR_OUT_OF_MEMORY  Out of memory
559  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
560  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denieda
561  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not Supported
562  */
563 int connection_get_default_cellular_service_profile(connection_h connection, connection_cellular_service_type_e type, connection_profile_h* profile);
564
565 /**
566  * @brief Sets the default profile which provides the given cellular service.
567  * @since_tizen 2.3
568  * @privlevel public
569  * @privilege %http://tizen.org/privilege/network.profile \n
570  *            %http://tizen.org/privilege/network.get
571  * @remarks This API needs both privileges.
572  * @param[in] connection  The connection handle
573  * @param[in] type  The type of cellular service \n
574  *                 only #CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET and #CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET are permitted.
575  * @param[in] profile  The profile handle
576  * @return @c 0 on success, otherwise a negative error value
577  * @retval #CONNECTION_ERROR_NONE  Successful
578  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
579  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
580  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
581  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not Supported
582  */
583 int connection_set_default_cellular_service_profile(connection_h connection, connection_cellular_service_type_e type, connection_profile_h profile);
584
585 /**
586  * @brief Sets the default profile which provides the given cellular service, asynchronously.
587  * @since_tizen 2.3
588  * @privlevel public
589  * @privilege %http://tizen.org/privilege/network.profile \n
590  *            %http://tizen.org/privilege/network.get
591  * @remarks This API needs both privileges.
592  * @param[in] connection  The connection handle
593  * @param[in] type  The type of cellular service (only #CONNECTION_CELLULAR_SERVICE_TYPE_INTERNET and #CONNECTION_CELLULAR_SERVICE_TYPE_PREPAID_INTERNET are permitted)
594  * @param[in] profile  The profile handle
595  * @param[in] callback  The callback function to be called
596  * @param[in] user_data The user data passed to the callback function
597  * @return @c 0 on success, otherwise negative error value
598  * @retval #CONNECTION_ERROR_NONE  Successful
599  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
600  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
601  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
602  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not Supported
603  */
604 int connection_set_default_cellular_service_profile_async(connection_h connection,
605                 connection_cellular_service_type_e type, connection_profile_h profile, connection_set_default_cb callback, void* user_data);
606
607 /**
608  * @brief Called after connection_open_profile() is finished.
609  * @since_tizen 2.3
610  * @param[in] result  The result
611  * @param[in] user_data The user data passed from connection_open_profile()
612  * @pre connection_open_profile() will invoke this callback function.
613  * @see connection_open_profile()
614 */
615 typedef void(*connection_opened_cb)(connection_error_e result, void* user_data);
616
617 /**
618  * @brief Called after connection_close_profile() is finished.
619  * @since_tizen 2.3
620  * @param[in] result  The result
621  * @param[in] user_data The user data passed from connection_close_profile()
622  * @pre connection_close_profile() will invoke this callback function.
623  * @see connection_close_profile()
624 */
625 typedef void(*connection_closed_cb)(connection_error_e result, void* user_data);
626
627 /**
628  * @brief Called after connection_reset_profile() is finished.
629  * @since_tizen 2.3
630  * @param[in] result  The result
631  * @param[in] user_data The user data passed from connection_reset_profile()
632  * @pre connection_reset_profile() will invoke this callback function.
633  * @see connection_reset_profile()
634 */
635 typedef void(*connection_reset_cb)(connection_error_e result, void* user_data);
636
637 /**
638  * @brief Opens a connection of profile, asynchronously.
639  * @since_tizen 2.3
640  * @privlevel public
641  * @privilege %http://tizen.org/privilege/network.set \n
642  *            %http://tizen.org/privilege/network.get
643  * @remarks This API needs both privileges.
644  * @param[in] connection  The connection handle
645  * @param[in] profile  The profile handle
646  * @param[in] callback  The callback function to be called
647  * @param[in] user_data The user data passed to the callback function
648  * @return @c 0 on success, otherwise negative error value
649  * @retval #CONNECTION_ERROR_NONE  Successful
650  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
651  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
652  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
653  * @post connection_opened_cb() will be invoked.
654  * @see connection_opened_cb()
655  * @see connection_close_profile()
656  * @see connection_profile_set_state_changed_cb()
657  * @see connection_profile_unset_state_changed_cb()
658  * @see connection_profile_state_changed_cb()
659  */
660 int connection_open_profile(connection_h connection, connection_profile_h profile, connection_opened_cb callback, void* user_data);
661
662 /**
663  * @brief Closes a connection of profile.
664  * @since_tizen 2.3
665  * @privlevel public
666  * @privilege %http://tizen.org/privilege/network.set
667  * @param[in] connection  The connection handle
668  * @param[in] profile  The profile handle
669  * @param[in] callback  The callback function to be called
670  * @param[in] user_data The user data passed to the callback function
671  * @return @c 0 on success, otherwise negative error value
672  * @retval #CONNECTION_ERROR_NONE  Successful
673  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
674  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
675  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
676  * @post connection_closed_cb() will be invoked.
677  * @see connection_closed_cb()
678  * @see connection_open_profile()
679  * @see connection_profile_set_state_changed_cb()
680  * @see connection_profile_unset_state_changed_cb()
681  * @see connection_profile_state_changed_cb()
682  */
683 int connection_close_profile(connection_h connection, connection_profile_h profile, connection_closed_cb callback, void* user_data);
684
685 /**
686  * @brief Resets the cellular profile.
687  * @since_tizen 2.3
688  * @privlevel public
689  * @privilege %http://tizen.org/privilege/network.profile \n
690  *            %http://tizen.org/privilege/network.get
691  * @remarks This API needs both privileges.
692  * @param[in] connection  The connection handle
693  * @param[in] type  The type of reset
694  * @param[in] id  The subscriber identity module id to reset (The sim index starts from 0.)
695  * @param[in] callback  The callback function to be called
696  * @param[in] user_data The user data passed to the callback function
697  * @return 0 on success, otherwise negative error value
698  * @retval #CONNECTION_ERROR_NONE Successful
699  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
700  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
701  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
702  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not Supported
703  * @post connection_reset_cb() will be invoked.
704 */
705 int connection_reset_profile(connection_h connection, connection_reset_option_e type, int id, connection_reset_cb callback, void *user_data);
706
707 /**
708  * @brief Adds a IPv4 route to the routing table.
709  * @details You can get the @a interface_name from connection_profile_get_network_interface_name() of opened profile.
710  * @since_tizen 2.3
711  * @privlevel public
712  * @privilege %http://tizen.org/privilege/network.set
713  * @param[in] connection  The connection handle
714  * @param[in] interface_name  The name of network interface
715  * @param[in] host_address  The IP address of the host
716  * @return @c 0 on success, otherwise negative error value
717  * @retval #CONNECTION_ERROR_NONE  Successful
718  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
719  * @retval #CONNECTION_ERROR_ALREADY_EXISTS  Already exists
720  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
721  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
722  * @see connection_profile_get_network_interface_name()
723  */
724 int connection_add_route(connection_h connection, const char* interface_name, const char* host_address);
725
726 /**
727  * @brief Removes a IPv4 route from the routing table.
728  * @details You can get the @a interface_name from connection_profile_get_network_interface_name() of opened profile.
729  * @since_tizen 2.3
730  * @privlevel public
731  * @privilege %http://tizen.org/privilege/network.set
732  * @param[in] connection  The connection handle
733  * @param[in] interface_name  The name of network interface
734  * @param[in] host_address  The IP address of the host
735  * @return @c 0 on success, otherwise negative error value
736  * @retval #CONNECTION_ERROR_NONE  Successful
737  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
738  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
739  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
740  * @see connection_profile_get_network_interface_name()
741  */
742 int connection_remove_route(connection_h connection, const char* interface_name, const char* host_address);
743
744 /**
745  * @brief Adds a IPv6 route to the routing table.
746  * @details You can get the @a interface_name from connection_profile_get_network_interface_name() of opened profile.
747  * @since_tizen 2.3.1
748  * @privlevel public
749  * @privilege %http://tizen.org/privilege/network.set
750  * @param[in] connection  The connection handle
751  * @param[in] interface_name  The name of network interface
752  * @param[in] host_address  The IP address of the host
753  * @param[in] gateway  The gateway address
754  * @return @c 0 on success, otherwise negative error value
755  * @retval #CONNECTION_ERROR_NONE  Successful
756  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
757  * @retval #CONNECTION_ERROR_ALREADY_EXISTS  Already exists
758  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
759  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
760  * @see connection_profile_get_network_interface_name()
761  */
762 int connection_remove_route(connection_h connection, const char* interface_name, const char* host_address);
763
764 /**
765  * @}
766 */
767
768 /**
769  * @addtogroup CAPI_NETWORK_CONNECTION_STATISTICS_MODULE
770  * @{
771 */
772
773 /**
774  * @brief Gets the statistics information.
775  * @since_tizen 2.3
776  * @privlevel public
777  * @privilege %http://tizen.org/privilege/network.get
778  * @param[in] connection  The connection handle
779  * @param[in] connection_type  The type of connection (only CONNECTION_TYPE_WIFI and CONNECTION_TYPE_CELLULAR are supported)
780  * @param[in] statistics_type  The type of statistics
781  * @param[out] size  The received data size of the last cellular packet data connection (bytes)
782  * @return @c 0 on success, otherwise negative error value
783  * @retval #CONNECTION_ERROR_NONE  Successful
784  * @retval #CONNECTION_ERROR_INVALID_PARAMETER  Invalid parameter
785  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
786  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not Supported
787  */
788 int connection_get_statistics(connection_h connection, connection_type_e connection_type, connection_statistics_type_e statistics_type, long long* size);
789
790 /**
791  * @brief Resets the statistics information.
792  * @since_tizen 2.3
793  * @privlevel public
794  * @privilege %http://tizen.org/privilege/network.set
795  * @remarks This API needs both privileges.
796  * @param[in] connection  The connection handle
797  * @param[in] connection_type  The type of connection (only CONNECTION_TYPE_WIFI and CONNECTION_TYPE_CELLULAR are supported)
798  * @param[in] statistics_type  The type of statistics
799  * @return @c 0 on success, otherwise negative error value
800  * @retval #CONNECTION_ERROR_NONE Successful
801  * @retval #CONNECTION_ERROR_INVALID_PARAMETER   Invalid parameter
802  * @retval #CONNECTION_ERROR_OPERATION_FAILED  Operation failed
803  * @retval #CONNECTION_ERROR_PERMISSION_DENIED Permission Denied
804  * @retval #CONNECTION_ERROR_NOT_SUPPORTED      Not Supported
805  */
806 int connection_reset_statistics(connection_h connection, connection_type_e connection_type, connection_statistics_type_e statistics_type);
807
808 /**
809  * @}
810 */
811
812 #ifdef __cplusplus
813 }
814 #endif /* __cplusplus */
815
816 #endif