|
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: Listner for getting the System of measurment settings using cRepository |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // System Include |
|
21 #include <centralrepository.h> |
|
22 #include <locnotprefplugindomaincrkeys.h> |
|
23 |
|
24 // INCLUDE FILES |
|
25 #include "CBlidMeasurementSettingListener.h" |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS ============================== |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // CBlidMeasurementSettingListener::CBlidMeasurementSettingListener |
|
34 // Overloaded Constructor |
|
35 // |
|
36 // --------------------------------------------------------------------------- |
|
37 // |
|
38 CBlidMeasurementSettingListener::CBlidMeasurementSettingListener( |
|
39 MBlidMeasurementSettings& aListenerObsrv ) |
|
40 :CActive(EPriorityStandard), |
|
41 iObserver(aListenerObsrv) |
|
42 { |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // CBlidMeasurementSettingListener::~CBlidMeasurementSettingListener |
|
47 // Destructor |
|
48 // |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CBlidMeasurementSettingListener::~CBlidMeasurementSettingListener() |
|
52 { |
|
53 Cancel(); |
|
54 |
|
55 delete iRepository; |
|
56 iRepository = NULL; |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // CBlidMeasurementSettingListener* CBlidMeasurementSettingListener::NewL |
|
61 // Creates new Systen of Measurement adapter |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 CBlidMeasurementSettingListener* CBlidMeasurementSettingListener::NewL( |
|
65 MBlidMeasurementSettings& aListenerObsrv ) |
|
66 { |
|
67 CBlidMeasurementSettingListener* self = |
|
68 CBlidMeasurementSettingListener::NewLC( aListenerObsrv ); |
|
69 CleanupStack::Pop(self); |
|
70 return self; |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // CBlidMeasurementSettingListener* CBlidMeasurementSettingListener::NewLC |
|
75 // Creates new Systen of Measurement Listener. Leaves the object on the clean-up |
|
76 // stack |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 CBlidMeasurementSettingListener* CBlidMeasurementSettingListener::NewLC( |
|
80 MBlidMeasurementSettings& aListenerObsrv ) |
|
81 { |
|
82 CBlidMeasurementSettingListener* self = |
|
83 new(ELeave) CBlidMeasurementSettingListener( aListenerObsrv ); |
|
84 CleanupStack::PushL(self); |
|
85 self->ConstructL(); |
|
86 return self; |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // void CBlidMeasurementSettingListener::ConstructL |
|
91 // Second Phase Constructor |
|
92 // |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 void CBlidMeasurementSettingListener::ConstructL() |
|
96 { |
|
97 CActiveScheduler::Add( this ); |
|
98 |
|
99 // Create the Central repository object for manipulating Avkon Central |
|
100 // repository for System of measurements settings |
|
101 iRepository = CRepository::NewL(TUid::Uid( KCRUidLocNotationPref )); |
|
102 |
|
103 StartNotification(); |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // TReal32 CBlidMeasurementSettingListener::SysofMeasurementL |
|
108 // Returns the current value of the System of measurements settings |
|
109 // |
|
110 // @return TReal32 Current value of the System of measurements settings |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 TReal32 CBlidMeasurementSettingListener::SysofMeasurementL() |
|
114 { |
|
115 |
|
116 TInt settingsValue = 0; |
|
117 User::LeaveIfError( iRepository->Get( KLocSystemofMeasurements, |
|
118 settingsValue )); |
|
119 return ( static_cast<TReal32>( settingsValue )); |
|
120 } |
|
121 |
|
122 |
|
123 // -------------------------------------------------------------------------- |
|
124 // void CBlidMeasurementSettingListener::RunL |
|
125 // Inherited from CActive |
|
126 // |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 void CBlidMeasurementSettingListener::RunL() |
|
130 { |
|
131 // Issue Notification |
|
132 iObserver.HandleSysMeasureValueL(); |
|
133 |
|
134 // Schedule for listening to change events again |
|
135 StartNotification(); |
|
136 } |
|
137 |
|
138 // -------------------------------------------------------------------------- |
|
139 // void CBlidMeasurementSettingListener::DoCancel |
|
140 // Inherited from CActive |
|
141 // |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 void CBlidMeasurementSettingListener::DoCancel() |
|
145 { |
|
146 // Cancel the outstanding CR notification request |
|
147 iRepository->NotifyCancel( KLocSystemofMeasurements ); |
|
148 } |
|
149 |
|
150 // -------------------------------------------------------------------------- |
|
151 // void CBlidMeasurementSettingListener::StartNotification |
|
152 // Start notification from the Central repository server for any changes in the |
|
153 // System of measurements key value |
|
154 // |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 void CBlidMeasurementSettingListener::StartNotification() |
|
158 { |
|
159 if( !IsActive()) |
|
160 { |
|
161 iStatus = KRequestPending; |
|
162 // Request for notification |
|
163 iRepository->NotifyRequest( KLocSystemofMeasurements, iStatus); |
|
164 SetActive(); |
|
165 } |
|
166 } |
|
167 |
|
168 // End of File |
|
169 |