os/security/authorisation/userpromptutils/upsnotifierutil/source/upsnotifierutil.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/security/authorisation/userpromptutils/upsnotifierutil/source/upsnotifierutil.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,116 @@
     1.4 +/*
     1.5 +* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#include "upsnotifierutil.h"
    1.23 +
    1.24 +using namespace UserPromptService;
    1.25 +
    1.26 +EXPORT_C CPromptData* CPromptData::NewL() 
    1.27 +/**
    1.28 +Factory function that creates a new, blank CPromptData object.
    1.29 +@return A pointer to the new CPromptData object.
    1.30 +*/
    1.31 +	{
    1.32 +	CPromptData* self = new(ELeave) CPromptData();
    1.33 +	return self;
    1.34 +	}
    1.35 +
    1.36 +CPromptData::CPromptData()
    1.37 +/**
    1.38 + Constructor
    1.39 + */
    1.40 +	{
    1.41 +	}
    1.42 +
    1.43 +CPromptData::~CPromptData()
    1.44 +/**
    1.45 + Destructor
    1.46 + */
    1.47 +	{
    1.48 +	Reset();
    1.49 +	}
    1.50 +	
    1.51 +void CPromptData::Reset() 
    1.52 +/**
    1.53 +Frees all internal memory in-case the object is internalised multiple times.
    1.54 +*/
    1.55 +	{
    1.56 +	iClientName.Close();
    1.57 +	iVendorName.Close();
    1.58 +	iClientSid.iId = 0;
    1.59 +	iServerSid.iId = 0;
    1.60 +	iServiceId.iUid = 0;
    1.61 +	iDestination.Close();
    1.62 +	iOpaqueData.Close();
    1.63 +	iDescriptions.ResetAndDestroy();	
    1.64 +	}
    1.65 +
    1.66 +EXPORT_C void CPromptData::InternalizeL(RReadStream& aStream)
    1.67 +/**
    1.68 + Internalizes the prompt data from the specified stream/
    1.69 + @param aStream The read stream
    1.70 +*/
    1.71 +	{
    1.72 +	Reset();
    1.73 +	iClientName.CreateL(aStream, KMaskDesLength16);
    1.74 +	iVendorName.CreateL(aStream, KMaskDesLength16);
    1.75 +	aStream >> iClientSid.iId;
    1.76 +	aStream >> iServerSid.iId;
    1.77 +	aStream >> iServiceId.iUid;
    1.78 +	iDestination.CreateL(aStream, KMaskDesLength16);
    1.79 +	iOpaqueData.CreateL(aStream, KMaskDesLength8);
    1.80 +	
    1.81 +	TInt32 count = aStream.ReadUint32L();
    1.82 +		
    1.83 +	for (TInt i = 0; i < count; ++i)
    1.84 +		{
    1.85 +		TInt32 l = aStream.ReadInt32L();
    1.86 +		HBufC* d = HBufC::NewMaxLC(l);
    1.87 +		TPtr wptr = d->Des();
    1.88 +		aStream.ReadL(wptr, l);
    1.89 +		iDescriptions.AppendL(d);
    1.90 +		CleanupStack::Pop(d);
    1.91 +		}
    1.92 +	aStream >> iOptions;
    1.93 +	aStream >> iFlags;
    1.94 +	}
    1.95 +
    1.96 +EXPORT_C void CPromptData::ExternalizeL(RWriteStream& aStream) const
    1.97 +/**
    1.98 + Externalizes the prompt data to the specified stream.
    1.99 + @param aStream The write stream.
   1.100 + */
   1.101 +	{
   1.102 +	aStream << iClientName;
   1.103 +	aStream << iVendorName;
   1.104 +	aStream << iClientSid.iId;
   1.105 +	aStream << iServerSid.iId;
   1.106 +	aStream << iServiceId.iUid;
   1.107 +	aStream << iDestination;
   1.108 +	aStream << iOpaqueData;
   1.109 +	TInt count = iDescriptions.Count();
   1.110 +	aStream.WriteUint32L(count);
   1.111 +	
   1.112 +	for (TInt i = 0; i < count; ++i)
   1.113 +		{
   1.114 +		aStream.WriteInt32L(iDescriptions[i]->Length());
   1.115 +		aStream.WriteL(*iDescriptions[i]);
   1.116 +		}
   1.117 +	aStream << iOptions;
   1.118 +	aStream << iFlags;
   1.119 +	}