void purple_notify_close_with_handle(void *handle) { GList *l, *prev = NULL; PurpleNotifyUiOps *ops; g_return_if_fail(handle != NULL); ops = purple_notify_get_ui_ops(); for (l = handles; l != NULL; l = prev ? prev->next : handles) { PurpleNotifyInfo *info = l->data; if (info->handle == handle) { handles = g_list_remove(handles, info); if (ops != NULL && ops->close_notify != NULL) ops->close_notify(info->type, info->ui_handle); if (info->cb != NULL) info->cb(info->cb_user_data); g_free(info); } else prev = l; } }
static gboolean plugin_load(PurplePlugin *plugin, GError **error) { PurpleNotifyUiOps *ops = purple_notify_get_ui_ops(); purple_prefs_add_none(PREFS_BASE); purple_prefs_add_int(PREF_LENGTH, 30); purple_prefs_add_string(PREF_URL, "http://tinyurl.com/api-create.php?url="); g_object_set_data(G_OBJECT(plugin), "notify-uri", ops->notify_uri); ops->notify_uri = tinyurl_notify_uri; tinyurl_cache = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); purple_signal_connect(purple_conversations_get_handle(), "wrote-im-msg", plugin, PURPLE_CALLBACK(wrote_msg), NULL); purple_signal_connect(purple_conversations_get_handle(), "wrote-chat-msg", plugin, PURPLE_CALLBACK(wrote_msg), NULL); purple_signal_connect(purple_conversations_get_handle(), "writing-im-msg", plugin, PURPLE_CALLBACK(writing_msg), NULL); purple_signal_connect(purple_conversations_get_handle(), "writing-chat-msg", plugin, PURPLE_CALLBACK(writing_msg), NULL); purple_signal_connect(purple_conversations_get_handle(), "deleting-conversation", plugin, PURPLE_CALLBACK(free_conv_urls), NULL); return TRUE; }
void * purple_notify_uri(void *handle, const char *uri) { PurpleNotifyUiOps *ops; g_return_val_if_fail(uri != NULL, NULL); ops = purple_notify_get_ui_ops(); if (ops != NULL && ops->notify_uri != NULL) { void *ui_handle = ops->notify_uri(uri); if (ui_handle != NULL) { PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1); info->type = PURPLE_NOTIFY_URI; info->handle = handle; info->ui_handle = ui_handle; handles = g_list_append(handles, info); return info->ui_handle; } } return NULL; }
void purple_notify_close(PurpleNotifyType type, void *ui_handle) { GList *l; PurpleNotifyUiOps *ops; g_return_if_fail(ui_handle != NULL); ops = purple_notify_get_ui_ops(); for (l = handles; l != NULL; l = l->next) { PurpleNotifyInfo *info = l->data; if (info->ui_handle == ui_handle) { handles = g_list_remove(handles, info); if (ops != NULL && ops->close_notify != NULL) ops->close_notify(info->type, ui_handle); if (info->cb != NULL) info->cb(info->cb_user_data); g_free(info); break; } } }
void * purple_notify_searchresults(PurpleConnection *gc, const char *title, const char *primary, const char *secondary, PurpleNotifySearchResults *results, PurpleNotifyCloseCallback cb, gpointer user_data) { PurpleNotifyUiOps *ops; ops = purple_notify_get_ui_ops(); if (ops != NULL && ops->notify_searchresults != NULL) { void *ui_handle = ops->notify_searchresults(gc, title, primary, secondary, results, user_data); if (ui_handle != NULL) { PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1); info->type = PURPLE_NOTIFY_SEARCHRESULTS; info->handle = gc; info->ui_handle = ui_handle; info->cb = cb; info->cb_user_data = user_data; handles = g_list_append(handles, info); return info->ui_handle; } } if (cb != NULL) cb(user_data); return NULL; }
void * purple_notify_formatted(void *handle, const char *title, const char *primary, const char *secondary, const char *text, PurpleNotifyCloseCallback cb, gpointer user_data) { PurpleNotifyUiOps *ops; g_return_val_if_fail(primary != NULL, NULL); ops = purple_notify_get_ui_ops(); if (ops != NULL && ops->notify_formatted != NULL) { void *ui_handle = ops->notify_formatted(title, primary, secondary, text); if (ui_handle != NULL) { PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1); info->type = PURPLE_NOTIFY_FORMATTED; info->handle = handle; info->ui_handle = ui_handle; info->cb = cb; info->cb_user_data = user_data; handles = g_list_append(handles, info); return info->ui_handle; } } if (cb != NULL) cb(user_data); return NULL; }
static gboolean plugin_unload(PurplePlugin *plugin, GError **error) { PurpleNotifyUiOps *ops = purple_notify_get_ui_ops(); if (ops->notify_uri == tinyurl_notify_uri) ops->notify_uri = g_object_get_data(G_OBJECT(plugin), "notify-uri"); g_hash_table_destroy(tinyurl_cache); tinyurl_cache = NULL; return TRUE; }
void purple_notify_searchresults_new_rows(PurpleConnection *gc, PurpleNotifySearchResults *results, void *data) { PurpleNotifyUiOps *ops; ops = purple_notify_get_ui_ops(); if (ops != NULL && ops->notify_searchresults != NULL) { ops->notify_searchresults_new_rows(gc, results, data); } }
void * purple_notify_emails(void *handle, size_t count, gboolean detailed, const char **subjects, const char **froms, const char **tos, const char **urls, PurpleNotifyCloseCallback cb, gpointer user_data) { PurpleNotifyUiOps *ops; if (count == 1) { return purple_notify_email(handle, (subjects == NULL ? NULL : *subjects), (froms == NULL ? NULL : *froms), (tos == NULL ? NULL : *tos), (urls == NULL ? NULL : *urls), cb, user_data); } ops = purple_notify_get_ui_ops(); if (ops != NULL && ops->notify_emails != NULL) { void *ui_handle; purple_signal_emit(purple_notify_get_handle(), "displaying-emails-notification", subjects, froms, tos, urls, count); ui_handle = ops->notify_emails(handle, count, detailed, subjects, froms, tos, urls); if (ui_handle != NULL) { PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1); info->type = PURPLE_NOTIFY_EMAILS; info->handle = handle; info->ui_handle = ui_handle; info->cb = cb; info->cb_user_data = user_data; handles = g_list_append(handles, info); return info->ui_handle; } } if (cb != NULL) cb(user_data); return NULL; }
/*------------------------------------------------------------------------ * Register MXit to receive URI click notifications from the UI */ void mxit_register_uri_handler( void ) { not_link_ref_count++; if ( not_link_ref_count == 1 ) { /* make copy of notifications */ mxit_nots_override_original = purple_notify_get_ui_ops(); memcpy( &mxit_nots_override, mxit_nots_override_original, sizeof( PurpleNotifyUiOps ) ); /* save previously configured callback function pointer */ mxit_pidgin_uri_cb = mxit_nots_override.notify_uri; /* override the URI function call with MXit's own one */ mxit_nots_override.notify_uri = mxit_link_click; purple_notify_set_ui_ops( &mxit_nots_override ); } }
void * purple_notify_userinfo(PurpleConnection *gc, const char *who, PurpleNotifyUserInfo *user_info, PurpleNotifyCloseCallback cb, gpointer user_data) { PurpleNotifyUiOps *ops; g_return_val_if_fail(who != NULL, NULL); ops = purple_notify_get_ui_ops(); if (ops != NULL && ops->notify_userinfo != NULL) { void *ui_handle; purple_signal_emit(purple_notify_get_handle(), "displaying-userinfo", purple_connection_get_account(gc), who, user_info); ui_handle = ops->notify_userinfo(gc, who, user_info); if (ui_handle != NULL) { PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1); info->type = PURPLE_NOTIFY_USERINFO; info->handle = gc; info->ui_handle = ui_handle; info->cb = cb; info->cb_user_data = user_data; handles = g_list_append(handles, info); return info->ui_handle; } } if (cb != NULL) cb(user_data); return NULL; }
void * purple_notify_email(void *handle, const char *subject, const char *from, const char *to, const char *url, PurpleNotifyCloseCallback cb, gpointer user_data) { PurpleNotifyUiOps *ops; ops = purple_notify_get_ui_ops(); if (ops != NULL && ops->notify_email != NULL) { void *ui_handle; purple_signal_emit(purple_notify_get_handle(), "displaying-email-notification", subject, from, to, url); ui_handle = ops->notify_email(handle, subject, from, to, url); if (ui_handle != NULL) { PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1); info->type = PURPLE_NOTIFY_EMAIL; info->handle = handle; info->ui_handle = ui_handle; info->cb = cb; info->cb_user_data = user_data; handles = g_list_append(handles, info); return info->ui_handle; } } if (cb != NULL) cb(user_data); return NULL; }
void * purple_notify_message(void *handle, PurpleNotifyMessageType type, const char *title, const char *primary, const char *secondary, PurpleRequestCommonParameters *cpar, PurpleNotifyCloseCallback cb, gpointer user_data) { PurpleNotifyUiOps *ops; g_return_val_if_fail(primary != NULL, NULL); ops = purple_notify_get_ui_ops(); if (ops != NULL && ops->notify_message != NULL) { void *ui_handle = ops->notify_message(type, title, primary, secondary, cpar); if (ui_handle != NULL) { PurpleNotifyInfo *info = g_new0(PurpleNotifyInfo, 1); info->type = PURPLE_NOTIFY_MESSAGE; info->handle = handle; info->ui_handle = ui_handle; info->cb = cb; info->cb_user_data = user_data; handles = g_list_append(handles, info); return info->ui_handle; } } if (cb != NULL) cb(user_data); return NULL; }