|
1 /* |
|
2 * Copyright (c) 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 FILES |
|
19 #include "ASYStubObserver.h" |
|
20 #include "TfAccessoryTestControlTypes.h" |
|
21 #include <AccConGenericID.h> |
|
22 #include <AccPolProprietaryNameValuePairs.h> |
|
23 |
|
24 |
|
25 // ---------------------------------------------------------------------------------- |
|
26 // CASYStubService::CASYStubService() |
|
27 // ---------------------------------------------------------------------------------- |
|
28 CASYStubService::CASYStubService() |
|
29 { |
|
30 } |
|
31 |
|
32 // ---------------------------------------------------------------------------------- |
|
33 // CASYStubService::ConstructL() |
|
34 // ---------------------------------------------------------------------------------- |
|
35 void CASYStubService::ConstructL(void) |
|
36 { |
|
37 TInt err(KErrNone); |
|
38 err = iAccessoryServer.Connect(); |
|
39 |
|
40 if ( err != KErrNone ) |
|
41 { |
|
42 User::Leave( err ); |
|
43 } |
|
44 |
|
45 err = iAccessoryControl.CreateSubSession( iAccessoryServer ); |
|
46 |
|
47 if ( err != KErrNone ) |
|
48 { |
|
49 User::Leave( err ); |
|
50 } |
|
51 } |
|
52 // |
|
53 // ---------------------------------------------------------------------------------- |
|
54 // CASYStubService::~CASYStubService() |
|
55 // ---------------------------------------------------------------------------------- |
|
56 CASYStubService::~CASYStubService() |
|
57 { |
|
58 iAccessoryControl.CloseSubSession(); |
|
59 iAccessoryServer.Close(); |
|
60 } |
|
61 // |
|
62 // ---------------------------------------------------------------------------------- |
|
63 // CASYStubService::Service() |
|
64 // ---------------------------------------------------------------------------------- |
|
65 void CASYStubService::Service( TTFASYReference aMethod, TInt64 aParam1 ) |
|
66 { |
|
67 |
|
68 switch ( aMethod ) |
|
69 { |
|
70 case ETFAsyConn: |
|
71 { |
|
72 |
|
73 TRequestStatus status; |
|
74 CAccConfigFileParser* accConfigFileParser = CAccConfigFileParser::NewL( _L("Configuration file")); |
|
75 |
|
76 TBuf<12> HWModelID; |
|
77 HWModelID.Num(aParam1); |
|
78 |
|
79 CAccConGenericID* genericID = CAccConGenericID::NewL(); |
|
80 CleanupStack::PushL( genericID); |
|
81 |
|
82 accConfigFileParser->FindL( genericID, aParam1, HWModelID ); |
|
83 |
|
84 iAccessoryControl.ConnectAccessory( status, genericID, EFalse); |
|
85 |
|
86 User::WaitForRequest(status); |
|
87 TInt retval = status.Int(); |
|
88 |
|
89 iGenericId = genericID->GenericID(); |
|
90 CleanupStack::PopAndDestroy( genericID); |
|
91 |
|
92 delete accConfigFileParser; |
|
93 |
|
94 } |
|
95 break; |
|
96 |
|
97 case ETFAsyDisc: |
|
98 { |
|
99 TRequestStatus status; |
|
100 iAccessoryControl.DisconnectAccessory(status, iGenericId); |
|
101 User::WaitForRequest(status); |
|
102 TInt retval = status.Int(); |
|
103 } |
|
104 break; |
|
105 |
|
106 default: |
|
107 break; |
|
108 } |
|
109 } |
|
110 |
|
111 // |
|
112 // ---------------------------------------------------------------------------------- |
|
113 // CASYStubService::GetTestCaseID() |
|
114 // ---------------------------------------------------------------------------------- |
|
115 TTFCapability CASYStubService::GetAndRemoveCapability() |
|
116 { |
|
117 |
|
118 TTFCapability aCapabilityS; // Jihuu |
|
119 |
|
120 if( iCapabilityArray.Count() != 0 ) |
|
121 { |
|
122 aCapabilityS.iCapability = iCapabilityArray[0].iCapability; |
|
123 aCapabilityS.iValue = iCapabilityArray[0].iValue; |
|
124 aCapabilityS.iTimeMs = iCapabilityArray[0].iTimeMs; |
|
125 iCapabilityArray.Remove(0); |
|
126 } |
|
127 else |
|
128 { |
|
129 aCapabilityS.iCapability = 0; |
|
130 aCapabilityS.iValue = 0; |
|
131 aCapabilityS.iTimeMs = 0; |
|
132 } |
|
133 |
|
134 return aCapabilityS; |
|
135 } |
|
136 |
|
137 |
|
138 |
|
139 |