]> code.citadel.org Git - citadel.git/blob - citadel/imap_misc.c
* Probable completion of STATUS, COPY, STORE, and EXPUNGE commands in IMAP
[citadel.git] / citadel / imap_misc.c
1 /*
2  * $Id$
3  *
4  *
5  */
6
7
8 #include "sysdep.h"
9 #include <stdlib.h>
10 #include <unistd.h>
11 #include <stdio.h>
12 #include <fcntl.h>
13 #include <signal.h>
14 #include <pwd.h>
15 #include <errno.h>
16 #include <sys/types.h>
17 #include <sys/time.h>
18 #include <sys/wait.h>
19 #include <ctype.h>
20 #include <string.h>
21 #include <limits.h>
22 #include "citadel.h"
23 #include "server.h"
24 #include <time.h>
25 #include "sysdep_decls.h"
26 #include "citserver.h"
27 #include "support.h"
28 #include "config.h"
29 #include "dynloader.h"
30 #include "room_ops.h"
31 #include "user_ops.h"
32 #include "policy.h"
33 #include "database.h"
34 #include "msgbase.h"
35 #include "tools.h"
36 #include "internet_addressing.h"
37 #include "serv_imap.h"
38 #include "imap_tools.h"
39 #include "imap_fetch.h"
40 #include "imap_misc.h"
41 #include "genstamp.h"
42
43
44
45
46
47
48 /*
49  * imap_copy() calls imap_do_copy() to do its actual work, once it's
50  * validated and boiled down the request a bit.  (returns 0 on success)
51  */
52 int imap_do_copy(char *destination_folder) {
53         int i;
54         char roomname[ROOMNAMELEN];
55
56         i = imap_grabroom(roomname, destination_folder);
57         if (i != 0) return(i);
58
59         if (IMAP->num_msgs > 0) {
60                 for (i = 0; i < IMAP->num_msgs; ++i) {
61                         if (IMAP->flags[i] && IMAP_SELECTED) {
62                                 CtdlCopyMsgToRoom(
63                                         IMAP->msgids[i], roomname);
64                         }
65                 }
66         }
67
68         return(0);
69 }
70
71
72 /*
73  * This function is called by the main command loop.
74  */
75 void imap_copy(int num_parms, char *parms[]) {
76         int ret;
77
78         if (num_parms != 4) {
79                 cprintf("%s BAD invalid parameters\r\n", parms[0]);
80                 return;
81         }
82
83         if (imap_is_message_set(parms[2])) {
84                 imap_pick_range(parms[2], 0);
85         }
86         else {
87                 cprintf("%s BAD invalid parameters\r\n", parms[0]);
88                 return;
89         }
90
91         ret = imap_do_copy(parms[3]);
92         if (!ret) {
93                 cprintf("%s OK COPY completed\r\n", parms[0]);
94         }
95         else {
96                 cprintf("%s NO COPY failed (error %d)\r\n", parms[0], ret);
97         }
98 }
99
100 /*
101  * This function is called by the main command loop.
102  */
103 void imap_uidcopy(int num_parms, char *parms[]) {
104
105         if (num_parms != 5) {
106                 cprintf("%s BAD invalid parameters\r\n", parms[0]);
107                 return;
108         }
109
110         if (imap_is_message_set(parms[3])) {
111                 imap_pick_range(parms[3], 1);
112         }
113         else {
114                 cprintf("%s BAD invalid parameters\r\n", parms[0]);
115                 return;
116         }
117
118         if (imap_do_copy(parms[4]) == 0) {
119                 cprintf("%s OK UID COPY completed\r\n", parms[0]);
120         }
121         else {
122                 cprintf("%s NO UID COPY failed\r\n", parms[0]);
123         }
124 }
125
126