|
1 /* |
|
2 * Copyright (c) 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 the License "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: Albums related collection functionality. |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 #ifndef VCXMYVIDEOSALBUMS_H |
|
20 #define VCXMYVIDEOSALBUMS_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <mdequery.h> |
|
24 #include "vcxmyvideosmdsdb.h" |
|
25 #include "vcxmyvideosalbum.h" |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CVcxMyVideosMdsDb; |
|
29 class CMPXMedia; |
|
30 class CVcxMyVideosCollectionPlugin; |
|
31 class CVcxMyVideosAlbum; |
|
32 |
|
33 // CONSTANTS |
|
34 |
|
35 // CLASS DECLARATION |
|
36 |
|
37 /** |
|
38 * Albums related collection functionality. |
|
39 * |
|
40 * @lib mpxmyvideoscollectionplugin.lib |
|
41 */ |
|
42 NONSHARABLE_CLASS(CVcxMyVideosAlbums) : public CBase, public MVcxMyVideosMdsAlbumsObserver |
|
43 { |
|
44 public: // Constructors and destructor |
|
45 |
|
46 /** |
|
47 * Two-phased constructor |
|
48 * @return object constructed |
|
49 */ |
|
50 static CVcxMyVideosAlbums* NewL( CVcxMyVideosCollectionPlugin& aCollectionPlugin ); |
|
51 |
|
52 /** |
|
53 * Destructor |
|
54 */ |
|
55 virtual ~CVcxMyVideosAlbums(); |
|
56 |
|
57 public: // new methods |
|
58 |
|
59 /** |
|
60 * Returns album from iAlbums array by MDS ID. Ownership does not move. |
|
61 * |
|
62 * @param aMdsId MDS ID of the album to get. |
|
63 * @param aPos If given, then the position index in iAlbums is written here. |
|
64 * Ownership does not move. |
|
65 * @return Pointer to album or NULL if not found. |
|
66 */ |
|
67 CVcxMyVideosAlbum* Album( TUint32 aMdsId, TInt* aPos = NULL ); |
|
68 |
|
69 /** |
|
70 * Creates iAlbumList if it doesn't exist yet. The list is populated |
|
71 * from async callback, HandleGetAlbumsResp(). |
|
72 */ |
|
73 void CreateAlbumListL(); |
|
74 |
|
75 /** |
|
76 * Fetches MDS IDs from MDS for all videos belonging to albums. |
|
77 * Ie fills iAlbums[*]->iVideoList[*].iMdsId (and iAlbums[*]->iVideoList[*].iRelationMdsId) fields. |
|
78 * Causes several async calls to MDS. |
|
79 */ |
|
80 void GetAlbumContentIdsL(); |
|
81 |
|
82 /** |
|
83 * Adds videos to album. |
|
84 * |
|
85 * @param aCmd See attribute usage from vcxmyvideosdefs.h. |
|
86 */ |
|
87 void AddVideosToAlbumL( CMPXMedia* aCmd ); |
|
88 |
|
89 /** |
|
90 * Removes videos from album. |
|
91 * |
|
92 * @param aCmd See attribute usage from vcxmyvideosdefs.h. |
|
93 */ |
|
94 void RemoveVideosFromAlbumL( CMPXMedia* aCmd ); |
|
95 |
|
96 /** |
|
97 * Adds album to MDS and to this class. KMPXMediaGeneralTitle |
|
98 * should be set in aCmd. Upon completion, the KMPXMediaGeneralId |
|
99 * attribute contains the new MPX item ID. Leaves if could |
|
100 * not add to MDS. |
|
101 * |
|
102 * @param aCmd Command object received from collection client. |
|
103 */ |
|
104 void AddAlbumL( CMPXMedia& aCmd ); |
|
105 |
|
106 /** |
|
107 * Removes albums from MDS. MDS delete events will clean up albums |
|
108 * from this class. |
|
109 * |
|
110 * @param aCmd MPX command received from the client. Contains media array, |
|
111 * which contains medias with album IDs set to KMPXMediaGeneralId. |
|
112 * Ownership does not move. |
|
113 */ |
|
114 void RemoveAlbumsFromMdsOnlyL( CMPXMedia* aCmd ); |
|
115 |
|
116 /** |
|
117 * Removes albums from this object (iAlbumList and iAlbums). |
|
118 * Called from MDS delete event. Album IDs which were removed are |
|
119 * also removed from aAlbumIds array. After the call aAlbumIds |
|
120 * will contain items which were not found and not deleted. |
|
121 * Sends appropriate events to collection client. |
|
122 * |
|
123 * @param aAlbumIds Album IDs to be removed. |
|
124 */ |
|
125 void RemoveAlbumsL( RArray<TUint32>& aAlbumIds ); |
|
126 |
|
127 /** |
|
128 * Removes album from this class (iAlbumList and iAlbums). |
|
129 * Adds event to message list but does not send it. |
|
130 * |
|
131 * @param aMdsIds Album MDS ID to be removed. |
|
132 * @param aCompress If ETrue, then iAlbums is compressed, |
|
133 * otherwise not. |
|
134 * @return ETrue if album was found and removed. |
|
135 */ |
|
136 TBool RemoveAlbum( TUint32 aMdsId, TBool aCompress ); |
|
137 |
|
138 /** |
|
139 * Fetches albums from MDS. This is called from MDS insert event. |
|
140 * |
|
141 * @param aAlbumIds Album IDs to fetch. |
|
142 */ |
|
143 void AddAlbumsFromMdsL( RArray<TUint32>& aAlbumIds ); |
|
144 |
|
145 /** |
|
146 * From MVcxMyVideosMdsAlbumsObserver. |
|
147 * Process albums arriving from MDS. Response to VcxMyVideosMdsAlbums::GetAlbumsL. |
|
148 */ |
|
149 void HandleGetAlbumsRespL( CMPXMedia* aAlbumList ); |
|
150 |
|
151 /** |
|
152 * From MVcxMyVideosMdsAlbumsObserver. |
|
153 * Process content ids arriving from MDS. Response to VcxMyVideosMdsAlbums::GetAlbumContentIdsL. |
|
154 * |
|
155 * @param aAlbumId ID of the album. |
|
156 * @param aAlbumContent Array containing MDS object IDs. This array is the same which |
|
157 * was given in GetAlbumContentIdsL call. |
|
158 */ |
|
159 void HandleGetAlbumContentIdsRespL( TUint32 aAlbumId, |
|
160 RArray<TVcxMyVideosAlbumVideo>& aAlbumContentIds ); |
|
161 |
|
162 /** |
|
163 * From MVcxMyVideosMdsAlbumsObserver. |
|
164 * Response to VcxMyVideosMdsAlbums::GetAlbumsL. |
|
165 * Sends insert events to collection clients. |
|
166 * |
|
167 * @param aAlbumList Pointer to same array which was given in GetAlbums call. |
|
168 */ |
|
169 void HandleGetAlbumsResp( CMPXMedia* aAlbumList ); |
|
170 |
|
171 /** |
|
172 * From MVcxMyVideosMdsAlbumsObserver. |
|
173 * Process content ids arriving from MDS. Response to CVcxMyVideosMdsAlbums::GetAlbumContentIdsL. |
|
174 * |
|
175 * @param aAlbumId ID of the album. |
|
176 * @param aAlbumContent Array containing MDS object IDs. This array is the same which |
|
177 * was given in GetAlbumContentL call. |
|
178 */ |
|
179 void HandleGetAlbumContentIdsResp( TUint32 aAlbumId, |
|
180 RArray<TVcxMyVideosAlbumVideo>& aAlbumContentIds ); |
|
181 |
|
182 /** |
|
183 * From MVcxMyVideosMdsAlbumsObserver. |
|
184 * Process content videos arriving from MDS. Response to CVcxMyVideosMdsAlbums::GetAlbumContentVideosL. |
|
185 * |
|
186 * @param aAlbumId Album ID. |
|
187 * @param aVideoList Media containing media array, array items are videos. |
|
188 * @param aError Error code in case of failure. |
|
189 * @param aFirstNewItemIndex The index of the first new item. |
|
190 * @param aNewItemCount How many new items since the last results. |
|
191 * @param aComplete ETrue is query is complete, EFalse if there is new to come. |
|
192 */ |
|
193 void HandleGetAlbumContentVideosResp( TUint32 /*aAlbumId*/, CMPXMedia& /*aVideoList*/, |
|
194 TInt /*aError*/, TInt /*aFirstNewItemIndex*/, TInt /*aNewItemCount*/, TBool /*aComplete*/ ) {} |
|
195 |
|
196 /** |
|
197 * From MVcxMyVideosMdsAlbumsObserver. |
|
198 * Response to CVcxMyVideosMdsAlbums::AddVideosToAlbumL. |
|
199 * |
|
200 * @param aCmd Pointer to object which was given in AddVideosToAlbumL |
|
201 * function call. Ownership does not move. |
|
202 * @param aItemArray Item array which was tried to add to MDS. |
|
203 */ |
|
204 void HandleAddVideosToAlbumResp( CMPXMedia* aCmd, |
|
205 RPointerArray<CMdEInstanceItem>& aItemArray ); |
|
206 |
|
207 /** |
|
208 * From MVcxMyVideosMdsAlbumsObserver. |
|
209 * Response to CVcxMyVideosMdsAlbums::RemoveRelationsL. |
|
210 */ |
|
211 void HandleRemoveRelationsResp( RArray<TUint32>& aRelationIds, |
|
212 RArray<TUint32>& aResults ); |
|
213 |
|
214 /** |
|
215 * From MVcxMyVideosMdsAlbumsObserver. |
|
216 * Response to CVcxMyVideosMdsAlbums::RemoveAlbumsL. |
|
217 */ |
|
218 void HandleRemoveAlbumsResp( CMPXMedia* aCmd, |
|
219 RArray<TUint32>& aResultIds ); |
|
220 |
|
221 /** |
|
222 * From MVcxMyVideosMdsAlbumsObserver. |
|
223 * Relation events from MDS. This object is set as an observer at |
|
224 * iCollection.ConstructL, CVcxMyVideosMdsDb::NewL(..,aAlbumsObserver,..). |
|
225 */ |
|
226 void HandleRelationEvent( TObserverNotificationType aType, |
|
227 const RArray<TMdERelation>& aRelationArray ); |
|
228 private: |
|
229 |
|
230 /** |
|
231 * Fills in iAlbums array. This is called when iAlbumList is ready. |
|
232 * Pointers to CVcxMyVideosVideoCache::iVideoList are not filled |
|
233 * in yet. |
|
234 */ |
|
235 void CreateAlbumsL(); |
|
236 |
|
237 /** |
|
238 * Constructor |
|
239 */ |
|
240 CVcxMyVideosAlbums( CVcxMyVideosCollectionPlugin& aCollectionPlugin ); |
|
241 |
|
242 /** |
|
243 * Symbian 2nd phase constructor. |
|
244 */ |
|
245 void ConstructL(); |
|
246 |
|
247 /** |
|
248 * Leaving version of HandleAddVideosToAlbumResp. |
|
249 */ |
|
250 void DoHandleAddVideosToAlbumRespL( CMPXMedia* aCmd, |
|
251 RPointerArray<CMdEInstanceItem>& aItemArray ); |
|
252 |
|
253 public: |
|
254 |
|
255 /** |
|
256 * Album list. This is given to client when categorylevel items are requested. Own. |
|
257 * If this is destroyed/edited, then pointers have to be updated in iAlbums. |
|
258 */ |
|
259 CMPXMedia* iAlbumList; |
|
260 |
|
261 /** |
|
262 * Array containing MDS IDs and pointers to album and video media items. |
|
263 * Album media items are in iAlbumList and video media items are in |
|
264 * CVcxMyVideosVideoCache::iVideoList. |
|
265 */ |
|
266 RArray<CVcxMyVideosAlbum*> iAlbums; |
|
267 |
|
268 /** |
|
269 * ETrue when iAlbumList is ready and iAlbums contains video IDs. |
|
270 */ |
|
271 TBool iAlbumListIsComplete; |
|
272 |
|
273 private: |
|
274 |
|
275 /** |
|
276 * Owner of this object. |
|
277 */ |
|
278 CVcxMyVideosCollectionPlugin& iCollection; |
|
279 |
|
280 /** |
|
281 * Used in MDS operations to store MDS video (or relation) IDs. |
|
282 */ |
|
283 RArray<TUint32> iMdsOpTargetIds; |
|
284 |
|
285 /** |
|
286 * Store album video data during relation deletion. This is to |
|
287 * avoid second search when resp arrives. |
|
288 */ |
|
289 RArray<TVcxMyVideosAlbumVideo> iRemoveFromAlbumVideos; |
|
290 |
|
291 /** |
|
292 * Used in MDS operations to store operation results. Is in sync with iMdsOpTargetIds. |
|
293 */ |
|
294 RArray<TInt> iMdsOpResults; |
|
295 |
|
296 /** |
|
297 * Used in MDS operations to store operation results. Is in sync with iMdsOpTargetIds. |
|
298 */ |
|
299 RArray<TUint32> iMdsOpResultsUint32; |
|
300 |
|
301 }; |
|
302 |
|
303 #endif // VCXMYVIDEOSALBUMS_H |
|
304 |
|
305 |