11146
|
1 #include "conversation.h"
|
|
2
|
|
3
|
|
4 GaimAccount *
|
|
5 gaim_accounts_find_ext(const char *name, const char *protocol_id,
|
|
6 gboolean (*account_test)(const GaimAccount *account))
|
|
7 {
|
|
8 GaimAccount *result = NULL;
|
|
9 GList *l;
|
|
10 char *who;
|
|
11
|
|
12 if (name)
|
|
13 who = g_strdup(gaim_normalize(NULL, name));
|
|
14 else
|
|
15 who = NULL;
|
|
16
|
|
17 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) {
|
|
18 GaimAccount *account = (GaimAccount *)l->data;
|
|
19
|
|
20 if (who && strcmp(gaim_normalize(NULL, gaim_account_get_username(account)), who))
|
|
21 continue;
|
|
22
|
|
23 if (protocol_id && strcmp(account->protocol_id, protocol_id))
|
|
24 continue;
|
|
25
|
|
26 if (account_test && !account_test(account))
|
|
27 continue;
|
|
28
|
|
29 result = account;
|
|
30 break;
|
|
31 }
|
|
32
|
|
33 g_free(who);
|
|
34
|
|
35 return result;
|
|
36 }
|
|
37
|
|
38 GaimAccount *gaim_accounts_find_any(const char *name, const char *protocol)
|
|
39 {
|
|
40 return gaim_accounts_find_ext(name, protocol, NULL);
|
|
41 }
|
|
42
|
|
43 GaimAccount *gaim_accounts_find_connected(const char *name, const char *protocol)
|
|
44 {
|
|
45 return gaim_accounts_find_ext(name, protocol, gaim_account_is_connected);
|
|
46 }
|
|
47
|
|
48
|