messagingappbase/mce/src/mceui.cpp
branchRCL_3
changeset 24 696bfeff199e
parent 22 1367103c24e2
child 25 fa1df4b99609
equal deleted inserted replaced
22:1367103c24e2 24:696bfeff199e
    37 #include <MuiuMsvProgressReporterOperation.h> // cmsvprogressreporteroperation
    37 #include <MuiuMsvProgressReporterOperation.h> // cmsvprogressreporteroperation
    38 #include <mtmdef.h>         // KUidMtmQueryCanSendMsgValue
    38 #include <mtmdef.h>         // KUidMtmQueryCanSendMsgValue
    39 #include <msvids.h>
    39 #include <msvids.h>
    40 #include <msvuids.h>
    40 #include <msvuids.h>
    41 #include <mtud.hrh>         // EMtudCommandTransferSend, EMtudCommandTransferSend, EMtudCommandTransferReceive
    41 #include <mtud.hrh>         // EMtudCommandTransferSend, EMtudCommandTransferSend, EMtudCommandTransferReceive
    42 #include <MuiuMessageIterator.h>// cmessageiterator
    42 
    43 #include <MuiuMsgEmbeddedEditorWatchingOperation.h> // tmsgexitmode
    43 #include <MuiuMsgEmbeddedEditorWatchingOperation.h> // tmsgexitmode
    44 #include <MuiuOperationWait.h>  // cmuiuoperationwait
    44 #include <MuiuOperationWait.h>  // cmuiuoperationwait
    45 #include <muiumsvuiserviceutilitiesinternal.h> // msvuiserviceutilitiesinternal
    45 #include <muiumsvuiserviceutilitiesinternal.h> // msvuiserviceutilitiesinternal
    46 #include <MuiuMsvUiServiceUtilities.h> // msvuiserviceutilities
    46 #include <MuiuMsvUiServiceUtilities.h> // msvuiserviceutilities
    47 class CGulIcon;
    47 class CGulIcon;
   269         // must not delete sessionholder, it will kill itself...
   269         // must not delete sessionholder, it will kill itself...
   270         iSessionHolder->RemoveClient();
   270         iSessionHolder->RemoveClient();
   271         // must not delete iSession, session holder takes care of that
   271         // must not delete iSession, session holder takes care of that
   272         }
   272         }
   273     delete iMceLogEngine;
   273     delete iMceLogEngine;
   274     delete iMessageIterator;
   274 
   275     delete iFolderIndicator;
   275     delete iFolderIndicator;
   276     delete iTabsArray;
   276     delete iTabsArray;
   277     delete iMMSNotifications;
   277     delete iMMSNotifications;
   278     delete iDecoratedTabGroup;
   278     delete iDecoratedTabGroup;
   279     delete iMceErrorUi;
   279     delete iMceErrorUi;
   303         iConnectionMonitor.Close();
   303         iConnectionMonitor.Close();
   304         }
   304         }
   305 
   305 
   306     // delete KPSUidMuiu property
   306     // delete KPSUidMuiu property
   307     RProperty::Delete( KPSUidMuiu, KMuiuKeyCurrentMsg );
   307     RProperty::Delete( KPSUidMuiu, KMuiuKeyCurrentMsg );
       
   308     RProperty::Delete( KPSUidMuiu, KMuiuKeyNextMsg );
   308     if ( iFeatureMgrEnabled ) // CR : 401-1806
   309     if ( iFeatureMgrEnabled ) // CR : 401-1806
   309         {
   310         {
   310     FeatureManager::UnInitializeLib();
   311     FeatureManager::UnInitializeLib();
   311 		    iFeatureMgrEnabled = EFalse ; // CR : 401-1806
   312 		    iFeatureMgrEnabled = EFalse ; // CR : 401-1806
   312 		    }
   313 		    }
  1175     }
  1176     }
  1176 
  1177 
  1177 // ----------------------------------------------------
  1178 // ----------------------------------------------------
  1178 // CMceUi::HandleOpenNextPreviousL
  1179 // CMceUi::HandleOpenNextPreviousL
  1179 // ----------------------------------------------------
  1180 // ----------------------------------------------------
  1180 void CMceUi::HandleOpenNextPreviousL( TBool aOpenNext )
  1181 void CMceUi::HandleOpenNextPreviousL( TBool /*aOpenNext*/ )
  1181     {
  1182     {
  1182     MCELOGGER_ENTERFN("HandleOpenNextPreviousL()");
  1183     MCELOGGER_ENTERFN("HandleOpenNextPreviousL()");
  1183     __ASSERT_DEBUG( iMessageIterator, Panic(EMceUiMessageIteratorNotCreated));
  1184      
  1184 
  1185     // Read the next message TMsvId using PS key 
  1185     if ( iMessageIterator )
  1186     TInt nextEntryId = 0;
  1186         {
  1187     TInt r = RProperty::Get( KPSUidMuiu, KMuiuKeyNextMsg, nextEntryId );
  1187         TInt error = (aOpenNext ?
  1188     if ( r != KErrNone )
  1188             iMessageIterator->SetNextMessage() : iMessageIterator->SetPreviousMessage() );
  1189         {
  1189         if ( error == KErrNone )
  1190         nextEntryId = 0;
  1190             {
  1191         }
  1191             TBool local = iMceListView->ListContainer()->FolderEntry().iServiceId == KMsvLocalServiceIndexEntryId;
  1192     
  1192             if ( local && !iLocalScreenClearer ) 
  1193     if ( nextEntryId > 0 )
  1193                 {
  1194         {
  1194                 iLocalScreenClearer = CAknLocalScreenClearer::NewL( ETrue );
  1195         // no need of following check because TMsvID is set properly
  1195                 }
  1196         //set from MsgEditorAppUI.
  1196 
  1197   
  1197     // TODO
  1198     
  1198             CMceMessageListContainerBase* container = iMceListView->ListContainer();
  1199         TBool local = iMceListView->ListContainer()->FolderEntry().iServiceId == KMsvLocalServiceIndexEntryId;
  1199             TMsvId currentItemId = iMessageIterator->CurrentMessage().Id();
  1200         if ( local && !iLocalScreenClearer ) 
  1200             if ( container )
  1201             {
  1201                 {
  1202             iLocalScreenClearer = CAknLocalScreenClearer::NewL( ETrue );
  1202                 container->SetCurrentItemIdL( currentItemId );
  1203             }
  1203                 container->DrawNow();
  1204 
  1204 /*                
  1205         CMceMessageListContainerBase* container = iMceListView->ListContainer();
  1205                 TInt currentItemIndex = container->ItemIndex( currentItemId );
  1206         
  1206                 if ( currentItemIndex != KErrNotFound )
  1207         TMsvId currentItemId = nextEntryId;
       
  1208         if ( container )
       
  1209             {
       
  1210             container->SetCurrentItemIdL( currentItemId );
       
  1211             container->DrawNow();
       
  1212             }
       
  1213 
       
  1214         TMsvEntry currentEntry;
       
  1215         TMsvId serviceId; // not used here but needed by GetEntry function
       
  1216         if ( iSession->GetEntry( currentItemId, serviceId, currentEntry ) == KErrNone &&
       
  1217              currentEntry.iType == KUidMsvMessageEntry )
       
  1218             {
       
  1219             TRAPD( err, EditMTMEntryL( currentEntry ) );
       
  1220             if ( err )
       
  1221                 {
       
  1222                 if ( iLocalScreenClearer )
  1207                     {
  1223                     {
  1208                     container->ListBox()->SetCurrentItemIndex( currentItemIndex );
  1224                     delete iLocalScreenClearer;
  1209                     container->ListBox()->DrawDeferred();
  1225                     iLocalScreenClearer = NULL;
  1210                     }*/
       
  1211                 }
       
  1212 
       
  1213             TMsvEntry currentEntry;
       
  1214             TMsvId serviceId; // not used here but needed by GetEntry function
       
  1215             if ( iSession->GetEntry( currentItemId, serviceId, currentEntry ) == KErrNone &&
       
  1216                  currentEntry.iType == KUidMsvMessageEntry )
       
  1217                 {
       
  1218                 TRAPD( err, EditMTMEntryL( currentEntry ) );
       
  1219                 if ( err )
       
  1220                     {
       
  1221                     if ( iLocalScreenClearer )
       
  1222                         {
       
  1223                         delete iLocalScreenClearer;
       
  1224                         iLocalScreenClearer = NULL;
       
  1225                         }
       
  1226                     User::Leave( err );
       
  1227                     }
  1226                     }
  1228                 }
  1227                 User::Leave( err );
  1229             } // end if ( container )
  1228                 }
  1230         } // end if ( error == KErrNone )
  1229             }
       
  1230         } // end  
  1231     MCELOGGER_LEAVEFN("HandleOpenNextPreviousL()");
  1231     MCELOGGER_LEAVEFN("HandleOpenNextPreviousL()");
  1232     }
  1232     }
  1233 
  1233 
  1234 // ----------------------------------------------------
  1234 // ----------------------------------------------------
  1235 // CMceUi::LaunchCBSApplicationL
  1235 // CMceUi::LaunchCBSApplicationL
  2234     // viewer next/prev
  2234     // viewer next/prev
  2235     else if ( aCompletionCode == CMsgEmbeddedEditorWatchingOperation::EMsgExitNext ||
  2235     else if ( aCompletionCode == CMsgEmbeddedEditorWatchingOperation::EMsgExitNext ||
  2236         aCompletionCode == CMsgEmbeddedEditorWatchingOperation::EMsgExitPrevious )
  2236         aCompletionCode == CMsgEmbeddedEditorWatchingOperation::EMsgExitPrevious )
  2237         {
  2237         {
  2238         MCELOGGER_WRITE("CMceUi::DoOperationCompletedL: Opening next/previous");
  2238         MCELOGGER_WRITE("CMceUi::DoOperationCompletedL: Opening next/previous");
  2239         if ( iMessageIterator && closedEntryId > 0 )
       
  2240             {
       
  2241             TMsvEntry currentEntry;
       
  2242             TMsvId serviceId; // not used here but needed by GetEntry function
       
  2243             // Get current entry
       
  2244             if ( iSession->GetEntry( closedEntryId, serviceId, currentEntry ) == KErrNone )
       
  2245                 {
       
  2246                 iMessageIterator->SetCurrentMessageL( currentEntry );
       
  2247                 }
       
  2248             }
       
  2249         HandleOpenNextPreviousL( aCompletionCode ==
  2239         HandleOpenNextPreviousL( aCompletionCode ==
  2250             CMsgEmbeddedEditorWatchingOperation::EMsgExitNext );
  2240             CMsgEmbeddedEditorWatchingOperation::EMsgExitNext );
  2251         if ( !IsForeground() )
  2241         if ( !IsForeground() )
  2252             {
  2242             {
  2253              // bring mce application to foreground
  2243              // bring mce application to foreground
  2255             }
  2245             }
  2256         return;
  2246         return;
  2257         }
  2247         }
  2258     else
  2248     else
  2259         {
  2249         {
  2260         MCELOGGER_WRITE("CMceUi::DoOperationCompletedL: deleting iMessageIterator");
       
  2261         // Viewer closed
  2250         // Viewer closed
  2262         if ( closedEntryId > 0 && iMessageIterator )
  2251         if ( closedEntryId > 0 )
  2263             {
  2252             {
  2264             CMceMessageListContainerBase* container = iMceListView->ListContainer();
  2253             CMceMessageListContainerBase* container = iMceListView->ListContainer();
  2265             if ( container )
  2254             if ( container )
  2266                 {
  2255                 {
  2267                 container->SetCurrentItemIdL( closedEntryId );
  2256                 container->SetCurrentItemIdL( closedEntryId );
  2268                 }
  2257                 }
  2269             }
  2258             }
  2270         delete iMessageIterator;
  2259          }
  2271         iMessageIterator = NULL;
       
  2272         }
       
  2273 
  2260 
  2274     if ( !iMceErrorUi )
  2261     if ( !iMceErrorUi )
  2275         {
  2262         {
  2276         iMceErrorUi = CErrorUI::NewL(*iCoeEnv);
  2263         iMceErrorUi = CErrorUI::NewL(*iCoeEnv);
  2277         }
  2264         }
  2641     TInt r = RProperty::Define( KPSUidMuiu, KMuiuKeyCurrentMsg, RProperty::EInt );
  2628     TInt r = RProperty::Define( KPSUidMuiu, KMuiuKeyCurrentMsg, RProperty::EInt );
  2642     if ( r != KErrAlreadyExists )
  2629     if ( r != KErrAlreadyExists )
  2643         {
  2630         {
  2644         User::LeaveIfError( r );
  2631         User::LeaveIfError( r );
  2645         }
  2632         }
       
  2633     
       
  2634      r = RProperty::Define( KPSUidMuiu, KMuiuKeyNextMsg, RProperty::EInt );
       
  2635      if ( r != KErrAlreadyExists )
       
  2636          {
       
  2637          User::LeaveIfError( r );
       
  2638          }
       
  2639 
  2646     // Set entry Id value to property
  2640     // Set entry Id value to property
  2647     if ( aEntry.iType == KUidMsvMessageEntry )
  2641     if ( aEntry.iType == KUidMsvMessageEntry )
  2648         {
  2642         {
  2649         r = RProperty::Set( KPSUidMuiu, KMuiuKeyCurrentMsg, aEntry.Id() );
  2643         r = RProperty::Set( KPSUidMuiu, KMuiuKeyCurrentMsg, aEntry.Id() );
       
  2644         r = RProperty::Set( KPSUidMuiu, KMuiuKeyNextMsg, 0 );
  2650         }
  2645         }
  2651 
  2646 
  2652     TBool tabsToCleanupStack = EFalse;
  2647     TBool tabsToCleanupStack = EFalse;
  2653     delete iMessageIterator;
       
  2654     iMessageIterator = NULL;
       
  2655     if ( aEntry.iType == KUidMsvMessageEntry )
       
  2656         {
       
  2657         iMessageIterator = CMessageIterator::NewL( *iSession, aEntry );
       
  2658         }
       
  2659 
  2648 
  2660     CBaseMtmUi& mtmUi=iMtmStore->GetMtmUiAndSetContextLC( aEntry );
  2649     CBaseMtmUi& mtmUi=iMtmStore->GetMtmUiAndSetContextLC( aEntry );
  2661     mtmUi.SetPreferences( mtmUi.Preferences() | EMtmUiFlagEditorPreferEmbedded );
  2650     mtmUi.SetPreferences( mtmUi.Preferences() | EMtmUiFlagEditorPreferEmbedded );
  2662 
  2651 
  2663     CMsvOperation* op = NULL;
  2652     CMsvOperation* op = NULL;
  5560 // CMceUi::HandleGainingForeground
  5549 // CMceUi::HandleGainingForeground
  5561 //
  5550 //
  5562 // ----------------------------------------------------
  5551 // ----------------------------------------------------
  5563 void CMceUi::HandleGainingForeground() // CR : 401-1806
  5552 void CMceUi::HandleGainingForeground() // CR : 401-1806
  5564     {
  5553     {
       
  5554    
       
  5555     // This code is added to remove screen clearer when returning from viewer.
       
  5556     if ( iMceListView )
       
  5557         {
       
  5558         CAknLocalScreenClearer** localScreenClearer = NULL; 
       
  5559         iMceListView->GetLocalScreenClearer( localScreenClearer );
       
  5560         delete *localScreenClearer;
       
  5561         *localScreenClearer = NULL;// this will assign null to iLocalScreenClearer in messagelistview.
       
  5562         }
  5565     if ( !iFeatureMgrEnabled )
  5563     if ( !iFeatureMgrEnabled )
  5566         {
  5564         {
  5567   	    TRAP_IGNORE( FeatureManager::InitializeLibL() );
  5565   	    TRAP_IGNORE( FeatureManager::InitializeLibL() );
  5568   	    iFeatureMgrEnabled = ETrue ;
  5566   	    iFeatureMgrEnabled = ETrue ;
  5569         }
  5567         }
  6649 // ----------------------------------------------------
  6647 // ----------------------------------------------------
  6650 // CMceUi::ResetAndHide
  6648 // CMceUi::ResetAndHide
  6651 // ----------------------------------------------------
  6649 // ----------------------------------------------------
  6652 void CMceUi::ResetAndHide()
  6650 void CMceUi::ResetAndHide()
  6653     {
  6651     {
  6654     SetCustomControl(1);    // Disable bring-to-foreground on view activation
  6652 	if (!MceViewActive( EMceMainViewActive ))
  6655     TRAP_IGNORE( CAknViewAppUi::CreateActivateViewEventL( \
  6653         {
  6656         KMessagingCentreMainViewUid, \
  6654         SetCustomControl(1);    // Disable bring-to-foreground on view activation
  6657         TUid::Uid(KMceHideInBackground), \
  6655         TRAP_IGNORE( CAknViewAppUi::CreateActivateViewEventL( \
  6658         KNullDesC8 ) ) ;
  6656             KMessagingCentreMainViewUid, \
       
  6657             TUid::Uid(KMceHideInBackground), \
       
  6658             KNullDesC8 ) ) ;
       
  6659         }
       
  6660     else
       
  6661         {
       
  6662         SetCustomControl(0); // Enable bring-to-foreground on view activation
       
  6663         }
  6659     HideInBackground();
  6664     HideInBackground();
  6660     }
  6665     }
       
  6666 
       
  6667 // ----------------------------------------------------
       
  6668 // CMceUi::OpenMtmMailboxViewL
       
  6669 // ----------------------------------------------------
  6661 void CMceUi::OpenMtmMailboxViewL( const TMsvEntry& aEntry )
  6670 void CMceUi::OpenMtmMailboxViewL( const TMsvEntry& aEntry )
  6662 	{
  6671 	{
  6663     CBaseMtmUi& mtmUi=iMtmStore->GetMtmUiAndSetContextLC( aEntry );
  6672     CBaseMtmUi& mtmUi=iMtmStore->GetMtmUiAndSetContextLC( aEntry );
  6664 
  6673 
  6665     CMsvSingleOpWatcher* singleOpWatcher=CMsvSingleOpWatcher::NewL( *this );
  6674     CMsvSingleOpWatcher* singleOpWatcher=CMsvSingleOpWatcher::NewL( *this );