mtpdataproviders/mtpimagedp/src/cmtpimagedpsetobjectpropvalue.cpp
changeset 49 c20dd21d1eb4
parent 17 aabe5387f5ce
equal deleted inserted replaced
41:2c19c7cf5550 49:c20dd21d1eb4
    30 #include "mtpimagedppanic.h"
    30 #include "mtpimagedppanic.h"
    31 #include "mtpimagedputilits.h"
    31 #include "mtpimagedputilits.h"
    32 #include "cmtpimagedp.h"
    32 #include "cmtpimagedp.h"
    33 #include "cmtpimagedpobjectpropertymgr.h"
    33 #include "cmtpimagedpobjectpropertymgr.h"
    34 #include "cmtpimagedpsetobjectpropvalue.h"
    34 #include "cmtpimagedpsetobjectpropvalue.h"
    35 
    35 #include "OstTraceDefinitions.h"
    36 __FLOG_STMT(_LIT8(KComponent,"CMTPImageDpSetObjectPropValue");)
    36 #ifdef OST_TRACE_COMPILER_IN_USE
       
    37 #include "cmtpimagedpsetobjectpropvalueTraces.h"
       
    38 #endif
       
    39 
       
    40 
    37 /**
    41 /**
    38 Two-phase construction method
    42 Two-phase construction method
    39 @param aPlugin	The data provider plugin
    43 @param aPlugin	The data provider plugin
    40 @param aFramework	The data provider framework
    44 @param aFramework	The data provider framework
    41 @param aConnection	The connection from which the request comes
    45 @param aConnection	The connection from which the request comes
    55 /**
    59 /**
    56 Destructor
    60 Destructor
    57 */	
    61 */	
    58 CMTPImageDpSetObjectPropValue::~CMTPImageDpSetObjectPropValue()
    62 CMTPImageDpSetObjectPropValue::~CMTPImageDpSetObjectPropValue()
    59 	{	
    63 	{	
    60 	__FLOG(_L8(">> ~CMTPImageDpSetObjectPropValue"));
    64 	OstTraceFunctionEntry0( CMTPIMAGEDPSETOBJECTPROPVALUE_CMTPIMAGEDPSETOBJECTPROPVALUE_DES_ENTRY );
    61 	delete iMTPTypeString;
    65 	delete iMTPTypeString;
    62 	delete iObjectMeta;
    66 	delete iObjectMeta;
    63 	__FLOG(_L8("<< ~CMTPImageDpSetObjectPropValue"));
    67 	OstTraceFunctionExit0( CMTPIMAGEDPSETOBJECTPROPVALUE_CMTPIMAGEDPSETOBJECTPROPVALUE_DES_EXIT );
    64 	__FLOG_CLOSE;
       
    65 	}
    68 	}
    66 
    69 
    67 /**
    70 /**
    68 Standard c++ constructor
    71 Standard c++ constructor
    69 */	
    72 */	
    82 @param aObjectPropCode the object property code passed in.
    85 @param aObjectPropCode the object property code passed in.
    83 @return ETrue if the object property code is readonly. Otherwise EFalse.
    86 @return ETrue if the object property code is readonly. Otherwise EFalse.
    84 */	
    87 */	
    85 TBool CMTPImageDpSetObjectPropValue::IsPropCodeReadonly(TUint32 aObjectPropCode)
    88 TBool CMTPImageDpSetObjectPropValue::IsPropCodeReadonly(TUint32 aObjectPropCode)
    86 	{
    89 	{
    87 	__FLOG(_L8(">> CMTPImageDpSetObjectPropValue::IsPropCodeReadonly"));
    90 	OstTraceFunctionEntry0( CMTPIMAGEDPSETOBJECTPROPVALUE_ISPROPCODEREADONLY_ENTRY );
    88 	TBool returnCode = EFalse;
    91 	TBool returnCode = EFalse;
    89 	if(aObjectPropCode == EMTPObjectPropCodeStorageID
    92 	if(aObjectPropCode == EMTPObjectPropCodeStorageID
    90 		|| aObjectPropCode == EMTPObjectPropCodeObjectFormat
    93 		|| aObjectPropCode == EMTPObjectPropCodeObjectFormat
    91 		|| aObjectPropCode == EMTPObjectPropCodeProtectionStatus
    94 		|| aObjectPropCode == EMTPObjectPropCodeProtectionStatus
    92 		|| aObjectPropCode == EMTPObjectPropCodeObjectSize
    95 		|| aObjectPropCode == EMTPObjectPropCodeObjectSize
   102 		|| aObjectPropCode == EMTPObjectPropCodeRepresentativeSampleWidth
   105 		|| aObjectPropCode == EMTPObjectPropCodeRepresentativeSampleWidth
   103 		|| aObjectPropCode == EMTPObjectPropCodeRepresentativeSampleData)
   106 		|| aObjectPropCode == EMTPObjectPropCodeRepresentativeSampleData)
   104 		{
   107 		{
   105 		returnCode = ETrue;
   108 		returnCode = ETrue;
   106 		}
   109 		}
   107 	__FLOG(_L8("<< CMTPImageDpSetObjectPropValue::IsPropCodeReadonly"));
   110 	OstTraceFunctionExit0( CMTPIMAGEDPSETOBJECTPROPVALUE_ISPROPCODEREADONLY_EXIT );
   108 	return returnCode;
   111 	return returnCode;
   109 	}
   112 	}
   110 
   113 
   111 /**
   114 /**
   112 Verify object handle, prop code
   115 Verify object handle, prop code
   113 */
   116 */
   114 TMTPResponseCode CMTPImageDpSetObjectPropValue::CheckRequestL()
   117 TMTPResponseCode CMTPImageDpSetObjectPropValue::CheckRequestL()
   115 	{
   118 	{
   116 	__FLOG(_L8(">> CMTPImageDpSetObjectPropValue::CheckRequestL"));
   119 	OstTraceFunctionEntry0( CMTPIMAGEDPSETOBJECTPROPVALUE_CHECKREQUESTL_ENTRY );
   117 	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
   120 	TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL();
   118 	if(responseCode == EMTPRespCodeOK)
   121 	if(responseCode == EMTPRespCodeOK)
   119 		{
   122 		{
   120 		responseCode = MTPImageDpUtilits::VerifyObjectHandleL(iFramework, Request().Uint32(TMTPTypeRequest::ERequestParameter1), *iObjectMeta);
   123 		responseCode = MTPImageDpUtilits::VerifyObjectHandleL(iFramework, Request().Uint32(TMTPTypeRequest::ERequestParameter1), *iObjectMeta);
   121 		}
   124 		}
   143 			if(i == count)
   146 			if(i == count)
   144 				{
   147 				{
   145 				responseCode = EMTPRespCodeInvalidObjectPropCode;
   148 				responseCode = EMTPRespCodeInvalidObjectPropCode;
   146 				}
   149 				}
   147 		}
   150 		}
   148 	__FLOG(_L8("<< CMTPImageDpSetObjectPropValue::CheckRequestL"));
   151 	OstTraceFunctionExit0( CMTPIMAGEDPSETOBJECTPROPVALUE_CHECKREQUESTL_EXIT );
   149 	return responseCode;
   152 	return responseCode;
   150 	}
   153 	}
   151 		
   154 		
   152 /**
   155 /**
   153 SetObjectPropValue request handler
   156 SetObjectPropValue request handler
   154 */	
   157 */	
   155 void CMTPImageDpSetObjectPropValue::ServiceL()
   158 void CMTPImageDpSetObjectPropValue::ServiceL()
   156 	{
   159 	{
   157 	__FLOG(_L8(">> CMTPImageDpSetObjectPropValue::ServiceL"));
   160 	OstTraceFunctionEntry0( CMTPIMAGEDPSETOBJECTPROPVALUE_SERVICEL_ENTRY );
   158 	TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
   161 	TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
   159 	delete iMTPTypeString;
   162 	delete iMTPTypeString;
   160 	iMTPTypeString = NULL;
   163 	iMTPTypeString = NULL;
   161 	iMTPTypeString = CMTPTypeString::NewL();
   164 	iMTPTypeString = CMTPTypeString::NewL();
   162 	switch(propCode)
   165 	switch(propCode)
   166 		case EMTPObjectPropCodeName:
   169 		case EMTPObjectPropCodeName:
   167 			ReceiveDataL(*iMTPTypeString);
   170 			ReceiveDataL(*iMTPTypeString);
   168 			break;
   171 			break;
   169         case EMTPObjectPropCodeNonConsumable:
   172         case EMTPObjectPropCodeNonConsumable:
   170             ReceiveDataL(iMTPTypeUint8);
   173             ReceiveDataL(iMTPTypeUint8);
   171             break;			
   174             break;
       
   175         case EMTPObjectPropCodeHidden:
       
   176             ReceiveDataL(iMTPTypeUint16);
       
   177             break;
   172 		default:
   178 		default:
       
   179 		    OstTrace1( TRACE_ERROR, CMTPIMAGEDPSETOBJECTPROPVALUE_SERVICEL, "Invalid propCode %d", propCode );
   173 			User::Leave(KErrGeneral);
   180 			User::Leave(KErrGeneral);
   174 		}	
   181 		}	
   175 	__FLOG(_L8("<< CMTPImageDpSetObjectPropValue::ServiceL"));
   182 	OstTraceFunctionExit0( CMTPIMAGEDPSETOBJECTPROPVALUE_SERVICEL_EXIT );
   176 	}
   183 	}
   177 
   184 
   178 /**
   185 /**
   179 Apply the references to the specified object
   186 Apply the references to the specified object
   180 @return EFalse
   187 @return EFalse
   181 */	
   188 */	
   182 TBool CMTPImageDpSetObjectPropValue::DoHandleResponsePhaseL()
   189 TBool CMTPImageDpSetObjectPropValue::DoHandleResponsePhaseL()
   183 	{
   190 	{
   184 	__FLOG(_L8(">> CMTPImageDpSetObjectPropValue::DoHandleResponsePhaseL"));
   191 	OstTraceFunctionEntry0( CMTPIMAGEDPSETOBJECTPROPVALUE_DOHANDLERESPONSEPHASEL_ENTRY );
   185 	
   192 	
   186     iObjectPropertyMgr.SetCurrentObjectL(*iObjectMeta, ETrue);
   193     iObjectPropertyMgr.SetCurrentObjectL(*iObjectMeta, ETrue);
   187     /*
   194     /*
   188     [Winlog]If file is readonly, all property of this file shoule not be changed.
   195     [Winlog]If file is readonly, all property of this file shoule not be changed.
   189     */
   196     */
   190     TUint16 protection;
   197     TUint16 protection;
   191     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeProtectionStatus, protection);
   198     iObjectPropertyMgr.GetPropertyL(EMTPObjectPropCodeProtectionStatus, protection);
   192     if(EMTPProtectionReadOnly == protection)
   199     if(EMTPProtectionReadOnly == protection)
   193         {
   200         {
   194         SendResponseL(EMTPRespCodeAccessDenied);
   201         SendResponseL(EMTPRespCodeAccessDenied);
       
   202         OstTraceFunctionExit0( CMTPIMAGEDPSETOBJECTPROPVALUE_DOHANDLERESPONSEPHASEL_EXIT );
   195         return EFalse;  
   203         return EFalse;  
   196         }
   204         }
   197 	TInt32 handle(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
   205 	TInt32 handle(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
   198 	TMTPResponseCode responseCode = EMTPRespCodeOK;
   206 	TMTPResponseCode responseCode = EMTPRespCodeOK;
   199 	TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
   207 	TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter2);
   231             {
   239             {
   232             iObjectPropertyMgr.SetPropertyL(TMTPObjectPropertyCode(propCode), iMTPTypeUint8.Value());
   240             iObjectPropertyMgr.SetPropertyL(TMTPObjectPropertyCode(propCode), iMTPTypeUint8.Value());
   233             iFramework.ObjectMgr().ModifyObjectL(*iObjectMeta);
   241             iFramework.ObjectMgr().ModifyObjectL(*iObjectMeta);
   234             responseCode = EMTPRespCodeOK;
   242             responseCode = EMTPRespCodeOK;
   235             }
   243             }
   236             break;            
   244             break;
       
   245         case EMTPObjectPropCodeHidden:
       
   246             {
       
   247             iObjectPropertyMgr.SetPropertyL(TMTPObjectPropertyCode(propCode), iMTPTypeUint16.Value());
       
   248             responseCode = EMTPRespCodeOK;
       
   249             }
       
   250             break;    
   237  		default:
   251  		default:
   238 			responseCode = EMTPRespCodeInvalidObjectPropFormat;
   252 			responseCode = EMTPRespCodeInvalidObjectPropFormat;
   239 			//Panic(EMTPImageDpUnsupportedProperty);
   253 			//Panic(EMTPImageDpUnsupportedProperty);
   240 		}
   254 		}
   241 	
   255 	
   242 	SendResponseL(responseCode);
   256 	SendResponseL(responseCode);
   243 	
   257 
   244 	__FLOG(_L8("<< CMTPImageDpSetObjectPropValue::DoHandleResponsePhaseL"));
   258 	OstTraceFunctionExit0( DUP1_CMTPIMAGEDPSETOBJECTPROPVALUE_DOHANDLERESPONSEPHASEL_EXIT );
   245 	return EFalse;	
   259 	return EFalse;	
   246 	}
   260 	}
   247 	
   261 	
   248 TBool CMTPImageDpSetObjectPropValue::HasDataphase() const
   262 TBool CMTPImageDpSetObjectPropValue::HasDataphase() const
   249 	{
   263 	{
   253 /**
   267 /**
   254 Second-phase construction
   268 Second-phase construction
   255 */			
   269 */			
   256 void CMTPImageDpSetObjectPropValue::ConstructL()
   270 void CMTPImageDpSetObjectPropValue::ConstructL()
   257 	{
   271 	{
   258 	__FLOG_OPEN(KMTPSubsystem, KComponent);
   272 	OstTraceFunctionEntry0( CMTPIMAGEDPSETOBJECTPROPVALUE_CONSTRUCTL_ENTRY );
   259 	__FLOG(_L8(">> CMTPImageDpSetObjectPropList::ConstructL"));
       
   260 	
   273 	
   261 	iObjectMeta = CMTPObjectMetaData::NewL();
   274 	iObjectMeta = CMTPObjectMetaData::NewL();
   262 	
   275 
   263 	__FLOG(_L8("<< CMTPImageDpSetObjectPropList::ConstructL"));
   276 	OstTraceFunctionExit0( CMTPIMAGEDPSETOBJECTPROPVALUE_CONSTRUCTL_EXIT );
   264 	}
   277 	}
   265 
   278 
   266 	
   279