summaryrefslogtreecommitdiff
authorsandman <sandman>2002-06-12 22:00:39 (UTC)
committer sandman <sandman>2002-06-12 22:00:39 (UTC)
commit72a7f7c6450033e3a2411c29b1f5505725c95241 (patch) (side-by-side diff)
tree12595f940d738c6a5dc5ded877f6856500301f3a
parent0d5717581cafd601edf76da8d53555ceaf82c770 (diff)
downloadopie-72a7f7c6450033e3a2411c29b1f5505725c95241.zip
opie-72a7f7c6450033e3a2411c29b1f5505725c95241.tar.gz
opie-72a7f7c6450033e3a2411c29b1f5505725c95241.tar.bz2
New singleton class for getting info on hardware
(Zaurus detection is missing -- kergoth ?)
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie/libopie.pro4
-rw-r--r--libopie/ohwinfo.cpp84
-rw-r--r--libopie/ohwinfo.h48
3 files changed, 134 insertions, 2 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro
index 7aa2ed9..49a7f49 100644
--- a/libopie/libopie.pro
+++ b/libopie/libopie.pro
@@ -1,6 +1,6 @@
TEMPLATE = lib
CONFIG += qte warn_on release
-HEADERS = ofontmenu.h ofileselector.h ofiledialog.h ofileview.h tododb.h todoevent.h todoresource.h todovcalresource.h xmltree.h colordialog.h colorpopupmenu.h oclickablelabel.h oprocctrl.h oprocess.h
-SOURCES = ofontmenu.cc ofileselector.cc ofiledialog.cc xmltree.cc tododb.cpp todoevent.cpp todovcalresource.cpp colordialog.cpp colorpopupmenu.cpp oclickablelabel.cpp oprocctrl.cpp oprocess.cpp
+HEADERS = ofontmenu.h ofileselector.h ofiledialog.h ofileview.h tododb.h todoevent.h todoresource.h todovcalresource.h xmltree.h colordialog.h colorpopupmenu.h oclickablelabel.h oprocctrl.h oprocess.h ohwinfo.h
+SOURCES = ofontmenu.cc ofileselector.cc ofiledialog.cc xmltree.cc tododb.cpp todoevent.cpp todovcalresource.cpp colordialog.cpp colorpopupmenu.cpp oclickablelabel.cpp oprocctrl.cpp oprocess.cpp ohwinfo.cpp
TARGET = opie
INCLUDEPATH += $(OPIEDIR)/include
diff --git a/libopie/ohwinfo.cpp b/libopie/ohwinfo.cpp
new file mode 100644
index 0000000..ae07c6c
--- a/dev/null
+++ b/libopie/ohwinfo.cpp
@@ -0,0 +1,84 @@
+#include <qfile.h>
+#include <qtextstream.h>
+
+#include "ohwinfo.h"
+
+
+struct OHwInfoData {
+ QString m_vendorstr;
+ OHwVendor m_vendor;
+
+ QString m_modelstr;
+ OHwModel m_model;
+};
+
+
+OHwInfo *OHwInfo::inst ( )
+{
+ static OHwInfo *inf = 0;
+
+ if ( !inf ) {
+ inf = new OHwInfo ( );
+ }
+ return inf;
+}
+
+OHwInfo::OHwInfo ( )
+{
+ m_data = new OHwInfoData ( );
+
+ QFile f ( "/proc/hal/model" );
+
+ if ( f. open ( IO_ReadOnly )) {
+ QTextStream ts ( &f );
+ m_data-> m_modelstr = ts. readLine ( );
+
+ if ( m_data-> m_modelstr == "H3100" )
+ m_data-> m_model = OMODEL_iPAQ_H31xx;
+ else if ( m_data-> m_modelstr == "H3600" )
+ m_data-> m_model = OMODEL_iPAQ_H36xx;
+ else if ( m_data-> m_modelstr == "H3700" )
+ m_data-> m_model = OMODEL_iPAQ_H37xx;
+ else if ( m_data-> m_modelstr == "H3800" )
+ m_data-> m_model = OMODEL_iPAQ_H38xx;
+ else
+ m_data-> m_model = OMODEL_Unknown;
+
+ m_data-> m_vendorstr = "HP";
+ m_data-> m_vendor = OVENDOR_HP;
+
+ f. close ( );
+ }
+ else {
+ m_data-> m_modelstr = "Unknown";
+ m_data-> m_model = OMODEL_Unknown;
+ m_data-> m_vendorstr = "Unkown";
+ m_data-> m_vendor = OVENDOR_Unknown;
+ }
+}
+
+OHwInfo::~OHwInfo ( )
+{
+ delete m_data;
+}
+
+QString OHwInfo::vendorString ( )
+{
+ return m_data-> m_vendorstr;
+}
+
+OHwVendor OHwInfo::vendor ( )
+{
+ return m_data-> m_vendor;
+}
+
+QString OHwInfo::modelString ( )
+{
+ return m_data-> m_modelstr;
+}
+
+OHwModel OHwInfo::model ( )
+{
+ return m_data-> m_model;
+}
+
diff --git a/libopie/ohwinfo.h b/libopie/ohwinfo.h
new file mode 100644
index 0000000..e2106f3
--- a/dev/null
+++ b/libopie/ohwinfo.h
@@ -0,0 +1,48 @@
+#ifndef _LIBOPIE_OHWINFO_H_
+#define _LIBOPIE_OHWINFO_H_
+
+#include <qstring.h>
+
+enum OHwModel {
+ OMODEL_Unknown,
+
+ OMODEL_iPAQ_H31xx,
+ OMODEL_iPAQ_H36xx,
+ OMODEL_iPAQ_H37xx,
+ OMODEL_iPAQ_H38xx,
+
+ OMODEL_Zaurus_SL5000
+};
+
+enum OHwVendor {
+ OVENDOR_Unknown,
+
+ OVENDOR_HP,
+ OVENDOR_Sharp,
+};
+
+class OHwInfoData;
+
+
+class OHwInfo
+{
+public:
+ static OHwInfo *inst ( );
+
+ QString modelString ( );
+ OHwModel model ( );
+
+ QString vendorString ( );
+ OHwVendor vendor ( );
+
+ virtual ~OHwInfo ( );
+
+private:
+ OHwInfo ( );
+ OHwInfo ( const OHwInfo & );
+
+ OHwInfoData *m_data;
+};
+
+#endif
+