]> code.citadel.org Git - citadel.git/blobdiff - citadel/journaling.c
Completed DVCA (Dump VCard Addresses) function. This function
[citadel.git] / citadel / journaling.c
index f45d601c6fcc054b2b9d4388e744945a843011fe..38629ab41eff073c82f6406e0e1216d33032296e 100644 (file)
@@ -47,6 +47,8 @@
 #include "html.h"
 #include "genstamp.h"
 #include "internet_addressing.h"
+#include "vcard.h"
+#include "serv_vcard.h"
 #include "journaling.h"
 
 struct jnlq *jnlq = NULL;      /* journal queue */
@@ -88,6 +90,28 @@ void JournalBackgroundSubmit(struct CtdlMessage *msg,
 }
 
 
+/*
+ * Convert a local user name to an internet email address for the journal
+ */
+void local_to_inetemail(char *inetemail, char *localuser, size_t inetemail_len) {
+       struct ctdluser us;
+       struct vCard *v;
+
+       strcpy(inetemail, "");
+       if (getuser(&us, localuser) != 0) {
+               return;
+       }
+
+       v = vcard_get_user(&us);
+       if (v == NULL) {
+               return;
+       }
+
+       extract_inet_email_addrs(inetemail, inetemail_len, NULL, 0, v, 1);
+       vcard_free(v);
+}
+
+
 /*
  * Called by JournalRunQueue() to send an individual message.
  */
@@ -98,6 +122,7 @@ void JournalRunQueueMsg(struct jnlq *jmsg) {
        char *message_text = NULL;
        char mime_boundary[256];
        char recipient[256];
+       char inetemail[256];
        static int seq = 0;
        int i;
 
@@ -136,11 +161,11 @@ void JournalRunQueueMsg(struct jnlq *jmsg) {
                         */
                        sprintf(message_text,
                                "Content-type: multipart/mixed; boundary=\"%s\"\r\n"
+                               "Content-Identifer: ExJournalReport\r\n"
                                "MIME-Version: 1.0\r\n"
                                "\n"
                                "--%s\r\n"
                                "Content-type: text/plain\r\n"
-                               "Content-Identifer: ExJournalReport\r\n"
                                "\r\n"
                                "Sender: %s "
                        ,
@@ -170,8 +195,9 @@ void JournalRunQueueMsg(struct jnlq *jmsg) {
                                for (i=0; i<jmsg->recps.num_local; ++i) {
                                        extract_token(recipient, jmsg->recps.recp_local,
                                                        i, '|', sizeof recipient);
+                                       local_to_inetemail(inetemail, recipient, sizeof inetemail);
                                        sprintf(&message_text[strlen(message_text)],
-                                               "       %s\r\n", recipient);
+                                               "       %s <%s>\r\n", recipient, inetemail);
                                }
                        }
 
@@ -215,7 +241,7 @@ void JournalRunQueueMsg(struct jnlq *jmsg) {
                        CtdlFreeMessage(journal_msg);
                }
 
-               free(journal_recps);
+               free_recipients(journal_recps);
        }
 
        /* We are responsible for freeing this memory. */
@@ -227,7 +253,7 @@ void JournalRunQueueMsg(struct jnlq *jmsg) {
  * Run the queue.
  */
 void JournalRunQueue(void) {
-       struct jnlq *jptr;
+       struct jnlq *jptr = NULL;
 
        while (jnlq != NULL) {
                begin_critical_section(S_JOURNAL_QUEUE);