|
1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Image thumbnail provider plugin |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ecom/ecom.h> |
|
20 #include <implementationproxy.h> |
|
21 |
|
22 #include "thumbnailimageprovider.h" |
|
23 #include "thumbnailimagedecoder.h" |
|
24 #include "thumbnailimagedecoderv2.h" |
|
25 #include "thumbnailmanageruids.hrh" |
|
26 #include "thumbnaillog.h" |
|
27 #include "thumbnailmanagerconstants.h" |
|
28 |
|
29 #ifndef IMPLEMENTATION_PROXY_ENTRY |
|
30 typedef TAny* TProxyNewLPtr; |
|
31 #define IMPLEMENTATION_PROXY_ENTRY(aUid, aFuncPtr) \ |
|
32 { {aUid}, static_cast<TProxyNewLPtr>(aFuncPtr) } |
|
33 #endif |
|
34 |
|
35 |
|
36 // ======== MEMBER FUNCTIONS ======== |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // CThumbnailImageProvider::NewL() |
|
40 // Two-phased constructor. |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 CThumbnailImageProvider* CThumbnailImageProvider::NewL() |
|
44 { |
|
45 CThumbnailImageProvider* self = new( ELeave )CThumbnailImageProvider(); |
|
46 return self; |
|
47 } |
|
48 |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // CThumbnailImageProvider::CThumbnailImageProvider() |
|
52 // C++ default constructor can NOT contain any code, that might leave. |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CThumbnailImageProvider::CThumbnailImageProvider() |
|
56 { |
|
57 TN_DEBUG1( "CThumbnailImageProvider::CThumbnailImageProvider()" ); |
|
58 } |
|
59 |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // CThumbnailImageProvider::~CThumbnailImageProvider() |
|
63 // Destructor. |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 CThumbnailImageProvider::~CThumbnailImageProvider() |
|
67 { |
|
68 TN_DEBUG1( "CThumbnailImageProvider::~CThumbnailImageProvider()" ); |
|
69 delete iImageDecoder; |
|
70 delete iImageDecoderv2; |
|
71 REComSession::DestroyedImplementation( iDtor_ID_Key ); |
|
72 } |
|
73 |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // CThumbnailImageProvider::GetThumbnailL() |
|
77 // Provides the thumbnail image |
|
78 // --------------------------------------------------------------------------- |
|
79 // |
|
80 void CThumbnailImageProvider::GetThumbnailL( RFs& aFs, RFile64& aFile, const |
|
81 TDataType& aMimeType, const CThumbnailManager::TThumbnailFlags aFlags, |
|
82 const TDisplayMode /*aDisplayMode*/, const CThumbnailManager::TThumbnailQualityPreference aQualityPreference ) |
|
83 { |
|
84 TN_DEBUG1( "CThumbnailImageProvider::GetThumbnailL() start" ); |
|
85 |
|
86 if ( !iImageDecoder ) |
|
87 { |
|
88 iImageDecoder = new( ELeave )CThumbnailImageDecoder( aFs ); |
|
89 } |
|
90 |
|
91 iMimeType = aMimeType; |
|
92 iFlags = aFlags; |
|
93 iQualityPreference = aQualityPreference; |
|
94 //set default mode displaymode from global constants |
|
95 iDisplayMode = KStoreDisplayMode; |
|
96 |
|
97 iImageDecoder->CreateL( aFile, *iObserver, iQualityPreference, iMimeType, iTargetSize ); |
|
98 iOriginalSize = iImageDecoder->OriginalSize(); |
|
99 iImageDecoder->DecodeL( iDisplayMode, iFlags ); |
|
100 |
|
101 TN_DEBUG1( "CThumbnailImageProvider::GetThumbnailL() end" ); |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // CThumbnailImageProvider::GetThumbnailL() |
|
106 // Provides the thumbnail image |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 void CThumbnailImageProvider::GetThumbnailL( RFs& aFs, TDesC8* aBuffer, const |
|
110 TDataType& aMimeType, const CThumbnailManager::TThumbnailFlags aFlags, |
|
111 const TDisplayMode /*aDisplayMode*/, const CThumbnailManager::TThumbnailQualityPreference aQualityPreference ) |
|
112 { |
|
113 TN_DEBUG1( "CThumbnailImageProvider::GetThumbnailL() start" ); |
|
114 |
|
115 if ( !iImageDecoder ) |
|
116 { |
|
117 iImageDecoder = new( ELeave )CThumbnailImageDecoder( aFs ); |
|
118 } |
|
119 |
|
120 iMimeType = aMimeType; |
|
121 iFlags = aFlags; |
|
122 iQualityPreference = aQualityPreference; |
|
123 //set default mode displaymode from global constants |
|
124 iDisplayMode = KStoreDisplayMode; |
|
125 |
|
126 iImageDecoder->CreateL( aBuffer, *iObserver, iQualityPreference, iMimeType, iTargetSize ); |
|
127 iOriginalSize = iImageDecoder->OriginalSize(); |
|
128 iImageDecoder->DecodeL( iDisplayMode, iFlags ); |
|
129 |
|
130 TN_DEBUG1( "CThumbnailImageProvider::GetThumbnailL() end" ); |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // CThumbnailImageProvider::GetThumbnailL() |
|
135 // Provides the thumbnail image |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 void CThumbnailImageProvider::GetThumbnailL( RFs& aFs, TDesC8& aBuffer) |
|
139 { |
|
140 TN_DEBUG1( "CThumbnailImageProvider::GetThumbnailL() start" ); |
|
141 |
|
142 if ( !iImageDecoderv2 ) |
|
143 { |
|
144 iImageDecoderv2 = new( ELeave )CThumbnailImageDecoderv2( aFs); |
|
145 } |
|
146 |
|
147 iImageDecoderv2->CreateL(aBuffer, *iObserver); |
|
148 |
|
149 iImageDecoderv2->DecodeL(); |
|
150 |
|
151 TN_DEBUG1( "CThumbnailImageProvider::GetThumbnailL() end" ); |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // Cancel thumbnail request |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 void CThumbnailImageProvider::CancelGetThumbnail() |
|
159 { |
|
160 if ( iImageDecoder ) |
|
161 { |
|
162 iImageDecoder->Cancel(); |
|
163 } |
|
164 if ( iImageDecoderv2) |
|
165 { |
|
166 iImageDecoderv2->Cancel(); |
|
167 } |
|
168 } |
|
169 |
|
170 // ======== GLOBAL FUNCTIONS ======== |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // ImplementationTable |
|
174 // Define the interface UIDs |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 const TImplementationProxy ImplementationTable[] = |
|
178 { |
|
179 IMPLEMENTATION_PROXY_ENTRY( THUMBNAIL_IMAGE_PROVIDER_IMP_UID, |
|
180 CThumbnailImageProvider::NewL ) |
|
181 }; |
|
182 |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // ImplementationGroupProxy |
|
186 // The one and only exported function that is the ECom entry point |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& |
|
190 aTableCount ) |
|
191 { |
|
192 aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); |
|
193 return ImplementationTable; |
|
194 } |
|
195 |
|
196 //End of file |