62
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 - 2007 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: MpxCollectionTest test module.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// INCLUDE FILES
|
|
19 |
#include <mpxcollectionutility.h>
|
|
20 |
#include <mpxcollectionpath.h>
|
|
21 |
#include <mpxcollectionplaylist.h>
|
|
22 |
#include <mpxplaybackframeworkdefs.h>
|
|
23 |
#include <mpxcollectionmessage.h>
|
|
24 |
#include <mpxcollectionframeworkdefs.h>
|
|
25 |
#include <mpxmessagegeneraldefs.h> // KMPXMessageGeneralEvent, KMPXMessageGeneralType
|
|
26 |
#include <mpxmediageneraldefs.h>
|
|
27 |
#include <mpxmediaarray.h>
|
|
28 |
#include <mpxmediacontainerdefs.h>
|
|
29 |
#include <mpxattribute.h>
|
|
30 |
#include <stiflogger.h>
|
|
31 |
#include <testutility.h>
|
|
32 |
#include <testplaybackutility.h>
|
|
33 |
#include <testplaybackview.h>
|
|
34 |
#include "pathoptionmenu.h"
|
|
35 |
#include "collectionbrowser.h"
|
|
36 |
|
|
37 |
// MACROS
|
|
38 |
|
|
39 |
// DATA TYPES
|
|
40 |
|
|
41 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
42 |
|
|
43 |
// -----------------------------------------------------------------------------
|
|
44 |
// CCollectionBrowser::NewL
|
|
45 |
// Two-phased constructor.
|
|
46 |
// -----------------------------------------------------------------------------
|
|
47 |
//
|
|
48 |
/*
|
|
49 |
CCollectionBrowser* CCollectionBrowser::NewL(CConsoleMain* aConsoleMain,
|
|
50 |
CTestBaseView* aParent,
|
|
51 |
const TDesC16& aName,
|
|
52 |
CStifLogger* aLogger,
|
|
53 |
CMPXCollectionPath* aPath)
|
|
54 |
{
|
|
55 |
CCollectionBrowser* self = CCollectionBrowser::NewL(aConsoleMain,
|
|
56 |
aParent,
|
|
57 |
aName,
|
|
58 |
aLogger);
|
|
59 |
CleanupStack::PopAndDestroy(self);
|
|
60 |
|
|
61 |
return self;
|
|
62 |
}
|
|
63 |
*/
|
|
64 |
// -----------------------------------------------------------------------------
|
|
65 |
// CCollectionBrowser::NewLC
|
|
66 |
// Two-phased constructor.
|
|
67 |
// -----------------------------------------------------------------------------
|
|
68 |
//
|
|
69 |
CCollectionBrowser* CCollectionBrowser::NewLC(CConsoleMain* aConsoleMain,
|
|
70 |
CTestBaseView* aParent,
|
|
71 |
const TDesC16& aName,
|
|
72 |
CStifLogger* aLogger,
|
|
73 |
CMPXCollectionPath* aPath)
|
|
74 |
{
|
|
75 |
CCollectionBrowser* self = new (ELeave) CCollectionBrowser(aConsoleMain,
|
|
76 |
aParent,
|
|
77 |
aName,
|
|
78 |
aLogger);
|
|
79 |
|
|
80 |
CleanupStack::PushL( self );
|
|
81 |
self->ConstructL(aPath);
|
|
82 |
|
|
83 |
return self;
|
|
84 |
}
|
|
85 |
|
|
86 |
// -----------------------------------------------------------------------------
|
|
87 |
// Destructor
|
|
88 |
// -----------------------------------------------------------------------------
|
|
89 |
CCollectionBrowser::~CCollectionBrowser()
|
|
90 |
{
|
|
91 |
iLogger->Log(_L("+CCollectionBrowser::~CCollectionBrowser"));
|
|
92 |
|
|
93 |
if(iCollectionUtility)
|
|
94 |
iCollectionUtility->Close();
|
|
95 |
if(iCollectionPath)
|
|
96 |
delete iCollectionPath;
|
|
97 |
if(iPlaybackUtility)
|
|
98 |
delete iPlaybackUtility;
|
|
99 |
iLogger->Log(_L("-CCollectionBrowser::~CCollectionBrowser"));
|
|
100 |
}
|
|
101 |
|
|
102 |
// -----------------------------------------------------------------------------
|
|
103 |
// From CTestBaseView
|
|
104 |
// Initialize the view before display view
|
|
105 |
// -----------------------------------------------------------------------------
|
|
106 |
void CCollectionBrowser::InitializeViewL()
|
|
107 |
{
|
|
108 |
iLogger->Log(_L("+CCollectionBrowser::InitializeViewL"));
|
|
109 |
|
|
110 |
/*
|
|
111 |
// Resynchronize podcast databases
|
|
112 |
TUid collection = KPodcastCollection;
|
|
113 |
collection = iCollectionUtility->
|
|
114 |
Collection().CollectionIDL( collection );
|
|
115 |
TRAP_IGNORE(
|
|
116 |
iCollectionUtility->
|
|
117 |
Collection().CommandL( EMcCmdCollectionInit,
|
|
118 |
collection.iUid ) );
|
|
119 |
|
|
120 |
// Resynchronize music collection databases
|
|
121 |
collection = KLocalCollection;
|
|
122 |
collection = iCollectionUtility->
|
|
123 |
Collection().CollectionIDL( collection );
|
|
124 |
iCollectionUtility->Collection().CommandL( EMcCmdCollectionInit,
|
|
125 |
collection.iUid );
|
|
126 |
*/
|
|
127 |
|
|
128 |
// ConstructL() did the Utility->NewL() already.
|
|
129 |
|
|
130 |
if( iCollectionPath )
|
|
131 |
iCollectionUtility->Collection().OpenL(*iCollectionPath);
|
|
132 |
else
|
|
133 |
iCollectionUtility->Collection().OpenL();
|
|
134 |
|
|
135 |
iLogger->Log(_L("-CCollectionBrowser::InitializeViewL"));
|
|
136 |
}
|
|
137 |
|
|
138 |
// -----------------------------------------------------------------------------
|
|
139 |
// From CTestBaseView
|
|
140 |
// Cleanup the view before deactivate/destroy view
|
|
141 |
// -----------------------------------------------------------------------------
|
|
142 |
void CCollectionBrowser::CleanupViewL()
|
|
143 |
{
|
|
144 |
if(iPlaybackUtility)
|
|
145 |
{
|
|
146 |
delete iPlaybackUtility;
|
|
147 |
iPlaybackUtility = NULL;
|
|
148 |
}
|
|
149 |
}
|
|
150 |
|
|
151 |
// -----------------------------------------------------------------------------
|
|
152 |
// From CTestBaseView
|
|
153 |
// Handle number key press
|
|
154 |
// -----------------------------------------------------------------------------
|
|
155 |
void CCollectionBrowser::HandleNumKeyL()
|
|
156 |
{
|
|
157 |
/*
|
|
158 |
TKeyCode key = LastKeyPressed();
|
|
159 |
if((int)key == '1')
|
|
160 |
{
|
|
161 |
CPathOptionMenu* pathOptionMenu =
|
|
162 |
CPathOptionMenu::NewL(iConsoleMain,
|
|
163 |
this,
|
|
164 |
KTxtPathOptionMenu,
|
|
165 |
iLogger);
|
|
166 |
CleanupStack::PushL(pathOptionMenu);
|
|
167 |
CMPXCollectionPath* path = iCollectionUtility->Collection().PathL();
|
|
168 |
CleanupStack::PushL(path);
|
|
169 |
path->SelectL(CurrentIndex()); //change to selected path
|
|
170 |
pathOptionMenu->SetPathL(*path);
|
|
171 |
CleanupStack::PopAndDestroy(path);
|
|
172 |
NextViewL(pathOptionMenu);
|
|
173 |
CleanupStack::Pop(pathOptionMenu);
|
|
174 |
iChild = static_cast<CTestBaseView*>(pathOptionMenu);
|
|
175 |
}
|
|
176 |
*/
|
|
177 |
}
|
|
178 |
|
|
179 |
// -----------------------------------------------------------------------------
|
|
180 |
// From CTestBaseView
|
|
181 |
// Handle left key press
|
|
182 |
// -----------------------------------------------------------------------------
|
|
183 |
void CCollectionBrowser::HandleLeftKeyL()
|
|
184 |
{
|
|
185 |
iLogger->Log(_L("+CCollectionBrowser::HandleLeftKeyL"));
|
|
186 |
CMPXCollectionPath* currPath = iCollectionUtility->Collection().PathL();
|
|
187 |
CleanupStack::PushL( currPath );
|
|
188 |
if(currPath->Levels() > 1)
|
|
189 |
{
|
|
190 |
iCollectionUtility->Collection().BackL();
|
|
191 |
}
|
|
192 |
// otherwise current path is at or below root level, thereofeore, no back call
|
|
193 |
CleanupStack::PopAndDestroy( currPath );
|
|
194 |
iLogger->Log(_L("-CCollectionBrowser::HandleLeftKeyL"));
|
|
195 |
}
|
|
196 |
|
|
197 |
// -----------------------------------------------------------------------------
|
|
198 |
// From CTestBaseView
|
|
199 |
// Handle right/enter key press
|
|
200 |
// -----------------------------------------------------------------------------
|
|
201 |
void CCollectionBrowser::HandleRightKeyL()
|
|
202 |
{
|
|
203 |
iLogger->Log(_L("+CCollectionBrowser::HandleRightKeyL"));
|
|
204 |
TInt count = ItemCount();
|
|
205 |
TInt index = CurrentIndex();
|
|
206 |
|
|
207 |
if(count > 0 && index >= 0 && index < count)
|
|
208 |
{
|
|
209 |
iCollectionUtility->Collection().OpenL( index );
|
|
210 |
}
|
|
211 |
iLogger->Log(_L("-CCollectionBrowser::HandleRightKeyL"));
|
|
212 |
}
|
|
213 |
|
|
214 |
// -----------------------------------------------------------------------------
|
|
215 |
// CCollectionBrowser::HandleCollectionMediaL
|
|
216 |
// -----------------------------------------------------------------------------
|
|
217 |
//
|
|
218 |
void CCollectionBrowser::HandleCollectionMediaL(
|
|
219 |
const CMPXMedia& aMedia,
|
|
220 |
TInt aError)
|
|
221 |
{
|
|
222 |
if(aError == KErrNone)
|
|
223 |
{
|
|
224 |
// Assume root plugins title will be returned only
|
|
225 |
// see CCollectionBrowser::HandleOpenL
|
|
226 |
TMPXAttribute titleAttr(KMPXMediaIdGeneral,EMPXMediaGeneralTitle);
|
|
227 |
if( aMedia.IsSupported(titleAttr) )
|
|
228 |
{
|
|
229 |
const TDesC& title = aMedia.ValueText( titleAttr );
|
|
230 |
// TestUtility::TestLog(iLogger, _L("%S\n"), &title);
|
|
231 |
AddItemL(title);
|
|
232 |
}
|
|
233 |
DisplayViewL();
|
|
234 |
}
|
|
235 |
}
|
|
236 |
|
|
237 |
// -----------------------------------------------------------------------------
|
|
238 |
// CCollectionBrowser::HandleCollectionMessageL
|
|
239 |
// -----------------------------------------------------------------------------
|
|
240 |
//
|
|
241 |
void CCollectionBrowser::HandleCollectionMessageL(const CMPXMessage& aMsg)
|
|
242 |
{
|
|
243 |
iLogger->Log(_L("+CCollectionBrowser::HandleCollectionMessageL"));
|
|
244 |
|
|
245 |
if( aMsg.IsSupported(KMPXMessageGeneralEvent) &&
|
|
246 |
aMsg.IsSupported(KMPXMessageGeneralType) )
|
|
247 |
{
|
|
248 |
TMPXCollectionMessage::TEvent event =
|
|
249 |
*aMsg.Value<TMPXCollectionMessage::TEvent>( KMPXMessageGeneralEvent );
|
|
250 |
TInt type = *aMsg.Value<TInt>( KMPXMessageGeneralType );
|
|
251 |
TInt data = *aMsg.Value<TInt>( KMPXMessageGeneralData );
|
|
252 |
TMPXCollectionMessage message(event, type, data);
|
|
253 |
|
|
254 |
if (message.Event() == TMPXCollectionMessage::EPathChanged &&
|
|
255 |
message.Type() == EMcPathChangedByOpen)
|
|
256 |
{
|
|
257 |
// Open new entries
|
|
258 |
iCollectionUtility->Collection().OpenL();
|
|
259 |
}
|
|
260 |
|
|
261 |
iLogger->Log(_L("CCollectionBrowser: Message %d Returned: type=%d data=%d"),
|
|
262 |
message.Event(),
|
|
263 |
message.Type(),
|
|
264 |
message.Data());
|
|
265 |
|
|
266 |
iLogger->Log(_L("-CCollectionBrowser::HandleCollectionMessageL"));
|
|
267 |
}
|
|
268 |
}
|
|
269 |
|
|
270 |
// -----------------------------------------------------------------------------
|
|
271 |
// CCollectionBrowser::HandleCollectionMessageL
|
|
272 |
// -----------------------------------------------------------------------------
|
|
273 |
//
|
|
274 |
void CCollectionBrowser::HandleOpenL(const CMPXMedia& aEntries,
|
|
275 |
TInt aIndex,TBool aComplete,TInt aError)
|
|
276 |
{
|
|
277 |
iLogger->Log(_L("+CCollectionBrowser::HandleOpenL"));
|
|
278 |
if(!aEntries.IsSupported(TMPXAttribute(KMPXMediaIdContainer,EMPXMediaArrayContents)) ||
|
|
279 |
!aEntries.IsSupported(TMPXAttribute(KMPXMediaIdContainer,EMPXMediaArrayCount)) )
|
|
280 |
User::Panic(_L("NOT appropiate array media"), -1);
|
|
281 |
|
|
282 |
CMPXMediaArray* media =
|
|
283 |
aEntries.ValueCObjectL<CMPXMediaArray>( TMPXAttribute(KMPXMediaIdContainer, EMPXMediaArrayContents) );
|
|
284 |
CleanupStack::PushL( media );
|
|
285 |
|
|
286 |
(void)aComplete;
|
|
287 |
iItems->Reset();
|
|
288 |
if(aError == KErrNone)
|
|
289 |
{
|
|
290 |
TMPXAttribute uidAttr(KMPXMediaIdGeneral,EMPXMediaGeneralId);
|
|
291 |
TMPXAttribute titleAttr(KMPXMediaIdGeneral,EMPXMediaGeneralTitle);
|
|
292 |
|
|
293 |
CMPXCollectionPath* currPath = iCollectionUtility->Collection().PathL();
|
|
294 |
CleanupStack::PushL( currPath );
|
|
295 |
|
|
296 |
for(TInt i=0; i<media->Count(); i++)
|
|
297 |
{
|
|
298 |
const CMPXMedia* entry = ( *media )[i];
|
|
299 |
if(currPath->Levels() == 1)
|
|
300 |
{
|
|
301 |
// Assume at root level, use MediaL to get plugin name
|
|
302 |
CMPXCollectionPath* rootPath = CMPXCollectionPath::NewL();
|
|
303 |
CleanupStack::PushL( rootPath );
|
|
304 |
TMPXItemId uid = entry->ValueTObjectL<TMPXItemId>( uidAttr );
|
|
305 |
rootPath->AppendL( uid );
|
|
306 |
RArray<TMPXAttribute> attrs;
|
|
307 |
CleanupClosePushL( attrs );
|
|
308 |
attrs.Append( titleAttr );
|
|
309 |
|
|
310 |
iCollectionUtility->Collection().MediaL(*rootPath, attrs.Array());
|
|
311 |
CleanupStack::PopAndDestroy(2, rootPath ); //attrs, rootPath
|
|
312 |
}
|
|
313 |
else
|
|
314 |
{
|
|
315 |
// Assume browsing within plugin already
|
|
316 |
const TDesC& title = entry->ValueText( titleAttr );
|
|
317 |
// TestUtility::TestLog(iLogger, _L("%S\n"), &title);
|
|
318 |
AddItemL(title);
|
|
319 |
}
|
|
320 |
}
|
|
321 |
CleanupStack::PopAndDestroy( currPath );
|
|
322 |
}
|
|
323 |
iPosOnScreen = aIndex;
|
|
324 |
DisplayViewL();
|
|
325 |
|
|
326 |
CleanupStack::PopAndDestroy(media);
|
|
327 |
iLogger->Log(_L("-CCollectionBrowser::HandleOpenL"));
|
|
328 |
}
|
|
329 |
|
|
330 |
// -----------------------------------------------------------------------------
|
|
331 |
// CCollectionBrowser::HandleCollectionMessageL
|
|
332 |
// -----------------------------------------------------------------------------
|
|
333 |
//
|
|
334 |
void CCollectionBrowser::HandleOpenL(const CMPXCollectionPlaylist& aPlaylist,TInt aError)
|
|
335 |
{
|
|
336 |
(void)aError;
|
|
337 |
CTestPlaybackView* view = CTestPlaybackView::NewL(iConsoleMain,
|
|
338 |
this,
|
|
339 |
KTxtTestPlaybackView,
|
|
340 |
iLogger);
|
|
341 |
iPlaybackUtility = CTestPlaybackUtility::NewL(KPbModeNewPlayer,
|
|
342 |
view,
|
|
343 |
iLogger);
|
|
344 |
view->AddObserver(iPlaybackUtility);
|
|
345 |
CleanupStack::PushL(view);
|
|
346 |
iPlaybackUtility->InitL(aPlaylist);
|
|
347 |
CleanupStack::Pop(view);
|
|
348 |
iChild = static_cast<CTestBaseView*>(view);
|
|
349 |
NextViewL(iChild);
|
|
350 |
}
|
|
351 |
|
|
352 |
// -----------------------------------------------------------------------------
|
|
353 |
// C++ default constructor.
|
|
354 |
// -----------------------------------------------------------------------------
|
|
355 |
CCollectionBrowser::CCollectionBrowser(CConsoleMain* aConsoleMain,
|
|
356 |
CTestBaseView* aParent,
|
|
357 |
const TDesC& aName,
|
|
358 |
CStifLogger* aLogger)
|
|
359 |
: CTestMenuView(aConsoleMain, aParent, aName)
|
|
360 |
{
|
|
361 |
iCollectionUtility = NULL; // set by ConstructL()
|
|
362 |
iLogger = aLogger;
|
|
363 |
iCollectionPath = NULL; // set by ConstructL() if path != NULL
|
|
364 |
iPlaybackUtility = NULL;
|
|
365 |
}
|
|
366 |
|
|
367 |
// -----------------------------------------------------------------------------
|
|
368 |
// Second phase constructor
|
|
369 |
// -----------------------------------------------------------------------------
|
|
370 |
void CCollectionBrowser::ConstructL(CMPXCollectionPath* aPath)
|
|
371 |
{
|
|
372 |
iLogger->Log(_L("+CCollectionBrowser::ConstructL"));
|
|
373 |
iCollectionUtility = MMPXCollectionUtility::NewL(this);
|
|
374 |
if(aPath)
|
|
375 |
{
|
|
376 |
iCollectionPath = CMPXCollectionPath::NewL(*aPath);
|
|
377 |
}
|
|
378 |
CTestMenuView::ConstructL();
|
|
379 |
iLogger->Log(_L("-CCollectionBrowser::ConstructL"));
|
|
380 |
}
|
|
381 |
|