source: trunk/dll/arccnrs.c@ 1329

Last change on this file since 1329 was 1329, checked in by Gregg Young, 17 years ago

Fix for editor opening empty on larger text files.

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