|
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 "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: Thin dll to handle special collection handling events |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CMPXCOLLECTIONMEDIATOR_H |
|
20 #define CMPXCOLLECTIONMEDIATOR_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <f32file.h> |
|
24 #include <barsc.h> |
|
25 |
|
26 #include <mpxcollectionutility.h> |
|
27 |
|
28 // FOWARD DECLARATIONS |
|
29 class CMPXMedia; |
|
30 class CMPXMediaArray; |
|
31 class CMPXCollectionPath; |
|
32 class CMPXCollectionType; |
|
33 class CMPXMoveItemHelper; |
|
34 class MMPXMediatorObserver; |
|
35 class MMPXMoveItemObserver; |
|
36 |
|
37 /** |
|
38 * |
|
39 * Mediator class to handle Music Player specific requirements |
|
40 * ie: files with genre podcast must be stored in podcast db. |
|
41 * |
|
42 * @lib mpxcollectionmediator.lib |
|
43 */ |
|
44 class CMPXCollectionMediator : public CBase |
|
45 { |
|
46 public: |
|
47 |
|
48 /** |
|
49 * Two-phased constructor. |
|
50 * @since S60 v3.2.3 |
|
51 * @param aColUtil collection utility. |
|
52 * @param aObs observer. |
|
53 * @return New instance of CMPXCollectionMediator |
|
54 */ |
|
55 IMPORT_C static CMPXCollectionMediator* NewL( MMPXCollection& aColUtil, |
|
56 MMPXMediatorObserver* aObs = NULL ); |
|
57 |
|
58 /** |
|
59 * Two-phased constructor. |
|
60 * Only use to execute "CheckItemL" not for adding/moving in collection. |
|
61 * @since S60 v3.2.3 |
|
62 * @return New instance of CMPXCollectionMediator |
|
63 */ |
|
64 IMPORT_C static CMPXCollectionMediator* NewL(); |
|
65 |
|
66 /** |
|
67 * Two-phased constructor. |
|
68 * @since S60 v3.2.3 |
|
69 * @param aColUtil. |
|
70 * @return New instance of CMPXCollectionMediator |
|
71 */ |
|
72 IMPORT_C static CMPXCollectionMediator* NewLC( MMPXCollection& aColUtil, |
|
73 MMPXMediatorObserver* aObs = NULL ); |
|
74 |
|
75 /** |
|
76 * Virtual destructor. |
|
77 * @since S60 v3.2.3 |
|
78 */ |
|
79 virtual ~CMPXCollectionMediator(); |
|
80 |
|
81 public: // New functions |
|
82 |
|
83 /** |
|
84 * Add a media to the collection. Upon successfull addition, |
|
85 * its KMPXMediaGeneralId will be updated. |
|
86 * @since S60 v3.2.3 |
|
87 * @param aMediaProp media item. |
|
88 * @leave KErrArgument leave if not a supported media type |
|
89 */ |
|
90 IMPORT_C void AddItemL( CMPXMedia*& aMediaProp ); |
|
91 |
|
92 /** |
|
93 * Add a list of files to the collection db. |
|
94 * @since S60 v3.2.3 |
|
95 * @param aArray list of media item. |
|
96 * @leave KErrArgument leave if not a supported media type |
|
97 */ |
|
98 IMPORT_C void AddItemL( CMPXMediaArray& aMPArray ); |
|
99 |
|
100 /** |
|
101 * Updates the media properties of a file. |
|
102 * Used for media objects where the caller does not know |
|
103 * the collection for which the item should belong to. |
|
104 * @since S60 v3.2.3 |
|
105 * |
|
106 * @param aMediaProp media to update |
|
107 */ |
|
108 IMPORT_C void SetItemL( CMPXMedia*& aMediaProp ); |
|
109 |
|
110 /** |
|
111 * Updates media for a list of items. |
|
112 * Used for media objects where the caller does not know |
|
113 * the collection for which the item should belong to. |
|
114 * @since S60 v3.2.3 |
|
115 * |
|
116 * @param aMPArray list of media item |
|
117 */ |
|
118 IMPORT_C void SetItemL( CMPXMediaArray& aMPArray ); |
|
119 |
|
120 /** |
|
121 * Update media for items in the same collection depth. Not implemented. |
|
122 * @since S60 v3.2.3 |
|
123 * @param aArray list of items. |
|
124 * @param aPath collection path of the item. |
|
125 * @param aIndices list of indices |
|
126 */ |
|
127 IMPORT_C void SetItemL( TArray<CMPXMedia*>& aArray, |
|
128 CMPXCollectionPath& aPath, |
|
129 RArray<TInt>& aIndices ); |
|
130 |
|
131 /** |
|
132 * Static item to check if the collection id is correct. |
|
133 * Updates the collection path object to podcast if it is podcast. |
|
134 * @since S60 v3.2.3 |
|
135 * @param aMedia media object |
|
136 */ |
|
137 IMPORT_C void CheckItemL( CMPXMedia& aMedia ); |
|
138 |
|
139 /** |
|
140 * Moves an item from one collection to another. |
|
141 * Updates the media properties "genre" to Unknown |
|
142 * if moving from podcast -> local audio. |
|
143 * @since S60 v3.2.3 |
|
144 * @param aMedia, properties of the object. |
|
145 * @param aOldCollectionId old collection id. |
|
146 * @param aNewCollectionId new collection id |
|
147 */ |
|
148 IMPORT_C void MoveItemL( CMPXMedia*& aMedia, |
|
149 TUid aOldCollectionId, |
|
150 TUid aNewCollectionId ); |
|
151 |
|
152 /** |
|
153 * Moves an item from one collection to another. |
|
154 * Updates the media properties "genre" to Unknown |
|
155 * if moving from podcast -> local audio. |
|
156 * @since S60 v3.2.3 |
|
157 * @param aMedia properties of the object. |
|
158 * @param aOldCollectionId old collection id. |
|
159 * @param aNewCollectionId new collection id. |
|
160 * @param aObs observer for event |
|
161 */ |
|
162 IMPORT_C void MoveItemL( CMPXMedia*& aMedia, |
|
163 TUid aOldCollectionId, |
|
164 TUid aNewCollectionId, |
|
165 MMPXMoveItemObserver* aObs ); |
|
166 |
|
167 private: // New functions |
|
168 |
|
169 /** |
|
170 * Is this item recognizable as podcast. |
|
171 * @since S60 v3.2.3 |
|
172 * @param aMedia media object. |
|
173 * @return ETrue if the file is a podcast EFalse otherwise |
|
174 */ |
|
175 TBool IsPodcastL( CMPXMedia& aMedia ); |
|
176 |
|
177 /** |
|
178 * Change a collection id to the podcast db. |
|
179 * @since S60 v3.2.3 |
|
180 * @param aMedia media to update the collection id to podcast |
|
181 */ |
|
182 void UpdatePathToPodcastL( CMPXMedia& aMedia ); |
|
183 |
|
184 /** |
|
185 * Move a file from one db to another. |
|
186 * @since S60 v3.2.3 |
|
187 * @param aMedia media object. |
|
188 * @param aNewCollection new colection |
|
189 */ |
|
190 void DoMoveItemL( CMPXMedia*& aMedia, |
|
191 TUid aNewCollection ); |
|
192 |
|
193 /** |
|
194 * Add a file to the collection. |
|
195 * @since S60 v3.2.3 |
|
196 * @param aMedia media to add. |
|
197 * @param aCollectionID collection to add the item |
|
198 */ |
|
199 void DoAddToCollectionL( CMPXMedia* aMedia, |
|
200 TUid aCollectionId ); |
|
201 |
|
202 |
|
203 /** |
|
204 * Set a file to the collection. |
|
205 * @since S60 v3.2.3 |
|
206 * @param aMedia media to set. |
|
207 * @param aCollectionID collection to set the item |
|
208 */ |
|
209 void DoSetToCollectionL( CMPXMedia* aMedia, |
|
210 TUid aCollectionId ); |
|
211 |
|
212 private: |
|
213 |
|
214 /** |
|
215 * Private constructor. |
|
216 * @since S60 v3.2.3 |
|
217 * @param aColUtil collection utility to share with the owner. |
|
218 * @param aObs observer to mediator operations |
|
219 */ |
|
220 CMPXCollectionMediator( MMPXCollection& aColUtil, |
|
221 MMPXMediatorObserver* aObs ); |
|
222 |
|
223 /** |
|
224 * Private constructor. |
|
225 * @since S60 v3.2.3 |
|
226 */ |
|
227 CMPXCollectionMediator(); |
|
228 |
|
229 /** |
|
230 * 2nd phase constructor. |
|
231 * @since S60 v3.2.3 |
|
232 */ |
|
233 void ConstructL(); |
|
234 |
|
235 |
|
236 private: // data |
|
237 MMPXCollection* iColUtil; // collection util, not owned |
|
238 CMPXMoveItemHelper* iMoveHelper; // Move item helper |
|
239 MMPXMediatorObserver* iObserver; // Observer |
|
240 RFs iFs; // FsSession (owned) |
|
241 HBufC* iPodCastBuf; // Localized string |
|
242 HBufC* iPodCastEngBuf;// Podcast in english |
|
243 HBufC* iUnknownBuf; // Unknown text |
|
244 TUid iMusicCollectionID; // Music Collection ID |
|
245 TUid iPodCastCollectionID; // PodCast Collection ID |
|
246 }; |
|
247 |
|
248 |
|
249 #endif // CMPXCOLLECTIONMEDIATOR_H |