* riece-identity.el (riece-coding-system-for-identity): Moved from
authorueno <ueno>
Mon, 29 Aug 2005 02:55:29 +0000 (02:55 +0000)
committerueno <ueno>
Mon, 29 Aug 2005 02:55:29 +0000 (02:55 +0000)
riece-coding.el.
(riece-decoded-string-for-identity): Ditto.

* riece-300.el (riece-handle-322-message): Decode message per
channel.
(riece-handle-set-topic): Ditto.

* riece-handle.el (riece-handle-notice-message): Decode message
per channel.
(riece-handle-part-message): Ditto.
(riece-handle-kick-message): Ditto.
(riece-handle-topic-message): Ditto.

lisp/ChangeLog
lisp/riece-300.el
lisp/riece-coding.el
lisp/riece-handle.el
lisp/riece-identity.el

index 3facbe6..81f2717 100644 (file)
@@ -1,3 +1,19 @@
+2005-08-29  Daiki Ueno  <ueno@unixuser.org>
+
+       * riece-identity.el (riece-coding-system-for-identity): Moved from
+       riece-coding.el.
+       (riece-decoded-string-for-identity): Ditto.
+
+       * riece-300.el (riece-handle-322-message): Decode message per
+       channel.
+       (riece-handle-set-topic): Ditto.
+
+       * riece-handle.el (riece-handle-notice-message): Decode message
+       per channel.
+       (riece-handle-part-message): Ditto.
+       (riece-handle-kick-message): Ditto.
+       (riece-handle-topic-message): Ditto.
+
 2005-08-28  Daiki Ueno  <ueno@unixuser.org>
 
        * riece-handle.el (riece-handle-privmsg-message): Use
index 109f2f2..ab992c3 100644 (file)
                (cons (cons channel (substring string (match-end 0)))
                      riece-353-message-alist))))))
 
-(defun riece-handle-322-message (prefix number name string)
-  (if (string-match "^\\([^ ]+\\) \\([0-9]+\\) :?" string)
-      (let* ((channel (match-string 1 string))
-            (visible (match-string 2 string))
-            (topic (substring string (match-end 0))))
-       (riece-channel-set-topic (riece-get-channel channel) topic)
-       (let* ((channel-identity (riece-make-identity channel
-                                                     riece-server-name))
-              (buffer (riece-channel-buffer channel-identity)))
-         (riece-insert-info buffer (concat visible " users, topic: "
-                                           topic "\n"))
-         (riece-insert-info
-          (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 "%s: %s users, topic: %s"
-                    (riece-format-identity channel-identity t) visible topic))
-           "\n"))))))
+(defun riece-handle-322-message (prefix number name decoded)
+  (let* ((parameters (riece-split-parameters (riece-decoded-string decoded)))
+        (channel (car parameters))
+        (visible (nth 1 parameters))
+        (channel-identity (riece-make-identity channel riece-server-name))
+        (buffer (riece-channel-buffer channel-identity))
+        topic)
+    (setq parameters (riece-split-parameters
+                     (riece-decoded-string-for-identity decoded
+                                                        channel-identity))
+         topic (nth 1 parameters))
+    (riece-channel-set-topic (riece-get-channel channel) topic)
+    (riece-insert-info buffer (concat visible " users, topic: " topic "\n"))
+    (riece-insert-info
+     (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 "%s: %s users, topic: %s"
+              (riece-format-identity channel-identity t) visible topic))
+      "\n"))))
 
 (defun riece-handle-324-message (prefix number name string)
   (if (string-match "^\\([^ ]+\\) \\([^ ]+\\) " string)
                     mode-string))
            "\n"))))))
 
-(defun riece-handle-set-topic (prefix number name string remove)
-  (if (string-match "^\\([^ ]+\\) :?" string)
-      (let* ((channel (match-string 1 string))
-            (message (substring string (match-end 0)))
-            (channel-identity (riece-make-identity channel riece-server-name))
-            (buffer (riece-channel-buffer channel-identity)))
-       (if remove
-           (riece-channel-set-topic (riece-get-channel channel) nil)
-         (riece-channel-set-topic (riece-get-channel channel) message)
-         (riece-insert-info buffer (concat "Topic: " message "\n"))
-         (riece-insert-info
-          (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 "Topic for %s: %s"
-                    (riece-format-identity channel-identity t)
-                    message))
-           "\n")))
-       (riece-emit-signal 'channel-topic-changed
-                           channel-identity
-                           (unless remove
-                             message)))))
+(defun riece-handle-set-topic (prefix number name decoded remove)
+  (let* ((parameters (riece-split-parameters (riece-decoded-string decoded)))
+        (channel (car parameters))
+        topic
+        (channel-identity (riece-make-identity channel riece-server-name))
+        (buffer (riece-channel-buffer channel-identity)))
+    (if remove
+       (riece-channel-set-topic (riece-get-channel channel) nil)
+      (setq parameters (riece-split-parameters
+                       (riece-decoded-string-for-identity decoded
+                                                          channel-identity))
+           topic (nth 1 parameters))
+      (riece-channel-set-topic (riece-get-channel channel) topic)
+      (riece-insert-info buffer (concat "Topic: " topic "\n"))
+      (riece-insert-info
+       (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 "Topic for %s: %s"
+                (riece-format-identity channel-identity t)
+                topic))
+       "\n")))
+    (riece-emit-signal 'channel-topic-changed channel-identity topic)))
 
 (defun riece-handle-331-message (prefix number name string)
   (riece-handle-set-topic prefix number name string t))
index ec2aa14..3da47a9 100644 (file)
@@ -76,19 +76,6 @@ specifying the coding systems for decoding and encoding respectively."
                       coding-system decoded)
     decoded))
 
-(defun riece-coding-system-for-identity (identity)
-  (let ((alist riece-coding-system-alist)
-       matcher)
-    (catch 'found
-      (while alist
-       (setq matcher (riece-parse-identity (car (car alist))))
-       (if (and (equal (riece-identity-server matcher)
-                       (riece-identity-server identity))
-                (equal (riece-identity-prefix matcher)
-                       (riece-identity-prefix identity)))
-           (throw 'found (cdr (car alist))))
-       (setq alist (cdr alist))))))
-
 ;; The following functions are API used by handler functions.  For the
 ;; meantime DECODED is actually a string (with some text properties).
 ;; In the future, however, the implementation _should_ be changed so
@@ -103,16 +90,6 @@ specifying the coding systems for decoding and encoding respectively."
 
 (defalias 'riece-decoded-string 'identity)
 
-(defun riece-decoded-string-for-identity (decoded identity)
-  "Return the string decoded for IDENTITY."
-  (let ((coding-system (riece-coding-system-for-identity identity)))
-    (if (and coding-system
-            (not (eq (riece-decoded-coding-system string)
-                     coding-system)))
-       (riece-decode-coding-string-1 (riece-decoded-encoded-string decoded)
-                                     coding-system)
-      decoded)))
-
 (provide 'riece-coding)
 
 ;;; riece-coding.el ends here
index dc94fd7..53be6f2 100644 (file)
                                 (riece-format-identity new-identity t)))
                          "\n"))))
 
-(defun riece-handle-privmsg-message (prefix string)
+(defun riece-handle-privmsg-message (prefix decoded)
   (let* ((user (riece-prefix-nickname prefix))
-        (parameters (riece-split-parameters (riece-decoded-string string)))
+        (parameters (riece-split-parameters (riece-decoded-string decoded)))
         (targets (split-string (car parameters) ","))
         message)
     (setq parameters (riece-split-parameters
                      (riece-decoded-string-for-identity
-                      string
+                      decoded
                       (riece-make-identity (car targets) riece-server-name)))
          message (nth 1 parameters))
     (riece-display-message
                         (riece-identity-equal-no-server
                          user riece-real-nickname)))))
 
-(defun riece-handle-notice-message (prefix string)
+(defun riece-handle-notice-message (prefix decoded)
   (let* ((user (if prefix
                   (riece-prefix-nickname prefix)))
-        (parameters (riece-split-parameters string))
+        (parameters (riece-split-parameters (riece-decoded-string decoded)))
         (targets (split-string (car parameters) ","))
-        (message (nth 1 parameters)))
+        message)
+    (setq parameters (riece-split-parameters
+                     (riece-decoded-string-for-identity
+                      decoded
+                      (riece-make-identity (car targets) riece-server-name)))
+         message (nth 1 parameters))
     (if user
        (riece-display-message
         (riece-make-message (riece-make-identity user
          "\n")))
       (setq channels (cdr channels)))))
 
-(defun riece-handle-part-message (prefix string)
+(defun riece-handle-part-message (prefix decoded)
   (let* ((user (riece-prefix-nickname prefix))
-        (parameters (riece-split-parameters string))
+        (parameters (riece-split-parameters (riece-decoded-string decoded)))
         ;; RFC2812 3.2.2 doesn't recommend server to send part
         ;; messages which contain multiple targets.
         (channels (split-string (car parameters) ","))
-        (message (nth 1 parameters))
         (user-identity (riece-make-identity user riece-server-name)))
     (while channels
       (let* ((channel-identity (riece-make-identity (car channels)
                                                    riece-server-name))
-            (buffer (riece-channel-buffer channel-identity)))
+            (buffer (riece-channel-buffer channel-identity))
+            message)
+       (setq parameters (riece-split-parameters
+                         (riece-decoded-string-for-identity decoded
+                                                            channel-identity))
+             message (nth 1 parameters))
        (riece-insert-change
         buffer
         (concat
       (riece-naming-assert-part user (car channels))
       (setq channels (cdr channels)))))
 
-(defun riece-handle-kick-message (prefix string)
+(defun riece-handle-kick-message (prefix decoded)
   (let* ((kicker (riece-prefix-nickname prefix))
-        (parameters (riece-split-parameters string))
+        (parameters (riece-split-parameters (riece-decoded-string decoded)))
         (channel (car parameters))
         (user (nth 1 parameters))
-        (message (nth 2 parameters))
+        message
         (kicker-identity (riece-make-identity kicker riece-server-name))
         (channel-identity (riece-make-identity channel riece-server-name))
         (user-identity (riece-make-identity user riece-server-name)))
+    (setq parameters (riece-split-parameters
+                     (riece-decoded-string-for-identity decoded
+                                                        channel-identity))
+         message (nth 2 parameters))
     (riece-naming-assert-part user channel)
     (let ((buffer (riece-channel-buffer channel-identity)))
       (riece-insert-change
               (riece-format-identity channel-identity)))
       "\n"))))
 
-(defun riece-handle-topic-message (prefix string)
+(defun riece-handle-topic-message (prefix decoded)
   (let* ((user (riece-prefix-nickname prefix))
-        (parameters (riece-split-parameters string))
+        (parameters (riece-split-parameters (riece-decoded-string decoded)))
         (channel (car parameters))
-        (topic (nth 1 parameters))
+        topic
         (user-identity (riece-make-identity user riece-server-name))
         (channel-identity (riece-make-identity channel riece-server-name)))
+    (setq parameters (riece-split-parameters
+                     (riece-decoded-string-for-identity decoded
+                                                        channel-identity))
+         topic (nth 1 parameters))
     (riece-channel-set-topic (riece-get-channel channel) topic)
     (riece-emit-signal 'channel-topic-changed
                       channel-identity topic)
index adada4c..61b9820 100644 (file)
@@ -184,6 +184,29 @@ The rest of arguments are the same as `completing-read'."
 ;;;      (error "Invalid channel name!"))
     identity))
 
+(defun riece-coding-system-for-identity (identity)
+  (let ((alist riece-coding-system-alist)
+       matcher)
+    (catch 'found
+      (while alist
+       (setq matcher (riece-parse-identity (car (car alist))))
+       (if (and (equal (riece-identity-server matcher)
+                       (riece-identity-server identity))
+                (equal (riece-identity-prefix matcher)
+                       (riece-identity-prefix identity)))
+           (throw 'found (cdr (car alist))))
+       (setq alist (cdr alist))))))
+
+(defun riece-decoded-string-for-identity (decoded identity)
+  "Return the string decoded for IDENTITY."
+  (let ((coding-system (riece-coding-system-for-identity identity)))
+    (if (and coding-system
+            (not (eq (riece-decoded-coding-system decoded)
+                     coding-system)))
+       (riece-decode-coding-string-1 (riece-decoded-encoded-string decoded)
+                                     coding-system)
+      decoded)))
+
 (provide 'riece-identity)
 
 ;;; riece-identity.el ends here