Thu, 28 Sep 2017 20:33:59 -0500
closing merged branch
| 5639 | 1 | /** |
| 2 | * @file accountopt.c Account Options API | |
| 3 | * @ingroup core | |
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
4 | */ |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
5 | |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
6 | /* purple |
| 5639 | 7 | * |
| 15884 | 8 | * Purple is the legal property of its developers, whose names are too numerous |
| 8046 | 9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 10 | * source distribution. | |
|
6902
bf0a4376750f
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
11 | * |
| 5639 | 12 | * This program is free software; you can redistribute it and/or modify |
| 13 | * it under the terms of the GNU General Public License as published by | |
| 14 | * the Free Software Foundation; either version 2 of the License, or | |
| 15 | * (at your option) any later version. | |
| 16 | * | |
| 17 | * This program is distributed in the hope that it will be useful, | |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 | * GNU General Public License for more details. | |
| 21 | * | |
| 22 | * You should have received a copy of the GNU General Public License | |
| 23 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18265
diff
changeset
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 5639 | 25 | */ |
|
18265
9f26190d7f46
Move the define in internal.h instead.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18190
diff
changeset
|
26 | #include "internal.h" |
|
9f26190d7f46
Move the define in internal.h instead.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18190
diff
changeset
|
27 | |
| 5639 | 28 | #include "accountopt.h" |
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
29 | #include "util.h" |
| 5639 | 30 | |
| 15884 | 31 | PurpleAccountOption * |
| 32 | purple_account_option_new(PurplePrefType type, const char *text, | |
| 5639 | 33 | const char *pref_name) |
| 34 | { | |
| 15884 | 35 | PurpleAccountOption *option; |
| 5639 | 36 | |
| 15884 | 37 | g_return_val_if_fail(type != PURPLE_PREF_NONE, NULL); |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
38 | g_return_val_if_fail(text != NULL, NULL); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
39 | g_return_val_if_fail(pref_name != NULL, NULL); |
| 5639 | 40 | |
| 15884 | 41 | option = g_new0(PurpleAccountOption, 1); |
| 5639 | 42 | |
| 43 | option->type = type; | |
| 44 | option->text = g_strdup(text); | |
| 45 | option->pref_name = g_strdup(pref_name); | |
| 46 | ||
| 47 | return option; | |
| 48 | } | |
| 49 | ||
| 15884 | 50 | PurpleAccountOption * |
| 51 | purple_account_option_bool_new(const char *text, const char *pref_name, | |
| 5639 | 52 | gboolean default_value) |
| 53 | { | |
| 15884 | 54 | PurpleAccountOption *option; |
|
6902
bf0a4376750f
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
55 | |
| 15884 | 56 | option = purple_account_option_new(PURPLE_PREF_BOOLEAN, text, pref_name); |
| 5639 | 57 | |
| 58 | if (option == NULL) | |
| 59 | return NULL; | |
| 60 | ||
| 61 | option->default_value.boolean = default_value; | |
| 62 | ||
| 63 | return option; | |
| 64 | } | |
| 65 | ||
| 15884 | 66 | PurpleAccountOption * |
| 67 | purple_account_option_int_new(const char *text, const char *pref_name, | |
| 5639 | 68 | int default_value) |
| 69 | { | |
| 15884 | 70 | PurpleAccountOption *option; |
|
6902
bf0a4376750f
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
71 | |
| 15884 | 72 | option = purple_account_option_new(PURPLE_PREF_INT, text, pref_name); |
| 5639 | 73 | |
| 74 | if (option == NULL) | |
| 75 | return NULL; | |
| 76 | ||
| 77 | option->default_value.integer = default_value; | |
| 78 | ||
| 79 | return option; | |
| 80 | } | |
| 81 | ||
| 15884 | 82 | PurpleAccountOption * |
| 83 | purple_account_option_string_new(const char *text, const char *pref_name, | |
| 5639 | 84 | const char *default_value) |
| 85 | { | |
| 15884 | 86 | PurpleAccountOption *option; |
|
6902
bf0a4376750f
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
87 | |
| 15884 | 88 | option = purple_account_option_new(PURPLE_PREF_STRING, text, pref_name); |
| 5639 | 89 | |
| 90 | if (option == NULL) | |
| 91 | return NULL; | |
| 92 | ||
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
93 | option->default_value.string = g_strdup(default_value); |
| 5639 | 94 | |
| 95 | return option; | |
| 96 | } | |
| 97 | ||
| 15884 | 98 | PurpleAccountOption * |
| 99 | purple_account_option_list_new(const char *text, const char *pref_name, | |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
100 | GList *list) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
101 | { |
| 15884 | 102 | PurpleAccountOption *option; |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
103 | |
| 15884 | 104 | option = purple_account_option_new(PURPLE_PREF_STRING_LIST, text, pref_name); |
|
8570
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 | if (option == NULL) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
107 | return NULL; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
108 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
109 | option->default_value.list = list; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
110 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
111 | return option; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
112 | } |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
113 | |
|
27977
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
114 | static void |
|
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
115 | purple_account_option_list_free(gpointer data, gpointer user_data) |
|
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
116 | { |
|
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
117 | PurpleKeyValuePair *kvp = data; |
|
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
118 | |
|
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
119 | g_free(kvp->value); |
|
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
120 | g_free(kvp->key); |
|
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
121 | g_free(kvp); |
|
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
122 | } |
|
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
123 | |
| 5639 | 124 | void |
| 15884 | 125 | purple_account_option_destroy(PurpleAccountOption *option) |
| 5639 | 126 | { |
| 127 | g_return_if_fail(option != NULL); | |
| 128 | ||
|
13234
1d8e569b2053
[gaim-migrate @ 15598]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12172
diff
changeset
|
129 | g_free(option->text); |
|
1d8e569b2053
[gaim-migrate @ 15598]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12172
diff
changeset
|
130 | g_free(option->pref_name); |
| 5639 | 131 | |
| 15884 | 132 | if (option->type == PURPLE_PREF_STRING) |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
133 | { |
|
13234
1d8e569b2053
[gaim-migrate @ 15598]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12172
diff
changeset
|
134 | g_free(option->default_value.string); |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
135 | } |
| 15884 | 136 | else if (option->type == PURPLE_PREF_STRING_LIST) |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
137 | { |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
138 | if (option->default_value.list != NULL) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
139 | { |
|
27977
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
140 | g_list_foreach(option->default_value.list, purple_account_option_list_free, NULL); |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
141 | g_list_free(option->default_value.list); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
142 | } |
| 5639 | 143 | } |
| 144 | ||
| 145 | g_free(option); | |
| 146 | } | |
| 147 | ||
| 148 | void | |
| 15884 | 149 | purple_account_option_set_default_bool(PurpleAccountOption *option, |
| 5639 | 150 | gboolean value) |
| 151 | { | |
| 152 | g_return_if_fail(option != NULL); | |
| 15884 | 153 | g_return_if_fail(option->type == PURPLE_PREF_BOOLEAN); |
| 5639 | 154 | |
| 155 | option->default_value.boolean = value; | |
| 156 | } | |
| 157 | ||
| 158 | void | |
| 15884 | 159 | purple_account_option_set_default_int(PurpleAccountOption *option, int value) |
| 5639 | 160 | { |
| 161 | g_return_if_fail(option != NULL); | |
| 15884 | 162 | g_return_if_fail(option->type == PURPLE_PREF_INT); |
| 5639 | 163 | |
| 164 | option->default_value.integer = value; | |
| 165 | } | |
| 166 | ||
| 167 | void | |
| 15884 | 168 | purple_account_option_set_default_string(PurpleAccountOption *option, |
| 5639 | 169 | const char *value) |
| 170 | { | |
| 171 | g_return_if_fail(option != NULL); | |
| 15884 | 172 | g_return_if_fail(option->type == PURPLE_PREF_STRING); |
| 5639 | 173 | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
174 | g_free(option->default_value.string); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
175 | option->default_value.string = g_strdup(value); |
| 5639 | 176 | } |
| 177 | ||
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
178 | void |
| 15884 | 179 | purple_account_option_set_masked(PurpleAccountOption *option, gboolean masked) |
| 10658 | 180 | { |
| 181 | g_return_if_fail(option != NULL); | |
| 15884 | 182 | g_return_if_fail(option->type == PURPLE_PREF_STRING); |
| 10658 | 183 | |
| 184 | option->masked = masked; | |
| 185 | } | |
| 186 | ||
| 187 | ||
| 188 | void | |
| 15884 | 189 | purple_account_option_set_list(PurpleAccountOption *option, GList *values) |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
190 | { |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
191 | g_return_if_fail(option != NULL); |
| 15884 | 192 | g_return_if_fail(option->type == PURPLE_PREF_STRING_LIST); |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
193 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
194 | if (option->default_value.list != NULL) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
195 | { |
|
27977
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
196 | g_list_foreach(option->default_value.list, purple_account_option_list_free, NULL); |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
197 | g_list_free(option->default_value.list); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
198 | } |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
199 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
200 | option->default_value.list = values; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
201 | } |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
202 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
203 | void |
| 15884 | 204 | purple_account_option_add_list_item(PurpleAccountOption *option, |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
205 | const char *key, const char *value) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
206 | { |
| 15884 | 207 | PurpleKeyValuePair *kvp; |
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
208 | |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
209 | g_return_if_fail(option != NULL); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
210 | g_return_if_fail(key != NULL); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
211 | g_return_if_fail(value != NULL); |
| 15884 | 212 | g_return_if_fail(option->type == PURPLE_PREF_STRING_LIST); |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
213 | |
| 15884 | 214 | kvp = g_new0(PurpleKeyValuePair, 1); |
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
215 | kvp->key = g_strdup(key); |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
216 | kvp->value = g_strdup(value); |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
217 | |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
218 | 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
|
219 | kvp); |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
220 | } |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
221 | |
| 15884 | 222 | PurplePrefType |
| 223 | purple_account_option_get_type(const PurpleAccountOption *option) | |
| 5639 | 224 | { |
| 15884 | 225 | g_return_val_if_fail(option != NULL, PURPLE_PREF_NONE); |
| 5639 | 226 | |
| 227 | return option->type; | |
| 228 | } | |
| 229 | ||
| 230 | const char * | |
| 15884 | 231 | purple_account_option_get_text(const PurpleAccountOption *option) |
| 5639 | 232 | { |
| 233 | g_return_val_if_fail(option != NULL, NULL); | |
| 234 | ||
| 235 | return option->text; | |
| 236 | } | |
| 237 | ||
|
5660
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
238 | const char * |
| 15884 | 239 | purple_account_option_get_setting(const PurpleAccountOption *option) |
|
5660
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
240 | { |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
241 | g_return_val_if_fail(option != NULL, NULL); |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
242 | |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
243 | return option->pref_name; |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
244 | } |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
245 | |
| 5639 | 246 | gboolean |
| 15884 | 247 | purple_account_option_get_default_bool(const PurpleAccountOption *option) |
| 5639 | 248 | { |
| 249 | g_return_val_if_fail(option != NULL, FALSE); | |
| 15884 | 250 | g_return_val_if_fail(option->type == PURPLE_PREF_BOOLEAN, FALSE); |
| 5639 | 251 | |
| 252 | return option->default_value.boolean; | |
| 253 | } | |
| 254 | ||
| 255 | int | |
| 15884 | 256 | purple_account_option_get_default_int(const PurpleAccountOption *option) |
| 5639 | 257 | { |
| 258 | g_return_val_if_fail(option != NULL, -1); | |
| 15884 | 259 | g_return_val_if_fail(option->type == PURPLE_PREF_INT, -1); |
| 5639 | 260 | |
| 261 | return option->default_value.integer; | |
| 262 | } | |
| 263 | ||
| 264 | const char * | |
| 15884 | 265 | purple_account_option_get_default_string(const PurpleAccountOption *option) |
| 5639 | 266 | { |
| 267 | g_return_val_if_fail(option != NULL, NULL); | |
| 15884 | 268 | g_return_val_if_fail(option->type == PURPLE_PREF_STRING, NULL); |
| 5639 | 269 | |
| 270 | return option->default_value.string; | |
| 271 | } | |
| 272 | ||
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
273 | const char * |
| 15884 | 274 | purple_account_option_get_default_list_value(const PurpleAccountOption *option) |
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
275 | { |
| 15884 | 276 | PurpleKeyValuePair *kvp; |
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
277 | |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
278 | g_return_val_if_fail(option != NULL, NULL); |
| 15884 | 279 | g_return_val_if_fail(option->type == PURPLE_PREF_STRING_LIST, NULL); |
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
280 | |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
281 | if (option->default_value.list == NULL) |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
282 | return NULL; |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
283 | |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
284 | kvp = option->default_value.list->data; |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
285 | |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
286 | return (kvp ? kvp->value : NULL); |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
287 | } |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
288 | |
| 10658 | 289 | gboolean |
| 15884 | 290 | purple_account_option_get_masked(const PurpleAccountOption *option) |
| 10658 | 291 | { |
| 292 | g_return_val_if_fail(option != NULL, FALSE); | |
| 15884 | 293 | g_return_val_if_fail(option->type == PURPLE_PREF_STRING, FALSE); |
| 10658 | 294 | |
| 295 | return option->masked; | |
| 296 | } | |
| 297 | ||
|
18190
bcf28ef7e8ff
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@pidgin.im>
parents:
18099
diff
changeset
|
298 | GList * |
| 15884 | 299 | purple_account_option_get_list(const PurpleAccountOption *option) |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
300 | { |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
301 | g_return_val_if_fail(option != NULL, NULL); |
| 15884 | 302 | g_return_val_if_fail(option->type == PURPLE_PREF_STRING_LIST, NULL); |
| 5639 | 303 | |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
304 | return option->default_value.list; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
305 | } |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
306 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
307 | /************************************************************************** |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
308 | * Account User Split API |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
309 | **************************************************************************/ |
| 15884 | 310 | PurpleAccountUserSplit * |
| 311 | purple_account_user_split_new(const char *text, const char *default_value, | |
| 5639 | 312 | char sep) |
| 313 | { | |
| 15884 | 314 | PurpleAccountUserSplit *split; |
| 5639 | 315 | |
| 316 | g_return_val_if_fail(text != NULL, NULL); | |
| 317 | g_return_val_if_fail(sep != 0, NULL); | |
| 318 | ||
| 15884 | 319 | split = g_new0(PurpleAccountUserSplit, 1); |
| 5639 | 320 | |
| 321 | split->text = g_strdup(text); | |
| 322 | split->field_sep = sep; | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
323 | split->default_value = g_strdup(default_value); |
|
18099
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
324 | split->reverse = TRUE; |
| 5639 | 325 | |
| 326 | return split; | |
| 327 | } | |
| 328 | ||
| 329 | void | |
| 15884 | 330 | purple_account_user_split_destroy(PurpleAccountUserSplit *split) |
| 5639 | 331 | { |
| 332 | g_return_if_fail(split != NULL); | |
| 333 | ||
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
334 | g_free(split->text); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
335 | g_free(split->default_value); |
| 5639 | 336 | g_free(split); |
| 337 | } | |
| 338 | ||
| 339 | const char * | |
| 15884 | 340 | purple_account_user_split_get_text(const PurpleAccountUserSplit *split) |
|
5654
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
341 | { |
|
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
342 | g_return_val_if_fail(split != NULL, NULL); |
|
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
343 | |
|
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
344 | return split->text; |
|
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
345 | } |
|
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
346 | |
|
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
347 | const char * |
| 15884 | 348 | purple_account_user_split_get_default_value(const PurpleAccountUserSplit *split) |
| 5639 | 349 | { |
| 350 | g_return_val_if_fail(split != NULL, NULL); | |
| 351 | ||
| 352 | return split->default_value; | |
| 353 | } | |
| 354 | ||
| 355 | char | |
| 15884 | 356 | purple_account_user_split_get_separator(const PurpleAccountUserSplit *split) |
| 5639 | 357 | { |
| 358 | g_return_val_if_fail(split != NULL, 0); | |
| 359 | ||
| 360 | return split->field_sep; | |
| 361 | } | |
|
18099
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
362 | |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
363 | gboolean |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
364 | purple_account_user_split_get_reverse(const PurpleAccountUserSplit *split) |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
365 | { |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
366 | g_return_val_if_fail(split != NULL, FALSE); |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
367 | |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
368 | return split->reverse; |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
369 | } |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
370 | |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
371 | void |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
372 | purple_account_user_split_set_reverse(PurpleAccountUserSplit *split, gboolean reverse) |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
373 | { |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
374 | g_return_if_fail(split != NULL); |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
375 | |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
376 | split->reverse = reverse; |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
377 | } |