|
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 <bautils.h> // FileExists |
|
22 |
|
23 #include <mtp/cmtpobjectmetadata.h> |
|
24 #include <mtp/mmtpdataproviderframework.h> |
|
25 #include <mtp/cmtptypeopaquedata.h> |
|
26 #include <thumbnailmanager.h> |
|
27 |
|
28 #include "cmtpimagedpgetthumb.h" |
|
29 #include "mtpimagedppanic.h" |
|
30 #include "mtpimagedputilits.h" |
|
31 #include "cmtpimagedpthumbnailcreator.h" |
|
32 #include "cmtpimagedpobjectpropertymgr.h" |
|
33 #include "cmtpimagedp.h" |
|
34 |
|
35 // Class constants. |
|
36 __FLOG_STMT(_LIT8(KComponent,"ImageDpGetThumb");) |
|
37 |
|
38 |
|
39 /** |
|
40 Two-phase construction method |
|
41 @param aPlugin The data provider plugin |
|
42 @param aFramework The data provider framework |
|
43 @param aConnection The connection from which the request comes |
|
44 @return a pointer to the created request processor object |
|
45 */ |
|
46 MMTPRequestProcessor* CMTPImageDpGetThumb::NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider) |
|
47 { |
|
48 CMTPImageDpGetThumb* self = new (ELeave) CMTPImageDpGetThumb(aFramework, aConnection,aDataProvider); |
|
49 CleanupStack::PushL(self); |
|
50 self->ConstructL(); |
|
51 CleanupStack::Pop(self); |
|
52 return self; |
|
53 } |
|
54 |
|
55 /** |
|
56 Destructor |
|
57 */ |
|
58 CMTPImageDpGetThumb::~CMTPImageDpGetThumb() |
|
59 { |
|
60 __FLOG(_L8(">> CMTPImageDpGetThumb::~CMTPImageDpGetThumb")); |
|
61 delete iThumb; |
|
62 delete iObjectMeta; |
|
63 __FLOG(_L8("<< CMTPImageDpGetThumb::~CMTPImageDpGetThumb")); |
|
64 __FLOG_CLOSE; |
|
65 } |
|
66 |
|
67 /** |
|
68 Standard c++ constructor |
|
69 */ |
|
70 CMTPImageDpGetThumb::CMTPImageDpGetThumb(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection,CMTPImageDataProvider& aDataProvider) : |
|
71 CMTPRequestProcessor(aFramework, aConnection, 0, NULL),imgDp(aDataProvider) |
|
72 { |
|
73 |
|
74 } |
|
75 |
|
76 /** |
|
77 Second-phase constructor. |
|
78 */ |
|
79 void CMTPImageDpGetThumb::ConstructL() |
|
80 { |
|
81 __FLOG_OPEN(KMTPSubsystem, KComponent); |
|
82 __FLOG(_L8("CMTPImageDpGetThumb::ConstructL")); |
|
83 iThumb = CMTPTypeOpaqueData::NewL(); |
|
84 iObjectMeta = CMTPObjectMetaData::NewL(); |
|
85 __FLOG(_L8("CMTPImageDpGetThumb::ConstructL")); |
|
86 } |
|
87 |
|
88 |
|
89 TMTPResponseCode CMTPImageDpGetThumb::CheckRequestL() |
|
90 { |
|
91 __FLOG(_L8(">> CMTPImageDpGetThumb::CheckRequestL")); |
|
92 TMTPResponseCode result = MTPImageDpUtilits::VerifyObjectHandleL(iFramework, Request().Uint32(TMTPTypeRequest::ERequestParameter1), *iObjectMeta); |
|
93 __FLOG(_L8("<< CMTPImageDpGetThumb::CheckRequestL")); |
|
94 return result; |
|
95 } |
|
96 |
|
97 |
|
98 /** |
|
99 GetObject request handler |
|
100 */ |
|
101 void CMTPImageDpGetThumb::ServiceL() |
|
102 { |
|
103 __FLOG(_L8(">> CMTPImageDpGetThumb::ServiceL")); |
|
104 TInt err = KErrNone; |
|
105 TEntry fileEntry; |
|
106 |
|
107 User::LeaveIfError(iFramework.Fs().Entry(iObjectMeta->DesC(CMTPObjectMetaData::ESuid), fileEntry)); |
|
108 imgDp.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDefaultFlags); |
|
109 if(fileEntry.iSize > KFileSizeMax) |
|
110 { |
|
111 __FLOG(_L8(">> CMTPImageDpGetThumb::ServiceL, fileEntry.iSize > KFileSizeMax")); |
|
112 imgDp.ThumbnailManager().GetThumbMgr()->SetFlagsL(CThumbnailManager::EDoNotCreate); |
|
113 } |
|
114 imgDp.ThumbnailManager().GetThumbnailL(iObjectMeta->DesC(CMTPObjectMetaData::ESuid), *iThumb, err); |
|
115 User::LeaveIfError(err); |
|
116 SendDataL(*iThumb); |
|
117 __FLOG(_L8("<< CMTPImageDpGetThumb::ServiceL")); |
|
118 } |
|
119 |
|
120 TBool CMTPImageDpGetThumb::DoHandleCompletingPhaseL() |
|
121 { |
|
122 return CMTPRequestProcessor::DoHandleCompletingPhaseL(); |
|
123 } |
|
124 |
|
125 |
|
126 // End Of File |