60
|
1 |
/*
|
|
2 |
* Copyright (c) 2008-2009 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: This class browses file system
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDE FILES
|
|
22 |
#include <e32cmn.h>
|
|
23 |
#include <mpxcollectionpath.h>
|
|
24 |
#include <mpxcollectionpluginobserver.h>
|
|
25 |
#include <mpxcmn.h>
|
|
26 |
#include <mpxcollectionmessagedefs.h>
|
|
27 |
#include <glxcollectionmessagedefs.h>
|
|
28 |
#include <mpxmediageneraldefs.h>
|
|
29 |
#include <mpxmediacontainerdefs.h>
|
|
30 |
#include <mpxmedia.h>
|
|
31 |
#include <mpxmediaarray.h>
|
|
32 |
#include <glxpluginalbums.rsg>
|
|
33 |
#include <StringLoader.h>
|
|
34 |
#include <glxtracer.h>
|
|
35 |
|
|
36 |
#include "glxcollectionpluginalbums.h"
|
|
37 |
#include "glxcollectionpluginalbums.hrh"
|
|
38 |
#include <glxmediageneraldefs.h>
|
|
39 |
#include <glxmediacollectioninternaldefs.h>
|
|
40 |
#include <glxcollectiongeneraldefs.h>
|
|
41 |
|
|
42 |
#include <glxpanic.h>
|
|
43 |
#include <mglxdatasource.h>
|
|
44 |
#include <glxrequest.h>
|
|
45 |
#include <glxidlistrequest.h>
|
|
46 |
#include <glxfilterfactory.h>
|
|
47 |
#include <glxlog.h>
|
|
48 |
|
|
49 |
// CONSTANTS
|
|
50 |
const TInt KFavoriteAlbumId = 1 ;
|
|
51 |
const TInt KCapturedAlbumId = 2 ;
|
|
52 |
|
|
53 |
|
|
54 |
/**
|
|
55 |
* @internal reviewed 14/06/2007 by Alex Birkett
|
|
56 |
*/
|
|
57 |
|
|
58 |
|
|
59 |
// ============================ LOCAL FUNCTIONS ==============================
|
|
60 |
|
|
61 |
// ============================ MEMBER FUNCTIONS ==============================
|
|
62 |
// ----------------------------------------------------------------------------
|
|
63 |
// Two-phased constructor.
|
|
64 |
// ----------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
CGlxCollectionPluginAlbums* CGlxCollectionPluginAlbums::NewL(TAny* aObs)
|
|
67 |
{
|
|
68 |
CGlxCollectionPluginAlbums* self = new (ELeave) CGlxCollectionPluginAlbums(
|
|
69 |
static_cast<MMPXCollectionPluginObserver*>(aObs));
|
|
70 |
CleanupStack::PushL(self);
|
|
71 |
self->ConstructL();
|
|
72 |
CleanupStack::Pop(self);
|
|
73 |
return self;
|
|
74 |
}
|
|
75 |
|
|
76 |
// ----------------------------------------------------------------------------
|
|
77 |
// Destructor
|
|
78 |
// ----------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
CGlxCollectionPluginAlbums::~CGlxCollectionPluginAlbums()
|
|
81 |
{
|
|
82 |
}
|
|
83 |
|
|
84 |
// ----------------------------------------------------------------------------
|
|
85 |
// Constructor
|
|
86 |
// ----------------------------------------------------------------------------
|
|
87 |
//
|
|
88 |
CGlxCollectionPluginAlbums::CGlxCollectionPluginAlbums(
|
|
89 |
MMPXCollectionPluginObserver* aObs)
|
|
90 |
{
|
|
91 |
iObs = aObs;
|
|
92 |
}
|
|
93 |
|
|
94 |
// ----------------------------------------------------------------------------
|
|
95 |
// ConstructL
|
|
96 |
// ----------------------------------------------------------------------------
|
|
97 |
//
|
|
98 |
void CGlxCollectionPluginAlbums::ConstructL()
|
|
99 |
{
|
|
100 |
iDataSource = MGlxDataSource::OpenDataSourceL(KGlxDefaultDataSourceUid, *this);
|
|
101 |
}
|
|
102 |
|
|
103 |
void CGlxCollectionPluginAlbums::CpiAttributeAdditionalAttributesL(
|
|
104 |
const TMPXAttribute& aCpiAttribute,
|
|
105 |
RArray<TMPXAttribute>& aAttributeArray)
|
|
106 |
{
|
|
107 |
TRACER("CGlxCollectionPluginAlbums::CpiAttributeAdditionalAttributesL");
|
|
108 |
// Only need to process KGlxMediaCollectionPluginSpecificSubTitle here
|
|
109 |
// as all the others are reading straight from resource files
|
|
110 |
// KGlxMediaCollectionPluginSpecificSubTitle requires a usage count
|
|
111 |
if (aCpiAttribute == KGlxMediaCollectionPluginSpecificSubTitle)
|
|
112 |
{
|
|
113 |
// need to add the usage count. but check first if it is already present
|
|
114 |
TInt attrCount = aAttributeArray.Count();
|
|
115 |
TBool found = EFalse;
|
|
116 |
|
|
117 |
for (TInt index = 0; index < attrCount; index++)
|
|
118 |
{
|
|
119 |
if (aAttributeArray[index] == KMPXMediaGeneralCount)
|
|
120 |
{
|
|
121 |
found = ETrue;
|
|
122 |
break;
|
|
123 |
}
|
|
124 |
}
|
|
125 |
|
|
126 |
if (!found)
|
|
127 |
{
|
|
128 |
aAttributeArray.AppendL(KGlxMediaCollectionInternalUsageCount);
|
|
129 |
}
|
|
130 |
}
|
|
131 |
}
|
|
132 |
void CGlxCollectionPluginAlbums::HandleCpiAttributeResponseL(
|
|
133 |
CMPXMedia* aResponse, TArray<TMPXAttribute> aCpiAttributes,
|
|
134 |
TArray<TGlxMediaId> aMediaIds)
|
|
135 |
{
|
|
136 |
TRACER("CGlxCollectionPluginAlbums::HandleCpiAttributeResponseL");
|
|
137 |
const TInt mediaIdCount = aMediaIds.Count();
|
|
138 |
|
|
139 |
switch (mediaIdCount)
|
|
140 |
{
|
|
141 |
case 0:
|
|
142 |
User::Leave(KErrNotSupported);
|
|
143 |
break;
|
|
144 |
case 1:
|
|
145 |
HandleCpiAttributeResponseL(aResponse, aCpiAttributes,
|
|
146 |
aMediaIds[0]);
|
|
147 |
break;
|
|
148 |
default:
|
|
149 |
{
|
|
150 |
// We have an array of CMPXMedia items
|
|
151 |
|
|
152 |
if (TGlxMediaId(KGlxCollectionRootId) == aMediaIds[0])
|
|
153 |
{
|
|
154 |
User::Leave(KErrNotSupported);
|
|
155 |
}
|
|
156 |
|
|
157 |
CMPXMediaArray* mediaArray = aResponse->ValueCObjectL<
|
|
158 |
CMPXMediaArray> (KMPXMediaArrayContents);
|
|
159 |
CleanupStack::PushL(mediaArray);
|
|
160 |
|
|
161 |
const TInt arrayCount = mediaArray->Count();
|
|
162 |
|
|
163 |
// Sanity check
|
|
164 |
if (arrayCount != mediaIdCount)
|
|
165 |
{
|
|
166 |
User::Leave(KErrArgument);
|
|
167 |
}
|
|
168 |
|
|
169 |
for (TInt index = 0; index < arrayCount; index++)
|
|
170 |
{
|
|
171 |
HandleCpiAttributeResponseL((*mediaArray)[index],
|
|
172 |
aCpiAttributes, aMediaIds[index]);
|
|
173 |
}
|
|
174 |
|
|
175 |
aResponse->SetCObjectValueL(KMPXMediaArrayContents, mediaArray);
|
|
176 |
CleanupStack::PopAndDestroy(mediaArray);
|
|
177 |
}
|
|
178 |
break;
|
|
179 |
}
|
|
180 |
}
|
|
181 |
|
|
182 |
void CGlxCollectionPluginAlbums::HandleCpiAttributeResponseL(
|
|
183 |
CMPXMedia* aResponse, TArray<TMPXAttribute> aCpiAttributes,
|
|
184 |
TGlxMediaId aMediaId)
|
|
185 |
{
|
|
186 |
_LIT(KResourceFile, "z:glxpluginalbums.rsc");
|
|
187 |
|
|
188 |
const TInt attribCount = aCpiAttributes.Count();
|
|
189 |
|
|
190 |
for (TInt index = 0; index < attribCount; index++)
|
|
191 |
{
|
|
192 |
const TMPXAttribute attr = aCpiAttributes[index];
|
|
193 |
|
|
194 |
if (attr == KGlxMediaCollectionPluginSpecificSubTitle)
|
|
195 |
{
|
|
196 |
TInt usageCount = 0;
|
|
197 |
if (aResponse->IsSupported(KMPXMediaGeneralCount))
|
|
198 |
{
|
|
199 |
usageCount = aResponse->ValueTObjectL<TInt> (
|
|
200 |
KMPXMediaGeneralCount);
|
|
201 |
}
|
|
202 |
else if (aResponse->IsSupported(
|
|
203 |
KGlxMediaCollectionInternalUsageCount))
|
|
204 |
{
|
|
205 |
usageCount = aResponse->ValueTObjectL<TInt> (
|
|
206 |
KGlxMediaCollectionInternalUsageCount);
|
|
207 |
aResponse->Delete(KGlxMediaCollectionInternalUsageCount);
|
|
208 |
}
|
|
209 |
else
|
|
210 |
{
|
|
211 |
User::Leave(KErrNotSupported);
|
|
212 |
}
|
|
213 |
HBufC* tempTitle = NULL;
|
|
214 |
|
|
215 |
if (TGlxMediaId(KGlxCollectionRootId) == aMediaId)
|
|
216 |
{
|
|
217 |
if (1 == usageCount)
|
|
218 |
{
|
|
219 |
tempTitle = LoadLocalizedStringLC(KResourceFile,
|
|
220 |
R_ALBUM_SUB_TITLE_SINGLE);
|
|
221 |
aResponse->SetTextValueL(attr, *tempTitle);
|
|
222 |
CleanupStack::PopAndDestroy(tempTitle);
|
|
223 |
continue;
|
|
224 |
}
|
|
225 |
else
|
|
226 |
{
|
|
227 |
tempTitle = LoadLocalizedStringLC(KResourceFile,
|
|
228 |
R_ALBUM_SUB_TITLE_MULTI);
|
|
229 |
}
|
|
230 |
}
|
|
231 |
else
|
|
232 |
{
|
|
233 |
if (0 == usageCount)
|
|
234 |
{
|
|
235 |
tempTitle = LoadLocalizedStringLC(KResourceFile,
|
|
236 |
R_ALBUM_ITEM_SUB_TITLE_EMPTY);
|
|
237 |
|
|
238 |
// Set the title in the response.
|
|
239 |
aResponse->SetTextValueL(attr, *tempTitle);
|
|
240 |
CleanupStack::PopAndDestroy(tempTitle);
|
|
241 |
|
|
242 |
// Set the count in the response.
|
|
243 |
aResponse->SetTObjectValueL(KMPXMediaGeneralCount,
|
|
244 |
usageCount);
|
|
245 |
|
|
246 |
continue;
|
|
247 |
}
|
|
248 |
else if (1 == usageCount)
|
|
249 |
{
|
|
250 |
tempTitle = LoadLocalizedStringLC(KResourceFile,
|
|
251 |
R_ALBUM_ITEM_SUB_TITLE_SINGLE);
|
|
252 |
aResponse->SetTextValueL(attr, *tempTitle);
|
|
253 |
CleanupStack::PopAndDestroy(tempTitle);
|
|
254 |
|
|
255 |
// Set the count in the response.
|
|
256 |
aResponse->SetTObjectValueL(KMPXMediaGeneralCount,
|
|
257 |
usageCount);
|
|
258 |
|
|
259 |
continue;
|
|
260 |
}
|
|
261 |
else
|
|
262 |
{
|
|
263 |
tempTitle = LoadLocalizedStringLC(KResourceFile,
|
|
264 |
R_ALBUM_ITEM_SUB_TITLE_MULTI);
|
|
265 |
}
|
|
266 |
}
|
|
267 |
|
|
268 |
TPtr formatString = tempTitle->Des();
|
|
269 |
|
|
270 |
// Now create a buffer that will contain the result. needs to be
|
|
271 |
// length of format string plus a few extra for the number
|
|
272 |
HBufC* title = HBufC::NewLC(formatString.Length() + 10);
|
|
273 |
TPtr ptr = title->Des();
|
|
274 |
StringLoader::Format(ptr, formatString, -1, usageCount);
|
|
275 |
|
|
276 |
// Set the title in the response.
|
|
277 |
aResponse->SetTextValueL(attr, *title);
|
|
278 |
|
|
279 |
// Set the count in the response.
|
|
280 |
aResponse->SetTObjectValueL(KMPXMediaGeneralCount, usageCount);
|
|
281 |
|
|
282 |
CleanupStack::PopAndDestroy(title);
|
|
283 |
CleanupStack::PopAndDestroy(tempTitle);
|
|
284 |
}
|
|
285 |
else if (attr
|
|
286 |
== KGlxMediaCollectionPluginSpecificSelectMediaPopupTitle)
|
|
287 |
{
|
|
288 |
HBufC* title = LoadLocalizedStringLC(KResourceFile,
|
|
289 |
R_ALBUM_POPUP_TITLE);
|
|
290 |
aResponse->SetTextValueL(attr, *title);
|
|
291 |
CleanupStack::PopAndDestroy(title);
|
|
292 |
}
|
|
293 |
else if (attr == KGlxMediaCollectionPluginSpecificNewMediaItemTitle)
|
|
294 |
{
|
|
295 |
HBufC* title = LoadLocalizedStringLC(KResourceFile,
|
|
296 |
R_ALBUM_ITEM_TITLE);
|
|
297 |
aResponse->SetTextValueL(attr, *title);
|
|
298 |
CleanupStack::PopAndDestroy(title);
|
|
299 |
}
|
|
300 |
else if (attr == KGlxMediaCollectionPluginSpecificDefaultMediaTitle)
|
|
301 |
{
|
|
302 |
HBufC* title = LoadLocalizedStringLC(KResourceFile,
|
|
303 |
R_ALBUM_DEFAULT_TITLE);
|
|
304 |
aResponse->SetTextValueL(attr, *title);
|
|
305 |
CleanupStack::PopAndDestroy(title);
|
|
306 |
}
|
|
307 |
else if (attr == KMPXMediaGeneralTitle)
|
|
308 |
{
|
|
309 |
if (TGlxMediaId(KGlxCollectionRootId) == aMediaId)
|
|
310 |
{
|
|
311 |
HBufC* title = LoadLocalizedStringLC(KResourceFile,
|
|
312 |
R_ALBUM_GENERAL_TITLE);
|
|
313 |
aResponse->SetTextValueL(attr, *title);
|
|
314 |
CleanupStack::PopAndDestroy(title);
|
|
315 |
}
|
|
316 |
else
|
|
317 |
{
|
|
318 |
if (aResponse->IsSupported(
|
|
319 |
KGlxMediaCollectionInternalSystemItemType))
|
|
320 |
{
|
|
321 |
TGlxMediaId responseMediaid(
|
|
322 |
(TUint32) aResponse->ValueTObjectL<TMPXItemId> (
|
|
323 |
KMPXMediaGeneralId));
|
|
324 |
// Set the text value based on the Media ID in aResponse
|
|
325 |
if (TGlxMediaId(KCapturedAlbumId) == responseMediaid)
|
|
326 |
{
|
|
327 |
HBufC* title = LoadLocalizedStringLC(KResourceFile,
|
|
328 |
R_ALBUM_CAMERA_TITLE);
|
|
329 |
aResponse->SetTextValueL(attr, *title);
|
|
330 |
CleanupStack::PopAndDestroy(title);
|
|
331 |
}
|
|
332 |
else if (TGlxMediaId(KFavoriteAlbumId) == responseMediaid)
|
|
333 |
{
|
|
334 |
HBufC* title = LoadLocalizedStringLC(KResourceFile,
|
|
335 |
R_ALBUM_FAVORITES_TITLE);
|
|
336 |
aResponse->SetTextValueL(attr, *title);
|
|
337 |
CleanupStack::PopAndDestroy(title);
|
|
338 |
}
|
|
339 |
}
|
|
340 |
aResponse->Delete(KGlxMediaCollectionInternalSystemItemType);
|
|
341 |
}
|
|
342 |
}
|
|
343 |
}
|
|
344 |
}
|
|
345 |
|
|
346 |
TBool CGlxCollectionPluginAlbums::IsUpdateMessageIgnored(CMPXMessage& /*aMessage*/)
|
|
347 |
{
|
|
348 |
TBool ignore = EFalse;
|
|
349 |
return ignore;
|
|
350 |
}
|
|
351 |
|
|
352 |
TGlxFilterProperties CGlxCollectionPluginAlbums::DefaultFilter(TInt aLevel)
|
|
353 |
{
|
|
354 |
__ASSERT_DEBUG(( (aLevel == KGlxCollectionRootLevel) || (aLevel == KGlxCollectionAlbumLevel)
|
|
355 |
|| (aLevel == KGlxCollectionAlbumContentsLevel) || (aLevel == KGlxCollectionAlbumContentsFSLevel)),
|
|
356 |
Panic(EGlxPanicInvalidPathLevel));
|
|
357 |
TGlxFilterProperties filterProperties;
|
|
358 |
filterProperties.iSortDirection = EGlxFilterSortDirectionAscending;
|
|
359 |
switch(aLevel)
|
|
360 |
{
|
|
361 |
case KGlxCollectionRootLevel:
|
|
362 |
case KGlxCollectionAlbumLevel:
|
|
363 |
{
|
|
364 |
filterProperties.iPromoteSystemItems = ETrue;
|
|
365 |
filterProperties.iSortOrder = EGlxFilterSortOrderAlphabetical;
|
|
366 |
filterProperties.iItemType = EGlxFilterAlbum;
|
|
367 |
break;
|
|
368 |
}
|
|
369 |
case KGlxCollectionAlbumContentsLevel:
|
|
370 |
{
|
|
371 |
filterProperties.iSortDirection = EGlxFilterSortDirectionDescending;
|
|
372 |
}
|
|
373 |
case KGlxCollectionAlbumContentsFSLevel:
|
|
374 |
{
|
|
375 |
filterProperties.iSortOrder = EGlxFilterSortOrderCaptureDate;
|
|
376 |
break;
|
|
377 |
}
|
|
378 |
}
|
|
379 |
return filterProperties;
|
|
380 |
}
|
|
381 |
|