camerauis/cameraapp/generic/GsCamcorderPlugin/src/GSCamPhotoSettingsList.cpp
branchRCL_3
changeset 24 bac7acad7cb3
equal deleted inserted replaced
23:61bc0f252b2b 24:bac7acad7cb3
       
     1 /*
       
     2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Image settings list class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20  
       
    21 #include <bldvariant.hrh>
       
    22 #include <CAknMemorySelectionSettingItem.h> // CAknMemorySelectionSettingItem
       
    23 #include <featmgr.h>
       
    24 #include <gscamerapluginrsc.rsg>
       
    25 #include <StringLoader.h>
       
    26 #include <AknQueryDialog.h>
       
    27 #include <AknWaitDialog.h>
       
    28 #include <CAknMemorySelectionSettingItemMultiDrive.h>
       
    29 #include <driveinfo.h> // DriveInfo
       
    30 #include <AknCommonDialogsDynMem.h>
       
    31 
       
    32 #include "GSCamcorderPlugin.hrh"
       
    33 #include "Cam.hrh"
       
    34 #include "CamSettings.hrh"
       
    35 #include "CamSettingsInternal.hrh"
       
    36 #include "CamPanic.h"
       
    37 #include "CamAppUiBase.h"
       
    38 #include "CamUtility.h"
       
    39 #include "MCamAppController.h"
       
    40 #include "GSCamPhotoSettingsList.h"
       
    41 #include "GSCamcorderPlugin.h"
       
    42 #include "GSCamQualitySettingItem.h"
       
    43 #include "GSCustomQualitySettingItem.h"
       
    44 #include "GSCamDefaultNameSettingItem.h"
       
    45 #include "CameraUiConfigManager.h"
       
    46 #include "CamCollectionManagerAo.h"
       
    47 #include "CamWaitDialog.h"
       
    48 #include "CamLocationSettingItem.h"
       
    49 #include "camconfiguration.h"
       
    50 #include "GSCamCaptureToneSettingItem.h"
       
    51 
       
    52 // ========================= MEMBER FUNCTIONS ================================
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // CGSCamPhotoSettingsList::CGSCamPhotoSettingsList
       
    56 // C++ constructor
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CGSCamPhotoSettingsList::CGSCamPhotoSettingsList( CCamStaticSettingsModel& aModel )
       
    60 : iModel( aModel )
       
    61     {
       
    62     }
       
    63 
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // CGSCamPhotoSettingsList::ConstructL
       
    67 // Symbian OS 2nd phase constructor
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 void CGSCamPhotoSettingsList::ConstructL( TBool aLaunchedFromGS,
       
    71                                           TBool aSecondaryCameraSettings )
       
    72     {
       
    73     CAknViewAppUi *AppUi = static_cast<CAknViewAppUi*>
       
    74                            ( CCoeEnv::Static()->AppUi() );
       
    75 
       
    76     CGSCamcorderPlugin* parent = static_cast<CGSCamcorderPlugin*> 
       
    77         					   ( AppUi->View( KGSCamcorderGSPluginUid ) );
       
    78     if ( parent )
       
    79         {
       
    80         parent->LoadVideoStaticSettingsL( ETrue );
       
    81         parent->LoadPhotoStaticSettingsL( ETrue );
       
    82         }
       
    83 
       
    84     iLaunchedFromGS = aLaunchedFromGS;
       
    85     iSecondaryCameraSettings = aSecondaryCameraSettings;
       
    86     iSettings.ResetAndDestroy();
       
    87     iModel.Configuration().GetPsiIntArrayL( ECamPsiSupportedStillQualities, iSupportedQualityLevels );
       
    88     
       
    89     TInt resId;
       
    90     if ( iModel.UiConfigManagerPtr() &&
       
    91          iModel.UiConfigManagerPtr()->IsLocationSupported() )
       
    92         {
       
    93         resId =  iLaunchedFromGS?R_CAM_PHOTO_GSSETTINGS_WITH_LOCATION_ITEM_LIST_CAMCORDER:
       
    94                                  R_CAM_PHOTO_SETTINGS_WITH_LOCATION_ITEM_LIST_CAMCORDER;
       
    95         }
       
    96     else
       
    97         {
       
    98         resId =  iLaunchedFromGS?R_CAM_PHOTO_GSSETTINGS_ITEM_LIST_CAMCORDER:
       
    99                                  R_CAM_PHOTO_SETTINGS_ITEM_LIST_CAMCORDER;
       
   100         }
       
   101     
       
   102     if ( iSecondaryCameraSettings )
       
   103         {
       
   104         resId =  R_CAM_PHOTO_SETTINGS_ITEM_LIST_PORTRAIT;
       
   105         }
       
   106     ConstructFromResourceL( resId );
       
   107     }
       
   108 
       
   109 
       
   110 // Destructor
       
   111 CGSCamPhotoSettingsList::~CGSCamPhotoSettingsList()
       
   112     {
       
   113     iSettings.ResetAndDestroy();
       
   114     iSettings.Close();
       
   115     iSupportedQualityLevels.Close(); 
       
   116     }
       
   117 
       
   118 
       
   119 // ---------------------------------------------------------------------------
       
   120 // CGSCamPhotoSettingsList::CreateSettingItemL
       
   121 // From CAknSettingItemList Handles creating setting items
       
   122 // ---------------------------------------------------------------------------
       
   123 //
       
   124 CAknSettingItem* CGSCamPhotoSettingsList::CreateSettingItemL( TInt aIdentifier )
       
   125     {
       
   126     // Add storage place to storage list of settings values. 
       
   127     // ...create the storage place.
       
   128     CAknViewAppUi *AppUi = static_cast<CAknViewAppUi*>
       
   129                            ( CCoeEnv::Static()->AppUi() );
       
   130 
       
   131     CGSCamcorderPlugin* parent = static_cast<CGSCamcorderPlugin*> 
       
   132         					   ( AppUi->View( KGSCamcorderGSPluginUid ) );
       
   133 
       
   134     TIntSetting* newSetting = new( ELeave ) TIntSetting;
       
   135     CleanupStack::PushL( newSetting );
       
   136     // ...set the identifier for this setting item.
       
   137     newSetting->iItemId = aIdentifier;
       
   138     if( aIdentifier != ECamSettingItemRestoreCameraSettings && parent )
       
   139         {
       
   140         newSetting->iValueId = parent->IntegerSettingValue( aIdentifier );
       
   141         }
       
   142     else
       
   143         {
       
   144         newSetting->iValueId = 0;     
       
   145         }
       
   146     // ...add the new storage place item to the storage list.
       
   147     iSettings.AppendL( newSetting );
       
   148     CleanupStack::Pop( newSetting );
       
   149 
       
   150   // Create the list setting item
       
   151   CAknSettingItem* settingItem = NULL;
       
   152   TInt lastItem = iSettings.Count() - 1;
       
   153   // Setting items take reference to the value to be manipulated.
       
   154   TInt& valueId( iSettings[lastItem]->iValueId );
       
   155 
       
   156   switch ( aIdentifier )
       
   157     {
       
   158     case ECamSettingItemPhotoShowFocusPoint:
       
   159     case ECamSettingItemShowCapturedPhoto:
       
   160       {
       
   161       settingItem = new( ELeave ) 
       
   162           CAknBinaryPopupSettingItem( aIdentifier, valueId );	
       
   163       }
       
   164       break;
       
   165 
       
   166     case ECamSettingItemPhotoDigitalZoom:
       
   167       {
       
   168       if ( iModel.UiConfigManagerPtr() &&
       
   169               iModel.UiConfigManagerPtr()->IsExtendedDigitalZoomSupported() )
       
   170           {
       
   171           settingItem = new( ELeave ) 
       
   172                           CAknEnumeratedTextPopupSettingItem( aIdentifier, valueId );          
       
   173           }
       
   174       }
       
   175       break;
       
   176 
       
   177     case ECamSettingItemPhotoQuality:
       
   178       {
       
   179       if ( parent )
       
   180           {
       
   181           iQualityValue = parent->IntegerSettingValue( ECamSettingItemPhotoQuality );
       
   182           }
       
   183       if ( !iLaunchedFromGS )
       
   184           {
       
   185           settingItem = new( ELeave )
       
   186                   CGSCamQualitySettingItem( ECamControllerImage,
       
   187                                             aIdentifier,
       
   188                                             iQualityValue,
       
   189                                             iModel
       
   190                                           );
       
   191           }
       
   192       else
       
   193           {
       
   194           settingItem = new( ELeave ) 
       
   195                   CGSCustomQualitySettingItem( aIdentifier, 
       
   196                                                iQualityValue,
       
   197                                                iModel,
       
   198                                                ECamControllerImage
       
   199                                               );
       
   200           }
       
   201        }
       
   202        break;
       
   203      case ECamSettingItemPhotoCaptureTone:
       
   204             {
       
   205             settingItem = new( ELeave ) 
       
   206                 CGSCamCaptureToneSettingItem( aIdentifier, valueId );    
       
   207             }
       
   208             break;
       
   209 
       
   210         case ECamSettingItemImageRotation:
       
   211             {
       
   212             if ( iModel.UiConfigManagerPtr() &&
       
   213                  iModel.UiConfigManagerPtr()->IsOrientationSensorSupported() )
       
   214                 {
       
   215                 settingItem = 
       
   216                     new( ELeave ) CAknBinaryPopupSettingItem( aIdentifier, valueId );
       
   217                 }
       
   218             }
       
   219             break;
       
   220 
       
   221         case ECamSettingItemRestoreCameraSettings:
       
   222             {
       
   223             settingItem = new ( ELeave ) CAknBigSettingItemBase( aIdentifier );
       
   224             }
       
   225         break;
       
   226 
       
   227         case ECamSettingItemPhotoMediaStorage:
       
   228             {
       
   229             // Convert the setting to a memory enum
       
   230             iMemVal = static_cast<DriveInfo::TDefaultDrives>
       
   231                     ( CamUtility::MapToSettingsListMemory( valueId ) );
       
   232             
       
   233 		    // Get the root path of the default mass storage memory.
       
   234 		    if(iMemVal != KErrNotFound)
       
   235 		        {
       
   236                 TInt driveInt;
       
   237 		        TInt err = DriveInfo::GetDefaultDrive( iMemVal, driveInt );
       
   238 		        iDrive = static_cast<TDriveNumber>(driveInt);
       
   239 		        }
       
   240 		    else
       
   241 		        {
       
   242                 iDrive = static_cast<TDriveNumber>(0); //Doesn't matter
       
   243 		        }
       
   244 		    TInt includedMedias(0);
       
   245 		    CGSCamcorderPlugin* parent = static_cast<CGSCamcorderPlugin*> 
       
   246 		                                ( AppUi->View( KGSCamcorderGSPluginUid ) );
       
   247 		    TInt driveCount(0);
       
   248 		    if( !parent->IntegerSettingValue(ECamSettingItemRemovePhoneMemoryUsage) )
       
   249 		        {
       
   250                 includedMedias |= AknCommonDialogsDynMem::EMemoryTypePhone;
       
   251                 driveCount++;
       
   252 		        }
       
   253 		    
       
   254 		    TInt drive(0);
       
   255 		    TUint driveStatus(0);    
       
   256 		    TInt err(0);
       
   257 		    err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, drive );
       
   258 		    if( err == KErrNone )
       
   259 		        {
       
   260 		        err = DriveInfo::GetDriveStatus( CCoeEnv::Static()->FsSession(), 
       
   261 		                                         drive, 
       
   262 		                                         driveStatus );
       
   263 		        if( err == KErrNone )
       
   264 		            {
       
   265                     if( ( driveStatus & DriveInfo::EDrivePresent) ==  DriveInfo::EDrivePresent )
       
   266                         {
       
   267                         if( ( driveStatus & DriveInfo::EDriveRemovable ) != DriveInfo::EDriveRemovable )
       
   268                             {
       
   269                             includedMedias |= AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage;
       
   270                             driveCount++;
       
   271                             }
       
   272                         }
       
   273 		            }
       
   274                 }
       
   275 		    
       
   276 		    err = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, drive );
       
   277             if( err == KErrNone )
       
   278                 {
       
   279                 err = DriveInfo::GetDriveStatus( CCoeEnv::Static()->FsSession(), 
       
   280                                                  drive,
       
   281                                                  driveStatus );
       
   282                 if( err == KErrNone )
       
   283                     {
       
   284                     if( ( driveStatus & DriveInfo::EDrivePresent) ==  DriveInfo::EDrivePresent )
       
   285                         {
       
   286                         includedMedias |= AknCommonDialogsDynMem::EMemoryTypeMMCExternalInDevice;
       
   287                         driveCount++;
       
   288                         }
       
   289                     }
       
   290                 }
       
   291 		    
       
   292 		    settingItem = new ( ELeave ) 
       
   293 		                  CAknMemorySelectionSettingItemMultiDrive(
       
   294 		                                                      aIdentifier,
       
   295                                                               iDrive
       
   296                                                               );
       
   297 		    static_cast<CAknMemorySelectionSettingItemMultiDrive*>(settingItem)
       
   298 		                        ->SetIncludedMediasL(includedMedias);
       
   299 		    if( driveCount <= 1 )
       
   300 		        {
       
   301                 settingItem->SetHidden( ETrue );
       
   302                 }
       
   303 		    }
       
   304             break;
       
   305  
       
   306         case ECamSettingItemPhotoNameBaseType:
       
   307             {
       
   308             if ( parent )
       
   309                 {
       
   310                 iDefaultNameBase = parent->TextSettingValue(
       
   311                                    ECamSettingItemPhotoNameBase );
       
   312                 TBool flag = ( iLaunchedFromGS );
       
   313                 settingItem = 
       
   314                     new( ELeave ) CGSCamDefaultNameSettingItem( iDefaultNameBase, 
       
   315                                                                 ECamControllerImage,
       
   316                                                                 aIdentifier,
       
   317                                                                 valueId, 
       
   318                                                                 flag );
       
   319                 }
       
   320              }
       
   321             break;          
       
   322 
       
   323     case ECamSettingItemRecLocation:
       
   324       {
       
   325       if ( !iLaunchedFromGS )
       
   326         {
       
   327         settingItem = 
       
   328             new( ELeave ) CCamLocationSettingItem( ECamControllerImage,
       
   329                                                    aIdentifier, 
       
   330                                                    valueId );
       
   331         }
       
   332       else
       
   333         {
       
   334         settingItem = new( ELeave ) 
       
   335             CAknBinaryPopupSettingItem( aIdentifier, valueId );
       
   336         }
       
   337       }
       
   338       break;
       
   339 
       
   340     default:
       
   341        {
       
   342        break;
       
   343        }
       
   344      }
       
   345     return settingItem;
       
   346     }
       
   347 
       
   348 
       
   349 
       
   350 // ---------------------------------------------------------------------------
       
   351 // CGSCamPhotoSettingsList::EditItemL
       
   352 // Launch the setting page for the current item by calling
       
   353 // EditItemL on it.
       
   354 // ---------------------------------------------------------------------------
       
   355 //
       
   356 void CGSCamPhotoSettingsList::EditItemL( TInt aIndex, TBool aCalledFromMenu )
       
   357     {
       
   358     CAknViewAppUi *AppUi = static_cast<CAknViewAppUi*>( CCoeEnv::Static()->AppUi() );
       
   359     CGSCamcorderPlugin* parent = static_cast<CGSCamcorderPlugin*> 
       
   360         					( AppUi->View( KGSCamcorderGSPluginUid ) );
       
   361     CAknSettingItemArray* itemArray = SettingItemArray();
       
   362     CAknSettingItem* editedItem = itemArray->At(aIndex);
       
   363     
       
   364     if ( editedItem->Identifier() == ECamSettingItemRestoreCameraSettings )
       
   365         {
       
   366         TInt response = 0; 
       
   367         if ( parent )
       
   368             {
       
   369             response = parent->DisplayRestoreSettingsDlgL(); 
       
   370             }
       
   371         // If launched from GS and response "Yes" reload settings page to update values 
       
   372         if ( iLaunchedFromGS && response )
       
   373             {
       
   374             AppUi->ActivateLocalViewL( KGSCamcorderGSPluginUid );
       
   375             }
       
   376         return;
       
   377         }    
       
   378 
       
   379     // Edit item via setting page or in-place.
       
   380     CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu );
       
   381     
       
   382     // Write the new value for the edited control to its stored data.
       
   383     editedItem->StoreL();
       
   384 
       
   385     // Update the settings model so that the navipane is updated.
       
   386     TInt settingValue;
       
   387     // ...If the changed setting is the media storage setting
       
   388     // ...then convert the memory value to settings model type value.
       
   389     if ( editedItem->Identifier() == ECamSettingItemPhotoMediaStorage )
       
   390         {
       
   391         iMemVal = static_cast<DriveInfo::TDefaultDrives>(CamUtility::GetDriveTypeFromDriveNumber( iDrive ));
       
   392         settingValue = CamUtility::MapFromSettingsListMemory( iMemVal );
       
   393         settingValue = ( (settingValue == ECamMediaStoragePhone) && 
       
   394                          parent->IntegerSettingValue(ECamSettingItemRemovePhoneMemoryUsage)  )?
       
   395                                  ECamMediaStorageNone:settingValue;
       
   396         }
       
   397     else if ( editedItem->Identifier() == ECamSettingItemPhotoQuality )
       
   398         {
       
   399         settingValue = iQualityValue;
       
   400         }
       
   401     else
       
   402         {
       
   403         settingValue = ValueOfSetting( editedItem->Identifier() );
       
   404         }
       
   405    
       
   406       if ( parent )
       
   407         {
       
   408         parent->SetIntegerSettingValueL( editedItem->Identifier(), settingValue );
       
   409         }
       
   410 
       
   411     // If the setting is for the photo base name then store the name.
       
   412       if ( parent )
       
   413         {
       
   414         parent->SetTextSettingValueL( ECamSettingItemPhotoNameBase,
       
   415                                       iDefaultNameBase );
       
   416         }
       
   417 
       
   418     }
       
   419 
       
   420 // ---------------------------------------------------------------------------
       
   421 // CGSCamPhotoSettingsList::ValueOfSetting
       
   422 // Returns the current value of the a setting for this list.
       
   423 // Note, this is not the value currently stored in the settings model, as these
       
   424 // may differ.
       
   425 // ---------------------------------------------------------------------------
       
   426 //
       
   427 TInt CGSCamPhotoSettingsList::ValueOfSetting( TInt aItemId ) const
       
   428     {
       
   429     TInt itemIndex = IndexOfSetting( aItemId );
       
   430     return iSettings[itemIndex]->iValueId;
       
   431     }
       
   432 
       
   433 // ---------------------------------------------------------------------------
       
   434 // CGSCamPhotoSettingsList::IndexOfSetting
       
   435 // Returns the array index of a setting for this list.
       
   436 // ---------------------------------------------------------------------------
       
   437 //
       
   438 TInt CGSCamPhotoSettingsList::IndexOfSetting( TInt aItemId ) const
       
   439     {
       
   440     TInt i;
       
   441   TInt itemTotal = iSettings.Count();
       
   442     for ( i = 0; i < itemTotal; ++i )
       
   443         {
       
   444         if ( iSettings[i]->iItemId == aItemId )
       
   445             {
       
   446             return i;
       
   447             }
       
   448         }
       
   449 
       
   450     // Should never get here.
       
   451     // Remove lint warning
       
   452     return KErrNotFound;
       
   453     }
       
   454 
       
   455    
       
   456 // ---------------------------------------------------------------------------
       
   457 // CGSCamPhotoSettingsList::SizeChanged
       
   458 // Set the size and position of component controls.
       
   459 // ---------------------------------------------------------------------------
       
   460 //
       
   461 void CGSCamPhotoSettingsList::SizeChanged()
       
   462     {
       
   463     CAknSettingItemList::SizeChanged();
       
   464 
       
   465     CEikListBox* lb = ListBox();
       
   466     if( lb )
       
   467         {
       
   468         lb->SetRect( Rect() );  // Set container's rect to listbox
       
   469         }
       
   470     }
       
   471 
       
   472 // End of File
       
   473