Mercurial > pidgin
comparison 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 |
comparison
equal
deleted
inserted
replaced
11116:bbb28c529be0 | 11117:5a8bc4b1f5b6 |
---|---|
22 #include "gtkgaim.h" | 22 #include "gtkgaim.h" |
23 | 23 |
24 #include "connection.h" | 24 #include "connection.h" |
25 #include "debug.h" | 25 #include "debug.h" |
26 #include "prefs.h" | 26 #include "prefs.h" |
27 #include "notify.h" | |
27 #include "signals.h" | 28 #include "signals.h" |
28 #include "util.h" | 29 #include "util.h" |
29 #include "version.h" | 30 #include "version.h" |
30 | 31 |
31 #include "gtkblist.h" | 32 #include "gtkblist.h" |
38 #include <libedata-book/Evolution-DataServer-Addressbook.h> | 39 #include <libedata-book/Evolution-DataServer-Addressbook.h> |
39 | 40 |
40 #include <libebook/e-book-listener.h> | 41 #include <libebook/e-book-listener.h> |
41 #include <libedata-book/e-data-book-factory.h> | 42 #include <libedata-book/e-data-book-factory.h> |
42 #include <bonobo/bonobo-main.h> | 43 #include <bonobo/bonobo-main.h> |
44 | |
45 #include <glib.h> | |
43 | 46 |
44 #define GEVOLUTION_PLUGIN_ID "gtk-x11-gevolution" | 47 #define GEVOLUTION_PLUGIN_ID "gtk-x11-gevolution" |
45 | 48 |
46 #define E_DATA_BOOK_FACTORY_OAF_ID \ | 49 #define E_DATA_BOOK_FACTORY_OAF_ID \ |
47 "OAFIID:GNOME_Evolution_DataServer_BookFactory" | 50 "OAFIID:GNOME_Evolution_DataServer_BookFactory" |
209 GaimBuddy *buddy = (GaimBuddy *)node; | 212 GaimBuddy *buddy = (GaimBuddy *)node; |
210 gevo_associate_buddy_dialog_new(buddy); | 213 gevo_associate_buddy_dialog_new(buddy); |
211 } | 214 } |
212 | 215 |
213 static void | 216 static void |
217 menu_item_send_mail_activate_cb(GaimBlistNode *node, gpointer user_data) | |
218 { | |
219 GaimBuddy *buddy = (GaimBuddy *)node; | |
220 EContact *contact; | |
221 char *mail = NULL; | |
222 | |
223 contact = gevo_search_buddy_in_contacts(buddy, NULL); | |
224 | |
225 if (contact != NULL) | |
226 { | |
227 mail = g_strdup(e_contact_get(contact, E_CONTACT_EMAIL_1)); | |
228 g_object_unref(contact); | |
229 } | |
230 else | |
231 { | |
232 GaimAccount *account = gaim_buddy_get_account(buddy); | |
233 const char *prpl_id = gaim_account_get_protocol_id(account); | |
234 | |
235 if (!strcmp(prpl_id, "prpl-msn")) | |
236 { | |
237 mail = g_strdup(gaim_normalize(account, | |
238 gaim_buddy_get_name(buddy))); | |
239 } | |
240 else if (!strcmp(prpl_id, "prpl-yahoo")) | |
241 { | |
242 mail = g_strdup_printf("%s@yahoo.com", | |
243 gaim_normalize(account, | |
244 gaim_buddy_get_name(buddy))); | |
245 } | |
246 } | |
247 | |
248 if (mail != NULL) | |
249 { | |
250 char *app = g_find_program_in_path("evolution"); | |
251 if (app != NULL) | |
252 { | |
253 char *command_line = g_strdup_printf("%s mailto:%s", app, mail); | |
254 g_free(app); | |
255 g_free(mail); | |
256 | |
257 g_spawn_command_line_async(command_line, NULL); | |
258 g_free(command_line); | |
259 } | |
260 else | |
261 { | |
262 gaim_notify_error(NULL, NULL, _("Unable to send e-mail"), | |
263 _("The evolution executable was not found in the PATH.")); | |
264 } | |
265 } | |
266 else | |
267 { | |
268 gaim_notify_error(NULL, NULL, _("Unable to send e-mail"), | |
269 _("The specified buddy was not found in the Evolution Contacts.")); | |
270 } | |
271 } | |
272 | |
273 static void | |
214 blist_node_extended_menu_cb(GaimBlistNode *node, GList **menu) | 274 blist_node_extended_menu_cb(GaimBlistNode *node, GList **menu) |
215 { | 275 { |
216 GaimBlistNodeAction *act; | 276 GaimBlistNodeAction *act; |
217 GaimBuddy *buddy; | 277 GaimBuddy *buddy; |
218 | 278 |
223 | 283 |
224 if (gevo_prpl_is_supported(buddy->account, buddy)) | 284 if (gevo_prpl_is_supported(buddy->account, buddy)) |
225 { | 285 { |
226 act = gaim_blist_node_action_new(_("Add to Address Book"), | 286 act = gaim_blist_node_action_new(_("Add to Address Book"), |
227 menu_item_activate_cb, | 287 menu_item_activate_cb, |
288 NULL, NULL); | |
289 *menu = g_list_append(*menu, act); | |
290 act = gaim_blist_node_action_new(_("Send E-Mail"), | |
291 menu_item_send_mail_activate_cb, | |
228 NULL, NULL); | 292 NULL, NULL); |
229 *menu = g_list_append(*menu, act); | 293 *menu = g_list_append(*menu, act); |
230 } | 294 } |
231 } | 295 } |
232 | 296 |
468 | 532 |
469 GEVOLUTION_PLUGIN_ID, /**< id */ | 533 GEVOLUTION_PLUGIN_ID, /**< id */ |
470 N_("Evolution Integration"), /**< name */ | 534 N_("Evolution Integration"), /**< name */ |
471 VERSION, /**< version */ | 535 VERSION, /**< version */ |
472 /** summary */ | 536 /** summary */ |
473 N_("Provides integration with Ximian Evolution."), | 537 N_("Provides integration with Evolution."), |
474 /** description */ | 538 /** description */ |
475 N_("Provides integration with Ximian Evolution."), | 539 N_("Provides integration with Evolution."), |
476 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ | 540 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ |
477 GAIM_WEBSITE, /**< homepage */ | 541 GAIM_WEBSITE, /**< homepage */ |
478 | 542 |
479 plugin_load, /**< load */ | 543 plugin_load, /**< load */ |
480 plugin_unload, /**< unload */ | 544 plugin_unload, /**< unload */ |