]> code.citadel.org Git - citadel.git/blobdiff - citadel/internet_addressing.c
* Bug fixes
[citadel.git] / citadel / internet_addressing.c
index 837279aabea9187ebd2808836908a0f680a2c2b6..f6e39e374ecf2c9f82b0e636c3bc190d05b3e54e 100644 (file)
@@ -29,6 +29,7 @@
 #include "tools.h"
 #include "internet_addressing.h"
 #include "user_ops.h"
+#include "room_ops.h"
 #include "parsedate.h"
 
 
@@ -240,6 +241,8 @@ int convert_internet_address(char *destuser, char *desthost, char *source)
        char user[256];
        char node[256];
        char name[256];
+       struct quickroom qrbuf;
+       int i;
 
        /* Split it up */
        process_rfc822_addr(source, user, node, name);
@@ -252,17 +255,23 @@ int convert_internet_address(char *destuser, char *desthost, char *source)
                strcpy(node, config.c_nodename);
        }
 
-       /* Return an error condition if the node is not known.
-        * FIX ... make this work for non-local systems
-        */
-       if (strcasecmp(node, config.c_nodename)) {
-               return(rfc822_address_invalid);
-       }
-       
        /* Now try to resolve the name
         * FIX ... do the multiple-addresses thing
         */
        if (!strcasecmp(node, config.c_nodename)) {
+               /* Try all local rooms */
+               if (!strncasecmp(user, "room_", 5)) {
+                       strcpy(name, &user[5]);
+                       for (i=0; i<strlen(name); ++i) 
+                               if (name[i]=='_') name[i]=' ';
+                       if (getroom(&qrbuf, name) == 0) {
+                               strcpy(destuser, qrbuf.QRname);
+                               strcpy(desthost, config.c_nodename);
+                               return rfc822_room_delivery;
+                       }
+               }
+
+               /* Try all local users */
                strcpy(destuser, user);
                strcpy(desthost, config.c_nodename);
                strcpy(CC->buffer1, user);
@@ -273,6 +282,8 @@ int convert_internet_address(char *destuser, char *desthost, char *source)
                return(rfc822_address_locally_validated);
        }
 
+       strcpy(destuser, user);
+       strcpy(desthost, node);
        return(rfc822_address_invalid); /* unknown error */
 }
 
@@ -348,14 +359,6 @@ int convert_field(struct CtdlMessage *msg, int beg, int end) {
                processed = 1;
        }
 
-       /* If a content type is specified, this becomes a MIME message.  The
-        * content-type header itself remains in the RFC822 headers, not in
-        * the Citadel headers, therefore we do not set 'processed' to 1.
-        */
-       else if (!strcasecmp(key, "Content-type")) {
-               msg->cm_format_type = 4;
-       }
-
        /* Clean up and move on. */
        phree(key);     /* Don't free 'value', it's actually the same buffer */
        return(processed);
@@ -379,7 +382,7 @@ struct CtdlMessage *convert_internet_message(char *rfc822) {
        memset(msg, 0, sizeof(struct CtdlMessage));
        msg->cm_magic = CTDLMESSAGE_MAGIC;      /* self check */
        msg->cm_anon_type = 0;                  /* never anonymous */
-       msg->cm_format_type = 1;                /* text unless specified */
+       msg->cm_format_type = FMT_RFC822;       /* internet message */
        msg->cm_fields['M'] = rfc822;
 
        lprintf(9, "Unconverted RFC822 message length = %d\n", strlen(rfc822));
@@ -409,10 +412,13 @@ struct CtdlMessage *convert_internet_message(char *rfc822) {
 
                /* At this point we have a field.  Are we interested in it? */
                converted = convert_field(msg, beg, end);
+
+               /******
                if (converted) {
                        strcpy(&rfc822[beg], &rfc822[pos]);
                        pos = beg;
                }
+               ********/
 
                /* If we've hit the end of the message, bail out */
                if (pos > strlen(rfc822)) done = 1;