Wed, 10 Jan 2007 03:47:57 +0000
[gaim-migrate @ 18099]
do utf8 validation on string and string list prefs
add new path and path list pref types
these aren't used yet...we need to audit our prefs, and replace as appropriate, but I'm too tired to do that tonight
| 5441 | 1 | /** |
| 2 | * @file prefs.h Prefs API | |
|
10066
606927534c36
[gaim-migrate @ 11041]
Mark Doliner <markdoliner@pidgin.im>
parents:
9713
diff
changeset
|
3 | * @ingroup core |
| 5441 | 4 | * |
| 5 | * gaim | |
| 6 | * | |
| 8046 | 7 | * Gaim is the legal property of its developers, whose names are too numerous |
| 8 | * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 9 | * source distribution. | |
| 5441 | 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify | |
| 12 | * it under the terms of the GNU General Public License as published by | |
| 13 | * the Free Software Foundation; either version 2 of the License, or | |
| 14 | * (at your option) any later version. | |
| 15 | * | |
| 16 | * This program is distributed in the hope that it will be useful, | |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 | * GNU General Public License for more details. | |
| 20 | * | |
| 21 | * You should have received a copy of the GNU General Public License | |
| 22 | * along with this program; if not, write to the Free Software | |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 24 | * | |
| 25 | */ | |
|
9713
bb37562302a1
[gaim-migrate @ 10574]
Mark Doliner <markdoliner@pidgin.im>
parents:
9619
diff
changeset
|
26 | #ifndef _GAIM_PREFS_H_ |
|
bb37562302a1
[gaim-migrate @ 10574]
Mark Doliner <markdoliner@pidgin.im>
parents:
9619
diff
changeset
|
27 | #define _GAIM_PREFS_H_ |
| 5441 | 28 | |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5561
diff
changeset
|
29 | #include <glib.h> |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5561
diff
changeset
|
30 | |
| 5441 | 31 | /** |
| 32 | * Pref data types. | |
| 33 | */ | |
| 34 | typedef enum _GaimPrefType | |
| 35 | { | |
| 36 | GAIM_PREF_NONE, | |
| 37 | GAIM_PREF_BOOLEAN, | |
| 38 | GAIM_PREF_INT, | |
| 5561 | 39 | GAIM_PREF_STRING, |
| 15370 | 40 | GAIM_PREF_STRING_LIST, |
| 41 | GAIM_PREF_PATH, | |
| 42 | GAIM_PREF_PATH_LIST | |
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
43 | |
| 5441 | 44 | } GaimPrefType; |
| 45 | ||
| 46 | /** | |
| 47 | * Pref change callback type | |
| 48 | */ | |
| 49 | ||
| 50 | typedef void (*GaimPrefCallback) (const char *name, GaimPrefType type, | |
|
12816
5f93e09fa9a6
[gaim-migrate @ 15164]
Mark Doliner <markdoliner@pidgin.im>
parents:
12712
diff
changeset
|
51 | gconstpointer val, gpointer data); |
| 5441 | 52 | |
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
53 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
54 | extern "C" { |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
55 | #endif |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
56 | |
| 5441 | 57 | /**************************************************************************/ |
| 58 | /** @name Prefs API */ | |
| 59 | /**************************************************************************/ | |
| 60 | /*@{*/ | |
| 61 | ||
| 62 | /** | |
|
10443
aa7dcc1c796a
[gaim-migrate @ 11703]
Mark Doliner <markdoliner@pidgin.im>
parents:
10087
diff
changeset
|
63 | * Returns the prefs subsystem handle. |
|
aa7dcc1c796a
[gaim-migrate @ 11703]
Mark Doliner <markdoliner@pidgin.im>
parents:
10087
diff
changeset
|
64 | * |
|
aa7dcc1c796a
[gaim-migrate @ 11703]
Mark Doliner <markdoliner@pidgin.im>
parents:
10087
diff
changeset
|
65 | * @return The prefs subsystem handle. |
|
aa7dcc1c796a
[gaim-migrate @ 11703]
Mark Doliner <markdoliner@pidgin.im>
parents:
10087
diff
changeset
|
66 | */ |
|
aa7dcc1c796a
[gaim-migrate @ 11703]
Mark Doliner <markdoliner@pidgin.im>
parents:
10087
diff
changeset
|
67 | void *gaim_prefs_get_handle(void); |
|
aa7dcc1c796a
[gaim-migrate @ 11703]
Mark Doliner <markdoliner@pidgin.im>
parents:
10087
diff
changeset
|
68 | |
|
aa7dcc1c796a
[gaim-migrate @ 11703]
Mark Doliner <markdoliner@pidgin.im>
parents:
10087
diff
changeset
|
69 | /** |
| 5441 | 70 | * Initialize core prefs |
| 71 | */ | |
|
12323
f52908fb23b0
[gaim-migrate @ 14627]
Richard Laager <rlaager@pidgin.im>
parents:
10443
diff
changeset
|
72 | void gaim_prefs_init(void); |
| 5441 | 73 | |
| 74 | /** | |
| 8235 | 75 | * Uninitializes the prefs subsystem. |
| 76 | */ | |
| 77 | void gaim_prefs_uninit(void); | |
| 78 | ||
| 79 | /** | |
| 5441 | 80 | * Add a new typeless pref. |
| 81 | * | |
| 82 | * @param name The name of the pref | |
| 83 | */ | |
| 84 | void gaim_prefs_add_none(const char *name); | |
| 85 | ||
| 86 | /** | |
| 87 | * Add a new boolean pref. | |
| 88 | * | |
| 89 | * @param name The name of the pref | |
| 90 | * @param value The initial value to set | |
| 91 | */ | |
| 92 | void gaim_prefs_add_bool(const char *name, gboolean value); | |
| 93 | ||
| 94 | /** | |
| 95 | * Add a new integer pref. | |
| 96 | * | |
| 97 | * @param name The name of the pref | |
| 98 | * @param value The initial value to set | |
| 99 | */ | |
| 100 | void gaim_prefs_add_int(const char *name, int value); | |
| 101 | ||
| 102 | /** | |
| 103 | * Add a new string pref. | |
| 104 | * | |
| 105 | * @param name The name of the pref | |
| 106 | * @param value The initial value to set | |
| 107 | */ | |
| 108 | void gaim_prefs_add_string(const char *name, const char *value); | |
| 109 | ||
| 110 | /** | |
| 5561 | 111 | * Add a new string list pref. |
| 112 | * | |
| 113 | * @param name The name of the pref | |
| 114 | * @param value The initial value to set | |
| 115 | */ | |
| 116 | void gaim_prefs_add_string_list(const char *name, GList *value); | |
| 117 | ||
| 118 | /** | |
| 15370 | 119 | * Add a new path pref. |
| 120 | * | |
| 121 | * @param name The name of the pref | |
| 122 | * @param value The initial value to set | |
| 123 | */ | |
| 124 | void gaim_prefs_add_path(const char *name, const char *value); | |
| 125 | ||
| 126 | /** | |
| 127 | * Add a new path list pref. | |
| 128 | * | |
| 129 | * @param name The name of the pref | |
| 130 | * @param value The initial value to set | |
| 131 | */ | |
| 132 | void gaim_prefs_add_path_list(const char *name, GList *value); | |
| 133 | ||
| 134 | ||
| 135 | /** | |
| 5441 | 136 | * Remove a pref. |
| 137 | * | |
| 138 | * @param name The name of the pref | |
| 139 | */ | |
| 140 | void gaim_prefs_remove(const char *name); | |
| 141 | ||
| 142 | /** | |
| 6693 | 143 | * Rename a pref |
| 144 | * | |
| 145 | * @param oldname The old name of the pref | |
| 146 | * @param newname The new name for the pref | |
| 147 | */ | |
| 148 | void gaim_prefs_rename(const char *oldname, const char *newname); | |
| 149 | ||
| 150 | /** | |
| 8705 | 151 | * Rename a boolean pref, toggling it's value |
| 152 | * | |
| 153 | * @param oldname The old name of the pref | |
| 154 | * @param newname The new name for the pref | |
| 155 | */ | |
| 156 | void gaim_prefs_rename_boolean_toggle(const char *oldname, const char *newname); | |
| 157 | ||
| 158 | /** | |
| 5441 | 159 | * Remove all prefs. |
| 160 | */ | |
|
12323
f52908fb23b0
[gaim-migrate @ 14627]
Richard Laager <rlaager@pidgin.im>
parents:
10443
diff
changeset
|
161 | void gaim_prefs_destroy(void); |
| 5441 | 162 | |
| 163 | /** | |
| 164 | * Set raw pref value | |
| 165 | * | |
| 166 | * @param name The name of the pref | |
| 167 | * @param value The value to set | |
| 168 | */ | |
| 169 | void gaim_prefs_set_generic(const char *name, gpointer value); | |
| 170 | ||
| 171 | /** | |
| 172 | * Set boolean pref value | |
| 173 | * | |
| 174 | * @param name The name of the pref | |
| 175 | * @param value The value to set | |
| 176 | */ | |
| 177 | void gaim_prefs_set_bool(const char *name, gboolean value); | |
| 178 | ||
| 179 | /** | |
| 180 | * Set integer pref value | |
| 181 | * | |
| 182 | * @param name The name of the pref | |
| 183 | * @param value The value to set | |
| 184 | */ | |
| 185 | void gaim_prefs_set_int(const char *name, int value); | |
| 186 | ||
| 187 | /** | |
| 188 | * Set string pref value | |
| 189 | * | |
| 190 | * @param name The name of the pref | |
| 191 | * @param value The value to set | |
| 192 | */ | |
| 5451 | 193 | void gaim_prefs_set_string(const char *name, const char *value); |
| 5441 | 194 | |
| 195 | /** | |
| 15370 | 196 | * Set string list pref value |
| 5561 | 197 | * |
| 198 | * @param name The name of the pref | |
| 199 | * @param value The value to set | |
| 200 | */ | |
| 201 | void gaim_prefs_set_string_list(const char *name, GList *value); | |
| 202 | ||
| 203 | /** | |
| 15370 | 204 | * Set path pref value |
| 205 | * | |
| 206 | * @param name The name of the pref | |
| 207 | * @param value The value to set | |
| 208 | */ | |
| 209 | void gaim_prefs_set_path(const char *name, const char *value); | |
| 210 | ||
| 211 | /** | |
| 212 | * Set path list pref value | |
| 213 | * | |
| 214 | * @param name The name of the pref | |
| 215 | * @param value The value to set | |
| 216 | */ | |
| 217 | void gaim_prefs_set_path_list(const char *name, GList *value); | |
| 218 | ||
| 219 | ||
| 220 | /** | |
| 9611 | 221 | * Check if a pref exists |
| 222 | * | |
|
9619
2d8adb92f665
[gaim-migrate @ 10463]
Mark Doliner <markdoliner@pidgin.im>
parents:
9611
diff
changeset
|
223 | * @param name The name of the pref |
|
2d8adb92f665
[gaim-migrate @ 10463]
Mark Doliner <markdoliner@pidgin.im>
parents:
9611
diff
changeset
|
224 | * @return TRUE if the pref exists. Otherwise FALSE. |
| 9611 | 225 | */ |
| 226 | gboolean gaim_prefs_exists(const char *name); | |
| 227 | ||
| 228 | /** | |
| 6538 | 229 | * Get pref type |
| 230 | * | |
| 231 | * @param name The name of the pref | |
| 232 | * @return The type of the pref | |
| 233 | */ | |
| 234 | GaimPrefType gaim_prefs_get_type(const char *name); | |
| 235 | ||
| 236 | /** | |
| 5441 | 237 | * Get boolean pref value |
| 238 | * | |
| 239 | * @param name The name of the pref | |
| 240 | * @return The value of the pref | |
| 241 | */ | |
| 242 | gboolean gaim_prefs_get_bool(const char *name); | |
| 243 | ||
| 244 | /** | |
| 245 | * Get integer pref value | |
| 246 | * | |
| 247 | * @param name The name of the pref | |
| 248 | * @return The value of the pref | |
| 249 | */ | |
| 250 | int gaim_prefs_get_int(const char *name); | |
| 251 | ||
| 252 | /** | |
| 253 | * Get string pref value | |
| 254 | * | |
| 255 | * @param name The name of the pref | |
| 256 | * @return The value of the pref | |
| 257 | */ | |
|
5545
a8b1a1262402
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5534
diff
changeset
|
258 | const char *gaim_prefs_get_string(const char *name); |
| 5441 | 259 | |
| 260 | /** | |
|
10071
d2ba11541693
[gaim-migrate @ 11047]
Jonathan Champ <royanee@users.sourceforge.net>
parents:
10066
diff
changeset
|
261 | * Get string list pref value |
| 5561 | 262 | * |
| 263 | * @param name The name of the pref | |
| 264 | * @return The value of the pref | |
| 265 | */ | |
| 266 | GList *gaim_prefs_get_string_list(const char *name); | |
| 267 | ||
| 268 | /** | |
| 15370 | 269 | * Get path pref value |
| 270 | * | |
| 271 | * @param name The name of the pref | |
| 272 | * @return The value of the pref | |
| 273 | */ | |
| 274 | const char *gaim_prefs_get_path(const char *name); | |
| 275 | ||
| 276 | /** | |
| 277 | * Get path list pref value | |
| 278 | * | |
| 279 | * @param name The name of the pref | |
| 280 | * @return The value of the pref | |
| 281 | */ | |
| 282 | GList *gaim_prefs_get_path_list(const char *name); | |
| 283 | ||
| 284 | ||
| 285 | /** | |
| 5441 | 286 | * Add a callback to a pref (and its children) |
| 287 | */ | |
|
10087
e5b80a38939d
[gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10071
diff
changeset
|
288 | guint gaim_prefs_connect_callback(void *handle, const char *name, GaimPrefCallback cb, |
| 5441 | 289 | gpointer data); |
| 290 | ||
| 291 | /** | |
| 292 | * Remove a callback to a pref | |
| 293 | */ | |
| 294 | void gaim_prefs_disconnect_callback(guint callback_id); | |
| 295 | ||
| 296 | /** | |
|
10087
e5b80a38939d
[gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10071
diff
changeset
|
297 | * Remove all pref callbacks by handle |
|
e5b80a38939d
[gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10071
diff
changeset
|
298 | */ |
|
e5b80a38939d
[gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10071
diff
changeset
|
299 | void gaim_prefs_disconnect_by_handle(void *handle); |
|
e5b80a38939d
[gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10071
diff
changeset
|
300 | |
|
e5b80a38939d
[gaim-migrate @ 11098]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10071
diff
changeset
|
301 | /** |
| 5684 | 302 | * Trigger callbacks as if the pref changed |
| 303 | */ | |
| 304 | void gaim_prefs_trigger_callback(const char *name); | |
| 305 | ||
| 306 | /** | |
| 5441 | 307 | * Read preferences |
| 308 | */ | |
|
12323
f52908fb23b0
[gaim-migrate @ 14627]
Richard Laager <rlaager@pidgin.im>
parents:
10443
diff
changeset
|
309 | gboolean gaim_prefs_load(void); |
| 5441 | 310 | |
| 311 | /** | |
|
8900
14f4b7ae958e
[gaim-migrate @ 9669]
Mark Doliner <markdoliner@pidgin.im>
parents:
8705
diff
changeset
|
312 | * Rename legacy prefs and delete some that no longer exist. |
|
14f4b7ae958e
[gaim-migrate @ 9669]
Mark Doliner <markdoliner@pidgin.im>
parents:
8705
diff
changeset
|
313 | */ |
|
12323
f52908fb23b0
[gaim-migrate @ 14627]
Richard Laager <rlaager@pidgin.im>
parents:
10443
diff
changeset
|
314 | void gaim_prefs_update_old(void); |
|
8900
14f4b7ae958e
[gaim-migrate @ 9669]
Mark Doliner <markdoliner@pidgin.im>
parents:
8705
diff
changeset
|
315 | |
| 5441 | 316 | /*@}*/ |
| 317 | ||
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
318 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
319 | } |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
320 | #endif |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5684
diff
changeset
|
321 | |
|
9713
bb37562302a1
[gaim-migrate @ 10574]
Mark Doliner <markdoliner@pidgin.im>
parents:
9619
diff
changeset
|
322 | #endif /* _GAIM_PREFS_H_ */ |