/cpw/tomkiewicz/http: f36899d03630: Cleaning up

Tomasz Wasilczyk tomkiewicz at cpw.pidgin.im
Sat Oct 20 09:11:44 EDT 2012


Changeset: f36899d03630f232b0a488554e2b77e2d7cf4bdd
Author:	 Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date:	 2012-10-20 15:11 +0200
Branch:	 default
URL: http://hg.pidgin.im/cpw/tomkiewicz/http/rev/f36899d03630

Description:

Cleaning up

diffstat:

 libpurple/http.c                   |    4 +-
 libpurple/protocols/gg/Makefile.am |    7 +-
 libpurple/protocols/gg/gg.c        |  387 -------------------------------------
 3 files changed, 5 insertions(+), 393 deletions(-)

diffs (truncated from 466 to 300 lines):

diff --git a/libpurple/http.c b/libpurple/http.c
--- a/libpurple/http.c
+++ b/libpurple/http.c
@@ -138,6 +138,8 @@ struct _PurpleHttpCookieJar
 	GHashTable *tab;
 };
 
+static time_t purple_http_rfc1123_to_time(const gchar *str);
+
 static PurpleHttpConnection * purple_http_connection_new(
 	PurpleHttpRequest *request, PurpleConnection *gc);
 static void purple_http_connection_terminate(PurpleHttpConnection *hc);
@@ -178,8 +180,6 @@ static GHashTable *purple_http_hc_by_ptr
 
 /*** Helper functions *********************************************************/
 
-static time_t purple_http_rfc1123_to_time(const gchar *str);
-
 static time_t purple_http_rfc1123_to_time(const gchar *str)
 {
 	static const gchar *months[13] = {"jan", "feb", "mar", "apr", "may", "jun",
diff --git a/libpurple/protocols/gg/Makefile.am b/libpurple/protocols/gg/Makefile.am
--- a/libpurple/protocols/gg/Makefile.am
+++ b/libpurple/protocols/gg/Makefile.am
@@ -1,4 +1,4 @@
-V=1
+#V=0
 #GADU_EXTRA_WARNINGS = -Wall -Wextra -Werror
 
 pkgdir = $(libdir)/purple-$(PURPLE_MAJOR_VERSION)
@@ -106,14 +106,14 @@ st = -DPURPLE_STATIC_PRPL $(GADU_CFLAGS)
 noinst_LTLIBRARIES = libgg.la
 libgg_la_SOURCES = $(GGSOURCES)
 libgg_la_CFLAGS  = $(AM_CFLAGS)
-libgg_la_LIBADD  = $(GADU_LIBS) $(JSON_LIBS)
+libgg_la_LIBADD  = $(GADU_LIBS)
 
 else
 
 st = $(GADU_CFLAGS)
 pkg_LTLIBRARIES = libgg.la
 libgg_la_SOURCES = $(GGSOURCES)
-libgg_la_LIBADD  = $(GLIB_LIBS) $(JSON_LIBS) $(GADU_LIBS)
+libgg_la_LIBADD  = $(GLIB_LIBS) $(GADU_LIBS)
 
 endif
 
@@ -121,7 +121,6 @@ AM_CPPFLAGS = \
 	$(GADU_EXTRA_WARNINGS) \
 	-I$(top_srcdir)/libpurple \
 	-I$(top_builddir)/libpurple \
-	$(JSON_CFLAGS)
 	$(INTGG_CFLAGS) \
 	$(GLIB_CFLAGS) \
 	$(DEBUG_CFLAGS)
diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c
--- a/libpurple/protocols/gg/gg.c
+++ b/libpurple/protocols/gg/gg.c
@@ -55,383 +55,6 @@
 
 /* ---------------------------------------------------------------------- */
 
-#include <http.h>
-#include <obsolete.h>
-#include <json-glib/json-glib.h>
-
-static gchar *ggp_imtoken = NULL;
-
-/*
-static void ggp_file_transfer_test_signedin(PurpleHttpConnection *http_conn,
-	PurpleHttpResponse *response, gpointer user_data)
-{
-	const gchar *data;
-	gchar *data_front, *data_tail;
-
-	purple_debug_info("gg-test", "Results: %d (code: %d)\n",
-		purple_http_response_is_successfull(response),
-		purple_http_response_get_code(response));
-
-	if (purple_http_response_get_error(response))
-		purple_debug_info("gg-test", "Returned error: %s.\n",
-			purple_http_response_get_error(response));
-
-	data = purple_http_response_get_data(response);
-	if (strlen(data) < 200)
-		purple_debug_info("gg-test", "Returned content: [%s].\n", data);
-	else {
-		data_front = g_strndup(data, 100);
-		data_tail = g_strdup(data + strlen(data) - 100);
-		purple_debug_info("gg-test", "Returned content: [%s ... %s].\n",
-			data_front, data_tail);
-		g_free(data_front);
-		g_free(data_tail);
-	}
-}
-*/
-
-uin_t ggp_file_transfer_test_recipient = 38522810;
-const gchar *ggp_file_transfer_test_filename = "plik.txt";
-const gchar *ggp_file_transfer_test_file = "ala ma kota";
-
-gchar *ggp_file_transfer_ticket = NULL;
-gchar *ggp_file_transfer_security_token = NULL;
-PurpleHttpCookieJar *ggp_file_transfer_cookie = NULL;
-
-static void ggp_file_transfer_test_sent(PurpleHttpConnection *http_conn,
-	PurpleHttpResponse *response, gpointer user_data)
-{
-	purple_debug_info("gg-test", "offered: %s\n",
-		purple_http_response_get_data(response));
-
-	if (!purple_http_response_is_successfull(response))
-	{
-		purple_debug_error("gg-test", "offer failed\n");
-		return;
-	}
-}
-
-static void ggp_event_json_edisc_ticket_changed(PurpleConnection *gc, const gchar *data)
-{
-	JsonNode *n;
-	JsonParser *parser;
-	JsonObject *change;
-	int i, len;
-	gboolean is_allowed, is_good_ticket;
-	PurpleHttpRequest *req;
-	gchar *upload_url;
-
-	purple_debug_info("gg", "edisc: %s\n", data);
-
-	parser = json_parser_new();
-	if (!json_parser_load_from_data(parser, data, -1, NULL)) {
-		g_object_unref(parser);
-		purple_debug_error("gg", "invalid JSON\n");
-		return;
-	}
-
-	change = json_node_get_object(json_parser_get_root(parser));
-	purple_debug_info("gg", "edisc ticket change: id=[%s] ack_status=[%s] send_status=[%s]\n",
-		json_object_get_string_member(change, "id"),
-		json_object_get_string_member(change, "ack_status"),
-		json_object_get_string_member(change, "send_status"));
-
-	is_allowed = (0 == g_strcmp0("allowed", json_object_get_string_member(
-		change, "ack_status")));
-	is_good_ticket = (0 == g_strcmp0(ggp_file_transfer_ticket,
-		json_object_get_string_member(change, "id")));
-
-	g_object_unref(parser);
-
-	if (!is_allowed || !is_good_ticket) {
-		purple_debug_warning("http", "invalid ticket\n");
-		return;
-	}
-
-	upload_url = g_strdup_printf("https://drive.mpa.gg.pl/me/file/outbox/%s%%2C%s",
-		ggp_file_transfer_ticket,
-		purple_url_encode(ggp_file_transfer_test_filename));
-	req = purple_http_request_new(upload_url);
-	g_free(upload_url);
-
-	purple_http_request_set_method(req, "PUT");
-	purple_http_request_set_cookie_jar(req, ggp_file_transfer_cookie);
-
-	purple_http_request_header_set(req, "X-gged-api-version", "6");
-	purple_http_request_header_set(req, "X-gged-local-revision", "0");
-	purple_http_request_header_set(req, "X-gged-security-token", ggp_file_transfer_security_token);
-	purple_http_request_header_set(req, "X-gged-metadata", "{\"node_type\": \"file\"}");
-
-	purple_http_request_set_contents(req, ggp_file_transfer_test_file, -1);
-
-	purple_http_request(gc,
-		req, ggp_file_transfer_test_sent, NULL);
-	purple_http_request_unref(req);
-
-	ggp_file_transfer_ticket = NULL;
-}
-
-static void ggp_event_json(PurpleConnection *gc, struct gg_event_json_event *ev)
-{
-	if (g_strcmp0("edisc/send_ticket_changed", ev->type) == 0)
-		ggp_event_json_edisc_ticket_changed(gc, ev->data);
-	else
-		purple_debug_info("gg", "unknown json event %s\n", ev->type);
-}
-
-static void ggp_file_transfer_test_offered(PurpleHttpConnection *http_conn,
-	PurpleHttpResponse *response, gpointer user_data)
-{
-	JsonParser *parser;
-	JsonObject *change;
-	JsonObject *ticket;
-	const gchar *ticket_id;
-
-	purple_debug_info("gg-test", "offered: %s\n",
-		purple_http_response_get_data(response));
-
-	if (!purple_http_response_is_successfull(response))
-	{
-		purple_debug_error("gg-test", "offer failed\n");
-		return;
-	}
-
-	parser = json_parser_new();
-	if (!json_parser_load_from_data(parser,
-		purple_http_response_get_data(response), -1, NULL)) {
-		g_object_unref(parser);
-		purple_debug_error("gg-test", "invalid JSON\n");
-		return;
-	}
-
-	ticket = json_node_get_object(json_parser_get_root(parser));
-	ticket = json_object_get_object_member(ticket, "result");
-	ticket = json_object_get_object_member(ticket, "send_ticket");
-	ticket_id = json_object_get_string_member(ticket, "id");
-	ggp_file_transfer_ticket = g_strdup(ticket_id);
-
-	purple_debug_info("gg", "ticket id=%s\n", ticket_id);
-
-	g_object_unref(parser);
-}
-
-static void ggp_file_transfer_test_signedin(PurpleHttpConnection *http_conn,
-	PurpleHttpResponse *response, gpointer user_data)
-{
-	PurpleHttpRequest *req;
-	const gchar *security_token;
-	gchar *data;
-
-	if (!purple_http_response_is_successfull(response))
-	{
-		purple_debug_error("gg-test", "signin failed\n");
-		return;
-	}
-
-	if (0 != strcmp(purple_http_response_get_data(response),
-		"{\"result\":{\"status\":0}}"))
-	{
-		purple_debug_error("gg-test", "signin failed - bad response\n");
-		return;
-	}
-
-	security_token = purple_http_response_get_header(response,
-		"X-gged-security-token");
-	if (!security_token)
-	{
-		purple_debug_error("gg-test", "signin failed - "
-			"no security token\n");
-		return;
-	}
-
-	if (purple_debug_is_unsafe())
-		purple_debug_misc("gg-test", "security token=%s\n",
-			security_token);
-
-	req = purple_http_request_new("https://drive.mpa.gg.pl/send_ticket");
-	purple_http_request_set_method(req, "PUT");
-	purple_http_request_set_cookie_jar(req,
-		purple_http_conn_get_cookie_jar(http_conn));
-
-	ggp_file_transfer_cookie = purple_http_conn_get_cookie_jar(http_conn);
-	purple_http_cookie_jar_ref(ggp_file_transfer_cookie);
-
-	purple_http_request_header_set(req, "X-gged-api-version", "6");
-	purple_http_request_header_set(req, "X-gged-security-token", security_token);
-	ggp_file_transfer_security_token = g_strdup(security_token);
-
-	data = g_strdup_printf("{\"send_ticket\":{"
-		"\"recipient\":\"%u\","
-		"\"file_name\":\"%s\","
-		"\"file_size\":\"%u\""
-		"}}",
-		ggp_file_transfer_test_recipient,
-		ggp_file_transfer_test_filename,
-		strlen(ggp_file_transfer_test_file));
-	purple_http_request_set_contents(req, data, -1);
-	g_free(data);
-
-	purple_http_request(purple_http_conn_get_purple_connection(http_conn),
-		req, ggp_file_transfer_test_offered, NULL);
-	purple_http_request_unref(req);
-}
-
-static void ggp_file_transfer_test(PurpleConnection *gc)
-{
-	PurpleHttpRequest *req;
-	GGPInfo *accdata = purple_connection_get_protocol_data(gc);
-	const gchar *metadata;
-
-	if (ggp_imtoken == NULL)
-	{
-		purple_debug_error("gg-test", "IMToken not ready!\n");
-		return;
-	}
-
-	if (purple_debug_is_unsafe())
-		purple_debug_misc("gg-test", "IMToken=[%s]\n", ggp_imtoken);
-
-	req = purple_http_request_new("https://drive.mpa.gg.pl/signin");
-	purple_http_request_set_method(req, "PUT");



More information about the Commits mailing list