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