source: trunk/dll/arccnrs.c@ 1311

Last change on this file since 1311 was 1311, checked in by John Small, 17 years ago

Ticket 284: Changed the no-start/end-of-list string to "None" and updated the documentation.

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