source: trunk/dll/arccnrs.c@ 1755

Last change on this file since 1755 was 1755, checked in by Gregg Young, 11 years ago

Comments for CS [1753]

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