voicerecorder/RecViewSrc/CVRRecView.cpp
branchRCL_3
changeset 19 2f5c9ee7098c
parent 15 487b46c8e1a4
equal deleted inserted replaced
17:41c99112ff9d 19:2f5c9ee7098c
    41 #include <voicerecorder.rsg>
    41 #include <voicerecorder.rsg>
    42 #include <e32property.h> 
    42 #include <e32property.h> 
    43 #include <coreapplicationuisdomainpskeys.h>
    43 #include <coreapplicationuisdomainpskeys.h>
    44 #include <AknLaunchAppService.h>
    44 #include <AknLaunchAppService.h>
    45 #include <AiwGenericParam.h>
    45 #include <AiwGenericParam.h>
       
    46 #include <sysutil.h>
       
    47 #include <aknnotewrappers.h>
    46 
    48 
    47 #include "voicerecorder.hrh"
    49 #include "voicerecorder.hrh"
    48 #include "CVRRecView.h"
    50 #include "CVRRecView.h"
    49 #include "CVRRecViewContainer.h"
    51 #include "CVRRecViewContainer.h"
    50 #include "CVRRecViewActivationContainer.h"
    52 #include "CVRRecViewActivationContainer.h"
   114 // 
   116 // 
   115 // ---------------------------------------------------------------------------
   117 // ---------------------------------------------------------------------------
   116 //
   118 //
   117 void CVRRecView::CVRRecViewModelActivator::RunL()
   119 void CVRRecView::CVRRecViewModelActivator::RunL()
   118 	{
   120 	{
   119 	// Activate model in correct context
   121 	if(iModel->GetIsDriveReady())
   120 	iModel->SetMemoNameNewL( iContext == EContextRecordNewForRemote);
   122 	    {
   121 	iModel->EnterContextL( iContext );
   123         // Activate model in correct context
   122 	iModel->ActivateL();
   124 	    iModel->SetMemoNameNewL( iContext == EContextRecordNewForRemote);
       
   125 	    iModel->EnterContextL( iContext );
       
   126 	    iModel->ActivateL();
       
   127 	    } 
   123 	
   128 	
   124 	// Notify recview
   129 	// Notify recview
   125 	iCallback.CallBack();
   130 	iCallback.CallBack();
   126 	}
   131 	}
   127 
   132 
   148 //
   153 //
   149 void CVRRecView::CVRRecViewModelActivator::DoCancel()
   154 void CVRRecView::CVRRecViewModelActivator::DoCancel()
   150     {
   155     {
   151     }
   156     }
   152 
   157 
       
   158 // ---------------------------------------------------------------------------
       
   159 // CVRRecView::CVRRecViewDialogActivator::CVRRecViewDialogActivator
       
   160 // 
       
   161 // ---------------------------------------------------------------------------
       
   162 //
       
   163 CVRRecView::CVRRecViewDialogActivator::CVRRecViewDialogActivator( CVRRecViewModel* aModel)
       
   164 :CAsyncOneShot(EPriorityNormal), iModel(aModel)
       
   165     {
       
   166     
       
   167     }
       
   168 
       
   169 // ---------------------------------------------------------------------------
       
   170 // CVRRecView::CVRRecViewDialogActivator::~CVRRecViewDialogActivator
       
   171 // 
       
   172 // ---------------------------------------------------------------------------
       
   173 //
       
   174 CVRRecView::CVRRecViewDialogActivator::~CVRRecViewDialogActivator()
       
   175     {
       
   176     Cancel();
       
   177     }
       
   178 
       
   179 // ---------------------------------------------------------------------------
       
   180 // CVRRecView::CVRRecViewDialogActivator::~CVRRecViewDialogActivator
       
   181 // 
       
   182 // ---------------------------------------------------------------------------
       
   183 //
       
   184 void CVRRecView::CVRRecViewDialogActivator::SetDialogType(TDialogTypeID aType)
       
   185     {
       
   186     iType = aType;
       
   187     }
       
   188 
       
   189 // ---------------------------------------------------------------------------
       
   190 // CVRRecView::CVRRecViewDialogActivator::SetViewContexts
       
   191 // 
       
   192 // ---------------------------------------------------------------------------
       
   193 //
       
   194 void CVRRecView::CVRRecViewDialogActivator::SetViewContexts(TVRRecViewContexts aContext)
       
   195     {
       
   196     iContext = aContext;
       
   197     }
       
   198 
       
   199 // ---------------------------------------------------------------------------
       
   200 // CVRRecView::CVRRecViewDialogActivator::DoCancel
       
   201 // 
       
   202 // ---------------------------------------------------------------------------
       
   203 //
       
   204 void CVRRecView::CVRRecViewDialogActivator::DoCancel()
       
   205     {
       
   206     }
       
   207 
       
   208 // ---------------------------------------------------------------------------
       
   209 // CVRRecView::CVRRecViewNoteActivator::RunL
       
   210 // 
       
   211 // ---------------------------------------------------------------------------
       
   212 //
       
   213 void CVRRecView::CVRRecViewDialogActivator::RunL()
       
   214     {
       
   215     if(iType == EDialogForWaitStorageCard)
       
   216         {
       
   217         TInt driveRemovableMassStorage = VRUtils::GetRemovableMassStorageL();
       
   218         while ( !VRUtils::DriveValid( (TDriveNumber) driveRemovableMassStorage ) )
       
   219             {
       
   220             if (!ShowDialogForWaitStorageCardL())
       
   221                 {
       
   222                 iModel->SendExitEvent();
       
   223                 }
       
   224             }
       
   225         // Come to here when driveRemovableMassStorage is valid
       
   226         VRUtils::SetMemoDriveL( (TDriveNumber) driveRemovableMassStorage );    
       
   227         
       
   228         /***** check if memory is below min value, if yes, close app*****/
       
   229         RFs& fs(CEikonEnv::Static()->FsSession());
       
   230         if (SysUtil::DiskSpaceBelowCriticalLevelL(&fs, 0, VRUtils::MemoDriveL()))
       
   231            {
       
   232            HBufC* errorText = StringLoader::LoadLC(
       
   233                    R_VR_MEMORY_LOW_STOP_WARNING);
       
   234            CAknErrorNote* dlg = new (ELeave) CAknErrorNote(ETrue);
       
   235            dlg->ExecuteLD(*errorText);
       
   236            CleanupStack::PopAndDestroy(errorText);
       
   237            iModel->SendExitEvent();
       
   238            }
       
   239         // check memory size end
       
   240         
       
   241         // To activate view model
       
   242         iModel->SetMemoNameNewL( iContext == EContextRecordNewForRemote);
       
   243         iModel->SetIsDriveReady(ETrue);
       
   244         iModel->EnterContextL( iContext );
       
   245         iModel->ActivateL();
       
   246         }
       
   247     else if(iType == EDialogForWaitUSBPluggingOut)
       
   248         {
       
   249         ShowDialogForWaitUSBPluggingOutL();
       
   250         iModel->SendExitEvent();
       
   251         }
       
   252     }
   153 
   253 
   154 // ---------------------------------------------------------------------------
   254 // ---------------------------------------------------------------------------
   155 // CVRRecView::NewLC
   255 // CVRRecView::NewLC
   156 // 
   256 // 
   157 // ---------------------------------------------------------------------------
   257 // ---------------------------------------------------------------------------
   184 		AppUi()->RemoveFromViewStack( *this, iActivationContainer );
   284 		AppUi()->RemoveFromViewStack( *this, iActivationContainer );
   185 		}
   285 		}
   186 
   286 
   187     delete iContainer;
   287     delete iContainer;
   188     delete iActivationContainer;
   288     delete iActivationContainer;
       
   289     delete iDialogActivator;
   189     delete iModel;
   290     delete iModel;
   190     delete iSendUi;
   291     delete iSendUi;
   191     delete iModelActivator;
   292     delete iModelActivator;
   192     delete iLaunchService;
   293     delete iLaunchService;
   193     delete iUSBStateHandler;
   294     delete iUSBStateHandler;
   724 	iActivationContainer->ConstructL( ClientRect() );
   825 	iActivationContainer->ConstructL( ClientRect() );
   725 	CAknViewAppUi* appUi = AppUi();
   826 	CAknViewAppUi* appUi = AppUi();
   726 	appUi->AddToViewStackL( *this, iActivationContainer );
   827 	appUi->AddToViewStackL( *this, iActivationContainer );
   727 	iActivationContainer->ActivateL();
   828 	iActivationContainer->ActivateL();
   728 
   829 
       
   830 	iDialogActivator = new( ELeave ) CVRRecViewDialogActivator(iModel);
       
   831 	CheckDriveState();
       
   832 
   729     // Activate model in correct context asynchronically.
   833     // Activate model in correct context asynchronically.
   730     // iContainer will be activated trough callback after model activation
   834     // iContainer will be activated trough callback after model activation
   731     TCallBack cb(ActivationCallBack, this);
   835     TCallBack cb(ActivationCallBack, this);
   732     iModelActivator->Activate(
   836     iContext = static_cast<TVRRecViewContexts> (aCustomMessageId.iUid);
   733             static_cast<TVRRecViewContexts> (aCustomMessageId.iUid), cb);
   837     iDialogActivator->SetViewContexts(iContext);
       
   838     iModelActivator->Activate(iContext , cb);
   734 
   839 
   735     // Construct the real container
   840     // Construct the real container
   736     iContainer = new (ELeave) CVRRecViewContainer;
   841     iContainer = new (ELeave) CVRRecViewContainer;
   737     iContainer->ConstructL(ClientRect(), iModel, iModel, iModel, this);
   842     iContainer->ConstructL(ClientRect(), iModel, iModel, iModel, this);
   738     iContainer->SetKeyObserver(iModel);
   843     iContainer->SetKeyObserver(iModel);
   739     iContainer->SetVolumeChangeObserver(iModel);
   844     iContainer->SetVolumeChangeObserver(iModel);
   740     }
   845     }
   741 
   846 
       
   847 // ---------------------------------------------------------------------------
       
   848 // CVRRecView::CheckDriveState
       
   849 // 
       
   850 // ---------------------------------------------------------------------------
       
   851 //
       
   852 void CVRRecView::CheckDriveState()
       
   853     {
       
   854     TInt memoDrive = VRUtils::MemoDriveL();
       
   855     if (VRUtils::DriveValid(memoDrive))
       
   856         {
       
   857         VRUtils::SetMemoDriveL((TDriveNumber) memoDrive);
       
   858         }
       
   859     else
       
   860         {
       
   861         TInt defaultDrive = VRUtils::DefaultMemoDriveL(); //eMMC
       
   862         if (defaultDrive == memoDrive)
       
   863             {
       
   864             SetDriveL();
       
   865             }
       
   866         else
       
   867             {
       
   868             if (VRUtils::DriveValid(defaultDrive))
       
   869                 {
       
   870                 VRUtils::SetMemoDriveL((TDriveNumber) defaultDrive);
       
   871                 }
       
   872             else
       
   873                 {
       
   874                 SetDriveL();
       
   875                 }
       
   876             }
       
   877         }
       
   878 
       
   879     
       
   880     if (iModel->GetIsDriveReady() && CVRUSBStateHanlder::IsUsbActive())
       
   881         {
       
   882         iModel->SetIsDriveReady(EFalse);
       
   883         iDialogActivator->SetDialogType(EDialogForWaitUSBPluggingOut);
       
   884         iDialogActivator->Call();
       
   885         }
       
   886     
       
   887     
       
   888     if(iModel->GetIsDriveReady()) 
       
   889         {
       
   890         /***** check if memory is below min value, if yes, close app*****/
       
   891         RFs& fs(CEikonEnv::Static()->FsSession());
       
   892         if (SysUtil::DiskSpaceBelowCriticalLevelL(&fs, 0, VRUtils::MemoDriveL()))
       
   893             {
       
   894             HBufC* errorText = StringLoader::LoadLC(
       
   895                     R_VR_MEMORY_LOW_STOP_WARNING);
       
   896             CAknErrorNote* dlg = new (ELeave) CAknErrorNote(ETrue);
       
   897             dlg->ExecuteLD(*errorText);
       
   898             CleanupStack::PopAndDestroy(errorText);
       
   899             iModel->SendExitEvent();
       
   900             }
       
   901         // check memory size end
       
   902         }
       
   903     }
       
   904 
       
   905 // ---------------------------------------------------------------------------
       
   906 // Make user insert the SD card, and choose SD card as the memo storage
       
   907 // ---------------------------------------------------------------------------
       
   908 //
       
   909 void CVRRecView::SetDriveL()
       
   910     {
       
   911     TInt driveRemovableMassStorage = VRUtils::GetRemovableMassStorageL();
       
   912     if ( VRUtils::DriveValid( (TDriveNumber) driveRemovableMassStorage ) )
       
   913         {
       
   914         VRUtils::SetMemoDriveL( (TDriveNumber) driveRemovableMassStorage );
       
   915         }
       
   916     else
       
   917         {
       
   918         iModel->SetIsDriveReady(EFalse);
       
   919         if (CVRUSBStateHanlder::IsUsbActive())
       
   920             {
       
   921             iDialogActivator->SetDialogType(EDialogForWaitUSBPluggingOut);
       
   922             iDialogActivator->Call();
       
   923             }
       
   924         else
       
   925             {
       
   926             iDialogActivator->SetDialogType(EDialogForWaitStorageCard);
       
   927             iDialogActivator->Call();
       
   928             }
       
   929         }
       
   930     }
       
   931 
       
   932 // ---------------------------------------------------------------------------
       
   933 // This method show a dialog to warn user to insert the SD card.
       
   934 // ---------------------------------------------------------------------------
       
   935 //
       
   936 TBool CVRRecView::ShowDialogForWaitStorageCardL()
       
   937     {
       
   938     HBufC* text = StringLoader::LoadLC( R_QTN_CCOR_INSERT_MMC );
       
   939     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
   940     TInt result( dlg->ExecuteLD( R_INSERT_F_CARD_DIALOG, *text ) );
       
   941     CleanupStack::PopAndDestroy( text );
       
   942 
       
   943     if ( result )
       
   944         {
       
   945         return ETrue;
       
   946         }
       
   947     return EFalse;
       
   948     }
   742 
   949 
   743 // ---------------------------------------------------------------------------
   950 // ---------------------------------------------------------------------------
   744 // CVRRecView::SetFileHandle
   951 // CVRRecView::SetFileHandle
   745 // 
   952 // 
   746 // ---------------------------------------------------------------------------
   953 // ---------------------------------------------------------------------------
   865 		MenuBar()->TryDisplayMenuBarL();
  1072 		MenuBar()->TryDisplayMenuBarL();
   866 		}
  1073 		}
   867 	
  1074 	
   868 
  1075 
   869     HandleCommandL(ECmdUSBChange);
  1076     HandleCommandL(ECmdUSBChange);
       
  1077     
       
  1078     if(!VRUtils::DriveValid(VRUtils::MemoDriveL()))
       
  1079         {
       
  1080         iModel->SendExitEvent();
       
  1081         }
   870     return KErrNone;
  1082     return KErrNone;
   871     }
  1083     }
   872 
  1084 
   873 void CVRRecView::DialogDismissedL(TInt /*aButtonId*/)
  1085 void CVRRecView::DialogDismissedL(TInt /*aButtonId*/)
   874     {
  1086     {