1 /* |
|
2 * Copyright (c) 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: CMdEManager declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMDEMANAGER_H |
|
20 #define CMDEMANAGER_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <mdesession.h> |
|
24 #include <mdequery.h> |
|
25 |
|
26 #include "playlistitem.h" |
|
27 |
|
28 class MMdEManagerObserver |
|
29 { |
|
30 public: |
|
31 virtual void AlbumsReaded( TInt aError ) = 0; |
|
32 virtual void AlbumReplaced( TInt aError ) = 0; |
|
33 }; |
|
34 |
|
35 class CMdEManager : public CBase, |
|
36 MMdESessionObserver, |
|
37 MMdEQueryObserver |
|
38 { |
|
39 public: |
|
40 // Cancel and destroy |
|
41 ~CMdEManager(); |
|
42 |
|
43 // Two-phased constructor. |
|
44 static CMdEManager* NewL( MMdEManagerObserver& aObserver ); |
|
45 |
|
46 public: |
|
47 |
|
48 /** |
|
49 * Start enumerating albums. Calls MMdEManagerObserver::AlbumsReaded when ready. |
|
50 * This needs to be called before any other operations. |
|
51 */ |
|
52 void GetAlbumsL(); |
|
53 |
|
54 |
|
55 RPointerArray<CPlaylistItem>& AlbumsArray(){ return iAlbums; }; |
|
56 const CPlaylistItem& AlbumL( TInt aAlbumId ) const; |
|
57 |
|
58 void CreateAlbumL( CPlaylistItem& aAlbum ); |
|
59 void ReplaceAlbumL( TInt aAlbumId, CPlaylistItem& aAlbum ); |
|
60 void DeleteAlbumL( TInt aAlbumId ); |
|
61 |
|
62 /** |
|
63 * Cancels any outstanding request if any. |
|
64 */ |
|
65 void Cancel(); |
|
66 |
|
67 private: |
|
68 void StartProcessingAlbumsL(); |
|
69 void ProcessNextAlbumL(); |
|
70 void FindItemsOnAlbumL( TItemId aAlbumObjectId ); |
|
71 |
|
72 private: // from MMdESessionObserver |
|
73 /** |
|
74 * Called to notify the observer that opening the session has been |
|
75 * completed and, if the opening succeeded, the session is ready for use. |
|
76 * |
|
77 * @param aSession session |
|
78 * @param aError <code>KErrNone</code>, if opening the session succeeded; |
|
79 * or one of the system-wide error codes, if opening the |
|
80 * session failed |
|
81 */ |
|
82 void HandleSessionOpened(CMdESession& aSession, TInt aError); |
|
83 |
|
84 /** |
|
85 * Called to notify the observer about errors, which are not a direct |
|
86 * consequence of the operations initiated by the client but caused by |
|
87 * some external source (e.g., other clients). The error cannot be |
|
88 * recovered and all on-going operations initiated by the client have been |
|
89 * aborted. Any attempts to continue using the session will cause a panic. |
|
90 * The client should close the session immediately and try to open a new |
|
91 * session, if it needs to continue using the metadata engine. |
|
92 * |
|
93 * @param aSession session |
|
94 * @param aError one of the system-wide error codes |
|
95 */ |
|
96 void HandleSessionError(CMdESession& aSession, TInt aError); |
|
97 |
|
98 private: // from MMdEQueryObserver |
|
99 /** |
|
100 * Called to notify the observer that new results have been received |
|
101 * in the query. |
|
102 * |
|
103 * @param aQuery Query instance that received new results. |
|
104 * @param aFirstNewItemIndex Index of the first new item that was added |
|
105 * to the result item array. |
|
106 * @param aNewItemCount Number of items added to the result item |
|
107 * array. |
|
108 */ |
|
109 void HandleQueryNewResults(CMdEQuery& aQuery, |
|
110 TInt aFirstNewItemIndex, |
|
111 TInt aNewItemCount); |
|
112 |
|
113 |
|
114 |
|
115 /** |
|
116 * Called to notify the observer that the query has been completed, |
|
117 * or that an error has occured. |
|
118 * |
|
119 * @param aQuery Query instance. |
|
120 * @param aError <code>KErrNone</code>, if the query was completed |
|
121 * successfully. Otherwise one of the system-wide error |
|
122 * codes. |
|
123 */ |
|
124 void HandleQueryCompleted(CMdEQuery& aQuery, TInt aError); |
|
125 private: |
|
126 |
|
127 CMdEManager( MMdEManagerObserver& aObserver ); |
|
128 |
|
129 void ConstructL(); |
|
130 |
|
131 void HandleAlbumQueryCompletedL( CMdEObjectQuery& aQuery ); |
|
132 void HandleObjectQueryCompletedL( CMdEObjectQuery& aQuery ); |
|
133 void HandleRelationQueryCompletedL( CMdERelationQuery& aQuery ); |
|
134 |
|
135 private: |
|
136 enum TCMdEManagerState |
|
137 { |
|
138 EUninitialized, // Uninitialized / initialization is ongoing |
|
139 EWaitingToEnumerateAlbums, // Initializing and starting collecting albums info |
|
140 EEnumeratingAlbums, // Album enumeration is ongoing |
|
141 EReplacingAlbum, // Replacing album (searching removed relation id:s) |
|
142 EIdle // Ready for next operation |
|
143 }; |
|
144 |
|
145 private: |
|
146 MMdEManagerObserver& iObserver; |
|
147 TCMdEManagerState iState; |
|
148 |
|
149 CMdESession* iMde; |
|
150 CMdEObjectQuery* iAlbumQuery; |
|
151 CMdEObjectQuery* iObjectQuery; |
|
152 CMdERelationQuery* iContainmentQuery; |
|
153 |
|
154 RPointerArray<CPlaylistItem> iAlbumsInProgress; |
|
155 RPointerArray<CPlaylistItem> iAlbums; |
|
156 |
|
157 }; |
|
158 |
|
159 #endif // CMDEMANAGER_H |
|