|
1 // Copyright (c) 2007-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 <ecom/implementationproxy.h> |
|
17 #include <ecom/implementationproxy.h> |
|
18 #include <ecom/ecom.h> |
|
19 #include <s32mem.h> |
|
20 |
|
21 #include "gsmconfigci.h" |
|
22 |
|
23 |
|
24 // MUX // |
|
25 |
|
26 TInt CMMFGsmConfigMux::OpenInterface(TUid /*aInterfaceId*/) |
|
27 { |
|
28 // attempt to open the interface link with the |
|
29 // remote slave device |
|
30 iRemoteHandle = -1; |
|
31 TUid slaveId = {KMmfUidCustomInterfaceGsmConfigDeMux}; |
|
32 |
|
33 TInt handle = iUtility->OpenSlave(slaveId, KNullDesC8); |
|
34 if (handle >= 0) |
|
35 { |
|
36 iRemoteHandle = handle; |
|
37 } |
|
38 |
|
39 return iRemoteHandle; |
|
40 } |
|
41 |
|
42 |
|
43 void CMMFGsmConfigMux::Release() |
|
44 { |
|
45 // close the slave device if it exists |
|
46 if (iRemoteHandle > 0) |
|
47 { |
|
48 // we assume the slave is closed correctly |
|
49 iUtility->CloseSlave(iRemoteHandle); |
|
50 } |
|
51 |
|
52 TUid key = iKey; |
|
53 delete this; |
|
54 |
|
55 // tell ECom to destroy us |
|
56 REComSession::DestroyedImplementation(key); |
|
57 } |
|
58 |
|
59 |
|
60 void CMMFGsmConfigMux::PassDestructorKey(TUid aDestructorKey) |
|
61 { |
|
62 // store the destructor key |
|
63 iKey = aDestructorKey; |
|
64 } |
|
65 |
|
66 |
|
67 void CMMFGsmConfigMux::CompleteConstructL(MMMFDevSoundCustomInterfaceMuxUtility* aCustomUtility) |
|
68 { |
|
69 // store a pointer to the utility |
|
70 iUtility = aCustomUtility; |
|
71 } |
|
72 |
|
73 |
|
74 MMMFDevSoundCustomInterfaceMuxPlugin* CMMFGsmConfigMux::NewL() |
|
75 { |
|
76 CMMFGsmConfigMux* self = new (ELeave) CMMFGsmConfigMux; |
|
77 return self; |
|
78 } |
|
79 |
|
80 |
|
81 TAny* CMMFGsmConfigMux::CustomInterface(TUid /*aInterfaceId*/) |
|
82 { |
|
83 MMMFGsmConfig* interface = this; |
|
84 return interface; |
|
85 } |
|
86 |
|
87 |
|
88 CMMFGsmConfigMux::CMMFGsmConfigMux() : |
|
89 iRemoteHandle(-1) |
|
90 { |
|
91 } |
|
92 |
|
93 |
|
94 CMMFGsmConfigMux::~CMMFGsmConfigMux() |
|
95 { |
|
96 } |
|
97 |
|
98 |
|
99 // from MMMFGsmConfig |
|
100 TInt CMMFGsmConfigMux::SetConversionFormat(TMMFGsmConversionFormat aConvFormat) |
|
101 { |
|
102 TInt result = KErrGeneral; |
|
103 |
|
104 if (iRemoteHandle > 0) |
|
105 { |
|
106 // send the convFormat in the sync command |
|
107 TPckgBuf<TMMFGsmConversionFormat> convFormat(aConvFormat); |
|
108 |
|
109 // any return code other than zero is an error |
|
110 result = iUtility->SendSlaveSyncCommand(iRemoteHandle, |
|
111 EMMFDevSoundCIGsmConfigSetConversionFormat, |
|
112 convFormat); |
|
113 } |
|
114 |
|
115 return result; |
|
116 } |
|
117 |
|
118 |
|
119 // from MMMFGsmConfig |
|
120 TInt CMMFGsmConfigMux::ConversionFormat(TMMFGsmConversionFormat& aConvFormat) const |
|
121 { |
|
122 TInt result = KErrGeneral; |
|
123 |
|
124 if (iRemoteHandle > 0) |
|
125 { |
|
126 // send the retConvFormat in the sync command |
|
127 TPckgBuf<TMMFGsmConversionFormat> retConvFormat; |
|
128 |
|
129 result = iUtility->SendSlaveSyncCommandResult(iRemoteHandle, |
|
130 EMMFDevSoundCIGsmConfigGetConversionFormat, |
|
131 KNullDesC8, |
|
132 retConvFormat); |
|
133 |
|
134 // assign return values to aConvFormat. Do nothing if there is an error |
|
135 if(result == KErrNone) |
|
136 { |
|
137 aConvFormat = retConvFormat(); |
|
138 } |
|
139 } |
|
140 |
|
141 return result; |
|
142 } |
|
143 |
|
144 |
|
145 |
|
146 // DEMUX // |
|
147 |
|
148 TInt CMMFGsmConfigDeMux::OpenInterface(TUid /*aInterfaceId*/) |
|
149 { |
|
150 return KErrNone; |
|
151 } |
|
152 |
|
153 |
|
154 void CMMFGsmConfigDeMux::Release() |
|
155 { |
|
156 TUid key = iKey; |
|
157 |
|
158 delete this; |
|
159 |
|
160 // tell ECom to destroy us |
|
161 REComSession::DestroyedImplementation(key); |
|
162 } |
|
163 |
|
164 |
|
165 void CMMFGsmConfigDeMux::PassDestructorKey(TUid aDestructorKey) |
|
166 { |
|
167 // store the destructor key |
|
168 iKey = aDestructorKey; |
|
169 } |
|
170 |
|
171 |
|
172 void CMMFGsmConfigDeMux::SetInterfaceTarget(MMMFDevSoundCustomInterfaceTarget* aTarget) |
|
173 { |
|
174 iTarget = aTarget; |
|
175 } |
|
176 |
|
177 |
|
178 void CMMFGsmConfigDeMux::CompleteConstructL(MMMFDevSoundCustomInterfaceDeMuxUtility* aCustomUtility) |
|
179 { |
|
180 // store a pointer to the utility |
|
181 iUtility = aCustomUtility; |
|
182 } |
|
183 |
|
184 |
|
185 void CMMFGsmConfigDeMux::RefreshL() |
|
186 { |
|
187 // refetch the Gsm config custom interface if we already have a target |
|
188 if (iTarget) |
|
189 { |
|
190 iInterfaceGsmConfig = static_cast <MMMFGsmConfig*> (iTarget->CustomInterface(KUidGsmConfig)); |
|
191 |
|
192 if (!iInterfaceGsmConfig) |
|
193 { |
|
194 iInterfaceGsmConfig = NULL; |
|
195 User::Leave(KErrNotSupported); |
|
196 } |
|
197 } |
|
198 } |
|
199 |
|
200 |
|
201 MMMFDevSoundCustomInterfaceDeMuxPlugin* CMMFGsmConfigDeMux::NewL() |
|
202 { |
|
203 CMMFGsmConfigDeMux* self = new (ELeave) CMMFGsmConfigDeMux; |
|
204 return self; |
|
205 } |
|
206 |
|
207 |
|
208 CMMFGsmConfigDeMux::CMMFGsmConfigDeMux() |
|
209 { |
|
210 } |
|
211 |
|
212 |
|
213 CMMFGsmConfigDeMux::~CMMFGsmConfigDeMux() |
|
214 { |
|
215 } |
|
216 |
|
217 |
|
218 TInt CMMFGsmConfigDeMux::DoOpenSlaveL(TUid /*aInterface*/, const TDesC8& /*aPackageBuf*/) |
|
219 { |
|
220 // fetch the Gsm Config Hw Device custom interface |
|
221 iInterfaceGsmConfig = static_cast<MMMFGsmConfig*> (iTarget->CustomInterface(KUidGsmConfig)); |
|
222 |
|
223 if (!iInterfaceGsmConfig) |
|
224 { |
|
225 iInterfaceGsmConfig = NULL; |
|
226 User::Leave(KErrNotSupported); |
|
227 } |
|
228 |
|
229 return KErrNone; |
|
230 } |
|
231 |
|
232 |
|
233 void CMMFGsmConfigDeMux::DoCloseSlaveL(TInt /*aHandle*/) |
|
234 { |
|
235 // nothing to do |
|
236 } |
|
237 |
|
238 |
|
239 // original RMessage is supplied so that remote demux plugin can extract necessary details |
|
240 // using DeMux utility |
|
241 TInt CMMFGsmConfigDeMux::DoSendSlaveSyncCommandL(const RMmfIpcMessage& aMessage) |
|
242 { |
|
243 TMMFDevSoundCIMessageData data; |
|
244 TInt result = KErrNotSupported; |
|
245 |
|
246 // decode message |
|
247 iUtility->GetSyncMessageDataL(aMessage, data); |
|
248 |
|
249 switch (data.iCommand) |
|
250 { |
|
251 case EMMFDevSoundCIGsmConfigSetConversionFormat: |
|
252 { |
|
253 TPckgBuf<MMMFGsmConfig::TMMFGsmConversionFormat> convFormat; |
|
254 iUtility->ReadFromInputDesL(aMessage, &convFormat); |
|
255 |
|
256 result = DoSetConversionFormatL(convFormat()); |
|
257 |
|
258 break; |
|
259 } |
|
260 default: |
|
261 { |
|
262 User::Leave(KErrNotSupported); |
|
263 } |
|
264 } |
|
265 |
|
266 return result; |
|
267 } |
|
268 |
|
269 |
|
270 TInt CMMFGsmConfigDeMux::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& aMessage) |
|
271 { |
|
272 TMMFDevSoundCIMessageData data; |
|
273 TInt result = KErrNotSupported; |
|
274 |
|
275 // decode message |
|
276 iUtility->GetSyncMessageDataL(aMessage, data); |
|
277 |
|
278 switch (data.iCommand) |
|
279 { |
|
280 case EMMFDevSoundCIGsmConfigGetConversionFormat: |
|
281 { |
|
282 TPckgBuf<MMMFGsmConfig::TMMFGsmConversionFormat> convFormat; |
|
283 iUtility->ReadFromInputDesL(aMessage, &convFormat); |
|
284 |
|
285 result = DoConversionFormatL(convFormat()); |
|
286 |
|
287 TPckgBuf<TBool> des(convFormat()); |
|
288 iUtility->WriteToOutputDesL(aMessage, des); |
|
289 break; |
|
290 } |
|
291 default: |
|
292 { |
|
293 User::Leave(KErrNotSupported); |
|
294 } |
|
295 } |
|
296 |
|
297 return result; |
|
298 } |
|
299 |
|
300 |
|
301 void CMMFGsmConfigDeMux::DoSendSlaveAsyncCommandL(const RMmfIpcMessage& /*aMessage*/) |
|
302 { |
|
303 // not used in this interface |
|
304 } |
|
305 |
|
306 |
|
307 void CMMFGsmConfigDeMux::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& /*aMessage*/) |
|
308 { |
|
309 // not used in this interface |
|
310 } |
|
311 |
|
312 |
|
313 // Gsm Config custom interface implementation |
|
314 TInt CMMFGsmConfigDeMux::DoSetConversionFormatL(MMMFGsmConfig::TMMFGsmConversionFormat aConvFormat) |
|
315 { |
|
316 TInt result = KErrNotFound; |
|
317 |
|
318 if (iInterfaceGsmConfig) |
|
319 { |
|
320 result = iInterfaceGsmConfig->SetConversionFormat(aConvFormat); |
|
321 } |
|
322 |
|
323 return result; |
|
324 } |
|
325 |
|
326 |
|
327 // Gsm Config custom interface implementation |
|
328 TInt CMMFGsmConfigDeMux::DoConversionFormatL(MMMFGsmConfig::TMMFGsmConversionFormat& aConvFormat) const |
|
329 { |
|
330 TInt result = KErrNotFound; |
|
331 |
|
332 if (iInterfaceGsmConfig) |
|
333 { |
|
334 result = iInterfaceGsmConfig->ConversionFormat(aConvFormat); |
|
335 } |
|
336 |
|
337 return result; |
|
338 } |
|
339 |
|
340 |
|
341 // |
|
342 // ImplementationTable |
|
343 // |
|
344 const TImplementationProxy ImplementationTable[] = |
|
345 { |
|
346 IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceGsmConfigMux, CMMFGsmConfigMux::NewL), |
|
347 IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceGsmConfigDeMux, CMMFGsmConfigDeMux::NewL), |
|
348 }; |
|
349 |
|
350 // |
|
351 // ImplementationGroupProxy |
|
352 // |
|
353 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
354 { |
|
355 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
356 |
|
357 return ImplementationTable; |
|
358 } |