|
1 /** |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: CUpnpTmFilteredAppList class implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "upnptmfilteredapplist.h" |
|
19 #include "upnptmserverimpl.h" |
|
20 #include "OstTraceDefinitions.h" |
|
21 #ifdef OST_TRACE_COMPILER_IN_USE |
|
22 #include "upnptmfilteredapplistTraces.h" |
|
23 #endif |
|
24 |
|
25 //Constants |
|
26 const TUint KQuote = '"'; |
|
27 const TUint KCommaSeparator = ','; |
|
28 |
|
29 //Literals |
|
30 _LIT8(KDoubleQuote, "\"\""); |
|
31 _LIT8(KIconElement, "icon"); |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS =================================== |
|
34 |
|
35 // --------------------------------------------------------------------------------- |
|
36 // CUpnpTmFilteredAppList::NewL |
|
37 // Two-phased constructor. |
|
38 // --------------------------------------------------------------------------------- |
|
39 // |
|
40 CUpnpTmFilteredAppList* CUpnpTmFilteredAppList::NewL( CUpnpTmServerImpl& aTmServerImpl ) |
|
41 { |
|
42 OstTraceFunctionEntry0( CUPNPTMFILTEREDAPPLIST_NEWL_ENTRY ); |
|
43 CUpnpTmFilteredAppList* self = new (ELeave) CUpnpTmFilteredAppList( aTmServerImpl ); |
|
44 CleanupStack::PushL(self); |
|
45 self->ConstructL( ); |
|
46 CleanupStack::Pop(self); |
|
47 OstTraceFunctionExit0( CUPNPTMFILTEREDAPPLIST_NEWL_EXIT ); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------------- |
|
52 // CUpnpTmFilteredAppList::CUpnpTmFilteredAppList |
|
53 // C++ default constructor can NOT contain any code, that |
|
54 // might leave. |
|
55 // --------------------------------------------------------------------------------- |
|
56 // |
|
57 CUpnpTmFilteredAppList::CUpnpTmFilteredAppList( CUpnpTmServerImpl& aTmServerImpl ) |
|
58 :iTmServerImpl (aTmServerImpl ) |
|
59 { |
|
60 |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------------- |
|
64 // CUpnpTmFilteredAppList::ConstructL |
|
65 // Symbian 2nd phase constructor can leave. |
|
66 // --------------------------------------------------------------------------------- |
|
67 // |
|
68 void CUpnpTmFilteredAppList::ConstructL() |
|
69 { |
|
70 OstTraceFunctionEntry0( CUPNPTMFILTEREDAPPLIST_CONSTRUCTL_ENTRY ); |
|
71 iFilterInfo = CUpnpAppFilterInfo::NewL(); |
|
72 OstTraceFunctionExit0( CUPNPTMFILTEREDAPPLIST_CONSTRUCTL_EXIT ); |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------------------------------- |
|
76 // CUpnpTmFilteredAppList::~CUpnpTmFilteredAppList |
|
77 // Destructor |
|
78 // --------------------------------------------------------------------------------- |
|
79 // |
|
80 CUpnpTmFilteredAppList::~CUpnpTmFilteredAppList() |
|
81 { |
|
82 OstTraceFunctionEntry0( CUPNPTMFILTEREDAPPLIST_CUPNPTMFILTEREDAPPLIST_ENTRY ); |
|
83 delete iFilterInfo; |
|
84 OstTraceFunctionExit0( CUPNPTMFILTEREDAPPLIST_CUPNPTMFILTEREDAPPLIST_EXIT ); |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------------- |
|
88 // CUpnpTmFilteredAppList::ParseAppFilterStringL |
|
89 // Method parses the descriptor containing the filter string |
|
90 // It parses the comma-separated list of A_ARG_TYPE_AppList schema |
|
91 // elements, attributes and their values |
|
92 // eg: "name="*Audio*",description="*",icon@mimetype="*svg+xml*", remotingInfo@protocolID="*", |
|
93 // appInfo@appCategory="*",audioInfo@audioType="*",resourceStatus="free",signature="*"" |
|
94 // @param aAppFilter Buffer containing application filter string |
|
95 // @param aErr[out] Terminal Mode error code |
|
96 // --------------------------------------------------------------------------------- |
|
97 // |
|
98 void CUpnpTmFilteredAppList::ParseAppFilterStringL( const TDesC8& aAppFilter, |
|
99 TTerminalModeErrorCode& aErr ) |
|
100 { |
|
101 OstTraceFunctionEntry0( CUPNPTMFILTEREDAPPLIST_PARSEAPPFILTERSTRINGL_ENTRY ); |
|
102 // Validate the filter string |
|
103 aErr = ETerminalModeSuccess; |
|
104 TInt quotePos = aAppFilter.Locate( KQuote ); |
|
105 if ( ( quotePos != 0 ) || ( aAppFilter.Find(KDoubleQuote) == KErrNotFound )) |
|
106 { |
|
107 // corrupt filter string |
|
108 aErr = ETerminalModeInvalidArgument; |
|
109 OstTrace1( TRACE_ERROR, DUP2_CUPNPTMFILTEREDAPPLIST_PARSEAPPFILTERSTRINGL, "CUpnpTmFilteredAppList::ParseAppFilterStringL;quotePos=%d", quotePos ); |
|
110 return; |
|
111 } |
|
112 RBuf8 filterBuffer; |
|
113 CleanupClosePushL(filterBuffer); |
|
114 /* Create a buffer having the content of AppFilter buffer but without |
|
115 the leading quote(") */ |
|
116 filterBuffer.CreateL(aAppFilter.Mid(quotePos+1)); |
|
117 TInt equalToQuoteToken; |
|
118 while( ( equalToQuoteToken = filterBuffer.Find(Keq)) != KErrNotFound ) |
|
119 { |
|
120 // Fetch the full key string |
|
121 TPtrC8 key = filterBuffer.Left(equalToQuoteToken); |
|
122 // Check for the presence of sub element by checking the @ in the key string |
|
123 TInt atTokenPos = key.Find(KAtToken); |
|
124 TBool displayInfo(EFalse); |
|
125 if ( atTokenPos != KErrNotFound ) |
|
126 { |
|
127 // @ is found in the key string |
|
128 // Now extract the parent element |
|
129 TPtrC8 parentKey = key.Left(atTokenPos); |
|
130 //Remove any leading and trailing whitespaces in the parent element |
|
131 const TDesC8& parentKeyWithoutSpace = RemoveWhiteSpace(parentKey); |
|
132 // Check if the parent elemet is one of desired element or not. |
|
133 // It should be one of the following : |
|
134 // <1> icon <2> remotingInfo <3> appInfo <4> displayInfo <5> audioInfo |
|
135 if ( ( parentKeyWithoutSpace.Compare(KIconElement) != KErrNone ) && |
|
136 ( parentKeyWithoutSpace.Compare(KRemotingInfo) != KErrNone ) && |
|
137 ( parentKeyWithoutSpace.Compare(KAppInfo) != KErrNone ) && |
|
138 ( parentKeyWithoutSpace.Compare(KDisplayInfo) != KErrNone ) && |
|
139 ( parentKeyWithoutSpace.Compare(KAudioInfo) != KErrNone ) ) |
|
140 { |
|
141 // parent element is not proper |
|
142 aErr = ETerminalModeInvalidArgument; |
|
143 break; |
|
144 } |
|
145 if ( parentKeyWithoutSpace.Compare(KDisplayInfo) == KErrNone ) |
|
146 { |
|
147 // The parent key element is displayInfo |
|
148 displayInfo = ETrue; |
|
149 } |
|
150 // Fetch the actual key name ( child element ) |
|
151 key.Set(key.Mid(atTokenPos+1)); |
|
152 } |
|
153 |
|
154 //Remove any leading and trailing whitespaces in the key |
|
155 const TDesC8& keyWithoutSpace = RemoveWhiteSpace(key); |
|
156 if ( (filterBuffer.Mid(equalToQuoteToken) ).Locate(KQuote) != 1 ) |
|
157 { |
|
158 // Missing quote(") ahead of the value |
|
159 aErr = ETerminalModeInvalidArgument; |
|
160 break; |
|
161 } |
|
162 TPtrC8 bufPtr = filterBuffer.Mid(equalToQuoteToken+2); |
|
163 quotePos = bufPtr.Locate( KQuote ); |
|
164 if ( quotePos == KErrNotFound ) |
|
165 { |
|
166 // missing quote (") at the end of the value |
|
167 aErr = ETerminalModeInvalidArgument; |
|
168 break; |
|
169 } |
|
170 |
|
171 /* Add the filter info as key-value pairs. |
|
172 // Also check if the parent key is display info. |
|
173 If display info flag is true then use the method with non default parameter */ |
|
174 if ( displayInfo ) |
|
175 { |
|
176 iFilterInfo->SetFilterInfoL( keyWithoutSpace, bufPtr.Left(quotePos), aErr, ETrue ); |
|
177 } |
|
178 else |
|
179 { |
|
180 // Use the method with default parameter |
|
181 iFilterInfo->SetFilterInfoL( keyWithoutSpace, bufPtr.Left(quotePos), aErr ); |
|
182 } |
|
183 if ( aErr != ETerminalModeSuccess ) |
|
184 { |
|
185 // Return the error code in case the key element is not as per the schema |
|
186 aErr = ETerminalModeInvalidArgument; |
|
187 break; |
|
188 } |
|
189 // Skip the quote position and set the buffer |
|
190 bufPtr.Set(bufPtr.Mid(quotePos+1)); |
|
191 if ( ( bufPtr.Locate(KCommaSeparator) != 0 ) && ( bufPtr.Locate(KQuote) != 0 ) ) |
|
192 { |
|
193 // missing quote (") or comma (,) following the quote. |
|
194 // Expected to be something of this kind ( ", or "" ) |
|
195 aErr = ETerminalModeInvalidArgument; |
|
196 break; |
|
197 } |
|
198 //Copy the residual content skipping two characters(", or "" ) in the actual buffer |
|
199 filterBuffer.Copy(bufPtr.Mid(UpnpString::KLinefeedLength)); |
|
200 } |
|
201 CleanupStack::PopAndDestroy(&filterBuffer); |
|
202 OstTrace1( TRACE_FLOW, CUPNPTMFILTEREDAPPLIST_PARSEAPPFILTERSTRINGL, "CUpnpTmFilteredAppList::ParseAppFilterStringL;aErr=%d", aErr ); |
|
203 OstTraceFunctionExit0( CUPNPTMFILTEREDAPPLIST_PARSEAPPFILTERSTRINGL_EXIT ); |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------------------------------- |
|
207 // CUpnpTmFilteredAppList::ConstructFilteredGetAppListResponseL |
|
208 // Constructs the GetApplicationList action response buffer satisfying |
|
209 // the AppListingFilter criteria |
|
210 // @param aAppIndex Index the registered application |
|
211 // --------------------------------------------------------------------------------- |
|
212 // |
|
213 void CUpnpTmFilteredAppList::ConstructFilteredGetAppListResponseL( TInt aAppIndex ) |
|
214 { |
|
215 OstTraceFunctionEntry0( CUPNPTMFILTEREDAPPLIST_CONSTRUCTFILTEREDGETAPPLISTRESPONSEL_ENTRY ); |
|
216 const TDesC8& filterAppName = iFilterInfo->AppName(); |
|
217 const TDesC8& filterAppDesc = iFilterInfo->AppDescription(); |
|
218 if ( ( ( filterAppName.Length() == 0 ) || |
|
219 ((iTmServerImpl.iAppStore->FetchRemotableApp(aAppIndex).AppName()).MatchC(filterAppName) |
|
220 != KErrNotFound )) && (( filterAppDesc.Length() == 0 ) || |
|
221 ((iTmServerImpl.iAppStore->FetchRemotableApp(aAppIndex).AppDescription()).MatchC(filterAppDesc) |
|
222 != KErrNotFound ))) |
|
223 { |
|
224 /** |
|
225 * 1. Either required appName element is unavailable in the filter string or the desired appName matches. |
|
226 * 2. Either optional appDescription element is unavailable in the filter string |
|
227 * or the desired appDescription element matches |
|
228 */ |
|
229 const RPointerArray<CUpnpTmInfoElement>& tmInfoElementList = |
|
230 iTmServerImpl.iAppStore->FetchRemotableApp(aAppIndex).TmInfoElementList(); |
|
231 TInt tmInfoCount = tmInfoElementList.Count(); |
|
232 // Check if terminal mode info is also available in the filter string |
|
233 TInt match(KErrNone); |
|
234 for ( TInt i(0); i < tmInfoCount; i++ ) |
|
235 { |
|
236 if ( TerminalModeInfoMatchingL( *tmInfoElementList[i]) ) |
|
237 { |
|
238 match++; |
|
239 } |
|
240 else |
|
241 { |
|
242 break; |
|
243 } |
|
244 } |
|
245 if ( match == tmInfoCount ) |
|
246 { |
|
247 // Check if resource status and xm signature elements are available in the filter |
|
248 const TDesC8& filterRscStatus = iFilterInfo->ResourceStatus(); |
|
249 const TDesC8& filterSignature = iFilterInfo->Signature(); |
|
250 if ( (( filterRscStatus.Length() == 0 ) || |
|
251 ((iTmServerImpl.iAppStore->FetchRemotableApp(aAppIndex).ResourceStatus()).MatchC(filterRscStatus) |
|
252 != KErrNotFound)) && ( ( filterSignature.Length() == 0 ) || |
|
253 ((iTmServerImpl.XmlSignature()).MatchC(filterSignature) != KErrNotFound)) ) |
|
254 { |
|
255 IconMatchingL( aAppIndex ); |
|
256 } |
|
257 } |
|
258 } |
|
259 OstTraceFunctionExit0( CUPNPTMFILTEREDAPPLIST_CONSTRUCTFILTEREDGETAPPLISTRESPONSEL_EXIT ); |
|
260 } |
|
261 |
|
262 // --------------------------------------------------------------------------------- |
|
263 // CUpnpTmFilteredAppList::TerminalModeInfoMatchingL |
|
264 // The method checks if the terminal mode info element is present in the filter string |
|
265 // If available then it compares with each of the desired key-value of a particular |
|
266 // info element. |
|
267 // @param aTmInfoElement Reference to Terminal Mode Info Element object |
|
268 // @return Returns a boolean value ( ETrue/EFalse ) |
|
269 // --------------------------------------------------------------------------------- |
|
270 // |
|
271 TBool CUpnpTmFilteredAppList::TerminalModeInfoMatchingL( const CUpnpTmInfoElement& aTmInfoElement )const |
|
272 { |
|
273 OstTraceFunctionEntry0( CUPNPTMFILTEREDAPPLIST_TERMINALMODEINFOMATCHING_ENTRY ); |
|
274 TBool match(EFalse); |
|
275 // First check for terminal mode info type |
|
276 const TDesC8& infoType = aTmInfoElement.TerminalModeInfoType(); |
|
277 /** |
|
278 * info Type must be either one of these |
|
279 * <1> Remoting Info <2> App Info <3> Display Info <4> Audio Info |
|
280 * |
|
281 */ |
|
282 if ( ( infoType.Compare(KRemotingInfo) == KErrNone ) ||( infoType.Compare(KAppInfo) == KErrNone ) |
|
283 || ( infoType.Compare(KDisplayInfo) == KErrNone ) || ( infoType.Compare(KAudioInfo) == KErrNone )) |
|
284 { |
|
285 for ( TInt j(0); j < aTmInfoElement.TmInfoElementCount(); j++ ) |
|
286 { |
|
287 match = TmInfoElementMatchingL( aTmInfoElement,j ); |
|
288 if ( !match ) |
|
289 { |
|
290 break; |
|
291 } |
|
292 } |
|
293 } |
|
294 OstTraceFunctionExit0( CUPNPTMFILTEREDAPPLIST_TERMINALMODEINFOMATCHING_EXIT ); |
|
295 return match; |
|
296 } |
|
297 |
|
298 // --------------------------------------------------------------------------------- |
|
299 // CUpnpTmFilteredAppList::TmInfoElementMatchingL |
|
300 // Method is used to compare with each of the desired key-value of a particular |
|
301 // info element. |
|
302 // @param aTmInfoElement Reference to Terminal Mode Info Element object. |
|
303 // @return Returns the boolean value ( ETrue/EFalse ) |
|
304 // --------------------------------------------------------------------------------- |
|
305 // |
|
306 TBool CUpnpTmFilteredAppList::TmInfoElementMatchingL( const CUpnpTmInfoElement& aTmInfoElement, |
|
307 TInt aIndex )const |
|
308 { |
|
309 OstTraceFunctionEntry0( CUPNPTMFILTEREDAPPLIST_TMINFOELEMENTMATCHINGL_ENTRY ); |
|
310 TBool match(EFalse); |
|
311 RBuf8 elementName; |
|
312 CleanupClosePushL(elementName); |
|
313 RBuf8 elementValue; |
|
314 CleanupClosePushL(elementValue); |
|
315 aTmInfoElement.GetTmInfoElementL(elementName,elementValue,aIndex ); |
|
316 // Check for required "protocolID" element |
|
317 if ( elementName.Compare(KProtocolId()) == KErrNone ) |
|
318 { |
|
319 const TDesC8& filterProtocol = iFilterInfo->ProtocolId(); |
|
320 if ( ( filterProtocol.Length() == KErrNone) || |
|
321 elementValue.MatchC(filterProtocol) != KErrNotFound ) |
|
322 { |
|
323 // Either protocolID( required element )is unavailable or desired |
|
324 // protocolID matches |
|
325 match = ETrue; |
|
326 } |
|
327 } |
|
328 // Check for optional "format" element |
|
329 else if ( elementName.Compare(KFormat()) == KErrNone ) |
|
330 { |
|
331 const TDesC8& filterFormat = iFilterInfo->Format(); |
|
332 if ( ( filterFormat.Length() == KErrNone) || |
|
333 elementValue.MatchC(filterFormat) != KErrNotFound ) |
|
334 { |
|
335 // Either format ( optional element )is unavailable or desired "format" matches |
|
336 match = ETrue; |
|
337 } |
|
338 } |
|
339 // Check for optional "direction" element |
|
340 else if ( elementName.Compare(KRemotingDirection()) == KErrNone ) |
|
341 { |
|
342 const TDesC8& filterDirection = iFilterInfo->Direction(); |
|
343 if ( ( filterDirection.Length() == KErrNone) || |
|
344 elementValue.MatchC(filterDirection) != KErrNotFound ) |
|
345 { |
|
346 // Either direction ( optional element )is unavailable or desired "direction" matches |
|
347 match = ETrue; |
|
348 } |
|
349 } |
|
350 // Check for optional "appCategory" element |
|
351 else if ( elementName.Compare(KAppCategory()) == KErrNone ) |
|
352 { |
|
353 const TDesC8& filterAppCategory = iFilterInfo->AppCategory(); |
|
354 if ( ( filterAppCategory.Length() == KErrNone) || |
|
355 elementValue.MatchC(filterAppCategory) != KErrNotFound ) |
|
356 { |
|
357 // Either appCategory ( optional element )is unavailable or desired "appCategory" matches |
|
358 match = ETrue; |
|
359 } |
|
360 } |
|
361 // Check for optional "trustLevel" element for App Info Type |
|
362 else if ( ( elementName.Compare(KTrustLevel()) == KErrNone ) && |
|
363 ( aTmInfoElement.TerminalModeInfoType() == KAppInfo()) ) |
|
364 { |
|
365 const TDesC8& filterAppTrustLevel = iFilterInfo->AppTrustLevel(); |
|
366 if ( ( filterAppTrustLevel.Length() == KErrNone) || |
|
367 elementValue.MatchC(filterAppTrustLevel) != KErrNotFound ) |
|
368 { |
|
369 // Either trustLevel ( optional element )is unavailable or desired "trustLevel" matches |
|
370 match = ETrue; |
|
371 } |
|
372 } |
|
373 // Check for optional "contentCategory" element |
|
374 else if ( elementName.Compare(KContCategory()) == KErrNone ) |
|
375 { |
|
376 const TDesC8& filterContCategory = iFilterInfo->ContentCategory(); |
|
377 if ( ( filterContCategory.Length() == KErrNone) || |
|
378 elementValue.MatchC(filterContCategory) != KErrNotFound ) |
|
379 { |
|
380 // Either contentCategory ( optional element )is unavailable or desired |
|
381 // "contentCategory" matches |
|
382 match = ETrue; |
|
383 } |
|
384 } |
|
385 // Check for optional "contentRules" element |
|
386 else if ( elementName.Compare(KContentRules()) == KErrNone ) |
|
387 { |
|
388 const TDesC8& filterContentRules = iFilterInfo->ContentRules(); |
|
389 if ( ( filterContentRules.Length() == KErrNone) || |
|
390 elementValue.MatchC(filterContentRules) != KErrNotFound ) |
|
391 { |
|
392 // Either contentRules ( optional element )is unavailable or desired "contentRules" matches |
|
393 match = ETrue; |
|
394 } |
|
395 } |
|
396 // Check for optional "trustLevel" element for Display Info type |
|
397 else if ( ( elementName.Compare(KTrustLevel()) == KErrNone ) && |
|
398 ( aTmInfoElement.TerminalModeInfoType() == KDisplayInfo()) ) |
|
399 { |
|
400 const TDesC8& filterContTrustLevel = iFilterInfo->ContentTrustLevel(); |
|
401 if ( ( filterContTrustLevel.Length() == KErrNone) || |
|
402 elementValue.MatchC(filterContTrustLevel) != KErrNotFound ) |
|
403 { |
|
404 // Either trustLevel ( optional element )is unavailable or desired "trustLevel" matches |
|
405 match = ETrue; |
|
406 } |
|
407 } |
|
408 // Check for optional "audioType" element |
|
409 else if ( elementName.Compare(KAudioType()) == KErrNone ) |
|
410 { |
|
411 const TDesC8& filterAudioType = iFilterInfo->AudioType(); |
|
412 if ( ( filterAudioType.Length() == KErrNone) || |
|
413 elementValue.MatchC(filterAudioType) != KErrNotFound ) |
|
414 { |
|
415 // Either audioType ( optional element )is unavailable or desired "audioType" matches |
|
416 match = ETrue; |
|
417 } |
|
418 } |
|
419 CleanupStack::PopAndDestroy(2,&elementName); |
|
420 OstTraceFunctionExit0( CUPNPTMFILTEREDAPPLIST_TMINFOELEMENTMATCHINGL_EXIT ); |
|
421 return match; |
|
422 } |
|
423 |
|
424 // --------------------------------------------------------------------------------- |
|
425 // CUpnpTmFilteredAppList::IconMatchingL |
|
426 // The method checks if the optional icon element is present in the filter string |
|
427 // If present then it compares with the icon of the given application |
|
428 // @param aAppIndex index of the registered app |
|
429 // @param aAppStore reference to CUpnpRemotableAppStore object |
|
430 // --------------------------------------------------------------------------------- |
|
431 // |
|
432 void CUpnpTmFilteredAppList::IconMatchingL( TInt aAppIndex ) |
|
433 { |
|
434 OstTraceFunctionEntry0( CUPNPTMFILTEREDAPPLIST_ICONMATCHINGL_ENTRY ); |
|
435 const TDesC8& mimeType = iFilterInfo->MimeType(); |
|
436 const TDesC8& width = iFilterInfo->Width(); |
|
437 const TDesC8& height = iFilterInfo->Height(); |
|
438 const TDesC8& depth = iFilterInfo->Depth(); |
|
439 const RPointerArray<CUpnpTerminalModeIcon>& iconList = |
|
440 iTmServerImpl.iAppStore->FetchRemotableApp(aAppIndex).IconList(); |
|
441 TInt iconCount = iconList.Count(); |
|
442 if( ( iconCount == 0 ) || |
|
443 (( mimeType.Length() == 0 ) && ( width.Length() == 0 ) && |
|
444 ( height.Length() == 0 ) && ( depth.Length() == 0 ))) |
|
445 { |
|
446 /* Match is found and the given application needs to be there |
|
447 in the response with no optional icon element */ |
|
448 ConstructFilteredResponseL( aAppIndex ); |
|
449 } |
|
450 else |
|
451 { |
|
452 for ( TInt k(0); k < iconCount; k++ ) |
|
453 { |
|
454 if ( IconLookUp( *iconList[k] )) |
|
455 { |
|
456 /* Match is found and the given application needs to be there |
|
457 in the response with the icon element to be present */ |
|
458 ConstructFilteredResponseL( aAppIndex ); |
|
459 break; |
|
460 } |
|
461 } |
|
462 } |
|
463 OstTraceFunctionExit0( DUP1_CUPNPTMFILTEREDAPPLIST_ICONMATCHINGL_EXIT ); |
|
464 } |
|
465 |
|
466 // --------------------------------------------------------------------------------- |
|
467 // CUpnpTmFilteredAppList::ConstructFilteredResponseL |
|
468 // Constructs the filtered soap response buffer for GetApplicationList action |
|
469 // @param aAppIndex index the registered application |
|
470 // @param aAppStore Reference to CUpnpRemotableAppStore object |
|
471 // --------------------------------------------------------------------------------- |
|
472 // |
|
473 void CUpnpTmFilteredAppList::ConstructFilteredResponseL( TInt aAppIndex ) |
|
474 { |
|
475 OstTraceFunctionEntry0( CUPNPTMFILTEREDAPPLIST_CONSTRUCTFILTEREDRESPONSEL_ENTRY ); |
|
476 iTmServerImpl.ConstructLeadingSoapBufferL(aAppIndex); |
|
477 const TDesC8& appDesc = iTmServerImpl.iAppStore->FetchRemotableApp(aAppIndex).AppDescription(); |
|
478 if ( ( iFilterInfo->AppDescription().Length() != KErrNone ) |
|
479 && ( appDesc.Length() != KErrNone ) ) |
|
480 { |
|
481 // Appends the optional application desciption element |
|
482 iTmServerImpl.AppendDataL(KStartNameDesc); |
|
483 iTmServerImpl.AppendDataL(appDesc); |
|
484 iTmServerImpl.AppendDataL(KEndNameDesc); |
|
485 } |
|
486 const TDesC8& mimeType = iFilterInfo->MimeType(); |
|
487 const TDesC8& width = iFilterInfo->Width(); |
|
488 const TDesC8& height = iFilterInfo->Height(); |
|
489 const TDesC8& depth = iFilterInfo->Depth(); |
|
490 if (( mimeType.Length() != KErrNone ) || ( width.Length() != KErrNone ) || |
|
491 ( height.Length() != KErrNone ) || ( depth.Length() != KErrNone )) |
|
492 { |
|
493 // Even if any one of the matching optional child element of the icon element is present |
|
494 // in the filter string,we will return the complete icon information related to that icon |
|
495 const RPointerArray<CUpnpTerminalModeIcon>& iconList = |
|
496 iTmServerImpl.iAppStore->FetchRemotableApp(aAppIndex).IconList(); |
|
497 TInt iconCount = iconList.Count(); |
|
498 if ( iconCount > KErrNone ) |
|
499 { |
|
500 // Appends the optional icon element |
|
501 iTmServerImpl.AppendDataL(KStartIconList); |
|
502 for ( TInt i(0); i < iconCount; i++ ) |
|
503 { |
|
504 if ( IconLookUp( *iconList[i] )) |
|
505 { |
|
506 iTmServerImpl.SetRemotableAppIconInfoL( *iconList[i] ); |
|
507 } |
|
508 } |
|
509 iTmServerImpl.AppendDataL(KEndIconList); |
|
510 } |
|
511 } |
|
512 // Appends allowed profile ID list |
|
513 if ( iFilterInfo->AllowedProfileIdList().Length() != KErrNone ) |
|
514 { |
|
515 iTmServerImpl.SetAllowedProfileIdListL(aAppIndex); |
|
516 } |
|
517 |
|
518 // Appends the different associated terminal mode info elements |
|
519 const TDesC8& filterAppCategory = iFilterInfo->AppCategory(); |
|
520 const TDesC8& filterAppTrustLevel = iFilterInfo->AppTrustLevel(); |
|
521 const TDesC8& filterContCategory = iFilterInfo->ContentCategory(); |
|
522 const TDesC8& filterContentRules = iFilterInfo->ContentRules(); |
|
523 const TDesC8& filterContTrustLevel = iFilterInfo->ContentTrustLevel(); |
|
524 const TDesC8& filterAudioType = iFilterInfo->AudioType(); |
|
525 |
|
526 const RPointerArray<CUpnpTmInfoElement>& tmInfoElementList = |
|
527 iTmServerImpl.iAppStore->FetchRemotableApp(aAppIndex).TmInfoElementList(); |
|
528 /** |
|
529 * Case 1. In case of matching child elements of remotingInfo ,all the child elements of the |
|
530 * remotingInfo element are sent in the response as protocolID is a required element. |
|
531 * Case 2. In case of matching child elements of appInfo,displayInfo or audioInfo ,if one or |
|
532 * more of the optional child element is available in the filter string,then all |
|
533 * the optional child elements for that info element will be sent in the response. |
|
534 */ |
|
535 for ( TInt j(0); j < tmInfoElementList.Count(); j++) |
|
536 { |
|
537 /** |
|
538 * No checking for availabilty of child elements of remotingInfo is needed , because |
|
539 * protocolID( child element of remotingInfo ) is required/must element in the response |
|
540 * and as per the rule even if one child element is present in the filter string, |
|
541 * all other optional child elements of their parent info element too will be sent. |
|
542 */ |
|
543 if ( ( tmInfoElementList[j]->TerminalModeInfoType() == KRemotingInfo ) || |
|
544 ( ( tmInfoElementList[j]->TerminalModeInfoType() == KAppInfo ) && |
|
545 (( filterAppCategory.Length() != KErrNone ) || (filterAppTrustLevel.Length() != KErrNone ))) || |
|
546 ( ( tmInfoElementList[j]->TerminalModeInfoType() == KDisplayInfo ) && |
|
547 (( filterContCategory.Length() != KErrNone ) || (filterContentRules.Length() != KErrNone ) || |
|
548 (filterContTrustLevel.Length() != KErrNone ) )) || ( ( tmInfoElementList[j]->TerminalModeInfoType() == KAudioInfo ) |
|
549 && ( filterAudioType.Length() != KErrNone ))) |
|
550 { |
|
551 // Called for each terminal mode element associated with the App |
|
552 iTmServerImpl.SetTerminalModeInfoElementL( *tmInfoElementList[j] ); |
|
553 } |
|
554 } |
|
555 // Appends resource status element for the app if it is available |
|
556 if ( iFilterInfo->ResourceStatus().Length() != KErrNone ) |
|
557 { |
|
558 iTmServerImpl.SetResourceStatusL(aAppIndex); |
|
559 } |
|
560 // End of an application |
|
561 iTmServerImpl.AppendDataL(KEndApp); |
|
562 OstTraceFunctionExit0( CUPNPTMFILTEREDAPPLIST_CONSTRUCTFILTEREDRESPONSEL_EXIT ); |
|
563 } |
|
564 |
|
565 // --------------------------------------------------------------------------------- |
|
566 // CUpnpTmFilteredAppList::IconLookUp |
|
567 // Performs the icon look up |
|
568 // Checks if the requested icon and given icon matches |
|
569 // @param aIcon Reference to the Terminal Mode Icon object |
|
570 // @return Returns boolean value(true or false) |
|
571 // --------------------------------------------------------------------------------- |
|
572 // |
|
573 TBool CUpnpTmFilteredAppList::IconLookUp( CUpnpTerminalModeIcon& aIcon ) |
|
574 { |
|
575 OstTraceFunctionEntry0( CUPNPTMFILTEREDAPPLIST_ICONLOOKUP_ENTRY ); |
|
576 TBool matchFound(EFalse); |
|
577 const TDesC8& filterMimeType = iFilterInfo->MimeType(); |
|
578 const TDesC8& filterWidth = iFilterInfo->Width(); |
|
579 const TDesC8& filterHeight = iFilterInfo->Height(); |
|
580 const TDesC8& filterDepth = iFilterInfo->Depth(); |
|
581 |
|
582 // Check whether the icon is meant to be used only at launch time |
|
583 TBuf8<UpnpString::KShortStringLength> widthBuf; |
|
584 widthBuf.Num(aIcon.Width()); |
|
585 TBuf8<UpnpString::KShortStringLength> heightBuf; |
|
586 heightBuf.Num(aIcon.Height()); |
|
587 TBuf8<UpnpString::KShortStringLength> depthBuf; |
|
588 depthBuf.Num(aIcon.Depth()); |
|
589 /* Check if the icon in provided in the input filter string, and if so |
|
590 then does it match with the desired icon ( type and dimension ) */ |
|
591 if ( (( filterMimeType.Length() == 0 ) ||( (aIcon.MimeType()).MatchC(filterMimeType) != KErrNotFound)) |
|
592 && (( filterWidth.Length() == 0 ) ||( widthBuf.MatchC(filterWidth) != KErrNotFound)) |
|
593 && (( filterHeight.Length() == 0 ) ||( heightBuf.MatchC(filterHeight) != KErrNotFound)) |
|
594 && (( filterDepth.Length() == 0 ) ||( depthBuf.MatchC(filterDepth) != KErrNotFound))) |
|
595 { |
|
596 matchFound = ETrue; |
|
597 } |
|
598 OstTraceFunctionExit0( CUPNPTMFILTEREDAPPLIST_ICONLOOKUP_EXIT ); |
|
599 return matchFound; |
|
600 } |
|
601 |
|
602 // --------------------------------------------------------------------------------- |
|
603 // Method is used to check whether signature element is needed in the response |
|
604 // to GetApplicationList action or not |
|
605 // --------------------------------------------------------------------------------- |
|
606 const TDesC8& CUpnpTmFilteredAppList::SignatureElement()const |
|
607 { |
|
608 OstTraceFunctionEntry0( CUPNPTMFILTEREDAPPLIST_GETSIGNATUREELEMENT_ENTRY ); |
|
609 return iFilterInfo->Signature(); |
|
610 } |
|
611 |
|
612 // --------------------------------------------------------------------------------- |
|
613 // CUpnpTmFilteredAppList::RemoveWhiteSpace |
|
614 // Method is used to remove leading and trailing whitespaces from the descriptor's data |
|
615 // @param aData Descriptor's data from which whitespaces have to be removed |
|
616 // @return Returns the descriptor having no white spaces |
|
617 // --------------------------------------------------------------------------------- |
|
618 // |
|
619 const TDesC8& CUpnpTmFilteredAppList::RemoveWhiteSpace( TPtrC8& aData ) |
|
620 { |
|
621 OstTraceFunctionEntry0( CUPNPTMFILTEREDAPPLIST_REMOVEWHITESPACE_ENTRY ); |
|
622 // Removes the leading white spaces |
|
623 TInt length = aData.Length(); |
|
624 TInt i = 0; |
|
625 TBool done = EFalse; |
|
626 while( !done && i < length ) |
|
627 { |
|
628 TChar current = aData[i]; |
|
629 done = !current.IsSpace(); |
|
630 if( !done ) |
|
631 ++i; |
|
632 } |
|
633 aData.Set(aData.Mid(i)); /* aData now does not have any white space character |
|
634 ahead of its actual data */ |
|
635 |
|
636 // Removes the trailing white spaces |
|
637 length = aData.Length(); |
|
638 i = 0; |
|
639 done = EFalse; |
|
640 while( !done && i < length ) |
|
641 { |
|
642 TChar current = aData[(length-1) - i]; |
|
643 done = !current.IsSpace(); |
|
644 if( !done ) |
|
645 ++i; |
|
646 } |
|
647 aData.Set(aData.Left(aData.Length() - i)); /* aData now does not have any white space character |
|
648 following the actual data */ |
|
649 OstTraceFunctionExit0( CUPNPTMFILTEREDAPPLIST_REMOVEWHITESPACE_EXIT ); |
|
650 return aData; |
|
651 } |
|
652 |
|
653 // End of File |
|
654 |