* riece-rdcc.el: Require 'riece-ctcp.
authorueno <ueno>
Tue, 3 Jun 2003 02:49:22 +0000 (02:49 +0000)
committerueno <ueno>
Tue, 3 Jun 2003 02:49:22 +0000 (02:49 +0000)
(riece-rdcc-insinuate): Add "DCC" to
riece-ctcp-additional-clientinfo.

* riece-ctcp.el (riece-ctcp-additional-clientinfo): New variable.
(riece-command-ctcp-clientinfo): New command.
(riece-ctcp-insinuate): Bind it in riece-dialogue-mode-map.
(riece-handle-ctcp-clientinfo-request): New handler.
(riece-handle-ctcp-clientinfo-response): New handler.

* riece-server.el (riece-open-server): No need to use
get-buffer-create to reuse process buffer.

lisp/ChangeLog
lisp/riece-ctcp.el
lisp/riece-rdcc.el
lisp/riece-server.el

index 035ef5a..9b4084a 100644 (file)
@@ -1,5 +1,20 @@
 2003-06-03  Daiki Ueno  <ueno@unixuser.org>
 
+       * riece-rdcc.el: Require 'riece-ctcp.
+       (riece-rdcc-insinuate): Add "DCC" to
+       riece-ctcp-additional-clientinfo.
+
+       * riece-ctcp.el (riece-ctcp-additional-clientinfo): New variable.
+       (riece-command-ctcp-clientinfo): New command.
+       (riece-ctcp-insinuate): Bind it in riece-dialogue-mode-map.
+       (riece-handle-ctcp-clientinfo-request): New handler.
+       (riece-handle-ctcp-clientinfo-response): New handler.
+
+       * riece-server.el (riece-open-server): No need to use
+       get-buffer-create to reuse process buffer.
+
+2003-06-03  Daiki Ueno  <ueno@unixuser.org>
+
        * riece-rdcc.el (riece-command-dcc-send): Generate new buffer for
        DCC process.
        (riece-command-dcc-receive): Likewise; don't set buffer-file-name.
index d86eb42..b878347 100644 (file)
@@ -28,6 +28,7 @@
 (require 'riece-misc)
 
 (defvar riece-ctcp-ping-time nil)
+(defvar riece-ctcp-additional-clientinfo nil)
 
 (defvar riece-dialogue-mode-map)
 
@@ -36,7 +37,8 @@
   (add-hook 'riece-notice-hook 'riece-handle-ctcp-response)
   (define-key riece-dialogue-mode-map "\C-cv" 'riece-command-ctcp-version)
   (define-key riece-dialogue-mode-map "\C-cp" 'riece-command-ctcp-ping)
-  (define-key riece-dialogue-mode-map "\C-ca" 'riece-command-ctcp-action))
+  (define-key riece-dialogue-mode-map "\C-ca" 'riece-command-ctcp-action)
+  (define-key riece-dialogue-mode-map "\C-cc" 'riece-command-ctcp-clientinfo))
 
 (defun riece-handle-ctcp-request (prefix string)
   (when (and prefix string
               target))
       "\n"))))
 
+(defun riece-handle-ctcp-clientinfo-request (prefix target string)
+  (let ((buffer (if (riece-channel-p target)
+                   (cdr (riece-identity-assoc-no-server
+                         (riece-make-identity target)
+                         riece-channel-buffer-alist))))
+       (user (riece-prefix-nickname prefix)))
+    (riece-send-string
+     (format "NOTICE %s :\1CLIENTINFO %s\1\r\n"
+            user
+            (let (messages)
+              (mapatoms
+               (lambda (atom)
+                 (let ((case-fold-search t))
+                   (if (and (fboundp atom)
+                            (string-match
+                             "riece-handle-ctcp-\\(.+\\)-request"
+                             (symbol-name atom)))
+                       (setq messages
+                             (cons (match-string 1 (symbol-name atom))
+                                   messages))))))
+              (mapconcat #'upcase (append messages
+                                          riece-ctcp-additional-clientinfo)
+                         " "))))
+    (riece-insert-change buffer (format "CTCP CLIENTINFO from %s\n" user))
+    (riece-insert-change
+     (if (and riece-channel-buffer-mode
+             (not (eq buffer riece-channel-buffer)))
+        (list riece-dialogue-buffer riece-others-buffer)
+       riece-dialogue-buffer)
+     (concat
+      (riece-concat-server-name
+       (format "CTCP CLIENTINFO from %s (%s) to %s"
+              user
+              (riece-strip-user-at-host (riece-prefix-user-at-host prefix))
+              target))
+      "\n"))))
+
 (defun riece-handle-ctcp-action-request (prefix target string)
   (let ((buffer (if (riece-channel-p target)
                    (cdr (riece-identity-assoc-no-server
               elapsed))
       "\n"))))
 
+(defun riece-handle-ctcp-clientinfo-response (prefix target string)
+  (riece-insert-change
+   (list riece-dialogue-buffer riece-others-buffer)
+   (concat
+    (riece-concat-server-name
+     (format "CTCP CLIENTINFO for %s (%s) = %s"
+            (riece-prefix-nickname prefix)
+            (riece-strip-user-at-host (riece-prefix-user-at-host prefix))
+            string))
+    "\n")))
+
 (defun riece-command-ctcp-version (user)
   (interactive
    (let ((completion-ignore-case t))
   (riece-send-string (format "PRIVMSG %s :\1PING\1\r\n" user))
   (setq riece-ctcp-ping-time (current-time)))
 
+(defun riece-command-ctcp-clientinfo (user)
+  (interactive
+   (let ((completion-ignore-case t))
+     (list (completing-read
+           "Channel/User: "
+           (mapcar #'list (riece-get-users-on-server))))))
+  (riece-send-string (format "PRIVMSG %s :\1CLIENTINFO\1\r\n" user)))
+
 (defun riece-command-ctcp-action (channel action)
   (interactive
    (list (if current-prefix-arg
index ae16c9d..48c3809 100644 (file)
@@ -27,6 +27,7 @@
 (require 'riece-misc)
 (require 'riece-channel)
 (require 'riece-identity)
+(require 'riece-ctcp)                  ;for riece-ctcp-additional-clientinfo
 
 (defgroup riece-rdcc nil
   "DCC implementation using ruby"
@@ -294,6 +295,7 @@ puts(\"#{" address " >> 24 & 0xFF}.#{" address " >> 16 & 0xFF}.#{"
 
 (defvar riece-dialogue-mode-map)
 (defun riece-rdcc-insinuate ()
+  (add-to-list 'riece-ctcp-additional-clientinfo "DCC" t)
   (add-hook 'riece-ctcp-dcc-request-hook 'riece-handle-dcc-request)
   (define-key riece-dialogue-mode-map "\C-ds" 'riece-command-dcc-send)
   (define-key riece-dialogue-mode-map "\C-dr" 'riece-command-dcc-receive))
index 9a47c35..4ff95c7 100644 (file)
@@ -112,10 +112,9 @@ the `riece-server-keyword-map' variable."
           (coding-system-for-write 'binary)
           (process
            (funcall function "IRC"
-                    (get-buffer-create
-                     (if server-name
-                         (format " *IRC*%s" server-name)
-                       " *IRC*"))
+                    (if server-name
+                        (format " *IRC*%s" server-name)
+                      " *IRC*")
                     host service)))
       (riece-reset-process-buffer process)
       (with-current-buffer (process-buffer process)