|
1 // Copyright (c) 2006-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 <mtp/cmtpobjectmetadata.h> |
|
17 #include <mtp/mtpprotocolconstants.h> |
|
18 |
|
19 #include "cmtpconnection.h" |
|
20 #include "cmtpdataprovider.h" |
|
21 #include "cmtpdataprovidercontroller.h" |
|
22 #include "cmtpframeworkconfig.h" |
|
23 #include "cmtpobjectmgr.h" |
|
24 #include "cmtpparserrouter.h" |
|
25 #include "cmtpsession.h" |
|
26 #include "cmtpstoragemgr.h" |
|
27 #include "tmtptypeobjecthandle.h" |
|
28 #include "cmtpservicemgr.h" |
|
29 |
|
30 // Class constants. |
|
31 __FLOG_STMT(_LIT8(KComponent,"ParserRouter");) |
|
32 |
|
33 /** |
|
34 Provides the byte size of the specified array. |
|
35 */ |
|
36 #define _ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) |
|
37 |
|
38 |
|
39 /** |
|
40 CMTPParserRouter panic codes. |
|
41 */ |
|
42 _LIT(KMTPPanicCategory, "CMTPParserRouter"); |
|
43 enum TMTPPanicReasons |
|
44 { |
|
45 EMTPPanicRoutingConflict = 0 |
|
46 }; |
|
47 |
|
48 /** |
|
49 Produces a "CMTPParserRouter" category panic. |
|
50 @param aReason The panic code. |
|
51 */ |
|
52 LOCAL_C void Panic(TInt aReason) |
|
53 { |
|
54 User::Panic(KMTPPanicCategory, aReason); |
|
55 } |
|
56 |
|
57 /** |
|
58 Constructor. |
|
59 */ |
|
60 EXPORT_C CMTPParserRouter::TRoutingParameters::TRoutingParameters(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) : |
|
61 iConnection(aConnection), |
|
62 iRequest(aRequest), |
|
63 iParameters(iParameterData, ENumTypes) |
|
64 { |
|
65 Reset(); |
|
66 } |
|
67 |
|
68 |
|
69 /** |
|
70 Copy constructor. |
|
71 */ |
|
72 CMTPParserRouter::TRoutingParameters::TRoutingParameters(const TRoutingParameters& aParams) : |
|
73 iConnection(aParams.iConnection), |
|
74 iRequest(aParams.iRequest), |
|
75 iParameters(iParameterData, ENumTypes) |
|
76 { |
|
77 iParameters.Copy(aParams.iParameters.Begin(), aParams.iParameters.Count()); |
|
78 } |
|
79 |
|
80 /** |
|
81 Provides the handle of the MTP connection on associated with the operation. |
|
82 @return The MTP connection handle. |
|
83 */ |
|
84 EXPORT_C MMTPConnection& CMTPParserRouter::TRoutingParameters::Connection() const |
|
85 { |
|
86 return iConnection; |
|
87 } |
|
88 |
|
89 /** |
|
90 Provides the value of the specified parameter. |
|
91 @param aId The parameter identifier. |
|
92 @return The parameter value. |
|
93 */ |
|
94 EXPORT_C TUint CMTPParserRouter::TRoutingParameters::Param(CMTPParserRouter::TRoutingParameters::TParameterType aId) const |
|
95 { |
|
96 return iParameters[aId]; |
|
97 } |
|
98 |
|
99 /** |
|
100 Resets all parameter values to zero. |
|
101 */ |
|
102 EXPORT_C void CMTPParserRouter::TRoutingParameters::Reset() |
|
103 { |
|
104 iParameters.Reset(); |
|
105 } |
|
106 |
|
107 /** |
|
108 Provides the operation dataset associated with the operation. |
|
109 @return The operation dataset. |
|
110 */ |
|
111 EXPORT_C const TMTPTypeRequest& CMTPParserRouter::TRoutingParameters::Request() const |
|
112 { |
|
113 return iRequest; |
|
114 } |
|
115 |
|
116 /** |
|
117 Sets the value of the specified parameter. |
|
118 @param aId The parameter identifier. |
|
119 @param aVal The new parameter value. |
|
120 */ |
|
121 EXPORT_C void CMTPParserRouter::TRoutingParameters::SetParam(CMTPParserRouter::TRoutingParameters::TParameterType aId, TUint aVal) |
|
122 { |
|
123 iParameters[aId] = aVal; |
|
124 } |
|
125 |
|
126 /** |
|
127 CMTPParserRouter factory method. |
|
128 @return A pointer to a new CMTPDataProvider instance. Ownership IS transfered. |
|
129 @leave One of the system wide error codes if a processing failure occurs. |
|
130 */ |
|
131 CMTPParserRouter* CMTPParserRouter::NewL() |
|
132 { |
|
133 CMTPParserRouter* self = new (ELeave) CMTPParserRouter(); |
|
134 CleanupStack::PushL(self); |
|
135 self->ConstructL(); |
|
136 CleanupStack::Pop(self); |
|
137 return self; |
|
138 } |
|
139 |
|
140 /** |
|
141 Destructor |
|
142 */ |
|
143 CMTPParserRouter::~CMTPParserRouter() |
|
144 { |
|
145 __FLOG(_L8("~CMTPParserRouter, Entry")); |
|
146 iMaps.ResetAndDestroy(); |
|
147 iSingletons.Close(); |
|
148 __FLOG(_L8("~CMTPParserRouter, Exit")); |
|
149 __FLOG_CLOSE; |
|
150 } |
|
151 |
|
152 /** |
|
153 Configures the parser/router. This processing primarily involves retrieving |
|
154 each data provider's set of supported category codes and using them to build |
|
155 up the operation parameter lookup routing sub-type tables. |
|
156 @leave One of the system wide error codes, if a processing failure occurs. |
|
157 */ |
|
158 EXPORT_C void CMTPParserRouter::ConfigureL() |
|
159 { |
|
160 __FLOG(_L8("ConfigureL, Entry")); |
|
161 const TUint KMapIds[] = |
|
162 { |
|
163 ESubTypeDevicePropCode, |
|
164 ESubTypeObjectPropCode, |
|
165 ESubTypeOperationCode, |
|
166 ESubTypeStorageType, |
|
167 ESubTypeFormatCodeFormatSubcode, |
|
168 ESubTypeFormatCodeOperationCode, |
|
169 ESubTypeStorageTypeOperationCode, |
|
170 ESubTypeFormatCodeFormatSubcodeStorageType, |
|
171 ESubTypeServiceIDOperationCode |
|
172 }; |
|
173 |
|
174 iMaps.ResetAndDestroy(); |
|
175 for (TUint i(0); (i < _ARRAY_SIZE(KMapIds)); i++) |
|
176 { |
|
177 const TUint KSubType(KMapIds[i]); |
|
178 CMap* map(CMap::NewLC(KSubType)); |
|
179 iMaps.AppendL(map); |
|
180 CleanupStack::Pop(map); |
|
181 |
|
182 RArray<TUint> p1Codes; |
|
183 RArray<TUint> p2Codes; |
|
184 RArray<TUint> p3Codes; |
|
185 CleanupClosePushL(p1Codes); |
|
186 CleanupClosePushL(p2Codes); |
|
187 CleanupClosePushL(p3Codes); |
|
188 |
|
189 GetMapParameterIdsL(KSubType, p1Codes, p2Codes, p3Codes); |
|
190 |
|
191 const TUint KParams(KSubType & ESubTypeParamsMask); |
|
192 switch (KParams) |
|
193 { |
|
194 case ESubTypeParams1: |
|
195 Configure1ParameterMapL(KSubType, p1Codes); |
|
196 break; |
|
197 |
|
198 case ESubTypeParams2: |
|
199 Configure2ParameterMapL(KSubType, p1Codes, p2Codes); |
|
200 break; |
|
201 |
|
202 case ESubTypeParams3: |
|
203 Configure3ParameterMapL(KSubType, p1Codes, p2Codes, p3Codes); |
|
204 break; |
|
205 |
|
206 default: |
|
207 __DEBUG_ONLY(User::Invariant()); |
|
208 break; |
|
209 } |
|
210 |
|
211 CleanupStack::PopAndDestroy(&p3Codes); |
|
212 CleanupStack::PopAndDestroy(&p2Codes); |
|
213 CleanupStack::PopAndDestroy(&p1Codes); |
|
214 } |
|
215 |
|
216 __FLOG_STMT(FLOGMapsL()); |
|
217 __FLOG(_L8("ConfigureL, Exit")); |
|
218 } |
|
219 |
|
220 /** |
|
221 Indicates if the specified MTP operation code is supported by any of the set |
|
222 of loaded data providers. |
|
223 @param aOperation The MTP operation code. |
|
224 @leave One of the system wide error codes, if a processing failure occurs. |
|
225 */ |
|
226 EXPORT_C TBool CMTPParserRouter::OperationSupportedL(TUint16 aOperation) const |
|
227 { |
|
228 __FLOG(_L8("OperationSupported, Entry")); |
|
229 RArray<TUint> from; |
|
230 RArray<TUint> to; |
|
231 CleanupClosePushL(from); |
|
232 CleanupClosePushL(to); |
|
233 |
|
234 from.AppendL(aOperation); |
|
235 iMaps[Index(ESubTypeOperationCode)]->GetToL(from, to); |
|
236 TBool ret(to.Count() > 0); |
|
237 |
|
238 CleanupStack::PopAndDestroy(&to); |
|
239 CleanupStack::PopAndDestroy(&from); |
|
240 __FLOG(_L8("OperationSupported, Exit")); |
|
241 return (ret); |
|
242 } |
|
243 |
|
244 /** |
|
245 Parses the operation dataset supplied in the specified routing parameters |
|
246 object which encapsulates all information required to route the operation. |
|
247 The parsing process involves: |
|
248 |
|
249 1. Extracting all relevant routing information from the received operation |
|
250 dataset. Note that not all parameter data is extracted, only that which |
|
251 is required to route the operation. |
|
252 2. Coarse grain validating the parsed data. Specifically this involves |
|
253 validating that any MTP StorageID or Object Handle parameter data refers |
|
254 to valid entities that exist on the device. |
|
255 3. Extracting additional meta-data related to specific data objects and/or |
|
256 storages referred to in the operation dataset and which is required to |
|
257 route the operation. |
|
258 |
|
259 @param aParams The routing parameters object. On entry this contains the |
|
260 operation dataset to be parsed and the handle of the MTP connection on which it |
|
261 was received. On exit this contains all information required to route the |
|
262 operation. |
|
263 @leave One of the system wide error codes if a processing failure occurs, |
|
264 */ |
|
265 EXPORT_C void CMTPParserRouter::ParseOperationRequestL(TRoutingParameters& aParams) const |
|
266 { |
|
267 __FLOG(_L8("ParseOperationRequestL, Entry")); |
|
268 const TUint16 KOpCode(aParams.Request().Uint16(TMTPTypeRequest::ERequestOperationCode)); |
|
269 __FLOG_VA((_L8("Operation Code = 0x%04X"), KOpCode)); |
|
270 switch (KOpCode) |
|
271 { |
|
272 case EMTPOpCodeGetStorageInfo: |
|
273 ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamStorageId, aParams); |
|
274 break; |
|
275 |
|
276 case EMTPOpCodeGetObjectInfo: |
|
277 case EMTPOpCodeGetObject: |
|
278 case EMTPOpCodeGetThumb: |
|
279 case EMTPOpCodeSetObjectProtection: |
|
280 case EMTPOpCodeMoveObject: |
|
281 case EMTPOpCodeCopyObject: |
|
282 case EMTPOpCodeGetPartialObject: |
|
283 case EMTPOpCodeGetObjectReferences: |
|
284 case EMTPOpCodeSetObjectReferences: |
|
285 case EMTPOpCodeUpdateObjectPropList : |
|
286 case EMTPOpCodeDeleteObjectPropList : |
|
287 ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamObjectHandle, aParams); |
|
288 break; |
|
289 |
|
290 case EMTPOpCodeGetObjectPropValue: |
|
291 case EMTPOpCodeSetObjectPropValue: |
|
292 ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamObjectHandle, aParams); |
|
293 ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter2, TRoutingParameters::EParamObjectPropCode, aParams); |
|
294 break; |
|
295 |
|
296 case EMTPOpCodeDeleteObject: |
|
297 ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamObjectHandle, aParams); |
|
298 ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter2, TRoutingParameters::EParamFormatCode, aParams); |
|
299 break; |
|
300 |
|
301 case EMTPOpCodeSendObjectInfo: |
|
302 ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamStorageId, aParams); |
|
303 break; |
|
304 |
|
305 case EMTPOpCodeInitiateCapture: |
|
306 case EMTPOpCodeInitiateOpenCapture: |
|
307 { |
|
308 ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamStorageId, aParams); |
|
309 ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter2, TRoutingParameters::EParamFormatCode, aParams); |
|
310 TUint format(aParams.Request().Uint32(TMTPTypeRequest::ERequestParameter2)); |
|
311 if (format == KMTPNotSpecified32) |
|
312 { |
|
313 iSingletons.FrameworkConfig().GetValueL(MMTPFrameworkConfig::EDefaultObjectFormatCode, format); |
|
314 if (format == KMTPNotSpecified32) |
|
315 { |
|
316 format = EMTPFormatCodeUndefined; |
|
317 } |
|
318 aParams.SetParam(TRoutingParameters::EParamFormatCode, format); |
|
319 } |
|
320 } |
|
321 break; |
|
322 |
|
323 case EMTPOpCodeSendObjectPropList: |
|
324 ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamStorageId, aParams); |
|
325 ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter3, TRoutingParameters::EParamFormatCode, aParams); |
|
326 break; |
|
327 |
|
328 case EMTPOpCodeGetDevicePropDesc: |
|
329 case EMTPOpCodeGetDevicePropValue: |
|
330 case EMTPOpCodeSetDevicePropValue: |
|
331 case EMTPOpCodeResetDevicePropValue: |
|
332 ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamDevicePropCode, aParams); |
|
333 break; |
|
334 |
|
335 case EMTPOpCodeGetObjectPropsSupported: |
|
336 case EMTPOpCodeGetInterdependentPropDesc: |
|
337 case EMTPOpCodeGetFormatCapabilities: |
|
338 ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamFormatCode, aParams); |
|
339 break; |
|
340 |
|
341 case EMTPOpCodeGetObjectPropDesc: |
|
342 ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamObjectPropCode, aParams); |
|
343 ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter2, TRoutingParameters::EParamFormatCode, aParams); |
|
344 break; |
|
345 |
|
346 case EMTPOpCodeGetObjectPropList: |
|
347 ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter2, TRoutingParameters::EParamFormatCode, aParams); |
|
348 ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamObjectHandle, aParams); |
|
349 ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter3, TRoutingParameters::EParamObjectPropCode, aParams); |
|
350 break; |
|
351 |
|
352 case EMTPOpCodeGetServiceInfo : |
|
353 case EMTPOpCodeGetServiceCapabilities : |
|
354 case EMTPOpCodeGetServicePropDesc : |
|
355 case EMTPOpCodeGetServicePropList : |
|
356 case EMTPOpCodeSetServicePropList: |
|
357 case EMTPOpCodeDeleteServicePropList : |
|
358 { |
|
359 ParseOperationRequestParameterL(TMTPTypeRequest::ERequestParameter1, TRoutingParameters::EParamServiceId, aParams); |
|
360 } |
|
361 break; |
|
362 |
|
363 case EMTPOpCodeGetDeviceInfo: |
|
364 case EMTPOpCodeOpenSession: |
|
365 case EMTPOpCodeCloseSession: |
|
366 case EMTPOpCodeGetStorageIDs: |
|
367 case EMTPOpCodeGetNumObjects: |
|
368 case EMTPOpCodeGetObjectHandles: |
|
369 case EMTPOpCodeSendObject: |
|
370 case EMTPOpCodeFormatStore: |
|
371 case EMTPOpCodeResetDevice: |
|
372 case EMTPOpCodeSelfTest: |
|
373 case EMTPOpCodePowerDown: |
|
374 case EMTPOpCodeSetObjectPropList: |
|
375 case EMTPOpCodeSkip: |
|
376 case EMTPOpCodeGetServiceIDs: |
|
377 default: |
|
378 break; |
|
379 } |
|
380 __FLOG(_L8("ParseOperationRequestL, Exit")); |
|
381 } |
|
382 |
|
383 /** |
|
384 Routes an MTP operation using the specified routing parameters. By default |
|
385 only operation parameter routing is performed. |
|
386 @param aParams The routing parameters. |
|
387 @param aTargets One exit, the set of data provider targets to which the |
|
388 operation should be dispatched. |
|
389 @leave One of the system wide error codes if a processing failure occurs, |
|
390 */ |
|
391 EXPORT_C void CMTPParserRouter::RouteOperationRequestL(const TRoutingParameters& aParams, RArray<TUint>& aTargets) const |
|
392 { |
|
393 __FLOG(_L8("RouteOperationRequestL, Entry")); |
|
394 aTargets.Reset(); |
|
395 |
|
396 // By default ETypeOperationParameter routing is always enabled. |
|
397 if (!(aParams.Param(TRoutingParameters::EFlagRoutingTypes) & ETypeOperationParameter)) |
|
398 { |
|
399 const_cast<TRoutingParameters&>(aParams).SetParam(TRoutingParameters::EFlagRoutingTypes, ETypeOperationParameter); |
|
400 } |
|
401 |
|
402 // Get the routing and validation sub-types. |
|
403 RArray<TUint> routing; |
|
404 CleanupClosePushL(routing); |
|
405 RArray<TUint> validation; |
|
406 CleanupClosePushL(validation); |
|
407 RArray<TRoutingParameters> params; |
|
408 CleanupClosePushL(params); |
|
409 params.AppendL(TRoutingParameters(aParams)); |
|
410 TRoutingParameters& param1(params[0]); |
|
411 GetRoutingSubTypesL(params, routing, validation); |
|
412 |
|
413 // Execute the routing sub-types. |
|
414 const TUint KCountParams(params.Count()); |
|
415 for (TUint p(0); ((p < KCountParams) && (aTargets.Count() == 0)); p++) |
|
416 { |
|
417 const TRoutingParameters& KParam(params[p]); |
|
418 const TUint KCountRouting(routing.Count()); |
|
419 for (TUint r(0); (r < KCountRouting); r++) |
|
420 { |
|
421 const TUint KRouting(routing[r]); |
|
422 if ((KRouting & ESubTypeParamsMask) == ESubTypeParams0) |
|
423 { |
|
424 RouteOperationRequest0ParametersL(KRouting, KParam, aTargets); |
|
425 } |
|
426 else |
|
427 { |
|
428 RouteOperationRequestNParametersL(KRouting, KParam, aTargets); |
|
429 } |
|
430 } |
|
431 } |
|
432 |
|
433 // Execute the validation sub-types. |
|
434 ValidateTargetsL(param1, validation, aTargets); |
|
435 const TUint KCountTargets(aTargets.Count()); |
|
436 if ((KCountTargets == 0) && (param1.Param(TRoutingParameters::EFlagRoutingTypes) & ETypeFramework)) |
|
437 { |
|
438 SelectTargetL(iSingletons.DpController().DeviceDpId(), aTargets); |
|
439 } |
|
440 else if (KCountTargets > 1) |
|
441 { |
|
442 if (param1.Param(TRoutingParameters::EFlagRoutingTypes) & ETypeFlagSingleTarget) |
|
443 { |
|
444 TUint target(KCountTargets); |
|
445 while (target-- > 1) |
|
446 { |
|
447 aTargets.Remove(target); |
|
448 } |
|
449 } |
|
450 else if (param1.Param(TRoutingParameters::EFlagRoutingTypes) & ETypeFramework) |
|
451 { |
|
452 aTargets.Reset(); |
|
453 SelectTargetL(iSingletons.DpController().ProxyDpId(), aTargets); |
|
454 } |
|
455 } |
|
456 CleanupStack::PopAndDestroy(¶ms); |
|
457 CleanupStack::PopAndDestroy(&validation); |
|
458 CleanupStack::PopAndDestroy(&routing); |
|
459 __FLOG(_L8("RouteOperationRequestL, Exit")); |
|
460 } |
|
461 |
|
462 /** |
|
463 Indicates if a routing request with the specified MTP operation code is |
|
464 registered on the specified session. |
|
465 @param aRequest The MTP operation requesty dataset specifying MTP operation |
|
466 code and session. |
|
467 @param aConnection The handle of the MTP connection on which the operation |
|
468 request is expected to be received. |
|
469 @return ETrue if a routing request with the specified MTP operation code is |
|
470 registered on the session, otherwise EFalse. |
|
471 @leave One of the system wide error codes, if a processing failure occurs. |
|
472 */ |
|
473 EXPORT_C TBool CMTPParserRouter::RouteRequestRegisteredL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) const |
|
474 { |
|
475 __FLOG(_L8("RouteRequestRegistered, Entry")); |
|
476 TBool ret(EFalse); |
|
477 const TUint32 KSessionId(aRequest.Uint32(TMTPTypeRequest::ERequestSessionID)); |
|
478 if ((KSessionId != KMTPSessionAll) && (aConnection.SessionWithMTPIdExists(KSessionId))) |
|
479 { |
|
480 CMTPSession& session(static_cast<CMTPSession&>(aConnection.SessionWithMTPIdL(KSessionId))); |
|
481 ret = session.RouteRequestRegistered(aRequest.Uint16(TMTPTypeRequest::ERequestOperationCode)); |
|
482 } |
|
483 __FLOG(_L8("RouteRequestRegistered, Exit")); |
|
484 return ret; |
|
485 } |
|
486 |
|
487 /** |
|
488 Routes and dispatches the specified MTP event dataset. The only valid event |
|
489 that is accepted is CancelTransaction, all other event types are discarded. |
|
490 Events are routed to the same target to which the currently active operation |
|
491 was dispatched. If there is no active transaction in progress then the event |
|
492 will be discarded. |
|
493 @param aEvent The MTP event dataset. |
|
494 @param aConnection The MTP connection on which the event was received. |
|
495 @leave One of the system wide error codes, if a processing failure occurs. |
|
496 */ |
|
497 void CMTPParserRouter::ProcessEventL(const TMTPTypeEvent& aEvent, CMTPConnection& aConnection) const |
|
498 { |
|
499 __FLOG(_L8("ProcessEventL, Entry")); |
|
500 if ((aEvent.Uint16(TMTPTypeEvent::EEventCode) == EMTPEventCodeCancelTransaction) && |
|
501 (aConnection.SessionWithMTPIdExists(aEvent.Uint32(TMTPTypeEvent::EEventSessionID)))) |
|
502 { |
|
503 CMTPSession& session(static_cast<CMTPSession&>(aConnection.SessionWithMTPIdL(aEvent.Uint32(TMTPTypeEvent::EEventSessionID)))); |
|
504 if (session.TransactionPhase() != EIdlePhase) |
|
505 { |
|
506 iSingletons.DpController().DataProviderL(RoutingTargetL(session.ActiveRequestL(), aConnection)).ExecuteEventL(aEvent, aConnection); |
|
507 } |
|
508 } |
|
509 __FLOG(_L8("ProcessEventL, Exit")); |
|
510 } |
|
511 |
|
512 /** |
|
513 Routes and dispatches the specified MTP operation (request) dataset. |
|
514 @param aRequest The MTP operation (request) dataset. |
|
515 @param aConnection The MTP connection on which the event was received. |
|
516 @leave One of the system wide error codes, if a processing failure occurs. |
|
517 */ |
|
518 void CMTPParserRouter::ProcessRequestL(const TMTPTypeRequest& aRequest, CMTPConnection& aConnection) const |
|
519 { |
|
520 __FLOG(_L8("ProcessRequestL, Entry")); |
|
521 iSingletons.DpController().DataProviderL(RoutingTargetL(aRequest, aConnection)).ExecuteRequestL(aRequest, aConnection); |
|
522 __FLOG(_L8("ProcessRequestL, Exit")); |
|
523 } |
|
524 |
|
525 /** |
|
526 Registers the calling data provider to receive one or more occurrences of |
|
527 the specified request dataset that are received on the specified connection. |
|
528 @param aRequest The operation request dataset being registered. |
|
529 @param aConnection The handle of the MTP connection on which the operation |
|
530 request is expected to be received. |
|
531 @param aId The data provider identifier. |
|
532 @leave One of the system wide error codes, if a processing failure occurs. |
|
533 @see MMTPDataProviderFramework::RouteRequestRegisterL |
|
534 */ |
|
535 void CMTPParserRouter::RouteRequestRegisterL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection, TInt aId) |
|
536 { |
|
537 __FLOG(_L8("RouteRequestRegisterL, Entry")); |
|
538 const TUint32 KSessionId(aRequest.Uint32(TMTPTypeRequest::ERequestSessionID)); |
|
539 if (KSessionId == KMTPSessionAll) |
|
540 { |
|
541 // Register the request on all sessions. |
|
542 const TUint KNumSessions(aConnection.SessionCount()); |
|
543 TUint count(0); |
|
544 TUint sessionId(1); |
|
545 while (count < KNumSessions) |
|
546 { |
|
547 // Insert the correct session id into a copy of the request and register this copy with the session |
|
548 if (aConnection.SessionWithMTPIdExists(sessionId)) |
|
549 { |
|
550 // Session exists |
|
551 count++; |
|
552 TMTPTypeRequest req(aRequest); |
|
553 req.SetUint32(TMTPTypeRequest::ERequestSessionID, sessionId); |
|
554 CMTPSession& session(static_cast<CMTPSession&>(aConnection.SessionWithMTPIdL(sessionId))); |
|
555 session.RouteRequestRegisterL(req, aId); |
|
556 } |
|
557 sessionId++; |
|
558 } |
|
559 } |
|
560 else |
|
561 { |
|
562 CMTPSession& session(static_cast<CMTPSession&>(aConnection.SessionWithMTPIdL(KSessionId))); |
|
563 session.RouteRequestRegisterL(aRequest, aId); |
|
564 } |
|
565 __FLOG(_L8("RouteRequestRegisterL, Exit")); |
|
566 } |
|
567 |
|
568 /** |
|
569 Cancels a pending RouteRequestRegisterL registration. |
|
570 @param aRequest The registered operation request dataset. |
|
571 @param aConnection The handle of the MTP connection for which the operation |
|
572 request was registered. |
|
573 @leave One of the system wide error codes, if a general processing error |
|
574 occurs. |
|
575 @see MMTPDataProviderFramework::RouteRequestUnregisterL |
|
576 */ |
|
577 void CMTPParserRouter::RouteRequestUnregisterL(const TMTPTypeRequest& aRequest, MMTPConnection& aConnection) |
|
578 { |
|
579 __FLOG(_L8("RouteRequestUnregisterL, Entry")); |
|
580 CMTPSession& session(static_cast<CMTPSession&>(aConnection.SessionWithMTPIdL(aRequest.Uint32(TMTPTypeRequest::ERequestSessionID)))); |
|
581 session.RouteRequestUnregister(aRequest); |
|
582 __FLOG(_L8("RouteRequestUnregisterL, Exit")); |
|
583 } |
|
584 |
|
585 /** |
|
586 Constructor. |
|
587 @param aFrom The map source parameter. |
|
588 */ |
|
589 CMTPParserRouter::TMap::TMap(TUint aFrom) : |
|
590 iFrom(aFrom), |
|
591 iSubType(0), |
|
592 iTo(0) |
|
593 { |
|
594 |
|
595 } |
|
596 |
|
597 /** |
|
598 Constructor. |
|
599 @param aFrom The map source parameter. |
|
600 @param aTo The map target. |
|
601 @param aSubType The map routing sub-type code (@see CMTPParserRouter::TRoutingSubType). |
|
602 */ |
|
603 CMTPParserRouter::TMap::TMap(TUint aFrom, TUint aTo, TUint aSubType) : |
|
604 iFrom(aFrom), |
|
605 iSubType(aSubType), |
|
606 iTo(aTo) |
|
607 { |
|
608 |
|
609 } |
|
610 |
|
611 /** |
|
612 CMTPParserRouter::CMap factory method. |
|
613 @param aSubType The map routing sub-type code (@see CMTPParserRouter::TRoutingSubType). |
|
614 @leave One of the system wide error codes, if a general processing error |
|
615 occurs. |
|
616 */ |
|
617 CMTPParserRouter::CMap* CMTPParserRouter::CMap::NewLC(TUint aSubType) |
|
618 { |
|
619 return NewLC(0, aSubType); |
|
620 } |
|
621 |
|
622 /** |
|
623 Destructor. |
|
624 */ |
|
625 CMTPParserRouter::CMap::~CMap() |
|
626 { |
|
627 if (Params(iSubType) == ESubTypeParams1) |
|
628 { |
|
629 iToNodes.Reset(); |
|
630 } |
|
631 else |
|
632 { |
|
633 iToBranches.ResetAndDestroy(); |
|
634 } |
|
635 __FLOG_CLOSE; |
|
636 } |
|
637 |
|
638 /** |
|
639 Provides the map source parameter. |
|
640 @return The map source parameter. |
|
641 */ |
|
642 TUint CMTPParserRouter::CMap::From() const |
|
643 { |
|
644 return iFrom; |
|
645 } |
|
646 |
|
647 /** |
|
648 Initialises a map source parameter set array. |
|
649 @param aFrom On exit, the initialised map source parameter set array. |
|
650 @leave One of the system wide error codes, if a general processing error |
|
651 occurs. |
|
652 |
|
653 */ |
|
654 void CMTPParserRouter::CMap::InitParamsL(RArray<TUint>& aFrom) const |
|
655 { |
|
656 aFrom.Reset(); |
|
657 TUint KCount(ParamsCount(iSubType)); |
|
658 for (TUint i(0); (i < KCount); i++) |
|
659 { |
|
660 aFrom.AppendL(0); |
|
661 } |
|
662 } |
|
663 |
|
664 /** |
|
665 Inserts an entry into the map table with the specified source and target |
|
666 parameters. |
|
667 @param aFrom The map source parameter set array. |
|
668 @param aFrom The map target parameter. |
|
669 @leave One of the system wide error codes, if a general processing error |
|
670 occurs. |
|
671 */ |
|
672 void CMTPParserRouter::CMap::InsertL(const RArray<TUint>& aFrom, TUint aTo) |
|
673 { |
|
674 const TUint KFrom(Param(aFrom)); |
|
675 if (Params(iSubType) == ESubTypeParams1) |
|
676 { |
|
677 // Node. |
|
678 __FLOG_STMT(FLOGMapEntryL(aFrom, aTo)); |
|
679 const TUint KSubType(CMTPParserRouter::SubType(Index(iSubType), Flags(iSubType), (ParamsCount(iSubType) - 1))); |
|
680 const TMap KNode(KFrom, aTo, KSubType); |
|
681 NodeInsertL(KNode); |
|
682 } |
|
683 else |
|
684 { |
|
685 // Branch. |
|
686 TInt idx(BranchFind(KFrom)); |
|
687 if (idx == KErrNotFound) |
|
688 { |
|
689 idx = BranchInsertL(KFrom); |
|
690 __ASSERT_DEBUG((idx != KErrNotFound), User::Invariant()); |
|
691 } |
|
692 iToBranches[idx]->InsertL(aFrom, aTo); |
|
693 } |
|
694 } |
|
695 |
|
696 /** |
|
697 Provides the set of targets which map from the specified source parameters. |
|
698 @param aFrom The map source parameters. |
|
699 @param aTo The map target parameter set. |
|
700 @leave One of the system wide error codes, if a general processing error |
|
701 occurs. |
|
702 */ |
|
703 void CMTPParserRouter::CMap::GetToL(const RArray<TUint>& aFrom, RArray<TUint>& aTo) const |
|
704 { |
|
705 __FLOG(_L8("CMap::GetToL - entry")); |
|
706 const TUint KFrom(Param(aFrom)); |
|
707 if (KFrom == KMTPNotSpecified32) |
|
708 { |
|
709 // Null (zero) parameter acts as a wildcard. |
|
710 SelectTargetAllL(aFrom, aTo); |
|
711 } |
|
712 else if (Flags(iSubType) & ESubTypeFlagEnableDuplicates) |
|
713 { |
|
714 // Select 0 .. n matching targets. |
|
715 SelectTargetMatchingL(aFrom, aTo); |
|
716 } |
|
717 else |
|
718 { |
|
719 // Select 0 .. 1 matching targets. |
|
720 SelectTargetSingleL(aFrom, aTo); |
|
721 } |
|
722 __FLOG(_L8("CMap::GetToL - Exit")); |
|
723 } |
|
724 |
|
725 /** |
|
726 Provides the map subtype code. |
|
727 @return The map subtype code. |
|
728 */ |
|
729 TUint CMTPParserRouter::CMap::SubType() const |
|
730 { |
|
731 return iSubType; |
|
732 } |
|
733 |
|
734 #ifdef __FLOG_ACTIVE |
|
735 /** |
|
736 Logs the map table entries (source and target) which match the specified source |
|
737 parameters. |
|
738 @param aFrom The map source parameters. |
|
739 @leave One of the system wide error codes, if a general processing error |
|
740 occurs. |
|
741 */ |
|
742 void CMTPParserRouter::CMap::FLOGMapL(RArray<TUint>& aFrom) const |
|
743 { |
|
744 if (Params(iSubType) == ESubTypeParams1) |
|
745 { |
|
746 // Node. |
|
747 const TUint KCount(iToNodes.Count()); |
|
748 for (TUint i(0); (i < KCount); i++) |
|
749 { |
|
750 aFrom[ParamIdx(aFrom)] = iToNodes[i].iFrom; |
|
751 FLOGMapEntryL(aFrom, iToNodes[i].iTo); |
|
752 } |
|
753 } |
|
754 else |
|
755 { |
|
756 // Branch. |
|
757 const TUint KCount(iToBranches.Count()); |
|
758 for (TUint i(0); (i < KCount); i++) |
|
759 { |
|
760 const CMap& KBranch(*iToBranches[i]); |
|
761 aFrom[ParamIdx(aFrom)] = KBranch.iFrom; |
|
762 KBranch.FLOGMapL(aFrom); |
|
763 } |
|
764 } |
|
765 } |
|
766 |
|
767 /** |
|
768 Logs the specified source and target map table entry parameters. |
|
769 @param aFrom The map source parameters. |
|
770 @param aTo The map target parameter. |
|
771 @leave One of the system wide error codes, if a general processing error |
|
772 occurs. |
|
773 */ |
|
774 void CMTPParserRouter::CMap::FLOGMapEntryL(const RArray<TUint>& aFrom, TUint aTo) const |
|
775 { |
|
776 __ASSERT_DEBUG((aFrom.Count() >= ParamsCount(iSubType)), User::Invariant()); |
|
777 RBuf log; |
|
778 log.CleanupClosePushL(); |
|
779 const TUint KParamsCount(aFrom.Count()); |
|
780 const TUint KWidthFrom(8); |
|
781 const TUint KWidthTo(2); |
|
782 const TUint KLength((KParamsCount * 11) + 7); |
|
783 log.CreateL(KLength); |
|
784 for (TUint i(0); (i < KParamsCount); i++) |
|
785 { |
|
786 log.Append(_L("0x")); |
|
787 log.AppendNumFixedWidthUC(aFrom[i], EHex, KWidthFrom); |
|
788 log.Append(_L(" ")); |
|
789 } |
|
790 log.Append(_L("-> 0x")); |
|
791 log.AppendNumFixedWidthUC(aTo, EHex, KWidthTo); |
|
792 __FLOG(log); |
|
793 CleanupStack::PopAndDestroy(&log); |
|
794 } |
|
795 #endif |
|
796 |
|
797 /** |
|
798 CMTPParserRouter::CMap factory method. |
|
799 @param aFrom The map source parameter. |
|
800 @param aTo The map target parameter. |
|
801 @leave One of the system wide error codes, if a general processing error |
|
802 occurs. |
|
803 */ |
|
804 CMTPParserRouter::CMap* CMTPParserRouter::CMap::NewLC(TUint aFrom, TUint aSubType) |
|
805 { |
|
806 CMap* self(new(ELeave) CMap(aFrom, aSubType)); |
|
807 CleanupStack::PushL(self); |
|
808 self->ConstructL(); |
|
809 return self; |
|
810 } |
|
811 |
|
812 /** |
|
813 Constructor. |
|
814 @param aFrom The map source parameter. |
|
815 @param aTo The map target parameter. |
|
816 */ |
|
817 CMTPParserRouter::CMap::CMap(TUint aFrom, TUint aSubType) : |
|
818 iFrom(aFrom), |
|
819 iSubType(aSubType) |
|
820 { |
|
821 |
|
822 } |
|
823 |
|
824 /** |
|
825 Second-phase constructor. |
|
826 */ |
|
827 void CMTPParserRouter::CMap::ConstructL() |
|
828 { |
|
829 __FLOG_OPEN(KMTPSubsystem, KComponent); |
|
830 } |
|
831 |
|
832 /** |
|
833 Locates the map branch table index of the first map table entry matching the |
|
834 specified source parameter, using a binary search algorithm. |
|
835 @param aFrom The map source parameter, |
|
836 @return The map node table index of the first matching entry, or KErrNotFound |
|
837 if no matching entry is found. |
|
838 */ |
|
839 TInt CMTPParserRouter::CMap::BranchFind(TUint aFrom) const |
|
840 { |
|
841 return (iToBranches.FindInOrder(aFrom, ((Flags(iSubType) & ESubTypeFlagOrderDescending) ? BranchOrderFromKeyDescending : BranchOrderFromKeyAscending))); |
|
842 } |
|
843 |
|
844 /** |
|
845 Inserts a new map branch table with the specified source parameter. |
|
846 @param aFrom The map source paramete. |
|
847 @return The map branch table index of the new entry. |
|
848 @leave One of the system wide error codes, if a general processing error |
|
849 occurs. |
|
850 */ |
|
851 TUint CMTPParserRouter::CMap::BranchInsertL(TUint aFrom) |
|
852 { |
|
853 CMap* branch(CMap::NewLC(aFrom, CMTPParserRouter::SubType(Index(iSubType), Flags(iSubType), (ParamsCount(iSubType) - 1)))); |
|
854 TLinearOrder<CMap> KOrder((iSubType & ESubTypeFlagOrderDescending) ? BranchOrderFromDescending : BranchOrderFromAscending); |
|
855 iToBranches.InsertInOrderL(branch, KOrder); |
|
856 CleanupStack::Pop(branch); |
|
857 return iToBranches.FindInOrder(branch, KOrder); |
|
858 } |
|
859 |
|
860 /** |
|
861 Locates the map node table index of the first map table entry matching the |
|
862 specified source parameter, using a binary search algorithm. |
|
863 @param aFrom The source parameter, |
|
864 @return The map node table index of the first matching entry, or KErrNotFound |
|
865 if no matching entry is found. |
|
866 */ |
|
867 TInt CMTPParserRouter::CMap::NodeFind(TUint aFrom) const |
|
868 { |
|
869 return (iToNodes.FindInOrder(aFrom, ((Flags(iSubType) & ESubTypeFlagOrderDescending) ? NodeOrderFromKeyDescending : NodeOrderFromKeyAscending))); |
|
870 } |
|
871 |
|
872 /** |
|
873 Locates the map node table index of the map table entry matching the specified |
|
874 node, using a binary search algorithm. |
|
875 @param aFrom The map node table entry. |
|
876 @return The map node table index, or KErrNotFound if no matching entry is |
|
877 found. |
|
878 */ |
|
879 TInt CMTPParserRouter::CMap::NodeFind(const TMap& aNode) const |
|
880 { |
|
881 return iToNodes.FindInOrder(aNode, ((Flags(iSubType) & ESubTypeFlagOrderDescending) ? NodeOrderFromToDescending : NodeOrderFromToAscending)); |
|
882 } |
|
883 |
|
884 /** |
|
885 Inserts the specified map node into the map node table. |
|
886 @param aFrom The map node table entry. |
|
887 @return The map node table index of the new entry. |
|
888 @leave One of the system wide error codes, if a general processing error |
|
889 occurs. |
|
890 */ |
|
891 TUint CMTPParserRouter::CMap::NodeInsertL(const TMap& aMap) |
|
892 { |
|
893 TLinearOrder<TMap> KOrder((iSubType & ESubTypeFlagOrderDescending) ? NodeOrderFromToDescending : NodeOrderFromToAscending); |
|
894 if (Flags(iSubType) & ESubTypeFlagEnableDuplicates) |
|
895 { |
|
896 // Duplicates allowed, but discard completely duplicated routes. |
|
897 if (NodeFind(aMap) == KErrNotFound) |
|
898 { |
|
899 iToNodes.InsertInOrderL(aMap, KOrder); |
|
900 } |
|
901 } |
|
902 else |
|
903 { |
|
904 TInt err(iToNodes.InsertInOrder(aMap, KOrder)); |
|
905 if (err == KErrAlreadyExists) |
|
906 { |
|
907 Panic(EMTPPanicRoutingConflict); |
|
908 } |
|
909 else |
|
910 { |
|
911 User::LeaveIfError(err); |
|
912 } |
|
913 } |
|
914 const TInt KIdx(NodeFind(aMap)); |
|
915 __ASSERT_DEBUG((KIdx != KErrNotFound), User::Invariant()); |
|
916 return KIdx; |
|
917 } |
|
918 |
|
919 /** |
|
920 Provides the source parameter value from the specified source parameter set |
|
921 appropriate to the parameter level of the map. |
|
922 @param aFrom The map source parameter set. |
|
923 @return The parameter value. |
|
924 */ |
|
925 TUint CMTPParserRouter::CMap::Param(const RArray<TUint>& aFrom) const |
|
926 { |
|
927 return (aFrom[ParamIdx(aFrom)]); |
|
928 } |
|
929 |
|
930 /** |
|
931 Provides the source parameter set index of the source parameter corresponding to the |
|
932 parameter level of the map. |
|
933 @param aFrom The map source parameter set. |
|
934 @return The parameter set index. |
|
935 */ |
|
936 TUint CMTPParserRouter::CMap::ParamIdx(const RArray<TUint>& aFrom) const |
|
937 { |
|
938 return (aFrom.Count() - ParamsCount(iSubType)); |
|
939 } |
|
940 |
|
941 /** |
|
942 Selects all map targets at the parameter level of the map. |
|
943 @param aFrom The map source parameter set. |
|
944 @param aTo The matching target parameters. |
|
945 @leave One of the system wide error codes, if a general processing error |
|
946 occurs. |
|
947 */ |
|
948 void CMTPParserRouter::CMap::SelectTargetAllL(const RArray<TUint>& aFrom, RArray<TUint>& aTo) const |
|
949 { |
|
950 if (Params(iSubType) == ESubTypeParams1) |
|
951 { |
|
952 // Node. |
|
953 const TUint KCount(iToNodes.Count()); |
|
954 for (TUint idx(0); (idx < KCount); idx++) |
|
955 { |
|
956 SelectTargetL(iToNodes[idx].iTo, aTo); |
|
957 } |
|
958 } |
|
959 else |
|
960 { |
|
961 // Branch. |
|
962 const TUint KCount(iToBranches.Count()); |
|
963 for (TUint idx(0); (idx < KCount); idx++) |
|
964 { |
|
965 iToBranches[idx]->GetToL(aFrom, aTo); |
|
966 } |
|
967 } |
|
968 } |
|
969 |
|
970 /** |
|
971 Selects all map targets which match the specified source parameters. |
|
972 @param aFrom The map source parameter set. |
|
973 @param aTo The matching target parameters. |
|
974 @leave One of the system wide error codes, if a general processing error |
|
975 occurs. |
|
976 */ |
|
977 void CMTPParserRouter::CMap::SelectTargetMatchingL(const RArray<TUint>& aFrom, RArray<TUint>& aTo) const |
|
978 { |
|
979 __FLOG(_L8("CMap::SelectTargetMatchingL - entry")); |
|
980 const TUint KFrom(Param(aFrom)); |
|
981 TInt idx(KErrNotFound); |
|
982 if (Params(iSubType) == ESubTypeParams1) |
|
983 { |
|
984 idx = iToNodes.SpecificFindInOrder(TMap(KFrom), ((iSubType & ESubTypeFlagOrderDescending) ? NodeOrderFromDescending : NodeOrderFromAscending), EArrayFindMode_First); |
|
985 if (idx != KErrNotFound) |
|
986 { |
|
987 const TUint KCount(iToNodes.Count()); |
|
988 while ((idx < KCount) && (iToNodes[idx].iFrom == KFrom)) |
|
989 { |
|
990 SelectTargetL(iToNodes[idx++].iTo, aTo); |
|
991 } |
|
992 } |
|
993 } |
|
994 else |
|
995 { |
|
996 CMap* from(CMap::NewLC(KFrom, iSubType)); |
|
997 idx = iToBranches.SpecificFindInOrder(from, ((iSubType & ESubTypeFlagOrderDescending) ? BranchOrderFromDescending : BranchOrderFromAscending), EArrayFindMode_First); |
|
998 CleanupStack::PopAndDestroy(from); |
|
999 const TUint KCount(iToBranches.Count()); |
|
1000 while ((idx < KCount) && (iToBranches[idx]->From() == KFrom)) |
|
1001 { |
|
1002 iToBranches[idx++]->GetToL(aFrom, aTo); |
|
1003 } |
|
1004 } |
|
1005 __FLOG(_L8("CMap::SelectTargetMatchingL - exit")); |
|
1006 } |
|
1007 |
|
1008 /** |
|
1009 Selects the first map target which matches the specified source parameters. |
|
1010 @param aFrom The map source parameter set. |
|
1011 @param aTo The matching target parameters. |
|
1012 @leave One of the system wide error codes, if a general processing error |
|
1013 occurs. |
|
1014 */ |
|
1015 void CMTPParserRouter::CMap::SelectTargetSingleL(const RArray<TUint>& aFrom, RArray<TUint>& aTo) const |
|
1016 { |
|
1017 const TUint KFrom(Param(aFrom)); |
|
1018 TInt idx(KErrNotFound); |
|
1019 if (Params(iSubType) == ESubTypeParams1) |
|
1020 { |
|
1021 idx = NodeFind(KFrom); |
|
1022 if (idx != KErrNotFound) |
|
1023 { |
|
1024 SelectTargetL(iToNodes[idx].iTo, aTo); |
|
1025 } |
|
1026 } |
|
1027 else |
|
1028 { |
|
1029 idx = BranchFind(KFrom); |
|
1030 if (idx != KErrNotFound) |
|
1031 { |
|
1032 iToBranches[idx]->GetToL(aFrom, aTo); |
|
1033 } |
|
1034 } |
|
1035 } |
|
1036 |
|
1037 /** |
|
1038 Implements an @see TLinearOrder relation for @see CMTPParserRouter::CMap |
|
1039 branch map objects based on ascending map source parameter order. |
|
1040 @param aL The first object instance. |
|
1041 @param aR The second object instance. |
|
1042 @return Zero, if the two objects are equal; A negative value, if the first |
|
1043 object is less than the second, or; A positive value, if the first object is |
|
1044 greater than the second. |
|
1045 */ |
|
1046 TInt CMTPParserRouter::CMap::BranchOrderFromAscending(const CMap& aL, const CMap& aR) |
|
1047 { |
|
1048 return (aL.iFrom - aR.iFrom); |
|
1049 } |
|
1050 |
|
1051 /** |
|
1052 Implements an @see TLinearOrder relation for @see CMTPParserRouter::CMap |
|
1053 branch map objects based on descending map source parameter order. |
|
1054 @param aL The first object instance. |
|
1055 @param aR The second object instance. |
|
1056 @return Zero, if the two objects are equal; A positive value, if the first |
|
1057 object is less than the second, or; A negative value, if the first object is |
|
1058 greater than the second. |
|
1059 */ |
|
1060 TInt CMTPParserRouter::CMap::BranchOrderFromDescending(const CMap& aL, const CMap& aR) |
|
1061 { |
|
1062 return (aR.iFrom - aL.iFrom); |
|
1063 } |
|
1064 |
|
1065 /** |
|
1066 Implements a map source parameter key identity relation for |
|
1067 @see CMTPParserRouter::CMap branch map objects based on ascending key order. |
|
1068 @param aL The first object instance. |
|
1069 @param aR The second object instance. |
|
1070 @return Zero, if the two objects are equal; A negative value, if the first |
|
1071 object is less than the second, or; A positive value, if the first object is |
|
1072 greater than the second. |
|
1073 */ |
|
1074 TInt CMTPParserRouter::CMap::BranchOrderFromKeyAscending(const TUint* aL, const CMap& aR) |
|
1075 { |
|
1076 return (*aL - aR.iFrom); |
|
1077 } |
|
1078 |
|
1079 /** |
|
1080 Implements a map source parameter key identity relation for |
|
1081 @see CMTPParserRouter::CMap branch map objects based on descending key order. |
|
1082 @param aL The first object instance. |
|
1083 @param aR The second object instance. |
|
1084 @return Zero, if the two objects are equal; A positive value, if the first |
|
1085 object is less than the second, or; A negative value, if the first object is |
|
1086 greater than the second. |
|
1087 */ |
|
1088 TInt CMTPParserRouter::CMap::BranchOrderFromKeyDescending(const TUint* aL, const CMap& aR) |
|
1089 { |
|
1090 return (aR.iFrom - *aL); |
|
1091 } |
|
1092 |
|
1093 /** |
|
1094 Implements an @see TLinearOrder relation for @see CMTPParserRouter::TMap |
|
1095 node map objects based on ascending map source parameter order. |
|
1096 @param aL The first object instance. |
|
1097 @param aR The second object instance. |
|
1098 @return Zero, if the two objects are equal; A negative value, if the first |
|
1099 object is less than the second, or; A positive value, if the first object is |
|
1100 greater than the second. |
|
1101 */ |
|
1102 TInt CMTPParserRouter::CMap::NodeOrderFromAscending(const TMap& aL, const TMap& aR) |
|
1103 { |
|
1104 return (aL.iFrom - aR.iFrom); |
|
1105 } |
|
1106 |
|
1107 /** |
|
1108 Implements an @see TLinearOrder relation for @see CMTPParserRouter::TMap |
|
1109 node map objects based on descending map source parameter order. |
|
1110 @param aL The first object instance. |
|
1111 @param aR The second object instance. |
|
1112 @return Zero, if the two objects are equal; A positive value, if the first |
|
1113 object is less than the second, or; A negative value, if the first object is |
|
1114 greater than the second. |
|
1115 */ |
|
1116 TInt CMTPParserRouter::CMap::NodeOrderFromDescending(const TMap& aL, const TMap& aR) |
|
1117 { |
|
1118 return (aR.iFrom - aL.iFrom); |
|
1119 } |
|
1120 |
|
1121 /** |
|
1122 Implements a map source parameter key identity relation for |
|
1123 @see CMTPParserRouter::TMap node map objects based on ascending key order. |
|
1124 @param aL The first object instance. |
|
1125 @param aR The second object instance. |
|
1126 @return Zero, if the two objects are equal; A negative value, if the first |
|
1127 object is less than the second, or; A positive value, if the first object is |
|
1128 greater than the second. |
|
1129 */ |
|
1130 TInt CMTPParserRouter::CMap::NodeOrderFromKeyAscending(const TUint* aL, const TMap& aR) |
|
1131 { |
|
1132 return (*aL - aR.iFrom); |
|
1133 } |
|
1134 |
|
1135 /** |
|
1136 Implements a map source parameter key identity relation for |
|
1137 @see CMTPParserRouter::TMap node map objects based on descending key order. |
|
1138 @param aL The first object instance. |
|
1139 @param aR The second object instance. |
|
1140 @return Zero, if the two objects are equal; A positive value, if the first |
|
1141 object is less than the second, or; A negative value, if the first object is |
|
1142 greater than the second. |
|
1143 */ |
|
1144 TInt CMTPParserRouter::CMap::NodeOrderFromKeyDescending(const TUint* aL, const TMap& aR) |
|
1145 { |
|
1146 return (aR.iFrom - *aL); |
|
1147 } |
|
1148 |
|
1149 /** |
|
1150 Implements an @see TLinearOrder relation for @see CMTPParserRouter::CMap |
|
1151 branch map objects based on ascending map source and target parameter order. |
|
1152 @param aL The first object instance. |
|
1153 @param aR The second object instance. |
|
1154 @return Zero, if the two objects are equal; A negative value, if the first |
|
1155 object is less than the second, or; A positive value, if the first object is |
|
1156 greater than the second. |
|
1157 */ |
|
1158 TInt CMTPParserRouter::CMap::NodeOrderFromToAscending(const TMap& aL, const TMap& aR) |
|
1159 { |
|
1160 TInt ret(0); |
|
1161 if (aL.iFrom != aR.iFrom) |
|
1162 { |
|
1163 ret = (aL.iFrom - aR.iFrom); |
|
1164 } |
|
1165 else |
|
1166 { |
|
1167 ret = (aL.iTo - aR.iTo); |
|
1168 } |
|
1169 return ret; |
|
1170 } |
|
1171 |
|
1172 /** |
|
1173 Implements an @see TLinearOrder relation for @see CMTPParserRouter::CMap |
|
1174 branch map objects based on descending map source and target parameter order. |
|
1175 @param aL The first object instance. |
|
1176 @param aR The second object instance. |
|
1177 @return Zero, if the two objects are equal; A positive value, if the first |
|
1178 object is less than the second, or; A negative value, if the first object is |
|
1179 greater than the second. |
|
1180 */ |
|
1181 TInt CMTPParserRouter::CMap::NodeOrderFromToDescending(const TMap& aL, const TMap& aR) |
|
1182 { |
|
1183 TInt ret(0); |
|
1184 if (aL.iFrom != aR.iFrom) |
|
1185 { |
|
1186 ret = aR.iFrom - aL.iFrom; |
|
1187 } |
|
1188 else |
|
1189 { |
|
1190 ret = aR.iTo - aL.iTo; |
|
1191 } |
|
1192 return ret; |
|
1193 } |
|
1194 |
|
1195 /** |
|
1196 Constructor. |
|
1197 */ |
|
1198 CMTPParserRouter::CMTPParserRouter() |
|
1199 { |
|
1200 |
|
1201 } |
|
1202 |
|
1203 /** |
|
1204 Second-phase constructor. |
|
1205 */ |
|
1206 void CMTPParserRouter::ConstructL() |
|
1207 { |
|
1208 __FLOG_OPEN(KMTPSubsystem, KComponent); |
|
1209 __FLOG(_L8("ConstructL, Entry")); |
|
1210 iSingletons.OpenL(); |
|
1211 __FLOG(_L8("ConstructL, Exit")); |
|
1212 } |
|
1213 |
|
1214 /** |
|
1215 Provides the set of @see TMTPSupportCategory codes which comprise each of the |
|
1216 lookup parameters for the specified routing sub-type (routing map). |
|
1217 @param aSubType The routing sub-type identifier. |
|
1218 @param aP1Codes On exit, the set of @see TMTPSupportCategory codes which |
|
1219 comprise the first lookup parameter. This set will be empty if the routing |
|
1220 sub-type implements fewer than one parameter. |
|
1221 @param aP2Codes On exit, the set of @see TMTPSupportCategory codes which |
|
1222 comprise the second lookup parameter. This set will be empty if the routing |
|
1223 sub-type implements fewer than two parameters. |
|
1224 @param aP2Codes On exit, the set of @see TMTPSupportCategory codes which |
|
1225 comprise the third lookup parameter. This set will be empty if the routing |
|
1226 sub-type implements fewer than three parameters. |
|
1227 @leave One of the system wide error codes, if a general processing error |
|
1228 occurs. |
|
1229 */ |
|
1230 void CMTPParserRouter::GetMapParameterIdsL(TUint aSubType, RArray<TUint>& aP1Codes, RArray<TUint>& aP2Codes, RArray<TUint>& aP3Codes) |
|
1231 { |
|
1232 aP1Codes.Reset(); |
|
1233 aP2Codes.Reset(); |
|
1234 aP3Codes.Reset(); |
|
1235 |
|
1236 switch (aSubType) |
|
1237 { |
|
1238 case ESubTypeDevicePropCode: |
|
1239 aP1Codes.AppendL(EDeviceProperties); |
|
1240 break; |
|
1241 |
|
1242 case ESubTypeObjectPropCode: |
|
1243 aP1Codes.AppendL(EObjectProperties); |
|
1244 break; |
|
1245 |
|
1246 case ESubTypeOperationCode: |
|
1247 aP1Codes.AppendL(EOperations); |
|
1248 break; |
|
1249 |
|
1250 case ESubTypeStorageType: |
|
1251 aP1Codes.AppendL(EStorageSystemTypes); |
|
1252 break; |
|
1253 |
|
1254 case ESubTypeFormatCodeFormatSubcode: |
|
1255 aP1Codes.AppendL(EObjectCaptureFormats); |
|
1256 aP1Codes.AppendL(EObjectPlaybackFormats); |
|
1257 aP2Codes.AppendL(EAssociationTypes); |
|
1258 break; |
|
1259 |
|
1260 case ESubTypeFormatCodeOperationCode: |
|
1261 aP1Codes.AppendL(EObjectCaptureFormats); |
|
1262 aP1Codes.AppendL(EObjectPlaybackFormats); |
|
1263 aP2Codes.AppendL(EOperations); |
|
1264 break; |
|
1265 |
|
1266 case ESubTypeStorageTypeOperationCode: |
|
1267 aP1Codes.AppendL(EStorageSystemTypes); |
|
1268 aP2Codes.AppendL(EOperations); |
|
1269 break; |
|
1270 |
|
1271 case ESubTypeFormatCodeFormatSubcodeStorageType: |
|
1272 aP1Codes.AppendL(EObjectCaptureFormats); |
|
1273 aP1Codes.AppendL(EObjectPlaybackFormats); |
|
1274 aP2Codes.AppendL(EAssociationTypes); |
|
1275 aP3Codes.AppendL(EStorageSystemTypes); |
|
1276 break; |
|
1277 |
|
1278 case ESubTypeServiceIDOperationCode: |
|
1279 aP1Codes.AppendL(EServiceIDs); |
|
1280 break; |
|
1281 |
|
1282 default: |
|
1283 __DEBUG_ONLY(User::Invariant()); |
|
1284 break; |
|
1285 } |
|
1286 } |
|
1287 |
|
1288 /** |
|
1289 Selects the specified data provider target identifier by appending it to the |
|
1290 set of selected targets. Each target identifier may only appear once in the |
|
1291 set of selected targets. A selected target which is already a member of the |
|
1292 selected set will be replaced to ensure that targets are dispatched in order |
|
1293 of most recent selection. |
|
1294 @param aTarget The data provider target identifier. |
|
1295 @param aTargets The set of selected targets. |
|
1296 @leave One of the system wide error codes, if a general processing error |
|
1297 occurs. |
|
1298 |
|
1299 */ |
|
1300 void CMTPParserRouter::SelectTargetL(TUint aTarget, RArray<TUint>& aTargets) |
|
1301 { |
|
1302 __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("SelectTargetL, Entry")); |
|
1303 TInt idx(aTargets.Find(aTarget)); |
|
1304 if (idx != KErrNotFound) |
|
1305 { |
|
1306 aTargets.Remove(idx); |
|
1307 } |
|
1308 aTargets.AppendL(aTarget); |
|
1309 __FLOG_STATIC(KMTPSubsystem, KComponent, _L8("SelectTargetL, Exit")); |
|
1310 } |
|
1311 |
|
1312 /** |
|
1313 Configures (loads) the specified one lookup parameter routing sub-type map. The |
|
1314 map is constructed by interrogating each data provider in turn and building a |
|
1315 set of map table entries which resolve each supported @see TMTPSupportCategory |
|
1316 code to its data provider (target) identifier. |
|
1317 @param aSubType The routing sub-type identifier. |
|
1318 @param aP1Codes The set of @see TMTPSupportCategory codes which comprise the |
|
1319 first lookup parameter. |
|
1320 @leave One of the system wide error codes, if a general processing error |
|
1321 occurs. |
|
1322 */ |
|
1323 void CMTPParserRouter::Configure1ParameterMapL(TUint aSubType, const RArray<TUint>& aP1Codes) |
|
1324 { |
|
1325 CMap& map(*iMaps[aSubType & ESubTypeIndexMask]); |
|
1326 RArray<TUint> from; |
|
1327 CleanupClosePushL(from); |
|
1328 map.InitParamsL(from); |
|
1329 |
|
1330 const TUint KCount(iSingletons.DpController().Count()); |
|
1331 for (TUint d(0); (d < KCount); d++) |
|
1332 { |
|
1333 CMTPDataProvider& dp(iSingletons.DpController().DataProviderByIndexL(d)); |
|
1334 __FLOG(_L8("")); |
|
1335 __FLOG_VA((_L8("Creating DP %02d Table 0x%08X Entries"), dp.DataProviderId(), aSubType)); |
|
1336 __FLOG(_L8("---------------------------------------")); |
|
1337 |
|
1338 RArray<TUint> p1s; |
|
1339 CleanupClosePushL(p1s); |
|
1340 GetConfigParametersL(dp, aP1Codes, p1s); |
|
1341 const TUint KCountP1s(p1s.Count()); |
|
1342 for (TUint p1(0); (p1 < KCountP1s); p1++) |
|
1343 { |
|
1344 const TUint KP1(p1s[p1]); |
|
1345 from[EParam1] = KP1; |
|
1346 map.InsertL(from, dp.DataProviderId()); |
|
1347 } |
|
1348 CleanupStack::PopAndDestroy(&p1s); |
|
1349 __FLOG(_L8("")); |
|
1350 } |
|
1351 CleanupStack::PopAndDestroy(&from); |
|
1352 } |
|
1353 |
|
1354 /** |
|
1355 Configures (loads) the specified two lookup parameter routing sub-type map. The |
|
1356 map is constructed by interrogating each data provider in turn and building a |
|
1357 set of map table entries which resolve each combination of supported |
|
1358 @see TMTPSupportCategory codes to its data provider (target) identifier. |
|
1359 @param aSubType The routing sub-type identifier. |
|
1360 @param aP1Codes The set of @see TMTPSupportCategory codes which comprise the |
|
1361 first lookup parameter. |
|
1362 @param aP2Codes The set of @see TMTPSupportCategory codes which comprise the |
|
1363 second lookup parameter. |
|
1364 @leave One of the system wide error codes, if a general processing error |
|
1365 occurs. |
|
1366 */ |
|
1367 void CMTPParserRouter::Configure2ParameterMapL(TUint aSubType, const RArray<TUint>& aP1Codes, const RArray<TUint>& aP2Codes) |
|
1368 { |
|
1369 CMap& map(*iMaps[aSubType & ESubTypeIndexMask]); |
|
1370 RArray<TUint> from; |
|
1371 CleanupClosePushL(from); |
|
1372 map.InitParamsL(from); |
|
1373 |
|
1374 const TUint KCountDps(iSingletons.DpController().Count()); |
|
1375 for (TUint d(0); (d < KCountDps); d++) |
|
1376 { |
|
1377 CMTPDataProvider& dp(iSingletons.DpController().DataProviderByIndexL(d)); |
|
1378 __FLOG(_L8("")); |
|
1379 __FLOG_VA((_L8("Creating DP %02d Table 0x%08X Entries"), dp.DataProviderId(), aSubType)); |
|
1380 __FLOG(_L8("---------------------------------------")); |
|
1381 |
|
1382 RArray<TUint> p1s; |
|
1383 CleanupClosePushL(p1s); |
|
1384 GetConfigParametersL(dp, aP1Codes, p1s); |
|
1385 const TUint KCountP1s(p1s.Count()); |
|
1386 for (TUint p1(0); (p1 < KCountP1s); p1++) |
|
1387 { |
|
1388 const TUint KP1(p1s[p1]); |
|
1389 from[EParam1] = KP1; |
|
1390 if ((aSubType == ESubTypeFormatCodeFormatSubcode) && |
|
1391 (KP1 != EMTPFormatCodeAssociation)) |
|
1392 { |
|
1393 from[EParam2] = EMTPAssociationTypeUndefined; |
|
1394 map.InsertL(from, dp.DataProviderId()); |
|
1395 } |
|
1396 else |
|
1397 { |
|
1398 RArray<TUint> p2s; |
|
1399 CleanupClosePushL(p2s); |
|
1400 GetConfigParametersL(dp, aP2Codes, p2s); |
|
1401 const TUint KCountP2s(p2s.Count()); |
|
1402 for (TUint p2(0); (p2 < KCountP2s); p2++) |
|
1403 { |
|
1404 const TUint KP2(p2s[p2]); |
|
1405 from[EParam2] = KP2; |
|
1406 map.InsertL(from, dp.DataProviderId()); |
|
1407 } |
|
1408 CleanupStack::PopAndDestroy(&p2s); |
|
1409 } |
|
1410 } |
|
1411 CleanupStack::PopAndDestroy(&p1s); |
|
1412 __FLOG(_L8("")); |
|
1413 } |
|
1414 CleanupStack::PopAndDestroy(&from); |
|
1415 } |
|
1416 |
|
1417 /** |
|
1418 Configures (loads) the specified three lookup parameter routing sub-type map. |
|
1419 The map is constructed by interrogating each data provider in turn and building |
|
1420 a set of map table entries which resolve each combination of supported |
|
1421 @see TMTPSupportCategory codes to its data provider (target) identifier. |
|
1422 @param aSubType The routing sub-type identifier. |
|
1423 @param aP1Codes The set of @see TMTPSupportCategory codes which comprise the |
|
1424 first lookup parameter. |
|
1425 @param aP2Codes The set of @see TMTPSupportCategory codes which comprise the |
|
1426 second lookup parameter. |
|
1427 @param aP3Codes The set of @see TMTPSupportCategory codes which comprise the |
|
1428 third lookup parameter. |
|
1429 @leave One of the system wide error codes, if a general processing error |
|
1430 occurs. |
|
1431 */ |
|
1432 void CMTPParserRouter::Configure3ParameterMapL(TUint aSubType, const RArray<TUint>& aP1Codes, const RArray<TUint>& aP2Codes, const RArray<TUint>& aP3Codes) |
|
1433 { |
|
1434 CMap& map(*iMaps[aSubType & ESubTypeIndexMask]); |
|
1435 RArray<TUint> from; |
|
1436 CleanupClosePushL(from); |
|
1437 map.InitParamsL(from); |
|
1438 |
|
1439 const TUint KCount(iSingletons.DpController().Count()); |
|
1440 for (TUint d(0); (d < KCount); d++) |
|
1441 { |
|
1442 CMTPDataProvider& dp(iSingletons.DpController().DataProviderByIndexL(d)); |
|
1443 __FLOG(_L8("")); |
|
1444 __FLOG_VA((_L8("Creating DP %02d Table 0x%08X Entries"), dp.DataProviderId(), aSubType)); |
|
1445 __FLOG(_L8("---------------------------------------")); |
|
1446 |
|
1447 RArray<TUint> p1s; |
|
1448 CleanupClosePushL(p1s); |
|
1449 GetConfigParametersL(dp, aP1Codes, p1s); |
|
1450 const TUint KCountP1s(p1s.Count()); |
|
1451 for (TUint p1(0); (p1 < KCountP1s); p1++) |
|
1452 { |
|
1453 RArray<TUint> p3s; |
|
1454 CleanupClosePushL(p3s); |
|
1455 const TUint KP1(p1s[p1]); |
|
1456 from[EParam1] = KP1; |
|
1457 if ((aSubType == ESubTypeFormatCodeFormatSubcodeStorageType) && |
|
1458 (KP1 != EMTPFormatCodeAssociation)) |
|
1459 { |
|
1460 from[EParam2] = EMTPAssociationTypeUndefined; |
|
1461 GetConfigParametersL(dp, aP3Codes, p3s); |
|
1462 const TUint KCountP3s(p3s.Count()); |
|
1463 for (TUint p3(0); (p3 < KCountP3s); p3++) |
|
1464 { |
|
1465 const TUint KP3(p3s[p3]); |
|
1466 from[EParam3] = KP3; |
|
1467 map.InsertL(from, dp.DataProviderId()); |
|
1468 } |
|
1469 } |
|
1470 else |
|
1471 { |
|
1472 RArray<TUint> p2s; |
|
1473 CleanupClosePushL(p2s); |
|
1474 GetConfigParametersL(dp, aP2Codes, p2s); |
|
1475 const TUint KCountP2s(p2s.Count()); |
|
1476 for (TUint p2(0); (p2 < KCountP2s); p2++) |
|
1477 { |
|
1478 const TUint KP2(p2s[p2]); |
|
1479 from[EParam2] = KP2; |
|
1480 GetConfigParametersL(dp, aP3Codes, p3s); |
|
1481 const TUint KCountP3s(p3s.Count()); |
|
1482 for (TUint p3(0); (p3 < KCountP3s); p3++) |
|
1483 { |
|
1484 const TUint KP3(p3s[p3]); |
|
1485 from[EParam3] = KP3; |
|
1486 map.InsertL(from, dp.DataProviderId()); |
|
1487 } |
|
1488 } |
|
1489 CleanupStack::PopAndDestroy(&p2s); |
|
1490 } |
|
1491 CleanupStack::PopAndDestroy(&p3s); |
|
1492 } |
|
1493 CleanupStack::PopAndDestroy(&p1s); |
|
1494 __FLOG(_L8("")); |
|
1495 } |
|
1496 CleanupStack::PopAndDestroy(&from); |
|
1497 } |
|
1498 |
|
1499 /** |
|
1500 Obtains the set of supported @see TMTPSupportCategory code parameter values |
|
1501 supported by the specified data provider. |
|
1502 @param aDp The data provider. |
|
1503 @param aCodes The set of @see TMTPSupportCategory codes which comprise the |
|
1504 parameter. |
|
1505 @param aParams On exit, the set of supported parameter values. |
|
1506 @leave One of the system wide error codes, if a general processing error |
|
1507 occurs. |
|
1508 */ |
|
1509 void CMTPParserRouter::GetConfigParametersL(const CMTPDataProvider& aDp, const RArray<TUint>& aCodes, RArray<TUint>& aParams) const |
|
1510 { |
|
1511 aParams.Reset(); |
|
1512 const TUint KCountCodes(aCodes.Count()); |
|
1513 for (TUint c(0); (c < KCountCodes); c++) |
|
1514 { |
|
1515 const RArray<TUint>& KParams(aDp.SupportedCodes(static_cast<TMTPSupportCategory>(aCodes[c]))); |
|
1516 const TUint KCountParams(KParams.Count()); |
|
1517 for (TUint p(0); (p < KCountParams); p++) |
|
1518 { |
|
1519 if(( EServiceIDs == aCodes[c] )&&( iSingletons.ServiceMgr().IsSupportedService( KParams[p] )) ) |
|
1520 { |
|
1521 __FLOG_1(_L8("GetConfigParametersL, abstract service id = %d"), KParams[p]); |
|
1522 continue; |
|
1523 } |
|
1524 TInt err(aParams.InsertInOrder(KParams[p])); |
|
1525 if ((err != KErrNone) && (err != KErrAlreadyExists)) |
|
1526 { |
|
1527 User::Leave(err); |
|
1528 } |
|
1529 } |
|
1530 } |
|
1531 } |
|
1532 |
|
1533 /** |
|
1534 Provides the set of operation parameter routing and validation sub-types to be |
|
1535 executed against each of the specified operation routing parameter data. |
|
1536 @param aParams The set of operation routing parameter data. |
|
1537 @param aRoutingSubTypes On exit, the set of routing sub-types to be executed. |
|
1538 @param aValidationSubTypes On exit, the set of validation sub-types to be executed. |
|
1539 @leave One of the system wide error codes, if a general processing error |
|
1540 occurs. |
|
1541 */ |
|
1542 void CMTPParserRouter::GetRoutingSubTypesL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const |
|
1543 { |
|
1544 __FLOG(_L8("GetRoutingSubTypesL, Entry")); |
|
1545 __ASSERT_DEBUG((aParams.Count() > 0), User::Invariant()); |
|
1546 aRoutingSubTypes.Reset(); |
|
1547 aValidationSubTypes.Reset(); |
|
1548 |
|
1549 TRoutingParameters& params1(aParams[0]); |
|
1550 if (params1.Param(TRoutingParameters::EFlagInvalid)) |
|
1551 { |
|
1552 SelectSubTypeRoutingL(ESubTypeDpDevice, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1553 } |
|
1554 else |
|
1555 { |
|
1556 const TUint KOpCode(params1.Request().Uint16(TMTPTypeRequest::ERequestOperationCode)); |
|
1557 const TUint KRoutingTypes(params1.Param(TRoutingParameters::EFlagRoutingTypes)); |
|
1558 switch (KOpCode) |
|
1559 { |
|
1560 case EMTPOpCodeGetDeviceInfo: |
|
1561 case EMTPOpCodeOpenSession: |
|
1562 case EMTPOpCodeCloseSession: |
|
1563 case EMTPOpCodeGetStorageIDs: |
|
1564 case EMTPOpCodeGetNumObjects: |
|
1565 case EMTPOpCodeGetObjectHandles: |
|
1566 case EMTPOpCodeFormatStore: |
|
1567 case EMTPOpCodeResetDevice: |
|
1568 case EMTPOpCodeSelfTest: |
|
1569 case EMTPOpCodePowerDown: |
|
1570 if (KRoutingTypes & ETypeFramework) |
|
1571 { |
|
1572 SelectSubTypeRoutingL(ESubTypeDpDevice, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1573 } |
|
1574 break; |
|
1575 |
|
1576 case EMTPOpCodeDeleteObject: |
|
1577 GetRoutingSubTypesDeleteRequestL(aParams, aRoutingSubTypes, aValidationSubTypes); |
|
1578 break; |
|
1579 |
|
1580 case EMTPOpCodeGetObjectPropList: |
|
1581 GetRoutingSubTypesGetObjectPropListRequestL(aParams, aRoutingSubTypes, aValidationSubTypes); |
|
1582 break; |
|
1583 |
|
1584 case EMTPOpCodeSetObjectPropList: |
|
1585 if (KRoutingTypes & ETypeFramework) |
|
1586 { |
|
1587 SelectSubTypeRoutingL(ESubTypeDpProxy, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1588 } |
|
1589 else if (KRoutingTypes & ETypeOperationParameter) |
|
1590 { |
|
1591 SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1592 SelectSubTypeValidationL(ESubTypeObjectPropCode, aValidationSubTypes); |
|
1593 } |
|
1594 break; |
|
1595 |
|
1596 case EMTPOpCodeSendObjectInfo: |
|
1597 if (KRoutingTypes & ETypeFramework) |
|
1598 { |
|
1599 SelectSubTypeRoutingL(ESubTypeDpProxy, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1600 } |
|
1601 else if (KRoutingTypes & ETypeOperationParameter) |
|
1602 { |
|
1603 SelectSubTypeRoutingL(ESubTypeFormatCodeFormatSubcodeStorageType, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1604 } |
|
1605 break; |
|
1606 |
|
1607 case EMTPOpCodeGetDevicePropDesc: |
|
1608 case EMTPOpCodeGetDevicePropValue: |
|
1609 case EMTPOpCodeSetDevicePropValue: |
|
1610 case EMTPOpCodeResetDevicePropValue: |
|
1611 if (KRoutingTypes & ETypeOperationParameter) |
|
1612 { |
|
1613 SelectSubTypeRoutingL(ESubTypeDevicePropCode, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1614 } |
|
1615 break; |
|
1616 |
|
1617 case EMTPOpCodeGetObjectPropsSupported: |
|
1618 if (KRoutingTypes & ETypeOperationParameter) |
|
1619 { |
|
1620 SelectSubTypeRoutingL(ESubTypeFormatCodeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1621 } |
|
1622 break; |
|
1623 |
|
1624 case EMTPOpCodeSkip: |
|
1625 if (KRoutingTypes & ETypeOperationParameter) |
|
1626 { |
|
1627 SelectSubTypeRoutingL(ESubTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1628 params1.SetParam(TRoutingParameters::EFlagRoutingTypes, (KRoutingTypes | ETypeFlagSingleTarget)); |
|
1629 } |
|
1630 break; |
|
1631 |
|
1632 case EMTPOpCodeGetObjectPropDesc: |
|
1633 if (KRoutingTypes & ETypeOperationParameter) |
|
1634 { |
|
1635 SelectSubTypeRoutingL(ESubTypeFormatCodeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1636 SelectSubTypeValidationL(ESubTypeObjectPropCode, aValidationSubTypes); |
|
1637 params1.SetParam(TRoutingParameters::EFlagRoutingTypes, (KRoutingTypes | ETypeFlagSingleTarget)); |
|
1638 } |
|
1639 break; |
|
1640 |
|
1641 case EMTPOpCodeGetInterdependentPropDesc: |
|
1642 if (KRoutingTypes & ETypeOperationParameter) |
|
1643 { |
|
1644 SelectSubTypeRoutingL(ESubTypeFormatCodeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1645 } |
|
1646 break; |
|
1647 |
|
1648 case EMTPOpCodeInitiateCapture: |
|
1649 case EMTPOpCodeInitiateOpenCapture: |
|
1650 if (KRoutingTypes & ETypeOperationParameter) |
|
1651 { |
|
1652 SelectSubTypeRoutingL(ESubTypeFormatCodeFormatSubcodeStorageType, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1653 } |
|
1654 break; |
|
1655 |
|
1656 case EMTPOpCodeSendObjectPropList: |
|
1657 GetRoutingSubTypesSendObjectPropListRequestL(aParams, aRoutingSubTypes, aValidationSubTypes); |
|
1658 break; |
|
1659 |
|
1660 case EMTPOpCodeMoveObject: |
|
1661 case EMTPOpCodeCopyObject: |
|
1662 GetRoutingSubTypesCopyMoveRequestL(aParams, aRoutingSubTypes, aValidationSubTypes); |
|
1663 break; |
|
1664 case EMTPOpCodeGetObjectInfo: |
|
1665 case EMTPOpCodeGetObject: |
|
1666 case EMTPOpCodeGetThumb: |
|
1667 case EMTPOpCodeGetPartialObject: |
|
1668 case EMTPOpCodeGetObjectReferences: |
|
1669 case EMTPOpCodeSetObjectReferences: |
|
1670 case EMTPOpCodeUpdateObjectPropList : |
|
1671 if (KRoutingTypes & ETypeOperationParameter) |
|
1672 { |
|
1673 SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1674 } |
|
1675 break; |
|
1676 |
|
1677 case EMTPOpCodeGetObjectPropValue: |
|
1678 case EMTPOpCodeSetObjectPropValue: |
|
1679 if (KRoutingTypes & ETypeOperationParameter) |
|
1680 { |
|
1681 SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1682 SelectSubTypeValidationL(ESubTypeObjectPropCode, aValidationSubTypes); |
|
1683 } |
|
1684 break; |
|
1685 |
|
1686 case EMTPOpCodeGetStorageInfo: |
|
1687 if (KRoutingTypes & ETypeOperationParameter) |
|
1688 { |
|
1689 SelectSubTypeRoutingL(ESubTypeOwnerStorage, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1690 } |
|
1691 break; |
|
1692 |
|
1693 case EMTPOpCodeSendObject: |
|
1694 case EMTPOpCodeTerminateOpenCapture: |
|
1695 if (KRoutingTypes & ETypeRequestRegistration) |
|
1696 { |
|
1697 SelectSubTypeRoutingL(ESubTypeRequestRegistration, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1698 } |
|
1699 break; |
|
1700 |
|
1701 case EMTPOpCodeGetServiceInfo: |
|
1702 case EMTPOpCodeGetServiceCapabilities: |
|
1703 case EMTPOpCodeGetServicePropDesc: |
|
1704 case EMTPOpCodeGetServicePropList: |
|
1705 case EMTPOpCodeSetServicePropList: |
|
1706 case EMTPOpCodeDeleteServicePropList: |
|
1707 { |
|
1708 if ( iSingletons.ServiceMgr().IsSupportedService( params1.Param(TRoutingParameters::EParamServiceId) ) ) |
|
1709 { |
|
1710 SelectSubTypeRoutingL(ESubTypeDpDevice, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1711 } |
|
1712 else |
|
1713 { |
|
1714 SelectSubTypeRoutingL(ESubTypeServiceIDOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1715 } |
|
1716 } |
|
1717 break; |
|
1718 case EMTPOpCodeDeleteObjectPropList : |
|
1719 { |
|
1720 GetRoutingSubTypesDeleteObjectPropListL( aParams, aRoutingSubTypes, aValidationSubTypes ); |
|
1721 } |
|
1722 break; |
|
1723 case EMTPOpCodeGetFormatCapabilities: |
|
1724 { |
|
1725 GetRoutingSubTypesGetFormatCapabilitiesL(aParams, aRoutingSubTypes, aValidationSubTypes); |
|
1726 } |
|
1727 break; |
|
1728 case EMTPOpCodeSetObjectProtection: |
|
1729 SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1730 break; |
|
1731 default: |
|
1732 if (KRoutingTypes & ETypeRequestRegistration) |
|
1733 { |
|
1734 SelectSubTypeRoutingL(ESubTypeRequestRegistration, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1735 } |
|
1736 if (KRoutingTypes & ETypeFramework) |
|
1737 { |
|
1738 SelectSubTypeRoutingL(ESubTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1739 params1.SetParam(TRoutingParameters::EFlagRoutingTypes, (KRoutingTypes | ETypeFlagSingleTarget)); |
|
1740 } |
|
1741 break; |
|
1742 } |
|
1743 } |
|
1744 __FLOG(_L8("GetRoutingSubTypesL, Exit")); |
|
1745 } |
|
1746 |
|
1747 /** |
|
1748 Provides the set of operation parameter routing and validation sub-types to be |
|
1749 executed against each of the specified MTP DeleteObject operation routing |
|
1750 parameter data. |
|
1751 @param aParams The set of operation routing parameter data. |
|
1752 @param aRoutingSubTypes On exit, the set of routing sub-types to be executed. |
|
1753 @param aValidationSubTypes On exit, the set of validation sub-types to be executed. |
|
1754 @leave One of the system wide error codes, if a general processing error |
|
1755 occurs. |
|
1756 */ |
|
1757 void CMTPParserRouter::GetRoutingSubTypesDeleteRequestL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const |
|
1758 { |
|
1759 __FLOG(_L8("GetRoutingSubTypesDeleteRequestL, Entry")); |
|
1760 TRoutingParameters& params1(aParams[0]); |
|
1761 __ASSERT_DEBUG((params1.Request().Uint16(TMTPTypeRequest::ERequestOperationCode) == EMTPOpCodeDeleteObject), User::Invariant()); |
|
1762 |
|
1763 const TUint KObjectHandle(params1.Param(TRoutingParameters::EParamObjectHandle)); |
|
1764 const TUint KObjectFormatCode(params1.Param(TRoutingParameters::EParamFormatCode)); |
|
1765 if (KObjectHandle == KMTPHandleAll) |
|
1766 { |
|
1767 if (KObjectFormatCode == KMTPFormatsAll || KObjectFormatCode == EMTPFormatCodeAssociation) |
|
1768 { |
|
1769 /* |
|
1770 Deleting all objects of all formats. Force the format to |
|
1771 Association to ensure that objects are deleted in the correct |
|
1772 order. |
|
1773 */ |
|
1774 if (KObjectFormatCode == KMTPFormatsAll) |
|
1775 { |
|
1776 params1.SetParam(TRoutingParameters::EParamFormatCode, EMTPFormatCodeAssociation); |
|
1777 } |
|
1778 SelectSubTypeRoutingL(ESubTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1779 } |
|
1780 else if ( KObjectFormatCode == EMTPFormatCodeUndefined ) |
|
1781 { |
|
1782 SelectSubTypeRoutingL(ESubTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1783 } |
|
1784 SelectSubTypeRoutingL(ESubTypeFormatCodeFormatSubcode, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1785 } |
|
1786 else if (KObjectHandle != KMTPHandleNone) |
|
1787 { |
|
1788 if (KObjectFormatCode == EMTPFormatCodeAssociation) |
|
1789 { |
|
1790 SelectSubTypeRoutingL(ESubTypeStorageTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1791 } |
|
1792 SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1793 } |
|
1794 __FLOG(_L8("GetRoutingSubTypesDeleteRequestL, Exit")); |
|
1795 } |
|
1796 |
|
1797 /** |
|
1798 Provides the set of operation parameter routing and validation sub-types to be |
|
1799 executed against each of the specified MTP CopyObject and MoveObject operation routing |
|
1800 parameter data. |
|
1801 @param aParams The set of operation routing parameter data. |
|
1802 @param aRoutingSubTypes On exit, the set of routing sub-types to be executed. |
|
1803 @param aValidationSubTypes On exit, the set of validation sub-types to be executed. |
|
1804 @leave One of the system wide error codes, if a general processing error |
|
1805 occurs. |
|
1806 */ |
|
1807 void CMTPParserRouter::GetRoutingSubTypesCopyMoveRequestL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const |
|
1808 { |
|
1809 __FLOG(_L8("GetRoutingSubTypesCopyMoveRequestL, Entry")); |
|
1810 const TUint KObjectFormatCode(aParams[0].Param(TRoutingParameters::EParamFormatCode)); |
|
1811 if (KObjectFormatCode == EMTPFormatCodeAssociation) |
|
1812 { |
|
1813 SelectSubTypeRoutingL(ESubTypeStorageTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1814 } |
|
1815 else |
|
1816 { |
|
1817 SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1818 } |
|
1819 __FLOG(_L8("GetRoutingSubTypesCopyMoveRequestL, Exit")); |
|
1820 } |
|
1821 /** |
|
1822 Provides the set of operation parameter routing and validation sub-types to be |
|
1823 executed against each of the specified MTP GetObjectPropList operation routing |
|
1824 parameter data. |
|
1825 @param aParams The set of operation routing parameter data. |
|
1826 @param aRoutingSubTypes On exit, the set of routing sub-types to be executed. |
|
1827 @param aValidationSubTypes On exit, the set of validation sub-types to be executed. |
|
1828 @leave One of the system wide error codes, if a general processing error |
|
1829 occurs. |
|
1830 */ |
|
1831 void CMTPParserRouter::GetRoutingSubTypesGetObjectPropListRequestL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const |
|
1832 { |
|
1833 __FLOG(_L8("GetRoutingSubTypesGetObjectPropListRequestL, Entry")); |
|
1834 TRoutingParameters& params1(aParams[0]); |
|
1835 __ASSERT_DEBUG((params1.Request().Uint16(TMTPTypeRequest::ERequestOperationCode) == EMTPOpCodeGetObjectPropList), User::Invariant()); |
|
1836 if (params1.Param(TRoutingParameters::EFlagRoutingTypes) & ETypeOperationParameter) |
|
1837 { |
|
1838 const TUint KObjectHandle(params1.Param(TRoutingParameters::EParamObjectHandle)); |
|
1839 const TUint KObjectFormatCode(params1.Param(TRoutingParameters::EParamFormatCode)); |
|
1840 const TUint KObjectFormatSubCode(params1.Param(TRoutingParameters::EParamFormatSubCode)); |
|
1841 const TUint KObjectPropCode(params1.Param(TRoutingParameters::EParamObjectPropCode)); |
|
1842 if ((KObjectHandle == KMTPHandleAll) || |
|
1843 (KObjectHandle == KMTPHandleAllRootLevel)) |
|
1844 { |
|
1845 // All objects or all root level objects. |
|
1846 if (KObjectFormatCode == KMTPFormatsAll) |
|
1847 { |
|
1848 SelectSubTypeRoutingL(ESubTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1849 } |
|
1850 else |
|
1851 { |
|
1852 SelectSubTypeRoutingL(ESubTypeFormatCodeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1853 } |
|
1854 } |
|
1855 else if (KObjectHandle != KMTPHandleNone) |
|
1856 { |
|
1857 if( (KObjectFormatCode == EMTPFormatCodeAssociation) && (KObjectFormatSubCode == EMTPAssociationTypeGenericFolder) ) |
|
1858 { |
|
1859 if ( params1.Param(TRoutingParameters::EFlagRoutingTypes) & ETypeFramework ) |
|
1860 { |
|
1861 SelectSubTypeRoutingL(ESubTypeDpProxy, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1862 } |
|
1863 else |
|
1864 { |
|
1865 SelectSubTypeRoutingL(ESubTypeStorageTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1866 SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1867 } |
|
1868 } |
|
1869 else |
|
1870 { |
|
1871 SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1872 } |
|
1873 } |
|
1874 |
|
1875 |
|
1876 if (KObjectPropCode != KMTPObjectPropCodeAll) |
|
1877 { |
|
1878 SelectSubTypeValidationL(ESubTypeObjectPropCode, aValidationSubTypes); |
|
1879 } |
|
1880 } |
|
1881 __FLOG(_L8("GetRoutingSubTypesGetObjectPropListRequestL, Exit")); |
|
1882 } |
|
1883 |
|
1884 /** |
|
1885 Provides the set of operation parameter routing and validation sub-types to be |
|
1886 executed against each of the specified MTP SendObjectPropList operation routing |
|
1887 parameter data. |
|
1888 @param aParams The set of operation routing parameter data. |
|
1889 @param aRoutingSubTypes On exit, the set of routing sub-types to be executed. |
|
1890 @param aValidationSubTypes On exit, the set of validation sub-types to be executed. |
|
1891 @leave One of the system wide error codes, if a general processing error |
|
1892 occurs. |
|
1893 */ |
|
1894 void CMTPParserRouter::GetRoutingSubTypesSendObjectPropListRequestL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const |
|
1895 { |
|
1896 __FLOG(_L8("GetRoutingSubTypesSendObjectPropListRequestL, Entry")); |
|
1897 TRoutingParameters& params1(aParams[0]); |
|
1898 __ASSERT_DEBUG((params1.Request().Uint16(TMTPTypeRequest::ERequestOperationCode) == EMTPOpCodeSendObjectPropList), User::Invariant()); |
|
1899 const TUint KRoutingTypes(params1.Param(TRoutingParameters::EFlagRoutingTypes)); |
|
1900 if ((KRoutingTypes & ETypeFramework) && |
|
1901 (params1.Param(TRoutingParameters::EParamFormatCode) == EMTPFormatCodeAssociation)) |
|
1902 { |
|
1903 SelectSubTypeRoutingL(ESubTypeDpProxy, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1904 } |
|
1905 else if (KRoutingTypes & ETypeOperationParameter) |
|
1906 { |
|
1907 SelectSubTypeRoutingL(ESubTypeFormatCodeFormatSubcodeStorageType, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1908 } |
|
1909 __FLOG(_L8("GetRoutingSubTypesSendObjectPropListRequestL, Exit")); |
|
1910 } |
|
1911 |
|
1912 void CMTPParserRouter::GetRoutingSubTypesDeleteObjectPropListL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const |
|
1913 { |
|
1914 __FLOG(_L8("GetRoutingSubTypesDeleteObjectPropListL, Entry")); |
|
1915 TRoutingParameters& params1(aParams[0]); |
|
1916 |
|
1917 __ASSERT_DEBUG((params1.Request().Uint16(TMTPTypeRequest::ERequestOperationCode) == EMTPOpCodeDeleteObjectPropList), User::Invariant()); |
|
1918 |
|
1919 const TUint KObjectHandle(params1.Param(TRoutingParameters::EParamObjectHandle)); |
|
1920 if ((KObjectHandle == KMTPHandleAll) || (KObjectHandle == KMTPHandleNone)) |
|
1921 { |
|
1922 SelectSubTypeRoutingL(ESubTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1923 } |
|
1924 else |
|
1925 { |
|
1926 SelectSubTypeRoutingL(ESubTypeOwnerObject, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1927 } |
|
1928 |
|
1929 __FLOG(_L8("GetRoutingSubTypesDeleteObjectPropListL, Exit")); |
|
1930 } |
|
1931 |
|
1932 void CMTPParserRouter::GetRoutingSubTypesGetFormatCapabilitiesL(RArray<TRoutingParameters>& aParams, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes) const |
|
1933 { |
|
1934 __FLOG(_L8("GetRoutingSubTypesGetFormatCapabilities, Entry")); |
|
1935 TRoutingParameters& params1(aParams[0]); |
|
1936 |
|
1937 __ASSERT_DEBUG((params1.Request().Uint16(TMTPTypeRequest::ERequestOperationCode) == EMTPOpCodeGetFormatCapabilities), User::Invariant()); |
|
1938 |
|
1939 if( params1.Param(TRoutingParameters::EParamFormatCode) == KMTPFormatsAll) |
|
1940 { |
|
1941 SelectSubTypeRoutingL(ESubTypeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1942 } |
|
1943 else if ( params1.Param(TRoutingParameters::EFlagRoutingTypes) & ETypeOperationParameter) |
|
1944 { |
|
1945 SelectSubTypeRoutingL(ESubTypeFormatCodeOperationCode, aRoutingSubTypes, aValidationSubTypes, aParams); |
|
1946 } |
|
1947 |
|
1948 __FLOG(_L8("GetRoutingSubTypesGetFormatCapabilities, Exit")); |
|
1949 } |
|
1950 |
|
1951 /** |
|
1952 Parses the specified MTP operation request dataset to extract the specified |
|
1953 parameter value together with any applicable meta-data. The parameter value |
|
1954 will be extracted only if not null (0x00000000). |
|
1955 @param aParam The operation request dataset parameter identifier. |
|
1956 @param aType The operation request dataset parameter type. |
|
1957 @param aParams The operation routing parameter data, updated on exit with the |
|
1958 parameter value together with any associated meta-data. |
|
1959 @leave One of the system wide error codes, if a general processing error |
|
1960 occurs. |
|
1961 */ |
|
1962 void CMTPParserRouter::ParseOperationRequestParameterL(TMTPTypeRequest::TElements aParam, TRoutingParameters::TParameterType aType, TRoutingParameters& aParams) const |
|
1963 { |
|
1964 __FLOG(_L8("ParseOperationRequestParameterL, Entry")); |
|
1965 const TUint32 KParam(aParams.Request().Uint32(aParam)); |
|
1966 __FLOG_VA((_L8("Parameter %d = 0x%08X"), (aParam - TMTPTypeRequest::ERequestParameter1 + 1), KParam)); |
|
1967 |
|
1968 // Parse out the parameter value if a non-null value is present. |
|
1969 if (KParam != KMTPNotSpecified32) |
|
1970 { |
|
1971 aParams.SetParam(aType, KParam); |
|
1972 } |
|
1973 |
|
1974 // Extract any applicable meta-data. |
|
1975 switch (aType) |
|
1976 { |
|
1977 case TRoutingParameters::EParamStorageId: |
|
1978 { |
|
1979 CMTPStorageMgr& storages(iSingletons.StorageMgr()); |
|
1980 if (KParam == KMTPStorageDefault) |
|
1981 { |
|
1982 aParams.SetParam(TRoutingParameters::EParamStorageSystemType, storages.StorageL(storages.DefaultStorageId()).Uint(CMTPStorageMetaData::EStorageSystemType)); |
|
1983 } |
|
1984 else if (storages.ValidStorageId(KParam)) |
|
1985 { |
|
1986 aParams.SetParam(TRoutingParameters::EParamStorageSystemType, storages.StorageL(KParam).Uint(CMTPStorageMetaData::EStorageSystemType)); |
|
1987 } |
|
1988 else |
|
1989 { |
|
1990 aParams.SetParam(TRoutingParameters::EFlagInvalid, ETrue); |
|
1991 } |
|
1992 } |
|
1993 break; |
|
1994 |
|
1995 case TRoutingParameters::EParamObjectHandle: |
|
1996 if ((KParam != KMTPHandleAll) && (KParam != KMTPHandleAllRootLevel)) |
|
1997 { |
|
1998 CMTPObjectMetaData* obj(CMTPObjectMetaData::NewLC()); |
|
1999 if (!iSingletons.ObjectMgr().ObjectL(aParams.Param(CMTPParserRouter::TRoutingParameters::EParamObjectHandle), *obj)) |
|
2000 { |
|
2001 // Object does not exist. |
|
2002 aParams.SetParam(TRoutingParameters::EFlagInvalid, ETrue); |
|
2003 } |
|
2004 else |
|
2005 { |
|
2006 aParams.SetParam(CMTPParserRouter::TRoutingParameters::EParamFormatCode, obj->Uint(CMTPObjectMetaData::EFormatCode)); |
|
2007 aParams.SetParam(CMTPParserRouter::TRoutingParameters::EParamFormatSubCode, obj->Uint(CMTPObjectMetaData::EFormatSubCode)); |
|
2008 aParams.SetParam(CMTPParserRouter::TRoutingParameters::EParamStorageSystemType, iSingletons.StorageMgr().StorageL(obj->Uint(CMTPObjectMetaData::EStorageId)).Uint(CMTPStorageMetaData::EStorageSystemType)); |
|
2009 } |
|
2010 CleanupStack::PopAndDestroy(obj); |
|
2011 } |
|
2012 break; |
|
2013 |
|
2014 default: |
|
2015 break; |
|
2016 } |
|
2017 __FLOG(_L8("ParseOperationRequestParameterL, Exit")); |
|
2018 } |
|
2019 |
|
2020 /** |
|
2021 Resolves set of zero or more routing targets using the specified lookup |
|
2022 parameter based routing sub-type. |
|
2023 @param aRoutingSubType The routing sub-type. |
|
2024 @param aParams The operation routing parameter data. |
|
2025 @param aTargets On exit, the seto of resolved routing targets. |
|
2026 @leave One of the system wide error codes, if a general processing error |
|
2027 occurs. |
|
2028 */ |
|
2029 void CMTPParserRouter::RouteOperationRequestNParametersL(TUint aRoutingSubType, const TRoutingParameters& aParams, RArray<TUint>& aTargets) const |
|
2030 { |
|
2031 __FLOG(_L8("RouteOperationRequestNParametersL, Entry")); |
|
2032 __FLOG_VA((_L8("Routing Sub-type = 0x%08X"), aRoutingSubType)); |
|
2033 |
|
2034 // Build the set of map source parameter values. |
|
2035 RArray<TUint> from; |
|
2036 CleanupClosePushL(from); |
|
2037 switch (aRoutingSubType) |
|
2038 { |
|
2039 case ESubTypeDevicePropCode: |
|
2040 from.AppendL(aParams.Param(TRoutingParameters::EParamDevicePropCode)); |
|
2041 break; |
|
2042 |
|
2043 case ESubTypeObjectPropCode: |
|
2044 from.AppendL(aParams.Param(TRoutingParameters::EParamObjectPropCode)); |
|
2045 break; |
|
2046 |
|
2047 case ESubTypeOperationCode: |
|
2048 from.AppendL(aParams.Request().Uint16(TMTPTypeRequest::ERequestOperationCode)); |
|
2049 break; |
|
2050 |
|
2051 case ESubTypeStorageType: |
|
2052 from.AppendL(aParams.Param(TRoutingParameters::EParamStorageSystemType)); |
|
2053 break; |
|
2054 |
|
2055 case ESubTypeFormatCodeFormatSubcode: |
|
2056 from.AppendL(aParams.Param(TRoutingParameters::EParamFormatCode)); |
|
2057 from.AppendL(aParams.Param(TRoutingParameters::EParamFormatSubCode)); |
|
2058 break; |
|
2059 |
|
2060 case ESubTypeFormatCodeOperationCode: |
|
2061 from.AppendL(aParams.Param(TRoutingParameters::EParamFormatCode)); |
|
2062 from.AppendL(aParams.Request().Uint16(TMTPTypeRequest::ERequestOperationCode)); |
|
2063 break; |
|
2064 |
|
2065 case ESubTypeStorageTypeOperationCode: |
|
2066 from.AppendL(aParams.Param(TRoutingParameters::EParamStorageSystemType)); |
|
2067 from.AppendL(aParams.Request().Uint16(TMTPTypeRequest::ERequestOperationCode)); |
|
2068 break; |
|
2069 |
|
2070 case ESubTypeFormatCodeFormatSubcodeStorageType: |
|
2071 from.AppendL(aParams.Param(TRoutingParameters::EParamFormatCode)); |
|
2072 from.AppendL(aParams.Param(TRoutingParameters::EParamFormatSubCode)); |
|
2073 from.AppendL(aParams.Param(TRoutingParameters::EParamStorageSystemType)); |
|
2074 break; |
|
2075 case ESubTypeServiceIDOperationCode : |
|
2076 { |
|
2077 from.AppendL(aParams.Param(TRoutingParameters::EParamServiceId)); |
|
2078 } |
|
2079 break; |
|
2080 |
|
2081 default: |
|
2082 __DEBUG_ONLY(User::Invariant()); |
|
2083 break; |
|
2084 } |
|
2085 |
|
2086 // Resolve the map target parameter set. |
|
2087 iMaps[Index(aRoutingSubType)]->GetToL(from, aTargets); |
|
2088 CleanupStack::PopAndDestroy(&from); |
|
2089 __FLOG(_L8("RouteOperationRequestNParametersL, Exit")); |
|
2090 } |
|
2091 |
|
2092 /** |
|
2093 Resolves set of zero or more routing targets using the specified parameterless |
|
2094 routing sub-type. |
|
2095 @param aRoutingSubType The routing sub-type. |
|
2096 @param aParams The operation routing parameter data. |
|
2097 @param aTargets On exit, the seto of resolved routing targets. |
|
2098 @leave One of the system wide error codes, if a general processing error |
|
2099 occurs. |
|
2100 */ |
|
2101 void CMTPParserRouter::RouteOperationRequest0ParametersL(TUint aRoutingSubType, const TRoutingParameters& aParams, RArray<TUint>& aTargets) const |
|
2102 { |
|
2103 __FLOG(_L8("RouteOperationRequest0ParametersL, Entry")); |
|
2104 __FLOG_VA((_L8("Routing Sub-type = 0x%08X"), aRoutingSubType)); |
|
2105 TInt id(KErrNotFound); |
|
2106 switch (aRoutingSubType) |
|
2107 { |
|
2108 case ESubTypeDpDevice: |
|
2109 id = iSingletons.DpController().DeviceDpId(); |
|
2110 break; |
|
2111 |
|
2112 case ESubTypeDpProxy: |
|
2113 id = iSingletons.DpController().ProxyDpId(); |
|
2114 break; |
|
2115 |
|
2116 case ESubTypeOwnerObject: |
|
2117 id = iSingletons.ObjectMgr().ObjectOwnerId(aParams.Param(TRoutingParameters::EParamObjectHandle)); |
|
2118 if ( EMTPOpCodeSetObjectProtection == aParams.Request().Uint16(TMTPTypeRequest::ERequestOperationCode)) |
|
2119 { |
|
2120 if ( (EMTPFormatCodeScript!=aParams.Param(TRoutingParameters::EParamFormatCode)) && (EMTPFormatCodeEXIFJPEG!=aParams.Param(TRoutingParameters::EParamFormatCode)) ) |
|
2121 { |
|
2122 id = iSingletons.DpController().FileDpId(); |
|
2123 } |
|
2124 } |
|
2125 break; |
|
2126 |
|
2127 case ESubTypeOwnerStorage: |
|
2128 { |
|
2129 CMTPStorageMgr& storages(iSingletons.StorageMgr()); |
|
2130 const TUint KStorageId(aParams.Param(TRoutingParameters::EParamStorageId)); |
|
2131 if (storages.LogicalStorageId(KStorageId)) |
|
2132 { |
|
2133 id = storages.LogicalStorageOwner(KStorageId); |
|
2134 } |
|
2135 else |
|
2136 { |
|
2137 id = storages.PhysicalStorageOwner(KStorageId); |
|
2138 } |
|
2139 } |
|
2140 break; |
|
2141 |
|
2142 case ESubTypeRequestRegistration: |
|
2143 { |
|
2144 CMTPSession& session(static_cast<CMTPSession&>(aParams.Connection().SessionWithMTPIdL(aParams.Request().Uint32(TMTPTypeRequest::ERequestSessionID)))); |
|
2145 id = session.RouteRequest(aParams.Request()); |
|
2146 } |
|
2147 break; |
|
2148 |
|
2149 default: |
|
2150 __DEBUG_ONLY(User::Invariant()); |
|
2151 break; |
|
2152 } |
|
2153 |
|
2154 if (id != KErrNotFound && iSingletons.DpController().IsDataProviderLoaded(id)) |
|
2155 { |
|
2156 SelectTargetL(id, aTargets); |
|
2157 } |
|
2158 __FLOG(_L8("RouteOperationRequest0ParametersL, Exit")); |
|
2159 } |
|
2160 |
|
2161 /** |
|
2162 Provides a single suitable routing target for the specified request. A target |
|
2163 is selected such that: |
|
2164 |
|
2165 1. Any request that resolves to multiple targets will always be directed |
|
2166 to the proxy data provider. |
|
2167 2. Any request that cannot be resolved to at least one target will always |
|
2168 be directed to the device data provider. |
|
2169 |
|
2170 @param aRequest The operation request dataset of the MTP operation to be |
|
2171 routed. |
|
2172 @param aConnection The MTP connection on which the operation request is being |
|
2173 processed. |
|
2174 @leave One of the system wide error codes, if a general processing error |
|
2175 occurs. |
|
2176 */ |
|
2177 TUint CMTPParserRouter::RoutingTargetL(const TMTPTypeRequest& aRequest, CMTPConnection& aConnection) const |
|
2178 { |
|
2179 __FLOG(_L8("RoutingTargetL, Entry")); |
|
2180 // Parse the operation request dataset. |
|
2181 TRoutingParameters params(aRequest, static_cast<MMTPConnection&>(aConnection)); |
|
2182 ParseOperationRequestL(params); |
|
2183 |
|
2184 // Route the operation request. |
|
2185 RArray<TUint> targets; |
|
2186 CleanupClosePushL(targets); |
|
2187 params.SetParam(TRoutingParameters::EFlagRoutingTypes, (ETypeFramework | ETypeOperationParameter | ETypeRequestRegistration)); |
|
2188 RouteOperationRequestL(params, targets); |
|
2189 |
|
2190 // Dispatch the operation request. |
|
2191 TUint target(0); |
|
2192 if (targets.Count() > 1) |
|
2193 { |
|
2194 target = iSingletons.DpController().ProxyDpId(); |
|
2195 } |
|
2196 else |
|
2197 { |
|
2198 target = targets[0]; |
|
2199 } |
|
2200 CleanupStack::PopAndDestroy(&targets); |
|
2201 __FLOG(_L8("RoutingTargetL, Exit")); |
|
2202 return target; |
|
2203 } |
|
2204 |
|
2205 /** |
|
2206 Selects the specified routing sub-type together with any applicable validation |
|
2207 sub-types. |
|
2208 @param aSubType The selected routing sub-type. |
|
2209 @param aRoutingSubTypes The set of selected routing sub-types, updated on exit. |
|
2210 @param aValidationSubTypes The set of selected validation sub-types, |
|
2211 potentially updated on exit. |
|
2212 @param aParams The set of operation routing parameter data. |
|
2213 @leave One of the system wide error codes, if a general processing error |
|
2214 occurs. |
|
2215 */ |
|
2216 void CMTPParserRouter::SelectSubTypeRoutingL(TRoutingSubType aSubType, RArray<TUint>& aRoutingSubTypes, RArray<TUint>& aValidationSubTypes, RArray<TRoutingParameters>& aParams) const |
|
2217 { |
|
2218 __FLOG(_L8("SelectSubTypeRoutingL, Entry")); |
|
2219 __ASSERT_DEBUG((aRoutingSubTypes.Find(aSubType) == KErrNotFound), User::Invariant()); |
|
2220 aRoutingSubTypes.AppendL(aSubType); |
|
2221 switch (aSubType) |
|
2222 { |
|
2223 case ESubTypeDevicePropCode: |
|
2224 case ESubTypeObjectPropCode: |
|
2225 case ESubTypeStorageType: |
|
2226 case ESubTypeOwnerObject: |
|
2227 case ESubTypeOwnerStorage: |
|
2228 SelectSubTypeValidationL(ESubTypeOperationCode, aValidationSubTypes); |
|
2229 break; |
|
2230 |
|
2231 case ESubTypeFormatCodeFormatSubcode: |
|
2232 case ESubTypeFormatCodeOperationCode: |
|
2233 case ESubTypeFormatCodeFormatSubcodeStorageType: |
|
2234 { |
|
2235 TRoutingParameters params2(aParams[0]); |
|
2236 params2.SetParam(TRoutingParameters::EParamFormatCode, EMTPFormatCodeUndefined); |
|
2237 aParams.AppendL(params2); |
|
2238 SelectSubTypeValidationL(ESubTypeOperationCode, aValidationSubTypes); |
|
2239 } |
|
2240 break; |
|
2241 |
|
2242 case ESubTypeRequestRegistration: |
|
2243 default: |
|
2244 break; |
|
2245 } |
|
2246 __FLOG(_L8("SelectSubTypeRoutingL, Exit")); |
|
2247 } |
|
2248 |
|
2249 /** |
|
2250 Selects the specified validation sub-type. |
|
2251 @param aSubType The selected validation sub-type. |
|
2252 @param aValidationSubTypes The set of selected validation sub-types, updated |
|
2253 on exit. |
|
2254 @leave One of the system wide error codes, if a general processing error |
|
2255 occurs. |
|
2256 */ |
|
2257 void CMTPParserRouter::SelectSubTypeValidationL(TRoutingSubType aSubType, RArray<TUint>& aValidationSubTypes) const |
|
2258 { |
|
2259 __FLOG(_L8("SelectSubTypeValidationL, Entry")); |
|
2260 TInt err(aValidationSubTypes.InsertInOrder(aSubType)); |
|
2261 if ((err != KErrNone) && |
|
2262 (err != KErrAlreadyExists)) |
|
2263 { |
|
2264 User::Leave(err); |
|
2265 } |
|
2266 __FLOG(_L8("SelectSubTypeValidationL, Exit")); |
|
2267 } |
|
2268 |
|
2269 /** |
|
2270 Validates the specified set of routing targets. |
|
2271 @param aParams The operation routing parameter data. |
|
2272 @param aValidationSubTypes The set of validation sub-types. |
|
2273 @param aTargets The set of data provider targets to be validated. Invalid |
|
2274 targets are removed from this set. |
|
2275 */ |
|
2276 void CMTPParserRouter::ValidateTargetsL(const TRoutingParameters& aParams, const RArray<TUint>& aValidationSubTypes, RArray<TUint>& aTargets) const |
|
2277 { |
|
2278 __FLOG(_L8("ValidateTargetsL, Entry")); |
|
2279 const TUint KValidationsCount(aValidationSubTypes.Count()); |
|
2280 for (TUint v(0); (v < KValidationsCount); v++) |
|
2281 { |
|
2282 RArray<TUint> valid; |
|
2283 CleanupClosePushL(valid); |
|
2284 RouteOperationRequestNParametersL(aValidationSubTypes[v], aParams, valid); |
|
2285 valid.Sort(); |
|
2286 TUint target(aTargets.Count()); |
|
2287 while (target--) |
|
2288 { |
|
2289 if (valid.FindInOrder(aTargets[target]) == KErrNotFound) |
|
2290 { |
|
2291 aTargets.Remove(target); |
|
2292 } |
|
2293 } |
|
2294 CleanupStack::PopAndDestroy(&valid); |
|
2295 } |
|
2296 __FLOG(_L8("ValidateTargetsL, Exit")); |
|
2297 } |
|
2298 |
|
2299 /** |
|
2300 Provides the routing sub-type modifier flags of the specified routing sub-type. |
|
2301 @param aSubType The routing sub-type identifier. |
|
2302 @return The routing sub-type modifier flags. |
|
2303 */ |
|
2304 TUint CMTPParserRouter::Flags(TUint aSubType) |
|
2305 { |
|
2306 return (aSubType & ESubTypeFlagMask); |
|
2307 } |
|
2308 |
|
2309 /** |
|
2310 Provides the routing sub-type (map) index of the specified routing sub-type. |
|
2311 @param aSubType The routing sub-type identifier. |
|
2312 @return The routing sub-type (map) index. |
|
2313 */ |
|
2314 TUint CMTPParserRouter::Index(TUint aSubType) |
|
2315 { |
|
2316 return (aSubType & ESubTypeIndexMask); |
|
2317 } |
|
2318 |
|
2319 /** |
|
2320 Provides the routing sub-type parameter count type of the specified routing |
|
2321 sub-type. |
|
2322 @param aSubType The routing sub-type identifier. |
|
2323 @return The routing sub-type parameter count type. |
|
2324 */ |
|
2325 TUint CMTPParserRouter::Params(TUint aSubType) |
|
2326 { |
|
2327 return (aSubType & ESubTypeParamsMask); |
|
2328 } |
|
2329 |
|
2330 /** |
|
2331 Provides the routing sub-type parameter count of the specified routing |
|
2332 sub-type. |
|
2333 @param aSubType The routing sub-type identifier. |
|
2334 @return The routing sub-type parameter count. |
|
2335 */ |
|
2336 TUint CMTPParserRouter::ParamsCount(TUint aSubType) |
|
2337 { |
|
2338 return (Params(aSubType) >> 24); |
|
2339 } |
|
2340 |
|
2341 /** |
|
2342 Encodes a routing sub-type identifier using the specified sub-field values. |
|
2343 @param aIndex The routing sub-type (map) index. |
|
2344 @param aFlags The routing sub-type modifier flags. |
|
2345 @param aParamsCount The routing sub-type parameter count. |
|
2346 */ |
|
2347 TUint CMTPParserRouter::SubType(TUint aIndex, TUint aFlags, TUint aParamsCount) |
|
2348 { |
|
2349 return ((aParamsCount << 24) | aFlags | aIndex); |
|
2350 } |
|
2351 |
|
2352 #ifdef __FLOG_ACTIVE |
|
2353 /** |
|
2354 Logs the map table entries of all map tables. |
|
2355 @leave One of the system wide error codes, if a general processing error |
|
2356 occurs. |
|
2357 */ |
|
2358 void CMTPParserRouter::FLOGMapsL() const |
|
2359 { |
|
2360 __FLOG(_L8("FLOGMapsL, Entry")); |
|
2361 const TUint KCount(iMaps.Count()); |
|
2362 for (TUint i(0); (i < KCount); i++) |
|
2363 { |
|
2364 const CMap& KMap (*iMaps[i]); |
|
2365 __FLOG(_L8("")); |
|
2366 __FLOG_VA((_L8("Table 0x%08X"), KMap.SubType())); |
|
2367 __FLOG(_L8("----------------")); |
|
2368 RArray<TUint> from; |
|
2369 CleanupClosePushL(from); |
|
2370 KMap.InitParamsL(from); |
|
2371 KMap.FLOGMapL(from); |
|
2372 CleanupStack::PopAndDestroy(&from); |
|
2373 __FLOG(_L8("")); |
|
2374 } |
|
2375 __FLOG(_L8("FLOGMapsL, Exit")); |
|
2376 } |
|
2377 #endif |