|
57
|
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:
|
|
|
15 |
*
|
|
|
16 |
*/
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
#ifndef VCXMYVIDEOSCOLLECTIONUTIL_H
|
|
|
22 |
#define VCXMYVIDEOSCOLLECTIONUTIL_H
|
|
|
23 |
|
|
|
24 |
// INCLUDES
|
|
|
25 |
#include <vcxmyvideosdefs.h>
|
|
|
26 |
|
|
|
27 |
// FORWARD DECLARATIONS
|
|
|
28 |
class CMPXMedia;
|
|
|
29 |
class RFs;
|
|
|
30 |
|
|
|
31 |
#include "myvideostesttrap.h"
|
|
|
32 |
|
|
|
33 |
// CONSTANTS
|
|
|
34 |
|
|
|
35 |
// CLASS DECLARATION
|
|
|
36 |
|
|
|
37 |
/**
|
|
|
38 |
* Util functions.
|
|
|
39 |
*
|
|
|
40 |
* @lib mpxmyvideoscollectionplugin.lib
|
|
|
41 |
*/
|
|
|
42 |
NONSHARABLE_CLASS(TVcxMyVideosCollectionUtil)
|
|
|
43 |
{
|
|
|
44 |
public:
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
* Creates media container and sets up empty media array to it.
|
|
|
48 |
*
|
|
|
49 |
* @return CMPXMedia media list.
|
|
|
50 |
*/
|
|
|
51 |
static CMPXMedia* CreateEmptyMediaListL();
|
|
|
52 |
|
|
|
53 |
/**
|
|
|
54 |
* Creates message list and sets up empty message array to it.
|
|
|
55 |
*
|
|
|
56 |
* @return CMPXMessage message list.
|
|
|
57 |
*/
|
|
|
58 |
static CMPXMedia* CreateEmptyMessageListL();
|
|
|
59 |
|
|
|
60 |
/**
|
|
|
61 |
* Tries to find aMdsIds from aFromList and if found, copies them
|
|
|
62 |
* to aToList. KMPXMediaArrayContents arrays must be set for aFromList
|
|
|
63 |
* and aToList, othewise leave (KErrArgument) occurs.
|
|
|
64 |
*
|
|
|
65 |
* @param aFromList Items are copied from here.
|
|
|
66 |
* @param aToList Items are copied here.
|
|
|
67 |
* @param aMdsIds Item IDs which are copied.
|
|
|
68 |
*/
|
|
|
69 |
static void CopyFromListToListL(
|
|
|
70 |
CMPXMedia& aFromList,
|
|
|
71 |
CMPXMedia& aToList,
|
|
|
72 |
RArray<TUint32>& aMdsIds );
|
|
|
73 |
|
|
|
74 |
/**
|
|
|
75 |
* Tries to find aMdsIds from aFromArray and if found, copies them
|
|
|
76 |
* to aToList. KMPXMediaArrayContents arrays must be set for aToList,
|
|
|
77 |
* othewise leave (KErrArgument) occurs.
|
|
|
78 |
*
|
|
|
79 |
* @param aFromArray Items are copied from here.
|
|
|
80 |
* @param aToList Items are copied here.
|
|
|
81 |
* @param aMdsIds Item IDs which are copied.
|
|
|
82 |
*/
|
|
|
83 |
static void CopyFromListToListL(
|
|
|
84 |
RArray<CMPXMedia*>& aFromArray,
|
|
|
85 |
CMPXMedia& aToList,
|
|
|
86 |
RArray<TUint32>& aMdsIds );
|
|
|
87 |
|
|
|
88 |
/**
|
|
|
89 |
* Appends all items from aFromList to aToList. New items will point to
|
|
|
90 |
* same shared memory.
|
|
|
91 |
*
|
|
|
92 |
* @param aToList List in which items are appended to.
|
|
|
93 |
* @param aFromList List in which items are copied from.
|
|
|
94 |
*/
|
|
|
95 |
static void AppendToListL( CMPXMedia& aToList, CMPXMedia& aFromList );
|
|
|
96 |
|
|
|
97 |
/**
|
|
|
98 |
* Converts drive letter to drive number.
|
|
|
99 |
*
|
|
|
100 |
* @param aDrive drive letter
|
|
|
101 |
* @return drive number
|
|
|
102 |
*/
|
|
|
103 |
static TInt DriveLetter2DriveNumber( const TDesC &aDrive );
|
|
|
104 |
|
|
|
105 |
/**
|
|
|
106 |
* Checks that file system does not have aPath file already, if it does
|
|
|
107 |
* then the aPath is changed to unique by adding digits to it. Result
|
|
|
108 |
* is stored to aUniquePath, (event if it is the same as aPath).
|
|
|
109 |
*
|
|
|
110 |
* @param aFs Open session to file server.
|
|
|
111 |
* @param aPath File name to make unique.
|
|
|
112 |
* @param aUniquePath Generated unique path.
|
|
|
113 |
*/
|
|
|
114 |
static void MakeUniqueFileNameL( RFs& aFs, const TDesC& aPath, TDes& aUniquePath );
|
|
|
115 |
|
|
|
116 |
/**
|
|
|
117 |
* Gets KVcxMediaMyVideosOrigin attribute of aVideo.
|
|
|
118 |
*
|
|
|
119 |
* @param aVideo Media object to fetch parameter from.
|
|
|
120 |
* @return Origin, see values from TVcxMyVideosOrigin in vcxmyvideosdefs.h
|
|
|
121 |
*/
|
|
|
122 |
static TUint8 OriginL( CMPXMedia& aVideo );
|
|
|
123 |
|
|
|
124 |
/**
|
|
|
125 |
* Gets KMPXMediaGeneralFlags attribute of aVideo.
|
|
|
126 |
*
|
|
|
127 |
* @param aVideo Media object to fetch parameter from.
|
|
|
128 |
* @return Flags, see values from TVcxMyVideosVideoFlags in vcxmyvideosdefs.h
|
|
|
129 |
*/
|
|
|
130 |
static TUint32 FlagsL( CMPXMedia& aVideo );
|
|
|
131 |
|
|
|
132 |
/**
|
|
|
133 |
* Gets KMPXMediaGeneralDate (creation date) of aVideo.
|
|
|
134 |
*
|
|
|
135 |
* @param aVideo Media object to fetch parameter from.
|
|
|
136 |
* @return Creation date, works with TTime.
|
|
|
137 |
*/
|
|
|
138 |
static TInt64 CreationDateL( CMPXMedia& aVideo );
|
|
|
139 |
|
|
|
140 |
/**
|
|
|
141 |
* Gets KVcxMediaMyVideosDownloadId attribute of aVideo.
|
|
|
142 |
*
|
|
|
143 |
* @param aVideo Media object to fetch parameter from.
|
|
|
144 |
* @return Download ID in Download Manager.
|
|
|
145 |
*/
|
|
|
146 |
static TUint32 DownloadIdL( CMPXMedia& aVideo );
|
|
|
147 |
|
|
|
148 |
/**
|
|
|
149 |
* Gets KVcxMediaMyVideosDownloadState attribute of aVideo.
|
|
|
150 |
*
|
|
|
151 |
* @param aVideo Media object to fetch parameter from.
|
|
|
152 |
* @return Download state.
|
|
|
153 |
*/
|
|
|
154 |
static TVcxMyVideosDownloadState DownloadStateL( CMPXMedia& aVideo );
|
|
|
155 |
|
|
|
156 |
/**
|
|
|
157 |
* Gets KMPXMediaGeneralId attribute of aVideo.
|
|
|
158 |
*
|
|
|
159 |
* @param aVideo Media object to fetch parameter from.
|
|
|
160 |
* @return ID.
|
|
|
161 |
*/
|
|
|
162 |
static TMPXItemId IdL( const CMPXMedia& aVideo );
|
|
|
163 |
|
|
|
164 |
/**
|
|
|
165 |
* Gets KVcxMediaMyVideosDuration attribute of aVideo.
|
|
|
166 |
*
|
|
|
167 |
* @param aVideo Media object to fetch parameter from.
|
|
|
168 |
* @return Duration.
|
|
|
169 |
*/
|
|
|
170 |
static TReal32 DurationL( CMPXMedia& aVideo );
|
|
|
171 |
|
|
|
172 |
/**
|
|
|
173 |
* Gets KMPXMediaGeneralTitle attribute of the video.
|
|
|
174 |
*
|
|
|
175 |
* @return KMPXMediaGeneralTitle value. If attribute is not supported,
|
|
|
176 |
* then KNullDesC is returned.
|
|
|
177 |
*/
|
|
|
178 |
static const TDesC& Title( const CMPXMedia& aVideo );
|
|
|
179 |
|
|
|
180 |
/**
|
|
|
181 |
* Gets KVcxMediaMyVideosRating attribute of the video.
|
|
|
182 |
*
|
|
|
183 |
* @param aVideo Media object to fetch parameter from.
|
|
|
184 |
* @return KVcxMediaMyVideosRating value. If attribute is not supported,
|
|
|
185 |
* then 0 is returned.
|
|
|
186 |
*/
|
|
|
187 |
static TUint8 RatingL( CMPXMedia& aVideo );
|
|
|
188 |
|
|
|
189 |
/**
|
|
|
190 |
* Gets KVcxMediaMyAudioFourCc attribute of the video.
|
|
|
191 |
*
|
|
|
192 |
* @param aVideo Media object to fetch parameter from.
|
|
|
193 |
* @return KVcxMediaMyAudioFourCc value. If attribute is not supported,
|
|
|
194 |
* then 0 is returned.
|
|
|
195 |
*/
|
|
|
196 |
static TUint32 AudioFourCcL( CMPXMedia& aVideo );
|
|
|
197 |
|
|
|
198 |
/**
|
|
|
199 |
* Checks if aAttrs contains attributes which are not supported in aVideo.
|
|
|
200 |
*
|
|
|
201 |
* @param aVideo Attributes to check from.
|
|
|
202 |
* @param aAttrs Attributes to check.
|
|
|
203 |
* @param aNonSupportedAttrCanBeFoundFromMds Set to ETrue if at least one of non supported
|
|
|
204 |
* attributes can be found from MDS.
|
|
|
205 |
* @return ETrue if all aAttrs attributes are supported in aVideo, EFalse
|
|
|
206 |
* otherwise.
|
|
|
207 |
*/
|
|
|
208 |
static TBool AreSupported( CMPXMedia& aVideo, const TArray<TMPXAttribute>& aAttrs,
|
|
|
209 |
TBool& aNonSupportedAttrCanBeFoundFromMds );
|
|
|
210 |
|
|
|
211 |
/**
|
|
|
212 |
* Checks if aAttrs belongs to "full" set of parameters which is saved to MDS but not
|
|
|
213 |
* cached by collection.
|
|
|
214 |
*
|
|
|
215 |
* @param aAttr Attribute to check.
|
|
|
216 |
* @return ETrue if aAttr belongs to full set and can be found from MDS, EFalse
|
|
|
217 |
* otherwise.
|
|
|
218 |
*/
|
|
|
219 |
static TBool AttrBelongsToFullSet( const TMPXAttribute& aAttr );
|
|
|
220 |
|
|
|
221 |
/**
|
|
|
222 |
* Converts collection category ID to origin.
|
|
|
223 |
*
|
|
|
224 |
* @param aCategoryId Category ID
|
|
|
225 |
* @return Returns Origin or KErrNotFound if not found. KVcxMvcCategoryIdAll
|
|
|
226 |
* returns also KErrNotFound.
|
|
|
227 |
*/
|
|
|
228 |
static TInt Origin( TInt aCategoryId );
|
|
|
229 |
|
|
|
230 |
/**
|
|
|
231 |
* Gets KMPXMediaArrayContents attribute from aMedia. Leaves
|
|
|
232 |
* with KErrArgument is attribute is not supported.
|
|
|
233 |
*
|
|
|
234 |
* @param aMedia Media where from the attribute is fetched.
|
|
|
235 |
* @return Pointer to media array.
|
|
|
236 |
*/
|
|
|
237 |
static CMPXMediaArray* MediaArrayL( const CMPXMedia& aMedia );
|
|
|
238 |
|
|
|
239 |
/**
|
|
|
240 |
* Gets KVcxMediaMyVideosInt32Value attribute from aMedia. Leaves
|
|
|
241 |
* with KErrArgument if attribute is not supported.
|
|
|
242 |
*
|
|
|
243 |
* @param aMedia Media where from the attribute is fetched.
|
|
|
244 |
* @return Value of KVcxMediaMyVideosInt32Value attribute.
|
|
|
245 |
*/
|
|
|
246 |
static TInt32 Int32ValueL( CMPXMedia& aMedia );
|
|
|
247 |
|
|
|
248 |
/**
|
|
|
249 |
* Gets KVcxMediaMyVideosUint32Value attribute from aMedia. Leaves
|
|
|
250 |
* with KErrArgument if attribute is not supported.
|
|
|
251 |
*
|
|
|
252 |
* @param aMedia Media where from the attribute is fetched.
|
|
|
253 |
* @return Value of KVcxMediaMyVideosUint32Value attribute.
|
|
|
254 |
*/
|
|
|
255 |
static TUint32 Uint32ValueL( CMPXMedia& aMedia );
|
|
|
256 |
|
|
|
257 |
/**
|
|
|
258 |
* Gets KMPXMediaGeneralId attributes from aMediaArray and
|
|
|
259 |
* puts them to aIdArray. aIdArray is reset before adding.
|
|
|
260 |
*
|
|
|
261 |
* @param aMediaArray Media array containing media items which
|
|
|
262 |
* have KMPXMediaGeneralId attribute set.
|
|
|
263 |
* @param aIdArray Array where to the IDs are written to.
|
|
|
264 |
*/
|
|
|
265 |
static void GetIdsFromMediaArrayL( CMPXMediaArray& aMediaArray,
|
|
|
266 |
RArray<TUint32>& aIdArray );
|
|
|
267 |
|
|
|
268 |
#ifdef _DEBUG
|
|
|
269 |
/**
|
|
|
270 |
* Prints process names which have file handle open to aFileName
|
|
|
271 |
*
|
|
|
272 |
* @param aFileName File to check for open file handles.
|
|
|
273 |
*/
|
|
|
274 |
static void PrintOpenFileHandlesL( const TDesC& aFileName, RFs& aFs );
|
|
|
275 |
|
|
|
276 |
/**
|
|
|
277 |
* Gets process name.
|
|
|
278 |
*
|
|
|
279 |
* @param aThreadId Thread ID
|
|
|
280 |
* @param aProcessName Upon completion process name is written here.
|
|
|
281 |
*/
|
|
|
282 |
static void GetProcessName( TInt aThreadId, TFullName& aProcessName );
|
|
|
283 |
|
|
|
284 |
private:
|
|
|
285 |
TBuf<500> iProcessName;
|
|
|
286 |
#endif
|
|
|
287 |
};
|
|
|
288 |
#endif // VCXMYVIDEOSCOLLECTIONUTIL_H
|
|
|
289 |
|
|
|
290 |
|