51
|
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: Implementation of a timer interface.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#include "t_schedulerstartandstoptimer.h"
|
|
21 |
#include "trace.h"
|
|
22 |
|
|
23 |
|
|
24 |
// ======== LOCAL FUNCTIONS ========
|
|
25 |
|
|
26 |
|
|
27 |
// ======== MEMBER FUNCTIONS ========
|
|
28 |
|
|
29 |
|
|
30 |
// -----------------------------------------------------------------------------
|
|
31 |
// CAccSrvResetInactivityTimeTimer::NewL
|
|
32 |
// Two-phased constructor.
|
|
33 |
// -----------------------------------------------------------------------------
|
|
34 |
//
|
|
35 |
CSchedulerStopAndStartTimer* CSchedulerStopAndStartTimer::NewL(
|
|
36 |
MSchedulerStartAndStopTimerObserver& aSchedulerStartAndStopTimerObserver )
|
|
37 |
{
|
|
38 |
FUNC_LOG;
|
|
39 |
|
|
40 |
CSchedulerStopAndStartTimer* self = new ( ELeave ) CSchedulerStopAndStartTimer(
|
|
41 |
aSchedulerStartAndStopTimerObserver );
|
|
42 |
CleanupStack::PushL( self );
|
|
43 |
self->ConstructL();
|
|
44 |
CleanupStack::Pop( self );
|
|
45 |
return self;
|
|
46 |
}
|
|
47 |
|
|
48 |
|
|
49 |
// Destructor
|
|
50 |
CSchedulerStopAndStartTimer::~CSchedulerStopAndStartTimer()
|
|
51 |
{
|
|
52 |
FUNC_LOG;
|
|
53 |
Cancel();
|
|
54 |
}
|
|
55 |
|
|
56 |
// -----------------------------------------------------------------------------
|
|
57 |
// CSchedulerStopAndStartTimer::StartTimer
|
|
58 |
// .
|
|
59 |
// -----------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
void CSchedulerStopAndStartTimer::StartTimer(
|
|
62 |
TInt aTime,
|
|
63 |
TUint aTimerId )
|
|
64 |
{
|
|
65 |
FUNC_LOG;
|
|
66 |
INFO_2( "Timer Id: %d, Time: %d", aTimerId, aTime)
|
|
67 |
iTime = aTime;
|
|
68 |
iTimerId = aTimerId;
|
|
69 |
|
|
70 |
if ( ETimerIdRunMUT == iTimerId )
|
|
71 |
{
|
|
72 |
After( ( TTimeIntervalMicroSeconds32 ) iTime );
|
|
73 |
}
|
|
74 |
else
|
|
75 |
{
|
|
76 |
After( ( TTimeIntervalMicroSeconds32 ) 1 );
|
|
77 |
}
|
|
78 |
CActiveScheduler::Start();
|
|
79 |
}
|
|
80 |
|
|
81 |
// -----------------------------------------------------------------------------
|
|
82 |
// CSchedulerStopAndStartTimer::RunL
|
|
83 |
//
|
|
84 |
// (other items were commented in a header).
|
|
85 |
// -----------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
void CSchedulerStopAndStartTimer::RunL()
|
|
88 |
{
|
|
89 |
FUNC_LOG;
|
|
90 |
iSchedulerStartAndStopTimerObserver.Timeout( iTimerId );
|
|
91 |
if ( ETimerIdCreateMUT == iTimerId )
|
|
92 |
{
|
|
93 |
iSchedulerStartAndStopTimerObserver.CreateMUT();
|
|
94 |
iTimerId = ETimerIdRunMUT;
|
|
95 |
After( ( TTimeIntervalMicroSeconds32 ) iTime );
|
|
96 |
}
|
|
97 |
else if ( ETimerIdDeleteMUT == iTimerId )
|
|
98 |
{
|
|
99 |
iSchedulerStartAndStopTimerObserver.DeleteMUT();
|
|
100 |
CActiveScheduler::Stop();
|
|
101 |
}
|
|
102 |
else
|
|
103 |
{
|
|
104 |
CActiveScheduler::Stop();
|
|
105 |
}
|
|
106 |
}
|
|
107 |
|
|
108 |
|
|
109 |
// -----------------------------------------------------------------------------
|
|
110 |
// CSchedulerStopAndStartTimer::RunError
|
|
111 |
// Returns KErrNone
|
|
112 |
// (other items were commented in a header).
|
|
113 |
// -----------------------------------------------------------------------------
|
|
114 |
//
|
|
115 |
TInt CSchedulerStopAndStartTimer::RunError( TInt aError )
|
|
116 |
{
|
|
117 |
FUNC_LOG;
|
|
118 |
// Avoid Panic in CActiveScheduler
|
|
119 |
aError = KErrNone;
|
|
120 |
return aError;
|
|
121 |
}
|
|
122 |
|
|
123 |
|
|
124 |
// -----------------------------------------------------------------------------
|
|
125 |
// CSchedulerStopAndStartTimer::CSchedulerStopAndStartTimer
|
|
126 |
// C++ default constructor can NOT contain any code, that
|
|
127 |
// might leave.
|
|
128 |
// -----------------------------------------------------------------------------
|
|
129 |
//
|
|
130 |
CSchedulerStopAndStartTimer::CSchedulerStopAndStartTimer(
|
|
131 |
MSchedulerStartAndStopTimerObserver& aSchedulerStartAndStopTimerObserver) :
|
|
132 |
CTimer( CActive::EPriorityStandard ),
|
|
133 |
iSchedulerStartAndStopTimerObserver( aSchedulerStartAndStopTimerObserver )
|
|
134 |
{
|
|
135 |
FUNC_LOG;
|
|
136 |
}
|
|
137 |
|
|
138 |
// -----------------------------------------------------------------------------
|
|
139 |
// CAccSrvProcessCommandTimer::ConstructL
|
|
140 |
// Symbian 2nd phase constructor can leave.
|
|
141 |
// -----------------------------------------------------------------------------
|
|
142 |
//
|
|
143 |
void CSchedulerStopAndStartTimer::ConstructL()
|
|
144 |
{
|
|
145 |
FUNC_LOG;
|
|
146 |
CTimer::ConstructL();
|
|
147 |
CActiveScheduler* AS = CActiveScheduler::Current();
|
|
148 |
CActiveScheduler::Add( this );
|
|
149 |
}
|
|
150 |
|
|
151 |
|
|
152 |
// ======== GLOBAL FUNCTIONS ========
|
|
153 |
|