connectivitymodules/SeCon/servers/syncserver/src/cscontimeout.cpp
changeset 40 b63e67867dcd
equal deleted inserted replaced
39:9905f7d46607 40:b63e67867dcd
       
     1 /*
       
     2 * Copyright (c) 2009 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:  CCSconTimeOut implementation
       
    15 *
       
    16 */
       
    17 
       
    18 #include "cscontimeout.h"
       
    19 
       
    20 CCSconTimeOut::CCSconTimeOut( MTimeOutObserver& aTimeOutObserver ) :
       
    21     CActive(EPriorityStandard), // Standard priority
       
    22     iTimeOutObserver(aTimeOutObserver)
       
    23     {
       
    24     }
       
    25 
       
    26 
       
    27 CCSconTimeOut* CCSconTimeOut::NewL( MTimeOutObserver& aTimeOutObserver )
       
    28     {
       
    29     CCSconTimeOut* self = new (ELeave) CCSconTimeOut( aTimeOutObserver );
       
    30     CleanupStack::PushL( self );
       
    31     self->ConstructL();
       
    32     CleanupStack::Pop( self );
       
    33     return self;
       
    34     }
       
    35 
       
    36 void CCSconTimeOut::ConstructL()
       
    37     {
       
    38     User::LeaveIfError(iTimer.CreateLocal()); // Initialize timer
       
    39     CActiveScheduler::Add(this); // Add to scheduler
       
    40     }
       
    41 
       
    42 CCSconTimeOut::~CCSconTimeOut()
       
    43     {
       
    44     Cancel(); // Cancel any request, if outstanding
       
    45     iTimer.Close(); // Destroy the RTimer object
       
    46     // Delete instance variables if any
       
    47     }
       
    48 
       
    49 void CCSconTimeOut::DoCancel()
       
    50     {
       
    51     iTimer.Cancel();
       
    52     }
       
    53 
       
    54 void CCSconTimeOut::Start(TTimeIntervalMicroSeconds32 aDelay)
       
    55     {
       
    56     Cancel(); // Cancel any request, just to be sure
       
    57     iState = EUninitialized;
       
    58     iTimer.After(iStatus, aDelay); // Set for later
       
    59     SetActive(); // Tell scheduler a request is active
       
    60     }
       
    61 
       
    62 void CCSconTimeOut::RunL()
       
    63     {
       
    64     /*if (iState == EUninitialized)
       
    65         {
       
    66         // Do something the first time RunL() is called
       
    67         iState = EInitialized;
       
    68         }
       
    69     else if (iState != EError)
       
    70         {
       
    71         // Do something
       
    72         }
       
    73     iTimer.After(iStatus, 1000000); // Set for 1 sec later
       
    74     SetActive(); // Tell scheduler a request is active*/
       
    75     if ( iState == KErrNone )
       
    76         {
       
    77         iTimeOutObserver.TimeOut();
       
    78         }
       
    79     
       
    80     }
       
    81 
       
    82 TInt CCSconTimeOut::RunError(TInt aError)
       
    83     {
       
    84     return aError;
       
    85     }