summaryrefslogtreecommitdiff
path: root/libopie2/opiecore
Unidiff
Diffstat (limited to 'libopie2/opiecore') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp17
-rw-r--r--libopie2/opiecore/device/odevice.h9
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp4
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.h8
-rw-r--r--libopie2/opiecore/device/odevice_jornada.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_jornada.h9
-rw-r--r--libopie2/opiecore/device/odevice_ramses.cpp3
-rw-r--r--libopie2/opiecore/device/odevice_ramses.h7
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp3
-rw-r--r--libopie2/opiecore/device/odevice_simpad.h8
-rw-r--r--libopie2/opiecore/device/odevice_yopy.cpp3
-rw-r--r--libopie2/opiecore/device/odevice_yopy.h9
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp3
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.h8
-rw-r--r--libopie2/opiecore/device/odevicebutton.cpp15
-rw-r--r--libopie2/opiecore/device/odevicebutton.h11
-rw-r--r--libopie2/opiecore/oapplication.cpp11
-rw-r--r--libopie2/opiecore/oapplication.h13
-rw-r--r--libopie2/opiecore/oconfig.cpp2
-rw-r--r--libopie2/opiecore/oconfig.h13
-rw-r--r--libopie2/opiecore/odebug.cpp7
-rw-r--r--libopie2/opiecore/odebug.h9
-rw-r--r--libopie2/opiecore/oglobal.cpp6
-rw-r--r--libopie2/opiecore/oglobal.h10
-rw-r--r--libopie2/opiecore/oglobalsettings.cpp3
-rw-r--r--libopie2/opiecore/oglobalsettings.h12
-rw-r--r--libopie2/opiecore/opiecore.pro8
-rw-r--r--libopie2/opiecore/oprocctrl.cpp2
-rw-r--r--libopie2/opiecore/oprocctrl.h10
-rw-r--r--libopie2/opiecore/oprocess.cpp10
-rw-r--r--libopie2/opiecore/oprocess.h13
-rw-r--r--libopie2/opiecore/osmartpointer.h2
-rw-r--r--libopie2/opiecore/ostorageinfo.cpp2
-rw-r--r--libopie2/opiecore/ostorageinfo.h8
-rw-r--r--libopie2/opiecore/xmltree.cc323
-rw-r--r--libopie2/opiecore/xmltree.h119
36 files changed, 212 insertions, 490 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 27b0e53..f3e2cfb 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -15,122 +15,122 @@ _;:, .> :=|. This program is free software; you can
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 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; 63using namespace Opie::Core;
64 64
65ODevice *ODevice::inst() 65ODevice *ODevice::inst()
66{ 66{
67 static ODevice *dev = 0; 67 static ODevice *dev = 0;
68 68
69 // rewrite this to only use /proc/cpuinfo or so 69 // rewrite this to only use /proc/cpuinfo or so
70 70
71 if ( !dev ) 71 if ( !dev )
72 { 72 {
73 QFile f( PATH_PROC_CPUINFO ); 73 QFile f( PATH_PROC_CPUINFO );
74 if ( f.open( IO_ReadOnly ) ) 74 if ( f.open( IO_ReadOnly ) )
75 { 75 {
76 QTextStream s( &f ); 76 QTextStream s( &f );
77 while ( !s.atEnd() ) 77 while ( !s.atEnd() )
78 { 78 {
79 QString line; 79 QString line;
80 line = s.readLine(); 80 line = s.readLine();
81 if ( line.startsWith( "Hardware" ) ) 81 if ( line.startsWith( "Hardware" ) )
82 { 82 {
83 qDebug( "ODevice() - found '%s'", (const char*) line ); 83 qDebug( "ODevice() - found '%s'", (const char*) line );
84 if ( line.contains( "sharp", false ) ) dev = new Zaurus(); 84 if ( line.contains( "sharp", false ) ) dev = new Private::Zaurus();
85 else if ( line.contains( "ipaq", false ) ) dev = new iPAQ(); 85 else if ( line.contains( "ipaq", false ) ) dev = new Private::iPAQ();
86 else if ( line.contains( "simpad", false ) ) dev = new SIMpad(); 86 else if ( line.contains( "simpad", false ) ) dev = new Private::SIMpad();
87 else if ( line.contains( "jornada", false ) ) dev = new Jornada(); 87 else if ( line.contains( "jornada", false ) ) dev = new Private::Jornada();
88 else if ( line.contains( "ramses", false ) ) dev = new Ramses(); 88 else if ( line.contains( "ramses", false ) ) dev = new Private::Ramses();
89 else qWarning( "ODevice() - unknown hardware - using default." ); 89 else qWarning( "ODevice() - unknown hardware - using default." );
90 break; 90 break;
91 } 91 }
92 } 92 }
93 } 93 }
94 else 94 else
95 { 95 {
96 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default." ); 96 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default." );
97 } 97 }
98 if ( !dev ) dev = new ODevice(); 98 if ( !dev ) dev = new ODevice();
99 dev->init(); 99 dev->init();
100 } 100 }
101 return dev; 101 return dev;
102} 102}
103 103
104ODevice::ODevice() 104ODevice::ODevice()
105{ 105{
106 d = new ODeviceData; 106 d = new ODeviceData;
107 107
108 d->m_modelstr = "Unknown"; 108 d->m_modelstr = "Unknown";
109 d->m_model = Model_Unknown; 109 d->m_model = Model_Unknown;
110 d->m_vendorstr = "Unknown"; 110 d->m_vendorstr = "Unknown";
111 d->m_vendor = Vendor_Unknown; 111 d->m_vendor = Vendor_Unknown;
112 d->m_systemstr = "Unknown"; 112 d->m_systemstr = "Unknown";
113 d->m_system = System_Unknown; 113 d->m_system = System_Unknown;
114 d->m_sysverstr = "0.0"; 114 d->m_sysverstr = "0.0";
115 d->m_rotation = Rot0; 115 d->m_rotation = Rot0;
116 d->m_direction = CW; 116 d->m_direction = CW;
117 117
118 d->m_holdtime = 1000; // 1000ms 118 d->m_holdtime = 1000; // 1000ms
119 d->m_buttons = 0; 119 d->m_buttons = 0;
120 d->m_cpu_frequencies = new QStrList; 120 d->m_cpu_frequencies = new QStrList;
121} 121}
122 122
123void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 123void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
124{ 124{
125 if ( msg == "deviceButtonMappingChanged()" ) { 125 if ( msg == "deviceButtonMappingChanged()" ) {
126 reloadButtonMapping(); 126 reloadButtonMapping();
127 } 127 }
128} 128}
129 129
130void ODevice::init() 130void ODevice::init()
131{ 131{
132} 132}
133 133
134/** 134/**
135* This method initialises the button mapping 135* This method initialises the button mapping
136*/ 136*/
@@ -142,97 +142,97 @@ void ODevice::initButtons()
142 qDebug ( "init Buttons" ); 142 qDebug ( "init Buttons" );
143 d->m_buttons = new QValueList <ODeviceButton>; 143 d->m_buttons = new QValueList <ODeviceButton>;
144 144
145 reloadButtonMapping(); 145 reloadButtonMapping();
146 146
147 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 147 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
148 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); 148 connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
149} 149}
150 150
151ODevice::~ODevice() 151ODevice::~ODevice()
152{ 152{
153// we leak m_devicebuttons and m_cpu_frequency 153// we leak m_devicebuttons and m_cpu_frequency
154// but it's a singleton and it is not so importantant 154// but it's a singleton and it is not so importantant
155// -zecke 155// -zecke
156 delete d; 156 delete d;
157} 157}
158 158
159bool ODevice::setSoftSuspend ( bool /*soft*/ ) 159bool ODevice::setSoftSuspend ( bool /*soft*/ )
160{ 160{
161 return false; 161 return false;
162} 162}
163 163
164//#include <linux/apm_bios.h> 164//#include <linux/apm_bios.h>
165 165
166#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 166#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
167 167
168/** 168/**
169* This method will try to suspend the device 169* This method will try to suspend the device
170* It only works if the user is the QWS Server and the apm application 170* It only works if the user is the QWS Server and the apm application
171* is installed. 171* is installed.
172* It tries to suspend and then waits some time cause some distributions 172* It tries to suspend and then waits some time cause some distributions
173* do have asynchronus apm implementations. 173* do have asynchronus apm implementations.
174* This method will either fail and return false or it'll suspend the 174* This method will either fail and return false or it'll suspend the
175* device and return once the device got woken up 175* device and return once the device got woken up
176* 176*
177* @return if the device got suspended 177* @return if the device got suspended
178*/ 178*/
179bool ODevice::suspend() 179bool ODevice::suspend()
180{ 180{
181 qDebug("ODevice::suspend"); 181 qDebug("ODevice::suspend");
182 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 182 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
183 return false; 183 return false;
184 184
185 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 185 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
186 return false; 186 return false;
187 187
188 bool res = false; 188 bool res = false;
189 ODevice::sendSuspendmsg(); 189 ODevice::sendSuspendmsg();
190 190
191 struct timeval tvs, tvn; 191 struct timeval tvs, tvn;
192 ::gettimeofday ( &tvs, 0 ); 192 ::gettimeofday ( &tvs, 0 );
193 193
194 ::sync(); // flush fs caches 194 ::sync(); // flush fs caches
195 res = ( ::system ( "apm --suspend" ) == 0 ); 195 res = ( ::system ( "apm --suspend" ) == 0 );
196 196
197 // This is needed because the iPAQ apm implementation is asynchronous and we 197 // This is needed because the iPAQ apm implementation is asynchronous and we
198 // can not be sure when exactly the device is really suspended 198 // can not be sure when exactly the device is really suspended
199 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 199 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
200 200
201 if ( res ) { 201 if ( res ) {
202 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 202 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
203 ::usleep ( 200 * 1000 ); 203 ::usleep ( 200 * 1000 );
204 ::gettimeofday ( &tvn, 0 ); 204 ::gettimeofday ( &tvn, 0 );
205 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 205 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
206 } 206 }
207 207
208 return res; 208 return res;
209} 209}
210 210
211//#include <linux/fb.h> better not rely on kernel headers in userspace ... 211//#include <linux/fb.h> better not rely on kernel headers in userspace ...
212 212
213#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 213#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
214 214
215/* VESA Blanking Levels */ 215/* VESA Blanking Levels */
216#define VESA_NO_BLANKING 0 216#define VESA_NO_BLANKING 0
217#define VESA_VSYNC_SUSPEND 1 217#define VESA_VSYNC_SUSPEND 1
218#define VESA_HSYNC_SUSPEND 2 218#define VESA_HSYNC_SUSPEND 2
219#define VESA_POWERDOWN 3 219#define VESA_POWERDOWN 3
220 220
221/** 221/**
222* This sets the display on or off 222* This sets the display on or off
223*/ 223*/
224bool ODevice::setDisplayStatus ( bool on ) 224bool ODevice::setDisplayStatus ( bool on )
225{ 225{
226 qDebug("ODevice::setDisplayStatus(%d)", on); 226 qDebug("ODevice::setDisplayStatus(%d)", on);
227 227
228 if ( d->m_model == Model_Unknown ) 228 if ( d->m_model == Model_Unknown )
229 return false; 229 return false;
230 230
231 bool res = false; 231 bool res = false;
232 int fd; 232 int fd;
233 233
234 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 234 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
235 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 235 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
236 ::close ( fd ); 236 ::close ( fd );
237 } 237 }
238 return res; 238 return res;
@@ -579,50 +579,53 @@ void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
579{ 579{
580 initButtons(); 580 initButtons();
581 581
582 QString mb_chan; 582 QString mb_chan;
583 583
584 if ( button >= (int) d->m_buttons->count()) 584 if ( button >= (int) d->m_buttons->count())
585 return; 585 return;
586 586
587 ODeviceButton &b = ( *d->m_buttons ) [button]; 587 ODeviceButton &b = ( *d->m_buttons ) [button];
588 b. setPressedAction ( action ); 588 b. setPressedAction ( action );
589 589
590 mb_chan=b. pressedAction(). channel(); 590 mb_chan=b. pressedAction(). channel();
591 591
592 Config buttonFile ( "ButtonSettings" ); 592 Config buttonFile ( "ButtonSettings" );
593 buttonFile. setGroup ( "Button" + QString::number ( button )); 593 buttonFile. setGroup ( "Button" + QString::number ( button ));
594 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 594 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
595 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); 595 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message());
596 596
597 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); 597 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
598 598
599 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 599 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
600} 600}
601 601
602void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 602void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
603{ 603{
604 initButtons(); 604 initButtons();
605 605
606 if ( button >= (int) d->m_buttons->count()) 606 if ( button >= (int) d->m_buttons->count())
607 return; 607 return;
608 608
609 ODeviceButton &b = ( *d->m_buttons ) [button]; 609 ODeviceButton &b = ( *d->m_buttons ) [button];
610 b. setHeldAction ( action ); 610 b. setHeldAction ( action );
611 611
612 Config buttonFile ( "ButtonSettings" ); 612 Config buttonFile ( "ButtonSettings" );
613 buttonFile. setGroup ( "Button" + QString::number ( button )); 613 buttonFile. setGroup ( "Button" + QString::number ( button ));
614 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); 614 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
615 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); 615 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
616 616
617 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); 617 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
618 618
619 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 619 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
620} 620}
621void ODevice::virtual_hook(int, void* ){ 621void ODevice::virtual_hook(int, void* ){
622 622
623} 623}
624 624
625void ODevice::sendSuspendmsg() 625void ODevice::sendSuspendmsg()
626{ 626{
627 if ( isQWS() )
628 return;
629
627 QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); 630 QCopEnvelope ( "QPE/System", "aboutToSuspend()" );
628} 631}
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index bccb449..5ee9cca 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -1,92 +1,93 @@
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#ifndef ODEVICE_H_ 30#ifndef ODEVICE_H_
31#define ODEVICE_H_ 31#define ODEVICE_H_
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odevicebutton.h> 34#include <opie2/odevicebutton.h>
35#include <qpe/qpeapplication.h> /* for Transformation enum.. */ 35#include <qpe/qpeapplication.h> /* for Transformation enum.. */
36 36
37/* QT */ 37/* QT */
38#include <qnamespace.h> 38#include <qnamespace.h>
39#include <qobject.h> 39#include <qobject.h>
40#include <qstring.h> 40#include <qstring.h>
41#include <qstrlist.h> 41#include <qstrlist.h>
42 42
43namespace Opie 43namespace Opie{
44{ 44namespace Core{
45
45 class ODeviceData; 46 class ODeviceData;
46/** 47/**
47 * The available devices 48 * The available devices
48 */ 49 */
49enum OModel { 50enum OModel {
50 Model_Unknown, // = 0 51 Model_Unknown, // = 0
51 52
52 Model_Series_Mask = 0xff000000, 53 Model_Series_Mask = 0xff000000,
53 54
54 Model_iPAQ = ( 1 << 24 ), 55 Model_iPAQ = ( 1 << 24 ),
55 56
56 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 57 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
57 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 58 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
58 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 59 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
59 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 60 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
60 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 61 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
61 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 62 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
62 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000011 ), 63 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000011 ),
63 64
64 Model_Jornada = ( 6 << 24 ), 65 Model_Jornada = ( 6 << 24 ),
65 Model_Jornada_56x = ( Model_Jornada | 0x000001 ), 66 Model_Jornada_56x = ( Model_Jornada | 0x000001 ),
66 67
67 Model_Zaurus = ( 2 << 24 ), 68 Model_Zaurus = ( 2 << 24 ),
68 69
69 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 70 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
70 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 71 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
71 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 72 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
72 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 73 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
73 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), 74 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ),
74 75
75 Model_SIMpad = ( 3 << 24 ), 76 Model_SIMpad = ( 3 << 24 ),
76 77
77 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), 78 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ),
78 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), 79 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ),
79 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), 80 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ),
80 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), 81 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ),
81 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), 82 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ),
82 83
83 Model_Ramses = ( 4 << 24 ), 84 Model_Ramses = ( 4 << 24 ),
84 85
85 Model_Ramses_All = ( Model_Ramses | 0xffffff ), 86 Model_Ramses_All = ( Model_Ramses | 0xffffff ),
86 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), 87 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
87 88
88 Model_Yopy = ( 5 << 24 ), 89 Model_Yopy = ( 5 << 24 ),
89 90
90 Model_Yopy_All = ( Model_Yopy | 0xffffff ), 91 Model_Yopy_All = ( Model_Yopy | 0xffffff ),
91 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), 92 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ),
92 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), 93 Model_Yopy_3500 = ( Model_Yopy | 0x000002 ),
@@ -205,128 +206,130 @@ public:
205 206
206 QString systemVersionString() const; 207 QString systemVersionString() const;
207 208
208 virtual Transformation rotation() const; 209 virtual Transformation rotation() const;
209 virtual ODirection direction() const; 210 virtual ODirection direction() const;
210 211
211 // system 212 // system
212 213
213 virtual bool setSoftSuspend ( bool on ); 214 virtual bool setSoftSuspend ( bool on );
214 virtual bool suspend(); 215 virtual bool suspend();
215 216
216 virtual bool setDisplayStatus ( bool on ); 217 virtual bool setDisplayStatus ( bool on );
217 virtual bool setDisplayBrightness ( int brightness ); 218 virtual bool setDisplayBrightness ( int brightness );
218 virtual int displayBrightnessResolution() const; 219 virtual int displayBrightnessResolution() const;
219 virtual bool setDisplayContrast ( int contrast ); 220 virtual bool setDisplayContrast ( int contrast );
220 virtual int displayContrastResolution() const; 221 virtual int displayContrastResolution() const;
221 222
222 // don't add new virtual methods, use this: 223 // don't add new virtual methods, use this:
223 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; 224 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
224 // and in your subclass do do overwrite 225 // and in your subclass do do overwrite
225 //protected virtual int virtual_hook(int, void *) 226 //protected virtual int virtual_hook(int, void *)
226 // which is defined below 227 // which is defined below
227 228
228 // input / output 229 // input / output
229 virtual void playAlarmSound(); 230 virtual void playAlarmSound();
230 virtual void playKeySound(); 231 virtual void playKeySound();
231 virtual void playTouchSound(); 232 virtual void playTouchSound();
232 233
233 virtual QValueList <OLed> ledList() const; 234 virtual QValueList <OLed> ledList() const;
234 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 235 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
235 virtual OLedState ledState ( OLed led ) const; 236 virtual OLedState ledState ( OLed led ) const;
236 virtual bool setLedState ( OLed led, OLedState st ); 237 virtual bool setLedState ( OLed led, OLedState st );
237 238
238 virtual bool hasLightSensor() const; 239 virtual bool hasLightSensor() const;
239 virtual int readLightSensor(); 240 virtual int readLightSensor();
240 virtual int lightSensorResolution() const; 241 virtual int lightSensorResolution() const;
241 242
242 virtual bool hasHingeSensor() const; 243 virtual bool hasHingeSensor() const;
243 virtual OHingeStatus readHingeSensor(); 244 virtual OHingeStatus readHingeSensor();
244 245
245 const QStrList &allowedCpuFrequencies() const; 246 const QStrList &allowedCpuFrequencies() const;
246 bool setCurrentCpuFrequency(uint index); 247 bool setCurrentCpuFrequency(uint index);
247 248
248 /** 249 /**
249 * Returns the available buttons on this device. The number and location 250 * Returns the available buttons on this device. The number and location
250 * of buttons will vary depending on the device. Button numbers will be assigned 251 * of buttons will vary depending on the device. Button numbers will be assigned
251 * by the device manufacturer and will be from most preferred button to least preffered 252 * by the device manufacturer and will be from most preferred button to least preffered
252 * button. Note that this list only contains "user mappable" buttons. 253 * button. Note that this list only contains "user mappable" buttons.
253 * 254 *
254 * @todo Make method const and take care of calling initButtons or make that const too 255 * @todo Make method const and take care of calling initButtons or make that const too
255 * 256 *
256 */ 257 */
257 const QValueList<ODeviceButton> &buttons(); 258 const QValueList<ODeviceButton> &buttons();
258 259
259 /** 260 /**
260 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 261 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
261 * returns 0L 262 * returns 0L
262 */ 263 */
263 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 264 const ODeviceButton *buttonForKeycode ( ushort keyCode );
264 265
265 /** 266 /**
266 * Reassigns the pressed action for \a button. To return to the factory 267 * Reassigns the pressed action for \a button. To return to the factory
267 * default pass an empty string as \a qcopMessage. 268 * default pass an empty string as \a qcopMessage.
268 */ 269 */
269 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 270 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
270 271
271 /** 272 /**
272 * Reassigns the held action for \a button. To return to the factory 273 * Reassigns the held action for \a button. To return to the factory
273 * default pass an empty string as \a qcopMessage. 274 * default pass an empty string as \a qcopMessage.
274 */ 275 */
275 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 276 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
276 277
277 /** 278 /**
278 * How long (in ms) you have to press a button for a "hold" action 279 * How long (in ms) you have to press a button for a "hold" action
279 */ 280 */
280 uint buttonHoldTime() const; 281 uint buttonHoldTime() const;
281 282
282signals: 283signals:
283 void buttonMappingChanged(); 284 void buttonMappingChanged();
284 285
285private slots: 286private slots:
286 void systemMessage ( const QCString &, const QByteArray & ); 287 void systemMessage ( const QCString &, const QByteArray & );
287 288
288protected: 289protected:
289 void reloadButtonMapping(); 290 void reloadButtonMapping();
290 /* ugly virtual hook */ 291 /* ugly virtual hook */
291 virtual void virtual_hook( int id, void* data ); 292 virtual void virtual_hook( int id, void* data );
292}; 293};
293 294
294class ODeviceData { 295class ODeviceData {
295 296
296 public: 297 public:
297 QString m_vendorstr; 298 QString m_vendorstr;
298 OVendor m_vendor; 299 OVendor m_vendor;
299 300
300 QString m_modelstr; 301 QString m_modelstr;
301 OModel m_model; 302 OModel m_model;
302 303
303 QString m_systemstr; 304 QString m_systemstr;
304 OSystem m_system; 305 OSystem m_system;
305 306
306 QString m_sysverstr; 307 QString m_sysverstr;
307 308
308 Transformation m_rotation; 309 Transformation m_rotation;
309 ODirection m_direction; 310 ODirection m_direction;
310 311
311 QValueList <ODeviceButton> *m_buttons; 312 QValueList <ODeviceButton> *m_buttons;
312 uint m_holdtime; 313 uint m_holdtime;
313 QStrList *m_cpu_frequencies; 314 QStrList *m_cpu_frequencies;
314}; 315};
315 316
316} 317}
318}
317 319
318static inline bool isQWS() 320static inline bool isQWS()
319{ 321{
320 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; 322 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
321} 323}
322 324
323static QCString makeChannel ( const char *str ) 325static QCString makeChannel ( const char *str )
324{ 326{
325 if ( str && !::strchr ( str, '/' )) 327 if ( str && !::strchr ( str, '/' ))
326 return QCString ( "QPE/Application/" ) + str; 328 return QCString ( "QPE/Application/" ) + str;
327 else 329 else
328 return str; 330 return str;
329} 331}
330 332
333
331#endif 334#endif
332 335
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 8ecea1b..177fd4c 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -8,96 +8,100 @@
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 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56
57using namespace Opie::Core;
58using namespace Opie::Core::Private;
59
56/* KERNEL */ 60/* KERNEL */
57#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 61#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
58 62
59#define OD_IO(type,number) OD_IOC(0,type,number,0) 63#define OD_IO(type,number) OD_IOC(0,type,number,0)
60#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 64#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
61#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 65#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
62#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 66#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
63 67
64typedef struct { 68typedef struct {
65 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 69 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
66 unsigned char TotalTime; /* Units of 5 seconds */ 70 unsigned char TotalTime; /* Units of 5 seconds */
67 unsigned char OnTime; /* units of 100m/s */ 71 unsigned char OnTime; /* units of 100m/s */
68 unsigned char OffTime; /* units of 100m/s */ 72 unsigned char OffTime; /* units of 100m/s */
69} LED_IN; 73} LED_IN;
70 74
71typedef struct { 75typedef struct {
72 unsigned char mode; 76 unsigned char mode;
73 unsigned char pwr; 77 unsigned char pwr;
74 unsigned char brightness; 78 unsigned char brightness;
75} FLITE_IN; 79} FLITE_IN;
76 80
77#define LED_ON OD_IOW( 'f', 5, LED_IN ) 81#define LED_ON OD_IOW( 'f', 5, LED_IN )
78#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 82#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
79 83
80struct i_button ipaq_buttons [] = { 84struct i_button ipaq_buttons [] = {
81 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 85 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
82 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 86 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
83 "devicebuttons/ipaq_calendar", 87 "devicebuttons/ipaq_calendar",
84 "datebook", "nextView()", 88 "datebook", "nextView()",
85 "today", "raise()" }, 89 "today", "raise()" },
86 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 90 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
87 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 91 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
88 "devicebuttons/ipaq_contact", 92 "devicebuttons/ipaq_contact",
89 "addressbook", "raise()", 93 "addressbook", "raise()",
90 "addressbook", "beamBusinessCard()" }, 94 "addressbook", "beamBusinessCard()" },
91 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 95 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
92 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 96 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
93 "devicebuttons/ipaq_menu", 97 "devicebuttons/ipaq_menu",
94 "QPE/TaskBar", "toggleMenu()", 98 "QPE/TaskBar", "toggleMenu()",
95 "QPE/TaskBar", "toggleStartMenu()" }, 99 "QPE/TaskBar", "toggleStartMenu()" },
96 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 100 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
97 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 101 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
98 "devicebuttons/ipaq_mail", 102 "devicebuttons/ipaq_mail",
99 "mail", "raise()", 103 "mail", "raise()",
100 "mail", "newMail()" }, 104 "mail", "newMail()" },
101 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 105 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
102 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 106 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
103 "devicebuttons/ipaq_home", 107 "devicebuttons/ipaq_home",
diff --git a/libopie2/opiecore/device/odevice_ipaq.h b/libopie2/opiecore/device/odevice_ipaq.h
index f512344..4f4af46 100644
--- a/libopie2/opiecore/device/odevice_ipaq.h
+++ b/libopie2/opiecore/device/odevice_ipaq.h
@@ -1,84 +1,90 @@
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#ifndef ODEVICE_IPAQ 30#ifndef ODEVICE_IPAQ
31#define ODEVICE_IPAQ 31#define ODEVICE_IPAQ
32 32
33#include "odevice.h" 33#include "odevice.h"
34 34
35/* QT */ 35/* QT */
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38using namespace Opie; 38namespace Opie {
39namespace Core {
40namespace Private {
39 41
40class iPAQ : public ODevice, public QWSServer::KeyboardFilter 42class iPAQ : public ODevice, public QWSServer::KeyboardFilter
41{ 43{
42 44
43 protected: 45 protected:
44 virtual void init(); 46 virtual void init();
45 virtual void initButtons(); 47 virtual void initButtons();
46 48
47 public: 49 public:
48 virtual bool setSoftSuspend( bool soft ); 50 virtual bool setSoftSuspend( bool soft );
49 51
50 virtual bool setDisplayBrightness( int b ); 52 virtual bool setDisplayBrightness( int b );
51 virtual int displayBrightnessResolution() const; 53 virtual int displayBrightnessResolution() const;
52 54
53 virtual void playAlarmSound(); 55 virtual void playAlarmSound();
54 56
55 virtual QValueList <OLed> ledList() const; 57 virtual QValueList <OLed> ledList() const;
56 virtual QValueList <OLedState> ledStateList( OLed led ) const; 58 virtual QValueList <OLedState> ledStateList( OLed led ) const;
57 virtual OLedState ledState( OLed led ) const; 59 virtual OLedState ledState( OLed led ) const;
58 virtual bool setLedState( OLed led, OLedState st ); 60 virtual bool setLedState( OLed led, OLedState st );
59 61
60 virtual bool hasLightSensor() const; 62 virtual bool hasLightSensor() const;
61 virtual int readLightSensor(); 63 virtual int readLightSensor();
62 virtual int lightSensorResolution() const; 64 virtual int lightSensorResolution() const;
63 65
64 protected: 66 protected:
65 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 67 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
66 virtual void timerEvent( QTimerEvent *te ); 68 virtual void timerEvent( QTimerEvent *te );
67 69
68 int m_power_timer; 70 int m_power_timer;
69 71
70 OLedState m_leds [2]; 72 OLedState m_leds [2];
71}; 73};
72 74
73struct i_button { 75struct i_button {
74 uint model; 76 uint model;
75 Qt::Key code; 77 Qt::Key code;
76 char *utext; 78 char *utext;
77 char *pix; 79 char *pix;
78 char *fpressedservice; 80 char *fpressedservice;
79 char *fpressedaction; 81 char *fpressedaction;
80 char *fheldservice; 82 char *fheldservice;
81 char *fheldaction; 83 char *fheldaction;
82}; 84};
83 85
86}
87}
88}
89
84#endif 90#endif
diff --git a/libopie2/opiecore/device/odevice_jornada.cpp b/libopie2/opiecore/device/odevice_jornada.cpp
index 37bd6e9..b79b0b5 100644
--- a/libopie2/opiecore/device/odevice_jornada.cpp
+++ b/libopie2/opiecore/device/odevice_jornada.cpp
@@ -32,97 +32,97 @@
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56/* KERNEL */ 56/* KERNEL */
57#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 57#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
58 58
59#define OD_IO(type,number) OD_IOC(0,type,number,0) 59#define OD_IO(type,number) OD_IOC(0,type,number,0)
60#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 60#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
61#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 61#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
62#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 62#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
63 63
64typedef struct { 64typedef struct {
65 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 65 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
66 unsigned char TotalTime; /* Units of 5 seconds */ 66 unsigned char TotalTime; /* Units of 5 seconds */
67 unsigned char OnTime; /* units of 100m/s */ 67 unsigned char OnTime; /* units of 100m/s */
68 unsigned char OffTime; /* units of 100m/s */ 68 unsigned char OffTime; /* units of 100m/s */
69} LED_IN; 69} LED_IN;
70 70
71typedef struct { 71typedef struct {
72 unsigned char mode; 72 unsigned char mode;
73 unsigned char pwr; 73 unsigned char pwr;
74 unsigned char brightness; 74 unsigned char brightness;
75} FLITE_IN; 75} FLITE_IN;
76 76
77#define LED_ON OD_IOW( 'f', 5, LED_IN ) 77#define LED_ON OD_IOW( 'f', 5, LED_IN )
78#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 78#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
79 79
80using namespace Opie; 80using namespace Opie::Core::Private;
81 81
82void Jornada::init() 82void Jornada::init()
83{ 83{
84 d->m_vendorstr = "HP"; 84 d->m_vendorstr = "HP";
85 d->m_vendor = Vendor_HP; 85 d->m_vendor = Vendor_HP;
86 d->m_modelstr = "Jornada 56x"; 86 d->m_modelstr = "Jornada 56x";
87 d->m_model = Model_Jornada_56x; 87 d->m_model = Model_Jornada_56x;
88 d->m_systemstr = "Familiar"; 88 d->m_systemstr = "Familiar";
89 d->m_system = System_Familiar; 89 d->m_system = System_Familiar;
90 d->m_rotation = Rot0; 90 d->m_rotation = Rot0;
91 91
92 QFile f ( "/etc/familiar-version" ); 92 QFile f ( "/etc/familiar-version" );
93 f.setName ( "/etc/familiar-version" ); 93 f.setName ( "/etc/familiar-version" );
94 if ( f.open ( IO_ReadOnly )) { 94 if ( f.open ( IO_ReadOnly )) {
95 95
96 QTextStream ts ( &f ); 96 QTextStream ts ( &f );
97 d->m_sysverstr = ts.readLine().mid( 10 ); 97 d->m_sysverstr = ts.readLine().mid( 10 );
98 98
99 f. close(); 99 f. close();
100 } 100 }
101} 101}
102 102
103 103
104int Jornada::displayBrightnessResolution() const 104int Jornada::displayBrightnessResolution() const
105{ 105{
106 return 0; 106 return 0;
107} 107}
108 108
109 109
110bool Jornada::setDisplayBrightness( int bright ) 110bool Jornada::setDisplayBrightness( int bright )
111{ 111{
112 bool res = false; 112 bool res = false;
113 int fd; 113 int fd;
114 114
115 if ( bright > 255 ) 115 if ( bright > 255 )
116 bright = 255; 116 bright = 255;
117 if ( bright < 0 ) 117 if ( bright < 0 )
118 bright = 0; 118 bright = 0;
119 119
120 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 120 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
121 FLITE_IN bl; 121 FLITE_IN bl;
122 bl. mode = 1; 122 bl. mode = 1;
123 bl. pwr = bright ? 1 : 0; 123 bl. pwr = bright ? 1 : 0;
124 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; 124 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
125 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 125 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
126 ::close ( fd ); 126 ::close ( fd );
127 } 127 }
128 return res; 128 return res;
diff --git a/libopie2/opiecore/device/odevice_jornada.h b/libopie2/opiecore/device/odevice_jornada.h
index 59be8da..c37d75e 100644
--- a/libopie2/opiecore/device/odevice_jornada.h
+++ b/libopie2/opiecore/device/odevice_jornada.h
@@ -1,50 +1,53 @@
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#ifndef ODEVICE_JORNADA 30#ifndef ODEVICE_JORNADA
31#define ODEVICE_JORNADA 31#define ODEVICE_JORNADA
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34 34
35using namespace Opie; 35namespace Opie {
36 36namespace Core {
37namespace Private {
37class Jornada : public ODevice 38class Jornada : public ODevice
38{ 39{
39 40
40 protected: 41 protected:
41 virtual void init(); 42 virtual void init();
42 43
43 public: 44 public:
44 virtual bool setSoftSuspend ( bool soft ); 45 virtual bool setSoftSuspend ( bool soft );
45 virtual bool setDisplayBrightness ( int b ); 46 virtual bool setDisplayBrightness ( int b );
46 virtual int displayBrightnessResolution() const; 47 virtual int displayBrightnessResolution() const;
47}; 48};
48 49}
50}
51}
49#endif 52#endif
50 53
diff --git a/libopie2/opiecore/device/odevice_ramses.cpp b/libopie2/opiecore/device/odevice_ramses.cpp
index 5bcf6a9..77de8c5 100644
--- a/libopie2/opiecore/device/odevice_ramses.cpp
+++ b/libopie2/opiecore/device/odevice_ramses.cpp
@@ -8,96 +8,99 @@
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_ramses.h" 30#include "odevice_ramses.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie::Core;
57using namespace Opie::Core::Private;
58
56struct r_button ramses_buttons [] = { 59struct r_button ramses_buttons [] = {
57 { Model_Ramses_MNCI, 60 { Model_Ramses_MNCI,
58 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 61 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
59 "devicebuttons/z_menu", 62 "devicebuttons/z_menu",
60 "QPE/TaskBar", "toggleMenu()", 63 "QPE/TaskBar", "toggleMenu()",
61 "QPE/TaskBar", "toggleStartMenu()" }, 64 "QPE/TaskBar", "toggleStartMenu()" },
62 { Model_Ramses_MNCI, 65 { Model_Ramses_MNCI,
63 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 66 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
64 "devicebuttons/ipaq_home", 67 "devicebuttons/ipaq_home",
65 "QPE/Launcher", "home()", 68 "QPE/Launcher", "home()",
66 "buttonsettings", "raise()" }, 69 "buttonsettings", "raise()" },
67}; 70};
68 71
69void Ramses::init() 72void Ramses::init()
70{ 73{
71 d->m_vendorstr = "M und N"; 74 d->m_vendorstr = "M und N";
72 d->m_vendor = Vendor_MundN; 75 d->m_vendor = Vendor_MundN;
73 76
74 QFile f("/proc/sys/board/ramses"); 77 QFile f("/proc/sys/board/ramses");
75 78
76 d->m_modelstr = "Ramses"; 79 d->m_modelstr = "Ramses";
77 d->m_model = Model_Ramses_MNCI; 80 d->m_model = Model_Ramses_MNCI;
78 81
79 d->m_rotation = Rot0; 82 d->m_rotation = Rot0;
80 d->m_holdtime = 1000; 83 d->m_holdtime = 1000;
81 84
82 f.setName("/etc/oz_version"); 85 f.setName("/etc/oz_version");
83 86
84 if (f.open(IO_ReadOnly)) { 87 if (f.open(IO_ReadOnly)) {
85 d->m_systemstr = "OpenEmbedded/Ramses"; 88 d->m_systemstr = "OpenEmbedded/Ramses";
86 d->m_system = System_OpenZaurus; 89 d->m_system = System_OpenZaurus;
87 90
88 QTextStream ts(&f); 91 QTextStream ts(&f);
89 ts.setDevice(&f); 92 ts.setDevice(&f);
90 d->m_sysverstr = ts.readLine(); 93 d->m_sysverstr = ts.readLine();
91 f.close(); 94 f.close();
92 } 95 }
93 96
94 m_power_timer = 0; 97 m_power_timer = 0;
95 98
96#ifdef QT_QWS_ALLOW_OVERCLOCK 99#ifdef QT_QWS_ALLOW_OVERCLOCK
97#warning *** Overclocking enabled - this may fry your hardware - you have been warned *** 100#warning *** Overclocking enabled - this may fry your hardware - you have been warned ***
98#define OC(x...) x 101#define OC(x...) x
99#else 102#else
100#define OC(x...) 103#define OC(x...)
101#endif 104#endif
102 105
103 // This table is true for a Intel XScale PXA 255 106 // This table is true for a Intel XScale PXA 255
diff --git a/libopie2/opiecore/device/odevice_ramses.h b/libopie2/opiecore/device/odevice_ramses.h
index 1b660ab..e673b1a 100644
--- a/libopie2/opiecore/device/odevice_ramses.h
+++ b/libopie2/opiecore/device/odevice_ramses.h
@@ -1,72 +1,77 @@
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#ifndef ODEVICE_RAMSES 30#ifndef ODEVICE_RAMSES
31#define ODEVICE_RAMSES 31#define ODEVICE_RAMSES
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34/* QT */ 34/* QT */
35#include <qwindowsystem_qws.h> 35#include <qwindowsystem_qws.h>
36 36
37using namespace Opie; 37namespace Opie {
38namespace Core {
39namespace Private {
38 40
39class Ramses : public ODevice, public QWSServer::KeyboardFilter 41class Ramses : public ODevice, public QWSServer::KeyboardFilter
40{ 42{
41 protected: 43 protected:
42 virtual void init(); 44 virtual void init();
43 45
44 public: 46 public:
45 virtual bool setSoftSuspend( bool soft ); 47 virtual bool setSoftSuspend( bool soft );
46 virtual bool suspend(); 48 virtual bool suspend();
47 49
48 virtual bool setDisplayStatus( bool on ); 50 virtual bool setDisplayStatus( bool on );
49 virtual bool setDisplayBrightness( int b ); 51 virtual bool setDisplayBrightness( int b );
50 virtual int displayBrightnessResolution() const; 52 virtual int displayBrightnessResolution() const;
51 virtual bool setDisplayContrast( int b ); 53 virtual bool setDisplayContrast( int b );
52 virtual int displayContrastResolution() const; 54 virtual int displayContrastResolution() const;
53 55
54 protected: 56 protected:
55 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 57 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
56 virtual void timerEvent ( QTimerEvent *te ); 58 virtual void timerEvent ( QTimerEvent *te );
57 59
58 int m_power_timer; 60 int m_power_timer;
59}; 61};
60 62
61struct r_button { 63struct r_button {
62 uint model; 64 uint model;
63 Qt::Key code; 65 Qt::Key code;
64 char *utext; 66 char *utext;
65 char *pix; 67 char *pix;
66 char *fpressedservice; 68 char *fpressedservice;
67 char *fpressedaction; 69 char *fpressedaction;
68 char *fheldservice; 70 char *fheldservice;
69 char *fheldaction; 71 char *fheldaction;
70}; 72};
73}
74}
75}
71 76
72#endif 77#endif
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index 90aca2f..80d40a3 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -8,97 +8,98 @@ _;:, .> :=|. 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_simpad.h" 30#include "odevice_simpad.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie; 56using namespace Opie::Core;
57using namespace Opie::Core::Private;
57 58
58struct s_button simpad_buttons [] = { 59struct s_button simpad_buttons [] = {
59 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 60 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
60 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 61 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
61 "devicebuttons/simpad_lower_up", 62 "devicebuttons/simpad_lower_up",
62 "datebook", "nextView()", 63 "datebook", "nextView()",
63 "today", "raise()" }, 64 "today", "raise()" },
64 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 65 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
65 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 66 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
66 "devicebuttons/simpad_lower_down", 67 "devicebuttons/simpad_lower_down",
67 "addressbook", "raise()", 68 "addressbook", "raise()",
68 "addressbook", "beamBusinessCard()" }, 69 "addressbook", "beamBusinessCard()" },
69 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 70 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
70 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 71 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
71 "devicebuttons/simpad_lower_right", 72 "devicebuttons/simpad_lower_right",
72 "QPE/TaskBar", "toggleMenu()", 73 "QPE/TaskBar", "toggleMenu()",
73 "QPE/TaskBar", "toggleStartMenu()" }, 74 "QPE/TaskBar", "toggleStartMenu()" },
74 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 75 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
75 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 76 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
76 "devicebuttons/simpad_lower_left", 77 "devicebuttons/simpad_lower_left",
77 "mail", "raise()", 78 "mail", "raise()",
78 "mail", "newMail()" }, 79 "mail", "newMail()" },
79 80
80 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 81 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
81 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 82 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
82 "devicebuttons/simpad_upper_up", 83 "devicebuttons/simpad_upper_up",
83 "QPE/Launcher", "home()", 84 "QPE/Launcher", "home()",
84 "buttonsettings", "raise()" }, 85 "buttonsettings", "raise()" },
85 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 86 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
86 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 87 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
87 "devicebuttons/simpad_upper_down", 88 "devicebuttons/simpad_upper_down",
88 "addressbook", "raise()", 89 "addressbook", "raise()",
89 "addressbook", "beamBusinessCard()" }, 90 "addressbook", "beamBusinessCard()" },
90 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 91 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
91 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 92 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
92 "devicebuttons/simpad_upper_right", 93 "devicebuttons/simpad_upper_right",
93 "QPE/TaskBar", "toggleMenu()", 94 "QPE/TaskBar", "toggleMenu()",
94 "QPE/TaskBar", "toggleStartMenu()" }, 95 "QPE/TaskBar", "toggleStartMenu()" },
95 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 96 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
96 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 97 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
97 "devicebuttons/simpad_upper_left", 98 "devicebuttons/simpad_upper_left",
98 "QPE/Rotation", "flip()", 99 "QPE/Rotation", "flip()",
99 "QPE/Rotation", "flip()" }, 100 "QPE/Rotation", "flip()" },
100 /* 101 /*
101 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 102 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
102 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 103 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
103 "devicebuttons/simpad_lower_upper", 104 "devicebuttons/simpad_lower_upper",
104 "QPE/Launcher", "home()", 105 "QPE/Launcher", "home()",
diff --git a/libopie2/opiecore/device/odevice_simpad.h b/libopie2/opiecore/device/odevice_simpad.h
index 3287ee8..1848151 100644
--- a/libopie2/opiecore/device/odevice_simpad.h
+++ b/libopie2/opiecore/device/odevice_simpad.h
@@ -1,81 +1,87 @@
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#ifndef ODEVICE_SIMPAD 30#ifndef ODEVICE_SIMPAD
31#define ODEVICE_SIMPAD 31#define ODEVICE_SIMPAD
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34 34
35/* QT */ 35/* QT */
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38using namespace Opie; 38namespace Opie {
39namespace Core {
40namespace Private {
39 41
40class SIMpad : public ODevice, public QWSServer::KeyboardFilter 42class SIMpad : public ODevice, public QWSServer::KeyboardFilter
41{ 43{
42 protected: 44 protected:
43 virtual void init(); 45 virtual void init();
44 virtual void initButtons(); 46 virtual void initButtons();
45 47
46 public: 48 public:
47 virtual bool setSoftSuspend( bool soft ); 49 virtual bool setSoftSuspend( bool soft );
48 virtual bool suspend(); 50 virtual bool suspend();
49 51
50 virtual bool setDisplayStatus( bool on ); 52 virtual bool setDisplayStatus( bool on );
51 virtual bool setDisplayBrightness( int b ); 53 virtual bool setDisplayBrightness( int b );
52 virtual int displayBrightnessResolution() const; 54 virtual int displayBrightnessResolution() const;
53 55
54 virtual void playAlarmSound(); 56 virtual void playAlarmSound();
55 57
56 virtual QValueList <OLed> ledList() const; 58 virtual QValueList <OLed> ledList() const;
57 virtual QValueList <OLedState> ledStateList( OLed led ) const; 59 virtual QValueList <OLedState> ledStateList( OLed led ) const;
58 virtual OLedState ledState( OLed led ) const; 60 virtual OLedState ledState( OLed led ) const;
59 virtual bool setLedState( OLed led, OLedState st ); 61 virtual bool setLedState( OLed led, OLedState st );
60 62
61 protected: 63 protected:
62 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 64 virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
63 virtual void timerEvent( QTimerEvent *te ); 65 virtual void timerEvent( QTimerEvent *te );
64 66
65 int m_power_timer; 67 int m_power_timer;
66 68
67 OLedState m_leds [1]; 69 OLedState m_leds [1];
68}; 70};
69 71
70struct s_button { 72struct s_button {
71 uint model; 73 uint model;
72 Qt::Key code; 74 Qt::Key code;
73 char *utext; 75 char *utext;
74 char *pix; 76 char *pix;
75 char *fpressedservice; 77 char *fpressedservice;
76 char *fpressedaction; 78 char *fpressedaction;
77 char *fheldservice; 79 char *fheldservice;
78 char *fheldaction; 80 char *fheldaction;
79}; 81};
80 82
83}
84}
85}
86
81#endif 87#endif
diff --git a/libopie2/opiecore/device/odevice_yopy.cpp b/libopie2/opiecore/device/odevice_yopy.cpp
index d241db8..f7a4025 100644
--- a/libopie2/opiecore/device/odevice_yopy.cpp
+++ b/libopie2/opiecore/device/odevice_yopy.cpp
@@ -8,97 +8,98 @@ _;:,     .>    :=|. 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_yopy.h" 30#include "odevice_yopy.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie; 56using namespace Opie::Core;
57using namespace Opie::Core::Private;
57 58
58struct yopy_button yopy_buttons [] = { 59struct yopy_button yopy_buttons [] = {
59 { Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Action Button" ), 60 { Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Action Button" ),
60 "devicebuttons/yopy_action", 61 "devicebuttons/yopy_action",
61 "datebook", "nextView()", 62 "datebook", "nextView()",
62 "today", "raise()" }, 63 "today", "raise()" },
63 { Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "OK Button" ), 64 { Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "OK Button" ),
64 "devicebuttons/yopy_ok", 65 "devicebuttons/yopy_ok",
65 "addressbook", "raise()", 66 "addressbook", "raise()",
66 "addressbook", "beamBusinessCard()" }, 67 "addressbook", "beamBusinessCard()" },
67 { Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "End Button" ), 68 { Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "End Button" ),
68 "devicebuttons/yopy_end", 69 "devicebuttons/yopy_end",
69 "QPE/Launcher", "home()", 70 "QPE/Launcher", "home()",
70 "buttonsettings", "raise()" }, 71 "buttonsettings", "raise()" },
71}; 72};
72 73
73void Yopy::init() 74void Yopy::init()
74{ 75{
75 d->m_vendorstr = "G.Mate"; 76 d->m_vendorstr = "G.Mate";
76 d->m_vendor = Vendor_GMate; 77 d->m_vendor = Vendor_GMate;
77 d->m_modelstr = "Yopy3700"; 78 d->m_modelstr = "Yopy3700";
78 d->m_model = Model_Yopy_3700; 79 d->m_model = Model_Yopy_3700;
79 d->m_rotation = Rot0; 80 d->m_rotation = Rot0;
80 81
81 d->m_systemstr = "Linupy"; 82 d->m_systemstr = "Linupy";
82 d->m_system = System_Linupy; 83 d->m_system = System_Linupy;
83 84
84 QFile f ( "/etc/issue" ); 85 QFile f ( "/etc/issue" );
85 if ( f. open ( IO_ReadOnly ) ) 86 if ( f. open ( IO_ReadOnly ) )
86 { 87 {
87 QTextStream ts ( &f ); 88 QTextStream ts ( &f );
88 ts.readLine(); 89 ts.readLine();
89 d->m_sysverstr = ts. readLine(); 90 d->m_sysverstr = ts. readLine();
90 f. close(); 91 f. close();
91 } 92 }
92} 93}
93 94
94 95
95void Yopy::initButtons() 96void Yopy::initButtons()
96{ 97{
97 if ( d->m_buttons ) 98 if ( d->m_buttons )
98 return ; 99 return ;
99 100
100 d->m_buttons = new QValueList <ODeviceButton>; 101 d->m_buttons = new QValueList <ODeviceButton>;
101 102
102 for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ ) 103 for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ )
103 { 104 {
104 105
diff --git a/libopie2/opiecore/device/odevice_yopy.h b/libopie2/opiecore/device/odevice_yopy.h
index be8f62c..7d85479 100644
--- a/libopie2/opiecore/device/odevice_yopy.h
+++ b/libopie2/opiecore/device/odevice_yopy.h
@@ -1,62 +1,67 @@
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#ifndef ODEVICE_YOPY 30#ifndef ODEVICE_YOPY
31#define ODEVICE_YOPY 31#define ODEVICE_YOPY
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34 34
35using namespace Opie; 35namespace Opie {
36 36namespace Core {
37namespace Private {
37class Yopy : public ODevice 38class Yopy : public ODevice
38{ 39{
39 protected: 40 protected:
40 41
41 virtual void init(); 42 virtual void init();
42 virtual void initButtons(); 43 virtual void initButtons();
43 44
44 public: 45 public:
45 virtual bool suspend(); 46 virtual bool suspend();
46 47
47 virtual bool setDisplayBrightness ( int b ); 48 virtual bool setDisplayBrightness ( int b );
48 virtual int displayBrightnessResolution() const; 49 virtual int displayBrightnessResolution() const;
49}; 50};
50 51
51struct yopy_button 52struct yopy_button
52{ 53{
53 Qt::Key code; 54 Qt::Key code;
54 char *utext; 55 char *utext;
55 char *pix; 56 char *pix;
56 char *fpressedservice; 57 char *fpressedservice;
57 char *fpressedaction; 58 char *fpressedaction;
58 char *fheldservice; 59 char *fheldservice;
59 char *fheldaction; 60 char *fheldaction;
60}; 61};
61 62
63}
64}
65}
66
62#endif 67#endif
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 8ab3cbe..0d21f26 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -8,97 +8,98 @@ _;:, .> :=|. 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_zaurus.h" 30#include "odevice_zaurus.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie; 56using namespace Opie::Core;
57using namespace Opie::Core::Private;
57 58
58struct z_button z_buttons [] = { 59struct z_button z_buttons [] = {
59 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 60 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
60 "devicebuttons/z_calendar", 61 "devicebuttons/z_calendar",
61 "datebook", "nextView()", 62 "datebook", "nextView()",
62 "today", "raise()" }, 63 "today", "raise()" },
63 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 64 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
64 "devicebuttons/z_contact", 65 "devicebuttons/z_contact",
65 "addressbook", "raise()", 66 "addressbook", "raise()",
66 "addressbook", "beamBusinessCard()" }, 67 "addressbook", "beamBusinessCard()" },
67 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 68 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
68 "devicebuttons/z_home", 69 "devicebuttons/z_home",
69 "QPE/Launcher", "home()", 70 "QPE/Launcher", "home()",
70 "buttonsettings", "raise()" }, 71 "buttonsettings", "raise()" },
71 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 72 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
72 "devicebuttons/z_menu", 73 "devicebuttons/z_menu",
73 "QPE/TaskBar", "toggleMenu()", 74 "QPE/TaskBar", "toggleMenu()",
74 "QPE/TaskBar", "toggleStartMenu()" }, 75 "QPE/TaskBar", "toggleStartMenu()" },
75 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 76 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
76 "devicebuttons/z_mail", 77 "devicebuttons/z_mail",
77 "mail", "raise()", 78 "mail", "raise()",
78 "mail", "newMail()" }, 79 "mail", "newMail()" },
79}; 80};
80 81
81struct z_button z_buttons_c700 [] = { 82struct z_button z_buttons_c700 [] = {
82 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 83 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
83 "devicebuttons/z_calendar", 84 "devicebuttons/z_calendar",
84 "datebook", "nextView()", 85 "datebook", "nextView()",
85 "today", "raise()" }, 86 "today", "raise()" },
86 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 87 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
87 "devicebuttons/z_contact", 88 "devicebuttons/z_contact",
88 "addressbook", "raise()", 89 "addressbook", "raise()",
89 "addressbook", "beamBusinessCard()" }, 90 "addressbook", "beamBusinessCard()" },
90 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 91 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
91 "devicebuttons/z_home", 92 "devicebuttons/z_home",
92 "QPE/Launcher", "home()", 93 "QPE/Launcher", "home()",
93 "buttonsettings", "raise()" }, 94 "buttonsettings", "raise()" },
94 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 95 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
95 "devicebuttons/z_menu", 96 "devicebuttons/z_menu",
96 "QPE/TaskBar", "toggleMenu()", 97 "QPE/TaskBar", "toggleMenu()",
97 "QPE/TaskBar", "toggleStartMenu()" }, 98 "QPE/TaskBar", "toggleStartMenu()" },
98 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 99 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
99 "devicebuttons/z_hinge", 100 "devicebuttons/z_hinge",
100 "QPE/Rotation", "rotateDefault()", 101 "QPE/Rotation", "rotateDefault()",
101 "QPE/Dummy", "doNothing()" }, 102 "QPE/Dummy", "doNothing()" },
102}; 103};
103 104
104// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 105// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h
index f5c5172..ffb648f 100644
--- a/libopie2/opiecore/device/odevice_zaurus.h
+++ b/libopie2/opiecore/device/odevice_zaurus.h
@@ -1,96 +1,100 @@
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#ifndef ODEVICE_ZAURUS 30#ifndef ODEVICE_ZAURUS
31#define ODEVICE_ZAURUS 31#define ODEVICE_ZAURUS
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34 34
35#ifndef ARRAY_SIZE 35#ifndef ARRAY_SIZE
36#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 36#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
37#endif 37#endif
38 38
39// _IO and friends are only defined in kernel headers ... 39// _IO and friends are only defined in kernel headers ...
40 40
41#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 41#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
42 42
43#define OD_IO(type,number) OD_IOC(0,type,number,0) 43#define OD_IO(type,number) OD_IOC(0,type,number,0)
44#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 44#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
45#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 45#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
46#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 46#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
47 47
48using namespace Opie;
49 48
49namespace Opie {
50namespace Core {
51namespace Private {
50class Zaurus : public ODevice 52class Zaurus : public ODevice
51{ 53{
52 54
53 protected: 55 protected:
54 virtual void init(); 56 virtual void init();
55 virtual void initButtons(); 57 virtual void initButtons();
56 58
57 public: 59 public:
58 virtual bool setSoftSuspend ( bool soft ); 60 virtual bool setSoftSuspend ( bool soft );
59 61
60 virtual bool setDisplayBrightness ( int b ); 62 virtual bool setDisplayBrightness ( int b );
61 virtual int displayBrightnessResolution() const; 63 virtual int displayBrightnessResolution() const;
62 64
63 virtual void playAlarmSound(); 65 virtual void playAlarmSound();
64 virtual void playKeySound(); 66 virtual void playKeySound();
65 virtual void playTouchSound(); 67 virtual void playTouchSound();
66 68
67 virtual QValueList <OLed> ledList() const; 69 virtual QValueList <OLed> ledList() const;
68 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 70 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
69 virtual OLedState ledState( OLed led ) const; 71 virtual OLedState ledState( OLed led ) const;
70 virtual bool setLedState( OLed led, OLedState st ); 72 virtual bool setLedState( OLed led, OLedState st );
71 73
72 virtual bool hasHingeSensor() const; 74 virtual bool hasHingeSensor() const;
73 virtual OHingeStatus readHingeSensor(); 75 virtual OHingeStatus readHingeSensor();
74 76
75 virtual bool suspend(); 77 virtual bool suspend();
76 virtual Transformation rotation() const; 78 virtual Transformation rotation() const;
77 virtual ODirection direction() const; 79 virtual ODirection direction() const;
78 80
79 protected: 81 protected:
80 virtual void buzzer ( int snd ); 82 virtual void buzzer ( int snd );
81 83
82 OLedState m_leds [1]; 84 OLedState m_leds [1];
83 bool m_embedix; 85 bool m_embedix;
84}; 86};
85 87
86struct z_button { 88struct z_button {
87 Qt::Key code; 89 Qt::Key code;
88 char *utext; 90 char *utext;
89 char *pix; 91 char *pix;
90 char *fpressedservice; 92 char *fpressedservice;
91 char *fpressedaction; 93 char *fpressedaction;
92 char *fheldservice; 94 char *fheldservice;
93 char *fheldaction; 95 char *fheldaction;
94}; 96};
95 97}
98}
99}
96#endif 100#endif
diff --git a/libopie2/opiecore/device/odevicebutton.cpp b/libopie2/opiecore/device/odevicebutton.cpp
index 0b593d5..a081b7f 100644
--- a/libopie2/opiecore/device/odevicebutton.cpp
+++ b/libopie2/opiecore/device/odevicebutton.cpp
@@ -1,176 +1,182 @@
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 <qpixmap.h> 30#include <qpixmap.h>
31#include <qstring.h> 31#include <qstring.h>
32 32
33#include <qpe/qcopenvelope_qws.h> 33#include <qpe/qcopenvelope_qws.h>
34#include <opie2/odevicebutton.h> 34#include <opie2/odevicebutton.h>
35 35
36using namespace Opie; 36
37namespace Opie {
38namespace Core {
39namespace Private {
37 40
38class OQCopMessageData 41class OQCopMessageData
39{ 42{
40 public: 43 public:
41 QCString m_channel; 44 QCString m_channel;
42 QCString m_message; 45 QCString m_message;
43 QByteArray m_data; 46 QByteArray m_data;
44}; 47};
48}
45 49
50using namespace Opie::Core;
51using namespace Opie::Core::Private;
46 52
47OQCopMessage::OQCopMessage() 53OQCopMessage::OQCopMessage()
48 : d ( 0 ) 54 : d ( 0 )
49{ 55{
50 init ( QCString(), QCString(), QByteArray()); 56 init ( QCString(), QCString(), QByteArray());
51} 57}
52 58
53OQCopMessage::OQCopMessage ( const OQCopMessage &copy ) 59OQCopMessage::OQCopMessage ( const OQCopMessage &copy )
54 : d ( 0 ) 60 : d ( 0 )
55{ 61{
56 init ( copy. channel(), copy. message(), copy. data()); 62 init ( copy. channel(), copy. message(), copy. data());
57} 63}
58 64
59OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign ) 65OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign )
60{ 66{
61 init ( assign. channel(), assign. message(), assign. data()); 67 init ( assign. channel(), assign. message(), assign. data());
62 return *this; 68 return *this;
63} 69}
64 70
65OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg ) 71OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg )
66 : d ( 0 ) 72 : d ( 0 )
67{ 73{
68 init ( ch, m, arg ); 74 init ( ch, m, arg );
69} 75}
70 76
71void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg ) 77void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg )
72{ 78{
73 if ( !d ) 79 if ( !d )
74 d = new OQCopMessageData(); 80 d = new OQCopMessageData();
75 d->m_channel = ch; 81 d->m_channel = ch;
76 d->m_message = m; 82 d->m_message = m;
77 d->m_data = arg; 83 d->m_data = arg;
78} 84}
79 85
80bool OQCopMessage::send() 86bool OQCopMessage::send()
81{ 87{
82 if ( d->m_channel. isEmpty() || d->m_message. isEmpty() ) 88 if ( d->m_channel. isEmpty() || d->m_message. isEmpty() )
83 return false; 89 return false;
84 90
85 QCopEnvelope e ( d->m_channel, d->m_message ); 91 QCopEnvelope e ( d->m_channel, d->m_message );
86 92
87 if ( d->m_data. size()) 93 if ( d->m_data. size())
88 e. writeRawBytes ( d->m_data. data(), d->m_data. size()); 94 e. writeRawBytes ( d->m_data. data(), d->m_data. size());
89 95
90 return true; 96 return true;
91} 97}
92 98
93QCString OQCopMessage::channel() const 99QCString OQCopMessage::channel() const
94{ 100{
95 return d->m_channel; 101 return d->m_channel;
96} 102}
97 103
98QCString OQCopMessage::message() const 104QCString OQCopMessage::message() const
99{ 105{
100 return d->m_message; 106 return d->m_message;
101} 107}
102 108
103QByteArray OQCopMessage::data() const 109QByteArray OQCopMessage::data() const
104{ 110{
105 return d->m_data; 111 return d->m_data;
106} 112}
107 113
108bool OQCopMessage::isNull() const 114bool OQCopMessage::isNull() const
109{ 115{
110 return d->m_message.isNull() || d->m_channel.isNull(); 116 return d->m_message.isNull() || d->m_channel.isNull();
111} 117}
112void OQCopMessage::setChannel ( const QCString &ch ) 118void OQCopMessage::setChannel ( const QCString &ch )
113{ 119{
114 d->m_channel = ch; 120 d->m_channel = ch;
115} 121}
116 122
117void OQCopMessage::setMessage ( const QCString &m ) 123void OQCopMessage::setMessage ( const QCString &m )
118{ 124{
119 d->m_message = m; 125 d->m_message = m;
120} 126}
121 127
122void OQCopMessage::setData ( const QByteArray &data ) 128void OQCopMessage::setData ( const QByteArray &data )
123{ 129{
124 d->m_data = data; 130 d->m_data = data;
125} 131}
126 132
127/*! \class Opie::ODeviceButton 133/*! \class Opie::Core::ODeviceButton
128 \brief The Opie::ODeviceButton class represents a physical user mappable button on a Qtopia device. 134 \brief The Opie::Core::ODeviceButton class represents a physical user mappable button on a Qtopia device.
129 135
130 This class represents a physical button on a Qtopia device. A 136 This class represents a physical button on a Qtopia device. A
131 device may have "user programmable" buttons. 137 device may have "user programmable" buttons.
132 The location and number of buttons will vary from device to 138 The location and number of buttons will vary from device to
133 device. userText() and pixmap() may be used to describe this button 139 device. userText() and pixmap() may be used to describe this button
134 to the user in help documentation. 140 to the user in help documentation.
135 141
136 \ingroup qtopiaemb 142 \ingroup qtopiaemb
137 \internal 143 \internal
138*/ 144*/
139 145
140ODeviceButton::ODeviceButton() 146ODeviceButton::ODeviceButton()
141{} 147{}
142 148
143ODeviceButton::~ODeviceButton() 149ODeviceButton::~ODeviceButton()
144{} 150{}
145 151
146/*! 152/*!
147Returns the button's keycode. 153Returns the button's keycode.
148*/ 154*/
149ushort ODeviceButton::keycode() const 155ushort ODeviceButton::keycode() const
150{ 156{
151 return m_Keycode; 157 return m_Keycode;
152} 158}
153 159
154 160
155/*! 161/*!
156This function returns a human readable, translated description of the button. 162This function returns a human readable, translated description of the button.
157*/ 163*/
158QString ODeviceButton::userText() const 164QString ODeviceButton::userText() const
159{ 165{
160 return m_UserText; 166 return m_UserText;
161} 167}
162 168
163/*! 169/*!
164This function returns the pixmap for this button. If there isn't one 170This function returns the pixmap for this button. If there isn't one
165it will return an empty (null) pixmap. 171it will return an empty (null) pixmap.
166*/ 172*/
167QPixmap ODeviceButton::pixmap() const 173QPixmap ODeviceButton::pixmap() const
168{ 174{
169 return m_Pixmap; 175 return m_Pixmap;
170} 176}
171 177
172/*! 178/*!
173This function returns the factory preset (default) action for when this button 179This function returns the factory preset (default) action for when this button
174is pressed. The return value is a legal QCop message. 180is pressed. The return value is a legal QCop message.
175*/ 181*/
176OQCopMessage ODeviceButton::factoryPresetPressedAction() const 182OQCopMessage ODeviceButton::factoryPresetPressedAction() const
@@ -199,48 +205,51 @@ OQCopMessage ODeviceButton::factoryPresetHeldAction() const
199} 205}
200 206
201/*! 207/*!
202This function returns the user assigned action for when this button is pressed 208This function returns the user assigned action for when this button is pressed
203and held. If no action is assigned, factoryPresetAction() is returned. 209and held. If no action is assigned, factoryPresetAction() is returned.
204*/ 210*/
205OQCopMessage ODeviceButton::heldAction() const 211OQCopMessage ODeviceButton::heldAction() const
206{ 212{
207 if (m_HeldAction.channel().isEmpty()) 213 if (m_HeldAction.channel().isEmpty())
208 return factoryPresetHeldAction(); 214 return factoryPresetHeldAction();
209 return m_HeldAction; 215 return m_HeldAction;
210} 216}
211 217
212void ODeviceButton::setKeycode(ushort keycode) 218void ODeviceButton::setKeycode(ushort keycode)
213{ 219{
214 m_Keycode = keycode; 220 m_Keycode = keycode;
215} 221}
216 222
217void ODeviceButton::setUserText(const QString& text) 223void ODeviceButton::setUserText(const QString& text)
218{ 224{
219 m_UserText = text; 225 m_UserText = text;
220} 226}
221 227
222void ODeviceButton::setPixmap(const QPixmap& picture) 228void ODeviceButton::setPixmap(const QPixmap& picture)
223{ 229{
224 m_Pixmap = picture; 230 m_Pixmap = picture;
225} 231}
226 232
227void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action) 233void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action)
228{ 234{
229 m_FactoryPresetPressedAction = action; 235 m_FactoryPresetPressedAction = action;
230} 236}
231 237
232 238
233void ODeviceButton::setPressedAction(const OQCopMessage& action) 239void ODeviceButton::setPressedAction(const OQCopMessage& action)
234{ 240{
235 m_PressedAction = action; 241 m_PressedAction = action;
236} 242}
237 243
238void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action) 244void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action)
239{ 245{
240 m_FactoryPresetHeldAction = action; 246 m_FactoryPresetHeldAction = action;
241} 247}
242 248
243void ODeviceButton::setHeldAction(const OQCopMessage& action) 249void ODeviceButton::setHeldAction(const OQCopMessage& action)
244{ 250{
245 m_HeldAction = action; 251 m_HeldAction = action;
246} 252}
253
254}
255}
diff --git a/libopie2/opiecore/device/odevicebutton.h b/libopie2/opiecore/device/odevicebutton.h
index a66b88f..4000144 100644
--- a/libopie2/opiecore/device/odevicebutton.h
+++ b/libopie2/opiecore/device/odevicebutton.h
@@ -1,108 +1,111 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef DEVICE_BUTTON_H 20#ifndef DEVICE_BUTTON_H
21#define DEVICE_BUTTON_H 21#define DEVICE_BUTTON_H
22 22
23#include <qpixmap.h> 23#include <qpixmap.h>
24#include <qstring.h> 24#include <qstring.h>
25 25
26class OQCopMessageData;
27 26
28namespace Opie 27namespace Opie{
29{ 28namespace Core{
29namespace Private {
30class OQCopMessageData;
31}
30 32
31class OQCopMessage 33class OQCopMessage
32{ 34{
33public: 35public:
34 OQCopMessage ( ); 36 OQCopMessage ( );
35 OQCopMessage ( const OQCopMessage &copy ); 37 OQCopMessage ( const OQCopMessage &copy );
36 OQCopMessage ( const QCString &m_channel, const QCString &message, const QByteArray &args = QByteArray ( )); 38 OQCopMessage ( const QCString &m_channel, const QCString &message, const QByteArray &args = QByteArray ( ));
37 39
38 OQCopMessage &operator = ( const OQCopMessage &assign ); 40 OQCopMessage &operator = ( const OQCopMessage &assign );
39 41
40 void setChannel ( const QCString &channel ); 42 void setChannel ( const QCString &channel );
41 void setMessage ( const QCString &message ); 43 void setMessage ( const QCString &message );
42 void setData ( const QByteArray &ba ); 44 void setData ( const QByteArray &ba );
43 45
44 QCString channel ( ) const; 46 QCString channel ( ) const;
45 QCString message ( ) const; 47 QCString message ( ) const;
46 QByteArray data ( ) const; 48 QByteArray data ( ) const;
47 49
48 bool isNull()const; 50 bool isNull()const;
49 51
50 bool send ( ); 52 bool send ( );
51 53
52private: 54private:
53 void init ( const QCString &m_channel, const QCString &message, const QByteArray &args ); 55 void init ( const QCString &m_channel, const QCString &message, const QByteArray &args );
54 56
55 OQCopMessageData *d; 57 Private::OQCopMessageData *d;
56 class Private; 58 class Private;
57 Private* m_data; 59 Private* m_data;
58}; 60};
59 61
60 62
61/** 63/**
62 * This class represents a physical button on a Qtopia device. A device may 64 * This class represents a physical button on a Qtopia device. A device may
63 * have n "user programmable" buttons, which are number 1..n. The location 65 * have n "user programmable" buttons, which are number 1..n. The location
64 * and number of buttons will vary from device to device. userText() and pixmap() 66 * and number of buttons will vary from device to device. userText() and pixmap()
65 * may be used to describe this button to the user in help documentation. 67 * may be used to describe this button to the user in help documentation.
66 * 68 *
67 * @version 1.0 69 * @version 1.0
68 * @author Trolltech 70 * @author Trolltech
69 * @short A representation of buttons 71 * @short A representation of buttons
70 */ 72 */
71 73
72class ODeviceButton 74class ODeviceButton
73{ 75{
74 public: 76 public:
75 ODeviceButton(); 77 ODeviceButton();
76 virtual ~ODeviceButton(); 78 virtual ~ODeviceButton();
77 79
78 ushort keycode ( ) const; 80 ushort keycode ( ) const;
79 QString userText ( ) const; 81 QString userText ( ) const;
80 QPixmap pixmap ( ) const; 82 QPixmap pixmap ( ) const;
81 OQCopMessage factoryPresetPressedAction ( ) const; 83 OQCopMessage factoryPresetPressedAction ( ) const;
82 OQCopMessage pressedAction ( ) const; 84 OQCopMessage pressedAction ( ) const;
83 OQCopMessage factoryPresetHeldAction ( ) const; 85 OQCopMessage factoryPresetHeldAction ( ) const;
84 OQCopMessage heldAction ( ) const; 86 OQCopMessage heldAction ( ) const;
85 87
86 void setKeycode ( ushort keycode ); 88 void setKeycode ( ushort keycode );
87 void setUserText ( const QString& text ); 89 void setUserText ( const QString& text );
88 void setPixmap ( const QPixmap& picture ); 90 void setPixmap ( const QPixmap& picture );
89 void setFactoryPresetPressedAction ( const OQCopMessage& qcopMessage ); 91 void setFactoryPresetPressedAction ( const OQCopMessage& qcopMessage );
90 void setPressedAction ( const OQCopMessage& qcopMessage ); 92 void setPressedAction ( const OQCopMessage& qcopMessage );
91 void setFactoryPresetHeldAction ( const OQCopMessage& qcopMessage ); 93 void setFactoryPresetHeldAction ( const OQCopMessage& qcopMessage );
92 void setHeldAction ( const OQCopMessage& qcopMessage ); 94 void setHeldAction ( const OQCopMessage& qcopMessage );
93 95
94 private: 96 private:
95 ushort m_Keycode; 97 ushort m_Keycode;
96 QString m_UserText; 98 QString m_UserText;
97 QPixmap m_Pixmap; 99 QPixmap m_Pixmap;
98 OQCopMessage m_FactoryPresetPressedAction; 100 OQCopMessage m_FactoryPresetPressedAction;
99 OQCopMessage m_PressedAction; 101 OQCopMessage m_PressedAction;
100 OQCopMessage m_FactoryPresetHeldAction; 102 OQCopMessage m_FactoryPresetHeldAction;
101 OQCopMessage m_HeldAction; 103 OQCopMessage m_HeldAction;
102 class Private; 104 class Private;
103 Private *d; 105 Private *d;
104}; 106};
105 107
106} 108}
109}
107 110
108#endif 111#endif
diff --git a/libopie2/opiecore/oapplication.cpp b/libopie2/opiecore/oapplication.cpp
index d340c0e..e2f6e82 100644
--- a/libopie2/opiecore/oapplication.cpp
+++ b/libopie2/opiecore/oapplication.cpp
@@ -1,127 +1,136 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> 3              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
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 <opie2/oapplication.h> 30#include <opie2/oapplication.h>
31#include <opie2/oconfig.h> 31#include <opie2/oconfig.h>
32#include <opie2/odebug.h> 32#include <opie2/odebug.h>
33 33
34#include <signal.h> 34#include <signal.h>
35#include <stdio.h> 35#include <stdio.h>
36 36
37using namespace Opie::Core;
38
39
37OApplication* OApplication::_instance = 0; 40OApplication* OApplication::_instance = 0;
38 41
39/************************************************************************************************** 42/**************************************************************************************************
40 * OApplicationPrivate 43 * OApplicationPrivate
41 **************************************************************************************************/ 44 **************************************************************************************************/
42 45
46namespace Opie {
47namespace Core {
48namespace Private {
43class OApplicationPrivate 49class OApplicationPrivate
44{ 50{
45 public: 51 public:
46 OApplicationPrivate() {}; 52 OApplicationPrivate() {};
47 ~OApplicationPrivate() {}; 53 ~OApplicationPrivate() {};
48}; 54};
55}
49 56
50/************************************************************************************************** 57/**************************************************************************************************
51 * OApplication 58 * OApplication
52 **************************************************************************************************/ 59 **************************************************************************************************/
53 60
54 61
55OApplication::OApplication( int& argc, char** argv, const QCString& rAppName ) 62OApplication::OApplication( int& argc, char** argv, const QCString& rAppName )
56 :QPEApplication( argc, argv ), 63 :QPEApplication( argc, argv ),
57 _appname( rAppName ), 64 _appname( rAppName ),
58 _config( 0 ) 65 _config( 0 )
59{ 66{
60 init(); 67 init();
61} 68}
62 69
63 70
64OApplication::~OApplication() 71OApplication::~OApplication()
65{ 72{
66 delete d; 73 delete d;
67 if ( _config ) 74 if ( _config )
68 delete _config; 75 delete _config;
69 OApplication::_instance = 0; 76 OApplication::_instance = 0;
70 // after deconstruction of the one-and-only application object, 77 // after deconstruction of the one-and-only application object,
71 // the construction of another object is allowed 78 // the construction of another object is allowed
72} 79}
73 80
74 81
75OConfig* OApplication::config() 82OConfig* OApplication::config()
76{ 83{
77 if ( !_config ) 84 if ( !_config )
78 { 85 {
79 _config = new OConfig( _appname ); 86 _config = new OConfig( _appname );
80 } 87 }
81 return _config; 88 return _config;
82} 89}
83 90
84 91
85void OApplication::init() 92void OApplication::init()
86{ 93{
87 d = new OApplicationPrivate(); 94 d = new Private::OApplicationPrivate();
88 if ( !OApplication::_instance ) 95 if ( !OApplication::_instance )
89 { 96 {
90 OApplication::_instance = this; 97 OApplication::_instance = this;
91 98
92 /* register SIGSEGV handler to give programs an option 99 /* register SIGSEGV handler to give programs an option
93 * to exit gracefully, e.g. save or close devices or files. 100 * to exit gracefully, e.g. save or close devices or files.
94 struct sigaction sa; 101 struct sigaction sa;
95 sa.sa_handler = ( void (*)(int) ) &segv_handler; 102 sa.sa_handler = ( void (*)(int) ) &segv_handler;
96 sa.sa_flags = SA_SIGINFO | SA_RESTART; 103 sa.sa_flags = SA_SIGINFO | SA_RESTART;
97 sigemptyset(&sa.sa_mask); 104 sigemptyset(&sa.sa_mask);
98 sigaction(SIGSEGV, &sa, NULL); 105 sigaction(SIGSEGV, &sa, NULL);
99 */ 106 */
100 } 107 }
101 else 108 else
102 { 109 {
103 ofatal << "OApplication: Can't create more than one OApplication object. Aborting." << oendl; 110 ofatal << "OApplication: Can't create more than one OApplication object. Aborting." << oendl;
104 //FIXME exit gracefully ? 111 //FIXME exit gracefully ?
105 ::exit( -1 ); 112 ::exit( -1 );
106 } 113 }
107} 114}
108 115
109 116
110void OApplication::showMainWidget( QWidget* widget, bool nomax ) 117void OApplication::showMainWidget( QWidget* widget, bool nomax )
111{ 118{
112 QPEApplication::showMainWidget( widget, nomax ); 119 QPEApplication::showMainWidget( widget, nomax );
113 widget->setCaption( _appname ); 120 widget->setCaption( _appname );
114} 121}
115 122
116 123
117void OApplication::setTitle( const QString& title ) const 124void OApplication::setTitle( const QString& title ) const
118{ 125{
119 if ( mainWidget() ) 126 if ( mainWidget() )
120 { 127 {
121 if ( !title.isNull() ) 128 if ( !title.isNull() )
122 mainWidget()->setCaption( QString(_appname) + QString( " - " ) + title ); 129 mainWidget()->setCaption( QString(_appname) + QString( " - " ) + title );
123 else 130 else
124 mainWidget()->setCaption( _appname ); 131 mainWidget()->setCaption( _appname );
125 } 132 }
126} 133}
127 134
135}
136}
diff --git a/libopie2/opiecore/oapplication.h b/libopie2/opiecore/oapplication.h
index cc506a2..c1e32a6 100644
--- a/libopie2/opiecore/oapplication.h
+++ b/libopie2/opiecore/oapplication.h
@@ -1,104 +1,111 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> 3              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
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#ifndef OAPPLICATION_H 30#ifndef OAPPLICATION_H
31#define OAPPLICATION_H 31#define OAPPLICATION_H
32 32
33#define oApp OApplication::oApplication() 33#define oApp Opie::Core::OApplication::oApplication()
34 34
35 35
36#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
37 37
38 38namespace Opie {
39namespace Core {
40namespace Private {
39class OApplicationPrivate; 41class OApplicationPrivate;
42} // private class
43
40class OConfig; 44class OConfig;
41 45
42 46
43class OApplication : public QPEApplication 47class OApplication : public QPEApplication
44{ 48{
45 Q_OBJECT 49 Q_OBJECT
46 50
47 public: 51 public:
48 /** 52 /**
49 * Constructor. Parses command-line arguments and sets the window caption. 53 * Constructor. Parses command-line arguments and sets the window caption.
50 * 54 *
51 * @param rAppName application name. Will be used for finding the 55 * @param rAppName application name. Will be used for finding the
52 * associated message, icon and configuration files 56 * associated message, icon and configuration files
53 * 57 *
54 */ 58 */
55 OApplication( int& argc, char** argv, const QCString& rAppName ); 59 OApplication( int& argc, char** argv, const QCString& rAppName );
56 /** 60 /**
57 * Destructor. Destroys the application object and its children. 61 * Destructor. Destroys the application object and its children.
58 */ 62 */
59 virtual ~OApplication(); 63 virtual ~OApplication();
60 /** 64 /**
61 * @returns the process-wide application object 65 * @returns the process-wide application object
62 * 66 *
63 * This is similar to the global @ref QApplication pointer qApp. It 67 * This is similar to the global @ref QApplication pointer qApp. It
64 * allows access to the single global OApplication object, since 68 * allows access to the single global OApplication object, since
65 * more than one cannot be created in the same application. It 69 * more than one cannot be created in the same application. It
66 * saves you the trouble of having to pass the pointer explicitly 70 * saves you the trouble of having to pass the pointer explicitly
67 * to every function that may require it. 71 * to every function that may require it.
68 */ 72 */
69 static OApplication* oApplication() { return _instance; }; 73 static OApplication* oApplication() { return _instance; };
70 /** 74 /**
71 * Returns the application name as given during creation. 75 * Returns the application name as given during creation.
72 * 76 *
73 * @returns a reference to the application name 77 * @returns a reference to the application name
74 */ 78 */
75 const QCString& appName() const { return _appname; }; 79 const QCString& appName() const { return _appname; };
76 /** 80 /**
77 * @returns the application session config object. 81 * @returns the application session config object.
78 * 82 *
79 * @see OConfig 83 * @see OConfig
80 */ 84 */
81 OConfig* config(); 85 OConfig* config();
82 /** 86 /**
83 * Shows the main @a widget and sets the name of the application as window caption. 87 * Shows the main @a widget and sets the name of the application as window caption.
84 */ 88 */
85 virtual void showMainWidget( QWidget* widget, bool nomax = false ); 89 virtual void showMainWidget( QWidget* widget, bool nomax = false );
86 /** 90 /**
87 * Set the application title. The application title will be concatenated 91 * Set the application title. The application title will be concatenated
88 * to the application name given in the constructor. 92 * to the application name given in the constructor.
89 * 93 *
90 * @param title the title. If not given, resets caption to appname 94 * @param title the title. If not given, resets caption to appname
91 */ 95 */
92 virtual void setTitle( const QString& title = QString::null ) const; 96 virtual void setTitle( const QString& title = QString::null ) const;
93 97
94 protected: 98 protected:
95 void init(); 99 void init();
96 100
97 private: 101 private:
98 const QCString _appname; 102 const QCString _appname;
99 static OApplication* _instance; 103 static OApplication* _instance;
100 OConfig* _config; 104 OConfig* _config;
101 OApplicationPrivate* d; 105 Private::OApplicationPrivate* d;
102}; 106};
103 107
108} // Core
109} // Opie
110
104#endif // OAPPLICATION_H 111#endif // OAPPLICATION_H
diff --git a/libopie2/opiecore/oconfig.cpp b/libopie2/opiecore/oconfig.cpp
index fb5eabb..05d8070 100644
--- a/libopie2/opiecore/oconfig.cpp
+++ b/libopie2/opiecore/oconfig.cpp
@@ -1,88 +1,90 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4 (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> 4 (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 Inspired by the config classes from the KDE Project which are 5 Inspired by the config classes from the KDE Project which are
6 =. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org> 6 =. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org>
7 .=l. 7 .=l.
8           .>+-= 8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can 9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under 10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software 12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License, 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version. 14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_. 15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that 16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of 18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 22++=   -.     .`     .: details.
23 :     =  ...= . :.=- 23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30*/ 30*/
31 31
32/* QT */ 32/* QT */
33 33
34#include <qfont.h> 34#include <qfont.h>
35#include <qcolor.h> 35#include <qcolor.h>
36 36
37/* OPIE */ 37/* OPIE */
38 38
39#include <opie2/oconfig.h> 39#include <opie2/oconfig.h>
40 40
41using namespace Opie::Core;
42
41OConfig::OConfig( const QString &name, Domain domain ) 43OConfig::OConfig( const QString &name, Domain domain )
42 :Config( name, domain ) 44 :Config( name, domain )
43{ 45{
44 qDebug( "OConfig::OConfig()" ); 46 qDebug( "OConfig::OConfig()" );
45} 47}
46 48
47OConfig::~OConfig() 49OConfig::~OConfig()
48{ 50{
49 qDebug( "OConfig::~OConfig()" ); 51 qDebug( "OConfig::~OConfig()" );
50} 52}
51 53
52QColor OConfig::readColorEntry( const QString& key, const QColor* pDefault ) const 54QColor OConfig::readColorEntry( const QString& key, const QColor* pDefault ) const
53{ 55{
54 QColor aRetColor; 56 QColor aRetColor;
55 int nRed = 0, nGreen = 0, nBlue = 0; 57 int nRed = 0, nGreen = 0, nBlue = 0;
56 58
57 QString aValue = readEntry( key ); 59 QString aValue = readEntry( key );
58 if( !aValue.isEmpty() ) 60 if( !aValue.isEmpty() )
59 { 61 {
60 if ( aValue.at(0) == '#' ) 62 if ( aValue.at(0) == '#' )
61 { 63 {
62 aRetColor.setNamedColor(aValue); 64 aRetColor.setNamedColor(aValue);
63 } 65 }
64 else 66 else
65 { 67 {
66 bool bOK; 68 bool bOK;
67 69
68 // find first part (red) 70 // find first part (red)
69 int nIndex = aValue.find( ',' ); 71 int nIndex = aValue.find( ',' );
70 72
71 if( nIndex == -1 ) 73 if( nIndex == -1 )
72 { 74 {
73 // return a sensible default -- Bernd 75 // return a sensible default -- Bernd
74 if( pDefault ) 76 if( pDefault )
75 aRetColor = *pDefault; 77 aRetColor = *pDefault;
76 return aRetColor; 78 return aRetColor;
77 } 79 }
78 80
79 nRed = aValue.left( nIndex ).toInt( &bOK ); 81 nRed = aValue.left( nIndex ).toInt( &bOK );
80 82
81 // find second part (green) 83 // find second part (green)
82 int nOldIndex = nIndex; 84 int nOldIndex = nIndex;
83 nIndex = aValue.find( ',', nOldIndex+1 ); 85 nIndex = aValue.find( ',', nOldIndex+1 );
84 86
85 if( nIndex == -1 ) 87 if( nIndex == -1 )
86 { 88 {
87 // return a sensible default -- Bernd 89 // return a sensible default -- Bernd
88 if( pDefault ) 90 if( pDefault )
diff --git a/libopie2/opiecore/oconfig.h b/libopie2/opiecore/oconfig.h
index becf70d..29c1f86 100644
--- a/libopie2/opiecore/oconfig.h
+++ b/libopie2/opiecore/oconfig.h
@@ -1,141 +1,154 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4 (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 4 (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 Inspired by the config classes from the KDE Project which are 5 Inspired by the config classes from the KDE Project which are
6 =. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org> 6 =. (C) 1997 Matthias Kalle Dalheimer <kalle@kde.org>
7 .=l. 7 .=l.
8           .>+-= 8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can 9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under 10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software 12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License, 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version. 14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_. 15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that 16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of 18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 22++=   -.     .`     .: details.
23 :     =  ...= . :.=- 23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30*/ 30*/
31 31
32#ifndef OCONFIG_H 32#ifndef OCONFIG_H
33#define OCONFIG_H 33#define OCONFIG_H
34 34
35//FIXME: Implement for X11 or reuse libqpe/Config there also? 35//FIXME: Implement for X11 or reuse libqpe/Config there also?
36//FIXME: Or rather use QSettings also for libqpe? 36//FIXME: Or rather use QSettings also for libqpe?
37 37
38#include <qpe/config.h> 38#include <qpe/config.h>
39 39
40class QColor; 40class QColor;
41class QFont; 41class QFont;
42 42
43namespace Opie {
44namespace Core {
45
43/** 46/**
44 * A Configuration class based on the Qtopia @ref Config class 47 * A Configuration class based on the Qtopia @ref Config class
45 * featuring additional handling of color and font entries 48 * featuring additional handling of color and font entries
46 */ 49 */
47 50
48class OConfig : public Config 51class OConfig : public Config
49{ 52{
50 public: 53 public:
51 /** 54 /**
52 * Constructs a OConfig object with a @a name. 55 * Constructs a OConfig object with a @a name.
53 */ 56 */
54 OConfig( const QString &name, Domain domain = User ); 57 OConfig( const QString &name, Domain domain = User );
55 /** 58 /**
56 * Destructs the OConfig object. 59 * Destructs the OConfig object.
57 * 60 *
58 * Writes back any dirty configuration entries, and destroys 61 * Writes back any dirty configuration entries, and destroys
59 * dynamically created objects. 62 * dynamically created objects.
60 */ 63 */
61 virtual ~OConfig(); 64 virtual ~OConfig();
62 /** 65 /**
63 * @returns the name of the current group. 66 * @returns the name of the current group.
64 * The current group is used for searching keys and accessing entries. 67 * The current group is used for searching keys and accessing entries.
68 * @todo make const
65 */ 69 */
66 const QString& group() { return git.key(); }; 70 const QString& group() { return git.key(); };
67 /** 71 /**
68 * @returns a @ref QColor entry or a @a default value if the key is not found. 72 * @returns a @ref QColor entry or a @a default value if the key is not found.
69 */ 73 */
70 QColor readColorEntry( const QString& key, const QColor* pDefault ) const; 74 QColor readColorEntry( const QString& key, const QColor* pDefault ) const;
71 /** 75 /**
72 * @returns a @ref QFont value or a @a default value if the key is not found. 76 * @returns a @ref QFont value or a @a default value if the key is not found.
73 */ 77 */
74 QFont readFontEntry( const QString& key, const QFont* pDefault ) const; 78 QFont readFontEntry( const QString& key, const QFont* pDefault ) const;
79
80private:
81 class Private;
82 Private *d;
75}; 83};
76 84
77/** 85/**
78 * @brief Helper class for easier use of OConfig groups. 86 * @brief Helper class for easier use of OConfig groups.
79 * 87 *
80 * Careful programmers always set the group of a 88 * Careful programmers always set the group of a
81 * @ref OConfig object to the group they want to read from 89 * @ref OConfig object to the group they want to read from
82 * and set it back to the old one of afterwards. This is usually 90 * and set it back to the old one of afterwards. This is usually
83 * written as: 91 * written as:
84 * <pre> 92 * <pre>
85 * 93 *
86 * QString oldgroup config()->group(); 94 * QString oldgroup config()->group();
87 * config()->setGroup( "TheGroupThatIWant" ); 95 * config()->setGroup( "TheGroupThatIWant" );
88 * ... 96 * ...
89 * config()->writeEntry( "Blah", "Blubb" ); 97 * config()->writeEntry( "Blah", "Blubb" );
90 * 98 *
91 * config()->setGroup( oldgroup ); 99 * config()->setGroup( oldgroup );
92 * </pre> 100 * </pre>
93 * 101 *
94 * In order to facilitate this task, you can use 102 * In order to facilitate this task, you can use
95 * OConfigGroupSaver. Simply construct such an object ON THE STACK 103 * OConfigGroupSaver. Simply construct such an object ON THE STACK
96 * when you want to switch to a new group. Then, when the object goes 104 * when you want to switch to a new group. Then, when the object goes
97 * out of scope, the group will automatically be restored. If you 105 * out of scope, the group will automatically be restored. If you
98 * want to use several different groups within a function or method, 106 * want to use several different groups within a function or method,
99 * you can still use OConfigGroupSaver: Simply enclose all work with 107 * you can still use OConfigGroupSaver: Simply enclose all work with
100 * one group (including the creation of the OConfigGroupSaver object) 108 * one group (including the creation of the OConfigGroupSaver object)
101 * in one block. 109 * in one block.
102 * 110 *
103 * @author Matthias Kalle Dalheimer <Kalle@kde.org> 111 * @author Matthias Kalle Dalheimer <Kalle@kde.org>
104 * @version $Id$ 112 * @version $Id$
105 * @see OConfig 113 * @see OConfig
106 */ 114 */
107 115
108class OConfigGroupSaver 116class OConfigGroupSaver
109{ 117{
110 public: 118 public:
111 /** 119 /**
112 * Constructor. 120 * Constructor.
113 * Create the object giving a @config object and a @a group to become 121 * Create the object giving a @config object and a @a group to become
114 * the current group. 122 * the current group.
115 */ 123 */
116 OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() ) 124 OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() )
117 { _config->setGroup( group ); } 125 { _config->setGroup( group ); }
118 126
119 OConfigGroupSaver( OConfig* config, const char *group ) :_config(config), _oldgroup(config->group()) 127 OConfigGroupSaver( OConfig* config, const char *group ) :_config(config), _oldgroup(config->group())
120 { _config->setGroup( group ); } 128 { _config->setGroup( group ); }
121 129
122 OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group()) 130 OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group())
123 { _config->setGroup( group ); } 131 { _config->setGroup( group ); }
124 /** 132 /**
125 * Destructor. 133 * Destructor.
126 * Restores the last current group. 134 * Restores the last current group.
127 * @todo make it not inline for bc reasons. See KDE BC guide 135 * @todo make it not inline for bc reasons. See KDE BC guide
128 */ 136 */
129 ~OConfigGroupSaver() { _config->setGroup( _oldgroup ); } 137 ~OConfigGroupSaver() { _config->setGroup( _oldgroup ); }
130 138
131 OConfig* config() { return _config; }; 139 OConfig* config() { return _config; };
132 140
133 private: 141 private:
134 OConfig* _config; 142 OConfig* _config;
135 QString _oldgroup; 143 QString _oldgroup;
136 144
137 OConfigGroupSaver( const OConfigGroupSaver& ); 145 OConfigGroupSaver( const OConfigGroupSaver& );
138 OConfigGroupSaver& operator=( const OConfigGroupSaver& ); 146 OConfigGroupSaver& operator=( const OConfigGroupSaver& );
147
148 class Private;
149 Private *d;
139}; 150};
151}
152}
140 153
141#endif // OCONFIG_H 154#endif // OCONFIG_H
diff --git a/libopie2/opiecore/odebug.cpp b/libopie2/opiecore/odebug.cpp
index a40ef53..cac985b 100644
--- a/libopie2/opiecore/odebug.cpp
+++ b/libopie2/opiecore/odebug.cpp
@@ -20,97 +20,98 @@
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 22++=   -.     .`     .: details.
23 :     =  ...= . :.=- 23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30*/ 30*/
31 31
32// Include this header without OPIE_NO_DEBUG defined to avoid having the oDebugInfo 32// Include this header without OPIE_NO_DEBUG defined to avoid having the oDebugInfo
33// functions inlined to noops (which would then conflict with their definition here). 33// functions inlined to noops (which would then conflict with their definition here).
34 34
35#include <opie2/odebug.h> 35#include <opie2/odebug.h>
36 36
37#ifdef OPIE_NO_DEBUG 37#ifdef OPIE_NO_DEBUG
38#undef odDebug 38#undef odDebug
39#undef odBacktrace 39#undef odBacktrace
40#endif 40#endif
41 41
42/* OPIE */ 42/* OPIE */
43 43
44#include <opie2/oapplication.h> 44#include <opie2/oapplication.h>
45#include <opie2/oglobalsettings.h> 45#include <opie2/oglobalsettings.h>
46#include <opie2/oconfig.h> 46#include <opie2/oconfig.h>
47 47
48/* QT */ 48/* QT */
49 49
50#include <qfile.h> 50#include <qfile.h>
51#include <qmessagebox.h> 51#include <qmessagebox.h>
52#include <qsocketdevice.h> 52#include <qsocketdevice.h>
53 53
54/* UNIX */ 54/* UNIX */
55 55
56#include <stdlib.h> // abort 56#include <stdlib.h> // abort
57#include <unistd.h> // getpid 57#include <unistd.h> // getpid
58#include <stdarg.h> // vararg stuff 58#include <stdarg.h> // vararg stuff
59#include <ctype.h> // isprint 59#include <ctype.h> // isprint
60#include <syslog.h> 60#include <syslog.h>
61#include <errno.h> 61#include <errno.h>
62#include <string.h> 62#include <string.h>
63 63
64#ifndef OPIE_NO_BACKTRACE 64#ifndef OPIE_NO_BACKTRACE
65#include <execinfo.h> 65#include <execinfo.h>
66#endif 66#endif
67 67
68 68namespace Opie {
69namespace Core {
69/*====================================================================================== 70/*======================================================================================
70 * debug levels 71 * debug levels
71 *======================================================================================*/ 72 *======================================================================================*/
72 73
73enum DebugLevels { 74enum DebugLevels {
74 ODEBUG_INFO = 0, 75 ODEBUG_INFO = 0,
75 ODEBUG_WARN = 1, 76 ODEBUG_WARN = 1,
76 ODEBUG_ERROR = 2, 77 ODEBUG_ERROR = 2,
77 ODEBUG_FATAL = 3 78 ODEBUG_FATAL = 3
78}; 79};
79 80
80/*====================================================================================== 81/*======================================================================================
81 * oDebug private data 82 * oDebug private data
82 *======================================================================================*/ 83 *======================================================================================*/
83 84
84/*====================================================================================== 85/*======================================================================================
85 * the main debug function 86 * the main debug function
86 *======================================================================================*/ 87 *======================================================================================*/
87 88
88static void oDebugBackend( unsigned short level, unsigned int area, const char *data) 89static void oDebugBackend( unsigned short level, unsigned int area, const char *data)
89{ 90{
90 //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data ); 91 //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data );
91 92
92 // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an 93 // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an
93 // ML: example use. I think it's not necessary to implement such a strategy here. 94 // ML: example use. I think it's not necessary to implement such a strategy here.
94 // ML: Comments? 95 // ML: Comments?
95 96
96 int priority = 0; 97 int priority = 0;
97 QString caption; 98 QString caption;
98 QString lev; 99 QString lev;
99 switch( level ) 100 switch( level )
100 { 101 {
101 case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break; 102 case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break;
102 case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break; 103 case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break;
103 case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break; 104 case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break;
104 default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." ); 105 default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." );
105 case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break; 106 case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break;
106 } 107 }
107 108
108 short output = OGlobalSettings::debugMode(); 109 short output = OGlobalSettings::debugMode();
109 if (!oApp && (output == 1)) 110 if (!oApp && (output == 1))
110 { 111 {
111 qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" ); 112 qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" );
112 output = 2; // need an application object to use MsgBox 113 output = 2; // need an application object to use MsgBox
113 } 114 }
114 115
115 // gcc 2.9x is dumb and sucks... can you hear it? 116 // gcc 2.9x is dumb and sucks... can you hear it?
116 //QString areaName = (oApp) ? oApp->appName() : "<unknown>"; 117 //QString areaName = (oApp) ? oApp->appName() : "<unknown>";
@@ -569,52 +570,56 @@ odbgstream& odbgstream::operator<<( const QBrush& b)
569 "DiagCrossPattern" }; 570 "DiagCrossPattern" };
570 571
571 *this <<"[ style: "; 572 *this <<"[ style: ";
572 *this <<s_brushStyles[ b.style() ]; 573 *this <<s_brushStyles[ b.style() ];
573 *this <<" color: "; 574 *this <<" color: ";
574 // can't use operator<<(str, b.color()) because that terminates a odbgstream (flushes) 575 // can't use operator<<(str, b.color()) because that terminates a odbgstream (flushes)
575 if ( b.color().isValid() ) 576 if ( b.color().isValid() )
576 *this <<b.color().name() ; 577 *this <<b.color().name() ;
577 else 578 else
578 *this <<"(invalid/default)"; 579 *this <<"(invalid/default)";
579 if ( b.pixmap() ) 580 if ( b.pixmap() )
580 *this <<" has a pixmap"; 581 *this <<" has a pixmap";
581 *this <<" ]"; 582 *this <<" ]";
582 return *this; 583 return *this;
583} 584}
584 585
585 586
586 587
587QString odBacktrace( int levels ) 588QString odBacktrace( int levels )
588{ 589{
589 QString s; 590 QString s;
590#ifndef OPIE_NO_BACKTRACE 591#ifndef OPIE_NO_BACKTRACE
591 void* trace[256]; 592 void* trace[256];
592 int n = backtrace(trace, 256); 593 int n = backtrace(trace, 256);
593 char** strings = backtrace_symbols (trace, n); 594 char** strings = backtrace_symbols (trace, n);
594 595
595 if ( levels != -1 ) 596 if ( levels != -1 )
596 n = QMIN( n, levels ); 597 n = QMIN( n, levels );
597 s = "[\n"; 598 s = "[\n";
598 599
599 for (int i = 0; i < n; ++i) 600 for (int i = 0; i < n; ++i)
600 s += QString::number(i) + 601 s += QString::number(i) +
601 QString::fromLatin1(": ") + 602 QString::fromLatin1(": ") +
602 QString::fromLatin1(strings[i]) + QString::fromLatin1("\n"); 603 QString::fromLatin1(strings[i]) + QString::fromLatin1("\n");
603 s += "]\n"; 604 s += "]\n";
604 free (strings); 605 free (strings);
605#endif 606#endif
606 return s; 607 return s;
607} 608}
608 609
609void odClearDebugConfig() 610void odClearDebugConfig()
610{ 611{
611 /* 612 /*
612 delete oDebug_data->config; 613 delete oDebug_data->config;
613 oDebug_data->config = 0; 614 oDebug_data->config = 0;
614 */ 615 */
615} 616}
616 617
618
617#ifdef OPIE_NO_DEBUG 619#ifdef OPIE_NO_DEBUG
618#define odDebug ondDebug 620#define odDebug ondDebug
619#define odBacktrace ondBacktrace 621#define odBacktrace ondBacktrace
620#endif 622#endif
623
624}
625} \ No newline at end of file
diff --git a/libopie2/opiecore/odebug.h b/libopie2/opiecore/odebug.h
index 85941fd..a5c9ded 100644
--- a/libopie2/opiecore/odebug.h
+++ b/libopie2/opiecore/odebug.h
@@ -2,96 +2,99 @@
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 (C) 2003 Michael 'Mickey' Lauer (mickey@tm.informatik.uni-frankfurt.de) 3 (C) 2003 Michael 'Mickey' Lauer (mickey@tm.informatik.uni-frankfurt.de)
4 Inspired by the KDE debug classes, which are 4 Inspired by the KDE debug classes, which are
5 (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) 5 (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org)
6 (C) 2002 Holger Freyther (freyther@kde.org) 6 (C) 2002 Holger Freyther (freyther@kde.org)
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31*/ 31*/
32 32
33#ifndef ODEBUG_H 33#ifndef ODEBUG_H
34#define ODEBUG_H 34#define ODEBUG_H
35 35
36#include <qstring.h> 36#include <qstring.h>
37 37
38class QWidget; 38class QWidget;
39class QDateTime; 39class QDateTime;
40class QDate; 40class QDate;
41class QTime; 41class QTime;
42class QPoint; 42class QPoint;
43class QSize; 43class QSize;
44class QRect; 44class QRect;
45class QRegion; 45class QRegion;
46class QStringList; 46class QStringList;
47class QColor; 47class QColor;
48class QBrush; 48class QBrush;
49 49
50namespace Opie {
51namespace Core {
52
50class odbgstream; 53class odbgstream;
51class ondbgstream; 54class ondbgstream;
52 55
53#ifdef __GNUC__ 56#ifdef __GNUC__
54#define o_funcinfo "[" << __PRETTY_FUNCTION__ << "] " 57#define o_funcinfo "[" << __PRETTY_FUNCTION__ << "] "
55#else 58#else
56#define o_funcinfo "[" << __FILE__ << ":" << __LINE__ << "] " 59#define o_funcinfo "[" << __FILE__ << ":" << __LINE__ << "] "
57#endif 60#endif
58 61
59#define o_lineinfo "[" << __FILE__ << ":" << __LINE__ << "] " 62#define o_lineinfo "[" << __FILE__ << ":" << __LINE__ << "] "
60 63
61#define owarn odWarning() 64#define owarn odWarning()
62#define oerr odError() 65#define oerr odError()
63#define odebug odDebug() 66#define odebug odDebug()
64#define ofatal odFatal() 67#define ofatal odFatal()
65#define oendl "\n" 68#define oendl "\n"
66 69
67class odbgstreamprivate; 70class odbgstreamprivate;
68/** 71/**
69 * odbgstream is a text stream that allows you to print debug messages. 72 * odbgstream is a text stream that allows you to print debug messages.
70 * Using the overloaded "<<" operator you can send messages. Usually 73 * Using the overloaded "<<" operator you can send messages. Usually
71 * you do not create the odbgstream yourself, but use @ref odDebug() (odebug) 74 * you do not create the odbgstream yourself, but use @ref odDebug() (odebug)
72 * @ref odWarning() (owarn), @ref odError() (oerr) or @ref odFatal (ofatal) to obtain one. 75 * @ref odWarning() (owarn), @ref odError() (oerr) or @ref odFatal (ofatal) to obtain one.
73 * 76 *
74 * Example: 77 * Example:
75 * <pre> 78 * <pre>
76 * int i = 5; 79 * int i = 5;
77 * odebug << "The value of i is " << i << oendl; 80 * odebug << "The value of i is " << i << oendl;
78 * </pre> 81 * </pre>
79 * @see odbgstream 82 * @see odbgstream
80 */ 83 */
81 84
82/*====================================================================================== 85/*======================================================================================
83 * odbgstream 86 * odbgstream
84 *======================================================================================*/ 87 *======================================================================================*/
85 88
86class odbgstream 89class odbgstream
87{ 90{
88 public: 91 public:
89 /** 92 /**
90 * @internal 93 * @internal
91 */ 94 */
92 odbgstream(unsigned int _area, unsigned int _level, bool _print = true); 95 odbgstream(unsigned int _area, unsigned int _level, bool _print = true);
93 odbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print = true); 96 odbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print = true);
94 odbgstream(odbgstream &str); 97 odbgstream(odbgstream &str);
95 odbgstream(const odbgstream &str); 98 odbgstream(const odbgstream &str);
96 virtual ~odbgstream(); 99 virtual ~odbgstream();
97 100
@@ -349,126 +352,132 @@ class ondbgstream {
349 */ 352 */
350 ondbgstream &operator<<(const char *) { return *this; } 353 ondbgstream &operator<<(const char *) { return *this; }
351 /** 354 /**
352 * Does nothing. 355 * Does nothing.
353 * @return this stream 356 * @return this stream
354 */ 357 */
355 ondbgstream& operator<<(const void *) { return *this; } 358 ondbgstream& operator<<(const void *) { return *this; }
356 /** 359 /**
357 * Does nothing. 360 * Does nothing.
358 * @return this stream 361 * @return this stream
359 */ 362 */
360 ondbgstream& operator<<(void *) { return *this; } 363 ondbgstream& operator<<(void *) { return *this; }
361 /** 364 /**
362 * Does nothing. 365 * Does nothing.
363 * @return this stream 366 * @return this stream
364 */ 367 */
365 ondbgstream& operator<<(double) { return *this; } 368 ondbgstream& operator<<(double) { return *this; }
366 /** 369 /**
367 * Does nothing. 370 * Does nothing.
368 * @return this stream 371 * @return this stream
369 */ 372 */
370 ondbgstream& operator<<(long) { return *this; } 373 ondbgstream& operator<<(long) { return *this; }
371 /** 374 /**
372 * Does nothing. 375 * Does nothing.
373 * @return this stream 376 * @return this stream
374 */ 377 */
375 ondbgstream& operator<<(unsigned long) { return *this; } 378 ondbgstream& operator<<(unsigned long) { return *this; }
376 /** 379 /**
377 * Does nothing. 380 * Does nothing.
378 * @return this stream 381 * @return this stream
379 */ 382 */
380 ondbgstream& operator << (QWidget*) { return *this; } 383 ondbgstream& operator << (QWidget*) { return *this; }
381 /** 384 /**
382 * Does nothing. 385 * Does nothing.
383 * @return this stream 386 * @return this stream
384 */ 387 */
385 ondbgstream &form(const char *, ...) { return *this; } 388 ondbgstream &form(const char *, ...) { return *this; }
386 389
387 ondbgstream& operator<<( const QDateTime& ) { return *this; } 390 ondbgstream& operator<<( const QDateTime& ) { return *this; }
388 ondbgstream& operator<<( const QDate& ) { return *this; } 391 ondbgstream& operator<<( const QDate& ) { return *this; }
389 ondbgstream& operator<<( const QTime& ) { return *this; } 392 ondbgstream& operator<<( const QTime& ) { return *this; }
390 ondbgstream& operator<<( const QPoint & ) { return *this; } 393 ondbgstream& operator<<( const QPoint & ) { return *this; }
391 ondbgstream& operator<<( const QSize & ) { return *this; } 394 ondbgstream& operator<<( const QSize & ) { return *this; }
392 ondbgstream& operator<<( const QRect & ) { return *this; } 395 ondbgstream& operator<<( const QRect & ) { return *this; }
393 ondbgstream& operator<<( const QRegion & ) { return *this; } 396 ondbgstream& operator<<( const QRegion & ) { return *this; }
394 ondbgstream& operator<<( const QStringList & ) { return *this; } 397 ondbgstream& operator<<( const QStringList & ) { return *this; }
395 ondbgstream& operator<<( const QColor & ) { return *this; } 398 ondbgstream& operator<<( const QColor & ) { return *this; }
396 ondbgstream& operator<<( const QBrush & ) { return *this; } 399 ondbgstream& operator<<( const QBrush & ) { return *this; }
400
401private:
402 class Private;
403 Private *d;
397}; 404};
398 405
399/*====================================================================================== 406/*======================================================================================
400 * related functions 407 * related functions
401 *======================================================================================*/ 408 *======================================================================================*/
402 409
403/** 410/**
404 * Does nothing. 411 * Does nothing.
405 * @param a stream 412 * @param a stream
406 * @return the given @p s 413 * @return the given @p s
407 */ 414 */
408inline ondbgstream& endl( ondbgstream & s) { return s; } 415inline ondbgstream& endl( ondbgstream & s) { return s; }
409/** 416/**
410 * Does nothing. 417 * Does nothing.
411 * @param a stream 418 * @param a stream
412 * @return the given @p s 419 * @return the given @p s
413 */ 420 */
414inline ondbgstream& flush( ondbgstream & s) { return s; } 421inline ondbgstream& flush( ondbgstream & s) { return s; }
415inline ondbgstream& perror( ondbgstream & s) { return s; } 422inline ondbgstream& perror( ondbgstream & s) { return s; }
416 423
417/** 424/**
418 * Returns a debug stream. You can use it to print debug 425 * Returns a debug stream. You can use it to print debug
419 * information. 426 * information.
420 * @param area an id to identify the output, 0 for default 427 * @param area an id to identify the output, 0 for default
421 */ 428 */
422odbgstream odDebug(int area = 0); 429odbgstream odDebug(int area = 0);
423odbgstream odDebug(bool cond, int area = 0); 430odbgstream odDebug(bool cond, int area = 0);
424/** 431/**
425 * Returns a backtrace. 432 * Returns a backtrace.
426 * @param levels the number of levels (-1 for unlimited) of the backtrace 433 * @param levels the number of levels (-1 for unlimited) of the backtrace
427 * @return a backtrace 434 * @return a backtrace
428 */ 435 */
429QString odBacktrace(int levels = -1); 436QString odBacktrace(int levels = -1);
430/** 437/**
431 * Returns a dummy debug stream. The stream does not print anything. 438 * Returns a dummy debug stream. The stream does not print anything.
432 * @param area an id to identify the output, 0 for default 439 * @param area an id to identify the output, 0 for default
433 * @see odDebug() 440 * @see odDebug()
434 */ 441 */
435inline ondbgstream ondDebug(int = 0) { return ondbgstream(); } 442inline ondbgstream ondDebug(int = 0) { return ondbgstream(); }
436inline ondbgstream ondDebug(bool , int = 0) { return ondbgstream(); } 443inline ondbgstream ondDebug(bool , int = 0) { return ondbgstream(); }
437inline QString ondBacktrace() { return QString::null; } 444inline QString ondBacktrace() { return QString::null; }
438inline QString ondBacktrace(int) { return QString::null; } 445inline QString ondBacktrace(int) { return QString::null; }
439 446
440/** 447/**
441 * Returns a warning stream. You can use it to print warning 448 * Returns a warning stream. You can use it to print warning
442 * information. 449 * information.
443 * @param area an id to identify the output, 0 for default 450 * @param area an id to identify the output, 0 for default
444 */ 451 */
445odbgstream odWarning(int area = 0); 452odbgstream odWarning(int area = 0);
446odbgstream odWarning(bool cond, int area = 0); 453odbgstream odWarning(bool cond, int area = 0);
447/** 454/**
448 * Returns an error stream. You can use it to print error 455 * Returns an error stream. You can use it to print error
449 * information. 456 * information.
450 * @param area an id to identify the output, 0 for default 457 * @param area an id to identify the output, 0 for default
451 */ 458 */
452odbgstream odError(int area = 0); 459odbgstream odError(int area = 0);
453odbgstream odError(bool cond, int area = 0); 460odbgstream odError(bool cond, int area = 0);
454/** 461/**
455 * Returns a fatal error stream. You can use it to print fatal error 462 * Returns a fatal error stream. You can use it to print fatal error
456 * information. 463 * information.
457 * @param area an id to identify the output, 0 for default 464 * @param area an id to identify the output, 0 for default
458 */ 465 */
459odbgstream odFatal(int area = 0); 466odbgstream odFatal(int area = 0);
460odbgstream odFatal(bool cond, int area = 0); 467odbgstream odFatal(bool cond, int area = 0);
461 468
462/** 469/**
463 * Deletes the odebugrc cache and therefore forces KDebug to reread the 470 * Deletes the odebugrc cache and therefore forces KDebug to reread the
464 * config file 471 * config file
465 */ 472 */
466void odClearDebugConfig(); 473void odClearDebugConfig();
467 474
468#ifdef OPIE_NO_DEBUG 475#ifdef OPIE_NO_DEBUG
469#define odDebug ondDebug 476#define odDebug ondDebug
470#define odBacktrace ondBacktrace 477#define odBacktrace ondBacktrace
471#endif 478#endif
472 479
473#endif 480#endif
474 481
482}
483}
diff --git a/libopie2/opiecore/oglobal.cpp b/libopie2/opiecore/oglobal.cpp
index 1aa206e..ea02058 100644
--- a/libopie2/opiecore/oglobal.cpp
+++ b/libopie2/opiecore/oglobal.cpp
@@ -1,88 +1,90 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> 3 Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de>
4 =. Copyright (C) 2004 Holger 'zecke' Freyther <zecke@handhelds.org> 4 =. Copyright (C) 2004 Holger 'zecke' Freyther <zecke@handhelds.org>
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 <opie2/oglobal.h> 30#include <opie2/oglobal.h>
31 31
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qdir.h> 33#include <qdir.h>
34#include <qpe/mimetype.h> 34#include <qpe/mimetype.h>
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#include <qpe/storage.h> 36#include <qpe/storage.h>
37 37
38#include <unistd.h> 38#include <unistd.h>
39#include <sys/types.h> 39#include <sys/types.h>
40 40
41using namespace Opie::Core;
42
41static const char Base64EncMap[64] = 43static const char Base64EncMap[64] =
42{ 44{
43 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 45 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
44 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 46 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
45 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 47 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
46 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 48 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
47 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 49 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E,
48 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 50 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
49 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, 0x33, 51 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, 0x33,
50 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F 52 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F
51}; 53};
52 54
53static char Base64DecMap[128] = 55static char Base64DecMap[128] =
54{ 56{
55 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 57 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
56 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 58 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
57 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 59 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
58 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 60 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
59 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 61 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
60 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3F, 62 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3F,
61 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 63 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B,
62 0x3C, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 64 0x3C, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
63 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 65 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
64 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 66 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
65 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 67 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
66 0x17, 0x18, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 68 0x17, 0x18, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00,
67 0x00, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 69 0x00, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,
68 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 70 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
69 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 71 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30,
70 0x31, 0x32, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00 72 0x31, 0x32, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00
71}; 73};
72 74
73 75
74OConfig* OGlobal::_config = 0; 76OConfig* OGlobal::_config = 0;
75OConfig* OGlobal::_qpe_config = 0; 77OConfig* OGlobal::_qpe_config = 0;
76 78
77OConfig* OGlobal::config() 79OConfig* OGlobal::config()
78{ 80{
79 if ( !OGlobal::_config ) 81 if ( !OGlobal::_config )
80 { 82 {
81 // odebug classes are reading config, so can't use them here! 83 // odebug classes are reading config, so can't use them here!
82 qDebug( "OGlobal::creating global configuration instance." ); 84 qDebug( "OGlobal::creating global configuration instance." );
83 OGlobal::_config = new OConfig( "global" ); 85 OGlobal::_config = new OConfig( "global" );
84 } 86 }
85 return OGlobal::_config; 87 return OGlobal::_config;
86} 88}
87 89
88 90
@@ -267,108 +269,108 @@ QByteArray OGlobal::decodeBase64( const QByteArray& in) {
267 { 269 {
268 // Adhere to RFC 2045 and ignore characters 270 // Adhere to RFC 2045 and ignore characters
269 // that are not part of the encoding table. 271 // that are not part of the encoding table.
270 unsigned char ch = data[idx]; 272 unsigned char ch = data[idx];
271 if ( (ch > 47 && ch < 58) || (ch > 64 && ch < 91 ) || 273 if ( (ch > 47 && ch < 58) || (ch > 64 && ch < 91 ) ||
272 (ch > 96 && ch < 123)|| ch == '+' || ch == '/' || ch == '=') 274 (ch > 96 && ch < 123)|| ch == '+' || ch == '/' || ch == '=')
273 { 275 {
274 out[outIdx++] = Base64DecMap[ch]; 276 out[outIdx++] = Base64DecMap[ch];
275 } 277 }
276 else 278 else
277 { 279 {
278 len--; 280 len--;
279 tail--; 281 tail--;
280 } 282 }
281 } 283 }
282 284
283 // kdDebug() << "Tail size = " << tail << ", Length size = " << len << endl; 285 // kdDebug() << "Tail size = " << tail << ", Length size = " << len << endl;
284 286
285 // 4-byte to 3-byte conversion 287 // 4-byte to 3-byte conversion
286 len = (tail>(len/4)) ? tail-(len/4) : 0; 288 len = (tail>(len/4)) ? tail-(len/4) : 0;
287 unsigned int sidx = 0, didx = 0; 289 unsigned int sidx = 0, didx = 0;
288 if ( len > 1 ) 290 if ( len > 1 )
289 { 291 {
290 while (didx < len-2) 292 while (didx < len-2)
291 { 293 {
292 out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003)); 294 out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003));
293 out[didx+1] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017)); 295 out[didx+1] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017));
294 out[didx+2] = (((out[sidx+2] << 6) & 255) | (out[sidx+3] & 077)); 296 out[didx+2] = (((out[sidx+2] << 6) & 255) | (out[sidx+3] & 077));
295 sidx += 4; 297 sidx += 4;
296 didx += 3; 298 didx += 3;
297 } 299 }
298 } 300 }
299 301
300 if (didx < len) 302 if (didx < len)
301 out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003)); 303 out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003));
302 304
303 if (++didx < len ) 305 if (++didx < len )
304 out[didx] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017)); 306 out[didx] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017));
305 307
306 // Resize the output buffer 308 // Resize the output buffer
307 if ( len == 0 || len < out.size() ) 309 if ( len == 0 || len < out.size() )
308 out.resize(len); 310 out.resize(len);
309 311
310 return out; 312 return out;
311} 313}
312 314
313bool OGlobal::isAppLnkFileName( const QString& str ) 315bool OGlobal::isAppLnkFileName( const QString& str )
314{ 316{
315 if (str.length()==0||str.at(str.length()-1)==QDir::separator()) return false; 317 if (str.isEmpty()||str.at(str.length()-1)==QDir::separator()) return false;
316 return str.startsWith(MimeType::appsFolderName()+QDir::separator()); 318 return str.startsWith(MimeType::appsFolderName()+QDir::separator());
317} 319}
318 320
319/* ToDo: 321/* ToDo:
320 * This fun should check the document-path value for the mounted media 322 * This fun should check the document-path value for the mounted media
321 * which has to be implemented later. this moment we just check for a 323 * which has to be implemented later. this moment we just check for a
322 * mounted media name. 324 * mounted media name.
323 */ 325 */
324bool OGlobal::isDocumentFileName( const QString& file ) 326bool OGlobal::isDocumentFileName( const QString& file )
325{ 327{
326 if (file.length()==0||file.at(file.length()-1)==QDir::separator()) return false; 328 if (file.isEmpty()||file.at(file.length()-1)==QDir::separator()) return false;
327 if (file.startsWith(QPEApplication::documentDir()+QDir::separator())) return true; 329 if (file.startsWith(QPEApplication::documentDir()+QDir::separator())) return true;
328 StorageInfo si; 330 StorageInfo si;
329 QList< FileSystem > fl = si.fileSystems(); 331 QList< FileSystem > fl = si.fileSystems();
330 FileSystem*fs; 332 FileSystem*fs;
331 for (fs = fl.first();fs!=0;fs=fl.next()) { 333 for (fs = fl.first();fs!=0;fs=fl.next()) {
332 if (fs->isRemovable()&&file.startsWith(fs->name()+QDir::separator())) 334 if (fs->isRemovable()&&file.startsWith(fs->name()+QDir::separator()))
333 return true; 335 return true;
334 } 336 }
335 if (file.startsWith(homeDirPath())+"/Documents/") return true; 337 if (file.startsWith(homeDirPath())+"/Documents/") return true;
336 return false; 338 return false;
337} 339}
338 340
339QString OGlobal::tempDirPath() 341QString OGlobal::tempDirPath()
340{ 342{
341 static QString defstring="/tmp"; 343 static QString defstring="/tmp";
342 char * tmpp = 0; 344 char * tmpp = 0;
343 if ( (tmpp=getenv("TEMP"))) { 345 if ( (tmpp=getenv("TEMP"))) {
344 return tmpp; 346 return tmpp;
345 } 347 }
346 return defstring; 348 return defstring;
347} 349}
348 350
349QString OGlobal::homeDirPath() 351QString OGlobal::homeDirPath()
350{ 352{
351 char * tmpp = getenv("HOME"); 353 char * tmpp = getenv("HOME");
352 return (tmpp?tmpp:"/"); 354 return (tmpp?tmpp:"/");
353} 355}
354 356
355bool OGlobal::weekStartsOnMonday() 357bool OGlobal::weekStartsOnMonday()
356{ 358{
357 OConfig*conf=OGlobal::qpe_config(); 359 OConfig*conf=OGlobal::qpe_config();
358 if (!conf)return false; 360 if (!conf)return false;
359 conf->setGroup("Time"); 361 conf->setGroup("Time");
360 return conf->readBoolEntry("MONDAY",true); 362 return conf->readBoolEntry("MONDAY",true);
361} 363}
362 364
363void OGlobal::setWeekStartsOnMonday( bool what) 365void OGlobal::setWeekStartsOnMonday( bool what)
364{ 366{
365 OConfig*conf=OGlobal::qpe_config(); 367 OConfig*conf=OGlobal::qpe_config();
366 if (!conf)return; 368 if (!conf)return;
367 conf->setGroup("Time"); 369 conf->setGroup("Time");
368 return conf->writeEntry("MONDAY",what); 370 return conf->writeEntry("MONDAY",what);
369} 371}
370 372
371bool OGlobal::useAMPM() 373bool OGlobal::useAMPM()
372{ 374{
373 OConfig*conf=OGlobal::qpe_config(); 375 OConfig*conf=OGlobal::qpe_config();
374 if (!conf)return false; 376 if (!conf)return false;
diff --git a/libopie2/opiecore/oglobal.h b/libopie2/opiecore/oglobal.h
index aeee75e..e6a6c46 100644
--- a/libopie2/opiecore/oglobal.h
+++ b/libopie2/opiecore/oglobal.h
@@ -7,145 +7,153 @@
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#ifndef OGLOBAL_H 30#ifndef OGLOBAL_H
31#define OGLOBAL_H 31#define OGLOBAL_H
32 32
33 33
34#include <opie2/oconfig.h> 34#include <opie2/oconfig.h>
35 35
36#ifndef private 36#ifndef private
37#define HACK_DEFINED 37#define HACK_DEFINED
38#define private protected 38#define private protected
39#endif 39#endif
40#include <qpe/global.h> 40#include <qpe/global.h>
41#ifdef HACK_DEFINED 41#ifdef HACK_DEFINED
42#undef private 42#undef private
43#endif 43#endif
44 44
45#include <sys/types.h> 45#include <sys/types.h>
46 46
47//FIXME Is it wise or even necessary to inherit OGlobal from Global? 47//FIXME Is it wise or even necessary to inherit OGlobal from Global?
48// once we totally skip libqpe it should ideally swallow Global -zecke 48// once we totally skip libqpe it should ideally swallow Global -zecke
49// You're right. I deleted global as the base class. -mickeyl 49// You're right. I deleted global as the base class. -mickeyl
50 50
51 51
52class QFile; 52class QFile;
53class QString; 53class QString;
54class DateFormat; 54class DateFormat;
55
56
57
58namespace Opie {
59namespace Core {
55/** 60/**
56 *\brief OGlobal contains a list of generic functions 61 *\brief OGlobal contains a list of generic functions
57 * 62 *
58 * The class OGlobal contains small utility functions 63 * The class OGlobal contains small utility functions
59 * which might be useful for other applications to use. It features access 64 * which might be useful for other applications to use. It features access
60 * to the global device config and specialized functions to get information 65 * to the global device config and specialized functions to get information
61 * out of this config like Weekstart or Owner name. 66 * out of this config like Weekstart or Owner name.
62 * 67 *
63 * @todo ODP implement the things from Global which are good 68 * @todo ODP implement the things from Global which are good
64 * @author mickey,alwin,zecke 69 * @author mickey,alwin,zecke
65 * @version 0.1 70 * @version 0.1
66 */ 71 */
67class OGlobal : public Global 72class OGlobal : public Global
68{ 73{
69public: 74public:
70 75
71 // how do they relate to our Document Idea 76 // how do they relate to our Document Idea
72 /** @name Document System related functions 77 /** @name Document System related functions
73 * 78 *
74 */ 79 */
75 //@{ 80 //@{
76 static bool isAppLnkFileName( const QString& str ); 81 static bool isAppLnkFileName( const QString& str );
77 static bool isDocumentFileName( const QString& file ); 82 static bool isDocumentFileName( const QString& file );
78 //@} 83 //@}
79 84
80 /** @name File Operations 85 /** @name File Operations
81 * File operations provided by OGlobal 86 * File operations provided by OGlobal
82 */ 87 */
83 //@{ 88 //@{
84 /** the content of TEMP 89 /** the content of TEMP
85 * reads the environment variable TEMP and returns the content. 90 * reads the environment variable TEMP and returns the content.
86 * if not set returns "/tmp" 91 * if not set returns "/tmp"
87 * @return a string containing a dir without trailing slash! 92 * @return a string containing a dir without trailing slash!
88 */ 93 */
89 static QString tempDirPath(); 94 static QString tempDirPath();
90 /** the content of HOME 95 /** the content of HOME
91 * reads the environment variable HOME and returns the content. 96 * reads the environment variable HOME and returns the content.
92 * if not set returns "/" 97 * if not set returns "/"
93 * @return a string containing a dir without trailing slash! 98 * @return a string containing a dir without trailing slash!
94 */ 99 */
95 static QString homeDirPath(); 100 static QString homeDirPath();
96 static QString tempFileName( const QString& ); 101 static QString tempFileName( const QString& );
97 static bool renameFile( const QString& from, const QString& to ); 102 static bool renameFile( const QString& from, const QString& to );
98 static bool truncateFile( QFile &f, off_t size ); 103 static bool truncateFile( QFile &f, off_t size );
99 //@} 104 //@}
100 105
101 106
102 static QString generateUuid(); 107 static QString generateUuid();
103 108
104 /** @name Convert Content 109 /** @name Convert Content
105 * Convert Content of a QByteArray 110 * Convert Content of a QByteArray
106 */ 111 */
107 //@{ 112 //@{
108 static QByteArray encodeBase64(const QByteArray&, bool insertLF = false ); 113 static QByteArray encodeBase64(const QByteArray&, bool insertLF = false );
109 static QByteArray decodeBase64(const QByteArray& ); 114 static QByteArray decodeBase64(const QByteArray& );
110 //@} 115 //@}
111 116
112 //FIXME Do we want to put that into OApplication as in KApplication? -zecke 117 //FIXME Do we want to put that into OApplication as in KApplication? -zecke
113 // We already have a per-application config in OApplication 118 // We already have a per-application config in OApplication
114 // ( accessed through oApp->config() ), but this one is the global one! -mickeyl 119 // ( accessed through oApp->config() ), but this one is the global one! -mickeyl
115 /** @name Config and Owner related Information 120 /** @name Config and Owner related Information
116 * 121 *
117 */ 122 */
118 //@{ 123 //@{
119 static OConfig* config(); 124 static OConfig* config();
120 static OConfig* qpe_config(); 125 static OConfig* qpe_config();
121 static QString ownerName(); 126 static QString ownerName();
122 static bool weekStartsOnMonday(); 127 static bool weekStartsOnMonday();
123 static bool useAMPM(); 128 static bool useAMPM();
124#ifdef ODP 129#ifdef ODP
125#error "Fix dateFormat" 130#error "Fix dateFormat"
126 /** 131 /**
127 * For Qt3/Qt4 we can use QDate::toString(OGlobal::dateFormat) 132 * For Qt3/Qt4 we can use QDate::toString(OGlobal::dateFormat)
128 * See if we need to use the function with String in it 133 * See if we need to use the function with String in it
129 * Anyway this is the future 134 * Anyway this is the future
130 * for now still use TimeString! 135 * for now still use TimeString!
131 */ 136 */
132#endif 137#endif
133 static DateFormat dateFormat(); 138 static DateFormat dateFormat();
134 static void setDateFormat( const DateFormat& ); 139 static void setDateFormat( const DateFormat& );
135 140
136 141
137 static void setWeekStartsOnMonday( bool ); 142 static void setWeekStartsOnMonday( bool );
138 static void setUseAMPM( bool ); 143 static void setUseAMPM( bool );
139 //@} 144 //@}
140 145
141 //@{ 146 //@{
142 static Global::Command* builtinCommands(); 147 static Global::Command* builtinCommands();
143 static QGuardedPtr<QWidget>* builtinRunning(); 148 static QGuardedPtr<QWidget>* builtinRunning();
144 //@} 149 //@}
145 150
146private: 151private:
147 static OConfig* _config; 152 static OConfig* _config;
148 static OConfig* _qpe_config; 153 static OConfig* _qpe_config;
154 class Private;
155 Private *d;
149}; 156};
150 157}
158}
151#endif // OGLOBAL_H 159#endif // OGLOBAL_H
diff --git a/libopie2/opiecore/oglobalsettings.cpp b/libopie2/opiecore/oglobalsettings.cpp
index 192e55b..f34c531 100644
--- a/libopie2/opiecore/oglobalsettings.cpp
+++ b/libopie2/opiecore/oglobalsettings.cpp
@@ -1,94 +1,97 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4              Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> 4              Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 Inspired by the KDE globalsettings which are 5 Inspired by the KDE globalsettings which are
6 Copyright (C) 2000 David Faure <faure@kde.org> 6 Copyright (C) 2000 David Faure <faure@kde.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9           .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10 _;:,     .>    :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_,   >  .   <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 12:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i,     .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14 - .   .-<_>     .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15     ._= =}       : or (at your option) any later version.
16    .%`+i>       _;_. 16    .%`+i>       _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17    .i_,=:_.      -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19    : ..    .:,     . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.=       =       ; Library General Public License for more
23++=   -.     .`     .: details. 23++=   -.     .`     .: details.
24 :     =  ...= . :.=- 24 :     =  ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25 -.   .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26  -_. . .   )=.  = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27    --        :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31*/ 31*/
32 32
33/* OPIE */ 33/* OPIE */
34 34
35#include <opie2/oglobalsettings.h> 35#include <opie2/oglobalsettings.h>
36#include <opie2/oconfig.h> 36#include <opie2/oconfig.h>
37#include <opie2/oglobal.h> 37#include <opie2/oglobal.h>
38 38
39/* QT */ 39/* QT */
40 40
41#include <qdir.h> 41#include <qdir.h>
42 42
43/* UNIX */ 43/* UNIX */
44 44
45#include <stdlib.h> 45#include <stdlib.h>
46 46
47
48using namespace Opie::Core;
49
47QString* OGlobalSettings::s_desktopPath = 0; 50QString* OGlobalSettings::s_desktopPath = 0;
48QString* OGlobalSettings::s_autostartPath = 0; 51QString* OGlobalSettings::s_autostartPath = 0;
49QString* OGlobalSettings::s_trashPath = 0; 52QString* OGlobalSettings::s_trashPath = 0;
50QString* OGlobalSettings::s_documentPath = 0; 53QString* OGlobalSettings::s_documentPath = 0;
51QFont *OGlobalSettings::_generalFont = 0; 54QFont *OGlobalSettings::_generalFont = 0;
52QFont *OGlobalSettings::_fixedFont = 0; 55QFont *OGlobalSettings::_fixedFont = 0;
53QFont *OGlobalSettings::_toolBarFont = 0; 56QFont *OGlobalSettings::_toolBarFont = 0;
54QFont *OGlobalSettings::_menuFont = 0; 57QFont *OGlobalSettings::_menuFont = 0;
55QFont *OGlobalSettings::_windowTitleFont = 0; 58QFont *OGlobalSettings::_windowTitleFont = 0;
56QFont *OGlobalSettings::_taskbarFont = 0; 59QFont *OGlobalSettings::_taskbarFont = 0;
57 60
58QColor *OGlobalSettings::OpieGray = 0; 61QColor *OGlobalSettings::OpieGray = 0;
59QColor *OGlobalSettings::OpieHighlight = 0; 62QColor *OGlobalSettings::OpieHighlight = 0;
60QColor *OGlobalSettings::OpieAlternate = 0; 63QColor *OGlobalSettings::OpieAlternate = 0;
61 64
62OGlobalSettings::OMouseSettings *OGlobalSettings::s_mouseSettings = 0; 65OGlobalSettings::OMouseSettings *OGlobalSettings::s_mouseSettings = 0;
63 66
64//FIXME: Add manipulators to the accessors 67//FIXME: Add manipulators to the accessors
65 68
66int OGlobalSettings::dndEventDelay() 69int OGlobalSettings::dndEventDelay()
67{ 70{
68 OConfig *c = OGlobal::config(); 71 OConfig *c = OGlobal::config();
69 OConfigGroupSaver cgs( c, "General" ); 72 OConfigGroupSaver cgs( c, "General" );
70 return c->readNumEntry("DndDelay", 2); 73 return c->readNumEntry("DndDelay", 2);
71} 74}
72 75
73bool OGlobalSettings::singleClick() 76bool OGlobalSettings::singleClick()
74{ 77{
75 OConfig *c = OGlobal::config(); 78 OConfig *c = OGlobal::config();
76 OConfigGroupSaver cgs( c, "OPIE" ); 79 OConfigGroupSaver cgs( c, "OPIE" );
77 return c->readBoolEntry("SingleClick", OPIE_DEFAULT_SINGLECLICK); 80 return c->readBoolEntry("SingleClick", OPIE_DEFAULT_SINGLECLICK);
78} 81}
79 82
80bool OGlobalSettings::insertTearOffHandle() 83bool OGlobalSettings::insertTearOffHandle()
81{ 84{
82 OConfig *c = OGlobal::config(); 85 OConfig *c = OGlobal::config();
83 OConfigGroupSaver cgs( c, "OPIE" ); 86 OConfigGroupSaver cgs( c, "OPIE" );
84 return c->readBoolEntry("InsertTearOffHandle", OPIE_DEFAULT_INSERTTEAROFFHANDLES); 87 return c->readBoolEntry("InsertTearOffHandle", OPIE_DEFAULT_INSERTTEAROFFHANDLES);
85} 88}
86 89
87bool OGlobalSettings::changeCursorOverIcon() 90bool OGlobalSettings::changeCursorOverIcon()
88{ 91{
89 OConfig *c = OGlobal::config(); 92 OConfig *c = OGlobal::config();
90 OConfigGroupSaver cgs( c, "OPIE" ); 93 OConfigGroupSaver cgs( c, "OPIE" );
91 return c->readBoolEntry("ChangeCursor", OPIE_DEFAULT_CHANGECURSOR); 94 return c->readBoolEntry("ChangeCursor", OPIE_DEFAULT_CHANGECURSOR);
92} 95}
93 96
94bool OGlobalSettings::visualActivate() 97bool OGlobalSettings::visualActivate()
diff --git a/libopie2/opiecore/oglobalsettings.h b/libopie2/opiecore/oglobalsettings.h
index e3ac148..8eea709 100644
--- a/libopie2/opiecore/oglobalsettings.h
+++ b/libopie2/opiecore/oglobalsettings.h
@@ -1,99 +1,105 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de> 3              Copyright (C) 2003 Michael Lauer <mickey@tm.informatik.uni-frankfurt.de>
4 Inspired by KDE OGlobalSettings 4 Inspired by KDE OGlobalSettings
5 Copyright (C) 2000 David Faure <faure@kde.org> 5 Copyright (C) 2000 David Faure <faure@kde.org>
6 =. 6 =.
7 .=l. 7 .=l.
8           .>+-= 8           .>+-=
9 _;:,     .>    :=|. This program is free software; you can 9 _;:,     .>    :=|. This program is free software; you can
10.> <`_,   >  .   <= redistribute it and/or modify it under 10.> <`_,   >  .   <= redistribute it and/or modify it under
11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 11:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
12.="- .-=="i,     .._ License as published by the Free Software 12.="- .-=="i,     .._ License as published by the Free Software
13 - .   .-<_>     .<> Foundation; either version 2 of the License, 13 - .   .-<_>     .<> Foundation; either version 2 of the License,
14     ._= =}       : or (at your option) any later version. 14     ._= =}       : or (at your option) any later version.
15    .%`+i>       _;_. 15    .%`+i>       _;_.
16    .i_,=:_.      -<s. This program is distributed in the hope that 16    .i_,=:_.      -<s. This program is distributed in the hope that
17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 17     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
18    : ..    .:,     . . . without even the implied warranty of 18    : ..    .:,     . . . without even the implied warranty of
19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 19    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 20  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.=       =       ; Library General Public License for more 21..}^=.=       =       ; Library General Public License for more
22++=   -.     .`     .: details. 22++=   -.     .`     .: details.
23 :     =  ...= . :.=- 23 :     =  ...= . :.=-
24 -.   .:....=;==+<; You should have received a copy of the GNU 24 -.   .:....=;==+<; You should have received a copy of the GNU
25  -_. . .   )=.  = Library General Public License along with 25  -_. . .   )=.  = Library General Public License along with
26    --        :-=` this library; see the file COPYING.LIB. 26    --        :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30*/ 30*/
31 31
32#ifndef OGLOBALSETTINGS_H 32#ifndef OGLOBALSETTINGS_H
33#define OGLOBALSETTINGS_H 33#define OGLOBALSETTINGS_H
34 34
35#include <qstring.h> 35#include <qstring.h>
36#include <qcolor.h> 36#include <qcolor.h>
37#include <qfont.h> 37#include <qfont.h>
38 38
39/**
40 * \todo make real const values
41 */
39#define OPIE_DEFAULT_SINGLECLICK true 42#define OPIE_DEFAULT_SINGLECLICK true
40#define OPIE_DEFAULT_INSERTTEAROFFHANDLES true 43#define OPIE_DEFAULT_INSERTTEAROFFHANDLES true
41#define OPIE_DEFAULT_AUTOSELECTDELAY -1 44#define OPIE_DEFAULT_AUTOSELECTDELAY -1
42#define OPIE_DEFAULT_CHANGECURSOR true 45#define OPIE_DEFAULT_CHANGECURSOR true
43#define OPIE_DEFAULT_LARGE_CURSOR false 46#define OPIE_DEFAULT_LARGE_CURSOR false
44#define OPIE_DEFAULT_VISUAL_ACTIVATE true 47#define OPIE_DEFAULT_VISUAL_ACTIVATE true
45#define OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED 50 48#define OPIE_DEFAULT_VISUAL_ACTIVATE_SPEED 50
46 49
47//FIXME: There's still a whole lot of stuff in here which has to be revised 50//FIXME: There's still a whole lot of stuff in here which has to be revised
48//FIXME: before public usage... lack of time to do it at once - so it will 51//FIXME: before public usage... lack of time to do it at once - so it will
49//FIXME: happen step-by-step. ML. 52//FIXME: happen step-by-step. ML.
50// we should not habe too much configure options!!!!!! -zecke 53// we should not habe too much configure options!!!!!! -zecke
51 54
55namespace Opie {
56namespace Core {
57
52/** 58/**
53 * Access the OPIE global configuration settings. 59 * Access the OPIE global configuration settings.
54 * 60 *
55 */ 61 */
56class OGlobalSettings 62class OGlobalSettings
57{ 63{
58 public: 64 public:
59 65
60 /** 66 /**
61 * Returns a threshold in pixels for drag & drop operations. 67 * Returns a threshold in pixels for drag & drop operations.
62 * As long as the mouse movement has not exceeded this number 68 * As long as the mouse movement has not exceeded this number
63 * of pixels in either X or Y direction no drag operation may 69 * of pixels in either X or Y direction no drag operation may
64 * be started. This prevents spurious drags when the user intended 70 * be started. This prevents spurious drags when the user intended
65 * to click on something but moved the mouse a bit while doing so. 71 * to click on something but moved the mouse a bit while doing so.
66 * 72 *
67 * For this to work you must save the position of the mouse (oldPos) 73 * For this to work you must save the position of the mouse (oldPos)
68 * in the @ref QWidget::mousePressEvent(). 74 * in the @ref QWidget::mousePressEvent().
69 * When the position of the mouse (newPos) 75 * When the position of the mouse (newPos)
70 * in a @ref QWidget::mouseMoveEvent() exceeds this threshold 76 * in a @ref QWidget::mouseMoveEvent() exceeds this threshold
71 * you may start a drag 77 * you may start a drag
72 * which should originate from oldPos. 78 * which should originate from oldPos.
73 * 79 *
74 * Example code: 80 * Example code:
75 * <pre> 81 * <pre>
76 * void OColorCells::mousePressEvent( QMouseEvent *e ) 82 * void OColorCells::mousePressEvent( QMouseEvent *e )
77 * { 83 * {
78 * mOldPos = e->pos(); 84 * mOldPos = e->pos();
79 * } 85 * }
80 * 86 *
81 * void OColorCells::mouseMoveEvent( QMouseEvent *e ) 87 * void OColorCells::mouseMoveEvent( QMouseEvent *e )
82 * { 88 * {
83 * if( !(e->state() && LeftButton)) return; 89 * if( !(e->state() && LeftButton)) return;
84 * 90 *
85 * int delay = OGlobalSettings::dndEventDelay(); 91 * int delay = OGlobalSettings::dndEventDelay();
86 * QPoint newPos = e->pos(); 92 * QPoint newPos = e->pos();
87 * if(newPos.x() > mOldPos.x()+delay || newPos.x() < mOldPos.x()-delay || 93 * if(newPos.x() > mOldPos.x()+delay || newPos.x() < mOldPos.x()-delay ||
88 * newPos.y() > mOldPos.y()+delay || newPos.y() < mOldPos.y()-delay) 94 * newPos.y() > mOldPos.y()+delay || newPos.y() < mOldPos.y()-delay)
89 * { 95 * {
90 * // Drag color object 96 * // Drag color object
91 * int cell = posToCell(mOldPos); // Find color at mOldPos 97 * int cell = posToCell(mOldPos); // Find color at mOldPos
92 * if ((cell != -1) && colors[cell].isValid()) 98 * if ((cell != -1) && colors[cell].isValid())
93 * { 99 * {
94 * OColorDrag *d = OColorDrag::makeDrag( colors[cell], this); 100 * OColorDrag *d = OColorDrag::makeDrag( colors[cell], this);
95 * d->dragCopy(); 101 * d->dragCopy();
96 * } 102 * }
97 * } 103 * }
98 * } 104 * }
99 * </pre> 105 * </pre>
@@ -323,51 +329,57 @@ class OGlobalSettings
323 * if the user wants OPIE to run on all of them or just on the primary 329 * if the user wants OPIE to run on all of them or just on the primary
324 */ 330 */
325 static bool isMultiHead(); 331 static bool isMultiHead();
326 332
327private: 333private:
328 /** 334 /**
329 * reads in all paths from kdeglobals 335 * reads in all paths from kdeglobals
330 */ 336 */
331 static void initStatic(); 337 static void initStatic();
332 /** 338 /**
333 * initialise kde2Blue 339 * initialise kde2Blue
334 */ 340 */
335 static void initColors(); 341 static void initColors();
336 /** 342 /**
337 * drop cached values for fonts (called by OApplication) 343 * drop cached values for fonts (called by OApplication)
338 */ 344 */
339 static void rereadFontSettings(); 345 static void rereadFontSettings();
340 /** 346 /**
341 * drop cached values for paths (called by OApplication) 347 * drop cached values for paths (called by OApplication)
342 */ 348 */
343 static void rereadPathSettings(); 349 static void rereadPathSettings();
344 /** 350 /**
345 * drop cached values for mouse settings (called by OApplication) 351 * drop cached values for mouse settings (called by OApplication)
346 */ 352 */
347 static void rereadMouseSettings(); 353 static void rereadMouseSettings();
348 354
349 355
350 static QString* s_desktopPath; 356 static QString* s_desktopPath;
351 static QString* s_autostartPath; 357 static QString* s_autostartPath;
352 static QString* s_trashPath; 358 static QString* s_trashPath;
353 static QString* s_documentPath; 359 static QString* s_documentPath;
354 static QFont *_generalFont; 360 static QFont *_generalFont;
355 static QFont *_fixedFont; 361 static QFont *_fixedFont;
356 static QFont *_toolBarFont; 362 static QFont *_toolBarFont;
357 static QFont *_menuFont; 363 static QFont *_menuFont;
358 static QFont *_windowTitleFont; 364 static QFont *_windowTitleFont;
359 static QFont *_taskbarFont; 365 static QFont *_taskbarFont;
360 static QColor * kde2Gray; 366 static QColor * kde2Gray;
361 static QColor * kde2Blue; 367 static QColor * kde2Blue;
362 static QColor * kde2AlternateColor; 368 static QColor * kde2AlternateColor;
363 static OMouseSettings *s_mouseSettings; 369 static OMouseSettings *s_mouseSettings;
364 370
365 static QColor * OpieGray; 371 static QColor * OpieGray;
366 static QColor * OpieBlue; 372 static QColor * OpieBlue;
367 static QColor * OpieAlternate; 373 static QColor * OpieAlternate;
368 static QColor * OpieHighlight; 374 static QColor * OpieHighlight;
369 375
370 friend class OApplication; 376 friend class OApplication;
377private:
378 class Private;
379 Private *d;
371}; 380};
372 381
382}
383}
384
373#endif 385#endif
diff --git a/libopie2/opiecore/opiecore.pro b/libopie2/opiecore/opiecore.pro
index 523d6a7..ff3c036 100644
--- a/libopie2/opiecore/opiecore.pro
+++ b/libopie2/opiecore/opiecore.pro
@@ -1,41 +1,39 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qt warn_on debug 2CONFIG += qt warn_on debug
3DESTDIR = $(OPIEDIR)/lib 3DESTDIR = $(OPIEDIR)/lib
4HEADERS = oapplication.h \ 4HEADERS = oapplication.h \
5 oconfig.h \ 5 oconfig.h \
6 odebug.h \ 6 odebug.h \
7 oglobal.h \ 7 oglobal.h \
8 oglobalsettings.h \ 8 oglobalsettings.h \
9 oprocess.h \ 9 oprocess.h \
10 oprocctrl.h \ 10 oprocctrl.h \
11 osmartpointer.h \ 11 osmartpointer.h \
12 ostorageinfo.h \ 12 ostorageinfo.h
13 xmltree.h
14 13
15SOURCES = oapplication.cpp \ 14SOURCES = oapplication.cpp \
16 oconfig.cpp \ 15 oconfig.cpp \
17 odebug.cpp \ 16 odebug.cpp \
18 oglobal.cpp \ 17 oglobal.cpp \
19 oglobalsettings.cpp \ 18 oglobalsettings.cpp \
20 oprocess.cpp \ 19 oprocess.cpp \
21 oprocctrl.cpp \ 20 oprocctrl.cpp \
22 ostorageinfo.cpp \ 21 ostorageinfo.cpp
23 xmltree.cc
24 22
25include ( device/device.pro ) 23include ( device/device.pro )
26 24
27INTERFACES = 25INTERFACES =
28TARGET = opiecore2 26TARGET = opiecore2
29VERSION = 1.8.5 27VERSION = 1.9.0
30INCLUDEPATH += $(OPIEDIR)/include 28INCLUDEPATH += $(OPIEDIR)/include
31DEPENDPATH += $(OPIEDIR)/include 29DEPENDPATH += $(OPIEDIR)/include
32 30
33!contains( platform, x11 ) { 31!contains( platform, x11 ) {
34 LIBS = -lqpe 32 LIBS = -lqpe
35 include ( $(OPIEDIR)/include.pro ) 33 include ( $(OPIEDIR)/include.pro )
36} 34}
37 35
38contains( platform, x11 ) { 36contains( platform, x11 ) {
39 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib 37 LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib
40} 38}
41 39
diff --git a/libopie2/opiecore/oprocctrl.cpp b/libopie2/opiecore/oprocctrl.cpp
index 0403526..46708ba 100644
--- a/libopie2/opiecore/oprocctrl.cpp
+++ b/libopie2/opiecore/oprocctrl.cpp
@@ -1,91 +1,93 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at) 2 Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19// 19//
20// KPROCESSCONTROLLER -- A helper class for KProcess 20// KPROCESSCONTROLLER -- A helper class for KProcess
21// 21//
22// version 0.3.1, Jan, 8th 1997 22// version 0.3.1, Jan, 8th 1997
23// 23//
24// (C) Christian Czezatke 24// (C) Christian Czezatke
25// e9025461@student.tuwien.ac.at 25// e9025461@student.tuwien.ac.at
26// Ported by Holger Freyther 26// Ported by Holger Freyther
27// 27//
28 28
29//#include <config.h> 29//#include <config.h>
30 30
31#include <sys/types.h> 31#include <sys/types.h>
32#include <sys/socket.h> 32#include <sys/socket.h>
33 33
34#include <errno.h> 34#include <errno.h>
35#include <fcntl.h> 35#include <fcntl.h>
36#include <stdio.h> 36#include <stdio.h>
37#include <string.h> 37#include <string.h>
38#include <unistd.h> 38#include <unistd.h>
39#include <assert.h> 39#include <assert.h>
40 40
41#include <qsocketnotifier.h> 41#include <qsocketnotifier.h>
42#include "oprocctrl.h" 42#include "oprocctrl.h"
43 43
44using namespace Opie::Core::Private;
45
44OProcessController *OProcessController::theOProcessController = 0; 46OProcessController *OProcessController::theOProcessController = 0;
45 47
46struct sigaction OProcessController::oldChildHandlerData; 48struct sigaction OProcessController::oldChildHandlerData;
47bool OProcessController::handlerSet = false; 49bool OProcessController::handlerSet = false;
48 50
49OProcessController::OProcessController() 51OProcessController::OProcessController()
50{ 52{
51 assert( theOProcessController == 0 ); 53 assert( theOProcessController == 0 );
52 54
53 if (0 > pipe(fd)) 55 if (0 > pipe(fd))
54 printf(strerror(errno)); 56 printf(strerror(errno));
55 57
56 notifier = new QSocketNotifier(fd[0], QSocketNotifier::Read); 58 notifier = new QSocketNotifier(fd[0], QSocketNotifier::Read);
57 notifier->setEnabled(true); 59 notifier->setEnabled(true);
58 QObject::connect(notifier, SIGNAL(activated(int)), 60 QObject::connect(notifier, SIGNAL(activated(int)),
59 this, SLOT(slotDoHousekeeping(int))); 61 this, SLOT(slotDoHousekeeping(int)));
60 connect( &delayedChildrenCleanupTimer, SIGNAL( timeout()), 62 connect( &delayedChildrenCleanupTimer, SIGNAL( timeout()),
61 SLOT( delayedChildrenCleanup())); 63 SLOT( delayedChildrenCleanup()));
62 64
63 theOProcessController = this; 65 theOProcessController = this;
64 66
65 setupHandlers(); 67 setupHandlers();
66} 68}
67 69
68 70
69void OProcessController::setupHandlers() 71void OProcessController::setupHandlers()
70{ 72{
71 if( handlerSet ) 73 if( handlerSet )
72 return; 74 return;
73 struct sigaction act; 75 struct sigaction act;
74 act.sa_handler=theSigCHLDHandler; 76 act.sa_handler=theSigCHLDHandler;
75 sigemptyset(&(act.sa_mask)); 77 sigemptyset(&(act.sa_mask));
76 sigaddset(&(act.sa_mask), SIGCHLD); 78 sigaddset(&(act.sa_mask), SIGCHLD);
77 // Make sure we don't block this signal. gdb tends to do that :-( 79 // Make sure we don't block this signal. gdb tends to do that :-(
78 sigprocmask(SIG_UNBLOCK, &(act.sa_mask), 0); 80 sigprocmask(SIG_UNBLOCK, &(act.sa_mask), 0);
79 81
80 act.sa_flags = SA_NOCLDSTOP; 82 act.sa_flags = SA_NOCLDSTOP;
81 83
82 // CC: take care of SunOS which automatically restarts interrupted system 84 // CC: take care of SunOS which automatically restarts interrupted system
83 // calls (and thus does not have SA_RESTART) 85 // calls (and thus does not have SA_RESTART)
84 86
85#ifdef SA_RESTART 87#ifdef SA_RESTART
86 act.sa_flags |= SA_RESTART; 88 act.sa_flags |= SA_RESTART;
87#endif 89#endif
88 90
89 sigaction( SIGCHLD, &act, &oldChildHandlerData ); 91 sigaction( SIGCHLD, &act, &oldChildHandlerData );
90 92
91 act.sa_handler=SIG_IGN; 93 act.sa_handler=SIG_IGN;
diff --git a/libopie2/opiecore/oprocctrl.h b/libopie2/opiecore/oprocctrl.h
index 44b8a48..4922ba2 100644
--- a/libopie2/opiecore/oprocctrl.h
+++ b/libopie2/opiecore/oprocctrl.h
@@ -1,121 +1,129 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at) 2 Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19// 19//
20// KPROCESSCONTROLLER -- A helper class for KProcess 20// KPROCESSCONTROLLER -- A helper class for KProcess
21// 21//
22// version 0.3.1, Jan 8th 1997 22// version 0.3.1, Jan 8th 1997
23// 23//
24// (C) Christian Czezatke 24// (C) Christian Czezatke
25// e9025461@student.tuwien.ac.at 25// e9025461@student.tuwien.ac.at
26// Ported by Holger Freyther 26// Ported by Holger Freyther
27// 27//
28 28
29#ifndef __KPROCCTRL_H__ 29#ifndef __KPROCCTRL_H__
30#define __KPROCCTRL_H__ 30#define __KPROCCTRL_H__
31 31
32#include <qvaluelist.h> 32#include <qvaluelist.h>
33#include <qtimer.h> 33#include <qtimer.h>
34 34
35#include "oprocess.h" 35#include "oprocess.h"
36 36
37class OProcessControllerPrivate;
38class QSocketNotifier; 37class QSocketNotifier;
39 38
39
40namespace Opie {
41namespace Core {
42namespace Private {
43class OProcessControllerPrivate;
44
40/** 45/**
41 * @short Used internally by @ref OProcess 46 * @short Used internally by @ref OProcess
42 * @internal 47 * @internal
43 * @author Christian Czezakte <e9025461@student.tuwien.ac.at> 48 * @author Christian Czezakte <e9025461@student.tuwien.ac.at>
44 * 49 *
45 * A class for internal use by OProcess only. -- Exactly one instance 50 * A class for internal use by OProcess only. -- Exactly one instance
46 * of this class is generated by the first instance of OProcess that is 51 * of this class is generated by the first instance of OProcess that is
47 * created (a pointer to it gets stored in @ref theOProcessController ). 52 * created (a pointer to it gets stored in @ref theOProcessController ).
48 * 53 *
49 * This class takes care of the actual (UN*X) signal handling. 54 * This class takes care of the actual (UN*X) signal handling.
50*/ 55*/
51class OProcessController : public QObject 56class OProcessController : public QObject
52{ 57{
53 Q_OBJECT 58 Q_OBJECT
54 59
55public: 60public:
56 OProcessController(); 61 OProcessController();
57 ~OProcessController(); 62 ~OProcessController();
58 //CC: WARNING! Destructor Not virtual (but you don't derive classes from this anyhow...) 63 //CC: WARNING! Destructor Not virtual (but you don't derive classes from this anyhow...)
59 64
60public: 65public:
61 66
62 /** 67 /**
63 * Only a single instance of this class is allowed at a time, 68 * Only a single instance of this class is allowed at a time,
64 * and this static variable is used to track the one instance. 69 * and this static variable is used to track the one instance.
65 */ 70 */
66 static OProcessController *theOProcessController; 71 static OProcessController *theOProcessController;
67 72
68 /** 73 /**
69 * Automatically called upon SIGCHLD. 74 * Automatically called upon SIGCHLD.
70 * 75 *
71 * Normally you do not need to do anything with this function but 76 * Normally you do not need to do anything with this function but
72 * if your application needs to disable SIGCHLD for some time for 77 * if your application needs to disable SIGCHLD for some time for
73 * reasons beyond your control, you should call this function afterwards 78 * reasons beyond your control, you should call this function afterwards
74 * to make sure that no SIGCHLDs where missed. 79 * to make sure that no SIGCHLDs where missed.
75 */ 80 */
76 static void theSigCHLDHandler(int signal); 81 static void theSigCHLDHandler(int signal);
77 // handler for sigchld 82 // handler for sigchld
78 83
79 /** 84 /**
80 * @internal 85 * @internal
81 */ 86 */
82 static void setupHandlers(); 87 static void setupHandlers();
83 /** 88 /**
84 * @internal 89 * @internal
85 */ 90 */
86 static void resetHandlers(); 91 static void resetHandlers();
87 /** 92 /**
88 * @internal 93 * @internal
89 */ 94 */
90 void addOProcess( OProcess* ); 95 void addOProcess( OProcess* );
91 /** 96 /**
92 * @internal 97 * @internal
93 */ 98 */
94 void removeOProcess( OProcess* ); 99 void removeOProcess( OProcess* );
95public slots: 100public slots:
96 /** 101 /**
97 * @internal 102 * @internal
98 */ 103 */
99 void slotDoHousekeeping(int socket); 104 void slotDoHousekeeping(int socket);
100 105
101private slots: 106private slots:
102 void delayedChildrenCleanup(); 107 void delayedChildrenCleanup();
103private: 108private:
104 int fd[2]; 109 int fd[2];
105 QSocketNotifier *notifier; 110 QSocketNotifier *notifier;
106 static struct sigaction oldChildHandlerData; 111 static struct sigaction oldChildHandlerData;
107 static bool handlerSet; 112 static bool handlerSet;
108 QValueList<OProcess*> processList; 113 QValueList<OProcess*> processList;
109 QTimer delayedChildrenCleanupTimer; 114 QTimer delayedChildrenCleanupTimer;
110 115
111 // Disallow assignment and copy-construction 116 // Disallow assignment and copy-construction
112 OProcessController( const OProcessController& ); 117 OProcessController( const OProcessController& );
113 OProcessController& operator= ( const OProcessController& ); 118 OProcessController& operator= ( const OProcessController& );
114 119
115 OProcessControllerPrivate *d; 120 OProcessControllerPrivate *d;
116}; 121};
117 122
123}
124}
125}
118 126
119 127
120#endif 128#endif
121 129
diff --git a/libopie2/opiecore/oprocess.cpp b/libopie2/opiecore/oprocess.cpp
index 6349c83..dfde74a 100644
--- a/libopie2/opiecore/oprocess.cpp
+++ b/libopie2/opiecore/oprocess.cpp
@@ -16,108 +16,113 @@ _;:,     .>    :=|. This program is free software; you can
16    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17   : ..    .:,     . . . without even the implied warranty of 17   : ..    .:,     . . . without even the implied warranty of
18   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22:     =  ...= . :.=- 22:     =  ...= . :.=-
23-.   .:....=;==+<; You should have received a copy of the GNU 23-.   .:....=;==+<; You should have received a copy of the GNU
24 -_. . .   )=.  = Library General Public License along with 24 -_. . .   )=.  = Library General Public License along with
25   --        :-=` this library; see the file COPYING.LIB. 25   --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include "oprocctrl.h" 31#include "oprocctrl.h"
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/oprocess.h> 34#include <opie2/oprocess.h>
35 35
36/* QT */ 36/* QT */
37 37
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qdir.h> 39#include <qdir.h>
40#include <qmap.h> 40#include <qmap.h>
41#include <qsocketnotifier.h> 41#include <qsocketnotifier.h>
42#include <qtextstream.h> 42#include <qtextstream.h>
43 43
44/* STD */ 44/* STD */
45#include <errno.h> 45#include <errno.h>
46#include <fcntl.h> 46#include <fcntl.h>
47#include <pwd.h> 47#include <pwd.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <signal.h> 49#include <signal.h>
50#include <stdio.h> 50#include <stdio.h>
51#include <string.h> 51#include <string.h>
52#include <sys/time.h> 52#include <sys/time.h>
53#include <sys/types.h> 53#include <sys/types.h>
54#include <sys/stat.h> 54#include <sys/stat.h>
55#include <sys/socket.h> 55#include <sys/socket.h>
56#include <unistd.h> 56#include <unistd.h>
57#ifdef HAVE_SYS_SELECT_H 57#ifdef HAVE_SYS_SELECT_H
58#include <sys/select.h> 58#include <sys/select.h>
59#endif 59#endif
60#ifdef HAVE_INITGROUPS 60#ifdef HAVE_INITGROUPS
61#include <grp.h> 61#include <grp.h>
62#endif 62#endif
63 63
64using namespace Opie::Core::Private;
65
66namespace Opie {
67namespace Core {
68namespace Private {
64class OProcessPrivate 69class OProcessPrivate
65{ 70{
66public: 71public:
67 OProcessPrivate() : useShell( false ) 72 OProcessPrivate() : useShell( false )
68 { } 73 { }
69 74
70 bool useShell; 75 bool useShell;
71 QMap<QString, QString> env; 76 QMap<QString, QString> env;
72 QString wd; 77 QString wd;
73 QCString shell; 78 QCString shell;
74}; 79};
75 80}
76 81
77OProcess::OProcess( QObject *parent, const char *name ) 82OProcess::OProcess( QObject *parent, const char *name )
78 : QObject( parent, name ) 83 : QObject( parent, name )
79{ 84{
80 init ( ); 85 init ( );
81} 86}
82 87
83OProcess::OProcess( const QString &arg0, QObject *parent, const char *name ) 88OProcess::OProcess( const QString &arg0, QObject *parent, const char *name )
84 : QObject( parent, name ) 89 : QObject( parent, name )
85{ 90{
86 init ( ); 91 init ( );
87 *this << arg0; 92 *this << arg0;
88} 93}
89 94
90OProcess::OProcess( const QStringList &args, QObject *parent, const char *name ) 95OProcess::OProcess( const QStringList &args, QObject *parent, const char *name )
91 : QObject( parent, name ) 96 : QObject( parent, name )
92{ 97{
93 init ( ); 98 init ( );
94 *this << args; 99 *this << args;
95} 100}
96 101
97void OProcess::init ( ) 102void OProcess::init ( )
98{ 103{
99 run_mode = NotifyOnExit; 104 run_mode = NotifyOnExit;
100 runs = false; 105 runs = false;
101 pid_ = 0; 106 pid_ = 0;
102 status = 0; 107 status = 0;
103 keepPrivs = false; 108 keepPrivs = false;
104 innot = 0; 109 innot = 0;
105 outnot = 0; 110 outnot = 0;
106 errnot = 0; 111 errnot = 0;
107 communication = NoCommunication; 112 communication = NoCommunication;
108 input_data = 0; 113 input_data = 0;
109 input_sent = 0; 114 input_sent = 0;
110 input_total = 0; 115 input_total = 0;
111 d = 0; 116 d = 0;
112 117
113 if ( 0 == OProcessController::theOProcessController ) 118 if ( 0 == OProcessController::theOProcessController )
114 { 119 {
115 ( void ) new OProcessController(); 120 ( void ) new OProcessController();
116 CHECK_PTR( OProcessController::theOProcessController ); 121 CHECK_PTR( OProcessController::theOProcessController );
117 } 122 }
118 123
119 OProcessController::theOProcessController->addOProcess( this ); 124 OProcessController::theOProcessController->addOProcess( this );
120 out[ 0 ] = out[ 1 ] = -1; 125 out[ 0 ] = out[ 1 ] = -1;
121 in[ 0 ] = in[ 1 ] = -1; 126 in[ 0 ] = in[ 1 ] = -1;
122 err[ 0 ] = err[ 1 ] = -1; 127 err[ 0 ] = err[ 1 ] = -1;
123} 128}
@@ -896,48 +901,51 @@ bool OProcess::isExecutable( const QCString &filename )
896 ( S_ISCHR( fileinfo.st_mode ) ) || 901 ( S_ISCHR( fileinfo.st_mode ) ) ||
897 ( S_ISBLK( fileinfo.st_mode ) ) || 902 ( S_ISBLK( fileinfo.st_mode ) ) ||
898#ifdef S_ISSOCK 903#ifdef S_ISSOCK
899 // CC: SYSVR4 systems don't have that macro 904 // CC: SYSVR4 systems don't have that macro
900 ( S_ISSOCK( fileinfo.st_mode ) ) || 905 ( S_ISSOCK( fileinfo.st_mode ) ) ||
901#endif 906#endif
902 ( S_ISFIFO( fileinfo.st_mode ) ) || 907 ( S_ISFIFO( fileinfo.st_mode ) ) ||
903 ( S_ISDIR( fileinfo.st_mode ) ) ) 908 ( S_ISDIR( fileinfo.st_mode ) ) )
904 { 909 {
905 return false; 910 return false;
906 } 911 }
907 912
908 // CC: now check for permission to execute the file 913 // CC: now check for permission to execute the file
909 if ( access( filename.data(), X_OK ) != 0 ) 914 if ( access( filename.data(), X_OK ) != 0 )
910 return false; 915 return false;
911 916
912 // CC: we've passed all the tests... 917 // CC: we've passed all the tests...
913 return true; 918 return true;
914} 919}
915 920
916int OProcess::processPID( const QString& process ) 921int OProcess::processPID( const QString& process )
917{ 922{
918 QString line; 923 QString line;
919 QDir d = QDir( "/proc" ); 924 QDir d = QDir( "/proc" );
920 QStringList dirs = d.entryList( QDir::Dirs ); 925 QStringList dirs = d.entryList( QDir::Dirs );
921 QStringList::Iterator it; 926 QStringList::Iterator it;
922 for ( it = dirs.begin(); it != dirs.end(); ++it ) 927 for ( it = dirs.begin(); it != dirs.end(); ++it )
923 { 928 {
924 //qDebug( "next entry: %s", (const char*) *it ); 929 //qDebug( "next entry: %s", (const char*) *it );
925 QFile file( "/proc/"+*it+"/cmdline" ); 930 QFile file( "/proc/"+*it+"/cmdline" );
926 file.open( IO_ReadOnly ); 931 file.open( IO_ReadOnly );
927 if ( !file.isOpen() ) continue; 932 if ( !file.isOpen() ) continue;
928 QTextStream t( &file ); 933 QTextStream t( &file );
929 line = t.readLine(); 934 line = t.readLine();
930 //qDebug( "cmdline = %s", (const char*) line ); 935 //qDebug( "cmdline = %s", (const char*) line );
931 if ( line.contains( process ) ) break; //FIXME: That may find also other process, if the name is not long enough ;) 936 if ( line.contains( process ) ) break; //FIXME: That may find also other process, if the name is not long enough ;)
932 } 937 }
933 if ( line.contains( process ) ) 938 if ( line.contains( process ) )
934 { 939 {
935 //qDebug( "found process id #%d", (*it).toInt() ); 940 //qDebug( "found process id #%d", (*it).toInt() );
936 return (*it).toInt(); 941 return (*it).toInt();
937 } 942 }
938 else 943 else
939 { 944 {
940 //qDebug( "process '%s' not found", (const char*) process ); 945 //qDebug( "process '%s' not found", (const char*) process );
941 return 0; 946 return 0;
942 } 947 }
943} 948}
949
950}
951}
diff --git a/libopie2/opiecore/oprocess.h b/libopie2/opiecore/oprocess.h
index 1a2472d..eb56b03 100644
--- a/libopie2/opiecore/oprocess.h
+++ b/libopie2/opiecore/oprocess.h
@@ -1,94 +1,100 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3             Copyright (C) 2003-2004 Holger Freyther <zecke@handhelds.org> 3             Copyright (C) 2003-2004 Holger Freyther <zecke@handhelds.org>
4 Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 =. Based on KProcess (C) 1997 Christian Czezatke (e9025461@student.tuwien.ac.at) 5 =. Based on KProcess (C) 1997 Christian Czezatke (e9025461@student.tuwien.ac.at)
6 .=l. 6 .=l.
7          .>+-= 7          .>+-=
8_;:,     .>    :=|. This program is free software; you can 8_;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12- .   .-<_>     .<> Foundation; either version 2 of the License, 12- .   .-<_>     .<> Foundation; either version 2 of the License,
13    ._= =}       : or (at your option) any later version. 13    ._= =}       : or (at your option) any later version.
14   .%`+i>       _;_. 14   .%`+i>       _;_.
15   .i_,=:_.      -<s. This program is distributed in the hope that 15   .i_,=:_.      -<s. This program is distributed in the hope that
16    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17   : ..    .:,     . . . without even the implied warranty of 17   : ..    .:,     . . . without even the implied warranty of
18   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22:     =  ...= . :.=- 22:     =  ...= . :.=-
23-.   .:....=;==+<; You should have received a copy of the GNU 23-.   .:....=;==+<; You should have received a copy of the GNU
24 -_. . .   )=.  = Library General Public License along with 24 -_. . .   )=.  = Library General Public License along with
25   --        :-=` this library; see the file COPYING.LIB. 25   --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#ifndef OPROCESS_H 31#ifndef OPROCESS_H
32#define OPROCESS_H 32#define OPROCESS_H
33 33
34/* QT */ 34/* QT */
35#include <qcstring.h> 35#include <qcstring.h>
36#include <qobject.h> 36#include <qobject.h>
37#include <qvaluelist.h> 37#include <qvaluelist.h>
38 38
39/* STD */ 39/* STD */
40#include <sys/types.h> // for pid_t 40#include <sys/types.h> // for pid_t
41#include <sys/wait.h> 41#include <sys/wait.h>
42#include <signal.h> 42#include <signal.h>
43#include <unistd.h> 43#include <unistd.h>
44 44
45class QSocketNotifier; 45class QSocketNotifier;
46
47namespace Opie {
48namespace Core {
49namespace Private {
50class OProcessController;
46class OProcessPrivate; 51class OProcessPrivate;
52}
47 53
48/** 54/**
49 * Child process invocation, monitoring and control. 55 * Child process invocation, monitoring and control.
50 * 56 *
51 * @sect General usage and features 57 * @sect General usage and features
52 * 58 *
53 *This class allows a KDE and OPIE application to start child processes without having 59 *This class allows a KDE and OPIE application to start child processes without having
54 *to worry about UN*X signal handling issues and zombie process reaping. 60 *to worry about UN*X signal handling issues and zombie process reaping.
55 * 61 *
56 *@see KProcIO 62 *@see KProcIO
57 * 63 *
58 *Basically, this class distinguishes three different ways of running 64 *Basically, this class distinguishes three different ways of running
59 *child processes: 65 *child processes:
60 * 66 *
61 *@li OProcess::DontCare -- The child process is invoked and both the child 67 *@li OProcess::DontCare -- The child process is invoked and both the child
62 *process and the parent process continue concurrently. 68 *process and the parent process continue concurrently.
63 * 69 *
64 *Starting a DontCare child process means that the application is 70 *Starting a DontCare child process means that the application is
65 *not interested in any notification to determine whether the 71 *not interested in any notification to determine whether the
66 *child process has already exited or not. 72 *child process has already exited or not.
67 * 73 *
68 *@li OProcess::NotifyOnExit -- The child process is invoked and both the 74 *@li OProcess::NotifyOnExit -- The child process is invoked and both the
69 *child and the parent process run concurrently. 75 *child and the parent process run concurrently.
70 * 76 *
71 *When the child process exits, the OProcess instance 77 *When the child process exits, the OProcess instance
72 *corresponding to it emits the Qt signal @ref processExited(). 78 *corresponding to it emits the Qt signal @ref processExited().
73 * 79 *
74 *Since this signal is @em not emitted from within a UN*X 80 *Since this signal is @em not emitted from within a UN*X
75 *signal handler, arbitrary function calls can be made. 81 *signal handler, arbitrary function calls can be made.
76 * 82 *
77 *Be aware: When the OProcess objects gets destructed, the child 83 *Be aware: When the OProcess objects gets destructed, the child
78 *process will be killed if it is still running! 84 *process will be killed if it is still running!
79 *This means in particular, that you cannot use a OProcess on the stack 85 *This means in particular, that you cannot use a OProcess on the stack
80 *with OProcess::NotifyOnExit. 86 *with OProcess::NotifyOnExit.
81 * 87 *
82 *@li OProcess::Block -- The child process starts and the parent process 88 *@li OProcess::Block -- The child process starts and the parent process
83 *is suspended until the child process exits. (@em Really not recommended 89 *is suspended until the child process exits. (@em Really not recommended
84 *for programs with a GUI.) 90 *for programs with a GUI.)
85 * 91 *
86 *OProcess also provides several functions for determining the exit status 92 *OProcess also provides several functions for determining the exit status
87 *and the pid of the child process it represents. 93 *and the pid of the child process it represents.
88 * 94 *
89 *Furthermore it is possible to supply command-line arguments to the process 95 *Furthermore it is possible to supply command-line arguments to the process
90 *in a clean fashion (no null -- terminated stringlists and such...) 96 *in a clean fashion (no null -- terminated stringlists and such...)
91 * 97 *
92 *A small usage example: 98 *A small usage example:
93 *<pre> 99 *<pre>
94 *OProcess *proc = new OProcess; 100 *OProcess *proc = new OProcess;
@@ -352,96 +358,97 @@ public:
352 * @li Transmission of data to the child process by a previous call to 358 * @li Transmission of data to the child process by a previous call to
353 * @ref writeStdin() is still in progress. 359 * @ref writeStdin() is still in progress.
354 * 360 *
355 * Please note that the data is sent to the client asynchronously, 361 * Please note that the data is sent to the client asynchronously,
356 * so when this function returns, the data might not have been 362 * so when this function returns, the data might not have been
357 * processed by the child process. 363 * processed by the child process.
358 * 364 *
359 * If all the data has been sent to the client, the signal 365 * If all the data has been sent to the client, the signal
360 * @ref wroteStdin() will be emitted. 366 * @ref wroteStdin() will be emitted.
361 * 367 *
362 * Please note that you must not free "buffer" or call @ref writeStdin() 368 * Please note that you must not free "buffer" or call @ref writeStdin()
363 * again until either a @ref wroteStdin() signal indicates that the 369 * again until either a @ref wroteStdin() signal indicates that the
364 * data has been sent or a @ref processHasExited() signal shows that 370 * data has been sent or a @ref processHasExited() signal shows that
365 * the child process is no longer alive... 371 * the child process is no longer alive...
366 **/ 372 **/
367 bool writeStdin( const char *buffer, int buflen ); 373 bool writeStdin( const char *buffer, int buflen );
368 374
369 void flushStdin(); 375 void flushStdin();
370 376
371 /** 377 /**
372 * This causes the stdin file descriptor of the child process to be 378 * This causes the stdin file descriptor of the child process to be
373 * closed indicating an "EOF" to the child. 379 * closed indicating an "EOF" to the child.
374 * 380 *
375 * @return @p false if no communication to the process's stdin 381 * @return @p false if no communication to the process's stdin
376 * had been specified in the call to @ref start(). 382 * had been specified in the call to @ref start().
377 */ 383 */
378 bool closeStdin(); 384 bool closeStdin();
379 385
380 /** 386 /**
381 * This causes the stdout file descriptor of the child process to be 387 * This causes the stdout file descriptor of the child process to be
382 * closed. 388 * closed.
383 * 389 *
384 * @return @p false if no communication to the process's stdout 390 * @return @p false if no communication to the process's stdout
385 * had been specified in the call to @ref start(). 391 * had been specified in the call to @ref start().
386 */ 392 */
387 bool closeStdout(); 393 bool closeStdout();
388 394
389 /** 395 /**
390 * This causes the stderr file descriptor of the child process to be 396 * This causes the stderr file descriptor of the child process to be
391 * closed. 397 * closed.
392 * 398 *
393 * @return @p false if no communication to the process's stderr 399 * @return @p false if no communication to the process's stderr
394 * had been specified in the call to @ref start(). 400 * had been specified in the call to @ref start().
395 */ 401 */
396 bool closeStderr(); 402 bool closeStderr();
397 403
398 /** 404 /**
399 * Lets you see what your arguments are for debugging. 405 * Lets you see what your arguments are for debugging.
406 * \todo make const
400 */ 407 */
401 408
402 const QValueList<QCString> &args() 409 const QValueList<QCString> &args()
403 { 410 {
404 return arguments; 411 return arguments;
405 } 412 }
406 413
407 /** 414 /**
408 * Controls whether the started process should drop any 415 * Controls whether the started process should drop any
409 * setuid/segid privileges or whether it should keep them 416 * setuid/segid privileges or whether it should keep them
410 * 417 *
411 * The default is @p false : drop privileges 418 * The default is @p false : drop privileges
412 */ 419 */
413 void setRunPrivileged( bool keepPrivileges ); 420 void setRunPrivileged( bool keepPrivileges );
414 421
415 /** 422 /**
416 * Returns whether the started process will drop any 423 * Returns whether the started process will drop any
417 * setuid/segid privileges or whether it will keep them 424 * setuid/segid privileges or whether it will keep them
418 */ 425 */
419 bool runPrivileged() const; 426 bool runPrivileged() const;
420 427
421 /** 428 /**
422 * Modifies the environment of the process to be started. 429 * Modifies the environment of the process to be started.
423 * This function must be called before starting the process. 430 * This function must be called before starting the process.
424 */ 431 */
425 void setEnvironment( const QString &name, const QString &value ); 432 void setEnvironment( const QString &name, const QString &value );
426 433
427 /** 434 /**
428 * Changes the current working directory (CWD) of the process 435 * Changes the current working directory (CWD) of the process
429 * to be started. 436 * to be started.
430 * This function must be called before starting the process. 437 * This function must be called before starting the process.
431 */ 438 */
432 void setWorkingDirectory( const QString &dir ); 439 void setWorkingDirectory( const QString &dir );
433 440
434 /** 441 /**
435 * Specify whether to start the command via a shell or directly. 442 * Specify whether to start the command via a shell or directly.
436 * The default is to start the command directly. 443 * The default is to start the command directly.
437 * If @p useShell is true @p shell will be used as shell, or 444 * If @p useShell is true @p shell will be used as shell, or
438 * if shell is empty, the standard shell is used. 445 * if shell is empty, the standard shell is used.
439 * @p quote A flag indicating whether to quote the arguments. 446 * @p quote A flag indicating whether to quote the arguments.
440 * 447 *
441 * When using a shell, the caller should make sure that all filenames etc. 448 * When using a shell, the caller should make sure that all filenames etc.
442 * are properly quoted when passed as argument. 449 * are properly quoted when passed as argument.
443 * @see quote() 450 * @see quote()
444 */ 451 */
445 void setUseShell( bool useShell, const char *shell = 0 ); 452 void setUseShell( bool useShell, const char *shell = 0 );
446 453
447 /** 454 /**
@@ -671,82 +678,84 @@ protected:
671 */ 678 */
672 virtual void commClose(); 679 virtual void commClose();
673 680
674 681
675 /** 682 /**
676 * the socket descriptors for stdin/stdout/stderr. 683 * the socket descriptors for stdin/stdout/stderr.
677 */ 684 */
678 int out[ 2 ]; 685 int out[ 2 ];
679 int in[ 2 ]; 686 int in[ 2 ];
680 int err[ 2 ]; 687 int err[ 2 ];
681 688
682 /** 689 /**
683 * The socket notifiers for the above socket descriptors. 690 * The socket notifiers for the above socket descriptors.
684 */ 691 */
685 QSocketNotifier *innot; 692 QSocketNotifier *innot;
686 QSocketNotifier *outnot; 693 QSocketNotifier *outnot;
687 QSocketNotifier *errnot; 694 QSocketNotifier *errnot;
688 695
689 /** 696 /**
690 * Lists the communication links that are activated for the child 697 * Lists the communication links that are activated for the child
691 * process. Should not be modified from derived classes. 698 * process. Should not be modified from derived classes.
692 */ 699 */
693 Communication communication; 700 Communication communication;
694 701
695 /** 702 /**
696 * Called by "slotChildOutput" this function copies data arriving from the 703 * Called by "slotChildOutput" this function copies data arriving from the
697 * child process's stdout to the respective buffer and emits the signal 704 * child process's stdout to the respective buffer and emits the signal
698 * "@ref receivedStderr". 705 * "@ref receivedStderr".
699 */ 706 */
700 int childOutput( int fdno ); 707 int childOutput( int fdno );
701 708
702 /** 709 /**
703 * Called by "slotChildOutput" this function copies data arriving from the 710 * Called by "slotChildOutput" this function copies data arriving from the
704 * child process's stdout to the respective buffer and emits the signal 711 * child process's stdout to the respective buffer and emits the signal
705 * "@ref receivedStderr" 712 * "@ref receivedStderr"
706 */ 713 */
707 int childError( int fdno ); 714 int childError( int fdno );
708 715
709 // information about the data that has to be sent to the child: 716 // information about the data that has to be sent to the child:
710 717
711 const char *input_data; // the buffer holding the data 718 const char *input_data; // the buffer holding the data
712 int input_sent; // # of bytes already transmitted 719 int input_sent; // # of bytes already transmitted
713 int input_total; // total length of input_data 720 int input_total; // total length of input_data
714 721
715 /** 722 /**
716 * @ref OProcessController is a friend of OProcess because it has to have 723 * @ref OProcessController is a friend of OProcess because it has to have
717 * access to various data members. 724 * access to various data members.
718 */ 725 */
719 friend class OProcessController; 726 friend class Private::OProcessController;
720 727
721private: 728private:
722 /** 729 /**
723 * Searches for a valid shell. 730 * Searches for a valid shell.
724 * Here is the algorithm used for finding an executable shell: 731 * Here is the algorithm used for finding an executable shell:
725 * 732 *
726 * @li Try the executable pointed to by the "SHELL" environment 733 * @li Try the executable pointed to by the "SHELL" environment
727 * variable with white spaces stripped off 734 * variable with white spaces stripped off
728 * 735 *
729 * @li If your process runs with uid != euid or gid != egid, a shell 736 * @li If your process runs with uid != euid or gid != egid, a shell
730 * not listed in /etc/shells will not used. 737 * not listed in /etc/shells will not used.
731 * 738 *
732 * @li If no valid shell could be found, "/bin/sh" is used as a last resort. 739 * @li If no valid shell could be found, "/bin/sh" is used as a last resort.
733 */ 740 */
734 QCString searchShell(); 741 QCString searchShell();
735 742
736 /** 743 /**
737 * Used by @ref searchShell in order to find out whether the shell found 744 * Used by @ref searchShell in order to find out whether the shell found
738 * is actually executable at all. 745 * is actually executable at all.
739 */ 746 */
740 bool isExecutable( const QCString &filename ); 747 bool isExecutable( const QCString &filename );
741 748
742 // Disallow assignment and copy-construction 749 // Disallow assignment and copy-construction
743 OProcess( const OProcess& ); 750 OProcess( const OProcess& );
744 OProcess& operator= ( const OProcess& ); 751 OProcess& operator= ( const OProcess& );
745 752
746private: 753private:
747 void init ( ); 754 void init ( );
748 OProcessPrivate *d; 755 Private::OProcessPrivate *d;
749}; 756};
757}
758}
750 759
751#endif 760#endif
752 761
diff --git a/libopie2/opiecore/osmartpointer.h b/libopie2/opiecore/osmartpointer.h
index 9000e71..8f9da7f 100644
--- a/libopie2/opiecore/osmartpointer.h
+++ b/libopie2/opiecore/osmartpointer.h
@@ -1,90 +1,91 @@
1// -*- Mode: C++; -*- 1// -*- Mode: C++; -*-
2/* 2/*
3 This file is part of the Opie Project 3 This file is part of the Opie Project
4 Copyright (C) 2004 Rajko Albrecht <alwin@handhelds.org> 4 Copyright (C) 2004 Rajko Albrecht <alwin@handhelds.org>
5 Copyright (C) The Opie Team <opie-devel@handhelds.org> 5 Copyright (C) The Opie Team <opie-devel@handhelds.org>
6 =. 6 =.
7 .=l. 7 .=l.
8 .>+-= 8 .>+-=
9_;:, .> :=|. This program is free software; you can 9_;:, .> :=|. This program is free software; you can
10.> <`_, > . <= redistribute it and/or modify it under 10.> <`_, > . <= redistribute it and/or modify it under
11:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 11:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
12.="- .-=="i, .._ License as published by the Free Software 12.="- .-=="i, .._ License as published by the Free Software
13- . .-<_> .<> Foundation; either version 2 of the License, 13- . .-<_> .<> Foundation; either version 2 of the License,
14 ._= =} : or (at your option) any later version. 14 ._= =} : or (at your option) any later version.
15 .%`+i> _;_. 15 .%`+i> _;_.
16 .i_,=:_. -<s. This program is distributed in the hope that 16 .i_,=:_. -<s. This program is distributed in the hope that
17 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 17 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
18 : .. .:, . . . without even the implied warranty of 18 : .. .:, . . . without even the implied warranty of
19 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 19 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
20 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 20 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
21..}^=.= = ; Library General Public License for more 21..}^=.= = ; Library General Public License for more
22++= -. .` .: details. 22++= -. .` .: details.
23: = ...= . :.=- 23: = ...= . :.=-
24-. .:....=;==+<; You should have received a copy of the GNU 24-. .:....=;==+<; You should have received a copy of the GNU
25 -_. . . )=. = Library General Public License along with 25 -_. . . )=. = Library General Public License along with
26 -- :-=` this library; see the file COPYING.LIB. 26 -- :-=` this library; see the file COPYING.LIB.
27 If not, write to the Free Software Foundation, 27 If not, write to the Free Software Foundation,
28 Inc., 59 Temple Place - Suite 330, 28 Inc., 59 Temple Place - Suite 330,
29 Boston, MA 02111-1307, USA. 29 Boston, MA 02111-1307, USA.
30*/ 30*/
31 31
32#ifndef _OSmartPointer_h 32#ifndef _OSmartPointer_h
33#define _OSmartPointer_h 33#define _OSmartPointer_h
34 34
35/*! 35/*!
36 * \file OSmartPointer.h 36 * \file OSmartPointer.h
37 * \brief smart pointer and reference counter 37 * \brief smart pointer and reference counter
38 * \author Rajko Albrecht 38 * \author Rajko Albrecht
39 * 39 *
40 */ 40 */
41 41
42namespace Opie { 42namespace Opie {
43namespace Core {
43 44
44//! simple reference counter class 45//! simple reference counter class
45class ORefCount { 46class ORefCount {
46protected: 47protected:
47 //! reference count member 48 //! reference count member
48 long m_RefCount; 49 long m_RefCount;
49public: 50public:
50 //! first reference must be added after "new" via Pointer() 51 //! first reference must be added after "new" via Pointer()
51 ORefCount() : m_RefCount(0) 52 ORefCount() : m_RefCount(0)
52 {} 53 {}
53 virtual ~ORefCount() {} 54 virtual ~ORefCount() {}
54 //! add a reference 55 //! add a reference
55 void Incr() { 56 void Incr() {
56 ++m_RefCount; 57 ++m_RefCount;
57 } 58 }
58 //! delete a reference 59 //! delete a reference
59 void Decr() { 60 void Decr() {
60 --m_RefCount; 61 --m_RefCount;
61 } 62 }
62 //! is it referenced 63 //! is it referenced
63 bool Shared() { return (m_RefCount > 0); } 64 bool Shared() { return (m_RefCount > 0); }
64}; 65};
65 66
66//! reference counting wrapper class 67//! reference counting wrapper class
67template<class T> class OSmartPointer { 68template<class T> class OSmartPointer {
68 //! pointer to object 69 //! pointer to object
69 /*! 70 /*!
70 * this object must contain Incr(), Decr() and Shared() 71 * this object must contain Incr(), Decr() and Shared()
71 * methode as public members. The best way is, that it will be a child 72 * methode as public members. The best way is, that it will be a child
72 * class of RefCount 73 * class of RefCount
73 */ 74 */
74 T *ptr; 75 T *ptr;
75public: 76public:
76 //! standart constructor 77 //! standart constructor
77 OSmartPointer() { ptr = NULL; } 78 OSmartPointer() { ptr = NULL; }
78 //! standart destructor 79 //! standart destructor
79 /*! 80 /*!
80 * release the reference, if it were the last reference, destroys 81 * release the reference, if it were the last reference, destroys
81 * ptr 82 * ptr
82 */ 83 */
83 ~OSmartPointer() 84 ~OSmartPointer()
84 { 85 {
85 if (ptr){ 86 if (ptr){
86 ptr->Decr(); 87 ptr->Decr();
87 if (!ptr->Shared()) 88 if (!ptr->Shared())
88 delete ptr; 89 delete ptr;
89 } 90 }
90 } 91 }
@@ -95,51 +96,52 @@ public:
95 { if (ptr = p.ptr) ptr->Incr(); } 96 { if (ptr = p.ptr) ptr->Incr(); }
96 //! pointer copy by assignment 97 //! pointer copy by assignment
97 OSmartPointer<T>& operator= (const OSmartPointer<T>& p) 98 OSmartPointer<T>& operator= (const OSmartPointer<T>& p)
98 { 99 {
99 // already same: nothing to do 100 // already same: nothing to do
100 if (ptr == p.ptr) return *this; 101 if (ptr == p.ptr) return *this;
101 // decouple reference 102 // decouple reference
102 if (ptr) { ptr->Decr(); if (!ptr->Shared()) delete ptr; } 103 if (ptr) { ptr->Decr(); if (!ptr->Shared()) delete ptr; }
103 // establish new reference 104 // establish new reference
104 if (ptr = p.ptr) ptr->Incr(); 105 if (ptr = p.ptr) ptr->Incr();
105 return *this; 106 return *this;
106 } 107 }
107 OSmartPointer<T>& operator= (T*p) 108 OSmartPointer<T>& operator= (T*p)
108 { 109 {
109 if (ptr==p)return *this; 110 if (ptr==p)return *this;
110 if (ptr) { 111 if (ptr) {
111 ptr->Decr(); 112 ptr->Decr();
112 if (!ptr->Shared()) delete ptr; 113 if (!ptr->Shared()) delete ptr;
113 } 114 }
114 if (ptr=p) ptr->Incr(); 115 if (ptr=p) ptr->Incr();
115 return *this; 116 return *this;
116 } 117 }
117 118
118 //! cast to conventional pointer 119 //! cast to conventional pointer
119 operator T* () const { return ptr; } 120 operator T* () const { return ptr; }
120 121
121 //! deref: fails for NULL pointer 122 //! deref: fails for NULL pointer
122 T& operator* () {return *ptr; } 123 T& operator* () {return *ptr; }
123 //! deref: fails for NULL pointer 124 //! deref: fails for NULL pointer
124 const T& operator* ()const {return *ptr; } 125 const T& operator* ()const {return *ptr; }
125 126
126 //! deref with method call 127 //! deref with method call
127 T* operator-> () {return ptr; } 128 T* operator-> () {return ptr; }
128 //! deref with const method call 129 //! deref with const method call
129 const T* operator-> ()const {return ptr; } 130 const T* operator-> ()const {return ptr; }
130 131
131 //! supports "if (pointer)" 132 //! supports "if (pointer)"
132 operator bool () const { return (ptr != NULL); } 133 operator bool () const { return (ptr != NULL); }
133 //! "if (pointer)" as non const 134 //! "if (pointer)" as non const
134 operator bool () { return ptr != NULL;} 135 operator bool () { return ptr != NULL;}
135 136
136 //! support if (!pointer)" 137 //! support if (!pointer)"
137 bool operator! () const { return (ptr == NULL); } 138 bool operator! () const { return (ptr == NULL); }
138 //! support if (!pointer)" as non const 139 //! support if (!pointer)" as non const
139 bool operator! () { return (ptr == NULL); } 140 bool operator! () { return (ptr == NULL); }
140}; 141};
141 142
142} 143}
144}
143 145
144#endif 146#endif
145 147
diff --git a/libopie2/opiecore/ostorageinfo.cpp b/libopie2/opiecore/ostorageinfo.cpp
index aa8d2fc..8fcf5fc 100644
--- a/libopie2/opiecore/ostorageinfo.cpp
+++ b/libopie2/opiecore/ostorageinfo.cpp
@@ -1,79 +1,81 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2004 Andreas 'ar' Richter <ar@oszine.de> 3              Copyright (C) 2004 Andreas 'ar' Richter <ar@oszine.de>
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 <opie2/ostorageinfo.h> 30#include <opie2/ostorageinfo.h>
31 31
32using namespace Opie::Core;
33
32OStorageInfo::OStorageInfo( QObject *parent ) 34OStorageInfo::OStorageInfo( QObject *parent )
33 : StorageInfo( parent ) 35 : StorageInfo( parent )
34{ 36{
35} 37}
36 38
37OStorageInfo::~OStorageInfo() 39OStorageInfo::~OStorageInfo()
38{ 40{
39} 41}
40 42
41QString OStorageInfo::cfPath()const 43QString OStorageInfo::cfPath()const
42{ 44{
43 QString r = ""; 45 QString r = "";
44 46
45 for (QListIterator<FileSystem> i( fileSystems() ); i.current(); ++i) 47 for (QListIterator<FileSystem> i( fileSystems() ); i.current(); ++i)
46 { 48 {
47 if ( (*i)->disk().left( 8 ) == "/dev/hda" ) 49 if ( (*i)->disk().left( 8 ) == "/dev/hda" )
48 { 50 {
49 r = (*i)->path(); 51 r = (*i)->path();
50 break; 52 break;
51 } 53 }
52 } 54 }
53 return r; 55 return r;
54} 56}
55 57
56QString OStorageInfo::sdPath()const 58QString OStorageInfo::sdPath()const
57{ 59{
58 QString r = ""; 60 QString r = "";
59 61
60 for (QListIterator<FileSystem> i( fileSystems() ); i.current(); ++i) 62 for (QListIterator<FileSystem> i( fileSystems() ); i.current(); ++i)
61 { 63 {
62 if ( (*i)->disk().left( 9 ) == "/dev/mmcd" ) 64 if ( (*i)->disk().left( 9 ) == "/dev/mmcd" )
63 { 65 {
64 r = (*i)->path(); 66 r = (*i)->path();
65 break; 67 break;
66 } 68 }
67 } 69 }
68 return r; 70 return r;
69} 71}
70 72
71QString OStorageInfo::mmcPath()const 73QString OStorageInfo::mmcPath()const
72{ 74{
73 QString r = ""; 75 QString r = "";
74 76
75 for (QListIterator<FileSystem> i( fileSystems() ); i.current(); ++i) 77 for (QListIterator<FileSystem> i( fileSystems() ); i.current(); ++i)
76 { 78 {
77 if ( (*i)->disk().left( 14 ) == "/dev/mmc/part1" ) 79 if ( (*i)->disk().left( 14 ) == "/dev/mmc/part1" )
78 { 80 {
79 r = (*i)->path(); 81 r = (*i)->path();
diff --git a/libopie2/opiecore/ostorageinfo.h b/libopie2/opiecore/ostorageinfo.h
index 740fa85..4e1097f 100644
--- a/libopie2/opiecore/ostorageinfo.h
+++ b/libopie2/opiecore/ostorageinfo.h
@@ -1,62 +1,70 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) 2004 Andreas 'ar' Richter <ar@oszine.de> 3              Copyright (C) 2004 Andreas 'ar' Richter <ar@oszine.de>
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#ifndef OSTORAGE_H 30#ifndef OSTORAGE_H
31#define OSTORAGE_H 31#define OSTORAGE_H
32 32
33#include <qpe/storage.h> 33#include <qpe/storage.h>
34 34
35namespace Opie {
36namespace Core {
37
35class OStorageInfo : public StorageInfo 38class OStorageInfo : public StorageInfo
36{ 39{
37 Q_OBJECT 40 Q_OBJECT
38 41
39 public: 42 public:
40 43
41 OStorageInfo( QObject *parent=0 ); 44 OStorageInfo( QObject *parent=0 );
42 ~OStorageInfo(); 45 ~OStorageInfo();
43 46
44 /** 47 /**
45 * @returns the mount path of the CF (Compact Flash) card 48 * @returns the mount path of the CF (Compact Flash) card
46 * 49 *
47 **/ 50 **/
48 QString cfPath() const; 51 QString cfPath() const;
49 /** 52 /**
50 * @returns the mount path of the SD (Secure Digital) card 53 * @returns the mount path of the SD (Secure Digital) card
51 * 54 *
52 **/ 55 **/
53 QString sdPath() const; 56 QString sdPath() const;
54 /** 57 /**
55 * @returns the mount path of the MMC (MultiMedia) card 58 * @returns the mount path of the MMC (MultiMedia) card
56 * 59 *
57 **/ 60 **/
58 QString mmcPath() const; 61 QString mmcPath() const;
62private:
63 class Private;
64 Private *d;
59}; 65};
60 66
67}
68}
61#endif // OSTORAGE_H 69#endif // OSTORAGE_H
62 70
diff --git a/libopie2/opiecore/xmltree.cc b/libopie2/opiecore/xmltree.cc
deleted file mode 100644
index 059791b..0000000
--- a/libopie2/opiecore/xmltree.cc
+++ b/dev/null
@@ -1,323 +0,0 @@
1/* This file is part of the KDE project
2 Copyright (C) 2001 Simon Hausmann <hausmann@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA.
18*/
19
20#include <opie2/xmltree.h>
21
22#include <qpe/stringutil.h>
23
24#include <qxml.h>
25
26#include <assert.h>
27
28using namespace Opie;
29
30XMLElement::XMLElement()
31 : m_parent( 0 ), m_next( 0 ), m_prev( 0 ), m_first( 0 ), m_last( 0 )
32{
33}
34
35XMLElement::~XMLElement()
36{
37 XMLElement *n = m_first;
38
39 while ( n )
40 {
41 XMLElement *tmp = n;
42 n = n->m_next;
43 delete tmp;
44 }
45}
46
47void XMLElement::appendChild( XMLElement *child )
48{
49 if ( child->m_parent )
50 child->m_parent->removeChild( child );
51
52 child->m_parent = this;
53
54 if ( m_last )
55 m_last->m_next = child;
56
57 child->m_prev = m_last;
58
59 if ( !m_first )
60 m_first = child;
61
62 m_last = child;
63}
64
65void XMLElement::insertAfter( XMLElement *newChild, XMLElement *refChild )
66{
67 assert( newChild != refChild );
68
69 if ( refChild == m_last )
70 {
71 appendChild( newChild );
72 return;
73 }
74
75 assert( refChild );
76 assert( refChild->m_parent );
77 assert( refChild->m_parent == this );
78
79 if ( newChild->m_parent && newChild != refChild )
80 newChild->m_parent->removeChild( newChild );
81
82 newChild->m_parent = this;
83
84 XMLElement *next = refChild->m_next;
85
86 refChild->m_next = newChild;
87
88 newChild->m_prev = refChild;
89 newChild->m_next = next;
90
91 if ( next )
92 next->m_prev = newChild;
93}
94
95QString XMLElement::attribute( const QString &attr ) const
96{
97 AttributeMap::ConstIterator it = m_attributes.find( attr );
98 if ( it == m_attributes.end() )
99 return QString::null;
100 return it.data();
101}
102
103void XMLElement::setAttribute( const QString &attr, const QString &value )
104{
105 m_attributes.replace( attr, value );
106}
107
108void XMLElement::insertBefore( XMLElement *newChild, XMLElement *refChild )
109{
110 assert( refChild );
111 assert( refChild->m_parent );
112 assert( refChild->m_parent == this );
113 assert( newChild != refChild );
114
115 if ( newChild->m_parent && newChild != refChild )
116 newChild->m_parent->removeChild( newChild );
117
118 newChild->m_parent = this;
119
120 XMLElement *prev = refChild->m_prev;
121
122 refChild->m_prev = newChild;
123
124 newChild->m_prev = prev;
125 newChild->m_next = refChild;
126
127 if ( prev )
128 prev->m_next = newChild;
129
130 if ( refChild == m_first )
131 m_first = newChild;
132}
133
134void XMLElement::removeChild( XMLElement *child )
135{
136 if ( child->m_parent != this )
137 return;
138
139 if ( m_first == child )
140 m_first = child->m_next;
141
142 if ( m_last == child )
143 m_last = child->m_prev;
144
145 if ( child->m_prev )
146 child->m_prev->m_next = child->m_next;
147
148 if ( child->m_next )
149 child->m_next->m_prev = child->m_prev;
150
151 child->m_parent = 0;
152 child->m_prev = 0;
153 child->m_next = 0;
154}
155
156void XMLElement::save( QTextStream &s, uint indent )
157{
158 if ( !m_value.isEmpty() )
159 {
160 s << Qtopia::escapeString( m_value );
161 return;
162 }
163
164 for ( uint i = 0; i < indent; ++i )
165 s << " ";
166
167 s << "<" << m_tag;
168
169 if ( !m_attributes.isEmpty() )
170 {
171 s << " ";
172 AttributeMap::ConstIterator it = m_attributes.begin();
173 AttributeMap::ConstIterator end = m_attributes.end();
174 for (; it != end; ++it )
175 {
176 s << it.key() << "=\"" << Qtopia::escapeString( it.data() ) << "\"";
177 s << " ";
178 }
179 }
180
181 if ( m_last )
182 {
183 if ( ( m_first && !m_first->value().isEmpty() ) || !m_parent )
184 s << ">";
185 else
186 s << ">" << endl;
187
188 int newIndent = indent;
189 if ( m_parent )
190 newIndent++;
191
192 XMLElement *n = m_first;
193 while ( n )
194 {
195 n->save( s, newIndent );
196 n = n->nextChild();
197 }
198
199 if ( m_last && m_last->value().isEmpty() && m_parent )
200 for ( uint i = 0; i < indent; ++i )
201 s << " ";
202
203 if ( m_parent )
204 s << "</" << m_tag << ">" << endl;
205 }
206 else
207 s << "/>" << endl;
208}
209
210class Handler : public QXmlDefaultHandler
211{
212public:
213 Handler() : m_node( 0 ), m_root( 0 ) {}
214
215 XMLElement *root() const { return m_root; }
216
217 virtual bool startDocument();
218 virtual bool endDocument();
219 virtual bool startElement( const QString &ns, const QString &ln, const QString &qName,
220 const QXmlAttributes &attr );
221 virtual bool endElement( const QString &ns, const QString &ln, const QString &qName );
222 virtual bool characters( const QString &ch );
223
224private:
225 XMLElement *m_node;
226 XMLElement *m_root;
227};
228
229bool Handler::startDocument()
230{
231 m_root = m_node = new XMLElement;
232
233 return true;
234}
235
236bool Handler::endDocument()
237{
238 return m_root == m_node;
239}
240
241bool Handler::startElement( const QString &, const QString &, const QString &qName,
242 const QXmlAttributes &attr )
243{
244 XMLElement *bm = new XMLElement;
245
246 XMLElement::AttributeMap attributes;
247 for ( int i = 0; i < attr.length(); ++i )
248 attributes[ attr.qName( i ) ] = attr.value( i );
249
250 bm->setAttributes( attributes );
251
252 bm->setTagName( qName );
253
254 m_node->appendChild( bm );
255 m_node = bm;
256
257 return true;
258}
259
260bool Handler::endElement( const QString &, const QString &, const QString & )
261{
262 if ( m_node == m_root )
263 return false;
264
265 m_node = m_node->parent();
266 return true;
267}
268
269bool Handler::characters( const QString &ch )
270{
271 XMLElement *textNode = new XMLElement;
272 textNode->setValue( ch );
273 m_node->appendChild( textNode );
274 return true;
275}
276
277XMLElement *XMLElement::namedItem( const QString &name )
278{
279 XMLElement *e = m_first;
280
281 for (; e; e = e->nextChild() )
282 if ( e->tagName() == name )
283 return e;
284
285 return 0;
286}
287
288XMLElement *XMLElement::clone() const
289{
290 XMLElement *res = new XMLElement;
291
292 res->setTagName( m_tag );
293 res->setValue( m_value );
294 res->setAttributes( m_attributes );
295
296 XMLElement *e = m_first;
297 for (; e; e = e->m_next )
298 res->appendChild( e->clone() );
299
300 return res;
301}
302
303XMLElement *XMLElement::load( const QString &fileName )
304{
305 QFile f( fileName );
306 if ( !f.open( IO_ReadOnly ) )
307 return 0;
308
309 QTextStream stream( &f );
310 stream.setEncoding( QTextStream::UnicodeUTF8 );
311 QXmlInputSource src( stream );
312 QXmlSimpleReader reader;
313 Handler handler;
314
315 reader.setFeature( "http://trolltech.com/xml/features/report-whitespace-only-CharData", false );
316 reader.setContentHandler( &handler );
317 reader.parse( src );
318
319 return handler.root();;
320}
321
322/* vim: et sw=4
323 */
diff --git a/libopie2/opiecore/xmltree.h b/libopie2/opiecore/xmltree.h
deleted file mode 100644
index 4b6bdfa..0000000
--- a/libopie2/opiecore/xmltree.h
+++ b/dev/null
@@ -1,119 +0,0 @@
1/* This file is part of the KDE project
2 Copyright (C) 2000,2001 Simon Hausmann <hausmann@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA.
18*/
19
20
21#ifndef __bookmarks_h__
22#define __bookmarks_h__
23
24#include <qstring.h>
25#include <qmap.h>
26#include <qtextstream.h>
27
28namespace Opie
29{
30
31/**
32 * A small xml lib written by Simon Hausmann.
33 */
34class XMLElement
35{
36public:
37 typedef QMap<QString, QString> AttributeMap;
38
39 /**
40 * The constructor of XMLElement
41 */
42 XMLElement();
43 ~XMLElement();
44
45 /** appendChild appends a child to the XMLElement behind the last element.
46 * The ownership of the child get's transfered to the
47 * this XMLElement.
48 * If child is already the child of another parent
49 * it's get removed from the other parent first.
50 */
51 void appendChild( XMLElement *child );
52
53 /** inserts newChild after refChild. If newChild is the child
54 * of another parent the child will get removed.
55 * The ownership of child gets transfered.
56 *
57 */
58 void insertAfter( XMLElement *newChild, XMLElement *refChild );
59
60 /** same as insertAfter but the element get's inserted before refChild.
61 *
62 */
63 void insertBefore( XMLElement *newChild, XMLElement *refChild );
64
65 /** removeChild removes the child from the XMLElement.
66 * The ownership gets dropped. You need to delete the
67 * child yourself.
68 */
69 void removeChild( XMLElement *child );
70
71 /** parent() returns the parent of this XMLElement
72 * If there is no parent 0l gets returned
73 */
74 XMLElement *parent() const { return m_parent; }
75 XMLElement *firstChild() const { return m_first; }
76 XMLElement *nextChild() const { return m_next; }
77 XMLElement *prevChild() const { return m_prev; }
78 XMLElement *lastChild() const { return m_last; }
79
80 void setTagName( const QString &tag ) { m_tag = tag; }
81 QString tagName() const { return m_tag; }
82
83 void setValue( const QString &val ) { m_value = val; }
84 QString value() const { return m_value; }
85
86 void setAttributes( const AttributeMap &attrs ) { m_attributes = attrs; }
87 AttributeMap attributes() const { return m_attributes; }
88 AttributeMap &attributes() { return m_attributes; }
89
90 QString attribute( const QString & ) const;
91 void setAttribute( const QString &attr, const QString &value );
92 void save( QTextStream &stream, uint indent = 0 );
93
94 XMLElement *namedItem( const QString &name );
95
96 XMLElement *clone() const;
97
98 static XMLElement *load( const QString &fileName );
99
100private:
101 QString m_tag;
102 QString m_value;
103 AttributeMap m_attributes;
104
105 XMLElement *m_parent;
106 XMLElement *m_next;
107 XMLElement *m_prev;
108 XMLElement *m_first;
109 XMLElement *m_last;
110
111 XMLElement( const XMLElement &rhs );
112 XMLElement &operator=( const XMLElement &rhs );
113 class Private;
114 Private* d;
115};
116
117} // namespace Opie
118
119#endif