filesystemuis/memscaneng/serversrc/msengfindallscanner.cpp
changeset 0 6a9f87576119
child 23 18e505e3f370
equal deleted inserted replaced
-1:000000000000 0:6a9f87576119
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0""
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *     Scanner class used to scan file system by filename extension
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // SYSTEM INCLUDES
       
    22 #include    <f32file.h>
       
    23 
       
    24 // USER INCLUDES
       
    25 #include    "msengfindallscanner.h"
       
    26 #include    "msenguihandler.h"
       
    27 #include    "memscanutils.h"
       
    28 
       
    29 
       
    30 // ================= MEMBER FUNCTIONS ========================================
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 // CMsengFindAllScanner::CMsengFindAllScanner()
       
    34 //
       
    35 // C++ default constructor. Can NOT contain any code, that might leave.
       
    36 // ---------------------------------------------------------------------------
       
    37 CMsengFindAllScanner::CMsengFindAllScanner(MMsengScannerObserver& aObserver, 
       
    38                                            CMsengInfoArray& aScanArray, 
       
    39                                            RFs& aFsSession)
       
    40 : CMsengFileScanner(aObserver, aScanArray, aFsSession)
       
    41     {
       
    42     }
       
    43 
       
    44 
       
    45 // ---------------------------------------------------------------------------
       
    46 // CMsengFindAllScanner::NewL()
       
    47 //
       
    48 // Two-phased constructor
       
    49 // ---------------------------------------------------------------------------
       
    50 CMsengFindAllScanner* CMsengFindAllScanner::NewL(
       
    51                                         MMsengScannerObserver& aObserver, 
       
    52                                         CMsengInfoArray& aScanArray, 
       
    53                                         RFs& aFsSession)
       
    54     {
       
    55     CMsengFindAllScanner* self = new (ELeave) CMsengFindAllScanner(aObserver, 
       
    56                                                     aScanArray, aFsSession);
       
    57     return self;
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // CMsengFindAllScanner::~CMsengFindAllScanner()
       
    62 //
       
    63 // Destructor
       
    64 // ---------------------------------------------------------------------------
       
    65 CMsengFindAllScanner::~CMsengFindAllScanner()
       
    66     {
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // CMsengFindAllScanner::FindFilesL()
       
    71 //
       
    72 //
       
    73 // ---------------------------------------------------------------------------
       
    74 CDir* CMsengFindAllScanner::FindFilesL(const TDesC& aDirectory, TBool& aMoveToNextDirectory)
       
    75     {
       
    76     TRACES( RDebug::Print(_L("CMsengFindAllScanner::FindFilesL(%S)"), &aDirectory) );
       
    77 
       
    78     // Get a list of results for this directory
       
    79     CDir* results;
       
    80     const TInt error = FsSession().GetDir(aDirectory, 
       
    81         KEntryAttMaskSupported|KEntryAttAllowUid, ESortNone, results);
       
    82     if (error == KErrNotFound)
       
    83         {
       
    84         results = NULL;
       
    85         }
       
    86 
       
    87     // Always move onto searching the next directory
       
    88     aMoveToNextDirectory = ETrue;
       
    89     
       
    90     // Return populated (or potentially NULL) list.
       
    91     return results;
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // CMsengFindAllScanner::HandleLocatedEntryL()
       
    96 // 
       
    97 // 
       
    98 // ---------------------------------------------------------------------------
       
    99 CMsengFileScanner::TLocationResponse CMsengFindAllScanner::HandleLocatedEntryL(
       
   100     const TDesC& aFullFileNameAndPath, const TEntry& aEntry)
       
   101     {
       
   102     // Figure out the data group by comparing the start of the path
       
   103 
       
   104     TInt dataDirCount = InfoArray().DataDirs().Count();
       
   105     for(TInt i=0; i < dataDirCount; i++)
       
   106         {
       
   107         TPtrC dataDirPath = InfoArray().DataDirs().MdcaPoint(i);
       
   108         if(aFullFileNameAndPath.Length() >= dataDirPath.Length())
       
   109             {
       
   110             TFileName currentPath;
       
   111             currentPath.Copy(aFullFileNameAndPath.Left(dataDirPath.Length()));
       
   112 
       
   113             // Compare whether folder matches
       
   114             if(!currentPath.Compare(dataDirPath))
       
   115                 {
       
   116                 TBool isExcluded = EFalse;
       
   117                 TInt fileLength = aFullFileNameAndPath.Length() - dataDirPath.Length();
       
   118                 TInt excludedFiles = 0;
       
   119                 if(InfoArray().DataDirExcludedFiles().Count())
       
   120                     {
       
   121                     excludedFiles = InfoArray().DataDirExcludedFiles().At(i)->MdcaCount();
       
   122                     }
       
   123 
       
   124                 currentPath.Copy(aFullFileNameAndPath.Right(fileLength));
       
   125 
       
   126                 TRACES( RDebug::Print(_L("Check file %S"), &currentPath) );
       
   127                 
       
   128                 for(TInt j=0; j < excludedFiles; j++)
       
   129                     {
       
   130                     TRACES
       
   131                     ( 
       
   132                     TPtrC file = InfoArray().DataDirExcludedFiles().At(i)->MdcaPoint(j);
       
   133                     RDebug::Print(_L("Comparing to excluded file %S"), &file);
       
   134                     );
       
   135                     
       
   136                     if(!currentPath.Compare(
       
   137                         InfoArray().DataDirExcludedFiles().At(i)->MdcaPoint(j)))
       
   138                         {
       
   139                         isExcluded = ETrue;
       
   140                         break;
       
   141                         }
       
   142                     }
       
   143 
       
   144                 if(!isExcluded)
       
   145                     {
       
   146                     // Add size of object when file is not in list of excluded files
       
   147                     if(InfoArray().DataDirGroups().Count())
       
   148                         {
       
   149                         TInt group = InfoArray().DataDirGroups().At(i);
       
   150                         InfoArray().AddSizeByGroupL(group, aEntry.iSize);
       
   151 
       
   152                         TRACES
       
   153                         ( 
       
   154                         RDebug::Print(_L("File %S belongs to group: %d"), 
       
   155                             &aFullFileNameAndPath, group)
       
   156                         );
       
   157                         }
       
   158                     }
       
   159                 }
       
   160             }
       
   161         }
       
   162         
       
   163     // We processed this one
       
   164     return EEntryWasProcessed;
       
   165     }
       
   166 
       
   167 //  End of File