/pidgin/main: ca831f1dd5a6: HTTP: remove old API
Tomasz Wasilczyk
tomkiewicz at cpw.pidgin.im
Fri Jul 5 09:04:29 EDT 2013
Changeset: ca831f1dd5a67fac4084ea8a854c87756e899407
Author: Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date: 2013-07-05 15:04 +0200
Branch: default
URL: https://hg.pidgin.im/pidgin/main/rev/ca831f1dd5a6
Description:
HTTP: remove old API
diffstat:
libpurple/Makefile.am | 2 -
libpurple/obsolete.c | 909 --------------------------------------------------
libpurple/obsolete.h | 111 ------
libpurple/proxy.c | 1 -
4 files changed, 0 insertions(+), 1023 deletions(-)
diffs (truncated from 1060 to 300 lines):
diff --git a/libpurple/Makefile.am b/libpurple/Makefile.am
--- a/libpurple/Makefile.am
+++ b/libpurple/Makefile.am
@@ -69,7 +69,6 @@ purple_coresources = \
network.c \
ntlm.c \
notify.c \
- obsolete.c \
plugin.c \
pluginpref.c \
pounce.c \
@@ -290,7 +289,6 @@ libpurple_la_SOURCES = \
noinst_HEADERS= \
internal.h \
- obsolete.h \
media/backend-fs2.h \
valgrind.h
diff --git a/libpurple/obsolete.c b/libpurple/obsolete.c
deleted file mode 100644
--- a/libpurple/obsolete.c
+++ /dev/null
@@ -1,909 +0,0 @@
-/* purple
- *
- * Purple is the legal property of its developers, whose names are too numerous
- * to list here. Please refer to the COPYRIGHT file distributed with this
- * source distribution.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
- */
-
-#include "obsolete.h"
-
-#include "internal.h"
-#include "debug.h"
-#include "ntlm.h"
-
-#if 0
-#include "http.h"
-#endif
-
-struct _PurpleUtilFetchUrlData
-{
- PurpleUtilFetchUrlCallback callback;
- void *user_data;
-
- struct
- {
- char *user;
- char *passwd;
- char *address;
- int port;
- char *page;
-
- } website;
-
- char *url;
- int num_times_redirected;
- gboolean full;
- char *user_agent;
- gboolean http11;
- char *request;
- gsize request_written;
- gboolean include_headers;
-
- gboolean is_ssl;
- PurpleSslConnection *ssl_connection;
- PurpleProxyConnectData *connect_data;
- int fd;
- guint inpa;
-
- gboolean got_headers;
- gboolean has_explicit_data_len;
- char *webdata;
- gsize len;
- unsigned long data_len;
- gssize max_len;
- gboolean chunked;
- PurpleAccount *account;
-
-#if 0
- PurpleHttpConnection *wrapped_request;
-#endif
- gboolean cancelled;
-};
-
-/**
- * Parses a URL, returning its host, port, file path, username and password.
- *
- * The returned data must be freed.
- *
- * @param url The URL to parse.
- * @param ret_host The returned host.
- * @param ret_port The returned port.
- * @param ret_path The returned path.
- * @param ret_user The returned username.
- * @param ret_passwd The returned password.
- */
-static gboolean purple_url_parse(const char *url, char **ret_host, int *ret_port,
- char **ret_path, char **ret_user, char **ret_passwd);
-
-#if 0
-
-typedef struct
-{
- PurpleUtilFetchUrlData *url_data;
- PurpleUtilFetchUrlCallback cb;
- gpointer user_data;
-} PurpleUtilLegacyWrapData;
-
-static void purple_util_fetch_url_cb(PurpleHttpConnection *http_conn,
- PurpleHttpResponse *response, gpointer _wrap_data)
-{
- PurpleUtilLegacyWrapData *wrap_data = _wrap_data;
- const char *data = NULL;
- size_t len;
-
- if (wrap_data->cb && !wrap_data->url_data->cancelled) {
- data = purple_http_response_get_data(response, &len);
-
- wrap_data->cb(wrap_data->url_data, wrap_data->user_data, data, len,
- purple_http_response_get_error(response));
- }
-
- g_free(wrap_data->url_data);
- g_free(wrap_data);
-}
-
-PurpleUtilFetchUrlData * purple_util_fetch_url(const gchar *url, gboolean full,
- const gchar *user_agent, gboolean http11, gssize max_len,
- PurpleUtilFetchUrlCallback cb, gpointer data)
-{
- PurpleHttpRequest *request;
- PurpleUtilFetchUrlData *url_data;
- PurpleUtilLegacyWrapData *wrap_data;
-
- if (FALSE)
- return purple_util_fetch_url_request(NULL, url, full,
- user_agent, http11, NULL, FALSE, max_len, cb, data);
-
- wrap_data = g_new0(PurpleUtilLegacyWrapData, 1);
- url_data = g_new0(PurpleUtilFetchUrlData, 1);
- request = purple_http_request_new(url);
-
- wrap_data->url_data = url_data;
- wrap_data->cb = cb;
- wrap_data->user_data = data;
-
- if (user_agent)
- purple_http_request_header_set(request,
- "User-Agent", user_agent);
- purple_http_request_set_http11(request, http11);
- purple_http_request_set_max_len(request, max_len);
-
- url_data->wrapped_request = purple_http_request(NULL, request,
- purple_util_fetch_url_cb, wrap_data);
-
- purple_http_request_unref(request);
-
- return url_data;
-}
-
-#endif
-
-/**
- * The arguments to this function are similar to printf.
- */
-static void
-purple_util_fetch_url_error(PurpleUtilFetchUrlData *gfud, const char *format, ...)
-{
- gchar *error_message;
- va_list args;
-
- va_start(args, format);
- error_message = g_strdup_vprintf(format, args);
- va_end(args);
-
- gfud->callback(gfud, gfud->user_data, NULL, 0, error_message);
- g_free(error_message);
- purple_util_fetch_url_cancel(gfud);
-}
-
-static void url_fetch_connect_cb(gpointer url_data, gint source, const gchar *error_message);
-static void ssl_url_fetch_connect_cb(gpointer data, PurpleSslConnection *ssl_connection, PurpleInputCondition cond);
-static void ssl_url_fetch_error_cb(PurpleSslConnection *ssl_connection, PurpleSslErrorType error, gpointer data);
-
-static gboolean
-parse_redirect(const char *data, size_t data_len,
- PurpleUtilFetchUrlData *gfud)
-{
- gchar *s;
- gchar *new_url, *temp_url, *end;
- gboolean full;
- int len;
-
- if ((s = g_strstr_len(data, data_len, "\nLocation: ")) == NULL)
- /* We're not being redirected */
- return FALSE;
-
- s += strlen("Location: ");
- end = strchr(s, '\r');
-
- /* Just in case :) */
- if (end == NULL)
- end = strchr(s, '\n');
-
- if (end == NULL)
- return FALSE;
-
- len = end - s;
-
- new_url = g_malloc(len + 1);
- strncpy(new_url, s, len);
- new_url[len] = '\0';
-
- full = gfud->full;
-
- if (*new_url == '/' || g_strstr_len(new_url, len, "://") == NULL)
- {
- temp_url = new_url;
-
- new_url = g_strdup_printf("%s:%d%s", gfud->website.address,
- gfud->website.port, temp_url);
-
- g_free(temp_url);
-
- full = FALSE;
- }
-
- purple_debug_info("util", "Redirecting to %s\n", new_url);
-
- gfud->num_times_redirected++;
- if (gfud->num_times_redirected >= 5)
- {
- purple_util_fetch_url_error(gfud,
- _("Could not open %s: Redirected too many times"),
- gfud->url);
- return TRUE;
- }
-
- /*
- * Try again, with this new location. This code is somewhat
- * ugly, but we need to reuse the gfud because whoever called
- * us is holding a reference to it.
- */
- g_free(gfud->url);
- gfud->url = new_url;
- gfud->full = full;
- g_free(gfud->request);
- gfud->request = NULL;
-
- if (gfud->is_ssl) {
- gfud->is_ssl = FALSE;
- purple_ssl_close(gfud->ssl_connection);
- gfud->ssl_connection = NULL;
- } else {
- purple_input_remove(gfud->inpa);
- gfud->inpa = 0;
- close(gfud->fd);
- gfud->fd = -1;
- }
- gfud->request_written = 0;
- gfud->len = 0;
- gfud->data_len = 0;
-
- g_free(gfud->website.user);
- g_free(gfud->website.passwd);
- g_free(gfud->website.address);
- g_free(gfud->website.page);
- purple_url_parse(new_url, &gfud->website.address, &gfud->website.port,
- &gfud->website.page, &gfud->website.user, &gfud->website.passwd);
-
- if (purple_strcasestr(new_url, "https://") != NULL) {
- gfud->is_ssl = TRUE;
- gfud->ssl_connection = purple_ssl_connect(gfud->account,
- gfud->website.address, gfud->website.port,
- ssl_url_fetch_connect_cb, ssl_url_fetch_error_cb, gfud);
- } else {
- gfud->connect_data = purple_proxy_connect(NULL, gfud->account,
- gfud->website.address, gfud->website.port,
- url_fetch_connect_cb, gfud);
- }
-
- if (gfud->ssl_connection == NULL && gfud->connect_data == NULL)
- {
- purple_util_fetch_url_error(gfud, _("Unable to connect to %s"),
More information about the Commits
mailing list