1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/SecureDRM/src/Client/MmfDrmPluginServerProxy.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,166 @@
1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <mmf/common/mmfcontrollerframeworkbase.h>
1.20 +#include "MmfDrmPluginServerProxy.h"
1.21 +#include "MmfDrmPluginServerStart.h"
1.22 +#include "MmfDrmPluginClientServer.h"
1.23 +#include "../../../inc/mmf/common/mmfbase.hrh" // get the UID
1.24 +
1.25 +#define KMaxServerNameLength 256
1.26 +
1.27 +static const TUid KUidDRMPluginServer = {KUidMmfDrmPluginServerDefine};
1.28 +
1.29 +/*
1.30 + * patchable const data values defined in MmfDrmPluginServerConst.cpp
1.31 + */
1.32 +IMPORT_C extern const TInt KMmfDrmPluginServerTimeOut;
1.33 +
1.34 +EXPORT_C TInt RMMFDRMPluginServerProxy::Open()
1.35 + {
1.36 +
1.37 + const TUidType serverUid(KNullUid, KNullUid, KUidDRMPluginServer);
1.38 +
1.39 + // Assume the server is already running and attempt to create a session
1.40 + // 4 message slots
1.41 + TInt err = CreateSession(KDrmPluginServerName, TVersion(KMMFDRMPluginServerVersion,
1.42 + KMMFDRMPluginServerMinorVersionNumber,
1.43 + KMMFDRMPluginServerBuildVersionNumber));
1.44 + if(err == KErrNotFound)
1.45 + {
1.46 + // Server not running
1.47 + // Construct the server binary name
1.48 + TBuf<KMaxServerNameLength> serverFile;
1.49 + RProcess server;
1.50 +
1.51 + err = server.Create(KDrmPluginServerFileName, KNullDesC, serverUid);
1.52 + if(err != KErrNone)
1.53 + return err;
1.54 + // Synchronise with the server
1.55 + TRequestStatus reqStatus;
1.56 + server.Rendezvous(reqStatus);
1.57 +
1.58 + if (reqStatus!=KRequestPending)
1.59 + {
1.60 + server.Kill(0);
1.61 + }
1.62 + else
1.63 + {
1.64 + // Start the test harness
1.65 + server.Resume();
1.66 + // Server will call the reciprocal static synchronise call
1.67 + }
1.68 + User::WaitForRequest(reqStatus); // wait for rendezvous or death
1.69 + server.Close();
1.70 + TInt reqStatusValue = reqStatus.Int();
1.71 + if(reqStatusValue == KErrNoMemory || reqStatusValue == KErrNotFound)
1.72 + {
1.73 + // All error codes except KErrNoMemory and KErrNotFound are assumed
1.74 + // to be a duplicate server instance dying, then keep trying connection
1.75 + // to the server. This can happen when two servers attempt to start
1.76 + // at the same time.
1.77 + return reqStatusValue;
1.78 + }
1.79 + // Create the root server session
1.80 + err = CreateSession(KDrmPluginServerName, TVersion(KMMFDRMPluginServerVersion,
1.81 + KMMFDRMPluginServerMinorVersionNumber,
1.82 + KMMFDRMPluginServerBuildVersionNumber));
1.83 + }
1.84 + if (err == KErrNone)
1.85 + {
1.86 + SendReceive(EMMFSetDrmPluginServerTimeout, KMmfDrmPluginServerTimeOut);
1.87 + }
1.88 +
1.89 + return err;
1.90 + }
1.91 +
1.92 +EXPORT_C TInt RMMFDRMPluginServerProxy::LaunchControllerServer(TUint aMaxHeapSize, TBool aUseSharedHeap,
1.93 + TThreadId& aControllerThreadId, TUint aStackSize)
1.94 + {
1.95 + TPckg<TUint> maxHeapSize(aMaxHeapSize);
1.96 + TPckg<TBool> userSharedHeap(aUseSharedHeap);
1.97 + TPckgBuf<TThreadId> threadId;
1.98 + TPckg<TUint> stackSize(aStackSize);
1.99 + TIpcArgs args(&maxHeapSize, &userSharedHeap, &threadId, &stackSize);
1.100 + TInt err = RSessionBase::SendReceive(EMMFControllerLaunchRequest, args);
1.101 + aControllerThreadId = threadId();
1.102 + return err;
1.103 + }
1.104 +
1.105 +EXPORT_C TInt RMMFDRMPluginServerProxy::GetControllerSessionHandle()
1.106 + {
1.107 + return RSessionBase::SendReceive(EMMFControllerSessionHandle);
1.108 + }
1.109 +
1.110 +EXPORT_C TInt RMMFDRMPluginServerProxy::PanicControllerThread(TThreadId aTid, const TDesC& aCategory,TInt aReason)
1.111 + {
1.112 + TPckgBuf<TThreadId> threadId(aTid);
1.113 + TPckg<TInt> reason(aReason);
1.114 +
1.115 + TIpcArgs args(&threadId, &aCategory, &reason);
1.116 + return RSessionBase::SendReceive(EMMFControllerThreadPanic, args);
1.117 + }
1.118 +
1.119 +EXPORT_C TInt RMMFDRMPluginServerProxy::KillControllerThread(TThreadId aTid, TInt aReason)
1.120 + {
1.121 + TPckgBuf<TThreadId> threadId(aTid);
1.122 + TPckg<TInt> reason(aReason);
1.123 +
1.124 + TIpcArgs args(&threadId, &reason);
1.125 + return RSessionBase::SendReceive(EMMFControllerThreadKill, args);
1.126 + }
1.127 +
1.128 +EXPORT_C TInt RMMFDRMPluginServerProxy::SetThreadPriority(TThreadId aTid, TThreadPriority aPriority)
1.129 + {
1.130 + TPckgBuf<TThreadId> threadId(aTid);
1.131 + TPckgBuf<TThreadPriority> priority(aPriority);
1.132 +
1.133 + TIpcArgs args(&threadId, &priority);
1.134 + return RSessionBase::SendReceive(EMMFControllerSetThreadPriority, args);
1.135 + }
1.136 +
1.137 +EXPORT_C void RMMFDRMPluginServerProxy::OpenDataContentL(const TDesC& aFilePath, const TDesC8& aInitData)
1.138 + {
1.139 + TIpcArgs args(&aFilePath, &aInitData);
1.140 + User::LeaveIfError(RSessionBase::SendReceive(EMMFDRMContentOpenByFilePath, args));
1.141 + }
1.142 +
1.143 +EXPORT_C void RMMFDRMPluginServerProxy::OpenDataContentL(const RFile& aFile, const TDesC8& aInitData)
1.144 + {
1.145 + TIpcArgs args(NULL, NULL, &aInitData);
1.146 + User::LeaveIfError(aFile.TransferToServer(args, 0, 1));
1.147 + User::LeaveIfError(RSessionBase::SendReceive(EMMFDRMContentOpenByFileHandle, args));
1.148 + }
1.149 +
1.150 +EXPORT_C TInt RMMFDRMPluginServerProxy::EvaluateDataContentIntent(TIntent aIntent)
1.151 + {
1.152 + TPckgBuf<TIntent> intentPckg(aIntent);
1.153 + return RSessionBase::SendReceive(EMMFDRMContentEvaluateIntent, TIpcArgs(&intentPckg));
1.154 + }
1.155 +
1.156 +EXPORT_C TBool RMMFDRMPluginServerProxy::GetDataContentMimeTypeL(TDes8& aMimeType)
1.157 + {
1.158 + TPckg<TBool> success(EFalse);
1.159 + TIpcArgs args(&aMimeType, &success);
1.160 + User::LeaveIfError(RSessionBase::SendReceive(EMMFDRMContentGetMimeType, args));
1.161 + return success();
1.162 + }
1.163 +
1.164 +EXPORT_C void RMMFDRMPluginServerProxy::GetDataContentFileHeaderL(TDes8& aHeaderData, TInt aMaxLength)
1.165 + {
1.166 + TIpcArgs args(aMaxLength, &aHeaderData);
1.167 + User::LeaveIfError(RSessionBase::SendReceive(EMMFDRMContentGetFileHeader, args));
1.168 + }
1.169 +