Back to index

webcit  8.12-dfsg
Classes | Typedefs | Functions | Variables
smtpqueue.c File Reference
#include "webcit.h"

Go to the source code of this file.

Classes

struct  _mailq_entry
struct  queueitem
struct  __QItemHandlerStruct

Typedefs

typedef struct _mailq_entry MailQEntry
typedef struct queueitem OneQueItem
typedef void(* QItemHandler )(OneQueItem *Item, StrBuf *Line, const char **Pos)
typedef struct __QItemHandlerStruct QItemHandlerStruct

Functions

void RegisterQItemHandler (const char *Key, long Len, QItemHandler H)
void FreeMailQEntry (void *qv)
void FreeQueItem (OneQueItem **Item)
void HFreeQueItem (void *Item)
OneQueItemDeserializeQueueItem (StrBuf *RawQItem, long QueMsgID)
void tmplput_MailQID (StrBuf *Target, WCTemplputParams *TP)
void tmplput_MailQPayloadID (StrBuf *Target, WCTemplputParams *TP)
void tmplput_MailQBounceTo (StrBuf *Target, WCTemplputParams *TP)
void tmplput_MailQAttempted (StrBuf *Target, WCTemplputParams *TP)
void tmplput_MailQSubmitted (StrBuf *Target, WCTemplputParams *TP)
void tmplput_MailQEnvelopeFrom (StrBuf *Target, WCTemplputParams *TP)
void tmplput_MailQSourceRoom (StrBuf *Target, WCTemplputParams *TP)
int Conditional_MailQ_HaveSourceRoom (StrBuf *Target, WCTemplputParams *TP)
void tmplput_MailQRetry (StrBuf *Target, WCTemplputParams *TP)
void tmplput_MailQRCPT (StrBuf *Target, WCTemplputParams *TP)
void tmplput_MailQRCPTStatus (StrBuf *Target, WCTemplputParams *TP)
void tmplput_MailQStatusMsg (StrBuf *Target, WCTemplputParams *TP)
HashList * iterate_get_Recipients (StrBuf *Target, WCTemplputParams *TP)
void NewMailQEntry (OneQueItem *Item)
void QItem_Handle_MsgID (OneQueItem *Item, StrBuf *Line, const char **Pos)
void QItem_Handle_EnvelopeFrom (OneQueItem *Item, StrBuf *Line, const char **Pos)
void QItem_Handle_BounceTo (OneQueItem *Item, StrBuf *Line, const char **Pos)
void QItem_Handle_SenderRoom (OneQueItem *Item, StrBuf *Line, const char **Pos)
void QItem_Handle_Recipient (OneQueItem *Item, StrBuf *Line, const char **Pos)
void QItem_Handle_retry (OneQueItem *Item, StrBuf *Line, const char **Pos)
void QItem_Handle_Submitted (OneQueItem *Item, StrBuf *Line, const char **Pos)
void QItem_Handle_Attempted (OneQueItem *Item, StrBuf *Line, const char **Pos)
void render_QUEUE (wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
void ServerShutdownModule_SMTP_QUEUE (void)
void ServerStartModule_SMTP_QUEUE (void)
int qview_PrintPageHeader (SharedMessageStatus *Stat, void **ViewSpecific)
int qview_GetParamsGetServerCall (SharedMessageStatus *Stat, void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen)
int qview_LoadMsgFromServer (SharedMessageStatus *Stat, void **ViewSpecific, message_summary *Msg, int is_new, int i)
int qview_RenderView_or_Tail (SharedMessageStatus *Stat, void **ViewSpecific, long oper)
int qview_Cleanup (void **ViewSpecific)
void InitModule_SMTP_QUEUE (void)

Variables

HashList * QItemHandlers = NULL

Class Documentation

struct _mailq_entry

Definition at line 10 of file smtpqueue.c.

Class Members
int Active
int n
StrBuf * Recipient
int Status 0 = No delivery has yet been attempted 2 = Delivery was successful 3 = Transient error like connection problem. Try next remote if available. 4 = A transient error was experienced ... try again later 5 = Delivery to this address failed permanently. The error message should be placed in the fourth field so that a bounce message may be generated.
StrBuf * StatusMessage
struct queueitem

Definition at line 28 of file smtpqueue.c.

Collaboration diagram for queueitem:
Class Members
long ActiveDeliveries
StrBuf * BounceTo
MailQEntry * Current
StrBuf * EnvelopeFrom
int FailNow
ParsedURL * FallBackHost
HashList * MailQEntries
long MessageID
long QueMsgID
time_t ReattemptWhen
time_t Retry
StrBuf * SenderRoom
long Submitted
ParsedURL * URL
struct __QItemHandlerStruct

Definition at line 52 of file smtpqueue.c.

Collaboration diagram for __QItemHandlerStruct:
Class Members
QItemHandler H

Typedef Documentation

typedef struct _mailq_entry MailQEntry
typedef struct queueitem OneQueItem
typedef void(* QItemHandler)(OneQueItem *Item, StrBuf *Line, const char **Pos)

Definition at line 50 of file smtpqueue.c.


Function Documentation

int Conditional_MailQ_HaveSourceRoom ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 167 of file smtpqueue.c.

{
       OneQueItem *Item = (OneQueItem*) CTX;
       return StrLength(Item->SenderRoom) > 0;
}

Here is the caller graph for this function:

OneQueItem* DeserializeQueueItem ( StrBuf *  RawQItem,
long  QueMsgID 
)

Definition at line 86 of file smtpqueue.c.

{
       OneQueItem *Item;
       const char *pLine = NULL;
       StrBuf *Line;
       StrBuf *Token;
       
       Item = (OneQueItem*)malloc(sizeof(OneQueItem));
       memset(Item, 0, sizeof(OneQueItem));
       Item->Retry = 0;
       Item->MessageID = -1;
       Item->QueMsgID = QueMsgID;

       Token = NewStrBuf();
       Line = NewStrBufPlain(NULL, 128);
       while (pLine != StrBufNOTNULL) {
              const char *pItemPart = NULL;
              void *vHandler;

              StrBufExtract_NextToken(Line, RawQItem, &pLine, '\n');
              if (StrLength(Line) == 0) continue;
              StrBufExtract_NextToken(Token, Line, &pItemPart, '|');
              if (GetHash(QItemHandlers, SKEY(Token), &vHandler))
              {
                     QItemHandlerStruct *HS;
                     HS = (QItemHandlerStruct*) vHandler;
                     HS->H(Item, Line, &pItemPart);
              }
       }
       FreeStrBuf(&Line);
       FreeStrBuf(&Token);
/*
       Put(ActiveQItems,
           LKEY(Item->MessageID),
           Item,
           HFreeQueItem);
*/     

       return Item;
}

Here is the caller graph for this function:

void FreeMailQEntry ( void *  qv)

Definition at line 63 of file smtpqueue.c.

{
       MailQEntry *Q = qv;
       FreeStrBuf(&Q->Recipient);
       FreeStrBuf(&Q->StatusMessage);
       free(Q);
}

Here is the caller graph for this function:

void FreeQueItem ( OneQueItem **  Item)

Definition at line 70 of file smtpqueue.c.

{
       DeleteHash(&(*Item)->MailQEntries);
       FreeStrBuf(&(*Item)->EnvelopeFrom);
       FreeStrBuf(&(*Item)->BounceTo);
       FreeStrBuf(&(*Item)->SenderRoom);
       FreeURL(&(*Item)->URL);
       free(*Item);
       Item = NULL;
}

Here is the caller graph for this function:

void HFreeQueItem ( void *  Item)

Definition at line 80 of file smtpqueue.c.

{
       FreeQueItem((OneQueItem**)&Item);
}

Here is the call graph for this function:

void InitModule_SMTP_QUEUE ( void  )

Definition at line 382 of file smtpqueue.c.

{

       RegisterQItemHandler(HKEY("msgid"),              QItem_Handle_MsgID);
       RegisterQItemHandler(HKEY("envelope_from"),      QItem_Handle_EnvelopeFrom);
       RegisterQItemHandler(HKEY("retry"),              QItem_Handle_retry);
       RegisterQItemHandler(HKEY("attempted"),          QItem_Handle_Attempted);
       RegisterQItemHandler(HKEY("remote"),             QItem_Handle_Recipient);
       RegisterQItemHandler(HKEY("bounceto"),           QItem_Handle_BounceTo);
       RegisterQItemHandler(HKEY("source_room"), QItem_Handle_SenderRoom);
       RegisterQItemHandler(HKEY("submitted"),          QItem_Handle_Submitted);
       RegisterMimeRenderer(HKEY("application/x-citadel-delivery-list"), render_QUEUE, 1, 9000);
       RegisterNamespace("MAILQ:ID", 0, 0, tmplput_MailQID, NULL, CTX_MAILQITEM);
       RegisterNamespace("MAILQ:PAYLOAD:ID", 0, 0, tmplput_MailQPayloadID, NULL, CTX_MAILQITEM);
       RegisterNamespace("MAILQ:BOUNCETO", 0, 1, tmplput_MailQBounceTo, NULL, CTX_MAILQITEM);
       RegisterNamespace("MAILQ:ATTEMPTED", 0, 0, tmplput_MailQAttempted, NULL, CTX_MAILQITEM);
       RegisterNamespace("MAILQ:SUBMITTED", 0, 0, tmplput_MailQSubmitted, NULL, CTX_MAILQITEM);
       RegisterNamespace("MAILQ:ENVELOPEFROM", 0, 1, tmplput_MailQEnvelopeFrom, NULL, CTX_MAILQITEM);
       RegisterNamespace("MAILQ:SRCROOM", 0, 1, tmplput_MailQSourceRoom, NULL, CTX_MAILQITEM);
       RegisterConditional(HKEY("COND:MAILQ:HAVESRCROOM"), 0, Conditional_MailQ_HaveSourceRoom,  CTX_MAILQITEM);
       RegisterNamespace("MAILQ:RETRY", 0, 0, tmplput_MailQRetry, NULL, CTX_MAILQITEM);

       RegisterNamespace("MAILQ:RCPT:ADDR", 0, 1, tmplput_MailQRCPT, NULL, CTX_MAILQ_RCPT);
       RegisterNamespace("MAILQ:RCPT:STATUS", 0, 0, tmplput_MailQRCPTStatus, NULL, CTX_MAILQ_RCPT);
       RegisterNamespace("MAILQ:RCPT:STATUSMSG", 0, 1, tmplput_MailQStatusMsg, NULL, CTX_MAILQ_RCPT);

       RegisterIterator("MAILQ:RCPT", 0, NULL, iterate_get_Recipients, 
                      NULL, NULL, CTX_MAILQ_RCPT, CTX_MAILQITEM, IT_NOFLAG);


       RegisterReadLoopHandlerset(
              VIEW_QUEUE,
              qview_GetParamsGetServerCall,
              qview_PrintPageHeader,
              NULL, /* TODO: is this right? */
              NULL,
              qview_LoadMsgFromServer,
              qview_RenderView_or_Tail,
              qview_Cleanup);

}

Here is the call graph for this function:

Here is the caller graph for this function:

HashList* iterate_get_Recipients ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 203 of file smtpqueue.c.

{
       OneQueItem *Item = (OneQueItem*) CTX;
       return Item->MailQEntries;
}

Here is the caller graph for this function:

void NewMailQEntry ( OneQueItem Item)

Definition at line 210 of file smtpqueue.c.

{
       Item->Current = (MailQEntry*) malloc(sizeof(MailQEntry));
       memset(Item->Current, 0, sizeof(MailQEntry));

       if (Item->MailQEntries == NULL)
              Item->MailQEntries = NewHash(1, Flathash);
       Item->Current->StatusMessage = NewStrBuf();
       Item->Current->n = GetCount(Item->MailQEntries);
       Put(Item->MailQEntries,
           IKEY(Item->Current->n),
           Item->Current,
           FreeMailQEntry);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void QItem_Handle_Attempted ( OneQueItem Item,
StrBuf *  Line,
const char **  Pos 
)

Definition at line 276 of file smtpqueue.c.

{
       Item->ReattemptWhen = StrBufExtractNext_int(Line, Pos, '|');
}

Here is the caller graph for this function:

void QItem_Handle_BounceTo ( OneQueItem Item,
StrBuf *  Line,
const char **  Pos 
)

Definition at line 237 of file smtpqueue.c.

{
       if (Item->BounceTo == NULL)
              Item->BounceTo = NewStrBufPlain(NULL, StrLength(Line));
       StrBufExtract_NextToken(Item->BounceTo, Line, Pos, '|');
}

Here is the caller graph for this function:

void QItem_Handle_EnvelopeFrom ( OneQueItem Item,
StrBuf *  Line,
const char **  Pos 
)

Definition at line 230 of file smtpqueue.c.

{
       if (Item->EnvelopeFrom == NULL)
              Item->EnvelopeFrom = NewStrBufPlain(NULL, StrLength(Line));
       StrBufExtract_NextToken(Item->EnvelopeFrom, Line, Pos, '|');
}

Here is the caller graph for this function:

void QItem_Handle_MsgID ( OneQueItem Item,
StrBuf *  Line,
const char **  Pos 
)

Definition at line 225 of file smtpqueue.c.

{
       Item->MessageID = StrBufExtractNext_long(Line, Pos, '|');
}

Here is the caller graph for this function:

void QItem_Handle_Recipient ( OneQueItem Item,
StrBuf *  Line,
const char **  Pos 
)

Definition at line 251 of file smtpqueue.c.

{
       if (Item->Current == NULL)
              NewMailQEntry(Item);
       if (Item->Current->Recipient == NULL)
              Item->Current->Recipient=NewStrBufPlain(NULL, StrLength(Line));
       StrBufExtract_NextToken(Item->Current->Recipient, Line, Pos, '|');
       Item->Current->Status = StrBufExtractNext_int(Line, Pos, '|');
       StrBufExtract_NextToken(Item->Current->StatusMessage, Line, Pos, '|');
       Item->Current = NULL; // TODO: is this always right?
}

Here is the call graph for this function:

Here is the caller graph for this function:

void QItem_Handle_retry ( OneQueItem Item,
StrBuf *  Line,
const char **  Pos 
)

Definition at line 264 of file smtpqueue.c.

{
       Item->Retry = StrBufExtractNext_int(Line, Pos, '|');
}

Here is the caller graph for this function:

void QItem_Handle_SenderRoom ( OneQueItem Item,
StrBuf *  Line,
const char **  Pos 
)

Definition at line 244 of file smtpqueue.c.

{
       if (Item->SenderRoom == NULL)
              Item->SenderRoom = NewStrBufPlain(NULL, StrLength(Line));
       StrBufExtract_NextToken(Item->SenderRoom, Line, Pos, '|');
}

Here is the caller graph for this function:

void QItem_Handle_Submitted ( OneQueItem Item,
StrBuf *  Line,
const char **  Pos 
)

Definition at line 270 of file smtpqueue.c.

{
       Item->Submitted = atol(*Pos);

}

Here is the caller graph for this function:

int qview_Cleanup ( void **  ViewSpecific)

Definition at line 374 of file smtpqueue.c.

{
       wDumpContent(1);
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 318 of file smtpqueue.c.

{
       if (!WC->is_aide)
       {
              DoTemplate(HKEY("aide_required"), NULL, NULL);
              end_burst();

              return 300;
       }
       else {
              snprintf(cmd, len, "MSGS ALL|0|1");
              snprintf(filter, flen, "SUBJ|QMSG");
              DoTemplate(HKEY("view_mailq_header"), NULL, NULL);
              return 200;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 344 of file smtpqueue.c.

{
       wcsession *WCC = WC;
       const StrBuf *Mime;

        /* Not (yet?) needed here? calview *c = (calview *) *ViewSpecific; */
       read_message(WCC->WBuf, HKEY("view_mailq_message_bearer"), Msg->msgnum, NULL, &Mime);

        return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int qview_PrintPageHeader ( SharedMessageStatus Stat,
void **  ViewSpecific 
)

Definition at line 312 of file smtpqueue.c.

{
       output_headers(1, 1, 1, 0, 0, 0);
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int qview_RenderView_or_Tail ( SharedMessageStatus Stat,
void **  ViewSpecific,
long  oper 
)

Definition at line 360 of file smtpqueue.c.

{
       wcsession *WCC = WC;
       WCTemplputParams SubTP;

       if (GetCount(WCC->summ) == 0)
              DoTemplate(HKEY("view_mailq_footer_empty"),NULL, &SubTP);
       else
              DoTemplate(HKEY("view_mailq_footer"),NULL, &SubTP);
       
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void RegisterQItemHandler ( const char *  Key,
long  Len,
QItemHandler  H 
)

Definition at line 56 of file smtpqueue.c.

{
       QItemHandlerStruct *HS = (QItemHandlerStruct*)malloc(sizeof(QItemHandlerStruct));
       HS->H = H;
       Put(QItemHandlers, Key, Len, HS, NULL);
}

Here is the caller graph for this function:

void render_QUEUE ( wc_mime_attachment Mime,
StrBuf *  RawData,
StrBuf *  FoundCharset 
)

Definition at line 288 of file smtpqueue.c.

{
       WCTemplputParams SubTP;

       memset(&SubTP, 0, sizeof(WCTemplputParams));
       SubTP.Filter.ContextType = CTX_MAILQITEM;
       SubTP.Context = DeserializeQueueItem(Mime->Data, Mime->msgnum);
       DoTemplate(HKEY("view_mailq_message"),NULL, &SubTP);
       FreeQueItem ((OneQueItem**)&SubTP.Context);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 301 of file smtpqueue.c.

{
       DeleteHash(&QItemHandlers);
}

Here is the caller graph for this function:

Definition at line 307 of file smtpqueue.c.

{
       QItemHandlers = NewHash(0, NULL);
}

Here is the caller graph for this function:

void tmplput_MailQAttempted ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 142 of file smtpqueue.c.

{
        char datebuf[64];
       OneQueItem *Item = (OneQueItem*) CTX;
        webcit_fmt_date(datebuf, 64, Item->ReattemptWhen, DATEFMT_BRIEF);
        StrBufAppendBufPlain(Target, datebuf, -1, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmplput_MailQBounceTo ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 137 of file smtpqueue.c.

{
       OneQueItem *Item = (OneQueItem*) CTX;
       StrBufAppendTemplate(Target, TP, Item->BounceTo, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmplput_MailQEnvelopeFrom ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 156 of file smtpqueue.c.

{
       OneQueItem *Item = (OneQueItem*) CTX;
       StrBufAppendTemplate(Target, TP, Item->EnvelopeFrom, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmplput_MailQID ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 127 of file smtpqueue.c.

{
       OneQueItem *Item = (OneQueItem*) CTX;
       StrBufAppendPrintf(Target, "%ld", Item->QueMsgID);;
}

Here is the caller graph for this function:

void tmplput_MailQPayloadID ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 132 of file smtpqueue.c.

{
       OneQueItem *Item = (OneQueItem*) CTX;
       StrBufAppendPrintf(Target, "%ld", Item->MessageID);
}

Here is the caller graph for this function:

void tmplput_MailQRCPT ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 187 of file smtpqueue.c.

{
       MailQEntry *Entry = (MailQEntry*) CTX;
       StrBufAppendTemplate(Target, TP, Entry->Recipient, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmplput_MailQRCPTStatus ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 192 of file smtpqueue.c.

{
       MailQEntry *Entry = (MailQEntry*) CTX;
       StrBufAppendPrintf(Target, "%ld", Entry->Status);
}

Here is the caller graph for this function:

void tmplput_MailQRetry ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 173 of file smtpqueue.c.

{
        char datebuf[64];
       OneQueItem *Item = (OneQueItem*) CTX;

       if (Item->Retry == 0) {
              StrBufAppendBufPlain(Target, _("First Attempt pending"), -1, 0);
       }
       else {
              webcit_fmt_date(datebuf, sizeof(datebuf), Item->Retry, DATEFMT_BRIEF);
              StrBufAppendBufPlain(Target, datebuf, -1, 0);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmplput_MailQSourceRoom ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 161 of file smtpqueue.c.

{
       OneQueItem *Item = (OneQueItem*) CTX;
       StrBufAppendTemplate(Target, TP, Item->SenderRoom, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmplput_MailQStatusMsg ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 197 of file smtpqueue.c.

{
       MailQEntry *Entry = (MailQEntry*) CTX;
       StrBufAppendTemplate(Target, TP, Entry->StatusMessage, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tmplput_MailQSubmitted ( StrBuf *  Target,
WCTemplputParams TP 
)

Definition at line 149 of file smtpqueue.c.

{
        char datebuf[64];
       OneQueItem *Item = (OneQueItem*) CTX;
        webcit_fmt_date(datebuf, 64, Item->Submitted, DATEFMT_BRIEF);
        StrBufAppendBufPlain(Target, datebuf, -1, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

HashList* QItemHandlers = NULL

Definition at line 6 of file smtpqueue.c.