mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetnumobjects.cpp
branchRCL_3
changeset 18 453dfc402455
parent 4 60a94a45d437
equal deleted inserted replaced
17:dbd1c5e08735 18:453dfc402455
    10 //
    10 //
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description:
    14 //
    14 //
       
    15 
    15 
    16 
    16 #include <mtp/tmtptyperequest.h>
    17 #include <mtp/tmtptyperequest.h>
    17 #include <mtp/mmtpdataproviderframework.h>
    18 #include <mtp/mmtpdataproviderframework.h>
    18 #include <mtp/mmtpobjectmgr.h>
    19 #include <mtp/mmtpobjectmgr.h>
    19 #include <mtp/mmtpdataprovider.h>
    20 #include <mtp/mmtpdataprovider.h>
   151     iTimeoutCount = 0;
   152     iTimeoutCount = 0;
   152     
   153     
   153 	if(iDevDpSingletons.DeviceDataStore().IsConnectMac()
   154 	if(iDevDpSingletons.DeviceDataStore().IsConnectMac()
   154         &&(KMTPFormatsAll == Request().Uint32(TMTPTypeRequest::ERequestParameter2)))
   155         &&(KMTPFormatsAll == Request().Uint32(TMTPTypeRequest::ERequestParameter2)))
   155         {
   156         {
   156         //get folder count
   157         TUint32 count(0);
   157     	TMTPObjectMgrQueryParams paramsFolder(Request().Uint32(TMTPTypeRequest::ERequestParameter1), EMTPFormatCodeAssociation, Request().Uint32(TMTPTypeRequest::ERequestParameter3));        
   158     	CMTPTypeArray *handles = CMTPTypeArray::NewLC(EMTPTypeAUINT32);
   158     	TUint32 count = iFramework.ObjectMgr().CountL(paramsFolder);
   159         HandleObjectHandlesUnderMacL(*handles);
   159         __FLOG_VA((_L8("ConnectMac and Fetch all, folder count = %d"), count));
   160         count = handles->NumElements();
   160 
   161         CleanupStack::PopAndDestroy(handles);         
   161         //get script count
       
   162         TMTPObjectMgrQueryParams paramsScript(Request().Uint32(TMTPTypeRequest::ERequestParameter1), EMTPFormatCodeScript, Request().Uint32(TMTPTypeRequest::ERequestParameter3));
       
   163         count += iFramework.ObjectMgr().CountL(paramsScript);
       
   164         
       
   165         //get Image file count
       
   166         TMTPObjectMgrQueryParams paramsImage(Request().Uint32(TMTPTypeRequest::ERequestParameter1), EMTPFormatCodeEXIFJPEG, Request().Uint32(TMTPTypeRequest::ERequestParameter3));
       
   167         count += iFramework.ObjectMgr().CountL(paramsImage);
       
   168         __FLOG_VA((_L8("ConnectMac and Fetch all, total count = %d"), count));        
   162         __FLOG_VA((_L8("ConnectMac and Fetch all, total count = %d"), count));        
   169     	SendResponseL(EMTPRespCodeOK, 1, &count); 
   163     	SendResponseL(EMTPRespCodeOK, 1, &count); 
   170         }
   164         }
   171     else
   165     else
   172         {       
   166         {       
   199 		}
   193 		}
   200 	return supported;	
   194 	return supported;	
   201 	}
   195 	}
   202 
   196 
   203 
   197 
   204 
   198 /**
   205 
   199 Handle special case under Mac.
   206 
   200 Only expose the Folder, Image File and Viedo, Script under Drive:\Images, Drive\Viedos
   207 
   201 */
   208 
   202 void CMTPGetNumObjects::HandleObjectHandlesUnderMacL(CMTPTypeArray &aObjectHandles)
   209 
   203     {
   210 
   204     __FLOG(_L8("HandleObjectHandlesUnderMacL - Entry"));
   211 
   205     
   212 
   206     CMTPTypeArray* totalHandles = CMTPTypeArray::NewLC(EMTPTypeAUINT32);
   213 	
   207     
   214 
   208     //get folder object handles    
   215 	
   209     GetObjectHandlesByFormatCodeL(EMTPFormatCodeAssociation,*totalHandles);
   216 
   210     
   217 
   211     //get image/jpeg object handles
   218    	
   212     GetObjectHandlesByFormatCodeL(EMTPFormatCodeEXIFJPEG,*totalHandles);
   219 
   213     //get image/bmp object handles
   220 	
   214     GetObjectHandlesByFormatCodeL(EMTPFormatCodeBMP,*totalHandles);
   221 
   215     //get image/jif object handles
   222 
   216     GetObjectHandlesByFormatCodeL(EMTPFormatCodeGIF,*totalHandles);
   223 
   217     //get image/jpeg object handles
   224 
   218     GetObjectHandlesByFormatCodeL(EMTPFormatCodePNG,*totalHandles);
   225 
   219     
   226 
   220     //get video/mp4 object handles
       
   221     GetObjectHandlesByFormatCodeL(EMTPFormatCodeMP4Container,*totalHandles);
       
   222     //get video/3gp object handles
       
   223     GetObjectHandlesByFormatCodeL(EMTPFormatCode3GPContainer,*totalHandles);
       
   224     //get video/wmv object handles
       
   225     GetObjectHandlesByFormatCodeL(EMTPFormatCodeWMV,*totalHandles); 
       
   226     //get video/asf object handles
       
   227     GetObjectHandlesByFormatCodeL(EMTPFormatCodeASF,*totalHandles); 
       
   228     
       
   229     //Filer the folder list, ?:\\Images\\* and ?:\\Videos\\*
       
   230     _LIT(KImagesFolderPre, "?:\\Images\\*");
       
   231     _LIT(KViedosFolderPre, "?:\\Videos\\*");    
       
   232    
       
   233     const TUint KCount(totalHandles->NumElements());
       
   234     
       
   235     for (TUint i(0); (i < KCount); i++)//handles loop
       
   236         {
       
   237          CMTPObjectMetaData* object(CMTPObjectMetaData::NewLC());
       
   238          iFramework.ObjectMgr().ObjectL(totalHandles->ElementUint(i),*object);
       
   239          const TDesC& suid(object->DesC(CMTPObjectMetaData::ESuid));
       
   240          
       
   241 #ifdef __FLOG_ACTIVE    
       
   242         TBuf8<KMaxFileName> tmp;
       
   243         tmp.Copy(suid);
       
   244         __FLOG_VA((_L8("HandleObjectHandlesUnderMacL - suid: %S"), &tmp));
       
   245 #endif // __FLOG_ACTIVE
       
   246          if((KErrNotFound != suid.MatchF(KImagesFolderPre)) ||
       
   247             (KErrNotFound != suid.MatchF(KViedosFolderPre)))
       
   248             {
       
   249         	_LIT(KComma,",");
       
   250         	_LIT(KLineation,"-");
       
   251         	_LIT(KUnderline,"_");
       
   252         	_LIT(Ksemicolon ,";");
       
   253             if((KErrNotFound != suid.Find(KComma))||
       
   254                 (KErrNotFound != suid.Find(KLineation))||
       
   255                 (KErrNotFound != suid.Find(KUnderline))||
       
   256                 (KErrNotFound != suid.Find(Ksemicolon)))
       
   257                 {
       
   258                 __FLOG(_L8("HandleObjectHandlesUnderMacL - Skip handle"));
       
   259                 }
       
   260             else
       
   261                 {
       
   262                 __FLOG_VA((_L8("HandleObjectHandlesUnderMacL - Add handle: %x"), totalHandles->ElementUint(i)));
       
   263                 RArray<TUint>   tmphandles;
       
   264                 CleanupClosePushL(tmphandles);
       
   265                 tmphandles.AppendL(totalHandles->ElementUint(i));
       
   266                 aObjectHandles.AppendL(tmphandles);
       
   267                 CleanupStack::PopAndDestroy(&tmphandles);                
       
   268                 }
       
   269             }
       
   270          CleanupStack::PopAndDestroy(object);
       
   271         }
       
   272     
       
   273     CleanupStack::PopAndDestroy(totalHandles);
       
   274     //get script object handles    
       
   275     GetObjectHandlesByFormatCodeL(EMTPFormatCodeScript,aObjectHandles);
       
   276     
       
   277     __FLOG(_L8("HandleObjectHandlesUnderMacL - Exit"));    
       
   278     }
       
   279 /**
       
   280 Get Object Handles by format code
       
   281 */
       
   282 void CMTPGetNumObjects::GetObjectHandlesByFormatCodeL(TUint32 aFormatCode, CMTPTypeArray &aObjectHandles)
       
   283     {
       
   284     __FLOG_VA((_L8("GetObjectHandlesByFormatCodeL - Entry FormatCode: %x"), aFormatCode));    
       
   285     RMTPObjectMgrQueryContext   context;
       
   286     RArray<TUint>               handles;   
       
   287     CleanupClosePushL(context);
       
   288     CleanupClosePushL(handles);    
       
   289     TMTPObjectMgrQueryParams    paramsFolder(Request().Uint32(TMTPTypeRequest::ERequestParameter1), aFormatCode, Request().Uint32(TMTPTypeRequest::ERequestParameter3));  
       
   290     do
       
   291         {
       
   292         iFramework.ObjectMgr().GetObjectHandlesL(paramsFolder, context, handles);
       
   293         aObjectHandles.AppendL(handles);
       
   294         }
       
   295     while (!context.QueryComplete());
       
   296     CleanupStack::PopAndDestroy(&context);
       
   297     CleanupStack::PopAndDestroy(&handles);
       
   298     __FLOG(_L8("GetObjectHandlesByFormatCode - Exit"));    
       
   299     }
       
   300