45
|
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: RMnMapViewServiceClient class implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <e32base.h>
|
|
20 |
#include <s32mem.h>
|
|
21 |
|
|
22 |
#include <lbsposition.h>
|
|
23 |
|
|
24 |
#include <EPos_CPosLandmark.h>
|
|
25 |
#include <epos_poslandmarkserialization.h>
|
|
26 |
|
|
27 |
#include "mnerrors.h"
|
|
28 |
#include "mndebug.h"
|
|
29 |
#include "mninternal.h"
|
|
30 |
#include "mninternal.inl"
|
|
31 |
#include "mnmapselectionresultinfo.inl"
|
|
32 |
|
|
33 |
#include "mnappserviceuids.hrh"
|
|
34 |
#include "mnmapviewserviceclient.h"
|
|
35 |
|
|
36 |
// ======== MEMBER FUNCTIONS ========
|
|
37 |
|
|
38 |
// ---------------------------------------------------------------------------
|
|
39 |
// ---------------------------------------------------------------------------
|
|
40 |
//
|
|
41 |
RMnMapViewServiceClient::RMnMapViewServiceClient()
|
|
42 |
: iSelectionRequestText( NULL ),
|
|
43 |
iSelectionRequestTextOwned( EFalse ),
|
|
44 |
iResultInfoPtr( iResultInfo )
|
|
45 |
{
|
|
46 |
Mem::FillZ( &iResultInfo, sizeof( TMnMapSelectionResultInfo ) );
|
|
47 |
}
|
|
48 |
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
// ---------------------------------------------------------------------------
|
|
51 |
//
|
|
52 |
RMnMapViewServiceClient::~RMnMapViewServiceClient()
|
|
53 |
{
|
|
54 |
ClearSelectionRequestText();
|
|
55 |
}
|
|
56 |
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
// ---------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
void RMnMapViewServiceClient::AddLandmarksToShowL(
|
|
61 |
const TDesC& aDatabaseUri,
|
|
62 |
RArray<TPosLmItemId>& aLandmarkIds)
|
|
63 |
{
|
|
64 |
TIpcArgs args;
|
|
65 |
|
|
66 |
// db uri
|
|
67 |
args.Set( EMnIpcMapDbUriParamIndex, &aDatabaseUri );
|
|
68 |
|
|
69 |
// landmark ids
|
|
70 |
TInt lmCount = aLandmarkIds.Count();
|
|
71 |
TPosLmItemId* ids = new (ELeave) TPosLmItemId[ lmCount ];
|
|
72 |
|
|
73 |
for ( TUint32 i = 0; i < lmCount; i++ )
|
|
74 |
{
|
|
75 |
*(ids + i) = aLandmarkIds[i];
|
|
76 |
}
|
|
77 |
|
|
78 |
TPtrC8 idsDes( reinterpret_cast<const TUint8*>( ids ), sizeof( TPosLmItemId ) * lmCount );
|
|
79 |
args.Set( EMnIpcMapLmIdsParamIndex, &idsDes );
|
|
80 |
|
|
81 |
TInt err = SendReceive( EMnIpcAddLmIdsToShow, args );
|
|
82 |
delete[] ids;
|
|
83 |
User::LeaveIfError( err );
|
|
84 |
}
|
|
85 |
|
|
86 |
// ---------------------------------------------------------------------------
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
//
|
|
89 |
void RMnMapViewServiceClient::AddLandmarksToShowL( RPointerArray<CPosLandmark>& aLandmarks )
|
|
90 |
{
|
|
91 |
LOG("RMnMapViewServiceClient::AddLandmarksToShowL in");
|
|
92 |
|
|
93 |
TIpcArgs args;
|
|
94 |
|
|
95 |
const TInt KGranularity = 1024; // expand in chunks of 1K
|
|
96 |
CBufFlat* lmBuffer = CBufFlat::NewL( KGranularity );
|
|
97 |
CleanupStack::PushL( lmBuffer );
|
|
98 |
|
|
99 |
RBufWriteStream writeStream;
|
|
100 |
writeStream.Open( *lmBuffer );
|
|
101 |
CleanupClosePushL( writeStream );
|
|
102 |
|
|
103 |
writeStream.WriteInt32L( aLandmarks.Count() );
|
|
104 |
|
|
105 |
LOG1("RMnMapViewServiceClient::AddLandmarksToShowL count %d", aLandmarks.Count());
|
|
106 |
|
|
107 |
for ( TInt i = 0; i < aLandmarks.Count(); i++ )
|
|
108 |
{
|
|
109 |
HBufC8* lmBuf = PosLandmarkSerialization::PackL( *aLandmarks[i] );
|
|
110 |
CleanupStack::PushL( lmBuf );
|
|
111 |
|
|
112 |
writeStream.WriteInt32L( lmBuf->Size() );
|
|
113 |
writeStream.WriteL( *lmBuf );
|
|
114 |
|
|
115 |
CleanupStack::PopAndDestroy( lmBuf );
|
|
116 |
}
|
|
117 |
writeStream.CommitL();
|
|
118 |
CleanupStack::PopAndDestroy( &writeStream );
|
|
119 |
|
|
120 |
LOG1("RMnMapViewServiceClient::AddLandmarksToShowL totalsize %d", lmBuffer->Size());
|
|
121 |
|
|
122 |
//lmBuffer->Compress();
|
|
123 |
TPtr8 lmBufferPtr( lmBuffer->Ptr( 0 ) );
|
|
124 |
User::LeaveIfError(
|
|
125 |
SendReceive( EMnIpcAddLandmarksToShow, TIpcArgs( &lmBufferPtr ) ) );
|
|
126 |
|
|
127 |
CleanupStack::PopAndDestroy( lmBuffer );
|
|
128 |
LOG("RMnMapViewServiceClient::AddLandmarksToShowL out");
|
|
129 |
}
|
|
130 |
|
|
131 |
// ---------------------------------------------------------------------------
|
|
132 |
// ---------------------------------------------------------------------------
|
|
133 |
//
|
|
134 |
void RMnMapViewServiceClient::AddLandmarksToShowL( RArray<TPtrC8>& aPackedLandmarks )
|
|
135 |
{
|
|
136 |
LOG("RMnMapViewServiceClient::AddLandmarksToShowL (packed) in");
|
|
137 |
TIpcArgs args;
|
|
138 |
|
|
139 |
const TInt KGranularity = 1024; // expand in chunks of 1K
|
|
140 |
CBufFlat* lmBuffer = CBufFlat::NewL( KGranularity );
|
|
141 |
CleanupStack::PushL( lmBuffer );
|
|
142 |
|
|
143 |
RBufWriteStream writeStream;
|
|
144 |
writeStream.Open( *lmBuffer );
|
|
145 |
CleanupClosePushL( writeStream );
|
|
146 |
|
|
147 |
writeStream.WriteInt32L( aPackedLandmarks.Count() );
|
|
148 |
|
|
149 |
LOG1("RMnMapViewServiceClient::AddLandmarksToShowL (packed) count %d", aPackedLandmarks.Count());
|
|
150 |
|
|
151 |
for ( TInt i = 0; i < aPackedLandmarks.Count(); i++ )
|
|
152 |
{
|
|
153 |
TPtrC8 data( aPackedLandmarks[i] );
|
|
154 |
|
|
155 |
writeStream.WriteInt32L( data.Size() );
|
|
156 |
writeStream.WriteL( data );
|
|
157 |
}
|
|
158 |
|
|
159 |
writeStream.CommitL();
|
|
160 |
CleanupStack::PopAndDestroy( &writeStream );
|
|
161 |
|
|
162 |
LOG1("RMnMapViewServiceClient::AddLandmarksToShowL (packed) totalsize %d", lmBuffer->Size());
|
|
163 |
|
|
164 |
lmBuffer->Compress();
|
|
165 |
TPtr8 lmBufferPtr( lmBuffer->Ptr( 0 ) );
|
|
166 |
User::LeaveIfError(
|
|
167 |
SendReceive( EMnIpcAddLandmarksToShow, TIpcArgs( &lmBufferPtr ) ) );
|
|
168 |
|
|
169 |
CleanupStack::PopAndDestroy( lmBuffer );
|
|
170 |
LOG("RMnMapViewServiceClient::AddLandmarksToShowL (packed) out");
|
|
171 |
}
|
|
172 |
|
|
173 |
// ---------------------------------------------------------------------------
|
|
174 |
// ---------------------------------------------------------------------------
|
|
175 |
//
|
|
176 |
void RMnMapViewServiceClient::ResetLandmarksToShow()
|
|
177 |
{
|
|
178 |
Send( EMnIpcResetLandmarksToShow );
|
|
179 |
}
|
|
180 |
|
|
181 |
// ---------------------------------------------------------------------------
|
|
182 |
// ---------------------------------------------------------------------------
|
|
183 |
//
|
|
184 |
void RMnMapViewServiceClient::SetSelectionRequestTextL(
|
|
185 |
const TDesC& aSelectionRequestText)
|
|
186 |
{
|
|
187 |
ClearSelectionRequestText();
|
|
188 |
iSelectionRequestText = aSelectionRequestText.AllocL();
|
|
189 |
iSelectionRequestTextOwned = ETrue;
|
|
190 |
}
|
|
191 |
|
|
192 |
// ---------------------------------------------------------------------------
|
|
193 |
// ---------------------------------------------------------------------------
|
|
194 |
//
|
|
195 |
void RMnMapViewServiceClient::SetSelectionRequestText( HBufC*& aSelectionRequestText )
|
|
196 |
{
|
|
197 |
ClearSelectionRequestText();
|
|
198 |
iSelectionRequestText = aSelectionRequestText;
|
|
199 |
iSelectionRequestTextOwned = EFalse;
|
|
200 |
}
|
|
201 |
|
|
202 |
// ---------------------------------------------------------------------------
|
|
203 |
// ---------------------------------------------------------------------------
|
|
204 |
//
|
|
205 |
void RMnMapViewServiceClient::InitSelectionRequestTextL( HBufC*& aSelectionRequestText )
|
|
206 |
{
|
|
207 |
SetSelectionRequestText( aSelectionRequestText );
|
|
208 |
|
|
209 |
TIpcArgs args;
|
|
210 |
args.Set( EMnIpcMapSelectionTextParamIndex, iSelectionRequestText );
|
|
211 |
|
|
212 |
TInt err = SendReceive( EMnIpcInitRequestText, args );
|
|
213 |
LOG1("RMnMapViewServiceClient::InitSelectionRequestTextL, sendreceive = %d", err);
|
|
214 |
User::LeaveIfError( err );
|
|
215 |
}
|
|
216 |
|
|
217 |
// ---------------------------------------------------------------------------
|
|
218 |
// ---------------------------------------------------------------------------
|
|
219 |
//
|
|
220 |
void RMnMapViewServiceClient::ClearSelectionRequestText()
|
|
221 |
{
|
|
222 |
if ( iSelectionRequestTextOwned )
|
|
223 |
{
|
|
224 |
delete iSelectionRequestText;
|
|
225 |
}
|
|
226 |
iSelectionRequestText = NULL;
|
|
227 |
iSelectionRequestTextOwned = ETrue;
|
|
228 |
}
|
|
229 |
|
|
230 |
// ---------------------------------------------------------------------------
|
|
231 |
// ---------------------------------------------------------------------------
|
|
232 |
//
|
|
233 |
void RMnMapViewServiceClient::ShowMapL( TMnMapOptions aOptions )
|
|
234 |
{
|
|
235 |
TIpcArgs args;
|
|
236 |
|
|
237 |
TPckgC<TMnMapOptions> optsPack( aOptions );
|
|
238 |
args.Set( EMnIpcMapOptionsParamIndex, &optsPack );
|
|
239 |
|
|
240 |
User::LeaveIfError( SendReceive( EMnIpcShowMap, args ) );
|
|
241 |
}
|
|
242 |
|
|
243 |
// ---------------------------------------------------------------------------
|
|
244 |
// ---------------------------------------------------------------------------
|
|
245 |
//
|
|
246 |
void RMnMapViewServiceClient::ShowCurrentLocationL( TMnMapOptions aOptions )
|
|
247 |
{
|
|
248 |
TIpcArgs args;
|
|
249 |
|
|
250 |
TPckgC<TMnMapOptions> optsPack( aOptions );
|
|
251 |
args.Set( EMnIpcMapOptionsParamIndex, &optsPack );
|
|
252 |
|
|
253 |
User::LeaveIfError( SendReceive( EMnIpcShowCurrentLocation, args ) );
|
|
254 |
}
|
|
255 |
|
|
256 |
// ---------------------------------------------------------------------------
|
|
257 |
// ---------------------------------------------------------------------------
|
|
258 |
//
|
|
259 |
void RMnMapViewServiceClient::SelectFromMap(
|
|
260 |
TMnMapOptions aOptions,
|
|
261 |
TRequestStatus& aStatus )
|
|
262 |
{
|
|
263 |
__ASSERT_DEBUG( iSelectionRequestText, PanicSelf( KErrGeneral ) );
|
|
264 |
|
|
265 |
TIpcArgs args;
|
|
266 |
|
|
267 |
// options
|
|
268 |
iOptions = aOptions;
|
|
269 |
TPckgC<TMnMapOptions> optsPack( iOptions );
|
|
270 |
iOptionsPtr.Set( optsPack );
|
|
271 |
args.Set( EMnIpcMapOptionsParamIndex, &iOptionsPtr );
|
|
272 |
|
|
273 |
// selection text
|
|
274 |
args.Set( EMnIpcMapSelectionTextParamIndex, iSelectionRequestText );
|
|
275 |
|
|
276 |
// selection result info
|
|
277 |
args.Set( EMnIpcMapSelectionResultInfoParamIndex, &iResultInfoPtr );
|
|
278 |
|
|
279 |
SendReceive( EMnIpcSelectFromMap, args, aStatus );
|
|
280 |
iLastRequest = EMnIpcSelectFromMap;
|
|
281 |
}
|
|
282 |
|
|
283 |
// ---------------------------------------------------------------------------
|
|
284 |
// ---------------------------------------------------------------------------
|
|
285 |
//
|
|
286 |
CMnMapView::TSelectionResultType RMnMapViewServiceClient::SelectionResultType()
|
|
287 |
{
|
|
288 |
return iResultInfo.iType;
|
|
289 |
}
|
|
290 |
|
|
291 |
// ---------------------------------------------------------------------------
|
|
292 |
// ---------------------------------------------------------------------------
|
|
293 |
//
|
|
294 |
CPosLandmark* RMnMapViewServiceClient::GetSelectedLandmarkL()
|
|
295 |
{
|
|
296 |
if ( iResultInfo.iType != CMnMapView::ESelectionFreeLandmark )
|
|
297 |
{
|
|
298 |
User::Leave( KErrNotFound );
|
|
299 |
}
|
|
300 |
|
|
301 |
TIpcArgs args;
|
|
302 |
|
|
303 |
// landmark receiving buffer
|
|
304 |
HBufC8* lmBuf = HBufC8::NewLC( iResultInfo.iLandmarkSize );
|
|
305 |
TPtr8 lmBufPtr( lmBuf->Des() );
|
|
306 |
|
|
307 |
args.Set( EMnIpcMapSelResultBufferParamIndex, &lmBufPtr );
|
|
308 |
User::LeaveIfError( SendReceive( EMnIpcGetSelectionResultLandmark, args ) );
|
|
309 |
|
|
310 |
CPosLandmark* l = PosLandmarkSerialization::UnpackL( *lmBuf );
|
|
311 |
CleanupStack::PopAndDestroy( lmBuf );
|
|
312 |
return l;
|
|
313 |
}
|
|
314 |
|
|
315 |
// ---------------------------------------------------------------------------
|
|
316 |
// ---------------------------------------------------------------------------
|
|
317 |
//
|
|
318 |
void RMnMapViewServiceClient::GetSelectedLandmarkL( TInt& aLandmarkIndex )
|
|
319 |
{
|
|
320 |
if ( iResultInfo.iType == CMnMapView::ESelectionLandmarkIndex )
|
|
321 |
{
|
|
322 |
aLandmarkIndex = iResultInfo.iLandmarkIndex;
|
|
323 |
}
|
|
324 |
else
|
|
325 |
{
|
|
326 |
User::Leave( KErrNotFound );
|
|
327 |
}
|
|
328 |
}
|
|
329 |
|
|
330 |
// ---------------------------------------------------------------------------
|
|
331 |
// ---------------------------------------------------------------------------
|
|
332 |
//
|
|
333 |
void RMnMapViewServiceClient::GetSelectedLandmarkL( TPosLmItemId& aLandmarkId, HBufC*& aDbUri )
|
|
334 |
{
|
|
335 |
if ( iResultInfo.iType != CMnMapView::ESelectionLinkedLandmark )
|
|
336 |
{
|
|
337 |
User::Leave( KErrNotFound );
|
|
338 |
}
|
|
339 |
|
|
340 |
aLandmarkId = iResultInfo.iLandmarkId;
|
|
341 |
|
|
342 |
TIpcArgs args;
|
|
343 |
|
|
344 |
// database URI receiving buffer
|
|
345 |
HBufC* uriBuf = HBufC::NewLC( iResultInfo.iDbUriSize );
|
|
346 |
TPtr uriBufPtr( uriBuf->Des() );
|
|
347 |
args.Set( EMnIpcMapSelResultBufferParamIndex, &uriBufPtr );
|
|
348 |
|
|
349 |
User::LeaveIfError( SendReceive( EMnIpcGetSelectionResultDbUri, args ) );
|
|
350 |
|
|
351 |
CleanupStack::Pop( uriBuf );
|
|
352 |
aDbUri = uriBuf;
|
|
353 |
}
|
|
354 |
|
|
355 |
// ---------------------------------------------------------------------------
|
|
356 |
// From class RApaAppServiceBase.
|
|
357 |
// ---------------------------------------------------------------------------
|
|
358 |
//
|
|
359 |
TUid RMnMapViewServiceClient::ServiceUid() const
|
|
360 |
{
|
|
361 |
return TUid::Uid(KMnAppMapViewService);
|
|
362 |
}
|