annotate src/accountopt.c @ 6577:ea785d055825

[gaim-migrate @ 7099] value.c added committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Fri, 22 Aug 2003 21:09:38 +0000
parents e9551e7d6f01
children e30bedfb99db
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /**
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * @file accountopt.c Account Options API
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 * @ingroup core
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 * gaim
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
7 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org>
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
8 *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * (at your option) any later version.
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * GNU General Public License for more details.
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 */
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 #include "accountopt.h"
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 GaimAccountOption *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26 gaim_account_option_new(GaimPrefType type, const char *text,
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 const char *pref_name)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 GaimAccountOption *option;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 g_return_val_if_fail(type == GAIM_PREF_BOOLEAN ||
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32 type == GAIM_PREF_INT ||
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33 type == GAIM_PREF_STRING,
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34 NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35 g_return_val_if_fail(text != NULL, NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 g_return_val_if_fail(pref_name != NULL, NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38 option = g_new0(GaimAccountOption, 1);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40 option->type = type;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 option->text = g_strdup(text);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 option->pref_name = g_strdup(pref_name);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 return option;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47 GaimAccountOption *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 gaim_account_option_bool_new(const char *text, const char *pref_name,
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 gboolean default_value)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 GaimAccountOption *option;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 option = gaim_account_option_new(GAIM_PREF_BOOLEAN, text, pref_name);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 if (option == NULL)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 return NULL;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 option->default_value.boolean = default_value;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60 return option;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 GaimAccountOption *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 gaim_account_option_int_new(const char *text, const char *pref_name,
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 int default_value)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 GaimAccountOption *option;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 option = gaim_account_option_new(GAIM_PREF_INT, text, pref_name);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 if (option == NULL)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 return NULL;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 option->default_value.integer = default_value;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76 return option;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 GaimAccountOption *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 gaim_account_option_string_new(const char *text, const char *pref_name,
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 const char *default_value)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 GaimAccountOption *option;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 option = gaim_account_option_new(GAIM_PREF_STRING, text, pref_name);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 if (option == NULL)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 return NULL;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 if (default_value != NULL)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 option->default_value.string = g_strdup(default_value);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 return option;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 void
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 gaim_account_option_destroy(GaimAccountOption *option)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 g_return_if_fail(option != NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101 if (option->text != NULL)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102 g_free(option->text);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
103
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
104 if (option->pref_name != NULL)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
105 g_free(option->pref_name);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
106
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
107 if (option->type == GAIM_PREF_STRING &&
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
108 option->default_value.string != NULL) {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
109
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
110 g_free(option->default_value.string);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
111 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 g_free(option);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116 void
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 gaim_account_option_set_default_bool(GaimAccountOption *option,
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118 gboolean value)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 g_return_if_fail(option != NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 g_return_if_fail(option->type == GAIM_PREF_BOOLEAN);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
123 option->default_value.boolean = value;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
124 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
125
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
126 void
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
127 gaim_account_option_set_default_int(GaimAccountOption *option, int value)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
128 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
129 g_return_if_fail(option != NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
130 g_return_if_fail(option->type == GAIM_PREF_INT);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
131
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
132 option->default_value.integer = value;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
133 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
134
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 void
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136 gaim_account_option_set_default_string(GaimAccountOption *option,
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 const char *value)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139 g_return_if_fail(option != NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 g_return_if_fail(option->type == GAIM_PREF_STRING);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 if (option->default_value.string != NULL)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 g_free(option->default_value.string);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 option->default_value.string = (value == NULL ? NULL : g_strdup(value));
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148 GaimPrefType
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149 gaim_account_option_get_type(const GaimAccountOption *option)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 g_return_val_if_fail(option != NULL, GAIM_PREF_NONE);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153 return option->type;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 const char *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 gaim_account_option_get_text(const GaimAccountOption *option)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 g_return_val_if_fail(option != NULL, NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 return option->text;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163
5660
1709a545a7bd [gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents: 5654
diff changeset
164 const char *
1709a545a7bd [gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents: 5654
diff changeset
165 gaim_account_option_get_setting(const GaimAccountOption *option)
1709a545a7bd [gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents: 5654
diff changeset
166 {
1709a545a7bd [gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents: 5654
diff changeset
167 g_return_val_if_fail(option != NULL, NULL);
1709a545a7bd [gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents: 5654
diff changeset
168
1709a545a7bd [gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents: 5654
diff changeset
169 return option->pref_name;
1709a545a7bd [gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents: 5654
diff changeset
170 }
1709a545a7bd [gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents: 5654
diff changeset
171
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
172 gboolean
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
173 gaim_account_option_get_default_bool(const GaimAccountOption *option)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
174 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
175 g_return_val_if_fail(option != NULL, FALSE);
5663
e9551e7d6f01 [gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents: 5660
diff changeset
176 g_return_val_if_fail(option->type == GAIM_PREF_BOOLEAN, FALSE);
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
177
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
178 return option->default_value.boolean;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
179 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
180
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
181 int
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
182 gaim_account_option_get_default_int(const GaimAccountOption *option)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
183 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
184 g_return_val_if_fail(option != NULL, -1);
5663
e9551e7d6f01 [gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents: 5660
diff changeset
185 g_return_val_if_fail(option->type == GAIM_PREF_INT, -1);
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
186
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
187 return option->default_value.integer;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
188 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
189
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
190 const char *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
191 gaim_account_option_get_default_string(const GaimAccountOption *option)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
192 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
193 g_return_val_if_fail(option != NULL, NULL);
5663
e9551e7d6f01 [gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents: 5660
diff changeset
194 g_return_val_if_fail(option->type == GAIM_PREF_STRING, NULL);
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
195
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
196 return option->default_value.string;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
197 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
198
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
199
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
200 GaimAccountUserSplit *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
201 gaim_account_user_split_new(const char *text, const char *default_value,
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
202 char sep)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
203 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
204 GaimAccountUserSplit *split;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
205
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
206 g_return_val_if_fail(text != NULL, NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
207 g_return_val_if_fail(sep != 0, NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
208
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
209 split = g_new0(GaimAccountUserSplit, 1);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
210
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
211 split->text = g_strdup(text);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
212 split->field_sep = sep;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
213 split->default_value = (default_value == NULL
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
214 ? NULL : g_strdup(default_value));
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
215
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216 return split;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219 void
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220 gaim_account_user_split_destroy(GaimAccountUserSplit *split)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 g_return_if_fail(split != NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 if (split->text != NULL)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 g_free(split->text);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227 if (split->default_value != NULL)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228 g_free(split->default_value);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230 g_free(split);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
232
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
233 const char *
5654
c52a97f3739e [gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents: 5639
diff changeset
234 gaim_account_user_split_get_text(const GaimAccountUserSplit *split)
c52a97f3739e [gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents: 5639
diff changeset
235 {
c52a97f3739e [gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents: 5639
diff changeset
236 g_return_val_if_fail(split != NULL, NULL);
c52a97f3739e [gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents: 5639
diff changeset
237
c52a97f3739e [gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents: 5639
diff changeset
238 return split->text;
c52a97f3739e [gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents: 5639
diff changeset
239 }
c52a97f3739e [gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents: 5639
diff changeset
240
c52a97f3739e [gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents: 5639
diff changeset
241 const char *
c52a97f3739e [gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents: 5639
diff changeset
242 gaim_account_user_split_get_default_value(const GaimAccountUserSplit *split)
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
244 g_return_val_if_fail(split != NULL, NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246 return split->default_value;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
248
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249 char
5654
c52a97f3739e [gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents: 5639
diff changeset
250 gaim_account_user_split_get_separator(const GaimAccountUserSplit *split)
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252 g_return_val_if_fail(split != NULL, 0);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
253
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
254 return split->field_sep;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
255 }