|
1 // Copyright (c) 2004-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/mmfdrmcustomcommands.h> |
|
17 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
18 #include <mmf/common/mmfdrmcustomcommandsenum.h> |
|
19 #endif |
|
20 |
|
21 EXPORT_C CMMFDRMCustomCommandParser* CMMFDRMCustomCommandParser::NewL(MMMFDRMCustomCommandImplementor& aImplementor) |
|
22 { |
|
23 return new(ELeave) CMMFDRMCustomCommandParser(aImplementor); |
|
24 } |
|
25 |
|
26 EXPORT_C CMMFDRMCustomCommandParser::~CMMFDRMCustomCommandParser() |
|
27 { |
|
28 } |
|
29 |
|
30 CMMFDRMCustomCommandParser::CMMFDRMCustomCommandParser(MMMFDRMCustomCommandImplementor& aImplementor) |
|
31 : CMMFCustomCommandParserBase(KUidInterfaceMMFDRMControl), |
|
32 iImplementor(aImplementor) |
|
33 { |
|
34 } |
|
35 |
|
36 void CMMFDRMCustomCommandParser::HandleRequest(TMMFMessage& aMessage) |
|
37 { |
|
38 TRAPD(err, |
|
39 DoHandleRequestL(aMessage); |
|
40 ); |
|
41 aMessage.Complete(err); |
|
42 } |
|
43 |
|
44 void CMMFDRMCustomCommandParser::DoHandleRequestL(TMMFMessage& aMessage) |
|
45 { |
|
46 if (aMessage.Destination().InterfaceId() == KUidInterfaceMMFDRMControl) |
|
47 { |
|
48 switch (aMessage.Function()) |
|
49 { |
|
50 case EMMFDRMControlEvaluateIntent: |
|
51 DoEvaluateIntentL(aMessage); |
|
52 break; |
|
53 |
|
54 case EMMFDRMControlExecuteIntent: |
|
55 DoExecuteIntentL(aMessage); |
|
56 break; |
|
57 |
|
58 case EMMFDRMControlDisableAutomaticIntent: |
|
59 DoDisableAutomaticIntentL(aMessage); |
|
60 break; |
|
61 |
|
62 case EMMFDRMControlSetAgentProperty: |
|
63 DoSetAgentPropertyL(aMessage); |
|
64 break; |
|
65 case EMMFDRMControlIsSupported: |
|
66 // we just complete the message with KErrNone |
|
67 break; |
|
68 default: |
|
69 User::Leave(KErrNotSupported); |
|
70 break; |
|
71 } |
|
72 } |
|
73 else |
|
74 { |
|
75 User::Leave(KErrNotSupported); |
|
76 } |
|
77 } |
|
78 |
|
79 void CMMFDRMCustomCommandParser::DoExecuteIntentL(TMMFMessage& aMessage) |
|
80 { |
|
81 TPckgBuf<ContentAccess::TIntent> intentPckg; |
|
82 aMessage.ReadData1FromClientL(intentPckg); |
|
83 User::LeaveIfError(iImplementor.MdcExecuteIntent( intentPckg())); |
|
84 } |
|
85 |
|
86 void CMMFDRMCustomCommandParser::DoEvaluateIntentL(TMMFMessage& aMessage) |
|
87 { |
|
88 TPckgBuf<ContentAccess::TIntent> intentPckg; |
|
89 aMessage.ReadData1FromClientL(intentPckg); |
|
90 User::LeaveIfError(iImplementor.MdcEvaluateIntent( intentPckg())); |
|
91 } |
|
92 |
|
93 void CMMFDRMCustomCommandParser::DoDisableAutomaticIntentL(TMMFMessage& aMessage) |
|
94 { |
|
95 TPckgBuf<TBool> boolPckg; |
|
96 aMessage.ReadData1FromClientL(boolPckg); |
|
97 iImplementor.MdcDisableAutomaticIntent( boolPckg()); |
|
98 } |
|
99 |
|
100 void CMMFDRMCustomCommandParser::DoSetAgentPropertyL(TMMFMessage& aMessage) |
|
101 { |
|
102 TPckgBuf<ContentAccess::TAgentProperty> propertyPckg; |
|
103 TPckgBuf<TInt> valuePckg; |
|
104 aMessage.ReadData1FromClientL(propertyPckg); |
|
105 aMessage.ReadData2FromClientL(valuePckg); |
|
106 User::LeaveIfError(iImplementor.MdcSetAgentProperty( propertyPckg(), valuePckg())); |
|
107 } |
|
108 |
|
109 |
|
110 EXPORT_C RMMFDRMCustomCommands::RMMFDRMCustomCommands(RMMFController& aController) : |
|
111 RMMFCustomCommandsBase(aController, KUidInterfaceMMFDRMControl) |
|
112 { |
|
113 } |
|
114 |
|
115 EXPORT_C TInt RMMFDRMCustomCommands::ExecuteIntent(ContentAccess::TIntent aIntent) |
|
116 { |
|
117 TPckgBuf<ContentAccess::TIntent> intentPckg(aIntent); |
|
118 |
|
119 return iController.CustomCommandSync(iDestinationPckg, |
|
120 EMMFDRMControlExecuteIntent, |
|
121 intentPckg, |
|
122 KNullDesC8); |
|
123 } |
|
124 |
|
125 EXPORT_C TInt RMMFDRMCustomCommands::EvaluateIntent(ContentAccess::TIntent aIntent) |
|
126 { |
|
127 TPckgBuf<ContentAccess::TIntent> intentPckg(aIntent); |
|
128 |
|
129 return iController.CustomCommandSync(iDestinationPckg, |
|
130 EMMFDRMControlEvaluateIntent, |
|
131 intentPckg, |
|
132 KNullDesC8); |
|
133 } |
|
134 |
|
135 EXPORT_C TInt RMMFDRMCustomCommands::DisableAutomaticIntent(TBool aBool) |
|
136 { |
|
137 TPckgBuf<TBool> boolPckg(aBool); |
|
138 |
|
139 return iController.CustomCommandSync(iDestinationPckg, |
|
140 EMMFDRMControlDisableAutomaticIntent, |
|
141 boolPckg, |
|
142 KNullDesC8); |
|
143 } |
|
144 |
|
145 EXPORT_C TInt RMMFDRMCustomCommands::SetAgentProperty(ContentAccess::TAgentProperty aProperty, TInt aValue) |
|
146 { |
|
147 TPckgBuf<ContentAccess::TAgentProperty> propertyPckg(aProperty); |
|
148 TPckgBuf<TInt> valuePckg(aValue); |
|
149 |
|
150 return iController.CustomCommandSync(iDestinationPckg, |
|
151 EMMFDRMControlSetAgentProperty, |
|
152 propertyPckg, |
|
153 valuePckg); |
|
154 } |
|
155 |
|
156 |
|
157 EXPORT_C TInt RMMFDRMCustomCommands::IsSupported() |
|
158 { |
|
159 TInt err = iController.CustomCommandSync(iDestinationPckg, |
|
160 EMMFDRMControlIsSupported, |
|
161 KNullDesC8, |
|
162 KNullDesC8); |
|
163 |
|
164 return (err == KErrNone)?ETrue : EFalse; |
|
165 } |