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


C++ xmlnode_get_attrib函数代码示例

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


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

示例1: xmlnode_get_child

static gfire_game_configuration *gfire_game_configuration_create_from_xml(xmlnode *p_node)
{
	xmlnode *command_node = xmlnode_get_child(p_node, "command");
	if(!command_node)
		return NULL;

	gfire_game_configuration *ret = g_malloc0(sizeof(gfire_game_configuration));

	if(xmlnode_get_attrib(p_node, "id"))
		sscanf(xmlnode_get_attrib(p_node, "id"), "%u", &ret->game_id);

	xmlnode *cur_node = xmlnode_get_child(command_node, "detect");
	if(cur_node)
		ret->detect_file = xmlnode_get_data_unescaped(cur_node);

	cur_node = xmlnode_get_child(command_node, "launch");
	if(cur_node)
		ret->launch_file = xmlnode_get_data_unescaped(cur_node);

	cur_node = xmlnode_get_child(command_node, "prefix");
	if(cur_node)
		ret->launch_prefix = xmlnode_get_data_unescaped(cur_node);

	return ret;
}
开发者ID:wosigh,项目名称:messaging-plugins,代码行数:25,代码来源:gf_games.c

示例2: base_to_deliver

result base_to_deliver(instance id, dpacket p, void *arg)
{
	char *log_data = xmlnode_get_data(p->x);
	char *subject;
	xmlnode message;

	if (log_data == NULL)
		return r_ERR;

	message = xmlnode_new_tag("message");

	xmlnode_insert_cdata(xmlnode_insert_tag(message, "body"), log_data,
			     -1);
	subject =
	    spools(xmlnode_pool(message), "Log Packet from ",
		   xmlnode_get_attrib(p->x, "from"),
		   xmlnode_pool(message));
	xmlnode_insert_cdata(xmlnode_insert_tag(message, "thread"),
			     shahash(subject), -1);
	xmlnode_insert_cdata(xmlnode_insert_tag(message, "subject"),
			     subject, -1);
	xmlnode_put_attrib(message, "from",
			   xmlnode_get_attrib(p->x, "from"));
	xmlnode_put_attrib(message, "to", (char *) arg);

	deliver(dpacket_new(message), id);
	pool_free(p->p);

	return r_DONE;
}
开发者ID:smokku,项目名称:wpjabber,代码行数:30,代码来源:base_to.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: 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

示例5: jabber_iq_version_parse

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

	type = xmlnode_get_attrib(packet, "type");

	if(type && !strcmp(type, "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
		from = xmlnode_get_attrib(packet, "from");
		id = xmlnode_get_attrib(packet, "id");

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

		query = 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);
			xmlnode_insert_data(xmlnode_new_child(query, "name"), ui_name, -1);
			xmlnode_insert_data(xmlnode_new_child(query, "version"), version_complete, -1);
			g_free(version_complete);
		} else {
			xmlnode_insert_data(xmlnode_new_child(query, "name"), "libpurple", -1);
			xmlnode_insert_data(xmlnode_new_child(query, "version"), VERSION, -1);
		}

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

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

示例6: jutil_tofrom

void jutil_tofrom(xmlnode x)
{
    char *to, *from;

    to = xmlnode_get_attrib(x,"to");
    from = xmlnode_get_attrib(x,"from");
    xmlnode_put_attrib(x,"from",to);
    xmlnode_put_attrib(x,"to",from);
}
开发者ID:GunioRobot,项目名称:jab_simul,代码行数:9,代码来源:jutil.c

示例7: jabber_chat_room_configure_cb

static void jabber_chat_room_configure_cb(JabberStream *js, xmlnode *packet, gpointer data)
{
	xmlnode *query, *x;
	const char *type = xmlnode_get_attrib(packet, "type");
	const char *from = xmlnode_get_attrib(packet, "from");
	char *msg;
	JabberChat *chat;
	JabberID *jid;

	if(!type || !from)
		return;



	if(!strcmp(type, "result")) {
		jid = jabber_id_new(from);

		if(!jid)
			return;

		chat = jabber_chat_find(js, jid->node, jid->domain);
		jabber_id_free(jid);

		if(!chat)
			return;

		if(!(query = xmlnode_get_child(packet, "query")))
			return;

		for(x = xmlnode_get_child(query, "x"); x; x = xmlnode_get_next_twin(x)) {
			const char *xmlns;
			if(!(xmlns = xmlnode_get_namespace(x)))
				continue;

			if(!strcmp(xmlns, "jabber:x:data")) {
				chat->config_dialog_type = PURPLE_REQUEST_FIELDS;
				chat->config_dialog_handle = jabber_x_data_request(js, x, jabber_chat_room_configure_x_data_cb, chat);
				return;
			}
		}
	} else if(!strcmp(type, "error")) {
		char *msg = jabber_parse_error(js, packet);

		purple_notify_error(js->gc, _("Configuration error"), _("Configuration error"), msg);

		if(msg)
			g_free(msg);
		return;
	}

	msg = g_strdup_printf("Unable to configure room %s", from);

	purple_notify_info(js->gc, _("Unable to configure"), _("Unable to configure"), msg);
	g_free(msg);

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

示例8: roomlist_disco_result_cb

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

	if(!js->roomlist)
		return;

	if (type == JABBER_IQ_ERROR) {
		char *err = jabber_parse_error(js, packet, NULL);
		purple_notify_error(js->gc, _("Error"),
				_("Error retrieving room list"), err);
		purple_roomlist_set_in_progress(js->roomlist, FALSE);
		purple_roomlist_unref(js->roomlist);
		js->roomlist = NULL;
		g_free(err);
		return;
	}

	if(!(query = xmlnode_get_child(packet, "query"))) {
		char *err = jabber_parse_error(js, packet, NULL);
		purple_notify_error(js->gc, _("Error"),
				_("Error retrieving room list"), err);
		purple_roomlist_set_in_progress(js->roomlist, FALSE);
		purple_roomlist_unref(js->roomlist);
		js->roomlist = NULL;
		g_free(err);
		return;
	}

	for(item = xmlnode_get_child(query, "item"); item;
			item = xmlnode_get_next_twin(item)) {
		const char *name;
		PurpleRoomlistRoom *room;
		JabberID *jid;

		if(!(jid = jabber_id_new(xmlnode_get_attrib(item, "jid"))))
			continue;
		name = xmlnode_get_attrib(item, "name");


		room = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_ROOM, jid->node, NULL);
		purple_roomlist_room_add_field(js->roomlist, room, jid->node);
		purple_roomlist_room_add_field(js->roomlist, room, jid->domain);
		purple_roomlist_room_add_field(js->roomlist, room, name ? name : "");
		purple_roomlist_room_add(js->roomlist, room);

		jabber_id_free(jid);
	}
	purple_roomlist_set_in_progress(js->roomlist, FALSE);
	purple_roomlist_unref(js->roomlist);
	js->roomlist = NULL;
}
开发者ID:Mons,项目名称:libpurple-mini,代码行数:55,代码来源:chat.c

示例9: gfire_game_load_config_xml

gboolean gfire_game_load_config_xml(gboolean p_force)
{
	if(!p_force && gfire_games_config)
		return TRUE;

	xmlnode *node = NULL;

	gchar *filename = g_build_filename(purple_user_dir(), "gfire_game_config.xml", NULL);
	if(filename)
	{
		purple_debug(PURPLE_DEBUG_INFO, "gfire", "Loading Game Launch Data from: %s\n", filename);
		g_free(filename);
	}

	node = purple_util_read_xml_from_file("gfire_game_config.xml", "Gfire Game Config List");
	if(!node)
	{
		purple_debug(PURPLE_DEBUG_ERROR, "gfire", "gfire_game_load_config_xml: Couldn't load game config.\n");
		return FALSE;
	}

	// Check for a valid game config
	if(g_utf8_collate(node->name, "game_config"))
	{
		xmlnode_free(node);
		return FALSE;
	}

	// Check for a valid version
	if(!xmlnode_get_attrib(node, "version") || g_utf8_collate(xmlnode_get_attrib(node, "version"), "2"))
	{
		xmlnode_free(node);
		return FALSE;
	}

	// Delete all old configurations
	gfire_game_config_cleanup();

	// Parse all games
	xmlnode *game_node = xmlnode_get_child(node, "game");
	while(game_node)
	{
		gfire_game_configuration *gconf = gfire_game_configuration_create_from_xml(game_node);
		if(gconf)
			gfire_games_config = g_list_append(gfire_games_config, gconf);

		game_node = xmlnode_get_next_twin(game_node);
	}

	gfire_game_config_sort();

	xmlnode_free(node);

	return TRUE;
}
开发者ID:wosigh,项目名称:messaging-plugins,代码行数:55,代码来源:gf_games.c

示例10: roomlist_disco_result_cb

static void roomlist_disco_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
{
	xmlnode *query;
	xmlnode *item;
	const char *type;

	if(!js->roomlist)
		return;

	if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "result")) {
		char *err = jabber_parse_error(js,packet);
		gaim_notify_error(js->gc, _("Error"),
				_("Error retrieving room list"), err);
		gaim_roomlist_set_in_progress(js->roomlist, FALSE);
		gaim_roomlist_unref(js->roomlist);
		js->roomlist = NULL;
		g_free(err);
		return;
	}

	if(!(query = xmlnode_get_child(packet, "query"))) {
		char *err = jabber_parse_error(js, packet);
		gaim_notify_error(js->gc, _("Error"),
				_("Error retrieving room list"), err);
		gaim_roomlist_set_in_progress(js->roomlist, FALSE);
		gaim_roomlist_unref(js->roomlist);
		js->roomlist = NULL;
		g_free(err);
		return;
	}

	for(item = xmlnode_get_child(query, "item"); item;
			item = xmlnode_get_next_twin(item)) {
		const char *name;
		GaimRoomlistRoom *room;
		JabberID *jid;

		if(!(jid = jabber_id_new(xmlnode_get_attrib(item, "jid"))))
			continue;
		name = xmlnode_get_attrib(item, "name");


		room = gaim_roomlist_room_new(GAIM_ROOMLIST_ROOMTYPE_ROOM, jid->node, NULL);
		gaim_roomlist_room_add_field(js->roomlist, room, jid->node);
		gaim_roomlist_room_add_field(js->roomlist, room, jid->domain);
		gaim_roomlist_room_add_field(js->roomlist, room, name ? name : "");
		gaim_roomlist_room_add(js->roomlist, room);

		jabber_id_free(jid);
	}
	gaim_roomlist_set_in_progress(js->roomlist, FALSE);
	gaim_roomlist_unref(js->roomlist);
	js->roomlist = NULL;
}
开发者ID:VoxOx,项目名称:VoxOx,代码行数:54,代码来源:chat.c

示例11: jingle_parse

void
jingle_parse(JabberStream *js, const char *from, JabberIqType type,
             const char *id, xmlnode *jingle)
{
	const gchar *action;
	const gchar *sid;
	JingleActionType action_type;
	JingleSession *session;

	if (type != JABBER_IQ_SET) {
		/* TODO: send iq error here */
		return;
	}

	if (!(action = xmlnode_get_attrib(jingle, "action"))) {
		/* TODO: send iq error here */
		return;
	}

	action_type = jingle_get_action_type(action);

	purple_debug_info("jabber", "got Jingle package action = %s\n",
			  action);

	if (!(sid = xmlnode_get_attrib(jingle, "sid"))) {
		/* send iq error here */
		return;
	}

	if (!(session = jingle_session_find_by_sid(js, sid))
			&& strcmp(action, "session-initiate")) {
		purple_debug_error("jingle", "jabber_jingle_session_parse couldn't find session\n");
		/* send iq error here */
		return;
	}

	if (action_type == JINGLE_SESSION_INITIATE) {
		if (session) {
			/* This should only happen if you start a session with yourself */
			purple_debug_error("jingle", "Jingle session with "
					"id={%s} already exists\n", sid);
			/* send iq error */
			return;
		} else {
			char *own_jid = g_strdup_printf("%[email protected]%s/%s", js->user->node,
					js->user->domain, js->user->resource);
			session = jingle_session_create(js, sid, own_jid, from, FALSE);
			g_free(own_jid);
		}
	}

	jingle_actions[action_type].handler(session, jingle);
}
开发者ID:crodjer,项目名称:pidgin_whiteboard,代码行数:53,代码来源:jingle.c

示例12: gfire_game_load_games_xml

gboolean gfire_game_load_games_xml()
{
	xmlnode *node = NULL;

	gchar *filename = g_build_filename(purple_user_dir(), "gfire_games.xml", NULL);
	if(filename)
	{
		purple_debug(PURPLE_DEBUG_INFO, "gfire", "Loading Game Data from: %s\n", filename);
		g_free(filename);
	}

	node = purple_util_read_xml_from_file("gfire_games.xml", "Gfire Games List");
	if(!node)
	{
		purple_debug(PURPLE_DEBUG_ERROR, "gfire", "gfire_game_load_games_xml: Couldn't load game list.\n");
		return FALSE;
	}

	// Delete all old games
	gfire_game_cleanup();

	// Read the games version
	if(g_utf8_collate(node->name, "games"))
	{
		xmlnode_free(node);
		return FALSE;
	}

	if(!xmlnode_get_attrib(node, "version"))
		gfire_games_version = 0;
	else
		sscanf(xmlnode_get_attrib(node, "version"), "%u", &gfire_games_version);

	// Read all games
	xmlnode *game_node = xmlnode_get_child(node, "game");
	while(game_node)
	{
		gboolean external = FALSE;
		gfire_game *game = gfire_game_create_from_xml(game_node, &external);
		if(game)
		{
			gfire_games = g_list_append(gfire_games, game);
			if(external)
				gfire_games_external = g_list_append(gfire_games_external, game);
		}

		game_node = xmlnode_get_next_twin(game_node);
	}

	xmlnode_free(node);

	return TRUE;
}
开发者ID:wosigh,项目名称:messaging-plugins,代码行数:53,代码来源:gf_games.c

示例13: jingle_handle_content_accept

static void
jingle_handle_content_accept(JingleSession *session, xmlnode *jingle)
{
	xmlnode *content = xmlnode_get_child(jingle, "content");
	jabber_iq_send(jingle_session_create_ack(session, jingle));

	for (; content; content = xmlnode_get_next_twin(content)) {
		const gchar *name = xmlnode_get_attrib(content, "name");
		const gchar *creator = xmlnode_get_attrib(content, "creator");
		jingle_session_accept_content(session, name, creator);
		/* signal here */
	}
}
开发者ID:crodjer,项目名称:pidgin_whiteboard,代码行数:13,代码来源:jingle.c

示例14: jabber_iq_time_parse

static void jabber_iq_time_parse(JabberStream *js, xmlnode *packet)
{
	const char *type, *from, *id, *xmlns;
	JabberIq *iq;
	xmlnode *query;
	time_t now_t;
	struct tm *now;

	time(&now_t);
	now = localtime(&now_t);

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

	/* we're gonna throw this away in a moment, but we need it
	 * to get the xmlns, so we can figure out if this is
	 * jabber:iq:time or urn:xmpp:time */
	query = xmlnode_get_child(packet, "query");
	xmlns = xmlnode_get_namespace(query);

	if(type && !strcmp(type, "get")) {
		xmlnode *utc;
		const char *date;

		iq = jabber_iq_new_query(js, JABBER_IQ_RESULT, xmlns);
		jabber_iq_set_id(iq, id);
		xmlnode_set_attrib(iq->node, "to", from);

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

		date = purple_utf8_strftime("%Y%m%dT%T", now);
		utc = xmlnode_new_child(query, "utc");
		xmlnode_insert_data(utc, date, -1);

		if(!strcmp("urn:xmpp:time", xmlns)) {
			xmlnode_insert_data(utc, "Z", 1); /* of COURSE the thing that is the same is different */

			date = purple_get_tzoff_str(now, TRUE);
			xmlnode_insert_data(xmlnode_new_child(query, "tzo"), date, -1);
		} else { /* jabber:iq:time */
			date = purple_utf8_strftime("%Z", now);
			xmlnode_insert_data(xmlnode_new_child(query, "tz"), date, -1);

			date = purple_utf8_strftime("%d %b %Y %T", now);
			xmlnode_insert_data(xmlnode_new_child(query, "display"), date, -1);
		}

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

示例15: jabber_oob_parse

void jabber_oob_parse(JabberStream *js, xmlnode *packet) {
	JabberOOBXfer *jox;
	PurpleXfer *xfer;
	char *filename;
	char *url;
	const char *type;
	xmlnode *querynode, *urlnode;

	if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "set"))
		return;

	if(!(querynode = xmlnode_get_child(packet, "query")))
		return;

	if(!(urlnode = xmlnode_get_child(querynode, "url")))
		return;

	url = xmlnode_get_data(urlnode);

	jox = g_new0(JabberOOBXfer, 1);
	purple_url_parse(url, &jox->address, &jox->port, &jox->page, NULL, NULL);
	g_free(url);
	jox->js = js;
	jox->headers = g_string_new("");
	jox->iq_id = g_strdup(xmlnode_get_attrib(packet, "id"));

	xfer = purple_xfer_new(js->gc->account, PURPLE_XFER_RECEIVE,
			xmlnode_get_attrib(packet, "from"));
	if (xfer)
	{
		xfer->data = jox;

		if(!(filename = g_strdup(g_strrstr(jox->page, "/"))))
			filename = g_strdup(jox->page);

		purple_xfer_set_filename(xfer, filename);

		g_free(filename);

		purple_xfer_set_init_fnc(xfer,   jabber_oob_xfer_init);
		purple_xfer_set_end_fnc(xfer,    jabber_oob_xfer_end);
		purple_xfer_set_request_denied_fnc(xfer, jabber_oob_xfer_recv_denied);
		purple_xfer_set_cancel_recv_fnc(xfer, jabber_oob_xfer_recv_canceled);
		purple_xfer_set_read_fnc(xfer,   jabber_oob_xfer_read);
		purple_xfer_set_start_fnc(xfer,  jabber_oob_xfer_start);

		js->oob_file_transfers = g_list_append(js->oob_file_transfers, xfer);

		purple_xfer_request(xfer);
	}
}
开发者ID:bf4,项目名称:pidgin-mac,代码行数:51,代码来源:oob.c


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