comparison src/gaimrc.c @ 960:fa681641643d

[gaim-migrate @ 970] *** MULTIPLE-CONNECTIONS *** committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 10 Oct 2000 00:02:02 +0000
parents 9fca1293f871
children 1d8f05ea6bdf
comparison
equal deleted inserted replaced
959:034d5d1d53eb 960:fa681641643d
36 #include "proxy.h" 36 #include "proxy.h"
37 37
38 /* for people like myself, who are too lazy to add an away msg :) */ 38 /* for people like myself, who are too lazy to add an away msg :) */
39 #define BORING_DEFAULT_AWAY_MSG "sorry, i ran out for a while. bbl" 39 #define BORING_DEFAULT_AWAY_MSG "sorry, i ran out for a while. bbl"
40 40
41 struct aim_user *current_user = NULL;
42 GList *aim_users = NULL; 41 GList *aim_users = NULL;
43 int general_options; 42 int general_options;
44 int display_options; 43 int display_options;
45 int sound_options; 44 int sound_options;
46 int font_options; 45 int font_options;
440 439
441 strcpy(u->username, p->value[0]); 440 strcpy(u->username, p->value[0]);
442 strcpy(u->password, p->value[1]); 441 strcpy(u->password, p->value[1]);
443 442
444 u->user_info[0] = 0; 443 u->user_info[0] = 0;
444 u->options = OPT_USR_REM_PASS;
445 u->protocol = PROTO_TOC;
445 446
446 if (!fgets(buf, sizeof(buf), f)) 447 if (!fgets(buf, sizeof(buf), f))
447 return u; 448 return u;
448 449
449 if (strcmp(buf, "\t\tuser_info {\n")) { 450 if (strcmp(buf, "\t\tuser_info {\n")) {
460 if (!fgets(buf, sizeof(buf), f)) { 461 if (!fgets(buf, sizeof(buf), f)) {
461 return u; 462 return u;
462 } 463 }
463 } 464 }
464 465
466 if (!fgets(buf, sizeof(buf), f)) {
467 return u;
468 }
469
470 if (!strcmp(buf, "\t}")) {
471 return u;
472 }
473
474 p = parse_line(buf);
475
476 if (strcmp(p->option, "user_opts"))
477 return u;
478
479 u->options = atoi(p->value[0]);
480 u->protocol = atoi(p->value[1]);
481
465 return u; 482 return u;
466 483
467 } 484 }
468 485
469 static void gaimrc_write_user(FILE *f, struct aim_user *u) 486 static void gaimrc_write_user(FILE *f, struct aim_user *u)
470 { 487 {
471 char *c; 488 char *c;
472 int nl = 1;; 489 int nl = 1;;
473 if (general_options & OPT_GEN_REMEMBER_PASS) 490 if (u->options & OPT_USR_REM_PASS)
474 fprintf(f, "\t\tident { %s } { %s }\n", u->username, u->password); 491 fprintf(f, "\t\tident { %s } { %s }\n", u->username, u->password);
475 else 492 else
476 fprintf(f, "\t\tident { %s } { }\n", u->username); 493 fprintf(f, "\t\tident { %s } { }\n", u->username);
477 fprintf(f, "\t\tuser_info {"); 494 fprintf(f, "\t\tuser_info {");
478 c = u->user_info; 495 c = u->user_info;
490 fprintf(f, "%c", *c); 507 fprintf(f, "%c", *c);
491 } 508 }
492 c++; 509 c++;
493 } 510 }
494 fprintf(f, "\n\t\t}\n"); 511 fprintf(f, "\n\t\t}\n");
512 fprintf(f, "\t\tuser_opts { %d } { %d }\n", u->options, u->protocol);
495 513
496 } 514 }
497 515
498 516
499 static void gaimrc_read_users(FILE *f) 517 static void gaimrc_read_users(FILE *f)
500 { 518 {
501 char buf[2048]; 519 char buf[2048];
502 struct aim_user *u; 520 struct aim_user *u;
503 struct parse *p; 521 struct parse *p;
504 int cur = 0;
505 522
506 buf[0] = 0; 523 buf[0] = 0;
507 524
508 while (buf[0] != '}') { 525 while (buf[0] != '}') {
509 if (buf[0] == '#') 526 if (buf[0] == '#')
515 532
516 533
517 p = parse_line(buf); 534 p = parse_line(buf);
518 535
519 if (!strcmp(p->option, "current_user")) { 536 if (!strcmp(p->option, "current_user")) {
520 cur = 1;
521 } else if (strcmp(p->option, "user")) { 537 } else if (strcmp(p->option, "user")) {
522 cur = 0;
523 continue; 538 continue;
524 } else { 539 } else {
525 cur = 0;
526 } 540 }
527 541
528 u = gaimrc_read_user(f); 542 u = gaimrc_read_user(f);
529 543
530 if (cur)
531 current_user = u;
532
533 aim_users = g_list_append(aim_users, u); 544 aim_users = g_list_append(aim_users, u);
534 } 545 }
535 } 546 }
536 547
537 static void gaimrc_write_users(FILE *f) 548 static void gaimrc_write_users(FILE *f)
541 552
542 fprintf(f, "users {\n"); 553 fprintf(f, "users {\n");
543 554
544 while(usr) { 555 while(usr) {
545 u = (struct aim_user *)usr->data; 556 u = (struct aim_user *)usr->data;
546 if (current_user == u) { 557 fprintf(f, "\tuser {\n");
547 fprintf(f, "\tcurrent_user {\n");
548 } else {
549 fprintf(f, "\tuser {\n");
550 }
551 gaimrc_write_user(f, u); 558 gaimrc_write_user(f, u);
552 559
553 fprintf(f, "\t}\n"); 560 fprintf(f, "\t}\n");
554 561
555 usr = usr->next; 562 usr = usr->next;
677 684
678 general_options = 685 general_options =
679 OPT_GEN_SEND_LINKS | 686 OPT_GEN_SEND_LINKS |
680 OPT_GEN_ENTER_SENDS | 687 OPT_GEN_ENTER_SENDS |
681 OPT_GEN_SAVED_WINDOWS | 688 OPT_GEN_SAVED_WINDOWS |
682 OPT_GEN_REMEMBER_PASS | 689 /* OPT_GEN_REMEMBER_PASS | */
683 OPT_GEN_REGISTERED | 690 OPT_GEN_REGISTERED |
684 OPT_GEN_NEAR_APPLET | 691 OPT_GEN_NEAR_APPLET |
685 OPT_GEN_CTL_SMILEYS | 692 OPT_GEN_CTL_SMILEYS |
686 OPT_GEN_CTL_CHARS; 693 OPT_GEN_CTL_CHARS;
687 694