diff -r 947415ec7603 -r a7062f7f0b79 rtsecuritymanager/rtsecuritymanagerutil/src/rtsecmgrmsg.cpp --- a/rtsecuritymanager/rtsecuritymanagerutil/src/rtsecmgrmsg.cpp Fri Jul 03 15:51:30 2009 +0100 +++ b/rtsecuritymanager/rtsecuritymanagerutil/src/rtsecmgrmsg.cpp Thu Sep 10 12:58:32 2009 +0300 @@ -118,3 +118,165 @@ iHashMarker = HBufC::NewL (aStream, KMaxHashValueDesLen); iPolicyID = aStream.ReadInt32L (); // Read iPolicyID } + +EXPORT_C CRTPermGrantMessage::~CRTPermGrantMessage() + { + iAllowedProviders.Close(); + iDeniedProviders.Close(); + } + +EXPORT_C CRTPermGrantMessage* CRTPermGrantMessage::NewL() + { + CRTPermGrantMessage* self = CRTPermGrantMessage::NewLC(); + CleanupStack::Pop(self); + return self; + } + +EXPORT_C CRTPermGrantMessage* CRTPermGrantMessage::NewLC() + { + CRTPermGrantMessage* self = new(ELeave) CRTPermGrantMessage(); + CleanupStack::PushL(self); + return self; + } + +EXPORT_C CRTPermGrantMessage* CRTPermGrantMessage::NewL(const TDesC8& aBuf) + { + CRTPermGrantMessage* self = CRTPermGrantMessage::NewLC(aBuf); + CleanupStack::Pop(self); + return self; + } + +EXPORT_C CRTPermGrantMessage* CRTPermGrantMessage::NewLC(const TDesC8& aBuf) + { + CRTPermGrantMessage* self = new(ELeave) CRTPermGrantMessage(); + CleanupStack::PushL(self); + self->ConstructL(aBuf); + return self; + } + +EXPORT_C CRTPermGrantMessage* CRTPermGrantMessage::NewL(RProviderArray aAllowedProviders, RProviderArray aDeniedProviders,TExecutableID aScriptId) + { + CRTPermGrantMessage* self = CRTPermGrantMessage::NewLC(aAllowedProviders,aDeniedProviders,aScriptId); + CleanupStack::Pop(self); + return self; + } + +EXPORT_C CRTPermGrantMessage* CRTPermGrantMessage::NewLC(RProviderArray aAllowedProviders, RProviderArray aDeniedProviders,TExecutableID aScriptId) + { + CRTPermGrantMessage* self = new(ELeave) CRTPermGrantMessage(aAllowedProviders,aDeniedProviders,aScriptId); + CleanupStack::PushL(self); + return self; + } + +CRTPermGrantMessage::CRTPermGrantMessage() + { + + } + +CRTPermGrantMessage::CRTPermGrantMessage(RProviderArray aAllowedProviders,RProviderArray aDeniedProviders,TExecutableID aScriptId) + { + iAllowedProviders.Reset(); + for(TInt i(0); i < aAllowedProviders.Count(); i++) + iAllowedProviders.Append(aAllowedProviders[i]); + iDeniedProviders.Reset(); + for(TInt i(0); i < aDeniedProviders.Count(); i++) + iDeniedProviders.Append(aDeniedProviders[i]); + iScriptId = aScriptId; + } + +void CRTPermGrantMessage::ConstructL(const TDesC8& aBuf) + { + RDesReadStream stream(aBuf); + CleanupClosePushL (stream); + InternalizeL (stream); + CleanupStack::PopAndDestroy (&stream); + } + +EXPORT_C void CRTPermGrantMessage::AllowedProviders(RProviderArray& aAllowedProviders) + { + aAllowedProviders.Reset(); + for(TInt i(0); i < iAllowedProviders.Count(); i++) + aAllowedProviders.Append(iAllowedProviders[i]); + } + +EXPORT_C void CRTPermGrantMessage::DeniedProviders(RProviderArray& aDeniedProviders) + { + aDeniedProviders.Reset(); + for(TInt i(0); i < iDeniedProviders.Count(); i++) + aDeniedProviders.Append(iDeniedProviders[i]); + } + +EXPORT_C TExecutableID CRTPermGrantMessage::ScriptID() + { + return iScriptId; + } + +EXPORT_C void CRTPermGrantMessage::setAllowedProviders(RProviderArray aAllowedProviders) + { + iAllowedProviders.Reset(); + for(TInt i(0); i < aAllowedProviders.Count(); i++) + iAllowedProviders.Append(aAllowedProviders[i]); + } + +EXPORT_C void CRTPermGrantMessage::setDeniedProviders(RProviderArray aDeniedProviders) + { + iDeniedProviders.Reset(); + for(TInt i(0); i < aDeniedProviders.Count(); i++) + iDeniedProviders.Append(aDeniedProviders[i]); + } + +EXPORT_C void CRTPermGrantMessage::setScriptID(TExecutableID aScriptId) + { + iScriptId = aScriptId; + } + +void CRTPermGrantMessage::InternalizeL(RReadStream& aSource) + { + iScriptId = aSource.ReadInt32L(); + TInt allowCnt = aSource.ReadInt32L(); + iAllowedProviders.Reset(); + for(TInt i(0); i < allowCnt; i++) + { + TInt uid = aSource.ReadInt32L(); + TUid allowPid = TUid::Uid(uid); + iAllowedProviders.Append(allowPid); + } + TInt denyCnt = aSource.ReadInt32L(); + iDeniedProviders.Reset(); + for(TInt i(0); i < denyCnt; i++) + { + TInt uid = aSource.ReadInt32L(); + TUid denyPid = TUid::Uid(uid); + iDeniedProviders.Append(denyPid); + } + } + +void CRTPermGrantMessage::ExternalizeL(RWriteStream& aSink) + { + aSink.WriteInt32L(iScriptId); + TInt cnt = iAllowedProviders.Count(); + aSink.WriteInt32L(cnt); + for(TInt i(0); i < iAllowedProviders.Count(); i++) + aSink.WriteInt32L(iAllowedProviders[i].iUid); + cnt = iDeniedProviders.Count(); + aSink.WriteInt32L(cnt); + for(TInt i(0); i < iDeniedProviders.Count(); i++) + aSink.WriteInt32L(iDeniedProviders[i].iUid); + } + +EXPORT_C HBufC8* CRTPermGrantMessage::PackMessageL() + { + // Dynamic data buffer + CBufFlat* buf = CBufFlat::NewL(KMaxMsgLength); + CleanupStack::PushL(buf); + RBufWriteStream stream(*buf); // Stream over the buffer + CleanupClosePushL(stream); + ExternalizeL(stream); + CleanupStack::PopAndDestroy(&stream); + // Create a heap descriptor from the buffer + HBufC8* des = HBufC8::NewL(buf->Size()); + TPtr8 ptr(des->Des()); + buf->Read(0, ptr, buf->Size()); + CleanupStack::PopAndDestroy(buf); // Finished with the buffer + return (des); + }