当前位置: 首页>>代码示例>>C++>>正文


C++ xmlnode_set_attrib函数代码示例

本文整理汇总了C++中xmlnode_set_attrib函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlnode_set_attrib函数的具体用法?C++ xmlnode_set_attrib怎么用?C++ xmlnode_set_attrib使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了xmlnode_set_attrib函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: jabber_chat_kick_user

gboolean jabber_chat_kick_user(JabberChat *chat, const char *who, const char *why)
{
	JabberIq *iq;
	JabberChatMember *jcm = g_hash_table_lookup(chat->members, who);
	char *to;
	xmlnode *query, *item, *reason;

	if(!jcm || !jcm->jid)
		return FALSE;

	iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET,
			"http://jabber.org/protocol/muc#admin");

	to = g_strdup_printf("%[email protected]%s", chat->room, chat->server);
	xmlnode_set_attrib(iq->node, "to", to);
	g_free(to);

	query = xmlnode_get_child(iq->node, "query");
	item = xmlnode_new_child(query, "item");
	xmlnode_set_attrib(item, "jid", jcm->jid);
	xmlnode_set_attrib(item, "role", "none");
	if(why) {
		reason = xmlnode_new_child(item, "reason");
		xmlnode_insert_data(reason, why, -1);
	}

	jabber_iq_send(iq);

	return TRUE;
}
开发者ID:arminius2,项目名称:apolloim,代码行数:30,代码来源:chat.c

示例2: jabber_si_bytestreams_connect_cb

static void
jabber_si_bytestreams_connect_cb(gpointer data, gint source, const gchar *error_message)
{
	GaimXfer *xfer = data;
	JabberSIXfer *jsx = xfer->data;
	JabberIq *iq;
	xmlnode *query, *su;
	struct bytestreams_streamhost *streamhost = jsx->streamhosts->data;

	gaim_proxy_info_destroy(jsx->gpi);
	jsx->connect_data = NULL;

	if(source < 0) {
		jsx->streamhosts = g_list_remove(jsx->streamhosts, streamhost);
		g_free(streamhost->jid);
		g_free(streamhost->host);
		g_free(streamhost);
		jabber_si_bytestreams_attempt_connect(xfer);
		return;
	}

	iq = jabber_iq_new_query(jsx->js, JABBER_IQ_RESULT, "http://jabber.org/protocol/bytestreams");
	xmlnode_set_attrib(iq->node, "to", xfer->who);
	jabber_iq_set_id(iq, jsx->iq_id);
	query = xmlnode_get_child(iq->node, "query");
	su = xmlnode_new_child(query, "streamhost-used");
	xmlnode_set_attrib(su, "jid", streamhost->jid);

	jabber_iq_send(iq);

	gaim_xfer_start(xfer, source, NULL, -1);
}
开发者ID:VoxOx,项目名称:VoxOx,代码行数:32,代码来源:si.c

示例3: jabber_chat_affiliate_user

gboolean jabber_chat_affiliate_user(JabberChat *chat, const char *who, const char *affiliation)
{
	JabberChatMember *jcm;
	const char *jid;
	char *to;
	JabberIq *iq;
	xmlnode *query, *item;

	jcm = g_hash_table_lookup(chat->members, who);
	if (jcm && jcm->jid)
		jid = jcm->jid;
	else if (strchr(who, '@') != NULL)
		jid = who;
	else
		return FALSE;

	iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET,
			"http://jabber.org/protocol/muc#admin");

	to = g_strdup_printf("%[email protected]%s", chat->room, chat->server);
	xmlnode_set_attrib(iq->node, "to", to);
	g_free(to);

	query = xmlnode_get_child(iq->node, "query");
	item = xmlnode_new_child(query, "item");
	xmlnode_set_attrib(item, "jid", jid);
	xmlnode_set_attrib(item, "affiliation", affiliation);

	jabber_iq_send(iq);

	return TRUE;
}
开发者ID:Mons,项目名称:libpurple-mini,代码行数:32,代码来源:chat.c

示例4: jabber_data_parse

void
jabber_data_parse(JabberStream *js, const char *who, JabberIqType type,
                  const char *id, xmlnode *data_node)
{
    JabberIq *result = NULL;
    const char *cid = xmlnode_get_attrib(data_node, "cid");
    const JabberData *data = cid ? jabber_data_find_local_by_cid(cid) : NULL;

    if (!data) {
        xmlnode *item_not_found = xmlnode_new("item-not-found");

        result = jabber_iq_new(js, JABBER_IQ_ERROR);
        if (who)
            xmlnode_set_attrib(result->node, "to", who);
        xmlnode_set_attrib(result->node, "id", id);
        xmlnode_insert_child(result->node, item_not_found);
    } else {
        result = jabber_iq_new(js, JABBER_IQ_RESULT);
        if (who)
            xmlnode_set_attrib(result->node, "to", who);
        xmlnode_set_attrib(result->node, "id", id);
        xmlnode_insert_child(result->node,
                             jabber_data_get_xml_definition(data));
    }
    jabber_iq_send(result);
}
开发者ID:psunkari,项目名称:spicebird,代码行数:26,代码来源:data.c

示例5: jabber_iq_last_parse

static void jabber_iq_last_parse(JabberStream *js, xmlnode *packet)
{
	JabberIq *iq;
	const char *type;
	const char *from;
	const char *id;
	xmlnode *query;
	char *idle_time;

	type = xmlnode_get_attrib(packet, "type");
	from = xmlnode_get_attrib(packet, "from");
	id = xmlnode_get_attrib(packet, "id");

	if(type && !strcmp(type, "get")) {
		iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, "jabber:iq:last");
		jabber_iq_set_id(iq, id);
		xmlnode_set_attrib(iq->node, "to", from);

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

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

		jabber_iq_send(iq);
	}
}
开发者ID:bf4,项目名称:pidgin-mac,代码行数:27,代码来源:iq.c

示例6: google_session_stream_info_cb

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) {
		xmlnode *sess;
		JabberIq *iq = jabber_iq_new(session->js, JABBER_IQ_SET);

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

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

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

		jabber_iq_send(iq);
	} else if (type == PURPLE_MEDIA_INFO_ACCEPT && local == TRUE) {
		google_session_ready(session);
	}
}
开发者ID:wosigh,项目名称:messaging-plugins,代码行数:30,代码来源:google_session.c

示例7: GetBuddyInfo

void GetBuddyInfo(struct fetion_account_data *sip, const char *who)
{
	gint xml_len;
	xmlnode *root, *son, *item;
	gchar *body;

	root = xmlnode_new("args");
	g_return_if_fail(root != NULL);
	son = xmlnode_new_child(root, "contacts");
	xmlnode_set_attrib(son, "attributes", "all");
	//xmlnode_set_attrib(son,"extended-attributes","score-level");
	g_return_if_fail(son != NULL);
	item = xmlnode_new_child(son, "contact");
	g_return_if_fail(item != NULL);

	xmlnode_set_attrib(item, "uri", who);

	body = g_strdup_printf("%s",xmlnode_to_str(root, &xml_len));
	purple_debug_info("fetion:", "GetBuddyInfo:body=[%s]", body);

	send_sip_request(sip->gc, "S", "", "", "N: GetContactsInfo\r\n", body,
			 NULL, (TransCallback) GetBuddyInfo_cb);

	xmlnode_free(root);
	g_free(body);

}
开发者ID:lichengjie,项目名称:fetion,代码行数:27,代码来源:f_buddy.c

示例8: jabber_chat_role_user

gboolean jabber_chat_role_user(JabberChat *chat, const char *who, const char *role)
{
	char *to;
	JabberIq *iq;
	xmlnode *query, *item;
	JabberChatMember *jcm;

	jcm = g_hash_table_lookup(chat->members, who);

	if (!jcm || !jcm->handle)
		return FALSE;

	iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET,
	                         "http://jabber.org/protocol/muc#admin");

	to = g_strdup_printf("%[email protected]%s", chat->room, chat->server);
	xmlnode_set_attrib(iq->node, "to", to);
	g_free(to);

	query = xmlnode_get_child(iq->node, "query");
	item = xmlnode_new_child(query, "item");
	xmlnode_set_attrib(item, "nick", jcm->handle);
	xmlnode_set_attrib(item, "role", role);

	jabber_iq_send(iq);

	return TRUE;
}
开发者ID:arminius2,项目名称:apolloim,代码行数:28,代码来源:chat.c

示例9: google_session_create_xmlnode

static xmlnode *
google_session_create_xmlnode(GoogleSession *session, const char *type)
{
	xmlnode *node = xmlnode_new("session");
	xmlnode_set_namespace(node, NS_GOOGLE_SESSION);
	xmlnode_set_attrib(node, "id", session->id.id);
	xmlnode_set_attrib(node, "initiator", session->id.initiator);
	xmlnode_set_attrib(node, "type", type);
	return node;
}
开发者ID:wosigh,项目名称:messaging-plugins,代码行数:10,代码来源:google_session.c

示例10: jabber_si_xfer_bytestreams_listen_cb

static void
jabber_si_xfer_bytestreams_listen_cb(int sock, gpointer data)
{
	GaimXfer *xfer = data;
	JabberSIXfer *jsx;
	JabberIq *iq;
	xmlnode *query, *streamhost;
	char *jid, *port;

	jsx = xfer->data;
	jsx->listen_data = NULL;

	if (gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_CANCEL_LOCAL) {
		gaim_xfer_unref(xfer);
		return;
	}

	gaim_xfer_unref(xfer);

	if (sock < 0) {
		gaim_xfer_cancel_local(xfer);
		return;
	}

	iq = jabber_iq_new_query(jsx->js, JABBER_IQ_SET,
			"http://jabber.org/protocol/bytestreams");
	xmlnode_set_attrib(iq->node, "to", xfer->who);
	query = xmlnode_get_child(iq->node, "query");

	xmlnode_set_attrib(query, "sid", jsx->stream_id);

	streamhost = xmlnode_new_child(query, "streamhost");
	jid = g_strdup_printf("%[email protected]%s/%s", jsx->js->user->node,
			jsx->js->user->domain, jsx->js->user->resource);
	xmlnode_set_attrib(streamhost, "jid", jid);
	g_free(jid);

	/* XXX: shouldn't we use the public IP or something? here */
	xmlnode_set_attrib(streamhost, "host",
			gaim_network_get_my_ip(jsx->js->fd));
	xfer->local_port = gaim_network_get_port_from_fd(sock);
	port = g_strdup_printf("%hu", xfer->local_port);
	xmlnode_set_attrib(streamhost, "port", port);
	g_free(port);

	xfer->watcher = gaim_input_add(sock, GAIM_INPUT_READ,
			jabber_si_xfer_bytestreams_send_connected_cb, xfer);

	/* XXX: insert proxies here */

	/* XXX: callback to find out which streamhost they used, or see if they
	 * screwed it up */
	jabber_iq_send(iq);

}
开发者ID:VoxOx,项目名称:VoxOx,代码行数:55,代码来源:si.c

示例11: jabber_chat_invite

void jabber_chat_invite(PurpleConnection *gc, int id, const char *msg,
		const char *name)
{
	JabberStream *js = gc->proto_data;
	JabberChat *chat;
	xmlnode *message, *body, *x, *invite;
	char *room_jid;

	chat = jabber_chat_find_by_id(js, id);
	if(!chat)
		return;

	message = xmlnode_new("message");

	room_jid = g_strdup_printf("%[email protected]%s", chat->room, chat->server);

	if(chat->muc) {
		xmlnode_set_attrib(message, "to", room_jid);
		x = xmlnode_new_child(message, "x");
		xmlnode_set_namespace(x, "http://jabber.org/protocol/muc#user");
		invite = xmlnode_new_child(x, "invite");
		xmlnode_set_attrib(invite, "to", name);
		if (msg) {
			body = xmlnode_new_child(invite, "reason");
			xmlnode_insert_data(body, msg, -1);
		}
	} else {
		xmlnode_set_attrib(message, "to", name);
		/*
		 * Putting the reason into the body was an 'undocumented protocol,
		 * ...not part of "groupchat 1.0"'.
		 * http://xmpp.org/extensions/attic/jep-0045-1.16.html#invite
		 *
		 * Left here for compatibility.
		 */
		if (msg) {
			body = xmlnode_new_child(message, "body");
			xmlnode_insert_data(body, msg, -1);
		}

		x = xmlnode_new_child(message, "x");
		xmlnode_set_attrib(x, "jid", room_jid);

		/* The better place for it! XEP-0249 style. */
		if (msg)
			xmlnode_set_attrib(x, "reason", msg);
		xmlnode_set_namespace(x, "jabber:x:conference");
	}

	jabber_send(js, message);
	xmlnode_free(message);
	g_free(room_jid);
}
开发者ID:Lilitana,项目名称:Pidgin,代码行数:53,代码来源:chat.c

示例12: jabber_data_get_xhtml_im

xmlnode *
jabber_data_get_xhtml_im(const JabberData *data, const gchar *alt)
{
    xmlnode *img = xmlnode_new("img");
    char src[128];

    xmlnode_set_attrib(img, "alt", alt);
    g_snprintf(src, sizeof(src), "cid:%s", data->cid);
    xmlnode_set_attrib(img, "src", src);

    return img;
}
开发者ID:psunkari,项目名称:spicebird,代码行数:12,代码来源:data.c

示例13: jabber_mam_request

void jabber_mam_request(JabberStream *js, const char* after)
{
	if (!js->mam)
		return;
	
	JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_SET, NS_XMPP_MAM);
	xmlnode *query = xmlnode_get_child(iq->node, "query");

	xmlnode *x = xmlnode_new_child(query, "x");
	xmlnode_set_namespace(x, "jabber:x:data");

	xmlnode *field = xmlnode_new_child(x, "field");
	xmlnode_set_attrib(field, "type", "hidden");
	xmlnode_set_attrib(field, "var", "FORM_TYPE");
	xmlnode *value = xmlnode_new_child(field, "value");
	xmlnode_insert_data(value, NS_XMPP_MAM, -1);

	if (after) {
		xmlnode *set = xmlnode_new_child(query, "set");
		xmlnode_set_namespace(set, NS_RSM);

		value = xmlnode_new_child(set, "after");
		xmlnode_insert_data(value, after, -1);
	}

	if (js->mam->current->start) {
		field = xmlnode_new_child(x, "field");
		xmlnode_set_attrib(field, "var", "start");

		value = xmlnode_new_child(field, "value");
		xmlnode_insert_data(value, js->mam->current->start, -1);
	}

	if (js->mam->current->end) {
		field = xmlnode_new_child(x, "field");
		xmlnode_set_attrib(field, "var", "end");

		value = xmlnode_new_child(field, "value");
		xmlnode_insert_data(value, js->mam->current->end, -1);
	}

	if (js->mam->current->with) {
		field = xmlnode_new_child(x, "field");
		xmlnode_set_attrib(field, "var", "with");

		value = xmlnode_new_child(field, "value");
		xmlnode_insert_data(value, js->mam->current->with, -1);
	}

	jabber_iq_send(iq);
}
开发者ID:Draghtnod,项目名称:pidgin,代码行数:51,代码来源:mam.c

示例14: bonjour_bytestreams_listen

static void
bonjour_bytestreams_listen(int sock, gpointer data)
{
	PurpleXfer *xfer = data;
	XepXfer *xf;
	XepIq *iq;
	xmlnode *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;
	}

	xfer->watcher = purple_input_add(sock, PURPLE_INPUT_READ,
					 bonjour_sock5_request_cb, xfer);
	xf = (XepXfer*)xfer->data;
	xf->listen_data = NULL;

	bd = xf->data;

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

	query = xmlnode_new_child(iq->node, "query");
	xmlnode_set_namespace(query, "http://jabber.org/protocol/bytestreams");
	xmlnode_set_attrib(query, "sid", xf->sid);
	xmlnode_set_attrib(query, "mode", "tcp");

	xfer->local_port = purple_network_get_port_from_fd(sock);

	local_ips = bonjour_jabber_get_local_ips(sock);

	port = g_strdup_printf("%hu", (guint16)purple_xfer_get_local_port(xfer));
	while(local_ips) {
		streamhost = xmlnode_new_child(query, "streamhost");
		xmlnode_set_attrib(streamhost, "jid", xf->sid);
		xmlnode_set_attrib(streamhost, "host", local_ips->data);
		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);
}
开发者ID:dylex,项目名称:pidgin,代码行数:48,代码来源:bonjour_ft.c

示例15: add_ipv6_link_local_ifaces

/**
 * 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(xmlnode *cur_streamhost, const char *host,
			   const PurpleBuddy *pb) {
	xmlnode *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 xmlnode twin copy for %s with new host address %s\n",
				  host, (char*)ip_elem->data);
		new_streamhost = xmlnode_insert_twin_copy(cur_streamhost);
		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;
}
开发者ID:dylex,项目名称:pidgin,代码行数:49,代码来源:bonjour_ft.c


注:本文中的xmlnode_set_attrib函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。