1 ;;; sieve-manage.el --- Implementation of the managesive protocol in elisp
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007,
4 ;; 2008, 2009 Free Software Foundation, Inc.
6 ;; Author: Simon Josefsson <simon@josefsson.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 ;; This library provides an elisp API for the managesieve network
28 ;; It uses the SASL library for authentication, which means it
29 ;; supports DIGEST-MD5, CRAM-MD5, SCRAM-MD5, NTLM, PLAIN and LOGIN
30 ;; methods. STARTTLS is not well tested, but should be easy to get to
31 ;; work if someone wants.
33 ;; The API should be fairly obvious for anyone familiar with the
34 ;; managesieve protocol, interface functions include:
36 ;; `sieve-manage-open'
37 ;; open connection to managesieve server, returning a buffer to be
38 ;; used by all other API functions.
40 ;; `sieve-manage-opened'
41 ;; check if a server is open or not
43 ;; `sieve-manage-close'
44 ;; close a server connection.
46 ;; `sieve-manage-authenticate'
47 ;; `sieve-manage-listscripts'
48 ;; `sieve-manage-deletescript'
49 ;; `sieve-manage-getscript'
50 ;; performs managesieve protocol actions
52 ;; and that's it. Example of a managesieve session in *scratch*:
54 ;; (setq my-buf (sieve-manage-open "my.server.com"))
55 ;; " *sieve* my.server.com:2000*"
57 ;; (sieve-manage-authenticate "myusername" "mypassword" my-buf)
60 ;; (sieve-manage-listscripts my-buf)
61 ;; ("vacation" "testscript" ("splitmail") "badscript")
65 ;; draft-martin-managesieve-02.txt,
66 ;; "A Protocol for Remotely Managing Sieve Scripts",
71 ;; 2001-10-31 Committed to Oort Gnus.
72 ;; 2002-07-27 Added DELETESCRIPT. Suggested by Ned Ludd.
73 ;; 2002-08-03 Use SASL library.
79 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
81 (if (locate-library "password-cache")
82 (require 'password-cache)
88 (autoload 'sasl-find-mechanism "sasl")
89 (autoload 'starttls-open-stream "starttls")
91 ;; User customizable variables:
93 (defgroup sieve-manage nil
94 "Low-level Managesieve protocol