mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetnumobjects.cpp
changeset 49 c20dd21d1eb4
parent 31 a26669f87b46
equal deleted inserted replaced
41:2c19c7cf5550 49:c20dd21d1eb4
    27 #include "cmtpdataprovidercontroller.h"
    27 #include "cmtpdataprovidercontroller.h"
    28 
    28 
    29 #include "cmtpgetnumobjects.h"
    29 #include "cmtpgetnumobjects.h"
    30 #include "mtpdevicedpconst.h"
    30 #include "mtpdevicedpconst.h"
    31 #include "mtpdevdppanic.h"
    31 #include "mtpdevdppanic.h"
       
    32 #include "OstTraceDefinitions.h"
       
    33 #ifdef OST_TRACE_COMPILER_IN_USE
       
    34 #include "cmtpgetnumobjectsTraces.h"
       
    35 #endif
       
    36 
    32 
    37 
    33 // Class constants.
    38 // Class constants.
    34 __FLOG_STMT(_LIT8(KComponent,"GetNumObjects");)
       
    35 static const TInt KMTPGetObjectNumTimeOut(1);
    39 static const TInt KMTPGetObjectNumTimeOut(1);
    36 
    40 
    37 /**
    41 /**
    38 Verification data for GetNumObjects request
    42 Verification data for GetNumObjects request
    39 */
    43 */
    65 */	
    69 */	
    66 CMTPGetNumObjects::~CMTPGetNumObjects()
    70 CMTPGetNumObjects::~CMTPGetNumObjects()
    67 	{	
    71 	{	
    68 	iDevDpSingletons.Close();
    72 	iDevDpSingletons.Close();
    69     iSingletons.Close();
    73     iSingletons.Close();
    70     __FLOG_CLOSE;
       
    71 	}
    74 	}
    72 /**
    75 /**
    73 Standard c++ constructor
    76 Standard c++ constructor
    74 */	
    77 */	
    75 CMTPGetNumObjects::CMTPGetNumObjects(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
    78 CMTPGetNumObjects::CMTPGetNumObjects(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
    81 /**
    84 /**
    82 Second phase constructor.
    85 Second phase constructor.
    83 */
    86 */
    84 void CMTPGetNumObjects::ConstructL()
    87 void CMTPGetNumObjects::ConstructL()
    85     {
    88     {
    86 	__FLOG_OPEN(KMTPSubsystem, KComponent);
       
    87     iSingletons.OpenL();
    89     iSingletons.OpenL();
    88     iDevDpSingletons.OpenL(iFramework);
    90     iDevDpSingletons.OpenL(iFramework);
    89     }
    91     }
    90 
    92 
    91 TMTPResponseCode CMTPGetNumObjects::CheckRequestL()
    93 TMTPResponseCode CMTPGetNumObjects::CheckRequestL()
   120 /**
   122 /**
   121 GetNumObjects request handler
   123 GetNumObjects request handler
   122 */	
   124 */	
   123 void CMTPGetNumObjects::ServiceL()
   125 void CMTPGetNumObjects::ServiceL()
   124 	{
   126 	{
   125     __FLOG(_L8("ServiceL - Entry"));
   127     OstTraceFunctionEntry0( CMTPGETNUMOBJECTS_SERVICEL_ENTRY );
   126     __FLOG_VA((_L8("IsConnectMac = %d; ERequestParameter2 = %d" ), iDevDpSingletons.DeviceDataStore().IsConnectMac(), Request().Uint32(TMTPTypeRequest::ERequestParameter2)));
   128     OstTraceExt2( TRACE_NORMAL, CMTPGETNUMOBJECTS_SERVICEL, 
       
   129             "IsConnectMac = %d; ERequestParameter2 = %d", iDevDpSingletons.DeviceDataStore().IsConnectMac(), Request().Uint32(TMTPTypeRequest::ERequestParameter2));
   127     
   130     
   128     if(iSingletons.DpController().EnumerateState() != CMTPDataProviderController::EEnumeratedFulllyCompleted)
   131     if(iSingletons.DpController().EnumerateState() != CMTPDataProviderController::EEnumeratedFulllyCompleted)
   129         {
   132         {
   130         TUint storageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
   133         TUint storageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
   131         TUint handle = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
   134         TUint handle = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
   133         if ( (enumerateState < CMTPDataProviderController::EEnumeratingPhaseOneDone)
   136         if ( (enumerateState < CMTPDataProviderController::EEnumeratingPhaseOneDone)
   134             || (enumerateState != CMTPDataProviderController::EEnumeratedFulllyCompleted && handle != KMTPHandleAll))
   137             || (enumerateState != CMTPDataProviderController::EEnumeratedFulllyCompleted && handle != KMTPHandleAll))
   135             {
   138             {
   136             if (iTimeoutCount++ >= KMTPGetObjectNumTimeOut)
   139             if (iTimeoutCount++ >= KMTPGetObjectNumTimeOut)
   137                 {
   140                 {
   138                 __FLOG(_L8("Wait for enumeration time out, return busy."));
   141                 OstTrace0( TRACE_NORMAL, DUP1_CMTPGETNUMOBJECTS_SERVICEL, 
       
   142                         "Wait for enumeration time out, return busy." );
   139                 SendResponseL(EMTPRespCodeDeviceBusy);
   143                 SendResponseL(EMTPRespCodeDeviceBusy);
   140                 iTimeoutCount = 0;
   144                 iTimeoutCount = 0;
       
   145                 OstTraceFunctionExit0( CMTPGETNUMOBJECTS_SERVICEL_EXIT );
   141                 return;
   146                 return;
   142                 }
   147                 }
   143             else
   148             else
   144                 {
   149                 {
   145                 __FLOG(_L8("Enumeration not completed, suspend request."));
   150                 OstTrace0( TRACE_NORMAL, DUP2_CMTPGETNUMOBJECTS_SERVICEL, 
       
   151                         "Enumeration not completed, suspend request." );
   146                 RegisterPendingRequest(20);
   152                 RegisterPendingRequest(20);
       
   153                 OstTraceFunctionExit0( DUP1_CMTPGETNUMOBJECTS_SERVICEL_EXIT );
   147                 return; 
   154                 return; 
   148                 }
   155                 }
   149             }
   156             }
   150         }
   157         }
   151     
   158     
   157         TUint32 count(0);
   164         TUint32 count(0);
   158     	CMTPTypeArray *handles = CMTPTypeArray::NewLC(EMTPTypeAUINT32);
   165     	CMTPTypeArray *handles = CMTPTypeArray::NewLC(EMTPTypeAUINT32);
   159         HandleObjectHandlesUnderMacL(*handles);
   166         HandleObjectHandlesUnderMacL(*handles);
   160         count = handles->NumElements();
   167         count = handles->NumElements();
   161         CleanupStack::PopAndDestroy(handles);         
   168         CleanupStack::PopAndDestroy(handles);         
   162         __FLOG_VA((_L8("ConnectMac and Fetch all, total count = %d"), count));        
   169         OstTrace1( TRACE_NORMAL, DUP3_CMTPGETNUMOBJECTS_SERVICEL, 
       
   170                 "ConnectMac and Fetch all, total count = %d", count );           
   163     	SendResponseL(EMTPRespCodeOK, 1, &count); 
   171     	SendResponseL(EMTPRespCodeOK, 1, &count); 
   164         }
   172         }
   165     else
   173     else
   166         {       
   174         {       
   167     	TMTPObjectMgrQueryParams params(Request().Uint32(TMTPTypeRequest::ERequestParameter1), Request().Uint32(TMTPTypeRequest::ERequestParameter2), Request().Uint32(TMTPTypeRequest::ERequestParameter3));
   175     	TMTPObjectMgrQueryParams params(Request().Uint32(TMTPTypeRequest::ERequestParameter1), Request().Uint32(TMTPTypeRequest::ERequestParameter2), Request().Uint32(TMTPTypeRequest::ERequestParameter3));
   168     	TUint32 count = iFramework.ObjectMgr().CountL(params);	
   176     	TUint32 count = iFramework.ObjectMgr().CountL(params);	
   169         __FLOG_VA((_L8("NOT ConnectMac or NOT Fetch all, total count = %d"), count));         
   177         OstTrace1( TRACE_NORMAL, DUP4_CMTPGETNUMOBJECTS_SERVICEL, 
   170     	SendResponseL(EMTPRespCodeOK, 1, &count);
   178                 "NOT ConnectMac or NOT Fetch all, total count = %d", count );
   171         }
   179         SendResponseL(EMTPRespCodeOK, 1, &count);
   172     __FLOG(_L8("ServiceL - Exit"));	    
   180         }
       
   181 	OstTraceFunctionExit0( DUP2_CMTPGETNUMOBJECTS_SERVICEL_EXIT );
   173 	}
   182 	}
   174 
   183 
   175 /**
   184 /**
   176 Check if the format code is supported by the current installed data providers
   185 Check if the format code is supported by the current installed data providers
   177 */	
   186 */	
   199 Handle special case under Mac.
   208 Handle special case under Mac.
   200 Only expose the Folder, Image File and Viedo, Script under Drive:\Images, Drive\Viedos
   209 Only expose the Folder, Image File and Viedo, Script under Drive:\Images, Drive\Viedos
   201 */
   210 */
   202 void CMTPGetNumObjects::HandleObjectHandlesUnderMacL(CMTPTypeArray &aObjectHandles)
   211 void CMTPGetNumObjects::HandleObjectHandlesUnderMacL(CMTPTypeArray &aObjectHandles)
   203     {
   212     {
   204     __FLOG(_L8("HandleObjectHandlesUnderMacL - Entry"));
   213     OstTraceFunctionEntry0( CMTPGETNUMOBJECTS_HANDLEOBJECTHANDLESUNDERMACL_ENTRY );
   205     
   214     
   206     CMTPTypeArray* totalHandles = CMTPTypeArray::NewLC(EMTPTypeAUINT32);
   215     CMTPTypeArray* totalHandles = CMTPTypeArray::NewLC(EMTPTypeAUINT32);
   207     
   216     
   208     //get folder object handles    
   217     //get folder object handles    
   209     GetObjectHandlesByFormatCodeL(EMTPFormatCodeAssociation,*totalHandles);
   218     GetObjectHandlesByFormatCodeL(EMTPFormatCodeAssociation,*totalHandles);
   236         {
   245         {
   237          CMTPObjectMetaData* object(CMTPObjectMetaData::NewLC());
   246          CMTPObjectMetaData* object(CMTPObjectMetaData::NewLC());
   238          iFramework.ObjectMgr().ObjectL(totalHandles->ElementUint(i),*object);
   247          iFramework.ObjectMgr().ObjectL(totalHandles->ElementUint(i),*object);
   239          const TDesC& suid(object->DesC(CMTPObjectMetaData::ESuid));
   248          const TDesC& suid(object->DesC(CMTPObjectMetaData::ESuid));
   240          
   249          
   241 #ifdef __FLOG_ACTIVE    
   250 #ifdef OST_TRACE_COMPILER_IN_USE    
   242         TBuf8<KMaxFileName> tmp;
   251         TBuf8<KMaxFileName> tmp;
   243         tmp.Copy(suid);
   252         tmp.Copy(suid);
   244         __FLOG_VA((_L8("HandleObjectHandlesUnderMacL - suid: %S"), &tmp));
   253         OstTraceExt1( TRACE_NORMAL, DUP2_CMTPGETNUMOBJECTS_HANDLEOBJECTHANDLESUNDERMACL, 
   245 #endif // __FLOG_ACTIVE
   254                 "HandleObjectHandlesUnderMacL - suid: %s", tmp);       
       
   255 #endif // OST_TRACE_COMPILER_IN_USE
   246          if((KErrNotFound != suid.MatchF(KImagesFolderPre)) ||
   256          if((KErrNotFound != suid.MatchF(KImagesFolderPre)) ||
   247             (KErrNotFound != suid.MatchF(KViedosFolderPre)))
   257             (KErrNotFound != suid.MatchF(KViedosFolderPre)))
   248             {
   258             {
   249         	_LIT(KComma,",");
   259         	_LIT(KComma,",");
   250         	_LIT(KLineation,"-");
   260         	_LIT(KLineation,"-");
   253             if((KErrNotFound != suid.Find(KComma))||
   263             if((KErrNotFound != suid.Find(KComma))||
   254                 (KErrNotFound != suid.Find(KLineation))||
   264                 (KErrNotFound != suid.Find(KLineation))||
   255                 (KErrNotFound != suid.Find(KUnderline))||
   265                 (KErrNotFound != suid.Find(KUnderline))||
   256                 (KErrNotFound != suid.Find(Ksemicolon)))
   266                 (KErrNotFound != suid.Find(Ksemicolon)))
   257                 {
   267                 {
   258                 __FLOG(_L8("HandleObjectHandlesUnderMacL - Skip handle"));
   268                 OstTrace0( TRACE_NORMAL, CMTPGETNUMOBJECTS_HANDLEOBJECTHANDLESUNDERMACL, 
       
   269                         "HandleObjectHandlesUnderMacL - Skip handle" );              
   259                 }
   270                 }
   260             else
   271             else
   261                 {
   272                 {
   262                 __FLOG_VA((_L8("HandleObjectHandlesUnderMacL - Add handle: %x"), totalHandles->ElementUint(i)));
   273                 OstTrace1( TRACE_NORMAL, DUP1_CMTPGETNUMOBJECTS_HANDLEOBJECTHANDLESUNDERMACL, 
       
   274                         "HandleObjectHandlesUnderMacL - Add handle: %x", totalHandles->ElementUint(i));
   263                 RArray<TUint>   tmphandles;
   275                 RArray<TUint>   tmphandles;
   264                 CleanupClosePushL(tmphandles);
   276                 CleanupClosePushL(tmphandles);
   265                 tmphandles.AppendL(totalHandles->ElementUint(i));
   277                 tmphandles.AppendL(totalHandles->ElementUint(i));
   266                 aObjectHandles.AppendL(tmphandles);
   278                 aObjectHandles.AppendL(tmphandles);
   267                 CleanupStack::PopAndDestroy(&tmphandles);                
   279                 CleanupStack::PopAndDestroy(&tmphandles);                
   272     
   284     
   273     CleanupStack::PopAndDestroy(totalHandles);
   285     CleanupStack::PopAndDestroy(totalHandles);
   274     //get script object handles    
   286     //get script object handles    
   275     GetObjectHandlesByFormatCodeL(EMTPFormatCodeScript,aObjectHandles);
   287     GetObjectHandlesByFormatCodeL(EMTPFormatCodeScript,aObjectHandles);
   276     
   288     
   277     __FLOG(_L8("HandleObjectHandlesUnderMacL - Exit"));    
   289     OstTraceFunctionExit0( CMTPGETNUMOBJECTS_HANDLEOBJECTHANDLESUNDERMACL_EXIT );
   278     }
   290     }
   279 /**
   291 /**
   280 Get Object Handles by format code
   292 Get Object Handles by format code
   281 */
   293 */
   282 void CMTPGetNumObjects::GetObjectHandlesByFormatCodeL(TUint32 aFormatCode, CMTPTypeArray &aObjectHandles)
   294 void CMTPGetNumObjects::GetObjectHandlesByFormatCodeL(TUint32 aFormatCode, CMTPTypeArray &aObjectHandles)
   283     {
   295     {
   284     __FLOG_VA((_L8("GetObjectHandlesByFormatCodeL - Entry FormatCode: %x"), aFormatCode));    
   296     OstTraceFunctionEntry0( CMTPGETNUMOBJECTS_GETOBJECTHANDLESBYFORMATCODEL_ENTRY );
       
   297     OstTrace1( TRACE_NORMAL, CMTPGETNUMOBJECTS_GETOBJECTHANDLESBYFORMATCODEL, 
       
   298             "FormatCode: %x",  aFormatCode); 
   285     RMTPObjectMgrQueryContext   context;
   299     RMTPObjectMgrQueryContext   context;
   286     RArray<TUint>               handles;   
   300     RArray<TUint>               handles;   
   287     CleanupClosePushL(context);
   301     CleanupClosePushL(context);
   288     CleanupClosePushL(handles);    
   302     CleanupClosePushL(handles);    
   289     TMTPObjectMgrQueryParams    paramsFolder(Request().Uint32(TMTPTypeRequest::ERequestParameter1), aFormatCode, Request().Uint32(TMTPTypeRequest::ERequestParameter3));  
   303     TMTPObjectMgrQueryParams    paramsFolder(Request().Uint32(TMTPTypeRequest::ERequestParameter1), aFormatCode, Request().Uint32(TMTPTypeRequest::ERequestParameter3));  
   293         aObjectHandles.AppendL(handles);
   307         aObjectHandles.AppendL(handles);
   294         }
   308         }
   295     while (!context.QueryComplete());
   309     while (!context.QueryComplete());
   296     CleanupStack::PopAndDestroy(&context);
   310     CleanupStack::PopAndDestroy(&context);
   297     CleanupStack::PopAndDestroy(&handles);
   311     CleanupStack::PopAndDestroy(&handles);
   298     __FLOG(_L8("GetObjectHandlesByFormatCode - Exit"));    
   312     OstTraceFunctionExit0( CMTPGETNUMOBJECTS_GETOBJECTHANDLESBYFORMATCODEL_EXIT );
   299     }
   313     }
   300 
   314