|
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/cmtpsvcgetreferences.cpp |
|
15 |
|
16 #include <mtp/cmtptypearray.h> |
|
17 #include <mtp/mmtpdataproviderframework.h> |
|
18 #include <mtp/mmtpreferencemgr.h> |
|
19 #include <mtp/tmtptyperequest.h> |
|
20 #include <mtp/cmtpobjectmetadata.h> |
|
21 #include <mtp/mmtpobjectmgr.h> |
|
22 |
|
23 #include "cmtpsvcgetreferences.h" |
|
24 #include "mmtpservicedataprovider.h" |
|
25 #include "mmtpsvcobjecthandler.h" |
|
26 |
|
27 __FLOG_STMT(_LIT8(KComponent,"SvcGetRef");) |
|
28 |
|
29 EXPORT_C MMTPRequestProcessor* CMTPSvcGetReferences::NewL(MMTPDataProviderFramework& aFramework, |
|
30 MMTPConnection& aConnection, |
|
31 MMTPServiceDataProvider& aDataProvider) |
|
32 { |
|
33 CMTPSvcGetReferences* self = new (ELeave) CMTPSvcGetReferences(aFramework, aConnection, aDataProvider); |
|
34 return self; |
|
35 } |
|
36 |
|
37 /** |
|
38 Destructor |
|
39 */ |
|
40 EXPORT_C CMTPSvcGetReferences::~CMTPSvcGetReferences() |
|
41 { |
|
42 __FLOG(_L8("~CMTPSvcGetReferences - Entry")); |
|
43 delete iReferences; |
|
44 delete iReceivedObjectMetaData; |
|
45 __FLOG(_L8("~CMTPSvcGetReferences - Exit")); |
|
46 __FLOG_CLOSE; |
|
47 } |
|
48 |
|
49 /** |
|
50 Standard c++ constructor |
|
51 */ |
|
52 CMTPSvcGetReferences::CMTPSvcGetReferences(MMTPDataProviderFramework& aFramework, |
|
53 MMTPConnection& aConnection, |
|
54 MMTPServiceDataProvider& aDataProvider) |
|
55 :CMTPRequestProcessor(aFramework, aConnection, 0, NULL), |
|
56 iDataProvider(aDataProvider) |
|
57 { |
|
58 __FLOG_OPEN(KMTPSubsystem, KComponent); |
|
59 __FLOG(_L8("Constructed")); |
|
60 } |
|
61 |
|
62 TMTPResponseCode CMTPSvcGetReferences::CheckRequestL() |
|
63 { |
|
64 __FLOG(_L8("CheckRequestL - Entry")); |
|
65 |
|
66 TMTPResponseCode responseCode = CMTPRequestProcessor::CheckRequestL(); |
|
67 if (EMTPRespCodeOK == responseCode) |
|
68 { |
|
69 TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1); |
|
70 iReceivedObjectMetaData = CMTPObjectMetaData::NewL(); |
|
71 // Check object handle |
|
72 MMTPObjectMgr& objMgr(iFramework.ObjectMgr()); |
|
73 // Check whether object handle is valid |
|
74 if (objMgr.ObjectL(objectHandle, *iReceivedObjectMetaData)) |
|
75 { |
|
76 // Check whether the owner of this object is correct data provider |
|
77 if (iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EDataProviderId) != iFramework.DataProviderId()) |
|
78 { |
|
79 responseCode = EMTPRespCodeInvalidObjectHandle; |
|
80 __FLOG(_L8("CheckRequestL - DataProviderId dismatch")); |
|
81 } |
|
82 else |
|
83 { |
|
84 // Check format code |
|
85 TUint16 formatCode = iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EFormatCode); |
|
86 if (!iDataProvider.ObjectHandler(formatCode)) |
|
87 { |
|
88 responseCode = EMTPRespCodeInvalidObjectHandle; |
|
89 } |
|
90 } |
|
91 } |
|
92 else |
|
93 { |
|
94 responseCode = EMTPRespCodeInvalidObjectHandle; |
|
95 } |
|
96 } |
|
97 __FLOG_VA((_L8("CheckRequestL - Exit with code: 0x%04X"), responseCode)); |
|
98 return responseCode; |
|
99 } |
|
100 |
|
101 void CMTPSvcGetReferences::ServiceL() |
|
102 { |
|
103 __FLOG(_L8("ServiceL - Entry")); |
|
104 TUint16 formatCode = iReceivedObjectMetaData->Uint(CMTPObjectMetaData::EFormatCode); |
|
105 delete iReferences; |
|
106 iReferences = NULL; |
|
107 iReferences = CMTPTypeArray::NewL(EMTPTypeAUINT32); |
|
108 iDataProvider.ObjectHandler(formatCode)->GetObjectReferenceL(*iReceivedObjectMetaData, *iReferences); |
|
109 SendDataL(*iReferences); |
|
110 __FLOG(_L8("ServiceL - Exit")); |
|
111 } |