launcher/src/launcherappui.cpp
changeset 0 d6fe6244b863
child 7 685c7418c584
equal deleted inserted replaced
-1:000000000000 0:d6fe6244b863
       
     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 
       
    43     iSendUi = CSendUi::NewL();
       
    44 
       
    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 
       
    95     delete iSendUi;
       
    96     }
       
    97 
       
    98 // ------------------------------------------------------------------------------
       
    99 // CLauncherAppUi::::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
       
   100 //  This function is called by the EIKON framework just before it displays
       
   101 //  a menu pane. Its default implementation is empty, and by overriding it,
       
   102 //  the application can set the state of menu items dynamically according
       
   103 //  to the state of application data.
       
   104 // ------------------------------------------------------------------------------
       
   105 //
       
   106 void CLauncherAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)
       
   107     {
       
   108     if (aResourceId == R_LAUNCHER_APP_MENU)
       
   109         {
       
   110         // launch stop check
       
   111         aMenuPane->SetItemDimmed(ECmdStopLaunch, !iEngine->LaunchingIsActive());
       
   112 
       
   113         // deleting log is possible only when the log exists
       
   114         aMenuPane->SetItemDimmed(ECmdDeleteLog, !(iEngine->LogFileExists() || iEngine->BCLogFileExists()));
       
   115 
       
   116         // SendUI for the log file
       
   117         if (iEngine->LogFileExists() || iEngine->BCLogFileExists())
       
   118             {
       
   119             TInt index(0);
       
   120             aMenuPane->ItemAndPos( ECmdDeleteLog, index );
       
   121             iSendUi->AddSendMenuItemL(*aMenuPane, index-1, ECmdSendUILogFile, TSendingCapabilities(0, 0, TSendingCapabilities::ESupportsAttachments));
       
   122             aMenuPane->SetItemTextL(ECmdSendUILogFile, _L("Send log(s)"));
       
   123             }
       
   124         }
       
   125 
       
   126     else if (aResourceId == R_LAUNCHER_DLLINFO_SUBMENU)
       
   127         {
       
   128         //SendUI for the system dll file
       
   129         TInt index(0);
       
   130         aMenuPane->ItemAndPos( ECmdCompareDLLs, index );
       
   131 
       
   132         iSendUi->AddSendMenuItemL(*aMenuPane, index, ECmdSendUISystemDllFile, TSendingCapabilities(0, 0, TSendingCapabilities::ESupportsAttachments));
       
   133         aMenuPane->SetItemTextL(ECmdSendUISystemDllFile, _L("Send list of DLLs"));
       
   134         aMenuPane->SetItemButtonState(ECmdSendUISystemDllFile, EEikMenuItemSymbolIndeterminate); 
       
   135         }
       
   136     }
       
   137 
       
   138 // ----------------------------------------------------
       
   139 // CLauncherAppUi::HandleKeyEventL(
       
   140 //     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
       
   141 // ----------------------------------------------------
       
   142 //
       
   143 TKeyResponse CLauncherAppUi::HandleKeyEventL(
       
   144     const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
       
   145     {
       
   146     if ( iTabGroup == NULL )
       
   147         {
       
   148         return EKeyWasNotConsumed;
       
   149         }
       
   150 
       
   151     TInt active = iTabGroup->ActiveTabIndex();
       
   152     TInt count = iTabGroup->TabCount();
       
   153 
       
   154     switch ( aKeyEvent.iCode )
       
   155         {
       
   156         case EKeyLeftArrow:
       
   157             if ( active > 0 )
       
   158                 {
       
   159                 active--;
       
   160                 iTabGroup->SetActiveTabByIndex( active );
       
   161                 ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
       
   162                 }
       
   163             break;
       
   164         case EKeyRightArrow:
       
   165             if( (active + 1) < count )
       
   166                 {
       
   167                 active++;
       
   168                 iTabGroup->SetActiveTabByIndex( active );
       
   169                 ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
       
   170                 }
       
   171             break;
       
   172         default:
       
   173             return EKeyWasNotConsumed;
       
   174         }
       
   175 
       
   176     return EKeyWasConsumed;
       
   177     }
       
   178 
       
   179 // ----------------------------------------------------
       
   180 // CLauncherAppUi::HandleCommandL(TInt aCommand)
       
   181 // ----------------------------------------------------
       
   182 //
       
   183 void CLauncherAppUi::HandleCommandL(TInt aCommand)
       
   184     {
       
   185     switch ( aCommand )
       
   186         {
       
   187         case EEikCmdExit:
       
   188         case EAknSoftkeyExit:
       
   189             {
       
   190             Exit();
       
   191             break;
       
   192             }
       
   193         case ECmdDeleteLog:
       
   194             {
       
   195             TInt ret = KErrNone;
       
   196             
       
   197             if( iEngine->LogFileExists())
       
   198                 {
       
   199                 ret = iEngine->DeleteLogFile();
       
   200                 }
       
   201             if (ret == KErrNone)                
       
   202                 {
       
   203                 if( iEngine->BCLogFileExists())
       
   204                     {
       
   205                     ret = iEngine->DeleteBCLogFile();
       
   206                     }
       
   207                 }            
       
   208             if( ret == KErrNone )
       
   209                 {
       
   210                 _LIT(KMessage, "Log file(s) deleted");
       
   211                 CAknConfirmationNote* note = new(ELeave) CAknConfirmationNote;
       
   212                 note->ExecuteLD(KMessage);
       
   213                 }
       
   214             else
       
   215                 {
       
   216                 _LIT(KMessage, "Unable to delete");
       
   217                 CAknErrorNote* note = new(ELeave) CAknErrorNote;
       
   218                 note->ExecuteLD(KMessage);
       
   219                 }
       
   220             break;
       
   221             }        
       
   222         case ECmdCompareDLLs:
       
   223             {
       
   224             iEngine->AnalyseDLLsL();
       
   225             break;
       
   226             }
       
   227 
       
   228         case ECmdAbout:
       
   229             {
       
   230 	        CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog;
       
   231             dialog->ExecuteLD(R_LAUNCHER_ABOUT_DIALOG);
       
   232 
       
   233             break;
       
   234             }
       
   235 
       
   236         case ECmdStopLaunch:
       
   237             {
       
   238             iEngine->StopLaunchingL();
       
   239             break;
       
   240             }
       
   241 
       
   242         case ECmdSendUILogFile:
       
   243             {
       
   244             iEngine->SendLogViaSendUiL(iSendUi);
       
   245             break;
       
   246             }
       
   247 
       
   248         case ECmdSendUISystemDllFile:
       
   249             {
       
   250             iEngine->SendListOfSystemDllsViaSendUiL(iSendUi);
       
   251             break;
       
   252             }
       
   253         case EAknSoftkeyCancel:
       
   254             {
       
   255             iEngine->Cancel();
       
   256             break;
       
   257             }
       
   258         default:
       
   259             {
       
   260             }
       
   261             break;      
       
   262         }
       
   263     }
       
   264 
       
   265 // End of File