Remove unused purple_protocol_override.
[pidgin-git.git] / libpurple / notify.c
blobc8da33235039757b91f3194ce6dabb4c8fe95568
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_foreach(row, (GFunc)g_free, NULL);
270 g_list_free(row);
273 for (l = results->columns; l; l = g_list_delete_link(l, l)) {
274 PurpleNotifySearchColumn *column = l->data;
275 g_free(column->title);
276 g_free(column);
279 g_free(results);
282 void
283 purple_notify_searchresults_new_rows(PurpleConnection *gc,
284 PurpleNotifySearchResults *results,
285 void *data)
287 PurpleNotifyUiOps *ops;
289 ops = purple_notify_get_ui_ops();
291 if (ops != NULL && ops->notify_searchresults != NULL) {
292 ops->notify_searchresults_new_rows(gc, results, data);
296 void
297 purple_notify_searchresults_button_add(PurpleNotifySearchResults *results,
298 PurpleNotifySearchButtonType type,
299 PurpleNotifySearchResultsCallback cb)
301 PurpleNotifySearchButton *button;
303 g_return_if_fail(results != NULL);
304 g_return_if_fail(cb != NULL);
306 button = g_new0(PurpleNotifySearchButton, 1);
307 button->callback = cb;
308 button->type = type;
310 results->buttons = g_list_append(results->buttons, button);
314 void
315 purple_notify_searchresults_button_add_labeled(PurpleNotifySearchResults *results,
316 const char *label,
317 PurpleNotifySearchResultsCallback cb) {
318 PurpleNotifySearchButton *button;
320 g_return_if_fail(results != NULL);
321 g_return_if_fail(cb != NULL);
322 g_return_if_fail(label != NULL);
323 g_return_if_fail(*label != '\0');
325 button = g_new0(PurpleNotifySearchButton, 1);
326 button->callback = cb;
327 button->type = PURPLE_NOTIFY_BUTTON_LABELED;
328 button->label = g_strdup(label);
330 results->buttons = g_list_append(results->buttons, button);
334 PurpleNotifySearchResults *
335 purple_notify_searchresults_new()
337 PurpleNotifySearchResults *rs = g_new0(PurpleNotifySearchResults, 1);
339 return rs;
342 void
343 purple_notify_searchresults_column_add(PurpleNotifySearchResults *results,
344 PurpleNotifySearchColumn *column)
346 g_return_if_fail(results != NULL);
347 g_return_if_fail(column != NULL);
349 results->columns = g_list_append(results->columns, column);
352 void purple_notify_searchresults_row_add(PurpleNotifySearchResults *results,
353 GList *row)
355 g_return_if_fail(results != NULL);
356 g_return_if_fail(row != NULL);
358 results->rows = g_list_append(results->rows, row);
361 PurpleNotifySearchColumn *
362 purple_notify_searchresults_column_new(const char *title)
364 PurpleNotifySearchColumn *sc;
366 g_return_val_if_fail(title != NULL, NULL);
368 sc = g_new0(PurpleNotifySearchColumn, 1);
369 sc->title = g_strdup(title);
370 sc->visible = TRUE;
372 return sc;
375 const char *purple_notify_searchresult_column_get_title(const PurpleNotifySearchColumn *column)
377 g_return_val_if_fail(column != NULL, NULL);
379 return column->title;
382 void purple_notify_searchresult_column_set_visible(PurpleNotifySearchColumn *column, gboolean visible)
384 g_return_if_fail(column != NULL);
386 column->visible = visible;
389 gboolean
390 purple_notify_searchresult_column_is_visible(const PurpleNotifySearchColumn *column)
392 g_return_val_if_fail(column != NULL, FALSE);
394 return column->visible;
397 void *
398 purple_notify_userinfo(PurpleConnection *gc, const char *who,
399 PurpleNotifyUserInfo *user_info, PurpleNotifyCloseCallback cb, gpointer user_data)
401 PurpleNotifyUiOps *ops;
403 g_return_val_if_fail(who != NULL, NULL);
405 ops = purple_notify_get_ui_ops();
407 if (ops != NULL && ops->notify_userinfo != NULL) {
408 void *ui_handle;
410 purple_signal_emit(purple_notify_get_handle(), "displaying-userinfo",
411 purple_connection_get_account(gc), who, user_info);
413 ui_handle = ops->notify_userinfo(gc, who, user_info);
415 if (ui_handle != NULL) {
417 PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1);
418 info->type = PURPLE_NOTIFY_USERINFO;
419 info->handle = gc;
420 info->ui_handle = ui_handle;
421 info->cb = cb;
422 info->cb_user_data = user_data;
424 handles = g_list_append(handles, info);
426 return info->ui_handle;
430 if (cb != NULL)
431 cb(user_data);
433 return NULL;
436 PurpleNotifyUserInfoEntry *
437 purple_notify_user_info_entry_new(const char *label, const char *value)
439 PurpleNotifyUserInfoEntry *user_info_entry;
441 user_info_entry = g_new0(PurpleNotifyUserInfoEntry, 1);
442 user_info_entry->label = g_strdup(label);
443 user_info_entry->value = g_strdup(value);
444 user_info_entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_PAIR;
446 return user_info_entry;
449 void
450 purple_notify_user_info_entry_destroy(PurpleNotifyUserInfoEntry *user_info_entry)
452 g_return_if_fail(user_info_entry != NULL);
454 g_free(user_info_entry->label);
455 g_free(user_info_entry->value);
456 g_free(user_info_entry);
459 PurpleNotifyUserInfo *
460 purple_notify_user_info_new()
462 PurpleNotifyUserInfo *user_info;
464 user_info = g_new0(PurpleNotifyUserInfo, 1);
465 g_queue_init(&user_info->entries);
467 return user_info;
470 void
471 purple_notify_user_info_destroy(PurpleNotifyUserInfo *user_info)
473 GList *l;
475 for (l = user_info->entries.head; l != NULL; l = l->next) {
476 PurpleNotifyUserInfoEntry *user_info_entry = l->data;
478 purple_notify_user_info_entry_destroy(user_info_entry);
481 g_queue_clear(&user_info->entries);
482 g_free(user_info);
485 GQueue *
486 purple_notify_user_info_get_entries(PurpleNotifyUserInfo *user_info)
488 g_return_val_if_fail(user_info != NULL, NULL);
490 return &user_info->entries;
493 char *
494 purple_notify_user_info_get_text_with_newline(PurpleNotifyUserInfo *user_info, const char *newline)
496 GList *l;
497 GString *text;
499 text = g_string_new("");
501 for (l = user_info->entries.head; l != NULL; l = l->next) {
502 PurpleNotifyUserInfoEntry *user_info_entry = l->data;
503 /* Add a newline before a section header */
504 if (user_info_entry->type == PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER)
505 g_string_append(text, newline);
507 /* Handle the label/value pair itself */
508 /* XXX Todo: Use a larger size for a section header? */
509 if (user_info_entry->label)
510 g_string_append_printf(text, "<b>%s</b>", user_info_entry->label);
511 if (user_info_entry->label && user_info_entry->value)
512 g_string_append(text, ": ");
513 if (user_info_entry->value)
514 g_string_append(text, user_info_entry->value);
516 /* Display a section break as a horizontal line */
517 if (user_info_entry->type == PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK)
518 g_string_append(text, "<HR>");
520 /* Don't insert a new line before or after a section break; <HR> does that for us */
521 if ((user_info_entry->type != PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK) &&
522 (l->next && ((((PurpleNotifyUserInfoEntry *)(l->next->data))->type != PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK))))
523 g_string_append(text, newline);
525 /* Add an extra newline after a section header */
526 if (user_info_entry->type == PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER)
527 g_string_append(text, newline);
530 return g_string_free(text, FALSE);
534 const gchar *
535 purple_notify_user_info_entry_get_label(PurpleNotifyUserInfoEntry *user_info_entry)
537 g_return_val_if_fail(user_info_entry != NULL, NULL);
539 return user_info_entry->label;
542 void
543 purple_notify_user_info_entry_set_label(PurpleNotifyUserInfoEntry *user_info_entry, const char *label)
545 g_return_if_fail(user_info_entry != NULL);
547 g_free(user_info_entry->label);
548 user_info_entry->label = g_strdup(label);
551 const gchar *
552 purple_notify_user_info_entry_get_value(PurpleNotifyUserInfoEntry *user_info_entry)
554 g_return_val_if_fail(user_info_entry != NULL, NULL);
556 return user_info_entry->value;
559 void
560 purple_notify_user_info_entry_set_value(PurpleNotifyUserInfoEntry *user_info_entry, const char *value)
562 g_return_if_fail(user_info_entry != NULL);
564 g_free(user_info_entry->value);
565 user_info_entry->value = g_strdup(value);
568 PurpleNotifyUserInfoEntryType
569 purple_notify_user_info_entry_get_entry_type(PurpleNotifyUserInfoEntry *user_info_entry)
571 g_return_val_if_fail(user_info_entry != NULL, PURPLE_NOTIFY_USER_INFO_ENTRY_PAIR);
573 return user_info_entry->type;
576 void
577 purple_notify_user_info_entry_set_entry_type(PurpleNotifyUserInfoEntry *user_info_entry,
578 PurpleNotifyUserInfoEntryType type)
580 g_return_if_fail(user_info_entry != NULL);
582 user_info_entry->type = type;
585 void
586 purple_notify_user_info_add_pair_html(PurpleNotifyUserInfo *user_info, const char *label, const char *value)
588 PurpleNotifyUserInfoEntry *entry;
590 entry = purple_notify_user_info_entry_new(label, value);
591 g_queue_push_tail(&user_info->entries, entry);
594 void
595 purple_notify_user_info_add_pair_plaintext(PurpleNotifyUserInfo *user_info, const char *label, const char *value)
597 gchar *escaped;
599 escaped = g_markup_escape_text(value, -1);
600 purple_notify_user_info_add_pair_html(user_info, label, escaped);
601 g_free(escaped);
604 void
605 purple_notify_user_info_prepend_pair_html(PurpleNotifyUserInfo *user_info, const char *label, const char *value)
607 PurpleNotifyUserInfoEntry *entry;
609 entry = purple_notify_user_info_entry_new(label, value);
610 g_queue_push_head(&user_info->entries, entry);
613 void
614 purple_notify_user_info_prepend_pair_plaintext(PurpleNotifyUserInfo *user_info, const char *label, const char *value)
616 gchar *escaped;
618 escaped = g_markup_escape_text(value, -1);
619 purple_notify_user_info_prepend_pair_html(user_info, label, escaped);
620 g_free(escaped);
623 void
624 purple_notify_user_info_remove_entry(PurpleNotifyUserInfo *user_info, PurpleNotifyUserInfoEntry *entry)
626 g_return_if_fail(user_info != NULL);
627 g_return_if_fail(entry != NULL);
629 g_queue_remove(&user_info->entries, entry);
632 void
633 purple_notify_user_info_add_section_header(PurpleNotifyUserInfo *user_info, const char *label)
635 PurpleNotifyUserInfoEntry *entry;
637 entry = purple_notify_user_info_entry_new(label, NULL);
638 entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER;
640 g_queue_push_tail(&user_info->entries, entry);
643 void
644 purple_notify_user_info_prepend_section_header(PurpleNotifyUserInfo *user_info, const char *label)
646 PurpleNotifyUserInfoEntry *entry;
648 entry = purple_notify_user_info_entry_new(label, NULL);
649 entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_HEADER;
651 g_queue_push_head(&user_info->entries, entry);
654 void
655 purple_notify_user_info_add_section_break(PurpleNotifyUserInfo *user_info)
657 PurpleNotifyUserInfoEntry *entry;
659 entry = purple_notify_user_info_entry_new(NULL, NULL);
660 entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK;
662 g_queue_push_tail(&user_info->entries, entry);
665 void
666 purple_notify_user_info_prepend_section_break(PurpleNotifyUserInfo *user_info)
668 PurpleNotifyUserInfoEntry *entry;
670 entry = purple_notify_user_info_entry_new(NULL, NULL);
671 entry->type = PURPLE_NOTIFY_USER_INFO_ENTRY_SECTION_BREAK;
673 g_queue_push_head(&user_info->entries, entry);
676 void
677 purple_notify_user_info_remove_last_item(PurpleNotifyUserInfo *user_info)
679 PurpleNotifyUserInfoEntry *entry;
681 entry = g_queue_pop_tail(&user_info->entries);
682 if (entry)
683 purple_notify_user_info_entry_destroy(entry);
686 static PurpleNotifyUserInfo *
687 purple_notify_user_info_copy(PurpleNotifyUserInfo *user_info)
689 PurpleNotifyUserInfo *user_info_copy;
690 GList *l;
692 g_return_val_if_fail(user_info != NULL, NULL);
694 user_info_copy = purple_notify_user_info_new();
696 for (l = user_info->entries.head; l != NULL; l = l->next) {
697 PurpleNotifyUserInfoEntry *new_entry, *user_info_entry = l->data;
699 new_entry = purple_notify_user_info_entry_new(user_info_entry->label,
700 user_info_entry->value);
701 new_entry->type = user_info_entry->type;
702 g_queue_push_tail(&user_info_copy->entries, new_entry);
705 return user_info_copy;
708 GType
709 purple_notify_user_info_get_type(void)
711 static GType type = 0;
713 if (type == 0) {
714 type = g_boxed_type_register_static("PurpleNotifyUserInfo",
715 (GBoxedCopyFunc)purple_notify_user_info_copy,
716 (GBoxedFreeFunc)purple_notify_user_info_destroy);
719 return type;
722 void *
723 purple_notify_uri(void *handle, const char *uri)
725 PurpleNotifyUiOps *ops;
727 g_return_val_if_fail(uri != NULL, NULL);
729 ops = purple_notify_get_ui_ops();
731 if (ops != NULL && ops->notify_uri != NULL) {
733 void *ui_handle = ops->notify_uri(uri);
735 if (ui_handle != NULL) {
737 PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1);
738 info->type = PURPLE_NOTIFY_URI;
739 info->handle = handle;
740 info->ui_handle = ui_handle;
742 handles = g_list_append(handles, info);
744 return info->ui_handle;
748 return NULL;
751 gboolean
752 purple_notify_is_valid_ui_handle(void *ui_handle, PurpleNotifyType *type)
754 GList *it;
756 if (ui_handle == NULL)
757 return FALSE;
759 for (it = handles; it != NULL; it = g_list_next(it)) {
760 PurpleNotifyInfo *info = it->data;
762 if (info->ui_handle != ui_handle)
763 continue;
765 if (type != NULL)
766 *type = info->type;
767 return TRUE;
770 return FALSE;
773 void
774 purple_notify_close(PurpleNotifyType type, void *ui_handle)
776 GList *l;
777 PurpleNotifyUiOps *ops;
779 g_return_if_fail(ui_handle != NULL);
781 ops = purple_notify_get_ui_ops();
783 for (l = handles; l != NULL; l = l->next) {
784 PurpleNotifyInfo *info = l->data;
786 if (info->ui_handle == ui_handle) {
787 handles = g_list_remove(handles, info);
789 if (ops != NULL && ops->close_notify != NULL)
790 ops->close_notify(info->type, ui_handle);
792 if (info->cb != NULL)
793 info->cb(info->cb_user_data);
795 g_free(info);
797 break;
802 void
803 purple_notify_close_with_handle(void *handle)
805 GList *l, *prev = NULL;
806 PurpleNotifyUiOps *ops;
808 g_return_if_fail(handle != NULL);
810 ops = purple_notify_get_ui_ops();
812 for (l = handles; l != NULL; l = prev ? prev->next : handles) {
813 PurpleNotifyInfo *info = l->data;
815 if (info->handle == handle) {
816 handles = g_list_remove(handles, info);
818 if (ops != NULL && ops->close_notify != NULL)
819 ops->close_notify(info->type, info->ui_handle);
821 if (info->cb != NULL)
822 info->cb(info->cb_user_data);
824 g_free(info);
825 } else
826 prev = l;
830 static PurpleNotifyUiOps *
831 purple_notify_ui_ops_copy(PurpleNotifyUiOps *ops)
833 PurpleNotifyUiOps *ops_new;
835 g_return_val_if_fail(ops != NULL, NULL);
837 ops_new = g_new(PurpleNotifyUiOps, 1);
838 *ops_new = *ops;
840 return ops_new;
843 GType
844 purple_notify_ui_ops_get_type(void)
846 static GType type = 0;
848 if (type == 0) {
849 type = g_boxed_type_register_static("PurpleNotifyUiOps",
850 (GBoxedCopyFunc)purple_notify_ui_ops_copy,
851 (GBoxedFreeFunc)g_free);
854 return type;
857 static PurpleNotifySearchButton *
858 purple_notify_search_button_copy(PurpleNotifySearchButton *button)
860 PurpleNotifySearchButton *button_new;
862 g_return_val_if_fail(button != NULL, NULL);
864 button_new = g_new(PurpleNotifySearchButton, 1);
865 *button_new = *button;
867 return button_new;
870 GType
871 purple_notify_search_button_get_type(void)
873 static GType type = 0;
875 if (type == 0) {
876 type = g_boxed_type_register_static("PurpleNotifySearchButton",
877 (GBoxedCopyFunc)purple_notify_search_button_copy,
878 (GBoxedFreeFunc)g_free);
881 return type;
884 void
885 purple_notify_set_ui_ops(PurpleNotifyUiOps *ops)
887 notify_ui_ops = ops;
890 PurpleNotifyUiOps *
891 purple_notify_get_ui_ops(void)
893 return notify_ui_ops;
896 void *
897 purple_notify_get_handle(void)
899 static int handle;
901 return &handle;
904 void
905 purple_notify_init(void)
907 gpointer handle = purple_notify_get_handle();
909 purple_signal_register(handle, "displaying-email-notification",
910 purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER,
911 G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING,
912 G_TYPE_STRING, G_TYPE_STRING);
914 purple_signal_register(handle, "displaying-emails-notification",
915 purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER_UINT,
916 G_TYPE_NONE, 5, G_TYPE_POINTER, G_TYPE_POINTER,
917 G_TYPE_POINTER, G_TYPE_POINTER, G_TYPE_UINT);
919 purple_signal_register(handle, "displaying-emails-clear",
920 purple_marshal_VOID, G_TYPE_NONE, 0);
922 purple_signal_register(handle, "displaying-userinfo",
923 purple_marshal_VOID__POINTER_POINTER_POINTER,
924 G_TYPE_NONE, 3, PURPLE_TYPE_ACCOUNT, G_TYPE_STRING,
925 PURPLE_TYPE_NOTIFY_USER_INFO);
928 void
929 purple_notify_uninit(void)
931 purple_signals_unregister_by_instance(purple_notify_get_handle());