summaryrefslogtreecommitdiff
authorzecke <zecke>2005-11-28 20:47:57 (UTC)
committer zecke <zecke>2005-11-28 20:47:57 (UTC)
commit252a5a6c477ee0b394b34dce5f77265006ae2010 (patch) (unidiff)
tree40e77d6f37873555c0cda0622e888e447f26c198
parent6ed0ea6196d210847c041dfd1229b4f2db71b152 (diff)
downloadopie-252a5a6c477ee0b394b34dce5f77265006ae2010.zip
opie-252a5a6c477ee0b394b34dce5f77265006ae2010.tar.gz
opie-252a5a6c477ee0b394b34dce5f77265006ae2010.tar.bz2
Opie Battery Applet for h19??:
Patch by Pawel Kolodziejski (thank you once again) to make this applet work with the specific iPAQ model. It uses a 2.6kernel and there is no iPAQ specific prof file anymore, I think this device is not even capable of having a sleeve.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/batteryapplet/batterystatus.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/core/applets/batteryapplet/batterystatus.cpp b/core/applets/batteryapplet/batterystatus.cpp
index 34043f4..08ddc85 100644
--- a/core/applets/batteryapplet/batterystatus.cpp
+++ b/core/applets/batteryapplet/batterystatus.cpp
@@ -1,78 +1,79 @@
1 1
2#include "batterystatus.h" 2#include "batterystatus.h"
3 3
4/* OPIE */ 4/* OPIE */
5#include <opie2/odevice.h> 5#include <opie2/odevice.h>
6#include <qpe/power.h> 6#include <qpe/power.h>
7 7
8/* QT */ 8/* QT */
9#include <qpushbutton.h> 9#include <qpushbutton.h>
10#include <qdrawutil.h> 10#include <qdrawutil.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qtextstream.h> 12#include <qtextstream.h>
13#include <qmessagebox.h> 13#include <qmessagebox.h>
14 14
15using namespace Opie::Core; 15using namespace Opie::Core;
16 16
17BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent, WFlags f ) 17BatteryStatus::BatteryStatus( const PowerStatus *p, QWidget *parent, WFlags f )
18: QFrame( parent, 0, f), ps(p), bat2(false) { 18: QFrame( parent, 0, f), ps(p), bat2(false) {
19 19
20 UpdateBatteryStatus(); 20 UpdateBatteryStatus();
21} 21}
22 22
23BatteryStatus::~BatteryStatus() {} 23BatteryStatus::~BatteryStatus() {}
24 24
25void BatteryStatus::UpdateBatteryStatus() { 25void BatteryStatus::UpdateBatteryStatus() {
26 26
27 jackPercent = 0; 27 jackPercent = 0;
28 28
29 if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) { 29 if ( ODevice::inst ( )-> series ( ) == Model_iPAQ ) {
30 getProcApmStatusIpaq(); 30 if ( ODevice::inst ( ) -> model() != Model_iPAQ_H191x )
31 getProcApmStatusIpaq();
31 } 32 }
32 percent = ps->batteryPercentRemaining(); 33 percent = ps->batteryPercentRemaining();
33} 34}
34 35
35/* 36/*
36 * Make use of the advanced apm interface of the ipaq 37 * Make use of the advanced apm interface of the ipaq
37 */ 38 */
38bool BatteryStatus::getProcApmStatusIpaq() { 39bool BatteryStatus::getProcApmStatusIpaq() {
39 40
40 bat2 = false; 41 bat2 = false;
41 42
42 QFile procApmIpaq("/proc/hal/battery"); 43 QFile procApmIpaq("/proc/hal/battery");
43 44
44 if (procApmIpaq.open(IO_ReadOnly) ) { 45 if (procApmIpaq.open(IO_ReadOnly) ) {
45 QStringList list; 46 QStringList list;
46 // since it is /proc we _must_ use QTextStream 47 // since it is /proc we _must_ use QTextStream
47 QTextStream stream ( &procApmIpaq); 48 QTextStream stream ( &procApmIpaq);
48 QString streamIn; 49 QString streamIn;
49 streamIn = stream.read(); 50 streamIn = stream.read();
50 list = QStringList::split("\n", streamIn); 51 list = QStringList::split("\n", streamIn);
51 52
52 sec2 = sec1 = ""; 53 sec2 = sec1 = "";
53 54
54 for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { 55 for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) {
55 // not nice, need a rewrite later 56 // not nice, need a rewrite later
56 if( (*line).startsWith(" Percentage") ) { 57 if( (*line).startsWith(" Percentage") ) {
57 if (bat2 == true) { 58 if (bat2 == true) {
58 perc2 = (*line).mid(((*line).find('(')) +1,(*line).find(')')-(*line).find('(')-2); 59 perc2 = (*line).mid(((*line).find('(')) +1,(*line).find(')')-(*line).find('(')-2);
59 } else { 60 } else {
60 perc1 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2); 61 perc1 = (*line).mid(((*line).find('('))+1,(*line).find(')')-(*line).find('(')-2);
61 } 62 }
62 } else if( (*line).startsWith(" Life") ) { 63 } else if( (*line).startsWith(" Life") ) {
63 if (bat2 == true) { 64 if (bat2 == true) {
64 sec2 = (*line).mid(((*line).find(':')+2), 5 ); 65 sec2 = (*line).mid(((*line).find(':')+2), 5 );
65 } else { 66 } else {
66 sec1 = (*line).mid(((*line).find(':')+2), 5 ); 67 sec1 = (*line).mid(((*line).find(':')+2), 5 );
67 } 68 }
68 } else if( (*line).startsWith("Battery #1") ) { 69 } else if( (*line).startsWith("Battery #1") ) {
69 bat2 = true; 70 bat2 = true;
70 } else if( (*line).startsWith(" Status") ) { 71 } else if( (*line).startsWith(" Status") ) {
71 if (bat2 == true) { 72 if (bat2 == true) {
72 jackStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1); 73 jackStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1);
73 } else { 74 } else {
74 ipaqStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1); 75 ipaqStatus = (*line).mid((*line).find('(')+1, (*line).find(')')-(*line).find('(')-1);
75 } 76 }
76 } else if( (*line).startsWith(" Chemistry") ) { 77 } else if( (*line).startsWith(" Chemistry") ) {
77 if (bat2 == true) { 78 if (bat2 == true) {
78 jackChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1); 79 jackChem = (*line).mid((*line).find('('), (*line).find(')')-(*line).find('(')+1);