os/mm/mmlibs/mmfw/src/ControllerFramework/MMFDRMCustomCommands.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <mmf/common/mmfdrmcustomcommands.h>
sl@0
    17
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
sl@0
    18
#include <mmf/common/mmfdrmcustomcommandsenum.h>
sl@0
    19
#endif
sl@0
    20
sl@0
    21
EXPORT_C CMMFDRMCustomCommandParser* CMMFDRMCustomCommandParser::NewL(MMMFDRMCustomCommandImplementor& aImplementor)
sl@0
    22
	{
sl@0
    23
	return new(ELeave) CMMFDRMCustomCommandParser(aImplementor);
sl@0
    24
	}
sl@0
    25
sl@0
    26
EXPORT_C CMMFDRMCustomCommandParser::~CMMFDRMCustomCommandParser()
sl@0
    27
	{
sl@0
    28
	}
sl@0
    29
sl@0
    30
CMMFDRMCustomCommandParser::CMMFDRMCustomCommandParser(MMMFDRMCustomCommandImplementor& aImplementor) 
sl@0
    31
	: CMMFCustomCommandParserBase(KUidInterfaceMMFDRMControl),
sl@0
    32
	  iImplementor(aImplementor)
sl@0
    33
	{
sl@0
    34
	}
sl@0
    35
sl@0
    36
void CMMFDRMCustomCommandParser::HandleRequest(TMMFMessage& aMessage)
sl@0
    37
	{
sl@0
    38
	TRAPD(err, 
sl@0
    39
			DoHandleRequestL(aMessage);
sl@0
    40
		);
sl@0
    41
	aMessage.Complete(err);
sl@0
    42
	}
sl@0
    43
sl@0
    44
void CMMFDRMCustomCommandParser::DoHandleRequestL(TMMFMessage& aMessage)
sl@0
    45
	{
sl@0
    46
	if (aMessage.Destination().InterfaceId() == KUidInterfaceMMFDRMControl)
sl@0
    47
		{
sl@0
    48
		switch (aMessage.Function())
sl@0
    49
			{
sl@0
    50
		case EMMFDRMControlEvaluateIntent:
sl@0
    51
			DoEvaluateIntentL(aMessage);
sl@0
    52
			break;
sl@0
    53
			
sl@0
    54
		case EMMFDRMControlExecuteIntent:
sl@0
    55
			DoExecuteIntentL(aMessage);
sl@0
    56
			break;
sl@0
    57
			
sl@0
    58
		case EMMFDRMControlDisableAutomaticIntent:
sl@0
    59
			DoDisableAutomaticIntentL(aMessage);
sl@0
    60
			break;
sl@0
    61
			
sl@0
    62
		case EMMFDRMControlSetAgentProperty:
sl@0
    63
			DoSetAgentPropertyL(aMessage);
sl@0
    64
			break;
sl@0
    65
		case EMMFDRMControlIsSupported:
sl@0
    66
			// we just complete the message with KErrNone
sl@0
    67
			break;
sl@0
    68
		default:
sl@0
    69
			User::Leave(KErrNotSupported);
sl@0
    70
			break;
sl@0
    71
			}
sl@0
    72
		}
sl@0
    73
	else
sl@0
    74
		{
sl@0
    75
		User::Leave(KErrNotSupported);
sl@0
    76
		}	
sl@0
    77
	}
sl@0
    78
sl@0
    79
void CMMFDRMCustomCommandParser::DoExecuteIntentL(TMMFMessage& aMessage)
sl@0
    80
	{
sl@0
    81
	TPckgBuf<ContentAccess::TIntent> intentPckg;
sl@0
    82
	aMessage.ReadData1FromClientL(intentPckg);
sl@0
    83
	User::LeaveIfError(iImplementor.MdcExecuteIntent( intentPckg()));
sl@0
    84
	}
sl@0
    85
	
sl@0
    86
void CMMFDRMCustomCommandParser::DoEvaluateIntentL(TMMFMessage& aMessage)
sl@0
    87
	{
sl@0
    88
	TPckgBuf<ContentAccess::TIntent> intentPckg;
sl@0
    89
	aMessage.ReadData1FromClientL(intentPckg);
sl@0
    90
	User::LeaveIfError(iImplementor.MdcEvaluateIntent( intentPckg()));
sl@0
    91
	}
sl@0
    92
	
sl@0
    93
void CMMFDRMCustomCommandParser::DoDisableAutomaticIntentL(TMMFMessage& aMessage)
sl@0
    94
	{
sl@0
    95
	TPckgBuf<TBool> boolPckg;
sl@0
    96
	aMessage.ReadData1FromClientL(boolPckg);
sl@0
    97
	iImplementor.MdcDisableAutomaticIntent( boolPckg());
sl@0
    98
	}
sl@0
    99
	
sl@0
   100
void CMMFDRMCustomCommandParser::DoSetAgentPropertyL(TMMFMessage& aMessage)
sl@0
   101
	{
sl@0
   102
	TPckgBuf<ContentAccess::TAgentProperty> propertyPckg;
sl@0
   103
	TPckgBuf<TInt> valuePckg;
sl@0
   104
	aMessage.ReadData1FromClientL(propertyPckg);
sl@0
   105
	aMessage.ReadData2FromClientL(valuePckg);
sl@0
   106
	User::LeaveIfError(iImplementor.MdcSetAgentProperty( propertyPckg(), valuePckg()));
sl@0
   107
	}
sl@0
   108
sl@0
   109
sl@0
   110
EXPORT_C RMMFDRMCustomCommands::RMMFDRMCustomCommands(RMMFController& aController) :
sl@0
   111
	RMMFCustomCommandsBase(aController, KUidInterfaceMMFDRMControl)
sl@0
   112
	{
sl@0
   113
	}
sl@0
   114
sl@0
   115
EXPORT_C TInt RMMFDRMCustomCommands::ExecuteIntent(ContentAccess::TIntent aIntent)
sl@0
   116
	{
sl@0
   117
	TPckgBuf<ContentAccess::TIntent> intentPckg(aIntent);
sl@0
   118
	
sl@0
   119
	return iController.CustomCommandSync(iDestinationPckg, 
sl@0
   120
										 EMMFDRMControlExecuteIntent, 
sl@0
   121
										 intentPckg,
sl@0
   122
										 KNullDesC8);
sl@0
   123
	}
sl@0
   124
sl@0
   125
EXPORT_C TInt RMMFDRMCustomCommands::EvaluateIntent(ContentAccess::TIntent aIntent)
sl@0
   126
	{
sl@0
   127
	TPckgBuf<ContentAccess::TIntent> intentPckg(aIntent);
sl@0
   128
	
sl@0
   129
	return iController.CustomCommandSync(iDestinationPckg, 
sl@0
   130
										 EMMFDRMControlEvaluateIntent, 
sl@0
   131
										 intentPckg,
sl@0
   132
										 KNullDesC8);
sl@0
   133
	}
sl@0
   134
sl@0
   135
EXPORT_C TInt RMMFDRMCustomCommands::DisableAutomaticIntent(TBool aBool)
sl@0
   136
	{
sl@0
   137
	TPckgBuf<TBool> boolPckg(aBool);
sl@0
   138
	
sl@0
   139
	return iController.CustomCommandSync(iDestinationPckg, 
sl@0
   140
										 EMMFDRMControlDisableAutomaticIntent, 
sl@0
   141
										 boolPckg,
sl@0
   142
										 KNullDesC8);
sl@0
   143
	}
sl@0
   144
sl@0
   145
EXPORT_C TInt RMMFDRMCustomCommands::SetAgentProperty(ContentAccess::TAgentProperty aProperty, TInt aValue)
sl@0
   146
	{
sl@0
   147
	TPckgBuf<ContentAccess::TAgentProperty> propertyPckg(aProperty);
sl@0
   148
	TPckgBuf<TInt> valuePckg(aValue);
sl@0
   149
	
sl@0
   150
	return iController.CustomCommandSync(iDestinationPckg, 
sl@0
   151
										 EMMFDRMControlSetAgentProperty, 
sl@0
   152
										 propertyPckg,
sl@0
   153
										 valuePckg);
sl@0
   154
	}
sl@0
   155
sl@0
   156
sl@0
   157
EXPORT_C TInt RMMFDRMCustomCommands::IsSupported()
sl@0
   158
	{
sl@0
   159
	TInt err = iController.CustomCommandSync(iDestinationPckg, 
sl@0
   160
										 EMMFDRMControlIsSupported, 
sl@0
   161
										 KNullDesC8,
sl@0
   162
										 KNullDesC8);
sl@0
   163
										 
sl@0
   164
	return (err == KErrNone)?ETrue : EFalse;
sl@0
   165
	}