equal
deleted
inserted
replaced
1230 { |
1230 { |
1231 iNewMailIds.Append( aMessages[ i ] ); |
1231 iNewMailIds.Append( aMessages[ i ] ); |
1232 } |
1232 } |
1233 } |
1233 } |
1234 |
1234 |
1235 // if iNewMailIds is not empty - start timer |
1235 // start timer only when all conditions are met: |
1236 if ( !iNewMailTimer->IsActive() && iNewMailIds.Count() ) |
1236 // timer isn`t already active |
|
1237 // there are new mails in the array |
|
1238 // timer event isn`t processing |
|
1239 if ( !iNewMailTimer->IsActive() && iNewMailIds.Count() && |
|
1240 iNewMailTimer->iStatus != KErrInUse ) |
1237 { |
1241 { |
1238 iNewMailTimer->Start( KNewMailTimerDelay ); |
1242 iNewMailTimer->Start( KNewMailTimerDelay ); |
1239 } |
1243 } |
1240 } |
1244 } |
1241 } |
1245 } |
1248 // |
1252 // |
1249 void CFSEmailUiMailListVisualiser::TimerEventL( CFSEmailUiGenericTimer* /*aTriggeredTimer*/ ) |
1253 void CFSEmailUiMailListVisualiser::TimerEventL( CFSEmailUiGenericTimer* /*aTriggeredTimer*/ ) |
1250 { |
1254 { |
1251 TInt count = Min( KNewMailMaxBatch, iNewMailIds.Count() ); |
1255 TInt count = Min( KNewMailMaxBatch, iNewMailIds.Count() ); |
1252 CFSMailClient* mailClient = iAppUi.GetMailClient(); |
1256 CFSMailClient* mailClient = iAppUi.GetMailClient(); |
|
1257 |
|
1258 // Enter critical section |
|
1259 // Because CFSMailClient::GetMessageByUidL can use CActiveSchedulerWait |
|
1260 // to ensure that only one TimerEventL method is processed at time |
|
1261 // CFSEmailUiGenericTimer`s iStatus will be used as mutex |
|
1262 iNewMailTimer->iStatus = KErrInUse; |
1253 |
1263 |
1254 for ( TInt i = 0; i < count; i++ ) |
1264 for ( TInt i = 0; i < count; i++ ) |
1255 { |
1265 { |
1256 CFSMailMessage* msgPtr = mailClient->GetMessageByUidL( iAppUi.GetActiveMailboxId(), |
1266 CFSMailMessage* msgPtr = mailClient->GetMessageByUidL( iAppUi.GetActiveMailboxId(), |
1257 iMailFolder->GetFolderId(), |
1267 iMailFolder->GetFolderId(), |
1267 CleanupStack::Pop( msgPtr ); // ownership transferred to model |
1277 CleanupStack::Pop( msgPtr ); // ownership transferred to model |
1268 } |
1278 } |
1269 // pop processed id from the queue, this is single thread operation |
1279 // pop processed id from the queue, this is single thread operation |
1270 iNewMailIds.Remove( 0 ); |
1280 iNewMailIds.Remove( 0 ); |
1271 } |
1281 } |
|
1282 |
|
1283 // End critical section |
|
1284 iNewMailTimer->iStatus = KErrNone; |
1272 |
1285 |
1273 // if timer stoped then restart if more messages available |
1286 // if timer stoped then restart if more messages available |
1274 if ( iNewMailIds.Count() && ! iNewMailTimer->IsActive() ) |
1287 if ( iNewMailIds.Count() && ! iNewMailTimer->IsActive() ) |
1275 { |
1288 { |
1276 iNewMailTimer->Start( KNewMailTimerDelay ); |
1289 iNewMailTimer->Start( KNewMailTimerDelay ); |