|
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: This is NPP PSY Positioning Plug-in ( PSY ). |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32std.h> |
|
22 #include <lbs/epos_mpositionerstatus.h> |
|
23 #include <lbscommon.h> |
|
24 |
|
25 #include "npppsystatushandler.h" |
|
26 #include "npppsysingletonhandler.h" |
|
27 #include "npppsylogging.h" |
|
28 #include "npppsypanic.h" |
|
29 #include "npppsy.hrh" |
|
30 |
|
31 |
|
32 // ========================== == MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CNppPsyStatusHandler::CNppPsyStatusHandler |
|
36 // C++default constructor can NOT contain any code, that |
|
37 // might leave. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CNppPsyStatusHandler::CNppPsyStatusHandler( MPositionerStatus& aStatusInterface ) |
|
41 : iStatusInterface( aStatusInterface ) |
|
42 { |
|
43 //Set to initialising |
|
44 iModuleStatus.SetDeviceStatus( TPositionModuleStatus::EDeviceInitialising ); |
|
45 iModuleStatus.SetDataQualityStatus( TPositionModuleStatus::EDataQualityNormal ); |
|
46 iStatusInterface.ReportStatus( iModuleStatus ); |
|
47 } |
|
48 |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CNppPsyStatusHandler::ConstructL |
|
52 // Symbian 2nd phase constructor can leave. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 void CNppPsyStatusHandler::ConstructL() |
|
56 { |
|
57 TRACESTRING( "CNppPsyStatusHandler::ConstructL start" ) |
|
58 |
|
59 //Set to ready |
|
60 iModuleStatus.SetDeviceStatus( TPositionModuleStatus::EDeviceReady ); |
|
61 iStatusInterface.ReportStatus( iModuleStatus ); |
|
62 |
|
63 TRACESTRING( "CNppPsyStatusHandler::ConstructL end" ) |
|
64 } |
|
65 |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CNppPsyStatusHandler::NewL |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CNppPsyStatusHandler* CNppPsyStatusHandler::NewL( |
|
72 MPositionerStatus& aStatusInterface ) |
|
73 { |
|
74 CNppPsyStatusHandler* self = new( ELeave ) CNppPsyStatusHandler( |
|
75 aStatusInterface ); |
|
76 |
|
77 CleanupStack::PushL( self ); |
|
78 self->ConstructL(); |
|
79 CleanupStack::Pop( self ); |
|
80 |
|
81 return self; |
|
82 } |
|
83 |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CNppPsyStatusHandler::~CNppPsyStatusHandler |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 CNppPsyStatusHandler::~CNppPsyStatusHandler() |
|
90 { |
|
91 //Set as inactive and data quality unknown |
|
92 iModuleStatus.SetDeviceStatus( TPositionModuleStatus::EDeviceInactive ); |
|
93 iModuleStatus.SetDataQualityStatus( |
|
94 TPositionModuleStatus::EDataQualityUnknown ); |
|
95 iStatusInterface.ReportStatus( iModuleStatus ); |
|
96 |
|
97 TRACESTRING( "CNppPsyStatusHandler:: destructed" ) |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CNppPsyStatusHandler::SetPsyListStatus |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 void CNppPsyStatusHandler::SetPsyListStatus( TBool aHealthy ) |
|
105 { |
|
106 if ( aHealthy && iModuleStatus.DeviceStatus() == |
|
107 TPositionModuleStatus::EDeviceError ) |
|
108 { |
|
109 if ( iRequests > 0 ) |
|
110 { |
|
111 iModuleStatus.SetDeviceStatus( |
|
112 TPositionModuleStatus::EDeviceActive ); |
|
113 } |
|
114 else |
|
115 { |
|
116 iModuleStatus.SetDeviceStatus( |
|
117 TPositionModuleStatus::EDeviceReady ); |
|
118 } |
|
119 iStatusInterface.ReportStatus( iModuleStatus ); |
|
120 } |
|
121 |
|
122 if ( !aHealthy && iModuleStatus.DeviceStatus() != |
|
123 TPositionModuleStatus::EDeviceError ) |
|
124 { |
|
125 iModuleStatus.SetDeviceStatus( TPositionModuleStatus::EDeviceError ); |
|
126 iStatusInterface.ReportStatus( iModuleStatus ); |
|
127 } |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CNppPsyStatusHandler::IncRequestCount |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void CNppPsyStatusHandler::IncRequestCount() |
|
135 { |
|
136 ++iRequests; |
|
137 UpdateStatus(); |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CNppPsyStatusHandler::DecRequestCount |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void CNppPsyStatusHandler::DecRequestCount() |
|
145 { |
|
146 if ( iRequests > 0 ) |
|
147 { |
|
148 --iRequests; |
|
149 } |
|
150 UpdateStatus(); |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CNppPsyStatusHandler::UpdateStatus |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 void CNppPsyStatusHandler::UpdateStatus() |
|
158 { |
|
159 if ( iRequests > 0 && iModuleStatus.DeviceStatus() == |
|
160 TPositionModuleStatus::EDeviceReady ) |
|
161 { |
|
162 iModuleStatus.SetDeviceStatus( TPositionModuleStatus::EDeviceActive ); |
|
163 iStatusInterface.ReportStatus( iModuleStatus ); |
|
164 } |
|
165 |
|
166 if ( iRequests <= 0 && iModuleStatus.DeviceStatus() == |
|
167 TPositionModuleStatus::EDeviceActive ) |
|
168 { |
|
169 iModuleStatus.SetDeviceStatus( TPositionModuleStatus::EDeviceReady ); |
|
170 iStatusInterface.ReportStatus( iModuleStatus ); |
|
171 } |
|
172 } |
|
173 |
|
174 // End of File |