Allow spaces in mail folder names for pop/imap.
authorBrenden Matthews <brenden@diddyinc.com>
Sun, 27 Sep 2009 17:40:06 +0000 (10:40 -0700)
committerBrenden Matthews <brenden@diddyinc.com>
Sun, 27 Sep 2009 17:40:06 +0000 (10:40 -0700)
For example, you can specify "-f '[Gmail]/All Mail'" in your mail args
to view all mails in your Google mail IMAP folder.

doc/config_settings.xml
doc/variables.xml
src/mail.c

index 1b71f43..3bb152a 100644 (file)
             </command>
         </term>
         <listitem>Default global IMAP server. Arguments are: "host
-        user pass [-i interval (in seconds)] [-f folder] [-p port]
-        [-e command] [-r retries]". Default port is 143, default
+        user pass [-i interval (in seconds)] [-f 'folder'] [-p port]
+        [-e 'command'] [-r retries]". Default port is 143, default
         folder is 'INBOX', default interval is 5 minutes, and
         default number of retries before giving up is 5. If the
         password is supplied as '*', you will be prompted to enter
             </command>
         </term>
         <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
         minutes, and default number of retries before giving up is
         5. If the password is supplied as '*', you will be prompted
index 1eea412..3472c78 100644 (file)
         IMAP inbox by default. You can define individual IMAP
         inboxes seperately by passing arguments to this object.
         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
         5 minutes, and default number of retries before giving up
         is 5. If the password is supplied as '*', you will be
         global IMAP inbox by default. You can define individual
         IMAP inboxes seperately by passing arguments to this
         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
         interval is 5 minutes, and default number of retries before
         giving up is 5. If the password is supplied as '*', you
         global POP3 inbox by default. You can define individual
         POP3 inboxes seperately by passing arguments to this
         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
         number of retries before giving up is 5. If the password is
         supplied as '*', you will be prompted to enter the password
         in your global POP3 inbox by default. You can define
         individual POP3 inboxes seperately by passing arguments to
         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
         number of retries before giving up is 5. If the password is
         supplied as '*', you will be prompted to enter the password
index ec1fbc9..6504dc1 100644 (file)
@@ -355,8 +355,15 @@ struct mail_s *parse_mail_args(char type, const char *arg)
        if (type == IMAP_TYPE) {
                tmp = strstr(arg, "-f ");
                if (tmp) {
+                       int len = 1024;
                        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 {
                        strncpy(mail->folder, "INBOX", 128);    // default imap inbox
                }
@@ -542,9 +549,9 @@ void *imap_thread(void *arg)
                                break;
                        }
 
-                       strncpy(sendbuf, "a2 STATUS ", MAXDATASIZE);
+                       strncpy(sendbuf, "a2 STATUS \"", MAXDATASIZE);
                        strncat(sendbuf, mail->folder, MAXDATASIZE - strlen(sendbuf) - 1);
-                       strncat(sendbuf, " (MESSAGES UNSEEN)\r\n",
+                       strncat(sendbuf, "\" (MESSAGES UNSEEN)\r\n",
                                        MAXDATASIZE - strlen(sendbuf) - 1);
                        if (imap_command(sockfd, sendbuf, recvbuf, "a2 OK")) {
                                fail++;
@@ -561,9 +568,9 @@ void *imap_thread(void *arg)
                        old_messages = mail->messages;
 
                        if (has_idle) {
-                               strncpy(sendbuf, "a4 SELECT ", MAXDATASIZE);
+                               strncpy(sendbuf, "a4 SELECT \"", MAXDATASIZE);
                                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")) {
                                        fail++;
                                        break;
@@ -653,9 +660,9 @@ void *imap_thread(void *arg)
                                                                fail++;
                                                                break;
                                                        }
-                                                       strncpy(sendbuf, "a2 STATUS ", MAXDATASIZE);
+                                                       strncpy(sendbuf, "a2 STATUS \"", MAXDATASIZE);
                                                        strncat(sendbuf, mail->folder, MAXDATASIZE - strlen(sendbuf) - 1);
-                                                       strncat(sendbuf, " (MESSAGES UNSEEN)\r\n",
+                                                       strncat(sendbuf, "\" (MESSAGES UNSEEN)\r\n",
                                                                        MAXDATASIZE - strlen(sendbuf) - 1);
                                                        if (imap_command(sockfd, sendbuf, recvbuf, "a2 OK")) {
                                                                fail++;