9 |
|
|
10 |
|
|
11 |
extern unsigned int options; |
extern unsigned int options; |
12 |
|
extern unsigned int capabilities; |
13 |
|
|
14 |
|
static struct namespace_t namesp; |
15 |
|
|
16 |
|
|
17 |
#ifdef DEBUG |
#ifdef DEBUG |
30 |
*/ |
*/ |
31 |
int check_capabilities(void) |
int check_capabilities(void) |
32 |
{ |
{ |
33 |
|
capabilities = CAPABILITY_NONE; |
34 |
|
|
35 |
return capability_response(imap_capability()); |
return capability_response(imap_capability()); |
36 |
} |
} |
37 |
|
|
38 |
|
|
39 |
/* |
/* |
40 |
|
* Get namespace of mail server's mailboxes. |
41 |
|
*/ |
42 |
|
int check_namespace(void) |
43 |
|
{ |
44 |
|
namesp.prefix[0] = namesp.delim = 0; |
45 |
|
|
46 |
|
if (!(options & OPTION_NAMESPACE) || |
47 |
|
!(capabilities & CAPABILITY_NAMESPACE)) |
48 |
|
return 0; |
49 |
|
else |
50 |
|
return namespace_response(imap_namespace(), &namesp); |
51 |
|
} |
52 |
|
|
53 |
|
|
54 |
|
/* |
55 |
* Login to server. |
* Login to server. |
56 |
*/ |
*/ |
57 |
int login(char *user, char *pass) |
int login(char *user, char *pass) |
61 |
return server_response(imap_login(user, pass)); |
return server_response(imap_login(user, pass)); |
62 |
} |
} |
63 |
|
|
64 |
|
|
65 |
/* |
/* |
66 |
* Open mailbox in read-write mode. |
* Open mailbox in read-write mode. |
67 |
*/ |
*/ |
73 |
return -2; /* No messages exist. No filters need to |
return -2; /* No messages exist. No filters need to |
74 |
be applied. */ |
be applied. */ |
75 |
|
|
76 |
r = select_response(imap_select(mbox)); |
r = select_response(imap_select(apply_namespace(mbox, namesp.prefix, |
77 |
|
namesp.delim))); |
78 |
|
|
79 |
log_info(LOG_MAILBOX, mbox); |
log_info(LOG_MAILBOX, mbox); |
80 |
|
|
87 |
*/ |
*/ |
88 |
int mailbox_status(char *mbox) |
int mailbox_status(char *mbox) |
89 |
{ |
{ |
90 |
return status_response(imap_status(mbox, "MESSAGES RECENT UNSEEN"), mbox); |
return status_response(imap_status(apply_namespace(mbox, namesp.prefix, |
91 |
|
namesp.delim), |
92 |
|
"MESSAGES RECENT UNSEEN"), mbox); |
93 |
|
|
94 |
} |
} |
95 |
|
|
96 |
|
|
129 |
log_info(LOG_FILTER, filters[i]->key); |
log_info(LOG_FILTER, filters[i]->key); |
130 |
|
|
131 |
apply_action(mesgs, &(filters[i]->action.type), |
apply_action(mesgs, &(filters[i]->action.type), |
132 |
filters[i]->action.destmbox, filters[i]->action.args); |
apply_namespace(filters[i]->action.destmbox, |
133 |
|
namesp.prefix, namesp.delim), |
134 |
|
filters[i]->action.args); |
135 |
|
|
136 |
free(mesgs); |
free(mesgs); |
137 |
} |
} |