|
1 /* |
|
2 * Copyright (c) 2008 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: Categories related functionality* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 #ifndef VCXMYVIDEOSCATEGORIES_H |
|
21 #define VCXMYVIDEOSCATEGORIES_H |
|
22 |
|
23 // INCLUDES |
|
24 |
|
25 #include <vcxmyvideosdefs.h> |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CMPXMedia; |
|
29 class CVcxMyVideosCollectionPlugin; |
|
30 |
|
31 // CONSTANTS |
|
32 |
|
33 // CLASS DECLARATION |
|
34 |
|
35 /** |
|
36 * MPX My Videos collection categories implementation. |
|
37 * |
|
38 * @lib mpxmyvideoscollectionplugin.lib |
|
39 */ |
|
40 NONSHARABLE_CLASS(CVcxMyVideosCategories) : CBase |
|
41 { |
|
42 public: // Constructors and destructor |
|
43 |
|
44 /** |
|
45 * Two-phased constructor |
|
46 * @return object constructed |
|
47 */ |
|
48 static CVcxMyVideosCategories* NewL ( CVcxMyVideosCollectionPlugin& aCollection ); |
|
49 |
|
50 /** |
|
51 * Destructor |
|
52 */ |
|
53 virtual ~CVcxMyVideosCategories(); |
|
54 |
|
55 /** |
|
56 * Creates Media container with categories. |
|
57 */ |
|
58 CMPXMedia* CreateCategoryListL(); |
|
59 |
|
60 public: // new methods |
|
61 |
|
62 /** |
|
63 * When CVcxMyVideosVideoCache::iCache->iVideoList is grown (appended), |
|
64 * this is called to update category attributes. |
|
65 * |
|
66 * @param aVideoList Current video list cache. |
|
67 * @param aNewItemsStartIndex Start position of new items. |
|
68 */ |
|
69 void UpdateCategoriesL( CMPXMedia& aVideoList, TInt aNewItemsStartIndex ); |
|
70 |
|
71 /** |
|
72 * Called after video is added to iCollection.iCache. |
|
73 * Updates category variables accordingly. |
|
74 * Modify events to iCollection.iMessageList are added, but the list |
|
75 * is not sent. |
|
76 * |
|
77 * @param aMdsId Item which was added. |
|
78 */ |
|
79 void VideoAddedL( TUint32 aMdsId ); |
|
80 |
|
81 |
|
82 /** |
|
83 * Called after video is added to iCollection.iCache. |
|
84 * Updates category variables accordingly. |
|
85 * Modify events to iCollection.iMessageList are added, but the list |
|
86 * is not sent. |
|
87 * |
|
88 * @param aVideo Item which was added. |
|
89 */ |
|
90 void VideoAddedL( CMPXMedia& aVideo ); |
|
91 |
|
92 /** |
|
93 * Called after videos are added to iCollection.iCache. |
|
94 * Updates category variables accordingly. |
|
95 * Modify events to iCollection.iMessageList are added, but the list |
|
96 * is not sent. |
|
97 * |
|
98 * @param aIds Items which were added. |
|
99 */ |
|
100 void VideosAddedL( RArray<TUint32>& aIds ); |
|
101 |
|
102 /** |
|
103 * Called just _before_ video is removed from iCollection.iCache. |
|
104 * Updates category variables accordingly. |
|
105 * Modify events to iCollection.iMessageList are added, but the list |
|
106 * is not sent. |
|
107 * |
|
108 * @param aMdsId Item which is being removed. |
|
109 */ |
|
110 void VideoRemovedL( TUint32 aMdsId ); |
|
111 |
|
112 /** |
|
113 * Called just _before_ video is removed from iCollection.iCache. |
|
114 * Updates category variables accordingly. |
|
115 * Modify events to iCollection.iMessageList are added, but the list |
|
116 * is not sent. |
|
117 * |
|
118 * @param aVideo Item which is being removed. |
|
119 */ |
|
120 void VideoRemovedL( CMPXMedia& aVideo ); |
|
121 |
|
122 /** |
|
123 * Called just _before_ videos are removed from iCollection.iCache. |
|
124 * Updates category variables accordingly. |
|
125 * Modify events to iCollection.iMessageList are added, but the list |
|
126 * is not sent. |
|
127 * |
|
128 * @param aIds Items which are being removed. |
|
129 */ |
|
130 void VideosRemovedL( RArray<TUint32>& aIds ); |
|
131 |
|
132 /** |
|
133 * Resets video counters to 0 from categories. Does not |
|
134 * send events. |
|
135 */ |
|
136 void ResetVideoCountersL(); |
|
137 |
|
138 /** |
|
139 * Updates categories' New Video Name fields. |
|
140 * Sends iCollection.iMessageList if any of the categories is modified. |
|
141 */ |
|
142 void UpdateCategoriesNewVideoNamesL(); |
|
143 |
|
144 |
|
145 /** |
|
146 * Called when video is updated in a way it affects New Video Name (and date) in category. |
|
147 * This updates the category accordinly. This function adds modify events to |
|
148 * collections message list if category is edited. Does not flush the message list. |
|
149 * |
|
150 * @param aVideo Video which was changed. |
|
151 * @param aModified Set to ETrue if categories were modified. |
|
152 */ |
|
153 void UpdateCategoryNewVideoNameAndDateL( CMPXMedia& aVideo, TBool& aModified ); |
|
154 |
|
155 /** |
|
156 * Called when items New Video Flag is updated in iCollection.iCache. |
|
157 * This function updates video counters only, no New Video Name. |
|
158 * |
|
159 * @param aOldFlags Items flags before update. |
|
160 * @param aNewFlags Items flags after update. |
|
161 * @param aOrigin Which origin is affected. |
|
162 * @param aModified Set to ETrue if category counters were edited and events |
|
163 * were added to message list. This does not flush the message list. |
|
164 */ |
|
165 void NewVideoFlagChangedL( TUint32 aOldFlags, TUint32 aNewFlags, |
|
166 TUint8 aOrigin, TBool& aModified ); |
|
167 |
|
168 /** |
|
169 * Checks in which categories the video belongs to and sends modified events for them. |
|
170 * |
|
171 * @param aVideo Video which was modified. |
|
172 * @param aFlushMessageList If ETrue, then the collections message list is sent to clients. |
|
173 * @param aExtraInfo Extra information about the event, this value is written to |
|
174 * KVcxMediaMyVideosInt32Value attribute. If aExtraInfo |
|
175 * is 0, nothing is written. |
|
176 */ |
|
177 void GenerateCategoryModifiedEventL( CMPXMedia& aVideo, TBool aFlushMessageList, |
|
178 TInt32 aExtraInfo = 0 ); |
|
179 |
|
180 /** |
|
181 * Called when videos origin is changed in iCollection.iCache. |
|
182 * Updates category variables and sends necessarry events. |
|
183 * |
|
184 * @param aVideo Video which is changed, flags variable is read from here. |
|
185 * @param aPrevOrigin Previous origin. |
|
186 * @param aNewOrigin New origin. |
|
187 */ |
|
188 void OriginChangedL( CMPXMedia& aVideo, TUint8 aPrevOrigin, TUint8 aNewOrigin ); |
|
189 |
|
190 private: |
|
191 /** |
|
192 * Constructor |
|
193 */ |
|
194 CVcxMyVideosCategories( CVcxMyVideosCollectionPlugin& aCollectionPlugin ); |
|
195 |
|
196 /** |
|
197 * Symbian 2nd phase constructor. |
|
198 */ |
|
199 void ConstructL (); |
|
200 |
|
201 /** |
|
202 * Creates CMPXMedia object with category values and appends it to |
|
203 * aCategoryArray. |
|
204 * |
|
205 * @param aTitle Category title. |
|
206 * @param aId Collection item ID |
|
207 * @param aCategoryArray New CMPXMedia category object is appended here. |
|
208 */ |
|
209 void AppendCategoryToArrayL( const TDesC& aTitle, TMPXItemId aId, |
|
210 CMPXMediaArray& aCategoryArray ); |
|
211 |
|
212 /** |
|
213 * Updates video counts in categories. |
|
214 * |
|
215 * @param aCategoryArray Category array, provided as function parameter since the |
|
216 * calling function already has it available. |
|
217 * @param aVideosIncrements How many new items were added to each category. |
|
218 * @param aNewVideosIncrements How many videos with new flag were added to each category. |
|
219 * @param aForceUpdate If set, the modify event is raised even though the count |
|
220 * has not changed. ETrue, if update is to be forced. |
|
221 */ |
|
222 void UpdateVideosCountL( CMPXMediaArray& aCategoryArray, |
|
223 RArray<TInt>& aVideosIncrements, RArray<TInt>& aNewVideosIncrements, |
|
224 TBool aForceUpdate ); |
|
225 |
|
226 /** |
|
227 * Increases/decreases aCountAttribute in aCategory. Adds event to |
|
228 * iCollection.iMessageList if category is modified. aEventInfo is written |
|
229 * to event's extra info. Does not flush iCollection.iMessageList. |
|
230 * |
|
231 * @param aCategory Category being modified. |
|
232 * @param aIncrement This is added to category's current attribute value. |
|
233 * @param aCountAttribute Attribute ID. |
|
234 * @param aEventInfo This is written to generated event's extra info attribute. |
|
235 * |
|
236 */ |
|
237 void UpdateVideosCountL( CMPXMedia& aCategory, TInt aIncrement, |
|
238 TMPXAttributeData aCountAttribute, TInt aEventInfo ); |
|
239 |
|
240 /** |
|
241 * aVideo is added(or removed) to aCategory. Updates category variables accordingly. |
|
242 * |
|
243 * @param aCategory Category |
|
244 * @param aCategoryIndex Category index in iList |
|
245 * @param aAdded ETrue if aVideo was added to iList, EFalse if being removedo. |
|
246 */ |
|
247 void UpdateCategoryL( CMPXMedia& aCategory, TInt aCategoryIndex, |
|
248 CMPXMedia& aVideo, TBool aAdded ); |
|
249 |
|
250 /** |
|
251 * Adds aAddition to aAttribute in aCategory. |
|
252 * |
|
253 * @param aCategory Category to modify. |
|
254 * @param aAddition How much increase/decrease the attribute. |
|
255 * @param aAttribute Which attribute to modify. |
|
256 */ |
|
257 void AddToTUint32AttributeL( CMPXMedia& aCategory, TInt aAddition, |
|
258 TMPXAttributeData aAttribute ); |
|
259 |
|
260 /** |
|
261 * Returns the corresponding category index in category list (=iList) for aOrigin. |
|
262 * Notice that category index is the same as categorys MPXIDs iId1 value. |
|
263 * They should be kept the same. |
|
264 * |
|
265 * @param aOrigin Origin, see values from TVcxMyVideosOrigin, if -1 given, then |
|
266 * index for All category is returned. |
|
267 * @return Index in category list (=iList) |
|
268 */ |
|
269 TInt CategoryIndex( TInt aOrigin ); |
|
270 |
|
271 /** |
|
272 * Updates categorys New Video Name and Creation date fields. Sets aModified to |
|
273 * ETrue if value is changed, also adds modify event to event list, |
|
274 * but does not send it. |
|
275 * |
|
276 * @param aOrigin Identifies the category, -1 is used for All category. |
|
277 * @param aModified Set to ETrue if category item is modified. Otherwise |
|
278 * the value is not touched. |
|
279 * @param aIgnoredIds Items with these MDS ids are ignored on the update. |
|
280 * Usefull if items are being deleted but are still on the |
|
281 * video list. |
|
282 */ |
|
283 void UpdateCategoryNewVideoNameAndDateL( TInt aOrigin, TBool& aModified, |
|
284 RArray<TUint32>& aIgnoredIds ); |
|
285 |
|
286 /** |
|
287 * Goes through aVideoList and checks all videos which have new video |
|
288 * flag set and returns the latest ones name. Pointer to latest video |
|
289 * object is written to aNewVideo. |
|
290 * |
|
291 * @param aVideoList Video list |
|
292 * @param aOrigin Can be used to filter search. Only items which have |
|
293 * matching origin are included to the operation. |
|
294 * If -1, then all items are included. |
|
295 * @param aIgnoredIds Items with these MDS ids are ignored on the update. |
|
296 * Usefull if items are being deleted but are still on the |
|
297 * video list. |
|
298 * @param aNewVideo Pointer to media object containing the new video name is |
|
299 * written here. NULL is written if not found. Ownership |
|
300 * does not move (stays in aVideoList). |
|
301 * |
|
302 */ |
|
303 const TDesC& CalculateNewVideoNameL( CMPXMedia& aVideoList, TInt aOrigin, |
|
304 RArray<TUint32>& aIgnoredIds, CMPXMedia*& aNewVideo ); |
|
305 |
|
306 /** |
|
307 * Video was added or is being removed in iCollection.iCache. Update |
|
308 * Categories accordingly. |
|
309 * |
|
310 * @param aMdsId Item which was added or removed. |
|
311 * @param aAdded ETrue if add operation, EFalse if remove. |
|
312 */ |
|
313 void VideoAddedOrRemovedL( TUint32 aMdsId, TBool aAdded ); |
|
314 |
|
315 /** |
|
316 * Video was added or is being removed in iCollection.iCache. Update |
|
317 * Categories accordingly. |
|
318 * |
|
319 * @param aVideo Item which was added or removed. |
|
320 * @param aAdded ETrue if add operation, EFalse if remove. |
|
321 */ |
|
322 void VideoAddedOrRemovedL( CMPXMedia& aVideo, TBool aAdded ); |
|
323 |
|
324 /** |
|
325 * Videos were added or are being removed in iCollection.iCache. Update |
|
326 * Categories accordingly. |
|
327 * |
|
328 * @param aIds Items which were added or are being removed. |
|
329 * @param aAdded ETrue if add operation, EFalse if remove. |
|
330 */ |
|
331 void VideosAddedOrRemovedL( RArray<TUint32>& aIds, TBool aAdded ); |
|
332 |
|
333 /** |
|
334 * Resets iModifiedCategories |
|
335 */ |
|
336 void ResetModifiedCategoriesArray(); |
|
337 |
|
338 /** |
|
339 * Creates events from iModifiedCategories and adds them |
|
340 * to iCollection.iMessageList. Does not send. |
|
341 */ |
|
342 void AddEventsFromModifiedCategoriesArrayL(); |
|
343 |
|
344 public: |
|
345 |
|
346 /** |
|
347 * Contains category list, this is kept in memory to speed things up. |
|
348 * Own. |
|
349 */ |
|
350 CMPXMedia* iList; |
|
351 |
|
352 /** |
|
353 * Media array of iList, owned by iList. |
|
354 */ |
|
355 CMPXMediaArray* iListArray; |
|
356 |
|
357 private: |
|
358 |
|
359 /** |
|
360 * Owner of this object. |
|
361 */ |
|
362 CVcxMyVideosCollectionPlugin& iCollection; |
|
363 |
|
364 /** |
|
365 * Array containing boolean for each category, if set ETrue, then modified event |
|
366 * has been added for the category (to iCollection.iMessageList). |
|
367 */ |
|
368 RArray<TBool> iModifiedCategories; |
|
369 |
|
370 }; |
|
371 |
|
372 #endif // VCXMYVIDEOSCATEGORIES_H |
|
373 |
|
374 |