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: CMnSelectFromMapHandler class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 |
|
21 #include <AiwGenericParam.hrh> |
|
22 #include <AiwCommon.hrh> |
|
23 |
|
24 #include <EPos_CPosLandmark.h> |
|
25 |
|
26 #include <mnmapview.h> |
|
27 |
|
28 #include "mnaiwdebug.h" |
|
29 #include "mnaiwinternal.h" |
|
30 #include "mnselectfrommaphandler.h" |
|
31 |
|
32 // ================= LOCAL FUNCTIONS ======================= |
|
33 |
|
34 // ================= MEMBER FUNCTIONS ======================= |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CMnSelectFromMapHandler::CMnSelectFromMapHandler( CMnProvider& aProvider ) |
|
40 : CMnMapViewCmdHandlerBase( aProvider ) |
|
41 { |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CMnSelectFromMapHandler* CMnSelectFromMapHandler::NewL( |
|
48 CMnProvider& aProvider, |
|
49 TRunMode aRunMode ) |
|
50 { |
|
51 CMnSelectFromMapHandler* self = |
|
52 new (ELeave) CMnSelectFromMapHandler( aProvider ); |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL( aRunMode ); |
|
55 CleanupStack::Pop( self ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 void CMnSelectFromMapHandler::ConstructL( TRunMode aRunMode ) |
|
63 { |
|
64 LOG("CMnSelectFromMapHandler::ConstructL in"); |
|
65 |
|
66 CMnMapViewCmdHandlerBase::ConstructL( aRunMode ); |
|
67 |
|
68 LOG("CMnSelectFromMapHandler::ConstructL out"); |
|
69 } |
|
70 |
|
71 // ================= INTERNAL FUNCTIONS ======================= |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // From class CMnAiwCommandHandlerBase |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CMnSelectFromMapHandler::DoStartL() |
|
78 { |
|
79 LOG("CMnSelectFromMapHandler::DoStartL in"); |
|
80 |
|
81 MapView().SelectFromMapL( iStatus ); |
|
82 |
|
83 LOG("CMnSelectFromMapHandler::DoStartL out"); |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // From class CActive |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void CMnSelectFromMapHandler::RunL() |
|
91 { |
|
92 LOG("CMnSelectFromMapHandler::RunL in"); |
|
93 |
|
94 TInt result = iStatus.Int(); |
|
95 if ( result == KErrNone ) |
|
96 { |
|
97 // read selection result and put to AIW |
|
98 switch ( MapView().SelectionResultType() ) |
|
99 { |
|
100 case CMnMapView::ESelectionFreeLandmark: |
|
101 LOG("CMnSelectFromMapHandler::RunL selected free"); |
|
102 { |
|
103 CPosLandmark* lm = MapView().RetrieveSelectionResultL(); |
|
104 CleanupStack::PushL( lm ); |
|
105 WriteLandmarkL( *lm ); |
|
106 CleanupStack::PopAndDestroy( lm ); |
|
107 } |
|
108 break; |
|
109 |
|
110 case CMnMapView::ESelectionLandmarkIndex: |
|
111 LOG("CMnSelectFromMapHandler::RunL selected index"); |
|
112 { |
|
113 TInt landmarkIndex( KErrNotFound ); |
|
114 MapView().RetrieveSelectionResultL( landmarkIndex ); |
|
115 LOG1("CMnSelectFromMapHandler::RunL selected index %d", landmarkIndex); |
|
116 |
|
117 // find this landmark in input |
|
118 TAiwGenericParam param; |
|
119 if ( FindLandmarkData( landmarkIndex, param ) ) |
|
120 { |
|
121 // give it back to client |
|
122 AiwParameters().OutList().AppendL( param ); |
|
123 } |
|
124 else |
|
125 { |
|
126 result = KErrNotFound; |
|
127 } |
|
128 } |
|
129 break; |
|
130 |
|
131 case CMnMapView::ESelectionLinkedLandmark: |
|
132 LOG("CMnSelectFromMapHandler::RunL selected linked"); |
|
133 { |
|
134 TPosLmItemId lmId( KPosLmNullItemId ); |
|
135 HBufC* dbUri = NULL; |
|
136 MapView().RetrieveSelectionResultL( lmId, dbUri ); |
|
137 CleanupStack::PushL( dbUri ); |
|
138 WriteLandmarkL( lmId, *dbUri ); |
|
139 CleanupStack::PopAndDestroy( dbUri ); |
|
140 } |
|
141 break; |
|
142 |
|
143 default: |
|
144 // Unknown result type |
|
145 break; |
|
146 } |
|
147 } |
|
148 Done( result ); |
|
149 LOG("CMnSelectFromMapHandler::RunL out"); |
|
150 } |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // From class CActive |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void CMnSelectFromMapHandler::DoCancel() |
|
157 { |
|
158 MapView().Cancel(); |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // From class CMnAiwCommandHandlerBase |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 void CMnSelectFromMapHandler::HandleAiwParamL( const TAiwGenericParam& aParam ) |
|
166 { |
|
167 switch ( aParam.SemanticId() ) |
|
168 { |
|
169 case EGenericParamRequestText: |
|
170 if ( aParam.Value().TypeId() == EVariantTypeDesC ) |
|
171 { |
|
172 iMapView->SetCustomRequestTextL( aParam.Value().AsDes() ); |
|
173 } |
|
174 else |
|
175 { |
|
176 User::Leave( KErrArgument ); |
|
177 } |
|
178 break; |
|
179 |
|
180 default: |
|
181 CMnMapViewCmdHandlerBase::HandleAiwParamL( aParam ); |
|
182 break; |
|
183 } |
|
184 } |
|