Commit c9b70898 authored by David Kågedal's avatar David Kågedal
Browse files

Använd protokollversion 9 för sessioninfo + lite till tror jag

parent 2baeff47
Fri Aug 9 01:18:34 1996 David Kgedal <davidk@lysator.liu.se>
* vars.el.in (kom-idle-hide): Ny variabel.
* commands1.el (lyskom-combine-username): Hantera username utan
"%".
(lyskom-insert-deferred-session-info): Ny funktion.
(lyskom-who-is-on-9): Frdrj utskrifter av static-session-info.
* swedish-strings.el (lyskom-parse-command-and-execute): Bort med
swascii och lite kosmetiska fixar.
(kom-expand-slow-command): Ny funktion.
......@@ -17,6 +24,53 @@ Thu Aug 8 12:33:03 1996 David Byers <davby@sen2.ida.liu.se>
ndringar har gjorts genom att stta bufferten rtt. Fixade en
kosmesisk bug som dk upp nr den riktiga blev rttad.
Thu Aug 8 00:04:41 1996 David Kgedal <davidk@lysator.liu.se>
* commands1.el (lyskom-combine-username): Ny funktion.
* services.el (initiate-get-static-session-info): Anvnd cache.
* cache.el (cache-get-static-session-info): Ny funktion.
(cache-add-static-session-info): Ny funktion.
(cache-del-static-session-info): Ny funktion.
* vars.el.in (lyskom-static-session-info-cache): Ny variabel.
* deferred-insert.el (lyskom-replace-deferred): Anvnd en sparad
kopia av lyskom-last-viewed.
* swedish-strings.el (lyskom-strings): Infrde session-status-9
och session-is-invisible.
* commands1.el (lyskom-who-is-on-8): Gamla kom-who-is-on.
(kom-who-is-on): Numera en dispatcher till de riktiga
funktionerna.
(lyskom-who-is-on-9): Ny funktion.
(lyskom-status-session-8): Bytte namn frn
lyskom-status-session-2.
(lyskom-status-session-9): Ny funktion.
* swedish-strings.el (lyskom-strings): La till who-is-active,
who-is-active-last-minutes och showing-invisibles.
* english-strings.el (lyskom-strings): Dito.
* komtypes.el (def-komtype): Nytt makro. Det kommer att flyttas
till macros.el senare.
(session-flags): Ny typ.
(dynamic-session-info): Ny typ.
(static-session-info): Ny typ.
* parse.el (lyskom-parse-session-flags): Ny funktion.
(lyskom-parse-dynamic-session-info): Ny funktion.
(lyskom-parse-dynamic-session-info-list): Ny funktion.
* services.el (initiate-who-is-on-dynamic): Ny funktion.
(initiate-get-static-session-info): Ny funktion.
* lyskom-rest.el (lyskom-update-prompt): Kolla om
lyskom-executing-command r satt.
Wed Aug 7 20:35:59 1996 David Kgedal <davidk@lysator.liu.se>
* Makefile: Frbttrade nnu mer.
......
......@@ -405,7 +405,7 @@ converted, before insertion."
"Print a message if the user was waiting. Change the prompt. run hooks."
(if (and (not lyskom-dont-change-prompt) ;We shall change it
(not lyskom-executing-command)) ;We have time to do it.
(lyskom-update-prompt))
(lyskom-update-prompt))
(let ((no-message nil))
(run-hooks 'lyskom-new-text-hook)
......
......@@ -217,6 +217,28 @@ otherwise return nil"
(setq marks (cdr marks))))))
;;; ================================================================
;;; Static-session-info cache
(defun cache-get-static-session-info (session)
"Get static-session-info for session SESSION, or nil if nothing is cached."
(let ((tx (cache-assoc session lyskom-static-session-info-cache)))
(cond
((static-session-info-p tx) tx))))
(defun cache-add-static-session-info (session info)
"Insert INFO in the cache."
(cache-add session info 'lyskom-static-session-info-cache))
(defun cache-del-static-session-info (session)
"Delete a text from the cache. Args: SESSION."
(cache-del session 'lyskom-static-session-info-cache))
;;; ================================================================
;;; who-info cache
......
......@@ -1487,9 +1487,17 @@ If MARK-NO == 0, review all marked texts."
;;; Rewritten by: David K}gedal
(def-kom-command kom-who-is-on ()
(def-kom-command kom-who-is-on (&optional arg)
"Display a list of all connected users."
(interactive)
(interactive "P")
(if (>= (car (cdr (assq 'protocol-version lyskom-server-supports))) 9)
(lyskom-who-is-on-9 arg)
(lyskom-who-is-on-8)))
(defun lyskom-who-is-on-8 ()
"Display a list of all connected users.
Uses Protocol A version 8 calls"
(let* ((who-info-list (blocking-do 'who-is-on))
(who-list (sort (listify-vector who-info-list)
(function (lambda (who1 who2)
......@@ -1542,6 +1550,107 @@ If MARK-NO == 0, review all marked texts."
"\n"))
(lyskom-insert (lyskom-format 'total-users total-users))))
(defun lyskom-who-is-on-9 (arg)
"Display a list of all connected users.
Uses Protocol A version 9 calls"
(let* ((wants-invisibles (and (numberp arg) (< arg 0)))
(idle-hide (if (numberp arg) (abs arg) kom-idle-hide))
(who-info-list (blocking-do 'who-is-on-dynamic
't wants-invisibles (* idle-hide 60)))
(who-list (sort (listify-vector who-info-list)
(function
(lambda (who1 who2)
(< (dynamic-session-info->session who1)
(dynamic-session-info->session who2))))))
(total-users (length who-list))
(session-width (1+ (length (int-to-string
(dynamic-session-info->session
(nth (1- total-users) who-list))))))
(format-string-1 (lyskom-info-line-format-string
session-width "P" "M"))
(format-string-2 (lyskom-info-line-format-string
session-width "D" "s"))
(lyskom-default-conf-string 'not-present-anywhere))
(if (zerop idle-hide)
(lyskom-insert (lyskom-get-string 'who-is-active-all))
(lyskom-format-insert 'who-is-active-last-minutes idle-hide))
(if wants-invisibles
(lyskom-insert (lyskom-get-string 'showing-invisibles)))
(lyskom-format-insert format-string-2
""
(lyskom-get-string 'lyskom-name)
(lyskom-get-string 'is-in-conf))
(if kom-show-where-and-what
(lyskom-format-insert format-string-2
""
(lyskom-get-string 'from-machine)
(lyskom-get-string 'is-doing)))
(lyskom-insert
(concat (make-string (- (lyskom-window-width) 2) ?-) "\n"))
(while who-list
(let* ((who-info (car who-list))
(session-no (dynamic-session-info->session who-info))
(session-no-s (int-to-string session-no))
(my-session (if (= lyskom-session-no session-no)
"*"
" ")))
(lyskom-format-insert
format-string-1
(concat session-no-s my-session)
(dynamic-session-info->person who-info)
(or (dynamic-session-info->working-conference who-info)
(lyskom-get-string 'not-present-anywhere)))
(if kom-show-where-and-what
(let* (static defer-info username)
(cond (kom-deferred-printing
(setq static (cache-get-static-session-info session-no))
(if static
(setq username
(lyskom-combine-username
(static-session-info->username static)
(static-session-info->ident-user static)
(static-session-info->hostname static)))
(setq defer-info
(lyskom-create-defer-info
'get-static-session-info
session-no
'lyskom-insert-deferred-session-info
(make-marker)
(length lyskom-defer-indicator)
"%#1s"))
(setq username defer-info)))
(t
(setq static
(blocking-do 'get-static-session-info session-no))
(setq username (lyskom-combine-username
(static-session-info->username static)
(static-session-info->ident-user static)
(static-session-info->hostname static)))))
(lyskom-format-insert
format-string-2
""
username
(concat "(" (dynamic-session-info->what-am-i-doing who-info)
")"))))
(setq who-list (cdr who-list))))
(lyskom-insert (concat (make-string (- (lyskom-window-width) 2) ?-)
"\n"))
(lyskom-insert (lyskom-format 'total-users total-users))))
(defun lyskom-insert-deferred-session-info (session-info defer-info)
(lyskom-replace-deferred defer-info
(lyskom-combine-username
(static-session-info->username session-info)
(static-session-info->ident-user session-info)
(static-session-info->hostname session-info))))
;;; =====================================================================
;;; Lista klienter - List clients
;;; Author: David Kågedal
......@@ -1638,9 +1747,7 @@ If MARK-NO == 0, review all marked texts."
(defun lyskom-return-username (who-info)
"Takes the username from the WHO-INFO and returns it on a better format."
(let* ((username (if (eq 'SESSION-INFO who-info) ; Weird...
(session-info->username who-info)
(who-info->username who-info)))
(let* ((username (who-info->username who-info))
(type (or
(string-match "\\([^%@.]+\\)%\\(.+\\)@\\([^%@.]+\\)" username)
(string-match "\\([^%@.]+\\)@\\([^%@.]+\\)" username))))
......@@ -1665,7 +1772,19 @@ If MARK-NO == 0, review all marked texts."
(concat name "@" gott rest)
(concat name "@" sent " (" gott rest ")")))
username)))
(defun lyskom-combine-username (username identname hostname)
"Return a description of from where a user is logged in."
;; Ignore ident info for now
(if (string-match "\\(.*\\)%\\(.*\\)" username)
(let ((user (substring username (match-beginning 1) (match-end 1)))
(uhost (substring username (match-beginning 2) (match-end 2))))
(if (string= uhost hostname)
(concat user "@" hostname)
(concat username "@" hostname)))
(concat username "@" hostname)))
;;; ================================================================
;;; Status (för) Session - Status (for a) session
......@@ -1681,52 +1800,109 @@ about or a single session number."
((numberp arg) (list arg)))
(lyskom-read-session-no
(lyskom-get-string 'status-for-session))))
(who-info (listify-vector (blocking-do 'who-is-on))))
(mapcar (function (lambda (x) (lyskom-status-session x who-info)))
sessions)))
who-info)
(if (>= (car (cdr (assq 'protocol-version lyskom-server-supports))) 9)
(progn
(setq who-info (listify-vector
(blocking-do 'who-is-on-dynamic t t 0)))
(mapcar (function (lambda (x) (lyskom-status-session-9 x who-info)))
sessions))
(setq who-info (listify-vector (blocking-do 'who-is-on)))
(mapcar (function (lambda (x) (lyskom-status-session-8 x who-info)))
sessions))))
(defun lyskom-status-session (sid who-info)
(defun lyskom-status-session-8 (sid who-info-list)
"Show session status for session SID. WHO-INFO is a list of
WHO-INFOS that are potential sessions."
(while who-info-list
(if (eq sid (who-info->connection (car who-info-list)))
(let* ((info (car who-info-list))
(client (if kom-deferred-printing
(lyskom-create-defer-info
'get-client-name
(who-info->connection info)
'lyskom-deferred-client-1
nil nil nil
(who-info->connection info))
(blocking-do-multiple
((name (get-client-name
(who-info->connection info)))
(version (get-client-version
(who-info->connection info))))
(concat name " " version)))))
(lyskom-format-insert
(lyskom-get-string 'session-status)
(who-info->connection info)
(who-info->pers-no info)
(lyskom-return-username info)
(if (not (eq (who-info->working-conf info) 0))
(who-info->working-conf info)
(lyskom-get-string 'not-present-anywhere))
(let ((string (if (string-match "^\\(.*[^.]\\)\\.*$"
(who-info->doing-what info))
(match-string 1 (who-info->doing-what info))
(who-info->doing-what info))))
(if (string= string "")
(lyskom-get-string 'unknown-doing-what)
string))
client
(if (not (eq (who-info->working-conf info) 0))
(lyskom-get-string 'doing-where-conn)
(lyskom-get-string 'doing-nowhere-conn)))))
(setq who-info-list (cdr who-info-list))))
(defun lyskom-status-session-9 (sid who-info-list)
"Show session status for session SID. WHO-INFO is a list of
WHO-INFOS that are potential sessions."
(while who-info
(if (eq sid (who-info->connection (car who-info)))
(lyskom-status-session-2 (car who-info)))
(setq who-info (cdr who-info))))
(defun lyskom-status-session-2 (info)
"Internal to lyskom-status-session"
(let ((client (if kom-deferred-printing
(lyskom-create-defer-info 'get-client-name
(who-info->connection info)
'lyskom-deferred-client-1
nil nil nil
(who-info->connection info))
(blocking-do-multiple
((name (get-client-name
(who-info->connection info)))
(version (get-client-version
(who-info->connection info))))
(concat name " " version)))))
(lyskom-format-insert (lyskom-get-string 'session-status)
(who-info->connection info)
(who-info->pers-no info)
(lyskom-return-username info)
(if (not (eq (who-info->working-conf info) 0))
(who-info->working-conf info)
(lyskom-get-string 'not-present-anywhere))
(let ((string
(if (string-match "^\\(.*[^.]\\)\\.*$"
(who-info->doing-what info))
(match-string 1 (who-info->doing-what info))
(who-info->doing-what info))))
(if (string= string "")
(lyskom-get-string 'unknown-doing-what)
string))
client
(if (not (eq (who-info->working-conf info) 0))
(lyskom-get-string 'doing-where-conn)
(lyskom-get-string 'doing-nowhere-conn)))))
(let ((static (blocking-do 'get-static-session-info sid)))
(while who-info-list
(if (eq sid (dynamic-session-info->session (car who-info-list)))
(let* ((info (car who-info-list))
(client (if kom-deferred-printing
(lyskom-create-defer-info
'get-client-name
(dynamic-session-info->session info)
'lyskom-deferred-client-1
nil nil nil
(dynamic-session-info->session info))
(blocking-do-multiple
((name (get-client-name
(dynamic-session-info->session info)))
(version
(get-client-version
(dynamic-session-info->session info))))
(concat name " " version)))))
(lyskom-format-insert
(lyskom-get-string 'session-status-9)
(dynamic-session-info->session info)
(dynamic-session-info->person info)
(lyskom-combine-username (static-session-info->username static)
(static-session-info->ident-user static)
(static-session-info->hostname static))
(if (not (eq (dynamic-session-info->working-conference info) 0))
(dynamic-session-info->working-conference info)
(lyskom-get-string 'not-present-anywhere))
(let ((string (if (string-match
"^\\(.*[^.]\\)\\.*$"
(dynamic-session-info->what-am-i-doing info))
(match-string
1 (dynamic-session-info->what-am-i-doing info))
(dynamic-session-info->what-am-i-doing info))))
(if (string= string "")
(lyskom-get-string 'unknown-doing-what)
string))
client
(if (not (eq (dynamic-session-info->working-conference info) 0))
(lyskom-get-string 'doing-where-conn)
(lyskom-get-string 'doing-nowhere-conn))
(lyskom-format-time
(static-session-info->connection-time static))
(/ (dynamic-session-info->idle-time info) 60))
(if (session-flags->invisible (dynamic-session-info->flags info))
(lyskom-insert (lyskom-get-string 'session-is-invisible)))))
(setq who-info-list (cdr who-info-list)))))
;;; ================================================================
......
......@@ -38,7 +38,8 @@
;;; 1. Insert some temporary text. Use the variable
;;; `lyskom-defer-indicator' as a placeholder.
;;;
;;; 2. Create a defer-info-structure with the following parameters
;;; 2. Create a defer-info-structure by calling
;;; `lyskom-create-defe-info' with the following parameters
;;;
;;; SERVER-CALL - the call to get the data (initate-get-*)
;;; CALL-ARG - the argument for the server call. This is
......@@ -88,7 +89,8 @@
del-chars format
&optional data)
(cons 'DEFER-INFO
(vector server-call call-par handler pos del-chars format data)))
(vector server-call call-par handler pos del-chars format data
lyskom-last-viewed)))
(defun lyskom-defer-info-p (obj)
(and (consp obj)
......@@ -101,6 +103,7 @@
(defun defer-info->del-chars (di) (aref (cdr di) 4))
(defun defer-info->format (di) (aref (cdr di) 5))
(defun defer-info->data (di) (aref (cdr di) 6))
(defun defer-info->last-viewed (di) (aref (cdr di) 7))
(defun set-defer-info->server-call (di x) (aset (cdr di) 0 x))
(defun set-defer-info->call-par (di x) (aset (cdr di) 1 x))
......@@ -109,11 +112,13 @@
(defun set-defer-info->del-chars (di x) (aset (cdr di) 4 x))
(defun set-defer-info->format (di x) (aset (cdr di) 5 x))
(defun set-defer-info->data (di x) (aset (cdr di) 6 x))
(defun set-defer-info->last-viewed (di x) (aset (cdr di) 7 x))
(defun lyskom-defer-insertion (defer-info)
"Defer insertion of something.
The insertion will be at (point)."
(set-defer-info->last-viewed defer-info lyskom-last-viewed)
;; (goto-char (defer-info->pos defer-info))
(funcall (intern-soft (concat "initiate-"
(symbol-name (defer-info->server-call
......@@ -143,10 +148,15 @@ The insertion will be at (point)."
;; that we can't use lyskom-last-viewed, because it has been
;; updated to the new prompt. Until that is solved we make
;; sure that we never scroll.
(move-to-window-line -1)
(vertical-motion 1)
(if (not (pos-visible-in-window-p))
(forward-char -1))
;;
;; The solution is to save lyskom-last-viewed in the defer-info
(save-selected-window
(select-window window)
(lyskom-scroll))
;; (move-to-window-line -1)
;; (vertical-motion 1)
;; (if (not (pos-visible-in-window-p))
;; (forward-char -1))
))))
......
......@@ -370,6 +370,10 @@ Read all about it at http://www.lysator.liu.se/history/")
(matching-regexp . "Conferences/users matching `%#1s'\n")
(who-is-active-all . "Showing all sessions.\n")
(who-is-active-last-minnutes . "Showing all sessions active tha last %#1d minutes.\n")
(showing-invisibles . "Showing invisible sessions.\n")
; From commands2.el:
(your-memberships . "Your LysKOM conference memberships:\n")
......
......@@ -1028,21 +1028,82 @@ TYPE is one of RECPT, CC-RECPT COMM-TO COMM-IN FOOTN-TO or FOOTN-IN."
;;; flags
;;; This is an experiment. Hopefully most of the code can be
;;; automatically generated.
(defmacro def-komtype (type &rest args)
(let ((typename (symbol-name type))
(n 0))
;; Constructor
(eval (list 'defsubst
(intern (concat "lyskom-create-" typename))
args
(concat "Create a `" typename "' from arguments.\n"
"Args: " (upcase (mapconcat
'symbol-name args " ")) "\n"
"Automatically created with def-komtype.")
(list 'cons
(list 'quote (intern (upcase typename)))
(cons 'vector args))))
;; Identifier
(eval (list 'defsubst
(intern (concat typename "-p"))
(list type)
(concat "Return `t' if " (upcase typename)
" is a " typename ".\n"
"Args: " (upcase typename) "\n"
"Automatically created with def-komtype.")
(list 'and
(list 'consp type)
(list 'eq (list 'car type)
(list 'quote (intern (upcase typename)))))))
;; Selectors/Modifiers
(while args
(let ((argname (symbol-name (car args))))
;; Selctor
(eval (list 'defsubst
(intern (concat typename "->" argname))
(list type)
"Automatically created with def-komtype."
(list 'aref (list 'cdr type) n)))
;; Modifier
(eval (list 'defsubst
(intern (concat "set-" typename "->" argname))
(list type (car args))
"Automatically created with def-komtype."
(list 'aset (list 'cdr type) n (car args))))
(setq n (1+ n)
args (cdr args)))))
'())
(def-komtype session-flags
invisible user_active_used user_absent
reserved3 reserved4 reserved5 reserved6 reserved7)
(def-komtype dynamic-session-info
session person working-conference idle-time flags what-am-i-doing)
(def-komtype static-session-info
username hostname ident-user connection-time)
;;; ================================================================
;;; flags
;;; Constructor:
(defsubst lyskom-create-flags (unread_is_secret
flg2
flg3
flg4
flg5
flg6
flg7
flg8)
flg2
flg3
flg4
flg5
flg6
flg7
flg8)
"Create a flags from all parameters."
(cons
'FLAGS
(vector unread_is_secret flg2 flg3 flg4 flg5 flg6 flg7 flg8
)))
(vector unread_is_secret flg2 flg3 flg4 flg5 flg6 flg7 flg8)))
;;; Selectors:
......
No preview for this file type
......@@ -567,6 +567,32 @@ than 0. Args: ITEMS-TO-PARSE PRE-FETCHED. Returns -1 if ITEMS-TO-PARSE is
(lyskom-parse-time))) ;connect-time
;; prot-A.txt says that this should allow more or less flags than
;; specified, but I can't figure out how. /davidk
(defun lyskom-parse-session-flags ()
"Parse session-flags."
(lyskom-create-session-flags
(lyskom-parse-1-or-0) ;invisible
(lyskom-parse-1-or-0) ;user_active_used
(lyskom-parse-1-or-0) ;user_absent
(lyskom-parse-1-or-0) ;flg4
(lyskom-parse-1-or-0) ;flg5
(lyskom-parse-1-or-0) ;flg6
(lyskom-parse-1-or-0) ;flg7
(lyskom-parse-1-or-0))) ;flg8
(defun lyskom-parse-dynamic-session-info ()
"Parse a dynamic-session-info."
(lyskom-create-dynamic-session-info
(lyskom-parse-num) ;session-no
(lyskom-parse-num) ;pers-no
(lyskom-parse-num) ;working-conf
(lyskom-parse-num) ;idle-time
(lyskom-parse-session-flags) ;session-flags
(lyskom-parse-string))) ;doing
;;; High level parsing. Parsing of complete replies.
......@@ -605,6 +631,19 @@ than 0. Args: ITEMS-TO-PARSE PRE-FETCHED. Returns -1 if ITEMS-TO-PARSE is
;;; Parsing of datatypes with cache