NETCFG: reimplement network_sync_to using the new api
[citadel.git] / citadel / modules / network / serv_netmail.c
index faf62a01cd4482e8cfac889900edf05683575b2d..9bc9df123831389e3d8c899d3b8ff92e6dc0cd54 100644 (file)
 #include "citadel_dirs.h"
 #include "threads.h"
 #include "context.h"
-#include "netconfig.h"
+#include "ctdl_module.h"
 #include "netspool.h"
 #include "netmail.h"
-#include "ctdl_module.h"
 
 
 /*
@@ -95,7 +94,7 @@ void network_deliver_digest(SpoolControl *sc) {
        char *precps;
        size_t recps_len = SIZ;
        struct recptypes *valid;
-       namelist *nptr;
+       RoomNetCfgLine *nptr;
        char bounce_to[256];
 
        if (sc->num_msgs_spooled < 1) {
@@ -152,7 +151,7 @@ void network_deliver_digest(SpoolControl *sc) {
         * Figure out how big a buffer we need to allocate
         */
        for (nptr = sc->NetConfigs[digestrecp]; nptr != NULL; nptr = nptr->next) {
-               recps_len = recps_len + StrLength(nptr->Value) + 2;
+               recps_len = recps_len + StrLength(nptr->Value[0]) + 2;
        }
 
        recps = NewStrBufPlain(NULL, recps_len);
@@ -169,7 +168,7 @@ void network_deliver_digest(SpoolControl *sc) {
                if (nptr != sc->NetConfigs[digestrecp]) {
                        StrBufAppendBufPlain(recps, HKEY(","), 0);
                }
-               StrBufAppendBuf(recps, nptr->Value, 0);
+               StrBufAppendBuf(recps, nptr->Value[0], 0);
        }
 
        /* Where do we want bounces and other noise to be heard?
@@ -200,7 +199,7 @@ void network_deliver_list(struct CtdlMessage *msg, SpoolControl *sc, const char
        char *precps = NULL;
        size_t recps_len = SIZ;
        struct recptypes *valid;
-       namelist *nptr;
+       RoomNetCfgLine *nptr;
        char bounce_to[256];
 
        /* Don't do this if there were no recipients! */
@@ -212,7 +211,7 @@ void network_deliver_list(struct CtdlMessage *msg, SpoolControl *sc, const char
         * Figure out how big a buffer we need to allocate
         */
        for (nptr = sc->NetConfigs[listrecp]; nptr != NULL; nptr = nptr->next) {
-               recps_len = recps_len + StrLength(nptr->Value) + 2;
+               recps_len = recps_len + StrLength(nptr->Value[0]) + 2;
        }
 
        recps = NewStrBufPlain(NULL, recps_len);
@@ -229,7 +228,7 @@ void network_deliver_list(struct CtdlMessage *msg, SpoolControl *sc, const char
                if (nptr != sc->NetConfigs[listrecp]) {
                        StrBufAppendBufPlain(recps, HKEY(","), 0);
                }
-               StrBufAppendBuf(recps, nptr->Value, 0);
+               StrBufAppendBuf(recps, nptr->Value[0], 0);
        }
 
        /* Where do we want bounces and other noise to be heard?
@@ -257,14 +256,14 @@ void network_deliver_list(struct CtdlMessage *msg, SpoolControl *sc, const char
 void network_spool_msg(long msgnum,
                       void *userdata)
 {
+       RoomNetCfgLine* mptr;
        struct CitContext *CCC = CC;
        StrBuf *Buf = NULL;
        SpoolControl *sc;
        int i;
        char *newpath = NULL;
        struct CtdlMessage *msg = NULL;
-       namelist *nptr;
-       maplist *mptr;
+       RoomNetCfgLine *nptr;
        struct ser_ret sermsg;
        FILE *fp;
        char filename[PATH_MAX];
@@ -466,11 +465,11 @@ void network_spool_msg(long msgnum,
                                }
 
                                Buf = NewStrBufPlain(msg->cm_fields['N'], -1);
-                               if (is_valid_node(NULL,
-                                                 NULL,
-                                                 Buf,
-                                                 sc->working_ignetcfg,
-                                                 sc->the_netmap) == 0)
+                               if (CtdlIsValidNode(NULL,
+                                                   NULL,
+                                                   Buf,
+                                                   sc->working_ignetcfg,
+                                                   sc->the_netmap) == 0)
                                {
                                        ok_to_participate = 1;
                                }
@@ -506,7 +505,7 @@ void network_spool_msg(long msgnum,
                                                free(msg->cm_fields['R']);
                                        }
                                        msg->cm_fields['R'] =
-                                               strdup(ChrPtr(nptr->Value));
+                                               strdup(ChrPtr(nptr->Value[0]));
 
                                        valid = validate_recipients(msg->cm_fields['R'],
                                                                    NULL, 0);
@@ -552,22 +551,22 @@ void network_spool_msg(long msgnum,
 
                /* Now send it to every node */
                if (sc->NetConfigs[ignet_push_share] != NULL)
-               for (mptr = (maplist*)sc->NetConfigs[ignet_push_share]; mptr != NULL;
+               for (mptr = sc->NetConfigs[ignet_push_share]; mptr != NULL;
                    mptr = mptr->next) {
 
                        send = 1;
-                       NewStrBufDupAppendFlush(&Buf, mptr->remote_nodename, NULL, 1);
+                       NewStrBufDupAppendFlush(&Buf, mptr->Value[0], NULL, 1);
 
                        /* Check for valid node name */
-                       if (is_valid_node(NULL,
-                                         NULL,
-                                         Buf,
-                                         sc->working_ignetcfg,
-                                         sc->the_netmap) != 0)
+                       if (CtdlIsValidNode(NULL,
+                                           NULL,
+                                           Buf,
+                                           sc->working_ignetcfg,
+                                           sc->the_netmap) != 0)
                        {
                                QN_syslog(LOG_ERR,
                                          "Invalid node <%s>\n",
-                                         ChrPtr(mptr->remote_nodename));
+                                         ChrPtr(mptr->Value[0]));
 
                                send = 0;
                        }
@@ -583,8 +582,8 @@ void network_spool_msg(long msgnum,
                                                      sizeof buf);
                                        
                                        QN_syslog(LOG_DEBUG, "Compare <%s> to <%s>\n",
-                                                 buf, ChrPtr(mptr->remote_nodename)) ;
-                                       if (!strcasecmp(buf, ChrPtr(mptr->remote_nodename))) {
+                                                 buf, ChrPtr(mptr->Value[0])) ;
+                                       if (!strcasecmp(buf, ChrPtr(mptr->Value[0]))) {
                                                send = 0;
                                                break;
                                        }
@@ -593,7 +592,7 @@ void network_spool_msg(long msgnum,
                                QN_syslog(LOG_INFO,
                                          "%sSending to %s\n",
                                          (send)?"":"Not ",
-                                         ChrPtr(mptr->remote_nodename));
+                                         ChrPtr(mptr->Value[0]));
                        }
 
                        /* Send the message */
@@ -607,9 +606,9 @@ void network_spool_msg(long msgnum,
                                if (msg->cm_fields['C'] != NULL) {
                                        free(msg->cm_fields['C']);
                                }
-                               if (StrLength(mptr->remote_roomname) > 0) {
+                               if (StrLength(mptr->Value[0]) > 0) {
                                        msg->cm_fields['C'] =
-                                               strdup(ChrPtr(mptr->remote_roomname));
+                                               strdup(ChrPtr(mptr->Value[0]));
                                }
                                else {
                                        msg->cm_fields['C'] =
@@ -625,7 +624,7 @@ void network_spool_msg(long msgnum,
                                                 sizeof(filename),
                                                 "%s/%s@%lx%x",
                                                 ctdl_netout_dir,
-                                                ChrPtr(mptr->remote_nodename),
+                                                ChrPtr(mptr->Value[0]),
                                                 time(NULL),
                                                 rand()
                                        );
@@ -657,7 +656,7 @@ void network_spool_msg(long msgnum,
        }
 
        /* update lastsent */
-       sc->lastsent = msgnum;
+       ///sc->lastsent = msgnum; ////// TODO
 
        /* Delete this message if delete-after-send is set */
        if (delete_after_send) {