photosgallery/collectionframework/plugins/glxcollectionpluginmonths/src/glxcollectionpluginmonths.cpp
branchRCL_3
changeset 47 f9e827349359
parent 35 420f6808bf21
equal deleted inserted replaced
35:420f6808bf21 47:f9e827349359
   107     iDataSource = MGlxDataSource::OpenDataSourceL(KGlxDefaultDataSourceUid, *this);
   107     iDataSource = MGlxDataSource::OpenDataSourceL(KGlxDefaultDataSourceUid, *this);
   108 	}
   108 	}
   109 
   109 
   110  
   110  
   111 // ----------------------------------------------------------------------------
   111 // ----------------------------------------------------------------------------
   112 // CpiAttributeAdditionalAttributes
   112 // CpiAttributeAdditionalAttributesL
   113 // ----------------------------------------------------------------------------
   113 // ----------------------------------------------------------------------------
   114 //
   114 //
   115 void CGlxCollectionPluginMonths::CpiAttributeAdditionalAttributes(
   115 void CGlxCollectionPluginMonths::CpiAttributeAdditionalAttributesL(
   116 	const TMPXAttribute& aCpiAttribute, RArray<TMPXAttribute>& aAttributeArray)
   116 	const TMPXAttribute& aCpiAttribute, RArray<TMPXAttribute>& aAttributeArray)
   117 	{
   117 	{
   118     TRACER("CGlxCollectionPluginMonths::CpiAttributeAdditionalAttributes");
   118     TRACER("CGlxCollectionPluginMonths::CpiAttributeAdditionalAttributesL");
   119     // Only need to process KGlxMediaCollectionPluginSpecificSubTitle here as all the others are reading straight from resource files
   119     // Only need to process KGlxMediaCollectionPluginSpecificSubTitle here as all the others are reading straight from resource files
   120     // KGlxMediaCollectionPluginSpecificSubTitle requires a usage count
   120     // KGlxMediaCollectionPluginSpecificSubTitle requires a usage count
   121 	if (aCpiAttribute == KGlxMediaCollectionPluginSpecificSubTitle)
   121 	if (aCpiAttribute == KGlxMediaCollectionPluginSpecificSubTitle)
   122 		{
   122 		{
   123 		// need to add the usage count. but check first if it is already present
   123 		// need to add the usage count. but check first if it is already present
   154 				}			    
   154 				}			    
   155 			}
   155 			}
   156 
   156 
   157 		if (!found)
   157 		if (!found)
   158 			{
   158 			{
   159 			aAttributeArray.Append(KGlxMediaCollectionInternalUsageCount);
   159             aAttributeArray.AppendL(KGlxMediaCollectionInternalUsageCount);
   160 			}
   160 			}
   161 			
   161 			
   162 		if (!startfound)
   162 		if (!startfound)
   163 			{
   163 			{
   164 			aAttributeArray.Append(KGlxMediaCollectionInternalStartDate);
   164             aAttributeArray.AppendL(KGlxMediaCollectionInternalStartDate);
   165 			}
   165 			}
   166 		// end date will be returned when start date is requested.	        
   166 		// end date will be returned when start date is requested.	        
   167 
   167 
   168 		if (!videofound)
   168 		if (!videofound)
   169 			{
   169 			{
   170 			aAttributeArray.Append(KGlxMediaItemTypeVideo);
   170             aAttributeArray.AppendL(KGlxMediaItemTypeVideo);
   171 			}
   171 			}
   172 
   172 
   173 		if (!imagefound)	        
   173 		if (!imagefound)	        
   174 			{
   174 			{
   175 			aAttributeArray.Append(KGlxMediaItemTypeImage);
   175             aAttributeArray.AppendL(KGlxMediaItemTypeImage);
   176 			}	
   176 			}	
   177 #else
   177 #else
   178 
   178 
   179 		for ( TInt index = 0 ; index < attrCount ; index++)
   179 		for ( TInt index = 0 ; index < attrCount ; index++)
   180 	        {
   180 	        {
   194 #endif // #ifdef SHOW_MONTHS_START_END_SUB_TITLE				
   194 #endif // #ifdef SHOW_MONTHS_START_END_SUB_TITLE				
   195 	        }
   195 	        }
   196 	        
   196 	        
   197 	    if (!found)
   197 	    if (!found)
   198 	        {
   198 	        {
   199 	        aAttributeArray.Append(KGlxMediaCollectionInternalUsageCount);
   199             aAttributeArray.AppendL(KGlxMediaCollectionInternalUsageCount);
   200 	        }
   200 	        }
   201 #ifdef SHOW_MONTHS_START_END_SUB_TITLE				
   201 #ifdef SHOW_MONTHS_START_END_SUB_TITLE				
   202 	    if (!startfound)
   202 	    if (!startfound)
   203 	        {
   203 	        {
   204 	        aAttributeArray.Append(KGlxMediaCollectionInternalStartDate);
   204             aAttributeArray.AppendL(KGlxMediaCollectionInternalStartDate);
   205 	        }
   205 	        }
   206 	    if(!endfound)
   206 	    if(!endfound)
   207 	    	{
   207 	    	{
   208 	    	aAttributeArray.Append(KGlxMediaCollectionInternalEndDate);
   208             aAttributeArray.AppendL(KGlxMediaCollectionInternalEndDate);
   209 	        }
   209 	        }
   210 #endif // #ifdef SHOW_MONTHS_START_END_SUB_TITLE
   210 #endif // #ifdef SHOW_MONTHS_START_END_SUB_TITLE
   211 #endif // #ifdef GLX_SUB_TITLE_REL8
   211 #endif // #ifdef GLX_SUB_TITLE_REL8
   212 	    // end date will be returned when start date is requested.			
   212 	    // end date will be returned when start date is requested.			
   213 		}
   213 		}
   279 		TArray<TMPXAttribute> aCpiAttributes, TGlxMediaId aMediaId)
   279 		TArray<TMPXAttribute> aCpiAttributes, TGlxMediaId aMediaId)
   280     {
   280     {
   281     TRACER("CGlxCollectionPluginMonths::HandleCpiAttributeResponseL");
   281     TRACER("CGlxCollectionPluginMonths::HandleCpiAttributeResponseL");
   282     
   282     
   283 	TInt count = aCpiAttributes.Count();
   283 	TInt count = aCpiAttributes.Count();
   284     GLX_DEBUG2("CGlxCollectionPluginMonths::HandleCpiAttributeResponseL count=%d", count);    
   284     GLX_DEBUG2("CGlxCollectionPluginMonths::HandleCpiAttributeResponseL count=%d", 
       
   285             count);    
   285 	
   286 	
   286 	TLanguage lang;
   287 	TLanguage lang;
   287     lang = User::Language();
   288     lang = User::Language();
   288 	
   289 	
   289 	for (TInt index = 0; index < count ; index++)
   290 	for (TInt index = 0; index < count ; index++)
   309 					TInt usageCount = aResponse->ValueTObjectL<TInt>(KGlxMediaCollectionInternalUsageCount);
   310 					TInt usageCount = aResponse->ValueTObjectL<TInt>(KGlxMediaCollectionInternalUsageCount);
   310 
   311 
   311 					// Get the format string
   312 					// Get the format string
   312 					HBufC* tempTitle = NULL;
   313 					HBufC* tempTitle = NULL;
   313 
   314 
   314 					if(0 == usageCount)	
   315 					if(0 == usageCount)
   315 						{	
   316                         {
   316 						GLX_LOG_INFO("SubTitle:0 Items");
   317                         GLX_LOG_INFO("SubTitle:0 Items");
   317 											
   318 
   318 						tempTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_NO_IMAGE_NO_VIDEO);
   319                         tempTitle = LoadLocalizedStringLC(KResourceFile, 
   319 						aResponse->SetTextValueL(attr, *tempTitle);
   320                                 R_MONTHS_SUB_TITLE_NO_IMAGE_NO_VIDEO);
   320 						}
   321                         aResponse->SetTextValueL(attr, *tempTitle);
   321 
   322                         }
   322 					// Get the format string
   323 
   323 					else if (1 == usageCount)
   324                     // Get the format string
   324 						{
   325 
   325 						GLX_LOG_INFO("SubTitle:1 Item");
   326                     else if (1 == usageCount)
   326 						
   327                         {
   327 						tempTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_SINGLE_BY_MONTH);
   328                         GLX_LOG_INFO("SubTitle:1 Item");
   328 						aResponse->SetTextValueL(attr, *tempTitle);
   329 
   329 						}
   330                         tempTitle = LoadLocalizedStringLC(KResourceFile, 
   330 					else 
   331                                 R_MONTHS_SUB_TITLE_SINGLE_BY_MONTH);
   331 						{
   332                         aResponse->SetTextValueL(attr, *tempTitle);
   332 						GLX_LOG_INFO1("SubTitle: %d Items",usageCount);
   333                         }
   333 						
   334                     else
   334 						tempTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_MULTI_BY_MONTH);						
   335                         {
   335 						TPtr formatString = tempTitle->Des();
   336                         GLX_LOG_INFO1("SubTitle: %d Items",usageCount);
   336 
   337 
   337 						// Now create a buffer that will contain the result. needs to be length of format string plus a few extra for the number
   338                         tempTitle = LoadLocalizedStringLC(KResourceFile, 
   338 						HBufC* title = HBufC::NewLC(formatString.Length() + KDateBufferPaddingMin);
   339                                 R_MONTHS_SUB_TITLE_MULTI_BY_MONTH);
   339 						TPtr ptr = title->Des();
   340                         TPtr formatString = tempTitle->Des();
   340 						StringLoader::Format(ptr, formatString, -1, usageCount);
   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);
   341 
   347 
   342 						// Set the title in the response.
   348 						// Set the title in the response.
   343 						aResponse->SetTextValueL(attr, *title);    
   349 						aResponse->SetTextValueL(attr, *title);    
   344 						CleanupStack::PopAndDestroy(title);						
   350 						CleanupStack::PopAndDestroy(title);						
   345 						}
   351 						}
   357 	            TTime start = aResponse->ValueTObjectL<TInt64>(KGlxMediaCollectionInternalStartDate);
   363 	            TTime start = aResponse->ValueTObjectL<TInt64>(KGlxMediaCollectionInternalStartDate);
   358 	            TTime end = aResponse->ValueTObjectL<TInt64>(KGlxMediaCollectionInternalEndDate);
   364 	            TTime end = aResponse->ValueTObjectL<TInt64>(KGlxMediaCollectionInternalEndDate);
   359 	            HBufC* tempTitle = NULL;
   365 	            HBufC* tempTitle = NULL;
   360                 if( TTime(0) == start )
   366                 if( TTime(0) == start )
   361                     {
   367                     {
   362                     tempTitle = LoadLocalizedStringLC(KResourceFile, R_MONTHS_SUB_TITLE_NO_IMAGE_NO_VIDEO);
   368                     tempTitle = LoadLocalizedStringLC(KResourceFile, 
       
   369                             R_MONTHS_SUB_TITLE_NO_IMAGE_NO_VIDEO);
   363                     aResponse->SetTextValueL(attr, *tempTitle);
   370                     aResponse->SetTextValueL(attr, *tempTitle);
   364                     CleanupStack::PopAndDestroy(tempTitle);
   371                     CleanupStack::PopAndDestroy(tempTitle);
   365                     continue;
   372                     continue;
   366                     }
   373                     }
   367                  _LIT(KGlxTempMonthYearTitleFormat, "%F%Y");
   374                  _LIT(KGlxTempMonthYearTitleFormat, "%F%Y");
   447 						tempTitle = LoadLocalizedStringLC(KResourceFile,
   454 						tempTitle = LoadLocalizedStringLC(KResourceFile,
   448 										R_MONTHS_SUB_TITLE_ONE_IMAGE_MULTI_VIDEO);
   455 										R_MONTHS_SUB_TITLE_ONE_IMAGE_MULTI_VIDEO);
   449 
   456 
   450 						TPtr formatString = tempTitle->Des();
   457 						TPtr formatString = tempTitle->Des();
   451 
   458 
   452 						// Now create a buffer that will contain the result. needs to be length of format string plus a few extra for the number
   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
   453 						HBufC* title = HBufC::NewLC(formatString.Length() + KDateBufferPaddingMin);
   461 						HBufC* title = HBufC::NewLC(formatString.Length() + KDateBufferPaddingMin);
   454 						TPtr ptr = title->Des();
   462 						TPtr ptr = title->Des();
   455 
   463 
   456 						StringLoader::Format(ptr, formatString, -1, videoCount);
   464 						StringLoader::Format(ptr, formatString, -1, videoCount);
   457 
   465 
   469 						tempTitle = LoadLocalizedStringLC(KResourceFile,
   477 						tempTitle = LoadLocalizedStringLC(KResourceFile,
   470 									R_MONTHS_SUB_TITLE_MULTI_IMAGE_ONE_VIDEO);
   478 									R_MONTHS_SUB_TITLE_MULTI_IMAGE_ONE_VIDEO);
   471 
   479 
   472 						TPtr formatString = tempTitle->Des();
   480 						TPtr formatString = tempTitle->Des();
   473 
   481 
   474 						// Now create a buffer that will contain the result. needs to be length of format string plus a few extra for the number
   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
   475 						HBufC* title = HBufC::NewLC(formatString.Length() + KDateBufferPaddingMin);
   484 						HBufC* title = HBufC::NewLC(formatString.Length() + KDateBufferPaddingMin);
   476 						TPtr ptr = title->Des();
   485 						TPtr ptr = title->Des();
   477 
   486 
   478 						StringLoader::Format(ptr, formatString, -1, imageCount);
   487 						StringLoader::Format(ptr, formatString, -1, imageCount);
   479 
   488 
   563                     			R_MONTHS_SUB_TITLE_MULTI);
   572                     			R_MONTHS_SUB_TITLE_MULTI);
   564                     }
   573                     }
   565                 
   574                 
   566                 TPtr formatString = tempTitle->Des();
   575                 TPtr formatString = tempTitle->Des();
   567                 
   576                 
   568                 // Now create a buffer that will contain the result. needs to be length of format string plus a few extra for the number
   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
   569                 HBufC* title = HBufC::NewLC(formatString.Length() + KDateBufferPaddingMin);
   579                 HBufC* title = HBufC::NewLC(formatString.Length() + KDateBufferPaddingMin);
   570                 TPtr ptr = title->Des();
   580                 TPtr ptr = title->Des();
   571                 StringLoader::Format(ptr, formatString, -1, usageCount);
   581                 StringLoader::Format(ptr, formatString, -1, usageCount);
   572                 
   582                 
   573                 // Set the title in the response.
   583                 // Set the title in the response.