Mercurial > emacs
annotate lisp/gnus/sieve-manage.el @ 112134:4c86fe2e7016
Use __builtin_unwind_init in MinGW builds of w32 port.
config.nt (HAVE___BUILTIN_UNWIND_INIT) [GCC >= 2.8]: Define.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Fri, 07 Jan 2011 12:16:20 +0200 |
parents | 147ba7e5851b |
children | 417b1e4d63cd |
rev | line source |
---|---|
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
1 ;;; sieve-manage.el --- Implementation of the managesive protocol in elisp |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64735
diff
changeset
|
2 |
111277
f1b7bcd27c95
Silence sieve-manage.el compilation.
Glenn Morris <rgm@gnu.org>
parents:
110918
diff
changeset
|
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, |
f1b7bcd27c95
Silence sieve-manage.el compilation.
Glenn Morris <rgm@gnu.org>
parents:
110918
diff
changeset
|
4 ;; 2010 Free Software Foundation, Inc. |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
5 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
6 ;; Author: Simon Josefsson <simon@josefsson.org> |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
7 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
9 |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94328
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
11 ;; it under the terms of the GNU General Public License as published by |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94328
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94328
diff
changeset
|
13 ;; (at your option) any later version. |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
14 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
15 ;; GNU Emacs is distributed in the hope that it will be useful, |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94328
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
18 ;; GNU General Public License for more details. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
19 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License |
94662
f42ef85caf91
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94328
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
22 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
23 ;;; Commentary: |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
24 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
25 ;; This library provides an elisp API for the managesieve network |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
26 ;; protocol. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
27 ;; |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
28 ;; It uses the SASL library for authentication, which means it |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
29 ;; supports DIGEST-MD5, CRAM-MD5, SCRAM-MD5, NTLM, PLAIN and LOGIN |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
30 ;; methods. STARTTLS is not well tested, but should be easy to get to |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
31 ;; work if someone wants. |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
32 ;; |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
33 ;; The API should be fairly obvious for anyone familiar with the |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
34 ;; managesieve protocol, interface functions include: |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
35 ;; |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
36 ;; `sieve-manage-open' |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
37 ;; open connection to managesieve server, returning a buffer to be |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
38 ;; used by all other API functions. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
39 ;; |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
40 ;; `sieve-manage-opened' |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
41 ;; check if a server is open or not |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
42 ;; |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
43 ;; `sieve-manage-close' |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
44 ;; close a server connection. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
45 ;; |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
46 ;; `sieve-manage-listscripts' |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
47 ;; `sieve-manage-deletescript' |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
48 ;; `sieve-manage-getscript' |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
49 ;; performs managesieve protocol actions |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
50 ;; |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
51 ;; and that's it. Example of a managesieve session in *scratch*: |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
52 ;; |
110793
6ab940f572a9
sieve-manage.el: Add authenticate function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110791
diff
changeset
|
53 ;; (with-current-buffer (sieve-manage-open "mail.example.com") |
6ab940f572a9
sieve-manage.el: Add authenticate function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110791
diff
changeset
|
54 ;; (sieve-manage-authenticate) |
6ab940f572a9
sieve-manage.el: Add authenticate function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110791
diff
changeset
|
55 ;; (sieve-manage-listscripts)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
56 ;; |
110793
6ab940f572a9
sieve-manage.el: Add authenticate function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110791
diff
changeset
|
57 ;; => ((active . "main") "vacation") |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
58 ;; |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
59 ;; References: |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
60 ;; |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
61 ;; draft-martin-managesieve-02.txt, |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
62 ;; "A Protocol for Remotely Managing Sieve Scripts", |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
63 ;; by Tim Martin. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
64 ;; |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
65 ;; Release history: |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
66 ;; |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
67 ;; 2001-10-31 Committed to Oort Gnus. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
68 ;; 2002-07-27 Added DELETESCRIPT. Suggested by Ned Ludd. |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
69 ;; 2002-08-03 Use SASL library. |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
70 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
71 ;;; Code: |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
72 |
110918
236342431786
nnimap.el (gnutls-negotiate): Silence the byte compiler.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110917
diff
changeset
|
73 ;; For Emacs <22.2 and XEmacs. |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
74 (eval-and-compile |
87200
ce561a765175
(declare-function): Add compatibility definition.
Glenn Morris <rgm@gnu.org>
parents:
87031
diff
changeset
|
75 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))) |
87454 | 76 |
77 (if (locate-library "password-cache") | |
78 (require 'password-cache) | |
79 (require 'password)) | |
80 | |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
81 (eval-when-compile |
111277
f1b7bcd27c95
Silence sieve-manage.el compilation.
Glenn Morris <rgm@gnu.org>
parents:
110918
diff
changeset
|
82 (require 'cl) ; caddr |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
83 (require 'sasl) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
84 (require 'starttls)) |
95820
645fb33380d6
Remove unnecessary eval-and-compile of autoloads.
Glenn Morris <rgm@gnu.org>
parents:
94662
diff
changeset
|
85 (autoload 'sasl-find-mechanism "sasl") |
645fb33380d6
Remove unnecessary eval-and-compile of autoloads.
Glenn Morris <rgm@gnu.org>
parents:
94662
diff
changeset
|
86 (autoload 'starttls-open-stream "starttls") |
110791
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
87 (autoload 'auth-source-user-or-password "auth-source") |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
88 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
89 ;; User customizable variables: |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
90 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
91 (defgroup sieve-manage nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
92 "Low-level Managesieve protocol issues." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
93 :group 'mail |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
94 :prefix "sieve-") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
95 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
96 (defcustom sieve-manage-log "*sieve-manage-log*" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
97 "Name of buffer for managesieve session trace." |
62755
0d1a48b1ca68
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-324
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
98 :type 'string |
0d1a48b1ca68
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-324
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
99 :group 'sieve-manage) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
100 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
101 (defcustom sieve-manage-server-eol "\r\n" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
102 "The EOL string sent from the server." |
62755
0d1a48b1ca68
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-324
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
103 :type 'string |
0d1a48b1ca68
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-324
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
104 :group 'sieve-manage) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
105 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
106 (defcustom sieve-manage-client-eol "\r\n" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
107 "The EOL string we send to the server." |
62755
0d1a48b1ca68
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-324
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
108 :type 'string |
0d1a48b1ca68
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-324
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
109 :group 'sieve-manage) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
110 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
111 (defcustom sieve-manage-streams '(network starttls shell) |
62755
0d1a48b1ca68
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-324
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
112 "Priority of streams to consider when opening connection to server." |
0d1a48b1ca68
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-324
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
113 :group 'sieve-manage) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
114 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
115 (defcustom sieve-manage-stream-alist |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
116 '((network sieve-manage-network-p sieve-manage-network-open) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
117 (shell sieve-manage-shell-p sieve-manage-shell-open) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
118 (starttls sieve-manage-starttls-p sieve-manage-starttls-open)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
119 "Definition of network streams. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
120 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
121 \(NAME CHECK OPEN) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
122 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
123 NAME names the stream, CHECK is a function returning non-nil if the |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
124 server support the stream and OPEN is a function for opening the |
62755
0d1a48b1ca68
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-324
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
125 stream." |
0d1a48b1ca68
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-324
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
126 :group 'sieve-manage) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
127 |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
128 (defcustom sieve-manage-authenticators '(digest-md5 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
129 cram-md5 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
130 scram-md5 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
131 ntlm |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
132 plain |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
133 login) |
62755
0d1a48b1ca68
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-324
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
134 "Priority of authenticators to consider when authenticating to server." |
0d1a48b1ca68
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-324
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
135 :group 'sieve-manage) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
136 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
137 (defcustom sieve-manage-authenticator-alist |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
138 '((cram-md5 sieve-manage-cram-md5-p sieve-manage-cram-md5-auth) |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
139 (digest-md5 sieve-manage-digest-md5-p sieve-manage-digest-md5-auth) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
140 (scram-md5 sieve-manage-scram-md5-p sieve-manage-scram-md5-auth) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
141 (ntlm sieve-manage-ntlm-p sieve-manage-ntlm-auth) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
142 (plain sieve-manage-plain-p sieve-manage-plain-auth) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
143 (login sieve-manage-login-p sieve-manage-login-auth)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
144 "Definition of authenticators. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
145 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
146 \(NAME CHECK AUTHENTICATE) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
147 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
148 NAME names the authenticator. CHECK is a function returning non-nil if |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
149 the server support the authenticator and AUTHENTICATE is a function |
62755
0d1a48b1ca68
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-324
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
150 for doing the actual authentication." |
0d1a48b1ca68
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-324
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
151 :group 'sieve-manage) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
152 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
153 (defcustom sieve-manage-default-port 2000 |
110917
3243e7055d49
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110793
diff
changeset
|
154 "Default port number or service name for managesieve protocol." |
62755
0d1a48b1ca68
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-324
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
155 :type 'integer |
0d1a48b1ca68
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-324
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
156 :group 'sieve-manage) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
157 |
110774
276ecc27ad6b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110674
diff
changeset
|
158 (defcustom sieve-manage-default-stream 'network |
276ecc27ad6b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110674
diff
changeset
|
159 "Default stream type to use for `sieve-manage'. |
276ecc27ad6b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110674
diff
changeset
|
160 Must be a name of a stream in `sieve-manage-stream-alist'." |
276ecc27ad6b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110674
diff
changeset
|
161 :type 'symbol |
276ecc27ad6b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110674
diff
changeset
|
162 :group 'sieve-manage) |
276ecc27ad6b
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110674
diff
changeset
|
163 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
164 ;; Internal variables: |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
165 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
166 (defconst sieve-manage-local-variables '(sieve-manage-server |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
167 sieve-manage-port |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
168 sieve-manage-auth |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
169 sieve-manage-stream |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
170 sieve-manage-process |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
171 sieve-manage-client-eol |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
172 sieve-manage-server-eol |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
173 sieve-manage-capability)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
174 (defconst sieve-manage-coding-system-for-read 'binary) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
175 (defconst sieve-manage-coding-system-for-write 'binary) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
176 (defvar sieve-manage-stream nil) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
177 (defvar sieve-manage-auth nil) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
178 (defvar sieve-manage-server nil) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
179 (defvar sieve-manage-port nil) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
180 (defvar sieve-manage-state 'closed |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
181 "Managesieve state. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
182 Valid states are `closed', `initial', `nonauth', and `auth'.") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
183 (defvar sieve-manage-process nil) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
184 (defvar sieve-manage-capability nil) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
185 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
186 ;; Internal utility functions |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
187 |
108287
c0d13767677a
Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
106815
diff
changeset
|
188 (defmacro sieve-manage-disable-multibyte () |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
189 "Enable multibyte in the current buffer." |
108287
c0d13767677a
Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
106815
diff
changeset
|
190 (unless (featurep 'xemacs) |
c0d13767677a
Synch with Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
106815
diff
changeset
|
191 '(set-buffer-multibyte nil))) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
192 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
193 (defun sieve-manage-erase (&optional p buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
194 (let ((buffer (or buffer (current-buffer)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
195 (and sieve-manage-log |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
196 (with-current-buffer (get-buffer-create sieve-manage-log) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
197 (sieve-manage-disable-multibyte) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
198 (buffer-disable-undo) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
199 (goto-char (point-max)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
200 (insert-buffer-substring buffer (with-current-buffer buffer |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
201 (point-min)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
202 (or p (with-current-buffer buffer |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
203 (point-max))))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
204 (delete-region (point-min) (or p (point-max)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
205 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
206 (defun sieve-manage-open-1 (buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
207 (with-current-buffer buffer |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
208 (sieve-manage-erase) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
209 (setq sieve-manage-state 'initial |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
210 sieve-manage-process |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
211 (condition-case () |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
212 (funcall (nth 2 (assq sieve-manage-stream |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
213 sieve-manage-stream-alist)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
214 "sieve" buffer sieve-manage-server sieve-manage-port) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
215 ((error quit) nil))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
216 (when sieve-manage-process |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
217 (while (and (eq sieve-manage-state 'initial) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
218 (memq (process-status sieve-manage-process) '(open run))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
219 (message "Waiting for response from %s..." sieve-manage-server) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
220 (accept-process-output sieve-manage-process 1)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
221 (message "Waiting for response from %s...done" sieve-manage-server) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
222 (and (memq (process-status sieve-manage-process) '(open run)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
223 sieve-manage-process)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
224 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
225 ;; Streams |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
226 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
227 (defun sieve-manage-network-p (buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
228 t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
229 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
230 (defun sieve-manage-network-open (name buffer server port) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
231 (let* ((port (or port sieve-manage-default-port)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
232 (coding-system-for-read sieve-manage-coding-system-for-read) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
233 (coding-system-for-write sieve-manage-coding-system-for-write) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
234 (process (open-network-stream name buffer server port))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
235 (when process |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
236 (while (and (memq (process-status process) '(open run)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
237 (set-buffer buffer) ;; XXX "blue moon" nntp.el bug |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
238 (goto-char (point-min)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
239 (not (sieve-manage-parse-greeting-1))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
240 (accept-process-output process 1) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
241 (sit-for 1)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
242 (sieve-manage-erase nil buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
243 (when (memq (process-status process) '(open run)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
244 process)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
245 |
100993 | 246 (defun sieve-manage-starttls-p (buffer) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
247 (condition-case () |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
248 (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
249 (require 'starttls) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
250 (call-process "starttls")) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
251 (error nil))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
252 |
100993 | 253 (defun sieve-manage-starttls-open (name buffer server port) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
254 (let* ((port (or port sieve-manage-default-port)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
255 (coding-system-for-read sieve-manage-coding-system-for-read) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
256 (coding-system-for-write sieve-manage-coding-system-for-write) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
257 (process (starttls-open-stream name buffer server port)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
258 done) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
259 (when process |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
260 (while (and (memq (process-status process) '(open run)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
261 (set-buffer buffer) ;; XXX "blue moon" nntp.el bug |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
262 (goto-char (point-min)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
263 (not (sieve-manage-parse-greeting-1))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
264 (accept-process-output process 1) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
265 (sit-for 1)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
266 (sieve-manage-erase nil buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
267 (sieve-manage-send "STARTTLS") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
268 (starttls-negotiate process)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
269 (when (memq (process-status process) '(open run)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
270 process))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
271 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
272 ;; Authenticators |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
273 (defun sieve-sasl-auth (buffer mech) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
274 "Login to server using the SASL MECH method." |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
275 (message "sieve: Authenticating using %s..." mech) |
110791
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
276 (with-current-buffer buffer |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
277 (let* ((user-password (auth-source-user-or-password |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
278 '("login" "password") |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
279 sieve-manage-server |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
280 "sieve" nil t)) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
281 (client (sasl-make-client (sasl-find-mechanism (list mech)) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
282 (car user-password) "sieve" sieve-manage-server)) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
283 (sasl-read-passphrase |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
284 ;; We *need* to copy the password, because sasl will modify it |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
285 ;; somehow. |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
286 `(lambda (prompt) ,(copy-sequence (cadr user-password)))) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
287 (step (sasl-next-step client nil)) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
288 (tag (sieve-manage-send |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
289 (concat |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
290 "AUTHENTICATE \"" |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
291 mech |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
292 "\"" |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
293 (and (sasl-step-data step) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
294 (concat |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
295 " \"" |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
296 (base64-encode-string |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
297 (sasl-step-data step) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
298 'no-line-break) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
299 "\""))))) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
300 data rsp) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
301 (catch 'done |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
302 (while t |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
303 (setq rsp nil) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
304 (goto-char (point-min)) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
305 (while (null (or (progn |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
306 (setq rsp (sieve-manage-is-string)) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
307 (if (not (and rsp (looking-at |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
308 sieve-manage-server-eol))) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
309 (setq rsp nil) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
310 (goto-char (match-end 0)) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
311 rsp)) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
312 (setq rsp (sieve-manage-is-okno)))) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
313 (accept-process-output sieve-manage-process 1) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
314 (goto-char (point-min))) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
315 (sieve-manage-erase) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
316 (when (sieve-manage-ok-p rsp) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
317 (when (and (cadr rsp) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
318 (string-match "^SASL \"\\([^\"]+\\)\"" (cadr rsp))) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
319 (sasl-step-set-data |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
320 step (base64-decode-string (match-string 1 (cadr rsp))))) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
321 (if (and (setq step (sasl-next-step client step)) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
322 (setq data (sasl-step-data step))) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
323 ;; We got data for server but it's finished |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
324 (error "Server not ready for SASL data: %s" data) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
325 ;; The authentication process is finished. |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
326 (throw 'done t))) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
327 (unless (stringp rsp) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
328 (error "Server aborted SASL authentication: %s" (caddr rsp))) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
329 (sasl-step-set-data step (base64-decode-string rsp)) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
330 (setq step (sasl-next-step client step)) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
331 (sieve-manage-send |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
332 (if (sasl-step-data step) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
333 (concat "\"" |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
334 (base64-encode-string (sasl-step-data step) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
335 'no-line-break) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
336 "\"") |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
337 "")))) |
5d585a964174
sieve-manage: use auth-source.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110775
diff
changeset
|
338 (message "sieve: Login using %s...done" mech)))) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
339 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
340 (defun sieve-manage-cram-md5-p (buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
341 (sieve-manage-capability "SASL" "CRAM-MD5" buffer)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
342 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
343 (defun sieve-manage-cram-md5-auth (buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
344 "Login to managesieve server using the CRAM-MD5 SASL method." |
85712
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
345 (sieve-sasl-auth buffer "CRAM-MD5")) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
346 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
347 (defun sieve-manage-digest-md5-p (buffer) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
348 (sieve-manage-capability "SASL" "DIGEST-MD5" buffer)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
349 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
350 (defun sieve-manage-digest-md5-auth (buffer) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
351 "Login to managesieve server using the DIGEST-MD5 SASL method." |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
352 (sieve-sasl-auth buffer "DIGEST-MD5")) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
353 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
354 (defun sieve-manage-scram-md5-p (buffer) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
355 (sieve-manage-capability "SASL" "SCRAM-MD5" buffer)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
356 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
357 (defun sieve-manage-scram-md5-auth (buffer) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
358 "Login to managesieve server using the SCRAM-MD5 SASL method." |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
359 (sieve-sasl-auth buffer "SCRAM-MD5")) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
360 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
361 (defun sieve-manage-ntlm-p (buffer) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
362 (sieve-manage-capability "SASL" "NTLM" buffer)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
363 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
364 (defun sieve-manage-ntlm-auth (buffer) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
365 "Login to managesieve server using the NTLM SASL method." |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
366 (sieve-sasl-auth buffer "NTLM")) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
367 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
368 (defun sieve-manage-plain-p (buffer) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
369 (sieve-manage-capability "SASL" "PLAIN" buffer)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
370 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
371 (defun sieve-manage-plain-auth (buffer) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
372 "Login to managesieve server using the PLAIN SASL method." |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
373 (sieve-sasl-auth buffer "PLAIN")) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
374 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
375 (defun sieve-manage-login-p (buffer) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
376 (sieve-manage-capability "SASL" "LOGIN" buffer)) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
377 |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
378 (defun sieve-manage-login-auth (buffer) |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
379 "Login to managesieve server using the LOGIN SASL method." |
a3c27999decb
Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents:
85034
diff
changeset
|
380 (sieve-sasl-auth buffer "LOGIN")) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
381 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
382 ;; Managesieve API |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
383 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
384 (defun sieve-manage-open (server &optional port stream auth buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
385 "Open a network connection to a managesieve SERVER (string). |
96488
a30459da1bd7
* nnimap.el (nnimap-id):
Juanma Barranquero <lekktu@gmail.com>
parents:
95820
diff
changeset
|
386 Optional argument PORT is port number (integer) on remote server. |
a30459da1bd7
* nnimap.el (nnimap-id):
Juanma Barranquero <lekktu@gmail.com>
parents:
95820
diff
changeset
|
387 Optional argument STREAM is any of `sieve-manage-streams' (a symbol). |
a30459da1bd7
* nnimap.el (nnimap-id):
Juanma Barranquero <lekktu@gmail.com>
parents:
95820
diff
changeset
|
388 Optional argument AUTH indicates authenticator to use, see |
a30459da1bd7
* nnimap.el (nnimap-id):
Juanma Barranquero <lekktu@gmail.com>
parents:
95820
diff
changeset
|
389 `sieve-manage-authenticators' for available authenticators. |
a30459da1bd7
* nnimap.el (nnimap-id):
Juanma Barranquero <lekktu@gmail.com>
parents:
95820
diff
changeset
|
390 If nil, chooses the best stream the server is capable of. |
a30459da1bd7
* nnimap.el (nnimap-id):
Juanma Barranquero <lekktu@gmail.com>
parents:
95820
diff
changeset
|
391 Optional argument BUFFER is buffer (buffer, or string naming buffer) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
392 to work in." |
112104
147ba7e5851b
* lisp/gnus/sieve-manage.el (sieve-manage-open): Correctly set sieve-manage-port.
Glenn Morris <rgm@gnu.org>
parents:
111277
diff
changeset
|
393 (or port (setq port sieve-manage-default-port)) |
147ba7e5851b
* lisp/gnus/sieve-manage.el (sieve-manage-open): Correctly set sieve-manage-port.
Glenn Morris <rgm@gnu.org>
parents:
111277
diff
changeset
|
394 (setq buffer (or buffer (format " *sieve* %s:%s" server port))) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
395 (with-current-buffer (get-buffer-create buffer) |
85034
8e5644592b67
(sieve-manage-interactive-login): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
78224
diff
changeset
|
396 (mapc 'make-local-variable sieve-manage-local-variables) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
397 (sieve-manage-disable-multibyte) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
398 (buffer-disable-undo) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
399 (setq sieve-manage-server (or server sieve-manage-server)) |
112104
147ba7e5851b
* lisp/gnus/sieve-manage.el (sieve-manage-open): Correctly set sieve-manage-port.
Glenn Morris <rgm@gnu.org>
parents:
111277
diff
changeset
|
400 (setq sieve-manage-port port) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
401 (setq sieve-manage-stream (or stream sieve-manage-stream)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
402 (message "sieve: Connecting to %s..." sieve-manage-server) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
403 (if (let ((sieve-manage-stream |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
404 (or sieve-manage-stream sieve-manage-default-stream))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
405 (sieve-manage-open-1 buffer)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
406 ;; Choose stream. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
407 (let (stream-changed) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
408 (message "sieve: Connecting to %s...done" sieve-manage-server) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
409 (when (null sieve-manage-stream) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
410 (let ((streams sieve-manage-streams)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
411 (while (setq stream (pop streams)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
412 (if (funcall (nth 1 (assq stream |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
413 sieve-manage-stream-alist)) buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
414 (setq stream-changed |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
415 (not (eq (or sieve-manage-stream |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
416 sieve-manage-default-stream) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
417 stream)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
418 sieve-manage-stream stream |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
419 streams nil))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
420 (unless sieve-manage-stream |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
421 (error "Couldn't figure out a stream for server")))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
422 (when stream-changed |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
423 (message "sieve: Reconnecting with stream `%s'..." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
424 sieve-manage-stream) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
425 (sieve-manage-close buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
426 (if (sieve-manage-open-1 buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
427 (message "sieve: Reconnecting with stream `%s'...done" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
428 sieve-manage-stream) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
429 (message "sieve: Reconnecting with stream `%s'...failed" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
430 sieve-manage-stream)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
431 (setq sieve-manage-capability nil)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
432 (if (sieve-manage-opened buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
433 ;; Choose authenticator |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
434 (when (and (null sieve-manage-auth) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
435 (not (eq sieve-manage-state 'auth))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
436 (let ((auths sieve-manage-authenticators)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
437 (while (setq auth (pop auths)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
438 (if (funcall (nth 1 (assq |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
439 auth |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
440 sieve-manage-authenticator-alist)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
441 buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
442 (setq sieve-manage-auth auth |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
443 auths nil))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
444 (unless sieve-manage-auth |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
445 (error "Couldn't figure out authenticator for server")))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
446 (message "sieve: Connecting to %s...failed" sieve-manage-server)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
447 (when (sieve-manage-opened buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
448 (sieve-manage-erase) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
449 buffer))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
450 |
110793
6ab940f572a9
sieve-manage.el: Add authenticate function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110791
diff
changeset
|
451 (defun sieve-manage-authenticate (&optional buffer) |
6ab940f572a9
sieve-manage.el: Add authenticate function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110791
diff
changeset
|
452 "Authenticate on server in BUFFER. |
6ab940f572a9
sieve-manage.el: Add authenticate function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110791
diff
changeset
|
453 Return `sieve-manage-state' value." |
6ab940f572a9
sieve-manage.el: Add authenticate function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110791
diff
changeset
|
454 (with-current-buffer (or buffer (current-buffer)) |
6ab940f572a9
sieve-manage.el: Add authenticate function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110791
diff
changeset
|
455 (if (eq sieve-manage-state 'nonauth) |
6ab940f572a9
sieve-manage.el: Add authenticate function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110791
diff
changeset
|
456 (when (funcall (nth 2 (assq sieve-manage-auth |
6ab940f572a9
sieve-manage.el: Add authenticate function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110791
diff
changeset
|
457 sieve-manage-authenticator-alist)) |
6ab940f572a9
sieve-manage.el: Add authenticate function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110791
diff
changeset
|
458 (current-buffer)) |
6ab940f572a9
sieve-manage.el: Add authenticate function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110791
diff
changeset
|
459 (setq sieve-manage-state 'auth)) |
6ab940f572a9
sieve-manage.el: Add authenticate function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110791
diff
changeset
|
460 sieve-manage-state))) |
6ab940f572a9
sieve-manage.el: Add authenticate function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110791
diff
changeset
|
461 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
462 (defun sieve-manage-opened (&optional buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
463 "Return non-nil if connection to managesieve server in BUFFER is open. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
464 If BUFFER is nil then the current buffer is used." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
465 (and (setq buffer (get-buffer (or buffer (current-buffer)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
466 (buffer-live-p buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
467 (with-current-buffer buffer |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
468 (and sieve-manage-process |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
469 (memq (process-status sieve-manage-process) '(open run)))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
470 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
471 (defun sieve-manage-close (&optional buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
472 "Close connection to managesieve server in BUFFER. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
473 If BUFFER is nil, the current buffer is used." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
474 (with-current-buffer (or buffer (current-buffer)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
475 (when (sieve-manage-opened) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
476 (sieve-manage-send "LOGOUT") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
477 (sit-for 1)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
478 (when (and sieve-manage-process |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
479 (memq (process-status sieve-manage-process) '(open run))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
480 (delete-process sieve-manage-process)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
481 (setq sieve-manage-process nil) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
482 (sieve-manage-erase) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
483 t)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
484 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
485 (defun sieve-manage-capability (&optional name value buffer) |
110775
6ae391b53988
sieve-manage.el (sieve-manage-capability): Do not bug out when the server-value of the capability is nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
486 "Check if capability NAME of server BUFFER match VALUE. |
6ae391b53988
sieve-manage.el (sieve-manage-capability): Do not bug out when the server-value of the capability is nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
487 If it does, return the server value of NAME. If not returns nil. |
6ae391b53988
sieve-manage.el (sieve-manage-capability): Do not bug out when the server-value of the capability is nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
488 If VALUE is nil, do not check VALUE and return server value. |
6ae391b53988
sieve-manage.el (sieve-manage-capability): Do not bug out when the server-value of the capability is nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
489 If NAME is nil, return the full server list of capabilities." |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
490 (with-current-buffer (or buffer (current-buffer)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
491 (if (null name) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
492 sieve-manage-capability |
110775
6ae391b53988
sieve-manage.el (sieve-manage-capability): Do not bug out when the server-value of the capability is nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
493 (let ((server-value (cadr (assoc name sieve-manage-capability)))) |
6ae391b53988
sieve-manage.el (sieve-manage-capability): Do not bug out when the server-value of the capability is nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
494 (when (or (null value) |
6ae391b53988
sieve-manage.el (sieve-manage-capability): Do not bug out when the server-value of the capability is nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
495 (and server-value |
6ae391b53988
sieve-manage.el (sieve-manage-capability): Do not bug out when the server-value of the capability is nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
496 (string-match value server-value))) |
6ae391b53988
sieve-manage.el (sieve-manage-capability): Do not bug out when the server-value of the capability is nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
110774
diff
changeset
|
497 server-value))))) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
498 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
499 (defun sieve-manage-listscripts (&optional buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
500 (with-current-buffer (or buffer (current-buffer)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
501 (sieve-manage-send "LISTSCRIPTS") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
502 (sieve-manage-parse-listscripts))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
503 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
504 (defun sieve-manage-havespace (name size &optional buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
505 (with-current-buffer (or buffer (current-buffer)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
506 (sieve-manage-send (format "HAVESPACE \"%s\" %s" name size)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
507 (sieve-manage-parse-okno))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
508 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
509 (defun sieve-manage-putscript (name content &optional buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
510 (with-current-buffer (or buffer (current-buffer)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
511 (sieve-manage-send (format "PUTSCRIPT \"%s\" {%d+}%s%s" name |
94328
742e69ab5179
(sieve-string-bytes): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93975
diff
changeset
|
512 ;; Here we assume that the coding-system will |
742e69ab5179
(sieve-string-bytes): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93975
diff
changeset
|
513 ;; replace each char with a single byte. |
742e69ab5179
(sieve-string-bytes): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93975
diff
changeset
|
514 ;; This is always the case if `content' is |
742e69ab5179
(sieve-string-bytes): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93975
diff
changeset
|
515 ;; a unibyte string. |
742e69ab5179
(sieve-string-bytes): Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93975
diff
changeset
|
516 (length content) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
517 sieve-manage-client-eol content)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
518 (sieve-manage-parse-okno))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
519 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
520 (defun sieve-manage-deletescript (name &optional buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
521 (with-current-buffer (or buffer (current-buffer)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
522 (sieve-manage-send (format "DELETESCRIPT \"%s\"" name)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
523 (sieve-manage-parse-okno))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
524 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
525 (defun sieve-manage-getscript (name output-buffer &optional buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
526 (with-current-buffer (or buffer (current-buffer)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
527 (sieve-manage-send (format "GETSCRIPT \"%s\"" name)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
528 (let ((script (sieve-manage-parse-string))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
529 (sieve-manage-parse-crlf) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
530 (with-current-buffer output-buffer |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
531 (insert script)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
532 (sieve-manage-parse-okno)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
533 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
534 (defun sieve-manage-setactive (name &optional buffer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
535 (with-current-buffer (or buffer (current-buffer)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
536 (sieve-manage-send (format "SETACTIVE \"%s\"" name)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
537 (sieve-manage-parse-okno))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
538 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
539 ;; Protocol parsing routines |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
540 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
541 (defun sieve-manage-ok-p (rsp) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
542 (string= (downcase (or (car-safe rsp) "")) "ok")) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
543 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
544 (defsubst sieve-manage-forward () |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
545 (or (eobp) (forward-char))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
546 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
547 (defun sieve-manage-is-okno () |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
548 (when (looking-at (concat |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
549 "^\\(OK\\|NO\\)\\( (\\([^)]+\\))\\)?\\( \\(.*\\)\\)?" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
550 sieve-manage-server-eol)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
551 (let ((status (match-string 1)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
552 (resp-code (match-string 3)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
553 (response (match-string 5))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
554 (when response |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
555 (goto-char (match-beginning 5)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
556 (setq response (sieve-manage-is-string))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
557 (list status resp-code response)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
558 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
559 (defun sieve-manage-parse-okno () |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
560 (let (rsp) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
561 (while (null rsp) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
562 (accept-process-output (get-buffer-process (current-buffer)) 1) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
563 (goto-char (point-min)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
564 (setq rsp (sieve-manage-is-okno))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
565 (sieve-manage-erase) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
566 rsp)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
567 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
568 (defun sieve-manage-parse-capability-1 () |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
569 "Accept a managesieve greeting." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
570 (let (str) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
571 (while (setq str (sieve-manage-is-string)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
572 (if (eq (char-after) ? ) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
573 (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
574 (sieve-manage-forward) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
575 (push (list str (sieve-manage-is-string)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
576 sieve-manage-capability)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
577 (push (list str) sieve-manage-capability)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
578 (forward-line))) |
106786
04c3b0f26a9e
* sieve-manage.el (sieve-manage-parse-capability-1): Loosely match OK response.
Jason Rumney <jasonr@gnu.org>
parents:
100993
diff
changeset
|
579 (when (re-search-forward (concat "^OK.*" sieve-manage-server-eol) nil t) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
580 (setq sieve-manage-state 'nonauth))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
581 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
582 (defalias 'sieve-manage-parse-greeting-1 'sieve-manage-parse-capability-1) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
583 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
584 (defun sieve-manage-is-string () |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
585 (cond ((looking-at "\"\\([^\"]+\\)\"") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
586 (prog1 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
587 (match-string 1) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
588 (goto-char (match-end 0)))) |
98286 | 589 ((looking-at (concat "{\\([0-9]+\\+?\\)}" sieve-manage-server-eol)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
590 (let ((pos (match-end 0)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
591 (len (string-to-number (match-string 1)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
592 (if (< (point-max) (+ pos len)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
593 nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
594 (goto-char (+ pos len)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
595 (buffer-substring pos (+ pos len))))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
596 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
597 (defun sieve-manage-parse-string () |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
598 (let (rsp) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
599 (while (null rsp) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
600 (accept-process-output (get-buffer-process (current-buffer)) 1) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
601 (goto-char (point-min)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
602 (setq rsp (sieve-manage-is-string))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
603 (sieve-manage-erase (point)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
604 rsp)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
605 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
606 (defun sieve-manage-parse-crlf () |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
607 (when (looking-at sieve-manage-server-eol) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
608 (sieve-manage-erase (match-end 0)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
609 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
610 (defun sieve-manage-parse-listscripts () |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
611 (let (tmp rsp data) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
612 (while (null rsp) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
613 (while (null (or (setq rsp (sieve-manage-is-okno)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
614 (setq tmp (sieve-manage-is-string)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
615 (accept-process-output (get-buffer-process (current-buffer)) 1) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
616 (goto-char (point-min))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
617 (when tmp |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
618 (while (not (looking-at (concat "\\( ACTIVE\\)?" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
619 sieve-manage-server-eol))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
620 (accept-process-output (get-buffer-process (current-buffer)) 1) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
621 (goto-char (point-min))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
622 (if (match-string 1) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
623 (push (cons 'active tmp) data) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
624 (push tmp data)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
625 (goto-char (match-end 0)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
626 (setq tmp nil))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
627 (sieve-manage-erase) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
628 (if (sieve-manage-ok-p rsp) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
629 data |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
630 rsp))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
631 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
632 (defun sieve-manage-send (cmdstr) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
633 (setq cmdstr (concat cmdstr sieve-manage-client-eol)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
634 (and sieve-manage-log |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
635 (with-current-buffer (get-buffer-create sieve-manage-log) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
636 (sieve-manage-disable-multibyte) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
637 (buffer-disable-undo) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
638 (goto-char (point-max)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
639 (insert cmdstr))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
640 (process-send-string sieve-manage-process cmdstr)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
641 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
642 (provide 'sieve-manage) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
643 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
diff
changeset
|
644 ;; sieve-manage.el ends here |