* riece-300.el: Rewrite using riece-decode-identity.
authorueno <ueno>
Mon, 23 Jun 2003 06:19:57 +0000 (06:19 +0000)
committerueno <ueno>
Mon, 23 Jun 2003 06:19:57 +0000 (06:19 +0000)
* riece-identity.el (riece-completing-read-identity): Signal an
error when the encoded channel name is not matched with
riece-channel-regexp.

* riece-globals.el (riece-channel-regexp): Moved from
riece-channel.el.
(riece-user-regexp): Moved form riece-user.el.

lisp/ChangeLog
lisp/riece-300.el
lisp/riece-channel.el
lisp/riece-globals.el
lisp/riece-identity.el
lisp/riece-user.el

index 680f097..c528ffa 100644 (file)
@@ -1,5 +1,17 @@
 2003-06-23  Daiki Ueno  <ueno@unixuser.org>
 
+       * riece-300.el: Rewrite using riece-decode-identity.
+
+       * riece-identity.el (riece-completing-read-identity): Signal an
+       error when the encoded channel name is not matched with
+       riece-channel-regexp.
+
+       * riece-globals.el (riece-channel-regexp): Moved from
+       riece-channel.el.
+       (riece-user-regexp): Moved form riece-user.el.
+
+2003-06-23  Daiki Ueno  <ueno@unixuser.org>
+
        * riece-handle.el (riece-handle-join-message): Don't call
        riece-switch-to-channel.
        (riece-handle-part-message): Don't decode message if it is empty.
index d7e60ad..3f52d56 100644 (file)
@@ -54,7 +54,9 @@
             (concat
              (riece-concat-server-name
               (format "%s is (%s) [%s, %s]"
-                      user
+                      (riece-decode-identity
+                       (riece-make-identity user riece-server-name)
+                       t)
                       (riece-strip-user-at-host user-at-host)
                       (if operator
                           "operator"
   (riece-insert-info
    (list riece-dialogue-buffer riece-others-buffer)
    (concat
-    (riece-concat-server-name (concat "Online: " (substring string 1)))
+    (riece-concat-server-name
+     (concat "Online: "
+            (mapconcat
+             (lambda (user)
+               (riece-decode-identity
+                (riece-make-identity user riece-server-name)
+                t))
+             (split-string (substring string 1) " ")
+             "")))
     "\n")))
 
 (defun riece-handle-301-message (prefix number name string)
-  (when (string-match
-        (concat "^\\(" riece-user-regexp "\\) :")
-        string)
-    (let ((user (match-string 1 string))
-         (message (riece-decode-coding-string
-                   (substring string (match-end 0)))))
-      (riece-user-toggle-away user t)
-      (riece-insert-info
-       (list riece-dialogue-buffer riece-others-buffer)
-       (concat
-       (riece-concat-server-name
-        (format "%s is away: %s" user message))
-       "\n")))
+  (if (string-match (concat "^\\(" riece-user-regexp "\\) :") string)
+      (let ((user (match-string 1 string))
+           (message (riece-decode-coding-string
+                     (substring string (match-end 0)))))
+       (riece-user-toggle-away user t)
+       (riece-insert-info
+        (list riece-dialogue-buffer riece-others-buffer)
+        (concat
+         (riece-concat-server-name
+          (format "%s is away: %s"
+                  (riece-decode-identity
+                   (riece-make-identity user riece-server-name)
+                   t)
+                  message))
+         "\n"))))
   (riece-update-status-indicators)
-  (force-mode-line-update t)))
+  (force-mode-line-update t))
 
 (defun riece-handle-305-message (prefix number name string)
   (riece-user-toggle-away riece-real-nickname nil)
        (concat "^\\(" riece-user-regexp
               "\\) \\([^ ]+\\) \\([^ ]+\\) \\* :")
        string)
-      (riece-insert-info
-       (list riece-dialogue-buffer riece-others-buffer)
-       (concat
-       (riece-concat-server-name
-        (format "%s is %s (%s@%s)"
-                (match-string 1 string)
-                (riece-decode-coding-string (substring string (match-end 0)))
-                (match-string 2 string)
-                (match-string 3 string)))
-       "\n"))))
+      (let ((user (match-string 1 string))
+           (name (substring string (match-end 0)))
+           (user-at-host (concat (match-string 2 string) "@"
+                                 (match-string 3 string))))
+       (riece-insert-info
+        (list riece-dialogue-buffer riece-others-buffer)
+        (concat
+         (riece-concat-server-name
+          (format "%s is %s (%s)"
+                  (riece-decode-identity
+                   (riece-make-identity user riece-server-name)
+                   t)
+                  (riece-decode-coding-string name)
+                  user-at-host))
+         "\n")))))
 
 (defun riece-handle-312-message (prefix number name string)
   (if (string-match
 
 (defun riece-handle-313-message (prefix number name string)
   (if (string-match (concat "^" riece-user-regexp) string)
-      (riece-insert-info
-       (list riece-dialogue-buffer riece-others-buffer)
-       (concat
-       (riece-concat-server-name
-        (concat (match-string 0 string) " is an IRC operator"))
-       "\n"))))
+      (let ((user (match-string 0 string)))
+       (riece-insert-info
+        (list riece-dialogue-buffer riece-others-buffer)
+        (concat
+         (riece-concat-server-name
+          (concat (riece-decode-identity
+                   (riece-make-identity user riece-server-name)
+                   t)
+                  " is an IRC operator"))
+         "\n")))))
 
 (defun riece-handle-317-message (prefix number name string)
   (if (string-match
        (concat "^\\(" riece-user-regexp "\\) \\([0-9]+\\) :")
        string)
-      (riece-insert-info
-       (list riece-dialogue-buffer riece-others-buffer)
-       (concat
-       (riece-concat-server-name
-        (format "%s is %s seconds idle"
-                (match-string 1 string)
-                (match-string 2 string)))
-       "\n"))))
+      (let ((user (match-string 1 string))
+           (idle (match-string 2 string)))
+       (riece-insert-info
+        (list riece-dialogue-buffer riece-others-buffer)
+        (concat
+         (riece-concat-server-name
+          (format "%s is %s seconds idle"
+                  (riece-decode-identity
+                   (riece-make-identity user riece-server-name)
+                   t)
+                  idle))
+         "\n")))))
 
 (defun riece-handle-351-message (prefix number name string)
   (if (string-match "\\([^ ]+\\.[^ ]+\\) \\([^ ]+\\) :" string)
             (topic (riece-decode-coding-string
                     (substring string (match-end 0)))))
        (riece-channel-set-topic (riece-get-channel channel) topic)
-       (let ((buffer (riece-channel-buffer-name
-                      (riece-make-identity channel riece-server-name))))
+       (let* ((channel-identity (riece-make-identity channel
+                                                     riece-server-name))
+              (buffer (riece-channel-buffer-name channel-identity)))
          (riece-insert-info buffer (concat visible " users, topic: "
                                            topic "\n"))
          (riece-insert-info
           (concat
            (riece-concat-server-name
             (format "%s users on %s, topic: %s" visible
-                    (riece-decode-coding-string channel) topic))
+                    (riece-decode-identity channel-identity t) topic))
            "\n"))))))
 
 (defun riece-handle-324-message (prefix number name string)
        (while modes
          (riece-channel-toggle-mode channel (car modes) (eq toggle ?+))
          (setq modes (cdr modes)))
-       (let ((buffer (riece-channel-buffer-name
-                      (riece-make-identity channel riece-server-name))))
+       (let* ((channel-identity (riece-make-identity channel
+                                                     riece-server-name))
+              (buffer (riece-channel-buffer-name channel-identity)))
          (riece-insert-info buffer (concat "Mode: " mode-string "\n"))
          (riece-insert-info
           (if (and riece-channel-buffer-mode
             riece-dialogue-buffer)
           (concat
            (riece-concat-server-name
-            (format "Mode for %s: %s" (riece-decode-coding-string channel)
+            (format "Mode for %s: %s"
+                    (riece-decode-identity channel-identity t)
                     mode-string))
            "\n")))
        (riece-update-channel-indicator)
       (let* ((channel (match-string 1 string))
             (message (riece-decode-coding-string
                       (substring string (match-end 0))))
-            (buffer (riece-channel-buffer-name
-                     (riece-make-identity channel riece-server-name))))
+            (channel-identity (riece-make-identity channel riece-server-name))
+            (buffer (riece-channel-buffer-name channel-identity)))
        (if remove
            (riece-channel-set-topic (riece-get-channel channel) nil)
          (riece-channel-set-topic (riece-get-channel channel) message)
           riece-dialogue-buffer)
         (concat
          (riece-concat-server-name
-          (format "Topic for %s: %s" (riece-decode-coding-string channel)
+          (format "Topic for %s: %s"
+                  (riece-decode-identity channel-identity t)
                   message))
          "\n"))
        (riece-update-channel-indicator)))))
   (if (string-match "^\\([^ ]+\\) " string)
       (let* ((channel (match-string 1 string))
             (user (substring string (match-end 0)))
-            (buffer (riece-channel-buffer-name
-                     (riece-make-identity channel riece-server-name))))
+            (channel-identity (riece-make-identity channel riece-server-name))
+            (buffer (riece-channel-buffer-name channel-identity)))
        (riece-insert-info buffer (concat "Inviting " user "\n"))
        (riece-insert-info
         (if (and riece-channel-buffer-mode
         (concat
          (riece-concat-server-name
           (format "Inviting %s to %s" user
-                  (riece-decode-coding-string channel)))
+                  (riece-decode-identity channel-identity t)))
          "\n")))))
 
 (defun riece-handle-352-message (prefix number name string)
             (name (riece-decode-coding-string
                    (substring string (match-end 0))))
             (buffer (riece-channel-buffer-name
-                     (riece-make-identity channel riece-server-name))))
+                     (riece-make-identity channel riece-server-name)))
+            (info (format "%10s = %s (%s) [%s, %s, %s hops, on %s]"
+                          (concat
+                           (if (memq flag '(?@ ?+))
+                               (char-to-string flag)
+                             " ")
+                           (riece-decode-identity
+                            (riece-make-identity nick riece-server-name)
+                            t))
+                          (riece-decode-coding-string name)
+                          (riece-strip-user-at-host
+                           (concat user "@" host))
+                          (if operator
+                              "operator"
+                            "not operator")
+                          (if away
+                              "away"
+                            "not away")
+                          hops
+                          server)))
        (riece-naming-assert-join nick channel)
        (riece-user-toggle-away user away)
        (riece-user-toggle-operator user operator)
-       (riece-insert-info
-        buffer
-        (format "%10s = %s (%s) [%s, %s, %s hops, on %s]\n"
-                (concat
-                 (if (memq flag '(?@ ?+))
-                     (char-to-string flag)
-                   " ")
-                 nick)
-                name
-                (riece-strip-user-at-host
-                 (concat user "@" host))
-                (if operator
-                    "operator"
-                  "not operator")
-                (if away
-                    "away"
-                  "not away")
-                hops
-                server))
+       (riece-insert-info buffer (concat info "\n"))
        (riece-insert-info
         (if (and riece-channel-buffer-mode
                  (not (eq buffer riece-channel-buffer)))
           riece-dialogue-buffer)
         (concat
          (riece-concat-server-name
-          (format "%s %10s = %s (%s) [%s, %s, %s hops, on %s]\n"
-                  (riece-decode-coding-string channel)
-                  (concat
-                   (if (memq flag '(?@ ?+))
-                       (char-to-string flag)
-                     " ")
-                   nick)
-                  name
-                  (riece-strip-user-at-host
-                   (concat user "@" host))
-                  (if operator
-                      "operator"
-                    "not operator")
-                  (if away
-                      "away"
-                    "not away")
-                  hops
-                  server))
+          (concat
+           (riece-decode-identity
+            (riece-make-identity channel riece-server-name)
+            t)
+           " "
+           info))
          "\n"))
        (riece-redisplay-buffers))))
 
index a6f3d6e..cf61f37 100644 (file)
 ;;; Code:
 
 (require 'riece-options)
+(require 'riece-globals)
 (require 'riece-identity)
 
 ;;; String representation of a channel:
-(defconst riece-channel-regexp "^[+&#!]")
-
 (defun riece-channel-p (string)
   "Return t if STRING is a channel.
 \(i.e. it matches `riece-channel-regexp')"
-  (string-match riece-channel-regexp string))
+  (string-match (concat "^" riece-channel-regexp) string))
 
 ;;; Channel object:
 (defun riece-find-channel (name)
index 99f2bb6..a260377 100644 (file)
 
 ;;; Code:
 
+;;; Constants:
+(defconst riece-channel-regexp
+  "\\([+&#]\\|![A-Z0-9]\\{5\\}\\)[^\0\7\r\n ,:]*\\(:[^\0\7\r\n ,:]*\\)?")
+(defconst riece-user-regexp
+  "[][\\\\`_^{|}A-Za-z][][\\\\`_^{|}A-Za-z0-9-]\\{0,8\\}")
+
 ;;; Miscellaneous global variables:
 (defvar riece-process-list nil
   "List of processes opened in the current session.")
index 081d3c3..b054edc 100644 (file)
@@ -159,6 +159,10 @@ RFC2812, 2.2 \"Character codes\" says:
           predicate must-match initial))
         (encoded
          (riece-encode-identity decoded)))
+    (unless (string-match (concat "^\\(" riece-channel-regexp "\\|"
+                                 riece-user-regexp "\\)")
+                         (riece-identity-prefix encoded))
+      (error "Invalid channel name!"))
     (if (and (not (string-match "[ ,]" decoded))
             (string-match "[ ,]" (riece-identity-prefix encoded))
             (not (y-or-n-p (format "The encoded channel name contains illegal character \"%s\".  continue? "
index 811867d..e42c825 100644 (file)
@@ -25,9 +25,6 @@
 
 (require 'riece-identity)
 
-(defconst riece-user-regexp
-  "[][\\\\`_^{|}A-Za-z][][\\\\`_^{|}A-Za-z0-9-]\\{0,8\\}")
-
 ;;; User object:
 (defun riece-find-user (name)
   "Get a user object named NAME from the server buffer."