aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@gnome-db.org>2011-10-28 17:38:03 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-10-28 17:38:03 +0800
commitb3b35231e2ce675202ef9f1a7ccefdc3ab0e0e89 (patch)
tree7190b4353c533028b4a0c27d241d96e883a280ad /plugins
parent9744056c5e69227abdcdd55c4bffb674b29bd765 (diff)
parent8f5493140c4da6e81e2c14e77833bfbb56c619f8 (diff)
downloadgsoc2013-evolution-b3b35231e2ce675202ef9f1a7ccefdc3ab0e0e89.tar
gsoc2013-evolution-b3b35231e2ce675202ef9f1a7ccefdc3ab0e0e89.tar.gz
gsoc2013-evolution-b3b35231e2ce675202ef9f1a7ccefdc3ab0e0e89.tar.bz2
gsoc2013-evolution-b3b35231e2ce675202ef9f1a7ccefdc3ab0e0e89.tar.lz
gsoc2013-evolution-b3b35231e2ce675202ef9f1a7ccefdc3ab0e0e89.tar.xz
gsoc2013-evolution-b3b35231e2ce675202ef9f1a7ccefdc3ab0e0e89.tar.zst
gsoc2013-evolution-b3b35231e2ce675202ef9f1a7ccefdc3ab0e0e89.zip
Merge branch 'master' into wip/gsettings
Diffstat (limited to 'plugins')
-rw-r--r--plugins/pst-import/pst-importer.c67
1 files changed, 62 insertions, 5 deletions
diff --git a/plugins/pst-import/pst-importer.c b/plugins/pst-import/pst-importer.c
index 89e45e6785..7ef82d450e 100644
--- a/plugins/pst-import/pst-importer.c
+++ b/plugins/pst-import/pst-importer.c
@@ -551,10 +551,12 @@ org_credativ_evolution_readpst_getwidget (EImport *ei,
g_signal_connect (w, "selected", G_CALLBACK (folder_selected), target);
gtk_box_pack_end ((GtkBox *) hbox, w, FALSE, FALSE, 0);
g_signal_connect (check, "toggled", G_CALLBACK (widget_sanitizer_cb), w);
+ widget_sanitizer_cb (GTK_TOGGLE_BUTTON (check), w);
w = gtk_label_new (_("Destination folder:"));
gtk_box_pack_end ((GtkBox *) hbox, w, FALSE, TRUE, 6);
g_signal_connect (check, "toggled", G_CALLBACK (widget_sanitizer_cb), w);
+ widget_sanitizer_cb (GTK_TOGGLE_BUTTON (check), w);
gtk_box_pack_start ((GtkBox *) framebox, hbox, FALSE, FALSE, 0);
@@ -1113,6 +1115,61 @@ attachment_to_part (PstImporter *m,
}
static void
+dequote_string (gchar *str)
+{
+ if (str[0] == '\'' || str[0] == '\"') {
+ gint len = strlen (str);
+
+ if (len > 1 && (str[len - 1] == '\'' || str[len - 1] == '\"')) {
+ str[0] = ' ';
+ str[len - 1] = ' ';
+ g_strstrip (str);
+ }
+ }
+}
+
+static gboolean
+lookup_address (pst_item *item, const gchar *str, gboolean is_unique, CamelAddress *addr)
+{
+ gboolean res = FALSE;
+ gchar *address;
+
+ if (!item || !str || !*str || !addr)
+ return FALSE;
+
+ address = g_strdup (str);
+ dequote_string (address);
+
+ if (item->contact && item->file_as.str &&
+ (is_unique || g_str_equal (item->file_as.str, str)) &&
+ item->contact->address1.str &&
+ item->contact->address1_transport.str &&
+ g_ascii_strcasecmp (item->contact->address1_transport.str, "SMTP") == 0 &&
+ !g_str_equal (address, item->contact->address1.str)) {
+ gchar *tmp = address;
+
+ address = g_strconcat ("\"", address, "\" <", item->contact->address1.str, ">", NULL);
+
+ g_free (tmp);
+ }
+
+ res = camel_address_decode (addr, address) > 0;
+
+ g_free (address);
+
+ return res;
+}
+
+static const gchar *
+strip_smtp (const gchar *str)
+{
+ if (str && g_ascii_strncasecmp (str, "SMTP:", 5) == 0)
+ return str + 5;
+
+ return str;
+}
+
+static void
pst_process_email (PstImporter *m,
pst_item *item)
{
@@ -1201,11 +1258,11 @@ pst_process_email (PstImporter *m,
addr = camel_internet_address_new ();
if (item->email->outlook_sender_name.str != NULL && item->email->outlook_sender.str != NULL) {
- camel_internet_address_add (addr, item->email->outlook_sender_name.str, item->email->outlook_sender.str);
+ camel_internet_address_add (addr, item->email->outlook_sender_name.str, strip_smtp (item->email->outlook_sender.str));
} else if (item->email->outlook_sender_name.str != NULL) {
- camel_address_decode (CAMEL_ADDRESS (addr), item->email->outlook_sender_name.str);
+ camel_address_decode (CAMEL_ADDRESS (addr), strip_smtp (item->email->outlook_sender_name.str));
} else if (item->email->outlook_sender.str != NULL) {
- camel_address_decode (CAMEL_ADDRESS (addr), item->email->outlook_sender.str);
+ camel_address_decode (CAMEL_ADDRESS (addr), strip_smtp (item->email->outlook_sender.str));
} else {
/* Evo prints a warning if no from is set, so supply an empty address */
camel_internet_address_add (addr, "", "");
@@ -1237,7 +1294,7 @@ pst_process_email (PstImporter *m,
if (item->email->sentto_address.str != NULL) {
addr = camel_internet_address_new ();
- if (camel_address_decode (CAMEL_ADDRESS (addr), item->email->sentto_address.str) > 0)
+ if (lookup_address (item, item->email->sentto_address.str, item->email->cc_address.str == NULL, CAMEL_ADDRESS (addr)))
camel_mime_message_set_recipients (msg, "To", addr);
g_object_unref (addr);
@@ -1246,7 +1303,7 @@ pst_process_email (PstImporter *m,
if (item->email->cc_address.str != NULL) {
addr = camel_internet_address_new ();
- if (camel_address_decode (CAMEL_ADDRESS (addr), item->email->cc_address.str) > 0)
+ if (lookup_address (item, item->email->cc_address.str, item->email->sentto_address.str == NULL, CAMEL_ADDRESS (addr)))
camel_mime_message_set_recipients (msg, "CC", addr);
g_object_unref (addr);