3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #ifndef PURPLE_FACEBOOK_HTTP_H
23 #define PURPLE_FACEBOOK_HTTP_H
27 * @section_id: facebook-http
28 * @short_description: <filename>http.h</filename>
29 * @title: HTTP Utilities
36 #include <libpurple/http.h>
41 * The #GQuark of the domain of HTTP errors.
43 #define FB_HTTP_ERROR fb_http_error_quark()
48 * Represents a set of #PurpleHttpConnection.
50 typedef struct _FbHttpConns FbHttpConns
;
55 * Represents a set of key/value HTTP parameters.
57 typedef GHashTable FbHttpParams
;
61 * @FB_HTTP_ERROR_SUCCESS: There is no error.
62 * @FB_HTTP_ERROR_NOMATCH: The name does not match anything.
64 * The error codes for the #FB_HTTP_ERROR domain.
68 FB_HTTP_ERROR_SUCCESS
= 0,
73 * fb_http_error_quark:
75 * Gets the #GQuark of the domain of HTTP errors.
77 * Returns: The #GQuark of the domain.
80 fb_http_error_quark(void);
85 * Creates a new #FbHttpConns. The returned #FbHttpConns should be
86 * freed with #fb_http_conns_free() when no longer needed.
88 * Returns: The new #FbHttpConns.
91 fb_http_conns_new(void);
95 * @cons: The #FbHttpConns.
97 * Frees all memory used by the #FbHttpConns. This will *not* cancel
98 * the any of the added #PurpleHttpConnection.
101 fb_http_conns_free(FbHttpConns
*cons
);
104 * fb_http_conns_cancel_all:
105 * @cons: The #FbHttpConns.
107 * Cancels each #PurpleHttpConnection in the #FbHttpConns.
110 fb_http_conns_cancel_all(FbHttpConns
*cons
);
113 * fb_http_conns_is_canceled:
114 * @cons: The #FbHttpConns.
116 * Determines if the #FbHttpConns has been canceled.
118 * Returns: #TRUE if it has been canceled, otherwise #FALSE.
121 fb_http_conns_is_canceled(FbHttpConns
*cons
);
125 * @cons: The #FbHttpConns.
126 * @con: The #PurpleHttpConnection.
128 * Adds a #PurpleHttpConnection to the #FbHttpConns.
131 fb_http_conns_add(FbHttpConns
*cons
, PurpleHttpConnection
*con
);
134 * fb_http_conns_remove:
135 * @cons: The #FbHttpConns.
136 * @con: The #PurpleHttpConnection.
138 * Removes a #PurpleHttpConnection from the #FbHttpConns.
141 fb_http_conns_remove(FbHttpConns
*cons
, PurpleHttpConnection
*con
);
144 * fb_http_conns_reset:
145 * @cons: The #FbHttpConns.
147 * Resets the #FbHttpConns. This removes each #PurpleHttpConnection
148 * from the #FbHttpConns *without* canceling it. This allows the the
149 * #FbHttpConns to be reused.
152 fb_http_conns_reset(FbHttpConns
*cons
);
156 * @res: The #PurpleHttpResponse.
157 * @error: The return location for the #GError or #NULL.
159 * Checks a #PurpleHttpResponse for success. This optionally assigns an
160 * appropriate #GError upon failure.
162 * Returns: #TRUE if the request was successful, otherwise #FALSE.
165 fb_http_error_chk(PurpleHttpResponse
*res
, GError
**error
);
168 * fb_http_params_new:
170 * Creates a new #FbHttpParams. The returned #FbHttpParams should be
171 * freed with #fb_http_params_free() when no longer needed. Optionally,
172 * instead of freeing, the returned #FbHttpParams can be closed with
173 * #fb_http_params_close().
175 * Returns: The new #FbHttpParams.
178 fb_http_params_new(void);
181 * fb_http_params_new_parse:
182 * @data: The string containing HTTP parameters.
183 * @isurl: #TRUE if @data is a URL, otherwise #FALSE.
185 * Creates a new #FbHttpParams. This parses the #FbHttpParams from a
186 * string, which can be a URL. The returned #FbHttpParams should be
187 * freed with #fb_http_params_free() when no longer needed. Optionally,
188 * instead of freeing, the returned #FbHttpParams can be closed with
189 * #fb_http_params_close().
191 * Returns: The new #FbHttpParams.
194 fb_http_params_new_parse(const gchar
*data
, gboolean isurl
);
197 * fb_http_params_free:
198 * @params: The #FbHttpParams.
200 * Frees all memory used by the #FbHttpParams.
203 fb_http_params_free(FbHttpParams
*params
);
206 * fb_http_params_close:
207 * @params: The #FbHttpParams.
208 * @url: The URL or #NULL.
210 * Closes the #FbHttpParams by returning a string representing the HTTP
211 * parameters. If @url is non-#NULL, then the parameters are appended
212 * to the value of @url. This frees the #FbHttpParams. The returned
213 * string should be freed with #g_free() when no longer needed.
215 * Returns: The string representation of the HTTP parameters.
218 fb_http_params_close(FbHttpParams
*params
, const gchar
*url
);
221 * fb_http_params_get_bool:
222 * @params: The #FbHttpParams.
223 * @name: The parameter name.
224 * @error: The return location for the #GError or #NULL.
226 * Gets a boolean value from the #FbHttpParams. This optionally assigns
227 * an appropriate #GError upon failure.
229 * Return: The boolean value.
232 fb_http_params_get_bool(FbHttpParams
*params
, const gchar
*name
,
236 * fb_http_params_get_dbl:
237 * @params: The #FbHttpParams.
238 * @name: The parameter name.
239 * @error: The return location for the #GError or #NULL.
241 * Gets a floating point value from the #FbHttpParams. This optionally
242 * assigns an appropriate #GError upon failure.
244 * Return: The floating point value.
247 fb_http_params_get_dbl(FbHttpParams
*params
, const gchar
*name
,
251 * fb_http_params_get_int:
252 * @params: The #FbHttpParams.
253 * @name: The parameter name.
254 * @error: The return location for the #GError or #NULL.
256 * Gets an integer value from the #FbHttpParams. This optionally
257 * assigns an appropriate #GError upon failure.
259 * Return: The integer value.
262 fb_http_params_get_int(FbHttpParams
*params
, const gchar
*name
,
266 * fb_http_params_get_str:
267 * @params: The #FbHttpParams.
268 * @name: The parameter name.
269 * @error: The return location for the #GError or #NULL.
271 * Gets a string value from the #FbHttpParams. This optionally assigns
272 * an appropriate #GError upon failure.
274 * Return: The string value.
277 fb_http_params_get_str(FbHttpParams
*params
, const gchar
*name
,
281 * fb_http_params_dup_str:
282 * @params: The #FbHttpParams.
283 * @name: The parameter name.
284 * @error: The return location for the #GError or #NULL.
286 * Gets a duplicated string value from the #FbHttpParams. This
287 * optionally assigns an appropriate #GError upon failure. The returned
288 * string should be freed with #g_free() when no longer needed.
290 * Return: The duplicated string value.
293 fb_http_params_dup_str(FbHttpParams
*params
, const gchar
*name
,
297 * fb_http_params_set_bool:
298 * @params: The #FbHttpParams.
299 * @name: The parameter name.
302 * Sets a boolean value to the #FbHttpParams.
305 fb_http_params_set_bool(FbHttpParams
*params
, const gchar
*name
,
309 * fb_http_params_set_dbl:
310 * @params: The #FbHttpParams.
311 * @name: The parameter name.
314 * Sets a floating point value to the #FbHttpParams.
317 fb_http_params_set_dbl(FbHttpParams
*params
, const gchar
*name
, gdouble value
);
320 * fb_http_params_set_int:
321 * @params: The #FbHttpParams.
322 * @name: The parameter name.
325 * Sets an integer value to the #FbHttpParams.
328 fb_http_params_set_int(FbHttpParams
*params
, const gchar
*name
, gint64 value
);
331 * fb_http_params_set_str:
332 * @params: The #FbHttpParams.
333 * @name: The parameter name.
336 * Sets a string value to the #FbHttpParams.
339 fb_http_params_set_str(FbHttpParams
*params
, const gchar
*name
,
343 * fb_http_params_set_strf:
344 * @params: The #FbHttpParams.
345 * @name: The parameter name.
346 * @format: The format string literal.
347 * @...: The arguments for @format.
349 * Sets a formatted string value to the #FbHttpParams.
352 fb_http_params_set_strf(FbHttpParams
*params
, const gchar
*name
,
353 const gchar
*format
, ...)
358 * @url1: The first URL.
359 * @url2: The second URL.
360 * @protocol: #TRUE to match the protocols, otherwise #FALSE.
362 * Compares two URLs. This is more reliable than just comparing two URL
363 * strings, as it avoids casing in some areas, while not in others. It
364 * can also, optionally, ignore the matching of the URL protocol.
366 * Returns: #TRUE if the URLs match, otherwise #FALSE.
369 fb_http_urlcmp(const gchar
*url1
, const gchar
*url2
, gboolean protocol
);
371 #endif /* PURPLE_FACEBOOK_HTTP_H */