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