2 * This file is part of Sharing Application Library
4 * Copyright (C) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
6 * Contact: Alexander Bokovoy <alexander.bokovoy@nokia.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * version 2.1 as published by the Free Software Foundation.
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 #ifndef _SHARING_HTTP_H_
25 #define _SHARING_HTTP_H_
28 #include <conicconnection.h>
32 typedef struct SharingHTTP SharingHTTP;
35 * SharingHTTPProgressCallback:
36 * @http: Pointer to #SharingHTTP object calling
37 * @bytes_sent: How many bytes is sent
38 * @user_data: User data pointer
40 * Progress callback function prototype for #SharingHTTP
42 * Returns: %TRUE to continue, %FALSE to cancel transfer
44 typedef gboolean (*SharingHTTPProgressCallback) (SharingHTTP * http,
45 guint64 bytes_sent, gpointer user_data);
49 * SharingHTTPRunResponse:
50 * @SHARING_HTTP_RUNRES_SUCCESS: Run was a success.
51 * @SHARING_HTTP_RUNRES_UNKNOWN_FAILURE: Unknown failure.
52 * @SHARING_HTTP_RUNRES_INVALID_PARAMETERS: Invalid parameters given.
53 * @SHARING_HTTP_RUNRES_CONNECTION_PROBLEM: Couldn't get connection to URL.
54 * @SHARING_HTTP_RUNRES_CANCELLED: Run was cancelled by callback.
55 * @SHARING_HTTP_RUNRES_ALREADY_RUNNING: There is already active process
58 * Response codes for sharing_http_run()
61 SHARING_HTTP_RUNRES_SUCCESS,
62 SHARING_HTTP_RUNRES_UNKNOWN_FAILURE,
63 SHARING_HTTP_RUNRES_INVALID_PARAMETERS,
64 SHARING_HTTP_RUNRES_CONNECTION_PROBLEM,
65 SHARING_HTTP_RUNRES_CANCELLED,
66 SHARING_HTTP_RUNRES_ALREADY_RUNNING
67 } SharingHTTPRunResponse;
69 SharingHTTP * sharing_http_new();
71 gint sharing_http_ref (SharingHTTP * self);
72 gint sharing_http_unref (SharingHTTP * self);
74 void sharing_http_set_connection (SharingHTTP * self,
75 ConIcConnection * connection);
76 ConIcConnection * sharing_http_get_connection (SharingHTTP * self);
78 void sharing_http_set_timeouts (SharingHTTP * self, glong connecting_timeout,
79 glong connection_timeout);
81 void sharing_http_set_progress_callback (SharingHTTP * self,
82 SharingHTTPProgressCallback callback, gpointer user_data);
84 SharingHTTPRunResponse sharing_http_run (SharingHTTP * self, const gchar * url);
86 void sharing_http_cancel (SharingHTTP * self);
88 gboolean sharing_http_add_req_header (SharingHTTP * self, const gchar * name,
90 gboolean sharing_http_add_req_header_line (SharingHTTP * self,
92 void sharing_http_remove_req_headers (SharingHTTP * self);
94 gboolean sharing_http_add_req_multipart_file (SharingHTTP * self,
95 const gchar * name, const gchar * filepath, const gchar * type);
97 gboolean sharing_http_add_req_multipart_file_with_filename (SharingHTTP * self,
98 const gchar * name, const gchar * filepath, const gchar * type,
99 const gchar * filename);
101 gboolean sharing_http_add_req_multipart_data (SharingHTTP * self,
102 const gchar * name, const gchar * data, gint data_len, const gchar * type);
104 void sharing_http_clear_multiparts (SharingHTTP * self);
106 void sharing_http_set_res_buffer_size_limit (SharingHTTP * self, gsize limit);
107 gsize sharing_http_get_res_buffer_size_limit (SharingHTTP * self);
109 gint sharing_http_get_res_code (SharingHTTP * self);
110 const gchar * sharing_http_get_res_content (SharingHTTP * self, gsize * len);
111 const gchar * sharing_http_get_res_body (SharingHTTP * self, gsize * len);
113 void sharing_http_set_user_agent_name (SharingHTTP * self,
118 #endif /* #ifndef _SHARING_HTTP_H_ */