photosgallery/collectionframework/plugins/glxcollectionplugincamera/src/glxcollectionplugincamera.cpp
branchRCL_3
changeset 47 f9e827349359
parent 0 4e91876724a2
equal deleted inserted replaced
35:420f6808bf21 47:f9e827349359
    95 void CGlxCollectionPluginCamera::ConstructL()
    95 void CGlxCollectionPluginCamera::ConstructL()
    96     {
    96     {
    97     iDataSource = MGlxDataSource::OpenDataSourceL(KGlxDefaultDataSourceUid, *this);
    97     iDataSource = MGlxDataSource::OpenDataSourceL(KGlxDefaultDataSourceUid, *this);
    98 	}
    98 	}
    99 // ----------------------------------------------------------------------------
    99 // ----------------------------------------------------------------------------
   100 // CpiAttributeAdditionalAttributes
   100 // CpiAttributeAdditionalAttributesL
   101 // ----------------------------------------------------------------------------
   101 // ----------------------------------------------------------------------------
   102 //
   102 //
   103 void CGlxCollectionPluginCamera::CpiAttributeAdditionalAttributes(const TMPXAttribute& aCpiAttribute, RArray<TMPXAttribute>& aAttributeArray)
   103 void CGlxCollectionPluginCamera::CpiAttributeAdditionalAttributesL(
   104 	{
   104         const TMPXAttribute& aCpiAttribute,
   105     TRACER("CGlxCollectionPluginCamera::CpiAttributeAdditionalAttributes");
   105         RArray<TMPXAttribute>& aAttributeArray)
   106     // Only need to process KGlxMediaCollectionPluginSpecificSubTitle here as all the other attributes
   106     {
   107     // are reading straight from resource files KGlxMediaCollectionPluginSpecificSubTitle 
   107     TRACER("CGlxCollectionPluginCamera::CpiAttributeAdditionalAttributesL");
   108     // requires a image and the Video count in the collection
   108     // Only need to process KGlxMediaCollectionPluginSpecificSubTitle here as 
   109     
   109     // all the other attributes are reading straight from resource files 
   110 	if (aCpiAttribute == KGlxMediaCollectionPluginSpecificSubTitle)
   110     // KGlxMediaCollectionPluginSpecificSubTitle requires a image and the 
   111 		{
   111     // Video count in the collection
   112 		// need to add the usage count. but check first if it is already present
   112 
   113 		TInt attrCount = aAttributeArray.Count();
   113     if (aCpiAttribute == KGlxMediaCollectionPluginSpecificSubTitle)
   114 		
   114         {
   115 		TBool found = EFalse;
   115         // need to add the usage count. but check first if it is already present
   116 		
   116         TInt attrCount = aAttributeArray.Count();
       
   117 
       
   118         TBool found = EFalse;
       
   119 
   117 #ifdef GLX_SUB_TITLE_REL8
   120 #ifdef GLX_SUB_TITLE_REL8
   118 		
   121 
   119 		TBool videofound = EFalse;
   122         TBool videofound = EFalse;
   120 		TBool imagefound = EFalse;		
   123         TBool imagefound = EFalse;
   121 
   124 
   122 		for ( TInt index = 0 ; index < attrCount ; index++)
   125         for ( TInt index = 0; index < attrCount; index++)
   123 			{
   126             {
   124 			if (aAttributeArray[index] == KMPXMediaGeneralCount)
   127             if (aAttributeArray[index] == KMPXMediaGeneralCount)
   125 				{
   128                 {
   126 				found = ETrue;	            
   129                 found = ETrue;
   127 				}
   130                 }
   128 			else if (aAttributeArray[index] == KGlxMediaItemTypeVideo)
   131             else if (aAttributeArray[index] == KGlxMediaItemTypeVideo)
   129 				{
   132                 {
   130 				videofound = ETrue;	            
   133                 videofound = ETrue;
   131 				}
   134                 }
   132 			else if(aAttributeArray[index] == KGlxMediaItemTypeImage)	            
   135             else if(aAttributeArray[index] == KGlxMediaItemTypeImage)
   133 				{
   136                 {
   134 				imagefound = ETrue;
   137                 imagefound = ETrue;
   135 				}
   138                 }
   136 				
   139 
   137 		if (!videofound)
   140             if (!videofound)
   138 			{
   141                 {
   139 			aAttributeArray.Append(KGlxMediaItemTypeVideo);
   142                 aAttributeArray.AppendL(KGlxMediaItemTypeVideo);
   140 			}
   143                 }
   141 		if (!imagefound)	        
   144             if (!imagefound)
   142 			{
   145                 {
   143 			aAttributeArray.Append(KGlxMediaItemTypeImage);
   146                 aAttributeArray.AppendL(KGlxMediaItemTypeImage);
   144 			}
   147                 }
   145 		if (!found)
   148             if (!found)
   146 			{
   149                 {
   147 			aAttributeArray.Append(KMPXMediaGeneralCount);
   150                 aAttributeArray.AppendL(KMPXMediaGeneralCount);
   148 			}
   151                 }
   149 				
   152 
   150 #else
   153 #else
   151 
   154 
   152 	for ( TInt index = 0 ; index < attrCount ; index++)
   155         for (TInt index = 0; index < attrCount; index++)
   153 			{
   156             {
   154 			if (aAttributeArray[index] == KMPXMediaGeneralCount)
   157             if (aAttributeArray[index] == KMPXMediaGeneralCount)
   155 				{
   158                 {
   156 				found = ETrue;	            
   159                 found = ETrue;
   157 				}			
   160                 }
   158 			}			
   161             }
   159 		if (!found)
   162         if (!found)
   160 			{
   163             {
   161 			aAttributeArray.Append(KMPXMediaGeneralCount);
   164             aAttributeArray.AppendL(KMPXMediaGeneralCount);
   162 			}       
   165             }
   163 #endif						
   166 #endif						
   164 		}
   167         }
   165 	}
   168     }
   166 
   169 
   167 // ----------------------------------------------------------------------------
   170 // ----------------------------------------------------------------------------
   168 // HandleCpiAttributeResponseL
   171 // HandleCpiAttributeResponseL
   169 // ----------------------------------------------------------------------------
   172 // ----------------------------------------------------------------------------
   170 // 
   173 // 
   171 void CGlxCollectionPluginCamera::HandleCpiAttributeResponseL(CMPXMedia* aResponse, TArray<TMPXAttribute> aCpiAttributes, TArray<TGlxMediaId> /* aMediaIds */)
   174 void CGlxCollectionPluginCamera::HandleCpiAttributeResponseL(
   172 	{
   175         CMPXMedia* aResponse, TArray<TMPXAttribute> aCpiAttributes, 
       
   176         TArray<TGlxMediaId> /* aMediaIds */)
       
   177     {
   173     TRACER("CGlxCollectionPluginCamera::HandleCpiAttributeResponseL");
   178     TRACER("CGlxCollectionPluginCamera::HandleCpiAttributeResponseL");
   174     
   179     
   175     _LIT(KResourceFile, "z:glxplugincamera.rsc");
   180     _LIT(KResourceFile, "z:glxplugincamera.rsc");
   176 
   181 
   177 	TInt count = aCpiAttributes.Count();
   182 	TInt count = aCpiAttributes.Count();
   214 				//No Images or Videos
   219 				//No Images or Videos
   215 				if ((0 == videoCount) && (0 == imageCount ))
   220 				if ((0 == videoCount) && (0 == imageCount ))
   216 					{	
   221 					{	
   217 					GLX_LOG_INFO("ImageCount and VideoCount is 0");
   222 					GLX_LOG_INFO("ImageCount and VideoCount is 0");
   218 									
   223 									
   219 					tempTitle = LoadLocalizedStringLC(KResourceFile, R_CAMERA_SUB_TITLE_NO_IMAGE_NO_VIDEO);
   224 					tempTitle = LoadLocalizedStringLC(KResourceFile, 
       
   225 					        R_CAMERA_SUB_TITLE_NO_IMAGE_NO_VIDEO);
   220 					aResponse->SetTextValueL(attr, *tempTitle);	
   226 					aResponse->SetTextValueL(attr, *tempTitle);	
   221 					}
   227 					}
   222 
   228 
   223 				// 1 Image and multi/0 Videos                		
   229 				// 1 Image and multi/0 Videos                		
   224 				else if (1 == imageCount) 
   230 				else if (1 == imageCount) 
   225 					{
   231 					{
   226 					GLX_LOG_INFO1("ImageCount is 0 and VideoCount is %d",videoCount);
   232 					GLX_LOG_INFO1("ImageCount is 0 and VideoCount is %d",videoCount);
   227 					
   233 					
   228 					tempTitle = LoadLocalizedStringLC(KResourceFile, R_CAMERA_SUB_TITLE_ONE_IMAGE_MULTI_VIDEO);
   234 					tempTitle = LoadLocalizedStringLC(KResourceFile, 
       
   235 					        R_CAMERA_SUB_TITLE_ONE_IMAGE_MULTI_VIDEO);
   229 
   236 
   230 					TPtr formatString = tempTitle->Des();
   237 					TPtr formatString = tempTitle->Des();
   231 
   238 
   232 					// Now create a buffer that will contain the result. needs to be length of format string plus a few extra for the number
   239 					// Now create a buffer that will contain the result. needs to be 
       
   240 					// length of format string plus a few extra for the number
   233 					HBufC* title = HBufC::NewLC(formatString.Length() + 10);
   241 					HBufC* title = HBufC::NewLC(formatString.Length() + 10);
   234 					TPtr ptr = title->Des();
   242 					TPtr ptr = title->Des();
   235 
   243 
   236 					StringLoader::Format(ptr, formatString, -1, videoCount);
   244 					StringLoader::Format(ptr, formatString, -1, videoCount);
   237 
   245 
   244 				// Multi/0 Image and 1 Video					
   252 				// Multi/0 Image and 1 Video					
   245 				else if (1 == videoCount)
   253 				else if (1 == videoCount)
   246 					{
   254 					{
   247 					GLX_LOG_INFO1("ImageCount is %d and VideoCount is 0",imageCount);
   255 					GLX_LOG_INFO1("ImageCount is %d and VideoCount is 0",imageCount);
   248 					
   256 					
   249 					tempTitle = LoadLocalizedStringLC(KResourceFile, R_CAMERA_SUB_TITLE_MULTI_IMAGE_ONE_VIDEO);                	
   257 					tempTitle = LoadLocalizedStringLC(KResourceFile, 
       
   258 					        R_CAMERA_SUB_TITLE_MULTI_IMAGE_ONE_VIDEO);                	
   250 
   259 
   251 					TPtr formatString = tempTitle->Des();
   260 					TPtr formatString = tempTitle->Des();
   252 
   261 
   253 					// Now create a buffer that will contain the result. needs to be length of format string plus a few extra for the number
   262 					// Now create a buffer that will contain the result. needs to be 
       
   263 					// length of format string plus a few extra for the number
   254 					HBufC* title = HBufC::NewLC(formatString.Length() + 10);
   264 					HBufC* title = HBufC::NewLC(formatString.Length() + 10);
   255 					TPtr ptr = title->Des();
   265 					TPtr ptr = title->Des();
   256 
   266 
   257 					StringLoader::Format(ptr, formatString, -1, imageCount);
   267 					StringLoader::Format(ptr, formatString, -1, imageCount);
   258 
   268 
   265 				// Multi Image and Multi Video
   275 				// Multi Image and Multi Video
   266 				else 
   276 				else 
   267 					{
   277 					{
   268 					GLX_LOG_INFO2("ImageCount is %d,VideoCount is %d",imageCount,videoCount);
   278 					GLX_LOG_INFO2("ImageCount is %d,VideoCount is %d",imageCount,videoCount);
   269 					
   279 					
   270 					tempTitle = LoadLocalizedStringLC(KResourceFile, R_CAMERA_SUB_TITLE_MULTI_IMAGE_MULTI_VIDEO);                	
   280 					tempTitle = LoadLocalizedStringLC(KResourceFile, 
       
   281 					        R_CAMERA_SUB_TITLE_MULTI_IMAGE_MULTI_VIDEO);                	
   271 					TPtr formatString = tempTitle->Des();	
   282 					TPtr formatString = tempTitle->Des();	
   272 
   283 
   273 					HBufC* title = HBufC::NewLC(formatString.Length() + 10);
   284 					HBufC* title = HBufC::NewLC(formatString.Length() + 10);
   274 					TPtr ptr = title->Des();
   285 					TPtr ptr = title->Des();
   275 
   286 
   288 				CleanupStack::PopAndDestroy(tempTitle);
   299 				CleanupStack::PopAndDestroy(tempTitle);
   289 
   300 
   290 #else
   301 #else
   291 				if(0 == usageCount)
   302 				if(0 == usageCount)
   292             		{
   303             		{
   293                 	tempTitle = LoadLocalizedStringLC(KResourceFile, R_CAMERA_SUB_TITLE_NO_IMAGE_NO_VIDEO);                	
   304                 	tempTitle = LoadLocalizedStringLC(KResourceFile, 
       
   305                 	        R_CAMERA_SUB_TITLE_NO_IMAGE_NO_VIDEO);                	
   294                 	// Set the title in the response.
   306                 	// Set the title in the response.
   295             		aResponse->SetTextValueL(attr, *tempTitle);  
   307             		aResponse->SetTextValueL(attr, *tempTitle);  
   296             		CleanupStack::PopAndDestroy(tempTitle);
   308             		CleanupStack::PopAndDestroy(tempTitle);
   297             		continue;                	
   309             		continue;                	
   298             		}
   310             		}
   308                     {
   320                     {
   309                     tempTitle = LoadLocalizedStringLC(KResourceFile, R_CAMERA_SUB_TITLE_MULTI);
   321                     tempTitle = LoadLocalizedStringLC(KResourceFile, R_CAMERA_SUB_TITLE_MULTI);
   310                     }
   322                     }
   311                 TPtr formatString = tempTitle->Des();
   323                 TPtr formatString = tempTitle->Des();
   312                 
   324                 
   313                 // Now create a buffer that will contain the result. needs to be length of format string plus a few extra for the number
   325                 // Now create a buffer that will contain the result. needs to be 
       
   326                 // length of format string plus a few extra for the number
   314                 HBufC* title = HBufC::NewLC(formatString.Length() + 10);
   327                 HBufC* title = HBufC::NewLC(formatString.Length() + 10);
   315                 TPtr ptr = title->Des();
   328                 TPtr ptr = title->Des();
   316                 StringLoader::Format(ptr, formatString, -1, usageCount);
   329                 StringLoader::Format(ptr, formatString, -1, usageCount);
   317                 
   330                 
   318                 // Set the title in the response.
   331                 // Set the title in the response.