37
|
1 |
/*
|
|
2 |
* Copyright (c) 2006-2010 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: Applications interface class to map and navigation use cases
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <AiwGenericParam.h>
|
|
21 |
#include <epos_poslandmarkserialization.h>
|
|
22 |
#include <lbsposition.h>
|
|
23 |
#include <eikenv.h>
|
|
24 |
#include <StringLoader.h>
|
|
25 |
#include <lmkui.rsg>
|
|
26 |
#include <EPos_CPosLandmarkDatabase.h>
|
|
27 |
#include <EPos_CPosLmOperation.h>
|
|
28 |
#include <EPos_CPosLandmark.h>
|
|
29 |
#include <EPos_Landmarks.h>
|
|
30 |
#include <e32math.h>
|
|
31 |
#include <AiwServiceHandler.h>
|
|
32 |
#include <AknQueryDialog.h>
|
|
33 |
#include <mnaiwservices.h>
|
|
34 |
#include <AknWaitDialog.h>
|
|
35 |
#include "clmkdbsearchutils.h"
|
|
36 |
#include "CLmkSender.h"
|
|
37 |
#include "CLmkEditorImpl.h"
|
|
38 |
#include "LmkNotes.h"
|
|
39 |
#include "clmkmapnavigationinterface.h"
|
|
40 |
|
|
41 |
// ================= LOCAL FUNCTIONS =======================
|
|
42 |
static void CleanupArray(TAny* aArray)
|
|
43 |
{
|
|
44 |
( reinterpret_cast<RPointerArray<CPosLandmark>*>( aArray ) )->ResetAndDestroy();
|
|
45 |
}
|
|
46 |
|
|
47 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
48 |
|
|
49 |
// -----------------------------------------------------------------------------
|
|
50 |
// CLmkMapNavigationInterface::CLmkMapNavigationInterface
|
|
51 |
// C++ default constructor can NOT contain any code, that
|
|
52 |
// might leave.
|
|
53 |
// -----------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
CLmkMapNavigationInterface::CLmkMapNavigationInterface( CPosLandmarkDatabase& aDb )
|
|
56 |
: iDb(aDb)
|
|
57 |
{
|
|
58 |
}
|
|
59 |
|
|
60 |
// -----------------------------------------------------------------------------
|
|
61 |
// CLmkMapNavigationInterface::ConstructL
|
|
62 |
// Symbian 2nd phase constructor can leave.
|
|
63 |
// -----------------------------------------------------------------------------
|
|
64 |
//
|
|
65 |
void CLmkMapNavigationInterface::ConstructL()
|
|
66 |
{
|
|
67 |
iAiwServiceHandler = CAiwServiceHandler::NewL();
|
|
68 |
iInList = CAiwGenericParamList::NewL();
|
|
69 |
iOutList = CAiwGenericParamList::NewL();
|
|
70 |
iSearchUtil = NULL;
|
|
71 |
iCategoryName = NULL;
|
|
72 |
iCategoryId = KPosLmNullItemId;
|
|
73 |
iEnv = CEikonEnv::Static();
|
|
74 |
}
|
|
75 |
|
|
76 |
// -----------------------------------------------------------------------------
|
|
77 |
// CLmkMapNavigationInterface::NewL
|
|
78 |
// Symbian 1st phase constructor can leave.
|
|
79 |
// -----------------------------------------------------------------------------
|
|
80 |
//
|
|
81 |
EXPORT_C CLmkMapNavigationInterface* CLmkMapNavigationInterface::NewL( CPosLandmarkDatabase& aDb)
|
|
82 |
{
|
|
83 |
CLmkMapNavigationInterface* self = static_cast<CLmkMapNavigationInterface*>(Dll::Tls());
|
|
84 |
if(!self)
|
|
85 |
{
|
|
86 |
self = new (ELeave) CLmkMapNavigationInterface( aDb );
|
|
87 |
CleanupStack::PushL( self );
|
|
88 |
self->ConstructL();
|
|
89 |
CleanupStack::Pop();//self
|
|
90 |
Dll::SetTls(self);
|
|
91 |
}
|
|
92 |
self->iRefCnt++;
|
|
93 |
return self;
|
|
94 |
}
|
|
95 |
|
|
96 |
// -----------------------------------------------------------------------------
|
|
97 |
// CLmkMapNavigationInterface::~CLmkMapNavigationInterface
|
|
98 |
// C++ Destructor
|
|
99 |
// -----------------------------------------------------------------------------
|
|
100 |
//
|
|
101 |
EXPORT_C CLmkMapNavigationInterface::~CLmkMapNavigationInterface()
|
|
102 |
{
|
|
103 |
Dll::SetTls( NULL );
|
|
104 |
delete iAiwServiceHandler;
|
|
105 |
delete iInList;
|
|
106 |
delete iOutList;
|
|
107 |
delete iCategoryName;
|
|
108 |
delete iSearchUtil;
|
|
109 |
iLandmarkArray.ResetAndDestroy();
|
|
110 |
}
|
|
111 |
|
|
112 |
// -----------------------------------------------------------------------------
|
|
113 |
// CLmkMapNavigationInterface::HandleNotifyL
|
|
114 |
// -----------------------------------------------------------------------------
|
|
115 |
//
|
|
116 |
EXPORT_C TInt CLmkMapNavigationInterface::HandleNotifyL( TInt /*aCmdId*/,
|
|
117 |
TInt /*aEventId*/,
|
|
118 |
CAiwGenericParamList& /*aEventParamList*/,
|
|
119 |
const CAiwGenericParamList& /*aInParamList*/ )
|
|
120 |
{
|
|
121 |
if ( iOutList->Count() )
|
|
122 |
{
|
|
123 |
const TAiwGenericParam& param = ( *iOutList )[0];
|
|
124 |
if ( EGenericParamLandmark == param.SemanticId() )
|
|
125 |
{
|
|
126 |
TPtrC8 landmarkData( param.Value().AsData() );
|
|
127 |
CPosLandmark* lm = PosLandmarkSerialization::UnpackL( landmarkData );
|
|
128 |
CleanupStack::PushL( lm );
|
|
129 |
SaveLandmarkL( *lm );
|
|
130 |
CleanupStack::PopAndDestroy( lm );
|
|
131 |
}
|
|
132 |
iOutList->Reset();
|
|
133 |
}
|
|
134 |
return KErrNone;
|
|
135 |
}
|
|
136 |
|
|
137 |
// -----------------------------------------------------------------------------
|
|
138 |
// CLmkMapNavigationInterface::DialogDismissedL
|
|
139 |
// -----------------------------------------------------------------------------
|
|
140 |
//
|
|
141 |
void CLmkMapNavigationInterface::DialogDismissedL( TInt /*aButtonId*/ )
|
|
142 |
{
|
|
143 |
CleanupStack::PushL( TCleanupItem( CleanupArray, &iLandmarkArray ) );
|
|
144 |
ShowLandmarksOnMapL( iLandmarkArray, iCategoryCommand, iViewType );
|
|
145 |
iLandmarkArray.ResetAndDestroy();
|
|
146 |
CleanupStack::PopAndDestroy(); //iLandmarkArray
|
|
147 |
}
|
|
148 |
|
|
149 |
// -----------------------------------------------------------------------------
|
|
150 |
// CLmkMapNavigationInterface::SaveLandmarkL
|
|
151 |
// -----------------------------------------------------------------------------
|
|
152 |
//
|
|
153 |
void CLmkMapNavigationInterface::SaveLandmarkL(CPosLandmark& aLandmark)
|
|
154 |
{
|
|
155 |
CPosLandmarkDatabase* db = CPosLandmarkDatabase::OpenL();
|
|
156 |
CleanupStack::PushL( db );
|
|
157 |
CLmkSender* sender = CLmkSender::NewL( *db );
|
|
158 |
CleanupStack::PushL( sender );
|
|
159 |
CPosLmOperation* operation = db->InitializeL();
|
|
160 |
CleanupStack::PushL( operation );
|
|
161 |
operation->ExecuteL();
|
|
162 |
|
|
163 |
if( iCategoryId != KPosLmNullItemId )
|
|
164 |
{
|
|
165 |
aLandmark.AddCategoryL( iCategoryId );
|
|
166 |
}
|
|
167 |
|
|
168 |
CLmkEditorImpl *dlg = CLmkEditorImpl::NewL( *db,
|
|
169 |
*sender,
|
|
170 |
CLmkEditorDlg::ELmkAll,
|
|
171 |
CLmkEditorDlg::ELmkEditor,
|
|
172 |
&aLandmark );
|
|
173 |
if( dlg->ExecuteLD() )
|
|
174 |
{
|
|
175 |
if ( iObserver )
|
|
176 |
{
|
|
177 |
iObserver->HandleLmCreated(aLandmark.LandmarkId());
|
|
178 |
}
|
|
179 |
}
|
|
180 |
CleanupStack::PopAndDestroy(3); //sender, operation and db
|
|
181 |
iCategoryId = KPosLmNullItemId;
|
|
182 |
}
|
|
183 |
|
|
184 |
// -----------------------------------------------------------------------------
|
|
185 |
// CLmkMapNavigationInterface::ShowLandmarksOnMapL
|
|
186 |
// -----------------------------------------------------------------------------
|
|
187 |
//
|
|
188 |
EXPORT_C void CLmkMapNavigationInterface::ShowLandmarksOnMapL(RPointerArray<CPosLandmark> &aArray,
|
|
189 |
TInt aCommand,
|
|
190 |
EViewType aViewType)
|
|
191 |
{
|
|
192 |
CPosLandmark* lm;
|
|
193 |
HBufC8* lmBuf;
|
|
194 |
iViewType = aViewType;
|
|
195 |
// Error checking
|
|
196 |
if(!CheckAndDisplayIfLandmarksEmptyL(aArray))
|
|
197 |
{
|
|
198 |
return;
|
|
199 |
}
|
|
200 |
|
|
201 |
iInList->Reset();
|
|
202 |
// Pack the landmark into generic parameter
|
|
203 |
for(TInt index = 0; index < aArray.Count(); ++index)
|
|
204 |
{
|
|
205 |
lm = aArray[index];
|
|
206 |
lmBuf =PosLandmarkSerialization::PackL( *lm );
|
|
207 |
CleanupStack::PushL( lmBuf );
|
|
208 |
TAiwGenericParam param( EGenericParamLandmark, TAiwVariant( *lmBuf ) );
|
|
209 |
iInList->AppendL( param );
|
|
210 |
TMnAiwCommonOptionsParam options;
|
|
211 |
options.iRunChained = EFalse;
|
|
212 |
TPckg<TMnAiwCommonOptionsParam> optionsPack( options );
|
|
213 |
TAiwGenericParam optParam( EGenericParamMnCommonOptions, TAiwVariant( optionsPack ) );
|
|
214 |
iInList->AppendL( optParam );
|
|
215 |
CleanupStack::PopAndDestroy( lmBuf );
|
|
216 |
}
|
|
217 |
// Send service command for "Show Landmark on Map"
|
|
218 |
iAiwServiceHandler->ExecuteMenuCmdL( aCommand, *iInList, *iOutList, 0, NULL );
|
|
219 |
}
|
|
220 |
|
|
221 |
// -----------------------------------------------------------------------------
|
|
222 |
// CLmkMapNavigationInterface::ShowCategoryOnMapL
|
|
223 |
// -----------------------------------------------------------------------------
|
|
224 |
//
|
|
225 |
EXPORT_C void CLmkMapNavigationInterface::ShowCategoryOnMapL( TPosLmItemId aCategoryId,
|
|
226 |
TInt aCommand,
|
|
227 |
EViewType aViewType )
|
|
228 |
{
|
|
229 |
iViewType = aViewType;
|
|
230 |
iCategoryCommand = aCommand;
|
|
231 |
// This will get deleted in the callback
|
|
232 |
if(iSearchUtil == NULL)
|
|
233 |
{
|
|
234 |
iSearchUtil = CLmkDbSearchUtils::NewL();
|
|
235 |
}
|
|
236 |
if(iCategoryName != NULL)
|
|
237 |
{
|
|
238 |
delete iCategoryName;
|
|
239 |
iCategoryName = NULL;
|
|
240 |
}
|
|
241 |
iSearchUtil->GetLandmarksUnderCategoryL( this, aCategoryId );
|
|
242 |
if( aCategoryId == KPosLmNullItemId )
|
|
243 |
{
|
|
244 |
iCategoryName = StringLoader::LoadL( R_LMK_LM_LIST_UNCATEGORISED, iEnv );
|
|
245 |
}
|
|
246 |
else
|
|
247 |
{
|
|
248 |
iCategoryName = iSearchUtil->GetCategoryNameL( aCategoryId );
|
|
249 |
}
|
|
250 |
iWaitNote = new (ELeave) CAknWaitDialog( NULL, ETrue );
|
|
251 |
iWaitNote->SetCallback( this );
|
|
252 |
iWaitNote->ExecuteLD( R_LMKUI_PROCESSING_WAIT_NOTE );
|
|
253 |
iWaitNote = NULL;
|
|
254 |
}
|
|
255 |
|
|
256 |
// -----------------------------------------------------------------------------
|
|
257 |
// CLmkMapNavigationInterface::NavigateToLandmarkL
|
|
258 |
// -----------------------------------------------------------------------------
|
|
259 |
//
|
|
260 |
EXPORT_C void CLmkMapNavigationInterface::NavigateToLandmarkL( CPosLandmark* aLandmark, TInt aCommand )
|
|
261 |
{
|
|
262 |
HBufC8* lmBuf = PosLandmarkSerialization::PackL( *aLandmark );
|
|
263 |
CleanupStack::PushL( lmBuf );
|
|
264 |
TAiwGenericParam param( EGenericParamLandmark, TAiwVariant( *lmBuf ) );
|
|
265 |
iInList->Reset();
|
|
266 |
iInList->AppendL( param );
|
|
267 |
TMnAiwCommonOptionsParam options;
|
|
268 |
options.iRunChained = EFalse;
|
|
269 |
TPckg<TMnAiwCommonOptionsParam> optionsPack( options );
|
|
270 |
TAiwGenericParam optParam( EGenericParamMnCommonOptions, TAiwVariant( optionsPack ) );
|
|
271 |
iInList->AppendL( optParam );
|
|
272 |
CleanupStack::PopAndDestroy( lmBuf );
|
|
273 |
iAiwServiceHandler->ExecuteMenuCmdL( aCommand, *iInList, *iOutList, 0, NULL );
|
|
274 |
}
|
|
275 |
|
|
276 |
// -----------------------------------------------------------------------------
|
|
277 |
// CLmkMapNavigationInterface::GetLandmarkFromMapL
|
|
278 |
// -----------------------------------------------------------------------------
|
|
279 |
//
|
|
280 |
EXPORT_C void CLmkMapNavigationInterface::GetLandmarkFromMapL( TInt aCommand )
|
|
281 |
{
|
|
282 |
// This string will be sent to the provider to display it in the map view
|
|
283 |
HBufC* buf = StringLoader::LoadLC( R_LM_SELECT_FROM_MAP, iEnv );
|
|
284 |
TAiwGenericParam param( EGenericParamRequestText, TAiwVariant( *buf ) );
|
|
285 |
iInList->Reset();
|
|
286 |
iInList->AppendL( param );
|
|
287 |
iOutList->Reset();
|
|
288 |
iAiwServiceHandler->ExecuteMenuCmdL( aCommand, *iInList, *iOutList, 0, this );
|
|
289 |
CleanupStack::PopAndDestroy(); // buf
|
|
290 |
}
|
|
291 |
|
|
292 |
// -----------------------------------------------------------------------------
|
|
293 |
// CLmkMapNavigationInterface::GetLandmarkFromMapForCategoryL
|
|
294 |
// -----------------------------------------------------------------------------
|
|
295 |
//
|
|
296 |
EXPORT_C void CLmkMapNavigationInterface::GetLandmarkFromMapForCategoryL( TInt aCommand, TPosLmItemId aCategoryId )
|
|
297 |
{
|
|
298 |
iCategoryId = aCategoryId;
|
|
299 |
GetLandmarkFromMapL( aCommand );
|
|
300 |
}
|
|
301 |
|
|
302 |
// -----------------------------------------------------------------------------
|
|
303 |
// CLmkMapNavigationInterface::GetServiceCmdByMenuCmd
|
|
304 |
// -----------------------------------------------------------------------------
|
|
305 |
//
|
|
306 |
EXPORT_C TInt CLmkMapNavigationInterface::GetServiceCmdByMenuCmd( TInt aCommand )
|
|
307 |
{
|
|
308 |
return iAiwServiceHandler->ServiceCmdByMenuCmd( aCommand );
|
|
309 |
}
|
|
310 |
|
|
311 |
// -----------------------------------------------------------------------------
|
|
312 |
// CLmkMapNavigationInterface::AttachAIWInterestL
|
|
313 |
// -----------------------------------------------------------------------------
|
|
314 |
//
|
|
315 |
EXPORT_C void CLmkMapNavigationInterface::AttachAIWInterestL(TInt aMenuPane, TInt aInterest)
|
|
316 |
{
|
|
317 |
iAiwServiceHandler->AttachMenuL(aMenuPane, aInterest);
|
|
318 |
}
|
|
319 |
|
|
320 |
// -----------------------------------------------------------------------------
|
|
321 |
// CLmkMapNavigationInterface::AttachAIWInterestL
|
|
322 |
// -----------------------------------------------------------------------------
|
|
323 |
//
|
|
324 |
EXPORT_C TBool CLmkMapNavigationInterface::HandleMenuOperationL( TInt aResourceId,
|
|
325 |
CEikMenuPane *aMenuPane,
|
|
326 |
TInt aBaseCommand )
|
|
327 |
{
|
|
328 |
if(iAiwServiceHandler->HandleSubmenuL( *aMenuPane ))
|
|
329 |
{
|
|
330 |
return ETrue;
|
|
331 |
}
|
|
332 |
|
|
333 |
// Checks whether it is aiw menu or not
|
|
334 |
if ( iAiwServiceHandler->IsAiwMenu( aResourceId ) )
|
|
335 |
{
|
|
336 |
CAiwGenericParamList* params = CAiwGenericParamList::NewLC();
|
|
337 |
|
|
338 |
// Adds the aiw plugin menus
|
|
339 |
TInt err;
|
|
340 |
TRAP( err, iAiwServiceHandler->InitializeMenuPaneL(
|
|
341 |
*aMenuPane, aResourceId, aBaseCommand, *params ) );
|
|
342 |
CleanupStack::PopAndDestroy(); // params
|
|
343 |
return ETrue;
|
|
344 |
}
|
|
345 |
|
|
346 |
return EFalse;
|
|
347 |
}
|
|
348 |
|
|
349 |
// -----------------------------------------------------------------------------
|
|
350 |
// CLmkMapNavigationInterface::AttachMenuPaneL
|
|
351 |
// -----------------------------------------------------------------------------
|
|
352 |
//
|
|
353 |
EXPORT_C void CLmkMapNavigationInterface::AttachMenuPaneL( CEikMenuPane *aMenuPane, TInt aResourceId, TInt aBaseCommand )
|
|
354 |
{
|
|
355 |
if(iAiwServiceHandler->IsAiwMenu( aResourceId ))
|
|
356 |
{
|
|
357 |
CAiwGenericParamList* params = CAiwGenericParamList::NewLC();
|
|
358 |
TInt err = KErrNone;
|
|
359 |
TRAP( err, iAiwServiceHandler->InitializeMenuPaneL(
|
|
360 |
*aMenuPane, aResourceId, aBaseCommand, *params ) );
|
|
361 |
CleanupStack::PopAndDestroy( params );
|
|
362 |
}
|
|
363 |
}
|
|
364 |
|
|
365 |
// -----------------------------------------------------------------------------
|
|
366 |
// CLmkMapNavigationInterface::DetachInterestL
|
|
367 |
// -----------------------------------------------------------------------------
|
|
368 |
//
|
|
369 |
EXPORT_C void CLmkMapNavigationInterface::DetachInterestL( TInt aMenuResourceId, TInt aInterestresourceId )
|
|
370 |
{
|
|
371 |
iAiwServiceHandler->DetachMenu( aMenuResourceId, aInterestresourceId );
|
|
372 |
}
|
|
373 |
|
|
374 |
// -----------------------------------------------------------------------------
|
|
375 |
// CLmkMapNavigationInterface::HandleCategorySearchNotifyL
|
|
376 |
// -----------------------------------------------------------------------------
|
|
377 |
//
|
|
378 |
void CLmkMapNavigationInterface::HandleCategorySearchNotifyL( RArray<TPosLmItemId> aArray )
|
|
379 |
{
|
|
380 |
iLandmarkArray.ResetAndDestroy();
|
|
381 |
for(TInt i = 0; i < aArray.Count(); ++i)
|
|
382 |
{
|
|
383 |
CPosLandmark* lmk = iSearchUtil->GetLandmarkForIdL( aArray[i] );
|
|
384 |
iLandmarkArray.Append( lmk );
|
|
385 |
}
|
|
386 |
if(iWaitNote)
|
|
387 |
{
|
|
388 |
iWaitNote->ProcessFinishedL();
|
|
389 |
}
|
|
390 |
delete iSearchUtil;
|
|
391 |
iSearchUtil = NULL;
|
|
392 |
}
|
|
393 |
// -----------------------------------------------------------------------------
|
|
394 |
// CLmkMapNavigationInterface::HandleLmkSearchNotifyL
|
|
395 |
// -----------------------------------------------------------------------------
|
|
396 |
//
|
|
397 |
void CLmkMapNavigationInterface::HandleLmkSearchNotifyL()
|
|
398 |
{
|
|
399 |
// Do nothing
|
|
400 |
}
|
|
401 |
|
|
402 |
// -----------------------------------------------------------------------------
|
|
403 |
// CLmkMapNavigationInterface::CheckAndDisplayIfLandmarksEmptyL
|
|
404 |
// -----------------------------------------------------------------------------
|
|
405 |
//
|
|
406 |
TBool CLmkMapNavigationInterface::CheckAndDisplayIfLandmarksEmptyL( RPointerArray<CPosLandmark> &aArray )
|
|
407 |
{
|
|
408 |
//Error cases when Landmark(s) is/are empty
|
|
409 |
enum ErrorCases
|
|
410 |
{
|
|
411 |
EErrAllEmpty, // All selected landmarks are empty
|
|
412 |
EErrSomeEmpty, // Some selected landmarks are empty
|
|
413 |
EErrOneEmpty, // Only one of the selected landmark is empty
|
|
414 |
EErrOnlyOneAndEmpty, // Only one landmark is selected and that is empty
|
|
415 |
EErrNone // All landmarks have valid coordinate data
|
|
416 |
};
|
|
417 |
|
|
418 |
TInt count = aArray.Count();
|
|
419 |
TInt err = EErrNone;
|
|
420 |
CPosLandmark* lmk;
|
|
421 |
TInt numberOfEmptyLmk = 0;
|
|
422 |
TInt emptyIndex = 0;
|
|
423 |
|
|
424 |
for(TInt index = 0; index < count; ++index)
|
|
425 |
{
|
|
426 |
lmk = aArray[index];
|
|
427 |
if( IsLandmarkDataEmptyL(*lmk) )
|
|
428 |
{
|
|
429 |
err = EErrSomeEmpty;
|
|
430 |
++numberOfEmptyLmk;
|
|
431 |
emptyIndex = index;
|
|
432 |
}
|
|
433 |
}
|
|
434 |
|
|
435 |
if(numberOfEmptyLmk == count)
|
|
436 |
{
|
|
437 |
/*
|
|
438 |
* When view type is by lmk view then we make the check for
|
|
439 |
* only one landmark.
|
|
440 |
*/
|
|
441 |
if( count == 1 && (EByLmkView == iViewType) )
|
|
442 |
{
|
|
443 |
err = EErrOnlyOneAndEmpty;
|
|
444 |
}
|
|
445 |
else
|
|
446 |
{
|
|
447 |
err = EErrAllEmpty;
|
|
448 |
}
|
|
449 |
}
|
|
450 |
else if(err == EErrSomeEmpty && numberOfEmptyLmk == 1)
|
|
451 |
{
|
|
452 |
err = EErrOneEmpty;
|
|
453 |
}
|
|
454 |
|
|
455 |
switch(err)
|
|
456 |
{
|
|
457 |
case EErrAllEmpty:
|
|
458 |
{
|
|
459 |
if(EByLmkView == iViewType)
|
|
460 |
{
|
|
461 |
LmkNotes::AllLandmarksEmptyNoteL( iEnv );
|
|
462 |
}
|
|
463 |
else
|
|
464 |
{
|
|
465 |
LmkNotes::CategoryEmptyNoteL( iEnv, iCategoryName->Des());
|
|
466 |
}
|
|
467 |
return EFalse;
|
|
468 |
}
|
|
469 |
case EErrSomeEmpty:
|
|
470 |
{
|
|
471 |
HBufC* noteText = NULL;
|
|
472 |
|
|
473 |
if(EByLmkView == iViewType)
|
|
474 |
{
|
|
475 |
noteText = StringLoader::LoadLC( R_LM_SHOW_QUERY_NO_COORDINATES_SEVERAL,
|
|
476 |
numberOfEmptyLmk,
|
|
477 |
iEnv );
|
|
478 |
}
|
|
479 |
else
|
|
480 |
{
|
|
481 |
CPtrC16Array* array = new (ELeave) CPtrC16Array(2);
|
|
482 |
array->Reset();
|
|
483 |
CleanupStack::PushL( array );
|
|
484 |
HBufC* ptr = iCategoryName->AllocLC();
|
|
485 |
array->AppendL( *ptr );
|
|
486 |
|
|
487 |
CArrayFix<TInt>* arrFix = new( ELeave ) CArrayFixFlat<TInt>(2);
|
|
488 |
CleanupStack::PushL( arrFix );
|
|
489 |
arrFix->AppendL(numberOfEmptyLmk);
|
|
490 |
noteText = StringLoader::LoadLC( R_LM_SHOW_QUERY_CATEGORY_NO_COORDINATES_SEVERAL,
|
|
491 |
*array,
|
|
492 |
*arrFix,
|
|
493 |
iEnv );
|
|
494 |
CleanupStack::Pop();// noteText
|
|
495 |
CleanupStack::PopAndDestroy( 3 ); //ptr, array
|
|
496 |
CleanupStack::PushL( noteText );
|
|
497 |
}
|
|
498 |
|
|
499 |
CAknQueryDialog* dlg = CAknQueryDialog::NewL( CAknQueryDialog::ENoTone );
|
|
500 |
TInt retVal = dlg->ExecuteLD( R_EMPTY_LANDMARKS_DIALOG, *noteText );
|
|
501 |
CleanupStack::PopAndDestroy( noteText );
|
|
502 |
if(!retVal)
|
|
503 |
{
|
|
504 |
return EFalse;
|
|
505 |
}
|
|
506 |
break;
|
|
507 |
}
|
|
508 |
case EErrOneEmpty:
|
|
509 |
{
|
|
510 |
lmk = aArray[emptyIndex];
|
|
511 |
TPtrC landmarkname;
|
|
512 |
lmk->GetLandmarkName( landmarkname );
|
|
513 |
HBufC* noteText = NULL;
|
|
514 |
|
|
515 |
if(EByLmkView == iViewType)
|
|
516 |
{
|
|
517 |
noteText = StringLoader::LoadLC( R_LM_SHOW_QUERY_NO_COORDINATES_SINGLE,
|
|
518 |
landmarkname,
|
|
519 |
iEnv );
|
|
520 |
}
|
|
521 |
else
|
|
522 |
{
|
|
523 |
CPtrC16Array* array = new (ELeave) CPtrC16Array(2);
|
|
524 |
array->Reset();
|
|
525 |
CleanupStack::PushL( array );
|
|
526 |
HBufC* ptr = landmarkname.AllocLC();
|
|
527 |
array->AppendL( *ptr );
|
|
528 |
array->AppendL( *iCategoryName );
|
|
529 |
|
|
530 |
noteText = StringLoader::LoadLC( R_LM_SHOW_QUERY_CATEGORY_NO_COORDINATES_SINGLE,
|
|
531 |
*array,
|
|
532 |
iEnv );
|
|
533 |
CleanupStack::Pop();// noteText
|
|
534 |
CleanupStack::PopAndDestroy( 2 ); //ptr, array
|
|
535 |
CleanupStack::PushL( noteText );
|
|
536 |
}
|
|
537 |
|
|
538 |
CAknQueryDialog* dlg = CAknQueryDialog::NewL( CAknQueryDialog::ENoTone );
|
|
539 |
TInt retVal = dlg->ExecuteLD( R_EMPTY_LANDMARK_DIALOG, *noteText );
|
|
540 |
CleanupStack::PopAndDestroy( noteText ); //array, lmk, category and noteText
|
|
541 |
if(!retVal)
|
|
542 |
{
|
|
543 |
return EFalse;
|
|
544 |
}
|
|
545 |
break;
|
|
546 |
}
|
|
547 |
case EErrOnlyOneAndEmpty:
|
|
548 |
{
|
|
549 |
lmk = aArray[emptyIndex];
|
|
550 |
TPtrC landmarkname;
|
|
551 |
lmk->GetLandmarkName( landmarkname );
|
|
552 |
if( EByLmkView == iViewType )
|
|
553 |
{
|
|
554 |
// This error case happens only when in by Landmark view.
|
|
555 |
LmkNotes::LandmarksEmptyNoteL( iEnv, landmarkname );
|
|
556 |
}
|
|
557 |
else
|
|
558 |
{
|
|
559 |
|
|
560 |
}
|
|
561 |
return EFalse;
|
|
562 |
}
|
|
563 |
default:
|
|
564 |
{
|
|
565 |
break;
|
|
566 |
}
|
|
567 |
}
|
|
568 |
return ETrue;
|
|
569 |
}
|
|
570 |
|
|
571 |
// -----------------------------------------------------------------------------
|
|
572 |
// CLmkMapNavigationInterface::IsLandmarkDataEmptyL
|
|
573 |
// -----------------------------------------------------------------------------
|
|
574 |
//
|
|
575 |
TBool CLmkMapNavigationInterface::IsLandmarkDataEmptyL( CPosLandmark& aLandmark )
|
|
576 |
{
|
|
577 |
// verify that destination landmark has coordinates
|
|
578 |
TLocality loc;
|
|
579 |
TBool isValid = (KErrNone == aLandmark.GetPosition( loc ) );
|
|
580 |
isValid &= !Math::IsNaN( loc.Latitude() ) && !Math::IsNaN( loc.Longitude() );
|
|
581 |
return !isValid;
|
|
582 |
|
|
583 |
/* if ( !isValid )
|
|
584 |
{
|
|
585 |
// verify that destination landmark has address info
|
|
586 |
TPositionFieldId fieldId = aLandmark.FirstPositionFieldId();
|
|
587 |
while ( fieldId != EPositionFieldNone )
|
|
588 |
{
|
|
589 |
if ( fieldId > EPositionFieldAddressCapabilitiesBegin &&
|
|
590 |
fieldId < EPositionFieldBuildingTelephone )
|
|
591 |
{
|
|
592 |
TPtrC field;
|
|
593 |
aLandmark.GetPositionField( fieldId, field );
|
|
594 |
if ( field.Length() )
|
|
595 |
{
|
|
596 |
isValid = ETrue;
|
|
597 |
break;
|
|
598 |
}
|
|
599 |
}
|
|
600 |
fieldId = aLandmark.NextPositionFieldId( fieldId );
|
|
601 |
}
|
|
602 |
}
|
|
603 |
return !isValid;*/
|
|
604 |
}
|
|
605 |
|
|
606 |
// -----------------------------------------------------------------------------
|
|
607 |
// CLmkMapNavigationInterface::SetObserver
|
|
608 |
// -----------------------------------------------------------------------------
|
|
609 |
//
|
|
610 |
EXPORT_C void CLmkMapNavigationInterface::SetObserver(MLmkMapAndNavigationObserver* aObserver)
|
|
611 |
{
|
|
612 |
iObserver = aObserver;
|
|
613 |
}
|
|
614 |
// -----------------------------------------------------------------------------
|
|
615 |
// CLmkMapNavigationInterface::Release
|
|
616 |
// -----------------------------------------------------------------------------
|
|
617 |
//
|
|
618 |
EXPORT_C void CLmkMapNavigationInterface::Release()
|
|
619 |
{
|
|
620 |
iRefCnt--;
|
|
621 |
if( iRefCnt == 0)
|
|
622 |
{
|
|
623 |
delete this;
|
|
624 |
}
|
|
625 |
}
|
|
626 |
// End of file
|