comparison src/multi.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 3502a25bad47
children 61ba567f9c64
comparison
equal deleted inserted replaced
4490:70b892694e0b 4491:3196d9044a45
34 34
35 static GtkWidget *acctedit = NULL; 35 static GtkWidget *acctedit = NULL;
36 static GtkWidget *treeview = NULL; /* the treeview of names in the accteditor */ 36 static GtkWidget *treeview = NULL; /* the treeview of names in the accteditor */
37 static GtkListStore *model = NULL; 37 static GtkListStore *model = NULL;
38 38
39 static GSList *mod_users = NULL; 39 static GSList *mod_accounts = NULL;
40 40
41 enum 41 enum
42 { 42 {
43 COLUMN_SCREENNAME, 43 COLUMN_SCREENNAME,
44 COLUMN_ONLINE, 44 COLUMN_ONLINE,
46 COLUMN_PROTOCOL, 46 COLUMN_PROTOCOL,
47 COLUMN_DATA, 47 COLUMN_DATA,
48 NUM_COLUMNS 48 NUM_COLUMNS
49 }; 49 };
50 50
51 struct mod_account {
52 struct gaim_account *account;
53
54 /* these are temporary */
55 int options;
56 int protocol;
57 char proto_opt[7][256];
58
59 /* stuff for modify window */
60 GtkWidget *mod;
61 GtkWidget *main;
62 GtkWidget *name;
63 GtkWidget *alias;
64 GtkWidget *pwdbox;
65 GtkWidget *pass;
66 GtkWidget *rempass;
67 GtkWidget *user_frame;
68 GtkWidget *proto_frame;
69 GtkSizeGroup *sg;
70 GList *opt_entries;
71
72 /* stuff for icon selection */
73 char iconfile[256];
74 GtkWidget *iconsel;
75 GtkWidget *iconentry;
76 GtkWidget *icondlg;
77
78 /* stuff for mail check prompt */
79 GtkWidget *checkmail;
80
81 /* stuff for register with server */
82 GtkWidget *register_user;
83 };
84
85
86 struct mod_account_opt {
87 struct mod_account *ma;
88 int opt;
89 };
90
51 static void acct_signin(GtkCellRendererToggle *cell, gchar *path_str, 91 static void acct_signin(GtkCellRendererToggle *cell, gchar *path_str,
52 gpointer d); 92 gpointer d);
53 static void acct_autologin(GtkCellRendererToggle *cell, gchar *path_str, 93 static void acct_autologin(GtkCellRendererToggle *cell, gchar *path_str,
54 gpointer d); 94 gpointer d);
55 95
56 static struct mod_user *find_mod_user(struct aim_user *a) 96 static struct mod_account *mod_account_find(struct gaim_account *a)
57 { 97 {
58 GSList *m = mod_users; 98 GSList *m = mod_accounts;
59 while (m) { 99 while (m) {
60 struct mod_user *u = m->data; 100 struct mod_account *ma = m->data;
61 if (u->user == a) 101 if (ma->account == a)
62 return u; 102 return ma;
63 m = m->next; 103 m = m->next;
64 } 104 }
65 return NULL; 105 return NULL;
66 } 106 }
67 107
68 static void generate_protocol_options(struct mod_user *, GtkWidget *); 108 static void generate_protocol_options(struct mod_account *, GtkWidget *);
69 109
70 struct mod_usr_opt { 110
71 struct mod_user *user; 111 struct gaim_connection *new_gaim_conn(struct gaim_account *account)
72 int opt;
73 };
74
75 struct gaim_connection *new_gaim_conn(struct aim_user *user)
76 { 112 {
77 struct gaim_connection *gc = g_new0(struct gaim_connection, 1); 113 struct gaim_connection *gc = g_new0(struct gaim_connection, 1);
78 gc->edittype = EDIT_GC; 114 gc->edittype = EDIT_GC;
79 gc->protocol = user->protocol; 115 gc->protocol = account->protocol;
80 gc->prpl = find_prpl(user->protocol); 116 gc->prpl = find_prpl(account->protocol);
81 g_snprintf(gc->username, sizeof(gc->username), "%s", user->username); 117 g_snprintf(gc->username, sizeof(gc->username), "%s", account->username);
82 g_snprintf(gc->password, sizeof(gc->password), "%s", user->password); 118 g_snprintf(gc->password, sizeof(gc->password), "%s", account->password);
83 gc->keepalive = 0; 119 gc->keepalive = 0;
84 gc->inpa = 0; 120 gc->inpa = 0;
85 gc->buddy_chats = NULL; 121 gc->buddy_chats = NULL;
86 gc->away = NULL; 122 gc->away = NULL;
87 gc->away_state = NULL; 123 gc->away_state = NULL;
88 124
89 connections = g_slist_append(connections, gc); 125 connections = g_slist_append(connections, gc);
90 126
91 user->gc = gc; 127 account->gc = gc;
92 gc->user = user; 128 gc->account = account;
93 129
94 return gc; 130 return gc;
95 } 131 }
96 132
97 struct meter_window { 133 struct meter_window {
112 g = g_slist_next(g); 148 g = g_slist_next(g);
113 h = m->members; 149 h = m->members;
114 while (h) { 150 while (h) {
115 n = (struct buddy *)h->data; 151 n = (struct buddy *)h->data;
116 h = g_slist_next(h); 152 h = g_slist_next(h);
117 if(n->user == gc->user) { 153 if(n->account == gc->account) {
118 n->present = 0; 154 n->present = 0;
119 } 155 }
120 } 156 }
121 } 157 }
122 g_free(gc->away); 158 g_free(gc->away);
158 return "Unknown"; 194 return "Unknown";
159 } 195 }
160 196
161 void regenerate_user_list() 197 void regenerate_user_list()
162 { 198 {
163 GSList *u = aim_users; 199 GSList *accounts = gaim_accounts;
164 struct aim_user *a; 200 struct gaim_account *a;
165 GtkTreeIter iter; 201 GtkTreeIter iter;
166 202
167 if (!acctedit) 203 if (!acctedit)
168 return; 204 return;
169 205
170 gtk_list_store_clear(model); 206 gtk_list_store_clear(model);
171 207
172 while (u) { 208 while (accounts) {
173 a = (struct aim_user *)u->data; 209 a = (struct gaim_account *)accounts->data;
174 210
175 gtk_list_store_append(model, &iter); 211 gtk_list_store_append(model, &iter);
176 gtk_list_store_set(model, &iter, 212 gtk_list_store_set(model, &iter,
177 COLUMN_SCREENNAME, a->username, 213 COLUMN_SCREENNAME, a->username,
178 COLUMN_ONLINE, (a->gc ? TRUE : FALSE), 214 COLUMN_ONLINE, (a->gc ? TRUE : FALSE),
179 COLUMN_AUTOLOGIN, (a->options & OPT_USR_AUTO), 215 COLUMN_AUTOLOGIN, (a->options & OPT_ACCT_AUTO),
180 COLUMN_PROTOCOL, proto_name(a->protocol), 216 COLUMN_PROTOCOL, proto_name(a->protocol),
181 COLUMN_DATA, a, 217 COLUMN_DATA, a,
182 -1); 218 -1);
183 u = u->next; 219 accounts = accounts->next;
184 } 220 }
185 } 221 }
186 222
187 static gboolean get_iter_from_data(GtkTreeView *treeview, 223 static gboolean get_iter_from_data(GtkTreeView *treeview,
188 struct aim_user *a, GtkTreeIter *iter) 224 struct gaim_account *a, GtkTreeIter *iter)
189 { 225 {
190 return gtk_tree_model_iter_nth_child(gtk_tree_view_get_model(treeview), 226 return gtk_tree_model_iter_nth_child(gtk_tree_view_get_model(treeview),
191 iter, NULL, 227 iter, NULL,
192 g_slist_index(aim_users, a)); 228 g_slist_index(gaim_accounts, a));
193 #if 0
194 GtkListModel *model = gtk_tree_view_get_model(treeview);
195 struct aim_user *user;
196 int i;
197
198 rows = gtk_tree_model_iter_n_children(model, NULL);
199
200 for (i = 0; i < rows; i++)
201 {
202 gtk_tree_model_get(model, iter, COLUMN_DATA, &user, -1);
203
204 if (user == a)
205 return TRUE;
206 }
207
208 return FALSE;
209 #endif
210 } 229 }
211 230
212 static void add_columns(GtkWidget *treeview) 231 static void add_columns(GtkWidget *treeview)
213 { 232 {
214 GtkCellRenderer *renderer; 233 GtkCellRenderer *renderer;
284 gtk_tree_view_set_reorderable (GTK_TREE_VIEW(treeview), TRUE); 303 gtk_tree_view_set_reorderable (GTK_TREE_VIEW(treeview), TRUE);
285 gtk_widget_show(win); 304 gtk_widget_show(win);
286 return win; 305 return win;
287 } 306 }
288 307
289 static void delmod(GtkWidget *w, struct mod_user *u) 308 static void delmod(GtkWidget *w, struct mod_account *ma)
290 { 309 {
291 mod_users = g_slist_remove(mod_users, u); 310 mod_accounts = g_slist_remove(mod_accounts, ma);
292 g_free(u); 311 g_free(ma);
293 } 312 }
294 313
295 static void mod_opt(GtkWidget *b, struct mod_usr_opt *m) 314 static void mod_opt(GtkWidget *b, struct mod_account_opt *mao)
296 { 315 {
297 m->user->options = m->user->options ^ m->opt; 316 mao->ma->options = mao->ma->options ^ mao->opt;
298 } 317 }
299 318
300 static void free_muo(GtkWidget *b, struct mod_usr_opt *m) 319 static void free_mao(GtkWidget *b, struct mod_account_opt *mao)
301 { 320 {
302 g_free(m); 321 g_free(mao);
303 } 322 }
304 323
305 static GtkWidget *acct_button(const char *text, struct mod_user *u, int option, GtkWidget *box) 324 static GtkWidget *acct_button(const char *text, struct mod_account *ma, int option, GtkWidget *box)
306 { 325 {
307 GtkWidget *button; 326 GtkWidget *button;
308 struct mod_usr_opt *muo = g_new0(struct mod_usr_opt, 1); 327 struct mod_account_opt *mao = g_new0(struct mod_account_opt, 1);
309 button = gtk_check_button_new_with_label(text); 328 button = gtk_check_button_new_with_label(text);
310 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), (u->options & option)); 329 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), (ma->options & option));
311 gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0); 330 gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
312 muo->user = u; 331 mao->ma = ma;
313 muo->opt = option; 332 mao->opt = option;
314 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(mod_opt), muo); 333 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(mod_opt), mao);
315 g_signal_connect(GTK_OBJECT(button), "destroy", G_CALLBACK(free_muo), muo); 334 g_signal_connect(GTK_OBJECT(button), "destroy", G_CALLBACK(free_mao), mao);
316 gtk_widget_show(button); 335 gtk_widget_show(button);
317 return button; 336 return button;
318 } 337 }
319 338
320 static void ok_mod(GtkWidget *w, struct mod_user *u) 339 static void ok_mod(GtkWidget *w, struct mod_account *ma)
321 { 340 {
322 GList *tmp; 341 GList *tmp;
323 const char *txt; 342 const char *txt;
324 struct aim_user *a; 343 struct gaim_account *a;
325 struct prpl *p; 344 struct prpl *p;
326 GtkTreeIter iter; 345 GtkTreeIter iter;
327 346
328 if (!u->user) { 347 if (!ma->account) {
329 txt = gtk_entry_get_text(GTK_ENTRY(u->name)); 348 txt = gtk_entry_get_text(GTK_ENTRY(ma->name));
330 u->user = new_user(txt, u->protocol, u->options); 349 ma->account = gaim_account_new(txt, ma->protocol, ma->options);
331 } 350 }
332 a = u->user; 351 a = ma->account;
333 352
334 a->options = u->options; 353 a->options = ma->options;
335 a->protocol = u->protocol; 354 a->protocol = ma->protocol;
336 txt = gtk_entry_get_text(GTK_ENTRY(u->name)); 355 txt = gtk_entry_get_text(GTK_ENTRY(ma->name));
337 g_snprintf(a->username, sizeof(a->username), "%s", txt); 356 g_snprintf(a->username, sizeof(a->username), "%s", txt);
338 txt = gtk_entry_get_text(GTK_ENTRY(u->alias)); 357 txt = gtk_entry_get_text(GTK_ENTRY(ma->alias));
339 g_snprintf(a->alias, sizeof(a->alias), "%s", txt); 358 g_snprintf(a->alias, sizeof(a->alias), "%s", txt);
340 txt = gtk_entry_get_text(GTK_ENTRY(u->pass)); 359 txt = gtk_entry_get_text(GTK_ENTRY(ma->pass));
341 if (a->options & OPT_USR_REM_PASS) 360 if (a->options & OPT_ACCT_REM_PASS)
342 g_snprintf(a->password, sizeof(a->password), "%s", txt); 361 g_snprintf(a->password, sizeof(a->password), "%s", txt);
343 else 362 else
344 a->password[0] = '\0'; 363 a->password[0] = '\0';
345 364
346 if (get_iter_from_data(GTK_TREE_VIEW(treeview), a, &iter)) { 365 if (get_iter_from_data(GTK_TREE_VIEW(treeview), a, &iter)) {
347 gtk_list_store_set(model, &iter, 366 gtk_list_store_set(model, &iter,
348 COLUMN_SCREENNAME, a->username, 367 COLUMN_SCREENNAME, a->username,
349 COLUMN_AUTOLOGIN, (a->options & OPT_USR_AUTO), 368 COLUMN_AUTOLOGIN, (a->options & OPT_ACCT_AUTO),
350 COLUMN_PROTOCOL, proto_name(a->protocol), 369 COLUMN_PROTOCOL, proto_name(a->protocol),
351 -1); 370 -1);
352 } 371 }
353 372
354 #if 0 373 #if 0
355 i = gtk_clist_find_row_from_data(GTK_CLIST(list), a); 374 i = gtk_clist_find_row_from_data(GTK_CLIST(list), a);
356 gtk_clist_set_text(GTK_CLIST(list), i, 0, a->username); 375 gtk_clist_set_text(GTK_CLIST(list), i, 0, a->username);
357 gtk_clist_set_text(GTK_CLIST(list), i, 2, 376 gtk_clist_set_text(GTK_CLIST(list), i, 2,
358 (a->options & OPT_USR_AUTO) ? "True" : "False"); 377 (a->options & OPT_ACCT_AUTO) ? "True" : "False");
359 gtk_clist_set_text(GTK_CLIST(list), i, 3, proto_name(a->protocol)); 378 gtk_clist_set_text(GTK_CLIST(list), i, 3, proto_name(a->protocol));
360 #endif 379 #endif
361 380
362 tmp = u->opt_entries; 381 tmp = ma->opt_entries;
363 while (tmp) { 382 while (tmp) {
364 GtkEntry *entry = tmp->data; 383 GtkEntry *entry = tmp->data;
365 int pos = (int)gtk_object_get_user_data(GTK_OBJECT(entry)); 384 int pos = (int)gtk_object_get_user_data(GTK_OBJECT(entry));
366 g_snprintf(a->proto_opt[pos], sizeof(a->proto_opt[pos]), "%s", 385 g_snprintf(a->proto_opt[pos], sizeof(a->proto_opt[pos]), "%s",
367 gtk_entry_get_text(entry)); 386 gtk_entry_get_text(entry));
368 tmp = tmp->next; 387 tmp = tmp->next;
369 } 388 }
370 if (u->opt_entries) 389 if (ma->opt_entries)
371 g_list_free(u->opt_entries); 390 g_list_free(ma->opt_entries);
372 u->opt_entries = NULL; 391 ma->opt_entries = NULL;
373 392
374 g_snprintf(a->iconfile, sizeof(a->iconfile), "%s", u->iconfile); 393 g_snprintf(a->iconfile, sizeof(a->iconfile), "%s", ma->iconfile);
375 if (u->icondlg) 394 if (ma->icondlg)
376 gtk_widget_destroy(u->icondlg); 395 gtk_widget_destroy(ma->icondlg);
377 u->icondlg = NULL; 396 ma->icondlg = NULL;
378 397
379 /* 398 /*
380 * See if user registration is supported/required 399 * See if user registration is supported/required
381 */ 400 */
382 if((p = find_prpl(u->protocol)) == NULL) { 401 if((p = find_prpl(ma->protocol)) == NULL) {
383 /* TBD: error dialog here! (This should never happen, you know...) */ 402 /* TBD: error dialog here! (This should never happen, you know...) */
384 fprintf(stderr, "dbg: couldn't find protocol for protocol number %d!\n", u->protocol); 403 fprintf(stderr, "dbg: couldn't find protocol for protocol number %d!\n", ma->protocol);
385 fflush(stderr); 404 fflush(stderr);
386 } else { 405 } else {
387 if(p->register_user != NULL && 406 if(p->register_user != NULL &&
388 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(u->register_user)) == TRUE) { 407 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ma->register_user)) == TRUE) {
389 ref_protocol(p); 408 ref_protocol(p);
390 p->register_user(a); 409 p->register_user(a);
391 /* we don't unref the protocol because register user has callbacks 410 /* we don't unref the protocol because register user has callbacks
392 * that need to get called first, then they will unref the protocol 411 * that need to get called first, then they will unref the protocol
393 * appropriately */ 412 * appropriately */
394 } 413 }
395 } 414 }
396 415
397 save_prefs(); 416 save_prefs();
398 417
399 gtk_widget_destroy(u->mod); 418 gtk_widget_destroy(ma->mod);
400 } 419 }
401 420
402 static void cancel_mod(GtkWidget *w, struct mod_user *u) 421 static void cancel_mod(GtkWidget *w, struct mod_account *ma)
403 { 422 {
404 if (u->opt_entries) 423 if (ma->opt_entries)
405 g_list_free(u->opt_entries); 424 g_list_free(ma->opt_entries);
406 u->opt_entries = NULL; 425 ma->opt_entries = NULL;
407 if (u->icondlg) 426 if (ma->icondlg)
408 gtk_widget_destroy(u->icondlg); 427 gtk_widget_destroy(ma->icondlg);
409 u->icondlg = NULL; 428 ma->icondlg = NULL;
410 gtk_widget_destroy(u->mod); 429 gtk_widget_destroy(ma->mod);
411 } 430 }
412 431
413 static void set_prot(GtkWidget *opt, int proto) 432 static void set_prot(GtkWidget *opt, int proto)
414 { 433 {
415 struct mod_user *u = gtk_object_get_user_data(GTK_OBJECT(opt)); 434 struct mod_account *ma = gtk_object_get_user_data(GTK_OBJECT(opt));
416 struct prpl *p, *q; 435 struct prpl *p, *q;
417 q = find_prpl(proto); 436 q = find_prpl(proto);
418 if (u->protocol != proto) { 437 if (ma->protocol != proto) {
419 int i; 438 int i;
420 for (i = 0; i < 7; i++) 439 for (i = 0; i < 7; i++)
421 u->proto_opt[i][0] = '\0'; 440 ma->proto_opt[i][0] = '\0';
422 p = find_prpl(u->protocol); 441 p = find_prpl(ma->protocol);
423 442
424 if (!(p->options & OPT_PROTO_NO_PASSWORD) && (q->options & OPT_PROTO_NO_PASSWORD)) { 443 if (!(p->options & OPT_PROTO_NO_PASSWORD) && (q->options & OPT_PROTO_NO_PASSWORD)) {
425 gtk_widget_hide(u->pwdbox); 444 gtk_widget_hide(ma->pwdbox);
426 gtk_widget_hide(u->rempass); 445 gtk_widget_hide(ma->rempass);
427 } else if ((p->options & OPT_PROTO_NO_PASSWORD) && !(q->options & OPT_PROTO_NO_PASSWORD)) { 446 } else if ((p->options & OPT_PROTO_NO_PASSWORD) && !(q->options & OPT_PROTO_NO_PASSWORD)) {
428 gtk_widget_show(u->pwdbox); 447 gtk_widget_show(ma->pwdbox);
429 gtk_widget_show(u->rempass); 448 gtk_widget_show(ma->rempass);
430 } 449 }
431 if (!(p->options & OPT_PROTO_MAIL_CHECK) && (q->options & OPT_PROTO_MAIL_CHECK)) { 450 if (!(p->options & OPT_PROTO_MAIL_CHECK) && (q->options & OPT_PROTO_MAIL_CHECK)) {
432 gtk_widget_show(u->checkmail); 451 gtk_widget_show(ma->checkmail);
433 } else if ((p->options & OPT_PROTO_MAIL_CHECK) && !(q->options & OPT_PROTO_MAIL_CHECK)) { 452 } else if ((p->options & OPT_PROTO_MAIL_CHECK) && !(q->options & OPT_PROTO_MAIL_CHECK)) {
434 gtk_widget_hide(u->checkmail); 453 gtk_widget_hide(ma->checkmail);
435 } 454 }
436 455
437 if (!(p->options & OPT_PROTO_BUDDY_ICON) && (q->options & OPT_PROTO_BUDDY_ICON)) { 456 if (!(p->options & OPT_PROTO_BUDDY_ICON) && (q->options & OPT_PROTO_BUDDY_ICON)) {
438 gtk_widget_show(u->iconsel); 457 gtk_widget_show(ma->iconsel);
439 } else if ((p->options & OPT_PROTO_BUDDY_ICON) && !(q->options & OPT_PROTO_BUDDY_ICON)) { 458 } else if ((p->options & OPT_PROTO_BUDDY_ICON) && !(q->options & OPT_PROTO_BUDDY_ICON)) {
440 gtk_widget_hide(u->iconsel); 459 gtk_widget_hide(ma->iconsel);
441 } 460 }
442 461
443 if ((q->options & OPT_PROTO_BUDDY_ICON) || (q->options & OPT_PROTO_MAIL_CHECK)) 462 if ((q->options & OPT_PROTO_BUDDY_ICON) || (q->options & OPT_PROTO_MAIL_CHECK))
444 gtk_widget_show(u->user_frame); 463 gtk_widget_show(ma->user_frame);
445 else 464 else
446 gtk_widget_hide(u->user_frame); 465 gtk_widget_hide(ma->user_frame);
447 466
448 u->protocol = proto; 467 ma->protocol = proto;
449 generate_protocol_options(u, u->main); 468 generate_protocol_options(ma, ma->main);
450 } 469 }
451 } 470 }
452 471
453 static GtkWidget *make_protocol_menu(GtkWidget *box, struct mod_user *u) 472 static GtkWidget *make_protocol_menu(GtkWidget *box, struct mod_account *ma)
454 { 473 {
455 GtkWidget *optmenu; 474 GtkWidget *optmenu;
456 GtkWidget *menu; 475 GtkWidget *menu;
457 GtkWidget *opt; 476 GtkWidget *opt;
458 GSList *p = protocols; 477 GSList *p = protocols;
466 485
467 menu = gtk_menu_new(); 486 menu = gtk_menu_new();
468 487
469 while (p) { 488 while (p) {
470 e = (struct prpl *)p->data; 489 e = (struct prpl *)p->data;
471 if (e->protocol == u->protocol) 490 if (e->protocol == ma->protocol)
472 found = TRUE; 491 found = TRUE;
473 if (!found) 492 if (!found)
474 count++; 493 count++;
475 if (e->name) 494 if (e->name)
476 opt = gtk_menu_item_new_with_label(e->name); 495 opt = gtk_menu_item_new_with_label(e->name);
477 else 496 else
478 opt = gtk_menu_item_new_with_label("Unknown"); 497 opt = gtk_menu_item_new_with_label("Unknown");
479 gtk_object_set_user_data(GTK_OBJECT(opt), u); 498 gtk_object_set_user_data(GTK_OBJECT(opt), ma);
480 g_signal_connect(GTK_OBJECT(opt), "activate", 499 g_signal_connect(GTK_OBJECT(opt), "activate",
481 G_CALLBACK(set_prot), (void *)e->protocol); 500 G_CALLBACK(set_prot), (void *)e->protocol);
482 gtk_menu_append(GTK_MENU(menu), opt); 501 gtk_menu_append(GTK_MENU(menu), opt);
483 gtk_widget_show(opt); 502 gtk_widget_show(opt);
484 p = p->next; 503 p = p->next;
488 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), count); 507 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), count);
489 508
490 return optmenu; 509 return optmenu;
491 } 510 }
492 511
493 static void des_icon_sel(GtkWidget *w, struct mod_user *u) 512 static void des_icon_sel(GtkWidget *w, struct mod_account *ma)
494 { 513 {
495 w = u->icondlg; 514 w = ma->icondlg;
496 if (u->icondlg) 515 if (ma->icondlg)
497 u->icondlg = NULL; 516 ma->icondlg = NULL;
498 if (w) 517 if (w)
499 gtk_widget_destroy(w); 518 gtk_widget_destroy(w);
500 } 519 }
501 520
502 static void set_icon(GtkWidget *w, struct mod_user *u) 521 static void set_icon(GtkWidget *w, struct mod_account *ma)
503 { 522 {
504 GtkWidget *sel = u->icondlg; 523 GtkWidget *sel = ma->icondlg;
505 const char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(sel)); 524 const char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(sel));
506 525
507 if (file_is_dir(file, sel)) 526 if (file_is_dir(file, sel))
508 return; 527 return;
509 528
510 gtk_entry_set_text(GTK_ENTRY(u->iconentry), file); 529 gtk_entry_set_text(GTK_ENTRY(ma->iconentry), file);
511 g_snprintf(u->iconfile, sizeof(u->iconfile), "%s", file); 530 g_snprintf(ma->iconfile, sizeof(ma->iconfile), "%s", file);
512 u->icondlg = NULL; 531 ma->icondlg = NULL;
513 532
514 gtk_widget_destroy(sel); 533 gtk_widget_destroy(sel);
515 } 534 }
516 535
517 static void sel_icon_dlg(GtkWidget *w, struct mod_user *u) 536 static void sel_icon_dlg(GtkWidget *w, struct mod_account *ma)
518 { 537 {
519 GtkWidget *dlg; 538 GtkWidget *dlg;
520 char buf[256]; 539 char buf[256];
521 540
522 if (u->icondlg) { 541 if (ma->icondlg) {
523 gtk_widget_show(u->icondlg); 542 gtk_widget_show(ma->icondlg);
524 return; 543 return;
525 } 544 }
526 545
527 dlg = gtk_file_selection_new(_("Gaim - Load Buddy Icon")); 546 dlg = gtk_file_selection_new(_("Gaim - Load Buddy Icon"));
528 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(dlg)); 547 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(dlg));
529 if (u->iconfile) { 548 if (ma->iconfile) {
530 char *tmp = g_dirname(u->iconfile); 549 char *tmp = g_dirname(ma->iconfile);
531 gtk_file_selection_set_filename(GTK_FILE_SELECTION(dlg), tmp); 550 gtk_file_selection_set_filename(GTK_FILE_SELECTION(dlg), tmp);
532 g_free(tmp); 551 g_free(tmp);
533 } else { 552 } else {
534 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S, gaim_home_dir()); 553 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S, gaim_home_dir());
535 gtk_file_selection_set_filename(GTK_FILE_SELECTION(dlg), buf); 554 gtk_file_selection_set_filename(GTK_FILE_SELECTION(dlg), buf);
536 } 555 }
537 556
538 g_signal_connect(GTK_OBJECT(dlg), "destroy", G_CALLBACK(des_icon_sel), u); 557 g_signal_connect(GTK_OBJECT(dlg), "destroy", G_CALLBACK(des_icon_sel), ma);
539 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(dlg)->cancel_button), "clicked", 558 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(dlg)->cancel_button), "clicked",
540 G_CALLBACK(des_icon_sel), u); 559 G_CALLBACK(des_icon_sel), ma);
541 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(dlg)->ok_button), "clicked", 560 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(dlg)->ok_button), "clicked",
542 G_CALLBACK(set_icon), u); 561 G_CALLBACK(set_icon), ma);
543 562
544 u->icondlg = dlg; 563 ma->icondlg = dlg;
545 564
546 gtk_widget_show(dlg); 565 gtk_widget_show(dlg);
547 } 566 }
548 567
549 static void reset_icon(GtkWidget *w, struct mod_user *u) 568 static void reset_icon(GtkWidget *w, struct mod_account *ma)
550 { 569 {
551 u->iconfile[0] = 0; 570 ma->iconfile[0] = 0;
552 gtk_entry_set_text(GTK_ENTRY(u->iconentry), ""); 571 gtk_entry_set_text(GTK_ENTRY(ma->iconentry), "");
553 } 572 }
554 573
555 static GtkWidget *build_icon_selection(struct mod_user *u, GtkWidget *box) 574 static GtkWidget *build_icon_selection(struct mod_account *ma, GtkWidget *box)
556 { 575 {
557 GtkWidget *hbox; 576 GtkWidget *hbox;
558 GtkWidget *label; 577 GtkWidget *label;
559 GtkWidget *name; 578 GtkWidget *name;
560 GtkWidget *browse; 579 GtkWidget *browse;
561 GtkWidget *reset; 580 GtkWidget *reset;
562 581
563 if (u->user) 582 if (ma->account)
564 g_snprintf(u->iconfile, sizeof(u->iconfile), "%s", u->user->iconfile); 583 g_snprintf(ma->iconfile, sizeof(ma->iconfile), "%s", ma->account->iconfile);
565 584
566 hbox = gtk_hbox_new(FALSE, 0); 585 hbox = gtk_hbox_new(FALSE, 0);
567 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5); 586 gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5);
568 gtk_widget_show(hbox); 587 gtk_widget_show(hbox);
569 588
570 label = gtk_label_new(_("Buddy Icon File:")); 589 label = gtk_label_new(_("Buddy Icon File:"));
571 gtk_size_group_add_widget(u->sg, label); 590 gtk_size_group_add_widget(ma->sg, label);
572 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); 591 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
573 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); 592 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
574 gtk_widget_show(label); 593 gtk_widget_show(label);
575 594
576 name = gtk_entry_new(); 595 name = gtk_entry_new();
577 gtk_entry_set_text(GTK_ENTRY(name), u->iconfile); 596 gtk_entry_set_text(GTK_ENTRY(name), ma->iconfile);
578 gtk_entry_set_editable(GTK_ENTRY(name), FALSE); 597 gtk_entry_set_editable(GTK_ENTRY(name), FALSE);
579 gtk_box_pack_start(GTK_BOX(hbox), name, TRUE, TRUE, 5); 598 gtk_box_pack_start(GTK_BOX(hbox), name, TRUE, TRUE, 5);
580 gtk_widget_show(name); 599 gtk_widget_show(name);
581 u->iconentry = name; 600 ma->iconentry = name;
582 601
583 browse = gtk_button_new_with_label(_("Browse")); 602 browse = gtk_button_new_with_label(_("Browse"));
584 g_signal_connect(GTK_OBJECT(browse), "clicked", G_CALLBACK(sel_icon_dlg), u); 603 g_signal_connect(GTK_OBJECT(browse), "clicked", G_CALLBACK(sel_icon_dlg), ma);
585 gtk_box_pack_start(GTK_BOX(hbox), browse, FALSE, FALSE, 0); 604 gtk_box_pack_start(GTK_BOX(hbox), browse, FALSE, FALSE, 0);
586 gtk_widget_show(browse); 605 gtk_widget_show(browse);
587 606
588 reset = gtk_button_new_with_label(_("Reset")); 607 reset = gtk_button_new_with_label(_("Reset"));
589 g_signal_connect(GTK_OBJECT(reset), "clicked", G_CALLBACK(reset_icon), u); 608 g_signal_connect(GTK_OBJECT(reset), "clicked", G_CALLBACK(reset_icon), ma);
590 gtk_box_pack_start(GTK_BOX(hbox), reset, FALSE, FALSE, 0); 609 gtk_box_pack_start(GTK_BOX(hbox), reset, FALSE, FALSE, 0);
591 gtk_widget_show(reset); 610 gtk_widget_show(reset);
592 611
593 return hbox; 612 return hbox;
594 } 613 }
595 614
596 static void generate_login_options(struct mod_user *u, GtkWidget *box) 615 static void generate_login_options(struct mod_account *ma, GtkWidget *box)
597 { 616 {
598 GtkWidget *frame, *frame_parent; 617 GtkWidget *frame, *frame_parent;
599 GtkWidget *vbox; 618 GtkWidget *vbox;
600 GtkWidget *hbox; 619 GtkWidget *hbox;
601 GtkWidget *label; 620 GtkWidget *label;
611 630
612 hbox = gtk_hbox_new(FALSE, 5); 631 hbox = gtk_hbox_new(FALSE, 5);
613 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 632 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
614 633
615 label = gtk_label_new(_("Screenname:")); 634 label = gtk_label_new(_("Screenname:"));
616 gtk_size_group_add_widget(u->sg, label); 635 gtk_size_group_add_widget(ma->sg, label);
617 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); 636 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
618 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); 637 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
619 638
620 u->name = gtk_entry_new(); 639 ma->name = gtk_entry_new();
621 gtk_box_pack_start(GTK_BOX(hbox), u->name, TRUE, TRUE, 0); 640 gtk_box_pack_start(GTK_BOX(hbox), ma->name, TRUE, TRUE, 0);
622 641
623 u->pwdbox = gtk_hbox_new(FALSE, 5); 642 ma->pwdbox = gtk_hbox_new(FALSE, 5);
624 gtk_box_pack_start(GTK_BOX(vbox), u->pwdbox, FALSE, FALSE, 0); 643 gtk_box_pack_start(GTK_BOX(vbox), ma->pwdbox, FALSE, FALSE, 0);
625 644
626 label = gtk_label_new(_("Password:")); 645 label = gtk_label_new(_("Password:"));
627 gtk_size_group_add_widget(u->sg, label); 646 gtk_size_group_add_widget(ma->sg, label);
628 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); 647 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
629 gtk_box_pack_start(GTK_BOX(u->pwdbox), label, FALSE, FALSE, 0); 648 gtk_box_pack_start(GTK_BOX(ma->pwdbox), label, FALSE, FALSE, 0);
630 649
631 u->pass = gtk_entry_new(); 650 ma->pass = gtk_entry_new();
632 gtk_box_pack_start(GTK_BOX(u->pwdbox), u->pass, TRUE, TRUE, 0); 651 gtk_box_pack_start(GTK_BOX(ma->pwdbox), ma->pass, TRUE, TRUE, 0);
633 gtk_entry_set_visibility(GTK_ENTRY(u->pass), FALSE); 652 gtk_entry_set_visibility(GTK_ENTRY(ma->pass), FALSE);
634 653
635 hbox = gtk_hbox_new(FALSE, 5); 654 hbox = gtk_hbox_new(FALSE, 5);
636 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 655 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
637 656
638 label = gtk_label_new(_("Alias:")); 657 label = gtk_label_new(_("Alias:"));
639 gtk_size_group_add_widget(u->sg, label); 658 gtk_size_group_add_widget(ma->sg, label);
640 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); 659 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
641 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); 660 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
642 661
643 u->alias = gtk_entry_new(); 662 ma->alias = gtk_entry_new();
644 gtk_box_pack_start(GTK_BOX(hbox), u->alias, TRUE, TRUE, 0); 663 gtk_box_pack_start(GTK_BOX(hbox), ma->alias, TRUE, TRUE, 0);
645 664
646 hbox = gtk_hbox_new(FALSE, 5); 665 hbox = gtk_hbox_new(FALSE, 5);
647 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 666 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
648 gtk_widget_show(hbox); 667 gtk_widget_show(hbox);
649 668
650 label = gtk_label_new(_("Protocol:")); 669 label = gtk_label_new(_("Protocol:"));
651 gtk_size_group_add_widget(u->sg, label); 670 gtk_size_group_add_widget(ma->sg, label);
652 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); 671 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
653 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); 672 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
654 673
655 make_protocol_menu(hbox, u); 674 make_protocol_menu(hbox, ma);
656 675
657 u->rempass = acct_button(_("Remember Password"), u, OPT_USR_REM_PASS, vbox); 676 ma->rempass = acct_button(_("Remember Password"), ma, OPT_ACCT_REM_PASS, vbox);
658 acct_button(_("Auto-Login"), u, OPT_USR_AUTO, vbox); 677 acct_button(_("Auto-Login"), ma, OPT_ACCT_AUTO, vbox);
659 678
660 gtk_widget_show_all(frame_parent); 679 gtk_widget_show_all(frame_parent);
661 680
662 if (u->user) { 681 if (ma->account) {
663 gtk_entry_set_text(GTK_ENTRY(u->name), u->user->username); 682 gtk_entry_set_text(GTK_ENTRY(ma->name), ma->account->username);
664 gtk_entry_set_text(GTK_ENTRY(u->alias), u->user->alias); 683 gtk_entry_set_text(GTK_ENTRY(ma->alias), ma->account->alias);
665 gtk_entry_set_text(GTK_ENTRY(u->pass), u->user->password); 684 gtk_entry_set_text(GTK_ENTRY(ma->pass), ma->account->password);
666 } 685 }
667 686
668 p = find_prpl(u->protocol); 687 p = find_prpl(ma->protocol);
669 if (p && (p->options & OPT_PROTO_NO_PASSWORD)) { 688 if (p && (p->options & OPT_PROTO_NO_PASSWORD)) {
670 gtk_widget_hide(u->pwdbox); 689 gtk_widget_hide(ma->pwdbox);
671 gtk_widget_hide(u->rempass); 690 gtk_widget_hide(ma->rempass);
672 } 691 }
673 } 692 }
674 693
675 static void generate_user_options(struct mod_user *u, GtkWidget *box) 694 static void generate_user_options(struct mod_account *ma, GtkWidget *box)
676 { 695 {
677 /* This function will add the appropriate (depending on the current 696 /* This function will add the appropriate (depending on the current
678 * protocol) widgets to frame and return TRUE if there anything 697 * protocol) widgets to frame and return TRUE if there anything
679 * was added (meaning the frame should be shown) 698 * was added (meaning the frame should be shown)
680 * Eric will most likely change this (as he does all other submitted code) 699 * Eric will most likely change this (as he does all other submitted code)
684 /* Sean was right. I did do that. I told him I would. */ 703 /* Sean was right. I did do that. I told him I would. */
685 704
686 GtkWidget *vbox; 705 GtkWidget *vbox;
687 GtkWidget *frame; 706 GtkWidget *frame;
688 707
689 struct prpl *p = find_prpl(u->protocol); 708 struct prpl *p = find_prpl(ma->protocol);
690 709
691 frame = make_frame(box, _("User Options")); 710 frame = make_frame(box, _("User Options"));
692 u->user_frame = gtk_widget_get_parent(gtk_widget_get_parent(frame)); 711 ma->user_frame = gtk_widget_get_parent(gtk_widget_get_parent(frame));
693 gtk_widget_show_all(u->user_frame); 712 gtk_widget_show_all(ma->user_frame);
694 713
695 vbox = gtk_vbox_new(FALSE, 5); 714 vbox = gtk_vbox_new(FALSE, 5);
696 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); 715 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
697 gtk_container_add(GTK_CONTAINER(frame), vbox); 716 gtk_container_add(GTK_CONTAINER(frame), vbox);
698 gtk_widget_show(vbox); 717 gtk_widget_show(vbox);
699 718
700 u->checkmail = acct_button(_("New Mail Notifications"), u, OPT_USR_MAIL_CHECK, vbox); 719 ma->checkmail = acct_button(_("New Mail Notifications"), ma, OPT_ACCT_MAIL_CHECK, vbox);
701 u->iconsel = build_icon_selection(u, vbox); 720 ma->iconsel = build_icon_selection(ma, vbox);
702 721
703 if (!p) { 722 if (!p) {
704 gtk_widget_hide(u->user_frame); 723 gtk_widget_hide(ma->user_frame);
705 return; 724 return;
706 } 725 }
707 726
708 if (!(p->options & OPT_PROTO_MAIL_CHECK)) 727 if (!(p->options & OPT_PROTO_MAIL_CHECK))
709 gtk_widget_hide(u->checkmail); 728 gtk_widget_hide(ma->checkmail);
710 if (!(p->options & OPT_PROTO_BUDDY_ICON)) 729 if (!(p->options & OPT_PROTO_BUDDY_ICON))
711 gtk_widget_hide(u->iconsel); 730 gtk_widget_hide(ma->iconsel);
712 731
713 if ((p->options & OPT_PROTO_BUDDY_ICON) || (p->options & OPT_PROTO_MAIL_CHECK)) 732 if ((p->options & OPT_PROTO_BUDDY_ICON) || (p->options & OPT_PROTO_MAIL_CHECK))
714 return; 733 return;
715 gtk_widget_hide(u->user_frame); 734 gtk_widget_hide(ma->user_frame);
716 } 735 }
717 736
718 static void generate_protocol_options(struct mod_user *u, GtkWidget *box) 737 static void generate_protocol_options(struct mod_account *ma, GtkWidget *box)
719 { 738 {
720 struct prpl *p = find_prpl(u->protocol); 739 struct prpl *p = find_prpl(ma->protocol);
721 740
722 GList *op, *tmp; 741 GList *op, *tmp;
723 742
724 GtkWidget *vbox; 743 GtkWidget *vbox;
725 GtkWidget *hbox; 744 GtkWidget *hbox;
727 GtkWidget *entry; 746 GtkWidget *entry;
728 GtkWidget *frame; 747 GtkWidget *frame;
729 748
730 char buf[256]; 749 char buf[256];
731 750
732 if (u->proto_frame) 751 if (ma->proto_frame)
733 gtk_widget_destroy(u->proto_frame); 752 gtk_widget_destroy(ma->proto_frame);
734 u->proto_frame = NULL; 753 ma->proto_frame = NULL;
735 754
736 if (u->opt_entries) { 755 if (ma->opt_entries) {
737 g_list_free(u->opt_entries); 756 g_list_free(ma->opt_entries);
738 u->opt_entries = NULL; 757 ma->opt_entries = NULL;
739 } 758 }
740 759
741 if (!p) 760 if (!p)
742 return; 761 return;
743 762
751 770
752 g_snprintf(buf, sizeof(buf), _("%s Options"), p->name); 771 g_snprintf(buf, sizeof(buf), _("%s Options"), p->name);
753 frame = make_frame(box, buf); 772 frame = make_frame(box, buf);
754 773
755 /* BLEH */ 774 /* BLEH */
756 u->proto_frame = gtk_widget_get_parent(gtk_widget_get_parent(frame)); 775 ma->proto_frame = gtk_widget_get_parent(gtk_widget_get_parent(frame));
757 gtk_widget_show_all(u->proto_frame); 776 gtk_widget_show_all(ma->proto_frame);
758 777
759 vbox = gtk_vbox_new(FALSE, 5); 778 vbox = gtk_vbox_new(FALSE, 5);
760 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5); 779 gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
761 gtk_container_add(GTK_CONTAINER(frame), vbox); 780 gtk_container_add(GTK_CONTAINER(frame), vbox);
762 gtk_widget_show(vbox); 781 gtk_widget_show(vbox);
767 hbox = gtk_hbox_new(FALSE, 5); 786 hbox = gtk_hbox_new(FALSE, 5);
768 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 787 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
769 gtk_widget_show(hbox); 788 gtk_widget_show(hbox);
770 789
771 label = gtk_label_new(puo->label); 790 label = gtk_label_new(puo->label);
772 gtk_size_group_add_widget(u->sg, label); 791 gtk_size_group_add_widget(ma->sg, label);
773 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); 792 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
774 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); 793 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
775 gtk_widget_show(label); 794 gtk_widget_show(label);
776 795
777 entry = gtk_entry_new(); 796 entry = gtk_entry_new();
778 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0); 797 gtk_box_pack_end(GTK_BOX(hbox), entry, FALSE, FALSE, 0);
779 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)puo->pos); 798 gtk_object_set_user_data(GTK_OBJECT(entry), (void *)puo->pos);
780 if (u->proto_opt[puo->pos][0]) { 799 if (ma->proto_opt[puo->pos][0]) {
781 debug_printf("setting text %s\n", u->proto_opt[puo->pos]); 800 debug_printf("setting text %s\n", ma->proto_opt[puo->pos]);
782 gtk_entry_set_text(GTK_ENTRY(entry), u->proto_opt[puo->pos]); 801 gtk_entry_set_text(GTK_ENTRY(entry), ma->proto_opt[puo->pos]);
783 } else { 802 } else {
784 gtk_entry_set_text(GTK_ENTRY(entry), puo->def); 803 gtk_entry_set_text(GTK_ENTRY(entry), puo->def);
785 } 804 }
786 gtk_widget_show(entry); 805 gtk_widget_show(entry);
787 806
788 u->opt_entries = g_list_append(u->opt_entries, entry); 807 ma->opt_entries = g_list_append(ma->opt_entries, entry);
789 808
790 op = op->next; 809 op = op->next;
791 } 810 }
792 811
793 if(p->register_user != NULL) { 812 if(p->register_user != NULL) {
794 u->register_user = gtk_check_button_new_with_label(_("Register with server")); 813 ma->register_user = gtk_check_button_new_with_label(_("Register with server"));
795 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(u->register_user), FALSE); 814 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(ma->register_user), FALSE);
796 gtk_box_pack_start(GTK_BOX(vbox), u->register_user, FALSE, FALSE, 0); 815 gtk_box_pack_start(GTK_BOX(vbox), ma->register_user, FALSE, FALSE, 0);
797 gtk_widget_show(u->register_user); 816 gtk_widget_show(ma->register_user);
798 } 817 }
799 818
800 } 819 }
801 820
802 static void show_acct_mod(struct aim_user *a) 821 static void show_acct_mod(struct gaim_account *a)
803 { 822 {
804 /* This is the fucking modify account dialog. I've fucking seperated it into 823 /* This is the fucking modify account dialog. I've fucking seperated it into
805 * three fucking frames: 824 * three fucking frames:
806 * a fucking Login Options frame, a fucking User Options frame and a fucking 825 * a fucking Login Options frame, a fucking User Options frame and a fucking
807 * Protcol Options frame. This fucking removes the two fucking tabs, which were 826 * Protcol Options frame. This fucking removes the two fucking tabs, which
808 * quite fucking uneccessary. Fuck. */ 827 * were quite fucking uneccessary. Fuck. */
809 /* -- SeanEgan */ 828 /* -- SeanEgan */
810 /* YEAH!! -- ChipX86 */ 829 /* YEAH!! -- ChipX86 */
811 GtkWidget *hbox, *vbox; 830 GtkWidget *hbox, *vbox;
812 GtkWidget *button; 831 GtkWidget *button;
813 GtkWidget *sep; 832 GtkWidget *sep;
814 GtkSizeGroup *button_sg; 833 GtkSizeGroup *button_sg;
815 834
816 struct mod_user *u = find_mod_user(a); 835 struct mod_account *ma = mod_account_find(a);
817 836
818 if (!u) { 837 if (!ma) {
819 u = g_new0(struct mod_user, 1); 838 ma = g_new0(struct mod_account, 1);
820 u->user = a; 839 ma->account = a;
821 mod_users = g_slist_append(mod_users, u); 840 mod_accounts = g_slist_append(mod_accounts, ma);
822 841
823 if (a) { 842 if (a) {
824 int i; 843 int i;
825 u->options = a->options; 844 ma->options = a->options;
826 if (find_prpl(a->protocol)) 845 if (find_prpl(a->protocol))
827 u->protocol = a->protocol; 846 ma->protocol = a->protocol;
828 else if (protocols) 847 else if (protocols)
829 u->protocol = ((struct prpl *)protocols->data)->protocol; 848 ma->protocol = ((struct prpl *)protocols->data)->protocol;
830 else 849 else
831 u->protocol = -1; 850 ma->protocol = -1;
832 g_snprintf(u->iconfile, sizeof(u->iconfile), "%s", a->iconfile); 851 g_snprintf(ma->iconfile, sizeof(ma->iconfile), "%s", a->iconfile);
833 for (i = 0; i < 7; i++) 852 for (i = 0; i < 7; i++)
834 g_snprintf(u->proto_opt[i], sizeof(u->proto_opt[i]), "%s", 853 g_snprintf(ma->proto_opt[i], sizeof(ma->proto_opt[i]), "%s",
835 a->proto_opt[i]); 854 a->proto_opt[i]);
836 } else { 855 } else {
837 u->options = OPT_USR_REM_PASS; 856 ma->options = OPT_ACCT_REM_PASS;
838 if (find_prpl(DEFAULT_PROTO)) 857 if (find_prpl(DEFAULT_PROTO))
839 u->protocol = DEFAULT_PROTO; 858 ma->protocol = DEFAULT_PROTO;
840 else if (protocols) 859 else if (protocols)
841 u->protocol = ((struct prpl *)protocols->data)->protocol; 860 ma->protocol = ((struct prpl *)protocols->data)->protocol;
842 else 861 else
843 u->protocol = -1; 862 ma->protocol = -1;
844 } 863 }
845 } else { 864 } else {
846 gtk_widget_show(u->mod); 865 gtk_widget_show(ma->mod);
847 return; 866 return;
848 } 867 }
849 868
850 u->mod = gtk_window_new(GTK_WINDOW_TOPLEVEL); 869 ma->mod = gtk_window_new(GTK_WINDOW_TOPLEVEL);
851 gtk_window_set_role(GTK_WINDOW(u->mod), "account"); 870 gtk_window_set_role(GTK_WINDOW(ma->mod), "account");
852 gtk_widget_realize(u->mod); 871 gtk_widget_realize(ma->mod);
853 gtk_window_set_title(GTK_WINDOW(u->mod), _("Gaim - Modify Account")); 872 gtk_window_set_title(GTK_WINDOW(ma->mod), _("Gaim - Modify Account"));
854 gtk_window_set_policy(GTK_WINDOW(u->mod), FALSE, FALSE, TRUE); /* nothing odd here :) */ 873 gtk_window_set_policy(GTK_WINDOW(ma->mod), FALSE, FALSE, TRUE); /* nothing odd here :) */
855 g_signal_connect(GTK_OBJECT(u->mod), "destroy", G_CALLBACK(delmod), u); 874 g_signal_connect(GTK_OBJECT(ma->mod), "destroy", G_CALLBACK(delmod), ma);
856 875
857 vbox = gtk_vbox_new(FALSE, 6); 876 vbox = gtk_vbox_new(FALSE, 6);
858 gtk_container_border_width(GTK_CONTAINER(vbox), 6); 877 gtk_container_border_width(GTK_CONTAINER(vbox), 6);
859 gtk_container_add(GTK_CONTAINER(u->mod), vbox); 878 gtk_container_add(GTK_CONTAINER(ma->mod), vbox);
860 gtk_widget_show(vbox); 879 gtk_widget_show(vbox);
861 880
862 u->main = gtk_vbox_new(FALSE, 12); 881 ma->main = gtk_vbox_new(FALSE, 12);
863 gtk_container_border_width(GTK_CONTAINER(u->main), 6); 882 gtk_container_border_width(GTK_CONTAINER(ma->main), 6);
864 gtk_box_pack_start(GTK_BOX(vbox), u->main, FALSE, FALSE, 0); 883 gtk_box_pack_start(GTK_BOX(vbox), ma->main, FALSE, FALSE, 0);
865 gtk_widget_show(u->main); 884 gtk_widget_show(ma->main);
866 885
867 u->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); 886 ma->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
868 887
869 generate_login_options(u, u->main); 888 generate_login_options(ma, ma->main);
870 generate_user_options(u, u->main); 889 generate_user_options(ma, ma->main);
871 generate_protocol_options(u, u->main); 890 generate_protocol_options(ma, ma->main);
872 891
873 hbox = gtk_hbox_new(FALSE, 6); 892 hbox = gtk_hbox_new(FALSE, 6);
874 gtk_container_set_border_width (GTK_CONTAINER (hbox), 6); 893 gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
875 gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 894 gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
876 895
877 button_sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); 896 button_sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);
878 897
879 button = gtk_button_new_from_stock(GTK_STOCK_OK); 898 button = gtk_button_new_from_stock(GTK_STOCK_OK);
880 gtk_size_group_add_widget(button_sg, button); 899 gtk_size_group_add_widget(button_sg, button);
881 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); 900 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
882 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(ok_mod), u); 901 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(ok_mod), ma);
883 902
884 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); 903 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
885 gtk_size_group_add_widget(button_sg, button); 904 gtk_size_group_add_widget(button_sg, button);
886 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); 905 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
887 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(cancel_mod), u); 906 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(cancel_mod), ma);
888 907
889 sep = gtk_hseparator_new(); 908 sep = gtk_hseparator_new();
890 gtk_box_pack_end (GTK_BOX (vbox), sep, FALSE, FALSE, 0); 909 gtk_box_pack_end (GTK_BOX (vbox), sep, FALSE, FALSE, 0);
891 gtk_widget_show(sep); 910 gtk_widget_show(sep);
892 911
893 gtk_widget_show_all(hbox); 912 gtk_widget_show_all(hbox);
894 gtk_widget_show(u->mod); 913 gtk_widget_show(ma->mod);
895 } 914 }
896 915
897 static void add_acct(GtkWidget *w, gpointer d) 916 static void add_acct(GtkWidget *w, gpointer d)
898 { 917 {
899 show_acct_mod(NULL); 918 show_acct_mod(NULL);
900 } 919 }
901 920
902 static void mod_acct_func(GtkTreeModel *model, GtkTreePath *path, 921 static void mod_acct_func(GtkTreeModel *model, GtkTreePath *path,
903 GtkTreeIter *iter, gpointer data) 922 GtkTreeIter *iter, gpointer data)
904 { 923 {
905 struct aim_user *u; 924 struct gaim_account *a;
906 925
907 gtk_tree_model_get(model, iter, COLUMN_DATA, &u, -1); 926 gtk_tree_model_get(model, iter, COLUMN_DATA, &a, -1);
908 927
909 if (u != NULL) 928 if (a != NULL)
910 show_acct_mod(u); 929 show_acct_mod(a);
911 } 930 }
912 931
913 static void mod_acct(GtkWidget *w, gpointer d) 932 static void mod_acct(GtkWidget *w, gpointer d)
914 { 933 {
915 GtkTreeSelection *selection; 934 GtkTreeSelection *selection;
916 935
917 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); 936 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
918 937
919 gtk_tree_selection_selected_foreach(selection, mod_acct_func, NULL); 938 gtk_tree_selection_selected_foreach(selection, mod_acct_func, NULL);
920
921 #if 0
922 while (l) {
923 row = (int)l->data;
924 if (row != -1) {
925 u = g_slist_nth_data(aim_users, row);
926 if (u)
927 show_acct_mod(u);
928 }
929 l = l->next;
930 }
931 #endif
932 } 939 }
933 940
934 struct pass_prompt { 941 struct pass_prompt {
935 struct aim_user *u; 942 struct gaim_account *account;
936 GtkWidget *win; 943 GtkWidget *win;
937 GtkWidget *entry; 944 GtkWidget *entry;
938 }; 945 };
939 static GSList *passes = NULL; 946 static GSList *passes = NULL;
940 947
941 static struct pass_prompt *find_pass_prompt(struct aim_user *u) 948 static struct pass_prompt *find_pass_prompt(struct gaim_account *account)
942 { 949 {
943 GSList *p = passes; 950 GSList *p = passes;
944 while (p) { 951 while (p) {
945 struct pass_prompt *r = p->data; 952 struct pass_prompt *r = p->data;
946 if (r->u == u) 953 if (r->account == account)
947 return r; 954 return r;
948 p = p->next; 955 p = p->next;
949 } 956 }
950 return NULL; 957 return NULL;
951 } 958 }
952 959
953 static void pass_callback(GtkDialog *d, gint resp, struct pass_prompt *p) 960 static void pass_callback(GtkDialog *d, gint resp, struct pass_prompt *p)
954 { 961 {
955 if (resp == GTK_RESPONSE_YES) { 962 if (resp == GTK_RESPONSE_YES) {
956 const char *txt = gtk_entry_get_text(GTK_ENTRY(p->entry)); 963 const char *txt = gtk_entry_get_text(GTK_ENTRY(p->entry));
957 g_snprintf(p->u->password, sizeof(p->u->password), "%s", txt); 964 g_snprintf(p->account->password, sizeof(p->account->password), "%s", txt);
958 serv_login(p->u); 965 serv_login(p->account);
959 } 966 }
960 passes = g_slist_remove(passes, p); 967 passes = g_slist_remove(passes, p);
961 gtk_widget_destroy(p->win); 968 gtk_widget_destroy(p->win);
962 g_free(p); 969 g_free(p);
963 } 970 }
964 971
965 static void do_pass_dlg(struct aim_user *u) 972 static void do_pass_dlg(struct gaim_account *account)
966 { 973 {
967 /* we can safely assume that u is not NULL */ 974 /* we can safely assume that u is not NULL */
968 struct pass_prompt *p = find_pass_prompt(u); 975 struct pass_prompt *p = find_pass_prompt(account);
969 GtkWidget *label; 976 GtkWidget *label;
970 GtkWidget *hbox, *vbox; 977 GtkWidget *hbox, *vbox;
971 char *labeltext=NULL; 978 char *labeltext=NULL;
972 char *filename = g_build_filename(DATADIR, "pixmaps", "gaim", "dialogs", "gaim_auth.png", NULL); 979 char *filename = g_build_filename(DATADIR, "pixmaps", "gaim", "dialogs", "gaim_auth.png", NULL);
973 GtkWidget *img = gtk_image_new_from_file(filename); 980 GtkWidget *img = gtk_image_new_from_file(filename);
974 g_free(filename); 981 g_free(filename);
975 982
976 983
977 if (p) { 984 if (p) {
978 gtk_widget_show(p->win); 985 gtk_widget_show(p->win);
979 return; 986 return;
980 } 987 }
981 988
982 p = g_new0(struct pass_prompt, 1); 989 p = g_new0(struct pass_prompt, 1);
983 p->u = u; 990 p->account = account;
984 passes = g_slist_append(passes, p); 991 passes = g_slist_append(passes, p);
985 992
986 p->win = gtk_dialog_new_with_buttons("", NULL, 0, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, 993 p->win = gtk_dialog_new_with_buttons("", NULL, 0, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
987 _("_Login"), GTK_RESPONSE_YES, NULL); 994 _("_Login"), GTK_RESPONSE_YES, NULL);
988 995
989 gtk_dialog_set_default_response (GTK_DIALOG(p->win), GTK_RESPONSE_YES); 996 gtk_dialog_set_default_response (GTK_DIALOG(p->win), GTK_RESPONSE_YES);
990 g_signal_connect(G_OBJECT(p->win), "response", G_CALLBACK(pass_callback), p); 997 g_signal_connect(G_OBJECT(p->win), "response", G_CALLBACK(pass_callback), p);
991 998
1000 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); 1007 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0);
1001 1008
1002 vbox = gtk_vbox_new(FALSE, 0); 1009 vbox = gtk_vbox_new(FALSE, 0);
1003 gtk_container_add(GTK_CONTAINER(hbox), vbox); 1010 gtk_container_add(GTK_CONTAINER(hbox), vbox);
1004 1011
1005 labeltext = g_strdup_printf(_("Please enter your password for %s.\n\n"), u->username); 1012 labeltext = g_strdup_printf(_("Please enter your password for %s.\n\n"),
1013 account->username);
1006 label = gtk_label_new(labeltext); 1014 label = gtk_label_new(labeltext);
1007 g_free(labeltext); 1015 g_free(labeltext);
1008 1016
1009 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); 1017 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
1010 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); 1018 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
1011 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); 1019 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
1012 1020
1013 hbox = gtk_hbox_new(FALSE, 5); 1021 hbox = gtk_hbox_new(FALSE, 5);
1014 gtk_container_add(GTK_CONTAINER(vbox), hbox); 1022 gtk_container_add(GTK_CONTAINER(vbox), hbox);
1015 label = gtk_label_new_with_mnemonic(_("_Password")); 1023 label = gtk_label_new_with_mnemonic(_("_Password"));
1016 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); 1024 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
1017 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); 1025 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
1029 gpointer d) 1037 gpointer d)
1030 { 1038 {
1031 GtkTreeModel *model = (GtkTreeModel *)d; 1039 GtkTreeModel *model = (GtkTreeModel *)d;
1032 GtkTreeIter iter; 1040 GtkTreeIter iter;
1033 1041
1034 struct aim_user *u = NULL; 1042 struct gaim_account *account = NULL;
1035 struct prpl *p = NULL; 1043 struct prpl *p = NULL;
1036 1044
1037 gtk_tree_model_get_iter_from_string(model, &iter, path_str); 1045 gtk_tree_model_get_iter_from_string(model, &iter, path_str);
1038 gtk_tree_model_get(model, &iter, COLUMN_DATA, &u, -1); 1046 gtk_tree_model_get(model, &iter, COLUMN_DATA, &account, -1);
1039 1047
1040 p = find_prpl(u->protocol); 1048 p = find_prpl(account->protocol);
1041 if (!u->gc && p && p->login) { 1049 if (!account->gc && p && p->login) {
1042 struct prpl *p = find_prpl(u->protocol); 1050 struct prpl *p = find_prpl(account->protocol);
1043 if (p && !(p->options & OPT_PROTO_NO_PASSWORD) && 1051 if (p && !(p->options & OPT_PROTO_NO_PASSWORD) &&
1044 !(p->options & OPT_PROTO_PASSWORD_OPTIONAL) && !u->password[0]) { 1052 !(p->options & OPT_PROTO_PASSWORD_OPTIONAL) && !account->password[0]) {
1045 do_pass_dlg(u); 1053 do_pass_dlg(account);
1046 } else { 1054 } else {
1047 serv_login(u); 1055 serv_login(account);
1048 } 1056 }
1049 } else if (u->gc) { 1057 } else if (account->gc) {
1050 u->gc->wants_to_die = TRUE; 1058 account->gc->wants_to_die = TRUE;
1051 signoff(u->gc); 1059 signoff(account->gc);
1052 } else { 1060 } else {
1053 if (u->protocol == PROTO_TOC) 1061 if (account->protocol == PROTO_TOC)
1054 do_error_dialog(_("TOC not found."), 1062 do_error_dialog(_("TOC not found."),
1055 _("You have attempted to login an IM account using the " 1063 _("You have attempted to login an IM account using the "
1056 "TOC protocol. Because this protocol is inferior to " 1064 "TOC protocol. Because this protocol is inferior to "
1057 "OSCAR, it is now compiled as a plugin by default. " 1065 "OSCAR, it is now compiled as a plugin by default. "
1058 "To login, edit this account to use OSCAR or load the " 1066 "To login, edit this account to use OSCAR or load the "
1069 gpointer d) 1077 gpointer d)
1070 { 1078 {
1071 GtkTreeModel *model = (GtkTreeModel *)d; 1079 GtkTreeModel *model = (GtkTreeModel *)d;
1072 GtkTreeIter iter; 1080 GtkTreeIter iter;
1073 1081
1074 struct aim_user *u = NULL; 1082 struct gaim_account *account = NULL;
1075 1083
1076 gtk_tree_model_get_iter_from_string(model, &iter, path_str); 1084 gtk_tree_model_get_iter_from_string(model, &iter, path_str);
1077 gtk_tree_model_get(model, &iter, COLUMN_DATA, &u, -1); 1085 gtk_tree_model_get(model, &iter, COLUMN_DATA, &account, -1);
1078 1086
1079 u->options ^= OPT_USR_AUTO; 1087 account->options ^= OPT_ACCT_AUTO;
1080 1088
1081 gtk_list_store_set(GTK_LIST_STORE(model), &iter, 1089 gtk_list_store_set(GTK_LIST_STORE(model), &iter,
1082 COLUMN_AUTOLOGIN, (u->options & OPT_USR_AUTO), -1); 1090 COLUMN_AUTOLOGIN, (account->options & OPT_ACCT_AUTO), -1);
1083 1091
1084 save_prefs(); 1092 save_prefs();
1085 } 1093 }
1086 1094
1087 static void do_del_acct(struct aim_user *u) 1095 static void do_del_acct(struct gaim_account *account)
1088 { 1096 {
1089 GtkTreeIter iter; 1097 GtkTreeIter iter;
1090 GSList *grps = groups, *buds; 1098 GSList *grps = groups, *buds;
1091 1099
1092 if (u->gc) { 1100 if (account->gc) {
1093 u->gc->wants_to_die = TRUE; 1101 account->gc->wants_to_die = TRUE;
1094 signoff(u->gc); 1102 signoff(account->gc);
1095 } 1103 }
1096 1104
1097 if (get_iter_from_data(GTK_TREE_VIEW(treeview), u, &iter)) { 1105 if (get_iter_from_data(GTK_TREE_VIEW(treeview), account, &iter)) {
1098 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); 1106 gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
1099 } 1107 }
1100 1108
1101 1109
1102 /* remove the buddies for the account we just destroyed */ 1110 /* remove the buddies for the account we just destroyed */
1105 grps = grps->next; 1113 grps = grps->next;
1106 buds = g->members; 1114 buds = g->members;
1107 while(buds) { 1115 while(buds) {
1108 struct buddy *b = buds->data; 1116 struct buddy *b = buds->data;
1109 buds = buds->next; 1117 buds = buds->next;
1110 if(b->user == u) { 1118 if(b->account == account) {
1111 /* sigh, someday we'll get a central gaim_buddy_free() */ 1119 /* sigh, someday we'll get a central gaim_buddy_free() */
1112 g->members = g_slist_remove(g->members, b); 1120 g->members = g_slist_remove(g->members, b);
1113 g_hash_table_destroy(b->settings); 1121 g_hash_table_destroy(b->settings);
1114 g_free(b); 1122 g_free(b);
1115 } 1123 }
1119 groups = g_slist_remove(groups, g); 1127 groups = g_slist_remove(groups, g);
1120 g_free(g); 1128 g_free(g);
1121 } 1129 }
1122 } 1130 }
1123 1131
1124 aim_users = g_slist_remove(aim_users, u); 1132 gaim_accounts = g_slist_remove(gaim_accounts, account);
1125 1133
1126 gaim_blist_save(); 1134 gaim_blist_save();
1127 1135
1128 save_prefs(); 1136 save_prefs();
1129 } 1137 }
1130 1138
1131 static void del_acct_func(GtkTreeModel *model, GtkTreePath *path, 1139 static void del_acct_func(GtkTreeModel *model, GtkTreePath *path,
1132 GtkTreeIter *iter, gpointer data) 1140 GtkTreeIter *iter, gpointer data)
1133 { 1141 {
1134 struct aim_user *u; 1142 struct gaim_account *account;
1135 1143
1136 gtk_tree_model_get(model, iter, COLUMN_DATA, &u, -1); 1144 gtk_tree_model_get(model, iter, COLUMN_DATA, &account, -1);
1137 1145
1138 if (u != NULL) { 1146 if (account != NULL) {
1139 char buf[8192]; 1147 char buf[8192];
1140 1148
1141 g_snprintf(buf, sizeof(buf), 1149 g_snprintf(buf, sizeof(buf),
1142 _("Are you sure you want to delete %s?"), u->username); 1150 _("Are you sure you want to delete %s?"), account->username);
1143 do_ask_dialog(buf, NULL, u, _("Delete"), do_del_acct, _("Cancel"), NULL, NULL, FALSE); 1151 do_ask_dialog(buf, NULL, account, _("Delete"), do_del_acct, _("Cancel"), NULL, NULL, FALSE);
1144 } 1152 }
1145 } 1153 }
1146 1154
1147 static void del_acct(GtkWidget *w, gpointer d) 1155 static void del_acct(GtkWidget *w, gpointer d)
1148 { 1156 {
1150 1158
1151 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); 1159 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
1152 1160
1153 gtk_tree_selection_selected_foreach(selection, del_acct_func, NULL); 1161 gtk_tree_selection_selected_foreach(selection, del_acct_func, NULL);
1154 } 1162 }
1155
1156 #if 0
1157 static void sel_auto(gpointer w, gpointer d)
1158 {
1159 GSList *l = aim_users;
1160 struct aim_user *u;
1161 int i = 0; /* faster than doing g_list_index each time */
1162 while (l) {
1163 u = l->data;
1164 l = l->next;
1165 if (u->options & OPT_USR_AUTO)
1166 gtk_clist_select_row(GTK_CLIST(list), i, -1);
1167 else
1168 gtk_clist_unselect_row(GTK_CLIST(list), i, -1);
1169 i++;
1170 }
1171 }
1172 #endif
1173 1163
1174 void account_editor(GtkWidget *w, GtkWidget *W) 1164 void account_editor(GtkWidget *w, GtkWidget *W)
1175 { 1165 {
1176 /* please kill me */ 1166 /* please kill me */
1177 GtkWidget *vbox; 1167 GtkWidget *vbox;
1358 } 1348 }
1359 1349
1360 redo_buddy_list(); 1350 redo_buddy_list();
1361 gaim_setup(gc); 1351 gaim_setup(gc);
1362 1352
1363 gc->user->connecting = FALSE; 1353 gc->account->connecting = FALSE;
1364 connecting_count--; 1354 connecting_count--;
1365 debug_printf("connecting_count: %d\n", connecting_count); 1355 debug_printf("connecting_count: %d\n", connecting_count);
1366 1356
1367 plugin_event(event_signon, gc); 1357 plugin_event(event_signon, gc);
1368 system_log(log_signon, gc, NULL, OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON); 1358 system_log(log_signon, gc, NULL, OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON);
1384 1374
1385 for(grps = groups; grps; grps = grps->next) { 1375 for(grps = groups; grps; grps = grps->next) {
1386 struct group *g = grps->data; 1376 struct group *g = grps->data;
1387 for(buds = g->members; buds; buds = buds->next) { 1377 for(buds = g->members; buds; buds = buds->next) {
1388 struct buddy *b = buds->data; 1378 struct buddy *b = buds->data;
1389 if(b->user->gc == gc) { 1379 if(b->account == gc->account) {
1390 add_buds = g_list_append(add_buds, b->name); 1380 add_buds = g_list_append(add_buds, b->name);
1391 } 1381 }
1392 } 1382 }
1393 } 1383 }
1394 1384
1401 1391
1402 /* everything for the account editor */ 1392 /* everything for the account editor */
1403 if (!acctedit) 1393 if (!acctedit)
1404 return; 1394 return;
1405 1395
1406 if (get_iter_from_data(GTK_TREE_VIEW(treeview), gc->user, &iter)) { 1396 if (get_iter_from_data(GTK_TREE_VIEW(treeview), gc->account, &iter)) {
1407 gtk_list_store_set(model, &iter, 1397 gtk_list_store_set(model, &iter,
1408 COLUMN_ONLINE, TRUE, 1398 COLUMN_ONLINE, TRUE,
1409 COLUMN_PROTOCOL, gc->prpl->name, 1399 COLUMN_PROTOCOL, gc->prpl->name,
1410 -1); 1400 -1);
1411 } 1401 }
1412 1402
1413 /* Update the conversation windows that use this account. */ 1403 /* Update the conversation windows that use this account. */
1414 for (l = gaim_get_conversations(); l != NULL; l = l->next) { 1404 for (l = gaim_get_conversations(); l != NULL; l = l->next) {
1415 struct gaim_conversation *conv = (struct gaim_conversation *)l->data; 1405 struct gaim_conversation *conv = (struct gaim_conversation *)l->data;
1416 1406
1417 if (gaim_conversation_get_user(conv) == gc->user) { 1407 if (gaim_conversation_get_account(conv) == gc->account) {
1418 gaim_conversation_update(conv, GAIM_CONV_UPDATE_USER); 1408 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ACCOUNT);
1419 } 1409 }
1420 } 1410 }
1421 } 1411 }
1422 1412
1423 void account_offline(struct gaim_connection *gc) 1413 void account_offline(struct gaim_connection *gc)
1430 kill_meter(meter); 1420 kill_meter(meter);
1431 meters = g_slist_remove(meters, meter); 1421 meters = g_slist_remove(meters, meter);
1432 g_free(meter); 1422 g_free(meter);
1433 } 1423 }
1434 debug_printf("Disconnecting. user = %p, gc = %p (%p)\n", 1424 debug_printf("Disconnecting. user = %p, gc = %p (%p)\n",
1435 gc->user, gc->user->gc, gc); 1425 gc->account, gc->account->gc, gc);
1436 gc->user->gc = NULL; /* wasn't that awkward? */ 1426 gc->account->gc = NULL; /* wasn't that awkward? */
1437 1427
1438 /* take these buddies out of the edit tree */ 1428 /* take these buddies out of the edit tree */
1439 build_edit_tree(); 1429 build_edit_tree();
1440 1430
1441 if (!acctedit) 1431 if (!acctedit)
1442 return; 1432 return;
1443 1433
1444 if (get_iter_from_data(GTK_TREE_VIEW(treeview), gc->user, &iter)) { 1434 if (get_iter_from_data(GTK_TREE_VIEW(treeview), gc->account, &iter)) {
1445 gtk_list_store_set(model, &iter, COLUMN_ONLINE, FALSE, -1); 1435 gtk_list_store_set(model, &iter, COLUMN_ONLINE, FALSE, -1);
1446 } 1436 }
1447 1437
1448 /* Update the conversation windows that use this account. */ 1438 /* Update the conversation windows that use this account. */
1449 for (l = gaim_get_conversations(); l != NULL; l = l->next) { 1439 for (l = gaim_get_conversations(); l != NULL; l = l->next) {
1450 struct gaim_conversation *conv = (struct gaim_conversation *)l->data; 1440 struct gaim_conversation *conv = (struct gaim_conversation *)l->data;
1451 1441
1452 if (gaim_conversation_get_user(conv) == gc->user) { 1442 if (gaim_conversation_get_account(conv) == gc->account) {
1453 gaim_conversation_update(conv, GAIM_CONV_UPDATE_USER); 1443 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ACCOUNT);
1454 } 1444 }
1455 } 1445 }
1456 } 1446 }
1457 1447
1458 void auto_login() 1448 void auto_login()
1459 { 1449 {
1460 GSList *u = aim_users; 1450 GSList *accts = gaim_accounts;
1461 struct aim_user *a = NULL; 1451 struct gaim_account *a = NULL;
1462 1452
1463 while (u) { 1453 while (accts) {
1464 a = (struct aim_user *)u->data; 1454 a = (struct gaim_account *)accts->data;
1465 if ((a->options & OPT_USR_AUTO) && (a->options & OPT_USR_REM_PASS)) { 1455 if ((a->options & OPT_ACCT_AUTO) && (a->options & OPT_ACCT_REM_PASS)) {
1466 serv_login(a); 1456 serv_login(a);
1467 } 1457 }
1468 u = u->next; 1458 accts = accts->next;
1469 } 1459 }
1470 } 1460 }
1471 1461
1472 /* 1462 /*
1473 * d:)->-< 1463 * d:)->-<
1495 GtkWidget *graphic; 1485 GtkWidget *graphic;
1496 GtkWidget *label; 1486 GtkWidget *label;
1497 GtkWidget *nest_vbox; 1487 GtkWidget *nest_vbox;
1498 GString *name_to_print; 1488 GString *name_to_print;
1499 struct signon_meter *meter; 1489 struct signon_meter *meter;
1500 1490
1501 name_to_print = g_string_new(gc->username); 1491 name_to_print = g_string_new(gc->username);
1502 1492
1503 meter = g_new0(struct signon_meter, 1); 1493 meter = g_new0(struct signon_meter, 1);
1504 1494
1505 (*rows)++; 1495 (*rows)++;
1506 gtk_table_resize (table, *rows, 4); 1496 gtk_table_resize (table, *rows, 4);
1507 1497
1508 graphic = create_meter_pixmap( widget , gc); 1498 graphic = create_meter_pixmap( widget , gc);
1509 1499
1510 nest_vbox = gtk_vbox_new (FALSE, 0); 1500 nest_vbox = gtk_vbox_new (FALSE, 0);
1511 1501
1512 g_string_prepend(name_to_print, _("Signon: ")); 1502 g_string_prepend(name_to_print, _("Signon: "));
1513 label = gtk_label_new (name_to_print->str); 1503 label = gtk_label_new (name_to_print->str);
1514 g_string_free(name_to_print, TRUE); 1504 g_string_free(name_to_print, TRUE);
1515 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); 1505 gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
1516 1506
1517 meter->status = gtk_statusbar_new(); 1507 meter->status = gtk_statusbar_new();
1518 gtk_widget_set_usize(meter->status, 250, 0); 1508 gtk_widget_set_usize(meter->status, 250, 0);
1519 1509
1520 meter->progress = gtk_progress_bar_new (); 1510 meter->progress = gtk_progress_bar_new ();
1521 1511
1522 meter->button = gtk_button_new_with_label (_("Cancel")); 1512 meter->button = gtk_button_new_with_label (_("Cancel"));
1523 g_signal_connect (GTK_OBJECT (meter->button), "clicked", G_CALLBACK (cancel_signon), meter); 1513 g_signal_connect (GTK_OBJECT (meter->button), "clicked", G_CALLBACK (cancel_signon), meter);
1524 1514
1525 gtk_table_attach (GTK_TABLE (table), graphic, 0, 1, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); 1515 gtk_table_attach (GTK_TABLE (table), graphic, 0, 1, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1526 gtk_table_attach (GTK_TABLE (table), nest_vbox, 1, 2, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); 1516 gtk_table_attach (GTK_TABLE (table), nest_vbox, 1, 2, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1527 gtk_box_pack_start (GTK_BOX (nest_vbox), GTK_WIDGET (label), FALSE, FALSE, 0); 1517 gtk_box_pack_start (GTK_BOX (nest_vbox), GTK_WIDGET (label), FALSE, FALSE, 0);
1528 gtk_box_pack_start (GTK_BOX (nest_vbox), GTK_WIDGET (meter->status), FALSE, FALSE, 0); 1518 gtk_box_pack_start (GTK_BOX (nest_vbox), GTK_WIDGET (meter->status), FALSE, FALSE, 0);
1529 gtk_table_attach (GTK_TABLE (table), meter->progress, 2, 3, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); 1519 gtk_table_attach (GTK_TABLE (table), meter->progress, 2, 3, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1530 gtk_table_attach (GTK_TABLE (table), meter->button, 3, 4, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0); 1520 gtk_table_attach (GTK_TABLE (table), meter->button, 3, 4, *rows, *rows+1, (GtkAttachOptions) (GTK_FILL), (GtkAttachOptions) (0), 0, 0);
1531 1521
1532 gtk_widget_show_all (GTK_WIDGET (meter_win->window)); 1522 gtk_widget_show_all (GTK_WIDGET (meter_win->window));
1533 1523
1534 meter_win->active_count++; 1524 meter_win->active_count++;
1535 1525
1536 return meter; 1526 return meter;
1537 } 1527 }
1538 1528
1539 static void loop_cancel () { 1529 static void loop_cancel () {
1540 GSList *m = meters; 1530 GSList *m = meters;
1600 gtk_statusbar_pop(GTK_STATUSBAR(meter->status), 1); 1590 gtk_statusbar_pop(GTK_STATUSBAR(meter->status), 1);
1601 gtk_statusbar_push(GTK_STATUSBAR(meter->status), 1, message); 1591 gtk_statusbar_push(GTK_STATUSBAR(meter->status), 1, message);
1602 } 1592 }
1603 1593
1604 struct kick_dlg { 1594 struct kick_dlg {
1605 struct aim_user *user; 1595 struct gaim_account *account;
1606 GtkWidget *dlg; 1596 GtkWidget *dlg;
1607 }; 1597 };
1608 static GSList *kicks = NULL; 1598 static GSList *kicks = NULL;
1609 1599
1610 static struct kick_dlg *find_kick_dlg(struct aim_user *u) 1600 static struct kick_dlg *find_kick_dlg(struct gaim_account *account)
1611 { 1601 {
1612 GSList *k = kicks; 1602 GSList *k = kicks;
1613 while (k) { 1603 while (k) {
1614 struct kick_dlg *d = k->data; 1604 struct kick_dlg *d = k->data;
1615 if (d->user == u) 1605 if (d->account == account)
1616 return d; 1606 return d;
1617 k = k->next; 1607 k = k->next;
1618 } 1608 }
1619 return NULL; 1609 return NULL;
1620 } 1610 }
1632 char *details, 1622 char *details,
1633 char *title, 1623 char *title,
1634 char *prologue) 1624 char *prologue)
1635 { 1625 {
1636 char buf[2048]; 1626 char buf[2048];
1637 struct kick_dlg *k = find_kick_dlg(gc->user); 1627 struct kick_dlg *k = find_kick_dlg(gc->account);
1638 struct signon_meter *meter = find_signon_meter(gc); 1628 struct signon_meter *meter = find_signon_meter(gc);
1639 sprintf(buf, _("%s\n%s: %s"), full_date(), prologue, details); 1629 sprintf(buf, _("%s\n%s: %s"), full_date(), prologue, details);
1640 if (k) 1630 if (k)
1641 gtk_widget_destroy(k->dlg); 1631 gtk_widget_destroy(k->dlg);
1642 k = g_new0(struct kick_dlg, 1); 1632 k = g_new0(struct kick_dlg, 1);
1643 k->user = gc->user; 1633 k->account = gc->account;
1644 k->dlg = do_error_dialog(title, buf, GAIM_ERROR); 1634 k->dlg = do_error_dialog(title, buf, GAIM_ERROR);
1645 kicks = g_slist_append(kicks, k); 1635 kicks = g_slist_append(kicks, k);
1646 g_signal_connect(GTK_OBJECT(k->dlg), "destroy", G_CALLBACK(set_kick_null), k); 1636 g_signal_connect(GTK_OBJECT(k->dlg), "destroy", G_CALLBACK(set_kick_null), k);
1647 if (meter) { 1637 if (meter) {
1648 kill_meter(meter); 1638 kill_meter(meter);
1710 plugin_event(event_signoff, gc); 1700 plugin_event(event_signoff, gc);
1711 system_log(log_signoff, gc, NULL, OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON); 1701 system_log(log_signoff, gc, NULL, OPT_LOG_BUDDY_SIGNON | OPT_LOG_MY_SIGNON);
1712 /* set this in case the plugin died before really connecting. 1702 /* set this in case the plugin died before really connecting.
1713 do it after calling the plugins so they can determine if 1703 do it after calling the plugins so they can determine if
1714 this user was ever on-line or not */ 1704 this user was ever on-line or not */
1715 if (gc->user->connecting) { 1705 if (gc->account->connecting) {
1716 gc->user->connecting = FALSE; 1706 gc->account->connecting = FALSE;
1717 connecting_count--; 1707 connecting_count--;
1718 } 1708 }
1719 debug_printf("connecting_count: %d\n", connecting_count); 1709 debug_printf("connecting_count: %d\n", connecting_count);
1720 serv_close(gc); 1710 serv_close(gc);
1721 1711
1744 destroy_buddy(); 1734 destroy_buddy();
1745 1735
1746 show_login(); 1736 show_login();
1747 } 1737 }
1748 1738
1749 struct aim_user *new_user(const char *name, int proto, int opts) 1739 struct gaim_account *gaim_account_new(const char *name, int proto, int opts)
1750 { 1740 {
1751 struct aim_user *u = g_new0(struct aim_user, 1); 1741 struct gaim_account *account = g_new0(struct gaim_account, 1);
1752 g_snprintf(u->username, sizeof(u->username), "%s", name); 1742 g_snprintf(account->username, sizeof(account->username), "%s", name);
1753 g_snprintf(u->user_info, sizeof(u->user_info), "%s", DEFAULT_INFO); 1743 g_snprintf(account->user_info, sizeof(account->user_info), "%s", DEFAULT_INFO);
1754 u->protocol = proto; 1744 account->protocol = proto;
1755 u->options = opts; 1745 account->options = opts;
1756 u->permit = NULL; 1746 account->permit = NULL;
1757 u->deny = NULL; 1747 account->deny = NULL;
1758 aim_users = g_slist_append(aim_users, u); 1748 gaim_accounts = g_slist_append(gaim_accounts, account);
1759 1749
1760 if (treeview) { 1750 if (treeview) {
1761 GtkTreeIter iter; 1751 GtkTreeIter iter;
1762 1752
1763 gtk_list_store_append(model, &iter); 1753 gtk_list_store_append(model, &iter);
1764 gtk_list_store_set(model, &iter, 1754 gtk_list_store_set(model, &iter,
1765 COLUMN_SCREENNAME, u->username, 1755 COLUMN_SCREENNAME, account->username,
1766 COLUMN_ONLINE, (u->gc ? TRUE : FALSE), 1756 COLUMN_ONLINE, (account->gc ? TRUE : FALSE),
1767 COLUMN_AUTOLOGIN, (u->options & OPT_USR_AUTO), 1757 COLUMN_AUTOLOGIN, (account->options & OPT_ACCT_AUTO),
1768 COLUMN_PROTOCOL, proto_name(u->protocol), 1758 COLUMN_PROTOCOL, proto_name(account->protocol),
1769 COLUMN_DATA, u, 1759 COLUMN_DATA, account,
1770 -1); 1760 -1);
1771 } 1761 }
1772 1762
1773 return u; 1763 return account;
1774 } 1764 }