os/mm/mmlibs/mmfw/SecureDRM/src/Client/MmfDrmPluginServerProxy.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    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
    21 
    22 #define KMaxServerNameLength 256
    23 
    24 static const TUid KUidDRMPluginServer = {KUidMmfDrmPluginServerDefine};
    25 
    26 /*
    27  * patchable const data values defined in MmfDrmPluginServerConst.cpp
    28  */
    29 IMPORT_C extern const TInt KMmfDrmPluginServerTimeOut;
    30 
    31 EXPORT_C TInt RMMFDRMPluginServerProxy::Open()
    32 	{
    33 
    34 	const TUidType serverUid(KNullUid, KNullUid, KUidDRMPluginServer);
    35 		
    36 	// Assume the server is already running and attempt to create a session
    37 	// 4 message slots
    38 	TInt err = CreateSession(KDrmPluginServerName, TVersion(KMMFDRMPluginServerVersion,
    39 														KMMFDRMPluginServerMinorVersionNumber,
    40 														KMMFDRMPluginServerBuildVersionNumber));
    41 	if(err == KErrNotFound)
    42 		{
    43 		// Server not running
    44 		// Construct the server binary name
    45 		TBuf<KMaxServerNameLength> serverFile;
    46 		RProcess server;
    47 
    48 		err = server.Create(KDrmPluginServerFileName, KNullDesC, serverUid);
    49 		if(err != KErrNone)
    50 			return err;
    51 		// Synchronise with the server
    52 		TRequestStatus reqStatus;
    53 		server.Rendezvous(reqStatus);
    54 		
    55 		if (reqStatus!=KRequestPending)
    56 			{
    57 			server.Kill(0);
    58 			}
    59 		else
    60 			{
    61 			// Start the test harness
    62 			server.Resume();
    63 			// Server will call the reciprocal static synchronise call
    64 			}
    65 		User::WaitForRequest(reqStatus); // wait for rendezvous or death
    66 		server.Close();
    67 		TInt reqStatusValue = reqStatus.Int();
    68 		if(reqStatusValue == KErrNoMemory || reqStatusValue == KErrNotFound)
    69 			{
    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
    73 			// at the same time.
    74 			return reqStatusValue;
    75 			}						
    76 		// Create the root server session
    77 		err = CreateSession(KDrmPluginServerName, TVersion(KMMFDRMPluginServerVersion,
    78 														KMMFDRMPluginServerMinorVersionNumber,
    79 														KMMFDRMPluginServerBuildVersionNumber));
    80 		}
    81 	if (err == KErrNone)
    82 		{
    83 		SendReceive(EMMFSetDrmPluginServerTimeout, KMmfDrmPluginServerTimeOut);
    84 		}
    85 		
    86 	return err;
    87 	}
    88 
    89 EXPORT_C TInt RMMFDRMPluginServerProxy::LaunchControllerServer(TUint aMaxHeapSize, TBool aUseSharedHeap,
    90 															TThreadId& aControllerThreadId, TUint aStackSize)
    91 	{
    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();
    99 	return err;
   100 	}
   101 
   102 EXPORT_C TInt RMMFDRMPluginServerProxy::GetControllerSessionHandle()
   103 	{
   104 	return RSessionBase::SendReceive(EMMFControllerSessionHandle);
   105 	}
   106 
   107 EXPORT_C TInt RMMFDRMPluginServerProxy::PanicControllerThread(TThreadId aTid, const TDesC& aCategory,TInt aReason)
   108 	{
   109 	TPckgBuf<TThreadId> threadId(aTid);
   110 	TPckg<TInt> reason(aReason);
   111 	
   112 	TIpcArgs args(&threadId, &aCategory, &reason);
   113 	return RSessionBase::SendReceive(EMMFControllerThreadPanic, args);
   114 	}
   115 
   116 EXPORT_C TInt RMMFDRMPluginServerProxy::KillControllerThread(TThreadId aTid, TInt aReason)
   117 	{
   118 	TPckgBuf<TThreadId> threadId(aTid);
   119 	TPckg<TInt> reason(aReason);
   120 	
   121 	TIpcArgs args(&threadId, &reason);
   122 	return RSessionBase::SendReceive(EMMFControllerThreadKill, args);
   123 	}
   124 
   125 EXPORT_C TInt RMMFDRMPluginServerProxy::SetThreadPriority(TThreadId aTid, TThreadPriority aPriority)
   126 	{
   127 	TPckgBuf<TThreadId> threadId(aTid);
   128 	TPckgBuf<TThreadPriority> priority(aPriority);
   129 	
   130 	TIpcArgs args(&threadId, &priority);
   131 	return RSessionBase::SendReceive(EMMFControllerSetThreadPriority, args);
   132 	}
   133 
   134 EXPORT_C void RMMFDRMPluginServerProxy::OpenDataContentL(const TDesC& aFilePath, const TDesC8& aInitData)
   135 	{
   136 	TIpcArgs args(&aFilePath, &aInitData);
   137 	User::LeaveIfError(RSessionBase::SendReceive(EMMFDRMContentOpenByFilePath, args));
   138 	}
   139 
   140 EXPORT_C void RMMFDRMPluginServerProxy::OpenDataContentL(const RFile& aFile, const TDesC8& aInitData)
   141 	{
   142 	TIpcArgs args(NULL, NULL, &aInitData);
   143 	User::LeaveIfError(aFile.TransferToServer(args, 0, 1));
   144 	User::LeaveIfError(RSessionBase::SendReceive(EMMFDRMContentOpenByFileHandle, args));
   145 	}
   146 
   147 EXPORT_C TInt RMMFDRMPluginServerProxy::EvaluateDataContentIntent(TIntent aIntent)
   148 	{
   149 	TPckgBuf<TIntent> intentPckg(aIntent);
   150 	return RSessionBase::SendReceive(EMMFDRMContentEvaluateIntent, TIpcArgs(&intentPckg));
   151 	}
   152 
   153 EXPORT_C TBool RMMFDRMPluginServerProxy::GetDataContentMimeTypeL(TDes8& aMimeType)
   154 	{
   155 	TPckg<TBool> success(EFalse);
   156 	TIpcArgs args(&aMimeType, &success);
   157 	User::LeaveIfError(RSessionBase::SendReceive(EMMFDRMContentGetMimeType, args));
   158 	return success();
   159 	}
   160 
   161 EXPORT_C void RMMFDRMPluginServerProxy::GetDataContentFileHeaderL(TDes8& aHeaderData, TInt aMaxLength)
   162 	{
   163 	TIpcArgs args(aMaxLength, &aHeaderData);
   164 	User::LeaveIfError(RSessionBase::SendReceive(EMMFDRMContentGetFileHeader, args));
   165 	}
   166