Mercurial > pidgin
annotate src/accountopt.c @ 12116:e75ef7aa913e
[gaim-migrate @ 14416]
" This patch implements a replacement for the queuing
system from 1.x. It also obsoletes a previous patch
[#1338873] I submitted to prioritize the unseen states
in gtk conversations.
The attached envelope.png is ripped from the
msgunread.png already included in gaim. It should be
dropped in the pixmaps directory (Makefile.am is
updated accordingly in this patch).
The two separate queuing preferences from 1.x, queuing
messages while away and queuing all new messages (from
docklet), are replaced with a single 3-way preference
for conversations. The new preference is "Hide new IM
conversations". This preference can be set to never,
away and always.
When a gtk conversation is created, it may be placed in
a hidden conversation window instead of being placed
normally. This decision is based upon the preference
and possibly the away state of the account the
conversation is being created for. This *will* effect
conversations the user explicitly requests to be
created, so in these cases the caller must be sure to
present the conversation to the user, using
gaim_gtkconv_present_conversation(). This is done
already in gtkdialogs.c which handles creating
conversations requested by the user from gaim proper
(menus, double-clicking on budy in blist, etc.).
The main advantage to not queuing messages is that the
conversations exist, the message is written to the
conversation (and logged if appropriate) and the unseen
state is set on the conversation. This means no
additional features are needed to track whether there
are queued messages or not, just use the unseen state
on conversations.
Since conversations may not be visible (messages
"queued"), gaim proper needs some notification that
there are messages waiting. I opted for a menutray icon
that shows up when an im conversation has an unseen
message. Clicking this icon will focus (and show if
hidden) the first conversation with an unseen message.
This is essentially the same behavior of the docklet in
cvs right now, except that the icon is only visible
when there is a conversation with an unread message.
The api that is added is flexible enough to allow
either the docklet or the new blist menutray icon to be
visible for conversations of any/all types and for
unseen messages >= any state. Currently they are set to
only IM conversations and only unseen states >= TEXT
(system messages and no log messages will not trigger
blinking the docklet or showing the blist tray icon),
but these could be made preferences relatively easily
in the future. Other plugins could probably benefit as
well: gaim_gtk_conversations_get_first_unseen().
There is probably some limit to comment size, so I'll
stop rambling now. If anyone has more
questions/comments, catch me in #gaim, here or on
gaim-devel."
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Wed, 16 Nov 2005 18:17:01 +0000 |
parents | 61930cadca7c |
children | d5937f126c60 |
rev | line source |
---|---|
5639 | 1 /** |
2 * @file accountopt.c Account Options API | |
3 * @ingroup core | |
4 * | |
5 * gaim | |
6 * | |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
6902
e30bedfb99db
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
10 * |
5639 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
25 #include "accountopt.h" | |
26 | |
27 GaimAccountOption * | |
28 gaim_account_option_new(GaimPrefType type, const char *text, | |
29 const char *pref_name) | |
30 { | |
31 GaimAccountOption *option; | |
32 | |
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
33 g_return_val_if_fail(type != GAIM_PREF_NONE, NULL); |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
34 g_return_val_if_fail(text != NULL, NULL); |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
35 g_return_val_if_fail(pref_name != NULL, NULL); |
5639 | 36 |
37 option = g_new0(GaimAccountOption, 1); | |
38 | |
39 option->type = type; | |
40 option->text = g_strdup(text); | |
41 option->pref_name = g_strdup(pref_name); | |
42 | |
43 return option; | |
44 } | |
45 | |
46 GaimAccountOption * | |
47 gaim_account_option_bool_new(const char *text, const char *pref_name, | |
48 gboolean default_value) | |
49 { | |
50 GaimAccountOption *option; | |
6902
e30bedfb99db
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
51 |
5639 | 52 option = gaim_account_option_new(GAIM_PREF_BOOLEAN, text, pref_name); |
53 | |
54 if (option == NULL) | |
55 return NULL; | |
56 | |
57 option->default_value.boolean = default_value; | |
58 | |
59 return option; | |
60 } | |
61 | |
62 GaimAccountOption * | |
63 gaim_account_option_int_new(const char *text, const char *pref_name, | |
64 int default_value) | |
65 { | |
66 GaimAccountOption *option; | |
6902
e30bedfb99db
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
67 |
5639 | 68 option = gaim_account_option_new(GAIM_PREF_INT, text, pref_name); |
69 | |
70 if (option == NULL) | |
71 return NULL; | |
72 | |
73 option->default_value.integer = default_value; | |
74 | |
75 return option; | |
76 } | |
77 | |
78 GaimAccountOption * | |
79 gaim_account_option_string_new(const char *text, const char *pref_name, | |
80 const char *default_value) | |
81 { | |
82 GaimAccountOption *option; | |
6902
e30bedfb99db
[gaim-migrate @ 7449]
Christian Hammond <chipx86@chipx86.com>
parents:
5663
diff
changeset
|
83 |
5639 | 84 option = gaim_account_option_new(GAIM_PREF_STRING, text, pref_name); |
85 | |
86 if (option == NULL) | |
87 return NULL; | |
88 | |
89 if (default_value != NULL) | |
90 option->default_value.string = g_strdup(default_value); | |
91 | |
92 return option; | |
93 } | |
94 | |
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
95 GaimAccountOption * |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
96 gaim_account_option_list_new(const char *text, const char *pref_name, |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
97 GList *list) |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
98 { |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
99 GaimAccountOption *option; |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
100 |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
101 option = gaim_account_option_new(GAIM_PREF_STRING_LIST, text, pref_name); |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
102 |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
103 if (option == NULL) |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
104 return NULL; |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
105 |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
106 option->default_value.list = list; |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
107 |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
108 return option; |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
109 } |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
110 |
5639 | 111 void |
112 gaim_account_option_destroy(GaimAccountOption *option) | |
113 { | |
114 g_return_if_fail(option != NULL); | |
115 | |
116 if (option->text != NULL) | |
117 g_free(option->text); | |
118 | |
119 if (option->pref_name != NULL) | |
120 g_free(option->pref_name); | |
121 | |
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
122 if (option->type == GAIM_PREF_STRING) |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
123 { |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
124 if (option->default_value.string != NULL) |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
125 g_free(option->default_value.string); |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
126 } |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
127 else if (option->type == GAIM_PREF_STRING_LIST) |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
128 { |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
129 if (option->default_value.list != NULL) |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
130 { |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
131 g_list_foreach(option->default_value.list, (GFunc)g_free, NULL); |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
132 g_list_free(option->default_value.list); |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
133 } |
5639 | 134 } |
135 | |
136 g_free(option); | |
137 } | |
138 | |
139 void | |
140 gaim_account_option_set_default_bool(GaimAccountOption *option, | |
141 gboolean value) | |
142 { | |
143 g_return_if_fail(option != NULL); | |
144 g_return_if_fail(option->type == GAIM_PREF_BOOLEAN); | |
145 | |
146 option->default_value.boolean = value; | |
147 } | |
148 | |
149 void | |
150 gaim_account_option_set_default_int(GaimAccountOption *option, int value) | |
151 { | |
152 g_return_if_fail(option != NULL); | |
153 g_return_if_fail(option->type == GAIM_PREF_INT); | |
154 | |
155 option->default_value.integer = value; | |
156 } | |
157 | |
158 void | |
159 gaim_account_option_set_default_string(GaimAccountOption *option, | |
160 const char *value) | |
161 { | |
162 g_return_if_fail(option != NULL); | |
163 g_return_if_fail(option->type == GAIM_PREF_STRING); | |
164 | |
165 if (option->default_value.string != NULL) | |
166 g_free(option->default_value.string); | |
167 | |
168 option->default_value.string = (value == NULL ? NULL : g_strdup(value)); | |
169 } | |
170 | |
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
171 void |
10658 | 172 gaim_account_option_set_masked(GaimAccountOption *option, gboolean masked) |
173 { | |
174 g_return_if_fail(option != NULL); | |
175 g_return_if_fail(option->type == GAIM_PREF_STRING); | |
176 | |
177 option->masked = masked; | |
178 } | |
179 | |
180 | |
181 void | |
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
182 gaim_account_option_set_list(GaimAccountOption *option, GList *values) |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
183 { |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
184 g_return_if_fail(option != NULL); |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
185 g_return_if_fail(option->type == GAIM_PREF_STRING_LIST); |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
186 |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
187 if (option->default_value.list != NULL) |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
188 { |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
189 g_list_foreach(option->default_value.list, (GFunc)g_free, NULL); |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
190 g_list_free(option->default_value.list); |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
191 } |
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 option->default_value.list = values; |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
194 } |
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 void |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
197 gaim_account_option_add_list_item(GaimAccountOption *option, |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
198 const char *key, const char *value) |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
199 { |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
200 g_return_if_fail(option != NULL); |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
201 g_return_if_fail(key != NULL); |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
202 g_return_if_fail(value != NULL); |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
203 g_return_if_fail(option->type == GAIM_PREF_STRING_LIST); |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
204 |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
205 option->default_value.list = g_list_append(option->default_value.list, |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
206 g_strdup(key)); |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
207 option->default_value.list = g_list_append(option->default_value.list, |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
208 g_strdup(value)); |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
209 } |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
210 |
5639 | 211 GaimPrefType |
212 gaim_account_option_get_type(const GaimAccountOption *option) | |
213 { | |
214 g_return_val_if_fail(option != NULL, GAIM_PREF_NONE); | |
215 | |
216 return option->type; | |
217 } | |
218 | |
219 const char * | |
220 gaim_account_option_get_text(const GaimAccountOption *option) | |
221 { | |
222 g_return_val_if_fail(option != NULL, NULL); | |
223 | |
224 return option->text; | |
225 } | |
226 | |
5660
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
227 const char * |
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
228 gaim_account_option_get_setting(const GaimAccountOption *option) |
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
229 { |
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
230 g_return_val_if_fail(option != NULL, NULL); |
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
231 |
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
232 return option->pref_name; |
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
233 } |
1709a545a7bd
[gaim-migrate @ 6074]
Christian Hammond <chipx86@chipx86.com>
parents:
5654
diff
changeset
|
234 |
5639 | 235 gboolean |
236 gaim_account_option_get_default_bool(const GaimAccountOption *option) | |
237 { | |
238 g_return_val_if_fail(option != NULL, FALSE); | |
5663
e9551e7d6f01
[gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents:
5660
diff
changeset
|
239 g_return_val_if_fail(option->type == GAIM_PREF_BOOLEAN, FALSE); |
5639 | 240 |
241 return option->default_value.boolean; | |
242 } | |
243 | |
244 int | |
245 gaim_account_option_get_default_int(const GaimAccountOption *option) | |
246 { | |
247 g_return_val_if_fail(option != NULL, -1); | |
5663
e9551e7d6f01
[gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents:
5660
diff
changeset
|
248 g_return_val_if_fail(option->type == GAIM_PREF_INT, -1); |
5639 | 249 |
250 return option->default_value.integer; | |
251 } | |
252 | |
253 const char * | |
254 gaim_account_option_get_default_string(const GaimAccountOption *option) | |
255 { | |
256 g_return_val_if_fail(option != NULL, NULL); | |
5663
e9551e7d6f01
[gaim-migrate @ 6077]
Christian Hammond <chipx86@chipx86.com>
parents:
5660
diff
changeset
|
257 g_return_val_if_fail(option->type == GAIM_PREF_STRING, NULL); |
5639 | 258 |
259 return option->default_value.string; | |
260 } | |
261 | |
10658 | 262 gboolean |
263 gaim_account_option_get_masked(const GaimAccountOption *option) | |
264 { | |
265 g_return_val_if_fail(option != NULL, FALSE); | |
266 g_return_val_if_fail(option->type == GAIM_PREF_STRING, FALSE); | |
267 | |
268 return option->masked; | |
269 } | |
270 | |
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
271 const GList * |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
272 gaim_account_option_get_list(const GaimAccountOption *option) |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
273 { |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
274 g_return_val_if_fail(option != NULL, NULL); |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
275 g_return_val_if_fail(option->type == GAIM_PREF_STRING_LIST, NULL); |
5639 | 276 |
8570
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
277 return option->default_value.list; |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
278 } |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
279 |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
280 /************************************************************************** |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
281 * Account User Split API |
1a62ab7225f3
[gaim-migrate @ 9318]
Christian Hammond <chipx86@chipx86.com>
parents:
8046
diff
changeset
|
282 **************************************************************************/ |
5639 | 283 GaimAccountUserSplit * |
284 gaim_account_user_split_new(const char *text, const char *default_value, | |
285 char sep) | |
286 { | |
287 GaimAccountUserSplit *split; | |
288 | |
289 g_return_val_if_fail(text != NULL, NULL); | |
290 g_return_val_if_fail(sep != 0, NULL); | |
291 | |
292 split = g_new0(GaimAccountUserSplit, 1); | |
293 | |
294 split->text = g_strdup(text); | |
295 split->field_sep = sep; | |
296 split->default_value = (default_value == NULL | |
297 ? NULL : g_strdup(default_value)); | |
298 | |
299 return split; | |
300 } | |
301 | |
302 void | |
303 gaim_account_user_split_destroy(GaimAccountUserSplit *split) | |
304 { | |
305 g_return_if_fail(split != NULL); | |
306 | |
307 if (split->text != NULL) | |
308 g_free(split->text); | |
309 | |
310 if (split->default_value != NULL) | |
311 g_free(split->default_value); | |
312 | |
313 g_free(split); | |
314 } | |
315 | |
316 const char * | |
5654
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
317 gaim_account_user_split_get_text(const GaimAccountUserSplit *split) |
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
318 { |
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
319 g_return_val_if_fail(split != NULL, NULL); |
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
320 |
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
321 return split->text; |
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
322 } |
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
323 |
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
324 const char * |
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
325 gaim_account_user_split_get_default_value(const GaimAccountUserSplit *split) |
5639 | 326 { |
327 g_return_val_if_fail(split != NULL, NULL); | |
328 | |
329 return split->default_value; | |
330 } | |
331 | |
332 char | |
5654
c52a97f3739e
[gaim-migrate @ 6068]
Christian Hammond <chipx86@chipx86.com>
parents:
5639
diff
changeset
|
333 gaim_account_user_split_get_separator(const GaimAccountUserSplit *split) |
5639 | 334 { |
335 g_return_val_if_fail(split != NULL, 0); | |
336 | |
337 return split->field_sep; | |
338 } |