Use g_list_free_full instead of g_list_foreach+g_list_free.
[pidgin-git.git] / libpurple / notify.c
blob7bd9552203547572de6cc869d35177085cfde984
1 /* purple
3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
5 * source distribution.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #include "internal.h"
23 #include "notify.h"
25 static PurpleNotifyUiOps *notify_ui_ops = NULL;
26 static GList *handles = NULL;
28 typedef struct
30 PurpleNotifyType type;
31 void *handle;
32 void *ui_handle;
33 PurpleNotifyCloseCallback cb;
34 gpointer cb_user_data;
35 } PurpleNotifyInfo;
38 * Definition of a user info entry
40 struct _PurpleNotifyUserInfoEntry
42 char *label;
43 char *value;
44 PurpleNotifyUserInfoEntryType type;
47 struct _PurpleNotifyUserInfo
49 GQueue entries;
53 * Single column of a search result.
55 struct _PurpleNotifySearchColumn
57 char *title; /* Title of the column. */
58 gboolean visible; /* Should the column be visible to the user. Defaults to TRUE. */
62 void *
63 purple_notify_message(void *handle, PurpleNotifyMessageType type, const char *title,
64 const char *primary, const char *secondary,
65 PurpleRequestCommonParameters *cpar, PurpleNotifyCloseCallback cb,
66 gpointer user_data)
68 PurpleNotifyUiOps *ops;
70 g_return_val_if_fail(primary != NULL, NULL);
72 ops = purple_notify_get_ui_ops();
74 if (ops != NULL && ops->notify_message != NULL) {
75 void *ui_handle = ops->notify_message(type, title, primary,
76 secondary, cpar);
77 if (ui_handle != NULL) {
79 PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1);
80 info->type = PURPLE_NOTIFY_MESSAGE;
81 info->handle = handle;
82 info->ui_handle = ui_handle;
83 info->cb = cb;
84 info->cb_user_data = user_data;
86 handles = g_list_append(handles, info);
88 return info->ui_handle;
93 if (cb != NULL)
94 cb(user_data);
96 return NULL;
99 void *
100 purple_notify_email(void *handle, const char *subject, const char *from,
101 const char *to, const char *url, PurpleNotifyCloseCallback cb,
102 gpointer user_data)
104 PurpleNotifyUiOps *ops;
106 ops = purple_notify_get_ui_ops();
108 if (ops != NULL && ops->notify_email != NULL) {
109 void *ui_handle;
111 purple_signal_emit(purple_notify_get_handle(), "displaying-email-notification",
112 subject, from, to, url);
114 ui_handle = ops->notify_email(handle, subject, from, to, url);
116 if (ui_handle != NULL) {
118 PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1);
119 info->type = PURPLE_NOTIFY_EMAIL;
120 info->handle = handle;
121 info->ui_handle = ui_handle;
122 info->cb = cb;
123 info->cb_user_data = user_data;
125 handles = g_list_append(handles, info);
127 return info->ui_handle;
131 if (cb != NULL)
132 cb(user_data);
134 return NULL;
137 void *
138 purple_notify_emails(void *handle, size_t count, gboolean detailed,
139 const char **subjects, const char **froms,
140 const char **tos, const char **urls,
141 PurpleNotifyCloseCallback cb, gpointer user_data)
143 PurpleNotifyUiOps *ops;
145 if (count == 1) {
146 return purple_notify_email(handle,
147 (subjects == NULL ? NULL : *subjects),
148 (froms == NULL ? NULL : *froms),
149 (tos == NULL ? NULL : *tos),
150 (urls == NULL ? NULL : *urls),
151 cb, user_data);
154 ops = purple_notify_get_ui_ops();
156 if (ops != NULL && ops->notify_emails != NULL) {
157 void *ui_handle;
159 purple_signal_emit(purple_notify_get_handle(), "displaying-emails-notification",
160 subjects, froms, tos, urls, count);
162 ui_handle = ops->notify_emails(handle, count, detailed, subjects,
163 froms, tos, urls);
165 if (ui_handle != NULL) {
166 PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1);
167 info->type = PURPLE_NOTIFY_EMAILS;
168 info->handle = handle;
169 info->ui_handle = ui_handle;
170 info->cb = cb;
171 info->cb_user_data = user_data;
173 handles = g_list_append(handles, info);
175 return info->ui_handle;
180 if (cb != NULL)
181 cb(user_data);
183 return NULL;
186 void *
187 purple_notify_formatted(void *handle, const char *title, const char *primary,
188 const char *secondary, const char *text,
189 PurpleNotifyCloseCallback cb, gpointer user_data)
191 PurpleNotifyUiOps *ops;
193 g_return_val_if_fail(primary != NULL, NULL);
195 ops = purple_notify_get_ui_ops();
197 if (ops != NULL && ops->notify_formatted != NULL) {
198 void *ui_handle = ops->notify_formatted(title, primary, secondary, text);
200 if (ui_handle != NULL) {
202 PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1);
203 info->type = PURPLE_NOTIFY_FORMATTED;
204 info->handle = handle;
205 info->ui_handle = ui_handle;
206 info->cb = cb;
207 info->cb_user_data = user_data;
209 handles = g_list_append(handles, info);
211 return info->ui_handle;
215 if (cb != NULL)
216 cb(user_data);
217 return NULL;
220 void *
221 purple_notify_searchresults(PurpleConnection *gc, const char *title,
222 const char *primary, const char *secondary,
223 PurpleNotifySearchResults *results, PurpleNotifyCloseCallback cb,
224 gpointer user_data)
226 PurpleNotifyUiOps *ops;
228 ops = purple_notify_get_ui_ops();
230 if (ops != NULL && ops->notify_searchresults != NULL) {
231 void *ui_handle = ops->notify_searchresults(gc, title, primary,
232 secondary, results, user_data);
233 if (ui_handle != NULL) {
235 PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1);
236 info->type = PURPLE_NOTIFY_SEARCHRESULTS;
237 info->handle = gc;
238 info->ui_handle = ui_handle;
239 info->cb = cb;
240 info->cb_user_data = user_data;
242 handles = g_list_append(handles, info);
244 return info->ui_handle;
248 if (cb != NULL)
249 cb(user_data);
251 return NULL;
254 void
255 purple_notify_searchresults_free(PurpleNotifySearchResults *results)
257 GList *l;
259 g_return_if_fail(results != NULL);
261 for (l = results->buttons; l; l = g_list_delete_link(l, l)) {
262 PurpleNotifySearchButton *button = l->data;
263 g_free(button->label);
264 g_free(button);
267 for (l = results->rows; l; l = g_list_delete_link(l, l)) {
268 GList *row = l->data;
269 g_list_free_full(row, g_free);
272 for (l = results->columns; l; l = g_list_delete_link(l, l)) {
273 PurpleNotifySearchColumn *column = l->data;
274 g_free(column->title);
275 g_free(column);
278 g_free(results);
281 void
282 purple_notify_searchresults_new_rows(PurpleConnection *gc,
283 PurpleNotifySearchResults *results,
284 void *data)
286 PurpleNotifyUiOps *ops;
288 ops = purple_notify_get_ui_ops();
290 if (ops != NULL && ops->notify_searchresults != NULL) {
291 ops->notify_searchresults_new_rows(gc, results, data);
295 void
296 purple_notify_searchresults_button_add(PurpleNotifySearchResults *results,
297 PurpleNotifySearchButtonType type,
298 PurpleNotifySearchResultsCallback cb)
300 PurpleNotifySearchButton *button;
302 g_return_if_fail(results != NULL);
303 g_return_if_fail(cb != NULL);
305 button = g_new0(PurpleNotifySearchButton, 1);
306 button->callback = cb;
307 button->type = type;
309 results->buttons = g_list_append(results->buttons, button);
313 void
314 purple_notify_searchresults_button_add_labeled(PurpleNotifySearchResults *results,
315 const char *label,
316 PurpleNotifySearchResultsCallback cb) {
317 PurpleNotifySearchButton *button;
319 g_return_if_fail(results != NULL);
320 g_return_if_fail(cb != NULL);
321 g_return_if_fail(label != NULL);
322 g_return_if_fail(*label != '\0');
324 button = g_new0(PurpleNotifySearchButton, 1);
325 button->callback = cb;
326 button->type = PURPLE_NOTIFY_BUTTON_LABELED;
327 button->label = g_strdup(label);
329 results->buttons = g_list_append(results->buttons, button);
333 PurpleNotifySearchResults *
334 purple_notify_searchresults_new()
336 PurpleNotifySearchResults *rs = g_new0(PurpleNotifySearchResults, 1);
338 return rs;
341 void
342 purple_notify_searchresults_column_add(PurpleNotifySearchResults *results,
343 PurpleNotifySearchColumn *column)
345 g_return_if_fail(results != NULL);
346 g_return_if_fail(column != NULL);
348 results->columns = g_list_append(results->columns, column);
351 void purple_notify_searchresults_row_add(PurpleNotifySearchResults *results,
352 GList *row)
354 g_return_if_fail(results != NULL);
355 g_return_if_fail(row != NULL);
357 results->rows = g_list_append(results->rows, row);
360 PurpleNotifySearchColumn *
361 purple_notify_searchresults_column_new(const char *title)
363 PurpleNotifySearchColumn *sc;
365 g_return_val_if_fail(title != NULL, NULL);
367 sc = g_new0(PurpleNotifySearchColumn, 1);
368 sc->title = g_strdup(title);
369 sc->visible = TRUE;
371 return sc;
374 const char *purple_notify_searchresult_column_get_title(const PurpleNotifySearchColumn *column)
376 g_return_val_if_fail(column != NULL, NULL);
378 return column->title;
381 void purple_notify_searchresult_column_set_visible(PurpleNotifySearchColumn *column, gboolean visible)
383 g_return_if_fail(column != NULL);
385 column->visible = visible;
388 gboolean
389 purple_notify_searchresult_column_is_visible(const PurpleNotifySearchColumn *column)
391 g_return_val_if_fail(column != NULL, FALSE);
393 return column->visible;
396 void *
397 purple_notify_userinfo(PurpleConnection *gc, const char *who,
398 PurpleNotifyUserInfo *user_info, PurpleNotifyCloseCallback cb, gpointer user_data)
400 PurpleNotifyUiOps *ops;
402 g_return_val_if_fail(who != NULL, NULL);
404 ops = purple_notify_get_ui_ops();
406 if (ops != NULL && ops->notify_userinfo != NULL) {
407 void *ui_handle;
409 purple_signal_emit(purple_notify_get_handle(), "displaying-userinfo",
410 purple_connection_get_account(gc), who, user_info);
412 ui_handle = ops->notify_userinfo(gc, who, user_info);
414 if (ui_handle != NULL) {
416 PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1);
417 info->type = PURPLE_NOTIFY_USERINFO;
418 info->handle = gc;
419 info->ui_handle = ui_handle;
420 info->cb = cb;
421 info->cb_user_data = user_data;
423 handles = g_list_append(handles, info);
425 return info->ui_handle;
429 if (cb != NULL)
430 cb(user_data);
432 return NULL;
435 PurpleNotifyUserInfoEntry *
436 purple_notify_user_info_entry_new(const char *label, const char *value)
438 PurpleNotifyUserInfoEntry *user_info_entry;
440 user_info_entry = g_new0(PurpleNotifyUserInfoEntry, 1);
441 user_info_entry->label = g_strdup(label);
442 user_info_entry->value = g_strdup(value);
443 user_info_entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_PAIR;
445 return user_info_entry;
448 void
449 purple_notify_user_info_entry_destroy(PurpleNotifyUserInfoEntry *user_info_entry)
451 g_return_if_fail(user_info_entry != NULL);
453 g_free(user_info_entry->label);
454 g_free(user_info_entry->value);
455 g_free(user_info_entry);
458 PurpleNotifyUserInfo *
459 purple_notify_user_info_new()
461 PurpleNotifyUserInfo *user_info;
463 user_info = g_new0(PurpleNotifyUserInfo, 1);
464 g_queue_init(&user_info->entries);
466 return user_info;
469 void
470 purple_notify_user_info_destroy(PurpleNotifyUserInfo *user_info)
472 GList *l;
474 for (l = user_info->entries.head; l != NULL; l = l->next) {
475 PurpleNotifyUserInfoEntry *user_info_entry = l->data;
477 purple_notify_user_info_entry_destroy(user_info_entry);
480 g_queue_clear(&user_info->entries);
481 g_free(user_info);
484 GQueue *
485 purple_notify_user_info_get_entries(PurpleNotifyUserInfo *user_info)
487 g_return_val_if_fail(user_info != NULL, NULL);
489 return &user_info->entries;
492 char *
493 purple_notify_user_info_get_text_with_newline(PurpleNotifyUserInfo *user_info, const char *newline)
495 GList *l;
496 GString *text;
498 text = g_string_new("");
500 for (l = user_info->entries.head; l != NULL; l = l->next) {
501 PurpleNotifyUserInfoEntry *user_info_entry = l->data;
502 /* Add a newline before a section header */
503 if (user_info_entry->type == PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER)
504 g_string_append(text, newline);
506 /* Handle the label/value pair itself */
507 /* XXX Todo: Use a larger size for a section header? */
508 if (user_info_entry->label)
509 g_string_append_printf(text, "<b>%s</b>", user_info_entry->label);
510 if (user_info_entry->label && user_info_entry->value)
511 g_string_append(text, ": ");
512 if (user_info_entry->value)
513 g_string_append(text, user_info_entry->value);
515 /* Display a section break as a horizontal line */
516 if (user_info_entry->type == PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK)
517 g_string_append(text, "<HR>");
519 /* Don't insert a new line before or after a section break; <HR> does that for us */
520 if ((user_info_entry->type != PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK) &&
521 (l->next && ((((PurpleNotifyUserInfoEntry *)(l->next->data))->type != PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK))))
522 g_string_append(text, newline);
524 /* Add an extra newline after a section header */
525 if (user_info_entry->type == PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER)
526 g_string_append(text, newline);
529 return g_string_free(text, FALSE);
533 const gchar *
534 purple_notify_user_info_entry_get_label(PurpleNotifyUserInfoEntry *user_info_entry)
536 g_return_val_if_fail(user_info_entry != NULL, NULL);
538 return user_info_entry->label;
541 void
542 purple_notify_user_info_entry_set_label(PurpleNotifyUserInfoEntry *user_info_entry, const char *label)
544 g_return_if_fail(user_info_entry != NULL);
546 g_free(user_info_entry->label);
547 user_info_entry->label = g_strdup(label);
550 const gchar *
551 purple_notify_user_info_entry_get_value(PurpleNotifyUserInfoEntry *user_info_entry)
553 g_return_val_if_fail(user_info_entry != NULL, NULL);
555 return user_info_entry->value;
558 void
559 purple_notify_user_info_entry_set_value(PurpleNotifyUserInfoEntry *user_info_entry, const char *value)
561 g_return_if_fail(user_info_entry != NULL);
563 g_free(user_info_entry->value);
564 user_info_entry->value = g_strdup(value);
567 PurpleNotifyUserInfoEntryType
568 purple_notify_user_info_entry_get_entry_type(PurpleNotifyUserInfoEntry *user_info_entry)
570 g_return_val_if_fail(user_info_entry != NULL, PURPLE_NOTIFY_USER_INFO_ENTRY_PAIR);
572 return user_info_entry->type;
575 void
576 purple_notify_user_info_entry_set_entry_type(PurpleNotifyUserInfoEntry *user_info_entry,
577 PurpleNotifyUserInfoEntryType type)
579 g_return_if_fail(user_info_entry != NULL);
581 user_info_entry->type = type;
584 void
585 purple_notify_user_info_add_pair_html(PurpleNotifyUserInfo *user_info, const char *label, const char *value)
587 PurpleNotifyUserInfoEntry *entry;
589 entry = purple_notify_user_info_entry_new(label, value);
590 g_queue_push_tail(&user_info->entries, entry);
593 void
594 purple_notify_user_info_add_pair_plaintext(PurpleNotifyUserInfo *user_info, const char *label, const char *value)
596 gchar *escaped;
598 escaped = g_markup_escape_text(value, -1);
599 purple_notify_user_info_add_pair_html(user_info, label, escaped);
600 g_free(escaped);
603 void
604 purple_notify_user_info_prepend_pair_html(PurpleNotifyUserInfo *user_info, const char *label, const char *value)
606 PurpleNotifyUserInfoEntry *entry;
608 entry = purple_notify_user_info_entry_new(label, value);
609 g_queue_push_head(&user_info->entries, entry);
612 void
613 purple_notify_user_info_prepend_pair_plaintext(PurpleNotifyUserInfo *user_info, const char *label, const char *value)
615 gchar *escaped;
617 escaped = g_markup_escape_text(value, -1);
618 purple_notify_user_info_prepend_pair_html(user_info, label, escaped);
619 g_free(escaped);
622 void
623 purple_notify_user_info_remove_entry(PurpleNotifyUserInfo *user_info, PurpleNotifyUserInfoEntry *entry)
625 g_return_if_fail(user_info != NULL);
626 g_return_if_fail(entry != NULL);
628 g_queue_remove(&user_info->entries, entry);
631 void
632 purple_notify_user_info_add_section_header(PurpleNotifyUserInfo *user_info, const char *label)
634 PurpleNotifyUserInfoEntry *entry;
636 entry = purple_notify_user_info_entry_new(label, NULL);
637 entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER;
639 g_queue_push_tail(&user_info->entries, entry);
642 void
643 purple_notify_user_info_prepend_section_header(PurpleNotifyUserInfo *user_info, const char *label)
645 PurpleNotifyUserInfoEntry *entry;
647 entry = purple_notify_user_info_entry_new(label, NULL);
648 entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER;
650 g_queue_push_head(&user_info->entries, entry);
653 void
654 purple_notify_user_info_add_section_break(PurpleNotifyUserInfo *user_info)
656 PurpleNotifyUserInfoEntry *entry;
658 entry = purple_notify_user_info_entry_new(NULL, NULL);
659 entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK;
661 g_queue_push_tail(&user_info->entries, entry);
664 void
665 purple_notify_user_info_prepend_section_break(PurpleNotifyUserInfo *user_info)
667 PurpleNotifyUserInfoEntry *entry;
669 entry = purple_notify_user_info_entry_new(NULL, NULL);
670 entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK;
672 g_queue_push_head(&user_info->entries, entry);
675 void
676 purple_notify_user_info_remove_last_item(PurpleNotifyUserInfo *user_info)
678 PurpleNotifyUserInfoEntry *entry;
680 entry = g_queue_pop_tail(&user_info->entries);
681 if (entry)
682 purple_notify_user_info_entry_destroy(entry);
685 static PurpleNotifyUserInfo *
686 purple_notify_user_info_copy(PurpleNotifyUserInfo *user_info)
688 PurpleNotifyUserInfo *user_info_copy;
689 GList *l;
691 g_return_val_if_fail(user_info != NULL, NULL);
693 user_info_copy = purple_notify_user_info_new();
695 for (l = user_info->entries.head; l != NULL; l = l->next) {
696 PurpleNotifyUserInfoEntry *new_entry, *user_info_entry = l->data;
698 new_entry = purple_notify_user_info_entry_new(user_info_entry->label,
699 user_info_entry->value);
700 new_entry->type = user_info_entry->type;
701 g_queue_push_tail(&user_info_copy->entries, new_entry);
704 return user_info_copy;
707 GType
708 purple_notify_user_info_get_type(void)
710 static GType type = 0;
712 if (type == 0) {
713 type = g_boxed_type_register_static("PurpleNotifyUserInfo",
714 (GBoxedCopyFunc)purple_notify_user_info_copy,
715 (GBoxedFreeFunc)purple_notify_user_info_destroy);
718 return type;
721 void *
722 purple_notify_uri(void *handle, const char *uri)
724 PurpleNotifyUiOps *ops;
726 g_return_val_if_fail(uri != NULL, NULL);
728 ops = purple_notify_get_ui_ops();
730 if (ops != NULL && ops->notify_uri != NULL) {
732 void *ui_handle = ops->notify_uri(uri);
734 if (ui_handle != NULL) {
736 PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1);
737 info->type = PURPLE_NOTIFY_URI;
738 info->handle = handle;
739 info->ui_handle = ui_handle;
741 handles = g_list_append(handles, info);
743 return info->ui_handle;
747 return NULL;
750 gboolean
751 purple_notify_is_valid_ui_handle(void *ui_handle, PurpleNotifyType *type)
753 GList *it;
755 if (ui_handle == NULL)
756 return FALSE;
758 for (it = handles; it != NULL; it = g_list_next(it)) {
759 PurpleNotifyInfo *info = it->data;
761 if (info->ui_handle != ui_handle)
762 continue;
764 if (type != NULL)
765 *type = info->type;
766 return TRUE;
769 return FALSE;
772 void
773 purple_notify_close(PurpleNotifyType type, void *ui_handle)
775 GList *l;
776 PurpleNotifyUiOps *ops;
778 g_return_if_fail(ui_handle != NULL);
780 ops = purple_notify_get_ui_ops();
782 for (l = handles; l != NULL; l = l->next) {
783 PurpleNotifyInfo *info = l->data;
785 if (info->ui_handle == ui_handle) {
786 handles = g_list_remove(handles, info);
788 if (ops != NULL && ops->close_notify != NULL)
789 ops->close_notify(info->type, ui_handle);
791 if (info->cb != NULL)
792 info->cb(info->cb_user_data);
794 g_free(info);
796 break;
801 void
802 purple_notify_close_with_handle(void *handle)
804 GList *l, *prev = NULL;
805 PurpleNotifyUiOps *ops;
807 g_return_if_fail(handle != NULL);
809 ops = purple_notify_get_ui_ops();
811 for (l = handles; l != NULL; l = prev ? prev->next : handles) {
812 PurpleNotifyInfo *info = l->data;
814 if (info->handle == handle) {
815 handles = g_list_remove(handles, info);
817 if (ops != NULL && ops->close_notify != NULL)
818 ops->close_notify(info->type, info->ui_handle);
820 if (info->cb != NULL)
821 info->cb(info->cb_user_data);
823 g_free(info);
824 } else
825 prev = l;
829 static PurpleNotifyUiOps *
830 purple_notify_ui_ops_copy(PurpleNotifyUiOps *ops)
832 PurpleNotifyUiOps *ops_new;
834 g_return_val_if_fail(ops != NULL, NULL);
836 ops_new = g_new(PurpleNotifyUiOps, 1);
837 *ops_new = *ops;
839 return ops_new;
842 GType
843 purple_notify_ui_ops_get_type(void)
845 static GType type = 0;
847 if (type == 0) {
848 type = g_boxed_type_register_static("PurpleNotifyUiOps",
849 (GBoxedCopyFunc)purple_notify_ui_ops_copy,
850 (GBoxedFreeFunc)g_free);
853 return type;
856 static PurpleNotifySearchButton *
857 purple_notify_search_button_copy(PurpleNotifySearchButton *button)
859 PurpleNotifySearchButton *button_new;
861 g_return_val_if_fail(button != NULL, NULL);
863 button_new = g_new(PurpleNotifySearchButton, 1);
864 *button_new = *button;
866 return button_new;
869 GType
870 purple_notify_search_button_get_type(void)
872 static GType type = 0;
874 if (type == 0) {
875 type = g_boxed_type_register_static("PurpleNotifySearchButton",
876 (GBoxedCopyFunc)purple_notify_search_button_copy,
877 (GBoxedFreeFunc)g_free);
880 return type;
883 void
884 purple_notify_set_ui_ops(PurpleNotifyUiOps *ops)
886 notify_ui_ops = ops;
889 PurpleNotifyUiOps *
890 purple_notify_get_ui_ops(void)
892 return notify_ui_ops;
895 void *
896 purple_notify_get_handle(void)
898 static int handle;
900 return &handle;
903 void
904 purple_notify_init(void)
906 gpointer handle = purple_notify_get_handle();
908 purple_signal_register(handle, "displaying-email-notification",
909 purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER,
910 G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING,
911 G_TYPE_STRING, G_TYPE_STRING);
913 purple_signal_register(handle, "displaying-emails-notification",
914 purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER_UINT,
915 G_TYPE_NONE, 5, G_TYPE_POINTER, G_TYPE_POINTER,
916 G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_UINT);
918 purple_signal_register(handle, "displaying-emails-clear",
919 purple_marshal_VOID, G_TYPE_NONE, 0);
921 purple_signal_register(handle, "displaying-userinfo",
922 purple_marshal_VOID__POINTER_POINTER_POINTER,
923 G_TYPE_NONE, 3, PURPLE_TYPE_ACCOUNT, G_TYPE_STRING,
924 PURPLE_TYPE_NOTIFY_USER_INFO);
927 void
928 purple_notify_uninit(void)
930 purple_signals_unregister_by_instance(purple_notify_get_handle());