Mercurial > pidgin
diff plugins/gevolution/gevolution.c @ 11117:5a8bc4b1f5b6
[gaim-migrate @ 13173]
Patch #1052811, from Szilard Novaki
"gevolution plugin should register a "Send Email" popup
menuitem to send mail for users using gaim contact list.
See the attached patch (patched for gaim-1.0.2 release)."
I made a number of changes to this to simplify it. Thanks to shres and NotZed in #evolution on irc.gnome.org for their help.
Other changes:
- I may have squashed some leaks in existing code as I tracked down leaks in the new code. I'm not really sure. It still leaks something that I can't track down, but that happens even if you don't call any of the new code. I verified that it was happening pre-patch, so it's no worse with this feature addition.
- It's not really Ximian Evolution anymore, so I changed the summary and description to remove "Ximian", leaving it just Evolution.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Mon, 18 Jul 2005 07:26:09 +0000 |
parents | bc700cc98b82 |
children | bb0d7b719af2 |
line wrap: on
line diff
--- a/plugins/gevolution/gevolution.c Mon Jul 18 01:52:43 2005 +0000 +++ b/plugins/gevolution/gevolution.c Mon Jul 18 07:26:09 2005 +0000 @@ -24,6 +24,7 @@ #include "connection.h" #include "debug.h" #include "prefs.h" +#include "notify.h" #include "signals.h" #include "util.h" #include "version.h" @@ -41,6 +42,8 @@ #include <libedata-book/e-data-book-factory.h> #include <bonobo/bonobo-main.h> +#include <glib.h> + #define GEVOLUTION_PLUGIN_ID "gtk-x11-gevolution" #define E_DATA_BOOK_FACTORY_OAF_ID \ @@ -211,6 +214,63 @@ } static void +menu_item_send_mail_activate_cb(GaimBlistNode *node, gpointer user_data) +{ + GaimBuddy *buddy = (GaimBuddy *)node; + EContact *contact; + char *mail = NULL; + + contact = gevo_search_buddy_in_contacts(buddy, NULL); + + if (contact != NULL) + { + mail = g_strdup(e_contact_get(contact, E_CONTACT_EMAIL_1)); + g_object_unref(contact); + } + else + { + GaimAccount *account = gaim_buddy_get_account(buddy); + const char *prpl_id = gaim_account_get_protocol_id(account); + + if (!strcmp(prpl_id, "prpl-msn")) + { + mail = g_strdup(gaim_normalize(account, + gaim_buddy_get_name(buddy))); + } + else if (!strcmp(prpl_id, "prpl-yahoo")) + { + mail = g_strdup_printf("%s@yahoo.com", + gaim_normalize(account, + gaim_buddy_get_name(buddy))); + } + } + + if (mail != NULL) + { + char *app = g_find_program_in_path("evolution"); + if (app != NULL) + { + char *command_line = g_strdup_printf("%s mailto:%s", app, mail); + g_free(app); + g_free(mail); + + g_spawn_command_line_async(command_line, NULL); + g_free(command_line); + } + else + { + gaim_notify_error(NULL, NULL, _("Unable to send e-mail"), + _("The evolution executable was not found in the PATH.")); + } + } + else + { + gaim_notify_error(NULL, NULL, _("Unable to send e-mail"), + _("The specified buddy was not found in the Evolution Contacts.")); + } +} + +static void blist_node_extended_menu_cb(GaimBlistNode *node, GList **menu) { GaimBlistNodeAction *act; @@ -227,6 +287,10 @@ menu_item_activate_cb, NULL, NULL); *menu = g_list_append(*menu, act); + act = gaim_blist_node_action_new(_("Send E-Mail"), + menu_item_send_mail_activate_cb, + NULL, NULL); + *menu = g_list_append(*menu, act); } } @@ -470,9 +534,9 @@ N_("Evolution Integration"), /**< name */ VERSION, /**< version */ /** summary */ - N_("Provides integration with Ximian Evolution."), + N_("Provides integration with Evolution."), /** description */ - N_("Provides integration with Ximian Evolution."), + N_("Provides integration with Evolution."), "Christian Hammond <chipx86@gnupdate.org>", /**< author */ GAIM_WEBSITE, /**< homepage */