* elmo-util.el (elmo-quoted-specials-list): New constant.
authorhmurata <hmurata>
Sun, 5 Jun 2005 02:08:15 +0000 (02:08 +0000)
committerhmurata <hmurata>
Sun, 5 Jun 2005 02:08:15 +0000 (02:08 +0000)
(elmo-quoted-token): New function.

* elmo-net.el (elmo-net-quote-chars-regexp): New constant.
(elmo-net-format-quoted): New function.
(elmo-net-parse-network): Ditto.
(elmo-folder-initialize): Use it.

* elmo-nntp.el (elmo-folder-initialize): Use
`elmo-net-parse-network' to parse network specification instead of
`elmo-folder-initialize#elmo-net'.

* elmo-pop3.el (elmo-folder-initialize): Ditto.

* elmo-imap4.el (elmo-folder-initialize): Ditto.
(elmo-folder-list-subfolders): Quote folder name by
`elmo-net-format-quoted'.

elmo/ChangeLog
elmo/elmo-imap4.el
elmo/elmo-net.el
elmo/elmo-nntp.el
elmo/elmo-pop3.el
elmo/elmo-util.el

index b725605..f76ef43 100644 (file)
@@ -1,3 +1,23 @@
+2005-06-05  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
+
+       * elmo-util.el (elmo-quoted-specials-list): New constant.
+       (elmo-quoted-token): New function.
+
+       * elmo-net.el (elmo-net-quote-chars-regexp): New constant.
+       (elmo-net-format-quoted): New function.
+       (elmo-net-parse-network): Ditto.
+       (elmo-folder-initialize): Use it.
+
+       * elmo-nntp.el (elmo-folder-initialize): Use
+       `elmo-net-parse-network' to parse network specification instead of
+       `elmo-folder-initialize#elmo-net'.
+
+       * elmo-pop3.el (elmo-folder-initialize): Ditto.
+
+       * elmo-imap4.el (elmo-folder-initialize): Ditto.
+       (elmo-folder-list-subfolders): Quote folder name by
+       `elmo-net-format-quoted'.
+
 2005-05-22  Hiroya Murata  <lapis-lazuli@pop06.odn.ne.jp>
 
        * elmo-nntp.el (elmo-nntp-use-server-search-p): New function.
index b59cfc2..4b59548 100644 (file)
@@ -1836,9 +1836,7 @@ Return nil if no complete line has arrived."
        (elmo-imap4-forward)
        (nreverse body)))))
 
-(luna-define-method elmo-folder-initialize :around ((folder
-                                                    elmo-imap4-folder)
-                                                   name)
+(luna-define-method elmo-folder-initialize ((folder elmo-imap4-folder) name)
   (let ((default-user  elmo-imap4-default-user)
        (default-server elmo-imap4-default-server)
        (default-port   elmo-imap4-default-port)
@@ -1853,25 +1851,26 @@ Return nil if no complete line has arrived."
       ;; "hoge%imap.server@gateway".
       (setq default-user (elmo-match-string 1 default-server))
       (setq default-server (elmo-match-string 2 default-server)))
-    (setq name (luna-call-next-method))
     ;; mailbox
-    (setq parse (elmo-parse-token name ":"))
+    (setq parse (elmo-parse-token name ":/@"))
     (elmo-imap4-folder-set-mailbox-internal folder
                                            (elmo-imap4-encode-folder-string
                                             (car parse)))
     ;; user
-    (setq parse (elmo-parse-prefixed-element ?: (cdr parse) "/"))
+    (setq parse (elmo-parse-prefixed-element ?: (cdr parse) "/@"))
     (elmo-net-folder-set-user-internal folder
                                       (if (eq (length (car parse)) 0)
                                           default-user
                                         (car parse)))
     ;; auth
-    (setq parse (elmo-parse-prefixed-element ?/ (cdr parse)))
+    (setq parse (elmo-parse-prefixed-element ?/ (cdr parse) "@"))
     (elmo-net-folder-set-auth-internal
      folder
      (if (eq (length (car parse)) 0)
         (or elmo-imap4-default-authenticate-type 'clear)
        (intern (car parse))))
+    ;; network
+    (elmo-net-parse-network folder (cdr parse))
     (unless (elmo-net-folder-server-internal folder)
       (elmo-net-folder-set-server-internal folder default-server))
     (unless (elmo-net-folder-port-internal folder)
@@ -2041,7 +2040,8 @@ Return nil if no complete line has arrived."
                                      fld))
                                  (cdr result)))
                  folder (concat prefix
-                                (elmo-imap4-decode-folder-string folder)
+                                (elmo-net-format-quoted
+                                 (elmo-imap4-decode-folder-string folder))
                                 (and append-serv
                                      (eval append-serv)))
                  ret (append ret (if has-child-p
@@ -2049,7 +2049,9 @@ Return nil if no complete line has arrived."
                                    (list folder)))))
          ret)
       (mapcar (lambda (fld)
-               (concat prefix (elmo-imap4-decode-folder-string fld)
+               (concat prefix
+                       (elmo-net-format-quoted
+                        (elmo-imap4-decode-folder-string fld))
                        (and append-serv
                             (eval append-serv))))
              result))))
index 28d0620..efef0ee 100644 (file)
@@ -310,25 +310,33 @@ Returned value is searched from `elmo-network-stream-type-alist'."
       (setq alist (cdr alist)))
     spec))
 
-(luna-define-method elmo-folder-initialize ((folder
-                                            elmo-net-folder)
-                                           name)
+(defconst elmo-net-quote-chars-regexp "[@:!]")
+
+(defun elmo-net-format-quoted (string)
+  (if (string-match elmo-net-quote-chars-regexp string)
+      (elmo-quoted-token string)
+    string))
+
+(defun elmo-net-parse-network (folder network)
+  (let (parse)
+    ;; server
+    (setq parse (elmo-parse-prefixed-element ?@ network ":!"))
+    (when (> (length (car parse)) 0)
+      (elmo-net-folder-set-server-internal folder (car parse)))
+    ;; port
+    (setq parse (elmo-parse-prefixed-element ?: (cdr parse) "!"))
+    (when (> (length (car parse)) 0)
+      (elmo-net-folder-set-port-internal folder (string-to-int (car parse))))
+    ;; stream-type
+    (elmo-net-folder-set-stream-type-internal
+     folder
+     (assoc (cdr parse) elmo-network-stream-type-alist))))
+
+(luna-define-method elmo-folder-initialize ((folder elmo-net-folder) name)
   ;; user and auth should be set in subclass.
   (when (string-match "\\(@[^@:/!]+\\)?\\(:[0-9]+\\)?\\(!.*\\)?$" name)
-    (if (match-beginning 1)
-       (elmo-net-folder-set-server-internal
-        folder
-        (elmo-match-substring 1 name 1)))
-    (if (match-beginning 2)
-       (elmo-net-folder-set-port-internal
-        folder
-        (string-to-int (elmo-match-substring 2 name 1))))
-    (if (match-beginning 3)
-       (elmo-net-folder-set-stream-type-internal
-        folder
-        (assoc (elmo-match-string 3 name)
-               elmo-network-stream-type-alist)))
-    (substring name 0 (match-beginning 0))))
+    (elmo-net-parse-network folder (substring name (match-beginning 0))))
+  folder)
 
 (luna-define-method elmo-net-port-info ((folder elmo-net-folder))
   (list (elmo-net-folder-server-internal folder)
index 0b0abf4..120ae00 100644 (file)
@@ -87,9 +87,7 @@ Debug information is inserted in the buffer \"*NNTP DEBUG*\"")
                     (group temp-crosses reads))
   (luna-define-internal-accessors 'elmo-nntp-folder))
 
-(luna-define-method elmo-folder-initialize :around ((folder
-                                                    elmo-nntp-folder)
-                                                   name)
+(luna-define-method elmo-folder-initialize ((folder elmo-nntp-folder) name)
   (let ((elmo-network-stream-type-alist
         (if elmo-nntp-stream-type-alist
             (setq elmo-network-stream-type-alist
@@ -97,18 +95,19 @@ Debug information is inserted in the buffer \"*NNTP DEBUG*\"")
                           elmo-network-stream-type-alist))
           elmo-network-stream-type-alist))
        explicit-user parse)
-    (setq name (luna-call-next-method))
-    (setq parse (elmo-parse-token name ":"))
+    (setq parse (elmo-parse-token name ":@"))
     (elmo-nntp-folder-set-group-internal folder
                                         (elmo-nntp-encode-group-string
                                          (car parse)))
     (setq explicit-user (eq ?: (string-to-char (cdr parse))))
-    (setq parse (elmo-parse-prefixed-element ?: (cdr parse)))
+    (setq parse (elmo-parse-prefixed-element ?: (cdr parse) "@"))
     (elmo-net-folder-set-user-internal folder
                                       (if (eq (length (car parse)) 0)
                                           (unless explicit-user
                                             elmo-nntp-default-user)
                                         (car parse)))
+    ;; network
+    (elmo-net-parse-network folder (cdr parse))
     (unless (elmo-net-folder-server-internal folder)
       (elmo-net-folder-set-server-internal folder
                                           elmo-nntp-default-server))
index e82ee97..0a7585f 100644 (file)
@@ -87,34 +87,33 @@ Debug information is inserted in the buffer \"*POP3 DEBUG*\"")
                     (use-uidl location-alist))
   (luna-define-internal-accessors 'elmo-pop3-folder))
 
-(luna-define-method elmo-folder-initialize :around ((folder
-                                                    elmo-pop3-folder)
-                                                   name)
+(luna-define-method elmo-folder-initialize ((folder elmo-pop3-folder) name)
   (let ((elmo-network-stream-type-alist
         (if elmo-pop3-stream-type-alist
             (append elmo-pop3-stream-type-alist
                     elmo-network-stream-type-alist)
           elmo-network-stream-type-alist))
        parse)
-    (setq name (luna-call-next-method))
     ;; user
-    (setq parse (elmo-parse-token name "/:"))
+    (setq parse (elmo-parse-token name "/:@"))
     (elmo-net-folder-set-user-internal folder
                                       (if (eq (length (car parse)) 0)
                                           elmo-pop3-default-user
                                         (car parse)))
     ;; auth
-    (setq parse (elmo-parse-prefixed-element ?/ (cdr parse) ":"))
+    (setq parse (elmo-parse-prefixed-element ?/ (cdr parse) ":@"))
     (elmo-net-folder-set-auth-internal folder
                                       (if (eq (length (car parse)) 0)
                                           elmo-pop3-default-authenticate-type
                                         (intern (downcase (car parse)))))
     ;; uidl
-    (setq parse (elmo-parse-prefixed-element ?: (cdr parse)))
+    (setq parse (elmo-parse-prefixed-element ?: (cdr parse) "@"))
     (elmo-pop3-folder-set-use-uidl-internal folder
                                            (if (eq (length (car parse)) 0)
                                                elmo-pop3-default-use-uidl
                                              (string= (car parse) "uidl")))
+    ;; network
+    (elmo-net-parse-network folder (cdr parse))
     (unless (elmo-net-folder-server-internal folder)
       (elmo-net-folder-set-server-internal folder
                                           elmo-pop3-default-server))
index 368c5b8..e3768c1 100644 (file)
@@ -1450,6 +1450,13 @@ ELT must be a string.  Upper-case and lower-case letters are treated as equal."
       newtext)))
 
 ;;; Folder parser utils.
+(defconst elmo-quoted-specials-list '(?\\ ?\"))
+
+(defun elmo-quoted-token (string)
+  (concat "\""
+         (std11-wrap-as-quoted-pairs string elmo-quoted-specials-list)
+         "\""))
+
 (defun elmo-parse-token (string &optional seps)
   "Parse atom from STRING using SEPS as a string of separator char list."
   (let ((len (length string))