Thu, 30 Apr 2020 23:43:54 -0500
Split PurpleKeyValuePair out to it's own file and try to do some cleanup in the files that need to include it.
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
1 | /* purple |
| 5639 | 2 | * |
| 15884 | 3 | * Purple is the legal property of its developers, whose names are too numerous |
| 8046 | 4 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 5 | * source distribution. | |
|
6902
bf0a4376750f
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
6 | * |
| 5639 | 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by | |
| 9 | * the Free Software Foundation; either version 2 of the License, or | |
| 10 | * (at your option) any later version. | |
| 11 | * | |
| 12 | * This program is distributed in the hope that it will be useful, | |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | * GNU General Public License for more details. | |
| 16 | * | |
| 17 | * You should have received a copy of the GNU General Public License | |
| 18 | * 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
|
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 5639 | 20 | */ |
|
18265
9f26190d7f46
Move the define in internal.h instead.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18190
diff
changeset
|
21 | #include "internal.h" |
|
9f26190d7f46
Move the define in internal.h instead.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18190
diff
changeset
|
22 | |
|
40350
72271baf92bc
Split PurpleKeyValuePair out to it's own file and try to do some cleanup in the files that need to include it.
Gary Kramlich <grim@reaperworld.com>
parents:
40331
diff
changeset
|
23 | #include "prefs.h" |
|
39970
cc7d4ff5a205
rename accountopt.[ch] to purpleaccountoption.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
39968
diff
changeset
|
24 | #include "purpleaccountoption.h" |
|
40350
72271baf92bc
Split PurpleKeyValuePair out to it's own file and try to do some cleanup in the files that need to include it.
Gary Kramlich <grim@reaperworld.com>
parents:
40331
diff
changeset
|
25 | #include "purplekeyvaluepair.h" |
| 5639 | 26 | |
|
35458
385156e1b493
Fix some gtk-doc warnings from account to connection
Ankit Vani <a@nevitus.org>
parents:
35454
diff
changeset
|
27 | /* |
|
32438
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27977
diff
changeset
|
28 | * An option for an account. |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27977
diff
changeset
|
29 | * |
|
36691
92122af1f083
Some documentation updates with regard to 'protocol plugins' and 'protocols'
Ankit Vani <a@nevitus.org>
parents:
33369
diff
changeset
|
30 | * This is set by protocols, and appears in the account settings |
|
32438
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27977
diff
changeset
|
31 | * dialogs. |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27977
diff
changeset
|
32 | */ |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27977
diff
changeset
|
33 | struct _PurpleAccountOption |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27977
diff
changeset
|
34 | { |
|
39972
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
35 | PurplePrefType type; /* The type of value. */ |
|
32438
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27977
diff
changeset
|
36 | |
|
39972
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
37 | gchar *text; /* The text that will appear to the user. */ |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
38 | gchar *pref_name; /* The name of the associated preference. */ |
|
32438
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27977
diff
changeset
|
39 | |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27977
diff
changeset
|
40 | union |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27977
diff
changeset
|
41 | { |
|
35470
8ee08a41f2f3
Convert some other doxygen-type comments
Ankit Vani <a@nevitus.org>
parents:
35458
diff
changeset
|
42 | gboolean boolean; /* The default boolean value. */ |
|
39972
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
43 | gint integer; /* The default integer value. */ |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
44 | gchar *string; /* The default string value. */ |
|
35470
8ee08a41f2f3
Convert some other doxygen-type comments
Ankit Vani <a@nevitus.org>
parents:
35458
diff
changeset
|
45 | GList *list; /* The default list value. */ |
|
32438
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27977
diff
changeset
|
46 | |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27977
diff
changeset
|
47 | } default_value; |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27977
diff
changeset
|
48 | |
|
33267
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
49 | union |
|
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
50 | { |
|
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
51 | struct |
|
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
52 | { |
|
35470
8ee08a41f2f3
Convert some other doxygen-type comments
Ankit Vani <a@nevitus.org>
parents:
35458
diff
changeset
|
53 | gboolean masked; /* Whether the value entered should |
|
33267
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
54 | * be obscured from view (for |
|
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
55 | * passwords and similar options) |
|
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
56 | */ |
|
35470
8ee08a41f2f3
Convert some other doxygen-type comments
Ankit Vani <a@nevitus.org>
parents:
35458
diff
changeset
|
57 | GSList *hints; /* List of hinted values */ |
|
33267
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
58 | } string; |
|
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
59 | } params; |
|
32438
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27977
diff
changeset
|
60 | }; |
|
dc8991868906
A boring and large patch so I can merge heads.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27977
diff
changeset
|
61 | |
|
39972
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
62 | G_DEFINE_BOXED_TYPE( |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
63 | PurpleAccountOption, |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
64 | purple_account_option, |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
65 | purple_account_option_copy, |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
66 | purple_account_option_destroy |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
67 | ); |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
68 | |
| 15884 | 69 | PurpleAccountOption * |
| 70 | purple_account_option_new(PurplePrefType type, const char *text, | |
| 5639 | 71 | const char *pref_name) |
| 72 | { | |
| 15884 | 73 | PurpleAccountOption *option; |
| 5639 | 74 | |
| 15884 | 75 | g_return_val_if_fail(type != PURPLE_PREF_NONE, NULL); |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
76 | g_return_val_if_fail(text != NULL, NULL); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
77 | g_return_val_if_fail(pref_name != NULL, NULL); |
| 5639 | 78 | |
| 15884 | 79 | option = g_new0(PurpleAccountOption, 1); |
| 5639 | 80 | |
| 81 | option->type = type; | |
| 82 | option->text = g_strdup(text); | |
| 83 | option->pref_name = g_strdup(pref_name); | |
| 84 | ||
| 85 | return option; | |
| 86 | } | |
| 87 | ||
| 15884 | 88 | PurpleAccountOption * |
|
39972
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
89 | purple_account_option_copy(PurpleAccountOption *option) { |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
90 | PurpleAccountOption *opt = NULL; |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
91 | |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
92 | g_return_val_if_fail(option, NULL); |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
93 | |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
94 | opt = g_new0(PurpleAccountOption, 1); |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
95 | *opt = *option; |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
96 | |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
97 | opt->text = g_strdup(option->text); |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
98 | opt->pref_name = g_strdup(option->pref_name); |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
99 | |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
100 | if(opt->type == PURPLE_PREF_STRING) { |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
101 | opt->default_value.string = g_strdup(option->default_value.string); |
|
39980
54284ab06efd
Fix some minor new warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39972
diff
changeset
|
102 | opt->params.string.hints = g_slist_copy(option->params.string.hints); |
|
39972
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
103 | } |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
104 | |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
105 | return opt; |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
106 | } |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
107 | |
|
347a24c5363d
register PurpleAccountOption as a boxed type
Gary Kramlich <grim@reaperworld.com>
parents:
39970
diff
changeset
|
108 | PurpleAccountOption * |
| 15884 | 109 | purple_account_option_bool_new(const char *text, const char *pref_name, |
| 5639 | 110 | gboolean default_value) |
| 111 | { | |
| 15884 | 112 | PurpleAccountOption *option; |
|
6902
bf0a4376750f
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
113 | |
| 15884 | 114 | option = purple_account_option_new(PURPLE_PREF_BOOLEAN, text, pref_name); |
| 5639 | 115 | |
| 116 | if (option == NULL) | |
| 117 | return NULL; | |
| 118 | ||
| 119 | option->default_value.boolean = default_value; | |
| 120 | ||
| 121 | return option; | |
| 122 | } | |
| 123 | ||
| 15884 | 124 | PurpleAccountOption * |
| 125 | purple_account_option_int_new(const char *text, const char *pref_name, | |
| 5639 | 126 | int default_value) |
| 127 | { | |
| 15884 | 128 | PurpleAccountOption *option; |
|
6902
bf0a4376750f
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
129 | |
| 15884 | 130 | option = purple_account_option_new(PURPLE_PREF_INT, text, pref_name); |
| 5639 | 131 | |
| 132 | if (option == NULL) | |
| 133 | return NULL; | |
| 134 | ||
| 135 | option->default_value.integer = default_value; | |
| 136 | ||
| 137 | return option; | |
| 138 | } | |
| 139 | ||
| 15884 | 140 | PurpleAccountOption * |
| 141 | purple_account_option_string_new(const char *text, const char *pref_name, | |
| 5639 | 142 | const char *default_value) |
| 143 | { | |
| 15884 | 144 | PurpleAccountOption *option; |
|
6902
bf0a4376750f
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
145 | |
| 15884 | 146 | option = purple_account_option_new(PURPLE_PREF_STRING, text, pref_name); |
| 5639 | 147 | |
| 148 | if (option == NULL) | |
| 149 | return NULL; | |
| 150 | ||
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
151 | option->default_value.string = g_strdup(default_value); |
| 5639 | 152 | |
| 153 | return option; | |
| 154 | } | |
| 155 | ||
| 15884 | 156 | PurpleAccountOption * |
| 157 | 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
|
158 | GList *list) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
159 | { |
| 15884 | 160 | PurpleAccountOption *option; |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
161 | |
| 15884 | 162 | 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
|
163 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
164 | if (option == NULL) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
165 | return NULL; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
166 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
167 | option->default_value.list = list; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
168 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
169 | return option; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
170 | } |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
171 | |
| 5639 | 172 | void |
| 15884 | 173 | purple_account_option_destroy(PurpleAccountOption *option) |
| 5639 | 174 | { |
| 175 | g_return_if_fail(option != NULL); | |
| 176 | ||
|
13234
1d8e569b2053
[gaim-migrate @ 15598]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12172
diff
changeset
|
177 | g_free(option->text); |
|
1d8e569b2053
[gaim-migrate @ 15598]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12172
diff
changeset
|
178 | g_free(option->pref_name); |
| 5639 | 179 | |
| 15884 | 180 | if (option->type == PURPLE_PREF_STRING) |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
181 | { |
|
13234
1d8e569b2053
[gaim-migrate @ 15598]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12172
diff
changeset
|
182 | g_free(option->default_value.string); |
|
33267
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
183 | g_slist_free_full(option->params.string.hints, &g_free); |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
184 | } |
| 15884 | 185 | else if (option->type == PURPLE_PREF_STRING_LIST) |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
186 | { |
|
39897
16b440d4ab36
Use g_list_free_full instead of g_list_foreach+g_list_free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37144
diff
changeset
|
187 | g_list_free_full(option->default_value.list, |
|
40331
684befe3ae5d
Add purple_key_value_pair_new_full with free function for value in PurpleKeyValuePair
qarkai <qarkai@gmail.com>
parents:
40329
diff
changeset
|
188 | (GDestroyNotify)purple_key_value_pair_free); |
| 5639 | 189 | } |
| 190 | ||
| 191 | g_free(option); | |
| 192 | } | |
| 193 | ||
| 194 | void | |
| 15884 | 195 | purple_account_option_set_default_bool(PurpleAccountOption *option, |
| 5639 | 196 | gboolean value) |
| 197 | { | |
| 198 | g_return_if_fail(option != NULL); | |
| 15884 | 199 | g_return_if_fail(option->type == PURPLE_PREF_BOOLEAN); |
| 5639 | 200 | |
| 201 | option->default_value.boolean = value; | |
| 202 | } | |
| 203 | ||
| 204 | void | |
| 15884 | 205 | purple_account_option_set_default_int(PurpleAccountOption *option, int value) |
| 5639 | 206 | { |
| 207 | g_return_if_fail(option != NULL); | |
| 15884 | 208 | g_return_if_fail(option->type == PURPLE_PREF_INT); |
| 5639 | 209 | |
| 210 | option->default_value.integer = value; | |
| 211 | } | |
| 212 | ||
| 213 | void | |
| 15884 | 214 | purple_account_option_set_default_string(PurpleAccountOption *option, |
| 5639 | 215 | const char *value) |
| 216 | { | |
| 217 | g_return_if_fail(option != NULL); | |
| 15884 | 218 | g_return_if_fail(option->type == PURPLE_PREF_STRING); |
| 5639 | 219 | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
220 | g_free(option->default_value.string); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
221 | option->default_value.string = g_strdup(value); |
| 5639 | 222 | } |
| 223 | ||
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
224 | void |
|
33267
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
225 | purple_account_option_string_set_masked(PurpleAccountOption *option, gboolean masked) |
| 10658 | 226 | { |
| 227 | g_return_if_fail(option != NULL); | |
| 15884 | 228 | g_return_if_fail(option->type == PURPLE_PREF_STRING); |
| 10658 | 229 | |
|
33267
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
230 | option->params.string.masked = masked; |
| 10658 | 231 | } |
| 232 | ||
|
33267
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
233 | void |
|
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
234 | purple_account_option_string_set_hints(PurpleAccountOption *option, GSList *hints) |
|
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
235 | { |
|
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
236 | g_return_if_fail(option != NULL); |
|
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
237 | g_return_if_fail(option->type == PURPLE_PREF_STRING); |
|
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
238 | |
|
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
239 | g_slist_free_full(option->params.string.hints, &g_free); |
|
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
240 | option->params.string.hints = hints; |
|
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
241 | } |
| 10658 | 242 | |
| 243 | void | |
| 15884 | 244 | purple_account_option_set_list(PurpleAccountOption *option, GList *values) |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
245 | { |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
246 | g_return_if_fail(option != NULL); |
| 15884 | 247 | g_return_if_fail(option->type == PURPLE_PREF_STRING_LIST); |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
248 | |
|
39897
16b440d4ab36
Use g_list_free_full instead of g_list_foreach+g_list_free.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
37144
diff
changeset
|
249 | g_list_free_full(option->default_value.list, |
|
40331
684befe3ae5d
Add purple_key_value_pair_new_full with free function for value in PurpleKeyValuePair
qarkai <qarkai@gmail.com>
parents:
40329
diff
changeset
|
250 | (GDestroyNotify)purple_key_value_pair_free); |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
251 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
252 | option->default_value.list = values; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
253 | } |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
254 | |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
255 | void |
| 15884 | 256 | purple_account_option_add_list_item(PurpleAccountOption *option, |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
257 | const char *key, const char *value) |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
258 | { |
| 15884 | 259 | PurpleKeyValuePair *kvp; |
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
260 | |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
261 | g_return_if_fail(option != NULL); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
262 | g_return_if_fail(key != NULL); |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
263 | g_return_if_fail(value != NULL); |
| 15884 | 264 | g_return_if_fail(option->type == PURPLE_PREF_STRING_LIST); |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
265 | |
|
40331
684befe3ae5d
Add purple_key_value_pair_new_full with free function for value in PurpleKeyValuePair
qarkai <qarkai@gmail.com>
parents:
40329
diff
changeset
|
266 | kvp = purple_key_value_pair_new_full(key, g_strdup(value), g_free); |
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
267 | |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
268 | 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
|
269 | kvp); |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
270 | } |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
271 | |
| 15884 | 272 | PurplePrefType |
|
35378
5d9e2581005b
gtk-doc prep: *_get_type() functions are hidden as standard GType-returning funcs, so rename them.
Ankit Vani <a@nevitus.org>
parents:
33369
diff
changeset
|
273 | purple_account_option_get_pref_type(const PurpleAccountOption *option) |
| 5639 | 274 | { |
| 15884 | 275 | g_return_val_if_fail(option != NULL, PURPLE_PREF_NONE); |
| 5639 | 276 | |
| 277 | return option->type; | |
| 278 | } | |
| 279 | ||
| 280 | const char * | |
| 15884 | 281 | purple_account_option_get_text(const PurpleAccountOption *option) |
| 5639 | 282 | { |
| 283 | g_return_val_if_fail(option != NULL, NULL); | |
| 284 | ||
| 285 | return option->text; | |
| 286 | } | |
| 287 | ||
|
5660
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
288 | const char * |
| 15884 | 289 | purple_account_option_get_setting(const PurpleAccountOption *option) |
|
5660
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
290 | { |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
291 | g_return_val_if_fail(option != NULL, NULL); |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
292 | |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
293 | return option->pref_name; |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
294 | } |
|
90787278c739
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
295 | |
| 5639 | 296 | gboolean |
| 15884 | 297 | purple_account_option_get_default_bool(const PurpleAccountOption *option) |
| 5639 | 298 | { |
| 299 | g_return_val_if_fail(option != NULL, FALSE); | |
| 15884 | 300 | g_return_val_if_fail(option->type == PURPLE_PREF_BOOLEAN, FALSE); |
| 5639 | 301 | |
| 302 | return option->default_value.boolean; | |
| 303 | } | |
| 304 | ||
| 305 | int | |
| 15884 | 306 | purple_account_option_get_default_int(const PurpleAccountOption *option) |
| 5639 | 307 | { |
| 308 | g_return_val_if_fail(option != NULL, -1); | |
| 15884 | 309 | g_return_val_if_fail(option->type == PURPLE_PREF_INT, -1); |
| 5639 | 310 | |
| 311 | return option->default_value.integer; | |
| 312 | } | |
| 313 | ||
| 314 | const char * | |
| 15884 | 315 | purple_account_option_get_default_string(const PurpleAccountOption *option) |
| 5639 | 316 | { |
| 317 | g_return_val_if_fail(option != NULL, NULL); | |
| 15884 | 318 | g_return_val_if_fail(option->type == PURPLE_PREF_STRING, NULL); |
| 5639 | 319 | |
| 320 | return option->default_value.string; | |
| 321 | } | |
| 322 | ||
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
323 | const char * |
| 15884 | 324 | purple_account_option_get_default_list_value(const PurpleAccountOption *option) |
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
325 | { |
| 15884 | 326 | PurpleKeyValuePair *kvp; |
|
12172
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
327 | |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
328 | g_return_val_if_fail(option != NULL, NULL); |
| 15884 | 329 | 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
|
330 | |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
331 | if (option->default_value.list == NULL) |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
332 | return NULL; |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
333 | |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
334 | kvp = option->default_value.list->data; |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
335 | |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
336 | return (kvp ? kvp->value : NULL); |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
337 | } |
|
717fa0ec02c4
[gaim-migrate @ 14474]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10658
diff
changeset
|
338 | |
| 10658 | 339 | gboolean |
|
33267
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
340 | purple_account_option_string_get_masked(const PurpleAccountOption *option) |
| 10658 | 341 | { |
| 342 | g_return_val_if_fail(option != NULL, FALSE); | |
| 15884 | 343 | g_return_val_if_fail(option->type == PURPLE_PREF_STRING, FALSE); |
| 10658 | 344 | |
|
33267
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
345 | return option->params.string.masked; |
|
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
346 | } |
|
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
347 | |
|
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
348 | const GSList * |
|
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
349 | purple_account_option_string_get_hints(const PurpleAccountOption *option) |
|
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
350 | { |
|
39980
54284ab06efd
Fix some minor new warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39972
diff
changeset
|
351 | g_return_val_if_fail(option != NULL, NULL); |
|
54284ab06efd
Fix some minor new warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39972
diff
changeset
|
352 | g_return_val_if_fail(option->type == PURPLE_PREF_STRING, NULL); |
|
33267
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
353 | |
|
c3ee96290bfd
Account Options: hinted string options; fix perl plugins compilation
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
32438
diff
changeset
|
354 | return option->params.string.hints; |
| 10658 | 355 | } |
| 356 | ||
|
18190
bcf28ef7e8ff
Re-fix the DBus list handling code by killing const GList* / const GSList*
Richard Laager <rlaager@pidgin.im>
parents:
18099
diff
changeset
|
357 | GList * |
| 15884 | 358 | purple_account_option_get_list(const PurpleAccountOption *option) |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
359 | { |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
360 | g_return_val_if_fail(option != NULL, NULL); |
| 15884 | 361 | g_return_val_if_fail(option->type == PURPLE_PREF_STRING_LIST, NULL); |
| 5639 | 362 | |
|
8570
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
363 | return option->default_value.list; |
|
bce05cb55dbc
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
364 | } |