Sun, 16 Oct 2011 03:03:39 +0000
Remove free_memory argument from D-Bus list functions. It's already
always set to FALSE in the auto-generated code.
Fixes #1747.
| 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 | |
|
32622
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
31 | /** |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
32 | * An option for an account. |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
33 | * |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
34 | * This is set by protocol plugins, and appears in the account settings |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
35 | * dialogs. |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
36 | */ |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
37 | struct _PurpleAccountOption |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
38 | { |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
39 | PurplePrefType type; /**< The type of value. */ |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
40 | |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
41 | char *text; /**< The text that will appear to the user. */ |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
42 | char *pref_name; /**< The name of the associated preference. */ |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
43 | |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
44 | union |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
45 | { |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
46 | gboolean boolean; /**< The default boolean value. */ |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
47 | int integer; /**< The default integer value. */ |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
48 | char *string; /**< The default string value. */ |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
49 | GList *list; /**< The default list value. */ |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
50 | |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
51 | } default_value; |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
52 | |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
53 | gboolean masked; /**< Whether the value entered should be |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
54 | * obscured from view (for passwords and |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
55 | * similar options) |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
56 | */ |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
57 | }; |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
58 | |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
59 | /** |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
60 | * A username split. |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
61 | * |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
62 | * This is used by some protocols to separate the fields of the username |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
63 | * into more human-readable components. |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
64 | */ |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
65 | struct _PurpleAccountUserSplit |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
66 | { |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
67 | char *text; /**< The text that will appear to the user. */ |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
68 | char *default_value; /**< The default value. */ |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
69 | char field_sep; /**< The field separator. */ |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
70 | gboolean reverse; /**< TRUE if the separator should be found |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
71 | starting a the end of the string, FALSE |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
72 | otherwise */ |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
73 | }; |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
74 | |
|
d2522cb828aa
Hide structs PurpleAccountOption and PurpleAccountUserSplit.
Andrew Victor <andrew.victor@mxit.com>
parents:
27977
diff
changeset
|
75 | |
| 15884 | 76 | PurpleAccountOption * |
| 77 | purple_account_option_new(PurplePrefType type, const char *text, | |
| 5639 | 78 | const char *pref_name) |
| 79 | { | |
| 15884 | 80 | PurpleAccountOption *option; |
| 5639 | 81 | |
| 15884 | 82 | g_return_val_if_fail(type != PURPLE_PREF_NONE, NULL); |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
83 | g_return_val_if_fail(text != NULL, NULL); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
84 | g_return_val_if_fail(pref_name != NULL, NULL); |
| 5639 | 85 | |
| 15884 | 86 | option = g_new0(PurpleAccountOption, 1); |
| 5639 | 87 | |
| 88 | option->type = type; | |
| 89 | option->text = g_strdup(text); | |
| 90 | option->pref_name = g_strdup(pref_name); | |
| 91 | ||
| 92 | return option; | |
| 93 | } | |
| 94 | ||
| 15884 | 95 | PurpleAccountOption * |
| 96 | purple_account_option_bool_new(const char *text, const char *pref_name, | |
| 5639 | 97 | gboolean default_value) |
| 98 | { | |
| 15884 | 99 | PurpleAccountOption *option; |
|
6902
bf0a4376750f
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
100 | |
| 15884 | 101 | option = purple_account_option_new(PURPLE_PREF_BOOLEAN, text, pref_name); |
| 5639 | 102 | |
| 103 | if (option == NULL) | |
| 104 | return NULL; | |
| 105 | ||
| 106 | option->default_value.boolean = default_value; | |
| 107 | ||
| 108 | return option; | |
| 109 | } | |
| 110 | ||
| 15884 | 111 | PurpleAccountOption * |
| 112 | purple_account_option_int_new(const char *text, const char *pref_name, | |
| 5639 | 113 | int default_value) |
| 114 | { | |
| 15884 | 115 | PurpleAccountOption *option; |
|
6902
bf0a4376750f
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
116 | |
| 15884 | 117 | option = purple_account_option_new(PURPLE_PREF_INT, text, pref_name); |
| 5639 | 118 | |
| 119 | if (option == NULL) | |
| 120 | return NULL; | |
| 121 | ||
| 122 | option->default_value.integer = default_value; | |
| 123 | ||
| 124 | return option; | |
| 125 | } | |
| 126 | ||
| 15884 | 127 | PurpleAccountOption * |
| 128 | purple_account_option_string_new(const char *text, const char *pref_name, | |
| 5639 | 129 | const char *default_value) |
| 130 | { | |
| 15884 | 131 | PurpleAccountOption *option; |
|
6902
bf0a4376750f
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
132 | |
| 15884 | 133 | option = purple_account_option_new(PURPLE_PREF_STRING, text, pref_name); |
| 5639 | 134 | |
| 135 | if (option == NULL) | |
| 136 | return NULL; | |
| 137 | ||
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
138 | option->default_value.string = g_strdup(default_value); |
| 5639 | 139 | |
| 140 | return option; | |
| 141 | } | |
| 142 | ||
| 15884 | 143 | PurpleAccountOption * |
| 144 | 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
|
145 | GList *list) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
146 | { |
| 15884 | 147 | PurpleAccountOption *option; |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
148 | |
| 15884 | 149 | 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
|
150 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
151 | if (option == NULL) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
152 | return NULL; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
153 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
154 | option->default_value.list = list; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
155 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
156 | return option; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
157 | } |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
158 | |
|
27977
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
159 | static void |
|
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
160 | 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
|
161 | { |
|
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
162 | PurpleKeyValuePair *kvp = data; |
|
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
163 | |
|
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
164 | g_free(kvp->value); |
|
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
165 | g_free(kvp->key); |
|
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
166 | g_free(kvp); |
|
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
167 | } |
|
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
168 | |
| 5639 | 169 | void |
| 15884 | 170 | purple_account_option_destroy(PurpleAccountOption *option) |
| 5639 | 171 | { |
| 172 | g_return_if_fail(option != NULL); | |
| 173 | ||
|
13234
1d8e569b2053
[gaim-migrate @ 15598]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12172
diff
changeset
|
174 | g_free(option->text); |
|
1d8e569b2053
[gaim-migrate @ 15598]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12172
diff
changeset
|
175 | g_free(option->pref_name); |
| 5639 | 176 | |
| 15884 | 177 | if (option->type == PURPLE_PREF_STRING) |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
178 | { |
|
13234
1d8e569b2053
[gaim-migrate @ 15598]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12172
diff
changeset
|
179 | g_free(option->default_value.string); |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
180 | } |
| 15884 | 181 | else if (option->type == PURPLE_PREF_STRING_LIST) |
|
8570
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 | if (option->default_value.list != NULL) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
184 | { |
|
27977
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
185 | 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
|
186 | g_list_free(option->default_value.list); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
187 | } |
| 5639 | 188 | } |
| 189 | ||
| 190 | g_free(option); | |
| 191 | } | |
| 192 | ||
| 193 | void | |
| 15884 | 194 | purple_account_option_set_default_bool(PurpleAccountOption *option, |
| 5639 | 195 | gboolean value) |
| 196 | { | |
| 197 | g_return_if_fail(option != NULL); | |
| 15884 | 198 | g_return_if_fail(option->type == PURPLE_PREF_BOOLEAN); |
| 5639 | 199 | |
| 200 | option->default_value.boolean = value; | |
| 201 | } | |
| 202 | ||
| 203 | void | |
| 15884 | 204 | purple_account_option_set_default_int(PurpleAccountOption *option, int value) |
| 5639 | 205 | { |
| 206 | g_return_if_fail(option != NULL); | |
| 15884 | 207 | g_return_if_fail(option->type == PURPLE_PREF_INT); |
| 5639 | 208 | |
| 209 | option->default_value.integer = value; | |
| 210 | } | |
| 211 | ||
| 212 | void | |
| 15884 | 213 | purple_account_option_set_default_string(PurpleAccountOption *option, |
| 5639 | 214 | const char *value) |
| 215 | { | |
| 216 | g_return_if_fail(option != NULL); | |
| 15884 | 217 | g_return_if_fail(option->type == PURPLE_PREF_STRING); |
| 5639 | 218 | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
219 | g_free(option->default_value.string); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
220 | option->default_value.string = g_strdup(value); |
| 5639 | 221 | } |
| 222 | ||
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
223 | void |
| 15884 | 224 | purple_account_option_set_masked(PurpleAccountOption *option, gboolean masked) |
| 10658 | 225 | { |
| 226 | g_return_if_fail(option != NULL); | |
| 15884 | 227 | g_return_if_fail(option->type == PURPLE_PREF_STRING); |
| 10658 | 228 | |
| 229 | option->masked = masked; | |
| 230 | } | |
| 231 | ||
| 232 | ||
| 233 | void | |
| 15884 | 234 | purple_account_option_set_list(PurpleAccountOption *option, GList *values) |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
235 | { |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
236 | g_return_if_fail(option != NULL); |
| 15884 | 237 | g_return_if_fail(option->type == PURPLE_PREF_STRING_LIST); |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
238 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
239 | if (option->default_value.list != NULL) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
240 | { |
|
27977
79edf3aeaac1
Free the KeyValuePairs associated with accountopt lists. Closes #9115.
Stefan Becker <stefan.becker@nokia.com>
parents:
20147
diff
changeset
|
241 | 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
|
242 | g_list_free(option->default_value.list); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
243 | } |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
244 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
245 | option->default_value.list = values; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
246 | } |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
247 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
248 | void |
| 15884 | 249 | purple_account_option_add_list_item(PurpleAccountOption *option, |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
250 | const char *key, const char *value) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
251 | { |
| 15884 | 252 | PurpleKeyValuePair *kvp; |
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
253 | |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
254 | g_return_if_fail(option != NULL); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
255 | g_return_if_fail(key != NULL); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
256 | g_return_if_fail(value != NULL); |
| 15884 | 257 | g_return_if_fail(option->type == PURPLE_PREF_STRING_LIST); |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
258 | |
| 15884 | 259 | kvp = g_new0(PurpleKeyValuePair, 1); |
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
260 | kvp->key = g_strdup(key); |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
261 | kvp->value = g_strdup(value); |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
262 | |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
263 | 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
|
264 | kvp); |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
265 | } |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
266 | |
| 15884 | 267 | PurplePrefType |
| 268 | purple_account_option_get_type(const PurpleAccountOption *option) | |
| 5639 | 269 | { |
| 15884 | 270 | g_return_val_if_fail(option != NULL, PURPLE_PREF_NONE); |
| 5639 | 271 | |
| 272 | return option->type; | |
| 273 | } | |
| 274 | ||
| 275 | const char * | |
| 15884 | 276 | purple_account_option_get_text(const PurpleAccountOption *option) |
| 5639 | 277 | { |
| 278 | g_return_val_if_fail(option != NULL, NULL); | |
| 279 | ||
| 280 | return option->text; | |
| 281 | } | |
| 282 | ||
|
5660
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
283 | const char * |
| 15884 | 284 | purple_account_option_get_setting(const PurpleAccountOption *option) |
|
5660
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
285 | { |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
286 | g_return_val_if_fail(option != NULL, NULL); |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
287 | |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
288 | return option->pref_name; |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
289 | } |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
290 | |
| 5639 | 291 | gboolean |
| 15884 | 292 | purple_account_option_get_default_bool(const PurpleAccountOption *option) |
| 5639 | 293 | { |
| 294 | g_return_val_if_fail(option != NULL, FALSE); | |
| 15884 | 295 | g_return_val_if_fail(option->type == PURPLE_PREF_BOOLEAN, FALSE); |
| 5639 | 296 | |
| 297 | return option->default_value.boolean; | |
| 298 | } | |
| 299 | ||
| 300 | int | |
| 15884 | 301 | purple_account_option_get_default_int(const PurpleAccountOption *option) |
| 5639 | 302 | { |
| 303 | g_return_val_if_fail(option != NULL, -1); | |
| 15884 | 304 | g_return_val_if_fail(option->type == PURPLE_PREF_INT, -1); |
| 5639 | 305 | |
| 306 | return option->default_value.integer; | |
| 307 | } | |
| 308 | ||
| 309 | const char * | |
| 15884 | 310 | purple_account_option_get_default_string(const PurpleAccountOption *option) |
| 5639 | 311 | { |
| 312 | g_return_val_if_fail(option != NULL, NULL); | |
| 15884 | 313 | g_return_val_if_fail(option->type == PURPLE_PREF_STRING, NULL); |
| 5639 | 314 | |
| 315 | return option->default_value.string; | |
| 316 | } | |
| 317 | ||
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
318 | const char * |
| 15884 | 319 | purple_account_option_get_default_list_value(const PurpleAccountOption *option) |
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
320 | { |
| 15884 | 321 | PurpleKeyValuePair *kvp; |
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
322 | |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
323 | g_return_val_if_fail(option != NULL, NULL); |
| 15884 | 324 | 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
|
325 | |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
326 | if (option->default_value.list == NULL) |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
327 | return NULL; |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
328 | |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
329 | kvp = option->default_value.list->data; |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
330 | |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
331 | return (kvp ? kvp->value : NULL); |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
332 | } |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
333 | |
| 10658 | 334 | gboolean |
| 15884 | 335 | purple_account_option_get_masked(const PurpleAccountOption *option) |
| 10658 | 336 | { |
| 337 | g_return_val_if_fail(option != NULL, FALSE); | |
| 15884 | 338 | g_return_val_if_fail(option->type == PURPLE_PREF_STRING, FALSE); |
| 10658 | 339 | |
| 340 | return option->masked; | |
| 341 | } | |
| 342 | ||
|
18190
bcf28ef7e8ff
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@pidgin.im>
parents:
18099
diff
changeset
|
343 | GList * |
| 15884 | 344 | purple_account_option_get_list(const PurpleAccountOption *option) |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
345 | { |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
346 | g_return_val_if_fail(option != NULL, NULL); |
| 15884 | 347 | g_return_val_if_fail(option->type == PURPLE_PREF_STRING_LIST, NULL); |
| 5639 | 348 | |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
349 | return option->default_value.list; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
350 | } |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
351 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
352 | /************************************************************************** |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
353 | * Account User Split API |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
354 | **************************************************************************/ |
| 15884 | 355 | PurpleAccountUserSplit * |
| 356 | purple_account_user_split_new(const char *text, const char *default_value, | |
| 5639 | 357 | char sep) |
| 358 | { | |
| 15884 | 359 | PurpleAccountUserSplit *split; |
| 5639 | 360 | |
| 361 | g_return_val_if_fail(text != NULL, NULL); | |
| 362 | g_return_val_if_fail(sep != 0, NULL); | |
| 363 | ||
| 15884 | 364 | split = g_new0(PurpleAccountUserSplit, 1); |
| 5639 | 365 | |
| 366 | split->text = g_strdup(text); | |
| 367 | split->field_sep = sep; | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
368 | 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
|
369 | split->reverse = TRUE; |
| 5639 | 370 | |
| 371 | return split; | |
| 372 | } | |
| 373 | ||
| 374 | void | |
| 15884 | 375 | purple_account_user_split_destroy(PurpleAccountUserSplit *split) |
| 5639 | 376 | { |
| 377 | g_return_if_fail(split != NULL); | |
| 378 | ||
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
379 | g_free(split->text); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
380 | g_free(split->default_value); |
| 5639 | 381 | g_free(split); |
| 382 | } | |
| 383 | ||
| 384 | const char * | |
| 15884 | 385 | purple_account_user_split_get_text(const PurpleAccountUserSplit *split) |
|
5654
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
386 | { |
|
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
387 | g_return_val_if_fail(split != NULL, NULL); |
|
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
388 | |
|
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
389 | return split->text; |
|
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
390 | } |
|
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
391 | |
|
3a0e6dba1c2f
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
392 | const char * |
| 15884 | 393 | purple_account_user_split_get_default_value(const PurpleAccountUserSplit *split) |
| 5639 | 394 | { |
| 395 | g_return_val_if_fail(split != NULL, NULL); | |
| 396 | ||
| 397 | return split->default_value; | |
| 398 | } | |
| 399 | ||
| 400 | char | |
| 15884 | 401 | purple_account_user_split_get_separator(const PurpleAccountUserSplit *split) |
| 5639 | 402 | { |
| 403 | g_return_val_if_fail(split != NULL, 0); | |
| 404 | ||
| 405 | return split->field_sep; | |
| 406 | } | |
|
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
|
407 | |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
408 | 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
|
409 | 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
|
410 | { |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
411 | 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
|
412 | |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
413 | 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
|
414 | } |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
415 | |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
416 | 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
|
417 | 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
|
418 | { |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
419 | 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
|
420 | |
|
f38988d232f7
jabber can contain @ symbols and / in the resource, so we have to look for
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
421 | 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
|
422 | } |