[Evolution-hackers] Message-ID



Hello, I've come up with a simple patch to change the generated
Message-IDs. Currently they're like:
{UNIX-time}.{Evolution PID}.{Mail Counter since Evolution
Start}@{Machine Name}

I've simply taken it, computed the SHA512, put it in BASE64 and then I
append @evolution.gnome.org

Message-id:
<aLO-ZyWA3VbQYwsp0A8fb3QzU-2r36DMQn7DXTPYvQ9VBSosLp0UrDkWy9cEYt654ZmGbJ_byk19gT-3CzmVPw evolution gnome org>

Comments, critics or simple rejection are welcome. Feel free to change
or improve the patch, which is GPL'd.

I've worked on gnome-2-32 branch.

Have a nice day!
venom00


diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 8e51497..952c2af 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -56,6 +56,9 @@
 #endif
 #include "camel-utf8.h"
 
+#include <nss/sechash.h>
+#include <glib.h>
+
 #ifdef G_OS_WIN32
 #ifdef gmtime_r
 #undef gmtime_r
@@ -4398,6 +4401,9 @@ camel_header_msgid_generate (void)
 	gint retval;
 	struct addrinfo *ai = NULL, hints = { 0 };
 	static gchar *cached_hostname = NULL;
+	guchar hash[SHA512_LENGTH];
+	gchar *base64_hash = NULL;
+	gint i = 0;
 
 	if (!cached_hostname) {
 		retval = gethostname (host, sizeof (host));
@@ -4417,7 +4423,23 @@ camel_header_msgid_generate (void)
 	COUNT_LOCK ();
 	msgid = g_strdup_printf ("%d.%d.%d.camel@%s", (gint) time (NULL),
getpid (), count++, cached_hostname);
 	COUNT_UNLOCK ();
-
+	
+	HASH_HashBuf(HASH_AlgSHA512, hash, (guchar *) msgid, strlen(msgid));
+	g_free(msgid);
+	base64_hash = g_base64_encode(hash, sizeof (hash));
+
+	base64_hash[sizeof(hash)*8/6+1] = '\0';
+	for (i = 0; i < strlen(base64_hash); i++) {
+		if (base64_hash[i] == '/') {
+			base64_hash[i] = '_';
+		} else if (base64_hash[i] == '+') {
+			base64_hash[i] = '-';
+		}
+	}
+	  
+	msgid = g_strdup_printf ("%s@%s", base64_hash, "evolution.gnome.org");
+	g_free(base64_hash);
+	
 	if (ai)
 		camel_freeaddrinfo(ai);
 
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 8e51497..952c2af 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -56,6 +56,9 @@
 #endif
 #include "camel-utf8.h"
 
+#include <nss/sechash.h>
+#include <glib.h>
+
 #ifdef G_OS_WIN32
 #ifdef gmtime_r
 #undef gmtime_r
@@ -4398,6 +4401,9 @@ camel_header_msgid_generate (void)
 	gint retval;
 	struct addrinfo *ai = NULL, hints = { 0 };
 	static gchar *cached_hostname = NULL;
+	guchar hash[SHA512_LENGTH];
+	gchar *base64_hash = NULL;
+	gint i = 0;
 
 	if (!cached_hostname) {
 		retval = gethostname (host, sizeof (host));
@@ -4417,7 +4423,23 @@ camel_header_msgid_generate (void)
 	COUNT_LOCK ();
 	msgid = g_strdup_printf ("%d.%d.%d.camel@%s", (gint) time (NULL), getpid (), count++, cached_hostname);
 	COUNT_UNLOCK ();
-
+	
+	HASH_HashBuf(HASH_AlgSHA512, hash, (guchar *) msgid, strlen(msgid));
+	g_free(msgid);
+	base64_hash = g_base64_encode(hash, sizeof (hash));
+
+	base64_hash[sizeof(hash)*8/6+1] = '\0';
+	for (i = 0; i < strlen(base64_hash); i++) {
+		if (base64_hash[i] == '/') {
+			base64_hash[i] = '_';
+		} else if (base64_hash[i] == '+') {
+			base64_hash[i] = '-';
+		}
+	}
+	  
+	msgid = g_strdup_printf ("%s@%s", base64_hash, "evolution.gnome.org");
+	g_free(base64_hash);
+	
 	if (ai)
 		camel_freeaddrinfo(ai);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]