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