diff -r 000000000000 -r 40261b775718 mmlibs/mmfw/SecureDRM/src/Client/MmfDrmPluginServerProxy.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mmlibs/mmfw/SecureDRM/src/Client/MmfDrmPluginServerProxy.cpp Tue Feb 02 01:56:55 2010 +0200 @@ -0,0 +1,166 @@ +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of "Eclipse Public License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.eclipse.org/legal/epl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + +#include +#include "MmfDrmPluginServerProxy.h" +#include "MmfDrmPluginServerStart.h" +#include "MmfDrmPluginClientServer.h" +#include "../../../inc/mmf/common/mmfbase.hrh" // get the UID + +#define KMaxServerNameLength 256 + +static const TUid KUidDRMPluginServer = {KUidMmfDrmPluginServerDefine}; + +/* + * patchable const data values defined in MmfDrmPluginServerConst.cpp + */ +IMPORT_C extern const TInt KMmfDrmPluginServerTimeOut; + +EXPORT_C TInt RMMFDRMPluginServerProxy::Open() + { + + const TUidType serverUid(KNullUid, KNullUid, KUidDRMPluginServer); + + // Assume the server is already running and attempt to create a session + // 4 message slots + TInt err = CreateSession(KDrmPluginServerName, TVersion(KMMFDRMPluginServerVersion, + KMMFDRMPluginServerMinorVersionNumber, + KMMFDRMPluginServerBuildVersionNumber)); + if(err == KErrNotFound) + { + // Server not running + // Construct the server binary name + TBuf serverFile; + RProcess server; + + err = server.Create(KDrmPluginServerFileName, KNullDesC, serverUid); + if(err != KErrNone) + return err; + // Synchronise with the server + TRequestStatus reqStatus; + server.Rendezvous(reqStatus); + + if (reqStatus!=KRequestPending) + { + server.Kill(0); + } + else + { + // Start the test harness + server.Resume(); + // Server will call the reciprocal static synchronise call + } + User::WaitForRequest(reqStatus); // wait for rendezvous or death + server.Close(); + TInt reqStatusValue = reqStatus.Int(); + if(reqStatusValue == KErrNoMemory || reqStatusValue == KErrNotFound) + { + // All error codes except KErrNoMemory and KErrNotFound are assumed + // to be a duplicate server instance dying, then keep trying connection + // to the server. This can happen when two servers attempt to start + // at the same time. + return reqStatusValue; + } + // Create the root server session + err = CreateSession(KDrmPluginServerName, TVersion(KMMFDRMPluginServerVersion, + KMMFDRMPluginServerMinorVersionNumber, + KMMFDRMPluginServerBuildVersionNumber)); + } + if (err == KErrNone) + { + SendReceive(EMMFSetDrmPluginServerTimeout, KMmfDrmPluginServerTimeOut); + } + + return err; + } + +EXPORT_C TInt RMMFDRMPluginServerProxy::LaunchControllerServer(TUint aMaxHeapSize, TBool aUseSharedHeap, + TThreadId& aControllerThreadId, TUint aStackSize) + { + TPckg maxHeapSize(aMaxHeapSize); + TPckg userSharedHeap(aUseSharedHeap); + TPckgBuf threadId; + TPckg stackSize(aStackSize); + TIpcArgs args(&maxHeapSize, &userSharedHeap, &threadId, &stackSize); + TInt err = RSessionBase::SendReceive(EMMFControllerLaunchRequest, args); + aControllerThreadId = threadId(); + return err; + } + +EXPORT_C TInt RMMFDRMPluginServerProxy::GetControllerSessionHandle() + { + return RSessionBase::SendReceive(EMMFControllerSessionHandle); + } + +EXPORT_C TInt RMMFDRMPluginServerProxy::PanicControllerThread(TThreadId aTid, const TDesC& aCategory,TInt aReason) + { + TPckgBuf threadId(aTid); + TPckg reason(aReason); + + TIpcArgs args(&threadId, &aCategory, &reason); + return RSessionBase::SendReceive(EMMFControllerThreadPanic, args); + } + +EXPORT_C TInt RMMFDRMPluginServerProxy::KillControllerThread(TThreadId aTid, TInt aReason) + { + TPckgBuf threadId(aTid); + TPckg reason(aReason); + + TIpcArgs args(&threadId, &reason); + return RSessionBase::SendReceive(EMMFControllerThreadKill, args); + } + +EXPORT_C TInt RMMFDRMPluginServerProxy::SetThreadPriority(TThreadId aTid, TThreadPriority aPriority) + { + TPckgBuf threadId(aTid); + TPckgBuf priority(aPriority); + + TIpcArgs args(&threadId, &priority); + return RSessionBase::SendReceive(EMMFControllerSetThreadPriority, args); + } + +EXPORT_C void RMMFDRMPluginServerProxy::OpenDataContentL(const TDesC& aFilePath, const TDesC8& aInitData) + { + TIpcArgs args(&aFilePath, &aInitData); + User::LeaveIfError(RSessionBase::SendReceive(EMMFDRMContentOpenByFilePath, args)); + } + +EXPORT_C void RMMFDRMPluginServerProxy::OpenDataContentL(const RFile& aFile, const TDesC8& aInitData) + { + TIpcArgs args(NULL, NULL, &aInitData); + User::LeaveIfError(aFile.TransferToServer(args, 0, 1)); + User::LeaveIfError(RSessionBase::SendReceive(EMMFDRMContentOpenByFileHandle, args)); + } + +EXPORT_C TInt RMMFDRMPluginServerProxy::EvaluateDataContentIntent(TIntent aIntent) + { + TPckgBuf intentPckg(aIntent); + return RSessionBase::SendReceive(EMMFDRMContentEvaluateIntent, TIpcArgs(&intentPckg)); + } + +EXPORT_C TBool RMMFDRMPluginServerProxy::GetDataContentMimeTypeL(TDes8& aMimeType) + { + TPckg success(EFalse); + TIpcArgs args(&aMimeType, &success); + User::LeaveIfError(RSessionBase::SendReceive(EMMFDRMContentGetMimeType, args)); + return success(); + } + +EXPORT_C void RMMFDRMPluginServerProxy::GetDataContentFileHeaderL(TDes8& aHeaderData, TInt aMaxLength) + { + TIpcArgs args(aMaxLength, &aHeaderData); + User::LeaveIfError(RSessionBase::SendReceive(EMMFDRMContentGetFileHeader, args)); + } +