backupandrestore/backupengine/src/sbtypes.cpp
changeset 0 d0791faffa3f
child 15 f85613f12947
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Implementation of sbtypes
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20 */
       
    21 #include <e32std.h>
       
    22 #include <connect/panic.h>
       
    23 #include "sbtypes.h"
       
    24 #include <s32mem.h>
       
    25 #include <apgcli.h>
       
    26 #include <apmstd.h>
       
    27 
       
    28 namespace conn
       
    29 	{
       
    30 	
       
    31 	EXPORT_C CDataOwnerInfo* CDataOwnerInfo::NewL( CSBGenericDataType* aGenericDataType,
       
    32 										  TCommonBURSettings aCommonSettings,
       
    33 										  TPassiveBURSettings aPassiveSettings,
       
    34 										  TActiveBURSettings aActiveSettings,
       
    35 										  const TDriveList& aDriveList )
       
    36 	/**
       
    37 	Symbian constructor. This constructor is used to create a CDataOwnerInfo from it's 
       
    38 	constituent parts, rather than from an externalised class etc.
       
    39 
       
    40 	@param aGenericDataType pointer to CSBGenericDataType object
       
    41 	@param aCommonSettings flags for storing common backup and restore settings
       
    42 	@param aPassiveSettings flags for storing passive backup and restore settings
       
    43 	@param aActiveSettings flags for storing active backup and restore settings
       
    44 	@param aDriveList the array of drives the data owner has data on
       
    45 	@return A pointer to the CDataOwnerInfo object
       
    46 	*/
       
    47 		{
       
    48 		CDataOwnerInfo* self = new(ELeave) CDataOwnerInfo();
       
    49 		CleanupStack::PushL(self);
       
    50 		self->ConstructL(aGenericDataType, aCommonSettings, aPassiveSettings, aActiveSettings, aDriveList);
       
    51 		CleanupStack::Pop(self);
       
    52 		return self;
       
    53 		}
       
    54 
       
    55 	EXPORT_C CDataOwnerInfo* CDataOwnerInfo::NewL( const TDesC8& aFlatDataOwnerInfo )
       
    56 	/**
       
    57 	Symbian constructor for constructing a CDataOwnerInfo object from an externalised CDataOwnerInfo 
       
    58 	object. This may be used when taking an externalised class out of a PC message or over IPC.
       
    59 
       
    60 	@param aFlatDataOwnerInfo a flat data owner info returned from IPC
       
    61 	@return A pointer to the CDataOwnerInfo object
       
    62 	*/
       
    63 		{
       
    64 		CDataOwnerInfo* self = new(ELeave) CDataOwnerInfo();
       
    65 		CleanupStack::PushL(self);
       
    66 		self->ConstructL(aFlatDataOwnerInfo);
       
    67 		CleanupStack::Pop(self);
       
    68 		return self;
       
    69 		}
       
    70 	
       
    71 	CDataOwnerInfo::CDataOwnerInfo()
       
    72 	/**
       
    73 	C++ Constructor 
       
    74 	*/
       
    75 		{
       
    76 		}
       
    77 
       
    78 	EXPORT_C CDataOwnerInfo::~CDataOwnerInfo()
       
    79 	/**
       
    80 	C++ Destructor
       
    81 	*/
       
    82 		{
       
    83 		delete iGenericDataType;
       
    84 		}
       
    85 
       
    86 	void CDataOwnerInfo::ConstructL(CSBGenericDataType* aGenericDataType,
       
    87 									TCommonBURSettings aCommonSettings,
       
    88 									TPassiveBURSettings aPassiveSettings,
       
    89 									TActiveBURSettings aActiveSettings,
       
    90 									const TDriveList& aDriveList)
       
    91 	/**
       
    92 	Symbian OS 2nd phase constructor.
       
    93 
       
    94 	@param aGenericDataType pointer to CSBGenericDataType object
       
    95 	@param aCommonSettings flags for storing common backup and restore settings
       
    96 	@param aPassiveSettings flags for storing passive backup and restore settings
       
    97 	@param aActiveSettings flags for storing active backup and restore settings
       
    98 	@param aDriveList the array of drives the data owner has data on
       
    99 	*/
       
   100 		{
       
   101 		if (aGenericDataType == NULL)
       
   102 			{
       
   103 			User::Leave(KErrArgument);
       
   104 			}
       
   105 		iGenericDataType = aGenericDataType;
       
   106 		iCommonBURSettings = aCommonSettings;
       
   107 		iPassiveBURSettings = aPassiveSettings;
       
   108 		iActiveBURSettings = aActiveSettings;
       
   109 		iDriveList = aDriveList;
       
   110 		}
       
   111 
       
   112 	void CDataOwnerInfo::ConstructL(const TDesC8& aFlatDataOwnerInfo)
       
   113 	/**
       
   114 	Symbian OS 2nd phase constructor. Internalise a descriptor containing a flattened 
       
   115 	object of this type
       
   116 
       
   117 	@param aFlatDataOwnerInfo a flat data owner info returned from IPC
       
   118 	*/
       
   119 		{
       
   120 		// TPtr8 that points to aFlatDataOwnerInfo (which remains const)
       
   121 		TPtr8 pSource(const_cast<TUint8*>(aFlatDataOwnerInfo.Ptr()), aFlatDataOwnerInfo.Size());
       
   122 		pSource.SetMax();
       
   123 		
       
   124 		// Position that we've read up to in the externalised class buffer
       
   125 		TInt sourcePos = 0;
       
   126 		
       
   127 		TInt32 genericDataTypeSize;
       
   128 		
       
   129 		// Extract the CSBGenericDataType's size
       
   130 		UnpackTypeAdvance(genericDataTypeSize, pSource, sourcePos);
       
   131 
       
   132 		// Construct a new CSBGenericDataType from the message
       
   133 		iGenericDataType = CSBGenericDataType::NewL(pSource.MidTPtr(sourcePos, genericDataTypeSize));
       
   134 		sourcePos += genericDataTypeSize;
       
   135 
       
   136 		UnpackTypeAdvance(iCommonBURSettings, pSource, sourcePos);
       
   137 		UnpackTypeAdvance(iPassiveBURSettings, pSource, sourcePos);
       
   138 		UnpackTypeAdvance(iActiveBURSettings, pSource, sourcePos);
       
   139 		UnpackTypeAdvance(iDriveList, pSource, sourcePos);
       
   140 		}
       
   141 		
       
   142 	EXPORT_C CSBGenericDataType& CDataOwnerInfo::Identifier()
       
   143 	/**
       
   144 	Getter method for returning a reference to the CSBGenericDataType
       
   145 	object
       
   146 	
       
   147 	@return Reference to the CSBGenericDataType object
       
   148 	*/
       
   149 		{
       
   150 		return *iGenericDataType;
       
   151 		}
       
   152 		
       
   153 	EXPORT_C const CSBGenericDataType& CDataOwnerInfo::Identifier() const
       
   154 	/**
       
   155 	Getter method for returning a reference to a const CSBGenericDataType
       
   156 	object, containing information including 
       
   157 	
       
   158 	@return Reference to the const CSBGenericDataType object
       
   159 	*/
       
   160 		{
       
   161 		return *iGenericDataType;
       
   162 		}
       
   163 		
       
   164 	EXPORT_C TCommonBURSettings CDataOwnerInfo::CommonSettings() const
       
   165 	/**
       
   166 	Getter method for returning the Backup and Restore flags that
       
   167 	the were specified in the Data Owner's backup registration file
       
   168 	that relate to both Active and Passive backup
       
   169 	
       
   170 	@return The Common backup and restore settings of the Data Owner
       
   171 	*/
       
   172 		{
       
   173 		return iCommonBURSettings;
       
   174 		}
       
   175 		
       
   176 	EXPORT_C TPassiveBURSettings CDataOwnerInfo::PassiveSettings() const
       
   177 	/**
       
   178 	Getter method for returning the Passive Backup and Restore flags that
       
   179 	the were specified in the Data Owner's backup registration file
       
   180 	
       
   181 	@return The passive backup and restore settings of the data owner
       
   182 	*/
       
   183 		{
       
   184 		return iPassiveBURSettings;
       
   185 		}
       
   186 		
       
   187 	EXPORT_C TActiveBURSettings CDataOwnerInfo::ActiveSettings() const
       
   188 	/**
       
   189 	Getter method for returning the Active Backup and Restore flags that
       
   190 	the were specified in the Data Owner's backup registration file
       
   191 	
       
   192 	@return The active backup and restore settings of the data owner
       
   193 	*/
       
   194 		{
       
   195 		return iActiveBURSettings;
       
   196 		}
       
   197 		
       
   198 	EXPORT_C TDriveList& CDataOwnerInfo::DriveList()
       
   199 	/**
       
   200 	Getter method for returning the list of drives on which the Data Owner stores
       
   201 	data to be backed up
       
   202 	
       
   203 	@return The drive list of the data owner
       
   204 	*/
       
   205 		{
       
   206 		return iDriveList;
       
   207 		}
       
   208 		
       
   209 	EXPORT_C const TDriveList& CDataOwnerInfo::DriveList() const
       
   210 	/**
       
   211 	Const getter method for returning the list of drives on which the Data Owner stores
       
   212 	data to be backed up
       
   213 	
       
   214 	@return The drive list of the data owner
       
   215 	*/
       
   216 		{
       
   217 		return iDriveList;
       
   218 		}
       
   219 		
       
   220 	EXPORT_C HBufC8* CDataOwnerInfo::ExternaliseL()
       
   221 	/**
       
   222 	Method to externalise the data owner so that it can be passed flat over the IPC interface 
       
   223 	or appended to a PC bound message, pops the pointer off the cleanup stack before it is
       
   224 	returned
       
   225 	
       
   226 	@return The externalised buffer
       
   227 	*/
       
   228 		{
       
   229 		HBufC8* dataOwnerBuffer = ExternaliseLC();
       
   230 		CleanupStack::Pop(dataOwnerBuffer);
       
   231 		
       
   232 		return dataOwnerBuffer;
       
   233 		}
       
   234 		
       
   235 	EXPORT_C HBufC8* CDataOwnerInfo::ExternaliseLC()
       
   236 	/**
       
   237 	Method to externalise the data owner so that it can be passed flat over the IPC interface 
       
   238 	or appended to a PC bound message, leaves the pointer on the cleanup stack.
       
   239 	
       
   240 	@return The externalised buffer
       
   241 	*/
       
   242 		{
       
   243 		HBufC8* dataBuffer = HBufC8::NewLC(Size());				
       
   244 		TPtr8 bufferPtr(dataBuffer->Des());
       
   245 						
       
   246 		iDriveList.SetMax();	// Ensure that the drivelist array is set to max
       
   247 		const TDesC8& dataType = iGenericDataType->Externalise();
       
   248 		TInt32 typeSize = dataType.Size();
       
   249 		
       
   250 		bufferPtr.Append(reinterpret_cast<TUint8*>(&typeSize),sizeof(TInt32));
       
   251 		bufferPtr.Append(dataType);
       
   252 		bufferPtr.Append(reinterpret_cast<TUint8*>(&iCommonBURSettings), sizeof(TCommonBURSettings));
       
   253 		bufferPtr.Append(reinterpret_cast<TUint8*>(&iPassiveBURSettings), sizeof(TPassiveBURSettings));
       
   254 		bufferPtr.Append(reinterpret_cast<TUint8*>(&iActiveBURSettings), sizeof(TActiveBURSettings));
       
   255 		bufferPtr.Append(iDriveList);
       
   256 		
       
   257 		return dataBuffer;
       
   258 		}
       
   259 		
       
   260 	EXPORT_C TInt CDataOwnerInfo::Size() const
       
   261 	/**
       
   262 	Getter for returning the total flattened size of the object. Used for calculating the 
       
   263 	size of a descriptor to fit the externalised instance of this object
       
   264 	
       
   265 	@return Size of class in bytes once flattened
       
   266 	*/
       
   267 		{
       
   268 		TInt size = 	sizeof(TCommonBURSettings) +
       
   269 						sizeof(TPassiveBURSettings) +
       
   270 						sizeof(TActiveBURSettings) +
       
   271 						sizeof(TInt32) + 	// Buffer size is stored as a TInt32
       
   272 						iGenericDataType->Externalise().Size() +
       
   273 						iDriveList.Size();
       
   274 						
       
   275 		return size;
       
   276 		}
       
   277 		
       
   278 	// CSBGenericDataType			
       
   279 	EXPORT_C CSBGenericDataType* CSBGenericDataType::NewL(const TDesC8& aDes)
       
   280 	/**
       
   281 	Symbian constructor. A base CSBGenericDataType may only be instantiated from a previously 
       
   282 	externalised data type. This is the method that is used to take a generic data type from 
       
   283 	either an IPC response or from a message sent by the PC. This method will not take ownership 
       
   284 	of the descriptor aDes
       
   285 
       
   286 	@param aDes descriptor containing the buffer of data
       
   287 	@return A pointer to the CSBGenericDataType object
       
   288 	*/
       
   289 		{
       
   290 		CSBGenericDataType* self = new(ELeave) CSBGenericDataType();
       
   291 		CleanupStack::PushL(self);
       
   292 		self->ConstructL(aDes);
       
   293 		CleanupStack::Pop(self);
       
   294 		return self;
       
   295 		}
       
   296 	
       
   297 	CSBGenericDataType::CSBGenericDataType(): iDataBuffer(NULL)
       
   298 	/**
       
   299 	C++ Constructor. Any derived types must increment iSize in their C++ constructors in order 
       
   300 	that when CSBGenericDataType::BaseConstructL() is called, the data buffer is initialised 
       
   301 	to be large enough to accomodate the data stored by the derived type
       
   302 	*/
       
   303 		{
       
   304 		// Initialise iSize
       
   305 		iSize = sizeof(TSBDerivedType);
       
   306 		}
       
   307 
       
   308 	EXPORT_C CSBGenericDataType::~CSBGenericDataType()
       
   309 	/**
       
   310 	C++ Destructor
       
   311 	*/
       
   312 		{
       
   313 		delete iDataBuffer;
       
   314 		}
       
   315 
       
   316 	void CSBGenericDataType::ConstructL(const TDesC8& aDes)
       
   317 	/**
       
   318 	Symbian OS 2nd phase constructor. Called when creating a base class from raw data
       
   319 	i.e. off the wire/IPC. Creates the base type data buffer to store object data in
       
   320 
       
   321 	@param aDes descriptor containing the buffer of data
       
   322 	*/
       
   323 		{
       
   324 		// Store the length of the descriptor as our max length
       
   325 		iSize = aDes.Size();
       
   326 			
       
   327 		// Create a new buffer and copy the passed one into it
       
   328 		iDataBuffer = HBufC8::NewL(iSize);
       
   329 		*iDataBuffer = aDes;
       
   330 
       
   331 		TInt offset = 0;
       
   332 		
       
   333 		// Initialise member pointers of all classes in the inheritence tree
       
   334 		InitialiseL(offset);
       
   335 		
       
   336 		// The base type should be as long as the des passed in (more info in a derived)
       
   337 		iDataBuffer->Des().SetLength(iSize);
       
   338 		}
       
   339 		
       
   340 	void CSBGenericDataType::InitialiseL(TInt& aOffset)
       
   341 	/**
       
   342 	Initialise all of member data offsets inside the base and derived classes
       
   343 	
       
   344 	@param 	aOffset The running offset indicating the position in the descriptor that has 
       
   345 			been parsed up to
       
   346 	*/
       
   347 		{
       
   348 		if (iSize < sizeof(TSBDerivedType))
       
   349 			{
       
   350 			User::Leave(KErrCorrupt);
       
   351 			}
       
   352 		
       
   353 		// Throwaway type used to determine the offset advance
       
   354 		TSBDerivedType derivedType;
       
   355 
       
   356 		iDerivedTypeOffset = aOffset;
       
   357 		UnpackTypeAdvance(derivedType, *iDataBuffer, aOffset);
       
   358 		
       
   359 		if (derivedType < 0 || derivedType > KMaxDerivedTypes)
       
   360 			{
       
   361 			User::Leave(KErrCorrupt);
       
   362 			}
       
   363 				
       
   364 		iDataBuffer->Des().SetLength(aOffset);
       
   365 		
       
   366 		}
       
   367 	
       
   368 	void CSBGenericDataType::BaseConstructL()
       
   369 	/**
       
   370 	Symbian OS 2nd phase constructor. Called by derived classes when creating an end 
       
   371 	derived class i.e. CSBSecureId. Constructs base class data buffer to store object
       
   372 	data in. Size of buffer has been determined by C++ constructors of all classes 
       
   373 	in inheritence tree incrementing iSize member so that a buffer big enough to store
       
   374 	the data of all classes is created.
       
   375 	*/
       
   376 		{
       
   377 		// All derived classes should += their size to iSize
       
   378 		iDataBuffer = HBufC8::NewL(iSize);
       
   379 		}
       
   380 		
       
   381 	EXPORT_C const TDesC8& CSBGenericDataType::Externalise() const
       
   382 	/**
       
   383 	Getter for a reference to the buffer containing the data
       
   384 		
       
   385 	@return  Reference to the buffer containing the data
       
   386 	*/
       
   387 		{
       
   388 		return *iDataBuffer;
       
   389 		}
       
   390 		
       
   391 	EXPORT_C TSBDerivedType CSBGenericDataType::DerivedTypeL() const
       
   392 	/**
       
   393 	Getter method for returning the type of the derived object. Used to determine at run time 
       
   394 	which derived type this base type contains
       
   395 	
       
   396 	@return The type of the derived object
       
   397 	*/
       
   398 		{
       
   399 		TSBDerivedType derivedType;
       
   400 		
       
   401 		UnpackType(derivedType, *iDataBuffer, iDerivedTypeOffset);
       
   402 		
       
   403 		return derivedType;
       
   404 		}
       
   405 
       
   406 	void CSBGenericDataType::UnpackDescriptorTypeAdvance(TDesC16& aDes, TInt& aOffset)
       
   407 		/**
       
   408 		Function to copy a simple type from a specified position in aDes
       
   409 		defined by aOffset. aOffset is advanced so that on return, the new 
       
   410 		offset is stored enabling the next call to UnpackType() to point at the position 
       
   411 		following this type.
       
   412 		
       
   413 		@param aDes The buffer that contains the type T pointed to by aPtr
       
   414 		@param aOffset The running index of where the following type begins. Updated by ExtractPointer
       
   415 		*/
       
   416 		{
       
   417 		// Set length of the unicode string in characters
       
   418 		TUint32 length;
       
   419 	
       
   420 		UnpackTypeAdvance(length, *iDataBuffer, aOffset);
       
   421 		
       
   422 		TUint8* pRawSource = reinterpret_cast<TUint8*>(const_cast<TUint16*>(aDes.Ptr()));
       
   423 		TUint8* pRawTarget = const_cast<TUint8*>(static_cast<const TUint8*>(iDataBuffer->Ptr() + aOffset));
       
   424 		
       
   425 		for (TInt32 index = 0; index < (length * KCharWidthInBytes) ; index++)
       
   426 			{
       
   427 			*pRawTarget++ = *pRawSource++;
       
   428 			aOffset++;
       
   429 			}
       
   430 		}
       
   431 
       
   432 	void CSBGenericDataType::UnpackDescriptorTypeAdvance(TDesC8& aDes, TInt& aOffset)
       
   433 		/**
       
   434 		Function to copy a simple type from a specified position in aDes
       
   435 		defined by aOffset. aOffset is advanced so that on return, the new 
       
   436 		offset is stored enabling the next call to UnpackType() to point at the position 
       
   437 		following this type.
       
   438 		
       
   439 		@param aDes The buffer that contains the descriptor to copy from
       
   440 		@param aOffset The running index of where the following type begins. Updated by ExtractPointer
       
   441 		*/
       
   442 		{
       
   443 		// Set length of the string in 8-bit byte characters
       
   444 		TUint32 length;
       
   445 	
       
   446 		UnpackTypeAdvance(length, *iDataBuffer, aOffset);
       
   447 		
       
   448 		TUint8* pRawSource = const_cast<TUint8*>(aDes.Ptr());
       
   449 		TUint8* pRawTarget = const_cast<TUint8*>(iDataBuffer->Ptr() + aOffset);
       
   450 		
       
   451 		for (TInt32 index = 0; index < length ; index++)
       
   452 			{
       
   453 			*pRawTarget++ = *pRawSource++;
       
   454 			aOffset++;
       
   455 			}
       
   456 		}
       
   457 
       
   458 	void CSBGenericDataType::UnpackTPtrAdvance(TPtrC16& aDes, TInt& aOffset)
       
   459 		/**
       
   460 		Function to copy a simple type from a specified position in aDes
       
   461 		defined by aOffset. aOffset is advanced so that on return, the new 
       
   462 		offset is stored enabling the next call to UnpackType() to point at the position 
       
   463 		following this type.
       
   464 		
       
   465 		@param aDes The buffer that contains the type T pointed to by aPtr
       
   466 		@param aOffset The running index of where the following type begins. Updated by ExtractPointer
       
   467 		*/
       
   468 		{
       
   469 		// Set length of the unicode string in characters
       
   470 		TInt32 length;
       
   471 	
       
   472 		UnpackTypeAdvance(length, *iDataBuffer, aOffset);
       
   473 		
       
   474 		aDes.Set(reinterpret_cast<const TUint16*>(iDataBuffer->Ptr() + aOffset), length);
       
   475 
       
   476 		aOffset += aDes.Size();
       
   477 		}
       
   478 
       
   479 	void CSBGenericDataType::UnpackTPtrAdvance(TPtrC8& aDes, TInt& aOffset)
       
   480 		/**
       
   481 		Function to copy a simple type from a specified position in aDes
       
   482 		defined by aOffset. aOffset is advanced so that on return, the new 
       
   483 		offset is stored enabling the next call to UnpackType() to point at the position 
       
   484 		following this type.
       
   485 		
       
   486 		@param aDes The buffer that contains the descriptor to copy from
       
   487 		@param aOffset The running index of where the following type begins. Updated by ExtractPointer
       
   488 		*/
       
   489 		{
       
   490 		// Set length of the string in 8-bit byte characters
       
   491 		TInt32 length;
       
   492 	
       
   493 		UnpackTypeAdvance(length, *iDataBuffer, aOffset);
       
   494 		
       
   495 		aDes.Set(iDataBuffer->Ptr() + aOffset, length);
       
   496 
       
   497 		aOffset += aDes.Size();
       
   498 		}
       
   499 
       
   500 	void CSBGenericDataType::PackDescriptorTypeAdvance(const TDesC16& aDes, TInt& aOffset)
       
   501 		/**
       
   502 		Templated function to copy a simple type into a specified position in aDes
       
   503 		defined by aOffset. aOffset is not advanced as a result of this operation
       
   504 		
       
   505 		@param aDes The buffer to copy from
       
   506 		@param aOffset The running index of where the following type begins. Updated by ExtractPointer
       
   507 		*/
       
   508 		{
       
   509 		TInt32 length = aDes.Length();
       
   510 
       
   511 		PackTypeAdvance(length, *iDataBuffer, aOffset);
       
   512 
       
   513  		TUint8* pRawSource = const_cast<TUint8*>(reinterpret_cast<const TUint8*>(aDes.Ptr()));
       
   514 		TUint8* pRawTarget = const_cast<TUint8*>(reinterpret_cast<const TUint8*>(iDataBuffer->Ptr())) + aOffset;
       
   515 		
       
   516 		for (TInt32 index = 0; index < (length * KCharWidthInBytes); index++)
       
   517 			{
       
   518 			*pRawTarget++ = *pRawSource++;
       
   519 			aOffset++;
       
   520 			}
       
   521 		}
       
   522 
       
   523 	void CSBGenericDataType::PackDescriptorTypeAdvance(const TDesC8& aDes, TInt& aOffset)
       
   524 		/**
       
   525 		Templated function to copy a simple type into a specified position in aDes
       
   526 		defined by aOffset. aOffset is not advanced as a result of this operation
       
   527 		
       
   528 		@param aDes The buffer to copy from
       
   529 		@param aOffset The running index of where the following type begins. Updated by ExtractPointer
       
   530 		*/
       
   531 		{
       
   532 		TInt32 length = aDes.Size();
       
   533 
       
   534 		PackTypeAdvance(length, *iDataBuffer, aOffset);
       
   535 
       
   536 		TUint8* pRawSource = const_cast<TUint8*>(reinterpret_cast<const TUint8*>(aDes.Ptr()));
       
   537 		TUint8* pRawTarget = const_cast<TUint8*>(iDataBuffer->Ptr() + aOffset);
       
   538 		
       
   539 		for (TInt32 index = 0; index < length; index++)
       
   540 			{
       
   541 			*pRawTarget++ = *pRawSource++;
       
   542 			aOffset++;
       
   543 			}
       
   544 		}
       
   545 		
       
   546 		
       
   547 // CSBSecureId
       
   548 	EXPORT_C CSBSecureId* CSBSecureId::NewL(TSecureId aSecureId)
       
   549 	/**
       
   550 	Symbian constructor used for creating a derived class from it's constituent parameters. Used 
       
   551 	for example when creating a derived type from scratch
       
   552 
       
   553 	@param aSecureId the secure identifier
       
   554 	@return A pointer to the CSBSecureId object
       
   555 	*/
       
   556 		{
       
   557 		CSBSecureId* self = new(ELeave) CSBSecureId();
       
   558 		CleanupStack::PushL(self);
       
   559 		self->ConstructL(aSecureId);
       
   560 		CleanupStack::Pop(self);
       
   561 		return self;
       
   562 		}
       
   563 	
       
   564 	EXPORT_C CSBSecureId* CSBSecureId::NewL(CSBGenericDataType* aGenericDataType)
       
   565 	/**
       
   566 	Symbian constructor used when creating a derived type from a base type, typically used 
       
   567 	post-IPC in SBEngine to create a derived type from a generic type originally passed from 
       
   568 	the PC
       
   569 
       
   570 	@param aGenericDataType pointer to a CSBGenericDataType object
       
   571 	@return A pointer to the CSBSecureId object
       
   572 	*/
       
   573 		{
       
   574 		CSBSecureId* self = new(ELeave) CSBSecureId();
       
   575 		CleanupStack::PushL(self);
       
   576 		self->ConstructL(aGenericDataType);
       
   577 		CleanupStack::Pop(self);
       
   578 		return self;
       
   579 		}
       
   580 		
       
   581 	CSBSecureId::CSBSecureId()
       
   582 	/**
       
   583 	C++ Constructor. Any derived types must increment iSize in their C++ constructors in order 
       
   584 	that when CSBGenericDataType::BaseConstructL() is called, the data buffer is initialised 
       
   585 	to be large enough to accomodate the data stored by the derived type
       
   586 	*/
       
   587 		{
       
   588 		iSize += sizeof(TSecureId);
       
   589 		}
       
   590 
       
   591 	EXPORT_C CSBSecureId::~CSBSecureId()
       
   592 	/**
       
   593 	C++ Destructor
       
   594 	*/
       
   595 		{
       
   596 		}
       
   597 
       
   598 	void CSBSecureId::InitialiseL(TInt& aOffset)
       
   599 	/**
       
   600 	Initialise all member pointers to data
       
   601 	
       
   602 	@param aOffset The running offset of where the descriptor has been parsed up to
       
   603 	*/
       
   604 		{
       
   605 		// Throwaway type used for sizeof information only
       
   606 		TSecureId sid;
       
   607 		
       
   608 		CSBGenericDataType::InitialiseL(aOffset);
       
   609 		iSecureIdOffset = aOffset;
       
   610 
       
   611 		UnpackTypeAdvance(sid, *iDataBuffer, aOffset);
       
   612 		
       
   613 		// Increment the size of the data buffer
       
   614 		iDataBuffer->Des().SetLength(aOffset);
       
   615 		}
       
   616 
       
   617 	void CSBSecureId::ConstructL(TSecureId aSecureId)
       
   618 	/**
       
   619 	Symbian OS 2nd phase constructor.
       
   620 
       
   621 	@param aSecureId the secure identifier
       
   622 	*/
       
   623 		{
       
   624 		TInt offset = 0;
       
   625 		// Call the Base ConstructL in order to allocate the buffer
       
   626 		BaseConstructL();
       
   627 		
       
   628 		TSBDerivedType derivedType = ESIDDerivedType;
       
   629 		PackType(derivedType, *iDataBuffer, offset);
       
   630 		
       
   631 		InitialiseL(offset);
       
   632 		
       
   633 		TSecureId sid = aSecureId;
       
   634 		
       
   635 		PackType(sid, *iDataBuffer, iSecureIdOffset);
       
   636 		}
       
   637 		
       
   638 	void CSBSecureId::ConstructL(CSBGenericDataType* aGenericDataType)
       
   639 	/**
       
   640 	Symbian 2nd phase constructor. Validates the externalised type, then passes it to the base ConstructL
       
   641 
       
   642 	@param aGenericDataType pointer to a CSBGenericDataType object
       
   643 	*/
       
   644 		{
       
   645 		if (aGenericDataType == NULL)
       
   646 			{
       
   647 			User::Leave(KErrArgument);
       
   648 			}
       
   649 		if (ESIDDerivedType != aGenericDataType->DerivedTypeL())
       
   650 			{
       
   651 			User::Leave(KErrArgument);
       
   652 			}
       
   653 		// If the descriptor is different to the size we're expecting then it's not correct
       
   654 		const TDesC8& des = aGenericDataType->Externalise();
       
   655 		if (des.Size() != iSize)
       
   656 			{
       
   657 			User::Leave(KErrArgument);
       
   658 			}
       
   659 		
       
   660 		// Call the base class ConstructL
       
   661 		CSBGenericDataType::ConstructL(des);
       
   662 		}
       
   663 		
       
   664 	EXPORT_C TSecureId CSBSecureId::SecureIdL() const
       
   665 	/**
       
   666 	Getter for the secure identifier
       
   667 		
       
   668 	@return  The secure identifier
       
   669 	*/
       
   670 		{
       
   671 		TSecureId sid;
       
   672 		
       
   673 		UnpackType(sid, *iDataBuffer, iSecureIdOffset);
       
   674 		
       
   675 		return sid;
       
   676 		}
       
   677 	
       
   678 	
       
   679 	// CSBPackageId
       
   680 	EXPORT_C CSBPackageId* CSBPackageId::NewL(TUid aPackageId, TSecureId aSecureId, const TDesC& aPackageName)
       
   681 	/**
       
   682 	Symbian constructor used for creating a derived class from it's constituent parameters. Used 
       
   683 	for example when creating a derived type from scratch
       
   684 
       
   685 	@param aPackageId  the package identifier
       
   686 	@param aSecureId  the secure identifier
       
   687 	@param aPackageName  the name of the package
       
   688 	@return A pointer to the CSBPackageId object
       
   689 	*/
       
   690 		{
       
   691 		CSBPackageId* self = new(ELeave) CSBPackageId();
       
   692 		CleanupStack::PushL(self);
       
   693 		self->ConstructL(aPackageId, aSecureId, aPackageName);
       
   694 		CleanupStack::Pop(self);
       
   695 		return self;
       
   696 		}
       
   697 	
       
   698 	EXPORT_C CSBPackageId* CSBPackageId::NewL(CSBGenericDataType* aGenericDataType)
       
   699 	/**
       
   700 	Symbian constructor used when creating a derived type from a base type, typically used 
       
   701 	post-IPC in SBEngine to create a derived type from a generic type originally passed from 
       
   702 	the PC
       
   703 
       
   704 	@param aGenericDataType  pointer to a CSBGenericDataType object
       
   705 	@return A pointer to the CSBPackageId object
       
   706 	*/
       
   707 		{
       
   708 		CSBPackageId* self = new(ELeave) CSBPackageId();
       
   709 		CleanupStack::PushL(self);
       
   710 		self->ConstructL(aGenericDataType);
       
   711 		CleanupStack::Pop(self);
       
   712 		return self;
       
   713 		}	
       
   714 	
       
   715 	CSBPackageId::CSBPackageId()
       
   716 	/**
       
   717 	C++ Constructor. Any derived types must increment iSize in their C++ constructors in order 
       
   718 	that when CSBGenericDataType::BaseConstructL() is called, the data buffer is initialised 
       
   719 	to be large enough to accomodate the data stored by the derived type
       
   720 	*/
       
   721 		{
       
   722 		iSize += (sizeof(TUid) + sizeof(TSecureId) + sizeof(TPackageName));
       
   723 		}
       
   724 
       
   725 	EXPORT_C CSBPackageId::~CSBPackageId()
       
   726 	/**
       
   727 	C++ Destructor
       
   728 	*/
       
   729 		{
       
   730 		}
       
   731 
       
   732 
       
   733 	void CSBPackageId::InitialiseL(TInt& aOffset, TInt aPackageNameLength)
       
   734 	/**
       
   735 	Initialise all member pointers to data
       
   736 	
       
   737 	@param aOffset The running offset of where the descriptor has been parsed up to
       
   738 	@param aPackageNameLength The lenght of the package name
       
   739 	*/
       
   740 		{
       
   741 		TUid pkgId;
       
   742 		TSecureId sid;
       
   743 		TPackageName pkgName;
       
   744 		
       
   745 		CSBGenericDataType::InitialiseL(aOffset);
       
   746 
       
   747 		iPackageIdOffset = aOffset;
       
   748 		// Assign the pointer to the package Id position in the buffer
       
   749 		UnpackTypeAdvance(pkgId, *iDataBuffer, aOffset);
       
   750 
       
   751 		iSecureIdOffset = aOffset;
       
   752 		// Assign the pointer to the secure Id position in the buffer
       
   753 		UnpackTypeAdvance(sid, *iDataBuffer, aOffset);
       
   754 		
       
   755 		iPackageNameOffset = aOffset;
       
   756 		aOffset += sizeof(TInt);
       
   757 		aOffset += aPackageNameLength * KCharWidthInBytes;
       
   758 		
       
   759 		// Increment the size of the data buffer
       
   760 		iDataBuffer->Des().SetLength(aOffset);
       
   761 		}
       
   762 		
       
   763 	void CSBPackageId::InitialiseL(TInt& aOffset)
       
   764 	/**
       
   765 	Initialise all member pointers to data
       
   766 	
       
   767 	@param aOffset The running offset of where the descriptor has been parsed up to
       
   768 	*/
       
   769 		{
       
   770 		TUid pkgId;
       
   771 		TSecureId sid;
       
   772 		TPackageName pkgName;
       
   773 		
       
   774 		CSBGenericDataType::InitialiseL(aOffset);
       
   775 
       
   776 		iPackageIdOffset = aOffset;
       
   777 		// Assign the pointer to the package Id position in the buffer
       
   778 		UnpackTypeAdvance(pkgId, *iDataBuffer, aOffset);
       
   779 
       
   780 		iSecureIdOffset = aOffset;
       
   781 		// Assign the pointer to the secure Id position in the buffer
       
   782 		UnpackTypeAdvance(sid, *iDataBuffer, aOffset);
       
   783 		
       
   784 		iPackageNameOffset = aOffset;
       
   785 		// Assign the pointer to the package name position
       
   786 		
       
   787 		TInt size = *(const_cast<TUint8*>(iDataBuffer->Des().Ptr()) + aOffset);
       
   788 		aOffset += 4;
       
   789 		aOffset += size * KCharWidthInBytes;
       
   790 		
       
   791 		// Increment the size of the data buffer
       
   792 		iDataBuffer->Des().SetLength(aOffset);
       
   793 		}
       
   794 		
       
   795 
       
   796 	void CSBPackageId::ConstructL(TUid aPackageId, TSecureId aSecureId,
       
   797 								  const TDesC& aPackageName)
       
   798 	/**
       
   799 	Symbian OS 2nd phase constructor.
       
   800 
       
   801 	@param aPackageId  the package identifier
       
   802 	@param aSecureId  the secure identifier
       
   803 	@param aPackageName  the name of the package
       
   804 	*/
       
   805 		{
       
   806 		// Call the Base ConstructL in order to allocate the buffer
       
   807 		BaseConstructL();
       
   808 		
       
   809 		TInt offset = 0;
       
   810 		
       
   811 		TSBDerivedType derivedType = EPackageDerivedType;
       
   812 		PackType(derivedType, *iDataBuffer, offset);
       
   813 		
       
   814 		// Initialise all member pointers right up the inheritence tree
       
   815 		InitialiseL(offset, aPackageName.Length());
       
   816 
       
   817 		// Set the passed in data into the data buffer
       
   818 		TUid packageId = aPackageId;
       
   819 		TSecureId secureId = aSecureId;
       
   820 		TPackageName packageName(aPackageName);
       
   821 		
       
   822 		PackType(packageId, *iDataBuffer, iPackageIdOffset);
       
   823 		PackType(secureId, *iDataBuffer, iSecureIdOffset);
       
   824 		PackType(packageName, *iDataBuffer, iPackageNameOffset);
       
   825 		}
       
   826 
       
   827 	void CSBPackageId::ConstructL(CSBGenericDataType* aGenericDataType)
       
   828 	/**
       
   829 	Symbian 2nd phase constructor. Validates the externalised type, then passes it to the base ConstructL
       
   830 
       
   831 	@param aGenericDataType  pointer to a CSBGenericDataType object
       
   832 	*/
       
   833 		{
       
   834 		if (aGenericDataType == NULL)
       
   835 			{
       
   836 			User::Leave(KErrArgument);
       
   837 			}
       
   838 		if (EPackageDerivedType != aGenericDataType->DerivedTypeL())
       
   839 			{
       
   840 			User::Leave(KErrArgument);
       
   841 			}
       
   842 		const TDesC8& des = aGenericDataType->Externalise();
       
   843 		
       
   844 		if (des.Size() > iSize)
       
   845 			{
       
   846 			User::Leave(KErrArgument);
       
   847 			}
       
   848 		// Call the base class ConstructL
       
   849 		CSBGenericDataType::ConstructL(des);
       
   850 		}
       
   851 		
       
   852 	EXPORT_C TUid CSBPackageId::PackageIdL() const
       
   853 	/**
       
   854 	Getter for the package identifier
       
   855 		
       
   856 	@return  The package identifier
       
   857 	*/
       
   858 		{
       
   859 		TUid pkgId;
       
   860 		
       
   861 		UnpackType(pkgId, *iDataBuffer, iPackageIdOffset);
       
   862 		
       
   863 		return pkgId;
       
   864 		}
       
   865 		
       
   866 	EXPORT_C TSecureId CSBPackageId::SecureIdL() const
       
   867 	/**
       
   868 	Getter for the secure identifier
       
   869 		
       
   870 	@return  The secure identifier
       
   871 	*/
       
   872 		{
       
   873 		TSecureId secureId;
       
   874 		
       
   875 		UnpackType(secureId, *iDataBuffer, iSecureIdOffset);
       
   876 		
       
   877 		return secureId;
       
   878 		}
       
   879 
       
   880 	EXPORT_C TPackageName CSBPackageId::PackageNameL() const
       
   881 	/**
       
   882 	Getter for the package name
       
   883 		
       
   884 	@return  Reference to the package name
       
   885 	*/
       
   886 		{
       
   887 		TPackageName pkgName;
       
   888 		
       
   889 		UnpackType(pkgName, *iDataBuffer, iPackageNameOffset);
       
   890 		
       
   891 		return pkgName;
       
   892 		}
       
   893 
       
   894 
       
   895 	// CSBGenericDataType
       
   896 	EXPORT_C CSBGenericTransferType* CSBGenericTransferType::NewL(const TDesC8& aDes)
       
   897 	/**
       
   898 	Symbian constructor
       
   899 
       
   900 	@param aDes descriptor containing the buffer of data
       
   901 	@return A pointer to the CSBGenericTransferType object
       
   902 	*/
       
   903 		{
       
   904 		CSBGenericTransferType* self = new(ELeave) CSBGenericTransferType();
       
   905 		CleanupStack::PushL(self);
       
   906 		self->CSBGenericDataType::ConstructL(aDes);
       
   907 		CleanupStack::Pop(self);
       
   908 		return self;
       
   909 		}
       
   910 
       
   911 	void CSBGenericTransferType::InitialiseL(TInt& aOffset)
       
   912 	/**
       
   913 	Initialise all member pointers to data
       
   914 	
       
   915 	@param aOffset The running offset of where the descriptor has been parsed up to
       
   916 	*/
       
   917 		{
       
   918 		CSBGenericDataType::InitialiseL(aOffset);
       
   919 		
       
   920 		if (iSize < (aOffset + sizeof(TDriveNumber)))
       
   921 			{
       
   922 			User::Leave(KErrCorrupt);
       
   923 			}
       
   924 		
       
   925 		// Dummy data to get sizeof information from
       
   926 		TDriveNumber driveNum;
       
   927 		
       
   928 		iDriveNumberOffset = aOffset;
       
   929 		UnpackTypeAdvance(driveNum, *iDataBuffer, aOffset);
       
   930 		
       
   931 		// Increment the size of the data buffer
       
   932 		iDataBuffer->Des().SetLength(aOffset);
       
   933 		}
       
   934 	
       
   935 	CSBGenericTransferType::CSBGenericTransferType()
       
   936 	/**
       
   937 	C++ Constructor. Any derived types must increment iSize in their C++ constructors in order 
       
   938 	that when CSBGenericDataType::BaseConstructL() is called, the data buffer is initialised 
       
   939 	to be large enough to accomodate the data stored by the derived type
       
   940 	*/
       
   941 		{
       
   942 		iSize += sizeof(TDriveNumber);
       
   943 		}
       
   944 
       
   945 	EXPORT_C CSBGenericTransferType::~CSBGenericTransferType()
       
   946 	/**
       
   947 	C++ Destructor
       
   948 	*/
       
   949 		{
       
   950 		}
       
   951 
       
   952 	EXPORT_C TDriveNumber CSBGenericTransferType::DriveNumberL() const
       
   953 	/**
       
   954 	Getter method for returning the drive number
       
   955 	
       
   956 	@return The drive number
       
   957 	*/
       
   958 		{
       
   959 		TDriveNumber driveNum;
       
   960 		
       
   961 		UnpackType(driveNum, *iDataBuffer, iDriveNumberOffset);
       
   962 		
       
   963 		return driveNum;
       
   964 		}
       
   965 		
       
   966 	// CSBSIDTransferType
       
   967 	EXPORT_C CSBSIDTransferType* CSBSIDTransferType::NewL(TSecureId aSecureId, TDriveNumber aDriveNumber, TTransferDataType aTransferDataType)
       
   968 	/**
       
   969 	Symbian constructor used for creating a derived class from it's constituent parameters. Used 
       
   970 	for example when creating a derived type from scratch
       
   971 
       
   972 	@param aSecureId the secure identifier
       
   973 	@param aDriveNumber the drive that contains the data
       
   974 	@param aTransferDataType the type of the data you wish to transfer
       
   975 	@return A pointer to the CSBSIDTransferType object
       
   976 	*/
       
   977 		{
       
   978 		CSBSIDTransferType* self = new(ELeave) CSBSIDTransferType();
       
   979 		CleanupStack::PushL(self);
       
   980 		self->ConstructL(aSecureId, aDriveNumber, aTransferDataType);
       
   981 		CleanupStack::Pop(self);
       
   982 		return self;
       
   983 		}
       
   984 	
       
   985 	EXPORT_C CSBSIDTransferType* CSBSIDTransferType::NewL(CSBGenericTransferType* aGenericTransferType)
       
   986 	/**
       
   987 	Symbian constructor used when creating a derived type from a base type, typically used 
       
   988 	post-IPC in SBEngine to create a derived type from a generic type originally passed from 
       
   989 	the PC
       
   990 
       
   991 	@param aGenericTransferType pointer to a CSBGenericTransferType object
       
   992 	@return A pointer to the CSBSIDTransferType object
       
   993 	*/
       
   994 		{
       
   995 		CSBSIDTransferType* self = new(ELeave) CSBSIDTransferType();
       
   996 		CleanupStack::PushL(self);
       
   997 		self->ConstructL(aGenericTransferType);
       
   998 		CleanupStack::Pop(self);
       
   999 		return self;
       
  1000 		}	
       
  1001 	
       
  1002 	CSBSIDTransferType::CSBSIDTransferType()
       
  1003 	/**
       
  1004 	C++ Constructor. Any derived types must increment iSize in their C++ constructors in order 
       
  1005 	that when CSBGenericDataType::BaseConstructL() is called, the data buffer is initialised 
       
  1006 	to be large enough to accomodate the data stored by the derived type
       
  1007 	*/
       
  1008 		{
       
  1009 		iSize += (sizeof(TSecureId) + sizeof(TTransferDataType));
       
  1010 		}
       
  1011 
       
  1012 	EXPORT_C CSBSIDTransferType::~CSBSIDTransferType()
       
  1013 	/**
       
  1014 	C++ Destructor
       
  1015 	*/
       
  1016 		{
       
  1017 		}
       
  1018 
       
  1019 	void CSBSIDTransferType::InitialiseL(TInt& aOffset)
       
  1020 	/**
       
  1021 	Initialise all member pointers to data
       
  1022 	
       
  1023 	@param aOffset The running offset of where the descriptor has been parsed up to
       
  1024 	*/
       
  1025 		{
       
  1026 		CSBGenericTransferType::InitialiseL(aOffset);
       
  1027 
       
  1028 		TSecureId sid;
       
  1029 		TTransferDataType transType;
       
  1030 
       
  1031 		iSecureIdOffset = aOffset;
       
  1032 		UnpackTypeAdvance(sid, *iDataBuffer, aOffset);
       
  1033 		
       
  1034 		iTransferDataTypeOffset = aOffset;
       
  1035 		UnpackTypeAdvance(transType, *iDataBuffer, aOffset);
       
  1036 		
       
  1037 		// Increment the size of the data buffer
       
  1038 		iDataBuffer->Des().SetLength(aOffset);
       
  1039 		}
       
  1040 
       
  1041 	void CSBSIDTransferType::ConstructL(TSecureId aSecureId, TDriveNumber aDriveNumber,
       
  1042 										TTransferDataType aTransferDataType)
       
  1043 	/**
       
  1044 	Symbian OS 2nd phase constructor.
       
  1045 
       
  1046 	@param aSecureId the secure identifier
       
  1047 	@param aDriveNumber the drive that contains the data
       
  1048 	@param aTransferDataType the type of the data you wish to transfer
       
  1049 	*/
       
  1050 		{
       
  1051 		TInt offset = 0;
       
  1052 
       
  1053 		BaseConstructL();
       
  1054 
       
  1055 		TSBDerivedType derivedType = ESIDTransferDerivedType;
       
  1056 		PackType(derivedType, *iDataBuffer, offset);
       
  1057 				
       
  1058 		InitialiseL(offset);
       
  1059 
       
  1060 		TDriveNumber driveNum = aDriveNumber;
       
  1061 		TSecureId sid = aSecureId;
       
  1062 		TTransferDataType transType = aTransferDataType;
       
  1063 
       
  1064 		PackType(driveNum, *iDataBuffer, iDriveNumberOffset);
       
  1065 		PackType(sid, *iDataBuffer, iSecureIdOffset);
       
  1066 		PackType(transType, *iDataBuffer, iTransferDataTypeOffset);
       
  1067 		}
       
  1068 
       
  1069 	void CSBSIDTransferType::ConstructL(CSBGenericTransferType* aGenericTransferType)
       
  1070 	/**
       
  1071 	Symbian 2nd phase constructor. Validates the externalised type, then passes it to the base ConstructL
       
  1072 
       
  1073 	@param aGenericTransferType pointer to a CSBGenericTransferType object
       
  1074 	*/
       
  1075 		{
       
  1076 		if (aGenericTransferType == NULL)
       
  1077 			{
       
  1078 			User::Leave(KErrArgument);
       
  1079 			}
       
  1080 		if (ESIDTransferDerivedType != aGenericTransferType->DerivedTypeL())
       
  1081 			{
       
  1082 			User::Leave(KErrArgument);
       
  1083 			}
       
  1084 		// If the descriptor is different to the size we're expecting then it's not correct
       
  1085 		const TDesC8& des = aGenericTransferType->Externalise();
       
  1086 		if (des.Size() != iSize)
       
  1087 			{
       
  1088 			User::Leave(KErrArgument);
       
  1089 			}
       
  1090 		
       
  1091 		// Call the base class ConstructL
       
  1092 		CSBGenericDataType::ConstructL(des);
       
  1093 		}
       
  1094 		
       
  1095 	EXPORT_C TSecureId CSBSIDTransferType::SecureIdL() const
       
  1096 	/**
       
  1097 	Getter for the secure identifier
       
  1098 		
       
  1099 	@return  The secure identifier
       
  1100 	*/
       
  1101 		{
       
  1102 		TSecureId sid;
       
  1103 		
       
  1104 		UnpackType(sid, *iDataBuffer, iSecureIdOffset);
       
  1105 		
       
  1106 		return sid;
       
  1107 		}
       
  1108 
       
  1109 	EXPORT_C TTransferDataType CSBSIDTransferType::DataTypeL() const
       
  1110 	/**
       
  1111 	Getter for the transfer data type
       
  1112 		
       
  1113 	@return  The transfer data type
       
  1114 	*/
       
  1115 		{
       
  1116 		TTransferDataType transType;
       
  1117 		
       
  1118 		UnpackType(transType, *iDataBuffer, iTransferDataTypeOffset);
       
  1119 
       
  1120 		return transType;
       
  1121 		}
       
  1122 		
       
  1123 		
       
  1124 	// CSBPackageTransferType
       
  1125 	EXPORT_C CSBPackageTransferType* CSBPackageTransferType::NewL(TUid aPackageId, TDriveNumber aDriveNumber,
       
  1126 																  TPackageDataType aPackageDataType)
       
  1127 	/**
       
  1128 	Symbian constructor used for creating a derived class from it's constituent parameters. Used 
       
  1129 	for example when creating a derived type from scratch
       
  1130 
       
  1131 	@param aPackageId the package identifier
       
  1132 	@param aDriveNumber the drive that contains the data
       
  1133 	@param aPackageDataType the type of the package data
       
  1134 	@return A pointer to the CSBPackageTransferType object
       
  1135 	*/
       
  1136 		{
       
  1137 		CSBPackageTransferType* self = new(ELeave) CSBPackageTransferType();
       
  1138 		CleanupStack::PushL(self);
       
  1139 		self->ConstructL(aPackageId, aDriveNumber, aPackageDataType);
       
  1140 		CleanupStack::Pop(self);
       
  1141 		return self;
       
  1142 		}
       
  1143 	
       
  1144 	EXPORT_C CSBPackageTransferType* CSBPackageTransferType::NewL(CSBGenericTransferType* aGenericTransferType)
       
  1145 	/**
       
  1146 	Symbian constructor used when creating a derived type from a base type, typically used 
       
  1147 	post-IPC in SBEngine to create a derived type from a generic type originally passed from 
       
  1148 	the PC
       
  1149 
       
  1150 	@param aGenericTransferType pointer to a CSBGenericTransferType object
       
  1151 	@return A pointer to the CSBPackageTransferType object
       
  1152 	*/
       
  1153 		{
       
  1154 		CSBPackageTransferType* self = new(ELeave) CSBPackageTransferType();
       
  1155 		CleanupStack::PushL(self);
       
  1156 		self->ConstructL(aGenericTransferType);
       
  1157 		CleanupStack::Pop(self);
       
  1158 		return self;
       
  1159 		}	
       
  1160 	
       
  1161 	CSBPackageTransferType::CSBPackageTransferType()
       
  1162 	/**
       
  1163 	C++ Constructor. Any derived types must increment iSize in their C++ constructors in order 
       
  1164 	that when CSBGenericDataType::BaseConstructL() is called, the data buffer is initialised 
       
  1165 	to be large enough to accomodate the data stored by the derived type
       
  1166 	*/
       
  1167 		{
       
  1168 		iSize += (sizeof(TUid) + sizeof(TPackageDataType));
       
  1169 		}
       
  1170 
       
  1171 	void CSBPackageTransferType::InitialiseL(TInt& aOffset)
       
  1172 	/**
       
  1173 	Initialise all member pointers to data
       
  1174 	
       
  1175 	@param aOffset The running offset of where the descriptor has been parsed up to
       
  1176 	*/
       
  1177 		{
       
  1178 		CSBGenericTransferType::InitialiseL(aOffset);
       
  1179 
       
  1180 		TUid pkgId;
       
  1181 		TPackageDataType pkgDataType;
       
  1182 		
       
  1183 		iPackageIdOffset = aOffset;
       
  1184 		UnpackTypeAdvance(pkgId, *iDataBuffer, aOffset);
       
  1185 		
       
  1186 		iPackageDataTypeOffset = aOffset;
       
  1187 		UnpackTypeAdvance(pkgDataType, *iDataBuffer, aOffset);
       
  1188 		
       
  1189 		// Increment the size of the data buffer
       
  1190 		iDataBuffer->Des().SetLength(aOffset);
       
  1191 		}
       
  1192 
       
  1193 	EXPORT_C CSBPackageTransferType::~CSBPackageTransferType()
       
  1194 	/**
       
  1195 	C++ Destructor
       
  1196 	*/
       
  1197 		{
       
  1198 		}
       
  1199 
       
  1200 	void CSBPackageTransferType::ConstructL(TUid aPackageId, TDriveNumber aDriveNumber,
       
  1201 										TPackageDataType aPackageDataType)
       
  1202 	/**
       
  1203 	Symbian OS 2nd phase constructor.
       
  1204 
       
  1205 	@param aPackageId the secure identifier
       
  1206 	@param aDriveNumber the drive that contains the data
       
  1207 	@param aPackageDataType the type of the data you wish to transfer
       
  1208 	*/
       
  1209 		{
       
  1210 		TInt offset = 0;
       
  1211 
       
  1212 		BaseConstructL();
       
  1213 
       
  1214 		TSBDerivedType derivedType = EPackageTransferDerivedType;
       
  1215 		PackType(derivedType, *iDataBuffer, offset);
       
  1216 				
       
  1217 		InitialiseL(offset);
       
  1218 
       
  1219 		TPackageDataType pkgDataType = aPackageDataType;
       
  1220 		TDriveNumber driveNum = aDriveNumber;
       
  1221 		TUid pkgId = aPackageId;
       
  1222 		
       
  1223 		PackType(driveNum, *iDataBuffer, iDriveNumberOffset);
       
  1224 		PackType(pkgId, *iDataBuffer, iPackageIdOffset);
       
  1225 		PackType(pkgDataType, *iDataBuffer, iPackageDataTypeOffset);
       
  1226 		}
       
  1227 
       
  1228 	void CSBPackageTransferType::ConstructL(CSBGenericTransferType* aGenericTransferType)
       
  1229 	/**
       
  1230 	Symbian 2nd phase constructor. Validates the externalised type, then passes it to the base ConstructL
       
  1231 
       
  1232 	@param aGenericTransferType pointer to a CSBGenericTransferType object
       
  1233 	*/
       
  1234 		{
       
  1235 		if (aGenericTransferType == NULL)
       
  1236 			{
       
  1237 			User::Leave(KErrArgument);
       
  1238 			}
       
  1239 		if (EPackageTransferDerivedType != aGenericTransferType->DerivedTypeL())
       
  1240 			{
       
  1241 			User::Leave(KErrArgument);
       
  1242 			}
       
  1243 		// If the descriptor is different to the size we're expecting then it's not correct
       
  1244 		const TDesC8& des = aGenericTransferType->Externalise();
       
  1245 		
       
  1246 		if (des.Size() != iSize)
       
  1247 			{
       
  1248 			User::Leave(KErrArgument);
       
  1249 			}
       
  1250 		
       
  1251 		// Call the base class ConstructL
       
  1252 		CSBGenericDataType::ConstructL(des);
       
  1253 		}
       
  1254 		
       
  1255 	EXPORT_C TUid CSBPackageTransferType::PackageIdL() const
       
  1256 	/**
       
  1257 	Getter for the package identifier
       
  1258 		
       
  1259 	@return  The package identifier
       
  1260 	*/
       
  1261 		{
       
  1262 		TUid pkgId;
       
  1263 		
       
  1264 		UnpackType(pkgId, *iDataBuffer, iPackageIdOffset);
       
  1265 		
       
  1266 		return pkgId;
       
  1267 		}
       
  1268 
       
  1269 	EXPORT_C TPackageDataType CSBPackageTransferType::DataTypeL() const
       
  1270 	/**
       
  1271 	Getter for the package data type
       
  1272 		
       
  1273 	@return  The package data type
       
  1274 	*/
       
  1275 		{
       
  1276 		TPackageDataType pkgDataType;
       
  1277 		
       
  1278 		UnpackType(pkgDataType, *iDataBuffer, iPackageDataTypeOffset);
       
  1279 		
       
  1280 		return pkgDataType;
       
  1281 		}
       
  1282 		
       
  1283 // JavaID
       
  1284 
       
  1285 	EXPORT_C CSBJavaId* CSBJavaId::NewL(const TDesC& aSuiteName, const TDesC& aSuiteVendor,
       
  1286 		const TDesC& aSuiteVersion, const TDesC& aSuiteHash)
       
  1287 	/**
       
  1288 	Symbian constructor used for creating a derived class from it's constituent parameters. Used 
       
  1289 	for example when creating a derived type from scratch
       
  1290 
       
  1291 	@param aSuiteName  the name of the java suite
       
  1292 	@param aSuiteVendor  the suite vendor
       
  1293 	@param aSuiteVersion  the version of the java suite
       
  1294 	@param aSuiteHash the hash of the java suite
       
  1295 	@return A pointer to the CSBJavaId object
       
  1296 	*/
       
  1297 		{
       
  1298 		CSBJavaId* self = new(ELeave) CSBJavaId(aSuiteName, aSuiteVendor, aSuiteVersion, aSuiteHash);
       
  1299 		CleanupStack::PushL(self);
       
  1300 		self->ConstructL(aSuiteName, aSuiteVendor, aSuiteVersion, aSuiteHash);
       
  1301 		CleanupStack::Pop(self);
       
  1302 		return self;
       
  1303 		}
       
  1304 	
       
  1305 	EXPORT_C CSBJavaId* CSBJavaId::NewL(CSBGenericDataType* aGenericDataType)
       
  1306 	/**
       
  1307 	Symbian constructor used when creating a derived type from a base type, typically used 
       
  1308 	post-IPC in SBEngine to create a derived type from a generic type originally passed from 
       
  1309 	the PC
       
  1310 
       
  1311 	@param aGenericDataType  pointer to a CSBGenericDataType object
       
  1312 	@return A pointer to the CSBJavaId object
       
  1313 	*/
       
  1314 		{
       
  1315 		CSBJavaId* self = new(ELeave) CSBJavaId;
       
  1316 		CleanupStack::PushL(self);
       
  1317 		self->ConstructFromExistingL(aGenericDataType);
       
  1318 		CleanupStack::Pop(self);
       
  1319 		return self;
       
  1320 		}	
       
  1321 		
       
  1322 	CSBJavaId::CSBJavaId()
       
  1323 		{
       
  1324 		}
       
  1325 	
       
  1326 	CSBJavaId::CSBJavaId(const TDesC& aSuiteName, const TDesC& aSuiteVendor,
       
  1327 		const TDesC& aSuiteVersion, const TDesC& aSuiteHash)
       
  1328 	/**
       
  1329 	C++ Constructor. Any derived types must increment iSize in their C++ constructors in order 
       
  1330 	that when CSBGenericDataType::BaseConstructL() is called, the data buffer is initialised 
       
  1331 	to be large enough to accomodate the data stored by the derived type
       
  1332 	
       
  1333 	@param aSuiteName The name of the MIDlet suite
       
  1334 	@param aSuiteVendor The name of the vendor of the MIDlet suiet
       
  1335 	@param aSuiteHash The Java MIDlet suite hash
       
  1336 	@param aSuiteVersion The version of the MIDlet suite
       
  1337 	*/
       
  1338 		{
       
  1339 		iSize += (4 * sizeof(TUint32)) + aSuiteName.Size() + aSuiteVendor.Size() + aSuiteVersion.Size() 
       
  1340 			+ aSuiteHash.Size();
       
  1341 		}
       
  1342 
       
  1343 	EXPORT_C CSBJavaId::~CSBJavaId()
       
  1344 	/**
       
  1345 	C++ Destructor
       
  1346 	*/
       
  1347 		{
       
  1348 		}
       
  1349 
       
  1350 	void CSBJavaId::InitialiseL(TInt& aOffset)
       
  1351 	/**
       
  1352 	Initialise all member pointers to data
       
  1353 	
       
  1354 	@param aOffset The running offset of where the descriptor has been parsed up to
       
  1355 	*/
       
  1356 		{
       
  1357 		CSBGenericDataType::InitialiseL(aOffset);
       
  1358 		
       
  1359 		UnpackTPtrAdvance(iSuiteName, aOffset);
       
  1360 		UnpackTPtrAdvance(iSuiteVendor, aOffset);
       
  1361 		UnpackTPtrAdvance(iSuiteVersion, aOffset);
       
  1362 		UnpackTPtrAdvance(iSuiteHash, aOffset);
       
  1363 
       
  1364 		// Increment the size of the data buffer
       
  1365 		iDataBuffer->Des().SetLength(aOffset);
       
  1366 		}
       
  1367 
       
  1368 	void CSBJavaId::InitialiseL(TInt& aOffset, const TDesC& aSuiteName, const TDesC& aSuiteVendor,
       
  1369 		const TDesC& aSuiteVersion, const TDesC& aSuiteHash)
       
  1370 	/**
       
  1371 	Initialise all member pointers to data
       
  1372 	
       
  1373 	@param aOffset The running offset of where the descriptor has been parsed up to
       
  1374 	@param aSuiteName The name of the MIDlet suite
       
  1375 	@param aSuiteVendor The name of the vendor of the MIDlet suiet
       
  1376 	@param aSuiteHash The Java MIDlet suite hash
       
  1377 	@param aSuiteVersion The version of the MIDlet suite
       
  1378 	*/
       
  1379 		{
       
  1380 		TSBDerivedType derivedType = EJavaDerivedType;
       
  1381 		
       
  1382 		PackType(derivedType, *iDataBuffer, aOffset);
       
  1383 		
       
  1384 		CSBGenericDataType::InitialiseL(aOffset);
       
  1385 
       
  1386 		// Set the derived type in the buffer
       
  1387 		
       
  1388 		TInt ptrOffset = aOffset;
       
  1389 
       
  1390 		PackDescriptorTypeAdvance(aSuiteName, aOffset);
       
  1391 		PackDescriptorTypeAdvance(aSuiteVendor, aOffset);
       
  1392 		PackDescriptorTypeAdvance(aSuiteVersion, aOffset);
       
  1393 		PackDescriptorTypeAdvance(aSuiteHash, aOffset);
       
  1394 		
       
  1395 		UnpackTPtrAdvance(iSuiteName, ptrOffset);
       
  1396 		UnpackTPtrAdvance(iSuiteVendor, ptrOffset);
       
  1397 		UnpackTPtrAdvance(iSuiteVersion, ptrOffset);
       
  1398 		UnpackTPtrAdvance(iSuiteHash, ptrOffset);
       
  1399 		
       
  1400 		// Increment the size of the data buffer
       
  1401 		iDataBuffer->Des().SetLength(aOffset);
       
  1402 		}
       
  1403 		
       
  1404 	void CSBJavaId::ConstructL(const TDesC& aSuiteName, const TDesC& aSuiteVendor, 
       
  1405 		const TDesC& aSuiteVersion, const TDesC& aSuiteHash)
       
  1406 	/**
       
  1407 	Symbian OS 2nd phase constructor.
       
  1408 
       
  1409 	@param aSuiteName The name of the MIDlet suite
       
  1410 	@param aSuiteVendor The name of the vendor of the MIDlet suiet
       
  1411 	@param aSuiteHash The Java MIDlet suite hash
       
  1412 	@param aSuiteVersion The version of the MIDlet suite
       
  1413 	*/
       
  1414 		{
       
  1415 		// Call the Base ConstructL in order to allocate the buffer
       
  1416 		BaseConstructL();
       
  1417 		
       
  1418 		TInt offset = 0;
       
  1419 		
       
  1420 		// Initialise all member pointers right up the inheritence tree
       
  1421 		InitialiseL(offset, aSuiteName, aSuiteVendor, aSuiteVersion, aSuiteHash);
       
  1422 		}
       
  1423 
       
  1424 	void CSBJavaId::ConstructFromExistingL(CSBGenericDataType* aGenericDataType)
       
  1425 	/**
       
  1426 	Symbian 2nd phase constructor. Validates the externalised type, then passes it to the base ConstructL
       
  1427 
       
  1428 	@param aGenericDataType  pointer to a CSBGenericDataType object
       
  1429 	*/
       
  1430 		{
       
  1431 		if (aGenericDataType == NULL)
       
  1432 			{
       
  1433 			User::Leave(KErrArgument);
       
  1434 			}
       
  1435 		if (EJavaDerivedType != aGenericDataType->DerivedTypeL())
       
  1436 			{
       
  1437 			User::Leave(KErrArgument);
       
  1438 			}
       
  1439 		// Call the base class ConstructL
       
  1440 		CSBGenericDataType::ConstructL(aGenericDataType->Externalise());
       
  1441 		}
       
  1442 		
       
  1443 	EXPORT_C const TDesC& CSBJavaId::SuiteNameL() const
       
  1444 	/**
       
  1445 	Getter for the MIDlet suite name
       
  1446 		
       
  1447 	@return  The package identifier
       
  1448 	*/
       
  1449 		{
       
  1450 		return iSuiteName;
       
  1451 		}
       
  1452 
       
  1453 	EXPORT_C const TDesC& CSBJavaId::SuiteVendorL() const
       
  1454 	/**
       
  1455 	Getter for the MIDlet suite vendor
       
  1456 		
       
  1457 	@return  The package identifier
       
  1458 	*/
       
  1459 		{
       
  1460 		return iSuiteVendor;
       
  1461 		}
       
  1462 
       
  1463 	EXPORT_C const TDesC& CSBJavaId::SuiteVersionL() const
       
  1464 	/**
       
  1465 	Getter for the MIDlet suite version
       
  1466 		
       
  1467 	@return  The package identifier
       
  1468 	*/
       
  1469 		{
       
  1470 		return iSuiteVersion;
       
  1471 		}
       
  1472 
       
  1473 	EXPORT_C const TDesC& CSBJavaId::SuiteHashL() const
       
  1474 	/**
       
  1475 	Getter for the MIDlet suite hash
       
  1476 		
       
  1477 	@return  The package identifier
       
  1478 	*/
       
  1479 		{
       
  1480 		return iSuiteHash;
       
  1481 		}
       
  1482 
       
  1483 // CSBJavaTransferType
       
  1484 	EXPORT_C CSBJavaTransferType* CSBJavaTransferType::NewL(const TDesC& aSuiteHash, TDriveNumber aDriveNumber, TJavaTransferType aTransferDataType)
       
  1485 	/**
       
  1486 	Symbian constructor used for creating a derived class from it's constituent parameters. Used 
       
  1487 	for example when creating a derived type from scratch
       
  1488 
       
  1489 	@param aSecureId the secure identifier
       
  1490 	@param aDriveNumber the drive that contains the data
       
  1491 	@param aTransferDataType the type of the data you wish to transfer
       
  1492 	@return A pointer to the CSBJavaTransferType object
       
  1493 	*/
       
  1494 		{
       
  1495 		CSBJavaTransferType* self = new(ELeave) CSBJavaTransferType(aSuiteHash);
       
  1496 		CleanupStack::PushL(self);
       
  1497 		self->ConstructL(aSuiteHash, aDriveNumber, aTransferDataType);
       
  1498 		CleanupStack::Pop(self);
       
  1499 		return self;
       
  1500 		}
       
  1501 	
       
  1502 	EXPORT_C CSBJavaTransferType* CSBJavaTransferType::NewL(CSBGenericTransferType* aGenericTransferType)
       
  1503 	/**
       
  1504 	Symbian constructor used when creating a derived type from a base type, typically used 
       
  1505 	post-IPC in SBEngine to create a derived type from a generic type originally passed from 
       
  1506 	the PC
       
  1507 
       
  1508 	@param aGenericTransferType pointer to a CSBGenericTransferType object
       
  1509 	@return A pointer to the CSBJavaTransferType object
       
  1510 	*/
       
  1511 		{
       
  1512 		CSBJavaTransferType* self = new(ELeave) CSBJavaTransferType;
       
  1513 		CleanupStack::PushL(self);
       
  1514 		self->ConstructL(aGenericTransferType);
       
  1515 		CleanupStack::Pop(self);
       
  1516 		return self;
       
  1517 		}
       
  1518 		
       
  1519 	CSBJavaTransferType::CSBJavaTransferType()
       
  1520 	/**
       
  1521 	C++ Constructor
       
  1522 	*/
       
  1523 		{
       
  1524 		}
       
  1525 	
       
  1526 	CSBJavaTransferType::CSBJavaTransferType(const TDesC& aSuiteHash)
       
  1527 	/**
       
  1528 	C++ Constructor. Any derived types must increment iSize in their C++ constructors in order 
       
  1529 	that when CSBGenericDataType::BaseConstructL() is called, the data buffer is initialised 
       
  1530 	to be large enough to accomodate the data stored by the derived type
       
  1531 	*/
       
  1532 		{
       
  1533 		iSize += aSuiteHash.Size() + sizeof(TUint32) + sizeof(TJavaTransferType);
       
  1534 		}
       
  1535 
       
  1536 	EXPORT_C CSBJavaTransferType::~CSBJavaTransferType()
       
  1537 	/**
       
  1538 	C++ Destructor
       
  1539 	*/
       
  1540 		{
       
  1541 		}
       
  1542 
       
  1543 	void CSBJavaTransferType::InitialiseL(TInt& aOffset)
       
  1544 	/**
       
  1545 	Initialise all member pointers to data
       
  1546 	
       
  1547 	@param aOffset The running offset of where the descriptor has been parsed up to
       
  1548 	*/
       
  1549 		{
       
  1550 		CSBGenericTransferType::InitialiseL(aOffset);
       
  1551 		
       
  1552 		iTransferDataTypeOffset = aOffset;
       
  1553 		TJavaTransferType transType;
       
  1554 		UnpackTypeAdvance(transType, *iDataBuffer, aOffset);
       
  1555 		
       
  1556 		UnpackTPtrAdvance(iSuiteHash, aOffset);
       
  1557 
       
  1558 		// Increment the size of the data buffer
       
  1559 		iDataBuffer->Des().SetLength(aOffset);
       
  1560 		}
       
  1561 
       
  1562 	void CSBJavaTransferType::InitialiseL(TInt& aOffset, const TDesC& aSuiteHash, TDriveNumber aDriveNumber,
       
  1563 										TJavaTransferType aTransferDataType)
       
  1564 	/**
       
  1565 	Initialise all member pointers to data
       
  1566 	
       
  1567 	@param aOffset The running offset of where the descriptor has been parsed up to
       
  1568 	@param aSuiteHash The Java MIDlet suite hash
       
  1569 	@param aSuiteVersion The version of the MIDlet suite
       
  1570 	*/
       
  1571 		{
       
  1572 		TSBDerivedType derivedType = EJavaTransferDerivedType;
       
  1573 		PackType(derivedType, *iDataBuffer, aOffset);
       
  1574 		
       
  1575 		CSBGenericTransferType::InitialiseL(aOffset);
       
  1576 
       
  1577 		// Set the derived type in the buffer
       
  1578 		TDriveNumber driveNum = aDriveNumber;
       
  1579 		TJavaTransferType transType = aTransferDataType;
       
  1580 
       
  1581 		PackType(driveNum, *iDataBuffer, iDriveNumberOffset);
       
  1582 		iTransferDataTypeOffset = aOffset;
       
  1583 
       
  1584 		PackTypeAdvance(transType, *iDataBuffer, aOffset);
       
  1585 
       
  1586 		TInt ptrOffset = aOffset;
       
  1587 		
       
  1588 		// Pack the descriptor in raw
       
  1589 		PackDescriptorTypeAdvance(aSuiteHash, aOffset);
       
  1590 		
       
  1591 		// Make the member TPtr point to it
       
  1592 		UnpackTPtrAdvance(iSuiteHash, ptrOffset);
       
  1593 		
       
  1594 		// Increment the size of the data buffer
       
  1595 		iDataBuffer->Des().SetLength(aOffset);
       
  1596 		}
       
  1597 
       
  1598 	void CSBJavaTransferType::ConstructL(const TDesC& aSuiteHash, TDriveNumber aDriveNumber,
       
  1599 										TJavaTransferType aTransferDataType)
       
  1600 	/**
       
  1601 	Symbian OS 2nd phase constructor.
       
  1602 
       
  1603 	@param aJavaId the Java MIDlet suite hash
       
  1604 	@param aDriveNumber the drive that contains the data
       
  1605 	@param aTransferDataType the type of the data you wish to transfer
       
  1606 	*/
       
  1607 		{
       
  1608 		TInt offset = 0;
       
  1609 
       
  1610 		BaseConstructL();
       
  1611 
       
  1612 		InitialiseL(offset, aSuiteHash, aDriveNumber, aTransferDataType);
       
  1613 		}
       
  1614 
       
  1615 	void CSBJavaTransferType::ConstructL(CSBGenericTransferType* aGenericTransferType)
       
  1616 	/**
       
  1617 	Symbian 2nd phase constructor. Validates the externalised type, then passes it to the base ConstructL
       
  1618 
       
  1619 	@param aGenericTransferType pointer to a CSBGenericTransferType object
       
  1620 	*/
       
  1621 		{
       
  1622 		if (aGenericTransferType == NULL)
       
  1623 			{
       
  1624 			User::Leave(KErrArgument);
       
  1625 			}
       
  1626 		if (EJavaTransferDerivedType != aGenericTransferType->DerivedTypeL())
       
  1627 			{
       
  1628 			User::Leave(KErrArgument);
       
  1629 			}
       
  1630 		// Call the base class ConstructL
       
  1631 		CSBGenericDataType::ConstructL(aGenericTransferType->Externalise());
       
  1632 		}
       
  1633 		
       
  1634 	EXPORT_C const TDesC& CSBJavaTransferType::SuiteHashL() const
       
  1635 	/**
       
  1636 	Getter for the secure identifier
       
  1637 		
       
  1638 	@return  The Java MIDlet suite hash
       
  1639 	*/
       
  1640 		{
       
  1641 		return iSuiteHash;
       
  1642 		}
       
  1643 
       
  1644 	EXPORT_C TJavaTransferType CSBJavaTransferType::DataTypeL() const
       
  1645 	/**
       
  1646 	Getter for the transfer data type
       
  1647 		
       
  1648 	@return  The transfer data type
       
  1649 	*/
       
  1650 		{
       
  1651 		TJavaTransferType transType;
       
  1652 		
       
  1653 		UnpackType(transType, *iDataBuffer, iTransferDataTypeOffset);
       
  1654 
       
  1655 		return transType;
       
  1656 		}
       
  1657 		
       
  1658 		
       
  1659 		
       
  1660 	EXPORT_C CSBEFileEntry* CSBEFileEntry::NewLC(const TEntry& aEntry, RApaLsSession& aSession)
       
  1661 	/** Constructor for creating a CSBEFileEntry from an existing TEntry (as returned
       
  1662 	from RFs' directory listing mechanisms)
       
  1663 	
       
  1664 	@param aEntry Information about the file that this object will represent
       
  1665 	@param aSession Required to map from TEntry's UID MIME type into a textual representation
       
  1666 	@return Instance of CSBEFileEntry created from data supplied in aEntry
       
  1667 	*/
       
  1668 		{
       
  1669 		CSBEFileEntry* self = new (ELeave) CSBEFileEntry(aEntry);
       
  1670 		CleanupStack::PushL(self);
       
  1671 		self->ConstructL(aEntry, aSession);
       
  1672 		return self;
       
  1673 		}
       
  1674 		
       
  1675 	EXPORT_C CSBEFileEntry* CSBEFileEntry::NewLC(const TDesC8& aStream, TInt& aBytesRead)
       
  1676 	/** Constructor designed to internalise an instance of CSBEFileEntry from a previously 
       
  1677 	ExternaliseL'd version.
       
  1678 	@param aStream The descriptor containing the internalised version of this object
       
  1679 	@param aBytesRead Upon return from this function, this contains the number of bytes read 
       
  1680 						from the descriptor for use in streaming multiple objects from one 
       
  1681 						stream
       
  1682 	@return Instance of CSBEFileEntry containing the information previously packed into aStream
       
  1683 	*/
       
  1684 		{
       
  1685 		CSBEFileEntry* self = new (ELeave) CSBEFileEntry;
       
  1686 		CleanupStack::PushL(self);
       
  1687 		self->InternaliseL(aStream, aBytesRead);
       
  1688 		return self;
       
  1689 		}
       
  1690 		
       
  1691 	CSBEFileEntry::CSBEFileEntry()
       
  1692 	/** C++ ctor */
       
  1693 		{
       
  1694 		}
       
  1695 
       
  1696 	CSBEFileEntry::CSBEFileEntry(const TEntry& aEntry)
       
  1697 	/** C++ ctor that copies out the parts of aEntry that don't require heap allocation 
       
  1698 	@param aEntry The entry to copy most of the settings from
       
  1699 	*/
       
  1700 		: iAtt(aEntry.iAtt), iSize(aEntry.iSize), iModified(aEntry.iModified), iUidType(aEntry.iType)
       
  1701 		{
       
  1702 		}
       
  1703 		
       
  1704 	EXPORT_C CSBEFileEntry::~CSBEFileEntry()
       
  1705 	/** C++ dtor */
       
  1706 		{
       
  1707 		delete iType;
       
  1708 		delete iFilename;
       
  1709 		}
       
  1710 		
       
  1711 	void CSBEFileEntry::ConstructL(const TEntry& aEntry, RApaLsSession& aSession)
       
  1712 	/** Symbian 2nd phase constructor used when instantiating an instance from component parts
       
  1713 	rather than from a previously externalised stream
       
  1714 	@param aEntry Information about the file that this object will represent
       
  1715 	@param aSession Required to map from TEntry's UID MIME type into a textual representation
       
  1716 	*/
       
  1717 		{
       
  1718 		// Look up the textual mime type of the file instead of the numerical one given by TEntry
       
  1719 		TUid uidForType;
       
  1720 		TDataType appDataType;
       
  1721 		aSession.AppForDocument(aEntry.iName,uidForType,appDataType);
       
  1722 		iType = appDataType.Des().AllocL();
       
  1723 		iFilename = aEntry.iName.AllocL();
       
  1724 		}
       
  1725 		
       
  1726 	void CSBEFileEntry::InternaliseL(const TDesC8& aStream, TInt& aBytesRead)
       
  1727 	/** Symbian 2nd phase constructor used when instantiating an instance from a previously 
       
  1728 	externalised stream of bytes. aStream must begin at the beginning of the internalised
       
  1729 	form of this object and upon return, aBytesRead will contain the number of bytes read from
       
  1730 	that stream which allows multiple objects to be packed into a stream and read sequentially
       
  1731 	@param aStream The stream containing at least one instance of CSBEFileEntry
       
  1732 	@param aBytesRead Upon return, this will contain the number of bytes read from aStream
       
  1733 						in order to internalise this single instance of CSBEFileEntry
       
  1734 	*/
       
  1735 		{
       
  1736 		RDesReadStream stream(aStream);
       
  1737 		CleanupClosePushL(stream);
       
  1738 		
       
  1739 		// Unpack the trivial types
       
  1740 		iAtt = stream.ReadUint32L();
       
  1741 		iSize = stream.ReadInt32L();
       
  1742 		iModified = MAKE_TINT64(stream.ReadUint32L(), stream.ReadUint32L());
       
  1743 		
       
  1744 		// TUidType is a C style array
       
  1745 		iUidType = TUidType(TUid::Uid(stream.ReadUint32L()),
       
  1746 							TUid::Uid(stream.ReadUint32L()),
       
  1747 							TUid::Uid(stream.ReadUint32L()));
       
  1748 
       
  1749 		// Unpack the strings
       
  1750 		delete iType;
       
  1751 		iType = NULL;
       
  1752 		delete iFilename;
       
  1753 		iFilename = NULL;
       
  1754 		
       
  1755 		TInt typeLength = stream.ReadUint16L();
       
  1756 		iType = HBufC::NewL(typeLength);
       
  1757 		TPtr typeBuf(iType->Des());
       
  1758 		stream.ReadL(typeBuf, typeLength);
       
  1759 		
       
  1760 		TInt filenameLength = stream.ReadUint16L();
       
  1761 		iFilename = HBufC::NewL(filenameLength);
       
  1762 		TPtr filenameBuf(iFilename->Des());
       
  1763 		stream.ReadL(filenameBuf, filenameLength);
       
  1764 		
       
  1765 		aBytesRead = CalculatePackedSize();
       
  1766 		CleanupStack::PopAndDestroy(&stream);
       
  1767 		}
       
  1768 		
       
  1769 	TUint16 CSBEFileEntry::CalculatePackedSize() const
       
  1770 	/** calculate the size of this object when externalised
       
  1771 	@return the size in bytes of the externalised representation of this object
       
  1772 	*/
       
  1773 		{
       
  1774 		TInt total = 
       
  1775 			sizeof(TUint32) +		// Length of attribute field
       
  1776 			sizeof(TInt32) +		// Length of file size
       
  1777 			8 +	// Length of last modified time
       
  1778 			sizeof(TUidType) +	// Length of MIME type uids
       
  1779 			sizeof(TUint16) + 	// Text MIME type length
       
  1780 			iType->Size() +		// Text MIME type data
       
  1781 			sizeof(TUint16) + 	// Filename length
       
  1782 			iFilename->Size();	// Filename data
       
  1783 		return total;
       
  1784 		}
       
  1785 
       
  1786 	EXPORT_C HBufC8* CSBEFileEntry::ExternaliseLC() const
       
  1787 	/** Return a pointer to a buffer descriptor containing an externalised representation of
       
  1788 	the data stored by this object. The returned stream is suitable for unpacking an identical 
       
  1789 	instance of this object by using the NewLC that accepts a descriptor as an argument
       
  1790 	@return An externalised instance of this object suitable for Internalising
       
  1791 	*/
       
  1792 		{
       
  1793 		TUint16 packedSize = CalculatePackedSize();
       
  1794 		HBufC8* pBuf = HBufC8::NewLC(packedSize);
       
  1795 		TPtr8 buf(pBuf->Des());
       
  1796 		RDesWriteStream stream(buf);
       
  1797 		CleanupClosePushL(stream);
       
  1798 		
       
  1799 		stream.WriteUint32L(iAtt);
       
  1800 		stream.WriteInt32L(iSize);
       
  1801 		stream.WriteUint32L(I64HIGH(iModified.Int64()));
       
  1802 		stream.WriteUint32L(I64LOW(iModified.Int64()));
       
  1803 		stream.WriteUint32L(iUidType[0].iUid);
       
  1804 		stream.WriteUint32L(iUidType[1].iUid);
       
  1805 		stream.WriteUint32L(iUidType[2].iUid);
       
  1806 		stream.WriteUint16L(iType->Length());
       
  1807 		stream.WriteL(*iType);
       
  1808 		stream.WriteUint16L(iFilename->Length());
       
  1809 		stream.WriteL(*iFilename);
       
  1810 		
       
  1811 		CleanupStack::PopAndDestroy(&stream);
       
  1812 		return pBuf;
       
  1813 		}
       
  1814 		
       
  1815 	EXPORT_C TUint CSBEFileEntry::FileAttributes() const
       
  1816 	/** Accessor function returning the packed bitmask representing the attributes
       
  1817 	of the file that this object represents in the format defined by TEntry
       
  1818 	@return Packed bits representing the file attributes of the file represented by this object
       
  1819 	@see TEntry::iAtt
       
  1820 	*/
       
  1821 		{
       
  1822 		return iAtt;
       
  1823 		}
       
  1824 		
       
  1825 	EXPORT_C TInt CSBEFileEntry::FileSize() const
       
  1826 	/** Accessor function returning the size in bytes of the file represented by this 
       
  1827 	object
       
  1828 	@return Size in bytes of the file represented by this object
       
  1829 	@see TEntry::iSize
       
  1830 	*/
       
  1831 		{
       
  1832 		return iSize;
       
  1833 		}
       
  1834 		
       
  1835 	EXPORT_C TTime CSBEFileEntry::LastModified() const
       
  1836 	/** Accessor function returning the time that the file represented by this object#
       
  1837 	was last modified
       
  1838 	@return Time of last modification of this file
       
  1839 	@see TEntry::iModified
       
  1840 	*/
       
  1841 		{
       
  1842 		return iModified;
       
  1843 		}
       
  1844 		
       
  1845 	EXPORT_C TDesC16& CSBEFileEntry::Filename() const
       
  1846 	/** Accessor function returning the path an name of the file represented by this object.
       
  1847 	@return Filename including path of the file represented by this object
       
  1848 	@see TEntry::iName
       
  1849 	*/
       
  1850 		{
       
  1851 		return *iFilename;
       
  1852 		}
       
  1853 		
       
  1854 	EXPORT_C TDesC16& CSBEFileEntry::MIMEType() const
       
  1855 	/** Accessor function returning a textual representation of the MIME type
       
  1856 	of the file represented by this object.
       
  1857 	@return textual representation of the MIME type	of the file represented by this object
       
  1858 	*/
       
  1859 		{
       
  1860 		return *iType;
       
  1861 		}
       
  1862 		
       
  1863 	EXPORT_C TUidType& CSBEFileEntry::MIMEUid()
       
  1864 	/** Accessor function returning the UID of the MIME type of the file represented 
       
  1865 	by this object.
       
  1866 	@return textual representation of the MIME type	of the file represented by this object
       
  1867 	@see TEntry::iType
       
  1868 	*/
       
  1869 		{
       
  1870 		return iUidType;
       
  1871 		}
       
  1872 		
       
  1873 	}