source: trunk/dll/arccnrs.c@ 1402

Last change on this file since 1402 was 1402, checked in by Gregg Young, 16 years ago

Remove variable aurgs from docopy & unlinkf (not used); Move more strings to PCSZs and string table; Move PCSZs to compile time initialization; Fix hang on startup caused by a drive scan and a dircnr scan trying to update a drive in the tree at the same time (related to the "treeswitch options); Code cleanup mainly removal of old printfs, SayMsgs, DbgMsg and unneeded %s.

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