Mercurial > pidgin
comparison src/account.c @ 5874:964e4f94fc56
[gaim-migrate @ 6306]
Moved gaim_account_find() from util.[ch] to gaim_accounts_find() in
account.[ch].
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sat, 14 Jun 2003 23:50:24 +0000 |
parents | 059d95c67cda |
children | 448f2f4ca3ec |
comparison
equal
deleted
inserted
replaced
5873:a18e88c4dace | 5874:964e4f94fc56 |
---|---|
115 | 115 |
116 GaimAccount * | 116 GaimAccount * |
117 gaim_account_new(const char *username, GaimProtocol protocol) | 117 gaim_account_new(const char *username, GaimProtocol protocol) |
118 { | 118 { |
119 GaimAccount *account; | 119 GaimAccount *account; |
120 GList *l; | |
121 | 120 |
122 g_return_val_if_fail(username != NULL, NULL); | 121 g_return_val_if_fail(username != NULL, NULL); |
123 | 122 |
124 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { | 123 account = gaim_accounts_find(username, protocol); |
125 account = l->data; | 124 |
126 | 125 if (account != NULL) |
127 if (!strcmp(gaim_account_get_username(account), username) && | 126 return account; |
128 gaim_account_get_protocol(account) == protocol) { | |
129 | |
130 return account; | |
131 } | |
132 } | |
133 | 127 |
134 account = g_new0(GaimAccount, 1); | 128 account = g_new0(GaimAccount, 1); |
135 | 129 |
136 gaim_account_set_username(account, username); | 130 gaim_account_set_username(account, username); |
137 gaim_account_set_protocol(account, protocol); | 131 gaim_account_set_protocol(account, protocol); |
1268 GList * | 1262 GList * |
1269 gaim_accounts_get_all(void) | 1263 gaim_accounts_get_all(void) |
1270 { | 1264 { |
1271 return accounts; | 1265 return accounts; |
1272 } | 1266 } |
1267 | |
1268 GaimAccount * | |
1269 gaim_accounts_find(const char *name, GaimProtocol protocol) | |
1270 { | |
1271 GaimAccount *account = NULL; | |
1272 GList *l; | |
1273 char *who; | |
1274 | |
1275 g_return_val_if_fail(name != NULL, NULL); | |
1276 | |
1277 who = g_strdup(normalize(name)); | |
1278 | |
1279 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { | |
1280 account = (GaimAccount *)l->data; | |
1281 | |
1282 if (!strcmp(normalize(gaim_account_get_username(account)), who)) { | |
1283 if (protocol != -1) { | |
1284 if (account->protocol == protocol) | |
1285 break; | |
1286 } | |
1287 else | |
1288 break; | |
1289 } | |
1290 | |
1291 account = NULL; | |
1292 } | |
1293 | |
1294 g_free(who); | |
1295 | |
1296 return account; | |
1297 } |