Move over deprecated function, adopt to new handler structures
authorWilfried Goesgens <dothebart@citadel.org>
Sat, 3 Jan 2015 21:12:43 +0000 (22:12 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Sat, 3 Jan 2015 21:12:43 +0000 (22:12 +0100)
webcit/messages.c
webcit/msg_renderers.c

index 16293a64ca68956c5561e1e9e96c99c00a69ec05..020e81665ca46a1e60d666d723d10da052ab7dfe 100644 (file)
@@ -18,7 +18,6 @@
 #include "calendar.h"
 
 HashList *MsgHeaderHandler = NULL;
 #include "calendar.h"
 
 HashList *MsgHeaderHandler = NULL;
-HashList *MsgEvaluators = NULL;
 HashList *MimeRenderHandler = NULL;
 HashList *ReadLoopHandler = NULL;
 int dbg_analyze_msg = 0;
 HashList *MimeRenderHandler = NULL;
 HashList *ReadLoopHandler = NULL;
 int dbg_analyze_msg = 0;
@@ -31,12 +30,6 @@ void jsonMessageListHdr(void);
 
 void display_enter(void);
 
 
 void display_enter(void);
 
-typedef void (*MsgPartEvaluatorFunc)(message_summary *Sum, StrBuf *Buf);
-
-typedef struct _MsgPartEvaluatorStruct {
-       MsgPartEvaluatorFunc f;
-} MsgPartEvaluatorStruct;
-
 void fixview()
 {
        /* workaround for json listview; its not useable directly */
 void fixview()
 {
        /* workaround for json listview; its not useable directly */
@@ -495,50 +488,6 @@ void display_headers(void) {
 }
 
 
 }
 
 
-message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSubject, long MsgNum) 
-{
-       void                 *vEval;
-       MsgPartEvaluatorStruct  *Eval;
-       message_summary      *Msg;
-       StrBuf *Buf;
-       const char *buf;
-       const char *ebuf;
-       int nBuf;
-       long len;
-       
-       Buf = NewStrBuf();
-
-       serv_printf("MSG0 %ld|1", MsgNum);      /* ask for headers only */
-       
-       StrBuf_ServGetln(Buf);
-       if (GetServerStatus(Buf, NULL) == 1) {
-               FreeStrBuf(&Buf);
-               return NULL;
-       }
-
-       Msg = (message_summary*)malloc(sizeof(message_summary));
-       memset(Msg, 0, sizeof(message_summary));
-       while (len = StrBuf_ServGetln(Buf),
-              (len >= 0) && 
-              ((len != 3)  ||
-               strcmp(ChrPtr(Buf), "000")))
-       {
-               buf = ChrPtr(Buf);
-               ebuf = strchr(ChrPtr(Buf), '=');
-               nBuf = ebuf - buf;
-               if (GetHash(MsgEvaluators, buf, nBuf, &vEval) && vEval != NULL) {
-                       Eval = (MsgPartEvaluatorStruct*) vEval;
-                       StrBufCutLeft(Buf, nBuf + 1);
-                       Eval->f(Msg, Buf);
-               }
-               else syslog(LOG_INFO, "Don't know how to handle Message Headerline [%s]", ChrPtr(Buf));
-       }
-       return Msg;
-}
-
-
-
-
 
 /*
  * load message pointers from the server for a "read messages" operation
 
 /*
  * load message pointers from the server for a "read messages" operation
@@ -740,7 +689,7 @@ void readloop(long oper, eCustomRoomRenderer ForceRenderer)
        long HKLen;
        WCTemplputParams SubTP;
        SharedMessageStatus Stat;
        long HKLen;
        WCTemplputParams SubTP;
        SharedMessageStatus Stat;
-       void *ViewSpecific;
+       void *ViewSpecific = NULL;
 
        if (havebstr("is_summary") && (1 == (ibstr("is_summary")))) {
                WCC->CurRoom.view = VIEW_MAILBOX;
 
        if (havebstr("is_summary") && (1 == (ibstr("is_summary")))) {
                WCC->CurRoom.view = VIEW_MAILBOX;
index 9fd7285dc9fe0f8b4dd4eadc0fb255b2c30e184c..9c63236903813da9046d502827dc2c5930e4a8a4 100644 (file)
@@ -877,6 +877,50 @@ void examine_content_type(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCh
        }
 }
 
        }
 }
 
+
+message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSubject, StrBuf *FoundCharset, long MsgNum) 
+{
+       void *vHdr;
+       headereval *Hdr;
+       message_summary      *Msg;
+       StrBuf *Buf;
+       const char *buf;
+       const char *ebuf;
+       int nBuf;
+       long len;
+       
+       Buf = NewStrBuf();
+
+       serv_printf("MSG0 %ld|1", MsgNum);      /* ask for headers only */
+       
+       StrBuf_ServGetln(Buf);
+       if (GetServerStatus(Buf, NULL) == 1) {
+               FreeStrBuf(&Buf);
+               return NULL;
+       }
+
+       Msg = (message_summary*)malloc(sizeof(message_summary));
+       memset(Msg, 0, sizeof(message_summary));
+       while (len = StrBuf_ServGetln(Buf),
+              (len >= 0) && 
+              ((len != 3)  ||
+               strcmp(ChrPtr(Buf), "000")))
+       {
+               buf = ChrPtr(Buf);
+               ebuf = strchr(ChrPtr(Buf), '=');
+               nBuf = ebuf - buf;
+               
+               if (GetHash(MsgHeaderHandler, buf, nBuf, &vHdr) &&
+                   (vHdr != NULL)) {
+                       Hdr = (headereval*)vHdr;
+                       StrBufCutLeft(Buf, nBuf + 1);
+                       Hdr->evaluator(Msg, Buf, FoundCharset);
+               }
+               else syslog(LOG_INFO, "Don't know how to handle Message Headerline [%s]", ChrPtr(Buf));
+       }
+       return Msg;
+}
+
 void tmplput_MAIL_SUMM_N(StrBuf *Target, WCTemplputParams *TP)
 {
        message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);
 void tmplput_MAIL_SUMM_N(StrBuf *Target, WCTemplputParams *TP)
 {
        message_summary *Msg = (message_summary*) CTX(CTX_MAILSUM);