3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #ifndef NETWORK_ACCESS_INTERFACE_H_
19 #define NETWORK_ACCESS_INTERFACE_H_
22 #include "network-access/property.h"
23 #include "network-access/status.h"
27 #endif /* __cplusplus */
30 * @file network_access_interface.h
31 * @brief Defines plug-in interfaces about network access
34 /** @addtogroup plugin_networkaccess NetworkAccess Domain
40 * API to open network connection
42 * @param[in] session as returned by sync_agent_plugin_open_connection() - network session information
43 * @param[in] proxy proxy information
44 * @param[in] timeout user preferred time-out seconds used in sending message (ex> 30 means 30seconds)
46 * @return 1 on success, 0 on error
51 * @see sync_agent_open_connection(int, int, unsigned int *), _create_all_session(int)
54 int sync_agent_plugin_open_connection(void **session, char *proxy, int timeout);
57 * API to bind header information for each network protocol
59 * @param[in] header_info header information for each network protocol
60 * @param[in] header_binding as returned by sync_agent_plugin_header_binding() - header information bound each network protocol
62 * @return 1 on success, 0 on error
67 * @see sync_agent_send_msg(GList *, int, char *, unsigned int, GList **, unsigned char **, unsigned int *, sync_agent_na_send_type_e, unsigned int)
70 int sync_agent_plugin_header_binding(GList * header_info, void **header_binding);
73 * API to send message to server and receive message from the server
75 * @param[in] session network session information
76 * @param[in] header_binding as returned by sync_agent_plugin_send_message() - header binding information
77 * @param[in] send_msg body message
78 * @param[in] send_msg_length length of body message
79 * @param[in] recv_msg_size as returned by sync_agent_plugin_send_message() - the size of received message from the server
81 * @return 1 on success, otherwise error
82 * @retval 0 operation failed
83 * @retval -1 cancel message
84 * @retval -8 try again
85 * @retval -408 request timeout
90 * @see sync_agent_send_msg(GList *, int, char *, unsigned int, GList **, unsigned char **, unsigned int *, sync_agent_na_send_type_e, unsigned int)
93 int sync_agent_plugin_send_message(void *session, void **header_binding, char *send_msg, unsigned int send_msg_length, unsigned int *recv_msg_size);
96 * API to divide header/body information using received message from the server
98 * @param[in] msg received message from the server
99 * @param[in] msg_size the size of received message from the server
100 * @param[in] recv_header as returned by sync_agent_plugin_header_unbinding() - header information of received message from the server
101 * @param[in] recv_msg as returned by sync_agent_plugin_header_unbinding() - information of received message from the server
102 * @param[in] recv_msg_length as returned by sync_agent_plugin_header_unbinding() - the length of body information
104 * @return 1 on success, 0 on error
109 * @see sync_agent_send_msg(GList *, int, char *, unsigned int, GList **, unsigned char **, unsigned int *, sync_agent_na_send_type_e, unsigned int)
112 int sync_agent_plugin_header_unbinding(void *msg, unsigned int msg_size, GList ** recv_header, unsigned char **recv_msg, unsigned int *recv_msg_length);
115 * API to close network connection
117 * @param[in] session network session information
119 * @return 1 on success, 0 on error
124 * @see sync_agent_close_connection(int, unsigned int)
127 int sync_agent_plugin_close_connection(void *session);
130 * API to cancel operation about message being sent to the server
132 * @param[in] session network session information
134 * @return 1 on success, 0 on error
139 * @see sync_agent_cancel_msg(int, unsigned int)
142 int sync_agent_plugin_cancel_message(void *session);
145 * API to just send message to the server (do not receive message from the server)
147 * @param[in] session network session information
148 * @param[in] header_binding as returned by sync_agent_plugin_just_send_message() - header binding information
149 * @param[in] send_msg Body message
150 * @param[in] send_msg_length Length of body message
152 * @return 1 on success, 0 on error
157 * @see sync_agent_send_msg(GList *, int, char *, unsigned int, GList **, unsigned char **, unsigned int *, sync_agent_na_send_type_e, unsigned int)
160 int sync_agent_plugin_just_send_message(void *session, void **header_binding, char *send_msg, unsigned int send_msg_length);
163 * API to get network header information about specific keyword
165 * @param[in] header_info list of network header information (key-value pair)
166 * @param[in] key Specific keyword of header information that user want to know
167 * @param[in] value as returned by sync_agent_plugin_get_header_info() - value for the key
169 * @return 1 on success, 0 on error
174 * @see sync_agent_get_header_info(int, GList *, char *, char **)
177 int sync_agent_plugin_get_header_info(GList * header_info, char *key, char **value);
180 * API to set download information(download range) to download header information of specific network protocol
182 * @param[in] down_info download header information of specific network protocol
183 * @param[in] current_down_range download current range
185 * @return 1 on success, 0 on error
190 * @see na_download_data(GList *header_info, int, unsigned char *, unsigned int, unsigned int, unsigned char **, sync_agent_na_send_type_e, unsigned int)
193 int sync_agent_plugin_set_data_download_info(void *down_info, char *current_down_range);
196 * API to get download information(download range, filename) to download header information of specific network protocol
198 * @param[in] http_req_info http request information
199 * @param[in] down_info download header information of specific network protocol
200 * @param[in] total_down_size as returned by sync_agent_plugin_get_data_download_info() - total download size
201 * @param[in] current_down_range as returned by sync_agent_plugin_get_data_download_info() - current download range
202 * @param[in] down_file_name as returned by sync_agent_plugin_get_data_download_info() - download file name
204 * @return 1 on success, 0 on error
209 * @see na_download_data(GList *header_info, int, unsigned char *, unsigned int, unsigned int, unsigned char **, sync_agent_na_send_type_e, unsigned int)
212 int sync_agent_plugin_get_data_download_info(void *http_req_info, void *down_info, int *total_down_size, char **current_down_range, char **down_file_name);
215 * API to add user authentication information (id, password) to session and
216 * register authentication callback for 'authenticate' signal
218 * @param[in] session network session information
219 * @param[in] id user id
220 * @param[in] password user password
222 * @return 1 on success, 0 on error
227 * @see sync_agent_add_authentication_info(int, char *, char *, unsigned int)
230 int sync_agent_plugin_add_authentication_info(void *session, char *id, char *password);
233 * API to connect service and register to the sync-agent-framework mainloop for data connection
235 * @param[in] data user data (meaningless value)
240 * @see na_init_network_access(int)
243 void sync_agent_plugin_register_fw_main_loop_network_access(void *data);
246 * API to set network communication property
248 * @param[in] session network session information
249 * @param[in] property network communication property (time out, retry count, ...)
250 * @param[in] va property value
252 * @return 1 on success, 0 on error
257 * @see na_set_property(int, unsigned int, sync_agent_na_property_e, ...)
260 int sync_agent_plugin_set_property(void *session, sync_agent_na_property_e property, va_list va);
263 * API to get network communication status
265 * @param[in] session network session information
266 * @param[in] status network communication status (response code, elapsed time, connection time, ...)
267 * @param[in] va status value
269 * @return 1 on success, 0 on error
274 * @see sync_agent_get_status(int, unsigned int, sync_agent_na_status_e, ...)
277 int sync_agent_plugin_get_status(void *session, sync_agent_na_status_e status, va_list va);
285 #endif /* __cplusplus */
286 #endif /* NETWORK_ACCESS_INTERFACE_H_ */