1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-12 19:06:36 +00:00

Allow spaces in mail folder names for pop/imap.

For example, you can specify "-f '[Gmail]/All Mail'" in your mail args
to view all mails in your Google mail IMAP folder.
This commit is contained in:
Brenden Matthews 2009-09-27 10:40:06 -07:00
parent a7df1681bb
commit 7fc4d40eb2
3 changed files with 21 additions and 14 deletions

View File

@ -316,8 +316,8 @@
</command> </command>
</term> </term>
<listitem>Default global IMAP server. Arguments are: "host <listitem>Default global IMAP server. Arguments are: "host
user pass [-i interval (in seconds)] [-f folder] [-p port] user pass [-i interval (in seconds)] [-f 'folder'] [-p port]
[-e command] [-r retries]". Default port is 143, default [-e 'command'] [-r retries]". Default port is 143, default
folder is 'INBOX', default interval is 5 minutes, and folder is 'INBOX', default interval is 5 minutes, and
default number of retries before giving up is 5. If the default number of retries before giving up is 5. If the
password is supplied as '*', you will be prompted to enter password is supplied as '*', you will be prompted to enter
@ -704,7 +704,7 @@
</command> </command>
</term> </term>
<listitem>Default global POP3 server. Arguments are: "host <listitem>Default global POP3 server. Arguments are: "host
user pass [-i interval (in seconds)] [-p port] [-e command] user pass [-i interval (in seconds)] [-p port] [-e 'command']
[-r retries]". Default port is 110, default interval is 5 [-r retries]". Default port is 110, default interval is 5
minutes, and default number of retries before giving up is minutes, and default number of retries before giving up is
5. If the password is supplied as '*', you will be prompted 5. If the password is supplied as '*', you will be prompted

View File

@ -1701,7 +1701,7 @@
IMAP inbox by default. You can define individual IMAP IMAP inbox by default. You can define individual IMAP
inboxes seperately by passing arguments to this object. inboxes seperately by passing arguments to this object.
Arguments are: "host user pass [-i interval (in seconds)] Arguments are: "host user pass [-i interval (in seconds)]
[-f folder] [-p port] [-e command] [-r retries]". Default [-f 'folder'] [-p port] [-e 'command'] [-r retries]". Default
port is 143, default folder is 'INBOX', default interval is port is 143, default folder is 'INBOX', default interval is
5 minutes, and default number of retries before giving up 5 minutes, and default number of retries before giving up
is 5. If the password is supplied as '*', you will be is 5. If the password is supplied as '*', you will be
@ -1719,7 +1719,7 @@
global IMAP inbox by default. You can define individual global IMAP inbox by default. You can define individual
IMAP inboxes seperately by passing arguments to this IMAP inboxes seperately by passing arguments to this
object. Arguments are: "host user pass [-i interval (in object. Arguments are: "host user pass [-i interval (in
seconds)] [-f folder] [-p port] [-e command] [-r retries]". seconds)] [-f 'folder'] [-p port] [-e 'command'] [-r retries]".
Default port is 143, default folder is 'INBOX', default Default port is 143, default folder is 'INBOX', default
interval is 5 minutes, and default number of retries before interval is 5 minutes, and default number of retries before
giving up is 5. If the password is supplied as '*', you giving up is 5. If the password is supplied as '*', you
@ -2514,7 +2514,7 @@
global POP3 inbox by default. You can define individual global POP3 inbox by default. You can define individual
POP3 inboxes seperately by passing arguments to this POP3 inboxes seperately by passing arguments to this
object. Arguments are: "host user pass [-i interval (in object. Arguments are: "host user pass [-i interval (in
seconds)] [-p port] [-e command] [-r retries]". Default seconds)] [-p port] [-e 'command'] [-r retries]". Default
port is 110, default interval is 5 minutes, and default port is 110, default interval is 5 minutes, and default
number of retries before giving up is 5. If the password is number of retries before giving up is 5. If the password is
supplied as '*', you will be prompted to enter the password supplied as '*', you will be prompted to enter the password
@ -2532,7 +2532,7 @@
in your global POP3 inbox by default. You can define in your global POP3 inbox by default. You can define
individual POP3 inboxes seperately by passing arguments to individual POP3 inboxes seperately by passing arguments to
this object. Arguments are: "host user pass [-i interval this object. Arguments are: "host user pass [-i interval
(in seconds)] [-p port] [-e command] [-r retries]". Default (in seconds)] [-p port] [-e 'command'] [-r retries]". Default
port is 110, default interval is 5 minutes, and default port is 110, default interval is 5 minutes, and default
number of retries before giving up is 5. If the password is number of retries before giving up is 5. If the password is
supplied as '*', you will be prompted to enter the password supplied as '*', you will be prompted to enter the password

View File

@ -355,8 +355,15 @@ struct mail_s *parse_mail_args(char type, const char *arg)
if (type == IMAP_TYPE) { if (type == IMAP_TYPE) {
tmp = strstr(arg, "-f "); tmp = strstr(arg, "-f ");
if (tmp) { if (tmp) {
int len = 1024;
tmp += 3; tmp += 3;
sscanf(tmp, "%s", mail->folder); if (tmp[0] == '\'') {
len = strstr(tmp + 1, "'") - tmp - 1;
if (len > 1024) {
len = 1024;
}
}
strncpy(mail->folder, tmp + 1, len);
} else { } else {
strncpy(mail->folder, "INBOX", 128); // default imap inbox strncpy(mail->folder, "INBOX", 128); // default imap inbox
} }
@ -542,9 +549,9 @@ void *imap_thread(void *arg)
break; break;
} }
strncpy(sendbuf, "a2 STATUS ", MAXDATASIZE); strncpy(sendbuf, "a2 STATUS \"", MAXDATASIZE);
strncat(sendbuf, mail->folder, MAXDATASIZE - strlen(sendbuf) - 1); strncat(sendbuf, mail->folder, MAXDATASIZE - strlen(sendbuf) - 1);
strncat(sendbuf, " (MESSAGES UNSEEN)\r\n", strncat(sendbuf, "\" (MESSAGES UNSEEN)\r\n",
MAXDATASIZE - strlen(sendbuf) - 1); MAXDATASIZE - strlen(sendbuf) - 1);
if (imap_command(sockfd, sendbuf, recvbuf, "a2 OK")) { if (imap_command(sockfd, sendbuf, recvbuf, "a2 OK")) {
fail++; fail++;
@ -561,9 +568,9 @@ void *imap_thread(void *arg)
old_messages = mail->messages; old_messages = mail->messages;
if (has_idle) { if (has_idle) {
strncpy(sendbuf, "a4 SELECT ", MAXDATASIZE); strncpy(sendbuf, "a4 SELECT \"", MAXDATASIZE);
strncat(sendbuf, mail->folder, MAXDATASIZE - strlen(sendbuf) - 1); strncat(sendbuf, mail->folder, MAXDATASIZE - strlen(sendbuf) - 1);
strncat(sendbuf, "\r\n", MAXDATASIZE - strlen(sendbuf) - 1); strncat(sendbuf, "\"\r\n", MAXDATASIZE - strlen(sendbuf) - 1);
if (imap_command(sockfd, sendbuf, recvbuf, "a4 OK")) { if (imap_command(sockfd, sendbuf, recvbuf, "a4 OK")) {
fail++; fail++;
break; break;
@ -653,9 +660,9 @@ void *imap_thread(void *arg)
fail++; fail++;
break; break;
} }
strncpy(sendbuf, "a2 STATUS ", MAXDATASIZE); strncpy(sendbuf, "a2 STATUS \"", MAXDATASIZE);
strncat(sendbuf, mail->folder, MAXDATASIZE - strlen(sendbuf) - 1); strncat(sendbuf, mail->folder, MAXDATASIZE - strlen(sendbuf) - 1);
strncat(sendbuf, " (MESSAGES UNSEEN)\r\n", strncat(sendbuf, "\" (MESSAGES UNSEEN)\r\n",
MAXDATASIZE - strlen(sendbuf) - 1); MAXDATASIZE - strlen(sendbuf) - 1);
if (imap_command(sockfd, sendbuf, recvbuf, "a2 OK")) { if (imap_command(sockfd, sendbuf, recvbuf, "a2 OK")) {
fail++; fail++;