browserutilities/browserdialogsprovider/Src/BrowserDialogsProvider.cpp
changeset 0 dd21522fd290
child 8 7c90e6132015
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2002 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 the CBrowserDialogsProvider class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE Files
       
    20 
       
    21 // User includes
       
    22 #include "BrowserDialogsProvider.h"	// Class header
       
    23 #include "BrowserDialogsProvider.hrh"
       
    24 #include "BrowserAuthenticationDialog.h"
       
    25 #include "BrowserDialogsProviderConstants.h"
       
    26 #include "BrowserDialogsProviderObserver.h" //obs
       
    27 
       
    28 // Browser as a Plugin - own classes
       
    29 #include "BrowserViewImagesPopup.h"		// For DialogDisplayPageImagesL
       
    30 #include "BrowserScriptPromptDialog.h"	// For DialogPromptLC
       
    31 #include "BrowserSelectElementDlg.h"	// For DialogFileSelectLC
       
    32 #include "BrowserUploadProgressNote.h"  // For UploadProgressNoteL
       
    33 
       
    34 // System Includes
       
    35 #include <aknLists.h>					// for Object Element Dialog
       
    36 #include <aknmessagequerydialog.h>		// DialogAlertL
       
    37 #include <CAknFileSelectionDialog.h>	// File Selection Dialog
       
    38 
       
    39 #ifdef RD_MULTIPLE_DRIVE
       
    40 #include <driveinfo.h>
       
    41 #include <CAknMemorySelectionDialogMultiDrive.h>
       
    42 #include <AknCommonDialogsDynMem.h>
       
    43 #else
       
    44 #include <CAknMemorySelectionDialog.h>
       
    45 #include <AknCommonDialogs.h>			// File Selection Dialog
       
    46 #endif
       
    47 
       
    48 #include <aknnotewrappers.h>			
       
    49 #include <AknInfoPopupNoteController.h> // tooltip
       
    50 #include <PathConfiguration.hrh>
       
    51 #include <FeatMgr.h>
       
    52 #include <MGFetch.h> // Media Fetch
       
    53 // General
       
    54 #include <StringLoader.h>				// strings
       
    55 #include <f32file.h>
       
    56 #include <THttpFields.h>
       
    57 
       
    58 // Resources
       
    59 #include <coneresloader.h>
       
    60 #include <BrowserDialogsProvider.rsg>
       
    61 #include <ErrorRes.rsg>
       
    62 
       
    63 // Data Caging
       
    64 #include <data_caging_path_literals.hrh>    
       
    65 
       
    66 // CONSTANTS
       
    67 const TInt KBrCtlObjectElementMaxLength = 50;
       
    68 const TInt KBrCtlMBFormat = 4;
       
    69 const TInt KBrCtlGBFormat = 10;
       
    70 const TInt KBrCtlMegabyte = 1000;	// although 1MB=1024 kB, treat as 1000kb for user simplicity
       
    71 
       
    72 // DLL resource file name with path
       
    73 _LIT( KBrowserDialogsProviderDirAndFile, "z:BrowserDialogsProvider.rsc" );// resource
       
    74 _LIT( KErrorResDirAndFile, "z:ErrorRes.rsc" );  // error resource
       
    75 
       
    76 //Mime Types
       
    77 _LIT( KMimeTypeImage, "image/*" );
       
    78 _LIT( KMimeTypeAudio, "audio/*" );
       
    79 _LIT( KMimeTypeVideo, "video/*" );
       
    80 
       
    81 // MACROS
       
    82 #define JAPANESE ( FeatureManager::FeatureSupported( KFeatureIdJapanese ) )
       
    83 
       
    84 
       
    85 //-----------------------------------------------------------------------------
       
    86 /*
       
    87 */
       
    88 //-----------------------------------------------------------------------------
       
    89 CBrowserDialogsProvider::CBrowserDialogsProvider( 
       
    90 								MBrowserDialogsProviderObserver* aObserver )
       
    91 :   iCoeEnv( *CCoeEnv::Static() ), 
       
    92     iObserver( aObserver ),
       
    93     iResourceLoader( iCoeEnv ),    
       
    94     iResourceOpened( EFalse ),    
       
    95     iErrResourceLoader( iCoeEnv ),    
       
    96     iErrResourceOpened( EFalse )    
       
    97 	{
       
    98 	}
       
    99 
       
   100 //-----------------------------------------------------------------------------
       
   101 //	CBrowserDialogsProvider* CBrowserDialogsProvider::NewL
       
   102 //
       
   103 //-----------------------------------------------------------------------------
       
   104 EXPORT_C CBrowserDialogsProvider* CBrowserDialogsProvider::NewL(
       
   105 								MBrowserDialogsProviderObserver* aObserver )
       
   106 	{
       
   107 	CBrowserDialogsProvider* self = 
       
   108 							new (ELeave) CBrowserDialogsProvider( aObserver );
       
   109 	CleanupStack::PushL( self );
       
   110 	self->ConstructL( );
       
   111 	CleanupStack::Pop( self );   // self
       
   112 	return self;
       
   113 	}
       
   114 
       
   115 //-----------------------------------------------------------------------------
       
   116 //  CBrowserDialogsProvider::ConstructL()
       
   117 //
       
   118 //-----------------------------------------------------------------------------
       
   119 void CBrowserDialogsProvider::ConstructL()
       
   120 	{
       
   121 	// Load resource file
       
   122 	AssureResourceL();
       
   123 	
       
   124 	// Tooltip
       
   125 	iTooltip = CAknInfoPopupNoteController::NewL();
       
   126 	}
       
   127 
       
   128 //-----------------------------------------------------------------------------
       
   129 //  CBrowserDialogsProvider::~CBrowserDialogsProvider()
       
   130 //
       
   131 //-----------------------------------------------------------------------------
       
   132 CBrowserDialogsProvider::~CBrowserDialogsProvider()
       
   133 	{
       
   134 	iResourceLoader.Close();
       
   135 	iErrResourceLoader.Close();
       
   136 
       
   137 	// Delete any dialogs
       
   138 	CancelAll();
       
   139 	
       
   140 	// Clean up tooltip
       
   141 	if ( iTooltip )
       
   142 	    {
       
   143 	    iTooltip->HideInfoPopupNote();
       
   144 	    }
       
   145 	delete iTooltip;
       
   146 	}
       
   147 
       
   148 //-----------------------------------------------------------------------------
       
   149 //  CBrowserDialogsProvider::DialogNotifyErrorL( TInt aErrCode )
       
   150 //
       
   151 //-----------------------------------------------------------------------------
       
   152 EXPORT_C void CBrowserDialogsProvider::DialogNotifyErrorL( TInt aErrCode )
       
   153 	{
       
   154     TInt httpErr = KBrCtlHttpErrorsOffset - aErrCode;
       
   155 
       
   156     switch ( httpErr )
       
   157         {
       
   158         case EHttpMultipleChoices: 
       
   159         case EHttpMovedPermanently:
       
   160         case EHttpMovedTemporarily:
       
   161         case EHttpTemporaryRedirect:
       
   162             {
       
   163             // Handle the redirect error dialog
       
   164             HBufC* msg = NULL;
       
   165             msg = StringLoader::LoadLC( R_NW_STAT_TOO_MANY_REDIRECTS );
       
   166             DialogNoteL( *msg );
       
   167     		CleanupStack::PopAndDestroy();	// msg
       
   168             break;
       
   169             }
       
   170         default:
       
   171             {
       
   172             // Handle all others as system error dialog
       
   173         	iCoeEnv.HandleError( aErrCode );
       
   174         	break;
       
   175             }
       
   176         }   // end of switch
       
   177 	
       
   178 	if ( iObserver )
       
   179     	{
       
   180     	iObserver->ReportDialogEventL( 
       
   181     	                            MBrowserDialogsProviderObserver::ENotifyError,
       
   182     	                            aErrCode );
       
   183         }
       
   184 	}
       
   185 
       
   186 
       
   187 //-----------------------------------------------------------------------------
       
   188 //  CBrowserDialogsProvider::DialogNotifyHttpErrorL(
       
   189 //								TInt aErrCode, const TDesC& /*aUri*/ )
       
   190 //-----------------------------------------------------------------------------
       
   191 EXPORT_C void CBrowserDialogsProvider::DialogNotifyHttpErrorL(
       
   192 								TInt aErrCode, const TDesC& /*aUri*/ )
       
   193 	{
       
   194     TInt httpErr = KBrCtlHttpErrorsOffset - aErrCode;
       
   195 
       
   196     switch ( httpErr )
       
   197         {
       
   198         case EHttpMultipleChoices: 
       
   199         case EHttpMovedPermanently:
       
   200         case EHttpMovedTemporarily:
       
   201         case EHttpTemporaryRedirect:
       
   202             {
       
   203             // Handle the redirect error dialog
       
   204             HBufC* msg = NULL;
       
   205             msg = StringLoader::LoadLC( R_NW_STAT_TOO_MANY_REDIRECTS );
       
   206             DialogNoteL( *msg );
       
   207     		CleanupStack::PopAndDestroy();	// msg
       
   208             break;
       
   209             }
       
   210         default:
       
   211             {
       
   212             // Handle all others as system error dialog
       
   213         	iCoeEnv.HandleError( aErrCode );
       
   214         	break;
       
   215             }
       
   216         }   // end of switch
       
   217 	
       
   218     if ( iObserver )
       
   219         {
       
   220         iObserver->ReportDialogEventL( 
       
   221                                 MBrowserDialogsProviderObserver::ENotifyHttpError,
       
   222                                 KBrCtlHttpErrorsOffset - aErrCode );
       
   223         }
       
   224 	}
       
   225 
       
   226 //CBrowserDialogsProvider::DialogFileSelectLC( 
       
   227 //                                              const TDesC& aStartPath,
       
   228 //												const TDesC& aRootPath,
       
   229 //												HBufC*& aSelectedFileName )
       
   230 //-----------------------------------------------------------------------------
       
   231 
       
   232 
       
   233 //-----------------------------------------------------------------------------
       
   234 
       
   235 //-----------------------------------------------------------------------------
       
   236 
       
   237 EXPORT_C TBool CBrowserDialogsProvider::DialogFileSelectLC( 
       
   238                                                     const TDesC& aStartPath,
       
   239 													const TDesC&/*aRootPath*/,
       
   240 													HBufC*& aSelectedFileName )
       
   241 	{
       
   242 	// Launch the AVKON dialog that will use existing path.
       
   243 	TBool selected( EFalse );
       
   244 
       
   245     HBufC* buf = NULL;
       
   246     buf = HBufC::NewLC( KMaxFileName );
       
   247 	TPtr ptr ( buf->Des() );
       
   248 	
       
   249 	// If a recent path exists, use that as the starting point.
       
   250 	if ( aStartPath.Length() )
       
   251 		{
       
   252 
       
   253 		TParsePtrC fileNameParser( aStartPath );
       
   254          // Copy drive into the buffer as a way to pass it to AVKON dialog.
       
   255         TPtrC ptrDrive( fileNameParser.Drive() );
       
   256         // Get phone memory root 
       
   257       	TPtrC8 tempPtrC8((const TUint8*)text_phone_memory_root_path);
       
   258 
       
   259 		// Unicode data will be <= in length to ASCII
       
   260 		HBufC* rootBuf = HBufC::NewLC(tempPtrC8.Length() + 1);
       
   261 		
       
   262 		rootBuf->Des().Copy(tempPtrC8);
       
   263 		rootBuf->Des().ZeroTerminate();
       
   264 		
       
   265 		TPtr rootPtr( rootBuf->Des() );
       
   266 		// Compare phone memory drive with drive from aStartPath
       
   267         if( rootPtr.Length() && (rootPtr[0] == ptrDrive[0] ))
       
   268 			{
       
   269 			// we are on the phone memory
       
   270     		TPtrC ptrPath( fileNameParser.DriveAndPath() );  
       
   271        		ptr.Copy(rootPtr); 
       
   272         	if ( ptrPath.Length() )
       
   273         
       
   274 				{// make ptrPath directory relative to a phone root directory
       
   275 				// remove "C:\\Data\\" from ptrPath
       
   276       			if(aStartPath.Match(rootBuf->Des() )) 
       
   277 					{
       
   278 					ptrPath.Set( ptrPath.Right( ptrPath.Length() - rootPtr.Length() ) );
       
   279 					}
       
   280 				} // for current configuration ptr is "C:\\Data\\", ptrPath is something like
       
   281             //  "images//" etc
       
   282         	selected = CAknFileSelectionDialog::RunDlgLD(ptr,ptrPath);   	
       
   283 			}
       
   284 		else
       
   285 			{
       
   286 			TBuf<KMaxPath> rootPath;
       
   287 			rootPath.Copy( ptrDrive ); 
       
   288 			ptr.Copy( rootPath );	
       
   289 	
       
   290 			// Remove leading backslash; required for AVKON dialog.
       
   291 			TPtrC ptrPath( fileNameParser.Path() );
       
   292     
       
   293 			if ( ptrPath.Length() )
       
   294 				{
       
   295 				if ( ptrPath[0] == '\\' ) 
       
   296 					{
       
   297 					ptrPath.Set( ptrPath.Right( ptrPath.Length() - 1 ) );
       
   298 					}
       
   299 				}	
       
   300             
       
   301      		selected = CAknFileSelectionDialog::RunDlgLD( ptr, ptrPath);
       
   302 			}
       
   303      	CleanupStack:: PopAndDestroy(rootBuf);
       
   304 
       
   305 		if( !selected )
       
   306 			{
       
   307 			// if mmc present launch memory selection dialog
       
   308 			FeatureManager::InitializeLibL();
       
   309 			TBool mmcSupported( FeatureManager::FeatureSupported( KFeatureIdMmc ) );
       
   310 			FeatureManager::UnInitializeLib();
       
   311 
       
   312 			TInt driveInfo( KErrNone );
       
   313 
       
   314 #ifdef RD_MULTIPLE_DRIVE
       
   315             TDriveNumber selectedMemory;
       
   316             User::LeaveIfError(
       
   317                 DriveInfo::GetDefaultDrive( DriveInfo::EDefaultPhoneMemory,
       
   318                                             ( TInt& )selectedMemory ) );
       
   319 #else
       
   320 			CAknMemorySelectionDialog::TMemory selectedMemory( 
       
   321 							CAknMemorySelectionDialog::EPhoneMemory );
       
   322 #endif
       
   323 
       
   324 			if ( mmcSupported )
       
   325 				{
       
   326 #ifdef RD_MULTIPLE_DRIVE
       
   327                 TDriveNumber defaultRMS;
       
   328                 User::LeaveIfError(
       
   329                     DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage,
       
   330                                                 ( TInt& )defaultRMS ) );
       
   331                 TUint status;
       
   332                 RFs& fs = CCoeEnv::Static()->FsSession();
       
   333                 driveInfo = DriveInfo::GetDriveStatus( fs, ( TInt& )defaultRMS, status );
       
   334 #else
       
   335    				driveInfo = DriveReady( TDriveNumber( EDriveE ) );
       
   336 #endif
       
   337 				}
       
   338 			// Temp variable
       
   339 			HBufC* defaultFolder = HBufC::NewLC( KMaxPath );
       
   340 			TPtr ptrDefaultFolder = defaultFolder->Des();
       
   341 			HBufC* defaultPath = HBufC::NewLC( KMaxPath );
       
   342 			TPtr ptrDefaultPath = defaultPath->Des();
       
   343 
       
   344 			if ( ( driveInfo == KErrNone ) && mmcSupported )
       
   345 				{
       
   346 				// Run MEMORY SELECTION DIALOG
       
   347 #ifdef RD_MULTIPLE_DRIVE
       
   348 				CAknMemorySelectionDialogMultiDrive* memoryDialog = 
       
   349 					CAknMemorySelectionDialogMultiDrive::NewL( ECFDDialogTypeSelect, 
       
   350 													 R_MEMORY_SELECTION_DIALOG,
       
   351 													 EFalse );
       
   352 #else
       
   353 				CAknMemorySelectionDialog* memoryDialog = 
       
   354 					CAknMemorySelectionDialog::NewL( ECFDDialogTypeSelect, 
       
   355 													 R_MEMORY_SELECTION_DIALOG,
       
   356 													 EFalse );
       
   357 #endif
       
   358 				CleanupStack::PushL( memoryDialog );
       
   359 				selected = memoryDialog->ExecuteL( selectedMemory,
       
   360 											   &ptrDefaultPath, 
       
   361 											   &ptrDefaultFolder );
       
   362 				CleanupStack::PopAndDestroy(); // memoryDialog
       
   363 				}
       
   364 			
       
   365 			if ( selected ) 
       
   366 				{
       
   367 				selected = CAknFileSelectionDialog::RunDlgLD( ptrDefaultPath, 
       
   368 														  ptrDefaultFolder );
       
   369 				if ( selected ) 
       
   370 					{
       
   371 					ptr.Copy( ptrDefaultPath );
       
   372 					}
       
   373 				}
       
   374 			CleanupStack::PopAndDestroy(defaultPath); //defaultPath
       
   375 			CleanupStack::PopAndDestroy(defaultFolder); //defaultFolder
       
   376 			}
       
   377 		}
       
   378 	else
       
   379 		{
       
   380         // aStartPath is NULL
       
   381         ptr.Copy( aStartPath );
       
   382 #ifdef RD_MULTIPLE_DRIVE
       
   383 		selected = AknCommonDialogsDynMem::RunSelectDlgLD( AknCommonDialogsDynMem::EMemoryTypePhone|
       
   384                                                            AknCommonDialogsDynMem::EMemoryTypeInternalMassStorage|
       
   385                                                            AknCommonDialogsDynMem::EMemoryTypeMMCExternal|
       
   386                                                            AknCommonDialogsDynMem::EMemoryTypeRemote, 
       
   387                                                            ptr, R_MEMORY_SELECTION_DIALOG );
       
   388 #else
       
   389 		selected = AknCommonDialogs::RunSelectDlgLD( ptr, 
       
   390 													 R_MEMORY_SELECTION_DIALOG );
       
   391 #endif
       
   392 		}
       
   393 
       
   394 	// return fully qualified file name
       
   395 	if ( selected )
       
   396 		{
       
   397 		aSelectedFileName = buf;
       
   398 		}
       
   399 
       
   400     if ( iObserver )
       
   401         {
       
   402         iObserver->ReportDialogEventL( 
       
   403     	                        MBrowserDialogsProviderObserver::EFileSelect,
       
   404     	                        ( TInt ) selected );    
       
   405         }       
       
   406 	return selected;
       
   407 	}
       
   408 
       
   409 
       
   410 
       
   411 //-----------------------------------------------------------------------------
       
   412 //  CBrowserDialogsProvider::DialogSelectOptionL(
       
   413 //								const TDesC& aTitle, 
       
   414 //								TBrCtlSelectOptionType aBrCtlSelectOptionType,
       
   415 //								CArrayFix<TBrCtlSelectOptionData>& aOptions )
       
   416 //-----------------------------------------------------------------------------
       
   417 EXPORT_C TBool CBrowserDialogsProvider::DialogSelectOptionL(
       
   418 								const TDesC& aTitle, 
       
   419 								TBrCtlSelectOptionType aBrCtlSelectOptionType,
       
   420 								CArrayFix<TBrCtlSelectOptionData>& aOptions )
       
   421 	{
       
   422     CBrowserSelectElementDlg* dlg = CBrowserSelectElementDlg::NewL(	aTitle, 
       
   423 												aBrCtlSelectOptionType, 
       
   424 												aOptions );
       
   425 
       
   426 	
       
   427     iDialogs.Append( dlg );     // Store a pointer to the dialog for CancelAll()
       
   428 
       
   429 	TInt result = dlg->ExecuteLD();
       
   430 
       
   431     RemoveDialogFromArray();
       
   432     
       
   433     if ( iObserver )
       
   434         {
       
   435         iObserver->ReportDialogEventL( 
       
   436     	                        MBrowserDialogsProviderObserver::ESelectOption,
       
   437     	                        ( TInt ) result );    
       
   438         }
       
   439         
       
   440     return result;
       
   441 	}
       
   442 
       
   443 
       
   444 //-----------------------------------------------------------------------------
       
   445 // CBrowserDialogsProvider::DialogUserAuthenticationLC(	
       
   446 //												const TDesC& /*aUrl**/, 
       
   447 //												const TDesC& /*aRealm*/, 
       
   448 //												const TDesC& aDefaultUserName, 
       
   449 //												HBufC*& aReturnedUserName, 
       
   450 //												HBufC*& aReturnedPasswd,
       
   451 //												TBool aBasicAuthentication )
       
   452 //-----------------------------------------------------------------------------
       
   453 EXPORT_C TBool CBrowserDialogsProvider::DialogUserAuthenticationLC(	
       
   454 												const TDesC& /*aUrl**/, 
       
   455 												const TDesC& /*aRealm*/, 
       
   456 												const TDesC& aDefaultUserName, 
       
   457 												HBufC*& aReturnedUserName, 
       
   458 												HBufC*& aReturnedPasswd,
       
   459 												TBool /*aBasicAuthentication*/ )
       
   460 	{
       
   461 	TBuf<KBrowserDialogsProviderMaxUsername> username;
       
   462     TBuf<KBrowserDialogsProviderMaxPassword> password;
       
   463     TBool bTryAgain = ETrue;
       
   464 	TBool cancelled = ETrue;
       
   465     
       
   466     // Fill in default username and notify that previous authentication failed
       
   467     if ( aDefaultUserName.Length() )
       
   468         {
       
   469         username.Copy( aDefaultUserName );
       
   470         bTryAgain = ( ConfirmQueryDialogL( R_BROWSER_DLGPROV_AUTH_FAIL_RETRY_QUERY ) != 0 );
       
   471         }
       
   472     
       
   473     // Show Authentication dialog
       
   474     if( bTryAgain )
       
   475         {
       
   476         switch (GetUserPasswordL( username, password ))
       
   477             {
       
   478             case EAknSoftkeyOk:
       
   479                 {
       
   480                 cancelled = EFalse;
       
   481                 break;
       
   482                 }
       
   483             case EAknSoftkeyCancel:
       
   484             default:
       
   485                 {
       
   486                 cancelled = ETrue;
       
   487                 }
       
   488             }
       
   489         }
       
   490 
       
   491     aReturnedUserName = username.AllocLC();
       
   492     aReturnedPasswd = password.AllocLC();
       
   493     
       
   494     if ( iObserver )
       
   495         {
       
   496         iObserver->ReportDialogEventL( 
       
   497                             MBrowserDialogsProviderObserver::EUserAuthentication,
       
   498                             ( TInt ) cancelled );
       
   499         }
       
   500     
       
   501     return !cancelled;
       
   502 	}
       
   503 
       
   504 
       
   505 //-----------------------------------------------------------------------------
       
   506 //  CBrowserDialogsProvider::DialogNoteL( const TDesC& aMessage )
       
   507 //
       
   508 //-----------------------------------------------------------------------------
       
   509 EXPORT_C void CBrowserDialogsProvider::DialogNoteL( const TDesC& aMessage )
       
   510 	{
       
   511     CAknNoteDialog* dialog = new (ELeave) CAknNoteDialog
       
   512 								( REINTERPRET_CAST( CEikDialog**, &dialog ) );
       
   513 		
       
   514     iDialogs.Append( dialog );                  // Set pointer for CancelAll()
       
   515     dialog->PrepareLC( R_DIALOGSPROVIDER_OK_NOTE ) ;
       
   516     dialog->SetCurrentLabelL( EGeneralNote, aMessage );
       
   517     dialog->RunDlgLD( CAknNoteDialog::ELongTimeout, CAknNoteDialog::ENoTone );
       
   518 
       
   519     RemoveDialogFromArray();
       
   520     
       
   521     if ( iObserver )
       
   522         {
       
   523         iObserver->ReportDialogEventL( 
       
   524                             MBrowserDialogsProviderObserver::ENote,
       
   525                             NULL );    
       
   526         }    
       
   527 	}
       
   528 
       
   529 
       
   530 //-----------------------------------------------------------------------------
       
   531 //  CBrowserDialogsProvider::DialogAlertL( const TDesC& aTitle, 
       
   532 //											const TDesC& aMessage )
       
   533 //-----------------------------------------------------------------------------
       
   534 EXPORT_C void CBrowserDialogsProvider::DialogAlertL( const TDesC& aTitle, 
       
   535 											const TDesC& aMessage )
       
   536 	{
       
   537 	// Taken from CBrowserAppUi::WmlScriptDlgAlertL()
       
   538     HBufC* messagebody = HBufC::NewLC( aMessage.Length()+2 );
       
   539     messagebody->Des().Append( aMessage );
       
   540     messagebody->Des().Append( _L("\n\n"));
       
   541 
       
   542     HBufC* header = HBufC::NewLC( aTitle.Length() );
       
   543 	header->Des().Append( aTitle );
       
   544 
       
   545     CAknMessageQueryDialog* dialog = 
       
   546                             CAknMessageQueryDialog::NewL( *messagebody );
       
   547 
       
   548 	// Store a pointer to the dialog for CancelAll()
       
   549     iDialogs.Append( dialog );
       
   550 
       
   551     dialog->PrepareLC( R_BROWSER_MESSAGE_QUERY_DIALOG );
       
   552     dialog->ButtonGroupContainer().MakeCommandVisible( 
       
   553 													EAknSoftkeyCancel, EFalse );
       
   554 
       
   555     dialog->QueryHeading()->SetTextL( *header );
       
   556 
       
   557     dialog->RunLD();
       
   558 
       
   559     RemoveDialogFromArray();
       
   560     CleanupStack::PopAndDestroy( 2 );  // header , messagebody
       
   561     
       
   562     if ( iObserver )
       
   563         {
       
   564         iObserver->ReportDialogEventL( 
       
   565                             MBrowserDialogsProviderObserver::EAlert,
       
   566                             NULL );
       
   567         }
       
   568 	}
       
   569 
       
   570 
       
   571 //-----------------------------------------------------------------------------
       
   572 //  CBrowserDialogsProvider::DialogConfirmL( const TDesC& aTitle,
       
   573 //												const TDesC& aMessage,
       
   574 //												const TDesC& aYesMessage,
       
   575 //												const TDesC& aNoMessage )
       
   576 //-----------------------------------------------------------------------------
       
   577 EXPORT_C TBool CBrowserDialogsProvider::DialogConfirmL( const TDesC& aTitle,
       
   578 												const TDesC& aMessage,
       
   579 												const TDesC& aYesMessage,
       
   580 												const TDesC& aNoMessage )
       
   581 	{
       
   582 	TBool retVal;
       
   583 
       
   584 	// CAknMessageQueryDialog must have title text, for the message text to be shown
       
   585 	if ( aTitle.Length() )
       
   586 		{
       
   587 		CAknMessageQueryDialog* dialog = 
       
   588 								CAknMessageQueryDialog::NewL( (TDesC&) aMessage );
       
   589 
       
   590 		
       
   591 		iDialogs.Append( dialog );  // Store a pointer to the dialog for CancelAll()
       
   592 
       
   593 		dialog->PrepareLC( R_BROWSER_MESSAGE_QUERY_DIALOG );
       
   594 
       
   595 		dialog->QueryHeading()->SetTextL( aTitle );
       
   596 
       
   597 		if( aYesMessage.Length() )
       
   598 			{
       
   599 			dialog->ButtonGroupContainer().SetCommandL( EAknSoftkeyOk, aYesMessage );
       
   600 			}
       
   601 
       
   602 		if( aNoMessage.Length() )
       
   603 			{ 
       
   604 			dialog->ButtonGroupContainer().SetCommandL( EAknSoftkeyCancel, aNoMessage );
       
   605 			}
       
   606 
       
   607 		if ( !dialog->RunLD() )
       
   608 			{
       
   609 			retVal = EFalse;
       
   610 			}
       
   611 		else
       
   612 			{
       
   613 			retVal = ETrue;
       
   614 			}
       
   615 
       
   616 		RemoveDialogFromArray();
       
   617 		}
       
   618 	else
       
   619 		{
       
   620 		// This dialog has an animation question mark.
       
   621 	    CAknQueryDialog* dialog = new (ELeave) CAknQueryDialog();
       
   622 
       
   623 		iDialogs.Append( dialog );	// Store dialog pointer for CancelAll()
       
   624 
       
   625 		dialog->PrepareLC( R_BROWSER_CONFIRM_QUERY );
       
   626 
       
   627 		dialog->SetPromptL( aMessage );
       
   628 		
       
   629 		if( aYesMessage.Length() )
       
   630 			{
       
   631 			dialog->ButtonGroupContainer().SetCommandL( EAknSoftkeyYes, aYesMessage );
       
   632 			}
       
   633 
       
   634 		if( aNoMessage.Length() )
       
   635 			{ 
       
   636 			dialog->ButtonGroupContainer().SetCommandL( EAknSoftkeyNo, aNoMessage );
       
   637 			}
       
   638 
       
   639 		if ( !dialog->RunLD() )
       
   640 			{
       
   641 			retVal = EFalse;
       
   642 			}
       
   643 		else
       
   644 			{
       
   645 			retVal = ETrue;
       
   646 			}
       
   647 		RemoveDialogFromArray();		
       
   648 		}
       
   649 		
       
   650 	if ( iObserver )	
       
   651     	{
       
   652     	iObserver->ReportDialogEventL( 
       
   653                             MBrowserDialogsProviderObserver::EConfirm,
       
   654                             ( TInt ) retVal );
       
   655     	}
       
   656 	return retVal;
       
   657 	}
       
   658 
       
   659 //-----------------------------------------------------------------------------
       
   660 // CBrowserDialogsProvider::DialogPromptLC( const TDesC& aTitle,
       
   661 //												const TDesC& aMessage,
       
   662 //												const TDesC& aDefaultInput,
       
   663 //												HBufC*& aReturnedInput )
       
   664 //-----------------------------------------------------------------------------
       
   665 EXPORT_C TBool CBrowserDialogsProvider::DialogPromptLC( const TDesC& aTitle,
       
   666 												const TDesC& aMessage,
       
   667 												const TDesC& aDefaultInput,
       
   668 												HBufC*& aReturnedInput )
       
   669 	{
       
   670     TBool retVal;
       
   671 
       
   672 	// defInput is not modified by the dialog.
       
   673     TPtr defInput( (TUint16*) aDefaultInput.Ptr(), aDefaultInput.Length(), 
       
   674 													    KMaxAltTextLength );
       
   675 
       
   676     CBrowserScriptPromptDialog* dialog = 
       
   677 		new (ELeave) CBrowserScriptPromptDialog( defInput, aReturnedInput );
       
   678 
       
   679 	iDialogs.Append( dialog );  // Store a pointer to the dialog for CancelAll()
       
   680 
       
   681     dialog->PrepareLC( R_DATA_QUERY_WITH_HEADING );
       
   682 	dialog->SetHeaderTextL( aTitle );
       
   683     dialog->SetPromptL( aMessage );
       
   684 
       
   685 	if ( !dialog->RunLD() )
       
   686 		{
       
   687 		retVal = EFalse;
       
   688 		}
       
   689 	else
       
   690 		{
       
   691 		retVal = ETrue;
       
   692 		}
       
   693 
       
   694     RemoveDialogFromArray();
       
   695     CleanupStack::PushL( aReturnedInput );
       
   696 
       
   697     if ( iObserver )
       
   698         {
       
   699         iObserver->ReportDialogEventL( 
       
   700                             MBrowserDialogsProviderObserver::EPrompt,
       
   701                             (TInt) retVal );
       
   702     	}
       
   703     	
       
   704     return retVal;
       
   705 	}
       
   706 
       
   707 //-----------------------------------------------------------------------------
       
   708 //  CBrowserDialogsProvider::DialogDownloadObjectL(
       
   709 //										CBrCtlObjectInfo* aBrCtlObjectInfo )
       
   710 //
       
   711 //-----------------------------------------------------------------------------
       
   712 EXPORT_C TBool CBrowserDialogsProvider::DialogDownloadObjectL(
       
   713 										CBrCtlObjectInfo* aBrCtlObjectInfo )
       
   714 	{
       
   715 	HBufC* header;	// holds the header text
       
   716 	HBufC* message;	// a buffer holding the text for each list item
       
   717 	HBufC* buf;		// a buffer for strings
       
   718 	TInt ret;		// general variable for return values
       
   719 	
       
   720 	//-------------------------------------------
       
   721 	// Query object info
       
   722 	//
       
   723 	CEikFormattedCellListBox* listBox = new ( ELeave ) 
       
   724 												CAknDoublePopupMenuStyleListBox;
       
   725 	CleanupStack::PushL( listBox );
       
   726 
       
   727 	// If supported show OK & Cancel buttons, otherwise just CANCEL
       
   728 	CAknPopupList* popupList;
       
   729 	if ( aBrCtlObjectInfo->AppSupported() || 
       
   730 						    aBrCtlObjectInfo->PluginSupported() )
       
   731 		{
       
   732 		popupList = CAknPopupList::NewL(listBox, R_AVKON_SOFTKEYS_OK_CANCEL__OK, 
       
   733 												AknPopupLayouts::EMenuDoubleWindow);
       
   734 		}
       
   735 	else
       
   736 		{
       
   737 		popupList = CAknPopupList::NewL(listBox, R_AVKON_SOFTKEYS_CANCEL, 
       
   738 												AknPopupLayouts::EMenuDoubleWindow);
       
   739 		}
       
   740 
       
   741     CleanupStack::PushL( popupList );
       
   742 
       
   743 	TInt flags = CEikListBox::EDisableHighlight;
       
   744 	listBox->ConstructL( popupList, flags );
       
   745 	listBox->CreateScrollBarFrameL( ETrue );
       
   746 	listBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, 
       
   747 															CEikScrollBarFrame::EAuto );
       
   748 
       
   749 	MDesCArray* itemList = listBox->Model()->ItemTextArray();
       
   750 	CDesCArray* itemArray = ( CDesCArray* ) itemList;
       
   751 	
       
   752 	//-------------------------------------------
       
   753 	// Header
       
   754 	//
       
   755 	header = StringLoader::LoadLC( R_BROWSER_DLGPROV_OBJ_DOWNLOAD_TITLE );
       
   756 	popupList->SetTitleL( *header );
       
   757 	CleanupStack::PopAndDestroy();	// header
       
   758 	header = NULL;
       
   759 
       
   760 	//-------------------------------------------
       
   761 	// Supported?
       
   762 	//
       
   763 	if ( !( aBrCtlObjectInfo->AppSupported() 
       
   764 			|| aBrCtlObjectInfo->PluginSupported()) )	// Object is "Not Supported"
       
   765 		{
       
   766 		HBufC* supported = StringLoader::LoadLC( R_BROWSER_DLGPROV_OBJ_DOWNLOAD_NOT_SUPPORTED );		
       
   767 		itemArray->AppendL( *supported );
       
   768 		CleanupStack::PopAndDestroy();	// supported
       
   769 		}
       
   770 
       
   771 	//-------------------------------------------
       
   772 	// Application Size
       
   773 	//
       
   774 	message = HBufC::NewLC( KBrCtlObjectElementMaxLength );
       
   775 	buf = StringLoader::LoadLC( R_BROWSER_DLGPROV_OBJ_DOWNLOAD_SIZE );	// first line - bold text
       
   776 	message->Des().Append( *buf );
       
   777 	message->Des().Append( TChar( '\t' ) );
       
   778 		
       
   779 	if ( aBrCtlObjectInfo->Size().Length() )	// second line - normal text
       
   780 		{
       
   781 		HBufC* size;
       
   782 		const TPtrC sizeString = aBrCtlObjectInfo->Size();
       
   783 		// convert size to int
       
   784 		TLex sizeLex( sizeString );		
       
   785 		TInt sizeInt = 0;
       
   786 				
       
   787 		ret = sizeLex.Val( sizeInt );
       
   788         __ASSERT_DEBUG( !ret , User::Panic( _L("BrowserDialogsProvider"), EInvalidSizeValue ) ) ;
       
   789         
       
   790 		// KB
       
   791 		if ( sizeInt < KBrCtlMegabyte )
       
   792 			{
       
   793 			// %N KB
       
   794 			size = StringLoader::LoadLC( R_BROWSER_DLGPROV_UNIT_KB, sizeInt );
       
   795 			}
       
   796 		// MB - up to 999MB
       
   797 		else if ( sizeInt < ( KBrCtlMegabyte * 1000 ) )
       
   798 			{			
       
   799 			HBufC* mbString = HBufC::NewLC( KBrCtlMBFormat );
       
   800 			HBufC* decimalSeparator = StringLoader::LoadLC( R_WML_DECIMAL_SEPARATOR );
       
   801 			TInt mb = sizeInt / KBrCtlMegabyte;
       
   802 			TInt remainder = sizeInt % KBrCtlMegabyte;
       
   803 
       
   804 			// Size shown in 3 numbers
       
   805 			mbString->Des().AppendNum( mb );
       
   806 			if ( mb < 10 )
       
   807 				{
       
   808 				// show 2 decimal places
       
   809 				mbString->Des().Append( *decimalSeparator );
       
   810 
       
   811                 // Add leading zeroes if necessary                                
       
   812                 if ( remainder < ( KBrCtlMegabyte / 10 ) )
       
   813                     {
       
   814                     // One leading zero needed
       
   815                     mbString->Des().AppendNum( 0 );
       
   816                     }
       
   817 
       
   818 				mbString->Des().AppendNum(  ( remainder * 100 ) / KBrCtlMegabyte  );
       
   819 				}
       
   820 			else if ( mb < 100 )
       
   821 				{
       
   822 				// show 1 decimal place
       
   823 				mbString->Des().Append( *decimalSeparator );				
       
   824 				mbString->Des().AppendNum( ( remainder * 10 ) / KBrCtlMegabyte );
       
   825 				}
       
   826 
       
   827 			CleanupStack::PopAndDestroy(); // decimalSeparator
       
   828 			
       
   829 			// %U MB
       
   830 			size = StringLoader::LoadLC( R_BROWSER_DLGPROV_UNIT_MB, *mbString );
       
   831 			CleanupStack::Pop();//size
       
   832 			CleanupStack::PopAndDestroy(); // mbString
       
   833 			CleanupStack::PushL( size );
       
   834 			}
       
   835 		// GB
       
   836 		else
       
   837 			{
       
   838 			HBufC* gb = HBufC::NewLC( KBrCtlGBFormat );
       
   839 			gb->Des().AppendNum( sizeInt / KBrCtlMegabyte );
       
   840 			size = StringLoader::LoadLC( R_BROWSER_DLGPROV_UNIT_MB, *gb );
       
   841 			CleanupStack::Pop();//size
       
   842 			CleanupStack::PopAndDestroy(); // gb
       
   843 			CleanupStack::PushL( size );
       
   844 			}
       
   845 		message->Des().Append( *size );
       
   846 		CleanupStack::PopAndDestroy();	// size
       
   847 		}
       
   848 	else
       
   849 		{
       
   850 		HBufC* sizeString = StringLoader::LoadLC( R_BROWSER_DLGPROV_OBJ_DOWNLOAD_UNKNOWN );
       
   851 		message->Des().Append( *sizeString );
       
   852 		CleanupStack::PopAndDestroy(); // sizeString
       
   853 		}
       
   854 	itemArray->AppendL( *message );
       
   855 	CleanupStack::PopAndDestroy(2);	// buf , message
       
   856 	buf = NULL;
       
   857 	message = NULL;
       
   858 
       
   859 	//-------------------------------------------
       
   860 	// Application Name	- only show if Supported
       
   861 	//	
       
   862 	if ( aBrCtlObjectInfo->AppSupported() 
       
   863 						|| aBrCtlObjectInfo->PluginSupported() )
       
   864 		{
       
   865 		message = HBufC::NewLC( KBrCtlObjectElementMaxLength );
       
   866 		HBufC* appName = StringLoader::LoadLC( R_BROWSER_DLGPROV_OBJ_DOWNLOAD_OPENWITH );
       
   867 		message->Des().Append( *appName );
       
   868 		message->Des().Append( TChar( '\t' ) );
       
   869 		message->Des().Append( aBrCtlObjectInfo->AppName() );
       
   870 		itemArray->AppendL( *message );
       
   871 		CleanupStack::PopAndDestroy(2);	// appName , message
       
   872 		appName = NULL;
       
   873 		message = NULL;
       
   874 		}
       
   875 
       
   876 	//-------------------------------------------
       
   877 	// (MIME) File Type
       
   878 	//
       
   879 	message = HBufC::NewLC( KBrCtlObjectElementMaxLength );
       
   880 	buf = StringLoader::LoadLC( R_BROWSER_DLGPROV_OBJ_DOWNLOAD_FILETYPE );
       
   881 	message->Des().Append( *buf );
       
   882 	message->Des().Append( TChar( '\t' ) );
       
   883 
       
   884 	if ( aBrCtlObjectInfo->FileType().Length() )
       
   885 		{
       
   886 		message->Des().Append( aBrCtlObjectInfo->FileType() );
       
   887 		}
       
   888 	else
       
   889 		{		
       
   890 		HBufC* fileName = StringLoader::LoadLC( R_BROWSER_DLGPROV_OBJ_DOWNLOAD_UNKNOWN );
       
   891 		message->Des().Append( *fileName );
       
   892 		CleanupStack::PopAndDestroy(); // fileName
       
   893 		fileName = NULL;
       
   894 		}
       
   895 	itemArray->AppendL( *message );
       
   896 	CleanupStack::PopAndDestroy(2); // buf , message
       
   897 	buf = NULL;
       
   898 	message = NULL;
       
   899 
       
   900 	CleanupStack::Pop();	// popupList 
       
   901     
       
   902     iDialogs.Append( popupList );   // store ptr to dlg
       
   903 
       
   904 	// Show Dialog
       
   905 	if ( !popupList->ExecuteLD() )
       
   906 		{
       
   907 		ret = EFalse;
       
   908 		}
       
   909 	else
       
   910 		{
       
   911 		ret = ETrue;
       
   912 		}
       
   913     
       
   914 	// cleanup
       
   915     RemoveDialogFromArray();
       
   916 	CleanupStack::PopAndDestroy();	// listBox 
       
   917 	listBox = NULL;
       
   918 
       
   919     if ( iObserver )
       
   920         {
       
   921         iObserver->ReportDialogEventL( 
       
   922                             MBrowserDialogsProviderObserver::EDownloadObject,
       
   923                             (TInt) ret );
       
   924         }
       
   925 
       
   926 	return ret;
       
   927 	}
       
   928 
       
   929 //-----------------------------------------------------------------------------
       
   930 //CBrowserDialogsProvider::DialogDisplayPageImagesL( 
       
   931 //							CArrayFixFlat<TBrCtlImageCarrier>& aPageImages )
       
   932 //-----------------------------------------------------------------------------
       
   933 EXPORT_C void CBrowserDialogsProvider::DialogDisplayPageImagesL( 
       
   934 							CArrayFixFlat<TBrCtlImageCarrier>& aPageImages )
       
   935 	{
       
   936     if (aPageImages.Count() > 1)
       
   937         {
       
   938         CBrowserViewImagesPopup* dialog = new (ELeave) CBrowserViewImagesPopup();
       
   939         CleanupStack::PushL( dialog );
       
   940         dialog->ConstructL( aPageImages );    
       
   941 
       
   942         iDialogs.Append( dialog );                  // add dialog ptr to array
       
   943         CleanupStack::Pop();
       
   944         dialog->ExecuteLD();
       
   945         RemoveDialogFromArray();
       
   946         }
       
   947     else if (aPageImages.Count() == 1)
       
   948         {
       
   949         CBrowserViewImagesPopup::PhotoOperationL(aPageImages[0]);
       
   950         }
       
   951     if ( iObserver )
       
   952     	{
       
   953             iObserver->ReportDialogEventL( 
       
   954                        	MBrowserDialogsProviderObserver::EDisplayPageImages,NULL );
       
   955     	}     
       
   956 	}
       
   957 
       
   958 
       
   959 //-----------------------------------------------------------------------------
       
   960 //  CBrowserDialogsProvider::CancelAll()
       
   961 //
       
   962 //-----------------------------------------------------------------------------
       
   963 //
       
   964 EXPORT_C void CBrowserDialogsProvider::CancelAll()
       
   965 	{
       
   966     // Empty the array
       
   967     iDialogs.ResetAndDestroy();
       
   968 	}
       
   969 
       
   970 //-----------------------------------------------------------------------------
       
   971 //  CBrowserDialogsProvider::RemoveDialogFromArray()
       
   972 //
       
   973 //-----------------------------------------------------------------------------
       
   974 //
       
   975 void CBrowserDialogsProvider::RemoveDialogFromArray()
       
   976     {
       
   977     // Do not try to remove a dialog if CancelAll() has been called
       
   978     if ( iDialogs.Count() )
       
   979         {
       
   980         iDialogs.Remove( iDialogs.Count() - 1 );    // remove dialog ptr to array
       
   981         }
       
   982     }
       
   983 
       
   984 //-----------------------------------------------------------------------------
       
   985 // New functions
       
   986 //
       
   987 
       
   988 // ----------------------------------------------------------------------------
       
   989 // CBrowserDialogsProvider::ShowTooltip
       
   990 // ----------------------------------------------------------------------------
       
   991 //
       
   992 EXPORT_C void CBrowserDialogsProvider::ShowTooltipL( const TDesC& aText, 
       
   993                                                      TInt aDuration,
       
   994                                                      TInt aDelay )
       
   995     {
       
   996     iTooltip->SetTextL( aText );
       
   997     iTooltip->SetTimeDelayBeforeShow( aDelay );
       
   998     iTooltip->SetTimePopupInView( aDuration );
       
   999     iTooltip->ShowInfoPopupNote();
       
  1000     }
       
  1001 
       
  1002 
       
  1003 // ----------------------------------------------------------------------------
       
  1004 // CBrowserDialogsProvider::UploadProgressNoteL
       
  1005 // ----------------------------------------------------------------------------
       
  1006 //
       
  1007 EXPORT_C void CBrowserDialogsProvider::UploadProgressNoteL(  
       
  1008                                 TInt32 aTotalSize,
       
  1009                                 TInt32 aChunkSize,
       
  1010                                 TBool aIsLastChunk,
       
  1011                                 MBrowserDialogsProviderObserver* aObserver )
       
  1012     {
       
  1013     // If the download is finished.
       
  1014     if( aIsLastChunk )
       
  1015         {
       
  1016         if( iUploadProgressNote )
       
  1017             {
       
  1018             // Delete progress note.
       
  1019             delete iUploadProgressNote;
       
  1020             iUploadProgressNote = NULL;
       
  1021             }
       
  1022         }
       
  1023     else
       
  1024         {
       
  1025         // If the download just started.
       
  1026         if ( !iUploadProgressNote )
       
  1027             {
       
  1028             // Create progress note.
       
  1029             iUploadProgressNote = CBrowserUploadProgressNote::NewL( 
       
  1030                     aTotalSize, 
       
  1031                     aObserver,
       
  1032                     REINTERPRET_CAST ( CEikDialog**, &iUploadProgressNote ) );
       
  1033                     
       
  1034             iUploadProgressNote->UpdateL( aChunkSize );
       
  1035             }
       
  1036         // If the download is in progress, and needs to update.
       
  1037         else
       
  1038             {
       
  1039             // Update progress note.
       
  1040             iUploadProgressNote->UpdateL( aChunkSize );
       
  1041             }
       
  1042         }
       
  1043     }
       
  1044     
       
  1045 //-----------------------------------------------------------------------------
       
  1046 //CBrowserDialogsProvider::DialogMimeFileSelectLC( 
       
  1047 //                                              HBufC*& aSelectedFileName,
       
  1048 //												const TDesC& aMimeType )
       
  1049 //-----------------------------------------------------------------------------
       
  1050 
       
  1051 EXPORT_C TBool CBrowserDialogsProvider::DialogMimeFileSelectLC( 
       
  1052 													HBufC*& aSelectedFileName,
       
  1053 													const TDesC& aMimeType )
       
  1054 	{
       
  1055 	TBool selected( EFalse );
       
  1056 	
       
  1057 	TMediaFileType mediaFileType(ENoMediaFile);
       
  1058 
       
  1059     if (aMimeType.FindF(KMimeTypeImage) != KErrNotFound)
       
  1060         {
       
  1061         mediaFileType = EImageFile;
       
  1062         }
       
  1063     else if (aMimeType.FindF(KMimeTypeAudio) != KErrNotFound)
       
  1064         {
       
  1065         mediaFileType = EAudioFile;
       
  1066         }
       
  1067     else if (aMimeType.FindF(KMimeTypeVideo) != KErrNotFound)
       
  1068         {
       
  1069         mediaFileType = EVideoFile;
       
  1070         }
       
  1071 
       
  1072     // if mime type not supported then use default file selector
       
  1073     if (mediaFileType == ENoMediaFile)
       
  1074         {
       
  1075         return DialogFileSelectLC(KNullDesC(), KNullDesC(), aSelectedFileName);
       
  1076         }
       
  1077 
       
  1078 	HBufC* buf = NULL;
       
  1079     buf = HBufC::NewLC( KMaxFileName );
       
  1080 	TPtr ptr ( buf->Des() );
       
  1081 
       
  1082     CDesCArrayFlat *selectedFiles = new (ELeave) CDesCArrayFlat(1);
       
  1083     CleanupStack::PushL(selectedFiles);
       
  1084 
       
  1085 	selected = MGFetch::RunL( *selectedFiles,
       
  1086                                 mediaFileType,
       
  1087                                 EFalse,
       
  1088                                 this );
       
  1089 	
       
  1090 	if ( selected && selectedFiles->Count()>0) 
       
  1091 		{
       
  1092 		ptr.Copy( (*selectedFiles)[0] );
       
  1093 		}
       
  1094 	selectedFiles->Reset();
       
  1095 	CleanupStack::PopAndDestroy();//selectedFiles
       
  1096 
       
  1097 	
       
  1098 	// return fully qualified file name
       
  1099 	if ( selected )
       
  1100 		{
       
  1101 		aSelectedFileName = buf;
       
  1102 		}
       
  1103 
       
  1104     if ( iObserver )
       
  1105         {
       
  1106         iObserver->ReportDialogEventL( 
       
  1107     	                        MBrowserDialogsProviderObserver::EFileSelect,
       
  1108     	                        ( TInt ) selected );    
       
  1109         }       
       
  1110 	return selected;
       
  1111 	}
       
  1112 
       
  1113 TBool CBrowserDialogsProvider::VerifySelectionL
       
  1114         (const MDesCArray* aSelectedFiles)
       
  1115     {
       
  1116     return (aSelectedFiles && aSelectedFiles->MdcaCount() > 0)? ETrue: EFalse;
       
  1117     }
       
  1118 
       
  1119 // ----------------------------------------------------------------------------
       
  1120 // CBrowserDialogsProvider::ConfirmQueryDialogL
       
  1121 // ----------------------------------------------------------------------------
       
  1122 //
       
  1123 TInt CBrowserDialogsProvider::ConfirmQueryDialogL(	const TInt aPromptResourceId,
       
  1124 													TInt aResId, 
       
  1125 													TInt aAnimation )
       
  1126     {
       
  1127     HBufC* prompt = StringLoader::LoadLC( aPromptResourceId );
       
  1128     TInt ret = ConfirmQueryDialogL( *prompt, aResId, aAnimation );
       
  1129     CleanupStack::PopAndDestroy();  // prompt
       
  1130     return ret;
       
  1131     }
       
  1132 
       
  1133 // ----------------------------------------------------------------------------
       
  1134 // CBrowserDialogsProvider::ConfirmQueryDialogL
       
  1135 // ----------------------------------------------------------------------------
       
  1136 //
       
  1137 TInt CBrowserDialogsProvider::ConfirmQueryDialogL(	const TDesC& aPrompt, 
       
  1138 													TInt aResId, 
       
  1139 													TInt aAnimation )
       
  1140     {
       
  1141     TInt ret;
       
  1142     CAknQueryDialog* dialog = new (ELeave) CAknQueryDialog();
       
  1143 
       
  1144 	// Store dialog pointer for CancelAll()
       
  1145 	iDialogs.Append( dialog );
       
  1146 
       
  1147     dialog->PrepareLC( R_BROWSER_CONFIRM_QUERY );
       
  1148     // passing prompt text in constructor is deprecated according to 
       
  1149     // AknQueryDialog.h
       
  1150     dialog->SetPromptL( aPrompt );
       
  1151     if( aResId )
       
  1152         {
       
  1153         dialog->ButtonGroupContainer().SetCommandSetL( aResId );
       
  1154         }
       
  1155 
       
  1156     if( aAnimation )
       
  1157         {
       
  1158         CAknQueryControl* control = STATIC_CAST( CAknQueryControl*, dialog->Control(EGeneralQuery) );
       
  1159         control->SetAnimationL( aAnimation );
       
  1160         }
       
  1161     ret = dialog->RunLD();
       
  1162     RemoveDialogFromArray();
       
  1163     return ret;
       
  1164     }
       
  1165 
       
  1166 
       
  1167 // ---------------------------------------------------------
       
  1168 // CBrowserDialogsProvider::GetUserPasswordL
       
  1169 // ---------------------------------------------------------
       
  1170 //
       
  1171 TInt CBrowserDialogsProvider::GetUserPasswordL( TDes& aUsername, TDes& aPassword )
       
  1172 	{
       
  1173     TInt ret;
       
  1174 	CBrowserAuthenticationDialog* dialog = 
       
  1175                 CBrowserAuthenticationDialog::NewL( aUsername, aPassword );
       
  1176 
       
  1177 	iDialogs.Append( dialog );                  // Store pointer for CancelAll()
       
  1178 	if (JAPANESE)
       
  1179     	{
       
  1180     	ret = dialog->ExecuteLD( R_WB_SCRIPT_USERPASSWD_LINES_JAPAN );
       
  1181     	}
       
  1182 	else
       
  1183     	{
       
  1184     	ret = dialog->ExecuteLD( R_WB_SCRIPT_USERPASSWD_LINES_NON_JAPAN );
       
  1185     	}
       
  1186     RemoveDialogFromArray();
       
  1187     return ret;
       
  1188 	}
       
  1189 
       
  1190 
       
  1191 // -----------------------------------------------------------------------------
       
  1192 // CBrowserDialogsProvider::AssureResourceL
       
  1193 // -----------------------------------------------------------------------------
       
  1194 //
       
  1195 void CBrowserDialogsProvider::AssureResourceL()
       
  1196     {
       
  1197     if ( !iResourceOpened )
       
  1198         {
       
  1199         // Add resource file.
       
  1200         TParse* fp = new(ELeave) TParse(); 
       
  1201 
       
  1202         TInt err = fp->Set( KBrowserDialogsProviderDirAndFile, 
       
  1203                             &KDC_RESOURCE_FILES_DIR, 
       
  1204                             NULL ); 
       
  1205         if ( err != KErrNone)
       
  1206             {
       
  1207             User::Leave( err );
       
  1208             }   
       
  1209     
       
  1210         TFileName resourceFileName = fp->FullName();
       
  1211         delete fp;
       
  1212 
       
  1213         TRAPD( error, iResourceLoader.OpenL( resourceFileName ) );
       
  1214         if ( !error )
       
  1215             {
       
  1216             iResourceOpened = ETrue;
       
  1217             }
       
  1218         else
       
  1219             {
       
  1220             User::Leave( error );
       
  1221             }
       
  1222         }
       
  1223 
       
  1224     if ( !iErrResourceOpened )
       
  1225         {
       
  1226         // Add error resource file.
       
  1227         TParse* errfp = new(ELeave) TParse(); 
       
  1228 
       
  1229         TInt err = errfp->Set( KErrorResDirAndFile, 
       
  1230                                &KDC_RESOURCE_FILES_DIR, 
       
  1231                                NULL ); 
       
  1232         if ( err != KErrNone)
       
  1233             {
       
  1234             User::Leave( err );
       
  1235             }   
       
  1236     
       
  1237         TFileName errResourceFileName = errfp->FullName();
       
  1238         delete errfp;
       
  1239 
       
  1240         TRAPD( error, iErrResourceLoader.OpenL( errResourceFileName ) );
       
  1241         if ( !error )
       
  1242             {
       
  1243             iErrResourceOpened = ETrue;
       
  1244             }
       
  1245         else
       
  1246             {
       
  1247             User::Leave( error );
       
  1248             }
       
  1249         }
       
  1250     }
       
  1251 
       
  1252 
       
  1253 // -----------------------------------------------------------------------------
       
  1254 // CBrowserDialogsProvider::DriveReady
       
  1255 // -----------------------------------------------------------------------------
       
  1256 //
       
  1257 TInt CBrowserDialogsProvider::DriveReady( TDriveNumber aDrive )
       
  1258 	{
       
  1259 	RFs& fs = CCoeEnv::Static()->FsSession();
       
  1260 	_LIT( KFat, "Fat" );
       
  1261     // Check if the drive is already mounted
       
  1262 	TFullName name;
       
  1263 	TInt error( fs.FileSystemName( name, aDrive ) );
       
  1264 	if ( error )
       
  1265 		{
       
  1266 		return KErrNotReady;
       
  1267 		}
       
  1268 	else
       
  1269 		{
       
  1270 		// check if MMC already mounted	
       
  1271 		if ( name.Length() == 0 )
       
  1272 			{
       
  1273 			// MMC drive isnt mounted at present, so try it now....
       
  1274 			error = fs.MountFileSystem( KFat, aDrive );
       
  1275 
       
  1276 			// If it's a locked MMC and the password is already known it'll be
       
  1277 			// unlocked automatically when it's mounted., otherwise the mount will
       
  1278 			// return with KErrLocked.....
       
  1279 			if ( error == KErrLocked )
       
  1280 				{
       
  1281 				return KErrLocked;
       
  1282 				}
       
  1283 			}
       
  1284 		}
       
  1285 	return KErrNone;
       
  1286 	}
       
  1287 
       
  1288 //  END OF FILE