--- a/commonuis/CommonDialogs/src/caknmemoryselectionsettingitemmultidrive.cpp Fri Mar 12 15:43:43 2010 +0200
+++ b/commonuis/CommonDialogs/src/caknmemoryselectionsettingitemmultidrive.cpp Mon Mar 15 12:41:34 2010 +0200
@@ -26,26 +26,45 @@
#include "MAknCFDFileSystemObserver.h"
-NONSHARABLE_CLASS(CAknMemorySelectionSettingItemExtension) : public CBase,
- public MAknCFDFileSystemObserver
+NONSHARABLE_CLASS(CAknMemorySelectionSettingItemExtension)
+ : public CBase,
+ public MAknCFDFileSystemObserver
{
public:
- CAknMemorySelectionSettingItemExtension(CAknMemorySelectionSettingItemMultiDrive* aSettingItem);
+ CAknMemorySelectionSettingItemExtension(
+ CAknMemorySelectionSettingItemMultiDrive* aSettingItem );
~CAknMemorySelectionSettingItemExtension();
- // second phase construct
- void ConstructL();
+ /**
+ * second phase construct
+ *
+ * @param aIncludedMedias bit flag definition of which medias are
+ * included in the dialog. See AknCommonDialogsDynMem::TMemoryTypes.
+ */
+ void ConstructL( TInt aIncludedMedias );
/**
* Static constructor.
*
* @since S60 5.0
* @param aSettingItem defines a pointer to the setting item.
+ * @param aIncludedMedias bit flag definition of which medias are
+ * included in the dialog. See AknCommonDialogsDynMem::TMemoryTypes.
+ * if not set, use dialog default value.
* @return Returns a pointer to an instance of itself.
*/
- static CAknMemorySelectionSettingItemExtension* NewL(CAknMemorySelectionSettingItemMultiDrive* aSettingItem);
+ static CAknMemorySelectionSettingItemExtension* NewL(
+ CAknMemorySelectionSettingItemMultiDrive* aSettingItem,
+ TInt aIncludedMedias = -1 );
+ /**
+ * Construct memory selection dialog
+ *
+ * @param aIncludedMedias bit flag definition of which medias are
+ * included in the dialog. See AknCommonDialogsDynMem::TMemoryTypes.
+ */
+ void ConstructDialogL( TInt aIncludedMedias );
// Functions from base interface MAknCFDFileSystemObserver
/**
@@ -61,6 +80,9 @@
// Own: The extension of setting item
CAknCFDFileSystemEvent* iFSEvent;
+
+ // Own: Indicate which media types of drives could be visible.
+ TInt iIncludedMedias;
};
// ======== MEMBER FUNCTIONS ========
@@ -94,7 +116,10 @@
//
EXPORT_C void CAknMemorySelectionSettingItemMultiDrive::CompleteConstructionL()
{
- iExtension = CAknMemorySelectionSettingItemExtension::NewL(this);
+ if ( !iExtension )
+ {
+ iExtension = CAknMemorySelectionSettingItemExtension::NewL( this );
+ }
}
@@ -119,28 +144,30 @@
else
{
// Changed with selection key
- if( ( iExtension->iDialog->NumberOfItems() == 2 ) &&
- ( !iExtension->iDialog->HasUnavailbleMMC() ) )
+ if( ( iExtension->iDialog->NumberOfItems() == 2 ) )
{
// Two items in list, function as binary pop-up setting page
TInt selectedIndex =
- iExtension->iDialog->FindIndexByDrive(
- iInternalData );
+ iExtension->iDialog->FindIndexByDrive( iInternalData );
if ( selectedIndex == KErrNotFound )
{
selectedIndex = 0;
}
else
{
- selectedIndex = 1 - selectedIndex; // switch to another one.
+ TDriveNumber driveNum =
+ iExtension->iDialog->FindDriveByIndex( 1 - selectedIndex );
+ if ( AknCFDUtility::DriveStatusL( driveNum ) == EDriveOK )
+ {
+ selectedIndex = 1 - selectedIndex; // switch to another one.
+ }
}
iInternalData =
iExtension->iDialog->FindDriveByIndex( selectedIndex );
}
else
{
- iExtension->iDialog->ExecuteL(
- iInternalData, NULL, NULL );
+ iExtension->iDialog->ExecuteL( iInternalData, NULL, NULL );
}
}
@@ -182,25 +209,46 @@
CompleteConstructionL();
}
- TInt memoryIndex = iExtension->iDialog->FindIndexByDrive(
- iInternalData );
- if ( AknCFDUtility::DriveStatusL( iInternalData )
- != EDriveOK )
+ TInt memoryIndex = iExtension->iDialog->FindIndexByDrive( iInternalData );
+ if ( AknCFDUtility::DriveStatusL( iInternalData ) != EDriveOK )
{
- TInt drive;
- User::LeaveIfError( DriveInfo::GetDefaultDrive(
- DriveInfo::EDefaultSystem, drive ) );
- memoryIndex = iExtension->iDialog->FindIndexByDrive(
- TDriveNumber( drive ) );
+ // Find the first proper drive in the dialog list.
+ memoryIndex = 0;
+ while ( memoryIndex < iExtension->iDialog->NumberOfItems() )
+ {
+ iInternalData = iExtension->iDialog->FindDriveByIndex( memoryIndex );
+ if ( AknCFDUtility::DriveStatusL( iInternalData ) == EDriveOK )
+ {
+ break;
+ }
+ memoryIndex++;
+ }
+ // Not find the proper drive.
+ if ( memoryIndex == iExtension->iDialog->NumberOfItems() )
+ {
+ iInternalData = EDriveC;
+ memoryIndex = KErrNotFound;
+ }
}
+
+ if ( memoryIndex == KErrNotFound )
+ {
+ return KNullDesC;
+ }
+
if( !iSettingText )
iSettingText = HBufC::NewL( KMaxName );
TPtr ptrSettingText( iSettingText->Des() );
iExtension->iDialog->GetItem( memoryIndex, ptrSettingText );
+
return *iSettingText;
}
+// ---------------------------------------------------------------------------
+// CAknMemorySelectionSettingItemMultiDrive::UpdateSettingItemContentL
+// ---------------------------------------------------------------------------
+//
void CAknMemorySelectionSettingItemMultiDrive::UpdateSettingItemContentL()
{
if ( iExtension->iDialog != NULL )
@@ -210,22 +258,37 @@
// Update setting item value.
TInt selectedIndex = iExtension->iDialog->
- FindIndexByDrive(iInternalData);
+ FindIndexByDrive( iInternalData );
- if (selectedIndex == KErrNotFound)
+ if ( selectedIndex == KErrNotFound )
{
- iInternalData = EDriveC;
+ // If the selected index is not found, set it to the first one
+ selectedIndex = 0;
}
- else
- {
- iInternalData = iExtension->iDialog->
- FindDriveByIndex(selectedIndex);
- }
+ iInternalData = iExtension->iDialog->FindDriveByIndex( selectedIndex );
UpdateListBoxTextL();
}
}
+// ---------------------------------------------------------------------------
+// CAknMemorySelectionSettingItemMultiDrive::SetIncludedMediasL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CAknMemorySelectionSettingItemMultiDrive::SetIncludedMediasL(
+ TInt aIncludedMedias )
+ {
+ if ( !iExtension )
+ {
+ iExtension = CAknMemorySelectionSettingItemExtension::NewL(
+ this, aIncludedMedias );
+ }
+ else if ( iExtension->iIncludedMedias != aIncludedMedias )
+ {
+ iExtension->ConstructDialogL( aIncludedMedias );
+ }
+ }
+
// ---------------------------------------------------------------------------
// CAknMemorySelectionSettingItemExtension
@@ -233,7 +296,8 @@
// ---------------------------------------------------------------------------
//
CAknMemorySelectionSettingItemExtension::
- CAknMemorySelectionSettingItemExtension(CAknMemorySelectionSettingItemMultiDrive* aSettingItem)
+ CAknMemorySelectionSettingItemExtension(
+ CAknMemorySelectionSettingItemMultiDrive* aSettingItem )
: iSettingItem( aSettingItem )
{
}
@@ -276,16 +340,43 @@
// ---------------------------------------------------------------------------
// CAknMemorySelectionSettingItemExtension
+// ConstructDialogL
+// ---------------------------------------------------------------------------
+//
+void CAknMemorySelectionSettingItemExtension::ConstructDialogL(
+ TInt aIncludedMedias )
+ {
+ if ( iDialog )
+ {
+ delete iDialog;
+ iDialog = NULL;
+ }
+
+ iIncludedMedias = aIncludedMedias;
+
+ if ( aIncludedMedias == -1 )
+ {
+ iDialog = CAknMemorySelectionDialogMultiDrive::NewL(
+ ECFDDialogTypeNormal, ETrue );
+ }
+ else
+ {
+ iDialog = CAknMemorySelectionDialogMultiDrive::NewL(
+ ECFDDialogTypeNormal, 0, ETrue, aIncludedMedias );
+ }
+ }
+
+// ---------------------------------------------------------------------------
+// CAknMemorySelectionSettingItemExtension
// ConstructL
// ---------------------------------------------------------------------------
//
-void CAknMemorySelectionSettingItemExtension::ConstructL()
+void CAknMemorySelectionSettingItemExtension::ConstructL( TInt aIncludedMedias )
{
+ ConstructDialogL( aIncludedMedias );
- iDialog = CAknMemorySelectionDialogMultiDrive::NewL(
- ECFDDialogTypeNormal, ETrue);
-
- iFSEvent = CAknCFDFileSystemEvent::NewL(CCoeEnv::Static()->FsSession(), *this, ENotifyDisk);
+ iFSEvent = CAknCFDFileSystemEvent::NewL(
+ CCoeEnv::Static()->FsSession(), *this, ENotifyDisk );
}
// ---------------------------------------------------------------------------
@@ -293,13 +384,16 @@
// NewL
// ---------------------------------------------------------------------------
//
-CAknMemorySelectionSettingItemExtension* CAknMemorySelectionSettingItemExtension::NewL(CAknMemorySelectionSettingItemMultiDrive* aSettingItem)
+CAknMemorySelectionSettingItemExtension*
+ CAknMemorySelectionSettingItemExtension::NewL(
+ CAknMemorySelectionSettingItemMultiDrive* aSettingItem,
+ TInt aIncludedMedias )
{
CAknMemorySelectionSettingItemExtension* self =
- new( ELeave ) CAknMemorySelectionSettingItemExtension(aSettingItem);
+ new( ELeave ) CAknMemorySelectionSettingItemExtension( aSettingItem );
CleanupStack::PushL( self );
- self->ConstructL();
+ self->ConstructL( aIncludedMedias );
CleanupStack::Pop( self );
return self;