From: ueno Date: Sun, 1 Jun 2003 20:39:57 +0000 (+0000) Subject: * riece-display.el (riece-configure-windows): Use window-buffer X-Git-Tag: riece-0_0_3~8 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4aef230433c7525d4c04b4163f634f8bc4ceec73;p=elisp%2Friece.git * riece-display.el (riece-configure-windows): Use window-buffer instead of current-buffer. * riece-rdcc.el (riece-rdcc-server-address): Default to nil. (riece-rdcc-ruby-command): New user option. (riece-rdcc-send-program): New user option. (riece-rdcc-decode-address-program): New user option. (riece-rdcc-substitute-variables): New function. (riece-command-dcc-send): Use it. (riece-rdcc-decode-address): Use it. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c4c0e68..b1af093 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,6 +1,20 @@ 2003-06-01 Daiki Ueno + * riece-display.el (riece-configure-windows): Use window-buffer + instead of current-buffer. + + * riece-rdcc.el (riece-rdcc-server-address): Default to nil. + (riece-rdcc-ruby-command): New user option. + (riece-rdcc-send-program): New user option. + (riece-rdcc-decode-address-program): New user option. + (riece-rdcc-substitute-variables): New function. + (riece-command-dcc-send): Use it. + (riece-rdcc-decode-address): Use it. + +2003-06-01 Daiki Ueno + * riece-rdcc.el: New add-on. + * Makefile.am (EXTRA_DIST): Add riece-rdcc.el 2003-06-01 Daiki Ueno diff --git a/lisp/riece-display.el b/lisp/riece-display.el index f497f5b..bd6f0e2 100644 --- a/lisp/riece-display.el +++ b/lisp/riece-display.el @@ -46,7 +46,7 @@ :group 'riece-looks) (defun riece-configure-windows () - (let ((buffer (current-buffer)) + (let ((buffer (window-buffer)) (show-user-list (and riece-user-list-buffer-mode riece-current-channel diff --git a/lisp/riece-rdcc.el b/lisp/riece-rdcc.el index d5217f0..f1a5f95 100644 --- a/lisp/riece-rdcc.el +++ b/lisp/riece-rdcc.el @@ -28,10 +28,49 @@ :prefix "riece-" :group 'riece) -(defcustom riece-rdcc-server-address "127.0.0.1" +(defcustom riece-rdcc-server-address nil "Local address of the DCC server. Only used for sending files." - :type 'vector + :type 'string + :group 'riece-rdcc) + +(defcustom riece-rdcc-ruby-command "ruby" + "Command name for Ruby interpreter." + :type 'string + :group 'riece-rdcc) + +(defcustom riece-rdcc-send-program + '("\ +unless " address " + sock = UDPSocket.new + sock.connect('164.46.176.4', 7) # www.unixuser.org/echo + address = sock.getsockname[4 .. 8].unpack('CCCC').join('.') +end +server = TCPServer.new(address, 0) +puts(\"#{server.addr[3].split(/\\./).collect{|c| c.to_i}.pack('CCCC').unpack('N')[0]} #{server.addr[1]}\") +session = server.accept +if session + total = 0 + File.open(" file ") {|file| + while (bytes = file.read(4096)) + total += bytes.length + puts(\"#{total}\") + session.write(bytes) + end + } + session.close +end +") + "Ruby program to send file with DCC." + :type 'list + :group 'riece-rdcc) + +(defcustom riece-rdcc-decode-address-program + '("\ +puts(\"#{" address " >> 24 & 0xFF}.#{" address " >> 16 & 0xFF}.#{" + address " >> 8 & 0xFF}.#{" address " & 0xFF}\")") + "Ruby program to numeric IP address." + :type 'list :group 'riece-rdcc) (defvar riece-rdcc-requests nil) @@ -40,6 +79,15 @@ Only used for sending files." (defvar riece-rdcc-request-file nil) (defvar riece-rdcc-request-size nil) +(defun riece-rdcc-substitute-variables (program variable value) + (setq program (copy-sequence program)) + (let ((pointer program)) + (while pointer + (setq pointer (memq variable program)) + (if pointer + (setcar pointer value))) + program)) + (defun riece-rdcc-server-filter (process input) (save-excursion (set-buffer (process-buffer process)) @@ -64,30 +112,24 @@ Only used for sending files." (defun riece-command-dcc-send (user file) (interactive (let ((completion-ignore-case t)) - (unless riece-rdcc-server-address - (error "Set riece-rdcc-server-address to your host")) (list (completing-read "User: " (mapcar #'list (riece-get-users-on-server))) (expand-file-name (read-file-name "File: "))))) (let ((process (start-process "DCC" " *DCC*" "ruby" "-rsocket"))) - (process-send-string process (concat "\ -server = TCPServer.new('" riece-rdcc-server-address "', 0) -puts(\"#{server.addr[3].split(/\\./).collect{|c| c.to_i}.pack('cccc').unpack('N')[0]} #{server.addr[1]}\") -session = server.accept -if session - total = 0 - File.open('" file "') {|file| - while (bytes = file.read(1024)) - total += bytes.length - puts(\"#{total}\") - session.write(bytes) - end - } - session.close -end -")) + (process-send-string process + (apply #'concat + (riece-rdcc-substitute-variables + (riece-rdcc-substitute-variables + riece-rdcc-send-program + 'address + (if riece-rdcc-server-address + (concat "'" riece-rdcc-server-address + "'") + "nil")) + 'file + (concat "'" file "'")))) (process-send-eof process) (save-excursion (set-buffer (process-buffer process)) @@ -136,8 +178,12 @@ end (defun riece-rdcc-decode-address (address) (with-temp-buffer - (call-process "ruby" nil t nil "-e" (concat "\ -puts(\"#{" address " >> 24 & 0xFF}.#{" address " >> 16 & 0xFF}.#{" address " >> 8 & 0xFF}.#{" address " & 0xFF}\")")) + (call-process riece-rdcc-ruby-command nil t nil "-e" + (apply #'concat + (riece-rdcc-substitute-variables + riece-rdcc-decode-address-program + 'address + address))) (buffer-substring (point-min) (1- (point-max))))) (defun riece-command-dcc-receive (request file)