codhandler/codui/src/CodDialog.cpp
changeset 0 dd21522fd290
child 10 a359256acfc6
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2004 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 the License "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:  Implementation of class CodDialog.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <coemain.h>
       
    20 #include <AknNoteWrappers.h>
       
    21 #include <AknQueryDialog.h>
       
    22 #include <CAknMemorySelectionDialog.h>
       
    23 #include <CodUi.rsg>
       
    24 #include "CodDialog.h"
       
    25 #include "CodLogger.h"
       
    26 #include <pathinfo.h>
       
    27 #ifndef RD_MULTIPLE_DRIVE
       
    28 _LIT(KBackSlash,"\\");
       
    29 #endif
       
    30 
       
    31 #ifdef RD_MULTIPLE_DRIVE
       
    32 #include <driveinfo.h>
       
    33 #endif
       
    34 
       
    35 // CONSTANTS
       
    36 #ifdef RD_MULTIPLE_DRIVE
       
    37 const TInt KMaxDriveListStrLen = KMaxDrives << 1;
       
    38 _LIT( KDefaultDriveListSep, ";" );
       
    39 _LIT( KDefaultDriveList, "c;e" );
       
    40 #endif
       
    41 
       
    42 // ================= MEMBER FUNCTIONS =======================
       
    43 
       
    44 // ----------------------------------------------------------
       
    45 // CodDialog::GetRootPathL()
       
    46 // ----------------------------------------------------------
       
    47 //
       
    48 
       
    49 void CodDialog::GetRootPathL( TDes& aRootPath )
       
    50     {
       
    51     CLOG(( 2, _L("-> CodDialog::SelectDownloadLocationL") ));
       
    52     CRepository *repository = CRepository::NewLC(KCRUidBrowser);
       
    53 	aRootPath=KNullDesC;
       
    54 	RFs fs;
       
    55  	User::LeaveIfError(fs.Connect());
       
    56 
       
    57 #ifdef RD_MULTIPLE_DRIVE 
       
    58     TDriveList driveList;
       
    59     TInt driveCount( 0 );
       
    60     TChar driveLetter;
       
    61     TBuf8<KMaxDriveListStrLen> driveLettersDyn;
       
    62     TBuf<KMaxDrives> driveListCenRep;
       
    63 
       
    64     // Checking validity of drives in Cenrep List
       
    65     // drive letters are separated by semicolons
       
    66     // Destination is FFS in default
       
    67     TInt drive;
       
    68     User::LeaveIfError(
       
    69         DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory, drive ) );
       
    70 
       
    71 	if( repository->Get(KBrowserDrivePrefListForDownloadedContent, driveListCenRep) == KErrNone )
       
    72         {
       
    73         driveListCenRep.Copy( KDefaultDriveList );
       
    74         }
       
    75 
       
    76     // get the list of drives available in real time
       
    77     if ( DriveInfo::GetUserVisibleDrives( fs, driveList, driveCount ) == KErrNone )
       
    78         {
       
    79         if ( driveListCenRep.Length() > 0 )
       
    80             {
       
    81                 driveLettersDyn.Append( driveListCenRep );
       
    82                 if ( driveLettersDyn[driveLettersDyn.Length() - 1] != ';' )
       
    83                     {
       
    84                     driveLettersDyn.Append( KDefaultDriveListSep );
       
    85                     }
       
    86             }
       
    87         TInt count( driveList.Length() );
       
    88         for ( TInt i( 0 ); i < count; ++i )
       
    89             {
       
    90             if ( driveList[ i ] )
       
    91                 {
       
    92                 User::LeaveIfError( fs.DriveToChar( i, driveLetter) );
       
    93                 TInt drivePos = driveLettersDyn.LocateF( driveLetter );
       
    94                 if ( drivePos == KErrNotFound )
       
    95                     {
       
    96                     driveLettersDyn.Append( driveLetter ); 
       
    97                     driveLettersDyn.Append( KDefaultDriveListSep ); 
       
    98                     }
       
    99                 }
       
   100             }
       
   101         }
       
   102 	    TPtrC8 drives(driveLettersDyn);
       
   103 	    TInt err(KErrNone);
       
   104 	    for( TInt i = 0; i < drives.Length() && err; i = i + 2 )
       
   105 	        {
       
   106 	            err = fs.CharToDrive( drives[i], drive ); 
       
   107 	        }
       
   108         User::LeaveIfError( PathInfo::GetRootPath( aRootPath, drive ) );
       
   109 #else
       
   110 	TBuf<KMaxDrives> driveList;
       
   111 	TInt drive( EDriveC );
       
   112 
       
   113 	if( repository->Get(KBrowserDrivePrefListForDownloadedContent, driveList) == KErrNone )
       
   114         {
       
   115 	    TPtrC drives(driveList);
       
   116 	    TInt err(KErrNone);
       
   117 	    for( TInt i = 0; i < drives.Length(); i = i + 2 )
       
   118 	        {
       
   119 	            err = fs.CharToDrive( drives[i], drive );
       
   120 	            if (err == KErrNone)
       
   121 	            		break;	            
       
   122 	        }
       
   123 	    TDriveUnit driveUnit(drive);
       
   124 	    aRootPath = driveUnit.Name();
       
   125 	    aRootPath.Append(KBackSlash);
       
   126         }
       
   127 #endif
       
   128     fs.Close();
       
   129 	CleanupStack::PopAndDestroy(repository);   
       
   130     CLOG(( 2, _L("<- CodDialog::GetRootPathL <%S>"), &aRootPath ));
       
   131     }
       
   132 
       
   133 // ----------------------------------------------------------
       
   134 // CodDialog::ConfirmConnectL()
       
   135 // ----------------------------------------------------------
       
   136 //
       
   137 TBool CodDialog::ConfirmConnectL()
       
   138     {
       
   139     CLOG(( 2, _L("-> CodDialog::ConfirmConnectL") ));
       
   140     TBool ret( ETrue );
       
   141     // TODO
       
   142     CLOG(( 2, _L("<- CodDialog::ConfirmConnectL(%d)"), ret ));
       
   143     return ret;
       
   144     }
       
   145 
       
   146 // ----------------------------------------------------------
       
   147 // CodDialog::InfoNoteL()
       
   148 // ----------------------------------------------------------
       
   149 //
       
   150 void CodDialog::InfoNoteL( TInt aPromptResourceId, CCoeEnv& aCoeEnv )
       
   151     {
       
   152     HBufC* prompt = aCoeEnv.AllocReadResourceLC( aPromptResourceId );
       
   153     CAknInformationNote* note = new (ELeave) CAknInformationNote();
       
   154     note->ExecuteLD( *prompt );
       
   155     CleanupStack::PopAndDestroy( prompt );
       
   156     }
       
   157 
       
   158 // ----------------------------------------------------------
       
   159 // CodDialog::InfoNoteL()
       
   160 // ----------------------------------------------------------
       
   161 //
       
   162 void CodDialog::InfoNoteL( const TDesC& aPrompt )
       
   163     {
       
   164     CAknInformationNote* note = new (ELeave) CAknInformationNote( ETrue );
       
   165     note->ExecuteLD( aPrompt );
       
   166     }
       
   167 
       
   168 // ----------------------------------------------------------
       
   169 // CodDialog::ConfNoteL()
       
   170 // ----------------------------------------------------------
       
   171 //
       
   172 void CodDialog::ConfNoteL( TInt aPromptResourceId, CCoeEnv& aCoeEnv )
       
   173     {
       
   174     HBufC* prompt = aCoeEnv.AllocReadResourceLC( aPromptResourceId );
       
   175     CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote( ETrue );
       
   176     note->ExecuteLD( *prompt );
       
   177     CleanupStack::PopAndDestroy( prompt );
       
   178     }
       
   179 
       
   180 // ----------------------------------------------------------
       
   181 // CodDialog::ConfNoteL()
       
   182 // ----------------------------------------------------------
       
   183 //
       
   184 void CodDialog::ConfNoteL( const TDesC& aPrompt )
       
   185     {
       
   186     CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote( ETrue );
       
   187     note->ExecuteLD( aPrompt );
       
   188     }