Mercurial > pidgin
diff 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 |
line wrap: on
line diff
--- a/src/account.c Sat Jun 14 23:25:41 2003 +0000 +++ b/src/account.c Sat Jun 14 23:50:24 2003 +0000 @@ -117,19 +117,13 @@ gaim_account_new(const char *username, GaimProtocol protocol) { GaimAccount *account; - GList *l; g_return_val_if_fail(username != NULL, NULL); - for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { - account = l->data; + account = gaim_accounts_find(username, protocol); - if (!strcmp(gaim_account_get_username(account), username) && - gaim_account_get_protocol(account) == protocol) { - - return account; - } - } + if (account != NULL) + return account; account = g_new0(GaimAccount, 1); @@ -1270,3 +1264,34 @@ { return accounts; } + +GaimAccount * +gaim_accounts_find(const char *name, GaimProtocol protocol) +{ + GaimAccount *account = NULL; + GList *l; + char *who; + + g_return_val_if_fail(name != NULL, NULL); + + who = g_strdup(normalize(name)); + + for (l = gaim_accounts_get_all(); l != NULL; l = l->next) { + account = (GaimAccount *)l->data; + + if (!strcmp(normalize(gaim_account_get_username(account)), who)) { + if (protocol != -1) { + if (account->protocol == protocol) + break; + } + else + break; + } + + account = NULL; + } + + g_free(who); + + return account; +}