|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * Timer implementation designed for always online timed operations |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "AlwaysOnlineEmailPluginLogging.h" |
|
21 #include "AlwaysOnlineEmailLoggingTools.h" |
|
22 #include "AlwaysOnlineEmailPluginTimer.h" |
|
23 |
|
24 // ---------------------------------------------------------------------------- |
|
25 // CAlwaysOnlineEmailPluginTimer::NewL |
|
26 // ---------------------------------------------------------------------------- |
|
27 CAlwaysOnlineEmailPluginTimer* CAlwaysOnlineEmailPluginTimer::NewL( |
|
28 CMsvSession& aMsvSession, TRequestStatus& aStatus ) |
|
29 { |
|
30 AOLOG_IN( "CAlwaysOnlineEmailPluginTimer::NewL" ); |
|
31 CAlwaysOnlineEmailPluginTimer* self = |
|
32 new( ELeave ) CAlwaysOnlineEmailPluginTimer( |
|
33 aMsvSession, CActive::EPriorityIdle, aStatus ); |
|
34 CleanupStack::PushL( self ); |
|
35 self->ConstructL(); |
|
36 CleanupStack::Pop( self ); |
|
37 return self; |
|
38 } |
|
39 |
|
40 // ---------------------------------------------------------------------------- |
|
41 // CAlwaysOnlineEmailPluginTimer::CAlwaysOnlineEmailPluginTimer |
|
42 // ---------------------------------------------------------------------------- |
|
43 CAlwaysOnlineEmailPluginTimer::CAlwaysOnlineEmailPluginTimer( |
|
44 CMsvSession& aMsvSession, |
|
45 TInt aPriority, |
|
46 TRequestStatus& aObserverRequestStatus ) |
|
47 : CMsvOperation(aMsvSession, aPriority, aObserverRequestStatus) |
|
48 { |
|
49 } |
|
50 |
|
51 |
|
52 // ---------------------------------------------------------------------------- |
|
53 // CAlwaysOnlineEmailPluginTimer::~CAlwaysOnlineEmailPluginTimer() |
|
54 // ---------------------------------------------------------------------------- |
|
55 CAlwaysOnlineEmailPluginTimer::~CAlwaysOnlineEmailPluginTimer() |
|
56 { |
|
57 AOLOG_IN( "CAlwaysOnlineEmailPluginTimer::~CAlwaysOnlineEmailPluginTimer" ); |
|
58 iTimer.Close(); |
|
59 } |
|
60 |
|
61 |
|
62 // ---------------------------------------------------------------------------- |
|
63 // CAlwaysOnlineEmailPluginTimer::ConstructL() |
|
64 // ---------------------------------------------------------------------------- |
|
65 void CAlwaysOnlineEmailPluginTimer::ConstructL() |
|
66 { |
|
67 AOLOG_IN( "CAlwaysOnlineEmailPluginTimer::ConstructL" ); |
|
68 User::LeaveIfError( iTimer.CreateLocal() ); |
|
69 CActiveScheduler::Add(this); |
|
70 } |
|
71 |
|
72 |
|
73 // ---------------------------------------------------------------------------- |
|
74 // CAlwaysOnlineEmailPluginTimer::ProgressL |
|
75 // ---------------------------------------------------------------------------- |
|
76 const TDesC8& CAlwaysOnlineEmailPluginTimer::ProgressL() |
|
77 { |
|
78 AOLOG_IN( "CAlwaysOnlineEmailPluginTimer::ProgressL" ); |
|
79 return iProgress; |
|
80 } |
|
81 |
|
82 // ---------------------------------------------------------------------------- |
|
83 // CAlwaysOnlineEmailPluginTimer::At |
|
84 // ---------------------------------------------------------------------------- |
|
85 void CAlwaysOnlineEmailPluginTimer::At(const TTime& aTime) |
|
86 { |
|
87 AOLOG_IN( "CAlwaysOnlineEmailPluginTimer::At" ); |
|
88 iCompletionTime = aTime; |
|
89 iTimer.Cancel(); |
|
90 iTimer.At(iStatus, aTime); // CSI: 1 # not an array |
|
91 SetActive(); |
|
92 } |
|
93 |
|
94 // ---------------------------------------------------------------------------- |
|
95 // CAlwaysOnlineEmailPluginTimer::DoCancel |
|
96 // ---------------------------------------------------------------------------- |
|
97 void CAlwaysOnlineEmailPluginTimer::DoCancel() |
|
98 { |
|
99 AOLOG_IN( "CAlwaysOnlineEmailPluginTimer::DoCancel" ); |
|
100 iTimer.Cancel(); |
|
101 TRequestStatus* status = &iObserverRequestStatus; |
|
102 User::RequestComplete( status, KErrCancel ); |
|
103 } |
|
104 |
|
105 |
|
106 // ---------------------------------------------------------------------------- |
|
107 // CAlwaysOnlineEmailPluginTimer::RunL |
|
108 // ---------------------------------------------------------------------------- |
|
109 void CAlwaysOnlineEmailPluginTimer::RunL() |
|
110 { |
|
111 AOLOG_IN( "CAlwaysOnlineEmailPluginTimer::RunL" ); |
|
112 KAOEMAIL_LOGGER_WRITE_FORMAT2("CAlwaysOnlineEmailPluginTimer::RunL(). OpId: %d RequestStatus: %d ",Id(), iObserverRequestStatus.Int() ); |
|
113 TTime home; |
|
114 home.HomeTime(); |
|
115 |
|
116 //get rid of microseconds, we don't need them. Second is accurate enough. Microseconds can and will change during execution anyway. |
|
117 TDateTime dtHome = home.DateTime(); |
|
118 TDateTime dtCompletion = iCompletionTime.DateTime(); |
|
119 dtHome.SetMicroSecond(0); |
|
120 dtCompletion.SetMicroSecond(0); |
|
121 |
|
122 home = dtHome; |
|
123 iCompletionTime = dtCompletion; |
|
124 |
|
125 |
|
126 KAOEMAIL_LOGGER_WRITE_DATETIME("CAlwaysOnlineEmailPluginTimer::RunL() HomeTime: ", home ); |
|
127 KAOEMAIL_LOGGER_WRITE_DATETIME("CAlwaysOnlineEmailPluginTimer::RunL() CompletionTime should be: ", iCompletionTime ); |
|
128 |
|
129 if( home >= iCompletionTime) |
|
130 { |
|
131 TRequestStatus* status = &iObserverRequestStatus; |
|
132 User::RequestComplete(status, KErrNone); |
|
133 } |
|
134 else |
|
135 { |
|
136 KAOEMAIL_LOGGER_WRITE("CAlwaysOnlineEmailPluginTimer::RunL() Timer stopped prematurely! Not going to complete, restarting timer"); |
|
137 KAOEMAIL_LOGGER_WRITE_FORMAT("CAlwaysOnlineEmailPluginTimer::RunL() iStatus: %d", iStatus.Int()); |
|
138 Cancel(); |
|
139 iTimer.At(iStatus, iCompletionTime); // CSI: 1 # not an array |
|
140 SetActive(); |
|
141 } |
|
142 } |
|
143 |
|
144 // ---------------------------------------------------------------------------- |
|
145 // CAlwaysOnlineEmailPluginTimer::RunError() |
|
146 // ---------------------------------------------------------------------------- |
|
147 // |
|
148 TInt CAlwaysOnlineEmailPluginTimer::RunError( TInt /* aError */ ) |
|
149 { |
|
150 AOLOG_IN( "CAlwaysOnlineEmailPluginTimer::RunError" ); |
|
151 // Just ignore any error and continue without |
|
152 // any handling to allow smooth execution. |
|
153 return KErrNone; |
|
154 } |
|
155 |
|
156 //EOF |