launcher/engine/inc/launcherengine.h
branchRCL_3
changeset 21 b3cee849fa46
equal deleted inserted replaced
20:48060abbbeaf 21:b3cee849fa46
       
     1 /*
       
     2 * Copyright (c) 2010 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 #ifndef LAUNCHERENGINE_H
       
    19 #define LAUNCHERENGINE_H
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <apgcli.h>
       
    23 #include <w32std.h>
       
    24 #include <e32std.h>
       
    25 #include <e32hal.h>
       
    26 
       
    27 #include "launcherparserobserver.h"
       
    28 
       
    29 // CONSTANTS
       
    30 // None
       
    31 
       
    32 // MACROS
       
    33 // None
       
    34 
       
    35 // DATA TYPES
       
    36 // None
       
    37 
       
    38 // FUNCTION PROTOTYPES
       
    39 // None
       
    40 
       
    41 // FORWARD DECLARATIONS
       
    42 class CEikonEnv;
       
    43 class CAppThreadChecker;
       
    44 class CAppRunningChecker;
       
    45 class CLauncherXMLParser;
       
    46 class CLauncherDLLParser;
       
    47 
       
    48 
       
    49 // INFERFACE FOR COMMUNICATION WITH UI
       
    50 
       
    51 class MLauncherUI
       
    52 {
       
    53 public:
       
    54     /**
       
    55      * Method for writing text to output window.
       
    56      * @param aText A text to be written.
       
    57      * @return None.
       
    58      */
       
    59     virtual void PrintText(const TDesC& aText) = 0;
       
    60 
       
    61     /**
       
    62      * Shows info message with text
       
    63      * @param aText An text to be shown in message.
       
    64      * @return None.
       
    65      */
       
    66     virtual void ShowInfoMessage(const TDesC& aText) = 0;
       
    67     
       
    68     /**
       
    69      * Shows error message with error text
       
    70      * @param aText An error text to be shown in message.
       
    71      * @return None.
       
    72      */
       
    73     virtual void ShowErrorMessage(const TDesC& aText) = 0;
       
    74     
       
    75     /**
       
    76      * Shows progress bar with text
       
    77      * @param aText A text to be shown at top of the progress bar.
       
    78      * @param aMinimum A minimum progress bar value.
       
    79      * @param aMaximum A maximum progress bar value.
       
    80      * @return None.
       
    81      */
       
    82     virtual void ShowProgressBar(const TDesC& aText, TInt aMinimum, TInt aMaximum ) = 0;
       
    83 
       
    84     /**
       
    85      * Sets progress bar value
       
    86      * @param aValue A value between min and max value of the progress bar range
       
    87      * @return None.
       
    88      */
       
    89     virtual void SetProgressBarValue(TInt aValue) = 0;
       
    90 
       
    91     /**
       
    92      * Hides progress bar
       
    93      * @return None.
       
    94      */
       
    95     virtual void HideProgressBar() = 0;
       
    96 
       
    97     /**
       
    98      * Shows wait dialog with text
       
    99      * @param aText A text to be shown at top of the wait bar.
       
   100      * @return None.
       
   101      */
       
   102     virtual void ShowWaitDialog(const TDesC& aText) = 0;
       
   103 
       
   104     /**
       
   105      * Hides wait dialog
       
   106      * @return None.
       
   107      */
       
   108     virtual void HideWaitDialog() = 0;
       
   109     
       
   110     /**
       
   111      * Changes focus to output view
       
   112      * @return None.
       
   113      */
       
   114     virtual void ChangeFocusToOutputView() = 0;
       
   115     
       
   116 };
       
   117 
       
   118 // CLASS DECLARATION
       
   119 
       
   120 class CLauncherEngine: public CActive, public MLauncherParserObserver
       
   121 {
       
   122 
       
   123 public:
       
   124     static CLauncherEngine* NewL(MLauncherUI *aLauncherUI);
       
   125     ~CLauncherEngine();
       
   126     CDesCArray* ListOfAllAppsL();
       
   127     void StartAppLaunchingL(const CArrayFix<TInt>* aSelectedApps, TBool aAutoClose);
       
   128     void CheckIfAppIsRunningL();
       
   129     void CheckWhyThreadDiedL();
       
   130     void StopLaunchingL();
       
   131     TBool LogFileExists();
       
   132     TBool BCLogFileExists();
       
   133     
       
   134     TInt DeleteLogFile();
       
   135     TInt DeleteBCLogFile();
       
   136     
       
   137     void AnalyseDLLsL( const TDesC& aFileName );
       
   138     
       
   139     void ElementParsedL(const CLauncherDLLElement& aDllElement);
       
   140     void DocumentParsedL(TInt aErrorCode);
       
   141     void ParsingProgressedL(TInt aBytes);
       
   142     TInt ReadLineFromFileL(RFile& aFile, TDes& aReadBuf);
       
   143     
       
   144     const TDesC& RequiredDllsFilePath() const { return iRequiredDllsFilePath; };
       
   145     
       
   146     void CancelBCAnalysis();
       
   147     
       
   148 private:
       
   149     CLauncherEngine();
       
   150     void ConstructL(MLauncherUI *aLauncherUI);
       
   151     
       
   152     void RunL();
       
   153     void DoCancel();
       
   154         
       
   155     TInt FindFiles(const TDesC& aFileName, const TDesC& aPath);
       
   156     void IssueLaunch();
       
   157     void WriteInitialStuffToTheLogL(const TDesC& aOwnData, RFile& aFile);
       
   158     void CheckForMoreAppsL();
       
   159     void LaunchApplicationL();
       
   160     void DoLaunchApplicationL();
       
   161     CDesCArray* DependencyCheckForE32ImageL();
       
   162 
       
   163     /**
       
   164      * Performs binary compatibility analysis based on reference data given
       
   165      * in XML-file.
       
   166      */
       
   167     void DoBCAnalysisL();
       
   168     
       
   169     /**
       
   170      * Compares given DLL list to system DLLs
       
   171      */
       
   172     void DoCompareDLLListsL();
       
   173     
       
   174 private:
       
   175 
       
   176     MLauncherUI *iLauncherUI;
       
   177     
       
   178     RTimer          iTimer;
       
   179     CEikonEnv*      iEnv;
       
   180     RApaLsSession   iLs;
       
   181     RWsSession      iWs;
       
   182     HBufC8*         iLogWriteBuf;    
       
   183     RFile           iLogFile;
       
   184     RFile           iBCLogFile;  
       
   185     TFileName       iLogFilePath;
       
   186     TFileName       iBCLogFilePath;
       
   187     TFileName       iSystemDllsFilePath;
       
   188     TFileName       iRequiredDllsFilePath;        
       
   189         
       
   190     CDesCArray*     iAppsArray;
       
   191     CDesCArray*     iAllAppsArray;
       
   192     CDesCArray*     iSystemDllArray;
       
   193 //  CDesCArray*     iRequiredDllArray;
       
   194 
       
   195     TBool           iLaunchingIsActive;
       
   196     TBool           iDLLAnalysisIsActive;
       
   197     TBool           iSkipHiddenAndEmbedOnly;
       
   198     TBool           iAutoClose;
       
   199     TInt            iAppLaunchCounter;
       
   200     TInt            iFailedCases;
       
   201     TInt            iOkCases;
       
   202     TInt            iSkippedCases;
       
   203     TInt            iTotalNumberOfCases;
       
   204 
       
   205     TUid            iCurrentAppUid;
       
   206     TThreadId       iCurrentAppThreadId;
       
   207     TBuf<128>       iCurrentAppNameAndExt;
       
   208     RThread         iCurrentAppThread;
       
   209 //
       
   210     CAppThreadChecker*          iAppThreadChecker;
       
   211     CAppRunningChecker*         iAppRunningChecker;
       
   212 
       
   213     CLauncherXMLParser*     iXMLParser;
       
   214     CLauncherDLLParser*     iDLLParser;
       
   215     CLauncherDLLElement*    iDLLElement;
       
   216     
       
   217     TInt                iFoundBCIssues;
       
   218     HBufC*              iBCIssuesBigBuffer;
       
   219 
       
   220         
       
   221 public:
       
   222     inline TBool SkipHiddenAndEmbedOnly()              { return iSkipHiddenAndEmbedOnly; };
       
   223     inline void SetSkipHiddenAndEmbedOnly(TBool aSkip) { iSkipHiddenAndEmbedOnly = aSkip; };
       
   224     inline const TDesC& LogFilePath() { return iLogFilePath; }
       
   225     inline const TDesC& BCLogFilePath() { return iBCLogFilePath; }
       
   226     inline const TDesC& SystemDllsFilePath() { return iSystemDllsFilePath; }
       
   227 };
       
   228 
       
   229 
       
   230 
       
   231 class CAppRunningChecker : public CActive
       
   232     {
       
   233 public:
       
   234     static CAppRunningChecker* NewL(CLauncherEngine* aLauncherEngine);
       
   235     ~CAppRunningChecker();
       
   236 
       
   237     void StartTesting();
       
   238 
       
   239 private:
       
   240     CAppRunningChecker();
       
   241     void ConstructL(CLauncherEngine* aLauncherEngine);
       
   242 
       
   243     void RunL();
       
   244     void DoCancel();
       
   245 
       
   246 private:
       
   247     RTimer iTimer;
       
   248     CEikonEnv* iEnv;
       
   249     CLauncherEngine* iLauncherEngine;
       
   250     };
       
   251 
       
   252 class CAppThreadChecker : public CActive
       
   253     {
       
   254 public:
       
   255     static CAppThreadChecker* NewL(CLauncherEngine* aLauncherEngine);
       
   256     ~CAppThreadChecker();
       
   257 
       
   258     void ActivateChecking();
       
   259     void CheckIfAppIsRunningL();
       
   260 
       
   261 private:
       
   262     CAppThreadChecker();
       
   263     void ConstructL(CLauncherEngine* aLauncherEngine);
       
   264 
       
   265     void RunL();
       
   266     void DoCancel();
       
   267 
       
   268 private:
       
   269     CEikonEnv* iEnv;
       
   270     CLauncherEngine* iLauncherEngine;
       
   271     };
       
   272 
       
   273 
       
   274 #endif //LAUNCHERENGINE_H