Beispiel #1
0
static void ycht_packet_read(YchtPkt *pkt, const char *buf, int len)
{
	const char *pos = buf;
	const char *needle;
	char *tmp, *tmp2;
	int i = 0;

	while (len > 0 && (needle = g_strstr_len(pos, len, YCHT_SEP))) {
		tmp = g_strndup(pos, needle - pos);
		pkt->data = g_list_append(pkt->data, tmp);
		len -= needle - pos + strlen(YCHT_SEP);
		pos = needle + strlen(YCHT_SEP);
		tmp2 = g_strescape(tmp, NULL);
		purple_debug_misc("yahoo", "Data[%d]:\t%s\n", i++, tmp2);
		g_free(tmp2);
	}

	if (len) {
		tmp = g_strndup(pos, len);
		pkt->data = g_list_append(pkt->data, tmp);
		tmp2 = g_strescape(tmp, NULL);
		purple_debug_misc("yahoo", "Data[%d]:\t%s\n", i, tmp2);
		g_free(tmp2);
	};

	purple_debug_misc("yahoo", "--==End of incoming YCHT packet==--\n");
}
Beispiel #2
0
static gboolean pidgin_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data)
{
	PidginIOClosure *closure = data;
	PurpleInputCondition purple_cond = 0;

	if (condition & PIDGIN_READ_COND)
		purple_cond |= PURPLE_INPUT_READ;
	if (condition & PIDGIN_WRITE_COND)
		purple_cond |= PURPLE_INPUT_WRITE;

#if 0
	purple_debug_misc("gtk_eventloop",
			   "CLOSURE: callback for %d, fd is %d\n",
			   closure->result, g_io_channel_unix_get_fd(source));
#endif

#ifdef _WIN32
	if(! purple_cond) {
#ifdef DEBUG
		purple_debug_misc("gtk_eventloop",
			   "CLOSURE received GIOCondition of 0x%x, which does not"
			   " match 0x%x (READ) or 0x%x (WRITE)\n",
			   condition, PIDGIN_READ_COND, PIDGIN_WRITE_COND);
#endif /* DEBUG */

		return TRUE;
	}
#endif /* _WIN32 */

	closure->function(closure->data, g_io_channel_unix_get_fd(source),
			  purple_cond);

	return TRUE;
}
Beispiel #3
0
static void
http_connection_send_request(PurpleHTTPConnection *conn, const GString *req)
{
	char *data;
	int ret;
	size_t len;

	/* Sending something to the server, restart the inactivity timer */
	jabber_stream_restart_inactivity_timer(conn->bosh->js);

	data = g_strdup_printf("POST %s HTTP/1.1\r\n"
	                       "Host: %s\r\n"
	                       "User-Agent: %s\r\n"
	                       "Content-Encoding: text/xml; charset=utf-8\r\n"
	                       "Content-Length: %" G_GSIZE_FORMAT "\r\n\r\n"
	                       "%s",
	                       conn->bosh->path, conn->bosh->host, bosh_useragent,
	                       req->len, req->str);

	len = strlen(data);

	++conn->requests;
	++conn->bosh->requests;

	if (purple_debug_is_unsafe() && purple_debug_is_verbose())
		/* Will contain passwords for SASL PLAIN and is verbose */
		purple_debug_misc("jabber", "BOSH (%p): Sending %s\n", conn, data);
	else if (purple_debug_is_verbose())
		purple_debug_misc("jabber", "BOSH (%p): Sending request of "
		                            "%" G_GSIZE_FORMAT " bytes.\n", conn, len);

	if (conn->writeh == 0)
		ret = http_connection_do_send(conn, data, len);
	else {
		ret = -1;
		errno = EAGAIN;
	}

	if (ret < 0 && errno != EAGAIN) {
		/*
		 * TODO: Handle this better. Probably requires a PurpleBOSHConnection
		 * buffer that stores what is "being sent" until the
		 * PurpleHTTPConnection reports it is fully sent.
		 */
		gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"),
				g_strerror(errno));
		purple_connection_error_reason(conn->bosh->js->gc,
				PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
				tmp);
		g_free(tmp);
		return;
	} else if (ret < len) {
		if (ret < 0)
			ret = 0;
		if (conn->writeh == 0)
			conn->writeh = purple_input_add(conn->psc ? conn->psc->fd : conn->fd,
					PURPLE_INPUT_WRITE, http_connection_send_cb, conn);
		purple_circ_buffer_append(conn->write_buf, data + ret, len - ret);
	}
}
static const gchar *get_proc_exe(const gchar *p_proc_path)
{
	static gchar exe[PATH_MAX];

	gchar *proc_exe = g_strdup_printf("%s/exe", p_proc_path);
#ifdef DEBUG_VERBOSE
	purple_debug_misc("gfire", "get_proc_exe: Resolving symlink \"%s\"\n", proc_exe);
#endif // DEBUG_VERBOSE

	int len = readlink(proc_exe, exe, PATH_MAX - 1);
	if(len == -1)
	{
#ifdef DEBUG
		purple_debug_error("gfire", "get_proc_exe: readlink() failed\n");
#endif // DEBUG
		g_free(proc_exe);
		return NULL;
	}

	exe[len] = 0;
#ifdef DEBUG_VERBOSE
	purple_debug_misc("gfire", "get_proc_exe: \"%s\" -> \"%s\"\n", proc_exe, exe);
#endif // DEBUG_VERBOSE
	g_free(proc_exe);

	return exe;
}
static void got_page_cb(PurpleUtilFetchUrlData * url_data, gpointer user_data, const gchar * url_text, gsize len, const gchar * error_message)
{
    BuddyIconContext *ctx = user_data;
    TwitterConvIcon *conv_icon;
    const gchar    *pic_data;

    conv_icon = twitter_conv_icon_find(ctx->account, ctx->buddy_name);
    twitter_buddy_icon_context_free(ctx);

    g_return_if_fail(conv_icon != NULL);

    conv_icon->requested = FALSE;
    conv_icon->fetch_data = NULL;

    if (len && !error_message && twitter_response_text_status_code(url_text) == 200 && (pic_data = twitter_response_text_data(url_text, len))) {
        purple_debug_info(PLUGIN_ID, "Attempting to create pixbuf\n");
        purple_debug_misc(PLUGIN_ID, "MHM: url text is |%s|\n", url_text);
        purple_debug_misc(PLUGIN_ID, "MHM: url text is |%02x %02x %02x %02x|\n", pic_data[0], pic_data[1], pic_data[2], pic_data[3]);
        conv_icon->pixbuf = make_scaled_pixbuf((const guchar *) pic_data, len);
    }

    if (conv_icon->pixbuf) {
        purple_debug_info(PLUGIN_ID, "All succeeded, inserting\n");
        insert_requested_icon(conv_icon);
    }
}
/* start the connection when all the details are available */
void 
start_direct_connection()
{
	int server_pid=fork();
	if (server_pid==0)
	{
		/* child process: run the server */
		purple_debug_misc(PLUGIN_ID,"server_ip=\"%s\"\n",purple_value_get_string(server_ip));

		const char* cmd=purple_prefs_get_string(PREF_SERVER_COMMAND_LINE);

		/* replace the port in the command string */
		GRegex *port_regex=g_regex_new("[$]PORT",0,0,NULL);
		char* command=g_regex_replace(port_regex,cmd,-1,0,purple_value_get_string(port),0,NULL);

		purple_debug_misc(PLUGIN_ID,"server command=\"%s\"\n",command);
		gchar **splitted_command=g_strsplit(command," ",0);

		execvp(splitted_command[0],splitted_command);

		g_free(command);
		g_free(splitted_command);
		g_free(port_regex);
	}
	else 
	{
		/* original process: sent the connection request*/
		send_connect_request_message();

	}
}
static const gchar *get_proc_cwd(GHashTable *p_environ, const gchar *p_proc_path)
{
    static gchar cwd[PATH_MAX + 1];

	gchar *proc_cwd = g_strdup_printf("%s/cwd", p_proc_path);
#ifdef DEBUG_VERBOSE
	purple_debug_misc("gfire", "get_proc_cwd: No match, resolving symlink \"%s\"\n", proc_cwd);
#endif // DEBUG_VERBOSE

    ssize_t len = readlink(proc_cwd, cwd, PATH_MAX);
    if(len == -1)
	{
#ifdef DEBUG
		purple_debug_error("gfire", "get_proc_cwd: readlink() failed\n");
#endif // DEBUG
		g_free(proc_cwd);
		return NULL;
	}
    cwd[len] = 0;

#ifdef DEBUG_VERBOSE
	purple_debug_misc("gfire", "get_proc_cwd: \"%s\" -> \"%s\"\n", proc_cwd, cwd);
#endif // DEBUG_VERBOSE
	g_free(proc_cwd);
	return cwd;
}
Beispiel #8
0
void
purple_xfer_ui_ready(PurpleXfer *xfer)
{
	PurpleInputCondition cond;
	PurpleXferType type;
	PurpleXferPrivData *priv;

	g_return_if_fail(xfer != NULL);

	priv = g_hash_table_lookup(xfers_data, xfer);
	priv->ready |= PURPLE_XFER_READY_UI;

	if (0 == (priv->ready & PURPLE_XFER_READY_PRPL)) {
		purple_debug_misc("xfer", "UI is ready on ft %p, waiting for prpl\n", xfer);
		return;
	}

	purple_debug_misc("xfer", "UI (and prpl) ready on ft %p, so proceeding\n", xfer);

	type = purple_xfer_get_type(xfer);
	if (type == PURPLE_XFER_SEND)
		cond = PURPLE_INPUT_WRITE;
	else /* if (type == PURPLE_XFER_RECEIVE) */
		cond = PURPLE_INPUT_READ;

	if (xfer->watcher == 0 && xfer->fd != -1)
		xfer->watcher = purple_input_add(xfer->fd, cond, transfer_cb, xfer);

	priv->ready = PURPLE_XFER_READY_NONE;

	do_transfer(xfer);
}
Beispiel #9
0
static void
msn_soap_read_cb(gpointer data, gint fd, PurpleInputCondition cond)
{
	MsnSoapConnection *conn = data;
	int count = 0, cnt, perrno;
	/* This buffer needs to be larger than any packets received from
		login.live.com or Adium will fail to receive the packet
		(something weird with the login.live.com server). With NSS it works
		fine, so I believe it's some bug with OS X */
	char buf[16 * 1024];
	gsize cursor;

	if (conn->message == NULL) {
		conn->message = msn_soap_message_new(NULL, NULL);
	}

	if (conn->buf == NULL) {
		conn->buf = g_string_new_len(buf, 0);
	}

	cursor = conn->buf->len;
	while ((cnt = purple_ssl_read(conn->ssl, buf, sizeof(buf))) > 0) {
		purple_debug_info("soap", "read %d bytes\n", cnt);
		count += cnt;
		g_string_append_len(conn->buf, buf, cnt);
	}

	perrno = errno;
	if (cnt < 0 && perrno != EAGAIN)
		purple_debug_info("soap", "read: %s\n", g_strerror(perrno));

	if (conn->current_request && conn->current_request->secure &&
		!purple_debug_is_unsafe())
		purple_debug_misc("soap", "Received secure request.\n");
	else if (count != 0)
		purple_debug_misc("soap", "current %s\n", conn->buf->str + cursor);

	/* && count is necessary for Adium, on OS X the last read always
	   return an error, so we want to proceed anyway. See #5212 for
	   discussion on this and the above buffer size issues */
	if(cnt < 0 && errno == EAGAIN && count == 0)
		return;

	/* msn_soap_process could alter errno */
	msn_soap_process(conn);

	if ((cnt < 0 && perrno != EAGAIN) || cnt == 0) {
		/* It's possible msn_soap_process closed the ssl connection */
		if (conn->ssl) {
			purple_ssl_close(conn->ssl);
			conn->ssl = NULL;
			msn_soap_connection_handle_next(conn);
		}
	}
}
Beispiel #10
0
static PurpleHTTPConnection *
find_available_http_connection(PurpleBOSHConnection *conn)
{
	int i;

	if (purple_debug_is_verbose()) {
		for (i = 0; i < NUM_HTTP_CONNECTIONS; ++i) {
			PurpleHTTPConnection *httpconn = conn->connections[i];
			if (httpconn == NULL)
				purple_debug_misc("jabber", "BOSH %p->connections[%d] = (nil)\n",
				                  conn, i);
			else
				purple_debug_misc("jabber", "BOSH %p->connections[%d] = %p, state = %d"
				                  ", requests = %d\n", conn, i, httpconn,
				                  httpconn->state, httpconn->requests);
		}
	}

	/* Easy solution: Does everyone involved support pipelining? Hooray! Just use
	 * one TCP connection! */
	if (conn->pipelining)
		return conn->connections[0]->state == HTTP_CONN_CONNECTED ?
				conn->connections[0] : NULL;

	/* First loop, look for a connection that's ready */
	for (i = 0; i < NUM_HTTP_CONNECTIONS; ++i) {
		if (conn->connections[i] &&
				conn->connections[i]->state == HTTP_CONN_CONNECTED &&
				conn->connections[i]->requests == 0)
			return conn->connections[i];
	}

	/* Second loop, is something currently connecting? If so, just queue up. */
	for (i = 0; i < NUM_HTTP_CONNECTIONS; ++i) {
		if (conn->connections[i] &&
				conn->connections[i]->state == HTTP_CONN_CONNECTING)
			return NULL;
	}

	/* Third loop, look for one that's NULL and create a new connection */
	for (i = 0; i < NUM_HTTP_CONNECTIONS; ++i) {
		if (!conn->connections[i]) {
			purple_debug_info("jabber", "bosh: Creating and connecting new httpconn\n");
			conn->connections[i] = jabber_bosh_http_connection_init(conn);

			http_connection_connect(conn->connections[i]);
			return NULL;
		}
	}

	purple_debug_warning("jabber", "Could not find a HTTP connection!\n");

	/* None available. */
	return NULL;
}
Beispiel #11
0
static void ggp_ggdrive_auth_done(PurpleHttpConnection *hc,
	PurpleHttpResponse *response, gpointer user_data)
{
	PurpleConnection *gc = purple_http_conn_get_purple_connection(hc);
	ggp_edisc_session_data *sdata = ggp_edisc_get_sdata(gc);
	JsonParser *parser;
	JsonObject *result;
	int status = -1;

	g_return_if_fail(sdata != NULL);

	sdata->auth_request = NULL;

	if (!purple_http_response_is_successful(response)) {
		purple_debug_misc("gg", "ggp_ggdrive_auth_done: authentication "
			"failed due to unsuccessful request (code = %d)\n",
			purple_http_response_get_code(response));
		ggp_ggdrive_auth_results(gc, FALSE);
		return;
	}

	parser = ggp_json_parse(purple_http_response_get_data(response, NULL));
	result = json_node_get_object(json_parser_get_root(parser));
	result = json_object_get_object_member(result, "result");
	if (json_object_has_member(result, "status"))
		status = json_object_get_int_member(result, "status");
	g_object_unref(parser);

	if (status != 0 ) {
		purple_debug_misc("gg", "ggp_ggdrive_auth_done: authentication "
			"failed due to bad result (status=%d)\n", status);
		if (purple_debug_is_verbose())
			purple_debug_misc("gg", "ggp_ggdrive_auth_done: "
				"result = %s\n",
				purple_http_response_get_data(response, NULL));
		ggp_ggdrive_auth_results(gc, FALSE);
		return;
	}

	sdata->security_token = g_strdup(purple_http_response_get_header(
		response, "X-gged-security-token"));
	if (!sdata->security_token) {
		purple_debug_misc("gg", "ggp_ggdrive_auth_done: authentication "
			"failed due to missing security token header\n");
		ggp_ggdrive_auth_results(gc, FALSE);
		return;
	}

	if (purple_debug_is_unsafe())
		purple_debug_misc("gg", "ggp_ggdrive_auth_done: "
			"security_token=%s\n", sdata->security_token);
	ggp_ggdrive_auth_results(gc, TRUE);
}
Beispiel #12
0
/* initialize an IM message to potentially be split */
static void
sending_im_msg_cb(PurpleAccount *account, const char *receiver,
                  const char **message)
{
	message_to_conv *msg_to_conv;

	if (splitter_injected_message)
		return;

	purple_debug_misc("purple-splitter", "splitter plugin invoked\n");

	g_return_if_fail(account  != NULL);
	g_return_if_fail(receiver != NULL);
	g_return_if_fail(message  != NULL);
	g_return_if_fail(*message != NULL);

	/* OTR compatibility hack */
	if (0 == strncmp(*message, "?OTR", strlen("?OTR")))
		return;

	msg_to_conv = g_new0(message_to_conv, 1);

	msg_to_conv->sender_username     = g_strdup(account->username);
	msg_to_conv->sender_protocol_id  = g_strdup(account->protocol_id);
	msg_to_conv->receiver            = g_strdup(receiver);
	msg_to_conv->type                = PURPLE_CONV_TYPE_IM;

	split_and_send(msg_to_conv, message);
}
Beispiel #13
0
guint32
aim_locate_getcaps_short(OscarData *od, ByteStream *bs, int len)
{
	guint32 flags = 0;
	int offset;

	for (offset = 0; byte_stream_empty(bs) && (offset < len); offset += 0x02) {
		guint8 *cap;
		int i, identified;

		cap = byte_stream_getraw(bs, 0x02);

		for (i = 0, identified = 0; !(aim_caps[i].flag & OSCAR_CAPABILITY_LAST); i++) {
			if (memcmp(&aim_caps[i].data[2], cap, 0x02) == 0) {
				flags |= aim_caps[i].flag;
				identified++;
				break; /* should only match once... */
			}
		}

		if (!identified)
			purple_debug_misc("oscar", "unknown short capability: {%02x%02x}\n", cap[0], cap[1]);

		g_free(cap);
	}

	return flags;
}
Beispiel #14
0
/* As we've covered before, libpurple calls this function, if present, when it
 * loads the plugin.  Here we're using it to show off the capabilities of the
 * debug API and just blindly returning TRUE to tell libpurple it's safe to
 * continue loading. */
static gboolean
plugin_load(PurplePlugin *plugin)
{
	/* Define these for convenience--we're just using them to show the
	 * similarities of the debug functions to the standard printf(). */
	gint i = 256;
	gfloat f = 512.1024;
	const gchar *s = "example string";

	/* Introductory message */
	purple_debug_info(PLUGIN_ID,
		"Called plugin_load.  Beginning debug demonstration\n");

	/* Show off the debug API a bit */
	purple_debug_misc(PLUGIN_ID,
		"MISC level debug message.  i = %d, f = %f, s = %s\n", i, f, s);

	purple_debug_info(PLUGIN_ID,
		"INFO level debug message.  i = %d, f = %f, s = %s\n", i, f, s);

	purple_debug_warning(PLUGIN_ID,
		"WARNING level debug message.  i = %d, f = %f, s = %s\n", i, f, s);

	purple_debug_error(PLUGIN_ID,
		"ERROR level debug message.  i = %d, f = %f, s = %s\n", i, f, s);

	purple_debug_fatal(PLUGIN_ID,
		"FATAL level debug message. i = %d, f = %f, s = %s\n", i, f, s);

	/* Now just return TRUE to tell libpurple to finish loading. */
	return TRUE;
}
Beispiel #15
0
static void
show_debug_cmd(MsnCmdProc *cmdproc, gboolean incoming, const char *command)
{
	MsnServConn *servconn;
	const char *names[] = { "NS", "SB" };
	char *show;
	char tmp;
	size_t len;

	servconn = cmdproc->servconn;
	len = strlen(command);
	show = g_strdup(command);

	tmp = (incoming) ? 'S' : 'C';

	if ((show[len - 1] == '\n') && (show[len - 2] == '\r'))
	{
		show[len - 2] = '\0';
	}

	purple_debug_misc("msn", "%c: %s %03d: %s\n", tmp,
					names[servconn->type], servconn->num, show);

	g_free(show);
}
Beispiel #16
0
/* Exported functions */
DBUS_EXPORT void
music_messaging_change_request(const int session, const char *command,
                               const char *parameters)
{

    MMConversation *mmconv = (MMConversation *)g_list_nth_data(conversations, session);

    if (mmconv->started)
    {
        if (mmconv->originator)
        {
            const char *name = purple_conversation_get_name(mmconv->conv);
            send_change_request (session, name, command, parameters);
        } else
        {
            GString *to_send = g_string_new("");
            g_string_append_printf(to_send, "##MM## request %s %s##MM##", command, parameters);

            purple_conversation_send(mmconv->conv, to_send->str);

            purple_debug_misc("musicmessaging", "Sent request: %s\n", to_send->str);
        }
    }

}
Beispiel #17
0
void ggp_edisc_xfer_send_ticket_changed(PurpleConnection *gc, PurpleXfer *xfer,
	gboolean is_allowed)
{
	ggp_edisc_xfer *edisc_xfer = purple_xfer_get_protocol_data(xfer);
	if (!edisc_xfer) {
		purple_debug_fatal("gg", "ggp_edisc_event_ticket_changed: "
			"transfer %p already free'd\n", xfer);
		return;
	}

	if (!is_allowed) {
		purple_debug_info("gg", "ggp_edisc_event_ticket_changed: "
			"transfer %p rejected\n", xfer);
		purple_xfer_cancel_remote(xfer);
		ggp_edisc_xfer_free(xfer);
		return;
	}

	if (edisc_xfer->allowed) {
		purple_debug_misc("gg", "ggp_edisc_event_ticket_changed: "
			"transfer %p already allowed\n", xfer);
		return;
	}
	edisc_xfer->allowed = TRUE;

	purple_xfer_start(xfer, -1, NULL, 0);
}
static gboolean
android_io_invoke(GIOChannel *source, GIOCondition condition, gpointer data)
{
	static JavaMethodIDCache methodCache = METHOD_CACHE("ioInvoke", "(JJII)V");

	jmethodID mid;
	AndroidIOClosure *closure;
	PurpleInputCondition purple_cond = 0;

	CALLBACK_START(&eventloop, 0);

	closure = data;
	if (condition & ANDROID_READ_COND)
		purple_cond |= PURPLE_INPUT_READ;
	if (condition & ANDROID_WRITE_COND)
		purple_cond |= PURPLE_INPUT_WRITE;

	purple_debug_misc("eventloop", "CLOSURE: callback for %d, fd is %d\n",
			closure->result, g_io_channel_unix_get_fd(source));

	mid = getMethodIDCachedReferenced(env, eventloop.java_class, &methodCache);
	if (mid != NULL) {
		(*env)->CallVoidMethod(env, eventloop.handlerObject, mid,
				pToLong(closure->function), pToLong(closure->data),
				(jint) g_io_channel_unix_get_fd(source), (jint) purple_cond);
	}

	return TRUE;
}
static void
hangouts_auth_get_session_cookies_uberauth_cb(PurpleHttpConnection *http_conn, PurpleHttpResponse *response, gpointer user_data)
{
	HangoutsAccount *ha = user_data;
	PurpleHttpRequest *request;
	const gchar *uberauth;

	uberauth = purple_http_response_get_data(response, NULL);

	if (purple_http_response_get_error(response) != NULL) {
		purple_connection_error(ha->pc, PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, 
			_("Auth error"));
		return;
	}
	
	purple_debug_misc("hangouts-prpl", "uberauth: %s", uberauth);

	request = purple_http_request_new(NULL);
	purple_http_request_set_url_printf(request, "https://accounts.google.com/MergeSession" "?service=mail&continue=http://www.google.com&uberauth=%s", purple_url_encode(uberauth));
	purple_http_request_set_cookie_jar(request, ha->cookie_jar);
	purple_http_request_header_set_printf(request, "Authorization", "Bearer %s", ha->access_token);
	purple_http_request_set_max_redirects(request, 0);
	
	purple_http_request(ha->pc, request, hangouts_auth_get_session_cookies_got_cb, ha);
	purple_http_request_unref(request);
}
Beispiel #20
0
static void
connection_common_established_cb(PurpleHTTPConnection *conn)
{
	purple_debug_misc("jabber", "bosh: httpconn %p re-connected\n", conn);

	/* Indicate we're ready and reset some variables */
	conn->state = HTTP_CONN_CONNECTED;
	if (conn->requests != 0)
		purple_debug_error("jabber", "bosh: httpconn %p has %d requests, != 0\n",
		                   conn, conn->requests);

	conn->requests = 0;
	if (conn->read_buf) {
		g_string_free(conn->read_buf, TRUE);
		conn->read_buf = NULL;
	}
	conn->close = FALSE;
	conn->headers_done = FALSE;
	conn->handled_len = conn->body_len = 0;

	if (purple_debug_is_verbose())
		debug_dump_http_connections(conn->bosh);

	if (conn->bosh->js->reinit)
		jabber_bosh_connection_send(conn->bosh, PACKET_NORMAL, NULL);
	else if (conn->bosh->state == BOSH_CONN_ONLINE) {
		purple_debug_info("jabber", "BOSH session already exists. Trying to reuse it.\n");
		if (conn->bosh->requests == 0 || conn->bosh->pending->bufused > 0) {
			/* Send the pending data */
			jabber_bosh_connection_send(conn->bosh, PACKET_FLUSH, NULL);
		}
	} else
		jabber_bosh_connection_boot(conn->bosh);
}
static void ggp_libgaduw_http_handler(gpointer _req, gint fd,
	PurpleInputCondition cond)
{
	ggp_libgaduw_http_req *req = _req;

	if (req->h->callback(req->h) == -1 || req->h->state == GG_STATE_ERROR) {
		purple_debug_error("gg", "ggp_libgaduw_http_handler: failed to "
			"make http request: %d\n", req->h->error);
		ggp_libgaduw_http_finish(req, FALSE);
		return;
	}

	if (purple_debug_is_verbose()) {
		purple_debug_misc("gg", "ggp_libgaduw_http_handler: got fd "
			"update [check=%d, state=%d]\n", req->h->check,
			req->h->state);
	}

	if (req->h->state != GG_STATE_DONE) {
		purple_input_remove(req->inpa);
		req->inpa = ggp_purplew_http_input_add(req->h,
			ggp_libgaduw_http_handler, req);
		return;
	}

	if (!req->h->data || !req->h->body) {
		purple_debug_error("gg", "ggp_libgaduw_http_handler: got empty "
			"http response: %d\n", req->h->error);
		ggp_libgaduw_http_finish(req, FALSE);
		return;
	}

	ggp_libgaduw_http_finish(req, TRUE);
}
void ggp_libgaduw_http_cancel(ggp_libgaduw_http_req *req)
{
	purple_debug_misc("gg", "ggp_libgaduw_http_cancel\n");
	req->cancelled = TRUE;
	gg_http_stop(req->h);
	ggp_libgaduw_http_finish(req, FALSE);
}
static void*
ggp_tcpsocket_connect(void *_gc, const char *host, int port, int is_tls,
	int is_async, void *priv)
{
	PurpleConnection *gc = _gc;
	PurpleSocket *ps;

	PURPLE_ASSERT_CONNECTION_IS_VALID(gc);
	g_return_val_if_fail(!purple_connection_is_disconnecting(gc), NULL);

	g_return_val_if_fail(host != NULL, NULL);
	g_return_val_if_fail(is_async, NULL);

	purple_debug_misc("gg", "ggp_tcpsocket_connect(%p, %s:%d, %s, %p)",
		gc, host, port, is_tls ? "tls" : "tcp", priv);

	ps = purple_socket_new(gc);
	purple_socket_set_tls(ps, is_tls);
	purple_socket_set_host(ps, host);
	purple_socket_set_port(ps, port);
	if (!purple_socket_connect(ps, ggp_tcpsocket_connected, priv)) {
		purple_socket_destroy(ps);
		return NULL;
	}

	return ps;
}
static void
displayed_chat_msg_cb(PurpleConversation *conv, PurpleMessage *msg, gpointer data)
{
    purple_debug_misc("gtk-signals test", "displayed-chat-msg (%s, %s)\n",
                      purple_conversation_get_name(conv),
                      purple_message_get_contents(msg));
}
Beispiel #25
0
static void
ubm_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
{
	purple_debug_misc("msn", "get UBM...\n");
	cmd->payload_len = atoi(cmd->params[3]);
	cmdproc->last_cmd->payload_cb = msg_cmd_post;
}
Beispiel #26
0
int aim__registermodule(OscarData *od, int (*modfirst)(OscarData *, aim_module_t *))
{
	aim_module_t *mod;

	if (!od || !modfirst)
		return -1;

	mod = g_new0(aim_module_t, 1);

	if (modfirst(od, mod) == -1) {
		g_free(mod);
		return -1;
	}

	if (aim__findmodule(od, mod->name)) {
		if (mod->shutdown)
			mod->shutdown(od, mod);
		g_free(mod);
		return -1;
	}

	mod->next = (aim_module_t *)od->modlistv;
	od->modlistv = mod;

	purple_debug_misc("oscar", "registered module %s (family 0x%04x, version = 0x%04x, tool 0x%04x, tool version 0x%04x)\n", mod->name, mod->family, mod->version, mod->toolid, mod->toolversion);

	return 0;
}
Beispiel #27
0
static void jabber_bosh_connection_boot(PurpleBOSHConnection *conn) {
	GString *buf = g_string_new(NULL);

	g_string_printf(buf, "<body content='text/xml; charset=utf-8' "
	                "secure='true' "
	                "to='%s' "
	                "xml:lang='en' "
	                "xmpp:version='1.0' "
	                "ver='1.6' "
	                "xmlns:xmpp='" NS_XMPP_BOSH "' "
	                "rid='%" G_GUINT64_FORMAT "' "
/* TODO: This should be adjusted/adjustable automatically according to
 * realtime network behavior */
	                "wait='60' "
	                "hold='1' "
	                "xmlns='" NS_BOSH "'/>",
	                conn->js->user->domain,
	                ++conn->rid);

	purple_debug_misc("jabber", "SendBOSH Boot %s(%" G_GSIZE_FORMAT "): %s\n",
	                  conn->ssl ? "(ssl)" : "", buf->len, buf->str);
	conn->receive_cb = boot_response_cb;
	http_connection_send_request(conn->connections[0], buf);
	g_string_free(buf, TRUE);
}
Beispiel #28
0
static void ggp_pubdir_search_got_token(PurpleConnection *gc,
	const gchar *token, gpointer _request)
{
	PurpleHttpRequest *req;
	ggp_pubdir_request *request = _request;
	gchar *query;

	PURPLE_ASSERT_CONNECTION_IS_VALID(gc);

	if (!token) {
		request->cb(gc, -1, NULL, 0, request->user_data);
		ggp_pubdir_request_free(request);
		return;
	}

	purple_debug_misc("gg", "ggp_pubdir_search_got_token\n");

	query = ggp_pubdir_search_make_query(request->params.search_form);

	req = purple_http_request_new(NULL);
	purple_http_request_set_url_printf(req, "http://api.gadu-gadu.pl%s", query);
	purple_http_request_header_set(req, "Authorization", token);
	purple_http_request(gc, req, ggp_pubdir_got_data, request);
	purple_http_request_unref(req);

	g_free(query);
}
Beispiel #29
0
void purple_roomlist_ref(PurpleRoomlist *list)
{
	g_return_if_fail(list != NULL);

	list->ref++;
	purple_debug_misc("roomlist", "reffing list, ref count now %d\n", list->ref);
}
static const char *
aim_receive_custom_icon(OscarData *od, ByteStream *bs, int len)
{
	int offset;
	const char *result = NULL;

	for (offset = 0; byte_stream_bytes_left(bs) && (offset < len); offset += 0x10) {
		/* check wheather this capability is a custom user icon */
		guint8 *cap;
		int i;

		cap = byte_stream_getraw(bs, 0x10);

		for (i = 0; icq_custom_icons[i].mood; i++) {
			if (memcmp(&icq_custom_icons[i].data, cap, 0x10) == 0) {
				purple_debug_misc("oscar", "Custom status icon: %s\n", icq_purple_moods[i].description);
				result = icq_custom_icons[i].mood;
				break; /* should only match once... */
			}
		}
		g_free(cap);
	}

	return result;
}