|
1 /* |
|
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <bluetoothav.h> |
|
19 |
|
20 // User Includes |
|
21 #include "T_AvdtpServiceCapabilityData.h" |
|
22 #include "T_AvdtpContentProtectionCapabilitiesData.h" |
|
23 |
|
24 |
|
25 /*@{*/ |
|
26 //Parameters |
|
27 _LIT(KExpected, "expected"); |
|
28 _LIT(KCPType, "cptype"); |
|
29 _LIT(KData, "data"); |
|
30 |
|
31 //Commands |
|
32 _LIT(KCmdnew, "new"); |
|
33 _LIT(KCmdContentProtectionType, "ContentProtectionType"); |
|
34 _LIT(KCmdSetContentProtectionType, "SetContentProtectionType"); |
|
35 _LIT(KCmdContentProtectionData, "ContentProtectionData"); |
|
36 _LIT(KCmdSetContentProtectionData, "SetContentProtectionData"); |
|
37 _LIT(KCmdDestructor, "~"); |
|
38 |
|
39 //Log |
|
40 _LIT(KLogMissingExpected, "Missing expected '%S'"); |
|
41 _LIT(KLogMissingParameter, "Missing parameter '%S'"); |
|
42 _LIT(KLogError, "Error=%d"); |
|
43 /*@}*/ |
|
44 |
|
45 ////////////////////////////////////////////////////////////////////// |
|
46 // Construction/Destruction |
|
47 ////////////////////////////////////////////////////////////////////// |
|
48 |
|
49 CT_AvdtpContentProtectionCapabilitiesData* CT_AvdtpContentProtectionCapabilitiesData::NewL() |
|
50 { |
|
51 CT_AvdtpContentProtectionCapabilitiesData* ret=new (ELeave) CT_AvdtpContentProtectionCapabilitiesData(); |
|
52 CleanupStack::PushL(ret); |
|
53 ret->ConstructL(); |
|
54 CleanupStack::Pop(ret); |
|
55 return ret; |
|
56 } |
|
57 |
|
58 CT_AvdtpContentProtectionCapabilitiesData::CT_AvdtpContentProtectionCapabilitiesData() |
|
59 :iAvdtpContentProtectionCapabilities(NULL) |
|
60 { |
|
61 } |
|
62 |
|
63 void CT_AvdtpContentProtectionCapabilitiesData::ConstructL() |
|
64 { |
|
65 } |
|
66 |
|
67 TAvdtpServiceCapability* CT_AvdtpContentProtectionCapabilitiesData::GetAvdtpServiceCapability() const |
|
68 { |
|
69 return iAvdtpContentProtectionCapabilities; |
|
70 } |
|
71 |
|
72 CT_AvdtpContentProtectionCapabilitiesData::~CT_AvdtpContentProtectionCapabilitiesData() |
|
73 { |
|
74 DestroyData(); |
|
75 } |
|
76 |
|
77 void CT_AvdtpContentProtectionCapabilitiesData::SetObjectL(TAny* aAny) |
|
78 { |
|
79 DestroyData(); |
|
80 iAvdtpContentProtectionCapabilities = static_cast<TAvdtpContentProtectionCapabilities*> (aAny); |
|
81 } |
|
82 |
|
83 void CT_AvdtpContentProtectionCapabilitiesData::DisownObjectL() |
|
84 { |
|
85 iAvdtpContentProtectionCapabilities = NULL; |
|
86 } |
|
87 |
|
88 void CT_AvdtpContentProtectionCapabilitiesData::DestroyData() |
|
89 { |
|
90 delete iAvdtpContentProtectionCapabilities; |
|
91 iAvdtpContentProtectionCapabilities=NULL; |
|
92 } |
|
93 |
|
94 |
|
95 TBool CT_AvdtpContentProtectionCapabilitiesData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex) |
|
96 { |
|
97 TBool ret = ETrue; |
|
98 |
|
99 if ( aCommand==KCmdnew ) |
|
100 { |
|
101 DoCmdnewL(); |
|
102 } |
|
103 else if ( aCommand==KCmdContentProtectionType ) |
|
104 { |
|
105 DoCmdContentProtectionType(aSection); |
|
106 } |
|
107 else if ( aCommand==KCmdSetContentProtectionType ) |
|
108 { |
|
109 DoCmdSetContentProtectionType(aSection); |
|
110 } |
|
111 else if ( aCommand==KCmdContentProtectionData ) |
|
112 { |
|
113 DoCmdContentProtectionData(aSection); |
|
114 } |
|
115 else if ( aCommand==KCmdSetContentProtectionData ) |
|
116 { |
|
117 DoCmdSetContentProtectionData(aSection); |
|
118 } |
|
119 else if ( aCommand==KCmdDestructor ) |
|
120 { |
|
121 DestroyData(); |
|
122 } |
|
123 else |
|
124 { |
|
125 ret=CT_AvdtpServiceCapabilityData::DoCommandL(aCommand, aSection, aAsyncErrorIndex); |
|
126 } |
|
127 |
|
128 return ret; |
|
129 } |
|
130 |
|
131 |
|
132 /** |
|
133 Test TAvdtpContentProtectionCapabilities () |
|
134 */ |
|
135 void CT_AvdtpContentProtectionCapabilitiesData::DoCmdnewL() |
|
136 { |
|
137 INFO_PRINTF1(_L("TAvdtpContentProtectionCapabilities Constructor Call")); |
|
138 DestroyData(); |
|
139 TRAPD( err, iAvdtpContentProtectionCapabilities = new (ELeave) TAvdtpContentProtectionCapabilities ()); |
|
140 |
|
141 if ( err!=KErrNone ) |
|
142 { |
|
143 ERR_PRINTF2(KLogError, err); |
|
144 SetError(err); |
|
145 } |
|
146 } |
|
147 |
|
148 |
|
149 /** |
|
150 Test ContentProtectionType () |
|
151 */ |
|
152 void CT_AvdtpContentProtectionCapabilitiesData::DoCmdContentProtectionType(const TDesC& aSection) |
|
153 { |
|
154 INFO_PRINTF1(_L("TAvdtpContentProtectionCapabilities ContentProtectionType() Call")); |
|
155 TUint16 actualValue = iAvdtpContentProtectionCapabilities->ContentProtectionType(); |
|
156 INFO_PRINTF2(_L("ContentProtectionType result (%d)"), actualValue); |
|
157 |
|
158 TInt expected; |
|
159 if ( GetIntFromConfig(aSection, KExpected, expected) ) |
|
160 { |
|
161 if ( actualValue != (TUint16)expected ) |
|
162 { |
|
163 ERR_PRINTF3(_L("Result (%d) is not as expected (%d)"), actualValue, expected); |
|
164 SetBlockResult(EFail); |
|
165 } |
|
166 } |
|
167 else |
|
168 { |
|
169 ERR_PRINTF2(KLogMissingExpected, &KExpected); |
|
170 SetBlockResult(EFail); |
|
171 } |
|
172 } |
|
173 |
|
174 |
|
175 /** |
|
176 Test SetContentProtectionType () |
|
177 */ |
|
178 void CT_AvdtpContentProtectionCapabilitiesData::DoCmdSetContentProtectionType(const TDesC& aSection) |
|
179 { |
|
180 INFO_PRINTF1(_L("TAvdtpContentProtectionCapabilities SetContentProtectionType() Call")); |
|
181 |
|
182 TInt cptype; |
|
183 if ( GetIntFromConfig(aSection, KCPType, cptype) ) |
|
184 { |
|
185 iAvdtpContentProtectionCapabilities->SetContentProtectionType((TUint16) cptype); |
|
186 } |
|
187 else |
|
188 { |
|
189 ERR_PRINTF2(KLogMissingParameter, &KCPType); |
|
190 SetBlockResult(EFail); |
|
191 } |
|
192 } |
|
193 |
|
194 |
|
195 /** |
|
196 Test ContentProtectionData () |
|
197 */ |
|
198 void CT_AvdtpContentProtectionCapabilitiesData::DoCmdContentProtectionData(const TDesC& aSection) |
|
199 { |
|
200 INFO_PRINTF1(_L("TAvdtpContentProtectionCapabilities ContentProtectionData() Call")); |
|
201 TPtrC8 actualValue = iAvdtpContentProtectionCapabilities->ContentProtectionData(); |
|
202 |
|
203 TPtrC theString; |
|
204 if ( GetStringFromConfig(aSection, KExpected, theString) ) |
|
205 { |
|
206 HBufC8* string8 = HBufC8::NewLC(theString.Length()); |
|
207 string8->Des().Copy(theString); |
|
208 TPtrC8 expected = string8->Des(); |
|
209 |
|
210 if ( actualValue != expected ) |
|
211 { |
|
212 ERR_PRINTF1( _L("result is not as expected. ") ); |
|
213 SetBlockResult(EFail); |
|
214 } |
|
215 CleanupStack::PopAndDestroy(string8); |
|
216 } |
|
217 else |
|
218 { |
|
219 ERR_PRINTF2(KLogMissingExpected, &KExpected); |
|
220 SetBlockResult(EFail); |
|
221 } |
|
222 } |
|
223 |
|
224 |
|
225 /** |
|
226 Test SetContentProtectionData () |
|
227 */ |
|
228 void CT_AvdtpContentProtectionCapabilitiesData::DoCmdSetContentProtectionData(const TDesC& aSection) |
|
229 { |
|
230 INFO_PRINTF1(_L("TAvdtpContentProtectionCapabilities SetContentProtectionData() Call")); |
|
231 TPtrC dataValue; |
|
232 if ( GetStringFromConfig(aSection, KData, dataValue) ) |
|
233 { |
|
234 HBufC8* data = HBufC8::NewLC(dataValue.Length()); |
|
235 data->Des().Copy(dataValue); |
|
236 |
|
237 iAvdtpContentProtectionCapabilities->SetContentProtectionData(*data); |
|
238 CleanupStack::PopAndDestroy(data); |
|
239 } |
|
240 else |
|
241 { |
|
242 ERR_PRINTF2(KLogMissingParameter, &KData); |
|
243 SetBlockResult(EFail); |
|
244 } |
|
245 } |
|
246 |