mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetobjecthandles.cpp
branchRCL_3
changeset 12 8b094906a049
parent 0 d0791faffa3f
child 14 60a94a45d437
--- a/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetobjecthandles.cpp	Fri Mar 12 15:46:41 2010 +0200
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetobjecthandles.cpp	Mon Mar 15 12:43:12 2010 +0200
@@ -18,11 +18,15 @@
 #include <mtp/mmtpobjectmgr.h>
 #include <mtp/cmtptypearray.h>
 #include <mtp/mtpdatatypeconstants.h>
+#include <mtp/mmtpstoragemgr.h>  
 
+#include "cmtpdevicedatastore.h"
 #include "cmtpgetobjecthandles.h"
 #include "mtpdevicedpconst.h"
 #include "mtpdevdppanic.h"
 
+// Class constants.
+__FLOG_STMT(_LIT8(KComponent,"GetObjectHandles");)
 
 /**
 Two-phase construction method
@@ -45,7 +49,8 @@
 */	
 CMTPGetObjectHandles::~CMTPGetObjectHandles()
 	{
-	delete iHandles;	
+	delete iHandles;
+    __FLOG_CLOSE;
 	}
 
 /**
@@ -62,6 +67,7 @@
 */
 void CMTPGetObjectHandles::ConstructL()
     {
+	__FLOG_OPEN(KMTPSubsystem, KComponent);    
     CMTPGetNumObjects::ConstructL();
     }
 
@@ -70,43 +76,102 @@
 */	
 void CMTPGetObjectHandles::ServiceL()
 	{
+    __FLOG(_L8("ServiceL - Entry"));
 	RMTPObjectMgrQueryContext   context;
 	RArray<TUint>               handles;
-	TMTPObjectMgrQueryParams    params(Request().Uint32(TMTPTypeRequest::ERequestParameter1), Request().Uint32(TMTPTypeRequest::ERequestParameter2), Request().Uint32(TMTPTypeRequest::ERequestParameter3));
 	CleanupClosePushL(context);
 	CleanupClosePushL(handles);
-	
 	delete iHandles;
 	iHandles = CMTPTypeArray::NewL(EMTPTypeAUINT32);
-	
-	do
-	    {
-    	iFramework.ObjectMgr().GetObjectHandlesL(params, context, handles);
-    	iHandles->AppendL(handles);
-	    }
-	while (!context.QueryComplete());
-	
+
+    __FLOG_VA((_L8("IsConnectMac = %d; ERequestParameter2 = %d" ), iDevDpSingletons.DeviceDataStore().IsConnectMac(), Request().Uint32(TMTPTypeRequest::ERequestParameter2)));
+	if(iDevDpSingletons.DeviceDataStore().IsConnectMac()
+       &&(KMTPFormatsAll == Request().Uint32(TMTPTypeRequest::ERequestParameter2)))
+        {
+        __FLOG(_L8("ConnectMac and Fetch all."));
+        //get folder object handles
+    	TMTPObjectMgrQueryParams    paramsFolder(Request().Uint32(TMTPTypeRequest::ERequestParameter1), EMTPFormatCodeAssociation, Request().Uint32(TMTPTypeRequest::ERequestParameter3));	
+    	do
+    	    {
+        	iFramework.ObjectMgr().GetObjectHandlesL(paramsFolder, context, handles);
+        	iHandles->AppendL(handles);
+    	    }
+    	while (!context.QueryComplete());
+
+        //get script object handles
+    	RMTPObjectMgrQueryContext   contextScript;
+    	RArray<TUint>               handlesScript;
+    	CleanupClosePushL(contextScript);
+    	CleanupClosePushL(handlesScript);            
+    	TMTPObjectMgrQueryParams    paramsScript(Request().Uint32(TMTPTypeRequest::ERequestParameter1), EMTPFormatCodeScript, Request().Uint32(TMTPTypeRequest::ERequestParameter3));	
+    	do
+    	    {
+        	iFramework.ObjectMgr().GetObjectHandlesL(paramsScript, contextScript, handlesScript);
+        	iHandles->AppendL(handlesScript);
+    	    }
+    	while (!contextScript.QueryComplete());
+    	CleanupStack::PopAndDestroy(&contextScript);
+    	CleanupStack::PopAndDestroy(&handlesScript);        
+
+        //get image object handles
+    	RMTPObjectMgrQueryContext   contextImage;
+    	RArray<TUint>               handlesImage;
+    	CleanupClosePushL(contextImage);
+    	CleanupClosePushL(handlesImage);            
+    	TMTPObjectMgrQueryParams    paramsImage(Request().Uint32(TMTPTypeRequest::ERequestParameter1), EMTPFormatCodeEXIFJPEG, Request().Uint32(TMTPTypeRequest::ERequestParameter3));	
+    	do
+    	    {
+        	iFramework.ObjectMgr().GetObjectHandlesL(paramsImage, contextImage, handlesImage);
+        	iHandles->AppendL(handlesImage);
+    	    }
+    	while (!contextImage.QueryComplete());
+    	CleanupStack::PopAndDestroy(&contextImage);
+    	CleanupStack::PopAndDestroy(&handlesImage);                            
+        }
+    else
+        {
+    	TMTPObjectMgrQueryParams    params(Request().Uint32(TMTPTypeRequest::ERequestParameter1), Request().Uint32(TMTPTypeRequest::ERequestParameter2), Request().Uint32(TMTPTypeRequest::ERequestParameter3));	
+    	do
+    	    {
+        	iFramework.ObjectMgr().GetObjectHandlesL(params, context, handles);
+			
+        	TUint32 storageId = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
+        	TUint32 parentHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
+        	if ( storageId != KMTPStorageAll && parentHandle == KMTPHandleNoParent )
+	            {
+	            const CMTPStorageMetaData& storage(iFramework.StorageMgr().StorageL(storageId));
+	            HBufC* StorageSuid = storage.DesC(CMTPStorageMetaData::EStorageSuid).AllocL();
+            
+	            RBuf suid;
+	            suid.CleanupClosePushL();
+	            suid.CreateL(KMaxFileName);
+	            suid = *StorageSuid;
+	            _LIT(WMPInfoXml,"WMPInfo.xml");
+	            suid.Append(WMPInfoXml); 
+	            TUint32 handle = iFramework.ObjectMgr().HandleL(suid);
+	            if ( handle != KMTPHandleNone )
+	                {
+	                TInt index = handles.Find(handle);
+	                if ( index != KErrNotFound )
+	                    {
+	                    handles.Remove(index);
+	                    handles.Insert(handle,0);
+	                    }
+	                }   
+	            delete StorageSuid;
+	            StorageSuid = NULL;
+	            CleanupStack::PopAndDestroy();
+            	}
+        	iHandles->AppendL(handles);
+    	    }
+    	while (!context.QueryComplete());        
+        }        
+    	
+        
+
 	CleanupStack::PopAndDestroy(&handles);
 	CleanupStack::PopAndDestroy(&context);					
-	SendDataL(*iHandles);	
+	SendDataL(*iHandles);
+    __FLOG(_L8("ServiceL - Exit"));	    
 	}
-
-
-
-
-
-
-	
-
 	
-
-
-   	
-
-	
-
-
-
-
-
-