|
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: CMnFetchCoordinatesHandler 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 #include <epos_poslandmarkserialization.h> |
|
26 |
|
27 #include <mngeocoder.h> |
|
28 |
|
29 #include "mnaiwdebug.h" |
|
30 #include "mnaiwinternal.h" |
|
31 #include "mnfetchcoordinateshandler.h" |
|
32 |
|
33 // ================= LOCAL FUNCTIONS ======================= |
|
34 |
|
35 // ================= MEMBER FUNCTIONS ======================= |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CMnFetchCoordinatesHandler::CMnFetchCoordinatesHandler( CMnProvider& aProvider ) |
|
41 : CMnGeocodingCmdHandlerBase( aProvider ) |
|
42 { |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CMnFetchCoordinatesHandler* CMnFetchCoordinatesHandler::NewL( |
|
49 CMnProvider& aProvider, |
|
50 TRunMode aRunMode ) |
|
51 { |
|
52 CMnFetchCoordinatesHandler* self = |
|
53 new (ELeave) CMnFetchCoordinatesHandler( aProvider ); |
|
54 CleanupStack::PushL( self ); |
|
55 self->ConstructL( aRunMode ); |
|
56 CleanupStack::Pop( self ); |
|
57 return self; |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 void CMnFetchCoordinatesHandler::ConstructL( TRunMode aRunMode ) |
|
64 { |
|
65 LOG("CMnFetchCoordinatesHandler::ConstructL in"); |
|
66 |
|
67 CMnGeocodingCmdHandlerBase::ConstructL( aRunMode ); |
|
68 |
|
69 LOG("CMnFetchCoordinatesHandler::ConstructL out"); |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 void CMnFetchCoordinatesHandler::DoStartL() |
|
76 { |
|
77 LOG("CMnFetchCoordinatesHandler::DoStartL in"); |
|
78 |
|
79 if ( iLandmarkData.Size() ) |
|
80 { |
|
81 CPosLandmark* lm = PosLandmarkSerialization::UnpackL( iLandmarkData ); |
|
82 CleanupStack::PushL( lm ); |
|
83 |
|
84 Geocoder().FindCoordinateByAddressL( *lm, iStatus ); |
|
85 |
|
86 CleanupStack::PopAndDestroy( lm ); |
|
87 } |
|
88 else if ( iPlainAddress.Length() ) |
|
89 { |
|
90 Geocoder().FindCoordinateByAddressL( iPlainAddress, iStatus ); |
|
91 } |
|
92 else |
|
93 { |
|
94 User::Leave( KErrArgument ); |
|
95 } |
|
96 |
|
97 LOG("CMnFetchCoordinatesHandler::DoStartL out"); |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 void CMnFetchCoordinatesHandler::RunL() |
|
104 { |
|
105 LOG("CMnFetchCoordinatesHandler::RunL in"); |
|
106 |
|
107 TInt result = iStatus.Int(); |
|
108 if ( result == KErrNone ) |
|
109 { |
|
110 CPosLandmark* lm = CPosLandmark::NewLC(); |
|
111 Geocoder().RetrieveGeocodingResultL( *lm ); |
|
112 WriteLandmarkL( *lm ); |
|
113 CleanupStack::PopAndDestroy( lm ); |
|
114 } |
|
115 Done( result ); |
|
116 LOG("CMnFetchCoordinatesHandler::RunL out"); |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // From class CActive |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 void CMnFetchCoordinatesHandler::DoCancel() |
|
124 { |
|
125 Geocoder().Cancel(); |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // From class CMnAiwCommandHandlerBase |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void CMnFetchCoordinatesHandler::HandleAiwParamL( const TAiwGenericParam& aParam ) |
|
133 { |
|
134 if ( aParam.SemanticId() == EGenericParamUnspecified && |
|
135 aParam.Value().TypeId() == EVariantTypeDesC ) |
|
136 { |
|
137 LOG("CMnFetchCoordinatesHandler::HandleAiwParam, PlainString"); |
|
138 if ( !iPlainAddress.Length() && !iLandmarkData.Size() ) |
|
139 { |
|
140 iPlainAddress.Set( aParam.Value().AsDes() ); |
|
141 } |
|
142 } |
|
143 else |
|
144 { |
|
145 CMnGeocodingCmdHandlerBase::HandleAiwParamL( aParam ); |
|
146 } |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // From class CMnAiwCommandHandlerBase |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CMnFetchCoordinatesHandler::HandleAiwParamLandmarksL( RArray<TPtrC8>& aLandmarkDataList ) |
|
154 { |
|
155 // ignore landmarks if plain address is already found |
|
156 if ( !iPlainAddress.Length() ) |
|
157 { |
|
158 CMnGeocodingCmdHandlerBase::HandleAiwParamLandmarksL( aLandmarkDataList ); |
|
159 } |
|
160 } |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // From class CMnAiwCommandHandlerBase |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 void CMnFetchCoordinatesHandler::ResetParametersL() |
|
167 { |
|
168 iPlainAddress.Set( NULL, 0 ); |
|
169 CMnGeocodingCmdHandlerBase::ResetParametersL(); |
|
170 } |