kerneltest/e32test/usb/t_usb_device/src/transferhandle.cpp
changeset 247 d8d70de2bd36
child 253 d37db4dcc88d
equal deleted inserted replaced
201:43365a9b78a3 247:d8d70de2bd36
       
     1 /*
       
     2 * Copyright (c) 2010 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 * Header file NTB build policy base class
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21 @file
       
    22 @internalComponent
       
    23 */
       
    24 
       
    25 #include "transferhandle.h"
       
    26 #include "transferserver.h"
       
    27 
       
    28 CTransferHandle* CTransferHandle::NewL(CTransferServer& aServer)
       
    29     {
       
    30     CTransferHandle *self=new (ELeave) CTransferHandle(aServer);
       
    31     CleanupStack::PushL(self);
       
    32     self->ConstructL();
       
    33     CleanupStack::Pop();
       
    34     return self;    
       
    35     }
       
    36 
       
    37 CTransferHandle::CTransferHandle(CTransferServer& aServer)
       
    38     : CActive(CActive::EPriorityStandard), iServer(aServer)
       
    39     {
       
    40     }
       
    41 
       
    42 CTransferHandle::~CTransferHandle()
       
    43     {
       
    44     RDebug::Printf("CTransferHandle::~CTransferHandle");
       
    45     Cancel();
       
    46     iTimer.Close();
       
    47     }
       
    48 
       
    49 void CTransferHandle::DoCancel()
       
    50     {
       
    51     RDebug::Printf("CTransferHandle::DoCancel");
       
    52     iTimer.Cancel();
       
    53     }
       
    54 
       
    55 void CTransferHandle::ConstructL()
       
    56     {
       
    57     CActiveScheduler::Add(this);
       
    58     User::LeaveIfError(iTimer.CreateLocal());
       
    59     }
       
    60 
       
    61 _LIT(KPanic, "CTransferHandle");
       
    62 const TInt KTimerError = 1;
       
    63 
       
    64 
       
    65 void CTransferHandle::RunL()
       
    66 	{
       
    67 	if(iStatus.Int() != KErrNone)
       
    68 		{		
       
    69 		RDebug::Printf("CTransferHandle::RunL");
       
    70 		User::Panic(KPanic, KTimerError);
       
    71 		return;
       
    72 		}
       
    73 	iServer.TransferHandleL();
       
    74 	}
       
    75 
       
    76 void CTransferHandle::StartTimer()
       
    77 	{
       
    78 	iStatus = KRequestPending;
       
    79     iTimer.After(iStatus, 10000);
       
    80     SetActive();
       
    81 	}
       
    82 
       
    83