comparison libgaim/util.h @ 14354:01daacf7b771

[gaim-migrate @ 17060] Make gaim_url_fetch() cancelable and change Yahoo! to take advantage of the changes. Other stuff can be changed later, the important thing is that the API is there. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 27 Aug 2006 21:13:30 +0000
parents 60b1bc8dbf37
children e0a93e6fa98b
comparison
equal deleted inserted replaced
14353:33dc9f22b528 14354:01daacf7b771
34 #include "xmlnode.h" 34 #include "xmlnode.h"
35 35
36 #ifdef __cplusplus 36 #ifdef __cplusplus
37 extern "C" { 37 extern "C" {
38 #endif 38 #endif
39
40 typedef struct _GaimUtilFetchUrlData GaimUtilFetchUrlData;
39 41
40 typedef struct _GaimMenuAction 42 typedef struct _GaimMenuAction
41 { 43 {
42 char *label; 44 char *label;
43 GaimCallback callback; 45 GaimCallback callback;
821 * @param ret_passwd The returned password. 823 * @param ret_passwd The returned password.
822 */ 824 */
823 gboolean gaim_url_parse(const char *url, char **ret_host, int *ret_port, 825 gboolean gaim_url_parse(const char *url, char **ret_host, int *ret_port,
824 char **ret_path, char **ret_user, char **ret_passwd); 826 char **ret_path, char **ret_user, char **ret_passwd);
825 827
826 typedef void (*GaimURLFetchCallback) (gpointer data, const char *buf, gsize len); 828 /**
829 * This is the signature used for functions that act as the callback
830 * to gaim_util_fetch_url() or gaim_util_fetch_url_request().
831 *
832 * @param url_data The same value that was returned when you called
833 * gaim_fetch_url() or gaim_fetch_url_request().
834 * @param user_data The user data that your code passed into either
835 * gaim_util_fetch_url() or gaim_util_fetch_url_request().
836 * @param url_text This will be NULL on error. Otherwise this
837 * will contain the contents of the URL.
838 * @param len 0 on error, otherwise this is the length of buf.
839 * @param error_message If something went wrong then this will contain
840 * a descriptive error message, and buf will be
841 * NULL and len will be 0.
842 */
843 typedef void (*GaimUtilFetchUrlCallback)(GaimUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, gsize len, const gchar *error_message);
827 844
828 /** 845 /**
829 * Fetches the data from a URL, and passes it to a callback function. 846 * Fetches the data from a URL, and passes it to a callback function.
830 * 847 *
831 * @param url The URL. 848 * @param url The URL.
834 * @param user_agent The user agent field to use, or NULL. 851 * @param user_agent The user agent field to use, or NULL.
835 * @param http11 TRUE if HTTP/1.1 should be used to download the file. 852 * @param http11 TRUE if HTTP/1.1 should be used to download the file.
836 * @param cb The callback function. 853 * @param cb The callback function.
837 * @param data The user data to pass to the callback function. 854 * @param data The user data to pass to the callback function.
838 */ 855 */
839 #define gaim_url_fetch(url, full, user_agent, http11, cb, data) \ 856 #define gaim_util_fetch_url(url, full, user_agent, http11, cb, data) \
840 gaim_url_fetch_request(url, full, user_agent, http11, NULL, \ 857 gaim_util_fetch_url_request(url, full, user_agent, http11, NULL, \
841 FALSE, cb, data); 858 FALSE, cb, data);
842 859
843 /** 860 /**
844 * Fetches the data from a URL, and passes it to a callback function. 861 * Fetches the data from a URL, and passes it to a callback function.
845 * 862 *
848 * partial URL. 865 * partial URL.
849 * @param user_agent The user agent field to use, or NULL. 866 * @param user_agent The user agent field to use, or NULL.
850 * @param http11 TRUE if HTTP/1.1 should be used to download the file. 867 * @param http11 TRUE if HTTP/1.1 should be used to download the file.
851 * @param request A HTTP request to send to the server instead of the 868 * @param request A HTTP request to send to the server instead of the
852 * standard GET 869 * standard GET
853 * @param include_headers if TRUE, include the HTTP headers in the 870 * @param include_headers
854 * response 871 * If TRUE, include the HTTP headers in the response.
855 * @param cb The callback function. 872 * @param callback The callback function.
856 * @param data The user data to pass to the callback function. 873 * @param data The user data to pass to the callback function.
857 */ 874 */
858 void gaim_url_fetch_request(const char *url, gboolean full, 875 GaimUtilFetchUrlData *gaim_util_fetch_url_request(const gchar *url,
859 const char *user_agent, gboolean http11, 876 gboolean full, const gchar *user_agent, gboolean http11,
860 const char *request, gboolean include_headers, 877 const gchar *request, gboolean include_headers,
861 GaimURLFetchCallback cb, void *data); 878 GaimUtilFetchUrlCallback callback, gpointer data);
879
880 /**
881 * Cancel a pending URL request started with either
882 * gaim_util_fetch_url_request() or gaim_util_fetch_url().
883 *
884 * @param url_data The data returned when you initiated the URL fetch.
885 */
886 void gaim_util_fetch_url_cancel(GaimUtilFetchUrlData *url_data);
862 887
863 /** 888 /**
864 * Decodes a URL into a plain string. 889 * Decodes a URL into a plain string.
865 * 890 *
866 * This will change hex codes and such to their ascii equivalents. 891 * This will change hex codes and such to their ascii equivalents.