Mercurial > emacs
annotate lisp/gnus/proto-stream.el @ 112390:1b25cd6a6e36
mm-decode.el (mm-inline-media-tests): Add text/x-sh.
gnus-art.el (gnus-mime-inline-part): Use mm-display-inline rather than mm-insert-inline to insert inline part: this respect mm-inline-media-tests displayers.
mm-view.el (mm-display-shell-script-inline): New function.
mm-decode.el (mm-inline-media-tests): Add x-shellscript and x-sh.
mm-uu.el (mm-uu-type-alist): Add org block.
(mm-uu-org-src-code-block-extract): New function.
mm-view.el (mm-display-org-inline): New function.
mm-decode.el (mm-automatic-display): Add text/org.
mailcap.el (mailcap-mime-extensions): Add .org.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Thu, 20 Jan 2011 23:43:27 +0000 |
parents | 700b890dcfb5 |
children |
rev | line source |
---|---|
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
1 ;;; proto-stream.el --- negotiating TLS, STARTTLS and other connections |
111795
5deef9141286
Standardize license notices in new files.
Glenn Morris <rgm@gnu.org>
parents:
111789
diff
changeset
|
2 |
112193
700b890dcfb5
proto-stream.el (open-protocol-stream): Protect against the low-level transport functions returning nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111884
diff
changeset
|
3 ;; Copyright (C) 2010, 2011 Free Software Foundation, Inc. |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
4 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
6 ;; Keywords: network |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
7 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
9 |
111795
5deef9141286
Standardize license notices in new files.
Glenn Morris <rgm@gnu.org>
parents:
111789
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
11 ;; it under the terms of the GNU General Public License as published by |
111795
5deef9141286
Standardize license notices in new files.
Glenn Morris <rgm@gnu.org>
parents:
111789
diff
changeset
|
12 ;; the Free Software Foundation, either version 3 of the License, or |
5deef9141286
Standardize license notices in new files.
Glenn Morris <rgm@gnu.org>
parents:
111789
diff
changeset
|
13 ;; (at your option) any later version. |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
14 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
15 ;; GNU Emacs is distributed in the hope that it will be useful, |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
111795
5deef9141286
Standardize license notices in new files.
Glenn Morris <rgm@gnu.org>
parents:
111789
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
18 ;; GNU General Public License for more details. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
19 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License |
111795
5deef9141286
Standardize license notices in new files.
Glenn Morris <rgm@gnu.org>
parents:
111789
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
22 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
23 ;;; Commentary: |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
24 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
25 ;; This library is meant to provide the glue between modules that want |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
26 ;; to establish a network connection to a server for protocols such as |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
27 ;; IMAP, NNTP, SMTP and POP3. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
28 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
29 ;; The main problem is that there's more than a couple of interfaces |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
30 ;; towards doing this. You have normal, plain connections, which are |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
31 ;; no trouble at all, but you also have TLS/SSL connections, and you |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
32 ;; have STARTTLS. Negotiating this for each protocol can be rather |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
33 ;; tedious, so this library provides a single entry point, and hides |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
34 ;; much of the ugliness. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
35 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
36 ;; Usage example: |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
37 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
38 ;; (open-protocol-stream |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
39 ;; "*nnimap*" buffer address port |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
40 ;; :type 'network |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
41 ;; :capability-command "1 CAPABILITY\r\n" |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
42 ;; :success " OK " |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
43 ;; :starttls-function |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
44 ;; (lambda (capabilities) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
45 ;; (if (not (string-match "STARTTLS" capabilities)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
46 ;; nil |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
47 ;; "1 STARTTLS\r\n"))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
48 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
49 ;;; Code: |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
50 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
51 (eval-when-compile |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
52 (require 'cl)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
53 (require 'tls) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
54 (require 'starttls) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
55 (require 'format-spec) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
56 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
57 (defcustom proto-stream-always-use-starttls (fboundp 'open-gnutls-stream) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
58 "If non-nil, always try to upgrade network connections with STARTTLS." |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
59 :version "24.1" |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
60 :type 'boolean |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
61 :group 'comm) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
62 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
63 (declare-function gnutls-negotiate "gnutls" |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
64 (proc type &optional priority-string trustfiles keyfiles)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
65 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
66 ;;;###autoload |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
67 (defun open-protocol-stream (name buffer host service &rest parameters) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
68 "Open a network stream to HOST, upgrading to STARTTLS if possible. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
69 The first four parameters have the same meaning as in |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
70 `open-network-stream'. The function returns a list where the |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
71 first element is the stream, the second element is the greeting |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
72 the server replied with after connecting, and the third element |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
73 is a string representing the capabilities of the server (if any). |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
74 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
75 The PARAMETERS is a keyword list that can have the following |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
76 values: |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
77 |
111872
a264bb877bc7
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111839
diff
changeset
|
78 :type -- either `network', `network-only, `tls', `shell' or |
a264bb877bc7
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111839
diff
changeset
|
79 `starttls'. If omitted, the default is `network'. `network' |
a264bb877bc7
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111839
diff
changeset
|
80 will be opportunistically upgraded to STARTTLS if both the server |
a264bb877bc7
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111839
diff
changeset
|
81 and Emacs supports it. If you don't want STARTTLS upgrades, use |
a264bb877bc7
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111839
diff
changeset
|
82 `network-only'. |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
83 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
84 :end-of-command -- a regexp saying what the end of a command is. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
85 This defaults to \"\\n\". |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
86 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
87 :success -- a regexp saying whether the STARTTLS command was |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
88 successful or not. For instance, for NNTP this is \"^3\". |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
89 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
90 :capability-command -- a string representing the command used to |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
91 query server for capabilities. For instance, for IMAP this is |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
92 \"1 CAPABILITY\\r\\n\". |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
93 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
94 :starttls-function -- a function that takes one parameter, which |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
95 is the response to the capaibility command. It should return nil |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
96 if it turns out that the server doesn't support STARTTLS, or the |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
97 command to switch on STARTTLS otherwise." |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
98 (let ((type (or (cadr (memq :type parameters)) 'network))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
99 (cond |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
100 ((eq type 'starttls) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
101 (setq type 'network)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
102 ((eq type 'ssl) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
103 (setq type 'tls))) |
112193
700b890dcfb5
proto-stream.el (open-protocol-stream): Protect against the low-level transport functions returning nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111884
diff
changeset
|
104 (let ((open-result |
700b890dcfb5
proto-stream.el (open-protocol-stream): Protect against the low-level transport functions returning nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111884
diff
changeset
|
105 (funcall (intern (format "proto-stream-open-%s" type) obarray) |
700b890dcfb5
proto-stream.el (open-protocol-stream): Protect against the low-level transport functions returning nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111884
diff
changeset
|
106 name buffer host service parameters))) |
700b890dcfb5
proto-stream.el (open-protocol-stream): Protect against the low-level transport functions returning nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111884
diff
changeset
|
107 (if (null open-result) |
700b890dcfb5
proto-stream.el (open-protocol-stream): Protect against the low-level transport functions returning nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111884
diff
changeset
|
108 (list nil nil nil) |
700b890dcfb5
proto-stream.el (open-protocol-stream): Protect against the low-level transport functions returning nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111884
diff
changeset
|
109 (destructuring-bind (stream greeting capabilities) open-result |
700b890dcfb5
proto-stream.el (open-protocol-stream): Protect against the low-level transport functions returning nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111884
diff
changeset
|
110 (list (and stream |
700b890dcfb5
proto-stream.el (open-protocol-stream): Protect against the low-level transport functions returning nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111884
diff
changeset
|
111 (memq (process-status stream) |
700b890dcfb5
proto-stream.el (open-protocol-stream): Protect against the low-level transport functions returning nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111884
diff
changeset
|
112 '(open run)) |
700b890dcfb5
proto-stream.el (open-protocol-stream): Protect against the low-level transport functions returning nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111884
diff
changeset
|
113 stream) |
700b890dcfb5
proto-stream.el (open-protocol-stream): Protect against the low-level transport functions returning nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111884
diff
changeset
|
114 greeting capabilities)))))) |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
115 |
111872
a264bb877bc7
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111839
diff
changeset
|
116 (defun proto-stream-open-network-only (name buffer host service parameters) |
111884
9b5cce10c8e2
proto-stream.el (proto-stream-open-network-only): Fix the calling convention of the network-only option.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111872
diff
changeset
|
117 (let ((start (with-current-buffer buffer (point))) |
9b5cce10c8e2
proto-stream.el (proto-stream-open-network-only): Fix the calling convention of the network-only option.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111872
diff
changeset
|
118 (stream (open-network-stream name buffer host service))) |
9b5cce10c8e2
proto-stream.el (proto-stream-open-network-only): Fix the calling convention of the network-only option.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111872
diff
changeset
|
119 (list stream |
9b5cce10c8e2
proto-stream.el (proto-stream-open-network-only): Fix the calling convention of the network-only option.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111872
diff
changeset
|
120 (proto-stream-get-response |
9b5cce10c8e2
proto-stream.el (proto-stream-open-network-only): Fix the calling convention of the network-only option.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111872
diff
changeset
|
121 stream start (proto-stream-eoc parameters)) |
9b5cce10c8e2
proto-stream.el (proto-stream-open-network-only): Fix the calling convention of the network-only option.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111872
diff
changeset
|
122 nil))) |
111872
a264bb877bc7
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111839
diff
changeset
|
123 |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
124 (defun proto-stream-open-network (name buffer host service parameters) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
125 (let* ((start (with-current-buffer buffer (point))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
126 (stream (open-network-stream name buffer host service)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
127 (capability-command (cadr (memq :capability-command parameters))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
128 (eoc (proto-stream-eoc parameters)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
129 (type (cadr (memq :type parameters))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
130 (greeting (proto-stream-get-response stream start eoc)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
131 success) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
132 (if (not capability-command) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
133 (list stream greeting nil) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
134 (let* ((capabilities |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
135 (proto-stream-command stream capability-command eoc)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
136 (starttls-command |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
137 (funcall (cadr (memq :starttls-function parameters)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
138 capabilities))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
139 (cond |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
140 ;; If this server doesn't support STARTTLS, but we have |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
141 ;; requested it explicitly, then close the connection and |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
142 ;; return nil. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
143 ((or (not starttls-command) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
144 (and (not (eq type 'starttls)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
145 (not proto-stream-always-use-starttls))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
146 (if (eq type 'starttls) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
147 (progn |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
148 (delete-process stream) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
149 nil) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
150 ;; Otherwise, just return this plain network connection. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
151 (list stream greeting capabilities))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
152 ;; We have some kind of STARTTLS support, so we try to |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
153 ;; upgrade the connection opportunistically. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
154 ((or (fboundp 'open-gnutls-stream) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
155 (executable-find "gnutls-cli")) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
156 (unless (fboundp 'open-gnutls-stream) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
157 (delete-process stream) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
158 (setq start (with-current-buffer buffer (point-max))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
159 (let* ((starttls-use-gnutls t) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
160 (starttls-extra-arguments |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
161 (if (not (eq type 'starttls)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
162 ;; When doing opportunistic TLS upgrades we |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
163 ;; don't really care about the identity of the |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
164 ;; peer. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
165 (cons "--insecure" starttls-extra-arguments) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
166 starttls-extra-arguments))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
167 (setq stream (starttls-open-stream name buffer host service))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
168 (proto-stream-get-response stream start eoc)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
169 (if (not |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
170 (string-match |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
171 (cadr (memq :success parameters)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
172 (proto-stream-command stream starttls-command eoc))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
173 ;; We got an error back from the STARTTLS command. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
174 (progn |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
175 (if (eq type 'starttls) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
176 (progn |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
177 (delete-process stream) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
178 nil) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
179 (list stream greeting capabilities))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
180 ;; The server said it was OK to start doing STARTTLS negotiations. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
181 (if (fboundp 'open-gnutls-stream) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
182 (gnutls-negotiate stream nil) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
183 (unless (starttls-negotiate stream) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
184 (delete-process stream) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
185 (setq stream nil))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
186 (when (or (null stream) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
187 (not (memq (process-status stream) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
188 '(open run)))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
189 ;; It didn't successfully negotiate STARTTLS, so we reopen |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
190 ;; the connection. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
191 (setq stream (open-network-stream name buffer host service)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
192 (proto-stream-get-response stream start eoc)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
193 ;; Re-get the capabilities, since they may have changed |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
194 ;; after switching to TLS. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
195 (list stream greeting |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
196 (proto-stream-command stream capability-command eoc)))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
197 ;; We don't have STARTTLS support available, but the caller |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
198 ;; requested a STARTTLS connection, so we give up. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
199 ((eq (cadr (memq :type parameters)) 'starttls) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
200 (delete-process stream) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
201 nil) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
202 ;; Fall back on using a plain network stream. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
203 (t |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
204 (list stream greeting capabilities))))))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
205 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
206 (defun proto-stream-command (stream command eoc) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
207 (let ((start (with-current-buffer (process-buffer stream) (point-max)))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
208 (process-send-string stream command) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
209 (proto-stream-get-response stream start eoc))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
210 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
211 (defun proto-stream-get-response (stream start end-of-command) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
212 (with-current-buffer (process-buffer stream) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
213 (save-excursion |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
214 (goto-char start) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
215 (while (and (memq (process-status stream) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
216 '(open run)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
217 (not (re-search-forward end-of-command nil t))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
218 (accept-process-output stream 0 50) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
219 (goto-char start)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
220 (if (= start (point)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
221 ;; The process died; return nil. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
222 nil |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
223 ;; Return the data we got back. |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
224 (buffer-substring start (point)))))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
225 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
226 (defun proto-stream-open-tls (name buffer host service parameters) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
227 (with-current-buffer buffer |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
228 (let ((start (point-max)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
229 (stream |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
230 (funcall (if (fboundp 'open-gnutls-stream) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
231 'open-gnutls-stream |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
232 'open-tls-stream) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
233 name buffer host service))) |
111839
833427a2cdd5
proto-stream.el (proto-stream-open-tls): Return nil if we don't get any stream.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111795
diff
changeset
|
234 (if (null stream) |
833427a2cdd5
proto-stream.el (proto-stream-open-tls): Return nil if we don't get any stream.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111795
diff
changeset
|
235 nil |
833427a2cdd5
proto-stream.el (proto-stream-open-tls): Return nil if we don't get any stream.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111795
diff
changeset
|
236 ;; If we're using tls.el, we have to delete the output from |
833427a2cdd5
proto-stream.el (proto-stream-open-tls): Return nil if we don't get any stream.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111795
diff
changeset
|
237 ;; openssl/gnutls-cli. |
833427a2cdd5
proto-stream.el (proto-stream-open-tls): Return nil if we don't get any stream.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111795
diff
changeset
|
238 (unless (fboundp 'open-gnutls-stream) |
833427a2cdd5
proto-stream.el (proto-stream-open-tls): Return nil if we don't get any stream.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111795
diff
changeset
|
239 (proto-stream-get-response |
833427a2cdd5
proto-stream.el (proto-stream-open-tls): Return nil if we don't get any stream.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111795
diff
changeset
|
240 stream start (proto-stream-eoc parameters)) |
833427a2cdd5
proto-stream.el (proto-stream-open-tls): Return nil if we don't get any stream.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111795
diff
changeset
|
241 (goto-char (point-min)) |
833427a2cdd5
proto-stream.el (proto-stream-open-tls): Return nil if we don't get any stream.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111795
diff
changeset
|
242 (when (re-search-forward (proto-stream-eoc parameters) nil t) |
833427a2cdd5
proto-stream.el (proto-stream-open-tls): Return nil if we don't get any stream.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111795
diff
changeset
|
243 (goto-char (match-beginning 0)) |
833427a2cdd5
proto-stream.el (proto-stream-open-tls): Return nil if we don't get any stream.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111795
diff
changeset
|
244 (delete-region (point-min) (line-beginning-position)))) |
833427a2cdd5
proto-stream.el (proto-stream-open-tls): Return nil if we don't get any stream.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
111795
diff
changeset
|
245 (proto-stream-capability-open start stream parameters))))) |
111789
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
246 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
247 (defun proto-stream-open-shell (name buffer host service parameters) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
248 (proto-stream-capability-open |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
249 (with-current-buffer buffer (point)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
250 (let ((process-connection-type nil)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
251 (start-process name buffer shell-file-name |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
252 shell-command-switch |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
253 (format-spec |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
254 (cadr (memq :shell-command parameters)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
255 (format-spec-make |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
256 ?s host |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
257 ?p service)))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
258 parameters)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
259 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
260 (defun proto-stream-capability-open (start stream parameters) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
261 (let ((capability-command (cadr (memq :capability-command parameters))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
262 (greeting (proto-stream-get-response |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
263 stream start (proto-stream-eoc parameters)))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
264 (list stream greeting |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
265 (and capability-command |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
266 (proto-stream-command |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
267 stream capability-command (proto-stream-eoc parameters)))))) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
268 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
269 (defun proto-stream-eoc (parameters) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
270 (or (cadr (memq :end-of-command parameters)) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
271 "\r\n")) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
272 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
273 (provide 'proto-stream) |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
274 |
f97704487fb3
Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff
changeset
|
275 ;;; proto-stream.el ends here |