commonuis/CommonDialogs/src/AknCommonDialogsDynMem.cpp
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002-2008 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 #include <coemain.h>
       
    20 #include <featmgr.h>
       
    21 #include <driveinfo.h>
       
    22 #include <pathinfo.h>
       
    23 #include <commondialogs.rsg>
       
    24 
       
    25 #include "AknCommonDialogsDynMem.h"
       
    26 #include "CAknMemorySelectionDialog.h"
       
    27 #include "CAknMemorySelectionDialogMultiDrive.h"
       
    28 #include "CAknFileSelectionDialog.h"
       
    29 #include "CAknFileNamePromptDialog.h"
       
    30 #include "AknCFDUtility.h"
       
    31 #include "CCFDCustomFilter.h"
       
    32 
       
    33 // ============================ MEMBER FUNCTIONS ===============================
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // AknCommonDialogsDynMem::RunSelectDlgLD
       
    37 //
       
    38 //
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 EXPORT_C TBool AknCommonDialogsDynMem::RunSelectDlgLD(
       
    42     TInt aIncludedMedias,
       
    43     TDes& aFileName,
       
    44     TInt aMemorySelectionResourceId,
       
    45     MAknFileSelectionObserver* aObserver )
       
    46     {
       
    47     return RunL( ECFDDialogTypeSelect, aFileName,
       
    48         aMemorySelectionResourceId, EFalse, 0, 0,
       
    49         KNullDesC, KNullDesC,
       
    50         NULL, NULL, aObserver, NULL, KNullDesC,
       
    51         aIncludedMedias );
       
    52     }
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // AknCommonDialogsDynMem::RunSelectDlgLD
       
    56 //
       
    57 //
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 EXPORT_C TBool AknCommonDialogsDynMem::RunSelectDlgLD(
       
    61     TInt aIncludedMedias,
       
    62     TDes& aFileName,
       
    63     TInt aMemorySelectionResourceId,
       
    64     MAknFileFilter* aFilter,
       
    65     MAknFileSelectionObserver* aObserver )
       
    66     {
       
    67     return RunL( ECFDDialogTypeSelect, aFileName,
       
    68         aMemorySelectionResourceId, EFalse, 0, 0,
       
    69         KNullDesC, KNullDesC,
       
    70         aFilter, NULL, aObserver, NULL, KNullDesC,
       
    71         aIncludedMedias );
       
    72     }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // AknCommonDialogsDynMem::RunSelectDlgLD
       
    76 //
       
    77 //
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 EXPORT_C TBool AknCommonDialogsDynMem::RunSelectDlgLD(
       
    81     TInt aIncludedMedias,
       
    82     TDes& aFileName,
       
    83     TInt aMemorySelectionResourceId,
       
    84     const TDesC& aFileSelectionTitle,
       
    85     MAknFileSelectionObserver* aObserver )
       
    86     {
       
    87     return RunL( ECFDDialogTypeSelect, aFileName,
       
    88         aMemorySelectionResourceId, EFalse, 0, 0,
       
    89         aFileSelectionTitle, KNullDesC,
       
    90         NULL, NULL, aObserver, NULL, KNullDesC,
       
    91         aIncludedMedias );
       
    92     }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // AknCommonDialogsDynMem::RunSelectDlgLD
       
    96 //
       
    97 //
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 EXPORT_C TBool AknCommonDialogsDynMem::RunSelectDlgLD(
       
   101     TInt aIncludedMedias,
       
   102     TDes& aFileName,
       
   103     TInt aMemorySelectionResourceId,
       
   104     TInt aFileSelectionResourceId,
       
   105     MAknFileSelectionObserver* aObserver )
       
   106     {
       
   107     return RunL( ECFDDialogTypeSelect, aFileName,
       
   108         aMemorySelectionResourceId, EFalse, aFileSelectionResourceId, 0,
       
   109         KNullDesC, KNullDesC,
       
   110         NULL, NULL, aObserver, NULL, KNullDesC,
       
   111         aIncludedMedias );
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // AknCommonDialogsDynMem::RunMoveDlgLD
       
   116 //
       
   117 //
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 EXPORT_C TBool AknCommonDialogsDynMem::RunMoveDlgLD(
       
   121     TInt aIncludedMedias,
       
   122     TDes& aDirectory,
       
   123     TInt aMemorySelectionResourceId,
       
   124     MAknFileSelectionObserver* aObserver )
       
   125     {
       
   126     return RunL( ECFDDialogTypeMove, aDirectory,
       
   127         aMemorySelectionResourceId, EFalse, 0, 0,
       
   128         KNullDesC, KNullDesC,
       
   129         NULL, NULL, aObserver, NULL, KNullDesC,
       
   130         aIncludedMedias );
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // AknCommonDialogsDynMem::RunMoveDlgLD
       
   135 //
       
   136 //
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 EXPORT_C TBool AknCommonDialogsDynMem::RunMoveDlgLD(
       
   140     TInt aIncludedMedias,
       
   141     TDes& aDirectory,
       
   142     TInt aMemorySelectionResourceId,
       
   143     MAknFileFilter* aFilter,
       
   144     MAknFileSelectionObserver* aObserver )
       
   145     {
       
   146     return RunL( ECFDDialogTypeMove, aDirectory,
       
   147         aMemorySelectionResourceId, EFalse, 0, 0,
       
   148         KNullDesC, KNullDesC,
       
   149         aFilter, NULL, aObserver, NULL, KNullDesC,
       
   150         aIncludedMedias );
       
   151     }
       
   152 
       
   153 // -----------------------------------------------------------------------------
       
   154 // AknCommonDialogsDynMem::RunMoveDlgLD
       
   155 //
       
   156 //
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 EXPORT_C TBool AknCommonDialogsDynMem::RunMoveDlgLD(
       
   160     TInt aIncludedMedias,
       
   161     TDes& aDirectory,
       
   162     TInt aMemorySelectionResourceId,
       
   163     const TDesC& aFileSelectionTitle,
       
   164     MAknFileSelectionObserver* aObserver )
       
   165     {
       
   166     return RunL( ECFDDialogTypeMove, aDirectory,
       
   167         aMemorySelectionResourceId, EFalse, 0, 0,
       
   168         aFileSelectionTitle, KNullDesC,
       
   169         NULL, NULL, aObserver, NULL, KNullDesC,
       
   170         aIncludedMedias );
       
   171     }
       
   172 
       
   173 // -----------------------------------------------------------------------------
       
   174 // AknCommonDialogsDynMem::RunMoveDlgLD
       
   175 //
       
   176 //
       
   177 // -----------------------------------------------------------------------------
       
   178 //
       
   179 EXPORT_C TBool AknCommonDialogsDynMem::RunMoveDlgLD(
       
   180     TInt aIncludedMedias,
       
   181     TDes& aDirectory,
       
   182     TInt aMemorySelectionResourceId,
       
   183     TInt aFileSelectionResourceId,
       
   184     MAknFileSelectionObserver* aObserver )
       
   185     {
       
   186     return RunL( ECFDDialogTypeMove, aDirectory,
       
   187         aMemorySelectionResourceId, EFalse, aFileSelectionResourceId, 0,
       
   188         KNullDesC, KNullDesC,
       
   189         NULL, NULL, aObserver, NULL, KNullDesC,
       
   190         aIncludedMedias);
       
   191     }
       
   192 
       
   193 // -----------------------------------------------------------------------------
       
   194 // AknCommonDialogsDynMem::RunSaveDlgLD
       
   195 //
       
   196 //
       
   197 // -----------------------------------------------------------------------------
       
   198 //
       
   199 EXPORT_C TBool AknCommonDialogsDynMem::RunSaveDlgLD(
       
   200     TInt aIncludedMedias,
       
   201     TDes& aDefaultFileName,
       
   202     TInt aMemorySelectionResourceId,
       
   203     MAknFileSelectionObserver* aObserver )
       
   204     {
       
   205     return RunL( ECFDDialogTypeSave, aDefaultFileName,
       
   206         aMemorySelectionResourceId, EFalse, 0, 0,
       
   207         KNullDesC, KNullDesC,
       
   208         NULL, NULL, NULL, aObserver, KNullDesC,
       
   209         aIncludedMedias );
       
   210     }
       
   211 
       
   212 // -----------------------------------------------------------------------------
       
   213 // AknCommonDialogsDynMem::RunSaveDlgLD
       
   214 //
       
   215 //
       
   216 // -----------------------------------------------------------------------------
       
   217 //
       
   218 EXPORT_C TBool AknCommonDialogsDynMem::RunSaveDlgLD(
       
   219     TInt aIncludedMedias,
       
   220     TDes& aDefaultFileName,
       
   221     TInt aMemorySelectionResourceId,
       
   222     MAknFileFilter* aFilter,
       
   223     MAknFileSelectionObserver* aObserver )
       
   224     {
       
   225     return RunL( ECFDDialogTypeSave, aDefaultFileName,
       
   226         aMemorySelectionResourceId, EFalse, 0, 0,
       
   227         KNullDesC, KNullDesC,
       
   228         aFilter, NULL, NULL, aObserver, KNullDesC,
       
   229         aIncludedMedias );
       
   230     }
       
   231 
       
   232 // -----------------------------------------------------------------------------
       
   233 // AknCommonDialogsDynMem::RunSaveDlgLD
       
   234 //
       
   235 //
       
   236 // -----------------------------------------------------------------------------
       
   237 //
       
   238 EXPORT_C TBool AknCommonDialogsDynMem::RunSaveDlgLD(
       
   239     TInt aIncludedMedias,
       
   240     TDes& aDefaultFileName,
       
   241     TInt aMemorySelectionResourceId,
       
   242     const TDesC& aFileSelectionTitle,
       
   243     const TDesC& aFileNamePromptTitle,
       
   244     MAknFileSelectionObserver* aObserver )
       
   245     {
       
   246     return RunL( ECFDDialogTypeSave, aDefaultFileName,
       
   247         aMemorySelectionResourceId, EFalse, 0, 0,
       
   248         aFileSelectionTitle, aFileNamePromptTitle,
       
   249         NULL, NULL, NULL, aObserver, KNullDesC,
       
   250         aIncludedMedias );
       
   251     }
       
   252 
       
   253 // -----------------------------------------------------------------------------
       
   254 // AknCommonDialogsDynMem::RunSaveDlgLD
       
   255 //
       
   256 //
       
   257 // -----------------------------------------------------------------------------
       
   258 //
       
   259 EXPORT_C TBool AknCommonDialogsDynMem::RunSaveDlgLD(
       
   260     TInt aIncludedMedias,
       
   261     TDes& aDefaultFileName,
       
   262     TInt aMemorySelectionResourceId,
       
   263     TInt aFileSelectionResourceId,
       
   264     MAknFileSelectionObserver* aObserver )
       
   265     {
       
   266     return RunL( ECFDDialogTypeSave, aDefaultFileName,
       
   267         aMemorySelectionResourceId, EFalse, aFileSelectionResourceId, 0,
       
   268         KNullDesC, KNullDesC,
       
   269         NULL, NULL, NULL, aObserver, KNullDesC,
       
   270         aIncludedMedias );
       
   271     }
       
   272 
       
   273 // -----------------------------------------------------------------------------
       
   274 // AknCommonDialogsDynMem::RunSaveDlgLD
       
   275 //
       
   276 //
       
   277 // -----------------------------------------------------------------------------
       
   278 //
       
   279 EXPORT_C TBool AknCommonDialogsDynMem::RunSaveDlgLD(
       
   280     TInt aIncludedMedias,
       
   281     TDes& aDefaultFileName,
       
   282     TInt aMemorySelectionResourceId,
       
   283     TInt aFileSelectionResourceId,
       
   284     const TDesC& aFileNamePromptTitle,
       
   285     MAknFileSelectionObserver* aObserver )
       
   286     {
       
   287     return RunL( ECFDDialogTypeSave, aDefaultFileName,
       
   288         aMemorySelectionResourceId, EFalse, aFileSelectionResourceId, 0,
       
   289         KNullDesC, aFileNamePromptTitle,
       
   290         NULL, NULL, NULL, aObserver, KNullDesC,
       
   291         aIncludedMedias );
       
   292     }
       
   293 
       
   294 // -----------------------------------------------------------------------------
       
   295 // AknCommonDialogsDynMem::RunSaveDlgLD
       
   296 //
       
   297 //
       
   298 // -----------------------------------------------------------------------------
       
   299 //
       
   300 EXPORT_C TBool AknCommonDialogsDynMem::RunSaveDlgNoDirectorySelectionLD(
       
   301     TInt aIncludedMedias,
       
   302     TDes& aDefaultFileName,
       
   303     TInt aMemorySelectionResourceId,
       
   304     MAknFileSelectionObserver* aObserver )
       
   305     {
       
   306     return RunL( ECFDDialogTypeSave, aDefaultFileName,
       
   307         aMemorySelectionResourceId, ETrue, 0, 0,
       
   308         KNullDesC, KNullDesC,
       
   309         NULL, NULL, NULL, aObserver, KNullDesC,
       
   310         aIncludedMedias );
       
   311     }
       
   312 
       
   313 // -----------------------------------------------------------------------------
       
   314 // AknCommonDialogsDynMem::RunSaveDlgLD
       
   315 //
       
   316 //
       
   317 // -----------------------------------------------------------------------------
       
   318 //
       
   319 EXPORT_C TBool AknCommonDialogsDynMem::RunSaveDlgNoDirectorySelectionLD(
       
   320     TInt aIncludedMedias,
       
   321     TDes& aDefaultFileName,
       
   322     TInt aMemorySelectionResourceId,
       
   323     const TDesC& aFileNamePromptTitle,
       
   324     MAknFileSelectionObserver* aObserver )
       
   325     {
       
   326     return RunL( ECFDDialogTypeSave, aDefaultFileName,
       
   327         aMemorySelectionResourceId, ETrue, 0, 0,
       
   328         KNullDesC, aFileNamePromptTitle,
       
   329         NULL, NULL, NULL, aObserver, KNullDesC,
       
   330         aIncludedMedias );
       
   331     }
       
   332 
       
   333 // -----------------------------------------------------------------------------
       
   334 // AknCommonDialogsDynMem::RunCopyDlgLD
       
   335 //
       
   336 //
       
   337 // -----------------------------------------------------------------------------
       
   338 //
       
   339 EXPORT_C TBool AknCommonDialogsDynMem::RunCopyDlgLD(
       
   340     TInt aIncludedMedias,
       
   341     TDes& aDirectory,
       
   342     TInt aMemorySelectionResourceId,
       
   343     MAknFileSelectionObserver* aObserver )
       
   344     {
       
   345     return RunL( ECFDDialogTypeCopy, aDirectory,
       
   346         aMemorySelectionResourceId, EFalse, 0, 0,
       
   347         KNullDesC, KNullDesC,
       
   348         NULL, NULL, aObserver, NULL, KNullDesC,
       
   349         aIncludedMedias );
       
   350     }
       
   351 
       
   352 
       
   353 // -----------------------------------------------------------------------------
       
   354 // AknCommonDialogsDynMem::RunCopyDlgLD
       
   355 //
       
   356 //
       
   357 // -----------------------------------------------------------------------------
       
   358 //
       
   359 EXPORT_C TBool AknCommonDialogsDynMem::RunCopyDlgLD(
       
   360     TInt aIncludedMedias,
       
   361     TDes& aDirectory,
       
   362     TInt aMemorySelectionResourceId,
       
   363     MAknFileFilter* aFilter,
       
   364     MAknFileSelectionObserver* aObserver )
       
   365     {
       
   366     return RunL( ECFDDialogTypeCopy, aDirectory,
       
   367         aMemorySelectionResourceId, EFalse, 0, 0,
       
   368         KNullDesC, KNullDesC,
       
   369         aFilter, NULL, aObserver, NULL, KNullDesC,
       
   370         aIncludedMedias );
       
   371     }
       
   372 
       
   373 // -----------------------------------------------------------------------------
       
   374 // AknCommonDialogsDynMem::RunCopyDlgLD
       
   375 //
       
   376 //
       
   377 // -----------------------------------------------------------------------------
       
   378 //
       
   379 EXPORT_C TBool AknCommonDialogsDynMem::RunCopyDlgLD(
       
   380     TInt aIncludedMedias,
       
   381     TDes& aDirectory,
       
   382     TInt aMemorySelectionResourceId,
       
   383     TInt aFileSelectionResourceId,
       
   384     MAknFileSelectionObserver* aObserver )
       
   385     {
       
   386     return RunL( ECFDDialogTypeCopy, aDirectory,
       
   387         aMemorySelectionResourceId, EFalse, aFileSelectionResourceId, 0,
       
   388         KNullDesC, KNullDesC,
       
   389         NULL, NULL, aObserver, NULL, KNullDesC,
       
   390         aIncludedMedias );
       
   391     }
       
   392 
       
   393 // -----------------------------------------------------------------------------
       
   394 // AknCommonDialogsDynMem::RunSelectDlgLD
       
   395 //
       
   396 //
       
   397 // -----------------------------------------------------------------------------
       
   398 //
       
   399 EXPORT_C TBool AknCommonDialogsDynMem::RunSelectDlgLD(
       
   400     TInt aIncludedMedias,
       
   401     TDes& aFileName,
       
   402     const TDesC& aStartFolder,
       
   403     TInt aMemorySelectionResourceId,
       
   404     MAknFileSelectionObserver* aObserver )
       
   405     {
       
   406     return RunL( ECFDDialogTypeSelect, aFileName,
       
   407         aMemorySelectionResourceId, EFalse, 0, 0,
       
   408         KNullDesC, KNullDesC,
       
   409         NULL, NULL, aObserver, NULL, aStartFolder,
       
   410         aIncludedMedias );
       
   411     }
       
   412 
       
   413 // -----------------------------------------------------------------------------
       
   414 // AknCommonDialogsDynMem::RunSelectDlgLD
       
   415 //
       
   416 //
       
   417 // -----------------------------------------------------------------------------
       
   418 //
       
   419 EXPORT_C TBool AknCommonDialogsDynMem::RunSelectDlgLD(
       
   420     TInt aIncludedMedias,
       
   421     TDes& aFileName,
       
   422     const TDesC& aStartFolder,
       
   423     TInt aMemorySelectionResourceId,
       
   424     MAknFileFilter* aFilter,
       
   425     MAknFileSelectionObserver* aObserver )
       
   426     {
       
   427 
       
   428     return RunL( ECFDDialogTypeSelect, aFileName,
       
   429         aMemorySelectionResourceId, EFalse, 0, 0,
       
   430         KNullDesC, KNullDesC,
       
   431         aFilter, NULL, aObserver, NULL, aStartFolder,
       
   432         aIncludedMedias );
       
   433     }
       
   434 
       
   435 // -----------------------------------------------------------------------------
       
   436 // AknCommonDialogsDynMem::RunSelectDlgLD
       
   437 //
       
   438 //
       
   439 // -----------------------------------------------------------------------------
       
   440 //
       
   441 EXPORT_C TBool AknCommonDialogsDynMem::RunSelectDlgLD(
       
   442     TInt aIncludedMedias,
       
   443     TDes& aFileName,
       
   444     const TDesC& aStartFolder,
       
   445     TInt aMemorySelectionResourceId,
       
   446     const TDesC& aFileSelectionTitle,
       
   447     MAknFileSelectionObserver* aObserver )
       
   448     {
       
   449 
       
   450     return RunL( ECFDDialogTypeSelect, aFileName,
       
   451         aMemorySelectionResourceId, EFalse, 0, 0,
       
   452         aFileSelectionTitle, KNullDesC,
       
   453         NULL, NULL, aObserver, NULL, aStartFolder,
       
   454         aIncludedMedias );
       
   455     }
       
   456 
       
   457 // -----------------------------------------------------------------------------
       
   458 // AknCommonDialogsDynMem::RunSelectDlgLD
       
   459 //
       
   460 //
       
   461 // -----------------------------------------------------------------------------
       
   462 //
       
   463 EXPORT_C TBool AknCommonDialogsDynMem::RunSelectDlgLD(
       
   464     TInt aIncludedMedias,
       
   465     TDes& aFileName,
       
   466     const TDesC& aStartFolder,
       
   467     TInt aMemorySelectionResourceId,
       
   468     TInt aFileSelectionResourceId,
       
   469     MAknFileSelectionObserver* aObserver )
       
   470     {
       
   471     return RunL( ECFDDialogTypeSelect, aFileName,
       
   472         aMemorySelectionResourceId, EFalse, aFileSelectionResourceId, 0,
       
   473         KNullDesC, KNullDesC,
       
   474         NULL, NULL, aObserver, NULL, aStartFolder,
       
   475         aIncludedMedias );
       
   476     }
       
   477 // -----------------------------------------------------------------------------
       
   478 // AknCommonDialogsDynMem::RunSelectDlgLD
       
   479 //
       
   480 //
       
   481 // -----------------------------------------------------------------------------
       
   482 //
       
   483 EXPORT_C TBool AknCommonDialogsDynMem::RunSelectDlgLD(
       
   484     TInt aIncludedMedias,
       
   485     TDes& aFileName,
       
   486     const TDesC& aStartFolder,
       
   487     TInt aMemorySelectionResourceId,
       
   488     TInt aFileSelectionResourceId,
       
   489     const TDesC& aFileSelectionTitle,
       
   490     MAknFileFilter* aFilter,
       
   491     MAknFileSelectionObserver* aObserver )
       
   492     {
       
   493     return RunL( ECFDDialogTypeSelect, aFileName,
       
   494         aMemorySelectionResourceId, EFalse, aFileSelectionResourceId, 0,
       
   495         aFileSelectionTitle, KNullDesC,
       
   496         aFilter, NULL, aObserver, NULL, aStartFolder,
       
   497         aIncludedMedias );
       
   498     }
       
   499 
       
   500 // -----------------------------------------------------------------------------
       
   501 // AknCommonDialogsDynMem::RunSaveDlgLD
       
   502 //
       
   503 //
       
   504 // -----------------------------------------------------------------------------
       
   505 //
       
   506 EXPORT_C TBool AknCommonDialogsDynMem::RunSaveDlgLD(
       
   507     TInt aIncludedMedias,
       
   508     TDes& aDefaultFileName,
       
   509     const TDesC& aStartFolder,
       
   510     TInt aMemorySelectionResourceId,
       
   511     TInt aFileSelectionResourceId,
       
   512     const TDesC& aFileSelectionTitle,
       
   513     MAknFileFilter* aFilter,
       
   514     MAknFileSelectionObserver* aObserver )
       
   515     {
       
   516     return RunL( ECFDDialogTypeSave, aDefaultFileName,
       
   517         aMemorySelectionResourceId, EFalse, aFileSelectionResourceId, 0,
       
   518         aFileSelectionTitle, KNullDesC,
       
   519         aFilter, NULL, aObserver, NULL, aStartFolder,
       
   520         aIncludedMedias );
       
   521     }
       
   522 
       
   523 // -----------------------------------------------------------------------------
       
   524 // AknCommonDialogsDynMem::RunFolderSelectDlgLD
       
   525 //
       
   526 //
       
   527 // -----------------------------------------------------------------------------
       
   528 //
       
   529 EXPORT_C TBool AknCommonDialogsDynMem::RunFolderSelectDlgLD(
       
   530     TInt aIncludedMedias,
       
   531     TDes& aFolder,
       
   532     const TDesC& aStartFolder,
       
   533     TInt aMemorySelectionResourceId,
       
   534     TInt aFileSelectionResourceId,
       
   535     const TDesC& aFileSelectionTitle,
       
   536     MAknFileFilter* aFilter,
       
   537     MAknFileSelectionObserver* aObserver )
       
   538     {
       
   539     return RunL( ECFDDialogTypeBrowse, aFolder,
       
   540         aMemorySelectionResourceId, EFalse, aFileSelectionResourceId, 0,
       
   541         aFileSelectionTitle, KNullDesC,
       
   542         aFilter, NULL, aObserver, NULL, aStartFolder,
       
   543         aIncludedMedias );
       
   544     }
       
   545 
       
   546 // -----------------------------------------------------------------------------
       
   547 // AknCommonDialogsDynMem::RunL
       
   548 //
       
   549 //
       
   550 // -----------------------------------------------------------------------------
       
   551 //
       
   552 TBool AknCommonDialogsDynMem::RunL(
       
   553     TCommonDialogType aDialogType,
       
   554     TDes& aFileName,
       
   555     TInt aMemorySelectionResourceId,
       
   556     TBool aNoFileSelectionDialog,
       
   557     TInt aFileSelectionResourceId,
       
   558     TInt aFileNamePromptResourceId,
       
   559     const TDesC& aFileSelectionTitle,
       
   560     const TDesC& aFileNamePromptTitle,
       
   561     MAknFileFilter* aFileFilter,
       
   562     MAknMemorySelectionObserver* /*aMemorySelectionObserver*/,
       
   563     MAknFileSelectionObserver* aFileSelectionObserver,
       
   564     MAknFileSelectionObserver* aFileNamePromptObserver,
       
   565     const TDesC& aStartFolder,
       
   566     TInt aIncludedMedias )
       
   567     {
       
   568 
       
   569     FeatureManager::InitializeLibL();
       
   570     TBool mmcSupported( FeatureManager::FeatureSupported( KFeatureIdMmc ) );
       
   571     FeatureManager::UnInitializeLib();
       
   572     CCoeEnv* coeEnv = CCoeEnv::Static();
       
   573 
       
   574     // Temp variables
       
   575     HBufC* rootPath         = HBufC::NewLC(KMaxPath);
       
   576     HBufC* defaultFolder    = HBufC::NewLC(KMaxPath);
       
   577     HBufC* cachedRootPath   = HBufC::NewLC(KMaxPath);
       
   578 
       
   579     TPtr ptrRootPath = rootPath->Des();
       
   580     TPtr ptrDefaultFolder = defaultFolder->Des();
       
   581     TPtr ptrCachedRootPath = cachedRootPath->Des();
       
   582 
       
   583     TDriveNumber defaultDrive;
       
   584     User::LeaveIfError(
       
   585         DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem,
       
   586                                     ( TInt& )defaultDrive ) );
       
   587     TDriveNumber selectedDrive( defaultDrive );
       
   588 
       
   589     // Variables for return values from dialogs
       
   590     TBool memoryReturnValue(    EFalse );
       
   591     TBool fileReturnValue(      EFalse );
       
   592     TBool promptReturnValue(    EFalse );
       
   593 
       
   594     // These booleans tell what dialogs have been shown
       
   595     TBool usedMemorySelection(  EFalse );
       
   596     TBool usedFileSelection(    EFalse );
       
   597     TBool usedFileNamePrompt(   EFalse );
       
   598 
       
   599     // Variable to handle start folder, if client gives a specific folder to
       
   600     // start browsing in file selecting
       
   601     HBufC * startFolder = aStartFolder.AllocLC();
       
   602     TPtr ptrStartFolder = startFolder->Des();
       
   603 
       
   604     TDriveNumber defaultMMC;
       
   605     User::LeaveIfError(
       
   606         DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage,
       
   607                                     ( TInt& )defaultMMC ) );
       
   608     TCFDDriveStatus driveStatus( EDriveOK );
       
   609 
       
   610     // Start a FOREVER loop in order to show memory selection dialog again if
       
   611     // user hits back in file selection
       
   612     FOREVER
       
   613         {
       
   614         // Reset variables
       
   615         *rootPath = KNullDesC;
       
   616         *defaultFolder = KNullDesC;
       
   617         fileReturnValue = ETrue;
       
   618         promptReturnValue = ETrue;
       
   619         memoryReturnValue = EFalse;
       
   620 
       
   621         ptrRootPath = rootPath->Des();
       
   622         ptrDefaultFolder = defaultFolder->Des();
       
   623 
       
   624         if ( mmcSupported )
       
   625             {
       
   626             driveStatus = AknCFDUtility::DriveStatusL( defaultMMC );
       
   627             }
       
   628 
       
   629         // Start folder is not defined so ask for it. Normal situation, or
       
   630         // second round with user given starting folder.
       
   631         if ( ptrStartFolder == KNullDesC )
       
   632             {
       
   633             // Run MEMORY SELECTION DIALOG
       
   634            CAknMemorySelectionDialogMultiDrive* memoryDialogMD =
       
   635                 CAknMemorySelectionDialogMultiDrive::NewL(
       
   636                     aDialogType,
       
   637                     aMemorySelectionResourceId,
       
   638                     EFalse,
       
   639                     aIncludedMedias
       
   640                     ); 
       
   641            CleanupStack::PushL( memoryDialogMD );
       
   642 
       
   643             // Check if there ame multiple drives in which case use memory
       
   644             // selection instead of file selection.
       
   645             if( usedMemorySelection ||
       
   646                 AknCFDUtility::UserVisibleDriveCountL( aIncludedMedias ) > 1 )
       
   647                 {
       
   648                 // Multiple drives: Execute memory selection
       
   649                 memoryReturnValue = memoryDialogMD->ExecuteL( selectedDrive,
       
   650                     &ptrRootPath, &ptrDefaultFolder );
       
   651                 usedMemorySelection = ETrue; // Memory selection was used
       
   652                 CleanupStack::PopAndDestroy();// memoryDialog or memoryDialogMD
       
   653                 if ( !memoryReturnValue )
       
   654                     {
       
   655                     // User cancels memory selection
       
   656                     CleanupStack::PopAndDestroy(startFolder);
       
   657                     CleanupStack::PopAndDestroy(cachedRootPath);
       
   658                     CleanupStack::PopAndDestroy(defaultFolder);
       
   659                     CleanupStack::PopAndDestroy(rootPath);
       
   660                     return EFalse;
       
   661                     }
       
   662                 }
       
   663              else
       
   664                 {
       
   665                 // Only one drive - get it's paths. EPhoneMemory is legacy.
       
   666                 // Functionally it points to index 0 of stored paths array, not
       
   667                 // necessarily the drive of the phone memory.
       
   668 
       
   669                 // The above is only valid for legacy code (even remote drive is
       
   670                 // used). For multiple drive support, default system drive
       
   671                 // should be more reasonable to be used in this case.
       
   672                 memoryDialogMD->GetDrivePaths(
       
   673                     defaultDrive,
       
   674                     &ptrRootPath,
       
   675                     &ptrDefaultFolder
       
   676                     );
       
   677                 CleanupStack::PopAndDestroy();// memoryDialog or memoryDialogMD
       
   678                 }
       
   679             }
       
   680         else // User gave a specific folder to start browsing
       
   681             {
       
   682             ptrDefaultFolder = ptrStartFolder;
       
   683             AknCFDUtility::AddTrailingBackslash(ptrDefaultFolder);
       
   684             TDriveNumber driveNumber = ( TDriveNumber )
       
   685                 AknCFDUtility::DriveNumber( ptrDefaultFolder );
       
   686 
       
   687             // Different logic should be used here.
       
   688             // Not only C & E drives need to be checked now. And the new method
       
   689             // PathInfo::GetRootPath could be used to get each drive's root
       
   690             // path. The specific folder user gave should be in drive's root
       
   691             // path. So generic check is launched here.
       
   692             PathInfo::GetRootPath( ptrRootPath, driveNumber );
       
   693 
       
   694             if ( ptrDefaultFolder.Length() )
       
   695                 {
       
   696                 if ( ptrDefaultFolder.Left( ptrRootPath.Length() ).CompareF(
       
   697                      ptrRootPath ) )
       
   698                     {
       
   699                     User::Leave( KErrPathNotFound );
       
   700                     }
       
   701                 else
       
   702                     {
       
   703                     ptrDefaultFolder = ptrDefaultFolder.Right(
       
   704                         ptrDefaultFolder.Length() - ptrRootPath.Length() );
       
   705                     }
       
   706                 }
       
   707 
       
   708             // Use system default drive if current drive is not ready
       
   709             driveStatus = AknCFDUtility::DriveStatusL( driveNumber );
       
   710 
       
   711             if ( driveStatus == EDriveNotReady )
       
   712                 {
       
   713                 PathInfo::GetRootPath( ptrRootPath, defaultDrive );
       
   714                 ptrDefaultFolder = KNullDesC;
       
   715                 }
       
   716 
       
   717             ptrStartFolder = KNullDesC; // we use starting folder only once...
       
   718 
       
   719             usedMemorySelection =
       
   720                 ( AknCFDUtility::UserVisibleDriveCountL( aIncludedMedias ) > 1 );
       
   721             }
       
   722 
       
   723         ptrCachedRootPath = ptrRootPath;
       
   724 
       
   725         CAknFileSelectionDialog* fileDialog = NULL;
       
   726         // aNoFileSelectionDialog is ETrue only with save dialog when the
       
   727         // client does not want the file selection dialog to be launched:
       
   728         if( !aNoFileSelectionDialog )
       
   729             {
       
   730             fileDialog = CAknFileSelectionDialog::NewL( aDialogType,
       
   731                          aFileSelectionResourceId );
       
   732             CleanupStack::PushL( fileDialog );
       
   733             fileDialog->SetTitleL( aFileSelectionTitle );
       
   734             fileDialog->SetObserver( aFileSelectionObserver );
       
   735             if ( usedMemorySelection )
       
   736                 {
       
   737                 HBufC* text = coeEnv->AllocReadResourceLC(
       
   738                               R_CFD_TEXT_SOFTKEY_BACK );
       
   739                 fileDialog->SetRightSoftkeyRootFolderL( *text );
       
   740                 CleanupStack::PopAndDestroy(); // text
       
   741                 }
       
   742             fileDialog->SetDefaultFolderL( ptrDefaultFolder );
       
   743             if( aFileFilter )
       
   744                 {
       
   745                 CCFDCustomFilter* filter =
       
   746                     new( ELeave ) CCFDCustomFilter( aFileFilter );
       
   747                 CleanupStack::PushL( filter );
       
   748                 fileDialog->AddFilterL( filter ); // Ownership is transferred
       
   749                 CleanupStack::Pop(); // filter
       
   750                 }
       
   751             }
       
   752         else
       
   753             {
       
   754             ptrCachedRootPath.Append( ptrDefaultFolder );
       
   755             }
       
   756 
       
   757         // Start file selection ExecuteL loop (needed in save case)
       
   758         FOREVER
       
   759             {
       
   760             usedFileSelection = EFalse;
       
   761             usedFileNamePrompt = EFalse;
       
   762 
       
   763             // Root path must be always the root path which is read from
       
   764             // resource
       
   765             ptrRootPath = ptrCachedRootPath;
       
   766             if( fileDialog )
       
   767                 {
       
   768                 TRAPD( endKeyErr, fileReturnValue = fileDialog->ExecuteL( ptrRootPath ) );
       
   769                 if ( endKeyErr == KErrAbort )
       
   770                     {
       
   771                     CleanupStack::PopAndDestroy(); // fileDialog
       
   772                     CleanupStack::PopAndDestroy(4); //4 number of HBufC
       
   773                     return EFalse;
       
   774                     }
       
   775 
       
   776                 // If file selection dialog returns ESelectionKey, it means
       
   777                 // that browsing was not used. The directory was empty.
       
   778                 if ( fileReturnValue != CAknCommonDialogsBase::ESelectionKey )
       
   779                     {
       
   780                     usedFileSelection = ETrue;
       
   781                     }
       
   782 
       
   783                 // If the user cancels file selection and memory selection was
       
   784                 // not used, exit function
       
   785                 if ( ( !usedMemorySelection ) && ( !fileReturnValue ) )
       
   786                     {
       
   787                     CleanupStack::PopAndDestroy(); // fileDialog
       
   788                     CleanupStack::PopAndDestroy(4); //4 number of HBufC
       
   789                     return EFalse;
       
   790                     }
       
   791                 }
       
   792 
       
   793             // If dialog type is SAVE and user selected something or in the case
       
   794             // of save dialog, if the file selection was not used at all, show
       
   795             // Filename prompt dialog
       
   796             if ( ( ( aDialogType == ECFDDialogTypeSave )
       
   797                    && ( fileReturnValue ) ) || aNoFileSelectionDialog )
       
   798                 {
       
   799                 CAknFileNamePromptDialog* promptDialog =
       
   800                     CAknFileNamePromptDialog::NewL(
       
   801                     aFileNamePromptResourceId );
       
   802                 CleanupStack::PushL( promptDialog );
       
   803                 promptDialog->SetTitleL( aFileNamePromptTitle );
       
   804                 promptDialog->SetObserver( aFileNamePromptObserver );
       
   805                 promptDialog->SetPathL( ptrRootPath );
       
   806 
       
   807                 promptReturnValue = promptDialog->ExecuteL( aFileName );
       
   808                 CleanupStack::PopAndDestroy(); // promptDialog
       
   809                 usedFileNamePrompt = ETrue;
       
   810                 if ( promptReturnValue )
       
   811                     {
       
   812                     // User approved the filename.
       
   813                     // Exit loop
       
   814                     break;
       
   815                     }
       
   816                 else
       
   817                     {
       
   818                     // User cancelled the operation.
       
   819                     if ( fileDialog )
       
   820                         {
       
   821                         CleanupStack::PopAndDestroy(); // fileDialog
       
   822                         }
       
   823                     CleanupStack::PopAndDestroy(4); //4 number of HBufC
       
   824                     return EFalse;
       
   825                     }
       
   826                 }
       
   827             // Exit loop if filename prompt wasn't used
       
   828             if ( ( !usedFileNamePrompt ) || 
       
   829                 // Exit loop if file selection wasn't used but prompt was
       
   830                 ( usedFileNamePrompt && !usedFileSelection ) )
       
   831                 {
       
   832                 break;
       
   833                 }
       
   834             } // FOREVER
       
   835 
       
   836         if ( fileDialog )
       
   837             {
       
   838             CleanupStack::PopAndDestroy(); // fileDialog
       
   839             }
       
   840 
       
   841         if (  // If neither file selection or filename prompt was used, break
       
   842             ( !usedFileNamePrompt && !usedFileSelection ) ||
       
   843              // If filename prompt was used and selection was made, break
       
   844             ( usedFileNamePrompt && promptReturnValue ) ||
       
   845              // If only file selection was used and selection made, break
       
   846             ( usedFileSelection && !usedFileNamePrompt && fileReturnValue ) )
       
   847             {
       
   848             break;
       
   849             }
       
   850 
       
   851         } // FOREVER
       
   852 
       
   853     if ( aDialogType == ECFDDialogTypeSave )
       
   854         {
       
   855         // In the save case, append the typed file in the end of path
       
   856         // If not enough space in descriptor, let the system panic because
       
   857         // it's not reasonable to append a partial file name.
       
   858         ptrRootPath.Append( aFileName );
       
   859         }
       
   860 
       
   861     aFileName = ptrRootPath;
       
   862 
       
   863     CleanupStack::PopAndDestroy(4); //4 number of HBufC
       
   864 
       
   865     return ETrue;
       
   866     }
       
   867 
       
   868 
       
   869 //  End of File