examples/sfexamples/Wikipedia/src/DetailContainer.cpp

00001 // 
00002 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
00003 // All rights reserved.
00004 // This component and the accompanying materials are made available
00005 // under the terms of the License "Eclipse Public License v1.0"
00006 // which accompanies this distribution, and is available
00007 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00008 // 
00009 // Initial Contributors:
00010 // Nokia Corporation - initial contribution.
00011 // 
00012 // Contributors:
00013 // 
00014 // Description:
00015 // 
00016 
00017 
00018 // INCLUDE FILES
00019 #include "DetailContainer.h"
00020 #include "DetailView.h"
00021 #include "SqlSrvDemoAppUi.h"
00022 #include "WikiDb.h"
00023 #include <charconv.h>
00024 #include <aknquerydialog.h>
00025 #include <SqlSrvDemo.rsg>
00026 
00027 _LIT(KConfirmText, "Leave database content to go to online Wikipedia page?");
00028 
00029 // ========================= MEMBER FUNCTIONS ==================================
00030 
00031 // -----------------------------------------------------------------------------
00032 // CDetailContainer::NewL()
00033 // Two-phased constructor.
00034 // -----------------------------------------------------------------------------
00035 //
00036 CDetailContainer* CDetailContainer::NewL( const TRect& aRect, CDetailView& aView )
00037     {
00038     CDetailContainer* self = CDetailContainer::NewLC( aRect, aView );
00039     CleanupStack::Pop( self );
00040     return self;
00041     }
00042 
00043 // -----------------------------------------------------------------------------
00044 // CDetailContainer::NewLC()
00045 // Two-phased constructor.
00046 // -----------------------------------------------------------------------------
00047 //
00048 CDetailContainer* CDetailContainer::NewLC( const TRect& aRect, CDetailView& aView )
00049     {
00050     CDetailContainer* self = new ( ELeave ) CDetailContainer( aView );
00051     CleanupStack::PushL( self );
00052     self->ConstructL( aRect );
00053     return self;
00054     }
00055 
00056 // -----------------------------------------------------------------------------
00057 // CDetailContainer::ConstructL()
00058 // Symbian 2nd phase constructor can leave.
00059 // -----------------------------------------------------------------------------
00060 //
00061 void CDetailContainer::ConstructL( const TRect& aRect )
00062     {
00063     CBrowserContainer::ConstructL(aRect);  
00064     iBrowser->AddLoadEventObserverL( this );
00065     
00066     _LIT( KUrl, "data:wikipedia" );
00067     _LIT8( KDataType, "text/html" );
00068 
00069     TDataType dataType( KDataType() );
00070     TUid uid;
00071     uid.iUid = KCharacterSetIdentifierIso88591;
00072     
00073         const TDesC8& articleText = iWikiEngine.GetCurrentArticleContentL();            
00074         
00075         // This S60 code causes a memory leak
00076         iBrowser->LoadDataL( KUrl, articleText, dataType, uid );
00077         
00078         ScrollBrowserToTopL();
00079     }
00080 
00081 CDetailContainer::CDetailContainer( CDetailView& aView ) :
00082         CBrowserContainer(aView),
00083         iWikiEngine( CSqlSrvDemoAppUi::WikiEngine() )
00084         {
00085         // No implementation
00086         }
00087 
00088 //-----------------------------------------------------------------------------
00089 // CDetailContainer::OfferKeyEventL
00090 // 
00091 // (other items were commented in a header).
00092 // -----------------------------------------------------------------------------
00093 //
00094 TKeyResponse CDetailContainer::OfferKeyEventL(
00095     const TKeyEvent& aKeyEvent, TEventCode aType )
00096     {
00097     TBool passToBrowser = ETrue;
00098     
00099     if (( aKeyEvent.iCode == EKeyDevice3 ) && ( !iOnlineConfirmed ) ) 
00100         {
00101         CAknQueryDialog* dialog = new ( ELeave ) CAknQueryDialog();
00102         dialog->SetPromptL( KConfirmText );
00103         passToBrowser = dialog->ExecuteLD( R_CONFIRM_QUERY );
00104         iOnlineConfirmed = passToBrowser;
00105         }
00106 
00107     if ( passToBrowser && iBrowser )
00108         {
00109         return iBrowser->OfferKeyEventL( aKeyEvent, aType );
00110         }
00111     return EKeyWasConsumed;
00112     }
00113 
00114 void CDetailContainer::HandleBrowserLoadEventL( TBrCtlDefs::TBrCtlLoadEvent aLoadEvent,
00115                 TUint /* aSize */, TUint16 /* aTransactionId */ )
00116         {
00117         if ( aLoadEvent == TBrCtlDefs::EEventNewContentDisplayed && iOnlineConfirmed )
00118                 {
00119             iBrowser->SetBrowserSettingL( TBrCtlDefs::ESettingsFontSize, TBrCtlDefs::EFontSizeLevelAllSmall );          
00120                 }
00121         }
00122 
00123 // End of File

Generated by  doxygen 1.6.2