Diffstat (limited to 'libopie2/opiecore/device/odevice.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 71 |
1 files changed, 35 insertions, 36 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index 0f88c3c..6c8432f 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp | |||
@@ -18,25 +18,30 @@ | |||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "odevice.h" | 30 | #include "odevice_ipaq.h" |
31 | #include "odevice_jornada.h" | ||
32 | #include "odevice_ramses.h" | ||
33 | #include "odevice_simpad.h" | ||
34 | #include "odevice_yopy.h" | ||
35 | #include "odevice_zaurus.h" | ||
31 | 36 | ||
32 | /* QT */ | 37 | /* QT */ |
33 | #include <qapplication.h> | 38 | #include <qapplication.h> |
34 | #include <qfile.h> | 39 | #include <qfile.h> |
35 | #include <qtextstream.h> | 40 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 41 | #include <qwindowsystem_qws.h> |
37 | 42 | ||
38 | /* OPIE */ | 43 | /* OPIE */ |
39 | #include <qpe/config.h> | 44 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | 45 | #include <qpe/resource.h> |
41 | #include <qpe/sound.h> | 46 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 47 | #include <qpe/qcopenvelope_qws.h> |
@@ -44,70 +49,64 @@ | |||
44 | /* STD */ | 49 | /* STD */ |
45 | #include <fcntl.h> | 50 | #include <fcntl.h> |
46 | #include <math.h> | 51 | #include <math.h> |
47 | #include <stdlib.h> | 52 | #include <stdlib.h> |
48 | #include <signal.h> | 53 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 54 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 55 | #include <sys/time.h> |
51 | #include <unistd.h> | 56 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 57 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 58 | #include <linux/soundcard.h> |
54 | #endif | 59 | #endif |
55 | 60 | ||
56 | #ifndef ARRAY_SIZE | 61 | const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; |
57 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) | ||
58 | #endif | ||
59 | |||
60 | // _IO and friends are only defined in kernel headers ... | ||
61 | |||
62 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | ||
63 | |||
64 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | ||
65 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | ||
66 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | ||
67 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | ||
68 | 62 | ||
69 | using namespace Opie; | 63 | using namespace Opie; |
70 | 64 | ||
71 | class iPAQ; | ||
72 | class Zaurus; | ||
73 | class SIMpad; | ||
74 | class Ramses; | ||
75 | class Jornada; | ||
76 | |||
77 | ODevice *ODevice::inst() | 65 | ODevice *ODevice::inst() |
78 | { | 66 | { |
79 | static ODevice *dev = 0; | 67 | static ODevice *dev = 0; |
80 | 68 | ||
81 | // rewrite this to only use /proc/devinfo or so | 69 | // rewrite this to only use /proc/cpuinfo or so |
82 | 70 | ||
83 | /* | 71 | if ( !dev ) |
84 | if ( !dev ) { | 72 | { |
85 | if ( QFile::exists ( "/proc/hal/model" )) | 73 | QFile f( PATH_PROC_CPUINFO ); |
86 | dev = new iPAQ(); | 74 | if ( f.open( IO_ReadOnly ) ) |
87 | else if ( Zaurus::isZaurus() ) | 75 | { |
88 | dev = new Zaurus(); | 76 | QTextStream s( &f ); |
89 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) | 77 | while ( !s.atEnd() ) |
90 | dev = new SIMpad(); | 78 | { |
91 | else if ( QFile::exists ( "/proc/sys/board/name" )) | 79 | QString line; |
92 | dev = new Ramses(); | 80 | line = s.readLine(); |
93 | else if ( Yopy::isYopy() ) | 81 | if ( line.startsWith( "Hardware" ) ) |
94 | dev = new Yopy(); | 82 | { |
95 | else if ( Jornada::isJornada() ) | 83 | qDebug( "ODevice() - found '%s'", (const char*) line ); |
96 | dev = new Jornada(); | 84 | if ( line.contains( "sharp", false ) ) dev = new Zaurus(); |
85 | else if ( line.contains( "ipaq", false ) ) dev = new iPAQ(); | ||
86 | else if ( line.contains( "simpad", false ) ) dev = new SIMpad(); | ||
87 | else if ( line.contains( "jornada", false ) ) dev = new Jornada(); | ||
88 | else if ( line.contains( "ramses", false ) ) dev = new Ramses(); | ||
89 | else qWarning( "ODevice() - unknown hardware - using default." ); | ||
90 | break; | ||
91 | } | ||
92 | } | ||
93 | } | ||
97 | else | 94 | else |
98 | dev = new ODevice(); | 95 | { |
96 | qWarning( "ODevice() - can't open '%s' - unknown hardware - using default." ); | ||
97 | } | ||
98 | if ( !dev ) dev = new ODevice(); | ||
99 | dev->init(); | 99 | dev->init(); |
100 | } | 100 | } |
101 | */ | ||
102 | return dev; | 101 | return dev; |
103 | } | 102 | } |
104 | 103 | ||
105 | ODevice::ODevice() | 104 | ODevice::ODevice() |
106 | { | 105 | { |
107 | d = new ODeviceData; | 106 | d = new ODeviceData; |
108 | 107 | ||
109 | d->m_modelstr = "Unknown"; | 108 | d->m_modelstr = "Unknown"; |
110 | d->m_model = Model_Unknown; | 109 | d->m_model = Model_Unknown; |
111 | d->m_vendorstr = "Unknown"; | 110 | d->m_vendorstr = "Unknown"; |
112 | d->m_vendor = Vendor_Unknown; | 111 | d->m_vendor = Vendor_Unknown; |
113 | d->m_systemstr = "Unknown"; | 112 | d->m_systemstr = "Unknown"; |