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