installationservices/swcomponentregistry/inc_private/scrrequestimpl.h
changeset 24 84a16765cd86
child 25 98b66e4fb0be
equal deleted inserted replaced
6:aba6b8104af3 24:84a16765cd86
       
     1 /*
       
     2 * Copyright (c) 2008-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 * Declares the class which implements SCR's session and sub-session service requests.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 /**
       
    21  @file
       
    22  @internalComponent
       
    23  @released
       
    24 */
       
    25 
       
    26 #ifndef SCRREQUESTIMPL_H
       
    27 #define SCRREQUESTIMPL_H
       
    28 
       
    29 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    30 #include "screntries_internal.h"
       
    31 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
       
    32 #include "screntries.h"
       
    33 
       
    34 namespace Usif
       
    35 	{
       
    36 	// constants
       
    37 	static const TLanguage KLangNone = TLanguage(0);
       
    38 	static const TInt KMaxSwTypeIdDigits = 4; 		///< Maximum number of digits a software type id may have.
       
    39 	static const TInt KMaxSwTypeIdValue = 0xFFFF;   ///< Maximum value of a software type id.	
       
    40 	
       
    41 	// forward declaration
       
    42 	class CDatabase;
       
    43 	class CStatement;
       
    44 	class CScrAsyncRequestImpl;
       
    45 	class CScrSession;
       
    46 	class CScrSubsession;
       
    47 	class CCompViewSubsessionContext;
       
    48 
       
    49 	class CScrRequestImpl : public CBase
       
    50 		{
       
    51 	public:
       
    52 		static CScrRequestImpl* NewL(RFs& aFs, RFile& aDatabaseFile, RFile& aJournalFile);
       
    53 		~CScrRequestImpl();
       
    54 		
       
    55 		// Transaction Requests
       
    56 		void CreateTransactionL();
       
    57 		void RollbackTransactionL();
       
    58 		void CommitTransactionL();
       
    59 		
       
    60 		// Component Management Requests
       
    61 		void AddComponentL(const RMessage2& aMessage);
       
    62 		void AddComponentDependencyL(const RMessage2& aMessage);
       
    63 		void SetComponentLocalizablePropertyL(const RMessage2& aMessage);
       
    64 		void SetComponentBinaryPropertyL(const RMessage2& aMessage);		
       
    65 		void SetComponentIntPropertyL(const RMessage2& aMessage);
       
    66 		void RegisterComponentFileL(const RMessage2& aMessage); 
       
    67 		void SetFileStrPropertyL(const RMessage2& aMessage);
       
    68 		void SetFileIntPropertyL(const RMessage2& aMessage);
       
    69 		void SetComponentNameL(const RMessage2& aMessage);
       
    70 		void SetVendorNameL(const RMessage2& aMessage);
       
    71 		void SetIsComponentRemovableL(const RMessage2& aMessage);
       
    72 		void SetIsComponentDrmProtectedL(const RMessage2& aMessage);
       
    73 		void SetIsComponentHiddenL(const RMessage2& aMessage);
       
    74 		void SetIsComponentKnownRevokedL(const RMessage2& aMessage);
       
    75 		void SetIsComponentOriginVerifiedL(const RMessage2& aMessage);
       
    76 		void SetComponentSizeL(const RMessage2& aMessage);
       
    77 		void SetComponentVersionL(const RMessage2& aMessage);
       
    78 		void DeleteComponentPropertyL(const RMessage2& aMessage);
       
    79 		void DeleteFilePropertyL(const RMessage2& aMessage);
       
    80 		void UnregisterComponentFileL(const RMessage2& aMessage);
       
    81 		void DeleteComponentL(const RMessage2& aMessage);
       
    82 		void DeleteComponentDependencyL(const RMessage2& aMessage);
       
    83 		
       
    84 		// Component Query requests
       
    85 		void GetComponentEntrySizeL(const RMessage2& aMessage) const;							
       
    86 		void GetComponentEntryDataL(const RMessage2& aMessage) const;
       
    87 		void GetComponentLocalizedEntrySizeL(const RMessage2& aMessage) const;
       
    88 		void GetComponentLocalizedEntryDataL(const RMessage2& aMessage) const;
       
    89 		void GetFilePropertiesSizeL(const RMessage2& aMessage) const;
       
    90 		void GetFilePropertiesDataL(const RMessage2& aMessage) const;
       
    91 		void GetSingleFilePropertySizeL(const RMessage2& aMessage) const;
       
    92 		void GetSingleFilePropertyDataL(const RMessage2& aMessage) const;
       
    93 		void GetFileComponentsSizeL(const RMessage2& aMessage) const;
       
    94 		void GetFileComponentsDataL(const RMessage2& aMessage) const;
       
    95 		void GetComponentPropertiesSizeL(const RMessage2& aMessage) const;
       
    96 		void GetComponentPropertiesDataL(const RMessage2& aMessage) const;
       
    97 		void GetComponentSinglePropertySizeL(const RMessage2& aMessage) const;
       
    98 		void GetComponentSinglePropertyDataL(const RMessage2& aMessage) const;
       
    99 		void GetComponentIdListSizeL(const RMessage2& aMessage) const;
       
   100 		void GetComponentIdListDataL(const RMessage2& aMessage) const;
       
   101 		void GetComponentFilesCountL(const RMessage2& aMessage) const;
       
   102 		void GetComponentIdL(const RMessage2& aMessage) const;
       
   103 		void GetComponentWithGlobalIdSizeL(const RMessage2& aMessage) const;
       
   104 		void GetComponentWithGlobalIdDataL(const RMessage2& aMessage) const;
       
   105 		void GetSupplierComponentsSizeL(const RMessage2& aMessage) const;
       
   106 		void GetSupplierComponentsDataL(const RMessage2& aMessage) const;
       
   107 		void GetDependantComponentsSizeL(const RMessage2& aMessage) const;
       
   108 		void GetDependantComponentsDataL(const RMessage2& aMessage) const;
       
   109 		void GetComponentSupportedLocalesListSizeL(const RMessage2& aMessage) const;
       
   110 		void GetComponentSupportedLocalesListDataL(const RMessage2& aMessage) const;
       
   111 				
       
   112 		// Application Manager Requests
       
   113 		void GetIsMediaPresentL(const RMessage2& aMessage) const;
       
   114 		void GetIsComponentOrphanedL(const RMessage2& aMessage) const;
       
   115 		void GetLogFileHandleL(const RMessage2& aMessage) const;
       
   116 		void FlushLogEntriesArrayL();
       
   117 		void GetIsComponentOnReadOnlyDriveL(const RMessage2& aMessage) const;
       
   118 		void GetIsComponentPresentL(const RMessage2& aMessage) const;
       
   119 		void SetIsComponentPresentL(const RMessage2& aMessage);
       
   120 		
       
   121 		// SIF Requests
       
   122 		void SetScomoStateL(const RMessage2& aMessage);
       
   123 		void GetPluginUidWithMimeTypeL(const RMessage2& aMessage) const;
       
   124 		void GetPluginUidWithComponentIdL(const RMessage2& aMessage) const;
       
   125 		
       
   126 		// Security Layer Requests
       
   127 		TBool GetInstallerSidForComponentL(TComponentId aComponentId, TSecureId& aSid) const;
       
   128 		TBool GetSidsForSoftwareTypeL(const HBufC* aSoftwareTypeName, TSecureId& aInstallerSid, TSecureId& aExecutableEnvSid) const;
       
   129 		TBool GetExecutionEnvSidForComponentL(TComponentId aComponentId, TSecureId& aSid) const;
       
   130 		TBool IsInstallerOrExecutionEnvSidL(TSecureId& aSid) const;
       
   131 		TBool GetIsComponentOrphanedL(TComponentId aComponentId) const;
       
   132 		
       
   133 		// Component's view operations
       
   134 		CComponentFilter* ReadComponentFilterL(const RMessage2& aMessage) const;
       
   135 		CStatement* OpenComponentViewL(CComponentFilter& aFilter, RArray<TComponentId>& aComponentFilterSuperset, TBool& aFilterSupersetInUse) const;
       
   136 		void NextComponentSizeL(const RMessage2& aMessage, CStatement* aStmt, CComponentFilter* aFilter, CComponentEntry*& aEntry, CCompViewSubsessionContext* aSubsessionContext) const;
       
   137 		void NextComponentDataL(const RMessage2& aMessage, CComponentEntry*& aEntry) const;
       
   138 		void NextComponentSetSizeL(const RMessage2& aMessage, CStatement* aStmt, CComponentFilter* aFilter, RPointerArray<CComponentEntry>& aEntryList, CCompViewSubsessionContext* aSubsessionContext) const;
       
   139 		void NextComponentSetDataL(const RMessage2& aMessage, RPointerArray<CComponentEntry>& aEntryList) const;
       
   140 				
       
   141 		// Files's list operations
       
   142 		CStatement* OpenFileListL(const RMessage2& aMessage) const; 	 
       
   143 		void NextFileSizeL(const RMessage2& aMessage, CStatement* aStmt, HBufC*& aFilePath) const;
       
   144 		void NextFileDataL(const RMessage2& aMessage, HBufC*& aFilePath) const;
       
   145 		void NextFileSetSizeL(const RMessage2& aMessage, CStatement* aStmt, RPointerArray<HBufC>& aFileList) const;
       
   146 		void NextFileSetDataL(const RMessage2& aMessage, RPointerArray<HBufC>& aFileList) const;
       
   147 		
       
   148 		// Static utility functions - code reuse between SCRServer and this class
       
   149 		static TComponentId GetComponentIdFromMsgL(const RMessage2& aMessage);
       
   150 		static HBufC* GetSoftwareTypeNameFromMsgLC(const RMessage2& aMessage);
       
   151 		static HBufC* ReadFileNameFromMsgLC(const RMessage2& aMessage);
       
   152 		
       
   153 		// Sofwtare type management operations
       
   154 		void AddSoftwareTypeL(const RMessage2& aMessage);
       
   155 		void DeleteSoftwareTypeL(const RMessage2& aMessage);
       
   156 		void GetDeletedMimeTypesL(const RMessage2& aMessage) const;
       
   157 		
       
   158 	private:
       
   159 		CScrRequestImpl(RFs& aFs);
       
   160 		void ConstructL(RFile& aDatabaseFile, RFile& aJournalFile);
       
   161 	
       
   162 	private:
       
   163 		enum TValueType
       
   164 			{
       
   165 			EValueInteger 	 = 0x01,
       
   166 			EValueString 	 = 0x02,
       
   167 			EValueInteger64  = 0x03,
       
   168 			EValueLanguage   = 0x04,
       
   169 			EValueBinary = 0x05,
       
   170 			};
       
   171 		
       
   172 		enum TPropertyType
       
   173 			{
       
   174 			EPropertyUndefined = 0,	  // The property type is not defined yet
       
   175 			EPropertyInteger   = 1,   // The property type is integer
       
   176 			EPropertyLocalizable    = 2,    // The property type is a localizable string
       
   177 			EPropertyBinary    = 3    // The property type is a non-localizable 8-bit descriptor
       
   178 			};
       
   179 		
       
   180 		enum TFileOperationType
       
   181 			{
       
   182 			EFileRegistered,
       
   183 			EFileUnregistered
       
   184 			};
       
   185 		
       
   186 		class TRollbackParams
       
   187 			{
       
   188 		public:
       
   189 			TRollbackParams(TInt aIdColumnVal, CScrRequestImpl& aReqImplHandle)
       
   190 				: iIdColumnVal(aIdColumnVal), iReqImplHandle(aReqImplHandle){}
       
   191 		
       
   192 			TInt iIdColumnVal;
       
   193 			CScrRequestImpl& iReqImplHandle;
       
   194 			};
       
   195 		
       
   196 	    static HBufC* ReadDescLC(const RMessage2& aMessage, TInt aSlot);
       
   197 	    static HBufC8* ReadDesc8LC(const RMessage2& aMessage, TInt aSlot);
       
   198 		static TUint32 HashCaseInsensitiveL(const TDesC& aName);
       
   199 		static TUint32 HashCaseSensitiveL(const TDesC& aName);
       
   200 		static void ComponentRollback(TAny* aParam);
       
   201 		static void ComponentLocalizablesRollback(TAny* aParam);
       
   202 		
       
   203 		HBufC* FormatStatementLC(const TDesC& aStatement, TInt aFormatLength,...) const;
       
   204 		HBufC* GenerateGlobalIdL(const TDesC& aUniqueSwTypeName, const TDesC& aGlobalId) const;
       
   205 		TComponentId CommonAddComponentL(const TDesC& aUniqueSwTypeName, const TDesC& aGlobalId);
       
   206 		void AddComponentLocalizablesL(TComponentId aCompId, TLanguage aLocale, const TDesC& aName, const TDesC& aVendor);
       
   207 		HBufC* ReadAndGetGlobalIdLC(const RMessage2& aMessage, TInt aSlot) const;
       
   208 		TUint32 ReadAndHashGlobalIdL(const RMessage2& aMessage, TInt aGlobalIdNameSlot, TInt aSwTypeNameSlot) const;
       
   209 		TUint32 HashGlobalIdsL(const TDesC& aDependantId, const TDesC& aSupplierId) const;		
       
   210 		CStatement* CreateGeneralPropertyStatementWithLocaleL(const TDesC& aStmtStr, TInt aIdColumnValue, TLanguage aLocale, const TDesC& aPropName, TBool aDoLocaleResolving=ETrue) const;
       
   211 		TInt FindGeneralPropertyNoLocaleDowngradeL(const TDesC& aTableName, const TDesC& aIdColumnName , TInt aIdColumnValue, const TDesC& aPropertyName, TLanguage aLocale, TPropertyType& aPropertyType) const;
       
   212 		void SetGeneralLocalizablePropertyL(CScrRequestImpl::TPropertyType aPropType, TInt aPropertyId, const TDesC& aIdColumnName , TInt aIdColumnValue, const TDesC& aPropName, TLanguage aLocale, const TDesC& aPropValue);
       
   213 		void SetGeneralBinaryPropertyL(CScrRequestImpl::TPropertyType aPropType, TInt aPropertyId, const TDesC& aTableName, const TDesC& aIdColumnName , TInt aIdColumnValue, const TDesC& aPropName, const TDesC8& aPropValue);
       
   214 		void SetGeneralIntPropertyL(TPropertyType aPropType, TInt aPropertyId, const TDesC& aTableName, const TDesC& aIdColumnName , TInt aIdColumnValue, const TDesC& aPropName, TInt64 aPropValue);
       
   215 		void ExecuteStatementL(TRefByValue<const TDesC>, TInt aValuesNum=0,...);
       
   216 		void GetFileComponentsL(const TDesC& aFileName, RArray<TComponentId>& aComponents) const;
       
   217 		TInt GetComponentFileIdL(const TDesC& aFileName, TComponentId aComponentId) const;
       
   218 		TInt FindComponentFileL(const TDesC& aFileName, TComponentId aComponentId) const;
       
   219 		void SetComponentLocalizableL(TComponentId aComponentId, TLanguage aLocale, const TDesC& aColumnName, const TDesC& aName, const TDesC& aVendor);
       
   220 		CPropertyEntry* GetGeneralSinglePropertyL(const TDesC& aTableName, const TDesC& aIdColumnName , TInt aIdColumnValue, const TDesC& aPropName, TLanguage aLocale) const;
       
   221 		CPropertyEntry* GetPropertyEntryL(CStatement& aStmt, const TDesC& aPropName, TInt aStartingIndex) const;
       
   222 		void AddGeneralPropertiesArrayWithLocaleL(const TDesC& aStmtStr, TLanguage aLocale, TComponentId aIdColumnValue, RPointerArray<CPropertyEntry>& aProperties) const;
       
   223 		void GetGeneralPropertiesArrayL(const TDesC& aTableName, const TDesC& aIdColumnName , TComponentId aIdColumnValue, TLanguage aLocale, RPointerArray<CPropertyEntry>& aProperties) const;
       
   224 		TBool BindAndProcessStatementObjectL(CStatement& aStatementObj, TLanguage aLanguage, TInt aValuesNum, VA_LIST aList) const;
       
   225 		CStatement* CreateStatementObjectWithoutLocaleL(const TDesC& aStatement, TInt aValuesNum,...) const;		
       
   226 		CStatement* CreateStatementObjectWithLocaleL(const TDesC& aStatement, TLanguage aLocale, TInt aValuesNum,...) const;
       
   227 		CStatement* CreateStatementObjectWithLocaleNoDowngradeL(const TDesC& aStatement, TLanguage aLocale, TInt aValuesNum,...) const;
       
   228 		void BindStatementValuesL(CStatement& aStatement, TLanguage aLanguage, TInt aValuesNum, VA_LIST aList) const;
       
   229 		void GetComponentIdsHavingThePropertiesL(RArray<TComponentId>& aComponentIds, RPointerArray<CPropertyEntry> aProperties, TBool aDoIntersect) const;
       
   230 		CStatement* CreateStatementObjectForComponentLocalizablesLC(const TDesC& aName, const TDesC& aVendor, TUint aSetFlag, TComponentId aComponentId  = 0 ) const;
       
   231 		void GetComponentsHavingNameVendorL(RArray<TComponentId>& aComponentIds, const TDesC& aName, const TDesC& aVendor, TUint16 aSetFlag, TBool aDoIntersect) const;
       
   232 		CComponentEntry* GetNextComponentEntryL(CStatement& aStmt, CComponentFilter& aFilter, TLanguage aLocale, CCompViewSubsessionContext* aSubsessionContext) const;
       
   233 		HBufC* GetNextFilePathL(CStatement& aStmt) const;
       
   234 		CComponentEntry* CreateComponentEntryFromStatementHandleL(CStatement& aStmt) const;
       
   235 		CStatement* ExecuteLocalizableStatementL(const TDesC& aLocalizableStmtStr, const TDesC& aAnyValueStmtStr, TInt aConditionIntValue, TLanguage aConditionLocale) const;
       
   236 		void AddComponentEntryLocalizablesL(TComponentId aComponentId, CComponentEntry& aEntry, TLanguage aLocale) const;
       
   237 		void AddComponentEntryLocalizablesL(TComponentId aComponentId, CComponentEntry& aEntry, TLanguage aLocale, const CComponentFilter& aFilter) const;
       
   238 		void AddSoftwareTypeNameToComponentEntryL(CStatement& aStmt, CComponentEntry& aEntry, TLanguage aLocale) const;
       
   239 		TBool IsSoftwareTypeExistingL(TInt aSoftwareTypeId) const;
       
   240 		void GetGeneralComponentEntrySizeL(const RMessage2& aMessage, const TDesC& aConditionColumn, TUint32 aConditionValue, TInt aReturnSizeSlot, TLanguage aLocale, CComponentEntry*& aComponentEntry) const;
       
   241         TInt GetDriveFromFilePath(const TDesC& aFilePath, TDriveUnit& aDriveUnit) const;
       
   242 		TInt InstalledDrivesToBitmaskL(const TDriveList& aDriveList) const;
       
   243 		void UpdateInstalledDrivesL(TComponentId aComponentId, const TDesC& aFilePath, TFileOperationType aType);
       
   244 		TBool GetIntSoftwareTypeDataForComponentLC(TComponentId aComponentId, const TDesC& aColumnName, TInt& aValue) const;
       
   245 		TInt GetInstalledDrivesBitmaskL(TComponentId aComponentId) const;
       
   246 		CGlobalComponentId* ParseGlobalComponendIdLC(const TDesC& aGlobalId) const;
       
   247 		void GetGeneralDependencyListL(const TDesC& aSelectColumn, const TDesC& aConditionColumn, const TDesC& aConditionValue, RPointerArray<CVersionedComponentId> &aVerCompIdList) const;
       
   248 		void ReadAndSetCommonComponentPropertyL(const RMessage2& aMessage, const TDesC& aPropertyColumn);
       
   249 		TBool HasFilesOnDriveL(TDriveUnit aDrive, TComponentId aComponentId);
       
   250 		CStatement* OpenFileListStatementL(TComponentId aComponentId) const;
       
   251 		TBool IsSoftwareTypeExistingL(TUint32 aSwTypeId, TUint32 aSifPluginUid, TUint32 aInstallerSecureId, TUint32 aExecutionLayerSecureId, const RPointerArray<HBufC>& aMimeTypesArray, const RPointerArray<CLocalizedSoftwareTypeName>& aLocalizedNamesArray);
       
   252 		void SubsessionAddLocalizableSoftwareTypeNameL(CStatement& aStmt, CComponentEntry& aEntry, TLanguage aLocale, CCompViewSubsessionContext* aSubsessionContext) const;
       
   253 		TBool IsDriveReadOnlyL(TInt driveIndex) const;
       
   254 		TBool CheckForMediaPresenceL(TComponentId aComponentId) const;
       
   255 		
       
   256 		// DB Version management
       
   257 		void InitializeDbVersionL();
       
   258 		void VerifyDbVersionCompatibilityL() const;
       
   259 		
       
   260 	private:
       
   261 		RFs& iFs;	///< Reference to the file handle. It is worth to consume a word of memory instead of passing the file handle to many functions.
       
   262 		CDatabase* iDbHandle; ///< Handle to the SCR database object.
       
   263 		TVersion iDbVersion;
       
   264 		mutable CComponentEntry* iComponentEntry; 			///< The component entry whose size calculated and sent to the client.
       
   265 		mutable CPropertyEntry* iSingleProperty;
       
   266 		mutable RArray<TComponentId> iFileComponents;
       
   267 		mutable RArray<TComponentId> iComponentIdList;
       
   268 		mutable RPointerArray<CPropertyEntry> iProperties;
       
   269 		mutable RPointerArray<CVersionedComponentId> iVerCompIdList; // The list of supplier/dependant versioned component IDs
       
   270 		mutable RPointerArray<HBufC> iDeletedMimeTypes; // The list of MIME types deleted as the result of software type deletion.
       
   271 		mutable RPointerArray<CScrLogEntry> iLogEntries; // The list of log entries recorded in a session
       
   272 		mutable RArray<TLanguage> iMatchingSupportedLanguageList; // The list of matching supported language list recorded in a session
       
   273 		mutable RPointerArray<CLocalizableComponentInfo> iCompLocalizedInfoArray; //Component's localized information (name, vendor, locale) 
       
   274 		};
       
   275 	
       
   276 	} // End of namespace Usif
       
   277 
       
   278 #endif /* SCRREQUESTIMPL_H */