messagingappbase/mcesettings/src/MceSettingsGeneralSettingsDialog.cpp
changeset 4 e9eae96aa117
parent 0 72b543305e3a
child 17 caea42e26caa
equal deleted inserted replaced
3:1324afda5dee 4:e9eae96aa117
    57 #endif //RD_MULTIPLE_DRIVE
    57 #endif //RD_MULTIPLE_DRIVE
    58 #include <e32cmn.h>             // RBuf
    58 #include <e32cmn.h>             // RBuf
    59 
    59 
    60 #include <bldvariant.hrh>
    60 #include <bldvariant.hrh>
    61 #include <data_caging_path_literals.hrh>
    61 #include <data_caging_path_literals.hrh>
    62 
    62 #include <msvids.h>
       
    63 #include <mtudreg.h>
       
    64 #include <miutset.h>
       
    65 #include <SendUiConsts.h>
    63 // CONSTANTS
    66 // CONSTANTS
    64 
    67 
    65 #define KMceApplicationUidValue         0x100058C5
    68 #define KMceApplicationUidValue         0x100058C5
    66 const TUid KMceApplicationUid           = {KMceApplicationUidValue};
    69 const TUid KMceApplicationUid           = {KMceApplicationUidValue};
    67 
    70 
    75 
    78 
    76 const TInt KMSKPosition = 3;
    79 const TInt KMSKPosition = 3;
    77 
    80 
    78 const TInt KMceListTypeTwoRow       = 0;
    81 const TInt KMceListTypeTwoRow       = 0;
    79 const TInt KMceListTypeOneRow       = 1;
    82 const TInt KMceListTypeOneRow       = 1;
       
    83 
       
    84 #define KUidMsgTypeCmailMtmVal               0x2001F406
    80 
    85 
    81 #ifdef _DEBUG
    86 #ifdef _DEBUG
    82 _LIT( KPanicText, "MceSettings" );
    87 _LIT( KPanicText, "MceSettings" );
    83 const TInt KCRepositorySettingFailure = 1;
    88 const TInt KCRepositorySettingFailure = 1;
    84 #endif
    89 #endif
    93     EMceGeneralSettingsSentItemsCount,
    98     EMceGeneralSettingsSentItemsCount,
    94     EMceGeneralSettingsMemoryInUse,
    99     EMceGeneralSettingsMemoryInUse,
    95     EMceGeneralSettingsInboxListType,
   100     EMceGeneralSettingsInboxListType,
    96     EMceGeneralSettingsMailListType
   101     EMceGeneralSettingsMailListType
    97     };
   102     };
       
   103 // These constants are added to handle 	"show e-mails in groups", when R_MCE_GENERAL_SETTINGS_ITEMS is used for MCESETTINGS.
       
   104 const TInt MceGeneralSettingsInboxListType = 2;
       
   105 const TInt MceGeneralSettingsMailListType = 3;
    98 #ifdef RD_MULTIPLE_DRIVE
   106 #ifdef RD_MULTIPLE_DRIVE
    99 const TInt KSpaceDelimiter=' ';
   107 const TInt KSpaceDelimiter=' ';
   100 #endif //RD_MULTIPLE_DRIVE
   108 #endif //RD_MULTIPLE_DRIVE
   101 
   109 
   102 // ================= MEMBER FUNCTIONS =======================
   110 // ================= MEMBER FUNCTIONS =======================
   129     MMceSettingsAccountManager* aManager )
   137     MMceSettingsAccountManager* aManager )
   130     :
   138     :
   131 #ifdef RD_MESSAGING_GENERAL_SETTINGS_RENOVATION
   139 #ifdef RD_MESSAGING_GENERAL_SETTINGS_RENOVATION
   132     CMceSettingsTitlePaneHandlerDialog(),
   140     CMceSettingsTitlePaneHandlerDialog(),
   133     iSession( aSession ), iObserver( aObserver ),
   141     iSession( aSession ), iObserver( aObserver ),
   134     iResources( *CCoeEnv::Static() ), iAccountManager( aManager )
   142     iResources( *CCoeEnv::Static() ), iAccountManager( aManager ),
   135 #else
   143 #else
   136     CMceSettingsTitlePaneHandlerDialog(),
   144     CMceSettingsTitlePaneHandlerDialog(),
   137     iSession( aSession ), iObserver(aObserver ), iAccountManager( aManager )
   145     iSession( aSession ), iObserver(aObserver ), iAccountManager( aManager ),
   138 #endif
   146 #endif
       
   147     iChangeDrive(EFalse),
       
   148 	iIsThirdPartyMail( EFalse )
       
   149 	
   139     {
   150     {
   140     }
   151     }
   141 
   152 
   142 
   153 
   143 void CMceGeneralSettingsDialog::ConstructL( TInt aResource )
   154 void CMceGeneralSettingsDialog::ConstructL( TInt aResource )
   148     TFileName fileName = fp.FullName();
   159     TFileName fileName = fp.FullName();
   149 
   160 
   150     iResources.OpenL( fileName );
   161     iResources.OpenL( fileName );
   151 #endif
   162 #endif
   152     CMceSettingsTitlePaneHandlerDialog::ConstructL( aResource );
   163     CMceSettingsTitlePaneHandlerDialog::ConstructL( aResource );
       
   164 	iIsThirdPartyMail = IsThirdPartyMailBox();
   153     }
   165     }
   154 
   166 
   155 // ----------------------------------------------------
   167 // ----------------------------------------------------
   156 // CMceGeneralSettingsDialog::Destructor
   168 // CMceGeneralSettingsDialog::Destructor
   157 // ----------------------------------------------------
   169 // ----------------------------------------------------
   190             __ASSERT_DEBUG( !ret, User::Panic(KPanicText,KCRepositorySettingFailure) );
   202             __ASSERT_DEBUG( !ret, User::Panic(KPanicText,KCRepositorySettingFailure) );
   191 #ifdef _DEBUG
   203 #ifdef _DEBUG
   192             setValue = ( *iMceSettingsArray )[EMceGeneralSettingsSentItemsCount].iCurrentNumber;
   204             setValue = ( *iMceSettingsArray )[EMceGeneralSettingsSentItemsCount].iCurrentNumber;
   193 #endif
   205 #endif
   194 
   206 
   195             ret = repository->Set( KMuiuInboxMessageListType,
   207             if ( iMemoryInUse )
   196                 ( *iMceSettingsArray )[EMceGeneralSettingsInboxListType].iCurrentNumber );
   208                 {
       
   209                 ret = repository->Set( KMuiuInboxMessageListType,
       
   210                   ( *iMceSettingsArray )[EMceGeneralSettingsInboxListType].iCurrentNumber );
       
   211                 }
       
   212             else
       
   213                 {
       
   214                 ret = repository->Set( KMuiuInboxMessageListType,
       
   215                   ( *iMceSettingsArray )[MceGeneralSettingsInboxListType].iCurrentNumber );
       
   216                 }
   197             __ASSERT_DEBUG( !ret, User::Panic(KPanicText,KCRepositorySettingFailure) );            
   217             __ASSERT_DEBUG( !ret, User::Panic(KPanicText,KCRepositorySettingFailure) );            
   198 
   218 
   199             ret = repository->Set( KMuiuMailMessageListType,
   219             if ( iIsThirdPartyMail )
   200                 ( *iMceSettingsArray )[EMceGeneralSettingsMailListType].iCurrentNumber );
   220                 {
   201             __ASSERT_DEBUG( !ret, User::Panic(KPanicText,KCRepositorySettingFailure) );            
   221                 if ( iMemoryInUse )
       
   222                     {
       
   223                     ret = repository->Set( KMuiuMailMessageListType,
       
   224                       ( *iMceSettingsArray )[EMceGeneralSettingsMailListType].iCurrentNumber );
       
   225                     }
       
   226                 else
       
   227                     {
       
   228                     ret = repository->Set( KMuiuMailMessageListType,
       
   229                       ( *iMceSettingsArray )[MceGeneralSettingsMailListType].iCurrentNumber );
       
   230                     }
       
   231                 __ASSERT_DEBUG( !ret, User::Panic(KPanicText,KCRepositorySettingFailure) );
       
   232                 }
       
   233             
   202             }
   234             }
   203         CleanupStack::Pop( repository );
   235         CleanupStack::Pop( repository );
   204         delete repository;
   236         delete repository;
   205         }
   237         }
   206 
   238 
   367         // Get one/two row list type selection
   399         // Get one/two row list type selection
   368         if ( repository->Get( KMuiuInboxMessageListType, i ) != KErrNone )
   400         if ( repository->Get( KMuiuInboxMessageListType, i ) != KErrNone )
   369             {
   401             {
   370             i = KMceListTypeTwoRow;
   402             i = KMceListTypeTwoRow;
   371             }
   403             }
   372         ( *iMceSettingsArray )[EMceGeneralSettingsInboxListType].iCurrentNumber =
   404         if ( iMemoryInUse )
   373                 i ? KMceListTypeOneRow : KMceListTypeTwoRow;
   405             {
   374 
   406             ( *iMceSettingsArray )[EMceGeneralSettingsInboxListType].iCurrentNumber =
   375         // Get one/two row list type selection
   407                    i ? KMceListTypeOneRow : KMceListTypeTwoRow;
   376         if ( repository->Get( KMuiuMailMessageListType, i ) != KErrNone )
   408             }
   377             {
   409         else
   378             i = KMceListTypeOneRow;
   410             {
   379             }
   411             ( *iMceSettingsArray )[MceGeneralSettingsInboxListType].iCurrentNumber =
   380         ( *iMceSettingsArray )[EMceGeneralSettingsMailListType].iCurrentNumber =
   412                    i ? KMceListTypeOneRow : KMceListTypeTwoRow;
   381                 i ? KMceListTypeOneRow : KMceListTypeTwoRow;
   413             }
       
   414         
       
   415         if ( iIsThirdPartyMail )
       
   416             {
       
   417              // Get one/two row list type selection
       
   418              if ( repository->Get( KMuiuMailMessageListType, i ) != KErrNone )
       
   419                  {
       
   420                  i = KMceListTypeOneRow;
       
   421                  }
       
   422              if ( iMemoryInUse )
       
   423                  {
       
   424                  ( *iMceSettingsArray )[EMceGeneralSettingsMailListType].iCurrentNumber =
       
   425                          i ? KMceListTypeOneRow : KMceListTypeTwoRow;
       
   426                  }
       
   427              else
       
   428                  {
       
   429                  ( *iMceSettingsArray )[MceGeneralSettingsMailListType].iCurrentNumber =
       
   430                         i ? KMceListTypeOneRow : KMceListTypeTwoRow;
       
   431                  }
       
   432             }
       
   433         else
       
   434             {
       
   435             if ( iMemoryInUse )
       
   436                 {
       
   437                 iMceSettingsArray->Delete(EMceGeneralSettingsMailListType);
       
   438                 }
       
   439             else
       
   440                 {
       
   441                 iMceSettingsArray->Delete(MceGeneralSettingsMailListType);
       
   442                 }
       
   443             }
   382         }
   444         }
   383 
   445 
   384     if ( iMemoryInUse )
   446     if ( iMemoryInUse )
   385         {
   447         {
   386         UpdateMemorySelectionL();
   448         UpdateMemorySelectionL();
   648     if ( !ShutdownAppsL() )
   710     if ( !ShutdownAppsL() )
   649         {
   711         {
   650         // User does not want to close open messages
   712         // User does not want to close open messages
   651         return;
   713         return;
   652         }
   714         }
       
   715     
       
   716     if(iChangeDrive)
       
   717         {
       
   718         return;
       
   719         }
   653 
   720 
   654     RFs& fs=iEikonEnv->FsSession();
   721     RFs& fs=iEikonEnv->FsSession();
   655     
   722     
   656 #ifdef RD_MULTIPLE_DRIVE     
   723 #ifdef RD_MULTIPLE_DRIVE     
   657     // Memory selection dialog from Avkon    
   724     // Memory selection dialog from Avkon    
   737             //if server is busy, do not change store
   804             //if server is busy, do not change store
   738             if( CheckIsServerBusyL() )
   805             if( CheckIsServerBusyL() )
   739                 {
   806                 {
   740                 return;
   807                 return;
   741                 }
   808                 }
   742 
   809             CAknInputBlock* comAbs=CAknInputBlock::NewLC();  
   743             // change message store
   810             // change message store
   744             CMuiuOperationWait* waiter=CMuiuOperationWait::NewLC();
   811             CMuiuOperationWait* waiter=CMuiuOperationWait::NewLC();
   745 
   812 
   746             CMsvProgressReporterOperation* reportOp =
   813             CMsvProgressReporterOperation* reportOp =
   747                     CMsvProgressReporterOperation::NewL( *iSession, waiter->iStatus );
   814                     CMsvProgressReporterOperation::NewL( *iSession, waiter->iStatus );
   748             CleanupStack::PushL( reportOp );
   815             CleanupStack::PushL( reportOp );
   749 
   816 
       
   817             reportOp->SetProgressVisibilityDelay(EFalse);
   750             HBufC* text = StringLoader::LoadLC( R_MCE_SETTINGS_SWITCHING_MESSAGE_STORE, 
   818             HBufC* text = StringLoader::LoadLC( R_MCE_SETTINGS_SWITCHING_MESSAGE_STORE, 
   751                        iEikonEnv );  
   819                        iEikonEnv );  
   752             reportOp->SetTitleL( *text ); 
   820             reportOp->SetTitleL( *text ); 
   753 
   821 
   754             reportOp->SetCanCancelL( EFalse);
   822             reportOp->SetCanCancelL( EFalse);
   755 
   823 
   756             CleanupStack::PopAndDestroy( text );
   824             CleanupStack::PopAndDestroy( text );
   757             
   825             iChangeDrive = ETrue;
   758             CMsvOperation* changeOp=iSession->ChangeDriveL( selectedDrive, reportOp->RequestStatus() );
   826             CMsvOperation* changeOp=iSession->ChangeDriveL( selectedDrive, reportOp->RequestStatus() );
   759             reportOp->SetOperationL( changeOp );
   827             reportOp->SetOperationL( changeOp );
   760 
   828 
   761             waiter->Start();
   829             waiter->Start();
   762     
   830             iChangeDrive = EFalse;
   763             CleanupStack::PopAndDestroy( reportOp );
   831             CleanupStack::PopAndDestroy( reportOp );
   764             CleanupStack::PopAndDestroy( waiter );
   832             CleanupStack::PopAndDestroy( waiter );
       
   833             CleanupStack::PopAndDestroy( comAbs );
   765                   
   834                   
   766             //memory has been changed
   835             //memory has been changed
   767             UpdateMemorySelectionL();           
   836             UpdateMemorySelectionL();           
   768             }
   837             }
   769         else       
   838         else       
   826                 if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iEikonEnv->FsSession(), 
   895                 if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iEikonEnv->FsSession(), 
   827                         KMceEmptyMessageStore, selectedDrive ) )
   896                         KMceEmptyMessageStore, selectedDrive ) )
   828                     {
   897                     {
   829                     User::Leave( KErrDiskFull );
   898                     User::Leave( KErrDiskFull );
   830                     }
   899                     }
   831 
   900                 CAknInputBlock* comAbs=CAknInputBlock::NewLC(); 
   832                 CMuiuOperationWait* waiter=CMuiuOperationWait::NewLC(); 
   901                 CMuiuOperationWait* waiter=CMuiuOperationWait::NewLC(); 
   833 
   902 
   834                 CMsvProgressReporterOperation* reportOp =
   903                 CMsvProgressReporterOperation* reportOp =
   835                             CMsvProgressReporterOperation::NewL( *iSession, waiter->iStatus );
   904                             CMsvProgressReporterOperation::NewL( *iSession, waiter->iStatus );
   836                 CleanupStack::PushL( reportOp );
   905                 CleanupStack::PushL( reportOp );
   837 
   906 
       
   907                 reportOp->SetProgressVisibilityDelay(EFalse);
   838                 HBufC* text = StringLoader::LoadLC( R_MCE_SETTINGS_SWITCHING_MESSAGE_STORE, 
   908                 HBufC* text = StringLoader::LoadLC( R_MCE_SETTINGS_SWITCHING_MESSAGE_STORE, 
   839                                                                         iEikonEnv );  
   909                                                                         iEikonEnv );  
   840                 reportOp->SetTitleL( *text ); 
   910                 reportOp->SetTitleL( *text ); 
   841 
   911 
   842                 reportOp->SetCanCancelL( EFalse);
   912                 reportOp->SetCanCancelL( EFalse);
   843 
   913 
   844                 CleanupStack::PopAndDestroy( text );
   914                 CleanupStack::PopAndDestroy( text );
   845             
   915                 iChangeDrive = ETrue;
   846                 CMsvOperation* changeOp=iSession->ChangeDriveL( selectedDrive, 
   916                 CMsvOperation* changeOp=iSession->ChangeDriveL( selectedDrive, 
   847                                                                                                 reportOp->RequestStatus() );
   917                                                                                                 reportOp->RequestStatus() );
   848                 reportOp->SetOperationL( changeOp );
   918                 reportOp->SetOperationL( changeOp );
   849 
   919 
   850                 waiter->Start();
   920                 waiter->Start();
   851     
   921                 iChangeDrive = EFalse;
   852                 CleanupStack::PopAndDestroy( reportOp ); 
   922                 CleanupStack::PopAndDestroy( reportOp ); 
   853                 CleanupStack::PopAndDestroy( waiter );
   923                 CleanupStack::PopAndDestroy( waiter );
       
   924                 CleanupStack::PopAndDestroy( comAbs );
   854                 UpdateMemorySelectionL();
   925                 UpdateMemorySelectionL();
   855                 }                
   926                 }                
   856             }
   927             }
   857 		
   928 		
   858         CEikTextListBox* list=STATIC_CAST( CEikTextListBox*, 
   929         CEikTextListBox* list=STATIC_CAST( CEikTextListBox*, 
  1008         {
  1079         {
  1009         return StringLoader::LoadLC( R_MCE_SETT_MEM_MEMORY_CARD, driveName, iEikonEnv );            
  1080         return StringLoader::LoadLC( R_MCE_SETT_MEM_MEMORY_CARD, driveName, iEikonEnv );            
  1010         }
  1081         }
  1011     }
  1082     }
  1012 #endif //RD_MULTIPLE_DRIVE
  1083 #endif //RD_MULTIPLE_DRIVE
       
  1084 
       
  1085 // ---------------------------------------------------------
       
  1086 // CMceGeneralSettingsDialog::IsThirdPartyMailBox()
       
  1087 // 
       
  1088 // ---------------------------------------------------------
       
  1089 //
       
  1090 TBool CMceGeneralSettingsDialog::IsThirdPartyMailBox()
       
  1091     {
       
  1092     CMsvEntry* entry = iSession->GetEntryL( KMsvRootIndexEntryId );
       
  1093     CleanupStack::PushL( entry );
       
  1094     TInt cnt = entry->Count();
       
  1095     TBool isThirdPartyMail = EFalse;
       
  1096     for ( TInt i=0; i < cnt ; i++)
       
  1097         {
       
  1098         if ( (*entry)[i].iType.iUid == KUidMsvServiceEntryValue &&
       
  1099              (*entry)[i].Id() != KMsvLocalServiceIndexEntryIdValue &&
       
  1100              ( !( (*entry)[i].iMtm.iUid == KUidMsgTypeCmailMtmVal ||
       
  1101                   (*entry)[i].iMtm == KSenduiMtmImap4Uid          || 
       
  1102                   (*entry)[i].iMtm == KSenduiMtmPop3Uid           ||
       
  1103                   (*entry)[i].iMtm == KSenduiMtmSmtpUid   ))   &&
       
  1104              IsEmailEntryL((*entry)[i]))
       
  1105            {
       
  1106            isThirdPartyMail = ETrue;
       
  1107            break;
       
  1108            }
       
  1109         }
       
  1110     CleanupStack::PopAndDestroy( entry );
       
  1111     return isThirdPartyMail;
       
  1112     }
       
  1113 
       
  1114 // ---------------------------------------------------------
       
  1115 // CMceGeneralSettingsDialog::IsEmailEntryL
       
  1116 // 
       
  1117 // ---------------------------------------------------------
       
  1118 //
       
  1119 TBool CMceGeneralSettingsDialog::IsEmailEntryL(TMsvEntry tentry)
       
  1120     {
       
  1121     TBool IsEmail = EFalse;
       
  1122 
       
  1123     CMtmUiDataRegistry* uiRegistry =
       
  1124                          CMtmUiDataRegistry::NewL( *iSession );
       
  1125     CleanupStack::PushL(uiRegistry);
       
  1126     if ( uiRegistry->IsPresent( tentry.iMtm ) &&
       
  1127          uiRegistry->IsPresent( KUidMsgTypePOP3 ) )
       
  1128          {
       
  1129           TUid mailMTMTechType =
       
  1130                   uiRegistry->TechnologyTypeUid( KUidMsgTypePOP3 );
       
  1131           if( uiRegistry->TechnologyTypeUid( tentry.iMtm ) == mailMTMTechType )
       
  1132                 {
       
  1133                 IsEmail = ETrue;
       
  1134                 }
       
  1135          }
       
  1136     CleanupStack::PopAndDestroy( uiRegistry );
       
  1137         
       
  1138     return IsEmail;
       
  1139     }
  1013 //  End of File
  1140 //  End of File