|
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 // INCLUDE FILES |
|
21 |
|
22 #include "glxcollectionpluginmonths.h" |
|
23 |
|
24 #include <e32cmn.h> |
|
25 #include <mpxcollectionpath.h> |
|
26 #include <mpxcollectionpluginobserver.h> |
|
27 #include <mpxcmn.h> |
|
28 #include <mpxmediageneraldefs.h> |
|
29 #include <mpxmediacontainerdefs.h> |
|
30 #include <mpxmedia.h> |
|
31 #include <mpxmediaarray.h> |
|
32 #include <glxmediacollectioninternaldefs.h> |
|
33 #include <glxmediageneraldefs.h> |
|
34 #include <glxcollectiongeneraldefs.h> |
|
35 #include <glxpluginmonths.rsg> |
|
36 #include <StringLoader.h> |
|
37 #include <glxpanic.h> |
|
38 #include <mglxdatasource.h> |
|
39 #include <glxrequest.h> |
|
40 #include <glxidlistrequest.h> |
|
41 #include <glxlog.h> |
|
42 #include <glxtracer.h> |
|
43 |
|
44 #include "glxcollectionpluginmonths.hrh" |
|
45 /** |
|
46 * @internal reviewed 14/06/2007 by Alex Birkett |
|
47 */ |
|
48 // CONSTANTS |
|
49 |
|
50 // ============================ LOCAL FUNCTIONS ============================== |
|
51 |
|
52 // ============================ MEMBER FUNCTIONS ============================== |
|
53 // ---------------------------------------------------------------------------- |
|
54 // Two-phased constructor. |
|
55 // ---------------------------------------------------------------------------- |
|
56 // |
|
57 CGlxCollectionPluginMonths* CGlxCollectionPluginMonths::NewL(TAny* aObs) |
|
58 { |
|
59 CGlxCollectionPluginMonths* self = new (ELeave) CGlxCollectionPluginMonths( |
|
60 static_cast<MMPXCollectionPluginObserver*>(aObs)); |
|
61 CleanupStack::PushL(self); |
|
62 self->ConstructL(); |
|
63 CleanupStack::Pop(self); |
|
64 return self; |
|
65 } |
|
66 |
|
67 // ---------------------------------------------------------------------------- |
|
68 // Destructor |
|
69 // ---------------------------------------------------------------------------- |
|
70 // |
|
71 CGlxCollectionPluginMonths::~CGlxCollectionPluginMonths() |
|
72 { |
|
73 } |
|
74 |
|
75 // ---------------------------------------------------------------------------- |
|
76 // Constructor |
|
77 // ---------------------------------------------------------------------------- |
|
78 // |
|
79 CGlxCollectionPluginMonths::CGlxCollectionPluginMonths( |
|
80 MMPXCollectionPluginObserver* aObs) |
|
81 { |
|
82 iObs = aObs; |
|
83 } |
|
84 |
|
85 // ---------------------------------------------------------------------------- |
|
86 // ConstructL |
|
87 // ---------------------------------------------------------------------------- |
|
88 // |
|
89 void CGlxCollectionPluginMonths::ConstructL() |
|
90 { |
|
91 iDataSource = MGlxDataSource::OpenDataSourceL(KGlxDefaultDataSourceUid, *this); |
|
92 } |
|
93 |
|
94 |
|
95 // ---------------------------------------------------------------------------- |
|
96 // CpiAttributeAdditionalAttributes |
|
97 // ---------------------------------------------------------------------------- |
|
98 // |
|
99 void CGlxCollectionPluginMonths::CpiAttributeAdditionalAttributes(const TMPXAttribute& aCpiAttribute, RArray<TMPXAttribute>& aAttributeArray) |
|
100 { |
|
101 TRACER("CGlxCollectionPluginMonths::CpiAttributeAdditionalAttributes"); |
|
102 // Only need to process KGlxMediaCollectionPluginSpecificSubTitle here as all the others are reading straight from resource files |
|
103 // KGlxMediaCollectionPluginSpecificSubTitle requires a usage count |
|
104 if (aCpiAttribute == KGlxMediaCollectionPluginSpecificSubTitle) |
|
105 { |
|
106 // need to add the usage count. but check first if it is already present |
|
107 TInt attrCount = aAttributeArray.Count(); |
|
108 TBool found = EFalse; |
|
109 TBool startfound = EFalse; |
|
110 |
|
111 #ifdef GLX_SUB_TITLE_REL8 |
|
112 |
|
113 TBool videofound = EFalse; |
|
114 TBool imagefound = EFalse; |
|
115 |
|
116 for ( TInt index = 0 ; index < attrCount ; index++) |
|
117 { |
|
118 if (aAttributeArray[index] == KMPXMediaGeneralCount) |
|
119 { |
|
120 found = ETrue; |
|
121 } |
|
122 else if ( aAttributeArray[index] == KGlxMediaCollectionInternalStartDate ) |
|
123 { |
|
124 startfound = ETrue; |
|
125 } |
|
126 |
|
127 else if (aAttributeArray[index] == KGlxMediaItemTypeVideo) |
|
128 { |
|
129 videofound = ETrue; |
|
130 } |
|
131 else if(aAttributeArray[index] == KGlxMediaItemTypeImage) |
|
132 { |
|
133 imagefound = ETrue; |
|
134 } |
|
135 } |
|
136 |
|
137 if (!found) |
|
138 { |
|
139 aAttributeArray.Append(KGlxMediaCollectionInternalUsageCount); |
|
140 } |
|
141 |
|
142 if (!startfound) |
|
143 { |
|
144 aAttributeArray.Append(KGlxMediaCollectionInternalStartDate); |
|
145 } |
|
146 // end date will be returned when start date is requested. |
|
147 |
|
148 if (!videofound) |
|
149 { |
|
150 aAttributeArray.Append(KGlxMediaItemTypeVideo); |
|
151 } |
|
152 |
|
153 if (!imagefound) |
|
154 { |
|
155 aAttributeArray.Append(KGlxMediaItemTypeImage); |
|
156 } |
|
157 #else |
|
158 |
|
159 for ( TInt index = 0 ; index < attrCount ; index++) |
|
160 { |
|
161 if (aAttributeArray[index] == KMPXMediaGeneralCount) |
|
162 { |
|
163 found = ETrue; |
|
164 } |
|
165 else if ( aAttributeArray[index] == KGlxMediaCollectionInternalStartDate ) |
|
166 { |
|
167 startfound = ETrue; |
|
168 } |
|
169 } |
|
170 |
|
171 if (!found) |
|
172 { |
|
173 aAttributeArray.Append(KGlxMediaCollectionInternalUsageCount); |
|
174 } |
|
175 if (!startfound) |
|
176 { |
|
177 aAttributeArray.Append(KGlxMediaCollectionInternalStartDate); |
|
178 } |
|
179 #endif |
|
180 // end date will be returned when start date is requested. |
|
181 } |
|
182 } |
|
183 |
|
184 // ---------------------------------------------------------------------------- |
|
185 // HandleCpiAttributeResponseL |
|
186 // ---------------------------------------------------------------------------- |
|
187 // |
|
188 void CGlxCollectionPluginMonths::HandleCpiAttributeResponseL(CMPXMedia* aResponse, TArray<TMPXAttribute> aCpiAttributes, TArray<TGlxMediaId> aMediaIds) |
|
189 { |
|
190 TRACER("CGlxCollectionPluginMonths::HandleCpiAttributeResponseL"); |
|
191 |
|
192 const TInt mediaIdCount = aMediaIds.Count(); |
|
193 |
|
194 switch (mediaIdCount) |
|
195 { |
|
196 case 0: |
|
197 User::Leave(KErrNotSupported); |
|
198 break; |
|
199 |
|
200 case 1: |
|
201 HandleCpiAttributeResponseL(aResponse, aCpiAttributes, aMediaIds[0]); |
|
202 break; |
|
203 |
|
204 |
|
205 default: |
|
206 { |
|
207 // We have an array of CMPXMedia items |
|
208 |
|
209 if (TGlxMediaId(KGlxCollectionRootId) == aMediaIds[0]) |
|
210 { |
|
211 User::Leave(KErrNotSupported); |
|
212 } |
|
213 |
|
214 CMPXMediaArray* mediaArray = aResponse->ValueCObjectL<CMPXMediaArray>(KMPXMediaArrayContents); |
|
215 CleanupStack::PushL(mediaArray); |
|
216 |
|
217 const TInt arrayCount = mediaArray->Count(); |
|
218 |
|
219 // Sanity check |
|
220 if (arrayCount != mediaIdCount) |
|
221 { |
|
222 User::Leave(KErrArgument); |
|
223 } |
|
224 |
|
225 for (TInt index = 0; index < arrayCount; index++) |
|
226 { |
|
227 HandleCpiAttributeResponseL((*mediaArray)[index], aCpiAttributes, aMediaIds[index]); |
|
228 } |
|
229 |
|
230 aResponse->SetCObjectValueL(KMPXMediaArrayContents, mediaArray); |
|
231 CleanupStack::PopAndDestroy(mediaArray); |
|
232 } |
|
233 break; |
|
234 } |
|
235 } |
|
236 |
|
237 |
|
238 // ---------------------------------------------------------------------------- |
|
239 // HandleCpiAttributeResponseL |
|
240 // ---------------------------------------------------------------------------- |
|
241 // |
|
242 void CGlxCollectionPluginMonths::HandleCpiAttributeResponseL(CMPXMedia* aResponse, TArray<TMPXAttribute> aCpiAttributes, TGlxMediaId aMediaId) |
|
243 { |
|
244 TRACER("CGlxCollectionPluginMonths::HandleCpiAttributeResponseL"); |
|
245 |
|
246 _LIT(KResourceFile, "z:glxpluginmonths.rsc"); |
|
247 |
|
248 TInt count = aCpiAttributes.Count(); |
|
249 |
|
250 for (TInt index = 0; index < count ; index++) |
|
251 { |
|
252 const TMPXAttribute attr = aCpiAttributes[index]; |
|
253 |
|
254 if (attr == KGlxMediaCollectionPluginSpecificSubTitle) |
|
255 { |
|
256 GLX_LOG_INFO("Attribute : SubTitle"); |
|
257 |
|
258 if (TGlxMediaId(KGlxCollectionRootId) == aMediaId) |
|
259 { |
|
260 GLX_LOG_INFO("Attribute : SubTitle-RootId"); |
|
261 |
|
262 #ifdef GLX_SUB_TITLE_REL8 |
|
263 |
|
264 //The usage Count is required for the subtitle in the main list view |
|
265 if (!aResponse->IsSupported(KGlxMediaCollectionInternalUsageCount)) |
|
266 { |
|
267 User::Leave(KErrNotSupported); |
|
268 } |
|
269 else |
|
270 { |
|
271 TInt usageCount = aResponse->ValueTObjectL<TInt>(KGlxMediaCollectionInternalUsageCount); |
|
272 |
|
273 // Get the format string |
|
274 HBufC* tempTitle = NULL; |
|
275 |
|
276 if(0 == usageCount) |
|
277 { |
|
278 GLX_LOG_INFO("SubTitle:0 Items"); |
|
279 |
|
280 tempTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_NO_IMAGE_NO_VIDEO); |
|
281 aResponse->SetTextValueL(attr, *tempTitle); |
|
282 } |
|
283 |
|
284 // Get the format string |
|
285 else if (1 == usageCount) |
|
286 { |
|
287 GLX_LOG_INFO("SubTitle:1 Item"); |
|
288 |
|
289 tempTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_SINGLE_BY_MONTH); |
|
290 aResponse->SetTextValueL(attr, *tempTitle); |
|
291 } |
|
292 else |
|
293 { |
|
294 GLX_LOG_INFO1("SubTitle: %d Items",usageCount); |
|
295 |
|
296 tempTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_MULTI_BY_MONTH); |
|
297 TPtr formatString = tempTitle->Des(); |
|
298 |
|
299 // Now create a buffer that will contain the result. needs to be length of format string plus a few extra for the number |
|
300 HBufC* title = HBufC::NewLC(formatString.Length() + 10); |
|
301 TPtr ptr = title->Des(); |
|
302 StringLoader::Format(ptr, formatString, -1, usageCount); |
|
303 |
|
304 // Set the title in the response. |
|
305 aResponse->SetTextValueL(attr, *title); |
|
306 CleanupStack::PopAndDestroy(title); |
|
307 } |
|
308 CleanupStack::PopAndDestroy(tempTitle); |
|
309 } |
|
310 #else |
|
311 if (!aResponse->IsSupported(KGlxMediaCollectionInternalStartDate)) |
|
312 { |
|
313 User::Leave(KErrNotSupported); |
|
314 } |
|
315 if (!aResponse->IsSupported(KGlxMediaCollectionInternalEndDate)) |
|
316 { |
|
317 User::Leave(KErrNotSupported); |
|
318 } |
|
319 TTime start = aResponse->ValueTObjectL<TInt64>(KGlxMediaCollectionInternalStartDate); |
|
320 TTime end = aResponse->ValueTObjectL<TInt64>(KGlxMediaCollectionInternalEndDate); |
|
321 if( TTime(0) == start ) |
|
322 { |
|
323 aResponse->SetTextValueL(attr, KNullDesC); |
|
324 continue; |
|
325 } |
|
326 _LIT(KGlxTempMonthYearTitleFormat, "%F%Y"); |
|
327 |
|
328 HBufC* tempTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE); |
|
329 TPtr formatString = tempTitle->Des(); |
|
330 TBuf<8> yearTitle; |
|
331 start.FormatL(yearTitle, KGlxTempMonthYearTitleFormat); |
|
332 HBufC* monthTitle = NULL; |
|
333 switch(start.DateTime().Month()) |
|
334 { |
|
335 case EJanuary: |
|
336 { |
|
337 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_JAN); |
|
338 break; |
|
339 } |
|
340 case EFebruary: |
|
341 { |
|
342 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_FEB); |
|
343 break; |
|
344 } |
|
345 case EMarch: |
|
346 { |
|
347 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_MAR); |
|
348 break; |
|
349 } |
|
350 case EApril: |
|
351 { |
|
352 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_APR); |
|
353 break; |
|
354 } |
|
355 case EMay: |
|
356 { |
|
357 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_MAY); |
|
358 break; |
|
359 } |
|
360 case EJune: |
|
361 { |
|
362 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_JUN); |
|
363 break; |
|
364 } |
|
365 case EJuly: |
|
366 { |
|
367 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_JUL); |
|
368 break; |
|
369 } |
|
370 case EAugust: |
|
371 { |
|
372 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_AUG); |
|
373 break; |
|
374 } |
|
375 case ESeptember: |
|
376 { |
|
377 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_SEP); |
|
378 break; |
|
379 } |
|
380 case EOctober: |
|
381 { |
|
382 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_OCT); |
|
383 break; |
|
384 } |
|
385 case ENovember: |
|
386 { |
|
387 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_NOV); |
|
388 break; |
|
389 } |
|
390 case EDecember: |
|
391 { |
|
392 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_DEC); |
|
393 break; |
|
394 } |
|
395 } |
|
396 TBuf<8> yearTitle2; |
|
397 end.FormatL(yearTitle2, KGlxTempMonthYearTitleFormat); |
|
398 HBufC* monthTitle2 = NULL; |
|
399 switch(end.DateTime().Month()) |
|
400 { |
|
401 case EJanuary: |
|
402 { |
|
403 monthTitle2 = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_JAN); |
|
404 break; |
|
405 } |
|
406 case EFebruary: |
|
407 { |
|
408 monthTitle2 = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_FEB); |
|
409 break; |
|
410 } |
|
411 case EMarch: |
|
412 { |
|
413 monthTitle2 = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_MAR); |
|
414 break; |
|
415 } |
|
416 case EApril: |
|
417 { |
|
418 monthTitle2 = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_APR); |
|
419 break; |
|
420 } |
|
421 case EMay: |
|
422 { |
|
423 monthTitle2 = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_MAY); |
|
424 break; |
|
425 } |
|
426 case EJune: |
|
427 { |
|
428 monthTitle2 = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_JUN); |
|
429 break; |
|
430 } |
|
431 case EJuly: |
|
432 { |
|
433 monthTitle2 = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_JUL); |
|
434 break; |
|
435 } |
|
436 case EAugust: |
|
437 { |
|
438 monthTitle2 = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_AUG); |
|
439 break; |
|
440 } |
|
441 case ESeptember: |
|
442 { |
|
443 monthTitle2 = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_SEP); |
|
444 break; |
|
445 } |
|
446 case EOctober: |
|
447 { |
|
448 monthTitle2 = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_OCT); |
|
449 break; |
|
450 } |
|
451 case ENovember: |
|
452 { |
|
453 monthTitle2 = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_NOV); |
|
454 break; |
|
455 } |
|
456 case EDecember: |
|
457 { |
|
458 monthTitle2 = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_DEC); |
|
459 break; |
|
460 } |
|
461 } |
|
462 |
|
463 HBufC* title1 = HBufC::NewLC(formatString.Length() + 20); |
|
464 TPtr ptr1 = title1->Des(); |
|
465 HBufC* title2 = HBufC::NewLC(formatString.Length() + 20); |
|
466 TPtr ptr2 = title2->Des(); |
|
467 HBufC* title3 = HBufC::NewLC(formatString.Length() + 20); |
|
468 TPtr ptr3 = title3->Des(); |
|
469 HBufC* title4 = HBufC::NewLC(formatString.Length() + 20); |
|
470 TPtr ptr4 = title4->Des(); |
|
471 TPtr monthPtr = monthTitle->Des(); |
|
472 TPtr monthPtr2 = monthTitle2->Des(); |
|
473 StringLoader::Format(ptr1, formatString, 0, monthPtr); |
|
474 StringLoader::Format(ptr2, ptr1, 1, yearTitle); |
|
475 StringLoader::Format(ptr3, ptr2, 2, monthPtr2); |
|
476 StringLoader::Format(ptr4, ptr3, 3, yearTitle2); |
|
477 |
|
478 |
|
479 aResponse->SetTextValueL(attr, *title4); |
|
480 CleanupStack::PopAndDestroy(title4); |
|
481 CleanupStack::PopAndDestroy(title3); |
|
482 CleanupStack::PopAndDestroy(title2); |
|
483 CleanupStack::PopAndDestroy(title1); |
|
484 CleanupStack::PopAndDestroy(monthTitle2); |
|
485 CleanupStack::PopAndDestroy(monthTitle); |
|
486 CleanupStack::PopAndDestroy(tempTitle); |
|
487 #endif |
|
488 } |
|
489 else |
|
490 { |
|
491 |
|
492 #ifdef GLX_SUB_TITLE_REL8 |
|
493 |
|
494 HBufC* tempTitle = NULL; |
|
495 |
|
496 TInt videoCount = aResponse->ValueTObjectL<TInt>(KGlxMediaItemTypeVideo); |
|
497 |
|
498 TInt imageCount = aResponse->ValueTObjectL<TInt>(KGlxMediaItemTypeImage); |
|
499 |
|
500 //No Images or Videos |
|
501 if ((0 == videoCount) && (0 == imageCount )) |
|
502 { |
|
503 GLX_LOG_INFO("VideoCount:0,ImageCount:0"); |
|
504 |
|
505 tempTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_NO_IMAGE_NO_VIDEO); |
|
506 aResponse->SetTextValueL(attr, *tempTitle); |
|
507 } |
|
508 else |
|
509 { |
|
510 // 1 Image and multi/0 Videos |
|
511 if (1 == imageCount) |
|
512 { |
|
513 GLX_LOG_INFO1("ImageCount:1,VideoCount:%d",videoCount); |
|
514 |
|
515 tempTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_ONE_IMAGE_MULTI_VIDEO); |
|
516 |
|
517 TPtr formatString = tempTitle->Des(); |
|
518 |
|
519 // Now create a buffer that will contain the result. needs to be length of format string plus a few extra for the number |
|
520 HBufC* title = HBufC::NewLC(formatString.Length() + 10); |
|
521 TPtr ptr = title->Des(); |
|
522 |
|
523 StringLoader::Format(ptr, formatString, -1, videoCount); |
|
524 |
|
525 // Set the title in the response. |
|
526 aResponse->SetTextValueL(attr, *title); |
|
527 |
|
528 CleanupStack::PopAndDestroy(title); |
|
529 } |
|
530 |
|
531 // Multi/0 Image and 1 Video |
|
532 else if (1 == videoCount) |
|
533 { |
|
534 GLX_LOG_INFO1("ImageCount: %d,VideoCount:1",imageCount); |
|
535 |
|
536 tempTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_MULTI_IMAGE_ONE_VIDEO); |
|
537 |
|
538 TPtr formatString = tempTitle->Des(); |
|
539 |
|
540 // Now create a buffer that will contain the result. needs to be length of format string plus a few extra for the number |
|
541 HBufC* title = HBufC::NewLC(formatString.Length() + 10); |
|
542 TPtr ptr = title->Des(); |
|
543 |
|
544 StringLoader::Format(ptr, formatString, -1, imageCount); |
|
545 |
|
546 // Set the title in the response. |
|
547 aResponse->SetTextValueL(attr, *title); |
|
548 |
|
549 CleanupStack::PopAndDestroy(title); |
|
550 } |
|
551 |
|
552 // Multi Image and Multi Video |
|
553 else |
|
554 { |
|
555 GLX_LOG_INFO2("ImageCount %d,VideoCount %d",imageCount,videoCount); |
|
556 |
|
557 tempTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_MULTI_IMAGE_MULTI_VIDEO); |
|
558 TPtr formatString = tempTitle->Des(); |
|
559 |
|
560 HBufC* title = HBufC::NewLC(formatString.Length() + 10); |
|
561 TPtr ptr = title->Des(); |
|
562 |
|
563 HBufC* title1 = HBufC::NewLC(formatString.Length() + 10); |
|
564 TPtr ptr1 = title1->Des(); |
|
565 |
|
566 StringLoader::Format(ptr, formatString, 0, imageCount); |
|
567 StringLoader::Format(ptr1, ptr, 1, videoCount); |
|
568 |
|
569 // Set the title in the response. |
|
570 aResponse->SetTextValueL(attr, *title1); |
|
571 |
|
572 CleanupStack::PopAndDestroy(title1); |
|
573 CleanupStack::PopAndDestroy(title); |
|
574 } |
|
575 } |
|
576 CleanupStack::PopAndDestroy(tempTitle); |
|
577 #else |
|
578 |
|
579 TInt usageCount = 0; |
|
580 |
|
581 if ( aResponse->IsSupported(KMPXMediaGeneralCount) ) |
|
582 { |
|
583 usageCount = aResponse->ValueTObjectL<TInt>(KMPXMediaGeneralCount); |
|
584 } |
|
585 else if ( aResponse->IsSupported(KGlxMediaCollectionInternalUsageCount) ) |
|
586 { |
|
587 usageCount = aResponse->ValueTObjectL<TInt>(KGlxMediaCollectionInternalUsageCount); |
|
588 } |
|
589 else |
|
590 { |
|
591 User::Leave(KErrNotSupported); |
|
592 } |
|
593 HBufC* tempTitle = NULL; |
|
594 |
|
595 if(0 == usageCount) |
|
596 { |
|
597 tempTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_NO_IMAGE_NO_VIDEO); |
|
598 // Set the title in the response. |
|
599 aResponse->SetTextValueL(attr, *tempTitle); |
|
600 CleanupStack::PopAndDestroy(tempTitle); |
|
601 continue; |
|
602 } |
|
603 |
|
604 else if (1 == usageCount) |
|
605 { |
|
606 tempTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_SINGLE); |
|
607 } |
|
608 else |
|
609 { |
|
610 tempTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_MULTI); |
|
611 } |
|
612 |
|
613 TPtr formatString = tempTitle->Des(); |
|
614 |
|
615 // Now create a buffer that will contain the result. needs to be length of format string plus a few extra for the number |
|
616 HBufC* title = HBufC::NewLC(formatString.Length() + 10); |
|
617 TPtr ptr = title->Des(); |
|
618 StringLoader::Format(ptr, formatString, -1, usageCount); |
|
619 |
|
620 // Set the title in the response. |
|
621 aResponse->SetTextValueL(attr, *title); |
|
622 |
|
623 CleanupStack::PopAndDestroy(title); |
|
624 CleanupStack::PopAndDestroy(tempTitle); |
|
625 #endif |
|
626 } |
|
627 } |
|
628 else if (attr == KGlxMediaCollectionPluginSpecificSelectMediaPopupTitle) |
|
629 { |
|
630 GLX_LOG_INFO("Attribute : MediaPopupTitle"); |
|
631 |
|
632 User::Leave(KErrNotSupported); |
|
633 } |
|
634 else if (attr == KGlxMediaCollectionPluginSpecificNewMediaItemTitle) |
|
635 { |
|
636 GLX_LOG_INFO("Attribute : NewMediaItemTitle"); |
|
637 |
|
638 User::Leave(KErrNotSupported); |
|
639 } |
|
640 else if (attr == KGlxMediaCollectionPluginSpecificDefaultMediaTitle) |
|
641 { |
|
642 GLX_LOG_INFO("Attribute : DefaultMediaTitle"); |
|
643 |
|
644 User::Leave(KErrNotSupported); |
|
645 } |
|
646 else if (attr == KMPXMediaGeneralTitle) |
|
647 { |
|
648 GLX_LOG_INFO("Attribute : GeneralTitle"); |
|
649 |
|
650 if( TGlxMediaId(KGlxCollectionRootId) == aMediaId ) |
|
651 { |
|
652 GLX_LOG_INFO("Attribute : GeneralTitle:RootId"); |
|
653 |
|
654 HBufC* title = LoadLocalizedStringLC(KResourceFile, R_MONTHS_GENERAL_TITLE); |
|
655 aResponse->SetTextValueL(attr, *title); |
|
656 CleanupStack::PopAndDestroy(title); |
|
657 } |
|
658 else |
|
659 { |
|
660 if( aResponse->IsSupported(KGlxMediaCollectionInternalStartDate) ) |
|
661 { |
|
662 HBufC* tempTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_ITEM_TITLE); |
|
663 TPtr formatString = tempTitle->Des(); |
|
664 TTime month = aResponse->ValueTObjectL<TInt64>(KGlxMediaCollectionInternalStartDate); |
|
665 _LIT(KGlxTempMonthYearTitleFormat, "%F%Y"); |
|
666 TBuf<8> yearTitle; |
|
667 month.FormatL(yearTitle, KGlxTempMonthYearTitleFormat); |
|
668 HBufC* monthTitle = NULL; |
|
669 switch(month.DateTime().Month()) |
|
670 { |
|
671 case EJanuary: |
|
672 { |
|
673 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_TITLE_JAN); |
|
674 break; |
|
675 } |
|
676 case EFebruary: |
|
677 { |
|
678 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_TITLE_FEB); |
|
679 break; |
|
680 } |
|
681 case EMarch: |
|
682 { |
|
683 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_TITLE_MAR); |
|
684 break; |
|
685 } |
|
686 case EApril: |
|
687 { |
|
688 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_TITLE_APR); |
|
689 break; |
|
690 } |
|
691 case EMay: |
|
692 { |
|
693 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_TITLE_MAY); |
|
694 break; |
|
695 } |
|
696 case EJune: |
|
697 { |
|
698 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_TITLE_JUN); |
|
699 break; |
|
700 } |
|
701 case EJuly: |
|
702 { |
|
703 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_TITLE_JUL); |
|
704 break; |
|
705 } |
|
706 case EAugust: |
|
707 { |
|
708 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_TITLE_AUG); |
|
709 break; |
|
710 } |
|
711 case ESeptember: |
|
712 { |
|
713 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_TITLE_SEP); |
|
714 break; |
|
715 } |
|
716 case EOctober: |
|
717 { |
|
718 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_TITLE_OCT); |
|
719 break; |
|
720 } |
|
721 case ENovember: |
|
722 { |
|
723 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_TITLE_NOV); |
|
724 break; |
|
725 } |
|
726 case EDecember: |
|
727 { |
|
728 monthTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_TITLE_DEC); |
|
729 break; |
|
730 } |
|
731 } |
|
732 |
|
733 HBufC* title1 = HBufC::NewLC(formatString.Length() + 20); |
|
734 TPtr ptr = title1->Des(); |
|
735 HBufC* title = HBufC::NewLC(formatString.Length() + 20); |
|
736 TPtr ptr2 = title->Des(); |
|
737 TPtr monthPtr = monthTitle->Des(); |
|
738 StringLoader::Format(ptr, formatString, 0, monthPtr); |
|
739 StringLoader::Format(ptr2, ptr, 1, yearTitle); |
|
740 |
|
741 |
|
742 aResponse->SetTextValueL(attr, *title); |
|
743 CleanupStack::PopAndDestroy(title); |
|
744 CleanupStack::PopAndDestroy(title1); |
|
745 CleanupStack::PopAndDestroy(monthTitle); |
|
746 CleanupStack::PopAndDestroy(tempTitle); |
|
747 } |
|
748 } |
|
749 } |
|
750 } |
|
751 aResponse->Delete(KGlxMediaCollectionInternalUsageCount); |
|
752 aResponse->Delete(KGlxMediaCollectionInternalStartDate); |
|
753 aResponse->Delete(KGlxMediaCollectionInternalEndDate); |
|
754 aResponse->Delete(KGlxMediaItemTypeImage); |
|
755 aResponse->Delete(KGlxMediaItemTypeVideo); |
|
756 } |
|
757 |
|
758 // ---------------------------------------------------------------------------- |
|
759 // IsUpdateMessageIgnored |
|
760 // ---------------------------------------------------------------------------- |
|
761 // |
|
762 |
|
763 TBool CGlxCollectionPluginMonths::IsUpdateMessageIgnored(CMPXMessage& /*aMessage*/) |
|
764 { |
|
765 TBool ignore = EFalse; |
|
766 return ignore; |
|
767 } |
|
768 |
|
769 // ---------------------------------------------------------------------------- |
|
770 // DefaultFilter |
|
771 // ---------------------------------------------------------------------------- |
|
772 // |
|
773 TGlxFilterProperties CGlxCollectionPluginMonths::DefaultFilter(TInt aLevel) |
|
774 { |
|
775 __ASSERT_DEBUG(( (aLevel == KGlxCollectionRootLevel) || |
|
776 (aLevel == KGlxCollectionMonthsLevel) || (aLevel == KGlxCollectionMonthContentsLevel) |
|
777 || (aLevel == KGlxCollectionMonthFSLevel)), Panic(EGlxPanicInvalidPathLevel)); |
|
778 TGlxFilterProperties filterProperties; |
|
779 filterProperties.iSortOrder = EGlxFilterSortOrderCaptureDate; |
|
780 filterProperties.iSortDirection = EGlxFilterSortDirectionDescending; |
|
781 filterProperties.iOrigin = EGlxFilterOriginCamera; |
|
782 switch(aLevel) |
|
783 { |
|
784 case KGlxCollectionRootLevel: |
|
785 case KGlxCollectionMonthsLevel: |
|
786 case KGlxCollectionMonthFSLevel: |
|
787 { |
|
788 filterProperties.iSortDirection = EGlxFilterSortDirectionDescending; |
|
789 filterProperties.iItemType = EGlxFilterMonth; |
|
790 break; |
|
791 } |
|
792 } |
|
793 return filterProperties; |
|
794 } |
|
795 |
|
796 |
|
797 // End of file |