summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/device/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index ee66d95..62a2e03 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -41,48 +41,71 @@ _;:, .> :=|. This program is free software; you can
41#include <qwindowsystem_qws.h> 41#include <qwindowsystem_qws.h>
42 42
43/* OPIE */ 43/* OPIE */
44#include <qpe/config.h> 44#include <qpe/config.h>
45#include <qpe/resource.h> 45#include <qpe/resource.h>
46#include <qpe/sound.h> 46#include <qpe/sound.h>
47#include <qpe/qcopenvelope_qws.h> 47#include <qpe/qcopenvelope_qws.h>
48 48
49/* STD */ 49/* STD */
50#include <fcntl.h> 50#include <fcntl.h>
51#include <math.h> 51#include <math.h>
52#include <stdlib.h> 52#include <stdlib.h>
53#include <signal.h> 53#include <signal.h>
54#include <sys/ioctl.h> 54#include <sys/ioctl.h>
55#include <sys/time.h> 55#include <sys/time.h>
56#include <unistd.h> 56#include <unistd.h>
57#ifndef QT_NO_SOUND 57#ifndef QT_NO_SOUND
58#include <linux/soundcard.h> 58#include <linux/soundcard.h>
59#endif 59#endif
60 60
61const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 61const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
62 62
63using namespace Opie::Core; 63using namespace Opie::Core;
64 64
65struct default_button default_buttons [] = {
66 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
67 "devicebuttons/z_calendar",
68 "datebook", "nextView()",
69 "today", "raise()" },
70 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
71 "devicebuttons/z_contact",
72 "addressbook", "raise()",
73 "addressbook", "beamBusinessCard()" },
74 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
75 "devicebuttons/z_home",
76 "QPE/Launcher", "home()",
77 "buttonsettings", "raise()" },
78 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
79 "devicebuttons/z_menu",
80 "QPE/TaskBar", "toggleMenu()",
81 "QPE/TaskBar", "toggleStartMenu()" },
82 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
83 "devicebuttons/z_mail",
84 "opiemail", "raise()",
85 "opiemail", "newMail()" },
86};
87
65ODevice *ODevice::inst() 88ODevice *ODevice::inst()
66{ 89{
67 static ODevice *dev = 0; 90 static ODevice *dev = 0;
68 91
69 // rewrite this to only use /proc/cpuinfo or so 92 // rewrite this to only use /proc/cpuinfo or so
70 93
71 if ( !dev ) 94 if ( !dev )
72 { 95 {
73 QFile f( PATH_PROC_CPUINFO ); 96 QFile f( PATH_PROC_CPUINFO );
74 if ( f.open( IO_ReadOnly ) ) 97 if ( f.open( IO_ReadOnly ) )
75 { 98 {
76 QTextStream s( &f ); 99 QTextStream s( &f );
77 while ( !s.atEnd() ) 100 while ( !s.atEnd() )
78 { 101 {
79 QString line; 102 QString line;
80 line = s.readLine(); 103 line = s.readLine();
81 if ( line.startsWith( "Hardware" ) ) 104 if ( line.startsWith( "Hardware" ) )
82 { 105 {
83 qDebug( "ODevice() - found '%s'", (const char*) line ); 106 qDebug( "ODevice() - found '%s'", (const char*) line );
84 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 107 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
85 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 108 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
86 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 109 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
87 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 110 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
88 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 111 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
@@ -120,48 +143,58 @@ ODevice::ODevice()
120 d->m_cpu_frequencies = new QStrList; 143 d->m_cpu_frequencies = new QStrList;
121} 144}
122 145
123void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 146void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
124{ 147{
125 if ( msg == "deviceButtonMappingChanged()" ) { 148 if ( msg == "deviceButtonMappingChanged()" ) {
126 reloadButtonMapping(); 149 reloadButtonMapping();
127 } 150 }
128} 151}
129 152
130void ODevice::init() 153void ODevice::init()
131{ 154{
132} 155}
133 156
134/** 157/**
135* This method initialises the button mapping 158* This method initialises the button mapping
136*/ 159*/
137void ODevice::initButtons() 160void ODevice::initButtons()
138{ 161{
139 if ( d->m_buttons ) 162 if ( d->m_buttons )
140 return; 163 return;
141 164
142 qDebug ( "init Buttons" ); 165 qDebug ( "init Buttons" );
143 d->m_buttons = new QValueList <ODeviceButton>; 166 d->m_buttons = new QValueList <ODeviceButton>;
167 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
168 default_button *db = default_buttons + i;
169 ODeviceButton b;
170 b. setKeycode ( db->code );
171 b. setUserText ( QObject::tr ( "Button", db->utext ));
172 b. setPixmap ( Resource::loadPixmap ( db->pix ));
173 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
174 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
175 d->m_buttons->append ( b );
176 }
144 177
145 reloadButtonMapping(); 178 reloadButtonMapping();
146 179
147 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 180 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
148 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 181 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
149} 182}
150 183
151ODevice::~ODevice() 184ODevice::~ODevice()
152{ 185{
153// we leak m_devicebuttons and m_cpu_frequency 186// we leak m_devicebuttons and m_cpu_frequency
154// but it's a singleton and it is not so importantant 187// but it's a singleton and it is not so importantant
155// -zecke 188// -zecke
156 delete d; 189 delete d;
157} 190}
158 191
159bool ODevice::setSoftSuspend ( bool /*soft*/ ) 192bool ODevice::setSoftSuspend ( bool /*soft*/ )
160{ 193{
161 return false; 194 return false;
162} 195}
163 196
164//#include <linux/apm_bios.h> 197//#include <linux/apm_bios.h>
165 198
166#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 199#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
167 200