Mercurial > pidgin
annotate src/accountopt.c @ 13794:ecfd8fb02c19
[gaim-migrate @ 16206]
We don't really need to pop up an error if the sound file doesn't exist
committer: Tailor Script <tailor@pidgin.im>
| author | Sean Egan <seanegan@gmail.com> |
|---|---|
| date | Tue, 30 May 2006 17:02:27 +0000 |
| parents | f09c6e8df82c |
| children | 8bda65b88e49 |
| 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 | |
|
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
12172
diff
changeset
|
117 g_free(option->text); |
|
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
12172
diff
changeset
|
118 g_free(option->pref_name); |
| 5639 | 119 |
|
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
120 if (option->type == GAIM_PREF_STRING) |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
121 { |
|
13233
f09c6e8df82c
[gaim-migrate @ 15598]
Richard Laager <rlaager@wiktel.com>
parents:
12172
diff
changeset
|
122 g_free(option->default_value.string); |
|
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
123 } |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
124 else if (option->type == GAIM_PREF_STRING_LIST) |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
125 { |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
126 if (option->default_value.list != NULL) |
|
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 g_list_foreach(option->default_value.list, (GFunc)g_free, NULL); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
129 g_list_free(option->default_value.list); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
130 } |
| 5639 | 131 } |
| 132 | |
| 133 g_free(option); | |
| 134 } | |
| 135 | |
| 136 void | |
| 137 gaim_account_option_set_default_bool(GaimAccountOption *option, | |
| 138 gboolean value) | |
| 139 { | |
| 140 g_return_if_fail(option != NULL); | |
| 141 g_return_if_fail(option->type == GAIM_PREF_BOOLEAN); | |
| 142 | |
| 143 option->default_value.boolean = value; | |
| 144 } | |
| 145 | |
| 146 void | |
| 147 gaim_account_option_set_default_int(GaimAccountOption *option, int value) | |
| 148 { | |
| 149 g_return_if_fail(option != NULL); | |
| 150 g_return_if_fail(option->type == GAIM_PREF_INT); | |
| 151 | |
| 152 option->default_value.integer = value; | |
| 153 } | |
| 154 | |
| 155 void | |
| 156 gaim_account_option_set_default_string(GaimAccountOption *option, | |
| 157 const char *value) | |
| 158 { | |
| 159 g_return_if_fail(option != NULL); | |
| 160 g_return_if_fail(option->type == GAIM_PREF_STRING); | |
| 161 | |
| 162 if (option->default_value.string != NULL) | |
| 163 g_free(option->default_value.string); | |
| 164 | |
| 165 option->default_value.string = (value == NULL ? NULL : g_strdup(value)); | |
| 166 } | |
| 167 | |
|
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
168 void |
| 10658 | 169 gaim_account_option_set_masked(GaimAccountOption *option, gboolean masked) |
| 170 { | |
| 171 g_return_if_fail(option != NULL); | |
| 172 g_return_if_fail(option->type == GAIM_PREF_STRING); | |
| 173 | |
| 174 option->masked = masked; | |
| 175 } | |
| 176 | |
| 177 | |
| 178 void | |
|
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
179 gaim_account_option_set_list(GaimAccountOption *option, GList *values) |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
180 { |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
181 g_return_if_fail(option != NULL); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
182 g_return_if_fail(option->type == GAIM_PREF_STRING_LIST); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
183 |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
184 if (option->default_value.list != NULL) |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
185 { |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
186 g_list_foreach(option->default_value.list, (GFunc)g_free, NULL); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
187 g_list_free(option->default_value.list); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
188 } |
|
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 option->default_value.list = values; |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
191 } |
|
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 void |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
194 gaim_account_option_add_list_item(GaimAccountOption *option, |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
195 const char *key, const char *value) |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
196 { |
| 12172 | 197 GaimKeyValuePair *kvp; |
| 198 | |
|
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
199 g_return_if_fail(option != NULL); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
200 g_return_if_fail(key != NULL); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
201 g_return_if_fail(value != NULL); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
202 g_return_if_fail(option->type == GAIM_PREF_STRING_LIST); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
203 |
| 12172 | 204 kvp = g_new0(GaimKeyValuePair, 1); |
| 205 kvp->key = g_strdup(key); | |
| 206 kvp->value = g_strdup(value); | |
| 207 | |
|
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
208 option->default_value.list = g_list_append(option->default_value.list, |
| 12172 | 209 kvp); |
|
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
210 } |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
211 |
| 5639 | 212 GaimPrefType |
| 213 gaim_account_option_get_type(const GaimAccountOption *option) | |
| 214 { | |
| 215 g_return_val_if_fail(option != NULL, GAIM_PREF_NONE); | |
| 216 | |
| 217 return option->type; | |
| 218 } | |
| 219 | |
| 220 const char * | |
| 221 gaim_account_option_get_text(const GaimAccountOption *option) | |
| 222 { | |
| 223 g_return_val_if_fail(option != NULL, NULL); | |
| 224 | |
| 225 return option->text; | |
| 226 } | |
| 227 | |
|
5660
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
228 const char * |
|
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
229 gaim_account_option_get_setting(const GaimAccountOption *option) |
|
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
230 { |
|
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
231 g_return_val_if_fail(option != NULL, NULL); |
|
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
232 |
|
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
233 return option->pref_name; |
|
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 |
| 5639 | 236 gboolean |
| 237 gaim_account_option_get_default_bool(const GaimAccountOption *option) | |
| 238 { | |
| 239 g_return_val_if_fail(option != NULL, FALSE); | |
|
5663
e9551e7d6f01
[gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents:
5660
diff
changeset
|
240 g_return_val_if_fail(option->type == GAIM_PREF_BOOLEAN, FALSE); |
| 5639 | 241 |
| 242 return option->default_value.boolean; | |
| 243 } | |
| 244 | |
| 245 int | |
| 246 gaim_account_option_get_default_int(const GaimAccountOption *option) | |
| 247 { | |
| 248 g_return_val_if_fail(option != NULL, -1); | |
|
5663
e9551e7d6f01
[gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents:
5660
diff
changeset
|
249 g_return_val_if_fail(option->type == GAIM_PREF_INT, -1); |
| 5639 | 250 |
| 251 return option->default_value.integer; | |
| 252 } | |
| 253 | |
| 254 const char * | |
| 255 gaim_account_option_get_default_string(const GaimAccountOption *option) | |
| 256 { | |
| 257 g_return_val_if_fail(option != NULL, NULL); | |
|
5663
e9551e7d6f01
[gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents:
5660
diff
changeset
|
258 g_return_val_if_fail(option->type == GAIM_PREF_STRING, NULL); |
| 5639 | 259 |
| 260 return option->default_value.string; | |
| 261 } | |
| 262 | |
| 12172 | 263 const char * |
| 264 gaim_account_option_get_default_list_value(const GaimAccountOption *option) | |
| 265 { | |
| 266 GaimKeyValuePair *kvp; | |
| 267 | |
| 268 g_return_val_if_fail(option != NULL, NULL); | |
| 269 g_return_val_if_fail(option->type == GAIM_PREF_STRING_LIST, NULL); | |
| 270 | |
| 271 if (option->default_value.list == NULL) | |
| 272 return NULL; | |
| 273 | |
| 274 kvp = option->default_value.list->data; | |
| 275 | |
| 276 return (kvp ? kvp->value : NULL); | |
| 277 } | |
| 278 | |
| 10658 | 279 gboolean |
| 280 gaim_account_option_get_masked(const GaimAccountOption *option) | |
| 281 { | |
| 282 g_return_val_if_fail(option != NULL, FALSE); | |
| 283 g_return_val_if_fail(option->type == GAIM_PREF_STRING, FALSE); | |
| 284 | |
| 285 return option->masked; | |
| 286 } | |
| 287 | |
|
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
288 const GList * |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
289 gaim_account_option_get_list(const GaimAccountOption *option) |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
290 { |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
291 g_return_val_if_fail(option != NULL, NULL); |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
292 g_return_val_if_fail(option->type == GAIM_PREF_STRING_LIST, NULL); |
| 5639 | 293 |
|
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
294 return option->default_value.list; |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
295 } |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
296 |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
297 /************************************************************************** |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
298 * Account User Split API |
|
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
299 **************************************************************************/ |
| 5639 | 300 GaimAccountUserSplit * |
| 301 gaim_account_user_split_new(const char *text, const char *default_value, | |
| 302 char sep) | |
| 303 { | |
| 304 GaimAccountUserSplit *split; | |
| 305 | |
| 306 g_return_val_if_fail(text != NULL, NULL); | |
| 307 g_return_val_if_fail(sep != 0, NULL); | |
| 308 | |
| 309 split = g_new0(GaimAccountUserSplit, 1); | |
| 310 | |
| 311 split->text = g_strdup(text); | |
| 312 split->field_sep = sep; | |
| 313 split->default_value = (default_value == NULL | |
| 314 ? NULL : g_strdup(default_value)); | |
| 315 | |
| 316 return split; | |
| 317 } | |
| 318 | |
| 319 void | |
| 320 gaim_account_user_split_destroy(GaimAccountUserSplit *split) | |
| 321 { | |
| 322 g_return_if_fail(split != NULL); | |
| 323 | |
| 324 if (split->text != NULL) | |
| 325 g_free(split->text); | |
| 326 | |
| 327 if (split->default_value != NULL) | |
| 328 g_free(split->default_value); | |
| 329 | |
| 330 g_free(split); | |
| 331 } | |
| 332 | |
| 333 const char * | |
|
5654
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
334 gaim_account_user_split_get_text(const GaimAccountUserSplit *split) |
|
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
335 { |
|
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
336 g_return_val_if_fail(split != NULL, NULL); |
|
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
337 |
|
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
338 return split->text; |
|
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 |
|
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
341 const char * |
|
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
342 gaim_account_user_split_get_default_value(const GaimAccountUserSplit *split) |
| 5639 | 343 { |
| 344 g_return_val_if_fail(split != NULL, NULL); | |
| 345 | |
| 346 return split->default_value; | |
| 347 } | |
| 348 | |
| 349 char | |
|
5654
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
350 gaim_account_user_split_get_separator(const GaimAccountUserSplit *split) |
| 5639 | 351 { |
| 352 g_return_val_if_fail(split != NULL, 0); | |
| 353 | |
| 354 return split->field_sep; | |
| 355 } |
