summaryrefslogtreecommitdiff
authoreilers <eilers>2004-08-29 12:42:03 (UTC)
committer eilers <eilers>2004-08-29 12:42:03 (UTC)
commitdd159675e6e3c361bc20eaa6994265e73b6599ef (patch) (unidiff)
tree70cf91b669307ae39e020ce4257b60b2de9acd42
parent496157cb35b8f90e73770fc43c9a63534baebf33 (diff)
downloadopie-dd159675e6e3c361bc20eaa6994265e73b6599ef.zip
opie-dd159675e6e3c361bc20eaa6994265e73b6599ef.tar.gz
opie-dd159675e6e3c361bc20eaa6994265e73b6599ef.tar.bz2
Minor but important changes in API. Improved SQL performance: contactsbackend now
supports look-ahead caching to speed up access. Fixed and improved look-ahead cache in todo-backend. Datebook backend will follow, soon !
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp4
-rw-r--r--libopie2/opiedb/osqlresult.cpp8
-rw-r--r--libopie2/opiedb/osqlresult.h4
-rw-r--r--libopie2/opiepim/TODO1
4 files changed, 11 insertions, 6 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 26c6dca..129215b 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,785 +1,789 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
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_ipaq.h" 30#include "odevice_ipaq.h"
31#include "odevice_jornada.h" 31#include "odevice_jornada.h"
32#include "odevice_ramses.h" 32#include "odevice_ramses.h"
33#include "odevice_simpad.h" 33#include "odevice_simpad.h"
34#include "odevice_yopy.h" 34#include "odevice_yopy.h"
35#include "odevice_zaurus.h" 35#include "odevice_zaurus.h"
36 36
37/* QT */ 37/* QT */
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
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#include <qpe/sound.h> 48#include <qpe/sound.h>
49#include <opie2/okeyfilter.h> 49#include <opie2/okeyfilter.h>
50 50
51/* STD */ 51/* STD */
52#include <fcntl.h> 52#include <fcntl.h>
53#include <math.h> 53#include <math.h>
54#include <stdlib.h> 54#include <stdlib.h>
55#include <signal.h> 55#include <signal.h>
56#include <sys/ioctl.h> 56#include <sys/ioctl.h>
57#include <sys/time.h> 57#include <sys/time.h>
58#include <unistd.h> 58#include <unistd.h>
59#ifndef QT_NO_SOUND 59#ifndef QT_NO_SOUND
60#include <linux/soundcard.h> 60#include <linux/soundcard.h>
61#endif 61#endif
62 62
63namespace Opie { 63namespace Opie {
64namespace Core { 64namespace Core {
65 65
66static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 66static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
67 67
68 68
69/* STATIC and common implementation */ 69/* STATIC and common implementation */
70/* EXPORT */ ODistribution distributions[] = { 70/* EXPORT */ ODistribution distributions[] = {
71 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, 71 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" },
72 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, 72 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" },
73 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, 73 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" },
74 { System_Unknown, "Linux", "/etc/issue" }, 74 { System_Unknown, "Linux", "/etc/issue" },
75}; 75};
76 76
77 77
78/* EXPORT */ bool isQWS(){ 78/* EXPORT */ bool isQWS(){
79 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; 79 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
80} 80}
81 81
82/* EXPORT */ QCString makeChannel ( const char *str ){ 82/* EXPORT */ QCString makeChannel ( const char *str ){
83 if ( str && !::strchr ( str, '/' )) 83 if ( str && !::strchr ( str, '/' ))
84 return QCString ( "QPE/Application/" ) + str; 84 return QCString ( "QPE/Application/" ) + str;
85 else 85 else
86 return str; 86 return str;
87} 87}
88 88
89 89
90 90
91/* Now the default implementation of ODevice */ 91/* Now the default implementation of ODevice */
92 92
93struct default_button default_buttons [] = { 93struct default_button default_buttons [] = {
94 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 94 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
95 "devicebuttons/z_calendar", 95 "devicebuttons/z_calendar",
96 "datebook", "nextView()", 96 "datebook", "nextView()",
97 "today", "raise()" }, 97 "today", "raise()" },
98 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 98 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
99 "devicebuttons/z_contact", 99 "devicebuttons/z_contact",
100 "addressbook", "raise()", 100 "addressbook", "raise()",
101 "addressbook", "beamBusinessCard()" }, 101 "addressbook", "beamBusinessCard()" },
102 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 102 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
103 "devicebuttons/z_home", 103 "devicebuttons/z_home",
104 "QPE/Launcher", "home()", 104 "QPE/Launcher", "home()",
105 "buttonsettings", "raise()" }, 105 "buttonsettings", "raise()" },
106 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 106 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
107 "devicebuttons/z_menu", 107 "devicebuttons/z_menu",
108 "QPE/TaskBar", "toggleMenu()", 108 "QPE/TaskBar", "toggleMenu()",
109 "QPE/TaskBar", "toggleStartMenu()" }, 109 "QPE/TaskBar", "toggleStartMenu()" },
110 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 110 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
111 "devicebuttons/z_mail", 111 "devicebuttons/z_mail",
112 "opiemail", "raise()", 112 "opiemail", "raise()",
113 "opiemail", "newMail()" }, 113 "opiemail", "newMail()" },
114}; 114};
115 115
116ODevice *ODevice::inst() 116ODevice *ODevice::inst()
117{ 117{
118 static ODevice *dev = 0; 118 static ODevice *dev = 0;
119 119
120 // rewrite this to only use /proc/cpuinfo or so 120 // rewrite this to only use /proc/cpuinfo or so
121 QString cpu_info; 121 QString cpu_info;
122 122
123 if ( !dev ) 123 if ( !dev )
124 { 124 {
125 QFile f( PATH_PROC_CPUINFO ); 125 QFile f( PATH_PROC_CPUINFO );
126 if ( f.open( IO_ReadOnly ) ) 126 if ( f.open( IO_ReadOnly ) )
127 { 127 {
128 QTextStream s( &f ); 128 QTextStream s( &f );
129 while ( !s.atEnd() ) 129 while ( !s.atEnd() )
130 { 130 {
131 QString line; 131 QString line;
132 line = s.readLine(); 132 line = s.readLine();
133 if ( line.startsWith( "Hardware" ) ) 133 if ( line.startsWith( "Hardware" ) )
134 { 134 {
135 qDebug( "ODevice() - found '%s'", (const char*) line ); 135 qDebug( "ODevice() - found '%s'", (const char*) line );
136 cpu_info = line; 136 cpu_info = line;
137 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 137 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
138 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 138 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
139 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 139 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
140 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 140 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
141 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 141 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
142 else qWarning( "ODevice() - unknown hardware - using default." ); 142 else qWarning( "ODevice() - unknown hardware - using default." );
143 break; 143 break;
144 } 144 }
145 } 145 }
146 } 146 }
147 else 147 else
148 { 148 {
149 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); 149 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
150 } 150 }
151 if ( !dev ) dev = new ODevice(); 151 if ( !dev ) dev = new ODevice();
152 dev->init(cpu_info); 152 dev->init(cpu_info);
153 } 153 }
154 return dev; 154 return dev;
155} 155}
156 156
157ODevice::ODevice() 157ODevice::ODevice()
158{ 158{
159 d = new ODeviceData; 159 d = new ODeviceData;
160 160
161 d->m_modelstr = "Unknown"; 161 d->m_modelstr = "Unknown";
162 d->m_model = Model_Unknown; 162 d->m_model = Model_Unknown;
163 d->m_vendorstr = "Unknown"; 163 d->m_vendorstr = "Unknown";
164 d->m_vendor = Vendor_Unknown; 164 d->m_vendor = Vendor_Unknown;
165 d->m_systemstr = "Unknown"; 165 d->m_systemstr = "Unknown";
166 d->m_system = System_Unknown; 166 d->m_system = System_Unknown;
167 d->m_sysverstr = "0.0"; 167 d->m_sysverstr = "0.0";
168 d->m_rotation = Rot0; 168 d->m_rotation = Rot0;
169 d->m_direction = CW; 169 d->m_direction = CW;
170 170
171 d->m_holdtime = 1000; // 1000ms 171 d->m_holdtime = 1000; // 1000ms
172 d->m_buttons = 0; 172 d->m_buttons = 0;
173 d->m_cpu_frequencies = new QStrList; 173 d->m_cpu_frequencies = new QStrList;
174 174
175 175
176 /* mixer */ 176 /* mixer */
177 d->m_sound = d->m_vol = d->m_mixer = -1; 177 d->m_sound = d->m_vol = d->m_mixer = -1;
178 178
179 // New distribution detection code first checks for legacy distributions, 179 // New distribution detection code first checks for legacy distributions,
180 // identified by /etc/familiar-version or /etc/oz_version. 180 // identified by /etc/familiar-version or /etc/oz_version.
181 // Then check for OpenEmbedded and lastly, read /etc/issue 181 // Then check for OpenEmbedded and lastly, read /etc/issue
182 182
183 for ( unsigned int i = 0; i < sizeof distributions; ++i ) 183 for ( unsigned int i = 0; i < sizeof distributions; ++i )
184 { 184 {
185 if ( QFile::exists( distributions[i].sysvfile ) ) 185 if ( QFile::exists( distributions[i].sysvfile ) )
186 { 186 {
187 d->m_systemstr = distributions[i].sysstr; 187 d->m_systemstr = distributions[i].sysstr;
188 d->m_system = distributions[i].system; 188 d->m_system = distributions[i].system;
189 d->m_sysverstr = "<Unknown>"; 189 d->m_sysverstr = "<Unknown>";
190 QFile f( distributions[i].sysvfile ); 190 QFile f( distributions[i].sysvfile );
191 if ( f.open( IO_ReadOnly ) ) 191 if ( f.open( IO_ReadOnly ) )
192 { 192 {
193 QTextStream ts( &f ); 193 QTextStream ts( &f );
194 d->m_sysverstr = ts.readLine(); 194 d->m_sysverstr = ts.readLine();
195 } 195 }
196 break; 196 break;
197 } 197 }
198 } 198 }
199} 199}
200 200
201void ODevice::systemMessage( const QCString &msg, const QByteArray & ) 201void ODevice::systemMessage( const QCString &msg, const QByteArray & )
202{ 202{
203 if ( msg == "deviceButtonMappingChanged()" ) { 203 if ( msg == "deviceButtonMappingChanged()" ) {
204 reloadButtonMapping(); 204 reloadButtonMapping();
205 } 205 }
206} 206}
207 207
208void ODevice::init(const QString&) 208void ODevice::init(const QString&)
209{ 209{
210} 210}
211 211
212/** 212/**
213* This method initialises the button mapping 213* This method initialises the button mapping
214*/ 214*/
215void ODevice::initButtons() 215void ODevice::initButtons()
216{ 216{
217 if ( d->m_buttons ) 217 if ( d->m_buttons )
218 return; 218 return;
219 219
220 qDebug ( "init Buttons" ); 220 qDebug ( "init Buttons" );
221 d->m_buttons = new QValueList <ODeviceButton>; 221 d->m_buttons = new QValueList <ODeviceButton>;
222 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { 222 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
223 default_button *db = default_buttons + i; 223 default_button *db = default_buttons + i;
224 ODeviceButton b; 224 ODeviceButton b;
225 b. setKeycode ( db->code ); 225 b. setKeycode ( db->code );
226 b. setUserText ( QObject::tr ( "Button", db->utext )); 226 b. setUserText ( QObject::tr ( "Button", db->utext ));
227 b. setPixmap ( Resource::loadPixmap ( db->pix )); 227 b. setPixmap ( Resource::loadPixmap ( db->pix ));
228 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); 228 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
229 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); 229 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
230 d->m_buttons->append ( b ); 230 d->m_buttons->append ( b );
231 } 231 }
232 232
233 reloadButtonMapping(); 233 reloadButtonMapping();
234 234
235 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 235 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
236 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 236 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
237} 237}
238 238
239ODevice::~ODevice() 239ODevice::~ODevice()
240{ 240{
241// we leak m_devicebuttons and m_cpu_frequency 241// we leak m_devicebuttons and m_cpu_frequency
242// but it's a singleton and it is not so importantant 242// but it's a singleton and it is not so importantant
243// -zecke 243// -zecke
244 delete d; 244 delete d;
245} 245}
246 246
247bool ODevice::setSoftSuspend ( bool /*soft*/ ) 247bool ODevice::setSoftSuspend ( bool /*soft*/ )
248{ 248{
249 return false; 249 return false;
250} 250}
251 251
252//#include <linux/apm_bios.h> 252//#include <linux/apm_bios.h>
253 253
254#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 254#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
255 255
256/** 256/**
257* This method will try to suspend the device 257* This method will try to suspend the device
258* It only works if the user is the QWS Server and the apm application 258* It only works if the user is the QWS Server and the apm application
259* is installed. 259* is installed.
260* It tries to suspend and then waits some time cause some distributions 260* It tries to suspend and then waits some time cause some distributions
261* do have asynchronus apm implementations. 261* do have asynchronus apm implementations.
262* This method will either fail and return false or it'll suspend the 262* This method will either fail and return false or it'll suspend the
263* device and return once the device got woken up 263* device and return once the device got woken up
264* 264*
265* @return if the device got suspended 265* @return if the device got suspended
266*/ 266*/
267bool ODevice::suspend() 267bool ODevice::suspend()
268{ 268{
269 qDebug("ODevice::suspend"); 269 qDebug("ODevice::suspend");
270 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 270 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
271 return false; 271 return false;
272 272
273 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 273 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
274 return false; 274 return false;
275 275
276 bool res = false; 276 bool res = false;
277 ODevice::sendSuspendmsg(); 277 ODevice::sendSuspendmsg();
278 278
279 struct timeval tvs, tvn; 279 struct timeval tvs, tvn;
280 ::gettimeofday ( &tvs, 0 ); 280 ::gettimeofday ( &tvs, 0 );
281 281
282 ::sync(); // flush fs caches 282 ::sync(); // flush fs caches
283 res = ( ::system ( "apm --suspend" ) == 0 ); 283 res = ( ::system ( "apm --suspend" ) == 0 );
284 284
285 // This is needed because the iPAQ apm implementation is asynchronous and we 285 // This is needed because the iPAQ apm implementation is asynchronous and we
286 // can not be sure when exactly the device is really suspended 286 // can not be sure when exactly the device is really suspended
287 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 287 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
288 288
289 if ( res ) { 289 if ( res ) {
290 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 290 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
291 ::usleep ( 200 * 1000 ); 291 ::usleep ( 200 * 1000 );
292 ::gettimeofday ( &tvn, 0 ); 292 ::gettimeofday ( &tvn, 0 );
293 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 293 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
294 } 294 }
295 295
296 return res; 296 return res;
297} 297}
298 298
299//#include <linux/fb.h> better not rely on kernel headers in userspace ... 299//#include <linux/fb.h> better not rely on kernel headers in userspace ...
300 300
301#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 301#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
302 302
303/* VESA Blanking Levels */ 303/* VESA Blanking Levels */
304#define VESA_NO_BLANKING 0 304#define VESA_NO_BLANKING 0
305#define VESA_VSYNC_SUSPEND 1 305#define VESA_VSYNC_SUSPEND 1
306#define VESA_HSYNC_SUSPEND 2 306#define VESA_HSYNC_SUSPEND 2
307#define VESA_POWERDOWN 3 307#define VESA_POWERDOWN 3
308 308
309/** 309/**
310* This sets the display on or off 310* This sets the display on or off
311*/ 311*/
312bool ODevice::setDisplayStatus ( bool on ) 312bool ODevice::setDisplayStatus ( bool on )
313{ 313{
314 qDebug("ODevice::setDisplayStatus(%d)", on); 314 qDebug("ODevice::setDisplayStatus(%d)", on);
315 315
316 if ( d->m_model == Model_Unknown ) 316 if ( d->m_model == Model_Unknown )
317 return false; 317 return false;
318 318
319 bool res = false; 319 bool res = false;
320 int fd; 320 int fd;
321 321
322 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 322 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
323 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 323 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
324 ::close ( fd ); 324 ::close ( fd );
325 } 325 }
326 return res; 326 return res;
327} 327}
328 328
329/** 329/**
330* This sets the display brightness 330* This sets the display brightness
331* 331*
332* @param p The brightness to be set on a scale from 0 to 255 332* @param p The brightness to be set on a scale from 0 to 255
333* @return success or failure 333* @return success or failure
334*/ 334*/
335bool ODevice::setDisplayBrightness ( int p) 335bool ODevice::setDisplayBrightness ( int p)
336{ 336{
337 Q_UNUSED( p ) 337 Q_UNUSED( p )
338 return false; 338 return false;
339} 339}
340 340
341/** 341/**
342* @return returns the number of steppings on the brightness slider 342* @return returns the number of steppings on the brightness slider
343* in the Light-'n-Power settings. 343* in the Light-'n-Power settings.
344*/ 344*/
345int ODevice::displayBrightnessResolution() const 345int ODevice::displayBrightnessResolution() const
346{ 346{
347 return 16; 347 return 16;
348} 348}
349 349
350/** 350/**
351* This sets the display contrast 351* This sets the display contrast
352* @param p The contrast to be set on a scale from 0 to 255 352* @param p The contrast to be set on a scale from 0 to 255
353* @return success or failure 353* @return success or failure
354*/ 354*/
355bool ODevice::setDisplayContrast ( int p) 355bool ODevice::setDisplayContrast ( int p)
356{ 356{
357 Q_UNUSED( p ) 357 Q_UNUSED( p )
358 return false; 358 return false;
359} 359}
360 360
361/** 361/**
362* @return return the max value for the brightness settings slider 362* @return return the max value for the brightness settings slider
363* or 0 if the device doesn't support setting of a contrast 363* or 0 if the device doesn't support setting of a contrast
364*/ 364*/
365int ODevice::displayContrastResolution() const 365int ODevice::displayContrastResolution() const
366{ 366{
367 return 0; 367 return 0;
368} 368}
369 369
370/** 370/**
371* This returns the vendor as string 371* This returns the vendor as string
372* @return Vendor as QString 372* @return Vendor as QString
373*/ 373*/
374QString ODevice::vendorString() const 374QString ODevice::vendorString() const
375{ 375{
376 return d->m_vendorstr; 376 return d->m_vendorstr;
377} 377}
378 378
379/** 379/**
380* This returns the vendor as one of the values of OVendor 380* This returns the vendor as one of the values of OVendor
381* @return OVendor 381* @return OVendor
382*/ 382*/
383OVendor ODevice::vendor() const 383OVendor ODevice::vendor() const
384{ 384{
385 return d->m_vendor; 385 return d->m_vendor;
386} 386}
387 387
388/** 388/**
389* This returns the model as a string 389* This returns the model as a string
390* @return A string representing the model 390* @return A string representing the model
391*/ 391*/
392QString ODevice::modelString() const 392QString ODevice::modelString() const
393{ 393{
394 return d->m_modelstr; 394 return d->m_modelstr;
395} 395}
396 396
397/** 397/**
398* This does return the OModel used 398* This does return the OModel used
399*/ 399*/
400OModel ODevice::model() const 400OModel ODevice::model() const
401{ 401{
402 return d->m_model; 402 return d->m_model;
403} 403}
404 404
405/** 405/**
406* This does return the systen name 406* This does return the systen name
407*/ 407*/
408QString ODevice::systemString() const 408QString ODevice::systemString() const
409{ 409{
410 return d->m_systemstr; 410 return d->m_systemstr;
411} 411}
412 412
413/** 413/**
414* Return System as OSystem value 414* Return System as OSystem value
415*/ 415*/
416OSystem ODevice::system() const 416OSystem ODevice::system() const
417{ 417{
418 return d->m_system; 418 return d->m_system;
419} 419}
420 420
421/** 421/**
422* @return the version string of the base system 422* @return the version string of the base system
423*/ 423*/
424QString ODevice::systemVersionString() const 424QString ODevice::systemVersionString() const
425{ 425{
426 return d->m_sysverstr; 426 return d->m_sysverstr;
427} 427}
428 428
429/** 429/**
430* @return the current Transformation 430* @return the current Transformation
431*/ 431*/
432Transformation ODevice::rotation() const 432Transformation ODevice::rotation() const
433{ 433{
434 return d->m_rotation; 434 return d->m_rotation;
435} 435}
436 436
437/** 437/**
438* @return the current rotation direction 438* @return the current rotation direction
439*/ 439*/
440ODirection ODevice::direction() const 440ODirection ODevice::direction() const
441{ 441{
442 return d->m_direction; 442 return d->m_direction;
443} 443}
444 444
445/** 445/**
446* This plays an alarm sound 446* This plays an alarm sound
447*/ 447*/
448void ODevice::playAlarmSound() 448void ODevice::playAlarmSound()
449{ 449{
450#ifndef QT_NO_SOUND 450#ifndef QT_NO_SOUND
451 static Sound snd ( "alarm" ); 451 static Sound snd ( "alarm" );
452 452
453 if ( snd. isFinished()) 453 if ( snd. isFinished())
454 snd. play(); 454 snd. play();
455#endif 455#endif
456} 456}
457 457
458/** 458/**
459* This plays a key sound 459* This plays a key sound
460*/ 460*/
461void ODevice::playKeySound() 461void ODevice::playKeySound()
462{ 462{
463#ifndef QT_NO_SOUND 463#ifndef QT_NO_SOUND
464 static Sound snd ( "keysound" ); 464 static Sound snd ( "keysound" );
465 465
466 if ( snd. isFinished()) 466 if ( snd. isFinished())
467 snd. play(); 467 snd. play();
468#endif 468#endif
469} 469}
470 470
471/** 471/**
472* This plays a touch sound 472* This plays a touch sound
473*/ 473*/
474void ODevice::playTouchSound() 474void ODevice::playTouchSound()
475{ 475{
476#ifndef QT_NO_SOUND 476#ifndef QT_NO_SOUND
477 static Sound snd ( "touchsound" ); 477 static Sound snd ( "touchsound" );
478 478
479 if ( snd. isFinished()) 479 if ( snd. isFinished())
480 snd. play(); 480 snd. play();
481#endif 481#endif
482} 482}
483 483
484/** 484/**
485* This method will return a list of leds 485* This method will return a list of leds
486* available on this device 486* available on this device
487* @return a list of LEDs. 487* @return a list of LEDs.
488*/ 488*/
489QValueList <OLed> ODevice::ledList() const 489QValueList <OLed> ODevice::ledList() const
490{ 490{
491 return QValueList <OLed>(); 491 return QValueList <OLed>();
492} 492}
493 493
494/** 494/**
495* This does return the state of the LEDs 495* This does return the state of the LEDs
496*/ 496*/
497QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 497QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
498{ 498{
499 return QValueList <OLedState>(); 499 return QValueList <OLedState>();
500} 500}
501 501
502/** 502/**
503* @return the state for a given OLed 503* @return the state for a given OLed
504*/ 504*/
505OLedState ODevice::ledState ( OLed /*which*/ ) const 505OLedState ODevice::ledState ( OLed /*which*/ ) const
506{ 506{
507 return Led_Off; 507 return Led_Off;
508} 508}
509 509
510/** 510/**
511* Set the state for a LED 511* Set the state for a LED
512* @param which Which OLed to use 512* @param which Which OLed to use
513* @param st The state to set 513* @param st The state to set
514* @return success or failure 514* @return success or failure
515*/ 515*/
516bool ODevice::setLedState ( OLed which, OLedState st ) 516bool ODevice::setLedState ( OLed which, OLedState st )
517{ 517{
518 Q_UNUSED( which ) 518 Q_UNUSED( which )
519 Q_UNUSED( st ) 519 Q_UNUSED( st )
520 return false; 520 return false;
521} 521}
522 522
523/** 523/**
524* @return if the device has a light sensor 524* @return if the device has a light sensor
525*/ 525*/
526bool ODevice::hasLightSensor() const 526bool ODevice::hasLightSensor() const
527{ 527{
528 return false; 528 return false;
529} 529}
530 530
531/** 531/**
532* @return a value from the light sensor 532* @return a value from the light sensor
533*/ 533*/
534int ODevice::readLightSensor() 534int ODevice::readLightSensor()
535{ 535{
536 return -1; 536 return -1;
537} 537}
538 538
539/** 539/**
540* @return the light sensor resolution 540* @return the light sensor resolution
541*/ 541*/
542int ODevice::lightSensorResolution() const 542int ODevice::lightSensorResolution() const
543{ 543{
544 return 0; 544 return 0;
545} 545}
546 546
547/** 547/**
548* @return if the device has a hinge sensor 548* @return if the device has a hinge sensor
549*/ 549*/
550bool ODevice::hasHingeSensor() const 550bool ODevice::hasHingeSensor() const
551{ 551{
552 return false; 552 return false;
553} 553}
554 554
555/** 555/**
556* @return a value from the hinge sensor 556* @return a value from the hinge sensor
557*/ 557*/
558OHingeStatus ODevice::readHingeSensor() 558OHingeStatus ODevice::readHingeSensor()
559{ 559{
560 return CASE_UNKNOWN; 560 return CASE_UNKNOWN;
561} 561}
562 562
563/** 563/**
564* @return a list with CPU frequencies supported by the hardware 564* @return a list with CPU frequencies supported by the hardware
565*/ 565*/
566const QStrList &ODevice::allowedCpuFrequencies() const 566const QStrList &ODevice::allowedCpuFrequencies() const
567{ 567{
568 return *d->m_cpu_frequencies; 568 return *d->m_cpu_frequencies;
569} 569}
570 570
571 571
572/** 572/**
573* Set desired CPU frequency 573* Set desired CPU frequency
574* 574*
575* @param index index into d->m_cpu_frequencies of the frequency to be set 575* @param index index into d->m_cpu_frequencies of the frequency to be set
576*/ 576*/
577bool ODevice::setCurrentCpuFrequency(uint index) 577bool ODevice::setCurrentCpuFrequency(uint index)
578{ 578{
579 if (index >= d->m_cpu_frequencies->count()) 579 if (index >= d->m_cpu_frequencies->count())
580 return false; 580 return false;
581 581
582 char *freq = d->m_cpu_frequencies->at(index); 582 char *freq = d->m_cpu_frequencies->at(index);
583 qWarning("set freq to %s", freq); 583 qWarning("set freq to %s", freq);
584 584
585 int fd; 585 int fd;
586 586
587 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 587 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
588 char writeCommand[50]; 588 char writeCommand[50];
589 const int count = sprintf(writeCommand, "%s\n", freq); 589 const int count = sprintf(writeCommand, "%s\n", freq);
590 int res = (::write(fd, writeCommand, count) != -1); 590 int res = (::write(fd, writeCommand, count) != -1);
591 ::close(fd); 591 ::close(fd);
592 return res; 592 return res;
593 } 593 }
594 594
595 return false; 595 return false;
596} 596}
597 597
598 598
599/** 599/**
600* @return a list of hardware buttons 600* @return a list of hardware buttons
601*/ 601*/
602const QValueList <ODeviceButton> &ODevice::buttons() 602const QValueList <ODeviceButton> &ODevice::buttons()
603{ 603{
604 initButtons(); 604 initButtons();
605 605
606 return *d->m_buttons; 606 return *d->m_buttons;
607} 607}
608 608
609/** 609/**
610* @return The amount of time that would count as a hold 610* @return The amount of time that would count as a hold
611*/ 611*/
612uint ODevice::buttonHoldTime() const 612uint ODevice::buttonHoldTime() const
613{ 613{
614 return d->m_holdtime; 614 return d->m_holdtime;
615} 615}
616 616
617/** 617/**
618* This method return a ODeviceButton for a key code 618* This method return a ODeviceButton for a key code
619* or 0 if no special hardware button is available for the device 619* or 0 if no special hardware button is available for the device
620* 620*
621* @return The devicebutton or 0l 621* @return The devicebutton or 0l
622* @see ODeviceButton 622* @see ODeviceButton
623*/ 623*/
624const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 624const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
625{ 625{
626 initButtons(); 626 initButtons();
627 627
628 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { 628 for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) {
629 if ( (*it). keycode() == code ) 629 if ( (*it). keycode() == code )
630 return &(*it); 630 return &(*it);
631 } 631 }
632 return 0; 632 return 0;
633} 633}
634 634
635void ODevice::reloadButtonMapping() 635void ODevice::reloadButtonMapping()
636{ 636{
637 initButtons(); 637 initButtons();
638 638
639 Config cfg ( "ButtonSettings" ); 639 Config cfg ( "ButtonSettings" );
640 640
641 for ( uint i = 0; i < d->m_buttons->count(); i++ ) { 641 for ( uint i = 0; i < d->m_buttons->count(); i++ ) {
642 ODeviceButton &b = ( *d->m_buttons ) [i]; 642 ODeviceButton &b = ( *d->m_buttons ) [i];
643 QString group = "Button" + QString::number ( i ); 643 QString group = "Button" + QString::number ( i );
644 644
645 QCString pch, hch; 645 QCString pch, hch;
646 QCString pm, hm; 646 QCString pm, hm;
647 QByteArray pdata, hdata; 647 QByteArray pdata, hdata;
648 648
649 if ( cfg. hasGroup ( group )) { 649 if ( cfg. hasGroup ( group )) {
650 cfg. setGroup ( group ); 650 cfg. setGroup ( group );
651 pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); 651 pch = cfg. readEntry ( "PressedActionChannel" ). latin1();
652 pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); 652 pm = cfg. readEntry ( "PressedActionMessage" ). latin1();
653 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 653 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
654 654
655 hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); 655 hch = cfg. readEntry ( "HeldActionChannel" ). latin1();
656 hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); 656 hm = cfg. readEntry ( "HeldActionMessage" ). latin1();
657 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 657 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
658 } 658 }
659 659
660 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 660 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
661 661
662 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 662 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
663 } 663 }
664} 664}
665 665
666void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 666void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
667{ 667{
668 initButtons(); 668 initButtons();
669 669
670 QString mb_chan; 670 QString mb_chan;
671 671
672 if ( button >= (int) d->m_buttons->count()) 672 if ( button >= (int) d->m_buttons->count())
673 return; 673 return;
674 674
675 ODeviceButton &b = ( *d->m_buttons ) [button]; 675 ODeviceButton &b = ( *d->m_buttons ) [button];
676 b. setPressedAction ( action ); 676 b. setPressedAction ( action );
677 677
678 mb_chan=b. pressedAction(). channel(); 678 mb_chan=b. pressedAction(). channel();
679 679
680 Config buttonFile ( "ButtonSettings" ); 680 Config buttonFile ( "ButtonSettings" );
681 buttonFile. setGroup ( "Button" + QString::number ( button )); 681 buttonFile. setGroup ( "Button" + QString::number ( button ));
682 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 682 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
683 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); 683 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message());
684 684
685// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); 685// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
686 686
687 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 687 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
688} 688}
689 689
690void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 690void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
691{ 691{
692 initButtons(); 692 initButtons();
693 693
694 if ( button >= (int) d->m_buttons->count()) 694 if ( button >= (int) d->m_buttons->count())
695 return; 695 return;
696 696
697 ODeviceButton &b = ( *d->m_buttons ) [button]; 697 ODeviceButton &b = ( *d->m_buttons ) [button];
698 b. setHeldAction ( action ); 698 b. setHeldAction ( action );
699 699
700 Config buttonFile ( "ButtonSettings" ); 700 Config buttonFile ( "ButtonSettings" );
701 buttonFile. setGroup ( "Button" + QString::number ( button )); 701 buttonFile. setGroup ( "Button" + QString::number ( button ));
702 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); 702 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
703 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); 703 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
704 704
705// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); 705// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
706 706
707 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 707 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
708} 708}
709void ODevice::virtual_hook(int, void* ){ 709void ODevice::virtual_hook(int, void* ){
710 710
711} 711}
712 712
713/** 713/**
714 * Sends a QCOP message to channel QPE/System 714 * Sends a QCOP message to channel QPE/System
715 * with the message "aboutToSuspend()" if this 715 * with the message "aboutToSuspend()" if this
716 * is the windowing server 716 * is the windowing server
717 */ 717 */
718void ODevice::sendSuspendmsg() 718void ODevice::sendSuspendmsg()
719{ 719{
720 if ( isQWS() ) 720 if ( isQWS() )
721 return; 721 return;
722 722
723 QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); 723 QCopEnvelope ( "QPE/System", "aboutToSuspend()" );
724} 724}
725 725
726/** 726/**
727 * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters 727 * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters
728 * 728 *
729 * Prepend a QWSServer::KeyboardFilter to the List of Keyboard 729 * Prepend a QWSServer::KeyboardFilter to the List of Keyboard
730 * Filters. This function is the only way to prepend a KeyFilter. 730 * Filters. This function is the only way to prepend a KeyFilter.
731 * 731 *
732 * @param aFilter The KeyFilter to be prepended to the list of filters 732 * @param aFilter The KeyFilter to be prepended to the list of filters
733 * 733 *
734 * @see Opie::Core::OKeyFilter 734 * @see Opie::Core::OKeyFilter
735 * @see Opie::Core::OKeyFilter::inst() 735 * @see Opie::Core::OKeyFilter::inst()
736 */ 736 */
737void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) 737void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter)
738{ 738{
739 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); 739 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter);
740} 740}
741 741
742/** 742/**
743 * \brief Remove the QWSServer::KeyboardFilter in the param from the list 743 * \brief Remove the QWSServer::KeyboardFilter in the param from the list
744 * 744 *
745 * Remove the QWSServer::KeyboardFilter \par aFilter from the List 745 * Remove the QWSServer::KeyboardFilter \par aFilter from the List
746 * of Keyfilters. Call this when you delete the KeyFilter! 746 * of Keyfilters. Call this when you delete the KeyFilter!
747 * 747 *
748 * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter 748 * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter
749 * @see Opie::Core::ODevice::addPreHandler 749 * @see Opie::Core::ODevice::addPreHandler
750 */ 750 */
751void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) 751void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter)
752{ 752{
753 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); 753 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter);
754} 754}
755 755
756void ODevice::playingStopped() { 756void ODevice::playingStopped() {
757 const_cast<QObject*>(sender())->disconnect( this ); 757 const_cast<QObject*>(sender())->disconnect( this );
758#ifndef QT_NO_SOUND
758 if ( d->m_sound >= 0 ) { 759 if ( d->m_sound >= 0 ) {
759 ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); 760 ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol );
760 ::close ( d->m_sound ); 761 ::close ( d->m_sound );
761 } 762 }
763#endif
762} 764}
763 765
764void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { 766void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) {
767#ifndef QT_NO_SOUND
765 if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { 768 if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) {
766 if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { 769 if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) {
767 Config cfg ( "qpe" ); 770 Config cfg ( "qpe" );
768 cfg. setGroup ( "Volume" ); 771 cfg. setGroup ( "Volume" );
769 772
770 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 773 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
771 if ( volalarm < 0 ) 774 if ( volalarm < 0 )
772 volalarm = 0; 775 volalarm = 0;
773 else if ( volalarm > 100 ) 776 else if ( volalarm > 100 )
774 volalarm = 100; 777 volalarm = 100;
775 volalarm |= ( volalarm << 8 ); 778 volalarm |= ( volalarm << 8 );
776 779
777 if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 ) 780 if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 )
778 register_qpe_sound_finished(snd, this, SLOT(playingStopped())); 781 register_qpe_sound_finished(snd, this, SLOT(playingStopped()));
779 } 782 }
780 d->m_mixer = mixer; 783 d->m_mixer = mixer;
781 } 784 }
785#endif
782} 786}
783 787
784} 788}
785} 789}
diff --git a/libopie2/opiedb/osqlresult.cpp b/libopie2/opiedb/osqlresult.cpp
index bad7d8b..268ac8e 100644
--- a/libopie2/opiedb/osqlresult.cpp
+++ b/libopie2/opiedb/osqlresult.cpp
@@ -1,128 +1,128 @@
1 1
2#include "osqlresult.h" 2#include "osqlresult.h"
3 3
4using namespace Opie::DB; 4using namespace Opie::DB;
5 5
6OSQLResultItem::OSQLResultItem( const TableString& string, 6OSQLResultItem::OSQLResultItem( const TableString& string,
7 const TableInt& Int) 7 const TableInt& Int)
8 : m_string( string ), m_int( Int ) 8 : m_string( string ), m_int( Int )
9{ 9{
10 10
11} 11}
12OSQLResultItem::~OSQLResultItem() { 12OSQLResultItem::~OSQLResultItem() {
13} 13}
14OSQLResultItem::OSQLResultItem( const OSQLResultItem& item) { 14OSQLResultItem::OSQLResultItem( const OSQLResultItem& item) {
15 *this = item; 15 *this = item;
16} 16}
17OSQLResultItem &OSQLResultItem::operator=( const OSQLResultItem& other) { 17OSQLResultItem &OSQLResultItem::operator=( const OSQLResultItem& other) {
18 m_string = other.m_string; 18 m_string = other.m_string;
19 m_int = other.m_int; 19 m_int = other.m_int;
20 return *this; 20 return *this;
21} 21}
22OSQLResultItem::TableString OSQLResultItem::tableString()const{ 22OSQLResultItem::TableString OSQLResultItem::tableString()const{
23 return m_string; 23 return m_string;
24} 24}
25OSQLResultItem::TableInt OSQLResultItem::tableInt()const { 25OSQLResultItem::TableInt OSQLResultItem::tableInt()const {
26 return m_int; 26 return m_int;
27} 27}
28QString OSQLResultItem::data( const QString& columnName, bool *ok ) { 28QString OSQLResultItem::data( const QString& columnName, bool *ok ) const {
29 TableString::Iterator it = m_string.find( columnName ); 29 TableString::ConstIterator it = m_string.find( columnName );
30 30
31 /* if found */ 31 /* if found */
32 if ( it != m_string.end() ) { 32 if ( it != m_string.end() ) {
33 if ( ok ) *ok = true; 33 if ( ok ) *ok = true;
34 return it.data(); 34 return it.data();
35 }else{ 35 }else{
36 if ( ok ) *ok = false; 36 if ( ok ) *ok = false;
37 return QString::null; 37 return QString::null;
38 } 38 }
39 39
40} 40}
41QString OSQLResultItem::data( int column, bool *ok ) { 41QString OSQLResultItem::data( int column, bool *ok ) const {
42 TableInt::Iterator it = m_int.find( column ); 42 TableInt::ConstIterator it = m_int.find( column );
43 43
44 /* if found */ 44 /* if found */
45 if ( it != m_int.end() ) { 45 if ( it != m_int.end() ) {
46 if ( ok ) *ok = true; 46 if ( ok ) *ok = true;
47 return it.data(); 47 return it.data();
48 }else{ 48 }else{
49 if ( ok ) *ok = false; 49 if ( ok ) *ok = false;
50 return QString::null; 50 return QString::null;
51 } 51 }
52} 52}
53/* 53/*
54 * DateFormat is 'YYYY-MM-DD' 54 * DateFormat is 'YYYY-MM-DD'
55 */ 55 */
56QDate OSQLResultItem::dataToDate( const QString& column, bool *ok ) { 56QDate OSQLResultItem::dataToDate( const QString& column, bool *ok ) {
57 QDate date = QDate::currentDate(); 57 QDate date = QDate::currentDate();
58 QString str = data( column, ok ); 58 QString str = data( column, ok );
59 if (!str.isEmpty() ) { 59 if (!str.isEmpty() ) {
60 ;// convert 60 ;// convert
61 } 61 }
62 return date; 62 return date;
63} 63}
64QDate OSQLResultItem::dataToDate( int column, bool *ok ) { 64QDate OSQLResultItem::dataToDate( int column, bool *ok ) {
65 QDate date = QDate::currentDate(); 65 QDate date = QDate::currentDate();
66 QString str = data( column, ok ); 66 QString str = data( column, ok );
67 if (!str.isEmpty() ) { 67 if (!str.isEmpty() ) {
68 ;// convert 68 ;// convert
69 } 69 }
70 return date; 70 return date;
71 71
72} 72}
73QDateTime OSQLResultItem::dataToDateTime( const QString& column, bool *ok ) { 73QDateTime OSQLResultItem::dataToDateTime( const QString& column, bool *ok ) {
74 QDateTime time = QDateTime::currentDateTime(); 74 QDateTime time = QDateTime::currentDateTime();
75 return time; 75 return time;
76} 76}
77QDateTime OSQLResultItem::dataToDateTime( int column, bool *ok ) { 77QDateTime OSQLResultItem::dataToDateTime( int column, bool *ok ) {
78 QDateTime time = QDateTime::currentDateTime(); 78 QDateTime time = QDateTime::currentDateTime();
79 return time; 79 return time;
80} 80}
81 81
82OSQLResult::OSQLResult( enum State state, 82OSQLResult::OSQLResult( enum State state,
83 const OSQLResultItem::ValueList& list, 83 const OSQLResultItem::ValueList& list,
84 const OSQLError::ValueList& error ) 84 const OSQLError::ValueList& error )
85 : m_state( state ), m_list( list ), m_error( error ) 85 : m_state( state ), m_list( list ), m_error( error )
86{ 86{
87 87
88} 88}
89OSQLResult::~OSQLResult() { 89OSQLResult::~OSQLResult() {
90 90
91} 91}
92OSQLResult::State OSQLResult::state()const { 92OSQLResult::State OSQLResult::state()const {
93 return m_state; 93 return m_state;
94} 94}
95void OSQLResult::setState( OSQLResult::State state ) { 95void OSQLResult::setState( OSQLResult::State state ) {
96 m_state = state; 96 m_state = state;
97} 97}
98OSQLError::ValueList OSQLResult::errors()const { 98OSQLError::ValueList OSQLResult::errors()const {
99 return m_error; 99 return m_error;
100} 100}
101void OSQLResult::setErrors( const OSQLError::ValueList& err ) { 101void OSQLResult::setErrors( const OSQLError::ValueList& err ) {
102 m_error = err; 102 m_error = err;
103} 103}
104OSQLResultItem::ValueList OSQLResult::results()const { 104OSQLResultItem::ValueList OSQLResult::results()const {
105 return m_list; 105 return m_list;
106} 106}
107void OSQLResult::setResults( const OSQLResultItem::ValueList& result ) { 107void OSQLResult::setResults( const OSQLResultItem::ValueList& result ) {
108 m_list = result; 108 m_list = result;
109} 109}
110OSQLResultItem OSQLResult::first() { 110OSQLResultItem OSQLResult::first() {
111 it = m_list.begin(); 111 it = m_list.begin();
112 return (*it); 112 return (*it);
113} 113}
114OSQLResultItem OSQLResult::next(){ 114OSQLResultItem OSQLResult::next(){
115 ++it; 115 ++it;
116 return (*it); 116 return (*it);
117} 117}
118bool OSQLResult::atEnd(){ 118bool OSQLResult::atEnd(){
119 if ( it == m_list.end() ) 119 if ( it == m_list.end() )
120 return true; 120 return true;
121 121
122 return false; 122 return false;
123} 123}
124OSQLResultItem::ValueList::ConstIterator OSQLResult::iterator()const { 124OSQLResultItem::ValueList::ConstIterator OSQLResult::iterator()const {
125 OSQLResultItem::ValueList::ConstIterator it; 125 OSQLResultItem::ValueList::ConstIterator it;
126 it = m_list.begin(); 126 it = m_list.begin();
127 return it; 127 return it;
128} 128}
diff --git a/libopie2/opiedb/osqlresult.h b/libopie2/opiedb/osqlresult.h
index fc6f01a..92b65a0 100644
--- a/libopie2/opiedb/osqlresult.h
+++ b/libopie2/opiedb/osqlresult.h
@@ -1,120 +1,120 @@
1#ifndef OSQL_RESULT_H 1#ifndef OSQL_RESULT_H
2#define OSQL_RESULT_H 2#define OSQL_RESULT_H
3 3
4#include <qdatetime.h> 4#include <qdatetime.h>
5#include <qmap.h> 5#include <qmap.h>
6#include <qvaluelist.h> 6#include <qvaluelist.h>
7 7
8 8
9#include "osqlerror.h" 9#include "osqlerror.h"
10 10
11namespace Opie { 11namespace Opie {
12namespace DB { 12namespace DB {
13 13
14/** 14/**
15 * ResultItem represents one row of the resulting answer 15 * ResultItem represents one row of the resulting answer
16 */ 16 */
17class OSQLResultItem { 17class OSQLResultItem {
18public: 18public:
19 typedef QValueList<OSQLResultItem> ValueList; 19 typedef QValueList<OSQLResultItem> ValueList;
20 /** 20 /**
21 * TableString is used to establish the relations 21 * TableString is used to establish the relations
22 * between the column name and the real item 22 * between the column name and the real item
23 */ 23 */
24 typedef QMap<QString, QString> TableString; 24 typedef QMap<QString, QString> TableString;
25 25
26 /** 26 /**
27 * TableInt is used to establish a relation between a 27 * TableInt is used to establish a relation between a
28 * position of a column and the row value 28 * position of a column and the row value
29 */ 29 */
30 typedef QMap<int, QString> TableInt; 30 typedef QMap<int, QString> TableInt;
31 31
32 /** 32 /**
33 * Default c'tor. It has a TableString and a TableInt 33 * Default c'tor. It has a TableString and a TableInt
34 */ 34 */
35 OSQLResultItem(const TableString& = TableString(), 35 OSQLResultItem(const TableString& = TableString(),
36 const TableInt& = TableInt() ); 36 const TableInt& = TableInt() );
37 OSQLResultItem( const OSQLResultItem& ); 37 OSQLResultItem( const OSQLResultItem& );
38 ~OSQLResultItem(); 38 ~OSQLResultItem();
39 OSQLResultItem &operator=( const OSQLResultItem& ); 39 OSQLResultItem &operator=( const OSQLResultItem& );
40 /** 40 /**
41 * returns the TableString 41 * returns the TableString
42 */ 42 */
43 TableString tableString()const; 43 TableString tableString()const;
44 44
45 /** 45 /**
46 * returns the TableInt 46 * returns the TableInt
47 */ 47 */
48 TableInt tableInt() const; 48 TableInt tableInt() const;
49 49
50 /** 50 /**
51 * retrieves the Data from columnName 51 * retrieves the Data from columnName
52 * 52 *
53 */ 53 */
54 QString data( const QString& columnName, bool *ok = 0); 54 QString data( const QString& columnName, bool *ok = 0) const;
55 55
56 /** 56 /**
57 * QString for column number 57 * QString for column number
58 */ 58 */
59 QString data(int columnNumber, bool *ok = 0); 59 QString data(int columnNumber, bool *ok = 0) const;
60 60
61 /** 61 /**
62 * Date conversion from columnName 62 * Date conversion from columnName
63 */ 63 */
64 QDate dataToDate( const QString& columnName, bool *ok = 0 ); 64 QDate dataToDate( const QString& columnName, bool *ok = 0 );
65 65
66 /** 66 /**
67 * Date conversion from column-number 67 * Date conversion from column-number
68 */ 68 */
69 QDate dataToDate( int columnNumber, bool *ok = 0 ); 69 QDate dataToDate( int columnNumber, bool *ok = 0 );
70 70
71 QDateTime dataToDateTime( const QString& columName, bool *ok = 0 ); 71 QDateTime dataToDateTime( const QString& columName, bool *ok = 0 );
72 QDateTime dataToDateTime( int columnNumber, bool *ok = 0 ); 72 QDateTime dataToDateTime( int columnNumber, bool *ok = 0 );
73private: 73private:
74 TableString m_string; 74 TableString m_string;
75 TableInt m_int; 75 TableInt m_int;
76}; 76};
77 77
78/** 78/**
79 * the OSQLResult 79 * the OSQLResult
80 * either a SQL statement failed or succeeded 80 * either a SQL statement failed or succeeded
81 */ 81 */
82class OSQLResult { 82class OSQLResult {
83public: 83public:
84 /** The State of a Result */ 84 /** The State of a Result */
85 enum State{ Success = 0, Failure,Undefined }; 85 enum State{ Success = 0, Failure,Undefined };
86 86
87 /** 87 /**
88 * default c'tor 88 * default c'tor
89 * @param state The State of the Result 89 * @param state The State of the Result
90 * @param r ResultItems 90 * @param r ResultItems
91 * @prarm errors the Errors a OSQLResult created 91 * @prarm errors the Errors a OSQLResult created
92 */ 92 */
93 OSQLResult( enum State state = Undefined, 93 OSQLResult( enum State state = Undefined,
94 const OSQLResultItem::ValueList& r= OSQLResultItem::ValueList(), 94 const OSQLResultItem::ValueList& r= OSQLResultItem::ValueList(),
95 const OSQLError::ValueList& errors = OSQLError::ValueList() ); 95 const OSQLError::ValueList& errors = OSQLError::ValueList() );
96 ~OSQLResult(); 96 ~OSQLResult();
97 State state()const; 97 State state()const;
98 OSQLError::ValueList errors()const; 98 OSQLError::ValueList errors()const;
99 OSQLResultItem::ValueList results()const; 99 OSQLResultItem::ValueList results()const;
100 100
101 void setState( enum State state ); 101 void setState( enum State state );
102 void setErrors( const OSQLError::ValueList& error ); 102 void setErrors( const OSQLError::ValueList& error );
103 void setResults( const OSQLResultItem::ValueList& result ); 103 void setResults( const OSQLResultItem::ValueList& result );
104 104
105 OSQLResultItem first(); 105 OSQLResultItem first();
106 OSQLResultItem next(); 106 OSQLResultItem next();
107 bool atEnd(); 107 bool atEnd();
108 OSQLResultItem::ValueList::ConstIterator iterator()const; 108 OSQLResultItem::ValueList::ConstIterator iterator()const;
109private: 109private:
110 enum State m_state; 110 enum State m_state;
111 OSQLResultItem::ValueList m_list; 111 OSQLResultItem::ValueList m_list;
112 OSQLError::ValueList m_error; 112 OSQLError::ValueList m_error;
113 OSQLResultItem::ValueList::Iterator it; 113 OSQLResultItem::ValueList::Iterator it;
114 class Private; 114 class Private;
115 Private *d; 115 Private *d;
116}; 116};
117 117
118} 118}
119} 119}
120#endif 120#endif
diff --git a/libopie2/opiepim/TODO b/libopie2/opiepim/TODO
index c3420cf..b520370 100644
--- a/libopie2/opiepim/TODO
+++ b/libopie2/opiepim/TODO
@@ -1,63 +1,64 @@
1As to popular request.... 1As to popular request....
2 2
31.) fix up the core/backend mess. 31.) fix up the core/backend mess.
4 The actual Backend Implementation + Interface should be there 4 The actual Backend Implementation + Interface should be there
5 The API frontend used by the developer should not be used 5 The API frontend used by the developer should not be used
6 6
7 Rename ODateBookAccess* to OPimDateBookAccess* 7 Rename ODateBookAccess* to OPimDateBookAccess*
8 Rename OContactAccess* to OpimContactAccess*
8 Fix filenames to OPim* ... 9 Fix filenames to OPim* ...
9 10
102.) Move sorting, Query By Example, Exposing of Attributes of a Record 112.) Move sorting, Query By Example, Exposing of Attributes of a Record
11 available to the Ptr base class and have sane implementation 12 available to the Ptr base class and have sane implementation
12 on the template level 13 on the template level
13 14
143.) Have something like QProperty to expose attributes from OPimRecord. 153.) Have something like QProperty to expose attributes from OPimRecord.
15 This would include exporting,importing of data, and translated names. 16 This would include exporting,importing of data, and translated names.
16 This can be used for Cross Reference, Selector Widget, Generic Table 17 This can be used for Cross Reference, Selector Widget, Generic Table
17 Shower 18 Shower
18 19
194.) Marshall/Demarshall all PIM Records correctly 204.) Marshall/Demarshall all PIM Records correctly
20 21
215.) Add the Private Backend to the OPimRecord ( private ) make the base 225.) Add the Private Backend to the OPimRecord ( private ) make the base
22 access class friend and allow retrieving the backend. Make it virtual 23 access class friend and allow retrieving the backend. Make it virtual
23 so the template gets the right pointer. So it can only be accessed from 24 so the template gets the right pointer. So it can only be accessed from
24 the inside 25 the inside
25 26
266.) Add signals for updating/adding/removing records to the access template 276.) Add signals for updating/adding/removing records to the access template
27 Internal connect method 28 Internal connect method
28 29
297.) internal QCOP communication between the interfaces 307.) internal QCOP communication between the interfaces
30 31
318.) GUI:Better and Improved Recurrence Widget 328.) GUI:Better and Improved Recurrence Widget
32 33
339.) GUI:Improved Alarm Widget and handling classes 349.) GUI:Improved Alarm Widget and handling classes
34 35
3510.) GUI:Undo/Redo template look at KDE 3610.) GUI:Undo/Redo template look at KDE
36 37
3711.) GUI: Generic X-Ref Selector using the factory and pointer interface 3811.) GUI: Generic X-Ref Selector using the factory and pointer interface
38 39
3912.) GUI: Factory and also registration of foreign services. generate a records of type 4012.) GUI: Factory and also registration of foreign services. generate a records of type
40 41
4113.) Multiple Backends for an Access Template 4213.) Multiple Backends for an Access Template
42 43
4314.) ReadOnly Access 4414.) ReadOnly Access
44 45
4515.) GUI: Generic Table Widget maybe even baed on Selector with 4615.) GUI: Generic Table Widget maybe even baed on Selector with
46 configuration of shown Attribute 47 configuration of shown Attribute
47 48
4816.) Multiple Categories with Sub Categories including popup selector 4916.) Multiple Categories with Sub Categories including popup selector
49 Widget. Fix Bug with changing visible. Both helper class + gui. 50 Widget. Fix Bug with changing visible. Both helper class + gui.
50 Also group PopupNames Like in Function Menu of XEmacs 51 Also group PopupNames Like in Function Menu of XEmacs
51 52
5217.) ListView for TodolIst At least introduce parents and child 5317.) ListView for TodolIst At least introduce parents and child
53 And query for them 54 And query for them
54 55
5518.) Add querieng to Ptr Level for dates and date ranges. 5618.) Add querieng to Ptr Level for dates and date ranges.
56 Return OEffectiveEvents or such which is also only loaded 57 Return OEffectiveEvents or such which is also only loaded
57 if required. 58 if required.
58 59
5919.) Clean Up 6019.) Clean Up
60 61
6120.) Datebook Classes 6220.) Datebook Classes
62 63
6322.) Better helper for AlarmServer \ No newline at end of file 6422.) Better helper for AlarmServer \ No newline at end of file