Mercurial > pidgin
annotate libgaim/notify.c @ 15289:fbc9a92547d8
[gaim-migrate @ 18079]
I'm not sure if relying on gaim_account_get_buddy_icon_path() here is right; using libgaim from Adium, I've only ever called gaim_account_set_buddy_icon(), which doesn't appear to update the the buddy_icon_path for the account. In any case, this no longer crashes if gaim_account_get_buddy_icon_path() returns NULL.
committer: Tailor Script <tailor@pidgin.im>
author | Evan Schoenberg <evan.s@dreskin.net> |
---|---|
date | Sat, 06 Jan 2007 17:36:48 +0000 |
parents | 132db06150ca |
children |
rev | line source |
---|---|
14192 | 1 /** |
2 * @file notify.c Notification API | |
3 * @ingroup core | |
4 * | |
5 * gaim | |
6 * | |
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. | |
10 * | |
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 "notify.h" | |
26 | |
27 static GaimNotifyUiOps *notify_ui_ops = NULL; | |
28 static GList *handles = NULL; | |
29 | |
30 typedef struct | |
31 { | |
32 GaimNotifyType type; | |
33 void *handle; | |
34 void *ui_handle; | |
35 GaimNotifyCloseCallback cb; | |
36 gpointer cb_user_data; | |
37 } GaimNotifyInfo; | |
38 | |
15143
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
39 /** |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
40 * Definition of a user info entry |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
41 */ |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
42 struct _GaimNotifyUserInfoEntry |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
43 { |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
44 char *label; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
45 char *value; |
15149
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
46 GaimNotifyUserInfoEntryType type; |
15143
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
47 }; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
48 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
49 struct _GaimNotifyUserInfo |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
50 { |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
51 GList *user_info_entries; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
52 }; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
53 |
14192 | 54 void * |
55 gaim_notify_message(void *handle, GaimNotifyMsgType type, | |
56 const char *title, const char *primary, | |
57 const char *secondary, GaimNotifyCloseCallback cb, gpointer user_data) | |
58 { | |
59 GaimNotifyUiOps *ops; | |
60 | |
61 g_return_val_if_fail(primary != NULL, NULL); | |
62 | |
63 ops = gaim_notify_get_ui_ops(); | |
64 | |
65 if (ops != NULL && ops->notify_message != NULL) { | |
66 GaimNotifyInfo *info; | |
67 | |
68 info = g_new0(GaimNotifyInfo, 1); | |
69 info->type = GAIM_NOTIFY_MESSAGE; | |
70 info->handle = handle; | |
71 info->ui_handle = ops->notify_message(type, title, primary, | |
72 secondary); | |
73 info->cb = cb; | |
74 info->cb_user_data = user_data; | |
75 | |
76 if (info->ui_handle != NULL) { | |
77 handles = g_list_append(handles, info); | |
78 | |
79 return info->ui_handle; | |
80 | |
81 } else { | |
82 if (info->cb != NULL) | |
83 info->cb(info->cb_user_data); | |
84 | |
85 g_free(info); | |
86 | |
87 return NULL; | |
88 } | |
89 | |
90 } else { | |
91 if (cb != NULL) | |
92 cb(user_data); | |
93 } | |
94 | |
95 return NULL; | |
96 } | |
97 | |
98 void * | |
99 gaim_notify_email(void *handle, const char *subject, const char *from, | |
100 const char *to, const char *url, GaimNotifyCloseCallback cb, | |
101 gpointer user_data) | |
102 { | |
103 GaimNotifyUiOps *ops; | |
104 | |
105 ops = gaim_notify_get_ui_ops(); | |
106 | |
107 if (ops != NULL && ops->notify_email != NULL) { | |
108 GaimNotifyInfo *info; | |
109 | |
110 info = g_new0(GaimNotifyInfo, 1); | |
111 info->type = GAIM_NOTIFY_EMAIL; | |
112 info->handle = handle; | |
113 info->ui_handle = ops->notify_email(handle, subject, from, to, url); | |
114 info->cb = cb; | |
115 info->cb_user_data = user_data; | |
116 | |
117 if (info->ui_handle != NULL) { | |
118 handles = g_list_append(handles, info); | |
119 | |
120 return info->ui_handle; | |
121 | |
122 } else { | |
123 if (info->cb != NULL) | |
124 info->cb(info->cb_user_data); | |
125 | |
126 g_free(info); | |
127 | |
128 return NULL; | |
129 } | |
130 } else { | |
131 if (cb != NULL) | |
132 cb(user_data); | |
133 } | |
134 | |
135 return NULL; | |
136 } | |
137 | |
138 void * | |
139 gaim_notify_emails(void *handle, size_t count, gboolean detailed, | |
140 const char **subjects, const char **froms, | |
141 const char **tos, const char **urls, | |
142 GaimNotifyCloseCallback cb, gpointer user_data) | |
143 { | |
144 GaimNotifyUiOps *ops; | |
145 | |
146 g_return_val_if_fail(count != 0, NULL); | |
147 | |
148 if (count == 1) { | |
149 return gaim_notify_email(handle, | |
150 (subjects == NULL ? NULL : *subjects), | |
151 (froms == NULL ? NULL : *froms), | |
152 (tos == NULL ? NULL : *tos), | |
153 (urls == NULL ? NULL : *urls), | |
154 cb, user_data); | |
155 } | |
156 | |
157 ops = gaim_notify_get_ui_ops(); | |
158 | |
159 if (ops != NULL && ops->notify_emails != NULL) { | |
160 GaimNotifyInfo *info; | |
161 | |
162 info = g_new0(GaimNotifyInfo, 1); | |
163 info->type = GAIM_NOTIFY_EMAILS; | |
164 info->handle = handle; | |
165 info->ui_handle = ops->notify_emails(handle, count, detailed, subjects, | |
166 froms, tos, urls); | |
167 info->cb = cb; | |
168 info->cb_user_data = user_data; | |
169 | |
170 if (info->ui_handle != NULL) { | |
171 handles = g_list_append(handles, info); | |
172 | |
173 return info->ui_handle; | |
174 | |
175 } else { | |
176 if (info->cb != NULL) | |
177 info->cb(info->cb_user_data); | |
178 | |
179 g_free(info); | |
180 | |
181 return NULL; | |
182 } | |
183 | |
184 } else { | |
185 if (cb != NULL) | |
186 cb(user_data); | |
187 } | |
188 | |
189 return NULL; | |
190 } | |
191 | |
192 void * | |
193 gaim_notify_formatted(void *handle, const char *title, const char *primary, | |
194 const char *secondary, const char *text, | |
195 GaimNotifyCloseCallback cb, gpointer user_data) | |
196 { | |
197 GaimNotifyUiOps *ops; | |
198 | |
199 g_return_val_if_fail(primary != NULL, NULL); | |
200 | |
201 ops = gaim_notify_get_ui_ops(); | |
202 | |
203 if (ops != NULL && ops->notify_formatted != NULL) { | |
204 GaimNotifyInfo *info; | |
205 | |
206 info = g_new0(GaimNotifyInfo, 1); | |
207 info->type = GAIM_NOTIFY_FORMATTED; | |
208 info->handle = handle; | |
209 info->ui_handle = ops->notify_formatted(title, primary, secondary, text); | |
210 info->cb = cb; | |
211 info->cb_user_data = user_data; | |
212 | |
213 if (info->ui_handle != NULL) { | |
214 handles = g_list_append(handles, info); | |
215 | |
216 return info->ui_handle; | |
217 | |
218 } else { | |
219 if (info->cb != NULL) | |
220 info->cb(info->cb_user_data); | |
221 | |
222 g_free(info); | |
223 | |
224 return NULL; | |
225 } | |
226 | |
227 } else { | |
228 if (cb != NULL) | |
229 cb(user_data); | |
230 } | |
231 | |
232 return NULL; | |
233 } | |
234 | |
235 void * | |
236 gaim_notify_searchresults(GaimConnection *gc, const char *title, | |
237 const char *primary, const char *secondary, | |
238 GaimNotifySearchResults *results, GaimNotifyCloseCallback cb, | |
239 gpointer user_data) | |
240 { | |
241 GaimNotifyUiOps *ops; | |
242 | |
243 ops = gaim_notify_get_ui_ops(); | |
244 | |
245 if (ops != NULL && ops->notify_searchresults != NULL) { | |
246 GaimNotifyInfo *info; | |
247 | |
248 info = g_new0(GaimNotifyInfo, 1); | |
249 info->type = GAIM_NOTIFY_SEARCHRESULTS; | |
250 info->handle = gc; | |
251 info->ui_handle = ops->notify_searchresults(gc, title, primary, | |
252 secondary, results, user_data); | |
253 info->cb = cb; | |
254 info->cb_user_data = user_data; | |
255 | |
256 if (info->ui_handle != NULL) { | |
257 handles = g_list_append(handles, info); | |
258 | |
259 return info->ui_handle; | |
260 | |
261 } else { | |
262 if (info->cb != NULL) | |
263 info->cb(info->cb_user_data); | |
264 | |
265 g_free(info); | |
266 | |
267 return NULL; | |
268 } | |
269 | |
270 } else { | |
271 if (cb != NULL) | |
272 cb(user_data); | |
273 } | |
274 | |
275 return NULL; | |
276 } | |
277 | |
278 void | |
279 gaim_notify_searchresults_free(GaimNotifySearchResults *results) | |
280 { | |
281 GList *l; | |
282 | |
283 g_return_if_fail(results != NULL); | |
284 | |
285 for (l = results->buttons; l; l = g_list_delete_link(l, l)) { | |
286 GaimNotifySearchButton *button = l->data; | |
287 g_free(button->label); | |
288 g_free(button); | |
289 } | |
290 | |
291 for (l = results->rows; l; l = g_list_delete_link(l, l)) { | |
292 GList *row = l->data; | |
293 g_list_foreach(row, (GFunc)g_free, NULL); | |
294 g_list_free(row); | |
295 } | |
296 | |
297 for (l = results->columns; l; l = g_list_delete_link(l, l)) { | |
298 GaimNotifySearchColumn *column = l->data; | |
299 g_free(column->title); | |
300 g_free(column); | |
301 } | |
302 | |
303 g_free(results); | |
304 } | |
305 | |
306 void | |
307 gaim_notify_searchresults_new_rows(GaimConnection *gc, | |
308 GaimNotifySearchResults *results, | |
309 void *data) | |
310 { | |
311 GaimNotifyUiOps *ops; | |
312 | |
313 ops = gaim_notify_get_ui_ops(); | |
314 | |
315 if (ops != NULL && ops->notify_searchresults != NULL) { | |
316 ops->notify_searchresults_new_rows(gc, results, data); | |
317 } | |
318 } | |
319 | |
320 void | |
321 gaim_notify_searchresults_button_add(GaimNotifySearchResults *results, | |
322 GaimNotifySearchButtonType type, | |
323 GaimNotifySearchResultsCallback cb) | |
324 { | |
325 GaimNotifySearchButton *button; | |
326 | |
327 g_return_if_fail(results != NULL); | |
328 g_return_if_fail(cb != NULL); | |
329 | |
330 button = g_new0(GaimNotifySearchButton, 1); | |
331 button->callback = cb; | |
332 button->type = type; | |
333 | |
334 results->buttons = g_list_append(results->buttons, button); | |
335 } | |
336 | |
337 | |
338 void | |
339 gaim_notify_searchresults_button_add_labeled(GaimNotifySearchResults *results, | |
340 const char *label, | |
341 GaimNotifySearchResultsCallback cb) { | |
342 GaimNotifySearchButton *button; | |
343 | |
344 g_return_if_fail(results != NULL); | |
345 g_return_if_fail(cb != NULL); | |
346 g_return_if_fail(label != NULL); | |
347 g_return_if_fail(*label != '\0'); | |
348 | |
349 button = g_new0(GaimNotifySearchButton, 1); | |
350 button->callback = cb; | |
351 button->type = GAIM_NOTIFY_BUTTON_LABELED; | |
352 button->label = g_strdup(label); | |
353 | |
354 results->buttons = g_list_append(results->buttons, button); | |
355 } | |
356 | |
357 | |
358 GaimNotifySearchResults * | |
359 gaim_notify_searchresults_new() | |
360 { | |
361 GaimNotifySearchResults *rs = g_new0(GaimNotifySearchResults, 1); | |
362 | |
363 return rs; | |
364 } | |
365 | |
366 void | |
367 gaim_notify_searchresults_column_add(GaimNotifySearchResults *results, | |
368 GaimNotifySearchColumn *column) | |
369 { | |
370 g_return_if_fail(results != NULL); | |
371 g_return_if_fail(column != NULL); | |
372 | |
373 results->columns = g_list_append(results->columns, column); | |
374 } | |
375 | |
376 void gaim_notify_searchresults_row_add(GaimNotifySearchResults *results, | |
377 GList *row) | |
378 { | |
379 g_return_if_fail(results != NULL); | |
380 g_return_if_fail(row != NULL); | |
381 | |
382 results->rows = g_list_append(results->rows, row); | |
383 } | |
384 | |
385 GaimNotifySearchColumn * | |
386 gaim_notify_searchresults_column_new(const char *title) | |
387 { | |
388 GaimNotifySearchColumn *sc; | |
389 | |
390 g_return_val_if_fail(title != NULL, NULL); | |
391 | |
392 sc = g_new0(GaimNotifySearchColumn, 1); | |
393 sc->title = g_strdup(title); | |
394 | |
395 return sc; | |
396 } | |
397 | |
398 guint | |
399 gaim_notify_searchresults_get_columns_count(GaimNotifySearchResults *results) | |
400 { | |
401 g_return_val_if_fail(results != NULL, 0); | |
402 | |
403 return g_list_length(results->columns); | |
404 } | |
405 | |
406 guint | |
407 gaim_notify_searchresults_get_rows_count(GaimNotifySearchResults *results) | |
408 { | |
409 g_return_val_if_fail(results != NULL, 0); | |
410 | |
411 return g_list_length(results->rows); | |
412 } | |
413 | |
414 char * | |
415 gaim_notify_searchresults_column_get_title(GaimNotifySearchResults *results, | |
416 unsigned int column_id) | |
417 { | |
418 g_return_val_if_fail(results != NULL, NULL); | |
419 | |
420 return ((GaimNotifySearchColumn *)g_list_nth_data(results->columns, column_id))->title; | |
421 } | |
422 | |
423 GList * | |
424 gaim_notify_searchresults_row_get(GaimNotifySearchResults *results, | |
425 unsigned int row_id) | |
426 { | |
427 g_return_val_if_fail(results != NULL, NULL); | |
428 | |
429 return g_list_nth_data(results->rows, row_id); | |
430 } | |
431 | |
432 void * | |
433 gaim_notify_userinfo(GaimConnection *gc, const char *who, | |
15143
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
434 GaimNotifyUserInfo *user_info, GaimNotifyCloseCallback cb, gpointer user_data) |
14192 | 435 { |
436 GaimNotifyUiOps *ops; | |
437 | |
438 g_return_val_if_fail(who != NULL, NULL); | |
439 | |
440 ops = gaim_notify_get_ui_ops(); | |
441 | |
442 if (ops != NULL && ops->notify_userinfo != NULL) { | |
443 GaimNotifyInfo *info; | |
444 | |
445 info = g_new0(GaimNotifyInfo, 1); | |
446 info->type = GAIM_NOTIFY_USERINFO; | |
447 info->handle = gc; | |
448 | |
449 gaim_signal_emit(gaim_notify_get_handle(), "displaying-userinfo", | |
15143
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
450 gaim_connection_get_account(gc), who, user_info); |
14192 | 451 |
15143
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
452 info->ui_handle = ops->notify_userinfo(gc, who, user_info); |
14192 | 453 info->cb = cb; |
454 info->cb_user_data = user_data; | |
455 | |
456 if (info->ui_handle != NULL) { | |
457 handles = g_list_append(handles, info); | |
458 | |
459 return info->ui_handle; | |
460 | |
461 } else { | |
462 if (info->cb != NULL) | |
463 info->cb(info->cb_user_data); | |
464 | |
465 g_free(info); | |
466 | |
467 return NULL; | |
468 } | |
469 | |
470 } else { | |
471 if (cb != NULL) | |
472 cb(user_data); | |
473 } | |
474 | |
475 return NULL; | |
476 } | |
477 | |
15266
c95a05393dc3
[gaim-migrate @ 18056]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15263
diff
changeset
|
478 GaimNotifyUserInfoEntry * |
15143
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
479 gaim_notify_user_info_entry_new(const char *label, const char *value) |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
480 { |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
481 GaimNotifyUserInfoEntry *user_info_entry; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
482 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
483 user_info_entry = g_new0(GaimNotifyUserInfoEntry, 1); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
484 user_info_entry->label = g_strdup(label); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
485 user_info_entry->value = g_strdup(value); |
15149
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
486 user_info_entry->type = GAIM_NOTIFY_USER_INFO_ENTRY_PAIR; |
15143
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
487 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
488 return user_info_entry; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
489 } |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
490 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
491 static void |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
492 gaim_notify_user_info_entry_destroy(GaimNotifyUserInfoEntry *user_info_entry) |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
493 { |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
494 g_return_if_fail(user_info_entry != NULL); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
495 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
496 g_free(user_info_entry->label); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
497 g_free(user_info_entry->value); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
498 g_free(user_info_entry); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
499 } |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
500 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
501 GaimNotifyUserInfo * |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
502 gaim_notify_user_info_new() |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
503 { |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
504 GaimNotifyUserInfo *user_info; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
505 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
506 user_info = g_new0(GaimNotifyUserInfo, 1); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
507 user_info->user_info_entries = NULL; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
508 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
509 return user_info; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
510 } |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
511 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
512 void |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
513 gaim_notify_user_info_destroy(GaimNotifyUserInfo *user_info) |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
514 { |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
515 GList *l; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
516 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
517 for (l = user_info->user_info_entries; l != NULL; l = l->next) { |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
518 GaimNotifyUserInfoEntry *user_info_entry = l->data; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
519 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
520 gaim_notify_user_info_entry_destroy(user_info_entry); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
521 } |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
522 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
523 g_list_free(user_info->user_info_entries); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
524 } |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
525 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
526 GList * |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
527 gaim_notify_user_info_get_entries(GaimNotifyUserInfo *user_info) |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
528 { |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
529 g_return_val_if_fail(user_info != NULL, NULL); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
530 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
531 return user_info->user_info_entries; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
532 } |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
533 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
534 char * |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
535 gaim_notify_user_info_get_text_with_newline(GaimNotifyUserInfo *user_info, const char *newline) |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
536 { |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
537 GList *l; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
538 GString *text; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
539 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
540 text = g_string_new(""); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
541 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
542 for (l = user_info->user_info_entries; l != NULL; l = l->next) { |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
543 GaimNotifyUserInfoEntry *user_info_entry = l->data; |
15149
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
544 /* Add a newline before a section header */ |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
545 if (user_info_entry->type == GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER) |
15143
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
546 g_string_append(text, newline); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
547 |
15149
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
548 /* Handle the label/value pair itself */ |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
549 /* XXX Todo: Use a larger size for a section header? */ |
15143
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
550 if (user_info_entry->label) |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
551 g_string_append_printf(text, "<b>%s</b>", user_info_entry->label); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
552 if (user_info_entry->label && user_info_entry->value) |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
553 g_string_append(text, ": "); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
554 if (user_info_entry->value) |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
555 g_string_append(text, user_info_entry->value); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
556 |
15149
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
557 /* Display a section break as a horizontal line */ |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
558 if (user_info_entry->type == GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK) |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
559 g_string_append(text, "<HR>"); |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
560 |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
561 /* Don't insert a new line before or after a section break; <HR> does that for us */ |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
562 if ((user_info_entry->type != GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK) && |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
563 (l->next && ((((GaimNotifyUserInfoEntry *)(l->next->data))->type != GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK)))) |
15143
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
564 g_string_append(text, newline); |
15149
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
565 |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
566 /* Add an extra newline after a section header */ |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
567 if (user_info_entry->type == GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER) |
15143
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
568 g_string_append(text, newline); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
569 } |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
570 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
571 return g_string_free(text, FALSE); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
572 } |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
573 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
574 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
575 gchar * |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
576 gaim_notify_user_info_entry_get_label(GaimNotifyUserInfoEntry *user_info_entry) |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
577 { |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
578 g_return_val_if_fail(user_info_entry != NULL, NULL); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
579 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
580 return user_info_entry->label; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
581 } |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
582 |
15263
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
583 void |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
584 gaim_notify_user_info_entry_set_label(GaimNotifyUserInfoEntry *user_info_entry, const char *label) |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
585 { |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
586 g_return_if_fail(user_info_entry != NULL); |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
587 |
15268
132db06150ca
[gaim-migrate @ 18058]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15267
diff
changeset
|
588 g_free(user_info_entry->label); |
132db06150ca
[gaim-migrate @ 18058]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15267
diff
changeset
|
589 user_info_entry->label = g_strdup(label); |
15263
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
590 } |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
591 |
15143
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
592 gchar * |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
593 gaim_notify_user_info_entry_get_value(GaimNotifyUserInfoEntry *user_info_entry) |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
594 { |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
595 g_return_val_if_fail(user_info_entry != NULL, NULL); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
596 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
597 return user_info_entry->value; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
598 } |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
599 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
600 void |
15263
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
601 gaim_notify_user_info_entry_set_value(GaimNotifyUserInfoEntry *user_info_entry, const char *value) |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
602 { |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
603 g_return_if_fail(user_info_entry != NULL); |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
604 |
15268
132db06150ca
[gaim-migrate @ 18058]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15267
diff
changeset
|
605 g_free(user_info_entry->value); |
132db06150ca
[gaim-migrate @ 18058]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15267
diff
changeset
|
606 user_info_entry->value = g_strdup(value); |
15263
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
607 } |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
608 |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
609 GaimNotifyUserInfoEntryType |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
610 gaim_notify_user_info_entry_get_type(GaimNotifyUserInfoEntry *user_info_entry) |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
611 { |
15268
132db06150ca
[gaim-migrate @ 18058]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15267
diff
changeset
|
612 g_return_val_if_fail(user_info_entry != NULL, GAIM_NOTIFY_USER_INFO_ENTRY_PAIR); |
132db06150ca
[gaim-migrate @ 18058]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15267
diff
changeset
|
613 |
15263
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
614 return user_info_entry->type; |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
615 } |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
616 |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
617 void |
15266
c95a05393dc3
[gaim-migrate @ 18056]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15263
diff
changeset
|
618 gaim_notify_user_info_entry_set_type(GaimNotifyUserInfoEntry *user_info_entry, GaimNotifyUserInfoEntryType type) |
15263
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
619 { |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
620 g_return_if_fail(user_info_entry != NULL); |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
621 |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
622 user_info_entry->type = type; |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
623 } |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
624 |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
625 void |
15143
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
626 gaim_notify_user_info_add_pair(GaimNotifyUserInfo *user_info, const char *label, const char *value) |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
627 { |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
628 GaimNotifyUserInfoEntry *entry; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
629 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
630 entry = gaim_notify_user_info_entry_new(label, value); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
631 user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
632 } |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
633 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
634 void |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
635 gaim_notify_user_info_prepend_pair(GaimNotifyUserInfo *user_info, const char *label, const char *value) |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
636 { |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
637 GaimNotifyUserInfoEntry *entry; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
638 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
639 entry = gaim_notify_user_info_entry_new(label, value); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
640 user_info->user_info_entries = g_list_prepend(user_info->user_info_entries, entry); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
641 } |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
642 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
643 void |
15267
6388c384bfac
[gaim-migrate @ 18057]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15266
diff
changeset
|
644 gaim_notify_user_info_remove_entry(GaimNotifyUserInfo *user_info, GaimNotifyUserInfoEntry *entry) |
15266
c95a05393dc3
[gaim-migrate @ 18056]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15263
diff
changeset
|
645 { |
c95a05393dc3
[gaim-migrate @ 18056]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15263
diff
changeset
|
646 g_return_if_fail(user_info != NULL); |
15267
6388c384bfac
[gaim-migrate @ 18057]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15266
diff
changeset
|
647 g_return_if_fail(entry != NULL); |
15266
c95a05393dc3
[gaim-migrate @ 18056]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15263
diff
changeset
|
648 |
c95a05393dc3
[gaim-migrate @ 18056]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15263
diff
changeset
|
649 user_info->user_info_entries = g_list_remove(user_info->user_info_entries, entry); |
c95a05393dc3
[gaim-migrate @ 18056]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15263
diff
changeset
|
650 } |
c95a05393dc3
[gaim-migrate @ 18056]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15263
diff
changeset
|
651 |
c95a05393dc3
[gaim-migrate @ 18056]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15263
diff
changeset
|
652 void |
15143
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
653 gaim_notify_user_info_add_section_header(GaimNotifyUserInfo *user_info, const char *label) |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
654 { |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
655 GaimNotifyUserInfoEntry *entry; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
656 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
657 entry = gaim_notify_user_info_entry_new(label, NULL); |
15149
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
658 entry->type = GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER; |
15143
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
659 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
660 user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
661 } |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
662 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
663 void |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
664 gaim_notify_user_info_add_section_break(GaimNotifyUserInfo *user_info) |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
665 { |
15149
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
666 GaimNotifyUserInfoEntry *entry; |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
667 |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
668 entry = gaim_notify_user_info_entry_new(NULL, NULL); |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
669 entry->type = GAIM_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK; |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
670 |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
671 user_info->user_info_entries = g_list_append(user_info->user_info_entries, entry); |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
672 } |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
673 |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
674 void |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
675 gaim_notify_user_info_remove_last_item(GaimNotifyUserInfo *user_info) |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
676 { |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
677 user_info->user_info_entries = g_list_remove(user_info->user_info_entries, |
a56c93f12f8f
[gaim-migrate @ 17935]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15143
diff
changeset
|
678 g_list_last(user_info->user_info_entries)->data); |
15143
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
679 } |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14192
diff
changeset
|
680 |
14192 | 681 void * |
682 gaim_notify_uri(void *handle, const char *uri) | |
683 { | |
684 GaimNotifyUiOps *ops; | |
685 | |
686 g_return_val_if_fail(uri != NULL, NULL); | |
687 | |
688 ops = gaim_notify_get_ui_ops(); | |
689 | |
690 if (ops != NULL && ops->notify_uri != NULL) { | |
691 GaimNotifyInfo *info; | |
692 | |
693 info = g_new0(GaimNotifyInfo, 1); | |
694 info->type = GAIM_NOTIFY_URI; | |
695 info->handle = handle; | |
696 info->ui_handle = ops->notify_uri(uri); | |
697 | |
698 if (info->ui_handle != NULL) { | |
699 handles = g_list_append(handles, info); | |
700 | |
701 return info->ui_handle; | |
702 | |
703 } else { | |
704 g_free(info); | |
705 | |
706 return NULL; | |
707 } | |
708 } | |
709 | |
710 return NULL; | |
711 } | |
712 | |
713 void | |
714 gaim_notify_close(GaimNotifyType type, void *ui_handle) | |
715 { | |
716 GList *l; | |
717 GaimNotifyUiOps *ops; | |
718 | |
719 g_return_if_fail(ui_handle != NULL); | |
720 | |
721 ops = gaim_notify_get_ui_ops(); | |
722 | |
723 for (l = handles; l != NULL; l = l->next) { | |
724 GaimNotifyInfo *info = l->data; | |
725 | |
726 if (info->ui_handle == ui_handle) { | |
727 handles = g_list_remove(handles, info); | |
728 | |
729 if (ops != NULL && ops->close_notify != NULL) | |
730 ops->close_notify(info->type, ui_handle); | |
731 | |
732 if (info->cb != NULL) | |
733 info->cb(info->cb_user_data); | |
734 | |
735 g_free(info); | |
736 | |
737 break; | |
738 } | |
739 } | |
740 } | |
741 | |
742 void | |
743 gaim_notify_close_with_handle(void *handle) | |
744 { | |
745 GList *l, *l_next; | |
746 GaimNotifyUiOps *ops; | |
747 | |
748 g_return_if_fail(handle != NULL); | |
749 | |
750 ops = gaim_notify_get_ui_ops(); | |
751 | |
752 for (l = handles; l != NULL; l = l_next) { | |
753 GaimNotifyInfo *info = l->data; | |
754 | |
755 l_next = l->next; | |
756 | |
757 if (info->handle == handle) { | |
758 handles = g_list_remove(handles, info); | |
759 | |
760 if (ops != NULL && ops->close_notify != NULL) | |
761 ops->close_notify(info->type, info->ui_handle); | |
762 | |
763 if (info->cb != NULL) | |
764 info->cb(info->cb_user_data); | |
765 | |
766 g_free(info); | |
767 } | |
768 } | |
769 } | |
770 | |
771 void | |
772 gaim_notify_set_ui_ops(GaimNotifyUiOps *ops) | |
773 { | |
774 notify_ui_ops = ops; | |
775 } | |
776 | |
777 GaimNotifyUiOps * | |
778 gaim_notify_get_ui_ops(void) | |
779 { | |
780 return notify_ui_ops; | |
781 } | |
782 | |
783 void * | |
784 gaim_notify_get_handle(void) | |
785 { | |
786 static int handle; | |
787 | |
788 return &handle; | |
789 } | |
790 | |
791 void | |
792 gaim_notify_init(void) | |
793 { | |
794 gpointer handle = gaim_notify_get_handle(); | |
795 | |
796 gaim_signal_register(handle, "displaying-userinfo", | |
797 gaim_marshal_VOID__POINTER_POINTER_POINTER, NULL, 3, | |
798 gaim_value_new(GAIM_TYPE_SUBTYPE, | |
799 GAIM_SUBTYPE_ACCOUNT), | |
800 gaim_value_new(GAIM_TYPE_STRING), | |
15263
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
801 gaim_value_new(GAIM_TYPE_SUBTYPE, |
a46c40c7a0e9
[gaim-migrate @ 18053]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15149
diff
changeset
|
802 GAIM_SUBTYPE_USERINFO)); |
14192 | 803 } |
804 | |
805 void | |
806 gaim_notify_uninit(void) | |
807 { | |
808 gaim_signals_unregister_by_instance(gaim_notify_get_handle()); | |
809 } |