Sun, 15 Apr 2007 02:10:37 +0000
propagate from branch 'im.pidgin.gaim' (head b2836a24d81e7a1bd1d21b3aea8794b094391344)
to branch 'im.pidgin.rlaager.merging.soc-msnp13-to-svn18164' (head 463b4fa9f067b279f843520d95a822adc86a0a1b)
| 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
bf0a4376750f
[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
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
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
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
34 | g_return_val_if_fail(type != GAIM_PREF_NONE, NULL); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
35 | g_return_val_if_fail(text != NULL, NULL); |
|
bce05cb55dbc
[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
bf0a4376750f
[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
bf0a4376750f
[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
bf0a4376750f
[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 | ||
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
90 | option->default_value.string = g_strdup(default_value); |
| 5639 | 91 | |
| 92 | return option; | |
| 93 | } | |
| 94 | ||
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
95 | GaimAccountOption * |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
96 | gaim_account_option_list_new(const char *text, const char *pref_name, |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
97 | GList *list) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
98 | { |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
99 | GaimAccountOption *option; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
100 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
101 | option = gaim_account_option_new(GAIM_PREF_STRING_LIST, text, pref_name); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
102 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
103 | if (option == NULL) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
104 | return NULL; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
105 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
106 | option->default_value.list = list; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
107 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
108 | return option; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
109 | } |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
110 | |
| 5639 | 111 | void |
| 112 | gaim_account_option_destroy(GaimAccountOption *option) | |
| 113 | { | |
| 114 | g_return_if_fail(option != NULL); | |
| 115 | ||
|
13234
1d8e569b2053
[gaim-migrate @ 15598]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12172
diff
changeset
|
116 | g_free(option->text); |
|
1d8e569b2053
[gaim-migrate @ 15598]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12172
diff
changeset
|
117 | g_free(option->pref_name); |
| 5639 | 118 | |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
119 | if (option->type == GAIM_PREF_STRING) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
120 | { |
|
13234
1d8e569b2053
[gaim-migrate @ 15598]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12172
diff
changeset
|
121 | g_free(option->default_value.string); |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
122 | } |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
123 | else if (option->type == GAIM_PREF_STRING_LIST) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
124 | { |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
125 | if (option->default_value.list != NULL) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
126 | { |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
127 | g_list_foreach(option->default_value.list, (GFunc)g_free, NULL); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
128 | g_list_free(option->default_value.list); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
129 | } |
| 5639 | 130 | } |
| 131 | ||
| 132 | g_free(option); | |
| 133 | } | |
| 134 | ||
| 135 | void | |
| 136 | gaim_account_option_set_default_bool(GaimAccountOption *option, | |
| 137 | gboolean value) | |
| 138 | { | |
| 139 | g_return_if_fail(option != NULL); | |
| 140 | g_return_if_fail(option->type == GAIM_PREF_BOOLEAN); | |
| 141 | ||
| 142 | option->default_value.boolean = value; | |
| 143 | } | |
| 144 | ||
| 145 | void | |
| 146 | gaim_account_option_set_default_int(GaimAccountOption *option, int value) | |
| 147 | { | |
| 148 | g_return_if_fail(option != NULL); | |
| 149 | g_return_if_fail(option->type == GAIM_PREF_INT); | |
| 150 | ||
| 151 | option->default_value.integer = value; | |
| 152 | } | |
| 153 | ||
| 154 | void | |
| 155 | gaim_account_option_set_default_string(GaimAccountOption *option, | |
| 156 | const char *value) | |
| 157 | { | |
| 158 | g_return_if_fail(option != NULL); | |
| 159 | g_return_if_fail(option->type == GAIM_PREF_STRING); | |
| 160 | ||
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
161 | g_free(option->default_value.string); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
162 | option->default_value.string = g_strdup(value); |
| 5639 | 163 | } |
| 164 | ||
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
165 | void |
| 10658 | 166 | gaim_account_option_set_masked(GaimAccountOption *option, gboolean masked) |
| 167 | { | |
| 168 | g_return_if_fail(option != NULL); | |
| 169 | g_return_if_fail(option->type == GAIM_PREF_STRING); | |
| 170 | ||
| 171 | option->masked = masked; | |
| 172 | } | |
| 173 | ||
| 174 | ||
| 175 | void | |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
176 | gaim_account_option_set_list(GaimAccountOption *option, GList *values) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
177 | { |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
178 | g_return_if_fail(option != NULL); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
179 | g_return_if_fail(option->type == GAIM_PREF_STRING_LIST); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
180 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
181 | if (option->default_value.list != NULL) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
182 | { |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
183 | g_list_foreach(option->default_value.list, (GFunc)g_free, NULL); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
184 | g_list_free(option->default_value.list); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
185 | } |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
186 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
187 | option->default_value.list = values; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
188 | } |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
189 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
190 | void |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
191 | gaim_account_option_add_list_item(GaimAccountOption *option, |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
192 | const char *key, const char *value) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
193 | { |
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
194 | GaimKeyValuePair *kvp; |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
195 | |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
196 | g_return_if_fail(option != NULL); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
197 | g_return_if_fail(key != NULL); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
198 | g_return_if_fail(value != NULL); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
199 | g_return_if_fail(option->type == GAIM_PREF_STRING_LIST); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
200 | |
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
201 | kvp = g_new0(GaimKeyValuePair, 1); |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
202 | kvp->key = g_strdup(key); |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
203 | kvp->value = g_strdup(value); |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
204 | |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
205 | option->default_value.list = g_list_append(option->default_value.list, |
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
206 | kvp); |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
207 | } |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
208 | |
| 5639 | 209 | GaimPrefType |
| 210 | gaim_account_option_get_type(const GaimAccountOption *option) | |
| 211 | { | |
| 212 | g_return_val_if_fail(option != NULL, GAIM_PREF_NONE); | |
| 213 | ||
| 214 | return option->type; | |
| 215 | } | |
| 216 | ||
| 217 | const char * | |
| 218 | gaim_account_option_get_text(const GaimAccountOption *option) | |
| 219 | { | |
| 220 | g_return_val_if_fail(option != NULL, NULL); | |
| 221 | ||
| 222 | return option->text; | |
| 223 | } | |
| 224 | ||
|
5660
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
225 | const char * |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
226 | gaim_account_option_get_setting(const GaimAccountOption *option) |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
227 | { |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
228 | g_return_val_if_fail(option != NULL, NULL); |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
229 | |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
230 | return option->pref_name; |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
231 | } |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
232 | |
| 5639 | 233 | gboolean |
| 234 | gaim_account_option_get_default_bool(const GaimAccountOption *option) | |
| 235 | { | |
| 236 | g_return_val_if_fail(option != NULL, FALSE); | |
|
5663
05c9effe5b5f
[gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents:
5660
diff
changeset
|
237 | g_return_val_if_fail(option->type == GAIM_PREF_BOOLEAN, FALSE); |
| 5639 | 238 | |
| 239 | return option->default_value.boolean; | |
| 240 | } | |
| 241 | ||
| 242 | int | |
| 243 | gaim_account_option_get_default_int(const GaimAccountOption *option) | |
| 244 | { | |
| 245 | g_return_val_if_fail(option != NULL, -1); | |
|
5663
05c9effe5b5f
[gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents:
5660
diff
changeset
|
246 | g_return_val_if_fail(option->type == GAIM_PREF_INT, -1); |
| 5639 | 247 | |
| 248 | return option->default_value.integer; | |
| 249 | } | |
| 250 | ||
| 251 | const char * | |
| 252 | gaim_account_option_get_default_string(const GaimAccountOption *option) | |
| 253 | { | |
| 254 | g_return_val_if_fail(option != NULL, NULL); | |
|
5663
05c9effe5b5f
[gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents:
5660
diff
changeset
|
255 | g_return_val_if_fail(option->type == GAIM_PREF_STRING, NULL); |
| 5639 | 256 | |
| 257 | return option->default_value.string; | |
| 258 | } | |
| 259 | ||
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
260 | const char * |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
261 | gaim_account_option_get_default_list_value(const GaimAccountOption *option) |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
262 | { |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
263 | GaimKeyValuePair *kvp; |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
264 | |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
265 | g_return_val_if_fail(option != NULL, NULL); |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
266 | g_return_val_if_fail(option->type == GAIM_PREF_STRING_LIST, NULL); |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
267 | |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
268 | if (option->default_value.list == NULL) |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
269 | return NULL; |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
270 | |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
271 | kvp = option->default_value.list->data; |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
272 | |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
273 | return (kvp ? kvp->value : NULL); |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
274 | } |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
275 | |
| 10658 | 276 | gboolean |
| 277 | gaim_account_option_get_masked(const GaimAccountOption *option) | |
| 278 | { | |
| 279 | g_return_val_if_fail(option != NULL, FALSE); | |
| 280 | g_return_val_if_fail(option->type == GAIM_PREF_STRING, FALSE); | |
| 281 | ||
| 282 | return option->masked; | |
| 283 | } | |
| 284 | ||
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
285 | const GList * |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
286 | gaim_account_option_get_list(const GaimAccountOption *option) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
287 | { |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
288 | g_return_val_if_fail(option != NULL, NULL); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
289 | g_return_val_if_fail(option->type == GAIM_PREF_STRING_LIST, NULL); |
| 5639 | 290 | |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
291 | return option->default_value.list; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
292 | } |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
293 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
294 | /************************************************************************** |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
295 | * Account User Split API |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
296 | **************************************************************************/ |
| 5639 | 297 | GaimAccountUserSplit * |
| 298 | gaim_account_user_split_new(const char *text, const char *default_value, | |
| 299 | char sep) | |
| 300 | { | |
| 301 | GaimAccountUserSplit *split; | |
| 302 | ||
| 303 | g_return_val_if_fail(text != NULL, NULL); | |
| 304 | g_return_val_if_fail(sep != 0, NULL); | |
| 305 | ||
| 306 | split = g_new0(GaimAccountUserSplit, 1); | |
| 307 | ||
| 308 | split->text = g_strdup(text); | |
| 309 | split->field_sep = sep; | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
310 | split->default_value = g_strdup(default_value); |
| 5639 | 311 | |
| 312 | return split; | |
| 313 | } | |
| 314 | ||
| 315 | void | |
| 316 | gaim_account_user_split_destroy(GaimAccountUserSplit *split) | |
| 317 | { | |
| 318 | g_return_if_fail(split != NULL); | |
| 319 | ||
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
320 | g_free(split->text); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
321 | g_free(split->default_value); |
| 5639 | 322 | g_free(split); |
| 323 | } | |
| 324 | ||
| 325 | const char * | |
|
5654
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
326 | gaim_account_user_split_get_text(const GaimAccountUserSplit *split) |
|
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
327 | { |
|
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
328 | g_return_val_if_fail(split != NULL, NULL); |
|
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
329 | |
|
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
330 | return split->text; |
|
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
331 | } |
|
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
332 | |
|
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
333 | const char * |
|
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
334 | gaim_account_user_split_get_default_value(const GaimAccountUserSplit *split) |
| 5639 | 335 | { |
| 336 | g_return_val_if_fail(split != NULL, NULL); | |
| 337 | ||
| 338 | return split->default_value; | |
| 339 | } | |
| 340 | ||
| 341 | char | |
|
5654
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
342 | gaim_account_user_split_get_separator(const GaimAccountUserSplit *split) |
| 5639 | 343 | { |
| 344 | g_return_val_if_fail(split != NULL, 0); | |
| 345 | ||
| 346 | return split->field_sep; | |
| 347 | } |