* allow LMTP posting to all rooms.
[citadel.git] / citadel / msgbase.h
1 /* $Id$ */
2
3 #ifndef MSGBASE_H
4 #define MSGBASE_H
5
6 #define aide_message(text, subject)      quickie_message("Citadel",NULL,NULL,AIDEROOM,text,0,subject)
7
8 enum {
9         MSGS_ALL,
10         MSGS_OLD,
11         MSGS_NEW,
12         MSGS_FIRST,
13         MSGS_LAST,
14         MSGS_GT,
15         MSGS_EQ,
16         MSGS_SEARCH
17 };
18
19 /*
20  * Possible return codes from CtdlOutputMsg()
21  */
22 enum {
23         om_ok,
24         om_not_logged_in,
25         om_no_such_msg,
26         om_mime_error
27 };
28
29 /*
30  * Values of "headers_only" when calling message output routines
31  */
32 #define HEADERS_ALL     0       /* Headers and body */
33 #define HEADERS_ONLY    1       /* Headers only */
34 #define HEADERS_NONE    2       /* Body only */
35 #define HEADERS_FAST    3       /* Headers only with no MIME info */
36
37
38 struct ma_info {
39         int is_ma;              /* Set to 1 if we are using this stuff */
40         int freeze;             /* Freeze the replacement chain because we're
41                                  * digging through a subsection */
42         int did_print;          /* One alternative has been displayed */
43         char chosen_part[128];  /* Which part of a m/a did we choose? */
44         int chosen_pref;        /* Chosen part preference level (lower is better) */
45         int use_fo_hooks;       /* Use fixed output hooks */
46 };
47
48
49 struct repl {                   /* Info for replication checking */
50         char exclusive_id[SIZ];
51         time_t highest;
52 };
53
54
55 /* Data structure returned by validate_recipients() */
56 struct recptypes {
57         int recptypes_magic;
58         int num_local;
59         int num_internet;
60         int num_ignet;
61         int num_room;
62         int num_error;
63         char *errormsg;
64         char *recp_local;
65         char *recp_internet;
66         char *recp_ignet;
67         char *recp_room;
68         char *display_recp;
69 };
70
71 #define RECPTYPES_MAGIC 0xfeeb
72
73 /*
74  * This is a list of "harvested" email addresses that we might want to
75  * stick into someone's address book.  But we defer this operaiton so
76  * it can be done asynchronously.
77  */
78 struct addresses_to_be_filed {
79         struct addresses_to_be_filed *next;
80         char *roomname;
81         char *collected_addresses;
82 };
83
84 extern struct addresses_to_be_filed *atbf;
85
86 int alias (char *name);
87 void cmd_msgs (char *cmdbuf);
88 void cmd_isme (char *cmdbuf);
89 void help_subst (char *strbuf, char *source, char *dest);
90 void do_help_subst (char *buffer);
91 void memfmout (char *mptr, char subst, char *nl);
92 void output_mime_parts(char *);
93 void cmd_msg0 (char *cmdbuf);
94 void cmd_msg2 (char *cmdbuf);
95 void cmd_msg3 (char *cmdbuf);
96 void cmd_msg4 (char *cmdbuf);
97 void cmd_msgp (char *cmdbuf);
98 void cmd_opna (char *cmdbuf);
99 void cmd_dlat (char *cmdbuf);
100 long send_message (struct CtdlMessage *);
101 void loadtroom (void);
102 long CtdlSubmitMsg(struct CtdlMessage *, struct recptypes *, char *);
103 void quickie_message (char *, char *, char *, char *, char *, int, char *);
104 void cmd_ent0 (char *entargs);
105 void cmd_dele (char *delstr);
106 void cmd_move (char *args);
107 void GetMetaData(struct MetaData *, long);
108 void PutMetaData(struct MetaData *);
109 void AdjRefCount(long, int);
110 void TDAP_AdjRefCount(long, int);
111 int TDAP_ProcessAdjRefCountQueue(void);
112 void simple_listing(long, void *);
113 int CtdlMsgCmp(struct CtdlMessage *msg, struct CtdlMessage *template);
114 int CtdlForEachMessage(int mode,
115                         long ref,
116                         char *searchstring,
117                         char *content_type,
118                         struct CtdlMessage *compare,
119                         void (*CallBack) (long, void *),
120                         void *userdata);
121 int CtdlDeleteMessages(char *, long *, int, char *);
122 void CtdlWriteObject(char *, char *, char *, struct ctdluser *,
123                         int, int, unsigned int);
124 struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body);
125 void CtdlFreeMessage(struct CtdlMessage *msg);
126 void serialize_message(struct ser_ret *, struct CtdlMessage *);
127 void dump_message(struct CtdlMessage *msg, long Siz);
128 int is_valid_message(struct CtdlMessage *);
129 void ReplicationChecks(struct CtdlMessage *);
130 int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newmsgs,
131                                 int do_repl_check, struct CtdlMessage *supplied_msg);
132 int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check, struct CtdlMessage *msg);
133 char *CtdlReadMessageBody(char *terminator, size_t maxlen, char *exist, int crlf, int sock);
134 char *CtdlGetSysConfig(char *sysconfname);
135 void CtdlPutSysConfig(char *sysconfname, char *sysconfdata);
136 int CtdlOutputMsg(long msg_num,         /* message number (local) to fetch */
137                 int mode,               /* how would you like that message? */
138                 int headers_only,       /* eschew the message body? */
139                 int do_proto,           /* do Citadel protocol responses? */
140                 int crlf,               /* 0=LF, 1=CRLF */
141                 char *section           /* output a message/rfc822 section */
142 );
143 int CtdlOutputPreLoadedMsg(struct CtdlMessage *,
144                 int mode,               /* how would you like that message? */
145                 int headers_only,       /* eschew the message body? */
146                 int do_proto,           /* do Citadel protocol responses? */
147                 int crlf                /* 0=LF, 1=CRLF */
148 );
149 int CtdlCopyMsgsToRoom(long *msgnum, int num_msgs, char *dest);
150 int CtdlDoIHavePermissionToDeleteMessagesFromThisRoom(void);
151
152 enum {
153         POST_LOGGED_IN,
154         POST_EXTERNAL,
155         CHECK_EXISTANCE,
156         POST_LMTP
157 };
158 int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf, 
159                                           size_t n, 
160                                           const char* RemoteIdentifier,
161                                           int PostPublic);
162
163
164 /* values for which_set */
165 enum {
166         ctdlsetseen_seen,
167         ctdlsetseen_answered
168 };
169 void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
170                  int target_setting, int which_set,
171                 struct ctdluser *which_user, struct ctdlroom *which_room);
172 void CtdlGetSeen(char *buf, int which_set);
173
174 struct recptypes *validate_recipients(char *recipients,
175                                       const char *RemoteIdentifier, 
176                                       int Flags);
177
178 void free_recipients(struct recptypes *);
179
180 struct CtdlMessage *CtdlMakeMessage(
181         struct ctdluser *author,        /* author's user structure */
182         char *recipient,                /* NULL if it's not mail */
183         char *recp_cc,                  /* NULL if it's not mail */
184         char *room,                     /* room where it's going */
185         int type,                       /* see MES_ types in header file */
186         int format_type,                /* variformat, plain text, MIME... */
187         char *fake_name,                /* who we're masquerading as */
188         char *my_email,                 /* which of my email addresses to use (empty is ok) */
189         char *subject,                  /* Subject (optional) */
190         char *supplied_euid,            /* ...or NULL if this is irrelevant */
191         char *preformatted_text         /* ...or NULL to read text from client */
192 );
193 int CtdlCheckInternetMailPermission(struct ctdluser *who);
194 int CtdlIsMe(char *addr, int addr_buf_len);
195
196 #endif /* MSGBASE_H */