filemanager/src/fmbkupengine/src/CMMCScBkupDriveSpecificRequest.cpp
branchRCL_3
changeset 20 491b3ed49290
equal deleted inserted replaced
19:95243422089a 20:491b3ed49290
       
     1 /*
       
     2 * Copyright (c) 2005 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: CMMCScBkupDriveSpecificRequest implementation
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 #include "CMMCScBkupDriveSpecificRequest.h"
       
    20 
       
    21 // User includes
       
    22 #include "CMMCScBkupDriveAndOperationTypeManager.h"
       
    23 
       
    24 
       
    25 // ---------------------------------------------------------------------------
       
    26 // CMMCScBkupDriveSpecificRequest::CMMCScBkupDriveSpecificRequest()
       
    27 // 
       
    28 // 
       
    29 // ---------------------------------------------------------------------------
       
    30 CMMCScBkupDriveSpecificRequest::CMMCScBkupDriveSpecificRequest( const CMMCScBkupDriveAndOperationTypeManager& aDriveAndOperations, TMMCScBkupOwnerDataType aDataType, CActive::TPriority aPriority )
       
    31 :   CActive(aPriority), iDriveAndOperations(aDriveAndOperations), iDataType( aDataType )
       
    32     {
       
    33     CActiveScheduler::Add(this);
       
    34     }
       
    35 
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // CMMCScBkupDriveSpecificRequest::~CMMCScBkupDriveSpecificRequest()
       
    39 // 
       
    40 // 
       
    41 // ---------------------------------------------------------------------------
       
    42 CMMCScBkupDriveSpecificRequest::~CMMCScBkupDriveSpecificRequest( )
       
    43     {
       
    44     Cancel();
       
    45     }
       
    46 
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // CMMCScBkupDriveSpecificRequest::ConstructL()
       
    50 // 
       
    51 // 
       
    52 // ---------------------------------------------------------------------------
       
    53 void CMMCScBkupDriveSpecificRequest::ConstructL( )
       
    54     {
       
    55     }
       
    56 
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // CMMCScBkupDriveSpecificRequest::RequestL()
       
    60 // 
       
    61 // 
       
    62 // ---------------------------------------------------------------------------
       
    63 void CMMCScBkupDriveSpecificRequest::RequestL( TRequestStatus& aObserver )
       
    64     {
       
    65     // Set to -1 so that when RunL is called, the next drive will be calculated
       
    66     // as 0 == EDriveA
       
    67     iCurrentDrive = -1;
       
    68     iObserver = &aObserver;
       
    69     *iObserver = KRequestPending;
       
    70     }
       
    71 
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // CMMCScBkupDriveSpecificRequest::NextValidDrive()
       
    75 // 
       
    76 // 
       
    77 // ---------------------------------------------------------------------------
       
    78 TBool CMMCScBkupDriveSpecificRequest::NextValidDrive(TDriveNumber& aDrive)
       
    79     {
       
    80     // If we've already reached Z then there isn't any sense in continuing
       
    81     // as all drives have been processed.
       
    82     TBool driveAvailable = EFalse;
       
    83 
       
    84     // Keep checking drives until we go past Z
       
    85     while( ++iCurrentDrive <= EDriveZ )
       
    86         {
       
    87         if  ( iDriveAndOperations.DriveList()[ iCurrentDrive ] != 0 )
       
    88             {
       
    89             const TDriveNumber drive =  static_cast< TDriveNumber >( iCurrentDrive );
       
    90 
       
    91             // Drive is allowable according to master list.
       
    92             // But is this data type allowed to access that drive?
       
    93             if  ( iDataType == EMMCScBkupOwnerDataTypeAny )
       
    94                 {
       
    95                 // Found an available drive - data type filtering is not in play...
       
    96                 aDrive = drive;
       
    97                 driveAvailable = ETrue;
       
    98                 break;
       
    99                 }
       
   100             else if ( iDriveAndOperations.IsDataTypeAllowedToAccessDrive( drive, iDataType ) )
       
   101                 {
       
   102                 // Found an available drive - this data type is allowed to access that drive...
       
   103                 aDrive = drive;
       
   104                 driveAvailable = ETrue;
       
   105                 break;
       
   106                 }
       
   107             }
       
   108         }
       
   109     //
       
   110     return driveAvailable;
       
   111     }
       
   112 
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // CMMCScBkupDriveSpecificRequest::NextValidDrive()
       
   116 // 
       
   117 // 
       
   118 // ---------------------------------------------------------------------------
       
   119 TBool CMMCScBkupDriveSpecificRequest::NextValidDrive(TDriveNumber& aDrive, const TDriveList& aCrossCheckList)
       
   120     {
       
   121     TDriveNumber drive;
       
   122     TBool driveAvailable = NextValidDrive(drive);
       
   123     
       
   124     while(driveAvailable)
       
   125         {
       
   126         // Check if aCrossCheckList also supports the same drive
       
   127         if  (aCrossCheckList[drive] != 0)
       
   128             {
       
   129             aDrive = drive;
       
   130             break;
       
   131             }
       
   132         else
       
   133             {
       
   134             // Try another drive from our master list
       
   135             driveAvailable = NextValidDrive(drive);
       
   136             }
       
   137         }
       
   138     //
       
   139     return driveAvailable;
       
   140     }
       
   141 
       
   142 
       
   143 // ---------------------------------------------------------------------------
       
   144 // CMMCScBkupDriveSpecificRequest::CurrentDrive()
       
   145 // 
       
   146 // 
       
   147 // ---------------------------------------------------------------------------
       
   148 TDriveNumber CMMCScBkupDriveSpecificRequest::CurrentDrive() const
       
   149     {
       
   150     return static_cast<TDriveNumber>(iCurrentDrive);
       
   151     }
       
   152 
       
   153 
       
   154 // ---------------------------------------------------------------------------
       
   155 // CMMCScBkupDriveSpecificRequest::DoCancel()
       
   156 // 
       
   157 // 
       
   158 // ---------------------------------------------------------------------------
       
   159 void CMMCScBkupDriveSpecificRequest::DoCancel()
       
   160     {
       
   161     }
       
   162 
       
   163 
       
   164 // ---------------------------------------------------------------------------
       
   165 // CMMCScBkupDriveSpecificRequest::RunError()
       
   166 // 
       
   167 // 
       
   168 // ---------------------------------------------------------------------------
       
   169 TInt CMMCScBkupDriveSpecificRequest::RunError(TInt aError)
       
   170     {
       
   171 #ifdef MMCSCBKUP_USE_BREAKPOINTS
       
   172     __BREAKPOINT();
       
   173 #endif
       
   174     //
       
   175     CompleteObserverRequest(aError);
       
   176     return KErrNone;
       
   177     }
       
   178 
       
   179 
       
   180 // ---------------------------------------------------------------------------
       
   181 // CMMCScBkupDriveSpecificRequest::CompleteObserverRequest()
       
   182 // 
       
   183 // 
       
   184 // ---------------------------------------------------------------------------
       
   185 void CMMCScBkupDriveSpecificRequest::CompleteObserverRequest(TInt aCompletionCode)
       
   186     {
       
   187     __ASSERT_ALWAYS(iObserver != NULL, User::Invariant());
       
   188     User::RequestComplete(iObserver, aCompletionCode);
       
   189     }
       
   190 
       
   191 
       
   192 // ---------------------------------------------------------------------------
       
   193 // CMMCScBkupDriveSpecificRequest::CompleteSelf()
       
   194 // 
       
   195 // 
       
   196 // ---------------------------------------------------------------------------
       
   197 void CMMCScBkupDriveSpecificRequest::CompleteSelf(TInt aCompletionCode)
       
   198     {
       
   199     SetActive();
       
   200     TRequestStatus* status = &iStatus;
       
   201     User::RequestComplete(status, aCompletionCode);
       
   202     }
       
   203 
       
   204