|
1 /* |
|
2 * Copyright (c) 2008 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 background checker |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <AknSoftNotifier.h> |
|
21 #include <AknNotifyStd.h> |
|
22 #include <AknSoftNotificationParameters.h> |
|
23 #include <avkon.rsg> |
|
24 #include <iaupdate.rsg> |
|
25 #include <centralrepository.h> |
|
26 #include "iaupdatebgremindertimer.h" |
|
27 #include "iaupdate.hrh" |
|
28 #include "iaupdateprivatecrkeys.h" |
|
29 #include "iaupdatebgconst.h" |
|
30 |
|
31 // ---------------------------------------------------------- |
|
32 // CIAUpdateBGReminderTimer::NewL() |
|
33 // ---------------------------------------------------------- |
|
34 CIAUpdateBGReminderTimer* CIAUpdateBGReminderTimer::NewL(MIAUpdateBGReminderTimerCallBack* aCallback) |
|
35 { |
|
36 CIAUpdateBGReminderTimer* self = new(ELeave)CIAUpdateBGReminderTimer(aCallback); |
|
37 CleanupStack::PushL(self); |
|
38 self->ConstructL(); |
|
39 CleanupStack::Pop(self); |
|
40 return self; |
|
41 } |
|
42 |
|
43 |
|
44 // ---------------------------------------------------------- |
|
45 // CIAUpdateBGReminderTimer::ConstructL() |
|
46 // ---------------------------------------------------------- |
|
47 void CIAUpdateBGReminderTimer::ConstructL() |
|
48 { |
|
49 CTimer::ConstructL(); |
|
50 CActiveScheduler::Add( this ); |
|
51 iInternalFile = CIAUpdateBGInternalFileHandler::NewL(); |
|
52 } |
|
53 |
|
54 |
|
55 // ---------------------------------------------------------- |
|
56 // CIAUpdateBGReminderTimer::~CIAUpdateBGReminderTimer() |
|
57 // ---------------------------------------------------------- |
|
58 CIAUpdateBGReminderTimer::~CIAUpdateBGReminderTimer() |
|
59 { |
|
60 Cancel(); |
|
61 delete iInternalFile; |
|
62 } |
|
63 |
|
64 |
|
65 // ---------------------------------------------------------- |
|
66 // CIAUpdateBGReminderTimer::CIAUpdateBGReminderTimer() |
|
67 // ---------------------------------------------------------- |
|
68 CIAUpdateBGReminderTimer::CIAUpdateBGReminderTimer(MIAUpdateBGReminderTimerCallBack* aCallback):CTimer( EPriorityStandard ), iCallback ( aCallback ) |
|
69 { |
|
70 } |
|
71 |
|
72 |
|
73 // ---------------------------------------------------------- |
|
74 // CIAUpdateBGReminderTimer::RunL() |
|
75 // ---------------------------------------------------------- |
|
76 void CIAUpdateBGReminderTimer::RunL() |
|
77 { |
|
78 |
|
79 if( iRuns == 0 ) |
|
80 { |
|
81 //timer expired call the callback |
|
82 iCallback->ReminderTimerCallBack(); |
|
83 } |
|
84 else |
|
85 { |
|
86 TTime currenttime; |
|
87 currenttime.UniversalTime(); |
|
88 |
|
89 if ( currenttime >= iNextRemindTime ) |
|
90 { |
|
91 StartL( StartNow ); |
|
92 } |
|
93 else |
|
94 { |
|
95 iInternalFile->ReadControllerDataL(); |
|
96 TTime nextremindtime = iInternalFile->NextRemindTime(); |
|
97 TTimeIntervalMinutes timetowait; |
|
98 currenttime.MinutesFrom( nextremindtime, timetowait ); |
|
99 StartL( timetowait ); |
|
100 } |
|
101 } |
|
102 } |
|
103 |
|
104 // ---------------------------------------------------------- |
|
105 // CIAUpdateBGReminderTimer::DoCancel() |
|
106 // ---------------------------------------------------------- |
|
107 void CIAUpdateBGReminderTimer::DoCancel() |
|
108 { |
|
109 } |
|
110 // ---------------------------------------------------------- |
|
111 // CIAUpdateBGReminderTimer::RunError() |
|
112 // ---------------------------------------------------------- |
|
113 TInt CIAUpdateBGReminderTimer::RunError(TInt /*aError*/) |
|
114 { |
|
115 return KErrNone; |
|
116 } |
|
117 |
|
118 // ---------------------------------------------------------- |
|
119 // CIAUpdateBGReminderTimer::StartReminderTimerL() |
|
120 // ---------------------------------------------------------- |
|
121 void CIAUpdateBGReminderTimer::StartReminderTimerL(TTimeIntervalMinutes& aTimetoWait ) |
|
122 { |
|
123 if ( IsActive() ) |
|
124 { |
|
125 Cancel(); |
|
126 } |
|
127 |
|
128 //show after one week |
|
129 StartL( aTimetoWait ); |
|
130 } |
|
131 |
|
132 |
|
133 // ---------------------------------------------------------- |
|
134 // CIAUpdateBGReminderTimer::CancelReminderTimerL() |
|
135 // ---------------------------------------------------------- |
|
136 void CIAUpdateBGReminderTimer::CancelReminderTimerL() |
|
137 { |
|
138 Cancel(); |
|
139 } |
|
140 |
|
141 |
|
142 // ---------------------------------------------------------- |
|
143 // CIAUpdateBGReminderTimer::StartL() |
|
144 // ---------------------------------------------------------- |
|
145 void CIAUpdateBGReminderTimer::StartL( TTimeIntervalMinutes aWaitTime ) |
|
146 { |
|
147 Cancel(); |
|
148 /* |
|
149 RTimer::After maximum delay is 35 minutes, 47 seconds this is because it is 32bit integer. |
|
150 Thats why aWaitTime is divided to 30min runs. |
|
151 */ |
|
152 iRuns = 0; |
|
153 if(aWaitTime.Int() > HalfHourInMinuts ) |
|
154 { |
|
155 iRuns = aWaitTime.Int() / HalfHourInMinuts; |
|
156 TTimeIntervalMinutes halfhour( HalfHourInMinuts ); |
|
157 After( ConvertToMicroseconds( halfhour ) ); |
|
158 } |
|
159 else{ |
|
160 After( ConvertToMicroseconds( aWaitTime ) ); |
|
161 } |
|
162 |
|
163 } |
|
164 |
|
165 // ---------------------------------------------------------- |
|
166 // CIAUpdateBGReminderTimer::ConvertToMicroseconds() |
|
167 // ---------------------------------------------------------- |
|
168 TTimeIntervalMicroSeconds32 CIAUpdateBGReminderTimer::ConvertToMicroseconds( TTimeIntervalMinutes aInterval ) |
|
169 { |
|
170 return aInterval.Int()*60*1000*1000; |
|
171 } |
|
172 |
|
173 // End of file |
|
174 |