obex/obexprotocol/obex/src/obexpackettimer.cpp
changeset 57 f6055a57ae18
parent 0 d0791faffa3f
equal deleted inserted replaced
54:4dc88a4ac6f4 57:f6055a57ae18
       
     1 // Copyright (c) 2005-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 "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  @released
       
    19  @internalComponent
       
    20 */
       
    21 
       
    22 #include "obexpackettimer.h"
       
    23 #include "obexclient.h"
       
    24 
       
    25 
       
    26 /*
       
    27  * CObexPacketTimer. Will RunL if the remote obex server has not send any packet for a certain time.
       
    28  * Duration is set by CObexClient::SetCommandTimeout
       
    29  */
       
    30 
       
    31 CObexPacketTimer::CObexPacketTimer(CObexClient& aObexClient) 
       
    32 	: CTimer(CActive::EPriorityStandard), iObexClient(aObexClient)
       
    33 	{
       
    34 	CActiveScheduler::Add(this);		
       
    35 	}
       
    36 
       
    37 CObexPacketTimer* CObexPacketTimer::NewL(CObexClient& aObexClient)
       
    38 	{
       
    39 	CObexPacketTimer* timer = new(ELeave)CObexPacketTimer(aObexClient);
       
    40 	CleanupStack::PushL(timer);
       
    41 	timer->ConstructL();
       
    42 	CleanupStack::Pop(timer);
       
    43 	return timer;
       
    44 	}
       
    45 
       
    46 CObexPacketTimer::~CObexPacketTimer()
       
    47 	{
       
    48 	Cancel();
       
    49 	}
       
    50 	
       
    51 void CObexPacketTimer::RunL()
       
    52 	{
       
    53 	if(iStatus==KErrNone)
       
    54 		{
       
    55 		//Timeout 
       
    56  		iObexClient.TimeOutCompletion();
       
    57 		}
       
    58 	}
       
    59 
       
    60 void CObexPacketTimer::SetTimer(TTimeIntervalMicroSeconds32 anInterval)
       
    61 	{
       
    62 	//Check if a timeout should be started on the request packet.
       
    63 	if(anInterval.Int()>KLowestPossibleTimerValue)
       
    64 		{
       
    65 		Cancel();
       
    66 
       
    67 		After(anInterval);
       
    68 		}
       
    69 	}
       
    70