34
|
1 |
|
|
2 |
/*
|
|
3 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
* All rights reserved.
|
|
5 |
* This component and the accompanying materials are made available
|
|
6 |
* under the terms of "Eclipse Public License v1.0"
|
|
7 |
* which accompanies this distribution, and is available
|
|
8 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
9 |
*
|
|
10 |
* Initial Contributors:
|
|
11 |
* Nokia Corporation - initial contribution.
|
|
12 |
*
|
|
13 |
* Contributors:
|
|
14 |
*
|
|
15 |
* Description: Helper class for creating mediaobjects for testing VideoListDataModel class methods*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// INCLUDES
|
|
19 |
|
|
20 |
#include <mpxmediageneraldefs.h>
|
|
21 |
#include <mpxmediaarray.h>
|
|
22 |
#include <mpxmedia.h>
|
|
23 |
#include <qdatetime.h>
|
|
24 |
#include "vcxmyvideosdefs.h"
|
|
25 |
#include "mediaobjectfactory.h"
|
|
26 |
|
|
27 |
// -----------------------------------------------------------------------------
|
|
28 |
// MediaObjectFactory
|
|
29 |
// -----------------------------------------------------------------------------
|
|
30 |
//
|
|
31 |
MediaObjectFactory::MediaObjectFactory() :
|
|
32 |
mArray(0)
|
|
33 |
{
|
|
34 |
|
|
35 |
}
|
|
36 |
|
|
37 |
// -----------------------------------------------------------------------------
|
|
38 |
// ~MediaObjectFactory
|
|
39 |
// -----------------------------------------------------------------------------
|
|
40 |
//
|
|
41 |
MediaObjectFactory::~MediaObjectFactory()
|
|
42 |
{
|
|
43 |
removeArray();
|
|
44 |
}
|
|
45 |
|
|
46 |
// -----------------------------------------------------------------------------
|
|
47 |
// mediaArray
|
|
48 |
// -----------------------------------------------------------------------------
|
|
49 |
//
|
|
50 |
CMPXMediaArray* MediaObjectFactory::mediaArray()
|
|
51 |
{
|
|
52 |
return mArray;
|
|
53 |
}
|
|
54 |
|
|
55 |
// -----------------------------------------------------------------------------
|
|
56 |
// createMediaItems
|
|
57 |
// -----------------------------------------------------------------------------
|
|
58 |
//
|
|
59 |
void MediaObjectFactory::createMediaItems(int count, int mediaType, MediaDetailSelection flags)
|
|
60 |
{
|
|
61 |
if(!mArray)
|
|
62 |
{
|
|
63 |
TRAPD(error, mArray = CMPXMediaArray::NewL() )
|
|
64 |
if(!mArray)
|
|
65 |
{
|
|
66 |
return;
|
|
67 |
}
|
|
68 |
}
|
|
69 |
int nextPossibleIndex = mArray->Count();
|
|
70 |
|
|
71 |
// - create 10 media objects and add them into array
|
|
72 |
CMPXMedia *media;
|
|
73 |
|
|
74 |
|
|
75 |
for(int i = 0; i < count; ++i)
|
|
76 |
{
|
|
77 |
media = NULL;
|
|
78 |
TRAPD(error, media = CMPXMedia::NewL());
|
|
79 |
if(!media)
|
|
80 |
{
|
|
81 |
delete mArray;
|
|
82 |
mArray = 0;
|
|
83 |
return;
|
|
84 |
}
|
|
85 |
|
|
86 |
if(!fillMediaDatas(media, i, mediaType, flags))
|
|
87 |
{
|
|
88 |
delete media;
|
|
89 |
delete mArray;
|
|
90 |
mArray = 0;
|
|
91 |
return;
|
|
92 |
}
|
|
93 |
|
|
94 |
TRAP(error, mArray->AppendL(media));
|
|
95 |
if(error != KErrNone)
|
|
96 |
{
|
|
97 |
delete mArray;
|
|
98 |
mArray = 0;
|
|
99 |
return;
|
|
100 |
}
|
|
101 |
}
|
|
102 |
}
|
|
103 |
|
|
104 |
// -----------------------------------------------------------------------------
|
|
105 |
// fillMediaDatas
|
|
106 |
// -----------------------------------------------------------------------------
|
|
107 |
//
|
|
108 |
bool MediaObjectFactory::fillMediaDatas(CMPXMedia* media, int index, int mediaType, MediaDetailSelection detailSelectionFlag)
|
|
109 |
{
|
|
110 |
if(!media)
|
|
111 |
{
|
|
112 |
return false;
|
|
113 |
}
|
|
114 |
TBuf<65> videoname;
|
|
115 |
TMPXItemId itemId;
|
|
116 |
// set media id
|
|
117 |
itemId.iId1 = index;
|
|
118 |
itemId.iId2 = mediaType;
|
|
119 |
TRAPD(error, media->SetTObjectValueL<TMPXItemId>(KMPXMediaGeneralId, itemId));
|
|
120 |
if(error != KErrNone)
|
|
121 |
{
|
|
122 |
return false;
|
|
123 |
}
|
|
124 |
|
|
125 |
// set media name
|
|
126 |
videoname.Format(KMediaTestNamePrefix, index);
|
|
127 |
TRAP(error, media->SetTextValueL( KMPXMediaGeneralTitle, videoname));
|
|
128 |
if(error != KErrNone)
|
|
129 |
{
|
|
130 |
return false;
|
|
131 |
}
|
|
132 |
|
|
133 |
// set media rating
|
|
134 |
if(detailSelectionFlag & MediaDetailRatingFlag)
|
|
135 |
{
|
|
136 |
int rating = (index%5) +1;
|
|
137 |
TRAPD(error, media->SetTObjectValueL<TInt>(KVcxMediaMyVideosRating, rating));
|
|
138 |
if(error != KErrNone)
|
|
139 |
{
|
|
140 |
return false;
|
|
141 |
}
|
|
142 |
}
|
|
143 |
|
|
144 |
// set media date
|
|
145 |
if(detailSelectionFlag & MediaDetailDateFlag)
|
|
146 |
{
|
|
147 |
TDateTime dateTime;
|
|
148 |
dateTime.Set(2009, TMonth(index), index, index+1, index+1, index+1, index+1);
|
|
149 |
TTime ttimeDate(dateTime);
|
|
150 |
TInt64 temp= ttimeDate.Int64();
|
|
151 |
TRAPD(error, media->SetTObjectValueL<TInt64>(KMPXMediaGeneralDate, ttimeDate.Int64()));
|
|
152 |
if(error != KErrNone)
|
|
153 |
{
|
|
154 |
return false;
|
|
155 |
}
|
|
156 |
}
|
|
157 |
|
|
158 |
// set duration
|
|
159 |
if(detailSelectionFlag & MediaDetailDurationFlag)
|
|
160 |
{
|
|
161 |
float duration = 1.0 * index;
|
|
162 |
TRAPD(error, media->SetTObjectValueL<float>(KMPXMediaGeneralDuration, duration));
|
|
163 |
if(error != KErrNone)
|
|
164 |
{
|
|
165 |
return false;
|
|
166 |
}
|
|
167 |
}
|
|
168 |
|
|
169 |
// set size
|
|
170 |
if(detailSelectionFlag & MediaDetailSizeFlag)
|
|
171 |
{
|
|
172 |
quint32 size = 1.0 + index;
|
|
173 |
TRAPD(error, media->SetTObjectValueL<quint32>(KMPXMediaGeneralSize, size));
|
|
174 |
if(error != KErrNone)
|
|
175 |
{
|
|
176 |
return false;
|
|
177 |
}
|
|
178 |
}
|
36
|
179 |
|
34
|
180 |
// set file path
|
|
181 |
if(detailSelectionFlag & MediaDetailFilePathFlag)
|
|
182 |
{
|
|
183 |
videoname.Format(KMediaTestFilePathPrefix, index);
|
|
184 |
TRAP(error, media->SetTextValueL( KMPXMediaGeneralUri, videoname));
|
|
185 |
if(error != KErrNone)
|
|
186 |
{
|
|
187 |
return false;
|
|
188 |
}
|
|
189 |
}
|
|
190 |
|
35
|
191 |
// set video count
|
|
192 |
if(detailSelectionFlag & MediaDetailCategoryVideoCount)
|
|
193 |
{
|
36
|
194 |
int count = 10 + index;
|
35
|
195 |
TRAPD(error, media->SetTObjectValueL<quint32>(KVcxMediaMyVideosCategoryItemCount, count));
|
|
196 |
if(error != KErrNone)
|
|
197 |
{
|
|
198 |
return false;
|
|
199 |
}
|
|
200 |
}
|
|
201 |
|
34
|
202 |
return true;
|
|
203 |
|
|
204 |
}
|
|
205 |
|
|
206 |
// -----------------------------------------------------------------------------
|
|
207 |
// removeArray
|
|
208 |
// -----------------------------------------------------------------------------
|
|
209 |
//
|
|
210 |
void MediaObjectFactory::removeArray()
|
|
211 |
{
|
|
212 |
delete mArray;
|
|
213 |
mArray = 0;
|
|
214 |
}
|
|
215 |
|
|
216 |
// End of file
|
|
217 |
|
|
218 |
|
|
219 |
|