Changeset 1444 for trunk/dll/worker.c


Ignore:
Timestamp:
Jul 23, 2009, 1:24:23 AM (16 years ago)
Author:
Gregg Young
Message:

Rework of drivebar to rescan all drives and refresh media buttons and menu items grey out inappropriate menu items. Streamline Tree scan code and use semaphores to serialize access. Add NOEASUPPORT and LOCALHD driveflag; .LONGNAME usage fixes; (Tickets 377-386)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/worker.c

    r1438 r1444  
    5454#define INCL_DOS
    5555#define INCL_DOSERRORS
    56 #define INCL_WINPROGRAMLIST
    57 #define INCL_WINHELP
     56// #define INCL_WINPROGRAMLIST          // 13 Jul 09 SHL dropped
     57// #define INCL_WINHELP                 // 13 Jul 09 SHL dropped
    5858#define INCL_LONGLONG
    59 #define INCL_WINPOINTERS
    60 #define INCL_WINWORKPLACE
    61 #define INCL_WINSHELLDATA
     59#define INCL_WINPOINTERS                // WinSetFileIcon
     60// #define INCL_WINWORKPLACE            // 13 Jul 09 SHL dropped
     61#define INCL_WINSHELLDATA               // PrfQueryProfileData
     62#define INCL_WINTIMER                   // WinStarTimer
     63#define INCL_WININPUT                   // WinQueryFocus
    6264
    6365#include "fm3dll.h"
     
    103105#include "avl.h"                        // SBoxDlgProc
    104106#include "subj.h"                       // Subject
     107#include "grep.h"                       // hwndStatus
    105108#include "stristr.h"                    // stristr
    106109#include "wrappers.h"                   // xfopen
     
    195198  INT plen = 0;
    196199  CHAR *p, *pp;
     200  ULONG idTimerStarted = 0;
     201  BOOL fActionPosted = FALSE;
     202  HAB habForActions;
     203  HWND hwndForActions;
    197204  CHAR szQuotedDirName[CCHMAXPATH];
    198205  CHAR szQuotedFileName[CCHMAXPATH];
     
    216223          IncrThreadUsage();
    217224          *wildname = 0;
     225          // Do action specific preprocessing
    218226          switch (wk->li->type) {
    219227          case IDM_MERGE:
     
    322330            break;
    323331          }
     332          // Process each list item
    324333          if (wk->li && wk->li->list && wk->li->list[0]) {
     334            // char ucClassname[8];
     335            if (hwndStatus) {
     336              // Send update request to source window or container
     337              // 13 Jul 09 SHL fixme to be sure we pick window that understand UM_ACTIONSTATE wk->dcd->hwndCnr?
     338              // 13 Jul 09 SHL fixme to ensure focus window is one that understands UM_ACTIONSTATE
     339              HWND hwndFocus = WinQueryFocus(HWND_DESKTOP);
     340              DbgMsg(pszSrcFile, __LINE__, "hwndFocus %lx", hwndFocus); // 13 Jul 09 SHL fixme debug
     341              DbgMsg(pszSrcFile, __LINE__, "hwndCnr %lx", wk->hwndCnr); // 13 Jul 09 SHL fixme debug
     342              // DbgMsg(pszSrcFile, __LINE__, "hwndS %lx", wk->li->hwndS);      // 13 Jul 09 SHL fixme debug
     343              DbgMsg(pszSrcFile, __LINE__, "hwnd %lx", wk->li->hwnd);   // 13 Jul 09 SHL fixme debug
     344              // DbgMsg(pszSrcFile, __LINE__, "hwndParent %lx", wk->hwndParent);        // 13 Jul 09 SHL fixme debug
     345              // DbgMsg(pszSrcFile, __LINE__, "hwndClient %lx", wk->hwndClient);        // 13 Jul 09 SHL fixme debug
     346              // DbgMsg(pszSrcFile, __LINE__, "hwndFrame %lx", wk->hwndFrame);  // 13 Jul 09 SHL fixme debug
     347              // hwndForActions = wk->li->hwnd == hwndFocus ? hwndFocus : wk->hwndCnr;
     348              hwndForActions = WinQueryFocus(HWND_DESKTOP);
     349#if 0 // 14 Jul 09 SHL fixme
     350              hwndForActions = WinQueryFocus(HWND_DESKTOP);
     351              if (WinQueryClassName(hwndForActions, sizeof(ucClassname), ucClassname)) {
     352                // If not a container fall back to worker
     353                if (strcmp(ucClassname, "#25"));
     354              }
     355#endif
     356              habForActions = WinQueryAnchorBlock(hwndForActions);
     357              DbgMsg(pszSrcFile, __LINE__, "habForActions %lx hwndForActions %lx", habForActions, hwndForActions);      // 13 Jul 09 SHL fixme debug
     358              // Ask container window to update status line every 5 seconds in case action is time intensive
     359              idTimerStarted = WinStartTimer(habForActions, hwndForActions, ID_ACTION_TIMER, 2000);     // 13 Jul 09 SHL fixme 5 sec
     360            }
    325361            for (x = 0; wk->li->list[x]; x++) {
    326362              switch (wk->li->type) {
     
    829865                    if (fRealIdle)
    830866                      priority_idle();
     867
    831868                    rc = docopyf(type, wk->li->list[x], newname);
    832869                    if (fResetVerify) {
     
    892929                      }
    893930                      else {
    894                         if (LogFileHandle)
     931                        if (LogFileHandle) {
    895932                          fprintf(LogFileHandle,
    896933                                  GetPString(IDS_LOGTOFAILEDTEXT),
    897934                                  move, wk->li->list[x], newname, rc);
     935                        }
    898936                        rc = Dos_Error(MB_ENTERCANCEL,
    899937                                       rc,
     
    912950                    }
    913951                    else {
    914                       if (LogFileHandle)
     952                      if (LogFileHandle) {
    915953                        fprintf(LogFileHandle,
    916954                                "%s \"%s\" %s\"%s\"\n",
     
    918956                                wk->li->list[x],
    919957                                GetPString(IDS_TOTEXT), newname);
     958                      }
    920959                      if ((driveflags[*wk->li->targetpath - 'A'] & DRIVE_RSCANNED) &&
    921960                          AddToList(wk->li->list[x],
     
    9841023            } // for list
    9851024
     1025            // Do actio specific post-processing
    9861026            switch (wk->li->type) {
    9871027            case IDM_MOVE:
     
    10261066              break;
    10271067            }
    1028           }
     1068            if (idTimerStarted)
     1069              WinStopTimer(habForActions, hwndForActions, ID_ACTION_TIMER);     // 13 Jul 09 SHL
     1070          } // if have non-empty list
    10291071
    10301072        Abort:
     
    10481090    }
    10491091
     1092    if (fActionPosted)
     1093      DosSleep(2000);                   // Alloc container time to process queued UM_ACTIONSTATE messages 13 Jul 09 SHL
    10501094    if (wk->li)
    10511095      FreeListInfo(wk->li);
     
    17631807  }
    17641808}
     1809
     1810// We can use static buffer for all in progress actions because we have only 1 status line
     1811static WORKER *pCachedActionWorker;     // Sent from Action thread via UM_ACTIONSTATE
     1812static PSZ pszCachedActionListItem;     // Sent from Action thread via UM_ACTIONSTATE
     1813
     1814MRESULT EXPENTRY ActionWMTimer(HWND hwnd, MPARAM mp1, MPARAM mp2)
     1815{
     1816  if (pCachedActionWorker != NULL && pszCachedActionListItem != NULL) {
     1817    DbgMsg(pszSrcFile, __LINE__, "Using hWndStatus %lx pCachedActionWorker %p pszCachedActionListItem %s", hwndStatus, pCachedActionWorker, pszCachedActionListItem);   // 13 Jul 09 SHL fixme debug
     1818    if (hwndStatus && WinQueryFocus(HWND_DESKTOP) == hwnd) {
     1819      CHAR s[CCHMAXPATH + 64];
     1820      sprintf(s, "%s %s",
     1821              pCachedActionWorker->li->type == IDM_MOVE ?
     1822                GetPString(IDS_MOVINGTEXT) :
     1823                GetPString(IDS_COPYINGTEXT),
     1824              pszCachedActionListItem);
     1825      // sprintf(s, "Moving/copying %s", pszCachedActionListItem);      // 14 Jul 09 SHL fixme
     1826      WinSetWindowText(hwndStatus, s);
     1827    }
     1828  }
     1829  return 0;
     1830}
     1831
     1832MRESULT EXPENTRY ActionUMWorkerState(HWND hwnd, MPARAM mp1, MPARAM mp2) {
     1833  pCachedActionWorker = PVOIDFROMMP(mp1);
     1834  pszCachedActionListItem = PVOIDFROMMP(mp2);
     1835  DbgMsg(pszSrcFile, __LINE__, "Setting pCachedActionWorker %p pszCachedActionListItem %s", pCachedActionWorker, pszCachedActionListItem);      // 13 Jul 09 SHL fixme debug
     1836  if (hwndStatus && WinQueryFocus(HWND_DESKTOP) == hwnd)
     1837    WinPostMsg(hwnd, WM_SETFOCUS, MPFROMLONG(hwnd), MPFROMLONG(TRUE));  // 14 Jul 09 SHL Force status line update
     1838  return 0;
     1839}
     1840
    17651841#pragma alloc_text(MASSACTION,MassAction)
    17661842#pragma alloc_text(ACTION,Action)
Note: See TracChangeset for help on using the changeset viewer.