* riece-rdcc.el (riece-rdcc-format-size): New function.
authorueno <ueno>
Wed, 22 Oct 2003 08:32:57 +0000 (08:32 +0000)
committerueno <ueno>
Wed, 22 Oct 2003 08:32:57 +0000 (08:32 +0000)
(riece-handle-dcc-request): Use it.

lisp/ChangeLog
lisp/riece-rdcc.el

index 8dc0a98..eeebf5e 100644 (file)
@@ -4,6 +4,9 @@
        accepting a connection.
        (riece-command-dcc-send): Use riece-completing-read-identity; take
        an identity object in the 1st argument.
+       (riece-rdcc-format-size): New function.
+       (riece-handle-dcc-request): Use it.
+
        * riece-ndcc.el (riece-command-dcc-send): Use
        riece-completing-read-identity; take an identity object in the 1st
        argument.
index ee97197..b54eb3b 100644 (file)
@@ -263,6 +263,17 @@ puts(\"#{" address " >> 24 & 0xFF}.#{" address " >> 16 & 0xFF}.#{"
     (set-process-filter process #'riece-rdcc-filter)
     (set-process-sentinel process #'riece-rdcc-sentinel)))
 
+(defun riece-rdcc-format-size (size)
+  (if (< size 1024)
+      (format "%0.1fB" size)
+    (setq size (/ size 1024.0))
+    (if (< size 1024)
+       (format "%0.1fKB" size)
+      (setq size (/ size 1024.0))
+      (if (< size 1024)
+         (format "%0.1fMB" size)
+       (format "%0.1fGB" (/ size 1024.0))))))
+
 (defun riece-handle-dcc-request (prefix target message)
   (let ((case-fold-search t))
     (when (string-match
@@ -279,7 +290,14 @@ puts(\"#{" address " >> 24 & 0xFF}.#{" address " >> 16 & 0xFF}.#{"
        (setq riece-rdcc-requests
              (cons (list user file address port size)
                    riece-rdcc-requests))
-       (riece-insert-change buffer (format "DCC SEND from %s\n" user))
+       (message "%s"
+                (substitute-command-keys
+                 (format
+                  "DCC SEND from %s, \\[riece-command-dcc-receive] to receive"
+                  user)))
+       (riece-insert-change buffer (format "DCC SEND from %s: %s (%s)\n"
+                                           user file
+                                           (riece-rdcc-format-size size)))
        (riece-insert-change
         (if (and riece-channel-buffer-mode
                  (not (eq buffer riece-channel-buffer)))
@@ -287,11 +305,13 @@ puts(\"#{" address " >> 24 & 0xFF}.#{" address " >> 16 & 0xFF}.#{"
           riece-dialogue-buffer)
         (concat
          (riece-concat-server-name
-          (format "DCC SEND from %s (%s) to %s"
+          (format "DCC SEND from %s (%s) to %s: %s (%s)"
                   user
                   (riece-strip-user-at-host
                    (riece-prefix-user-at-host prefix))
-                  (riece-decode-coding-string target)))
+                  (riece-decode-coding-string target)
+                  file
+                  (riece-rdcc-format-size size)))
          "\n")))
       t)))