|
26
|
1 |
/*
|
|
|
2 |
* Copyright (c) 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: Implementation of UPnP players browse Dialog
|
|
|
15 |
*
|
|
|
16 |
*/
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
// INCLUDE FILES
|
|
|
21 |
#include <aknPopupHeadingPane.h>
|
|
|
22 |
#include <aknPopup.h>
|
|
|
23 |
#include <aknlists.h>
|
|
|
24 |
#include <AknIconArray.h>
|
|
|
25 |
#include <gulicon.h>
|
|
|
26 |
#include <StringLoader.h>
|
|
|
27 |
#include <data_caging_path_literals.hrh> // KDC_APP_RESOURCE_DIR
|
|
|
28 |
#include <bautils.h> // BaflUtils
|
|
|
29 |
#include <AknsConstants.h>
|
|
|
30 |
#include <aknnotewrappers.h>
|
|
|
31 |
|
|
|
32 |
#include "mpxupnpbrowsedialog.h"
|
|
|
33 |
#include <mpxupnpbrowsedialog.rsg>
|
|
|
34 |
#include <mpxmessagegeneraldefs.h>
|
|
|
35 |
#include <mpxviewutility.h>
|
|
|
36 |
#include <mpxmusicplayerviewplugin.hrh>
|
|
|
37 |
#include "mpxplayermanagerstub.h"
|
|
|
38 |
#include "mpxlog.h"
|
|
|
39 |
|
|
|
40 |
#include <aknconsts.h>
|
|
|
41 |
#include <avkon.mbg>
|
|
|
42 |
#include <errorres.rsg>
|
|
|
43 |
#include <wlanerrorcodes.h>
|
|
|
44 |
|
|
|
45 |
#include <mpxmedia.h>
|
|
|
46 |
#include <mpxplaybackutility.h> // MMPXPlayerManager, MMPXPlaybackUtility
|
|
|
47 |
#include <mpxplaybackmessage.h>
|
|
|
48 |
#include <mpxplaybackframeworkdefs.h>
|
|
|
49 |
#include <mpxcommandgeneraldefs.h> // KMPXCommandGeneralDoSync
|
|
|
50 |
#include <mpxcollectionplaylist.h>
|
|
|
51 |
#include <mpxuser.h>
|
|
|
52 |
|
|
|
53 |
// CONSTANTS
|
|
|
54 |
_LIT( KMPlayerUPnPBrowserDialogRscPath, "mpxupnpbrowsedialog.rsc" );
|
|
|
55 |
|
|
|
56 |
_LIT( KUPnPBrowseListboxString, "%S\t%d\t" );
|
|
|
57 |
_LIT(KTab,"\t");
|
|
|
58 |
_LIT(KSpace, " ");
|
|
|
59 |
|
|
|
60 |
// ---------------------------------------------------------------------------
|
|
|
61 |
// CMPXUPnPBrowseDialog::NewL
|
|
|
62 |
// Two-phased constructor.
|
|
|
63 |
// ---------------------------------------------------------------------------
|
|
|
64 |
EXPORT_C CMPXUPnPBrowseDialog* CMPXUPnPBrowseDialog::NewL(TInt aPlayerUid)
|
|
|
65 |
{
|
|
|
66 |
CMPXUPnPBrowseDialog* self = new (ELeave) CMPXUPnPBrowseDialog(aPlayerUid);
|
|
|
67 |
CleanupStack::PushL(self);
|
|
|
68 |
self->ConstructL();
|
|
|
69 |
CleanupStack::Pop();
|
|
|
70 |
return self;
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
// ---------------------------------------------------------------------------
|
|
|
74 |
// CMPXUPnPBrowseDialog::ConstructL
|
|
|
75 |
// Symbian 2nd phase constructor can leave.
|
|
|
76 |
// ---------------------------------------------------------------------------
|
|
|
77 |
void CMPXUPnPBrowseDialog::ConstructL( )
|
|
|
78 |
{
|
|
|
79 |
MPX_FUNC( "CMPXUPnPBrowseDialog::ConstructL" );
|
|
|
80 |
|
|
|
81 |
// Get the playback utility instance from engine.
|
|
|
82 |
iPlaybackUtility = MMPXPlaybackUtility::UtilityL( KPbModeDefault );
|
|
|
83 |
iPlaybackUtility->AddObserverL( *this );
|
|
|
84 |
|
|
|
85 |
// Load resource file
|
|
|
86 |
//
|
|
|
87 |
TParse parse;
|
|
|
88 |
parse.Set( KMPlayerUPnPBrowserDialogRscPath, &KDC_APP_RESOURCE_DIR, NULL );
|
|
|
89 |
TFileName resourceFile( parse.FullName() );
|
|
|
90 |
User::LeaveIfError( MPXUser::CompleteWithDllPath( resourceFile ) );
|
|
|
91 |
BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(),
|
|
|
92 |
resourceFile );
|
|
|
93 |
iResourceOffset = CCoeEnv::Static()->AddResourceFileL( resourceFile );
|
|
|
94 |
|
|
|
95 |
iViewUtility = MMPXViewUtility::UtilityL();
|
|
|
96 |
}
|
|
|
97 |
|
|
|
98 |
// ---------------------------------------------------------------------------
|
|
|
99 |
// CMPXUPnPBrowseDialog::CMPXUPnPBrowseDialog
|
|
|
100 |
// C++ default constructor can NOT contain any code, that
|
|
|
101 |
// might leave.
|
|
|
102 |
// ---------------------------------------------------------------------------
|
|
|
103 |
CMPXUPnPBrowseDialog::CMPXUPnPBrowseDialog(TInt aPlayerUid) :
|
|
|
104 |
iPlayerUid(aPlayerUid)
|
|
|
105 |
{
|
|
|
106 |
}
|
|
|
107 |
|
|
|
108 |
// Destructor
|
|
|
109 |
CMPXUPnPBrowseDialog::~CMPXUPnPBrowseDialog()
|
|
|
110 |
{
|
|
|
111 |
MPX_FUNC( "CMPXUPnPBrowseDialog::Destructor" );
|
|
|
112 |
if (iResourceOffset)
|
|
|
113 |
{
|
|
|
114 |
CCoeEnv::Static()->DeleteResourceFile( iResourceOffset );
|
|
|
115 |
}
|
|
|
116 |
delete iListBox;
|
|
|
117 |
|
|
|
118 |
//Already cancelled in the destructor
|
|
|
119 |
delete iPlayerManagerStub;
|
|
|
120 |
|
|
|
121 |
if ( iPlaybackUtility )
|
|
|
122 |
{
|
|
|
123 |
TRAP_IGNORE( iPlaybackUtility->RemoveObserverL( *this ) );
|
|
|
124 |
iPlaybackUtility->Close();
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
delete iCurrentlySelectedSubPlayerName;
|
|
|
128 |
|
|
|
129 |
if ( iViewUtility )
|
|
|
130 |
{
|
|
|
131 |
iViewUtility->Close();
|
|
|
132 |
}
|
|
|
133 |
}
|
|
|
134 |
|
|
|
135 |
// -----------------------------------------------------------------------------
|
|
|
136 |
// Executes the popup list
|
|
|
137 |
// -----------------------------------------------------------------------------
|
|
|
138 |
//
|
|
|
139 |
EXPORT_C TInt CMPXUPnPBrowseDialog::ExecuteLD(TInt aPlayerUid)
|
|
|
140 |
{
|
|
|
141 |
MPX_FUNC( "CMPXUPnPBrowseDialog::ExecuteLD()" );
|
|
|
142 |
TInt errorSelectSubPlayer = KErrNone;
|
|
|
143 |
TBool okToExit = EFalse;
|
|
|
144 |
TInt selectedSubplayerIndex = KErrNotFound;
|
|
|
145 |
iPlayerUnavailableError = EFalse;
|
|
|
146 |
|
|
|
147 |
iPlayerUid = aPlayerUid;
|
|
|
148 |
|
|
|
149 |
while ( !okToExit )
|
|
|
150 |
{
|
|
|
151 |
RetrieveCurrentlySelectSubplayerNameL();
|
|
|
152 |
CreatePopupL();
|
|
|
153 |
TInt returnValue = StartPopupL();
|
|
|
154 |
MPX_DEBUG2( "CMPXUPnPBrowseDialog::ExecuteLD() after StartPopupL() returnValue %d", returnValue );
|
|
|
155 |
|
|
|
156 |
// if 1, Select was pressed
|
|
|
157 |
if ( returnValue )
|
|
|
158 |
{
|
|
|
159 |
TInt currentItemIndex = iListBox->CurrentItemIndex();
|
|
|
160 |
TInt numberOfItems = iListBox->Model()->NumberOfItems();
|
|
|
161 |
|
|
|
162 |
// check for boundaries
|
|
|
163 |
// if currentItemIndex is valid
|
|
|
164 |
if ( ( currentItemIndex >= 0 ) &&
|
|
|
165 |
( currentItemIndex < numberOfItems ) )
|
|
|
166 |
{
|
|
|
167 |
MPX_DEBUG2( "CMPXUPnPBrowseDialog::ExecuteLD() currentItemIndex %d", currentItemIndex );
|
|
|
168 |
MPX_DEBUG2( "CMPXUPnPBrowseDialog::ExecuteLD() numberOfItems %d", numberOfItems );
|
|
|
169 |
|
|
|
170 |
// if a subplayer was selected (and not <search again>)
|
|
|
171 |
HBufC* listText =
|
|
|
172 |
StringLoader::LoadLC(R_UPNP_LIST_UPNP_MORE_SUBPLAYERS);
|
|
|
173 |
TInt isSelectedItemASubplayerName =
|
|
|
174 |
listText->CompareF(
|
|
|
175 |
(iListBox->Model()->ItemText(currentItemIndex)) );
|
|
|
176 |
MPX_DEBUG2( "CMPXUPnPBrowseDialog::ExecuteLD() isSelectedItemASubplayerName %d", isSelectedItemASubplayerName );
|
|
|
177 |
CleanupStack::PopAndDestroy( listText );
|
|
|
178 |
|
|
|
179 |
if ( isSelectedItemASubplayerName )
|
|
|
180 |
{
|
|
|
181 |
if ( iPlaybackUtility )
|
|
|
182 |
{
|
|
|
183 |
iPlaybackUtility->CancelRequest();
|
|
|
184 |
}
|
|
|
185 |
|
|
|
186 |
TBool selecDifferentSubPlayer = ETrue;
|
|
|
187 |
|
|
|
188 |
if ( iCurrentlySelectedSubPlayerName )
|
|
|
189 |
{
|
|
|
190 |
TFileName listName(iListBox->Model()->ItemText(currentItemIndex));
|
|
|
191 |
TInt index = listName.Find(KTab);
|
|
|
192 |
if ( index >= 0 )
|
|
|
193 |
{
|
|
|
194 |
TFileName subPlayerName = listName.LeftTPtr(index);
|
|
|
195 |
selecDifferentSubPlayer =
|
|
|
196 |
( ( subPlayerName.CompareF(
|
|
|
197 |
*iCurrentlySelectedSubPlayerName ) ) &&
|
|
|
198 |
( aPlayerUid == iCurrentlyUsedPlayer.iUid) );
|
|
|
199 |
}
|
|
|
200 |
else
|
|
|
201 |
{
|
|
|
202 |
selecDifferentSubPlayer =
|
|
|
203 |
( ( listName.CompareF(
|
|
|
204 |
*iCurrentlySelectedSubPlayerName ) ) &&
|
|
|
205 |
( aPlayerUid == iCurrentlyUsedPlayer.iUid) );
|
|
|
206 |
}
|
|
|
207 |
MPX_DEBUG2( "CMPXUPnPBrowseDialog::ExecuteLD() selecDifferentSubPlayer %d", selecDifferentSubPlayer);
|
|
|
208 |
}
|
|
|
209 |
|
|
|
210 |
if(iPlaybackUtility)
|
|
|
211 |
{
|
|
|
212 |
MMPXSource* source = iPlaybackUtility->Source();
|
|
|
213 |
CMPXCollectionPlaylist* playlist = NULL;
|
|
|
214 |
if ( source )
|
|
|
215 |
{
|
|
|
216 |
playlist = source->PlaylistL();
|
|
|
217 |
if ( playlist )
|
|
|
218 |
{
|
|
|
219 |
CleanupStack::PushL( playlist );
|
|
|
220 |
}
|
|
|
221 |
}
|
|
|
222 |
|
|
|
223 |
MMPXPlayerManager& manager = iPlaybackUtility->PlayerManager();
|
|
|
224 |
// user selects a different remote player
|
|
|
225 |
if ( iCurrentlySelectedSubPlayerName &&
|
|
|
226 |
selecDifferentSubPlayer )
|
|
|
227 |
{
|
|
|
228 |
// need to clean up the current plugin
|
|
|
229 |
TRAP_IGNORE( manager.ClearSelectPlayersL() );
|
|
|
230 |
}
|
|
|
231 |
|
|
|
232 |
MPX_DEBUG3( "CMPXUPnPBrowseDialog::ExecuteLD() before call to manager.SelectSubPlayerL(%d, %d)", iPlayerUid, currentItemIndex );
|
|
|
233 |
MPX_TRAP( errorSelectSubPlayer,
|
|
|
234 |
manager.SelectSubPlayerL( TUid::Uid(iPlayerUid),
|
|
|
235 |
currentItemIndex ) );
|
|
|
236 |
|
|
|
237 |
MPX_DEBUG2( "CMPXUPnPBrowseDialog::ExecuteLD() after manager.SelectSubPlayerL()", errorSelectSubPlayer );
|
|
|
238 |
if ( errorSelectSubPlayer == KErrNone )
|
|
|
239 |
{
|
|
|
240 |
okToExit = ETrue;
|
|
|
241 |
|
|
|
242 |
if ( selecDifferentSubPlayer )
|
|
|
243 |
{
|
|
|
244 |
selectedSubplayerIndex = currentItemIndex;
|
|
|
245 |
}
|
|
|
246 |
else // subplayer selected is the same as the current one
|
|
|
247 |
{
|
|
|
248 |
selectedSubplayerIndex = KErrInUse;
|
|
|
249 |
}
|
|
|
250 |
}
|
|
|
251 |
else
|
|
|
252 |
{
|
|
|
253 |
TRAP_IGNORE( manager.ClearSelectPlayersL() );
|
|
|
254 |
if ( playlist )
|
|
|
255 |
{
|
|
|
256 |
iPlaybackUtility->InitL( *playlist, EFalse );
|
|
|
257 |
}
|
|
|
258 |
|
|
|
259 |
DisplayErrorNoteL( R_UPNP_ERROR_PLAYER_UNAVAILABLE );
|
|
|
260 |
}
|
|
|
261 |
|
|
|
262 |
if ( playlist )
|
|
|
263 |
{
|
|
|
264 |
CleanupStack::PopAndDestroy( playlist );
|
|
|
265 |
}
|
|
|
266 |
}
|
|
|
267 |
else
|
|
|
268 |
{
|
|
|
269 |
// Should not reach here
|
|
|
270 |
MPX_DEBUG1( "CMPXUPnPBrowseDialog::ExecuteLD()playbackutility is NULL" );
|
|
|
271 |
}
|
|
|
272 |
} // if ( isSelectedItemASubplayerName )
|
|
|
273 |
} // check for boundaries
|
|
|
274 |
else
|
|
|
275 |
{
|
|
|
276 |
okToExit = ETrue;
|
|
|
277 |
selectedSubplayerIndex = KErrCancel;
|
|
|
278 |
}
|
|
|
279 |
} // if ( returnValue )
|
|
|
280 |
else // Cancel was selected
|
|
|
281 |
{
|
|
|
282 |
if ( !iPlayerUnavailableError )
|
|
|
283 |
{
|
|
|
284 |
if ( iPlaybackUtility )
|
|
|
285 |
{
|
|
|
286 |
iPlaybackUtility->CancelRequest();
|
|
|
287 |
}
|
|
|
288 |
|
|
|
289 |
CMPXCommand* cmd = CMPXCommand::NewL();
|
|
|
290 |
CleanupStack::PushL(cmd);
|
|
|
291 |
cmd->SetTObjectValueL<TInt>(KMPXCommandGeneralId, KMPXCommandIdPlaybackGeneral);
|
|
|
292 |
// All of current commands are sync
|
|
|
293 |
cmd->SetTObjectValueL<TBool>(KMPXCommandGeneralDoSync, ETrue);
|
|
|
294 |
cmd->SetTObjectValueL<TInt>(KMPXCommandPlaybackGeneralType, EPbCmdUnloadNonActivePlugin);
|
|
|
295 |
cmd->SetTObjectValueL<TInt>(KMPXCommandPlaybackGeneralData, aPlayerUid);
|
|
|
296 |
if(iPlaybackUtility)
|
|
|
297 |
{
|
|
|
298 |
iPlaybackUtility->CommandL(*cmd, NULL);
|
|
|
299 |
}
|
|
|
300 |
CleanupStack::PopAndDestroy(cmd);
|
|
|
301 |
|
|
|
302 |
okToExit = ETrue;
|
|
|
303 |
selectedSubplayerIndex = KErrCancel;
|
|
|
304 |
}
|
|
|
305 |
// else we display the popup again
|
|
|
306 |
else
|
|
|
307 |
{
|
|
|
308 |
iPlayerUnavailableError = EFalse;
|
|
|
309 |
}
|
|
|
310 |
}
|
|
|
311 |
} // while ( !okToExit )
|
|
|
312 |
|
|
|
313 |
return selectedSubplayerIndex;
|
|
|
314 |
}
|
|
|
315 |
|
|
|
316 |
// ---------------------------------------------------------------------------
|
|
|
317 |
// CMPXUPnPBrowseDialog::PreLayoutDynInitL();
|
|
|
318 |
// called by framework before dialog is shown
|
|
|
319 |
// ---------------------------------------------------------------------------
|
|
|
320 |
void CMPXUPnPBrowseDialog::PreLayoutDynInitL()
|
|
|
321 |
{
|
|
|
322 |
MPX_FUNC( "CMPXUPnPBrowseDialog::PreLayoutDynInitL()" );
|
|
|
323 |
|
|
|
324 |
// Browse dialog title text
|
|
|
325 |
HBufC* dialogTitle = StringLoader::LoadLC(R_UPNP_MENU_TITLE_SELECT_PLAYER);
|
|
|
326 |
iPopup->SetTitleL(*dialogTitle);
|
|
|
327 |
CleanupStack::PopAndDestroy(dialogTitle);
|
|
|
328 |
|
|
|
329 |
// Previous UPNP code
|
|
|
330 |
|
|
|
331 |
CAknIconArray* icons = new ( ELeave ) CAknIconArray(2);
|
|
|
332 |
CleanupStack::PushL(icons);
|
|
|
333 |
|
|
|
334 |
// Mif icons
|
|
|
335 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
|
|
|
336 |
TFileName iconsPath( AknIconUtils::AvkonIconFileName( ) );
|
|
|
337 |
|
|
|
338 |
// Media server icon
|
|
|
339 |
AppendIconToArrayL( icons, skin,
|
|
|
340 |
KAvkonBitmapFile,
|
|
|
341 |
KAknsIIDQgnIndiMarkedAdd,
|
|
|
342 |
EMbmAvkonQgn_indi_marked_add,
|
|
|
343 |
EMbmAvkonQgn_indi_marked_add_mask );
|
|
|
344 |
iListBox->ItemDrawer()->FormattedCellData()->SetIconArrayL( icons );
|
|
|
345 |
CleanupStack::Pop(icons);
|
|
|
346 |
|
|
|
347 |
// Previous UPNP code
|
|
|
348 |
|
|
|
349 |
LoadListItemsL();
|
|
|
350 |
}
|
|
|
351 |
|
|
|
352 |
|
|
|
353 |
// --------------------------------------------------------------------------
|
|
|
354 |
// CUPnPBrowsePopup::LoadListItemsL
|
|
|
355 |
// Sends the browse request to MPXPlayerManager. When result set arrives,
|
|
|
356 |
// Playback callback will call the "HandleSubPlayerNamesL" call back method,
|
|
|
357 |
// which is implemented below.
|
|
|
358 |
// --------------------------------------------------------------------------
|
|
|
359 |
void CMPXUPnPBrowseDialog::LoadListItemsL()
|
|
|
360 |
{
|
|
|
361 |
MPX_FUNC( "CMPXUPnPBrowseDialog::LoadListItemsL()" );
|
|
|
362 |
|
|
|
363 |
MMPXPlayerManager& manager = iPlaybackUtility->PlayerManager();
|
|
|
364 |
|
|
|
365 |
DisplayWaitingTextL();
|
|
|
366 |
|
|
|
367 |
if ( iPlayerManagerStub )
|
|
|
368 |
{
|
|
|
369 |
iPlayerManagerStub->SubPlayerNamesL(*this, TUid::Uid(iPlayerUid));
|
|
|
370 |
}
|
|
|
371 |
else
|
|
|
372 |
{
|
|
|
373 |
MPX_DEBUG1( "CMPXUPnPBrowseDialog::LoadListItemsL() before call to manager.SubPlayerNamesL()" );
|
|
|
374 |
manager.SubPlayerNamesL(*this, TUid::Uid(iPlayerUid));
|
|
|
375 |
}
|
|
|
376 |
}
|
|
|
377 |
|
|
|
378 |
// --------------------------------------------------------------------------
|
|
|
379 |
// CUPnPBrowsePopup::DisplaySubPlayersNamesL
|
|
|
380 |
// --------------------------------------------------------------------------
|
|
|
381 |
void CMPXUPnPBrowseDialog::DisplaySubPlayersNamesL( const MDesCArray* aSubPlayers,
|
|
|
382 |
const TBool aComplete )
|
|
|
383 |
{
|
|
|
384 |
MPX_FUNC( "CMPXUPnPBrowseDialog::DisplaySubPlayersNamesL()" );
|
|
|
385 |
|
|
|
386 |
CTextListBoxModel* model = iListBox->Model();
|
|
|
387 |
MDesCArray* textArray = model->ItemTextArray();
|
|
|
388 |
CDesCArray* listBoxItems = static_cast<CDesCArray*>(textArray);
|
|
|
389 |
TInt subPlayersCount = 0;
|
|
|
390 |
|
|
|
391 |
listBoxItems->Reset();
|
|
|
392 |
|
|
|
393 |
if ( aSubPlayers )
|
|
|
394 |
{
|
|
|
395 |
subPlayersCount = aSubPlayers->MdcaCount();
|
|
|
396 |
MPX_DEBUG2( "CMPXUPnPBrowseDialog::DisplaySubPlayersNamesL(), aSubPlayer exists %d",
|
|
|
397 |
subPlayersCount );
|
|
|
398 |
|
|
|
399 |
if ( subPlayersCount > 0 )
|
|
|
400 |
{
|
|
|
401 |
for (TInt i=0; i < subPlayersCount; i++)
|
|
|
402 |
{
|
|
|
403 |
TPtrC temp = aSubPlayers->MdcaPoint(i);
|
|
|
404 |
TFileName subPlayerName;
|
|
|
405 |
|
|
|
406 |
subPlayerName.Copy(temp);
|
|
|
407 |
subPlayerName.TrimAll(); // trim all leading and trailing spaces (including tab)
|
|
|
408 |
|
|
|
409 |
TInt tabPos = subPlayerName.Find(KTab);
|
|
|
410 |
|
|
|
411 |
// replace tab with single space
|
|
|
412 |
while (tabPos != KErrNotFound)
|
|
|
413 |
{
|
|
|
414 |
subPlayerName.Replace(tabPos, 1, KSpace);
|
|
|
415 |
tabPos = subPlayerName.Find(KTab);
|
|
|
416 |
}
|
|
|
417 |
|
|
|
418 |
// Append name of the subplayer in the listbox
|
|
|
419 |
if ( iCurrentlySelectedSubPlayerName )
|
|
|
420 |
{
|
|
|
421 |
if ( !subPlayerName.CompareF( *iCurrentlySelectedSubPlayerName ) )
|
|
|
422 |
{
|
|
|
423 |
// names are the same and we add the selection icon
|
|
|
424 |
TFileName item;
|
|
|
425 |
|
|
|
426 |
item.Format(KUPnPBrowseListboxString, &subPlayerName, 0);
|
|
|
427 |
listBoxItems->AppendL(item);
|
|
|
428 |
}
|
|
|
429 |
else
|
|
|
430 |
{
|
|
|
431 |
listBoxItems->AppendL(subPlayerName);
|
|
|
432 |
}
|
|
|
433 |
}
|
|
|
434 |
else
|
|
|
435 |
{
|
|
|
436 |
listBoxItems->AppendL(subPlayerName);
|
|
|
437 |
}
|
|
|
438 |
}
|
|
|
439 |
|
|
|
440 |
// if search is complete we add the <search again> listbox item last
|
|
|
441 |
if ( aComplete )
|
|
|
442 |
{
|
|
|
443 |
HBufC* listText = StringLoader::LoadLC(R_UPNP_LIST_UPNP_MORE_SUBPLAYERS);
|
|
|
444 |
listBoxItems->AppendL(*listText);
|
|
|
445 |
CleanupStack::PopAndDestroy( listText );
|
|
|
446 |
}
|
|
|
447 |
|
|
|
448 |
iPopup->ButtonGroupContainer()->SetCommandSetL(
|
|
|
449 |
R_AVKON_SOFTKEYS_SELECT_CANCEL);
|
|
|
450 |
iPopup->ButtonGroupContainer()->DrawDeferred();
|
|
|
451 |
|
|
|
452 |
iListBox->HandleItemAdditionL(); // Update listbox
|
|
|
453 |
iListBox->SetCurrentItemIndexAndDraw(0); // select new item
|
|
|
454 |
}
|
|
|
455 |
}
|
|
|
456 |
|
|
|
457 |
if ( !aSubPlayers || (subPlayersCount <= 0) )
|
|
|
458 |
{
|
|
|
459 |
if ( aComplete ) // search is complete
|
|
|
460 |
{
|
|
|
461 |
HBufC* searchAgainText = StringLoader::LoadLC(R_UPNP_LIST_UPNP_MORE_SUBPLAYERS);
|
|
|
462 |
listBoxItems->AppendL(*searchAgainText);
|
|
|
463 |
CleanupStack::PopAndDestroy(searchAgainText);
|
|
|
464 |
|
|
|
465 |
iPopup->ButtonGroupContainer()->SetCommandSetL(
|
|
|
466 |
R_AVKON_SOFTKEYS_SELECT_CANCEL);
|
|
|
467 |
iPopup->ButtonGroupContainer()->DrawDeferred();
|
|
|
468 |
iListBox->HandleItemAdditionL(); // Update listbox
|
|
|
469 |
iListBox->SetCurrentItemIndexAndDraw(0); // select new item
|
|
|
470 |
}
|
|
|
471 |
else // not complete, we're still searching
|
|
|
472 |
{
|
|
|
473 |
DisplayWaitingTextL();
|
|
|
474 |
}
|
|
|
475 |
}
|
|
|
476 |
}
|
|
|
477 |
|
|
|
478 |
// ---------------------------------------------------------------------------
|
|
|
479 |
// CMPXUPnPBrowseDialog::HandlePropertyL
|
|
|
480 |
// Handle playback property.
|
|
|
481 |
// ---------------------------------------------------------------------------
|
|
|
482 |
void CMPXUPnPBrowseDialog::HandlePropertyL( TMPXPlaybackProperty /*aProperty*/,
|
|
|
483 |
TInt /*aValue*/,
|
|
|
484 |
TInt /*aError*/)
|
|
|
485 |
{
|
|
|
486 |
MPX_FUNC( "CMPXUPnPBrowseDialog::HandlePropertyL()" );
|
|
|
487 |
// empty
|
|
|
488 |
}
|
|
|
489 |
|
|
|
490 |
// ---------------------------------------------------------------------------
|
|
|
491 |
// CMPXUPnPBrowseDialog::HandleSubPlayerNamesL
|
|
|
492 |
// Method is called continously until aComplete=ETrue, signifying that
|
|
|
493 |
// it is done and there will be no more callbacks
|
|
|
494 |
// Only new items are passed each time.
|
|
|
495 |
// ---------------------------------------------------------------------------
|
|
|
496 |
void CMPXUPnPBrowseDialog::HandleSubPlayerNamesL( TUid /*aPlayer*/,
|
|
|
497 |
const MDesCArray* aSubPlayers,
|
|
|
498 |
TBool aComplete,
|
|
|
499 |
TInt aError)
|
|
|
500 |
{
|
|
|
501 |
MPX_FUNC( "CMPXUPnPBrowseDialog::HandleSubPlayerNamesL()" );
|
|
|
502 |
MPX_DEBUG3( "CMPXUPnPBrowseDialog::HandleSubPlayerNamesL(complete %d, error: %d)",
|
|
|
503 |
aComplete, aError );
|
|
|
504 |
|
|
|
505 |
if ( aError == KErrNone )
|
|
|
506 |
{
|
|
|
507 |
DisplaySubPlayersNamesL(aSubPlayers, aComplete);
|
|
|
508 |
}
|
|
|
509 |
else
|
|
|
510 |
{
|
|
|
511 |
if ( ( aError == KErrServerTerminated ) ||
|
|
|
512 |
( aError == KErrCouldNotConnect ) ||
|
|
|
513 |
( aError == KErrWlanNetworkNotFound ))
|
|
|
514 |
{
|
|
|
515 |
// defined in errorres.rsg
|
|
|
516 |
DisplayErrorNoteL( R_ERRE_GE_WLAN_WLAN_NETWORK_LOST );
|
|
|
517 |
}
|
|
|
518 |
|
|
|
519 |
// No error note specified, we can't get list of subplayers so
|
|
|
520 |
// we just exit the dialog
|
|
|
521 |
iPopup->CancelPopup();
|
|
|
522 |
}
|
|
|
523 |
}
|
|
|
524 |
|
|
|
525 |
// ---------------------------------------------------------------------------
|
|
|
526 |
// CMPXUPnPBrowseDialog::HandleMediaL
|
|
|
527 |
// Call back of media request
|
|
|
528 |
// ---------------------------------------------------------------------------
|
|
|
529 |
void CMPXUPnPBrowseDialog::HandleMediaL( const CMPXMedia& /*aProperties*/,
|
|
|
530 |
TInt /*aError*/)
|
|
|
531 |
{
|
|
|
532 |
MPX_FUNC( "CMPXUPnPBrowseDialog::HandleMediaL()" );
|
|
|
533 |
// empty
|
|
|
534 |
}
|
|
|
535 |
|
|
|
536 |
// ---------------------------------------------------------------------------
|
|
|
537 |
// CMPXUPnPBrowseDialog::AppendIconToArrayL
|
|
|
538 |
// Load a possibly skinned icon (with mask) and append it to an
|
|
|
539 |
// icon array.
|
|
|
540 |
// ---------------------------------------------------------------------------
|
|
|
541 |
void CMPXUPnPBrowseDialog::AppendIconToArrayL(CAknIconArray* aArray,
|
|
|
542 |
MAknsSkinInstance* aSkin,
|
|
|
543 |
const TDesC& aMbmFile,
|
|
|
544 |
const TAknsItemID& aID,
|
|
|
545 |
TInt aBitmapId,
|
|
|
546 |
TInt aMaskId)
|
|
|
547 |
{
|
|
|
548 |
MPX_FUNC( "CMPXUPnPBrowseDialog::AppendIconToArrayL()" );
|
|
|
549 |
|
|
|
550 |
__ASSERT_DEBUG(aArray != NULL, User::Leave(KErrArgument));
|
|
|
551 |
|
|
|
552 |
CFbsBitmap* bitmap = NULL;
|
|
|
553 |
CFbsBitmap* mask = NULL;
|
|
|
554 |
|
|
|
555 |
AknsUtils::CreateIconLC(aSkin, aID,
|
|
|
556 |
bitmap, mask, aMbmFile, aBitmapId, aMaskId);
|
|
|
557 |
|
|
|
558 |
CGulIcon* icon = CGulIcon::NewL(bitmap, mask);
|
|
|
559 |
icon->SetBitmapsOwnedExternally(EFalse);
|
|
|
560 |
|
|
|
561 |
// icon now owns the bitmaps, no need to keep on cleanup stack.
|
|
|
562 |
CleanupStack::Pop(2); // mask, bitmap
|
|
|
563 |
bitmap = NULL;
|
|
|
564 |
mask = NULL;
|
|
|
565 |
|
|
|
566 |
CleanupStack::PushL(icon);
|
|
|
567 |
aArray->AppendL(icon);
|
|
|
568 |
|
|
|
569 |
// aArray now owns the icon, no need to delete.
|
|
|
570 |
CleanupStack::Pop();
|
|
|
571 |
}
|
|
|
572 |
|
|
|
573 |
// ---------------------------------------------------------------------------
|
|
|
574 |
// CMPXUPnPBrowseDialog::CreatePopupL
|
|
|
575 |
// Creates a selection popup.
|
|
|
576 |
// ---------------------------------------------------------------------------
|
|
|
577 |
void CMPXUPnPBrowseDialog::CreatePopupL()
|
|
|
578 |
{
|
|
|
579 |
MPX_FUNC( "CMPXUPnPBrowseDialog::CreatePopupL()" );
|
|
|
580 |
|
|
|
581 |
// Create and configure the list box
|
|
|
582 |
if ( iListBox )
|
|
|
583 |
{
|
|
|
584 |
delete iListBox;
|
|
|
585 |
iListBox = NULL;
|
|
|
586 |
}
|
|
|
587 |
iListBox = new (ELeave) CAknSinglePopupMenuStyleListBox;
|
|
|
588 |
iPopup = CAknPopupList::NewL(iListBox,
|
|
|
589 |
R_MPX_SOFTKEYS_UPNP_EMPTY_CANCEL,
|
|
|
590 |
AknPopupLayouts::EDynMenuWindow);
|
|
|
591 |
iListBox->ConstructL(iPopup, EAknListBoxSelectionList);
|
|
|
592 |
iListBox->CreateScrollBarFrameL( ETrue );
|
|
|
593 |
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
|
|
|
594 |
CEikScrollBarFrame::EOff,
|
|
|
595 |
CEikScrollBarFrame::EAuto );
|
|
|
596 |
// Enable Marquee
|
|
|
597 |
CEikFormattedCellListBox* eikListbox =
|
|
|
598 |
static_cast<CEikFormattedCellListBox*>( iListBox );
|
|
|
599 |
eikListbox->EnableExtendedDrawingL();
|
|
|
600 |
eikListbox->ItemDrawer()->FormattedCellData()->EnableMarqueeL( ETrue );
|
|
|
601 |
PreLayoutDynInitL();
|
|
|
602 |
}
|
|
|
603 |
|
|
|
604 |
// ---------------------------------------------------------------------------
|
|
|
605 |
// CMPXUPnPBrowseDialog::StartPopupL
|
|
|
606 |
// Parses the friendly names from the list of UPnPDevices and
|
|
|
607 |
// executes the selection dialog. Returns 0 or 1 (Cancel or Select)
|
|
|
608 |
// ---------------------------------------------------------------------------
|
|
|
609 |
//
|
|
|
610 |
TInt CMPXUPnPBrowseDialog::StartPopupL()
|
|
|
611 |
{
|
|
|
612 |
MPX_FUNC( "CMPXUPnPBrowseDialog::StartPopupL()" );
|
|
|
613 |
|
|
|
614 |
TInt popupOk = iPopup->ExecuteLD();
|
|
|
615 |
iPopup = NULL;
|
|
|
616 |
return popupOk;
|
|
|
617 |
}
|
|
|
618 |
|
|
|
619 |
// ---------------------------------------------------------------------------
|
|
|
620 |
// From MMPXPlaybackObserver
|
|
|
621 |
// Handle playback message.
|
|
|
622 |
// ---------------------------------------------------------------------------
|
|
|
623 |
//
|
|
|
624 |
void CMPXUPnPBrowseDialog::HandlePlaybackMessage(
|
|
|
625 |
CMPXMessage* aMessage, TInt aError )
|
|
|
626 |
{
|
|
|
627 |
MPX_FUNC( "CMPXUPnPBrowseDialog::HandlePlaybackMessage()" );
|
|
|
628 |
|
|
|
629 |
if ( aError == KErrNone && aMessage )
|
|
|
630 |
{
|
|
|
631 |
TRAP_IGNORE( DoHandlePlaybackMessageL( *aMessage ) );
|
|
|
632 |
}
|
|
|
633 |
}
|
|
|
634 |
|
|
|
635 |
// ---------------------------------------------------------------------------
|
|
|
636 |
// CMPXUPnPBrowseDialog::RetrieveCurrentlySelectSubplayerNameL
|
|
|
637 |
// Retrieves the name and other info of the currently used subplayer
|
|
|
638 |
// ---------------------------------------------------------------------------
|
|
|
639 |
//
|
|
|
640 |
void CMPXUPnPBrowseDialog::RetrieveCurrentlySelectSubplayerNameL()
|
|
|
641 |
{
|
|
|
642 |
MPX_FUNC( "CMPXUPnPBrowseDialog::RetrieveCurrentlySelectSubplayerName()" );
|
|
|
643 |
|
|
|
644 |
if ( iCurrentlySelectedSubPlayerName )
|
|
|
645 |
{
|
|
|
646 |
delete iCurrentlySelectedSubPlayerName;
|
|
|
647 |
iCurrentlySelectedSubPlayerName = NULL;
|
|
|
648 |
}
|
|
|
649 |
if( iPlaybackUtility)
|
|
|
650 |
{
|
|
|
651 |
MMPXPlayerManager& manager = iPlaybackUtility->PlayerManager();
|
|
|
652 |
TMPXPlaybackPlayerType playerType;
|
|
|
653 |
TInt currentlyUsedSubPlayer;
|
|
|
654 |
MPX_DEBUG1( "CMPXUPnPBrowseDialog::RetrieveCurrentlySelectSubplayerName() before call to manager.GetSelectionL()" );
|
|
|
655 |
MPX_TRAPD( errorSelectSubPlayer, manager.GetSelectionL( playerType,
|
|
|
656 |
iCurrentlyUsedPlayer,
|
|
|
657 |
currentlyUsedSubPlayer,
|
|
|
658 |
iCurrentlySelectedSubPlayerName));
|
|
|
659 |
MPX_DEBUG4( "CMPXUPnPBrowseDialog::RetrieveCurrentlySelectSubplayerName() after call to manager.GetSelectionL(%d, %d, %d)",
|
|
|
660 |
playerType,
|
|
|
661 |
iCurrentlyUsedPlayer.iUid,
|
|
|
662 |
currentlyUsedSubPlayer );
|
|
|
663 |
if (iCurrentlySelectedSubPlayerName)
|
|
|
664 |
{
|
|
|
665 |
MPX_DEBUG2( "CMPXUPnPBrowseDialog::RetrieveCurrentlySelectSubplayerName() after call to manager.GetSelectionL(%S)",
|
|
|
666 |
iCurrentlySelectedSubPlayerName );
|
|
|
667 |
}
|
|
|
668 |
if ( errorSelectSubPlayer != KErrNone && iCurrentlySelectedSubPlayerName )
|
|
|
669 |
{
|
|
|
670 |
MPX_DEBUG2( "CMPXUPnPBrowseDialog::RetrieveCurrentlySelectSubplayerName() after call to manager.GetSelectionL() error %d",
|
|
|
671 |
errorSelectSubPlayer );
|
|
|
672 |
delete iCurrentlySelectedSubPlayerName;
|
|
|
673 |
iCurrentlySelectedSubPlayerName = NULL;
|
|
|
674 |
}
|
|
|
675 |
}
|
|
|
676 |
else
|
|
|
677 |
{
|
|
|
678 |
//Should not reach here
|
|
|
679 |
MPX_DEBUG1( "CMPXUPnPBrowseDialog::RetrieveCurrentlySelectSubplayerName() iPlaybackUtility is NULL" );
|
|
|
680 |
}
|
|
|
681 |
}
|
|
|
682 |
|
|
|
683 |
// ---------------------------------------------------------------------------
|
|
|
684 |
// CMPXUPnPBrowseDialog::DisplayErrorNoteL
|
|
|
685 |
// Retrieves the name and other info of the currently used subplayer
|
|
|
686 |
// ---------------------------------------------------------------------------
|
|
|
687 |
//
|
|
|
688 |
void CMPXUPnPBrowseDialog::DisplayErrorNoteL( TInt aResourceId )
|
|
|
689 |
{
|
|
|
690 |
MPX_FUNC( "CMPXUPnPBrowseDialog::DisplayErrorNoteL()" );
|
|
|
691 |
|
|
|
692 |
// error note
|
|
|
693 |
HBufC* dialogText = StringLoader::LoadLC( aResourceId );
|
|
|
694 |
CAknErrorNote* errNote = new(ELeave) CAknErrorNote(ETrue);
|
|
|
695 |
errNote->SetTimeout(CAknNoteDialog::ELongTimeout);
|
|
|
696 |
errNote->ExecuteLD( *dialogText );
|
|
|
697 |
CleanupStack::PopAndDestroy( dialogText );
|
|
|
698 |
}
|
|
|
699 |
|
|
|
700 |
// ---------------------------------------------------------------------------
|
|
|
701 |
// CMPXUPnPBrowseDialog::DisplayWaitingTextL
|
|
|
702 |
// Displays the waiting text during retrieval of subplayer names
|
|
|
703 |
// ---------------------------------------------------------------------------
|
|
|
704 |
//
|
|
|
705 |
void CMPXUPnPBrowseDialog::DisplayWaitingTextL()
|
|
|
706 |
{
|
|
|
707 |
MPX_FUNC( "CMPXUPnPBrowseDialog::DisplayWaitingTextL()" );
|
|
|
708 |
|
|
|
709 |
if ( iListBox && iListBox->View() )
|
|
|
710 |
{
|
|
|
711 |
HBufC* waitText = StringLoader::LoadLC(R_UPNP_DIALOG_WAITING_FOR_DEVICES);
|
|
|
712 |
iListBox->View()->SetListEmptyTextL(*waitText);
|
|
|
713 |
CleanupStack::PopAndDestroy(waitText);
|
|
|
714 |
}
|
|
|
715 |
}
|
|
|
716 |
|
|
|
717 |
// ---------------------------------------------------------------------------
|
|
|
718 |
// Handle playback message.
|
|
|
719 |
// ---------------------------------------------------------------------------
|
|
|
720 |
//
|
|
|
721 |
void CMPXUPnPBrowseDialog::DoHandlePlaybackMessageL(
|
|
|
722 |
const CMPXMessage& aMessage )
|
|
|
723 |
{
|
|
|
724 |
MPX_FUNC( "CMPXUPnPBrowseDialog::DoHandlePlaybackMessageL" );
|
|
|
725 |
|
|
|
726 |
TMPXMessageId id( aMessage.ValueTObjectL<TMPXMessageId>( KMPXMessageGeneralId ) );
|
|
|
727 |
if ( KMPXMessageGeneral == id )
|
|
|
728 |
{
|
|
|
729 |
TInt type( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralType ) );
|
|
|
730 |
TInt data( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralData ) );
|
|
|
731 |
switch ( aMessage.ValueTObjectL<TInt>( KMPXMessageGeneralEvent ) )
|
|
|
732 |
{
|
|
|
733 |
case TMPXPlaybackMessage::EPlayerUnavailable:
|
|
|
734 |
{
|
|
|
735 |
MPX_DEBUG2( "HandlePlaybackMessageL - EPlayerUnavailable(%d)", type );
|
|
|
736 |
TUid activeView = iViewUtility->ActiveViewType();
|
|
|
737 |
if ( activeView == TUid::Uid( KMPXPluginTypeUPnPBrowseDialogUid ) )
|
|
|
738 |
{
|
|
|
739 |
iPlayerUnavailableError = ETrue;
|
|
|
740 |
MMPXPlayerManager& manager = iPlaybackUtility->PlayerManager();
|
|
|
741 |
TRAP_IGNORE( manager.ClearSelectPlayersL() );
|
|
|
742 |
DisplayErrorNoteL( R_UPNP_ERROR_PLAYER_UNAVAILABLE );
|
|
|
743 |
|
|
|
744 |
iPopup->CancelPopup();
|
|
|
745 |
}
|
|
|
746 |
break;
|
|
|
747 |
}
|
|
|
748 |
default:
|
|
|
749 |
{
|
|
|
750 |
break;
|
|
|
751 |
}
|
|
|
752 |
}
|
|
|
753 |
}
|
|
|
754 |
}
|
|
|
755 |
|
|
|
756 |
// End of file
|
|
|
757 |
|