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