mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetobjecthandles.cpp
branchRCL_3
changeset 12 8b094906a049
parent 0 d0791faffa3f
child 14 60a94a45d437
equal deleted inserted replaced
11:4843bb5893b6 12:8b094906a049
    16 #include <mtp/tmtptyperequest.h>
    16 #include <mtp/tmtptyperequest.h>
    17 #include <mtp/mmtpdataproviderframework.h>
    17 #include <mtp/mmtpdataproviderframework.h>
    18 #include <mtp/mmtpobjectmgr.h>
    18 #include <mtp/mmtpobjectmgr.h>
    19 #include <mtp/cmtptypearray.h>
    19 #include <mtp/cmtptypearray.h>
    20 #include <mtp/mtpdatatypeconstants.h>
    20 #include <mtp/mtpdatatypeconstants.h>
       
    21 #include <mtp/mmtpstoragemgr.h>  
    21 
    22 
       
    23 #include "cmtpdevicedatastore.h"
    22 #include "cmtpgetobjecthandles.h"
    24 #include "cmtpgetobjecthandles.h"
    23 #include "mtpdevicedpconst.h"
    25 #include "mtpdevicedpconst.h"
    24 #include "mtpdevdppanic.h"
    26 #include "mtpdevdppanic.h"
    25 
    27 
       
    28 // Class constants.
       
    29 __FLOG_STMT(_LIT8(KComponent,"GetObjectHandles");)
    26 
    30 
    27 /**
    31 /**
    28 Two-phase construction method
    32 Two-phase construction method
    29 @param aPlugin	The data provider plugin
    33 @param aPlugin	The data provider plugin
    30 @param aFramework	The data provider framework
    34 @param aFramework	The data provider framework
    43 /**
    47 /**
    44 GetObjectHandles request handler
    48 GetObjectHandles request handler
    45 */	
    49 */	
    46 CMTPGetObjectHandles::~CMTPGetObjectHandles()
    50 CMTPGetObjectHandles::~CMTPGetObjectHandles()
    47 	{
    51 	{
    48 	delete iHandles;	
    52 	delete iHandles;
       
    53     __FLOG_CLOSE;
    49 	}
    54 	}
    50 
    55 
    51 /**
    56 /**
    52 Standard c++ constructor
    57 Standard c++ constructor
    53 */	
    58 */	
    60 /**
    65 /**
    61 Second phase constructor.
    66 Second phase constructor.
    62 */
    67 */
    63 void CMTPGetObjectHandles::ConstructL()
    68 void CMTPGetObjectHandles::ConstructL()
    64     {
    69     {
       
    70 	__FLOG_OPEN(KMTPSubsystem, KComponent);    
    65     CMTPGetNumObjects::ConstructL();
    71     CMTPGetNumObjects::ConstructL();
    66     }
    72     }
    67 
    73 
    68 /**
    74 /**
    69 GetObjectHandles request handler
    75 GetObjectHandles request handler
    70 */	
    76 */	
    71 void CMTPGetObjectHandles::ServiceL()
    77 void CMTPGetObjectHandles::ServiceL()
    72 	{
    78 	{
       
    79     __FLOG(_L8("ServiceL - Entry"));
    73 	RMTPObjectMgrQueryContext   context;
    80 	RMTPObjectMgrQueryContext   context;
    74 	RArray<TUint>               handles;
    81 	RArray<TUint>               handles;
    75 	TMTPObjectMgrQueryParams    params(Request().Uint32(TMTPTypeRequest::ERequestParameter1), Request().Uint32(TMTPTypeRequest::ERequestParameter2), Request().Uint32(TMTPTypeRequest::ERequestParameter3));
       
    76 	CleanupClosePushL(context);
    82 	CleanupClosePushL(context);
    77 	CleanupClosePushL(handles);
    83 	CleanupClosePushL(handles);
    78 	
       
    79 	delete iHandles;
    84 	delete iHandles;
    80 	iHandles = CMTPTypeArray::NewL(EMTPTypeAUINT32);
    85 	iHandles = CMTPTypeArray::NewL(EMTPTypeAUINT32);
    81 	
    86 
    82 	do
    87     __FLOG_VA((_L8("IsConnectMac = %d; ERequestParameter2 = %d" ), iDevDpSingletons.DeviceDataStore().IsConnectMac(), Request().Uint32(TMTPTypeRequest::ERequestParameter2)));
    83 	    {
    88 	if(iDevDpSingletons.DeviceDataStore().IsConnectMac()
    84     	iFramework.ObjectMgr().GetObjectHandlesL(params, context, handles);
    89        &&(KMTPFormatsAll == Request().Uint32(TMTPTypeRequest::ERequestParameter2)))
    85     	iHandles->AppendL(handles);
    90         {
    86 	    }
    91         __FLOG(_L8("ConnectMac and Fetch all."));
    87 	while (!context.QueryComplete());
    92         //get folder object handles
    88 	
    93     	TMTPObjectMgrQueryParams    paramsFolder(Request().Uint32(TMTPTypeRequest::ERequestParameter1), EMTPFormatCodeAssociation, Request().Uint32(TMTPTypeRequest::ERequestParameter3));	
       
    94     	do
       
    95     	    {
       
    96         	iFramework.ObjectMgr().GetObjectHandlesL(paramsFolder, context, handles);
       
    97         	iHandles->AppendL(handles);
       
    98     	    }
       
    99     	while (!context.QueryComplete());
       
   100 
       
   101         //get script object handles
       
   102     	RMTPObjectMgrQueryContext   contextScript;
       
   103     	RArray<TUint>               handlesScript;
       
   104     	CleanupClosePushL(contextScript);
       
   105     	CleanupClosePushL(handlesScript);            
       
   106     	TMTPObjectMgrQueryParams    paramsScript(Request().Uint32(TMTPTypeRequest::ERequestParameter1), EMTPFormatCodeScript, Request().Uint32(TMTPTypeRequest::ERequestParameter3));	
       
   107     	do
       
   108     	    {
       
   109         	iFramework.ObjectMgr().GetObjectHandlesL(paramsScript, contextScript, handlesScript);
       
   110         	iHandles->AppendL(handlesScript);
       
   111     	    }
       
   112     	while (!contextScript.QueryComplete());
       
   113     	CleanupStack::PopAndDestroy(&contextScript);
       
   114     	CleanupStack::PopAndDestroy(&handlesScript);        
       
   115 
       
   116         //get image object handles
       
   117     	RMTPObjectMgrQueryContext   contextImage;
       
   118     	RArray<TUint>               handlesImage;
       
   119     	CleanupClosePushL(contextImage);
       
   120     	CleanupClosePushL(handlesImage);            
       
   121     	TMTPObjectMgrQueryParams    paramsImage(Request().Uint32(TMTPTypeRequest::ERequestParameter1), EMTPFormatCodeEXIFJPEG, Request().Uint32(TMTPTypeRequest::ERequestParameter3));	
       
   122     	do
       
   123     	    {
       
   124         	iFramework.ObjectMgr().GetObjectHandlesL(paramsImage, contextImage, handlesImage);
       
   125         	iHandles->AppendL(handlesImage);
       
   126     	    }
       
   127     	while (!contextImage.QueryComplete());
       
   128     	CleanupStack::PopAndDestroy(&contextImage);
       
   129     	CleanupStack::PopAndDestroy(&handlesImage);                            
       
   130         }
       
   131     else
       
   132         {
       
   133     	TMTPObjectMgrQueryParams    params(Request().Uint32(TMTPTypeRequest::ERequestParameter1), Request().Uint32(TMTPTypeRequest::ERequestParameter2), Request().Uint32(TMTPTypeRequest::ERequestParameter3));	
       
   134     	do
       
   135     	    {
       
   136         	iFramework.ObjectMgr().GetObjectHandlesL(params, context, handles);
       
   137 			
       
   138         	TUint32 storageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
       
   139         	TUint32 parentHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
       
   140         	if ( storageId != KMTPStorageAll && parentHandle == KMTPHandleNoParent )
       
   141 	            {
       
   142 	            const CMTPStorageMetaData& storage(iFramework.StorageMgr().StorageL(storageId));
       
   143 	            HBufC* StorageSuid = storage.DesC(CMTPStorageMetaData::EStorageSuid).AllocL();
       
   144             
       
   145 	            RBuf suid;
       
   146 	            suid.CleanupClosePushL();
       
   147 	            suid.CreateL(KMaxFileName);
       
   148 	            suid = *StorageSuid;
       
   149 	            _LIT(WMPInfoXml,"WMPInfo.xml");
       
   150 	            suid.Append(WMPInfoXml); 
       
   151 	            TUint32 handle = iFramework.ObjectMgr().HandleL(suid);
       
   152 	            if ( handle != KMTPHandleNone )
       
   153 	                {
       
   154 	                TInt index = handles.Find(handle);
       
   155 	                if ( index != KErrNotFound )
       
   156 	                    {
       
   157 	                    handles.Remove(index);
       
   158 	                    handles.Insert(handle,0);
       
   159 	                    }
       
   160 	                }   
       
   161 	            delete StorageSuid;
       
   162 	            StorageSuid = NULL;
       
   163 	            CleanupStack::PopAndDestroy();
       
   164             	}
       
   165         	iHandles->AppendL(handles);
       
   166     	    }
       
   167     	while (!context.QueryComplete());        
       
   168         }        
       
   169     	
       
   170         
       
   171 
    89 	CleanupStack::PopAndDestroy(&handles);
   172 	CleanupStack::PopAndDestroy(&handles);
    90 	CleanupStack::PopAndDestroy(&context);					
   173 	CleanupStack::PopAndDestroy(&context);					
    91 	SendDataL(*iHandles);	
   174 	SendDataL(*iHandles);
       
   175     __FLOG(_L8("ServiceL - Exit"));	    
    92 	}
   176 	}
    93 
       
    94 
       
    95 
       
    96 
       
    97 
       
    98 
       
    99 	
   177 	
   100 
       
   101 	
       
   102 
       
   103 
       
   104    	
       
   105 
       
   106 	
       
   107 
       
   108 
       
   109 
       
   110 
       
   111 
       
   112