Mercurial > pidgin.yaz
comparison src/gaimrc.c @ 917:f3c23b3c1ed7
[gaim-migrate @ 927]
Better support for upgrading between config file version.
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Fri, 15 Sep 2000 22:29:23 +0000 |
parents | 378c862a2381 |
children | 9fca1293f871 |
comparison
equal
deleted
inserted
replaced
916:e208822ed014 | 917:f3c23b3c1ed7 |
---|---|
657 fprintf(f, "\tlatest_ver { %s }\n", latest_ver); | 657 fprintf(f, "\tlatest_ver { %s }\n", latest_ver); |
658 fprintf(f, "}\n"); | 658 fprintf(f, "}\n"); |
659 } | 659 } |
660 | 660 |
661 | 661 |
662 void set_defaults() | 662 void set_defaults(int saveinfo) |
663 { | 663 { |
664 if (aim_users) | 664 if (!saveinfo) |
665 { | 665 { |
666 g_list_free(aim_users); | 666 if (aim_users) |
667 aim_users = NULL; | 667 { |
668 } | 668 g_list_free(aim_users); |
669 if (away_messages) | 669 aim_users = NULL; |
670 { | 670 } |
671 g_list_free(away_messages); | 671 if (away_messages) |
672 away_messages = NULL; | 672 { |
673 } | 673 g_list_free(away_messages); |
674 away_messages = NULL; | |
675 } | |
676 } | |
677 | |
674 general_options = | 678 general_options = |
675 OPT_GEN_SEND_LINKS | | 679 OPT_GEN_SEND_LINKS | |
676 OPT_GEN_ENTER_SENDS | | 680 OPT_GEN_ENTER_SENDS | |
677 OPT_GEN_SAVED_WINDOWS | | 681 OPT_GEN_SAVED_WINDOWS | |
678 OPT_GEN_REMEMBER_PASS | | 682 OPT_GEN_REMEMBER_PASS | |
694 OPT_DISP_CONV_BUTTON_XPM | | 698 OPT_DISP_CONV_BUTTON_XPM | |
695 OPT_DISP_CONV_BUTTON_TEXT | | 699 OPT_DISP_CONV_BUTTON_TEXT | |
696 OPT_DISP_CHAT_BUTTON_XPM | | 700 OPT_DISP_CHAT_BUTTON_XPM | |
697 OPT_DISP_CHAT_BUTTON_TEXT; | 701 OPT_DISP_CHAT_BUTTON_TEXT; |
698 | 702 |
699 font_options = 0; | 703 if (!saveinfo) |
700 sound_options = OPT_SOUND_LOGIN | OPT_SOUND_LOGOUT | OPT_SOUND_RECV | OPT_SOUND_SEND | OPT_SOUND_SILENT_SIGNON; | 704 { |
701 report_idle = IDLE_GAIM; | 705 font_options = 0; |
702 web_browser = BROWSER_NETSCAPE; | 706 sound_options = OPT_SOUND_LOGIN | OPT_SOUND_LOGOUT | OPT_SOUND_RECV | OPT_SOUND_SEND | OPT_SOUND_SILENT_SIGNON; |
703 proxy_type = PROXY_NONE; | 707 report_idle = IDLE_GAIM; |
708 web_browser = BROWSER_NETSCAPE; | |
709 proxy_type = PROXY_NONE; | |
704 | 710 |
705 aim_port = TOC_PORT; | 711 aim_port = TOC_PORT; |
706 login_port = AUTH_PORT; | 712 login_port = AUTH_PORT; |
707 g_snprintf(aim_host, sizeof(aim_host), "%s", TOC_HOST); | 713 g_snprintf(aim_host, sizeof(aim_host), "%s", TOC_HOST); |
708 g_snprintf(login_host, sizeof(login_host), "%s", AUTH_HOST); | 714 g_snprintf(login_host, sizeof(login_host), "%s", AUTH_HOST); |
709 proxy_host[0] = 0; | 715 proxy_host[0] = 0; |
710 proxy_port = 0; | 716 proxy_port = 0; |
711 g_snprintf(web_command, sizeof(web_command), "xterm -e lynx %%s"); | 717 g_snprintf(web_command, sizeof(web_command), "xterm -e lynx %%s"); |
712 blist_pos.width = 0; | 718 blist_pos.width = 0; |
713 blist_pos.height = 0; | 719 blist_pos.height = 0; |
714 blist_pos.x = 0; | 720 blist_pos.x = 0; |
715 blist_pos.y = 0; | 721 blist_pos.y = 0; |
716 blist_pos.xoff = 0; | 722 blist_pos.xoff = 0; |
717 blist_pos.yoff = 0; | 723 blist_pos.yoff = 0; |
718 g_snprintf(latest_ver, BUF_LONG, "%s", VERSION); | 724 g_snprintf(latest_ver, BUF_LONG, "%s", VERSION); |
725 } | |
719 } | 726 } |
720 | 727 |
721 | 728 |
722 void load_prefs() | 729 void load_prefs() |
723 { | 730 { |
730 if ((f = fopen(buf,"r"))) { | 737 if ((f = fopen(buf,"r"))) { |
731 fgets(buf, sizeof(buf), f); | 738 fgets(buf, sizeof(buf), f); |
732 sscanf(buf, "# .gaimrc v%d", &ver); | 739 sscanf(buf, "# .gaimrc v%d", &ver); |
733 if ( (ver <= 1) || (buf[0] != '#')) { | 740 if ( (ver <= 1) || (buf[0] != '#')) { |
734 fclose(f); | 741 fclose(f); |
735 set_defaults(); | 742 set_defaults(FALSE); |
736 save_prefs(); | 743 save_prefs(); |
737 load_prefs(); | 744 load_prefs(); |
738 return; | 745 return; |
739 } | 746 } |
747 | |
740 while(!feof(f)) { | 748 while(!feof(f)) { |
741 switch(gaimrc_parse_tag(f)) { | 749 switch(gaimrc_parse_tag(f)) { |
742 case -1: | 750 case -1: |
743 /* Let the loop end, EOF*/ | 751 /* Let the loop end, EOF*/ |
744 break; | 752 break; |
768 } | 776 } |
769 } | 777 } |
770 fclose(f); | 778 fclose(f); |
771 } | 779 } |
772 } | 780 } |
781 | |
782 if ( (ver == 2) || (buf[0] != '#')) { | |
783 set_defaults(TRUE); | |
784 } | |
773 | 785 |
774 } | 786 } |
775 | 787 |
776 void save_prefs() | 788 void save_prefs() |
777 { | 789 { |
779 char buf[BUF_LONG]; | 791 char buf[BUF_LONG]; |
780 | 792 |
781 if (getenv("HOME")) { | 793 if (getenv("HOME")) { |
782 g_snprintf(buf, sizeof(buf), "%s/.gaimrc", getenv("HOME")); | 794 g_snprintf(buf, sizeof(buf), "%s/.gaimrc", getenv("HOME")); |
783 if ((f = fopen(buf,"w"))) { | 795 if ((f = fopen(buf,"w"))) { |
784 fprintf(f, "# .gaimrc v%d\n", 2); | 796 fprintf(f, "# .gaimrc v%d\n", 3); |
785 gaimrc_write_users(f); | 797 gaimrc_write_users(f); |
786 gaimrc_write_options(f); | 798 gaimrc_write_options(f); |
787 gaimrc_write_away(f); | 799 gaimrc_write_away(f); |
788 #ifdef GAIM_PLUGINS | 800 #ifdef GAIM_PLUGINS |
789 gaimrc_write_plugins(f); | 801 gaimrc_write_plugins(f); |