source: trunk/dll/arccnrs.c@ 1337

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

Ticket 26: Add exception handlers to all threads using xbeginthread

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