commonuis/CommonDialogs/src/CAknMemorySelectionSettingItem.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002-2006 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:  ?Description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <pathinfo.h> //PathInfo
       
    21 #include <driveinfo.h> //DriveInfo
       
    22 
       
    23 #include "CAknMemorySelectionSettingItem.h"
       
    24 #include "AknCFDUtility.h"
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS =============================
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // CAknMemorySelectionSettingItem::CAknMemorySelectionSettingItem
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 EXPORT_C CAknMemorySelectionSettingItem::CAknMemorySelectionSettingItem(
       
    33     TInt aIdentifier,
       
    34     CAknMemorySelectionSettingPage::TMemory& aSelectedMemory )
       
    35     :   CAknSettingItem( aIdentifier ),
       
    36         iExternalData( aSelectedMemory )
       
    37     {
       
    38     }
       
    39 
       
    40 // Destructor
       
    41 EXPORT_C CAknMemorySelectionSettingItem::~CAknMemorySelectionSettingItem()
       
    42     {
       
    43     delete iSettingPage;
       
    44     }
       
    45 
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // CAknMemorySelectionSettingItem::CompleteConstructionL
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 EXPORT_C void CAknMemorySelectionSettingItem::CompleteConstructionL()
       
    52     {
       
    53     if( !iSettingPage )
       
    54         {
       
    55         iSettingPage =
       
    56             CAknMemorySelectionSettingPage::NewL( SettingPageResourceId() );
       
    57         }
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // CAknMemorySelectionSettingItem::EditItemL
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 EXPORT_C void CAknMemorySelectionSettingItem::EditItemL( TBool aCalledFromMenu )
       
    65     {
       
    66     // This in case application hasn't called CompleteConstructionL()
       
    67     CompleteConstructionL();
       
    68     
       
    69 	  if( aCalledFromMenu )
       
    70         {
       
    71         // Changed with Options/Change
       
    72         iSettingPage->ExecuteL( iInternalData );
       
    73         }
       
    74     else
       
    75         {
       
    76         // Changed with selection key
       
    77         TDriveNumber mmcDrive;
       
    78         User::LeaveIfError(
       
    79             DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage,
       
    80                                         ( TInt& )mmcDrive ) );
       
    81         if( iSettingPage->NumberOfItems() != 2 ||
       
    82             AknCFDUtility::DriveStatusL( mmcDrive )  != EDriveOK )
       
    83             {
       
    84             // Does not qualify as binary pop-up setting page
       
    85             // with two available values
       
    86             iSettingPage->ExecuteL( iInternalData );
       
    87             }
       
    88         else
       
    89             {
       
    90             // Two items in list, function as binary pop-up setting page
       
    91             if( iInternalData == CAknMemorySelectionSettingPage::EMemoryCard )
       
    92                 {
       
    93                 iInternalData = CAknMemorySelectionSettingPage::EPhoneMemory;
       
    94                 }
       
    95             else
       
    96                 {
       
    97                 iInternalData = CAknMemorySelectionSettingPage::EMemoryCard;
       
    98                 }
       
    99             }
       
   100         }
       
   101     UpdateListBoxTextL();
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------------------------
       
   105 // CAknMemorySelectionSettingItem::LoadL
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 EXPORT_C void CAknMemorySelectionSettingItem::LoadL()
       
   109     {
       
   110     iInternalData = iExternalData;
       
   111     }
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // CAknMemorySelectionSettingItem::StoreL
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 EXPORT_C void CAknMemorySelectionSettingItem::StoreL()
       
   118     {
       
   119     iExternalData = iInternalData;
       
   120     }
       
   121 
       
   122 // ---------------------------------------------------------------------------
       
   123 // CAknMemorySelectionSettingItem::SettingTextL
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 EXPORT_C const TDesC& CAknMemorySelectionSettingItem::SettingTextL()
       
   127     {
       
   128     // This in case application hasn't called CompleteConstructionL()
       
   129     CompleteConstructionL();
       
   130 
       
   131     TInt memoryIndex( iInternalData );
       
   132     if( iInternalData == CAknMemorySelectionSettingPage::EMemoryCard )
       
   133         {
       
   134         TDriveNumber mmcDrive;
       
   135         User::LeaveIfError(
       
   136             DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage,
       
   137                                         ( TInt& )mmcDrive ) );
       
   138         if( AknCFDUtility::DriveStatusL( mmcDrive ) != EDriveOK )
       
   139             {
       
   140             // If user's selection is memory card and it is locked, corrupted
       
   141             // or unavailable, show name of phone memory as selected item.
       
   142             memoryIndex = CAknMemorySelectionSettingPage::EPhoneMemory;
       
   143             }
       
   144         }
       
   145 
       
   146     iSettingPage->GetItem( memoryIndex, iSettingText );
       
   147     return iSettingText;
       
   148     }
       
   149