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 Daiki Ueno <ueno@unixuser.org>
+
+ * 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 <bg66@koka-in.org>
* riece-log.el (riece-log-get-directory): Follow the change of
(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)))))
(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)))))
(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
(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
(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))))))