hotspotfw/hsbrowser/src/hsbrowserappui.cpp
branchRCL_3
changeset 25 f28ada11abbf
parent 0 56b72877c1cb
equal deleted inserted replaced
24:63be7eb3fc78 25:f28ada11abbf
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   The UI class for HotSpot Browser Application.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <avkon.hrh>
       
    22 #include <es_enum.h>
       
    23 #include <hsbrowser.rsg>
       
    24 #include <akntitle.h>
       
    25 #include <AknUtils.h>
       
    26 #include <hlplch.h>
       
    27 
       
    28 #include "hsbrowserappui.h"
       
    29 #include "hsbrowsercontainer.h" 
       
    30 #include "hsbrowserdocument.h"
       
    31 #include "hsbrowsercommon.h"
       
    32 #include "am_debug.h"
       
    33 
       
    34 // ================= MEMBER FUNCTIONS =======================
       
    35 //
       
    36 // ----------------------------------------------------------
       
    37 // CHsBrowserAppUi::ConstructL()
       
    38 // ----------------------------------------------------------
       
    39 //
       
    40 void CHsBrowserAppUi::ConstructL()
       
    41     {
       
    42     DEBUG( "CHsBrowserAppUi::ConstructL()" );
       
    43     BaseConstructL( CAknAppUi::EAknEnableSkin );
       
    44     CHsBrowserModel* model;
       
    45     model = static_cast<CHsBrowserDocument*>(iDocument)->Model();
       
    46     iAppContainer = new (ELeave) CHsBrowserContainer( model );
       
    47     iAppContainer->SetMopParent( this );
       
    48     iAppContainer->ConstructL( ClientRect() );
       
    49     AddToStackL( iAppContainer );
       
    50     }
       
    51 
       
    52 // ----------------------------------------------------
       
    53 // CHsBrowserAppUi::~CHsBrowserAppUi()
       
    54 // Destructor
       
    55 // Frees reserved resources
       
    56 // ----------------------------------------------------
       
    57 //
       
    58 CHsBrowserAppUi::~CHsBrowserAppUi()
       
    59     {
       
    60     DEBUG( "CHsBrowserAppUi::~CHsBrowserAppUi()" );
       
    61     if ( iAppContainer )
       
    62         {
       
    63         RemoveFromStack( iAppContainer );
       
    64         delete iAppContainer;
       
    65         }        
       
    66    }
       
    67 
       
    68 // ----------------------------------------------------
       
    69 // CHsBrowserAppUi::ProcessCommandParametersL
       
    70 // ----------------------------------------------------
       
    71 //
       
    72 TBool CHsBrowserAppUi::ProcessCommandParametersL(
       
    73     CApaCommandLine& aCommandLine )
       
    74     {
       
    75     DEBUG( "CHsBrowserAppUi::ProcessCommandParametersL()" );
       
    76     
       
    77     TApaTaskList taskList( CEikonEnv::Static()->WsSession() );
       
    78 	TApaTask task = taskList.FindApp( KUidHsBrowserApp );
       
    79     task.BringToForeground();
       
    80     
       
    81     TBuf<KBufSize> args;
       
    82     args.Copy( aCommandLine.DocumentName() );
       
    83 
       
    84     if ( args.Length() == 0 )
       
    85     {
       
    86         // No arguments, meaning started from application menu.
       
    87         // Continue normally, for testing purposes
       
    88         return EFalse;	
       
    89     }    
       
    90     
       
    91     TLex wordLex( args );
       
    92     TPtrC word;
       
    93     // get IAP ID
       
    94     word.Set( wordLex.NextToken() );
       
    95     TInt iapId;
       
    96     TLex x1( word );
       
    97     TInt err = x1.Val( iapId );
       
    98     if ( err != KErrNone )
       
    99         {
       
   100         DEBUG1( "CHsBrowserAppUi::ProcessCommandParametersL() x1.Val(), err=%d",
       
   101             err );
       
   102         }
       
   103     // get net ID
       
   104     word.Set( wordLex.NextToken() );
       
   105     TInt netId;
       
   106     TLex x2( word );
       
   107     err = x2.Val( netId );
       
   108     if ( err != KErrNone )
       
   109         {
       
   110         DEBUG1( "CHsBrowserAppUi::ProcessCommandParametersL() x2.Val(), err=%d",
       
   111             err );
       
   112         }
       
   113     // get URL
       
   114     TPtrC url( wordLex.NextToken() );
       
   115     
       
   116     err = iAppContainer->LoadRedirect( url, iapId, netId );
       
   117     if ( err != KErrNone )
       
   118         {
       
   119         DEBUG1( "CHsBrowserAppUi::ProcessCommandParametersL() LoadRedirect(), err=%d",
       
   120             err );
       
   121         }
       
   122 	return EFalse;
       
   123 }
       
   124 
       
   125 // ----------------------------------------------------
       
   126 // CHsBrowserAppUi::HandleCommandL(TInt aCommand)
       
   127 // ----------------------------------------------------
       
   128 //
       
   129 void CHsBrowserAppUi::HandleCommandL( TInt aCommand )
       
   130     {
       
   131     DEBUG1( "CHsBrowserAppUi::HandleCommandL() aCommmand=%d", aCommand );
       
   132     
       
   133     switch ( aCommand )
       
   134         {
       
   135         case EAknSoftkeyCancel:
       
   136             {          
       
   137             iAppContainer->HandleCommandL( aCommand );
       
   138             Exit();                	
       
   139             break;
       
   140             }
       
   141         case EAknSoftkeyClose:
       
   142             {
       
   143             // Now for sure we know that we are in input box. 
       
   144             // Next close aCommand should be treated as EAknSoftkeyCancel
       
   145             iAppContainer->SetActiveInputBox( ETrue );
       
   146             // change softkey to Cancel...
       
   147         	CEikButtonGroupContainer* cba = CEikonEnv::Static()->
       
   148                 AppUiFactory()->Cba();
       
   149             if ( cba )
       
   150             	{
       
   151                 cba->SetCommandSetL( R_AVKON_SOFTKEYS_CANCEL );
       
   152                 cba->DrawNow();
       
   153             	}
       
   154         	break;
       
   155             }
       
   156         case EAknSoftkeyExit:
       
   157         case EAknSoftkeyBack:
       
   158         case EEikCmdExit:
       
   159             {
       
   160             iAppContainer->HandleCommandL( aCommand );
       
   161             Exit();
       
   162             break;
       
   163             }
       
   164         case EAknCmdHelp:
       
   165             {
       
   166             HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(),
       
   167                 AppHelpContextL());
       
   168             break;
       
   169             }
       
   170 
       
   171         default:
       
   172             iAppContainer->HandleCommandL( aCommand );
       
   173             break;      
       
   174         }
       
   175     }
       
   176     
       
   177 // ----------------------------------------------------
       
   178 // CHsBrowserAppUi::HandleKeyEventL()
       
   179 // ----------------------------------------------------
       
   180 //
       
   181 TKeyResponse CHsBrowserAppUi::HandleKeyEventL(
       
   182     const TKeyEvent& aKeyEvent,TEventCode aType)
       
   183     {
       
   184     //DEBUG( "CHsBrowserAppUi::HandleKeyEventL()" )
       
   185     return iAppContainer->HandleKeyEventL(aKeyEvent, aType);
       
   186     }
       
   187  
       
   188 // ---------------------------------------------------------
       
   189 // CHsBrowserAppUi::HandleForegroundEventL()
       
   190 // ---------------------------------------------------------
       
   191 //
       
   192 void CHsBrowserAppUi::HandleForegroundEventL( TBool aForeground )
       
   193     {
       
   194     DEBUG( "CHsBrowserAppUi::HandleForegroundEventL()" );
       
   195  
       
   196     CAknAppUi::HandleForegroundEventL( aForeground );
       
   197     if ( iAppContainer )
       
   198    	    {
       
   199         iAppContainer->ProcessForegroundEvent( aForeground );
       
   200         }
       
   201     }
       
   202     
       
   203     
       
   204 // End of File