|
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, RArray<TGlxMediaId>& aItemIds, RArray<TMPXAttribute>& aAttributes, CMPXAttributeSpecs*& aDetailedSpecs) const; |
|
103 |
|
104 /** |
|
105 * Ordering function for attributes |
|
106 * |
|
107 * @see TLinearOrder |
|
108 * |
|
109 * @param aItem1 first item to order |
|
110 * @param aItem2 second item to order |
|
111 * @return TInt indicating ordering |
|
112 */ |
|
113 static TInt AttributeOrder(const TMPXAttribute& aItem1, const TMPXAttribute& aItem2); |
|
114 |
|
115 /** |
|
116 * Ordering function for attributes |
|
117 * |
|
118 * @see TLinearOrder |
|
119 * |
|
120 * @param aItem1 first item to order |
|
121 * @param aItem2 second item to order |
|
122 * @return TInt indicating ordering |
|
123 */ |
|
124 static TInt AttributeOrderReversed(const TMPXAttribute& aItem1, const TMPXAttribute& aItem2); |
|
125 |
|
126 public: // From MGlxMediaList |
|
127 /// See @ref MGlxMediaList::Close |
|
128 void Close(); |
|
129 |
|
130 /// See @ref MGlxMediaList::Id |
|
131 TGlxMediaListId Id() const; |
|
132 |
|
133 /// See @ref MGlxMediaList::Count |
|
134 TInt Count(NGlxListDefs::TCountType aType = NGlxListDefs::ECountAll) const; |
|
135 |
|
136 /// See @ref MGlxMediaList::FocusIndex |
|
137 TInt FocusIndex() const; |
|
138 |
|
139 /// See @ref MGlxMediaList::SetFocusL |
|
140 void SetFocusL(NGlxListDefs::TFocusSetType aType, TInt aValue); |
|
141 |
|
142 /// See @ref MGlxMediaList::Item |
|
143 const TGlxMedia& Item(TInt aIndex) const; |
|
144 |
|
145 /// See @ref MGlxMediaList::Index |
|
146 TInt Index(const TGlxIdSpaceId& aIdSpaceId, const TGlxMediaId& aId) const; |
|
147 |
|
148 /// See @ref MGlxMediaList::AddMediaListObserverL |
|
149 void AddMediaListObserverL(MGlxMediaListObserver* aObserver); |
|
150 |
|
151 /// See @ref MGlxMediaList::RemoveMediaListObserver |
|
152 void RemoveMediaListObserver(MGlxMediaListObserver* aObserver); |
|
153 |
|
154 /// See @ref MGlxMediaList::AddContext |
|
155 void AddContextL(const MGlxFetchContext* aContext, TInt aPriority); |
|
156 |
|
157 /// See @ref MGlxMediaList::RemoveContext |
|
158 void RemoveContext(const MGlxFetchContext* aContext); |
|
159 |
|
160 /// See @ref MGlxMediaList::Collection |
|
161 MMPXCollection& Collection() const; |
|
162 |
|
163 /// See @ref MGlxMediaList::PathLC |
|
164 CMPXCollectionPath* PathLC(NGlxListDefs::TPathType aType = NGlxListDefs::EPathAllOrSelection) const; |
|
165 |
|
166 /// See @ref MGlxMediaList::IsSelected |
|
167 TBool IsSelected(TInt aIndex) const; |
|
168 |
|
169 /// See @ref MGlxMediaList::SetSelectedL |
|
170 void SetSelectedL(TInt aIndex, TBool aSelected); |
|
171 |
|
172 /// See @ref MGlxMediaList::SelectionCount |
|
173 TInt SelectionCount() const; |
|
174 |
|
175 /// See @ref MGlxMediaList::SelectedItemIndex |
|
176 TInt SelectedItemIndex(TInt aSelectionIndex) const; |
|
177 |
|
178 /// See @ref MGlxMediaList::CommandL |
|
179 void CommandL(CMPXCommand& aCommand); |
|
180 |
|
181 /// See @ref MGlxMediaList::CancelCommand |
|
182 void CancelCommand(); |
|
183 |
|
184 /// See @ref MGlxMediaList::SetFilterL |
|
185 void SetFilterL(CMPXFilter* aFilter); |
|
186 |
|
187 /// See @ref MGlxMediaList::Filter |
|
188 CMPXFilter* Filter() const; |
|
189 |
|
190 /// See @ref MGlxMediaList::IdSpaceId |
|
191 TGlxIdSpaceId IdSpaceId(TInt aIndex) const; |
|
192 |
|
193 /// See @ref MGlxMediaList::IsPopulated |
|
194 TBool IsPopulated() const; |
|
195 |
|
196 /// See @ref MGlxMediaList::AddStaticItemL |
|
197 void AddStaticItemL( CGlxMedia* aStaticItem, |
|
198 NGlxListDefs::TInsertionPosition aTargetPosition ); |
|
199 |
|
200 /// See @ref MGlxMediaList::RemoveStaticItem |
|
201 void RemoveStaticItem(const TGlxMediaId& aItemId); |
|
202 |
|
203 /// See @ref MGlxMediaList::SetStaticItemsEnabled |
|
204 void SetStaticItemsEnabled( TBool aEnabled ); |
|
205 |
|
206 /// See @ref MGlxMediaList::IsStaticItemsEnabled |
|
207 TBool IsStaticItemsEnabled() const; |
|
208 |
|
209 /// See @ref MGlxMediaList::SetFocusInitialPosition |
|
210 void SetFocusInitialPosition(NGlxListDefs::TFocusInitialPosition aFocusInitialPosition); |
|
211 |
|
212 /// See @ref MGlxMediaList::ResetFocus |
|
213 void ResetFocus(); |
|
214 |
|
215 /// See @ref MGlxMediaList::SetVisibleWindowIndex |
|
216 void SetVisibleWindowIndexL( TInt aIndex ); |
|
217 |
|
218 /// See @ref MGlxMediaList::VisibleWindowIndex |
|
219 TInt VisibleWindowIndex() const; |
|
220 |
|
221 /// See @ref MGlxMediaList::CancelPreviousRequests |
|
222 void CancelPreviousRequests(); |
|
223 |
|
224 public: // From MMPXCollectionObserver |
|
225 /// See @ref MMPXCollectionObserver::HandleCollectionMessageL |
|
226 void HandleCollectionMessageL(const CMPXMessage& aMessage); |
|
227 |
|
228 /// See @ref MMPXCollectionObserver::HandleOpenL |
|
229 void HandleOpenL(const CMPXMedia& aEntries, TInt aIndex, TBool aComplete, TInt aError); |
|
230 |
|
231 /// See @ref MMPXCollectionObserver::HandleOpenL |
|
232 void HandleOpenL(const CMPXCollectionPlaylist& aPlaylist, TInt aError); |
|
233 |
|
234 /// See @ref MMPXCollectionObserver::HandleCollectionMediaL |
|
235 void HandleCollectionMediaL(const CMPXMedia& aMedia, TInt aError); |
|
236 |
|
237 /// See @ref MMPXCollectionObserver::HandleCommandComplete |
|
238 void HandleCommandComplete(CMPXCommand* aCommandResult, TInt aError); |
|
239 |
|
240 // from MGlxNavigableListObserver |
|
241 void HandleItemsAdded( TInt aAddedAtIndex, TInt aCount ); |
|
242 void HandleItemsRemoved( TInt aRemovedFromIndex, TInt aCount ); |
|
243 void HandleFocusChanged( NGlxListDefs::TFocusChangeType aType, |
|
244 TInt aNewIndex, TInt aOldIndex ); |
|
245 void HandleItemSelected( TInt aIndex, TBool aSelected ); |
|
246 |
|
247 // From MGlxMediaUser |
|
248 void HandleAttributesAvailableL( TInt aIndex, const RArray< TMPXAttribute >& aAttributes ); |
|
249 void GetRequiredAttributesL( TInt aIndex, RArray<TMPXAttribute>& aAttributes ); |
|
250 void RemoveReference( TInt aIndex ); |
|
251 void HandleError(TInt aError); |
|
252 |
|
253 private: |
|
254 /** |
|
255 * Two phase constructor |
|
256 */ |
|
257 static CGlxMediaList* NewLC(const TGlxHierarchyId& aHierarchyId); |
|
258 |
|
259 /** |
|
260 * Constructor |
|
261 */ |
|
262 CGlxMediaList(const TGlxHierarchyId& aHierarchyId); |
|
263 |
|
264 /** |
|
265 * Destructor |
|
266 */ |
|
267 virtual ~CGlxMediaList(); |
|
268 |
|
269 /** |
|
270 * 2nd phase constructor |
|
271 */ |
|
272 void ConstructL(); |
|
273 |
|
274 /** |
|
275 * Initialize the media list |
|
276 * Copies the levels from the path, and retrieves the |
|
277 * contents from MPX Collection Server |
|
278 * |
|
279 * @param aPath path that this list refers to |
|
280 */ |
|
281 void OpenL(const CMPXCollectionPath& aPath); |
|
282 |
|
283 /** |
|
284 * Add a reference |
|
285 * |
|
286 * @return new reference count |
|
287 */ |
|
288 TInt AddReference(); |
|
289 |
|
290 /** |
|
291 * Remove a reference |
|
292 * |
|
293 * @return new reference count |
|
294 */ |
|
295 TInt RemoveReference(); |
|
296 |
|
297 /** |
|
298 * Current number of references |
|
299 * |
|
300 * @return new reference count |
|
301 */ |
|
302 TInt ReferenceCount() const; |
|
303 |
|
304 /** |
|
305 * Determines if path is the same |
|
306 * |
|
307 * @param aPath collection path |
|
308 * @return ETrue if this media list refers to the path |
|
309 */ |
|
310 TBool Equals(const CMPXCollectionPath& aPath) const; |
|
311 |
|
312 /** |
|
313 * Determines if this list has a filter applied |
|
314 * |
|
315 * @return Boolean indication if filter has been applied |
|
316 */ |
|
317 TBool IsFiltered() const; |
|
318 |
|
319 /** |
|
320 * Synchronise the media list |
|
321 * Re-retrieves the contents from MPX Collection Server |
|
322 */ |
|
323 void ReOpenL(); |
|
324 |
|
325 /** |
|
326 * Populates the list with the items in the current path |
|
327 */ |
|
328 void PopulateL(); |
|
329 |
|
330 /** |
|
331 * Handles item modifications |
|
332 * |
|
333 * @param aId MPX item id |
|
334 * @param aAttributes Attributes that have been modified |
|
335 */ |
|
336 void HandleItemModifiedL(TInt aId, const RArray<TMPXAttribute>& aAttributes); |
|
337 |
|
338 /** |
|
339 * Notify observers of media object being now available |
|
340 * |
|
341 * @param aListIndex index of item for which properties are available |
|
342 */ |
|
343 void NotifyObserversOfMediaL(TInt aListIndex); |
|
344 |
|
345 /** |
|
346 * Notify observers, and reports errors to error manager |
|
347 */ |
|
348 void NotifyObservers( NGlxMediaList::TNotificationStrategy& aStrategy ); |
|
349 |
|
350 /** |
|
351 * Populates the path with hierarchy to parent |
|
352 * |
|
353 * @param aPath path to populate |
|
354 */ |
|
355 void PathPopulateParentL(CMPXCollectionPath& aPath) const; |
|
356 |
|
357 /** |
|
358 * Populates the path with all items |
|
359 * and sets the focus |
|
360 * |
|
361 * @param aPath path to populate |
|
362 */ |
|
363 void PathPopulateAllL(CMPXCollectionPath& aPath) const; |
|
364 |
|
365 /** |
|
366 * Populates the path with focused item |
|
367 * and sets the focus |
|
368 * |
|
369 * @param aPath path to populate |
|
370 */ |
|
371 void PathPopulateFocusL(CMPXCollectionPath& aPath) const; |
|
372 |
|
373 /** |
|
374 * Populates the path with selected items |
|
375 * and selects all |
|
376 * |
|
377 * @param aPath path to populate |
|
378 */ |
|
379 void PathPopulateSelectionL(CMPXCollectionPath& aPath) const; |
|
380 |
|
381 /* |
|
382 * Updates each media used by this media list with the current index |
|
383 */ |
|
384 void UpdateMedia(); |
|
385 |
|
386 /* |
|
387 * Updates each media used by this media list with the current index |
|
388 */ |
|
389 void UpdateMediaInvalidateAttributesChangedByCounts(TGlxMedia& aItem); |
|
390 |
|
391 /** |
|
392 * Opens a collection at the appropriate level |
|
393 * |
|
394 * @param aPath used to determine which collection and level to open |
|
395 */ |
|
396 void OpenCollectionL(const CMPXCollectionPath& aPath); |
|
397 |
|
398 /** |
|
399 * Handles the tasks after open completes |
|
400 */ |
|
401 void HandleOpenL(); |
|
402 |
|
403 private: |
|
404 /** |
|
405 * Enumeration to indicate pending sync status |
|
406 */ |
|
407 enum TSyncStatus |
|
408 { |
|
409 KNonePending, |
|
410 KSyncPending, |
|
411 KResyncPending |
|
412 }; |
|
413 |
|
414 /** |
|
415 * TContext |
|
416 */ |
|
417 struct TContext |
|
418 { |
|
419 /** |
|
420 * Find match by context pointer |
|
421 */ |
|
422 static TBool Match(const TContext& a1, const TContext& a2); |
|
423 |
|
424 /** |
|
425 * Compare by comparing priority |
|
426 */ |
|
427 static TInt Compare(const TContext& a1, const TContext& a2); |
|
428 |
|
429 const MGlxFetchContext* iContext; // Not owned |
|
430 TInt iPriority; // Priority, higher is more important |
|
431 }; |
|
432 |
|
433 private: |
|
434 /** |
|
435 * Number of users of this object |
|
436 */ |
|
437 TInt iReferenceCount; |
|
438 |
|
439 /** |
|
440 * Manager of this list |
|
441 * Not owned |
|
442 */ |
|
443 CGlxCacheManager* iManager; |
|
444 |
|
445 /** |
|
446 * Observers that will be notified if items get added or removed or if they change |
|
447 * Not owned |
|
448 */ |
|
449 RPointerArray<MGlxMediaListObserver> iItemListObservers; |
|
450 |
|
451 /** |
|
452 * Contexts that contain intelligence of attribute (e.g., |
|
453 * thumbnail of URI) retrieving, incl. priorities. Not owned |
|
454 */ |
|
455 RArray<TContext> iContexts; |
|
456 |
|
457 /** List that contains items, focus, and selection */ |
|
458 CGlxNavigableList* iItemList; |
|
459 |
|
460 /** |
|
461 * Collection utility that is bound to this list. |
|
462 */ |
|
463 MMPXCollectionUtility* iCollectionUtility; // own |
|
464 |
|
465 RArray<TGlxMediaId> iPath; |
|
466 |
|
467 /** |
|
468 * Indicates if a command has already been placed on the collection, which has not complete yet. |
|
469 * Currently, only one command can be made at a time |
|
470 * Stores the sessionId (client that issued the command) |
|
471 */ |
|
472 TAny* iCommandPending; |
|
473 |
|
474 /** |
|
475 * Filter currently set on the collection. Owned |
|
476 */ |
|
477 CMPXFilter* iFilter; |
|
478 |
|
479 /// IdSpaceId for items in the list. |
|
480 TGlxIdSpaceId iIdSpaceId; |
|
481 |
|
482 TGlxHierarchyId iHierarchyId; |
|
483 |
|
484 /** |
|
485 * Is populated, set to ETrue |
|
486 * when the media list is first populated. |
|
487 */ |
|
488 TBool iIsPopulated; |
|
489 |
|
490 /** |
|
491 * Singleton to post errors to |
|
492 */ |
|
493 CGlxErrorPoster* iErrorPoster; |
|
494 |
|
495 /// Indicates that filter was set, so need to re-order contents |
|
496 TBool iReorderPending; |
|
497 |
|
498 /// Indicates that item(s) updated, so need to sync now or resync later |
|
499 TSyncStatus iSyncStatus; |
|
500 |
|
501 /** |
|
502 * Array of media lists |
|
503 * (singleton: should be closed, not deleted) |
|
504 */ |
|
505 CGlxMediaListArray* iMediaListArray; |
|
506 |
|
507 /// Array of attributes to be invalidated when items are added or removed |
|
508 RArray<TMPXAttribute> iCountAttributes; |
|
509 |
|
510 /// VisibleWindow Index |
|
511 TInt iVisibleWindowIndex; |
|
512 }; |
|
513 |
|
514 #endif // C_GLXMEDIALIST_H |