|
1 /* |
|
2 * Copyright (c) 2010 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 * CMsgErrorWatcherPrivate implementation file |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32base.h> |
|
23 |
|
24 #include <msvapi.h> |
|
25 #include <msvids.h> //Msv index entry ID's |
|
26 #include <msvuids.h> |
|
27 #include <mmscmds.h> //EMmsScheduledReceiveForced |
|
28 #include <mmsconst.h> //Notification folder |
|
29 #include <SenduiMtmUids.h> //MTM Uids |
|
30 #include <mtclreg.h> //ClientMtmRegistry |
|
31 #include <watcher.h> |
|
32 #include <mmserrors.h> |
|
33 #include <mmsclient.h> |
|
34 #include <mmssettings.h> |
|
35 |
|
36 |
|
37 |
|
38 #include <xqconversions.h> |
|
39 #include <hbglobal.h> |
|
40 #include <HbTranslator> |
|
41 #include <QString> |
|
42 #include <in_iface.h> // KErrIfAuthenticationFailure |
|
43 #include <etelpckt.h> // KErrGprsInsufficientResources, etc. |
|
44 //#include <exterror.h> // KErrGsmMMServiceOptionTemporaryOutOfOrder |
|
45 #include <gsmerror.h> |
|
46 |
|
47 #include <centralrepository.h> // link against centralrepository.lib |
|
48 #include <messaginginternalcrkeys.h> // for Central Repository keys |
|
49 |
|
50 #include <messagingvariant.hrh> // Variation |
|
51 |
|
52 #include "msgerrorwatcher.h" |
|
53 #include "msgerrorwatcher_p.h" |
|
54 #include "msgerrorwatcher.hrh" |
|
55 #include "msgerrorcommdbobserver.h" |
|
56 #include "msgcenrepobserver.h" |
|
57 // this should be handled later, |
|
58 //#include "msgerrorconnectionobserver.h" |
|
59 #include "msgerrordiskspaceobserver.h" |
|
60 #include "msgerrorsmsdiskspaceobserver.h" |
|
61 #include "msgerrorextsmsdiskspaceobserver.h" |
|
62 #include "msgerrorroamingobserver.h" |
|
63 #include "msgerrorstartupobserver.h" |
|
64 |
|
65 |
|
66 |
|
67 #include "debugtraces.h" |
|
68 |
|
69 //const TInt KConnectionRetries = 3; |
|
70 //const TInt KIntMaxLength = 10; //2~32 =~ 4000000000 |
|
71 const TUint KInitialDelayBetweenSessionConnectRetries = 5000000; //five seconds |
|
72 const TUint KMaxTimerRetries = 50; |
|
73 //const TInt KDelayAfterDisconnect = 3000000; //3 seconds |
|
74 //Total delay between first and last retry is |
|
75 //( A * (B^2 + B) ) / 2 |
|
76 // - where A is KInitialDelayBetweenSessionConnectRetries |
|
77 // - and B is KMaxTimerRetries |
|
78 //If A = 5 seconds and B = 50 times last retry is made |
|
79 //after about 106 minutes from the first one. |
|
80 //const TMsvId KWatcherInboxFolderId = KMsvGlobalInBoxIndexEntryIdValue; |
|
81 const TMsvId KWatcherOutboxFolderId = KMsvGlobalOutBoxIndexEntryIdValue; |
|
82 //const TUid KMessageEntryUid = { KUidMsvMessageEntryValue }; |
|
83 |
|
84 |
|
85 CMsgErrorWatcherPrivate::CMsgErrorWatcherPrivate(MsgErrorWatcher* msgErrorWatcher ): |
|
86 CActive( EPriorityStandard ), |
|
87 q_ptr(msgErrorWatcher), |
|
88 iMmsServiceId( KMsvNullIndexEntryId ), |
|
89 iNotificationFolderId( KMsvNullIndexEntryId ), |
|
90 iCurrentEntryId ( KMsvNullIndexEntryId ) |
|
91 { |
|
92 QDEBUG_WRITE("CMsgErrorWatcherPrivate:CMsgErrorWatcherPrivate : Enter"); |
|
93 CActiveScheduler::Add( this ); |
|
94 TRAP_IGNORE(InitL()) |
|
95 QDEBUG_WRITE("CMsgErrorWatcherPrivate:CMsgErrorWatcherPrivate : Exit"); |
|
96 |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------- |
|
100 // CMsgErrorWatcherPrivate::CMsgErrorWatcherPrivate |
|
101 // |
|
102 // Symbian OS default constructor can leave. |
|
103 // --------------------------------------------------------- |
|
104 // |
|
105 void CMsgErrorWatcherPrivate::InitL() |
|
106 { |
|
107 QDEBUG_WRITE("CMsgErrorWatcherPrivate:InitL : Enter"); |
|
108 User::LeaveIfError( iTimer.CreateLocal() ); |
|
109 User::LeaveIfError(iFs.Connect()); |
|
110 |
|
111 TInt features = 0; |
|
112 CRepository* repository = CRepository::NewL( KCRUidMuiuVariation ); |
|
113 repository->Get( KMuiuMmsFeatures, features ); |
|
114 delete repository; |
|
115 repository = NULL; |
|
116 if ( features & KMmsFeatureIdDelayDisconnectDialog ) |
|
117 { |
|
118 iWatcherFlags |= EReceivingDisconnectDelay; |
|
119 } |
|
120 |
|
121 StartWatcherL(); |
|
122 QDEBUG_WRITE("CMsgErrorWatcherPrivate:InitL : Exit"); |
|
123 } |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 // --------------------------------------------------------- |
|
129 // CMsgErrorWatcherPrivate::~CMsgErrorWatcherPrivate |
|
130 // |
|
131 // Destructor |
|
132 // --------------------------------------------------------- |
|
133 // |
|
134 CMsgErrorWatcherPrivate::~CMsgErrorWatcherPrivate() |
|
135 { |
|
136 QDEBUG_WRITE("CMsgErrorWatcherPrivate:~CMsgErrorWatcherPrivate : Enter"); |
|
137 StopWatcher(); |
|
138 iTimer.Close(); |
|
139 QDEBUG_WRITE("CMsgErrorWatcherPrivate:~CMsgErrorWatcherPrivate : Exit"); |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------- |
|
143 // CMsgErrorWatcherPrivate::StartWatcherL |
|
144 // |
|
145 // Does the actual construction of the watcher. |
|
146 // --------------------------------------------------------- |
|
147 // |
|
148 void CMsgErrorWatcherPrivate::StartWatcherL() |
|
149 { |
|
150 QDEBUG_WRITE("CMsgErrorWatcherPrivate:StartMmsFetchL : Enter"); |
|
151 iSession = CMsvSession::OpenSyncL( *this ); |
|
152 // might be required in future for propogating the errors to the ui. |
|
153 iMmsReceiveErrorMessages = new ( ELeave ) CMsvEntrySelection; |
|
154 iMmsSendErrorMessages = new ( ELeave ) CMsvEntrySelection; |
|
155 |
|
156 // Get message server session |
|
157 iClientMtmRegistry = CClientMtmRegistry::NewL( *iSession ); |
|
158 TRAPD( err, |
|
159 { |
|
160 iMmsClient = static_cast<CMmsClientMtm*> |
|
161 ( iClientMtmRegistry->NewMtmL( KUidMsgTypeMultimedia ) ); |
|
162 } ); |
|
163 if ( err == KErrNotFound ) |
|
164 { |
|
165 QDEBUG_WRITE( "MmsClientMtm not found!" ); |
|
166 // Make sure iMmsClient is NULL - just in case. |
|
167 delete iMmsClient; |
|
168 iMmsClient = NULL; |
|
169 } |
|
170 else |
|
171 { |
|
172 User::LeaveIfError( err ); |
|
173 } |
|
174 |
|
175 if ( iMmsClient ) |
|
176 { |
|
177 // We're interested in roaming events only if MMS is enabled. |
|
178 iRoamingObserver = CMsgErrorRoamingObserver::NewL( *this ); |
|
179 QDEBUG_WRITE( "Created Roaming Observer!" ); |
|
180 } |
|
181 |
|
182 |
|
183 iStartupObserver = CMsgErrorStartupObserver::NewL( *this ); |
|
184 |
|
185 if(!( iWatcherFlags & EWatcherRunning)) |
|
186 { |
|
187 //if not yet created |
|
188 iSmsDiskSpaceObserver = CMsgErrorSmsDiskSpaceObserver::NewL( *this ); |
|
189 iSmsExtDiskSpaceObserver = CMsgErrorExtSmsDiskSpaceObserver::NewL( *this ); |
|
190 QDEBUG_WRITE( "Created iSmsDiskSpaceObserver, iSmsExtDiskSpaceObserver!" ); |
|
191 } |
|
192 |
|
193 iWatcherFlags |= EWatcherRunning; |
|
194 |
|
195 if ( GetMmsServiceL() ) |
|
196 { |
|
197 CheckMmsReceivingModeL(); |
|
198 } |
|
199 |
|
200 // Startup successful if we got this far. Reset retry counter. |
|
201 iTimerRetries = 0; |
|
202 |
|
203 QDEBUG_WRITE("CMsgErrorWatcherPrivate:StartWatcherL : Exit"); |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------- |
|
207 // CMsgErrorWatcherPrivate::StopWatcher |
|
208 // |
|
209 // Stops (and destructs) the watcher. |
|
210 // --------------------------------------------------------- |
|
211 // |
|
212 void CMsgErrorWatcherPrivate::StopWatcher() |
|
213 { |
|
214 QDEBUG_WRITE("CMsgErrorWatcherPrivate:~CMsgErrorWatcherPrivate : Enter"); |
|
215 iWatcherFlags &= ~EWatcherRunning; |
|
216 iWatcherFlags &= ~ENoAPErrorPending; |
|
217 iMmsServiceId = KMsvNullIndexEntryId; |
|
218 iNotificationFolderId = KMsvNullIndexEntryId; |
|
219 Cancel(); |
|
220 |
|
221 delete iCommDbObserver; |
|
222 iCommDbObserver = NULL; |
|
223 delete iCenRepObserver; |
|
224 iCenRepObserver = NULL; |
|
225 // delete iConnectionObserver; |
|
226 // iConnectionObserver = NULL; |
|
227 delete iDiskSpaceObserver; |
|
228 iDiskSpaceObserver = NULL; |
|
229 delete iSmsDiskSpaceObserver; |
|
230 iSmsDiskSpaceObserver = NULL; |
|
231 delete iSmsExtDiskSpaceObserver; |
|
232 iSmsExtDiskSpaceObserver = NULL; |
|
233 delete iRoamingObserver; |
|
234 iRoamingObserver = NULL; |
|
235 delete iMmsClient; |
|
236 iMmsClient = NULL; |
|
237 delete iClientMtmRegistry; |
|
238 iClientMtmRegistry = NULL; |
|
239 delete iOperation; |
|
240 iOperation = NULL; |
|
241 delete iStartupObserver; |
|
242 iStartupObserver = NULL; |
|
243 delete iSession; |
|
244 iSession = NULL; |
|
245 delete iMmsReceiveErrorMessages; |
|
246 iMmsReceiveErrorMessages = NULL; |
|
247 delete iMmsSendErrorMessages; |
|
248 iMmsSendErrorMessages = NULL; |
|
249 |
|
250 QDEBUG_WRITE("CMsgErrorWatcherPrivate:~CMsgErrorWatcherPrivate : Exit"); |
|
251 } |
|
252 |
|
253 // --------------------------------------------------------- |
|
254 // CMsgErrorWatcherPrivate::StartRestartTimer |
|
255 // |
|
256 // Start session reconnect timer. |
|
257 // --------------------------------------------------------- |
|
258 // |
|
259 void CMsgErrorWatcherPrivate::StartRestartTimer() |
|
260 { |
|
261 QDEBUG_WRITE("CMsgErrorWatcherPrivate:~CMsgErrorWatcherPrivate : Enter"); |
|
262 if ( !IsActive() ) |
|
263 { |
|
264 QDEBUG_WRITE( "Starting timer" ); |
|
265 iStatus = KRequestPending; |
|
266 iRequestType = EMsgRequestStartingUp; |
|
267 iTimerRetries++; |
|
268 //The interval between retries comes longer every time |
|
269 iTimer.After( iStatus, |
|
270 iTimerRetries * KInitialDelayBetweenSessionConnectRetries ); |
|
271 SetActive(); |
|
272 } |
|
273 QDEBUG_WRITE("CMsgErrorWatcherPrivate:~CMsgErrorWatcherPrivate : Exit"); |
|
274 } |
|
275 |
|
276 // --------------------------------------------------------- |
|
277 // CMsgErrorWatcherPrivate::ResetWatcher |
|
278 // |
|
279 // Resets watcher. |
|
280 // --------------------------------------------------------- |
|
281 // |
|
282 void CMsgErrorWatcherPrivate::ResetWatcher() |
|
283 { |
|
284 QDEBUG_WRITE("CMsgErrorWatcherPrivate:~CMsgErrorWatcherPrivate : Enter"); |
|
285 |
|
286 iWatcherFlags &= ~ENoAPErrorPending; |
|
287 |
|
288 //Drop all observers |
|
289 delete iCommDbObserver; |
|
290 iCommDbObserver = NULL; |
|
291 delete iCenRepObserver; |
|
292 iCenRepObserver = NULL; |
|
293 // delete iConnectionObserver; |
|
294 // iConnectionObserver = NULL; |
|
295 delete iDiskSpaceObserver; |
|
296 iDiskSpaceObserver = NULL; |
|
297 delete iSmsDiskSpaceObserver; |
|
298 iSmsDiskSpaceObserver = NULL; |
|
299 delete iSmsExtDiskSpaceObserver; |
|
300 iSmsExtDiskSpaceObserver = NULL; |
|
301 //Reset disk space errors |
|
302 iDiskSpaceErrors = 0; |
|
303 QDEBUG_WRITE("CMsgErrorWatcherPrivate:~CMsgErrorWatcherPrivate : Exit"); |
|
304 } |
|
305 |
|
306 // --------------------------------------------------------- |
|
307 // CMsgErrorWatcherPrivate::GetMmsServiceL |
|
308 // |
|
309 // Retrieves MMS service id from MsgStore |
|
310 // --------------------------------------------------------- |
|
311 // |
|
312 TBool CMsgErrorWatcherPrivate::GetMmsServiceL() |
|
313 { |
|
314 if ( !iMmsClient ) |
|
315 { |
|
316 return EFalse; |
|
317 } |
|
318 QDEBUG_WRITE("CMsgErrorWatcherPrivate:~CMsgErrorWatcherPrivate : Enter"); |
|
319 if ( iMmsServiceId == KMsvNullIndexEntryId ) |
|
320 { |
|
321 QDEBUG_WRITE( "Looking for MMS service" ); |
|
322 iMmsClient->RestoreSettingsL(); |
|
323 iMmsServiceId = iMmsClient->MmsSettings().Service(); |
|
324 iNotificationFolderId = iMmsClient->MmsSettings().NotificationFolder(); |
|
325 iMaxReceiveSize = iMmsClient->MmsSettings().MaximumReceiveSize(); |
|
326 } |
|
327 QDEBUG_WRITE("CMsgErrorWatcherPrivate:~CMsgErrorWatcherPrivate : Exit"); |
|
328 return ( iMmsServiceId != KMsvNullIndexEntryId ); |
|
329 } |
|
330 |
|
331 // --------------------------------------------------------- |
|
332 // CMsgErrorWatcherPrivate::StartMmsFetchL |
|
333 // |
|
334 // Initiates MMS fetch |
|
335 // --------------------------------------------------------- |
|
336 // |
|
337 void CMsgErrorWatcherPrivate::StartMmsFetchL() |
|
338 { |
|
339 QDEBUG_WRITE("CMsgErrorWatcherPrivate:~CMsgErrorWatcherPrivate : Enter"); |
|
340 if ( !IsActive() && iMmsReceiveErrorMessages->Count() ) |
|
341 { |
|
342 QDEBUG_WRITE_FORMAT("Fetching message(s): ", |
|
343 iMmsReceiveErrorMessages->Count() ); |
|
344 TCommandParameters parameters; // initialized to zero |
|
345 TCommandParametersBuf paramPack( parameters ); |
|
346 |
|
347 //Add service entry as the first entry in the array |
|
348 iMmsReceiveErrorMessages->InsertL( 0, iMmsServiceId ); |
|
349 |
|
350 // First remove existing schedules: |
|
351 QDEBUG_WRITE( "Deleting old schedules" ); |
|
352 // Calling synchronous TransferCommandL method |
|
353 const TInt KBufSize = 256; |
|
354 TBuf8<KBufSize> dummy; |
|
355 iSession->TransferCommandL( *iMmsReceiveErrorMessages, |
|
356 EMmsDeleteSchedule, |
|
357 paramPack, |
|
358 dummy ); |
|
359 QDEBUG_WRITE( "Old schedules deleted!" ); |
|
360 |
|
361 // Then reschedule: |
|
362 iStatus = KRequestPending; |
|
363 iRequestType = EMsgRequestFetching; |
|
364 delete iOperation; |
|
365 iOperation = NULL; |
|
366 QDEBUG_WRITE( "Request fetch" ); |
|
367 iOperation = iSession->TransferCommandL( *iMmsReceiveErrorMessages, |
|
368 EMmsScheduledReceive, |
|
369 paramPack, |
|
370 iStatus ); |
|
371 SetActive(); |
|
372 QDEBUG_WRITE( "Reset array" ); |
|
373 iMmsReceiveErrorMessages->Reset(); |
|
374 } |
|
375 QDEBUG_WRITE("CMsgErrorWatcherPrivate:~CMsgErrorWatcherPrivate : Exit"); |
|
376 } |
|
377 |
|
378 // --------------------------------------------------------- |
|
379 // CMsgErrorWatcherPrivate::StartMmsSendL |
|
380 // |
|
381 // |
|
382 // --------------------------------------------------------- |
|
383 // TODO: to be handled late when connection errors are handled. |
|
384 //void CMsgErrorWatcherPrivate::StartMmsSendL() |
|
385 // { |
|
386 // QDEBUG_WRITE("CMsgErrorWatcherPrivate:StartMmsSendL : Enter"); |
|
387 // if ( !IsActive() && iMmsSendErrorMessages->Count() ) |
|
388 // { |
|
389 // QDEBUG_WRITE_FORMAT("Sending message(s): "), |
|
390 // iMmsSendErrorMessages->Count() ); |
|
391 // TCommandParameters parameters; // initialized to zero |
|
392 // TCommandParametersBuf paramPack( parameters ); |
|
393 // |
|
394 // //Add service entry as the first entry in the array |
|
395 // iMmsSendErrorMessages->InsertL( 0, iMmsServiceId ); |
|
396 // |
|
397 // iStatus = KRequestPending; |
|
398 // iRequestType = EMsgRequestSending; |
|
399 // delete iOperation; |
|
400 // iOperation = NULL; |
|
401 // QDEBUG_WRITE( "Request send" ); |
|
402 // iOperation = iSession->TransferCommandL( *iMmsSendErrorMessages, |
|
403 // EMmsScheduledSend, |
|
404 // paramPack, |
|
405 // iStatus ); |
|
406 // SetActive(); |
|
407 // QDEBUG_WRITE( "Reset array" ); |
|
408 // iMmsSendErrorMessages->Reset(); |
|
409 // } |
|
410 // QDEBUG_WRITE("CMsgErrorWatcherPrivate:StartMmsSendL : Exit"); |
|
411 // } |
|
412 |
|
413 // --------------------------------------------------------- |
|
414 // CMsgErrorWatcherPrivate::CheckMmsReceivingModeL |
|
415 // |
|
416 // Checks MMS receiving mode |
|
417 // --------------------------------------------------------- |
|
418 // |
|
419 void CMsgErrorWatcherPrivate::CheckMmsReceivingModeL() |
|
420 { |
|
421 if ( !( iWatcherFlags & EStartupReady ) || !GetMmsServiceL() ) |
|
422 { |
|
423 return; |
|
424 } |
|
425 QDEBUG_WRITE("CMsgErrorWatcherPrivate:CMsgErrorWatcherPrivate : Enter"); |
|
426 TBool validAP = ValidateMmsServiceL(); //Refreshes MMS settings |
|
427 |
|
428 |
|
429 TInt fetchHome = iMmsClient->MmsSettings().ReceivingModeHome(); |
|
430 TInt fetchRoam = iMmsClient->MmsSettings().ReceivingModeForeign(); |
|
431 QDEBUG_WRITE_FORMAT("ReceivingModeHome: ", fetchHome ); |
|
432 QDEBUG_WRITE_FORMAT("ReceivingModeForeign: ", fetchRoam ); |
|
433 |
|
434 if ( validAP && |
|
435 fetchRoam == EMmsReceivingReject && |
|
436 fetchHome != EMmsReceivingReject ) |
|
437 { |
|
438 QDEBUG_WRITE( "ShowNote flag enabled" ); |
|
439 iWatcherFlags |= EShowRoamingNote; |
|
440 } |
|
441 else |
|
442 { |
|
443 //Reset roaming note flag |
|
444 QDEBUG_WRITE( "ShowNote flag disabled" ); |
|
445 iWatcherFlags &= ~EShowRoamingNote; |
|
446 iWatcherFlags &= ~ERoamingNoteShown; |
|
447 } |
|
448 QDEBUG_WRITE("CMsgErrorWatcherPrivate:~CMsgErrorWatcherPrivate : Exit"); |
|
449 } |
|
450 |
|
451 // --------------------------------------------------------- |
|
452 // CMsgErrorWatcherPrivate::ValidateMmsServiceL |
|
453 // |
|
454 // Validates MMS service |
|
455 // --------------------------------------------------------- |
|
456 // |
|
457 TBool CMsgErrorWatcherPrivate::ValidateMmsServiceL() |
|
458 { |
|
459 // if ( !GetMmsServiceL() ) |
|
460 // { |
|
461 // return EFalse; |
|
462 // } |
|
463 QDEBUG_WRITE("CMsgErrorWatcherPrivate:ValidateMmsServiceL : Enter"); |
|
464 iMmsClient->RestoreSettingsL(); //Refreshes MMS settings |
|
465 QDEBUG_WRITE_FORMAT("ValidateService: ", iMmsClient->ValidateService( iMmsServiceId ) ); |
|
466 |
|
467 TInt errorCode = iMmsClient->ValidateService( iMmsServiceId ); |
|
468 QDEBUG_WRITE_FORMAT("ValidateService: errorcode --- ", errorCode ); |
|
469 QDEBUG_WRITE("CMsgErrorWatcherPrivate:ValidateMmsServiceL : Exit"); |
|
470 return ( errorCode == KErrNone ); |
|
471 } |
|
472 |
|
473 // --------------------------------------------------------- |
|
474 // --------------------------------------------------------- |
|
475 // CMsgErrorWatcherPrivate::HandleNoAPErrorL |
|
476 // |
|
477 // Handles "no access point defined" error |
|
478 // --------------------------------------------------------- |
|
479 // |
|
480 void CMsgErrorWatcherPrivate::HandleNoAPErrorL( TMsvEntry& aEntry ) |
|
481 { |
|
482 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleNoAPErrorL : Enter"); |
|
483 iMmsReceiveErrorMessages->AppendL( aEntry.Id() ); |
|
484 |
|
485 iWatcherFlags |= ENoAPErrorPending; |
|
486 if ( !iCenRepObserver ) |
|
487 { |
|
488 QDEBUG_WRITE( "Creating CenRep observer" ); |
|
489 iCenRepObserver = CMsgCenRepObserver::NewL( *this ); |
|
490 iCenRepObserver->SubscribeNotification(); |
|
491 } |
|
492 //Let's reset the TMsvEntry::iError to get rig of excess warning note |
|
493 ResetErrorFieldL( aEntry ); |
|
494 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleNoAPErrorL : Exit"); |
|
495 } |
|
496 |
|
497 // --------------------------------------------------------- |
|
498 // CMsgErrorWatcherPrivate::HandleInvalidAPErrorL |
|
499 // |
|
500 // Handles "invalid access point" error |
|
501 // --------------------------------------------------------- |
|
502 // |
|
503 void CMsgErrorWatcherPrivate::HandleInvalidAPErrorL( TMsvEntry& aEntry, TBool aStartObserver ) |
|
504 { |
|
505 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleInvalidAPErrorL : Enter"); |
|
506 iMmsReceiveErrorMessages->AppendL( aEntry.Id() ); |
|
507 |
|
508 q_ptr->ShowNote(EInvalidAccessPointNote); |
|
509 if ( aStartObserver && !iCommDbObserver ) |
|
510 { |
|
511 QDEBUG_WRITE( "Creating CommDB observer" ); |
|
512 iCommDbObserver = CMsgErrorCommDbObserver::NewL( *this ); |
|
513 } |
|
514 if ( aStartObserver && !iCenRepObserver ) |
|
515 { |
|
516 //We must also start cenrep observer |
|
517 QDEBUG_WRITE( "Creating CenRep observer" ); |
|
518 iCenRepObserver = CMsgCenRepObserver::NewL( *this ); |
|
519 iCenRepObserver->SubscribeNotification(); |
|
520 } |
|
521 |
|
522 //Let's reset the TMsvEntry::iError to get rig of excess warning note |
|
523 ResetErrorFieldL( aEntry ); |
|
524 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleInvalidAPErrorL : Exit"); |
|
525 } |
|
526 |
|
527 // --------------------------------------------------------- |
|
528 // CMsgErrorWatcherPrivate::HandleConnectionErrorL |
|
529 // |
|
530 // Handles "connection reserved" error |
|
531 // --------------------------------------------------------- |
|
532 // TODO: to be handled later. |
|
533 //void CMsgErrorWatcherPrivate::HandleConnectionErrorL( TMsvEntry& aEntry, TBool aReceive ) |
|
534 // { |
|
535 // QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleConnectionErrorL : Enter"); |
|
536 // if ( !iConnectionObserver ) |
|
537 // { |
|
538 // QDEBUG_WRITE( "Creating connection observer" ); |
|
539 // iConnectionObserver = CMsgErrorConnectionObserver::NewL( *this ); |
|
540 // } |
|
541 // if ( iConnectionObserver->ConnectionsOpen() ) |
|
542 // { |
|
543 // QDEBUG_WRITE( "Open connections detected" ); |
|
544 // if ( aReceive ) |
|
545 // { |
|
546 // iMmsReceiveErrorMessages->AppendL( aEntry.Id() ); |
|
547 // } |
|
548 // else |
|
549 // { |
|
550 // iMmsSendErrorMessages->AppendL( aEntry.Id() ); |
|
551 // } |
|
552 // //No matter if already started |
|
553 // iConnectionObserver->StartL(); |
|
554 // } |
|
555 // else |
|
556 // { |
|
557 // QDEBUG_WRITE( "No open connections" ); |
|
558 // delete iConnectionObserver; |
|
559 // iConnectionObserver = NULL; |
|
560 // } |
|
561 // QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleConnectionErrorL : Exit"); |
|
562 // } |
|
563 |
|
564 // --------------------------------------------------------- |
|
565 // CMsgErrorWatcher::HandleDiskSpaceErrorL |
|
566 // |
|
567 // Handles "no disk space" error |
|
568 // --------------------------------------------------------- |
|
569 // |
|
570 void CMsgErrorWatcherPrivate::HandleDiskSpaceErrorL( TMsvEntry& aEntry ) |
|
571 { |
|
572 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleDiskSpaceErrorL : Enter"); |
|
573 iMmsReceiveErrorMessages->AppendL( aEntry.Id() ); |
|
574 |
|
575 iDiskSpaceErrors++; |
|
576 if ( iDiskSpaceErrors == 1 ) |
|
577 { |
|
578 if ( !( iWatcherFlags & EStartupReady ) ) |
|
579 { |
|
580 return; |
|
581 } |
|
582 QDEBUG_WRITE( "Show note" ); |
|
583 q_ptr->ShowNote(EDiskLowNote1); |
|
584 } |
|
585 TUint triggerLevel = Max( KDefaultTriggerLevel, iMaxReceiveSize ); |
|
586 //Activate DiskSpace observer |
|
587 if ( !iDiskSpaceObserver ) |
|
588 { |
|
589 QDEBUG_WRITE( "Creating disk space observer" ); |
|
590 iDiskSpaceObserver = CMsgErrorDiskSpaceObserver::NewL( *this, *iSession, iFs ); |
|
591 } |
|
592 QDEBUG_WRITE_FORMAT("Limit set to: ", |
|
593 KCriticalLevel + triggerLevel + KTriggerMargin ); |
|
594 iDiskSpaceObserver->SetLimitAndActivateL( KCriticalLevel + |
|
595 triggerLevel + |
|
596 KTriggerMargin ); |
|
597 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleDiskSpaceErrorL : Exit"); |
|
598 } |
|
599 |
|
600 // --------------------------------------------------------- |
|
601 // CMsgErrorWatcherPrivate::HandleMemoryErrorL |
|
602 // |
|
603 // Handles "no memory" error |
|
604 // --------------------------------------------------------- |
|
605 // |
|
606 void CMsgErrorWatcherPrivate::HandleMemoryErrorL( TMsvEntry& aEntry ) |
|
607 { |
|
608 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleMemoryErrorL : Enter"); |
|
609 iMmsReceiveErrorMessages->AppendL( aEntry.Id() ); |
|
610 if ( !( iWatcherFlags & EStartupReady ) ) |
|
611 { |
|
612 return; |
|
613 } |
|
614 q_ptr->ShowNote(EMemoryLowNote); |
|
615 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleMemoryErrorL : Exit"); |
|
616 } |
|
617 |
|
618 // --------------------------------------------------------- |
|
619 // CMsgErrorWatcherPrivate::HandleRoamingEventL |
|
620 // |
|
621 // Handles events from roaming observer |
|
622 // --------------------------------------------------------- |
|
623 // |
|
624 void CMsgErrorWatcherPrivate::HandleRoamingEventL( TBool aRoaming ) |
|
625 { |
|
626 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleRoamingEventL : Enter"); |
|
627 QDEBUG_WRITE_FORMAT("aRoaming : ", aRoaming ); |
|
628 if ( !iMmsClient ) |
|
629 { |
|
630 // We should never get here if MMS Client MTM is not present |
|
631 // since roaming observer is not started in that case. |
|
632 // This return is here just in case... |
|
633 return; |
|
634 } |
|
635 |
|
636 TInt fetchHome = iMmsClient->MmsSettings().ReceivingModeHome(); |
|
637 TInt fetchRoam = iMmsClient->MmsSettings().ReceivingModeForeign(); |
|
638 QDEBUG_WRITE_FORMAT("HandleRoamingEventL fetchHome : ", fetchHome ); |
|
639 QDEBUG_WRITE_FORMAT("HandleRoamingEventL fetchRoam : ", fetchRoam ); |
|
640 |
|
641 TBool fetchAll = EFalse; |
|
642 |
|
643 if ( aRoaming ) |
|
644 { |
|
645 QDEBUG_WRITE( "we are in roaming." ); |
|
646 //We are in roaming network |
|
647 if ( fetchRoam == EMmsReceivingAutomatic && |
|
648 fetchHome != EMmsReceivingAutomatic ) |
|
649 { |
|
650 fetchAll = ETrue; |
|
651 } |
|
652 if ( ( iWatcherFlags & EShowRoamingNote ) && |
|
653 !( iWatcherFlags & ERoamingNoteShown ) ) |
|
654 { |
|
655 //Show roaming note if requested |
|
656 if ( !( iWatcherFlags & EStartupReady ) ) |
|
657 { |
|
658 return; |
|
659 } |
|
660 q_ptr->ShowNote(ERoamingNote); |
|
661 iWatcherFlags |= ERoamingNoteShown; |
|
662 } |
|
663 } |
|
664 else |
|
665 { |
|
666 QDEBUG_WRITE( "we are in home network." ); |
|
667 //We are in home network |
|
668 if ( fetchHome == EMmsReceivingAutomatic && |
|
669 fetchRoam != EMmsReceivingAutomatic ) |
|
670 { |
|
671 fetchAll = ETrue; |
|
672 } |
|
673 //Reset roaming note flag |
|
674 iWatcherFlags &= ~ERoamingNoteShown; |
|
675 } |
|
676 |
|
677 if ( fetchAll && !IsActive() ) |
|
678 { |
|
679 QDEBUG_WRITE( "starting fetch all" ); |
|
680 iStatus = KRequestPending; |
|
681 iRequestType = EMsgRequestFetchingAll; |
|
682 delete iOperation; |
|
683 iOperation = NULL; |
|
684 iOperation = iMmsClient->FetchAllL( iStatus, EFalse ); |
|
685 SetActive(); |
|
686 } |
|
687 QDEBUG_WRITE("CMsgErrorWatcherPrivate:~CMsgErrorWatcherPrivate : Exit"); |
|
688 } |
|
689 |
|
690 // --------------------------------------------------------- |
|
691 // CMsgErrorWatcherPrivate::HandleCommDbEventL |
|
692 // |
|
693 // Handles events from CommDB observer |
|
694 // --------------------------------------------------------- |
|
695 // |
|
696 void CMsgErrorWatcherPrivate::HandleCommDbEventL() |
|
697 { |
|
698 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleCommDbEventL : Enter"); |
|
699 if ( ValidateMmsServiceL() ) |
|
700 { |
|
701 QDEBUG_WRITE( "starting fetch" ); |
|
702 StartMmsFetchL(); |
|
703 } |
|
704 else |
|
705 { |
|
706 //Wait for another event |
|
707 QDEBUG_WRITE( "restart CommDB observer" ); |
|
708 iCommDbObserver->Restart(); |
|
709 } |
|
710 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleCommDbEventL : Exit"); |
|
711 } |
|
712 |
|
713 // --------------------------------------------------------- |
|
714 // CMsgErrorWatcherPrivate::HandleConnectionEvent |
|
715 // |
|
716 // Handles events from connection observer |
|
717 // --------------------------------------------------------- |
|
718 // TODO: handel later. |
|
719 //void CMsgErrorWatcherPrivate::HandleConnectionEvent() |
|
720 // { |
|
721 // QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleConnectionEvent : Enter"); |
|
722 // if ( !IsActive() ) |
|
723 // { |
|
724 // MEWLOGGER_WRITE( "HandleConnectionEvent, Starting delay timer" ); |
|
725 // iStatus = KRequestPending; |
|
726 // iRequestType = EMsgRequestWaitingDisconnection; |
|
727 // iTimer.After( iStatus, KDelayAfterDisconnect ); |
|
728 // SetActive(); |
|
729 // } |
|
730 // QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleConnectionEvent : Exit"); |
|
731 // } |
|
732 |
|
733 // --------------------------------------------------------- |
|
734 // CMsgErrorWatcherPrivate::HandleDiskSpaceEventL |
|
735 // |
|
736 // Handles events from disk space observer |
|
737 // --------------------------------------------------------- |
|
738 // |
|
739 void CMsgErrorWatcherPrivate::HandleDiskSpaceEventL() |
|
740 { |
|
741 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleDiskSpaceEventL : Enter"); |
|
742 QDEBUG_WRITE( "starting fetch" ); |
|
743 StartMmsFetchL(); |
|
744 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleDiskSpaceEventL : Exit"); |
|
745 } |
|
746 |
|
747 |
|
748 // --------------------------------------------------------- |
|
749 // CMsgErrorWatcherPrivate::HandleDiskSpaceEvent2L |
|
750 // |
|
751 // Handles events from disk space observer |
|
752 // -------k-------------------------------------------------- |
|
753 // |
|
754 void CMsgErrorWatcherPrivate::HandleDiskSpaceEvent2L() |
|
755 { |
|
756 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleDiskSpaceEvent2L : Enter"); |
|
757 // erro note text was coming form avkon. |
|
758 QDEBUG_WRITE( "show note" ); |
|
759 q_ptr->ShowNote(ESMSIncomingLowDiskSpace); |
|
760 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleDiskSpaceEvent2L : Exit"); |
|
761 |
|
762 } |
|
763 |
|
764 |
|
765 // --------------------------------------------------------- |
|
766 // CMsgErrorWatcherPrivate::HandleStartupReadyL |
|
767 // |
|
768 // Handles events from startup state observer (currently |
|
769 // CMsgSentItemsObserver) |
|
770 // --------------------------------------------------------- |
|
771 // |
|
772 void CMsgErrorWatcherPrivate::HandleStartupReadyL() |
|
773 { |
|
774 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleStartupReadyL : Enter"); |
|
775 QDEBUG_WRITE( "Startup ready!" ); |
|
776 iWatcherFlags |= EStartupReady; |
|
777 CheckMmsReceivingModeL(); |
|
778 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleStartupReadyL : Exit"); |
|
779 } |
|
780 |
|
781 |
|
782 // --------------------------------------------------------- |
|
783 // CMsgErrorWatcherPrivate::HandleCenRepNotificationL |
|
784 // |
|
785 // Handles events from Central Repository observer |
|
786 // --------------------------------------------------------- |
|
787 // |
|
788 void CMsgErrorWatcherPrivate::HandleCenRepNotificationL() |
|
789 { |
|
790 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleCenRepNotificationL : Enter"); |
|
791 if ( ValidateMmsServiceL() ) |
|
792 { |
|
793 QDEBUG_WRITE( "starting fetch" ); |
|
794 StartMmsFetchL(); |
|
795 } |
|
796 else |
|
797 { |
|
798 //Wait for another event |
|
799 QDEBUG_WRITE( "restart CenRep observer" ); |
|
800 iCenRepObserver->SubscribeNotification(); |
|
801 } |
|
802 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleCenRepNotificationL : Exit"); |
|
803 } |
|
804 |
|
805 // --------------------------------------------------------- |
|
806 // CMsgErrorWatcherPrivate::HandleSessionEventL |
|
807 // |
|
808 // Handles events from MsgServer observer |
|
809 // --------------------------------------------------------- |
|
810 // |
|
811 void CMsgErrorWatcherPrivate::HandleSessionEventL( TMsvSessionEvent aEvent, |
|
812 TAny* aArg1, |
|
813 TAny* aArg2, |
|
814 TAny* aArg3 ) |
|
815 { |
|
816 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleSessionEventL : Enter"); |
|
817 if ( ( aEvent == EMsvCloseSession || |
|
818 aEvent == EMsvServerTerminated || |
|
819 aEvent == EMsvMediaUnavailable || |
|
820 aEvent == EMsvMediaChanged ) && |
|
821 iWatcherFlags & EWatcherRunning ) |
|
822 { |
|
823 QDEBUG_WRITE_FORMAT("StopWatcher event: ", aEvent ); |
|
824 StopWatcher(); |
|
825 //Start retry timer |
|
826 StartRestartTimer(); |
|
827 return; |
|
828 } |
|
829 if ( aEvent == EMsvServerReady && |
|
830 !( iWatcherFlags & EWatcherRunning ) ) |
|
831 { |
|
832 TRAPD ( err, StartWatcherL() ); |
|
833 if ( err ) //make sure watcher is not left in obscure state |
|
834 { |
|
835 StopWatcher(); |
|
836 } |
|
837 return; |
|
838 } |
|
839 if ( aArg1 == 0 || aArg2 == 0 || !( iWatcherFlags & EWatcherRunning ) ) |
|
840 { |
|
841 return; |
|
842 } |
|
843 // If for some reason MMS service is not yet found, |
|
844 // we try to find it now... |
|
845 GetMmsServiceL(); |
|
846 |
|
847 CMsvEntrySelection* entries = static_cast<CMsvEntrySelection*>( aArg1 ); |
|
848 TInt count = entries->Count(); |
|
849 |
|
850 // Mark the _original_ folder as parent for "entries moved" events (in "aArg3"). |
|
851 // For other events the parent is in "aArg2". |
|
852 TMsvId parentId = ( aEvent == EMsvEntriesMoved ) |
|
853 ? *( static_cast<TMsvId*>( aArg3 ) ) |
|
854 : *( static_cast<TMsvId*>( aArg2 ) ); |
|
855 |
|
856 if ( count < 1 ) |
|
857 { |
|
858 return; |
|
859 } |
|
860 if ( parentId == KMsvRootIndexEntryIdValue && |
|
861 iMmsServiceId != KMsvNullIndexEntryId ) |
|
862 { |
|
863 // We're not interested in these events if MMS Service is not present. |
|
864 HandleRootEventL( aEvent, entries ); |
|
865 } |
|
866 else if ( parentId == KMsvLocalServiceIndexEntryIdValue ) |
|
867 { |
|
868 HandleLocalServiceEventL( aEvent, entries ); |
|
869 } |
|
870 else if ( parentId == KWatcherOutboxFolderId ) |
|
871 { |
|
872 HandleOutboxEventL( aEvent, entries ); |
|
873 } |
|
874 else if ( ( iMmsServiceId != KMsvNullIndexEntryId && parentId == iMmsServiceId ) || |
|
875 ( iNotificationFolderId != KMsvNullIndexEntryId && parentId == iNotificationFolderId ) ) |
|
876 { |
|
877 HandleMmsServiceEventL( aEvent, entries ); |
|
878 } |
|
879 else |
|
880 { |
|
881 //do nothing |
|
882 } |
|
883 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleSessionEventL : Exit"); |
|
884 } |
|
885 |
|
886 // --------------------------------------------------------- |
|
887 // CMsgErrorWatcherPrivate::HandleRootEventL |
|
888 // |
|
889 // Handles root events from MsgServer observer |
|
890 // --------------------------------------------------------- |
|
891 // |
|
892 void CMsgErrorWatcherPrivate::HandleRootEventL( TMsvSessionEvent aEvent, |
|
893 CMsvEntrySelection* aEntries ) |
|
894 { |
|
895 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleRootEventL : Enter"); |
|
896 QDEBUG_WRITE_FORMAT("aEvent : ",aEvent); |
|
897 switch ( aEvent ) |
|
898 { |
|
899 case EMsvEntriesChanged: |
|
900 { |
|
901 TInt count = aEntries->Count(); |
|
902 TInt i = 0; |
|
903 while ( i < count ) |
|
904 { |
|
905 TMsvId dummy; |
|
906 TMsvEntry entry; |
|
907 TInt error = iSession->GetEntry( |
|
908 aEntries->At( i ), dummy, entry ); |
|
909 |
|
910 //We're only interested in MMS service |
|
911 if ( !error && |
|
912 iMmsServiceId != KMsvNullIndexEntryId && |
|
913 entry.Id() == iMmsServiceId ) |
|
914 { |
|
915 QDEBUG_WRITE( "HandleRootEventL, MMS service changed" ); |
|
916 //Check whether the roaming setting has changed |
|
917 CheckMmsReceivingModeL(); |
|
918 |
|
919 //We're waiting for the the user to change access points |
|
920 //if iCommDbObserver exists |
|
921 if ( iCommDbObserver && ValidateMmsServiceL() ) |
|
922 { |
|
923 QDEBUG_WRITE( "HandleRootEventL, deleting CommDB observer" ); |
|
924 StartMmsFetchL(); |
|
925 } |
|
926 } |
|
927 i++; |
|
928 } |
|
929 break; |
|
930 } |
|
931 default: |
|
932 break; |
|
933 } |
|
934 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleRootEventL : Exit"); |
|
935 } |
|
936 |
|
937 // --------------------------------------------------------- |
|
938 // CMsgErrorWatcherPrivate::HandleLocalServiceEventL |
|
939 // |
|
940 // Handles local service events from MsgServer observer |
|
941 // --------------------------------------------------------- |
|
942 // |
|
943 void CMsgErrorWatcherPrivate::HandleLocalServiceEventL( TMsvSessionEvent aEvent, |
|
944 CMsvEntrySelection* aEntries ) |
|
945 { |
|
946 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleLocalServiceEventL : Enter"); |
|
947 if ( iNotificationFolderId == KMsvNullIndexEntryId && |
|
948 aEvent == EMsvEntriesCreated ) |
|
949 { |
|
950 TInt count = aEntries->Count(); |
|
951 TInt i = 0; |
|
952 while ( i < count ) |
|
953 { |
|
954 TMsvId dummy; |
|
955 TMsvEntry entry; |
|
956 TInt error = iSession->GetEntry( |
|
957 aEntries->At( i ), dummy, entry ); |
|
958 if ( !error && |
|
959 entry.iDetails.Compare( KMMSNotificationFolder ) == 0 ) |
|
960 { |
|
961 iNotificationFolderId = aEntries->At( i ); |
|
962 QDEBUG_WRITE_FORMAT("Notification folder created: ", iNotificationFolderId ); |
|
963 } |
|
964 i++; |
|
965 } |
|
966 } |
|
967 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleLocalServiceEventL : Exit"); |
|
968 } |
|
969 |
|
970 |
|
971 |
|
972 // --------------------------------------------------------- |
|
973 // CMsgErrorWatcherPrivate::HandleOutboxEventL |
|
974 // |
|
975 // Handles outbox events from MsgServer observer |
|
976 // --------------------------------------------------------- |
|
977 // |
|
978 void CMsgErrorWatcherPrivate::HandleOutboxEventL( TMsvSessionEvent aEvent, |
|
979 CMsvEntrySelection* aEntries ) |
|
980 { |
|
981 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleOutboxEventL : Enter"); |
|
982 TInt count = aEntries->Count(); |
|
983 QDEBUG_WRITE_FORMAT("aEvent: ",aEvent); |
|
984 switch (aEvent) |
|
985 { |
|
986 case EMsvEntriesChanged: |
|
987 { |
|
988 // MEWLOGGER_WRITE("HandleOutboxEventL: case: EMsvEntriesChanged start"); |
|
989 // TInt i = 0; |
|
990 // MEWLOGGER_WRITEF( _L("EMsvEntriesChanged count: %d"), count ); |
|
991 // while ( i < count ) |
|
992 // { |
|
993 // MEWLOGGER_WRITE( "EMsvEntriesChanged - inside while" ); |
|
994 // TMsvId dummy; |
|
995 // TMsvEntry entry; |
|
996 // TInt error = iSession->GetEntry( |
|
997 // aEntries->At( i ), dummy, entry ); |
|
998 // TUid mtm = entry.iMtm; |
|
999 // MEWLOGGER_WRITEF( _L("EMsvEntriesChanged - mtm --- %d"), mtm ); |
|
1000 // MEWLOGGER_WRITEF( _L("EMsvEntriesChanged - entry id --- %d"), iMmsSendErrorMessages->Find( entry.Id() )); |
|
1001 // if ( mtm == KSenduiMtmMmsUid && |
|
1002 // iMmsSendErrorMessages->Find( entry.Id() ) == KErrNotFound ) |
|
1003 // { |
|
1004 // MEWLOGGER_WRITE( "EMsvEntriesChanged - inside if" ); |
|
1005 // if ( // the first error is activated again to synchronize |
|
1006 // // with connection manager (MPM) |
|
1007 // entry.iError == KErrPacketDataTsyMaxPdpContextsReached || |
|
1008 // entry.iError == KErrUmtsMaxNumOfContextExceededByPhone || |
|
1009 // entry.iError == KErrUmtsMaxNumOfContextExceededByNetwork || |
|
1010 // // add the following error to the list to synchronize with |
|
1011 // // connection manager (MPM) |
|
1012 // entry.iError == KErrGprsInsufficientResources ) |
|
1013 // { |
|
1014 // MEWLOGGER_WRITE( "MMS send - connection active" ); |
|
1015 // |
|
1016 // //Let's now save the id. This way we can reset the entrys |
|
1017 // //error field just before the fetch start. This prevents |
|
1018 // //duplicate error notes because this case branch is reached many times. |
|
1019 // iCurrentEntryId = entry.Id(); |
|
1020 // |
|
1021 // HandleConnectionErrorL( entry, EFalse ); |
|
1022 // } |
|
1023 // } |
|
1024 // i++; |
|
1025 // } |
|
1026 break; |
|
1027 } |
|
1028 case EMsvEntriesMoved: // Messages are moved _from_ this folder. |
|
1029 case EMsvEntriesDeleted: |
|
1030 { |
|
1031 TInt i = 0; |
|
1032 while ( i < count ) |
|
1033 { |
|
1034 TInt selectionId = iMmsSendErrorMessages->Find( aEntries->At( i ) ); |
|
1035 if ( selectionId != KErrNotFound ) |
|
1036 { |
|
1037 iMmsSendErrorMessages->Delete( selectionId ); |
|
1038 } |
|
1039 i++; |
|
1040 } |
|
1041 } |
|
1042 break; |
|
1043 default: |
|
1044 break; |
|
1045 } |
|
1046 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleOutboxEventL : Exit"); |
|
1047 } |
|
1048 |
|
1049 // --------------------------------------------------------- |
|
1050 // CMsgErrorWatcherPrivate::HandleMmsServiceEventL |
|
1051 // |
|
1052 // Handles MMS service events from MsgServer observer |
|
1053 // --------------------------------------------------------- |
|
1054 // |
|
1055 void CMsgErrorWatcherPrivate::HandleMmsServiceEventL( TMsvSessionEvent aEvent, |
|
1056 CMsvEntrySelection* aEntries ) |
|
1057 { |
|
1058 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleMmsServiceEventL : Enter"); |
|
1059 TInt count = aEntries->Count(); |
|
1060 QDEBUG_WRITE_FORMAT("aEvent: ", aEvent ); |
|
1061 switch (aEvent) |
|
1062 { |
|
1063 case EMsvEntriesChanged: |
|
1064 { |
|
1065 TInt i = 0; |
|
1066 while ( i < count ) |
|
1067 { |
|
1068 TMsvId dummy; |
|
1069 TMsvEntry entry; |
|
1070 TInt error = iSession->GetEntry( |
|
1071 aEntries->At( i ), dummy, entry ); |
|
1072 |
|
1073 if ( !error ) |
|
1074 { |
|
1075 QDEBUG_WRITE_FORMAT("FetchState: ", entry.SendingState() ); |
|
1076 QDEBUG_WRITE_FORMAT("Error: ", entry.iError ); |
|
1077 QDEBUG_WRITE_FORMAT("Retries: ", entry.iMtmData3 ); |
|
1078 QDEBUG_WRITE_FORMAT("Failed: ", (TInt)entry.Failed() ); |
|
1079 QDEBUG_WRITE_FORMAT("ArrayId: ", iMmsReceiveErrorMessages->Find( entry.Id() ) ); |
|
1080 } |
|
1081 //Check that reception has failed and that the entry is not |
|
1082 //already in iMmsReceiveErrorMessages |
|
1083 if ( !error && |
|
1084 iMmsReceiveErrorMessages->Find( entry.Id() ) == KErrNotFound ) |
|
1085 { |
|
1086 TInt entryErr = entry.iError; |
|
1087 if ( entryErr == KErrGprsMissingorUnknownAPN ) |
|
1088 { |
|
1089 // Map to "invalid ap" error. |
|
1090 entryErr = KMmsErrorAP1Invalid; |
|
1091 } |
|
1092 QDEBUG_WRITE_FORMAT("entryErr: ", entryErr ); |
|
1093 switch ( entryErr ) |
|
1094 { |
|
1095 case KErrDiskFull: |
|
1096 { |
|
1097 HandleDiskSpaceErrorL( entry ); |
|
1098 } |
|
1099 break; |
|
1100 case KErrNoMemory: |
|
1101 { |
|
1102 HandleMemoryErrorL( entry ); |
|
1103 } |
|
1104 break; |
|
1105 // TODO: to be handled later. |
|
1106 // the first error is activated again to synchronize |
|
1107 // with connection manager (MPM) |
|
1108 // case KErrPacketDataTsyMaxPdpContextsReached: |
|
1109 // case KErrUmtsMaxNumOfContextExceededByPhone: |
|
1110 // case KErrUmtsMaxNumOfContextExceededByNetwork: |
|
1111 // // add the following error to the list to synchronize with |
|
1112 // // connection manager (MPM) |
|
1113 // case KErrGprsInsufficientResources: |
|
1114 // { |
|
1115 // //Let's now save the id. This way we can reset the entrys |
|
1116 // //error field just before the fetch start. This prevents |
|
1117 // //duplicate error notes because this case branch is reached many times. |
|
1118 // iCurrentEntryId = entry.Id(); |
|
1119 // //Connection already active should be "detected" |
|
1120 // //only after third retry failure if "disconnect |
|
1121 // //delay" feature is activated. |
|
1122 // TInt retries = ( iWatcherFlags & EReceivingDisconnectDelay ) |
|
1123 // ? KConnectionRetries |
|
1124 // : 0; |
|
1125 // if ( ( entry.iMtmData3 & KMmsRetryCountMask ) >= retries ) //lint !e574 |
|
1126 // { |
|
1127 // MEWLOGGER_WRITE( "MMS fetch - connection active" ); |
|
1128 // |
|
1129 // |
|
1130 // HandleConnectionErrorL( entry, ETrue ); |
|
1131 // } |
|
1132 // } |
|
1133 // |
|
1134 // break; |
|
1135 |
|
1136 case KMmsErrorNoWAPAccessPoint: |
|
1137 { |
|
1138 HandleNoAPErrorL( entry ); |
|
1139 } |
|
1140 break; |
|
1141 case KMmsErrorAP1Invalid: |
|
1142 case KMmsErrorNoURI1: |
|
1143 { |
|
1144 HandleInvalidAPErrorL( entry, ETrue ); |
|
1145 } |
|
1146 break; |
|
1147 case KErrIfAuthenticationFailure: //username/passwd |
|
1148 { |
|
1149 HandleInvalidAPErrorL( entry, EFalse ); |
|
1150 } |
|
1151 break; |
|
1152 default: |
|
1153 //nothing to do |
|
1154 break; |
|
1155 } |
|
1156 } |
|
1157 i++; |
|
1158 } |
|
1159 } |
|
1160 break; |
|
1161 case EMsvEntriesMoved: // Messages are moved _from_ this "folder". |
|
1162 case EMsvEntriesDeleted: |
|
1163 { |
|
1164 TInt i = 0; |
|
1165 TInt originalCount = iMmsReceiveErrorMessages->Count(); |
|
1166 while ( i < count ) |
|
1167 { |
|
1168 TInt selectionId = iMmsReceiveErrorMessages->Find( aEntries->At( i ) ); |
|
1169 if ( selectionId != KErrNotFound ) |
|
1170 { |
|
1171 iMmsReceiveErrorMessages->Delete( selectionId ); |
|
1172 } |
|
1173 i++; |
|
1174 } |
|
1175 if ( originalCount && !iMmsReceiveErrorMessages->Count() ) |
|
1176 { |
|
1177 // array was emptied |
|
1178 ResetWatcher(); |
|
1179 } |
|
1180 } |
|
1181 break; |
|
1182 default: |
|
1183 break; |
|
1184 } |
|
1185 QDEBUG_WRITE("CMsgErrorWatcherPrivate:HandleMmsServiceEventL : Enter"); |
|
1186 } |
|
1187 |
|
1188 |
|
1189 // --------------------------------------------------------- |
|
1190 // CMsgErrorWatcherPrivate::ResetErrorFieldL |
|
1191 // |
|
1192 // Reset TMsvEntry::iError of the current notification |
|
1193 // --------------------------------------------------------- |
|
1194 // |
|
1195 void CMsgErrorWatcherPrivate::ResetErrorFieldL( ) |
|
1196 { |
|
1197 QDEBUG_WRITE("CMsgErrorWatcherPrivate:ResetErrorFieldL : Enter"); |
|
1198 //Makes sure the entry is set |
|
1199 if( iCurrentEntryId != KMsvNullIndexEntryId ) |
|
1200 { |
|
1201 CMsvEntry *cEntry( NULL ); |
|
1202 TRAPD( err, cEntry = iSession->GetEntryL( iCurrentEntryId ) ); |
|
1203 if ( err == KErrNotFound ) |
|
1204 { |
|
1205 iCurrentEntryId = KMsvNullIndexEntryId; |
|
1206 return; |
|
1207 } |
|
1208 CleanupStack::PushL( cEntry ); |
|
1209 TMsvEntry tEntry = cEntry->Entry(); |
|
1210 tEntry.iError = KErrNone; |
|
1211 cEntry -> ChangeL( tEntry ); |
|
1212 CleanupStack::PopAndDestroy( cEntry ); |
|
1213 //This prevents getting here to often |
|
1214 iCurrentEntryId = KMsvNullIndexEntryId; |
|
1215 } |
|
1216 QDEBUG_WRITE("CMsgErrorWatcherPrivate:ResetErrorFieldL : Exit"); |
|
1217 } |
|
1218 |
|
1219 // --------------------------------------------------------- |
|
1220 // CMsgErrorWatcherPrivate::ResetErrorFieldL |
|
1221 // |
|
1222 // Reset TMsvEntry::iError |
|
1223 // --------------------------------------------------------- |
|
1224 // |
|
1225 void CMsgErrorWatcherPrivate::ResetErrorFieldL( TMsvEntry& aEntry ) |
|
1226 { |
|
1227 QDEBUG_WRITE("CMsgErrorWatcherPrivate:ResetErrorFieldL() : Enter"); |
|
1228 CMsvEntry *cEntry = iSession->GetEntryL( aEntry.Id() ); |
|
1229 CleanupStack::PushL( cEntry ); |
|
1230 aEntry.iError = KErrNone; |
|
1231 cEntry -> ChangeL( aEntry ); |
|
1232 CleanupStack::PopAndDestroy( cEntry ); |
|
1233 QDEBUG_WRITE("CMsgErrorWatcherPrivate:ResetErrorFieldL() : Exit"); |
|
1234 } |
|
1235 |
|
1236 // --------------------------------------------------------- |
|
1237 // CMsgErrorWatcherPrivate::DoCancel |
|
1238 // |
|
1239 // From active object framework |
|
1240 // --------------------------------------------------------- |
|
1241 // |
|
1242 void CMsgErrorWatcherPrivate::DoCancel() |
|
1243 { |
|
1244 QDEBUG_WRITE("CMsgErrorWatcherPrivate:DoCancel : Enter"); |
|
1245 iTimer.Cancel(); |
|
1246 if ( iOperation ) |
|
1247 { |
|
1248 iOperation->Cancel(); |
|
1249 } |
|
1250 QDEBUG_WRITE("CMsgErrorWatcherPrivate:DoCancel : Exit"); |
|
1251 } |
|
1252 |
|
1253 // --------------------------------------------------------- |
|
1254 // CMsgErrorWatcherPrivate::RunL |
|
1255 // |
|
1256 // From active object framework |
|
1257 // --------------------------------------------------------- |
|
1258 // |
|
1259 void CMsgErrorWatcherPrivate::RunL() |
|
1260 { |
|
1261 QDEBUG_WRITE("CMsgErrorWatcherPrivate:RunL : Enter"); |
|
1262 QDEBUG_WRITE_FORMAT("RunL, iStatus: ", iStatus.Int() ); |
|
1263 QDEBUG_WRITE_FORMAT("RunL, iRequestType: ", iRequestType ); |
|
1264 QDEBUG_WRITE_FORMAT("RunL, EMsgRequestSending - iMmsReceiveErrorMessages: ", iMmsReceiveErrorMessages->Count() ); |
|
1265 |
|
1266 switch ( iRequestType ) |
|
1267 { |
|
1268 case EMsgRequestStartingUp: |
|
1269 { |
|
1270 if ( !( iWatcherFlags & EWatcherRunning ) ) |
|
1271 { |
|
1272 TRAPD ( err, StartWatcherL() ); |
|
1273 if ( err ) //make sure watcher is not left in obscure state |
|
1274 { |
|
1275 QDEBUG_WRITE_FORMAT("Leave from StartWatcherL: %d", err ); |
|
1276 StopWatcher(); |
|
1277 if ( iTimerRetries < KMaxTimerRetries ) |
|
1278 { |
|
1279 StartRestartTimer(); |
|
1280 } |
|
1281 //else give up |
|
1282 } |
|
1283 } |
|
1284 } |
|
1285 break; |
|
1286 case EMsgRequestSending: |
|
1287 { |
|
1288 if ( iMmsReceiveErrorMessages->Count() ) |
|
1289 { |
|
1290 StartMmsFetchL(); |
|
1291 } |
|
1292 else |
|
1293 { |
|
1294 // delete iConnectionObserver; |
|
1295 // iConnectionObserver = NULL; |
|
1296 ResetErrorFieldL(); |
|
1297 } |
|
1298 break; |
|
1299 } |
|
1300 case EMsgRequestFetching: |
|
1301 { |
|
1302 ResetErrorFieldL(); |
|
1303 ResetWatcher(); |
|
1304 break; |
|
1305 } |
|
1306 // TODO: to be handled later. |
|
1307 // case EMsgRequestWaitingDisconnection: |
|
1308 // { |
|
1309 // MEWLOGGER_WRITE( "RunL, Disconnect delay passed" ); |
|
1310 // MEWLOGGER_WRITEF( _L("RunL, EMsgRequestWaitingDisconnection - iMmsReceiveErrorMessages: %d"), iMmsSendErrorMessages->Count() ); |
|
1311 // if ( iMmsSendErrorMessages->Count() ) |
|
1312 // { |
|
1313 // StartMmsSendL(); |
|
1314 // } |
|
1315 // else |
|
1316 // { |
|
1317 // StartMmsFetchL(); |
|
1318 // } |
|
1319 // //ResetErrorFieldL(); |
|
1320 // } |
|
1321 // break; |
|
1322 case EMsgRequestFetchingAll: |
|
1323 default: |
|
1324 break; |
|
1325 } |
|
1326 QDEBUG_WRITE("CMsgErrorWatcherPrivate:RunL : Exit"); |
|
1327 } |
|
1328 |
|
1329 |
|
1330 // End of File |
|
1331 |