Mercurial > pidgin.yaz
comparison src/gaimrc.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 | a4a87d79c67c |
children | c5bc145addf9 |
comparison
equal
deleted
inserted
replaced
4490:70b892694e0b | 4491:3196d9044a45 |
---|---|
45 | 45 |
46 /* for people like myself, who are too lazy to add an away msg :) */ | 46 /* for people like myself, who are too lazy to add an away msg :) */ |
47 #define BORING_DEFAULT_AWAY_MSG "sorry, i ran out for a while. bbl" | 47 #define BORING_DEFAULT_AWAY_MSG "sorry, i ran out for a while. bbl" |
48 #define MAX_VALUES 10 | 48 #define MAX_VALUES 10 |
49 | 49 |
50 GSList *aim_users = NULL; | 50 GSList *gaim_accounts = NULL; |
51 guint misc_options; | 51 guint misc_options; |
52 guint logging_options; | 52 guint logging_options; |
53 guint blist_options; | 53 guint blist_options; |
54 guint convo_options; | 54 guint convo_options; |
55 guint im_options; | 55 guint im_options; |
474 load = g_slist_remove(load, load->data); | 474 load = g_slist_remove(load, load->data); |
475 } | 475 } |
476 } | 476 } |
477 #endif /* GAIM_PLUGINS */ | 477 #endif /* GAIM_PLUGINS */ |
478 | 478 |
479 static struct aim_user *gaimrc_read_user(FILE *f) | 479 static struct gaim_account *gaimrc_read_user(FILE *f) |
480 { | 480 { |
481 struct parse parse_buffer; | 481 struct parse parse_buffer; |
482 struct parse *p; | 482 struct parse *p; |
483 struct aim_user *u; | 483 struct gaim_account *account; |
484 int i; | 484 int i; |
485 char buf[4096]; | 485 char buf[4096]; |
486 | 486 |
487 if (!fgets(buf, sizeof(buf), f)) | 487 if (!fgets(buf, sizeof(buf), f)) |
488 return NULL; | 488 return NULL; |
490 p = parse_line(buf, &parse_buffer); | 490 p = parse_line(buf, &parse_buffer); |
491 | 491 |
492 if (strcmp(p->option, "ident")) | 492 if (strcmp(p->option, "ident")) |
493 return NULL; | 493 return NULL; |
494 | 494 |
495 u = g_new0(struct aim_user, 1); | 495 account = g_new0(struct gaim_account, 1); |
496 | 496 |
497 strcpy(u->username, p->value[0]); | 497 strcpy(account->username, p->value[0]); |
498 strcpy(u->password, p->value[1]); | 498 strcpy(account->password, p->value[1]); |
499 | 499 |
500 u->user_info[0] = 0; | 500 account->user_info[0] = 0; |
501 u->options = OPT_USR_REM_PASS; | 501 account->options = OPT_ACCT_REM_PASS; |
502 u->protocol = DEFAULT_PROTO; | 502 account->protocol = DEFAULT_PROTO; |
503 u->permit = u->deny = NULL; | 503 account->permit = account->deny = NULL; |
504 | 504 |
505 if (!fgets(buf, sizeof(buf), f)) | 505 if (!fgets(buf, sizeof(buf), f)) |
506 return u; | 506 return account; |
507 | 507 |
508 if (strcmp(buf, "\t\tuser_info {\n")) { | 508 if (strcmp(buf, "\t\tuser_info {\n")) { |
509 return u; | 509 return account; |
510 } | 510 } |
511 | 511 |
512 if (!fgets(buf, sizeof(buf), f)) | 512 if (!fgets(buf, sizeof(buf), f)) |
513 return u; | 513 return account; |
514 | 514 |
515 while (strncmp(buf, "\t\t}", 3)) { | 515 while (strncmp(buf, "\t\t}", 3)) { |
516 if (strlen(buf) > 3) | 516 if (strlen(buf) > 3) |
517 strcat(u->user_info, buf + 3); | 517 strcat(account->user_info, buf + 3); |
518 | 518 |
519 if (!fgets(buf, sizeof(buf), f)) { | 519 if (!fgets(buf, sizeof(buf), f)) { |
520 return u; | 520 return account; |
521 } | 521 } |
522 } | 522 } |
523 | 523 |
524 if ((i = strlen(u->user_info))) { | 524 if ((i = strlen(account->user_info))) { |
525 u->user_info[i - 1] = '\0'; | 525 account->user_info[i - 1] = '\0'; |
526 } | 526 } |
527 | 527 |
528 if (!fgets(buf, sizeof(buf), f)) { | 528 if (!fgets(buf, sizeof(buf), f)) { |
529 return u; | 529 return account; |
530 } | 530 } |
531 | 531 |
532 if (!strcmp(buf, "\t}")) { | 532 if (!strcmp(buf, "\t}")) { |
533 return u; | 533 return account; |
534 } | 534 } |
535 | 535 |
536 p = parse_line(buf, &parse_buffer); | 536 p = parse_line(buf, &parse_buffer); |
537 | 537 |
538 if (strcmp(p->option, "user_opts")) | 538 if (strcmp(p->option, "user_opts")) |
539 return u; | 539 return account; |
540 | 540 |
541 u->options = atoi(p->value[0]); | 541 account->options = atoi(p->value[0]); |
542 u->protocol = atoi(p->value[1]); | 542 account->protocol = atoi(p->value[1]); |
543 | 543 |
544 if (!fgets(buf, sizeof(buf), f)) | 544 if (!fgets(buf, sizeof(buf), f)) |
545 return u; | 545 return account; |
546 | 546 |
547 if (!strcmp(buf, "\t}")) | 547 if (!strcmp(buf, "\t}")) |
548 return u; | 548 return account; |
549 | 549 |
550 p = parse_line(buf, &parse_buffer); | 550 p = parse_line(buf, &parse_buffer); |
551 | 551 |
552 if (strcmp(p->option, "proto_opts")) | 552 if (strcmp(p->option, "proto_opts")) |
553 return u; | 553 return account; |
554 | 554 |
555 for (i = 0; i < 7; i++) | 555 for (i = 0; i < 7; i++) |
556 g_snprintf(u->proto_opt[i], sizeof u->proto_opt[i], "%s", p->value[i]); | 556 g_snprintf(account->proto_opt[i], sizeof account->proto_opt[i], "%s", p->value[i]); |
557 | 557 |
558 if (!fgets(buf, sizeof(buf), f)) | 558 if (!fgets(buf, sizeof(buf), f)) |
559 return u; | 559 return account; |
560 | 560 |
561 if (!strcmp(buf, "\t}")) | 561 if (!strcmp(buf, "\t}")) |
562 return u; | 562 return account; |
563 | 563 |
564 p = parse_line(buf, &parse_buffer); | 564 p = parse_line(buf, &parse_buffer); |
565 | 565 |
566 if (strcmp(p->option, "iconfile")) | 566 if (strcmp(p->option, "iconfile")) |
567 return u; | 567 return account; |
568 | 568 |
569 g_snprintf(u->iconfile, sizeof(u->iconfile), "%s", p->value[0]); | 569 g_snprintf(account->iconfile, sizeof(account->iconfile), "%s", p->value[0]); |
570 | 570 |
571 if (!fgets(buf, sizeof(buf), f)) | 571 if (!fgets(buf, sizeof(buf), f)) |
572 return u; | 572 return account; |
573 | 573 |
574 if (!strcmp(buf, "\t}")) | 574 if (!strcmp(buf, "\t}")) |
575 return u; | 575 return account; |
576 | 576 |
577 p = parse_line(buf, &parse_buffer); | 577 p = parse_line(buf, &parse_buffer); |
578 | 578 |
579 if (strcmp(p->option, "alias")) | 579 if (strcmp(p->option, "alias")) |
580 return u; | 580 return account; |
581 | 581 |
582 g_snprintf(u->alias, sizeof(u->alias), "%s", p->value[0]); | 582 g_snprintf(account->alias, sizeof(account->alias), "%s", p->value[0]); |
583 | 583 |
584 return u; | 584 return account; |
585 | 585 |
586 } | 586 } |
587 | 587 |
588 static void gaimrc_write_user(FILE *f, struct aim_user *u) | 588 static void gaimrc_write_user(FILE *f, struct gaim_account *account) |
589 { | 589 { |
590 char *c; | 590 char *c; |
591 int nl = 1, i; | 591 int nl = 1, i; |
592 | 592 |
593 if (u->options & OPT_USR_REM_PASS) { | 593 if (account->options & OPT_ACCT_REM_PASS) { |
594 fprintf(f, "\t\tident { %s } { %s }\n", u->username, (c = escape_text2(u->password))); | 594 fprintf(f, "\t\tident { %s } { %s }\n", account->username, (c = escape_text2(account->password))); |
595 free(c); | 595 free(c); |
596 } else { | 596 } else { |
597 fprintf(f, "\t\tident { %s } { }\n", u->username); | 597 fprintf(f, "\t\tident { %s } { }\n", account->username); |
598 } | 598 } |
599 fprintf(f, "\t\tuser_info {"); | 599 fprintf(f, "\t\tuser_info {"); |
600 c = u->user_info; | 600 c = account->user_info; |
601 while (*c) { | 601 while (*c) { |
602 /* This is not as silly as it looks. */ | 602 /* This is not as silly as it looks. */ |
603 if (*c == '\n') { | 603 if (*c == '\n') { |
604 nl++; | 604 nl++; |
605 } else { | 605 } else { |
612 fprintf(f, "%c", *c); | 612 fprintf(f, "%c", *c); |
613 } | 613 } |
614 c++; | 614 c++; |
615 } | 615 } |
616 fprintf(f, "\n\t\t}\n"); | 616 fprintf(f, "\n\t\t}\n"); |
617 fprintf(f, "\t\tuser_opts { %d } { %d }\n", u->options, u->protocol); | 617 fprintf(f, "\t\tuser_opts { %d } { %d }\n", account->options, account->protocol); |
618 fprintf(f, "\t\tproto_opts"); | 618 fprintf(f, "\t\tproto_opts"); |
619 for (i = 0; i < 7; i++) | 619 for (i = 0; i < 7; i++) |
620 fprintf(f, " { %s }", u->proto_opt[i]); | 620 fprintf(f, " { %s }", account->proto_opt[i]); |
621 fprintf(f, "\n"); | 621 fprintf(f, "\n"); |
622 #ifndef _WIN32 | 622 #ifndef _WIN32 |
623 fprintf(f, "\t\ticonfile { %s }\n", u->iconfile); | 623 fprintf(f, "\t\ticonfile { %s }\n", account->iconfile); |
624 #else | 624 #else |
625 { | 625 { |
626 /* Make sure windows dir speparators arn't swallowed up when | 626 /* Make sure windows dir speparators arn't swallowed up when |
627 path is read back in from resource file */ | 627 path is read back in from resource file */ |
628 char* tmp=wgaim_escape_dirsep(u->iconfile); | 628 char* tmp=wgaim_escape_dirsep(account->iconfile); |
629 fprintf(f, "\t\ticonfile { %s }\n", tmp); | 629 fprintf(f, "\t\ticonfile { %s }\n", tmp); |
630 g_free(tmp); | 630 g_free(tmp); |
631 } | 631 } |
632 #endif | 632 #endif |
633 fprintf(f, "\t\talias { %s }\n", u->alias); | 633 fprintf(f, "\t\talias { %s }\n", account->alias); |
634 } | 634 } |
635 | 635 |
636 static void gaimrc_read_users(FILE *f) | 636 static void gaimrc_read_users(FILE *f) |
637 { | 637 { |
638 char buf[2048]; | 638 char buf[2048]; |
639 struct aim_user *u=NULL; | 639 struct gaim_account *account = NULL; |
640 struct parse parse_buffer; | 640 struct parse parse_buffer; |
641 struct parse *p=NULL; | 641 struct parse *p=NULL; |
642 | 642 |
643 buf[0] = 0; | 643 buf[0] = 0; |
644 | 644 |
650 | 650 |
651 p = parse_line(buf, &parse_buffer); | 651 p = parse_line(buf, &parse_buffer); |
652 | 652 |
653 if (strcmp(p->option, "user")==0 || | 653 if (strcmp(p->option, "user")==0 || |
654 strcmp(p->option, "current_user")==0) { | 654 strcmp(p->option, "current_user")==0) { |
655 if((u=gaimrc_read_user(f))!=NULL) | 655 if((account=gaimrc_read_user(f))!=NULL) |
656 aim_users = g_slist_append(aim_users, u); | 656 gaim_accounts = g_slist_append(gaim_accounts, account); |
657 else { | 657 else { |
658 debug_printf("Error reading in users from .gaimrc\n"); | 658 debug_printf("Error reading in users from .gaimrc\n"); |
659 return; | 659 return; |
660 } | 660 } |
661 } | 661 } |
662 } | 662 } |
663 } | 663 } |
664 | 664 |
665 static void gaimrc_write_users(FILE *f) | 665 static void gaimrc_write_users(FILE *f) |
666 { | 666 { |
667 GSList *usr = aim_users; | 667 GSList *usr = gaim_accounts; |
668 struct aim_user *u; | 668 struct gaim_account *account; |
669 | 669 |
670 fprintf(f, "users {\n"); | 670 fprintf(f, "users {\n"); |
671 | 671 |
672 while (usr) { | 672 while (usr) { |
673 u = (struct aim_user *)usr->data; | 673 account = (struct gaim_account *)usr->data; |
674 fprintf(f, "\tuser {\n"); | 674 fprintf(f, "\tuser {\n"); |
675 gaimrc_write_user(f, u); | 675 gaimrc_write_user(f, account); |
676 | 676 |
677 fprintf(f, "\t}\n"); | 677 fprintf(f, "\t}\n"); |
678 | 678 |
679 usr = usr->next; | 679 usr = usr->next; |
680 } | 680 } |