Style cleanup
[citadel.git] / citadel / modules / smtp / smtpqueue.h
1 /*
2  *
3  * Copyright (c) 1998-2012 by the citadel.org team
4  *
5  *  This program is open source software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 3 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 /*****************************************************************************/
21 /*               SMTP CLIENT (Queue Management) STUFF                        */
22 /*****************************************************************************/
23
24
25
26 #define MaxAttempts 15
27 typedef struct _delivery_attempt {
28         time_t when;
29         time_t retry;
30 }DeliveryAttempt;
31
32 typedef struct _mailq_entry {
33         DeliveryAttempt Attempts[MaxAttempts];
34         int nAttempts;
35         StrBuf *Recipient;
36         StrBuf *StatusMessage;
37         int Status;
38         /**<
39          * 0 = No delivery has yet been attempted
40          * 2 = Delivery was successful
41          * 4 = A transient error was experienced ... try again later
42          * 5 = Delivery to this address failed permanently.  The error message
43          *     should be placed in the fourth field so that a bounce message may
44          *     be generated.
45          */
46
47         int n;
48         int Active;
49 }MailQEntry;
50
51 typedef struct queueitem {
52         long MessageID;
53         long QueMsgID;
54         long Submitted;
55         int FailNow;
56         HashList *MailQEntries;
57 /* copy of the currently parsed item in the MailQEntries list;
58  * if null add a new one.
59  */
60         MailQEntry *Current;
61         DeliveryAttempt LastAttempt;
62         long ActiveDeliveries;
63         StrBuf *EnvelopeFrom;
64         StrBuf *BounceTo;
65         ParsedURL *URL;
66         ParsedURL *FallBackHost;
67 } OneQueItem;
68
69 typedef void (*QItemHandler)(OneQueItem *Item, StrBuf *Line, const char **Pos);
70
71 int     DecreaseQReference(OneQueItem *MyQItem);
72 void    RemoveQItem(OneQueItem *MyQItem);
73 int     CountActiveQueueEntries(OneQueItem *MyQItem);
74 StrBuf *SerializeQueueItem(OneQueItem *MyQItem);
75 void    smtpq_do_bounce(OneQueItem *MyQItem, StrBuf *OMsgTxt);