annotate src/prefs.c @ 13202:241c59e3906b

[gaim-migrate @ 15565] fix sf bug #1413457 Having the horizontal scrollbar set to NEVER was causing weird bugs with the new status dialog where typing into the imhtml would cause the window to grow in width and the text would not wrap (well, it would eventually). I know having the horizontal scrollbar set to AUTOMATIC was causing problems in the past, but I played around with it and everything seems ok to me. If this becomes a problem I'm thinking we can set it to the horizontal policy to NEVER for editable imhtmls when using GTK < 2.4.0. I think maybe our use of GTK_WRAP_WORD_CHAR might be a partial cause of the bug mentioned in the comment that I'm removing. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 09 Feb 2006 04:40:32 +0000
parents d50c330e8089
children a376b680ae84
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1 /*
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2 * gaim
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 *
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7785
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7785
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7785
diff changeset
6 * source distribution.
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11 * (at your option) any later version.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 * GNU General Public License for more details.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
22 */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
23
349
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 340
diff changeset
24 #ifdef HAVE_CONFIG_H
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2074
diff changeset
25 #include <config.h>
349
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 340
diff changeset
26 #endif
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
27
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
28 #include <string.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
29 #include <stdio.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
30 #include <stdlib.h>
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
31 #include <sys/stat.h>
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
32 #include <sys/types.h>
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
33 #include <glib.h>
6216
dc42b27101c0 [gaim-migrate @ 6702]
Nathan Walp <nwalp@pidgin.im>
parents: 6040
diff changeset
34 #include "internal.h"
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
35 #include "prefs.h"
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
36 #include "debug.h"
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
37 #include "util.h"
3366
120e08ea5aee [gaim-migrate @ 3385]
Sean Egan <seanegan@gmail.com>
parents: 3326
diff changeset
38
4026
a997156437b6 [gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4010
diff changeset
39 #ifdef _WIN32
a997156437b6 [gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4010
diff changeset
40 #include "win32dep.h"
a997156437b6 [gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4010
diff changeset
41 #endif
a997156437b6 [gaim-migrate @ 4230]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4010
diff changeset
42
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
43 struct pref_cb {
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
44 GaimPrefCallback func;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
45 gpointer data;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
46 guint id;
10087
9fdbfe832fac [gaim-migrate @ 11098]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9594
diff changeset
47 void *handle;
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
48 };
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
49
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
50 /* TODO: This should use GaimValues? */
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
51 struct gaim_pref {
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
52 GaimPrefType type;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
53 char *name;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
54 union {
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
55 gpointer generic;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
56 gboolean boolean;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
57 int integer;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
58 char *string;
5561
d67b5b4e1323 [gaim-migrate @ 5962]
Nathan Walp <nwalp@pidgin.im>
parents: 5551
diff changeset
59 GList *stringlist;
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
60 } value;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
61 GSList *callbacks;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
62 struct gaim_pref *parent;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
63 struct gaim_pref *sibling;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
64 struct gaim_pref *first_child;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
65 };
3366
120e08ea5aee [gaim-migrate @ 3385]
Sean Egan <seanegan@gmail.com>
parents: 3326
diff changeset
66
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
67
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
68 static struct gaim_pref prefs = {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
69 GAIM_PREF_NONE,
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
70 NULL,
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
71 { NULL },
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
72 NULL,
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
73 NULL,
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
74 NULL,
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
75 NULL
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
76 };
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
77
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
78 static GHashTable *prefs_hash = NULL;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
79 static guint save_timer = 0;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
80 static gboolean prefs_loaded = FALSE;
5534
0aa4d089125c [gaim-migrate @ 5934]
Nathan Walp <nwalp@pidgin.im>
parents: 5533
diff changeset
81
0aa4d089125c [gaim-migrate @ 5934]
Nathan Walp <nwalp@pidgin.im>
parents: 5533
diff changeset
82
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
83 /*********************************************************************
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
84 * Private utility functions *
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
85 *********************************************************************/
8235
63c7a16a2c09 [gaim-migrate @ 8958]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
86
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
87 static struct
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
88 gaim_pref *find_pref(const char *name)
5787
2adc29c88a45 [gaim-migrate @ 6212]
Christian Hammond <chipx86@chipx86.com>
parents: 5684
diff changeset
89 {
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
90 if (!name || name[0] != '/')
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
91 return NULL;
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
92 else if (name[1] == '\0')
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
93 return &prefs;
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
94 else
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
95 return g_hash_table_lookup(prefs_hash, name);
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
96 }
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
97
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
98
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
99 /*********************************************************************
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
100 * Writing to disk *
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
101 *********************************************************************/
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
102
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
103 /*
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
104 * This function recursively creates the xmlnode tree from the prefs
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
105 * tree structure. Yay recursion!
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
106 */
10850
fa06fda62868 [gaim-migrate @ 12522]
Mark Doliner <mark@kingant.net>
parents: 10443
diff changeset
107 static void
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
108 pref_to_xmlnode(xmlnode *parent, struct gaim_pref *pref)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
109 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
110 xmlnode *node, *childnode;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
111 struct gaim_pref *child;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
112 char buf[20];
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
113 GList *cur;
5561
d67b5b4e1323 [gaim-migrate @ 5962]
Nathan Walp <nwalp@pidgin.im>
parents: 5551
diff changeset
114
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
115 /* Create a new node */
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
116 node = xmlnode_new_child(parent, "pref");
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
117 xmlnode_set_attrib(node, "name", pref->name);
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
118
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
119 /* Set the type of this node (if type == GAIM_PREF_NONE then do nothing) */
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
120 if (pref->type == GAIM_PREF_INT) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
121 xmlnode_set_attrib(node, "type", "int");
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
122 snprintf(buf, sizeof(buf), "%d", pref->value.integer);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
123 xmlnode_set_attrib(node, "value", buf);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
124 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
125 else if (pref->type == GAIM_PREF_STRING) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
126 xmlnode_set_attrib(node, "type", "string");
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
127 xmlnode_set_attrib(node, "value", pref->value.string);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
128 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
129 else if (pref->type == GAIM_PREF_STRING_LIST) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
130 xmlnode_set_attrib(node, "type", "stringlist");
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
131 for (cur = pref->value.stringlist; cur != NULL; cur = cur->next)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
132 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
133 childnode = xmlnode_new_child(node, "item");
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
134 xmlnode_set_attrib(childnode, "value", cur->data);
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
135 }
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
136 }
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
137 else if (pref->type == GAIM_PREF_BOOLEAN) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
138 xmlnode_set_attrib(node, "type", "bool");
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
139 snprintf(buf, sizeof(buf), "%d", pref->value.boolean);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
140 xmlnode_set_attrib(node, "value", buf);
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
141 }
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
142
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
143 /* All My Children */
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
144 for (child = pref->first_child; child != NULL; child = child->sibling)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
145 pref_to_xmlnode(node, child);
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
146 }
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
147
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
148 static xmlnode *
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
149 prefs_to_xmlnode(void)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
150 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
151 xmlnode *node;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
152 struct gaim_pref *pref, *child;
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
153
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
154 pref = &prefs;
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
155
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
156 /* Create the root preference node */
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
157 node = xmlnode_new("pref");
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
158 xmlnode_set_attrib(node, "version", "1");
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
159 xmlnode_set_attrib(node, "name", "/");
5561
d67b5b4e1323 [gaim-migrate @ 5962]
Nathan Walp <nwalp@pidgin.im>
parents: 5551
diff changeset
160
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
161 /* All My Children */
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
162 for (child = pref->first_child; child != NULL; child = child->sibling)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
163 pref_to_xmlnode(node, child);
5561
d67b5b4e1323 [gaim-migrate @ 5962]
Nathan Walp <nwalp@pidgin.im>
parents: 5551
diff changeset
164
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
165 return node;
5561
d67b5b4e1323 [gaim-migrate @ 5962]
Nathan Walp <nwalp@pidgin.im>
parents: 5551
diff changeset
166 }
d67b5b4e1323 [gaim-migrate @ 5962]
Nathan Walp <nwalp@pidgin.im>
parents: 5551
diff changeset
167
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
168 static void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
169 sync_prefs(void)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
170 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
171 xmlnode *node;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
172 char *data;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5105
diff changeset
173
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
174 if (!prefs_loaded)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
175 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
176 /*
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
177 * TODO: Call schedule_prefs_save()? Ideally we wouldn't need to.
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
178 * (prefs.xml should be loaded when gaim_prefs_init is called)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
179 */
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
180 gaim_debug_error("prefs", "Attempted to save prefs before "
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
181 "they were read!\n");
5814
fb9209877f37 [gaim-migrate @ 6244]
Nathan Walp <nwalp@pidgin.im>
parents: 5787
diff changeset
182 return;
fb9209877f37 [gaim-migrate @ 6244]
Nathan Walp <nwalp@pidgin.im>
parents: 5787
diff changeset
183 }
3500
b79894c97bed [gaim-migrate @ 3563]
Luke Schierer <lschiere@pidgin.im>
parents: 3485
diff changeset
184
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
185 node = prefs_to_xmlnode();
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
186 data = xmlnode_to_formatted_str(node, NULL);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
187 gaim_util_write_data_to_file("prefs.xml", data, -1);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
188 g_free(data);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
189 xmlnode_free(node);
4326
eb63f9960d07 [gaim-migrate @ 4582]
Rob Flynn <gaim@robflynn.com>
parents: 4325
diff changeset
190 }
eb63f9960d07 [gaim-migrate @ 4582]
Rob Flynn <gaim@robflynn.com>
parents: 4325
diff changeset
191
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
192 static gboolean
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
193 save_cb(gpointer data)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
194 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
195 sync_prefs();
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
196 save_timer = 0;
9594
15d09e546cee [gaim-migrate @ 10437]
Mark Doliner <mark@kingant.net>
parents: 9251
diff changeset
197 return FALSE;
4288
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4241
diff changeset
198 }
a723d060620a [gaim-migrate @ 4541]
Sean Egan <seanegan@gmail.com>
parents: 4241
diff changeset
199
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
200 static void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
201 schedule_prefs_save(void)
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
202 {
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
203 if (save_timer == 0)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
204 save_timer = gaim_timeout_add(5000, save_cb, NULL);
3366
120e08ea5aee [gaim-migrate @ 3385]
Sean Egan <seanegan@gmail.com>
parents: 3326
diff changeset
205 }
120e08ea5aee [gaim-migrate @ 3385]
Sean Egan <seanegan@gmail.com>
parents: 3326
diff changeset
206
2254
c0ac78ffe77f [gaim-migrate @ 2264]
Rob Flynn <gaim@robflynn.com>
parents: 2199
diff changeset
207
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
208 /*********************************************************************
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
209 * Reading from disk *
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
210 *********************************************************************/
3551
cd938f18f3f8 [gaim-migrate @ 3626]
Sean Egan <seanegan@gmail.com>
parents: 3526
diff changeset
211
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
212 static GList *prefs_stack = NULL;
873
789df4b47508 [gaim-migrate @ 883]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 864
diff changeset
213
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
214 static void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
215 prefs_start_element_handler (GMarkupParseContext *context,
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
216 const gchar *element_name,
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
217 const gchar **attribute_names,
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
218 const gchar **attribute_values,
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
219 gpointer user_data,
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
220 GError **error)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
221 {
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
222 GaimPrefType pref_type = GAIM_PREF_NONE;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
223 int i;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
224 const char *pref_name = NULL, *pref_value = NULL;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
225 GString *pref_name_full;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
226 GList *tmp;
3366
120e08ea5aee [gaim-migrate @ 3385]
Sean Egan <seanegan@gmail.com>
parents: 3326
diff changeset
227
5561
d67b5b4e1323 [gaim-migrate @ 5962]
Nathan Walp <nwalp@pidgin.im>
parents: 5551
diff changeset
228 if(strcmp(element_name, "pref") && strcmp(element_name, "item"))
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
229 return;
3500
b79894c97bed [gaim-migrate @ 3563]
Luke Schierer <lschiere@pidgin.im>
parents: 3485
diff changeset
230
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
231 for(i = 0; attribute_names[i]; i++) {
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
232 if(!strcmp(attribute_names[i], "name")) {
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
233 pref_name = attribute_values[i];
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
234 } else if(!strcmp(attribute_names[i], "type")) {
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
235 if(!strcmp(attribute_values[i], "bool"))
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
236 pref_type = GAIM_PREF_BOOLEAN;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
237 else if(!strcmp(attribute_values[i], "int"))
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
238 pref_type = GAIM_PREF_INT;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
239 else if(!strcmp(attribute_values[i], "string"))
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
240 pref_type = GAIM_PREF_STRING;
5561
d67b5b4e1323 [gaim-migrate @ 5962]
Nathan Walp <nwalp@pidgin.im>
parents: 5551
diff changeset
241 else if(!strcmp(attribute_values[i], "stringlist"))
d67b5b4e1323 [gaim-migrate @ 5962]
Nathan Walp <nwalp@pidgin.im>
parents: 5551
diff changeset
242 pref_type = GAIM_PREF_STRING_LIST;
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
243 else
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
244 return;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
245 } else if(!strcmp(attribute_names[i], "value")) {
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
246 pref_value = attribute_values[i];
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
247 }
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
248 }
873
789df4b47508 [gaim-migrate @ 883]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 864
diff changeset
249
5561
d67b5b4e1323 [gaim-migrate @ 5962]
Nathan Walp <nwalp@pidgin.im>
parents: 5551
diff changeset
250 if(!strcmp(element_name, "item")) {
5838
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
251 struct gaim_pref *pref;
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
252
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
253 pref_name_full = g_string_new("");
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
254
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
255 for(tmp = prefs_stack; tmp; tmp = tmp->next) {
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
256 pref_name_full = g_string_prepend(pref_name_full, tmp->data);
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
257 pref_name_full = g_string_prepend_c(pref_name_full, '/');
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
258 }
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
259
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
260 pref = find_pref(pref_name_full->str);
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
261
5561
d67b5b4e1323 [gaim-migrate @ 5962]
Nathan Walp <nwalp@pidgin.im>
parents: 5551
diff changeset
262 if(pref) {
d67b5b4e1323 [gaim-migrate @ 5962]
Nathan Walp <nwalp@pidgin.im>
parents: 5551
diff changeset
263 pref->value.stringlist = g_list_append(pref->value.stringlist,
d67b5b4e1323 [gaim-migrate @ 5962]
Nathan Walp <nwalp@pidgin.im>
parents: 5551
diff changeset
264 g_strdup(pref_value));
d67b5b4e1323 [gaim-migrate @ 5962]
Nathan Walp <nwalp@pidgin.im>
parents: 5551
diff changeset
265 }
5838
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
266 } else {
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
267 if(!pref_name || !strcmp(pref_name, "/"))
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
268 return;
652
4d3285caa191 [gaim-migrate @ 662]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 619
diff changeset
269
5838
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
270 pref_name_full = g_string_new(pref_name);
652
4d3285caa191 [gaim-migrate @ 662]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 619
diff changeset
271
5838
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
272 for(tmp = prefs_stack; tmp; tmp = tmp->next) {
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
273 pref_name_full = g_string_prepend_c(pref_name_full, '/');
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
274 pref_name_full = g_string_prepend(pref_name_full, tmp->data);
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
275 }
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
276
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
277 pref_name_full = g_string_prepend_c(pref_name_full, '/');
1253
8342d3aab1f1 [gaim-migrate @ 1263]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1250
diff changeset
278
5838
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
279 switch(pref_type) {
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
280 case GAIM_PREF_NONE:
7785
d5ee9c6da122 [gaim-migrate @ 8430]
Nathan Walp <nwalp@pidgin.im>
parents: 7689
diff changeset
281 gaim_prefs_add_none(pref_name_full->str);
5838
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
282 break;
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
283 case GAIM_PREF_BOOLEAN:
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
284 gaim_prefs_set_bool(pref_name_full->str, atoi(pref_value));
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
285 break;
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
286 case GAIM_PREF_INT:
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
287 gaim_prefs_set_int(pref_name_full->str, atoi(pref_value));
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
288 break;
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
289 case GAIM_PREF_STRING:
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
290 gaim_prefs_set_string(pref_name_full->str, pref_value);
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
291 break;
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
292 case GAIM_PREF_STRING_LIST:
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
293 gaim_prefs_set_string_list(pref_name_full->str, NULL);
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
294 break;
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
295 }
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
296 prefs_stack = g_list_prepend(prefs_stack, g_strdup(pref_name));
6aa7651c7c15 [gaim-migrate @ 6269]
Nathan Walp <nwalp@pidgin.im>
parents: 5814
diff changeset
297 g_string_free(pref_name_full, TRUE);
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
298 }
1170
16d748023b2b [gaim-migrate @ 1180]
Rob Flynn <gaim@robflynn.com>
parents: 1147
diff changeset
299 }
16d748023b2b [gaim-migrate @ 1180]
Rob Flynn <gaim@robflynn.com>
parents: 1147
diff changeset
300
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
301 static void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
302 prefs_end_element_handler(GMarkupParseContext *context,
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
303 const gchar *element_name,
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
304 gpointer user_data, GError **error)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
305 {
5940
94ad4d45346a [gaim-migrate @ 6380]
Nathan Walp <nwalp@pidgin.im>
parents: 5858
diff changeset
306 if(prefs_stack && !strcmp(element_name, "pref")) {
94ad4d45346a [gaim-migrate @ 6380]
Nathan Walp <nwalp@pidgin.im>
parents: 5858
diff changeset
307 g_free(prefs_stack->data);
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
308 prefs_stack = g_list_delete_link(prefs_stack, prefs_stack);
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
309 }
1170
16d748023b2b [gaim-migrate @ 1180]
Rob Flynn <gaim@robflynn.com>
parents: 1147
diff changeset
310 }
16d748023b2b [gaim-migrate @ 1180]
Rob Flynn <gaim@robflynn.com>
parents: 1147
diff changeset
311
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
312 static GMarkupParser prefs_parser = {
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
313 prefs_start_element_handler,
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
314 prefs_end_element_handler,
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
315 NULL,
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
316 NULL,
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
317 NULL
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
318 };
1170
16d748023b2b [gaim-migrate @ 1180]
Rob Flynn <gaim@robflynn.com>
parents: 1147
diff changeset
319
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
320 gboolean
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
321 gaim_prefs_load()
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
322 {
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
323 gchar *filename = g_build_filename(gaim_user_dir(), "prefs.xml", NULL);
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
324 gchar *contents = NULL;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
325 gsize length;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
326 GMarkupParseContext *context;
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
327 GError *error = NULL;
5314
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5297
diff changeset
328
7561
cdfdbabd3266 [gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents: 7555
diff changeset
329 if (!filename) {
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
330 prefs_loaded = TRUE;
5545
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5539
diff changeset
331 return FALSE;
5534
0aa4d089125c [gaim-migrate @ 5934]
Nathan Walp <nwalp@pidgin.im>
parents: 5533
diff changeset
332 }
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
333
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
334 gaim_debug_info("prefs", "Reading %s\n", filename);
5314
1f901484599d [gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents: 5297
diff changeset
335
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
336 if(!g_file_get_contents(filename, &contents, &length, &error)) {
8671
d99d2572d1a9 [gaim-migrate @ 9423]
Christian Hammond <chipx86@chipx86.com>
parents: 8549
diff changeset
337 #ifndef _WIN32
d99d2572d1a9 [gaim-migrate @ 9423]
Christian Hammond <chipx86@chipx86.com>
parents: 8549
diff changeset
338 g_free(filename);
d99d2572d1a9 [gaim-migrate @ 9423]
Christian Hammond <chipx86@chipx86.com>
parents: 8549
diff changeset
339 g_error_free(error);
d99d2572d1a9 [gaim-migrate @ 9423]
Christian Hammond <chipx86@chipx86.com>
parents: 8549
diff changeset
340
d99d2572d1a9 [gaim-migrate @ 9423]
Christian Hammond <chipx86@chipx86.com>
parents: 8549
diff changeset
341 error = NULL;
d99d2572d1a9 [gaim-migrate @ 9423]
Christian Hammond <chipx86@chipx86.com>
parents: 8549
diff changeset
342
8702
68d8280c5e13 [gaim-migrate @ 9455]
Luke Schierer <lschiere@pidgin.im>
parents: 8671
diff changeset
343 filename = g_build_filename(SYSCONFDIR, "gaim", "prefs.xml", NULL);
8671
d99d2572d1a9 [gaim-migrate @ 9423]
Christian Hammond <chipx86@chipx86.com>
parents: 8549
diff changeset
344
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
345 gaim_debug_info("prefs", "Reading %s\n", filename);
8671
d99d2572d1a9 [gaim-migrate @ 9423]
Christian Hammond <chipx86@chipx86.com>
parents: 8549
diff changeset
346
d99d2572d1a9 [gaim-migrate @ 9423]
Christian Hammond <chipx86@chipx86.com>
parents: 8549
diff changeset
347 if (!g_file_get_contents(filename, &contents, &length, &error)) {
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
348 gaim_debug_error("prefs", "Error reading prefs: %s\n",
8671
d99d2572d1a9 [gaim-migrate @ 9423]
Christian Hammond <chipx86@chipx86.com>
parents: 8549
diff changeset
349 error->message);
d99d2572d1a9 [gaim-migrate @ 9423]
Christian Hammond <chipx86@chipx86.com>
parents: 8549
diff changeset
350 g_error_free(error);
d99d2572d1a9 [gaim-migrate @ 9423]
Christian Hammond <chipx86@chipx86.com>
parents: 8549
diff changeset
351 g_free(filename);
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
352 prefs_loaded = TRUE;
8671
d99d2572d1a9 [gaim-migrate @ 9423]
Christian Hammond <chipx86@chipx86.com>
parents: 8549
diff changeset
353
d99d2572d1a9 [gaim-migrate @ 9423]
Christian Hammond <chipx86@chipx86.com>
parents: 8549
diff changeset
354 return FALSE;
d99d2572d1a9 [gaim-migrate @ 9423]
Christian Hammond <chipx86@chipx86.com>
parents: 8549
diff changeset
355 }
d99d2572d1a9 [gaim-migrate @ 9423]
Christian Hammond <chipx86@chipx86.com>
parents: 8549
diff changeset
356 #else /* _WIN32 */
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
357 gaim_debug_error("prefs", "Error reading prefs: %s\n",
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
358 error->message);
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
359 g_error_free(error);
6040
80e3641ee9eb [gaim-migrate @ 6490]
Mark Doliner <mark@kingant.net>
parents: 5986
diff changeset
360 g_free(filename);
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
361 prefs_loaded = TRUE;
6040
80e3641ee9eb [gaim-migrate @ 6490]
Mark Doliner <mark@kingant.net>
parents: 5986
diff changeset
362
5545
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5539
diff changeset
363 return FALSE;
8671
d99d2572d1a9 [gaim-migrate @ 9423]
Christian Hammond <chipx86@chipx86.com>
parents: 8549
diff changeset
364 #endif /* _WIN32 */
1170
16d748023b2b [gaim-migrate @ 1180]
Rob Flynn <gaim@robflynn.com>
parents: 1147
diff changeset
365 }
16d748023b2b [gaim-migrate @ 1180]
Rob Flynn <gaim@robflynn.com>
parents: 1147
diff changeset
366
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
367 context = g_markup_parse_context_new(&prefs_parser, 0, NULL, NULL);
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
368
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
369 if(!g_markup_parse_context_parse(context, contents, length, NULL)) {
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
370 g_markup_parse_context_free(context);
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
371 g_free(contents);
6040
80e3641ee9eb [gaim-migrate @ 6490]
Mark Doliner <mark@kingant.net>
parents: 5986
diff changeset
372 g_free(filename);
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
373 prefs_loaded = TRUE;
6040
80e3641ee9eb [gaim-migrate @ 6490]
Mark Doliner <mark@kingant.net>
parents: 5986
diff changeset
374
5545
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5539
diff changeset
375 return FALSE;
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
376 }
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
377
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
378 if(!g_markup_parse_context_end_parse(context, NULL)) {
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
379 gaim_debug_error("prefs", "Error parsing %s\n", filename);
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
380 g_markup_parse_context_free(context);
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
381 g_free(contents);
6040
80e3641ee9eb [gaim-migrate @ 6490]
Mark Doliner <mark@kingant.net>
parents: 5986
diff changeset
382 g_free(filename);
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
383 prefs_loaded = TRUE;
6040
80e3641ee9eb [gaim-migrate @ 6490]
Mark Doliner <mark@kingant.net>
parents: 5986
diff changeset
384
5545
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5539
diff changeset
385 return FALSE;
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
386 }
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
387
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
388 gaim_debug_info("prefs", "Finished reading %s\n", filename);
5440
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
389 g_markup_parse_context_free(context);
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
390 g_free(contents);
7e8524b5ff98 [gaim-migrate @ 5822]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
391 g_free(filename);
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
392 prefs_loaded = TRUE;
5545
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5539
diff changeset
393
13053
d50c330e8089 [gaim-migrate @ 15414]
Richard Laager <rlaager@wiktel.com>
parents: 13040
diff changeset
394 /* I introduced a bug in 2.0.0beta2. This fixes the broken
d50c330e8089 [gaim-migrate @ 15414]
Richard Laager <rlaager@wiktel.com>
parents: 13040
diff changeset
395 * scores on upgrade. This can be removed sometime shortly
d50c330e8089 [gaim-migrate @ 15414]
Richard Laager <rlaager@wiktel.com>
parents: 13040
diff changeset
396 * after 2.0.0 final is released. -- rlaager */
d50c330e8089 [gaim-migrate @ 15414]
Richard Laager <rlaager@wiktel.com>
parents: 13040
diff changeset
397 if (gaim_prefs_get_int("/core/status/scores/offline") == -500 &&
d50c330e8089 [gaim-migrate @ 15414]
Richard Laager <rlaager@wiktel.com>
parents: 13040
diff changeset
398 gaim_prefs_get_int("/core/status/scores/available") == 100 &&
d50c330e8089 [gaim-migrate @ 15414]
Richard Laager <rlaager@wiktel.com>
parents: 13040
diff changeset
399 gaim_prefs_get_int("/core/status/scores/invisible") == -50 &&
d50c330e8089 [gaim-migrate @ 15414]
Richard Laager <rlaager@wiktel.com>
parents: 13040
diff changeset
400 gaim_prefs_get_int("/core/status/scores/away") == -100 &&
d50c330e8089 [gaim-migrate @ 15414]
Richard Laager <rlaager@wiktel.com>
parents: 13040
diff changeset
401 gaim_prefs_get_int("/core/status/scores/extended_away") == -200 &&
d50c330e8089 [gaim-migrate @ 15414]
Richard Laager <rlaager@wiktel.com>
parents: 13040
diff changeset
402 gaim_prefs_get_int("/core/status/scores/idle") == -400)
d50c330e8089 [gaim-migrate @ 15414]
Richard Laager <rlaager@wiktel.com>
parents: 13040
diff changeset
403 {
d50c330e8089 [gaim-migrate @ 15414]
Richard Laager <rlaager@wiktel.com>
parents: 13040
diff changeset
404 gaim_prefs_set_int("/core/status/scores/idle", -10);
d50c330e8089 [gaim-migrate @ 15414]
Richard Laager <rlaager@wiktel.com>
parents: 13040
diff changeset
405 }
d50c330e8089 [gaim-migrate @ 15414]
Richard Laager <rlaager@wiktel.com>
parents: 13040
diff changeset
406
5545
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5539
diff changeset
407 return TRUE;
1006
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1002
diff changeset
408 }
0a4d0ed65e17 [gaim-migrate @ 1016]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1002
diff changeset
409
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
410
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
411
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
412 static void
12822
cecc9706c11f [gaim-migrate @ 15170]
Richard Laager <rlaager@wiktel.com>
parents: 12762
diff changeset
413 prefs_save_cb(const char *name, GaimPrefType type, gconstpointer val,
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
414 gpointer user_data)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
415 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
416
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
417 if(!prefs_loaded)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
418 return;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
419
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
420 gaim_debug_misc("prefs", "%s changed, scheduling save.\n", name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
421
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
422 schedule_prefs_save();
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
423 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
424
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
425 static char *
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
426 get_path_dirname(const char *name)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
427 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
428 char *c, *str;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
429
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
430 str = g_strdup(name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
431
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
432 if ((c = strrchr(str, '/')) != NULL) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
433 *c = '\0';
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
434
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
435 if (*str == '\0') {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
436 g_free(str);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
437
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
438 str = g_strdup("/");
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
439 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
440 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
441 else {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
442 g_free(str);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
444 str = g_strdup(".");
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
445 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
446
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
447 return str;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
448 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
449
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
450 static char *
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
451 get_path_basename(const char *name)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
452 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
453 const char *c;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
454
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
455 if ((c = strrchr(name, '/')) != NULL)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
456 return g_strdup(c + 1);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
457
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
458 return g_strdup(name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
459 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
460
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
461 static char *
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
462 pref_full_name(struct gaim_pref *pref)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
463 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
464 GString *name;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
465 struct gaim_pref *parent;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
466 char *ret;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
467
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
468 if(!pref)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
469 return NULL;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
470
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
471 if(pref == &prefs)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
472 return g_strdup("/");
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
473
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
474 name = g_string_new(pref->name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
475 parent = pref->parent;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
476
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
477 for(parent = pref->parent; parent && parent->name; parent = parent->parent) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
478 name = g_string_prepend_c(name, '/');
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
479 name = g_string_prepend(name, parent->name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
480 }
12759
019d0e4d8d65 [gaim-migrate @ 15106]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12615
diff changeset
481 name = g_string_prepend_c(name, '/');
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
482 ret = name->str;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
483 g_string_free(name, FALSE);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
484 return ret;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
485 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
486
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
487 static struct gaim_pref *
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
488 find_pref_parent(const char *name)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
489 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
490 char *parent_name = get_path_dirname(name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
491 struct gaim_pref *ret = &prefs;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
492
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
493 if(strcmp(parent_name, "/")) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
494 ret = find_pref(parent_name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
495 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
496
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
497 g_free(parent_name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
498 return ret;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
499 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
500
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
501 static void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
502 free_pref_value(struct gaim_pref *pref)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
503 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
504 switch(pref->type) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
505 case GAIM_PREF_BOOLEAN:
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
506 pref->value.boolean = FALSE;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
507 break;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
508 case GAIM_PREF_INT:
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
509 pref->value.integer = 0;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
510 break;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
511 case GAIM_PREF_STRING:
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
512 g_free(pref->value.string);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
513 pref->value.string = NULL;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
514 break;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
515 case GAIM_PREF_STRING_LIST:
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
516 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
517 GList *tmp;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
518 for(tmp = pref->value.stringlist; tmp; tmp = tmp->next)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
519 g_free(tmp->data);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
520
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
521 g_list_free(pref->value.stringlist);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
522 } break;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
523 case GAIM_PREF_NONE:
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
524 break;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
525 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
526 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
527
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
528 static struct gaim_pref *
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
529 add_pref(GaimPrefType type, const char *name)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
530 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
531 struct gaim_pref *parent;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
532 struct gaim_pref *me;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
533 struct gaim_pref *sibling;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
534 char *my_name;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
535
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
536 parent = find_pref_parent(name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
537
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
538 if(!parent)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
539 return NULL;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
540
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
541 my_name = get_path_basename(name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
542
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
543 for(sibling = parent->first_child; sibling; sibling = sibling->sibling) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
544 if(!strcmp(sibling->name, my_name)) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
545 g_free(my_name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
546 return NULL;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
547 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
548 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
549
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
550 me = g_new0(struct gaim_pref, 1);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
551 me->type = type;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
552 me->name = my_name;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
553
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
554 me->parent = parent;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
555 if(parent->first_child) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
556 /* blatant abuse of a for loop */
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
557 for(sibling = parent->first_child; sibling->sibling;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
558 sibling = sibling->sibling);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
559 sibling->sibling = me;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
560 } else {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
561 parent->first_child = me;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
562 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
563
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
564 g_hash_table_insert(prefs_hash, g_strdup(name), (gpointer)me);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
565
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
566 return me;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
567 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
568
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
569 void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
570 gaim_prefs_add_none(const char *name)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
571 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
572 add_pref(GAIM_PREF_NONE, name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
573 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
574
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
575 void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
576 gaim_prefs_add_bool(const char *name, gboolean value)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
577 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
578 struct gaim_pref *pref = add_pref(GAIM_PREF_BOOLEAN, name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
579
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
580 if(!pref)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
581 return;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
582
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
583 pref->value.boolean = value;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
584 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
585
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
586 void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
587 gaim_prefs_add_int(const char *name, int value)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
588 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
589 struct gaim_pref *pref = add_pref(GAIM_PREF_INT, name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
590
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
591 if(!pref)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
592 return;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
593
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
594 pref->value.integer = value;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
595 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
596
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
597 void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
598 gaim_prefs_add_string(const char *name, const char *value)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
599 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
600 struct gaim_pref *pref = add_pref(GAIM_PREF_STRING, name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
601
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
602 if(!pref)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
603 return;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
604
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
605 pref->value.string = g_strdup(value);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
606 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
607
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
608 void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
609 gaim_prefs_add_string_list(const char *name, GList *value)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
610 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
611 struct gaim_pref *pref = add_pref(GAIM_PREF_STRING_LIST, name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
612 GList *tmp;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
613
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
614 if(!pref)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
615 return;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
616
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
617 for(tmp = value; tmp; tmp = tmp->next)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
618 pref->value.stringlist = g_list_append(pref->value.stringlist,
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
619 g_strdup(tmp->data));
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
620 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
621
10871
6240d7fd5b2c [gaim-migrate @ 12558]
Mark Doliner <mark@kingant.net>
parents: 10850
diff changeset
622 static void
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
623 remove_pref(struct gaim_pref *pref)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
624 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
625 char *name;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
626
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
627 if(!pref || pref == &prefs)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
628 return;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
629
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
630 while(pref->first_child)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
631 remove_pref(pref->first_child);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
632
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
633 if(pref->parent->first_child == pref) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
634 pref->parent->first_child = pref->sibling;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
635 } else {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
636 struct gaim_pref *sib = pref->parent->first_child;
12599
e94c33909aa6 [gaim-migrate @ 14929]
Nathan Walp <nwalp@pidgin.im>
parents: 12573
diff changeset
637 while(sib && sib->sibling != pref)
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
638 sib = sib->sibling;
12599
e94c33909aa6 [gaim-migrate @ 14929]
Nathan Walp <nwalp@pidgin.im>
parents: 12573
diff changeset
639 if(sib)
e94c33909aa6 [gaim-migrate @ 14929]
Nathan Walp <nwalp@pidgin.im>
parents: 12573
diff changeset
640 sib->sibling = pref->sibling;
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
641 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
642
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
643 name = pref_full_name(pref);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
644
12762
40584fbf8c6e [gaim-migrate @ 15109]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12759
diff changeset
645 gaim_debug_info("prefs", "removing pref %s\n", name);
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
646
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
647 g_hash_table_remove(prefs_hash, name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
648 g_free(name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
649
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
650 free_pref_value(pref);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
651
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
652 g_slist_free(pref->callbacks);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
653 g_free(pref->name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
654 g_free(pref);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
655 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
656
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
657 void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
658 gaim_prefs_remove(const char *name)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
659 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
660 struct gaim_pref *pref = find_pref(name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
661
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
662 if(!pref)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
663 return;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
664
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
665 remove_pref(pref);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
666 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
667
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
668 void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
669 gaim_prefs_destroy()
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
670 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
671 gaim_prefs_remove("/");
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
672 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
673
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
674 static void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
675 do_callbacks(const char* name, struct gaim_pref *pref)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
676 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
677 GSList *cbs;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
678 struct gaim_pref *cb_pref;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
679 for(cb_pref = pref; cb_pref; cb_pref = cb_pref->parent) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
680 for(cbs = cb_pref->callbacks; cbs; cbs = cbs->next) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
681 struct pref_cb *cb = cbs->data;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
682 cb->func(name, pref->type, pref->value.generic, cb->data);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
683 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
684 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
685 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
686
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
687 void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
688 gaim_prefs_trigger_callback(const char *name)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
689 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
690 struct gaim_pref *pref = find_pref(name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
691
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
692 if(!pref) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
693 gaim_debug_error("prefs",
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
694 "gaim_prefs_trigger_callback: Unknown pref %s\n", name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
695 return;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
696 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
697
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
698 do_callbacks(name, pref);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
699 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
700
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
701 void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
702 gaim_prefs_set_generic(const char *name, gpointer value)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
703 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
704 struct gaim_pref *pref = find_pref(name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
705
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
706 if(!pref) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
707 gaim_debug_error("prefs",
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
708 "gaim_prefs_set_generic: Unknown pref %s\n", name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
709 return;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
710 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
711
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
712 pref->value.generic = value;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
713 do_callbacks(name, pref);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
714 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
715
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
716 void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
717 gaim_prefs_set_bool(const char *name, gboolean value)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
718 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
719 struct gaim_pref *pref = find_pref(name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
720
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
721 if(pref) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
722 if(pref->type != GAIM_PREF_BOOLEAN) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
723 gaim_debug_error("prefs",
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
724 "gaim_prefs_set_bool: %s not a boolean pref\n", name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
725 return;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
726 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
727
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
728 if(pref->value.boolean != value) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
729 pref->value.boolean = value;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
730 do_callbacks(name, pref);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
731 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
732 } else {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
733 gaim_prefs_add_bool(name, value);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
734 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
735 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
736
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
737 void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
738 gaim_prefs_set_int(const char *name, int value)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
739 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
740 struct gaim_pref *pref = find_pref(name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
741
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
742 if(pref) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
743 if(pref->type != GAIM_PREF_INT) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
744 gaim_debug_error("prefs",
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
745 "gaim_prefs_set_int: %s not an integer pref\n", name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
746 return;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
747 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
748
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
749 if(pref->value.integer != value) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
750 pref->value.integer = value;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
751 do_callbacks(name, pref);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
752 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
753 } else {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
754 gaim_prefs_add_int(name, value);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
755 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
756 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
757
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
758 void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
759 gaim_prefs_set_string(const char *name, const char *value)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
760 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
761 struct gaim_pref *pref = find_pref(name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
762
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
763 if(pref) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
764 if(pref->type != GAIM_PREF_STRING) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
765 gaim_debug_error("prefs",
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
766 "gaim_prefs_set_string: %s not a string pref\n", name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
767 return;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
768 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
769
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
770 if((value && !pref->value.string) ||
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
771 (!value && pref->value.string) ||
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
772 strcmp(pref->value.string, value)) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
773 g_free(pref->value.string);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
774 pref->value.string = g_strdup(value);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
775 do_callbacks(name, pref);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
776 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
777 } else {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
778 gaim_prefs_add_string(name, value);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
779 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
780 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
781
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
782 void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
783 gaim_prefs_set_string_list(const char *name, GList *value)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
784 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
785 struct gaim_pref *pref = find_pref(name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
786 if(pref) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
787 GList *tmp;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
788
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
789 if(pref->type != GAIM_PREF_STRING_LIST) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
790 gaim_debug_error("prefs",
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
791 "gaim_prefs_set_string_list: %s not a string list pref\n",
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
792 name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
793 return;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
794 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
795
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
796 for(tmp = pref->value.stringlist; tmp; tmp = tmp->next)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
797 g_free(tmp->data);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
798
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
799 g_list_free(pref->value.stringlist);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
800 pref->value.stringlist = NULL;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
801
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
802 for(tmp = value; tmp; tmp = tmp->next)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
803 pref->value.stringlist = g_list_append(pref->value.stringlist,
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
804 g_strdup(tmp->data));
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
805
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
806 do_callbacks(name, pref);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
807
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
808 } else {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
809 gaim_prefs_add_string_list(name, value);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
810 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
811 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
812
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
813 gboolean
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
814 gaim_prefs_exists(const char *name)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
815 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
816 struct gaim_pref *pref = find_pref(name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
817
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
818 if (pref != NULL)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
819 return TRUE;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
820
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
821 return FALSE;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
822 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
823
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
824 GaimPrefType
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
825 gaim_prefs_get_type(const char *name)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
826 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
827 struct gaim_pref *pref = find_pref(name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
828
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
829 if (pref == NULL)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
830 return GAIM_PREF_NONE;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
831
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
832 return (pref->type);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
833 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
834
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
835 gboolean
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
836 gaim_prefs_get_bool(const char *name)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
837 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
838 struct gaim_pref *pref = find_pref(name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
839
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
840 if(!pref) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
841 gaim_debug_error("prefs",
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
842 "gaim_prefs_get_bool: Unknown pref %s\n", name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
843 return FALSE;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
844 } else if(pref->type != GAIM_PREF_BOOLEAN) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
845 gaim_debug_error("prefs",
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
846 "gaim_prefs_get_bool: %s not a boolean pref\n", name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
847 return FALSE;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
848 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
849
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
850 return pref->value.boolean;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
851 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
852
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
853 int
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
854 gaim_prefs_get_int(const char *name)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
855 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
856 struct gaim_pref *pref = find_pref(name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
857
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
858 if(!pref) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
859 gaim_debug_error("prefs",
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
860 "gaim_prefs_get_int: Unknown pref %s\n", name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
861 return 0;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
862 } else if(pref->type != GAIM_PREF_INT) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
863 gaim_debug_error("prefs",
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
864 "gaim_prefs_get_int: %s not an integer pref\n", name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
865 return 0;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
866 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
867
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
868 return pref->value.integer;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
869 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
870
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
871 const char *
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
872 gaim_prefs_get_string(const char *name)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
873 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
874 struct gaim_pref *pref = find_pref(name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
875
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
876 if(!pref) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
877 gaim_debug_error("prefs",
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
878 "gaim_prefs_get_string: Unknown pref %s\n", name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
879 return NULL;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
880 } else if(pref->type != GAIM_PREF_STRING) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
881 gaim_debug_error("prefs",
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
882 "gaim_prefs_get_string: %s not a string pref\n", name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
883 return NULL;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
884 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
885
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
886 return pref->value.string;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
887 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
888
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
889 GList *
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
890 gaim_prefs_get_string_list(const char *name)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
891 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
892 struct gaim_pref *pref = find_pref(name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
893 GList *ret = NULL, *tmp;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
894
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
895 if(!pref) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
896 gaim_debug_error("prefs",
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
897 "gaim_prefs_get_string_list: Unknown pref %s\n", name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
898 return NULL;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
899 } else if(pref->type != GAIM_PREF_STRING_LIST) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
900 gaim_debug_error("prefs",
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
901 "gaim_prefs_get_string_list: %s not a string list pref\n", name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
902 return NULL;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
903 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
904
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
905 for(tmp = pref->value.stringlist; tmp; tmp = tmp->next)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
906 ret = g_list_append(ret, g_strdup(tmp->data));
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
907
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
908 return ret;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
909 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
910
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
911 void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
912 gaim_prefs_rename(const char *oldname, const char *newname)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
913 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
914 struct gaim_pref *oldpref, *newpref;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
915
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
916 oldpref = find_pref(oldname);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
917 newpref = find_pref(newname);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
918
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
919 /* it's already been renamed, call off the dogs */
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
920 if(!oldpref)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
921 return;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
922
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
923 gaim_debug_info("prefs", "Renaming %s to %s\n", oldname, newname);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
924
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
925 g_return_if_fail(newpref != NULL); /* the new one needs to be created first */
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
926 g_return_if_fail(oldpref->type == newpref->type);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
927 g_return_if_fail(oldpref->first_child == NULL); /* can't rename parents */
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
928
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
929 switch(oldpref->type) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
930 case GAIM_PREF_NONE:
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
931 break;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
932 case GAIM_PREF_BOOLEAN:
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
933 gaim_prefs_set_bool(newname, oldpref->value.boolean);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
934 break;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
935 case GAIM_PREF_INT:
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
936 gaim_prefs_set_int(newname, oldpref->value.integer);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
937 break;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
938 case GAIM_PREF_STRING:
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
939 gaim_prefs_set_string(newname, oldpref->value.string);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
940 break;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
941 case GAIM_PREF_STRING_LIST:
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
942 gaim_prefs_set_string_list(newname, oldpref->value.stringlist);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
943 break;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
944 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
945
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
946 remove_pref(oldpref);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
947 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
948
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
949 void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
950 gaim_prefs_rename_boolean_toggle(const char *oldname, const char *newname)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
951 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
952 struct gaim_pref *oldpref, *newpref;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
953
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
954 oldpref = find_pref(oldname);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
955 newpref = find_pref(newname);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
956
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
957 /* it's already been renamed, call off the cats */
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
958 if(!oldpref)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
959 return;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
960
11736
a14d72b6ca41 [gaim-migrate @ 14027]
Mark Doliner <mark@kingant.net>
parents: 11719
diff changeset
961 gaim_debug_info("prefs", "Renaming and toggling %s to %s\n", oldname, newname);
a14d72b6ca41 [gaim-migrate @ 14027]
Mark Doliner <mark@kingant.net>
parents: 11719
diff changeset
962
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
963 g_return_if_fail(newpref != NULL); /* the new one needs to be created */
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
964 g_return_if_fail(oldpref->type == newpref->type);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
965 g_return_if_fail(oldpref->type == GAIM_PREF_BOOLEAN);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
966 g_return_if_fail(oldpref->first_child == NULL); /* can't rename parents */
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
967
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
968 gaim_prefs_set_bool(newname, !(oldpref->value.boolean));
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
969
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
970 remove_pref(oldpref);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
971
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
972 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
973
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
974 guint
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
975 gaim_prefs_connect_callback(void *handle, const char *name, GaimPrefCallback func, gpointer data)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
976 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
977 struct gaim_pref *pref;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
978 struct pref_cb *cb;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
979 static guint cb_id = 0;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
980
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
981 pref = find_pref(name);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
982 if (pref == NULL)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
983 return 0;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
984
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
985 cb = g_new0(struct pref_cb, 1);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
986
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
987 cb->func = func;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
988 cb->data = data;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
989 cb->id = ++cb_id;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
990 cb->handle = handle;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
991
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
992 pref->callbacks = g_slist_append(pref->callbacks, cb);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
993
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
994 return cb->id;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
995 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
996
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
997 static gboolean
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
998 disco_callback_helper(struct gaim_pref *pref, guint callback_id)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
999 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1000 GSList *cbs;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1001 struct gaim_pref *child;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1002
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1003 if(!pref)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1004 return FALSE;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1005
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1006 for(cbs = pref->callbacks; cbs; cbs = cbs->next) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1007 struct pref_cb *cb = cbs->data;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1008 if(cb->id == callback_id) {
11719
109ee3bfeac5 [gaim-migrate @ 14010]
Richard Laager <rlaager@wiktel.com>
parents: 11698
diff changeset
1009 pref->callbacks = g_slist_delete_link(pref->callbacks, cbs);
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1010 g_free(cb);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1011 return TRUE;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1012 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1013 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1014
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1015 for(child = pref->first_child; child; child = child->sibling) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1016 if(disco_callback_helper(child, callback_id))
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1017 return TRUE;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1018 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1019
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1020 return FALSE;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1021 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1022
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1023 void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1024 gaim_prefs_disconnect_callback(guint callback_id)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1025 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1026 disco_callback_helper(&prefs, callback_id);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1027 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1028
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1029 static void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1030 disco_callback_helper_handle(struct gaim_pref *pref, void *handle)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1031 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1032 GSList *cbs;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1033 struct gaim_pref *child;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1034
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1035 if(!pref)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1036 return;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1037
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1038 cbs = pref->callbacks;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1039 while (cbs != NULL) {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1040 struct pref_cb *cb = cbs->data;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1041 if(cb->handle == handle) {
11719
109ee3bfeac5 [gaim-migrate @ 14010]
Richard Laager <rlaager@wiktel.com>
parents: 11698
diff changeset
1042 pref->callbacks = g_slist_delete_link(pref->callbacks, cbs);
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1043 g_free(cb);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1044 cbs = pref->callbacks;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1045 } else
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1046 cbs = cbs->next;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1047 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1048
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1049 for(child = pref->first_child; child; child = child->sibling)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1050 disco_callback_helper_handle(child, handle);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1051 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1052
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1053 void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1054 gaim_prefs_disconnect_by_handle(void *handle)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1055 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1056 g_return_if_fail(handle != NULL);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1057
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1058 disco_callback_helper_handle(&prefs, handle);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1059 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1060
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1061 void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1062 gaim_prefs_update_old()
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1063 {
8900
7a67c459ab8f [gaim-migrate @ 9669]
Mark Doliner <mark@kingant.net>
parents: 8705
diff changeset
1064 /* Remove some no-longer-used prefs */
9594
15d09e546cee [gaim-migrate @ 10437]
Mark Doliner <mark@kingant.net>
parents: 9251
diff changeset
1065 gaim_prefs_remove("/core/away/auto_response/enabled");
15d09e546cee [gaim-migrate @ 10437]
Mark Doliner <mark@kingant.net>
parents: 9251
diff changeset
1066 gaim_prefs_remove("/core/away/auto_response/idle_only");
8948
175cbf710a47 [gaim-migrate @ 9720]
Mark Doliner <mark@kingant.net>
parents: 8942
diff changeset
1067 gaim_prefs_remove("/core/away/auto_response/in_active_conv");
175cbf710a47 [gaim-migrate @ 9720]
Mark Doliner <mark@kingant.net>
parents: 8942
diff changeset
1068 gaim_prefs_remove("/core/away/auto_response/sec_before_resend");
9594
15d09e546cee [gaim-migrate @ 10437]
Mark Doliner <mark@kingant.net>
parents: 9251
diff changeset
1069 gaim_prefs_remove("/core/away/auto_response");
11654
bf6ba37db13b [gaim-migrate @ 13938]
Mark Doliner <mark@kingant.net>
parents: 11256
diff changeset
1070 gaim_prefs_remove("/core/away/default_message");
10353
fc7168f9ecb0 [gaim-migrate @ 11570]
Mark Doliner <mark@kingant.net>
parents: 10349
diff changeset
1071 gaim_prefs_remove("/core/buddies/use_server_alias");
8942
06f47021ddd3 [gaim-migrate @ 9712]
Mark Doliner <mark@kingant.net>
parents: 8905
diff changeset
1072 gaim_prefs_remove("/core/conversations/away_back_on_send");
8900
7a67c459ab8f [gaim-migrate @ 9669]
Mark Doliner <mark@kingant.net>
parents: 8705
diff changeset
1073 gaim_prefs_remove("/core/conversations/send_urls_as_links");
8942
06f47021ddd3 [gaim-migrate @ 9712]
Mark Doliner <mark@kingant.net>
parents: 8905
diff changeset
1074 gaim_prefs_remove("/core/conversations/im/show_login");
8998
3738d1eac0ad [gaim-migrate @ 9773]
Luke Schierer <lschiere@pidgin.im>
parents: 8948
diff changeset
1075 gaim_prefs_remove("/core/conversations/chat/show_join");
3738d1eac0ad [gaim-migrate @ 9773]
Luke Schierer <lschiere@pidgin.im>
parents: 8948
diff changeset
1076 gaim_prefs_remove("/core/conversations/chat/show_leave");
9251
45d2ad4ac1c1 [gaim-migrate @ 10050]
Ethan Blanton <elb@pidgin.im>
parents: 9156
diff changeset
1077 gaim_prefs_remove("/core/conversations/combine_chat_im");
10389
c432b927b0b1 [gaim-migrate @ 11616]
Sean Egan <seanegan@gmail.com>
parents: 10387
diff changeset
1078 gaim_prefs_remove("/core/conversations/use_alias_for_title");
11698
a647f92e1d57 [gaim-migrate @ 13989]
Mark Doliner <mark@kingant.net>
parents: 11654
diff changeset
1079 gaim_prefs_remove("/core/logging/log_signon_signoff");
a647f92e1d57 [gaim-migrate @ 13989]
Mark Doliner <mark@kingant.net>
parents: 11654
diff changeset
1080 gaim_prefs_remove("/core/logging/log_idle_state");
a647f92e1d57 [gaim-migrate @ 13989]
Mark Doliner <mark@kingant.net>
parents: 11654
diff changeset
1081 gaim_prefs_remove("/core/logging/log_away_state");
a647f92e1d57 [gaim-migrate @ 13989]
Mark Doliner <mark@kingant.net>
parents: 11654
diff changeset
1082 gaim_prefs_remove("/core/logging/log_own_states");
13040
b705e30efe61 [gaim-migrate @ 15399]
Richard Laager <rlaager@wiktel.com>
parents: 12822
diff changeset
1083 gaim_prefs_remove("/core/status/scores/hidden");
11959
6f8869d95c09 [gaim-migrate @ 14250]
Mark Doliner <mark@kingant.net>
parents: 11736
diff changeset
1084 gaim_prefs_remove("/plugins/core/autorecon/hide_connected_error");
6f8869d95c09 [gaim-migrate @ 14250]
Mark Doliner <mark@kingant.net>
parents: 11736
diff changeset
1085 gaim_prefs_remove("/plugins/core/autorecon/hide_connecting_error");
6f8869d95c09 [gaim-migrate @ 14250]
Mark Doliner <mark@kingant.net>
parents: 11736
diff changeset
1086 gaim_prefs_remove("/plugins/core/autorecon/hide_reconnecting_dialog");
6f8869d95c09 [gaim-migrate @ 14250]
Mark Doliner <mark@kingant.net>
parents: 11736
diff changeset
1087 gaim_prefs_remove("/plugins/core/autorecon/restore_state");
6f8869d95c09 [gaim-migrate @ 14250]
Mark Doliner <mark@kingant.net>
parents: 11736
diff changeset
1088 gaim_prefs_remove("/plugins/core/autorecon");
8900
7a67c459ab8f [gaim-migrate @ 9669]
Mark Doliner <mark@kingant.net>
parents: 8705
diff changeset
1089 }
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1090
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1091 void *
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1092 gaim_prefs_get_handle(void)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1093 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1094 static int handle;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1095
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1096 return &handle;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1097 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1098
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1099 void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1100 gaim_prefs_init(void)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1101 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1102 void *handle = gaim_prefs_get_handle();
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1103
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1104 prefs_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1105
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1106 gaim_prefs_connect_callback(handle, "/", prefs_save_cb, NULL);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1107
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1108 gaim_prefs_add_none("/core");
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1109 gaim_prefs_add_none("/plugins");
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1110 gaim_prefs_add_none("/plugins/core");
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1111 gaim_prefs_add_none("/plugins/lopl");
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1112 gaim_prefs_add_none("/plugins/prpl");
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1113
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1114 /* Away */
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1115 gaim_prefs_add_none("/core/away");
12573
200f22ca4890 [gaim-migrate @ 14895]
Mark Doliner <mark@kingant.net>
parents: 12272
diff changeset
1116 gaim_prefs_add_string("/core/away/idle_reporting", "system");
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1117 gaim_prefs_add_bool("/core/away/away_when_idle", TRUE);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1118 gaim_prefs_add_int("/core/away/mins_before_away", 5);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1119
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1120 /* Away -> Auto-Reply */
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1121 if (!gaim_prefs_exists("/core/away/auto_response/enabled") ||
12615
e3ca84a8b551 [gaim-migrate @ 14951]
Richard Laager <rlaager@wiktel.com>
parents: 12599
diff changeset
1122 !gaim_prefs_exists("/core/away/auto_response/idle_only"))
e3ca84a8b551 [gaim-migrate @ 14951]
Richard Laager <rlaager@wiktel.com>
parents: 12599
diff changeset
1123 {
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1124 gaim_prefs_add_string("/core/away/auto_reply", "awayidle");
12615
e3ca84a8b551 [gaim-migrate @ 14951]
Richard Laager <rlaager@wiktel.com>
parents: 12599
diff changeset
1125 }
e3ca84a8b551 [gaim-migrate @ 14951]
Richard Laager <rlaager@wiktel.com>
parents: 12599
diff changeset
1126 else
e3ca84a8b551 [gaim-migrate @ 14951]
Richard Laager <rlaager@wiktel.com>
parents: 12599
diff changeset
1127 {
e3ca84a8b551 [gaim-migrate @ 14951]
Richard Laager <rlaager@wiktel.com>
parents: 12599
diff changeset
1128 if (!gaim_prefs_get_bool("/core/away/auto_response/enabled"))
e3ca84a8b551 [gaim-migrate @ 14951]
Richard Laager <rlaager@wiktel.com>
parents: 12599
diff changeset
1129 {
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1130 gaim_prefs_add_string("/core/away/auto_reply", "never");
12615
e3ca84a8b551 [gaim-migrate @ 14951]
Richard Laager <rlaager@wiktel.com>
parents: 12599
diff changeset
1131 }
e3ca84a8b551 [gaim-migrate @ 14951]
Richard Laager <rlaager@wiktel.com>
parents: 12599
diff changeset
1132 else
e3ca84a8b551 [gaim-migrate @ 14951]
Richard Laager <rlaager@wiktel.com>
parents: 12599
diff changeset
1133 {
e3ca84a8b551 [gaim-migrate @ 14951]
Richard Laager <rlaager@wiktel.com>
parents: 12599
diff changeset
1134 if (gaim_prefs_get_bool("/core/away/auto_response/idle_only"))
e3ca84a8b551 [gaim-migrate @ 14951]
Richard Laager <rlaager@wiktel.com>
parents: 12599
diff changeset
1135 {
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1136 gaim_prefs_add_string("/core/away/auto_reply", "awayidle");
12615
e3ca84a8b551 [gaim-migrate @ 14951]
Richard Laager <rlaager@wiktel.com>
parents: 12599
diff changeset
1137 }
e3ca84a8b551 [gaim-migrate @ 14951]
Richard Laager <rlaager@wiktel.com>
parents: 12599
diff changeset
1138 else
e3ca84a8b551 [gaim-migrate @ 14951]
Richard Laager <rlaager@wiktel.com>
parents: 12599
diff changeset
1139 {
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1140 gaim_prefs_add_string("/core/away/auto_reply", "away");
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1141 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1142 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1143 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1144
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1145 /* Buddies */
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1146 gaim_prefs_add_none("/core/buddies");
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1147
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1148 /* Contact Priority Settings */
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1149 gaim_prefs_add_none("/core/contact");
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1150 gaim_prefs_add_bool("/core/contact/last_match", FALSE);
12164
281ab2ecc08c [gaim-migrate @ 14465]
Richard Laager <rlaager@wiktel.com>
parents: 11959
diff changeset
1151 gaim_prefs_remove("/core/contact/offline_score");
281ab2ecc08c [gaim-migrate @ 14465]
Richard Laager <rlaager@wiktel.com>
parents: 11959
diff changeset
1152 gaim_prefs_remove("/core/contact/away_score");
281ab2ecc08c [gaim-migrate @ 14465]
Richard Laager <rlaager@wiktel.com>
parents: 11959
diff changeset
1153 gaim_prefs_remove("/core/contact/idle_score");
10443
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1154 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1155
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1156 void
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1157 gaim_prefs_uninit()
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1158 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1159 if (save_timer != 0)
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1160 {
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1161 gaim_timeout_remove(save_timer);
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1162 save_timer = 0;
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1163 sync_prefs();
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1164 }
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1165
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1166 gaim_prefs_disconnect_by_handle(gaim_prefs_get_handle());
b6ca0e1b19d0 [gaim-migrate @ 11703]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1167 }