aboutsummaryrefslogtreecommitdiffstats
path: root/mail/em-popup.c
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2008-03-13 18:12:49 +0800
committerMilan Crha <mcrha@src.gnome.org>2008-03-13 18:12:49 +0800
commit9bd177927d423b36a7506af4b23f5b5feccc5705 (patch)
treed54f4f15fb0e733a517dd08f3045c163cab0f55a /mail/em-popup.c
parentcc692562f528115284d338dea12f8809d1efd17f (diff)
downloadgsoc2013-evolution-9bd177927d423b36a7506af4b23f5b5feccc5705.tar
gsoc2013-evolution-9bd177927d423b36a7506af4b23f5b5feccc5705.tar.gz
gsoc2013-evolution-9bd177927d423b36a7506af4b23f5b5feccc5705.tar.bz2
gsoc2013-evolution-9bd177927d423b36a7506af4b23f5b5feccc5705.tar.lz
gsoc2013-evolution-9bd177927d423b36a7506af4b23f5b5feccc5705.tar.xz
gsoc2013-evolution-9bd177927d423b36a7506af4b23f5b5feccc5705.tar.zst
gsoc2013-evolution-9bd177927d423b36a7506af4b23f5b5feccc5705.zip
** Fix for bug #273177
2008-03-13 Milan Crha <mcrha@redhat.com> ** Fix for bug #273177 * addressbook/gui/contact-editor/e-contact-quick-add.h: (e_contact_quick_add_vcard): * addressbook/gui/contact-editor/e-contact-quick-add.c: (struct _QuickAdd), (quick_add_unref), (quick_add_set_vcard), (clicked_cb), (build_quick_add_dialog), (e_contact_quick_add_vcard): Allow adding also whole vCard with this dialog. * addressbook/gui/widgets/eab-popup-control.h: (struct _EABPopupControl): * addressbook/gui/widgets/eab-popup-control.c: (eab_popup_control_set_vcard), (eab_popup_control_cleanup), (eab_popup_control_set_vcard), (eab_popup_control_no_matches), (set_prop), (get_prop), (eab_popup_control_new): New property 'vcard', if set, has higher precedence than name/email. * mail/em-utils.h: (em_utils_add_vcard): * mail/em-utils.c: (emu_add_address_or_vcard), (em_utils_add_address), (em_utils_add_vcard): New function to add whole vCard to addressbook. * mail/em-popup.c: (emp_add_vcard), (emp_standard_menu_factory): Add popup menu item to vcard attachments. svn path=/trunk/; revision=35181
Diffstat (limited to 'mail/em-popup.c')
-rw-r--r--mail/em-popup.c53
1 files changed, 52 insertions, 1 deletions
diff --git a/mail/em-popup.c b/mail/em-popup.c
index 53797b0fdb..d44d206414 100644
--- a/mail/em-popup.c
+++ b/mail/em-popup.c
@@ -56,6 +56,7 @@
#include <camel/camel-mime-utils.h>
#include <camel/camel-mime-part.h>
#include <camel/camel-url.h>
+#include <camel/camel-stream-mem.h>
#include <camel/camel-vee-folder.h>
#include <camel/camel-vtrash-folder.h>
@@ -697,6 +698,40 @@ emp_standard_items_free(EPopup *ep, GSList *items, void *data)
}
static void
+emp_add_vcard (EPopup *ep, EPopupItem *item, void *data)
+{
+ EPopupTarget *target = ep->target;
+ CamelMimePart *part;
+ CamelDataWrapper *content;
+ CamelStreamMem *mem;
+
+
+ if (target->type == EM_POPUP_TARGET_ATTACHMENTS)
+ part = ((EAttachment *) ((EMPopupTargetAttachments *) target)->attachments->data)->body;
+ else
+ part = ((EMPopupTargetPart *) target)->part;
+
+ if (!part)
+ return;
+
+ content = camel_medium_get_content_object (CAMEL_MEDIUM (part));
+ mem = CAMEL_STREAM_MEM (camel_stream_mem_new ());
+
+ if (camel_data_wrapper_decode_to_stream (content, CAMEL_STREAM (mem)) == -1 ||
+ !mem->buffer->data)
+ g_warning ("Read part's content failed!");
+ else {
+ GString *vcard = g_string_new_len ((const gchar *) mem->buffer->data, mem->buffer->len);
+
+ em_utils_add_vcard (target->widget, vcard->str);
+
+ g_string_free (vcard, TRUE);
+ }
+
+ camel_object_unref (mem);
+}
+
+static void
emp_standard_menu_factory(EPopup *emp, void *data)
{
int i, len;
@@ -768,7 +803,6 @@ emp_standard_menu_factory(EPopup *emp, void *data)
apps = gnome_vfs_mime_get_all_applications(name_type);
}
}
- g_free (mime_type);
if (apps) {
GString *label = g_string_new("");
@@ -800,6 +834,23 @@ emp_standard_menu_factory(EPopup *emp, void *data)
g_string_free(label, TRUE);
g_list_free(apps);
}
+
+ if (g_ascii_strcasecmp (mime_type, "text/x-vcard") == 0||
+ g_ascii_strcasecmp (mime_type, "text/vcard") == 0) {
+ EPopupItem *item;
+
+ item = g_malloc0 (sizeof (*item));
+ item->type = E_POPUP_ITEM;
+ item->path = "00.00.vcf.00"; /* make it first item */
+ item->label = _("_Add to Address Book");
+ item->activate = emp_add_vcard;
+ item->user_data = NULL;
+ item->image = "contact-new";
+
+ e_popup_add_items (emp, g_slist_append (NULL, item), NULL, NULL, NULL);
+ }
+
+ g_free (mime_type);
}
for (i=0;i<len;i++) {