|
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: CMnGeocodingServiceBase class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 |
|
21 #include <EPos_CPosLandmark.h> |
|
22 #include <epos_poslandmarkserialization.h> |
|
23 |
|
24 #include "mndebug.h" |
|
25 #include "mnerrors.h" |
|
26 #include "mninternal.h" |
|
27 #include "mninternal.inl" |
|
28 |
|
29 #include "mngeocodingservicebase.h" |
|
30 |
|
31 // ======== MEMBER FUNCTIONS ======== |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 EXPORT_C CMnGeocodingServiceBase::CMnGeocodingServiceBase() |
|
37 { |
|
38 } |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 EXPORT_C CMnGeocodingServiceBase::~CMnGeocodingServiceBase() |
|
44 { |
|
45 delete iResult; |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 EXPORT_C void CMnGeocodingServiceBase::BaseConstructL() |
|
52 { |
|
53 CMnServiceBase::BaseConstructL(); |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 EXPORT_C CMnGeocoder::TOptions CMnGeocodingServiceBase::Options() const |
|
60 { |
|
61 LOG("CMnGeocodingServiceBase::Options"); |
|
62 return iOptions; |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 EXPORT_C void CMnGeocodingServiceBase::CompleteGeocodingRequestL( |
|
69 const CPosLandmark& aLandmark ) |
|
70 { |
|
71 LOG("CMnGeocodingServiceBase::CompleteGeocodingRequestL in"); |
|
72 switch ( CurrentAsyncRequest() ) |
|
73 { |
|
74 case EMnIpcCoordToAddress: |
|
75 iResultType = EMnGeoResultAddress; |
|
76 break; |
|
77 |
|
78 case EMnIpcAddressToCoord: |
|
79 case EMnIpcPlainAddressToCoord: |
|
80 iResultType = EMnGeoResultCoordinates; |
|
81 break; |
|
82 |
|
83 default: |
|
84 PanicServer( KMnPanicAttemptToCompleteNoRequest ); |
|
85 } |
|
86 |
|
87 delete iResult; |
|
88 iResult = NULL; |
|
89 iResult = PosLandmarkSerialization::PackL( aLandmark ); |
|
90 |
|
91 TInt resultSize = iResult->Size(); |
|
92 TPckg<TInt> resultSizePack( resultSize ); |
|
93 TInt err = iMessage.Write( EMnIpcGeoResultSizeParamIndex, resultSizePack ); |
|
94 CompleteRequest( err ); |
|
95 |
|
96 LOG("CMnGeocodingServiceBase::CompleteGeocodingRequestL out"); |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // From class CAknAppServiceBase |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 EXPORT_C void CMnGeocodingServiceBase::ServiceL( const RMessage2& aMessage ) |
|
104 { |
|
105 LOG1("CMnGeocodingServiceBase::ServiceL in, function %d", aMessage.Function()); |
|
106 |
|
107 switch ( aMessage.Function() ) |
|
108 { |
|
109 case EMnIpcCoordToAddress: |
|
110 case EMnIpcAddressToCoord: |
|
111 case EMnIpcPlainAddressToCoord: |
|
112 PrepareAsyncRequestL( aMessage ); |
|
113 StartAsyncRequestL( aMessage ); |
|
114 break; |
|
115 |
|
116 case EMnIpcGetConversionResult: |
|
117 HandleGetConversionResultL( aMessage ); |
|
118 break; |
|
119 |
|
120 case EMnIpcCancel: |
|
121 HandleCancelRequestL( aMessage ); |
|
122 break; |
|
123 |
|
124 default: |
|
125 CMnServiceBase::ServiceL( aMessage ); |
|
126 } |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------------------------- |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 void CMnGeocodingServiceBase::StartAsyncRequestL( const RMessage2& aMessage ) |
|
133 { |
|
134 LOG("CMnGeocodingServiceBase::StartAsyncRequestL in"); |
|
135 |
|
136 HBufC* addr = NULL; |
|
137 CPosLandmark* lm = NULL; |
|
138 |
|
139 UnpackOptionsL( aMessage ); |
|
140 |
|
141 switch ( CurrentAsyncRequest() ) |
|
142 { |
|
143 case EMnIpcCoordToAddress: |
|
144 lm = UnpackLandmarkLC( aMessage, EMnIpcGeoLandmarkParamIndex ); |
|
145 HandleFindAddressByCoordinateL( *lm ); |
|
146 CleanupStack::PopAndDestroy( lm ); |
|
147 break; |
|
148 |
|
149 case EMnIpcAddressToCoord: |
|
150 lm = UnpackLandmarkLC( aMessage, EMnIpcGeoLandmarkParamIndex ); |
|
151 HandleFindCoordinateByAddressL( *lm ); |
|
152 CleanupStack::PopAndDestroy( lm ); |
|
153 break; |
|
154 |
|
155 case EMnIpcPlainAddressToCoord: |
|
156 addr = UnpackPlainAddressLC( aMessage ); |
|
157 HandleFindCoordinateByAddressL( addr->Des() ); |
|
158 CleanupStack::PopAndDestroy( addr ); |
|
159 break; |
|
160 |
|
161 default: |
|
162 User::Leave( KErrNotSupported ); |
|
163 } |
|
164 |
|
165 LOG("CMnGeocodingServiceBase::StartAsyncRequestL out"); |
|
166 } |
|
167 |
|
168 // --------------------------------------------------------------------------- |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 void CMnGeocodingServiceBase::UnpackOptionsL( const RMessage2& aMessage ) |
|
172 { |
|
173 LOG("CMnGeocodingServiceBase::UnpackOptionsL"); |
|
174 |
|
175 TPckg<CMnGeocoder::TOptions> optsPack( iOptions ); |
|
176 aMessage.ReadL( EMnIpcGeoOptionsParamIndex, optsPack ); |
|
177 } |
|
178 |
|
179 // --------------------------------------------------------------------------- |
|
180 // --------------------------------------------------------------------------- |
|
181 // |
|
182 HBufC* CMnGeocodingServiceBase::UnpackPlainAddressLC( const RMessage2& aMessage ) |
|
183 { |
|
184 LOG("CMnGeocodingServiceBase::UnpackPlainAddressLC"); |
|
185 return CopyClientBufferLC( aMessage, EMnIpcGeoPlainAddressParamIndex ); |
|
186 } |
|
187 |
|
188 // --------------------------------------------------------------------------- |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 void CMnGeocodingServiceBase::HandleGetConversionResultL( const RMessage2& aMessage ) |
|
192 { |
|
193 LOG("CMnGeocodingServiceBase::HandleGetConversionResultL in"); |
|
194 |
|
195 if ( !iResult ) |
|
196 { |
|
197 User::Leave( KErrNotFound ); |
|
198 } |
|
199 |
|
200 aMessage.WriteL( EMnIpcGeoResultParamIndex, *iResult ); |
|
201 TPckg<TInt> typePack( iResultType ); |
|
202 aMessage.WriteL( EMnIpcGeoResultTypeParamIndex, typePack ); |
|
203 |
|
204 Complete( aMessage, KErrNone ); |
|
205 |
|
206 LOG("CMnGeocodingServiceBase::HandleGetConversionResultL out"); |
|
207 } |