|
1 /* |
|
2 * Copyright (c) 2004 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: This class implements the waiting for next login retry feature |
|
15 * for the Always Online Plugin |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CPEngAOPluginTimer.h" |
|
22 #include "MPEngAOWaitObserver.h" |
|
23 |
|
24 #include "IMPSCommonUiDebugPrint.h" |
|
25 |
|
26 // ============================ MEMBER FUNCTIONS =============================== |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CPEngAOPluginTimer::CPEngAOPluginTimer |
|
30 // C++ default constructor can NOT contain any code, that |
|
31 // might leave. |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CPEngAOPluginTimer::CPEngAOPluginTimer() : CTimer( EPriorityStandard ) |
|
35 { |
|
36 CActiveScheduler::Add( this ); |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CPEngAOPluginTimer::ConstructL |
|
41 // Symbian 2nd phase constructor can leave. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 void CPEngAOPluginTimer::ConstructL() |
|
45 { |
|
46 // the base class must be constructed explicitely |
|
47 CTimer::ConstructL(); |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CPEngAOPluginTimer::NewL |
|
52 // Two-phased constructor. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CPEngAOPluginTimer* CPEngAOPluginTimer::NewL() |
|
56 { |
|
57 CPEngAOPluginTimer* self = new( ELeave ) CPEngAOPluginTimer; |
|
58 |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(); |
|
61 CleanupStack::Pop( self ); |
|
62 |
|
63 return self; |
|
64 } |
|
65 |
|
66 // Destructor |
|
67 CPEngAOPluginTimer::~CPEngAOPluginTimer() |
|
68 { |
|
69 Cancel(); |
|
70 } |
|
71 |
|
72 void CPEngAOPluginTimer::SetObserver( MPEngAOWaitObserver* aObserver ) |
|
73 { |
|
74 iObserver = aObserver; |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CPEngAOPluginTimer::At |
|
79 // Derived from CTimer |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void CPEngAOPluginTimer::At( const TTime& aTime ) |
|
83 { |
|
84 iTimerStarted.HomeTime(); |
|
85 iExpectedLaunchTime = aTime; |
|
86 CTimer::At( aTime ); |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CPEngAOPluginTimer::RunL |
|
91 // Derived from CActive |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 void CPEngAOPluginTimer::RunL() |
|
95 { |
|
96 IMPSCUI_DP_FUNC_ENTER( "RunL" ); |
|
97 if ( iObserver ) |
|
98 { |
|
99 TInt status( iStatus.Int() ); |
|
100 IMPSCUI_DP( D_IMPSCUI_LIT( "CPEngAOPluginTimer::RunL status = %d" ), status ); |
|
101 if ( status < KErrNone ) |
|
102 { |
|
103 if ( status == KErrAbort ) |
|
104 { |
|
105 TTime curTime; |
|
106 curTime.HomeTime(); |
|
107 |
|
108 // if current time is between start time and |
|
109 // expected launch time then just restarting timer to |
|
110 // expected launch time to avoid unnecessary timer |
|
111 // early launching |
|
112 if ( ( curTime > iTimerStarted ) && |
|
113 ( curTime < iExpectedLaunchTime ) ) |
|
114 { |
|
115 IMPSCUI_DP_TXT( "Timer stopped prematurely with error KErrAbort(-39)" ); |
|
116 IMPSCUI_DP_TXT( "Restarting timer to expected launch time" ); |
|
117 TDateTime launchTime; |
|
118 launchTime = iExpectedLaunchTime.DateTime(); |
|
119 // +1 added to day and month to get debug print human readable form |
|
120 IMPSCUI_DP( D_IMPSCUI_LIT( "year [%d] " ), launchTime.Year() ); |
|
121 IMPSCUI_DP( D_IMPSCUI_LIT( "day [%d], month [%d]" ), launchTime.Day() + 1, |
|
122 launchTime.Month() + 1 ); |
|
123 IMPSCUI_DP( D_IMPSCUI_LIT( "hour [%d], minu [%d]" ), launchTime.Hour(), |
|
124 launchTime.Minute() ); |
|
125 At( iExpectedLaunchTime ); |
|
126 // returning because error handled in this timer itself |
|
127 IMPSCUI_DP_FUNC_DONE( "RunL" ); |
|
128 return; |
|
129 } |
|
130 } |
|
131 iObserver->HandleTimeWaitedError( status ); |
|
132 } |
|
133 else |
|
134 { |
|
135 iObserver->HandleTimeWaited(); |
|
136 } |
|
137 } |
|
138 IMPSCUI_DP_FUNC_DONE( "RunL" ); |
|
139 } |
|
140 |
|
141 // --------------------------------------------------------- |
|
142 // CPEngAOPluginTimer::RunError |
|
143 // Derived from CActive |
|
144 // --------------------------------------------------------- |
|
145 // |
|
146 TInt CPEngAOPluginTimer::RunError( TInt aError ) |
|
147 { |
|
148 IMPSCUI_DP( D_IMPSCUI_LIT( "CPEngAOPluginTimer::RunError [%d]" ), aError ); |
|
149 |
|
150 if ( iObserver ) |
|
151 { |
|
152 iObserver->HandleTimeWaitedError( aError ); |
|
153 } |
|
154 |
|
155 return aError; |
|
156 } |
|
157 |
|
158 // End of File |