Update contrib.
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include <mmf/common/mmfcontrollerframeworkbase.h>
17 #include "MmfDrmPluginServerProxy.h"
18 #include "MmfDrmPluginServerStart.h"
19 #include "MmfDrmPluginClientServer.h"
20 #include "../../../inc/mmf/common/mmfbase.hrh" // get the UID
22 #define KMaxServerNameLength 256
24 static const TUid KUidDRMPluginServer = {KUidMmfDrmPluginServerDefine};
27 * patchable const data values defined in MmfDrmPluginServerConst.cpp
29 IMPORT_C extern const TInt KMmfDrmPluginServerTimeOut;
31 EXPORT_C TInt RMMFDRMPluginServerProxy::Open()
34 const TUidType serverUid(KNullUid, KNullUid, KUidDRMPluginServer);
36 // Assume the server is already running and attempt to create a session
38 TInt err = CreateSession(KDrmPluginServerName, TVersion(KMMFDRMPluginServerVersion,
39 KMMFDRMPluginServerMinorVersionNumber,
40 KMMFDRMPluginServerBuildVersionNumber));
41 if(err == KErrNotFound)
44 // Construct the server binary name
45 TBuf<KMaxServerNameLength> serverFile;
48 err = server.Create(KDrmPluginServerFileName, KNullDesC, serverUid);
51 // Synchronise with the server
52 TRequestStatus reqStatus;
53 server.Rendezvous(reqStatus);
55 if (reqStatus!=KRequestPending)
61 // Start the test harness
63 // Server will call the reciprocal static synchronise call
65 User::WaitForRequest(reqStatus); // wait for rendezvous or death
67 TInt reqStatusValue = reqStatus.Int();
68 if(reqStatusValue == KErrNoMemory || reqStatusValue == KErrNotFound)
70 // All error codes except KErrNoMemory and KErrNotFound are assumed
71 // to be a duplicate server instance dying, then keep trying connection
72 // to the server. This can happen when two servers attempt to start
74 return reqStatusValue;
76 // Create the root server session
77 err = CreateSession(KDrmPluginServerName, TVersion(KMMFDRMPluginServerVersion,
78 KMMFDRMPluginServerMinorVersionNumber,
79 KMMFDRMPluginServerBuildVersionNumber));
83 SendReceive(EMMFSetDrmPluginServerTimeout, KMmfDrmPluginServerTimeOut);
89 EXPORT_C TInt RMMFDRMPluginServerProxy::LaunchControllerServer(TUint aMaxHeapSize, TBool aUseSharedHeap,
90 TThreadId& aControllerThreadId, TUint aStackSize)
92 TPckg<TUint> maxHeapSize(aMaxHeapSize);
93 TPckg<TBool> userSharedHeap(aUseSharedHeap);
94 TPckgBuf<TThreadId> threadId;
95 TPckg<TUint> stackSize(aStackSize);
96 TIpcArgs args(&maxHeapSize, &userSharedHeap, &threadId, &stackSize);
97 TInt err = RSessionBase::SendReceive(EMMFControllerLaunchRequest, args);
98 aControllerThreadId = threadId();
102 EXPORT_C TInt RMMFDRMPluginServerProxy::GetControllerSessionHandle()
104 return RSessionBase::SendReceive(EMMFControllerSessionHandle);
107 EXPORT_C TInt RMMFDRMPluginServerProxy::PanicControllerThread(TThreadId aTid, const TDesC& aCategory,TInt aReason)
109 TPckgBuf<TThreadId> threadId(aTid);
110 TPckg<TInt> reason(aReason);
112 TIpcArgs args(&threadId, &aCategory, &reason);
113 return RSessionBase::SendReceive(EMMFControllerThreadPanic, args);
116 EXPORT_C TInt RMMFDRMPluginServerProxy::KillControllerThread(TThreadId aTid, TInt aReason)
118 TPckgBuf<TThreadId> threadId(aTid);
119 TPckg<TInt> reason(aReason);
121 TIpcArgs args(&threadId, &reason);
122 return RSessionBase::SendReceive(EMMFControllerThreadKill, args);
125 EXPORT_C TInt RMMFDRMPluginServerProxy::SetThreadPriority(TThreadId aTid, TThreadPriority aPriority)
127 TPckgBuf<TThreadId> threadId(aTid);
128 TPckgBuf<TThreadPriority> priority(aPriority);
130 TIpcArgs args(&threadId, &priority);
131 return RSessionBase::SendReceive(EMMFControllerSetThreadPriority, args);
134 EXPORT_C void RMMFDRMPluginServerProxy::OpenDataContentL(const TDesC& aFilePath, const TDesC8& aInitData)
136 TIpcArgs args(&aFilePath, &aInitData);
137 User::LeaveIfError(RSessionBase::SendReceive(EMMFDRMContentOpenByFilePath, args));
140 EXPORT_C void RMMFDRMPluginServerProxy::OpenDataContentL(const RFile& aFile, const TDesC8& aInitData)
142 TIpcArgs args(NULL, NULL, &aInitData);
143 User::LeaveIfError(aFile.TransferToServer(args, 0, 1));
144 User::LeaveIfError(RSessionBase::SendReceive(EMMFDRMContentOpenByFileHandle, args));
147 EXPORT_C TInt RMMFDRMPluginServerProxy::EvaluateDataContentIntent(TIntent aIntent)
149 TPckgBuf<TIntent> intentPckg(aIntent);
150 return RSessionBase::SendReceive(EMMFDRMContentEvaluateIntent, TIpcArgs(&intentPckg));
153 EXPORT_C TBool RMMFDRMPluginServerProxy::GetDataContentMimeTypeL(TDes8& aMimeType)
155 TPckg<TBool> success(EFalse);
156 TIpcArgs args(&aMimeType, &success);
157 User::LeaveIfError(RSessionBase::SendReceive(EMMFDRMContentGetMimeType, args));
161 EXPORT_C void RMMFDRMPluginServerProxy::GetDataContentFileHeaderL(TDes8& aHeaderData, TInt aMaxLength)
163 TIpcArgs args(aMaxLength, &aHeaderData);
164 User::LeaveIfError(RSessionBase::SendReceive(EMMFDRMContentGetFileHeader, args));