-
Notifications
You must be signed in to change notification settings - Fork 4
/
va.c
1584 lines (1244 loc) · 35.6 KB
/
va.c
1
2
3
4
5
6
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
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
426
427
428
429
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
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
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Teradesk. Copyright (c) 1997 - 2002 W. Klaren,
* 2002 - 2003 H. Robbers,
* 2003 - 2017 Dj. Vukovic
*
* This file is part of Teradesk.
*
* Teradesk 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 of the License, or
* (at your option) any later version.
*
* Teradesk 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 Teradesk; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA
*/
#include <library.h>
#include <xdialog.h>
#include "resource.h"
#include "desk.h"
#include "error.h"
#include "font.h"
#include "xfilesys.h"
#include "config.h"
#include "window.h"
#include "open.h"
#include "copy.h"
#include "dir.h"
#include "showinfo.h"
#include "file.h"
#include "lists.h"
#include "slider.h"
#include "icon.h"
#include "va.h"
#include "filetype.h"
#include "applik.h"
#include "main.h"
static void va_redraw(WINDOW *w, GRECT *r);
static void va_iconify(WINDOW *w, GRECT *r);
static void va_uniconify(WINDOW *w, GRECT *r);
static void va_fulled(WINDOW *w, _WORD dummy);
static void copy_avstat(LSTYPE *t, LSTYPE *s);
static void rem_avstat(LSTYPE **list, LSTYPE *t);
static WD_FUNC aw_functions = {
0L, /* handle key */
0L, /* handle button */
va_redraw, /* redraw; was wd_type_redraw */
wd_type_topped, /* topped */
wd_type_bottomed, /* bottomed */
wd_type_topped, /* newtop */
wd_type_close, /* closed */
va_fulled, /* fulled */
xw_nop2, /* arrowed */
0L, /* hslider */
0L, /* vslider */
0L, /* sized */
0L, /* moved */
0L, /* hndlmenu */
0L, /* top */
va_iconify, /* iconify */
va_uniconify /* uniconify */
};
bool va_reply = FALSE; /* true if AV-protocol handshake is in progress */
_WORD av_current; /* ap_id of the currently messaging AV-client */
static AVTYPE avwork; /* work area for editing AV-clients data */
AVTYPE *avclients; /* List of signed-on AV-clients */
static AVSTAT avswork; /* work area for client statuses */
static AVSTAT *avstatus; /* for logging status of AV-clients */
AVSETW avsetw; /* size for the next window */
char const thisapp[] = "DESKTOP "; /* AV-protocol name of this application */
/* These are VA_THAT_IZIT answers which correspond to ITMTYPEs */
#if _MORE_AV
static const _WORD answertypes[] = {
VA_OB_UNKNOWN, /* unused-unknown */
VA_OB_DRIVE, /* disk volume */
VA_OB_SHREDDER, /* was TRASHCAN first */
VA_OB_UNKNOWN, /* printer- funny it is not provided in VA */
VA_OB_FOLDER, /* folder */
VA_OB_FILE, /* program file */
VA_OB_FILE, /* any file */
VA_OB_FOLDER, /* parent directory */
VA_OB_FILE, /* symbolic link */
VA_OB_FILE /* network object */
};
#endif
#define SINGLE_Q 39 /* single quote character */
/*
* Redraw AV-client's wndow
*/
static void va_redraw(WINDOW *w, GRECT *r)
{
xw_send_redraw(w, WM_REDRAW, r);
}
/*
* Full the client's window
*/
static void va_fulled(WINDOW *w, _WORD dummy)
{
(void) dummy;
xw_send(w, WM_FULLED);
}
/*
* Iconify the client's window
*/
static void va_iconify(WINDOW *w, GRECT *r)
{
xw_send_rect(w, WM_ICONIFY, w->xw_ap_id, r);
w->xw_xflags |= XWF_ICN;
}
/*
* Uniconify the client's window
*/
static void va_uniconify(WINDOW *w, GRECT *r)
{
wd_type_topped(w);
xw_send_rect(w, WM_UNICONIFY, w->xw_ap_id, r);
w->xw_xflags &= ~XWF_ICN;
}
/*
* Clear the 'answer' buffer and set word [1] to TeraDesk's ap_id
*/
static void va_clranswer(_WORD *va_answer)
{
memclr(va_answer, 16);
va_answer[1] = ap_id;
}
/*
* Initialize structures for using the AV-protocol.
* Should be called before initialization of windows.
*/
void va_init(void)
{
avclients = NULL; /* list of AV-protocol clients */
avstatus = NULL; /* list of clients' statuses */
avsetw.flag = FALSE; /* don't set next window size */
va_reply = FALSE; /* a reply to a client is not in progress */
}
/*
* Find out if there are any AV-client windows "open"
* Return index of the first accessory window
* This routine will also log any accessory windows open as TeraDesk windows
*/
WINDOW *va_accw(void)
{
WINDOW *w = xw_first();
while (w)
{
if (w->xw_type == ACC_WIND)
{
/* A call to xw_top will log any acc window that is topped */
xw_top();
return w;
}
w = xw_next(w);
}
return NULL;
}
/*
* Delete all pseudowindows structures of AV-clients (if ap_id < 0)
* or all windows belonging to a single client (if ap_id >= 0).
* (because in single-tos all acc windows are closed anyway
* when a program is started).
* If force is FALSE, pseudowindows will be just closed (by sending
* messages to relevant applicatons) and TeraDesk will rely on those
* applications to send AV_ACCWINDCLOSED; if force is TRUE,
* the pseudo-windows structures in TeraDesk will be deleted
*/
void va_delall(_WORD id, bool force)
{
WINDOW *prev;
WINDOW *w = xw_last();
while (w)
{
prev = xw_prev(w);
if (w->xw_type == ACC_WIND && (id < 0 || w->xw_ap_id == id))
{
xw_close(w);
if (force)
xw_delete(w);
}
w = prev;
}
}
/*
* Copy data for one AV-client into. Here, maybe there is no need
* to preserve target's pointer to next ????
*/
static void copy_avtype(LSTYPE *lt, LSTYPE *ls)
{
AVTYPE *t = (AVTYPE *) lt;
AVTYPE *s = (AVTYPE *) ls;
AVTYPE *next = t->next;
*t = *s;
t->next = next;
}
/*
* Find a signed-on AV-client identified by its ap_id
*/
AVTYPE *va_findclient(_WORD id)
{
AVTYPE *f = avclients;
while (f)
{
if (f->ap_id == id)
return f;
f = f->next;
}
return NULL;
}
/*
* Remove an AV-protocol client from the list. Close all its windows
*/
static void rem_avtype(LSTYPE **llist, LSTYPE *it)
{
AVTYPE **list = (AVTYPE **) llist;
AVTYPE *item = (AVTYPE *) it;
xw_dosend = 0;
va_delall(item->ap_id, TRUE);
lsrem((LSTYPE **) list, (LSTYPE *) item);
xw_dosend = 1;
}
/*
* Use these AV-client-list-specific functions to manipulate lists:
*/
#if 0
static LS_FUNC avlist_func = /* for the list of clients */
{
copy_avtype,
rem_avtype,
NULL,
find_lsitem, /* find an item specified by name or position */
NULL
};
#endif
#if 0
static LS_FUNC avslist_func = /* for the list of status strings */
{
copy_avstat,
rem_avstat,
NULL,
find_lsitem, /* find an item specified by name or position */
NULL
};
#endif
/*
* Check for existing AV-clients.
* Maybe some of the signed-on AV-clients has crashed or illegally exited
* without signing-off, and so its windows and data generally have to be
* removed. In such cases, messages should not be sent to those clients,
* because they do not in fact exist anymore.
* Run this function at some convenient moments, such as program startup
*/
void va_checkclient(void)
{
AVTYPE *f = avclients;
AVTYPE *next;
while (f)
{
next = f->next; /* f is about to be destroyed, so save f->next */
if (appl_find(f->name) < 0)
rem_avtype((LSTYPE **) & avclients, (LSTYPE *) f);
f = next;
}
}
/*
* Check if the application specified is already running,
* has signed as an av-client, and supports VA_START.
* If true, then use the VA_START message to pass the command.
* Note: accessories are maybe an exception?: they can be sent VA_START
* even if they had not signed on.
* Note 2: some other aps also understand VA_START but do not sign-on
* to the server. Pity. So the above idea is impractical. See below.
*
* Parameters:
*
* program - name of the program.
* cmdl - commandline.
*
* If flag 'onfile' is set to TRUE elsewhere, this routine will not ask
* about starting another instance of an already running application
*
* Result: TRUE if command has been passed using VA_START.
*/
_WORD va_start_prg(const char *program, ApplType type, const char *cmdl)
{
char *fb; /* not used here */
char prgname[14]; /* 8-chars-long name of the program. Must be 14 bytes long here */
_WORD va_answer[8]; /* local answer-message buffer */
_WORD dest_ap_id; /* ap_id of the application parameters are sent to */
(void) type;
/*
* Use this opportunity to check for existing AV-clients.
* As programs are not started very often, probably there will
* not be any noticeable penalty in speed here.
*/
va_checkclient();
/*
* Check if globally available buffer is large enough
* for the command line.
*/
if ((long)strlen(cmdl) < global_mem_size)
{
/*
* Now copy not more than first eight characters of program name (no path)
* (should it be converted to uppercase?)
* YES- appl_find() in Magic is case sensitive.
*/
cv_tos_fn2form(prgname, fn_get_name(program));
strupr(prgname);
prgname[8] = 0;
/*
* Has this application signed on as an AV-client?
* that supports VA_START ?
* (or, is it maybe an accessory? If neither, return FALSE)
* Some accessories appear to sign-on only when
* they open a window, so it is necessary to be able to send
* them a VA_START even if they have not signed on.
* BUT: it seems that applications generally do NOT sign-on as
* AV-protocol clients, so this severely restricts the behaviour
* of the desktop vs applications. Maybe better to test each
* time if an application is still running?
* Note: this function may be called even if no AV-protocol clients
* had previously signed-on.
*/
#if 0 /* disabled for the time being */
theclient = (AVTYPE *) find_lsitem((LSTYPE **) & avclients, prgname, &i);
if (type != PACC && (!theclient || (theclient->avcap3 & VV_START) != 0))
return FALSE; /* this is not a VA_START capable client */
#endif
/* Check if the application with this name is still/already running */
dest_ap_id = appl_find(prgname);
if (dest_ap_id >= 0)
{
/*
* Yes, this applicaton already runs. Should it be
* started again? If this is a certain kind of special app,
* just ignore it if it already runs, but behave as if it
* has been started
*/
if (onone)
return TRUE;
/*
* Consider again: should the application be started anew?
* Do not ask this if this application is to be used to open
* a file- in that case always assume that the parameters will be
* passed to the running application)
*/
if (onfile || (alert_query(MDUPAPP) != 1))
{
/*
* Something seems to be wrong here!!!!!
* If CAB is started, and then EVEREST from CAB
* (i.e. to view html source) and then EVEREST and CAB exited;
* next time CAB can not be started: check below
* returns dest_ap_id = 0, as if it is already running.
* Maybe avoid it so that a check is made if destination
* is the same as the current app.
* However, avoid confusing CAB with TeraDesk itself.
*/
if (ap_id == dest_ap_id && strcmp(prgname, thisapp) != 0) /* should this fix CAB ? */
return FALSE;
/* Double quotes must be converted to single quotes */
strcpyrq(global_memory, cmdl, SINGLE_Q, &fb);
va_clranswer(va_answer);
va_answer[0] = VA_START;
*(char **) (va_answer + 3) = global_memory;
appl_write(dest_ap_id, 16, va_answer);
return TRUE;
}
}
}
return FALSE;
}
#if _MORE_AV
/*
* Send all registered clients a message- if they support (and need) it.
* This routine must not be used if another handshake is in progress.
*/
static void va_send_all(_WORD cap, _WORD *message)
{
AVTYPE *f = avclients;
while (f)
{
if ((f->avcap3 & cap) == cap)
appl_write(f->ap_id, 16, message);
f = f->next;
}
}
#endif
/*
* Report a font or a font change to an av-client
* Currently, this always returns TRUE, even if failed
*/
bool va_fontreply(_WORD messid, _WORD dest_ap_id)
{
_WORD va_answer[8];
va_clranswer(va_answer);
/* Note: font colour and effects are not sent in these replies */
va_answer[0] = messid; /* message id */
va_answer[3] = dir_font.id; /* directory font id */
va_answer[4] = dir_font.size; /* font size */
#if _MORE_AV
if (messid == VA_FONTCHANGED)
{
va_answer[5] = dir_font.id; /* simulate console font */
va_answer[6] = dir_font.size; /* and size */
va_send_all(VV_FONTASKED | VV_FONTCHANGED, va_answer);
} else
#endif
{
appl_write(dest_ap_id, 16, va_answer);
}
return TRUE;
}
/*
* Add a name to a reply string for an AV-client. If the name contains
* spaces, it will be quoted with single quotes ('). If the name contais
* the single-quote character, it will be doubled.
* This routine is also used to create a list of names to be sent
* to an application using the Drag & drop protocol
*/
bool va_add_name(_WORD type, const char *name)
{
long g = strlen(global_memory); /* cumulative string length */
/*
* Check for available space in the global buffer:
* Must fit: existing string, the name (maybe quoted), a blank
* a backslash and a terminating 0. These 3 bytes are accounted
* for in strlenq.
*/
if (g + (long)strlenq(name) > global_mem_size)
{
alert_iprint(TFNTLNG);
return FALSE;
} else
{
char *pd;
/* Add a blank before the name, but not before the first one */
if (*global_memory != 0)
strcat(global_memory, " ");
pd = global_memory + strlen(global_memory);
/* Add the name, quoting it if necessary */
pd = strcpyq(pd, name, SINGLE_Q);
/* Add a trailing backslash to folder names */
if (*name && (type == ITM_FOLDER || type == ITM_PREVDIR))
{
if (*(pd - 1) == SINGLE_Q)
{
*(pd - 1) = '\\';
*pd++ = SINGLE_Q;
} else
{
*pd++ = '\\';
}
*pd = '\0';
}
}
return TRUE;
}
#if _MORE_AV
/*
* Send window path to be updated to registered AV clients
*(can global 'answer' be used here? va_pathupdate happens
* unprovoked by clients, maybe during a handshake).
* If composing of another VA_ mesage is in progress,
* messages will not be sent; instead. windows will be marked
* for sending the message.
* Return TRUE if messages sent.
* Take care to use this routine only for directory windows.
*/
bool va_pathupdate(WINDOW *w)
{
if (!va_reply)
{
_WORD va_answer[8];
va_clranswer(va_answer);
va_answer[0] = VA_PATH_UPDATE; /* message id */
*(char **) (va_answer + 3) = global_memory;
*global_memory = 0; /* so that va_add_name() works properly */
va_add_name(isroot(((DIR_WINDOW *) w)->path) ? ITM_DRIVE : ITM_FOLDER, ((DIR_WINDOW *) w)->path);
va_send_all(VV_PATH_UPDATE, va_answer);
((DIR_WINDOW *) w)->va_refresh = FALSE;
return TRUE;
}
((DIR_WINDOW *) w)->va_refresh = TRUE;
return FALSE;
}
#endif
/*
* Drop items onto an accwindow using AV/VA protocol.
* Note 1: client window has to be signed-on for this to work
* Note 2: parameter 'list' is locally modified
*/
bool va_accdrop(WINDOW *dw, WINDOW *sw, _WORD *list, _WORD n, _WORD kstate, _WORD x, _WORD y)
{
AVTYPE *client;
ITMTYPE itype;
char *thename;
_WORD i;
(void) kstate;
/*
* Find the data for the client which created this window.
* If the window exists, it is assumed that the client is still alive
* and there is no need to check it.
*/
client = va_findclient(dw->xw_ap_id);
if (client)
{
_WORD va_answer[8];
/* Client found; add each name from the list into the global memory */
*global_memory = 0; /* clear previous */
for (i = 0; i < n; i++)
{
thename = NULL; /* see further below */
if (((itype = itm_type(sw, *list)) == ITM_NOTUSED) ||
((thename = itm_fullname(sw, *list)) == NULL) || (!va_add_name(itype, thename)))
{
free(thename);
return FALSE;
}
/*
* "thename" must be NULL for the next loop, otherwise, if an
* unused item type occurs, an unallocated block will be
* freed above
*/
free(thename);
list++;
}
/* Create a message and send it */
va_clranswer(va_answer);
va_answer[0] = VA_DRAGACCWIND;
va_answer[3] = dw->xw_handle;
va_answer[4] = x;
va_answer[5] = y;
*(char **) (va_answer + 6) = global_memory;
appl_write(client->ap_id, 16, va_answer);
client->flags |= AVCOPYING;
return TRUE;
}
return FALSE;
}
/*
* Handle (most of) AV messages and FONT messages
*
* Parameters:
*
* message - buffer with AES message.
*
* AV-protocol messages handled in these routines (request/reply):
*
* AV_PROTOKOLL/VA_PROTOSTATUS
* AV_ASKCONFONT/VA_CONFONT
* AV_ASKFILEFONT/VA_FILEFONT/VA_FONTCHANGED
* VA_START/AV_STARTED
* VA_DRAGACCWIND
* AV_ACCWINDOPEN
* AV_ACCWINDCLOSED
* AV_OPENWIND/VA_WINDOPEN
* AV_XWIND/VA_XOPEN
* AV_STARTPROG/VA_PROGSTART
* AV_VIEW/VA_VIEWED
* AV_PATH_UPDATE
* AV_COPY_DRAGGED/VA_COPY_COMPLETE
* AV_DRAG_ON_WINDOW/VA_DRAG_COMPLETE
* AV_FILEINFO/VA_FILECHANGED
* AV_DELFILE/VA_FILEDELETED
* AV_COPYFILE/VA_FILECOPIED
* AV_STATUS
* AV_GETSTATUS/VA_SETSTATUS
* AV_SETWINDPOS
* AV_SENDKEY
* VA_PATH_UPDATE
* AV_EXIT
*
* Unsupported:
*
* AV_OPENCONSOLE/VA_CONSOLEOPEN
* AV_ASKOBJECT/VA_OBJECT
*
* FONT protocol messages supported:
*
* FONT_SELECT/FONT_CHANGED (FONT protocol, see also font.c)
*
*/
void handle_av_protocol(const _WORD *message)
{
char *path = NULL;
char *mask = NULL;
const char *pp3; /* location in the message as a string pointer */
const char *mp5; /* same */
const char *pp6; /* same */
#if _MINT_
_WORD j;
#endif
_WORD answer[8]; /* answer message will be composed here */
_WORD m3 = message[3]; /* save some bytes in program size */
bool status;
int error;
bool reply = TRUE;
#if 0 /* not used for the time being, see below */
AVTYPE *oldclient;
#endif
AVTYPE *theclient;
#if _MORE_AV
AVSTAT *thestatus;
#endif
WINDOW *aw;
/* Clear the answer message buffer; then set TeraDesk's ap_id where it will be */
va_clranswer(answer);
/* Find data for the client if it exists */
av_current = message[1]; /* who sent the message (its ap_id) */
theclient = va_findclient(av_current); /* are there any data for it */
/*
* Ignore unknown clients, except if they are signing-on,
* or ask for a font, or inf-file is sent to TeraDesk
*/
if (!
(message[0] == AV_PROTOKOLL || message[0] == FONT_SELECT || (message[0] == VA_START && av_current == ap_id)
|| theclient))
return;
/*
* Some locations in the message may point to strings and
* these pointers are used in several functions, so determine
* them here for all concerned
*/
pp3 = *(const char *const *) (message + 3);
mp5 = *(const char *const *) (message + 5);
pp6 = *(const char *const *) (message + 6);
switch (message[0])
{
case AV_PROTOKOLL:
/*
* Client signing on.
* Mostly ignore the features send by the (sender) client.
* Return the server-supported features.
* Maybe the name should be converted to uppercase here ?
* Hopefully not- AV protocol requires that names be sent in uppercase.
*/
strcpy(avwork.name, pp6);
avwork.ap_id = appl_find((const char *) avwork.name);
avwork.avcap3 = m3; /* notify client-supported features */
avwork.flags = 0;
/*
* Add the client to the list- but it seems that some clients
* (e.g. ST-GUIDE) may sign-on more than once without signing off.
* Avoid this.
*/
if (!theclient && av_current != ap_id)
{
if (!lsadd_end((LSTYPE **) & avclients, sizeof(AVTYPE), (LSTYPE *) (&avwork), copy_avtype))
reply = FALSE; /* can't add client */
}
if (reply)
{
strcpy(global_memory, thisapp); /* must be exactly 8 characters long */
answer[0] = VA_PROTOSTATUS;
answer[3] = AA_SENDKEY |
AA_ASKFILEFONT | AA_ASKCONFONT | AA_COPY_DRAGGED | AA_STARTPROG | AA_ACCWIND | AA_EXIT |
#if _MORE_AV
AA_SRV_QUOTING | AA_STATUS | AA_XWIND | AA_OPENWIND | AA_DRAG_ON_WINDOW | /* also for AV_WHAT_IZIT and AV_PATH_UPDATE */
AA_FILE | /* for FILEINFO */
AA_FONTCHANGED |
#endif
AA_STARTED;
answer[4] =
#if _MORE_AV
AA_COPY | AA_DELETE | AA_SETWINDPOS |
#endif
AA_VIEW;
*(char **) (answer + 6) = global_memory;
}
break;
case AV_EXIT:
/*
* Note: do not send to an AV client the instructions to close its
* windows. It is supposed that now it will do that by itself.
* Therefore xw_dosend = 0 temporarily
*/
rem_avtype((LSTYPE **) & avclients, (LSTYPE *) va_findclient(av_current));
reply = FALSE;
break;
case AV_ASKCONFONT:
/*
* Return the id and size of the console window font.
* Reply to this is currently the same as for directory window font
*/
case AV_ASKFILEFONT:
/*
* Return the id and size of the currently selected directory font.
* Message is composed and sent in va_fontreply(); there is no need
* for an additional reply
*/
theclient->avcap3 |= VV_FONTASKED;
va_fontreply((message[0] == AV_ASKCONFONT) ? VA_CONFONT : VA_FILEFONT, message[1]);
reply = FALSE;
break;
case AV_ACCWINDOPEN:
/*
* Create an av-client pseudowindow;
* use "flags" parameter to pass the window handle
* which the client has supplied in message[3]
*/
aw = xw_create(ACC_WIND, &aw_functions, m3, NULL, sizeof(ACC_WINDOW), NULL, &error);
aw->xw_xflags |= XWF_OPN;
aw->xw_ap_id = av_current;
reply = FALSE;
break;
case AV_ACCWINDCLOSED:
/*
* Client has closed a window, identified by its handle.
* Now delete the data structire for this window
*/
xw_delete(xw_hfind(m3));
reply = FALSE;
break;
case AV_COPY_DRAGGED:
/* Confirmation of copying to an acc window */
if (theclient->flags & AVCOPYING)
{
answer[0] = VA_COPY_COMPLETE;
answer[3] = 1;
theclient->flags &= ~AVCOPYING;
} else
{
reply = FALSE;
}
break;
#if _MORE_AV
case AV_XWIND:
/*
* Open a directory window with additional features.
* Action is currently similar to that for just opening a window.
* It is not entirely clear whether this message is
* correctly supported
*/
answer[0] = VA_XOPEN;
goto getwpath;
case AV_OPENWIND:
/* Open a directory window. (name lengths are checked in dir_add_window() ) */
answer[0] = VA_WINDOPEN;
getwpath:;
path = strdup(pp3); /* path must be kept */
if (path)
{
dir_trim_slash(path);
status = TRUE;
/* If an existing window can not be topped, open a new one */
if (!(message[0] == AV_XWIND && (message[7] & 0x01) && dir_do_path(path, DO_PATH_TOP)))
{
mask = strdup(mp5); /* mask must be kept too */
/*
* In case of an error (e.g. too long string), path and mask are
* deallocated in dir_add_window()
*/
if (mask)
{
status = dir_add_window(path, mask, NULL);
} else
{
free(path);
status = FALSE;
}
} else
{
/* This was AV_XWIND; path was just used for comparison */
free(path);
}
} else
{
status = FALSE;
}
answer[3] = status;
break;
#endif
case VA_START:
/*
* TeraDesk can understand about inf files being sent to it by itself.
* There is no point in sending the reply message back
* because AV_STARTED is ignored anyway.
* Name of the file must be kept.
* This command is ignored if it does not come from TeraDesk?
*/
reply = FALSE;