browserutilities/browserdialogsprovider/Src/BrowserDialogsProvider.cpp
branchRCL_3
changeset 49 919f36ff910f
parent 48 79859ed3eea9
equal deleted inserted replaced
48:79859ed3eea9 49:919f36ff910f
    17 
    17 
    18 
    18 
    19 // INCLUDE Files
    19 // INCLUDE Files
    20 
    20 
    21 // User includes
    21 // User includes
    22 #include "BrowserDialogsProvider.h"	// Class header
    22 #include <browserdialogsprovider.h>	// Class header
    23 #include "BrowserDialogsProvider.hrh"
    23 #include "BrowserDialogsProvider.hrh"
    24 #include "BrowserAuthenticationDialog.h"
    24 #include "BrowserAuthenticationDialog.h"
    25 #include "BrowserDialogsProviderConstants.h"
    25 #include "BrowserDialogsProviderConstants.h"
    26 #include "BrowserDialogsProviderObserver.h" //obs
    26 #include <browserdialogsproviderobserver.h> //obs
    27 
    27 
    28 // Browser as a Plugin - own classes
    28 // Browser as a Plugin - own classes
    29 #include "BrowserViewImagesPopup.h"		// For DialogDisplayPageImagesL
    29 #include "BrowserViewImagesPopup.h"		// For DialogDisplayPageImagesL
    30 #include "BrowserScriptPromptDialog.h"	// For DialogPromptLC
    30 #include "BrowserScriptPromptDialog.h"	// For DialogPromptLC
    31 #include "BrowserSelectElementDlg.h"	// For DialogFileSelectLC
    31 #include "BrowserSelectElementDlg.h"	// For DialogFileSelectLC
    32 #include "BrowserUploadProgressNote.h"  // For UploadProgressNoteL
    32 #include "BrowserUploadProgressNote.h"  // For UploadProgressNoteL
    33 
    33 
    34 // System Includes
    34 // System Includes
    35 #include <aknlists.h>					// for Object Element Dialog
    35 #include <aknLists.h>					// for Object Element Dialog
    36 #include <aknmessagequerydialog.h>		// DialogAlertL
    36 #include <aknmessagequerydialog.h>		// DialogAlertL
    37 #include <CAknFileSelectionDialog.h>	// File Selection Dialog
    37 #include <CAknFileSelectionDialog.h>	// File Selection Dialog
    38 
    38 
    39 #ifdef RD_MULTIPLE_DRIVE
    39 #ifdef RD_MULTIPLE_DRIVE
    40 #include <driveinfo.h>
    40 #include <driveinfo.h>
    45 #include <AknCommonDialogs.h>			// File Selection Dialog
    45 #include <AknCommonDialogs.h>			// File Selection Dialog
    46 #endif
    46 #endif
    47 
    47 
    48 #include <aknnotewrappers.h>			
    48 #include <aknnotewrappers.h>			
    49 #include <AknInfoPopupNoteController.h> // tooltip
    49 #include <AknInfoPopupNoteController.h> // tooltip
    50 #include <pathconfiguration.hrh>
    50 #include <PathConfiguration.hrh>
    51 #include <featmgr.h>
    51 #include <FeatMgr.h>
    52 #include <MGFetch.h> // Media Fetch
    52 #include <MGFetch.h> // Media Fetch
    53 // General
    53 // General
    54 #include <StringLoader.h>				// strings
    54 #include <StringLoader.h>				// strings
    55 #include <f32file.h>
    55 #include <f32file.h>
    56 #include <thttpfields.h>
    56 #include <THttpFields.h>
    57 #include <textresolver.h>
    57 #include <textresolver.h>
    58 
    58 
    59 // Resources
    59 // Resources
    60 #include <ConeResLoader.h>
    60 #include <coneresloader.h>
    61 #include <BrowserDialogsProvider.rsg>
    61 #include <BrowserDialogsProvider.rsg>
    62 
    62 
    63 // Data Caging
    63 // Data Caging
    64 #include <data_caging_path_literals.hrh>    
    64 #include <data_caging_path_literals.hrh>
    65 
    65 
    66 // CONSTANTS
    66 // CONSTANTS
    67 const TInt KBrCtlObjectElementMaxLength = 50;
    67 const TInt KBrCtlObjectElementMaxLength = 50;
    68 const TInt KBrCtlMBFormat = 4;
    68 const TInt KBrCtlMBFormat = 4;
    69 const TInt KBrCtlGBFormat = 10;
    69 const TInt KBrCtlGBFormat = 10;
    70 const TInt KBrCtlMegabyte = 1000;	// although 1MB=1024 kB, treat as 1000kb for user simplicity
    70 const TInt KBrCtlMegabyte = 1000;	// although 1MB=1024 kB, treat as 1000kb for user simplicity
       
    71 const TInt KBrowserFileNotFound  = -26003; // Defined in ErrorDefs.h but not exported so define here
       
    72 //There is an empty note popup is displayed because of this undefined error code that has been thrown by http layer
       
    73 const TInt KHttpErrIgnore  = -26173;
    71 
    74 
    72 // DLL resource file name with path
    75 // DLL resource file name with path
    73 _LIT( KBrowserDialogsProviderDirAndFile, "z:BrowserDialogsProvider.rsc" );// resource
    76 _LIT( KBrowserDialogsProviderDirAndFile, "z:BrowserDialogsProvider.rsc" );// resource
    74 
    77 
    75 //Mime Types
    78 //Mime Types
   126 //  CBrowserDialogsProvider::~CBrowserDialogsProvider()
   129 //  CBrowserDialogsProvider::~CBrowserDialogsProvider()
   127 //
   130 //
   128 //-----------------------------------------------------------------------------
   131 //-----------------------------------------------------------------------------
   129 CBrowserDialogsProvider::~CBrowserDialogsProvider()
   132 CBrowserDialogsProvider::~CBrowserDialogsProvider()
   130 	{
   133 	{
       
   134 	iDialogs.Close();
       
   135 	iDialogs.ResetAndDestroy();
   131 	iResourceLoader.Close();
   136 	iResourceLoader.Close();
   132 
   137 
   133 	// Delete any dialogs
   138 	// Delete any dialogs
   134 	CancelAll();
   139 	CancelAll();
   135 	
   140 	
   145 //  CBrowserDialogsProvider::DialogNotifyErrorL( TInt aErrCode )
   150 //  CBrowserDialogsProvider::DialogNotifyErrorL( TInt aErrCode )
   146 //
   151 //
   147 //-----------------------------------------------------------------------------
   152 //-----------------------------------------------------------------------------
   148 EXPORT_C void CBrowserDialogsProvider::DialogNotifyErrorL( TInt aErrCode )
   153 EXPORT_C void CBrowserDialogsProvider::DialogNotifyErrorL( TInt aErrCode )
   149 	{
   154 	{
       
   155     if( aErrCode == KHttpErrIgnore )
       
   156        return;
   150     TInt httpErr = KBrCtlHttpErrorsOffset - aErrCode;
   157     TInt httpErr = KBrCtlHttpErrorsOffset - aErrCode;
   151 	CTextResolver* textresolver = CTextResolver::NewLC(); 
   158 	CTextResolver* textresolver = CTextResolver::NewLC(); 
   152 	TPtrC msg;
   159 	TPtrC msg;
   153 		
   160 		
   154     switch ( httpErr )
   161     switch ( httpErr )
   163             DialogNoteL( msg );
   170             DialogNoteL( msg );
   164             break;
   171             break;
   165             }
   172             }
   166         default:
   173         default:
   167             {
   174             {
   168             // Handle all others as system error dialog
   175             // change error code to browser error code, when trying to open file
   169             CCoeEnv::Static()->HandleError( aErrCode );
   176             // that doesn't exist
       
   177             if ( KErrNotFound == aErrCode )
       
   178             	{
       
   179             	iCoeEnv.HandleError( KBrowserFileNotFound );
       
   180             	}
       
   181             else
       
   182             	{
       
   183 				// Handle all others as system error dialog
       
   184             	iCoeEnv.HandleError( aErrCode );
       
   185             	}
   170         	break;
   186         	break;
   171             }
   187             }
   172         }   // end of switch
   188         }   // end of switch
   173 	
   189 	
   174    CleanupStack::PopAndDestroy(); //textresolver
   190    CleanupStack::PopAndDestroy(); //textresolver
   426 EXPORT_C TBool CBrowserDialogsProvider::DialogSelectOptionL(
   442 EXPORT_C TBool CBrowserDialogsProvider::DialogSelectOptionL(
   427 								const TDesC& aTitle, 
   443 								const TDesC& aTitle, 
   428 								TBrCtlSelectOptionType aBrCtlSelectOptionType,
   444 								TBrCtlSelectOptionType aBrCtlSelectOptionType,
   429 								CArrayFix<TBrCtlSelectOptionData>& aOptions )
   445 								CArrayFix<TBrCtlSelectOptionData>& aOptions )
   430 	{
   446 	{
   431     CBrowserSelectElementDlg* dlg = CBrowserSelectElementDlg::NewL(	aTitle, 
   447      iSelectDlg = CBrowserSelectElementDlg::NewL(	aTitle, 
   432 												aBrCtlSelectOptionType, 
   448 												aBrCtlSelectOptionType, 
   433 												aOptions );
   449 												aOptions );
   434 
   450 
   435 	
   451 
   436     iDialogs.Append( dlg );     // Store a pointer to the dialog for CancelAll()
   452 
   437 
   453 	TInt result = iSelectDlg->ExecuteLD();
   438 	TInt result = dlg->ExecuteLD();
   454 
   439 
   455 
   440     RemoveDialogFromArray();
   456     iSelectDlg = 0;
   441     
       
   442     if ( iObserver )
   457     if ( iObserver )
   443         {
   458         {
   444         iObserver->ReportDialogEventL( 
   459         iObserver->ReportDialogEventL( 
   445     	                        MBrowserDialogsProviderObserver::ESelectOption,
   460     	                        MBrowserDialogsProviderObserver::ESelectOption,
   446     	                        ( TInt ) result );    
   461     	                        ( TInt ) result );    
   675 												const TDesC& aMessage,
   690 												const TDesC& aMessage,
   676 												const TDesC& aDefaultInput,
   691 												const TDesC& aDefaultInput,
   677 												HBufC*& aReturnedInput )
   692 												HBufC*& aReturnedInput )
   678 	{
   693 	{
   679     TBool retVal;
   694     TBool retVal;
   680 
   695     TInt length = aDefaultInput.Length();
   681 	// defInput is not modified by the dialog.
   696     if ( aDefaultInput.Length() > KMaxAltTextLength )
   682     TPtr defInput( (TUint16*) aDefaultInput.Ptr(), aDefaultInput.Length(), 
   697         {
   683 													    KMaxAltTextLength );
   698         length = KMaxAltTextLength;
   684 
   699         }
       
   700     // defInput is not modified by the dialog.Truncate if length is greater than KMaxAltTextLength 
       
   701     TPtr defInput( (TUint16*) aDefaultInput.Ptr(), length, KMaxAltTextLength );
       
   702     
   685     CBrowserScriptPromptDialog* dialog = 
   703     CBrowserScriptPromptDialog* dialog = 
   686 		new (ELeave) CBrowserScriptPromptDialog( defInput, aReturnedInput );
   704 		new (ELeave) CBrowserScriptPromptDialog( defInput, aReturnedInput );
   687 
   705 
   688 	iDialogs.Append( dialog );  // Store a pointer to the dialog for CancelAll()
   706 	iDialogs.Append( dialog );  // Store a pointer to the dialog for CancelAll()
   689 
   707 
   969 //  CBrowserDialogsProvider::CancelAll()
   987 //  CBrowserDialogsProvider::CancelAll()
   970 //
   988 //
   971 //-----------------------------------------------------------------------------
   989 //-----------------------------------------------------------------------------
   972 //
   990 //
   973 EXPORT_C void CBrowserDialogsProvider::CancelAll()
   991 EXPORT_C void CBrowserDialogsProvider::CancelAll()
   974 	{
   992     {
   975     // Empty the array
   993 	 if(iSelectDlg  )
   976     iDialogs.ResetAndDestroy();
   994         iSelectDlg->CancelPopup();
       
   995 		
   977 	}
   996 	}
   978 
   997 
   979 //-----------------------------------------------------------------------------
   998 //-----------------------------------------------------------------------------
   980 //  CBrowserDialogsProvider::RemoveDialogFromArray()
   999 //  CBrowserDialogsProvider::RemoveDialogFromArray()
   981 //
  1000 //