Mercurial > pidgin
annotate src/accountopt.c @ 13159:d03013fd39bf
[gaim-migrate @ 15522]
Fix the filename unescaping.
committer: Tailor Script <tailor@pidgin.im>
| author | Richard Laager <rlaager@wiktel.com> |
|---|---|
| date | Tue, 07 Feb 2006 16:02:25 +0000 |
| parents | d5937f126c60 |
| children | f09c6e8df82c |
| 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" | |
| 12172 | 26 #include "util.h" |
| 5639 | 27 |
| 28 GaimAccountOption * | |
| 29 gaim_account_option_new(GaimPrefType type, const char *text, | |
| 30 const char *pref_name) | |
| 31 { | |
| 32 GaimAccountOption *option; | |
| 33 | |
|
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
34 g_return_val_if_fail(type != GAIM_PREF_NONE, NULL); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
35 g_return_val_if_fail(text != NULL, NULL); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
36 g_return_val_if_fail(pref_name != NULL, NULL); |
| 5639 | 37 |
| 38 option = g_new0(GaimAccountOption, 1); | |
| 39 | |
| 40 option->type = type; | |
| 41 option->text = g_strdup(text); | |
| 42 option->pref_name = g_strdup(pref_name); | |
| 43 | |
| 44 return option; | |
| 45 } | |
| 46 | |
| 47 GaimAccountOption * | |
| 48 gaim_account_option_bool_new(const char *text, const char *pref_name, | |
| 49 gboolean default_value) | |
| 50 { | |
| 51 GaimAccountOption *option; | |
|
6902
e30bedfb99db
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
52 |
| 5639 | 53 option = gaim_account_option_new(GAIM_PREF_BOOLEAN, text, pref_name); |
| 54 | |
| 55 if (option == NULL) | |
| 56 return NULL; | |
| 57 | |
| 58 option->default_value.boolean = default_value; | |
| 59 | |
| 60 return option; | |
| 61 } | |
| 62 | |
| 63 GaimAccountOption * | |
| 64 gaim_account_option_int_new(const char *text, const char *pref_name, | |
| 65 int default_value) | |
| 66 { | |
| 67 GaimAccountOption *option; | |
|
6902
e30bedfb99db
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
68 |
| 5639 | 69 option = gaim_account_option_new(GAIM_PREF_INT, text, pref_name); |
| 70 | |
| 71 if (option == NULL) | |
| 72 return NULL; | |
| 73 | |
| 74 option->default_value.integer = default_value; | |
| 75 | |
| 76 return option; | |
| 77 } | |
| 78 | |
| 79 GaimAccountOption * | |
| 80 gaim_account_option_string_new(const char *text, const char *pref_name, | |
| 81 const char *default_value) | |
| 82 { | |
| 83 GaimAccountOption *option; | |
|
6902
e30bedfb99db
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
84 |
| 5639 | 85 option = gaim_account_option_new(GAIM_PREF_STRING, text, pref_name); |
| 86 | |
| 87 if (option == NULL) | |
| 88 return NULL; | |
| 89 | |
| 90 if (default_value != NULL) | |
| 91 option->default_value.string = g_strdup(default_value); | |
| 92 | |
| 93 return option; | |
| 94 } | |
| 95 | |
|
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
96 GaimAccountOption * |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
97 gaim_account_option_list_new(const char *text, const char *pref_name, |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
98 GList *list) |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
99 { |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
100 GaimAccountOption *option; |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
101 |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
102 option = gaim_account_option_new(GAIM_PREF_STRING_LIST, text, pref_name); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
103 |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
104 if (option == NULL) |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
105 return NULL; |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
106 |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
107 option->default_value.list = list; |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
108 |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
109 return option; |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
110 } |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
111 |
| 5639 | 112 void |
| 113 gaim_account_option_destroy(GaimAccountOption *option) | |
| 114 { | |
| 115 g_return_if_fail(option != NULL); | |
| 116 | |
| 117 if (option->text != NULL) | |
| 118 g_free(option->text); | |
| 119 | |
| 120 if (option->pref_name != NULL) | |
| 121 g_free(option->pref_name); | |
| 122 | |
|
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
123 if (option->type == GAIM_PREF_STRING) |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
124 { |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
125 if (option->default_value.string != NULL) |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
126 g_free(option->default_value.string); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
127 } |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
128 else if (option->type == GAIM_PREF_STRING_LIST) |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
129 { |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
130 if (option->default_value.list != NULL) |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
131 { |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
132 g_list_foreach(option->default_value.list, (GFunc)g_free, NULL); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
133 g_list_free(option->default_value.list); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
134 } |
| 5639 | 135 } |
| 136 | |
| 137 g_free(option); | |
| 138 } | |
| 139 | |
| 140 void | |
| 141 gaim_account_option_set_default_bool(GaimAccountOption *option, | |
| 142 gboolean value) | |
| 143 { | |
| 144 g_return_if_fail(option != NULL); | |
| 145 g_return_if_fail(option->type == GAIM_PREF_BOOLEAN); | |
| 146 | |
| 147 option->default_value.boolean = value; | |
| 148 } | |
| 149 | |
| 150 void | |
| 151 gaim_account_option_set_default_int(GaimAccountOption *option, int value) | |
| 152 { | |
| 153 g_return_if_fail(option != NULL); | |
| 154 g_return_if_fail(option->type == GAIM_PREF_INT); | |
| 155 | |
| 156 option->default_value.integer = value; | |
| 157 } | |
| 158 | |
| 159 void | |
| 160 gaim_account_option_set_default_string(GaimAccountOption *option, | |
| 161 const char *value) | |
| 162 { | |
| 163 g_return_if_fail(option != NULL); | |
| 164 g_return_if_fail(option->type == GAIM_PREF_STRING); | |
| 165 | |
| 166 if (option->default_value.string != NULL) | |
| 167 g_free(option->default_value.string); | |
| 168 | |
| 169 option->default_value.string = (value == NULL ? NULL : g_strdup(value)); | |
| 170 } | |
| 171 | |
|
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
172 void |
| 10658 | 173 gaim_account_option_set_masked(GaimAccountOption *option, gboolean masked) |
| 174 { | |
| 175 g_return_if_fail(option != NULL); | |
| 176 g_return_if_fail(option->type == GAIM_PREF_STRING); | |
| 177 | |
| 178 option->masked = masked; | |
| 179 } | |
| 180 | |
| 181 | |
| 182 void | |
|
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
183 gaim_account_option_set_list(GaimAccountOption *option, GList *values) |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
184 { |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
185 g_return_if_fail(option != NULL); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
186 g_return_if_fail(option->type == GAIM_PREF_STRING_LIST); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
187 |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
188 if (option->default_value.list != NULL) |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
189 { |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
190 g_list_foreach(option->default_value.list, (GFunc)g_free, NULL); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
191 g_list_free(option->default_value.list); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
192 } |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
193 |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
194 option->default_value.list = values; |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
195 } |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
196 |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
197 void |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
198 gaim_account_option_add_list_item(GaimAccountOption *option, |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
199 const char *key, const char *value) |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
200 { |
| 12172 | 201 GaimKeyValuePair *kvp; |
| 202 | |
|
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
203 g_return_if_fail(option != NULL); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
204 g_return_if_fail(key != NULL); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
205 g_return_if_fail(value != NULL); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
206 g_return_if_fail(option->type == GAIM_PREF_STRING_LIST); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
207 |
| 12172 | 208 kvp = g_new0(GaimKeyValuePair, 1); |
| 209 kvp->key = g_strdup(key); | |
| 210 kvp->value = g_strdup(value); | |
| 211 | |
|
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
212 option->default_value.list = g_list_append(option->default_value.list, |
| 12172 | 213 kvp); |
|
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
214 } |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
215 |
| 5639 | 216 GaimPrefType |
| 217 gaim_account_option_get_type(const GaimAccountOption *option) | |
| 218 { | |
| 219 g_return_val_if_fail(option != NULL, GAIM_PREF_NONE); | |
| 220 | |
| 221 return option->type; | |
| 222 } | |
| 223 | |
| 224 const char * | |
| 225 gaim_account_option_get_text(const GaimAccountOption *option) | |
| 226 { | |
| 227 g_return_val_if_fail(option != NULL, NULL); | |
| 228 | |
| 229 return option->text; | |
| 230 } | |
| 231 | |
|
5660
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
232 const char * |
|
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
233 gaim_account_option_get_setting(const GaimAccountOption *option) |
|
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
234 { |
|
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
235 g_return_val_if_fail(option != NULL, NULL); |
|
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
236 |
|
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
237 return option->pref_name; |
|
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
238 } |
|
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
239 |
| 5639 | 240 gboolean |
| 241 gaim_account_option_get_default_bool(const GaimAccountOption *option) | |
| 242 { | |
| 243 g_return_val_if_fail(option != NULL, FALSE); | |
|
5663
e9551e7d6f01
[gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents:
5660
diff
changeset
|
244 g_return_val_if_fail(option->type == GAIM_PREF_BOOLEAN, FALSE); |
| 5639 | 245 |
| 246 return option->default_value.boolean; | |
| 247 } | |
| 248 | |
| 249 int | |
| 250 gaim_account_option_get_default_int(const GaimAccountOption *option) | |
| 251 { | |
| 252 g_return_val_if_fail(option != NULL, -1); | |
|
5663
e9551e7d6f01
[gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents:
5660
diff
changeset
|
253 g_return_val_if_fail(option->type == GAIM_PREF_INT, -1); |
| 5639 | 254 |
| 255 return option->default_value.integer; | |
| 256 } | |
| 257 | |
| 258 const char * | |
| 259 gaim_account_option_get_default_string(const GaimAccountOption *option) | |
| 260 { | |
| 261 g_return_val_if_fail(option != NULL, NULL); | |
|
5663
e9551e7d6f01
[gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents:
5660
diff
changeset
|
262 g_return_val_if_fail(option->type == GAIM_PREF_STRING, NULL); |
| 5639 | 263 |
| 264 return option->default_value.string; | |
| 265 } | |
| 266 | |
| 12172 | 267 const char * |
| 268 gaim_account_option_get_default_list_value(const GaimAccountOption *option) | |
| 269 { | |
| 270 GaimKeyValuePair *kvp; | |
| 271 | |
| 272 g_return_val_if_fail(option != NULL, NULL); | |
| 273 g_return_val_if_fail(option->type == GAIM_PREF_STRING_LIST, NULL); | |
| 274 | |
| 275 if (option->default_value.list == NULL) | |
| 276 return NULL; | |
| 277 | |
| 278 kvp = option->default_value.list->data; | |
| 279 | |
| 280 return (kvp ? kvp->value : NULL); | |
| 281 } | |
| 282 | |
| 10658 | 283 gboolean |
| 284 gaim_account_option_get_masked(const GaimAccountOption *option) | |
| 285 { | |
| 286 g_return_val_if_fail(option != NULL, FALSE); | |
| 287 g_return_val_if_fail(option->type == GAIM_PREF_STRING, FALSE); | |
| 288 | |
| 289 return option->masked; | |
| 290 } | |
| 291 | |
|
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
292 const GList * |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
293 gaim_account_option_get_list(const GaimAccountOption *option) |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
294 { |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
295 g_return_val_if_fail(option != NULL, NULL); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
296 g_return_val_if_fail(option->type == GAIM_PREF_STRING_LIST, NULL); |
| 5639 | 297 |
|
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
298 return option->default_value.list; |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
299 } |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
300 |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
301 /************************************************************************** |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
302 * Account User Split API |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
303 **************************************************************************/ |
| 5639 | 304 GaimAccountUserSplit * |
| 305 gaim_account_user_split_new(const char *text, const char *default_value, | |
| 306 char sep) | |
| 307 { | |
| 308 GaimAccountUserSplit *split; | |
| 309 | |
| 310 g_return_val_if_fail(text != NULL, NULL); | |
| 311 g_return_val_if_fail(sep != 0, NULL); | |
| 312 | |
| 313 split = g_new0(GaimAccountUserSplit, 1); | |
| 314 | |
| 315 split->text = g_strdup(text); | |
| 316 split->field_sep = sep; | |
| 317 split->default_value = (default_value == NULL | |
| 318 ? NULL : g_strdup(default_value)); | |
| 319 | |
| 320 return split; | |
| 321 } | |
| 322 | |
| 323 void | |
| 324 gaim_account_user_split_destroy(GaimAccountUserSplit *split) | |
| 325 { | |
| 326 g_return_if_fail(split != NULL); | |
| 327 | |
| 328 if (split->text != NULL) | |
| 329 g_free(split->text); | |
| 330 | |
| 331 if (split->default_value != NULL) | |
| 332 g_free(split->default_value); | |
| 333 | |
| 334 g_free(split); | |
| 335 } | |
| 336 | |
| 337 const char * | |
|
5654
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
338 gaim_account_user_split_get_text(const GaimAccountUserSplit *split) |
|
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
339 { |
|
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
340 g_return_val_if_fail(split != NULL, NULL); |
|
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
341 |
|
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
342 return split->text; |
|
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
343 } |
|
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
344 |
|
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
345 const char * |
|
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
346 gaim_account_user_split_get_default_value(const GaimAccountUserSplit *split) |
| 5639 | 347 { |
| 348 g_return_val_if_fail(split != NULL, NULL); | |
| 349 | |
| 350 return split->default_value; | |
| 351 } | |
| 352 | |
| 353 char | |
|
5654
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
354 gaim_account_user_split_get_separator(const GaimAccountUserSplit *split) |
| 5639 | 355 { |
| 356 g_return_val_if_fail(split != NULL, 0); | |
| 357 | |
| 358 return split->field_sep; | |
| 359 } |
