lbs/lbsclient/src/ctlbsclienteventtimer.cpp
branchSymbian2
changeset 1 8758140453c0
child 6 c108117318cb
equal deleted inserted replaced
0:e8c1ea2c6496 1:8758140453c0
       
     1 // Copyright (c) 2001-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 "Symbian Foundation License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "ctlbsclienteventtimer.h"
       
    20 #include "mctlbsrequestobserver.h"
       
    21 #include <coemain.h>
       
    22 #include "ctlbsclientrequestor.h"
       
    23 
       
    24 // ================= MEMBER FUNCTIONS =======================
       
    25 
       
    26 // C++ default constructor can NOT contain any code, that
       
    27 // might leave.
       
    28 //
       
    29 CT_LbsClientEventTimer::CT_LbsClientEventTimer()
       
    30 	: CActive(EActivePriorityDefault),	
       
    31 	iTimer(),
       
    32 	iObserver(NULL),
       
    33 	iCompletionCode(KNoEvent)
       
    34     {
       
    35     }
       
    36 
       
    37 // EPOC default constructor can leave.
       
    38 void CT_LbsClientEventTimer::ConstructL(CTestExecuteLogger& aLogger)
       
    39 	{
       
    40 	iLogger = aLogger;
       
    41     User::LeaveIfError(iTimer.CreateLocal());
       
    42 	CActiveScheduler::Add(this);
       
    43     }
       
    44 
       
    45 // Two-phased constructor.
       
    46 CT_LbsClientEventTimer* CT_LbsClientEventTimer::NewL(CTestExecuteLogger& aLogger)
       
    47     {
       
    48 	CT_LbsClientEventTimer* self = NewLC(aLogger);
       
    49 	CleanupStack::Pop();
       
    50 	return self;
       
    51     }
       
    52 
       
    53 // Two-phased constructor.
       
    54 CT_LbsClientEventTimer* CT_LbsClientEventTimer::NewLC(CTestExecuteLogger& aLogger)
       
    55     {
       
    56 	CT_LbsClientEventTimer* self =
       
    57 		new (ELeave) CT_LbsClientEventTimer(); 
       
    58 	CleanupStack::PushL(self); // push to clean-up stack
       
    59 	self->ConstructL(aLogger); // construct
       
    60 	return self; // return new object
       
    61     }
       
    62 
       
    63 // Destructor
       
    64 CT_LbsClientEventTimer::~CT_LbsClientEventTimer()
       
    65     {
       
    66     iObserver = NULL;
       
    67 	Cancel();
       
    68 	iTimer.Close();
       
    69     }
       
    70 
       
    71 // ---------------------------------------------------------
       
    72 // CT_LbsClientEventTimer::SetObserver
       
    73 //
       
    74 // (other items were commented in a header).
       
    75 // ---------------------------------------------------------
       
    76 // 
       
    77 void CT_LbsClientEventTimer::SetObserver(MCT_LbsRequestObserver* aObserver)
       
    78     {
       
    79     iObserver = aObserver;
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------
       
    83 // CT_LbsClientEventTimer::CompletionCode
       
    84 // 
       
    85 // (other items were commented in a header).
       
    86 // ---------------------------------------------------------
       
    87 //
       
    88 TInt CT_LbsClientEventTimer::CompletionCode() const
       
    89     {
       
    90     return iCompletionCode;
       
    91     }
       
    92 
       
    93 // ---------------------------------------------------------
       
    94 // CT_LbsClientEventTimer::ResetCompletionCode
       
    95 // 
       
    96 // (other items were commented in a header).
       
    97 // ---------------------------------------------------------
       
    98 //
       
    99 void CT_LbsClientEventTimer::ResetCompletionCode()
       
   100 	{
       
   101 	iCompletionCode = KNoEvent;
       
   102 	}
       
   103 
       
   104 // ---------------------------------------------------------
       
   105 // CT_LbsClientEventTimer::Start
       
   106 // starts the RTimer
       
   107 // (other items were commented in a header).
       
   108 // ---------------------------------------------------------
       
   109 //
       
   110 void CT_LbsClientEventTimer::Start(TInt aTimeout)
       
   111     {
       
   112 	iTimer.After(iStatus, aTimeout);
       
   113 	SetActive();
       
   114     }
       
   115 
       
   116 // ---------------------------------------------------------
       
   117 // CT_LbsClientEventTimer::DoCancel
       
   118 // cancels the RTimer
       
   119 // (other items were commented in a header).
       
   120 // ---------------------------------------------------------
       
   121 //
       
   122 void CT_LbsClientEventTimer::DoCancel()
       
   123     {
       
   124 	iTimer.Cancel();
       
   125     }
       
   126 
       
   127 // ---------------------------------------------------------
       
   128 // CPosNotifierTimer::RunL
       
   129 // report a timeout to the observer
       
   130 // (other items were commented in a header).
       
   131 // ---------------------------------------------------------
       
   132 //
       
   133 void CT_LbsClientEventTimer::RunL()
       
   134     {
       
   135 	iCompletionCode = iStatus.Int();
       
   136 	RequestComplete();
       
   137     }
       
   138 
       
   139 // ---------------------------------------------------------
       
   140 // CT_LbsClientEventTimer::RunError
       
   141 // (other items were commented in a header).
       
   142 // ---------------------------------------------------------
       
   143 //
       
   144 TInt CT_LbsClientEventTimer::RunError(TInt /*aError*/)
       
   145     {
       
   146     return KErrNone;
       
   147     }
       
   148 
       
   149 // ---------------------------------------------------------
       
   150 // CT_LbsClientEventTimer::RequestComplete
       
   151 // 
       
   152 // (other items were commented in a header).
       
   153 // ---------------------------------------------------------
       
   154 //
       
   155 void CT_LbsClientEventTimer::RequestComplete()
       
   156     {
       
   157 	if (iObserver)
       
   158         {
       
   159         TRAPD(err, iObserver->RequestCompleteL());
       
   160         if(KErrNone != err)
       
   161         	{
       
   162         	_LIT(KRequestCompleteError, "Error in LbsRequester: %d");
       
   163         	ERR_PRINTF2(KRequestCompleteError, err);
       
   164         	}
       
   165         }
       
   166     }
       
   167 
       
   168 //  End of File