]> code.citadel.org Git - citadel.git/blob - citadel/imap_misc.c
*** empty log message ***
[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(1);
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
77         if (num_parms != 4) {
78                 cprintf("%s BAD invalid parameters\r\n", parms[0]);
79                 return;
80         }
81
82         if (imap_is_message_set(parms[2])) {
83                 imap_pick_range(parms[2], 0);
84         }
85         else {
86                 cprintf("%s BAD invalid parameters\r\n", parms[0]);
87                 return;
88         }
89
90         if (imap_do_copy(parms[3]) == 0) {
91                 cprintf("%s OK COPY completed\r\n", parms[0]);
92         }
93         else {
94                 cprintf("%s NO COPY failed\r\n", parms[0]);
95         }
96 }
97
98 /*
99  * This function is called by the main command loop.
100  */
101 void imap_uidcopy(int num_parms, char *parms[]) {
102
103         if (num_parms != 5) {
104                 cprintf("%s BAD invalid parameters\r\n", parms[0]);
105                 return;
106         }
107
108         if (imap_is_message_set(parms[3])) {
109                 imap_pick_range(parms[3], 1);
110         }
111         else {
112                 cprintf("%s BAD invalid parameters\r\n", parms[0]);
113                 return;
114         }
115
116         if (imap_do_copy(parms[4]) == 0) {
117                 cprintf("%s OK UID COPY completed\r\n", parms[0]);
118         }
119         else {
120                 cprintf("%s NO UID COPY failed\r\n", parms[0]);
121         }
122 }
123
124