source: trunk/dll/arccnrs.c@ 1394

Last change on this file since 1394 was 1394, checked in by Steven Levine, 17 years ago

Ticket 340: Convert GetPString to use STRINGTABLE.

Drop fm3dll.str and mkstr.exe from makefiles and wpi builders

Convert many functions to expect PCSZ arguments.
Correct walk, compare and dirsizes dialog setups to ignore saved dialog size
Drop copyright.c logic from makefile

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 106.7 KB
RevLine 
[27]1
2/***********************************************************************
3
4 $Id: arccnrs.c 1394 2009-02-05 04:17:25Z stevenhl $
5
[123]6 Archive containers
7
[28]8 Copyright (c) 1993-98 M. Kimes
[1394]9 Copyright (c) 2001, 2009 Steven H. Levine
[27]10
[130]11 11 Jun 02 SHL Ensure archive name not garbage
12 22 May 03 SHL ArcObjWndProc: fix UM_RESCAN now that we understand it
13 01 Aug 04 SHL Rework lstrip/rstrip usage
14 23 May 05 SHL Use QWL_USER
[156]15 25 May 05 SHL Rename comnam to szCommonName and fix typo
16 25 May 05 SHL Use ULONGLONG and CommaFmtULL
[212]17 05 Jun 05 SHL Drop obsolete, localize
18 05 Jun 05 SHL Correct last sort logic
19 05 Jun 05 SHL Use QWL_USER
[229]20 22 Jun 05 SHL ArcSort: correct typo in last sort fix
[249]21 13 Aug 05 SHL FillArcCnr: optimize
[300]22 08 Dec 05 SHL FillArcCnr: allow list start and end markers to be empty (i.e. tar)
23 08 Dec 05 SHL ArcCnrWndProc: suppress IDM_EXTRACT if no simple extract (i.e. tar)
24 30 Dec 05 SHL ArcCnrWndProc: correct date/time column display setup
25 29 May 06 SHL Comments
[358]26 14 Jul 06 SHL Use Runtime_Error
[367]27 26 Jul 06 SHL Correct SelectAll usage
[406]28 29 Jul 06 SHL Use xfgets_bstripcr
[423]29 31 Jul 06 SHL Lower priority for archives with more than 1000 entries
[426]30 02 Aug 06 SHL Add logic to stop processing large archives
[460]31 23 Aug 06 SHL Integrate John Small's switch list title logic
[531]32 03 Nov 06 SHL Renames
[562]33 14 Mar 07 SHL ArcObjWndProc/UM_ENTER: delay before starting viewer
[593]34 30 Mar 07 GKY Remove GetPString for window class names
[618]35 06 Apr 07 GKY Work around PM DragInfo and DrgFreeISH limit
[606]36 06 Apr 07 GKY Add some error checking in drag/drop
[618]37 20 Apr 07 SHL Sync with NumItemsToUnhilite mods
[627]38 21 Apr 07 GKY Find FM2Utils by path or utils directory
[672]39 12 May 07 SHL Use dcd->ulItemsToUnHilite; sync with UnHilite arg mods
[688]40 10 Jun 07 GKY Add CheckPmDrgLimit including IsFm2Window as part of work around PM drag limit
[696]41 16 Jun 07 SHL Use DosQueryAppType not DosQAppType
[751]42 02 Aug 07 SHL Sync with ARCITEM mods
[773]43 06 Aug 07 SHL Use BldFullPathName and BldQuotedFileName
44 06 Aug 07 SHL Move BldQuotedFileName and BldQuotedFullPathNamehere
45 to be near primary caller
[775]46 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
[793]47 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
[814]48 26 Aug 07 GKY DosSleep(1) in loops changed to (0)
[872]49 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
[897]50 30 Dec 07 GKY Use TestCDates for sort by date
[917]51 10 Jan 08 SHL Sync with CfgDlgProc mods
[946]52 10 Feb 08 GKY Implement bubble help for bitmap menu items
[953]53 15 Feb 08 SHL Sync with settings menu rework
[985]54 29 Feb 08 GKY Use xfree where appropriate
[1068]55 14 Jul 08 JBS Ticket 126: Add support for WPS open default & open settings in arccnrs
[1069]56 16 Jul 08 GKY Fix trap on viewing multiple files from an archive (misplaced free)
[1082]57 16 Jul 08 GKY Use TMP directory for temp files if present. Use MakeTempName
[1104]58 19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory
[1120]59 25 Aug 08 GKY Check TMP directory space warn if lee than 5 MiB prevent archiver from opening if
[1335]60 less than 10 KiB (It hangs and can't be closed)
[1270]61 08 Nov 08 GKY Add WaitChildThread to fix hang caused by viewer trying to open a file before
[1335]62 the archiver process closes. (Ticket 58)
[1298]63 23 Nov 08 JBS Ticket 284: Support archivers with no Start or End of list strings
[1301]64 29 Nov 08 GKY Add flag to tell CheckListProc file is in an archive so it won't try to open it.
65 29 Nov 08 GKY Remove or replace with a mutex semaphore DosEnterCriSec where appropriate.
[1306]66 30 Nov 08 GKY Add the option of creating a subdirectory from the arcname
[1335]67 for the extract path to arc container.
[1311]68 02 Dec 08 JBS Ticket 284: Changed string indicating no Start/End of list strings.
[1314]69 03 Dec 08 GKY Subdirectory from the arcname for the extract path only created if an "extract"
[1335]70 menu option is selected.
71 10 Dec 08 SHL Integrate exception handler support
[618]72
[27]73***********************************************************************/
74
[907]75#include <stdlib.h> // free..
[2]76#include <string.h>
77#include <ctype.h>
[907]78#include <direct.h> // rmdir
79#include <share.h> // SH_DENYWR
80#include <limits.h> // ULONG_MAX
[1335]81// #include <process.h> // _beginthread // 10 Dec 08 SHL
[762]82
83#if 0
[751]84#include <malloc.h> // _heapchk
[762]85#endif
[156]86
[907]87#define INCL_DOS
88#define INCL_DOSERRORS
89#define INCL_WIN
90#define INCL_LONGLONG
91
[1183]92#include "fm3dll.h"
[1220]93#include "fm3dll2.h" // #define's for UM_*, control id's, etc.
94#include "arccnrs.h"
95#include "makelist.h" // Typedef
96#include "colors.h" // Typedef
[1203]97#include "mainwnd2.h" // Data declaration(s)
98#include "grep.h" // Data declaration(s)
99#include "dircnrs.h" // Data declaration(s)
100#include "info.h" // Data declaration(s)
101#include "init.h" // Data declaration(s)
[2]102#include "fm3dlg.h"
103#include "fm3str.h"
104#include "mle.h"
[907]105#include "pathutil.h" // BldFullPathName
106#include "filldir.h" // EmptyCnr...
107#include "errutil.h" // Dos_Error...
108#include "strutil.h" // GetPString
[953]109#include "notebook.h" // CfgDlgProc
[1335]110#include "worker.h" // Action, MassAction
[1160]111#include "avv.h" // ArcReviewDlgProc, rewrite_archiverbb2
112#include "chklist.h" // CenterOverWindow, CheckListProc
113#include "common.h" // CommonCreateTextChildren, CommonFrameWndProc, CommonTextPaint
[1335]114 // CommonTextButton
[1183]115#include "draglist.h" // DoFileDrag, DragOne
[1160]116#include "valid.h" // GetDesktopName, TestCDates
[1183]117#include "mainwnd.h" // GetNextWindowPos, MakeBubble, TopWindowName
[1160]118#include "objwin.h" // MakeObjWin
119#include "shadow.h" // MakeShadows
120#include "objcnr.h" // ObjCnrDlgProc
121#include "printer.h" // PrintListThread
122#include "srchpath.h" // RunFM2Util
[1183]123#include "misc.h" // Broadcast, CheckMenu, CurrentRecord, SayFilter, SaySort
[1335]124 // DrawTargetEmphasis, IsFm2Window
[1160]125#include "select.h" // SelectAll, SelectList
126#include "findrec.h" // ShowCnrRecord
127#include "walkem.h" // WalkExtractDlgProc
[1183]128#include "droplist.h" // AcceptOneDrop, CheckPmDrgLimit, DropHelp, GetOneDrop
129#include "archive.h" // ArchiveDlgProc
130#include "common.h" // CommonTextProc
131#include "presparm.h" // CopyPresParams
132#include "defview.h" // DefaultViewKeys
133#include "systemf.h" // ExecOnList
134#include "filter.h" // PickMaskDlgProc
135#include "avl.h" // SBoxDlgProc
136#include "mkdir.h" // SetDir
137#include "collect.h" // StartCollector
138#include "viewer.h" // StartMLEEditor
139#include "newview.h" // StartViewer
140#include "commafmt.h" // commafmt
141#include "copyf.h" // unlinkf
142#include "literal.h" // wildcard
143#include "wrappers.h" // xrealloc
[1335]144#include "misc.h" // AdjustCnrColVis, QuickPopup, SetSortChecks, SwitchCommand
[1160]145#include "select.h" // DeselectAll, InvertAll
[1183]146#include "strips.h" // bstrip
147#include "dirs.h" // save_dir2
[1011]148#include "fortify.h"
[1335]149#include "excputil.h" // 06 May 08 SHL added
[2]150
[1220]151#define ARCFLAGS_REALDIR 0x00000001
152#define ARCFLAGS_PSEUDODIR 0x00000002
153#define CON_COLS 6
154#define EXTRA_ARCRECORD_BYTES (sizeof(ARCITEM) - sizeof(MINIRECORDCORE))
[1311]155#define NO_START_OF_ARCHIVER_LIST_STRING "None"
156#define NO_END_OF_ARCHIVER_LIST_STRING NO_START_OF_ARCHIVER_LIST_STRING
[1220]157
[2]158#pragma data_seg(DATA1)
[1203]159static INT DefArcSortFlags;
[358]160
[1203]161// Data definitions
[358]162static PSZ pszSrcFile = __FILE__;
[1203]163#pragma data_seg(GLOBAL1)
164HWND ArcCnrMenu;
165HWND ArcMenu;
166CHAR ArcTempRoot[CCHMAXPATH];
167BOOL fArcStuffVisible;
[1306]168BOOL fFileNameCnrPath;
[358]169
[1203]170#pragma data_seg(GLOBAL2)
171CHAR lastextractpath[CCHMAXPATH];
172ULONGLONG ullDATFileSpaceNeeded;
173
[1268]174typedef struct {
175
[1271]176 HWND hwndCnr; //hwnd you want the message posted to
177 HWND hwndClient; //hwnd calling this thread; NULL will work
178 ULONG RunFlags; //runemf2 flags see systemf.h
[1339]179 ULONG msg; //Message to post
180 UINT uiLineNumber;
181 PCSZ pszSrcFile;
182 CHAR filename[CCHMAXPATH]; //file passed as MP1 message parameter (file selected)
183 CHAR *pszDirectory; //Execution directory
184 CHAR *pszEnvironment; //Enviroment -- NULL passes current
185 CHAR *pszCmdLine; //Use sprintf to format multipart command line into single string
[1271]186 CHAR formatstring[40]; //Usally "%s"
[1268]187}
188WAITCHILD;
189
[1272]190/** Creates a thread to wait for a child process to complete then posts a message and closes
191 * This function should only be used for runemf2 calls that include the WAIT flag
192 */
[1268]193VOID WaitChildThread(VOID * arg)
194{
195 WAITCHILD *WaitChild;
196 HAB thab;
197 CHAR *filename;
[1271]198 INT ret;
[1268]199
200 DosError(FERR_DISABLEHARDERR);
201
202# ifdef FORTIFY
203 Fortify_EnterScope();
204# endif
205
206 WaitChild = (WAITCHILD *) arg;
207 if (WaitChild) {
208 filename = xstrdup(WaitChild->filename, pszSrcFile, __LINE__);
209 thab = WinInitialize(0);
210 if (thab) {
211 IncrThreadUsage();
[1272]212 priority_normal();
[1339]213 ret = runemf2(WaitChild->RunFlags, WaitChild->hwndClient,
[1394]214 WaitChild->pszSrcFile, WaitChild->uiLineNumber,
[1335]215 WaitChild->pszDirectory, WaitChild->pszEnvironment,
[1339]216 WaitChild->formatstring, WaitChild->pszCmdLine);
[1271]217 if (ret != -1) {
[1335]218 if (IsFile(WaitChild->filename) == 1)
[1339]219 PostMsg(WaitChild->hwndCnr, WaitChild->msg, MPFROMP(filename), MPVOID);
[1271]220 }
[1268]221 DecrThreadUsage();
222 WinTerminate(thab);
223 }
[1271]224 xfree(WaitChild->pszDirectory, pszSrcFile, __LINE__);
225 xfree(WaitChild->pszEnvironment, pszSrcFile, __LINE__);
[1339]226 xfree(WaitChild->pszCmdLine, pszSrcFile, __LINE__);
[1268]227 free(WaitChild);
228 } // if WaitChild
229# ifdef FORTIFY
230 Fortify_LeaveScope();
231# endif
[1335]232 // _endthread(); // 10 Dec 08 SHL
[1268]233}
234
[551]235static MRESULT EXPENTRY ArcErrProc(HWND hwnd, ULONG msg, MPARAM mp1,
236 MPARAM mp2)
[172]237{
[2]238 ARCDUMP *ad;
[773]239 CHAR szQuotedArcName[CCHMAXPATH];
[2]240
[551]241 switch (msg) {
242 case WM_INITDLG:
243 if (!mp2)
244 WinDismissDlg(hwnd, 0);
245 else {
246 ad = (ARCDUMP *) mp2;
247 WinSetWindowPtr(hwnd, QWL_USER, ad);
248 if (ad->errmsg)
249 WinSetDlgItemText(hwnd, ARCERR_TEXT, ad->errmsg);
250 if (!ad->info->test)
251 WinEnableWindow(WinWindowFromID(hwnd, ARCERR_TEST), FALSE);
252 if (ad->listname) {
253 MLEsetlimit(WinWindowFromID(hwnd, ARCERR_MLE), -1L);
254 MLEsetformat(WinWindowFromID(hwnd, ARCERR_MLE), MLFIE_NOTRANS);
255 MLEsetcurpos(WinWindowFromID(hwnd, ARCERR_MLE),
256 MLEgetlen(WinWindowFromID(hwnd, ARCERR_MLE)));
257 MLEinsert(WinWindowFromID(hwnd, ARCERR_MLE),
258 GetPString(IDS_ARCHIVERREPORTTEXT));
259 MLEinsertfile(WinWindowFromID(hwnd, ARCERR_MLE), ad->listname);
[2]260 }
[551]261 }
262 break;
263
264 case WM_COMMAND:
265 switch (SHORT1FROMMP(mp1)) {
266 case DID_CANCEL:
267 WinDismissDlg(hwnd, 0);
[2]268 break;
269
[551]270 case IDM_HELP:
271 if (hwndHelp) {
272 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
273 MPFROM2SHORT(HELP_ARCERR, 0), MPFROMSHORT(HM_RESOURCEID));
274 }
275 break;
[2]276
[551]277 case DID_OK:
278 ad = WinQueryWindowPtr(hwnd, QWL_USER);
279 WinDlgBox(HWND_DESKTOP, hwnd, ArcReviewDlgProc, FM3ModHandle,
280 AD_FRAME, MPFROMP(ad));
281 WinDismissDlg(hwnd, 0);
282 break;
[2]283
[551]284 case ARCERR_VIEW:
285 ad = WinQueryWindowPtr(hwnd, QWL_USER);
286 {
287 CHAR *list[2];
[2]288
[551]289 list[0] = ad->arcname;
290 list[1] = NULL;
291 if (TestBinary(ad->arcname)) {
292 if (*binview)
293 ExecOnList((HWND) 0, binview, WINDOWED | SEPARATE, NULL, list,
[888]294 NULL, pszSrcFile, __LINE__);
[551]295 else
296 StartMLEEditor(HWND_DESKTOP, 16 + 4 + 1, ad->arcname, hwnd);
297 }
298 else {
299 if (*viewer) {
300 ExecOnList((HWND) 0, viewer, WINDOWED | SEPARATE |
[907]301 (fViewChild ? CHILD : 0),
302 NULL, list, NULL, pszSrcFile, __LINE__);
[551]303 }
304 else
305 StartMLEEditor(HWND_DESKTOP, 8 + 4 + 1, ad->arcname, hwnd);
306 }
307 }
308 break;
[2]309
[551]310 case ARCERR_TEST:
311 ad = WinQueryWindowPtr(hwnd, QWL_USER);
312 runemf2(SEPARATEKEEP | WINDOWED | MAXIMIZED,
[888]313 hwnd, pszSrcFile, __LINE__, NULL, NULL,
[773]314 "%s %s",
315 ad->info->test,
316 BldQuotedFileName(szQuotedArcName, ad->arcname));
[551]317 break;
318 }
319 return 0;
[2]320 }
[551]321 return WinDefDlgProc(hwnd, msg, mp1, mp2);
[2]322}
323
[551]324static SHORT APIENTRY ArcSort(PMINIRECORDCORE pmrc1, PMINIRECORDCORE pmrc2,
325 PVOID pStorage)
[172]326{
[551]327 PARCITEM pai1 = (PARCITEM) pmrc1;
328 PARCITEM pai2 = (PARCITEM) pmrc2;
329 DIRCNRDATA *pdcd = (DIRCNRDATA *) pStorage;
330 SHORT ret = 0;
331 CHAR *pext, *ppext;
332 INT sortFlags;
[2]333
[423]334 if (!pdcd) {
[212]335 HWND hwndCnr = pai1->hwndCnr;
[551]336
337 pdcd = WinQueryWindowPtr(hwndCnr, QWL_USER);
[358]338 if (!pdcd) {
[377]339 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
[212]340 return ret;
341 }
342 }
343
344 sortFlags = pdcd->sortFlags; // Optimize
345
[423]346 if (sortFlags) {
[551]347 switch (sortFlags & (~SORT_REVERSE)) {
348 case SORT_FIRSTEXTENSION:
[730]349 pext = strchr(pai1->pszFileName, '.');
350 ppext = strchr(pai2->pszFileName, '.');
[551]351 if (!pext)
352 pext = NullStr;
353 if (!ppext)
354 ppext = NullStr;
355 ret = stricmp(pext, ppext);
356 break;
[2]357
[551]358 case SORT_LASTEXTENSION:
[730]359 pext = strrchr(pai1->pszFileName, '.');
360 ppext = strrchr(pai2->pszFileName, '.');
[551]361 if (!pext)
362 pext = NullStr;
363 if (!ppext)
364 ppext = NullStr;
365 ret = stricmp(pext, ppext);
366 break;
[2]367
[551]368 case SORT_LWDATE:
[897]369 ret = TestCDates(&pai1->date, &pai1->time,
[907]370 &pai2->date, &pai2->time);
371 /*(pai1->date.year < pai2->date.year) ? 1 :
[551]372 (pai1->date.year > pai2->date.year) ? -1 :
373 (pai1->date.month < pai2->date.month) ? 1 :
374 (pai1->date.month > pai2->date.month) ? -1 :
375 (pai1->date.day < pai2->date.day) ? 1 :
376 (pai1->date.day > pai2->date.day) ? -1 :
377 (pai1->time.hours < pai2->time.hours) ? 1 :
378 (pai1->time.hours > pai2->time.hours) ? -1 :
379 (pai1->time.minutes < pai2->time.minutes) ? 1 :
380 (pai1->time.minutes > pai2->time.minutes) ? -1 :
381 (pai1->time.seconds < pai2->time.seconds) ? 1 :
[897]382 (pai1->time.seconds > pai2->time.seconds) ? -1 : 0;*/
[551]383 break;
[2]384
[551]385 case SORT_SIZE:
386 ret =
387 (pai1->cbFile < pai2->cbFile) ? 1 : (pai1->cbFile ==
388 pai2->cbFile) ? 0 : -1;
389 if (!ret)
390 ret =
391 (pai1->cbComp < pai2->cbComp) ? 1 : (pai1->cbComp ==
392 pai2->cbComp) ? 0 : -1;
393 break;
[2]394
[551]395 case SORT_EASIZE:
396 ret =
397 (pai1->cbComp < pai2->cbComp) ? 1 : (pai1->cbComp ==
398 pai2->cbComp) ? 0 : -1;
399 if (!ret)
400 ret =
401 (pai1->cbFile < pai2->cbFile) ? 1 : (pai1->cbFile ==
402 pai2->cbFile) ? 0 : -1;
403 break;
[2]404 }
[423]405 if (!ret)
[730]406 ret = (SHORT) stricmp(pai1->pszFileName, pai2->pszFileName);
[423]407 if (ret && (sortFlags & SORT_REVERSE))
[562]408 ret = ret > 0 ? -1 : 1;
[2]409 return ret;
410 }
[730]411 return (SHORT) stricmp(pai1->pszFileName, pai2->pszFileName);
[2]412}
413
[551]414static INT APIENTRY ArcFilter(PMINIRECORDCORE rmini, PVOID arg)
[172]415{
[551]416 DIRCNRDATA *dcd = (DIRCNRDATA *) arg;
417 PARCITEM r;
418 register INT x;
419 INT ret = FALSE;
[2]420
[423]421 if (dcd && *dcd->mask.szMask) {
[551]422 r = (PARCITEM) rmini;
[423]423 if (dcd->mask.pszMasks[1]) {
[551]424 for (x = 0; dcd->mask.pszMasks[x]; x++) {
425 if (*dcd->mask.pszMasks[x]) {
426 if (*dcd->mask.pszMasks[x] != '/') {
[730]427 if (wildcard(r->pszFileName, dcd->mask.pszMasks[x], FALSE))
[551]428 ret = TRUE;
429 }
430 else {
[730]431 if (wildcard(r->pszFileName, dcd->mask.pszMasks[x] + 1, FALSE)) {
[551]432 ret = FALSE;
433 break;
434 }
435 }
436 }
[2]437 }
438 }
439 else {
[730]440 if (wildcard(r->pszFileName, dcd->mask.szMask, FALSE))
[551]441 ret = TRUE;
[2]442 }
443 }
444 else
445 ret = TRUE;
446 return ret;
447}
448
[551]449static MRESULT EXPENTRY ArcFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
450 MPARAM mp2)
[172]451{
[551]452 return CommonFrameWndProc(ARC_CNR, hwnd, msg, mp1, mp2);
[2]453}
454
[551]455static BOOL IsArcThere(HWND hwnd, CHAR * arcname)
[172]456{
[423]457 if (arcname) {
458 if (IsFile(arcname) != 1) {
[551]459 saymsg(MB_CANCEL, hwnd,
460 GetPString(IDS_SAYWHATTEXT),
461 GetPString(IDS_ARCNOTTHERETEXT), arcname);
[2]462 return FALSE;
463 }
464 return TRUE;
465 }
466 return FALSE;
467}
468
[751]469/**
470 * Free storage associated with archive container item
471 * Caller is responsible for correcting pointers
472 */
473
474static VOID FreeArcItemData(PARCITEM pai)
475{
476 // DbgMsg(pszSrcFile, __LINE__, "FreeArcItemData %p", pai);
[762]477 PSZ psz;
[751]478
[762]479 if (pai->pszFileName && pai->pszFileName != NullStr) {
480 psz = pai->pszFileName;
[1077]481 pai->pszFileName = NULL; // 08 Jul 08 SHL was NulStr
[762]482 free(psz);
483 }
[751]484}
485
486/**
[762]487 * Remove item(s) from archive container and free associated storage if requested
488 * @param paiFirst points to first item to remove or NULL to remove all
489 * @param usCnt is remove count or 0 to remove all
[751]490 */
491
[762]492static VOID RemoveArcItems(HWND hwnd, PARCITEM paiFirst, USHORT usCnt, USHORT usFlags)
[751]493{
[762]494 INT remaining = usCnt;
495 PARCITEM pai;
496
497 if ((usCnt && !paiFirst) || (!usCnt && paiFirst))
498 Runtime_Error(pszSrcFile, __LINE__, "paiFirst %p usCnt %u mismatch", paiFirst, usCnt);
499 else {
500 // Free our buffers if free requested
501 if (usFlags & CMA_FREE) {
502 if (paiFirst)
503 pai = paiFirst;
504 else {
[751]505 pai = (PARCITEM)WinSendMsg(hwnd, CM_QUERYRECORD, MPVOID,
506 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
[762]507 if ((INT)pai == -1) {
[751]508 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"CM_QUERYRECORD");
[762]509 remaining = -1;
510 pai = NULL;
[751]511 }
512 }
[762]513 while (pai) {
514 FreeArcItemData(pai);
515 pai = (PARCITEM)pai->rc.preccNextRecord;
516 if (remaining && --remaining == 0)
517 break;
518 }
[751]519 }
520 }
521
[762]522 // DbgMsg(pszSrcFile, __LINE__, "RemoveArcItems %p %u %s", pai, usCnt, pai->pszFileName);
[751]523
[762]524 if (remaining != - 1) {
525 remaining = (INT)WinSendMsg(hwnd, CM_REMOVERECORD, MPFROMP(&paiFirst), MPFROM2SHORT(usCnt, usFlags));
526 if (remaining == -1) {
[751]527 // Win_Error2(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,IDS_CMREMOVEERRTEXT);
[762]528 Win_Error(hwnd, HWND_DESKTOP, pszSrcFile, __LINE__,"CM_REMOVERECORD hwnd %x pai %p cnt %u", hwnd, paiFirst, usCnt);
[751]529 }
530 }
531}
532
533/**
[762]534 * Empty all records from an archive container and
535 * free associated storage and free up field infos
[751]536 */
537
538static VOID EmptyArcCnr(HWND hwnd)
539{
[773]540#if 0 // fixme to be gone or to be configurable
[751]541 {
542 int state = _heapchk();
543 if (state != _HEAPOK)
544 Runtime_Error(pszSrcFile, __LINE__, "heap corrupted %d", state);
[762]545 else
546 DbgMsg(pszSrcFile, __LINE__, "_memavl %u", _memavl());
[751]547 }
548#endif
549
550 // Remove all ARCITEM records
551 RemoveArcItems(hwnd, NULL, 0, CMA_FREE);
552
553 // Use common code to remove rest
554 EmptyCnr(hwnd);
555}
556
[423]557//== FillArcCnr() generate archive content list and fill container window ==
558
[551]559static INT FillArcCnr(HWND hwndCnr, CHAR * arcname, ARC_TYPE ** arcinfo,
560 ULONGLONG * pullTotalBytes, volatile PCHAR pStopFlag)
[44]561{
[551]562 FILE *fp;
563 HFILE oldstdout;
564 HFILE newstdout;
565 CHAR s[CCHMAXPATH * 2], lonename[CCHMAXPATH + 2],
[1082]566 *nsize, *osize, *fdate, *fname, *p, *pp, *arctemp;
[551]567 BOOL gotstart;
568 BOOL gotend;
569 BOOL wasquote;
[773]570 BOOL nomove = FALSE; // fixme to be gone?
[1298]571 INT highest = 0, fieldnum, counter = 0, numarcfiles = 0;
[551]572 PARCITEM lastpai;
573 ARC_TYPE *info;
574 ARC_TYPE *tinfo;
575 ULONG apptype;
576 APIRET rc;
[2]577
[423]578 if (!arcname || !arcinfo)
[2]579 return 0;
[300]580
[2]581 info = *arcinfo;
[423]582 if (!info)
[551]583 info = find_type(arcname, NULL);
[1082]584 arctemp = xmallocz(CCHMAXPATH, pszSrcFile, __LINE__);
[1120]585 if (CheckDriveSpaceAvail(ArcTempRoot, ullDATFileSpaceNeeded, ullTmpSpaceNeeded) == 1)
586 saymsg(MB_OK,
[1335]587 HWND_DESKTOP,
588 NullStr,
589 GetPString(IDS_ARCTMPDRIVESPACELIMITED),
590 ArcTempRoot);
[1082]591 MakeTempName(arctemp, ArcTempRoot, 2);
[300]592
[1120]593
[2]594ReTry:
595
596 tinfo = NULL;
597 numarcfiles = counter = highest = 0;
598 gotstart = gotend = FALSE;
599 lastpai = NULL;
[156]600 *pullTotalBytes = 0;
[358]601 if (!info || !info->list)
[377]602 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
[358]603 else {
[751]604 RemoveArcItems(hwndCnr, NULL, 0, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
[2]605 *arcinfo = info;
606 highest = info->osizepos;
[423]607 if (info->nsizepos > highest)
[2]608 highest = info->nsizepos;
[423]609 if (info->fdpos > highest)
[2]610 highest = info->fdpos;
[423]611 if (info->fnpos > highest)
[2]612 highest = info->fnpos;
[423]613 if (highest > 50) {
[551]614 saymsg(MB_ENTER | MB_ICONEXCLAMATION, HWND_DESKTOP,
615 GetPString(IDS_SHAMETEXT), "%s", GetPString(IDS_BUNGEDUPTEXT));
[423]616 }
617 if (info->fnpos == -1)
[2]618 highest = 32767;
[300]619
[2]620 DosError(FERR_DISABLEHARDERR);
621 DosForceDelete(arctemp);
622 DosError(FERR_DISABLEHARDERR);
[300]623
[551]624 strcpy(s, info->list);
625 p = strchr(s, ' ');
[423]626 if (p)
[2]627 *p = 0;
628 DosError(FERR_DISABLEHARDERR);
[696]629 if (!DosQueryAppType(s, &apptype) &&
[563]630 (apptype & FAPPTYP_DOS ||
631 apptype & FAPPTYP_WINDOWSREAL ||
632 apptype & FAPPTYP_WINDOWSPROT ||
633 apptype & FAPPTYP_WINDOWSPROT31)) {
[2]634 p = GetCmdSpec(TRUE);
635 runemf2(SEPARATE | INVISIBLE | MINIMIZED | BACKGROUND | WAIT,
[888]636 hwndCnr, pszSrcFile, __LINE__, NULL, "DOS_BACKGROUND_EXECUTION=1",
[773]637 "%s /C %s %s >%s",
638 p, // shell
639 info->list, // list command
640 BldQuotedFileName(s, arcname),
[562]641 arctemp);
[2]642 }
643 else {
[551]644 fp = xfopen(arctemp, "w", pszSrcFile, __LINE__);
[1082]645 if (!fp) {
[1321]646 xfree(arctemp, pszSrcFile, __LINE__);
647 return 0;
[1082]648 }
[358]649 else {
[551]650 newstdout = -1;
651 DosError(FERR_DISABLEHARDERR);
652 rc = DosDupHandle(fileno(stdout), &newstdout);
653 if (rc) {
654 Dos_Error(MB_CANCEL, rc, hwndCnr, pszSrcFile, __LINE__,
[1321]655 "DosDupHandle");
656 xfree(arctemp, pszSrcFile, __LINE__);
[551]657 return 0;
[358]658 }
659 else {
[551]660 oldstdout = fileno(stdout);
661 DosError(FERR_DISABLEHARDERR);
662 rc = DosDupHandle(fileno(fp), &oldstdout);
663 if (rc) {
664 Dos_Error(MB_CANCEL, rc, hwndCnr, pszSrcFile, __LINE__,
665 "DosDupHandle");
[1321]666 xfree(arctemp, pszSrcFile, __LINE__);
667 return 0;
[358]668 }
669 else {
[1268]670 runemf2(SEPARATE | INVISIBLE | MINIMIZED | BACKGROUND | WAIT,
[888]671 hwndCnr, pszSrcFile, __LINE__, NULL, NULL,
[773]672 "%s %s",
673 info->list,
674 BldQuotedFileName(s, arcname));
[551]675 oldstdout = fileno(stdout);
676 DosError(FERR_DISABLEHARDERR);
677 DosDupHandle(newstdout, &oldstdout);
678 DosClose(newstdout);
679 fclose(fp);
680 }
681 }
[2]682 }
683 }
[300]684
[2]685 DosError(FERR_DISABLEHARDERR);
[551]686 fp = _fsopen(arctemp, "r", SH_DENYWR);
[300]687
[358]688 if (fp) {
[1298]689 gotstart = !info->startlist || // If list has no start marker
[1335]690 !*info->startlist ||
691 (stricmp(info->startlist, NO_START_OF_ARCHIVER_LIST_STRING) == 0);
[300]692
[551]693 while (!feof(fp) && !gotend && !*pStopFlag) {
694 if (!xfgets_bstripcr(s, sizeof(s), fp, pszSrcFile, __LINE__))
695 break;
696 if (!gotstart) {
697 if (!strcmp(s, info->startlist))
698 gotstart = TRUE;
699 }
700 else if (info->endlist && !strcmp(s, info->endlist))
701 gotend = TRUE;
702 else {
[300]703 /* add to container */
[551]704 fname = NULL;
705 bstrip(s);
706 if (info->nameisfirst) {
707 strncpy(lonename, s, CCHMAXPATH + 2);
708 lonename[CCHMAXPATH + 1] = 0;
709 fname = lonename;
710 if (!xfgets_bstripcr(s, sizeof(s), fp, pszSrcFile, __LINE__))
711 break;
712 if (*fname == '\"') {
713 memmove(fname, fname + 1, strlen(fname) + 1);
714 p = strchr(fname, '\"');
715 if (p)
716 *p = 0;
717 }
718 }
719 nsize = NULL;
720 osize = fdate = NullStr;
721 p = s;
[1298]722 for (fieldnum = 0; fieldnum <= highest; fieldnum++) {
[551]723 pp = p;
724 while (*pp && (*pp == ' ' || *pp == '\t')) /* skip leading */
725 pp++;
726 if (!*pp)
727 break;
728 wasquote = FALSE;
729 p = pp;
730 while (*p && (wasquote ||
[1298]731 ((fieldnum != info->fnpos || !info->nameislast) ?
[551]732 (*p != ' ' && *p != '\t') : TRUE))) {
733 if (*p == '\"') {
734 if (!wasquote) {
735 wasquote = TRUE;
736 memmove(p, p + 1, strlen(p));
737 while (*p == ' ' || *p == '\t')
738 p++;
739 }
740 else {
741 memmove(p, p + 1, strlen(p));
742 break;
743 }
744 }
745 else if (*p)
746 p++;
747 }
748 if (*p) {
749 *p = 0;
750 p++;
751 }
[1298]752 if (fieldnum == info->nsizepos)
[551]753 nsize = pp;
[1298]754 else if (fieldnum == info->osizepos)
[551]755 osize = pp;
[1298]756 else if (fieldnum == info->fdpos) {
[551]757 fdate = pp;
758 if (info->fdflds > 1 && info->fdflds < 24) {
759 INT y;
[2]760
[551]761 if (*p) {
762 p--;
763 *p = ' ';
764 for (y = 0; y < info->fdflds - 1; y++) {
765 while (*p && (*p == ' ' || *p == '\t'))
766 p++;
767 while (*p && (*p != ' ' && *p != '\t'))
768 p++;
[1298]769 fieldnum++;
[551]770 }
771 if (*p) {
772 *p = 0;
773 p++;
774 }
775 }
776 }
777 }
[1298]778 else if (fieldnum == info->fnpos) {
[551]779 fname = pp;
780 if (pp && *pp == '*' && !*(pp + 1)) /* workaround for LH.EXE */
781 fname = NULL;
782 if (info->nameislast)
783 break;
784 }
785 else if ((!p || !*p) && info->fnpos == -1) {
786 fname = pp;
787 break;
788 }
789 }
790 if (info->nameisnext) {
791 if (!xfgets_bstripcr
792 (lonename, sizeof(lonename), fp, pszSrcFile, __LINE__))
793 break;
794 fname = lonename;
795 }
[423]796 // fixme to complain?
[551]797 if (fname && *fname) {
[2]798
[551]799 RECORDINSERT ri;
800 PARCITEM pai;
[2]801
[551]802 pai = WinSendMsg(hwndCnr,
803 CM_ALLOCRECORD,
804 MPFROMLONG(EXTRA_ARCRECORD_BYTES),
805 MPFROMLONG(1L));
806 if (!pai) {
[358]807 Runtime_Error(pszSrcFile, __LINE__, "CM_ALLOCRECORD");
808 break;
809 }
810 else {
[551]811 memset(pai, 0, sizeof(ARCITEM));
812 pai->hwndCnr = hwndCnr;
813 if (*fname == '*') {
814 fname++;
815 pai->flags = ARCFLAGS_REALDIR;
[358]816 }
[551]817 if (fname[strlen(fname) - 1] == '\\' ||
818 fname[strlen(fname) - 1] == '/')
819 pai->flags = ARCFLAGS_REALDIR;
[730]820 pai->pszFileName = xstrdup(fname,pszSrcFile, __LINE__);
[1321]821# ifdef FORTIFY
822 // Will be freed by WM_DESTROY
823 Fortify_SetOwner(pai->pszFileName, 1);
824 // Fortify_ChangeScope(pai->pszFileName, -1);
825# endif
826
[762]827 pai->pszDisplayName = pai->pszFileName;
828 pai->rc.pszIcon = pai->pszDisplayName;
[551]829 if (fdate)
830 strcpy(pai->szDate, fdate);
[730]831 // pai->pszFileName = pai->pszFileName;
[551]832 pai->rc.pszIcon = pai->pszFileName;
[562]833 pai->rc.hptrIcon = (pai->flags & ARCFLAGS_REALDIR) != 0 ?
[551]834 hptrDir : hptrFile;
835 pai->pszDate = pai->szDate;
836 if (osize)
837 pai->cbFile = atol(osize);
838 if (nsize)
839 pai->cbComp = atol(nsize);
840 if (info->datetype && fdate && *fdate)
841 ArcDateTime(fdate, info->datetype, &pai->date, &pai->time);
842 memset(&ri, 0, sizeof(RECORDINSERT));
843 ri.cb = sizeof(RECORDINSERT);
844 ri.pRecordOrder = (PRECORDCORE) CMA_END;
845 ri.pRecordParent = (PRECORDCORE) NULL;
846 ri.zOrder = (USHORT) CMA_TOP;
847 ri.cRecordsInsert = 1L;
848 ri.fInvalidateRecord = FALSE;
849 if (WinSendMsg(hwndCnr,
850 CM_INSERTRECORD, MPFROMP(pai), MPFROMP(&ri))) {
851 *pullTotalBytes += pai->cbFile;
852 }
853 numarcfiles++;
854 if (!(++counter % 50)) {
855 if (!lastpai)
856 lastpai = pai;
857 WinSendMsg(hwndCnr,
858 CM_INVALIDATERECORD,
859 lastpai,
860 MPFROM2SHORT(10, CMA_ERASE | CMA_REPOSITION));
861 lastpai = pai;
862 }
[426]863 // Avoid hogging system for large archive
864 if (numarcfiles == 100)
[551]865 priority_idle();
866 }
867 }
868 }
869 } // while !eof
[300]870
[2]871 fclose(fp);
[300]872
[426]873 if (*pStopFlag)
[551]874 numarcfiles = 0; // Request close
875 else if (!numarcfiles || !gotstart
[1311]876 || (!gotend && info->endlist && *info->endlist && (stricmp(info->endlist, NO_END_OF_ARCHIVER_LIST_STRING)))) {
[423]877 // Oops
[551]878 ARCDUMP ad;
879 CHAR errstr[CCHMAXPATH + 256];
[2]880
[423]881 // Try for alternate archiver
[551]882 tinfo = info;
883 do {
884 tinfo = tinfo->next;
885 if (tinfo)
886 tinfo = find_type(arcname, tinfo);
887 if (tinfo) {
888 DosError(FERR_DISABLEHARDERR);
889 DosForceDelete(arctemp);
890 info = tinfo;
891 goto ReTry;
892 }
893 } while (tinfo);
894 DosBeep(750, 50); // wake up user
895 sprintf(errstr, GetPString(IDS_ARCERRORINFOTEXT),
896 arcname,
[562]897 !gotstart ? GetPString(IDS_NOGOTSTARTTEXT) : NullStr,
898 !numarcfiles ? GetPString(IDS_NOARCFILESFOUNDTEXT) :
[551]899 NullStr,
[562]900 !gotend ? GetPString(IDS_NOENDOFLISTTEXT) : NullStr);
[551]901 memset(&ad, 0, sizeof(ARCDUMP));
902 ad.info = info;
903 strcpy(ad.listname, arctemp);
904 strcpy(ad.arcname, arcname);
905 ad.errmsg = errstr;
906 WinDlgBox(HWND_DESKTOP,
907 hwndCnr,
908 ArcErrProc, FM3ModHandle, ARCERR_FRAME, MPFROMP(&ad));
[2]909 }
[249]910 else if (!nomove && tinfo) {
911 /* if we got a false hit, move working hit to top */
[551]912 tinfo = info->next;
913 info->next = arcsighead;
914 arcsighead->prev = info;
915 if (tinfo)
916 tinfo->next->prev = info->prev;
917 info->prev->next = tinfo;
918 info->prev = NULL;
919 arcsighead = info;
920 rewrite_archiverbb2(NULL); // Rewrite with warning
[2]921 }
[551]922 } // if opened
[426]923
[2]924 DosError(FERR_DISABLEHARDERR);
925 DosForceDelete(arctemp);
[1082]926 xfree(arctemp, pszSrcFile, __LINE__);
[2]927 }
928
[426]929 if (numarcfiles)
[423]930 priority_normal();
931
[2]932 return numarcfiles;
933}
934
[551]935MRESULT EXPENTRY ArcTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[172]936{
[551]937 static BOOL emphasized = FALSE;
938 static HWND hwndButtonPopup = (HWND) 0;
939 static ULONG timestamp = ULONG_MAX;
940 static USHORT lastid = 0;
[2]941
[551]942 switch (msg) {
943 case WM_CREATE:
944 return CommonTextProc(hwnd, msg, mp1, mp2);
[2]945
[551]946 case WM_COMMAND:
947 return WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
948 ARC_CNR), msg, mp1, mp2);
[2]949
[551]950 case UM_CONTEXTMENU:
951 case WM_CONTEXTMENU:
952 {
953 USHORT id;
[2]954
[551]955 id = WinQueryWindowUShort(hwnd, QWS_ID);
956 switch (id) {
957 case DIR_SELECTED:
958 case DIR_VIEW:
959 case DIR_SORT:
960 {
961 POINTL ptl = { 0, 0 };
962 SWP swp;
963 DIRCNRDATA *dcd;
[2]964
[551]965 if (hwndButtonPopup)
966 WinDestroyWindow(hwndButtonPopup);
967 if (id == DIR_SELECTED)
968 id = DIR_RESTORE;
969 if (id == lastid) {
[2]970
[551]971 ULONG check;
[2]972
[551]973 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &check,
974 sizeof(check));
975 if (check < timestamp + 500) {
976 lastid = 0;
977 goto MenuAbort;
978 }
979 }
980 hwndButtonPopup = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
981 if (hwndButtonPopup) {
982 WinSetWindowUShort(hwndButtonPopup, QWS_ID, id);
983 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
984 QW_PARENT),
985 ARC_CNR), QWL_USER);
986 if (id == DIR_SORT) {
987 if (dcd)
988 SetSortChecks(hwndButtonPopup, dcd->sortFlags);
989 WinSendMsg(hwndButtonPopup,
990 MM_DELETEITEM,
991 MPFROM2SHORT(IDM_SORTNONE, FALSE), MPVOID);
992 WinSendMsg(hwndButtonPopup,
993 MM_DELETEITEM,
994 MPFROM2SHORT(IDM_SORTNAME, FALSE), MPVOID);
995 WinSendMsg(hwndButtonPopup,
996 MM_DELETEITEM,
997 MPFROM2SHORT(IDM_SORTLADATE, FALSE), MPVOID);
998 WinSendMsg(hwndButtonPopup,
999 MM_DELETEITEM,
1000 MPFROM2SHORT(IDM_SORTCRDATE, FALSE), MPVOID);
1001 WinSendMsg(hwndButtonPopup,
1002 MM_DELETEITEM,
1003 MPFROM2SHORT(IDM_SORTDIRSFIRST, FALSE), MPVOID);
1004 WinSendMsg(hwndButtonPopup,
1005 MM_DELETEITEM,
1006 MPFROM2SHORT(IDM_SORTDIRSLAST, FALSE), MPVOID);
1007 WinSendMsg(hwndButtonPopup,
1008 MM_DELETEITEM,
1009 MPFROM2SHORT(IDM_SORTSUBJECT, FALSE), MPVOID);
1010 WinSendMsg(hwndButtonPopup,
1011 MM_SETITEMTEXT,
1012 MPFROM2SHORT(IDM_SORTEASIZE, 0),
1013 MPFROMP(GetPString(IDS_COMPRESSEDSIZEMENUTEXT)));
1014 WinSendMsg(hwndButtonPopup,
1015 MM_SETITEMTEXT,
1016 MPFROM2SHORT(IDM_SORTLWDATE, 0),
1017 MPFROMP(GetPString(IDS_DATEMENUTEXT)));
1018 }
1019 ptl.x = 0;
1020 if (WinPopupMenu(HWND_OBJECT,
1021 HWND_OBJECT,
1022 hwndButtonPopup, -32767, -32767, 0, 0)) {
1023 WinQueryWindowPos(hwndButtonPopup, &swp);
1024 ptl.y = -(swp.cy + 2);
1025 }
1026 else {
1027 WinQueryWindowPos(hwnd, &swp);
1028 ptl.y = swp.cy + 2;
1029 }
1030 if (WinPopupMenu(hwnd,
1031 hwnd,
1032 hwndButtonPopup,
1033 ptl.x,
1034 ptl.y,
1035 0,
1036 PU_HCONSTRAIN | PU_VCONSTRAIN |
1037 PU_KEYBOARD | PU_MOUSEBUTTON1)) {
1038 CenterOverWindow(hwndButtonPopup);
1039 PaintRecessedWindow(hwnd, (HPS) 0, FALSE, FALSE);
1040 }
1041 }
1042 }
1043 break;
1044 default:
1045 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1046 ARC_CNR),
1047 WM_CONTROL, MPFROM2SHORT(ARC_CNR, CN_CONTEXTMENU), MPVOID);
1048 break;
[2]1049 }
[551]1050 }
1051 MenuAbort:
1052 if (msg == UM_CONTEXTMENU)
1053 return 0;
1054 break;
[2]1055
[551]1056 case WM_MENUEND:
1057 if (hwndButtonPopup == (HWND) mp2) {
1058 lastid = WinQueryWindowUShort((HWND) mp2, QWS_ID);
1059 WinDestroyWindow(hwndButtonPopup);
1060 hwndButtonPopup = (HWND) 0;
1061 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &timestamp,
1062 sizeof(timestamp));
1063 switch (lastid) {
1064 case DIR_VIEW:
1065 case DIR_SORT:
1066 case DIR_RESTORE:
1067 case DIR_SELECTED:
1068 PaintRecessedWindow(hwnd, (HPS) 0, TRUE, FALSE);
1069 break;
[2]1070 }
[551]1071 }
1072 break;
[2]1073
[551]1074 case WM_MOUSEMOVE:
1075 {
1076 USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
[1394]1077 PCSZ s = NULL;
[2]1078
[551]1079 if (fOtherHelp) {
1080 if ((!hwndBubble ||
1081 WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
1082 !WinQueryCapture(HWND_DESKTOP)) {
1083 switch (id) {
1084 case DIR_TOTALS:
1085 s = GetPString(IDS_ARCCNRTOTALSHELPTEXT);
1086 break;
1087 case DIR_SELECTED:
1088 s = GetPString(IDS_ARCCNRSELECTEDHELPTEXT);
1089 break;
1090 case DIR_VIEW:
1091 s = GetPString(IDS_ARCCNRVIEWHELPTEXT);
1092 break;
1093 case DIR_SORT:
1094 s = GetPString(IDS_DIRCNRSORTHELP);
1095 break;
1096 case DIR_FILTER:
1097 s = GetPString(IDS_DIRCNRFILTERHELP);
1098 break;
1099 case DIR_FOLDERICON:
1100 s = GetPString(IDS_ARCCNRFOLDERHELPTEXT);
1101 break;
1102 default:
1103 break;
1104 }
1105 if (s)
1106 MakeBubble(hwnd, TRUE, s);
1107 else if (hwndBubble)
1108 WinDestroyWindow(hwndBubble);
1109 }
[2]1110 }
[551]1111 switch (id) {
1112 case DIR_FILTER:
1113 case DIR_SORT:
1114 case DIR_VIEW:
1115 case DIR_SELECTED:
1116 case DIR_FOLDERICON:
1117 return CommonTextButton(hwnd, msg, mp1, mp2);
1118 }
1119 }
1120 break;
[2]1121
[551]1122 case WM_BUTTON3UP:
1123 case WM_BUTTON1UP:
1124 case WM_BUTTON1DOWN:
1125 case WM_BUTTON3DOWN:
1126 {
1127 USHORT id;
[2]1128
[551]1129 id = WinQueryWindowUShort(hwnd, QWS_ID);
1130 switch (id) {
1131 case DIR_FILTER:
1132 case DIR_SORT:
1133 case DIR_VIEW:
1134 case DIR_SELECTED:
1135 case DIR_FOLDERICON:
1136 return CommonTextButton(hwnd, msg, mp1, mp2);
[2]1137 }
[551]1138 }
1139 break;
[2]1140
[551]1141 case UM_CLICKED:
1142 case UM_CLICKED3:
1143 {
1144 USHORT id, cmd = 0;
[2]1145
[551]1146 id = WinQueryWindowUShort(hwnd, QWS_ID);
1147 switch (id) {
1148 case DIR_FOLDERICON:
1149 switch (msg) {
1150 case WM_BUTTON3CLICK:
1151 case WM_CHORD:
1152 cmd = IDM_RESCAN;
1153 break;
1154 default:
1155 if ((SHORT2FROMMP(mp2) & KC_ALT) != 0)
1156 cmd = IDM_WINDOWDLG;
1157 else
1158 cmd = IDM_WALKDIR;
1159 break;
1160 }
1161 break;
1162 case DIR_VIEW:
1163 case DIR_SORT:
1164 case DIR_SELECTED:
1165 PostMsg(hwnd, UM_CONTEXTMENU, MPVOID, MPVOID);
1166 break;
1167 case DIR_FILTER:
1168 cmd = IDM_FILTER;
1169 break;
1170 default:
1171 break;
[2]1172 }
[551]1173 if (cmd)
1174 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1175 ARC_CNR),
1176 WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
1177 }
1178 return 0;
[2]1179
[551]1180 case WM_BEGINDRAG:
1181 case DM_DROP:
1182 case DM_DRAGOVER:
1183 case DM_DRAGLEAVE:
1184 case DM_DROPHELP:
1185 if (msg == DM_DRAGOVER) {
1186 if (!emphasized) {
1187 emphasized = TRUE;
1188 DrawTargetEmphasis(hwnd, emphasized);
[2]1189 }
[551]1190 }
1191 else if (msg != WM_BEGINDRAG) {
1192 if (emphasized) {
1193 emphasized = FALSE;
1194 DrawTargetEmphasis(hwnd, emphasized);
[2]1195 }
[551]1196 }
1197 switch (WinQueryWindowUShort(hwnd, QWS_ID)) {
1198 case DIR_FOLDERICON:
1199 switch (msg) {
1200 case DM_DRAGOVER:
[618]1201 if (AcceptOneDrop(hwnd, mp1, mp2))
[551]1202 return MRFROM2SHORT(DOR_DROP, DO_MOVE);
[562]1203 return MRFROM2SHORT(DOR_NODROP, 0); /* Drop not valid */
[551]1204 case DM_DROPHELP:
1205 DropHelp(mp1, mp2, hwnd, GetPString(IDS_ARCCNRFOLDERDROPHELPTEXT));
1206 return 0;
1207 case DM_DROP:
1208 {
1209 char szFrom[CCHMAXPATH + 2];
[2]1210
[551]1211 if (emphasized) {
1212 emphasized = FALSE;
1213 DrawTargetEmphasis(hwnd, emphasized);
1214 }
[618]1215 if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom)))
[551]1216 WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1217 ARC_CNR),
1218 WM_COMMAND,
1219 MPFROM2SHORT(IDM_SWITCH, 0), MPFROMP(szFrom));
1220 }
1221 return 0;
1222 default:
1223 return PFNWPStatic(hwnd, msg, mp1, mp2);
1224 }
1225 default:
1226 {
1227 CNRDRAGINFO cnd;
1228 USHORT dcmd;
[2]1229
[551]1230 switch (msg) {
1231 case DM_DROP:
1232 dcmd = CN_DROP;
1233 break;
1234 case DM_DRAGOVER:
1235 dcmd = CN_DRAGOVER;
1236 break;
1237 case DM_DRAGLEAVE:
1238 dcmd = CN_DRAGLEAVE;
1239 break;
1240 case DM_DROPHELP:
1241 dcmd = CN_DROPHELP;
1242 break;
1243 case WM_BEGINDRAG:
1244 dcmd = CN_INITDRAG;
1245 break;
1246 }
1247 cnd.pDragInfo = (PDRAGINFO) mp1;
1248 cnd.pRecord = NULL;
1249 return WinSendMsg(WinQueryWindow(hwnd, QW_PARENT),
1250 WM_CONTROL,
1251 MPFROM2SHORT(ARC_CNR, dcmd), MPFROMP(&cnd));
[2]1252 }
[551]1253 }
[2]1254 }
[551]1255 return PFNWPStatic(hwnd, msg, mp1, mp2);
[2]1256}
1257
[551]1258MRESULT EXPENTRY ArcClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
1259 MPARAM mp2)
1260{
[2]1261
[551]1262 switch (msg) {
1263 case UM_CONTAINERHWND:
1264 return MRFROMLONG(WinWindowFromID(hwnd, ARC_CNR));
[2]1265
[551]1266 case UM_VIEWSMENU:
1267 // fixme to disble menu items as needed
[872]1268 return MRFROMLONG(CheckMenu(hwnd, &ArcCnrMenu, ARCCNR_POPUP));
[2]1269
[551]1270 case UM_FILESMENU:
1271 // fixme to disble menu items as needed
[872]1272 return MRFROMLONG(CheckMenu(hwnd, &ArcMenu, ARC_POPUP));
[2]1273
[551]1274 case MM_PORTHOLEINIT:
1275 case WM_INITMENU:
1276 case UM_INITMENU:
1277 case UM_COMMAND:
1278 case UM_LOADFILE:
1279 case UM_UPDATERECORD:
1280 case UM_UPDATERECORDLIST:
1281 case WM_COMMAND:
1282 case WM_CONTROL:
1283 case WM_CLOSE:
1284 return WinSendMsg(WinWindowFromID(hwnd, ARC_CNR), msg, mp1, mp2);
[2]1285
[551]1286 case WM_PSETFOCUS:
1287 case WM_SETFOCUS:
1288 if (mp2)
1289 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
1290 break;
[2]1291
[551]1292 case UM_FOCUSME:
1293 WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, ARC_CNR));
1294 break;
[2]1295
[551]1296 case WM_PAINT:
1297 {
1298 HPS hps;
1299 RECTL rcl;
[2]1300
[551]1301 hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
1302 if (hps) {
1303 WinQueryWindowRect(hwnd, &rcl);
1304 WinFillRect(hps, &rcl, CLR_PALEGRAY);
1305 CommonTextPaint(hwnd, hps);
1306 WinEndPaint(hps);
[2]1307 }
[551]1308 }
1309 break;
[2]1310
[551]1311 case UM_SIZE:
1312 case WM_SIZE:
1313 if (msg == UM_SIZE) {
[2]1314
[551]1315 SWP swp;
[2]1316
[551]1317 WinQueryWindowPos(hwnd, &swp);
1318 mp1 = MPFROM2SHORT(swp.cx, swp.cy);
1319 mp2 = MPFROM2SHORT(swp.cx, swp.cy);
1320 }
1321 {
1322 USHORT cx, cy, bx;
[2]1323
[551]1324 cx = SHORT1FROMMP(mp2);
1325 cy = SHORT2FROMMP(mp2);
1326 WinSetWindowPos(WinWindowFromID(hwnd, ARC_CNR), HWND_TOP,
1327 0,
1328 22, cx, cy - (24 + 22), SWP_SHOW | SWP_MOVE | SWP_SIZE);
1329 WinSetWindowPos(WinWindowFromID(hwnd, ARC_EXTRACTDIR), HWND_TOP,
1330 0, 0, cx, 22, SWP_SHOW | SWP_MOVE | SWP_SIZE);
1331 WinSetWindowPos(WinWindowFromID(hwnd, DIR_FOLDERICON), HWND_TOP,
1332 2, cy - 22, 24, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
1333 WinSetWindowPos(WinWindowFromID(hwnd, DIR_TOTALS), HWND_TOP,
1334 29,
1335 cy - 22,
1336 (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
1337 WinSetWindowPos(WinWindowFromID(hwnd, DIR_SELECTED), HWND_TOP,
1338 29 + (cx / 3) + 2,
1339 cy - 22,
1340 (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
1341 bx = (cx - (29 + (((cx / 3) + 2) * 2))) / 3;
1342 WinSetWindowPos(WinWindowFromID(hwnd, DIR_VIEW), HWND_TOP,
1343 29 + (((cx / 3) + 2) * 2),
1344 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
1345 WinSetWindowPos(WinWindowFromID(hwnd, DIR_SORT), HWND_TOP,
1346 29 + (((cx / 3) + 2) * 2) + bx,
1347 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
1348 WinSetWindowPos(WinWindowFromID(hwnd, DIR_FILTER), HWND_TOP,
1349 29 + (((cx / 3) + 2) * 2) + (bx * 2),
1350 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
1351 }
1352 CommonTextPaint(hwnd, (HPS) 0);
1353 if (msg == UM_SIZE) {
1354 WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
1355 SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE);
1356 return 0;
1357 }
1358 break;
[2]1359 }
[551]1360 return WinDefWindowProc(hwnd, msg, mp1, mp2);
[2]1361}
1362
[551]1363MRESULT EXPENTRY ArcObjWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[172]1364{
[2]1365 DIRCNRDATA *dcd;
[358]1366 PSZ psz;
[773]1367 CHAR szQuotedArcName[CCHMAXPATH];
1368 CHAR szQuotedMemberName[CCHMAXPATH];
[2]1369
[551]1370 switch (msg) {
[1077]1371 case WM_CREATE:
1372 DbgMsg(pszSrcFile, __LINE__, "WM_CREATE mp1 %p mp2 %p", mp1, mp2); // 18 Jul 08 SHL fixme
1373 break;
1374
[551]1375 case DM_PRINTOBJECT:
1376 case DM_DISCARDOBJECT:
1377 dcd = INSTDATA(hwnd);
1378 if (dcd) {
[2]1379
[551]1380 LISTINFO *li;
1381 CNRDRAGINFO cni;
[2]1382
[551]1383 cni.pRecord = NULL;
1384 cni.pDragInfo = (PDRAGINFO) mp1;
1385 li = DoFileDrop(dcd->hwndCnr,
[762]1386 dcd->directory, FALSE, MPVOID, MPFROMP(&cni));
[687]1387 CheckPmDrgLimit(cni.pDragInfo);
[551]1388 if (li) {
1389 li->type = (msg == DM_DISCARDOBJECT) ? IDM_DELETE : IDM_PRINT;
1390 if (!li->list ||
1391 !li->list[0] || !PostMsg(hwnd, UM_ACTION, MPFROMP(li), MPVOID))
1392 FreeListInfo(li);
1393 else
1394 return MRFROMLONG(DRR_SOURCE);
[2]1395 }
[551]1396 }
1397 return MRFROMLONG(DRR_TARGET);
[2]1398
[551]1399 case DM_RENDERPREPARE:
1400 return (MRESULT) TRUE;
[2]1401
[551]1402 case DM_RENDER:
1403 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1404 if (dcd && dcd->info && dcd->info->extract && dcd->arcname) {
[2]1405
[551]1406 PDRAGTRANSFER pdt = (PDRAGTRANSFER) mp1;
1407 CHAR filename[CCHMAXPATH];
1408 ULONG len;
[2]1409
[551]1410 if (pdt->hwndClient && pdt->pditem && pdt->hstrSelectedRMF &&
1411 pdt->hstrRenderToName) {
1412 if (pdt->usOperation == DO_COPY || pdt->usOperation == DO_MOVE) {
1413 *filename = 0;
1414 len = DrgQueryStrName(pdt->hstrSelectedRMF, CCHMAXPATH, filename);
1415 filename[len] = 0;
1416 if (!strnicmp(filename, "OS2FILE,", 8)) {
1417 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"RMF = \"%s\"",filename);
1418 }
1419 else {
1420 *filename = 0;
1421 len =
1422 DrgQueryStrName(pdt->hstrRenderToName, CCHMAXPATH, filename);
1423 filename[len] = 0;
1424 if (len && *filename) {
1425 psz = xstrdup(filename, pszSrcFile, __LINE__);
1426 if (psz) {
1427 PostMsg(hwnd, UM_RENDER, MPFROMP(pdt), MPFROMP(psz));
1428 return (MRESULT) TRUE;
1429 }
1430 }
[358]1431 else {
[551]1432 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"No render-to name given.");
[358]1433 }
1434 }
[551]1435 }
1436 pdt->fsReply = DMFL_RENDERRETRY;
[2]1437 }
[551]1438 }
1439 return (MRESULT) FALSE;
[2]1440
[551]1441 case UM_RENDER:
1442 {
1443 PDRAGTRANSFER pdt = (PDRAGTRANSFER) mp1;
1444 USHORT usRes = DMFL_RENDERFAIL;
[2]1445
[551]1446 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1447 if (dcd && dcd->info && dcd->info->extract && dcd->arcname) {
[2]1448
[551]1449 CHAR *filename = (CHAR *) mp2, *p;
1450 ULONG len;
1451 CHAR membername[CCHMAXPATH], construct[CCHMAXPATH * 2];
[2]1452
[551]1453 *membername = 0;
1454 len = DrgQueryStrName(pdt->pditem->hstrSourceName,
1455 CCHMAXPATH, membername);
1456 membername[len] = 0;
1457 if (*membername && len && filename) {
1458 unlinkf("%s", filename);
1459 strcpy(construct, filename);
1460 p = strrchr(filename, '\\');
1461 if (!p)
1462 *construct = 0;
1463 else {
1464 if (p == filename || *(p - 1) == ':')
1465 p++;
1466 *p = 0;
1467 }
1468 // saymsg(MB_ENTER,HWND_DESKTOP,DEBUG_STRING,"%s %s %s\r[%s]",dcd->info->extract,dcd->arcname,membername,construct);
[1268]1469 runemf2(SEPARATE | WINDOWED | ASYNCHRONOUS | WAIT |
[888]1470 (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED),
1471 dcd->hwndClient, pszSrcFile, __LINE__, construct, NULL,
[773]1472 "%s %s %s",
[551]1473 dcd->info->extract,
[773]1474 BldQuotedFileName(szQuotedArcName, dcd->arcname),
1475 BldQuotedFileName(szQuotedMemberName, membername));
1476 BldFullPathName(construct, construct, membername);
[551]1477 if (IsFile(construct) != -1) {
1478 rename(construct, filename);
1479 unlinkf("%s", construct);
1480 if (IsFile(filename) != -1)
1481 usRes = DMFL_RENDEROK;
1482 }
1483 }
[2]1484 }
[1009]1485 xfree((CHAR *)mp2, pszSrcFile, __LINE__);
[551]1486 PostMsg(pdt->hwndClient, DM_RENDERCOMPLETE, MPFROMP(pdt),
1487 MPFROM2SHORT(usRes, 0));
1488 }
1489 return 0;
[2]1490
[551]1491 case UM_SETUP:
[1077]1492# ifdef FORTIFY
1493 Fortify_EnterScope();
1494# endif
[551]1495 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1496 if (!dcd) {
1497 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
1498 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1499 }
1500 else {
[1077]1501# ifdef FORTIFY
[1078]1502 Fortify_BecomeOwner(dcd);
[1077]1503# endif
[551]1504 /* set unique id */
1505 WinSetWindowUShort(hwnd, QWS_ID, ARCOBJ_FRAME + (ARC_FRAME - dcd->id));
1506 dcd->hwndObject = hwnd; // pass back hwnd
1507 if (ParentIsDesktop(hwnd, dcd->hwndParent))
[771]1508 DosSleep(100); //05 Aug 07 GKY 250 // Avoid race?
[551]1509 }
1510 return 0;
1511
1512 case UM_RESCAN:
1513 /*
1514 * populate container
1515 */
1516 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1517 if (dcd) {
1518 if (mp1)
1519 strcpy(dcd->arcname, (CHAR *) mp1); // Update name on request
1520 dcd->ullTotalBytes = dcd->totalfiles =
1521 dcd->selectedfiles = dcd->selectedbytes = 0;
1522 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, "0");
1523 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, "0 / 0k");
1524 dcd->totalfiles = FillArcCnr(dcd->hwndCnr,
1525 dcd->arcname,
1526 &dcd->info,
1527 &dcd->ullTotalBytes, &dcd->stopflag);
1528 if (!dcd->totalfiles)
1529 PostMsg(dcd->hwndCnr, WM_CLOSE, MPVOID, MPVOID);
[423]1530 else {
[551]1531 dcd->arcfilled = TRUE;
1532 if (!PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID))
1533 WinSendMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
1534 PostMsg(dcd->hwndCnr, UM_SETUP2, MPVOID, MPVOID);
1535 WinSendMsg(dcd->hwndCnr,
1536 CM_INVALIDATERECORD,
1537 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
[2]1538 }
[551]1539 }
1540 return 0;
[2]1541
[551]1542 case UM_SELECT:
1543 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1544 if (dcd) {
1545 switch (SHORT1FROMMP(mp1)) {
1546 case IDM_SELECTALL:
1547 case IDM_SELECTALLFILES:
1548 SelectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, TRUE);
1549 break;
1550 case IDM_DESELECTALL:
1551 case IDM_DESELECTALLFILES:
1552 DeselectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, TRUE);
1553 break;
1554 case IDM_DESELECTMASK:
1555 case IDM_SELECTMASK:
1556 {
1557 MASK mask;
1558 PARCITEM pci = (PARCITEM) mp2;
[2]1559
[551]1560 memset(&mask, 0, sizeof(MASK));
1561 mask.fNoAttribs = TRUE;
1562 mask.fNoDirs = TRUE;
1563 strcpy(mask.prompt,
1564 GetPString((SHORT1FROMMP(mp1) == IDM_SELECTMASK) ?
1565 IDS_SELECTFILTERTEXT : IDS_DESELECTFILTERTEXT));
1566 if (pci && (INT) pci != -1)
[730]1567 strcpy(mask.szMask, pci->pszFileName);
[551]1568 if (WinDlgBox(HWND_DESKTOP, dcd->hwndCnr, PickMaskDlgProc,
1569 FM3ModHandle, MSK_FRAME, MPFROMP(&mask))) {
1570 if (SHORT1FROMMP(mp1) == IDM_SELECTMASK)
1571 SelectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, NULL, FALSE);
1572 else
1573 DeselectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, NULL, FALSE);
1574 }
1575 }
[2]1576
[551]1577 case IDM_INVERT:
1578 InvertAll(dcd->hwndCnr);
1579 break;
[2]1580 }
[551]1581 }
1582 return 0;
[2]1583
[551]1584 case UM_ENTER:
1585 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1586 if (dcd) {
[2]1587
[1268]1588 CHAR *s = (CHAR *) mp1, *p, *pp; // filename[CCHMAXPATH];
1589 WAITCHILD *WaitChild;
[2]1590
[1268]1591 WaitChild = xmallocz(sizeof(WAITCHILD), pszSrcFile, __LINE__);
[1339]1592 WaitChild->pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
[1268]1593 if (!WaitChild)
[1335]1594 return 0;
[551]1595 if (s) {
1596 if (!dcd->info->extract) {
1597 Runtime_Error(pszSrcFile, __LINE__, "no extract");
[1039]1598 free(s);
[551]1599 return 0;
1600 }
[1394]1601 sprintf(WaitChild->pszCmdLine, "%s %s %s",
1602 dcd->info->exwdirs ? dcd->info->exwdirs :
[1339]1603 dcd->info->extract,
[773]1604 BldQuotedFileName(szQuotedArcName, dcd->arcname),
[1339]1605 BldQuotedFileName(szQuotedMemberName, s));
[551]1606 if (!dcd->info->exwdirs) {
1607 p = s;
1608 p = strrchr(s, '\\');
1609 pp = strrchr(s, '/');
1610 if (p && pp)
1611 p = max(p, pp);
1612 else if (!p)
1613 p = pp;
1614 if (p)
1615 memmove(s, p + 1, strlen(p + 1));
1616 }
[1268]1617 sprintf(WaitChild->filename, "%s\\%s", dcd->workdir, s);
1618 p = WaitChild->filename;
[551]1619 while (*p) {
1620 if (*p == '/')
1621 *p = '\\';
1622 p++;
1623 }
[1335]1624 free(s);
1625 WaitChild->RunFlags = SEPARATE | ASYNCHRONOUS | WAIT |
1626 (fArcStuffVisible ? 0 : BACKGROUND);
[1394]1627 WaitChild->hwndClient = dcd->hwndClient;
1628 WaitChild->msg = UM_ENTER;
1629 WaitChild->uiLineNumber = __LINE__;
1630 WaitChild->pszSrcFile = pszSrcFile;
[1335]1631 WaitChild->pszDirectory = xstrdup(dcd->workdir, pszSrcFile, __LINE__);
1632 WaitChild->pszEnvironment = NULL;
1633 strcpy(WaitChild->formatstring, "%s");
1634 WaitChild->hwndCnr = dcd->hwndCnr;
1635 xbeginthread(WaitChildThread,
1636 65536,
1637 WaitChild,
1638 pszSrcFile,
1639 __LINE__);
[2]1640 }
[551]1641 }
1642 return 0;
[2]1643
[551]1644 case UM_COMMAND:
1645 if (mp1) {
1646 if (PostMsg(hwnd, UM_ACTION, mp1, mp2))
1647 return (MRESULT) TRUE;
1648 }
1649 return 0;
[2]1650
[551]1651 case UM_ACTION:
1652 DosError(FERR_DISABLEHARDERR);
1653 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
1654 if (dcd) {
[2]1655
[551]1656 LISTINFO *li = (LISTINFO *) mp1;
1657 register INT x;
[2]1658
[551]1659 if (li && li->list && li->list[0]) {
[1321]1660 // printf("%x/r", li->type); fflush(stdout); // 24 Sep 08 SHL
[551]1661 switch (li->type) {
1662 case IDM_ARCHIVE:
1663 case IDM_ARCHIVEM:
1664 {
1665 DIRCNRDATA ad;
1666 CHAR szBuffer[1025], *p;
[2]1667
[551]1668 if (!li->list[1] && !stricmp(li->list[0], dcd->arcname)) {
1669 Runtime_Error(pszSrcFile, __LINE__, "arc to self");
1670 break;
1671 }
1672 ad = *dcd;
1673 ad.namecanchange = 0;
1674 ad.fmoving = (li->type == IDM_ARCHIVEM);
1675 if (!WinDlgBox(HWND_DESKTOP, dcd->hwndClient, ArchiveDlgProc, FM3ModHandle, ARCH_FRAME, (PVOID) & ad) || !*ad.arcname || !*ad.command) /* we blew it */
1676 break;
1677 /* build the sucker */
1678 strcpy(szBuffer, ad.command);
1679 strcat(szBuffer, " ");
[773]1680
1681 BldQuotedFileName(szBuffer + strlen(szBuffer), ad.arcname);
1682
1683 p = &szBuffer[strlen(szBuffer)]; // Remeber where archiver name ends
1684
[551]1685 if (ad.mask.szMask) {
1686 strcat(szBuffer, " ");
[773]1687
1688 BldQuotedFileName(szBuffer + strlen(szBuffer), ad.mask.szMask);
[551]1689 }
1690 strcat(szBuffer, " ");
1691 x = 0;
[773]1692
1693 // Run commands avoiding command line overflow
[551]1694 while (li->list[x]) {
[773]1695
1696 if (IsFile(li->list[x]))
[907]1697 BldQuotedFileName(szBuffer + strlen(szBuffer), li->list[x]);
[773]1698 else
[907]1699 BldQuotedFullPathName(szBuffer + strlen(szBuffer), li->list[x], "*");
[773]1700
[551]1701 x++;
1702 if (!li->list[x] || strlen(szBuffer) +
[1004]1703 strlen(li->list[x]) + 5 > MaxComLineStrg) {
[1268]1704 runemf2(SEPARATE | WINDOWED | ASYNCHRONOUS |
[1335]1705 (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED),
1706 hwnd, pszSrcFile, __LINE__,
[907]1707 NULL, NULL, "%s", szBuffer);
[551]1708 *p = 0;
1709 }
1710 strcat(szBuffer, " ");
[773]1711 } // while
1712
[551]1713 PostMsg(dcd->hwndCnr, UM_RESCAN, MPFROMSHORT(1), MPVOID);
1714 Broadcast(WinQueryAnchorBlock(hwnd),
1715 hwndMain, UM_UPDATERECORD, MPFROMP(ad.arcname), MPVOID);
1716 Broadcast(WinQueryAnchorBlock(hwnd),
1717 hwndMain,
1718 UM_UPDATERECORDLIST, MPFROMP(li->list), MPVOID);
1719 }
1720 break;
[2]1721
[551]1722 case IDM_REFRESH:
1723 case IDM_DELETE:
1724 {
[1077]1725 CHAR *endofit;
1726 PSZ pszCmdLine;
[551]1727 INT z;
1728 CHECKLIST ck;
1729 CHAR prompt[CCHMAXPATH + 257];
[2]1730
[551]1731 if (!dcd->info->delete)
1732 break;
1733 memset(&ck, 0, sizeof(ck));
1734 ck.size = sizeof(ck);
1735 ck.list = li->list;
1736 ck.cmd = li->type;
[1335]1737 ck.prompt = prompt;
1738 ck.flags = CHECK_ARCHIVE;
[551]1739 sprintf(prompt, GetPString(IDS_ARCCNRDELREFTEXT),
1740 (li->type == IDM_DELETE) ?
1741 GetPString(IDS_DELETELOWERTEXT) :
1742 GetPString(IDS_REFRESHLOWERTEXT),
1743 &"s"[li->list[1] == NULL],
1744 dcd->arcname,
1745 (li->type == IDM_DELETE) ?
1746 GetPString(IDS_DELETELOWERTEXT) :
1747 GetPString(IDS_REFRESHLOWERTEXT));
1748 if (!WinDlgBox(HWND_DESKTOP, hwnd, CheckListProc,
1749 FM3ModHandle, CHECK_FRAME, MPFROMP(&ck)))
1750 break;
1751 li->list = ck.list;
1752 if (!li->list || !li->list[0])
[1077]1753 break;
1754 pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1755 if (!pszCmdLine)
1756 break;
[1040]1757 strcpy(pszCmdLine, li->type == IDM_DELETE ?
[773]1758 dcd->info->delete :
1759 dcd->info->create);
[1040]1760 strcat(pszCmdLine, " ");
1761 BldQuotedFileName(pszCmdLine + strlen(pszCmdLine), dcd->arcname);
1762 endofit = &pszCmdLine[strlen(pszCmdLine)];
[551]1763 z = 0;
1764 do {
1765 for (x = z; li->list[x] &&
[1040]1766 strlen(pszCmdLine) + strlen(li->list[x]) < 999; x++) {
1767 strcat(pszCmdLine, " ");
1768 BldQuotedFileName(pszCmdLine + strlen(pszCmdLine), li->list[x]);
[551]1769 }
1770 z = x;
[1268]1771 runemf2(SEPARATE | WINDOWED | ASYNCHRONOUS | WAIT |
[888]1772 (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED),
[1040]1773 hwnd, pszSrcFile, __LINE__, NullStr, NULL, "%s", pszCmdLine);
[1077]1774 *endofit = 0;
1775 free(pszCmdLine);
[551]1776 } while (li->list[x]);
1777 PostMsg(dcd->hwndCnr, UM_RESCAN, MPFROMSHORT(1), MPVOID);
1778 Broadcast(WinQueryAnchorBlock(hwnd),
1779 hwndMain,
1780 UM_UPDATERECORD, MPFROMP(dcd->arcname), MPVOID);
1781 }
1782 break;
[2]1783
[551]1784 case IDM_PRINT:
1785 case IDM_VIRUSSCAN:
1786 case IDM_VIEW:
1787 case IDM_MCIPLAY:
1788 case IDM_VIEWARCHIVE:
1789 case IDM_VIEWTEXT:
1790 case IDM_VIEWBINARY:
1791 case IDM_EDIT:
1792 case IDM_EDITTEXT:
1793 case IDM_EDITBINARY:
1794 case IDM_EXEC:
1795 case IDM_EXTRACTWDIRS:
1796 case IDM_EXTRACT:
[1068]1797 case IDM_OPENDEFAULT:
1798 case IDM_OPENSETTINGS:
[551]1799 {
[1077]1800 CHAR *endofit, *ptr;
1801 PSZ pszCmdLine;
[551]1802 INT z;
1803 if ((li->type == IDM_EXTRACT && !li->info->extract) ||
1804 ((li->type == IDM_VIEW || li->type == IDM_VIEWTEXT ||
1805 li->type == IDM_VIEWBINARY || li->type == IDM_EDIT ||
1806 li->type == IDM_VIEWARCHIVE || li->type == IDM_EDITTEXT ||
1807 li->type == IDM_EDITBINARY || li->type == IDM_MCIPLAY) &&
1808 (!li->info->extract && !li->info->exwdirs)) ||
1809 (li->type != IDM_EXTRACT && li->type != IDM_EDIT &&
1810 li->type != IDM_VIEW && li->type != IDM_VIEWTEXT &&
1811 li->type != IDM_VIEWBINARY &&
1812 li->type != IDM_VIEWARCHIVE &&
1813 li->type != IDM_EDITTEXT &&
1814 li->type != IDM_EDITBINARY &&
1815 li->type != IDM_MCIPLAY && !li->info->exwdirs)) {
1816 Runtime_Error(pszSrcFile, __LINE__, "no cmd for request");
1817 break;
1818 }
1819 if (li->type == IDM_EXTRACT || li->type == IDM_EXTRACTWDIRS) {
[2]1820
[551]1821 CHAR fullname[CCHMAXPATH * 2];
1822 CHAR **exfiles = NULL;
[907]1823 UINT numfiles = 0, numalloc = 0;
[2]1824
[1335]1825 if (li->targetpath && fFileNameCnrPath &&
1826 stricmp(lastextractpath, li->targetpath)) {
1827 strcpy(lastextractpath, li->targetpath);
1828 SetDir(dcd->hwndParent, hwnd, li->targetpath, 1);
1829 }
[551]1830 for (x = 0; li->list[x]; x++) {
[1335]1831 BldFullPathName(fullname, li->targetpath, li->list[x]);
1832 //Check if file already exists on disk warn if it does.
[551]1833 if (IsFile(fullname) != -1) {
1834 AddToList(li->list[x], &exfiles, &numfiles, &numalloc);
1835 li->list = RemoveFromList(li->list, li->list[x]);
1836 if (!li->list)
1837 break;
1838 x--;
1839 }
1840 }
[1335]1841 if (exfiles && numfiles) {
[2]1842
[551]1843 CHECKLIST ckl;
1844 CHAR prompt[(CCHMAXPATH * 2) + 256];
[2]1845
[551]1846 memset(&ckl, 0, sizeof(ckl));
1847 ckl.size = sizeof(ckl);
1848 ckl.list = exfiles;
1849 ckl.prompt = prompt;
[1335]1850 ckl.cmd = li->type;
1851 ckl.flags = CHECK_ARCHIVE;
[551]1852 sprintf(prompt,
1853 GetPString(IDS_REPLACEWARNTEXT),
1854 &"s"[numfiles == 1],
1855 li->arcname, &"s"[numfiles != 1], li->targetpath);
1856 if (!WinDlgBox(HWND_DESKTOP, hwnd, CheckListProc,
1857 FM3ModHandle, CHECK_FRAME, MPFROMP(&ckl))) {
1858 if (ckl.list)
1859 FreeList(ckl.list);
1860 break;
1861 }
1862 else if (ckl.list)
1863 li->list = CombineLists(li->list, ckl.list);
[1306]1864 } // end check and warn
[551]1865 }
1866 if (!li->list || !li->list[0])
[1077]1867 break;
1868 pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
1869 if (!pszCmdLine)
1870 break;
[1040]1871 strcpy(pszCmdLine,
[773]1872 (li->type == IDM_EXTRACT ||
1873 ((li->type == IDM_VIEW ||
1874 li->type == IDM_VIEWTEXT ||
1875 li->type == IDM_VIEWBINARY ||
1876 li->type == IDM_VIEWARCHIVE ||
1877 li->type == IDM_PRINT ||
1878 li->type == IDM_EDIT ||
1879 li->type == IDM_EDITTEXT ||
[1068]1880 li->type == IDM_OPENDEFAULT ||
1881 li->type == IDM_OPENSETTINGS ||
1882 (li->type == IDM_EDITBINARY && // JBS No way for this () to be true??
[773]1883 li->type == IDM_MCIPLAY)) &&
1884 !li->info->exwdirs)) ?
1885 li->info->extract :
1886 li->info->exwdirs);
[1040]1887 strcat(pszCmdLine, " ");
1888 BldQuotedFileName(pszCmdLine + strlen(pszCmdLine), li->arcname);
1889 endofit = &pszCmdLine[strlen(pszCmdLine)];
[888]1890 z = 0;
1891 do {
1892 for (x = z; li->list[x] &&
[1069]1893 strlen(pszCmdLine) + strlen(li->list[x]) < MaxComLineStrg - 1 ; x++) {
[1040]1894 strcat(pszCmdLine, " ");
1895 BldQuotedFileName(pszCmdLine + strlen(pszCmdLine), li->list[x]);
[551]1896 ptr = li->list[x];
1897 while (*ptr) {
1898 if (*ptr == '/')
1899 *ptr = '\\';
1900 ptr++;
1901 }
1902 }
[1394]1903 z = x;
1904 runemf2(SEPARATE | WINDOWED | WAIT |
1905 (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED),
1906 hwnd, pszSrcFile, __LINE__,
1907 li->targetpath, NULL, "%s", pszCmdLine);
[551]1908 *endofit = 0;
1909 } while (li->list[x]);
1910 if (li->type == IDM_EXTRACT || li->type == IDM_EXTRACTWDIRS) {
1911 /* update windows */
1912 for (x = 0; li->list[x]; x++) {
[2]1913
[551]1914 CHAR *temp, *p;
[2]1915
[551]1916 temp = li->list[x];
1917 p = temp;
1918 while (*p) {
1919 if (*p == '/')
1920 *p = '\\';
1921 p++;
1922 }
[1017]1923 p = xmalloc(strlen(temp) + strlen(li->targetpath) + 2,
1924 pszSrcFile, __LINE__);
[1077]1925 if (p) {
1926 BldFullPathName(p, li->targetpath, temp);
[551]1927 li->list[x] = p;
[1039]1928 free(temp);
[551]1929 }
1930 }
1931 if (fFolderAfterExtract) {
[2]1932
[551]1933 CHAR objectpath[CCHMAXPATH], *p;
1934 APIRET rc;
[2]1935
[551]1936 GetDesktopName(objectpath, sizeof(objectpath));
1937 rc = WinDlgBox(HWND_DESKTOP, dcd->hwndParent, ObjCnrDlgProc,
1938 FM3ModHandle, OBJCNR_FRAME,
1939 MPFROMP(objectpath));
1940 if (rc) {
1941 if (rc > 1)
1942 strcpy(objectpath, "<WP_DESKTOP>");
1943 p = NULL;
1944 if (li->arcname) {
1945 p = strrchr(li->arcname, '\\');
1946 if (p)
1947 p++;
1948 }
1949 MakeShadows(dcd->hwndParent, li->list, 2, objectpath, p);
1950 }
1951 }
1952 Broadcast(WinQueryAnchorBlock(hwnd),
1953 hwndMain,
1954 UM_UPDATERECORDLIST, MPFROMP(li->list), MPVOID);
1955 }
1956 else if (li->type == IDM_EXEC)
1957 ExecOnList(hwnd,
1958 li->runfile,
1959 WINDOWED | SEPARATEKEEP | PROMPT,
1960 li->targetpath,
[907]1961 NULL, GetPString(IDS_EXECARCFILETITLETEXT),
1962 pszSrcFile, __LINE__);
[551]1963 else if (li->type == IDM_VIRUSSCAN)
1964 ExecOnList(hwnd, virus, PROMPT | WINDOWED | SEPARATEKEEP,
1965 li->targetpath, NULL,
[907]1966 GetPString(IDS_VIRUSSCANARCHIVETITLETEXT),
1967 pszSrcFile, __LINE__);
[551]1968 else if (li->type == IDM_VIEW || li->type == IDM_VIEWTEXT ||
1969 li->type == IDM_VIEWBINARY || li->type == IDM_EDIT ||
1970 li->type == IDM_EDITTEXT ||
1971 li->type == IDM_VIEWARCHIVE ||
1972 li->type == IDM_EDITBINARY ||
[1068]1973 li->type == IDM_OPENDEFAULT ||
1974 li->type == IDM_OPENSETTINGS ||
[551]1975 li->type == IDM_MCIPLAY || li->type == IDM_PRINT) {
[2]1976
[551]1977 CHAR *temp, *p;
1978 for (x = 0; li->list[x]; x++) {
1979 if (!li->info->exwdirs) {
1980 temp = li->list[x];
1981 p = strrchr(li->list[x], '\\');
1982 if (p) {
1983 p++;
1984 li->list[x] = xstrdup(p, pszSrcFile, __LINE__);
1985 if (!li->list[x])
1986 li->list[x] = temp;
1987 else {
[1032]1988 xfree(temp, pszSrcFile, __LINE__);
[551]1989 }
1990 }
[1077]1991 }
[1040]1992 BldFullPathName(pszCmdLine, li->targetpath, li->list[x]);
[551]1993 temp = li->list[x];
[1077]1994 li->list[x] = xstrdup(pszCmdLine, pszSrcFile, __LINE__);
[551]1995 if (!li->list[x])
1996 li->list[x] = temp;
1997 else
[1032]1998 xfree(temp, pszSrcFile, __LINE__);
[1077]1999 }
2000 free(pszCmdLine);
[551]2001 if (li->type == IDM_VIEW || li->type == IDM_EDIT) {
[2]2002
[551]2003 BOOL isit = TestBinary(li->list[0]);
[2]2004
[551]2005 if (isit) {
2006 if (li->type == IDM_VIEW)
2007 li->type = IDM_VIEWBINARY;
2008 else
2009 li->type = IDM_EDITBINARY;
2010 }
2011 else {
2012 if (li->type == IDM_VIEW)
2013 li->type = IDM_VIEWTEXT;
2014 else
2015 li->type = IDM_EDITTEXT;
2016 }
2017 }
2018 if (li->type == IDM_MCIPLAY) {
[2]2019
[1077]2020 FILE *fp;
2021 CHAR szTempFile[CCHMAXPATH];
[2]2022
[1077]2023 BldFullPathName(szTempFile, pTmpDir, "$FM2PLAY.$$$");
[1073]2024 fp = xfopen(szTempFile, "w", pszSrcFile, __LINE__);
[551]2025 if (fp) {
2026 fprintf(fp, "%s", ";AV/2-built FM2Play listfile\n");
2027 for (x = 0; li->list[x]; x++)
2028 fprintf(fp, "%s\n", li->list[x]);
2029 fprintf(fp, ";end\n");
[1077]2030 fclose(fp);
2031 strrev(szTempFile);
2032 strcat(szTempFile, "@/");
2033 strrev(szTempFile);
[1073]2034 RunFM2Util("FM2PLAY.EXE", szTempFile);
[762]2035 }
[551]2036 }
2037 else if (li->type == IDM_PRINT) {
2038 strcpy(li->targetpath, printer);
[1335]2039 // 10 Dec 08 SHL correct error handling - looked backward
2040 if (xbeginthread(PrintListThread,
2041 65536,
2042 li,
2043 pszSrcFile,
2044 __LINE__) != -1)
2045 {
2046 li = NULL; // Ensure not freed here
[551]2047 }
[1335]2048
[551]2049 }
2050 else if (li->type == IDM_VIEWARCHIVE) {
[2]2051
[551]2052 ARC_TYPE *info;
[2]2053
[551]2054 for (x = 0; li->list[x]; x++) {
2055 if (IsFile(li->list[x]) == 1) {
2056 info = NULL; // Do not hide dups - fixme to know why?
2057 if (WinDlgBox(HWND_DESKTOP, HWND_DESKTOP,
2058 SBoxDlgProc, FM3ModHandle, ASEL_FRAME,
2059 (PVOID) & info) && info) {
2060 StartArcCnr(HWND_DESKTOP,
2061 HWND_DESKTOP, li->list[x], 4, info);
2062 }
2063 }
2064 }
2065 }
2066 else if ((li->type == IDM_VIEWTEXT && *viewer) ||
2067 (li->type == IDM_VIEWBINARY && *binview) ||
2068 (li->type == IDM_EDITTEXT && *editor) ||
2069 (li->type == IDM_EDITBINARY && *bined)) {
[1334]2070 //DosSleep(32); // Added WAIT to runemf2 12-12-08 GKY
[551]2071 ExecOnList(hwnd, ((li->type == IDM_VIEWTEXT) ? viewer :
2072 (li->type == IDM_VIEWBINARY) ? binview :
2073 (li->type == IDM_EDITTEXT) ? editor :
2074 bined),
2075 WINDOWED | SEPARATE, li->targetpath, li->list,
[888]2076 NULL, pszSrcFile, __LINE__);
[551]2077 }
[1068]2078 else if (li->type == IDM_OPENDEFAULT ||
2079 li->type == IDM_OPENSETTINGS) {
2080 WORKER *wk;
[1077]2081# ifdef FORTIFY
2082 Fortify_EnterScope();
2083# endif
[1068]2084 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
2085 if (!wk)
[1077]2086 FreeListInfo(li);
[1068]2087 else {
[1077]2088 wk->size = sizeof(WORKER);
2089 wk->hwndCnr = dcd->hwndCnr;
2090 wk->hwndParent = dcd->hwndParent;
2091 wk->hwndFrame = dcd->hwndFrame;
2092 wk->hwndClient = dcd->hwndClient;
2093 wk->li = li;
2094 strcpy(wk->directory, dcd->directory);
[1335]2095 if (xbeginthread(Action,
2096 122880,
2097 wk,
2098 pszSrcFile,
2099 __LINE__) == -1)
2100 {
[1077]2101 free(wk);
2102 FreeListInfo((LISTINFO *) mp1);
2103 }
2104 }
2105# ifdef FORTIFY
2106 Fortify_LeaveScope();
2107# endif
[1068]2108 }
[551]2109 else {
2110 if (li->hwnd) {
[2]2111
[551]2112 ULONG viewtype;
[2]2113
[551]2114 for (x = 0; li->list[x]; x++) {
2115 if (x == 0) {
2116 if (li->type == IDM_VIEWBINARY ||
2117 li->type == IDM_EDITBINARY)
2118 viewtype = 16;
2119 else
2120 viewtype = 8;
2121 }
2122 else
2123 viewtype = 0;
[1077]2124# ifdef FORTIFY
2125 Fortify_EnterScope();
2126# endif
[551]2127 temp = xstrdup(li->list[x], pszSrcFile, __LINE__);
2128 if (temp) {
2129 if (!PostMsg(WinQueryWindow(li->hwnd, QW_PARENT),
2130 UM_LOADFILE,
2131 MPFROMLONG(4L +
2132 (li->type == IDM_VIEWTEXT ||
2133 li->type == IDM_VIEWBINARY) +
2134 viewtype), MPFROMP(temp)))
2135 free(temp);
2136 }
[1077]2137# ifdef FORTIFY
2138 DosSleep(1); // Allow MassAction to take ownership
2139 Fortify_LeaveScope();
2140# endif
[551]2141 }
2142 }
2143 }
2144 }
2145 }
2146 break;
[2]2147
[551]2148 case IDM_FIND:
2149 {
[907]2150 UINT numfiles = 0, numalloced = 0;
[551]2151 CHAR **list2 = NULL, fullname[CCHMAXPATH * 2], *p;
[2]2152
[551]2153 for (x = 0; li->list[x]; x++) {
2154 p = li->list[x];
2155 while (*p) {
2156 if (*p == '/')
2157 *p = '\\';
2158 p++;
2159 }
[773]2160 BldFullPathName(fullname, dcd->directory, li->list[x]);
[551]2161 if (IsFile(fullname) != -1)
2162 if (AddToList(fullname, &list2, &numfiles, &numalloced))
2163 break;
2164 if (strchr(li->list[x], '\\')) {
2165 p = strrchr(li->list[x], '\\');
2166 if (p) {
2167 p++;
2168 if (*p) {
[773]2169 BldFullPathName(fullname, dcd->directory, p);
[551]2170 if (IsFile(fullname) != -1)
2171 if (AddToList(fullname, &list2, &numfiles, &numalloced))
2172 break;
2173 }
2174 }
2175 }
2176 }
2177 if (!numfiles || !list2)
2178 Runtime_Error(pszSrcFile, __LINE__, "no files or list");
2179 else {
2180 WinSendMsg(dcd->hwndCnr, WM_COMMAND,
2181 MPFROM2SHORT(IDM_COLLECTOR, 0), MPVOID);
[814]2182 DosSleep(10); //05 Aug 07 GKY 128
[551]2183 if (Collector) {
2184 if (!PostMsg(Collector, WM_COMMAND,
2185 MPFROM2SHORT(IDM_COLLECTOR, 0), MPFROMP(list2)))
2186 FreeList(list2);
2187 }
2188 else
2189 FreeList(list2);
2190 }
2191 }
2192 break;
[1335]2193 } // switch
[2]2194 }
[1068]2195 if (li->type != IDM_OPENDEFAULT && li->type != IDM_OPENSETTINGS)
2196 {
[1077]2197 FreeListInfo(li);
[1068]2198 }
[551]2199 }
2200 return 0;
[2]2201
[551]2202 case WM_CLOSE:
2203 WinDestroyWindow(hwnd);
2204 break;
[2]2205
[551]2206 case WM_DESTROY:
2207 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
2208 if (dcd) {
2209 if (*dcd->workdir) {
[771]2210 DosSleep(16); //05 Aug 07 GKY 33
[551]2211 wipeallf("%s\\*", dcd->workdir);
2212 if (rmdir(dcd->workdir)) {
[771]2213 DosSleep(100); //05 Aug 07 GKY 256
[551]2214 wipeallf("%s\\*", dcd->workdir);
2215 rmdir(dcd->workdir);
2216 }
[2]2217 }
[551]2218 FreeList(dcd->lastselection);
2219 WinSendMsg(dcd->hwndCnr, UM_CLOSE, MPVOID, MPVOID);
[1039]2220 free(dcd);
[1063]2221# ifdef FORTIFY
[1077]2222 Fortify_LeaveScope();
2223# endif
[551]2224 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL);
2225 }
2226 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
2227 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
2228 break;
2229 } // switch
2230 return WinDefWindowProc(hwnd, msg, mp1, mp2);
[2]2231}
2232
[551]2233static MRESULT EXPENTRY ArcCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
2234 MPARAM mp2)
[172]2235{
[672]2236 DIRCNRDATA *dcd = INSTDATA(hwnd);
[773]2237 CHAR szQuotedArcName[CCHMAXPATH];
[2]2238
[551]2239 switch (msg) {
2240 case DM_PRINTOBJECT:
2241 case DM_DISCARDOBJECT:
2242 if (dcd)
2243 return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
2244 else
2245 return MRFROMLONG(DRR_TARGET);
[2]2246
[551]2247 case WM_CHAR:
2248 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
2249 if (SHORT1FROMMP(mp1) & KC_KEYUP)
2250 return (MRESULT) TRUE;
2251 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
2252 switch (SHORT2FROMMP(mp2)) {
2253 case VK_DELETE:
2254 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
2255 break;
[2]2256 }
[551]2257 }
2258 if (shiftstate || fNoSearch)
2259 break;
2260 if (SHORT1FROMMP(mp1) & KC_CHAR) {
[2]2261
[551]2262 ULONG thistime, len;
2263 SEARCHSTRING srch;
2264 PCNRITEM pci;
[2]2265
[551]2266 if (!dcd)
2267 break;
2268 switch (SHORT1FROMMP(mp2)) {
2269 case '\x1b':
2270 case '\r':
2271 case '\n':
2272 dcd->lasttime = 0;
2273 *dcd->szCommonName = 0;
2274 break;
2275 default:
2276 thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
2277 if (thistime > dcd->lasttime + 1250)
2278 *dcd->szCommonName = 0;
2279 dcd->lasttime = thistime;
2280 if (SHORT1FROMMP(mp2) == ' ' && !*dcd->szCommonName)
2281 break;
2282 KbdRetry:
2283 len = strlen(dcd->szCommonName);
2284 if (len >= CCHMAXPATH - 1) {
2285 *dcd->szCommonName = 0;
2286 len = 0;
2287 }
2288 dcd->szCommonName[len] = toupper(SHORT1FROMMP(mp2));
2289 dcd->szCommonName[len + 1] = 0;
2290 memset(&srch, 0, sizeof(SEARCHSTRING));
2291 srch.cb = (ULONG) sizeof(SEARCHSTRING);
2292 srch.pszSearch = dcd->szCommonName;
2293 srch.fsPrefix = TRUE;
2294 srch.fsCaseSensitive = FALSE;
2295 srch.usView = CV_ICON;
2296 pci = WinSendMsg(hwnd,
2297 CM_SEARCHSTRING,
2298 MPFROMP(&srch), MPFROMLONG(CMA_FIRST));
[1335]2299 if (pci && (INT) pci != -1) {
[2]2300
[1335]2301 USHORT attrib = CRA_CURSORED;
[2]2302
[1120]2303
[551]2304 /* make found item current item */
2305 if (!stricmp(pci->pszFileName, dcd->szCommonName))
2306 attrib |= CRA_SELECTED;
2307 WinSendMsg(hwnd,
2308 CM_SETRECORDEMPHASIS,
2309 MPFROMP(pci), MPFROM2SHORT(TRUE, attrib));
2310 /* make sure that record shows in viewport */
2311 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
2312 return (MRESULT) TRUE;
2313 }
2314 else {
2315 if (SHORT1FROMMP(mp2) == ' ') {
2316 dcd->szCommonName[len] = 0;
2317 break;
2318 }
2319 *dcd->szCommonName = 0;
2320 dcd->lasttime = 0;
2321 if (len) // retry as first letter if no match
2322 goto KbdRetry;
2323 }
2324 break;
[2]2325 }
[551]2326 }
2327 break;
[2]2328
[551]2329 case WM_MOUSEMOVE:
2330 case WM_BUTTON1UP:
2331 case WM_BUTTON2UP:
2332 case WM_BUTTON3UP:
2333 case WM_CHORD:
2334 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
2335 break;
[2]2336
[551]2337 case WM_BUTTON1MOTIONEND:
2338 {
2339 CNRINFO cnri;
[2]2340
[551]2341 memset(&cnri, 0, sizeof(CNRINFO));
2342 cnri.cb = sizeof(CNRINFO);
2343 if (WinSendMsg(hwnd,
2344 CM_QUERYCNRINFO,
2345 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)))) {
2346 if (cnri.flWindowAttr & CV_DETAIL)
2347 PrfWriteProfileData(fmprof,
2348 appname,
2349 "ArcCnrSplitBar",
2350 (PVOID) & cnri.xVertSplitbar, sizeof(LONG));
[2]2351 }
[551]2352 }
2353 break;
[2]2354
[551]2355 case WM_PRESPARAMCHANGED:
2356 PresParamChanged(hwnd, "ArcCnr", mp1, mp2);
2357 break;
[2]2358
[551]2359 case UM_UPDATERECORD:
2360 case UM_UPDATERECORDLIST:
2361 if (dcd && !IsArcThere(hwnd, dcd->arcname))
2362 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
2363 return 0;
[2]2364
[551]2365 case WM_SETFOCUS:
2366 /*
2367 * put name of our window (archive name) on status line
2368 */
2369 if (dcd && hwndStatus && mp2)
2370 WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2371 break;
[2]2372
[551]2373 case UM_SETUP2:
2374 if (dcd && dcd->info) {
2375 if (dcd->info->fdpos == -1 || !dcd->info->datetype)
2376 dcd->sortFlags &= (~SORT_LWDATE);
2377 if (dcd->info->nsizepos == -1)
2378 dcd->sortFlags &= (~SORT_EASIZE);
2379 if (dcd->info->osizepos == -1)
2380 dcd->sortFlags &= (~SORT_SIZE);
2381 AdjustCnrColVis(hwnd,
2382 GetPString(IDS_OLDSIZECOLTEXT),
2383 dcd->info->osizepos != -1, FALSE);
2384 AdjustCnrColVis(hwnd,
2385 GetPString(IDS_NEWSIZECOLTEXT),
2386 dcd->info->nsizepos != -1, FALSE);
2387 // Display unsullied date/time string if type 0
2388 AdjustCnrColVis(hwnd,
2389 GetPString(IDS_DATETIMECOLTEXT),
2390 dcd->info->fdpos != -1 && !dcd->info->datetype, FALSE);
2391 // Display parsed date/time columns if type specified
2392 AdjustCnrColVis(hwnd,
2393 GetPString(IDS_TIMECOLTEXT),
2394 dcd->info->fdpos != -1 && dcd->info->datetype, FALSE);
2395 AdjustCnrColVis(hwnd,
2396 GetPString(IDS_DATECOLTEXT),
2397 dcd->info->fdpos != -1 && dcd->info->datetype, FALSE);
2398 WinSendMsg(hwnd, CM_INVALIDATEDETAILFIELDINFO, MPVOID, MPVOID);
2399 }
2400 return 0;
[2]2401
[551]2402 case UM_RESCAN:
2403 if (dcd) {
2404 CNRINFO cnri;
2405 CHAR s[CCHMAXPATH * 2], tb[81], tf[81];
2406 PARCITEM pci;
[2]2407
[551]2408 if (mp1) {
2409 PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID);
2410 return 0;
2411 }
2412 memset(&cnri, 0, sizeof(CNRINFO));
2413 cnri.cb = sizeof(CNRINFO);
2414 WinSendMsg(hwnd,
2415 CM_QUERYCNRINFO,
2416 MPFROMP(&cnri), MPFROMLONG(sizeof(CNRINFO)));
2417 dcd->totalfiles = cnri.cRecords;
2418 commafmt(tf, sizeof(tf), dcd->selectedfiles);
2419 if (dcd->ullTotalBytes)
2420 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, 'K');
2421 else
2422 *tb = 0;
2423 sprintf(s, "%s%s%s", tf, *tb ? " / " : NullStr, tb);
2424 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
2425 commafmt(tf, sizeof(tf), dcd->totalfiles);
2426 if (dcd->ullTotalBytes)
2427 CommaFmtULL(tb, sizeof(tb), dcd->ullTotalBytes, 'K');
2428 else
2429 *tb = 0;
2430 sprintf(s, "%s%s%s", tf, *tb ? " / " : NullStr, tb);
2431 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
2432 if (hwndStatus &&
2433 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
2434 sprintf(s, " [%s%s%s]%s%s%s %s",
2435 tf,
[156]2436 *tb ? " / " : NullStr,
[551]2437 tb,
[562]2438 *dcd->mask.szMask ? " (" : NullStr,
2439 *dcd->mask.szMask ? dcd->mask.szMask : NullStr,
2440 *dcd->mask.szMask ? ")" : NullStr, dcd->arcname);
[551]2441 WinSetWindowText(hwndStatus, s);
2442 if (!ParentIsDesktop(hwnd, dcd->hwndParent)) {
2443 pci = WinSendMsg(hwnd,
2444 CM_QUERYRECORDEMPHASIS,
2445 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
[1335]2446 if (pci && (INT) pci != -1) {
[551]2447 if (fSplitStatus && hwndStatus2) {
2448 if (dcd->ullTotalBytes)
2449 CommaFmtULL(tb, sizeof(tb), pci->cbFile, ' ');
2450 else
2451 *tb = 0;
2452 sprintf(s, "%s%s%s%s",
2453 *tb ? " " : NullStr,
[730]2454 tb, *tb ? " " : NullStr, pci->pszFileName);
[551]2455 WinSetWindowText(hwndStatus2, s);
2456 }
2457 if (fMoreButtons)
[730]2458 WinSetWindowText(hwndName, pci->pszFileName);
[551]2459 }
2460 else {
2461 WinSetWindowText(hwndStatus2, NullStr);
2462 WinSetWindowText(hwndName, NullStr);
2463 }
2464 WinSetWindowText(hwndDate, NullStr);
2465 WinSetWindowText(hwndAttr, NullStr);
2466 }
[2]2467 }
[563]2468 if ((dcd->arcfilled && !dcd->totalfiles) ||
[762]2469 !IsArcThere(hwnd, dcd->arcname))
[551]2470 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
2471 }
2472 return 0;
2473
2474 case UM_SETUP:
2475 if (!dcd) {
2476 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
2477 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
[2]2478 return 0;
[551]2479 }
2480 else {
2481 if (!dcd->hwndObject) {
2482 /*
2483 * first time through -- set things up
2484 */
2485 {
2486 CHAR *p, *pp;
2487 ULONG z, was;
2488 APIRET rc;
[2]2489
[551]2490 rc = DosCreateDir(dcd->workdir, 0);
2491 if (rc) {
2492 if (rc == ERROR_ACCESS_DENIED) {
2493 p = strrchr(dcd->workdir, '.');
2494 if (p) {
2495 p++;
2496 pp = p;
2497 was = strtoul(p, &pp, 16);
2498 for (z = 0; z < 99; z++) {
2499 was++;
2500 sprintf(p, "%03x");
2501 rc = DosCreateDir(dcd->workdir, 0);
2502 if (!rc || rc != ERROR_ACCESS_DENIED)
2503 break;
2504 }
2505 }
2506 }
2507 if (rc)
2508 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
2509 return 0;
2510 }
2511 }
2512 RestorePresParams(hwnd, "ArcCnr");
2513 dcd->mask.fNoAttribs = TRUE;
2514 dcd->mask.fNoDirs = TRUE;
2515 *dcd->mask.prompt = 0;
2516 {
2517 PFIELDINFO pfi, pfiLastLeftCol;
2518 ULONG numcols = CON_COLS;
2519 CNRINFO cnri;
2520 ULONG size;
[2]2521
[551]2522 pfi = WinSendMsg(hwnd,
2523 CM_ALLOCDETAILFIELDINFO,
2524 MPFROMLONG(numcols), NULL);
2525 if (pfi) {
[2]2526
[551]2527 PFIELDINFO pfiFirst;
2528 FIELDINFOINSERT fii;
[2]2529
[551]2530 pfiFirst = pfi;
2531 pfi->flData = CFA_STRING | CFA_LEFT | CFA_FIREADONLY;
2532 pfi->flTitle = CFA_CENTER;
[1394]2533 pfi->pTitleData = (PSZ)GetPString(IDS_FILENAMECOLTEXT);
[739]2534 pfi->offStruct = FIELDOFFSET(ARCITEM, pszDisplayName);
[551]2535 pfiLastLeftCol = pfi;
2536 pfi = pfi->pNextFieldInfo;
2537 pfi->flData =
2538 CFA_ULONG | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
2539 pfi->flTitle = CFA_CENTER;
[1394]2540 pfi->pTitleData = (PSZ)GetPString(IDS_OLDSIZECOLTEXT);
[551]2541 pfi->offStruct = FIELDOFFSET(ARCITEM, cbFile);
2542 pfi = pfi->pNextFieldInfo;
2543 pfi->flData =
2544 CFA_ULONG | CFA_RIGHT | CFA_SEPARATOR | CFA_FIREADONLY;
2545 pfi->flTitle = CFA_CENTER;
[1394]2546 pfi->pTitleData = (PSZ)GetPString(IDS_NEWSIZECOLTEXT);
[551]2547 pfi->offStruct = FIELDOFFSET(ARCITEM, cbComp);
2548 pfi = pfi->pNextFieldInfo;
2549 pfi->flData =
2550 CFA_STRING | CFA_CENTER | CFA_SEPARATOR | CFA_FIREADONLY;
2551 pfi->flTitle = CFA_CENTER | CFA_FITITLEREADONLY;
[1394]2552 pfi->pTitleData = (PSZ)GetPString(IDS_DATETIMECOLTEXT);
[551]2553 pfi->offStruct = FIELDOFFSET(ARCITEM, pszDate);
2554 pfi = pfi->pNextFieldInfo;
2555 pfi->flData = CFA_DATE | CFA_RIGHT | CFA_FIREADONLY;
2556 pfi->flTitle = CFA_CENTER;
[1394]2557 pfi->pTitleData = (PSZ)GetPString(IDS_DATECOLTEXT);
[551]2558 pfi->offStruct = FIELDOFFSET(ARCITEM, date);
2559 pfi = pfi->pNextFieldInfo;
2560 pfi->flData = CFA_TIME | CFA_RIGHT | CFA_FIREADONLY;
2561 pfi->flTitle = CFA_CENTER | CFA_FITITLEREADONLY;
[1394]2562 pfi->pTitleData = (PSZ)GetPString(IDS_TIMECOLTEXT);
[551]2563 pfi->offStruct = FIELDOFFSET(ARCITEM, time);
2564 memset(&fii, 0, sizeof(FIELDINFOINSERT));
2565 fii.cb = sizeof(FIELDINFOINSERT);
2566 fii.pFieldInfoOrder = (PFIELDINFO) CMA_FIRST;
2567 fii.cFieldInfoInsert = (SHORT) numcols;
2568 fii.fInvalidateFieldInfo = TRUE;
2569 WinSendMsg(hwnd,
2570 CM_INSERTDETAILFIELDINFO,
2571 MPFROMP(pfiFirst), MPFROMP(&fii));
2572 PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
[2]2573
[551]2574 memset(&cnri, 0, sizeof(cnri));
2575 cnri.cb = sizeof(CNRINFO);
2576 cnri.pFieldInfoLast = pfiLastLeftCol;
2577 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET + 32;
[2]2578
[551]2579 size = sizeof(LONG);
2580 PrfQueryProfileData(fmprof, appname, "ArcCnrSplitBar",
2581 &cnri.xVertSplitbar, &size);
2582 if (cnri.xVertSplitbar <= 0)
2583 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET + 32;
[2]2584
[551]2585 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT | CV_NAME));
2586 cnri.flWindowAttr |= (CV_DETAIL | CA_DETAILSVIEWTITLES | CV_FLOW);
2587 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH |
2588 CA_MIXEDTARGETEMPH));
2589 cnri.pSortRecord = (PVOID) ArcSort;
2590 WinSendMsg(hwnd,
2591 CM_SETCNRINFO,
2592 MPFROMP(&cnri),
2593 MPFROMLONG(CMA_PFIELDINFOLAST |
2594 CMA_XVERTSPLITBAR |
2595 CMA_PSORTRECORD | CMA_FLWINDOWATTR));
2596 }
2597 }
2598 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(ArcSort), MPFROMP(dcd));
[1335]2599 if (xbeginthread(MakeObjWin,
2600 245760,
2601 dcd,
2602 pszSrcFile,
2603 __LINE__) == -1)
2604 {
[551]2605 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
2606 return 0;
2607 }
2608 else
[766]2609 DosSleep(1);
[551]2610 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2611 DIR_FILTER), &dcd->mask, TRUE);
2612 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2613 DIR_SORT), dcd->sortFlags, TRUE);
2614 DefArcSortFlags = dcd->sortFlags; // Remember for new windows
[2]2615 }
[551]2616 }
2617 return 0;
[2]2618
[551]2619 case UM_SETDIR:
2620 if (dcd) {
[2]2621
[551]2622 CHAR s[CCHMAXPATH], *p;
2623 ULONG ret = 0;
[2]2624
[551]2625 WinQueryDlgItemText(dcd->hwndClient, ARC_EXTRACTDIR, CCHMAXPATH, s);
2626 bstrip(s);
2627 MakeFullName(s);
2628 if (*s) {
2629 while ((p = strchr(s, '/')) != NULL)
2630 *p = '\\';
2631 while (strlen(s) > 3 && s[strlen(s) - 1] == '\\')
2632 s[strlen(s) - 1] = 0;
2633 if (stricmp(s, dcd->directory)) {
2634 if (IsFullName(s)) {
2635 if (driveflags[toupper(*s) - 'A'] &
2636 (DRIVE_NOTWRITEABLE | DRIVE_IGNORE | DRIVE_INVALID)) {
2637 Runtime_Error(pszSrcFile, __LINE__, "drive %s bad", s);
2638 WinSetDlgItemText(dcd->hwndClient,
2639 ARC_EXTRACTDIR, dcd->directory);
2640 return 0;
2641 }
2642 }
2643 if (!SetDir(dcd->hwndParent, hwnd, s, 0)) {
2644 if (stricmp(dcd->directory, s)) {
[1335]2645 //DosEnterCritSec(); //GKY 11-29-08
2646 DosRequestMutexSem(hmtxFM2Globals, SEM_INDEFINITE_WAIT);
2647 strcpy(lastextractpath, s);
2648 DosReleaseMutexSem(hmtxFM2Globals);
[1301]2649 //DosExitCritSec();
[551]2650 }
2651 strcpy(dcd->directory, s);
2652 if ((!isalpha(*s) || s[1] != ':') && *s != '.')
2653 saymsg(MB_ENTER | MB_ICONASTERISK,
2654 hwnd,
2655 GetPString(IDS_WARNINGTEXT),
2656 GetPString(IDS_SPECIFYDRIVETEXT));
2657 }
2658 else
2659 ret = 1;
2660 }
[2]2661 }
[551]2662 WinSetDlgItemText(dcd->hwndClient, ARC_EXTRACTDIR, dcd->directory);
2663 return (MRESULT) ret;
2664 }
2665 return 0;
2666
2667 case UM_ENTER:
[1268]2668 if (WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID)) {
2669 free(mp1);
[2]2670 return 0;
[1268]2671 }
[551]2672 SetShiftState();
2673 if (dcd && (CHAR *) mp1) {
[2]2674
[551]2675 SWP swp;
2676 CHAR *filename = mp1;
[1268]2677 printf("%s %d UM_ENTER %s\n",__FILE__, __LINE__, filename); fflush(stdout);
2678 if (IsFile(filename) != 1) {
[1335]2679 free(mp1);
2680 return 0;
[1268]2681 }
[551]2682 WinQueryWindowPos(dcd->hwndFrame, &swp);
2683 DefaultViewKeys(hwnd, dcd->hwndFrame, dcd->hwndParent, &swp, filename);
2684 if (fUnHilite)
[672]2685 UnHilite(hwnd, FALSE, &dcd->lastselection, 0);
[551]2686 }
[1268]2687 free(mp1);
[551]2688 return 0;
[2]2689
[551]2690 case WM_MENUEND:
2691 if (dcd) {
[2]2692
[551]2693 HWND hwndMenu = (HWND) mp2;
[2]2694
[551]2695 if (hwndMenu == ArcCnrMenu || hwndMenu == ArcMenu) {
2696 MarkAll(hwnd, TRUE, FALSE, TRUE);
2697 if (dcd->cnremphasized) {
2698 WinSendMsg(hwnd,
2699 CM_SETRECORDEMPHASIS,
2700 MPVOID, MPFROM2SHORT(FALSE, CRA_SOURCE));
2701 dcd->cnremphasized = FALSE;
2702 }
[2]2703 }
[551]2704 }
2705 break;
[2]2706
[551]2707 case MM_PORTHOLEINIT:
2708 if (dcd) {
2709 switch (SHORT1FROMMP(mp1)) {
2710 case 0:
2711 case 1:
2712 {
2713 ULONG wmsg;
[2]2714
[562]2715 wmsg = SHORT1FROMMP(mp1) == 0 ? UM_FILESMENU : UM_VIEWSMENU;
[551]2716 PortholeInit((HWND) WinSendMsg(dcd->hwndClient,
2717 wmsg, MPVOID, MPVOID), mp1, mp2);
2718 }
2719 break;
[2]2720 }
[551]2721 }
2722 break;
[2]2723
[551]2724 case UM_INITMENU:
2725 case WM_INITMENU:
2726 if (dcd) {
2727 switch (SHORT1FROMMP(mp1)) {
2728 case IDM_FILESMENU:
2729 if (dcd->info) {
2730 WinEnableMenuItem((HWND) mp2,
2731 IDM_DELETE, dcd->info->delete != NULL);
2732 WinEnableMenuItem((HWND) mp2, IDM_TEST, dcd->info->test != NULL);
2733 WinEnableMenuItem((HWND) mp2,
2734 IDM_EXTRACT, dcd->info->extract != NULL);
2735 WinEnableMenuItem((HWND) mp2,
2736 IDM_EXTRACTWDIRS, dcd->info->exwdirs != NULL);
2737 WinEnableMenuItem((HWND) mp2,
2738 IDM_ARCEXTRACTWDIRS, dcd->info->exwdirs != NULL);
2739 WinEnableMenuItem((HWND) mp2,
2740 IDM_ARCEXTRACTWDIRSEXIT,
2741 dcd->info->exwdirs != NULL);
2742 }
2743 break;
[2]2744
[551]2745 case IDM_VIEWSMENU:
2746 WinCheckMenuItem((HWND) mp2,
[562]2747 IDM_MINIICONS, (dcd->flWindowAttr & CV_MINI) != 0);
[551]2748 WinEnableMenuItem((HWND) mp2,
2749 IDM_RESELECT, (dcd->lastselection != NULL));
2750 break;
[2]2751
[551]2752 case IDM_COMMANDSMENU:
2753 SetupCommandMenu((HWND) mp2, hwnd);
2754 break;
[2]2755
[551]2756 case IDM_SORTSUBMENU:
2757 SetSortChecks((HWND) mp2, dcd->sortFlags);
2758 break;
[2]2759
[551]2760 case IDM_WINDOWSMENU:
2761 /*
2762 * add switchlist entries to end of pulldown menu
2763 */
[562]2764 SetupWinList((HWND)mp2,
2765 hwndMain ? hwndMain : (HWND)0, dcd->hwndFrame);
[551]2766 break;
[2]2767 }
[551]2768 dcd->hwndLastMenu = (HWND) mp2;
2769 }
2770 if (msg == WM_INITMENU)
2771 break;
2772 return 0;
[2]2773
[551]2774 case UM_LOADFILE:
2775 if (dcd && mp2) {
[2]2776
[1037]2777 HWND hwnd;
[2]2778
[1037]2779 if ((INT)mp1 == 5 || (INT)mp1 == 13 || (INT)mp1 == 21)
[1077]2780 hwnd = StartViewer(HWND_DESKTOP, (INT)mp1,
2781 (CHAR *)mp2, dcd->hwndFrame);
[1037]2782 else
[1077]2783 hwnd = StartMLEEditor(dcd->hwndParent,
2784 (INT)mp1, (CHAR *)mp2, dcd->hwndFrame);
[1039]2785 free((CHAR *)mp2);
[1037]2786 return MRFROMLONG(hwnd);
[551]2787 }
2788 return 0;
2789
2790 case UM_COMMAND:
2791 if (mp1) {
2792 if (dcd) {
2793 if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
2794 Runtime_Error(pszSrcFile, __LINE__, "post");
2795 FreeListInfo((LISTINFO *) mp1);
2796 }
2797 else
2798 return (MRESULT) TRUE;
[2]2799 }
[551]2800 else
2801 FreeListInfo((LISTINFO *) mp1);
2802 }
2803 return 0;
[2]2804
[551]2805 case UM_OPENWINDOWFORME:
2806 if (dcd) {
2807 if (mp1 && !IsFile((CHAR *) mp1)) {
2808 OpenDirCnr((HWND) 0, hwndMain, dcd->hwndFrame, FALSE, (char *)mp1);
[2]2809 }
[1120]2810 else if (mp1 && IsFile(mp1) == 1 &&
[1335]2811 CheckDriveSpaceAvail(ArcTempRoot, ullDATFileSpaceNeeded, ullTmpSpaceNeeded) != 2) {
[551]2812 StartArcCnr(HWND_DESKTOP,
2813 dcd->hwndFrame, (CHAR *) mp1, 4, (ARC_TYPE *) mp2);
2814 }
2815 }
2816 return 0;
[2]2817
[551]2818 case WM_COMMAND:
2819 DosError(FERR_DISABLEHARDERR);
2820 if (dcd) {
2821 if (SwitchCommand(dcd->hwndLastMenu, SHORT1FROMMP(mp1)))
2822 return 0;
2823 if (WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID))
2824 return 0;
2825 if (!IsArcThere(hwnd, dcd->arcname)) {
2826 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
2827 return 0;
[2]2828 }
[551]2829 switch (SHORT1FROMMP(mp1)) {
2830 case IDM_TREEVIEW:
[2]2831
[551]2832 break;
[2]2833
[551]2834 case IDM_CONTEXTMENU:
2835 {
2836 PCNRITEM pci;
[2]2837
[551]2838 pci = (PCNRITEM) CurrentRecord(hwnd);
2839 PostMsg(hwnd,
2840 WM_CONTROL,
2841 MPFROM2SHORT(ARC_CNR, CN_CONTEXTMENU), MPFROMP(pci));
2842 }
2843 break;
[2]2844
[551]2845 case IDM_NEXTWINDOW:
2846 case IDM_PREVWINDOW:
2847 {
2848 HWND hwndActive;
[2]2849
[551]2850 hwndActive = WinQueryFocus(HWND_DESKTOP);
2851 WinSetFocus(HWND_DESKTOP,
[563]2852 hwndActive == hwnd ?
[762]2853 WinWindowFromID(dcd->hwndClient, ARC_EXTRACTDIR) :
2854 hwnd);
[551]2855 }
2856 break;
[2]2857
[551]2858 case IDM_FOLDERAFTEREXTRACT:
[562]2859 fFolderAfterExtract = fFolderAfterExtract ? FALSE : TRUE;
[551]2860 PrfWriteProfileData(fmprof, appname, "FolderAfterExtract",
2861 &fFolderAfterExtract, sizeof(BOOL));
2862 break;
[2]2863
[551]2864 case IDM_SHOWSELECT:
[872]2865 QuickPopup(hwnd, dcd, CheckMenu(hwnd, &ArcCnrMenu, ARCCNR_POPUP),
[551]2866 IDM_SELECTSUBMENU);
2867 break;
[2]2868
[551]2869 case IDM_SHOWSORT:
[872]2870 QuickPopup(hwnd, dcd, CheckMenu(hwnd, &ArcCnrMenu, ARCCNR_POPUP),
[551]2871 IDM_SORTSUBMENU);
2872 break;
[2]2873
[953]2874 case IDM_ARCHIVERSETTINGS:
[551]2875 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
[917]2876 PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_ARCHIVERSETTINGS), mp2);
2877 else {
[551]2878 WinDlgBox(HWND_DESKTOP,
2879 hwnd,
[917]2880 CfgDlgProc,
2881 FM3ModHandle,
2882 CFG_FRAME,
2883 MPFROMLONG(IDM_ARCHIVERSETTINGS));
2884 }
[551]2885 break;
[2]2886
[551]2887 case IDM_RESCAN:
2888 dcd->ullTotalBytes = dcd->totalfiles =
2889 dcd->selectedfiles = dcd->selectedbytes = 0;
2890 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, "0");
2891 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, "0 / 0k");
2892 dcd->totalfiles = FillArcCnr(dcd->hwndCnr,
2893 dcd->arcname,
2894 &dcd->info,
2895 &dcd->ullTotalBytes, &dcd->stopflag);
2896 PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
2897 PostMsg(dcd->hwndCnr, UM_SETUP2, MPVOID, MPVOID);
2898 WinSendMsg(dcd->hwndCnr,
2899 CM_INVALIDATERECORD,
2900 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
2901 break;
[2]2902
[551]2903 case IDM_RESELECT:
2904 SelectList(hwnd, TRUE, FALSE, FALSE, NULL, NULL, dcd->lastselection);
2905 break;
[2]2906
[551]2907 case IDM_HELP:
2908 if (hwndHelp)
2909 WinSendMsg(hwndHelp,
2910 HM_DISPLAY_HELP,
2911 MPFROM2SHORT(HELP_ARCLIST, 0),
2912 MPFROMSHORT(HM_RESOURCEID));
2913 break;
[2]2914
[551]2915 case IDM_WINDOWDLG:
2916 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndFrame))
2917 PostMsg(dcd->hwndParent,
2918 UM_COMMAND, MPFROM2SHORT(IDM_WINDOWDLG, 0), MPVOID);
2919 break;
[2]2920
[551]2921 case IDM_SELECTALL:
2922 case IDM_SELECTALLFILES:
2923 case IDM_DESELECTALL:
2924 case IDM_DESELECTALLFILES:
2925 case IDM_SELECTMASK:
2926 case IDM_DESELECTMASK:
2927 case IDM_INVERT:
2928 {
2929 PARCITEM pci;
[2]2930
[551]2931 pci = (PARCITEM) WinSendMsg(hwnd,
2932 CM_QUERYRECORDEMPHASIS,
2933 MPFROMLONG(CMA_FIRST),
2934 MPFROMSHORT(CRA_CURSORED));
2935 if ((INT) pci == -1)
2936 pci = NULL;
2937 if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
2938 if (pci) {
2939 if (!(pci->rc.flRecordAttr & CRA_SELECTED))
2940 pci->rc.flRecordAttr |= CRA_FILTERED;
2941 WinSendMsg(hwnd,
2942 CM_INVALIDATERECORD,
2943 MPFROMP(&pci),
2944 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
2945 break;
2946 }
2947 }
2948 PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
2949 }
2950 break;
[2]2951
[551]2952 case IDM_SORTSMARTNAME:
2953 case IDM_SORTNAME:
2954 case IDM_SORTFILENAME:
2955 case IDM_SORTSIZE:
2956 case IDM_SORTEASIZE:
2957 case IDM_SORTFIRST:
2958 case IDM_SORTLAST:
2959 case IDM_SORTLWDATE:
2960 dcd->sortFlags &= SORT_REVERSE;
2961 /* intentional fallthru */
2962 case IDM_SORTREVERSE:
2963 switch (SHORT1FROMMP(mp1)) {
2964 case IDM_SORTSMARTNAME:
2965 case IDM_SORTFILENAME:
2966 dcd->sortFlags |= SORT_FILENAME;
2967 break;
2968 case IDM_SORTSIZE:
2969 dcd->sortFlags |= SORT_SIZE;
2970 break;
2971 case IDM_SORTEASIZE:
2972 dcd->sortFlags |= SORT_EASIZE;
2973 break;
2974 case IDM_SORTFIRST:
2975 dcd->sortFlags |= SORT_FIRSTEXTENSION;
2976 break;
2977 case IDM_SORTLAST:
2978 dcd->sortFlags |= SORT_LASTEXTENSION;
2979 break;
2980 case IDM_SORTLWDATE:
2981 dcd->sortFlags |= SORT_LWDATE;
2982 break;
2983 case IDM_SORTREVERSE:
2984 if (dcd->sortFlags & SORT_REVERSE)
2985 dcd->sortFlags &= (~SORT_REVERSE);
2986 else
2987 dcd->sortFlags |= SORT_REVERSE;
2988 break;
2989 }
2990 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(ArcSort), MPFROMP(dcd));
2991 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
2992 DIR_SORT), dcd->sortFlags, TRUE);
2993 DefArcSortFlags = dcd->sortFlags; // Remember for new windows
2994 break;
[2]2995
[551]2996 case IDM_COLLECTOR:
2997 if (!Collector) {
2998 HWND hwndC;
2999 SWP swp;
[2]3000
[551]3001 if (ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
3002 (!fExternalCollector && !strcmp(realappname, FM3Str)))
3003 GetNextWindowPos(dcd->hwndParent, &swp, NULL, NULL);
[563]3004 hwndC = StartCollector(fExternalCollector ||
3005 strcmp(realappname, FM3Str) ?
3006 HWND_DESKTOP : dcd->hwndParent, 4);
[551]3007 if (hwndC) {
3008 if (!ParentIsDesktop(hwnd, dcd->hwndParent) && !fAutoTile &&
3009 (!fExternalCollector && !strcmp(realappname, FM3Str)))
3010 WinSetWindowPos(hwndC,
3011 HWND_TOP,
3012 swp.x,
3013 swp.y,
3014 swp.cx,
3015 swp.cy,
3016 SWP_MOVE | SWP_SIZE | SWP_SHOW | SWP_ZORDER);
3017 else if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
3018 fAutoTile && !strcmp(realappname, FM3Str)) {
3019 TileChildren(dcd->hwndParent, TRUE);
3020 }
3021 WinSetWindowPos(hwndC, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE);
[771]3022 DosSleep(100); //05 Aug 07 GKY 128
[551]3023 }
3024 }
3025 else
3026 StartCollector(dcd->hwndParent, 4);
3027 break;
[2]3028
[551]3029 case IDM_ARCEXTRACTEXIT:
3030 case IDM_ARCEXTRACT:
[1335]3031 if (dcd->directory && fFileNameCnrPath &&
3032 stricmp(lastextractpath, dcd->directory)) {
3033 strcpy(lastextractpath, dcd->directory);
3034 SetDir(dcd->hwndParent, hwnd, dcd->directory, 1);
3035 }
[551]3036 if (dcd->info->extract)
[1268]3037 runemf2(SEPARATE | WINDOWED | ASYNCHRONOUS |
[888]3038 (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED),
[907]3039 hwnd, pszSrcFile, __LINE__,
3040 dcd->directory, NULL, "%s %s", dcd->info->extract,
[773]3041 BldQuotedFileName(szQuotedArcName, dcd->arcname));
[551]3042 if (SHORT1FROMMP(mp1) == IDM_ARCEXTRACTEXIT)
3043 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
3044 break;
[2]3045
[551]3046 case IDM_ARCEXTRACTWDIRSEXIT:
3047 case IDM_ARCEXTRACTWDIRS:
[1335]3048 if (dcd->directory && fFileNameCnrPath &&
3049 stricmp(lastextractpath, dcd->directory)) {
3050 strcpy(lastextractpath, dcd->directory);
3051 SetDir(dcd->hwndParent, hwnd, dcd->directory, 1);
3052 }
[551]3053 if (dcd->info->exwdirs)
[1268]3054 runemf2(SEPARATE | WINDOWED | ASYNCHRONOUS |
[888]3055 (fArcStuffVisible ? 0 : BACKGROUND | MINIMIZED),
[907]3056 hwnd, pszSrcFile, __LINE__,
3057 dcd->directory, NULL, "%s %s",
[551]3058 dcd->info->exwdirs,
[773]3059 BldQuotedFileName(szQuotedArcName, dcd->arcname));
[551]3060 if (SHORT1FROMMP(mp1) == IDM_ARCEXTRACTWDIRSEXIT)
3061 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
3062 break;
[2]3063
[551]3064 case IDM_RESORT:
3065 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(ArcSort), MPFROMP(dcd));
3066 break;
[2]3067
[551]3068 case IDM_FILTER:
3069 {
3070 BOOL empty = FALSE;
3071 PARCITEM pci;
[2]3072
[551]3073 if (!*dcd->mask.szMask) {
3074 empty = TRUE;
3075 pci = (PARCITEM) CurrentRecord(hwnd);
[730]3076 if (pci && strchr(pci->pszFileName, '.'))
3077 strcpy(dcd->mask.szMask, pci->pszFileName);
[551]3078 }
[2]3079
[551]3080 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
3081 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask))) {
3082 WinSendMsg(hwnd, CM_FILTER, MPFROMP(ArcFilter), MPFROMP(dcd));
3083 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
3084 }
3085 else if (empty)
3086 *dcd->mask.szMask = 0;
3087 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
3088 DIR_FILTER), &dcd->mask, TRUE);
3089 }
3090 break;
[2]3091
[551]3092 case IDM_SWITCH:
3093 if (mp2) {
3094 if (stricmp(dcd->directory, (CHAR *) mp2)) {
[1335]3095 //DosEnterCritSec(); //GKY 11-29-08
3096 DosRequestMutexSem(hmtxFM2Globals, SEM_INDEFINITE_WAIT);
[551]3097 strcpy(lastextractpath, (CHAR *) mp2);
[1335]3098 MakeValidDir(lastextractpath);
3099 DosReleaseMutexSem(hmtxFM2Globals);
[1301]3100 //DosExitCritSec();
[551]3101 }
3102 strcpy(dcd->directory, (CHAR *) mp2);
3103 MakeValidDir(dcd->directory);
3104 WinSetWindowText(dcd->hwndExtract, dcd->directory);
3105 }
3106 break;
[2]3107
[551]3108 case IDM_WALKDIR:
3109 {
3110 CHAR newdir[CCHMAXPATH];
[2]3111
[551]3112 strcpy(newdir, dcd->directory);
3113 if (!WinDlgBox(HWND_DESKTOP, dcd->hwndParent, WalkExtractDlgProc,
3114 FM3ModHandle, WALK_FRAME,
3115 MPFROMP(newdir)) || !*newdir)
3116 break;
3117 if (stricmp(newdir, dcd->directory)) {
3118 strcpy(dcd->directory, newdir);
3119 if (stricmp(lastextractpath, newdir))
3120 strcpy(lastextractpath, newdir);
3121 WinSetWindowText(dcd->hwndExtract, dcd->directory);
3122 }
3123 }
3124 break;
[2]3125
[551]3126 case IDM_TEST:
3127 if (dcd->info->test)
3128 runemf2(SEPARATEKEEP | WINDOWED | MAXIMIZED,
[888]3129 hwnd, pszSrcFile, __LINE__, NULL, NULL,
[773]3130 "%s %s",dcd->info->test,
3131 BldQuotedFileName(szQuotedArcName, dcd->arcname));
[551]3132 break;
[2]3133
[551]3134 case IDM_REFRESH:
3135 case IDM_DELETE:
3136 case IDM_PRINT:
3137 case IDM_VIEW:
3138 case IDM_VIEWTEXT:
3139 case IDM_VIEWBINARY:
3140 case IDM_VIEWARCHIVE:
3141 case IDM_EDIT:
3142 case IDM_EDITTEXT:
3143 case IDM_EDITBINARY:
3144 case IDM_EXTRACT:
3145 case IDM_EXTRACTWDIRS:
3146 case IDM_FIND:
3147 case IDM_EXEC:
3148 case IDM_VIRUSSCAN:
[1068]3149 case IDM_OPENDEFAULT:
3150 case IDM_OPENSETTINGS:
[1069]3151 case IDM_MCIPLAY:
[551]3152 {
3153 LISTINFO *li;
[1077]3154# ifdef FORTIFY
3155 Fortify_EnterScope();
3156# endif
[551]3157 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
3158 if (li) {
3159 li->type = SHORT1FROMMP(mp1);
3160 li->hwnd = hwnd;
3161 li->list = BuildArcList(hwnd);
3162 if (li->type == IDM_REFRESH) {
[2]3163
[551]3164 CHAR s[CCHMAXPATH], *p;
3165 INT x, y;
[2]3166
[551]3167 for (x = 0; li->list && li->list[x]; x++) {
[773]3168 BldFullPathName(s, dcd->workdir, li->list[x]);
[551]3169 if (IsFile(s) != 1) {
[1039]3170 free(li->list[x]);
[551]3171 li->list[x] = NULL;
3172 for (y = x; li->list[y]; y++)
3173 li->list[y] = li->list[y + 1];
3174 li->list =
3175 xrealloc(li->list, y * sizeof(CHAR *), pszSrcFile,
3176 __LINE__);
3177 x--;
3178 }
3179 else {
3180 p = xstrdup(s, pszSrcFile, __LINE__);
3181 if (p) {
[1039]3182 free(li->list[x]);
[551]3183 li->list[x] = p;
3184 }
3185 }
3186 } // for
3187 }
3188 strcpy(li->arcname, dcd->arcname);
3189 li->info = dcd->info;
3190 {
3191 PARCITEM pai;
[2]3192
[551]3193 if (SHORT1FROMMP(mp1) != IDM_EXEC)
3194 pai = (PARCITEM) CurrentRecord(hwnd);
3195 else
3196 pai = (PARCITEM) WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
3197 MPFROMLONG(CMA_FIRST),
3198 MPFROMSHORT(CRA_CURSORED));
3199 if (pai && (INT) pai != -1)
[730]3200 strcpy(li->runfile, pai->pszFileName);
[551]3201 else
3202 strcpy(li->runfile, li->list[0]);
3203 }
3204 switch (SHORT1FROMMP(mp1)) {
3205 case IDM_VIEW:
3206 case IDM_VIEWTEXT:
3207 case IDM_VIEWBINARY:
3208 case IDM_VIEWARCHIVE:
3209 case IDM_EDIT:
3210 case IDM_EDITTEXT:
3211 case IDM_EDITBINARY:
3212 case IDM_EXEC:
3213 case IDM_PRINT:
3214 case IDM_VIRUSSCAN:
[1068]3215 case IDM_OPENDEFAULT:
[1077]3216 case IDM_OPENSETTINGS:
3217 case IDM_MCIPLAY:
[551]3218 strcpy(li->targetpath, dcd->workdir);
3219 break;
3220 default:
3221 strcpy(li->targetpath, dcd->directory);
3222 break;
3223 }
3224 if (li->list) {
3225 if (!PostMsg(dcd->hwndObject, UM_ACTION, MPFROMP(li), MPVOID)) {
3226 Runtime_Error(pszSrcFile, __LINE__, "post");
3227 FreeListInfo(li);
3228 }
3229 else if (fUnHilite && SHORT1FROMMP(mp1) != IDM_EDIT)
[672]3230 UnHilite(hwnd, TRUE, &dcd->lastselection, 0);
[551]3231 }
[1077]3232 else {
[1039]3233 free(li);
[1077]3234 }
[551]3235 }
[1077]3236# ifdef FORTIFY
3237 Fortify_LeaveScope();
3238# endif
[551]3239 }
3240 break;
[2]3241 }
[551]3242 }
3243 return 0;
[2]3244
[551]3245 case WM_CONTROL:
3246 DosError(FERR_DISABLEHARDERR);
3247 if (dcd) {
3248 switch (SHORT2FROMMP(mp1)) {
3249 case CN_BEGINEDIT:
3250 PostMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
3251 break;
[2]3252
[551]3253 case CN_ENDEDIT:
3254 if (!((PCNREDITDATA) mp2)->pRecord) {
[2]3255
[551]3256 PFIELDINFO pfi = ((PCNREDITDATA) mp2)->pFieldInfo;
3257 USHORT cmd = 0;
[2]3258
[739]3259 if (!pfi || pfi->offStruct == FIELDOFFSET(ARCITEM, pszDisplayName))
[551]3260 cmd = IDM_SORTSMARTNAME;
3261 else if (pfi->offStruct == FIELDOFFSET(ARCITEM, cbFile))
3262 cmd = IDM_SORTSIZE;
3263 else if (pfi->offStruct == FIELDOFFSET(ARCITEM, cbComp))
3264 cmd = IDM_SORTEASIZE;
3265 else if (pfi->offStruct == FIELDOFFSET(ARCITEM, date))
3266 cmd = IDM_SORTLWDATE;
3267 else if (pfi->offStruct == FIELDOFFSET(ARCITEM, time))
3268 cmd = IDM_SORTLWDATE;
3269 if (cmd)
3270 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
3271 }
3272 break;
[2]3273
[551]3274 case CN_DROPHELP:
3275 saymsg(MB_ENTER, hwnd,
3276 GetPString(IDS_DROPHELPHDRTEXT),
3277 GetPString(IDS_ARCCNRDROPHELPTEXT), dcd->arcname);
3278 return 0;
[2]3279
[551]3280 case CN_DRAGLEAVE:
3281 if (mp2) {
[2]3282
[551]3283 PDRAGINFO pDInfo;
[2]3284
[551]3285 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
[562]3286 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */
3287 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
[551]3288 }
3289 return 0;
[2]3290
[551]3291 case CN_DRAGAFTER:
3292 case CN_DRAGOVER:
3293 if (mp2) {
[2]3294
[773]3295 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
3296 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
[551]3297 PARCITEM pci;
[2]3298
[551]3299 pci = (PARCITEM) ((PCNRDRAGINFO) mp2)->pRecord;
3300 if (SHORT1FROMMP(mp1) == CN_DRAGAFTER)
3301 pci = NULL;
3302 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
[562]3303 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */
[551]3304 if (*dcd->arcname) {
3305 if ((driveflags[toupper(*dcd->arcname) - 'A'] &
3306 DRIVE_NOTWRITEABLE) || !dcd->info || !dcd->info->create) {
3307 DrgFreeDraginfo(pDInfo);
3308 return MRFROM2SHORT(DOR_NEVERDROP, 0);
3309 }
3310 }
3311 if (pci) {
3312 DrgFreeDraginfo(pDInfo);
3313 return MRFROM2SHORT(DOR_NODROP, 0);
3314 }
[562]3315 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */
3316 0); /* Index to DRAGITEM */
[551]3317 if (DrgVerifyRMF(pDItem, /* Check valid rendering */
[562]3318 DRM_OS2FILE, /* mechanisms and data */
[551]3319 NULL) && !(pDItem->fsControl & DC_PREPARE)) {
[773]3320 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
[562]3321 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
3322 fCopyDefault ? DO_COPY : DO_MOVE);
[551]3323 }
[562]3324 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
[551]3325 }
[562]3326 return (MRFROM2SHORT(DOR_NEVERDROP, 0)); /* Drop not valid */
[2]3327
[551]3328 case CN_INITDRAG:
3329 if (mp2) {
[2]3330
[551]3331 BOOL wasemphasized = FALSE;
3332 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
3333 PARCITEM pci;
[2]3334
[551]3335 if (pcd) {
3336 pci = (PARCITEM) pcd->pRecord;
3337 if (pci) {
3338 if (pci->rc.flRecordAttr & CRA_SELECTED)
3339 wasemphasized = TRUE;
3340 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
3341 fSplitStatus && hwndStatus2)
3342 WinSetWindowText(hwndStatus2, GetPString(IDS_DRAGARCMEMTEXT));
3343 if (DoFileDrag(hwnd,
3344 dcd->hwndObject,
3345 mp2, dcd->arcname, NULL, TRUE)) {
[672]3346 if ((fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite)
3347 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
[551]3348 }
3349 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
3350 fSplitStatus && hwndStatus2) {
3351 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
3352 }
3353 }
3354 else {
3355 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
3356 fSplitStatus && hwndStatus2)
3357 WinSetWindowText(hwndStatus2,
3358 GetPString(IDS_DRAGARCFILETEXT));
3359 DragOne(hwnd, dcd->hwndObject, dcd->arcname, FALSE);
3360 if (!ParentIsDesktop(hwnd, dcd->hwndParent) &&
3361 fSplitStatus && hwndStatus2)
3362 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
3363 }
3364 }
3365 }
3366 return 0;
[2]3367
[551]3368 case CN_DROP:
3369 if (mp2) {
[2]3370
[551]3371 LISTINFO *li;
[2]3372
[551]3373 DosBeep(500, 100); // fixme to know why beep?
3374 li = DoFileDrop(hwnd, dcd->arcname, FALSE, mp1, mp2);
[762]3375 DosBeep(50, 100); // fixme to know why beep?
3376 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
[551]3377 if (li) {
[562]3378 li->type = li->type == DO_MOVE ? IDM_ARCHIVEM : IDM_ARCHIVE;
[551]3379 strcpy(li->targetpath, dcd->arcname);
3380 if (!li->list ||
3381 !li->list[0] ||
3382 !PostMsg(dcd->hwndObject, UM_ACTION, MPFROMP(li), MPVOID))
3383 FreeListInfo(li);
3384 }
3385 }
3386 return 0;
[2]3387
[551]3388 case CN_CONTEXTMENU:
3389 {
3390 PARCITEM pci = (PARCITEM) mp2;
[2]3391
[551]3392 if (pci) {
3393 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
3394 MPFROM2SHORT(TRUE, CRA_CURSORED));
3395 MarkAll(hwnd, FALSE, FALSE, TRUE);
[872]3396 dcd->hwndLastMenu = CheckMenu(hwnd, &ArcMenu, ARC_POPUP);
[551]3397 }
3398 else {
[872]3399 dcd->hwndLastMenu = CheckMenu(hwnd, &ArcCnrMenu, ARCCNR_POPUP);
[551]3400 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
3401 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
3402 MPFROM2SHORT(TRUE, CRA_SOURCE));
3403 dcd->cnremphasized = TRUE;
3404 }
3405 }
3406 if (dcd->hwndLastMenu) {
3407 if (dcd->hwndLastMenu == ArcCnrMenu) {
3408 if (dcd->flWindowAttr & CV_MINI)
3409 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
3410 }
3411 WinCheckMenuItem(dcd->hwndLastMenu, IDM_FOLDERAFTEREXTRACT,
3412 fFolderAfterExtract);
3413 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
3414 if (dcd->cnremphasized) {
3415 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
3416 MPFROM2SHORT(FALSE, CRA_SOURCE));
3417 dcd->cnremphasized = TRUE;
3418 }
3419 MarkAll(hwnd, TRUE, FALSE, TRUE);
3420 }
3421 }
3422 }
3423 break;
[2]3424
[551]3425 case CN_EMPHASIS:
3426 if (mp2) {
[2]3427
[551]3428 PNOTIFYRECORDEMPHASIS pre = mp2;
3429 PARCITEM pci;
3430 CHAR s[CCHMAXPATHCOMP + 91], tf[81], tb[81];
[2]3431
[562]3432 pci = (PARCITEM)(pre ? pre->pRecord : NULL);
[551]3433 if (!pci) {
3434 if (!ParentIsDesktop(hwnd, dcd->hwndParent)) {
3435 if (hwndStatus2)
3436 WinSetWindowText(hwndStatus2, NullStr);
3437 if (fMoreButtons)
3438 WinSetWindowText(hwndName, NullStr);
3439 }
3440 break;
3441 }
3442 if (pre->fEmphasisMask & CRA_SELECTED) {
3443 if (pci->rc.flRecordAttr & CRA_SELECTED) {
3444 dcd->selectedbytes += pci->cbFile;
3445 dcd->selectedfiles++;
3446 }
3447 else if (dcd->selectedfiles) {
3448 dcd->selectedbytes -= pci->cbFile;
3449 dcd->selectedfiles--;
3450 }
3451 commafmt(tf, sizeof(tf), dcd->selectedfiles);
3452 if (dcd->ullTotalBytes)
3453 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, ' ');
3454 else
3455 *tb = 0;
3456 sprintf(s, "%s%s%s", tf, *tb ? " / " : NullStr, tb);
3457 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
3458 }
3459 else if (WinQueryActiveWindow(dcd->hwndParent) ==
3460 dcd->hwndFrame &&
3461 !ParentIsDesktop(hwnd, dcd->hwndParent)) {
3462 if (pre->fEmphasisMask & CRA_CURSORED) {
3463 if (pci->rc.flRecordAttr & CRA_CURSORED) {
3464 if (fSplitStatus && hwndStatus2) {
3465 if (dcd->ullTotalBytes)
3466 CommaFmtULL(tb, sizeof(tb), pci->cbFile, ' ');
3467 else
3468 *tb = 0;
3469 sprintf(s, "%s%s%s%s",
3470 *tb ? " " : NullStr,
[730]3471 tb, *tb ? " " : NullStr, pci->pszFileName);
[551]3472 WinSetWindowText(hwndStatus2, s);
3473 }
3474 if (fMoreButtons)
[730]3475 WinSetWindowText(hwndName, pci->pszFileName);
[551]3476 }
3477 }
3478 }
3479 }
3480 break;
[2]3481
[551]3482 case CN_ENTER:
3483 if (mp2) {
[2]3484
[551]3485 PARCITEM pci = (PARCITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
[2]3486
[551]3487 if (pci) {
[2]3488
[551]3489 CHAR *s;
[2]3490
[551]3491 if ((pci->rc.flRecordAttr & CRA_INUSE) ||
3492 (pci->flags & (ARCFLAGS_REALDIR | ARCFLAGS_PSEUDODIR)))
3493 break;
[730]3494 s = xstrdup(pci->pszFileName, pszSrcFile, __LINE__);
[551]3495 if (s) {
3496 if (!PostMsg(dcd->hwndObject, UM_ENTER, MPFROMP(s), MPVOID)) {
3497 Runtime_Error(pszSrcFile, __LINE__, "post");
[1039]3498 free(s);
[551]3499 }
3500 }
3501 }
3502 }
3503 break;
[2]3504 }
[551]3505 }
3506 return 0;
[2]3507
[551]3508 case UM_FOLDUP:
3509 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
3510 DosExit(EXIT_PROCESS, 1);
3511 return 0;
[2]3512
[551]3513 case UM_CLOSE:
3514 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
3515 QW_PARENT));
3516 return 0;
[2]3517
[551]3518 case WM_SAVEAPPLICATION:
3519 if (dcd && ParentIsDesktop(hwnd, dcd->hwndParent)) {
3520 SWP swp;
[2]3521
[551]3522 WinQueryWindowPos(dcd->hwndFrame, &swp);
3523 if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE | SWP_MAXIMIZE)))
3524 PrfWriteProfileData(fmprof, appname, "AV2SizePos", &swp, sizeof(swp));
3525 }
3526 break;
[2]3527
[551]3528 case WM_CLOSE:
3529 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
3530 if (dcd)
3531 dcd->stopflag++;
3532 if (dcd && dcd->hwndObject) {
3533 if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
3534 WinSendMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID);
3535 }
3536 // In case object window frees dcd
3537 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
3538 if (!dcd ||
3539 (!dcd->dontclose &&
3540 !dcd->amextracted && ParentIsDesktop(hwnd, dcd->hwndParent))) {
3541 if (!PostMsg(hwnd, UM_FOLDUP, MPVOID, MPVOID))
3542 WinSendMsg(hwnd, UM_FOLDUP, MPVOID, MPVOID);
3543 }
3544 return 0;
3545
3546 case WM_DESTROY:
3547 if (ArcMenu)
3548 WinDestroyWindow(ArcMenu);
3549 if (ArcCnrMenu)
3550 WinDestroyWindow(ArcCnrMenu);
3551 ArcMenu = ArcCnrMenu = (HWND) 0;
[751]3552 EmptyArcCnr(hwnd);
[1120]3553# ifdef FORTIFY
3554 Fortify_LeaveScope();
3555# endif
[551]3556 break;
[2]3557 }
[705]3558 if (dcd && dcd->oldproc){
3559 return dcd->oldproc(hwnd, msg, mp1, mp2);
3560 }
3561 else
3562 return PFNWPCnr(hwnd, msg, mp1, mp2);
[2]3563}
3564
[942]3565MRESULT EXPENTRY ArcCnrMenuProc(HWND hwnd, ULONG msg, MPARAM mp1,
3566 MPARAM mp2)
3567{
3568 PFNWP oldMenuProc = WinQueryWindowPtr(hwnd, QWL_USER);
3569 static short sLastMenuitem;
3570
3571 switch (msg) {
3572 case WM_MOUSEMOVE: {
3573 if (fOtherHelp) {
[953]3574 RECTL rectl;
3575 SHORT i, sCurrentMenuitem;
3576 SHORT MenuItems = 10;
3577 SHORT asMenuIDs[10] = {IDM_VIEW,
3578 IDM_DELETE,
3579 IDM_EXEC,
3580 IDM_EXTRACT,
3581 IDM_TEST,
3582 IDM_VIRUSSCAN,
3583 IDM_RESCAN,
3584 IDM_WALKDIR,
3585 IDM_FILTER,
3586 0};
[1394]3587 PCSZ szHelpString = NULL;
[942]3588
3589
[953]3590 for (i=0; i<MenuItems; i++) {
3591 sCurrentMenuitem = asMenuIDs[i];
3592 oldMenuProc(hwnd,MM_QUERYITEMRECT,
3593 MPFROM2SHORT(asMenuIDs[i], FALSE),
3594 &rectl);
[942]3595
[953]3596 if (MOUSEMSG(&msg)->x > rectl.xLeft &&
3597 MOUSEMSG(&msg)->x < rectl.xRight &&
3598 MOUSEMSG(&msg)->y > rectl.yBottom &&
3599 MOUSEMSG(&msg)->y < rectl.yTop)
3600 break;
3601 } // for
[942]3602
3603
[953]3604 switch (sCurrentMenuitem) {
3605 case 0:
3606 break;
3607 case IDM_VIEW:
3608 szHelpString = GetPString(IDS_ARCCNRVIEWMENUHELP);
3609 break;
3610 case IDM_DELETE:
3611 szHelpString = GetPString(IDS_ARCCNRDELETEMENUHELP);
3612 break;
3613 case IDM_EXEC:
3614 szHelpString = GetPString(IDS_ARCCNREXECMENUHELP);
3615 break;
3616 case IDM_EXTRACT:
3617 szHelpString = GetPString(IDS_ARCCNREXTRACTMENUHELP);
3618 break;
3619 case IDM_TEST:
3620 szHelpString = GetPString(IDS_ARCCNRTESTMENUHELP);
3621 break;
3622 case IDM_VIRUSSCAN:
3623 szHelpString = GetPString(IDS_ARCCNRVIRUSMENUHELP);
3624 break;
3625 case IDM_RESCAN:
3626 szHelpString = GetPString(IDS_ARCCNRRESCANMENUHELP);
3627 break;
3628 case IDM_WALKDIR:
3629 szHelpString = GetPString(IDS_ARCCNRWALKDIRMENUHELP);
3630 break;
3631 case IDM_FILTER:
3632 szHelpString = GetPString(IDS_ARCCNRFILTERMENUHELP);
3633 break;
3634 default:
3635 break;
3636 }
[942]3637
[953]3638 if (sLastMenuitem != sCurrentMenuitem && szHelpString) {
3639 sLastMenuitem = sCurrentMenuitem;
3640 MakeBubble(hwnd, TRUE, szHelpString);
3641 }
3642 else if (hwndBubble && !sCurrentMenuitem){
3643 sLastMenuitem = sCurrentMenuitem;
3644 WinDestroyWindow(hwndBubble);
3645 }
[942]3646 }
3647 }
3648 }
3649 return oldMenuProc(hwnd, msg, mp1, mp2);
3650}
3651
[551]3652HWND StartArcCnr(HWND hwndParent, HWND hwndCaller, CHAR * arcname, INT flags,
3653 ARC_TYPE * sinfo)
[212]3654{
[2]3655 /*
3656 * bitmapped flags:
3657 * 1 = am extracted from another archive
3658 * 4 = don't kill proc on close
3659 */
3660
[551]3661 HWND hwndFrame = (HWND) 0, hwndClient;
3662 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
3663 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
3664 USHORT id;
3665 DIRCNRDATA *dcd;
3666 ARC_TYPE *info = sinfo;
3667 CHAR title[MAXNAMEL + 1] = "AV/2 - ";
3668 CHAR fullname[CCHMAXPATH + 8], *p, temp;
[2]3669 static USHORT idinc = 0;
3670
[423]3671 if (!idinc)
[2]3672 idinc = (rand() % 256);
[551]3673 if (ParentIsDesktop(hwndParent, hwndParent))
[2]3674 FrameFlags |= (FCF_TASKLIST | FCF_MENU);
[423]3675 if (arcname) {
[2]3676 DosError(FERR_DISABLEHARDERR);
[423]3677 if (DosQueryPathInfo(arcname,
[551]3678 FIL_QUERYFULLNAME, fullname, sizeof(fullname)))
3679 strcpy(fullname, arcname);
[2]3680 p = fullname;
[551]3681 while (*p) {
[423]3682 if (*p == '/')
[551]3683 *p = '\\';
[2]3684 p++;
3685 }
[423]3686 if (!info)
[551]3687 info = find_type(fullname, arcsighead);
[423]3688 if (!info)
[2]3689 return hwndFrame;
[551]3690 if (strlen(title) + strlen(fullname) > MAXNAMEL) {
3691 p = title + strlen(title);
3692 strncpy(p, fullname, MAXNAMEL / 2 - 5);
3693 strcpy(p + MAXNAMEL / 2 - 5, "...");
3694 strcat(title, fullname + strlen(fullname) - (MAXNAMEL / 2 - 5));
[460]3695 }
[551]3696 else {
3697 strcat(title, fullname);
[460]3698 }
[2]3699 hwndFrame = WinCreateStdWindow(hwndParent,
[551]3700 WS_VISIBLE,
3701 &FrameFlags,
[593]3702 WC_ARCCONTAINER,
[551]3703 title,
3704 WS_VISIBLE | fwsAnimate,
3705 FM3ModHandle, ARC_FRAME, &hwndClient);
[423]3706 if (hwndFrame && hwndClient) {
[2]3707 id = ARC_FRAME + idinc++;
[423]3708 if (idinc > 512)
[551]3709 idinc = 0;
3710 WinSetWindowUShort(hwndFrame, QWS_ID, id);
[1063]3711# ifdef FORTIFY
3712 Fortify_EnterScope();
[1077]3713# endif
[551]3714 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
[358]3715 if (!dcd) {
[551]3716 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
3717 hwndFrame = (HWND) 0;
[358]3718 }
3719 else {
[1321]3720# ifdef FORTIFY
3721 // Will be freed by WM_DESTROY
3722 Fortify_ChangeScope(dcd, -1);
3723# endif
[551]3724 dcd->size = sizeof(DIRCNRDATA);
3725 dcd->id = id;
3726 dcd->type = ARC_FRAME;
[1082]3727 if (!pTmpDir)
[1321]3728 strcpy(dcd->workdir, pFM2SaveDirectory);
3729 MakeTempName(dcd->workdir, ArcTempRoot, 2);
3730#if 0 // 06 Sep 08 SHL fixme to be gone
3731 if (dcd->workdir[strlen(dcd->workdir) - 1] != '\\')
[1077]3732 strcat(dcd->workdir, "\\");
3733 sprintf(dcd->workdir + strlen(dcd->workdir), "%s.%03x",
3734 ArcTempRoot, (clock() & 4095));
3735 else
3736 sprintf(dcd->workdir, "%s.%03x",
[1321]3737 ArcTempRoot, (clock() & 4095));
3738#endif // 06 Sep 08 SHL fixme to be gone
[551]3739 strcpy(dcd->arcname, fullname);
3740 if (*extractpath) {
3741 if (!strcmp(extractpath, "*")) {
3742 p = strrchr(fullname, '\\');
3743 if (p) {
3744 if (p < fullname + 3)
3745 p++;
3746 temp = *p;
3747 *p = 0;
3748 strcpy(dcd->directory, fullname);
3749 *p = temp;
3750 }
3751 }
3752 else
3753 strcpy(dcd->directory, extractpath);
[1335]3754 }
3755 if (!*dcd->directory && fFileNameCnrPath && dcd->arcname) {
3756 strcpy(fullname, dcd->arcname);
3757 p = strrchr(fullname, '.');
3758 if (p)
3759 *p = 0;
3760 else {
3761 p = fullname + strlen(fullname);
3762 p--;
3763 *p = 0;
3764 }
3765 strcpy(dcd->directory, fullname);
3766 }
[551]3767 if (!*dcd->directory && *lastextractpath) {
[1335]3768 //DosEnterCritSec(); //GKY 11-29-08
3769 DosRequestMutexSem(hmtxFM2Globals, SEM_INDEFINITE_WAIT);
3770 strcpy(dcd->directory, lastextractpath);
3771 DosReleaseMutexSem(hmtxFM2Globals);
[1301]3772 //DosExitCritSec();
[551]3773 }
3774 if (!*dcd->directory) {
3775 if (!ParentIsDesktop(hwndParent, hwndParent))
3776 TopWindowName(hwndParent, hwndCaller, dcd->directory);
3777 if (!*dcd->directory) {
3778 p = strrchr(fullname, '\\');
3779 if (p) {
3780 if (p < fullname + 3)
3781 p++;
3782 *p = 0;
3783 strcpy(dcd->directory, fullname);
3784 }
3785 }
3786 }
3787 if (!*dcd->directory ||
[1307]3788 (IsFile(dcd->directory) == 1) ||
[551]3789 (isalpha(*dcd->directory) &&
3790 (driveflags[toupper(*dcd->directory) - 'A'] &
3791 DRIVE_NOTWRITEABLE)))
[1104]3792 strcpy(dcd->directory, pFM2SaveDirectory);
[562]3793 dcd->hwndParent = hwndParent ? hwndParent : HWND_DESKTOP;
[551]3794 dcd->hwndFrame = hwndFrame;
3795 dcd->hwndClient = hwndClient;
[562]3796 dcd->amextracted = (flags & 1) != 0;
3797 dcd->dontclose = (flags & 4) != 0;
[551]3798 dcd->info = info;
[1335]3799 dcd->sortFlags = DefArcSortFlags;
[551]3800 {
3801 PFNWP oldproc;
[2]3802
[551]3803 oldproc = WinSubclassWindow(hwndFrame, (PFNWP) ArcFrameWndProc);
3804 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
[358]3805 }
[551]3806 dcd->hwndCnr = WinCreateWindow(hwndClient,
3807 WC_CONTAINER,
3808 NULL,
3809 CCS_AUTOPOSITION | CCS_MINIICONS |
3810 CCS_MINIRECORDCORE | ulCnrType |
3811 WS_VISIBLE,
3812 0,
3813 0,
3814 0,
3815 0,
3816 hwndClient,
3817 HWND_TOP, (ULONG) ARC_CNR, NULL, NULL);
3818 if (!dcd->hwndCnr) {
3819 Win_Error2(hwndClient, hwndClient, pszSrcFile, __LINE__,
3820 IDS_WINCREATEWINDOW);
3821 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
[1077]3822 free(dcd);
[551]3823 hwndFrame = (HWND) 0;
3824 }
[358]3825 else {
[551]3826 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
3827 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
3828 (PFNWP) ArcCnrWndProc);
3829 {
3830 USHORT ids[] = { DIR_TOTALS, DIR_SELECTED, DIR_VIEW, DIR_SORT,
3831 DIR_FILTER, DIR_FOLDERICON, 0
3832 };
[2]3833
[551]3834 CommonCreateTextChildren(dcd->hwndClient,
[593]3835 WC_ARCSTATUS, ids);
[551]3836 }
3837 WinEnableWindow(WinWindowFromID(dcd->hwndClient, DIR_VIEW), FALSE);
3838 dcd->hwndExtract = WinCreateWindow(dcd->hwndClient,
3839 WC_ENTRYFIELD,
3840 NULL,
3841 ES_AUTOSCROLL,
3842 0,
3843 0,
3844 0,
3845 0,
3846 dcd->hwndClient,
3847 HWND_TOP,
3848 ARC_EXTRACTDIR, NULL, NULL);
3849 WinSendMsg(dcd->hwndExtract,
3850 EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
3851 WinSetWindowText(dcd->hwndExtract, dcd->directory);
3852 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
3853 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
[953]3854 if (FrameFlags & FCF_MENU) {
3855 PFNWP oldmenuproc;
3856 HWND hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
[942]3857
3858 oldmenuproc = WinSubclassWindow(hwndMenu, (PFNWP) ArcCnrMenuProc);
3859 WinSetWindowPtr(hwndMenu, QWL_USER, (PVOID) oldmenuproc);
[551]3860 if (!fToolbar) {
[2]3861
[551]3862 if (hwndMenu) {
3863 WinSendMsg(hwndMenu, MM_DELETEITEM,
3864 MPFROM2SHORT(IDM_VIEW, FALSE), MPVOID);
3865 WinSendMsg(hwndMenu, MM_DELETEITEM,
3866 MPFROM2SHORT(IDM_EXEC, FALSE), MPVOID);
3867 WinSendMsg(hwndMenu, MM_DELETEITEM,
3868 MPFROM2SHORT(IDM_RESCAN, FALSE), MPVOID);
3869 WinSendMsg(hwndMenu, MM_DELETEITEM,
3870 MPFROM2SHORT(IDM_DELETE, FALSE), MPVOID);
3871 WinSendMsg(hwndMenu, MM_DELETEITEM,
3872 MPFROM2SHORT(IDM_EXTRACT, FALSE), MPVOID);
3873 WinSendMsg(hwndMenu, MM_DELETEITEM,
3874 MPFROM2SHORT(IDM_TEST, FALSE), MPVOID);
3875 WinSendMsg(hwndMenu, MM_DELETEITEM,
3876 MPFROM2SHORT(IDM_VIRUSSCAN, FALSE), MPVOID);
3877 WinSendMsg(hwndMenu, MM_DELETEITEM,
3878 MPFROM2SHORT(IDM_WALKDIR, FALSE), MPVOID);
3879 WinSendMsg(hwndMenu, MM_DELETEITEM,
3880 MPFROM2SHORT(IDM_FILTER, FALSE), MPVOID);
3881 }
3882 }
3883 }
3884 if (FrameFlags & FCF_TASKLIST) {
[2]3885
[551]3886 SWP swp, swpD;
3887 ULONG size = sizeof(swp);
3888 LONG cxScreen, cyScreen;
[2]3889
[551]3890 WinQueryTaskSizePos(WinQueryAnchorBlock(hwndFrame), 0, &swp);
3891 if (PrfQueryProfileData(fmprof,
3892 appname, "AV2SizePos", &swpD, &size)) {
3893 cxScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
3894 cyScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
3895 if (swp.x + swpD.cx > cxScreen)
3896 swp.x = cxScreen - swpD.cx;
3897 if (swp.y + swpD.cy > cyScreen)
3898 swp.y = cyScreen - swpD.cy;
3899 swp.cx = swpD.cx;
3900 swp.cy = swpD.cy;
3901 }
3902 WinSetWindowPos(hwndFrame,
3903 HWND_TOP,
3904 swp.x,
3905 swp.y,
3906 swp.cx,
3907 swp.cy,
3908 SWP_SIZE | SWP_MOVE | SWP_SHOW | SWP_ZORDER |
3909 SWP_ACTIVATE);
3910 }
[1335]3911 }
[2]3912 }
[1077]3913# ifdef FORTIFY
3914 Fortify_LeaveScope();
3915# endif
[2]3916 }
3917 }
3918 return hwndFrame;
3919}
[793]3920
3921#pragma alloc_text(ARCCNRS,ArcCnrWndProc,ArcObjWndProc,ArcClientWndProc,BldQuotedFullPathName)
3922#pragma alloc_text(ARCCNRS,ArcTextProc,FillArcCnr,ArcFilter,BldQuotedFileName)
3923#pragma alloc_text(ARCCNRS,ArcSort,ArcFrameWndProc,IsArcThere,ArcErrProc)
3924#pragma alloc_text(STARTUP,StartArcCnr)
Note: See TracBrowser for help on using the repository browser.