-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 | |||
@@ -117,78 +117,24 @@ bool PowerStatusManager::getProcApmStatus( int &ac, int &bs, int &bf, int &pc, i | |||
117 | break; | 117 | break; |
118 | case 0x02: | 118 | case 0x02: |
119 | ps->ac = PowerStatus::Backup; | 119 | ps->ac = PowerStatus::Backup; |
120 | break; | 120 | break; |
121 | } | 121 | } |
122 | 122 | ||
123 | if ( pc > 100 ) | 123 | if ( pc > 100 ) pc = 100; |
124 | pc = -1; | 124 | if ( pc < 0 ) pc = 0; |
125 | 125 | ||
126 | ps->percentRemain = pc; | 126 | ps->percentRemain = pc; |
127 | ps->secsRemain = sec; | 127 | ps->secsRemain = sec; |
128 | 128 | ||
129 | ok = true; | 129 | ok = true; |
130 | } | 130 | } |
131 | 131 | ||
132 | return ok; | 132 | return ok; |
133 | } | 133 | } |
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() |
190 | { | 136 | { |
191 | bool usedApm = FALSE; | 137 | bool usedApm = FALSE; |
192 | 138 | ||
193 | ps->percentAccurate = TRUE; | 139 | ps->percentAccurate = TRUE; |
194 | 140 | ||
@@ -220,9 +166,6 @@ void PowerStatusManager::getStatus() | |||
220 | ps->percentRemain = 100; | 166 | ps->percentRemain = 100; |
221 | ps->secsRemain = -1; | 167 | ps->secsRemain = -1; |
222 | ps->percentAccurate = FALSE; | 168 | ps->percentAccurate = FALSE; |
223 | #endif | 169 | #endif |
224 | } | 170 | } |
225 | } | 171 | } |
226 | |||
227 | #endif | ||
228 | |||