sl@0: /* sl@0: * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #include "upsnotifierutil.h" sl@0: sl@0: using namespace UserPromptService; sl@0: sl@0: EXPORT_C CPromptData* CPromptData::NewL() sl@0: /** sl@0: Factory function that creates a new, blank CPromptData object. sl@0: @return A pointer to the new CPromptData object. sl@0: */ sl@0: { sl@0: CPromptData* self = new(ELeave) CPromptData(); sl@0: return self; sl@0: } sl@0: sl@0: CPromptData::CPromptData() sl@0: /** sl@0: Constructor sl@0: */ sl@0: { sl@0: } sl@0: sl@0: CPromptData::~CPromptData() sl@0: /** sl@0: Destructor sl@0: */ sl@0: { sl@0: Reset(); sl@0: } sl@0: sl@0: void CPromptData::Reset() sl@0: /** sl@0: Frees all internal memory in-case the object is internalised multiple times. sl@0: */ sl@0: { sl@0: iClientName.Close(); sl@0: iVendorName.Close(); sl@0: iClientSid.iId = 0; sl@0: iServerSid.iId = 0; sl@0: iServiceId.iUid = 0; sl@0: iDestination.Close(); sl@0: iOpaqueData.Close(); sl@0: iDescriptions.ResetAndDestroy(); sl@0: } sl@0: sl@0: EXPORT_C void CPromptData::InternalizeL(RReadStream& aStream) sl@0: /** sl@0: Internalizes the prompt data from the specified stream/ sl@0: @param aStream The read stream sl@0: */ sl@0: { sl@0: Reset(); sl@0: iClientName.CreateL(aStream, KMaskDesLength16); sl@0: iVendorName.CreateL(aStream, KMaskDesLength16); sl@0: aStream >> iClientSid.iId; sl@0: aStream >> iServerSid.iId; sl@0: aStream >> iServiceId.iUid; sl@0: iDestination.CreateL(aStream, KMaskDesLength16); sl@0: iOpaqueData.CreateL(aStream, KMaskDesLength8); sl@0: sl@0: TInt32 count = aStream.ReadUint32L(); sl@0: sl@0: for (TInt i = 0; i < count; ++i) sl@0: { sl@0: TInt32 l = aStream.ReadInt32L(); sl@0: HBufC* d = HBufC::NewMaxLC(l); sl@0: TPtr wptr = d->Des(); sl@0: aStream.ReadL(wptr, l); sl@0: iDescriptions.AppendL(d); sl@0: CleanupStack::Pop(d); sl@0: } sl@0: aStream >> iOptions; sl@0: aStream >> iFlags; sl@0: } sl@0: sl@0: EXPORT_C void CPromptData::ExternalizeL(RWriteStream& aStream) const sl@0: /** sl@0: Externalizes the prompt data to the specified stream. sl@0: @param aStream The write stream. sl@0: */ sl@0: { sl@0: aStream << iClientName; sl@0: aStream << iVendorName; sl@0: aStream << iClientSid.iId; sl@0: aStream << iServerSid.iId; sl@0: aStream << iServiceId.iUid; sl@0: aStream << iDestination; sl@0: aStream << iOpaqueData; sl@0: TInt count = iDescriptions.Count(); sl@0: aStream.WriteUint32L(count); sl@0: sl@0: for (TInt i = 0; i < count; ++i) sl@0: { sl@0: aStream.WriteInt32L(iDescriptions[i]->Length()); sl@0: aStream.WriteL(*iDescriptions[i]); sl@0: } sl@0: aStream << iOptions; sl@0: aStream << iFlags; sl@0: }