1 /* |
|
2 * Copyright (c) 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: CMnMapImageServiceBase class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef MN_MAPIMAGESERVICEBASE_H_ |
|
20 #define MN_MAPIMAGESERVICEBASE_H_ |
|
21 |
|
22 #include <mnservicebase.h> |
|
23 #include <mnmapimage.h> |
|
24 #include <mnmapimageparams.h> |
|
25 |
|
26 class CFbsBitmap; |
|
27 |
|
28 /** Base class for MapImage service implementations (@p KMnAppMapImageService). |
|
29 * |
|
30 * Provider Application |
|
31 * must derive its MapImage service class from this one. This base implementation |
|
32 * hides IPC communication details and provides native methods for accessing |
|
33 * various parameters, specified by client. |
|
34 * |
|
35 * Provider Application must return pointer to instance of its class, derived |
|
36 * from this class, in response to @p CAknAppService::CreateServiceL() call, |
|
37 * if given parameter is KMnAppMapImageService. |
|
38 * |
|
39 * This class defines handlers of particular requests from client as pure |
|
40 * virtual methods, which derived class must implement (@ref HandleRenderingL). |
|
41 * The parameters, which client application may specify in CMnMapImage are |
|
42 * accessible via other methods of this class. Provider Application must obey |
|
43 * these parameters. |
|
44 * |
|
45 * See parent @ref CMnServiceBase class documentation for |
|
46 * other details. |
|
47 * |
|
48 * @since 5.0 |
|
49 * @lib mnservicelib.lib |
|
50 * @ingroup MnProviderAPI |
|
51 */ |
|
52 class CMnMapImageServiceBase : public CMnServiceBase |
|
53 { |
|
54 public : |
|
55 |
|
56 /** Returns drawing parameters of map image. |
|
57 * @param aImageParams Parameters of map image. */ |
|
58 IMPORT_C const TMnMapImageParams& MapImageParams() const; |
|
59 |
|
60 /** Returns drawing parameters of map image. |
|
61 * @param aImageParams Parameters of map image. */ |
|
62 IMPORT_C TMnMapImageParams& MapImageParams(); |
|
63 |
|
64 /** @internal */ |
|
65 /* Sets drawing parameters of map image. Implementation can read |
|
66 * these by calling MapImageParams(). |
|
67 * @param aImageParams Parameters of map image. */ |
|
68 void SetMapImageParams( const TMnMapImageParams& aImageParams ); |
|
69 |
|
70 /** Returns origin and size of needed image in pixels. |
|
71 * Size part of that rectangle is the same as specified in MapImageParams(). |
|
72 * @return Rectangle within destination bitmap (see @ref TargetBitmap() ), |
|
73 * where the map should be drawn to. */ |
|
74 IMPORT_C TRect TargetRect() const; |
|
75 |
|
76 /** Returns rendering options set by client. Rendering process |
|
77 * must obey these options. If it is not possible, it should complete |
|
78 * rendering with KErrNotSupported. |
|
79 * @returns Options defined in CMnMapImage::TShowOptions. */ |
|
80 IMPORT_C CMnMapImage::TShowOptions ShowOptions() const; |
|
81 |
|
82 /** Returns reference to target bitmap object. This is the bitmap, |
|
83 * which the map image should be rendered to. |
|
84 * It is guaranteed that bitmap's size in pixels is sufficient |
|
85 * for drawing. |
|
86 * This method should be called only during processing of rendering |
|
87 * request, i.e. not before HandleRenderingL() or after |
|
88 * CompleteRendering() */ |
|
89 IMPORT_C CFbsBitmap& TargetBitmap() const; |
|
90 |
|
91 /** Must be called by client when rendering is successfully completed. |
|
92 * (If there were an error, then CMnServiceBase::CompleteRequest() |
|
93 * should be called instead.) |
|
94 * |
|
95 * Before completion, actual type of image drawn should be set in |
|
96 * MapImageParams() in case original value was TMnMapImageParams::ETypeUnspecified. |
|
97 * |
|
98 * @panic "MnPanicServer"-KMnPanicInvalidResult if image type in |
|
99 * @p MapImageParams() is TMnMapImageParams::ETypeUnspecified. |
|
100 * @panic "MnPanicServer"-KMnPanicAttemptToCompleteNoRequest if |
|
101 * there is no ongoing asynchronous request. */ |
|
102 IMPORT_C void CompleteRendering(); |
|
103 |
|
104 protected : |
|
105 /** C++ constructor */ |
|
106 IMPORT_C CMnMapImageServiceBase(); |
|
107 /** Destructor */ |
|
108 IMPORT_C ~CMnMapImageServiceBase(); |
|
109 |
|
110 /** This method must be called from derived class' ConstructL to |
|
111 * allow internal initialization of this class. */ |
|
112 IMPORT_C void BaseConstructL(); |
|
113 |
|
114 /** Handles client's request for rendering map image. |
|
115 * |
|
116 * Derived class must implement this method if KMnSvcFeatureRender |
|
117 * feature is specified in SERVICE_INFO. |
|
118 * |
|
119 * Implementation should draw map image to bitmap object returned by |
|
120 * @ref TargetBitmap(). Drawing must be done to the area of the bitmap, |
|
121 * specified by @ref TargetRect(). |
|
122 * |
|
123 * Map image parameters are specified in object of TMnMapImageParams and |
|
124 * can be accessed via @ref MapImageOptions(). Center of the drawing must correspond |
|
125 * to world point given by @ref TMnMapImageParams::GetCentralPoint(), |
|
126 * scale must be as specified by @ref TMnMapImageParams::Scale(). Image |
|
127 * must be oriented as required by @ref TMnMapImageParams::Direction(). |
|
128 * Image type requested is defined in @ref TMnMapImageParams::ImageType(). |
|
129 * Additional options defined by @ref ShowOptions() must also be obeyed |
|
130 * (if possible). |
|
131 * |
|
132 * If any of those requirements can not be satisfied, rendering must be |
|
133 * completed with KErrNotSupported. If any of arguments are considered |
|
134 * generally invalid, then error code should be KErrArgument. |
|
135 * |
|
136 * This is asynchronous request. |
|
137 * Implementation should complete this request by calling CompleteRendering() |
|
138 * if rendering ended successfully or by calling CMnServiceBase::CompleteRequest() |
|
139 * in case of error. |
|
140 * |
|
141 * This request can be canceled by client, in which case base method |
|
142 * DoCancel() will be called. |
|
143 * |
|
144 * If this function leaves then client's request is automatically |
|
145 * completed with error. |
|
146 * |
|
147 * @leave KErrNotSupported Should leave if this feature is not supported. |
|
148 */ |
|
149 virtual void HandleRenderingL() =0; |
|
150 |
|
151 protected: // From CAknAppServiceBase |
|
152 |
|
153 /** @internal */ |
|
154 IMPORT_C virtual void ServiceL( const RMessage2& aMessage ); |
|
155 |
|
156 private: |
|
157 void StartAsyncRequestL( const RMessage2& aMessage ); |
|
158 |
|
159 void UnpackOptionsL( const RMessage2& aMessage ); |
|
160 void UnpackImageParamsL( const RMessage2& aMessage ); |
|
161 void UnpackBitmapHandleL( const RMessage2& aMessage ); |
|
162 void HandleCancelRequestL( const RMessage2& aMessage ); |
|
163 |
|
164 private: |
|
165 TMnMapImageParams iMapImageParams; |
|
166 CMnMapImage::TShowOptions iShowOptions; |
|
167 TPoint iTargetOrigin; |
|
168 CFbsBitmap* iBitmap; |
|
169 }; |
|
170 |
|
171 |
|
172 #endif /*MN_MAPIMAGESERVICEBASE_H_*/ |
|