|
1 // Copyright (c) 1998-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 "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Implements CSmsuTimeout |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 */ |
|
21 |
|
22 #include "SmsuTimer.h" |
|
23 |
|
24 #include <e32std.h> |
|
25 |
|
26 #include "smsumain.h" |
|
27 #include "smsstacklog.h" |
|
28 |
|
29 /** |
|
30 * 2 phase contructor |
|
31 * |
|
32 * @param aActive Reference to an active observer |
|
33 */ |
|
34 CSmsuTimeout* CSmsuTimeout::NewL(CSmsuActiveBase& aActive) |
|
35 { |
|
36 LOGSMSU1("CSmsuTimeout::NewL()"); |
|
37 |
|
38 CSmsuTimeout* self = new(ELeave) CSmsuTimeout(aActive); |
|
39 CleanupStack::PushL(self); |
|
40 self->ConstructL(); |
|
41 CleanupStack::Pop(self); |
|
42 return self; |
|
43 } |
|
44 |
|
45 /** |
|
46 * D'tor |
|
47 */ |
|
48 CSmsuTimeout::~CSmsuTimeout() |
|
49 { |
|
50 Cancel(); |
|
51 } |
|
52 |
|
53 |
|
54 /** |
|
55 * Start a timeout specified in aTimeIntervalMicroSeconds32 |
|
56 */ |
|
57 void CSmsuTimeout::Start(const TTimeIntervalMicroSeconds32& aTimeIntervalMicroSeconds32) |
|
58 { |
|
59 LOGSMSU1("CSmsuTimeout::Start()"); |
|
60 |
|
61 iTimedOut = EFalse; |
|
62 After(aTimeIntervalMicroSeconds32); |
|
63 } // CSmsuTimeout::Start |
|
64 |
|
65 |
|
66 /** |
|
67 * C'tor |
|
68 */ |
|
69 CSmsuTimeout::CSmsuTimeout(CSmsuActiveBase& aActive) |
|
70 : CTimer(aActive.Priority()), |
|
71 iActive(aActive), |
|
72 iTimedOut(EFalse), |
|
73 iCompleteMyselfRequested(EFalse) |
|
74 { |
|
75 LOGSMSU1("CSmsuTimeout::CSmsuTimeout()"); |
|
76 |
|
77 CActiveScheduler::Add(this); |
|
78 } // CSmsuTimeout::CSmsuTimeout |
|
79 |
|
80 |
|
81 /** |
|
82 * Timer completed - cancel the observer |
|
83 */ |
|
84 void CSmsuTimeout::RunL() |
|
85 { |
|
86 LOGSMSU2("CSmsuTimeout::RunL [iStatus=%d]", iStatus.Int() ); |
|
87 iTimedOut = ETrue; |
|
88 iActive.Cancel(); |
|
89 |
|
90 // |
|
91 // It would be nice to call a DoTimeout() function here, |
|
92 // and give the client the option of deciding what to do |
|
93 // next, but that would be a BC break. |
|
94 // |
|
95 // So instead, we can do the next best thing. If the client |
|
96 // calls CSmsuActiveBase::CompleteMyselfAfterTimeout() after |
|
97 // a timeout (but within the DoCancel() function) then |
|
98 // we now call the complete method - thereby restarting |
|
99 // the active object outside of the Cancel(). |
|
100 // |
|
101 if (iCompleteMyselfRequested) |
|
102 { |
|
103 iActive.CompleteMyself(iCompleteMyselfStatus); |
|
104 iCompleteMyselfRequested = EFalse; |
|
105 } |
|
106 } // CSmsuTimeout::RunL |
|
107 |
|
108 |
|
109 void CSmsuTimeout::RequestCompleteMyselfAfterCancel(TInt aStatus) |
|
110 { |
|
111 // Ignore in code coverage - not used within the SMS stack. |
|
112 BULLSEYE_OFF |
|
113 __ASSERT_DEBUG(iCompleteMyselfRequested == EFalse, SmsuPanic(ESmsuCompleteMyselfAlreadyRequested)); |
|
114 |
|
115 iCompleteMyselfRequested = ETrue; |
|
116 iCompleteMyselfStatus = aStatus; |
|
117 BULLSEYE_RESTORE |
|
118 } |