-rw-r--r-- | library/power.cpp | 61 |
1 files changed, 2 insertions, 59 deletions
diff --git a/library/power.cpp b/library/power.cpp index ec5b309..21c8960 100644 --- a/library/power.cpp +++ b/library/power.cpp | |||
@@ -122,4 +122,4 @@ bool PowerStatusManager::getProcApmStatus( int &ac, int &bs, int &bf, int &pc, i | |||
122 | 122 | ||
123 | if ( pc > 100 ) | 123 | if ( pc > 100 ) pc = 100; |
124 | pc = -1; | 124 | if ( pc < 0 ) pc = 0; |
125 | 125 | ||
@@ -134,56 +134,2 @@ bool PowerStatusManager::getProcApmStatus( int &ac, int &bs, int &bf, int &pc, i | |||
134 | 134 | ||
135 | #ifdef QT_QWS_SHARP | ||
136 | |||
137 | void PowerStatusManager::getStatus() | ||
138 | { | ||
139 | int ac, bs, bf, pc, sec; | ||
140 | ps->percentAccurate = TRUE; // not for long... | ||
141 | |||
142 | if ( haveProcApm && getProcApmStatus( ac, bs, bf, pc, sec ) ) { | ||
143 | // special case | ||
144 | if ( bs == 0x7f ) | ||
145 | ps->bs = PowerStatus::VeryLow; | ||
146 | pc = -1; // fake percentage | ||
147 | if ( pc < 0 ) { | ||
148 | switch ( bs ) { | ||
149 | case 0x00: ps->percentRemain = 100; break; // High | ||
150 | case 0x01: ps->percentRemain = 30; break; // Low | ||
151 | case 0x7f: ps->percentRemain = 10; break; // Very Low | ||
152 | case 0x02: ps->percentRemain = 5; break; // Critical | ||
153 | case 0x03: ps->percentRemain = -1; break; // Charging | ||
154 | } | ||
155 | ps->percentAccurate = FALSE; | ||
156 | } | ||
157 | } | ||
158 | |||
159 | char *device = "/dev/apm_bios"; | ||
160 | int fd = ::open (device, O_WRONLY); | ||
161 | if ( fd >= 0 ) { | ||
162 | int bbat_status = ioctl( fd, APM_IOC_BATTERY_BACK_CHK, 0 ); | ||
163 | switch ( bbat_status ) { | ||
164 | case 0x00: | ||
165 | ps->bbs = PowerStatus::High; | ||
166 | break; | ||
167 | case 0x01: | ||
168 | ps->bbs = PowerStatus::Low; | ||
169 | break; | ||
170 | case 0x7f: | ||
171 | ps->bbs = PowerStatus::VeryLow; | ||
172 | break; | ||
173 | case 0x02: | ||
174 | ps->bbs = PowerStatus::Critical; | ||
175 | break; | ||
176 | case 0x03: | ||
177 | ps->bbs = PowerStatus::Charging; | ||
178 | break; | ||
179 | case 0x04: | ||
180 | ps->bbs = PowerStatus::NotPresent; | ||
181 | break; | ||
182 | } | ||
183 | ::close(fd); | ||
184 | } | ||
185 | } | ||
186 | |||
187 | #else | ||
188 | |||
189 | void PowerStatusManager::getStatus() | 135 | void PowerStatusManager::getStatus() |
@@ -225,4 +171 @@ void PowerStatusManager::getStatus() | |||
225 | } | } | |
226 | |||
227 | #endif | ||
228 | |||