* Pidgin is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA /* make the compiler happy... */ G_MODULE_EXPORT GPluginPluginInfo *gplugin_query(GError **error); G_MODULE_EXPORT gboolean gplugin_load(GPluginPlugin *plugin, GError **error); G_MODULE_EXPORT gboolean gplugin_unload(GPluginPlugin *plugin, GError **error); /****************************************************************************** *****************************************************************************/ purple_toast_get_application(void) { static GApplication *application = NULL; if(G_UNLIKELY(application == NULL)) { application = g_application_get_default(); if(application == NULL) { application = g_application_new(NULL, G_APPLICATION_FLAGS_NONE); g_application_register(application, NULL, NULL); purple_toast_show_notification(const gchar *title, GNotification *notification = g_notification_new(title); gchar *stripped = purple_markup_strip_html(body); g_notification_set_body(notification, stripped); g_notification_set_icon(notification, icon); g_application_send_notification(purple_toast_get_application(), g_object_unref(G_OBJECT(notification)); purple_toast_find_icon(PurpleAccount *account, if(PURPLE_IS_BUDDY(buddy)) { PurpleBuddyIcon *buddy_icon = purple_buddy_get_icon(buddy); const gchar *filename = NULL; filename = purple_buddy_icon_get_full_path(buddy_icon); GFile *file = g_file_new_for_path(filename); icon = g_file_icon_new(file); PurpleImage *image = NULL; const gchar *path = NULL; image = purple_buddy_icons_find_account_icon(account); if(PURPLE_IS_IMAGE(image)) { path = purple_image_get_path(image); GFile *file = g_file_new_for_path(path); icon = g_file_icon_new(file); g_object_unref(G_OBJECT(file)); g_object_unref(G_OBJECT(image)); /* We should probably have a fallback, but we need a libpurple or * pidgin icon or something to make that happen. /****************************************************************************** *****************************************************************************/ purple_toast_im_message_received(PurpleAccount *account, PurpleConversation *conv, PurpleMessageFlags flags, PurpleBuddy *buddy = NULL; const gchar *title = NULL; buddy = purple_blist_find_buddy(account, sender); title = PURPLE_IS_BUDDY(buddy) ? purple_buddy_get_alias(buddy) : sender; icon = purple_toast_find_icon(account, buddy, sender); purple_toast_show_notification(title, message, icon); g_object_unref(G_OBJECT(icon)); purple_toast_chat_message_received(PurpleAccount *account, PurpleConversation *conv, PurpleMessageFlags flags, PurpleBuddy *buddy = NULL; const gchar *chat_name = NULL, *from = NULL; /* figure out the title */ chat_name = purple_conversation_get_name(PURPLE_CONVERSATION(conv)); PurpleChat *chat = purple_blist_find_chat(account, chat_name); chat_name = purple_chat_get_name(chat); buddy = purple_blist_find_buddy(account, sender); if(PURPLE_IS_BUDDY(buddy)) { from = purple_buddy_get_alias(buddy); title = g_strdup_printf("%s : %s", chat_name, from); /* figure out the icon */ icon = purple_toast_find_icon(account, buddy, sender); /* show the notification */ purple_toast_show_notification(title, message, icon); /* clean up our memory */ g_object_unref(G_OBJECT(icon)); /****************************************************************************** *****************************************************************************/ G_MODULE_EXPORT GPluginPluginInfo * gplugin_query(GError **error) { PurplePluginInfo *info = NULL; const gchar * const authors[] = { "Gary Kramlich <grim@reaperworld.com>", info = purple_plugin_info_new( "abi-version", PURPLE_ABI_VERSION, return GPLUGIN_PLUGIN_INFO(info); gplugin_load(GPluginPlugin *plugin, GError **error) { gpointer conv_handle = purple_conversations_get_handle(); purple_signal_connect(conv_handle, PURPLE_CALLBACK(purple_toast_im_message_received), purple_signal_connect(conv_handle, PURPLE_CALLBACK(purple_toast_chat_message_received), gplugin_unload(GPluginPlugin *plugin, GError **error) {