-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.c
4259 lines (3761 loc) · 144 KB
/
main.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: Fleet Street Messagereader |
+-----------------------------------------+---------------------------------+
| Erstellt von: Michael Hohner | Am: 15.04.93 |
+-----------------------------------------+---------------------------------+
| System: OS/2 2.x PM mit CSet++ 2.1 |
+---------------------------------------------------------------------------+
| Beschreibung: Messagereader fuer Fido- und Squish-Messagebase |
| |
+---------------------------------------------------------------------------+
| Bemerkungen: |
+---------------------------------------------------------------------------*/
/*----------------------------- Header-Dateien ------------------------------*/
#pragma strings(readonly)
#define INCL_GPI
#define INCL_WIN
#define INCL_BASE
#define INCL_SPL
#define INCL_SPLDOSPRINT
#include <os2.h>
#include <io.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "main.h"
#include "version.h"
#include "structs.h"
#include "msgheader.h"
#include "areaman/areaman.h"
#include "areaman/folderman.h"
#include "dialogs.h"
#include "dialogids.h"
#include "resids.h"
#include "messages.h"
#include "controls/editwin.h"
#include "controls/statline.h"
#include "controls/msgviewer.h"
#include "controls/toolbar.h"
#include "handlemsg/handlemsg.h"
#include "handlemsg/kludgeapi.h"
#include "init.h"
#include "help.h"
#include "areadlg.h"
#include "areascan.h"
#include "mainwindow.h"
#include "msglist.h"
#include "setupdlg.h"
#include "finddlg.h"
#include "pipeserv.h"
#include "utility.h"
#include "cclist.h"
#include "templatedlg.h"
#include "savemsg.h"
#include "fltv7/fltv7.h"
#include "lookups.h"
#include "attachcheck.h"
#include "threadlist.h"
#include "secwin.h"
#include "ccmanage.h"
#include "rxfolder.h"
#include "rexxexec.h"
#include "markmanage.h"
#include "nlbrowser.h"
#include "nickmanage.h"
#include "nicknames.h"
#include "echomanager.h"
#include "printsetup.h"
#include "toolbarconfig.h"
#include "request.h"
#include "request_manage.h"
#include "dump/expt.h"
#include "dump/pmassert.h"
#include "util/addrcnv.h"
/*--------------------------------- Defines ---------------------------------*/
#define REQUIRED_LANGDLL_VERSION 24UL
#define WINDOWTITLE "FleetStreet " FLEETVER
#define WINDOWTITLESEC "FleetStreet " FLEETVER " [*]"
char pchWindowTitle[100];
#define TPLTYPE_NEW 0
#define TPLTYPE_QUOTE 1
#define TPLTYPE_FORWARD 2
/*---------------------------- Globale Variablen ----------------------------*/
/* Fensterhandles */
HAB anchor = 0;
HMQ queue = NULLHANDLE;
HMODULE hmodLang=NULLHANDLE;
HWND frame = NULLHANDLE;
HWND client = NULLHANDLE;
HWND hwndmenu = NULLHANDLE;
HWND hwndhelp = NULLHANDLE;
PFNWP OldFrameProc=NULL; /* Original-WP des Frame */
volatile BOOL issecondinstance=FALSE;
volatile BOOL isregistered=FALSE;
volatile HWND hwndKludge=NULLHANDLE;
volatile HWND hwndAreaDlg=NULLHANDLE;
HACCEL hAccel1=NULLHANDLE;
HACCEL hAccel2=NULLHANDLE;
HACCEL hAccel3=NULLHANDLE;
volatile ULONG ProfileError;
BOOL bProfileSaved=FALSE;
BOOL bNoHook=FALSE;
volatile HWND hwndTemplates = NULLHANDLE;
volatile HWND hwndCCLists = NULLHANDLE;
volatile HWND hwndRxFolder = NULLHANDLE;
/* Nodelist-Browser */
volatile HWND hwndNLBrowser = NULLHANDLE;
volatile BOOL bDoingBrowse = FALSE;
/* Merker fuer den Exit */
BOOL MailEntered[3]={FALSE, FALSE, FALSE};
/* Scan-Thread */
int tidAreaScan=0;
volatile BOOL DoingAreaScan=FALSE;
volatile BOOL StopAreaScan=FALSE;
/* Find-Thread */
int tidFind=0;
volatile HWND hwndFindDlg=NULLHANDLE;
volatile HWND hwndFindResults=NULLHANDLE;
volatile BOOL DoingFind=FALSE;
volatile BOOL StopFind=FALSE;
/* Worker-Thread */
volatile int tidWorker=0;
volatile BOOL bDoingWork=FALSE;
volatile BOOL bStopWork = FALSE;
/* Thread-Liste */
volatile int tidThreadList=0;
volatile HWND hwndThreadList=NULLHANDLE;
volatile BOOL DoingInsert=FALSE;
volatile BOOL StopInsert=FALSE;
/* Message-Liste */
volatile HWND hwndMsgList=NULLHANDLE;
/* Request-Dialog */
volatile HWND hwndRequester=NULLHANDLE;
volatile BOOL bIgnoreActivate=FALSE;
/* Script-Ausfuehrung */
volatile HWND hwndMonitor=NULLHANDLE;
volatile PRXSCRIPT pExecScript=NULL;
volatile int tidRexxExec=0;
/* Messages schreiben */
BOOL NewMessage=FALSE;
char NewArea[LEN_AREATAG+1]="";
char *pchXPostList=NULL;
ULONG ulCCSelected=0;
char SaveToName[LEN_USERNAME+1];
char SaveToAddress[LEN_5DADDRESS+1];
int QuotedMsgNum=0;
LONG iptInitialPos=0;
LONG iptInitialPos2=0;
BOOL bTemplateProcessed=TRUE;
ULONG ulTemplateType=0;
BOOL bOldMsgLocal=FALSE;
/* Alle Programmoptionen */
AREALIST arealiste;
NICKNAMELIST NickNameList;
USERDATAOPT userdaten;
WINDOWCOLORS windowcolors;
WINDOWFONTS windowfonts;
WINDOWPOSITIONS windowpositions;
PATHNAMES pathnames;
MISCOPTIONS miscoptions;
MACROTABLEOPT macrotable;
GENERALOPT generaloptions;
NODELISTOPT nodelist;
ECHOTOSSOPT echotossoptions;
PDOMAINS domains=NULL;
OUTBOUND outbound[MAX_ADDRESSES];
INTLSETTING intlsetting;
THREADLISTOPTIONS threadlistoptions;
LOOKUPOPTIONS lookupoptions;
RESULTSOPTIONS resultsoptions;
REQUESTOPT requestoptions;
AREALISTOPTIONS arealistoptions;
MSGLISTOPTIONS msglistoptions;
DRIVEREMAP driveremap;
TEMPLATELIST templatelist;
CCANCHOR ccanchor;
SCRIPTLIST scriptlist;
PCCLIST pQuickCCList=NULL;
REXXHOOKS rexxhooks;
FINDJOB FindJob;
MARKERLIST MarkerList;
BOOL bSaveResults;
BROWSEROPTIONS BrowserOptions;
ULONG ulExportOptions;
TOOLBAROPTIONS ToolbarOptions;
ECHOMGROPT EchoMgrOpt;
SEARCHPAR SearchPar;
PRINTSETUP PrintSetup;
TOOLBARCONFIG ToolbarConfig;
OPENWIN OpenWindows;
FOLDERANCHOR FolderAnchor;
/* Derzeitige Message */
FTNMESSAGE CurrentMessage;
MSGHEADER CurrentHeader;
char CurrentAddress[LEN_5DADDRESS+1]="";
char CurrentName[LEN_USERNAME+1]="";
char CurrentArea[LEN_AREATAG+1]="";
int CurrentStatus=PROGSTATUS_NOSETUP;
int MonoDisp=FALSE;
int TempMono=FALSE; /* temp. monospaced (wg. NPD-Flag) */
/*--------------------------- Funktionsprototypen ---------------------------*/
static MRESULT EXPENTRY clientwndproc(HWND fenster, ULONG message, MPARAM mp1, MPARAM mp2);
static void ProcessCommands(HWND client, USHORT CommandID);
static BOOL ProcessKeys(HWND client, USHORT usVK);
static MRESULT ProcessWorkMessages(HWND hwnd, ULONG message, MPARAM mp1, MPARAM mp2);
void StartQuickRexx(USHORT menuID);
static void EditMenuCommands(HWND client, ULONG message);
static int SwitchToArea(char *NewArea);
static void ShutdownProgram(void);
static void HandleAttachAttrib(HWND hwndClient);
static int QuoteCurrentMessage(PWINDOWDATA pWindowData, BOOL bDiffArea, ULONG ulReplyDest,
ULONG ulOptions);
static int GetReplyArea(PFTNMESSAGE pCurrentMessage, char *pchDestArea);
static void ShowSecondaryWindows(BOOL bShow);
static BOOL SearchInMessage(HWND hwndClient, PSEARCHPAR pSearchPar);
/*---------------------------------- main -----------------------------------*/
int main(int argc, char **argv)
{
QMSG qmsg;
HELPINIT hinit;
char pchModError[100];
HWND hwndAbout=NULLHANDLE;
HEV hevInit=NULLHANDLE;
ULONG ulTimerID=0;
HWND hwnd;
PFNWP pPrevProc;
int rc = RET_NOACTION;
ULONG ulCurrentCP, ulRet;
ULONG frameflags= FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON |
FCF_TASKLIST | FCF_SYSMENU | FCF_TITLEBAR;
INSTALLEXPT("Main");
/* erkennen, ob schon eine Instanz laeuft*/
if (issecondinstance=AlreadyRunning())
strcpy(pchWindowTitle, WINDOWTITLESEC);
else
strcpy(pchWindowTitle, WINDOWTITLE);
anchor=WinInitialize(0);
PMASSERT(anchor != NULLHANDLE, "Can't init PM");
queue=WinCreateMsgQueue(anchor,100);
PMASSERT(queue != NULLHANDLE, "Can't create msg queue");
DosQueryCp(sizeof(ulCurrentCP), &ulCurrentCP, &ulRet);
MSG_SetCPInfo(ulCurrentCP);
if (!RegisterSecondaryWindows(anchor))
return RET_ERROR;
OpenMarkerList(&MarkerList);
/* Language-DLL laden */
if (DosLoadModule(pchModError, 100, "FLEETLNG", &hmodLang))
{
/* DLL nicht erfolgreich geladen */
WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
"FLEETLNG.DLL not found! Run INSTALL.EXE.",
"Fatal error!", 50000, MB_OK | MB_ERROR | MB_MOVEABLE);
return RET_ERROR;
}
else
{
ULONG (* _System QueryLangVersion)(void);
if (DosQueryProcAddr(hmodLang, 0, "FLTLNG_QueryVersion", (PFN *) &QueryLangVersion) ||
QueryLangVersion() != REQUIRED_LANGDLL_VERSION)
{
/* falsche DLL-Version */
WinMessageBox(HWND_DESKTOP, HWND_DESKTOP,
"The language DLL is not suited for this version"
" of FleetStreet. Run INSTALL.EXE to update your installation.",
"Fatal error!", 50000, MB_OK | MB_ERROR | MB_MOVEABLE);
return RET_ERROR;
}
}
if (!WinRegisterClass(anchor,
"FleetStreet",
clientwndproc,
CS_SIZEREDRAW | CS_SYNCPAINT,
sizeof(PVOID)))
return RET_ERROR; /* Register fehlgeschlagen */
/* Semaphore fuer Init */
DosCreateEventSem(NULL, &hevInit, 0, FALSE);
/* Timer starten f. About-Dialog*/
ulTimerID=WinStartTimer(anchor, 0, 0, 500);
if (LogoDisplayEnabled())
{
/* About-Dialog anzeigen */
hwndAbout=WinLoadDlg(HWND_DESKTOP, HWND_DESKTOP, AboutProc, hmodLang,
IDD_HELPABOUT, NULL);
PMASSERT(hwndAbout != NULLHANDLE, "Can't load about dialog");
WinShowWindow(hwndAbout, TRUE);
}
/* INI-Thread starten */
ParseArgs(argc, argv);
if (!_beginthread(ReadIniThread, NULL, 65536, &hevInit))
return RET_ERROR;
/* erste Message-Loop */
while(WinGetMsg(anchor,&qmsg,0,0,0))
if ((qmsg.msg != WM_TIMER) || (LONGFROMMP((qmsg.mp1)) != ulTimerID))
WinDispatchMsg(anchor, &qmsg);
else
{
if (!WinWaitEventSem(hevInit, SEM_IMMEDIATE_RETURN))
{
WinStopTimer(anchor, 0, ulTimerID);
break;
}
}
if (hwndAbout)
WinDestroyWindow(hwndAbout);
DosCloseEventSem(hevInit);
CreatePipes();
InitPrintSetup(&PrintSetup, anchor);
memset(&CurrentMessage, 0, sizeof(CurrentMessage));
if (!(windowpositions.mainwindowpos.uchFlags & WINPOS_VALID))
frameflags |= FCF_SHELLPOSITION;
if (!(frame=WinCreateStdWindow(HWND_DESKTOP,
0,
&frameflags,
"FleetStreet",
pchWindowTitle,
WS_SYNCPAINT,
NULLHANDLE, /* Ressourcen */
ID_WINDOW,
&client)))
return RET_ERROR; /* Fenster kann nicht erzeugt werden */
#if 0
AddToWindowList(frame);
#endif
InitMainWindow(client);
/* Frame-Window ableiten */
pPrevProc= WinSubclassWindow(frame, ToolbarFrameProc);
WinSetWindowPtr(frame, 0, (PVOID) pPrevProc);
/* Menue laden */
hwndmenu=WinLoadMenu(frame, hmodLang, IDM_MENU);
PMASSERT(hwndmenu != NULLHANDLE, "Can't load menu");
CreateToolbar(frame);
CreateStatusLine(frame);
/* Rexx-Menue-Handle holen */
hwnd = WinWindowFromID(frame, FID_MENU);
if (hwnd)
{
MENUITEM MenuItem;
if (SendMsg(hwnd, MM_QUERYITEM, MPFROM2SHORT(IDM_REXX, FALSE), &MenuItem))
{
PWINDOWDATA pWindowData;
pWindowData=(PWINDOWDATA) WinQueryWindowULong(client, QWL_USER);
pWindowData->hwndRexxMenu = MenuItem.hwndSubMenu;
UpdateRexxMenu(pWindowData->hwndRexxMenu);
}
}
SetFont(hwndmenu, windowfonts.menufont);
SendMsg(frame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, NULL);
RestoreWinPos(frame, &windowpositions.mainwindowpos, TRUE, TRUE);
WinSendDlgItemMsg(client, IDML_MAINEDIT, MLM_SETTEXTCOLOR,
MPFROMLONG(windowcolors.editfore), NULL);
/* Helpsystem initialisieren */
memset(&hinit, 0, sizeof(hinit));
hinit.cb=sizeof(HELPINIT);
hinit.phtHelpTable=(PHELPTABLE) MAKEULONG(FLEET_HELP_TABLE, 0xffff);
hinit.pszHelpWindowTitle="FleetStreet"; /* Titel der Hilfe */
hinit.fShowPanelId=CMIC_HIDE_PANEL_ID;
hinit.pszHelpLibraryName="FLTSTRT.HLP"; /* Helpfile */
if (!(hwndhelp=WinCreateHelpInstance(anchor,&hinit)) ||
hinit.ulReturnCode)
{
char msgbuf[200];
LoadString(IDST_MSG_NOHELP, 200, msgbuf);
WinMessageBox(HWND_DESKTOP,
HWND_DESKTOP,
msgbuf,
NULL,
IDD_NOHELP,
MB_OK | MB_ERROR | MB_MOVEABLE);
}
else
WinAssociateHelpInstance(hwndhelp, frame);
if (ProfileError)
{
if (HandleInitErrors(client, ProfileError) != MBID_OK)
{
bProfileSaved = TRUE;
return RET_ERROR;
}
if (ProfileError == INIERROR(INIFILE_NEW))
{
WinPostMsg(client, WM_COMMAND, MPFROM2SHORT(IDM_OPCONFIG,0),
MPFROM2SHORT(CMDSRC_MENU, 0));
if (hwndhelp)
SendMsg(hwndhelp, HM_GENERAL_HELP, NULL, NULL);
}
}
hAccel1=WinLoadAccelTable(anchor, NULLHANDLE, ID_ACCEL1);
hAccel2=WinLoadAccelTable(anchor, NULLHANDLE, ID_ACCEL2);
hAccel3=WinLoadAccelTable(anchor, NULLHANDLE, ID_ACCEL3);
StatusChanged(client, CurrentStatus);
TplSetIntl(&intlsetting);
if (MSG_OpenApi(userdaten.address[0]))
return RET_ERROR;
if (generaloptions.uselastarea)
SwitchToArea(miscoptions.lastarearead);
else
SwitchToArea(generaloptions.startarea);
if (generaloptions.scanatstartup)
{
MarkAllAreas(&arealiste, FOLDERID_ALL, WORK_SCAN);
if ((tidAreaScan=_beginthread(ScanAreas, NULL, 32768, &arealiste))==-1)
WinAlarm(HWND_DESKTOP, WA_ERROR);
}
if (!issecondinstance)
{
/* Pipe starten */
_beginthread(NewPipeServer, NULL, 32768, NULL);
}
RestoreOpenWindows(&OpenWindows);
SetFocusControl(client, IDML_MAINEDIT);
/* Message-Loop */
do
{
WinGetMsg(anchor, &qmsg, 0, 0, 0);
if (qmsg.msg == WM_QUIT &&
qmsg.hwnd)
qmsg.msg = WM_CLOSE;
WinDispatchMsg(anchor, &qmsg);
} while(qmsg.msg != WM_QUIT);
ShutdownProgram();
MSG_CloseArea(&arealiste, CurrentArea, TRUE, miscoptions.lastreadoffset, &driveremap);
MSG_CloseApi(&arealiste, &driveremap);
TermPrintSetup(&PrintSetup);
if (hwndhelp)
{
WinAssociateHelpInstance(NULLHANDLE, hwndhelp);
WinDestroyHelpInstance(hwndhelp);
}
if (hmodLang)
DosFreeModule(hmodLang);
if (frame)
WinDestroyWindow(frame);
if (queue)
WinDestroyMsgQueue(queue);
if (anchor)
WinTerminate(anchor);
AM_DeleteAllAreas(&arealiste);
CleanupDomains(&domains);
CloseMarkerList(&MarkerList);
/* Errorlevel erzeugen */
if (MailEntered[AREATYPE_NET])
rc += RET_NEWNETMAIL;
if (MailEntered[AREATYPE_ECHO])
rc += RET_NEWECHOMAIL;
if (MailEntered[AREATYPE_LOCAL])
rc += RET_NEWLOCALMAIL;
DEINSTALLEXPT;
return rc;
}
/*------------------------------ clientwndroc ------------------------------*/
/* Die Fensterprozedur */
/*---------------------------------------------------------------------------*/
static MRESULT EXPENTRY clientwndproc(HWND fenster, ULONG message, MPARAM mp1, MPARAM mp2)
{
char chBuffer[LEN_AREATAG+1+20];
AREADEFLIST *zeiger=NULL;
static char pchFormatScanning[50];
REQUESTPAR *pRequestPar=NULL;
ULONG ulResult=0;
PWINDOWDATA pWindowData;
BOOL bInsert;
MESSAGEID MessageID;
HWND hwnd;
pWindowData=(PWINDOWDATA) WinQueryWindowULong(fenster, QWL_USER);
switch(message)
{
/* Bei Drag-Drop aus der Farbpalette */
case WM_PRESPARAMCHANGED:
if (((ULONG)mp1)==PP_BACKGROUNDCOLOR) /* andere Aenderungen nicht */
{ /* beachten */
WinQueryPresParam(fenster,
(ULONG)mp1, 0,
NULL,
sizeof(LONG),
(PVOID)&windowcolors.windowback,
0);
WinInvalidateRect(fenster, 0, TRUE);
}
return 0;
case WM_MOUSEMOVE:
DisplayStatusText(0);
break;
case WM_MINMAXFRAME:
if (((PSWP)mp1)->fl & SWP_MINIMIZE)
{
ShowSecondaryWindows(FALSE);
}
if (((PSWP)mp1)->fl & (SWP_MAXIMIZE | SWP_RESTORE))
{
ShowSecondaryWindows(TRUE);
}
break;
case WM_SAVEAPPLICATION:
if (!bProfileSaved)
{
if (echotossoptions.useechotoss &&
echotossoptions.pchEchoToss[0])
WriteEchotoss(&arealiste, echotossoptions.pchEchoToss);
QueryLayout(fenster);
QueryOpenWindows(&OpenWindows);
/* zweite Instanz darf nicht speichern */
if (!issecondinstance)
{
SaveIniProfile(anchor);
if (arealiste.bDirty)
SaveIniAreas(anchor);
}
}
break;
/* PM soll Hintergrund loeschen */
case WM_PAINT:
{
HPS hps;
RECTL rectl;
hps=WinBeginPaint(fenster, NULLHANDLE, &rectl);
/* Color Table auf RGB umschalten */
GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, 0);
WinFillRect(hps, &rectl, windowcolors.windowback);
WinEndPaint(hps);
}
return (MRESULT) FALSE;
/* Alle Controls einrichten */
case WM_CREATE:
LoadString(IDST_FORMAT_SCANNING, 50, pchFormatScanning);
break;
/* Menue klappt auf */
case WM_INITMENU:
if ((HWND) mp2 != pWindowData->hwndPopup)
InitMenus(SHORT1FROMMP(mp1), (HWND) mp2);
break;
case WM_MENUSELECT:
if ((HWND) mp2 != pWindowData->hwndPopup)
DisplayMenuHelp(client, SHORT1FROMMP(mp1));
break;
case WM_CONTEXTMENU:
if (mp2)
{
hwnd=WinQueryFocus(HWND_DESKTOP);
if (hwnd)
SendMsg(hwnd, message, mp1, mp2);
}
break;
/* Groesse veraendert, anpassen */
case WM_SIZE:
FLTLAY_ResizeMainWindow(fenster, SHORT1FROMMP(mp2),SHORT2FROMMP(mp2));
return (MRESULT) FALSE;
case WM_CLOSE:
if (tidRexxExec || bDoingWork || DoingFind || bDoingBrowse)
return (MRESULT) FALSE;
MSG_MarkRead(&arealiste, CurrentArea, 0, CurrentName, &driveremap);
if (CurrentStatus == PROGSTATUS_EDITING)
{
if (MessageBox(client, IDST_MSG_EXITNOSAVE, IDST_TITLE_DISCARD,
IDD_EXITNOSAVE,
MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2)!=MBID_YES)
return (MRESULT) FALSE;
}
if (!bProfileSaved && CurrentStatus != PROGSTATUS_CLEANUP)
{
if (echotossoptions.useechotoss &&
echotossoptions.pchEchoToss[0])
if (WriteEchotoss(&arealiste, echotossoptions.pchEchoToss))
{
MessageBox(client, IDST_MSG_ETOSSERROR, 0, IDD_ETOSSERROR,
MB_ERROR | MB_OK);
return (MRESULT) FALSE;
}
QueryLayout(fenster);
QueryOpenWindows(&OpenWindows);
CurrentStatus = PROGSTATUS_CLEANUP;
UpdateDisplay(FALSE, FALSE);
ShutdownProgram();
StatusChanged(client, CurrentStatus);
if (!bNoHook && rexxhooks.ulExitID && !StartRexxScript(rexxhooks.ulExitID, NULL))
{
pWindowData->ulCurrentHook = CURRENTHOOK_EXIT;
return (MRESULT) FALSE;
}
if (!issecondinstance)
{
_beginthread(SaveIniProfileThread, NULL, 32768, &queue);
}
else
break;
}
return (MRESULT) FALSE;
case KM_KLUDGEWNDCLOSE:
WinDestroyWindow(hwndKludge);
hwndKludge=NULLHANDLE;
if (pWindowData->pArea &&
pWindowData->pArea->maxmessages>0)
WinSendDlgItemMsg(frame, FID_TOOLBAR, TBM_ENABLECMD, MPFROMLONG(IDB_SHOWKLUDGES), NULL);
break;
case FM_FINDRESULTSCLOSE:
WinDestroyWindow(hwndFindResults);
hwndFindResults=NULLHANDLE;
break;
case MSGLM_CLOSE:
WinDestroyWindow(hwndMsgList);
hwndMsgList=NULLHANDLE;
break;
case TM_THREADLISTCLOSE:
WinDestroyWindow(hwndThreadList);
hwndThreadList=NULLHANDLE;
break;
case ALM_CLOSE:
if (hwndAreaDlg == (HWND) mp1)
{
WinDestroyWindow(hwndAreaDlg);
hwndAreaDlg = NULLHANDLE;
}
break;
case TPLF_CLOSE:
WinDestroyWindow(hwndTemplates);
hwndTemplates=NULLHANDLE;
break;
case CCFM_CLOSE:
WinDestroyWindow(hwndCCLists);
hwndCCLists=NULLHANDLE;
break;
case RXF_CLOSE:
WinDestroyWindow(hwndRxFolder);
hwndRxFolder=NULLHANDLE;
break;
case BRSM_CLOSE:
if (hwndNLBrowser)
{
WinDestroyWindow(hwndNLBrowser);
hwndNLBrowser=NULLHANDLE;
}
break;
case REXXM_CLOSE:
WinDestroyWindow((HWND) mp1);
if (hwndRxFolder)
SendMsg(hwndRxFolder, REXXM_CLOSE, mp1, mp2);
hwndMonitor = NULLHANDLE;
switch (pWindowData->ulCurrentHook)
{
case CURRENTHOOK_NONE:
break;
case CURRENTHOOK_PRESAVE:
pWindowData->ulCurrentHook = CURRENTHOOK_NONE;
bNoHook=TRUE;
ProcessCommands(client, IDB_OK);
bNoHook=FALSE;
break;
case CURRENTHOOK_EXIT:
pWindowData->ulCurrentHook = CURRENTHOOK_NONE;
CurrentStatus = PROGSTATUS_READING;
bNoHook=TRUE;
SendMsg(client, WM_CLOSE, NULL, NULL);
bNoHook=FALSE;
break;
}
break;
case RXM_UPDATEMENU:
if (pWindowData->hwndRexxMenu)
UpdateRexxMenu(pWindowData->hwndRexxMenu);
break;
case ALM_SWITCHAREA:
/* Source-Window */
pWindowData->ulSourceWindow = SOURCEWIN_AREA;
if (CurrentStatus == PROGSTATUS_READING &&
stricmp(CurrentArea, (PCHAR) mp1))
{
MSGLISTPAR MsgListPar;
MSG_MarkRead(&arealiste, CurrentArea, 0, CurrentName, &driveremap);
strcpy(MessageID.pchAreaTag, CurrentArea);
MessageID.ulMsgID=pWindowData->ulCurrentID;
SendMsg(client, WORKM_READ, &MessageID, NULL);
/* Aktuelle Area schliessen */
MSG_CloseArea(&arealiste, CurrentArea, TRUE, miscoptions.lastreadoffset, &driveremap);
/* Neue Area oeffnen */
NewMessage=FALSE;
SwitchToArea(mp1);
MsgListPar.msgnum=MSG_MsgnToUid(&arealiste, CurrentArea, QueryCurrent(&arealiste, CurrentArea));
pWindowData->ulCurrentID= MsgListPar.msgnum;
if (hwndThreadList)
SendMsg(hwndThreadList, TM_REREADTHREADS, &MsgListPar, NULL);
if (hwndMsgList)
SendMsg(hwndMsgList, TM_REREADTHREADS, &MsgListPar, NULL);
}
break;
case WM_DESTROY:
if (pWindowData->hwndPopup)
WinDestroyWindow(pWindowData->hwndPopup);
break;
case WM_CONTROLPOINTER:
DisplayStatusText(SHORT1FROMMP(mp1));
break;
case WM_COMMAND:
ProcessCommands(fenster, SHORT1FROMMP(mp1));
return (MRESULT) FALSE;
case WM_CONTROL:
switch (SHORT1FROMMP(mp1))
{
case FID_STATUSLINE:
switch(SHORT2FROMMP(mp1))
{
case STLN_CONTEXTMENU:
break;
case STLN_OPEN:
if ((ULONG) mp2 == pWindowData->idAddressField)
ProcessCommands(client, IDM_OPNAMEADDR);
if ((ULONG) mp2 == pWindowData->idCheckField &&
CurrentStatus == PROGSTATUS_READING)
ProcessCommands(client, IDA_MARKTOGGLE);
if ((ULONG) mp2 == pWindowData->idProgressField)
ProcessCommands(client, IDA_CANCEL);
break;
default:
break;
}
break;
case FID_TOOLBAR:
switch(SHORT2FROMMP(mp1))
{
case TBN_CONTEXTMENU:
OpenToolbarContext(client, pWindowData, (ULONG) mp2);
break;
default:
break;
}
break;
case IDE_TOADDRESS:
if (SHORT2FROMMP(mp1)==EN_SETFOCUS)
SendMsg((HWND)mp2, EM_SETSEL, MPFROM2SHORT(0, LEN_5DADDRESS+1),
NULL);
if (SHORT2FROMMP(mp1)==EN_KILLFOCUS && !ulCCSelected && !pQuickCCList &&
CurrentStatus == PROGSTATUS_EDITING)
{
char pchTemp[LEN_5DADDRESS+1];
FTNADDRESS tempAddr, tempAddr2;
int iMatch;
WinQueryWindowText((HWND)mp2, LEN_5DADDRESS+1, pchTemp);
StringToNetAddr(pchTemp, &tempAddr, CurrentAddress);
WinSetWindowText((HWND)mp2, NetAddrToString(pchTemp, &tempAddr));
WinQueryWindowText(WinWindowFromID(client, IDE_FROMADDRESS), LEN_5DADDRESS+1, pchTemp);
StringToNetAddr(pchTemp, &tempAddr2, NULL);
iMatch = MSG_MatchAddress(&tempAddr, &userdaten, &tempAddr2);
if (iMatch>=0)
WinSetDlgItemText(client, IDE_FROMADDRESS, userdaten.address[iMatch]);
}
if (SHORT2FROMMP(mp1) == EN_CONTEXTMENU)
{
pWindowData->usPopupControl = SHORT1FROMMP(mp1);
OpenEditPopup(client, pWindowData, (BOOL) mp2);
return 0;
}
if (SHORT2FROMMP(mp1) == EN_NODEDROPPED && mp2)
{
PCHAR pchTemp=strchr((PCHAR)mp2, ' ');
if (pchTemp)
{
pchTemp++;
WinSetDlgItemText(client, IDE_TONAME, pchTemp);
}
}
break;
case IDE_FROMADDRESS:
if (SHORT2FROMMP(mp1)==EN_SETFOCUS)
SendMsg((HWND)mp2, EM_SETSEL, MPFROM2SHORT(0, LEN_5DADDRESS+1),
NULL);
if (SHORT2FROMMP(mp1)==EN_KILLFOCUS && CurrentStatus == PROGSTATUS_EDITING)
{
char pchTemp[LEN_5DADDRESS+1];
FTNADDRESS tempAddr;
WinQueryWindowText((HWND)mp2, LEN_5DADDRESS+1, pchTemp);
StringToNetAddr(pchTemp, &tempAddr, CurrentAddress);
WinSetWindowText((HWND)mp2, NetAddrToString(pchTemp, &tempAddr));
}
if (SHORT2FROMMP(mp1) == EN_CONTEXTMENU)
{
pWindowData->usPopupControl = SHORT1FROMMP(mp1);
OpenEditPopup(client, pWindowData, (BOOL) mp2);
return 0;
}
if (SHORT2FROMMP(mp1) == EN_NODEDROPPED && mp2)
{
PCHAR pchTemp=strchr((PCHAR)mp2, ' ');
if (pchTemp)
{
pchTemp++;
WinSetDlgItemText(client, IDE_FROMNAME, pchTemp);
}
}
break;
case IDE_SUBJTEXT:
if (SHORT2FROMMP(mp1) == EN_CONTEXTMENU)
{
pWindowData->usPopupControl = SHORT1FROMMP(mp1);
OpenEditPopup(client, pWindowData, (BOOL) mp2);
return 0;
}
if (SHORT2FROMMP(mp1) == EN_FILEATTACH)
{
CurrentHeader.ulAttrib &= ~ATTRIB_FILEATTACHED;
WinPostMsg(client, WM_COMMAND, MPFROMSHORT(IDA_TOGGLE_FILE),
MPFROM2SHORT(CMDSRC_ACCELERATOR, FALSE));
return 0;
}
break;
case IDE_FROMNAME:
case IDE_TONAME:
if (SHORT2FROMMP(mp1) == EN_CONTEXTMENU)
{
pWindowData->usPopupControl = SHORT1FROMMP(mp1);
OpenEditPopup(client, pWindowData, (BOOL) mp2);
return 0;
}
if (SHORT2FROMMP(mp1) == EN_NODEDROPPED && mp2)
{
PCHAR pchTemp=strdup((PCHAR)mp2);
PCHAR pchTemp2=strchr(pchTemp, ' ');
if (pchTemp2)
{
*pchTemp2=0;
if (SHORT1FROMMP(mp1) == IDE_FROMNAME)
WinSetDlgItemText(client, IDE_FROMADDRESS, pchTemp);
else
WinSetDlgItemText(client, IDE_TOADDRESS, pchTemp);
}
free(pchTemp);
}
break;
case IDML_MAINEDIT:
if (SHORT2FROMMP(mp1)==MLN_SETFOCUS)
{
if (!bTemplateProcessed)
{
char pchTemp[LEN_5DADDRESS+1];
/* Template fertig verarbeiten und einsetzen */
WinQueryDlgItemText(client, IDE_FROMNAME, LEN_USERNAME, CurrentHeader.pchFromName);
if (!ulCCSelected && !pQuickCCList)
WinQueryDlgItemText(client, IDE_TONAME, LEN_USERNAME, CurrentHeader.pchToName);
else
CurrentHeader.pchToName[0]='\0';
WinQueryDlgItemText(client, IDE_FROMADDRESS, LEN_5DADDRESS, pchTemp);
StringToNetAddr(pchTemp, &CurrentHeader.FromAddress, CurrentAddress);
WinQueryDlgItemText(client, IDE_TOADDRESS, LEN_5DADDRESS, pchTemp);
StringToNetAddr(pchTemp, &CurrentHeader.ToAddress, CurrentAddress);
switch(ulTemplateType)
{
case TPLTYPE_NEW:
MSG_NewMessageStep2(&templatelist, &arealiste, NewArea,
&CurrentMessage, &CurrentHeader, &iptInitialPos);
break;