[evolution-data-server] Bug 702703 - Be able to overwrite domain in Message IDs
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug 702703 - Be able to overwrite domain in Message IDs
- Date: Tue, 17 Jun 2014 09:50:24 +0000 (UTC)
commit 5772fd692854e3b0abb9308e7eacdb8368caaf85
Author: Milan Crha <mcrha redhat com>
Date: Tue Jun 17 11:49:23 2014 +0200
Bug 702703 - Be able to overwrite domain in Message IDs
camel/camel-mime-message.c | 14 +++++++++++++-
camel/camel-mime-part.c | 2 +-
camel/camel-mime-utils.c | 19 +++++++++++++++----
camel/camel-mime-utils.h | 2 +-
configure.ac | 2 +-
5 files changed, 31 insertions(+), 8 deletions(-)
---
diff --git a/camel/camel-mime-message.c b/camel/camel-mime-message.c
index 20f17b0..023bd49 100644
--- a/camel/camel-mime-message.c
+++ b/camel/camel-mime-message.c
@@ -536,7 +536,19 @@ camel_mime_message_set_message_id (CamelMimeMessage *mime_message,
if (message_id) {
id = g_strstrip (g_strdup (message_id));
} else {
- id = camel_header_msgid_generate ();
+ CamelInternetAddress *from;
+ const gchar *domain = NULL;
+
+ from = camel_mime_message_get_from (mime_message);
+ if (from && camel_internet_address_get (from, 0, NULL, &domain) && domain) {
+ const gchar *at = strchr (domain, '@');
+ if (at)
+ domain = at + 1;
+ else
+ domain = NULL;
+ }
+
+ id = camel_header_msgid_generate (domain);
}
mime_message->message_id = id;
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index c7c2b6a..117f163 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -1217,7 +1217,7 @@ camel_mime_part_set_content_id (CamelMimePart *mime_part,
if (contentid)
id = g_strstrip (g_strdup (contentid));
else
- id = camel_header_msgid_generate ();
+ id = camel_header_msgid_generate (NULL);
cid = g_strdup_printf ("<%s>", id);
camel_medium_set_header (medium, "Content-ID", cid);
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 8f01b16..0a98411 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -4703,8 +4703,17 @@ camel_header_raw_clear (struct _camel_header_raw **list)
*list = NULL;
}
+/**
+ * camel_header_msgid_generate:
+ * @domain: domain to use (like "example.com") for the ID suffix; can be NULL
+ *
+ * Either the @domain is used, or the user's local hostname,
+ * in case it's NULL or empty.
+ *
+ * Returns: Unique message ID.
+ **/
gchar *
-camel_header_msgid_generate (void)
+camel_header_msgid_generate (const gchar *domain)
{
static GMutex count_lock;
#define COUNT_LOCK() g_mutex_lock (&count_lock)
@@ -4717,7 +4726,10 @@ camel_header_msgid_generate (void)
struct addrinfo *ai = NULL, hints = { 0 };
static gchar *cached_hostname = NULL;
- if (!cached_hostname) {
+ COUNT_LOCK ();
+ if (!cached_hostname && (!domain || !*domain)) {
+ domain = NULL;
+
retval = gethostname (host, sizeof (host));
if (retval == 0 && *host) {
hints.ai_flags = AI_CANONNAME;
@@ -4733,8 +4745,7 @@ camel_header_msgid_generate (void)
cached_hostname = g_strdup (name);
}
- COUNT_LOCK ();
- msgid = g_strdup_printf ("%d %d %d camel %s", (gint) time (NULL), getpid (), count++,
cached_hostname);
+ msgid = g_strdup_printf ("%d %d %d camel %s", (gint) time (NULL), getpid (), count++, domain ? domain
: cached_hostname);
COUNT_UNLOCK ();
if (ai)
diff --git a/camel/camel-mime-utils.h b/camel/camel-mime-utils.h
index 6ca102a..a0981c6 100644
--- a/camel/camel-mime-utils.h
+++ b/camel/camel-mime-utils.h
@@ -201,7 +201,7 @@ gchar *camel_header_msgid_decode (const gchar *in);
gchar *camel_header_contentid_decode (const gchar *in);
/* generate msg id */
-gchar *camel_header_msgid_generate (void);
+gchar *camel_header_msgid_generate (const gchar *domain);
/* decode a References or In-Reply-To header */
struct _camel_header_references *camel_header_references_inreplyto_decode (const gchar *in);
diff --git a/configure.ac b/configure.ac
index 49cc959..bc340ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -130,7 +130,7 @@ LIBEBOOK_CONTACTS_CURRENT=0
LIBEBOOK_CONTACTS_REVISION=0
LIBEBOOK_CONTACTS_AGE=0
-LIBCAMEL_CURRENT=49
+LIBCAMEL_CURRENT=50
LIBCAMEL_REVISION=0
LIBCAMEL_AGE=0
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]