95 // CONST VALUES |
95 // CONST VALUES |
96 const TInt KControlBarTransitionTime = 250; |
96 const TInt KControlBarTransitionTime = 250; |
97 const TInt KMaxPreviewPaneLength = 60; |
97 const TInt KMaxPreviewPaneLength = 60; |
98 const TInt KMsgUpdaterTimerDelay = 2500000; // Time to update list, 2,5sec |
98 const TInt KMsgUpdaterTimerDelay = 2500000; // Time to update list, 2,5sec |
99 const TInt KNewMailTimerDelay = 20; // sleeping timer to start processing new messages |
99 const TInt KNewMailTimerDelay = 20; // sleeping timer to start processing new messages |
|
100 const TInt KSortTimerDelay = 40; // sleeping timer to start sorting ( delay should be longer than abowe ) |
|
101 const TInt KSortCountdown = 5; // number how many times will be tried do start sorting when it's forbidden |
100 const TInt KNewMailMaxBatch = 7; // number of new mails inserted into list at once |
102 const TInt KNewMailMaxBatch = 7; // number of new mails inserted into list at once |
101 static const TInt KMsgDeletionWaitNoteAmount = 5; |
103 static const TInt KMsgDeletionWaitNoteAmount = 5; |
102 _LIT( KMissingPreviewDataMarker, "..." ); |
104 _LIT( KMissingPreviewDataMarker, "..." ); |
103 |
105 |
104 static const TInt KMaxItemsFethed = 1000; |
106 static const TInt KMaxItemsFethed = 1000; |
1248 // --------------------------------------------------------------------------- |
1259 // --------------------------------------------------------------------------- |
1249 // TimerEventL |
1260 // TimerEventL |
1250 // |
1261 // |
1251 // --------------------------------------------------------------------------- |
1262 // --------------------------------------------------------------------------- |
1252 // |
1263 // |
1253 void CFSEmailUiMailListVisualiser::TimerEventL( CFSEmailUiGenericTimer* /*aTriggeredTimer*/ ) |
1264 void CFSEmailUiMailListVisualiser::TimerEventL( CFSEmailUiGenericTimer* aTriggeredTimer ) |
1254 { |
1265 { |
1255 TInt count = Min( KNewMailMaxBatch, iNewMailIds.Count() ); |
1266 |
1256 CFSMailClient* mailClient = iAppUi.GetMailClient(); |
1267 if( aTriggeredTimer == iSortTimer ) |
1257 |
1268 { |
1258 // Enter critical section |
1269 switch ( iSortState ) |
1259 // Because CFSMailClient::GetMessageByUidL can use CActiveSchedulerWait |
1270 { |
1260 // to ensure that only one TimerEventL method is processed at time |
1271 case ESortNone: |
1261 // CFSEmailUiGenericTimer`s iStatus will be used as mutex |
1272 { |
1262 iNewMailTimer->iStatus = KErrInUse; |
1273 iSortTryCount = 0; |
1263 |
1274 iSortState = ESortRequested; |
1264 for ( TInt i = 0; i < count; i++ ) |
1275 break; |
1265 { |
1276 } |
1266 CFSMailMessage* msgPtr = mailClient->GetMessageByUidL( iAppUi.GetActiveMailboxId(), |
1277 case ESortRequested: |
|
1278 { |
|
1279 if( !iNewMailTimer->IsActive() && iNewMailTimer->iStatus != KErrInUse ) |
|
1280 { |
|
1281 // Size sorting does not use nodes, so disable those, otherwise check from CR |
|
1282 iNodesInUse = iAppUi.GetCRHandler()->TitleDividers(); |
|
1283 SetSortButtonTextAndIconL(); |
|
1284 |
|
1285 iFocusedControl = EControlBarComponent; |
|
1286 iMailList->SetFocusedL( EFalse ); |
|
1287 iControlBarControl->SetFocusByIdL( iSortButtonId ); |
|
1288 |
|
1289 SortMailListModelAsyncL(); // sort can take long time |
|
1290 SetMskL(); |
|
1291 iSortState = ESortStarted; |
|
1292 } |
|
1293 else |
|
1294 { |
|
1295 iSortTryCount = 0; |
|
1296 iSortState = ESortPostponed; |
|
1297 iNewMailTimer->Stop(); // stop mail timer |
|
1298 } |
|
1299 break; |
|
1300 } |
|
1301 case ESortPostponed: |
|
1302 { |
|
1303 if ( !iNewMailTimer->IsActive() && iNewMailTimer->iStatus != KErrInUse ) |
|
1304 { |
|
1305 iSortState = ESortRequested; // start request again |
|
1306 } |
|
1307 else |
|
1308 { |
|
1309 iSortTryCount++; |
|
1310 } |
|
1311 if( iSortTryCount >= KSortCountdown )// repeat a few times |
|
1312 { |
|
1313 iSortTryCount = 0; // reset |
|
1314 iSortState = ESortStartError; // can't start sorting some error |
|
1315 } |
|
1316 break; |
|
1317 } |
|
1318 case ESortStarted: |
|
1319 { |
|
1320 if ( !iSortWaitNote )// it will restart the timer elsewhere (see below) |
|
1321 { |
|
1322 iSortState = ESortCompleted; |
|
1323 } |
|
1324 break; |
|
1325 } |
|
1326 case ESortStartError: |
|
1327 case ESortCompleted: |
|
1328 { |
|
1329 if( !iNewMailTimer->IsActive() ) |
|
1330 { |
|
1331 // refresh the whole mail list if list was sorted |
|
1332 if(iSortState != ESortStartError ) |
|
1333 { |
|
1334 RefreshL(); |
|
1335 } |
|
1336 // stop sorting process |
|
1337 iSortState = ESortNone; |
|
1338 iSortTimer->Stop(); |
|
1339 // restart if more messages available |
|
1340 if ( iNewMailIds.Count() ) |
|
1341 { |
|
1342 iNewMailTimer->Start( KNewMailTimerDelay ); |
|
1343 } |
|
1344 return; |
|
1345 } |
|
1346 iNewMailTimer->Stop(); |
|
1347 break; |
|
1348 } |
|
1349 default : |
|
1350 { |
|
1351 // do nothing |
|
1352 } |
|
1353 } |
|
1354 // start timer again |
|
1355 if ( !iSortTimer->IsActive() ) |
|
1356 { |
|
1357 iSortTimer->Start( KSortTimerDelay ); |
|
1358 } |
|
1359 } |
|
1360 |
|
1361 if( aTriggeredTimer == iNewMailTimer ) |
|
1362 { |
|
1363 TInt count = Min( KNewMailMaxBatch, iNewMailIds.Count() ); |
|
1364 CFSMailClient* mailClient = iAppUi.GetMailClient(); |
|
1365 |
|
1366 // Enter critical section |
|
1367 // Because CFSMailClient::GetMessageByUidL can use CActiveSchedulerWait |
|
1368 // to ensure that only one TimerEventL method is processed at time |
|
1369 // CFSEmailUiGenericTimer`s iStatus will be used as mutex |
|
1370 iNewMailTimer->iStatus = KErrInUse; |
|
1371 iModel->SetSortCriteria(iCurrentSortCriteria); |
|
1372 |
|
1373 for ( TInt i = 0; i < count; i++ ) |
|
1374 { |
|
1375 // stop synchronization if mail list is being sorted |
|
1376 if( iSortState != ESortNone || iSortWaitNote ) |
|
1377 { |
|
1378 iNewMailTimer->iStatus = KErrNone; |
|
1379 iNewMailTimer->Stop(); |
|
1380 return; // leave method |
|
1381 } |
|
1382 |
|
1383 CFSMailMessage* msgPtr = mailClient->GetMessageByUidL( iAppUi.GetActiveMailboxId(), |
1267 iMailFolder->GetFolderId(), |
1384 iMailFolder->GetFolderId(), |
1268 iNewMailIds[ 0 ], |
1385 iNewMailIds[ 0 ], |
1269 EFSMsgDataEnvelope ); |
1386 EFSMsgDataEnvelope ); |
1270 if ( msgPtr != NULL ) |
1387 if ( msgPtr != NULL ) |
1271 { |
1388 { |
1272 CleanupStack::PushL( msgPtr ); |
1389 __ASSERT_DEBUG( FolderId() == msgPtr->GetFolderId(), User::Invariant() ); |
1273 //first item - show scrollbar |
1390 CleanupStack::PushL( msgPtr ); |
1274 //last item - update scrollbar |
1391 //first item - show scrollbar |
1275 TBool allowRefresh = ( i == 0 || i == count - 1 ); |
1392 //last item - update scrollbar |
1276 InsertNewMessageL( msgPtr, allowRefresh ); |
1393 TBool allowRefresh = ( i == 0 || i == count - 1 ); |
1277 CleanupStack::Pop( msgPtr ); // ownership transferred to model |
1394 InsertNewMessageL( msgPtr, allowRefresh ); |
1278 } |
1395 CleanupStack::Pop( msgPtr ); // ownership transferred to model |
1279 // pop processed id from the queue, this is single thread operation |
1396 } |
1280 iNewMailIds.Remove( 0 ); |
1397 // pop processed id from the queue, this is single thread operation |
1281 } |
1398 iNewMailIds.Remove( 0 ); |
1282 |
1399 } |
1283 // End critical section |
1400 |
1284 iNewMailTimer->iStatus = KErrNone; |
1401 // End critical section |
1285 |
1402 iNewMailTimer->iStatus = KErrNone; |
1286 // if timer stoped then restart if more messages available |
1403 |
1287 if ( iNewMailIds.Count() && ! iNewMailTimer->IsActive() ) |
1404 // if timer stoped then restart if more messages available |
1288 { |
1405 if ( iNewMailIds.Count() && ! iNewMailTimer->IsActive() && iSortState == ESortNone ) |
1289 iNewMailTimer->Start( KNewMailTimerDelay ); |
1406 { |
1290 } |
1407 iNewMailTimer->Start( KNewMailTimerDelay ); |
|
1408 } |
|
1409 }//iNewMailTimer |
1291 } |
1410 } |
1292 |
1411 |
1293 // --------------------------------------------------------------------------- |
1412 // --------------------------------------------------------------------------- |
1294 // InsertNewMessageL |
1413 // InsertNewMessageL |
1295 // Creates a single new message item to the model and tree list from the given |
1414 // Creates a single new message item to the model and tree list from the given |
1558 iScreenAnchorLayout->SetSize( clientRect.Size() ); |
1677 iScreenAnchorLayout->SetSize( clientRect.Size() ); |
1559 SetMailListLayoutAnchors(); |
1678 SetMailListLayoutAnchors(); |
1560 //if the view is already active don't update the icons so they won't "blink" |
1679 //if the view is already active don't update the icons so they won't "blink" |
1561 //when the view is activated. |
1680 //when the view is activated. |
1562 if(!iThisViewActive) |
1681 if(!iThisViewActive) |
1563 { |
1682 { |
1564 ScaleControlBarL(); |
1683 ScaleControlBarL(); |
|
1684 |
|
1685 // Set icons on toolbar |
|
1686 iAppUi.FsTextureManager()->ClearTextureByIndex( EListControlBarMailboxDefaultIcon ); |
|
1687 iFolderListButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListControlBarMailboxDefaultIcon ) ); |
|
1688 iAppUi.FsTextureManager()->ClearTextureByIndex( EListTextureCreateNewMessageIcon ); |
|
1689 iNewEmailButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( EListTextureCreateNewMessageIcon ) ); |
|
1690 iAppUi.FsTextureManager()->ClearTextureByIndex( GetSortButtonTextureIndex() ); |
|
1691 iSortButton->SetIconL( iAppUi.FsTextureManager()->TextureByIndex( GetSortButtonTextureIndex() ) ); |
|
1692 |
1565 SetListAndCtrlBarFocusL(); |
1693 SetListAndCtrlBarFocusL(); |
1566 } |
1694 } |
1567 |
1695 |
1568 FadeOut(EFalse); // we can show now CAlfVisuals from CurrentView (to show Folders before updating emails) |
1696 FadeOut(EFalse); // we can show now CAlfVisuals from CurrentView (to show Folders before updating emails) |
1569 |
1697 |
2067 // "Clear deleted folder" command is available only in Deleted folder |
2196 // "Clear deleted folder" command is available only in Deleted folder |
2068 if ( currentFolderType != EFSDeleted || !iModel->Count() ) |
2197 if ( currentFolderType != EFSDeleted || !iModel->Count() ) |
2069 { |
2198 { |
2070 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsEmptyDeleted, ETrue ); |
2199 aMenuPane->SetItemDimmed( EFsEmailUiCmdActionsEmptyDeleted, ETrue ); |
2071 } |
2200 } |
2072 } |
2201 |
|
2202 CConnectionStatusQueryExtension::TConnectionStatus connetionStatus; |
|
2203 iAppUi.GetConnectionStatusL( connetionStatus ); |
|
2204 if ( connetionStatus == CConnectionStatusQueryExtension::ESynchronizing ) |
|
2205 { |
|
2206 aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, ETrue ); |
|
2207 aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelSync, EFalse ); |
|
2208 } |
|
2209 else |
|
2210 { |
|
2211 aMenuPane->SetItemDimmed( EFsEmailUiCmdSync, EFalse ); |
|
2212 aMenuPane->SetItemDimmed( EFsEmailUiCmdCancelSync, ETrue ); |
|
2213 } |
|
2214 } |
|
2215 |
2073 // MAIN MENU *************************************************************************** |
2216 // MAIN MENU *************************************************************************** |
2074 |
2217 |
2075 |
2218 |
2076 // ACTIONS SUBMENU ********************************************************************* |
2219 // ACTIONS SUBMENU ********************************************************************* |
2077 if ( aResourceId == R_FSEMAILUI_MAILLIST_SUBMENU_MAIL_ACTIONS ) |
2220 if ( aResourceId == R_FSEMAILUI_MAILLIST_SUBMENU_MAIL_ACTIONS ) |
6216 CFSMailMessage* confirmedMsgPtr = NULL; |
6364 CFSMailMessage* confirmedMsgPtr = NULL; |
6217 TRAP_IGNORE( confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL( iAppUi.GetActiveMailboxId(), |
6365 TRAP_IGNORE( confirmedMsgPtr = iAppUi.GetMailClient()->GetMessageByUidL( iAppUi.GetActiveMailboxId(), |
6218 iMailFolder->GetFolderId(), |
6366 iMailFolder->GetFolderId(), |
6219 modelItem->MessagePtr().GetMessageId() , |
6367 modelItem->MessagePtr().GetMessageId() , |
6220 EFSMsgDataEnvelope ) ); |
6368 EFSMsgDataEnvelope ) ); |
6221 if ( confirmedMsgPtr ) |
6369 if( aIndex < iTreeItemArray.Count() ) |
6222 { |
6370 { |
6223 // Replace message pointer in model with newly fetched one |
6371 if ( confirmedMsgPtr ) |
6224 Model()->ReplaceMessagePtr( aIndex, confirmedMsgPtr ); |
|
6225 |
|
6226 const SMailListItem& item = iTreeItemArray[aIndex]; |
|
6227 |
|
6228 // Update the list item contents and formating to match the message pointer |
|
6229 CFsTreePlainTwoLineItemData* itemData = |
|
6230 static_cast<CFsTreePlainTwoLineItemData*>( item.iTreeItemData ); |
|
6231 CFsTreePlainTwoLineItemVisualizer* itemVis = |
|
6232 static_cast<CFsTreePlainTwoLineItemVisualizer*>( item.iTreeItemVisualiser ); |
|
6233 |
|
6234 UpdateItemDataL( itemData, confirmedMsgPtr ); |
|
6235 UpdatePreviewPaneTextForItemL( itemData, confirmedMsgPtr ); |
|
6236 UpdateMsgIconAndBoldingL( itemData, itemVis, confirmedMsgPtr ); |
|
6237 iMailTreeListVisualizer->UpdateItemL( item.iListItemId ); |
|
6238 } |
|
6239 else |
|
6240 { |
|
6241 // No confirmed message for highlighted, remove from list also |
|
6242 iMailList->RemoveL( iTreeItemArray[aIndex].iListItemId ); // remove from list |
|
6243 iTreeItemArray.Remove( aIndex ); // remove from internal array. |
|
6244 iModel->RemoveAndDestroy( aIndex ); // Remove from model |
|
6245 if ( iNodesInUse ) |
|
6246 { |
6372 { |
6247 RemoveUnnecessaryNodesL(); |
6373 const SMailListItem& item = iTreeItemArray[aIndex]; |
|
6374 // Replace message pointer in model with newly fetched one |
|
6375 Model()->ReplaceMessagePtr( aIndex, confirmedMsgPtr ); |
|
6376 |
|
6377 // Update the list item contents and formating to match the message pointer |
|
6378 CFsTreePlainTwoLineItemData* itemData = |
|
6379 static_cast<CFsTreePlainTwoLineItemData*>( item.iTreeItemData ); |
|
6380 CFsTreePlainTwoLineItemVisualizer* itemVis = |
|
6381 static_cast<CFsTreePlainTwoLineItemVisualizer*>( item.iTreeItemVisualiser ); |
|
6382 |
|
6383 UpdateItemDataL( itemData, confirmedMsgPtr ); |
|
6384 UpdatePreviewPaneTextForItemL( itemData, confirmedMsgPtr ); |
|
6385 UpdateMsgIconAndBoldingL( itemData, itemVis, confirmedMsgPtr ); |
|
6386 iMailTreeListVisualizer->UpdateItemL( item.iListItemId ); |
6248 } |
6387 } |
6249 } |
6388 else |
|
6389 { |
|
6390 // No confirmed message for highlighted, remove from list also |
|
6391 iMailList->RemoveL( iTreeItemArray[aIndex].iListItemId ); // remove from list |
|
6392 iTreeItemArray.Remove( aIndex ); // remove from internal array. |
|
6393 iModel->RemoveAndDestroy( aIndex ); // Remove from model |
|
6394 if ( iNodesInUse ) |
|
6395 { |
|
6396 RemoveUnnecessaryNodesL(); |
|
6397 } |
|
6398 } |
|
6399 } |
6250 } |
6400 } |
6251 } |
6401 } |
6252 } |
6402 } |
6253 |
6403 |
6254 // --------------------------------------------------------------------------- |
6404 // --------------------------------------------------------------------------- |
6598 FUNC_LOG; |
6748 FUNC_LOG; |
6599 TFSMailMsgId folderId = FolderId(); |
6749 TFSMailMsgId folderId = FolderId(); |
6600 TFSMailMsgId mailBox = iAppUi.GetActiveMailboxId(); |
6750 TFSMailMsgId mailBox = iAppUi.GetActiveMailboxId(); |
6601 RArray<TFSMailMsgId> msgIds; |
6751 RArray<TFSMailMsgId> msgIds; |
6602 CleanupClosePushL( msgIds ); |
6752 CleanupClosePushL( msgIds ); |
6603 for ( TInt i = 0; i < aEntries.Count(); i++ ) |
6753 for ( TInt i = aEntries.Count() - 1; i >= 0; i-- ) |
6604 { |
6754 { |
6605 msgIds.AppendL( MsgIdFromListId( aEntries[i] ) ); |
6755 msgIds.AppendL( MsgIdFromListId( aEntries[i] ) ); |
6606 } |
6756 } |
|
6757 |
|
6758 // Clear the focused item to avoid repeated selection of a new focused |
|
6759 // item, unnecessary scrolling of the viewport, etc. |
|
6760 iMailTreeListVisualizer->SetFocusedItemL( KFsTreeNoneID ); |
|
6761 |
|
6762 iMailList->BeginUpdate(); |
6607 iAppUi.GetMailClient()->DeleteMessagesByUidL( mailBox, folderId, msgIds ); |
6763 iAppUi.GetMailClient()->DeleteMessagesByUidL( mailBox, folderId, msgIds ); |
6608 // Remove from mail list if not already removed by mailbox events |
6764 // Remove from mail list if not already removed by mailbox events |
6609 RemoveMsgItemsFromListIfFoundL( msgIds ); |
6765 RemoveMsgItemsFromListIfFoundL( msgIds ); |
|
6766 iMailList->EndUpdateL(); |
|
6767 |
6610 CleanupStack::PopAndDestroy(); // msgIds.Close() |
6768 CleanupStack::PopAndDestroy(); // msgIds.Close() |
6611 } |
6769 } |
6612 |
6770 |
6613 // --------------------------------------------------------------------------- |
6771 // --------------------------------------------------------------------------- |
6614 // ConfirmDeleteL |
6772 // ConfirmDeleteL |
7187 { |
7347 { |
7188 iCurrentSortCriteria.iOrder = EFSMailDescending; |
7348 iCurrentSortCriteria.iOrder = EFSMailDescending; |
7189 } |
7349 } |
7190 |
7350 |
7191 iCurrentSortCriteria.iField = aSortField; |
7351 iCurrentSortCriteria.iField = aSortField; |
7192 |
7352 iModel->SetSortCriteria(iCurrentSortCriteria); |
7193 // Size sorting does not use nodes, so disable those, otherwise check from CR |
7353 |
7194 iNodesInUse = iAppUi.GetCRHandler()->TitleDividers(); |
7354 // rest of the code moved to TimerEventL ( iSortTimer part ) |
7195 SetSortButtonTextAndIconL(); |
7355 // used also in DoHandleControlBarOpenL to prevent SortList reopening |
7196 |
7356 iSortState = ESortRequested; |
7197 iFocusedControl = EControlBarComponent; |
7357 iSortTimer->Start( KSortTimerDelay ); |
7198 iMailList->SetFocusedL( EFalse ); |
|
7199 iControlBarControl->SetFocusByIdL( iSortButtonId ); |
|
7200 |
|
7201 SortMailListModelAsyncL(); // sort can take long time |
|
7202 // <cmail> |
|
7203 //if ( iMailListUpdater ) |
|
7204 // { |
|
7205 // Start updating mail list with sorting parameter. |
|
7206 // iMailListUpdater->StartL( ETrue ); |
|
7207 // } |
|
7208 // </cmail> |
|
7209 SetMskL(); |
|
7210 } |
7358 } |
7211 |
7359 |
7212 // --------------------------------------------------------------------------- |
7360 // --------------------------------------------------------------------------- |
7213 // SortButtonRect |
7361 // SortButtonRect |
7214 // Getter for sort button rectangle. Sort popup needs to get this |
7362 // Getter for sort button rectangle. Sort popup needs to get this |