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-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
(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))
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
(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
(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)
;;; (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