installationservices/swi/source/sishelper/uissclienthandler.h
changeset 0 ba25891c3a9e
child 17 741e5bba2bd1
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2004-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 the License "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 * Declaration of Swi::CUissClientHandler class which is the client-side part 
       
    16 * of the reverse completion mechanism used by SWI to communicate with the UI
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 /**
       
    22  @file
       
    23  @internalComponent
       
    24 */
       
    25 
       
    26 #include <e32std.h>
       
    27 #include "../uiss/client/uissclient.h"
       
    28 #include "swi/msisuihandlers.h"
       
    29 #include "swi/launcher.h"
       
    30 #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
    31 namespace Usif
       
    32 	{
       
    33 	class CComponentInfo;
       
    34 	}
       
    35 #include "swi/nativecomponentinfo.h"
       
    36 #endif
       
    37 
       
    38 namespace Swi
       
    39 {
       
    40 class CSisRegistryPackage;
       
    41 class CUissCmdHandler;
       
    42 class CWriteStream;
       
    43 
       
    44 /**
       
    45  * This class communicates asynchronously with UISS using reverse completion 
       
    46  * mechanism, making requests to UISS and receiving completions with requests
       
    47  * to display dialogs to the user, which it does by calling back to UI 
       
    48  * implementation (see Swi::MUiHandler and Swi::Launcher).
       
    49  *
       
    50  * @note This class is similar to the class CInstCoordClient from Jetstream
       
    51  *
       
    52  * @see Swi::MUiHandler
       
    53  * @see Swi::Launcher
       
    54  *
       
    55  * @internalComponent
       
    56  * @released
       
    57  */
       
    58 class CUissClientHandler : public CActive
       
    59 	{
       
    60 public:
       
    61 	static CUissClientHandler* NewL(MUiHandler& aUiHandler, TBool aActiveObjectMode = true);
       
    62 	static CUissClientHandler* NewLC(MUiHandler& aUiHandler, TBool aActiveObjectMode = true);
       
    63 	
       
    64 	virtual ~CUissClientHandler();
       
    65 	
       
    66 	// client methods
       
    67 	
       
    68 	/**
       
    69 	 * Performs installation asynchronously. The r/c mechanism is handled 
       
    70 	 * internally.
       
    71 	 */
       
    72 	void InstallL(const CInstallPrefs& aInstallPrefs, const RArray<TInt>& aDeviceSupportedLanguages, TRequestStatus& aStatus, RThread& aServer);
       
    73 		
       
    74 	#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
    75 	/**
       
    76 	 * Retrieves component info asynchronously. The buffer management is handled internally.
       
    77 	 */
       
    78 	void GetComponentInfoL(const CInstallPrefs& aInstallPrefs, Usif::CComponentInfo& aComponentInfo,  TRequestStatus& aStatus, RThread& aServer);
       
    79 	#endif
       
    80 		
       
    81 	/**
       
    82 	 * Performs uninstallation asynchronously. The r/c mechanism is handled 
       
    83 	 * internally.
       
    84 	 *
       
    85 	 * @param aPackage Package to uninstall
       
    86 	 */
       
    87 	void UninstallL(const CSisRegistryPackage& aPackage, TRequestStatus& aStatus);
       
    88 	
       
    89 	/**
       
    90 	 * Cancels operation in progress
       
    91 	 */
       
    92 	void CancelOperation();
       
    93 
       
    94 	/**
       
    95 	 * Used during synchronous operation to issue/process all
       
    96 	 * requests until operation is complete.
       
    97 	 */
       
    98 	void WorkUntilCompleteL();
       
    99 
       
   100 	/**
       
   101 	 * Returns true if an install/uninstall operation is in
       
   102 	 * progress. This is different to IsActive() which just returns
       
   103 	 * true if we have an outstanding request on the UISS.
       
   104 	 */
       
   105 	TBool IsBusy();
       
   106 		
       
   107 private:
       
   108 	//	static const TInt KBufSize=10*1024; ///< Initial size of the command buffer
       
   109 	static const TInt KBufSize=10; ///< Initial size of the command buffer
       
   110 
       
   111 	void Cancel(); // Weak attempt to stop any user calling Cancel directly.
       
   112 	
       
   113 	CUissClientHandler(MUiHandler& aUiHandler, TBool aActiveObjectMode);
       
   114 
       
   115 	CUissClientHandler(const CUissClientHandler&); // Disable copy construction
       
   116 	const CUissClientHandler &operator=(const CUissClientHandler&); // Disable assignment
       
   117 	
       
   118 	void ConstructL();             ///< Second phase construction function
       
   119 	
       
   120 	/**
       
   121 	 * Starts UISS in a new thread of the same SISHelper process. Later SWIS 
       
   122 	 * will connect to UISS to show dialogs.
       
   123 	 *
       
   124 	 * @return KErrNone or an error code
       
   125 	 */
       
   126 	static TInt StartUiss();
       
   127 	
       
   128 	/**
       
   129 	 * UISS thread function to run UISS in the same process.
       
   130 	 *
       
   131 	 * @return KErrNone or an error code
       
   132 	 */
       
   133 	static TInt UissThreadFunction(TAny *);
       
   134 	
       
   135 	/**
       
   136 	 * Creates a command handler object corresponding to the specified UI 
       
   137 	 * dialog request from SWIS
       
   138 	 *
       
   139 	 * @param aCode Dialog code (see CUissSession::TMessage)
       
   140 	 *
       
   141 	 * @return Command handler object (caller must destroy it)
       
   142 	 */
       
   143 	CUissCmdHandler* UissCmdHandlerFactoryL(TInt aCommand) const;
       
   144 	void AllocBufL(TInt aSize);    ///< [Re]allocates buffer to aSize
       
   145 	void HandleOverflowL();        ///< Increases UISS r/c command buffer size
       
   146 	void InitializeArgStreamL(const CInstallPrefs& aInstallPrefs);
       
   147 	
       
   148 	/**
       
   149 	 * Process a completion of an internal request to the UISS server.
       
   150 	 */
       
   151 	virtual void RunL();
       
   152 
       
   153 
       
   154 	/**
       
   155 	 * Propogate RunL failures to client via its TRequestStatus
       
   156 	 */
       
   157 	virtual TInt RunError(TInt aError);
       
   158 	
       
   159 	/**
       
   160 	 * Cancel any internal request and complete the client request.
       
   161 	 */
       
   162 	virtual void DoCancel();
       
   163 	
       
   164 	void WaitForSisHelperShutdown();
       
   165 
       
   166 	MUiHandler& iUiHandler;        ///< UI implementation
       
   167 	MCancelHandler* iCancelHandler;///< Internal cancel handler
       
   168 	HBufC8* iBuf;                  ///< Command buffer
       
   169 	TPtr8 iPtrIntoBuf;
       
   170 	RUissSession iUissSession;     ///< UISS session
       
   171 
       
   172 	TBool iActiveObjectMode;		///< Normally true for CActive object mode, set to false for sync install
       
   173 	TRequestStatus* iClientStatus; ///< Client request status
       
   174     CWriteStream* iArgsStream;    ///< Saved copy of arguments stream
       
   175 	TPtrC8 iPtrIntoArgsStream;
       
   176     enum { KUissClientIdle, 
       
   177     	   KUissClientInstalling,  
       
   178     	   KUissClientUninstalling
       
   179     	   #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK
       
   180     	   , KUissClientGettingCompInfo
       
   181     	   #endif
       
   182 		} iState;
       
   183     RThread iSisHelper;
       
   184    
       
   185    	#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK 
       
   186 	void AllocCompInfoBufL(TInt aBufSize);
       
   187 	void ConstructCompInfoFromBufferL();
       
   188 	Usif::CComponentInfo::CNode* MapToComponentInfoL(CNativeComponentInfo& aNativeComponentInfo);
       
   189 	
       
   190 	HBufC8* iCompInfoBuffer;		//< Component Information storage buffer
       
   191 	TPtr8   iCompInfoBufPtr;
       
   192 	
       
   193 	Usif::CComponentInfo* iComponentInfo;
       
   194 	#endif
       
   195 	};
       
   196 } // namespace Swi