source: trunk/dll/collect.c@ 956

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

Fix attempt to free container items that were never inserted. Fix "collect" so it updates recollected files and unhides them if needed. (Ticket 220)

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