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


C++ xmlnode_get_child函数代码示例

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


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

示例1: msn_oim_request_helper

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. */
		xmlnode *ticket;
		ticket = xmlnode_get_child(data->body, "Header/Ticket");
		xmlnode_set_attrib(ticket, "passport",
			msn_nexus_get_token_str(session->nexus, MSN_AUTH_LIVE_SECURE));
	}
	else
	{
		xmlnode *passport;
		xmlnode *xml_t;
		xmlnode *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 = xmlnode_get_child(data->body, "Header/PassportCookie");
		xml_t = xmlnode_get_child(passport, "t");
		xml_p = xmlnode_get_child(passport, "p");

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

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

	msn_soap_message_send(session,
		msn_soap_message_new(data->action, xmlnode_copy(data->body)),
		data->host, data->url, FALSE,
		msn_oim_request_cb, data);

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

示例2: shinima_message_links_foreach

static void
shinima_message_links_foreach(gchar **message,
							  void(*foreach_func)(xmlnode*,
												  const gchar*,
												  gchar**,
												  gboolean*,
												  gpointer),
							  gboolean *_changed,
							  gpointer *user_data)
{
	xmlnode *root, *a;
	gboolean *changed =
		(_changed != NULL) ? changed : g_malloc(sizeof(gboolean));

	g_return_if_fail(foreach_func != NULL);

	root = xmlnode_from_str(*message, -1);

	for(a=xmlnode_get_child(root, "a"); a; a=xmlnode_get_next_twin(a))
	{
		const gchar *href = xmlnode_get_attrib(a, "href");
		if(href) foreach_func(a, href, message, changed, user_data);
	}

	if(changed)
	{
		g_free(*message);
		*message = xmlnode_to_str(root, NULL);
	}

	if(_changed == NULL) g_free(changed);

	xmlnode_free(root);
}
开发者ID:inickey,项目名称:shinima-pidgin-plugin,代码行数:34,代码来源:shinima-message.c

示例3: 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

示例4: roster_request_cb

static void roster_request_cb(JabberStream *js, const char *from,
                              JabberIqType type, const char *id,
                              xmlnode *packet, gpointer data)
{
	xmlnode *query;

	if (type == JABBER_IQ_ERROR) {
		/*
		 * This shouldn't happen in any real circumstances and
		 * likely constitutes a server-side misconfiguration (i.e.
		 * explicitly not loading mod_roster...)
		 */
		purple_debug_error("jabber", "Error retrieving roster!?\n");
		jabber_stream_set_state(js, JABBER_STREAM_CONNECTED);
		return;
	}

	query = xmlnode_get_child(packet, "query");
	if (query == NULL) {
		jabber_stream_set_state(js, JABBER_STREAM_CONNECTED);
		return;
	}

	jabber_roster_parse(js, from, type, id, query);
	jabber_stream_set_state(js, JABBER_STREAM_CONNECTED);
}
开发者ID:crodjer,项目名称:pidgin_whiteboard,代码行数:26,代码来源:roster.c

示例5: 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

示例6: xmlnode_get_child_with_namespace

xmlnode *
xmlnode_get_child_with_namespace(const xmlnode *parent, const char *name, const char *ns)
{
	xmlnode *x, *ret = NULL;
	char **names;
	char *parent_name, *child_name;

	g_return_val_if_fail(parent != NULL, NULL);
	g_return_val_if_fail(name != NULL, NULL);

	names = g_strsplit(name, "/", 2);
	parent_name = names[0];
	child_name = names[1];

	for(x = parent->child; x; x = x->next) {
		/* XXX: Is it correct to ignore the namespace for the match if none was specified? */
		const char *xmlns = NULL;
		if(ns)
			xmlns = xmlnode_get_namespace(x);

		if(x->type == XMLNODE_TYPE_TAG && name && !strcmp(parent_name, x->name)
				&& (!ns || (xmlns && !strcmp(ns, xmlns)))) {
			ret = x;
			break;
		}
	}

	if(child_name && ret)
		ret = xmlnode_get_child(ret, child_name);

	g_strfreev(names);
	return ret;
}
开发者ID:bf4,项目名称:pidgin-mac,代码行数:33,代码来源:xmlnode.c

示例7: msn_oim_get_read_cb

/* Parse the XML data,
 * prepare to report the OIM to user
 */
static void
msn_oim_get_read_cb(MsnSoapMessage *request, MsnSoapMessage *response,
	gpointer data)
{
	MsnOimRecvData *rdata = data;

	if (response != NULL) {
		xmlnode *msg_node = xmlnode_get_child(response->xml,
			"Body/GetMessageResponse/GetMessageResult");

		if (msg_node) {
			char *msg_str = xmlnode_get_data(msg_node);
			msn_oim_report_to_user(rdata, msg_str);
			g_free(msg_str);
		} else {
			char *str = xmlnode_to_str(response->xml, NULL);
			purple_debug_info("msn", "Unknown OIM response: %s\n", str);
			g_free(str);
			msn_oim_recv_data_free(rdata);
		}
	} else {
		purple_debug_info("msn", "Failed to get OIM\n");
		msn_oim_recv_data_free(rdata);
	}

}
开发者ID:wosigh,项目名称:messaging-plugins,代码行数:29,代码来源:oim.c

示例8: xmlnode_get_child_with_namespace

xmlnode*
xmlnode_get_child_with_namespace(xmlnode *parent, const char *name, const char *ns)
{
	xmlnode *x, *ret = NULL;
	char **names;
	char *parent_name, *child_name;

	g_return_val_if_fail(parent != NULL, NULL);

	names = g_strsplit(name, "/", 2);
	parent_name = names[0];
	child_name = names[1];

	for(x = parent->child; x; x = x->next) {
		const char *xmlns = NULL;
		if(ns)
			xmlns = xmlnode_get_attrib(x, "xmlns");

		if(x->type == XMLNODE_TYPE_TAG && name && !strcmp(parent_name, x->name)
				&& (!ns || (xmlns && !strcmp(ns, xmlns)))) {
			ret = x;
			break;
		}
	}

	if(child_name && ret)
		ret = xmlnode_get_child(ret, child_name);

	g_strfreev(names);
	return ret;
}
开发者ID:BackupTheBerlios,项目名称:koopa-svn,代码行数:31,代码来源:xmlnode.c

示例9: format_message

static char*
format_message(char *sender,
               char *message)
{
    GString* format_message = g_string_new("");
    xmlnode* message_node = xmlnode_from_str(message, -1);

    /* raw */
    if ( !message_node ||
            !( strcmp(message_node->name, "html")==0 ||
               strcmp(message_node->name, "body")==0 )) {
        g_string_printf(format_message, "%s: %s", sender, message);
        return g_string_free(format_message, FALSE);
    }

    xmlnode* body_node =
        (strcmp(message_node->name, "body")) ?
        xmlnode_get_child(message_node, "body") :
        message_node;

    char* message_content = xmlnode_get_content(body_node);
    g_string_printf(format_message, "%s: %s", sender, message_content);
    g_free(message_content);

    xmlnode_free(message_node);

    return g_string_free(format_message, FALSE);
}
开发者ID:bhuztez,项目名称:purple-chatroom-bridge,代码行数:28,代码来源:purple-chatroom-bridge.c

示例10: 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

示例11: 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

示例12: nexus_got_response_cb

static void
nexus_got_response_cb(MsnSoapMessage *req, MsnSoapMessage *resp, gpointer data)
{
	MsnNexus *nexus = data;
	MsnSession *session = nexus->session;
	const char *ticket;
	char *response;

	if (resp == NULL) {
		msn_session_set_error(session, MSN_ERROR_SERVCONN, _("Windows Live ID authentication:Unable to connect"));
		return;
	}

	if (!nexus_parse_collection(nexus, -1,
	                            xmlnode_get_child(resp->xml,
	                                              "Body/RequestSecurityTokenResponseCollection"))) {
		msn_session_set_error(session, MSN_ERROR_SERVCONN, _("Windows Live ID authentication:Invalid response"));
		return;
	}

	ticket = msn_nexus_get_token_str(nexus, MSN_AUTH_MESSENGER);
	response = msn_rps_encrypt(nexus);
	msn_got_login_params(session, ticket, response);
	g_free(response);
}
开发者ID:Lilitana,项目名称:Pidgin,代码行数:25,代码来源:nexus.c

示例13: 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

示例14: jabber_google_session_parse

void
jabber_google_session_parse(JabberStream *js, const char *from,
                            JabberIqType type, const char *iq_id,
                            xmlnode *session_node)
{
	GoogleSession *session = NULL;
	GoogleSessionId id;

	xmlnode *desc_node;

	GList *iter = NULL;

	if (type != JABBER_IQ_SET)
		return;

	id.id = (gchar*)xmlnode_get_attrib(session_node, "id");
	if (!id.id)
		return;

	id.initiator = (gchar*)xmlnode_get_attrib(session_node, "initiator");
	if (!id.initiator)
		return;

	iter = purple_media_manager_get_media_by_account(
			purple_media_manager_get(),
			purple_connection_get_account(js->gc));
	for (; iter; iter = g_list_delete_link(iter, iter)) {
		GoogleSession *gsession =
				purple_media_get_prpl_data(iter->data);
		if (google_session_id_equal(&(gsession->id), &id)) {
			session = gsession;
			break;
		}
	}
	if (iter != NULL) {
		g_list_free(iter);
	}

	if (session) {
		google_session_parse_iq(js, session, session_node, iq_id);
		return;
	}

	/* If the session doesn't exist, this has to be an initiate message */
	if (strcmp(xmlnode_get_attrib(session_node, "type"), "initiate"))
		return;
	desc_node = xmlnode_get_child(session_node, "description");
	if (!desc_node)
		return;
	session = g_new0(GoogleSession, 1);
	session->id.id = g_strdup(id.id);
	session->id.initiator = g_strdup(id.initiator);
	session->state = UNINIT;
	session->js = js;
	session->remote_jid = g_strdup(session->id.initiator);
	session->session_data = g_new0(GoogleAVSessionData, 1);

	google_session_handle_initiate(js, session, session_node, iq_id);
}
开发者ID:wosigh,项目名称:messaging-plugins,代码行数:59,代码来源:google_session.c

示例15: msn_oim_request_cb

static void
msn_oim_request_cb(MsnSoapMessage *request, MsnSoapMessage *response,
	gpointer req_data)
{
	MsnOimRequestData *data = (MsnOimRequestData *)req_data;
	xmlnode *fault = NULL;
	xmlnode *faultcode = NULL;

	if (response == NULL)
		return;

	fault = xmlnode_get_child(response->xml, "Body/Fault");
	if (fault)
		faultcode = xmlnode_get_child(fault, "faultcode");

	if (faultcode) {
		gchar *faultcode_str = xmlnode_get_data(faultcode);
		gboolean need_token_update = FALSE;

		if (faultcode_str) {
			if (g_str_equal(faultcode_str, "q0:BadContextToken") ||
				g_str_equal(faultcode_str, "AuthenticationFailed"))
				need_token_update = TRUE;
			else if (g_str_equal(faultcode_str, "q0:AuthenticationFailed") &&
				xmlnode_get_child(fault, "detail/RequiredAuthPolicy") != NULL)
				need_token_update = TRUE;
		}

		if (need_token_update) {
			purple_debug_warning("msn", "OIM Request Error, Updating token now.\n");
			msn_nexus_update_token(data->oim->session->nexus,
				data->send ? MSN_AUTH_LIVE_SECURE : MSN_AUTH_MESSENGER_WEB,
				(GSourceFunc)msn_oim_request_helper, data);
			g_free(faultcode_str);
			return;

		}

		g_free(faultcode_str);
	}

	if (data->cb)
		data->cb(request, response, data->cb_data);
	xmlnode_free(data->body);
	g_free(data);
}
开发者ID:Mons,项目名称:libpurple-mini,代码行数:46,代码来源:oim.c


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