more sorting out of the headers
[citadel.git] / webcit / messages.c
index 8dcc5c13aed142d94349b1069ad62c45807c5195..a98d702572aa500b1d83ccdd64776d52d31db557 100644 (file)
@@ -1404,15 +1404,15 @@ void display_enter(void) {
                return;
        }
 
-
        ReplyingModeStr = bstr("replying_mode");
-       if (ReplyingModeStr != NULL) for (i = 0; i < 3; i++) {
+       if (ReplyingModeStr != NULL) {
+               for (i = 0; i < 3; i++) {
                        if (strcmp(ReplyingModeStr, ReplyToModeStrings[i]) == 0) {
                                ReplyMode = (eReplyToNodes) i;
                                break;
                        }
                }
-               
+       }
 
        /*
         * If the "replying_to" variable is set, it refers to a message
@@ -1424,26 +1424,19 @@ void display_enter(void) {
                StrBuf *wefw = NULL;
                StrBuf *msgn = NULL;
                StrBuf *from = NULL;
-               StrBuf *node = NULL;
                StrBuf *rfca = NULL;
                StrBuf *rcpt = NULL;
                StrBuf *cccc = NULL;
                StrBuf *replyto = NULL;
                StrBuf *nvto = NULL;
+               int message_originated_locally = 0;
                serv_printf("MSG0 %ld|1", replying_to); 
 
                StrBuf_ServGetln(Line);
                if (GetServerStatusMsg(Line, NULL, 0, 0) == 1)
-                       while (len = StrBuf_ServGetln(Line),
-                              (len >= 0) && 
-                              ((len != 3)  ||
-                               strcmp(ChrPtr(Line), "000")))
-                       {
+                       while (len = StrBuf_ServGetln(Line), (len >= 0) && ((len != 3) || strcmp(ChrPtr(Line), "000"))) {
                                eMessageField which;
-                               if ((StrLength(Line) > 4) && 
-                                   (ChrPtr(Line)[4] == '=') &&
-                                   GetFieldFromMnemonic(&which, ChrPtr(Line)))
-                                       switch (which) {
+                               if ((StrLength(Line) > 4) && (ChrPtr(Line)[4] == '=') && GetFieldFromMnemonic(&which, ChrPtr(Line))) switch (which) {
                                        case eMsgSubject: {
                                                StrBuf *subj = NewStrBuf();
                                                StrBuf *FlatSubject;
@@ -1468,6 +1461,11 @@ void display_enter(void) {
                                        }
                                                break;
 
+                                       case eIsLocal: {
+                                               message_originated_locally = 1;
+                                               break;
+                                       }
+
                                        case eWeferences:
                                        {
                                                int rrtok;
@@ -1503,20 +1501,12 @@ void display_enter(void) {
                                                }
                                                break;
                                        }
-                               
                                        case eRecipient:
                                                rcpt = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
                                                break;
-                       
-                               
                                        case eCarbonCopY:
                                                cccc = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
                                                break;
-
-                               
-                                       case eNodeName:
-                                               node = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
-                                               break;
                                        case eReplyTo:
                                                replyto = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
                                                break;
@@ -1534,11 +1524,9 @@ void display_enter(void) {
                                                putbstr("nvto", nvto);
                                                break;
                                        case eXclusivID:
-                                       case eHumanNode:
                                        case eJournal:
                                        case eListID:
                                        case eMesageText:
-                                       case eOriginalRoom:
                                        case eMessagePath:
                                        case eSpecialField:
                                        case eTimestamp:
@@ -1546,7 +1534,6 @@ void display_enter(void) {
                                        case eFormatType:
                                        case eMessagePart:
                                        case eSubFolder:
-                                       case ePevious:
                                        case eLastHeader:
                                                break;
 
@@ -1573,13 +1560,14 @@ void display_enter(void) {
                /*
                 * If this is a Reply or a ReplyAll, copy the sender's email into the To: field
                 */
-               if ((ReplyMode == eReply) || (ReplyMode == eReplyAll))
-               {
+               if ((ReplyMode == eReply) || (ReplyMode == eReplyAll)) {
                        StrBuf *to_rcpt;
+
                        if ((StrLength(replyto) > 0) && (ReplyMode == eReplyAll)) {
                                to_rcpt = NewStrBuf();
                                StrBufAppendBuf(to_rcpt, replyto, 0);
                        }
+
                        else if (StrLength(rfca) > 0) {
                                to_rcpt = NewStrBuf();
                                StrBufAppendBuf(to_rcpt, from, 0);
@@ -1587,15 +1575,10 @@ void display_enter(void) {
                                StrBufAppendBuf(to_rcpt, rfca, 0);
                                StrBufAppendBufPlain(to_rcpt, HKEY(">"), 0);
                        }
+
                        else {
                                to_rcpt =  from;
                                from = NULL;
-                               if (    (StrLength(node) > 0)
-                                       && (strcasecmp(ChrPtr(node), ChrPtr(WCC->serv_info->serv_nodename)))
-                               ) {
-                                       StrBufAppendBufPlain(to_rcpt, HKEY(" @ "), 0);
-                                       StrBufAppendBuf(to_rcpt, node, 0);
-                               }
                        }
                        PutBstr(HKEY("recp"), to_rcpt);
                }
@@ -1603,37 +1586,48 @@ void display_enter(void) {
                /*
                 * Only if this is a ReplyAll, copy all recipients into the Cc: field
                 */
-               if (ReplyMode == eReplyAll)
-               {
+               if (ReplyMode == eReplyAll) {
                        StrBuf *cc_rcpt = rcpt;
                        rcpt = NULL;
-                       if ((StrLength(cccc) > 0) && (StrLength(replyto) == 0))
-                       {
+                       if ((StrLength(cccc) > 0) && (StrLength(replyto) == 0)) {
                                if (cc_rcpt != NULL)  {
                                        StrBufAppendPrintf(cc_rcpt, ", ");
                                        StrBufAppendBuf(cc_rcpt, cccc, 0);
-                               } else {
+                               }
+                               else {
                                        cc_rcpt = cccc;
                                        cccc = NULL;
                                }
                        }
-                       if (cc_rcpt != NULL)
+                       if (cc_rcpt != NULL) {
                                PutBstr(HKEY("cc"), cc_rcpt);
+                       }
                }
+
+               // FOOFOO
+               syslog(LOG_DEBUG, "wefw = %s", ChrPtr(wefw));
+               syslog(LOG_DEBUG, "msgn = %s", ChrPtr(msgn));
+               syslog(LOG_DEBUG, "from = %s", ChrPtr(from));
+               syslog(LOG_DEBUG, "rfca = %s", ChrPtr(rfca));
+               syslog(LOG_DEBUG, "rcpt = %s", ChrPtr(rcpt));
+               syslog(LOG_DEBUG, "cccc = %s", ChrPtr(cccc));
+               syslog(LOG_DEBUG, "replyto = %s", ChrPtr(replyto));
+               syslog(LOG_DEBUG, "nvto = %s", ChrPtr(nvto));
+               syslog(LOG_DEBUG, "local = %d" , message_originated_locally);
+
                FreeStrBuf(&wefw);
                FreeStrBuf(&msgn);
                FreeStrBuf(&from);
-               FreeStrBuf(&node);
                FreeStrBuf(&rfca);
                FreeStrBuf(&rcpt);
                FreeStrBuf(&cccc);
        }
        FreeStrBuf(&Line);
+
        /*
         * Otherwise proceed normally.
         * Do a custom room banner with no navbar...
         */
-
        if (recipient_required) {
                const StrBuf *Recp = NULL; 
                const StrBuf *Cc = NULL;