[mew-int 2233] Re: Mew + imtest
Richard Levitte - VMS Whacker
richard at example.com
Thu Nov 23 23:53:39 JST 2006
In message <20061120.003601.74746592.haba at example.com> on Mon, 20 Nov 2006 00:36:01 +0100 (MET), Harald Barth <haba at example.com> said:
haba> Then my friend modified mew to use imtest with PREAUTH. I think our
haba> patch of mew-imap.el is OK, because we can list the contents on the
haba> IMAP server. But it works not to copy mail _to_ the imap server ("li"
haba> command), which means that our patch to mew-imap2.el is not correct. I
haba> think we did something wrong in the filter function. There might be
haba> even more places that need patching. Ehm, I don't even know why there
haba> is mew-imap and mew-imap2. So naturally, we hope you can fix the rest
haba> ;-) ;-)
haba>
haba> Harald (and Richard).
I'm that friend. I just went through a few hours of testing of
mew-imap2.el (well, actually, I just tested copying a message using
'l i' over and over until I got it working) and eliminated a few
stupid bugs, and also cleared the somewhat odd situation when status i
NIL (I can't figure out why that happens, for now).
The new patch is attached (I'm sorry, I don't have Harald's discretion
about attachments, but on the other hand, it's pretty small), and
replaces the patch that Harald pointed at entirely. It also holds all
my comments as debian/changelog, which can of course be entirely
ignored if it fails in the patch, but may be interesting otherwise.
Cheers,
Richard
-----
Please consider sponsoring my work on free software.
See http://www.free.lp.se/sponsoring.html for details.
--
Richard Levitte richard at example.com
http://richard.levitte.org/
"When I became a man I put away childish things, including
the fear of childishness and the desire to be very grown up."
-- C.S. Lewis
-------------- next part --------------
#
# old_revision [baaf6f4e29b3b898326fa0a4e5a9514ef6899bec]
#
# patch "debian/changelog"
# from [09bce08f6dd0297a84c87f7401083739a032992c]
# to [2435308d8f6840183209835e7d13db11a4b53721]
#
# patch "mew-config.el"
# from [262980f6a0caa2188acf8acadf106d13502719a0]
# to [ff2cb1379a390bfa8eedab225eda7cf7192b9e25]
#
# patch "mew-imap.el"
# from [09ff2c91f3af917dcacdd4731256342fd050a9e5]
# to [843bc90ffe0b767ee26a213a973169f181e260f1]
#
# patch "mew-imap2.el"
# from [9d373e0e1e717302d3cdcf205c5e1d271ac71090]
# to [52285a27378e6bc690c4103a36b01d1079f8988e]
#
# patch "mew-vars.el"
# from [16d7071c8381f8300a8d77a4792505c6a7ed632d]
# to [823667b31549fafacacda2c50f0dd8b166a22c4f]
#
# patch "mew-vars2.el"
# from [36a7c113276fc8e125bdeb4fb3e7c2678f62511c]
# to [7650079db047a2ee9cb6ba77e922a67ebc73ffb6]
#
============================================================
--- debian/changelog 09bce08f6dd0297a84c87f7401083739a032992c
+++ debian/changelog 2435308d8f6840183209835e7d13db11a4b53721
@@ -1,3 +1,37 @@
+mew-beta (5.1.52~0.20061031-1+RL20061123-1) unstable; urgency=low
+
+ * Changes in mew-imap2.el:
+
+ - MATCH-STRING should be called with the string as second argument
+ when the last match was done with STRING-MATCH.
+ - MEW-IMAP2-PROCESS-UP needs an argument that I forgot.
+ - There are some cases where MEW-IMAP2-DEBUG gets a NIL label, make
+ sure to handle that, as well as all the places where UPCASE is
+ used. This is really just cover-up, and I should really try to
+ figure out why there's a NIL status at times, but I can honestly
+ not be arsed right now...
+
+ -- Richard Levitte <richard at example.com> Thu, 23 Nov 2006 15:46:25 +0100
+
+mew-beta (5.1.52~0.20061031-1+RL20061118-2) unstable; urgency=low
+
+ * Apply the changes done to mew-imap.el to mew-imap2.el.
+
+ -- Richard Levitte <richard at example.com> Sat, 18 Nov 2006 23:05:26 +0100
+
+mew-beta (5.1.52~0.20061031-1+RL20061118-1) unstable; urgency=low
+
+ * Introduce the possiblity to use an external program such as imtest as
+ imap proxy.
+
+ -- Richard Levitte <richard at example.com> Sat, 18 Nov 2006 16:00:41 +0100
+
+mew-beta (5.1.52~0.20061031-1+RL20061117-1) unstable; urgency=low
+
+ * Hack mew-imap.el so it understands the PREAUTH greeting.
+
+ -- Richard Levitte <richard at example.com> Fri, 17 Nov 2006 16:02:50 +0100
+
mew-beta (5.1.52~0.20061031-1) unstable; urgency=low
* New upstream release. (CVS trunk on 2006-10-31)
============================================================
--- mew-config.el 262980f6a0caa2188acf8acadf106d13502719a0
+++ mew-config.el ff2cb1379a390bfa8eedab225eda7cf7192b9e25
@@ -282,6 +282,12 @@
(defun mew-imap-proxy-port (&optional case)
(mew-cfent-value case "imap-proxy-port" mew-imap-proxy-port))
+(defun mew-imap-prog (&optional case)
+ (mew-cfent-value case "imap-prog" mew-imap-prog))
+
+(defun mew-imap-prog-args (&optional case)
+ (mew-cfent-value case "imap-prog-args" mew-imap-prog-args))
+
(defun mew-imap-user (&optional case)
(mew-cfent-value case "imap-user" mew-imap-user))
============================================================
--- mew-imap.el 09ff2c91f3af917dcacdd4731256342fd050a9e5
+++ mew-imap.el 843bc90ffe0b767ee26a213a973169f181e260f1
@@ -48,7 +48,7 @@
;;;
(defvar mew-imap-fsm
- '(("greeting" ("OK" . "capability"))
+ '(("greeting" ("OK" . "capability") ("PREAUTH" . "next"))
("capability" ("OK" . "post-capability"))
("auth-cram-md5" ("OK" . "pwd-cram-md5") ("NO" . "wpwd"))
("pwd-cram-md5" ("OK" . "next") ("NO" . "wpwd"))
@@ -932,18 +932,23 @@
(defsubst mew-imap-buffer-name (pnm)
(concat mew-buffer-prefix pnm))
+(defun mew-imap-process-up (pro)
+ (and (processp pro)
+ (or (eq (process-status pro) 'open)
+ (eq (process-status pro) 'run))))
+
(defun mew-imap-process-send-string (pro pnm &rest args)
(let ((str (apply 'format args))
(tag (mew-imap-tag)))
(mew-imap-debug "=SEND=" (concat tag " " str))
(mew-imap-set-tag pnm tag)
- (if (and (processp pro) (eq (process-status pro) 'open))
+ (if (mew-imap-process-up pro)
(process-send-string pro (concat tag " " str mew-cs-eol))
(message "IMAP time out"))))
(defun mew-imap-process-send-string2 (pro &rest args)
(let ((str (apply 'format args)))
- (if (and (processp pro) (eq (process-status pro) 'open))
+ (if (mew-imap-process-up pro)
(process-send-string pro (concat str mew-cs-eol))
(message "IMAP time out"))))
@@ -974,7 +979,7 @@
(or (mew-imap-get-passwd pnm) ;; mew-imap-biff
(mew-input-passwd prompt tag)) ;; mew-imap-check
(setq pass (mew-input-passwd prompt tag))
- (unless (and (processp pro) (eq (process-status pro) 'open))
+ (unless (mew-imap-process-up pro)
(mew-passwd-set-passwd tag nil))
pass)))
@@ -1128,13 +1133,20 @@
;;;
(defun mew-imap-open (pnm server port no-msg)
- (let ((sprt (mew-port-sanity-check port))
- pro tm)
+ (let* ((sprt (mew-port-sanity-check port))
+ (case (mew-sinfo-get-case))
+ (prog (mew-imap-prog case))
+ (prog-args (mew-imap-prog-args case))
+ pro tm)
(condition-case emsg
(progn
(setq tm (run-at-time mew-imap-timeout-time nil 'mew-imap-timeout))
(or no-msg (message "Connecting to the IMAP server..."))
- (setq pro (open-network-stream pnm nil server sprt))
+ (setq pro
+ (if prog
+ (let ((process-connection-type nil)) ; Use a pipe
+ (apply (function start-process) pnm nil prog prog-args))
+ (open-network-stream pnm nil server sprt)))
(process-kill-without-query pro)
(mew-set-process-cs pro mew-cs-binary mew-cs-text-for-net)
(or no-msg (message "Connecting to the IMAP server...done")))
@@ -1354,10 +1366,10 @@
(setq stay t)
(delete-region (1+ bytes) (point-max))
(setq next (mew-imap-fsm-next status "OK")))))
- ((and (goto-char (point-max)) (= (forward-line -1) 0) (looking-at "^\\*"))
+ ((and (goto-char (point-max)) (= (forward-line -1) 0) (looking-at "^\\* \\(\\w+\\) "))
;; untagged message
(if (string= status "greeting")
- (setq next (mew-imap-fsm-next "greeting" "OK"))
+ (setq next (mew-imap-fsm-next "greeting" (match-string 1)))
(setq stay t)))
((and (goto-char (point-min)) (looking-at "\\+"))
(setq next (mew-imap-fsm-next status "OK")))
============================================================
--- mew-imap2.el 9d373e0e1e717302d3cdcf205c5e1d271ac71090
+++ mew-imap2.el 52285a27378e6bc690c4103a36b01d1079f8988e
@@ -35,7 +35,7 @@
;;;
(defvar mew-imap2-fsm
- '(("greeting" ("OK" . "capability"))
+ '(("greeting" ("OK" . "capability") ("PREAUTH" . "next"))
("capability" ("OK" . "post-capability"))
("auth-cram-md5" ("OK" . "pwd-cram-md5") ("NO" . "wpwd"))
("pwd-cram-md5" ("OK" . "next") ("NO" . "wpwd"))
@@ -228,7 +228,7 @@
(defun mew-imap2-command-logout2 (pro pnm)
;; error is set
(mew-imap2-set-done pnm t)
- (when (and (processp pro) (eq (process-status pro) 'open))
+ (when (mew-imap2-process-up pro)
(mew-imap2-set-status pnm "logout")
(mew-imap2-process-send-string pro pnm "LOGOUT")))
@@ -301,18 +301,23 @@
(defsubst mew-imap2-buffer-name (pnm)
(concat mew-buffer-prefix pnm))
+(defun mew-imap2-process-up (pro)
+ (and (processp pro)
+ (or (eq (process-status pro) 'open)
+ (eq (process-status pro) 'run))))
+
(defun mew-imap2-process-send-string (pro pnm &rest args)
(let ((str (apply 'format args))
(tag (mew-imap2-tag)))
(mew-imap2-debug "=SEND=" (concat tag " " str))
(mew-imap2-set-tag pnm tag)
- (if (and (processp pro) (eq (process-status pro) 'open))
+ (if (mew-imap2-process-up pro)
(process-send-string pro (concat tag " " str mew-cs-eol))
(message "IMAP time out"))))
(defun mew-imap2-process-send-string2 (pro &rest args)
(let ((str (apply 'format args)))
- (if (and (processp pro) (eq (process-status pro) 'open))
+ (if (mew-imap2-process-up pro)
(process-send-string pro (concat str mew-cs-eol))
(message "IMAP time out"))))
@@ -335,7 +340,7 @@
(let* ((tag (mew-imap2-passtag pnm))
(pro (mew-imap2-get-process pnm))
(pass (mew-input-passwd prompt tag)))
- (unless (and (processp pro) (eq (process-status pro) 'open))
+ (unless (mew-imap2-process-up pro)
(mew-passwd-set-passwd tag nil))
pass))
@@ -362,13 +367,20 @@
;;;
(defun mew-imap2-open (pnm server port)
- (let ((sprt (mew-port-sanity-check port))
- pro tm)
+ (let* ((sprt (mew-port-sanity-check port))
+ (case mew-case)
+ (prog (mew-imap-prog case))
+ (prog-args (mew-imap-prog-args case))
+ pro tm)
(condition-case emsg
(progn
(setq tm (run-at-time mew-imap-timeout-time nil 'mew-imap2-timeout))
(message "Connecting to the IMAP server...")
- (setq pro (open-network-stream pnm nil server sprt))
+ (setq pro
+ (if prog
+ (let ((process-connection-type nil)) ; Use a pipe
+ (apply (function start-process) pnm nil prog prog-args))
+ (open-network-stream pnm nil server sprt)))
(process-kill-without-query pro)
(mew-set-process-cs pro mew-cs-text-for-net mew-cs-text-for-net)
(message "Connecting to the IMAP server...done"))
@@ -530,7 +542,7 @@ with '*' in the region are handled."
(save-excursion
(set-buffer (get-buffer-create mew-buffer-debug))
(goto-char (point-max))
- (insert (format "\n<%s>\n%s\n" label string)))))
+ (insert (format "\n<%s>\n%s\n" (or label "{nil}") string)))))
(defun mew-imap2-filter (process string)
(let* ((pnm (process-name process))
@@ -540,14 +552,15 @@ with '*' in the region are handled."
(str (concat (mew-imap2-get-string pnm) string))
(buf (process-buffer process))
aux stay next func code resp)
- (mew-imap2-debug (upcase status) string)
+ (mew-imap2-debug (and status (upcase status)) string)
(if (and buf (get-buffer buf)) (set-buffer buf))
(while (string-match "^\\*[^\n]*\n" str)
(setq aux (substring str 0 (match-end 0)))
(setq str (substring str (match-end 0)))
(cond
((string= status "greeting")
- (setq next (mew-imap2-fsm-next "greeting" "OK")))
+ (string-match "^\\* \\(\\w+\\) " aux)
+ (setq next (mew-imap2-fsm-next "greeting" (match-string 1 aux))))
((string= status "capability")
(mew-imap2-set-aux pnm (concat (mew-imap2-get-aux pnm) aux)))))
(mew-imap2-set-string pnm str)
============================================================
--- mew-vars.el 16d7071c8381f8300a8d77a4792505c6a7ed632d
+++ mew-vars.el 823667b31549fafacacda2c50f0dd8b166a22c4f
@@ -865,6 +865,16 @@ Mail/inbox.
:group 'mew-imap
:type '(choice string (const nil)))
+(defcustom mew-imap-prog nil
+ "*Proxy program to use instead of connecting directly. Useful to run imtest."
+ :group 'mew-imap
+ :type '(choice string (const nil)))
+
+(defcustom mew-imap-prog-args nil
+ "*List of arguments for the program named by MEW-IMAP-PROG."
+ :group 'mew-imap
+ :type '(choice string (const nil)))
+
(defvar mew-imap-timeout-time 4)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
============================================================
--- mew-vars2.el 36a7c113276fc8e125bdeb4fb3e7c2678f62511c
+++ mew-vars2.el 7650079db047a2ee9cb6ba77e922a67ebc73ffb6
@@ -920,6 +920,7 @@ Currently, the following keys are suppor
\"imap-size\", \"imap-header-only\", \"imap-delete\",
\"imap-trash-folder\", \"imap-queue-folder\", \"imap-spam-field\", \"imap-spam-word\",
\"imap-proxy-server\", \"imap-proxy-port\",
+\"imap-prog\", \"imap-prog-args\",
\"nntp-server\", \"nntp-port\", \"nntp-ssh-server\", \"nntp-ssl\", \"nntp-ssl-port\",
\"nntp-user\", \"nntp-size\", \"nntp-header-only\",
\"nntp-msgid-user\", \"nntp-msgid-domain\",
More information about the Mew-int
mailing list