1 /* |
|
2 * Copyright (c) 2005-2006 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: List in advanced find results dialog |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 // System |
|
21 #include <aknnotewrappers.h> |
|
22 #include <aknlists.h> |
|
23 #include <StringLoader.h> |
|
24 #include <AknWaitDialog.h> |
|
25 #include <akntextsettingpage.h> //for text editor flags |
|
26 #include <upnpstring.h> |
|
27 |
|
28 // upnp stack api's |
|
29 #include <upnpitem.h> |
|
30 |
|
31 // upnpframework / avcontroller api |
|
32 #include "upnpavbrowsingsession.h" |
|
33 |
|
34 // upnpramework / avcontroller helper api |
|
35 #include "upnpconstantdefs.h" // upnp definitions |
|
36 |
|
37 // upnpframework / xml parser api |
|
38 #include "upnpxmlparser.h" |
|
39 |
|
40 // common ui internal |
|
41 #include "upnpcommonui.hrh" |
|
42 #include <upnpcommonui.rsg> |
|
43 #include "upnpadvfindresultwindow.h" |
|
44 #include "upnpadvfindlist.h" |
|
45 #include "upnpadvfinddialog.h" |
|
46 |
|
47 |
|
48 _LIT( KComponentLogfile, "commonui.txt"); |
|
49 #include "upnplog.h" |
|
50 |
|
51 //CONSTANTS |
|
52 _LIT( KDate, "%d0000:" ); //Initial value for date elements |
|
53 _LIT8( KAttributeRefID, "@refID" ); |
|
54 _LIT8( KTimeFormat8, "%d-%02d-%02d" ); |
|
55 const TInt KMaxRequestCount = 50; |
|
56 const TInt KTmpDateFormatLength = 12; |
|
57 // -------------------------------------------------------------------------- |
|
58 // CUPnPAdvancedFindList::CUPnPAdvancedFindList |
|
59 // C++ default constructor can NOT contain any code, that |
|
60 // might leave. |
|
61 // -------------------------------------------------------------------------- |
|
62 // |
|
63 CUPnPAdvancedFindList::CUPnPAdvancedFindList( |
|
64 MUPnPAVController& aAVControl, |
|
65 MUPnPAVBrowsingSession& aBrowsingSession, |
|
66 CUPnPAdvancedFindDialog& aParent, |
|
67 CUPnPCommonUI& aCommonUI ): |
|
68 iAVControl(aAVControl), |
|
69 iCommonUI(aCommonUI), |
|
70 iAdvancedFindDialog(aParent), |
|
71 iBrowseSession(aBrowsingSession), |
|
72 iShowingErrorNote(EFalse) |
|
73 { |
|
74 |
|
75 // Set date to January first of current year |
|
76 iDateFrom.HomeTime(); |
|
77 TInt year = iDateFrom.DateTime().Year(); |
|
78 TBuf<10> tempBuf; |
|
79 tempBuf.Format( KDate(), year ); |
|
80 iDateFrom.Set( tempBuf ); |
|
81 |
|
82 iDateUntil.HomeTime(); |
|
83 |
|
84 iDateInitial.Set( tempBuf ); |
|
85 |
|
86 |
|
87 |
|
88 // backup existing browsesession observer and set this as current observer |
|
89 iBrowseObserver = iBrowseSession.Observer(); |
|
90 iBrowseSession.RemoveObserver(); |
|
91 iBrowseSession.SetObserver( *this ); |
|
92 |
|
93 iSearchResponseReceived = EFalse; |
|
94 |
|
95 iAction = CUPnPCommonUI::EUPnPNone; |
|
96 } |
|
97 |
|
98 // -------------------------------------------------------------------------- |
|
99 // CUPnPAdvancedFindList::ConstructL |
|
100 // Symbian 2nd phase constructor can leave. |
|
101 // -------------------------------------------------------------------------- |
|
102 // |
|
103 void CUPnPAdvancedFindList::ConstructL() |
|
104 { |
|
105 } |
|
106 // -------------------------------------------------------------------------- |
|
107 // CUPnPAdvancedFindList::NewL |
|
108 // Two-phased constructor. |
|
109 // -------------------------------------------------------------------------- |
|
110 // |
|
111 CUPnPAdvancedFindList* CUPnPAdvancedFindList::NewL( |
|
112 MUPnPAVController& aAVControl, |
|
113 MUPnPAVBrowsingSession& aBrowsingSession, |
|
114 CUPnPAdvancedFindDialog& aParent, |
|
115 CUPnPCommonUI& aCommonUI ) |
|
116 { |
|
117 __LOG( "CUPnPAdvancedFindList newL" ) ; |
|
118 CUPnPAdvancedFindList* self = new (ELeave) CUPnPAdvancedFindList( |
|
119 aAVControl, |
|
120 aBrowsingSession, |
|
121 aParent, |
|
122 aCommonUI ); |
|
123 CleanupStack::PushL( self ); |
|
124 self->ConstructL(); |
|
125 CleanupStack::Pop( self ); |
|
126 return self; |
|
127 } |
|
128 |
|
129 // -------------------------------------------------------------------------- |
|
130 // CUPnPAdvancedFindList::NewL |
|
131 // Destructor |
|
132 // -------------------------------------------------------------------------- |
|
133 // |
|
134 CUPnPAdvancedFindList::~CUPnPAdvancedFindList() |
|
135 { |
|
136 __LOG( "CUPnPAdvancedFindList::~CUPnPAdvancedFindList" ); |
|
137 if ( iWaitNoteDialog ) |
|
138 { |
|
139 // Stop showing wait note |
|
140 TRAP_IGNORE( iWaitNoteDialog->ProcessFinishedL() ); |
|
141 delete iWaitNoteDialog; |
|
142 iWaitNoteDialog = NULL; |
|
143 } |
|
144 |
|
145 iBrowseSession.RemoveObserver(); |
|
146 if( iBrowseObserver ) |
|
147 { |
|
148 iBrowseSession.SetObserver( *iBrowseObserver ); |
|
149 } |
|
150 |
|
151 iResultArray.ResetAndDestroy(); |
|
152 } |
|
153 |
|
154 // -------------------------------------------------------------------------- |
|
155 // CUPnPAdvancedFindList::MediaServerDisappeared |
|
156 // -------------------------------------------------------------------------- |
|
157 // |
|
158 void CUPnPAdvancedFindList::MediaServerDisappeared( |
|
159 TUPnPDeviceDisconnectedReason aReason ) |
|
160 { |
|
161 iClose = ETrue; |
|
162 iCloseReason = aReason; |
|
163 TRAP_IGNORE( MediaServerDisappearedL( aReason ) ); |
|
164 } |
|
165 |
|
166 // -------------------------------------------------------------------------- |
|
167 // CUPnPAdvancedFindList::MediaServerDisappearedL |
|
168 // -------------------------------------------------------------------------- |
|
169 // |
|
170 void CUPnPAdvancedFindList::MediaServerDisappearedL( |
|
171 TUPnPDeviceDisconnectedReason aReason ) |
|
172 { |
|
173 __LOG( "CUPnPAdvancedFindList::MediaServerDisappearedL" ); |
|
174 |
|
175 if( aReason == EDisconnected ) |
|
176 { |
|
177 iExitCode = KErrSessionClosed; |
|
178 } |
|
179 else if( aReason == EWLANLost) |
|
180 { |
|
181 iExitCode = KErrDisconnected; |
|
182 } |
|
183 else |
|
184 { |
|
185 __PANICD( __FILE__, __LINE__); |
|
186 } |
|
187 |
|
188 if( iWaitNoteDialog ) //if it is on searching |
|
189 { |
|
190 __LOG( "CUPnPAdvancedFindList::iWaitNoteDialog ETrue" ); |
|
191 DialogDismissedL( EEikBidCancel ); |
|
192 iWaitNoteDialog->ProcessFinishedL(); |
|
193 //no need to call DialogDismissedL; |
|
194 delete iWaitNoteDialog; |
|
195 iWaitNoteDialog = NULL; |
|
196 } |
|
197 else |
|
198 { |
|
199 if( iFindResultWindow ) |
|
200 { |
|
201 __LOG( "CUPnPAdvancedFindList::iFindResultWindow->DismissItselfL" ); |
|
202 iFindResultWindow->DismissItselfL( iExitCode ); |
|
203 iFindResultWindow = NULL; |
|
204 } |
|
205 else //notify AdvancedFindDialog to close itself |
|
206 { |
|
207 if ( !iShowingErrorNote ) |
|
208 { |
|
209 iAdvancedFindDialog.DismissItselfL( iExitCode ); |
|
210 } |
|
211 else |
|
212 { |
|
213 __LOG( "CUPnPAdvancedFindList::iShowingErrorNote ETrue" ); |
|
214 } |
|
215 } |
|
216 } |
|
217 __LOG( "CUPnPAdvancedFindList::MediaServerDisappearedL End" ); |
|
218 } |
|
219 |
|
220 // -------------------------------------------------------------------------- |
|
221 // CUPnPAdvancedFindList::DialogDismissedL |
|
222 // -------------------------------------------------------------------------- |
|
223 // |
|
224 void CUPnPAdvancedFindList::DialogDismissedL( TInt aButtonId ) |
|
225 { |
|
226 __LOG( "CUPnPBrowseDialog::DialogDismissedL" ); |
|
227 |
|
228 // If button is cancel, inform observer parent class |
|
229 // that cancel has been made |
|
230 if( aButtonId == EEikBidCancel ) |
|
231 { |
|
232 __LOG( "CUPnPBrowseDialog::DialogDismissedL: \ |
|
233 Cancel was pressed." ); |
|
234 |
|
235 iAction = CUPnPCommonUI::EUPnPNone; |
|
236 iBrowseSession.CancelSearch(); |
|
237 } |
|
238 |
|
239 __LOG( "CUPnPBrowseDialog::DialogDismissedL end" ); |
|
240 //Do nothing |
|
241 } |
|
242 |
|
243 // -------------------------------------------------------------------------- |
|
244 // CUPnPAdvancedFindList::SearchResponse |
|
245 // -------------------------------------------------------------------------- |
|
246 // |
|
247 void CUPnPAdvancedFindList::SearchResponse( const TDesC8& aSearchResponse, |
|
248 TInt aError, TInt /*aMatches*/, TInt /*aTotalCount*/, const TDesC8& |
|
249 /*aUpdateId*/ ) |
|
250 { |
|
251 __LOG( "CUPnPBrowseDialog::SearchResponse" ); |
|
252 RPointerArray<CUpnpObject> array; |
|
253 |
|
254 if( aError == KErrNone ) |
|
255 { |
|
256 CUPnPXMLParser* parser = NULL; |
|
257 TRAP( aError, parser = CUPnPXMLParser::NewL(); |
|
258 parser->ParseResultDataL( array, |
|
259 aSearchResponse ) ); |
|
260 |
|
261 delete parser; |
|
262 } |
|
263 |
|
264 TRAP_IGNORE( SearchResponseL( aError, array ) ); |
|
265 |
|
266 array.ResetAndDestroy(); |
|
267 |
|
268 __LOG( "CUPnPBrowseDialog::SearchResponse -end" ); |
|
269 } |
|
270 |
|
271 // -------------------------------------------------------------------------- |
|
272 // CUPnPAdvancedFindList::SearchResponseL |
|
273 // Response to FindMetadataL function. |
|
274 // -------------------------------------------------------------------------- |
|
275 void CUPnPAdvancedFindList::SearchResponseL( |
|
276 TInt aError, |
|
277 const RPointerArray<CUpnpObject>& aResultArray ) |
|
278 { |
|
279 |
|
280 __LOG( "CUPnPBrowseDialog::SearchResponseL" ); |
|
281 iExitCode = aError; |
|
282 if( KErrNone == aError ) |
|
283 { |
|
284 iSearchResponseReceived = ETrue; |
|
285 TBuf<KMaxNameLength> previousTitleName; |
|
286 previousTitleName.Zero(); |
|
287 //Go through the search result and add data to database |
|
288 |
|
289 |
|
290 for( TInt count = 0; count < aResultArray.Count(); count++ ) |
|
291 { |
|
292 //If an Item is found |
|
293 CUpnpObject* tmpObject = aResultArray[count]; |
|
294 |
|
295 //If it is right type and name is longer than zero |
|
296 if ( tmpObject->ObjectType() == EUPnPItem ) |
|
297 { |
|
298 CUpnpItem* item = static_cast<CUpnpItem*>( tmpObject ); |
|
299 |
|
300 if ( item->Title().Length() > 0 ) |
|
301 { |
|
302 |
|
303 //Copy the item |
|
304 item = CUpnpItem::NewL(); |
|
305 CleanupStack::PushL( item ); |
|
306 item->CopyL( *aResultArray[count] ); |
|
307 //And if item is correct type |
|
308 iResultArray.AppendL( item ); // item ownership transferred |
|
309 CleanupStack::Pop( item ); |
|
310 } |
|
311 } |
|
312 } |
|
313 } |
|
314 else |
|
315 { |
|
316 iCommonUI.GetUpnpAction( iAction ); |
|
317 iCommonUI.HandleCommonErrorL( aError, NULL ); |
|
318 __LOG( "CUPnPAdvancedFindList: \ |
|
319 SearchResponse operation failed!" ); |
|
320 } |
|
321 if ( iWaitNoteDialog ) |
|
322 { |
|
323 TRAP_IGNORE( iWaitNoteDialog->ProcessFinishedL() ); |
|
324 } |
|
325 __LOG( "CUPnPBrowseDialog::SearchResponseL -end" ); |
|
326 } |
|
327 |
|
328 // -------------------------------------------------------------------------- |
|
329 // CUPnPAdvancedFindList::CreateSettingItemL |
|
330 // Creates list items |
|
331 // -------------------------------------------------------------------------- |
|
332 // |
|
333 CAknSettingItem* CUPnPAdvancedFindList::CreateSettingItemL( |
|
334 TInt aIdentifier ) |
|
335 { |
|
336 CAknSettingItem* settingItem = NULL; |
|
337 switch (aIdentifier) |
|
338 { |
|
339 case EAdvancedFindMediaType: |
|
340 { |
|
341 iMediatype = 0; |
|
342 settingItem = new (ELeave) CAknEnumeratedTextPopupSettingItem( |
|
343 aIdentifier, iMediatype ); |
|
344 break; |
|
345 } |
|
346 case EAdvancedFindFileName: |
|
347 { |
|
348 settingItem = new (ELeave) CAknTextSettingItem( aIdentifier, |
|
349 iFileName ); |
|
350 settingItem->SetSettingPageFlags( |
|
351 CAknTextSettingPage::EZeroLengthAllowed ); |
|
352 break; |
|
353 } |
|
354 case EAdvancedFindArtist: |
|
355 { |
|
356 settingItem = new (ELeave) CAknTextSettingItem( aIdentifier, |
|
357 iArtistText ); |
|
358 settingItem->SetSettingPageFlags( |
|
359 CAknTextSettingPage::EZeroLengthAllowed ); |
|
360 settingItem->SetHidden( ETrue ); |
|
361 break; |
|
362 } |
|
363 case EAdvancedFindAlbum: |
|
364 { |
|
365 settingItem = new (ELeave) CAknTextSettingItem( aIdentifier, |
|
366 iAlbumText ); |
|
367 settingItem->SetSettingPageFlags( |
|
368 CAknTextSettingPage::EZeroLengthAllowed ); |
|
369 settingItem->SetHidden( ETrue ); |
|
370 break; |
|
371 } |
|
372 case EAdvancedFindGenre: |
|
373 { |
|
374 settingItem = new (ELeave) CAknTextSettingItem( aIdentifier, |
|
375 iGenreText ); |
|
376 settingItem->SetSettingPageFlags( |
|
377 CAknTextSettingPage::EZeroLengthAllowed ); |
|
378 settingItem->SetHidden( ETrue ); |
|
379 break; |
|
380 } |
|
381 case EAdvancedFindDateFrom: |
|
382 { |
|
383 settingItem = new (ELeave) CAknTimeOrDateSettingItem( |
|
384 aIdentifier, |
|
385 CAknTimeOrDateSettingItem::EDate, |
|
386 iDateFrom ); |
|
387 break; |
|
388 } |
|
389 case EAdvancedFindDateUntil: |
|
390 { |
|
391 settingItem = new (ELeave) CAknTimeOrDateSettingItem( |
|
392 aIdentifier, |
|
393 CAknTimeOrDateSettingItem::EDate, |
|
394 iDateUntil ); |
|
395 break; |
|
396 } |
|
397 default: |
|
398 break; |
|
399 } |
|
400 return settingItem; |
|
401 } |
|
402 |
|
403 // -------------------------------------------------------------------------- |
|
404 // CUPnPAdvancedFindList::EditItemL |
|
405 // -------------------------------------------------------------------------- |
|
406 // |
|
407 void CUPnPAdvancedFindList::EditItemL ( TInt aIndex, TBool aCalledFromMenu ) |
|
408 { |
|
409 CAknSettingItemArray* arrayForTrueIndex = |
|
410 CAknSettingItemList::SettingItemArray(); |
|
411 TInt indexForEditing = arrayForTrueIndex-> |
|
412 ItemIndexFromVisibleIndex( aIndex ); |
|
413 arrayForTrueIndex = NULL; |
|
414 switch ( indexForEditing ) |
|
415 { |
|
416 case EAdvancedFindMediaType: |
|
417 { |
|
418 iSettingPageOpen = ETrue; |
|
419 CAknSettingItemList::EditItemL( indexForEditing, |
|
420 aCalledFromMenu ); |
|
421 CAknSettingItemArray* arrayForHideCommands = |
|
422 CAknSettingItemList::SettingItemArray(); |
|
423 StoreSettingsL(); |
|
424 if ( iMediatype == EAdvancedFindMusic ) |
|
425 { |
|
426 CAknSettingItem* settingItem = |
|
427 arrayForHideCommands->At( EAdvancedFindArtist ); |
|
428 settingItem->SetHidden( EFalse ); |
|
429 settingItem = NULL; |
|
430 CAknSettingItem* settingItem2 = |
|
431 arrayForHideCommands->At( EAdvancedFindAlbum ); |
|
432 settingItem2->SetHidden( EFalse ); |
|
433 settingItem2 = NULL; |
|
434 CAknSettingItem* settingItem3 = |
|
435 arrayForHideCommands->At( EAdvancedFindGenre ); |
|
436 settingItem3->SetHidden( EFalse ); |
|
437 settingItem3 = NULL; |
|
438 } |
|
439 else |
|
440 { |
|
441 CAknSettingItem* settingItem = |
|
442 arrayForHideCommands->At( EAdvancedFindArtist ); |
|
443 settingItem->SetHidden( ETrue ); |
|
444 settingItem = NULL; |
|
445 CAknSettingItem* settingItem2 = |
|
446 arrayForHideCommands->At( EAdvancedFindAlbum ); |
|
447 settingItem2->SetHidden(ETrue); |
|
448 settingItem2 = NULL; |
|
449 CAknSettingItem* settingItem3 = |
|
450 arrayForHideCommands->At( EAdvancedFindGenre ); |
|
451 settingItem3->SetHidden( ETrue ); |
|
452 settingItem3 = NULL; |
|
453 } |
|
454 arrayForHideCommands = NULL; |
|
455 } |
|
456 break; |
|
457 case EAdvancedFindFileName: |
|
458 { |
|
459 iSettingPageOpen = ETrue; |
|
460 CAknSettingItemList::EditItemL( indexForEditing, |
|
461 aCalledFromMenu ); |
|
462 StoreSettingsL(); |
|
463 } |
|
464 break; |
|
465 case EAdvancedFindArtist: |
|
466 { |
|
467 iSettingPageOpen = ETrue; |
|
468 CAknSettingItemList::EditItemL( indexForEditing, |
|
469 aCalledFromMenu ); |
|
470 StoreSettingsL(); |
|
471 } |
|
472 break; |
|
473 case EAdvancedFindAlbum: |
|
474 { |
|
475 iSettingPageOpen = ETrue; |
|
476 CAknSettingItemList::EditItemL( indexForEditing, |
|
477 aCalledFromMenu ); |
|
478 StoreSettingsL(); |
|
479 } |
|
480 break; |
|
481 case EAdvancedFindGenre: |
|
482 { |
|
483 iSettingPageOpen = ETrue; |
|
484 CAknSettingItemList::EditItemL( indexForEditing, |
|
485 aCalledFromMenu ); |
|
486 StoreSettingsL(); |
|
487 } |
|
488 break; |
|
489 case EAdvancedFindDateFrom: |
|
490 { |
|
491 iSettingPageOpen = ETrue; |
|
492 CAknSettingItemList::EditItemL( indexForEditing, |
|
493 aCalledFromMenu ); |
|
494 StoreSettingsL(); |
|
495 } |
|
496 break; |
|
497 case EAdvancedFindDateUntil: |
|
498 { |
|
499 iSettingPageOpen = ETrue; |
|
500 CAknSettingItemList::EditItemL( indexForEditing, |
|
501 aCalledFromMenu ); |
|
502 StoreSettingsL(); |
|
503 |
|
504 } |
|
505 break; |
|
506 default: |
|
507 break; |
|
508 } |
|
509 |
|
510 iSettingPageOpen = EFalse; |
|
511 //load settings to screen |
|
512 CAknSettingItemList::LoadSettingsL(); |
|
513 CAknSettingItemList::DrawDeferred(); |
|
514 |
|
515 |
|
516 if( iClose ) |
|
517 { |
|
518 MediaServerDisappearedL(iCloseReason); |
|
519 } |
|
520 } |
|
521 |
|
522 // -------------------------------------------------------------------------- |
|
523 // CUPnPAdvancedFindList::MakeQueryL |
|
524 // -------------------------------------------------------------------------- |
|
525 // |
|
526 TInt CUPnPAdvancedFindList::MakeQueryL() |
|
527 { |
|
528 //Search criteria string |
|
529 HBufC8* searchCriteria = BuildSearchCriteriaL(); |
|
530 CleanupStack::PushL( searchCriteria ); |
|
531 |
|
532 HBufC8* sortCriteria = KSortCriteria().AllocL(); |
|
533 CleanupStack::PushL( sortCriteria ); |
|
534 |
|
535 iAction = CUPnPCommonUI::EUPnPSearch; |
|
536 // Make the search request |
|
537 iBrowseSession.SearchL( |
|
538 KContainerIdRoot, /* object id of the container */ |
|
539 *searchCriteria, /* criteria */ |
|
540 KFilterCommon, /* filter */ |
|
541 0, /* start index */ |
|
542 KMaxRequestCount + 1, /* request count + 1 */ |
|
543 *sortCriteria ); /* sort criteria */ |
|
544 CleanupStack::PopAndDestroy( sortCriteria ); |
|
545 CleanupStack::PopAndDestroy( searchCriteria ); |
|
546 |
|
547 TInt ret = KErrNone; |
|
548 iWaitNoteDialog = new(ELeave) CAknWaitDialog( ( |
|
549 REINTERPRET_CAST( CEikDialog**, |
|
550 &iWaitNoteDialog ) ), |
|
551 ETrue ); |
|
552 iWaitNoteDialog->SetCallback( this ); |
|
553 |
|
554 ret = iWaitNoteDialog->ExecuteLD( |
|
555 R_UPNPCOMMONUI_ADVANCEDFIND_WAIT_NOTE_DIALOG ); |
|
556 |
|
557 //Make result window |
|
558 //ret is KErrNone only when the DialogDismissedL by the FW. |
|
559 // ( not canceling) |
|
560 if( ret != KErrNone && iExitCode == KErrNone ) |
|
561 { |
|
562 //If there was more than request count received |
|
563 if( iResultArray.Count() > KMaxRequestCount ) |
|
564 { |
|
565 //Delete Item from array |
|
566 delete iResultArray[KMaxRequestCount]; |
|
567 //Remove from array |
|
568 iResultArray.Remove( KMaxRequestCount ); |
|
569 |
|
570 iShowingErrorNote = ETrue; |
|
571 //Display error note |
|
572 iCommonUI.DisplayErrorTextL( |
|
573 R_UPNPCOMMONUI_ADVANCED_FIND_TOO_MANY_RESULTS_ERROR, |
|
574 KMaxRequestCount ); |
|
575 iShowingErrorNote = EFalse; |
|
576 } |
|
577 |
|
578 // During running DisplayErrorTextL() |
|
579 // We also need to care about whether iExitCode been changed or not. |
|
580 if ( iExitCode != KErrNone ) |
|
581 { |
|
582 iResultArray.ResetAndDestroy(); |
|
583 return iExitCode; |
|
584 } |
|
585 else |
|
586 { |
|
587 iFindResultWindow = CAdvancedFindResultWindow::NewL( |
|
588 R_UPNPCOMMONUI_RESULT_WINDOW_MENUBAR, |
|
589 iResultArray, |
|
590 iAVControl, |
|
591 iBrowseSession, |
|
592 iCommonUI ); |
|
593 |
|
594 iFindResultWindow->SetMopParent( this ); |
|
595 |
|
596 iShowingErrorNote = ETrue; |
|
597 |
|
598 iExitCode = iFindResultWindow->ExecuteLD( |
|
599 R_UPNPCOMMONUI_ADVANCED_FIND_RESULT_DIALOG ); |
|
600 iShowingErrorNote = EFalse; |
|
601 |
|
602 iFindResultWindow = NULL; |
|
603 } |
|
604 } |
|
605 CAknSettingItemList::LoadSettingsL(); |
|
606 CAknSettingItemList::DrawDeferred(); |
|
607 |
|
608 //Delete result array |
|
609 iResultArray.ResetAndDestroy(); |
|
610 iSearchResponseReceived = EFalse; |
|
611 |
|
612 if( iExitCode != KErrSessionClosed && |
|
613 iExitCode != KErrDisconnected && |
|
614 iExitCode != EAknCmdExit && |
|
615 iExitCode != EEikCmdExit ) |
|
616 { |
|
617 iExitCode = KErrNone; |
|
618 } |
|
619 __LOG( "CUPnPAdvancedFindList::MakeQueryL End" ); |
|
620 return iExitCode; |
|
621 } |
|
622 |
|
623 // -------------------------------------------------------------------------- |
|
624 // CUPnPAdvancedFindList::HandleResourceChange |
|
625 // -------------------------------------------------------------------------- |
|
626 // |
|
627 void CUPnPAdvancedFindList::HandleResourceChange( TInt aType ) |
|
628 { |
|
629 __LOG( "CUPnPAdvancedFindList::HandleResourceChange" ); |
|
630 |
|
631 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
632 { |
|
633 TRect mainPaneRect; |
|
634 AknLayoutUtils::LayoutMetricsRect( |
|
635 AknLayoutUtils::EMainPane, mainPaneRect ); |
|
636 |
|
637 TAknLayoutRect layoutRect; |
|
638 layoutRect.LayoutRect( |
|
639 TRect( TPoint( 0, 0 ), mainPaneRect.Size() ), |
|
640 AKN_LAYOUT_WINDOW_list_gen_pane( 0 ) ); |
|
641 |
|
642 ListBox()->SetRect( layoutRect.Rect() ); |
|
643 } |
|
644 |
|
645 // Base call |
|
646 CAknSettingItemList::HandleResourceChange( aType ); |
|
647 } |
|
648 |
|
649 |
|
650 // -------------------------------------------------------------------------- |
|
651 // CUPnPAdvancedFindList::BuildSearchCriteriaL |
|
652 // -------------------------------------------------------------------------- |
|
653 // |
|
654 HBufC8* CUPnPAdvancedFindList::BuildSearchCriteriaL() const |
|
655 { |
|
656 __LOG( "CUPnPAdvancedFindList::BuildSearchCriteriaL" ); |
|
657 //Search criteria string |
|
658 HBufC8* searchCriteria = NULL; |
|
659 HBufC8* tmpStr = NULL; |
|
660 |
|
661 //Date variables for handling date search |
|
662 TBuf8<KTmpDateFormatLength> tmpDateFormat; |
|
663 TDateTime tmpDate; |
|
664 |
|
665 searchCriteria = HBufC8::NewL( |
|
666 KElementClass().Length() + |
|
667 KCriteriaSpace().Length() + |
|
668 KCriteriaDerivedFrom().Length() + |
|
669 KCriteriaSpace().Length() + |
|
670 KCriteriaQuot().Length() + |
|
671 KClassVideo().Length() + |
|
672 KCriteriaQuot().Length() + |
|
673 KCriteriaSpace().Length() + |
|
674 KCriteriaAnd().Length() + |
|
675 KCriteriaSpace().Length() + |
|
676 KAttributeRefID().Length() + |
|
677 KCriteriaSpace().Length() + |
|
678 KCriteriaExists().Length() + |
|
679 KCriteriaSpace().Length() + |
|
680 KCriteriaFalse().Length() ); |
|
681 TPtr8 strPtr = searchCriteria->Des(); |
|
682 |
|
683 strPtr.Copy( KElementClass() ); |
|
684 strPtr.Append( KCriteriaSpace ); |
|
685 strPtr.Append( KCriteriaDerivedFrom ); |
|
686 strPtr.Append( KCriteriaSpace ); |
|
687 strPtr.Append( KCriteriaQuot ); |
|
688 |
|
689 //Set search for the mediatype |
|
690 __LOG1( "iMediatype: %d", iMediatype ); |
|
691 switch( iMediatype ) |
|
692 { |
|
693 case EAdvancedFindAll: |
|
694 { |
|
695 strPtr.Append( KClassItem() ); |
|
696 break; |
|
697 } |
|
698 case EAdvancedFindImages: |
|
699 { |
|
700 strPtr.Append( KClassImage() ); |
|
701 break; |
|
702 } |
|
703 case EAdvancedFindVideo: |
|
704 { |
|
705 strPtr.Append( KClassVideo() ); |
|
706 break; |
|
707 } |
|
708 case EAdvancedFindMusic: |
|
709 { |
|
710 strPtr.Append( KClassAudio() ); |
|
711 break; |
|
712 } |
|
713 default: |
|
714 { |
|
715 __PANICD( __FILE__, __LINE__ ); |
|
716 break; |
|
717 } |
|
718 } |
|
719 |
|
720 strPtr.Append( KCriteriaQuot ); |
|
721 strPtr.Append( KCriteriaSpace ); |
|
722 strPtr.Append( KCriteriaAnd ); |
|
723 strPtr.Append( KCriteriaSpace ); |
|
724 strPtr.Append( KAttributeRefID ); |
|
725 strPtr.Append( KCriteriaSpace ); |
|
726 strPtr.Append( KCriteriaExists ); |
|
727 strPtr.Append( KCriteriaSpace ); |
|
728 strPtr.Append( KCriteriaFalse ); |
|
729 CleanupStack::PushL( searchCriteria ); |
|
730 |
|
731 //Check if filename has been entered to search criteria |
|
732 __LOG1( "iFileName.Length: %d", iFileName.Length() ); |
|
733 if( iFileName.Length() > 0 ) |
|
734 { |
|
735 __LOG( "add name condition" ); |
|
736 tmpStr = UpnpString::FromUnicodeL( iFileName ); |
|
737 |
|
738 //If inserted, add to search string |
|
739 searchCriteria = searchCriteria->ReAllocL( |
|
740 searchCriteria->Length() + |
|
741 KCriteriaSpace().Length() + |
|
742 KCriteriaAnd().Length() + |
|
743 KCriteriaSpace().Length() + |
|
744 KElementTitle().Length() + |
|
745 KCriteriaSpace().Length() + |
|
746 KCriteriaContains().Length() + |
|
747 KCriteriaSpace().Length() + |
|
748 KCriteriaQuot().Length() + |
|
749 tmpStr->Length() + |
|
750 KCriteriaQuot().Length() |
|
751 ); |
|
752 |
|
753 //pop out the old searchCriteria |
|
754 CleanupStack::Pop(); |
|
755 //push the new searchCriteria which is created by ReAllocL |
|
756 CleanupStack::PushL( searchCriteria ); |
|
757 |
|
758 strPtr.Set( searchCriteria->Des() ); |
|
759 strPtr.Append( KCriteriaSpace() ); |
|
760 strPtr.Append( KCriteriaAnd() ); |
|
761 strPtr.Append( KCriteriaSpace() ); |
|
762 strPtr.Append( KElementTitle() ); |
|
763 strPtr.Append( KCriteriaSpace() ); |
|
764 strPtr.Append( KCriteriaContains() ); |
|
765 strPtr.Append( KCriteriaSpace() ); |
|
766 strPtr.Append( KCriteriaQuot() ); |
|
767 strPtr.Append( *tmpStr ); |
|
768 strPtr.Append( KCriteriaQuot() ); |
|
769 delete tmpStr; |
|
770 tmpStr = NULL; |
|
771 |
|
772 } |
|
773 |
|
774 //Add possibly artists to search criteria |
|
775 if( iArtistText.Length() > 0 && iMediatype == EAdvancedFindMusic ) |
|
776 { |
|
777 __LOG( "add artists condition" ); |
|
778 tmpStr = UpnpString::FromUnicodeL( iArtistText ); |
|
779 searchCriteria = searchCriteria->ReAllocL( |
|
780 searchCriteria->Length() + |
|
781 KCriteriaSpace().Length() + |
|
782 KCriteriaAnd().Length() + |
|
783 KCriteriaSpace().Length() + |
|
784 KCriteriaOB().Length() + |
|
785 KElementArtist().Length() + |
|
786 KCriteriaSpace().Length() + |
|
787 KCriteriaContains().Length() + |
|
788 KCriteriaSpace().Length() + |
|
789 KCriteriaQuot().Length() + |
|
790 tmpStr->Length() + |
|
791 KCriteriaQuot().Length() + |
|
792 KCriteriaSpace().Length() + |
|
793 KCriteriaCB().Length() |
|
794 ); |
|
795 |
|
796 //pop out the old searchCriteria |
|
797 CleanupStack::Pop(); |
|
798 //push the new searchCriteria which is created by ReAllocL |
|
799 CleanupStack::PushL( searchCriteria ); |
|
800 |
|
801 strPtr.Set( searchCriteria->Des() ); |
|
802 strPtr.Append( KCriteriaSpace() ); |
|
803 strPtr.Append( KCriteriaAnd() ); |
|
804 strPtr.Append( KCriteriaSpace() ); |
|
805 strPtr.Append( KCriteriaOB() ); |
|
806 strPtr.Append( KElementArtist() ); |
|
807 strPtr.Append( KCriteriaSpace() ); |
|
808 strPtr.Append( KCriteriaContains() ); |
|
809 strPtr.Append( KCriteriaSpace() ); |
|
810 strPtr.Append( KCriteriaQuot() ); |
|
811 strPtr.Append( *tmpStr ); //Artist name |
|
812 strPtr.Append( KCriteriaQuot() ); |
|
813 strPtr.Append( KCriteriaSpace() ); |
|
814 strPtr.Append( KCriteriaCB() ); |
|
815 delete tmpStr; |
|
816 tmpStr = NULL; |
|
817 } |
|
818 |
|
819 //Add possibly albums to search criteria |
|
820 if( iAlbumText.Length() > 0 && iMediatype == EAdvancedFindMusic ) |
|
821 { |
|
822 __LOG( "add albums condition" ); |
|
823 tmpStr = UpnpString::FromUnicodeL( iAlbumText ); |
|
824 searchCriteria = searchCriteria->ReAllocL( |
|
825 searchCriteria->Length() + |
|
826 KCriteriaSpace().Length() + |
|
827 KCriteriaAnd().Length() + |
|
828 KCriteriaSpace().Length() + |
|
829 KCriteriaOB().Length() + |
|
830 KElementAlbum().Length() + |
|
831 KCriteriaSpace().Length() + |
|
832 KCriteriaContains().Length() + |
|
833 KCriteriaSpace().Length() + |
|
834 KCriteriaQuot().Length() + |
|
835 tmpStr->Length() + |
|
836 KCriteriaQuot().Length() + |
|
837 KCriteriaSpace().Length() + |
|
838 KCriteriaCB().Length() |
|
839 ); |
|
840 |
|
841 //pop out the old searchCriteria |
|
842 CleanupStack::Pop(); |
|
843 //push the new searchCriteria which is created by ReAllocL |
|
844 CleanupStack::PushL( searchCriteria ); |
|
845 |
|
846 strPtr.Set( searchCriteria->Des() ); |
|
847 strPtr.Append( KCriteriaSpace() ); |
|
848 strPtr.Append( KCriteriaAnd() ); |
|
849 strPtr.Append( KCriteriaSpace() ); |
|
850 strPtr.Append( KCriteriaOB() ); |
|
851 strPtr.Append( KElementAlbum() ); |
|
852 strPtr.Append( KCriteriaSpace() ); |
|
853 strPtr.Append( KCriteriaContains() ); |
|
854 strPtr.Append( KCriteriaSpace() ); |
|
855 strPtr.Append( KCriteriaQuot() ); |
|
856 strPtr.Append( *tmpStr ); //Artist name |
|
857 strPtr.Append( KCriteriaQuot() ); |
|
858 strPtr.Append( KCriteriaSpace() ); |
|
859 strPtr.Append( KCriteriaCB() ); |
|
860 delete tmpStr; |
|
861 tmpStr = NULL; |
|
862 } |
|
863 |
|
864 //Add possibly genres to search criteria |
|
865 if( iGenreText.Length() > 0 && iMediatype == EAdvancedFindMusic ) |
|
866 { |
|
867 __LOG( "add genres condition" ); |
|
868 tmpStr = UpnpString::FromUnicodeL( iGenreText ); |
|
869 |
|
870 searchCriteria = searchCriteria->ReAllocL( |
|
871 searchCriteria->Length() + |
|
872 KCriteriaSpace().Length() + |
|
873 KCriteriaAnd().Length() + |
|
874 KCriteriaSpace().Length() + |
|
875 KCriteriaOB().Length() + |
|
876 KElementGenre().Length() + |
|
877 KCriteriaSpace().Length() + |
|
878 KCriteriaContains().Length() + |
|
879 KCriteriaSpace().Length() + |
|
880 KCriteriaQuot().Length() + |
|
881 tmpStr->Length() + |
|
882 KCriteriaQuot().Length() + |
|
883 KCriteriaSpace().Length() + |
|
884 KCriteriaCB().Length() |
|
885 ); |
|
886 |
|
887 //pop out the old searchCriteria |
|
888 CleanupStack::Pop(); |
|
889 //push the new searchCriteria which is created by ReAllocL |
|
890 CleanupStack::PushL( searchCriteria ); |
|
891 |
|
892 strPtr.Set( searchCriteria->Des() ); |
|
893 strPtr.Append( KCriteriaSpace() ); |
|
894 strPtr.Append( KCriteriaAnd() ); |
|
895 strPtr.Append( KCriteriaSpace() ); |
|
896 strPtr.Append( KCriteriaOB() ); |
|
897 strPtr.Append( KElementGenre() ); |
|
898 strPtr.Append( KCriteriaSpace() ); |
|
899 strPtr.Append( KCriteriaContains() ); |
|
900 strPtr.Append( KCriteriaSpace() ); |
|
901 strPtr.Append( KCriteriaQuot() ); |
|
902 strPtr.Append( *tmpStr ); //Genre name |
|
903 strPtr.Append( KCriteriaQuot() ); |
|
904 strPtr.Append( KCriteriaSpace() ); |
|
905 strPtr.Append( KCriteriaCB() ); |
|
906 delete tmpStr; |
|
907 tmpStr = NULL; |
|
908 } |
|
909 |
|
910 // To check whether need to add time condition |
|
911 TBool addTimeCondition = ETrue; |
|
912 |
|
913 if( iFileName.Length() > 0 ) |
|
914 { |
|
915 __LOG( "iFileName > 0" ); |
|
916 |
|
917 // Make temp TDateTime item with current home time to compare with date |
|
918 // until. |
|
919 TTime tempTTimeforCurrent; |
|
920 tempTTimeforCurrent.HomeTime(); |
|
921 TDateTime tempTDateTimeforCurrent = tempTTimeforCurrent.DateTime(); |
|
922 TDateTime tempTDateTimeforUntil = iDateUntil.DateTime(); |
|
923 TBuf8<KTmpDateFormatLength> tempDateFormatCurrent; |
|
924 TBuf8<KTmpDateFormatLength> tempDateFormatUntil; |
|
925 tempDateFormatCurrent.Format( KTimeFormat8(), |
|
926 tempTDateTimeforCurrent.Year(), |
|
927 tempTDateTimeforCurrent.Month() + 1, |
|
928 tempTDateTimeforCurrent.Day() + 1 ); |
|
929 tempDateFormatUntil.Format( KTimeFormat8(), |
|
930 tempTDateTimeforUntil.Year(), |
|
931 tempTDateTimeforUntil.Month() + 1, |
|
932 tempTDateTimeforUntil.Day() +1 ); |
|
933 |
|
934 if( ( iDateFrom == iDateInitial ) && |
|
935 ( tempDateFormatCurrent == tempDateFormatUntil ) ) |
|
936 { |
|
937 // Time criterias are not included into the find query |
|
938 // if they are not altered when Title search |
|
939 __LOG( "time criterias are not altered" ); |
|
940 addTimeCondition = EFalse; |
|
941 } |
|
942 } |
|
943 |
|
944 if ( addTimeCondition ) |
|
945 { |
|
946 __LOG( "add time conditions" ); |
|
947 |
|
948 // Add time from |
|
949 tmpDate = iDateFrom.DateTime(); |
|
950 //Format the date according to UPnP |
|
951 tmpDateFormat.Format( KTimeFormat8, |
|
952 tmpDate.Year(), |
|
953 tmpDate.Month() + 1, |
|
954 tmpDate.Day() + 1 ); |
|
955 |
|
956 searchCriteria = searchCriteria->ReAllocL( |
|
957 searchCriteria->Length() + |
|
958 KCriteriaSpace().Length() + |
|
959 KCriteriaAnd().Length() + |
|
960 KCriteriaSpace().Length() + |
|
961 KElementDate().Length() + |
|
962 KCriteriaSpace().Length() + |
|
963 KCriteriaGTE().Length() + |
|
964 KCriteriaSpace().Length() + |
|
965 KCriteriaQuot().Length() + |
|
966 tmpDateFormat.Length() + |
|
967 KCriteriaQuot().Length() |
|
968 ); |
|
969 CleanupStack::Pop(); |
|
970 CleanupStack::PushL( searchCriteria ); |
|
971 |
|
972 strPtr.Set( searchCriteria->Des() ); |
|
973 strPtr.Append( KCriteriaSpace() ); |
|
974 strPtr.Append( KCriteriaAnd() ); |
|
975 strPtr.Append( KCriteriaSpace() ); |
|
976 strPtr.Append( KElementDate() ); |
|
977 strPtr.Append( KCriteriaSpace() ); |
|
978 strPtr.Append( KCriteriaGTE() ); |
|
979 strPtr.Append( KCriteriaSpace() ); |
|
980 strPtr.Append( KCriteriaQuot() ); |
|
981 strPtr.Append( tmpDateFormat ); |
|
982 strPtr.Append( KCriteriaQuot() ); |
|
983 |
|
984 // Add time until |
|
985 tmpDate = iDateUntil.DateTime(); |
|
986 tmpDateFormat.Format( KTimeFormat8, |
|
987 tmpDate.Year(), |
|
988 tmpDate.Month() + 1, |
|
989 tmpDate.Day() + 1 ); |
|
990 |
|
991 searchCriteria = searchCriteria->ReAllocL( |
|
992 searchCriteria->Length() + |
|
993 KCriteriaSpace().Length() + |
|
994 KCriteriaAnd().Length() + |
|
995 KCriteriaSpace().Length() + |
|
996 KElementDate().Length() + |
|
997 KCriteriaSpace().Length() + |
|
998 KCriteriaLTE().Length() + |
|
999 KCriteriaSpace().Length() + |
|
1000 KCriteriaQuot().Length() + |
|
1001 tmpDateFormat.Length() + |
|
1002 KCriteriaQuot().Length() |
|
1003 ); |
|
1004 CleanupStack::Pop(); |
|
1005 CleanupStack::PushL( searchCriteria ); |
|
1006 |
|
1007 strPtr.Set( searchCriteria->Des() ); |
|
1008 strPtr.Append( KCriteriaSpace() ); |
|
1009 strPtr.Append( KCriteriaAnd() ); |
|
1010 strPtr.Append( KCriteriaSpace() ); |
|
1011 strPtr.Append( KElementDate() ); |
|
1012 strPtr.Append( KCriteriaSpace() ); |
|
1013 strPtr.Append( KCriteriaLTE() ); |
|
1014 strPtr.Append( KCriteriaSpace() ); |
|
1015 strPtr.Append( KCriteriaQuot() ); |
|
1016 strPtr.Append( tmpDateFormat ); |
|
1017 strPtr.Append( KCriteriaQuot() ); |
|
1018 } |
|
1019 |
|
1020 //Encode the searchcriteria for xml compatibility |
|
1021 HBufC8* xmlEncodedSearchCriteria = |
|
1022 UpnpString::EncodeXmlStringL( searchCriteria ); |
|
1023 |
|
1024 CleanupStack::PopAndDestroy( searchCriteria ); //searchCriteria |
|
1025 |
|
1026 __LOG( "CUPnPAdvancedFindList::BuildSearchCriteriaL - end" ); |
|
1027 return xmlEncodedSearchCriteria; |
|
1028 } |
|
1029 |
|
1030 // -------------------------------------------------------------------------- |
|
1031 // CUPnPAdvancedFindList::IsSettingPageOpen |
|
1032 // -------------------------------------------------------------------------- |
|
1033 // |
|
1034 TBool CUPnPAdvancedFindList::IsSettingPageOpen() const |
|
1035 { |
|
1036 return iSettingPageOpen; |
|
1037 } |
|
1038 |
|
1039 // End of file |
|