launcher/src/launcherappui.cpp
branchRCL_3
changeset 22 fad26422216a
equal deleted inserted replaced
21:b3cee849fa46 22:fad26422216a
       
     1 /*
       
     2 * Copyright (c) 2009 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "launcherappui.h"
       
    21 #include "launcherviewapps.h"
       
    22 #include "launcherviewoutput.h"
       
    23 #include <launcher.rsg>
       
    24 #include "launcher.hrh"
       
    25 
       
    26 #include <avkon.hrh>
       
    27 #include <aknnotewrappers.h>
       
    28 #include <eikmenup.h>
       
    29 #include <aknmessagequerydialog.h>
       
    30 
       
    31 
       
    32 // ================= MEMBER FUNCTIONS =======================
       
    33 //
       
    34 // ----------------------------------------------------------
       
    35 // CLauncherAppUi::ConstructL()
       
    36 // ?implementation_description
       
    37 // ----------------------------------------------------------
       
    38 //
       
    39 void CLauncherAppUi::ConstructL()
       
    40     {
       
    41     BaseConstructL(EAknEnableSkin);
       
    42     #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 )
       
    43     iSendUi = CSendUi::NewL();
       
    44     #endif
       
    45     // Show tabs for main views from resources
       
    46     CEikStatusPane* sp = StatusPane();
       
    47 
       
    48     // Fetch pointer to the default navi pane control
       
    49     iNaviPane = (CAknNavigationControlContainer*)sp->ControlL( 
       
    50         TUid::Uid(EEikStatusPaneUidNavi));
       
    51 
       
    52     // Tabgroup has been read from resource and it were pushed to the navi pane. 
       
    53     // Get pointer to the navigation decorator with the ResourceDecorator() function. 
       
    54     // Application owns the decorator and it has responsibility to delete the object.
       
    55     iDecoratedTabGroup = iNaviPane->ResourceDecorator();
       
    56     if (iDecoratedTabGroup)
       
    57         {
       
    58         iTabGroup = (CAknTabGroup*) iDecoratedTabGroup->DecoratedControl();
       
    59         }
       
    60 
       
    61     // init the engine class
       
    62     iEngine = CLauncherEngine::NewL(this);
       
    63 
       
    64     // init the apps view
       
    65     CLauncherViewApps* view1 = new (ELeave) CLauncherViewApps;
       
    66     CleanupStack::PushL( view1 );
       
    67     view1->ConstructL(iEngine);
       
    68     AddViewL( view1 );      // transfer ownership to CAknViewAppUi
       
    69     CleanupStack::Pop();    // view1
       
    70 
       
    71     // init the output view
       
    72     CLauncherViewOutput* view2 = new (ELeave) CLauncherViewOutput;
       
    73     CleanupStack::PushL( view2 );
       
    74     view2->ConstructL(iEngine);
       
    75     AddViewL( view2 );      // transfer ownership to CAknViewAppUi
       
    76     CleanupStack::Pop();    // view2
       
    77 
       
    78     // set apps view as default
       
    79     SetDefaultViewL(*view1);
       
    80 
       
    81     }
       
    82 
       
    83 // ----------------------------------------------------
       
    84 // CLauncherAppUi::~CLauncherAppUi()
       
    85 // Destructor
       
    86 // Frees reserved resources
       
    87 // ----------------------------------------------------
       
    88 //
       
    89 CLauncherAppUi::~CLauncherAppUi()
       
    90     {
       
    91     delete iEngine;
       
    92 
       
    93     delete iDecoratedTabGroup;
       
    94     #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 )
       
    95     delete iSendUi;
       
    96     #endif
       
    97     }
       
    98 
       
    99 // ------------------------------------------------------------------------------
       
   100 // CLauncherAppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
       
   101 //  This function is called by the EIKON framework just before it displays
       
   102 //  a menu pane. Its default implementation is empty, and by overriding it,
       
   103 //  the application can set the state of menu items dynamically according
       
   104 //  to the state of application data.
       
   105 // ------------------------------------------------------------------------------
       
   106 //
       
   107 void CLauncherAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
       
   108     {
       
   109     if (aResourceId == R_LAUNCHER_APP_MENU)
       
   110         {
       
   111         // launch stop check
       
   112         aMenuPane->SetItemDimmed(ECmdStopLaunch, !iEngine->LaunchingIsActive());
       
   113 
       
   114         // deleting log is possible only when the log exists
       
   115         aMenuPane->SetItemDimmed(ECmdDeleteLog, !(iEngine->LogFileExists() || iEngine->BCLogFileExists()));
       
   116 
       
   117         // SendUI for the log file
       
   118 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 )
       
   119         if (iEngine->LogFileExists() || iEngine->BCLogFileExists())
       
   120             {
       
   121             TInt index(0);
       
   122             aMenuPane->ItemAndPos( ECmdDeleteLog, index );
       
   123             iSendUi->AddSendMenuItemL(*aMenuPane, index-1, ECmdSendUILogFile, TSendingCapabilities(0, 0, TSendingCapabilities::ESupportsAttachments));
       
   124             aMenuPane->SetItemTextL(ECmdSendUILogFile, _L("Send log(s)"));
       
   125             }
       
   126 #endif
       
   127         }
       
   128 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 )
       
   129     else if (aResourceId == R_LAUNCHER_DLLINFO_SUBMENU)
       
   130         {
       
   131         //SendUI for the system dll file
       
   132         TInt index(0);
       
   133         aMenuPane->ItemAndPos( ECmdCompareDLLs, index );
       
   134 
       
   135         iSendUi->AddSendMenuItemL(*aMenuPane, index, ECmdSendUISystemDllFile, TSendingCapabilities(0, 0, TSendingCapabilities::ESupportsAttachments));
       
   136         aMenuPane->SetItemTextL(ECmdSendUISystemDllFile, _L("Send list of DLLs"));
       
   137         aMenuPane->SetItemButtonState(ECmdSendUISystemDllFile, EEikMenuItemSymbolIndeterminate); 
       
   138         }
       
   139 #endif
       
   140     }
       
   141 
       
   142 // ----------------------------------------------------
       
   143 // CLauncherAppUi::HandleKeyEventL(
       
   144 //     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
       
   145 // ----------------------------------------------------
       
   146 //
       
   147 TKeyResponse CLauncherAppUi::HandleKeyEventL(
       
   148     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
       
   149     {
       
   150     if ( iTabGroup == NULL )
       
   151         {
       
   152         return EKeyWasNotConsumed;
       
   153         }
       
   154 
       
   155     TInt active = iTabGroup->ActiveTabIndex();
       
   156     TInt count = iTabGroup->TabCount();
       
   157 
       
   158     switch ( aKeyEvent.iCode )
       
   159         {
       
   160         case EKeyLeftArrow:
       
   161             if ( active > 0 )
       
   162                 {
       
   163                 active--;
       
   164                 iTabGroup->SetActiveTabByIndex( active );
       
   165                 ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
       
   166                 }
       
   167             break;
       
   168         case EKeyRightArrow:
       
   169             if( (active + 1) < count )
       
   170                 {
       
   171                 active++;
       
   172                 iTabGroup->SetActiveTabByIndex( active );
       
   173                 ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
       
   174                 }
       
   175             break;
       
   176         default:
       
   177             return EKeyWasNotConsumed;
       
   178         }
       
   179 
       
   180     return EKeyWasConsumed;
       
   181     }
       
   182 
       
   183 // ----------------------------------------------------
       
   184 // CLauncherAppUi::HandleCommandL(TInt aCommand)
       
   185 // ----------------------------------------------------
       
   186 //
       
   187 void CLauncherAppUi::HandleCommandL(TInt aCommand)
       
   188     {
       
   189     switch ( aCommand )
       
   190         {
       
   191         case EEikCmdExit:
       
   192         case EAknSoftkeyExit:
       
   193             {
       
   194             Exit();
       
   195             break;
       
   196             }
       
   197         case ECmdDeleteLog:
       
   198             {
       
   199             TInt ret = KErrNone;
       
   200             
       
   201             if( iEngine->LogFileExists())
       
   202                 {
       
   203                 ret = iEngine->DeleteLogFile();
       
   204                 }
       
   205             if (ret == KErrNone)                
       
   206                 {
       
   207                 if( iEngine->BCLogFileExists())
       
   208                     {
       
   209                     ret = iEngine->DeleteBCLogFile();
       
   210                     }
       
   211                 }            
       
   212             if( ret == KErrNone )
       
   213                 {
       
   214                 _LIT(KMessage, "Log file(s) deleted");
       
   215                 CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
       
   216                 note->ExecuteLD(KMessage);
       
   217                 }
       
   218             else
       
   219                 {
       
   220                 _LIT(KMessage, "Unable to delete");
       
   221                 CAknErrorNote* note = new(ELeave) CAknErrorNote;
       
   222                 note->ExecuteLD(KMessage);
       
   223                 }
       
   224             break;
       
   225             }        
       
   226         case ECmdCompareDLLs:
       
   227             {
       
   228             iEngine->AnalyseDLLsL();
       
   229             break;
       
   230             }
       
   231 
       
   232         case ECmdAbout:
       
   233             {
       
   234 	        CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog;
       
   235             dialog->ExecuteLD(R_LAUNCHER_ABOUT_DIALOG);
       
   236 
       
   237             break;
       
   238             }
       
   239 
       
   240         case ECmdStopLaunch:
       
   241             {
       
   242             iEngine->StopLaunchingL();
       
   243             break;
       
   244             }
       
   245 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 )
       
   246         case ECmdSendUILogFile:
       
   247             {
       
   248             iEngine->SendLogViaSendUiL(iSendUi);
       
   249             break;
       
   250             }
       
   251 
       
   252         case ECmdSendUISystemDllFile:
       
   253             {
       
   254             iEngine->SendListOfSystemDllsViaSendUiL(iSendUi);
       
   255             break;
       
   256             }
       
   257 #endif
       
   258         case EAknSoftkeyCancel:
       
   259             {
       
   260             iEngine->Cancel();
       
   261             break;
       
   262             }
       
   263         default:
       
   264             {
       
   265             }
       
   266             break;      
       
   267         }
       
   268     }
       
   269 
       
   270 // End of File