widgets/widgetapp/src/WidgetUiDialogsProviderProxy.cpp
changeset 0 dd21522fd290
child 36 0ed94ceaa377
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2005 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 CWidgetUiDialogsProviderProxy class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE Files
       
    20 
       
    21 // User includes
       
    22 #include "WidgetUiDialogsProviderProxy.h"
       
    23 #include "WidgetUiWindowManager.h"
       
    24 #include "WidgetUiWindow.h"
       
    25 #include "WidgetUiWindowView.h"
       
    26 
       
    27 // System includes
       
    28 #include <BrowserDialogsProviderObserver.h>
       
    29 #include <BrowserDialogsProvider.h>
       
    30 
       
    31 // CONSTANTS
       
    32 
       
    33 //-----------------------------------------------------------------------------
       
    34 // CWidgetUiDialogsProviderProxy::CWidgetUiDialogsProviderProxy
       
    35 //-----------------------------------------------------------------------------
       
    36 CWidgetUiDialogsProviderProxy::CWidgetUiDialogsProviderProxy(
       
    37 						    CBrowserDialogsProvider& aDialogsProvider,
       
    38 						    MBrowserDialogsProviderObserver* aDialogsObserver,
       
    39 						    CWidgetUiWindow& aWidgetWindow )
       
    40     : iDialogsProvider( aDialogsProvider ),
       
    41       iDialogsObserver( aDialogsObserver ),
       
    42       iWidgetWindow( aWidgetWindow ),
       
    43       iCancelWaitingDialogs( EFalse )
       
    44 	{
       
    45 	}
       
    46 
       
    47 
       
    48 //-----------------------------------------------------------------------------
       
    49 // CWidgetUiDialogsProviderProxy::~CWidgetUiDialogsProviderProxy
       
    50 //-----------------------------------------------------------------------------
       
    51 CWidgetUiDialogsProviderProxy::~CWidgetUiDialogsProviderProxy()
       
    52 	{
       
    53 	}
       
    54 
       
    55 
       
    56 //-----------------------------------------------------------------------------
       
    57 //	CWidgetUiDialogsProviderProxy* CWidgetUiDialogsProviderProxy::NewL
       
    58 //-----------------------------------------------------------------------------
       
    59 CWidgetUiDialogsProviderProxy* CWidgetUiDialogsProviderProxy::NewL(
       
    60 						    CBrowserDialogsProvider& aDialogsProvider,
       
    61 						    MBrowserDialogsProviderObserver* aDialogsObserver,
       
    62 						    CWidgetUiWindow& aWidgetWindow  )
       
    63 	{
       
    64 	CWidgetUiDialogsProviderProxy* self = new (ELeave)
       
    65 	        CWidgetUiDialogsProviderProxy(   aDialogsProvider,
       
    66 	                                        aDialogsObserver,
       
    67 	                                        aWidgetWindow );
       
    68 
       
    69 	CleanupStack::PushL( self );
       
    70 	self->ConstructL( );
       
    71 	CleanupStack::Pop( self );   // self
       
    72 	return self;
       
    73 	}
       
    74 
       
    75 //-----------------------------------------------------------------------------
       
    76 //  CWidgetUiDialogsProviderProxy::ConstructL
       
    77 //
       
    78 //-----------------------------------------------------------------------------
       
    79 void CWidgetUiDialogsProviderProxy::ConstructL()
       
    80 	{
       
    81 	}
       
    82 
       
    83 
       
    84 //-----------------------------------------------------------------------------
       
    85 //  CWidgetUiDialogsProviderProxy::DialogNotifyErrorL
       
    86 //
       
    87 //-----------------------------------------------------------------------------
       
    88 void CWidgetUiDialogsProviderProxy::DialogNotifyErrorL( TInt aErrCode )
       
    89 	{
       
    90 	HandleDialogRequestL();
       
    91 
       
    92 	// Forward dialog to DialogsProvider if it has not been cancelled
       
    93 	if ( !iCancelWaitingDialogs )
       
    94     	{
       
    95     	iDialogsProvider.DialogNotifyErrorL( aErrCode );
       
    96     	if ( iDialogsObserver )
       
    97     	    {
       
    98     	    iDialogsObserver->ReportDialogEventL(
       
    99                                 MBrowserDialogsProviderObserver::ENotifyError,
       
   100         	                            aErrCode );
       
   101     	    }
       
   102         }
       
   103 	}
       
   104 
       
   105 
       
   106 //-----------------------------------------------------------------------------
       
   107 //  CWidgetUiDialogsProviderProxy::DialogNotifyHttpErrorL
       
   108 //-----------------------------------------------------------------------------
       
   109 void CWidgetUiDialogsProviderProxy::DialogNotifyHttpErrorL(
       
   110 								            TInt aErrCode, const TDesC& aUri )
       
   111 	{
       
   112 	HandleDialogRequestL();
       
   113 
       
   114 	// Forward dialog to DialogsProvider if it has not been cancelled
       
   115 	if ( !iCancelWaitingDialogs )
       
   116     	{
       
   117     	iDialogsProvider.DialogNotifyHttpErrorL( aErrCode, aUri );
       
   118     	if ( iDialogsObserver )
       
   119     	    {
       
   120     	    iDialogsObserver->ReportDialogEventL(
       
   121     	                    MBrowserDialogsProviderObserver::ENotifyHttpError,
       
   122                             NULL );
       
   123     	    }
       
   124     	}
       
   125 	}
       
   126 
       
   127 
       
   128 //-----------------------------------------------------------------------------
       
   129 //  CWidgetUiDialogsProviderProxy::DialogFileSelectLC
       
   130 //-----------------------------------------------------------------------------
       
   131 TBool CWidgetUiDialogsProviderProxy::DialogFileSelectLC(
       
   132                                                     const TDesC& aStartPath,
       
   133 													const TDesC& aRootPath,
       
   134 													HBufC*& aSelectedFileName )
       
   135 	{
       
   136 	TBool retVal( EFalse );
       
   137 
       
   138 	HandleDialogRequestL();
       
   139 
       
   140 	// Forward dialog to DialogsProvider if it has not been cancelled
       
   141 	if ( !iCancelWaitingDialogs )
       
   142     	{
       
   143     	retVal = iDialogsProvider.DialogFileSelectLC( aStartPath,
       
   144     	                                                    aRootPath,
       
   145     	                                                    aSelectedFileName );
       
   146     	}
       
   147 
       
   148 	return retVal;
       
   149 	}
       
   150 
       
   151 //-----------------------------------------------------------------------------
       
   152 //  CWidgetUiDialogsProviderProxy::DialogSelectOptionL
       
   153 //-----------------------------------------------------------------------------
       
   154 TBool CWidgetUiDialogsProviderProxy::DialogSelectOptionL(
       
   155 								const TDesC& aTitle,
       
   156 								TBrCtlSelectOptionType aBrCtlSelectOptionType,
       
   157 								CArrayFix<TBrCtlSelectOptionData>& aOptions )
       
   158 	{
       
   159 	TBool retVal( EFalse );
       
   160 
       
   161 	HandleDialogRequestL();
       
   162 
       
   163 	// Forward dialog to DialogsProvider if it has not been cancelled
       
   164 	if ( !iCancelWaitingDialogs )
       
   165 	    {
       
   166 	    retVal = iDialogsProvider.DialogSelectOptionL(
       
   167 	                                                aTitle,
       
   168 	                                                aBrCtlSelectOptionType,
       
   169 	                                                aOptions );
       
   170 	    }
       
   171 
       
   172 	return retVal;
       
   173 	}
       
   174 
       
   175 
       
   176 //-----------------------------------------------------------------------------
       
   177 // CWidgetUiDialogsProviderProxy::DialogUserAuthenticationLC
       
   178 //-----------------------------------------------------------------------------
       
   179 TBool CWidgetUiDialogsProviderProxy::DialogUserAuthenticationLC(
       
   180 												const TDesC& aUrl,
       
   181 												const TDesC& aRealm,
       
   182 												const TDesC& aDefaultUserName,
       
   183 												HBufC*& aReturnedUserName,
       
   184 												HBufC*& aReturnedPasswd,
       
   185 												TBool aBasicAuthentication )
       
   186 	{
       
   187 	TBool retVal( EFalse );
       
   188 
       
   189 	HandleDialogRequestL();
       
   190 
       
   191 		// Forward dialog to DialogsProvider if it has not been cancelled
       
   192 	if ( !iCancelWaitingDialogs )
       
   193 	    {
       
   194 	    retVal = iDialogsProvider.DialogUserAuthenticationLC(
       
   195 	                                                aUrl,
       
   196 	                                                aRealm,
       
   197 	                                                aDefaultUserName,
       
   198 	                                                aReturnedUserName,
       
   199 	                                                aReturnedPasswd,
       
   200 	                                                aBasicAuthentication );
       
   201 	    if ( iDialogsObserver )
       
   202 	        {
       
   203             iDialogsObserver->ReportDialogEventL(
       
   204                         MBrowserDialogsProviderObserver::EUserAuthentication,
       
   205                         ( TInt ) retVal );
       
   206 	        }
       
   207 	    }
       
   208 
       
   209 	return retVal;
       
   210 	}
       
   211 
       
   212 
       
   213 //-----------------------------------------------------------------------------
       
   214 //  CWidgetUiDialogsProviderProxy::DialogNoteL
       
   215 //-----------------------------------------------------------------------------
       
   216 void CWidgetUiDialogsProviderProxy::DialogNoteL( const TDesC& aMessage )
       
   217 	{
       
   218 	HandleDialogRequestL();
       
   219 
       
   220     // Forward dialog to DialogsProvider if it has not been cancelled
       
   221 	if ( !iCancelWaitingDialogs )
       
   222 	    {
       
   223 	    iDialogsProvider.DialogNoteL( aMessage );
       
   224 	    }
       
   225 	}
       
   226 
       
   227 
       
   228 //-----------------------------------------------------------------------------
       
   229 //  CWidgetUiDialogsProviderProxy::DialogAlertL
       
   230 //-----------------------------------------------------------------------------
       
   231 void CWidgetUiDialogsProviderProxy::DialogAlertL( const TDesC& aTitle,
       
   232 											        const TDesC& aMessage )
       
   233 	{
       
   234 	HandleDialogRequestL();
       
   235 
       
   236 	// Forward dialog to DialogsProvider if it has not been cancelled
       
   237 	if ( !iCancelWaitingDialogs )
       
   238 	    {
       
   239 	    iDialogsProvider.DialogAlertL( aTitle, aMessage );
       
   240 	    }
       
   241 	}
       
   242 
       
   243 
       
   244 //-----------------------------------------------------------------------------
       
   245 //  CWidgetUiDialogsProviderProxy::DialogConfirmL
       
   246 //-----------------------------------------------------------------------------
       
   247 TBool CWidgetUiDialogsProviderProxy::DialogConfirmL( const TDesC& aTitle,
       
   248 												    const TDesC& aMessage,
       
   249 												    const TDesC& aYesMessage,
       
   250 												    const TDesC& aNoMessage )
       
   251 	{
       
   252 	TBool retVal( EFalse );
       
   253 
       
   254 	HandleDialogRequestL();
       
   255 
       
   256 		// Forward dialog to DialogsProvider if it has not been cancelled
       
   257 	if ( !iCancelWaitingDialogs )
       
   258 	    {
       
   259 	    retVal = iDialogsProvider.DialogConfirmL( aTitle, aMessage,
       
   260 	                                                aYesMessage, aNoMessage );
       
   261 	    }
       
   262 
       
   263     return retVal;
       
   264 	}
       
   265 
       
   266 //-----------------------------------------------------------------------------
       
   267 // CWidgetUiDialogsProviderProxy::DialogPromptLC
       
   268 //-----------------------------------------------------------------------------
       
   269 TBool CWidgetUiDialogsProviderProxy::DialogPromptLC( const TDesC& aTitle,
       
   270 												const TDesC& aMessage,
       
   271 												const TDesC& aDefaultInput,
       
   272 												HBufC*& aReturnedInput )
       
   273 	{
       
   274 	TBool retVal( EFalse );
       
   275 	HandleDialogRequestL();
       
   276 
       
   277 	// Forward dialog to DialogsProvider if it has not been cancelled
       
   278 	if ( !iCancelWaitingDialogs )
       
   279 	    {
       
   280 	    retVal = iDialogsProvider.DialogPromptLC( aTitle, aMessage,
       
   281                                             aDefaultInput, aReturnedInput );
       
   282 	    }
       
   283 
       
   284     return retVal;
       
   285 	}
       
   286 
       
   287 //-----------------------------------------------------------------------------
       
   288 //  CWidgetUiDialogsProviderProxy::DialogDownloadObjectL
       
   289 //-----------------------------------------------------------------------------
       
   290 TBool CWidgetUiDialogsProviderProxy::DialogDownloadObjectL(
       
   291 										CBrCtlObjectInfo* aBrCtlObjectInfo )
       
   292 	{
       
   293 	HandleDialogRequestL();
       
   294 	TBool retVal = iDialogsProvider.DialogDownloadObjectL( aBrCtlObjectInfo );
       
   295 	return retVal;
       
   296 	}
       
   297 
       
   298 //-----------------------------------------------------------------------------
       
   299 // CWidgetUiDialogsProviderProxy::DialogDisplayPageImagesL
       
   300 //-----------------------------------------------------------------------------
       
   301 void CWidgetUiDialogsProviderProxy::DialogDisplayPageImagesL(
       
   302 							CArrayFixFlat<TBrCtlImageCarrier>& aPageImages )
       
   303 	{
       
   304     HandleDialogRequestL();
       
   305 
       
   306 	// Forward dialog to DialogsProvider if it has not been cancelled
       
   307 	if ( !iCancelWaitingDialogs )
       
   308 	    {
       
   309 	    iDialogsProvider.DialogDisplayPageImagesL( aPageImages );
       
   310 	    }
       
   311 	}
       
   312 
       
   313 
       
   314 //-----------------------------------------------------------------------------
       
   315 //  CWidgetUiDialogsProviderProxy::CancelAll
       
   316 //-----------------------------------------------------------------------------
       
   317 //
       
   318 void CWidgetUiDialogsProviderProxy::CancelAll()
       
   319 	{
       
   320 	// Dialogs should be flushed, but not displayed
       
   321     iCancelWaitingDialogs = ETrue;
       
   322     iDialogsProvider.CancelAll();
       
   323 	}
       
   324 
       
   325 //-----------------------------------------------------------------------------
       
   326 //  CWidgetUiDialogsProviderProxy::DialogMimeFileSelectLC
       
   327 //-----------------------------------------------------------------------------
       
   328 TBool CWidgetUiDialogsProviderProxy::DialogMimeFileSelectLC(
       
   329 													HBufC*& aSelectedFileName,
       
   330 													const TDesC& aMimeType )
       
   331 	{
       
   332 	TBool retVal( EFalse );
       
   333 
       
   334 	HandleDialogRequestL();
       
   335 
       
   336 	// Forward dialog to DialogsProvider if it has not been cancelled
       
   337 	if ( !iCancelWaitingDialogs )
       
   338     	{
       
   339     	retVal = iDialogsProvider.DialogMimeFileSelectLC( aSelectedFileName,
       
   340     	                                                  aMimeType );
       
   341     	}
       
   342 
       
   343 	return retVal;
       
   344 	}
       
   345 
       
   346 //-----------------------------------------------------------------------------
       
   347 //  CWidgetUiDialogsProviderProxy::ShowTooltipL
       
   348 //-----------------------------------------------------------------------------
       
   349 //
       
   350 void CWidgetUiDialogsProviderProxy::ShowTooltipL(    const TDesC& aText,
       
   351                                                     TInt aDuration,
       
   352                                                     TInt aDelay )
       
   353     {
       
   354     HandleDialogRequestL();
       
   355     if ( !iCancelWaitingDialogs )
       
   356         {
       
   357         iDialogsProvider.ShowTooltipL(   aText, aDuration, aDelay );
       
   358         }
       
   359     }
       
   360 
       
   361 //-----------------------------------------------------------------------------
       
   362 //  CWidgetUiDialogsProviderProxy::UploadProgressNoteL
       
   363 //-----------------------------------------------------------------------------
       
   364 //
       
   365 void CWidgetUiDialogsProviderProxy::UploadProgressNoteL(
       
   366                                 TInt32 aTotalSize,
       
   367                                 TInt32 aChunkSize,
       
   368                                 TBool aIsLastChunk,
       
   369                                 MBrowserDialogsProviderObserver* aObserver )
       
   370     {
       
   371     HandleDialogRequestL();
       
   372 
       
   373     // Forward dialog to DialogsProvider if it has not been cancelled
       
   374 	if ( !iCancelWaitingDialogs )
       
   375 	    {
       
   376 	    iDialogsProvider.UploadProgressNoteL(   aTotalSize,
       
   377 	                                            aChunkSize,
       
   378 	                                            aIsLastChunk,
       
   379 	                                            aObserver );
       
   380 	    }
       
   381 
       
   382     }
       
   383 
       
   384 //-----------------------------------------------------------------------------
       
   385 //  CWidgetUiDialogsProviderProxy::HandleDialogRequestL()
       
   386 //-----------------------------------------------------------------------------
       
   387 //
       
   388 void CWidgetUiDialogsProviderProxy::HandleDialogRequestL()
       
   389     {
       
   390     // Dialogs for background windows must be blocked
       
   391 	// Also, if options menu is loaded,  then alert dialogs must be blocked
       
   392 	iCancelWaitingDialogs = ( iWidgetWindow.WidgetMiniViewState() == EPublishStart
       
   393     						||(iWidgetWindow.WindowManager().View())->IsOptionsMenuActivated());
       
   394     if ( !iCancelWaitingDialogs)
       
   395         iCancelWaitingDialogs = ((iWidgetWindow.WindowManager().ActiveWindow())?
       
   396                     (iWidgetWindow.WindowManager().ActiveWindow() != &iWidgetWindow):
       
   397                     (ETrue));
       
   398     }
       
   399 
       
   400 
       
   401 //  End of File