|
1 // Copyright (c) 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 /** |
|
17 @file |
|
18 @internalTechnology |
|
19 */ |
|
20 |
|
21 #include <f32file.h> |
|
22 #include <centralrepository.h> |
|
23 |
|
24 #include <mtp/cmtptypefile.h> |
|
25 #include <mtp/cmtpobjectmetadata.h> |
|
26 #include <mtp/mmtpdataproviderframework.h> |
|
27 #include <mtp/mmtpobjectmgr.h> |
|
28 #include <mtp/mmtpstoragemgr.h> |
|
29 #include <mtp/mtpprotocolconstants.h> |
|
30 #include <mtp/tmtptyperequest.h> |
|
31 |
|
32 #include "cmtpimagedpgetobject.h" |
|
33 #include "mtpimagedppanic.h" |
|
34 #include "cmtpimagedp.h" |
|
35 #include "mtpimagedpconst.h" |
|
36 #include "mtpimagedputilits.h" |
|
37 |
|
38 // Class constants. |
|
39 __FLOG_STMT(_LIT8(KComponent,"ImageDpGetObject");) |
|
40 |
|
41 /** |
|
42 Verification data for the GetNumObjects request |
|
43 */ |
|
44 const TMTPRequestElementInfo KMTPGetObjectPolicy[] = |
|
45 { |
|
46 {TMTPTypeRequest::ERequestParameter1, EMTPElementTypeObjectHandle, EMTPElementAttrFile, 0, 0, 0} |
|
47 }; |
|
48 |
|
49 /** |
|
50 Two-phase construction method |
|
51 @param aPlugin The data provider plugin |
|
52 @param aFramework The data provider framework |
|
53 @param aConnection The connection from which the request comes |
|
54 @return a pointer to the created request processor object |
|
55 */ |
|
56 MMTPRequestProcessor* CMTPImageDpGetObject::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& aDataProvider) |
|
57 { |
|
58 CMTPImageDpGetObject* self = new (ELeave) CMTPImageDpGetObject(aFramework, aConnection, aDataProvider); |
|
59 CleanupStack::PushL(self); |
|
60 self->ConstructL(); |
|
61 CleanupStack::Pop(self); |
|
62 return self; |
|
63 } |
|
64 |
|
65 /** |
|
66 Destructor |
|
67 */ |
|
68 CMTPImageDpGetObject::~CMTPImageDpGetObject() |
|
69 { |
|
70 __FLOG(_L8(">> ~CMTPImageDpGetObject")); |
|
71 delete iFileObject; |
|
72 __FLOG(_L8("<< ~CMTPImageDpGetObject")); |
|
73 __FLOG_CLOSE; |
|
74 } |
|
75 |
|
76 /** |
|
77 Standard c++ constructor |
|
78 */ |
|
79 CMTPImageDpGetObject::CMTPImageDpGetObject(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection, CMTPImageDataProvider& aDataProvider) : |
|
80 CMTPRequestProcessor(aFramework, aConnection, sizeof(KMTPGetObjectPolicy)/sizeof(TMTPRequestElementInfo), KMTPGetObjectPolicy), |
|
81 iDataProvider(aDataProvider) |
|
82 { |
|
83 |
|
84 } |
|
85 |
|
86 /** |
|
87 Second-phase constructor. |
|
88 */ |
|
89 void CMTPImageDpGetObject::ConstructL() |
|
90 { |
|
91 __FLOG_OPEN(KMTPSubsystem, KComponent); |
|
92 __FLOG(_L8(">> CMTPImageDpGetObject::ConstructL")); |
|
93 __FLOG(_L8("<< CMTPImageDpGetObject::ConstructL")); |
|
94 } |
|
95 |
|
96 /** |
|
97 GetObject request handler |
|
98 */ |
|
99 void CMTPImageDpGetObject::ServiceL() |
|
100 { |
|
101 __FLOG(_L8(">> CMTPImageDpGetObject::ServiceL")); |
|
102 |
|
103 TUint32 objectHandle = Request().Uint32(TMTPTypeRequest::ERequestParameter1); |
|
104 //does not take ownership |
|
105 CMTPObjectMetaData* objectInfo = iRequestChecker->GetObjectInfo(objectHandle); |
|
106 __ASSERT_DEBUG(objectInfo, Panic(EMTPImageDpObjectNull)); |
|
107 |
|
108 BuildFileObjectL(objectInfo->DesC(CMTPObjectMetaData::ESuid)); |
|
109 SendDataL(*iFileObject); |
|
110 __FLOG(_L8("<< CMTPImageDpGetObject::ServiceL")); |
|
111 } |
|
112 |
|
113 |
|
114 /** |
|
115 Build the file object data set for the file requested |
|
116 @param aFileName The file name of the requested object |
|
117 */ |
|
118 void CMTPImageDpGetObject::BuildFileObjectL(const TDesC& aFileName) |
|
119 { |
|
120 __FLOG(_L8(">> CMTPImageDpGetObject::BuildFileObjectL")); |
|
121 delete iFileObject; |
|
122 iFileObject = NULL; |
|
123 iFileObject = CMTPTypeFile::NewL(iFramework.Fs(), aFileName, EFileShareReadersOnly); |
|
124 __FLOG(_L8("<< CMTPImageDpGetObject::BuildFileObjectL")); |
|
125 } |
|
126 |
|
127 TBool CMTPImageDpGetObject::DoHandleCompletingPhaseL() |
|
128 { |
|
129 __FLOG(_L8(" CMTPImageDpGetObject::DoHandleResponsePhaseL - Entry")); |
|
130 TInt currentNewPics = 0; |
|
131 iDataProvider.Repository().Get(ENewImagesCount, currentNewPics); |
|
132 if (currentNewPics != 0) |
|
133 { |
|
134 /** |
|
135 Zero the new pictures of RProperty. |
|
136 Because we think the end-use has import all pictures as long as MTP receive one getobject operation |
|
137 |
|
138 There are two different phases to collect new pictures: |
|
139 1. In enumeration phase, calculate new pictures value from MSS in one go. |
|
140 2. After enumeration phase, dynamically calculate new pictures value from MdS by Notifications |
|
141 */ |
|
142 iDataProvider.Repository().Set(ENewImagesCount, 0); |
|
143 RProperty::Set(TUid::Uid(KMTPServerUID), KMTPNewPicKey, 0); |
|
144 } |
|
145 |
|
146 __FLOG(_L8("CMTPImageDpGetObject::DoHandleResponsePhaseL - Exit")); |
|
147 return CMTPRequestProcessor::DoHandleCompletingPhaseL(); |
|
148 } |