-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathechomanager.c
2411 lines (2073 loc) · 91 KB
/
echomanager.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
/*---------------------------------------------------------------------------+
| Titel: ECHOMANAGER.C |
+-----------------------------------------+---------------------------------+
| Erstellt von: Michael Hohner | Am: 16.04.1995 |
+-----------------------------------------+---------------------------------+
| System: OS/2 2.x PM |
+---------------------------------------------------------------------------+
| Beschreibung: |
| |
| Echo-Manager von FleetStreet |
| |
| |
+---------------------------------------------------------------------------+
| Bemerkungen: |
+---------------------------------------------------------------------------*/
/*----------------------------- Header-Dateien ------------------------------*/
#pragma strings(readonly)
#define INCL_BASE
#define INCL_WIN
#include <os2.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include "main.h"
#include "resids.h"
#include "messages.h"
#include "structs.h"
#include "msgheader.h"
#include "areaman\areaman.h"
#include "utility.h"
#include "dialogids.h"
#include "handlemsg\handlemsg.h"
#include "handlemsg\kludgeapi.h"
#include "areadlg.h"
#include "setupdlg.h"
#include "savemsg.h"
#include "devkit\echoman.h"
#include "util\fltutil.h"
#include "util\addrcnv.h"
#include "dump\expt.h"
#include "echomanager.h"
/*--------------------------------- Defines ---------------------------------*/
#define ECHOMGR_STRINGLEN 50
#ifndef CRA_SOURCE
#define CRA_SOURCE 0x00004000L
#endif
#define TAB_FONT "8.Helv"
#define RGB_GREY 0x00cccccc
#define TEXTBLOCKSIZE 4096
#define CMD_LINK "+%s\n"
#define CMD_LNKRESC "+%s\n%%RESCAN %s\n"
#define CMD_UNLINK "-%s\n"
#define CMD_RESCAN "%%RESCAN %s\n"
#define CMD_REFRESH "%LIST\n"
#define CMD_PAUSE "%PAUSE\n"
#define CMD_RESUME "%RESUME\n"
#define WM_SAVEDONE WM_USER
#define WM_CHANGEDONE (WM_USER+1)
#define WM_CURRENTDEL (WM_USER+2)
/*---------------------------------- Typen ----------------------------------*/
typedef struct
{
MINIRECORDCORE RecordCore;
PCHAR pchEchoName;
PCHAR pchStatus;
PCHAR pchAction;
ULONG ulAction;
ULONG ulStatus;
} ECHOMGRRECORD, *PECHOMGRRECORD;
#define ACTION_NONE 0UL
#define ACTION_LINK 1UL
#define ACTION_UNLINK 2UL
#define ACTION_RESCAN 3UL
#define ACTION_PAUSE 4UL
#define ACTION_RESUME 5UL
#define ACTION_REFRESH 6UL
#define ACTION_LNKRESC 7UL
#define STATUS_UNLINKED 0UL
#define STATUS_LINKED 1UL
typedef struct
{
HWND hwndDlg;
FTNMESSAGE Message;
MSGHEADER Header;
} SAVEPARAM, *PSAVEPARAM;
typedef struct
{
USHORT usID; /* Menue-ID */
PUPLINK pUplink; /* zugehoeriger Uplink */
} MENUTABLE, *PMENUTABLE;
typedef struct
{
HWND hwndPopup;
HWND hwndFolderPopup;
char pchTitleEcho[ECHOMGR_STRINGLEN];
char pchTitleStatus[ECHOMGR_STRINGLEN];
char pchTitleAction[ECHOMGR_STRINGLEN];
char pchStatusLinked[ECHOMGR_STRINGLEN];
char pchStatusUnlinked[ECHOMGR_STRINGLEN];
char pchActionLink[ECHOMGR_STRINGLEN];
char pchActionUnlink[ECHOMGR_STRINGLEN];
char pchActionRescan[ECHOMGR_STRINGLEN];
char pchActionRefresh[ECHOMGR_STRINGLEN];
char pchActionPause[ECHOMGR_STRINGLEN];
char pchActionResume[ECHOMGR_STRINGLEN];
ULONG ulAction;
BOOL bNotify;
BOOL bKeyboard;
PECHOMGRRECORD pPopupRecord;
SAVEPARAM SaveParam;
PUPLINK pUplink;
PMENUTABLE pMenuTable;
ULONG ulCountUplinks;
} ECHOMGRDATA, *PECHOMGRDATA;
typedef struct
{
USHORT cb;
PUPLINK pUplink;
HWND hwndSettingsDlg;
PECHOMGRDATA pEchoMgrData;
} EMANSETTINGSDATA, *PEMANSETTINGSDATA;
typedef struct stringlist
{
struct stringlist *next;
char *pchString;
} STRINGLIST, *PSTRINGLIST;
typedef struct actionlist
{
struct actionlist *next;
ULONG ulAction;
char pchAreaTag[LEN_AREATAG+1];
} ACTIONLIST, *PACTIONLIST;
typedef struct
{
HWND hwndDlg;
PACTIONLIST pActionList;
PUPLINK pUplink;
} CHANGEPARAM, *PCHANGEPARAM;
typedef struct
{
USHORT cb;
PUPLINK pUplink;
} UPLINKPARAM, *PUPLINKPARAM;
typedef struct
{
HMODULE hModule;
ULONG (* APIENTRY QueryVersion)(VOID);
ULONG (* APIENTRY QueryParamBlockSize)(VOID);
ULONG (* APIENTRY SetupParams)(PVOID, ULONG, HWND, HAB, HMODULE);
ULONG (* APIENTRY AddEcho)(PVOID, ULONG, PCHAR, PCHAR, PCHAR, PCHAR, ULONG);
ULONG (* APIENTRY RemoveEcho)(PVOID, ULONG, PCHAR, PCHAR, PCHAR, PCHAR, ULONG);
} FUNCTABLE, *PFUNCTABLE;
#define LOADDLL_OK 0
#define LOADDLL_CANTLOAD 1
#define LOADDLL_VERSION 2
#define LOADDLL_FUNCMISSING 3
/*---------------------------- Globale Variablen ----------------------------*/
extern HAB anchor;
extern HMODULE hmodLang;
extern ECHOMGROPT EchoMgrOpt;
/*--------------------------- Funktionsprototypen ---------------------------*/
/*----------------------- interne Funktionsprototypen -----------------------*/
static void InsertEchos(HWND hwndCnr, PECHOMGRDATA pEchoMgrData);
static void CleanupContainer(HWND hwndCnr);
static void OpenPopup(HWND hwndDlg, PECHOMGRRECORD pRecord, PECHOMGRDATA pEchoMgrData);
static MRESULT EXPENTRY EchoMgrSettings(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
static void InsertPages(HWND hwndDlg, PVOID pParam);
static MRESULT EXPENTRY UplinkSettings(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
static MRESULT EXPENTRY DllSettings(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
static char *CreateMessageText(HWND hwndCnr, PECHOMGRDATA pEchoMgrData);
static PACTIONLIST CreateActionList(HWND hwndCnr);
static int CreateMessage(HWND hwndCnr, PECHOMGRDATA pEchoMgrData, PFTNMESSAGE pMessage, PMSGHEADER pHeader);
static void _Optlink MessageSaveThread(PVOID pParam);
static void _Optlink CfgChangeThread(PVOID pParam);
static int LoadExtensionDLL(char *pchDllName, PFUNCTABLE pFuncTable);
static void ConfigureDLL(HWND hwndDlg, PFUNCTABLE pFuncTable);
static PUPLINK FindUplink(PECHOMGROPT pEchoMgrOpt, char *pchUplinkAddress);
static PUPLINK FindMatchingUplink(PECHOMGROPT pEchoMgrOpt, char *pchMyAddress);
static char *ExtractAreasFromMessage(char *pchMessageText, char *pchOldAreas);
static int ChangeUplink(HWND hwndDlg, SHORT sItem);
static int DeleteUplink(HWND hwndDlg, SHORT sItem, PECHOMGRDATA pEchoMgrData);
static MRESULT EXPENTRY UplinkProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
static int RemoveEchoFromUplink(HWND hwndDlg, PECHOMGRDATA pEchoMgrData);
static void CreateUplinkMenu(PECHOMGRDATA pEchoMgrData, ECHOMGROPT *pEchoMgrOpt);
static void SwitchUplink(HWND hwndDlg, PECHOMGRDATA pEchoMgrData, USHORT usID);
static SHORT _System SortEchos(PRECORDCORE p1, PRECORDCORE p2, PVOID pData);
static BOOL HaveArea(PSTRINGLIST pList, char *pchTag);
/*---------------------------------------------------------------------------*/
/* Funktionsname: EchoMgrProc */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Beschreibung: Window-Prozedur des Echo-Managers */
/* */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Parameter: WINPROC */
/* */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Rckgabewerte: MRESULT */
/* */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Sonstiges: - */
/* */
/*---------------------------------------------------------------------------*/
MRESULT EXPENTRY EchoMgrProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
extern HWND hwndhelp;
extern char CurrentAddress[LEN_5DADDRESS+1];
PECHOMGRDATA pEchoMgrData = WinQueryWindowPtr(hwnd, 0);
PFIELDINFO pFieldInfo, pFirstFieldInfo;
HWND hwndCnr;
FIELDINFOINSERT FieldInfoInsert;
CNRINFO CnrInfo;
PACTIONLIST pActionList=NULL;
switch(msg)
{
case WM_INITDLG:
/* Instanzdaten */
pEchoMgrData = calloc(1, sizeof(ECHOMGRDATA));
WinSetWindowPtr(hwnd, 0, pEchoMgrData);
/* Strings laden */
LoadString(IDST_EM_ECHO, ECHOMGR_STRINGLEN, pEchoMgrData->pchTitleEcho);
LoadString(IDST_EM_STATUS, ECHOMGR_STRINGLEN, pEchoMgrData->pchTitleStatus);
LoadString(IDST_EM_ACTION, ECHOMGR_STRINGLEN, pEchoMgrData->pchTitleAction);
LoadString(IDST_EM_LINKED, ECHOMGR_STRINGLEN, pEchoMgrData->pchStatusLinked);
LoadString(IDST_EM_UNLINKED, ECHOMGR_STRINGLEN, pEchoMgrData->pchStatusUnlinked);
LoadString(IDST_EM_LINK, ECHOMGR_STRINGLEN, pEchoMgrData->pchActionLink);
LoadString(IDST_EM_UNLINK, ECHOMGR_STRINGLEN, pEchoMgrData->pchActionUnlink);
LoadString(IDST_EM_RESCAN, ECHOMGR_STRINGLEN, pEchoMgrData->pchActionRescan);
LoadString(IDST_EM_REFRESH, ECHOMGR_STRINGLEN, pEchoMgrData->pchActionRefresh);
LoadString(IDST_EM_PAUSE, ECHOMGR_STRINGLEN, pEchoMgrData->pchActionPause);
LoadString(IDST_EM_RESUME, ECHOMGR_STRINGLEN, pEchoMgrData->pchActionResume);
/* Menues laden */
pEchoMgrData->hwndPopup = WinLoadMenu(HWND_OBJECT, hmodLang, IDM_EM_POPUP);
pEchoMgrData->hwndFolderPopup = WinLoadMenu(HWND_OBJECT, hmodLang, IDM_EMF_POPUP);
/* Spalten im Container */
hwndCnr = WinWindowFromID(hwnd, IDD_ECHOMANAGER+1);
pFirstFieldInfo=(PFIELDINFO)SendMsg(hwndCnr, CM_ALLOCDETAILFIELDINFO,
MPFROMLONG(3), NULL);
pFieldInfo=pFirstFieldInfo;
pFieldInfo->cb=sizeof(FIELDINFO);
pFieldInfo->flData=CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR;
pFieldInfo->flTitle=0;
pFieldInfo->pTitleData= pEchoMgrData->pchTitleEcho;
pFieldInfo->offStruct= FIELDOFFSET(ECHOMGRRECORD, pchEchoName);
pFieldInfo=pFieldInfo->pNextFieldInfo;
pFieldInfo->cb=sizeof(FIELDINFO);
pFieldInfo->flData=CFA_STRING | CFA_HORZSEPARATOR | CFA_SEPARATOR;
pFieldInfo->flTitle=0;
pFieldInfo->pTitleData= pEchoMgrData->pchTitleStatus;
pFieldInfo->offStruct= FIELDOFFSET(ECHOMGRRECORD, pchStatus);
pFieldInfo=pFieldInfo->pNextFieldInfo;
pFieldInfo->cb=sizeof(FIELDINFO);
pFieldInfo->flData=CFA_STRING | CFA_HORZSEPARATOR;
pFieldInfo->flTitle=0;
pFieldInfo->pTitleData= pEchoMgrData->pchTitleAction;
pFieldInfo->offStruct= FIELDOFFSET(ECHOMGRRECORD, pchAction);
/* Felder des Containers einfuegen */
FieldInfoInsert.cb=sizeof(FIELDINFOINSERT);
FieldInfoInsert.pFieldInfoOrder=(PFIELDINFO) CMA_FIRST;
FieldInfoInsert.fInvalidateFieldInfo=TRUE;
FieldInfoInsert.cFieldInfoInsert=3;
SendMsg(hwndCnr, CM_INSERTDETAILFIELDINFO,
pFirstFieldInfo, &FieldInfoInsert);
pEchoMgrData->pUplink = FindMatchingUplink(&EchoMgrOpt, CurrentAddress);
/* Container-Attribute setzen */
CnrInfo.cb=sizeof(CNRINFO);
CnrInfo.flWindowAttr=CV_DETAIL | CA_DETAILSVIEWTITLES | CA_CONTAINERTITLE |
CA_TITLEREADONLY | CA_TITLESEPARATOR;
CnrInfo.pSortRecord = (PVOID) SortEchos;
if (pEchoMgrData->pUplink)
CnrInfo.pszCnrTitle=pEchoMgrData->pUplink->pchEchoMgrAddress;
else
CnrInfo.pszCnrTitle=NULL;
SendMsg(hwndCnr, CM_SETCNRINFO, &CnrInfo,
MPFROMLONG(CMA_FLWINDOWATTR | CMA_CNRTITLE | CMA_PSORTRECORD));
CreateUplinkMenu(pEchoMgrData, &EchoMgrOpt);
if (pEchoMgrData->pUplink)
InsertEchos(hwndCnr, pEchoMgrData);
/* Fenstergroesse herstellen */
SetForeground(hwndCnr, &EchoMgrOpt.lFolderFore);
SetBackground(hwndCnr, &EchoMgrOpt.lFolderBack);
SetFont(hwndCnr, EchoMgrOpt.pchFolderFont);
RestoreWinPos(hwnd, &EchoMgrOpt.FolderPos, TRUE, TRUE);
pEchoMgrData->bNotify=TRUE;
break;
case WM_DESTROY:
{
LONG lColor;
char pchFont[FACESIZE+5];
HWND hwndCnr = WinWindowFromID(hwnd, IDD_ECHOMANAGER+1);
QueryForeground(hwndCnr, &lColor);
if (EchoMgrOpt.lFolderFore != lColor)
{
EchoMgrOpt.lFolderFore = lColor;
EchoMgrOpt.bDirty=TRUE;
}
QueryBackground(hwndCnr, &lColor);
if (EchoMgrOpt.lFolderBack != lColor)
{
EchoMgrOpt.lFolderBack = lColor;
EchoMgrOpt.bDirty=TRUE;
}
QueryFont(hwndCnr, pchFont);
if (strcmp(EchoMgrOpt.pchFolderFont, pchFont))
{
strcpy(EchoMgrOpt.pchFolderFont, pchFont);
EchoMgrOpt.bDirty=TRUE;
}
CleanupContainer(hwndCnr);
if (pEchoMgrData->hwndPopup)
WinDestroyWindow(pEchoMgrData->hwndPopup);
if (pEchoMgrData->hwndFolderPopup)
WinDestroyWindow(pEchoMgrData->hwndFolderPopup);
if (pEchoMgrData->pMenuTable)
free(pEchoMgrData->pMenuTable);
free(pEchoMgrData);
}
break;
case WM_COMMAND:
switch(SHORT1FROMMP(mp1))
{
case DID_OK:
memset(&pEchoMgrData->SaveParam, 0, sizeof(SAVEPARAM));
pEchoMgrData->SaveParam.hwndDlg = hwnd;
if (pEchoMgrData->pUplink)
{
switch(CreateMessage(WinWindowFromID(hwnd, IDD_ECHOMANAGER+1), pEchoMgrData,
&pEchoMgrData->SaveParam.Message, &pEchoMgrData->SaveParam.Header))
{
case 0:
if (EchoMgrOpt.pchDllName[0])
pActionList = CreateActionList(WinWindowFromID(hwnd, IDD_ECHOMANAGER+1));
/* Message speichern */
WinEnableControl(hwnd, DID_OK, FALSE);
WinEnableControl(hwnd, DID_CANCEL, FALSE);
if (pActionList)
{
PCHANGEPARAM pChangeParam;
pChangeParam = malloc(sizeof(CHANGEPARAM));
pChangeParam->hwndDlg = hwnd;
pChangeParam->pUplink = pEchoMgrData->pUplink;
pChangeParam->pActionList = pActionList;
_beginthread(CfgChangeThread, NULL, 32768, pChangeParam);
}
else
_beginthread(MessageSaveThread, NULL, 32768, &pEchoMgrData->SaveParam);
return (MRESULT) FALSE;
case 1:
MessageBox(hwnd, IDST_MSG_NOACTIONS, 0, IDD_NOACTIONS, MB_ERROR | MB_OK);
return (MRESULT) FALSE;
case 2:
MessageBox(hwnd, IDST_MSG_EM_NOPASS, 0, IDD_EM_NOPASS, MB_ERROR | MB_OK);
return (MRESULT) FALSE;
default:
return (MRESULT) FALSE;
}
}
break;
case DID_CANCEL:
if (WinIsWindowEnabled(WinWindowFromID(hwnd, DID_CANCEL)))
break;
else
return (MRESULT) FALSE;
case IDM_EMF_SETTINGS:
{
EMANSETTINGSDATA EManSettingsData;
EManSettingsData.cb = sizeof(EManSettingsData);
EManSettingsData.pEchoMgrData = pEchoMgrData;
if (WinDlgBox(HWND_DESKTOP, hwnd, EchoMgrSettings, hmodLang,
IDD_ECHOMGRSETTINGS, &EManSettingsData) == DID_OK)
WinDismissDlg(hwnd, DID_CANCEL);
}
return (MRESULT)FALSE;
case IDM_EMF_REFRESH:
pEchoMgrData->ulAction = ACTION_REFRESH;
CnrInfo.cb=sizeof(CNRINFO);
CnrInfo.pszCnrTitle = pEchoMgrData->pchActionRefresh;
WinSendDlgItemMsg(hwnd, IDD_ECHOMANAGER+1, CM_SETCNRINFO, &CnrInfo,
MPFROMLONG(CMA_CNRTITLE));
return (MRESULT)FALSE;
case IDM_EMF_PAUSE:
pEchoMgrData->ulAction = ACTION_PAUSE;
CnrInfo.cb=sizeof(CNRINFO);
CnrInfo.pszCnrTitle = pEchoMgrData->pchActionPause;
WinSendDlgItemMsg(hwnd, IDD_ECHOMANAGER+1, CM_SETCNRINFO, &CnrInfo,
MPFROMLONG(CMA_CNRTITLE));
return (MRESULT)FALSE;
case IDM_EMF_RESUME:
pEchoMgrData->ulAction = ACTION_RESUME;
CnrInfo.cb=sizeof(CNRINFO);
CnrInfo.pszCnrTitle = pEchoMgrData->pchActionResume;
WinSendDlgItemMsg(hwnd, IDD_ECHOMANAGER+1, CM_SETCNRINFO, &CnrInfo,
MPFROMLONG(CMA_CNRTITLE));
return (MRESULT)FALSE;
case IDM_EMF_RESET:
pEchoMgrData->ulAction = ACTION_NONE;
CnrInfo.cb=sizeof(CNRINFO);
if (pEchoMgrData->pUplink)
CnrInfo.pszCnrTitle = pEchoMgrData->pUplink->pchEchoMgrAddress;
else
CnrInfo.pszCnrTitle = NULL;
WinSendDlgItemMsg(hwnd, IDD_ECHOMANAGER+1, CM_SETCNRINFO, &CnrInfo,
MPFROMLONG(CMA_CNRTITLE));
return (MRESULT)FALSE;
case IDM_EM_LINK:
pEchoMgrData->pPopupRecord->ulAction = ACTION_LINK;
pEchoMgrData->pPopupRecord->pchAction = pEchoMgrData->pchActionLink;
WinSendDlgItemMsg(hwnd, IDD_ECHOMANAGER+1, CM_INVALIDATERECORD,
&pEchoMgrData->pPopupRecord, MPFROM2SHORT(1, CMA_TEXTCHANGED));
return (MRESULT)FALSE;
case IDM_EM_UNLINK:
pEchoMgrData->pPopupRecord->ulAction = ACTION_UNLINK;
pEchoMgrData->pPopupRecord->pchAction = pEchoMgrData->pchActionUnlink;
WinSendDlgItemMsg(hwnd, IDD_ECHOMANAGER+1, CM_INVALIDATERECORD,
&pEchoMgrData->pPopupRecord, MPFROM2SHORT(1, CMA_TEXTCHANGED));
return (MRESULT)FALSE;
case IDM_EM_RESCAN:
if (pEchoMgrData->pPopupRecord->ulAction == ACTION_LINK)
pEchoMgrData->pPopupRecord->ulAction = ACTION_LNKRESC;
else
pEchoMgrData->pPopupRecord->ulAction = ACTION_RESCAN;
pEchoMgrData->pPopupRecord->pchAction = pEchoMgrData->pchActionRescan;
WinSendDlgItemMsg(hwnd, IDD_ECHOMANAGER+1, CM_INVALIDATERECORD,
&pEchoMgrData->pPopupRecord, MPFROM2SHORT(1, CMA_TEXTCHANGED));
return (MRESULT)FALSE;
case IDM_EM_RESET:
pEchoMgrData->pPopupRecord->ulAction = ACTION_NONE;
pEchoMgrData->pPopupRecord->pchAction = NULL;
WinSendDlgItemMsg(hwnd, IDD_ECHOMANAGER+1, CM_INVALIDATERECORD,
&pEchoMgrData->pPopupRecord, MPFROM2SHORT(1, CMA_TEXTCHANGED));
return (MRESULT)FALSE;
case IDM_EM_REMOVE:
RemoveEchoFromUplink(hwnd, pEchoMgrData);
return (MRESULT)FALSE;
default:
SwitchUplink(hwnd, pEchoMgrData, SHORT1FROMMP(mp1));
return (MRESULT)FALSE;
}
break;
case WM_CONTROL:
if (SHORT1FROMMP(mp1) == IDD_ECHOMANAGER+1)
{
switch(SHORT2FROMMP(mp1))
{
case CN_CONTEXTMENU:
if (WinIsWindowEnabled(WinWindowFromID(hwnd, DID_CANCEL)))
OpenPopup(hwnd, (PECHOMGRRECORD) mp2, pEchoMgrData);
break;
default:
break;
}
}
break;
case WM_CLOSE:
if (WinIsWindowEnabled(WinWindowFromID(hwnd, DID_CANCEL)))
break;
else
return (MRESULT) FALSE;
case WM_ACTIVATE:
if (mp1)
WinAssociateHelpInstance(hwndhelp, hwnd);
else
WinAssociateHelpInstance(hwndhelp, NULLHANDLE);
break;
case WM_CONTEXTMENU:
if (WinIsWindowEnabled(WinWindowFromID(hwnd, DID_CANCEL)) &&
WinQueryFocus(HWND_DESKTOP) == WinWindowFromID(hwnd, IDD_ECHOMANAGER+1))
{
pEchoMgrData->bKeyboard=TRUE;
WinSendDlgItemMsg(hwnd, IDD_ECHOMANAGER+1, msg, mp1, mp2);
}
break;
case WM_WINDOWPOSCHANGED:
if (pEchoMgrData && pEchoMgrData->bNotify)
SaveWinPos(hwnd, (PSWP) mp1, &EchoMgrOpt.FolderPos, &EchoMgrOpt.bDirty);
break;
case WM_ADJUSTFRAMEPOS:
if (((PSWP)mp1)->fl & (SWP_SIZE|SWP_MAXIMIZE|SWP_MINIMIZE|SWP_RESTORE))
{
SWP swp;
RECTL rectl;
rectl.xLeft=0;
rectl.xRight=((PSWP)mp1)->cx;
rectl.yBottom=0;
rectl.yTop=((PSWP)mp1)->cy;
CalcClientRect(anchor, hwnd, &rectl);
WinQueryWindowPos(WinWindowFromID(hwnd, DID_OK), &swp);
rectl.yBottom += swp.y + swp.cy;
WinSetWindowPos(WinWindowFromID(hwnd, IDD_ECHOMANAGER+1),
NULLHANDLE,
rectl.xLeft, rectl.yBottom,
rectl.xRight-rectl.xLeft, rectl.yTop-rectl.yBottom,
SWP_MOVE | SWP_SIZE);
}
break;
case WM_QUERYTRACKINFO:
{
SWP swp;
MRESULT resultbuf;
/* Default-Werte aus Original-Prozedur holen */
resultbuf=WinDefDlgProc(hwnd, msg, mp1, mp2);
WinQueryWindowPos(WinWindowFromID(hwnd, IDD_ECHOMANAGER+2), &swp);
/* Minimale Fenstergroesse einstellen */
((PTRACKINFO)mp2)->ptlMinTrackSize.x=swp.x+swp.cx+5;
((PTRACKINFO)mp2)->ptlMinTrackSize.y=200;
return resultbuf;
}
case WM_MENUEND:
if ((HWND) mp2 == pEchoMgrData->hwndPopup ||
(HWND) mp2 == pEchoMgrData->hwndFolderPopup)
WinSendDlgItemMsg(hwnd, IDD_ECHOMANAGER+1, CM_SETRECORDEMPHASIS,
pEchoMgrData->pPopupRecord,
MPFROM2SHORT(FALSE, CRA_SOURCE));
break;
case WM_CHANGEDONE:
switch((ULONG) mp1)
{
case LOADDLL_CANTLOAD:
MessageBox(hwnd, IDST_MSG_EM_DLLLOAD, 0, IDD_EM_DLLLOAD, MB_ERROR | MB_OK);
break;
case LOADDLL_VERSION:
MessageBox(hwnd, IDST_MSG_EM_DLLVER, 0, IDD_EM_DLLVER, MB_ERROR | MB_OK);
break;
case LOADDLL_FUNCMISSING:
MessageBox(hwnd, IDST_MSG_EM_DLLFUNC, 0, IDD_EM_DLLFUNC, MB_ERROR | MB_OK);
break;
default:
break;
}
switch((ULONG) mp1)
{
case ECHOMAN_OK:
break;
case ECHOMAN_PARAMSIZE:
case ECHOMAN_FORMAT:
MessageBox(hwnd, IDST_MSG_EM_INIT, 0, IDD_EM_INIT, MB_ERROR | MB_OK);
break;
case ECHOMAN_CFGNOTFOUND:
MessageBox(hwnd, IDST_MSG_EM_CFGNOTF, 0, IDD_EM_CFGNOTF, MB_ERROR | MB_OK);
break;
case ECHOMAN_CFGREAD:
MessageBox(hwnd, IDST_MSG_EM_CFGREAD, 0, IDD_EM_CFGREAD, MB_ERROR | MB_OK);
break;
case ECHOMAN_CFGWRITE:
MessageBox(hwnd, IDST_MSG_EM_CFGWRITE, 0, IDD_EM_CFGWRITE, MB_ERROR | MB_OK);
break;
case ECHOMAN_CFGFORMAT:
MessageBox(hwnd, IDST_MSG_EM_CFGFORMAT, 0, IDD_EM_CFGFORMAT, MB_ERROR | MB_OK);
break;
case ECHOMAN_ALREADYLINKED:
MessageBox(hwnd, IDST_MSG_EM_CFGLINKED, 0, IDD_EM_CFGLINKED, MB_ERROR | MB_OK);
break;
case ECHOMAN_NOTLINKED:
MessageBox(hwnd, IDST_MSG_EM_CFGUNLINKED, 0, IDD_EM_CFGUNLINKED, MB_ERROR | MB_OK);
break;
default:
MessageBox(hwnd, IDST_MSG_EM_DLLINT, 0, IDD_EM_DLLINT, MB_ERROR | MB_OK);
break;
}
_beginthread(MessageSaveThread, NULL, 32768, &pEchoMgrData->SaveParam);
break;
case WM_SAVEDONE:
switch((ULONG) mp1)
{
case 0:
break;
default:
MessageBox(hwnd, IDST_MSG_ERRORMSGSAVE, 0, IDD_ERRORMSGSAVE, MB_OK | MB_ERROR);
break;
}
WinDismissDlg(hwnd, DID_OK);
return (MRESULT) FALSE;
default:
break;
}
return WinDefDlgProc(hwnd, msg, mp1, mp2);
}
static SHORT _System SortEchos(PRECORDCORE p1, PRECORDCORE p2, PVOID pData)
{
pData = pData;
return stricmp(((PECHOMGRRECORD)p1)->pchEchoName, ((PECHOMGRRECORD)p2)->pchEchoName);
}
/*-----------------------------------------------------------------------------
| Funktionsname: SwitchUplink
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Beschreibung: Schaltet den aktuellen Uplink um
|
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Parameter: hwndDlg: Dialog-Window-Handle
| pEchoMgrData: Instanzdaten des Echo-Managers
| usID: ID des gew„hlten Uplink-Menu-Punktes
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Rckgabewerte: -
|
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Sonstiges: -
|
+---------------------------------------------------------------------------*/
static void SwitchUplink(HWND hwndDlg, PECHOMGRDATA pEchoMgrData, USHORT usID)
{
int iUplink=0;
/* Uplink in Tabelle suchen */
while (iUplink < pEchoMgrData->ulCountUplinks)
{
if (pEchoMgrData->pMenuTable[iUplink].usID == usID)
break;
iUplink++;
}
if (iUplink < pEchoMgrData->ulCountUplinks) /* gefunden */
{
if (pEchoMgrData->pMenuTable[iUplink].pUplink != pEchoMgrData->pUplink) /* anderer als aktueller */
{
CNRINFO CnrInfo;
HWND hwndCnr = WinWindowFromID(hwndDlg, IDD_ECHOMANAGER+1);
/* umschalten */
CleanupContainer(hwndCnr);
pEchoMgrData->pUplink = pEchoMgrData->pMenuTable[iUplink].pUplink;
InsertEchos(hwndCnr, pEchoMgrData);
/* Aktionen zuruecksetzen */
pEchoMgrData->ulAction = ACTION_NONE;
CnrInfo.cb=sizeof(CNRINFO);
if (pEchoMgrData->pUplink)
CnrInfo.pszCnrTitle=pEchoMgrData->pUplink->pchEchoMgrAddress;
else
CnrInfo.pszCnrTitle=NULL;
SendMsg(hwndCnr, CM_SETCNRINFO, &CnrInfo, MPFROMLONG(CMA_CNRTITLE));
}
}
return;
}
/*---------------------------------------------------------------------------*/
/* Funktionsname: InsertEchos */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Beschreibung: Fuegt alle Echos in den Container ein */
/* */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Parameter: hwndCnr: Container-Window */
/* pEchoMgrData: Instanzdaten des Echomanagers */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Rckgabewerte: - */
/* */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Sonstiges: - */
/* */
/*---------------------------------------------------------------------------*/
static void InsertEchos(HWND hwndCnr, PECHOMGRDATA pEchoMgrData)
{
extern AREALIST arealiste;
ULONG ulNumAreas=0;
PCHAR pchTemp;
PCHAR pchCopy;
PECHOMGRRECORD pRecord, pFirstRecord;
RECORDINSERT RecordInsert;
if (!pEchoMgrData->pUplink->pchUplinkAreas ||
!pEchoMgrData->pUplink->pchUplinkAreas[0])
return;
pchTemp = pEchoMgrData->pUplink->pchUplinkAreas;
while (*pchTemp == ' ')
pchTemp++;
while (*pchTemp)
{
if (*pchTemp == ' ')
{
ulNumAreas++;
while (*pchTemp == ' ')
pchTemp++;
}
else
pchTemp++;
}
ulNumAreas++;
pchCopy = strdup(pEchoMgrData->pUplink->pchUplinkAreas);
pFirstRecord = SendMsg(hwndCnr, CM_ALLOCRECORD,
MPFROMLONG(sizeof(ECHOMGRRECORD) - sizeof(MINIRECORDCORE)),
MPFROMLONG(ulNumAreas));
pRecord = pFirstRecord;
pchTemp = strtok(pchCopy, " ");
while (pchTemp)
{
pRecord->pchEchoName = strdup(pchTemp);
if (AM_FindArea(&arealiste, pchTemp))
{
pRecord->pchStatus = pEchoMgrData->pchStatusLinked;
pRecord->ulStatus = STATUS_LINKED;
}
else
{
pRecord->pchStatus = pEchoMgrData->pchStatusUnlinked;
pRecord->ulStatus = STATUS_UNLINKED;
}
pRecord->pchAction = "";
pRecord->ulAction= ACTION_NONE;
pRecord = (PECHOMGRRECORD) pRecord->RecordCore.preccNextRecord;
pchTemp = strtok(NULL, " ");
}
free(pchCopy);
RecordInsert.cb = sizeof(RecordInsert);
RecordInsert.pRecordOrder = (PRECORDCORE) CMA_FIRST;
RecordInsert.pRecordParent = NULL;
RecordInsert.fInvalidateRecord = TRUE;
RecordInsert.zOrder = CMA_TOP;
RecordInsert.cRecordsInsert = ulNumAreas;
SendMsg(hwndCnr, CM_INSERTRECORD, pFirstRecord, &RecordInsert);
return;
}
/*-----------------------------------------------------------------------------
| Funktionsname: CreateUplinkMenu
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Beschreibung: Erzeugt das Unter-Men mit den Uplinks
|
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Parameter: pEchoMgrData: Instanzdaten
| pEchoMgrOpt: Echo-Manager-Optionen
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Rckgabewerte: -
|
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| Sonstiges: -
|
+---------------------------------------------------------------------------*/
static void CreateUplinkMenu(PECHOMGRDATA pEchoMgrData, ECHOMGROPT *pEchoMgrOpt)
{
PUPLINK pUplink = pEchoMgrOpt->pUplinks;
int iNumUplinks=0;
int iUplink=0;
MENUITEM SubMenu;
MENUITEM NewItem = {MIT_END, MIS_TEXT, 0, 0, NULLHANDLE, NULLHANDLE};
HWND hwndMenu;
/* Uplinks zaehlen */
while (pUplink)
{
iNumUplinks++;
pUplink = pUplink->next;
}
/* Anzahl begrenzen */
if (iNumUplinks >= (IDM_EM_POPUP - IDM_EMF_UPLINK))
iNumUplinks = IDM_EM_POPUP - IDM_EMF_UPLINK - 1;
if (iNumUplinks) /* nur, wenn wirklich welche da */
{
/* Feld anlegen */
pEchoMgrData->pMenuTable = calloc(iNumUplinks, sizeof(MENUTABLE));
pEchoMgrData->ulCountUplinks = iNumUplinks;
/* Sub-Menu holen */
SendMsg(pEchoMgrData->hwndFolderPopup, MM_QUERYITEM,
MPFROM2SHORT(IDM_EMF_UPLINK, FALSE), &SubMenu);
hwndMenu = SubMenu.hwndSubMenu;
/* alle Uplinks durchgehen */
pUplink = pEchoMgrOpt->pUplinks;
while (pUplink && iUplink < iNumUplinks)
{
/* Menue-Eintrag erzeugen */
NewItem.id = IDM_EMF_UPLINK+1+iUplink;
SendMsg(hwndMenu, MM_INSERTITEM, &NewItem, pUplink->pchEchoMgrAddress);
/* in Tabelle eintragen */
pEchoMgrData->pMenuTable[iUplink].usID = NewItem.id;
pEchoMgrData->pMenuTable[iUplink].pUplink = pUplink;
/* weiter */
iUplink++;
pUplink = pUplink->next;
}
}
return;
}
/*---------------------------------------------------------------------------*/
/* Funktionsname: CleanupContainer */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Beschreibung: Entfernt alle Records vom Container */
/* */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Parameter: hwndCnr: Container-Window */
/* */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Rckgabewerte: - */
/* */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Sonstiges: - */
/* */
/*---------------------------------------------------------------------------*/
static void CleanupContainer(HWND hwndCnr)
{
PECHOMGRRECORD pRecord = NULL;
while (pRecord = SendMsg(hwndCnr, CM_QUERYRECORD, pRecord,
MPFROM2SHORT(pRecord?CMA_NEXT:CMA_FIRST, CMA_ITEMORDER)))
{
if (pRecord->pchEchoName)
free(pRecord->pchEchoName);
}
SendMsg(hwndCnr, CM_REMOVERECORD, NULL, NULL);
return;
}
/*---------------------------------------------------------------------------*/
/* Funktionsname: OpenPopup */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Beschreibung: Oeffnet das Popup-Menue des Echo-Managers */
/* */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Parameter: hwndDlg: Echo-Manager-Dialog */
/* pRecord: Record, fuer den das Popup-Menue geoeffnet wurde */
/* pEchoMgrData: Instanz-Daten */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Rckgabewerte: - */
/* */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Sonstiges: - */
/* */
/*---------------------------------------------------------------------------*/
static void OpenPopup(HWND hwndDlg, PECHOMGRRECORD pRecord, PECHOMGRDATA pEchoMgrData)
{
POINTL pointl;
if (!pEchoMgrData->bKeyboard)
WinQueryPointerPos(HWND_DESKTOP, &pointl);
else
{
QUERYRECORDRECT qRecord;
RECTL rectl;
SWP swp;
WinQueryWindowPos(WinWindowFromID(hwndDlg, IDD_ECHOMANAGER+1), &swp);
if (pRecord)
{
qRecord.cb = sizeof(qRecord);
qRecord.pRecord = (PRECORDCORE) pRecord;
qRecord.fRightSplitWindow=FALSE;
qRecord.fsExtent = CMA_TEXT;
WinSendDlgItemMsg(hwndDlg, IDD_ECHOMANAGER+1, CM_QUERYRECORDRECT,
&rectl, &qRecord);
pointl.x = swp.x + rectl.xLeft+ (rectl.xRight - rectl.xLeft)/2;
pointl.y = swp.y + rectl.yBottom + (rectl.yTop - rectl.yBottom)/2;
}
else
{
pointl.x = swp.x + swp.cx/2;
pointl.y = swp.y + swp.cy/2;
}
WinMapWindowPoints(hwndDlg, HWND_DESKTOP, &pointl, 1);
}
pEchoMgrData->pPopupRecord = pRecord;
WinSendDlgItemMsg(hwndDlg, IDD_ECHOMANAGER+1, CM_SETRECORDEMPHASIS, pRecord,
MPFROM2SHORT(TRUE, CRA_SOURCE));
if (pRecord)
{