|
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 * This class implements RemCon bearer pulgin interface. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <remcon/remconbearerobserver.h> |
|
22 #include <remcon/remconconverterplugin.h> |
|
23 #include <remconaddress.h> |
|
24 #include <RemConExtensionApi.h> |
|
25 #include "atcodec.h" |
|
26 #include "bmbserviceuid.h" |
|
27 #include "bmbplugin.h" |
|
28 #include "debug.h" |
|
29 #include "bmbcmdlistener.h" |
|
30 #include <remconcoreapi.h> |
|
31 |
|
32 class SRemConExtCallHandlingOpToCmd |
|
33 { |
|
34 public: |
|
35 TRemConExtCallHandlingApiOperationId ifId; |
|
36 TATId brId; |
|
37 TATType brType; |
|
38 }; |
|
39 |
|
40 const SRemConExtCallHandlingOpToCmd KRemConExtCallHandlingOpToCmd[] = |
|
41 { |
|
42 {ERemConExtAnswerCall, EATA, EATActionCmd}, |
|
43 {ERemConExtEndCall, EATCHUP, EATActionCmd}, |
|
44 {ERemConExtDialCall, EATD1, EATActionCmd}, |
|
45 {ERemConExtSpeedDial, EATD2, EATActionCmd}, |
|
46 {ERemConExtVoiceDial, EATBVRA, EATWriteCmd}, |
|
47 {ERemConExtLastNumberRedial, EATBLDN, EATActionCmd}, |
|
48 {ERemConExt3WaysCalling, EATCHLD, EATWriteCmd}, |
|
49 {ERemConExtGenerateDTMF, EATVTS, EATWriteCmd}, |
|
50 {ERemConExtAnswerEnd, EATCKPD, EATWriteCmd} |
|
51 }; |
|
52 |
|
53 const TInt KRemConExtCallHandlingOpNum = (sizeof(KRemConExtCallHandlingOpToCmd) / sizeof(SRemConExtCallHandlingOpToCmd)); |
|
54 |
|
55 |
|
56 // ================= MEMBER FUNCTIONS ======================= |
|
57 // --------------------------------------------------------- |
|
58 // CBTAspAccConnection::NewL() |
|
59 // --------------------------------------------------------- |
|
60 // |
|
61 CBmbPlugin* CBmbPlugin::NewL(TBearerParams& aParams) |
|
62 { |
|
63 CBmbPlugin* self = new (ELeave) CBmbPlugin(aParams); |
|
64 CleanupStack::PushL(self); |
|
65 self->ConstructL(); |
|
66 CleanupStack::Pop(self); |
|
67 return self; |
|
68 } |
|
69 |
|
70 // Destructor |
|
71 CBmbPlugin::~CBmbPlugin() |
|
72 { |
|
73 TRACE_FUNC_ENTRY |
|
74 delete iListener; |
|
75 delete iPlayerControlListener; |
|
76 if( iConnIndicated ) |
|
77 { |
|
78 Observer().DisconnectIndicate(iRemConAddress); |
|
79 } |
|
80 TRACE_FUNC_EXIT |
|
81 } |
|
82 |
|
83 TAny* CBmbPlugin::GetInterface(TUid aUid) |
|
84 { |
|
85 TRACE_FUNC_ENTRY |
|
86 TRACE_INFO((_L("aUid = [0x%08X]"), this, aUid)) |
|
87 TAny* ret = NULL; |
|
88 if (aUid == TUid::Uid(KRemConBearerInterface1)) |
|
89 { |
|
90 ret = reinterpret_cast<TAny*>( |
|
91 static_cast<MRemConBearerInterface*>(this) |
|
92 ); |
|
93 } |
|
94 TRACE_INFO((_L("ret = [0x%08X]"), ret)) |
|
95 TRACE_FUNC_EXIT |
|
96 return ret; |
|
97 } |
|
98 |
|
99 TInt CBmbPlugin::GetResponse( |
|
100 TUid& /*aInterfaceUid*/, |
|
101 TUint& /*aTransactionId*/, |
|
102 TUint& /*aOperationId*/, |
|
103 RBuf8& /*aData*/, |
|
104 TRemConAddress& /*aAddr*/) |
|
105 { |
|
106 TRACE_FUNC |
|
107 return KErrNotSupported; |
|
108 } |
|
109 |
|
110 TInt CBmbPlugin::SendCommand( |
|
111 TUid /*aInterfaceUid*/, |
|
112 TUint /*aOperationId*/, |
|
113 TUint /*aTransactionId*/, |
|
114 RBuf8& /*aData*/, |
|
115 const TRemConAddress& /*aAddr*/) |
|
116 { |
|
117 TRACE_FUNC |
|
118 return KErrNotSupported; |
|
119 } |
|
120 |
|
121 void CBmbPlugin::DataFromRemote(const TDesC8& aATCmd) |
|
122 { |
|
123 TRACE_FUNC_ENTRY |
|
124 if (!iConnIndicated) |
|
125 { |
|
126 iConnIndicated = ETrue; |
|
127 Observer().ConnectIndicate(iRemConAddress); |
|
128 } |
|
129 |
|
130 CATCommand *tmpCmd = NULL; |
|
131 TRAPD(err, tmpCmd = CATCommand::NewL(aATCmd)); |
|
132 if(!err) |
|
133 { |
|
134 TRACE_INFO((_L8("DataFromRemote: %S, Id: %d, type %d"), &aATCmd, tmpCmd->Id(), tmpCmd->Type())); |
|
135 for (TInt i = 0; i < KRemConExtCallHandlingOpNum; i++) |
|
136 { |
|
137 if (KRemConExtCallHandlingOpToCmd[i].brId == tmpCmd->Id() && |
|
138 tmpCmd->Type() == KRemConExtCallHandlingOpToCmd[i].brType) |
|
139 { |
|
140 iOperationId = (TUint)KRemConExtCallHandlingOpToCmd[i].ifId; |
|
141 break; |
|
142 } |
|
143 } |
|
144 |
|
145 iInterfaceUid = TUid::Uid(KRemConExtCallHandlingApiUid); |
|
146 iTransactionId = Observer().NewTransactionId(); |
|
147 |
|
148 if (tmpCmd->ParamNum()) |
|
149 { |
|
150 TATParam param; |
|
151 tmpCmd->Parameter(0, param); |
|
152 iInData.Copy(param.Des()); |
|
153 } |
|
154 else |
|
155 { |
|
156 iInData = KNullDesC8; |
|
157 } |
|
158 |
|
159 TRACE_INFO((_L8(" iInterfaceUid 0x%08X, iOperationId %d, iInData '%S'"), |
|
160 iInterfaceUid, iOperationId, &iInData)) |
|
161 |
|
162 err = Observer().NewCommand(iRemConAddress); |
|
163 TRACE_INFO((_L("NewCommand return %d"), err)) |
|
164 delete tmpCmd; |
|
165 } |
|
166 if (err) |
|
167 { |
|
168 TPckgBuf<TInt> pckg(err); |
|
169 iListener->HandlingDataCompleted( pckg ); |
|
170 } |
|
171 TRACE_FUNC_EXIT |
|
172 } |
|
173 |
|
174 TInt CBmbPlugin::GetCommand( |
|
175 TUid& aInterfaceUid, |
|
176 TUint& aTransactionId, |
|
177 TUint& aOperationId, |
|
178 RBuf8& aData, |
|
179 TRemConAddress& aAddr) |
|
180 { |
|
181 TRACE_FUNC |
|
182 aInterfaceUid = iInterfaceUid; |
|
183 aTransactionId = iTransactionId; |
|
184 aOperationId = iOperationId; |
|
185 TInt err = aData.Create(iInData); |
|
186 if (err) |
|
187 { |
|
188 TRACE_ERROR((_L("RBuf8::Create err %d"), err)) |
|
189 } |
|
190 aAddr = iRemConAddress; |
|
191 return err; |
|
192 } |
|
193 |
|
194 TInt CBmbPlugin::SendResponse( |
|
195 TUid aInterfaceUid, |
|
196 TUint aOperationId, |
|
197 TUint /*aTransactionId*/, |
|
198 RBuf8& aData, |
|
199 const TRemConAddress& aAddr) |
|
200 { |
|
201 TRACE_FUNC |
|
202 TRACE_INFO((_L8("interface [0x%08X], op %d"), |
|
203 aInterfaceUid, aOperationId)) |
|
204 if (aInterfaceUid.iUid == KRemConCoreApiUid) |
|
205 { |
|
206 aData.Close(); |
|
207 return KErrNone; |
|
208 } |
|
209 if (aInterfaceUid.iUid == KRemConExtCallHandlingApiUid && |
|
210 iRemConAddress == aAddr && |
|
211 iOperationId == aOperationId) |
|
212 { |
|
213 iListener->HandlingDataCompleted( aData ); |
|
214 aData.Close(); |
|
215 return KErrNone; |
|
216 } |
|
217 return KErrNotFound; |
|
218 } |
|
219 |
|
220 void CBmbPlugin::ConnectRequest(const TRemConAddress& aAddr) |
|
221 { |
|
222 TRACE_FUNC_ENTRY |
|
223 TRACE_INFO((_L8("Request to connect to %S"), &(aAddr.Addr()))) |
|
224 Observer().ConnectConfirm(aAddr, KErrNotSupported); |
|
225 TRACE_FUNC_EXIT |
|
226 } |
|
227 |
|
228 void CBmbPlugin::DisconnectRequest(const TRemConAddress& aAddr) |
|
229 { |
|
230 TRACE_FUNC_ENTRY |
|
231 TRACE_INFO((_L8("Request to disconnect %S"), &(aAddr.Addr()))) |
|
232 Observer().DisconnectConfirm(aAddr, KErrNotSupported); |
|
233 TRACE_FUNC_EXIT |
|
234 } |
|
235 |
|
236 void CBmbPlugin::ClientStatus(TBool /*aControllerPresent*/, TBool /*aTargetPresent*/) |
|
237 { |
|
238 TRACE_FUNC |
|
239 } |
|
240 |
|
241 TSecurityPolicy CBmbPlugin::SecurityPolicy() const |
|
242 { |
|
243 return TSecurityPolicy(ECapabilityLocalServices); |
|
244 } |
|
245 void CBmbPlugin::Pause() |
|
246 { |
|
247 TRACE_FUNC_ENTRY |
|
248 if (!iConnIndicated) |
|
249 { |
|
250 iConnIndicated = ETrue; |
|
251 Observer().ConnectIndicate(iRemConAddress); |
|
252 } |
|
253 |
|
254 iOperationId = (TUint) ERemConCoreApiPause; |
|
255 iInterfaceUid = TUid::Uid(KRemConCoreApiUid); |
|
256 iTransactionId = Observer().NewTransactionId(); |
|
257 |
|
258 iInData = _L8("a"); |
|
259 iInData[0] = ERemConCoreApiButtonClick; |
|
260 |
|
261 TRACE_INFO((_L8(" iInterfaceUid 0x%08X, iOperationId %d"), |
|
262 iInterfaceUid, iOperationId)) |
|
263 iRemConAddress.Addr() = KBTAudioServiceName; |
|
264 TInt err = Observer().NewCommand(iRemConAddress); |
|
265 TRACE_INFO((_L("NewCommand return %d"), err)) |
|
266 TRACE_FUNC_EXIT |
|
267 } |
|
268 |
|
269 void CBmbPlugin::Play() |
|
270 { |
|
271 TRACE_FUNC_ENTRY |
|
272 if (!iConnIndicated) |
|
273 { |
|
274 iConnIndicated = ETrue; |
|
275 Observer().ConnectIndicate(iRemConAddress); |
|
276 } |
|
277 |
|
278 iOperationId = (TUint) ERemConCoreApiPlay; |
|
279 iInterfaceUid = TUid::Uid(KRemConCoreApiUid); |
|
280 iTransactionId = Observer().NewTransactionId(); |
|
281 |
|
282 iInData = _L8("a"); |
|
283 iInData[0] = ERemConCoreApiButtonClick; |
|
284 |
|
285 TRACE_INFO((_L8(" iInterfaceUid 0x%08X, iOperationId %d"), |
|
286 iInterfaceUid, iOperationId)) |
|
287 iRemConAddress.Addr() = KBTAudioServiceName; |
|
288 TInt err = Observer().NewCommand(iRemConAddress); |
|
289 TRACE_INFO((_L("NewCommand return %d"), err)) |
|
290 TRACE_FUNC_EXIT |
|
291 } |
|
292 |
|
293 CBmbPlugin::CBmbPlugin(TBearerParams& aParams) |
|
294 : CRemConBearerPlugin(aParams) |
|
295 { |
|
296 } |
|
297 |
|
298 void CBmbPlugin::ConstructL() |
|
299 { |
|
300 TRACE_FUNC_ENTRY |
|
301 iRemConAddress.BearerUid() = Uid(); |
|
302 iListener = CBmbCmdListener::NewL(*this); |
|
303 iPlayerControlListener = CBTAudioPlayerControlListener::NewL(*this); |
|
304 iRemConAddress.Addr() = KBTAudioServiceName; |
|
305 TRACE_FUNC_EXIT |
|
306 } |
|
307 |
|
308 // End of file |