annotate lisp/erc/erc-dcc.el @ 103881:af8ccc3ec158

*** empty log message ***
author Eli Zaretskii <eliz@gnu.org>
date Mon, 13 Jul 2009 20:23:46 +0000
parents b3adc9117711
children 97655a0c7e67
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1 ;;; erc-dcc.el --- CTCP DCC module for ERC
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
2
101228
b3adc9117711 (erc-dcc-server): Silence warning about obsolete function behind
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
3 ;; Copyright (C) 1993, 1994, 1995, 1998, 2002, 2003, 2004, 2006, 2007,
b3adc9117711 (erc-dcc-server): Silence warning about obsolete function behind
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
4 ;; 2008, 2009 Free Software Foundation, Inc.
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
5
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
6 ;; Author: Ben A. Mesander <ben@gnu.ai.mit.edu>
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
7 ;; Noah Friedman <friedman@prep.ai.mit.edu>
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
8 ;; Per Persson <pp@sno.pp.se>
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
9 ;; Maintainer: mlang@delysid.org
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
10 ;; Keywords: comm, processes
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
11 ;; Created: 1994-01-23
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
12
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
13 ;; This file is part of GNU Emacs.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
14
94660
2a734255bcc7 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92128
diff changeset
15 ;; GNU Emacs is free software: you can redistribute it and/or modify
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
16 ;; it under the terms of the GNU General Public License as published by
94660
2a734255bcc7 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92128
diff changeset
17 ;; the Free Software Foundation, either version 3 of the License, or
2a734255bcc7 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92128
diff changeset
18 ;; (at your option) any later version.
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
19
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
20 ;; GNU Emacs is distributed in the hope that it will be useful,
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
21 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
23 ;; GNU General Public License for more details.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
24
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
25 ;; You should have received a copy of the GNU General Public License
94660
2a734255bcc7 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92128
diff changeset
26 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
27
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
28 ;;; Commentary:
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
29
68814
fe9073ac802e Revision: emacs@sv.gnu.org/emacs--devo--0--patch-73
Miles Bader <miles@gnu.org>
parents: 68451
diff changeset
30 ;; This file provides Direct Client-to-Client support for ERC.
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
31 ;;
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
32 ;; The original code was taken from zenirc-dcc.el, heavily mangled and
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
33 ;; rewritten to support the way how ERC operates. Server socket support
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
34 ;; was added for DCC CHAT and SEND afterwards. Thanks
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
35 ;; to the original authors for their work.
74093
bc5d69739d5e Merge from erc--emacs--22
Miles Bader <miles@gnu.org>
parents: 73727
diff changeset
36
bc5d69739d5e Merge from erc--emacs--22
Miles Bader <miles@gnu.org>
parents: 73727
diff changeset
37 ;;; Usage:
bc5d69739d5e Merge from erc--emacs--22
Miles Bader <miles@gnu.org>
parents: 73727
diff changeset
38
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
39 ;; To use this file, put
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
40 ;; (require 'erc-dcc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
41 ;; in your .emacs.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
42 ;;
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
43 ;; Provided commands
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
44 ;; /dcc chat nick - Either accept pending chat offer from nick, or offer
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
45 ;; DCC chat to nick
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
46 ;; /dcc close type [nick] - Close DCC connection (SEND/GET/CHAT) with nick
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
47 ;; /dcc get nick [file] - Accept DCC offer from nick
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
48 ;; /dcc list - List all DCC offers/connections
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
49 ;; /dcc send nick file - Offer DCC SEND to nick
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
50 ;;
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
51 ;; Please note that offering DCC connections (offering chats and sending
74093
bc5d69739d5e Merge from erc--emacs--22
Miles Bader <miles@gnu.org>
parents: 73727
diff changeset
52 ;; files) is only supported with Emacs 22.
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
53
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
54 ;;; Code:
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
55
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
56 (require 'erc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
57 (eval-when-compile
68865
90c105dcb4a0 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-82
Miles Bader <miles@gnu.org>
parents: 68822
diff changeset
58 (require 'cl)
90c105dcb4a0 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-82
Miles Bader <miles@gnu.org>
parents: 68822
diff changeset
59 (require 'pcomplete))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
60
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
61 ;;;###autoload (autoload 'erc-dcc-mode "erc-dcc")
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
62 (define-erc-module dcc nil
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
63 "Provide Direct Client-to-Client support for ERC."
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
64 ((add-hook 'erc-server-401-functions 'erc-dcc-no-such-nick))
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
65 ((remove-hook 'erc-server-401-functions 'erc-dcc-no-such-nick)))
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
66
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
67 (defgroup erc-dcc nil
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
68 "DCC stands for Direct Client Communication, where you and your
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
69 friend's client programs connect directly to each other,
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
70 bypassing IRC servers and their occasional \"lag\" or \"split\"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
71 problems. Like /MSG, the DCC chat is completely private.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
72
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
73 Using DCC get and send, you can transfer files directly from and to other
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
74 IRC users."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
75 :group 'erc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
76
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
77 (defcustom erc-dcc-verbose nil
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
78 "*If non-nil, be verbose about DCC activity reporting."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
79 :group 'erc-dcc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
80 :type 'boolean)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
81
98560
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
82 (defconst erc-dcc-connection-types
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
83 '("CHAT" "GET" "SEND")
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
84 "List of valid DCC connection types.
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
85 All values of the list must be uppercase strings.")
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
86
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
87 (defvar erc-dcc-list nil
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
88 "List of DCC connections. Looks like:
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
89 ((:nick \"nick!user@host\" :type GET :peer proc :parent proc :size size :file file)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
90 (:nick \"nick!user@host\" :type CHAT :peer proc :parent proc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
91 (:nick \"nick\" :type SEND :peer server-proc :parent parent-proc :file
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
92 file :sent <marker> :confirmed <marker>))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
93
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
94 :nick - a user or userhost for the peer. combine with :parent to reach them
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
95
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
96 :type - the type of DCC connection - SEND for outgoing files, GET for
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
97 incoming, and CHAT for both directions. To tell which end started
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
98 the DCC chat, look at :peer
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
99
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
100 :peer - the other end of the DCC connection. In the case of outgoing DCCs,
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
101 this represents a server process until a connection is established
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
102
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
103 :parent - the server process where the dcc connection was established.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
104 Note that this can be nil or an invalid process since a DCC
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
105 connection is in general independent from a particular server
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
106 connection after it was established.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
107
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
108 :file - for outgoing sends, the full path to the file. for incoming sends,
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
109 the suggested filename or vetted filename
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
110
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
111 :size - size of the file, may be nil on incoming DCCs")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
112
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
113 (defun erc-dcc-list-add (type nick peer parent &rest args)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
114 "Add a new entry of type TYPE to `erc-dcc-list' and return it."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
115 (car
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
116 (setq erc-dcc-list
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
117 (cons
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
118 (append (list :nick nick :type type :peer peer :parent parent) args)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
119 erc-dcc-list))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
120
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
121 ;; This function takes all the usual args as open-network-stream, plus one
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
122 ;; more: the entry data from erc-dcc-list for this particular process.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
123 (defvar erc-dcc-connect-function 'erc-dcc-open-network-stream)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
124
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
125 (defun erc-dcc-open-network-stream (procname buffer addr port entry)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
126 (if nil; (fboundp 'open-network-stream-nowait) ;; this currently crashes
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
127 ;; cvs emacs
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
128 (open-network-stream-nowait procname buffer addr port)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
129 (open-network-stream procname buffer addr port)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
130
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
131 (erc-define-catalog
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
132 'english
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
133 '((dcc-chat-discarded
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
134 . "DCC: previous chat request from %n (%u@%h) discarded")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
135 (dcc-chat-ended . "DCC: chat with %n ended %t: %e")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
136 (dcc-chat-no-request . "DCC: chat request from %n not found")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
137 (dcc-chat-offered . "DCC: chat offered by %n (%u@%h:%p)")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
138 (dcc-chat-offer . "DCC: offering chat to %n")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
139 (dcc-chat-accept . "DCC: accepting chat from %n")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
140 (dcc-chat-privmsg . "=%n= %m")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
141 (dcc-closed . "DCC: Closed %T from %n")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
142 (dcc-command-undefined
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
143 . "DCC: %c undefined subcommand. GET, CHAT and LIST are defined.")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
144 (dcc-ctcp-errmsg . "DCC: `%s' is not a DCC subcommand known to this client")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
145 (dcc-ctcp-unknown . "DCC: unknown dcc command `%q' from %n (%u@%h)")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
146 (dcc-get-bytes-received . "DCC: %f: %b bytes received")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
147 (dcc-get-complete
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
148 . "DCC: file %f transfer complete (%s bytes in %t seconds)")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
149 (dcc-get-cmd-aborted . "DCC: Aborted getting %f from %n")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
150 (dcc-get-file-too-long
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
151 . "DCC: %f: File longer than sender claimed; aborting transfer")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
152 (dcc-get-notfound . "DCC: %n hasn't offered %f for DCC transfer")
98560
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
153 (dcc-list-head . "DCC: From Type Active Size Filename")
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
154 (dcc-list-line . "DCC: -------- ---- ------ -------------- --------")
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
155 (dcc-list-item . "DCC: %-8n %-4t %-6a %-14s %f")
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
156 (dcc-list-end . "DCC: End of list.")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
157 (dcc-malformed . "DCC: error: %n (%u@%h) sent malformed request: %q")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
158 (dcc-privileged-port
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
159 . "DCC: possibly bogus request: %p is a privileged port.")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
160 (dcc-request-bogus . "DCC: bogus dcc `%r' from %n (%u@%h)")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
161 (dcc-send-finished . "DCC: SEND of %f to %n finished (size %s)")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
162 (dcc-send-offered . "DCC: file %f offered by %n (%u@%h) (size %s)")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
163 (dcc-send-offer . "DCC: offering %f to %n")))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
164
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
165 ;;; Misc macros and utility functions
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
166
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
167 (defun erc-dcc-member (&rest args)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
168 "Return the first matching entry in `erc-dcc-list' which satisfies the
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
169 constraints given as a plist in ARGS. Returns nil on no match.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
170
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
171 The property :nick is treated specially, if it contains a '!' character,
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
172 it is treated as a nick!user@host string, and compared with the :nick property
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
173 value of the individual elements using string-equal. Otherwise it is
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
174 compared with `erc-nick-equal-p' which is IRC case-insensitive."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
175 (let ((list erc-dcc-list)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
176 result test)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
177 ;; for each element in erc-dcc-list
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
178 (while (and list (not result))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
179 (let ((elt (car list))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
180 (prem args)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
181 (cont t))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
182 ;; loop through the constraints
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
183 (while (and prem cont)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
184 (let ((prop (car prem))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
185 (val (cadr prem)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
186 (setq prem (cddr prem)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
187 ;; plist-member is a predicate in xemacs
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
188 test (and (plist-member elt prop)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
189 (plist-get elt prop)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
190 ;; if the property exists and is equal, we continue, else, try the
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
191 ;; next element of the list
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
192 (or (and (eq prop :nick) (string-match "!" val)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
193 test (string-equal test val))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
194 (and (eq prop :nick)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
195 test val
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
196 (erc-nick-equal-p
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
197 (erc-extract-nick test)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
198 (erc-extract-nick val)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
199 ;; not a nick
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
200 (eq test val)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
201 (setq cont nil))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
202 (if cont
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
203 (setq result elt)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
204 (setq list (cdr list)))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
205 result))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
206
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
207 (defun erc-pack-int (value)
98560
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
208 "Convert an integer into a packed string in network byte order,
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
209 which is big-endian."
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
210 ;; make sure value is not negative
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
211 (when (< value 0)
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
212 (error "ERC-DCC (erc-pack-int): packet size is negative"))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
213 ;; make sure size is not larger than 4 bytes
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
214 (let ((len (if (= value 0) 0
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
215 (ceiling (/ (ceiling (/ (log value) (log 2))) 8.0)))))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
216 (when (> len 4)
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
217 (error "ERC-DCC (erc-pack-int): packet too large")))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
218 ;; pack
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
219 (let ((str (make-string 4 0))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
220 (i 3))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
221 (while (and (>= i 0) (> value 0))
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
222 (aset str i (% value 256))
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
223 (setq value (/ value 256))
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
224 (setq i (1- i)))
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
225 str))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
226
98560
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
227 (defconst erc-most-positive-int-bytes
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
228 (ceiling (/ (ceiling (/ (log most-positive-fixnum) (log 2))) 8.0))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
229 "Maximum number of bytes for a fixnum.")
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
230
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
231 (defconst erc-most-positive-int-msb
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
232 (lsh most-positive-fixnum (- 0 (* 8 (1- erc-most-positive-int-bytes))))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
233 "Content of the most significant byte of most-positive-fixnum.")
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
234
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
235 (defun erc-unpack-int (str)
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
236 "Unpack a packed string into an integer."
98560
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
237 (let ((len (length str)))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
238 ;; strip leading 0-bytes
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
239 (let ((start 0))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
240 (while (and (> len start) (eq (aref str start) 0))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
241 (setq start (1+ start)))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
242 (when (> start 0)
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
243 (setq str (substring str start))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
244 (setq len (- len start))))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
245 ;; make sure size is not larger than Emacs can handle
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
246 (when (or (> len (min 4 erc-most-positive-int-bytes))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
247 (and (eq len erc-most-positive-int-bytes)
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
248 (> (aref str 0) erc-most-positive-int-msb)))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
249 (error "ERC-DCC (erc-unpack-int): packet to send is too large"))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
250 ;; unpack
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
251 (let ((num 0)
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
252 (count 0))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
253 (while (< count len)
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
254 (setq num (+ num (lsh (aref str (- len count 1)) (* 8 count))))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
255 (setq count (1+ count)))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
256 num)))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
257
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
258 (defconst erc-dcc-ipv4-regexp
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
259 (concat "^"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
260 (mapconcat #'identity (make-list 4 "\\([0-9]\\{1,3\\}\\)") "\\.")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
261 "$"))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
262
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
263 (defun erc-ip-to-decimal (ip)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
264 "Convert IP address to its decimal representation.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
265 Argument IP is the address as a string. The result is also a string."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
266 (interactive "sIP Address: ")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
267 (if (not (string-match erc-dcc-ipv4-regexp ip))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
268 (error "Not an IP address")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
269 (let* ((ips (mapcar
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
270 (lambda (str)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
271 (let ((n (string-to-number str)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
272 (if (and (>= n 0) (< n 256))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
273 n
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
274 (error "%d out of range" n))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
275 (split-string ip "\\.")))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
276 (res (+ (* (car ips) 16777216.0)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
277 (* (nth 1 ips) 65536.0)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
278 (* (nth 2 ips) 256.0)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
279 (nth 3 ips))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
280 (if (interactive-p)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
281 (message "%s is %.0f" ip res)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
282 (format "%.0f" res)))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
283
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
284 (defun erc-decimal-to-ip (dec)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
285 "Convert a decimal representation DEC to an IP address.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
286 The result is also a string."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
287 (when (stringp dec)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
288 (setq dec (string-to-number (concat dec ".0"))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
289 (let* ((first (floor (/ dec 16777216.0)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
290 (first-rest (- dec (* first 16777216.0)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
291 (second (floor (/ first-rest 65536.0)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
292 (second-rest (- first-rest (* second 65536.0)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
293 (third (floor (/ second-rest 256.0)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
294 (third-rest (- second-rest (* third 256.0)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
295 (fourth (floor third-rest)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
296 (format "%s.%s.%s.%s" first second third fourth)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
297
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
298 ;;; Server code
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
299
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
300 (defcustom erc-dcc-listen-host nil
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
301 "IP address to listen on when offering files.
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
302 Should be set to a string or nil. If nil, automatic detection of
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
303 the host interface to use will be attempted."
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
304 :group 'erc-dcc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
305 :type (list 'choice (list 'const :tag "Auto-detect" nil)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
306 (list 'string :tag "IP-address"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
307 :valid-regexp erc-dcc-ipv4-regexp)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
308
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
309 (defcustom erc-dcc-public-host nil
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
310 "IP address to use for outgoing DCC offers.
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
311 Should be set to a string or nil. If nil, use the value of
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
312 `erc-dcc-listen-host'."
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
313 :group 'erc-dcc
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
314 :type (list 'choice (list 'const :tag "Same as erc-dcc-listen-host" nil)
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
315 (list 'string :tag "IP-address"
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
316 :valid-regexp erc-dcc-ipv4-regexp)))
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
317
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
318 (defcustom erc-dcc-send-request 'ask
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
319 "*How to treat incoming DCC Send requests.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
320 'ask - Report the Send request, and wait for the user to manually accept it
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
321 You might want to set `erc-dcc-auto-masks' for this.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
322 'auto - Automatically accept the request and begin downloading the file
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
323 'ignore - Ignore incoming DCC Send requests completely."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
324 :group 'erc-dcc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
325 :type '(choice (const ask) (const auto) (const ignore)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
326
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
327 (defun erc-dcc-get-host (proc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
328 "Returns the local IP address used for an open PROCess."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
329 (format-network-address (process-contact proc :local) t))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
330
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
331 (defun erc-dcc-host ()
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
332 "Determine the IP address we are using.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
333 If variable `erc-dcc-host' is non-nil, use it. Otherwise call
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
334 `erc-dcc-get-host' on the erc-server-process."
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
335 (or erc-dcc-listen-host (erc-dcc-get-host erc-server-process)
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
336 (error "Unable to determine local address")))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
337
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
338 (defcustom erc-dcc-port-range nil
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
339 "If nil, any available user port is used for outgoing DCC connections.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
340 If set to a cons, it specifies a range of ports to use in the form (min . max)"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
341 :group 'erc-dcc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
342 :type '(choice
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
343 (const :tag "Any port" nil)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
344 (cons :tag "Port range"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
345 (integer :tag "Lower port")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
346 (integer :tag "Upper port"))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
347
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
348 (defcustom erc-dcc-auto-masks nil
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
349 "List of regexps matching user identifiers whose DCC send offers should be
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
350 accepted automatically. A user identifier has the form \"nick!login@host\".
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
351 For instance, to accept all incoming DCC send offers automatically, add the
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
352 string \".*!.*@.*\" to this list."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
353 :group 'erc-dcc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
354 :type '(repeat regexp))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
355
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
356 (defun erc-dcc-server (name filter sentinel)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
357 "Start listening on a port for an incoming DCC connection. Returns the newly
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
358 created subprocess, or nil."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
359 (let ((port (or (and erc-dcc-port-range (car erc-dcc-port-range)) t))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
360 (upper (and erc-dcc-port-range (cdr erc-dcc-port-range)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
361 process)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
362 (while (not process)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
363 (condition-case err
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
364 (progn
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
365 (setq process
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
366 (make-network-process :name name
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
367 :buffer nil
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
368 :host (erc-dcc-host)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
369 :service port
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
370 :nowait t
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
371 :noquery nil
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
372 :filter filter
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
373 :sentinel sentinel
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
374 :log #'erc-dcc-server-accept
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
375 :server t))
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
376 (when (processp process)
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
377 (when (fboundp 'set-process-coding-system)
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
378 (set-process-coding-system process 'binary 'binary))
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
379 (when (fboundp 'set-process-filter-multibyte)
101228
b3adc9117711 (erc-dcc-server): Silence warning about obsolete function behind
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
380 (with-no-warnings ; obsolete since 23.1
b3adc9117711 (erc-dcc-server): Silence warning about obsolete function behind
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
381 (set-process-filter-multibyte process nil)))))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
382 (file-error
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
383 (unless (and (string= "Cannot bind server socket" (cadr err))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
384 (string= "address already in use" (caddr err)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
385 (signal (car err) (cdr err)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
386 (setq port (1+ port))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
387 (unless (< port upper)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
388 (error "No available ports in erc-dcc-port-range")))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
389 process))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
390
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
391 (defun erc-dcc-server-accept (server client message)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
392 "Log an accepted DCC offer, then terminate the listening process and set up
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
393 the accepted connection."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
394 (erc-log (format "(erc-dcc-server-accept): server %s client %s message %s"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
395 server client message))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
396 (when (and (string-match "^accept from " message)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
397 (processp server) (processp client))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
398 (let ((elt (erc-dcc-member :peer server)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
399 ;; change the entry in erc-dcc-list from the listening process to the
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
400 ;; accepted process
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
401 (setq elt (plist-put elt :peer client))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
402 ;; delete the listening process, as we've accepted the connection
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
403 (delete-process server))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
404
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
405 ;;; Interactive command handling
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
406
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
407 (defcustom erc-dcc-get-default-directory nil
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
408 "*Default directory for incoming DCC file transfers.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
409 If this is nil, then the current value of `default-directory' is used."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
410 :group 'erc-dcc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
411 :type '(choice (const nil :tag "Default directory") directory))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
412
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
413 ;;;###autoload
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
414 (defun erc-cmd-DCC (cmd &rest args)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
415 "Parser for /dcc command.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
416 This figures out the dcc subcommand and calls the appropriate routine to
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
417 handle it. The function dispatched should be named \"erc-dcc-do-FOO-command\",
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
418 where FOO is one of CLOSE, GET, SEND, LIST, CHAT, etc."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
419 (when cmd
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
420 (let ((fn (intern-soft (concat "erc-dcc-do-" (upcase cmd) "-command"))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
421 (if fn
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
422 (apply fn erc-server-process args)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
423 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
424 nil 'notice 'active
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
425 'dcc-command-undefined ?c cmd)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
426 (apropos "erc-dcc-do-.*-command")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
427 t))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
428
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
429 ;;;###autoload
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
430 (defun pcomplete/erc-mode/DCC ()
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
431 "Provides completion for the /DCC command."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
432 (pcomplete-here (append '("chat" "close" "get" "list")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
433 (when (fboundp 'make-network-process) '("send"))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
434 (pcomplete-here
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
435 (case (intern (downcase (pcomplete-arg 1)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
436 (chat (mapcar (lambda (elt) (plist-get elt :nick))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
437 (erc-remove-if-not
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
438 #'(lambda (elt)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
439 (eq (plist-get elt :type) 'CHAT))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
440 erc-dcc-list)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
441 (close (remove-duplicates
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
442 (mapcar (lambda (elt) (symbol-name (plist-get elt :type)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
443 erc-dcc-list) :test 'string=))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
444 (get (mapcar #'erc-dcc-nick
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
445 (erc-remove-if-not
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
446 #'(lambda (elt)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
447 (eq (plist-get elt :type) 'GET))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
448 erc-dcc-list)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
449 (send (pcomplete-erc-all-nicks))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
450 (pcomplete-here
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
451 (case (intern (downcase (pcomplete-arg 2)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
452 (get (mapcar (lambda (elt) (plist-get elt :file))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
453 (erc-remove-if-not
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
454 #'(lambda (elt)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
455 (and (eq (plist-get elt :type) 'GET)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
456 (erc-nick-equal-p (erc-extract-nick
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
457 (plist-get elt :nick))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
458 (pcomplete-arg 1))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
459 erc-dcc-list)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
460 (close (mapcar #'erc-dcc-nick
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
461 (erc-remove-if-not
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
462 #'(lambda (elt)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
463 (eq (plist-get elt :type)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
464 (intern (upcase (pcomplete-arg 1)))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
465 erc-dcc-list)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
466 (send (pcomplete-entries)))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
467
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
468 (defun erc-dcc-do-CHAT-command (proc &optional nick)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
469 (when nick
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
470 (let ((elt (erc-dcc-member :nick nick :type 'CHAT :parent proc)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
471 (if (and elt (not (processp (plist-get elt :peer))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
472 ;; accept an existing chat offer
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
473 ;; FIXME: perhaps /dcc accept like other clients?
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
474 (progn (erc-dcc-chat-accept elt erc-server-process)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
475 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
476 nil 'notice 'active
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
477 'dcc-chat-accept ?n nick)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
478 t)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
479 (erc-dcc-chat nick erc-server-process)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
480 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
481 nil 'notice 'active
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
482 'dcc-chat-offer ?n nick)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
483 t))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
484
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
485 (defun erc-dcc-do-CLOSE-command (proc &optional type nick)
98560
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
486 "Close a connection. Usage: /dcc close type nick.
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
487 At least one of TYPE and NICK must be provided."
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
488 ;; disambiguate type and nick if only one is provided
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
489 (when (and type (null nick)
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
490 (not (member (upcase type) erc-dcc-connection-types)))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
491 (setq nick type)
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
492 (setq type nil))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
493 ;; validate nick argument
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
494 (unless (and nick (string-match (concat "\\`" erc-valid-nick-regexp "\\'")
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
495 nick))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
496 (setq nick nil))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
497 ;; validate type argument
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
498 (if (and type (member (upcase type) erc-dcc-connection-types))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
499 (setq type (intern (upcase type)))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
500 (setq type nil))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
501 (when (or nick type)
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
502 (let ((ret t))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
503 (while ret
98560
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
504 (cond ((and nick type)
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
505 (setq ret (erc-dcc-member :type type :nick nick)))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
506 (nick
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
507 (setq ret (erc-dcc-member :nick nick)))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
508 (type
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
509 (setq ret (erc-dcc-member :type type)))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
510 (t
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
511 (setq ret nil)))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
512 (when ret
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
513 ;; found a match - delete process if it exists.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
514 (and (processp (plist-get ret :peer))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
515 (delete-process (plist-get ret :peer)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
516 (setq erc-dcc-list (delq ret erc-dcc-list))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
517 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
518 nil 'notice 'active
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
519 'dcc-closed
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
520 ?T (plist-get ret :type)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
521 ?n (erc-extract-nick (plist-get ret :nick))))))
98560
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
522 t))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
523
92128
84357f6e06d1 ERC: Sync from upstream.
Michael Olson <mwolson@gnu.org>
parents: 87952
diff changeset
524 (defun erc-dcc-do-GET-command (proc nick &rest file)
84357f6e06d1 ERC: Sync from upstream.
Michael Olson <mwolson@gnu.org>
parents: 87952
diff changeset
525 "Do a DCC GET command. NICK is the person who is sending the file.
84357f6e06d1 ERC: Sync from upstream.
Michael Olson <mwolson@gnu.org>
parents: 87952
diff changeset
526 FILE is the filename. If FILE is split into multiple arguments,
84357f6e06d1 ERC: Sync from upstream.
Michael Olson <mwolson@gnu.org>
parents: 87952
diff changeset
527 re-join the arguments, separated by a space.
84357f6e06d1 ERC: Sync from upstream.
Michael Olson <mwolson@gnu.org>
parents: 87952
diff changeset
528 PROC is the server process."
84357f6e06d1 ERC: Sync from upstream.
Michael Olson <mwolson@gnu.org>
parents: 87952
diff changeset
529 (setq file (and file (mapconcat #'identity file " ")))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
530 (let* ((elt (erc-dcc-member :nick nick :type 'GET))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
531 (filename (or file (plist-get elt :file) "unknown")))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
532 (if elt
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
533 (let* ((file (read-file-name
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
534 (format "Local filename (default %s): "
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
535 (file-name-nondirectory filename))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
536 (or erc-dcc-get-default-directory
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
537 default-directory)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
538 (expand-file-name (file-name-nondirectory filename)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
539 (or erc-dcc-get-default-directory
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
540 default-directory)))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
541 (cond ((file-exists-p file)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
542 (if (yes-or-no-p (format "File %s exists. Overwrite? "
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
543 file))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
544 (erc-dcc-get-file elt file proc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
545 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
546 nil '(notice error) proc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
547 'dcc-get-cmd-aborted
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
548 ?n nick ?f filename)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
549 (t
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
550 (erc-dcc-get-file elt file proc))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
551 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
552 nil '(notice error) 'active
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
553 'dcc-get-notfound ?n nick ?f filename))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
554
98560
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
555 (defvar erc-dcc-byte-count nil)
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
556 (make-variable-buffer-local 'erc-dcc-byte-count)
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
557
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
558 (defun erc-dcc-do-LIST-command (proc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
559 "This is the handler for the /dcc list command.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
560 It lists the current state of `erc-dcc-list' in an easy to read manner."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
561 (let ((alist erc-dcc-list)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
562 size elt)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
563 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
564 nil 'notice 'active
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
565 'dcc-list-head)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
566 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
567 nil 'notice 'active
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
568 'dcc-list-line)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
569 (while alist
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
570 (setq elt (car alist)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
571 alist (cdr alist))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
572
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
573 (setq size (or (and (plist-member elt :size)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
574 (plist-get elt :size))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
575 ""))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
576 (setq size
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
577 (cond ((null size) "")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
578 ((numberp size) (number-to-string size))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
579 ((string= size "") "unknown")))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
580 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
581 nil 'notice 'active
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
582 'dcc-list-item
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
583 ?n (erc-dcc-nick elt)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
584 ?t (plist-get elt :type)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
585 ?a (if (processp (plist-get elt :peer))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
586 (process-status (plist-get elt :peer))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
587 "no")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
588 ?s (concat size
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
589 (if (and (eq 'GET (plist-get elt :type))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
590 (plist-member elt :file)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
591 (buffer-live-p (get-buffer (plist-get elt :file)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
592 (plist-member elt :size))
98560
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
593 (let ((byte-count (with-current-buffer
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
594 (get-buffer (plist-get elt :file))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
595 (+ (buffer-size) 0.0
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
596 erc-dcc-byte-count))))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
597 (concat " ("
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
598 (if (= byte-count 0)
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
599 "0"
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
600 (number-to-string
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
601 (truncate
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
602 (* 100
98560
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
603 (/ byte-count (plist-get elt :size))))))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
604 "%)"))))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
605 ?f (or (and (plist-member elt :file) (plist-get elt :file)) "")))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
606 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
607 nil 'notice 'active
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
608 'dcc-list-end)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
609 t))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
610
92128
84357f6e06d1 ERC: Sync from upstream.
Michael Olson <mwolson@gnu.org>
parents: 87952
diff changeset
611 (defun erc-dcc-do-SEND-command (proc nick &rest file)
84357f6e06d1 ERC: Sync from upstream.
Michael Olson <mwolson@gnu.org>
parents: 87952
diff changeset
612 "Offer FILE to NICK by sending a ctcp dcc send message.
84357f6e06d1 ERC: Sync from upstream.
Michael Olson <mwolson@gnu.org>
parents: 87952
diff changeset
613 If FILE is split into multiple arguments, re-join the arguments,
84357f6e06d1 ERC: Sync from upstream.
Michael Olson <mwolson@gnu.org>
parents: 87952
diff changeset
614 separated by a space."
84357f6e06d1 ERC: Sync from upstream.
Michael Olson <mwolson@gnu.org>
parents: 87952
diff changeset
615 (setq file (and file (mapconcat #'identity file " ")))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
616 (if (file-exists-p file)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
617 (progn
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
618 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
619 nil 'notice 'active
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
620 'dcc-send-offer ?n nick ?f file)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
621 (erc-dcc-send-file nick file) t)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
622 (erc-display-message nil '(notice error) proc "File not found") t))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
623
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
624 ;;; Server message handling (i.e. messages from remote users)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
625
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
626 ;;;###autoload
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
627 (defvar erc-ctcp-query-DCC-hook '(erc-ctcp-query-DCC)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
628 "Hook variable for CTCP DCC queries")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
629
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
630 (defvar erc-dcc-query-handler-alist
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
631 '(("SEND" . erc-dcc-handle-ctcp-send)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
632 ("CHAT" . erc-dcc-handle-ctcp-chat)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
633
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
634 ;;;###autoload
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
635 (defun erc-ctcp-query-DCC (proc nick login host to query)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
636 "The function called when a CTCP DCC request is detected by the client.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
637 It examines the DCC subcommand, and calls the appropriate routine for
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
638 that subcommand."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
639 (let* ((cmd (cadr (split-string query " ")))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
640 (handler (cdr (assoc cmd erc-dcc-query-handler-alist))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
641 (if handler
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
642 (funcall handler proc query nick login host to)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
643 ;; FIXME: Send a ctcp error notice to the remote end?
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
644 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
645 nil '(notice error) proc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
646 'dcc-ctcp-unknown
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
647 ?q query ?n nick ?u login ?h host))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
648
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
649 (defconst erc-dcc-ctcp-query-send-regexp
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
650 "^DCC SEND \\([^ ]+\\) \\([0-9]+\\) \\([0-9]+\\) *\\([0-9]*\\)")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
651
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
652 (defun erc-dcc-handle-ctcp-send (proc query nick login host to)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
653 "This is called if a CTCP DCC SEND subcommand is sent to the client.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
654 It extracts the information about the dcc request and adds it to
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
655 `erc-dcc-list'."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
656 (unless (eq erc-dcc-send-request 'ignore)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
657 (cond
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
658 ((not (erc-current-nick-p to))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
659 ;; DCC SEND requests must be sent to you, and you alone.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
660 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
661 nil 'notice proc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
662 'dcc-request-bogus
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
663 ?r "SEND" ?n nick ?u login ?h host))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
664 ((string-match erc-dcc-ctcp-query-send-regexp query)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
665 (let ((filename (match-string 1 query))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
666 (ip (erc-decimal-to-ip (match-string 2 query)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
667 (port (match-string 3 query))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
668 (size (match-string 4 query)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
669 ;; FIXME: a warning really should also be sent
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
670 ;; if the ip address != the host the dcc sender is on.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
671 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
672 nil 'notice proc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
673 'dcc-send-offered
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
674 ?f filename ?n nick ?u login ?h host
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
675 ?s (if (string= size "") "unknown" size))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
676 (and (< (string-to-number port) 1025)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
677 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
678 nil 'notice proc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
679 'dcc-privileged-port
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
680 ?p port))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
681 (erc-dcc-list-add
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
682 'GET (format "%s!%s@%s" nick login host)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
683 nil proc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
684 :ip ip :port port :file filename
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
685 :size (string-to-number size))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
686 (if (and (eq erc-dcc-send-request 'auto)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
687 (erc-dcc-auto-mask-p (format "\"%s!%s@%s\"" nick login host)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
688 (erc-dcc-get-file (car erc-dcc-list) filename proc))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
689 (t
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
690 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
691 nil 'notice proc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
692 'dcc-malformed
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
693 ?n nick ?u login ?h host ?q query)))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
694
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
695 (defun erc-dcc-auto-mask-p (spec)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
696 "Takes a full SPEC of a user in the form \"nick!login@host\" and
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
697 matches against all the regexp's in `erc-dcc-auto-masks'. If any
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
698 match, returns that regexp and nil otherwise."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
699 (let ((lst erc-dcc-auto-masks))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
700 (while (and lst
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
701 (not (string-match (car lst) spec)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
702 (setq lst (cdr lst)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
703 (and lst (car lst))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
704
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
705 (defconst erc-dcc-ctcp-query-chat-regexp
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
706 "^DCC CHAT +chat +\\([0-9]+\\) +\\([0-9]+\\)")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
707
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
708 (defcustom erc-dcc-chat-request 'ask
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
709 "*How to treat incoming DCC Chat requests.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
710 'ask - Report the Chat request, and wait for the user to manually accept it
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
711 'auto - Automatically accept the request and open a new chat window
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
712 'ignore - Ignore incoming DCC chat requests completely."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
713 :group 'erc-dcc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
714 :type '(choice (const ask) (const auto) (const ignore)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
715
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
716 (defun erc-dcc-handle-ctcp-chat (proc query nick login host to)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
717 (unless (eq erc-dcc-chat-request 'ignore)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
718 (cond
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
719 (;; DCC CHAT requests must be sent to you, and you alone.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
720 (not (erc-current-nick-p to))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
721 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
722 nil '(notice error) proc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
723 'dcc-request-bogus ?r "CHAT" ?n nick ?u login ?h host))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
724 ((string-match erc-dcc-ctcp-query-chat-regexp query)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
725 ;; We need to use let* here, since erc-dcc-member might clutter
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
726 ;; the match value.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
727 (let* ((ip (erc-decimal-to-ip (match-string 1 query)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
728 (port (match-string 2 query))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
729 (elt (erc-dcc-member :nick nick :type 'CHAT)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
730 ;; FIXME: A warning really should also be sent if the ip
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
731 ;; address != the host the dcc sender is on.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
732 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
733 nil 'notice proc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
734 'dcc-chat-offered
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
735 ?n nick ?u login ?h host ?p port)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
736 (and (< (string-to-number port) 1025)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
737 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
738 nil 'notice proc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
739 'dcc-privileged-port ?p port))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
740 (cond (elt
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
741 ;; XXX: why are we updating ip/port on the existing connection?
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
742 (setq elt (plist-put (plist-put elt :port port) :ip ip))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
743 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
744 nil 'notice proc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
745 'dcc-chat-discarded ?n nick ?u login ?h host))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
746 (t
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
747 (erc-dcc-list-add
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
748 'CHAT (format "%s!%s@%s" nick login host)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
749 nil proc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
750 :ip ip :port port)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
751 (if (eq erc-dcc-chat-request 'auto)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
752 (erc-dcc-chat-accept (erc-dcc-member :nick nick :type 'CHAT)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
753 proc))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
754 (t
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
755 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
756 nil '(notice error) proc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
757 'dcc-malformed ?n nick ?u login ?h host ?q query)))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
758
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
759
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
760 (defvar erc-dcc-entry-data nil
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
761 "Holds the `erc-dcc-list' entry for this DCC connection.")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
762 (make-variable-buffer-local 'erc-dcc-entry-data)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
763
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
764 ;;; SEND handling
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
765
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
766 (defcustom erc-dcc-block-size 1024
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
767 "*Block size to use for DCC SEND sessions."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
768 :group 'erc-dcc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
769 :type 'integer)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
770
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
771 (defcustom erc-dcc-pump-bytes nil
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
772 "*If set to an integer, keep sending until that number of bytes are
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
773 unconfirmed."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
774 :group 'erc-dcc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
775 :type '(choice (const nil) integer))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
776
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
777 (defsubst erc-dcc-get-parent (proc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
778 (plist-get (erc-dcc-member :peer proc) :parent))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
779
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
780 (defun erc-dcc-send-block (proc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
781 "Send one block of data.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
782 PROC is the process-object of the DCC connection. Returns the number of
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
783 bytes sent."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
784 (let* ((elt (erc-dcc-member :peer proc))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
785 (confirmed-marker (plist-get elt :sent))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
786 (sent-marker (plist-get elt :sent)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
787 (with-current-buffer (process-buffer proc)
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
788 (when erc-dcc-verbose
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
789 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
790 nil 'notice (erc-dcc-get-parent proc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
791 (format "DCC: Confirmed %d, sent %d, sending block now"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
792 (- confirmed-marker (point-min))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
793 (- sent-marker (point-min)))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
794 (let* ((end (min (+ sent-marker erc-dcc-block-size)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
795 (point-max)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
796 (string (buffer-substring-no-properties sent-marker end)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
797 (when (< sent-marker end)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
798 (set-marker sent-marker end)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
799 (process-send-string proc string))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
800 (length string)))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
801
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
802 (defun erc-dcc-send-filter (proc string)
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
803 (let* ((size (erc-unpack-int string))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
804 (elt (erc-dcc-member :peer proc))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
805 (parent (plist-get elt :parent))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
806 (sent-marker (plist-get elt :sent))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
807 (confirmed-marker (plist-get elt :confirmed)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
808 (with-current-buffer (process-buffer proc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
809 (set-marker confirmed-marker (+ (point-min) size))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
810 (cond
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
811 ((and (= confirmed-marker sent-marker)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
812 (= confirmed-marker (point-max)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
813 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
814 nil 'notice parent
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
815 'dcc-send-finished
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
816 ?n (plist-get elt :nick)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
817 ?f buffer-file-name
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
818 ?s (number-to-string (- sent-marker (point-min))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
819 (setq erc-dcc-list (delete elt erc-dcc-list))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
820 (set-buffer-modified-p nil)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
821 (kill-buffer (current-buffer))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
822 (delete-process proc))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
823 ((<= confirmed-marker sent-marker)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
824 (while (and (< (- sent-marker confirmed-marker)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
825 (or erc-dcc-pump-bytes
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
826 erc-dcc-block-size))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
827 (> (erc-dcc-send-block proc) 0))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
828 ((> confirmed-marker sent-marker)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
829 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
830 nil 'notice parent
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
831 (format "DCC: Client confirmed too much (%s vs %s)!"
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
832 (marker-position confirmed-marker)
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
833 (marker-position sent-marker)))
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
834 (set-buffer-modified-p nil)
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
835 (kill-buffer (current-buffer))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
836 (delete-process proc))))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
837
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
838 (defun erc-dcc-display-send (proc)
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
839 (erc-display-message
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
840 nil 'notice (erc-dcc-get-parent proc)
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
841 (format "DCC: SEND connect from %s"
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
842 (format-network-address (process-contact proc :remote)))))
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
843
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
844 (defcustom erc-dcc-send-connect-hook
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
845 '(erc-dcc-display-send erc-dcc-send-block)
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
846 "*Hook run whenever the remote end of a DCC SEND offer connected to your
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
847 listening port."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
848 :group 'erc-dcc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
849 :type 'hook)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
850
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
851 (defun erc-dcc-nick (plist)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
852 "Extract the nickname portion of the :nick property value in PLIST."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
853 (erc-extract-nick (plist-get plist :nick)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
854
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
855 (defun erc-dcc-send-sentinel (proc event)
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
856 (let* ((elt (erc-dcc-member :peer proc)))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
857 (cond
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
858 ((string-match "^open from " event)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
859 (when elt
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
860 (let ((buf (marker-buffer (plist-get elt :sent))))
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
861 (with-current-buffer buf
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
862 (set-process-buffer proc buf)
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
863 (setq erc-dcc-entry-data elt)))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
864 (run-hook-with-args 'erc-dcc-send-connect-hook proc))))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
865
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
866 (defun erc-dcc-find-file (file)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
867 (with-current-buffer (generate-new-buffer (file-name-nondirectory file))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
868 (insert-file-contents-literally file)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
869 (setq buffer-file-name file)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
870 (current-buffer)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
871
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
872 (defun erc-dcc-file-to-name (file)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
873 (with-temp-buffer
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
874 (insert (file-name-nondirectory file))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
875 (subst-char-in-region (point-min) (point-max) ? ?_ t)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
876 (buffer-string)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
877
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
878 (defun erc-dcc-send-file (nick file &optional pproc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
879 "Open a socket for incoming connections, and send a CTCP send request to the
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
880 other client."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
881 (interactive "sNick: \nfFile: ")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
882 (when (null pproc) (if (processp erc-server-process)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
883 (setq pproc erc-server-process)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
884 (error "Can not find parent process")))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
885 (if (featurep 'make-network-process)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
886 (let* ((buffer (erc-dcc-find-file file))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
887 (size (buffer-size buffer))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
888 (start (with-current-buffer buffer
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
889 (set-marker (make-marker) (point-min))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
890 (sproc (erc-dcc-server "dcc-send"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
891 'erc-dcc-send-filter
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
892 'erc-dcc-send-sentinel))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
893 (contact (process-contact sproc)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
894 (erc-dcc-list-add
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
895 'SEND nick sproc pproc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
896 :file file :size size
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
897 :sent start :confirmed (copy-marker start))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
898 (process-send-string
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
899 pproc (format "PRIVMSG %s :\C-aDCC SEND %s %s %d %d\C-a\n"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
900 nick (erc-dcc-file-to-name file)
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
901 (erc-ip-to-decimal (or erc-dcc-public-host
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
902 (nth 0 contact)))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
903 (nth 1 contact)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
904 size)))
73727
9105f834eb17 (erc-dcc-send-file): Fix typo in error message.
Juanma Barranquero <lekktu@gmail.com>
parents: 68865
diff changeset
905 (error "`make-network-process' not supported by your Emacs")))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
906
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
907 ;;; GET handling
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
908
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
909 (defcustom erc-dcc-receive-cache (* 1024 512)
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
910 "Number of bytes to let the receive buffer grow before flushing it."
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
911 :group 'erc-dcc
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
912 :type 'integer)
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
913
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
914 (defvar erc-dcc-file-name nil)
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
915 (make-variable-buffer-local 'erc-dcc-file-name)
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
916
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
917 (defun erc-dcc-get-file (entry file parent-proc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
918 "This function does the work of setting up a transfer from the remote client
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
919 to the local one over a tcp connection. This involves setting up a process
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
920 filter and a process sentinel, and making the connection."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
921 (let* ((buffer (generate-new-buffer (file-name-nondirectory file)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
922 proc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
923 (with-current-buffer buffer
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
924 (fundamental-mode)
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
925 (buffer-disable-undo (current-buffer))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
926 ;; This is necessary to have the buffer saved as-is in GNU
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
927 ;; Emacs.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
928 ;; XEmacs change: We don't have `set-buffer-multibyte', setting
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
929 ;; coding system to 'binary below takes care of us.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
930 (when (fboundp 'set-buffer-multibyte)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
931 (set-buffer-multibyte nil))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
932
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
933 (setq mode-line-process '(":%s")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
934 buffer-file-type t
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
935 buffer-read-only t)
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
936 (setq erc-dcc-file-name file)
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
937
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
938 ;; Truncate the given file to size 0 before appending to it.
98560
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
939 (let ((inhibit-file-name-handlers
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
940 (append '(jka-compr-handler image-file-handler)
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
941 inhibit-file-name-handlers))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
942 (inhibit-file-name-operation 'write-region))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
943 (write-region (point) (point) erc-dcc-file-name nil 'nomessage))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
944
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
945 (setq erc-server-process parent-proc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
946 erc-dcc-entry-data entry)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
947 (setq erc-dcc-byte-count 0)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
948 (setq proc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
949 (funcall erc-dcc-connect-function
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
950 "dcc-get" buffer
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
951 (plist-get entry :ip)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
952 (string-to-number (plist-get entry :port))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
953 entry))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
954 (set-process-buffer proc buffer)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
955 (set-process-coding-system proc 'binary 'binary)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
956 (set-buffer-file-coding-system 'binary t)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
957
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
958 (set-process-filter proc 'erc-dcc-get-filter)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
959 (set-process-sentinel proc 'erc-dcc-get-sentinel)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
960 (setq entry (plist-put entry :start-time (erc-current-time)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
961 (setq entry (plist-put entry :peer proc)))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
962
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
963 (defun erc-dcc-append-contents (buffer file)
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
964 "Append the contents of BUFFER to FILE.
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
965 The contents of the BUFFER will then be erased."
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
966 (with-current-buffer buffer
98560
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
967 (let ((coding-system-for-write 'binary)
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
968 (inhibit-read-only t)
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
969 (inhibit-file-name-handlers
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
970 (append '(jka-compr-handler image-file-handler)
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
971 inhibit-file-name-handlers))
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
972 (inhibit-file-name-operation 'write-region))
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
973 (write-region (point-min) (point-max) erc-dcc-file-name t 'nomessage)
98560
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
974 (setq erc-dcc-byte-count (+ (buffer-size) erc-dcc-byte-count))
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
975 (erase-buffer))))
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
976
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
977 (defun erc-dcc-get-filter (proc str)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
978 "This is the process filter for transfers from other clients to this one.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
979 It reads incoming bytes from the network and stores them in the DCC
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
980 buffer, and sends back the replies after each block of data per the DCC
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
981 protocol spec. Well not really. We write back a reply after each read,
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
982 rather than every 1024 byte block, but nobody seems to care."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
983 (with-current-buffer (process-buffer proc)
98560
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
984 (let ((inhibit-read-only t)
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
985 received-bytes)
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents: 74484
diff changeset
986 (goto-char (point-max))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents: 74484
diff changeset
987 (insert (string-make-unibyte str))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
988
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
989 (when (> (point-max) erc-dcc-receive-cache)
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
990 (erc-dcc-append-contents (current-buffer) erc-dcc-file-name))
98560
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
991 (setq received-bytes (+ (buffer-size) erc-dcc-byte-count))
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
992
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
993 (and erc-dcc-verbose
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents: 74484
diff changeset
994 (erc-display-message
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents: 74484
diff changeset
995 nil 'notice erc-server-process
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents: 74484
diff changeset
996 'dcc-get-bytes-received
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents: 74484
diff changeset
997 ?f (file-name-nondirectory buffer-file-name)
98560
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
998 ?b (number-to-string received-bytes)))
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents: 74484
diff changeset
999 (cond
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents: 74484
diff changeset
1000 ((and (> (plist-get erc-dcc-entry-data :size) 0)
98560
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
1001 (> received-bytes (plist-get erc-dcc-entry-data :size)))
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents: 74484
diff changeset
1002 (erc-display-message
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents: 74484
diff changeset
1003 nil '(error notice) 'active
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents: 74484
diff changeset
1004 'dcc-get-file-too-long
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents: 74484
diff changeset
1005 ?f (file-name-nondirectory buffer-file-name))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents: 74484
diff changeset
1006 (delete-process proc))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents: 74484
diff changeset
1007 (t
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents: 74484
diff changeset
1008 (process-send-string
98560
7a2a452a3e7d ERC: DCC fixes.
Michael Olson <mwolson@gnu.org>
parents: 94660
diff changeset
1009 proc (erc-pack-int received-bytes)))))))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1010
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1011
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1012 (defun erc-dcc-get-sentinel (proc event)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1013 "This is the process sentinel for CTCP DCC SEND connections.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1014 It shuts down the connection and notifies the user that the
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1015 transfer is complete."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1016 ;; FIXME, we should look at EVENT, and also check size.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1017 (with-current-buffer (process-buffer proc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1018 (delete-process proc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1019 (setq erc-dcc-list (delete erc-dcc-entry-data erc-dcc-list))
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
1020 (unless (= (point-min) (point-max))
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
1021 (erc-dcc-append-contents (current-buffer) erc-dcc-file-name))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1022 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1023 nil 'notice erc-server-process
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1024 'dcc-get-complete
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
1025 ?f erc-dcc-file-name
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
1026 ?s (number-to-string erc-dcc-byte-count)
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1027 ?t (format "%.0f"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1028 (erc-time-diff (plist-get erc-dcc-entry-data :start-time)
87952
b8f89dd3680d ERC: Sync version 5.3, release candidate 1.
Michael Olson <mwolson@gnu.org>
parents: 79706
diff changeset
1029 (erc-current-time)))))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1030 (kill-buffer (process-buffer proc))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1031 (delete-process proc))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1032
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1033 ;;; CHAT handling
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1034
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1035 (defcustom erc-dcc-chat-buffer-name-format "DCC-CHAT-%s"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1036 "*Format to use for DCC Chat buffer names."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1037 :group 'erc-dcc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1038 :type 'string)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1039
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1040 (defcustom erc-dcc-chat-mode-hook nil
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1041 "*Hook calls when `erc-dcc-chat-mode' finished setting up the buffer."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1042 :group 'erc-dcc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1043 :type 'hook)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1044
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1045 (defcustom erc-dcc-chat-connect-hook nil
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1046 ""
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1047 :group 'erc-dcc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1048 :type 'hook)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1049
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1050 (defcustom erc-dcc-chat-exit-hook nil
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1051 ""
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1052 :group 'erc-dcc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1053 :type 'hook)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1054
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1055 (defun erc-cmd-CREQ (line &optional force)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1056 "Set or get the DCC chat request flag.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1057 Possible values are: ask, auto, ignore."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1058 (when (string-match "^\\s-*\\(auto\\|ask\\|ignore\\)?$" line)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1059 (let ((cmd (match-string 1 line)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1060 (if (stringp cmd)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1061 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1062 nil 'notice 'active
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1063 (format "Set DCC Chat requests to %S"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1064 (setq erc-dcc-chat-request (intern cmd))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1065 (erc-display-message nil 'notice 'active
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1066 (format "DCC Chat requests are set to %S"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1067 erc-dcc-chat-request)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1068 t)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1069
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1070 (defun erc-cmd-SREQ (line &optional force)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1071 "Set or get the DCC send request flag.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1072 Possible values are: ask, auto, ignore."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1073 (when (string-match "^\\s-*\\(auto\\|ask\\|ignore\\)?$" line)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1074 (let ((cmd (match-string 1 line)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1075 (if (stringp cmd)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1076 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1077 nil 'notice 'active
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1078 (format "Set DCC Send requests to %S"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1079 (setq erc-dcc-send-request (intern cmd))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1080 (erc-display-message nil 'notice 'active
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1081 (format "DCC Send requests are set to %S"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1082 erc-dcc-send-request)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1083 t)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1084
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1085 (defun pcomplete/erc-mode/CREQ ()
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1086 (pcomplete-here '("auto" "ask" "ignore")))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1087 (defalias 'pcomplete/erc-mode/SREQ 'pcomplete/erc-mode/CREQ)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1088
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1089 (defvar erc-dcc-chat-filter-hook '(erc-dcc-chat-parse-output)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1090 "*Hook to run after doing parsing (and possible insertion) of DCC messages.")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1091
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1092 (defvar erc-dcc-chat-mode-map
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1093 (let ((map (make-sparse-keymap)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1094 (define-key map (kbd "RET") 'erc-send-current-line)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1095 (define-key map "\t" 'erc-complete-word)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1096 map)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1097 "Keymap for `erc-dcc-mode'.")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1098
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1099 (defun erc-dcc-chat-mode ()
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1100 "Major mode for wasting time via DCC chat."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1101 (interactive)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1102 (kill-all-local-variables)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1103 (setq mode-line-process '(":%s")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1104 mode-name "DCC-Chat"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1105 major-mode 'erc-dcc-chat-mode
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1106 erc-send-input-line-function 'erc-dcc-chat-send-input-line
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1107 erc-default-recipients '(dcc))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1108 (use-local-map erc-dcc-chat-mode-map)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1109 (run-hooks 'erc-dcc-chat-mode-hook))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1110
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1111 (defun erc-dcc-chat-send-input-line (recipient line &optional force)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1112 "Send LINE to the remote end.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1113 Argument RECIPIENT should always be the symbol dcc, and force
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1114 is ignored."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1115 ;; FIXME: We need to get rid of all force arguments one day!
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1116 (if (eq recipient 'dcc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1117 (process-send-string
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1118 (get-buffer-process (current-buffer)) line)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1119 (error "erc-dcc-chat-send-input-line in %s" (current-buffer))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1120
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1121 (defun erc-dcc-chat (nick &optional pproc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1122 "Open a socket for incoming connections, and send a chat request to the
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1123 other client."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1124 (interactive "sNick: ")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1125 (when (null pproc) (if (processp erc-server-process)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1126 (setq pproc erc-server-process)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1127 (error "Can not find parent process")))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1128 (let* ((sproc (erc-dcc-server "dcc-chat-out"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1129 'erc-dcc-chat-filter
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1130 'erc-dcc-chat-sentinel))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1131 (contact (process-contact sproc)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1132 (erc-dcc-list-add 'OCHAT nick sproc pproc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1133 (process-send-string pproc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1134 (format "PRIVMSG %s :\C-aDCC CHAT chat %s %d\C-a\n"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1135 nick
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1136 (erc-ip-to-decimal (nth 0 contact)) (nth 1 contact)))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1137
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1138 (defvar erc-dcc-from)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1139 (make-variable-buffer-local 'erc-dcc-from)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1140
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1141 (defvar erc-dcc-unprocessed-output)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1142 (make-variable-buffer-local 'erc-dcc-unprocessed-output)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1143
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1144 (defun erc-dcc-chat-setup (entry)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1145 "Setup a DCC chat buffer, returning the buffer."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1146 (let* ((nick (erc-extract-nick (plist-get entry :nick)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1147 (buffer (generate-new-buffer
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1148 (format erc-dcc-chat-buffer-name-format nick)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1149 (proc (plist-get entry :peer))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1150 (parent-proc (plist-get entry :parent)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1151 (erc-setup-buffer buffer)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1152 ;; buffer is now the current buffer.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1153 (erc-dcc-chat-mode)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1154 (setq erc-server-process parent-proc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1155 (setq erc-dcc-from nick)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1156 (setq erc-dcc-entry-data entry)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1157 (setq erc-dcc-unprocessed-output "")
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1158 (setq erc-insert-marker (set-marker (make-marker) (point-max)))
74484
e9bc018298b2 Update from erc--emacs--22
Miles Bader <miles@gnu.org>
parents: 74093
diff changeset
1159 (setq erc-input-marker (make-marker))
68451
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1160 (erc-display-prompt buffer (point-max))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1161 (set-process-buffer proc buffer)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1162 (add-hook 'kill-buffer-hook 'erc-dcc-chat-buffer-killed nil t)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1163 (run-hook-with-args 'erc-dcc-chat-connect-hook proc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1164 buffer))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1165
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1166 (defun erc-dcc-chat-accept (entry parent-proc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1167 "Accept an incoming DCC connection and open a DCC window"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1168 (let* ((nick (erc-extract-nick (plist-get entry :nick)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1169 buffer proc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1170 (setq proc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1171 (funcall erc-dcc-connect-function
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1172 "dcc-chat" nil
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1173 (plist-get entry :ip)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1174 (string-to-number (plist-get entry :port))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1175 entry))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1176 ;; XXX: connected, should we kill the ip/port properties?
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1177 (setq entry (plist-put entry :peer proc))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1178 (setq entry (plist-put entry :parent parent-proc))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1179 (set-process-filter proc 'erc-dcc-chat-filter)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1180 (set-process-sentinel proc 'erc-dcc-chat-sentinel)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1181 (setq buffer (erc-dcc-chat-setup entry))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1182
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1183 (defun erc-dcc-chat-filter (proc str)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1184 (let ((orig-buffer (current-buffer)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1185 (unwind-protect
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1186 (progn
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1187 (set-buffer (process-buffer proc))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1188 (setq erc-dcc-unprocessed-output
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1189 (concat erc-dcc-unprocessed-output str))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1190 (run-hook-with-args 'erc-dcc-chat-filter-hook proc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1191 erc-dcc-unprocessed-output))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1192 (set-buffer orig-buffer))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1193
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1194 (defun erc-dcc-chat-parse-output (proc str)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1195 (save-match-data
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1196 (let ((posn 0)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1197 line)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1198 (while (string-match "\n" str posn)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1199 (setq line (substring str posn (match-beginning 0)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1200 (setq posn (match-end 0))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1201 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1202 nil nil proc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1203 'dcc-chat-privmsg ?n (erc-propertize erc-dcc-from 'face
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1204 'erc-nick-default-face) ?m line))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1205 (setq erc-dcc-unprocessed-output (substring str posn)))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1206
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1207 (defun erc-dcc-chat-buffer-killed ()
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1208 (erc-dcc-chat-close "killed buffer"))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1209
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1210 (defun erc-dcc-chat-close (&optional event)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1211 "Close a DCC chat, removing any associated processes and tidying up
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1212 `erc-dcc-list'"
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1213 (let ((proc (plist-get erc-dcc-entry-data :peer))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1214 (evt (or event "")))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1215 (when proc
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1216 (setq erc-dcc-list (delq erc-dcc-entry-data erc-dcc-list))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1217 (run-hook-with-args 'erc-dcc-chat-exit-hook proc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1218 (delete-process proc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1219 (erc-display-message
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1220 nil 'notice erc-server-process
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1221 'dcc-chat-ended ?n erc-dcc-from ?t (current-time-string) ?e evt)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1222 (setq erc-dcc-entry-data (plist-put erc-dcc-entry-data :peer nil)))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1223
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1224 (defun erc-dcc-chat-sentinel (proc event)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1225 (let ((buf (current-buffer))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1226 (elt (erc-dcc-member :peer proc)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1227 ;; the sentinel is also notified when the connection is opened, so don't
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1228 ;; immediately kill it again
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1229 ;(message "buf %s elt %S evt %S" buf elt event)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1230 (unwind-protect
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1231 (if (string-match "^open from" event)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1232 (erc-dcc-chat-setup elt)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1233 (erc-dcc-chat-close event))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1234 (set-buffer buf))))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1235
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1236 (defun erc-dcc-no-such-nick (proc parsed)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1237 "Detect and handle no-such-nick replies from the IRC server."
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1238 (let* ((elt (erc-dcc-member :nick (second (erc-response.command-args parsed))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1239 :parent proc))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1240 (peer (plist-get elt :peer)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1241 (when (or (and (processp peer) (not (eq (process-status peer) 'open)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1242 elt)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1243 ;; Since we already created an entry before sending the CTCP
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1244 ;; message, we now remove it, if it doesn't point to a process
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1245 ;; which is already open.
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1246 (setq erc-dcc-list (delq elt erc-dcc-list))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1247 (if (processp peer) (delete-process peer)))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1248 nil))
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1249
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1250 (provide 'erc-dcc)
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1251
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1252 ;;; erc-dcc.el ends here
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1253 ;;
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1254 ;; Local Variables:
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1255 ;; indent-tabs-mode: nil
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1256 ;; End:
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1257
fc745b05e928 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-22
Miles Bader <miles@gnu.org>
parents:
diff changeset
1258 ;; arch-tag: cda5a6b3-c510-4dbe-b699-84cccfa04edb