htiui/HtiServicePlugins/HtiAppServicePlugin/inc/HtiAppControl.h
branchRCL_3
changeset 18 48060abbbeaf
parent 17 d40e813b23c0
child 19 b3cee849fa46
equal deleted inserted replaced
17:d40e813b23c0 18:48060abbbeaf
     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:  Implementation of ECOM plug-in service interface providing
       
    15 *                process and application control service.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #ifndef HTIAPPSERVICEPLUGIN_H__
       
    22 #define HTIAPPSERVICEPLUGIN_H__
       
    23 
       
    24 //  INCLUDES
       
    25 #include "../../../symbian_version.hrh"
       
    26 
       
    27 #include <e32base.h>
       
    28 #include <apgcli.h>
       
    29 #include <w32std.h>
       
    30 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 )
       
    31 #include <SWInstDefs.h>
       
    32 #include <swi/sisregistryentry.h>
       
    33 #else
       
    34 #include <usif/usifcommon.h>
       
    35 #endif
       
    36 #include <HtiServicePluginInterface.h>
       
    37 
       
    38 // CONSTANTS
       
    39 
       
    40 // MACROS
       
    41 
       
    42 // DATA TYPES
       
    43 
       
    44 // FUNCTION PROTOTYPES
       
    45 
       
    46 // FORWARD DECLARATIONS
       
    47 class CDesC8ArrayFlat;
       
    48 class TApaTask;
       
    49 
       
    50 // CLASS DECLARATION
       
    51 
       
    52 NONSHARABLE_CLASS (CHtiAppControl) : public CHTIServicePluginInterface
       
    53     {
       
    54 protected:
       
    55     //commands
       
    56     enum TAppCommand
       
    57         {
       
    58         //commands
       
    59         EProcessLastCommand = 0x0F, //!!! used to sort process control from
       
    60                                     //!!! app control
       
    61 
       
    62         //app control
       
    63         EStartApp               = 0x10,
       
    64         EStartApp_u             = 0x11,
       
    65         EStartApp_uid           = 0x12,
       
    66         EStartApp_uid_u         = 0x13,
       
    67         EStartDoc               = 0x14,
       
    68         EStartDoc_u             = 0x15,
       
    69         EStatusApp              = 0x16,
       
    70         EStatusApp_u            = 0x17,
       
    71         EStatusDoc              = 0x18,
       
    72         EStatusDoc_u            = 0x19,
       
    73         EStatusApp_uid          = 0x1A,
       
    74         EStopApp                = 0x1C,
       
    75         EStopApp_u              = 0x1D,
       
    76         EStopDoc                = 0x1E,
       
    77         EStopDoc_u              = 0x1F,
       
    78         EStopApp_uid            = 0x20,
       
    79         EListApps               = 0x24,
       
    80         EListApps_u             = 0x25,
       
    81         EListInstalledApps      = 0x26,
       
    82         EListInstalledApps_u    = 0x27,
       
    83 
       
    84         EAppLastCommand     = 0x2F, //!!! used to sort process control from
       
    85                                     //!!! app control
       
    86         EInstall            = 0x30,
       
    87         EInstall_u          = 0x31,
       
    88         EUnInstall          = 0x32,
       
    89         EUnInstallName_u    = 0x33,
       
    90         EUnInstallName      = 0x34,
       
    91 
       
    92         ESisLastCommand = 0x3F, //!!! used to sort sis control from
       
    93                                 //!!! app control
       
    94         //responses
       
    95         EOk             = 0xF0,
       
    96         ENotFound       = 0xF1,
       
    97         EAlreadyRunning = 0xF2,
       
    98         EAlreadyStopped = 0xF3,
       
    99         ERunning        = 0xF4,
       
   100         EKilled         = 0xF5,
       
   101         EPanic          = 0xF6
       
   102         };
       
   103 
       
   104 public:
       
   105     static CHtiAppControl* NewL();
       
   106 
       
   107     // Interface implementation
       
   108     void ProcessMessageL(const TDesC8& aMessage,
       
   109                          THtiMessagePriority aPriority);
       
   110 
       
   111 protected:
       
   112     CHtiAppControl();
       
   113     void ConstructL();
       
   114 
       
   115     virtual ~CHtiAppControl();
       
   116     
       
   117     void HandleAppControlL(const TDesC8& aMessage);
       
   118     void HandleInstallerControlL( const TDesC8& aMessage );
       
   119     /**
       
   120     * Extracts string from incoming request and convert it to unicode
       
   121     * for non-unicode request
       
   122     * aResult should have enough maz length and it will contain
       
   123     * Function returns either offset for a next parameter in aRequest
       
   124     * or some symbian error code
       
   125     */
       
   126     TInt ParseString( const TDesC8& aRequest,
       
   127                       TInt anOffset,
       
   128                       TBool aUnicode,
       
   129                       TDes& aResult);
       
   130 
       
   131     //command handlers
       
   132     void HandleStartProcessL( const TDesC& aProgramName,
       
   133                               const TDesC& aCmdLine,
       
   134                               TBool aStoreProcessHandle );
       
   135 
       
   136     void HandleStopProcessL( RProcess& aProcess );
       
   137     void HandleStatusProcessL( RProcess& aProcess );
       
   138 
       
   139     void HandleListProcessesL( const TDesC& aMatch );
       
   140 
       
   141     void HandleStartAppL( TApaAppInfo &aAppInfo, const TDesC& aDocName );
       
   142 
       
   143     void HandleListAppsL( TBool aIncludeHidden,
       
   144                           TBool aIncludeSystem,
       
   145                           TBool aUnicode );
       
   146 
       
   147     void HandleListInstalledAppsL( TBool aUnicode );
       
   148 
       
   149     //construct and send short message
       
   150     void SendMessageL(TAppCommand aResponseCode, const TDesC8& aMsg = KNullDesC8 );
       
   151 
       
   152     /**
       
   153     * Helper to send error message
       
   154     * @return KErrNone or some system-wide error code
       
   155     */
       
   156     inline TInt SendErrorMsg( TInt anError, const TDesC8& aMsg );
       
   157 
       
   158     /**
       
   159     *
       
   160     */
       
   161     TInt OpenProcessL( RProcess& aProcess, const TDesC& aMatch );
       
   162     TInt OpenProcessL( RProcess& aProcess, const TUint32 aProcessId );
       
   163 
       
   164 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 )
       
   165     SwiUI::TPolicy ConvertToPolicy( const TInt8 aValue );
       
   166     TInt GetPackageUidL( const TDesC& aPackageName, TInt aMimeIndex );
       
   167 #else
       
   168     Usif::TSifPolicy ConvertToSifPolicy( const TInt8 aValue );
       
   169     TInt GetComponentIdFromUid(const TInt32 aUid);
       
   170     TInt GetComponentIdFromPackageName(const TDesC& aPackageName);
       
   171 #endif
       
   172 
       
   173     TBool ValidateInstallParams( const TDesC8& aParams, TBool aIsUnicode );
       
   174 
       
   175     /**
       
   176     * Find application based on its full path name and fill in aAppInfo
       
   177     * @return KErrNone or KErrNotFound
       
   178     */
       
   179     TBool FindAppL( TApaAppInfo &aAppInfo, const TDesC& aAppFullName );
       
   180     TBool FindAppL( TApaAppInfo &aAppInfo, const TInt32 aUid );
       
   181 
       
   182     /**
       
   183      * Find a task running the application specified by the UID as a root app
       
   184      * (i.e. not embedded.
       
   185      * @param aAppUid the UID of the application to find
       
   186      * @return the found task or an empty task if not found
       
   187      */
       
   188     TApaTask FindRunningRootApp( TUid aAppUid );
       
   189 
       
   190     /**
       
   191     * Convert string to T 32bit int (e.g. TUint, TInt32)
       
   192     */
       
   193     template<class T> T Parse32( const TDesC8& a32int);
       
   194 
       
   195 protected:
       
   196 
       
   197     // Session to Window Server
       
   198     RWsSession iWs;
       
   199 
       
   200     // Session to Application Architecture Server
       
   201     RApaLsSession iAppServer;
       
   202 
       
   203     // A flag that is set to EFalse if connecting to Window Server or
       
   204     // Application Architecture Server fails. In that case all application
       
   205     // related commands will return a "not supported" error.
       
   206     TBool iIsAppCmdsSupported;
       
   207 
       
   208     // Container array for process handles for querying the process exit codes
       
   209     RArray<RProcess> iProcessHandleArray;
       
   210 
       
   211     // possible mimetypes for silent software uninstallation
       
   212     CDesC8ArrayFlat* iMimeTypes;
       
   213 
       
   214 #if ( SYMBIAN_VERSION_SUPPORT < SYMBIAN_4 )
       
   215     SwiUI::TInstallOptions iInstOpts;
       
   216     SwiUI::TInstallOptionsPckg iInstOptsPckg;
       
   217     SwiUI::TUninstallOptions iUnInstOpts;
       
   218     SwiUI::TUninstallOptionsPckg iUnInstOptsPckg;
       
   219     RPointerArray<Swi::CSisRegistryPackage> iAugmentations;
       
   220     TInt iAugmentationIndex;
       
   221 #endif
       
   222     };
       
   223 
       
   224 #endif
       
   225 
       
   226 // End of file