Networker: remove unneeded assignment
[citadel.git] / citadel / journaling.c
index ec158b43c80999e120a1d02669002900aa6d3acb..33b840732fa300178933c38f7631bc3ba0f5837d 100644 (file)
@@ -1,8 +1,5 @@
 /*
- * $Id:  $
- *
  * Message journaling functions.
- *
  */
 
 #include "sysdep.h"
@@ -29,9 +26,9 @@
 #include <errno.h>
 #include <stdarg.h>
 #include <sys/stat.h>
+#include <libcitadel.h>
 #include "citadel.h"
 #include "server.h"
-#include "serv_extensions.h"
 #include "database.h"
 #include "msgbase.h"
 #include "support.h"
 #include "file_ops.h"
 #include "config.h"
 #include "control.h"
-#include "tools.h"
-#include "mime_parser.h"
-#include "html.h"
 #include "genstamp.h"
 #include "internet_addressing.h"
-#include "vcard.h"
-#include "serv_vcard.h"
+#include "serv_vcard.h"                        /* Needed for vcard_getuser and extract_inet_email_addrs */
 #include "journaling.h"
 
+#include "ctdl_module.h"
+#include "threads.h"
+
 struct jnlq *jnlq = NULL;      /* journal queue */
 
 /*
  * Hand off a copy of a message to be journalized.
  */
 void JournalBackgroundSubmit(struct CtdlMessage *msg,
-                       char *saved_rfc822_version,
+                       StrBuf *saved_rfc822_version,
                        struct recptypes *recps) {
 
        struct jnlq *jptr = NULL;
 
        /* Avoid double journaling! */
        if (msg->cm_fields['J'] != NULL) {
-               free(saved_rfc822_version);
+               FreeStrBuf(&saved_rfc822_version);
                return;
        }
 
        jptr = (struct jnlq *)malloc(sizeof(struct jnlq));
        if (jptr == NULL) {
-               free(saved_rfc822_version);
+               FreeStrBuf(&saved_rfc822_version);
                return;
        }
        memset(jptr, 0, sizeof(struct jnlq));
@@ -80,7 +76,7 @@ void JournalBackgroundSubmit(struct CtdlMessage *msg,
        if (msg->cm_fields['F'] != NULL) jptr->rfca = strdup(msg->cm_fields['F']);
        if (msg->cm_fields['U'] != NULL) jptr->subj = strdup(msg->cm_fields['U']);
        if (msg->cm_fields['I'] != NULL) jptr->msgn = strdup(msg->cm_fields['I']);
-       jptr->rfc822 = saved_rfc822_version;
+       jptr->rfc822 = SmashStrBuf(&saved_rfc822_version);
 
        /* Add to the queue */
        begin_critical_section(S_JOURNAL_QUEUE);
@@ -93,12 +89,20 @@ void JournalBackgroundSubmit(struct CtdlMessage *msg,
 /*
  * Convert a local user name to an internet email address for the journal
  */
+/*
+ * TODODRW: change this into a CtdlModuleDo type function that returns alternative address info
+ * for this local user. Something like CtdlModuleGoGetAddr(char *localuser, int type, char *alt_addr, size_t alt_addr_len)
+ * where type can be ADDR_EMAIL, ADDR_FIDO, ADDR_UUCP, ADDR_WEB, ADDR_POSTAL etc etc.
+ * This then begs the question of what should be returned. Is it wise to return a single char* using a comma as a
+ * delimiter? Or would it be better to return a linked list of some kind?
+ */
 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) {
+       if (CtdlGetUser(&us, localuser) != 0) {
                return;
        }
 
@@ -107,7 +111,7 @@ void local_to_inetemail(char *inetemail, char *localuser, size_t inetemail_len)
                return;
        }
 
-       extract_primary_inet_email(inetemail, inetemail_len, v);
+       extract_inet_email_addrs(inetemail, inetemail_len, NULL, 0, v, 1);
        vcard_free(v);
 }
 
@@ -126,7 +130,7 @@ void JournalRunQueueMsg(struct jnlq *jmsg) {
        static int seq = 0;
        int i;
 
-       journal_recps = validate_recipients(config.c_journal_dest);
+       journal_recps = validate_recipients(config.c_journal_dest, NULL, 0);
        if (journal_recps != NULL) {
 
                if (  (journal_recps->num_local > 0)
@@ -237,11 +241,11 @@ void JournalRunQueueMsg(struct jnlq *jmsg) {
                        free(jmsg->msgn);
                        
                        /* Submit journal message */
-                       CtdlSubmitMsg(journal_msg, journal_recps, "");
+                       CtdlSubmitMsg(journal_msg, journal_recps, "", 0);
                        CtdlFreeMessage(journal_msg);
                }
 
-               free(journal_recps);
+               free_recipients(journal_recps);
        }
 
        /* We are responsible for freeing this memory. */