annotate src/accountopt.c @ 12561:e8314f98b870

[gaim-migrate @ 14880] Various changes as per SF #1384517. This should get us closer to working out of the box on IRIX, hopefully without breaking anything else. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Mon, 19 Dec 2005 12:48:13 +0000
parents d5937f126c60
children f09c6e8df82c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /**
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * @file accountopt.c Account Options API
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 * @ingroup core
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 * gaim
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
6 *
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 6902
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 6902
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 6902
diff changeset
9 * source distribution.
6902
e30bedfb99db [gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents: 5663
diff changeset
10 *
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 * (at your option) any later version.
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 * GNU General Public License for more details.
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 */
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 #include "accountopt.h"
12172
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
26 #include "util.h"
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
28 GaimAccountOption *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
29 gaim_account_option_new(GaimPrefType type, const char *text,
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 const char *pref_name)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32 GaimAccountOption *option;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33
8570
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
34 g_return_val_if_fail(type != GAIM_PREF_NONE, NULL);
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
35 g_return_val_if_fail(text != NULL, NULL);
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
36 g_return_val_if_fail(pref_name != NULL, NULL);
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
38 option = g_new0(GaimAccountOption, 1);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40 option->type = type;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
41 option->text = g_strdup(text);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
42 option->pref_name = g_strdup(pref_name);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
43
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
44 return option;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
45 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
46
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47 GaimAccountOption *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 gaim_account_option_bool_new(const char *text, const char *pref_name,
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
49 gboolean default_value)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 GaimAccountOption *option;
6902
e30bedfb99db [gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents: 5663
diff changeset
52
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 option = gaim_account_option_new(GAIM_PREF_BOOLEAN, text, pref_name);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 if (option == NULL)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 return NULL;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 option->default_value.boolean = default_value;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60 return option;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 GaimAccountOption *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 gaim_account_option_int_new(const char *text, const char *pref_name,
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 int default_value)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 GaimAccountOption *option;
6902
e30bedfb99db [gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents: 5663
diff changeset
68
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 option = gaim_account_option_new(GAIM_PREF_INT, text, pref_name);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
70
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 if (option == NULL)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 return NULL;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
73
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 option->default_value.integer = default_value;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76 return option;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
78
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
79 GaimAccountOption *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
80 gaim_account_option_string_new(const char *text, const char *pref_name,
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
81 const char *default_value)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
82 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
83 GaimAccountOption *option;
6902
e30bedfb99db [gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents: 5663
diff changeset
84
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 option = gaim_account_option_new(GAIM_PREF_STRING, text, pref_name);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 if (option == NULL)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 return NULL;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 if (default_value != NULL)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91 option->default_value.string = g_strdup(default_value);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93 return option;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95
8570
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
96 GaimAccountOption *
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
97 gaim_account_option_list_new(const char *text, const char *pref_name,
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
98 GList *list)
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
99 {
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
100 GaimAccountOption *option;
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
101
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
102 option = gaim_account_option_new(GAIM_PREF_STRING_LIST, text, pref_name);
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
103
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
104 if (option == NULL)
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
105 return NULL;
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
106
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
107 option->default_value.list = list;
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
108
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
109 return option;
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
110 }
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
111
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
112 void
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
113 gaim_account_option_destroy(GaimAccountOption *option)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
114 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
115 g_return_if_fail(option != NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
116
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
117 if (option->text != NULL)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
118 g_free(option->text);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
119
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
120 if (option->pref_name != NULL)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
121 g_free(option->pref_name);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
122
8570
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
123 if (option->type == GAIM_PREF_STRING)
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
124 {
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
125 if (option->default_value.string != NULL)
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
126 g_free(option->default_value.string);
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
127 }
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
128 else if (option->type == GAIM_PREF_STRING_LIST)
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
129 {
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
130 if (option->default_value.list != NULL)
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
131 {
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
132 g_list_foreach(option->default_value.list, (GFunc)g_free, NULL);
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
133 g_list_free(option->default_value.list);
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
134 }
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
135 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
136
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
137 g_free(option);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
138 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
139
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
140 void
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
141 gaim_account_option_set_default_bool(GaimAccountOption *option,
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
142 gboolean value)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
143 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
144 g_return_if_fail(option != NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
145 g_return_if_fail(option->type == GAIM_PREF_BOOLEAN);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
146
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
147 option->default_value.boolean = value;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
148 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
149
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 void
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 gaim_account_option_set_default_int(GaimAccountOption *option, int value)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153 g_return_if_fail(option != NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 g_return_if_fail(option->type == GAIM_PREF_INT);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 option->default_value.integer = value;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
159 void
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
160 gaim_account_option_set_default_string(GaimAccountOption *option,
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
161 const char *value)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
162 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
163 g_return_if_fail(option != NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
164 g_return_if_fail(option->type == GAIM_PREF_STRING);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
165
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
166 if (option->default_value.string != NULL)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
167 g_free(option->default_value.string);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
168
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
169 option->default_value.string = (value == NULL ? NULL : g_strdup(value));
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
170 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
171
8570
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
172 void
10658
61930cadca7c [gaim-migrate @ 12190]
Mark Doliner <mark@kingant.net>
parents: 8570
diff changeset
173 gaim_account_option_set_masked(GaimAccountOption *option, gboolean masked)
61930cadca7c [gaim-migrate @ 12190]
Mark Doliner <mark@kingant.net>
parents: 8570
diff changeset
174 {
61930cadca7c [gaim-migrate @ 12190]
Mark Doliner <mark@kingant.net>
parents: 8570
diff changeset
175 g_return_if_fail(option != NULL);
61930cadca7c [gaim-migrate @ 12190]
Mark Doliner <mark@kingant.net>
parents: 8570
diff changeset
176 g_return_if_fail(option->type == GAIM_PREF_STRING);
61930cadca7c [gaim-migrate @ 12190]
Mark Doliner <mark@kingant.net>
parents: 8570
diff changeset
177
61930cadca7c [gaim-migrate @ 12190]
Mark Doliner <mark@kingant.net>
parents: 8570
diff changeset
178 option->masked = masked;
61930cadca7c [gaim-migrate @ 12190]
Mark Doliner <mark@kingant.net>
parents: 8570
diff changeset
179 }
61930cadca7c [gaim-migrate @ 12190]
Mark Doliner <mark@kingant.net>
parents: 8570
diff changeset
180
61930cadca7c [gaim-migrate @ 12190]
Mark Doliner <mark@kingant.net>
parents: 8570
diff changeset
181
61930cadca7c [gaim-migrate @ 12190]
Mark Doliner <mark@kingant.net>
parents: 8570
diff changeset
182 void
8570
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
183 gaim_account_option_set_list(GaimAccountOption *option, GList *values)
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
184 {
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
185 g_return_if_fail(option != NULL);
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
186 g_return_if_fail(option->type == GAIM_PREF_STRING_LIST);
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
187
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
188 if (option->default_value.list != NULL)
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
189 {
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
190 g_list_foreach(option->default_value.list, (GFunc)g_free, NULL);
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
191 g_list_free(option->default_value.list);
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
192 }
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
193
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
194 option->default_value.list = values;
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
195 }
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
196
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
197 void
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
198 gaim_account_option_add_list_item(GaimAccountOption *option,
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
199 const char *key, const char *value)
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
200 {
12172
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
201 GaimKeyValuePair *kvp;
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
202
8570
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
203 g_return_if_fail(option != NULL);
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
204 g_return_if_fail(key != NULL);
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
205 g_return_if_fail(value != NULL);
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
206 g_return_if_fail(option->type == GAIM_PREF_STRING_LIST);
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
207
12172
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
208 kvp = g_new0(GaimKeyValuePair, 1);
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
209 kvp->key = g_strdup(key);
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
210 kvp->value = g_strdup(value);
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
211
8570
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
212 option->default_value.list = g_list_append(option->default_value.list,
12172
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
213 kvp);
8570
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
214 }
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
215
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
216 GaimPrefType
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
217 gaim_account_option_get_type(const GaimAccountOption *option)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
218 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
219 g_return_val_if_fail(option != NULL, GAIM_PREF_NONE);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
220
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
221 return option->type;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
222 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
223
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
224 const char *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
225 gaim_account_option_get_text(const GaimAccountOption *option)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
226 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
227 g_return_val_if_fail(option != NULL, NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
228
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
229 return option->text;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
230 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
231
5660
1709a545a7bd [gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents: 5654
diff changeset
232 const char *
1709a545a7bd [gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents: 5654
diff changeset
233 gaim_account_option_get_setting(const GaimAccountOption *option)
1709a545a7bd [gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents: 5654
diff changeset
234 {
1709a545a7bd [gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents: 5654
diff changeset
235 g_return_val_if_fail(option != NULL, NULL);
1709a545a7bd [gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents: 5654
diff changeset
236
1709a545a7bd [gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents: 5654
diff changeset
237 return option->pref_name;
1709a545a7bd [gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents: 5654
diff changeset
238 }
1709a545a7bd [gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents: 5654
diff changeset
239
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
240 gboolean
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
241 gaim_account_option_get_default_bool(const GaimAccountOption *option)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
242 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
243 g_return_val_if_fail(option != NULL, FALSE);
5663
e9551e7d6f01 [gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents: 5660
diff changeset
244 g_return_val_if_fail(option->type == GAIM_PREF_BOOLEAN, FALSE);
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
245
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
246 return option->default_value.boolean;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
247 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
248
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
249 int
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
250 gaim_account_option_get_default_int(const GaimAccountOption *option)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
251 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
252 g_return_val_if_fail(option != NULL, -1);
5663
e9551e7d6f01 [gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents: 5660
diff changeset
253 g_return_val_if_fail(option->type == GAIM_PREF_INT, -1);
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
254
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
255 return option->default_value.integer;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
256 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
257
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
258 const char *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
259 gaim_account_option_get_default_string(const GaimAccountOption *option)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
260 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
261 g_return_val_if_fail(option != NULL, NULL);
5663
e9551e7d6f01 [gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents: 5660
diff changeset
262 g_return_val_if_fail(option->type == GAIM_PREF_STRING, NULL);
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
263
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
264 return option->default_value.string;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
265 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
266
12172
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
267 const char *
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
268 gaim_account_option_get_default_list_value(const GaimAccountOption *option)
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
269 {
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
270 GaimKeyValuePair *kvp;
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
271
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
272 g_return_val_if_fail(option != NULL, NULL);
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
273 g_return_val_if_fail(option->type == GAIM_PREF_STRING_LIST, NULL);
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
274
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
275 if (option->default_value.list == NULL)
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
276 return NULL;
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
277
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
278 kvp = option->default_value.list->data;
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
279
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
280 return (kvp ? kvp->value : NULL);
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
281 }
d5937f126c60 [gaim-migrate @ 14474]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10658
diff changeset
282
10658
61930cadca7c [gaim-migrate @ 12190]
Mark Doliner <mark@kingant.net>
parents: 8570
diff changeset
283 gboolean
61930cadca7c [gaim-migrate @ 12190]
Mark Doliner <mark@kingant.net>
parents: 8570
diff changeset
284 gaim_account_option_get_masked(const GaimAccountOption *option)
61930cadca7c [gaim-migrate @ 12190]
Mark Doliner <mark@kingant.net>
parents: 8570
diff changeset
285 {
61930cadca7c [gaim-migrate @ 12190]
Mark Doliner <mark@kingant.net>
parents: 8570
diff changeset
286 g_return_val_if_fail(option != NULL, FALSE);
61930cadca7c [gaim-migrate @ 12190]
Mark Doliner <mark@kingant.net>
parents: 8570
diff changeset
287 g_return_val_if_fail(option->type == GAIM_PREF_STRING, FALSE);
61930cadca7c [gaim-migrate @ 12190]
Mark Doliner <mark@kingant.net>
parents: 8570
diff changeset
288
61930cadca7c [gaim-migrate @ 12190]
Mark Doliner <mark@kingant.net>
parents: 8570
diff changeset
289 return option->masked;
61930cadca7c [gaim-migrate @ 12190]
Mark Doliner <mark@kingant.net>
parents: 8570
diff changeset
290 }
61930cadca7c [gaim-migrate @ 12190]
Mark Doliner <mark@kingant.net>
parents: 8570
diff changeset
291
8570
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
292 const GList *
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
293 gaim_account_option_get_list(const GaimAccountOption *option)
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
294 {
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
295 g_return_val_if_fail(option != NULL, NULL);
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
296 g_return_val_if_fail(option->type == GAIM_PREF_STRING_LIST, NULL);
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
297
8570
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
298 return option->default_value.list;
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
299 }
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
300
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
301 /**************************************************************************
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
302 * Account User Split API
1a62ab7225f3 [gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents: 8046
diff changeset
303 **************************************************************************/
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
304 GaimAccountUserSplit *
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
305 gaim_account_user_split_new(const char *text, const char *default_value,
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
306 char sep)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
307 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
308 GaimAccountUserSplit *split;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
309
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
310 g_return_val_if_fail(text != NULL, NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
311 g_return_val_if_fail(sep != 0, NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
312
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
313 split = g_new0(GaimAccountUserSplit, 1);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
314
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
315 split->text = g_strdup(text);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
316 split->field_sep = sep;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
317 split->default_value = (default_value == NULL
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
318 ? NULL : g_strdup(default_value));
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
319
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
320 return split;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
321 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
322
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
323 void
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
324 gaim_account_user_split_destroy(GaimAccountUserSplit *split)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
325 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
326 g_return_if_fail(split != NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
327
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
328 if (split->text != NULL)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
329 g_free(split->text);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
330
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
331 if (split->default_value != NULL)
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
332 g_free(split->default_value);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
333
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
334 g_free(split);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
335 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
336
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
337 const char *
5654
c52a97f3739e [gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents: 5639
diff changeset
338 gaim_account_user_split_get_text(const GaimAccountUserSplit *split)
c52a97f3739e [gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents: 5639
diff changeset
339 {
c52a97f3739e [gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents: 5639
diff changeset
340 g_return_val_if_fail(split != NULL, NULL);
c52a97f3739e [gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents: 5639
diff changeset
341
c52a97f3739e [gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents: 5639
diff changeset
342 return split->text;
c52a97f3739e [gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents: 5639
diff changeset
343 }
c52a97f3739e [gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents: 5639
diff changeset
344
c52a97f3739e [gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents: 5639
diff changeset
345 const char *
c52a97f3739e [gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents: 5639
diff changeset
346 gaim_account_user_split_get_default_value(const GaimAccountUserSplit *split)
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
347 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
348 g_return_val_if_fail(split != NULL, NULL);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
349
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
350 return split->default_value;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
351 }
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
352
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
353 char
5654
c52a97f3739e [gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents: 5639
diff changeset
354 gaim_account_user_split_get_separator(const GaimAccountUserSplit *split)
5639
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
355 {
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
356 g_return_val_if_fail(split != NULL, 0);
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
357
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
358 return split->field_sep;
408fef845144 [gaim-migrate @ 6051]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
359 }