source: trunk/dll/collect.c@ 985

Last change on this file since 985 was 985, checked in by Gregg Young, 18 years ago

Update sizes dialog (ticket 44); Make max command line length user settable (ticket 199); use xfree for free in most cases (ticket 212); initial code to check for valid ini file (ticket 102); Some additional refactoring and structure rework; Some documentation updates;

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 75.8 KB
Line 
1
2/***********************************************************************
3
4 $Id: collect.c 985 2008-03-01 01:37:14Z gyoung $
5
6 Collector
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2003, 2008 Steven H. Levine
10
11 15 Oct 02 MK Baseline
12 10 Jan 04 SHL Avoid -1L byte counts
13 01 Aug 04 SHL Rework lstrip/rstrip usage
14 23 May 05 SHL Use QWL_USER
15 24 May 05 SHL Rework Win_Error usage
16 25 May 05 SHL Use ULONGLONG and CommaFmtULL
17 25 May 05 SHL Rework for FillInRecordFromFFB
18 05 Jun 05 SHL Use QWL_USER
19 06 Jun 05 SHL Indent -i2
20 06 Jun 05 SHL Make savedSortFlags static to avoid referencing garbage
21 24 Oct 05 SHL Sanitize handle references
22 24 Oct 05 SHL CollectorCnrWndProc: avoid excess writes to Status2 window
23 10 Nov 05 SHL CollectorCnrWndProc: correct missing button window updates
24 14 Jul 06 SHL Use Runtime_Error
25 27 Jul 06 SHL Avoid shutdown hang - pre3 typo
26 29 Jul 06 SHL Use xfgets_bstripcr
27 15 Aug 06 SHL Don't write garbage to CollectorFilter INI entry
28 15 Aug 06 SHL Rework SetMask args
29 18 Aug 06 SHL CollectorCnrWndProc: avoid freeing NULL pointer
30 31 Aug 06 SHL Disable Utilities->Seek and scan menu while busy
31 31 Aug 06 SHL Correct stop scan context menu enable/disable
32 30 Mar 07 GKY Remove GetPString for window class names
33 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits
34 06 Apr 07 GKY Add some error checking in drag/drop
35 19 Apr 07 SHL Use FreeDragInfoData. Add more drag/drop error checks.
36 12 May 07 SHL Use dcd->ulItemsToUnHilite
37 10 Jun 07 GKY Add CheckPmDrgLimit including IsFm2Window as part of work around PM drag limit
38 05 Jul 07 SHL CollectorCnrWndProc: just warn if busy
39 02 Aug 07 SHL Sync with CNRITEM mods
40 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
41 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
42 26 Aug 07 GKY DosSleep(1) in loops changed to (0)
43 22 Nov 07 GKY Use CopyPresParams to fix presparam inconsistencies in menus
44 10 Jan 08 SHL Sync with CfgDlgProc mods
45 10 Feb 08 GKY Implement bubble help for bitmap menu items
46 15 Feb 08 SHL Sync with settings menu rework
47 15 Feb 08 GKY Fix attempt to free container items that were never inserted
48 15 Feb 08 GKY Fix "collect" so it updates recollected files and unhides them if needed
49 29 Feb 08 GKY Use xfree where appropriate
50
51***********************************************************************/
52
53#include <stdlib.h>
54#include <string.h>
55#include <ctype.h>
56#include <share.h>
57#include <limits.h>
58#include <process.h> // _beginthread
59
60#define INCL_DOS // QSV_MS_COUNT
61#define INCL_WIN
62#define INCL_DOSERRORS
63#define INCL_LONGLONG
64
65#include "fm3dlg.h"
66#include "fm3str.h"
67#include "mle.h"
68#include "grep.h"
69#include "comp.h"
70#include "arccnrs.h" // StartArcCnr
71#include "filldir.h" // EmptyCnr...
72#include "strutil.h" // GetPString
73#include "errutil.h" // Runtime_Error
74#include "tmrsvcs.h" // ITIMER_DESC
75#include "notebook.h" // CfgDlgProc
76#include "fm3dll.h"
77
78#pragma data_seg(DATA1)
79
80static PSZ pszSrcFile = __FILE__;
81
82MRESULT EXPENTRY CollectorFrameWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
83 MPARAM mp2)
84{
85 return CommonFrameWndProc(COLLECTOR_CNR, hwnd, msg, mp1, mp2);
86}
87
88MRESULT EXPENTRY CollectorTextProc(HWND hwnd, ULONG msg, MPARAM mp1,
89 MPARAM mp2)
90{
91 DIRCNRDATA *dcd;
92
93 static BOOL emphasized = FALSE;
94 static HWND hwndButtonPopup = (HWND) 0;
95 static ULONG timestamp = ULONG_MAX;
96 static USHORT lastid = 0;
97
98 switch (msg) {
99 case WM_CREATE:
100 return CommonTextProc(hwnd, msg, mp1, mp2);
101
102 case UM_CONTEXTMENU:
103 case WM_CONTEXTMENU:
104 {
105 USHORT id;
106
107 id = WinQueryWindowUShort(hwnd, QWS_ID);
108 switch (id) {
109 case DIR_SELECTED:
110 case DIR_VIEW:
111 case DIR_SORT:
112 {
113 POINTL ptl = { 0, 0 };
114 SWP swp;
115
116 if (hwndButtonPopup)
117 WinDestroyWindow(hwndButtonPopup);
118 if (id == lastid) {
119 ULONG check;
120
121 DosQuerySysInfo(QSV_MS_COUNT,
122 QSV_MS_COUNT, &check, sizeof(check));
123 if (check < timestamp + 500) {
124 lastid = 0;
125 goto MenuAbort;
126 }
127 }
128 hwndButtonPopup = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
129 if (hwndButtonPopup) {
130 WinSetWindowUShort(hwndButtonPopup, QWS_ID, id);
131 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
132 QW_PARENT),
133 COLLECTOR_CNR), QWL_USER);
134 if (id == DIR_VIEW) {
135 if (dcd) {
136 SetViewMenu(hwndButtonPopup, dcd->flWindowAttr);
137 SetDetailsSwitches(hwndButtonPopup, dcd);
138 CopyPresParams(hwndButtonPopup, hwnd);
139 }
140
141 /* don't have tree view in collector */
142 WinSendMsg(hwndButtonPopup,
143 MM_DELETEITEM,
144 MPFROM2SHORT(IDM_TREEVIEW, FALSE), MPVOID);
145
146 }
147 else if (id == DIR_SORT) {
148 if (dcd)
149 SetSortChecks(hwndButtonPopup, dcd->sortFlags);
150 }
151 ptl.x = 0;
152 if (WinPopupMenu(HWND_OBJECT,
153 HWND_OBJECT,
154 hwndButtonPopup, -32767, -32767, 0, 0)) {
155 WinQueryWindowPos(hwndButtonPopup, &swp);
156 ptl.y = -(swp.cy + 2);
157 }
158 else {
159 WinQueryWindowPos(hwnd, &swp);
160 ptl.y = swp.cy + 2;
161 }
162 if (WinPopupMenu(hwnd,
163 hwnd,
164 hwndButtonPopup,
165 ptl.x,
166 ptl.y,
167 0,
168 PU_HCONSTRAIN | PU_VCONSTRAIN |
169 PU_KEYBOARD | PU_MOUSEBUTTON1)) {
170 CenterOverWindow(hwndButtonPopup);
171 PaintRecessedWindow(hwnd, NULLHANDLE, FALSE, FALSE);
172 }
173 }
174 }
175 break;
176 default:
177 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
178 COLLECTOR_CNR),
179 WM_CONTROL,
180 MPFROM2SHORT(COLLECTOR_CNR, CN_CONTEXTMENU), MPVOID);
181 break;
182 }
183 }
184 MenuAbort:
185 if (msg == UM_CONTEXTMENU)
186 return 0;
187 break;
188
189 case WM_MENUEND:
190 if (hwndButtonPopup == (HWND) mp2) {
191 lastid = WinQueryWindowUShort((HWND) mp2, QWS_ID);
192 WinDestroyWindow(hwndButtonPopup);
193 hwndButtonPopup = (HWND) 0;
194 DosQuerySysInfo(QSV_MS_COUNT, QSV_MS_COUNT, &timestamp,
195 sizeof(timestamp));
196 switch (lastid) {
197 case DIR_SELECTED:
198 case DIR_VIEW:
199 case DIR_SORT:
200 PaintRecessedWindow(hwnd, NULLHANDLE, TRUE, FALSE);
201 break;
202 }
203 }
204 break;
205
206 case WM_COMMAND:
207 {
208 DIRCNRDATA *dcd;
209 MRESULT mr;
210
211 mr = WinSendMsg(WinWindowFromID(WinQueryWindow(hwnd,
212 QW_PARENT),
213 COLLECTOR_CNR), msg, mp1, mp2);
214 if (hwndButtonPopup &&
215 SHORT1FROMMP(mp1) > IDM_DETAILSTITLES &&
216 SHORT1FROMMP(mp1) < IDM_DETAILSSETUP) {
217 dcd = WinQueryWindowPtr(WinWindowFromID(WinQueryWindow(hwnd,
218 QW_PARENT),
219 COLLECTOR_CNR), QWL_USER);
220 if (dcd)
221 SetDetailsSwitches(hwndButtonPopup, dcd);
222 }
223 return mr;
224 }
225
226 case WM_MOUSEMOVE:
227 {
228 USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
229 char *s = NULL;
230
231 if (fOtherHelp) {
232 if ((!hwndBubble ||
233 WinQueryWindowULong(hwndBubble, QWL_USER) != hwnd) &&
234 !WinQueryCapture(HWND_DESKTOP)) {
235 switch (id) {
236 case DIR_SELECTED:
237 s = GetPString(IDS_COLSELECTEDHELP);
238 break;
239 case DIR_TOTALS:
240 s = GetPString(IDS_COLTOTALSHELP);
241 break;
242 case DIR_VIEW:
243 s = GetPString(IDS_DIRCNRVIEWHELP);
244 break;
245 case DIR_SORT:
246 s = GetPString(IDS_DIRCNRSORTHELP);
247 break;
248 case DIR_FILTER:
249 s = GetPString(IDS_DIRCNRFILTERHELP);
250 break;
251 default:
252 break;
253 }
254 if (s)
255 MakeBubble(hwnd, TRUE, s);
256 else if (hwndBubble)
257 WinDestroyWindow(hwndBubble);
258 }
259 }
260 switch (id) {
261 case DIR_FILTER:
262 case DIR_SORT:
263 case DIR_VIEW:
264 case DIR_SELECTED:
265 return CommonTextButton(hwnd, msg, mp1, mp2);
266 }
267 }
268 break;
269
270 case WM_BUTTON3UP:
271 case WM_BUTTON1UP:
272 case WM_BUTTON3DOWN:
273 case WM_BUTTON1DOWN:
274 {
275 USHORT id;
276
277 id = WinQueryWindowUShort(hwnd, QWS_ID);
278 switch (id) {
279 case DIR_FILTER:
280 case DIR_SORT:
281 case DIR_VIEW:
282 case DIR_SELECTED:
283 return CommonTextButton(hwnd, msg, mp1, mp2);
284 }
285 }
286 break;
287
288 case UM_CLICKED:
289 case UM_CLICKED3:
290 {
291 USHORT id, cmd = 0;
292
293 id = WinQueryWindowUShort(hwnd, QWS_ID);
294 switch (id) {
295 case DIR_VIEW:
296 case DIR_SORT:
297 case DIR_SELECTED:
298 PostMsg(hwnd, UM_CONTEXTMENU, MPVOID, MPVOID);
299 break;
300 case DIR_FILTER:
301 cmd = IDM_FILTER;
302 break;
303 default:
304 break;
305 }
306 if (cmd)
307 PostMsg(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
308 COLLECTOR_CNR),
309 WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
310 }
311 return 0;
312
313 case DM_DROP:
314 case DM_DRAGOVER:
315 case DM_DRAGLEAVE:
316 case DM_DROPHELP:
317 if (msg == DM_DRAGOVER) {
318 if (!emphasized) {
319 emphasized = TRUE;
320 DrawTargetEmphasis(hwnd, emphasized);
321 }
322 }
323 else {
324 if (emphasized) {
325 emphasized = FALSE;
326 DrawTargetEmphasis(hwnd, emphasized);
327 }
328 }
329 {
330 CNRDRAGINFO cnd;
331 USHORT dcmd;
332
333 switch (msg) {
334 case DM_DROP:
335 dcmd = CN_DROP;
336 break;
337 case DM_DRAGOVER:
338 dcmd = CN_DRAGOVER;
339 break;
340 case DM_DRAGLEAVE:
341 dcmd = CN_DRAGLEAVE;
342 break;
343 case DM_DROPHELP:
344 dcmd = CN_DROPHELP;
345 break;
346 }
347 memset(&cnd, 0, sizeof(cnd));
348 cnd.pDragInfo = (PDRAGINFO) mp1;
349 cnd.pRecord = NULL;
350 return WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_CONTROL,
351 MPFROM2SHORT(COLLECTOR_CNR, dcmd), MPFROMP(&cnd));
352 }
353 }
354 return PFNWPStatic(hwnd, msg, mp1, mp2);
355}
356
357MRESULT EXPENTRY CollectorClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
358 MPARAM mp2)
359{
360 switch (msg) {
361 case UM_CONTAINERHWND:
362 return MRFROMLONG(WinWindowFromID(hwnd, COLLECTOR_CNR));
363
364 case UM_VIEWSMENU:
365 return MRFROMLONG(CheckMenu(hwnd, &CollectorCnrMenu, COLLECTORCNR_POPUP));
366
367 case MM_PORTHOLEINIT:
368 case WM_INITMENU:
369 case UM_INITMENU:
370 case UM_CONTAINER_FILLED:
371 case UM_FILESMENU:
372 case UM_UPDATERECORD:
373 case UM_UPDATERECORDLIST:
374 return WinSendMsg(WinWindowFromID(hwnd, COLLECTOR_CNR), msg, mp1, mp2);
375
376 case WM_PSETFOCUS:
377 case WM_SETFOCUS:
378 if (mp2)
379 PostMsg(hwnd, UM_FOCUSME, MPVOID, MPVOID);
380 break;
381
382 case UM_FOCUSME:
383 WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, COLLECTOR_CNR));
384 break;
385
386 case WM_PAINT:
387 {
388 HPS hps;
389 RECTL rcl;
390
391 hps = WinBeginPaint(hwnd, NULLHANDLE, NULL);
392 if (hps) {
393 WinQueryWindowRect(hwnd, &rcl);
394 WinFillRect(hps, &rcl, CLR_PALEGRAY);
395 CommonTextPaint(hwnd, hps);
396 WinEndPaint(hps);
397 }
398 }
399 break;
400
401 case UM_SIZE:
402 case WM_SIZE:
403 if (msg == UM_SIZE) {
404 SWP swp;
405
406 WinQueryWindowPos(hwnd, &swp);
407 mp1 = MPFROM2SHORT(swp.cx, swp.cy);
408 mp2 = MPFROM2SHORT(swp.cx, swp.cy);
409 }
410 {
411 USHORT cx, cy, bx;
412
413 cx = SHORT1FROMMP(mp2);
414 cy = SHORT2FROMMP(mp2);
415 WinSetWindowPos(WinWindowFromID(hwnd, COLLECTOR_CNR), HWND_TOP,
416 0, 0, cx, cy - 24, SWP_SHOW | SWP_MOVE | SWP_SIZE);
417 WinSetWindowPos(WinWindowFromID(hwnd, DIR_TOTALS), HWND_TOP,
418 2,
419 cy - 22,
420 (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
421 WinSetWindowPos(WinWindowFromID(hwnd, DIR_SELECTED), HWND_TOP,
422 2 + (cx / 3) + 2,
423 cy - 22,
424 (cx / 3) - 2, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
425 bx = (cx - (2 + (((cx / 3) + 2) * 2))) / 3;
426 WinSetWindowPos(WinWindowFromID(hwnd, DIR_VIEW), HWND_TOP,
427 2 + (((cx / 3) + 2) * 2),
428 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
429 WinSetWindowPos(WinWindowFromID(hwnd, DIR_SORT), HWND_TOP,
430 2 + (((cx / 3) + 2) * 2) + bx,
431 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
432 WinSetWindowPos(WinWindowFromID(hwnd, DIR_FILTER), HWND_TOP,
433 2 + (((cx / 3) + 2) * 2) + (bx * 2),
434 cy - 22, bx - 4, 20, SWP_SHOW | SWP_MOVE | SWP_SIZE);
435 }
436 CommonTextPaint(hwnd, NULLHANDLE);
437 if (msg == UM_SIZE) {
438 WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT), HWND_TOP, 0, 0, 0, 0,
439 SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE);
440 return 0;
441 }
442 break;
443
444 case UM_COMMAND:
445 case WM_COMMAND:
446 case WM_CONTROL:
447 case WM_CLOSE:
448 return WinSendMsg(WinWindowFromID(hwnd, COLLECTOR_CNR), msg, mp1, mp2);
449 }
450 return WinDefWindowProc(hwnd, msg, mp1, mp2);
451}
452
453MRESULT EXPENTRY CollectorObjWndProc(HWND hwnd, ULONG msg,
454 MPARAM mp1, MPARAM mp2)
455{
456 ULONG size;
457 DIRCNRDATA *dcd;
458
459 switch (msg) {
460 case WM_CREATE:
461 break;
462
463 case DM_PRINTOBJECT:
464 return MRFROMLONG(DRR_TARGET);
465
466 case DM_DISCARDOBJECT:
467 dcd = INSTDATA(hwnd);
468 if (fFM2Deletes && dcd) {
469 LISTINFO *li;
470 CNRDRAGINFO cni;
471
472 cni.pRecord = NULL;
473 cni.pDragInfo = (PDRAGINFO) mp1;
474 li = DoFileDrop(dcd->hwndCnr, NULL, FALSE, MPVOID, MPFROMP(&cni));
475 CheckPmDrgLimit(cni.pDragInfo);
476 if (li) {
477 li->type = fDefaultDeletePerm ? IDM_PERMDELETE : IDM_DELETE;
478 if (!PostMsg(hwnd, UM_MASSACTION, MPFROMP(li), MPVOID))
479 FreeListInfo(li);
480 else
481 return MRFROMLONG(DRR_SOURCE);
482 }
483 }
484 return MRFROMLONG(DRR_TARGET);
485
486 case UM_UPDATERECORDLIST:
487 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
488 if (dcd && mp1) {
489 INT numentries = 0;
490 CHAR **list = (CHAR **) mp1;
491
492 while (list[numentries])
493 numentries++;
494 if (numentries)
495 UpdateCnrList(dcd->hwndCnr, list, numentries, FALSE, dcd);
496 }
497 return 0;
498
499 case UM_SETUP:
500 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
501 if (dcd) {
502 /* set unique id */
503 WinSetWindowUShort(hwnd,
504 QWS_ID,
505 COLLECTOROBJ_FRAME + (COLLECTOR_FRAME - dcd->id));
506 dcd->hwndObject = hwnd;
507 // 09 Feb 08 SHL fixme to be sure applet does not really need this
508 // if (ParentIsDesktop(hwnd, dcd->hwndParent))
509 // DosSleep(100); //05 Aug 07 GKY 250
510 }
511 else
512 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
513 return 0;
514
515 case UM_COMMAND:
516 if (mp1) {
517 LISTINFO *li = (LISTINFO *) mp1;
518
519 switch (li->type) {
520 case IDM_DOITYOURSELF:
521 case IDM_APPENDTOCLIP:
522 case IDM_SAVETOCLIP:
523 case IDM_ARCHIVE:
524 case IDM_ARCHIVEM:
525 case IDM_VIEW:
526 case IDM_VIEWTEXT:
527 case IDM_VIEWBINARY:
528 case IDM_VIEWARCHIVE:
529 case IDM_EDIT:
530 case IDM_EDITTEXT:
531 case IDM_EDITBINARY:
532 case IDM_OBJECT:
533 case IDM_SHADOW:
534 case IDM_SHADOW2:
535 case IDM_PRINT:
536 case IDM_ATTRS:
537 case IDM_DELETE:
538 case IDM_PERMDELETE:
539 case IDM_FAKEEXTRACT:
540 case IDM_FAKEEXTRACTM:
541 case IDM_MCIPLAY:
542 case IDM_UPDATE:
543 if (PostMsg(hwnd, UM_MASSACTION, mp1, mp2))
544 return (MRESULT) TRUE;
545 break;
546 default:
547 if (PostMsg(hwnd, UM_ACTION, mp1, mp2))
548 return (MRESULT) TRUE;
549 }
550 }
551 return 0;
552
553 case UM_COLLECT:
554 DosError(FERR_DISABLEHARDERR);
555 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
556 if (dcd) {
557 LISTINFO *li = (LISTINFO *) mp1;
558 INT x;
559 FILEFINDBUF4L fb4;
560 HDIR hdir;
561 ULONG nm;
562 PCNRITEM pci, pciFirst, pciT, pciP = NULL;
563 RECORDINSERT ri;
564 ULONG ulMaxFiles;
565 ULONGLONG ullTotalBytes;
566 CHAR fullname[CCHMAXPATH];
567
568 if (!hwndStatus) {
569 WinSetWindowText(WinWindowFromID(dcd->hwndClient, DIR_SELECTED),
570 GetPString(IDS_COLLECTINGTEXT));
571 }
572 else {
573 if (WinQueryFocus(HWND_DESKTOP) == dcd->hwndCnr)
574 WinSetWindowText(hwndStatus, GetPString(IDS_COLLECTINGTEXT));
575 }
576
577 for (ulMaxFiles = 0; li->list[ulMaxFiles]; ulMaxFiles++) ; // Count
578
579 if (ulMaxFiles) {
580 pci = WinSendMsg(dcd->hwndCnr, CM_ALLOCRECORD,
581 MPFROMLONG(EXTRA_RECORD_BYTES),
582 MPFROMLONG(ulMaxFiles));
583 if (!pci) {
584 Runtime_Error(pszSrcFile, __LINE__, "CM_ALLOCRECORD %u failed",
585 ulMaxFiles);
586 break;
587 }
588 else {
589 ITIMER_DESC itdSleep = { 0 }; // 06 Feb 08 SHL
590 InitITimer(&itdSleep, 500); // Sleep every 500 mSec
591 pciFirst = pci;
592 // 04 Jan 08 SHL fixme like comp.c if CM_ALLOCRECORD returns unexpected record count
593 for (x = 0; li->list[x]; x++) {
594 nm = 1;
595 hdir = HDIR_CREATE;
596 DosError(FERR_DISABLEHARDERR);
597 if (FindCnrRecord(dcd->hwndCnr,
598 li->list[x],
599 NULL,
600 FALSE,
601 FALSE,
602 TRUE)) {
603 pci = UpdateCnrRecord(dcd->hwndCnr, li->list[x], FALSE, dcd);
604 if (Filter((PMINIRECORDCORE) pci, (PVOID) & dcd->mask)) {
605 pci->rc.flRecordAttr &= ~CRA_FILTERED;
606 WinSendMsg(dcd->hwndCnr, CM_INVALIDATERECORD, MPVOID,
607 MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE));
608 }
609 pci = (PCNRITEM) pci->rc.preccNextRecord;
610 if (pciP)
611 pciP->rc.preccNextRecord = (PMINIRECORDCORE) pci;
612 else
613 pciFirst = pci;
614 }
615 else if (*li->list[x] &&
616 !DosQueryPathInfo(li->list[x], FIL_QUERYFULLNAME,
617 fullname, sizeof(fullname)) &&
618 !IsRoot(fullname) &&
619 !xDosFindFirst(fullname,
620 &hdir,
621 FILE_NORMAL | FILE_DIRECTORY |
622 FILE_ARCHIVED | FILE_SYSTEM |
623 FILE_HIDDEN | FILE_READONLY,
624 &fb4, sizeof(fb4), &nm, FIL_QUERYEASIZEL)) {
625 DosFindClose(hdir);
626 priority_normal();
627 *fb4.achName = 0;
628 ullTotalBytes = FillInRecordFromFFB(dcd->hwndCnr,
629 pci,
630 fullname, &fb4, FALSE, dcd);
631 dcd->ullTotalBytes += ullTotalBytes;
632 pciP = pci;
633 pci = (PCNRITEM) pci->rc.preccNextRecord;
634 }
635 else {
636 // Oops - fixme to complain?
637 pciT = pci;
638 pci = (PCNRITEM) pci->rc.preccNextRecord;
639 if (pciP)
640 pciP->rc.preccNextRecord = (PMINIRECORDCORE) pci;
641 else
642 pciFirst = pci;
643 if (pciT)
644 FreeCnrItemData(pciT); // FreeCnrItem(hwnd, pciT);
645 ulMaxFiles--; // Remember gone
646 }
647 SleepIfNeeded(&itdSleep, 1); // 09 Feb 08 SHL
648 // DosSleep(0); //26 Aug 07 GKY 1 // 09 Feb 08 SHL
649 } // for
650 if (ulMaxFiles) {
651 // Some files OK
652 memset(&ri, 0, sizeof(RECORDINSERT));
653 ri.cb = sizeof(RECORDINSERT);
654 ri.pRecordOrder = (PRECORDCORE) CMA_END;
655 ri.pRecordParent = (PRECORDCORE) 0;
656 ri.zOrder = (ULONG) CMA_TOP;
657 ri.cRecordsInsert = ulMaxFiles;
658 ri.fInvalidateRecord = TRUE;
659 WinSendMsg(dcd->hwndCnr,
660 CM_INSERTRECORD, MPFROMP(pciFirst), MPFROMP(&ri));
661 PostMsg(dcd->hwndCnr, UM_RESCAN, MPVOID, MPVOID);
662 }
663 }
664 }
665 }
666 if (dcd->flWindowAttr & CV_DETAIL)
667 WinSendDlgItemMsg(hwnd,
668 COLLECTOR_CNR,
669 CM_INVALIDATERECORD,
670 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
671 return 0;
672
673 case UM_COLLECTFROMFILE:
674 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
675 if (dcd && mp1) {
676 FILESTATUS4L fs4;
677 PCNRITEM pci;
678 RECORDINSERT ri;
679 CHAR fullname[1024], *p;
680 FILE *fp;
681 ULONG errs = 0;
682 BOOL first = FALSE;
683 size_t c;
684
685 fp = _fsopen((CHAR *) mp1, "r", SH_DENYNO);
686 if (fp) {
687 while (!feof(fp)) {
688 // Avoid too much noise if collecting from binary file - oops
689 if (!fgets(fullname, sizeof(fullname), fp)) {
690 if (ferror(fp))
691 Runtime_Error(pszSrcFile, __LINE__, "fgets");
692 break;
693 }
694
695 c = strlen(fullname);
696 if (c + 1 >= sizeof(fullname))
697 errs++;
698 else if (!c || (fullname[c - 1] != '\n' && fullname[c - 1] != '\r'))
699 errs++;
700 else {
701 bstripcr(fullname);
702
703 if (*fullname == '\"') {
704 memmove(fullname, fullname + 1, strlen(fullname) + 1);
705 lstrip(fullname);
706 p = strchr(fullname, '\"');
707 if (p)
708 *p = 0;
709 rstrip(fullname);
710 }
711 else {
712 p = strchr(fullname, ' ');
713 if (p)
714 *p = 0;
715 }
716 /* fullname now contains name of file to collect */
717 DosError(FERR_DISABLEHARDERR);
718 if (FindCnrRecord(dcd->hwndCnr,
719 fullname,
720 NULL,
721 FALSE,
722 FALSE,
723 TRUE)) {
724 pci = UpdateCnrRecord(dcd->hwndCnr, fullname, FALSE, dcd);
725 if (Filter((PMINIRECORDCORE) pci, (PVOID) & dcd->mask)) {
726 pci->rc.flRecordAttr &= ~CRA_FILTERED;
727 WinSendMsg(dcd->hwndCnr, CM_INVALIDATERECORD, MPVOID,
728 MPFROM2SHORT(0, CMA_REPOSITION | CMA_ERASE));
729 }
730 /*pci = (PCNRITEM) pci->rc.preccNextRecord;
731 if (pciP)
732 pciP->rc.preccNextRecord = (PMINIRECORDCORE) pci;
733 else
734 pciFirst = pci;*/
735 }
736 else if (IsFullName(fullname) &&
737 !IsRoot(fullname) &&
738 !DosQueryPathInfo(fullname,
739 FIL_QUERYEASIZEL,
740 &fs4,
741 sizeof(fs4))) {
742 /* collect it */
743 pci = WinSendMsg(dcd->hwndCnr,
744 CM_ALLOCRECORD,
745 MPFROMLONG(EXTRA_RECORD_BYTES),
746 MPFROMLONG(1));
747 if (pci) {
748 dcd->ullTotalBytes += FillInRecordFromFSA(dcd->hwndCnr, pci,
749 fullname,
750 &fs4, FALSE, dcd);
751 memset(&ri, 0, sizeof(RECORDINSERT));
752 ri.cb = sizeof(RECORDINSERT);
753 ri.pRecordOrder = (PRECORDCORE) CMA_END;
754 ri.pRecordParent = (PRECORDCORE) 0;
755 ri.zOrder = (ULONG) CMA_TOP;
756 ri.cRecordsInsert = 1;
757 ri.fInvalidateRecord = TRUE;
758 WinSendMsg(dcd->hwndCnr, CM_INSERTRECORD,
759 MPFROMP(pci), MPFROMP(&ri));
760 }
761 }
762 else
763 errs++;
764 }
765 if (errs > (first ? 0 : 50)) {
766 /* prevent runaway on bad file */
767 APIRET ret = saymsg(MB_YESNO, dcd->hwndCnr,
768 GetPString(IDS_COLLECTNOLISTHDRTEXT),
769 GetPString(IDS_COLLECTNOLISTTEXT),
770 (CHAR *) mp1);
771
772 if (ret == MBID_NO)
773 break;
774 if (!first)
775 errs = 0;
776 else
777 first = FALSE;
778 }
779 } // while not eof
780 fclose(fp);
781 }
782 }
783 xfree(mp1);
784 return 0;
785
786 case UM_SELECT:
787 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
788 if (dcd) {
789 switch (SHORT1FROMMP(mp1)) {
790 case IDM_SELECTLIST:
791 {
792 CHAR filename[CCHMAXPATH], *p, *pp;
793
794 strcpy(filename, "*.LST");
795 size = CCHMAXPATH;
796 PrfQueryProfileData(fmprof, appname, "SaveToListName", filename,
797 &size);
798 pp = strrchr(filename, '\\');
799 if (!pp)
800 pp = filename;
801 p = strrchr(pp, '.');
802 if (p && *(p + 1) && p > pp + 1) {
803 if (pp > filename)
804 pp++;
805 *pp = '*';
806 pp++;
807 if (p > pp)
808 memmove(pp, p, strlen(p) + 1);
809 }
810 if (insert_filename(hwnd, filename, FALSE, FALSE))
811 SelectList(dcd->hwndCnr, TRUE, FALSE, FALSE, NULL, filename,
812 NULL);
813 }
814 break;
815 case IDM_SELECTALL:
816 SelectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
817 break;
818 case IDM_DESELECTALL:
819 DeselectAll(dcd->hwndCnr, TRUE, TRUE, NULL, NULL, FALSE);
820 break;
821 case IDM_SELECTALLFILES:
822 SelectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
823 break;
824 case IDM_DESELECTALLFILES:
825 DeselectAll(dcd->hwndCnr, TRUE, FALSE, NULL, NULL, FALSE);
826 break;
827 case IDM_SELECTALLDIRS:
828 SelectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
829 break;
830 case IDM_DESELECTALLDIRS:
831 DeselectAll(dcd->hwndCnr, FALSE, TRUE, NULL, NULL, FALSE);
832 break;
833 case IDM_DESELECTMASK:
834 case IDM_SELECTMASK:
835 {
836 MASK mask;
837 PCNRITEM pci = (PCNRITEM) mp2;
838
839 memset(&mask, 0, sizeof(MASK));
840 mask.fNoAttribs = TRUE;
841 mask.fNoDirs = TRUE;
842 mask.fText = TRUE;
843 strcpy(mask.prompt,
844 GetPString((SHORT1FROMMP(mp1) == IDM_SELECTMASK) ?
845 IDS_SELECTFILTERTEXT : IDS_DESELECTFILTERTEXT));
846 if (pci && (INT) pci != -1)
847 strcpy(mask.szMask, pci->pszFileName);
848 if (WinDlgBox(HWND_DESKTOP, dcd->hwndCnr, PickMaskDlgProc,
849 FM3ModHandle, MSK_FRAME, MPFROMP(&mask))) {
850 if (SHORT1FROMMP(mp1) == IDM_SELECTMASK)
851 SelectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, mask.szText,
852 FALSE);
853 else
854 DeselectAll(dcd->hwndCnr, TRUE, TRUE, mask.szMask, mask.szText,
855 FALSE);
856 }
857 }
858
859 case IDM_DESELECTCLIP:
860 case IDM_SELECTCLIP:
861 {
862 CHAR **list;
863
864 list = ListFromClipboard(hwnd);
865 if (list) {
866 SelectList(dcd->hwndCnr, TRUE, FALSE,
867 (SHORT1FROMMP(mp1) == IDM_DESELECTCLIP),
868 NULL, NULL, list);
869 FreeList(list);
870 }
871 }
872 break;
873
874 case IDM_INVERT:
875 InvertAll(dcd->hwndCnr);
876 break;
877 }
878 }
879 return 0;
880
881 case UM_MASSACTION:
882 if (mp1) {
883 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
884 if (dcd) {
885 WORKER *wk;
886
887 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
888 if (!wk)
889 FreeListInfo((LISTINFO *) mp1);
890 else {
891 wk->size = sizeof(WORKER);
892 wk->hwndCnr = dcd->hwndCnr;
893 wk->hwndParent = dcd->hwndParent;
894 wk->hwndFrame = dcd->hwndFrame;
895 wk->hwndClient = dcd->hwndClient;
896 wk->li = (LISTINFO *) mp1;
897 strcpy(wk->directory, dcd->directory);
898 if (_beginthread(MassAction, NULL, 122880, (PVOID) wk) == -1) {
899 Runtime_Error(pszSrcFile, __LINE__,
900 GetPString(IDS_COULDNTSTARTTHREADTEXT));
901 xfree(wk);
902 FreeListInfo((LISTINFO *) mp1);
903 }
904 }
905 }
906 }
907 return 0;
908
909 case UM_ACTION:
910 if (mp1) {
911 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
912 if (dcd) {
913 WORKER *wk;
914
915 wk = xmallocz(sizeof(WORKER), pszSrcFile, __LINE__);
916 if (!wk)
917 FreeListInfo((LISTINFO *) mp1);
918 else {
919 wk->size = sizeof(WORKER);
920 wk->hwndCnr = dcd->hwndCnr;
921 wk->hwndParent = dcd->hwndParent;
922 wk->hwndFrame = dcd->hwndFrame;
923 wk->hwndClient = dcd->hwndClient;
924 wk->li = (LISTINFO *) mp1;
925 strcpy(wk->directory, dcd->directory);
926 if (_beginthread(Action, NULL, 122880, (PVOID) wk) == -1) {
927 Runtime_Error(pszSrcFile, __LINE__,
928 GetPString(IDS_COULDNTSTARTTHREADTEXT));
929 xfree(wk);
930 FreeListInfo((LISTINFO *) mp1);
931 }
932 }
933 }
934 }
935 return 0;
936
937 case WM_CLOSE:
938 WinDestroyWindow(hwnd);
939 break;
940
941 case WM_DESTROY:
942 dcd = WinQueryWindowPtr(hwnd, QWL_USER);
943 if (dcd) {
944 INT x;
945
946 dcd->stopflag = 1;
947 // Allow other threads to honor stop request
948 for (x = 0; x < 100 && dcd->amextracted; x++)
949 DosSleep(10);
950 if (dcd->amextracted)
951 Runtime_Error(pszSrcFile, __LINE__, "still busy");
952 WinSendMsg(dcd->hwndCnr, UM_CLOSE, MPVOID, MPVOID);
953 FreeList(dcd->lastselection);
954 xfree(dcd);
955 }
956 DosPostEventSem(CompactSem);
957 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
958 WinSendMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
959 break;
960 }
961 return WinDefWindowProc(hwnd, msg, mp1, mp2);
962}
963
964MRESULT EXPENTRY CollectorCnrWndProc(HWND hwnd, ULONG msg, MPARAM mp1,
965 MPARAM mp2)
966{
967 DIRCNRDATA *dcd = INSTDATA(hwnd);
968 ULONG size;
969
970 static INT savedSortFlags;
971
972 switch (msg) {
973 case DM_PRINTOBJECT:
974 return MRFROMLONG(DRR_TARGET);
975
976 case DM_DISCARDOBJECT:
977 if (dcd)
978 return WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
979 else
980 return MRFROMLONG(DRR_TARGET);
981
982 case WM_CHAR:
983 shiftstate = (SHORT1FROMMP(mp1) & (KC_SHIFT | KC_ALT | KC_CTRL));
984 if (SHORT1FROMMP(mp1) & KC_KEYUP)
985 return (MRESULT) TRUE;
986 if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
987 switch (SHORT2FROMMP(mp2)) {
988 case VK_DELETE:
989 if ((shiftstate & KC_CTRL) == KC_CTRL)
990 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_PERMDELETE, 0), MPVOID);
991 else if ((shiftstate & KC_SHIFT) == KC_SHIFT)
992 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SAVETOCLIP, 0), MPVOID);
993 else
994 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_DELETE, 0), MPVOID);
995 break;
996 }
997 }
998 if (shiftstate || fNoSearch)
999 break;
1000 if (SHORT1FROMMP(mp1) & KC_CHAR) {
1001 ULONG thistime, len;
1002 SEARCHSTRING srch;
1003 PCNRITEM pci;
1004
1005 if (!dcd)
1006 break;
1007 switch (SHORT1FROMMP(mp2)) {
1008 case '\x1b':
1009 case '\r':
1010 case '\n':
1011 dcd->lasttime = 0;
1012 *dcd->szCommonName = 0;
1013 break;
1014 default:
1015 thistime = WinQueryMsgTime(WinQueryAnchorBlock(hwnd));
1016 if (thistime > dcd->lasttime + 1250)
1017 *dcd->szCommonName = 0;
1018 dcd->lasttime = thistime;
1019 if (SHORT1FROMMP(mp2) == ' ' && !dcd->szCommonName)
1020 break;
1021 KbdRetry:
1022 len = strlen(dcd->szCommonName);
1023 if (len >= CCHMAXPATH - 1) {
1024 *dcd->szCommonName = 0;
1025 len = 0;
1026 }
1027 dcd->szCommonName[len] = toupper(SHORT1FROMMP(mp2));
1028 dcd->szCommonName[len + 1] = 0;
1029 memset(&srch, 0, sizeof(SEARCHSTRING));
1030 srch.cb = sizeof(SEARCHSTRING);
1031 srch.pszSearch = dcd->szCommonName;
1032 srch.fsPrefix = TRUE;
1033 srch.fsCaseSensitive = FALSE;
1034 srch.usView = CV_ICON;
1035 pci = WinSendMsg(hwnd, CM_SEARCHSTRING, MPFROMP(&srch),
1036 MPFROMLONG(CMA_FIRST));
1037 if (pci && (INT) pci != -1) {
1038 USHORT attrib = CRA_CURSORED;
1039
1040 /* make found item current item */
1041 if (!stricmp(pci->pszFileName, dcd->szCommonName))
1042 attrib |= CRA_SELECTED;
1043 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
1044 MPFROM2SHORT(TRUE, attrib));
1045 /* make sure that record shows in viewport */
1046 ShowCnrRecord(hwnd, (PMINIRECORDCORE) pci);
1047 return (MRESULT) TRUE;
1048 }
1049 else {
1050 if (SHORT1FROMMP(mp2) == ' ') {
1051 dcd->szCommonName[len] = 0;
1052 break;
1053 }
1054 *dcd->szCommonName = 0;
1055 dcd->lasttime = 0;
1056 if (len) // retry as first letter if no match
1057
1058 goto KbdRetry;
1059 }
1060 break;
1061 }
1062 }
1063 break;
1064
1065 case WM_MOUSEMOVE:
1066 case WM_BUTTON1UP:
1067 case WM_BUTTON2UP:
1068 case WM_BUTTON3UP:
1069 case WM_CHORD:
1070 shiftstate = (SHORT2FROMMP(mp2) & (KC_SHIFT | KC_ALT | KC_CTRL));
1071 break;
1072
1073 case WM_BUTTON1MOTIONEND:
1074 {
1075 CNRINFO cnri;
1076
1077 memset(&cnri, 0, sizeof(CNRINFO));
1078 cnri.cb = sizeof(CNRINFO);
1079 if (WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1080 MPFROMLONG(sizeof(CNRINFO)))) {
1081 if (cnri.flWindowAttr & CV_DETAIL)
1082 PrfWriteProfileData(fmprof, appname, "CollectorCnrSplitBar",
1083 (PVOID) & cnri.xVertSplitbar, sizeof(LONG));
1084 }
1085 }
1086 break;
1087
1088 case WM_PRESPARAMCHANGED:
1089 PresParamChanged(hwnd, "Collector", mp1, mp2);
1090 break;
1091
1092 case UM_COMPARE:
1093 if (dcd && mp1 && mp2) {
1094 COMPARE *cmp;
1095 CHAR *leftdir = (CHAR *) mp1, *rightdir = (CHAR *) mp2;
1096
1097 if (!IsFile(leftdir) && !IsFile(rightdir)) {
1098 cmp = xmallocz(sizeof(COMPARE), pszSrcFile, __LINE__);
1099 if (cmp) {
1100 cmp->size = sizeof(COMPARE);
1101 strcpy(cmp->leftdir, leftdir);
1102 strcpy(cmp->rightdir, rightdir);
1103 cmp->hwndParent = dcd->hwndParent;
1104 cmp->dcd.hwndParent = dcd->hwndParent;
1105 WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, CompareDlgProc,
1106 FM3ModHandle, COMP_FRAME, MPFROMP(cmp));
1107 }
1108 }
1109 }
1110 return 0;
1111
1112 case UM_UPDATERECORDLIST:
1113 if (dcd && mp1)
1114 WinSendMsg(dcd->hwndObject, msg, mp1, mp2);
1115 return 0;
1116
1117 case UM_UPDATERECORD:
1118 if (dcd && mp1) {
1119 CHAR *filename;
1120
1121 filename = mp1;
1122 if (filename)
1123 UpdateCnrRecord(hwnd, filename, TRUE, dcd);
1124 }
1125 return 0;
1126
1127 case WM_SETFOCUS:
1128 /*
1129 * put name of our window on status line
1130 */
1131 if (dcd && hwndStatus && mp2) {
1132 PCNRITEM pci = NULL;
1133
1134 if (fAutoView && hwndMain) {
1135 pci = WinSendMsg(hwnd,
1136 CM_QUERYRECORDEMPHASIS,
1137 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1138 if (pci && (INT) pci != -1 &&
1139 (!(driveflags[toupper(*pci->pszFileName) - 'A'] & DRIVE_SLOW)))
1140 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1141 else
1142 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1143 }
1144 if (dcd->amextracted)
1145 WinSetWindowText(hwndStatus2, GetPString(IDS_INSEEKSCANTEXT)); // Say working
1146 WinSendMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1147 }
1148 break;
1149
1150 case UM_RESCAN:
1151 if (dcd) {
1152 CNRINFO cnri;
1153 CHAR s[CCHMAXPATH + 69], tb[81], tf[81], *p;
1154 PCNRITEM pci = NULL;
1155
1156 memset(&cnri, 0, sizeof(CNRINFO));
1157 cnri.cb = sizeof(CNRINFO);
1158 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1159 MPFROMLONG(sizeof(CNRINFO)));
1160 dcd->totalfiles = cnri.cRecords;
1161 commafmt(tf, sizeof(tf), dcd->totalfiles);
1162 CommaFmtULL(tb, sizeof(tb), dcd->ullTotalBytes, ' ');
1163 sprintf(s, "%s / %s", tf, tb);
1164 WinSetDlgItemText(dcd->hwndClient, DIR_TOTALS, s);
1165
1166 commafmt(tf, sizeof(tf), dcd->selectedfiles);
1167 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, ' ');
1168 sprintf(s, "%s / %s", tf, tb);
1169 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
1170
1171 if (hwndStatus &&
1172 dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
1173 if (hwndMain) {
1174 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1175 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1176 if (pci && (INT) pci != -1)
1177 PostMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName), MPVOID);
1178 else
1179 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1180 }
1181 if (!dcd->amextracted) {
1182 if (!fMoreButtons) {
1183 sprintf(s, " %s%s%s%s",
1184 GetPString(IDS_COLLECTORTEXT),
1185 *dcd->mask.szMask || dcd->mask.antiattr ||
1186 dcd->mask.attrFile != ALLATTRS ? " (" : NullStr,
1187 *dcd->mask.szMask ?
1188 dcd->mask.szMask :
1189 dcd->mask.antiattr ||
1190 dcd->mask.attrFile != ALLATTRS ?
1191 GetPString(IDS_ATTRTEXT) : NullStr,
1192 *dcd->mask.szMask || dcd->mask.antiattr ||
1193 dcd->mask.attrFile != ALLATTRS ?
1194 ")" : NullStr);
1195 }
1196 else
1197 strcpy(s, GetPString(IDS_COLLECTORTEXT));
1198 WinSetWindowText(hwndStatus, s);
1199 }
1200 if (!pci)
1201 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1202 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1203 if (pci && (INT) pci != -1) {
1204 BOOL fStatus2Used = FALSE;
1205
1206 if (fSplitStatus && hwndStatus2) {
1207 if (pci->attrFile & FILE_DIRECTORY)
1208 p = pci->pszFileName;
1209 else {
1210 p = strrchr(pci->pszFileName, '\\');
1211 if (p) {
1212 if (*(p + 1))
1213 p++;
1214 else
1215 p = pci->pszFileName;
1216 }
1217 else
1218 p = pci->pszFileName;
1219 }
1220 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
1221 if (!fMoreButtons) {
1222 sprintf(s, " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
1223 tb, pci->date.year, pci->date.month,
1224 pci->date.day, pci->time.hours, pci->time.minutes,
1225 pci->time.seconds, pci->pszDispAttr, p);
1226 }
1227 else {
1228 if (pci->cbFile + pci->easize > 1024)
1229 CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize, 'K');
1230 else
1231 *tf = 0;
1232 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
1233 tb, *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
1234 }
1235 WinSetWindowText(hwndStatus2, s);
1236 fStatus2Used = TRUE;
1237 }
1238 if (fMoreButtons) {
1239 WinSetWindowText(hwndName, pci->pszFileName);
1240 sprintf(s, "%04u/%02u/%02u %02u:%02u:%02u",
1241 pci->date.year, pci->date.month,
1242 pci->date.day, pci->time.hours, pci->time.minutes,
1243 pci->time.seconds);
1244 WinSetWindowText(hwndDate, s);
1245 WinSetWindowText(hwndAttr, pci->pszDispAttr);
1246 }
1247 if (dcd->amextracted && hwndStatus2 && !fStatus2Used)
1248 WinSetWindowText(hwndStatus2, GetPString(IDS_INSEEKSCANTEXT)); // Say working
1249 }
1250 else {
1251 if (hwndStatus2) {
1252 if (dcd->amextracted)
1253 WinSetWindowText(hwndStatus2, GetPString(IDS_INSEEKSCANTEXT)); // Say working
1254 else
1255 WinSetWindowText(hwndStatus2, NullStr);
1256 }
1257 if (fMoreButtons) {
1258 WinSetWindowText(hwndName, NullStr);
1259 WinSetWindowText(hwndDate, NullStr);
1260 WinSetWindowText(hwndAttr, NullStr);
1261 }
1262 }
1263 }
1264 }
1265 return 0;
1266
1267 case UM_CONTAINER_FILLED:
1268 DosBeep(1000, 50); // Wake up user?
1269 WinSendMsg(hwnd,
1270 CM_INVALIDATERECORD,
1271 MPVOID, MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
1272 disable_menuitem(WinWindowFromID(WinQueryWindow(hwndMain, QW_PARENT),
1273 FID_MENU), IDM_GREP, FALSE);
1274 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1275 if (dcd) {
1276 dcd->stopflag = 0;
1277 dcd->amextracted = FALSE; // Say not busy
1278 if (dcd->namecanchange) {
1279 if (!PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID))
1280 WinSendMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1281 }
1282 else
1283 WinSetWindowPos(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
1284 QW_PARENT),
1285 HWND_TOP,
1286 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE | SWP_ZORDER);
1287 }
1288 return 0;
1289
1290 case UM_SETUP:
1291 if (dcd) {
1292 if (!dcd->hwndObject) {
1293 /* first time through -- set things up */
1294
1295 CNRINFO cnri;
1296
1297 RestorePresParams(hwnd, "Collector");
1298 LoadDetailsSwitches("Collector", dcd);
1299
1300 dcd->amextracted = FALSE; // Say not busy
1301 dcd->stopflag = 0;
1302 memset(&cnri, 0, sizeof(CNRINFO));
1303 cnri.cb = sizeof(CNRINFO);
1304 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1305 MPFROMLONG(sizeof(CNRINFO)));
1306 cnri.cyLineSpacing = 0;
1307 cnri.cxTreeIndent = 12;
1308
1309 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT | CV_DETAIL));
1310 cnri.flWindowAttr |= (CV_NAME | CA_DETAILSVIEWTITLES |
1311 CV_MINI | CV_FLOW);
1312 cnri.pSortRecord = (PVOID) SortCollectorCnr;
1313
1314 size = sizeof(ULONG);
1315 PrfQueryProfileData(fmprof, appname, "CollectorflWindowAttr",
1316 (PVOID) & cnri.flWindowAttr, &size);
1317 size = sizeof(MASK);
1318 if (PrfQueryProfileSize(fmprof, appname, "CollectorFilter", &size) &&
1319 size) {
1320 PrfQueryProfileData(fmprof, appname, "CollectorFilter", &dcd->mask,
1321 &size);
1322 SetMask(NULL, &dcd->mask);
1323 }
1324 else {
1325 dcd->mask.attrFile = (FILE_NORMAL | FILE_READONLY |
1326 FILE_DIRECTORY | FILE_HIDDEN |
1327 FILE_SYSTEM | FILE_ARCHIVED);
1328 dcd->mask.antiattr = 0;
1329 }
1330
1331 *(dcd->mask.prompt) = 0;
1332
1333 cnri.flWindowAttr |= CV_FLOW;
1334 cnri.flWindowAttr &= (~(CA_MIXEDTARGETEMPH | CA_ORDEREDTARGETEMPH));
1335 dcd->flWindowAttr = cnri.flWindowAttr;
1336 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
1337 MPFROMLONG(CMA_FLWINDOWATTR | CMA_LINESPACING |
1338 CMA_CXTREEINDENT | CMA_PSORTRECORD));
1339 SetCnrCols(hwnd, FALSE);
1340 AdjustCnrColsForPref(hwnd, NULL, dcd, FALSE);
1341
1342 /* fix splitbar for collector container */
1343 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
1344 size = sizeof(LONG);
1345 PrfQueryProfileData(fmprof, appname, "CollectorCnrSplitBar",
1346 &cnri.xVertSplitbar, &size);
1347 if (cnri.xVertSplitbar <= 0)
1348 cnri.xVertSplitbar = DIR_SPLITBAR_OFFSET - 32;
1349 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
1350 MPFROMLONG(CMA_XVERTSPLITBAR));
1351
1352 if (_beginthread(MakeObjWin, NULL, 245760, (PVOID)dcd) == -1) {
1353 Runtime_Error(pszSrcFile, __LINE__,
1354 GetPString(IDS_COULDNTSTARTTHREADTEXT));
1355 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1356 return 0;
1357 }
1358 else
1359 DosSleep(32); // Let object window get started
1360 }
1361 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1362 DIR_FILTER), &dcd->mask, FALSE);
1363 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1364 DIR_SORT), CollectorsortFlags, FALSE);
1365 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1366 DIR_VIEW), dcd->flWindowAttr);
1367 }
1368 else {
1369 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
1370 return 0;
1371 }
1372 return 0;
1373
1374 case WM_MENUEND:
1375 if (dcd) {
1376 HWND hwndMenu = (HWND) mp2;
1377
1378 if (hwndMenu == CollectorCnrMenu || hwndMenu == CollectorFileMenu ||
1379 hwndMenu == CollectorDirMenu) {
1380 MarkAll(hwnd, TRUE, FALSE, TRUE);
1381 if (dcd->cnremphasized) {
1382 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
1383 MPFROM2SHORT(FALSE, CRA_SOURCE));
1384 dcd->cnremphasized = FALSE;
1385 }
1386 }
1387 }
1388 break;
1389
1390 case UM_OPENWINDOWFORME:
1391 if (dcd) {
1392 if (mp1 && !IsFile((CHAR *) mp1))
1393 OpenDirCnr(HWND_DESKTOP, hwndMain, dcd->hwndFrame, FALSE, (PSZ) mp1);
1394 else if (mp1 && IsFile(mp1) == 1)
1395 StartArcCnr(HWND_DESKTOP,
1396 dcd->hwndFrame, (CHAR *) mp1, 4, (ARC_TYPE *) mp2);
1397 }
1398 return 0;
1399
1400 case MM_PORTHOLEINIT:
1401 if (dcd) {
1402 switch (SHORT1FROMMP(mp1)) {
1403 case 0:
1404 case 1:
1405 {
1406 ULONG wmsg;
1407
1408 wmsg = (SHORT1FROMMP(mp1) == 0) ? UM_FILESMENU : UM_VIEWSMENU;
1409 PortholeInit((HWND) WinSendMsg(dcd->hwndClient, wmsg, MPVOID,
1410 MPVOID), mp1, mp2);
1411 }
1412 break;
1413 }
1414 }
1415 break;
1416
1417 case UM_INITMENU:
1418 case WM_INITMENU:
1419 if (dcd) {
1420 switch (SHORT1FROMMP(mp1)) {
1421 case IDM_VIEWSMENU:
1422 SetViewMenu((HWND) mp2, dcd->flWindowAttr);
1423 WinEnableMenuItem((HWND) mp2, IDM_RESELECT,
1424 (dcd->lastselection != NULL));
1425 CopyPresParams((HWND) mp2, hwnd);
1426 break;
1427
1428 case IDM_DETAILSSETUP:
1429 SetDetailsSwitches((HWND) mp2, dcd);
1430 break;
1431
1432 case IDM_COMMANDSMENU:
1433 SetupCommandMenu((HWND) mp2, hwnd);
1434 break;
1435
1436 case IDM_SORTSUBMENU:
1437 SetSortChecks((HWND) mp2, CollectorsortFlags);
1438 break;
1439 }
1440 dcd->hwndLastMenu = (HWND) mp2;
1441 }
1442 if (msg == WM_INITMENU)
1443 break;
1444 return 0;
1445
1446 case UM_COLLECTFROMFILE:
1447 if (mp1) {
1448 if (!dcd) {
1449 xfree(mp1);
1450 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
1451 }
1452 else {
1453 if (!PostMsg(dcd->hwndObject, UM_COLLECTFROMFILE, mp1, mp2)) {
1454 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
1455 xfree(mp1);
1456 }
1457 }
1458 }
1459 return 0;
1460
1461 case UM_COMMAND:
1462 if (mp1) {
1463 if (dcd) {
1464 if (!PostMsg(dcd->hwndObject, UM_COMMAND, mp1, mp2)) {
1465 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
1466 FreeListInfo((LISTINFO *) mp1);
1467 }
1468 else
1469 return (MRESULT) TRUE;
1470 }
1471 else
1472 FreeListInfo((LISTINFO *) mp1);
1473 }
1474 return 0;
1475
1476 case UM_NOTIFY:
1477 if (mp2)
1478 AddNote((CHAR *) mp2);
1479 return 0;
1480
1481 case WM_COMMAND:
1482 DosError(FERR_DISABLEHARDERR);
1483 if (dcd) {
1484 switch (SHORT1FROMMP(mp1)) {
1485 case IDM_SETTARGET:
1486 SetTargetDir(hwnd, FALSE);
1487 break;
1488
1489 case IDM_CONTEXTMENU:
1490 {
1491 PCNRITEM pci;
1492
1493 pci = (PCNRITEM) CurrentRecord(hwnd);
1494 PostMsg(hwnd, WM_CONTROL, MPFROM2SHORT(COLLECTOR_CNR,
1495 CN_CONTEXTMENU),
1496 MPFROMP(pci));
1497 }
1498 break;
1499
1500 case IDM_SHOWALLFILES:
1501 {
1502 PCNRITEM pci;
1503
1504 pci = WinSendMsg(hwnd,
1505 CM_QUERYRECORDEMPHASIS,
1506 MPFROMLONG(CMA_FIRST), MPFROMSHORT(CRA_CURSORED));
1507 if (pci && (INT) pci != -1) {
1508 static CHAR dirname[CCHMAXPATH];
1509
1510 strcpy(dirname, pci->pszFileName);
1511 MakeValidDir(dirname);
1512 StartSeeAll(HWND_DESKTOP, FALSE, dirname);
1513 }
1514 }
1515 break;
1516
1517 case IDM_BEGINEDIT:
1518 OpenEdit(hwnd);
1519 break;
1520
1521 case IDM_ENDEDIT:
1522 WinSendMsg(hwnd, CM_CLOSEEDIT, MPVOID, MPVOID);
1523 break;
1524
1525 case IDM_SHOWSELECT:
1526 QuickPopup(hwnd, dcd,
1527 CheckMenu(hwnd, &CollectorCnrMenu, COLLECTORCNR_POPUP),
1528 IDM_SELECTSUBMENU);
1529 break;
1530
1531 case IDM_SHOWSORT:
1532 QuickPopup(hwnd, dcd,
1533 CheckMenu(hwnd, &CollectorCnrMenu, COLLECTORCNR_POPUP),
1534 IDM_SORTSUBMENU);
1535 break;
1536
1537 case IDM_VIEWORARC:
1538 {
1539 SWP swp;
1540 PCNRITEM pci;
1541
1542 pci = (PCNRITEM) WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1543 MPFROMLONG(CMA_FIRST),
1544 MPFROMSHORT(CRA_CURSORED));
1545 if (pci && (INT) pci != -1) {
1546 WinQueryWindowPos(dcd->hwndFrame, &swp);
1547 DefaultViewKeys(hwnd, dcd->hwndFrame, dcd->hwndParent, &swp,
1548 pci->pszFileName);
1549 }
1550 }
1551 break;
1552
1553 case IDM_SEEALL:
1554 StartSeeAll(HWND_DESKTOP, FALSE, NULL);
1555 break;
1556
1557 case IDM_COLLECTSELECT:
1558 {
1559 CHAR filename[CCHMAXPATH], *p, *pp;
1560
1561 strcpy(filename, "*.LST");
1562 size = CCHMAXPATH;
1563 PrfQueryProfileData(fmprof, appname, "SaveToListName",
1564 filename, &size);
1565 pp = strrchr(filename, '\\');
1566 if (!pp)
1567 pp = filename;
1568 p = strrchr(pp, '.');
1569 if (p && *(p + 1) && p > pp + 1) {
1570 if (pp > filename)
1571 pp++;
1572 *pp = '*';
1573 pp++;
1574 if (p > pp)
1575 memmove(pp, p, strlen(p) + 1);
1576 }
1577 if (insert_filename(hwnd, filename, FALSE, FALSE)) {
1578 p = xstrdup(filename, pszSrcFile, __LINE__);
1579 if (p) {
1580 if (!PostMsg(hwnd, UM_COLLECTFROMFILE, MPFROMP(p), MPVOID))
1581 xfree(p);
1582 }
1583 }
1584 }
1585 break;
1586
1587 case IDM_COLLECTORVIEWSETTINGS:
1588 if (!ParentIsDesktop(dcd->hwndParent, dcd->hwndParent))
1589 PostMsg(dcd->hwndParent, msg, MPFROMLONG(IDM_COLLECTORVIEWSETTINGS), mp2);
1590 else {
1591 WinDlgBox(HWND_DESKTOP,
1592 hwnd,
1593 CfgDlgProc,
1594 FM3ModHandle,
1595 CFG_FRAME,
1596 MPFROMLONG(IDM_COLLECTORVIEWSETTINGS));
1597 }
1598 break;
1599
1600 case IDM_RESELECT:
1601 SelectList(hwnd, FALSE, FALSE, FALSE, NULL, NULL, dcd->lastselection);
1602 break;
1603
1604 case IDM_HELP:
1605 if (hwndHelp)
1606 WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
1607 MPFROM2SHORT(HELP_COLLECT, 0),
1608 MPFROMSHORT(HM_RESOURCEID));
1609 break;
1610
1611 case IDM_SORTNONE:
1612 case IDM_SORTSMARTNAME:
1613 case IDM_SORTNAME:
1614 case IDM_SORTFILENAME:
1615 case IDM_SORTSIZE:
1616 case IDM_SORTEASIZE:
1617 case IDM_SORTFIRST:
1618 case IDM_SORTLAST:
1619 case IDM_SORTLWDATE:
1620 case IDM_SORTLADATE:
1621 case IDM_SORTCRDATE:
1622 case IDM_SORTSUBJECT:
1623 savedSortFlags = CollectorsortFlags;
1624 CollectorsortFlags &= (SORT_REVERSE | SORT_DIRSFIRST | SORT_DIRSLAST);
1625 case IDM_SORTDIRSFIRST:
1626 case IDM_SORTDIRSLAST:
1627 case IDM_SORTREVERSE:
1628 switch (SHORT1FROMMP(mp1)) {
1629 case IDM_SORTSUBJECT:
1630 CollectorsortFlags |= SORT_SUBJECT;
1631 break;
1632 case IDM_SORTNONE:
1633 CollectorsortFlags |= SORT_NOSORT;
1634 break;
1635 case IDM_SORTSMARTNAME:
1636 if (~savedSortFlags & SORT_FILENAME)
1637 CollectorsortFlags |= SORT_FILENAME;
1638 break;
1639 case IDM_SORTFILENAME:
1640 CollectorsortFlags |= SORT_FILENAME;
1641 break;
1642 case IDM_SORTSIZE:
1643 CollectorsortFlags |= SORT_SIZE;
1644 break;
1645 case IDM_SORTEASIZE:
1646 CollectorsortFlags |= SORT_EASIZE;
1647 break;
1648 case IDM_SORTFIRST:
1649 CollectorsortFlags |= SORT_FIRSTEXTENSION;
1650 break;
1651 case IDM_SORTLAST:
1652 CollectorsortFlags |= SORT_LASTEXTENSION;
1653 break;
1654 case IDM_SORTLWDATE:
1655 CollectorsortFlags |= SORT_LWDATE;
1656 break;
1657 case IDM_SORTLADATE:
1658 CollectorsortFlags |= SORT_LADATE;
1659 break;
1660 case IDM_SORTCRDATE:
1661 CollectorsortFlags |= SORT_CRDATE;
1662 break;
1663 case IDM_SORTDIRSFIRST:
1664 if (CollectorsortFlags & SORT_DIRSFIRST)
1665 CollectorsortFlags &= (~SORT_DIRSFIRST);
1666 else {
1667 CollectorsortFlags |= SORT_DIRSFIRST;
1668 CollectorsortFlags &= (~SORT_DIRSLAST);
1669 }
1670 break;
1671 case IDM_SORTDIRSLAST:
1672 if (CollectorsortFlags & SORT_DIRSLAST)
1673 CollectorsortFlags &= (~SORT_DIRSLAST);
1674 else {
1675 CollectorsortFlags |= SORT_DIRSLAST;
1676 CollectorsortFlags &= (~SORT_DIRSFIRST);
1677 }
1678 break;
1679 case IDM_SORTREVERSE:
1680 if (CollectorsortFlags & SORT_REVERSE)
1681 CollectorsortFlags &= (~SORT_REVERSE);
1682 else
1683 CollectorsortFlags |= SORT_REVERSE;
1684 break;
1685 }
1686 PrfWriteProfileData(fmprof, appname, "CollectorSort",
1687 &CollectorsortFlags, sizeof(INT));
1688 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortCollectorCnr), MPVOID);
1689 SaySort(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1690 DIR_SORT), CollectorsortFlags, FALSE);
1691 break;
1692
1693 case IDM_COLLECTFROMCLIP:
1694 {
1695 LISTINFO *li;
1696
1697 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
1698 if (li) {
1699 li->list = ListFromClipboard(hwnd);
1700 if (!li->list || !li->list[0])
1701 FreeListInfo(li);
1702 else {
1703 li->type = IDM_COLLECT;
1704 if (!PostMsg(dcd->hwndObject, UM_COLLECT, MPFROMP(li), MPVOID))
1705 FreeListInfo(li);
1706 }
1707 }
1708 }
1709 break;
1710
1711 case IDM_REMOVE:
1712 if (fAutoView && hwndMain)
1713 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1714 dcd->suspendview = 1;
1715 RemoveAll(hwnd, &dcd->ullTotalBytes, &dcd->totalfiles);
1716 dcd->suspendview = 0;
1717 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1718 break;
1719
1720 case IDM_CLEARCNR:
1721 {
1722 PCNRITEM pci;
1723
1724 pci = (PCNRITEM) WinSendMsg(hwnd,
1725 CM_QUERYRECORD,
1726 MPVOID,
1727 MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
1728 if (pci && (INT) pci != -1) {
1729 RemoveCnrItems(hwnd, NULL, 0, CMA_FREE | CMA_INVALIDATE);
1730 dcd->ullTotalBytes = dcd->selectedbytes = dcd->selectedfiles =
1731 dcd->totalfiles = 0;
1732 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1733 }
1734 }
1735 break;
1736
1737 case DID_CANCEL:
1738 if (dcd->amextracted)
1739 dcd->stopflag = 1; // Request cancel
1740 break;
1741
1742 case IDM_COLLECTOR:
1743 if (mp2) {
1744 LISTINFO *li;
1745
1746 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
1747 if (li) {
1748 li->list = mp2;
1749 if (!li->list || !li->list[0])
1750 FreeListInfo(li);
1751 else {
1752 li->type = IDM_COLLECT;
1753 if (!PostMsg(dcd->hwndObject, UM_COLLECT, MPFROMP(li), MPVOID))
1754 FreeListInfo(li);
1755 }
1756 }
1757 else
1758 FreeList(mp2);
1759 }
1760 break;
1761
1762 case IDM_UNDELETE:
1763 {
1764 PCNRITEM pci;
1765 CHAR path[CCHMAXPATH];
1766
1767 pci = (PCNRITEM) CurrentRecord(hwnd);
1768 if (pci) {
1769 strcpy(path, pci->pszFileName);
1770 MakeValidDir(path);
1771 WinDlgBox(HWND_DESKTOP, hwnd, UndeleteDlgProc, FM3ModHandle,
1772 UNDEL_FRAME, MPFROMP(path));
1773 }
1774 }
1775 break;
1776
1777 case IDM_GREP:
1778 if (dcd->amextracted) {
1779 saymsg(MB_OK | MB_ICONASTERISK,
1780 hwnd,
1781 GetPString(IDS_WARNINGTEXT),
1782 "Collector busy - please try again later");
1783 }
1784 else {
1785 if (WinDlgBox(HWND_DESKTOP, hwnd, GrepDlgProc,
1786 FM3ModHandle, GREP_FRAME, (PVOID) & hwnd)) {
1787 dcd->amextracted = TRUE; // Say busy scanning
1788 disable_menuitem(WinWindowFromID
1789 (WinQueryWindow(hwndMain, QW_PARENT), FID_MENU),
1790 IDM_GREP, TRUE);
1791 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1792 }
1793 }
1794 break;
1795
1796 case IDM_RESORT:
1797 WinSendMsg(hwnd, CM_SORTRECORD, MPFROMP(SortCollectorCnr), MPVOID);
1798 break;
1799
1800 case IDM_FILTER:
1801 {
1802 BOOL empty = FALSE;
1803 PCNRITEM pci;
1804 CHAR *p;
1805
1806 if (!*dcd->mask.szMask) {
1807 empty = TRUE;
1808 pci = (PCNRITEM) CurrentRecord(hwnd);
1809 if (pci && !(pci->attrFile & FILE_DIRECTORY)) {
1810 p = strrchr(pci->pszFileName, '\\');
1811 if (p) {
1812 p++;
1813 strcpy(dcd->mask.szMask, p);
1814 }
1815 }
1816 }
1817 *(dcd->mask.prompt) = 0;
1818
1819 if (WinDlgBox(HWND_DESKTOP, hwnd, PickMaskDlgProc,
1820 FM3ModHandle, MSK_FRAME, MPFROMP(&dcd->mask))) {
1821 size = sizeof(MASK);
1822 PrfWriteProfileData(fmprof, appname, "CollectorFilter",
1823 &dcd->mask, size);
1824 dcd->suspendview = 1;
1825 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
1826 dcd->suspendview = 0;
1827 if (fAutoView && hwndMain) {
1828 pci = WinSendMsg(hwnd, CM_QUERYRECORDEMPHASIS,
1829 MPFROMLONG(CMA_FIRST),
1830 MPFROMSHORT(CRA_CURSORED));
1831 if (pci && (INT) pci != -1 &&
1832 (!(driveflags[toupper(*pci->pszFileName) - 'A'] &
1833 DRIVE_SLOW)))
1834 WinSendMsg(hwndMain, UM_LOADFILE, MPFROMP(pci->pszFileName),
1835 MPVOID);
1836 else
1837 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1838 }
1839 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1840 }
1841 else if (empty)
1842 *dcd->mask.szMask = 0;
1843 SayFilter(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1844 DIR_FILTER), &dcd->mask, FALSE);
1845 }
1846 break;
1847
1848 case IDM_UNHIDEALL:
1849 WinSendMsg(hwnd, CM_FILTER, MPFROMP(Filter), MPFROMP(&dcd->mask));
1850 break;
1851
1852 case IDM_HIDEALL:
1853 if (fAutoView && hwndMain)
1854 PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
1855 dcd->suspendview = 1;
1856 HideAll(hwnd);
1857 dcd->suspendview = 0;
1858 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
1859 break;
1860
1861 case IDM_SELECTLIST:
1862 case IDM_SELECTALL:
1863 case IDM_DESELECTALL:
1864 case IDM_SELECTALLFILES:
1865 case IDM_DESELECTALLFILES:
1866 case IDM_SELECTALLDIRS:
1867 case IDM_DESELECTALLDIRS:
1868 case IDM_SELECTMASK:
1869 case IDM_DESELECTMASK:
1870 case IDM_INVERT:
1871 case IDM_SELECTCLIP:
1872 case IDM_DESELECTCLIP:
1873 {
1874 PCNRITEM pci;
1875
1876 pci = (PCNRITEM) CurrentRecord(hwnd);
1877 if ((INT) pci == -1)
1878 pci = NULL;
1879 if (SHORT1FROMMP(mp1) == IDM_HIDEALL) {
1880 if (pci) {
1881 if (!(pci->rc.flRecordAttr & CRA_SELECTED))
1882 pci->rc.flRecordAttr |= CRA_FILTERED;
1883 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPFROMP(&pci),
1884 MPFROM2SHORT(1, CMA_ERASE | CMA_REPOSITION));
1885 break;
1886 }
1887 }
1888 PostMsg(dcd->hwndObject, UM_SELECT, mp1, MPFROMP(pci));
1889 }
1890 break;
1891
1892 case IDM_RESCAN:
1893 PostMsg(dcd->hwndObject, UM_RESCAN, MPVOID, MPVOID);
1894 break;
1895
1896 case IDM_SHOWLNAMES:
1897 case IDM_SHOWSUBJECT:
1898 case IDM_SHOWEAS:
1899 case IDM_SHOWSIZE:
1900 case IDM_SHOWICON:
1901 case IDM_SHOWLWDATE:
1902 case IDM_SHOWLWTIME:
1903 case IDM_SHOWLADATE:
1904 case IDM_SHOWLATIME:
1905 case IDM_SHOWCRDATE:
1906 case IDM_SHOWCRTIME:
1907 case IDM_SHOWATTR:
1908 AdjustDetailsSwitches(hwnd, dcd->hwndLastMenu,
1909 SHORT1FROMMP(mp1), NULL,
1910 "Collector", dcd, FALSE);
1911 break;
1912
1913 case IDM_ICON:
1914 case IDM_TEXT:
1915 case IDM_DETAILS:
1916 case IDM_NAME:
1917 case IDM_MINIICONS:
1918 case IDM_DETAILSTITLES:
1919 {
1920 CNRINFO cnri;
1921
1922 memset(&cnri, 0, sizeof(CNRINFO));
1923 cnri.cb = sizeof(CNRINFO);
1924 WinSendMsg(hwnd, CM_QUERYCNRINFO, MPFROMP(&cnri),
1925 MPFROMLONG(sizeof(CNRINFO)));
1926 switch (SHORT1FROMMP(mp1)) {
1927 case IDM_ICON:
1928 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
1929 CV_DETAIL | CV_NAME));
1930 cnri.flWindowAttr |= CV_ICON;
1931 break;
1932 case IDM_NAME:
1933 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
1934 CV_DETAIL | CV_NAME));
1935 cnri.flWindowAttr |= CV_NAME;
1936 break;
1937 case IDM_TEXT:
1938 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
1939 CV_DETAIL | CV_NAME));
1940 cnri.flWindowAttr |= CV_TEXT;
1941 break;
1942 case IDM_DETAILS:
1943 cnri.flWindowAttr &= (~(CV_ICON | CV_TREE | CV_TEXT |
1944 CV_DETAIL | CV_NAME));
1945 cnri.flWindowAttr |= CV_DETAIL;
1946 break;
1947 case IDM_MINIICONS:
1948 if (cnri.flWindowAttr & CV_MINI)
1949 cnri.flWindowAttr &= (~CV_MINI);
1950 else
1951 cnri.flWindowAttr |= CV_MINI;
1952 break;
1953 case IDM_DETAILSTITLES:
1954 if (cnri.flWindowAttr & CA_DETAILSVIEWTITLES)
1955 cnri.flWindowAttr &= (~CA_DETAILSVIEWTITLES);
1956 else
1957 cnri.flWindowAttr |= CA_DETAILSVIEWTITLES;
1958 break;
1959 }
1960 cnri.flWindowAttr &= (~(CA_ORDEREDTARGETEMPH | CA_MIXEDTARGETEMPH));
1961 cnri.flWindowAttr |= CV_FLOW;
1962 dcd->flWindowAttr = cnri.flWindowAttr;
1963 PrfWriteProfileData(fmprof, appname, "CollectorflWindowAttr",
1964 &cnri.flWindowAttr, sizeof(ULONG));
1965 WinSendMsg(hwnd, CM_SETCNRINFO, MPFROMP(&cnri),
1966 MPFROMLONG(CMA_FLWINDOWATTR));
1967 WinSendMsg(hwnd, CM_INVALIDATERECORD, MPVOID,
1968 MPFROM2SHORT(0, CMA_ERASE | CMA_REPOSITION));
1969 SayView(WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
1970 DIR_VIEW), dcd->flWindowAttr);
1971 }
1972 break;
1973
1974 case IDM_SAVETOLIST:
1975 WinDlgBox(HWND_DESKTOP, hwnd, SaveListDlgProc, FM3ModHandle,
1976 SAV_FRAME, MPFROMP(&hwnd));
1977 break;
1978
1979 case IDM_SIZES:
1980 {
1981 PCNRITEM pci;
1982
1983 pci = (PCNRITEM) CurrentRecord(hwnd);
1984 if (pci && (INT) pci != -1)
1985 WinDlgBox(HWND_DESKTOP, HWND_DESKTOP, DirSizeProc, FM3ModHandle,
1986 DSZ_FRAME, pci->pszFileName);
1987 }
1988 break;
1989
1990 case IDM_MKDIR:
1991 {
1992 PCNRITEM pci;
1993
1994 pci = (PCNRITEM) CurrentRecord(hwnd);
1995 PMMkDir(dcd->hwndParent, (pci && (INT) pci != -1) ?
1996 pci->pszFileName : NULL, FALSE);
1997 }
1998 break;
1999
2000 case IDM_DOITYOURSELF:
2001 case IDM_UPDATE:
2002 case IDM_COLLECTFROMFILE:
2003 case IDM_OPENWINDOW:
2004 case IDM_OPENSETTINGS:
2005 case IDM_OPENDEFAULT:
2006 case IDM_OPENICON:
2007 case IDM_OPENDETAILS:
2008 case IDM_OPENTREE:
2009 case IDM_OBJECT:
2010 case IDM_SHADOW:
2011 case IDM_SHADOW2:
2012 case IDM_DELETE:
2013 case IDM_PERMDELETE:
2014 case IDM_PRINT:
2015 case IDM_ATTRS:
2016 case IDM_INFO:
2017 case IDM_COPY:
2018 case IDM_MOVE:
2019 case IDM_WPSCOPY:
2020 case IDM_WPSMOVE:
2021 case IDM_COPYPRESERVE:
2022 case IDM_MOVEPRESERVE:
2023 case IDM_WILDCOPY:
2024 case IDM_WILDMOVE:
2025 case IDM_RENAME:
2026 case IDM_COMPARE:
2027 case IDM_EAS:
2028 case IDM_SUBJECT:
2029 case IDM_VIEW:
2030 case IDM_VIEWTEXT:
2031 case IDM_VIEWBINARY:
2032 case IDM_VIEWARCHIVE:
2033 case IDM_EDIT:
2034 case IDM_EDITTEXT:
2035 case IDM_EDITBINARY:
2036 case IDM_SAVETOCLIP:
2037 case IDM_APPENDTOCLIP:
2038 case IDM_ARCHIVE:
2039 case IDM_ARCHIVEM:
2040 case IDM_EXTRACT:
2041 case IDM_MCIPLAY:
2042 case IDM_UUDECODE:
2043 case IDM_MERGE:
2044 {
2045 LISTINFO *li;
2046 ULONG action = UM_ACTION;
2047
2048 li = xmallocz(sizeof(LISTINFO), pszSrcFile, __LINE__);
2049 if (li) {
2050 li->type = SHORT1FROMMP(mp1);
2051 li->hwnd = hwnd;
2052 li->list = BuildList(hwnd);
2053 if (li->list) {
2054 switch (SHORT1FROMMP(mp1)) {
2055 case IDM_DOITYOURSELF:
2056 case IDM_APPENDTOCLIP:
2057 case IDM_SAVETOCLIP:
2058 case IDM_ARCHIVE:
2059 case IDM_ARCHIVEM:
2060 case IDM_DELETE:
2061 case IDM_PERMDELETE:
2062 case IDM_ATTRS:
2063 case IDM_PRINT:
2064 case IDM_SHADOW:
2065 case IDM_SHADOW2:
2066 case IDM_OBJECT:
2067 case IDM_VIEW:
2068 case IDM_VIEWTEXT:
2069 case IDM_VIEWBINARY:
2070 case IDM_EDIT:
2071 case IDM_EDITTEXT:
2072 case IDM_EDITBINARY:
2073 case IDM_MCIPLAY:
2074 case IDM_UPDATE:
2075 case IDM_INFO:
2076 case IDM_EAS:
2077 action = UM_MASSACTION;
2078 break;
2079 }
2080 if (li->type == IDM_SHADOW || li->type == IDM_OBJECT ||
2081 li->type == IDM_SHADOW2)
2082 *li->targetpath = 0;
2083 if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID)) {
2084 Runtime_Error(pszSrcFile, __LINE__, "PostMsg");
2085 FreeListInfo(li);
2086 }
2087 else if (fUnHilite)
2088 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2089 }
2090 else
2091 xfree(li);
2092 }
2093 }
2094 break;
2095
2096 default:
2097 if (!cmdloaded)
2098 load_commands();
2099 if (SHORT1FROMMP(mp1) >= IDM_COMMANDSTART &&
2100 SHORT1FROMMP(mp1) < IDM_QUICKTOOLSTART) {
2101 INT x;
2102
2103 x = SHORT1FROMMP(mp1) - IDM_COMMANDSTART;
2104 if (x >= 0) {
2105 x++;
2106 RunCommand(hwnd, x);
2107 if (fUnHilite)
2108 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2109 }
2110 }
2111 break;
2112 }
2113 }
2114 return 0;
2115
2116 case UM_FIXCNRMLE:
2117 case UM_FIXEDITNAME:
2118 return CommonCnrProc(hwnd, msg, mp1, mp2);
2119
2120 case UM_FILESMENU:
2121 {
2122 PCNRITEM pci;
2123 HWND menuHwnd = (HWND) 0;
2124
2125 pci = (PCNRITEM) CurrentRecord(hwnd);
2126 if (pci && (INT) pci != -1) {
2127 if (pci->attrFile & FILE_DIRECTORY)
2128 menuHwnd = CheckMenu(hwnd, &CollectorDirMenu, COLLECTORDIR_POPUP);
2129 else
2130 menuHwnd = CheckMenu(hwnd, &CollectorFileMenu, COLLECTORFILE_POPUP);
2131 }
2132 return MRFROMLONG(menuHwnd);
2133 }
2134
2135 case WM_CONTROL:
2136 DosError(FERR_DISABLEHARDERR);
2137 if (dcd) {
2138 switch (SHORT2FROMMP(mp1)) {
2139 case CN_CONTEXTMENU:
2140 {
2141 PCNRITEM pci = (PCNRITEM) mp2;
2142
2143 if (pci) {
2144 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPFROMP(pci),
2145 MPFROM2SHORT(TRUE, CRA_CURSORED));
2146 MarkAll(hwnd, FALSE, FALSE, TRUE);
2147 if (pci->attrFile & FILE_DIRECTORY)
2148 dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorDirMenu,
2149 COLLECTORDIR_POPUP);
2150 else
2151 dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorFileMenu,
2152 COLLECTORFILE_POPUP);
2153 }
2154 else {
2155 dcd->hwndLastMenu = CheckMenu(hwnd, &CollectorCnrMenu,
2156 COLLECTORCNR_POPUP);
2157 if (dcd->hwndLastMenu && !dcd->cnremphasized) {
2158 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
2159 MPFROM2SHORT(TRUE, CRA_SOURCE));
2160 dcd->cnremphasized = TRUE;
2161 }
2162 }
2163 if (dcd->hwndLastMenu) {
2164 if (dcd->hwndLastMenu == CollectorCnrMenu) {
2165 SetViewMenu(dcd->hwndLastMenu, dcd->flWindowAttr);
2166 SetDetailsSwitches(dcd->hwndLastMenu, dcd);
2167 CopyPresParams(dcd->hwndLastMenu, hwnd);
2168 if (dcd->flWindowAttr & CV_MINI)
2169 WinCheckMenuItem(dcd->hwndLastMenu, IDM_MINIICONS, TRUE);
2170 disable_menuitem(dcd->hwndLastMenu, DID_CANCEL,
2171 !dcd->amextracted);
2172 disable_menuitem(dcd->hwndLastMenu, IDM_GREP, dcd->amextracted);
2173 }
2174 if (!PopupMenu(hwnd, hwnd, dcd->hwndLastMenu)) {
2175 if (dcd->cnremphasized) {
2176 WinSendMsg(hwnd, CM_SETRECORDEMPHASIS, MPVOID,
2177 MPFROM2SHORT(FALSE, CRA_SOURCE));
2178 dcd->cnremphasized = TRUE;
2179 }
2180 MarkAll(hwnd, TRUE, FALSE, TRUE);
2181 }
2182 }
2183 }
2184 break;
2185
2186 case CN_DROPHELP:
2187 if (mp2) {
2188 PDRAGINFO pDInfo;
2189 PCNRITEM pci;
2190 ULONG numitems;
2191 USHORT usOperation;
2192
2193 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2194 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2195 if (!DrgAccessDraginfo(pDInfo)) {
2196 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2197 "DrgAccessDraginfo");
2198 return 0;
2199 }
2200 numitems = DrgQueryDragitemCount(pDInfo);
2201 usOperation = pDInfo->usOperation;
2202 FreeDragInfoData(hwnd, pDInfo);
2203 saymsg(MB_ENTER | MB_ICONASTERISK,
2204 hwnd,
2205 GetPString(IDS_DROPHELPHDRTEXT),
2206 GetPString(IDS_DROPHELPTEXT),
2207 numitems,
2208 &"s"[numitems == 1],
2209 (pci) ? NullStr : GetPString(IDS_NOTEXT),
2210 (pci) ? NullStr : " ",
2211 (pci) ? pci->pszFileName : NullStr,
2212 (pci) ? " " : NullStr,
2213 GetPString((usOperation == DO_COPY) ?
2214 IDS_COPYTEXT :
2215 (usOperation == DO_LINK) ?
2216 IDS_LINKTEXT : IDS_MOVETEXT));
2217 }
2218 return 0;
2219
2220 case CN_DRAGLEAVE:
2221 if (mp2) {
2222 PDRAGINFO pDInfo;
2223
2224 // fixme to know why needed
2225 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2226 DrgAccessDraginfo(pDInfo); /* Access DRAGINFO */
2227 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2228 }
2229 return 0;
2230
2231 case CN_DRAGAFTER:
2232 case CN_DRAGOVER:
2233 if (mp2) {
2234 PDRAGITEM pDItem; /* Pointer to DRAGITEM */
2235 PDRAGINFO pDInfo; /* Pointer to DRAGINFO */
2236 PCNRITEM pci;
2237 USHORT uso;
2238
2239 pci = (PCNRITEM) ((PCNRDRAGINFO) mp2)->pRecord;
2240 // if(SHORT1FROMMP(mp1) == CN_DRAGAFTER)
2241 // pci = NULL;
2242 pDInfo = ((PCNRDRAGINFO) mp2)->pDragInfo;
2243 if (!DrgAccessDraginfo(pDInfo)) {
2244 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__,
2245 "DrgAccessDraginfo");
2246 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
2247 }
2248 if (pci) {
2249 if (pci->rc.flRecordAttr & CRA_SOURCE) {
2250 DrgFreeDraginfo(pDInfo);
2251 return (MRFROM2SHORT(DOR_NODROP, 0));
2252 }
2253 uso = pDInfo->usOperation;
2254 if (uso == DO_DEFAULT)
2255 uso = (fCopyDefault) ? DO_COPY : DO_MOVE;
2256 if (!(pci->attrFile & FILE_DIRECTORY)) {
2257 if (uso != DO_LINK && uso != DO_MOVE && uso != DO_COPY) {
2258 DrgFreeDraginfo(pDInfo);
2259 return MRFROM2SHORT(DOR_NODROP, 0);
2260 }
2261 if (uso != DO_LINK &&
2262 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2263 DRIVE_NOTWRITEABLE)) {
2264 ARC_TYPE *info = NULL;
2265
2266 if (!fQuickArcFind &&
2267 !(driveflags[toupper(*pci->pszFileName) - 'A'] &
2268 DRIVE_SLOW))
2269 info = find_type(pci->pszFileName, NULL);
2270 else
2271 info = quick_find_type(pci->pszFileName, NULL);
2272 if (!info || ((uso == DO_MOVE && !info->move) ||
2273 (uso == DO_COPY && !info->create))) {
2274 DrgFreeDraginfo(pDInfo);
2275 return MRFROM2SHORT(DOR_NODROP, 0);
2276 }
2277 }
2278 }
2279 }
2280 pDItem = DrgQueryDragitemPtr(pDInfo, /* Access DRAGITEM */
2281 0); /* Index to DRAGITEM */
2282 if (DrgVerifyRMF(pDItem, /* Check valid rendering */
2283 DRM_OS2FILE, /* mechanisms and data */
2284 NULL)) {
2285 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2286 if (pci) {
2287 if (driveflags[toupper(*pci->pszFileName) - 'A'] &
2288 DRIVE_NOTWRITEABLE)
2289 return MRFROM2SHORT(DOR_DROP, DO_LINK);
2290 if (toupper(*pci->pszFileName) < 'C')
2291 return MRFROM2SHORT(DOR_DROP, DO_COPY);
2292 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
2293 ((fCopyDefault) ? DO_COPY : DO_MOVE));
2294 }
2295 else
2296 return MRFROM2SHORT(DOR_DROP, /* Return okay to drop */
2297 DO_COPY);
2298 }
2299 DrgFreeDraginfo(pDInfo); /* Free DRAGINFO */
2300 }
2301 return (MRFROM2SHORT(DOR_NODROP, 0)); /* Drop not valid */
2302
2303 case CN_INITDRAG:
2304 if (mp2) {
2305 BOOL wasemphasized = FALSE;
2306 PCNRDRAGINIT pcd = (PCNRDRAGINIT) mp2;
2307 PCNRITEM pci;
2308
2309 if (pcd) {
2310 pci = (PCNRITEM) pcd->pRecord;
2311 if (pci) {
2312 if (pci->rc.flRecordAttr & CRA_SELECTED)
2313 wasemphasized = TRUE;
2314 if (IsRoot(pci->pszFileName))
2315 break;
2316 if (hwndStatus2)
2317 WinSetWindowText(hwndStatus2,
2318 GetPString(IDS_DRAGFILEOBJTEXT));
2319 if (DoFileDrag(hwnd, dcd->hwndObject, mp2, NULL, NULL, TRUE)) {
2320 if ((fUnHilite && wasemphasized) || dcd->ulItemsToUnHilite)
2321 UnHilite(hwnd, TRUE, &dcd->lastselection, dcd->ulItemsToUnHilite);
2322 }
2323 if (hwndStatus2)
2324 PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
2325 }
2326 }
2327 }
2328 return 0;
2329
2330 case CN_DROP:
2331 if (mp2) {
2332 LISTINFO *li;
2333 ULONG action = UM_ACTION;
2334
2335 li = DoFileDrop(hwnd, NULL, TRUE, mp1, mp2);
2336 CheckPmDrgLimit(((PCNRDRAGINFO)mp2)->pDragInfo);
2337 if (li) {
2338 if (!*li->targetpath) {
2339 li->type = IDM_COLLECT;
2340 action = UM_COLLECT;
2341 }
2342 else {
2343 if (li->list && li->list[0] && IsRoot(li->list[0]))
2344 li->type = DO_LINK;
2345 else if (fDragndropDlg && (!*li->arcname || !li->info)) {
2346 CHECKLIST cl;
2347
2348 memset(&cl, 0, sizeof(cl));
2349 cl.size = sizeof(cl);
2350 cl.flags = li->type;
2351 cl.list = li->list;
2352 cl.cmd = li->type;
2353 cl.prompt = li->targetpath;
2354 li->type = WinDlgBox(HWND_DESKTOP, dcd->hwndParent,
2355 DropListProc, FM3ModHandle,
2356 DND_FRAME, MPFROMP(&cl));
2357 if (li->type == DID_ERROR)
2358 Win_Error(DND_FRAME, HWND_DESKTOP, pszSrcFile, __LINE__,
2359 "Drag & Drop Dialog");
2360 if (!li->type) {
2361 FreeListInfo(li);
2362 return 0;
2363 }
2364 li->list = cl.list;
2365 if (!li->list || !li->list[0]) {
2366 FreeListInfo(li);
2367 return 0;
2368 }
2369 }
2370 switch (li->type) {
2371 case DND_LAUNCH:
2372 strcat(li->targetpath, " %a");
2373 ExecOnList(dcd->hwndParent, li->targetpath,
2374 PROMPT | WINDOWED, NULL, li->list, NULL,
2375 pszSrcFile, __LINE__);
2376 FreeList(li->list);
2377 li->list = NULL;
2378 break;
2379 case DO_LINK:
2380 if (fLinkSetsIcon) {
2381 li->type = IDM_SETICON;
2382 action = UM_MASSACTION;
2383 }
2384 else
2385 li->type = IDM_COMPARE;
2386 break;
2387 case DND_EXTRACT:
2388 if (*li->targetpath && !IsFile(li->targetpath))
2389 li->type = IDM_EXTRACT;
2390 break;
2391 case DND_MOVE:
2392 li->type = IDM_MOVE;
2393 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2394 action = UM_MASSACTION;
2395 li->type = IDM_ARCHIVEM;
2396 }
2397 break;
2398 case DND_WILDMOVE:
2399 li->type = IDM_WILDMOVE;
2400 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2401 action = UM_MASSACTION;
2402 li->type = IDM_ARCHIVEM;
2403 }
2404 break;
2405 case DND_OBJECT:
2406 li->type = IDM_OBJECT;
2407 action = UM_MASSACTION;
2408 break;
2409 case DND_SHADOW:
2410 li->type = IDM_SHADOW;
2411 action = UM_MASSACTION;
2412 break;
2413 case DND_COMPARE:
2414 li->type = IDM_COMPARE;
2415 break;
2416 case DND_SETICON:
2417 action = UM_MASSACTION;
2418 li->type = IDM_SETICON;
2419 break;
2420 case DND_WILDCOPY:
2421 li->type = IDM_WILDCOPY;
2422 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2423 action = UM_MASSACTION;
2424 li->type = IDM_ARCHIVE;
2425 }
2426 break;
2427 case DND_COPY:
2428 li->type = IDM_COPY;
2429 if (*li->targetpath && IsFile(li->targetpath) == 1) {
2430 action = UM_MASSACTION;
2431 li->type = IDM_ARCHIVE;
2432 }
2433 break;
2434 default:
2435 if (*li->arcname && li->info) {
2436 action = UM_MASSACTION;
2437 li->type =
2438 (li->type ==
2439 DO_MOVE) ? IDM_FAKEEXTRACTM : IDM_FAKEEXTRACT;
2440 }
2441 else if (*li->targetpath && IsFile(li->targetpath) == 1) {
2442 action = UM_MASSACTION;
2443 li->type =
2444 (li->type == DO_MOVE) ? IDM_ARCHIVEM : IDM_ARCHIVE;
2445 }
2446 else
2447 li->type = (li->type == DO_MOVE) ? IDM_MOVE : IDM_COPY;
2448 break;
2449 }
2450 }
2451 if (!li->list || !li->list[0])
2452 FreeListInfo(li);
2453 else if (!PostMsg(dcd->hwndObject, action, MPFROMP(li), MPVOID))
2454 FreeListInfo(li);
2455 else {
2456 USHORT usop = 0;
2457
2458 switch (li->type) {
2459 case IDM_COPY:
2460 case IDM_WILDCOPY:
2461 usop = DO_COPY;
2462 break;
2463 case IDM_MOVE:
2464 case IDM_WILDMOVE:
2465 case IDM_ARCHIVEM:
2466 usop = DO_MOVE;
2467 break;
2468 }
2469 if (usop)
2470 return MRFROM2SHORT(DOR_DROP, usop);
2471 }
2472 }
2473 }
2474 return 0;
2475
2476 case CN_BEGINEDIT:
2477 case CN_REALLOCPSZ:
2478 case CN_ENDEDIT:
2479 {
2480 MRESULT mre;
2481
2482 mre = CnrDirectEdit(hwnd, msg, mp1, mp2);
2483 if (mre != (MRESULT) - 1)
2484 return mre;
2485 }
2486 break;
2487
2488 case CN_EMPHASIS:
2489 if (mp2) {
2490 PNOTIFYRECORDEMPHASIS pre = mp2;
2491 PCNRITEM pci;
2492 CHAR s[CCHMAXPATH + 91], tb[81], tf[81], *p;
2493
2494 pci = (PCNRITEM) ((pre) ? pre->pRecord : NULL);
2495 if (!pci) {
2496 if (hwndStatus2)
2497 WinSetWindowText(hwndStatus2, NullStr);
2498 if (fMoreButtons) {
2499 WinSetWindowText(hwndName, NullStr);
2500 WinSetWindowText(hwndDate, NullStr);
2501 WinSetWindowText(hwndAttr, NullStr);
2502 }
2503 if (hwndMain)
2504 WinSendMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
2505 break;
2506 }
2507 if (pre->fEmphasisMask & CRA_SELECTED) {
2508 if (pci->rc.flRecordAttr & CRA_SELECTED) {
2509 dcd->selectedbytes += (pci->cbFile + pci->easize);
2510 dcd->selectedfiles++;
2511 }
2512 else if (dcd->selectedfiles) {
2513 dcd->selectedbytes -= (pci->cbFile + pci->easize);
2514 dcd->selectedfiles--;
2515 }
2516 if (!dcd->suspendview) {
2517 commafmt(tf, sizeof(tf), dcd->selectedfiles);
2518 CommaFmtULL(tb, sizeof(tb), dcd->selectedbytes, ' ');
2519 sprintf(s, "%s / %s", tf, tb);
2520 WinSetDlgItemText(dcd->hwndClient, DIR_SELECTED, s);
2521 }
2522 }
2523 if (!dcd->suspendview &&
2524 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame) {
2525 if (pre->fEmphasisMask & CRA_CURSORED) {
2526 if (pci->rc.flRecordAttr & CRA_CURSORED) {
2527 if (fSplitStatus && hwndStatus2) {
2528 if (pci->attrFile & FILE_DIRECTORY)
2529 p = pci->pszFileName;
2530 else {
2531 p = strrchr(pci->pszFileName, '\\');
2532 if (p) {
2533 if (*(p + 1))
2534 p++;
2535 else
2536 p = pci->pszFileName;
2537 }
2538 else
2539 p = pci->pszFileName;
2540 }
2541 CommaFmtULL(tb, sizeof(tb), pci->cbFile + pci->easize, ' ');
2542 if (!fMoreButtons)
2543 sprintf(s, " %s %04u/%02u/%02u %02u:%02u:%02u [%s] %s",
2544 tb, pci->date.year,
2545 pci->date.month, pci->date.day, pci->time.hours,
2546 pci->time.minutes, pci->time.seconds,
2547 pci->pszDispAttr, p);
2548 else {
2549 if (pci->cbFile + pci->easize > 1024)
2550 CommaFmtULL(tf, sizeof(tf), pci->cbFile + pci->easize,
2551 ' ');
2552 else
2553 *tf = 0;
2554 sprintf(s, GetPString(IDS_STATUSSIZETEXT),
2555 tb,
2556 *tf ? " (" : NullStr, tf, *tf ? ")" : NullStr);
2557 }
2558 WinSetWindowText(hwndStatus2, s);
2559 }
2560 if (fMoreButtons) {
2561 WinSetWindowText(hwndName, pci->pszFileName);
2562 sprintf(s, "%04u/%02u/%02u %02u:%02u:%02u",
2563 pci->date.year, pci->date.month,
2564 pci->date.day, pci->time.hours, pci->time.minutes,
2565 pci->time.seconds);
2566 WinSetWindowText(hwndDate, s);
2567 WinSetWindowText(hwndAttr, pci->pszDispAttr);
2568 }
2569 }
2570 }
2571 }
2572 if (!dcd->suspendview && hwndMain &&
2573 (pre->fEmphasisMask & CRA_CURSORED) &&
2574 (pci->rc.flRecordAttr & CRA_CURSORED) &&
2575 WinQueryActiveWindow(dcd->hwndParent) == dcd->hwndFrame)
2576 WinSendMsg(hwndMain, UM_LOADFILE,
2577 MPFROMP(((fComments
2578 || (pci->attrFile & FILE_DIRECTORY) ==
2579 0) ? pci->pszFileName : NULL)), MPVOID);
2580 }
2581 break;
2582
2583 case CN_ENTER:
2584 if (mp2) {
2585 PCNRITEM pci = (PCNRITEM) ((PNOTIFYRECORDENTER) mp2)->pRecord;
2586 FILEFINDBUF3 ffb;
2587 HDIR hDir = HDIR_CREATE;
2588 ULONG nm = 1;
2589 APIRET status = 0;
2590
2591 SetShiftState();
2592 if (pci) {
2593 if (pci->rc.flRecordAttr & CRA_INUSE)
2594 break;
2595 DosError(FERR_DISABLEHARDERR);
2596 status = DosFindFirst(pci->pszFileName, &hDir,
2597 FILE_NORMAL | FILE_DIRECTORY |
2598 FILE_ARCHIVED | FILE_READONLY |
2599 FILE_HIDDEN | FILE_SYSTEM,
2600 &ffb, sizeof(ffb), &nm, FIL_STANDARD);
2601 priority_bumped();
2602 if (!status) {
2603 DosFindClose(hDir);
2604 if (ffb.attrFile & FILE_DIRECTORY) {
2605 if ((shiftstate & (KC_CTRL | KC_ALT)) == (KC_CTRL | KC_ALT))
2606 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IDM_SHOWALLFILES, 0),
2607 MPVOID);
2608 else if ((shiftstate & (KC_CTRL | KC_SHIFT)) ==
2609 (KC_CTRL | KC_SHIFT))
2610 OpenObject(pci->pszFileName, Settings, dcd->hwndFrame);
2611 else if (shiftstate & KC_CTRL)
2612 OpenObject(pci->pszFileName, Default, dcd->hwndFrame);
2613 else
2614 OpenDirCnr(HWND_DESKTOP,
2615 hwndMain,
2616 dcd->hwndFrame, FALSE, pci->pszFileName);
2617 }
2618 else {
2619 SWP swp;
2620
2621 WinSendMsg(hwnd,
2622 CM_SETRECORDEMPHASIS,
2623 MPFROMP(pci), MPFROM2SHORT(TRUE, CRA_INUSE));
2624 WinQueryWindowPos(dcd->hwndFrame, &swp);
2625 DefaultViewKeys(hwnd,
2626 dcd->hwndFrame,
2627 dcd->hwndParent, &swp, pci->pszFileName);
2628 WinSendMsg(hwnd,
2629 CM_SETRECORDEMPHASIS,
2630 MPFROMP(pci),
2631 MPFROM2SHORT(FALSE, CRA_INUSE |
2632 ((fUnHilite) ? CRA_SELECTED : 0)));
2633 }
2634 }
2635 else
2636 RemoveCnrItems(hwnd, pci, 1, CMA_FREE | CMA_INVALIDATE | CMA_ERASE);
2637 }
2638 }
2639 break;
2640 }
2641 }
2642 return 0;
2643
2644 case UM_LOADFILE:
2645 if (dcd && mp2) {
2646 HWND ret;
2647
2648 ret = StartMLEEditor(dcd->hwndParent,
2649 (INT) mp1, (CHAR *) mp2, dcd->hwndFrame);
2650 xfree((CHAR *) mp2);
2651 return MRFROMLONG(ret);
2652 }
2653 return 0;
2654
2655 case UM_CLOSE:
2656 WinDestroyWindow(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
2657 QW_PARENT));
2658 return 0;
2659
2660 case UM_FOLDUP:
2661 if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
2662 DosExit(EXIT_PROCESS, 1);
2663 return 0;
2664
2665 case WM_CLOSE:
2666 if (dcd) {
2667 dcd->namecanchange = TRUE;
2668 dcd->stopflag = 1;
2669 if (dcd->amextracted)
2670 return 0; // Can not close yet
2671 }
2672 WinSendMsg(hwnd, WM_SAVEAPPLICATION, MPVOID, MPVOID);
2673 if (dcd) {
2674 if (!dcd->dontclose && ParentIsDesktop(hwnd, dcd->hwndParent))
2675 PostMsg(hwnd, UM_FOLDUP, MPVOID, MPVOID);
2676 if (dcd->hwndObject) {
2677 DosSleep(32); // Allow UM_FOLDUP to process
2678 if (!PostMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID))
2679 WinSendMsg(dcd->hwndObject, WM_CLOSE, MPVOID, MPVOID);
2680 }
2681 }
2682 else
2683 WinSendMsg(hwnd, UM_CLOSE, MPVOID, MPVOID);
2684 return 0;
2685
2686 case WM_DESTROY:
2687 if (CollectorDirMenu)
2688 WinDestroyWindow(CollectorDirMenu);
2689 if (CollectorFileMenu)
2690 WinDestroyWindow(CollectorFileMenu);
2691 if (CollectorCnrMenu)
2692 WinDestroyWindow(CollectorCnrMenu);
2693 CollectorCnrMenu = CollectorFileMenu = CollectorDirMenu = (HWND) 0;
2694 Collector = (HWND) 0;
2695 EmptyCnr(hwnd);
2696 break;
2697 }
2698 if (dcd && dcd->oldproc){
2699 return dcd->oldproc(hwnd, msg, mp1, mp2);
2700 }
2701 else
2702 return PFNWPCnr(hwnd, msg, mp1, mp2);
2703}
2704
2705MRESULT EXPENTRY CollectorMenuProc(HWND hwnd, ULONG msg, MPARAM mp1,
2706 MPARAM mp2)
2707{
2708 PFNWP oldMenuProc = WinQueryWindowPtr(hwnd, QWL_USER);
2709 static short sLastMenuitem;
2710
2711 switch (msg) {
2712 case WM_MOUSEMOVE: {
2713 if (fOtherHelp) {
2714 RECTL rectl;
2715 SHORT i, sCurrentMenuitem;
2716 SHORT MenuItems = 5;
2717 SHORT asMenuIDs[5] = {IDM_GREP,
2718 IDM_SEEALL,
2719 IDM_CLEARCNR,
2720 IDM_REMOVE,
2721 0};
2722 char *szHelpString = NULL;
2723
2724
2725 for (i=0; i<MenuItems; i++) {
2726 sCurrentMenuitem = asMenuIDs[i];
2727 oldMenuProc(hwnd,MM_QUERYITEMRECT,
2728 MPFROM2SHORT(asMenuIDs[i], FALSE),
2729 &rectl);
2730
2731 if (MOUSEMSG(&msg)->x > rectl.xLeft &&
2732 MOUSEMSG(&msg)->x < rectl.xRight &&
2733 MOUSEMSG(&msg)->y > rectl.yBottom &&
2734 MOUSEMSG(&msg)->y < rectl.yTop)
2735 break;
2736 } // for
2737
2738
2739 switch (sCurrentMenuitem) {
2740 case 0:
2741 break;
2742 case IDM_GREP:
2743 szHelpString = GetPString(IDS_COLMENUSEEKSCANHELP);
2744 break;
2745 case IDM_SEEALL:
2746 szHelpString = GetPString(IDS_COLMENUSEEALLHELP);
2747 break;
2748 case IDM_CLEARCNR:
2749 szHelpString = GetPString(IDS_COLMENUCLEARCNRHELP);
2750 break;
2751 case IDM_REMOVE:
2752 szHelpString = GetPString(IDS_COLMENUREMOVECNRHELP);
2753 break;
2754 default:
2755 break;
2756 }
2757
2758 if (sLastMenuitem != sCurrentMenuitem && szHelpString) {
2759 sLastMenuitem = sCurrentMenuitem;
2760 MakeBubble(hwnd, TRUE, szHelpString);
2761 }
2762 else if (hwndBubble && !sCurrentMenuitem){
2763 sLastMenuitem = sCurrentMenuitem;
2764 WinDestroyWindow(hwndBubble);
2765 }
2766 }
2767 }
2768 }
2769 return oldMenuProc(hwnd, msg, mp1, mp2);
2770}
2771
2772HWND StartCollector(HWND hwndParent, INT flags)
2773{
2774 HWND hwndFrame = (HWND) 0;
2775 HWND hwndClient;
2776 ULONG FrameFlags = FCF_TITLEBAR | FCF_SYSMENU |
2777 FCF_SIZEBORDER | FCF_MINMAX | FCF_ICON | FCF_NOBYTEALIGN | FCF_ACCELTABLE;
2778 USHORT id;
2779 DIRCNRDATA *dcd;
2780
2781 static USHORT idinc = 0;
2782
2783 if (ParentIsDesktop(hwndParent, hwndParent))
2784 FrameFlags |= (FCF_TASKLIST | FCF_SHELLPOSITION | FCF_MENU);
2785 if (Collector) {
2786 WinSetWindowPos(WinQueryWindow(WinQueryWindow(Collector,
2787 QW_PARENT),
2788 QW_PARENT),
2789 HWND_TOP, 0, 0, 0, 0, SWP_SHOW | SWP_RESTORE);
2790 return WinQueryWindow(WinQueryWindow(Collector, QW_PARENT), QW_PARENT);
2791 }
2792 hwndFrame = WinCreateStdWindow(hwndParent,
2793 WS_VISIBLE,
2794 &FrameFlags,
2795 WC_COLLECTOR,
2796 NULL,
2797 WS_VISIBLE | fwsAnimate,
2798 FM3ModHandle, COLLECTOR_FRAME, &hwndClient);
2799 if (hwndFrame && hwndClient) {
2800 id = COLLECTOR_FRAME + idinc++;
2801 WinSetWindowUShort(hwndFrame, QWS_ID, id);
2802 dcd = xmallocz(sizeof(DIRCNRDATA), pszSrcFile, __LINE__);
2803 if (!dcd) {
2804 Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
2805 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
2806 hwndFrame = (HWND) 0;
2807 }
2808 else {
2809 dcd->size = sizeof(DIRCNRDATA);
2810 dcd->id = id;
2811 dcd->type = COLLECTOR_FRAME;
2812 dcd->hwndParent = (hwndParent) ? hwndParent : HWND_DESKTOP;
2813 dcd->hwndFrame = hwndFrame;
2814 dcd->hwndClient = hwndClient;
2815 if (flags & 4)
2816 dcd->dontclose = TRUE;
2817 {
2818 PFNWP oldproc;
2819
2820 oldproc = WinSubclassWindow(hwndFrame, (PFNWP) CollectorFrameWndProc);
2821 WinSetWindowPtr(hwndFrame, QWL_USER, (PVOID) oldproc);
2822 }
2823 dcd->hwndCnr = WinCreateWindow(hwndClient,
2824 WC_CONTAINER,
2825 NULL,
2826 CCS_AUTOPOSITION | CCS_MINIICONS |
2827 CCS_MINIRECORDCORE | ulCnrType |
2828 WS_VISIBLE,
2829 0,
2830 0,
2831 0,
2832 0,
2833 hwndClient,
2834 HWND_TOP,
2835 (ULONG) COLLECTOR_CNR, NULL, NULL);
2836 if (!dcd->hwndCnr) {
2837 Win_Error2(hwndClient, hwndClient, pszSrcFile, __LINE__,
2838 IDS_WINCREATEWINDOW);
2839 PostMsg(hwndClient, WM_CLOSE, MPVOID, MPVOID);
2840 xfree(dcd);
2841 hwndFrame = (HWND) 0;
2842 }
2843 else {
2844 Collector = dcd->hwndCnr;
2845 WinSetWindowPtr(dcd->hwndCnr, QWL_USER, (PVOID) dcd);
2846 WinSetWindowText(hwndFrame, GetPString(IDS_COLLECTORTITLETEXT));
2847 if (FrameFlags & FCF_MENU) {
2848 PFNWP oldmenuproc;
2849 HWND hwndMenu = WinWindowFromID(hwndFrame, FID_MENU);
2850
2851 oldmenuproc = WinSubclassWindow(hwndMenu, (PFNWP) CollectorMenuProc);
2852 WinSetWindowPtr(hwndMenu, QWL_USER, (PVOID) oldmenuproc);
2853 if (!fToolbar) {
2854 if (hwndMenu) {
2855
2856 WinSendMsg(hwndMenu,
2857 MM_DELETEITEM,
2858 MPFROM2SHORT(IDM_SEEALL, FALSE), MPVOID);
2859 WinSendMsg(hwndMenu,
2860 MM_DELETEITEM,
2861 MPFROM2SHORT(IDM_GREP, FALSE), MPVOID);
2862 WinSendMsg(hwndMenu,
2863 MM_DELETEITEM,
2864 MPFROM2SHORT(IDM_CLEARCNR, FALSE), MPVOID);
2865 WinSendMsg(hwndMenu,
2866 MM_DELETEITEM,
2867 MPFROM2SHORT(IDM_REMOVE, FALSE), MPVOID);
2868 }
2869 }
2870 }
2871 dcd->oldproc = WinSubclassWindow(dcd->hwndCnr,
2872 (PFNWP) CollectorCnrWndProc);
2873 {
2874 USHORT ids[] = { DIR_TOTALS,
2875 DIR_SELECTED,
2876 DIR_VIEW,
2877 DIR_SORT,
2878 DIR_FILTER,
2879 0
2880 };
2881
2882 CommonCreateTextChildren(dcd->hwndClient,
2883 WC_COLSTATUS, ids);
2884 }
2885 if (FrameFlags & FCF_SHELLPOSITION)
2886 PostMsg(hwndClient, UM_SIZE, MPVOID, MPVOID);
2887 if (!PostMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID))
2888 WinSendMsg(dcd->hwndCnr, UM_SETUP, MPVOID, MPVOID);
2889 }
2890 }
2891 }
2892 return hwndFrame;
2893}
2894
2895#pragma alloc_text(COLLECTOR,CollectorCnrWndProc,CollectorObjWndProc)
2896#pragma alloc_text(COLLECTOR,CollectorClientWndProc,CollectorTextProc)
2897#pragma alloc_text(COLLECTOR,CollectorFrameWndProc)
2898#pragma alloc_text(STARTUP,StartCollector)
Note: See TracBrowser for help on using the repository browser.