mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetobjecthandles.cpp
changeset 31 a26669f87b46
parent 20 6e82ae192c3a
child 47 63cf70d3ecd8
--- a/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetobjecthandles.cpp	Fri Jun 25 16:54:01 2010 +0800
+++ b/mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetobjecthandles.cpp	Fri Jul 09 17:58:21 2010 +0800
@@ -107,10 +107,6 @@
     
     iTimeoutCount = 0;
     
-	RMTPObjectMgrQueryContext   context;
-	RArray<TUint>               handles;
-	CleanupClosePushL(context);
-	CleanupClosePushL(handles);
 	delete iHandles;
 	iHandles = CMTPTypeArray::NewL(EMTPTypeAUINT32);
 
@@ -119,47 +115,14 @@
        &&(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);                            
+        HandleObjectHandlesUnderMacL(*iHandles);
         }
     else
         {
+    	RMTPObjectMgrQueryContext   context;
+    	RArray<TUint>               handles;
+    	CleanupClosePushL(context);
+    	CleanupClosePushL(handles);        
     	TMTPObjectMgrQueryParams    params(Request().Uint32(TMTPTypeRequest::ERequestParameter1), Request().Uint32(TMTPTypeRequest::ERequestParameter2), Request().Uint32(TMTPTypeRequest::ERequestParameter3));	
     	do
     	    {
@@ -185,7 +148,7 @@
 	                if ( index != KErrNotFound )
 	                    {
 	                    handles.Remove(index);
-	                    handles.Insert(handle,0);
+	                    handles.InsertL(handle,0);
 	                    }
 	                }   
 	            delete StorageSuid;
@@ -194,13 +157,11 @@
             	}
         	iHandles->AppendL(handles);
     	    }
-    	while (!context.QueryComplete());        
+    	while (!context.QueryComplete()); 
+    	CleanupStack::PopAndDestroy(&handles);
+    	CleanupStack::PopAndDestroy(&context);        
         }        
-    	
-        
-
-	CleanupStack::PopAndDestroy(&handles);
-	CleanupStack::PopAndDestroy(&context);					
+    						
 	SendDataL(*iHandles);
     __FLOG(_L8("ServiceL - Exit"));	    
 	}