Mercurial > pidgin
comparison src/main.c @ 4491:3196d9044a45
[gaim-migrate @ 4766]
aim_user is dead. long live gaim_account.
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Fri, 31 Jan 2003 13:03:47 +0000 |
parents | 58c3c6cfd537 |
children | 7521e29658bc |
comparison
equal
deleted
inserted
replaced
4490:70b892694e0b | 4491:3196d9044a45 |
---|---|
162 return TRUE; | 162 return TRUE; |
163 } | 163 } |
164 | 164 |
165 static void dologin(GtkWidget *widget, GtkWidget *w) | 165 static void dologin(GtkWidget *widget, GtkWidget *w) |
166 { | 166 { |
167 struct aim_user *u; | 167 struct gaim_account *account; |
168 const char *username = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(name)->entry)); | 168 const char *username = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(name)->entry)); |
169 const char *password = gtk_entry_get_text(GTK_ENTRY(pass)); | 169 const char *password = gtk_entry_get_text(GTK_ENTRY(pass)); |
170 | 170 |
171 if (!strlen(username)) { | 171 if (!strlen(username)) { |
172 do_error_dialog(_("Please enter your login."), NULL, GAIM_ERROR); | 172 do_error_dialog(_("Please enter your login."), NULL, GAIM_ERROR); |
175 | 175 |
176 /* if there is more than one user of the same name, then fuck | 176 /* if there is more than one user of the same name, then fuck |
177 * them, they just have to use the account editor to sign in | 177 * them, they just have to use the account editor to sign in |
178 * the second one */ | 178 * the second one */ |
179 | 179 |
180 u = find_user(username, -1); | 180 account = gaim_account_find(username, -1); |
181 if (!u) | 181 if (!account) |
182 u = new_user(username, DEFAULT_PROTO, OPT_USR_REM_PASS); | 182 account = gaim_account_new(username, DEFAULT_PROTO, OPT_ACCT_REM_PASS); |
183 g_snprintf(u->password, sizeof u->password, "%s", password); | 183 g_snprintf(account->password, sizeof account->password, "%s", password); |
184 save_prefs(); | 184 save_prefs(); |
185 serv_login(u); | 185 serv_login(account); |
186 } | 186 } |
187 | 187 |
188 /* <name> is a comma-separated list of names, or NULL | 188 /* <name> is a comma-separated list of names, or NULL |
189 if NULL and there is at least one user defined in .gaimrc, try to login. | 189 if NULL and there is at least one user defined in .gaimrc, try to login. |
190 if not NULL, parse <name> into separate strings, look up each one in | 190 if not NULL, parse <name> into separate strings, look up each one in |
192 returns: 0 if successful | 192 returns: 0 if successful |
193 -1 if no user was found that had a saved password | 193 -1 if no user was found that had a saved password |
194 */ | 194 */ |
195 static int dologin_named(char *name) | 195 static int dologin_named(char *name) |
196 { | 196 { |
197 struct aim_user *u; | 197 struct gaim_account *account; |
198 char **names, **n; | 198 char **names, **n; |
199 int retval = -1; | 199 int retval = -1; |
200 | 200 |
201 if (name !=NULL) { /* list of names given */ | 201 if (name !=NULL) { /* list of names given */ |
202 names = g_strsplit(name, ",", 32); | 202 names = g_strsplit(name, ",", 32); |
203 for (n = names; *n != NULL; n++) { | 203 for (n = names; *n != NULL; n++) { |
204 u = find_user(*n, -1); | 204 account = gaim_account_find(*n, -1); |
205 if (u) { /* found a user */ | 205 if (account) { /* found a user */ |
206 if (u->options & OPT_USR_REM_PASS) { | 206 if (account->options & OPT_ACCT_REM_PASS) { |
207 retval = 0; | 207 retval = 0; |
208 serv_login(u); | 208 serv_login(account); |
209 } | 209 } |
210 } | 210 } |
211 } | 211 } |
212 g_strfreev(names); | 212 g_strfreev(names); |
213 } else { /* no name given, use default */ | 213 } else { /* no name given, use default */ |
214 u = (struct aim_user *)aim_users->data; | 214 account = (struct gaim_account *)gaim_accounts->data; |
215 if (u->options & OPT_USR_REM_PASS) { | 215 if (account->options & OPT_ACCT_REM_PASS) { |
216 retval = 0; | 216 retval = 0; |
217 serv_login(u); | 217 serv_login(account); |
218 } | 218 } |
219 } | 219 } |
220 | 220 |
221 return retval; | 221 return retval; |
222 } | 222 } |
235 | 235 |
236 | 236 |
237 static void combo_changed(GtkWidget *w, GtkWidget *combo) | 237 static void combo_changed(GtkWidget *w, GtkWidget *combo) |
238 { | 238 { |
239 const char *txt = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)); | 239 const char *txt = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)); |
240 struct aim_user *u; | 240 struct gaim_account *account; |
241 | 241 |
242 u = find_user(txt, -1); | 242 account = gaim_account_find(txt, -1); |
243 | 243 |
244 if (u && u->options & OPT_USR_REM_PASS) { | 244 if (account && account->options & OPT_ACCT_REM_PASS) { |
245 gtk_entry_set_text(GTK_ENTRY(pass), u->password); | 245 gtk_entry_set_text(GTK_ENTRY(pass), account->password); |
246 } else { | 246 } else { |
247 gtk_entry_set_text(GTK_ENTRY(pass), ""); | 247 gtk_entry_set_text(GTK_ENTRY(pass), ""); |
248 } | 248 } |
249 } | 249 } |
250 | 250 |
251 | 251 |
252 static GList *combo_user_names() | 252 static GList *combo_user_names() |
253 { | 253 { |
254 GSList *usr = aim_users; | 254 GSList *accts = gaim_accounts; |
255 GList *tmp = NULL; | 255 GList *tmp = NULL; |
256 struct aim_user *u; | 256 struct gaim_account *account; |
257 | 257 |
258 if (!usr) | 258 if (!accts) |
259 return g_list_append(NULL, _("<New User>")); | 259 return g_list_append(NULL, _("<New User>")); |
260 | 260 |
261 while (usr) { | 261 while (accts) { |
262 u = (struct aim_user *)usr->data; | 262 account = (struct gaim_account *)accts->data; |
263 tmp = g_list_append(tmp, u->username); | 263 tmp = g_list_append(tmp, account->username); |
264 usr = usr->next; | 264 accts = accts->next; |
265 } | 265 } |
266 | 266 |
267 return tmp; | 267 return tmp; |
268 } | 268 } |
269 | 269 |
383 /* Register newly created window with systray module */ | 383 /* Register newly created window with systray module */ |
384 wgaim_created_loginwin(GTK_WIDGET(mainwindow)); | 384 wgaim_created_loginwin(GTK_WIDGET(mainwindow)); |
385 #endif | 385 #endif |
386 | 386 |
387 /* Now grab the focus that we need */ | 387 /* Now grab the focus that we need */ |
388 if (aim_users) { | 388 if (gaim_accounts) { |
389 struct aim_user *c = (struct aim_user *)aim_users->data; | 389 struct gaim_account *account = gaim_accounts->data; |
390 if (c->options & OPT_USR_REM_PASS) { | 390 if (account->options & OPT_ACCT_REM_PASS) { |
391 combo_changed(NULL, name); | 391 combo_changed(NULL, name); |
392 gtk_widget_grab_focus(button); | 392 gtk_widget_grab_focus(button); |
393 } else { | 393 } else { |
394 gtk_widget_grab_focus(pass); | 394 gtk_widget_grab_focus(pass); |
395 } | 395 } |
548 return 0; | 548 return 0; |
549 } | 549 } |
550 | 550 |
551 static void set_first_user(char *name) | 551 static void set_first_user(char *name) |
552 { | 552 { |
553 struct aim_user *u; | 553 struct gaim_account *account; |
554 | 554 |
555 u = find_user(name, -1); | 555 account = gaim_account_find(name, -1); |
556 | 556 |
557 if (!u) { /* new user */ | 557 if (!account) { /* new user */ |
558 u = g_new0(struct aim_user, 1); | 558 account = g_new0(struct gaim_account, 1); |
559 g_snprintf(u->username, sizeof(u->username), "%s", name); | 559 g_snprintf(account->username, sizeof(account->username), "%s", name); |
560 u->protocol = DEFAULT_PROTO; | 560 account->protocol = DEFAULT_PROTO; |
561 aim_users = g_slist_prepend(aim_users, u); | 561 gaim_accounts = g_slist_prepend(gaim_accounts, account); |
562 } else { /* user already exists */ | 562 } else { /* user already exists */ |
563 aim_users = g_slist_remove(aim_users, u); | 563 gaim_accounts = g_slist_remove(gaim_accounts, account); |
564 aim_users = g_slist_prepend(aim_users, u); | 564 gaim_accounts = g_slist_prepend(gaim_accounts, account); |
565 } | 565 } |
566 save_prefs(); | 566 save_prefs(); |
567 } | 567 } |
568 | 568 |
569 #ifdef _WIN32 | 569 #ifdef _WIN32 |