mtpfws/mtpfw/dataproviders/devdp/src/cmtpresetdevicepropvalue.cpp
changeset 0 d0791faffa3f
child 4 60a94a45d437
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/mtpdatatypeconstants.h>
       
    21 #include <mtp/mmtpframeworkconfig.h>
       
    22 #include <centralrepository.h>
       
    23 
       
    24 #include "cmtpdevicedatastore.h"
       
    25 #include "cmtpresetdevicepropvalue.h"
       
    26 #include "mtpdevicedpconst.h"
       
    27 #include "mtpdevdppanic.h"
       
    28 
       
    29 // Class constants.
       
    30 __FLOG_STMT(_LIT8(KComponent,"ResetDevicePropValue");)
       
    31 
       
    32 /**
       
    33 Two-phase constructor.
       
    34 @param aPlugin  The data provider plugin
       
    35 @param aFramework The data provider framework
       
    36 @param aConnection The connection from which the request comes
       
    37 @return a pointer to the created request processor object.
       
    38 */  
       
    39 MMTPRequestProcessor* CMTPResetDevicePropValue::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection)
       
    40     {
       
    41     CMTPResetDevicePropValue* self = new (ELeave) CMTPResetDevicePropValue(aFramework, aConnection);
       
    42     CleanupStack::PushL(self);
       
    43     self->ConstructL();
       
    44     CleanupStack::Pop(self);
       
    45     return self;
       
    46     }
       
    47 
       
    48 /**
       
    49 Destructor
       
    50 */    
       
    51 CMTPResetDevicePropValue::~CMTPResetDevicePropValue()
       
    52     {    
       
    53     __FLOG(_L8("~CMTPResetDevicePropValue - Entry"));
       
    54         iDpSingletons.Close();
       
    55         delete iData;
       
    56         delete iRepository;
       
    57     __FLOG(_L8("~CMTPResetDevicePropValue - Exit"));
       
    58     __FLOG_CLOSE;
       
    59     }
       
    60 
       
    61 /**
       
    62 Standard c++ constructor
       
    63 */    
       
    64 CMTPResetDevicePropValue::CMTPResetDevicePropValue(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection) :
       
    65  CMTPRequestProcessor(aFramework, aConnection, 0, NULL)
       
    66     {
       
    67     
       
    68     }
       
    69     
       
    70 /**
       
    71 Second-phase construction
       
    72 */    
       
    73 void CMTPResetDevicePropValue::ConstructL()
       
    74     {
       
    75     __FLOG_OPEN(KMTPSubsystem, KComponent);
       
    76     __FLOG(_L8("ConstructL - Entry")); 
       
    77     iDpSingletons.OpenL(iFramework);
       
    78 	const TUint32 KUidMTPRepositoryValue(0x10282FCC);
       
    79     const TUid KUidMTPRepository = {KUidMTPRepositoryValue};
       
    80     iRepository = CRepository::NewL(KUidMTPRepository);
       
    81     __FLOG(_L8("ConstructL - Exit")); 
       
    82     }
       
    83 
       
    84 /**
       
    85 SetDevicePropValue request validator.
       
    86 @return EMTPRespCodeOK if request is verified, otherwise one of the error response codes
       
    87 */
       
    88 TMTPResponseCode CMTPResetDevicePropValue::CheckRequestL()
       
    89     {
       
    90     __FLOG(_L8("CheckRequestL - Entry"));
       
    91     TMTPResponseCode respCode(EMTPRespCodeDevicePropNotSupported);
       
    92     iPropCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
       
    93     const TInt count = sizeof(KMTPDeviceDpSupportedProperties) / sizeof(KMTPDeviceDpSupportedProperties[0]);
       
    94     for (TUint i(0); ((respCode != EMTPRespCodeOK) && (i < count)); i++)
       
    95         {
       
    96         if (iPropCode == KMTPDeviceDpSupportedProperties[i])
       
    97             {
       
    98             respCode = EMTPRespCodeOK;
       
    99             }
       
   100         }
       
   101 
       
   102     if(iDpSingletons.DeviceDataStore().ExtnDevicePropDp())
       
   103         {
       
   104         respCode = EMTPRespCodeOK;
       
   105         }
       
   106     __FLOG(_L8("CheckRequestL - Exit"));
       
   107     return respCode;
       
   108     }
       
   109 /**
       
   110 ResetDevicePropValue request handler.
       
   111 */ 	
       
   112 void CMTPResetDevicePropValue::ServiceL()
       
   113     {
       
   114     __FLOG(_L8("ServiceL - Entry"));
       
   115     iPropCode = Request().Uint32(TMTPTypeRequest::ERequestParameter1);
       
   116     MExtnDevicePropDp* extnDevplugin = iDpSingletons.DeviceDataStore().ExtnDevicePropDp();
       
   117     switch (iPropCode)
       
   118         {
       
   119         //Added all new prpoerties here we have to add other properties that not present here*/
       
   120         case EMTPDevicePropCodeSessionInitiatorVersionInfo:
       
   121             ServiceSessionInitiatorVersionInfoL();
       
   122         break;
       
   123         case EMTPDevicePropCodePerceivedDeviceType:
       
   124             ServicePerceivedDeviceTypeL();
       
   125         break;
       
   126 
       
   127         case EMTPDevicePropCodeDeviceIcon:
       
   128             ServiceDeviceIconL();
       
   129         break;
       
   130 
       
   131         case EMTPDevicePropCodeSupportedFormatsOrdered:
       
   132             ServiceSupportedFormatsOrderedL();
       
   133         break;
       
   134 
       
   135         case EMTPDevicePropCodeDateTime:
       
   136             ServiceDateTimeL();
       
   137         break;
       
   138         case EMTPDevicePropCodeFunctionalID:
       
   139         	ServiceFunctionalIDL();
       
   140         break;
       
   141         case EMTPDevicePropCodeModelID:
       
   142         	ServiceModelIDL();
       
   143         break;
       
   144         case EMTPDevicePropCodeUseDeviceStage:
       
   145         	ServiceUseDeviceStageL();
       
   146         break;
       
   147         default:         
       
   148             if(extnDevplugin)
       
   149                 { 
       
   150                 HandleExtnServiceL(iPropCode, extnDevplugin);
       
   151                 }
       
   152             else 
       
   153                 { 
       
   154                 SendResponseL(EMTPRespCodeDevicePropNotSupported);
       
   155                 }
       
   156         break;   
       
   157         }
       
   158     } 
       
   159 
       
   160  void CMTPResetDevicePropValue::HandleExtnServiceL(TInt aPropCode, MExtnDevicePropDp* aExtnDevplugin)
       
   161     {
       
   162 	  if(aExtnDevplugin->ResetDevPropertyL((TMTPDevicePropertyCode)aPropCode) == KErrNone)
       
   163 	  {
       
   164 	  SendResponseL(EMTPRespCodeOK);
       
   165 	  }
       
   166 	  else
       
   167 	  {
       
   168 	  SendResponseL(EMTPRespCodeDevicePropNotSupported);
       
   169 	  }
       
   170     
       
   171     }
       
   172 
       
   173 /**
       
   174 Service session initiator property.
       
   175 */ 
       
   176 void CMTPResetDevicePropValue::ServiceSessionInitiatorVersionInfoL()
       
   177     {  
       
   178     __FLOG(_L8("SetSessionInitiatorVersionInfo - Entry")); 
       
   179     iDpSingletons.DeviceDataStore().SetSessionInitiatorVersionInfoL( iDpSingletons.DeviceDataStore().SessionInitiatorVersionInfoDefault());
       
   180     SendResponseL(EMTPRespCodeOK);
       
   181     __FLOG(_L8("SetSessionInitiatorVersionInfo - Exit"));
       
   182     }
       
   183 
       
   184 /**
       
   185 *Service the PerceivedDeviceType property.
       
   186 *it is not set type it should be removed 
       
   187 **/
       
   188 void CMTPResetDevicePropValue::ServicePerceivedDeviceTypeL()
       
   189     {  
       
   190     __FLOG(_L8("ServicePerceivedDeviceType - Entry")); 
       
   191     //PerceivedDeviceType is of type get only .
       
   192     SendResponseL(EMTPRespCodeAccessDenied);
       
   193     __FLOG(_L8("ServicePerceivedDeviceType - Exit"));
       
   194     }
       
   195 
       
   196 /**
       
   197 Service the Date Time property.
       
   198 */ 
       
   199 void CMTPResetDevicePropValue::ServiceDateTimeL()
       
   200     {  
       
   201     __FLOG(_L8("ServiceDateTime - Entry")); 
       
   202     SendResponseL(EMTPRespCodeOperationNotSupported);
       
   203     __FLOG(_L8("ServiceDateTime - Exit"));
       
   204     }
       
   205 
       
   206 
       
   207 /*
       
   208 *Service the Device Icon property and CompleteDeviceIcon.
       
   209 As of now implemented as device property of type get.
       
   210 */   
       
   211 void CMTPResetDevicePropValue::ServiceDeviceIconL()
       
   212     {  
       
   213     __FLOG(_L8("ServiceDeviceIcon - Entry")); 
       
   214     //DeviceIcon property is implemented as get only .
       
   215     SendResponseL(EMTPRespCodeAccessDenied);
       
   216     __FLOG(_L8("ServiceDeviceIcon - Exit"));
       
   217     }
       
   218 
       
   219 /*
       
   220 *ServiceSupportedFormatsOrdered property. it is get only type.
       
   221 */
       
   222 void CMTPResetDevicePropValue::ServiceSupportedFormatsOrderedL()
       
   223     {  
       
   224     __FLOG(_L8("ServiceSupportedFormatsOrdered - Entry"));  
       
   225     //no need to recive this data beacuse it is Get property
       
   226     //iDpSingletons.DeviceDataStore().SetFormatOrdered( iDpSingletons.DeviceDataStore().FormatOrderedDefault());
       
   227     SendResponseL(EMTPRespCodeAccessDenied);
       
   228     __FLOG(_L8("ServicePerceivedDeviceType - Exit"));
       
   229     }
       
   230 
       
   231 /*
       
   232 *FunctionalID property. 
       
   233 */
       
   234 void CMTPResetDevicePropValue::ServiceFunctionalIDL()
       
   235     {	 
       
   236     __FLOG(_L8("ServiceFunctionalIDL - Entry")); 
       
   237     delete iData;
       
   238     iData = GetGUIDL( MMTPFrameworkConfig::EDeviceDefaultFuncationalID ); 
       
   239     SaveGUID(MMTPFrameworkConfig::EDeviceCurrentFuncationalID, *iData);
       
   240     SendResponseL(EMTPRespCodeOK);
       
   241     __FLOG(_L8("ServiceFunctionalIDL - Exit"));
       
   242     }
       
   243 
       
   244 /*
       
   245 *ModelID property. it is get only type.
       
   246 */
       
   247 void CMTPResetDevicePropValue::ServiceModelIDL()
       
   248     {	 
       
   249     __FLOG(_L8("ServiceModelIDL - Entry")); 	
       
   250     SendResponseL(EMTPRespCodeAccessDenied);
       
   251     __FLOG(_L8("ServiceModelIDL - Exit"));
       
   252     }
       
   253 
       
   254 /*
       
   255 *UseDeviceStage property. it is get only type.
       
   256 */
       
   257 void CMTPResetDevicePropValue::ServiceUseDeviceStageL()
       
   258     {	 
       
   259     __FLOG(_L8("ServiceUseDeviceStageL - Entry")); 	
       
   260     SendResponseL(EMTPRespCodeAccessDenied);
       
   261     __FLOG(_L8("ServiceUseDeviceStageL - Exit"));
       
   262     }
       
   263 
       
   264 TMTPTypeGuid* CMTPResetDevicePropValue::GetGUIDL(const TUint aKey)
       
   265     {
       
   266     
       
   267     TBuf8<KMTPTypeUINT128Size> ptr;
       
   268     
       
   269     iRepository->Get(aKey,ptr);
       
   270     
       
   271     TMTPTypeGuid* ret = new (ELeave) TMTPTypeGuid( ptr );
       
   272     
       
   273     return ret;
       
   274     }
       
   275 
       
   276 void CMTPResetDevicePropValue::SaveGUID( const TUint aKey,  TMTPTypeGuid& aValue )
       
   277     {
       
   278     TPtrC8 ptr;
       
   279     if ( KMTPChunkSequenceCompletion == aValue.FirstReadChunk(ptr) )
       
   280     	{
       
   281     	iRepository->Set(aKey,ptr);
       
   282     	}
       
   283     }