|
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: CMnGeocodingCmdHandlerBase class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <AiwGenericParam.hrh> |
|
20 #include <AiwCommon.hrh> |
|
21 |
|
22 #include <mngeocoder.h> |
|
23 |
|
24 #include "mnaiwdebug.h" |
|
25 #include "mngeocodingcmdhandlerbase.h" |
|
26 |
|
27 // ================= LOCAL FUNCTIONS ======================= |
|
28 |
|
29 // ================= MEMBER FUNCTIONS ======================= |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CMnGeocodingCmdHandlerBase::CMnGeocodingCmdHandlerBase( CMnProvider& aProvider ) |
|
35 : CMnAiwCommandHandlerBase( aProvider ) |
|
36 { |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 CMnGeocodingCmdHandlerBase::~CMnGeocodingCmdHandlerBase() |
|
43 { |
|
44 delete iGeocoder; |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 void CMnGeocodingCmdHandlerBase::SetExitObserverL( |
|
51 MMnProviderExitCallback& aExitCallback ) |
|
52 { |
|
53 iGeocoder->SetExitObserverL( *this ); |
|
54 CMnAiwCommandHandlerBase::SetExitObserverL( aExitCallback ); |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 void CMnGeocodingCmdHandlerBase::ConstructL( TRunMode aRunMode ) |
|
61 { |
|
62 CMnAiwCommandHandlerBase::ConstructL(); |
|
63 |
|
64 if ( aRunMode == ERunModeChained ) |
|
65 { |
|
66 iGeocoder = CMnGeocoder::NewChainedL( Provider() ); |
|
67 } |
|
68 else |
|
69 { |
|
70 iGeocoder = CMnGeocoder::NewL( Provider() ); |
|
71 } |
|
72 |
|
73 iRunMode = aRunMode; |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 void CMnGeocodingCmdHandlerBase::ReadGeocodingOptionsL( |
|
80 const TAiwGenericParam& aParam, |
|
81 TMnAiwGeocodingOptionsParam& aGeoOptions ) |
|
82 { |
|
83 TPtrC8 data( aParam.Value().AsData() ); |
|
84 if ( data.Size() == sizeof( TMnAiwGeocodingOptionsParam ) ) |
|
85 { |
|
86 TMnAiwGeocodingOptionsParam options; |
|
87 TPckg<TMnAiwGeocodingOptionsParam> optionsPack( options ); |
|
88 optionsPack.Copy( data ); |
|
89 aGeoOptions = options; |
|
90 } |
|
91 else |
|
92 { |
|
93 User::Leave( KErrArgument ); |
|
94 } |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 CMnGeocoder& CMnGeocodingCmdHandlerBase::Geocoder() |
|
101 { |
|
102 return *iGeocoder; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // From class CMnAiwCommandHandlerBase |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 void CMnGeocodingCmdHandlerBase::HandleAiwParamL( const TAiwGenericParam& aParam ) |
|
110 { |
|
111 switch ( aParam.SemanticId() ) |
|
112 { |
|
113 case EGenericParamMnGeocodingOptions: |
|
114 //LOG("CMnGeocodingCmdHandlerBase::HandleAiwParam, GeocodingOptions"); |
|
115 { |
|
116 TMnAiwGeocodingOptionsParam geoOptions; |
|
117 ReadGeocodingOptionsL( aParam, geoOptions ); |
|
118 iGeocoder->SetOptions( ( CMnGeocoder::TOptions ) geoOptions.iOptions ); |
|
119 break; |
|
120 } |
|
121 default: |
|
122 CMnAiwCommandHandlerBase::HandleAiwParamL( aParam ); |
|
123 break; |
|
124 } |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // From class CMnAiwCommandHandlerBase |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 void CMnGeocodingCmdHandlerBase::HandleAiwParamLandmarksL( RArray<TPtrC8>& aLandmarkDataList ) |
|
132 { |
|
133 // if already set or not single landmarks are given |
|
134 if ( iLandmarkData.Size() || aLandmarkDataList.Count() != 1 ) |
|
135 { |
|
136 User::Leave( KErrArgument ); |
|
137 } |
|
138 iLandmarkData.Set( aLandmarkDataList[0] ); |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // From class CMnAiwCommandHandlerBase |
|
143 // ----------------------------------------------------------------------------- |
|
144 // |
|
145 void CMnGeocodingCmdHandlerBase::ResetParametersL() |
|
146 { |
|
147 iGeocoder->SetOptions( CMnGeocoder::EOptionNone ); |
|
148 iLandmarkData.Set( NULL, 0 ); |
|
149 } |