connectivitymodules/SeCon/servers/syncserver/src/cscontimeout.cpp
author hgs
Tue, 13 Jul 2010 03:39:25 +0530
changeset 40 b63e67867dcd
permissions -rw-r--r--
201025
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:  CCSconTimeOut implementation
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
#include "cscontimeout.h"
hgs
parents:
diff changeset
    19
hgs
parents:
diff changeset
    20
CCSconTimeOut::CCSconTimeOut( MTimeOutObserver& aTimeOutObserver ) :
hgs
parents:
diff changeset
    21
    CActive(EPriorityStandard), // Standard priority
hgs
parents:
diff changeset
    22
    iTimeOutObserver(aTimeOutObserver)
hgs
parents:
diff changeset
    23
    {
hgs
parents:
diff changeset
    24
    }
hgs
parents:
diff changeset
    25
hgs
parents:
diff changeset
    26
hgs
parents:
diff changeset
    27
CCSconTimeOut* CCSconTimeOut::NewL( MTimeOutObserver& aTimeOutObserver )
hgs
parents:
diff changeset
    28
    {
hgs
parents:
diff changeset
    29
    CCSconTimeOut* self = new (ELeave) CCSconTimeOut( aTimeOutObserver );
hgs
parents:
diff changeset
    30
    CleanupStack::PushL( self );
hgs
parents:
diff changeset
    31
    self->ConstructL();
hgs
parents:
diff changeset
    32
    CleanupStack::Pop( self );
hgs
parents:
diff changeset
    33
    return self;
hgs
parents:
diff changeset
    34
    }
hgs
parents:
diff changeset
    35
hgs
parents:
diff changeset
    36
void CCSconTimeOut::ConstructL()
hgs
parents:
diff changeset
    37
    {
hgs
parents:
diff changeset
    38
    User::LeaveIfError(iTimer.CreateLocal()); // Initialize timer
hgs
parents:
diff changeset
    39
    CActiveScheduler::Add(this); // Add to scheduler
hgs
parents:
diff changeset
    40
    }
hgs
parents:
diff changeset
    41
hgs
parents:
diff changeset
    42
CCSconTimeOut::~CCSconTimeOut()
hgs
parents:
diff changeset
    43
    {
hgs
parents:
diff changeset
    44
    Cancel(); // Cancel any request, if outstanding
hgs
parents:
diff changeset
    45
    iTimer.Close(); // Destroy the RTimer object
hgs
parents:
diff changeset
    46
    // Delete instance variables if any
hgs
parents:
diff changeset
    47
    }
hgs
parents:
diff changeset
    48
hgs
parents:
diff changeset
    49
void CCSconTimeOut::DoCancel()
hgs
parents:
diff changeset
    50
    {
hgs
parents:
diff changeset
    51
    iTimer.Cancel();
hgs
parents:
diff changeset
    52
    }
hgs
parents:
diff changeset
    53
hgs
parents:
diff changeset
    54
void CCSconTimeOut::Start(TTimeIntervalMicroSeconds32 aDelay)
hgs
parents:
diff changeset
    55
    {
hgs
parents:
diff changeset
    56
    Cancel(); // Cancel any request, just to be sure
hgs
parents:
diff changeset
    57
    iState = EUninitialized;
hgs
parents:
diff changeset
    58
    iTimer.After(iStatus, aDelay); // Set for later
hgs
parents:
diff changeset
    59
    SetActive(); // Tell scheduler a request is active
hgs
parents:
diff changeset
    60
    }
hgs
parents:
diff changeset
    61
hgs
parents:
diff changeset
    62
void CCSconTimeOut::RunL()
hgs
parents:
diff changeset
    63
    {
hgs
parents:
diff changeset
    64
    /*if (iState == EUninitialized)
hgs
parents:
diff changeset
    65
        {
hgs
parents:
diff changeset
    66
        // Do something the first time RunL() is called
hgs
parents:
diff changeset
    67
        iState = EInitialized;
hgs
parents:
diff changeset
    68
        }
hgs
parents:
diff changeset
    69
    else if (iState != EError)
hgs
parents:
diff changeset
    70
        {
hgs
parents:
diff changeset
    71
        // Do something
hgs
parents:
diff changeset
    72
        }
hgs
parents:
diff changeset
    73
    iTimer.After(iStatus, 1000000); // Set for 1 sec later
hgs
parents:
diff changeset
    74
    SetActive(); // Tell scheduler a request is active*/
hgs
parents:
diff changeset
    75
    if ( iState == KErrNone )
hgs
parents:
diff changeset
    76
        {
hgs
parents:
diff changeset
    77
        iTimeOutObserver.TimeOut();
hgs
parents:
diff changeset
    78
        }
hgs
parents:
diff changeset
    79
    
hgs
parents:
diff changeset
    80
    }
hgs
parents:
diff changeset
    81
hgs
parents:
diff changeset
    82
TInt CCSconTimeOut::RunError(TInt aError)
hgs
parents:
diff changeset
    83
    {
hgs
parents:
diff changeset
    84
    return aError;
hgs
parents:
diff changeset
    85
    }