userlibandfileserver/fileserver/shostmassstorage/server/controller/cusbmssuspendresume.cpp
changeset 0 a41df078684a
child 31 56f325a607ea
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalTechnology
       
    19 */
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <e32base_private.h>
       
    23 #include <d32usbdi.h>
       
    24 
       
    25 #include <d32usbtransfers.h>
       
    26 #include "msctypes.h"
       
    27 #include "mscutils.h"
       
    28 #include "shared.h"
       
    29 #include "msgservice.h"
       
    30 #include "botmsctypes.h"
       
    31 
       
    32 #include "mprotocol.h"
       
    33 #include "mtransport.h"
       
    34 #include "cusbhostmslogicalunit.h"
       
    35 #include "cusbhostmsdevice.h"
       
    36 #include "cbulkonlytransport.h"
       
    37 #include "cusbmssuspendresume.h"
       
    38 
       
    39 #include "msdebug.h"
       
    40 #include "debug.h"
       
    41 
       
    42 
       
    43 void CUsbMsIfaceSuspendResume::RunL()
       
    44     {
       
    45     __MSFNLOG
       
    46 	iDevice->ResumeCompletedL();
       
    47 	if(iCancelSuspend)
       
    48 		{
       
    49 		User::RequestComplete(iDeviceStatus, iStatus.Int());
       
    50 		iDeviceStatus = NULL;
       
    51 		}
       
    52 	else
       
    53 		{
       
    54 		iDevice->DoHandleRemoteWakeupL();
       
    55 		}
       
    56     }
       
    57 
       
    58 /**
       
    59 Cancellation of outstanding request
       
    60 */
       
    61 void CUsbMsIfaceSuspendResume::DoCancel()
       
    62 	{
       
    63     __MSFNLOG
       
    64 	}
       
    65 
       
    66 TInt CUsbMsIfaceSuspendResume::RunError(TInt aError)
       
    67 	{
       
    68     __MSFNLOG
       
    69     return KErrNone;
       
    70 	}
       
    71 
       
    72 
       
    73 void CUsbMsIfaceSuspendResume::Resume(TRequestStatus &aStatus)
       
    74 	{
       
    75     __MSFNLOG
       
    76 	iCancelSuspend = ETrue;
       
    77 	iDeviceStatus = &aStatus;
       
    78 	iTransport->Resume();
       
    79 	}
       
    80 
       
    81 void CUsbMsIfaceSuspendResume::Suspend()
       
    82 	{
       
    83     __MSFNLOG
       
    84 	if(!IsActive())
       
    85 		SetActive();
       
    86 	iCancelSuspend = EFalse;
       
    87 	iTransport->Suspend(iStatus);
       
    88 	}
       
    89 
       
    90 CUsbMsIfaceSuspendResume* CUsbMsIfaceSuspendResume::NewL(MTransport *aTransport, CUsbHostMsDevice *aDevice)
       
    91 	{
       
    92 	return new (ELeave) CUsbMsIfaceSuspendResume(aTransport, aDevice);
       
    93 	}
       
    94 
       
    95 CUsbMsIfaceSuspendResume::CUsbMsIfaceSuspendResume(MTransport *aTransport, CUsbHostMsDevice *aDevice)
       
    96 :	CActive(EPriorityHigh)
       
    97 	{
       
    98     __MSFNLOG
       
    99 	iTransport = aTransport;
       
   100 	iDevice = aDevice;
       
   101 	iCancelSuspend = EFalse;
       
   102 	iDeviceStatus = NULL;
       
   103 	CActiveScheduler::Add(this);
       
   104 	}
       
   105 
       
   106 CUsbMsIfaceSuspendResume::~CUsbMsIfaceSuspendResume()
       
   107 	{
       
   108     __MSFNLOG
       
   109 	Cancel();
       
   110 	}
       
   111