Esempio n. 1
0
static gboolean
poll_file_send_progress(gpointer user_data)
{
	SkypeWebFileTransfer *swft = user_data;
	SkypeWebAccount *sa = swft->sa;
	PurpleHttpURL *httpurl;
	const gchar *host, *path;
	gchar *headers;
	
	httpurl = purple_http_url_parse(swft->url);
	host = purple_http_url_get_host(httpurl);
	path = purple_http_url_get_path(httpurl);
	
	headers = g_strdup_printf("GET /%s HTTP/1.0\r\n"
			"Connection: close\r\n"
			"Cookie: skypetoken_asm=%s\r\n"
			"Host: %s\r\n"
			"\r\n\r\n",
			path, 
			sa->skype_token, 
			host);
	
	skypeweb_fetch_url_request(sa, swft->url, TRUE, NULL, FALSE, headers, FALSE, -1, got_file_send_progress, swft);
	
	g_free(headers);
	purple_http_url_free(httpurl);
	
	return FALSE;
}
Esempio n. 2
0
static void
skypeweb_init_file_download(PurpleXfer *xfer)
{
	SkypeWebFileTransfer *swft;
	const gchar *view_location;
	gint64 content_full_length;
	PurpleHttpURL *httpurl;
	gchar *headers;
	
	swft = purple_xfer_get_protocol_data(xfer);
	
	view_location = json_object_get_string_member(swft->info, "view_location");
	content_full_length = json_object_get_int_member(swft->info, "content_full_length");
	
	purple_xfer_start(xfer, -1, NULL, 0);
	
	httpurl = purple_http_url_parse(view_location);
	headers = g_strdup_printf("GET /%s HTTP/1.0\r\n"
			"Connection: close\r\n"
			"Cookie: skypetoken_asm=%s\r\n"
			"Host: %s\r\n"
			"\r\n\r\n",
			purple_http_url_get_path(httpurl), 
			swft->sa->skype_token, 
			purple_http_url_get_host(httpurl));
	
	skypeweb_fetch_url_request(swft->sa, view_location, TRUE, NULL, FALSE, headers, FALSE, content_full_length, skypeweb_got_file, swft);
	
	g_free(headers);
	purple_http_url_free(httpurl);
}
Esempio n. 3
0
void
skypeweb_download_uri_to_conv(SkypeWebAccount *sa, const gchar *uri, PurpleConversation *conv)
{
	gchar *headers;
	PurpleUtilFetchUrlData *requestdata;
	PurpleHttpURL *httpurl;
	
	httpurl = purple_http_url_parse(uri);
	headers = g_strdup_printf("GET /%s HTTP/1.0\r\n"
			"Connection: close\r\n"
			"Accept: image/*\r\n"
			"Cookie: skypetoken_asm=%s\r\n"
			"Host: %s\r\n"
			"\r\n\r\n",
			purple_http_url_get_path(httpurl), sa->skype_token, 
			purple_http_url_get_host(httpurl));
	
	requestdata = skypeweb_fetch_url_request(sa, uri, TRUE, NULL, FALSE, headers, FALSE, -1, skypeweb_got_imagemessage, conv);

	if (requestdata != NULL)
		requestdata->num_times_redirected = 10; /* Prevent following redirects */
	
	g_free(headers);
	purple_http_url_free(httpurl);
}
Esempio n. 4
0
PurpleJabberBOSHConnection*
jabber_bosh_connection_new(JabberStream *js, const gchar *url)
{
	PurpleJabberBOSHConnection *conn;
	PurpleHttpURL *url_p;

	url_p = purple_http_url_parse(url);
	if (!url_p) {
		purple_debug_error("jabber-bosh", "Unable to parse given URL.\n");
		return NULL;
	}

	conn = g_new0(PurpleJabberBOSHConnection, 1);
	conn->kapool = purple_http_keepalive_pool_new();
	conn->payload_reqs = purple_http_connection_set_new();
	purple_http_keepalive_pool_set_limit_per_host(conn->kapool, 2);
	conn->url = g_strdup(url);
	conn->js = js;
	conn->is_ssl = (g_ascii_strcasecmp("https",
		purple_http_url_get_protocol(url_p)) == 0);
	conn->send_buff = g_string_new(NULL);

	/*
	 * Random 64-bit integer masked off by 2^52 - 1.
	 *
	 * This should produce a random integer in the range [0, 2^52). It's
	 * unlikely we'll send enough packets in one session to overflow the
	 * rid.
	 */
	conn->rid = (((guint64)g_random_int() << 32) | g_random_int());
	conn->rid &= 0xFFFFFFFFFFFFFLL;

	if (purple_ip_address_is_valid(purple_http_url_get_host(url_p)))
		js->serverFQDN = g_strdup(js->user->domain);
	else
		js->serverFQDN = g_strdup(purple_http_url_get_host(url_p));

	purple_http_url_free(url_p);

	jabber_bosh_connection_session_create(conn);

	return conn;
}
Esempio n. 5
0
void
skypeweb_present_uri_as_filetransfer(SkypeWebAccount *sa, const gchar *uri, const gchar *from)
{
	PurpleHttpURL *httpurl;
	const gchar *host;
	gchar *path;
	SkypeWebFileTransfer *swft;
	gchar *headers;
	
	
	httpurl = purple_http_url_parse(uri);
	host = purple_http_url_get_host(httpurl);
	
	if (g_str_has_suffix(uri, "/views/original/status")) {
		path = g_strconcat(purple_http_url_get_path(httpurl), NULL);
	} else {
		path = g_strconcat(purple_http_url_get_path(httpurl), "/views/original/status", NULL);
	}
	
	headers = g_strdup_printf("GET /%s HTTP/1.0\r\n"
			"Connection: close\r\n"
			"Cookie: skypetoken_asm=%s\r\n"
			"Host: %s\r\n"
			"\r\n\r\n",
			path, 
			sa->skype_token, 
			host);
	
	swft = g_new0(SkypeWebFileTransfer, 1);
	swft->sa = sa;
	swft->url = g_strdup(uri);
	swft->from = g_strdup(from);
	
	skypeweb_fetch_url_request(sa, uri, TRUE, NULL, FALSE, headers, FALSE, -1, skypeweb_got_file_info, swft);
	
	g_free(path);
	g_free(headers);
	purple_http_url_free(httpurl);
}