mtpfws/mtpfw/dataproviders/devdp/src/cmtpsetdevicepropvalue.cpp
changeset 0 d0791faffa3f
child 2 4843bb5893b6
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <mtp/cmtptypestring.h>
       
    17 #include <mtp/mmtpdataproviderframework.h>
       
    18 #include <mtp/mtpprotocolconstants.h>
       
    19 #include <mtp/tmtptyperequest.h>
       
    20 #include <mtp/rmtpclient.h>
       
    21 #include <e32property.h>
       
    22 #include <mtp/mmtpframeworkconfig.h>
       
    23 #include "cmtpdevicedatastore.h"
       
    24 #include "cmtpsetdevicepropvalue.h"
       
    25 #include "mtpdevicedpconst.h"
       
    26 #include "mtpdevdppanic.h"
       
    27 
       
    28 // Class constants.
       
    29 __FLOG_STMT(_LIT8(KComponent,"SetDevicePropValue");)
       
    30 
       
    31 /**
       
    32 Two-phase constructor.
       
    33 @param aPlugin  The data provider plugin
       
    34 @param aFramework The data provider framework
       
    35 @param aConnection The connection from which the request comes
       
    36 @return a pointer to the created request processor object.
       
    37 */  
       
    38 MMTPRequestProcessor* CMTPSetDevicePropValue::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
       
    39     {
       
    40     CMTPSetDevicePropValue* self = new (ELeave) CMTPSetDevicePropValue(aFramework, aConnection);
       
    41     CleanupStack::PushL(self);
       
    42     self->ConstructL();
       
    43     CleanupStack::Pop(self);
       
    44     return self;
       
    45     }
       
    46 
       
    47 /**
       
    48 Destructor
       
    49 */    
       
    50 CMTPSetDevicePropValue::~CMTPSetDevicePropValue()
       
    51     {    
       
    52     __FLOG(_L8("~CMTPSetDevicePropValue - Entry"));
       
    53     delete iString;
       
    54     delete iMtparray;
       
    55     delete iData;
       
    56     __FLOG(_L8("~CMTPSetDevicePropValue - Exit"));
       
    57     __FLOG_CLOSE;
       
    58     }
       
    59 
       
    60 /**
       
    61 Standard c++ constructor
       
    62 */    
       
    63 CMTPSetDevicePropValue::CMTPSetDevicePropValue(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
       
    64     CMTPGetDevicePropDesc(aFramework, aConnection)
       
    65     {
       
    66     
       
    67     }
       
    68     
       
    69 /**
       
    70 Second-phase construction
       
    71 */    
       
    72 void CMTPSetDevicePropValue::ConstructL()
       
    73     {
       
    74     __FLOG_OPEN(KMTPSubsystem, KComponent);
       
    75     __FLOG(_L8("ConstructL - Entry")); 
       
    76     CMTPGetDevicePropDesc::ConstructL();
       
    77     iString = CMTPTypeString::NewL();
       
    78     iMtparray = CMTPTypeArray::NewL(EMTPTypeAUINT8);
       
    79     iData = new(ELeave) TMTPTypeGuid();
       
    80     __FLOG(_L8("ConstructL - Exit")); 
       
    81     }
       
    82 
       
    83 /**
       
    84 Service Battery level property
       
    85 */    
       
    86 void CMTPSetDevicePropValue::ServiceBatteryLevelL()
       
    87     {
       
    88     __FLOG(_L8("ServiceBatteryLevelL - Entry"));
       
    89     SendResponseL(EMTPRespCodeAccessDenied); 
       
    90     __FLOG(_L8("ServiceBatteryLevelL - Exit"));   
       
    91     }
       
    92 
       
    93 /**
       
    94 Service the device friendly name property.
       
    95 */   
       
    96 void CMTPSetDevicePropValue::ServiceDeviceFriendlyNameL()
       
    97     {
       
    98     __FLOG(_L8("ServiceDeviceFriendlyNameL - Entry"));
       
    99     iString->SetL(KNullDesC);
       
   100     ReceiveDataL(*iString); 
       
   101     __FLOG(_L8("ServiceDeviceFriendlyNameL - Exit"));    
       
   102     }
       
   103         
       
   104 /**
       
   105 Service the synchronisation partner property.
       
   106 */ 
       
   107 void CMTPSetDevicePropValue::ServiceSynchronisationPartnerL()
       
   108     {    
       
   109     __FLOG(_L8("ServiceSynchronisationPartnerL - Entry")); 
       
   110     iString->SetL(KNullDesC);
       
   111     ReceiveDataL(*iString);
       
   112     __FLOG(_L8("ServiceSynchronisationPartnerL - Exit"));
       
   113     }
       
   114     
       
   115 /**
       
   116 SetDevicePropValue request validator.
       
   117 @return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
       
   118 */
       
   119 TMTPResponseCode CMTPSetDevicePropValue::CheckRequestL()
       
   120 	{
       
   121 	__FLOG(_L8("CheckRequestL - Entry")); 
       
   122 	TMTPResponseCode responseCode = CMTPGetDevicePropDesc::CheckRequestL();
       
   123 	
       
   124 	TUint32 propCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
       
   125 	if( propCode == EMTPDevicePropCodeBatteryLevel)
       
   126 		{
       
   127 		responseCode = EMTPRespCodeAccessDenied;
       
   128 		}
       
   129 	__FLOG(_L8("CheckRequestL - Exit")); 
       
   130 	return responseCode;
       
   131 	}
       
   132 
       
   133 /**
       
   134 Process the transaction response phase.
       
   135 */    
       
   136 TBool CMTPSetDevicePropValue::DoHandleResponsePhaseL()
       
   137     {
       
   138     __FLOG(_L8("DoHandleResponsePhaseL - Entry"));
       
   139     MExtnDevicePropDp* extnDevplugin = iDpSingletons.DeviceDataStore().ExtnDevicePropDp();
       
   140     TUint32 propCode(Request().Uint32(TMTPTypeRequest::ERequestParameter1));
       
   141     switch(propCode)
       
   142         {
       
   143     case EMTPDevicePropCodeSynchronizationPartner:
       
   144         CompleteServiceSynchronisationPartnerL();
       
   145         break;
       
   146         
       
   147     case EMTPDevicePropCodeDeviceFriendlyName:
       
   148         CompleteServiceDeviceFriendlyNameL();
       
   149         break;
       
   150 
       
   151 	case EMTPDevicePropCodeSessionInitiatorVersionInfo:
       
   152 		CompleteServiceSessionInitiatorVersionInfoL();
       
   153 		break;
       
   154 	case EMTPDevicePropCodeDateTime:	
       
   155 		CompleteServiceDateTimeL();
       
   156 		break;
       
   157 	
       
   158 	case EMTPDevicePropCodeSupportedFormatsOrdered:		
       
   159 		CompleteServiceSupportedFormatsOrderedL();
       
   160 		break;
       
   161 	
       
   162 	case EMTPDevicePropCodeDeviceIcon:		
       
   163 		CompleteDeviceIconL();
       
   164 		break;
       
   165 	case EMTPDevicePropCodePerceivedDeviceType:		
       
   166 		CompletePerceivedDeviceTypeL();
       
   167 		break;
       
   168 	case EMTPDevicePropCodeFunctionalID:		
       
   169 		CompleteServiceFunctionalIDL();
       
   170 		break;
       
   171 	case EMTPDevicePropCodeModelID:		
       
   172 		CompleteServiceModelIDL();
       
   173 		break;
       
   174 	case EMTPDevicePropCodeUseDeviceStage:		
       
   175 		CompleteServiceUseDeviceStageL();
       
   176 		break;
       
   177     default:
       
   178  		if(extnDevplugin)
       
   179 		{
       
   180 		SendResponseL(extnDevplugin->SetDevicePropertyL());
       
   181 		}
       
   182 		else 
       
   183 		{
       
   184 		SendResponseL(EMTPRespCodeDevicePropNotSupported); 
       
   185 		}
       
   186         break;             
       
   187         }
       
   188     __FLOG(_L8("DoHandleResponsePhaseL - Exit"));
       
   189     return EFalse;    
       
   190     }
       
   191     
       
   192 TBool CMTPSetDevicePropValue::HasDataphase() const
       
   193 	{
       
   194 	return ETrue;
       
   195 	}
       
   196     
       
   197 /**
       
   198 Processes the device friendly name property transaction response phase.
       
   199 */
       
   200 void CMTPSetDevicePropValue::CompleteServiceDeviceFriendlyNameL()
       
   201     {
       
   202     __FLOG(_L8("CompleteServiceDeviceFriendlyNameL - Entry"));
       
   203     iDpSingletons.DeviceDataStore().SetDeviceFriendlyNameL(iString->StringChars());
       
   204     SendResponseL(EMTPRespCodeOK);  
       
   205     __FLOG(_L8("CompleteServiceDeviceFriendlyNameL - Exit"));  
       
   206     }
       
   207 
       
   208 /**
       
   209 Processes the synchronisation partner property transaction response phase.
       
   210 */
       
   211 void CMTPSetDevicePropValue::CompleteServiceSynchronisationPartnerL()
       
   212     {
       
   213     __FLOG(_L8("CompleteServiceSynchronisationPartnerL - Entry"));
       
   214     iDpSingletons.DeviceDataStore().SetSynchronisationPartnerL(iString->StringChars());
       
   215     SendResponseL(EMTPRespCodeOK);
       
   216     __FLOG(_L8("CompleteServiceSynchronisationPartnerL - Exit"));
       
   217     }
       
   218 
       
   219 void CMTPSetDevicePropValue::HandleExtnServiceL(TInt aPropCode, MExtnDevicePropDp* aExtnDevplugin)
       
   220 	{
       
   221 	MMTPType* ammtptype = NULL;
       
   222 	aExtnDevplugin->GetDevicePropertyContainerL((TMTPDevicePropertyCode)aPropCode, &ammtptype);	
       
   223 	if(ammtptype != NULL)
       
   224 	{
       
   225 	ReceiveDataL(*ammtptype);
       
   226 	}
       
   227 	else
       
   228 	{
       
   229 	SendResponseL(EMTPRespCodeDevicePropNotSupported);	
       
   230 	}
       
   231 	}
       
   232  
       
   233 /**
       
   234 Processes the session initiator version info and set the same to session device data store.
       
   235 */
       
   236 void CMTPSetDevicePropValue::CompleteServiceSessionInitiatorVersionInfoL()
       
   237 	{
       
   238 	__FLOG(_L8("CompleteServiceSynchronisationPartnerL - Entry"));
       
   239 	RProcess process;
       
   240 	RProperty::Set(process.SecureId(), EMTPConnStateKey, iString->StringChars());
       
   241 	iDpSingletons.DeviceDataStore().SetSessionInitiatorVersionInfoL(iString->StringChars());
       
   242 	SendResponseL(EMTPRespCodeOK);
       
   243 	__FLOG(_L8("CompleteServiceSynchronisationPartnerL - Exit"));
       
   244 	}
       
   245 
       
   246 /**
       
   247 Service session initiator property.
       
   248 */ 
       
   249 void CMTPSetDevicePropValue::ServiceSessionInitiatorVersionInfoL()
       
   250 	{	 
       
   251 	__FLOG(_L8("SetSessionInitiatorVersionInfoL - Entry")); 
       
   252 	iString->SetL(KNullDesC);
       
   253 	ReceiveDataL(*iString);
       
   254 	__FLOG(_L8("SetSessionInitiatorVersionInfoL - Exit"));
       
   255 	}
       
   256 
       
   257 
       
   258 /**
       
   259 This should be removed no set for percived device type.
       
   260 */
       
   261 void CMTPSetDevicePropValue::CompletePerceivedDeviceTypeL()
       
   262     {
       
   263     __FLOG(_L8("CompletePerceivedDeviceType - Entry"));
       
   264     SendResponseL(EMTPRespCodeAccessDenied);
       
   265     __FLOG(_L8("CompletePerceivedDeviceType - Exit"));
       
   266     }
       
   267 
       
   268 /**
       
   269 *Service the PerceivedDeviceType property.
       
   270 *it is not set type it should be removed 
       
   271 **/
       
   272 void CMTPSetDevicePropValue::ServicePerceivedDeviceTypeL()
       
   273     {	 
       
   274     __FLOG(_L8("ServicePerceivedDeviceType - Entry")); 	
       
   275     ReceiveDataL(iUint32);
       
   276     __FLOG(_L8("ServicePerceivedDeviceType - Exit"));
       
   277     }
       
   278 
       
   279 /**
       
   280 Processes the Date Time property transaction response phase.
       
   281 */
       
   282 void CMTPSetDevicePropValue::CompleteServiceDateTimeL()
       
   283 	{
       
   284 	__FLOG(_L8("CompleteDateTime - Entry"));
       
   285 	//validate the incoming date time string first and then set it.
       
   286 	if(KErrNone == iDpSingletons.DeviceDataStore().SetDateTimeL(iString->StringChars()) )
       
   287 		{
       
   288 		SendResponseL(EMTPRespCodeOK);
       
   289 		}
       
   290 	else
       
   291 		{
       
   292 		SendResponseL(EMTPRespCodeInvalidDataset);
       
   293 		}
       
   294 	
       
   295 	__FLOG(_L8("CompleteDateTime - Exit"));
       
   296 	}
       
   297 
       
   298 /**
       
   299 Service the Date Time property. 
       
   300 */ 
       
   301 void CMTPSetDevicePropValue::ServiceDateTimeL()
       
   302     {	 
       
   303     __FLOG(_L8("ServiceDateTime - Entry")); 
       
   304     iString->SetL(KNullDesC);
       
   305     ReceiveDataL(*iString);
       
   306     __FLOG(_L8("ServiceDateTime - Exit"));
       
   307     }
       
   308 
       
   309 /*
       
   310 *Complete Service the Device Icon property and CompleteDeviceIcon.
       
   311 As of now implemented as device property of type get.
       
   312 */
       
   313 void CMTPSetDevicePropValue::CompleteDeviceIconL()
       
   314     {   	
       
   315     __FLOG(_L8("CompleteDeviceIcon - Entry"));
       
   316     //it is Get only device property
       
   317     SendResponseL(EMTPRespCodeAccessDenied);
       
   318     __FLOG(_L8("CompleteDeviceIcon - Exit"));
       
   319     }
       
   320 
       
   321 /*
       
   322 *Service the Device Icon property and CompleteDeviceIcon.
       
   323 As of now implemented as device property of type get.
       
   324 */   
       
   325 void CMTPSetDevicePropValue::ServiceDeviceIconL()
       
   326     {    
       
   327     __FLOG(_L8("ServiceDeviceIcon - Entry")); 	
       
   328     //no need to recive this data beacuse it is Get property
       
   329     ReceiveDataL(*iMtparray);
       
   330     __FLOG(_L8("ServiceDeviceIcon - Exit"));
       
   331     }
       
   332        
       
   333 
       
   334 /*
       
   335 *Processes the PerceivedDeviceType property transaction response phase.
       
   336 */
       
   337 void CMTPSetDevicePropValue::CompleteServiceSupportedFormatsOrderedL()
       
   338     {
       
   339     __FLOG(_L8("CompleteServiceSupportedFormatsOrdered - Entry"));
       
   340     //it is Get only device property
       
   341     SendResponseL(EMTPRespCodeAccessDenied);
       
   342     __FLOG(_L8("CompleteServiceSupportedFormatsOrdered - Exit"));
       
   343     }
       
   344 
       
   345 /*
       
   346 *ServiceSupportedFormatsOrdered property. it is get only type.
       
   347 */
       
   348 void CMTPSetDevicePropValue::ServiceSupportedFormatsOrderedL()
       
   349     {	 
       
   350     __FLOG(_L8("ServiceSupportedFormatsOrdered - Entry")); 	
       
   351     //no need to recive this data beacuse it is Get property
       
   352     ReceiveDataL(iUint8);
       
   353     __FLOG(_L8("ServicePerceivedDeviceType - Exit"));
       
   354     }
       
   355 
       
   356 /*
       
   357 *Processes the FunctionalID property transaction response phase.
       
   358 */
       
   359 void CMTPSetDevicePropValue::CompleteServiceFunctionalIDL()
       
   360     {
       
   361     __FLOG(_L8("CompleteServiceFunctionalIDL - Entry"));
       
   362 
       
   363     TPtrC8 ptr(NULL,0);
       
   364     if ( KMTPChunkSequenceCompletion == iData->FirstReadChunk(ptr) )
       
   365    		{
       
   366    		SaveGUID( MMTPFrameworkConfig::EDeviceCurrentFuncationalID, *iData );
       
   367    		SendResponseL(EMTPRespCodeOK);
       
   368     	}
       
   369     
       
   370     __FLOG(_L8("CompleteServiceFunctionalIDL - Exit"));
       
   371     }
       
   372 
       
   373 /*
       
   374 *FunctionalID property. 
       
   375 */
       
   376 void CMTPSetDevicePropValue::ServiceFunctionalIDL()
       
   377     {	 
       
   378     __FLOG(_L8("ServiceFunctionalIDL - Entry")); 	
       
   379     ReceiveDataL(*iData);
       
   380     __FLOG(_L8("ServiceFunctionalIDL - Exit"));
       
   381     }
       
   382 
       
   383 /*
       
   384 *Processes the ModelID property transaction response phase.
       
   385 */
       
   386 void CMTPSetDevicePropValue::CompleteServiceModelIDL()
       
   387     {
       
   388     __FLOG(_L8("CompleteServiceModelIDL - Entry"));
       
   389     SendResponseL(EMTPRespCodeAccessDenied);
       
   390     __FLOG(_L8("CompleteServiceModelIDL - Exit"));
       
   391     }
       
   392 
       
   393 /*
       
   394 *ModelID property. 
       
   395 */
       
   396 void CMTPSetDevicePropValue::ServiceModelIDL()
       
   397     {	 
       
   398     __FLOG(_L8("ServiceModelIDL - Entry")); 	
       
   399     ReceiveDataL(*iData);
       
   400     __FLOG(_L8("ServiceModelIDL - Exit"));
       
   401     }
       
   402 
       
   403 /*
       
   404 *Processes the UseDeviceStage property transaction response phase.
       
   405 */
       
   406 void CMTPSetDevicePropValue::CompleteServiceUseDeviceStageL()
       
   407     {
       
   408     __FLOG(_L8("CompleteServiceUseDeviceStageL - Entry"));
       
   409     SendResponseL(EMTPRespCodeAccessDenied);
       
   410     __FLOG(_L8("CompleteServiceUseDeviceStageL - Exit"));
       
   411     }
       
   412 
       
   413 /*
       
   414 *UseDeviceStage property. 
       
   415 */
       
   416 void CMTPSetDevicePropValue::ServiceUseDeviceStageL()
       
   417     {	 
       
   418     __FLOG(_L8("ServiceUseDeviceStageL - Entry")); 	
       
   419     ReceiveDataL(iUint8);
       
   420     __FLOG(_L8("ServiceUseDeviceStageL - Exit"));
       
   421     }