view libpurple/dbus-useful.c @ 22756:17cda378a2dd

Added "chat-join-failed" signal, emitted by a new serv_got_join_chat_failed() function in server.c. This is emitted with the PurpleConnection and chat name and allows a UI or plugin which was expecting a group chat to be joined to know if failure occurred. serv_got_join_chat_failed() is only called by jabber so far; I know that at least oscar should call it some situations, as well, such as when a busted SNAC error is received after trying to join a chat with an invalid room name.
author Evan Schoenberg <evan.s@dreskin.net>
date Tue, 29 Apr 2008 01:46:40 +0000
parents 32c366eeeb99
children 4ca97b26a8fb f75041cb3fec
line wrap: on
line source

#include <string.h>
#include <glib.h>

#include "dbus-useful.h"
#include "conversation.h"
#include "util.h"


PurpleAccount *
purple_accounts_find_ext(const char *name, const char *protocol_id,
		       gboolean (*account_test)(const PurpleAccount *account))
{
	PurpleAccount *result = NULL;
	GList *l;
	char *who;

	if (name)
		who = g_strdup(purple_normalize(NULL, name));
	else
		who = NULL;

	for (l = purple_accounts_get_all(); l != NULL; l = l->next) {
		PurpleAccount *account = (PurpleAccount *)l->data;

		if (who && strcmp(purple_normalize(NULL, purple_account_get_username(account)), who))
			continue;

		if (protocol_id && strcmp(account->protocol_id, protocol_id))
			continue;

		if (account_test && !account_test(account))
			continue;

		result = account;
		break;
	}

	g_free(who);

	return result;
}

PurpleAccount *purple_accounts_find_any(const char *name, const char *protocol)
{
	return purple_accounts_find_ext(name, protocol, NULL);
}

PurpleAccount *purple_accounts_find_connected(const char *name, const char *protocol)
{
	return purple_accounts_find_ext(name, protocol, purple_account_is_connected);
}