-rw-r--r-- | libopie/libopie.pro | 4 | ||||
-rw-r--r-- | libopie/ohwinfo.cpp | 84 | ||||
-rw-r--r-- | libopie/ohwinfo.h | 48 |
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,7 +1,7 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qte warn_on release | 2 | CONFIG += qte warn_on release |
3 | 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 | 3 | 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 |
4 | 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 | 4 | 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 |
5 | TARGET = opie | 5 | TARGET = opie |
6 | INCLUDEPATH += $(OPIEDIR)/include | 6 | INCLUDEPATH += $(OPIEDIR)/include |
7 | DESTDIR = $(QTDIR)/lib$(PROJMAK) | 7 | DESTDIR = $(QTDIR)/lib$(PROJMAK) |
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 @@ | |||
1 | #include <qfile.h> | ||
2 | #include <qtextstream.h> | ||
3 | |||
4 | #include "ohwinfo.h" | ||
5 | |||
6 | |||
7 | struct OHwInfoData { | ||
8 | QString m_vendorstr; | ||
9 | OHwVendor m_vendor; | ||
10 | |||
11 | QString m_modelstr; | ||
12 | OHwModel m_model; | ||
13 | }; | ||
14 | |||
15 | |||
16 | OHwInfo *OHwInfo::inst ( ) | ||
17 | { | ||
18 | static OHwInfo *inf = 0; | ||
19 | |||
20 | if ( !inf ) { | ||
21 | inf = new OHwInfo ( ); | ||
22 | } | ||
23 | return inf; | ||
24 | } | ||
25 | |||
26 | OHwInfo::OHwInfo ( ) | ||
27 | { | ||
28 | m_data = new OHwInfoData ( ); | ||
29 | |||
30 | QFile f ( "/proc/hal/model" ); | ||
31 | |||
32 | if ( f. open ( IO_ReadOnly )) { | ||
33 | QTextStream ts ( &f ); | ||
34 | m_data-> m_modelstr = ts. readLine ( ); | ||
35 | |||
36 | if ( m_data-> m_modelstr == "H3100" ) | ||
37 | m_data-> m_model = OMODEL_iPAQ_H31xx; | ||
38 | else if ( m_data-> m_modelstr == "H3600" ) | ||
39 | m_data-> m_model = OMODEL_iPAQ_H36xx; | ||
40 | else if ( m_data-> m_modelstr == "H3700" ) | ||
41 | m_data-> m_model = OMODEL_iPAQ_H37xx; | ||
42 | else if ( m_data-> m_modelstr == "H3800" ) | ||
43 | m_data-> m_model = OMODEL_iPAQ_H38xx; | ||
44 | else | ||
45 | m_data-> m_model = OMODEL_Unknown; | ||
46 | |||
47 | m_data-> m_vendorstr = "HP"; | ||
48 | m_data-> m_vendor = OVENDOR_HP; | ||
49 | |||
50 | f. close ( ); | ||
51 | } | ||
52 | else { | ||
53 | m_data-> m_modelstr = "Unknown"; | ||
54 | m_data-> m_model = OMODEL_Unknown; | ||
55 | m_data-> m_vendorstr = "Unkown"; | ||
56 | m_data-> m_vendor = OVENDOR_Unknown; | ||
57 | } | ||
58 | } | ||
59 | |||
60 | OHwInfo::~OHwInfo ( ) | ||
61 | { | ||
62 | delete m_data; | ||
63 | } | ||
64 | |||
65 | QString OHwInfo::vendorString ( ) | ||
66 | { | ||
67 | return m_data-> m_vendorstr; | ||
68 | } | ||
69 | |||
70 | OHwVendor OHwInfo::vendor ( ) | ||
71 | { | ||
72 | return m_data-> m_vendor; | ||
73 | } | ||
74 | |||
75 | QString OHwInfo::modelString ( ) | ||
76 | { | ||
77 | return m_data-> m_modelstr; | ||
78 | } | ||
79 | |||
80 | OHwModel OHwInfo::model ( ) | ||
81 | { | ||
82 | return m_data-> m_model; | ||
83 | } | ||
84 | |||
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 @@ | |||
1 | #ifndef _LIBOPIE_OHWINFO_H_ | ||
2 | #define _LIBOPIE_OHWINFO_H_ | ||
3 | |||
4 | #include <qstring.h> | ||
5 | |||
6 | enum OHwModel { | ||
7 | OMODEL_Unknown, | ||
8 | |||
9 | OMODEL_iPAQ_H31xx, | ||
10 | OMODEL_iPAQ_H36xx, | ||
11 | OMODEL_iPAQ_H37xx, | ||
12 | OMODEL_iPAQ_H38xx, | ||
13 | |||
14 | OMODEL_Zaurus_SL5000 | ||
15 | }; | ||
16 | |||
17 | enum OHwVendor { | ||
18 | OVENDOR_Unknown, | ||
19 | |||
20 | OVENDOR_HP, | ||
21 | OVENDOR_Sharp, | ||
22 | }; | ||
23 | |||
24 | class OHwInfoData; | ||
25 | |||
26 | |||
27 | class OHwInfo | ||
28 | { | ||
29 | public: | ||
30 | static OHwInfo *inst ( ); | ||
31 | |||
32 | QString modelString ( ); | ||
33 | OHwModel model ( ); | ||
34 | |||
35 | QString vendorString ( ); | ||
36 | OHwVendor vendor ( ); | ||
37 | |||
38 | virtual ~OHwInfo ( ); | ||
39 | |||
40 | private: | ||
41 | OHwInfo ( ); | ||
42 | OHwInfo ( const OHwInfo & ); | ||
43 | |||
44 | OHwInfoData *m_data; | ||
45 | }; | ||
46 | |||
47 | #endif | ||
48 | |||