|
1 /* |
|
2 * Copyright (c) 2005-2006 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: CMnMapImageServiceBase class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <fbs.h> |
|
21 |
|
22 #include "mndebug.h" |
|
23 #include "mnerrors.h" |
|
24 #include "mninternal.h" |
|
25 #include "mninternal.inl" |
|
26 |
|
27 #include "mnmapimageservicebase.h" |
|
28 |
|
29 // ========================== MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // --------------------------------------------------------------------------- |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 EXPORT_C CMnMapImageServiceBase::CMnMapImageServiceBase() |
|
35 { |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 EXPORT_C CMnMapImageServiceBase::~CMnMapImageServiceBase() |
|
42 { |
|
43 if ( iBitmap ) |
|
44 { |
|
45 delete iBitmap; |
|
46 } |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 EXPORT_C void CMnMapImageServiceBase::BaseConstructL() |
|
53 { |
|
54 CMnServiceBase::BaseConstructL(); |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 EXPORT_C const TMnMapImageParams& CMnMapImageServiceBase::MapImageParams() const |
|
61 { |
|
62 return iMapImageParams; |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 EXPORT_C TMnMapImageParams& CMnMapImageServiceBase::MapImageParams() |
|
69 { |
|
70 return iMapImageParams; |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 EXPORT_C void CMnMapImageServiceBase::SetMapImageParams( const TMnMapImageParams& aImageParams ) |
|
77 { |
|
78 iMapImageParams = aImageParams; |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 EXPORT_C TRect CMnMapImageServiceBase::TargetRect() const |
|
85 { |
|
86 if ( iBitmap ) |
|
87 { |
|
88 return TRect( iTargetOrigin, iBitmap->SizeInPixels() ); |
|
89 } |
|
90 else |
|
91 { |
|
92 return TRect( 0, 0, 0, 0 ); |
|
93 } |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 EXPORT_C CMnMapImage::TShowOptions CMnMapImageServiceBase::ShowOptions() const |
|
100 { |
|
101 return iShowOptions; |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 EXPORT_C CFbsBitmap& CMnMapImageServiceBase::TargetBitmap() const |
|
108 { |
|
109 if ( !iBitmap ) |
|
110 { |
|
111 PanicServer( KErrGeneral ); |
|
112 } |
|
113 return *iBitmap; |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 EXPORT_C void CMnMapImageServiceBase::CompleteRendering() |
|
120 { |
|
121 LOG("CMnMapImageServiceBase::CompleteRenderingL in"); |
|
122 if ( CurrentAsyncRequest() != EMnIpcRenderImage ) |
|
123 { |
|
124 PanicServer( KMnPanicAttemptToCompleteNoRequest ); |
|
125 } |
|
126 |
|
127 if ( iMapImageParams.ImageType() == TMnMapImageParams::ETypeUnspecified ) |
|
128 { |
|
129 PanicServer( KMnPanicInvalidResult ); |
|
130 } |
|
131 |
|
132 TPckg<TMnMapImageParams> paramsPack( iMapImageParams ); |
|
133 TInt err = iMessage.Write( EMnIpcImageParamsParamIndex, paramsPack ); |
|
134 |
|
135 CompleteRequest( err ); |
|
136 |
|
137 delete iBitmap; |
|
138 iBitmap = NULL; |
|
139 |
|
140 LOG("CMnMapImageServiceBase::CompleteRenderingL out"); |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // From class CAknAppServiceBase |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 EXPORT_C void CMnMapImageServiceBase::ServiceL( const RMessage2& aMessage ) |
|
148 { |
|
149 //LOG1("CMnMapImageServiceBase::ServiceL in, function %d", aMessage.Function()); |
|
150 |
|
151 switch ( aMessage.Function() ) |
|
152 { |
|
153 case EMnIpcRenderImage: |
|
154 PrepareAsyncRequestL( aMessage ); |
|
155 StartAsyncRequestL( aMessage ); |
|
156 break; |
|
157 |
|
158 case EMnIpcCancel: |
|
159 HandleCancelRequestL( aMessage ); |
|
160 break; |
|
161 |
|
162 default: |
|
163 CMnServiceBase::ServiceL( aMessage ); |
|
164 } |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 void CMnMapImageServiceBase::StartAsyncRequestL( const RMessage2& aMessage ) |
|
171 { |
|
172 LOG("CMnMapImageServiceBase::StartAsyncRequestL in"); |
|
173 |
|
174 switch ( CurrentAsyncRequest() ) |
|
175 { |
|
176 case EMnIpcRenderImage: |
|
177 UnpackImageParamsL( aMessage ); |
|
178 UnpackOptionsL( aMessage ); |
|
179 UnpackBitmapHandleL( aMessage ); |
|
180 HandleRenderingL(); |
|
181 break; |
|
182 |
|
183 default: |
|
184 User::Leave( KErrNotSupported ); |
|
185 } |
|
186 |
|
187 LOG("CMnMapImageServiceBase::StartAsyncRequestL out"); |
|
188 } |
|
189 |
|
190 // --------------------------------------------------------------------------- |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 void CMnMapImageServiceBase::UnpackOptionsL( const RMessage2& aMessage ) |
|
194 { |
|
195 LOG("CMnMapImageServiceBase::UnpackOptionsL"); |
|
196 |
|
197 TMnMapImageOptions options; |
|
198 TPckg<TMnMapImageOptions> optsPack( options ); |
|
199 aMessage.ReadL( EMnIpcImageOptionsParamIndex, optsPack ); |
|
200 |
|
201 if ( options.iShowOptions & CMnMapImage::EShowOptionCurrentLocation ) |
|
202 { |
|
203 // leaves with KErrPermissionDenied if client does not have Location capability |
|
204 aMessage.HasCapabilityL( ECapabilityLocation ); |
|
205 } |
|
206 |
|
207 iShowOptions = options.iShowOptions; |
|
208 iTargetOrigin = options.iTargetOrigin; |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------------------------- |
|
212 // --------------------------------------------------------------------------- |
|
213 // |
|
214 void CMnMapImageServiceBase::UnpackImageParamsL( const RMessage2& aMessage ) |
|
215 { |
|
216 LOG("CMnMapImageServiceBase::UnpackImageParamsL"); |
|
217 |
|
218 TPckg<TMnMapImageParams> paramsPack( iMapImageParams ); |
|
219 aMessage.ReadL( EMnIpcImageParamsParamIndex, paramsPack ); |
|
220 } |
|
221 |
|
222 // --------------------------------------------------------------------------- |
|
223 // --------------------------------------------------------------------------- |
|
224 // |
|
225 void CMnMapImageServiceBase::UnpackBitmapHandleL( const RMessage2& aMessage ) |
|
226 { |
|
227 TInt bitmapHandle = aMessage.Int2(); // EMnIpcImageBitmapHandleParamIndex == 2 |
|
228 LOG1("CMnMapImageServiceBase::UnpackBitmapHandleL, handle %d", bitmapHandle); |
|
229 |
|
230 ASSERT( !iBitmap ); |
|
231 |
|
232 iBitmap = new (ELeave) CFbsBitmap; |
|
233 User::LeaveIfError( iBitmap->Duplicate( bitmapHandle ) ); |
|
234 } |
|
235 |
|
236 // --------------------------------------------------------------------------- |
|
237 // --------------------------------------------------------------------------- |
|
238 // |
|
239 void CMnMapImageServiceBase::HandleCancelRequestL( const RMessage2& aMessage ) |
|
240 { |
|
241 TInt request = CurrentAsyncRequest(); |
|
242 |
|
243 CMnServiceBase::HandleCancelRequestL( aMessage ); |
|
244 |
|
245 if ( request == EMnIpcRenderImage ) |
|
246 { |
|
247 delete iBitmap; |
|
248 iBitmap = NULL; |
|
249 } |
|
250 } |