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: Source file for UPnP Browse UI Implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 // System |
|
21 #include <featmgr.h> |
|
22 #include <AknIconArray.h> |
|
23 #include <aknnavide.h> |
|
24 #include <eikclbd.h> |
|
25 #include <akntabgrp.h> |
|
26 #include <StringLoader.h> |
|
27 #include <hlplch.h> |
|
28 #include <commondialogs.mbg> |
|
29 #include <AknWaitDialog.h> |
|
30 #include <upnpstring.h> |
|
31 #include <AknDialog.h> |
|
32 #include <akntitle.h> |
|
33 #include <aknlists.h> |
|
34 #include <aknnotewrappers.h> |
|
35 #include <mmf/common/mmfcontrollerpluginresolver.h> |
|
36 #include <httperr.h> |
|
37 |
|
38 // upnp stack api's |
|
39 #include <upnpitem.h> |
|
40 #include <upnpcontainer.h> |
|
41 |
|
42 // upnpframework / avcontroller api |
|
43 #include "upnpavcontroller.h" //start browse session and rendering session |
|
44 #include "upnpavdevice.h" |
|
45 #include "upnpavbrowsingsession.h" |
|
46 #include "upnpavrenderingsession.h" |
|
47 |
|
48 // upnpframework / avcontroller helper api |
|
49 #include "upnpconstantdefs.h" // upnp definitions |
|
50 |
|
51 // upnpframework / xml parser api |
|
52 #include "upnpxmlparser.h" |
|
53 |
|
54 // upnpframework / utility class UPnPItemUtility |
|
55 #include "upnpitemutility.h" |
|
56 |
|
57 // upnpframework / internal api's |
|
58 #include "upnpfiletransferengine.h" |
|
59 #include "upnpmusicadapter.h" |
|
60 #include "upnpbrowseplaylistfiller.h" |
|
61 |
|
62 // common ui internal |
|
63 #include "upnpcommonui.h" |
|
64 #include <upnpcommonui.rsg> |
|
65 #include <upnpcommonui.mbg> |
|
66 #include "upnpcommonutils.h" |
|
67 |
|
68 #include "upnplocalplayer.h" |
|
69 #include "upnpbrowsedialog.h" |
|
70 #include "upnpcommonui.hrh" |
|
71 #include "upnpbrowsecacheitem.h" |
|
72 #include "upnpimageplayer.h" |
|
73 #include "upnpperiodic.h" |
|
74 |
|
75 _LIT( KComponentLogfile, "commonui.txt"); |
|
76 #include "upnplog.h" |
|
77 |
|
78 |
|
79 //CONSTANTS |
|
80 _LIT( KAknCommonUIMbmFileName, "\\resource\\apps\\upnpcommonui.mbm" ); |
|
81 _LIT( KFormatString, "%d\t%S\t\t" ); |
|
82 _LIT( KFormatString2, "%d\t%S\t\t%d" ); |
|
83 _LIT( KUPNP_HLP_REMOTE_DEVICES, "UPNP_HLP_REMOTE_DEVICES" ); |
|
84 _LIT( KUPNP_HLP_CONTENT_VIEW, "UPNP_HLP_CONTENT_VIEW" ); |
|
85 |
|
86 const TInt KBrowseBack = -1; |
|
87 const TInt KBrowseRoot = -2; |
|
88 const TInt KBrowseForward = -3; |
|
89 const TInt KBrowseRequestCount = 20; |
|
90 const TInt KWindowBrowseTricker = 3; |
|
91 |
|
92 const TInt KImageTimerDelay = 800000; |
|
93 const TInt KImageTimerInterval = 800000; |
|
94 |
|
95 const TInt KLength = 100; |
|
96 |
|
97 // CONSTANTS |
|
98 enum TUPnPIconTypes |
|
99 { |
|
100 EUPnPIconFolder = 1, |
|
101 //EUPnPIconFolderLocked, |
|
102 EUPnPIconMusic, |
|
103 EUPnPIconVideo, |
|
104 EUPnPIconImage, |
|
105 EUPnPIconImageShowing, |
|
106 EUPnPIconOther, |
|
107 EUPnPIconLast |
|
108 }; |
|
109 enum TUPnPBrowseDirection |
|
110 { |
|
111 EBackward= 1, |
|
112 EForward |
|
113 }; |
|
114 |
|
115 // ============================ MEMBER FUNCTIONS ============================ |
|
116 |
|
117 // -------------------------------------------------------------------------- |
|
118 // CUPnPBrowseDialog::NewL |
|
119 // Two-phased constructor. |
|
120 // -------------------------------------------------------------------------- |
|
121 CUPnPBrowseDialog* CUPnPBrowseDialog::NewL( TInt aMenuResource, |
|
122 MUPnPAVController& aAVControl, |
|
123 const CUpnpAVDevice& aDevice, |
|
124 CUPnPCommonUI& aCommonUI) |
|
125 { |
|
126 __LOG( "CUPnPBrowseDialog::NewL" ); |
|
127 |
|
128 CUPnPBrowseDialog* self = new (ELeave) CUPnPBrowseDialog( |
|
129 aAVControl, aCommonUI, aDevice ); |
|
130 CleanupStack::PushL( self ); |
|
131 self->ConstructL( aMenuResource ); |
|
132 |
|
133 CleanupStack::Pop( self ); |
|
134 |
|
135 __LOG( "CUPnPBrowseDialog::NewL-END" ); |
|
136 return self; |
|
137 } |
|
138 |
|
139 // -------------------------------------------------------------------------- |
|
140 // CUPnPBrowseDialog::ConstructL |
|
141 // Symbian 2nd phase constructor can leave. |
|
142 // -------------------------------------------------------------------------- |
|
143 void CUPnPBrowseDialog::ConstructL( TInt aMenuResource ) |
|
144 |
|
145 { |
|
146 // Register as an observer to file operations (browse results) |
|
147 |
|
148 __LOG( "CUPnPBrowseDialog::ConstructL" ); |
|
149 |
|
150 iBrowseSession = &iAVControl.StartBrowsingSessionL( iSourceDevice ); |
|
151 iBrowseSession->SetObserver( *this ); |
|
152 |
|
153 iFirstResultArray = ETrue; |
|
154 CAknDialog::ConstructL( aMenuResource ); |
|
155 |
|
156 iTargetDevice = CUpnpAVDevice::NewL(); |
|
157 iImageControlTimer = CUPnPPeriodic::NewL( CActive::EPriorityUserInput ); |
|
158 |
|
159 iError = KErrNone; |
|
160 iDlgPreLayoutDone = EFalse; |
|
161 iErrorForCancel = KErrNone; |
|
162 __LOG( "CUPnPBrowseDialog::ConstructL-END" ); |
|
163 } |
|
164 |
|
165 // -------------------------------------------------------------------------- |
|
166 // CUPnPBrowseDialog::CUPnPBrowseDialog |
|
167 // C++ default constructor can NOT contain any code, that |
|
168 // might leave. |
|
169 // -------------------------------------------------------------------------- |
|
170 CUPnPBrowseDialog::CUPnPBrowseDialog( MUPnPAVController& aAVControl, |
|
171 CUPnPCommonUI& aCommonUI, |
|
172 const CUpnpAVDevice& aDevice ): |
|
173 iCommonUI( aCommonUI ), |
|
174 iAVControl( aAVControl ), |
|
175 iSourceDevice(aDevice) |
|
176 { |
|
177 __LOG( "CUPnPBrowseDialog::CUPnPBrowseDialog" ); |
|
178 |
|
179 iBrowseRequestSent = EFalse; |
|
180 iChildDialogOpen = 0; |
|
181 iLastImageItemIndex = KErrNotFound; |
|
182 iMSDisappear = EFalse; |
|
183 iAction = CUPnPCommonUI::EUPnPNone; |
|
184 iCopyIndex = NULL; |
|
185 iRoot = ETrue; |
|
186 |
|
187 iIsMusicItem = EFalse; |
|
188 iHashKeyFlag = EFalse; |
|
189 __LOG( "CUPnPBrowseDialog::CUPnPBrowseDialog-END" ); |
|
190 } |
|
191 |
|
192 // -------------------------------------------------------------------------- |
|
193 // CUPnPBrowseDialog::~CUPnPBrowseDialog |
|
194 // C++ default destructor can NOT contain any code, that |
|
195 // might leave. |
|
196 // -------------------------------------------------------------------------- |
|
197 CUPnPBrowseDialog::~CUPnPBrowseDialog() |
|
198 { |
|
199 __LOG( "CUPnPBrowseDialog::~CUPnPBrowseDialog" ); |
|
200 // Unregister as an observer to file operations (browse results) |
|
201 TRAPD( err, DismissWaitNoteL() ); |
|
202 if ( err != KErrNone ) |
|
203 { |
|
204 __LOG( "CUPnPBrowseDialog::~CUPnPBrowseDialog \ |
|
205 delete WaitNote error" ); |
|
206 } |
|
207 |
|
208 if ( iCurrentFolderId && !iBrowseRequestSent ) |
|
209 { |
|
210 TRAP_IGNORE( CacheItemUpdateL( *iCurrentFolderId, EFalse ) ); |
|
211 } |
|
212 |
|
213 delete iCurrentFolderId; |
|
214 |
|
215 delete iTargetDevice; |
|
216 delete iImagePlayer; |
|
217 iParentId.ResetAndDestroy(); |
|
218 iParentName.ResetAndDestroy(); |
|
219 iResultArray.Close(); |
|
220 iBrowseCacheItems.ResetAndDestroy(); |
|
221 iTempArray.Close(); |
|
222 if ( iNaviPane && iNaviDecorator ) |
|
223 { |
|
224 iNaviPane->Pop( iNaviDecorator ); |
|
225 } |
|
226 |
|
227 delete iNaviDecorator; |
|
228 |
|
229 iSelectedItemsArray.ResetAndDestroy(); |
|
230 |
|
231 if ( iImageControlTimer ) |
|
232 { |
|
233 iImageControlTimer->Cancel(); |
|
234 delete iImageControlTimer; |
|
235 } |
|
236 |
|
237 delete iLocalPlayer; |
|
238 |
|
239 if( iBrowseSession ) |
|
240 { |
|
241 iBrowseSession->CancelBrowse(); |
|
242 iBrowseSession->RemoveObserver(); |
|
243 iAVControl.StopBrowsingSession( *iBrowseSession ); |
|
244 } |
|
245 |
|
246 __LOG( "CUPnPBrowseDialog::~CUPnPBrowseDialog-END" ); |
|
247 } |
|
248 |
|
249 // -------------------------------------------------------------------------- |
|
250 // CUPnPBrowseDialog::DialogDismissedL(); |
|
251 // MProgressDialogCallback, progressbar callback function |
|
252 // -------------------------------------------------------------------------- |
|
253 void CUPnPBrowseDialog::DialogDismissedL( TInt aButtonId ) |
|
254 { |
|
255 __LOG( "CUPnPBrowseDialog::DialogDismissedL" ); |
|
256 // If button is cancel, inform observer parent class |
|
257 // that cancel has been made |
|
258 if( aButtonId == EEikBidCancel ) |
|
259 { |
|
260 __LOG( "CUPnPBrowseDialog::DialogDismissedL: \ |
|
261 Cancel was pressed."); |
|
262 iAction = CUPnPCommonUI::EUPnPNone; |
|
263 iBrowseSession->CancelBrowse(); |
|
264 iBrowseRequestSent = EFalse; |
|
265 |
|
266 TInt cachedItemIndex = CacheCheck( *iCurrentFolderId ); |
|
267 |
|
268 if ( cachedItemIndex > -1 ) |
|
269 { |
|
270 delete iBrowseCacheItems[ cachedItemIndex ]; |
|
271 iBrowseCacheItems[ cachedItemIndex ] = NULL; |
|
272 iBrowseCacheItems.Remove( cachedItemIndex ); |
|
273 iBrowseCacheItems.Compress(); |
|
274 } |
|
275 // If button is cancel, |
|
276 // the browse dialog should not been displayed,leave it in the |
|
277 // function of PreLayoutDynInitL. |
|
278 iErrorForCancel = EEikBidCancel; |
|
279 } |
|
280 __LOG( "CUPnPBrowseDialog::DialogDismissedL-END" ); |
|
281 } |
|
282 |
|
283 // -------------------------------------------------------------------------- |
|
284 // CUPnPBrowseDialog::PreLayoutDynInitL(); |
|
285 // called by framework before dialog is shown |
|
286 // -------------------------------------------------------------------------- |
|
287 void CUPnPBrowseDialog::PreLayoutDynInitL() |
|
288 { |
|
289 __LOG( "CUPnPBrowseDialog::PreLayoutDynInitL" ); |
|
290 |
|
291 // Browse dialog title text |
|
292 TUid titlePaneUid; |
|
293 titlePaneUid.iUid = EEikStatusPaneUidTitle; |
|
294 CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
295 CEikStatusPaneBase::TPaneCapabilities titlesubPane = |
|
296 statusPane->PaneCapabilities( titlePaneUid ); |
|
297 |
|
298 if ( titlesubPane.IsPresent() && titlesubPane.IsAppOwned() ) |
|
299 { |
|
300 iTitlePane = (CAknTitlePane*) statusPane->ControlL( titlePaneUid ); |
|
301 |
|
302 // Get device friendly name and replace illegal characters. |
|
303 HBufC8* tmpfriendlyname = |
|
304 UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( |
|
305 iSourceDevice.FriendlyName() ); |
|
306 |
|
307 CleanupStack::PushL( tmpfriendlyname ); |
|
308 TPtrC8 friendlyname = *tmpfriendlyname; |
|
309 |
|
310 HBufC *tmpbuf = UpnpString::ToUnicodeL( |
|
311 friendlyname.Left( KLength ) ); |
|
312 CleanupStack::PushL( tmpbuf ); |
|
313 iTitlePane->SetTextL( *tmpbuf ); |
|
314 |
|
315 CleanupStack::PopAndDestroy( tmpbuf ); |
|
316 CleanupStack::PopAndDestroy( tmpfriendlyname ); |
|
317 } |
|
318 |
|
319 iListBox = static_cast<CAknSingleGraphicStyleListBox*>( |
|
320 Control( EUPnPBrowseListBoxId ) ); |
|
321 iListBox->CreateScrollBarFrameL( ETrue ); |
|
322 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
323 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto ); |
|
324 |
|
325 iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue ); |
|
326 CAknIconArray* icons = new ( ELeave ) CAknIconArray( EUPnPIconLast ); |
|
327 CleanupStack::PushL( icons ); |
|
328 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
329 |
|
330 TFileName mbmFileName( KAknCommonUIMbmFileName ); |
|
331 TFileName dllName; |
|
332 Dll::FileName( dllName ); |
|
333 TBuf<2> drive = dllName.Left( 2 ); // Drive letter followed by ':' |
|
334 mbmFileName.Insert( 0, drive ); |
|
335 |
|
336 AppendIconToArrayL( icons, |
|
337 skin, |
|
338 KAvkonBitmapFile, |
|
339 KAknsIIDQgnIndiMarkedAdd, |
|
340 EMbmAvkonQgn_indi_marked_add, |
|
341 EMbmAvkonQgn_indi_marked_add_mask ); |
|
342 |
|
343 // Folder icon |
|
344 AppendIconToArrayL( icons, |
|
345 skin, |
|
346 mbmFileName, |
|
347 KAknsIIDQgnPropFolderSmall, |
|
348 EMbmUpnpcommonuiQgn_prop_mserv_folder_small, |
|
349 EMbmUpnpcommonuiQgn_prop_mserv_folder_small_mask ); |
|
350 |
|
351 |
|
352 // Music icon |
|
353 AppendIconToArrayL( icons, |
|
354 skin, |
|
355 mbmFileName, |
|
356 KAknsIIDDefault, |
|
357 EMbmUpnpcommonuiQgn_prop_mserv_music, |
|
358 EMbmUpnpcommonuiQgn_prop_mserv_music_mask ); |
|
359 |
|
360 // Video icon |
|
361 AppendIconToArrayL( icons, |
|
362 skin, |
|
363 mbmFileName, |
|
364 KAknsIIDDefault, |
|
365 EMbmUpnpcommonuiQgn_prop_mserv_other_videos, |
|
366 EMbmUpnpcommonuiQgn_prop_mserv_other_videos_mask ); |
|
367 |
|
368 // Image icon |
|
369 AppendIconToArrayL( icons, |
|
370 skin, |
|
371 mbmFileName, |
|
372 KAknsIIDDefault, |
|
373 EMbmUpnpcommonuiQgn_prop_mserv_other_images, |
|
374 EMbmUpnpcommonuiQgn_prop_mserv_other_images_mask ); |
|
375 |
|
376 //Image showing icon |
|
377 AppendIconToArrayL( icons, |
|
378 skin, |
|
379 mbmFileName, |
|
380 KAknsIIDDefault, |
|
381 EMbmUpnpcommonuiQgn_graf_upnp_ext_renderer_list_icon, |
|
382 EMbmUpnpcommonuiQgn_graf_upnp_ext_renderer_list_icon_mask ); |
|
383 |
|
384 |
|
385 // Other icon |
|
386 AppendIconToArrayL( icons, |
|
387 skin, |
|
388 KCommonDialogsBitmapFile, |
|
389 KAknsIIDQgnPropFmgrFileSound, |
|
390 EMbmCommondialogsQgn_prop_fmgr_file_other, |
|
391 EMbmCommondialogsQgn_prop_fmgr_file_other_mask ); |
|
392 |
|
393 iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons ); |
|
394 |
|
395 CleanupStack::Pop(icons); |
|
396 |
|
397 // Hide "No data" text |
|
398 iListBox->View()->SetListEmptyTextL( KNullDesC() ); |
|
399 |
|
400 // Send browse request |
|
401 SendBrowseRequestL( KBrowseRoot ); |
|
402 |
|
403 iDlgPreLayoutDone = ETrue; |
|
404 |
|
405 if( iError < KErrNone ) |
|
406 { |
|
407 __LOG1( "CUPnPBrowseDialog::PreLayoutDynInitL leave %d", iError ); |
|
408 User::Leave( iError ); |
|
409 } |
|
410 |
|
411 if( iErrorForCancel == EEikBidCancel ) |
|
412 { |
|
413 User::Leave( EEikBidCancel ); |
|
414 } |
|
415 __LOG( "CUPnPBrowseDialog::PreLayoutDynInitL-END" ); |
|
416 |
|
417 } |
|
418 |
|
419 // -------------------------------------------------------------------------- |
|
420 // CUPnPBrowseDialog::OkToExitL( TInt aButtonId ) |
|
421 // called by framework when the softkey is pressed |
|
422 // -------------------------------------------------------------------------- |
|
423 TBool CUPnPBrowseDialog::OkToExitL( TInt aButtonId ) |
|
424 { |
|
425 __LOG( "CUPnPBrowseDialog::OkToExitL" ); |
|
426 |
|
427 TBool returnValue = EFalse; |
|
428 TInt error = KErrNone; |
|
429 switch (aButtonId ) |
|
430 { |
|
431 // Connection failed. Dialog must be closed |
|
432 case KErrDisconnected: |
|
433 case KErrSessionClosed: //fall through |
|
434 { |
|
435 // exit only if PreLayoutDynInitL is done |
|
436 if( iDlgPreLayoutDone ) |
|
437 { |
|
438 return ETrue; |
|
439 } |
|
440 else |
|
441 { |
|
442 return EFalse; |
|
443 } |
|
444 } |
|
445 case EAknSoftkeyOptions: |
|
446 { |
|
447 SelectedArrayCheckL(); |
|
448 DisplayMenuL(); |
|
449 break; |
|
450 } |
|
451 case EUPnPStopCmd: |
|
452 { |
|
453 StopImageControlL(); |
|
454 break; |
|
455 } |
|
456 case EAknSoftkeyBack: |
|
457 { |
|
458 // Check if we are in the root |
|
459 if ( !iParentId.Count() ) |
|
460 { |
|
461 ClearTitleL(); |
|
462 return ETrue; |
|
463 } |
|
464 else |
|
465 { |
|
466 if ( iBrowseRequestSent ) |
|
467 { |
|
468 iBrowseSession->CancelBrowse(); |
|
469 iBrowseRequestSent = EFalse; |
|
470 } |
|
471 |
|
472 iListBox->ClearSelection(); |
|
473 iSelectedItemsArray.ResetAndDestroy(); |
|
474 SendBrowseRequestL( KBrowseBack ); |
|
475 } |
|
476 |
|
477 break; |
|
478 } |
|
479 case EUPnPPlayCmd: //for lsk only, play on external renderer |
|
480 { |
|
481 if( !iMusicPlay ) |
|
482 { |
|
483 StopImageControlL(); |
|
484 TRAP( error, PlayL( EFalse ) ); |
|
485 if( KErrNone != error ) |
|
486 { |
|
487 iMusicPlay = EFalse; |
|
488 } |
|
489 } |
|
490 |
|
491 break; |
|
492 } |
|
493 case EAknSoftkeyOpen: //fall thougth |
|
494 case EAknSoftkeyOk: |
|
495 { |
|
496 // Shift and Ok pressed so the external device dialog must not be |
|
497 // opened |
|
498 if ( iShiftAndOkPressed ) |
|
499 { |
|
500 iShiftAndOkPressed = EFalse; |
|
501 return EFalse; |
|
502 } |
|
503 if ( !iResultArray.Count() || iImageControlActive ) |
|
504 { |
|
505 return EFalse; // Do nothing if empty |
|
506 } |
|
507 else if ( iResultArray[iListBox->CurrentItemIndex()]-> |
|
508 ObjectType() == EUPnPContainer ) |
|
509 { |
|
510 if ( !iBrowseRequestSent ) |
|
511 { |
|
512 iListBox->ClearSelection(); |
|
513 iSelectedItemsArray.ResetAndDestroy(); |
|
514 SendBrowseRequestL( iListBox->CurrentItemIndex() ); |
|
515 } |
|
516 } |
|
517 else |
|
518 { |
|
519 // Play or Show on external device |
|
520 // Select device according to the media type |
|
521 TRAP( error, ShowPlayExtL() ); |
|
522 |
|
523 /* if something happens, set iMusicPlay = EFalse, |
|
524 * no matter what kinda of media file playing |
|
525 * before |
|
526 */ |
|
527 |
|
528 if( KErrNone != error ) |
|
529 { |
|
530 iMusicPlay = EFalse; |
|
531 } |
|
532 } |
|
533 break; |
|
534 } |
|
535 case EAknSoftkeyShow: |
|
536 { |
|
537 StopImageControlL(); |
|
538 TRAP( error, ShowVideoDialogExtL() ); |
|
539 break; |
|
540 } |
|
541 case EAknSoftkeyCancel: |
|
542 case EAknSoftkeyExit: |
|
543 case EAknCmdExit: |
|
544 case EEikCmdExit: //fall through |
|
545 { |
|
546 ClearTitleL(); |
|
547 return ETrue; //back to previous dialog |
|
548 } |
|
549 default: |
|
550 { |
|
551 break; |
|
552 } |
|
553 }//switch |
|
554 |
|
555 HandleErrorL( error ); |
|
556 __LOG( "CUPnPBrowseDialog::OkToExitL End" ); |
|
557 |
|
558 return returnValue; |
|
559 } |
|
560 |
|
561 // -------------------------------------------------------------------------- |
|
562 // CUPnPBrowseDialog::OfferKeyEventL(); |
|
563 // called by framework when key is pressed |
|
564 // -------------------------------------------------------------------------- |
|
565 TKeyResponse CUPnPBrowseDialog::OfferKeyEventL( |
|
566 const TKeyEvent &aKeyEvent, |
|
567 TEventCode aType ) |
|
568 { |
|
569 __LOG( "CUPnPBrowseDialog::OfferKeyEventL" ); |
|
570 TInt currentItemIndex = iListBox->CurrentItemIndex(); |
|
571 TInt tempCounter = currentItemIndex; |
|
572 // Shift and Ok pressed at same time so the event must consumed |
|
573 if ( ( aKeyEvent.iModifiers & EModifierShift ) != 0 && |
|
574 aType == EEventKeyDown && ( aKeyEvent.iScanCode == EStdKeyDevice3 ) ) |
|
575 { |
|
576 iShiftAndOkPressed = ETrue; |
|
577 return EKeyWasConsumed; |
|
578 } |
|
579 if ( aType != EEventKey ) |
|
580 { |
|
581 if ( aKeyEvent.iScanCode == EStdKeyHash ) |
|
582 { |
|
583 if ( aType == EEventKeyDown ) |
|
584 { |
|
585 iHashKeyFlag = ETrue; |
|
586 } |
|
587 else |
|
588 { |
|
589 iHashKeyFlag = EFalse; |
|
590 } |
|
591 } |
|
592 CAknDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
593 if ( aType == EEventKeyUp && !iHashKeyFlag ) |
|
594 { |
|
595 if ( ( tempCounter < iResultArray.Count() ) && tempCounter > -1 ) |
|
596 { |
|
597 |
|
598 if ( !iImageControlActive ) |
|
599 { |
|
600 const CArrayFix<TInt>* indexes = |
|
601 iListBox->SelectionIndexes(); |
|
602 if ( indexes->Count() ) |
|
603 { |
|
604 UpdateCommandButtonAreaL( ETrue, tempCounter ); |
|
605 } |
|
606 else |
|
607 { |
|
608 UpdateCommandButtonAreaL( EFalse, tempCounter ); |
|
609 } |
|
610 } |
|
611 |
|
612 } |
|
613 } |
|
614 return EKeyWasConsumed; |
|
615 } |
|
616 |
|
617 // Shift (pen) key cannot be used marking folders |
|
618 if ( currentItemIndex < 0 ) |
|
619 { |
|
620 currentItemIndex = 0; |
|
621 } |
|
622 |
|
623 |
|
624 if ( ( aKeyEvent.iCode == EKeyUpArrow ) && |
|
625 ( currentItemIndex == 0 ) ) |
|
626 { |
|
627 return EKeyWasConsumed; |
|
628 } |
|
629 |
|
630 CTextListBoxModel* model = iListBox->Model(); |
|
631 TInt numberOfItems = model->NumberOfItems(); |
|
632 |
|
633 if ( iAllObjectsReceived && ( currentItemIndex == numberOfItems-1 ) |
|
634 && aKeyEvent.iCode == EKeyDownArrow ) |
|
635 { |
|
636 return EKeyWasConsumed; |
|
637 } |
|
638 |
|
639 // If selection is approaching the end of the list |
|
640 if ( ( aKeyEvent.iCode == EKeyDownArrow ) && ( !iRoot ) && |
|
641 ( ( currentItemIndex + KWindowBrowseTricker ) >= numberOfItems ) && |
|
642 ( iUppermostItem + numberOfItems < iTotalCount ) && |
|
643 ( !iAllObjectsReceived ) && |
|
644 ( !iBrowseRequestSent ) ) |
|
645 { |
|
646 TInt startIndex = iUppermostItem + numberOfItems; |
|
647 iAction = CUPnPCommonUI::EUPnPBrowse; |
|
648 iOriginalBrowseRequest = ETrue; |
|
649 iBrowseSession->BrowseL( *iCurrentFolderId, |
|
650 KFilterCommon, /* filter */ |
|
651 MUPnPAVBrowsingSession::EDirectChildren, |
|
652 startIndex, /* start index */ |
|
653 KBrowseRequestCount, /* request count */ |
|
654 KSortNone ); /* sort criteria */ |
|
655 iBrowseRequestSent = ETrue; |
|
656 iCurrentItem = currentItemIndex; |
|
657 iBrowseDirection = EForward; |
|
658 } |
|
659 if ( ( aKeyEvent.iCode == EKeyUpArrow ) && ( !iRoot ) && |
|
660 ( ( (currentItemIndex - KWindowBrowseTricker ) <= 0 ) ) && |
|
661 ( !iBrowseRequestSent ) && ( iUppermostItem > 0 ) ) |
|
662 { |
|
663 TInt requestCount = KBrowseRequestCount; |
|
664 TInt startIndex = KErrNotFound; |
|
665 |
|
666 // To keep order of items of listbox don't change. |
|
667 if ( iNeedRepeatRequest ) |
|
668 { |
|
669 startIndex = iUppermostItem - iServerReturnObjectCount; |
|
670 requestCount = iServerReturnObjectCount; |
|
671 if ( startIndex < 0 ) |
|
672 { |
|
673 startIndex = 0; |
|
674 } |
|
675 } |
|
676 else |
|
677 { |
|
678 startIndex = iUppermostItem - KBrowseRequestCount; |
|
679 if ( startIndex < 0 ) |
|
680 { |
|
681 requestCount = iUppermostItem; |
|
682 startIndex = 0; |
|
683 } |
|
684 } |
|
685 iAction = CUPnPCommonUI::EUPnPBrowse; |
|
686 iOriginalBrowseRequest = ETrue; |
|
687 iBrowseSession->BrowseL( *iCurrentFolderId, |
|
688 KFilterCommon, /* filter */ |
|
689 MUPnPAVBrowsingSession::EDirectChildren, |
|
690 startIndex, /* start index */ |
|
691 requestCount, /* request count */ |
|
692 KSortNone ); /* sort criteria */ |
|
693 |
|
694 iBrowseRequestSent = ETrue; |
|
695 iCurrentItem = currentItemIndex; |
|
696 iBrowseDirection = EBackward; |
|
697 |
|
698 if ( iAllObjectsReceived ) |
|
699 { |
|
700 iAllObjectsReceived = EFalse; |
|
701 } |
|
702 |
|
703 } |
|
704 |
|
705 // it is checked that currentItemIndex is valid |
|
706 iCurrentItem = currentItemIndex; |
|
707 |
|
708 if ( ( aKeyEvent.iCode == EKeyDownArrow) && |
|
709 ( currentItemIndex + 1) == numberOfItems ) |
|
710 { |
|
711 return EKeyWasConsumed; |
|
712 } |
|
713 |
|
714 else if ( ( aKeyEvent.iCode == EKeyUpArrow) && |
|
715 ( currentItemIndex == 0 ) && |
|
716 ( iBrowseRequestSent ) ) |
|
717 { |
|
718 return EKeyWasConsumed; |
|
719 } |
|
720 else if ( aKeyEvent.iCode == EKeyDownArrow ) |
|
721 { |
|
722 if ( ( numberOfItems - 1 ) > iCurrentItem ) |
|
723 { |
|
724 iCurrentItem++; |
|
725 } |
|
726 else |
|
727 { |
|
728 iCurrentItem = 0; |
|
729 } |
|
730 } |
|
731 else if ( aKeyEvent.iCode == EKeyUpArrow ) |
|
732 { |
|
733 //if already if first item, should then go to the last one. |
|
734 if ( iCurrentItem > 0 ) |
|
735 { |
|
736 iCurrentItem--; |
|
737 } |
|
738 } |
|
739 |
|
740 if ( aKeyEvent.iCode == EKeyDownArrow || |
|
741 aKeyEvent.iCode == EKeyUpArrow ) |
|
742 { |
|
743 if ( iImageControlActive ) |
|
744 { |
|
745 iImageControlTimer->Cancel(); |
|
746 StartImageControlTimer(); |
|
747 } |
|
748 if ( aKeyEvent.iCode == EKeyDownArrow ) |
|
749 { |
|
750 tempCounter++; |
|
751 } |
|
752 else |
|
753 { |
|
754 tempCounter--; |
|
755 } |
|
756 if ( ( tempCounter < iResultArray.Count() ) && tempCounter > -1 ) |
|
757 { |
|
758 if( iImageControlActive ) |
|
759 { |
|
760 // image or container |
|
761 if ( ( iResultArray[tempCounter] )->ObjectClass() |
|
762 .Find( KClassImage ) == 0 || |
|
763 ( iResultArray[tempCounter] )->ObjectClass() |
|
764 .Find( KClassContainer ) == 0 ) |
|
765 { |
|
766 UpdateSoftkeysL( R_UPNPCOMMONUI_SOFTKEYS_EMPTY_STOP ); |
|
767 } |
|
768 else if ( ( iResultArray[tempCounter] )->ObjectClass() |
|
769 .Find( KClassVideo ) == 0 ) //video |
|
770 { |
|
771 UpdateSoftkeysL( R_UPNPCOMMONUI_SOFTKEYS_SHOW_STOP ); |
|
772 } |
|
773 else if ( ( iResultArray[tempCounter] )->ObjectClass() |
|
774 .Find( KClassAudio ) == 0 ) //music |
|
775 { |
|
776 UpdateSoftkeysL( R_UPNPCOMMONUI_SOFTKEYS_PLAY_STOP ); |
|
777 } |
|
778 else |
|
779 { |
|
780 UpdateSoftkeysL( R_UPNPCOMMONUI_SOFTKEYS_EMPTY_STOP ); |
|
781 } |
|
782 } |
|
783 } |
|
784 } |
|
785 |
|
786 if ( ( currentItemIndex >= 0 ) && |
|
787 ( currentItemIndex < iListBox->Model()->NumberOfItems() ) ) |
|
788 { |
|
789 if ( ( ( iResultArray[currentItemIndex])->ObjectType() |
|
790 != EUPnPContainer) || |
|
791 !( aKeyEvent.iModifiers & EModifierShift ) ) |
|
792 { |
|
793 if( aKeyEvent.iCode == EKeyEscape ) |
|
794 { |
|
795 __LOG( "OfferKeyEventL EKeyEscape" ); |
|
796 if( !iCopying ) |
|
797 { |
|
798 CAknDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
799 } |
|
800 else |
|
801 { |
|
802 __LOG( "Copying ongoing, app should be closed" ); |
|
803 iApplicationClose = ETrue; |
|
804 __LOG( "Copying ongoing, app should be closed-end" ); |
|
805 } |
|
806 __LOG( "OfferKeyEventL EKeyEscape -end" ); |
|
807 } |
|
808 else |
|
809 { |
|
810 CAknDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
811 } |
|
812 } |
|
813 } |
|
814 |
|
815 // no items in list, all events can be handled by system |
|
816 else if ( iListBox->Model()->NumberOfItems() == 0) |
|
817 { |
|
818 CAknDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
819 } |
|
820 |
|
821 |
|
822 __LOG( "CUPnPBrowseDialog::OfferKeyEventL End" ); |
|
823 return EKeyWasConsumed; |
|
824 } |
|
825 |
|
826 // -------------------------------------------------------------------------- |
|
827 // CUPnPBrowseDialog::ProcessCommandL( TInt aCommand ) |
|
828 // called by framework when menu item is selected |
|
829 // -------------------------------------------------------------------------- |
|
830 void CUPnPBrowseDialog::ProcessCommandL( TInt aCommand ) |
|
831 { |
|
832 __LOG( "CUPnPBrowseDialog::ProcessCommandL" ); |
|
833 |
|
834 TInt error = KErrNone; |
|
835 TInt selected_item = iListBox->CurrentItemIndex(); |
|
836 if ( selected_item < 0 ) |
|
837 { |
|
838 selected_item = 0; |
|
839 } |
|
840 |
|
841 // Menu commands control |
|
842 HideMenu(); |
|
843 switch ( aCommand ) |
|
844 { |
|
845 case EAknCmdExit: |
|
846 case EEikCmdExit:// fall through |
|
847 { |
|
848 TryExitL( aCommand ); |
|
849 return; |
|
850 } |
|
851 case EUPnPOpen: |
|
852 { |
|
853 if ( iResultArray[selected_item]->ObjectType() == EUPnPContainer) |
|
854 { |
|
855 iListBox->ClearSelection(); |
|
856 iSelectedItemsArray.ResetAndDestroy(); |
|
857 SendBrowseRequestL( selected_item ); |
|
858 } |
|
859 break; |
|
860 } |
|
861 case EUPnPFind: |
|
862 { |
|
863 if ( iNaviDecorator ) |
|
864 { |
|
865 iNaviPane->Pop( iNaviDecorator ); |
|
866 delete iNaviDecorator; |
|
867 iNaviDecorator = NULL; |
|
868 } |
|
869 // cancel idle timer because player uses own timer |
|
870 error = iCommonUI.ExecuteAdvFindDialogL( iAVControl, |
|
871 *iBrowseSession ); |
|
872 |
|
873 //only MS or WLAN lost can make advfind dlg exit |
|
874 if( KErrSessionClosed == error ) |
|
875 { |
|
876 iMSDisappear = ETrue; |
|
877 } |
|
878 |
|
879 //if not media server or wlan lost, update its navipane |
|
880 if( !iMSDisappear && error != KErrDisconnected ) |
|
881 { |
|
882 UpdateNaviPaneTextL(); |
|
883 } |
|
884 |
|
885 break; |
|
886 } |
|
887 case EUPnPHelp: |
|
888 { |
|
889 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), |
|
890 iEikonEnv->EikAppUi()->AppHelpContextL() ); |
|
891 break; |
|
892 } |
|
893 case EUPnPPlayExt: |
|
894 case EUPnPShowExt: //fall through |
|
895 { |
|
896 TRAP( error, ShowPlayExtL() ); |
|
897 if( KErrNone != error ) |
|
898 { |
|
899 iMusicPlay = EFalse; |
|
900 } |
|
901 break; |
|
902 } |
|
903 case EUPnPShowLocal: //show image & video on local |
|
904 { |
|
905 if( !iLocalPlayer ) |
|
906 { |
|
907 iLocalPlayer = CUPnPLocalPlayer::NewL( iAVControl, |
|
908 *iBrowseSession, |
|
909 iCommonUI ); |
|
910 } |
|
911 const CUpnpObject* item = |
|
912 iResultArray[ iListBox->CurrentItemIndex() ]; |
|
913 |
|
914 iAction = CUPnPCommonUI::EUPnPShow; |
|
915 TRAP( error, iLocalPlayer->PlayL( *item ) ); |
|
916 if( KErrSessionClosed == error ) |
|
917 { |
|
918 iMSDisappear = ETrue; |
|
919 } |
|
920 break; |
|
921 } |
|
922 case EUPnPPlayLocal: //play music on local |
|
923 { |
|
924 if( ( iResultArray[ iListBox->CurrentItemIndex() ] |
|
925 ->ObjectClass().Find( KClassAudio ) == 0 || |
|
926 iIsMusicItem ) && !iMusicPlay ) |
|
927 { |
|
928 TRAP( error, PlayL( ETrue ) ); |
|
929 if( KErrNone != error ) |
|
930 { |
|
931 iMusicPlay = EFalse; |
|
932 } |
|
933 } |
|
934 break; |
|
935 } |
|
936 case EUPnPCopy: |
|
937 { |
|
938 TRAP( error, HandleCopyL() ); |
|
939 iCopying = EFalse; |
|
940 __LOG1( "HandleCopyL is finished: %d", error ); |
|
941 if( iApplicationClose ) |
|
942 { |
|
943 __LOG( "copying is onging, exit" ); |
|
944 TryExitL( EAknCmdExit ); |
|
945 return; |
|
946 } |
|
947 |
|
948 //During copying, sometimes we get the httperr, |
|
949 //but doesn't handle it, at here I transfer the httperr |
|
950 //to symbian error. |
|
951 if ( KErrHttpPartialResponseReceived == error || |
|
952 KErrHttpRequestNotSent == error || |
|
953 KErrHttpResponseNotReceived == error ) |
|
954 { |
|
955 error = KErrSessionClosed; |
|
956 } |
|
957 |
|
958 __LOG1( "CUPnPBrowseDialog::HandleCopyL: %d", error ); |
|
959 |
|
960 if( KErrSessionClosed == error ) //if server lost |
|
961 { |
|
962 iMSDisappear = ETrue; |
|
963 } |
|
964 else if( KErrNotFound == error ) |
|
965 { |
|
966 if( iResultArray[iListBox->CurrentItemIndex()]-> |
|
967 ObjectType() == EUPnPContainer ) |
|
968 { |
|
969 if( iCopyIndex > 0 ) //if the container is not empty |
|
970 { |
|
971 iCommonUI.DisplayErrorTextL( |
|
972 R_UPNPCOMMONUI_GENERAL_FAILURE_ERROR_TEXT ); |
|
973 iAction = CUPnPCommonUI::EUPnPNone; |
|
974 } |
|
975 else //if the container is empty |
|
976 { |
|
977 iCopyIndex = ETrue; |
|
978 } |
|
979 |
|
980 } |
|
981 else |
|
982 { |
|
983 iCopyIndex = EFalse; |
|
984 } |
|
985 } |
|
986 break; |
|
987 } |
|
988 case EAknCmdMark: |
|
989 { |
|
990 MarkItemL( iListBox->CurrentItemIndex() ); |
|
991 break; |
|
992 } |
|
993 case EAknMarkAll: |
|
994 { |
|
995 MarkAllItemsL(); |
|
996 break; |
|
997 } |
|
998 case EAknCmdUnmark: |
|
999 { |
|
1000 UnmarkItem( iListBox->CurrentItemIndex() ); |
|
1001 break; |
|
1002 } |
|
1003 case EAknUnmarkAll: |
|
1004 { |
|
1005 UnmarkAllItems(); |
|
1006 break; |
|
1007 } |
|
1008 default: |
|
1009 { |
|
1010 CAknDialog::ProcessCommandL( aCommand ); |
|
1011 break; |
|
1012 } |
|
1013 } |
|
1014 |
|
1015 HandleErrorL( error ); |
|
1016 __LOG( "CUPnPBrowseDialog::ProcessCommandL End" ); |
|
1017 } |
|
1018 |
|
1019 // -------------------------------------------------------------------------- |
|
1020 // CUPnPBrowseDialog::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane |
|
1021 // *aMenuPane) |
|
1022 // called by framework before menu panel is shown |
|
1023 // -------------------------------------------------------------------------- |
|
1024 void CUPnPBrowseDialog::DynInitMenuPaneL( TInt aResourceId, |
|
1025 CEikMenuPane *aMenuPane ) |
|
1026 { |
|
1027 __LOG( "CUPnPBrowseDialog::DynInitMenuPaneL" ); |
|
1028 |
|
1029 TVolumeInfo info; |
|
1030 |
|
1031 TInt selected_item = iListBox->CurrentItemIndex(); |
|
1032 |
|
1033 if ( aResourceId == R_UPNPCOMMONUI_BROWSE_OPTION_MENU ) |
|
1034 { |
|
1035 iIsMusicItem = EFalse; |
|
1036 if ( !FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
1037 { |
|
1038 aMenuPane->SetItemDimmed( EUPnPHelp, ETrue ); |
|
1039 } |
|
1040 |
|
1041 if ( !iSourceDevice.SearchCapability() ) |
|
1042 { |
|
1043 aMenuPane->SetItemDimmed( EUPnPFind, ETrue ); |
|
1044 } |
|
1045 if ( iResultArray.Count() == 0 ) |
|
1046 { |
|
1047 aMenuPane->SetItemDimmed( EUPnPOpen, ETrue ); |
|
1048 aMenuPane->SetItemDimmed( EUPnPFind, ETrue ); |
|
1049 aMenuPane->SetItemDimmed( EUPnPCopy, ETrue ); |
|
1050 aMenuPane->SetItemDimmed( EAknCmdEditListMenu, ETrue ); |
|
1051 aMenuPane->SetItemDimmed( EUPnPShow, ETrue ); |
|
1052 aMenuPane->SetItemDimmed( EUPnPPlay, ETrue ); |
|
1053 } |
|
1054 // Something marked |
|
1055 else if( iSelectedItemsArray.Count() ) |
|
1056 { |
|
1057 // Only one video or image be able to show on external device |
|
1058 for ( TInt count = 0; |
|
1059 count < iSelectedItemsArray.Count(); |
|
1060 count++) |
|
1061 { |
|
1062 if ( ( iSelectedItemsArray[ count ] )-> |
|
1063 ObjectClass().Find( KClassAudio ) == 0 ) |
|
1064 { |
|
1065 //if marked items have at least one audio item |
|
1066 iIsMusicItem = ETrue; |
|
1067 count = iSelectedItemsArray.Count(); |
|
1068 } |
|
1069 else |
|
1070 { |
|
1071 iIsMusicItem = EFalse; |
|
1072 } |
|
1073 } |
|
1074 |
|
1075 aMenuPane->SetItemDimmed( EUPnPShow, ETrue ); |
|
1076 if ( UPnPItemUtility::BelongsToClass( |
|
1077 *iResultArray[selected_item], KClassAudio ) |
|
1078 && IsAudioItemMarked() ) |
|
1079 { |
|
1080 aMenuPane->SetItemDimmed( EUPnPPlay, EFalse ); |
|
1081 } |
|
1082 else |
|
1083 { |
|
1084 aMenuPane->SetItemDimmed( EUPnPPlay, ETrue ); |
|
1085 } |
|
1086 |
|
1087 // we must enable unmark all |
|
1088 aMenuPane->SetItemDimmed( EAknCmdEditListMenu, EFalse ); |
|
1089 |
|
1090 //only items are marked, disable EUPnPOpen |
|
1091 aMenuPane->SetItemDimmed( EUPnPOpen, ETrue ); |
|
1092 |
|
1093 } |
|
1094 else if( selected_item >= 0 ) //if no marked items |
|
1095 { |
|
1096 // Focus on a container |
|
1097 if ( iResultArray[ selected_item ]-> |
|
1098 ObjectType() == EUPnPContainer ) |
|
1099 { |
|
1100 aMenuPane->SetItemDimmed( EUPnPShow, ETrue ); |
|
1101 aMenuPane->SetItemDimmed( EUPnPPlay, ETrue ); |
|
1102 if ( iResultArray[ selected_item ]->ObjectClass() |
|
1103 .Find( KClassPlaylist ) == 0 ) |
|
1104 { |
|
1105 //aMenuPane->SetItemDimmed(EUPnPPlay, ETrue); |
|
1106 } |
|
1107 |
|
1108 aMenuPane->SetItemDimmed( EAknCmdEditListMenu, ETrue ); |
|
1109 } |
|
1110 else //if hightlighted item |
|
1111 { |
|
1112 // show edit list menu |
|
1113 aMenuPane->SetItemDimmed( EAknCmdEditListMenu, EFalse ); |
|
1114 aMenuPane->SetItemDimmed( EUPnPOpen, ETrue ); |
|
1115 if( ( iResultArray[ selected_item ] )-> |
|
1116 ObjectClass().Find( KClassAudio ) == 0 ) |
|
1117 { |
|
1118 aMenuPane->SetItemDimmed( EUPnPShow, ETrue ); |
|
1119 aMenuPane->SetItemDimmed( EUPnPPlay, EFalse ); |
|
1120 } |
|
1121 else if( ( ( iResultArray[ selected_item ] )->ObjectClass() |
|
1122 .Find( KClassImage ) == 0 |
|
1123 || ( iResultArray[ selected_item ])->ObjectClass() |
|
1124 .Find( KClassVideo ) == 0 ) |
|
1125 && !iSelectedItemsArray.Count() ) |
|
1126 { |
|
1127 if( iIsMusicItem ) |
|
1128 { |
|
1129 aMenuPane->SetItemDimmed( EUPnPPlay, EFalse ); |
|
1130 } |
|
1131 else |
|
1132 { |
|
1133 aMenuPane->SetItemDimmed( EUPnPPlay, ETrue ); |
|
1134 } |
|
1135 aMenuPane->SetItemDimmed( EUPnPShow, EFalse ); |
|
1136 } |
|
1137 else |
|
1138 { |
|
1139 aMenuPane->SetItemDimmed( EUPnPShow, ETrue ); |
|
1140 if( iIsMusicItem ) |
|
1141 { |
|
1142 aMenuPane->SetItemDimmed( EUPnPPlay, EFalse ); |
|
1143 } |
|
1144 else |
|
1145 { |
|
1146 aMenuPane->SetItemDimmed( EUPnPPlay, ETrue ); |
|
1147 } |
|
1148 } |
|
1149 } |
|
1150 } |
|
1151 |
|
1152 } |
|
1153 else if ( aResourceId == |
|
1154 R_UPNPCOMMONUI_MENUPANE_MARKABLE_LIST_IMPLEMENTATION ) |
|
1155 { |
|
1156 TBool markHidden = iListBox->View()->ItemIsSelected( selected_item ); |
|
1157 TBool unmarkHidden = !iListBox->View()-> |
|
1158 ItemIsSelected( selected_item ); |
|
1159 TBool markAllHidden = iListBox->Model()->NumberOfItems() == 0 || |
|
1160 iListBox->SelectionIndexes()->Count() == |
|
1161 iListBox->Model()->NumberOfItems(); |
|
1162 TBool unmarkAllHidden = iListBox->Model()->NumberOfItems() == 0 || |
|
1163 iSelectedItemsArray.Count() == 0; |
|
1164 |
|
1165 if ( iResultArray[ selected_item ]->ObjectType() == EUPnPContainer ) |
|
1166 { |
|
1167 aMenuPane->SetItemDimmed( EAknCmdMark, ETrue ); |
|
1168 aMenuPane->SetItemDimmed( EAknCmdUnmark, ETrue ); |
|
1169 aMenuPane->SetItemDimmed( EAknMarkAll, ETrue ); |
|
1170 } |
|
1171 else |
|
1172 { |
|
1173 aMenuPane->SetItemDimmed( EAknCmdMark, markHidden ); |
|
1174 aMenuPane->SetItemDimmed( EAknCmdUnmark, unmarkHidden ); |
|
1175 aMenuPane->SetItemDimmed( EAknMarkAll, markAllHidden ); |
|
1176 aMenuPane->SetItemDimmed( EAknUnmarkAll, unmarkAllHidden ); |
|
1177 } |
|
1178 } |
|
1179 CAknDialog::DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
1180 __LOG( "CUPnPBrowseDialog::DynInitMenuPaneL End" ); |
|
1181 } |
|
1182 |
|
1183 // -------------------------------------------------------------------------- |
|
1184 // CUPnPBrowseDialog::DeleteListItemsL |
|
1185 // Delete old items from browse list. |
|
1186 // -------------------------------------------------------------------------- |
|
1187 void CUPnPBrowseDialog::DeleteListItemsL() |
|
1188 { |
|
1189 __LOG ( "CUPnPBrowseDialog::DeleteListItemsL" ); |
|
1190 |
|
1191 CTextListBoxModel* model = iListBox->Model(); |
|
1192 TInt currentItem = iListBox->CurrentItemIndex(); |
|
1193 if ( currentItem < 0 ) |
|
1194 { |
|
1195 currentItem = 0; |
|
1196 } |
|
1197 MDesCArray* textArray = model->ItemTextArray(); |
|
1198 CDesCArray* listBoxItems = static_cast<CDesCArray*>( textArray ); |
|
1199 listBoxItems->Delete( 0,listBoxItems->Count() ); |
|
1200 AknListBoxUtils::HandleItemRemovalAndPositionHighlightL( iListBox, |
|
1201 currentItem, |
|
1202 ETrue ); |
|
1203 __LOG ( "CUPnPBrowseDialog::DeleteListItemsL End" ); |
|
1204 } |
|
1205 |
|
1206 // -------------------------------------------------------------------------- |
|
1207 // CUPnPBrowseDialog::LoadListItemsL |
|
1208 // Loads browse result set to the screen |
|
1209 // -------------------------------------------------------------------------- |
|
1210 void CUPnPBrowseDialog::LoadListItemsL() |
|
1211 { |
|
1212 __LOG( "CUPnPBrowseDialog::LoadListItemsL" ); |
|
1213 |
|
1214 CTextListBoxModel* model = iListBox->Model(); |
|
1215 MDesCArray* textArray = model->ItemTextArray(); |
|
1216 CDesCArray* listBoxItems = static_cast<CDesCArray*>( textArray ); |
|
1217 |
|
1218 TBuf<KMaxFileName> item; |
|
1219 |
|
1220 if( !iResultArray.Count() ) |
|
1221 { |
|
1222 iListBox->View()->SetListEmptyTextL( |
|
1223 *StringLoader::LoadLC( R_UPNPCOMMONUI_EXTERNAL_EMPTY_FOLDER ) ); |
|
1224 CleanupStack::PopAndDestroy(); |
|
1225 UpdateSoftkeysL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); |
|
1226 } |
|
1227 else |
|
1228 { |
|
1229 for (TInt i=0; i < iResultArray.Count(); i++) |
|
1230 { |
|
1231 // Get title and replace illegal characters. |
|
1232 HBufC8* tmptitle = |
|
1233 UPnPCommonUtils::FixListboxItemTextL( |
|
1234 iResultArray[i]->Title().Left( KLength ) ); |
|
1235 CleanupStack::PushL( tmptitle ); |
|
1236 |
|
1237 TPtrC8 tmpnameptr = *tmptitle; |
|
1238 iResultArray[i]->SetTitleL( tmpnameptr ); |
|
1239 |
|
1240 HBufC *tmpItem = UpnpString::ToUnicodeL( |
|
1241 tmpnameptr.Left( KLength ) ); |
|
1242 CleanupStack::PushL( tmpItem ); |
|
1243 |
|
1244 if ( iResultArray[ i ]->ObjectType() == EUPnPContainer ) |
|
1245 { |
|
1246 item.Format( KFormatString(), EUPnPIconFolder, tmpItem ); |
|
1247 } |
|
1248 else |
|
1249 { |
|
1250 if ( (iResultArray[ i ] )->ObjectClass() |
|
1251 .Find( KClassAudio ) == 0 ) |
|
1252 { |
|
1253 item.Format( KFormatString(), EUPnPIconMusic, |
|
1254 tmpItem ); |
|
1255 } |
|
1256 else if ( ( iResultArray[ i ] )->ObjectClass() |
|
1257 .Find( KClassVideo ) == 0 ) |
|
1258 { |
|
1259 item.Format( KFormatString(), EUPnPIconVideo, |
|
1260 tmpItem ); |
|
1261 } |
|
1262 else if ( ( iResultArray[ i ] )->ObjectClass() |
|
1263 .Find( KClassImage ) == 0 ) |
|
1264 { |
|
1265 item.Format( KFormatString(), EUPnPIconImage, |
|
1266 tmpItem ); |
|
1267 } |
|
1268 else |
|
1269 { |
|
1270 item.Format( KFormatString(), EUPnPIconOther, |
|
1271 tmpItem ); |
|
1272 } |
|
1273 } |
|
1274 CleanupStack::PopAndDestroy ( tmpItem ); |
|
1275 CleanupStack::PopAndDestroy ( tmptitle ); |
|
1276 listBoxItems->AppendL( item ); |
|
1277 |
|
1278 if ( iSelectedItemsArray.Count() ) |
|
1279 { |
|
1280 for ( TInt index = 0; |
|
1281 index < iSelectedItemsArray.Count(); |
|
1282 index++ ) |
|
1283 { |
|
1284 for ( TInt i = 0; i < iResultArray.Count() ; i++ ) |
|
1285 { |
|
1286 if ( !( iResultArray[ i ])->Id().CompareC( |
|
1287 iSelectedItemsArray[ index ]->Id() ) ) |
|
1288 { |
|
1289 MarkItemL( i ); |
|
1290 i = iResultArray.Count(); |
|
1291 } |
|
1292 } |
|
1293 } |
|
1294 } |
|
1295 } //for |
|
1296 |
|
1297 iListBox->HandleItemAdditionL(); // Update listbox |
|
1298 // Ensure iCurrentItem isn't out of bounds |
|
1299 if ( iCurrentItem < 0 ) |
|
1300 { |
|
1301 iCurrentItem = 0; |
|
1302 } |
|
1303 if ( iCurrentItem >= model->NumberOfItems() ) |
|
1304 { |
|
1305 iCurrentItem = model->NumberOfItems() - 1; |
|
1306 } |
|
1307 |
|
1308 // select new item |
|
1309 iListBox->SetCurrentItemIndexAndDraw( iCurrentItem ); |
|
1310 if( !iImageControlActive ) |
|
1311 { |
|
1312 if( (iResultArray[iCurrentItem])-> |
|
1313 ObjectClass().Find( KClassImage ) == 0 || |
|
1314 (iResultArray[iCurrentItem])-> |
|
1315 ObjectClass().Find( KClassVideo ) == 0) |
|
1316 { |
|
1317 UpdateSoftkeysL( R_UPNPCOMMONUI_SOFTKEYS_OPTIONS_BACK__SHOW); |
|
1318 } |
|
1319 else if( ( iResultArray[iCurrentItem] )->ObjectClass() |
|
1320 .Find( KClassAudio ) == 0 ) |
|
1321 { |
|
1322 UpdateSoftkeysL( R_UPNPCOMMONUI_SOFTKEYS_OPTIONS_BACK__PLAY); |
|
1323 } |
|
1324 else if( ( iResultArray[iCurrentItem] )->ObjectClass() |
|
1325 .Find( KClassContainer ) == 0 ) |
|
1326 { |
|
1327 UpdateSoftkeysL( R_UPNPCOMMONUI_SOFTKEYS_OPTIONS_BACK__OPEN); |
|
1328 } |
|
1329 else |
|
1330 { |
|
1331 UpdateSoftkeysL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); |
|
1332 } |
|
1333 } |
|
1334 } |
|
1335 |
|
1336 |
|
1337 |
|
1338 __LOG( "CUPnPBrowseDialog::LoadListItemsL End" ); |
|
1339 } |
|
1340 |
|
1341 // -------------------------------------------------------------------------- |
|
1342 // CUPnPBrowseDialog::SendBrowseRequestL |
|
1343 // Sends the browse request to UPnP AV Controller. When result set arrives, |
|
1344 // UPnP AV Controller will call the "BrowseResponse" call back method, |
|
1345 // which is implemented below. |
|
1346 // -------------------------------------------------------------------------- |
|
1347 void CUPnPBrowseDialog::SendBrowseRequestL( TInt aIndex ) |
|
1348 { |
|
1349 __LOG1( "CUPnPBrowseDialog::SendBrowseRequestL, index: %d", aIndex ); |
|
1350 iFirstResultArray = ETrue; |
|
1351 |
|
1352 iNeedRepeatRequest = EFalse; |
|
1353 iOriginalBrowseRequest = ETrue; |
|
1354 iServerReturnObjectCount = 0; |
|
1355 |
|
1356 iBrowseDirection = EForward; |
|
1357 |
|
1358 TInt cache = 0; |
|
1359 iDummyBrowseResponse = EFalse; |
|
1360 if( iBrowseSession ) |
|
1361 { |
|
1362 // If the given index is negative, get the root ("0") container |
|
1363 if( KBrowseRoot == aIndex ) |
|
1364 { |
|
1365 iUppermostItem = 0; |
|
1366 //Set browse flag for root browse |
|
1367 iBrowseFlag = KBrowseRoot; |
|
1368 |
|
1369 // Clear parent id table |
|
1370 iParentId.ResetAndDestroy(); |
|
1371 |
|
1372 // Clear temporary array for browse view |
|
1373 iTempArray.Reset(); |
|
1374 |
|
1375 // Clear previous browse view |
|
1376 |
|
1377 iCurrentFolderId = KContainerIdRoot().AllocL(); |
|
1378 |
|
1379 // Make the browse request |
|
1380 cache = CacheCheck( *iCurrentFolderId ); |
|
1381 if ( cache > 0 ) |
|
1382 { |
|
1383 //update current cache item |
|
1384 CacheItemUpdateL( *iCurrentFolderId, EFalse ); |
|
1385 } |
|
1386 else |
|
1387 { |
|
1388 //not founded in cache create new cache item |
|
1389 CacheItemUpdateL( *iCurrentFolderId, ETrue ); |
|
1390 } |
|
1391 |
|
1392 iAction = CUPnPCommonUI::EUPnPBrowse; |
|
1393 iBrowseSession->BrowseL( *iCurrentFolderId, |
|
1394 KFilterCommon, /* filter */ |
|
1395 MUPnPAVBrowsingSession::EDirectChildren, |
|
1396 0, /* start index */ |
|
1397 KBrowseRequestCount,/* request count */ |
|
1398 KSortNone ); /* sort criteria */ |
|
1399 } |
|
1400 else if( KBrowseBack == aIndex ) // Back operation |
|
1401 { |
|
1402 if ( iParentId.Count() > 0 ) |
|
1403 { |
|
1404 // Set browse flag so that cleanup can be done in response |
|
1405 iBrowseFlag = KBrowseBack; |
|
1406 |
|
1407 TInt startIndex = |
|
1408 iPrevHighlighteditem - KBrowseRequestCount; |
|
1409 |
|
1410 if ( startIndex < 0 ) |
|
1411 { |
|
1412 startIndex = 0; |
|
1413 } |
|
1414 |
|
1415 TInt requestCount = KBrowseRequestCount * 2; |
|
1416 CacheItemUpdateL( *iCurrentFolderId, EFalse ); |
|
1417 |
|
1418 delete iCurrentFolderId; iCurrentFolderId = NULL; |
|
1419 iCurrentFolderId = |
|
1420 iParentId[ iParentId.Count() - 1 ]->AllocL(); |
|
1421 cache = CacheCheck( *iCurrentFolderId ); |
|
1422 |
|
1423 if ( cache < 0 ) |
|
1424 { |
|
1425 iUppermostItem = 0; |
|
1426 iBrowseRequestSent = ETrue; |
|
1427 iAction = CUPnPCommonUI::EUPnPBrowse; |
|
1428 iBrowseSession->BrowseL( |
|
1429 *iCurrentFolderId, |
|
1430 KFilterCommon, /* filter */ |
|
1431 MUPnPAVBrowsingSession::EDirectChildren, |
|
1432 startIndex, /* start index */ |
|
1433 requestCount, /* request count */ |
|
1434 KSortNone ); /* sort criteria */ |
|
1435 } |
|
1436 else |
|
1437 { |
|
1438 iDummyBrowseResponse = ETrue; |
|
1439 } |
|
1440 } |
|
1441 } |
|
1442 else |
|
1443 { |
|
1444 // If there is an object in the browse array with the given |
|
1445 // index, get the container id of that object |
|
1446 iPrevHighlighteditem = iListBox->CurrentItemIndex(); |
|
1447 if( iResultArray.Count() >= aIndex ) |
|
1448 { |
|
1449 iBrowseFlag = KBrowseForward; |
|
1450 |
|
1451 // store selected item index |
|
1452 iSelectedItem = aIndex; |
|
1453 |
|
1454 //update current cache item |
|
1455 CacheItemUpdateL( *iCurrentFolderId, EFalse ); |
|
1456 delete iCurrentFolderId; iCurrentFolderId = NULL; |
|
1457 iCurrentFolderId = |
|
1458 iResultArray[ aIndex ]->Id().AllocL(); |
|
1459 |
|
1460 // compare if the array what is about to be requested |
|
1461 // Make the browse request |
|
1462 cache = CacheCheck( *iCurrentFolderId ); |
|
1463 if ( cache < 0 ) |
|
1464 { |
|
1465 //not founded in cache create new cache item |
|
1466 CacheItemUpdateL( *iCurrentFolderId, ETrue ); |
|
1467 iUppermostItem = 0; |
|
1468 iBrowseRequestSent = ETrue; |
|
1469 iAction = CUPnPCommonUI::EUPnPBrowse; |
|
1470 iBrowseSession->BrowseL( |
|
1471 ( ( CUpnpContainer*)iResultArray[aIndex])->Id(), |
|
1472 /* CUpnpContainer (containing the object id of |
|
1473 the container */ |
|
1474 KFilterCommon, /* filter */ |
|
1475 MUPnPAVBrowsingSession::EDirectChildren, |
|
1476 0, /* start index */ |
|
1477 KBrowseRequestCount, /* request count */ |
|
1478 KSortNone ); /* sort criteria */ |
|
1479 } |
|
1480 else |
|
1481 { |
|
1482 iDummyBrowseResponse = ETrue; |
|
1483 } |
|
1484 |
|
1485 |
|
1486 } |
|
1487 } |
|
1488 if ( iDummyBrowseResponse ) |
|
1489 { |
|
1490 SendDummyBrowseResponseL( cache ); |
|
1491 } |
|
1492 else |
|
1493 { |
|
1494 // Display waiting note if browse request is sent |
|
1495 DisplayWaitNoteL( R_UPNPCOMMONUI_BROWSE_UPDATE_WAIT_NOTE_DIALOG ); |
|
1496 } |
|
1497 } |
|
1498 else |
|
1499 { |
|
1500 __LOG( " CUPnPBrowseDialog::SendBrowseRequestL: \ |
|
1501 FAILED AV control point is NULL" ); |
|
1502 |
|
1503 } |
|
1504 |
|
1505 __LOG( "CUPnPBrowseDialog::SendBrowseRequestL End" ); |
|
1506 } |
|
1507 |
|
1508 // -------------------------------------------------------------------------- |
|
1509 // CUPnPBrowseDialog::BrowseResponse |
|
1510 // Returns browse results from UPnP AV control point. |
|
1511 // -------------------------------------------------------------------------- |
|
1512 void CUPnPBrowseDialog::BrowseResponse( const TDesC8& aBrowseResponse, |
|
1513 TInt aError, TInt /*aMatches*/, TInt aTotalCount, const TDesC8& |
|
1514 /*aUpdateId*/ ) |
|
1515 { |
|
1516 __LOG1( "CUPnPBrowseDialog::BrowseResponse: %d", aError ); |
|
1517 |
|
1518 RPointerArray<CUpnpObject> array; |
|
1519 |
|
1520 if( aError == KErrNone ) |
|
1521 { |
|
1522 iRoot = EFalse; |
|
1523 CUPnPXMLParser* parser = NULL; |
|
1524 TRAP( aError, parser = CUPnPXMLParser::NewL(); |
|
1525 parser->ParseResultDataL( array, |
|
1526 aBrowseResponse ) ); |
|
1527 |
|
1528 delete parser; |
|
1529 } |
|
1530 |
|
1531 TRAP_IGNORE( BrowseResponseL( aError, aTotalCount, array ) ); |
|
1532 |
|
1533 array.ResetAndDestroy(); |
|
1534 |
|
1535 __LOG( "CUPnPBrowseDialog::BrowseResponse -end" ); |
|
1536 } |
|
1537 |
|
1538 // -------------------------------------------------------------------------- |
|
1539 // CUPnPBrowseDialog::BrowseResponseL |
|
1540 // Returns browse results from UPnP AV control point. |
|
1541 // -------------------------------------------------------------------------- |
|
1542 void CUPnPBrowseDialog::BrowseResponseL( |
|
1543 TInt aStatus, |
|
1544 TInt aTotalCount, |
|
1545 const RPointerArray<CUpnpObject>& aResultArray ) |
|
1546 { |
|
1547 __LOG( "CUPnPBrowseDialog::BrowseResponseL" ); |
|
1548 |
|
1549 CUPnPCommonUI::TUPnPAction currentAction = iAction; |
|
1550 TInt currentCopyIndex = iCopyIndex; |
|
1551 iAction = CUPnPCommonUI::EUPnPBrowse; |
|
1552 TRAPD( error, HandleErrorL( aStatus ) ); |
|
1553 iAction = currentAction; |
|
1554 iCopyIndex = currentCopyIndex; |
|
1555 User::LeaveIfError( error ); |
|
1556 |
|
1557 if( KErrNone == aStatus ) |
|
1558 { |
|
1559 iTotalCount = aTotalCount; |
|
1560 SelectedArrayCheckL(); |
|
1561 iAllObjectsReceived = EFalse; |
|
1562 iBrowseRequestSent = EFalse; |
|
1563 if( iBrowseFlag != KBrowseRoot ) |
|
1564 { |
|
1565 if ( iFirstResultArray ) |
|
1566 { |
|
1567 if( iBrowseFlag == KBrowseBack ) //Back browse was made |
|
1568 { |
|
1569 delete iParentId[ iParentId.Count() - 1 ]; |
|
1570 iParentId.Remove( iParentId.Count() - 1 ); |
|
1571 |
|
1572 // delete non-relevant parent name |
|
1573 delete iParentName[iParentName.Count() - 1]; |
|
1574 iParentName.Remove( iParentName.Count() - 1 ); |
|
1575 } |
|
1576 else //Forward browse has been made |
|
1577 { |
|
1578 // Save Parent Id |
|
1579 if ( iResultArray.Count() > 0 ) |
|
1580 { |
|
1581 HBufC8* containerId = |
|
1582 ( iResultArray[ 0 ]->ParentId() ).AllocL(); |
|
1583 iParentId.AppendL( containerId ); |
|
1584 |
|
1585 // store parent name |
|
1586 HBufC8* name = |
|
1587 ( iResultArray[ iSelectedItem ]->Title() ).AllocL(); |
|
1588 iParentName.AppendL( name ); |
|
1589 } |
|
1590 } |
|
1591 } |
|
1592 } |
|
1593 // If the result array in response to first browse request |
|
1594 if ( iFirstResultArray ) |
|
1595 { |
|
1596 DeleteListItemsL(); |
|
1597 iResultArray.Reset(); |
|
1598 |
|
1599 // If Server don't return all of the objects requested in |
|
1600 // an first browse request So need repeat browse request |
|
1601 // to get all objects which the first browse request desired |
|
1602 TInt tempCount = iTotalCount; |
|
1603 if ( tempCount > KBrowseRequestCount ) |
|
1604 { |
|
1605 tempCount = KBrowseRequestCount; |
|
1606 } |
|
1607 iServerReturnObjectCount = aResultArray.Count(); |
|
1608 if ( iServerReturnObjectCount < tempCount ) |
|
1609 { |
|
1610 iNeedRepeatRequest = ETrue; |
|
1611 } |
|
1612 } |
|
1613 |
|
1614 CTextListBoxModel* model = iListBox->Model(); |
|
1615 |
|
1616 // If response to an original browse request, so could get count of |
|
1617 // all objects which the original browse request desired |
|
1618 // PS: the first browse request is actually an original browse request |
|
1619 if ( iOriginalBrowseRequest ) |
|
1620 { |
|
1621 TInt tempCount = 0; |
|
1622 if ( iBrowseDirection == EForward ) |
|
1623 { |
|
1624 tempCount = iTotalCount - iUppermostItem - |
|
1625 model->NumberOfItems(); |
|
1626 } |
|
1627 else if ( iBrowseDirection == EBackward ) |
|
1628 { |
|
1629 tempCount = iUppermostItem; |
|
1630 } |
|
1631 |
|
1632 if ( tempCount > KBrowseRequestCount ) |
|
1633 { |
|
1634 tempCount = KBrowseRequestCount; |
|
1635 } |
|
1636 iNeedRecevedObjectCount = tempCount; |
|
1637 iCurrentRecevedObjectIndex = 0; |
|
1638 iOriginalBrowseRequest = EFalse; |
|
1639 } |
|
1640 |
|
1641 if( ( aResultArray.Count() + |
|
1642 iUppermostItem + |
|
1643 model->NumberOfItems() ) >= aTotalCount && |
|
1644 aResultArray.Count() == 0 ) |
|
1645 { |
|
1646 iAllObjectsReceived = ETrue; |
|
1647 } |
|
1648 else //if not all the objects are recevied |
|
1649 { |
|
1650 if ( aResultArray.Count() < KBrowseRequestCount ) |
|
1651 { |
|
1652 iAllObjectsReceviedInOneBrowse = EFalse; |
|
1653 iNumObjectReceviedInOnBrowse+=aResultArray.Count(); |
|
1654 if( iNumObjectReceviedInOnBrowse >= KBrowseRequestCount ) |
|
1655 { |
|
1656 iAllObjectsReceviedInOneBrowse = ETrue; |
|
1657 } |
|
1658 } |
|
1659 } |
|
1660 |
|
1661 // Copy the items from the array received as a parameter |
|
1662 for( TInt index=0; index < aResultArray.Count(); index++ ) |
|
1663 { |
|
1664 |
|
1665 if ( iBrowseDirection == EForward ) |
|
1666 { |
|
1667 if ( ( aResultArray[index]->ObjectType() == |
|
1668 EUPnPContainer ) ) |
|
1669 { |
|
1670 CUpnpContainer* container = CUpnpContainer::NewL(); |
|
1671 |
|
1672 CleanupStack::PushL( container ); |
|
1673 container->CopyL( *aResultArray[ index ] ); |
|
1674 CleanupStack::Pop( container ); |
|
1675 iResultArray.AppendL( container ); |
|
1676 } |
|
1677 else |
|
1678 { |
|
1679 CUpnpItem* item = CUpnpItem::NewL(); |
|
1680 |
|
1681 CleanupStack::PushL( item ); |
|
1682 item->CopyL( *aResultArray[ index ] ); |
|
1683 CleanupStack::Pop( item ); |
|
1684 iResultArray.AppendL( item ); |
|
1685 } |
|
1686 } |
|
1687 else if ( iBrowseDirection == EBackward ) |
|
1688 { |
|
1689 if ( aResultArray[ index ]->ObjectType() == EUPnPContainer ) |
|
1690 { |
|
1691 CUpnpContainer* container = CUpnpContainer::NewL(); |
|
1692 CleanupStack::PushL( container ); |
|
1693 container->CopyL( *aResultArray[ index ] ); |
|
1694 CleanupStack::Pop( container ); |
|
1695 iResultArray.InsertL( container, index ); |
|
1696 iUppermostItem--; |
|
1697 } |
|
1698 else |
|
1699 { |
|
1700 CUpnpItem* item = CUpnpItem::NewL(); |
|
1701 |
|
1702 CleanupStack::PushL( item ); |
|
1703 item->CopyL( *aResultArray[ index ] ); |
|
1704 CleanupStack::Pop( item ); |
|
1705 iResultArray.InsertL( item, index ); |
|
1706 iUppermostItem--; |
|
1707 } |
|
1708 } |
|
1709 } |
|
1710 |
|
1711 if ( iResultArray.Count() > ( KBrowseRequestCount * 2 ) ) |
|
1712 { |
|
1713 if ( iBrowseDirection == EForward ) |
|
1714 { |
|
1715 for ( ; |
|
1716 ( KBrowseRequestCount * 2 ) < iResultArray.Count(); ) |
|
1717 { |
|
1718 delete iResultArray[ 0 ]; |
|
1719 iResultArray[ 0 ] = NULL; |
|
1720 iResultArray.Remove( 0 ); |
|
1721 if ( iCurrentItem > 0 ) |
|
1722 { |
|
1723 iCurrentItem--; |
|
1724 } |
|
1725 iUppermostItem++; |
|
1726 } |
|
1727 } |
|
1728 else if ( iBrowseDirection == EBackward ) |
|
1729 { |
|
1730 for ( ; |
|
1731 ( KBrowseRequestCount * 2 ) < iResultArray.Count(); ) |
|
1732 { |
|
1733 delete iResultArray[ ( iResultArray.Count() - 1 ) ]; |
|
1734 iResultArray[ ( iResultArray.Count() - 1 ) ] = NULL; |
|
1735 iResultArray.Remove( iResultArray.Count() - 1 ); |
|
1736 iCurrentItem++; |
|
1737 } |
|
1738 } |
|
1739 } |
|
1740 |
|
1741 // Reload the list items |
|
1742 if ( iFirstResultArray ) |
|
1743 { |
|
1744 if ( !iDummyBrowseResponse ) |
|
1745 { |
|
1746 iCurrentItem = 0; |
|
1747 } |
|
1748 iFirstResultArray = EFalse; |
|
1749 // update navi pane text |
|
1750 UpdateNaviPaneTextL(); |
|
1751 // Redraw the list |
|
1752 iListBox->ActivateL(); |
|
1753 iListBox->DrawDeferred(); |
|
1754 } |
|
1755 DeleteListItemsL(); |
|
1756 LoadListItemsL(); |
|
1757 |
|
1758 // If count of CDS objects requesed in an original browse request |
|
1759 // isn't complete, countinue send browse request |
|
1760 iCurrentRecevedObjectIndex += aResultArray.Count(); |
|
1761 if ( iNeedRepeatRequest && |
|
1762 iCurrentRecevedObjectIndex < iNeedRecevedObjectCount ) |
|
1763 { |
|
1764 TInt startIndex = KErrNotFound; |
|
1765 if ( iBrowseDirection == EForward ) |
|
1766 { |
|
1767 TInt numberOfItems = iListBox->Model()->NumberOfItems(); |
|
1768 startIndex = iUppermostItem + numberOfItems; |
|
1769 } |
|
1770 else if ( iBrowseDirection == EBackward ) |
|
1771 { |
|
1772 startIndex = iUppermostItem - iServerReturnObjectCount; |
|
1773 } |
|
1774 iAction = CUPnPCommonUI::EUPnPBrowse; |
|
1775 iBrowseSession->BrowseL( *iCurrentFolderId, |
|
1776 KFilterCommon, /* filter */ |
|
1777 MUPnPAVBrowsingSession::EDirectChildren, |
|
1778 startIndex, /* start index */ |
|
1779 iServerReturnObjectCount,/* request count */ |
|
1780 KSortNone ); /* sort criteria */ |
|
1781 iBrowseRequestSent = ETrue; |
|
1782 } |
|
1783 else |
|
1784 { |
|
1785 DismissWaitNoteL(); |
|
1786 } |
|
1787 } |
|
1788 else |
|
1789 { |
|
1790 __LOG( "CUPnPBrowseDialog: \ |
|
1791 Browse operation failed!" ); |
|
1792 DismissWaitNoteL(); |
|
1793 //Delete the current browsed container id in the cache and |
|
1794 // handle the error |
|
1795 DialogDismissedL( KErrNotFound ); |
|
1796 } |
|
1797 |
|
1798 |
|
1799 __LOG( "CUPnPBrowseDialog::BrowseResponseL-END" ); |
|
1800 } |
|
1801 |
|
1802 // -------------------------------------------------------------------------- |
|
1803 // CUPnPBrowseDialog::ClearTitleL |
|
1804 // Sets title back to default. |
|
1805 // -------------------------------------------------------------------------- |
|
1806 void CUPnPBrowseDialog::ClearTitleL() |
|
1807 { |
|
1808 __LOG( "tCUPnPBrowseDialog::ClearTitleL" ); |
|
1809 |
|
1810 TUid titlePaneUid; |
|
1811 titlePaneUid.iUid = EEikStatusPaneUidTitle; |
|
1812 CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
1813 CEikStatusPaneBase::TPaneCapabilities titlesubPane = |
|
1814 statusPane->PaneCapabilities( titlePaneUid ); |
|
1815 |
|
1816 CAknTitlePane* titlePane = |
|
1817 ( CAknTitlePane* ) statusPane->ControlL( titlePaneUid ); |
|
1818 __LOG( "CUPnPBrowseDialog::ClearTitleL-END" ); |
|
1819 } |
|
1820 |
|
1821 // -------------------------------------------------------------------------- |
|
1822 // CUPnPBrowseDialog::AppendIconToArrayL |
|
1823 // Load a possibly skinned icon (with mask) and append it to an |
|
1824 // icon array. |
|
1825 // -------------------------------------------------------------------------- |
|
1826 void CUPnPBrowseDialog::AppendIconToArrayL( CAknIconArray* aArray, |
|
1827 MAknsSkinInstance* aSkin, |
|
1828 const TDesC& aMbmFile, |
|
1829 const TAknsItemID& aID, |
|
1830 TInt aBitmapId, |
|
1831 TInt aMaskId) |
|
1832 { |
|
1833 __LOG( "CUPnPBrowseDialog::AppendIconToArrayL" ); |
|
1834 |
|
1835 __ASSERTD( aArray != NULL, __FILE__, __LINE__ ); |
|
1836 |
|
1837 CFbsBitmap* bitmap = NULL; |
|
1838 CFbsBitmap* mask = NULL; |
|
1839 |
|
1840 |
|
1841 AknsUtils::CreateIconL( |
|
1842 aSkin, aID, bitmap, mask, aMbmFile, aBitmapId, aMaskId ); |
|
1843 |
|
1844 CleanupStack::PushL( bitmap ); |
|
1845 CleanupStack::PushL( mask ); |
|
1846 |
|
1847 CGulIcon* icon = CGulIcon::NewL( bitmap, mask ); |
|
1848 |
|
1849 icon->SetBitmapsOwnedExternally( EFalse ); |
|
1850 |
|
1851 // icon now owns the bitmaps, no need to keep on cleanup stack. |
|
1852 CleanupStack::Pop( mask ); |
|
1853 CleanupStack::Pop( bitmap ); |
|
1854 bitmap = NULL; |
|
1855 mask = NULL; |
|
1856 |
|
1857 CleanupStack::PushL( icon ); |
|
1858 aArray->AppendL( icon ); |
|
1859 |
|
1860 // aArray now owns the icon, no need to delete. |
|
1861 CleanupStack::Pop( icon ); |
|
1862 __LOG( "CUPnPBrowseDialog::AppendIconToArrayL-END" ); |
|
1863 } |
|
1864 |
|
1865 // -------------------------------------------------------------------------- |
|
1866 // CUPnPBrowseDialog::MarkItemL |
|
1867 // Marks one item |
|
1868 // -------------------------------------------------------------------------- |
|
1869 void CUPnPBrowseDialog::MarkItemL( TInt aItemIndex ) |
|
1870 { |
|
1871 __LOG( "CUPnPBrowseDialog::MarkItemL" ); |
|
1872 |
|
1873 CTextListBoxModel* model = iListBox->Model(); |
|
1874 CListBoxView* listBoxView = iListBox->View(); |
|
1875 |
|
1876 if( iResultArray[ aItemIndex ] ) |
|
1877 { |
|
1878 if( iResultArray[ aItemIndex ]->ObjectType() == EUPnPItem ) |
|
1879 { |
|
1880 listBoxView->SelectItemL( aItemIndex ); |
|
1881 } |
|
1882 } |
|
1883 UpdateCommandButtonAreaL( ETrue, iListBox->CurrentItemIndex() ); |
|
1884 __LOG( "CUPnPBrowseDialog::MarkItemL-END" ); |
|
1885 } |
|
1886 |
|
1887 // -------------------------------------------------------------------------- |
|
1888 // CUPnPBrowseDialog::UnmarkItemL |
|
1889 // Unmarks one item |
|
1890 // -------------------------------------------------------------------------- |
|
1891 void CUPnPBrowseDialog::UnmarkItem( TInt aItemIndex ) |
|
1892 { |
|
1893 __LOG( "CUPnPBrowseDialog::UnmarkItemL" ); |
|
1894 |
|
1895 CTextListBoxModel* model = iListBox->Model(); |
|
1896 CListBoxView* listBoxView = iListBox->View(); |
|
1897 listBoxView->DeselectItem( aItemIndex ); |
|
1898 const CArrayFix<TInt>* indexes = iListBox->SelectionIndexes(); |
|
1899 if ( indexes->Count() ) |
|
1900 { |
|
1901 UpdateCommandButtonArea( ETrue, iListBox->CurrentItemIndex() ); |
|
1902 } |
|
1903 else |
|
1904 { |
|
1905 UpdateCommandButtonArea( EFalse, iListBox->CurrentItemIndex() ); |
|
1906 } |
|
1907 __LOG( "CUPnPBrowseDialog::UnmarkItemL-END" ); |
|
1908 } |
|
1909 |
|
1910 // -------------------------------------------------------------------------- |
|
1911 // CUPnPBrowseDialog::MarkAllItemsL |
|
1912 // Marks all items. Does not mark any containers. |
|
1913 // -------------------------------------------------------------------------- |
|
1914 void CUPnPBrowseDialog::MarkAllItemsL() |
|
1915 { |
|
1916 __LOG( "CUPnPBrowseDialog::MarkAllItemsL" ); |
|
1917 |
|
1918 CTextListBoxModel* model = iListBox->Model(); |
|
1919 TInt itemCount = model->NumberOfItems(); |
|
1920 CListBoxView* listBoxView = iListBox->View(); |
|
1921 |
|
1922 // Go through the items and select all items |
|
1923 for( TInt index = 0; index < itemCount; index++ ) |
|
1924 { |
|
1925 if( iResultArray[ index ]->ObjectType() == EUPnPItem ) |
|
1926 { |
|
1927 listBoxView->SelectItemL( index ); |
|
1928 } |
|
1929 } |
|
1930 UpdateCommandButtonAreaL( ETrue, iListBox->CurrentItemIndex() ); |
|
1931 __LOG( "CUPnPBrowseDialog::MarkAllItemsL-END" ); |
|
1932 } |
|
1933 |
|
1934 // -------------------------------------------------------------------------- |
|
1935 // CUPnPBrowseDialog::UnmarkAllItems |
|
1936 // Unmarks all items |
|
1937 // -------------------------------------------------------------------------- |
|
1938 void CUPnPBrowseDialog::UnmarkAllItems() |
|
1939 { |
|
1940 __LOG( "CUPnPBrowseDialog::UnmarkAllItems" ); |
|
1941 |
|
1942 CTextListBoxModel* model = iListBox->Model(); |
|
1943 TInt itemCount = model->NumberOfItems(); |
|
1944 CListBoxView* listBoxView = iListBox->View(); |
|
1945 iSelectedItemsArray.ResetAndDestroy(); |
|
1946 for( TInt index = 0; index < itemCount; index++ ) |
|
1947 { |
|
1948 listBoxView->DeselectItem( index ); |
|
1949 } |
|
1950 UpdateCommandButtonArea( EFalse, iListBox->CurrentItemIndex() ); |
|
1951 __LOG( "CUPnPBrowseDialog::UnmarkAllItems-END" ); |
|
1952 } |
|
1953 // -------------------------------------------------------------------------- |
|
1954 // CUPnPBrowseDialog::ShowPlayExtL |
|
1955 // show image or video on external device |
|
1956 // -------------------------------------------------------------------------- |
|
1957 void CUPnPBrowseDialog::ShowPlayExtL() |
|
1958 { |
|
1959 __LOG( "CUPnPBrowseDialog::ShowPlayExtL" ); |
|
1960 |
|
1961 SelectedArrayCheckL(); |
|
1962 //if there is(are) audio item(s) marked, start playing it(them) on remote |
|
1963 //renderer |
|
1964 if ( iSelectedItemsArray.Count() > 0 ) |
|
1965 { |
|
1966 if( IsAudioItemMarked() ) |
|
1967 { |
|
1968 //if marked items have at least one audio item |
|
1969 iIsMusicItem = ETrue; |
|
1970 } |
|
1971 else |
|
1972 { |
|
1973 iIsMusicItem = EFalse; |
|
1974 } |
|
1975 //if at least one audio file is either in marked items |
|
1976 //play it |
|
1977 if( iIsMusicItem && !iMusicPlay ) |
|
1978 { |
|
1979 PlayL( EFalse ); |
|
1980 } |
|
1981 } |
|
1982 else // if no marked items |
|
1983 { |
|
1984 if ( ( iResultArray[iListBox->CurrentItemIndex()] )-> |
|
1985 ObjectClass().Find( KClassVideo ) == 0 ) |
|
1986 { |
|
1987 ShowVideoDialogExtL(); |
|
1988 } |
|
1989 else if ( ( iResultArray[iListBox->CurrentItemIndex()] )-> |
|
1990 ObjectClass().Find( KClassImage ) == 0 ) |
|
1991 { |
|
1992 StartImageControlL(); |
|
1993 } |
|
1994 else if ( ( iResultArray[iListBox->CurrentItemIndex()] )-> |
|
1995 ObjectClass().Find( KClassAudio ) == 0 && |
|
1996 !iMusicPlay ) |
|
1997 { |
|
1998 PlayL( EFalse ); |
|
1999 } |
|
2000 } |
|
2001 |
|
2002 __LOG( "CUPnPBrowseDialog::ShowPlayExtL-END" ); |
|
2003 } |
|
2004 |
|
2005 // -------------------------------------------------------------------------- |
|
2006 // CUPnPBrowseDialog::CreateFillerLC |
|
2007 // Creates a playlist representing current selection for music playback |
|
2008 // -------------------------------------------------------------------------- |
|
2009 |
|
2010 CUPnPPlayListFiller* CUPnPBrowseDialog::CreateFillerLC() |
|
2011 { |
|
2012 CUPnPPlayListFiller* filler = NULL; |
|
2013 |
|
2014 if ( iSelectedItemsArray.Count() > 0 ) |
|
2015 { |
|
2016 // Play marked items only |
|
2017 filler = CUPnPPlayListFiller::NewL(); |
|
2018 CleanupStack::PushL( filler ); |
|
2019 TInt firstAudioItem = KErrNotFound; |
|
2020 TBool focusedItemFound = EFalse; |
|
2021 for( TInt i = 0; i < iSelectedItemsArray.Count(); i++ ) |
|
2022 { |
|
2023 filler->InsertObjectL( |
|
2024 iSourceDevice, *iSelectedItemsArray[ i ] ); |
|
2025 |
|
2026 if( UPnPItemUtility::BelongsToClass( *iSelectedItemsArray[ i ] |
|
2027 , KClassAudio ) |
|
2028 && firstAudioItem == KErrNotFound ) |
|
2029 { |
|
2030 firstAudioItem = i; |
|
2031 } |
|
2032 if( iSelectedItemsArray[i]->Id() == iResultArray[ iListBox-> |
|
2033 CurrentItemIndex() ]->Id() ) |
|
2034 { |
|
2035 filler->SetSelectedIndex( i ); |
|
2036 focusedItemFound = ETrue; |
|
2037 } |
|
2038 } |
|
2039 // if focused item was not found set index to first audio item |
|
2040 if( !focusedItemFound ) |
|
2041 { |
|
2042 filler->SetSelectedIndex( firstAudioItem ); |
|
2043 } |
|
2044 } |
|
2045 else |
|
2046 { |
|
2047 // play entire container starting from current pointer |
|
2048 TInt currentIndex = iListBox->CurrentItemIndex(); |
|
2049 if( currentIndex < 0 ) |
|
2050 { |
|
2051 currentIndex = 0; |
|
2052 } |
|
2053 |
|
2054 if( iParentId.Count() == 0 ) |
|
2055 { |
|
2056 //root level |
|
2057 filler = CUPnPBrowsePlaylistFiller::NewL( |
|
2058 KContainerIdRoot, |
|
2059 iUppermostItem, |
|
2060 iTotalCount ); |
|
2061 } |
|
2062 else if( iParentId.Count() > 0) |
|
2063 { |
|
2064 //any other level |
|
2065 filler = CUPnPBrowsePlaylistFiller::NewL( |
|
2066 iResultArray[ 0 ]->ParentId(), |
|
2067 iUppermostItem, |
|
2068 iTotalCount ); |
|
2069 } |
|
2070 else |
|
2071 { |
|
2072 User::Leave( KErrNotFound ); |
|
2073 } |
|
2074 CleanupStack::PushL( filler ); |
|
2075 for( TInt i = 0; i < iResultArray.Count(); i++ ) |
|
2076 { |
|
2077 filler->InsertObjectL( iSourceDevice, *iResultArray[ i ] ); |
|
2078 } |
|
2079 filler->SetSelectedIndex( currentIndex ); |
|
2080 } |
|
2081 |
|
2082 return filler; |
|
2083 } |
|
2084 |
|
2085 // -------------------------------------------------------------------------- |
|
2086 // CUPnPBrowseDialog::PlayL |
|
2087 // Plays selected music file |
|
2088 // -------------------------------------------------------------------------- |
|
2089 void CUPnPBrowseDialog::PlayL( TBool aLocal ) |
|
2090 { |
|
2091 __LOG( "CUPnPBrowseDialog::PlayL" ); |
|
2092 TInt error = KErrNone; |
|
2093 if( !aLocal ) |
|
2094 { |
|
2095 if( !iImageControlActive ) //if not played via image control |
|
2096 { //start device dialog |
|
2097 iChildDialogOpen++; |
|
2098 error = iCommonUI.SelectDeviceL( |
|
2099 iAVControl, |
|
2100 *iTargetDevice, |
|
2101 EUPnPSearchRenderingDevicesWithAudioCapability, |
|
2102 EUPnPSelectDeviceTitle ); |
|
2103 iChildDialogOpen--; |
|
2104 } |
|
2105 if ( KErrNone == error ) |
|
2106 { |
|
2107 CUPnPPlayListFiller* filler = CreateFillerLC(); |
|
2108 CleanupStack::Pop( filler ); |
|
2109 iChildDialogOpen++; |
|
2110 iMusicPlay = ETrue; |
|
2111 //filler ownership transferred |
|
2112 error = iCommonUI.ExecuteMusicPlayerL( |
|
2113 iAVControl, filler, iTargetDevice ); |
|
2114 |
|
2115 iMusicPlay = EFalse; |
|
2116 iChildDialogOpen--; |
|
2117 iEikonEnv->AppUiFactory()->StatusPane()->SwitchLayoutL( |
|
2118 R_AVKON_STATUS_PANE_LAYOUT_USUAL); |
|
2119 iAvkonEnv->LoadAknLayoutL(); |
|
2120 iAvkonAppUi->ReportResourceChangedToAppL( |
|
2121 KEikDynamicLayoutVariantSwitch ); |
|
2122 } |
|
2123 else |
|
2124 { |
|
2125 __LOG( "CUPnPBrowseDialog::PlayL SelectDeviceL failed" ); |
|
2126 } |
|
2127 } |
|
2128 else |
|
2129 { |
|
2130 CUPnPPlayListFiller* filler = CreateFillerLC(); |
|
2131 CleanupStack::Pop( filler ); |
|
2132 iChildDialogOpen++; |
|
2133 iMusicPlay = ETrue; |
|
2134 //filler ownership transferred |
|
2135 error = iCommonUI.ExecuteMusicPlayerL( iAVControl, filler, NULL ); |
|
2136 |
|
2137 iMusicPlay = EFalse; |
|
2138 iChildDialogOpen--; |
|
2139 iEikonEnv->AppUiFactory()->StatusPane()->SwitchLayoutL( |
|
2140 R_AVKON_STATUS_PANE_LAYOUT_USUAL); |
|
2141 iAvkonEnv->LoadAknLayoutL(); |
|
2142 iAvkonAppUi->ReportResourceChangedToAppL( |
|
2143 KEikDynamicLayoutVariantSwitch ); |
|
2144 } |
|
2145 |
|
2146 if( KErrNone != error ) |
|
2147 { |
|
2148 User::Leave( error ); |
|
2149 } |
|
2150 __LOG( "CUPnPBrowseDialog::PlayL-END" ); |
|
2151 } |
|
2152 |
|
2153 // -------------------------------------------------------------------------- |
|
2154 // CUPnPBrowseDialog::DisplayWaitNoteL |
|
2155 // |
|
2156 // -------------------------------------------------------------------------- |
|
2157 void CUPnPBrowseDialog::DisplayWaitNoteL( TInt aResource ) |
|
2158 { |
|
2159 __LOG( "CUPnPBrowseDialog::DisplayWaitNoteL" ); |
|
2160 |
|
2161 // Wait dialog is terminated from Ready function |
|
2162 iWaitNoteDialog = new( ELeave )CAknWaitDialog( |
|
2163 ( REINTERPRET_CAST ( CEikDialog**,&iWaitNoteDialog ) ), ETrue ); |
|
2164 iWaitNoteDialog->SetCallback( this ); |
|
2165 iWaitNoteDialog->ExecuteLD( aResource ); |
|
2166 |
|
2167 __LOG( "CUPnPBrowseDialog::DisplayWaitNoteL-END" ); |
|
2168 } |
|
2169 |
|
2170 // -------------------------------------------------------------------------- |
|
2171 // CUPnPBrowseDialog::DismissWaitNoteL |
|
2172 // |
|
2173 // -------------------------------------------------------------------------- |
|
2174 void CUPnPBrowseDialog::DismissWaitNoteL() |
|
2175 { |
|
2176 __LOG( "CUPnPBrowseDialog::DismissWaitNoteL" ); |
|
2177 |
|
2178 if ( iWaitNoteDialog ) |
|
2179 { |
|
2180 iWaitNoteDialog->ProcessFinishedL(); |
|
2181 delete iWaitNoteDialog; |
|
2182 iWaitNoteDialog = NULL; |
|
2183 } |
|
2184 |
|
2185 __LOG( "CUPnPBrowseDialog::DismissWaitNoteL-END" ); |
|
2186 } |
|
2187 |
|
2188 |
|
2189 // -------------------------------------------------------------------------- |
|
2190 // CUPnPBrowseDialog::GetHelpContext |
|
2191 // -------------------------------------------------------------------------- |
|
2192 void CUPnPBrowseDialog::GetHelpContext( TCoeHelpContext& aContext ) const |
|
2193 { |
|
2194 __LOG( "CUPnPBrowseDialog::GetHelpContext" ); |
|
2195 |
|
2196 // aContext.iMajor = TUid::Uid( KMediaGalleryUID3 ); |
|
2197 |
|
2198 aContext.iContext = KUPNP_HLP_REMOTE_DEVICES; |
|
2199 |
|
2200 TInt count = iResultArray.Count(); |
|
2201 for ( TInt index = 0; index < count; index++ ) |
|
2202 { |
|
2203 if ( iResultArray[ index ]->ObjectType() != EUPnPContainer ) |
|
2204 { |
|
2205 // show content help if folder contains items |
|
2206 aContext.iContext = KUPNP_HLP_CONTENT_VIEW; |
|
2207 // end loop |
|
2208 index = count; |
|
2209 } |
|
2210 } |
|
2211 __LOG( "CUPnPBrowseDialog::GetHelpContext-END" ); |
|
2212 } |
|
2213 |
|
2214 // -------------------------------------------------------------------------- |
|
2215 // CUPnPExternalDeviceDialog::MediaServerDisappeared |
|
2216 // -------------------------------------------------------------------------- |
|
2217 void CUPnPBrowseDialog::MediaServerDisappeared( |
|
2218 TUPnPDeviceDisconnectedReason aReason ) |
|
2219 { |
|
2220 __LOG( "CUPnPBrowseDlg::MediaServerDisappeared" ); |
|
2221 |
|
2222 TInt error = KErrNone; |
|
2223 if( aReason == EDisconnected ) |
|
2224 { |
|
2225 error = KErrSessionClosed; |
|
2226 iMSDisappear = ETrue; |
|
2227 } |
|
2228 else if( aReason == EWLANLost ) |
|
2229 { |
|
2230 error = KErrDisconnected; |
|
2231 } |
|
2232 else |
|
2233 { |
|
2234 __PANICD( __FILE__, __LINE__ ); |
|
2235 } |
|
2236 |
|
2237 TRAPD( err, DismissWaitNoteL() ); |
|
2238 if ( err != KErrNone ) |
|
2239 { |
|
2240 __LOG( "CUPnPBrowseDlg::MediaServerDisappeared \ |
|
2241 delete WaitNote error" ); |
|
2242 } |
|
2243 |
|
2244 //Only HandleCopyL will set iAction to CUPnPCommonUI::EUPnPCopy, after |
|
2245 //HandleCopyL be called, HandleErrorL also will be called. So at here |
|
2246 //HandleErrorL shouldn't be called. Otherwise will result ESLX-7M88UF |
|
2247 if ( iAction != CUPnPCommonUI::EUPnPCopy ) |
|
2248 { |
|
2249 TRAP_IGNORE( HandleErrorL( error ) ); |
|
2250 } |
|
2251 |
|
2252 __LOG( "CUPnPBrowseDlg::MediaServerDisappeared - END" ); |
|
2253 } |
|
2254 |
|
2255 // -------------------------------------------------------------------------- |
|
2256 // CUPnPExternalDeviceDialog::UpdateNaviPaneTextL |
|
2257 // -------------------------------------------------------------------------- |
|
2258 void CUPnPBrowseDialog::UpdateNaviPaneTextL() |
|
2259 { |
|
2260 __LOG( "CUPnPBrowseDialog::UpdateNaviPaneTextL" ); |
|
2261 |
|
2262 // Set text to navi pane |
|
2263 CEikStatusPane* sp = |
|
2264 ( ( CAknAppUi* )iEikonEnv->EikAppUi() )->StatusPane(); |
|
2265 iNaviPane = ( CAknNavigationControlContainer * )sp->ControlL( |
|
2266 TUid::Uid( EEikStatusPaneUidNavi ) ); |
|
2267 |
|
2268 // old decorator is popped and deleted |
|
2269 if ( iNaviDecorator ) |
|
2270 { |
|
2271 iNaviPane->Pop( iNaviDecorator ); |
|
2272 delete iNaviDecorator; |
|
2273 iNaviDecorator = NULL; |
|
2274 } |
|
2275 |
|
2276 if ( iImageControlActive ) |
|
2277 { |
|
2278 if( iTitlePane ) |
|
2279 { |
|
2280 iTitlePane->SetTextL( *StringLoader::LoadLC( |
|
2281 R_UPNPCOMMONUI_TITLE_SHOWING ) ); |
|
2282 CleanupStack::PopAndDestroy(); |
|
2283 } |
|
2284 |
|
2285 // Get device friendly name and replace illegal characters. |
|
2286 HBufC8* tmpfriendlyname = |
|
2287 UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( |
|
2288 iTargetDevice->FriendlyName() ); |
|
2289 |
|
2290 CleanupStack::PushL( tmpfriendlyname ); |
|
2291 TPtrC8 friendlyname = *tmpfriendlyname; |
|
2292 |
|
2293 HBufC *tmpbuf = UpnpString::ToUnicodeL( |
|
2294 friendlyname.Left( KLength ) ); |
|
2295 CleanupStack::PushL( tmpbuf ); |
|
2296 |
|
2297 iNaviDecorator = iNaviPane->CreateNavigationLabelL( *tmpbuf ); |
|
2298 CleanupStack::PopAndDestroy( tmpbuf ); |
|
2299 CleanupStack::PopAndDestroy( tmpfriendlyname ); |
|
2300 iNaviPane->PushL( *iNaviDecorator ); |
|
2301 } |
|
2302 // parent name is given |
|
2303 else if ( iParentName.Count() > 0 ) |
|
2304 { |
|
2305 //set back the title |
|
2306 if( iTitlePane ) |
|
2307 { |
|
2308 // Get device friendly name and replace illegal characters. |
|
2309 HBufC8* tmpfriendlyname = |
|
2310 UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( |
|
2311 iSourceDevice.FriendlyName() ); |
|
2312 CleanupStack::PushL( tmpfriendlyname ); |
|
2313 |
|
2314 TPtrC8 friendlyname = *tmpfriendlyname; |
|
2315 HBufC *tmpbuf = UpnpString::ToUnicodeL( |
|
2316 friendlyname.Left( KLength ) ); |
|
2317 CleanupStack::PushL( tmpbuf ); |
|
2318 |
|
2319 iTitlePane->SetTextL( *tmpbuf ); |
|
2320 CleanupStack::PopAndDestroy( tmpbuf ); |
|
2321 CleanupStack::PopAndDestroy( tmpfriendlyname ); |
|
2322 } |
|
2323 |
|
2324 // Get name and replace illegal characters. |
|
2325 HBufC8* tmpname = |
|
2326 UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( |
|
2327 *iParentName[ iParentName.Count() - 1 ] ); |
|
2328 |
|
2329 CleanupStack::PushL( tmpname ); |
|
2330 TPtrC8 tmpnameptr = *tmpname; |
|
2331 |
|
2332 HBufC* buf = UpnpString::ToUnicodeL( tmpnameptr.Left( KLength ) ); |
|
2333 CleanupStack::PushL(buf); |
|
2334 // ownership of decorator is transfered to application |
|
2335 iNaviDecorator = iNaviPane->CreateNavigationLabelL( *buf ); |
|
2336 CleanupStack::PopAndDestroy( buf ); |
|
2337 CleanupStack::PopAndDestroy( tmpname ); |
|
2338 iNaviPane->PushL( *iNaviDecorator ); |
|
2339 } |
|
2340 __LOG( "CUPnPBrowseDialog::UpdateNaviPaneTextL-END" ); |
|
2341 } |
|
2342 |
|
2343 // -------------------------------------------------------------------------- |
|
2344 // CUPnPBrowseDialog::CacheCheck |
|
2345 // Checks if the wanted container is in Cache |
|
2346 // -------------------------------------------------------------------------- |
|
2347 |
|
2348 TInt CUPnPBrowseDialog::CacheCheck( const TDesC8& aCheckContainerId ) |
|
2349 { |
|
2350 __LOG( "CUPnPBrowseDialog::CacheCheck" ); |
|
2351 |
|
2352 TInt retContainerCacheArrayId = -1; |
|
2353 for ( TInt index = 0; index < iBrowseCacheItems.Count(); index++ ) |
|
2354 { |
|
2355 if ( aCheckContainerId.Compare( |
|
2356 iBrowseCacheItems[ index ]->ContainerId() ) == 0 ) |
|
2357 { |
|
2358 // item is in cache |
|
2359 retContainerCacheArrayId = index; |
|
2360 break; |
|
2361 } |
|
2362 } |
|
2363 |
|
2364 __LOG( "CUPnPBrowseDialog::CacheCheck-END" ); |
|
2365 return retContainerCacheArrayId; |
|
2366 } |
|
2367 |
|
2368 // -------------------------------------------------------------------------- |
|
2369 // CUPnPBrowseDialog::SendDummyBrowseResponseL |
|
2370 // sends dummy response as browseresponse from cache |
|
2371 // -------------------------------------------------------------------------- |
|
2372 |
|
2373 void CUPnPBrowseDialog::SendDummyBrowseResponseL( TInt aCacheIndex ) |
|
2374 { |
|
2375 __LOG( "CUPnPBrowseDialog::SendDummyBrowseResponseL" ); |
|
2376 iTempArray.Reset(); |
|
2377 |
|
2378 TInt numberOfItems = iBrowseCacheItems[ aCacheIndex ]->GetNumberOfItems(); |
|
2379 for ( TInt index = 0; index < numberOfItems; index++ ) |
|
2380 { |
|
2381 iTempArray.Appendl( iBrowseCacheItems[ aCacheIndex ]-> |
|
2382 GetItem( index ) ); |
|
2383 } |
|
2384 iUppermostItem = iBrowseCacheItems[ aCacheIndex ]->GetUpperMostItem(); |
|
2385 iTotalCount = iBrowseCacheItems[ aCacheIndex ]->GetTotalCount(); |
|
2386 iCurrentItem = iBrowseCacheItems[ aCacheIndex ]->GetHighlightedItem(); |
|
2387 BrowseResponseL( KErrNone, iTotalCount, iTempArray ); |
|
2388 __LOG( "CUPnPBrowseDialog::SendDummyBrowseResponseL-END" ); |
|
2389 } |
|
2390 |
|
2391 // -------------------------------------------------------------------------- |
|
2392 // CUPnPBrowseDialog::CacheItemUpdateL |
|
2393 // updates containers cache |
|
2394 // -------------------------------------------------------------------------- |
|
2395 void CUPnPBrowseDialog::CacheItemUpdateL( const TDesC8& aContainerId, |
|
2396 TBool aNewItem ) |
|
2397 { |
|
2398 __LOG( "CUPnPBrowseDialog::CacheItemUpdateL" ); |
|
2399 if ( aNewItem ) |
|
2400 { |
|
2401 __LOG( "CUPnPBrowseDialog::CacheItemUpdateL, NewItem" ); |
|
2402 CUPnPBrowseCacheItem* test = CUPnPBrowseCacheItem::NewL( |
|
2403 aContainerId, |
|
2404 iPrevHighlighteditem, |
|
2405 iUppermostItem ); |
|
2406 CleanupStack::PushL( test ); |
|
2407 iBrowseCacheItems.AppendL( test ); |
|
2408 CleanupStack::Pop( test ); |
|
2409 } |
|
2410 else //update current item |
|
2411 { |
|
2412 TInt cacheItemIndex = CacheCheck( aContainerId ); |
|
2413 if ( cacheItemIndex > -1 ) |
|
2414 { |
|
2415 iBrowseCacheItems[ cacheItemIndex ]->SetFirstItem( |
|
2416 iUppermostItem ); |
|
2417 iBrowseCacheItems[ cacheItemIndex ]->SetHighLightedItem( |
|
2418 iCurrentItem ); |
|
2419 iBrowseCacheItems[ cacheItemIndex ]->SetTotalCount( |
|
2420 iTotalCount ); |
|
2421 //iResultArray ownership transferred here |
|
2422 iBrowseCacheItems[cacheItemIndex]->SetItemArrayL( iResultArray ); |
|
2423 } |
|
2424 } |
|
2425 __LOG( "CUPnPBrowseDialog::CacheItemUpdateL-END" ); |
|
2426 } |
|
2427 |
|
2428 // -------------------------------------------------------------------------- |
|
2429 // CUPnPBrowseDialog::SelectedArrayCheckL |
|
2430 // -------------------------------------------------------------------------- |
|
2431 void CUPnPBrowseDialog::SelectedArrayCheckL( void ) |
|
2432 { |
|
2433 __LOG( "CUPnPBrowseDialog::SelectedArrayCheckL" ); |
|
2434 const CArrayFix<TInt>* indexes = iListBox->SelectionIndexes(); |
|
2435 //add possible new selections |
|
2436 if ( indexes->Count() ) |
|
2437 { |
|
2438 for ( TInt selectionCount = 0; selectionCount < indexes->Count(); |
|
2439 selectionCount++ ) |
|
2440 { |
|
2441 TBool alreadyInArray = EFalse; |
|
2442 for ( TInt i = 0; i < iSelectedItemsArray.Count(); i++ ) |
|
2443 { |
|
2444 //checks if the selected BrowseArray item is |
|
2445 //in the selected items array |
|
2446 if ( !( iSelectedItemsArray[ i ]->Id().CompareC( ( |
|
2447 iResultArray[ indexes->At( selectionCount ) ] |
|
2448 )->Id() ) ) ) |
|
2449 |
|
2450 { |
|
2451 alreadyInArray = ETrue; |
|
2452 i = iSelectedItemsArray.Count(); |
|
2453 } |
|
2454 } |
|
2455 //if not in array add it there |
|
2456 if ( !alreadyInArray ) |
|
2457 { |
|
2458 CUpnpItem* itemForSelectionArray = CUpnpItem::NewL(); |
|
2459 |
|
2460 itemForSelectionArray->CopyL( *iResultArray[ indexes->At( |
|
2461 selectionCount ) ] ); |
|
2462 |
|
2463 iSelectedItemsArray.AppendL( itemForSelectionArray ); |
|
2464 } |
|
2465 } |
|
2466 } |
|
2467 CTextListBoxModel* model = iListBox->Model(); |
|
2468 TInt numberOfItems = model->NumberOfItems(); |
|
2469 |
|
2470 //delete unselectedItems from selected items array |
|
2471 if ( numberOfItems ) |
|
2472 { |
|
2473 const CArrayFix<TInt>* indexes = iListBox->SelectionIndexes(); |
|
2474 |
|
2475 //check all items in the current dialog |
|
2476 for ( TInt listItemIndex = 0; listItemIndex < numberOfItems; |
|
2477 listItemIndex++ ) |
|
2478 { |
|
2479 TBool notSelected = ETrue; |
|
2480 |
|
2481 //check all selected items |
|
2482 for ( TInt index = 0; index < indexes->Count() ; index++ ) |
|
2483 { |
|
2484 if ( listItemIndex == indexes->At( index ) ) |
|
2485 { |
|
2486 notSelected = EFalse; |
|
2487 index = indexes->Count(); |
|
2488 } |
|
2489 } |
|
2490 //if not selected, check if the item is in selected items array |
|
2491 if ( notSelected ) |
|
2492 { |
|
2493 //check selected items array |
|
2494 for ( TInt selectionArray = 0; |
|
2495 selectionArray < iSelectedItemsArray.Count() ; |
|
2496 selectionArray++ ) |
|
2497 |
|
2498 { |
|
2499 if ( !( iSelectedItemsArray[ selectionArray ]-> |
|
2500 Id().CompareC( |
|
2501 ( ( CUpnpItem* )iResultArray[ listItemIndex ] ) |
|
2502 ->Id() ) ) ) |
|
2503 { |
|
2504 delete iSelectedItemsArray[ selectionArray ]; |
|
2505 iSelectedItemsArray.Remove( selectionArray ); |
|
2506 iSelectedItemsArray.Compress(); |
|
2507 selectionArray = iSelectedItemsArray.Count(); |
|
2508 } |
|
2509 } |
|
2510 } |
|
2511 } |
|
2512 } |
|
2513 __LOG( "CUPnPBrowseDialog::SelectedArrayCheckL-END" ); |
|
2514 } |
|
2515 |
|
2516 // -------------------------------------------------------------------------- |
|
2517 // CUPnPBrowseDialog::StartImageControlL |
|
2518 // -------------------------------------------------------------------------- |
|
2519 void CUPnPBrowseDialog::StartImageControlL() |
|
2520 { |
|
2521 __LOG( "CUPnPBrowseDialog::StartImageControlL" ); |
|
2522 TInt error = KErrNone; |
|
2523 |
|
2524 iChildDialogOpen++; |
|
2525 error = iCommonUI.SelectDeviceL( |
|
2526 iAVControl, |
|
2527 *iTargetDevice, |
|
2528 EUPnPSearchRenderingDevicesWithImageCapability, |
|
2529 EUPnPSelectDeviceTitle ); |
|
2530 iChildDialogOpen--; |
|
2531 if ( KErrNone == error ) |
|
2532 { |
|
2533 if( !iImagePlayer ) |
|
2534 { |
|
2535 iImagePlayer = CUpnpImagePlayer::NewL( iAVControl, |
|
2536 *this, |
|
2537 iCommonUI ); |
|
2538 } |
|
2539 |
|
2540 TRAP( error, iImagePlayer->SetTargetDeviceL( *iTargetDevice ) ); |
|
2541 |
|
2542 if( KErrNone == error ) |
|
2543 { |
|
2544 StartImageControlTimer(); |
|
2545 iImageControlActive = ETrue; |
|
2546 UpdateNaviPaneTextL(); |
|
2547 UpdateSoftkeysL( R_UPNPCOMMONUI_SOFTKEYS_EMPTY_STOP ); |
|
2548 } |
|
2549 else |
|
2550 { |
|
2551 __LOG( "CUPnPBrowseDialog::StartImageControlL SetTargetDeviceL \ |
|
2552 didn't selected" ); |
|
2553 } |
|
2554 } |
|
2555 else |
|
2556 { |
|
2557 __LOG( "CUPnPBrowseDialog::StartImageControlL SelectDevice \ |
|
2558 didn't selected" ); |
|
2559 } |
|
2560 if( KErrNone != error ) |
|
2561 { |
|
2562 User::Leave( error ); |
|
2563 } |
|
2564 |
|
2565 __LOG( "CUPnPBrowseDialog::StartImageControlL-END" ); |
|
2566 } |
|
2567 |
|
2568 // -------------------------------------------------------------------------- |
|
2569 // CUPnPBrowseDialog::StopImageControlL |
|
2570 // -------------------------------------------------------------------------- |
|
2571 |
|
2572 void CUPnPBrowseDialog::StopImageControlL() |
|
2573 { |
|
2574 __LOG( "CUPnPBrowseDialog::StopImageControlL" ); |
|
2575 if ( iImageControlActive ) |
|
2576 { |
|
2577 iImageControlActive = EFalse; |
|
2578 iImageControlTimer->Cancel(); |
|
2579 ShowCurrentImageL( EFalse ); |
|
2580 UpdateNaviPaneTextL(); |
|
2581 TInt currentItemIndex = iListBox->CurrentItemIndex(); |
|
2582 if ( currentItemIndex < 0 ) |
|
2583 { |
|
2584 currentItemIndex = 0; |
|
2585 } |
|
2586 UpdateCommandButtonAreaL( EFalse, currentItemIndex ); |
|
2587 iAction = CUPnPCommonUI::EUPnPNone; |
|
2588 iImagePlayer->Stop(); |
|
2589 } |
|
2590 |
|
2591 __LOG( "CUPnPBrowseDialog::StopImageControlL-END" ); |
|
2592 } |
|
2593 |
|
2594 // -------------------------------------------------------------------------- |
|
2595 // CUPnPBrowseDialog::UpdateSoftkeysL |
|
2596 // Update CBA-keys |
|
2597 // -------------------------------------------------------------------------- |
|
2598 |
|
2599 void CUPnPBrowseDialog::UpdateSoftkeysL( TInt aResourceId ) |
|
2600 { |
|
2601 __LOG( "CUPnPBrowseDialog::UpdateSoftkeysL" ); |
|
2602 CEikButtonGroupContainer* cba = &ButtonGroupContainer(); |
|
2603 cba->SetCommandSetL( aResourceId ); |
|
2604 cba->DrawDeferred(); |
|
2605 __LOG( "CUPnPBrowseDialog::UpdateSoftkeysL-END" ); |
|
2606 } |
|
2607 |
|
2608 // -------------------------------------------------------------------------- |
|
2609 // UPnPImagePlayerDialog::ImageControlTimerCallbackL |
|
2610 // Callback method for the Timer. |
|
2611 // -------------------------------------------------------------------------- |
|
2612 TInt CUPnPBrowseDialog::ImageControlTimerCallbackL( TAny* aDlg ) |
|
2613 { |
|
2614 __LOG( "CUPnPBrowseDialog::ImageControlTimerCallbackL" ); |
|
2615 static_cast< CUPnPBrowseDialog* >( aDlg )->iImageControlTimer->Cancel(); |
|
2616 if ( !( static_cast< CUPnPBrowseDialog* >( aDlg )->iBrowseRequestSent ) ) |
|
2617 { |
|
2618 static_cast< CUPnPBrowseDialog* >( aDlg )->ShowCurrentImageL( ETrue ); |
|
2619 } |
|
2620 else |
|
2621 { |
|
2622 static_cast<CUPnPBrowseDialog*>(aDlg)->StartImageControlTimer(); |
|
2623 } |
|
2624 __LOG( "CUPnPBrowseDialog::ImageControlTimerCallbackL-END" ); |
|
2625 return KErrNone; |
|
2626 } |
|
2627 |
|
2628 |
|
2629 // -------------------------------------------------------------------------- |
|
2630 // CUPnPBrowseDialog::StartImageControlTimer |
|
2631 // Starts periodic timer |
|
2632 // -------------------------------------------------------------------------- |
|
2633 void CUPnPBrowseDialog::StartImageControlTimer( void ) |
|
2634 { |
|
2635 __LOG( "CUPnPBrowseDialog::StartImageControlTimer" ); |
|
2636 iImageControlTimer->Start( |
|
2637 KImageTimerDelay, |
|
2638 KImageTimerInterval, |
|
2639 TCallBack( ImageControlTimerCallbackL, this ) ); |
|
2640 __LOG( "CUPnPBrowseDialog::StartImageControlTimer-END" ); |
|
2641 } |
|
2642 |
|
2643 // -------------------------------------------------------------------------- |
|
2644 // CUPnPBrowseDialog::ShowCurrentImageL |
|
2645 // -------------------------------------------------------------------------- |
|
2646 void CUPnPBrowseDialog::ShowCurrentImageL( TBool aShowImage ) |
|
2647 { |
|
2648 __LOG( "CUPnPBrowseDialog::ShowCurrentImageL" ); |
|
2649 |
|
2650 TInt currentItemIndex = iListBox->CurrentItemIndex(); |
|
2651 if ( currentItemIndex < 0 ) |
|
2652 { |
|
2653 currentItemIndex = 0; |
|
2654 } |
|
2655 |
|
2656 CTextListBoxModel* model = iListBox->Model(); |
|
2657 MDesCArray* textArray = model->ItemTextArray(); |
|
2658 CDesCArray* listBoxItems = static_cast< CDesCArray* >( textArray ); |
|
2659 |
|
2660 if( iLastImageItemIndex >= 0 ) //if last item was image |
|
2661 { |
|
2662 TBuf<KMaxFileName> lastItem; |
|
2663 HBufC *lastTmpItem = UpnpString::ToUnicodeL( |
|
2664 iResultArray[ iLastImageItemIndex ]->Title().Left( KLength ) ); |
|
2665 CleanupStack::PushL( lastTmpItem ); |
|
2666 lastItem.Format( KFormatString(), |
|
2667 EUPnPIconImage, |
|
2668 lastTmpItem); |
|
2669 CleanupStack::PopAndDestroy ( lastTmpItem ); |
|
2670 |
|
2671 listBoxItems->Delete( iLastImageItemIndex ); |
|
2672 listBoxItems->InsertL( iLastImageItemIndex, lastItem ); |
|
2673 iListBox->HandleItemAdditionL(); |
|
2674 if( ( iResultArray[ iListBox->CurrentItemIndex() ] )-> |
|
2675 ObjectClass().Find( KClassImage ) != 0 ) |
|
2676 { |
|
2677 iLastImageItemIndex = KErrNotFound; |
|
2678 } |
|
2679 } |
|
2680 |
|
2681 if ( ( iResultArray[ iListBox->CurrentItemIndex() ] )-> |
|
2682 ObjectClass().Find( KClassImage ) == 0 ) |
|
2683 { |
|
2684 if( ( CUpnpItem* )iResultArray[ currentItemIndex ] |
|
2685 ->Title().Length() != 0 ) |
|
2686 { |
|
2687 HBufC *tmpItem = UpnpString::ToUnicodeL( |
|
2688 iResultArray[ currentItemIndex ]-> |
|
2689 Title().Left( KLength ) ); |
|
2690 CleanupStack::PushL( tmpItem ); |
|
2691 |
|
2692 TBuf<KMaxFileName> item; |
|
2693 //if not showing an image |
|
2694 if ( !aShowImage ) |
|
2695 { |
|
2696 item.Format( KFormatString(), EUPnPIconImage, tmpItem); |
|
2697 iLastImageItemIndex = KErrNotFound; |
|
2698 listBoxItems->Delete( currentItemIndex ); |
|
2699 listBoxItems->InsertL( currentItemIndex, item ); |
|
2700 } |
|
2701 else //if showing an image |
|
2702 { |
|
2703 |
|
2704 item.Format( KFormatString2() ,EUPnPIconImage, |
|
2705 tmpItem, |
|
2706 EUPnPIconImageShowing ); |
|
2707 if(iImagePlayer) |
|
2708 { |
|
2709 __LOG( "CUPnPBrowseDialog::iImagePlayer->PlayL" ); |
|
2710 iAction = CUPnPCommonUI::EUPnPShow; |
|
2711 TRAPD( error, iImagePlayer->PlayL( |
|
2712 *iResultArray[currentItemIndex] ) ); |
|
2713 |
|
2714 HandleErrorL( error ); |
|
2715 |
|
2716 } |
|
2717 |
|
2718 //listBoxItem.Set( item ); |
|
2719 listBoxItems->Delete( currentItemIndex ); |
|
2720 listBoxItems->InsertL( currentItemIndex, item ); |
|
2721 iLastImageItemIndex = currentItemIndex; |
|
2722 } |
|
2723 CleanupStack::PopAndDestroy ( tmpItem ); |
|
2724 iListBox->HandleItemAdditionL(); |
|
2725 iListBox->SetCurrentItemIndexAndDraw( currentItemIndex ); |
|
2726 } |
|
2727 } |
|
2728 |
|
2729 __LOG( "CUPnPBrowseDialog::ShowCurrentImageL-END" ); |
|
2730 } |
|
2731 |
|
2732 // -------------------------------------------------------------------------- |
|
2733 // CUPnPBrowseDialog::ShowVideoDialogExt |
|
2734 // -------------------------------------------------------------------------- |
|
2735 void CUPnPBrowseDialog::ShowVideoDialogExtL() |
|
2736 { |
|
2737 __LOG( "CUPnPBrowseDialog::ShowVideoDialogExtL" ); |
|
2738 |
|
2739 TInt error = KErrNone; |
|
2740 |
|
2741 const CUpnpObject* selectedObject = |
|
2742 iResultArray[ iListBox->CurrentItemIndex() ]; |
|
2743 |
|
2744 if( !iImageControlActive ) //if showing video is not from image timer |
|
2745 { //then start select device dialog |
|
2746 iChildDialogOpen++; |
|
2747 error = iCommonUI.SelectDeviceL( |
|
2748 iAVControl, |
|
2749 *iTargetDevice, |
|
2750 EUPnPSearchRenderingDevicesWithVideoCapability, |
|
2751 EUPnPSelectDeviceTitle ); |
|
2752 iChildDialogOpen--; |
|
2753 } |
|
2754 else //if target renderer exists, check video capability |
|
2755 { |
|
2756 if( !iTargetDevice->VideoCapability() ) |
|
2757 { |
|
2758 User::Leave( KErrNotSupported ); |
|
2759 } |
|
2760 } |
|
2761 if( KErrNone == error ) |
|
2762 { |
|
2763 iAction = CUPnPCommonUI::EUPnPShow; |
|
2764 MUPnPAVRenderingSession* renderingSession = NULL; |
|
2765 renderingSession = &( iAVControl.StartRenderingSessionL( |
|
2766 *iTargetDevice ) ); |
|
2767 |
|
2768 iChildDialogOpen++; |
|
2769 //trap here to release rendering session properly, better to |
|
2770 //create and destroy the rendering ession inside the video player |
|
2771 TInt ret = KErrNone; |
|
2772 TRAP( error, ret = iCommonUI.ExecuteVideoPlayerL( |
|
2773 *renderingSession, |
|
2774 *selectedObject ) ); |
|
2775 |
|
2776 if( ret < KErrNone && error == KErrNone ) |
|
2777 { |
|
2778 error = ret; |
|
2779 } |
|
2780 renderingSession->RemoveObserver(); |
|
2781 iAVControl.StopRenderingSession( *renderingSession ); |
|
2782 |
|
2783 iChildDialogOpen--; |
|
2784 |
|
2785 //if not media server or wlan lost, update its navipane |
|
2786 if( !iMSDisappear && error != KErrDisconnected ) |
|
2787 { |
|
2788 UpdateNaviPaneTextL(); |
|
2789 } |
|
2790 } |
|
2791 else |
|
2792 { |
|
2793 __LOG( "ShowVideoDialogExtL: SetTargetDeviceL FAILED" ); |
|
2794 } |
|
2795 |
|
2796 if( KErrNone != error ) |
|
2797 { |
|
2798 User::Leave( error ); |
|
2799 } |
|
2800 |
|
2801 __LOG( "CUPnPBrowseDialog::ShowVideoDialogExtL-END" ); |
|
2802 } |
|
2803 |
|
2804 // -------------------------------------------------------------------------- |
|
2805 // CUPnPBrowseDialog::HandleCopyL() |
|
2806 // -------------------------------------------------------------------------- |
|
2807 void CUPnPBrowseDialog::HandleCopyL() |
|
2808 { |
|
2809 __LOG( "CUPnPBrowseDialog::HandleCopyL" ); |
|
2810 |
|
2811 iAction = CUPnPCommonUI::EUPnPCopy; |
|
2812 iCopyIndex = NULL; |
|
2813 TInt selected_item = iListBox->CurrentItemIndex(); |
|
2814 iCopying = ETrue; |
|
2815 if( iResultArray[ selected_item ]->ObjectType() == EUPnPContainer ) |
|
2816 { |
|
2817 // Instantiate the UPnP File Transfer Engine |
|
2818 CUpnpFileTransferEngine* ftEngine = |
|
2819 CUpnpFileTransferEngine::NewL( iBrowseSession ); |
|
2820 CleanupStack::PushL( ftEngine ); |
|
2821 |
|
2822 TBool playlistContainer = EFalse; |
|
2823 playlistContainer = UPnPCommonUtils::IsPlaylistContainerL( |
|
2824 *iResultArray[ iListBox->CurrentItemIndex() ] ); |
|
2825 |
|
2826 // Copy container to phone memory |
|
2827 TInt copyErr = KErrNone; |
|
2828 if( playlistContainer ) |
|
2829 { |
|
2830 TRAP( copyErr, ftEngine->CopyRemotePlaylistToHandsetL( |
|
2831 ( CUpnpContainer* )iResultArray[ |
|
2832 iListBox->CurrentItemIndex() ] ) ); |
|
2833 } |
|
2834 else |
|
2835 { |
|
2836 TRAP( copyErr, ftEngine->CopyRemoteContainerToHandsetL( |
|
2837 ( CUpnpContainer* )iResultArray[ |
|
2838 iListBox->CurrentItemIndex() ] ) ); |
|
2839 } |
|
2840 |
|
2841 iCopyIndex = ftEngine->ItemCopiedFromContainer(); |
|
2842 |
|
2843 User::LeaveIfError( copyErr ); |
|
2844 |
|
2845 // Clean up ftEngine |
|
2846 CleanupStack::PopAndDestroy( ftEngine ); |
|
2847 ftEngine = NULL; |
|
2848 } |
|
2849 else |
|
2850 { |
|
2851 RPointerArray<CUpnpItem> tempArrayForCopy; |
|
2852 CleanupResetAndDestroyPushL( tempArrayForCopy ); |
|
2853 if ( iSelectedItemsArray.Count() ) |
|
2854 { |
|
2855 for ( TInt count=0; |
|
2856 count < iSelectedItemsArray.Count(); |
|
2857 count++ ) |
|
2858 { |
|
2859 CUpnpItem* tempItem = CUpnpItem::NewL(); |
|
2860 CleanupStack::PushL( tempItem ); |
|
2861 |
|
2862 |
|
2863 tempItem->CopyL( *iSelectedItemsArray[ count ] ); |
|
2864 |
|
2865 //ownership transferred |
|
2866 tempArrayForCopy.AppendL( tempItem ); |
|
2867 CleanupStack::Pop( tempItem ); |
|
2868 } |
|
2869 iCopyIndex = iSelectedItemsArray.Count(); |
|
2870 } |
|
2871 else |
|
2872 { |
|
2873 CUpnpItem* tempItem = CUpnpItem::NewL(); |
|
2874 CleanupStack::PushL( tempItem ); |
|
2875 tempItem->CopyL( *iResultArray[selected_item] ); |
|
2876 //ownership transferred |
|
2877 tempArrayForCopy.AppendL( tempItem ); |
|
2878 CleanupStack::Pop( tempItem ); |
|
2879 iCopyIndex = 1; |
|
2880 } |
|
2881 // Instantiate the UPnP File Transfer Engine |
|
2882 CUpnpFileTransferEngine* ftEngine = NULL; |
|
2883 ftEngine = CUpnpFileTransferEngine::NewL( iBrowseSession ); |
|
2884 CleanupStack::PushL( ftEngine ); |
|
2885 // Copy to phone |
|
2886 ftEngine->CopyRemoteItemsToHandsetL( tempArrayForCopy ); |
|
2887 // Clean up ftEngine |
|
2888 CleanupStack::PopAndDestroy( ftEngine ); |
|
2889 ftEngine = NULL; |
|
2890 CleanupStack::PopAndDestroy( &tempArrayForCopy ); |
|
2891 } |
|
2892 iCopying = EFalse; |
|
2893 UnmarkAllItems(); |
|
2894 |
|
2895 __LOG( "CUPnPBrowseDialog::HandleCopyL-END" ); |
|
2896 |
|
2897 } |
|
2898 |
|
2899 // -------------------------------------------------------------------------- |
|
2900 // CUPnPBrowseDialog::DeviceDisappeared( TInt aError ) |
|
2901 // called in image play |
|
2902 //--------------------------------------------------------------------------- |
|
2903 void CUPnPBrowseDialog::DeviceDisappeared( TInt aError ) |
|
2904 { |
|
2905 TRAP_IGNORE( HandleErrorL( aError ) ); |
|
2906 } |
|
2907 |
|
2908 // -------------------------------------------------------------------------- |
|
2909 // CUPnPBrowseDialog::HandleErrorL( TInt aError ) |
|
2910 // Handle errors in all the case EGKL-6ZPH89 |
|
2911 //--------------------------------------------------------------------------- |
|
2912 void CUPnPBrowseDialog::HandleErrorL( TInt aError ) |
|
2913 { |
|
2914 iCommonUI.GetUpnpAction( iAction ); |
|
2915 //if media server or WLAN lost, close the browse dialog |
|
2916 if( ( KErrSessionClosed == aError && iMSDisappear ) || |
|
2917 KErrDisconnected == aError || |
|
2918 EAknCmdExit == aError || |
|
2919 EEikCmdExit == aError ) |
|
2920 { |
|
2921 if( iError == KErrNone ) |
|
2922 { |
|
2923 iError = aError; |
|
2924 } |
|
2925 |
|
2926 if( iChildDialogOpen > 0 ) |
|
2927 { |
|
2928 //if some dialos are open on the top of browse dialog, |
|
2929 //close those dialogs and do the corresponding action via |
|
2930 //errors returned from them |
|
2931 iCommonUI.DismissDialogL( aError ); |
|
2932 } |
|
2933 else //if no, do the corresponding action via the error |
|
2934 { |
|
2935 TryExitL( aError ); |
|
2936 } |
|
2937 } |
|
2938 else |
|
2939 { |
|
2940 // if media renderer disappears |
|
2941 if( KErrSessionClosed == aError && !iMSDisappear ) |
|
2942 { |
|
2943 StopImageControlL(); |
|
2944 UpdateNaviPaneTextL(); |
|
2945 } |
|
2946 |
|
2947 iCommonUI.HandleCommonErrorL( aError, iCopyIndex ); |
|
2948 iAction = CUPnPCommonUI::EUPnPNone; |
|
2949 iCopyIndex = NULL; |
|
2950 } |
|
2951 } |
|
2952 |
|
2953 // -------------------------------------------------------------------------- |
|
2954 // CUPnPBrowseDialog::HandleResourceChange |
|
2955 // -------------------------------------------------------------------------- |
|
2956 // |
|
2957 void CUPnPBrowseDialog::HandleResourceChange(TInt aType) |
|
2958 { |
|
2959 __LOG("[UPnPCommonUI]\t CUPnPBrowseDialog::HandleResourceChange"); |
|
2960 CAknDialog::HandleResourceChange(aType); |
|
2961 } |
|
2962 |
|
2963 // -------------------------------------------------------------------------- |
|
2964 // CUPnPBrowseDialog::IsAudioItemMarked |
|
2965 // -------------------------------------------------------------------------- |
|
2966 TBool CUPnPBrowseDialog::IsAudioItemMarked( void ) |
|
2967 { |
|
2968 TBool mark = EFalse; |
|
2969 const CArrayFix<TInt>* indexes = iListBox->SelectionIndexes(); |
|
2970 if ( indexes->Count() ) //if items are marked |
|
2971 { |
|
2972 for (TInt count=0; count < indexes->Count(); count++) |
|
2973 { |
|
2974 if ( ( iResultArray[indexes->At(count)])-> |
|
2975 ObjectClass().Find( KClassAudio ) |
|
2976 == 0 ) //audio |
|
2977 { |
|
2978 mark = ETrue; |
|
2979 count = indexes->Count(); |
|
2980 } |
|
2981 } |
|
2982 } |
|
2983 __LOG( "CUPnPBrowseDialog::IsAudioItemMarked-END" ); |
|
2984 return mark; |
|
2985 } |
|
2986 |
|
2987 // -------------------------------------------------------------------------- |
|
2988 // CUPnPBrowseDialog::UpdateCommandButtonAreaL( |
|
2989 // TBool aMark, TInt tempCounter ) |
|
2990 // Updates command button area |
|
2991 // -------------------------------------------------------------------------- |
|
2992 void CUPnPBrowseDialog::UpdateCommandButtonAreaL( TBool aMark, |
|
2993 TInt aTempCounter ) |
|
2994 { |
|
2995 if( aTempCounter>=0 && iResultArray.Count() ) |
|
2996 { |
|
2997 if( !aMark ) // no marked items in the list box |
|
2998 { |
|
2999 if( ( UPnPItemUtility::BelongsToClass( |
|
3000 *iResultArray[aTempCounter], KClassImage ) ) || |
|
3001 ( UPnPItemUtility::BelongsToClass( |
|
3002 *iResultArray[aTempCounter], KClassVideo ) ) ) |
|
3003 { |
|
3004 UpdateSoftkeysL( |
|
3005 R_UPNPCOMMONUI_SOFTKEYS_OPTIONS_BACK__SHOW ); |
|
3006 } |
|
3007 else if( ( UPnPItemUtility::BelongsToClass( |
|
3008 *iResultArray[aTempCounter], KClassAudio ) ) ) |
|
3009 { |
|
3010 UpdateSoftkeysL( |
|
3011 R_UPNPCOMMONUI_SOFTKEYS_OPTIONS_BACK__PLAY ); |
|
3012 } |
|
3013 else if( ( UPnPItemUtility::BelongsToClass( |
|
3014 *iResultArray[aTempCounter], KClassContainer ) ) ) |
|
3015 { |
|
3016 UpdateSoftkeysL( |
|
3017 R_UPNPCOMMONUI_SOFTKEYS_OPTIONS_BACK__OPEN ); |
|
3018 } |
|
3019 else |
|
3020 { |
|
3021 UpdateSoftkeysL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); |
|
3022 } |
|
3023 } |
|
3024 else // at least one marked item in the list box |
|
3025 { |
|
3026 if( ( UPnPItemUtility::BelongsToClass( |
|
3027 *iResultArray[aTempCounter], KClassContainer ) ) ) |
|
3028 { |
|
3029 UpdateSoftkeysL( |
|
3030 R_UPNPCOMMONUI_SOFTKEYS_OPTIONS_BACK__OPEN ); |
|
3031 } |
|
3032 else if( !IsAudioItemMarked() ) |
|
3033 { |
|
3034 //if no audio item have been marked. |
|
3035 UpdateSoftkeysL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); |
|
3036 } |
|
3037 else |
|
3038 { |
|
3039 if( !( UPnPItemUtility::BelongsToClass( |
|
3040 *iResultArray[aTempCounter], KClassAudio ) ) ) |
|
3041 { |
|
3042 UpdateSoftkeysL( R_AVKON_SOFTKEYS_OPTIONS_BACK ); |
|
3043 } |
|
3044 else |
|
3045 { |
|
3046 UpdateSoftkeysL( |
|
3047 R_UPNPCOMMONUI_SOFTKEYS_OPTIONS_BACK__PLAY ); |
|
3048 } |
|
3049 } |
|
3050 } |
|
3051 } |
|
3052 } |
|
3053 |
|
3054 // -------------------------------------------------------------------------- |
|
3055 // CUPnPBrowseDialog::UpdateCommandButtonArea( TBool aMark, TInt tempCounter ) |
|
3056 // Updates command button area |
|
3057 // -------------------------------------------------------------------------- |
|
3058 void CUPnPBrowseDialog::UpdateCommandButtonArea( TBool aMark, |
|
3059 TInt aTempCounter ) |
|
3060 { |
|
3061 TInt error = KErrNone; |
|
3062 TRAP( error, UpdateCommandButtonAreaL( aMark, aTempCounter ) ); |
|
3063 if( error ) |
|
3064 { |
|
3065 __LOG1( "UpdateCommandButtonAreaL error,error=%d", error ); |
|
3066 } |
|
3067 } |
|
3068 |
|
3069 // End of file |
|