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