mtpfws/mtpfw/dataproviders/dputility/src/mmtpsvcobjecthandler.cpp
changeset 0 d0791faffa3f
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 // mw/remoteconn/mtpfws/mtpfw/dataproviders/dputility/src/mmtpsvcobjecthandler.cpp
       
    15 
       
    16 #include <mtp/mmtptype.h>
       
    17 
       
    18 #include <mtp/cmtptypeobjectproplist.h>
       
    19 #include <mtp/mtpdatatypeconstants.h>
       
    20 #include "mmtpsvcobjecthandler.h"
       
    21 #include "mtpsvcdpconst.h"
       
    22 
       
    23 EXPORT_C TMTPResponseCode MMTPSvcObjectHandler::SendObjectInfoL(const CMTPTypeObjectInfo& /*aObjectInfo*/, TUint32& /*aParentHandle*/, TDes& /*aSuid*/)
       
    24 	{
       
    25 	return EMTPRespCodeOperationNotSupported;
       
    26 	}
       
    27 
       
    28 EXPORT_C TMTPResponseCode MMTPSvcObjectHandler::GetObjectInfoL(const CMTPObjectMetaData& /*aObjectMetaData*/, CMTPTypeObjectInfo& /*aObjectInfo*/)
       
    29 	{
       
    30 	return EMTPRespCodeOperationNotSupported;
       
    31 	}
       
    32 
       
    33 EXPORT_C TMTPResponseCode MMTPSvcObjectHandler::SetObjectReferenceL(const CMTPObjectMetaData& /*aObjectMetaData*/, const CMTPTypeArray& /*aReferences*/)
       
    34 	{
       
    35 	return EMTPRespCodeOperationNotSupported;
       
    36 	}
       
    37 
       
    38 EXPORT_C TMTPResponseCode MMTPSvcObjectHandler::GetObjectReferenceL(const CMTPObjectMetaData& /*aObjectMetaData*/, CMTPTypeArray& /*aReferences*/)
       
    39 	{
       
    40 	return EMTPRespCodeOperationNotSupported;
       
    41 	}
       
    42 
       
    43 EXPORT_C TMTPResponseCode MMTPSvcObjectHandler::CopyObject(const CMTPObjectMetaData& /*aObjectMetaData*/, TUint32 /*aDestStorageId*/, TUint32 /*aNewParentHandle*/)
       
    44 	{
       
    45 	return EMTPRespCodeOperationNotSupported;
       
    46 	}
       
    47 
       
    48 EXPORT_C TMTPResponseCode MMTPSvcObjectHandler::MoveObject(const CMTPObjectMetaData& /*aObjectMetaData*/, TUint32 /*aDestStorageId*/, TUint32 /*aNewParentHandle*/)
       
    49 	{
       
    50 	return EMTPRespCodeOperationNotSupported;
       
    51 	}
       
    52 
       
    53 EXPORT_C void MMTPSvcObjectHandler::CommitL()
       
    54 	{
       
    55 	
       
    56 	}
       
    57 
       
    58 EXPORT_C void MMTPSvcObjectHandler::CommitForNewObjectL(TDes& /*aSuid*/)
       
    59 	{
       
    60 	
       
    61 	}
       
    62 
       
    63 EXPORT_C void MMTPSvcObjectHandler::RollBack()
       
    64 	{
       
    65 	
       
    66 	}
       
    67 
       
    68 EXPORT_C void MMTPSvcObjectHandler::ReleaseObjectBuffer()
       
    69 	{
       
    70 	
       
    71 	}
       
    72 
       
    73 EXPORT_C TMTPResponseCode MMTPSvcObjectHandler::CheckGenObjectPropertyL(const CMTPTypeObjectPropListElement& element, TMTPOperationCode aOperationCode) const
       
    74 	{
       
    75 	TMTPResponseCode responseCode = EMTPRespCodeOK;
       
    76 	TUint16 propertyCode = element.Uint16L(CMTPTypeObjectPropListElement::EPropertyCode);
       
    77 	TUint16 dataType = element.Uint16L(CMTPTypeObjectPropListElement::EDatatype);
       
    78 	// If create new object request, then only SendObjectPropList will call this function
       
    79 	switch (propertyCode)
       
    80 		{
       
    81 		//Access denied Properties, if not for new object purpose , should response access denied.
       
    82 		case EMTPGenObjPropCodeParentID:
       
    83 		case EMTPGenObjPropCodeStorageID:
       
    84 		case EMTPGenObjPropCodeObjectFormat:
       
    85 		case EMTPGenObjPropCodeObjectSize:
       
    86 			{
       
    87 			// Properties which are contained in the operation parameters (StorageID, ParentObject, 
       
    88 			// ObjectFormat, ObjectSize) should not be included in the sent dataset for SendObjectPropList
       
    89 			if (EMTPOpCodeSendObjectPropList == aOperationCode)
       
    90 				{
       
    91 				responseCode = EMTPRespCodeInvalidDataset;
       
    92 				break;
       
    93 				}
       
    94 			
       
    95 			if(EMTPOpCodeUpdateObjectPropList != aOperationCode)
       
    96 				{
       
    97 				responseCode = EMTPRespCodeAccessDenied;
       
    98 				break;
       
    99 				}
       
   100 
       
   101 			//EMTPOpCodeUpdateObjectPropList == aOperationCode
       
   102 			if(EMTPGenObjPropCodeParentID == propertyCode)
       
   103 				{
       
   104 				if (dataType != EMTPTypeUINT32)
       
   105 					{
       
   106 					responseCode = EMTPRespCodeInvalidObjectPropFormat;
       
   107 					}
       
   108 				}
       
   109 			else if(EMTPGenObjPropCodeObjectSize == propertyCode)
       
   110 				{
       
   111 				if (dataType != EMTPTypeUINT64)
       
   112 					{
       
   113 					responseCode = EMTPRespCodeInvalidObjectPropFormat;
       
   114 					}
       
   115 				}
       
   116 			else
       
   117 				{
       
   118 				if (dataType != EMTPTypeUINT16)
       
   119 					{
       
   120 					responseCode = EMTPRespCodeInvalidObjectPropFormat;
       
   121 					}
       
   122 				}
       
   123 			break;
       
   124 			}
       
   125 		case EMTPGenObjPropCodeName:
       
   126 			{
       
   127 			if (aOperationCode == EMTPOpCodeSetObjectPropList)
       
   128 				{
       
   129 				responseCode = EMTPRespCodeAccessDenied;
       
   130 				break;
       
   131 				}
       
   132 			
       
   133 			if (dataType != EMTPTypeString)
       
   134 				{
       
   135 				responseCode = EMTPRespCodeInvalidObjectPropFormat;
       
   136 				}
       
   137 			break;
       
   138 			}
       
   139 		case EMTPGenObjPropCodePersistentUniqueObjectIdentifier:
       
   140 			{
       
   141 			// PC should not set this prop.
       
   142 			responseCode = EMTPRespCodeAccessDenied;
       
   143 			break;
       
   144 			}
       
   145 		case EMTPGenObjPropCodeObjectHidden:
       
   146 			{
       
   147 			if (aOperationCode == EMTPOpCodeSetObjectPropList)
       
   148 				{
       
   149 				// RO prop can't be changed.
       
   150 				responseCode = EMTPRespCodeAccessDenied;
       
   151 				break;
       
   152 				}
       
   153 
       
   154 			if (dataType != EMTPTypeUINT16)
       
   155 				{
       
   156 				responseCode = EMTPRespCodeInvalidObjectPropFormat;
       
   157 				}
       
   158 			break;
       
   159 			}
       
   160 		case EMTPGenObjPropCodeDateModified:
       
   161 			{
       
   162 			if (dataType != EMTPTypeString)
       
   163 				{
       
   164 				responseCode = EMTPRespCodeInvalidObjectPropFormat;
       
   165 				}
       
   166 			break;
       
   167 			}
       
   168 		case EMTPObjectPropCodeNonConsumable:
       
   169 			{
       
   170 			if (aOperationCode == EMTPOpCodeSetObjectPropList)
       
   171 				{
       
   172 				responseCode = EMTPRespCodeAccessDenied;
       
   173 				break;
       
   174 				}
       
   175 
       
   176 			if (dataType != EMTPTypeUINT8)
       
   177 				{
       
   178 				responseCode = EMTPRespCodeInvalidObjectPropFormat;
       
   179 				break;
       
   180 				}
       
   181 			
       
   182 			// Knowledge object must be non consumable
       
   183 			if (0x01 != element.Uint8L(CMTPTypeObjectPropListElement::EValue))
       
   184 				{
       
   185 				responseCode = EMTPRespCodeInvalidObjectPropValue;
       
   186 				}
       
   187 			break;
       
   188 			}
       
   189 		case EMTPSvcObjPropCodeLastAuthorProxyID:
       
   190 			{
       
   191 			if (dataType != EMTPTypeUINT128)
       
   192 				{
       
   193 				responseCode = EMTPRespCodeInvalidObjectPropFormat;
       
   194 				}
       
   195 			break;
       
   196 			}
       
   197 		default:
       
   198 			{
       
   199 			// Conform with enhanced spec, but DeleteObjectPropList return invalidpropcode
       
   200 			responseCode = EMTPRespCodeObjectPropNotSupported;
       
   201 			break;
       
   202 			}
       
   203 		}
       
   204 	return responseCode;
       
   205 	}