|
1 /* |
|
2 * Copyright (c) 2007 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 * CMsgGarbageCollection implementation file |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <watcher.h> |
|
23 #include <msvids.h> |
|
24 #include <mtclreg.h> |
|
25 #include <mtclbase.h> |
|
26 #include <SendUiConsts.h> |
|
27 #include <PushMtmCommands.hrh> // EPushMtmCmdCollectGarbage |
|
28 |
|
29 #include "MsgGarbageCollection.h" |
|
30 |
|
31 #ifdef USE_LOGGER |
|
32 #include "MsgErrorWatcherLogging.h" |
|
33 #endif |
|
34 |
|
35 // CONSTANTS |
|
36 const TUint KGarbageCollectionInterval = 1; // In hours |
|
37 |
|
38 // ================= MEMBER FUNCTIONS ======================= |
|
39 |
|
40 // --------------------------------------------------------- |
|
41 // CMsgGarbageCollection::NewL |
|
42 // --------------------------------------------------------- |
|
43 // |
|
44 CMsgGarbageCollection* CMsgGarbageCollection::NewL( |
|
45 CClientMtmRegistry& aMtmRegistry ) |
|
46 { |
|
47 CMsgGarbageCollection* self = new ( ELeave ) CMsgGarbageCollection( aMtmRegistry ); |
|
48 |
|
49 CleanupStack::PushL( self ); |
|
50 self->ConstructL(); |
|
51 CleanupStack::Pop( self ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // --------------------------------------------------------- |
|
56 // CMsgGarbageCollection::CMsgGarbageCollection |
|
57 // --------------------------------------------------------- |
|
58 // |
|
59 CMsgGarbageCollection::CMsgGarbageCollection( CClientMtmRegistry& aMtmRegistry ) |
|
60 : CActive( EPriorityStandard ), |
|
61 iMtmRegistry( aMtmRegistry ) |
|
62 { |
|
63 CActiveScheduler::Add( this ); |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------- |
|
67 // CMsgGarbageCollection::~CMsgGarbageCollection |
|
68 // --------------------------------------------------------- |
|
69 // |
|
70 CMsgGarbageCollection::~CMsgGarbageCollection() |
|
71 { |
|
72 Cancel(); |
|
73 iTimer.Close(); |
|
74 delete iOp; |
|
75 delete iWapMtm; |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------- |
|
79 // CMsgGarbageCollection::ConstructL |
|
80 // --------------------------------------------------------- |
|
81 // |
|
82 void CMsgGarbageCollection::ConstructL() |
|
83 { |
|
84 #ifdef USE_LOGGER |
|
85 MEWLOGGER_ENTERFN( "GarbageCollection: ConstructL" ); |
|
86 #endif |
|
87 User::LeaveIfError( iTimer.CreateLocal() ); |
|
88 iWapMtm = iMtmRegistry.NewMtmL( KSenduiMtmPushMtmUid ); |
|
89 |
|
90 StartWaiting(); |
|
91 |
|
92 #ifdef USE_LOGGER |
|
93 MEWLOGGER_LEAVEFN( "GarbageCollection: ConstructL" ); |
|
94 #endif |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------- |
|
98 // CMsgGarbageCollection::RunL |
|
99 // --------------------------------------------------------- |
|
100 // |
|
101 void CMsgGarbageCollection::RunL() |
|
102 { |
|
103 #ifdef USE_LOGGER |
|
104 MEWLOGGER_ENTERFN( "GarbageCollection: RunL" ); |
|
105 #endif |
|
106 if ( iState == EGarbageCollectionWaiting ) |
|
107 { |
|
108 WapPushGarbageCollectionL(); |
|
109 } |
|
110 else |
|
111 { |
|
112 StartWaiting(); |
|
113 } |
|
114 #ifdef USE_LOGGER |
|
115 MEWLOGGER_LEAVEFN( "GarbageCollection: RunL" ); |
|
116 #endif |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------- |
|
120 // CMsgGarbageCollection::DoCancel |
|
121 // --------------------------------------------------------- |
|
122 // |
|
123 void CMsgGarbageCollection::DoCancel() |
|
124 { |
|
125 iTimer.Cancel(); |
|
126 if ( iOp ) |
|
127 { |
|
128 iOp->Cancel(); |
|
129 } |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------- |
|
133 // CMsgGarbageCollection::StartWaiting |
|
134 // --------------------------------------------------------- |
|
135 // |
|
136 void CMsgGarbageCollection::StartWaiting() |
|
137 { |
|
138 #ifdef USE_LOGGER |
|
139 MEWLOGGER_ENTERFN( "GarbageCollection: StartWaiting" ); |
|
140 #endif |
|
141 iState = EGarbageCollectionWaiting; |
|
142 iStatus = KRequestPending; |
|
143 TTime time; |
|
144 time.UniversalTime(); |
|
145 time += TTimeIntervalHours( KGarbageCollectionInterval ); |
|
146 iTimer.AtUTC( iStatus, time ); |
|
147 SetActive(); |
|
148 #ifdef USE_LOGGER |
|
149 MEWLOGGER_LEAVEFN( "GarbageCollection: StartWaiting" ); |
|
150 #endif |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------- |
|
154 // CMsgGarbageCollection::WapPushGarbageCollectionL |
|
155 // --------------------------------------------------------- |
|
156 // |
|
157 void CMsgGarbageCollection::WapPushGarbageCollectionL() |
|
158 { |
|
159 #ifdef USE_LOGGER |
|
160 MEWLOGGER_ENTERFN( "GarbageCollection: WapPushGarbageCollectionL" ); |
|
161 #endif |
|
162 // Delete just in case... |
|
163 iState = EGarbageCollectionWapPush; |
|
164 CMsvEntrySelection* selection = new( ELeave ) CMsvEntrySelection(); |
|
165 CleanupStack::PushL( selection ); |
|
166 TBuf8<1> blankParams; |
|
167 iStatus = KRequestPending; |
|
168 delete iOp; |
|
169 iOp = NULL; |
|
170 iOp = iWapMtm->InvokeAsyncFunctionL( |
|
171 EPushMtmCmdCollectGarbage, |
|
172 *selection, |
|
173 blankParams, |
|
174 iStatus ); |
|
175 CleanupStack::PopAndDestroy( selection ); |
|
176 SetActive(); |
|
177 #ifdef USE_LOGGER |
|
178 MEWLOGGER_LEAVEFN( "GarbageCollection: WapPushGarbageCollectionL" ); |
|
179 #endif |
|
180 } |
|
181 |
|
182 // End of File |
|
183 |