|
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_AvdtpSEPInfoData.h" |
|
22 #include "T_BTUtil.h" |
|
23 /*@{*/ |
|
24 //Parameters |
|
25 |
|
26 //Fields |
|
27 _LIT(KFldExpected, "expected"); |
|
28 _LIT(KFldSeid, "seid"); |
|
29 _LIT(KFldIsInUse, "isinuse"); |
|
30 _LIT(KFldMediaType, "mediatype"); |
|
31 _LIT(KFldIsSink, "issink"); |
|
32 |
|
33 //Commands |
|
34 _LIT(KCmdnew, "new"); |
|
35 _LIT(KCmdSEID, "SEID"); |
|
36 _LIT(KCmdSetSEID, "SetSEID"); |
|
37 _LIT(KCmdInUse, "InUse"); |
|
38 _LIT(KCmdSetInUse, "SetInUse"); |
|
39 _LIT(KCmdMediaType, "MediaType"); |
|
40 _LIT(KCmdSetMediaType, "SetMediaType"); |
|
41 _LIT(KCmdIsSink, "IsSink"); |
|
42 _LIT(KCmdSetIsSink, "SetIsSink"); |
|
43 _LIT(KCmdDestructor, "~"); |
|
44 |
|
45 //Log |
|
46 _LIT(KLogError, "Error=%d"); |
|
47 _LIT(KLogMissingParameter, "Missing parameter '%S'"); |
|
48 _LIT(KLogMissingParameter2, "Missing parameter '%S' or '%S'"); |
|
49 _LIT(KLogNotExpectedValue, "Not expected value"); |
|
50 /*@}*/ |
|
51 |
|
52 ////////////////////////////////////////////////////////////////////// |
|
53 // Construction/Destruction |
|
54 ////////////////////////////////////////////////////////////////////// |
|
55 |
|
56 CT_AvdtpSEPInfoData* CT_AvdtpSEPInfoData::NewL() |
|
57 { |
|
58 CT_AvdtpSEPInfoData* ret=new (ELeave) CT_AvdtpSEPInfoData(); |
|
59 CleanupStack::PushL(ret); |
|
60 ret->ConstructL(); |
|
61 CleanupStack::Pop(ret); |
|
62 return ret; |
|
63 } |
|
64 |
|
65 CT_AvdtpSEPInfoData::CT_AvdtpSEPInfoData() |
|
66 : iData(NULL) |
|
67 { |
|
68 } |
|
69 |
|
70 void CT_AvdtpSEPInfoData::ConstructL() |
|
71 { |
|
72 } |
|
73 |
|
74 CT_AvdtpSEPInfoData::~CT_AvdtpSEPInfoData() |
|
75 { |
|
76 DestroyData(); |
|
77 } |
|
78 |
|
79 TAny* CT_AvdtpSEPInfoData::GetObject() |
|
80 { |
|
81 return iData; |
|
82 } |
|
83 |
|
84 |
|
85 void CT_AvdtpSEPInfoData::SetObjectL(TAny* aAny) |
|
86 { |
|
87 DestroyData(); |
|
88 iData = static_cast<TAvdtpSEPInfo*> (aAny); |
|
89 } |
|
90 |
|
91 void CT_AvdtpSEPInfoData::DisownObjectL() |
|
92 { |
|
93 iData = NULL; |
|
94 } |
|
95 |
|
96 void CT_AvdtpSEPInfoData::DestroyData() |
|
97 { |
|
98 delete iData; |
|
99 iData=NULL; |
|
100 } |
|
101 |
|
102 inline TCleanupOperation CT_AvdtpSEPInfoData::CleanupOperation() |
|
103 { |
|
104 return CleanupOperation; |
|
105 } |
|
106 |
|
107 void CT_AvdtpSEPInfoData::CleanupOperation(TAny* aAny) |
|
108 { |
|
109 //may be unnecessary |
|
110 TAvdtpSEPInfo* arg=static_cast<TAvdtpSEPInfo*>(aAny); |
|
111 delete arg; |
|
112 } |
|
113 |
|
114 |
|
115 TBool CT_AvdtpSEPInfoData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt /*aAsyncErrorIndex*/) |
|
116 { |
|
117 TBool ret = ETrue; |
|
118 |
|
119 if ( aCommand==KCmdnew ) |
|
120 { |
|
121 DoCmdnewL(aSection); |
|
122 } |
|
123 else if ( aCommand==KCmdSEID ) |
|
124 { |
|
125 DoCmdSEIDL(aSection); |
|
126 } |
|
127 else if ( aCommand==KCmdSetSEID ) |
|
128 { |
|
129 DoCmdSetSEIDL(aSection); |
|
130 } |
|
131 else if ( aCommand==KCmdInUse ) |
|
132 { |
|
133 DoCmdInUse(aSection); |
|
134 } |
|
135 else if ( aCommand==KCmdSetInUse ) |
|
136 { |
|
137 DoCmdSetInUse(aSection); |
|
138 } |
|
139 else if ( aCommand==KCmdMediaType ) |
|
140 { |
|
141 DoCmdMediaType(aSection); |
|
142 } |
|
143 else if ( aCommand==KCmdSetMediaType ) |
|
144 { |
|
145 DoCmdSetMediaType(aSection); |
|
146 } |
|
147 else if ( aCommand==KCmdIsSink ) |
|
148 { |
|
149 DoCmdIsSink(aSection); |
|
150 } |
|
151 else if ( aCommand==KCmdSetIsSink ) |
|
152 { |
|
153 DoCmdSetIsSink(aSection); |
|
154 } |
|
155 else if ( aCommand==KCmdDestructor ) |
|
156 { |
|
157 DestroyData(); |
|
158 } |
|
159 else |
|
160 { |
|
161 ret=EFalse; |
|
162 } |
|
163 |
|
164 return ret; |
|
165 } |
|
166 |
|
167 /** |
|
168 Test TAvdtpSEPInfo() |
|
169 */ |
|
170 void CT_AvdtpSEPInfoData::DoCmdnewL(const TDesC& /*aSection*/) |
|
171 { |
|
172 INFO_PRINTF1(_L("TAvdtpSEPInfo Constructor Call.")); |
|
173 DestroyData(); |
|
174 |
|
175 TInt err = KErrNone; |
|
176 TRAP( err, iData = new (ELeave) TAvdtpSEPInfo()); |
|
177 |
|
178 if ( err!=KErrNone ) |
|
179 { |
|
180 ERR_PRINTF2(KLogError, err); |
|
181 SetError(err); |
|
182 } |
|
183 } |
|
184 |
|
185 /** |
|
186 Test SEID() |
|
187 */ |
|
188 void CT_AvdtpSEPInfoData::DoCmdSEIDL(const TDesC& aSection) |
|
189 { |
|
190 INFO_PRINTF1(_L("TAvdtpSEPInfo SEID() Call.")); |
|
191 INFO_PRINTF1(_L("Execute SEID()")); |
|
192 TSEID actual = iData->SEID(); |
|
193 _LIT(KLogSeid,"actual seid: %d"); |
|
194 INFO_PRINTF2(KLogSeid, actual.SEID()); |
|
195 _LIT(KLogIslocalTrue, "IsLocal: true"); |
|
196 _LIT(KLogIslocalFalse, "IsLocal: false"); |
|
197 if(actual.IsLocal()) |
|
198 { |
|
199 INFO_PRINTF1(KLogIslocalTrue); |
|
200 } |
|
201 else |
|
202 { |
|
203 INFO_PRINTF1(KLogIslocalFalse); |
|
204 } |
|
205 |
|
206 TSEID* expected=NULL; |
|
207 TSEID* setbackSeid=NULL; |
|
208 TPtrC seidName; |
|
209 if ( !GetStringFromConfig(aSection, KFldExpected, seidName) ) |
|
210 { |
|
211 if ( !GetStringFromConfig(aSection, KFldSeid, seidName) ) |
|
212 { |
|
213 ERR_PRINTF3(KLogMissingParameter2, &KFldExpected, &KFldSeid); |
|
214 SetBlockResult(EFail); |
|
215 } |
|
216 else |
|
217 { |
|
218 _LIT(KLogSetSEIDBack,"Set SEID back. Not compare with expected."); |
|
219 INFO_PRINTF1(KLogSetSEIDBack); |
|
220 setbackSeid = static_cast<TSEID*>(GetDataObjectL(seidName)); |
|
221 *setbackSeid = actual; |
|
222 } |
|
223 } |
|
224 else |
|
225 { |
|
226 expected = static_cast<TSEID*>(GetDataObjectL(seidName)); |
|
227 |
|
228 if(expected != NULL) |
|
229 { |
|
230 if(actual != (*expected)) |
|
231 { |
|
232 ERR_PRINTF1(KLogNotExpectedValue); |
|
233 SetBlockResult(EFail); |
|
234 } |
|
235 } |
|
236 else |
|
237 { |
|
238 ERR_PRINTF1(_L("TSEID pointer is NULL")); |
|
239 SetBlockResult(EFail); |
|
240 } |
|
241 } |
|
242 } |
|
243 |
|
244 /** |
|
245 Test SetSEID() |
|
246 */ |
|
247 void CT_AvdtpSEPInfoData::DoCmdSetSEIDL(const TDesC& aSection) |
|
248 { |
|
249 INFO_PRINTF1(_L("TAvdtpSEPInfo SetSEID() Call.")); |
|
250 TSEID* seid=NULL; |
|
251 TPtrC seidName; |
|
252 if ( !GetStringFromConfig(aSection, KFldSeid, seidName) ) |
|
253 { |
|
254 ERR_PRINTF2(KLogMissingParameter, &KFldSeid); |
|
255 SetBlockResult(EFail); |
|
256 } |
|
257 else |
|
258 { |
|
259 seid = static_cast<TSEID*>(GetDataObjectL(seidName)); |
|
260 |
|
261 if(!seid) |
|
262 { |
|
263 ERR_PRINTF1(_L("TSEID pointer is NULL")); |
|
264 SetBlockResult(EFail); |
|
265 } |
|
266 else |
|
267 { |
|
268 INFO_PRINTF1(_L("Execute SetSEID(TSEID)")); |
|
269 iData->SetSEID(*seid); |
|
270 } |
|
271 } |
|
272 } |
|
273 |
|
274 /** |
|
275 Test InUse() |
|
276 */ |
|
277 void CT_AvdtpSEPInfoData::DoCmdInUse(const TDesC& aSection) |
|
278 { |
|
279 INFO_PRINTF1(_L("TAvdtpSEPInfo InUse() Call.")); |
|
280 TBool actual = iData->InUse(); |
|
281 INFO_PRINTF2(_L("Execute InUse()=%d"), actual); |
|
282 |
|
283 TBool expected = EFalse; |
|
284 if( !GetBoolFromConfig(aSection, KFldExpected(), expected) ) |
|
285 { |
|
286 ERR_PRINTF2(KLogMissingParameter, &KFldExpected); |
|
287 SetBlockResult(EFail); |
|
288 } |
|
289 else |
|
290 { |
|
291 if ( actual!=expected ) |
|
292 { |
|
293 ERR_PRINTF1(KLogNotExpectedValue); |
|
294 SetBlockResult(EFail); |
|
295 } |
|
296 } |
|
297 } |
|
298 |
|
299 /** |
|
300 Test SetInUse() |
|
301 */ |
|
302 void CT_AvdtpSEPInfoData::DoCmdSetInUse(const TDesC& aSection) |
|
303 { |
|
304 INFO_PRINTF1(_L("TAvdtpSEPInfo SetInUse() Call.")); |
|
305 TBool isInUse=EFalse; |
|
306 if( !GetBoolFromConfig(aSection, KFldIsInUse(), isInUse) ) |
|
307 { |
|
308 ERR_PRINTF2(KLogMissingParameter, &KFldIsInUse); |
|
309 SetBlockResult(EFail); |
|
310 } |
|
311 else |
|
312 { |
|
313 INFO_PRINTF2(_L("Execute SetInUse(TBool), isinuse = %d"), isInUse); |
|
314 iData->SetInUse(isInUse); |
|
315 } |
|
316 } |
|
317 |
|
318 /** |
|
319 Test MediaType() |
|
320 */ |
|
321 void CT_AvdtpSEPInfoData::DoCmdMediaType(const TDesC& aSection) |
|
322 { |
|
323 INFO_PRINTF1(_L("TAvdtpSEPInfo MediaType() Call.")); |
|
324 SymbianBluetoothAV::TBluetoothMediaType actual = iData->MediaType(); |
|
325 INFO_PRINTF2(_L("Execute MediaType()=%d"), actual); |
|
326 |
|
327 SymbianBluetoothAV::TBluetoothMediaType expected; |
|
328 if( CT_BTUtil::ReadBluetoothMediaType(*this, aSection, KFldExpected(), expected) ) |
|
329 { |
|
330 if ( actual!=expected ) |
|
331 { |
|
332 ERR_PRINTF1(KLogNotExpectedValue); |
|
333 SetBlockResult(EFail); |
|
334 } |
|
335 } |
|
336 else |
|
337 { |
|
338 ERR_PRINTF2(KLogMissingParameter, KFldExpected); |
|
339 SetBlockResult(EFail); |
|
340 } |
|
341 } |
|
342 |
|
343 /** |
|
344 Test SetMediaType() |
|
345 */ |
|
346 void CT_AvdtpSEPInfoData::DoCmdSetMediaType(const TDesC& aSection) |
|
347 { |
|
348 INFO_PRINTF1(_L("TAvdtpSEPInfo SetMediaType() Call.")); |
|
349 SymbianBluetoothAV::TBluetoothMediaType mediaType; |
|
350 if( CT_BTUtil::ReadBluetoothMediaType(*this, aSection, KFldMediaType(), mediaType) ) |
|
351 { |
|
352 INFO_PRINTF2(_L("Execute SetMediaType(SymbianBluetoothAV::TBluetoothMediaType), MediaType = %d"), mediaType); |
|
353 iData->SetMediaType(mediaType); |
|
354 } |
|
355 else |
|
356 { |
|
357 ERR_PRINTF2(KLogMissingParameter, KFldMediaType); |
|
358 SetBlockResult(EFail); |
|
359 } |
|
360 } |
|
361 |
|
362 /** |
|
363 Test IsSink() |
|
364 */ |
|
365 void CT_AvdtpSEPInfoData::DoCmdIsSink(const TDesC& aSection) |
|
366 { |
|
367 INFO_PRINTF1(_L("TAvdtpSEPInfo IsSink() Call.")); |
|
368 TBool actual = iData->IsSink(); |
|
369 INFO_PRINTF2(_L("Execute IsSink()()=%d"), actual); |
|
370 |
|
371 TBool expected = EFalse; |
|
372 if( !GetBoolFromConfig(aSection, KFldExpected(), expected) ) |
|
373 { |
|
374 ERR_PRINTF2(KLogMissingParameter, &KFldExpected); |
|
375 SetBlockResult(EFail); |
|
376 } |
|
377 else |
|
378 { |
|
379 if ( actual!=expected ) |
|
380 { |
|
381 ERR_PRINTF1(KLogNotExpectedValue); |
|
382 SetBlockResult(EFail); |
|
383 } |
|
384 } |
|
385 } |
|
386 |
|
387 /** |
|
388 Test SetIsSink() |
|
389 */ |
|
390 void CT_AvdtpSEPInfoData::DoCmdSetIsSink(const TDesC& aSection) |
|
391 { |
|
392 INFO_PRINTF1(_L("TAvdtpSEPInfo SetIsSink() Call.")); |
|
393 TBool isSink=EFalse; |
|
394 if( !GetBoolFromConfig(aSection, KFldIsSink(), isSink) ) |
|
395 { |
|
396 ERR_PRINTF2(KLogMissingParameter, &KFldIsInUse); |
|
397 SetBlockResult(EFail); |
|
398 } |
|
399 else |
|
400 { |
|
401 INFO_PRINTF2(_L("Execute SetIsSink(TBool), isSink = %d"), isSink); |
|
402 iData->SetIsSink(isSink); |
|
403 } |
|
404 } |