26 #include "ipvmbxengine.h" |
26 #include "ipvmbxengine.h" |
27 |
27 |
28 |
28 |
29 const TInt KMinReSubscribeDelta = 600; // 10 min |
29 const TInt KMinReSubscribeDelta = 600; // 10 min |
30 const TInt KMaxReSubscribeDelta = 86400; // 24 h |
30 const TInt KMaxReSubscribeDelta = 86400; // 24 h |
31 const TUint32 KServerRefreshInterval = KMaxReSubscribeDelta; |
|
32 const TInt KSecondsToMicro = 1000000; |
|
33 |
31 |
34 _LIT8( KEventHeader8, "message-summary" ); |
32 _LIT8( KEventHeader8, "message-summary" ); |
35 |
33 |
36 |
34 |
37 // ============================ MEMBER FUNCTIONS ============================== |
35 // ============================ MEMBER FUNCTIONS ============================== |
57 // Symbian 2nd phase constructor can leave. |
54 // Symbian 2nd phase constructor can leave. |
58 // ---------------------------------------------------------------------------- |
55 // ---------------------------------------------------------------------------- |
59 // |
56 // |
60 void CIpVmbxBase::ConstructL( TDesC8& aVoiceMailUri8 ) |
57 void CIpVmbxBase::ConstructL( TDesC8& aVoiceMailUri8 ) |
61 { |
58 { |
62 iReSubscribe = CDeltaTimer::NewL( CActive::EPriorityIdle ); |
|
63 if ( iVmbxUri8.MaxLength() >= aVoiceMailUri8.Length() ) |
59 if ( iVmbxUri8.MaxLength() >= aVoiceMailUri8.Length() ) |
64 { |
60 { |
65 iVmbxUri8.Copy( aVoiceMailUri8 ); |
61 iVmbxUri8.Copy( aVoiceMailUri8 ); |
66 } |
62 } |
67 TCallBack cb( ReSubscribe, this ); |
|
68 iUpdateEvent.Set( cb ); |
|
69 } |
63 } |
70 |
64 |
71 |
65 |
72 // ---------------------------------------------------------------------------- |
66 // ---------------------------------------------------------------------------- |
73 // Two-phased constructor. |
67 // Two-phased constructor. |
141 { |
130 { |
142 // Resubscribe shouldn't occur too infrequently |
131 // Resubscribe shouldn't occur too infrequently |
143 aReSubscribe = KMaxReSubscribeDelta; |
132 aReSubscribe = KMaxReSubscribeDelta; |
144 } |
133 } |
145 |
134 |
146 iReSubscribePeriod = ( TInt64 ) aReSubscribe * ( TInt64 ) KSecondsToMicro; |
135 TUint32 resubscribeInterval = ( TUint32 ) aReSubscribe; |
147 |
136 |
|
137 IPVMEPRINT2( "CIpVmbxAppBase::SubscribeL - resubscribe interval=%d", |
|
138 resubscribeInterval ); |
|
139 |
148 __ASSERT_DEBUG( !iMceOutEvent, Panic( KErrAlreadyExists ) ); |
140 __ASSERT_DEBUG( !iMceOutEvent, Panic( KErrAlreadyExists ) ); |
149 |
141 |
150 if ( !iMceOutEvent ) |
142 if ( !iMceOutEvent ) |
151 { |
143 { |
152 iMceOutEvent = CMceOutEvent::NewL( |
144 iMceOutEvent = CMceOutEvent::NewL( |
153 iMceManager, |
145 iMceManager, |
154 *iSipProfile, |
146 *iSipProfile, |
155 iVmbxUri8, |
147 iVmbxUri8, |
156 KEventHeader8, |
148 KEventHeader8, |
157 KServerRefreshInterval ); |
149 resubscribeInterval ); |
158 } |
150 } |
159 else |
151 else |
160 { |
152 { |
161 User::Leave( KErrAlreadyExists ); |
153 User::Leave( KErrAlreadyExists ); |
162 } |
154 } |
181 // |
173 // |
182 void CIpVmbxBase::TerminateEventL() |
174 void CIpVmbxBase::TerminateEventL() |
183 { |
175 { |
184 IPVMEPRINT( "CIpVmbxAppBase::TerminateEventL - IN" ); |
176 IPVMEPRINT( "CIpVmbxAppBase::TerminateEventL - IN" ); |
185 |
177 |
186 iReSubscribe->Remove( iUpdateEvent ); |
|
187 if ( iMceOutEvent && CMceEvent::EActive == iMceOutEvent->State() ) |
178 if ( iMceOutEvent && CMceEvent::EActive == iMceOutEvent->State() ) |
188 { |
179 { |
189 iMceOutEvent->TerminateL(); |
180 iMceOutEvent->TerminateL(); |
190 iState = ETerminating; |
181 iState = ETerminating; |
191 } |
182 } |
207 delete iMceOutEvent; |
198 delete iMceOutEvent; |
208 iMceOutEvent = NULL; |
199 iMceOutEvent = NULL; |
209 } |
200 } |
210 |
201 |
211 |
202 |
|
203 // ---------------------------------------------------------------------------- |
|
204 // |
|
205 // ---------------------------------------------------------------------------- |
|
206 // |
|
207 void CIpVmbxBase::Cancel() |
|
208 { |
|
209 iState = EDisabled; |
|
210 } |
|
211 |
|
212 |
212 // --------------------------------------------------------------------------- |
213 // --------------------------------------------------------------------------- |
213 // |
214 // |
214 // --------------------------------------------------------------------------- |
215 // --------------------------------------------------------------------------- |
215 // |
216 // |
216 TInt CIpVmbxBase::ReSubscribe( TAny* aThis ) |
|
217 { |
|
218 CIpVmbxBase* base = reinterpret_cast<CIpVmbxBase*> ( aThis ); |
|
219 __ASSERT_DEBUG( base, Panic( KErrArgument ) ); |
|
220 IPVMEPRINT2( |
|
221 "CIpVmbxAppBase::ReSubscribeL - IN state: %d", |
|
222 base->iMceOutEvent->State() ); |
|
223 |
|
224 if ( base && base->iMceOutEvent ) |
|
225 { |
|
226 switch ( base->iMceOutEvent->State() ) |
|
227 { |
|
228 case CMceEvent::EActive: |
|
229 { |
|
230 TRAPD( err, base->iMceOutEvent->UpdateL( KServerRefreshInterval ) ); |
|
231 if ( err ) |
|
232 { |
|
233 base->iVmbxEngine.HandleMessage( |
|
234 base->iServiceProviderId, CIpVmbxEngine::EEngineNetworkError ); |
|
235 } |
|
236 base->iPendingResubscribeCount = 0; |
|
237 if ( !base->iReSubscribe->IsActive() ) |
|
238 { |
|
239 base->iReSubscribe->QueueLong( |
|
240 base->iReSubscribePeriod, |
|
241 base->iUpdateEvent ); |
|
242 } |
|
243 break; |
|
244 } |
|
245 case CMceEvent::EPending: |
|
246 { |
|
247 if ( base->iPendingResubscribeCount++ ) |
|
248 { |
|
249 // Allows to skip one resubscribe before error occurs |
|
250 base->iVmbxEngine.HandleMessage( |
|
251 base->iServiceProviderId, |
|
252 CIpVmbxEngine::EEngineNetworkLost ); |
|
253 } |
|
254 break; |
|
255 } |
|
256 case CMceEvent::EIdle: |
|
257 case CMceEvent::ETerminated: |
|
258 { |
|
259 base->iVmbxEngine.HandleMessage( |
|
260 base->iServiceProviderId, |
|
261 CIpVmbxEngine::EEngineNetworkLost ); |
|
262 break; |
|
263 } |
|
264 default: |
|
265 IPVMEPRINT( "Unhandled message!" ); |
|
266 } |
|
267 } |
|
268 |
|
269 IPVMEPRINT( "CIpVmbxAppBase::ReSubscribeL - OUT" ); |
|
270 return KErrNone; |
|
271 } |
|
272 |
|
273 |
|
274 // ---------------------------------------------------------------------------- |
|
275 // |
|
276 // ---------------------------------------------------------------------------- |
|
277 // |
|
278 void CIpVmbxBase::Cancel() |
|
279 { |
|
280 iState = EDisabled; |
|
281 iReSubscribe->Remove( iUpdateEvent ); |
|
282 } |
|
283 |
|
284 |
|
285 // --------------------------------------------------------------------------- |
|
286 // |
|
287 // --------------------------------------------------------------------------- |
|
288 // |
|
289 TUint32 CIpVmbxBase::ServiceProviderId() const |
217 TUint32 CIpVmbxBase::ServiceProviderId() const |
290 { |
218 { |
291 return iServiceProviderId; |
219 return iServiceProviderId; |
292 } |
220 } |
293 |
221 |
307 // ---------------------------------------------------------------------------- |
235 // ---------------------------------------------------------------------------- |
308 // |
236 // |
309 void CIpVmbxBase::SetStateRegistered() |
237 void CIpVmbxBase::SetStateRegistered() |
310 { |
238 { |
311 iState = ERegistered; |
239 iState = ERegistered; |
312 if ( !iReSubscribe->IsActive() ) |
|
313 { |
|
314 iReSubscribe->QueueLong( iReSubscribePeriod, iUpdateEvent ); |
|
315 } |
|
316 } |
240 } |
317 |
241 |
318 |
242 |
319 // ---------------------------------------------------------------------------- |
243 // ---------------------------------------------------------------------------- |
320 // |
244 // |