From: ueno Date: Thu, 23 Oct 2003 02:07:24 +0000 (+0000) Subject: * riece-identity.el (riece-identity-member): Take an optional 3rd X-Git-Tag: riece-0_1_5~7 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da90e3c6815f79db698d4fd073311d5f8dd922d9;p=elisp%2Friece.git * riece-identity.el (riece-identity-member): Take an optional 3rd argument to instruct to use riece-identity-equal-no-server. (riece-identity-assoc): Ditto. * riece-display.el (riece-update-user-list-buffer): Use riece-channel-operator-p and riece-channel-speaker-p. * riece-button.el (riece-user-button-set-operators): Use riece-channel-operator-p. (riece-user-button-set-speakers): Use riece-channel-speaker-p. * riece-channel.el (riece-channel-intern-user): New function. (riece-channel-toggle-operator): Use it. (riece-channel-toggle-speaker): Use it. (riece-channel-operator-p): New function. (riece-channel-speaker-p): New function. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b4e3438..87bb64b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,22 @@ +2003-10-23 Daiki Ueno + + * riece-identity.el (riece-identity-member): Take an optional 3rd + argument to instruct to use riece-identity-equal-no-server. + (riece-identity-assoc): Ditto. + + * riece-display.el (riece-update-user-list-buffer): Use + riece-channel-operator-p and riece-channel-speaker-p. + + * riece-button.el (riece-user-button-set-operators): Use + riece-channel-operator-p. + (riece-user-button-set-speakers): Use riece-channel-speaker-p. + + * riece-channel.el (riece-channel-intern-user): New function. + (riece-channel-toggle-operator): Use it. + (riece-channel-toggle-speaker): Use it. + (riece-channel-operator-p): New function. + (riece-channel-speaker-p): New function. + 2003-10-23 OHASHI Akira * riece-log.el (riece-log-get-directory): Follow the change of diff --git a/lisp/riece-button.el b/lisp/riece-button.el index f75ac2f..6a112c2 100644 --- a/lisp/riece-button.el +++ b/lisp/riece-button.el @@ -127,19 +127,14 @@ This function is used as a callback for a channel button." (delq nil (mapcar (lambda (identity) - (riece-with-server-buffer (riece-identity-server - riece-current-channel) - (if (and (member - (riece-identity-prefix identity) - (riece-channel-get-users - (riece-identity-prefix - riece-current-channel))) - (not (member - (riece-identity-prefix identity) - (riece-channel-get-operators - (riece-identity-prefix - riece-current-channel))))) - identity))) + (unless (riece-channel-operator-p + (riece-with-server-buffer + (riece-identity-server + riece-current-channel) + (riece-get-channel (riece-identity-prefix + riece-current-channel))) + (riece-identity-prefix identity)) + identity)) group))) (riece-command-set-operators (mapcar #'riece-identity-prefix group))))) @@ -159,24 +154,23 @@ This function is used as a callback for a channel button." (delq nil (mapcar (lambda (identity) - (riece-with-server-buffer (riece-identity-server - riece-current-channel) - (if (and (member - (riece-identity-prefix identity) - (riece-channel-get-users - (riece-identity-prefix - riece-current-channel))) - (not (member - (riece-identity-prefix identity) - (riece-channel-get-operators - (riece-identity-prefix - riece-current-channel)))) - (not (member - (riece-identity-prefix identity) - (riece-channel-get-speakers - (riece-identity-prefix - riece-current-channel))))) - identity))) + (unless (or (riece-channel-operator-p + (riece-with-server-buffer + (riece-identity-server + riece-current-channel) + (riece-get-channel + (riece-identity-prefix + riece-current-channel))) + (riece-identity-prefix identity)) + (riece-channel-speaker-p + (riece-with-server-buffer + (riece-identity-server + riece-current-channel) + (riece-get-channel + (riece-identity-prefix + riece-current-channel))) + (riece-identity-prefix identity))) + identity)) group))) (riece-command-set-speakers (mapcar #'riece-identity-prefix group))))) diff --git a/lisp/riece-channel.el b/lisp/riece-channel.el index 5805faf..3602dea 100644 --- a/lisp/riece-channel.el +++ b/lisp/riece-channel.el @@ -221,26 +221,44 @@ the channel key, respectively." (if (setq user (car (member user users))) (riece-channel-set-users channel (delq user users)))))) +(defun riece-channel-intern-user (channel user) + (unless (setq user (car (member user (riece-channel-users channel)))) + (if riece-debug + (message "%s is not a member of channel" user))) + user) + (defun riece-channel-toggle-operator (name user flag) "Add or remove an operator to channel." (let* ((channel (riece-get-channel name)) (operators (riece-channel-operators channel))) + (setq user (riece-channel-intern-user channel user)) (if flag - (unless (member user operators) + (unless (memq user operators) (riece-channel-set-operators channel (cons user operators))) - (if (setq user (car (member user operators))) + (if (setq user (car (memq user operators))) (riece-channel-set-operators channel (delq user operators)))))) (defun riece-channel-toggle-speaker (name user flag) "Add or remove an speaker to channel." (let* ((channel (riece-get-channel name)) (speakers (riece-channel-speakers channel))) + (setq user (riece-channel-intern-user channel user)) (if flag - (unless (member user speakers) + (unless (memq user speakers) (riece-channel-set-speakers channel (cons user speakers))) - (if (setq user (car (member user speakers))) + (if (setq user (car (memq user speakers))) (riece-channel-set-speakers channel (delq user speakers)))))) +(defun riece-channel-operator-p (channel user) + "Return non-nil, if USER has operator privileges in channel." + (memq (riece-channel-intern-user channel user) + (riece-channel-operators channel))) + +(defun riece-channel-speaker-p (channel user) + "Return non-nil, if USER is allowed to speak in channel." + (memq (riece-channel-intern-user channel user) + (riece-channel-speakers channel))) + (provide 'riece-channel) ;;; riece-channel.el ends here diff --git a/lisp/riece-display.el b/lisp/riece-display.el index b353474..fd1e827 100644 --- a/lisp/riece-display.el +++ b/lisp/riece-display.el @@ -50,35 +50,29 @@ Local to the buffer in `riece-buffer-list'.") (set-buffer riece-user-list-buffer) (if (and riece-current-channel (riece-channel-p (riece-identity-prefix riece-current-channel))) - (let (users operators speakers) - (with-current-buffer (process-buffer (riece-server-process - (riece-identity-server - riece-current-channel))) - (setq users - (riece-channel-get-users - (riece-identity-prefix riece-current-channel)) - operators - (riece-channel-get-operators - (riece-identity-prefix riece-current-channel)) - speakers - (riece-channel-get-speakers - (riece-identity-prefix riece-current-channel)))) - (let ((inhibit-read-only t) - buffer-read-only) - (erase-buffer) - (while users - (insert (if (member (car users) operators) - "@" - (if (member (car users) speakers) - "+" - " ")) - (riece-format-identity - (riece-make-identity (car users) - (riece-identity-server - riece-current-channel)) - t) - "\n") - (setq users (cdr users)))))))) + (let* ((channel + (with-current-buffer (process-buffer (riece-server-process + (riece-identity-server + riece-current-channel))) + (riece-get-channel (riece-identity-prefix + riece-current-channel)))) + (users (riece-channel-users channel)) + (inhibit-read-only t) + buffer-read-only) + (erase-buffer) + (while users + (insert (if (riece-channel-operator-p channel (car users)) + "@" + (if (riece-channel-speaker-p channel (car users)) + "+" + " ")) + (riece-format-identity + (riece-make-identity (car users) + (riece-identity-server + riece-current-channel)) + t) + "\n") + (setq users (cdr users))))))) (defun riece-update-channel-list-buffer () (save-excursion diff --git a/lisp/riece-identity.el b/lisp/riece-identity.el index ee7e728..c01c454 100644 --- a/lisp/riece-identity.el +++ b/lisp/riece-identity.el @@ -77,26 +77,29 @@ RFC2812, 2.2 \"Character codes\" says: (set-case-table old-table)))) (defun riece-identity-equal-no-server (prefix1 prefix2) - "Return t, if IDENT1 and IDENT2 is equal without server." + "Return t, if IDENT1 and IDENT2 is equal without server part." (equal (riece-identity-canonicalize-prefix prefix1) (riece-identity-canonicalize-prefix prefix2))) -(defun riece-identity-member (elt list) +(defun riece-identity-member (elt list &optional no-server) "Return non-nil if an identity ELT is an element of LIST." (catch 'found (while list - (if (and (vectorp (car list)) ;needed because - ;riece-current-channels - ;contains nil. - (riece-identity-equal (car list) elt)) + (if (and (car list) ;needed because riece-current-channels + ;contains nil. + (if no-server + (riece-identity-equal-no-server (car list) elt) + (riece-identity-equal (car list) elt))) (throw 'found list) (setq list (cdr list)))))) -(defun riece-identity-assoc (elt alist) +(defun riece-identity-assoc (elt alist &optional no-server) "Return non-nil if an identity ELT matches the car of an element of ALIST." (catch 'found (while alist - (if (riece-identity-equal (car (car alist)) elt) + (if (if no-server + (riece-identity-equal-no-server (car (car alist)) elt) + (riece-identity-equal (car (car alist)) elt)) (throw 'found (car alist)) (setq alist (cdr alist))))))