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