1 /* |
|
2 * Copyright (c) 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: Location Notation Preferences Plugin Co-ordinate display adapter |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // System Include |
|
20 #include <centralrepository.h> |
|
21 |
|
22 // User Include |
|
23 #include "locnotprefcorddisadapter.h" |
|
24 #include "locnotprefadapterobserver.h" |
|
25 |
|
26 // Constant Definition |
|
27 const TUint KAvkonCRUID = 0x101F876E; |
|
28 const TUint KLocCoordinateDisplayUID = 0x00000009; |
|
29 |
|
30 // ========================= MEMBER FUNCTIONS ================================ |
|
31 |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // CLocNotPrefCoordinateDisplayAdapter::CLocNotPrefCoordinateDisplayAdapter |
|
35 // Overloaded Constructor |
|
36 // |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 CLocNotPrefCoordinateDisplayAdapter::CLocNotPrefCoordinateDisplayAdapter( |
|
40 MLocNotPrefAdapterObserver& aAdapterObsrv ) |
|
41 :CActive(EPriorityStandard), |
|
42 iObserver(aAdapterObsrv) |
|
43 { |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CLocNotPrefCoordinateDisplayAdapter::~CLocNotPrefCoordinateDisplayAdapter |
|
48 // Destructor |
|
49 // |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 CLocNotPrefCoordinateDisplayAdapter::~CLocNotPrefCoordinateDisplayAdapter() |
|
53 { |
|
54 Cancel(); |
|
55 |
|
56 delete iRepository; |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CLocNotPrefCoordinateDisplayAdapter* CLocNotPrefCoordinateDisplayAdapter::NewL |
|
61 // Creates new Co-ordinate display adapter |
|
62 // |
|
63 // @param aAdapterObsrv Observer to the Settings adapter |
|
64 // @return CLocNotPrefCoordinateDisplayAdapter& Reference to the application view |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CLocNotPrefCoordinateDisplayAdapter* CLocNotPrefCoordinateDisplayAdapter::NewL( |
|
68 MLocNotPrefAdapterObserver& aAdapterObsrv ) |
|
69 { |
|
70 CLocNotPrefCoordinateDisplayAdapter* self = |
|
71 CLocNotPrefCoordinateDisplayAdapter::NewLC( aAdapterObsrv ); |
|
72 CleanupStack::Pop(self); |
|
73 return self; |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // CLocNotPrefCoordinateDisplayAdapter* CLocNotPrefCoordinateDisplayAdapter::NewLC |
|
78 // Creates new Co-ordinate display adapter. Leaves the object on the clean-up |
|
79 // stack |
|
80 // |
|
81 // @param aAdapterObsrv Observer to the Settings adapter |
|
82 // @return CLocNotPrefCoordinateDisplayAdapter& Reference to the application view |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 CLocNotPrefCoordinateDisplayAdapter* CLocNotPrefCoordinateDisplayAdapter::NewLC( |
|
86 MLocNotPrefAdapterObserver& aAdapterObsrv ) |
|
87 { |
|
88 CLocNotPrefCoordinateDisplayAdapter* self = |
|
89 new(ELeave) CLocNotPrefCoordinateDisplayAdapter( aAdapterObsrv ); |
|
90 CleanupStack::PushL(self); |
|
91 self->ConstructL(); |
|
92 return self; |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------------------------- |
|
96 // void CLocNotPrefCoordinateDisplayAdapter::ConstructL |
|
97 // Second Phase Constructor |
|
98 // |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 void CLocNotPrefCoordinateDisplayAdapter::ConstructL() |
|
102 { |
|
103 CActiveScheduler::Add( this ); |
|
104 |
|
105 // Create the Central repository object for manipulating Avkon Central |
|
106 // repository for Co-ordinate display settings |
|
107 iRepository = CRepository::NewL(TUid::Uid( KAvkonCRUID)); |
|
108 |
|
109 StartNotification(); |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // CLocNotPrefCoordinateDisplayAdapter::TCordDisSetListPosition |
|
114 // CLocNotPrefCoordinateDisplayAdapter::GetCurrentDisplayFormatL |
|
115 // Returns the position of the Co-ordinate display format settings value. |
|
116 // |
|
117 // @return TCordDisSetListPosition Current postion of the Co-ordinate display |
|
118 // settings value. |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 CLocNotPrefCoordinateDisplayAdapter::TCordDisSetListPosition |
|
122 CLocNotPrefCoordinateDisplayAdapter::GetCurrentDisplayFormatL() |
|
123 { |
|
124 |
|
125 TInt settingsValue = EDMSS; |
|
126 User::LeaveIfError( iRepository->Get( KLocCoordinateDisplayUID, |
|
127 settingsValue )); |
|
128 |
|
129 TCordDisSetListPosition setPos = EPosDMSS; |
|
130 switch( settingsValue ) |
|
131 { |
|
132 case EDD: |
|
133 { |
|
134 setPos = EPosDD; |
|
135 break; |
|
136 } |
|
137 case EDMM: |
|
138 { |
|
139 setPos = EPosDMM; |
|
140 break; |
|
141 } |
|
142 case EDMSS: |
|
143 default: |
|
144 { |
|
145 // Incase there was no valid settings value present then we |
|
146 // set the default value. Hence, nothing to do |
|
147 break; |
|
148 } |
|
149 } |
|
150 return setPos; |
|
151 } |
|
152 |
|
153 // -------------------------------------------------------------------------- |
|
154 // void CLocNotPrefCoordinateDisplayAdapter::SetCurrentDisplayFormatL |
|
155 // Sets the value of the Co-ordinate display format settings based on the |
|
156 // display position. |
|
157 // |
|
158 // @param aSettingsPos Position of the new Co-ordinate display settings value |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 void CLocNotPrefCoordinateDisplayAdapter::SetCurrentDisplayFormatL( |
|
162 CLocNotPrefCoordinateDisplayAdapter::TCordDisSetListPosition aSettingsValue ) |
|
163 { |
|
164 |
|
165 TCoordinateDisplayValue setValue = EDMSS; |
|
166 switch( aSettingsValue ) |
|
167 { |
|
168 case EPosDD: |
|
169 { |
|
170 setValue = EDD; |
|
171 break; |
|
172 } |
|
173 case EPosDMM: |
|
174 { |
|
175 setValue = EDMM; |
|
176 break; |
|
177 } |
|
178 case EPosDMSS: |
|
179 default: |
|
180 { |
|
181 // Incase there was no valid settings value present then we |
|
182 // set the default value. Hence, nothing to do |
|
183 break; |
|
184 } |
|
185 } |
|
186 User::LeaveIfError( iRepository->Set( KLocCoordinateDisplayUID, |
|
187 setValue )); |
|
188 } |
|
189 |
|
190 // -------------------------------------------------------------------------- |
|
191 // void CLocNotPrefCoordinateDisplayAdapter::RunL |
|
192 // Inherited from CActive |
|
193 // |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 void CLocNotPrefCoordinateDisplayAdapter::RunL() |
|
197 { |
|
198 // Issue Notification |
|
199 iObserver.HandleSettingsChangeL(); |
|
200 |
|
201 // Schedule for listening to change events again |
|
202 StartNotification(); |
|
203 } |
|
204 |
|
205 // -------------------------------------------------------------------------- |
|
206 // void CLocNotPrefCoordinateDisplayAdapter::DoCancel |
|
207 // Inherited from CActive |
|
208 // |
|
209 // --------------------------------------------------------------------------- |
|
210 // |
|
211 void CLocNotPrefCoordinateDisplayAdapter::DoCancel() |
|
212 { |
|
213 // Cancel the outstanding CR notification request |
|
214 if( iRepository ) |
|
215 { |
|
216 iRepository->NotifyCancel( KLocCoordinateDisplayUID ); |
|
217 } |
|
218 } |
|
219 |
|
220 // -------------------------------------------------------------------------- |
|
221 // void CLocNotPrefCoordinateDisplayAdapter::StartNotification |
|
222 // Start notification from the Central repository server for any changes in the |
|
223 // Co-ordinate display format key value |
|
224 // |
|
225 // --------------------------------------------------------------------------- |
|
226 // |
|
227 void CLocNotPrefCoordinateDisplayAdapter::StartNotification() |
|
228 { |
|
229 if( !IsActive()) |
|
230 { |
|
231 // Request for notification |
|
232 iRepository->NotifyRequest( KLocCoordinateDisplayUID, iStatus); |
|
233 SetActive(); |
|
234 } |
|
235 } |
|