Mercurial > pidgin
annotate src/accountopt.c @ 8150:20262ccefdd8
[gaim-migrate @ 8862]
Nope, it's humor. Trust me, I know--I define it.
Oh, also, this should make oscar ssi lists take precedence over
local lists. So if you sign on while you're in Rome and delete
someone, the next time you sign in with Gaim the dude will be
deleted from your local list as well.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 20 Jan 2004 15:27:33 +0000 |
parents | fa6395637e2c |
children | 1a62ab7225f3 |
rev | line source |
---|---|
5639 | 1 /** |
2 * @file accountopt.c Account Options API | |
3 * @ingroup core | |
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. | |
6902
e30bedfb99db
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
10 * |
5639 | 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 #include "accountopt.h" | |
26 | |
27 GaimAccountOption * | |
28 gaim_account_option_new(GaimPrefType type, const char *text, | |
29 const char *pref_name) | |
30 { | |
31 GaimAccountOption *option; | |
32 | |
33 g_return_val_if_fail(type == GAIM_PREF_BOOLEAN || | |
34 type == GAIM_PREF_INT || | |
35 type == GAIM_PREF_STRING, | |
36 NULL); | |
37 g_return_val_if_fail(text != NULL, NULL); | |
38 g_return_val_if_fail(pref_name != NULL, NULL); | |
39 | |
40 option = g_new0(GaimAccountOption, 1); | |
41 | |
42 option->type = type; | |
43 option->text = g_strdup(text); | |
44 option->pref_name = g_strdup(pref_name); | |
45 | |
46 return option; | |
47 } | |
48 | |
49 GaimAccountOption * | |
50 gaim_account_option_bool_new(const char *text, const char *pref_name, | |
51 gboolean default_value) | |
52 { | |
53 GaimAccountOption *option; | |
6902
e30bedfb99db
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
54 |
5639 | 55 option = gaim_account_option_new(GAIM_PREF_BOOLEAN, text, pref_name); |
56 | |
57 if (option == NULL) | |
58 return NULL; | |
59 | |
60 option->default_value.boolean = default_value; | |
61 | |
62 return option; | |
63 } | |
64 | |
65 GaimAccountOption * | |
66 gaim_account_option_int_new(const char *text, const char *pref_name, | |
67 int default_value) | |
68 { | |
69 GaimAccountOption *option; | |
6902
e30bedfb99db
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
70 |
5639 | 71 option = gaim_account_option_new(GAIM_PREF_INT, text, pref_name); |
72 | |
73 if (option == NULL) | |
74 return NULL; | |
75 | |
76 option->default_value.integer = default_value; | |
77 | |
78 return option; | |
79 } | |
80 | |
81 GaimAccountOption * | |
82 gaim_account_option_string_new(const char *text, const char *pref_name, | |
83 const char *default_value) | |
84 { | |
85 GaimAccountOption *option; | |
6902
e30bedfb99db
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
86 |
5639 | 87 option = gaim_account_option_new(GAIM_PREF_STRING, text, pref_name); |
88 | |
89 if (option == NULL) | |
90 return NULL; | |
91 | |
92 if (default_value != NULL) | |
93 option->default_value.string = g_strdup(default_value); | |
94 | |
95 return option; | |
96 } | |
97 | |
98 void | |
99 gaim_account_option_destroy(GaimAccountOption *option) | |
100 { | |
101 g_return_if_fail(option != NULL); | |
102 | |
103 if (option->text != NULL) | |
104 g_free(option->text); | |
105 | |
106 if (option->pref_name != NULL) | |
107 g_free(option->pref_name); | |
108 | |
109 if (option->type == GAIM_PREF_STRING && | |
110 option->default_value.string != NULL) { | |
111 | |
112 g_free(option->default_value.string); | |
113 } | |
114 | |
115 g_free(option); | |
116 } | |
117 | |
118 void | |
119 gaim_account_option_set_default_bool(GaimAccountOption *option, | |
120 gboolean value) | |
121 { | |
122 g_return_if_fail(option != NULL); | |
123 g_return_if_fail(option->type == GAIM_PREF_BOOLEAN); | |
124 | |
125 option->default_value.boolean = value; | |
126 } | |
127 | |
128 void | |
129 gaim_account_option_set_default_int(GaimAccountOption *option, int value) | |
130 { | |
131 g_return_if_fail(option != NULL); | |
132 g_return_if_fail(option->type == GAIM_PREF_INT); | |
133 | |
134 option->default_value.integer = value; | |
135 } | |
136 | |
137 void | |
138 gaim_account_option_set_default_string(GaimAccountOption *option, | |
139 const char *value) | |
140 { | |
141 g_return_if_fail(option != NULL); | |
142 g_return_if_fail(option->type == GAIM_PREF_STRING); | |
143 | |
144 if (option->default_value.string != NULL) | |
145 g_free(option->default_value.string); | |
146 | |
147 option->default_value.string = (value == NULL ? NULL : g_strdup(value)); | |
148 } | |
149 | |
150 GaimPrefType | |
151 gaim_account_option_get_type(const GaimAccountOption *option) | |
152 { | |
153 g_return_val_if_fail(option != NULL, GAIM_PREF_NONE); | |
154 | |
155 return option->type; | |
156 } | |
157 | |
158 const char * | |
159 gaim_account_option_get_text(const GaimAccountOption *option) | |
160 { | |
161 g_return_val_if_fail(option != NULL, NULL); | |
162 | |
163 return option->text; | |
164 } | |
165 | |
5660
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
166 const char * |
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
167 gaim_account_option_get_setting(const GaimAccountOption *option) |
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 g_return_val_if_fail(option != NULL, NULL); |
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 return option->pref_name; |
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
172 } |
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
173 |
5639 | 174 gboolean |
175 gaim_account_option_get_default_bool(const GaimAccountOption *option) | |
176 { | |
177 g_return_val_if_fail(option != NULL, FALSE); | |
5663
e9551e7d6f01
[gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents:
5660
diff
changeset
|
178 g_return_val_if_fail(option->type == GAIM_PREF_BOOLEAN, FALSE); |
5639 | 179 |
180 return option->default_value.boolean; | |
181 } | |
182 | |
183 int | |
184 gaim_account_option_get_default_int(const GaimAccountOption *option) | |
185 { | |
186 g_return_val_if_fail(option != NULL, -1); | |
5663
e9551e7d6f01
[gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents:
5660
diff
changeset
|
187 g_return_val_if_fail(option->type == GAIM_PREF_INT, -1); |
5639 | 188 |
189 return option->default_value.integer; | |
190 } | |
191 | |
192 const char * | |
193 gaim_account_option_get_default_string(const GaimAccountOption *option) | |
194 { | |
195 g_return_val_if_fail(option != NULL, NULL); | |
5663
e9551e7d6f01
[gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents:
5660
diff
changeset
|
196 g_return_val_if_fail(option->type == GAIM_PREF_STRING, NULL); |
5639 | 197 |
198 return option->default_value.string; | |
199 } | |
200 | |
201 | |
202 GaimAccountUserSplit * | |
203 gaim_account_user_split_new(const char *text, const char *default_value, | |
204 char sep) | |
205 { | |
206 GaimAccountUserSplit *split; | |
207 | |
208 g_return_val_if_fail(text != NULL, NULL); | |
209 g_return_val_if_fail(sep != 0, NULL); | |
210 | |
211 split = g_new0(GaimAccountUserSplit, 1); | |
212 | |
213 split->text = g_strdup(text); | |
214 split->field_sep = sep; | |
215 split->default_value = (default_value == NULL | |
216 ? NULL : g_strdup(default_value)); | |
217 | |
218 return split; | |
219 } | |
220 | |
221 void | |
222 gaim_account_user_split_destroy(GaimAccountUserSplit *split) | |
223 { | |
224 g_return_if_fail(split != NULL); | |
225 | |
226 if (split->text != NULL) | |
227 g_free(split->text); | |
228 | |
229 if (split->default_value != NULL) | |
230 g_free(split->default_value); | |
231 | |
232 g_free(split); | |
233 } | |
234 | |
235 const char * | |
5654
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
236 gaim_account_user_split_get_text(const GaimAccountUserSplit *split) |
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 g_return_val_if_fail(split != NULL, NULL); |
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 return split->text; |
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
241 } |
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
242 |
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
243 const char * |
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
244 gaim_account_user_split_get_default_value(const GaimAccountUserSplit *split) |
5639 | 245 { |
246 g_return_val_if_fail(split != NULL, NULL); | |
247 | |
248 return split->default_value; | |
249 } | |
250 | |
251 char | |
5654
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
252 gaim_account_user_split_get_separator(const GaimAccountUserSplit *split) |
5639 | 253 { |
254 g_return_val_if_fail(split != NULL, 0); | |
255 | |
256 return split->field_sep; | |
257 } |