mtpfws/mtpfw/dataproviders/devdp/src/cmtpgetnumobjects.cpp
changeset 17 aabe5387f5ce
parent 0 d0791faffa3f
child 12 8b094906a049
equal deleted inserted replaced
0:d0791faffa3f 17:aabe5387f5ce
    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/mmtpdataprovider.h>
    19 #include <mtp/mmtpdataprovider.h>
    20 #include <mtp/cmtpdataproviderplugin.h>
    20 #include <mtp/cmtpdataproviderplugin.h>
       
    21 #include <mtp/cmtpobjectmetadata.h>
    21 
    22 
    22 #include "cmtpdataprovidercontroller.h"
    23 #include "cmtpdataprovidercontroller.h"
    23 #include "cmtpdataprovider.h"
    24 #include "cmtpdataprovider.h"
    24 
    25 
    25 #include "cmtpgetnumobjects.h"
    26 #include "cmtpgetnumobjects.h"
    26 #include "mtpdevicedpconst.h"
    27 #include "mtpdevicedpconst.h"
    27 #include "mtpdevdppanic.h"
    28 #include "mtpdevdppanic.h"
       
    29 
    28 
    30 
    29 /**
    31 /**
    30 Verification data for GetNumObjects request
    32 Verification data for GetNumObjects request
    31 */
    33 */
    32 const TMTPRequestElementInfo KMTPGetNumObjectsPolicy[] = 
    34 const TMTPRequestElementInfo KMTPGetNumObjectsPolicy[] = 
    55 /**
    57 /**
    56 Destructor
    58 Destructor
    57 */	
    59 */	
    58 CMTPGetNumObjects::~CMTPGetNumObjects()
    60 CMTPGetNumObjects::~CMTPGetNumObjects()
    59 	{	
    61 	{	
       
    62 	iDevDpSingletons.Close();
    60     iSingletons.Close();
    63     iSingletons.Close();
    61 	}
    64 	}
    62 /**
    65 /**
    63 Standard c++ constructor
    66 Standard c++ constructor
    64 */	
    67 */	
    72 Second phase constructor.
    75 Second phase constructor.
    73 */
    76 */
    74 void CMTPGetNumObjects::ConstructL()
    77 void CMTPGetNumObjects::ConstructL()
    75     {
    78     {
    76     iSingletons.OpenL();
    79     iSingletons.OpenL();
       
    80     iDevDpSingletons.OpenL(iFramework);
    77     }
    81     }
    78 
    82 
    79 TMTPResponseCode CMTPGetNumObjects::CheckRequestL()
    83 TMTPResponseCode CMTPGetNumObjects::CheckRequestL()
    80 	{
    84 	{
    81 	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
    85 	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
    82 	if(responseCode == EMTPRespCodeOK)
    86 	if(responseCode != EMTPRespCodeOK)
    83 		{
    87 		{
    84 		TUint32 formatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
    88 		return responseCode;	
    85 		if(formatCode != 0 && !IsSupportedFormatL(formatCode))
    89 		}
       
    90 	
       
    91 	TUint32 formatCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2); 
       
    92 	if(formatCode != 0 && !IsSupportedFormatL(formatCode))
       
    93 		{
       
    94 		return EMTPRespCodeInvalidObjectFormatCode;
       
    95 		}
       
    96 	
       
    97 	if(iSingletons.DpController().EnumerateState() != CMTPDataProviderController::EEnumeratedFulllyCompleted)
       
    98 		{
       
    99 		TUint storageID = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
       
   100 		TUint handle = Request().Uint32(TMTPTypeRequest::ERequestParameter3);
       
   101 		if(iDevDpSingletons.PendingStorages().FindInOrder(storageID) != KErrNotFound)
    86 			{
   102 			{
    87 			responseCode = EMTPRespCodeInvalidObjectFormatCode;
   103 			responseCode = EMTPRespCodeDeviceBusy;
       
   104 			}
       
   105 		else if( (handle != KMTPHandleNone) && (handle != KMTPHandleAll)  )
       
   106 			{
       
   107 			CMTPObjectMetaData* meta = iRequestChecker->GetObjectInfo(handle);
       
   108 			__ASSERT_DEBUG(meta, Panic(EMTPDevDpObjectNull));
       
   109 			
       
   110 			if( meta->Uint(CMTPObjectMetaData::EFormatCode) == EMTPFormatCodeAssociation )
       
   111 				{
       
   112 				responseCode = EMTPRespCodeDeviceBusy;
       
   113 				}
       
   114 			}
       
   115 		else if(EMTPFormatCodeUndefined == formatCode)
       
   116 			{
       
   117 			responseCode = EMTPRespCodeDeviceBusy;
    88 			}
   118 			}
    89 		}
   119 		}
       
   120 	else if(iDevDpSingletons.PendingStorages().Count() > 0)
       
   121 		{
       
   122 		iDevDpSingletons.PendingStorages().Close();
       
   123 		}
       
   124 	
    90 	return responseCode;	
   125 	return responseCode;	
    91 	}
   126 	}
    92 	
   127 	
    93 	
   128 	
    94 /**
   129 /**