Пример #1
0
static PurpleXmlNode *
pounce_to_xmlnode(PurplePounce *pounce)
{
	PurpleXmlNode *node, *child;
	PurpleAccount *pouncer;
	PurplePounceEvent events;
	PurplePounceOption options;

	pouncer = purple_pounce_get_pouncer(pounce);
	events  = purple_pounce_get_events(pounce);
	options = purple_pounce_get_options(pounce);

	node = purple_xmlnode_new("pounce");
	purple_xmlnode_set_attrib(node, "ui", pounce->ui_type);

	child = purple_xmlnode_new_child(node, "account");
	purple_xmlnode_set_attrib(child, "protocol", purple_account_get_protocol_id(pouncer));
	purple_xmlnode_insert_data(child,
			purple_normalize(pouncer, purple_account_get_username(pouncer)), -1);

	child = purple_xmlnode_new_child(node, "pouncee");
	purple_xmlnode_insert_data(child, purple_pounce_get_pouncee(pounce), -1);

	/* Write pounce options */
	child = purple_xmlnode_new_child(node, "options");
	if (options & PURPLE_POUNCE_OPTION_AWAY)
		add_option_to_xmlnode(child, "on-away");

	/* Write pounce events */
	child = purple_xmlnode_new_child(node, "events");
	if (events & PURPLE_POUNCE_SIGNON)
		add_event_to_xmlnode(child, "sign-on");
	if (events & PURPLE_POUNCE_SIGNOFF)
		add_event_to_xmlnode(child, "sign-off");
	if (events & PURPLE_POUNCE_AWAY)
		add_event_to_xmlnode(child, "away");
	if (events & PURPLE_POUNCE_AWAY_RETURN)
		add_event_to_xmlnode(child, "return-from-away");
	if (events & PURPLE_POUNCE_IDLE)
		add_event_to_xmlnode(child, "idle");
	if (events & PURPLE_POUNCE_IDLE_RETURN)
		add_event_to_xmlnode(child, "return-from-idle");
	if (events & PURPLE_POUNCE_TYPING)
		add_event_to_xmlnode(child, "start-typing");
	if (events & PURPLE_POUNCE_TYPED)
		add_event_to_xmlnode(child, "typed");
	if (events & PURPLE_POUNCE_TYPING_STOPPED)
		add_event_to_xmlnode(child, "stop-typing");
	if (events & PURPLE_POUNCE_MESSAGE_RECEIVED)
		add_event_to_xmlnode(child, "message-received");

	/* Write pounce actions */
	child = purple_xmlnode_new_child(node, "actions");
	g_hash_table_foreach(pounce->actions, action_parameter_list_to_xmlnode, child);

	if (purple_pounce_get_save(pounce))
		purple_xmlnode_new_child(node, "save");

	return node;
}
static void
google_session_stream_info_cb(PurpleMedia *media, PurpleMediaInfoType type,
		gchar *sid, gchar *name, gboolean local,
		GoogleSession *session)
{
	if (sid != NULL || name != NULL)
		return;

	if (type == PURPLE_MEDIA_INFO_HANGUP) {
		PurpleXmlNode *sess;
		JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);

		purple_xmlnode_set_attrib(iq->node, "to", session->remote_jid);
		sess = google_session_create_xmlnode(session, "terminate");
		purple_xmlnode_insert_child(iq->node, sess);

		jabber_iq_send(iq);
	} else if (type == PURPLE_MEDIA_INFO_REJECT) {
		PurpleXmlNode *sess;
		JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);

		purple_xmlnode_set_attrib(iq->node, "to", session->remote_jid);
		sess = google_session_create_xmlnode(session, "reject");
		purple_xmlnode_insert_child(iq->node, sess);

		jabber_iq_send(iq);
	} else if (type == PURPLE_MEDIA_INFO_ACCEPT && local == TRUE) {
		google_session_ready(session);
	}
}
static PurpleXmlNode *
google_session_create_xmlnode(GoogleSession *session, const char *type)
{
	PurpleXmlNode *node = purple_xmlnode_new("session");
	purple_xmlnode_set_namespace(node, NS_GOOGLE_SESSION);
	purple_xmlnode_set_attrib(node, "id", session->id.id);
	purple_xmlnode_set_attrib(node, "initiator", session->id.initiator);
	purple_xmlnode_set_attrib(node, "type", type);
	return node;
}
Пример #4
0
JabberIq *
jingle_session_create_ack(JingleSession *session, const PurpleXmlNode *jingle)
{
	JabberIq *result = jabber_iq_new(
			jingle_session_get_js(session),
			JABBER_IQ_RESULT);
	PurpleXmlNode *packet = purple_xmlnode_get_parent(jingle);
	jabber_iq_set_id(result, purple_xmlnode_get_attrib(packet, "id"));
	purple_xmlnode_set_attrib(result->node, "from", purple_xmlnode_get_attrib(packet, "to"));
	purple_xmlnode_set_attrib(result->node, "to", purple_xmlnode_get_attrib(packet, "from"));
	return result;
}
Пример #5
0
static JabberIq *
jingle_create_iq(JingleSession *session)
{
	JabberStream *js = jingle_session_get_js(session);
	JabberIq *result = jabber_iq_new(js, JABBER_IQ_SET);
	gchar *from = jingle_session_get_local_jid(session);
	gchar *to = jingle_session_get_remote_jid(session);

	purple_xmlnode_set_attrib(result->node, "from", from);
	purple_xmlnode_set_attrib(result->node, "to", to);

	g_free(from);
	g_free(to);
	return result;
}
Пример #6
0
static void
bonjour_bytestreams_listen(int sock, gpointer data)
{
	PurpleXfer *xfer = data;
	XepXfer *xf;
	XepIq *iq;
	PurpleXmlNode *query, *streamhost;
	gchar *port;
	GSList *local_ips;
	BonjourData *bd;

	purple_debug_info("bonjour", "Bonjour-bytestreams-listen. sock=%d.\n", sock);
	if (sock < 0 || xfer == NULL) {
		/*purple_xfer_cancel_local(xfer);*/
		return;
	}

	purple_xfer_set_watcher(xfer, purple_input_add(sock, PURPLE_INPUT_READ,
					 bonjour_sock5_request_cb, xfer));
	xf = purple_xfer_get_protocol_data(xfer);
	xf->listen_data = NULL;

	bd = xf->data;

	iq = xep_iq_new(bd, XEP_IQ_SET, purple_xfer_get_remote_user(xfer), bonjour_get_jid(bd->jabber_data->account), xf->sid);

	query = purple_xmlnode_new_child(iq->node, "query");
	purple_xmlnode_set_namespace(query, "http://jabber.org/protocol/bytestreams");
	purple_xmlnode_set_attrib(query, "sid", xf->sid);
	purple_xmlnode_set_attrib(query, "mode", "tcp");

	purple_xfer_set_local_port(xfer, purple_network_get_port_from_fd(sock));

	local_ips = bonjour_jabber_get_local_ips(sock);

	port = g_strdup_printf("%hu", purple_xfer_get_local_port(xfer));
	while(local_ips) {
		streamhost = purple_xmlnode_new_child(query, "streamhost");
		purple_xmlnode_set_attrib(streamhost, "jid", xf->sid);
		purple_xmlnode_set_attrib(streamhost, "host", local_ips->data);
		purple_xmlnode_set_attrib(streamhost, "port", port);
		g_free(local_ips->data);
		local_ips = g_slist_delete_link(local_ips, local_ips);
	}
	g_free(port);

	xep_iq_send_and_free(iq);
}
Пример #7
0
void jabber_gmail_init(JabberStream *js) {
	JabberIq *iq;
	PurpleXmlNode *usersetting, *mailnotifications;

	if (!purple_account_get_check_mail(purple_connection_get_account(js->gc)))
		return;

	/*
	 * Quoting https://developers.google.com/talk/jep_extensions/usersettings:
	 * To ensure better compatibility with other clients, rather than
	 * setting this value to "false" to turn off notifications, it is
	 * recommended that a client set this to "true" and filter incoming
	 * email notifications itself.
	 */
	iq = jabber_iq_new(js, JABBER_IQ_SET);
	usersetting = purple_xmlnode_new_child(iq->node, "usersetting");
	purple_xmlnode_set_namespace(usersetting, "google:setting");
	mailnotifications = purple_xmlnode_new_child(usersetting, "mailnotifications");
	purple_xmlnode_set_attrib(mailnotifications, "value", "true");
	jabber_iq_send(iq);

	iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_GOOGLE_MAIL_NOTIFY);
	jabber_iq_set_callback(iq, jabber_gmail_parse, NULL);
	jabber_iq_send(iq);
}
Пример #8
0
/**
 * Tries to append an interface scope to an IPv6 link local address.
 *
 * If the given address is a link local IPv6 address (with no
 * interface scope) then we try to determine all fitting interfaces
 * from our Bonjour IP address list.
 *
 * For any such found matches we insert a copy of our current xml
 * streamhost entry right after this streamhost entry and append
 * the determined interface to the host address of this copy.
 *
 * @param cur_streamhost	The XML streamhost node we examine
 * @param host	The host address to examine in text form
 * @param pb	Buddy to get the list of link local IPv6 addresses
 *		and their interface from
 * @return	Returns TRUE if the specified 'host' address is a
 *		link local IPv6 address with no interface scope.
 *		Otherwise returns FALSE.
 */
static gboolean
add_ipv6_link_local_ifaces(PurpleXmlNode *cur_streamhost, const char *host,
			   const PurpleBuddy *pb) {
	PurpleXmlNode *new_streamhost = NULL;
	struct in6_addr in6_addr;
	BonjourBuddy *bb;
	GSList *ip_elem;

	if (inet_pton(AF_INET6, host, &in6_addr) != 1 ||
	    !IN6_IS_ADDR_LINKLOCAL(&in6_addr) ||
	    strchr(host, '%'))
		return FALSE;

	bb = purple_buddy_get_protocol_data(pb);

	for (ip_elem = bb->ips;
	     (ip_elem = g_slist_find_custom(ip_elem, host, (GCompareFunc)&xep_addr_differ));
	     ip_elem = ip_elem->next) {
		purple_debug_info("bonjour", "Inserting an PurpleXmlNode twin copy for %s with new host address %s\n",
				  host, (char*)ip_elem->data);
		new_streamhost = purple_xmlnode_insert_twin_copy(cur_streamhost);
		purple_xmlnode_set_attrib(new_streamhost, "host", ip_elem->data);
	}

	if (!new_streamhost)
		purple_debug_info("bonjour", "No interface for this IPv6 link local address found: %s\n",
				  host);

	return TRUE;
}
Пример #9
0
static void
add_option_to_xmlnode(PurpleXmlNode *node, const char *type)
{
	PurpleXmlNode *child;

	child = purple_xmlnode_new_child(node, "option");
	purple_xmlnode_set_attrib(child, "type", type);
}
Пример #10
0
static void
jabber_ibb_send_error_response(JabberStream *js, const char *to, const char *id)
{
	JabberIq *result = jabber_iq_new(js, JABBER_IQ_ERROR);
	PurpleXmlNode *error = purple_xmlnode_new("error");
	PurpleXmlNode *item_not_found = purple_xmlnode_new("item-not-found");

	purple_xmlnode_set_namespace(item_not_found, NS_XMPP_STANZAS);
	purple_xmlnode_set_attrib(error, "code", "440");
	purple_xmlnode_set_attrib(error, "type", "cancel");
	jabber_iq_set_id(result, id);
	purple_xmlnode_set_attrib(result->node, "to", to);
	purple_xmlnode_insert_child(error, item_not_found);
	purple_xmlnode_insert_child(result->node, error);

	jabber_iq_send(result);
}
Пример #11
0
void
jabber_ibb_session_send_data(JabberIBBSession *sess, gconstpointer data,
                             gsize size)
{
	JabberIBBSessionState state = jabber_ibb_session_get_state(sess);

	purple_debug_info("jabber", "sending data block of %" G_GSIZE_FORMAT " bytes on IBB stream\n",
		size);

	if (state != JABBER_IBB_SESSION_OPENED) {
		purple_debug_error("jabber",
			"trying to send data on a non-open IBB session\n");
	} else if (size > jabber_ibb_session_get_max_data_size(sess)) {
		purple_debug_error("jabber",
			"trying to send a too large packet in the IBB session\n");
	} else {
		JabberIq *set = jabber_iq_new(jabber_ibb_session_get_js(sess),
			JABBER_IQ_SET);
		PurpleXmlNode *data_element = purple_xmlnode_new("data");
		char *base64 = purple_base64_encode(data, size);
		char seq[10];
		g_snprintf(seq, sizeof(seq), "%u", jabber_ibb_session_get_send_seq(sess));

		purple_xmlnode_set_attrib(set->node, "to", jabber_ibb_session_get_who(sess));
		purple_xmlnode_set_namespace(data_element, NS_IBB);
		purple_xmlnode_set_attrib(data_element, "sid", jabber_ibb_session_get_sid(sess));
		purple_xmlnode_set_attrib(data_element, "seq", seq);
		purple_xmlnode_insert_data(data_element, base64, -1);

		purple_xmlnode_insert_child(set->node, data_element);

		purple_debug_info("jabber",
			"IBB: setting send <iq/> callback for session %p %s\n", sess,
			sess->sid);
		jabber_iq_set_callback(set, jabber_ibb_session_send_acknowledge_cb, sess);
		sess->last_iq_id = g_strdup(purple_xmlnode_get_attrib(set->node, "id"));
		purple_debug_info("jabber", "IBB: set sess->last_iq_id: %s\n",
			sess->last_iq_id);
		jabber_iq_send(set);

		g_free(base64);
		(sess->send_seq)++;
	}
}
Пример #12
0
static void jabber_iq_version_parse(JabberStream *js, const char *from,
                                    JabberIqType type, const char *id,
                                    PurpleXmlNode *packet)
{
	JabberIq *iq;
	PurpleXmlNode *query;

	if(type == JABBER_IQ_GET) {
		GHashTable *ui_info;
		const char *ui_name = NULL, *ui_version = NULL;
#if 0
		char *os = NULL;
		if(!purple_prefs_get_bool("/plugins/prpl/jabber/hide_os")) {
			struct utsname osinfo;

			uname(&osinfo);
			os = g_strdup_printf("%s %s %s", osinfo.sysname, osinfo.release,
					osinfo.machine);
		}
#endif

		iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, "jabber:iq:version");
		if (from)
			purple_xmlnode_set_attrib(iq->node, "to", from);
		jabber_iq_set_id(iq, id);

		query = purple_xmlnode_get_child(iq->node, "query");

		ui_info = purple_core_get_ui_info();

		if(NULL != ui_info) {
			ui_name = g_hash_table_lookup(ui_info, "name");
			ui_version = g_hash_table_lookup(ui_info, "version");
		}

		if(NULL != ui_name && NULL != ui_version) {
			char *version_complete = g_strdup_printf("%s (libpurple " VERSION ")", ui_version);
			purple_xmlnode_insert_data(purple_xmlnode_new_child(query, "name"), ui_name, -1);
			purple_xmlnode_insert_data(purple_xmlnode_new_child(query, "version"), version_complete, -1);
			g_free(version_complete);
		} else {
			purple_xmlnode_insert_data(purple_xmlnode_new_child(query, "name"), "libpurple", -1);
			purple_xmlnode_insert_data(purple_xmlnode_new_child(query, "version"), VERSION, -1);
		}

#if 0
		if(os) {
			purple_xmlnode_insert_data(purple_xmlnode_new_child(query, "os"), os, -1);
			g_free(os);
		}
#endif

		jabber_iq_send(iq);
	}
}
Пример #13
0
void
jabber_ibb_session_accept(JabberIBBSession *sess)
{
	JabberIq *result = jabber_iq_new(jabber_ibb_session_get_js(sess),
		JABBER_IQ_RESULT);

	purple_xmlnode_set_attrib(result->node, "to", jabber_ibb_session_get_who(sess));
	jabber_iq_set_id(result, sess->id);
	jabber_iq_send(result);
	sess->state = JABBER_IBB_SESSION_OPENED;
}
static JabberSaslState
digest_md5_start(JabberStream *js, PurpleXmlNode *packet, PurpleXmlNode **response,
                 char **error)
{
	PurpleXmlNode *auth = purple_xmlnode_new("auth");
	purple_xmlnode_set_namespace(auth, NS_XMPP_SASL);
	purple_xmlnode_set_attrib(auth, "mechanism", "DIGEST-MD5");

	*response = auth;
	return JABBER_SASL_STATE_CONTINUE;
}
Пример #15
0
void jabber_iq_set_id(JabberIq *iq, const char *id)
{
	g_free(iq->id);

	if(id) {
		purple_xmlnode_set_attrib(iq->node, "id", id);
		iq->id = g_strdup(id);
	} else {
		purple_xmlnode_remove_attrib(iq->node, "id");
		iq->id = NULL;
	}
}
Пример #16
0
static PurpleXmlNode *
jingle_add_jingle_packet(JingleSession *session,
			 JabberIq *iq, JingleActionType action)
{
	PurpleXmlNode *jingle = iq ?
			purple_xmlnode_new_child(iq->node, "jingle") :
			purple_xmlnode_new("jingle");
	gchar *local_jid = jingle_session_get_local_jid(session);
	gchar *remote_jid = jingle_session_get_remote_jid(session);
	gchar *sid = jingle_session_get_sid(session);

	purple_xmlnode_set_namespace(jingle, JINGLE);
	purple_xmlnode_set_attrib(jingle, "action", jingle_get_action_name(action));

	if (jingle_session_is_initiator(session)) {
		purple_xmlnode_set_attrib(jingle, "initiator", local_jid);
		purple_xmlnode_set_attrib(jingle, "responder", remote_jid);
	} else {
		purple_xmlnode_set_attrib(jingle, "initiator", remote_jid);
		purple_xmlnode_set_attrib(jingle, "responder", local_jid);
	}

	purple_xmlnode_set_attrib(jingle, "sid", sid);

	g_free(local_jid);
	g_free(remote_jid);
	g_free(sid);

	return jingle;
}
Пример #17
0
static void
xep_ft_si_result(PurpleXfer *xfer, const char *to)
{
	PurpleXmlNode *si_node, *feature, *field, *value, *x;
	XepIq *iq;
	XepXfer *xf;
	BonjourData *bd;

	if(!to || !xfer)
		return;
	xf = purple_xfer_get_protocol_data(xfer);
	if(!xf)
		return;

	bd = xf->data;

	purple_debug_info("bonjour", "xep file transfer stream initialization result.\n");
	iq = xep_iq_new(bd, XEP_IQ_RESULT, to, bonjour_get_jid(bd->jabber_data->account), xf->iq_id);
	if(iq == NULL)
		return;

	si_node = purple_xmlnode_new_child(iq->node, "si");
	purple_xmlnode_set_namespace(si_node, "http://jabber.org/protocol/si");
	/*purple_xmlnode_set_attrib(si_node, "profile", "http://jabber.org/protocol/si/profile/file-transfer");*/

	feature = purple_xmlnode_new_child(si_node, "feature");
	purple_xmlnode_set_namespace(feature, "http://jabber.org/protocol/feature-neg");

	x = purple_xmlnode_new_child(feature, "x");
	purple_xmlnode_set_namespace(x, "jabber:x:data");
	purple_xmlnode_set_attrib(x, "type", "submit");

	field = purple_xmlnode_new_child(x, "field");
	purple_xmlnode_set_attrib(field, "var", "stream-method");

	value = purple_xmlnode_new_child(field, "value");
	purple_xmlnode_insert_data(value, "http://jabber.org/protocol/bytestreams", -1);

	xep_iq_send_and_free(iq);
}
Пример #18
0
void
jabber_ibb_session_close(JabberIBBSession *sess)
{
	JabberIBBSessionState state = jabber_ibb_session_get_state(sess);

	if (state != JABBER_IBB_SESSION_OPENED && state != JABBER_IBB_SESSION_ERROR) {
		purple_debug_error("jabber",
			"jabber_ibb_session_close called on a session that has not been"
			"opened\n");
	} else {
		JabberIq *set = jabber_iq_new(jabber_ibb_session_get_js(sess),
			JABBER_IQ_SET);
		PurpleXmlNode *close = purple_xmlnode_new("close");

		purple_xmlnode_set_attrib(set->node, "to", jabber_ibb_session_get_who(sess));
		purple_xmlnode_set_namespace(close, NS_IBB);
		purple_xmlnode_set_attrib(close, "sid", jabber_ibb_session_get_sid(sess));
		purple_xmlnode_insert_child(set->node, close);
		jabber_iq_send(set);
		sess->state = JABBER_IBB_SESSION_CLOSED;
	}
}
Пример #19
0
static void
action_parameter_to_xmlnode(gpointer key, gpointer value, gpointer user_data)
{
	const char *name, *param_value;
	PurpleXmlNode *node, *child;

	name        = (const char *)key;
	param_value = (const char *)value;
	node        = (PurpleXmlNode *)user_data;

	child = purple_xmlnode_new_child(node, "param");
	purple_xmlnode_set_attrib(child, "name", name);
	purple_xmlnode_insert_data(child, param_value, -1);
}
Пример #20
0
static void jabber_iq_last_parse(JabberStream *js, const char *from,
                                 JabberIqType type, const char *id,
                                 PurpleXmlNode *packet)
{
	JabberIq *iq;
	PurpleXmlNode *query;
	char *idle_time;

	if(type == JABBER_IQ_GET) {
		iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, NS_LAST_ACTIVITY);
		jabber_iq_set_id(iq, id);
		if (from)
			purple_xmlnode_set_attrib(iq->node, "to", from);

		query = purple_xmlnode_get_child(iq->node, "query");

		idle_time = g_strdup_printf("%ld", js->idle ? time(NULL) - js->idle : 0);
		purple_xmlnode_set_attrib(query, "seconds", idle_time);
		g_free(idle_time);

		jabber_iq_send(iq);
	}
}
Пример #21
0
static void
xep_ft_si_reject(BonjourData *bd, const char *id, const char *to, const char *error_code, const char *error_type)
{
	PurpleXmlNode *error_node;
	XepIq *iq;

	g_return_if_fail(error_code != NULL);
	g_return_if_fail(error_type != NULL);

	if(!to || !id) {
		purple_debug_info("bonjour", "xep file transfer stream initialization error.\n");
		return;
	}

	iq = xep_iq_new(bd, XEP_IQ_ERROR, to, bonjour_get_jid(bd->jabber_data->account), id);
	if(iq == NULL)
		return;

	error_node = purple_xmlnode_new_child(iq->node, "error");
	purple_xmlnode_set_attrib(error_node, "code", error_code);
	purple_xmlnode_set_attrib(error_node, "type", error_type);

	/* TODO: Make this better */
	if (!strcmp(error_code, "403")) {
		PurpleXmlNode *tmp_node = purple_xmlnode_new_child(error_node, "forbidden");
		purple_xmlnode_set_namespace(tmp_node, "urn:ietf:params:xml:ns:xmpp-stanzas");

		tmp_node = purple_xmlnode_new_child(error_node, "text");
		purple_xmlnode_set_namespace(tmp_node, "urn:ietf:params:xml:ns:xmpp-stanzas");
		purple_xmlnode_insert_data(tmp_node, "Offer Declined", -1);
	} else if (!strcmp(error_code, "404")) {
		PurpleXmlNode *tmp_node = purple_xmlnode_new_child(error_node, "item-not-found");
		purple_xmlnode_set_namespace(tmp_node, "urn:ietf:params:xml:ns:xmpp-stanzas");
	}

	xep_iq_send_and_free(iq);
}
Пример #22
0
void
jabber_gmail_poke(JabberStream *js, const char *from, JabberIqType type,
                  const char *id, PurpleXmlNode *new_mail)
{
	PurpleXmlNode *query;
	JabberIq *iq;

	/* bail if the user isn't interested */
	if (!purple_account_get_check_mail(purple_connection_get_account(js->gc)))
		return;

	/* Is this an initial incoming mail notification? If so, send a request for more info */
	if (type != JABBER_IQ_SET)
		return;

	/* Acknowledge the notification */
	iq = jabber_iq_new(js, JABBER_IQ_RESULT);
	if (from)
		purple_xmlnode_set_attrib(iq->node, "to", from);
	purple_xmlnode_set_attrib(iq->node, "id", id);
	jabber_iq_send(iq);

	purple_debug_misc("jabber",
		   "Got new mail notification. Sending request for more info\n");

	iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_GOOGLE_MAIL_NOTIFY);
	jabber_iq_set_callback(iq, jabber_gmail_parse, NULL);
	query = purple_xmlnode_get_child(iq->node, "query");

	if (js->gmail_last_time)
		purple_xmlnode_set_attrib(query, "newer-than-time", js->gmail_last_time);
	if (js->gmail_last_tid)
		purple_xmlnode_set_attrib(query, "newer-than-tid", js->gmail_last_tid);

	jabber_iq_send(iq);
	return;
}
Пример #23
0
JabberIq *jabber_iq_new(JabberStream *js, JabberIqType type)
{
	JabberIq *iq;

	iq = g_new0(JabberIq, 1);

	iq->type = type;

	iq->node = purple_xmlnode_new("iq");
	switch(iq->type) {
		case JABBER_IQ_SET:
			purple_xmlnode_set_attrib(iq->node, "type", "set");
			break;
		case JABBER_IQ_GET:
			purple_xmlnode_set_attrib(iq->node, "type", "get");
			break;
		case JABBER_IQ_ERROR:
			purple_xmlnode_set_attrib(iq->node, "type", "error");
			break;
		case JABBER_IQ_RESULT:
			purple_xmlnode_set_attrib(iq->node, "type", "result");
			break;
		case JABBER_IQ_NONE:
			/* this shouldn't ever happen */
			break;
	}

	iq->js = js;

	if(type == JABBER_IQ_GET || type == JABBER_IQ_SET) {
		iq->id = jabber_get_next_id(js);
		purple_xmlnode_set_attrib(iq->node, "id", iq->id);
	}

	return iq;
}
Пример #24
0
static PurpleXmlNode *
smiley_to_xmlnode(PurpleSmiley *smiley)
{
	PurpleSmileyPrivate *priv = NULL;
	PurpleXmlNode *smiley_node = NULL;

	smiley_node = purple_xmlnode_new(XML_SMILEY_TAG);

	if (!smiley_node)
		return NULL;

	priv = PURPLE_SMILEY_GET_PRIVATE(smiley);

	purple_xmlnode_set_attrib(smiley_node, XML_SHORTCUT_ATTRIB_TAG,
			priv->shortcut);

	purple_xmlnode_set_attrib(smiley_node, XML_CHECKSUM_ATRIB_TAG,
			priv->checksum);

	purple_xmlnode_set_attrib(smiley_node, XML_FILENAME_ATRIB_TAG,
			purple_imgstore_get_filename(priv->img));

	return smiley_node;
}
Пример #25
0
static PurpleXmlNode *
smileys_to_xmlnode(void)
{
	PurpleXmlNode *root_node, *profile_node, *smileyset_node;

	root_node = purple_xmlnode_new(XML_ROOT_TAG);
	purple_xmlnode_set_attrib(root_node, "version", "1.0");

	/* See the top comments above to understand why initial tag elements
	 * are not being considered by now. */
	profile_node = purple_xmlnode_new(XML_PROFILE_TAG);
	if (profile_node) {
		purple_xmlnode_set_attrib(profile_node, XML_PROFILE_NAME_ATTRIB_TAG, "Default");
		purple_xmlnode_insert_child(root_node, profile_node);

		smileyset_node = purple_xmlnode_new(XML_SMILEY_SET_TAG);
		if (smileyset_node) {
			purple_xmlnode_insert_child(profile_node, smileyset_node);
			g_hash_table_foreach(smiley_shortcut_index, add_smiley_to_main_node, smileyset_node);
		}
	}

	return root_node;
}
Пример #26
0
static void do_nick_set(JabberStream *js, const char *nick) {
	PurpleXmlNode *publish, *nicknode;

	publish = purple_xmlnode_new("publish");
	purple_xmlnode_set_attrib(publish,"node","http://jabber.org/protocol/nick");
	nicknode = purple_xmlnode_new_child(purple_xmlnode_new_child(publish, "item"), "nick");
	purple_xmlnode_set_namespace(nicknode, "http://jabber.org/protocol/nick");

	if(nick && nick[0] != '\0')
		purple_xmlnode_insert_data(nicknode, nick, -1);

	jabber_pep_publish(js, publish);
	/* publish is freed by jabber_pep_publish -> jabber_iq_send -> jabber_iq_free
		(yay for well-defined memory management rules) */
}
Пример #27
0
void
jabber_ibb_session_open(JabberIBBSession *sess)
{
	if (jabber_ibb_session_get_state(sess) != JABBER_IBB_SESSION_NOT_OPENED) {
		purple_debug_error("jabber",
			"jabber_ibb_session called on an already open stream\n");
	} else {
		JabberIq *set = jabber_iq_new(sess->js, JABBER_IQ_SET);
		PurpleXmlNode *open = purple_xmlnode_new("open");
		gchar block_size[10];

		purple_xmlnode_set_attrib(set->node, "to", jabber_ibb_session_get_who(sess));
		purple_xmlnode_set_namespace(open, NS_IBB);
		purple_xmlnode_set_attrib(open, "sid", jabber_ibb_session_get_sid(sess));
		g_snprintf(block_size, sizeof(block_size), "%" G_GSIZE_FORMAT,
			jabber_ibb_session_get_block_size(sess));
		purple_xmlnode_set_attrib(open, "block-size", block_size);
		purple_xmlnode_insert_child(set->node, open);

		jabber_iq_set_callback(set, jabber_ibb_session_opened_cb, sess);

		jabber_iq_send(set);
	}
}
Пример #28
0
static gboolean
msn_oim_request_helper(MsnOimRequestData *data)
{
    MsnSession *session = data->oim->session;

    if (data->send) {
        /* The Sending of OIM's uses a different token for some reason. */
        PurpleXmlNode *ticket;
        ticket = purple_xmlnode_get_child(data->body, "Header/Ticket");
        purple_xmlnode_set_attrib(ticket, "passport",
                                  msn_nexus_get_token_str(session->nexus, MSN_AUTH_LIVE_SECURE));
    }
    else
    {
        PurpleXmlNode *passport;
        PurpleXmlNode *xml_t;
        PurpleXmlNode *xml_p;
        GHashTable *token;
        const char *msn_t;
        const char *msn_p;

        token = msn_nexus_get_token(session->nexus, MSN_AUTH_MESSENGER_WEB);
        g_return_val_if_fail(token != NULL, FALSE);

        msn_t = g_hash_table_lookup(token, "t");
        msn_p = g_hash_table_lookup(token, "p");

        g_return_val_if_fail(msn_t != NULL, FALSE);
        g_return_val_if_fail(msn_p != NULL, FALSE);

        passport = purple_xmlnode_get_child(data->body, "Header/PassportCookie");
        xml_t = purple_xmlnode_get_child(passport, "t");
        xml_p = purple_xmlnode_get_child(passport, "p");

        /* frees old token text, or the 'EMPTY' text if first time */
        purple_xmlnode_free(xml_t->child);
        purple_xmlnode_free(xml_p->child);

        purple_xmlnode_insert_data(xml_t, msn_t, -1);
        purple_xmlnode_insert_data(xml_p, msn_p, -1);
    }

    msn_soap_service_send_message(session->soap,
                                  msn_soap_message_new(data->action, purple_xmlnode_copy(data->body)),
                                  data->host, data->url, FALSE, msn_oim_request_cb, data);

    return FALSE;
}
Пример #29
0
static PurpleXmlNode *
pounces_to_xmlnode(void)
{
	PurpleXmlNode *node, *child;
	GList *cur;

	node = purple_xmlnode_new("pounces");
	purple_xmlnode_set_attrib(node, "version", "1.0");

	for (cur = purple_pounces_get_all(); cur != NULL; cur = cur->next)
	{
		child = pounce_to_xmlnode(cur->data);
		purple_xmlnode_insert_child(node, child);
	}

	return node;
}
Пример #30
0
static void
action_parameter_list_to_xmlnode(gpointer key, gpointer value, gpointer user_data)
{
	const char *action;
	PurplePounceActionData *action_data;
	PurpleXmlNode *node, *child;

	action      = (const char *)key;
	action_data = (PurplePounceActionData *)value;
	node        = (PurpleXmlNode *)user_data;

	if (!action_data->enabled)
		return;

	child = purple_xmlnode_new_child(node, "action");
	purple_xmlnode_set_attrib(child, "type", action);

	g_hash_table_foreach(action_data->atts, action_parameter_to_xmlnode, child);
}