Commit 53dd2a58 authored by David Byers's avatar David Byers
Browse files

MULEified the client. No Gnu Emacs support in this version.

parent 6b007b88
1999-11-19 David Byers <davby@ida.liu.se>
* startup.el (lyskom): Decode the motd text mass and format it as
a text.
* lyskom-rest.el (lyskom-format-aux-help): No longer accept text
as an argument, because we can't decode it.
(kom-save-text-body): Decode the text body.
* filter.el (lyskom-filter-text-p-3): Decode the text mass of the
text.
* edit-text.el (lyskom-edit-add-recipient/copy): Decode the
text-mass of the motd.
(kom-edit-insert-text): Get the text-stat and text for
lyskom-edit-insert-commented.
(lyskom-edit-get-commented): Pass text and text-stat to thendo.
* commands2.el (lyskom-print-summary-line): Decode the text mass.
(lyskom-print-mark-summary-line): Same here.
(lyskom-set-motd): Same here.Accept text stat as argument.
(kom-set-motd): Get the text-stat and text and send them to
lyskom-set-motd.
* commands1.el (lyskom-write-comment-soon): Decode the text mass.
(lyskom-private-answer-soon): Same here.
(lyskom-private-answer-soon-prev): Same here.
(lyskom-change-pres-or-motd-2): Same here.
* komtypes.el (text->decoded-text-mass): New function.
* Makefile (SOURCES): Added mime.el to the sources.
* view-text.el (lyskom-print-text): Decode the string according to
the charset specified by the content type.
* mime.el (lyskom-charset-alist): New variable.
(lyskom-mime-string-charset): New function.
(lyskom-mime-charset-coding-system): New function.
(lyskom-mime-encode-string): New function.
(lyskom-mime-decode-string): New function.
(lyskom-mime-decode-content-type): New function.
* utilities.el (lyskom-subset-p): New function.
(lyskom-intersection): Moved from review.el
* edit-text.el (lyskom-edit-send): Pass on aux-list even if we're
anonymous.
1999-11-18 Joel Rosdahl <joel@lysator.liu.se>
* Makefile: Debian package building.
......
......@@ -62,6 +62,7 @@ SOURCES = $(LANGUAGE-EL) \
command.el \
buffers.el \
aux-items.el \
mime.el \
prefetch.el \
startup.el \
reading.el \
......
......@@ -3,6 +3,10 @@
Att göra i elisp-klienten
=========================
MULEifiera hanteringen av user-arean.
Kolla att spara text sparar med en vettig kodning.
Bli av med lyskom-is-parsing, gör parsern reentrant, installera
reentrant blocking-do. Se över alla användningar av lyskom-wait-queue
eftersom den just nu inte kan användas i svar på asynkront anrop.
......
......@@ -819,19 +819,19 @@ If optional arg TEXT-NO is present write a footnote to that text instead."
(defun lyskom-write-comment-soon (text-stat text text-no type)
"Write a comment to the text with TEXT-STAT, TEXT and, TEXT-NO.
TYPE is either 'comment or 'footnote."
(cond
;; Text not found?
((or (null text-stat)
(null text))
(lyskom-format-insert 'cant-read-textno text-no))
;; Give header.
((string-match "\n" (text->text-mass text))
(lyskom-write-comment text-stat
(substring (text->text-mass text)
0 (match-beginning 0))
type))
;; The commented text had no header.
(t (lyskom-write-comment text-stat "" type))))
(let ((str (and text-stat text (text->decoded-text-mass text text-stat))))
(cond
;; Text not found?
((or (null text-stat)
(null text))
(lyskom-format-insert 'cant-read-textno text-no))
;; Give header.
((string-match "\n" str)
(lyskom-write-comment text-stat
(substring str 0 (match-beginning 0))
type))
;; The commented text had no header.
(t (lyskom-write-comment text-stat "" type)))))
(defun lyskom-write-comment (text-stat subject type)
......@@ -969,11 +969,12 @@ that text instead."
(defun lyskom-private-answer-soon (text-stat text text-no)
"Write a private answer to TEXT-STAT, TEXT."
(if (and text-stat text)
(if (string-match "\n" (text->text-mass text))
(lyskom-private-answer text-stat
(substring (text->text-mass text)
0 (match-beginning 0)))
(lyskom-private-answer text-stat ""))
(let ((str (text->decoded-text-mass text text-stat)))
(if (string-match "\n" str)
(lyskom-private-answer text-stat
(substring str
0 (match-beginning 0))))
(lyskom-private-answer text-stat ""))
(lyskom-format-insert 'no-such-text-no text-no)))
......@@ -1013,11 +1014,11 @@ that text instead."
(defun lyskom-private-answer-soon-prev (text-stat text)
"Write a private answer to TEXT-STAT, TEXT."
(if (string-match "\n" (text->text-mass text))
(let ((str (text->decoded-text-mass text text-stat)))
(if (string-match "\n" str)
(lyskom-private-answer text-stat
(substring (text->text-mass text)
0 (match-beginning 0)))
(lyskom-private-answer text-stat "")))
(substring str 0 (match-beginning 0)))
(lyskom-private-answer text-stat ""))))
;;; ================================================================
......@@ -1122,48 +1123,49 @@ TYPE is either 'pres or 'motd, depending on what should be changed."
((or lyskom-is-administrator
(lyskom-get-membership (conf-stat->supervisor conf-stat) t)
(= lyskom-pers-no (conf-stat->conf-no conf-stat)))
(lyskom-dispatch-edit-text
lyskom-proc
(apply
'lyskom-create-misc-list
(if (and (eq type 'pres)
(not (zerop (conf-stat->presentation conf-stat))))
(append
(lyskom-get-recipients-from-misc-list
(text-stat->misc-info-list
(blocking-do 'get-text-stat
(conf-stat->presentation conf-stat))))
(list 'comm-to
(conf-stat->presentation conf-stat)))
(list 'recpt
(cond
((eq type 'motd)
(server-info->motd-conf lyskom-server-info))
((eq type 'pres)
(if (conf-type->letterbox
(conf-stat->conf-type conf-stat))
(server-info->pers-pres-conf
lyskom-server-info)
(server-info->conf-pres-conf
lyskom-server-info)))))))
(conf-stat->name conf-stat)
(let ((text-mass (blocking-do 'get-text
(cond
((eq type 'pres)
(conf-stat->presentation conf-stat))
((eq type 'motd)
(conf-stat->msg-of-day conf-stat))))))
(if (and text-mass
(string-match "\n" (text->text-mass text-mass)))
(substring (text->text-mass text-mass) (match-end 0))
(if (and (eq type 'pres)
(conf-type->letterbox (conf-stat->conf-type conf-stat)))
(lyskom-get-string 'presentation-form)
"")))
(cond
((eq type 'pres) 'lyskom-set-presentation)
((eq type 'motd) 'lyskom-set-conf-motd))
(conf-stat->conf-no conf-stat)))
(blocking-do-multiple ((text-stat (get-text-stat
(conf-stat->presentation conf-stat)))
(text-mass (get-text
(cond
((eq type 'pres)
(conf-stat->presentation conf-stat))
((eq type 'motd)
(conf-stat->msg-of-day conf-stat))))))
(let ((str (and text-mass (text->decoded-text-mass
text-mass text-stat))))
(lyskom-dispatch-edit-text
lyskom-proc
(apply
'lyskom-create-misc-list
(if (and (eq type 'pres)
(not (zerop (conf-stat->presentation conf-stat))))
(append
(lyskom-get-recipients-from-misc-list
(text-stat->misc-info-list text-stat))
(list 'comm-to
(conf-stat->presentation conf-stat)))
(list 'recpt
(cond
((eq type 'motd)
(server-info->motd-conf lyskom-server-info))
((eq type 'pres)
(if (conf-type->letterbox
(conf-stat->conf-type conf-stat))
(server-info->pers-pres-conf
lyskom-server-info)
(server-info->conf-pres-conf
lyskom-server-info)))))))
(conf-stat->name conf-stat)
(if (and text-mass (string-match "\n" str))
(substring str (match-end 0))
(if (and (eq type 'pres)
(conf-type->letterbox (conf-stat->conf-type conf-stat)))
(lyskom-get-string 'presentation-form)
""))))
(cond
((eq type 'pres) 'lyskom-set-presentation)
((eq type 'motd) 'lyskom-set-conf-motd))
(conf-stat->conf-no conf-stat)))
(t
(lyskom-format-insert 'not-supervisor-for
conf-stat))))
......@@ -1760,12 +1762,12 @@ If MARK-NO is nil, review all marked texts."
(lyskom-format-insert
"%#1t"
(lyskom-format event
(+ (time->year time) 1900)
(1+ (time->mon time))
(time->mday time)
(time->hour time)
(time->min time)
(time->sec time))))
(+ (time->year time) 1900)
(1+ (time->mon time))
(time->mday time)
(time->hour time)
(time->min time)
(time->sec time))))
(error nil))))))
lyskom-times)
;;;
......
......@@ -908,7 +908,7 @@ Format is 23:29 if the text is written today. Otherwise 04-01."
(if (not (and text-stat text)) ;+++ B{ttre felhantering.
(lyskom-format-insert 'could-not-read text-no)
(let* ((lines (text-stat->no-of-lines text-stat))
(txt (text->text-mass text))
(txt (text->decoded-text-mass text text-stat))
(eos (string-match (regexp-quote "\n") txt))
(subject (substring txt 0 eos))
(mx-date (car (lyskom-get-aux-item (text-stat->aux-items text-stat) 21)))
......@@ -1001,7 +1001,7 @@ Format is 23:29 if the text is written today. Otherwise 04-01."
(if (not (and text-stat text)) ;+++ B{ttre felhantering.
(lyskom-format-insert 'could-not-read text-no)
(let* ((lines (text-stat->no-of-lines text-stat))
(txt (text->text-mass text))
(txt (text->decoded-text-mass text text-stat))
(eos (string-match (regexp-quote "\n") txt))
(subject (substring txt 0 eos))
;; length of the number %%%%%% :8
......@@ -1337,27 +1337,32 @@ Format is 23:29 if the text is written today. Otherwise 04-01."
"Set the message of the day for LysKOM."
(interactive)
(if (server-info->motd-of-lyskom lyskom-server-info)
(initiate-get-text 'main 'lyskom-set-motd
(progn (lyskom-collect 'main)
(initiate-get-text-stat 'main nil
(server-info->motd-of-lyskom lyskom-server-info))
(initiate-get-text 'main nil
(server-info->motd-of-lyskom lyskom-server-info))
(lyskom-set-motd nil)))
(lyskom-use 'main 'lyskom-set-motd))
(lyskom-set-motd nil nil)))
(defun lyskom-set-motd (old-motd-text)
(defun lyskom-set-motd (old-motd-text-stat old-motd-text)
"Set the message of the day for LysKOM.
Use OLD-MOTD-TEXT as the default text if non-nil."
(lyskom-edit-text
lyskom-proc
(lyskom-create-misc-list)
(if (and old-motd-text
(string-match "\n" (text->text-mass old-motd-text)))
(substring (text->text-mass old-motd-text) 0 (1- (match-end 0)))
"")
(if (and old-motd-text
(string-match "\n" (text->text-mass old-motd-text)))
(substring (text->text-mass old-motd-text) (match-end 0))
"")
'lyskom-set-motd-2))
(let ((str (and old-motd-text
old-motd-text-stat
(text->decoded-text-mass old-motd-text old-motd-text-stat))))
(lyskom-edit-text
lyskom-proc
(lyskom-create-misc-list)
(if (and str (string-match "\n" str))
(substring str 0 (1- (match-end 0)))
"")
(if (and str (string-match "\n" str))
(substring str (match-end 0))
"")
'lyskom-set-motd-2)))
;; Should really fix lyskom-edit text instead of the ugly IGNORE
......
......@@ -282,6 +282,10 @@ string to search in."
(lyskom-provide-function set-process-coding-system (proc &optional encoding decoding)
)
(lyskom-provide-function encode-coding-string (str coding-system) str)
(lyskom-provide-function decode-coding-string (str coding-system) str)
(lyskom-provide-function string-bytes (str) (length str))
(lyskom-provide-function last (x &optional n)
"Returns the last link in the list LIST.
With optional argument N, returns the Nth-to-last link (default 1)."
......
......@@ -55,6 +55,7 @@ SOURCES = $(LANGUAGE-EL) \
command.el \
buffers.el \
aux-items.el \
mime.el \
prefetch.el \
startup.el \
reading.el \
......
......@@ -548,38 +548,71 @@ anonymously and take actions to avoid revealing the sender."
(lyskom-edit-extract-text))
(lyskom-edit-extract-text)))
(lyskom-edit-sending-mode 1)
(save-excursion
(let ((full-message
(cond ((and lyskom-allow-missing-subject
(or (null subject)
(string= subject ""))
(not (string-match ".*\n" message)))
message)
(t (concat (or subject "") "\n" message)))))
(set-buffer lyskom-buffer)
;; Don't change the prompt if we won't see our own text
(if (and kom-created-texts-are-read
(not is-anonymous))
(setq lyskom-dont-change-prompt t))
(setq lyskom-is-writing nil)
(lyskom-tell-internat 'kom-tell-send)
(funcall send-function
'sending
'lyskom-create-text-handler
full-message
misc-list
(unless is-anonymous
(cons (lyskom-create-aux-item
0 15 0 0
(lyskom-create-aux-item-flags
nil nil nil nil nil nil nil nil)
0 (concat "lyskom.el "
lyskom-clientversion))
aux-list))
buffer
is-anonymous))))
(let* ((full-message
(cond ((and lyskom-allow-missing-subject
(or (null subject)
(string= subject ""))
(not (string-match ".*\n" message)))
message)
(t (concat (or subject "") "\n" message))))
(content-type (lyskom-get-aux-item aux-list 1))
(charset (and content-type
(cdr (lyskom-mime-decode-content-type
(aux-item->data (car content-type))))))
(mime-charset (lyskom-mime-string-charset full-message)))
;; If the charset isn't already set, encode the string
(if (and mime-charset (null charset))
(setq full-message
(lyskom-mime-encode-string full-message))
(when (lyskom-j-or-n-p 'too-many-languages)
(keyboard-quit)))
;; Add the charset data to the content type
(cond ((> (length content-type) 1)
(lyskom-error (lyskom-get-string 'too-many-content-types)))
((null content-type)
(setq aux-list
(cons (lyskom-create-aux-item 0 1 nil nil
(lyskom-create-aux-item-flags nil nil nil nil nil nil nil nil)
0
(format "x-kom/text;charset=%S" mime-charset))
aux-list)))
((null charset)
(set-aux-item->data (car content-type)
(format "%s;charset=%S"
(aux-item->data (car content-type))
mime-charset))))
;; Send the text
(lyskom-edit-sending-mode 1)
(set-buffer lyskom-buffer)
;; Don't change the prompt if we won't see our own text
(if (and kom-created-texts-are-read
(not is-anonymous))
(setq lyskom-dont-change-prompt t))
(setq lyskom-is-writing nil)
(lyskom-tell-internat 'kom-tell-send)
(funcall send-function
'sending
'lyskom-create-text-handler
full-message
misc-list
(if (not is-anonymous)
(cons (lyskom-create-aux-item
0 15 0 0
(lyskom-create-aux-item-flags
nil nil nil nil nil nil nil nil)
0 (concat "lyskom.el "
lyskom-clientversion))
aux-list)
aux-list)
buffer
is-anonymous))))
(lyskom-undisplay-buffer)
(goto-char (point-max))))
;;
......@@ -994,17 +1027,20 @@ Cannot be called from a callback."
(let ((buffer (current-buffer))
(window (selected-window)))
(set-buffer lyskom-buffer)
(lyskom-collect 'edit)
(initiate-get-text 'edit
'lyskom-edit-insert-commented
no
buffer
window)
nil
no)
(initiate-get-text-stat 'edit
nil
no)
(lyskom-use 'edit 'lyskom-edit-insert-commented buffer window)
(set-buffer buffer)
(sit-for 0)))
(defun lyskom-edit-get-commented (thendo)
"Get the commented text and then do THENDO with it."
"Get the commented text and text stat and then do THENDO with it."
(let ((p (point)))
(save-excursion
(let* ((buffer (current-buffer))
......@@ -1023,7 +1059,10 @@ Cannot be called from a callback."
(no
(goto-char p)
(set-buffer lyskom-buffer)
(initiate-get-text 'edit thendo no buffer window)
(lyskom-collect 'edit)
(initiate-get-text 'edit thendo no)
(initiate-get-text-stat 'edit nil no)
(lyskom-use 'edit thendo buffer window)
(set-buffer buffer))
(t
(lyskom-message "%s" (lyskom-get-string 'no-such-text-m))))))
......@@ -1189,14 +1228,16 @@ RECPT-TYPE is the type of recipient to add."
;; Otherwise, show the notive and keep on going
(let ((text (blocking-do 'get-text text-no)))
(blocking-do-multiple ((text (get-text text-no))
(text-stat (get-text-stat text-no)))
(if (and text (get-buffer-window edit-buffer))
(let ((win-config (current-window-configuration)))
;;(set-buffer buffer)
(with-output-to-temp-buffer "*Motd*"
(princ (lyskom-format 'conf-has-motd-no
(text->text-no text)
(text->text-mass text))))
(text->decoded-text-mass text
text-stat))))
(and (j-or-n-p (lyskom-get-string 'still-want-to-add))
(if what-to-do
(funcall what-to-do conf-stat insert-at edit-buffer)
......@@ -1647,8 +1688,8 @@ Point must be located on the line where the subject is."
)))
(defun lyskom-edit-show-commented (text editing-buffer window)
"Handles the TEXT from the return of the call of the text.
(defun lyskom-edit-show-commented (text text-stat editing-buffer window)
"Handles the TEXT and TEXT-STAT from the return of the call of the text.
The EDITING-BUFFER is the buffer the editing is done in. If this buffer is
not displayed nothing is done. If displayed then this buffer is chosen then
the with-output-to-temp-buffer command is issued to make them both apear."
......@@ -1668,19 +1709,19 @@ the with-output-to-temp-buffer command is issued to make them both apear."
(lyskom-view-mode)))))))
(defun lyskom-edit-insert-commented (text editing-buffer window)
"Handles the TEXT from the return of the call of the text.
(defun lyskom-edit-insert-commented (text text-stat editing-buffer window)
"Handles the TEXT and TEXT-STAT from the return of the call of the text.
The text is inserted in the buffer with '>' first on each line."
(if text
(progn
(if (and text text-stat)
(let ((str (text->decoded-text-mass text text-stat)))
(set-buffer editing-buffer)
(and (not (bolp))
(insert "\n"))
(and (not (eolp))
(open-line 1))
(let* ((pb (point))
(as (string-match "\n" (text->text-mass text)))
(te (substring (text->text-mass text) (1+ as))))
(as (string-match "\n" str))
(te (substring str (1+ as))))
(insert te)
(while (<= pb (point))
(beginning-of-line)
......
......@@ -177,15 +177,6 @@ invalid-value until a filter action has been selected.")
(setq lyskom-filter-hack nil)
(let (subject text-stat)
;;
;; Extract the subject
;;
(cond ((string-match "\n" (text->text-mass text))
(setq subject
(substring (text->text-mass text) 0 (match-beginning 0))))
(t (setq subject "")))
;;
;; Extract the text-stat which is the last element of data
;; Next shorten the list in data to exclude the text-stat.
......@@ -196,6 +187,15 @@ invalid-value until a filter action has been selected.")
(setq data nil)
(rplacd (nthcdr (- (length data) 2) data) nil))
;;
;; Extract the subject
;;
(let ((str (text->decoded-text-mass text text-stat)))
(cond ((string-match "\n" str)
(setq subject (substring str 0 (match-beginning 0))))
(t (setq subject ""))))
;;
;; Do the checking
;;
......@@ -205,7 +205,7 @@ invalid-value until a filter action has been selected.")
author
data
subject
(text->text-mass text)
(text->decoded-text-mass text text-stat)
lyskom-filter-list)))))
(defun lyskom-check-filter-list (text-stat
......@@ -377,23 +377,21 @@ invalid-value until a filter action has been selected.")
(subject nil))
(if text-stat
(blocking-do-multiple
((text (get-text text-no))
(conf-stat (get-conf-stat
(text-stat->author text-stat))))
(if text
(progn
(setq subject
(if (string-match "\n" (text->text-mass text))
(substring (text->text-mass text)
0
(match-beginning 0))
(text->text-mass text)))
(lyskom-format-insert prompt
text-stat
subject
(or conf-stat
(text-stat->author text-stat)))
(lyskom-scroll))))))
((text (get-text text-no))
(conf-stat (get-conf-stat
(text-stat->author text-stat))))
(if text
(let ((str (text->decoded-text-mass text text-stat)))
(setq subject
(if (string-match "\n" str)
(substring str 0 (match-beginning 0))
str))
(lyskom-format-insert prompt
text-stat
subject
(or conf-stat
(text-stat->author text-stat)))
(lyskom-scroll))))))
(setq lyskom-filter-hack nil))
......
......@@ -669,6 +669,22 @@ Both vectors should be of the same length."
"Return t if OBJECT is a text-stat."
(eq (car-safe object) 'TEXT-STAT))
;;; ================================================================
;;; aux-item
(def-komtype aux-item-flags deleted inherit secret anonymous