aux-items.el 26.4 KB
Newer Older
David Byers's avatar
David Byers committed
1
;;;;; -*-coding: iso-8859-1;-*-
2
3
;;;;;
;;;;; $Id$
4
;;;;; Copyright (C) 1991-2002  Lysator Academic Computer Association.
5
;;;;;
6
;;;;; This file is part of the LysKOM Emacs LISP client.
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
;;;;; 
;;;;; LysKOM is free software; you can redistribute it and/or modify it
;;;;; under the terms of the GNU General Public License as published by 
;;;;; the Free Software Foundation; either version 2, or (at your option) 
;;;;; any later version.
;;;;; 
;;;;; LysKOM is distributed in the hope that it will be useful, but WITHOUT
;;;;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
;;;;; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
;;;;; for more details.
;;;;; 
;;;;; You should have received a copy of the GNU General Public License
;;;;; along with LysKOM; see the file COPYING.  If not, write to
;;;;; Lysator, c/o ISY, Linkoping University, S-581 83 Linkoping, SWEDEN,
;;;;; or the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, 
;;;;; MA 02139, USA.
;;;;;
;;;;; Please mail bug reports to bug-lyskom@lysator.liu.se. 
;;;;;
;;;; ================================================================
;;;; ================================================================
;;;;
;;;; File: aux-items.el
;;;;
;;;; Implementation of aux-item specific stuff.
;;;; Hopefulle more of this will be made more general in the future.
;;;;

(setq lyskom-clientversion-long 
      (concat lyskom-clientversion-long
	      "$Id$\n"))

39
40
41
42
;;; (eval-when-compile
;;;   (require 'lyskom-defvar "defvar.el")
;;;   (require 'lyskom-vars "vars.el")
;;;   (require 'lyskom-types "komtypes.el"))
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65


(def-kom-var lyskom-aux-item-definitions nil
  "List of aux item definitions.")

(defmacro def-aux-item (name number &rest data)
  (` (setq lyskom-aux-item-definitions 
           (add-to-list 'lyskom-aux-item-definitions
                        (cons (, number)
                              (cons (cons 'name (quote (, name)))
                                    (quote (, data))))))))

(defun lyskom-aux-item-definition->name (def)
  (cdr (assq 'name def)))

(defun lyskom-aux-item-definition->number (def)
  (car def))

(defun lyskom-map-aux-items (fn text-stat)
  "Apply FN to every aux item in TEXT-STAT."
  (let ((items (text-stat->aux-items text-stat)))
    (while items
      (when (and (car items) 
David Byers's avatar
David Byers committed
66
                 (not (aux-item-flags->deleted (aux-item->flags items))))
67
68
69
70
71
        (funcall fn (car items)))
      (setq items (cdr items)))))



72
73
74
(defun lyskom-aux-item-try-call (item method default &rest args)
  (when (lyskom-aux-item-p item)
    (setq item (lyskom-find-aux-item-definition item)))
75
  (cond ((listp method)
76
77
         (let ((result nil)
               (found nil))
78
           (while method
79
             (when (lyskom-aux-item-definition-field item (car method))
80
               (setq result
81
                     (apply (lyskom-aux-item-definition-field item
82
                                                              (car method))
83
84
85
                            args)
                     found t
                     method nil))
86
             (setq method (cdr method)))
87
88
89
90
91
           (if found result default)))
        (t (if (lyskom-aux-item-definition-field item method)
             (apply (lyskom-aux-item-definition-field item method) args)
             default))))

David Byers's avatar
David Byers committed
92
93
94
95
96
(defun lyskom-aux-item-has-call (item method)
  "Return non-nil if aux-item ITEM has a defined method METHOD"
  (when (lyskom-aux-item-p item)
    (setq item (lyskom-find-aux-item-definition item)))
  (lyskom-aux-item-definition-field item method))
97
98
99

(defun lyskom-aux-item-call (def method &rest args)
  (apply 'lyskom-aux-item-try-call def method nil args))
100
101
102


(defun lyskom-aux-item-definition-field (def method)
103
  (when (lyskom-aux-item-p def)
104
105
106
107
108
109
110
    (setq def (lyskom-find-aux-item-definition def)))
  (cdr (assq method def)))


(defun lyskom-find-aux-item-definition (aux)
  (assq (aux-item->tag aux) lyskom-aux-item-definitions))

111
112
113
114
115
116
117
118
119
120
121
(defun lyskom-match-aux-items (item-list predicate)
  "Return a list of all aux-items in ITEM-LIST that match PREDICATE.
PREDICATE should receives a single aux-item as its argument and should
return non-nil if the item is to be included in the list."
  (let ((result nil))
    (while item-list
      (when (funcall predicate (car item-list))
        (setq result (cons (car item-list) result)))
      (setq item-list (cdr item-list)))
    (nreverse result)))

122
123
124
125
126
127
128
                                        
(defun lyskom-get-aux-item (item-list tag)
  "Return all aux-items in ITEM-LIST with tag TAG."
  (lyskom-match-aux-items item-list
                          (lambda (el) (eq (aux-item->tag el) tag))))


129
130
(defun lyskom-aux-item-terminating-button (item obj)
  (if obj
131
132
133
134
135
136
137
138
139
140
141
142
       (lyskom-format 
        " %#1@%[[*]%]" 
        (lyskom-default-button 
         'aux 
         (cond ((lyskom-text-stat-p obj) (list 'text
                                               (text-stat->text-no obj)
                                               (aux-item->aux-no item)))
               ((lyskom-conf-stat-p obj) (list 'conf
                                               (conf-stat->conf-no obj)
                                               (aux-item->aux-no item)))
               ((eq obj 'server) (list 'server nil (aux-item->aux-no item)))
               (t item))))
143
144
     ""))

145
146
147
148
149
150
151
(defun lyskom-aux-item-after-parse (item)
  (lyskom-aux-item-try-call item 'decode-data nil)
  item)

(defun lyskom-aux-item-output-data (item)
  (lyskom-aux-item-try-call item 
                            'encode-data
152
153
                            (aux-item->data item)
			    item))
154
155


156
157
158
;;; ======================================================================

(def-aux-item content-type 1
David Byers's avatar
David Byers committed
159
  (text-name aux-content-type-name)
160
  (parse . lyskom-parse-content-type)
David Byers's avatar
David Byers committed
161
  (text-print . lyskom-print-content-type)
162
163
164
  (info  . lyskom-aux-item-info))

(def-aux-item fast-reply 2
David Byers's avatar
David Byers committed
165
  (text-name aux-fast-reply-name)
166
  (parse . nil)
167
  (parse-data . lyskom-aux-item-decode-data)
168
  (encode-data . lyskom-aux-item-encode-data)
169
170
171
  (info . lyskom-aux-item-info))

(def-aux-item cross-reference 3
David Byers's avatar
David Byers committed
172
  (text-name aux-cross-reference-name)
David Byers's avatar
David Byers committed
173
174
  (status-print . lyskom-status-print-cross-reference)
  (text-print-when . comment)
175
  (parse . lyskom-parse-cross-reference)
176
  (parse-data . lyskom-aux-item-decode-data)
177
  (encode-data . lyskom-aux-item-encode-data)
David Byers's avatar
David Byers committed
178
  (text-print . lyskom-print-cross-reference)
179
180
181
182
  (edit-insert . lyskom-edit-insert-cross-reference)
  (info  . lyskom-aux-item-info))

(def-aux-item no-comments 4
David Byers's avatar
David Byers committed
183
  (text-name aux-no-comments-name)
David Byers's avatar
David Byers committed
184
  (text-print-when . footer)
185
  (parse . lyskom-parse-no-comments)
David Byers's avatar
David Byers committed
186
  (text-print . lyskom-print-no-comments)
187
188
189
190
  (edit-insert . lyskom-edit-insert-no-comments)
  (info  . lyskom-aux-item-info))

(def-aux-item personal-comment 5
David Byers's avatar
David Byers committed
191
  (text-name aux-personal-comment-name)
David Byers's avatar
David Byers committed
192
  (text-print-when . footer)
193
  (parse . lyskom-parse-personal-comments)
David Byers's avatar
David Byers committed
194
  (text-print . lyskom-print-personal-comments)
195
196
197
198
  (edit-insert . lyskom-edit-insert-personal-comments)
  (info  . lyskom-aux-item-info))

(def-aux-item request-confirmation 6
David Byers's avatar
David Byers committed
199
  (text-name aux-request-confirmation-name)
David Byers's avatar
David Byers committed
200
  (text-print-when . header)
201
  (parse . lyskom-parse-request-confirmation)
David Byers's avatar
David Byers committed
202
  (text-print . lyskom-print-request-confirmation)
203
204
205
206
207
  (edit-insert . lyskom-edit-insert-request-confirmation)
  (info  . lyskom-aux-item-info)
  (read-action . lyskom-request-confirmation-action))

(def-aux-item read-confirm 7
David Byers's avatar
David Byers committed
208
  (text-name aux-read-confirm-name)
David Byers's avatar
David Byers committed
209
210
  (text-print-when . header)
  (text-print . lyskom-print-read-confirm)
211
212
213
  (info  . lyskom-aux-item-info))

(def-aux-item redirect 8
David Byers's avatar
David Byers committed
214
  (text-name aux-redirect-name)
215
216
217
218
  (print . lyskom-print-redirect)
  (info  . lyskom-aux-item-info))

(def-aux-item x-face 9
David Byers's avatar
David Byers committed
219
  (text-name aux-x-face-name)
220
221
222
223
  (print . lyskom-print-xface)
  (info  . lyskom-aux-item-info))

(def-aux-item alternate-name 10
David Byers's avatar
David Byers committed
224
  (text-name aux-alternate-name-name)
David Byers's avatar
David Byers committed
225
226
  (text-print-when . header)
  (text-print . lyskom-print-alternate-name)
227
  (encode-data . lyskom-aux-item-encode-data)
228
  (parse-data . lyskom-aux-item-decode-data)
229
230
231
  (info  . lyskom-aux-item-info))

(def-aux-item pgp-signature 11
David Byers's avatar
David Byers committed
232
  (text-name aux-pgp-signature-name)
233
234
235
  (info  . lyskom-aux-item-info))

(def-aux-item pgp-public-key 12
David Byers's avatar
David Byers committed
236
  (text-name aux-pgp-public-key-name)
237
238
239
  (info  . lyskom-aux-item-info))

(def-aux-item e-mail-address 13
David Byers's avatar
David Byers committed
240
  (text-name aux-e-mail-address-name)
241
242
  (info  . lyskom-aux-item-info))

David Byers's avatar
David Byers committed
243
(def-aux-item faq-text 14
David Byers's avatar
David Byers committed
244
  (text-name aux-faq-text-name)
David Byers's avatar
David Byers committed
245
  (info . lyskom-aux-item-info)
246
  (text-header-line . (faq-in-text faq-in-text-by))
David Byers's avatar
David Byers committed
247
248
249
  (status-print . lyskom-status-print-faq-text))

(def-aux-item creating-software 15
David Byers's avatar
David Byers committed
250
  (text-name aux-creating-software-name)
David Byers's avatar
David Byers committed
251
252
  (info . lyskom-aux-item-info)
  (text-print-when . header)
253
  (parse-data . lyskom-aux-item-decode-data)
254
  (encode-data . lyskom-aux-item-encode-data)
David Byers's avatar
David Byers committed
255
256
257
  (text-print . lyskom-print-creating-software))

(def-aux-item mx-author 16
David Byers's avatar
David Byers committed
258
  (text-name aux-mx-author-name)
David Byers's avatar
David Byers committed
259
260
261
  (info . lyskom-aux-item-info))

(def-aux-item mx-from 17
David Byers's avatar
David Byers committed
262
  (text-name aux-mx-from-name)
David Byers's avatar
David Byers committed
263
264
265
  (info . lyskom-aux-item-info))

(def-aux-item mx-reply-to 18
David Byers's avatar
David Byers committed
266
  (text-name aux-mx-reply-to-name)
David Byers's avatar
David Byers committed
267
268
269
  (info . lyskom-aux-item-info))

(def-aux-item mx-to 19
David Byers's avatar
David Byers committed
270
  (text-name aux-mx-to-name)
David Byers's avatar
David Byers committed
271
272
273
  (info . lyskom-aux-item-info))

(def-aux-item mx-cc 20
David Byers's avatar
David Byers committed
274
  (text-name aux-mx-cc-name)
David Byers's avatar
David Byers committed
275
276
277
  (info . lyskom-aux-item-info))

(def-aux-item mx-date 21
David Byers's avatar
David Byers committed
278
  (text-name aux-mx-date-name)
David Byers's avatar
David Byers committed
279
280
281
  (info . lyskom-aux-item-info))

(def-aux-item mx-message-id 22
David Byers's avatar
David Byers committed
282
  (text-name aux-mx-message-id-name)
David Byers's avatar
David Byers committed
283
284
285
  (info . lyskom-aux-item-info))

(def-aux-item mx-in-reply-to 23
David Byers's avatar
David Byers committed
286
  (text-name aux-mx-in-reply-to-name)
David Byers's avatar
David Byers committed
287
288
289
  (info . lyskom-aux-item-info))

(def-aux-item mx-misc 24
David Byers's avatar
David Byers committed
290
  (text-name aux-mx-misc-name)
David Byers's avatar
David Byers committed
291
292
293
  (info . lyskom-aux-item-info))

(def-aux-item mx-allow-filter 25
David Byers's avatar
David Byers committed
294
  (text-name aux-mx-allow-filter-name)
David Byers's avatar
David Byers committed
295
296
297
  (info . lyskom-aux-item-info))

(def-aux-item mx-reject-forward 26
David Byers's avatar
David Byers committed
298
  (text-name aux-mx-reject-forward-name)
David Byers's avatar
David Byers committed
299
300
301
  (info . lyskom-aux-item-info))

(def-aux-item notify-comments 27
David Byers's avatar
David Byers committed
302
  (text-name aux-notify-comments-name)
David Byers's avatar
David Byers committed
303
304
305
  (info . lyskom-aux-item-info))

(def-aux-item faq-for-conf 28
David Byers's avatar
David Byers committed
306
  (text-name aux-faq-for-conf-name)
David Byers's avatar
David Byers committed
307
308
  (text-print . lyskom-print-faq-for-conf)
  (text-print-when . header)
David Byers's avatar
David Byers committed
309
310
311
  (info . lyskom-aux-item-info)
  (read-action . lyskom-faq-for-conf-action))

David Byers's avatar
David Byers committed
312

313
(def-aux-item recommended-conf 29
David Byers's avatar
David Byers committed
314
  (text-name aux-recommended-conf-name)
315
  (status-print . lyskom-print-recommended-conf)
316
317
318
  (info . lyskom-aux-item-info))

(def-aux-item allowed-content-type 30
David Byers's avatar
David Byers committed
319
  (text-name aux-allowed-content-type-name)
320
321
  (info . lyskom-aux-item-info))

322
(def-aux-item canonical-name 31
David Byers's avatar
David Byers committed
323
  (text-name aux-canonical-name-name)
324
325
326
  (info . lyskom-aux-item-info))

(def-aux-item mx-list-name 32
David Byers's avatar
David Byers committed
327
  (text-name aux-mx-list-name-name)
328
329
330
331
  (info . lyskom-aux-item-info)
  (status-print . lyskom-print-mx-list-name))

(def-aux-item send-comments-to 33
David Byers's avatar
David Byers committed
332
333
  (text-name aux-send-comments-to-name)
  (info . lyskom-print-aux-item-info)
334
335
336
  (status-print . lyskom-print-send-comments-to))

(def-aux-item world-readable 34
David Byers's avatar
David Byers committed
337
  (text-name aux-world-readable-name)
338
339
340
341
342
343
  (info . lyskom-aux-item-info)
  (text-print . lyskom-print-world-readable)
  (parse . lyskom-parse-world-readable)
  (edit-insert . lyskom-edit-insert-world-readable)
  (text-print-when . header))

David Byers's avatar
David Byers committed
344
(def-aux-item elisp-client-read-faq 10000
David Byers's avatar
David Byers committed
345
  (text-name aux-elisp-client-read-faq-name)
David Byers's avatar
David Byers committed
346
347
  (info . lyskom-aux-item-info)
  (status-print . lyskom-print-elisp-client-read-faq))
348

349
(def-aux-item elisp-client-rejected-invitation 10001
David Byers's avatar
David Byers committed
350
  (text-name aux-elisp-client-rejected-invitation-name)
351
352
353
  (info . lyskom-aux-item-info)
  (status-print . lyskom-print-elisp-client-rejected-invitation))

354
355
356
357
358

;;; ================================================================



359
360
361
362
363
364
365
366
367
368
(defun lyskom-aux-item-decode-data (item)
  (set-aux-item->data 
   item
   (decode-coding-string (aux-item->data item) lyskom-server-coding-system)))

(defun lyskom-aux-item-encode-data (item)
  (encode-coding-string (aux-item->data item) lyskom-server-coding-system)
  )


369
370
371
372
373
374
375
376
377
378
(defun lyskom-aux-item-info (item header)
  (let ((def (lyskom-find-aux-item-definition item)))
    
    (concat 
     (lyskom-get-string 'aux-item-for)
     header
     "\n"
     (lyskom-format
      'aux-item-info
      (aux-item->aux-no item)
David Byers's avatar
David Byers committed
379
      (aux-item->tag item)
380
381
382
383
      (if def
          (lyskom-aux-item-definition->name def)
        "unknown")
      (aux-item->creator item)
384
      (lyskom-format-time 'date-and-time (aux-item->sent-at item))
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
      (if (aux-item-flags->deleted (aux-item->flags item))
          (format "(%s)" (lyskom-get-string 'deleted))
        "")
      (mapconcat 'identity
                 (delq nil
                       (list
                        (and (aux-item-flags->secret (aux-item->flags item))
                             (lyskom-get-string 'secret))
                        (and (aux-item-flags->anonymous (aux-item->flags item))
                             (lyskom-get-string 'hide-creator))
                        (and (aux-item-flags->inherit (aux-item->flags item))
                             (lyskom-get-string 'inherit))))
                 ", ")
      (cond ((not (aux-item-flags->inherit (aux-item->flags item)))
             (lyskom-get-string 'no-inheritance))
            ((zerop (aux-item->inherit-limit item))
             (lyskom-get-string 'unlimited-inherit))
            ((eq 1  (aux-item->inherit-limit item))
             (lyskom-get-string 'no-more-inherit))
            (t (lyskom-format 'inherit-steps
                              (1- (aux-item->inherit-limit item)))))
      (aux-item->data item)))))

                 

(defun lyskom-print-content-type (item &optional obj)
  (concat (lyskom-format 'content-type-aux (aux-item->data item))
          (lyskom-aux-item-terminating-button item obj)))

(defun lyskom-parse-content-type ()
  (and (looking-at (lyskom-get-string 'content-type-regexp))
       (match-string 1)))

(defun lyskom-parse-cross-reference ()
  (or (and (looking-at (lyskom-get-string 'cross-reference-text-regexp))
           (concat "T" (match-string 1)))
      (and (looking-at (lyskom-get-string 'cross-reference-conf-regexp))
           (concat "C" (match-string 1)))
      (and (looking-at (lyskom-get-string 'cross-reference-pers-regexp))
           (concat "P" (match-string 1)))))

David Byers's avatar
David Byers committed
426
(defun lyskom-edit-insert-cross-reference (item pers)
427
428
429
  (concat
   (lyskom-print-cross-reference item nil pers)
   (lyskom-edit-generate-aux-item-flags (aux-item->flags item))))
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461

(defun lyskom-print-cross-reference (item &optional obj pers)
  (let ((pers (if (and (zerop (aux-item->creator item))
                       pers)
                  pers
                (aux-item->creator item))))
    (concat
     (cond ((string-match "^P\\([0-9]+\\)" (aux-item->data item))
            (lyskom-format 'cross-reference-pers-aux 
                           (string-to-int 
                            (match-string 1 (aux-item->data item)))
                           pers
                           ))
           ((string-match "^C\\([0-9]+\\)" (aux-item->data item))
            (lyskom-format 'cross-reference-conf-aux 
                           (string-to-int 
                            (match-string 1 (aux-item->data item)))
                           pers
                           ))
           ((string-match "^T\\([0-9]+\\)" (aux-item->data item))
            (lyskom-format 'cross-reference-text-aux 
                           (string-to-int 
                            (match-string 1 (aux-item->data item)))
                           pers
                           ))
           (t (lyskom-format 'strange-cross-reference 
                             (aux-item->data item)
                             pers
                             )))
     (lyskom-aux-item-terminating-button item obj)
     )))

David Byers's avatar
David Byers committed
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
(defun lyskom-status-print-cross-reference (item &optional obj pers)
  (lyskom-insert 
   (concat
    (cond ((string-match "^P\\([0-9]+\\)" (aux-item->data item))
           (lyskom-format 'cross-reference-pers-status-aux 
                          (string-to-int 
                           (match-string 1 (aux-item->data item)))
                          (aux-item->creator pers)
                          ))
          ((string-match "^C\\([0-9]+\\)" (aux-item->data item))
           (lyskom-format 'cross-reference-conf-status-aux 
                          (string-to-int 
                           (match-string 1 (aux-item->data item)))
                          pers
                          ))
          ((string-match "^T\\([0-9]+\\)" (aux-item->data item))
           (lyskom-format 'cross-reference-text-status-aux 
                          (string-to-int 
                           (match-string 1 (aux-item->data item)))
                          (aux-item->creator pers)
                          ))
          (t (lyskom-format 'strange-cross-reference-status 
                            (aux-item->data item)
                            (aux-item->creator pers)
                            )))
    (lyskom-aux-item-terminating-button item obj)
    "\n")))  

490
491
492
493
494
495
496
497
498
(defun lyskom-parse-no-comments ()
  (and (looking-at (lyskom-get-string 'no-comments-regexp))
       ""))

(defun lyskom-print-no-comments (item &optional obj)
  (concat (lyskom-format 'no-comments-aux)
          (lyskom-aux-item-terminating-button item obj)))

(defun lyskom-edit-insert-no-comments (item &optional obj)
499
500
501
  (concat
   (lyskom-format 'no-comments-edit-aux)
   (lyskom-edit-generate-aux-item-flags (aux-item->flags item))))
502
503
504
505
506
507
508
509
510
511

(defun lyskom-parse-personal-comments ()
  (and (looking-at (lyskom-get-string 'personal-comment-regexp))
       ""))

(defun lyskom-print-personal-comments (item &optional obj)
  (concat (lyskom-format 'personal-comment-aux)
          (lyskom-aux-item-terminating-button item obj)))

(defun lyskom-edit-insert-personal-comments (item &optional obj)
512
513
514
  (concat
   (lyskom-format 'personal-comment-edit-aux)
   (lyskom-edit-generate-aux-item-flags (aux-item->flags item))))
515
516
517
518
519
520

(defun lyskom-parse-request-confirmation ()
  (and (looking-at (lyskom-get-string 'request-confirmation-regexp))
       ""))

(defun lyskom-print-request-confirmation (item &optional obj)
521
522
  (concat (lyskom-format 'request-confirmation-aux
                         (aux-item->creator item))
523
524
525
          (lyskom-aux-item-terminating-button item obj)))

(defun lyskom-edit-insert-request-confirmation (item &optional obj)
526
527
528
  (concat
   (lyskom-format 'request-confirmation-edit-aux)
   (lyskom-edit-generate-aux-item-flags (aux-item->flags item))))
529

David Byers's avatar
David Byers committed
530
531
532
533
534
535
(defun lyskom-faq-for-conf-action (text-stat)
  (let ((faqs (text-stat-find-aux text-stat 28)))
    (lyskom-traverse aux faqs
      (lyskom-register-read-faq (string-to-int (aux-item->data aux))
                                (text-stat->text-no text-stat)))))

536
537
538
539
540
541
542
543
(defun lyskom-request-confirmation-action (text-stat)
  (let ((confirmations (text-stat-find-aux text-stat 7))
        (have-confirmation nil))
    (while confirmations
      (when (eq lyskom-pers-no (aux-item->creator (car confirmations)))
        (setq have-confirmation t)
        (setq confirmations nil))
      (setq confirmations (cdr confirmations)))
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
    (when  (not have-confirmation)
      (lyskom-scroll)
      (when (lyskom-j-or-n-p
             (lyskom-format (lyskom-get-string 'confirm-read-q)
                            text-stat))
        (let ((item (lyskom-create-aux-item 0 7 lyskom-pers-no
                                            nil 
                                            (lyskom-create-aux-item-flags
                                             nil nil nil nil nil nil nil nil)
                                            0 "")))
          (initiate-modify-text-info 'background
                                     nil
                                     (text-stat->text-no text-stat)
                                     nil
                                     (list item))
          (cache-del-text-stat (text-stat->text-no text-stat)))))))
560
561
562
563
564

(defun lyskom-print-read-confirm (item &optional obj)
  (concat 
   (lyskom-format 'read-confirm-aux
                  (aux-item->creator item)
565
                  (lyskom-format-time 'date-and-time (aux-item->sent-at item)))
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
   (lyskom-aux-item-terminating-button item obj)))



(defun lyskom-print-redirect (item &optional obj)
  (concat
   (cond ((string-match "^E-mail:\\(.*\\)$" (aux-item->data item))
          (lyskom-format 'redirect-email-aux 
                         (match-string 1 (aux-item->data item))))
         ((string-match "^LysKOM:\\(.*\\)$" (aux-item->data item))
          (lyskom-format 'redirect-lyskom-aux 
                         (string-to-int 
                          (match-string 1 (aux-item->data item))))))
   (lyskom-aux-item-terminating-button item obj)))   


(defun lyskom-print-xface (item &optional obj)
  (lyskom-xemacs-or-gnu
584
585
   (lyskom-maybe-add-face-to-string item
                                    (make-string 0 ?X))
586
587
   nil))

588
589
590
591
(defun lyskom-maybe-add-face-to-string (item string)
  (lyskom-xemacs-or-gnu
   (if (null item)
       string
David Byers's avatar
David Byers committed
592
     (setq item (car item))
593
594
     (unless (find-face 'kom-xface)
       (make-face 'kom-xface))
595
     (let* ((h (concat "X-Face: " (aux-item->data item)))
596
            (g (intern h lyskom-xface-cache))
David Byers's avatar
David Byers committed
597
            (e (make-extent 0 (length string) string)))
598
599
600
       (if (boundp g)
           (setq g (symbol-value g))
         (set g (make-glyph
David Byers's avatar
David Byers committed
601
602
603
604
                 (list
                  (list 'global (cons '(tty) [nothing]))
                  (list 'global (cons '(win) 
                                      (vector 'xface ':data h))))))
605
606
607
         (setq g (symbol-value g))
         (set-glyph-face g 'kom-xface))
       (set-extent-begin-glyph e g)
David Byers's avatar
David Byers committed
608
609
610
611
       (set-extent-property e 'end-open nil)
       (set-extent-property e 'start-open nil)
       (set-extent-property e 'duplicable t)
       string))
612
613
614
   string))


615
(defun lyskom-print-alternate-name (item &optional obj)
David Byers's avatar
David Byers committed
616
  (concat "[" (aux-item->data item) "] "
617
618
          (lyskom-aux-item-terminating-button item obj)))

David Byers's avatar
David Byers committed
619
(defun lyskom-print-faq-format-subject (text text-stat text-no)
David Byers's avatar
David Byers committed
620
621
622
623
624
625
626
  (if (and text text-stat)
      (concat "\""
	      (cond ((string-match "\n" (text->decoded-text-mass text text-stat))
		     (substring (text->decoded-text-mass text text-stat) 0 (match-beginning 0)))
		    (t ""))
	      "\"")
    (lyskom-format 'no-such-text-no text-no)))
David Byers's avatar
David Byers committed
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643

(defun lyskom-deferred-print-faq (text-stat defer-info)
  (if text-stat
      (initiate-get-text 
       'deferred 
       (lambda (text text-stat defer-info)
         (lyskom-replace-deferred defer-info 
                                  (lyskom-format "%#1r" 
                                                 (lyskom-print-faq-format-subject text
                                                                                  text-stat
                                                                                  (defer-info->data defer-info)))))
       (text-stat->text-no text-stat)
       text-stat
       defer-info)
    (lyskom-replace-deferred defer-info
                             (lyskom-print-faq-format-subject nil nil (defer-info->data defer-info)))))

David Byers's avatar
David Byers committed
644
(defun lyskom-status-print-faq-text (item &optional obj)
David Byers's avatar
David Byers committed
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
  (let* ((text-no (string-to-int (aux-item->data item)))
         (subject (if kom-deferred-printing
                      (lyskom-create-defer-info 'get-text-stat
                                                text-no
                                                'lyskom-deferred-print-faq
                                                nil nil nil
                                                text-no)
                    (blocking-do-multiple ((text (get-text text-no))
                                           (text-stat (get-text-stat text-no)))
                      (lyskom-print-faq-format-subject text text-stat text-no)))))
    (lyskom-format-insert 'faq-in-text-aux 
                          text-no
                          subject)
    (lyskom-insert (lyskom-aux-item-terminating-button item obj))
    (lyskom-insert "\n")))
David Byers's avatar
David Byers committed
660
661

(defun lyskom-print-faq-for-conf (item &optional obj)
662
663
664
665
666
  (let ((conf-no (string-to-int (aux-item->data item))))
    (concat 
     (cond ((zerop conf-no) (lyskom-get-string 'faq-for-server-aux))
          (t (lyskom-format 'faq-for-conf-aux conf-no)))
     (lyskom-aux-item-terminating-button item obj))))
David Byers's avatar
David Byers committed
667
668

(defun lyskom-print-creating-software (item &optional obj)
669
  (when (or kom-show-creating-software
David Byers's avatar
David Byers committed
670
            (lyskom-viewing-noconversion))
671
672
673
    (concat
     (lyskom-format 'creating-software-aux (aux-item->data item))
     (lyskom-aux-item-terminating-button item obj))))
David Byers's avatar
David Byers committed
674

David Byers's avatar
David Byers committed
675
676
677
678
679
680
681
682
683
(defun lyskom-print-send-comments-to (item &optional obj)
  (when (string-match "^\\([0-9]+\\)" (aux-item->data item))
    (let ((conf-no (string-to-int (match-string 1 (aux-item->data item)))))
      (lyskom-format-insert 'status-send-comments-to
                            conf-no 
                            (lyskom-aux-item-terminating-button item obj)))))



684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
(defun lyskom-parse-world-readable ()
  (and (looking-at (regexp-quote 
                    (lyskom-get-string 'world-readable-text-edit-aux)))
       ""))

(defun lyskom-edit-insert-world-readable (item &optional obj)
  (concat
   (lyskom-format 'world-readable-text-edit-aux)
   (lyskom-edit-generate-aux-item-flags (aux-item->flags item))))

(defun lyskom-print-world-readable (item &optional obj)
  (concat (lyskom-format 'world-readable-text-aux)
          (lyskom-aux-item-terminating-button item obj)))

(defun lyskom-print-mx-list-name (item &optional obj)
  (lyskom-format-insert 'conf-mx-list-name 
                        (aux-item->data item)
                        (lyskom-aux-item-terminating-button item obj)))

(defun lyskom-print-recommended-conf (item &optional obj)
  (let ((conf-no (string-to-int (if (string-match " " (aux-item->data item))
                                    (substring (aux-item->data item) 0 (match-beginning 0))
                                  (aux-item->data item)))))
707
708
709
    (lyskom-format-insert 'recommended-conf-aux
                          conf-no
                          (lyskom-aux-item-terminating-button item obj))))
David Byers's avatar
David Byers committed
710
711

(defun lyskom-print-elisp-client-read-faq (item &optional obj)
712
713
714
715
716
717
718
719
  (when kom-extended-status-information
    (when (string-match "^\\([0-9]+\\) \\([0-9]+\\)" (aux-item->data item))
      (let ((conf-no (string-to-int (match-string 1 (aux-item->data item))))
            (text-no (string-to-int (match-string 2 (aux-item->data item)))))
        (lyskom-format-insert 'status-read-faq-aux-item 
                              conf-no 
                              text-no
                              (lyskom-aux-item-terminating-button item obj))))))
720

721
(defun lyskom-print-elisp-client-rejected-invitation (item &optional obj)
722
723
724
  (when (string-match "^\\([0-9]+\\)" (aux-item->data item))
    (let ((conf-no (string-to-int (match-string 1 (aux-item->data item)))))
      (lyskom-format-insert 'status-rejected-recommendation-aux-item
725
726
727
                            conf-no 
                            (lyskom-aux-item-terminating-button item obj)))))

728
(provide 'lyskom-aux-items)