comparison src/prefs.c @ 5545:7a64114641c3

[gaim-migrate @ 5946] I've been rewriting the prefs to move from gaimrc to prefs.xml. This will NOT compile! I don't want to see complaints about this, as it's CVS, and you should only be using it if you can put up with things like this. Also, don't ask how long it'll take until it compiles again. It may be several days. This is a big migration. Even when it works, it may not run right. However, it's made a lot of progress, and I plan to actively work on it today and tomorrow. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 29 May 2003 19:10:24 +0000
parents de09863bd4b5
children 90a67ea697f7
comparison
equal deleted inserted replaced
5544:0028381fa874 5545:7a64114641c3
95 gaim_prefs_connect_callback("/", prefs_save_cb, NULL); 95 gaim_prefs_connect_callback("/", prefs_save_cb, NULL);
96 96
97 gaim_prefs_add_none("/core"); 97 gaim_prefs_add_none("/core");
98 98
99 /* XXX: this is where you would want to put prefs declarations */ 99 /* XXX: this is where you would want to put prefs declarations */
100
101 /* Away */
102 gaim_prefs_add_none("/core/away");
103 gaim_prefs_add_bool("/core/away/queue_messages", FALSE);
104 gaim_prefs_add_bool("/core/away/away_when_idle", TRUE);
105
106 /* Away -> Auto Response */
107 gaim_prefs_add_none("/core/away/auto_response");
108 gaim_prefs_add_bool("/core/away/auto_response/enabled", TRUE);
109 gaim_prefs_add_bool("/core/away/auto_response/in_active_conv", TRUE);
110 gaim_prefs_add_bool("/core/away/auto_response/idle_only", FALSE);
111
112 /* Buddies */
113 gaim_prefs_add_none("/core/buddies");
114 gaim_prefs_add_bool("/core/buddies/use_server_alias", TRUE);
115
116 /* Conversations */
100 gaim_prefs_add_none("/core/conversations"); 117 gaim_prefs_add_none("/core/conversations");
101 gaim_prefs_add_bool("/core/conversations/send_urls_as_links", TRUE); 118 gaim_prefs_add_bool("/core/conversations/send_urls_as_links", TRUE);
119 gaim_prefs_add_bool("/core/conversations/away_back_on_send", TRUE);
120 gaim_prefs_add_bool("/core/conversations/use_alias_for_title", TRUE);
121 gaim_prefs_add_bool("/core/conversations/combine_chat_im", FALSE);
122
123 /* Conversations -> Chat */
124 gaim_prefs_add_none("/core/conversations/chat");
125 gaim_prefs_add_bool("/core/conversations/chat/show_join", TRUE);
126 gaim_prefs_add_bool("/core/conversations/chat/show_leave", TRUE);
127 gaim_prefs_add_bool("/core/conversations/chat/show_nick_change", TRUE);
128
129 /* Conversations -> IM */
130 gaim_prefs_add_none("/core/conversations/im");
131 gaim_prefs_add_bool("/core/conversations/im/show_login", TRUE);
132 gaim_prefs_add_bool("/core/conversations/im/show_logoff", TRUE);
133 gaim_prefs_add_bool("/core/conversations/im/send_typing", TRUE);
134
135 /* Proxy */
136 gaim_prefs_add_none("/core/proxy");
137 gaim_prefs_add_int("/core/proxy/type");
138
139 /* Sound */
140 gaim_prefs_add_none("/core/sound");
141 gaim_prefs_add_bool("/core/sound/command", FALSE);
142 gaim_prefs_add_bool("/core/sound/use_arts", FALSE);
143 gaim_prefs_add_bool("/core/sound/use_beep", FALSE);
144 gaim_prefs_add_bool("/core/sound/use_custom", FALSE);
145 gaim_prefs_add_bool("/core/sound/use_esd", FALSE);
146 gaim_prefs_add_bool("/core/sound/use_nas", TRUE);
147 gaim_prefs_add_bool("/core/sound/use_sys_default", TRUE);
148 gaim_prefs_add_bool("/core/sound/while_away", FALSE);
102 } 149 }
103 150
104 static char *pref_full_name(struct gaim_pref *pref) { 151 static char *pref_full_name(struct gaim_pref *pref) {
105 GString *name; 152 GString *name;
106 struct gaim_pref *parent; 153 struct gaim_pref *parent;
368 g_return_val_if_fail(pref->type == GAIM_PREF_INT, 0); 415 g_return_val_if_fail(pref->type == GAIM_PREF_INT, 0);
369 416
370 return pref->value.integer; 417 return pref->value.integer;
371 } 418 }
372 419
373 char *gaim_prefs_get_string(const char *name) { 420 const char *gaim_prefs_get_string(const char *name) {
374 struct gaim_pref *pref = find_pref(name); 421 struct gaim_pref *pref = find_pref(name);
375 422
376 g_return_val_if_fail(pref != NULL, NULL); 423 g_return_val_if_fail(pref != NULL, NULL);
377 g_return_val_if_fail(pref->type == GAIM_PREF_STRING, NULL); 424 g_return_val_if_fail(pref->type == GAIM_PREF_STRING, NULL);
378 425
594 NULL, 641 NULL,
595 NULL, 642 NULL,
596 NULL 643 NULL
597 }; 644 };
598 645
599 void gaim_prefs_load() { 646 gboolean gaim_prefs_load() {
600 gchar *filename = g_build_filename(gaim_user_dir(), "prefs.xml", NULL); 647 gchar *filename = g_build_filename(gaim_user_dir(), "prefs.xml", NULL);
601 gchar *contents = NULL; 648 gchar *contents = NULL;
602 gsize length; 649 gsize length;
603 GMarkupParseContext *context; 650 GMarkupParseContext *context;
604 GError *error = NULL; 651 GError *error = NULL;
605 652
606 653
607 if(!filename) { 654 if(!filename) {
608 prefs_is_loaded = TRUE; 655 prefs_is_loaded = TRUE;
609 return; 656 return FALSE;
610 } 657 }
611 658
612 gaim_debug(GAIM_DEBUG_INFO, "prefs", "Reading %s\n", filename); 659 gaim_debug(GAIM_DEBUG_INFO, "prefs", "Reading %s\n", filename);
613 660
614 if(!g_file_get_contents(filename, &contents, &length, &error)) { 661 if(!g_file_get_contents(filename, &contents, &length, &error)) {
615 gaim_debug(GAIM_DEBUG_ERROR, "prefs", "Error reading prefs: %s\n", 662 gaim_debug(GAIM_DEBUG_ERROR, "prefs", "Error reading prefs: %s\n",
616 error->message); 663 error->message);
617 g_error_free(error); 664 g_error_free(error);
618 prefs_is_loaded = TRUE; 665 prefs_is_loaded = TRUE;
619 return; 666 return FALSE;
620 } 667 }
621 668
622 context = g_markup_parse_context_new(&prefs_parser, 0, NULL, NULL); 669 context = g_markup_parse_context_new(&prefs_parser, 0, NULL, NULL);
623 670
624 if(!g_markup_parse_context_parse(context, contents, length, NULL)) { 671 if(!g_markup_parse_context_parse(context, contents, length, NULL)) {
625 g_markup_parse_context_free(context); 672 g_markup_parse_context_free(context);
626 g_free(contents); 673 g_free(contents);
627 prefs_is_loaded = TRUE; 674 prefs_is_loaded = TRUE;
628 return; 675 return FALSE;
629 } 676 }
630 677
631 if(!g_markup_parse_context_end_parse(context, NULL)) { 678 if(!g_markup_parse_context_end_parse(context, NULL)) {
632 gaim_debug(GAIM_DEBUG_ERROR, "prefs", "Error parsing %s\n", filename); 679 gaim_debug(GAIM_DEBUG_ERROR, "prefs", "Error parsing %s\n", filename);
633 g_markup_parse_context_free(context); 680 g_markup_parse_context_free(context);
634 g_free(contents); 681 g_free(contents);
635 prefs_is_loaded = TRUE; 682 prefs_is_loaded = TRUE;
636 return; 683 return FALSE;
637 } 684 }
638 685
639 g_markup_parse_context_free(context); 686 g_markup_parse_context_free(context);
640 g_free(contents); 687 g_free(contents);
641 688
642 gaim_debug(GAIM_DEBUG_INFO, "prefs", "Finished reading %s\n", filename); 689 gaim_debug(GAIM_DEBUG_INFO, "prefs", "Finished reading %s\n", filename);
643 g_free(filename); 690 g_free(filename);
644 prefs_is_loaded = TRUE; 691 prefs_is_loaded = TRUE;
645 } 692
646 693 return TRUE;
647 694 }
695