|
1 /* |
|
2 * Copyright (c) 2002-2005 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: General purpose class for timeout notification. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "epos_comasupltimeouttimer.h" |
|
21 #include "epos_momasupltimeoutnotifier.h" |
|
22 |
|
23 #if defined(_DEBUG) |
|
24 _LIT( KPanicMsg, "COMASuplTimeoutTimer"); |
|
25 #endif |
|
26 |
|
27 // COMASuplTimeoutTimer::NewL |
|
28 // Creates instance of COMASuplTimeoutTimer |
|
29 |
|
30 COMASuplTimeoutTimer* COMASuplTimeoutTimer::NewL(MOMASuplTimeOutNotifier& aTimeOutNotify) |
|
31 { |
|
32 COMASuplTimeoutTimer* self = COMASuplTimeoutTimer::NewLC(aTimeOutNotify); |
|
33 CleanupStack::Pop(self); |
|
34 return self; |
|
35 } |
|
36 |
|
37 // COMASuplTimeoutTimer::NewLC |
|
38 // Creates instance of COMASuplTimeoutTimer & pushes into cleanup stack |
|
39 COMASuplTimeoutTimer* COMASuplTimeoutTimer::NewLC(MOMASuplTimeOutNotifier& aTimeOutNotify) |
|
40 { |
|
41 COMASuplTimeoutTimer* self = new (ELeave) COMASuplTimeoutTimer(aTimeOutNotify); |
|
42 CleanupStack::PushL(self); |
|
43 self->ConstructL(); |
|
44 return self; |
|
45 } |
|
46 |
|
47 // COMASuplTimeoutTimer::COMASuplTimeoutTimer |
|
48 // Constructor |
|
49 COMASuplTimeoutTimer::COMASuplTimeoutTimer(MOMASuplTimeOutNotifier& aTimeOutNotify) |
|
50 : CTimer(CActive::EPriorityStandard), iNotify(aTimeOutNotify),iTimerExpired(EFalse) |
|
51 { |
|
52 } |
|
53 |
|
54 // COMASuplTimeoutTimer::~COMASuplTimeoutTimer() |
|
55 // Destuctor |
|
56 COMASuplTimeoutTimer::~COMASuplTimeoutTimer() |
|
57 { |
|
58 } |
|
59 |
|
60 // COMASuplTimeoutTimer::ConstructL() |
|
61 // 2nd phase constuction |
|
62 void COMASuplTimeoutTimer::ConstructL() |
|
63 { |
|
64 CTimer::ConstructL(); |
|
65 CActiveScheduler::Add(this); |
|
66 } |
|
67 |
|
68 // COMASuplTimeoutTimer::StartTimer() |
|
69 // Starts timer |
|
70 void COMASuplTimeoutTimer::StartTimer( const TInt aTimeOut) |
|
71 { |
|
72 if (!IsActive()) |
|
73 { |
|
74 iTimerExpired = EFalse; |
|
75 After(aTimeOut); |
|
76 } |
|
77 } |
|
78 |
|
79 // COMASuplTimeoutTimer::StopTimer() |
|
80 // Stops timer |
|
81 void COMASuplTimeoutTimer::StopTimer() |
|
82 { |
|
83 iTimerExpired = EFalse; |
|
84 Cancel(); |
|
85 } |
|
86 |
|
87 // COMASuplTimeoutTimer::RunL() |
|
88 // Gets called when time out occurs |
|
89 void COMASuplTimeoutTimer::RunL() |
|
90 { |
|
91 // Timer request has completed, so notify the timer's owner |
|
92 if (iStatus == KErrNone) |
|
93 { |
|
94 iTimerExpired = ETrue; |
|
95 iNotify.TimerExpiredL(); |
|
96 } |
|
97 else |
|
98 { |
|
99 #if defined(_DEBUG) |
|
100 User::Panic(KPanicMsg, ESuplTimeoutTimerFailed); |
|
101 #endif |
|
102 } |
|
103 } |
|
104 |
|
105 TBool COMASuplTimeoutTimer::IsTimerExpired() |
|
106 { |
|
107 return iTimerExpired; |
|
108 } |