26
|
1 |
/*
|
|
2 |
* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: List of media items
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
#ifndef C_GLXMEDIALIST_H
|
|
22 |
#define C_GLXMEDIALIST_H
|
|
23 |
|
|
24 |
#include <e32std.h>
|
|
25 |
#include <mpxattributespecs.h>
|
|
26 |
#include <mpxcollectionobserver.h>
|
|
27 |
|
|
28 |
#include "mglxmedialist.h"
|
|
29 |
#include "mglxnavigablelistobserver.h"
|
|
30 |
#include "mglxmediauser.h"
|
|
31 |
|
|
32 |
// Forward declarations
|
|
33 |
class CGlxCacheManager;
|
|
34 |
class CGlxErrorPoster;
|
|
35 |
class CGlxNavigableList;
|
|
36 |
class CMPXCollectionPath;
|
|
37 |
class MGlxFetchContext;
|
|
38 |
class MMPXCollection;
|
|
39 |
class MMPXCollectionUtility;
|
|
40 |
class TGlxMedia;
|
|
41 |
class CGlxMediaListArray;
|
|
42 |
|
|
43 |
namespace NGlxMediaList
|
|
44 |
{
|
|
45 |
class TNotificationStrategy;
|
|
46 |
}
|
|
47 |
|
|
48 |
/**
|
|
49 |
* CGlxMediaList
|
|
50 |
*
|
|
51 |
* Interface for reading lists of media items
|
|
52 |
*
|
|
53 |
* @ingroup mlm_media_list_manager_design
|
|
54 |
* @lib glxmedialists.lib
|
|
55 |
*/
|
|
56 |
class CGlxMediaList :
|
|
57 |
public CBase, public MGlxMediaList, public MMPXCollectionObserver,
|
|
58 |
public MGlxNavigableListObserver, public MGlxMediaUser
|
|
59 |
{
|
|
60 |
public:
|
|
61 |
/**
|
|
62 |
* Return a reference-counted instance of CGlxMediaList. User MUST Close() this when finished with it.
|
|
63 |
*
|
|
64 |
* @param aPath Path to the collection
|
|
65 |
* @param aHierarchyId Id of the client hierarchy
|
|
66 |
* @param aFilter Filter on the collection
|
|
67 |
* @return instance of media list object
|
|
68 |
*/
|
|
69 |
static CGlxMediaList* InstanceL(const CMPXCollectionPath& aPath,
|
|
70 |
const TGlxHierarchyId& aHierarchyId = KGlxIdNone, CMPXFilter* aFilter = NULL);
|
|
71 |
|
|
72 |
|
|
73 |
/**
|
|
74 |
* Gives an array of all media lists in current use
|
|
75 |
*
|
|
76 |
* @return The array of media lists
|
|
77 |
*/
|
|
78 |
static RPointerArray<CGlxMediaList>& MediaListsL();
|
|
79 |
|
|
80 |
public:
|
|
81 |
/**
|
|
82 |
* Media object is available. The list picks up the pointer to the media object
|
|
83 |
* if it has a matching item, and adds itself as a user of the media object
|
|
84 |
* The index into the list is also stored, to allow clients that
|
|
85 |
* are processing users of a media, to index directly into the list
|
|
86 |
* Note: The function assumes that a reservation for at least one list has been
|
|
87 |
* made in each CGlxMedia::iUsedByLists array, and this object can use that
|
|
88 |
* reservation
|
|
89 |
*
|
|
90 |
* @param aItems media items to offer to list
|
|
91 |
*/
|
|
92 |
void OfferMedia(const TGlxIdSpaceId& aIdSpaceId, CGlxMedia* aItems);
|
|
93 |
|
|
94 |
/**
|
|
95 |
* Ask if the list has any requests to place
|
|
96 |
*
|
|
97 |
* @param aItemIndexes Indexes of the items to request attributes for
|
|
98 |
* @param aItemIds Ids of the items to request attributes for
|
|
99 |
* @param aAttributes attributes to request for the items
|
|
100 |
* @param aDetailedSpecs attribute specifications
|
|
101 |
*/
|
|
102 |
void AttributeRequestL(RArray<TInt>& aItemIndexes,
|
|
103 |
RArray<TGlxMediaId>& aItemIds,
|
|
104 |
RArray<TMPXAttribute>& aAttributes,
|
|
105 |
CMPXAttributeSpecs*& aDetailedSpecs) const;
|
|
106 |
|
|
107 |
/**
|
|
108 |
* Ordering function for attributes
|
|
109 |
*
|
|
110 |
* @see TLinearOrder
|
|
111 |
*
|
|
112 |
* @param aItem1 first item to order
|
|
113 |
* @param aItem2 second item to order
|
|
114 |
* @return TInt indicating ordering
|
|
115 |
*/
|
|
116 |
static TInt AttributeOrder(const TMPXAttribute& aItem1, const TMPXAttribute& aItem2);
|
|
117 |
|
|
118 |
/**
|
|
119 |
* Ordering function for attributes
|
|
120 |
*
|
|
121 |
* @see TLinearOrder
|
|
122 |
*
|
|
123 |
* @param aItem1 first item to order
|
|
124 |
* @param aItem2 second item to order
|
|
125 |
* @return TInt indicating ordering
|
|
126 |
*/
|
|
127 |
static TInt AttributeOrderReversed(const TMPXAttribute& aItem1, const TMPXAttribute& aItem2);
|
|
128 |
|
|
129 |
public: // From MGlxMediaList
|
|
130 |
/// See @ref MGlxMediaList::Close
|
|
131 |
void Close();
|
|
132 |
|
|
133 |
/// See @ref MGlxMediaList::Id
|
|
134 |
TGlxMediaListId Id() const;
|
|
135 |
|
|
136 |
/// See @ref MGlxMediaList::Count
|
|
137 |
TInt Count(NGlxListDefs::TCountType aType = NGlxListDefs::ECountAll) const;
|
|
138 |
|
|
139 |
/// See @ref MGlxMediaList::FocusIndex
|
|
140 |
TInt FocusIndex() const;
|
|
141 |
|
|
142 |
/// See @ref MGlxMediaList::SetFocusL
|
|
143 |
void SetFocusL(NGlxListDefs::TFocusSetType aType, TInt aValue);
|
|
144 |
|
|
145 |
/// See @ref MGlxMediaList::Item
|
|
146 |
const TGlxMedia& Item(TInt aIndex) const;
|
|
147 |
|
|
148 |
/// See @ref MGlxMediaList::Index
|
|
149 |
TInt Index(const TGlxIdSpaceId& aIdSpaceId, const TGlxMediaId& aId) const;
|
|
150 |
|
|
151 |
/// See @ref MGlxMediaList::AddMediaListObserverL
|
|
152 |
void AddMediaListObserverL(MGlxMediaListObserver* aObserver);
|
|
153 |
|
|
154 |
/// See @ref MGlxMediaList::RemoveMediaListObserver
|
|
155 |
void RemoveMediaListObserver(MGlxMediaListObserver* aObserver);
|
|
156 |
|
|
157 |
/// See @ref MGlxMediaList::AddContext
|
|
158 |
void AddContextL(const MGlxFetchContext* aContext, TInt aPriority);
|
|
159 |
|
|
160 |
/// See @ref MGlxMediaList::RemoveContext
|
|
161 |
void RemoveContext(const MGlxFetchContext* aContext);
|
|
162 |
|
|
163 |
/// See @ref MGlxMediaList::Collection
|
|
164 |
MMPXCollection& Collection() const;
|
|
165 |
|
|
166 |
/// See @ref MGlxMediaList::PathLC
|
|
167 |
CMPXCollectionPath* PathLC(NGlxListDefs::TPathType aType = NGlxListDefs::EPathAllOrSelection) const;
|
|
168 |
|
|
169 |
/// See @ref MGlxMediaList::IsSelected
|
|
170 |
TBool IsSelected(TInt aIndex) const;
|
|
171 |
|
|
172 |
/// See @ref MGlxMediaList::SetSelectedL
|
|
173 |
void SetSelectedL(TInt aIndex, TBool aSelected);
|
|
174 |
|
|
175 |
/// See @ref MGlxMediaList::SelectionCount
|
|
176 |
TInt SelectionCount() const;
|
|
177 |
|
|
178 |
/// See @ref MGlxMediaList::SelectedItemIndex
|
|
179 |
TInt SelectedItemIndex(TInt aSelectionIndex) const;
|
|
180 |
|
|
181 |
/// See @ref MGlxMediaList::CommandL
|
|
182 |
void CommandL(CMPXCommand& aCommand);
|
|
183 |
|
|
184 |
/// See @ref MGlxMediaList::CancelCommand
|
|
185 |
void CancelCommand();
|
|
186 |
|
|
187 |
/// See @ref MGlxMediaList::SetFilterL
|
|
188 |
void SetFilterL(CMPXFilter* aFilter);
|
|
189 |
|
|
190 |
/// See @ref MGlxMediaList::Filter
|
|
191 |
CMPXFilter* Filter() const;
|
|
192 |
|
|
193 |
/// See @ref MGlxMediaList::IdSpaceId
|
|
194 |
TGlxIdSpaceId IdSpaceId(TInt aIndex) const;
|
|
195 |
|
|
196 |
/// See @ref MGlxMediaList::IsPopulated
|
|
197 |
TBool IsPopulated() const;
|
|
198 |
|
|
199 |
/// See @ref MGlxMediaList::AddStaticItemL
|
|
200 |
void AddStaticItemL( CGlxMedia* aStaticItem,
|
|
201 |
NGlxListDefs::TInsertionPosition aTargetPosition );
|
|
202 |
|
|
203 |
/// See @ref MGlxMediaList::RemoveStaticItem
|
|
204 |
void RemoveStaticItem(const TGlxMediaId& aItemId);
|
|
205 |
|
|
206 |
/// See @ref MGlxMediaList::SetStaticItemsEnabled
|
|
207 |
void SetStaticItemsEnabled( TBool aEnabled );
|
|
208 |
|
|
209 |
/// See @ref MGlxMediaList::IsStaticItemsEnabled
|
|
210 |
TBool IsStaticItemsEnabled() const;
|
|
211 |
|
|
212 |
/// See @ref MGlxMediaList::SetFocusInitialPosition
|
|
213 |
void SetFocusInitialPosition(NGlxListDefs::TFocusInitialPosition aFocusInitialPosition);
|
|
214 |
|
|
215 |
/// See @ref MGlxMediaList::ResetFocus
|
|
216 |
void ResetFocus();
|
|
217 |
|
|
218 |
/// See @ref MGlxMediaList::SetVisibleWindowIndex
|
|
219 |
void SetVisibleWindowIndexL( TInt aIndex );
|
|
220 |
|
|
221 |
/// See @ref MGlxMediaList::VisibleWindowIndex
|
|
222 |
TInt VisibleWindowIndex() const;
|
|
223 |
|
|
224 |
/// See @ref MGlxMediaList::CancelPreviousRequests
|
|
225 |
void CancelPreviousRequests();
|
|
226 |
|
|
227 |
public: // From MMPXCollectionObserver
|
|
228 |
/// See @ref MMPXCollectionObserver::HandleCollectionMessageL
|
|
229 |
void HandleCollectionMessageL(const CMPXMessage& aMessage);
|
|
230 |
|
|
231 |
/// See @ref MMPXCollectionObserver::HandleOpenL
|
|
232 |
void HandleOpenL(const CMPXMedia& aEntries, TInt aIndex, TBool aComplete, TInt aError);
|
|
233 |
|
|
234 |
/// See @ref MMPXCollectionObserver::HandleOpenL
|
|
235 |
void HandleOpenL(const CMPXCollectionPlaylist& aPlaylist, TInt aError);
|
|
236 |
|
|
237 |
/// See @ref MMPXCollectionObserver::HandleCollectionMediaL
|
|
238 |
void HandleCollectionMediaL(const CMPXMedia& aMedia, TInt aError);
|
|
239 |
|
|
240 |
/// See @ref MMPXCollectionObserver::HandleCommandComplete
|
|
241 |
void HandleCommandComplete(CMPXCommand* aCommandResult, TInt aError);
|
|
242 |
|
|
243 |
// from MGlxNavigableListObserver
|
|
244 |
void HandleItemsAdded( TInt aAddedAtIndex, TInt aCount );
|
|
245 |
void HandleItemsRemoved( TInt aRemovedFromIndex, TInt aCount );
|
|
246 |
void HandleFocusChanged( NGlxListDefs::TFocusChangeType aType,
|
|
247 |
TInt aNewIndex, TInt aOldIndex );
|
|
248 |
void HandleItemSelected( TInt aIndex, TBool aSelected );
|
|
249 |
|
|
250 |
// From MGlxMediaUser
|
|
251 |
void HandleAttributesAvailableL( TInt aIndex, const RArray< TMPXAttribute >& aAttributes );
|
|
252 |
void GetRequiredAttributesL( TInt aIndex, RArray<TMPXAttribute>& aAttributes );
|
|
253 |
void RemoveReference( TInt aIndex );
|
|
254 |
void HandleError(TInt aError);
|
|
255 |
|
|
256 |
private:
|
|
257 |
/**
|
|
258 |
* Two phase constructor
|
|
259 |
*/
|
|
260 |
static CGlxMediaList* NewLC(const TGlxHierarchyId& aHierarchyId);
|
|
261 |
|
|
262 |
/**
|
|
263 |
* Constructor
|
|
264 |
*/
|
|
265 |
CGlxMediaList(const TGlxHierarchyId& aHierarchyId);
|
|
266 |
|
|
267 |
/**
|
|
268 |
* Destructor
|
|
269 |
*/
|
|
270 |
virtual ~CGlxMediaList();
|
|
271 |
|
|
272 |
/**
|
|
273 |
* 2nd phase constructor
|
|
274 |
*/
|
|
275 |
void ConstructL();
|
|
276 |
|
|
277 |
/**
|
|
278 |
* Initialize the media list
|
|
279 |
* Copies the levels from the path, and retrieves the
|
|
280 |
* contents from MPX Collection Server
|
|
281 |
*
|
|
282 |
* @param aPath path that this list refers to
|
|
283 |
*/
|
|
284 |
void OpenL(const CMPXCollectionPath& aPath);
|
|
285 |
|
|
286 |
/**
|
|
287 |
* Add a reference
|
|
288 |
*
|
|
289 |
* @return new reference count
|
|
290 |
*/
|
|
291 |
TInt AddReference();
|
|
292 |
|
|
293 |
/**
|
|
294 |
* Remove a reference
|
|
295 |
*
|
|
296 |
* @return new reference count
|
|
297 |
*/
|
|
298 |
TInt RemoveReference();
|
|
299 |
|
|
300 |
/**
|
|
301 |
* Current number of references
|
|
302 |
*
|
|
303 |
* @return new reference count
|
|
304 |
*/
|
|
305 |
TInt ReferenceCount() const;
|
|
306 |
|
|
307 |
/**
|
|
308 |
* Determines if path is the same
|
|
309 |
*
|
|
310 |
* @param aPath collection path
|
|
311 |
* @return ETrue if this media list refers to the path
|
|
312 |
*/
|
|
313 |
TBool Equals(const CMPXCollectionPath& aPath) const;
|
|
314 |
|
|
315 |
/**
|
|
316 |
* Determines if this list has a filter applied
|
|
317 |
*
|
|
318 |
* @return Boolean indication if filter has been applied
|
|
319 |
*/
|
|
320 |
TBool IsFiltered() const;
|
|
321 |
|
|
322 |
/**
|
|
323 |
* Synchronise the media list
|
|
324 |
* Re-retrieves the contents from MPX Collection Server
|
|
325 |
*/
|
|
326 |
void ReOpenL();
|
|
327 |
|
|
328 |
/**
|
|
329 |
* Populates the list with the items in the current path
|
|
330 |
*/
|
|
331 |
void PopulateL();
|
|
332 |
|
|
333 |
/**
|
|
334 |
* Handles item modifications
|
|
335 |
*
|
|
336 |
* @param aId MPX item id
|
|
337 |
* @param aAttributes Attributes that have been modified
|
|
338 |
*/
|
|
339 |
void HandleItemModifiedL(TInt aId, const RArray<TMPXAttribute>& aAttributes);
|
|
340 |
|
|
341 |
/**
|
|
342 |
* Notify observers of media object being now available
|
|
343 |
*
|
|
344 |
* @param aListIndex index of item for which properties are available
|
|
345 |
*/
|
|
346 |
void NotifyObserversOfMediaL(TInt aListIndex);
|
|
347 |
|
|
348 |
/**
|
|
349 |
* Notify observers, and reports errors to error manager
|
|
350 |
*/
|
|
351 |
void NotifyObservers( NGlxMediaList::TNotificationStrategy& aStrategy );
|
|
352 |
|
|
353 |
/**
|
|
354 |
* Populates the path with hierarchy to parent
|
|
355 |
*
|
|
356 |
* @param aPath path to populate
|
|
357 |
*/
|
|
358 |
void PathPopulateParentL(CMPXCollectionPath& aPath) const;
|
|
359 |
|
|
360 |
/**
|
|
361 |
* Populates the path with all items
|
|
362 |
* and sets the focus
|
|
363 |
*
|
|
364 |
* @param aPath path to populate
|
|
365 |
*/
|
|
366 |
void PathPopulateAllL(CMPXCollectionPath& aPath) const;
|
|
367 |
|
|
368 |
/**
|
|
369 |
* Populates the path with focused item
|
|
370 |
* and sets the focus
|
|
371 |
*
|
|
372 |
* @param aPath path to populate
|
|
373 |
*/
|
|
374 |
void PathPopulateFocusL(CMPXCollectionPath& aPath) const;
|
|
375 |
|
|
376 |
/**
|
|
377 |
* Populates the path with selected items
|
|
378 |
* and selects all
|
|
379 |
*
|
|
380 |
* @param aPath path to populate
|
|
381 |
*/
|
|
382 |
void PathPopulateSelectionL(CMPXCollectionPath& aPath) const;
|
|
383 |
|
|
384 |
/*
|
|
385 |
* Updates each media used by this media list with the current index
|
|
386 |
*/
|
|
387 |
void UpdateMedia();
|
|
388 |
|
|
389 |
/*
|
|
390 |
* Updates each media used by this media list with the current index
|
|
391 |
*/
|
|
392 |
void UpdateMediaInvalidateAttributesChangedByCounts(TGlxMedia& aItem);
|
|
393 |
|
|
394 |
/**
|
|
395 |
* Opens a collection at the appropriate level
|
|
396 |
*
|
|
397 |
* @param aPath used to determine which collection and level to open
|
|
398 |
*/
|
|
399 |
void OpenCollectionL(const CMPXCollectionPath& aPath);
|
|
400 |
|
|
401 |
/**
|
|
402 |
* Handles the tasks after open completes
|
|
403 |
*/
|
|
404 |
void HandleOpenL();
|
|
405 |
|
|
406 |
private:
|
|
407 |
/**
|
|
408 |
* Enumeration to indicate pending sync status
|
|
409 |
*/
|
|
410 |
enum TSyncStatus
|
|
411 |
{
|
|
412 |
KNonePending,
|
|
413 |
KSyncPending,
|
|
414 |
KResyncPending
|
|
415 |
};
|
|
416 |
|
|
417 |
/**
|
|
418 |
* TContext
|
|
419 |
*/
|
|
420 |
struct TContext
|
|
421 |
{
|
|
422 |
/**
|
|
423 |
* Find match by context pointer
|
|
424 |
*/
|
|
425 |
static TBool Match(const TContext& a1, const TContext& a2);
|
|
426 |
|
|
427 |
/**
|
|
428 |
* Compare by comparing priority
|
|
429 |
*/
|
|
430 |
static TInt Compare(const TContext& a1, const TContext& a2);
|
|
431 |
|
|
432 |
const MGlxFetchContext* iContext; // Not owned
|
|
433 |
TInt iPriority; // Priority, higher is more important
|
|
434 |
};
|
|
435 |
|
|
436 |
private:
|
|
437 |
/**
|
|
438 |
* Number of users of this object
|
|
439 |
*/
|
|
440 |
TInt iReferenceCount;
|
|
441 |
|
|
442 |
/**
|
|
443 |
* Manager of this list
|
|
444 |
* Not owned
|
|
445 |
*/
|
|
446 |
CGlxCacheManager* iManager;
|
|
447 |
|
|
448 |
/**
|
|
449 |
* Observers that will be notified if items get added or removed or if they change
|
|
450 |
* Not owned
|
|
451 |
*/
|
|
452 |
RPointerArray<MGlxMediaListObserver> iItemListObservers;
|
|
453 |
|
|
454 |
/**
|
|
455 |
* Contexts that contain intelligence of attribute (e.g.,
|
|
456 |
* thumbnail of URI) retrieving, incl. priorities. Not owned
|
|
457 |
*/
|
|
458 |
RArray<TContext> iContexts;
|
|
459 |
|
|
460 |
/** List that contains items, focus, and selection */
|
|
461 |
CGlxNavigableList* iItemList;
|
|
462 |
|
|
463 |
/**
|
|
464 |
* Collection utility that is bound to this list.
|
|
465 |
*/
|
|
466 |
MMPXCollectionUtility* iCollectionUtility; // own
|
|
467 |
|
|
468 |
RArray<TGlxMediaId> iPath;
|
|
469 |
|
|
470 |
/**
|
|
471 |
* Indicates if a command has already been placed on the collection, which has not complete yet.
|
|
472 |
* Currently, only one command can be made at a time
|
|
473 |
* Stores the sessionId (client that issued the command)
|
|
474 |
*/
|
|
475 |
TAny* iCommandPending;
|
|
476 |
|
|
477 |
/**
|
|
478 |
* Filter currently set on the collection. Owned
|
|
479 |
*/
|
|
480 |
CMPXFilter* iFilter;
|
|
481 |
|
|
482 |
/// IdSpaceId for items in the list.
|
|
483 |
TGlxIdSpaceId iIdSpaceId;
|
|
484 |
|
|
485 |
TGlxHierarchyId iHierarchyId;
|
|
486 |
|
|
487 |
/**
|
|
488 |
* Is populated, set to ETrue
|
|
489 |
* when the media list is first populated.
|
|
490 |
*/
|
|
491 |
TBool iIsPopulated;
|
|
492 |
|
|
493 |
/**
|
|
494 |
* Singleton to post errors to
|
|
495 |
*/
|
|
496 |
CGlxErrorPoster* iErrorPoster;
|
|
497 |
|
|
498 |
/// Indicates that filter was set, so need to re-order contents
|
|
499 |
TBool iReorderPending;
|
|
500 |
|
|
501 |
/// Indicates that item(s) updated, so need to sync now or resync later
|
|
502 |
TSyncStatus iSyncStatus;
|
|
503 |
|
|
504 |
/**
|
|
505 |
* Array of media lists
|
|
506 |
* (singleton: should be closed, not deleted)
|
|
507 |
*/
|
|
508 |
CGlxMediaListArray* iMediaListArray;
|
|
509 |
|
|
510 |
/// Array of attributes to be invalidated when items are added or removed
|
|
511 |
RArray<TMPXAttribute> iCountAttributes;
|
|
512 |
|
|
513 |
/// VisibleWindow Index
|
|
514 |
TInt iVisibleWindowIndex;
|
|
515 |
};
|
|
516 |
|
|
517 |
#endif // C_GLXMEDIALIST_H
|