annotate lisp/net/tls.el @ 83167:69ebc75cb461

Implemented display ids for multiple emacsclients on the same tty. Plus assorted bugfixes. * lisp/frame.el (make-frame-on-display): Update doc. (make-frame): Handle display-id parameter. Update doc. (frames-on-display-list): Update for display ids. (framep-on-display): Ditto. (suspend-frame): Use display-name, not frame-tty-name. (selected-display): New function. * lisp/server.el (server-delete-client): Use delete-display, not delete-tty. (server-tty-live-p, server-handle-delete-tty): Removed. (server-handle-delete-frame): Delete tty clients, if needed. (server-process-filter): Set the display parameter, and use it when appropriate. (server-handle-suspend-tty): Use the display parameter. (server-start, server-unload-hook): Removed obsolete delete-tty hook. * lisp/talk.el (talk): Always use talk-add-display. (talk-add-tty-frame, talk-handle-delete-tty): Removed. (talk-handle-delete-frame): New function. (talk-add-display): Open a new frame only if parameter was not a frame. * src/dispextern.h (get_display, Fdisplay_tty_type): New prototypes. (Fframe_tty_type): Removed. * src/dispnew.c (init_display): Use Fdisplay_tty_type, not Fframe_tty_type. * src/frame.c (Qdisplay_id, Qdisplay_live_p): New symbols. (make_terminal_frame): Get display as a parameter. (Fmake_terminal_frame): Get/create display here; pass it to make_terminal_frame. (Fframe_display): New function. (Fdelete_frame): Stop if the hook deleted the frame. (syms_of_frame): Register new stuff. * src/frame.h (Qdisplay_id, Qdisplay_live_p, make_terminal_frame): Updated prototypes. * src/keyboard.c (interrupt_signal): Updated comment. * src/term.c (Vdelete_tty_after_functions): Removed variable. (Qframe_tty_name, Qframe_tty_type): Removed. (next_display_id): New var. (tty_ring_bell): Don't do anything on suspended frames. (Ftty_display_color_p, Ftty_display_color_cells): Doc update. (get_display): New function. (get_tty_display): Use it. (get_named_tty_display): Ignore suspended displays. (Fframe_tty_name): Renamed to Fdisplay_name. Handle all kinds of displays. (Fframe_tty_type): Renamed to Fdisplay_tty_type. (init_initial_display): Set display name. (term_init): Allow more displays on the same device. Set display name. (Fdelete_tty): Removed. (delete_tty): Don't run hooks. (create_display): Set display id. (delete_display): Free display name. (Fdelete_display, Fdisplay_live_p, Fdisplay_list): New functions. (Fsuspend_tty): Call hook with display id. Doc update. (Fresume_tty): Refuse to resume when there is already an active display on the same device. Call hook with display id. Doc update. (syms_of_term): Reflect above changes. * src/termhooks.h (struct display): Added `id' and `name' members. (DISPLAY_ACTIVE_P): New macro. * src/xfns.c (check_x_display_info): Handle display ids. (Fx_create_frame): Try to get display from `display-id' parameter. * src/xterm.c (x_term_init): Set display name. (x_delete_display): Handle the case when `font_table' is NULL. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-207
author Karoly Lorentey <lorentey@elte.hu>
date Sun, 04 Jul 2004 04:48:55 +0000
parents 695cf19ef79e
children 55fd4f77387a 375f2633d815
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
50313
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
1 ;;; tls.el --- TLS/SSL support via wrapper around GnuTLS
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
2
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
3 ;; Copyright (C) 2003 Free Software Foundation, Inc.
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
4
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
5 ;; Author: Simon Josefsson <simon@josefsson.org>
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
6 ;; Keywords: comm, tls, gnutls, ssl
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
7
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
9
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
13 ;; any later version.
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
14
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
18 ;; GNU General Public License for more details.
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
19
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
24
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
25 ;;; Commentary:
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
26
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
27 ;; This package implements a simple wrapper around "gnutls-cli" to
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
28 ;; make Emacs support TLS/SSL.
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
29 ;;
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
30 ;; Usage is the same as `open-network-stream', i.e.:
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
31 ;;
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
32 ;; (setq tmp (open-tls-stream "test" (current-buffer) "news.mozilla.org" 563))
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
33 ;; ...
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
34 ;; #<process test>
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
35 ;; (process-send-string tmp "mode reader\n")
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
36 ;; 200 secnews.netscape.com Netscape-Collabra/3.52 03615 NNRP ready ...
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
37 ;; nil
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
38 ;; (process-send-string tmp "quit\n")
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
39 ;; 205
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
40 ;; nil
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
41
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
42 ;; To use this package as a replacement for ssl.el by William M. Perry
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
43 ;; <wmperry@cs.indiana.edu>, you need to evaluate the following:
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
44 ;;
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
45 ;; (defalias 'open-ssl-stream 'open-tls-stream)
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
46
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
47 ;;; Code:
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
48
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
49 (eval-and-compile
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
50 (autoload 'format-spec "format-spec")
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
51 (autoload 'format-spec-make "format-spec"))
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
52
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
53 (defgroup tls nil
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
54 "Transport Layer Security (TLS) parameters."
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
55 :group 'comm)
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
56
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
57 (defcustom tls-program '("gnutls-cli -p %p %h"
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
58 "gnutls-cli -p %p %h --protocols ssl3")
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
59 "List of strings containing commands to start TLS stream to a host.
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
60 Each entry in the list is tried until a connection is successful.
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
61 %s is replaced with server hostname, %p with port to connect to.
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
62 The program should read input on stdin and write output to
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
63 stdout. Also see `tls-success' for what the program should output
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
64 after successful negotiation."
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
65 :type '(repeat string)
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
66 :group 'tls)
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
67
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
68 (defcustom tls-process-connection-type nil
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
69 "*Value for `process-connection-type' to use when starting process."
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
70 :type 'boolean
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
71 :group 'tls)
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
72
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
73 (defcustom tls-success "- Handshake was completed"
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
74 "*Regular expression indicating completed TLS handshakes.
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
75 The default is what GNUTLS's \"gnutls-cli\" outputs."
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
76 :type 'regexp
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
77 :group 'tls)
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
78
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
79 (defun open-tls-stream (name buffer host service)
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
80 "Open a TLS connection for a service to a host.
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
81 Returns a subprocess-object to represent the connection.
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
82 Input and output work as for subprocesses; `delete-process' closes it.
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
83 Args are NAME BUFFER HOST SERVICE.
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
84 NAME is name for process. It is modified if necessary to make it unique.
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
85 BUFFER is the buffer (or buffer-name) to associate with the process.
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
86 Process output goes at end of that buffer, unless you specify
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
87 an output stream or filter function to handle the output.
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
88 BUFFER may be also nil, meaning that this process is not associated
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
89 with any buffer
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
90 Third arg is name of the host to connect to, or its IP address.
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
91 Fourth arg SERVICE is name of the service desired, or an integer
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
92 specifying a port number to connect to."
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
93 (let ((cmds tls-program) cmd done)
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
94 (message "Opening TLS connection to `%s'..." host)
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
95 (while (and (not done) (setq cmd (pop cmds)))
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
96 (message "Opening TLS connection with `%s'..." cmd)
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
97 (let* ((process-connection-type tls-process-connection-type)
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
98 (process (start-process
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
99 name buffer shell-file-name shell-command-switch
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
100 (format-spec
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
101 cmd
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
102 (format-spec-make
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
103 ?h host
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
104 ?p (if (integerp service)
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
105 (int-to-string service)
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
106 service)))))
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
107 response)
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
108 (while (and process
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
109 (memq (process-status process) '(open run))
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
110 (save-excursion
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
111 (set-buffer buffer) ;; XXX "blue moon" nntp.el bug
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
112 (goto-char (point-min))
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
113 (not (setq done (re-search-forward tls-success nil t)))))
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
114 (accept-process-output process 1)
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
115 (sit-for 1))
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
116 (message "Opening TLS connection with `%s'...%s" cmd
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
117 (if done "done" "failed"))
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
118 (if done
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
119 (setq done process)
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
120 (delete-process process))))
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
121 (message "Opening TLS connection to `%s'...%s"
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
122 host (if done "done" "failed"))
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
123 done))
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
124
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
125 (provide 'tls)
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
126
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 50313
diff changeset
127 ;;; arch-tag: 5596d1c4-facc-4bc4-94a9-9863b928d7ac
50313
59ddec11881f Initial revision
Simon Josefsson <jas@extundo.com>
parents:
diff changeset
128 ;;; tls.el ends here