src/account.c

changeset 5867
46d0ef5058c7
parent 5865
5b358b960d7d
child 5868
e7b36a802a7e
equal deleted inserted replaced
5866:5caedbcd1bb7 5867:46d0ef5058c7
124 124
125 GaimAccount * 125 GaimAccount *
126 gaim_account_new(const char *username, GaimProtocol protocol) 126 gaim_account_new(const char *username, GaimProtocol protocol)
127 { 127 {
128 GaimAccount *account; 128 GaimAccount *account;
129 GList *l;
129 130
130 g_return_val_if_fail(username != NULL, NULL); 131 g_return_val_if_fail(username != NULL, NULL);
132
133 for (l = gaim_accounts_get_all(); l != NULL; l = l->next) {
134 account = l->data;
135
136 if (!strcmp(gaim_account_get_username(account), username) &&
137 gaim_account_get_protocol(account) == protocol) {
138
139 return account;
140 }
141 }
131 142
132 account = g_new0(GaimAccount, 1); 143 account = g_new0(GaimAccount, 1);
133 144
134 gaim_account_set_username(account, username); 145 gaim_account_set_username(account, username);
135 gaim_account_set_protocol(account, protocol); 146 gaim_account_set_protocol(account, protocol);
1190 void 1201 void
1191 gaim_accounts_add(GaimAccount *account) 1202 gaim_accounts_add(GaimAccount *account)
1192 { 1203 {
1193 g_return_if_fail(account != NULL); 1204 g_return_if_fail(account != NULL);
1194 1205
1206 if (g_list_find(accounts, account) != NULL)
1207 return;
1208
1195 accounts = g_list_append(accounts, account); 1209 accounts = g_list_append(accounts, account);
1196 1210
1197 schedule_accounts_save(); 1211 schedule_accounts_save();
1198 } 1212 }
1199 1213

mercurial