src/gaimrc.c

changeset 9460
7c1ab9155fe2
parent 9251
60b4994e93b8
equal deleted inserted replaced
9459:72399a7d7e29 9460:7c1ab9155fe2
520 int i; 520 int i;
521 char buf[4096]; 521 char buf[4096];
522 char user_info[2048]; 522 char user_info[2048];
523 int flags; 523 int flags;
524 char *tmp; 524 char *tmp;
525 const char *protocol_id;
525 526
526 if (!fgets(buf, sizeof(buf), f)) 527 if (!fgets(buf, sizeof(buf), f))
527 return NULL; 528 return NULL;
528 529
529 p = parse_line(buf, &parse_buffer); 530 p = parse_line(buf, &parse_buffer);
589 gaim_account_set_check_mail(account, TRUE); 590 gaim_account_set_check_mail(account, TRUE);
590 591
591 if (!(flags & OPT_ACCT_REM_PASS)) 592 if (!(flags & OPT_ACCT_REM_PASS))
592 gaim_account_set_remember_password(account, FALSE); 593 gaim_account_set_remember_password(account, FALSE);
593 594
594 gaim_account_set_protocol(account, atoi(p->value[1])); 595 /* convert the old GaimProtocol to the protocol_id */
596 switch(atoi(p->value[1])) {
597 case 0: tmp = g_strdup("prpl-toc"); break;
598 case 1: tmp = g_strdup("prpl-oscar"); break;
599 case 2: tmp = g_strdup("prpl-yahoo"); break;
600 case 3: tmp = g_strdup("prpl-icq"); break;
601 case 4: tmp = g_strdup("prpl-msn"); break;
602 case 5: tmp = g_strdup("prpl-irc"); break;
603 case 8: tmp = g_strdup("prpl-jabber"); break;
604 case 9: tmp = g_strdup("prpl-napster"); break;
605 case 10:tmp = g_strdup("prpl-zephyr"); break;
606 case 11:tmp = g_strdup("prpl-gg"); break;
607 case 16:tmp = g_strdup("prpl-moo"); break;
608 case 18:tmp = g_strdup("prpl-trepia"); break;
609 case 21:tmp = g_strdup("prpl-blogger"); break;
610 default:
611 tmp = NULL;
612 }
613 if (tmp) {
614 gaim_account_set_protocol_id(account, tmp);
615 g_free(tmp);
616 }
595 617
596 if (!fgets(buf, sizeof(buf), f)) 618 if (!fgets(buf, sizeof(buf), f))
597 return account; 619 return account;
598 620
599 if (!strcmp(buf, "\t}")) 621 if (!strcmp(buf, "\t}"))
603 625
604 if (strcmp(p->option, "proto_opts")) 626 if (strcmp(p->option, "proto_opts"))
605 return account; 627 return account;
606 628
607 /* I hate this part. We must convert the protocol options. */ 629 /* I hate this part. We must convert the protocol options. */
608 switch (gaim_account_get_protocol(account)) { 630 protocol_id = gaim_account_get_protocol_id(account);
609 /* TOC */ 631
610 case GAIM_PROTO_TOC: 632 /* TOC */
633 if (protocol_id) {
634 if (strcmp(protocol_id, "prpl-toc") == 0) {
611 if (*p->value[0] == '\0') 635 if (*p->value[0] == '\0')
612 gaim_account_set_string(account, "server", "toc.oscar.aol.com"); 636 gaim_account_set_string(account, "server", "toc.oscar.aol.com");
613 else 637 else
614 gaim_account_set_string(account, "server", p->value[0]); 638 gaim_account_set_string(account, "server", p->value[0]);
615 639
616 if (*p->value[1] == '\0') 640 if (*p->value[1] == '\0')
617 gaim_account_set_int(account, "port", 9898); 641 gaim_account_set_int(account, "port", 9898);
618 else 642 else
619 gaim_account_set_int(account, "port", atoi(p->value[1])); 643 gaim_account_set_int(account, "port", atoi(p->value[1]));
620 644
621 break;
622
623 /* OSCAR */ 645 /* OSCAR */
624 case GAIM_PROTO_OSCAR: 646 } else if (strcmp(protocol_id, "prpl-oscar") == 0) {
625 if (*p->value[0] == '\0') 647 if (*p->value[0] == '\0')
626 gaim_account_set_string(account, "server", 648 gaim_account_set_string(account, "server",
627 "login.oscar.aol.com"); 649 "login.oscar.aol.com");
628 else 650 else
629 gaim_account_set_string(account, "server", p->value[0]); 651 gaim_account_set_string(account, "server", p->value[0]);
630 652
631 if (*p->value[1] == '\0') 653 if (*p->value[1] == '\0')
632 gaim_account_set_int(account, "port", 5190); 654 gaim_account_set_int(account, "port", 5190);
633 else 655 else
634 gaim_account_set_int(account, "port", atoi(p->value[1])); 656 gaim_account_set_int(account, "port", atoi(p->value[1]));
635 657
636 break;
637
638 /* Jabber */ 658 /* Jabber */
639 case GAIM_PROTO_JABBER: 659 } else if (strcmp(protocol_id, "prpl-jabber") == 0) {
640 if (*p->value[0] == '\0') 660 if (*p->value[0] == '\0')
641 gaim_account_set_int(account, "port", 5222); 661 gaim_account_set_int(account, "port", 5222);
642 else 662 else
643 gaim_account_set_int(account, "port", atoi(p->value[0])); 663 gaim_account_set_int(account, "port", atoi(p->value[0]));
644 664
645 if (*p->value[1] != '\0') 665 if (*p->value[1] != '\0')
646 gaim_account_set_string(account, "connect_server", p->value[1]); 666 gaim_account_set_string(account, "connect_server", p->value[1]);
647 667
648 break;
649
650 /* Napster */ 668 /* Napster */
651 case GAIM_PROTO_NAPSTER: 669 } else if (strcmp(protocol_id, "prpl-napster") == 0) {
652 if (*p->value[3] == '\0') 670 if (*p->value[3] == '\0')
653 gaim_account_set_string(account, "server", "64.124.41.187"); 671 gaim_account_set_string(account, "server", "64.124.41.187");
654 else 672 else
655 gaim_account_set_string(account, "server", p->value[3]); 673 gaim_account_set_string(account, "server", p->value[3]);
656 674
657 if (*p->value[4] == '\0') 675 if (*p->value[4] == '\0')
658 gaim_account_set_int(account, "port", 8888); 676 gaim_account_set_int(account, "port", 8888);
659 else 677 else
660 gaim_account_set_int(account, "port", atoi(p->value[4])); 678 gaim_account_set_int(account, "port", atoi(p->value[4]));
661 679
662 break;
663
664 /* Yahoo! */ 680 /* Yahoo! */
665 case GAIM_PROTO_YAHOO: 681 } else if (strcmp(protocol_id, "prpl-yahoo") == 0) {
666 if (*p->value[3] == '\0') 682 if (*p->value[3] == '\0')
667 gaim_account_set_string(account, "server", "scs.yahoo.com"); 683 gaim_account_set_string(account, "server", "scs.yahoo.com");
668 else 684 else
669 gaim_account_set_string(account, "server", p->value[3]); 685 gaim_account_set_string(account, "server", p->value[3]);
670 686
671 if (*p->value[4] == '\0') 687 if (*p->value[4] == '\0')
672 gaim_account_set_int(account, "port", 5050); 688 gaim_account_set_int(account, "port", 5050);
673 else 689 else
674 gaim_account_set_int(account, "port", atoi(p->value[4])); 690 gaim_account_set_int(account, "port", atoi(p->value[4]));
675 691
676 break;
677
678 /* MSN */ 692 /* MSN */
679 case GAIM_PROTO_MSN: 693 } else if (strcmp(protocol_id, "prpl-msn") == 0) {
680 if (*p->value[3] == '\0') 694 if (*p->value[3] == '\0')
681 gaim_account_set_string(account, "server", 695 gaim_account_set_string(account, "server",
682 "messenger.hotmail.com"); 696 "messenger.hotmail.com");
683 else 697 else
684 gaim_account_set_string(account, "server", p->value[3]); 698 gaim_account_set_string(account, "server", p->value[3]);
685 699
686 if (*p->value[4] == '\0') 700 if (*p->value[4] == '\0')
687 gaim_account_set_int(account, "port", 1863); 701 gaim_account_set_int(account, "port", 1863);
688 else 702 else
689 gaim_account_set_int(account, "port", atoi(p->value[4])); 703 gaim_account_set_int(account, "port", atoi(p->value[4]));
690 704
691 break;
692
693 /* IRC */ 705 /* IRC */
694 case GAIM_PROTO_IRC: 706 } else if (strcmp(protocol_id, "prpl-irc") == 0) {
695 if (*p->value[0] != '\0' && 707 if (*p->value[0] != '\0' &&
696 strchr(gaim_account_get_username(account), '@') == NULL) { 708 strchr(gaim_account_get_username(account), '@') == NULL) {
697 709
698 tmp = g_strdup_printf("%s@%s", 710 tmp = g_strdup_printf("%s@%s",
699 gaim_account_get_username(account), 711 gaim_account_get_username(account),
710 722
711 if (*p->value[2] == '\0') 723 if (*p->value[2] == '\0')
712 gaim_account_set_string(account, "charset", "ISO-8859-1"); 724 gaim_account_set_string(account, "charset", "ISO-8859-1");
713 else 725 else
714 gaim_account_set_string(account, "charset", p->value[2]); 726 gaim_account_set_string(account, "charset", p->value[2]);
715 727 }
716 break;
717
718 default:
719 break;
720 } 728 }
721 729
722 if (!fgets(buf, sizeof(buf), f)) 730 if (!fgets(buf, sizeof(buf), f))
723 return account; 731 return account;
724 732

mercurial