11187
|
1 #include <string.h>
|
|
2 #include <glib.h>
|
|
3
|
11146
|
4 #include "conversation.h"
|
11187
|
5 #include "util.h"
|
|
6
|
11146
|
7
|
|
8
|
|
9 GaimAccount *
|
|
10 gaim_accounts_find_ext(const char *name, const char *protocol_id,
|
|
11 gboolean (*account_test)(const GaimAccount *account))
|
|
12 {
|
|
13 GaimAccount *result = NULL;
|
|
14 GList *l;
|
|
15 char *who;
|
|
16
|
|
17 if (name)
|
|
18 who = g_strdup(gaim_normalize(NULL, name));
|
|
19 else
|
|
20 who = NULL;
|
|
21
|
|
22 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) {
|
|
23 GaimAccount *account = (GaimAccount *)l->data;
|
|
24
|
|
25 if (who && strcmp(gaim_normalize(NULL, gaim_account_get_username(account)), who))
|
|
26 continue;
|
|
27
|
|
28 if (protocol_id && strcmp(account->protocol_id, protocol_id))
|
|
29 continue;
|
|
30
|
|
31 if (account_test && !account_test(account))
|
|
32 continue;
|
|
33
|
|
34 result = account;
|
|
35 break;
|
|
36 }
|
|
37
|
|
38 g_free(who);
|
|
39
|
|
40 return result;
|
|
41 }
|
|
42
|
|
43 GaimAccount *gaim_accounts_find_any(const char *name, const char *protocol)
|
|
44 {
|
|
45 return gaim_accounts_find_ext(name, protocol, NULL);
|
|
46 }
|
|
47
|
|
48 GaimAccount *gaim_accounts_find_connected(const char *name, const char *protocol)
|
|
49 {
|
|
50 return gaim_accounts_find_ext(name, protocol, gaim_account_is_connected);
|
|
51 }
|
|
52
|
|
53
|
11187
|
54 /* DBusMessage *gaim_account_set_status_DBUS(DBusMessage *message_DBUS, DBusError *error_DBUS) */
|
|
55 /* { */
|
|
56 /* DBusMessage *reply; */
|
|
57 /* DBusMessageIter iter; */
|
|
58
|
|
59 /* dbus_int32_t account, active; */
|
|
60 /* char *status_id; */
|
|
61
|
|
62 /* dbus_message_iter_init(message, &iter); */
|
|
63 /* const char *name; */
|
|
64 /* const char *protocol; */
|
|
65
|
|
66 /* dbus_message_get_args(message_DBUS, error_DBUS, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &protocol, DBUS_TYPE_INVALID); */
|
|
67 /* CHECK_ERROR(error_DBUS); */
|
|
68 /* NULLIFY(name); */
|
|
69 /* NULLIFY(protocol); */
|
|
70 /* GAIM_DBUS_POINTER_TO_ID(RESULT, gaim_accounts_find_any(name, protocol), error_DBUS); */
|
|
71 /* reply_DBUS = dbus_message_new_method_return (message_DBUS); */
|
|
72 /* dbus_message_append_args(reply_DBUS, DBUS_TYPE_INT32, &RESULT, DBUS_TYPE_INVALID); */
|
|
73 /* return reply_DBUS; */
|
|
74
|
|
75 /* } */
|