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: RMnGeocodingServiceClient 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 "mninternal.h" |
|
26 #include "mnappserviceuids.hrh" |
|
27 |
|
28 #include "mnprovider.h" |
|
29 #include "mngeocoder.h" |
|
30 #include "mngeocodingserviceclient.h" |
|
31 |
|
32 // ======== LOCAL FUNCTIONS ======== |
|
33 |
|
34 // ======== MEMBER FUNCTIONS ======== |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 RMnGeocodingServiceClient::RMnGeocodingServiceClient() |
|
40 : iResultSizePtr( iResultSize ) |
|
41 { |
|
42 iResultSize = 0; |
|
43 iLandmarkBuffer = NULL; |
|
44 iPlainAddress = NULL; |
|
45 iLastRequest = EMnIpcNone; |
|
46 } |
|
47 |
|
48 RMnGeocodingServiceClient::~RMnGeocodingServiceClient() |
|
49 { |
|
50 delete iLandmarkBuffer; |
|
51 delete iPlainAddress; |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 void RMnGeocodingServiceClient::AddressByCoordinateL( |
|
58 const CPosLandmark& aCoordinateLanmdark, |
|
59 CMnGeocoder::TOptions aOptions, |
|
60 TRequestStatus& aStatus) |
|
61 { |
|
62 LOG("RMnGeocodingServiceClient::AddressByCoordinateL"); |
|
63 TIpcArgs args; |
|
64 |
|
65 // options |
|
66 iOptions = aOptions; |
|
67 TPckg<CMnGeocoder::TOptions> optsPack( iOptions ); |
|
68 iOptionsPtr.Set( optsPack ); |
|
69 args.Set( EMnIpcGeoOptionsParamIndex, &iOptionsPtr ); |
|
70 |
|
71 // landmark |
|
72 delete iLandmarkBuffer; |
|
73 iLandmarkBuffer = NULL; |
|
74 iLandmarkBuffer = PosLandmarkSerialization::PackL( aCoordinateLanmdark ); |
|
75 args.Set( EMnIpcGeoLandmarkParamIndex, iLandmarkBuffer ); |
|
76 |
|
77 // size of result |
|
78 args.Set( EMnIpcGeoResultSizeParamIndex, &iResultSizePtr ); |
|
79 |
|
80 SendReceive( EMnIpcCoordToAddress, args, aStatus ); |
|
81 iLastRequest = EMnIpcCoordToAddress; |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 void RMnGeocodingServiceClient::CoordinateByAddressL( |
|
88 const CPosLandmark& aAddressLanmdark, |
|
89 CMnGeocoder::TOptions aOptions, |
|
90 TRequestStatus& aStatus ) |
|
91 { |
|
92 LOG("RMnGeocodingServiceClient::CoordinateByAddressL"); |
|
93 TIpcArgs args; |
|
94 |
|
95 // options |
|
96 iOptions = aOptions; |
|
97 TPckg<CMnGeocoder::TOptions> optsPack( iOptions ); |
|
98 iOptionsPtr.Set( optsPack ); |
|
99 args.Set( EMnIpcGeoOptionsParamIndex, &iOptionsPtr ); |
|
100 |
|
101 // landmark |
|
102 delete iLandmarkBuffer; |
|
103 iLandmarkBuffer = NULL; |
|
104 iLandmarkBuffer = PosLandmarkSerialization::PackL( aAddressLanmdark ); |
|
105 args.Set( EMnIpcGeoLandmarkParamIndex, iLandmarkBuffer ); |
|
106 |
|
107 // size of result |
|
108 args.Set( EMnIpcGeoResultSizeParamIndex, &iResultSizePtr ); |
|
109 |
|
110 SendReceive( EMnIpcAddressToCoord, args, aStatus ); |
|
111 iLastRequest = EMnIpcAddressToCoord; |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 void RMnGeocodingServiceClient::CoordinateByAddressL( |
|
118 const TDesC& aAddress, |
|
119 CMnGeocoder::TOptions aOptions, |
|
120 TRequestStatus& aStatus ) |
|
121 { |
|
122 LOG("RMnGeocodingServiceClient::CoordinateByAddressL"); |
|
123 TIpcArgs args; |
|
124 |
|
125 // options |
|
126 iOptions = aOptions; |
|
127 TPckg<CMnGeocoder::TOptions> optsPack( iOptions ); |
|
128 iOptionsPtr.Set( optsPack ); |
|
129 args.Set( EMnIpcGeoOptionsParamIndex, &iOptionsPtr ); |
|
130 |
|
131 // landmark |
|
132 delete iPlainAddress; |
|
133 iPlainAddress = NULL; |
|
134 iPlainAddress = aAddress.AllocL(); |
|
135 args.Set( EMnIpcGeoPlainAddressParamIndex, iPlainAddress ); |
|
136 |
|
137 // size of result |
|
138 args.Set( EMnIpcGeoResultSizeParamIndex, &iResultSizePtr ); |
|
139 |
|
140 SendReceive( EMnIpcPlainAddressToCoord, args, aStatus ); |
|
141 iLastRequest = EMnIpcPlainAddressToCoord; |
|
142 } |
|
143 |
|
144 // --------------------------------------------------------------------------- |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 void RMnGeocodingServiceClient::GetLastResultL( |
|
148 CPosLandmark*& aResult, |
|
149 TMnGeocodingResultType& aResultType ) |
|
150 { |
|
151 LOG("RMnGeocodingServiceClient::GetLastResultL in"); |
|
152 TIpcArgs args; |
|
153 |
|
154 if ( iResultSize <= 0 ) |
|
155 { |
|
156 User::Leave( KErrNotFound ); |
|
157 } |
|
158 |
|
159 // receiving buffer |
|
160 HBufC8* lmBuf = HBufC8::NewLC( iResultSize ); |
|
161 TPtr8 lmBufPtr( lmBuf->Des() ); |
|
162 args.Set( EMnIpcGeoResultParamIndex, &lmBufPtr ); |
|
163 |
|
164 TPckg<TMnGeocodingResultType> resultTypePack( aResultType ); |
|
165 args.Set( EMnIpcGeoResultTypeParamIndex, &resultTypePack); |
|
166 |
|
167 TInt err = SendReceive( EMnIpcGetConversionResult, args ); |
|
168 User::LeaveIfError( err ); |
|
169 |
|
170 CPosLandmark* lm = PosLandmarkSerialization::UnpackL( *lmBuf ); |
|
171 aResult = lm; |
|
172 CleanupStack::PopAndDestroy( lmBuf ); |
|
173 LOG("RMnGeocodingServiceClient::GetLastResultL out"); |
|
174 } |
|
175 |
|
176 // --------------------------------------------------------------------------- |
|
177 // From class RApaAppServiceBase. |
|
178 // --------------------------------------------------------------------------- |
|
179 // |
|
180 EXPORT_C TUid RMnGeocodingServiceClient::ServiceUid() const |
|
181 { |
|
182 LOG("RMnGeocodingServiceClient::ServiceUid"); |
|
183 return TUid::Uid( KMnAppGeocodingService ); |
|
184 } |
|