예제 #1
0
파일: iq.c 프로젝트: bf4/pidgin-mac
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);
	}
}
예제 #2
0
static void ga_plugin_init(PurplePlugin *plugin)
{
	PurpleAccountOption *option;
	GHashTable *ui_info = purple_core_get_ui_info();
	const gchar *ui_name = g_hash_table_lookup(ui_info, "version");
	if(!ui_name)
		ui_name = GA_NAME;

	option = purple_account_option_string_new("User-agent", "user-agent", ui_name);
	ga_plugin_prpl_info.protocol_options = g_list_append(ga_plugin_prpl_info.protocol_options, option);

	_gayattitude_plugin = plugin;
}
예제 #3
0
파일: bosh.c 프로젝트: Lilitana/Pidgin
void jabber_bosh_init(void)
{
	GHashTable *ui_info = purple_core_get_ui_info();
	const char *ui_name = NULL;
	const char *ui_version = NULL;

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

	if (ui_name)
		bosh_useragent = g_strdup_printf("%s%s%s (libpurple " VERSION ")",
		                                 ui_name, ui_version ? " " : "",
		                                 ui_version ? ui_version : "");
	else
		bosh_useragent = g_strdup("libpurple " VERSION);
}
예제 #4
0
파일: state.c 프로젝트: Draghtnod/pidgin
void
msn_change_status(MsnSession *session)
{
	PurpleAccount *account;
	MsnCmdProc *cmdproc;
	MsnTransaction *trans;
	MsnUser *user;
	MsnObject *msnobj;
	const char *state_text;
	GHashTable *ui_info = purple_core_get_ui_info();
	MsnClientCaps caps = MSN_CLIENT_ID;

	g_return_if_fail(session != NULL);
	g_return_if_fail(session->notification != NULL);

	/* set client caps based on what the UI tells us it is... */
	if (ui_info) {
		const gchar *client_type = g_hash_table_lookup(ui_info, "client_type");
		if (client_type) {
			if (strcmp(client_type, "phone") == 0 ||
				strcmp(client_type, "handheld") == 0) {
				caps |= MSN_CAP_VIA_MOBILE;
			} else if (strcmp(client_type, "web") == 0) {
				caps |= MSN_CAP_VIA_WEBIM;
			} else if (strcmp(client_type, "bot") == 0) {
				caps |= MSN_CAP_BOT;
			}
			/* MSN doesn't a "console" type...
			 What, they have no ncurses UI? :-) */
		}
	}

	account = session->account;
	cmdproc = session->notification->cmdproc;
	user = session->user;
	state_text = msn_state_get_text(msn_state_from_account(account));

	/* If we're not logged in yet, don't send the status to the server,
	 * it will be sent when login completes
	 */
	if (!session->logged_in)
		return;

	msn_set_psm(session);

	msnobj = msn_user_get_object(user);

	if (msnobj == NULL)
	{
		trans = msn_transaction_new(cmdproc, "CHG", "%s %u:%02u 0", state_text,
		                            caps, MSN_CLIENT_ID_EXT_CAPS);
	}
	else
	{
		char *msnobj_str;

		msnobj_str = msn_object_to_string(msnobj);

		trans = msn_transaction_new(cmdproc, "CHG", "%s %u:%02u %s", state_text,
		                            caps, MSN_CLIENT_ID_EXT_CAPS,
		                            purple_url_encode(msnobj_str));

		g_free(msnobj_str);
	}

	msn_cmdproc_send_trans(cmdproc, trans);
}