Back to index

webcit  8.12-dfsg
Classes | Defines | Typedefs | Enumerations | Functions | Variables
messages.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _RenderMimeFuncStruct
struct  wc_mime_attachment
struct  _message_summary
struct  _readloopstruct
struct  _SharedMessageStatus

Defines

#define MSGFLAG_READ   (1<<0)

Typedefs

typedef struct wc_mime_attachment
typedef void(* RenderMimeFunc )(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
typedef struct
_RenderMimeFuncStruct 
RenderMimeFuncStruct
typedef struct _message_summary message_summary
typedef void(* ExamineMsgHeaderFunc )(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
typedef enum _eCustomRoomRenderer eCustomRoomRenderer
typedef int(* load_msg_ptrs_detailheaders )(StrBuf *Line, const char **pos, message_summary *Msg, StrBuf *ConversionBuffer)
 function to parse the | separated message headers list
typedef void(* readloop_servcmd )(char *buf, long bufsize)
typedef struct _readloopstruct readloop_struct
typedef struct _SharedMessageStatus SharedMessageStatus
typedef int(* GetParamsGetServerCall_func )(SharedMessageStatus *Stat, void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen)
typedef int(* PrintViewHeader_func )(SharedMessageStatus *Stat, void **ViewSpecific)
typedef int(* LoadMsgFromServer_func )(SharedMessageStatus *Stat, void **ViewSpecific, message_summary *Msg, int is_new, int i)
typedef int(* RenderView_or_Tail_func )(SharedMessageStatus *Stat, void **ViewSpecific, long oper)
typedef int(* View_Cleanup_func )(void **ViewSpecific)

Enumerations

enum  _eCustomRoomRenderer { eUseDefault = VIEW_JOURNAL + 100, eReadEUIDS }
enum  {
  do_search, headers, readfwd, readnew,
  readold, readgt, readlt
}

Functions

void DestroyMime (void *vMime)
void DestroyMessageSummary (void *vMsg)
static message_summaryGetMessagePtrAt (int n, HashList *Summ)
void evaluate_mime_part (message_summary *Msg, wc_mime_attachment *Mime)
void readloop (long oper, eCustomRoomRenderer ForceRenderer)
int read_message (StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, const StrBuf *section, const StrBuf **OutMime)
int load_message (message_summary *Msg, StrBuf *FoundCharset, StrBuf **Error)
int load_msg_ptrs (const char *servcmd, const char *filter, SharedMessageStatus *Stat, load_msg_ptrs_detailheaders LH)
void RegisterReadLoopHandlerset (int RoomType, GetParamsGetServerCall_func GetParamsGetServerCall, PrintViewHeader_func PrintPageHeader, PrintViewHeader_func PrintViewHeader, load_msg_ptrs_detailheaders LH, LoadMsgFromServer_func LoadMsgFromServer, RenderView_or_Tail_func RenderView_or_Tail, View_Cleanup_func ViewCleanup)
int ParseMessageListHeaders_Detail (StrBuf *Line, const char **pos, message_summary *Msg, StrBuf *ConversionBuffer)
void RegisterMimeRenderer (const char *HeaderName, long HdrNLen, RenderMimeFunc MimeRenderer, int InlineRenderable, int Priority)
 function to register the availability to render a specific message

Variables

HashList * MsgHeaderHandler
HashList * MimeRenderHandler
HashList * ReadLoopHandler
readloop_struct rlid []

Class Documentation

struct _RenderMimeFuncStruct

Definition at line 7 of file messages.h.

Collaboration diagram for _RenderMimeFuncStruct:
Class Members
RenderMimeFunc f
struct wc_mime_attachment

Definition at line 11 of file messages.h.

Collaboration diagram for wc_mime_attachment:
Class Members
StrBuf * Charset
StrBuf * ContentType
StrBuf * Data
StrBuf * Disposition
StrBuf * FileName
size_t length
int level
long lvalue
long msgnum
StrBuf * Name
StrBuf * PartNum
const RenderMimeFuncStruct * Renderer
long size_known
struct _message_summary

Definition at line 30 of file messages.h.

Collaboration diagram for _message_summary:
Class Members
HashList * AllAttach
StrBuf * AllRcpt
HashList * AttachLinks
HashList * Attachments
StrBuf * cccc
time_t date
StrBuf * euid
int Flags
int format_type
StrBuf * from
int hasattachments
StrBuf * hnod
wc_mime_attachment * MsgBody
long msgnum
int nhdr
StrBuf * OtherNode
const StrBuf * PartNum
StrBuf * reply_inreplyto
StrBuf * reply_references
StrBuf * Rfca
StrBuf * Room
StrBuf * subj
HashList * Submessages
StrBuf * to
struct _readloopstruct

Definition at line 113 of file messages.h.

Class Members
readloop_servcmd cmd
ConstStr name
struct _SharedMessageStatus

Definition at line 133 of file messages.h.

Class Members
long defaultsortorder
long highest_found
long load_seen
long lowest_found
long maxload
long maxmsgs
long num_displayed
long nummsgs
long sortit
long startmsg

Define Documentation

#define MSGFLAG_READ   (1<<0)

Definition at line 28 of file messages.h.


Typedef Documentation

typedef void(* ExamineMsgHeaderFunc)(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)

Definition at line 79 of file messages.h.

typedef int(* GetParamsGetServerCall_func)(SharedMessageStatus *Stat, void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen)

Definition at line 155 of file messages.h.

typedef int(* load_msg_ptrs_detailheaders)(StrBuf *Line, const char **pos, message_summary *Msg, StrBuf *ConversionBuffer)

function to parse the | separated message headers list

Parameters:
Linethe raw line with your message data
Msgput your parser results here...
ConversionBufferif you need some workbuffer, don't free me!
Returns:
0: failure, trash this message. 1: all right, store it

Definition at line 106 of file messages.h.

typedef int(* LoadMsgFromServer_func)(SharedMessageStatus *Stat, void **ViewSpecific, message_summary *Msg, int is_new, int i)

Definition at line 165 of file messages.h.

typedef int(* PrintViewHeader_func)(SharedMessageStatus *Stat, void **ViewSpecific)

Definition at line 163 of file messages.h.

typedef void(* readloop_servcmd)(char *buf, long bufsize)

Definition at line 111 of file messages.h.

typedef void(* RenderMimeFunc)(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)

Definition at line 6 of file messages.h.

typedef int(* RenderView_or_Tail_func)(SharedMessageStatus *Stat, void **ViewSpecific, long oper)

Definition at line 171 of file messages.h.

typedef int(* View_Cleanup_func)(void **ViewSpecific)

Definition at line 174 of file messages.h.

typedef struct wc_mime_attachment

Definition at line 5 of file messages.h.


Enumeration Type Documentation

anonymous enum
Enumerator:
do_search 
headers 
readfwd 
readnew 
readold 
readgt 
readlt 

Definition at line 89 of file messages.h.

Enumerator:
eUseDefault 
eReadEUIDS 

Definition at line 84 of file messages.h.

                                  {
       eUseDefault = VIEW_JOURNAL + 100, 
       eReadEUIDS
}eCustomRoomRenderer;

Function Documentation

void DestroyMessageSummary ( void *  vMsg)

Definition at line 38 of file msg_renderers.c.

{
       message_summary *Msg = (message_summary*) vMsg;

       FreeStrBuf(&Msg->from);
       FreeStrBuf(&Msg->to);
       FreeStrBuf(&Msg->subj);
       FreeStrBuf(&Msg->reply_inreplyto);
       FreeStrBuf(&Msg->reply_references);
       FreeStrBuf(&Msg->cccc);
       FreeStrBuf(&Msg->hnod);
       FreeStrBuf(&Msg->AllRcpt);
       FreeStrBuf(&Msg->Room);
       FreeStrBuf(&Msg->Rfca);
       FreeStrBuf(&Msg->OtherNode);

       DeleteHash(&Msg->Attachments);     /* list of Attachments */
       DeleteHash(&Msg->Submessages);
       DeleteHash(&Msg->AttachLinks);
       DeleteHash(&Msg->AllAttach);
       free(Msg);
}

Here is the caller graph for this function:

void DestroyMime ( void *  vMime)

Definition at line 31 of file msg_renderers.c.

{
       wc_mime_attachment *Mime = (wc_mime_attachment*)vMime;
       DestroyMimeParts(Mime);
       free(Mime);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 716 of file msg_renderers.c.

{
       void *vMimeRenderer;

       /* just print the root-node */
       if ((Mime->level >= 1) &&
           GetHash(MimeRenderHandler, SKEY(Mime->ContentType), &vMimeRenderer) &&
           vMimeRenderer != NULL)
       {
              Mime->Renderer = (RenderMimeFuncStruct*) vMimeRenderer;
              if (Msg->Submessages == NULL)
                     Msg->Submessages = NewHash(1,NULL);
              Put(Msg->Submessages, SKEY(Mime->PartNum), Mime, reference_free_handler);
       }
       else if ((Mime->level >= 1) &&
               (!strcasecmp(ChrPtr(Mime->Disposition), "inline"))
               && (!strncasecmp(ChrPtr(Mime->ContentType), "image/", 6)) ){
              if (Msg->AttachLinks == NULL)
                     Msg->AttachLinks = NewHash(1,NULL);
              Put(Msg->AttachLinks, SKEY(Mime->PartNum), Mime, reference_free_handler);
       }
       else if ((Mime->level >= 1) &&
               (StrLength(Mime->ContentType) > 0) &&
                ( (!strcasecmp(ChrPtr(Mime->Disposition), "attachment")) 
                  || (!strcasecmp(ChrPtr(Mime->Disposition), "inline"))
                  || (!strcasecmp(ChrPtr(Mime->Disposition), ""))))
       {             
              if (Msg->AttachLinks == NULL)
                     Msg->AttachLinks = NewHash(1,NULL);
              Put(Msg->AttachLinks, SKEY(Mime->PartNum), Mime, reference_free_handler);
              if ((strcasecmp(ChrPtr(Mime->ContentType), "application/octet-stream") == 0) && 
                  (StrLength(Mime->FileName) > 0)) {
                     FlushStrBuf(Mime->ContentType);
                     StrBufAppendBufPlain(Mime->ContentType,
                                        GuessMimeByFilename(SKEY(Mime->FileName)),
                                        -1, 0);
              }
       }
}

Here is the caller graph for this function:

static message_summary* GetMessagePtrAt ( int  n,
HashList *  Summ 
) [inline, static]

Definition at line 67 of file messages.h.

{
       const char *Key;
       long HKLen;
       void *vMsg;

       if (Summ == NULL)
              return NULL;
       GetHashAt(Summ, n, &HKLen, &Key, &vMsg);
       return (message_summary*) vMsg;
}

Here is the caller graph for this function:

int load_message ( message_summary Msg,
StrBuf *  FoundCharset,
StrBuf **  Error 
)

Definition at line 49 of file messages.c.

{
       StrBuf *Buf;
       StrBuf *HdrToken;
       headereval *Hdr;
       void *vHdr;
       char buf[SIZ];
       int Done = 0;
       int state=0;
       
       Buf = NewStrBuf();
       if (Msg->PartNum != NULL) {
              serv_printf("MSG4 %ld|%s", Msg->msgnum, ChrPtr(Msg->PartNum));
       }
       else {
              serv_printf("MSG4 %ld", Msg->msgnum);
       }

       StrBuf_ServGetln(Buf);
       if (GetServerStatus(Buf, NULL) != 1) {
              *Error = NewStrBuf();
              StrBufAppendPrintf(*Error, "<strong>");
              StrBufAppendPrintf(*Error, _("ERROR:"));
              StrBufAppendPrintf(*Error, "</strong> %s<br>\n", &buf[4]);
              FreeStrBuf(&Buf);
              return 0;
       }

       /* begin everythingamundo table */
       HdrToken = NewStrBuf();
       while (!Done && StrBuf_ServGetln(Buf)>=0) {
              if ( (StrLength(Buf)==3) && 
                  !strcmp(ChrPtr(Buf), "000")) 
              {
                     Done = 1;
                     if (state < 2) {
                            if (Msg->MsgBody->Data == NULL)
                                   Msg->MsgBody->Data = NewStrBuf();
                            Msg->MsgBody->ContentType = NewStrBufPlain(HKEY("text/html"));
                            StrBufAppendPrintf(Msg->MsgBody->Data, "<div><i>");
                            StrBufAppendPrintf(Msg->MsgBody->Data, _("Empty message"));
                            StrBufAppendPrintf(Msg->MsgBody->Data, "</i><br><br>\n");
                            StrBufAppendPrintf(Msg->MsgBody->Data, "</div>\n");
                     }
                     break;
              }
              switch (state) {
              case 0:/* Citadel Message Headers */
                     if (StrLength(Buf) == 0) {
                            state ++;
                            break;
                     }
                     StrBufExtract_token(HdrToken, Buf, 0, '=');
                     StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
                     
                     /* look up one of the examine_* functions to parse the content */
                     if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) &&
                         (vHdr != NULL)) {
                            Hdr = (headereval*)vHdr;
                            Hdr->evaluator(Msg, Buf, FoundCharset);
                            if (Hdr->Type == 1) {
                                   state++;
                            }
                     }/* TODO: 
                     else LogError(Target, 
                                  __FUNCTION__,  
                                  "don't know how to handle message header[%s]\n", 
                                  ChrPtr(HdrToken));
                      */
                     break;
              case 1:/* Message Mime Header */
                     if (StrLength(Buf) == 0) {
                            state++;
                            if (Msg->MsgBody->ContentType == NULL)
                                   /* end of header or no header? */
                                   Msg->MsgBody->ContentType = NewStrBufPlain(HKEY("text/plain"));
                             /* usual end of mime header */
                     }
                     else
                     {
                            StrBufExtract_token(HdrToken, Buf, 0, ':');
                            if (StrLength(HdrToken) > 0) {
                                   StrBufCutLeft(Buf, StrLength(HdrToken) + 1);
                                   /* the examine*'s know how to do with mime headers too... */
                                   if (GetHash(MsgHeaderHandler, SKEY(HdrToken), &vHdr) &&
                                       (vHdr != NULL)) {
                                          Hdr = (headereval*)vHdr;
                                          Hdr->evaluator(Msg, Buf, FoundCharset);
                                   }
                                   break;
                            }
                     }
              case 2: /* Message Body */
                     
                     if (Msg->MsgBody->size_known > 0) {
                            StrBuf_ServGetBLOBBuffered(Msg->MsgBody->Data, Msg->MsgBody->length);
                            state ++;
                            /*/ todo: check next line, if not 000, append following lines */
                     }
                     else if (1){
                            if (StrLength(Msg->MsgBody->Data) > 0)
                                   StrBufAppendBufPlain(Msg->MsgBody->Data, "\n", 1, 0);
                            StrBufAppendBuf(Msg->MsgBody->Data, Buf, 0);
                     }
                     break;
              case 3:
                     StrBufAppendBuf(Msg->MsgBody->Data, Buf, 0);
                     break;
              }
       }

       if (Msg->AllAttach == NULL)
              Msg->AllAttach = NewHash(1,NULL);
       /* now we put the body mimepart we read above into the mimelist */
       Put(Msg->AllAttach, SKEY(Msg->MsgBody->PartNum), Msg->MsgBody, DestroyMime);
       
       FreeStrBuf(&Buf);
       FreeStrBuf(&HdrToken);
       return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int load_msg_ptrs ( const char *  servcmd,
const char *  filter,
SharedMessageStatus Stat,
load_msg_ptrs_detailheaders  LH 
)

Definition at line 535 of file messages.c.

{
        wcsession *WCC = WC;
       message_summary *Msg;
       StrBuf *Buf, *Buf2;
       long len;
       int n;
       int skipit;
       const char *Ptr = NULL;
       int StatMajor;

       Stat->lowest_found = LONG_MAX;
       Stat->highest_found = LONG_MIN;

       if (WCC->summ != NULL) {
              DeleteHash(&WCC->summ);
       }
       WCC->summ = NewHash(1, Flathash);
       
       Buf = NewStrBuf();
       serv_puts(servcmd);
       StrBuf_ServGetln(Buf);
       StatMajor = GetServerStatus(Buf, NULL);
       switch (StatMajor) {
       case 1:
              break;
       case 8:
              if (filter != NULL) {
                     serv_puts(filter);
                        serv_puts("000");
                     break;
              }
              /* fall back to empty filter in case of we were fooled... */
              serv_puts("");
              serv_puts("000");
              break;
       default:
              FreeStrBuf(&Buf);
              return (Stat->nummsgs);
       }
       Buf2 = NewStrBuf();
       while (len = StrBuf_ServGetln(Buf), 
              ((len >= 0) &&
              ((len != 3) || 
               strcmp(ChrPtr(Buf), "000")!= 0)))
       {
              if (Stat->nummsgs < Stat->maxload) {
                     skipit = 0;
                     Ptr = NULL;
                     Msg = (message_summary*)malloc(sizeof(message_summary));
                     memset(Msg, 0, sizeof(message_summary));

                     Msg->msgnum = StrBufExtractNext_long(Buf, &Ptr, '|');
                     Msg->date = StrBufExtractNext_long(Buf, &Ptr, '|');

                     if (Stat->nummsgs == 0) {
                            if (Msg->msgnum < Stat->lowest_found) {
                                   Stat->lowest_found = Msg->msgnum;
                            }
                            if (Msg->msgnum > Stat->highest_found) {
                                   Stat->highest_found = Msg->msgnum;
                            }
                     }

                     if ((Msg->msgnum == 0) && (StrLength(Buf) < 32)) {
                            free(Msg);
                            continue;
                     }

                     /* 
                      * as citserver probably gives us messages in forward date sorting
                      * nummsgs should be the same order as the message date.
                      */
                     if (Msg->date == 0) {
                            Msg->date = Stat->nummsgs;
                            if (StrLength(Buf) < 32) 
                                   skipit = 1;
                     }
                     if ((!skipit) && (LH != NULL)) {
                            if (!LH(Buf, &Ptr, Msg, Buf2)){
                                   free(Msg);
                                   continue;
                            }                                  
                     }
                     n = Msg->msgnum;
                     Put(WCC->summ, (const char *)&n, sizeof(n), Msg, DestroyMessageSummary);
              }
              Stat->nummsgs++;
       }
       FreeStrBuf(&Buf2);
       FreeStrBuf(&Buf);
       return (Stat->nummsgs);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int ParseMessageListHeaders_Detail ( StrBuf *  Line,
const char **  pos,
message_summary Msg,
StrBuf *  ConversionBuffer 
)

Definition at line 1298 of file msg_renderers.c.

{
       wcsession *WCC = WC;
       long len;
       long totallen;

       CheckConvertBufs(WCC);

       totallen = StrLength(Line);
       Msg->from = NewStrBufPlain(NULL, totallen);
       len = StrBufExtract_NextToken(ConversionBuffer, Line, pos, '|');
       if (len > 0) {
              /* Handle senders with RFC2047 encoding */
              StrBuf_RFC822_2_Utf8(Msg->from, 
                                 ConversionBuffer, 
                                 WCC->DefaultCharset, 
                                 NULL, 
                                 WCC->ConvertBuf1,
                                 WCC->ConvertBuf2);
       }
                     
       /* node name */
       len = StrBufExtract_NextToken(ConversionBuffer, Line, pos, '|');
       if ((len > 0 ) &&
           ( ((WCC->CurRoom.QRFlags & QR_NETWORK)
              || ((strcasecmp(ChrPtr(ConversionBuffer), ChrPtr(WCC->serv_info->serv_nodename))
                  && (strcasecmp(ChrPtr(ConversionBuffer), ChrPtr(WCC->serv_info->serv_fqdn))))))))
       {
              StrBufAppendBufPlain(Msg->from, HKEY(" @ "), 0);
              StrBufAppendBuf(Msg->from, ConversionBuffer, 0);
       }

       /* Internet address (not used)
        *     StrBufExtract_token(Msg->inetaddr, Line, 4, '|');
        */
       StrBufSkip_NTokenS(Line, pos, '|', 1);
       Msg->subj = NewStrBufPlain(NULL, totallen);

       FlushStrBuf(ConversionBuffer);
       /* we assume the subject is the last parameter inside of the list; 
        * thus we don't use the tokenizer to fetch it, since it will hick up 
        * on tokenizer chars inside of the subjects
       StrBufExtract_NextToken(ConversionBuffer,  Line, pos, '|');
       */
       len = 0;
       if (*pos != StrBufNOTNULL) {
              len = totallen - (*pos - ChrPtr(Line));
              StrBufPlain(ConversionBuffer, *pos, len);
              *pos = StrBufNOTNULL;
              if ((len > 0) &&
                  (*(ChrPtr(ConversionBuffer) + len - 1) == '|'))
                     StrBufCutRight(ConversionBuffer, 1);
       }

       if (len == 0)
              StrBufAppendBufPlain(Msg->subj, _("(no subject)"), -1,0);
       else {
              StrBuf_RFC822_2_Utf8(Msg->subj, 
                                 ConversionBuffer, 
                                 WCC->DefaultCharset, 
                                 NULL,
                                 WCC->ConvertBuf1,
                                 WCC->ConvertBuf2);
       }

       return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int read_message ( StrBuf *  Target,
const char *  tmpl,
long  tmpllen,
long  msgnum,
const StrBuf *  section,
const StrBuf **  OutMime 
)

Definition at line 181 of file messages.c.

{
       StrBuf *Buf;
       StrBuf *FoundCharset;
       HashPos  *it;
       void *vMime;
       message_summary *Msg = NULL;
       void *vHdr;
       long len;
       const char *Key;
       WCTemplputParams SubTP;
       StrBuf *Error = NULL;

       Buf = NewStrBuf();
       FoundCharset = NewStrBuf();
       Msg = (message_summary *)malloc(sizeof(message_summary));
       memset(Msg, 0, sizeof(message_summary));
       Msg->msgnum = msgnum;
       Msg->PartNum = PartNum;
       Msg->MsgBody =  (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
       memset(Msg->MsgBody, 0, sizeof(wc_mime_attachment));
       Msg->MsgBody->msgnum = msgnum;

       if (!load_message(Msg, FoundCharset, &Error)) {
              StrBufAppendBuf(Target, Error, 0);
              FreeStrBuf(&Error);
       }

       /* Extract just the content-type (omit attributes such as "charset") */
       StrBufExtract_token(Buf, Msg->MsgBody->ContentType, 0, ';');
       StrBufTrim(Buf);
       StrBufLowerCase(Buf);

       /* Locate a renderer capable of converting this MIME part into HTML */
       if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) &&
           (vHdr != NULL)) {
              RenderMimeFuncStruct *Render;
              Render = (RenderMimeFuncStruct*)vHdr;
              Render->f(Msg->MsgBody, NULL, FoundCharset);
       }

       if (StrLength(Msg->reply_references)> 0) {
              /* Trim down excessively long lists of thread references.  We eliminate the
               * second one in the list so that the thread root remains intact.
               */
              int rrtok = num_tokens(ChrPtr(Msg->reply_references), '|');
              int rrlen = StrLength(Msg->reply_references);
              if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) {
                     StrBufRemove_token(Msg->reply_references, 1, '|');
              }
       }

       /* now check if we need to translate some mimeparts, and remove the duplicate */
       it = GetNewHashPos(Msg->AllAttach, 0);
       while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) && 
              (vMime != NULL)) {
              wc_mime_attachment *Mime = (wc_mime_attachment*) vMime;
              evaluate_mime_part(Msg, Mime);
       }
       DeleteHashPos(&it);
       memset(&SubTP, 0, sizeof(WCTemplputParams));
       SubTP.Filter.ContextType = CTX_MAILSUM;
       SubTP.Context = Msg;
       *OutMime = DoTemplate(tmpl, tmpllen, Target, &SubTP);

       DestroyMessageSummary(Msg);
       FreeStrBuf(&FoundCharset);
       FreeStrBuf(&Buf);
       return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void readloop ( long  oper,
eCustomRoomRenderer  ForceRenderer 
)

Definition at line 709 of file messages.c.

{
       RoomRenderer *ViewMsg;
       void *vViewMsg;
       void *vMsg;
       message_summary *Msg;
       char cmd[256] = "";
       char filter[256] = "";
       int i, r;
       wcsession *WCC = WC;
       HashPos *at;
       const char *HashKey;
       long HKLen;
       WCTemplputParams SubTP;
       SharedMessageStatus Stat;
       void *ViewSpecific;

       if (havebstr("is_summary") && (1 == (ibstr("is_summary")))) {
              WCC->CurRoom.view = VIEW_MAILBOX;
       }

       if (havebstr("view")) {
              WCC->CurRoom.view = ibstr("view");
       }

       memset(&Stat, 0, sizeof(SharedMessageStatus));
       Stat.maxload = 10000;
       Stat.lowest_found = (-1);
       Stat.highest_found = (-1);
       if (ForceRenderer == eUseDefault)
              GetHash(ReadLoopHandler, IKEY(WCC->CurRoom.view), &vViewMsg);
       else 
              GetHash(ReadLoopHandler, IKEY(ForceRenderer), &vViewMsg);
       if (vViewMsg == NULL) {
              WCC->CurRoom.view = VIEW_BBS;
              GetHash(ReadLoopHandler, IKEY(WCC->CurRoom.view), &vViewMsg);
       }
       if (vViewMsg == NULL) {
              return;                     /* TODO: print message */
       }

       ViewMsg = (RoomRenderer*) vViewMsg;
       if (ViewMsg->PrintPageHeader == NULL)
              output_headers(1, 1, 1, 0, 0, 0);
       else 
              ViewMsg->PrintPageHeader(&Stat, ViewSpecific);

       if (ViewMsg->GetParamsGetServerCall != NULL) {
              r = ViewMsg->GetParamsGetServerCall(
                     &Stat,
                     &ViewSpecific,
                     oper,
                     cmd, sizeof(cmd),
                     filter, sizeof(filter)
              );
       } else {
              r = 0;
       }

       switch(r)
       {
       case 400:
       case 404:

              return;
       case 300: /* the callback hook should do the work for us here, since he knows what to do. */
              return;
       case 200:
       default:
              break;
       }
       if (!IsEmptyStr(cmd)) {
              const char *p = NULL;
              if (!IsEmptyStr(filter))
                     p = filter;
              Stat.nummsgs = load_msg_ptrs(cmd, p, &Stat, ViewMsg->LHParse);
       }

       if (Stat.sortit) {
              CompareFunc SortIt;
              memset(&SubTP, 0, sizeof(WCTemplputParams));
              SubTP.Filter.ContextType = CTX_MAILSUM;
              SubTP.Context = NULL;
              SortIt =  RetrieveSort(&SubTP, NULL, 0,
                                   HKEY("date"), Stat.defaultsortorder);
              if (SortIt != NULL)
                     SortByPayload(WCC->summ, SortIt);
       }
       if (Stat.startmsg < 0) {
              Stat.startmsg =  0;
       }

       if (Stat.load_seen) load_seen_flags();
       
        /*
        * Print any inforation above the message list...
        */
       if (ViewMsg->PrintViewHeader != NULL)
              ViewMsg->PrintViewHeader(&Stat, &ViewSpecific);

       WCC->startmsg =  Stat.startmsg;
       WCC->maxmsgs = Stat.maxmsgs;
       WCC->num_displayed = 0;

       /* Put some helpful data in vars for mailsummary_json */
       {
              StrBuf *Foo;
              
              Foo = NewStrBuf ();
              StrBufPrintf(Foo, "%ld", Stat.nummsgs);
              PutBstr(HKEY("__READLOOP:TOTALMSGS"), NewStrBufDup(Foo));
              StrBufPrintf(Foo, "%ld", Stat.startmsg);
              PutBstr(HKEY("__READLOOP:STARTMSG"), Foo);
       }

       /*
        * iterate over each message. if we need to load an attachment, do it here. 
        */

       if ((ViewMsg->LoadMsgFromServer != NULL) && 
           (!IsEmptyStr(cmd)))
       {
              at = GetNewHashPos(WCC->summ, 0);
              Stat.num_displayed = i = 0;
              while (       GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
                     Msg = (message_summary*) vMsg;            
                     if ((Msg->msgnum >= Stat.startmsg) && (Stat.num_displayed <= Stat.maxmsgs)) {
                            ViewMsg->LoadMsgFromServer(&Stat, 
                                                    &ViewSpecific, 
                                                    Msg, 
                                                    (Msg->Flags & MSGFLAG_READ) != 0, 
                                                    i);
                     } 
                     i++;
              }
              DeleteHashPos(&at);
       }

       /*
        * Done iterating the message list. now tasks we want to do after.
        */
       if (ViewMsg->RenderView_or_Tail != NULL)
              ViewMsg->RenderView_or_Tail(&Stat, &ViewSpecific, oper);

       if (ViewMsg->ViewCleanup != NULL)
              ViewMsg->ViewCleanup(&ViewSpecific);

       WCC->startmsg = 0;
       WCC->maxmsgs = 0;
       if (WCC->summ != NULL) {
              DeleteHash(&WCC->summ);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void RegisterMimeRenderer ( const char *  HeaderName,
long  HdrNLen,
RenderMimeFunc  MimeRenderer,
int  InlineRenderable,
int  Priority 
)

function to register the availability to render a specific message

Parameters:
HeaderNameMimetype we know howto display
HdrNLenlength...
InlineRenderableShould we announce to citserver that we want to receive these mimeparts immediately?
Priorityif multipart/alternative; which mimepart/Renderer should be prefered? (only applies if InlineRenderable)

Definition at line 72 of file msg_renderers.c.

{
       RenderMimeFuncStruct *f;

       f = (RenderMimeFuncStruct*) malloc(sizeof(RenderMimeFuncStruct));
       f->f = MimeRenderer;
       Put(MimeRenderHandler, HeaderName, HdrNLen, f, NULL);
       if (InlineRenderable)
              RegisterEmbeddableMimeType(HeaderName, HdrNLen, 10000 - Priority);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void RegisterReadLoopHandlerset ( int  RoomType,
GetParamsGetServerCall_func  GetParamsGetServerCall,
PrintViewHeader_func  PrintPageHeader,
PrintViewHeader_func  PrintViewHeader,
load_msg_ptrs_detailheaders  LH,
LoadMsgFromServer_func  LoadMsgFromServer,
RenderView_or_Tail_func  RenderView_or_Tail,
View_Cleanup_func  ViewCleanup 
)
Parameters:
RoomTypeRoomType: which View definition are you going to be called for
GetParamsGetServerCallGetParamsGetServerCall should do the following:
  • allocate your private context structure
  • evaluate your commandline arguments, put results to your private struct.
  • fill cmd with the command to load the message pointer list:
    • might depend on bstr/oper depending on your needs
    • might stay empty if no list should loaded and LoadMsgFromServer is skipped.
  • influence the behaviour by presetting values on SharedMessageStatus
PrintPageHeaderPrintpageHeader prints the surrounding information like iconbar, header etc. by default, output_headers() is called.
PrintViewHeaderPrintViewHeader is here to print informations infront of your messages. The message list is already loaded & sorted (if) so you can evaluate its result on the SharedMessageStatus struct.
LHLH is the function, you specify if you want to load more than just message numbers from the server during the listing fetch operation.
LoadMsgFromServerLoadMsgFromServer is called for every message in the message list:
  • which is
    • after 'startmsg'
    • up to 'maxmsgs' after your 'startmsg'
  • it should load and parse messages from citserer.
  • depending on your needs you might want to print your message here...
  • if cmd was empty, its skipped alltogether.
RenderView_or_TailRenderView_or_Tail is called last;
  • if you used PrintViewHeader to print messages, you might want to print trailing information here
  • if you just pre-loaded your messages, put your render code here.
ViewCleanupViewCleanup should just clear your private data so all your mem can go back to VALgrindHALLA. it also should release the content for delivery via end_burst() or wDumpContent(1);

Definition at line 1939 of file messages.c.

{
       RoomRenderer *Handler;

       Handler = (RoomRenderer*) malloc(sizeof(RoomRenderer));

       Handler->RoomType = RoomType;
       Handler->GetParamsGetServerCall = GetParamsGetServerCall;
       Handler->PrintPageHeader = PrintPageHeader;
       Handler->PrintViewHeader = PrintViewHeader;
       Handler->LoadMsgFromServer = LoadMsgFromServer;
       Handler->RenderView_or_Tail = RenderView_or_Tail;
       Handler->ViewCleanup = ViewCleanup;
       Handler->LHParse = LH;

       Put(ReadLoopHandler, IKEY(RoomType), Handler, NULL);
}

Here is the caller graph for this function:


Variable Documentation

HashList* MimeRenderHandler

Definition at line 22 of file messages.c.

HashList* MsgHeaderHandler

Definition at line 20 of file messages.c.

HashList* ReadLoopHandler

Definition at line 23 of file messages.c.

Definition at line 1287 of file msg_renderers.c.