summaryrefslogtreecommitdiff
path: root/libopie2
authorzecke <zecke>2004-04-04 21:27:42 (UTC)
committer zecke <zecke>2004-04-04 21:27:42 (UTC)
commitf664b509b5e622ab74560fb74093175e50b2790c (patch) (unidiff)
treed46acaa8dd49ab2de70aebcdcf57bce1276c6fd1 /libopie2
parenteb2831b5c94c4c27b8282842c9709234f5365e01 (diff)
downloadopie-f664b509b5e622ab74560fb74093175e50b2790c.zip
opie-f664b509b5e622ab74560fb74093175e50b2790c.tar.gz
opie-f664b509b5e622ab74560fb74093175e50b2790c.tar.bz2
Opie::XYZ::Private -> Opie::XYZ::Internal
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp10
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.h2
-rw-r--r--libopie2/opiecore/device/odevice_jornada.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_jornada.h2
-rw-r--r--libopie2/opiecore/device/odevice_ramses.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_ramses.h2
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_simpad.h2
-rw-r--r--libopie2/opiecore/device/odevice_yopy.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_yopy.h2
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp10
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.h2
-rw-r--r--libopie2/opiecore/device/odevicebutton.cpp8
-rw-r--r--libopie2/opiecore/device/odevicebutton.h4
-rw-r--r--libopie2/opiecore/oapplication.cpp4
-rw-r--r--libopie2/opiecore/oapplication.h4
-rw-r--r--libopie2/opiecore/oconfig.h6
-rw-r--r--libopie2/opiecore/odebug.cpp11
-rw-r--r--libopie2/opiecore/oprocctrl.cpp8
-rw-r--r--libopie2/opiecore/oprocctrl.h8
-rw-r--r--libopie2/opiecore/oprocess.cpp4
-rw-r--r--libopie2/opiecore/oprocess.h6
-rw-r--r--libopie2/opiedb/osqlitedriver.cpp2
-rw-r--r--libopie2/opiedb/osqlitedriver.h2
-rw-r--r--libopie2/opiedb/osqlmanager.cpp4
-rw-r--r--libopie2/opienet/odebugmapper.cpp2
-rw-r--r--libopie2/opienet/odebugmapper.h2
-rw-r--r--libopie2/opienet/onetutils.cpp2
-rw-r--r--libopie2/opienet/onetutils.h2
-rw-r--r--libopie2/opienet/onetwork.cpp4
-rw-r--r--libopie2/opieui/big-screen/obigscreen_p.h2
-rw-r--r--libopie2/opieui/big-screen/osplitter.cpp6
-rw-r--r--libopie2/opieui/big-screen/osplitter.h6
-rw-r--r--libopie2/opieui/fileselector/ofileselector.cpp5
-rw-r--r--libopie2/opieui/fileselector/ofileselector.h12
-rw-r--r--libopie2/opieui/fileselector/ofileselector_p.h2
-rw-r--r--libopie2/opieui/ofontselector.cpp4
-rw-r--r--libopie2/opieui/ofontselector.h4
-rw-r--r--libopie2/opieui/okeyconfigwidget.cpp41
-rw-r--r--libopie2/opieui/okeyconfigwidget.h8
-rw-r--r--libopie2/opieui/okeyconfigwidget_p.h2
-rw-r--r--libopie2/opieui/otaskbarapplet.h4
43 files changed, 116 insertions, 105 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 1ad0327..ee66d95 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,216 +1,216 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Opie Team <opie-devel@handhelds.org> 3 Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7_;:, .> :=|. This program is free software; you can 7_;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21: = ...= . :.=- 21: = ...= . :.=-
22-. .:....=;==+<; You should have received a copy of the GNU 22-. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_ipaq.h" 30#include "odevice_ipaq.h"
31#include "odevice_jornada.h" 31#include "odevice_jornada.h"
32#include "odevice_ramses.h" 32#include "odevice_ramses.h"
33#include "odevice_simpad.h" 33#include "odevice_simpad.h"
34#include "odevice_yopy.h" 34#include "odevice_yopy.h"
35#include "odevice_zaurus.h" 35#include "odevice_zaurus.h"
36 36
37/* QT */ 37/* QT */
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
41#include <qwindowsystem_qws.h> 41#include <qwindowsystem_qws.h>
42 42
43/* OPIE */ 43/* OPIE */
44#include <qpe/config.h> 44#include <qpe/config.h>
45#include <qpe/resource.h> 45#include <qpe/resource.h>
46#include <qpe/sound.h> 46#include <qpe/sound.h>
47#include <qpe/qcopenvelope_qws.h> 47#include <qpe/qcopenvelope_qws.h>
48 48
49/* STD */ 49/* STD */
50#include <fcntl.h> 50#include <fcntl.h>
51#include <math.h> 51#include <math.h>
52#include <stdlib.h> 52#include <stdlib.h>
53#include <signal.h> 53#include <signal.h>
54#include <sys/ioctl.h> 54#include <sys/ioctl.h>
55#include <sys/time.h> 55#include <sys/time.h>
56#include <unistd.h> 56#include <unistd.h>
57#ifndef QT_NO_SOUND 57#ifndef QT_NO_SOUND
58#include <linux/soundcard.h> 58#include <linux/soundcard.h>
59#endif 59#endif
60 60
61const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 61const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
62 62
63using namespace Opie::Core; 63using namespace Opie::Core;
64 64
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 Private::Zaurus(); 84 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
85 else if ( line.contains( "ipaq", false ) ) dev = new Private::iPAQ(); 85 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
86 else if ( line.contains( "simpad", false ) ) dev = new Private::SIMpad(); 86 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
87 else if ( line.contains( "jornada", false ) ) dev = new Private::Jornada(); 87 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
88 else if ( line.contains( "ramses", false ) ) dev = new Private::Ramses(); 88 else if ( line.contains( "ramses", false ) ) dev = new Internal::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.", PATH_PROC_CPUINFO ); 96 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
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*/
137void ODevice::initButtons() 137void ODevice::initButtons()
138{ 138{
139 if ( d->m_buttons ) 139 if ( d->m_buttons )
140 return; 140 return;
141 141
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
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 177fd4c..2efcd3a 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -1,186 +1,186 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_ipaq.h" 30#include "odevice_ipaq.h"
31 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 56
57using namespace Opie::Core; 57using namespace Opie::Core;
58using namespace Opie::Core::Private; 58using namespace Opie::Core::Internal;
59 59
60/* KERNEL */ 60/* KERNEL */
61#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 ))
62 62
63#define OD_IO(type,number) OD_IOC(0,type,number,0) 63#define OD_IO(type,number) OD_IOC(0,type,number,0)
64#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))
65#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))
66#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))
67 67
68typedef struct { 68typedef struct {
69 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 69 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
70 unsigned char TotalTime; /* Units of 5 seconds */ 70 unsigned char TotalTime; /* Units of 5 seconds */
71 unsigned char OnTime; /* units of 100m/s */ 71 unsigned char OnTime; /* units of 100m/s */
72 unsigned char OffTime; /* units of 100m/s */ 72 unsigned char OffTime; /* units of 100m/s */
73} LED_IN; 73} LED_IN;
74 74
75typedef struct { 75typedef struct {
76 unsigned char mode; 76 unsigned char mode;
77 unsigned char pwr; 77 unsigned char pwr;
78 unsigned char brightness; 78 unsigned char brightness;
79} FLITE_IN; 79} FLITE_IN;
80 80
81#define LED_ON OD_IOW( 'f', 5, LED_IN ) 81#define LED_ON OD_IOW( 'f', 5, LED_IN )
82#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 82#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
83 83
84struct i_button ipaq_buttons [] = { 84struct i_button ipaq_buttons [] = {
85 { 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,
86 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 86 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
87 "devicebuttons/ipaq_calendar", 87 "devicebuttons/ipaq_calendar",
88 "datebook", "nextView()", 88 "datebook", "nextView()",
89 "today", "raise()" }, 89 "today", "raise()" },
90 { 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,
91 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 91 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
92 "devicebuttons/ipaq_contact", 92 "devicebuttons/ipaq_contact",
93 "addressbook", "raise()", 93 "addressbook", "raise()",
94 "addressbook", "beamBusinessCard()" }, 94 "addressbook", "beamBusinessCard()" },
95 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 95 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
96 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 96 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
97 "devicebuttons/ipaq_menu", 97 "devicebuttons/ipaq_menu",
98 "QPE/TaskBar", "toggleMenu()", 98 "QPE/TaskBar", "toggleMenu()",
99 "QPE/TaskBar", "toggleStartMenu()" }, 99 "QPE/TaskBar", "toggleStartMenu()" },
100 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 100 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
101 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 101 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
102 "devicebuttons/ipaq_mail", 102 "devicebuttons/ipaq_mail",
103 "mail", "raise()", 103 "mail", "raise()",
104 "mail", "newMail()" }, 104 "mail", "newMail()" },
105 { 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,
106 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 106 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
107 "devicebuttons/ipaq_home", 107 "devicebuttons/ipaq_home",
108 "QPE/Launcher", "home()", 108 "QPE/Launcher", "home()",
109 "buttonsettings", "raise()" }, 109 "buttonsettings", "raise()" },
110 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 110 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
111 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 111 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
112 "devicebuttons/ipaq_record", 112 "devicebuttons/ipaq_record",
113 "QPE/VMemo", "toggleRecord()", 113 "QPE/VMemo", "toggleRecord()",
114 "sound", "raise()" }, 114 "sound", "raise()" },
115}; 115};
116 116
117void iPAQ::init() 117void iPAQ::init()
118{ 118{
119 d->m_vendorstr = "HP"; 119 d->m_vendorstr = "HP";
120 d->m_vendor = Vendor_HP; 120 d->m_vendor = Vendor_HP;
121 121
122 QFile f ( "/proc/hal/model" ); 122 QFile f ( "/proc/hal/model" );
123 123
124 if ( f. open ( IO_ReadOnly )) { 124 if ( f. open ( IO_ReadOnly )) {
125 QTextStream ts ( &f ); 125 QTextStream ts ( &f );
126 126
127 d->m_modelstr = "H" + ts. readLine(); 127 d->m_modelstr = "H" + ts. readLine();
128 128
129 if ( d->m_modelstr == "H3100" ) 129 if ( d->m_modelstr == "H3100" )
130 d->m_model = Model_iPAQ_H31xx; 130 d->m_model = Model_iPAQ_H31xx;
131 else if ( d->m_modelstr == "H3600" ) 131 else if ( d->m_modelstr == "H3600" )
132 d->m_model = Model_iPAQ_H36xx; 132 d->m_model = Model_iPAQ_H36xx;
133 else if ( d->m_modelstr == "H3700" ) 133 else if ( d->m_modelstr == "H3700" )
134 d->m_model = Model_iPAQ_H37xx; 134 d->m_model = Model_iPAQ_H37xx;
135 else if ( d->m_modelstr == "H3800" ) 135 else if ( d->m_modelstr == "H3800" )
136 d->m_model = Model_iPAQ_H38xx; 136 d->m_model = Model_iPAQ_H38xx;
137 else if ( d->m_modelstr == "H3900" ) 137 else if ( d->m_modelstr == "H3900" )
138 d->m_model = Model_iPAQ_H39xx; 138 d->m_model = Model_iPAQ_H39xx;
139 else if ( d->m_modelstr == "H5400" ) 139 else if ( d->m_modelstr == "H5400" )
140 d->m_model = Model_iPAQ_H5xxx; 140 d->m_model = Model_iPAQ_H5xxx;
141 else 141 else
142 d->m_model = Model_Unknown; 142 d->m_model = Model_Unknown;
143 143
144 f. close(); 144 f. close();
145 } 145 }
146 146
147 switch ( d->m_model ) { 147 switch ( d->m_model ) {
148 case Model_iPAQ_H31xx: 148 case Model_iPAQ_H31xx:
149 case Model_iPAQ_H38xx: 149 case Model_iPAQ_H38xx:
150 d->m_rotation = Rot90; 150 d->m_rotation = Rot90;
151 break; 151 break;
152 case Model_iPAQ_H36xx: 152 case Model_iPAQ_H36xx:
153 case Model_iPAQ_H37xx: 153 case Model_iPAQ_H37xx:
154 case Model_iPAQ_H39xx: 154 case Model_iPAQ_H39xx:
155 155
156 default: 156 default:
157 d->m_rotation = Rot270; 157 d->m_rotation = Rot270;
158 break; 158 break;
159 case Model_iPAQ_H5xxx: 159 case Model_iPAQ_H5xxx:
160 d->m_rotation = Rot0; 160 d->m_rotation = Rot0;
161 } 161 }
162 162
163 f. setName ( "/etc/familiar-version" ); 163 f. setName ( "/etc/familiar-version" );
164 if ( f. open ( IO_ReadOnly )) { 164 if ( f. open ( IO_ReadOnly )) {
165 d->m_systemstr = "Familiar"; 165 d->m_systemstr = "Familiar";
166 d->m_system = System_Familiar; 166 d->m_system = System_Familiar;
167 167
168 QTextStream ts ( &f ); 168 QTextStream ts ( &f );
169 d->m_sysverstr = ts. readLine(). mid ( 10 ); 169 d->m_sysverstr = ts. readLine(). mid ( 10 );
170 170
171 f. close(); 171 f. close();
172 } else { 172 } else {
173 f. setName ( "/etc/oz_version" ); 173 f. setName ( "/etc/oz_version" );
174 174
175 if ( f. open ( IO_ReadOnly )) { 175 if ( f. open ( IO_ReadOnly )) {
176 d->m_systemstr = "OpenEmbedded/iPaq"; 176 d->m_systemstr = "OpenEmbedded/iPaq";
177 d->m_system = System_Familiar; 177 d->m_system = System_Familiar;
178 178
179 QTextStream ts ( &f ); 179 QTextStream ts ( &f );
180 ts.setDevice ( &f ); 180 ts.setDevice ( &f );
181 d->m_sysverstr = ts. readLine(); 181 d->m_sysverstr = ts. readLine();
182 f. close(); 182 f. close();
183 } 183 }
184 } 184 }
185 185
186 m_leds [0] = m_leds [1] = Led_Off; 186 m_leds [0] = m_leds [1] = Led_Off;
diff --git a/libopie2/opiecore/device/odevice_ipaq.h b/libopie2/opiecore/device/odevice_ipaq.h
index 4f4af46..968f715 100644
--- a/libopie2/opiecore/device/odevice_ipaq.h
+++ b/libopie2/opiecore/device/odevice_ipaq.h
@@ -1,90 +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
38namespace Opie { 38namespace Opie {
39namespace Core { 39namespace Core {
40namespace Private { 40namespace Internal {
41 41
42class iPAQ : public ODevice, public QWSServer::KeyboardFilter 42class iPAQ : public ODevice, public QWSServer::KeyboardFilter
43{ 43{
44 44
45 protected: 45 protected:
46 virtual void init(); 46 virtual void init();
47 virtual void initButtons(); 47 virtual void initButtons();
48 48
49 public: 49 public:
50 virtual bool setSoftSuspend( bool soft ); 50 virtual bool setSoftSuspend( bool soft );
51 51
52 virtual bool setDisplayBrightness( int b ); 52 virtual bool setDisplayBrightness( int b );
53 virtual int displayBrightnessResolution() const; 53 virtual int displayBrightnessResolution() const;
54 54
55 virtual void playAlarmSound(); 55 virtual void playAlarmSound();
56 56
57 virtual QValueList <OLed> ledList() const; 57 virtual QValueList <OLed> ledList() const;
58 virtual QValueList <OLedState> ledStateList( OLed led ) const; 58 virtual QValueList <OLedState> ledStateList( OLed led ) const;
59 virtual OLedState ledState( OLed led ) const; 59 virtual OLedState ledState( OLed led ) const;
60 virtual bool setLedState( OLed led, OLedState st ); 60 virtual bool setLedState( OLed led, OLedState st );
61 61
62 virtual bool hasLightSensor() const; 62 virtual bool hasLightSensor() const;
63 virtual int readLightSensor(); 63 virtual int readLightSensor();
64 virtual int lightSensorResolution() const; 64 virtual int lightSensorResolution() const;
65 65
66 protected: 66 protected:
67 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 );
68 virtual void timerEvent( QTimerEvent *te ); 68 virtual void timerEvent( QTimerEvent *te );
69 69
70 int m_power_timer; 70 int m_power_timer;
71 71
72 OLedState m_leds [2]; 72 OLedState m_leds [2];
73}; 73};
74 74
75struct i_button { 75struct i_button {
76 uint model; 76 uint model;
77 Qt::Key code; 77 Qt::Key code;
78 char *utext; 78 char *utext;
79 char *pix; 79 char *pix;
80 char *fpressedservice; 80 char *fpressedservice;
81 char *fpressedaction; 81 char *fpressedaction;
82 char *fheldservice; 82 char *fheldservice;
83 char *fheldaction; 83 char *fheldaction;
84}; 84};
85 85
86} 86}
87} 87}
88} 88}
89 89
90#endif 90#endif
diff --git a/libopie2/opiecore/device/odevice_jornada.cpp b/libopie2/opiecore/device/odevice_jornada.cpp
index b79b0b5..eaa93ca 100644
--- a/libopie2/opiecore/device/odevice_jornada.cpp
+++ b/libopie2/opiecore/device/odevice_jornada.cpp
@@ -1,150 +1,150 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_jornada.h" 30#include "odevice_jornada.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/* 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::Core::Private; 80using namespace Opie::Core::Internal;
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;
129} 129}
130 130
131 131
132bool Jornada::setSoftSuspend( bool soft ) 132bool Jornada::setSoftSuspend( bool soft )
133{ 133{
134 bool res = false; 134 bool res = false;
135 int fd; 135 int fd;
136 136
137 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 137 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
138 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 138 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
139 res = true; 139 res = true;
140 else 140 else
141 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 141 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
142 142
143 ::close ( fd ); 143 ::close ( fd );
144 } 144 }
145 else 145 else
146 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 146 ::perror ( "/proc/sys/ts/suspend_button_mode" );
147 147
148 return res; 148 return res;
149} 149}
150 150
diff --git a/libopie2/opiecore/device/odevice_jornada.h b/libopie2/opiecore/device/odevice_jornada.h
index c37d75e..e2e67af 100644
--- a/libopie2/opiecore/device/odevice_jornada.h
+++ b/libopie2/opiecore/device/odevice_jornada.h
@@ -1,53 +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
35namespace Opie { 35namespace Opie {
36namespace Core { 36namespace Core {
37namespace Private { 37namespace Internal {
38class Jornada : public ODevice 38class Jornada : public ODevice
39{ 39{
40 40
41 protected: 41 protected:
42 virtual void init(); 42 virtual void init();
43 43
44 public: 44 public:
45 virtual bool setSoftSuspend ( bool soft ); 45 virtual bool setSoftSuspend ( bool soft );
46 virtual bool setDisplayBrightness ( int b ); 46 virtual bool setDisplayBrightness ( int b );
47 virtual int displayBrightnessResolution() const; 47 virtual int displayBrightnessResolution() const;
48}; 48};
49} 49}
50} 50}
51} 51}
52#endif 52#endif
53 53
diff --git a/libopie2/opiecore/device/odevice_ramses.cpp b/libopie2/opiecore/device/odevice_ramses.cpp
index 77de8c5..10b7b61 100644
--- a/libopie2/opiecore/device/odevice_ramses.cpp
+++ b/libopie2/opiecore/device/odevice_ramses.cpp
@@ -1,185 +1,185 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_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; 56using namespace Opie::Core;
57using namespace Opie::Core::Private; 57using namespace Opie::Core::Internal;
58 58
59struct r_button ramses_buttons [] = { 59struct r_button ramses_buttons [] = {
60 { Model_Ramses_MNCI, 60 { Model_Ramses_MNCI,
61 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 61 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
62 "devicebuttons/z_menu", 62 "devicebuttons/z_menu",
63 "QPE/TaskBar", "toggleMenu()", 63 "QPE/TaskBar", "toggleMenu()",
64 "QPE/TaskBar", "toggleStartMenu()" }, 64 "QPE/TaskBar", "toggleStartMenu()" },
65 { Model_Ramses_MNCI, 65 { Model_Ramses_MNCI,
66 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 66 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
67 "devicebuttons/ipaq_home", 67 "devicebuttons/ipaq_home",
68 "QPE/Launcher", "home()", 68 "QPE/Launcher", "home()",
69 "buttonsettings", "raise()" }, 69 "buttonsettings", "raise()" },
70}; 70};
71 71
72void Ramses::init() 72void Ramses::init()
73{ 73{
74 d->m_vendorstr = "M und N"; 74 d->m_vendorstr = "M und N";
75 d->m_vendor = Vendor_MundN; 75 d->m_vendor = Vendor_MundN;
76 76
77 QFile f("/proc/sys/board/ramses"); 77 QFile f("/proc/sys/board/ramses");
78 78
79 d->m_modelstr = "Ramses"; 79 d->m_modelstr = "Ramses";
80 d->m_model = Model_Ramses_MNCI; 80 d->m_model = Model_Ramses_MNCI;
81 81
82 d->m_rotation = Rot0; 82 d->m_rotation = Rot0;
83 d->m_holdtime = 1000; 83 d->m_holdtime = 1000;
84 84
85 f.setName("/etc/oz_version"); 85 f.setName("/etc/oz_version");
86 86
87 if (f.open(IO_ReadOnly)) { 87 if (f.open(IO_ReadOnly)) {
88 d->m_systemstr = "OpenEmbedded/Ramses"; 88 d->m_systemstr = "OpenEmbedded/Ramses";
89 d->m_system = System_OpenZaurus; 89 d->m_system = System_OpenZaurus;
90 90
91 QTextStream ts(&f); 91 QTextStream ts(&f);
92 ts.setDevice(&f); 92 ts.setDevice(&f);
93 d->m_sysverstr = ts.readLine(); 93 d->m_sysverstr = ts.readLine();
94 f.close(); 94 f.close();
95 } 95 }
96 96
97 m_power_timer = 0; 97 m_power_timer = 0;
98 98
99#ifdef QT_QWS_ALLOW_OVERCLOCK 99#ifdef QT_QWS_ALLOW_OVERCLOCK
100#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 ***
101#define OC(x...) x 101#define OC(x...) x
102#else 102#else
103#define OC(x...) 103#define OC(x...)
104#endif 104#endif
105 105
106 // This table is true for a Intel XScale PXA 255 106 // This table is true for a Intel XScale PXA 255
107 107
108 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 108 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50
109OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem 109OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem
110 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 110 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99
111OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem 111OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem
112 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 112 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99
113OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem 113OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem
114 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 114 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99
115 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 115 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196
116OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus 116OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus
117 117
118} 118}
119 119
120bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) 120bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat)
121{ 121{
122 Q_UNUSED( keycode ); 122 Q_UNUSED( keycode );
123 Q_UNUSED( modifiers ); 123 Q_UNUSED( modifiers );
124 Q_UNUSED( isPress ); 124 Q_UNUSED( isPress );
125 Q_UNUSED( autoRepeat ); 125 Q_UNUSED( autoRepeat );
126 return false; 126 return false;
127} 127}
128 128
129void Ramses::timerEvent(QTimerEvent *) 129void Ramses::timerEvent(QTimerEvent *)
130{ 130{
131 killTimer(m_power_timer); 131 killTimer(m_power_timer);
132 m_power_timer = 0; 132 m_power_timer = 0;
133 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); 133 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false);
134 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); 134 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false);
135} 135}
136 136
137 137
138bool Ramses::setSoftSuspend(bool soft) 138bool Ramses::setSoftSuspend(bool soft)
139{ 139{
140 qDebug("Ramses::setSoftSuspend(%d)", soft); 140 qDebug("Ramses::setSoftSuspend(%d)", soft);
141#if 0 141#if 0
142 bool res = false; 142 bool res = false;
143 int fd; 143 int fd;
144 144
145 if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || 145 if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) ||
146 ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { 146 ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) {
147 147
148 int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources 148 int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources
149 149
150 if (sources >= 0) { 150 if (sources >= 0) {
151 if (soft) 151 if (soft)
152 sources &= ~APM_EVT_POWER_BUTTON; 152 sources &= ~APM_EVT_POWER_BUTTON;
153 else 153 else
154 sources |= APM_EVT_POWER_BUTTON; 154 sources |= APM_EVT_POWER_BUTTON;
155 155
156 if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources 156 if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources
157 res = true; 157 res = true;
158 else 158 else
159 perror("APM_IOCGEVTSRC"); 159 perror("APM_IOCGEVTSRC");
160 } 160 }
161 else 161 else
162 perror("APM_IOCGEVTSRC"); 162 perror("APM_IOCGEVTSRC");
163 163
164 ::close(fd); 164 ::close(fd);
165 } 165 }
166 else 166 else
167 perror("/dev/apm_bios or /dev/misc/apm_bios"); 167 perror("/dev/apm_bios or /dev/misc/apm_bios");
168 168
169 return res; 169 return res;
170#else 170#else
171 return true; 171 return true;
172#endif 172#endif
173} 173}
174 174
175bool Ramses::suspend() 175bool Ramses::suspend()
176{ 176{
177 qDebug("Ramses::suspend"); 177 qDebug("Ramses::suspend");
178 return false; 178 return false;
179} 179}
180 180
181/** 181/**
182* This sets the display on or off 182* This sets the display on or off
183*/ 183*/
184bool Ramses::setDisplayStatus(bool on) 184bool Ramses::setDisplayStatus(bool on)
185{ 185{
diff --git a/libopie2/opiecore/device/odevice_ramses.h b/libopie2/opiecore/device/odevice_ramses.h
index e673b1a..aea9e2a 100644
--- a/libopie2/opiecore/device/odevice_ramses.h
+++ b/libopie2/opiecore/device/odevice_ramses.h
@@ -1,77 +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
37namespace Opie { 37namespace Opie {
38namespace Core { 38namespace Core {
39namespace Private { 39namespace Internal {
40 40
41class Ramses : public ODevice, public QWSServer::KeyboardFilter 41class Ramses : public ODevice, public QWSServer::KeyboardFilter
42{ 42{
43 protected: 43 protected:
44 virtual void init(); 44 virtual void init();
45 45
46 public: 46 public:
47 virtual bool setSoftSuspend( bool soft ); 47 virtual bool setSoftSuspend( bool soft );
48 virtual bool suspend(); 48 virtual bool suspend();
49 49
50 virtual bool setDisplayStatus( bool on ); 50 virtual bool setDisplayStatus( bool on );
51 virtual bool setDisplayBrightness( int b ); 51 virtual bool setDisplayBrightness( int b );
52 virtual int displayBrightnessResolution() const; 52 virtual int displayBrightnessResolution() const;
53 virtual bool setDisplayContrast( int b ); 53 virtual bool setDisplayContrast( int b );
54 virtual int displayContrastResolution() const; 54 virtual int displayContrastResolution() const;
55 55
56 protected: 56 protected:
57 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 );
58 virtual void timerEvent ( QTimerEvent *te ); 58 virtual void timerEvent ( QTimerEvent *te );
59 59
60 int m_power_timer; 60 int m_power_timer;
61}; 61};
62 62
63struct r_button { 63struct r_button {
64 uint model; 64 uint model;
65 Qt::Key code; 65 Qt::Key code;
66 char *utext; 66 char *utext;
67 char *pix; 67 char *pix;
68 char *fpressedservice; 68 char *fpressedservice;
69 char *fpressedaction; 69 char *fpressedaction;
70 char *fheldservice; 70 char *fheldservice;
71 char *fheldaction; 71 char *fheldaction;
72}; 72};
73} 73}
74} 74}
75} 75}
76 76
77#endif 77#endif
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index 80d40a3..7d79ef5 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -1,185 +1,185 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Opie Team <opie-devel@handhelds.org> 3 Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7_;:, .> :=|. This program is free software; you can 7_;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21: = ...= . :.=- 21: = ...= . :.=-
22-. .:....=;==+<; You should have received a copy of the GNU 22-. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_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::Core; 56using namespace Opie::Core;
57using namespace Opie::Core::Private; 57using namespace Opie::Core::Internal;
58 58
59struct s_button simpad_buttons [] = { 59struct s_button simpad_buttons [] = {
60 { 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,
61 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 61 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
62 "devicebuttons/simpad_lower_up", 62 "devicebuttons/simpad_lower_up",
63 "datebook", "nextView()", 63 "datebook", "nextView()",
64 "today", "raise()" }, 64 "today", "raise()" },
65 { 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,
66 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 66 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
67 "devicebuttons/simpad_lower_down", 67 "devicebuttons/simpad_lower_down",
68 "addressbook", "raise()", 68 "addressbook", "raise()",
69 "addressbook", "beamBusinessCard()" }, 69 "addressbook", "beamBusinessCard()" },
70 { 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,
71 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 71 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
72 "devicebuttons/simpad_lower_right", 72 "devicebuttons/simpad_lower_right",
73 "QPE/TaskBar", "toggleMenu()", 73 "QPE/TaskBar", "toggleMenu()",
74 "QPE/TaskBar", "toggleStartMenu()" }, 74 "QPE/TaskBar", "toggleStartMenu()" },
75 { 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,
76 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 76 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
77 "devicebuttons/simpad_lower_left", 77 "devicebuttons/simpad_lower_left",
78 "mail", "raise()", 78 "mail", "raise()",
79 "mail", "newMail()" }, 79 "mail", "newMail()" },
80 80
81 { 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,
82 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 82 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
83 "devicebuttons/simpad_upper_up", 83 "devicebuttons/simpad_upper_up",
84 "QPE/Launcher", "home()", 84 "QPE/Launcher", "home()",
85 "buttonsettings", "raise()" }, 85 "buttonsettings", "raise()" },
86 { 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,
87 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 87 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
88 "devicebuttons/simpad_upper_down", 88 "devicebuttons/simpad_upper_down",
89 "addressbook", "raise()", 89 "addressbook", "raise()",
90 "addressbook", "beamBusinessCard()" }, 90 "addressbook", "beamBusinessCard()" },
91 { 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,
92 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 92 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
93 "devicebuttons/simpad_upper_right", 93 "devicebuttons/simpad_upper_right",
94 "QPE/TaskBar", "toggleMenu()", 94 "QPE/TaskBar", "toggleMenu()",
95 "QPE/TaskBar", "toggleStartMenu()" }, 95 "QPE/TaskBar", "toggleStartMenu()" },
96 { 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,
97 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 97 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
98 "devicebuttons/simpad_upper_left", 98 "devicebuttons/simpad_upper_left",
99 "QPE/Rotation", "flip()", 99 "QPE/Rotation", "flip()",
100 "QPE/Rotation", "flip()" }, 100 "QPE/Rotation", "flip()" },
101 /* 101 /*
102 { 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,
103 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 103 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
104 "devicebuttons/simpad_lower_upper", 104 "devicebuttons/simpad_lower_upper",
105 "QPE/Launcher", "home()", 105 "QPE/Launcher", "home()",
106 "buttonsettings", "raise()" }, 106 "buttonsettings", "raise()" },
107 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 107 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
108 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 108 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
109 "devicebuttons/simpad_upper_lower", 109 "devicebuttons/simpad_upper_lower",
110 "QPE/Launcher", "home()", 110 "QPE/Launcher", "home()",
111 "buttonsettings", "raise()" }, 111 "buttonsettings", "raise()" },
112 */ 112 */
113}; 113};
114 114
115void SIMpad::init() 115void SIMpad::init()
116{ 116{
117 d->m_vendorstr = "SIEMENS"; 117 d->m_vendorstr = "SIEMENS";
118 d->m_vendor = Vendor_SIEMENS; 118 d->m_vendor = Vendor_SIEMENS;
119 119
120 QFile f ( "/proc/hal/model" ); 120 QFile f ( "/proc/hal/model" );
121 121
122 //TODO Implement model checking 122 //TODO Implement model checking
123 //FIXME For now we assume an SL4 123 //FIXME For now we assume an SL4
124 124
125 d->m_modelstr = "SL4"; 125 d->m_modelstr = "SL4";
126 d->m_model = Model_SIMpad_SL4; 126 d->m_model = Model_SIMpad_SL4;
127 127
128 switch ( d->m_model ) { 128 switch ( d->m_model ) {
129 default: 129 default:
130 d->m_rotation = Rot0; 130 d->m_rotation = Rot0;
131 d->m_direction = CCW; 131 d->m_direction = CCW;
132 d->m_holdtime = 1000; // 1000ms 132 d->m_holdtime = 1000; // 1000ms
133 133
134 break; 134 break;
135 } 135 }
136 136
137 f. setName ( "/etc/familiar-version" ); 137 f. setName ( "/etc/familiar-version" );
138 if ( f. open ( IO_ReadOnly )) { 138 if ( f. open ( IO_ReadOnly )) {
139 d->m_systemstr = "Familiar"; 139 d->m_systemstr = "Familiar";
140 d->m_system = System_Familiar; 140 d->m_system = System_Familiar;
141 141
142 QTextStream ts ( &f ); 142 QTextStream ts ( &f );
143 d->m_sysverstr = ts. readLine(). mid ( 10 ); 143 d->m_sysverstr = ts. readLine(). mid ( 10 );
144 144
145 f. close(); 145 f. close();
146 } else { 146 } else {
147 f. setName ( "/etc/oz_version" ); 147 f. setName ( "/etc/oz_version" );
148 148
149 if ( f. open ( IO_ReadOnly )) { 149 if ( f. open ( IO_ReadOnly )) {
150 d->m_systemstr = "OpenEmbedded/SIMpad"; 150 d->m_systemstr = "OpenEmbedded/SIMpad";
151 d->m_system = System_OpenZaurus; 151 d->m_system = System_OpenZaurus;
152 152
153 QTextStream ts ( &f ); 153 QTextStream ts ( &f );
154 ts.setDevice ( &f ); 154 ts.setDevice ( &f );
155 d->m_sysverstr = ts. readLine(); 155 d->m_sysverstr = ts. readLine();
156 f. close(); 156 f. close();
157 } 157 }
158 } 158 }
159 159
160 m_leds [0] = m_leds [1] = Led_Off; 160 m_leds [0] = m_leds [1] = Led_Off;
161 161
162 m_power_timer = 0; 162 m_power_timer = 0;
163 163
164} 164}
165 165
166void SIMpad::initButtons() 166void SIMpad::initButtons()
167{ 167{
168 if ( d->m_buttons ) 168 if ( d->m_buttons )
169 return; 169 return;
170 170
171 if ( isQWS( ) ) 171 if ( isQWS( ) )
172 QWSServer::setKeyboardFilter ( this ); 172 QWSServer::setKeyboardFilter ( this );
173 173
174 d->m_buttons = new QValueList <ODeviceButton>; 174 d->m_buttons = new QValueList <ODeviceButton>;
175 175
176 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 176 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
177 s_button *sb = simpad_buttons + i; 177 s_button *sb = simpad_buttons + i;
178 ODeviceButton b; 178 ODeviceButton b;
179 179
180 if (( sb->model & d->m_model ) == d->m_model ) { 180 if (( sb->model & d->m_model ) == d->m_model ) {
181 b. setKeycode ( sb->code ); 181 b. setKeycode ( sb->code );
182 b. setUserText ( QObject::tr ( "Button", sb->utext )); 182 b. setUserText ( QObject::tr ( "Button", sb->utext ));
183 b. setPixmap ( Resource::loadPixmap ( sb->pix )); 183 b. setPixmap ( Resource::loadPixmap ( sb->pix ));
184 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction )); 184 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction ));
185 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction )); 185 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction ));
diff --git a/libopie2/opiecore/device/odevice_simpad.h b/libopie2/opiecore/device/odevice_simpad.h
index 1848151..3d5acb5 100644
--- a/libopie2/opiecore/device/odevice_simpad.h
+++ b/libopie2/opiecore/device/odevice_simpad.h
@@ -1,87 +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
38namespace Opie { 38namespace Opie {
39namespace Core { 39namespace Core {
40namespace Private { 40namespace Internal {
41 41
42class SIMpad : public ODevice, public QWSServer::KeyboardFilter 42class SIMpad : public ODevice, public QWSServer::KeyboardFilter
43{ 43{
44 protected: 44 protected:
45 virtual void init(); 45 virtual void init();
46 virtual void initButtons(); 46 virtual void initButtons();
47 47
48 public: 48 public:
49 virtual bool setSoftSuspend( bool soft ); 49 virtual bool setSoftSuspend( bool soft );
50 virtual bool suspend(); 50 virtual bool suspend();
51 51
52 virtual bool setDisplayStatus( bool on ); 52 virtual bool setDisplayStatus( bool on );
53 virtual bool setDisplayBrightness( int b ); 53 virtual bool setDisplayBrightness( int b );
54 virtual int displayBrightnessResolution() const; 54 virtual int displayBrightnessResolution() const;
55 55
56 virtual void playAlarmSound(); 56 virtual void playAlarmSound();
57 57
58 virtual QValueList <OLed> ledList() const; 58 virtual QValueList <OLed> ledList() const;
59 virtual QValueList <OLedState> ledStateList( OLed led ) const; 59 virtual QValueList <OLedState> ledStateList( OLed led ) const;
60 virtual OLedState ledState( OLed led ) const; 60 virtual OLedState ledState( OLed led ) const;
61 virtual bool setLedState( OLed led, OLedState st ); 61 virtual bool setLedState( OLed led, OLedState st );
62 62
63 protected: 63 protected:
64 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 );
65 virtual void timerEvent( QTimerEvent *te ); 65 virtual void timerEvent( QTimerEvent *te );
66 66
67 int m_power_timer; 67 int m_power_timer;
68 68
69 OLedState m_leds [1]; 69 OLedState m_leds [1];
70}; 70};
71 71
72struct s_button { 72struct s_button {
73 uint model; 73 uint model;
74 Qt::Key code; 74 Qt::Key code;
75 char *utext; 75 char *utext;
76 char *pix; 76 char *pix;
77 char *fpressedservice; 77 char *fpressedservice;
78 char *fpressedaction; 78 char *fpressedaction;
79 char *fheldservice; 79 char *fheldservice;
80 char *fheldaction; 80 char *fheldaction;
81}; 81};
82 82
83} 83}
84} 84}
85} 85}
86 86
87#endif 87#endif
diff --git a/libopie2/opiecore/device/odevice_yopy.cpp b/libopie2/opiecore/device/odevice_yopy.cpp
index f7a4025..4e9f227 100644
--- a/libopie2/opiecore/device/odevice_yopy.cpp
+++ b/libopie2/opiecore/device/odevice_yopy.cpp
@@ -1,164 +1,164 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3             Copyright (C) The Opie Team <opie-devel@handhelds.org> 3             Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6          .>+-= 6          .>+-=
7_;:,     .>    :=|. This program is free software; you can 7_;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11- .   .-<_>     .<> Foundation; either version 2 of the License, 11- .   .-<_>     .<> Foundation; either version 2 of the License,
12    ._= =}       : or (at your option) any later version. 12    ._= =}       : or (at your option) any later version.
13   .%`+i>       _;_. 13   .%`+i>       _;_.
14   .i_,=:_.      -<s. This program is distributed in the hope that 14   .i_,=:_.      -<s. This program is distributed in the hope that
15    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15    +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16   : ..    .:,     . . . without even the implied warranty of 16   : ..    .:,     . . . without even the implied warranty of
17   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17   =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21:     =  ...= . :.=- 21:     =  ...= . :.=-
22-.   .:....=;==+<; You should have received a copy of the GNU 22-.   .:....=;==+<; You should have received a copy of the GNU
23 -_. . .   )=.  = Library General Public License along with 23 -_. . .   )=.  = Library General Public License along with
24   --        :-=` this library; see the file COPYING.LIB. 24   --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_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::Core; 56using namespace Opie::Core;
57using namespace Opie::Core::Private; 57using namespace Opie::Core::Internal;
58 58
59struct yopy_button yopy_buttons [] = { 59struct yopy_button yopy_buttons [] = {
60 { Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Action Button" ), 60 { Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Action Button" ),
61 "devicebuttons/yopy_action", 61 "devicebuttons/yopy_action",
62 "datebook", "nextView()", 62 "datebook", "nextView()",
63 "today", "raise()" }, 63 "today", "raise()" },
64 { Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "OK Button" ), 64 { Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "OK Button" ),
65 "devicebuttons/yopy_ok", 65 "devicebuttons/yopy_ok",
66 "addressbook", "raise()", 66 "addressbook", "raise()",
67 "addressbook", "beamBusinessCard()" }, 67 "addressbook", "beamBusinessCard()" },
68 { Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "End Button" ), 68 { Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "End Button" ),
69 "devicebuttons/yopy_end", 69 "devicebuttons/yopy_end",
70 "QPE/Launcher", "home()", 70 "QPE/Launcher", "home()",
71 "buttonsettings", "raise()" }, 71 "buttonsettings", "raise()" },
72}; 72};
73 73
74void Yopy::init() 74void Yopy::init()
75{ 75{
76 d->m_vendorstr = "G.Mate"; 76 d->m_vendorstr = "G.Mate";
77 d->m_vendor = Vendor_GMate; 77 d->m_vendor = Vendor_GMate;
78 d->m_modelstr = "Yopy3700"; 78 d->m_modelstr = "Yopy3700";
79 d->m_model = Model_Yopy_3700; 79 d->m_model = Model_Yopy_3700;
80 d->m_rotation = Rot0; 80 d->m_rotation = Rot0;
81 81
82 d->m_systemstr = "Linupy"; 82 d->m_systemstr = "Linupy";
83 d->m_system = System_Linupy; 83 d->m_system = System_Linupy;
84 84
85 QFile f ( "/etc/issue" ); 85 QFile f ( "/etc/issue" );
86 if ( f. open ( IO_ReadOnly ) ) 86 if ( f. open ( IO_ReadOnly ) )
87 { 87 {
88 QTextStream ts ( &f ); 88 QTextStream ts ( &f );
89 ts.readLine(); 89 ts.readLine();
90 d->m_sysverstr = ts. readLine(); 90 d->m_sysverstr = ts. readLine();
91 f. close(); 91 f. close();
92 } 92 }
93} 93}
94 94
95 95
96void Yopy::initButtons() 96void Yopy::initButtons()
97{ 97{
98 if ( d->m_buttons ) 98 if ( d->m_buttons )
99 return ; 99 return ;
100 100
101 d->m_buttons = new QValueList <ODeviceButton>; 101 d->m_buttons = new QValueList <ODeviceButton>;
102 102
103 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++ )
104 { 104 {
105 105
106 yopy_button *ib = yopy_buttons + i; 106 yopy_button *ib = yopy_buttons + i;
107 107
108 ODeviceButton b; 108 ODeviceButton b;
109 109
110 b. setKeycode ( ib->code ); 110 b. setKeycode ( ib->code );
111 b. setUserText ( QObject::tr ( "Button", ib->utext ) ); 111 b. setUserText ( QObject::tr ( "Button", ib->utext ) );
112 b. setPixmap ( Resource::loadPixmap ( ib->pix ) ); 112 b. setPixmap ( Resource::loadPixmap ( ib->pix ) );
113 b. setFactoryPresetPressedAction 113 b. setFactoryPresetPressedAction
114 ( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) ); 114 ( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) );
115 b. setFactoryPresetHeldAction 115 b. setFactoryPresetHeldAction
116 ( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) ); 116 ( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) );
117 117
118 d->m_buttons->append ( b ); 118 d->m_buttons->append ( b );
119 } 119 }
120 reloadButtonMapping(); 120 reloadButtonMapping();
121 121
122 QCopChannel *sysch = new QCopChannel( "QPE/System", this ); 122 QCopChannel *sysch = new QCopChannel( "QPE/System", this );
123 connect( sysch, SIGNAL( received(const QCString&,const QByteArray&) ), 123 connect( sysch, SIGNAL( received(const QCString&,const QByteArray&) ),
124 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); 124 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
125} 125}
126 126
127 127
128bool Yopy::suspend() 128bool Yopy::suspend()
129{ 129{
130 /* Opie for Yopy does not implement its own power management at the 130 /* Opie for Yopy does not implement its own power management at the
131 moment. The public version runs parallel to X, and relies on the 131 moment. The public version runs parallel to X, and relies on the
132 existing power management features. */ 132 existing power management features. */
133 return false; 133 return false;
134} 134}
135 135
136 136
137bool Yopy::setDisplayBrightness( int bright ) 137bool Yopy::setDisplayBrightness( int bright )
138{ 138{
139 /* The code here works, but is disabled as the current version runs 139 /* The code here works, but is disabled as the current version runs
140 parallel to X, and relies on the existing backlight demon. */ 140 parallel to X, and relies on the existing backlight demon. */
141#if 0 141#if 0
142 if ( QFile::exists( "/proc/sys/pm/light" ) ) 142 if ( QFile::exists( "/proc/sys/pm/light" ) )
143 { 143 {
144 int fd = ::open( "/proc/sys/pm/light", O_WRONLY ); 144 int fd = ::open( "/proc/sys/pm/light", O_WRONLY );
145 if ( fd >= 0 ) 145 if ( fd >= 0 )
146 { 146 {
147 if ( bright ) 147 if ( bright )
148 ::write( fd, "1\n", 2 ); 148 ::write( fd, "1\n", 2 );
149 else 149 else
150 ::write( fd, "0\n", 2 ); 150 ::write( fd, "0\n", 2 );
151 ::close( fd ); 151 ::close( fd );
152 return true; 152 return true;
153 } 153 }
154 } 154 }
155#endif 155#endif
156 return false; 156 return false;
157} 157}
158 158
159 159
160int Yopy::displayBrightnessResolution() const 160int Yopy::displayBrightnessResolution() const
161{ 161{
162 return 2; 162 return 2;
163} 163}
164 164
diff --git a/libopie2/opiecore/device/odevice_yopy.h b/libopie2/opiecore/device/odevice_yopy.h
index 7d85479..6e1db88 100644
--- a/libopie2/opiecore/device/odevice_yopy.h
+++ b/libopie2/opiecore/device/odevice_yopy.h
@@ -1,67 +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
35namespace Opie { 35namespace Opie {
36namespace Core { 36namespace Core {
37namespace Private { 37namespace Internal {
38class Yopy : public ODevice 38class Yopy : public ODevice
39{ 39{
40 protected: 40 protected:
41 41
42 virtual void init(); 42 virtual void init();
43 virtual void initButtons(); 43 virtual void initButtons();
44 44
45 public: 45 public:
46 virtual bool suspend(); 46 virtual bool suspend();
47 47
48 virtual bool setDisplayBrightness ( int b ); 48 virtual bool setDisplayBrightness ( int b );
49 virtual int displayBrightnessResolution() const; 49 virtual int displayBrightnessResolution() const;
50}; 50};
51 51
52struct yopy_button 52struct yopy_button
53{ 53{
54 Qt::Key code; 54 Qt::Key code;
55 char *utext; 55 char *utext;
56 char *pix; 56 char *pix;
57 char *fpressedservice; 57 char *fpressedservice;
58 char *fpressedaction; 58 char *fpressedaction;
59 char *fheldservice; 59 char *fheldservice;
60 char *fheldaction; 60 char *fheldaction;
61}; 61};
62 62
63} 63}
64} 64}
65} 65}
66 66
67#endif 67#endif
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 0d21f26..000d29c 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -1,185 +1,185 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Opie Team <opie-devel@handhelds.org> 3 Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7_;:, .> :=|. This program is free software; you can 7_;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11- . .-<_> .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21: = ...= . :.=- 21: = ...= . :.=-
22-. .:....=;==+<; You should have received a copy of the GNU 22-. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_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::Core; 56using namespace Opie::Core;
57using namespace Opie::Core::Private; 57using namespace Opie::Core::Internal;
58 58
59struct z_button z_buttons [] = { 59struct z_button z_buttons [] = {
60 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 60 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
61 "devicebuttons/z_calendar", 61 "devicebuttons/z_calendar",
62 "datebook", "nextView()", 62 "datebook", "nextView()",
63 "today", "raise()" }, 63 "today", "raise()" },
64 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 64 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
65 "devicebuttons/z_contact", 65 "devicebuttons/z_contact",
66 "addressbook", "raise()", 66 "addressbook", "raise()",
67 "addressbook", "beamBusinessCard()" }, 67 "addressbook", "beamBusinessCard()" },
68 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 68 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
69 "devicebuttons/z_home", 69 "devicebuttons/z_home",
70 "QPE/Launcher", "home()", 70 "QPE/Launcher", "home()",
71 "buttonsettings", "raise()" }, 71 "buttonsettings", "raise()" },
72 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 72 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
73 "devicebuttons/z_menu", 73 "devicebuttons/z_menu",
74 "QPE/TaskBar", "toggleMenu()", 74 "QPE/TaskBar", "toggleMenu()",
75 "QPE/TaskBar", "toggleStartMenu()" }, 75 "QPE/TaskBar", "toggleStartMenu()" },
76 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 76 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
77 "devicebuttons/z_mail", 77 "devicebuttons/z_mail",
78 "mail", "raise()", 78 "mail", "raise()",
79 "mail", "newMail()" }, 79 "mail", "newMail()" },
80}; 80};
81 81
82struct z_button z_buttons_c700 [] = { 82struct z_button z_buttons_c700 [] = {
83 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 83 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
84 "devicebuttons/z_calendar", 84 "devicebuttons/z_calendar",
85 "datebook", "nextView()", 85 "datebook", "nextView()",
86 "today", "raise()" }, 86 "today", "raise()" },
87 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 87 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
88 "devicebuttons/z_contact", 88 "devicebuttons/z_contact",
89 "addressbook", "raise()", 89 "addressbook", "raise()",
90 "addressbook", "beamBusinessCard()" }, 90 "addressbook", "beamBusinessCard()" },
91 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 91 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
92 "devicebuttons/z_home", 92 "devicebuttons/z_home",
93 "QPE/Launcher", "home()", 93 "QPE/Launcher", "home()",
94 "buttonsettings", "raise()" }, 94 "buttonsettings", "raise()" },
95 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 95 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
96 "devicebuttons/z_menu", 96 "devicebuttons/z_menu",
97 "QPE/TaskBar", "toggleMenu()", 97 "QPE/TaskBar", "toggleMenu()",
98 "QPE/TaskBar", "toggleStartMenu()" }, 98 "QPE/TaskBar", "toggleStartMenu()" },
99 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 99 { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
100 "devicebuttons/z_hinge", 100 "devicebuttons/z_hinge",
101 "QPE/Rotation", "rotateDefault()", 101 "QPE/Rotation", "rotateDefault()",
102 "QPE/Dummy", "doNothing()" }, 102 "QPE/Dummy", "doNothing()" },
103}; 103};
104 104
105// 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
106// class up into individual classes. We need three classes 106// class up into individual classes. We need three classes
107// 107//
108// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 108// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
109// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 109// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
110// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) 110// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860)
111// 111//
112// Only question right now is: Do we really need to do it? Because as soon 112// Only question right now is: Do we really need to do it? Because as soon
113// as the OpenZaurus kernel is ready, there will be a unified interface for all 113// as the OpenZaurus kernel is ready, there will be a unified interface for all
114// Zaurus models (concerning apm, backlight, buttons, etc.) 114// Zaurus models (concerning apm, backlight, buttons, etc.)
115// 115//
116// Comments? - mickeyl. 116// Comments? - mickeyl.
117 117
118void Zaurus::init() 118void Zaurus::init()
119{ 119{
120 d->m_vendorstr = "Sharp"; 120 d->m_vendorstr = "Sharp";
121 d->m_vendor = Vendor_Sharp; 121 d->m_vendor = Vendor_Sharp;
122 m_embedix = true; // Not openzaurus means: It has an embedix kernel ! 122 m_embedix = true; // Not openzaurus means: It has an embedix kernel !
123 123
124 // QFile f ( "/proc/filesystems" ); 124 // QFile f ( "/proc/filesystems" );
125 QString model; 125 QString model;
126 126
127 // It isn't a good idea to check the system configuration to 127 // It isn't a good idea to check the system configuration to
128 // detect the distribution ! 128 // detect the distribution !
129 // Otherwise it may happen that any other distribution is detected as openzaurus, just 129 // Otherwise it may happen that any other distribution is detected as openzaurus, just
130 // because it uses a jffs2 filesystem.. 130 // because it uses a jffs2 filesystem..
131 // (eilers) 131 // (eilers)
132 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read(). find ( "\tjffs2\n" ) >= 0 )) { 132 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read(). find ( "\tjffs2\n" ) >= 0 )) {
133 QFile f ("/etc/oz_version"); 133 QFile f ("/etc/oz_version");
134 if ( f.exists() ){ 134 if ( f.exists() ){
135 d->m_vendorstr = "OpenZaurus Team"; 135 d->m_vendorstr = "OpenZaurus Team";
136 d->m_systemstr = "OpenZaurus"; 136 d->m_systemstr = "OpenZaurus";
137 d->m_system = System_OpenZaurus; 137 d->m_system = System_OpenZaurus;
138 138
139 if ( f. open ( IO_ReadOnly )) { 139 if ( f. open ( IO_ReadOnly )) {
140 QTextStream ts ( &f ); 140 QTextStream ts ( &f );
141 d->m_sysverstr = ts. readLine();//. mid ( 10 ); 141 d->m_sysverstr = ts. readLine();//. mid ( 10 );
142 f. close(); 142 f. close();
143 } 143 }
144 144
145 // Openzaurus sometimes uses the embedix kernel! 145 // Openzaurus sometimes uses the embedix kernel!
146 // => Check whether this is an embedix kernel 146 // => Check whether this is an embedix kernel
147 FILE *uname = popen("uname -r", "r"); 147 FILE *uname = popen("uname -r", "r");
148 QString line; 148 QString line;
149 if ( f.open(IO_ReadOnly, uname) ) { 149 if ( f.open(IO_ReadOnly, uname) ) {
150 QTextStream ts ( &f ); 150 QTextStream ts ( &f );
151 line = ts. readLine(); 151 line = ts. readLine();
152 int loc = line. find ( "embedix" ); 152 int loc = line. find ( "embedix" );
153 if ( loc != -1 ) 153 if ( loc != -1 )
154 m_embedix = true; 154 m_embedix = true;
155 else 155 else
156 m_embedix = false; 156 m_embedix = false;
157 f. close(); 157 f. close();
158 } 158 }
159 pclose(uname); 159 pclose(uname);
160 } 160 }
161 else { 161 else {
162 d->m_systemstr = "Zaurus"; 162 d->m_systemstr = "Zaurus";
163 d->m_system = System_Zaurus; 163 d->m_system = System_Zaurus;
164 } 164 }
165 165
166 f. setName ( "/proc/cpuinfo" ); 166 f. setName ( "/proc/cpuinfo" );
167 if ( f. open ( IO_ReadOnly ) ) { 167 if ( f. open ( IO_ReadOnly ) ) {
168 QTextStream ts ( &f ); 168 QTextStream ts ( &f );
169 QString line; 169 QString line;
170 while( line = ts. readLine() ) { 170 while( line = ts. readLine() ) {
171 if ( line. left ( 8 ) == "Hardware" ) 171 if ( line. left ( 8 ) == "Hardware" )
172 break; 172 break;
173 } 173 }
174 int loc = line. find ( ":" ); 174 int loc = line. find ( ":" );
175 if ( loc != -1 ) 175 if ( loc != -1 )
176 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 176 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
177 } 177 }
178 178
179 if ( model == "SHARP Corgi" ) { 179 if ( model == "SHARP Corgi" ) {
180 d->m_model = Model_Zaurus_SLC7x0; 180 d->m_model = Model_Zaurus_SLC7x0;
181 d->m_modelstr = "Zaurus SL-C700"; 181 d->m_modelstr = "Zaurus SL-C700";
182 } else if ( model == "SHARP Shepherd" ) { 182 } else if ( model == "SHARP Shepherd" ) {
183 d->m_model = Model_Zaurus_SLC7x0; 183 d->m_model = Model_Zaurus_SLC7x0;
184 d->m_modelstr = "Zaurus SL-C750"; 184 d->m_modelstr = "Zaurus SL-C750";
185 } else if ( model == "SHARP Husky" ) { 185 } else if ( model == "SHARP Husky" ) {
@@ -262,432 +262,432 @@ void Zaurus::initButtons()
262#include <sys/ioctl.h> 262#include <sys/ioctl.h>
263 263
264//#include <asm/sharp_char.h> // including kernel headers is evil ... 264//#include <asm/sharp_char.h> // including kernel headers is evil ...
265 265
266#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 266#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
267 267
268 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 268 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
269#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 269#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
270 270
271#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 271#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
272#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 272#define SHARP_BUZ_KEYSOUND 2 /* key sound */
273#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 273#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
274 274
275/* --- for SHARP_BUZZER device --- */ 275/* --- for SHARP_BUZZER device --- */
276 276
277 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 277 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
278//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 278//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
279 279
280#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 280#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
281#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 281#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
282#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 282#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
283#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 283#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
284#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 284#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
285 285
286//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 286//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
287//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 287//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
288 288
289//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 289//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
290//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 290//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
291//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 291//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
292//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 292//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
293//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 293//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
294//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 294//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
295//#define SHARP_PDA_APPSTART 9 /* application start */ 295//#define SHARP_PDA_APPSTART 9 /* application start */
296//#define SHARP_PDA_APPQUIT 10 /* application ends */ 296//#define SHARP_PDA_APPQUIT 10 /* application ends */
297 297
298//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 298//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
299//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 299//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
300//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 300//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
301//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 301//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
302// 302//
303 303
304 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 304 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
305#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 305#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
306 306
307#define SHARP_IOCTL_GET_ROTATION 0x413c 307#define SHARP_IOCTL_GET_ROTATION 0x413c
308 308
309typedef struct sharp_led_status { 309typedef struct sharp_led_status {
310int which; /* select which LED status is wanted. */ 310int which; /* select which LED status is wanted. */
311int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 311int status; /* set new led status if you call SHARP_LED_SETSTATUS */
312} sharp_led_status; 312} sharp_led_status;
313 313
314#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 314#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
315 315
316#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 316#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
317#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 317#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
318#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 318#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
319 319
320// #include <asm/sharp_apm.h> // including kernel headers is evil ... 320// #include <asm/sharp_apm.h> // including kernel headers is evil ...
321 321
322#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 322#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
323#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 323#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
324#define APM_EVT_POWER_BUTTON (1 << 0) 324#define APM_EVT_POWER_BUTTON (1 << 0)
325 325
326#define FL_IOCTL_STEP_CONTRAST 100 326#define FL_IOCTL_STEP_CONTRAST 100
327 327
328 328
329void Zaurus::buzzer ( int sound ) 329void Zaurus::buzzer ( int sound )
330{ 330{
331#ifndef QT_NO_SOUND 331#ifndef QT_NO_SOUND
332 QString soundname; 332 QString soundname;
333 333
334 // Not all devices have real sound 334 // Not all devices have real sound
335 if ( d->m_model == Model_Zaurus_SLC7x0 335 if ( d->m_model == Model_Zaurus_SLC7x0
336 || d->m_model == Model_Zaurus_SLB600 ){ 336 || d->m_model == Model_Zaurus_SLB600 ){
337 337
338 switch ( sound ){ 338 switch ( sound ){
339 case SHARP_BUZ_SCHEDULE_ALARM: 339 case SHARP_BUZ_SCHEDULE_ALARM:
340 soundname = "alarm"; 340 soundname = "alarm";
341 break; 341 break;
342 case SHARP_BUZ_TOUCHSOUND: 342 case SHARP_BUZ_TOUCHSOUND:
343 soundname = "touchsound"; 343 soundname = "touchsound";
344 break; 344 break;
345 case SHARP_BUZ_KEYSOUND: 345 case SHARP_BUZ_KEYSOUND:
346 soundname = "keysound"; 346 soundname = "keysound";
347 break; 347 break;
348 default: 348 default:
349 soundname = "alarm"; 349 soundname = "alarm";
350 350
351 } 351 }
352 } 352 }
353 353
354 // If a soundname is defined, we expect that this device has 354 // If a soundname is defined, we expect that this device has
355 // sound capabilities.. Otherwise we expect to have the buzzer 355 // sound capabilities.. Otherwise we expect to have the buzzer
356 // device.. 356 // device..
357 if ( !soundname.isEmpty() ){ 357 if ( !soundname.isEmpty() ){
358 int fd; 358 int fd;
359 int vol; 359 int vol;
360 bool vol_reset = false; 360 bool vol_reset = false;
361 361
362 Sound snd ( soundname ); 362 Sound snd ( soundname );
363 363
364 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 364 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
365 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 365 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
366 Config cfg ( "qpe" ); 366 Config cfg ( "qpe" );
367 cfg. setGroup ( "Volume" ); 367 cfg. setGroup ( "Volume" );
368 368
369 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 369 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
370 if ( volalarm < 0 ) 370 if ( volalarm < 0 )
371 volalarm = 0; 371 volalarm = 0;
372 else if ( volalarm > 100 ) 372 else if ( volalarm > 100 )
373 volalarm = 100; 373 volalarm = 100;
374 volalarm |= ( volalarm << 8 ); 374 volalarm |= ( volalarm << 8 );
375 375
376 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 376 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
377 vol_reset = true; 377 vol_reset = true;
378 } 378 }
379 } 379 }
380 380
381 snd. play(); 381 snd. play();
382 while ( !snd. isFinished()) 382 while ( !snd. isFinished())
383 qApp->processEvents(); 383 qApp->processEvents();
384 384
385 if ( fd >= 0 ) { 385 if ( fd >= 0 ) {
386 if ( vol_reset ) 386 if ( vol_reset )
387 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 387 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
388 ::close ( fd ); 388 ::close ( fd );
389 } 389 }
390 } else { 390 } else {
391 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 391 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
392 392
393 if ( fd >= 0 ) { 393 if ( fd >= 0 ) {
394 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 394 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
395 ::close ( fd ); 395 ::close ( fd );
396 } 396 }
397 397
398 } 398 }
399#endif 399#endif
400} 400}
401 401
402 402
403void Zaurus::playAlarmSound() 403void Zaurus::playAlarmSound()
404{ 404{
405 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 405 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
406} 406}
407 407
408void Zaurus::playTouchSound() 408void Zaurus::playTouchSound()
409{ 409{
410 buzzer ( SHARP_BUZ_TOUCHSOUND ); 410 buzzer ( SHARP_BUZ_TOUCHSOUND );
411} 411}
412 412
413void Zaurus::playKeySound() 413void Zaurus::playKeySound()
414{ 414{
415 buzzer ( SHARP_BUZ_KEYSOUND ); 415 buzzer ( SHARP_BUZ_KEYSOUND );
416} 416}
417 417
418 418
419QValueList <OLed> Zaurus::ledList() const 419QValueList <OLed> Zaurus::ledList() const
420{ 420{
421 QValueList <OLed> vl; 421 QValueList <OLed> vl;
422 vl << Led_Mail; 422 vl << Led_Mail;
423 return vl; 423 return vl;
424} 424}
425 425
426QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 426QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
427{ 427{
428 QValueList <OLedState> vl; 428 QValueList <OLedState> vl;
429 429
430 if ( l == Led_Mail ) 430 if ( l == Led_Mail )
431 vl << Led_Off << Led_On << Led_BlinkSlow; 431 vl << Led_Off << Led_On << Led_BlinkSlow;
432 return vl; 432 return vl;
433} 433}
434 434
435OLedState Zaurus::ledState ( OLed which ) const 435OLedState Zaurus::ledState ( OLed which ) const
436{ 436{
437 if ( which == Led_Mail ) 437 if ( which == Led_Mail )
438 return m_leds [0]; 438 return m_leds [0];
439 else 439 else
440 return Led_Off; 440 return Led_Off;
441} 441}
442 442
443bool Zaurus::setLedState ( OLed which, OLedState st ) 443bool Zaurus::setLedState ( OLed which, OLedState st )
444{ 444{
445 if (!m_embedix) // Currently not supported on non_embedix kernels 445 if (!m_embedix) // Currently not supported on non_embedix kernels
446 return false; 446 return false;
447 447
448 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 448 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
449 449
450 if ( which == Led_Mail ) { 450 if ( which == Led_Mail ) {
451 if ( fd >= 0 ) { 451 if ( fd >= 0 ) {
452 struct sharp_led_status leds; 452 struct sharp_led_status leds;
453 ::memset ( &leds, 0, sizeof( leds )); 453 ::memset ( &leds, 0, sizeof( leds ));
454 leds. which = SHARP_LED_MAIL_EXISTS; 454 leds. which = SHARP_LED_MAIL_EXISTS;
455 bool ok = true; 455 bool ok = true;
456 456
457 switch ( st ) { 457 switch ( st ) {
458 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 458 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
459 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 459 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
460 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 460 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
461 default : ok = false; 461 default : ok = false;
462 } 462 }
463 463
464 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 464 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
465 m_leds [0] = st; 465 m_leds [0] = st;
466 return true; 466 return true;
467 } 467 }
468 } 468 }
469 } 469 }
470 return false; 470 return false;
471} 471}
472 472
473bool Zaurus::setSoftSuspend ( bool soft ) 473bool Zaurus::setSoftSuspend ( bool soft )
474{ 474{
475 if (!m_embedix) { 475 if (!m_embedix) {
476 /* non-Embedix kernels dont have kernel autosuspend */ 476 /* non-Embedix kernels dont have kernel autosuspend */
477 return ODevice::setSoftSuspend( soft ); 477 return ODevice::setSoftSuspend( soft );
478 } 478 }
479 479
480 bool res = false; 480 bool res = false;
481 int fd; 481 int fd;
482 482
483 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 483 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
484 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 484 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
485 485
486 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 486 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
487 487
488 if ( sources >= 0 ) { 488 if ( sources >= 0 ) {
489 if ( soft ) 489 if ( soft )
490 sources &= ~APM_EVT_POWER_BUTTON; 490 sources &= ~APM_EVT_POWER_BUTTON;
491 else 491 else
492 sources |= APM_EVT_POWER_BUTTON; 492 sources |= APM_EVT_POWER_BUTTON;
493 493
494 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 494 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
495 res = true; 495 res = true;
496 else 496 else
497 perror ( "APM_IOCGEVTSRC" ); 497 perror ( "APM_IOCGEVTSRC" );
498 } 498 }
499 else 499 else
500 perror ( "APM_IOCGEVTSRC" ); 500 perror ( "APM_IOCGEVTSRC" );
501 501
502 ::close ( fd ); 502 ::close ( fd );
503 } 503 }
504 else 504 else
505 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 505 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
506 506
507 return res; 507 return res;
508} 508}
509 509
510 510
511bool Zaurus::setDisplayBrightness ( int bright ) 511bool Zaurus::setDisplayBrightness ( int bright )
512{ 512{
513 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 513 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
514 bool res = false; 514 bool res = false;
515 int fd; 515 int fd;
516 516
517 if ( bright > 255 ) bright = 255; 517 if ( bright > 255 ) bright = 255;
518 if ( bright < 0 ) bright = 0; 518 if ( bright < 0 ) bright = 0;
519 519
520 if ( m_embedix ) 520 if ( m_embedix )
521 { 521 {
522 if ( d->m_model == Model_Zaurus_SLC7x0 ) 522 if ( d->m_model == Model_Zaurus_SLC7x0 )
523 { 523 {
524 //qDebug( "using special treatment for devices with the corgi backlight interface" ); 524 //qDebug( "using special treatment for devices with the corgi backlight interface" );
525 // special treatment for devices with the corgi backlight interface 525 // special treatment for devices with the corgi backlight interface
526 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) 526 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 )
527 { 527 {
528 int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 ); 528 int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 );
529 char writeCommand[100]; 529 char writeCommand[100];
530 const int count = sprintf( writeCommand, "0x%x\n", value ); 530 const int count = sprintf( writeCommand, "0x%x\n", value );
531 res = ( ::write ( fd, writeCommand, count ) != -1 ); 531 res = ( ::write ( fd, writeCommand, count ) != -1 );
532 ::close ( fd ); 532 ::close ( fd );
533 } 533 }
534 return res; 534 return res;
535 } 535 }
536 else 536 else
537 { 537 {
538 // standard treatment for devices with the dumb embedix frontlight interface 538 // standard treatment for devices with the dumb embedix frontlight interface
539 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 539 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
540 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 540 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
541 if ( bright && !bl ) 541 if ( bright && !bl )
542 bl = 1; 542 bl = 1;
543 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 543 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
544 ::close ( fd ); 544 ::close ( fd );
545 } 545 }
546 } 546 }
547 } 547 }
548 else 548 else
549 { 549 {
550 // special treatment for the OpenZaurus unified interface 550 // special treatment for the OpenZaurus unified interface
551 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ 551 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */
552 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { 552 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) {
553 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); 553 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 );
554 ::close ( fd ); 554 ::close ( fd );
555 } 555 }
556 } 556 }
557 return res; 557 return res;
558} 558}
559 559
560bool Zaurus::suspend() 560bool Zaurus::suspend()
561{ 561{
562 qDebug("ODevice::suspend"); 562 qDebug("ODevice::suspend");
563 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 563 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
564 return false; 564 return false;
565 565
566 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 566 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
567 return false; 567 return false;
568 568
569 bool res = false; 569 bool res = false;
570 ODevice::sendSuspendmsg(); 570 ODevice::sendSuspendmsg();
571 571
572 struct timeval tvs, tvn; 572 struct timeval tvs, tvn;
573 ::gettimeofday ( &tvs, 0 ); 573 ::gettimeofday ( &tvs, 0 );
574 574
575 ::sync(); // flush fs caches 575 ::sync(); // flush fs caches
576 res = ( ::system ( "apm --suspend" ) == 0 ); 576 res = ( ::system ( "apm --suspend" ) == 0 );
577 577
578 // This is needed because the iPAQ apm implementation is asynchronous and we 578 // This is needed because the iPAQ apm implementation is asynchronous and we
579 // can not be sure when exactly the device is really suspended 579 // can not be sure when exactly the device is really suspended
580 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 580 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
581 581
582 if ( res ) { 582 if ( res ) {
583 do { // Yes, wait 15 seconds. This APM bug sucks big time. 583 do { // Yes, wait 15 seconds. This APM bug sucks big time.
584 ::usleep ( 200 * 1000 ); 584 ::usleep ( 200 * 1000 );
585 ::gettimeofday ( &tvn, 0 ); 585 ::gettimeofday ( &tvn, 0 );
586 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); 586 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
587 } 587 }
588 588
589 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); 589 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
590 return res; 590 return res;
591} 591}
592 592
593 593
594Transformation Zaurus::rotation() const 594Transformation Zaurus::rotation() const
595{ 595{
596 Transformation rot; 596 Transformation rot;
597 int handle = 0; 597 int handle = 0;
598 int retval = 0; 598 int retval = 0;
599 599
600 switch ( d->m_model ) { 600 switch ( d->m_model ) {
601 case Model_Zaurus_SLC7x0: 601 case Model_Zaurus_SLC7x0:
602 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 602 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
603 if (handle == -1) { 603 if (handle == -1) {
604 return Rot270; 604 return Rot270;
605 } else { 605 } else {
606 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 606 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
607 ::close (handle); 607 ::close (handle);
608 608
609 if (retval == 2 ) 609 if (retval == 2 )
610 rot = Rot0; 610 rot = Rot0;
611 else 611 else
612 rot = Rot270; 612 rot = Rot270;
613 } 613 }
614 break; 614 break;
615 case Model_Zaurus_SLA300: 615 case Model_Zaurus_SLA300:
616 case Model_Zaurus_SLB600: 616 case Model_Zaurus_SLB600:
617 case Model_Zaurus_SL5500: 617 case Model_Zaurus_SL5500:
618 case Model_Zaurus_SL5000: 618 case Model_Zaurus_SL5000:
619 default: 619 default:
620 rot = d->m_rotation; 620 rot = d->m_rotation;
621 break; 621 break;
622 } 622 }
623 623
624 return rot; 624 return rot;
625} 625}
626ODirection Zaurus::direction() const 626ODirection Zaurus::direction() const
627{ 627{
628 ODirection dir; 628 ODirection dir;
629 int handle = 0; 629 int handle = 0;
630 int retval = 0; 630 int retval = 0;
631 switch ( d->m_model ) { 631 switch ( d->m_model ) {
632 case Model_Zaurus_SLC7x0: 632 case Model_Zaurus_SLC7x0:
633 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 633 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
634 if (handle == -1) { 634 if (handle == -1) {
635 dir = CW; 635 dir = CW;
636 } else { 636 } else {
637 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 637 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
638 ::close (handle); 638 ::close (handle);
639 if (retval == 2 ) 639 if (retval == 2 )
640 dir = CCW; 640 dir = CCW;
641 else 641 else
642 dir = CW; 642 dir = CW;
643 } 643 }
644 break; 644 break;
645 case Model_Zaurus_SLA300: 645 case Model_Zaurus_SLA300:
646 case Model_Zaurus_SLB600: 646 case Model_Zaurus_SLB600:
647 case Model_Zaurus_SL5500: 647 case Model_Zaurus_SL5500:
648 case Model_Zaurus_SL5000: 648 case Model_Zaurus_SL5000:
649 default: 649 default:
650 dir = d->m_direction; 650 dir = d->m_direction;
651 break; 651 break;
652 } 652 }
653 return dir; 653 return dir;
654 654
655} 655}
656 656
657int Zaurus::displayBrightnessResolution() const 657int Zaurus::displayBrightnessResolution() const
658{ 658{
659 if (m_embedix) 659 if (m_embedix)
660 return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5; 660 return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5;
661 else 661 else
662 return 256; 662 return 256;
663} 663}
664 664
665bool Zaurus::hasHingeSensor() const 665bool Zaurus::hasHingeSensor() const
666{ 666{
667 return d->m_model == Model_Zaurus_SLC7x0; 667 return d->m_model == Model_Zaurus_SLC7x0;
668} 668}
669 669
670OHingeStatus Zaurus::readHingeSensor() 670OHingeStatus Zaurus::readHingeSensor()
671{ 671{
672 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 672 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
673 if (handle == -1) 673 if (handle == -1)
674 { 674 {
675 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror 675 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
676 return CASE_UNKNOWN; 676 return CASE_UNKNOWN;
677 } 677 }
678 else 678 else
679 { 679 {
680 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 680 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
681 ::close (handle); 681 ::close (handle);
682 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) 682 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
683 { 683 {
684 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 684 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
685 return static_cast<OHingeStatus>( retval ); 685 return static_cast<OHingeStatus>( retval );
686 } 686 }
687 else 687 else
688 { 688 {
689 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 689 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
690 return CASE_UNKNOWN; 690 return CASE_UNKNOWN;
691 } 691 }
692 } 692 }
693} 693}
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h
index ffb648f..a0b1787 100644
--- a/libopie2/opiecore/device/odevice_zaurus.h
+++ b/libopie2/opiecore/device/odevice_zaurus.h
@@ -1,100 +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
48 48
49namespace Opie { 49namespace Opie {
50namespace Core { 50namespace Core {
51namespace Private { 51namespace Internal {
52class Zaurus : public ODevice 52class Zaurus : public ODevice
53{ 53{
54 54
55 protected: 55 protected:
56 virtual void init(); 56 virtual void init();
57 virtual void initButtons(); 57 virtual void initButtons();
58 58
59 public: 59 public:
60 virtual bool setSoftSuspend ( bool soft ); 60 virtual bool setSoftSuspend ( bool soft );
61 61
62 virtual bool setDisplayBrightness ( int b ); 62 virtual bool setDisplayBrightness ( int b );
63 virtual int displayBrightnessResolution() const; 63 virtual int displayBrightnessResolution() const;
64 64
65 virtual void playAlarmSound(); 65 virtual void playAlarmSound();
66 virtual void playKeySound(); 66 virtual void playKeySound();
67 virtual void playTouchSound(); 67 virtual void playTouchSound();
68 68
69 virtual QValueList <OLed> ledList() const; 69 virtual QValueList <OLed> ledList() const;
70 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 70 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
71 virtual OLedState ledState( OLed led ) const; 71 virtual OLedState ledState( OLed led ) const;
72 virtual bool setLedState( OLed led, OLedState st ); 72 virtual bool setLedState( OLed led, OLedState st );
73 73
74 virtual bool hasHingeSensor() const; 74 virtual bool hasHingeSensor() const;
75 virtual OHingeStatus readHingeSensor(); 75 virtual OHingeStatus readHingeSensor();
76 76
77 virtual bool suspend(); 77 virtual bool suspend();
78 virtual Transformation rotation() const; 78 virtual Transformation rotation() const;
79 virtual ODirection direction() const; 79 virtual ODirection direction() const;
80 80
81 protected: 81 protected:
82 virtual void buzzer ( int snd ); 82 virtual void buzzer ( int snd );
83 83
84 OLedState m_leds [1]; 84 OLedState m_leds [1];
85 bool m_embedix; 85 bool m_embedix;
86}; 86};
87 87
88struct z_button { 88struct z_button {
89 Qt::Key code; 89 Qt::Key code;
90 char *utext; 90 char *utext;
91 char *pix; 91 char *pix;
92 char *fpressedservice; 92 char *fpressedservice;
93 char *fpressedaction; 93 char *fpressedaction;
94 char *fheldservice; 94 char *fheldservice;
95 char *fheldaction; 95 char *fheldaction;
96}; 96};
97} 97}
98} 98}
99} 99}
100#endif 100#endif
diff --git a/libopie2/opiecore/device/odevicebutton.cpp b/libopie2/opiecore/device/odevicebutton.cpp
index a081b7f..6974b30 100644
--- a/libopie2/opiecore/device/odevicebutton.cpp
+++ b/libopie2/opiecore/device/odevicebutton.cpp
@@ -1,255 +1,255 @@
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
36 36
37namespace Opie { 37namespace Opie {
38namespace Core { 38namespace Core {
39namespace Private { 39namespace Internal {
40 40
41class OQCopMessageData 41class OQCopMessageData
42{ 42{
43 public: 43 public:
44 QCString m_channel; 44 QCString m_channel;
45 QCString m_message; 45 QCString m_message;
46 QByteArray m_data; 46 QByteArray m_data;
47}; 47};
48} 48}
49 49
50using namespace Opie::Core; 50using namespace Opie::Core;
51using namespace Opie::Core::Private; 51using Opie::Core::Internal::OQCopMessageData;
52 52
53OQCopMessage::OQCopMessage() 53OQCopMessage::OQCopMessage()
54 : d ( 0 ) 54 : d ( 0 )
55{ 55{
56 init ( QCString(), QCString(), QByteArray()); 56 init ( QCString(), QCString(), QByteArray());
57} 57}
58 58
59OQCopMessage::OQCopMessage ( const OQCopMessage &copy ) 59OQCopMessage::OQCopMessage ( const OQCopMessage &copy )
60 : d ( 0 ) 60 : d ( 0 )
61{ 61{
62 init ( copy. channel(), copy. message(), copy. data()); 62 init ( copy. channel(), copy. message(), copy. data());
63} 63}
64 64
65OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign ) 65OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign )
66{ 66{
67 init ( assign. channel(), assign. message(), assign. data()); 67 init ( assign. channel(), assign. message(), assign. data());
68 return *this; 68 return *this;
69} 69}
70 70
71OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg ) 71OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg )
72 : d ( 0 ) 72 : d ( 0 )
73{ 73{
74 init ( ch, m, arg ); 74 init ( ch, m, arg );
75} 75}
76 76
77void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg ) 77void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg )
78{ 78{
79 if ( !d ) 79 if ( !d )
80 d = new OQCopMessageData(); 80 d = new OQCopMessageData();
81 d->m_channel = ch; 81 d->m_channel = ch;
82 d->m_message = m; 82 d->m_message = m;
83 d->m_data = arg; 83 d->m_data = arg;
84} 84}
85 85
86bool OQCopMessage::send() 86bool OQCopMessage::send()
87{ 87{
88 if ( d->m_channel. isEmpty() || d->m_message. isEmpty() ) 88 if ( d->m_channel. isEmpty() || d->m_message. isEmpty() )
89 return false; 89 return false;
90 90
91 QCopEnvelope e ( d->m_channel, d->m_message ); 91 QCopEnvelope e ( d->m_channel, d->m_message );
92 92
93 if ( d->m_data. size()) 93 if ( d->m_data. size())
94 e. writeRawBytes ( d->m_data. data(), d->m_data. size()); 94 e. writeRawBytes ( d->m_data. data(), d->m_data. size());
95 95
96 return true; 96 return true;
97} 97}
98 98
99QCString OQCopMessage::channel() const 99QCString OQCopMessage::channel() const
100{ 100{
101 return d->m_channel; 101 return d->m_channel;
102} 102}
103 103
104QCString OQCopMessage::message() const 104QCString OQCopMessage::message() const
105{ 105{
106 return d->m_message; 106 return d->m_message;
107} 107}
108 108
109QByteArray OQCopMessage::data() const 109QByteArray OQCopMessage::data() const
110{ 110{
111 return d->m_data; 111 return d->m_data;
112} 112}
113 113
114bool OQCopMessage::isNull() const 114bool OQCopMessage::isNull() const
115{ 115{
116 return d->m_message.isNull() || d->m_channel.isNull(); 116 return d->m_message.isNull() || d->m_channel.isNull();
117} 117}
118void OQCopMessage::setChannel ( const QCString &ch ) 118void OQCopMessage::setChannel ( const QCString &ch )
119{ 119{
120 d->m_channel = ch; 120 d->m_channel = ch;
121} 121}
122 122
123void OQCopMessage::setMessage ( const QCString &m ) 123void OQCopMessage::setMessage ( const QCString &m )
124{ 124{
125 d->m_message = m; 125 d->m_message = m;
126} 126}
127 127
128void OQCopMessage::setData ( const QByteArray &data ) 128void OQCopMessage::setData ( const QByteArray &data )
129{ 129{
130 d->m_data = data; 130 d->m_data = data;
131} 131}
132 132
133/*! \class Opie::Core::ODeviceButton 133/*! \class Opie::Core::ODeviceButton
134 \brief The Opie::Core::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.
135 135
136 This class represents a physical button on a Qtopia device. A 136 This class represents a physical button on a Qtopia device. A
137 device may have "user programmable" buttons. 137 device may have "user programmable" buttons.
138 The location and number of buttons will vary from device to 138 The location and number of buttons will vary from device to
139 device. userText() and pixmap() may be used to describe this button 139 device. userText() and pixmap() may be used to describe this button
140 to the user in help documentation. 140 to the user in help documentation.
141 141
142 \ingroup qtopiaemb 142 \ingroup qtopiaemb
143 \internal 143 \internal
144*/ 144*/
145 145
146ODeviceButton::ODeviceButton() 146ODeviceButton::ODeviceButton()
147{} 147{}
148 148
149ODeviceButton::~ODeviceButton() 149ODeviceButton::~ODeviceButton()
150{} 150{}
151 151
152/*! 152/*!
153Returns the button's keycode. 153Returns the button's keycode.
154*/ 154*/
155ushort ODeviceButton::keycode() const 155ushort ODeviceButton::keycode() const
156{ 156{
157 return m_Keycode; 157 return m_Keycode;
158} 158}
159 159
160 160
161/*! 161/*!
162This function returns a human readable, translated description of the button. 162This function returns a human readable, translated description of the button.
163*/ 163*/
164QString ODeviceButton::userText() const 164QString ODeviceButton::userText() const
165{ 165{
166 return m_UserText; 166 return m_UserText;
167} 167}
168 168
169/*! 169/*!
170This 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
171it will return an empty (null) pixmap. 171it will return an empty (null) pixmap.
172*/ 172*/
173QPixmap ODeviceButton::pixmap() const 173QPixmap ODeviceButton::pixmap() const
174{ 174{
175 return m_Pixmap; 175 return m_Pixmap;
176} 176}
177 177
178/*! 178/*!
179This function returns the factory preset (default) action for when this button 179This function returns the factory preset (default) action for when this button
180is pressed. The return value is a legal QCop message. 180is pressed. The return value is a legal QCop message.
181*/ 181*/
182OQCopMessage ODeviceButton::factoryPresetPressedAction() const 182OQCopMessage ODeviceButton::factoryPresetPressedAction() const
183{ 183{
184 return m_FactoryPresetPressedAction; 184 return m_FactoryPresetPressedAction;
185} 185}
186 186
187/*! 187/*!
188This function returns the user assigned action for when this button is pressed. 188This function returns the user assigned action for when this button is pressed.
189If no action is assigned, factoryPresetAction() is returned. 189If no action is assigned, factoryPresetAction() is returned.
190*/ 190*/
191OQCopMessage ODeviceButton::pressedAction() const 191OQCopMessage ODeviceButton::pressedAction() const
192{ 192{
193 if (m_PressedAction.channel().isEmpty()) 193 if (m_PressedAction.channel().isEmpty())
194 return factoryPresetPressedAction(); 194 return factoryPresetPressedAction();
195 return m_PressedAction; 195 return m_PressedAction;
196} 196}
197 197
198/*! 198/*!
199This function returns the factory preset (default) action for when this button 199This function returns the factory preset (default) action for when this button
200is pressed and held. The return value is a legal QCop message. 200is pressed and held. The return value is a legal QCop message.
201*/ 201*/
202OQCopMessage ODeviceButton::factoryPresetHeldAction() const 202OQCopMessage ODeviceButton::factoryPresetHeldAction() const
203{ 203{
204 return m_FactoryPresetHeldAction; 204 return m_FactoryPresetHeldAction;
205} 205}
206 206
207/*! 207/*!
208This 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
209and held. If no action is assigned, factoryPresetAction() is returned. 209and held. If no action is assigned, factoryPresetAction() is returned.
210*/ 210*/
211OQCopMessage ODeviceButton::heldAction() const 211OQCopMessage ODeviceButton::heldAction() const
212{ 212{
213 if (m_HeldAction.channel().isEmpty()) 213 if (m_HeldAction.channel().isEmpty())
214 return factoryPresetHeldAction(); 214 return factoryPresetHeldAction();
215 return m_HeldAction; 215 return m_HeldAction;
216} 216}
217 217
218void ODeviceButton::setKeycode(ushort keycode) 218void ODeviceButton::setKeycode(ushort keycode)
219{ 219{
220 m_Keycode = keycode; 220 m_Keycode = keycode;
221} 221}
222 222
223void ODeviceButton::setUserText(const QString& text) 223void ODeviceButton::setUserText(const QString& text)
224{ 224{
225 m_UserText = text; 225 m_UserText = text;
226} 226}
227 227
228void ODeviceButton::setPixmap(const QPixmap& picture) 228void ODeviceButton::setPixmap(const QPixmap& picture)
229{ 229{
230 m_Pixmap = picture; 230 m_Pixmap = picture;
231} 231}
232 232
233void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action) 233void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action)
234{ 234{
235 m_FactoryPresetPressedAction = action; 235 m_FactoryPresetPressedAction = action;
236} 236}
237 237
238 238
239void ODeviceButton::setPressedAction(const OQCopMessage& action) 239void ODeviceButton::setPressedAction(const OQCopMessage& action)
240{ 240{
241 m_PressedAction = action; 241 m_PressedAction = action;
242} 242}
243 243
244void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action) 244void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action)
245{ 245{
246 m_FactoryPresetHeldAction = action; 246 m_FactoryPresetHeldAction = action;
247} 247}
248 248
249void ODeviceButton::setHeldAction(const OQCopMessage& action) 249void ODeviceButton::setHeldAction(const OQCopMessage& action)
250{ 250{
251 m_HeldAction = action; 251 m_HeldAction = action;
252} 252}
253 253
254} 254}
255} 255}
diff --git a/libopie2/opiecore/device/odevicebutton.h b/libopie2/opiecore/device/odevicebutton.h
index 4000144..e3f9ba9 100644
--- a/libopie2/opiecore/device/odevicebutton.h
+++ b/libopie2/opiecore/device/odevicebutton.h
@@ -1,111 +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
26 26
27namespace Opie{ 27namespace Opie{
28namespace Core{ 28namespace Core{
29namespace Private { 29namespace Internal {
30class OQCopMessageData; 30class OQCopMessageData;
31} 31}
32 32
33class OQCopMessage 33class OQCopMessage
34{ 34{
35public: 35public:
36 OQCopMessage ( ); 36 OQCopMessage ( );
37 OQCopMessage ( const OQCopMessage &copy ); 37 OQCopMessage ( const OQCopMessage &copy );
38 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 ( ));
39 39
40 OQCopMessage &operator = ( const OQCopMessage &assign ); 40 OQCopMessage &operator = ( const OQCopMessage &assign );
41 41
42 void setChannel ( const QCString &channel ); 42 void setChannel ( const QCString &channel );
43 void setMessage ( const QCString &message ); 43 void setMessage ( const QCString &message );
44 void setData ( const QByteArray &ba ); 44 void setData ( const QByteArray &ba );
45 45
46 QCString channel ( ) const; 46 QCString channel ( ) const;
47 QCString message ( ) const; 47 QCString message ( ) const;
48 QByteArray data ( ) const; 48 QByteArray data ( ) const;
49 49
50 bool isNull()const; 50 bool isNull()const;
51 51
52 bool send ( ); 52 bool send ( );
53 53
54private: 54private:
55 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 );
56 56
57 Private::OQCopMessageData *d; 57 Internal::OQCopMessageData *d;
58 class Private; 58 class Private;
59 Private* m_data; 59 Private* m_data;
60}; 60};
61 61
62 62
63/** 63/**
64 * 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
65 * 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
66 * 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()
67 * 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.
68 * 68 *
69 * @version 1.0 69 * @version 1.0
70 * @author Trolltech 70 * @author Trolltech
71 * @short A representation of buttons 71 * @short A representation of buttons
72 */ 72 */
73 73
74class ODeviceButton 74class ODeviceButton
75{ 75{
76 public: 76 public:
77 ODeviceButton(); 77 ODeviceButton();
78 virtual ~ODeviceButton(); 78 virtual ~ODeviceButton();
79 79
80 ushort keycode ( ) const; 80 ushort keycode ( ) const;
81 QString userText ( ) const; 81 QString userText ( ) const;
82 QPixmap pixmap ( ) const; 82 QPixmap pixmap ( ) const;
83 OQCopMessage factoryPresetPressedAction ( ) const; 83 OQCopMessage factoryPresetPressedAction ( ) const;
84 OQCopMessage pressedAction ( ) const; 84 OQCopMessage pressedAction ( ) const;
85 OQCopMessage factoryPresetHeldAction ( ) const; 85 OQCopMessage factoryPresetHeldAction ( ) const;
86 OQCopMessage heldAction ( ) const; 86 OQCopMessage heldAction ( ) const;
87 87
88 void setKeycode ( ushort keycode ); 88 void setKeycode ( ushort keycode );
89 void setUserText ( const QString& text ); 89 void setUserText ( const QString& text );
90 void setPixmap ( const QPixmap& picture ); 90 void setPixmap ( const QPixmap& picture );
91 void setFactoryPresetPressedAction ( const OQCopMessage& qcopMessage ); 91 void setFactoryPresetPressedAction ( const OQCopMessage& qcopMessage );
92 void setPressedAction ( const OQCopMessage& qcopMessage ); 92 void setPressedAction ( const OQCopMessage& qcopMessage );
93 void setFactoryPresetHeldAction ( const OQCopMessage& qcopMessage ); 93 void setFactoryPresetHeldAction ( const OQCopMessage& qcopMessage );
94 void setHeldAction ( const OQCopMessage& qcopMessage ); 94 void setHeldAction ( const OQCopMessage& qcopMessage );
95 95
96 private: 96 private:
97 ushort m_Keycode; 97 ushort m_Keycode;
98 QString m_UserText; 98 QString m_UserText;
99 QPixmap m_Pixmap; 99 QPixmap m_Pixmap;
100 OQCopMessage m_FactoryPresetPressedAction; 100 OQCopMessage m_FactoryPresetPressedAction;
101 OQCopMessage m_PressedAction; 101 OQCopMessage m_PressedAction;
102 OQCopMessage m_FactoryPresetHeldAction; 102 OQCopMessage m_FactoryPresetHeldAction;
103 OQCopMessage m_HeldAction; 103 OQCopMessage m_HeldAction;
104 class Private; 104 class Private;
105 Private *d; 105 Private *d;
106}; 106};
107 107
108} 108}
109} 109}
110 110
111#endif 111#endif
diff --git a/libopie2/opiecore/oapplication.cpp b/libopie2/opiecore/oapplication.cpp
index e2f6e82..ac7cd5a 100644
--- a/libopie2/opiecore/oapplication.cpp
+++ b/libopie2/opiecore/oapplication.cpp
@@ -1,136 +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; 37using namespace Opie::Core;
38 38
39 39
40OApplication* OApplication::_instance = 0; 40OApplication* OApplication::_instance = 0;
41 41
42/************************************************************************************************** 42/**************************************************************************************************
43 * OApplicationPrivate 43 * OApplicationPrivate
44 **************************************************************************************************/ 44 **************************************************************************************************/
45 45
46namespace Opie { 46namespace Opie {
47namespace Core { 47namespace Core {
48namespace Private { 48namespace Internal {
49class OApplicationPrivate 49class OApplicationPrivate
50{ 50{
51 public: 51 public:
52 OApplicationPrivate() {}; 52 OApplicationPrivate() {};
53 ~OApplicationPrivate() {}; 53 ~OApplicationPrivate() {};
54}; 54};
55} 55}
56 56
57/************************************************************************************************** 57/**************************************************************************************************
58 * OApplication 58 * OApplication
59 **************************************************************************************************/ 59 **************************************************************************************************/
60 60
61 61
62OApplication::OApplication( int& argc, char** argv, const QCString& rAppName ) 62OApplication::OApplication( int& argc, char** argv, const QCString& rAppName )
63 :QPEApplication( argc, argv ), 63 :QPEApplication( argc, argv ),
64 _appname( rAppName ), 64 _appname( rAppName ),
65 _config( 0 ) 65 _config( 0 )
66{ 66{
67 init(); 67 init();
68} 68}
69 69
70 70
71OApplication::~OApplication() 71OApplication::~OApplication()
72{ 72{
73 delete d; 73 delete d;
74 if ( _config ) 74 if ( _config )
75 delete _config; 75 delete _config;
76 OApplication::_instance = 0; 76 OApplication::_instance = 0;
77 // after deconstruction of the one-and-only application object, 77 // after deconstruction of the one-and-only application object,
78 // the construction of another object is allowed 78 // the construction of another object is allowed
79} 79}
80 80
81 81
82OConfig* OApplication::config() 82OConfig* OApplication::config()
83{ 83{
84 if ( !_config ) 84 if ( !_config )
85 { 85 {
86 _config = new OConfig( _appname ); 86 _config = new OConfig( _appname );
87 } 87 }
88 return _config; 88 return _config;
89} 89}
90 90
91 91
92void OApplication::init() 92void OApplication::init()
93{ 93{
94 d = new Private::OApplicationPrivate(); 94 d = new Internal::OApplicationPrivate();
95 if ( !OApplication::_instance ) 95 if ( !OApplication::_instance )
96 { 96 {
97 OApplication::_instance = this; 97 OApplication::_instance = this;
98 98
99 /* register SIGSEGV handler to give programs an option 99 /* register SIGSEGV handler to give programs an option
100 * to exit gracefully, e.g. save or close devices or files. 100 * to exit gracefully, e.g. save or close devices or files.
101 struct sigaction sa; 101 struct sigaction sa;
102 sa.sa_handler = ( void (*)(int) ) &segv_handler; 102 sa.sa_handler = ( void (*)(int) ) &segv_handler;
103 sa.sa_flags = SA_SIGINFO | SA_RESTART; 103 sa.sa_flags = SA_SIGINFO | SA_RESTART;
104 sigemptyset(&sa.sa_mask); 104 sigemptyset(&sa.sa_mask);
105 sigaction(SIGSEGV, &sa, NULL); 105 sigaction(SIGSEGV, &sa, NULL);
106 */ 106 */
107 } 107 }
108 else 108 else
109 { 109 {
110 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;
111 //FIXME exit gracefully ? 111 //FIXME exit gracefully ?
112 ::exit( -1 ); 112 ::exit( -1 );
113 } 113 }
114} 114}
115 115
116 116
117void OApplication::showMainWidget( QWidget* widget, bool nomax ) 117void OApplication::showMainWidget( QWidget* widget, bool nomax )
118{ 118{
119 QPEApplication::showMainWidget( widget, nomax ); 119 QPEApplication::showMainWidget( widget, nomax );
120 widget->setCaption( _appname ); 120 widget->setCaption( _appname );
121} 121}
122 122
123 123
124void OApplication::setTitle( const QString& title ) const 124void OApplication::setTitle( const QString& title ) const
125{ 125{
126 if ( mainWidget() ) 126 if ( mainWidget() )
127 { 127 {
128 if ( !title.isNull() ) 128 if ( !title.isNull() )
129 mainWidget()->setCaption( QString(_appname) + QString( " - " ) + title ); 129 mainWidget()->setCaption( QString(_appname) + QString( " - " ) + title );
130 else 130 else
131 mainWidget()->setCaption( _appname ); 131 mainWidget()->setCaption( _appname );
132 } 132 }
133} 133}
134 134
135} 135}
136} 136}
diff --git a/libopie2/opiecore/oapplication.h b/libopie2/opiecore/oapplication.h
index c1e32a6..337fe5e 100644
--- a/libopie2/opiecore/oapplication.h
+++ b/libopie2/opiecore/oapplication.h
@@ -1,111 +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 Opie::Core::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
38namespace Opie { 38namespace Opie {
39namespace Core { 39namespace Core {
40namespace Private { 40namespace Internal {
41class OApplicationPrivate; 41class OApplicationPrivate;
42} // private class 42} // private class
43 43
44class OConfig; 44class OConfig;
45 45
46 46
47class OApplication : public QPEApplication 47class OApplication : public QPEApplication
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50 50
51 public: 51 public:
52 /** 52 /**
53 * Constructor. Parses command-line arguments and sets the window caption. 53 * Constructor. Parses command-line arguments and sets the window caption.
54 * 54 *
55 * @param rAppName application name. Will be used for finding the 55 * @param rAppName application name. Will be used for finding the
56 * associated message, icon and configuration files 56 * associated message, icon and configuration files
57 * 57 *
58 */ 58 */
59 OApplication( int& argc, char** argv, const QCString& rAppName ); 59 OApplication( int& argc, char** argv, const QCString& rAppName );
60 /** 60 /**
61 * Destructor. Destroys the application object and its children. 61 * Destructor. Destroys the application object and its children.
62 */ 62 */
63 virtual ~OApplication(); 63 virtual ~OApplication();
64 /** 64 /**
65 * @returns the process-wide application object 65 * @returns the process-wide application object
66 * 66 *
67 * This is similar to the global @ref QApplication pointer qApp. It 67 * This is similar to the global @ref QApplication pointer qApp. It
68 * allows access to the single global OApplication object, since 68 * allows access to the single global OApplication object, since
69 * more than one cannot be created in the same application. It 69 * more than one cannot be created in the same application. It
70 * saves you the trouble of having to pass the pointer explicitly 70 * saves you the trouble of having to pass the pointer explicitly
71 * to every function that may require it. 71 * to every function that may require it.
72 */ 72 */
73 static OApplication* oApplication() { return _instance; }; 73 static OApplication* oApplication() { return _instance; };
74 /** 74 /**
75 * Returns the application name as given during creation. 75 * Returns the application name as given during creation.
76 * 76 *
77 * @returns a reference to the application name 77 * @returns a reference to the application name
78 */ 78 */
79 const QCString& appName() const { return _appname; }; 79 const QCString& appName() const { return _appname; };
80 /** 80 /**
81 * @returns the application session config object. 81 * @returns the application session config object.
82 * 82 *
83 * @see OConfig 83 * @see OConfig
84 */ 84 */
85 OConfig* config(); 85 OConfig* config();
86 /** 86 /**
87 * 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.
88 */ 88 */
89 virtual void showMainWidget( QWidget* widget, bool nomax = false ); 89 virtual void showMainWidget( QWidget* widget, bool nomax = false );
90 /** 90 /**
91 * Set the application title. The application title will be concatenated 91 * Set the application title. The application title will be concatenated
92 * to the application name given in the constructor. 92 * to the application name given in the constructor.
93 * 93 *
94 * @param title the title. If not given, resets caption to appname 94 * @param title the title. If not given, resets caption to appname
95 */ 95 */
96 virtual void setTitle( const QString& title = QString::null ) const; 96 virtual void setTitle( const QString& title = QString::null ) const;
97 97
98 protected: 98 protected:
99 void init(); 99 void init();
100 100
101 private: 101 private:
102 const QCString _appname; 102 const QCString _appname;
103 static OApplication* _instance; 103 static OApplication* _instance;
104 OConfig* _config; 104 OConfig* _config;
105 Private::OApplicationPrivate* d; 105 Internal::OApplicationPrivate* d;
106}; 106};
107 107
108} // Core 108} // Core
109} // Opie 109} // Opie
110 110
111#endif // OAPPLICATION_H 111#endif // OAPPLICATION_H
diff --git a/libopie2/opiecore/oconfig.h b/libopie2/opiecore/oconfig.h
index 29c1f86..8c3060c 100644
--- a/libopie2/opiecore/oconfig.h
+++ b/libopie2/opiecore/oconfig.h
@@ -1,154 +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 { 43namespace Opie {
44namespace Core { 44namespace Core {
45 45
46/** 46/**
47 * A Configuration class based on the Qtopia @ref Config class 47 * A Configuration class based on the Qtopia @ref Config class
48 * featuring additional handling of color and font entries 48 * featuring additional handling of color and font entries
49 */ 49 */
50 50
51class OConfig : public Config 51class OConfig : public Config
52{ 52{
53 public: 53 public:
54 /** 54 /**
55 * Constructs a OConfig object with a @a name. 55 * Constructs a OConfig object with a @a name.
56 */ 56 */
57 OConfig( const QString &name, Domain domain = User ); 57 OConfig( const QString &name, Domain domain = User );
58 /** 58 /**
59 * Destructs the OConfig object. 59 * Destructs the OConfig object.
60 * 60 *
61 * Writes back any dirty configuration entries, and destroys 61 * Writes back any dirty configuration entries, and destroys
62 * dynamically created objects. 62 * dynamically created objects.
63 */ 63 */
64 virtual ~OConfig(); 64 virtual ~OConfig();
65 /** 65 /**
66 * @returns the name of the current group. 66 * @returns the name of the current group.
67 * 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 68 * @todo make const
69 */ 69 */
70 const QString& group() { return git.key(); }; 70 const QString& group()const { return git.key(); };
71 /** 71 /**
72 * @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.
73 */ 73 */
74 QColor readColorEntry( const QString& key, const QColor* pDefault ) const; 74 QColor readColorEntry( const QString& key, const QColor* pDefault ) const;
75 /** 75 /**
76 * @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.
77 */ 77 */
78 QFont readFontEntry( const QString& key, const QFont* pDefault ) const; 78 QFont readFontEntry( const QString& key, const QFont* pDefault ) const;
79 79
80private: 80private:
81 class Private; 81 class Private;
82 Private *d; 82 Private *d;
83}; 83};
84 84
85/** 85/**
86 * @brief Helper class for easier use of OConfig groups. 86 * @brief Helper class for easier use of OConfig groups.
87 * 87 *
88 * Careful programmers always set the group of a 88 * Careful programmers always set the group of a
89 * @ref OConfig object to the group they want to read from 89 * @ref OConfig object to the group they want to read from
90 * 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
91 * written as: 91 * written as:
92 * <pre> 92 * <pre>
93 * 93 *
94 * QString oldgroup config()->group(); 94 * QString oldgroup config()->group();
95 * config()->setGroup( "TheGroupThatIWant" ); 95 * config()->setGroup( "TheGroupThatIWant" );
96 * ... 96 * ...
97 * config()->writeEntry( "Blah", "Blubb" ); 97 * config()->writeEntry( "Blah", "Blubb" );
98 * 98 *
99 * config()->setGroup( oldgroup ); 99 * config()->setGroup( oldgroup );
100 * </pre> 100 * </pre>
101 * 101 *
102 * In order to facilitate this task, you can use 102 * In order to facilitate this task, you can use
103 * OConfigGroupSaver. Simply construct such an object ON THE STACK 103 * OConfigGroupSaver. Simply construct such an object ON THE STACK
104 * 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
105 * out of scope, the group will automatically be restored. If you 105 * out of scope, the group will automatically be restored. If you
106 * want to use several different groups within a function or method, 106 * want to use several different groups within a function or method,
107 * you can still use OConfigGroupSaver: Simply enclose all work with 107 * you can still use OConfigGroupSaver: Simply enclose all work with
108 * one group (including the creation of the OConfigGroupSaver object) 108 * one group (including the creation of the OConfigGroupSaver object)
109 * in one block. 109 * in one block.
110 * 110 *
111 * @author Matthias Kalle Dalheimer <Kalle@kde.org> 111 * @author Matthias Kalle Dalheimer <Kalle@kde.org>
112 * @version $Id$ 112 * @version $Id$
113 * @see OConfig 113 * @see OConfig
114 */ 114 */
115 115
116class OConfigGroupSaver 116class OConfigGroupSaver
117{ 117{
118 public: 118 public:
119 /** 119 /**
120 * Constructor. 120 * Constructor.
121 * 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
122 * the current group. 122 * the current group.
123 */ 123 */
124 OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() ) 124 OConfigGroupSaver( OConfig* config, QString group ) :_config(config), _oldgroup(config->group() )
125 { _config->setGroup( group ); } 125 { _config->setGroup( group ); }
126 126
127 OConfigGroupSaver( OConfig* config, const char *group ) :_config(config), _oldgroup(config->group()) 127 OConfigGroupSaver( OConfig* config, const char *group ) :_config(config), _oldgroup(config->group())
128 { _config->setGroup( group ); } 128 { _config->setGroup( group ); }
129 129
130 OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group()) 130 OConfigGroupSaver( OConfig* config, const QCString &group ) : _config(config), _oldgroup(config->group())
131 { _config->setGroup( group ); } 131 { _config->setGroup( group ); }
132 /** 132 /**
133 * Destructor. 133 * Destructor.
134 * Restores the last current group. 134 * Restores the last current group.
135 * @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
136 */ 136 */
137 ~OConfigGroupSaver() { _config->setGroup( _oldgroup ); } 137 ~OConfigGroupSaver() { _config->setGroup( _oldgroup ); }
138 138
139 OConfig* config() { return _config; }; 139 OConfig* config() { return _config; };
140 140
141 private: 141 private:
142 OConfig* _config; 142 OConfig* _config;
143 QString _oldgroup; 143 QString _oldgroup;
144 144
145 OConfigGroupSaver( const OConfigGroupSaver& ); 145 OConfigGroupSaver( const OConfigGroupSaver& );
146 OConfigGroupSaver& operator=( const OConfigGroupSaver& ); 146 OConfigGroupSaver& operator=( const OConfigGroupSaver& );
147 147
148 class Private; 148 class Private;
149 Private *d; 149 Private *d;
150}; 150};
151} 151}
152} 152}
153 153
154#endif // OCONFIG_H 154#endif // OCONFIG_H
diff --git a/libopie2/opiecore/odebug.cpp b/libopie2/opiecore/odebug.cpp
index cac985b..f258faa 100644
--- a/libopie2/opiecore/odebug.cpp
+++ b/libopie2/opiecore/odebug.cpp
@@ -1,197 +1,206 @@
1/* 1/*
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 (C) 2002 Holger Freyther (freyther@kde.org) 4 (C) 2002 Holger Freyther (freyther@kde.org)
5 (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) 5 (C) 1997 Matthias Kalle Dalheimer (kalle@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// 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
68namespace Opie { 68namespace Opie {
69namespace Core { 69namespace Core {
70namespace Internal {
71class DebugBackend {
72};
73
74static DebugBackend *backEnd = 0;
75}
76static void clean_up_routine() {
77 delete Internal::backEnd;
78}
70/*====================================================================================== 79/*======================================================================================
71 * debug levels 80 * debug levels
72 *======================================================================================*/ 81 *======================================================================================*/
73 82
74enum DebugLevels { 83enum DebugLevels {
75 ODEBUG_INFO = 0, 84 ODEBUG_INFO = 0,
76 ODEBUG_WARN = 1, 85 ODEBUG_WARN = 1,
77 ODEBUG_ERROR = 2, 86 ODEBUG_ERROR = 2,
78 ODEBUG_FATAL = 3 87 ODEBUG_FATAL = 3
79}; 88};
80 89
81/*====================================================================================== 90/*======================================================================================
82 * oDebug private data 91 * oDebug private data
83 *======================================================================================*/ 92 *======================================================================================*/
84 93
85/*====================================================================================== 94/*======================================================================================
86 * the main debug function 95 * the main debug function
87 *======================================================================================*/ 96 *======================================================================================*/
88 97
89static void oDebugBackend( unsigned short level, unsigned int area, const char *data) 98static void oDebugBackend( unsigned short level, unsigned int area, const char *data)
90{ 99{
91 //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data ); 100 //qDebug( "oDebugBackend: Level=%d, Area=%d, Data=%s", level, area, data );
92 101
93 // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an 102 // ML: OPIE doesn't use areacodes at the moment. See the KDE debug classes for an
94 // ML: example use. I think it's not necessary to implement such a strategy here. 103 // ML: example use. I think it's not necessary to implement such a strategy here.
95 // ML: Comments? 104 // ML: Comments?
96 105
97 int priority = 0; 106 int priority = 0;
98 QString caption; 107 QString caption;
99 QString lev; 108 QString lev;
100 switch( level ) 109 switch( level )
101 { 110 {
102 case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break; 111 case ODEBUG_INFO: lev = "(Info)"; caption = "Info"; priority = LOG_INFO; break;
103 case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break; 112 case ODEBUG_WARN: lev = "(Warn)"; caption = "Warning"; priority = LOG_WARNING; break;
104 case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break; 113 case ODEBUG_FATAL: lev = "(Fatal)"; caption = "Fatal Error"; priority = LOG_CRIT; break;
105 default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." ); 114 default: qDebug( "oDebugBackend: Warning: Unknown debug level! - defaulting to ODEBUG_ERROR." );
106 case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break; 115 case ODEBUG_ERROR: lev = "(Error)"; caption = "Error"; priority = LOG_ERR; break;
107 } 116 }
108 117
109 short output = OGlobalSettings::debugMode(); 118 short output = OGlobalSettings::debugMode();
110 if (!oApp && (output == 1)) 119 if (!oApp && (output == 1))
111 { 120 {
112 qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" ); 121 qDebug( "oDebugBackend: Warning: no oapplication object - can't use MsgBox" );
113 output = 2; // need an application object to use MsgBox 122 output = 2; // need an application object to use MsgBox
114 } 123 }
115 124
116 // gcc 2.9x is dumb and sucks... can you hear it? 125 // gcc 2.9x is dumb and sucks... can you hear it?
117 //QString areaName = (oApp) ? oApp->appName() : "<unknown>"; 126 //QString areaName = (oApp) ? oApp->appName() : "<unknown>";
118 QString areaName; 127 QString areaName;
119 if ( oApp ) areaName = oApp->appName(); 128 if ( oApp ) areaName = oApp->appName();
120 else areaName = "<unknown>"; 129 else areaName = "<unknown>";
121 130
122 // Output 131 // Output
123 switch( output ) 132 switch( output )
124 { 133 {
125 case -1: // ignore 134 case -1: // ignore
126 { 135 {
127 return; 136 return;
128 } 137 }
129 case 0: // File 138 case 0: // File
130 { 139 {
131 QString outputFilename = OGlobalSettings::debugOutput(); 140 QString outputFilename = OGlobalSettings::debugOutput();
132 141
133 const int BUFSIZE = 4096; 142 const int BUFSIZE = 4096;
134 char buf[BUFSIZE] = ""; 143 char buf[BUFSIZE] = "";
135 buf[BUFSIZE-1] = '\0'; 144 buf[BUFSIZE-1] = '\0';
136 int nSize; 145 int nSize;
137 146
138 nSize = snprintf( buf, BUFSIZE-1, "%s: %s", (const char*) areaName, data); 147 nSize = snprintf( buf, BUFSIZE-1, "%s: %s", (const char*) areaName, data);
139 148
140 QFile outputFile( outputFilename ); 149 QFile outputFile( outputFilename );
141 if ( outputFile.open( IO_WriteOnly | IO_Append ) ) 150 if ( outputFile.open( IO_WriteOnly | IO_Append ) )
142 { 151 {
143 if ( ( nSize == -1 ) || ( nSize >= BUFSIZE ) ) 152 if ( ( nSize == -1 ) || ( nSize >= BUFSIZE ) )
144 { 153 {
145 outputFile.writeBlock( buf, BUFSIZE-1 ); 154 outputFile.writeBlock( buf, BUFSIZE-1 );
146 } 155 }
147 else 156 else
148 { 157 {
149 outputFile.writeBlock( buf, nSize ); 158 outputFile.writeBlock( buf, nSize );
150 } 159 }
151 } 160 }
152 else 161 else
153 { 162 {
154 qDebug( "ODebug: can't write to file '%s' (%s)", (const char*) outputFilename, strerror(errno) ); 163 qDebug( "ODebug: can't write to file '%s' (%s)", (const char*) outputFilename, strerror(errno) );
155 } 164 }
156 break; 165 break;
157 } // automatic close of file here 166 } // automatic close of file here
158 167
159 case 1: // Message Box 168 case 1: // Message Box
160 { 169 {
161 // Since we are in opiecore here, we cannot use OMsgBox and use 170 // Since we are in opiecore here, we cannot use OMsgBox and use
162 // QMessageBox instead 171 // QMessageBox instead
163 172
164 caption += QString("(") + areaName + ")"; 173 caption += QString("(") + areaName + ")";
165 QMessageBox::warning( 0L, caption, data, ("&OK") ); // tr? 174 QMessageBox::warning( 0L, caption, data, ("&OK") ); // tr?
166 break; 175 break;
167 } 176 }
168 177
169 case 2: // Shell 178 case 2: // Shell
170 { 179 {
171 FILE *output = stderr; 180 FILE *output = stderr;
172 fprintf( output, "%s: ", (const char*) areaName ); 181 fprintf( output, "%s: ", (const char*) areaName );
173 fputs( data, output); 182 fputs( data, output);
174 break; 183 break;
175 } 184 }
176 185
177 case 3: // syslog 186 case 3: // syslog
178 { 187 {
179 syslog( priority, "%s", data); 188 syslog( priority, "%s", data);
180 break; 189 break;
181 } 190 }
182 191
183 case 4: // socket 192 case 4: // socket
184 { 193 {
185 QString destination = OGlobalSettings::debugOutput(); 194 QString destination = OGlobalSettings::debugOutput();
186 if ( destination && destination.find(":") != -1 ) 195 if ( destination && destination.find(":") != -1 )
187 { 196 {
188 QString host = destination.left( destination.find(":") ); 197 QString host = destination.left( destination.find(":") );
189 QString port = destination.right( destination.length()-host.length()-1 ); 198 QString port = destination.right( destination.length()-host.length()-1 );
190 QHostAddress addr; 199 QHostAddress addr;
191 addr.setAddress( host ); 200 addr.setAddress( host );
192 // TODO: sanity check the address 201 // TODO: sanity check the address
193 QString line; 202 QString line;
194 line.sprintf( "%s: %s", (const char*) areaName, (const char*) data ); 203 line.sprintf( "%s: %s", (const char*) areaName, (const char*) data );
195 QSocketDevice s( QSocketDevice::Datagram ); 204 QSocketDevice s( QSocketDevice::Datagram );
196 int result = s.writeBlock( (const char*) line, line.length(), addr, port.toInt() ); 205 int result = s.writeBlock( (const char*) line, line.length(), addr, port.toInt() );
197 if ( result == -1 ) 206 if ( result == -1 )
@@ -497,129 +506,129 @@ odbgstream& odbgstream::operator<<( const QDate& date)
497 *this << date.toString(); 506 *this << date.toString();
498 507
499 return *this; 508 return *this;
500} 509}
501 510
502 511
503odbgstream& odbgstream::operator<<( const QTime& time ) 512odbgstream& odbgstream::operator<<( const QTime& time )
504{ 513{
505 *this << time.toString(); 514 *this << time.toString();
506 return *this; 515 return *this;
507} 516}
508 517
509 518
510odbgstream& odbgstream::operator<<( const QPoint& p ) 519odbgstream& odbgstream::operator<<( const QPoint& p )
511{ 520{
512 *this << "(" << p.x() << ", " << p.y() << ")"; 521 *this << "(" << p.x() << ", " << p.y() << ")";
513 return *this; 522 return *this;
514} 523}
515 524
516 525
517odbgstream& odbgstream::operator<<( const QSize& s ) 526odbgstream& odbgstream::operator<<( const QSize& s )
518{ 527{
519 *this << "[" << s.width() << "x" << s.height() << "]"; 528 *this << "[" << s.width() << "x" << s.height() << "]";
520 return *this; 529 return *this;
521} 530}
522 531
523 532
524odbgstream& odbgstream::operator<<( const QRect& r ) 533odbgstream& odbgstream::operator<<( const QRect& r )
525{ 534{
526 *this << "[" << r.left() << ", " << r.top() << " - " << r.right() << ", " << r.bottom() << "]"; 535 *this << "[" << r.left() << ", " << r.top() << " - " << r.right() << ", " << r.bottom() << "]";
527 return *this; 536 return *this;
528} 537}
529 538
530 539
531odbgstream& odbgstream::operator<<( const QRegion& reg ) 540odbgstream& odbgstream::operator<<( const QRegion& reg )
532{ 541{
533 /* Qt2 doesn't have a QMemArray... :( 542 /* Qt2 doesn't have a QMemArray... :(
534 *this << "[ "; 543 *this << "[ ";
535 QMemArray<QRect>rs=reg.rects(); 544 QMemArray<QRect>rs=reg.rects();
536 for (uint i=0;i<rs.size();++i) 545 for (uint i=0;i<rs.size();++i)
537 *this << QString("[%1, %2 - %3, %4] ").arg(rs[i].left()).arg(rs[i].top()).arg(rs[i].right()).arg(rs[i].bottom() ) ; 546 *this << QString("[%1, %2 - %3, %4] ").arg(rs[i].left()).arg(rs[i].top()).arg(rs[i].right()).arg(rs[i].bottom() ) ;
538 *this <<"]"; 547 *this <<"]";
539 */ 548 */
540 return *this; 549 return *this;
541} 550}
542 551
543 552
544odbgstream& odbgstream::operator<<( const QStringList& l ) 553odbgstream& odbgstream::operator<<( const QStringList& l )
545{ 554{
546 *this << "("; 555 *this << "(";
547 *this << l.join(","); 556 *this << l.join(",");
548 *this << ")"; 557 *this << ")";
549 558
550 return *this; 559 return *this;
551} 560}
552 561
553 562
554odbgstream& odbgstream::operator<<( const QColor& c ) 563odbgstream& odbgstream::operator<<( const QColor& c )
555{ 564{
556 if ( c.isValid() ) 565 if ( c.isValid() )
557 *this << c.name(); 566 *this << c.name();
558 else 567 else
559 *this << "(invalid/default)"; 568 *this << "(invalid/default)";
560 return *this; 569 return *this;
561} 570}
562 571
563 572
564odbgstream& odbgstream::operator<<( const QBrush& b) 573odbgstream& odbgstream::operator<<( const QBrush& b)
565{ 574{
566 static const char* const s_brushStyles[] = { 575 static const char* const s_brushStyles[] = {
567 "NoBrush", "SolidPattern", "Dense1Pattern", "Dense2Pattern", "Dense3Pattern", 576 "NoBrush", "SolidPattern", "Dense1Pattern", "Dense2Pattern", "Dense3Pattern",
568 "Dense4Pattern", "Dense5Pattern", "Dense6Pattern", "Dense7Pattern", 577 "Dense4Pattern", "Dense5Pattern", "Dense6Pattern", "Dense7Pattern",
569 "HorPattern", "VerPattern", "CrossPattern", "BDiagPattern", "FDiagPattern", 578 "HorPattern", "VerPattern", "CrossPattern", "BDiagPattern", "FDiagPattern",
570 "DiagCrossPattern" }; 579 "DiagCrossPattern" };
571 580
572 *this <<"[ style: "; 581 *this <<"[ style: ";
573 *this <<s_brushStyles[ b.style() ]; 582 *this <<s_brushStyles[ b.style() ];
574 *this <<" color: "; 583 *this <<" color: ";
575 // can't use operator<<(str, b.color()) because that terminates a odbgstream (flushes) 584 // can't use operator<<(str, b.color()) because that terminates a odbgstream (flushes)
576 if ( b.color().isValid() ) 585 if ( b.color().isValid() )
577 *this <<b.color().name() ; 586 *this <<b.color().name() ;
578 else 587 else
579 *this <<"(invalid/default)"; 588 *this <<"(invalid/default)";
580 if ( b.pixmap() ) 589 if ( b.pixmap() )
581 *this <<" has a pixmap"; 590 *this <<" has a pixmap";
582 *this <<" ]"; 591 *this <<" ]";
583 return *this; 592 return *this;
584} 593}
585 594
586 595
587 596
588QString odBacktrace( int levels ) 597QString odBacktrace( int levels )
589{ 598{
590 QString s; 599 QString s;
591#ifndef OPIE_NO_BACKTRACE 600#ifndef OPIE_NO_BACKTRACE
592 void* trace[256]; 601 void* trace[256];
593 int n = backtrace(trace, 256); 602 int n = backtrace(trace, 256);
594 char** strings = backtrace_symbols (trace, n); 603 char** strings = backtrace_symbols (trace, n);
595 604
596 if ( levels != -1 ) 605 if ( levels != -1 )
597 n = QMIN( n, levels ); 606 n = QMIN( n, levels );
598 s = "[\n"; 607 s = "[\n";
599 608
600 for (int i = 0; i < n; ++i) 609 for (int i = 0; i < n; ++i)
601 s += QString::number(i) + 610 s += QString::number(i) +
602 QString::fromLatin1(": ") + 611 QString::fromLatin1(": ") +
603 QString::fromLatin1(strings[i]) + QString::fromLatin1("\n"); 612 QString::fromLatin1(strings[i]) + QString::fromLatin1("\n");
604 s += "]\n"; 613 s += "]\n";
605 free (strings); 614 free (strings);
606#endif 615#endif
607 return s; 616 return s;
608} 617}
609 618
610void odClearDebugConfig() 619void odClearDebugConfig()
611{ 620{
612 /* 621 /*
613 delete oDebug_data->config; 622 delete oDebug_data->config;
614 oDebug_data->config = 0; 623 oDebug_data->config = 0;
615 */ 624 */
616} 625}
617 626
618 627
619#ifdef OPIE_NO_DEBUG 628#ifdef OPIE_NO_DEBUG
620#define odDebug ondDebug 629#define odDebug ondDebug
621#define odBacktrace ondBacktrace 630#define odBacktrace ondBacktrace
622#endif 631#endif
623 632
624} 633}
625} \ No newline at end of file 634}
diff --git a/libopie2/opiecore/oprocctrl.cpp b/libopie2/opiecore/oprocctrl.cpp
index 46708ba..404e0b3 100644
--- a/libopie2/opiecore/oprocctrl.cpp
+++ b/libopie2/opiecore/oprocctrl.cpp
@@ -1,172 +1,172 @@
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; 44using namespace Opie::Core::Internal;
45 45
46OProcessController *OProcessController::theOProcessController = 0; 46OProcessController *OProcessController::theOProcessController = 0;
47 47
48struct sigaction OProcessController::oldChildHandlerData; 48struct sigaction OProcessController::oldChildHandlerData;
49bool OProcessController::handlerSet = false; 49bool OProcessController::handlerSet = false;
50 50
51OProcessController::OProcessController() 51OProcessController::OProcessController()
52{ 52{
53 assert( theOProcessController == 0 ); 53 assert( theOProcessController == 0 );
54 54
55 if (0 > pipe(fd)) 55 if (0 > pipe(fd))
56 printf(strerror(errno)); 56 printf(strerror(errno));
57 57
58 notifier = new QSocketNotifier(fd[0], QSocketNotifier::Read); 58 notifier = new QSocketNotifier(fd[0], QSocketNotifier::Read);
59 notifier->setEnabled(true); 59 notifier->setEnabled(true);
60 QObject::connect(notifier, SIGNAL(activated(int)), 60 QObject::connect(notifier, SIGNAL(activated(int)),
61 this, SLOT(slotDoHousekeeping(int))); 61 this, SLOT(slotDoHousekeeping(int)));
62 connect( &delayedChildrenCleanupTimer, SIGNAL( timeout()), 62 connect( &delayedChildrenCleanupTimer, SIGNAL( timeout()),
63 SLOT( delayedChildrenCleanup())); 63 SLOT( delayedChildrenCleanup()));
64 64
65 theOProcessController = this; 65 theOProcessController = this;
66 66
67 setupHandlers(); 67 setupHandlers();
68} 68}
69 69
70 70
71void OProcessController::setupHandlers() 71void OProcessController::setupHandlers()
72{ 72{
73 if( handlerSet ) 73 if( handlerSet )
74 return; 74 return;
75 struct sigaction act; 75 struct sigaction act;
76 act.sa_handler=theSigCHLDHandler; 76 act.sa_handler=theSigCHLDHandler;
77 sigemptyset(&(act.sa_mask)); 77 sigemptyset(&(act.sa_mask));
78 sigaddset(&(act.sa_mask), SIGCHLD); 78 sigaddset(&(act.sa_mask), SIGCHLD);
79 // 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 :-(
80 sigprocmask(SIG_UNBLOCK, &(act.sa_mask), 0); 80 sigprocmask(SIG_UNBLOCK, &(act.sa_mask), 0);
81 81
82 act.sa_flags = SA_NOCLDSTOP; 82 act.sa_flags = SA_NOCLDSTOP;
83 83
84 // CC: take care of SunOS which automatically restarts interrupted system 84 // CC: take care of SunOS which automatically restarts interrupted system
85 // calls (and thus does not have SA_RESTART) 85 // calls (and thus does not have SA_RESTART)
86 86
87#ifdef SA_RESTART 87#ifdef SA_RESTART
88 act.sa_flags |= SA_RESTART; 88 act.sa_flags |= SA_RESTART;
89#endif 89#endif
90 90
91 sigaction( SIGCHLD, &act, &oldChildHandlerData ); 91 sigaction( SIGCHLD, &act, &oldChildHandlerData );
92 92
93 act.sa_handler=SIG_IGN; 93 act.sa_handler=SIG_IGN;
94 sigemptyset(&(act.sa_mask)); 94 sigemptyset(&(act.sa_mask));
95 sigaddset(&(act.sa_mask), SIGPIPE); 95 sigaddset(&(act.sa_mask), SIGPIPE);
96 act.sa_flags = 0; 96 act.sa_flags = 0;
97 sigaction( SIGPIPE, &act, 0L); 97 sigaction( SIGPIPE, &act, 0L);
98 handlerSet = true; 98 handlerSet = true;
99} 99}
100 100
101void OProcessController::resetHandlers() 101void OProcessController::resetHandlers()
102{ 102{
103 if( !handlerSet ) 103 if( !handlerSet )
104 return; 104 return;
105 sigaction( SIGCHLD, &oldChildHandlerData, 0 ); 105 sigaction( SIGCHLD, &oldChildHandlerData, 0 );
106 // there should be no problem with SIGPIPE staying SIG_IGN 106 // there should be no problem with SIGPIPE staying SIG_IGN
107 handlerSet = false; 107 handlerSet = false;
108} 108}
109 109
110// block SIGCHLD handler, because it accesses processList 110// block SIGCHLD handler, because it accesses processList
111void OProcessController::addOProcess( OProcess* p ) 111void OProcessController::addOProcess( OProcess* p )
112{ 112{
113 sigset_t newset, oldset; 113 sigset_t newset, oldset;
114 sigemptyset( &newset ); 114 sigemptyset( &newset );
115 sigaddset( &newset, SIGCHLD ); 115 sigaddset( &newset, SIGCHLD );
116 sigprocmask( SIG_BLOCK, &newset, &oldset ); 116 sigprocmask( SIG_BLOCK, &newset, &oldset );
117 processList.append( p ); 117 processList.append( p );
118 sigprocmask( SIG_SETMASK, &oldset, 0 ); 118 sigprocmask( SIG_SETMASK, &oldset, 0 );
119} 119}
120 120
121void OProcessController::removeOProcess( OProcess* p ) 121void OProcessController::removeOProcess( OProcess* p )
122{ 122{
123 sigset_t newset, oldset; 123 sigset_t newset, oldset;
124 sigemptyset( &newset ); 124 sigemptyset( &newset );
125 sigaddset( &newset, SIGCHLD ); 125 sigaddset( &newset, SIGCHLD );
126 sigprocmask( SIG_BLOCK, &newset, &oldset ); 126 sigprocmask( SIG_BLOCK, &newset, &oldset );
127 processList.remove( p ); 127 processList.remove( p );
128 sigprocmask( SIG_SETMASK, &oldset, 0 ); 128 sigprocmask( SIG_SETMASK, &oldset, 0 );
129} 129}
130 130
131//using a struct which contains both the pid and the status makes it easier to write 131//using a struct which contains both the pid and the status makes it easier to write
132//and read the data into the pipe 132//and read the data into the pipe
133//especially this solves a problem which appeared on my box where slotDoHouseKeeping() received 133//especially this solves a problem which appeared on my box where slotDoHouseKeeping() received
134//only 4 bytes (with some debug output around the write()'s it received all 8 bytes) 134//only 4 bytes (with some debug output around the write()'s it received all 8 bytes)
135//don't know why this happened, but when writing all 8 bytes at once it works here, aleXXX 135//don't know why this happened, but when writing all 8 bytes at once it works here, aleXXX
136struct waitdata 136struct waitdata
137{ 137{
138 pid_t pid; 138 pid_t pid;
139 int status; 139 int status;
140}; 140};
141 141
142void OProcessController::theSigCHLDHandler(int arg) 142void OProcessController::theSigCHLDHandler(int arg)
143{ 143{
144 struct waitdata wd; 144 struct waitdata wd;
145 // int status; 145 // int status;
146 // pid_t this_pid; 146 // pid_t this_pid;
147 int saved_errno; 147 int saved_errno;
148 148
149 saved_errno = errno; 149 saved_errno = errno;
150 // since waitpid and write change errno, we have to save it and restore it 150 // since waitpid and write change errno, we have to save it and restore it
151 // (Richard Stevens, Advanced programming in the Unix Environment) 151 // (Richard Stevens, Advanced programming in the Unix Environment)
152 152
153 bool found = false; 153 bool found = false;
154 if( theOProcessController != 0 ) 154 if( theOProcessController != 0 )
155 { 155 {
156 // iterating the list doesn't perform any system call 156 // iterating the list doesn't perform any system call
157 for( QValueList<OProcess*>::ConstIterator it = theOProcessController->processList.begin(); 157 for( QValueList<OProcess*>::ConstIterator it = theOProcessController->processList.begin();
158 it != theOProcessController->processList.end(); 158 it != theOProcessController->processList.end();
159 ++it ) 159 ++it )
160 { 160 {
161 if( !(*it)->isRunning()) 161 if( !(*it)->isRunning())
162 continue; 162 continue;
163 wd.pid = waitpid( (*it)->pid(), &wd.status, WNOHANG ); 163 wd.pid = waitpid( (*it)->pid(), &wd.status, WNOHANG );
164 if ( wd.pid > 0 ) 164 if ( wd.pid > 0 )
165 { 165 {
166 ::write(theOProcessController->fd[1], &wd, sizeof(wd)); 166 ::write(theOProcessController->fd[1], &wd, sizeof(wd));
167 found = true; 167 found = true;
168 } 168 }
169 } 169 }
170 } 170 }
171 if( !found && oldChildHandlerData.sa_handler != SIG_IGN 171 if( !found && oldChildHandlerData.sa_handler != SIG_IGN
172 && oldChildHandlerData.sa_handler != SIG_DFL ) 172 && oldChildHandlerData.sa_handler != SIG_DFL )
diff --git a/libopie2/opiecore/oprocctrl.h b/libopie2/opiecore/oprocctrl.h
index 4922ba2..ea00859 100644
--- a/libopie2/opiecore/oprocctrl.h
+++ b/libopie2/opiecore/oprocctrl.h
@@ -1,129 +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 QSocketNotifier; 37class QSocketNotifier;
38 38
39 39
40namespace Opie { 40namespace Opie {
41namespace Core { 41namespace Core {
42namespace Private { 42namespace Internal {
43class OProcessControllerPrivate; 43class OProcessControllerPrivate;
44 44
45/** 45/**
46 * @short Used internally by @ref OProcess 46 * @short Used internally by @ref OProcess
47 * @internal 47 * @internal
48 * @author Christian Czezakte <e9025461@student.tuwien.ac.at> 48 * @author Christian Czezakte <e9025461@student.tuwien.ac.at>
49 * 49 *
50 * A class for internal use by OProcess only. -- Exactly one instance 50 * A class for internal use by OProcess only. -- Exactly one instance
51 * 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
52 * created (a pointer to it gets stored in @ref theOProcessController ). 52 * created (a pointer to it gets stored in @ref theOProcessController ).
53 * 53 *
54 * This class takes care of the actual (UN*X) signal handling. 54 * This class takes care of the actual (UN*X) signal handling.
55*/ 55*/
56class OProcessController : public QObject 56class OProcessController : public QObject
57{ 57{
58 Q_OBJECT 58 Q_OBJECT
59 59
60public: 60public:
61 OProcessController(); 61 OProcessController();
62 ~OProcessController(); 62 ~OProcessController();
63 //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...)
64 64
65public: 65public:
66 66
67 /** 67 /**
68 * 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,
69 * and this static variable is used to track the one instance. 69 * and this static variable is used to track the one instance.
70 */ 70 */
71 static OProcessController *theOProcessController; 71 static OProcessController *theOProcessController;
72 72
73 /** 73 /**
74 * Automatically called upon SIGCHLD. 74 * Automatically called upon SIGCHLD.
75 * 75 *
76 * 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
77 * if your application needs to disable SIGCHLD for some time for 77 * if your application needs to disable SIGCHLD for some time for
78 * reasons beyond your control, you should call this function afterwards 78 * reasons beyond your control, you should call this function afterwards
79 * to make sure that no SIGCHLDs where missed. 79 * to make sure that no SIGCHLDs where missed.
80 */ 80 */
81 static void theSigCHLDHandler(int signal); 81 static void theSigCHLDHandler(int signal);
82 // handler for sigchld 82 // handler for sigchld
83 83
84 /** 84 /**
85 * @internal 85 * @internal
86 */ 86 */
87 static void setupHandlers(); 87 static void setupHandlers();
88 /** 88 /**
89 * @internal 89 * @internal
90 */ 90 */
91 static void resetHandlers(); 91 static void resetHandlers();
92 /** 92 /**
93 * @internal 93 * @internal
94 */ 94 */
95 void addOProcess( OProcess* ); 95 void addOProcess( OProcess* );
96 /** 96 /**
97 * @internal 97 * @internal
98 */ 98 */
99 void removeOProcess( OProcess* ); 99 void removeOProcess( OProcess* );
100public slots: 100public slots:
101 /** 101 /**
102 * @internal 102 * @internal
103 */ 103 */
104 void slotDoHousekeeping(int socket); 104 void slotDoHousekeeping(int socket);
105 105
106private slots: 106private slots:
107 void delayedChildrenCleanup(); 107 void delayedChildrenCleanup();
108private: 108private:
109 int fd[2]; 109 int fd[2];
110 QSocketNotifier *notifier; 110 QSocketNotifier *notifier;
111 static struct sigaction oldChildHandlerData; 111 static struct sigaction oldChildHandlerData;
112 static bool handlerSet; 112 static bool handlerSet;
113 QValueList<OProcess*> processList; 113 QValueList<OProcess*> processList;
114 QTimer delayedChildrenCleanupTimer; 114 QTimer delayedChildrenCleanupTimer;
115 115
116 // Disallow assignment and copy-construction 116 // Disallow assignment and copy-construction
117 OProcessController( const OProcessController& ); 117 OProcessController( const OProcessController& );
118 OProcessController& operator= ( const OProcessController& ); 118 OProcessController& operator= ( const OProcessController& );
119 119
120 OProcessControllerPrivate *d; 120 OProcessControllerPrivate *d;
121}; 121};
122 122
123} 123}
124} 124}
125} 125}
126 126
127 127
128#endif 128#endif
129 129
diff --git a/libopie2/opiecore/oprocess.cpp b/libopie2/opiecore/oprocess.cpp
index dfde74a..b3f9724 100644
--- a/libopie2/opiecore/oprocess.cpp
+++ b/libopie2/opiecore/oprocess.cpp
@@ -1,196 +1,196 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3             Copyright (C) 2002-2004 Holger Freyther <zecke@handhelds.org> 3             Copyright (C) 2002-2004 Holger Freyther <zecke@handhelds.org>
4 and The Opie Team <opie-devel@handhelds.org> 4 and 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#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; 64using namespace Opie::Core::Internal;
65 65
66namespace Opie { 66namespace Opie {
67namespace Core { 67namespace Core {
68namespace Private { 68namespace Internal {
69class OProcessPrivate 69class OProcessPrivate
70{ 70{
71public: 71public:
72 OProcessPrivate() : useShell( false ) 72 OProcessPrivate() : useShell( false )
73 { } 73 { }
74 74
75 bool useShell; 75 bool useShell;
76 QMap<QString, QString> env; 76 QMap<QString, QString> env;
77 QString wd; 77 QString wd;
78 QCString shell; 78 QCString shell;
79}; 79};
80} 80}
81 81
82OProcess::OProcess( QObject *parent, const char *name ) 82OProcess::OProcess( QObject *parent, const char *name )
83 : QObject( parent, name ) 83 : QObject( parent, name )
84{ 84{
85 init ( ); 85 init ( );
86} 86}
87 87
88OProcess::OProcess( const QString &arg0, QObject *parent, const char *name ) 88OProcess::OProcess( const QString &arg0, QObject *parent, const char *name )
89 : QObject( parent, name ) 89 : QObject( parent, name )
90{ 90{
91 init ( ); 91 init ( );
92 *this << arg0; 92 *this << arg0;
93} 93}
94 94
95OProcess::OProcess( const QStringList &args, QObject *parent, const char *name ) 95OProcess::OProcess( const QStringList &args, QObject *parent, const char *name )
96 : QObject( parent, name ) 96 : QObject( parent, name )
97{ 97{
98 init ( ); 98 init ( );
99 *this << args; 99 *this << args;
100} 100}
101 101
102void OProcess::init ( ) 102void OProcess::init ( )
103{ 103{
104 run_mode = NotifyOnExit; 104 run_mode = NotifyOnExit;
105 runs = false; 105 runs = false;
106 pid_ = 0; 106 pid_ = 0;
107 status = 0; 107 status = 0;
108 keepPrivs = false; 108 keepPrivs = false;
109 innot = 0; 109 innot = 0;
110 outnot = 0; 110 outnot = 0;
111 errnot = 0; 111 errnot = 0;
112 communication = NoCommunication; 112 communication = NoCommunication;
113 input_data = 0; 113 input_data = 0;
114 input_sent = 0; 114 input_sent = 0;
115 input_total = 0; 115 input_total = 0;
116 d = 0; 116 d = 0;
117 117
118 if ( 0 == OProcessController::theOProcessController ) 118 if ( 0 == OProcessController::theOProcessController )
119 { 119 {
120 ( void ) new OProcessController(); 120 ( void ) new OProcessController();
121 CHECK_PTR( OProcessController::theOProcessController ); 121 CHECK_PTR( OProcessController::theOProcessController );
122 } 122 }
123 123
124 OProcessController::theOProcessController->addOProcess( this ); 124 OProcessController::theOProcessController->addOProcess( this );
125 out[ 0 ] = out[ 1 ] = -1; 125 out[ 0 ] = out[ 1 ] = -1;
126 in[ 0 ] = in[ 1 ] = -1; 126 in[ 0 ] = in[ 1 ] = -1;
127 err[ 0 ] = err[ 1 ] = -1; 127 err[ 0 ] = err[ 1 ] = -1;
128} 128}
129 129
130void OProcess::setEnvironment( const QString &name, const QString &value ) 130void OProcess::setEnvironment( const QString &name, const QString &value )
131{ 131{
132 if ( !d ) 132 if ( !d )
133 d = new OProcessPrivate; 133 d = new OProcessPrivate;
134 d->env.insert( name, value ); 134 d->env.insert( name, value );
135} 135}
136 136
137void OProcess::setWorkingDirectory( const QString &dir ) 137void OProcess::setWorkingDirectory( const QString &dir )
138{ 138{
139 if ( !d ) 139 if ( !d )
140 d = new OProcessPrivate; 140 d = new OProcessPrivate;
141 d->wd = dir; 141 d->wd = dir;
142} 142}
143 143
144void OProcess::setupEnvironment() 144void OProcess::setupEnvironment()
145{ 145{
146 if ( d ) 146 if ( d )
147 { 147 {
148 QMap<QString, QString>::Iterator it; 148 QMap<QString, QString>::Iterator it;
149 for ( it = d->env.begin(); it != d->env.end(); ++it ) 149 for ( it = d->env.begin(); it != d->env.end(); ++it )
150 setenv( QFile::encodeName( it.key() ).data(), 150 setenv( QFile::encodeName( it.key() ).data(),
151 QFile::encodeName( it.data() ).data(), 1 ); 151 QFile::encodeName( it.data() ).data(), 1 );
152 if ( !d->wd.isEmpty() ) 152 if ( !d->wd.isEmpty() )
153 chdir( QFile::encodeName( d->wd ).data() ); 153 chdir( QFile::encodeName( d->wd ).data() );
154 } 154 }
155} 155}
156 156
157void OProcess::setRunPrivileged( bool keepPrivileges ) 157void OProcess::setRunPrivileged( bool keepPrivileges )
158{ 158{
159 keepPrivs = keepPrivileges; 159 keepPrivs = keepPrivileges;
160} 160}
161 161
162bool OProcess::runPrivileged() const 162bool OProcess::runPrivileged() const
163{ 163{
164 return keepPrivs; 164 return keepPrivs;
165} 165}
166 166
167OProcess::~OProcess() 167OProcess::~OProcess()
168{ 168{
169 // destroying the OProcess instance sends a SIGKILL to the 169 // destroying the OProcess instance sends a SIGKILL to the
170 // child process (if it is running) after removing it from the 170 // child process (if it is running) after removing it from the
171 // list of valid processes (if the process is not started as 171 // list of valid processes (if the process is not started as
172 // "DontCare") 172 // "DontCare")
173 173
174 OProcessController::theOProcessController->removeOProcess( this ); 174 OProcessController::theOProcessController->removeOProcess( this );
175 // this must happen before we kill the child 175 // this must happen before we kill the child
176 // TODO: block the signal while removing the current process from the process list 176 // TODO: block the signal while removing the current process from the process list
177 177
178 if ( runs && ( run_mode != DontCare ) ) 178 if ( runs && ( run_mode != DontCare ) )
179 kill( SIGKILL ); 179 kill( SIGKILL );
180 180
181 // Clean up open fd's and socket notifiers. 181 // Clean up open fd's and socket notifiers.
182 closeStdin(); 182 closeStdin();
183 closeStdout(); 183 closeStdout();
184 closeStderr(); 184 closeStderr();
185 185
186 // TODO: restore SIGCHLD and SIGPIPE handler if this is the last OProcess 186 // TODO: restore SIGCHLD and SIGPIPE handler if this is the last OProcess
187 delete d; 187 delete d;
188} 188}
189 189
190void OProcess::detach() 190void OProcess::detach()
191{ 191{
192 OProcessController::theOProcessController->removeOProcess( this ); 192 OProcessController::theOProcessController->removeOProcess( this );
193 193
194 runs = false; 194 runs = false;
195 pid_ = 0; 195 pid_ = 0;
196 196
diff --git a/libopie2/opiecore/oprocess.h b/libopie2/opiecore/oprocess.h
index e23f98c..be1436c 100644
--- a/libopie2/opiecore/oprocess.h
+++ b/libopie2/opiecore/oprocess.h
@@ -1,177 +1,177 @@
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 46
47namespace Opie { 47namespace Opie {
48namespace Core { 48namespace Core {
49namespace Private { 49namespace Internal {
50class OProcessController; 50class OProcessController;
51class OProcessPrivate; 51class OProcessPrivate;
52} 52}
53 53
54/** 54/**
55 * Child process invocation, monitoring and control. 55 * Child process invocation, monitoring and control.
56 * 56 *
57 * @sect General usage and features 57 * @sect General usage and features
58 * 58 *
59 *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
60 *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.
61 * 61 *
62 *@see KProcIO 62 *@see KProcIO
63 * 63 *
64 *Basically, this class distinguishes three different ways of running 64 *Basically, this class distinguishes three different ways of running
65 *child processes: 65 *child processes:
66 * 66 *
67 *@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
68 *process and the parent process continue concurrently. 68 *process and the parent process continue concurrently.
69 * 69 *
70 *Starting a DontCare child process means that the application is 70 *Starting a DontCare child process means that the application is
71 *not interested in any notification to determine whether the 71 *not interested in any notification to determine whether the
72 *child process has already exited or not. 72 *child process has already exited or not.
73 * 73 *
74 *@li OProcess::NotifyOnExit -- The child process is invoked and both the 74 *@li OProcess::NotifyOnExit -- The child process is invoked and both the
75 *child and the parent process run concurrently. 75 *child and the parent process run concurrently.
76 * 76 *
77 *When the child process exits, the OProcess instance 77 *When the child process exits, the OProcess instance
78 *corresponding to it emits the Qt signal @ref processExited(). 78 *corresponding to it emits the Qt signal @ref processExited().
79 * 79 *
80 *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
81 *signal handler, arbitrary function calls can be made. 81 *signal handler, arbitrary function calls can be made.
82 * 82 *
83 *Be aware: When the OProcess objects gets destructed, the child 83 *Be aware: When the OProcess objects gets destructed, the child
84 *process will be killed if it is still running! 84 *process will be killed if it is still running!
85 *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
86 *with OProcess::NotifyOnExit. 86 *with OProcess::NotifyOnExit.
87 * 87 *
88 *@li OProcess::Block -- The child process starts and the parent process 88 *@li OProcess::Block -- The child process starts and the parent process
89 *is suspended until the child process exits. (@em Really not recommended 89 *is suspended until the child process exits. (@em Really not recommended
90 *for programs with a GUI.) 90 *for programs with a GUI.)
91 * 91 *
92 *OProcess also provides several functions for determining the exit status 92 *OProcess also provides several functions for determining the exit status
93 *and the pid of the child process it represents. 93 *and the pid of the child process it represents.
94 * 94 *
95 *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
96 *in a clean fashion (no null -- terminated stringlists and such...) 96 *in a clean fashion (no null -- terminated stringlists and such...)
97 * 97 *
98 *A small usage example: 98 *A small usage example:
99 *<pre> 99 *<pre>
100 *OProcess *proc = new OProcess; 100 *OProcess *proc = new OProcess;
101 * 101 *
102 **proc << "my_executable"; 102 **proc << "my_executable";
103 **proc << "These" << "are" << "the" << "command" << "line" << "args"; 103 **proc << "These" << "are" << "the" << "command" << "line" << "args";
104 *QApplication::connect(proc, SIGNAL(processExited(Opie::Core::OProcess *)), 104 *QApplication::connect(proc, SIGNAL(processExited(Opie::Core::OProcess *)),
105 * pointer_to_my_object, SLOT(my_objects_slot(Opie::Core::OProcess *))); 105 * pointer_to_my_object, SLOT(my_objects_slot(Opie::Core::OProcess *)));
106 *proc->start(); 106 *proc->start();
107 *</pre> 107 *</pre>
108 * 108 *
109 *This will start "my_executable" with the commandline arguments "These"... 109 *This will start "my_executable" with the commandline arguments "These"...
110 * 110 *
111 *When the child process exits, the respective Qt signal will be emitted. 111 *When the child process exits, the respective Qt signal will be emitted.
112 * 112 *
113 *@sect Communication with the child process 113 *@sect Communication with the child process
114 * 114 *
115 *OProcess supports communication with the child process through 115 *OProcess supports communication with the child process through
116 *stdin/stdout/stderr. 116 *stdin/stdout/stderr.
117 * 117 *
118 *The following functions are provided for getting data from the child 118 *The following functions are provided for getting data from the child
119 *process or sending data to the child's stdin (For more information, 119 *process or sending data to the child's stdin (For more information,
120 *have a look at the documentation of each function): 120 *have a look at the documentation of each function):
121 * 121 *
122 *@li bool @ref writeStdin(char *buffer, int buflen); 122 *@li bool @ref writeStdin(char *buffer, int buflen);
123 *@li -- Transmit data to the child process's stdin. 123 *@li -- Transmit data to the child process's stdin.
124 * 124 *
125 *@li bool @ref closeStdin(); 125 *@li bool @ref closeStdin();
126 *@li -- Closes the child process's stdin (which causes it to see an feof(stdin)). 126 *@li -- Closes the child process's stdin (which causes it to see an feof(stdin)).
127 *Returns false if you try to close stdin for a process that has been started 127 *Returns false if you try to close stdin for a process that has been started
128 *without a communication channel to stdin. 128 *without a communication channel to stdin.
129 * 129 *
130 *@li bool @ref closeStdout(); 130 *@li bool @ref closeStdout();
131 *@li -- Closes the child process's stdout. 131 *@li -- Closes the child process's stdout.
132 *Returns false if you try to close stdout for a process that has been started 132 *Returns false if you try to close stdout for a process that has been started
133 *without a communication channel to stdout. 133 *without a communication channel to stdout.
134 * 134 *
135 *@li bool @ref closeStderr(); 135 *@li bool @ref closeStderr();
136 *@li -- Closes the child process's stderr. 136 *@li -- Closes the child process's stderr.
137 *Returns false if you try to close stderr for a process that has been started 137 *Returns false if you try to close stderr for a process that has been started
138 *without a communication channel to stderr. 138 *without a communication channel to stderr.
139 * 139 *
140 * 140 *
141 *@sect QT signals: 141 *@sect QT signals:
142 * 142 *
143 *@li void @ref receivedStdout(OProcess *proc, char *buffer, int buflen); 143 *@li void @ref receivedStdout(OProcess *proc, char *buffer, int buflen);
144 *@li void @ref receivedStderr(OProcess *proc, char *buffer, int buflen); 144 *@li void @ref receivedStderr(OProcess *proc, char *buffer, int buflen);
145 *@li -- Indicates that new data has arrived from either the 145 *@li -- Indicates that new data has arrived from either the
146 *child process's stdout or stderr. 146 *child process's stdout or stderr.
147 * 147 *
148 *@li void @ref wroteStdin(OProcess *proc); 148 *@li void @ref wroteStdin(OProcess *proc);
149 *@li -- Indicates that all data that has been sent to the child process 149 *@li -- Indicates that all data that has been sent to the child process
150 *by a prior call to @ref writeStdin() has actually been transmitted to the 150 *by a prior call to @ref writeStdin() has actually been transmitted to the
151 *client . 151 *client .
152 * 152 *
153 *@author Christian Czezakte e9025461@student.tuwien.ac.at 153 *@author Christian Czezakte e9025461@student.tuwien.ac.at
154 *@author Holger Freyther (Opie Port) 154 *@author Holger Freyther (Opie Port)
155 * 155 *
156 **/ 156 **/
157class OProcess : public QObject 157class OProcess : public QObject
158{ 158{
159 Q_OBJECT 159 Q_OBJECT
160 160
161public: 161public:
162 162
163 /** 163 /**
164 * Modes in which the communication channel can be opened. 164 * Modes in which the communication channel can be opened.
165 * 165 *
166 * If communication for more than one channel is required, 166 * If communication for more than one channel is required,
167 * the values have to be or'ed together, for example to get 167 * the values have to be or'ed together, for example to get
168 * communication with stdout as well as with stdin, you would 168 * communication with stdout as well as with stdin, you would
169 * specify @p Stdin @p | @p Stdout 169 * specify @p Stdin @p | @p Stdout
170 * 170 *
171 * If @p NoRead is specified in conjunction with @p Stdout, 171 * If @p NoRead is specified in conjunction with @p Stdout,
172 * no data is actually read from @p Stdout but only 172 * no data is actually read from @p Stdout but only
173 * the signal @ref childOutput(int fd) is emitted. 173 * the signal @ref childOutput(int fd) is emitted.
174 */ 174 */
175 enum Communication { NoCommunication = 0, Stdin = 1, Stdout = 2, Stderr = 4, 175 enum Communication { NoCommunication = 0, Stdin = 1, Stdout = 2, Stderr = 4,
176 AllOutput = 6, All = 7, 176 AllOutput = 6, All = 7,
177 NoRead }; 177 NoRead };
@@ -598,164 +598,164 @@ protected:
598 * later versions of OProcess. 598 * later versions of OProcess.
599 */ 599 */
600 pid_t pid_; 600 pid_t pid_;
601 601
602 /** 602 /**
603 * The process' exit status as returned by "waitpid". You should not 603 * The process' exit status as returned by "waitpid". You should not
604 * modify the value of this data member from derived classes. You should 604 * modify the value of this data member from derived classes. You should
605 * rather use @ref exitStatus than accessing this data member directly 605 * rather use @ref exitStatus than accessing this data member directly
606 * since it will probably be made private in further versions of 606 * since it will probably be made private in further versions of
607 * OProcess. 607 * OProcess.
608 */ 608 */
609 int status; 609 int status;
610 610
611 611
612 /** 612 /**
613 * See setRunPrivileged() 613 * See setRunPrivileged()
614 */ 614 */
615 bool keepPrivs; 615 bool keepPrivs;
616 616
617 /* 617 /*
618 Functions for setting up the sockets for communication. 618 Functions for setting up the sockets for communication.
619 setupCommunication 619 setupCommunication
620 -- is called from "start" before "fork"ing. 620 -- is called from "start" before "fork"ing.
621 commSetupDoneP 621 commSetupDoneP
622 -- completes communication socket setup in the parent 622 -- completes communication socket setup in the parent
623 commSetupDoneC 623 commSetupDoneC
624 -- completes communication setup in the child process 624 -- completes communication setup in the child process
625 commClose 625 commClose
626 -- frees all allocated communication resources in the parent 626 -- frees all allocated communication resources in the parent
627 after the process has exited 627 after the process has exited
628 */ 628 */
629 629
630 /** 630 /**
631 * This function is called from "OProcess::start" right before a "fork" takes 631 * This function is called from "OProcess::start" right before a "fork" takes
632 * place. According to 632 * place. According to
633 * the "comm" parameter this function has to initialize the "in", "out" and 633 * the "comm" parameter this function has to initialize the "in", "out" and
634 * "err" data member of OProcess. 634 * "err" data member of OProcess.
635 * 635 *
636 * This function should return 0 if setting the needed communication channels 636 * This function should return 0 if setting the needed communication channels
637 * was successful. 637 * was successful.
638 * 638 *
639 * The default implementation is to create UNIX STREAM sockets for the communication, 639 * The default implementation is to create UNIX STREAM sockets for the communication,
640 * but you could overload this function and establish a TCP/IP communication for 640 * but you could overload this function and establish a TCP/IP communication for
641 * network communication, for example. 641 * network communication, for example.
642 */ 642 */
643 virtual int setupCommunication( Communication comm ); 643 virtual int setupCommunication( Communication comm );
644 644
645 /** 645 /**
646 * Called right after a (successful) fork on the parent side. This function 646 * Called right after a (successful) fork on the parent side. This function
647 * will usually do some communications cleanup, like closing the reading end 647 * will usually do some communications cleanup, like closing the reading end
648 * of the "stdin" communication channel. 648 * of the "stdin" communication channel.
649 * 649 *
650 * Furthermore, it must also create the QSocketNotifiers "innot", "outnot" and 650 * Furthermore, it must also create the QSocketNotifiers "innot", "outnot" and
651 * "errnot" and connect their Qt slots to the respective OProcess member functions. 651 * "errnot" and connect their Qt slots to the respective OProcess member functions.
652 * 652 *
653 * For a more detailed explanation, it is best to have a look at the default 653 * For a more detailed explanation, it is best to have a look at the default
654 * implementation of "setupCommunication" in kprocess.cpp. 654 * implementation of "setupCommunication" in kprocess.cpp.
655 */ 655 */
656 virtual int commSetupDoneP(); 656 virtual int commSetupDoneP();
657 657
658 /** 658 /**
659 * Called right after a (successful) fork, but before an "exec" on the child 659 * Called right after a (successful) fork, but before an "exec" on the child
660 * process' side. It usually just closes the unused communication ends of 660 * process' side. It usually just closes the unused communication ends of
661 * "in", "out" and "err" (like the writing end of the "in" communication 661 * "in", "out" and "err" (like the writing end of the "in" communication
662 * channel. 662 * channel.
663 */ 663 */
664 virtual int commSetupDoneC(); 664 virtual int commSetupDoneC();
665 665
666 666
667 /** 667 /**
668 * Immediately called after a process has exited. This function normally 668 * Immediately called after a process has exited. This function normally
669 * calls commClose to close all open communication channels to this 669 * calls commClose to close all open communication channels to this
670 * process and emits the "processExited" signal (if the process was 670 * process and emits the "processExited" signal (if the process was
671 * not running in the "DontCare" mode). 671 * not running in the "DontCare" mode).
672 */ 672 */
673 virtual void processHasExited( int state ); 673 virtual void processHasExited( int state );
674 674
675 /** 675 /**
676 * Should clean up the communication links to the child after it has 676 * Should clean up the communication links to the child after it has
677 * exited. Should be called from "processHasExited". 677 * exited. Should be called from "processHasExited".
678 */ 678 */
679 virtual void commClose(); 679 virtual void commClose();
680 680
681 681
682 /** 682 /**
683 * the socket descriptors for stdin/stdout/stderr. 683 * the socket descriptors for stdin/stdout/stderr.
684 */ 684 */
685 int out[ 2 ]; 685 int out[ 2 ];
686 int in[ 2 ]; 686 int in[ 2 ];
687 int err[ 2 ]; 687 int err[ 2 ];
688 688
689 /** 689 /**
690 * The socket notifiers for the above socket descriptors. 690 * The socket notifiers for the above socket descriptors.
691 */ 691 */
692 QSocketNotifier *innot; 692 QSocketNotifier *innot;
693 QSocketNotifier *outnot; 693 QSocketNotifier *outnot;
694 QSocketNotifier *errnot; 694 QSocketNotifier *errnot;
695 695
696 /** 696 /**
697 * Lists the communication links that are activated for the child 697 * Lists the communication links that are activated for the child
698 * process. Should not be modified from derived classes. 698 * process. Should not be modified from derived classes.
699 */ 699 */
700 Communication communication; 700 Communication communication;
701 701
702 /** 702 /**
703 * Called by "slotChildOutput" this function copies data arriving from the 703 * Called by "slotChildOutput" this function copies data arriving from the
704 * 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
705 * "@ref receivedStderr". 705 * "@ref receivedStderr".
706 */ 706 */
707 int childOutput( int fdno ); 707 int childOutput( int fdno );
708 708
709 /** 709 /**
710 * Called by "slotChildOutput" this function copies data arriving from the 710 * Called by "slotChildOutput" this function copies data arriving from the
711 * 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
712 * "@ref receivedStderr" 712 * "@ref receivedStderr"
713 */ 713 */
714 int childError( int fdno ); 714 int childError( int fdno );
715 715
716 // 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:
717 717
718 const char *input_data; // the buffer holding the data 718 const char *input_data; // the buffer holding the data
719 int input_sent; // # of bytes already transmitted 719 int input_sent; // # of bytes already transmitted
720 int input_total; // total length of input_data 720 int input_total; // total length of input_data
721 721
722 /** 722 /**
723 * @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
724 * access to various data members. 724 * access to various data members.
725 */ 725 */
726 friend class Private::OProcessController; 726 friend class Internal::OProcessController;
727 727
728private: 728private:
729 /** 729 /**
730 * Searches for a valid shell. 730 * Searches for a valid shell.
731 * Here is the algorithm used for finding an executable shell: 731 * Here is the algorithm used for finding an executable shell:
732 * 732 *
733 * @li Try the executable pointed to by the "SHELL" environment 733 * @li Try the executable pointed to by the "SHELL" environment
734 * variable with white spaces stripped off 734 * variable with white spaces stripped off
735 * 735 *
736 * @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
737 * not listed in /etc/shells will not used. 737 * not listed in /etc/shells will not used.
738 * 738 *
739 * @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.
740 */ 740 */
741 QCString searchShell(); 741 QCString searchShell();
742 742
743 /** 743 /**
744 * 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
745 * is actually executable at all. 745 * is actually executable at all.
746 */ 746 */
747 bool isExecutable( const QCString &filename ); 747 bool isExecutable( const QCString &filename );
748 748
749 // Disallow assignment and copy-construction 749 // Disallow assignment and copy-construction
750 OProcess( const OProcess& ); 750 OProcess( const OProcess& );
751 OProcess& operator= ( const OProcess& ); 751 OProcess& operator= ( const OProcess& );
752 752
753private: 753private:
754 void init ( ); 754 void init ( );
755 Private::OProcessPrivate *d; 755 Internal::OProcessPrivate *d;
756}; 756};
757} 757}
758} 758}
759 759
760#endif 760#endif
761 761
diff --git a/libopie2/opiedb/osqlitedriver.cpp b/libopie2/opiedb/osqlitedriver.cpp
index 47bc250..2c53248 100644
--- a/libopie2/opiedb/osqlitedriver.cpp
+++ b/libopie2/opiedb/osqlitedriver.cpp
@@ -1,172 +1,172 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
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 30
31#include "osqlquery.h" 31#include "osqlquery.h"
32#include "osqlitedriver.h" 32#include "osqlitedriver.h"
33 33
34#include <opie2/odebug.h> 34#include <opie2/odebug.h>
35 35
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38// fromLocal8Bit() does not work as expected. Thus it 38// fromLocal8Bit() does not work as expected. Thus it
39// is replaced by fromLatin1() (eilers) 39// is replaced by fromLatin1() (eilers)
40#define __BUGGY_LOCAL8BIT_ 40#define __BUGGY_LOCAL8BIT_
41 41
42 42
43using namespace Opie::DB; 43using namespace Opie::DB;
44using namespace Opie::DB::Private; 44using namespace Opie::DB::Internal;
45 45
46namespace { 46namespace {
47 struct Query { 47 struct Query {
48 OSQLError::ValueList errors; 48 OSQLError::ValueList errors;
49 OSQLResultItem::ValueList items; 49 OSQLResultItem::ValueList items;
50 OSQLiteDriver *driver; 50 OSQLiteDriver *driver;
51 }; 51 };
52} 52}
53 53
54 54
55OSQLiteDriver::OSQLiteDriver( QLibrary *lib ) 55OSQLiteDriver::OSQLiteDriver( QLibrary *lib )
56 : OSQLDriver( lib ) 56 : OSQLDriver( lib )
57{ 57{
58 m_sqlite = 0l; 58 m_sqlite = 0l;
59} 59}
60 60
61 61
62OSQLiteDriver::~OSQLiteDriver() { 62OSQLiteDriver::~OSQLiteDriver() {
63 close(); 63 close();
64} 64}
65 65
66 66
67QString OSQLiteDriver::id()const { 67QString OSQLiteDriver::id()const {
68 return QString::fromLatin1("SQLite"); 68 return QString::fromLatin1("SQLite");
69} 69}
70 70
71void OSQLiteDriver::setUserName( const QString& ) {} 71void OSQLiteDriver::setUserName( const QString& ) {}
72 72
73 73
74void OSQLiteDriver::setPassword( const QString& ) {} 74void OSQLiteDriver::setPassword( const QString& ) {}
75 75
76 76
77void OSQLiteDriver::setUrl( const QString& url ) { 77void OSQLiteDriver::setUrl( const QString& url ) {
78 m_url = url; 78 m_url = url;
79} 79}
80 80
81 81
82void OSQLiteDriver::setOptions( const QStringList& ) { 82void OSQLiteDriver::setOptions( const QStringList& ) {
83} 83}
84 84
85 85
86/* 86/*
87 * try to open a db specified via setUrl 87 * try to open a db specified via setUrl
88 * and options 88 * and options
89 */ 89 */
90bool OSQLiteDriver::open() { 90bool OSQLiteDriver::open() {
91 char *error; 91 char *error;
92 qDebug("OSQLiteDriver::open: about to open"); 92 qDebug("OSQLiteDriver::open: about to open");
93 m_sqlite = sqlite_open(m_url.local8Bit(), 93 m_sqlite = sqlite_open(m_url.local8Bit(),
94 0, 94 0,
95 &error ); 95 &error );
96 96
97 /* failed to open */ 97 /* failed to open */
98 if (m_sqlite == 0l ) { 98 if (m_sqlite == 0l ) {
99 // FIXME set the last error 99 // FIXME set the last error
100 qWarning("OSQLiteDriver::open: %s", error ); 100 qWarning("OSQLiteDriver::open: %s", error );
101 free( error ); 101 free( error );
102 return false; 102 return false;
103 } 103 }
104 return true; 104 return true;
105} 105}
106 106
107 107
108/* close the db 108/* close the db
109 * sqlite closes them without 109 * sqlite closes them without
110 * telling failure or success 110 * telling failure or success
111 */ 111 */
112bool OSQLiteDriver::close() { 112bool OSQLiteDriver::close() {
113 if (m_sqlite ) 113 if (m_sqlite )
114 sqlite_close( m_sqlite ), m_sqlite=0l; 114 sqlite_close( m_sqlite ), m_sqlite=0l;
115 115
116 return true; 116 return true;
117} 117}
118 118
119 119
120/* Query */ 120/* Query */
121OSQLResult OSQLiteDriver::query( OSQLQuery* qu) { 121OSQLResult OSQLiteDriver::query( OSQLQuery* qu) {
122 if ( !m_sqlite ) { 122 if ( !m_sqlite ) {
123 // FIXME set error code 123 // FIXME set error code
124 OSQLResult result( OSQLResult::Failure ); 124 OSQLResult result( OSQLResult::Failure );
125 return result; 125 return result;
126 } 126 }
127 Query query; 127 Query query;
128 query.driver = this; 128 query.driver = this;
129 char *err; 129 char *err;
130 /* SQLITE_OK 0 if return code > 0 == failure */ 130 /* SQLITE_OK 0 if return code > 0 == failure */
131 if ( sqlite_exec(m_sqlite, qu->query(),&call_back, &query, &err) > 0 ) { 131 if ( sqlite_exec(m_sqlite, qu->query(),&call_back, &query, &err) > 0 ) {
132 qWarning("OSQLiteDriver::query: Error while executing"); 132 qWarning("OSQLiteDriver::query: Error while executing");
133 free(err ); 133 free(err );
134 // FixMe Errors 134 // FixMe Errors
135 } 135 }
136 136
137 OSQLResult result(OSQLResult::Success, 137 OSQLResult result(OSQLResult::Success,
138 query.items, 138 query.items,
139 query.errors ); 139 query.errors );
140 return result; 140 return result;
141} 141}
142 142
143 143
144OSQLTable::ValueList OSQLiteDriver::tables() const { 144OSQLTable::ValueList OSQLiteDriver::tables() const {
145 145
146} 146}
147 147
148 148
149OSQLError OSQLiteDriver::lastError() { 149OSQLError OSQLiteDriver::lastError() {
150 OSQLError error; 150 OSQLError error;
151 return error; 151 return error;
152}; 152};
153 153
154 154
155/* handle a callback add the row to the global 155/* handle a callback add the row to the global
156 * OSQLResultItem 156 * OSQLResultItem
157 */ 157 */
158int OSQLiteDriver::handleCallBack( int, char**, char** ) { 158int OSQLiteDriver::handleCallBack( int, char**, char** ) {
159 return 0; 159 return 0;
160} 160}
161 161
162 162
163/* callback_handler add the values to the list*/ 163/* callback_handler add the values to the list*/
164int OSQLiteDriver::call_back( void* voi, int argc, 164int OSQLiteDriver::call_back( void* voi, int argc,
165 char** argv, char** columns) { 165 char** argv, char** columns) {
166 Query* qu = (Query*)voi; 166 Query* qu = (Query*)voi;
167 167
168 //copy them over to a OSQLResultItem 168 //copy them over to a OSQLResultItem
169 QMap<QString, QString> tableString; 169 QMap<QString, QString> tableString;
170 QMap<int, QString> tableInt; 170 QMap<int, QString> tableInt;
171 for (int i = 0; i < argc; i++ ) { 171 for (int i = 0; i < argc; i++ ) {
172 172
diff --git a/libopie2/opiedb/osqlitedriver.h b/libopie2/opiedb/osqlitedriver.h
index 3e1325b..9064e52 100644
--- a/libopie2/opiedb/osqlitedriver.h
+++ b/libopie2/opiedb/osqlitedriver.h
@@ -1,42 +1,42 @@
1#ifndef OSQL_LITE_DRIVER_H 1#ifndef OSQL_LITE_DRIVER_H
2#define OSQL_LITE_DRIVER_H 2#define OSQL_LITE_DRIVER_H
3 3
4#include <sqlite.h> 4#include <sqlite.h>
5 5
6#include "osqldriver.h" 6#include "osqldriver.h"
7#include "osqlerror.h" 7#include "osqlerror.h"
8#include "osqlresult.h" 8#include "osqlresult.h"
9 9
10namespace Opie { 10namespace Opie {
11namespace DB { 11namespace DB {
12namespace Private { 12namespace Internal {
13 13
14class OSQLiteDriver : public OSQLDriver { 14class OSQLiteDriver : public OSQLDriver {
15 Q_OBJECT 15 Q_OBJECT
16public: 16public:
17 OSQLiteDriver( QLibrary *lib = 0l ); 17 OSQLiteDriver( QLibrary *lib = 0l );
18 ~OSQLiteDriver(); 18 ~OSQLiteDriver();
19 QString id()const; 19 QString id()const;
20 void setUserName( const QString& ); 20 void setUserName( const QString& );
21 void setPassword( const QString& ); 21 void setPassword( const QString& );
22 void setUrl( const QString& url ); 22 void setUrl( const QString& url );
23 void setOptions( const QStringList& ); 23 void setOptions( const QStringList& );
24 bool open(); 24 bool open();
25 bool close(); 25 bool close();
26 OSQLError lastError(); 26 OSQLError lastError();
27 OSQLResult query( OSQLQuery* ); 27 OSQLResult query( OSQLQuery* );
28 OSQLTable::ValueList tables()const; 28 OSQLTable::ValueList tables()const;
29private: 29private:
30 OSQLError m_lastE; 30 OSQLError m_lastE;
31 OSQLResult m_result; 31 OSQLResult m_result;
32 OSQLResultItem m_items; 32 OSQLResultItem m_items;
33 int handleCallBack( int, char**, char** ); 33 int handleCallBack( int, char**, char** );
34 static int call_back( void*, int, char**, char** ); 34 static int call_back( void*, int, char**, char** );
35 QString m_url; 35 QString m_url;
36 sqlite *m_sqlite; 36 sqlite *m_sqlite;
37}; 37};
38} 38}
39} 39}
40} 40}
41 41
42#endif 42#endif
diff --git a/libopie2/opiedb/osqlmanager.cpp b/libopie2/opiedb/osqlmanager.cpp
index 990d258..a6498df 100644
--- a/libopie2/opiedb/osqlmanager.cpp
+++ b/libopie2/opiedb/osqlmanager.cpp
@@ -1,83 +1,83 @@
1 1
2#include <stdlib.h> 2#include <stdlib.h>
3 3
4#include "osqlmanager.h" 4#include "osqlmanager.h"
5#include "osqlbackendmanager.h" 5#include "osqlbackendmanager.h"
6#include "osqlitedriver.h" 6#include "osqlitedriver.h"
7 7
8using namespace Opie::DB; 8using namespace Opie::DB;
9 9
10OSQLManager::OSQLManager() { 10OSQLManager::OSQLManager() {
11} 11}
12OSQLBackEnd::ValueList OSQLManager::queryBackEnd() { 12OSQLBackEnd::ValueList OSQLManager::queryBackEnd() {
13 m_list.clear(); 13 m_list.clear();
14 QString opie = QString::fromLatin1( getenv("OPIEDIR") ); 14 QString opie = QString::fromLatin1( getenv("OPIEDIR") );
15 QString qpe = QString::fromLatin1( getenv("QPEDIR") ); 15 QString qpe = QString::fromLatin1( getenv("QPEDIR") );
16 16
17 if ( !m_path.contains(opie) && !opie.isEmpty() ) 17 if ( !m_path.contains(opie) && !opie.isEmpty() )
18 m_path << opie; 18 m_path << opie;
19 if ( !m_path.contains(qpe) && !qpe.isEmpty() ) 19 if ( !m_path.contains(qpe) && !qpe.isEmpty() )
20 m_path << qpe; 20 m_path << qpe;
21 21
22 OSQLBackEndManager mng( m_path ); 22 OSQLBackEndManager mng( m_path );
23 m_list = mng.scan(); 23 m_list = mng.scan();
24 m_list += builtIn(); 24 m_list += builtIn();
25 25
26 return m_list; 26 return m_list;
27} 27}
28/* 28/*
29 * loading dso's is currently not enabled due problems with QLibrary 29 * loading dso's is currently not enabled due problems with QLibrary
30 * beeing in libqpe and not libqte 30 * beeing in libqpe and not libqte
31 */ 31 */
32OSQLDriver* OSQLManager::load( const QString& name ) { 32OSQLDriver* OSQLManager::load( const QString& name ) {
33 OSQLDriver* driver = 0l; 33 OSQLDriver* driver = 0l;
34 34
35 if ( name == "SQLite" ) { 35 if ( name == "SQLite" ) {
36 driver = new Opie::DB::Private::OSQLiteDriver; 36 driver = new Opie::DB::Internal::OSQLiteDriver;
37 } 37 }
38 return driver; 38 return driver;
39} 39}
40/* 40/*
41 * same as above 41 * same as above
42 */ 42 */
43OSQLDriver* OSQLManager::load( const OSQLBackEnd& end) { 43OSQLDriver* OSQLManager::load( const OSQLBackEnd& end) {
44 OSQLDriver *driver = 0l; 44 OSQLDriver *driver = 0l;
45 if ( end.library() == "builtin" && 45 if ( end.library() == "builtin" &&
46 end.name() == "SQLite" ) 46 end.name() == "SQLite" )
47 driver = new Opie::DB::Private::OSQLiteDriver; 47 driver = new Opie::DB::Internal::OSQLiteDriver;
48 48
49 return driver; 49 return driver;
50} 50}
51/* 51/*
52 * let's find the a default with the highes preference 52 * let's find the a default with the highes preference
53 */ 53 */
54OSQLDriver* OSQLManager::standard() { 54OSQLDriver* OSQLManager::standard() {
55 OSQLDriver* driver =0l; 55 OSQLDriver* driver =0l;
56 if ( m_list.isEmpty() ) queryBackEnd(); 56 if ( m_list.isEmpty() ) queryBackEnd();
57 OSQLBackEnd::ValueList::Iterator it; 57 OSQLBackEnd::ValueList::Iterator it;
58 OSQLBackEnd back; 58 OSQLBackEnd back;
59 for ( it = m_list.begin(); it != m_list.end(); ++it ) { 59 for ( it = m_list.begin(); it != m_list.end(); ++it ) {
60 if ( (*it).isDefault() && 60 if ( (*it).isDefault() &&
61 back.preference() < (*it).preference() ) { 61 back.preference() < (*it).preference() ) {
62 back = (*it); 62 back = (*it);
63 } 63 }
64 } 64 }
65 driver = load( back ); 65 driver = load( back );
66 return driver; 66 return driver;
67} 67}
68void OSQLManager::registerPath( const QString& path ) { 68void OSQLManager::registerPath( const QString& path ) {
69 m_path << path; 69 m_path << path;
70} 70}
71bool OSQLManager::unregisterPath( const QString& path ) { 71bool OSQLManager::unregisterPath( const QString& path ) {
72 m_path.remove( path ); 72 m_path.remove( path );
73 return true; 73 return true;
74} 74}
75OSQLBackEnd::ValueList OSQLManager::builtIn()const { 75OSQLBackEnd::ValueList OSQLManager::builtIn()const {
76 OSQLBackEnd::ValueList list; 76 OSQLBackEnd::ValueList list;
77 // create the OSQLiteBackend 77 // create the OSQLiteBackend
78 OSQLBackEnd back("SQLite","Opie e.V.","GPL", "builtin" ); 78 OSQLBackEnd back("SQLite","Opie e.V.","GPL", "builtin" );
79 back.setDefault( true ); 79 back.setDefault( true );
80 back.setPreference( 50 ); 80 back.setPreference( 50 );
81 list.append( back ); 81 list.append( back );
82 return list; 82 return list;
83} 83}
diff --git a/libopie2/opienet/odebugmapper.cpp b/libopie2/opienet/odebugmapper.cpp
index f679afb..0de1247 100644
--- a/libopie2/opienet/odebugmapper.cpp
+++ b/libopie2/opienet/odebugmapper.cpp
@@ -1,142 +1,142 @@
1 1
2/* 2/*
3 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> 3 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
4 */ 4 */
5 5
6#include <opie2/odebug.h> 6#include <opie2/odebug.h>
7 7
8#include "odebugmapper.h" 8#include "odebugmapper.h"
9 9
10using namespace Opie::Core; 10using namespace Opie::Core;
11 11
12namespace Opie { 12namespace Opie {
13namespace Net { 13namespace Net {
14namespace Private { 14namespace Internal {
15 15
16DebugMapper::DebugMapper() 16DebugMapper::DebugMapper()
17{ 17{
18 odebug << "DebugMapper::DebugMapper()" << oendl; 18 odebug << "DebugMapper::DebugMapper()" << oendl;
19 19
20 20
21 _map.insert( 0x8902, new QString("SIOCSPGRP") ); 21 _map.insert( 0x8902, new QString("SIOCSPGRP") );
22 _map.insert( 0x8904, new QString("SIOCGPGRP") ); 22 _map.insert( 0x8904, new QString("SIOCGPGRP") );
23 _map.insert( 0x8905, new QString("SIOCATMARK") ); 23 _map.insert( 0x8905, new QString("SIOCATMARK") );
24 _map.insert( 0x8906, new QString("SIOCGSTAMP") ); 24 _map.insert( 0x8906, new QString("SIOCGSTAMP") );
25 _map.insert( 0x890B, new QString("SIOCADDRT") ); 25 _map.insert( 0x890B, new QString("SIOCADDRT") );
26 _map.insert( 0x890C, new QString("SIOCDELRT") ); 26 _map.insert( 0x890C, new QString("SIOCDELRT") );
27 _map.insert( 0x890D, new QString("SIOCRTMSG") ); 27 _map.insert( 0x890D, new QString("SIOCRTMSG") );
28 _map.insert( 0x8910, new QString("SIOCGIFNAME") ); 28 _map.insert( 0x8910, new QString("SIOCGIFNAME") );
29 _map.insert( 0x8911, new QString("SIOCSIFLINK") ); 29 _map.insert( 0x8911, new QString("SIOCSIFLINK") );
30 _map.insert( 0x8912, new QString("SIOCGIFCONF") ); 30 _map.insert( 0x8912, new QString("SIOCGIFCONF") );
31 _map.insert( 0x8913, new QString("SIOCGIFFLAGS") ); 31 _map.insert( 0x8913, new QString("SIOCGIFFLAGS") );
32 _map.insert( 0x8914, new QString("SIOCSIFFLAGS") ); 32 _map.insert( 0x8914, new QString("SIOCSIFFLAGS") );
33 _map.insert( 0x8915, new QString("SIOCGIFADDR") ); 33 _map.insert( 0x8915, new QString("SIOCGIFADDR") );
34 _map.insert( 0x8916, new QString("SIOCSIFADDR") ); 34 _map.insert( 0x8916, new QString("SIOCSIFADDR") );
35 _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") ); 35 _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") );
36 _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") ); 36 _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") );
37 _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") ); 37 _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") );
38 _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") ); 38 _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") );
39 _map.insert( 0x891b, new QString("SIOCGIFNETMASK") ); 39 _map.insert( 0x891b, new QString("SIOCGIFNETMASK") );
40 _map.insert( 0x891c, new QString("SIOCSIFNETMASK") ); 40 _map.insert( 0x891c, new QString("SIOCSIFNETMASK") );
41 _map.insert( 0x891d, new QString("SIOCGIFMETRIC") ); 41 _map.insert( 0x891d, new QString("SIOCGIFMETRIC") );
42 _map.insert( 0x891e, new QString("SIOCSIFMETRIC") ); 42 _map.insert( 0x891e, new QString("SIOCSIFMETRIC") );
43 _map.insert( 0x891f, new QString("SIOCGIFMEM") ); 43 _map.insert( 0x891f, new QString("SIOCGIFMEM") );
44 _map.insert( 0x8920, new QString("SIOCSIFMEM") ); 44 _map.insert( 0x8920, new QString("SIOCSIFMEM") );
45 _map.insert( 0x8921, new QString("SIOCGIFMTU") ); 45 _map.insert( 0x8921, new QString("SIOCGIFMTU") );
46 _map.insert( 0x8922, new QString("SIOCSIFMTU") ); 46 _map.insert( 0x8922, new QString("SIOCSIFMTU") );
47 _map.insert( 0x8923, new QString("SIOCSIFNAME") ); 47 _map.insert( 0x8923, new QString("SIOCSIFNAME") );
48 _map.insert( 0x8924, new QString("SIOCSIFHWADDR") ); 48 _map.insert( 0x8924, new QString("SIOCSIFHWADDR") );
49 _map.insert( 0x8925, new QString("SIOCGIFENCAP") ); 49 _map.insert( 0x8925, new QString("SIOCGIFENCAP") );
50 _map.insert( 0x8926, new QString("SIOCSIFENCAP") ); 50 _map.insert( 0x8926, new QString("SIOCSIFENCAP") );
51 _map.insert( 0x8927, new QString("SIOCGIFHWADDR") ); 51 _map.insert( 0x8927, new QString("SIOCGIFHWADDR") );
52 _map.insert( 0x8929, new QString("SIOCGIFSLAVE") ); 52 _map.insert( 0x8929, new QString("SIOCGIFSLAVE") );
53 _map.insert( 0x8930, new QString("SIOCSIFSLAVE") ); 53 _map.insert( 0x8930, new QString("SIOCSIFSLAVE") );
54 _map.insert( 0x8931, new QString("SIOCADDMULTI") ); 54 _map.insert( 0x8931, new QString("SIOCADDMULTI") );
55 _map.insert( 0x8932, new QString("SIOCDELMULTI") ); 55 _map.insert( 0x8932, new QString("SIOCDELMULTI") );
56 _map.insert( 0x8933, new QString("SIOCGIFINDEX") ); 56 _map.insert( 0x8933, new QString("SIOCGIFINDEX") );
57 _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") ); 57 _map.insert( 0x8934, new QString("SIOCSIFPFLAGS") );
58 _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") ); 58 _map.insert( 0x8935, new QString("SIOCGIFPFLAGS") );
59 _map.insert( 0x8936, new QString("SIOCDIFADDR") ); 59 _map.insert( 0x8936, new QString("SIOCDIFADDR") );
60 _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") ); 60 _map.insert( 0x8937, new QString("SIOCSIFHWBROADCAST") );
61 _map.insert( 0x8938, new QString("SIOCGIFCOUNT") ); 61 _map.insert( 0x8938, new QString("SIOCGIFCOUNT") );
62 _map.insert( 0x8940, new QString("SIOCGIFBR") ); 62 _map.insert( 0x8940, new QString("SIOCGIFBR") );
63 _map.insert( 0x8941, new QString("SIOCSIFBR") ); 63 _map.insert( 0x8941, new QString("SIOCSIFBR") );
64 _map.insert( 0x8942, new QString("SIOCGIFTXQLEN") ); 64 _map.insert( 0x8942, new QString("SIOCGIFTXQLEN") );
65 _map.insert( 0x8943, new QString("SIOCSIFTXQLEN") ); 65 _map.insert( 0x8943, new QString("SIOCSIFTXQLEN") );
66 _map.insert( 0x8953, new QString("SIOCDARP") ); 66 _map.insert( 0x8953, new QString("SIOCDARP") );
67 _map.insert( 0x8954, new QString("SIOCGARP") ); 67 _map.insert( 0x8954, new QString("SIOCGARP") );
68 _map.insert( 0x8955, new QString("SIOCSARP") ); 68 _map.insert( 0x8955, new QString("SIOCSARP") );
69 _map.insert( 0x8960, new QString("SIOCDRARP") ); 69 _map.insert( 0x8960, new QString("SIOCDRARP") );
70 _map.insert( 0x8961, new QString("SIOCGRARP") ); 70 _map.insert( 0x8961, new QString("SIOCGRARP") );
71 _map.insert( 0x8962, new QString("SIOCSRARP") ); 71 _map.insert( 0x8962, new QString("SIOCSRARP") );
72 _map.insert( 0x8970, new QString("SIOCGIFMAP") ); 72 _map.insert( 0x8970, new QString("SIOCGIFMAP") );
73 _map.insert( 0x8971, new QString("SIOCSIFMAP") ); 73 _map.insert( 0x8971, new QString("SIOCSIFMAP") );
74 _map.insert( 0x8980, new QString("SIOCADDDLCI") ); 74 _map.insert( 0x8980, new QString("SIOCADDDLCI") );
75 _map.insert( 0x8981, new QString("SIOCDELDLCI") ); 75 _map.insert( 0x8981, new QString("SIOCDELDLCI") );
76 _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") ); 76 _map.insert( 0x89F0, new QString("SIOCDEVPRIVATE") );
77 _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") ); 77 _map.insert( 0x89E0, new QString("SIOCPROTOPRIVATE") );
78 _map.insert( 0x1fff, new QString("SIOCPARM_MASK") ); 78 _map.insert( 0x1fff, new QString("SIOCPARM_MASK") );
79 _map.insert( 0x00000000, new QString("SIOC_VOID") ); 79 _map.insert( 0x00000000, new QString("SIOC_VOID") );
80 _map.insert( 0x20000000, new QString("SIOC_OUT") ); 80 _map.insert( 0x20000000, new QString("SIOC_OUT") );
81 _map.insert( 0x40000000, new QString("SIOC_IN") ); 81 _map.insert( 0x40000000, new QString("SIOC_IN") );
82 _map.insert( 0x8B00, new QString("SIOCSIWCOMMIT") ); 82 _map.insert( 0x8B00, new QString("SIOCSIWCOMMIT") );
83 _map.insert( 0x8B01, new QString("SIOCGIWNAME") ); 83 _map.insert( 0x8B01, new QString("SIOCGIWNAME") );
84 _map.insert( 0x8B02, new QString("SIOCSIWNWID") ); 84 _map.insert( 0x8B02, new QString("SIOCSIWNWID") );
85 _map.insert( 0x8B03, new QString("SIOCGIWNWID") ); 85 _map.insert( 0x8B03, new QString("SIOCGIWNWID") );
86 _map.insert( 0x8B04, new QString("SIOCSIWFREQ") ); 86 _map.insert( 0x8B04, new QString("SIOCSIWFREQ") );
87 _map.insert( 0x8B05, new QString("SIOCGIWFREQ") ); 87 _map.insert( 0x8B05, new QString("SIOCGIWFREQ") );
88 _map.insert( 0x8B06, new QString("SIOCSIWMODE") ); 88 _map.insert( 0x8B06, new QString("SIOCSIWMODE") );
89 _map.insert( 0x8B07, new QString("SIOCGIWMODE") ); 89 _map.insert( 0x8B07, new QString("SIOCGIWMODE") );
90 _map.insert( 0x8B08, new QString("SIOCSIWSENS") ); 90 _map.insert( 0x8B08, new QString("SIOCSIWSENS") );
91 _map.insert( 0x8B09, new QString("SIOCGIWSENS") ); 91 _map.insert( 0x8B09, new QString("SIOCGIWSENS") );
92 _map.insert( 0x8B0A, new QString("SIOCSIWRANGE") ); 92 _map.insert( 0x8B0A, new QString("SIOCSIWRANGE") );
93 _map.insert( 0x8B0B, new QString("SIOCGIWRANGE") ); 93 _map.insert( 0x8B0B, new QString("SIOCGIWRANGE") );
94 _map.insert( 0x8B0C, new QString("SIOCSIWPRIV") ); 94 _map.insert( 0x8B0C, new QString("SIOCSIWPRIV") );
95 _map.insert( 0x8B0D, new QString("SIOCGIWPRIV") ); 95 _map.insert( 0x8B0D, new QString("SIOCGIWPRIV") );
96 _map.insert( 0x8B0E, new QString("SIOCSIWSTATS") ); 96 _map.insert( 0x8B0E, new QString("SIOCSIWSTATS") );
97 _map.insert( 0x8B0F, new QString("SIOCGIWSTATS") ); 97 _map.insert( 0x8B0F, new QString("SIOCGIWSTATS") );
98 _map.insert( 0x8B10, new QString("SIOCSIWSPY") ); 98 _map.insert( 0x8B10, new QString("SIOCSIWSPY") );
99 _map.insert( 0x8B11, new QString("SIOCGIWSPY") ); 99 _map.insert( 0x8B11, new QString("SIOCGIWSPY") );
100 _map.insert( 0x8B14, new QString("SIOCSIWAP") ); 100 _map.insert( 0x8B14, new QString("SIOCSIWAP") );
101 _map.insert( 0x8B15, new QString("SIOCGIWAP") ); 101 _map.insert( 0x8B15, new QString("SIOCGIWAP") );
102 _map.insert( 0x8B17, new QString("SIOCGIWAPLIST") ); 102 _map.insert( 0x8B17, new QString("SIOCGIWAPLIST") );
103 _map.insert( 0x8B18, new QString("SIOCSIWSCAN") ); 103 _map.insert( 0x8B18, new QString("SIOCSIWSCAN") );
104 _map.insert( 0x8B19, new QString("SIOCGIWSCAN") ); 104 _map.insert( 0x8B19, new QString("SIOCGIWSCAN") );
105 _map.insert( 0x8B1A, new QString("SIOCSIWESSID") ); 105 _map.insert( 0x8B1A, new QString("SIOCSIWESSID") );
106 _map.insert( 0x8B1B, new QString("SIOCGIWESSID") ); 106 _map.insert( 0x8B1B, new QString("SIOCGIWESSID") );
107 _map.insert( 0x8B1C, new QString("SIOCSIWNICKN") ); 107 _map.insert( 0x8B1C, new QString("SIOCSIWNICKN") );
108 _map.insert( 0x8B1D, new QString("SIOCGIWNICKN") ); 108 _map.insert( 0x8B1D, new QString("SIOCGIWNICKN") );
109 _map.insert( 0x8B20, new QString("SIOCSIWRATE") ); 109 _map.insert( 0x8B20, new QString("SIOCSIWRATE") );
110 _map.insert( 0x8B21, new QString("SIOCGIWRATE") ); 110 _map.insert( 0x8B21, new QString("SIOCGIWRATE") );
111 _map.insert( 0x8B22, new QString("SIOCSIWRTS") ); 111 _map.insert( 0x8B22, new QString("SIOCSIWRTS") );
112 _map.insert( 0x8B23, new QString("SIOCGIWRTS") ); 112 _map.insert( 0x8B23, new QString("SIOCGIWRTS") );
113 _map.insert( 0x8B24, new QString("SIOCSIWFRAG") ); 113 _map.insert( 0x8B24, new QString("SIOCSIWFRAG") );
114 _map.insert( 0x8B25, new QString("SIOCGIWFRAG") ); 114 _map.insert( 0x8B25, new QString("SIOCGIWFRAG") );
115 _map.insert( 0x8B26, new QString("SIOCSIWTXPOW") ); 115 _map.insert( 0x8B26, new QString("SIOCSIWTXPOW") );
116 _map.insert( 0x8B27, new QString("SIOCGIWTXPOW") ); 116 _map.insert( 0x8B27, new QString("SIOCGIWTXPOW") );
117 _map.insert( 0x8B28, new QString("SIOCSIWRETRY") ); 117 _map.insert( 0x8B28, new QString("SIOCSIWRETRY") );
118 _map.insert( 0x8B29, new QString("SIOCGIWRETRY") ); 118 _map.insert( 0x8B29, new QString("SIOCGIWRETRY") );
119 _map.insert( 0x8B2A, new QString("SIOCSIWENCODE") ); 119 _map.insert( 0x8B2A, new QString("SIOCSIWENCODE") );
120 _map.insert( 0x8B2B, new QString("SIOCGIWENCODE") ); 120 _map.insert( 0x8B2B, new QString("SIOCGIWENCODE") );
121 _map.insert( 0x8B2C, new QString("SIOCSIWPOWER") ); 121 _map.insert( 0x8B2C, new QString("SIOCSIWPOWER") );
122 _map.insert( 0x8B2D, new QString("SIOCGIWPOWER") ); 122 _map.insert( 0x8B2D, new QString("SIOCGIWPOWER") );
123 _map.insert( 0x8BE0, new QString("SIOCIWFIRSTPRIV") ); 123 _map.insert( 0x8BE0, new QString("SIOCIWFIRSTPRIV") );
124 _map.insert( 0x8BFF, new QString("SIOCIWLASTPRIV") ); 124 _map.insert( 0x8BFF, new QString("SIOCIWLASTPRIV") );
125 _map.insert( 0x8B00, new QString("SIOCIWFIRST") ); 125 _map.insert( 0x8B00, new QString("SIOCIWFIRST") );
126 _map.insert( 0x5000, new QString("SIOCGBPQETHPARAM") ); 126 _map.insert( 0x5000, new QString("SIOCGBPQETHPARAM") );
127 _map.insert( 0x5001, new QString("SIOCSBPQETHPARAM") ); 127 _map.insert( 0x5001, new QString("SIOCSBPQETHPARAM") );
128 _map.insert( 0x890B, new QString("SIOCADDRT") ); 128 _map.insert( 0x890B, new QString("SIOCADDRT") );
129 _map.insert( 0x890C, new QString("SIOCDELRT") ); 129 _map.insert( 0x890C, new QString("SIOCDELRT") );
130 _map.insert( 0x890D, new QString("SIOCRTMSG") ); 130 _map.insert( 0x890D, new QString("SIOCRTMSG") );
131 _map.insert( 0x8910, new QString("SIOCGIFNAME") ); 131 _map.insert( 0x8910, new QString("SIOCGIFNAME") );
132 _map.insert( 0x8911, new QString("SIOCSIFLINK") ); 132 _map.insert( 0x8911, new QString("SIOCSIFLINK") );
133 _map.insert( 0x8912, new QString("SIOCGIFCONF") ); 133 _map.insert( 0x8912, new QString("SIOCGIFCONF") );
134 _map.insert( 0x8913, new QString("SIOCGIFFLAGS") ); 134 _map.insert( 0x8913, new QString("SIOCGIFFLAGS") );
135 _map.insert( 0x8914, new QString("SIOCSIFFLAGS") ); 135 _map.insert( 0x8914, new QString("SIOCSIFFLAGS") );
136 _map.insert( 0x8915, new QString("SIOCGIFADDR") ); 136 _map.insert( 0x8915, new QString("SIOCGIFADDR") );
137 _map.insert( 0x8916, new QString("SIOCSIFADDR") ); 137 _map.insert( 0x8916, new QString("SIOCSIFADDR") );
138 _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") ); 138 _map.insert( 0x8917, new QString("SIOCGIFDSTADDR") );
139 _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") ); 139 _map.insert( 0x8918, new QString("SIOCSIFDSTADDR") );
140 _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") ); 140 _map.insert( 0x8919, new QString("SIOCGIFBRDADDR") );
141 _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") ); 141 _map.insert( 0x891a, new QString("SIOCSIFBRDADDR") );
142 _map.insert( 0x891b, new QString("SIOCGIFNETMASK") ); 142 _map.insert( 0x891b, new QString("SIOCGIFNETMASK") );
diff --git a/libopie2/opienet/odebugmapper.h b/libopie2/opienet/odebugmapper.h
index f47db47..79fb42e 100644
--- a/libopie2/opienet/odebugmapper.h
+++ b/libopie2/opienet/odebugmapper.h
@@ -1,36 +1,36 @@
1 1
2/* 2/*
3 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de> 3 * debug value mapper - generated by regen.py - (C) Michael 'Mickey' Lauer <mickey@vanille.de>
4 */ 4 */
5 5
6#ifndef DEBUGMAPPER_H 6#ifndef DEBUGMAPPER_H
7#define DEBUGMAPPER_H 7#define DEBUGMAPPER_H
8 8
9#include <qstring.h> 9#include <qstring.h>
10#include <qintdict.h> 10#include <qintdict.h>
11 11
12namespace Opie { 12namespace Opie {
13namespace Net { 13namespace Net {
14namespace Private { 14namespace Internal {
15 15
16typedef QIntDict<QString> IntStringMap; 16typedef QIntDict<QString> IntStringMap;
17 17
18class DebugMapper 18class DebugMapper
19{ 19{
20 public: 20 public:
21 DebugMapper(); 21 DebugMapper();
22 ~DebugMapper(); 22 ~DebugMapper();
23 23
24 const QString& map( int value ) const; 24 const QString& map( int value ) const;
25 private: 25 private:
26 IntStringMap _map; 26 IntStringMap _map;
27 class Private; 27 class Private;
28 Private *d; 28 Private *d;
29}; 29};
30 30
31} 31}
32} 32}
33} 33}
34 34
35#endif 35#endif
36 36
diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp
index 7794334..c185805 100644
--- a/libopie2/opienet/onetutils.cpp
+++ b/libopie2/opienet/onetutils.cpp
@@ -65,177 +65,177 @@ OMacAddress::OMacAddress( unsigned char* p )
65 65
66 66
67OMacAddress::OMacAddress( const unsigned char* p ) 67OMacAddress::OMacAddress( const unsigned char* p )
68{ 68{
69 memcpy( _bytes, p, 6 ); 69 memcpy( _bytes, p, 6 );
70} 70}
71 71
72 72
73OMacAddress::OMacAddress( struct ifreq& ifr ) 73OMacAddress::OMacAddress( struct ifreq& ifr )
74{ 74{
75 memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 ); 75 memcpy( _bytes, ifr.ifr_hwaddr.sa_data, 6 );
76} 76}
77 77
78 78
79OMacAddress::~OMacAddress() 79OMacAddress::~OMacAddress()
80{ 80{
81} 81}
82 82
83 83
84//#ifdef QT_NO_DEBUG 84//#ifdef QT_NO_DEBUG
85//inline 85//inline
86//#endif 86//#endif
87const unsigned char* OMacAddress::native() const 87const unsigned char* OMacAddress::native() const
88{ 88{
89 return (const unsigned char*) &_bytes; 89 return (const unsigned char*) &_bytes;
90} 90}
91 91
92 92
93OMacAddress OMacAddress::fromString( const QString& str ) 93OMacAddress OMacAddress::fromString( const QString& str )
94{ 94{
95 QString addr( str ); 95 QString addr( str );
96 unsigned char buf[6]; 96 unsigned char buf[6];
97 bool ok = true; 97 bool ok = true;
98 int index = 14; 98 int index = 14;
99 for ( int i = 5; i >= 0; --i ) 99 for ( int i = 5; i >= 0; --i )
100 { 100 {
101 buf[i] = addr.right( 2 ).toUShort( &ok, 16 ); 101 buf[i] = addr.right( 2 ).toUShort( &ok, 16 );
102 if ( !ok ) return OMacAddress::unknown; 102 if ( !ok ) return OMacAddress::unknown;
103 addr.truncate( index ); 103 addr.truncate( index );
104 index -= 3; 104 index -= 3;
105 } 105 }
106 return (const unsigned char*) &buf; 106 return (const unsigned char*) &buf;
107} 107}
108 108
109 109
110QString OMacAddress::toString( bool substitute ) const 110QString OMacAddress::toString( bool substitute ) const
111{ 111{
112 QString manu; 112 QString manu;
113 manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff ); 113 manu.sprintf( "%.2X:%.2X:%.2X", _bytes[0]&0xff, _bytes[1]&0xff, _bytes[2]&0xff );
114 QString serial; 114 QString serial;
115 serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff ); 115 serial.sprintf( ":%.2X:%.2X:%.2X", _bytes[3]&0xff, _bytes[4]&0xff, _bytes[5]&0xff );
116 if ( !substitute ) return manu+serial; 116 if ( !substitute ) return manu+serial;
117 // fallback - if no vendor is found, just use the number 117 // fallback - if no vendor is found, just use the number
118 QString textmanu = OManufacturerDB::instance()->lookup( manu ); 118 QString textmanu = OManufacturerDB::instance()->lookup( manu );
119 return textmanu.isNull() ? manu+serial : textmanu+serial; 119 return textmanu.isNull() ? manu+serial : textmanu+serial;
120} 120}
121 121
122 122
123QString OMacAddress::manufacturer() const 123QString OMacAddress::manufacturer() const
124{ 124{
125 return OManufacturerDB::instance()->lookupExt( toString() ); 125 return OManufacturerDB::instance()->lookupExt( toString() );
126} 126}
127 127
128 128
129bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) 129bool operator==( const OMacAddress &m1, const OMacAddress &m2 )
130{ 130{
131 return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0; 131 return memcmp( &m1._bytes, &m2._bytes, 6 ) == 0;
132} 132}
133 133
134 134
135/*====================================================================================== 135/*======================================================================================
136 * OHostAddress 136 * OHostAddress
137 *======================================================================================*/ 137 *======================================================================================*/
138 138
139 139
140/*====================================================================================== 140/*======================================================================================
141 * OPrivateIOCTL 141 * OPrivateIOCTL
142 *======================================================================================*/ 142 *======================================================================================*/
143 143
144OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) 144OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs )
145 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs ) 145 :QObject( parent, name ), _ioctl( cmd ), _getargs( getargs ), _setargs( setargs )
146{ 146{
147} 147}
148 148
149 149
150OPrivateIOCTL::~OPrivateIOCTL() 150OPrivateIOCTL::~OPrivateIOCTL()
151{ 151{
152} 152}
153 153
154 154
155int OPrivateIOCTL::numberGetArgs() const 155int OPrivateIOCTL::numberGetArgs() const
156{ 156{
157 return _getargs & IW_PRIV_SIZE_MASK; 157 return _getargs & IW_PRIV_SIZE_MASK;
158} 158}
159 159
160 160
161int OPrivateIOCTL::typeGetArgs() const 161int OPrivateIOCTL::typeGetArgs() const
162{ 162{
163 return _getargs & IW_PRIV_TYPE_MASK >> 12; 163 return _getargs & IW_PRIV_TYPE_MASK >> 12;
164} 164}
165 165
166 166
167int OPrivateIOCTL::numberSetArgs() const 167int OPrivateIOCTL::numberSetArgs() const
168{ 168{
169 return _setargs & IW_PRIV_SIZE_MASK; 169 return _setargs & IW_PRIV_SIZE_MASK;
170} 170}
171 171
172 172
173int OPrivateIOCTL::typeSetArgs() const 173int OPrivateIOCTL::typeSetArgs() const
174{ 174{
175 return _setargs & IW_PRIV_TYPE_MASK >> 12; 175 return _setargs & IW_PRIV_TYPE_MASK >> 12;
176} 176}
177 177
178 178
179void OPrivateIOCTL::invoke() const 179void OPrivateIOCTL::invoke() const
180{ 180{
181 ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl ); 181 ( (OWirelessNetworkInterface*) parent() )->wioctl( _ioctl );
182} 182}
183 183
184 184
185void OPrivateIOCTL::setParameter( int num, u_int32_t value ) 185void OPrivateIOCTL::setParameter( int num, u_int32_t value )
186{ 186{
187 u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name; 187 u_int32_t* arglist = (u_int32_t*) &( (OWirelessNetworkInterface*) parent() )->_iwr.u.name;
188 arglist[num] = value; 188 arglist[num] = value;
189} 189}
190 190
191 191
192 192
193namespace Private { 193namespace Internal {
194/*====================================================================================== 194/*======================================================================================
195 * assorted functions 195 * assorted functions
196 *======================================================================================*/ 196 *======================================================================================*/
197 197
198void dumpBytes( const unsigned char* data, int num ) 198void dumpBytes( const unsigned char* data, int num )
199{ 199{
200 printf( "Dumping %d bytes @ %0x", num, data ); 200 printf( "Dumping %d bytes @ %0x", num, data );
201 printf( "-------------------------------------------\n" ); 201 printf( "-------------------------------------------\n" );
202 202
203 for ( int i = 0; i < num; ++i ) 203 for ( int i = 0; i < num; ++i )
204 { 204 {
205 printf( "%02x ", data[i] ); 205 printf( "%02x ", data[i] );
206 if ( !((i+1) % 32) ) printf( "\n" ); 206 if ( !((i+1) % 32) ) printf( "\n" );
207 } 207 }
208 printf( "\n\n" ); 208 printf( "\n\n" );
209} 209}
210 210
211 211
212int stringToMode( const QString& mode ) 212int stringToMode( const QString& mode )
213{ 213{
214 if ( mode == "auto" ) return IW_MODE_AUTO; 214 if ( mode == "auto" ) return IW_MODE_AUTO;
215 else if ( mode == "adhoc" ) return IW_MODE_ADHOC; 215 else if ( mode == "adhoc" ) return IW_MODE_ADHOC;
216 else if ( mode == "managed" ) return IW_MODE_INFRA; 216 else if ( mode == "managed" ) return IW_MODE_INFRA;
217 else if ( mode == "master" ) return IW_MODE_MASTER; 217 else if ( mode == "master" ) return IW_MODE_MASTER;
218 else if ( mode == "repeater" ) return IW_MODE_REPEAT; 218 else if ( mode == "repeater" ) return IW_MODE_REPEAT;
219 else if ( mode == "secondary" ) return IW_MODE_SECOND; 219 else if ( mode == "secondary" ) return IW_MODE_SECOND;
220 else if ( mode == "monitor" ) return IW_MODE_MONITOR; 220 else if ( mode == "monitor" ) return IW_MODE_MONITOR;
221 else assert( 0 ); 221 else assert( 0 );
222} 222}
223 223
224 224
225QString modeToString( int mode ) 225QString modeToString( int mode )
226{ 226{
227 switch ( mode ) 227 switch ( mode )
228 { 228 {
229 case IW_MODE_AUTO: return "auto"; 229 case IW_MODE_AUTO: return "auto";
230 case IW_MODE_ADHOC: return "adhoc"; 230 case IW_MODE_ADHOC: return "adhoc";
231 case IW_MODE_INFRA: return "managed"; 231 case IW_MODE_INFRA: return "managed";
232 case IW_MODE_MASTER: return "master"; 232 case IW_MODE_MASTER: return "master";
233 case IW_MODE_REPEAT: return "repeater"; 233 case IW_MODE_REPEAT: return "repeater";
234 case IW_MODE_SECOND: return "second"; 234 case IW_MODE_SECOND: return "second";
235 case IW_MODE_MONITOR: return "monitor"; 235 case IW_MODE_MONITOR: return "monitor";
236 default: assert( 0 ); 236 default: assert( 0 );
237 } 237 }
238} 238}
239} 239}
240} 240}
241} 241}
diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h
index ca6815d..4a09426 100644
--- a/libopie2/opienet/onetutils.h
+++ b/libopie2/opienet/onetutils.h
@@ -7,190 +7,190 @@
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 31
32#ifndef ONETUTILS_H 32#ifndef ONETUTILS_H
33#define ONETUTILS_H 33#define ONETUTILS_H
34 34
35#include <qdict.h> 35#include <qdict.h>
36#include <qmap.h> 36#include <qmap.h>
37#include <qstring.h> 37#include <qstring.h>
38#include <qhostaddress.h> 38#include <qhostaddress.h>
39#include <qobject.h> 39#include <qobject.h>
40 40
41#include <sys/types.h> 41#include <sys/types.h>
42 42
43struct ifreq; 43struct ifreq;
44 44
45namespace Opie { 45namespace Opie {
46namespace Net { 46namespace Net {
47 47
48class OWirelessNetworkInterface; 48class OWirelessNetworkInterface;
49 49
50/*====================================================================================== 50/*======================================================================================
51 * OMacAddress 51 * OMacAddress
52 *======================================================================================*/ 52 *======================================================================================*/
53 53
54class OMacAddress 54class OMacAddress
55{ 55{
56 public: 56 public:
57 // QString c'tor? -zecke 57 // QString c'tor? -zecke
58 OMacAddress(); 58 OMacAddress();
59 OMacAddress( unsigned char* ); 59 OMacAddress( unsigned char* );
60 OMacAddress( const unsigned char* ); 60 OMacAddress( const unsigned char* );
61 OMacAddress( struct ifreq& ); 61 OMacAddress( struct ifreq& );
62 ~OMacAddress(); 62 ~OMacAddress();
63 63
64 QString manufacturer() const; 64 QString manufacturer() const;
65 QString toString( bool substitute = false ) const; 65 QString toString( bool substitute = false ) const;
66 const unsigned char* native() const; 66 const unsigned char* native() const;
67 67
68 // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem? 68 // no c'tor but this one why not make it a c'tor. it could also replace the others or is this the problem?
69 static OMacAddress fromString( const QString& ); 69 static OMacAddress fromString( const QString& );
70 70
71 public: 71 public:
72 static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff 72 static const OMacAddress& broadcast; // ff:ff:ff:ff:ff:ff
73 static const OMacAddress& unknown; // 44:44:44:44:44:44 73 static const OMacAddress& unknown; // 44:44:44:44:44:44
74 74
75 private: 75 private:
76 unsigned char _bytes[6]; 76 unsigned char _bytes[6];
77 77
78 friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); 78 friend bool operator==( const OMacAddress &m1, const OMacAddress &m2 );
79 class Private; 79 class Private;
80 Private *d; 80 Private *d;
81 81
82}; 82};
83 83
84bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); 84bool operator==( const OMacAddress &m1, const OMacAddress &m2 );
85 85
86 86
87/*====================================================================================== 87/*======================================================================================
88 * OHostAddress 88 * OHostAddress
89 *======================================================================================*/ 89 *======================================================================================*/
90 90
91class OHostAddress : public QHostAddress 91class OHostAddress : public QHostAddress
92{ 92{
93 /*public: 93 /*public:
94 OHostAddress(); 94 OHostAddress();
95 ~OHostAddress(); 95 ~OHostAddress();
96 */ 96 */
97 private: 97 private:
98 class Private; 98 class Private;
99 Private *d; 99 Private *d;
100}; 100};
101 101
102 102
103/*====================================================================================== 103/*======================================================================================
104 * OPrivateIOCTL 104 * OPrivateIOCTL
105 *======================================================================================*/ 105 *======================================================================================*/
106 106
107class OPrivateIOCTL : public QObject 107class OPrivateIOCTL : public QObject
108{ 108{
109 public: 109 public:
110 OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ); 110 OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs );
111 ~OPrivateIOCTL(); 111 ~OPrivateIOCTL();
112 112
113 int numberGetArgs() const; 113 int numberGetArgs() const;
114 int typeGetArgs() const; 114 int typeGetArgs() const;
115 int numberSetArgs() const; 115 int numberSetArgs() const;
116 int typeSetArgs() const; 116 int typeSetArgs() const;
117 117
118 // FIXME return int? as ::ioctl does? -zecke 118 // FIXME return int? as ::ioctl does? -zecke
119 void invoke() const; 119 void invoke() const;
120 void setParameter( int, u_int32_t ); 120 void setParameter( int, u_int32_t );
121 121
122 private: 122 private:
123 u_int32_t _ioctl; 123 u_int32_t _ioctl;
124 u_int16_t _getargs; 124 u_int16_t _getargs;
125 u_int16_t _setargs; 125 u_int16_t _setargs;
126 126
127 class Private; 127 class Private;
128 Private *d; 128 Private *d;
129}; 129};
130 130
131 /*====================================================================================== 131 /*======================================================================================
132 * Miscellaneous 132 * Miscellaneous
133 *======================================================================================*/ 133 *======================================================================================*/
134 134
135namespace Private { 135namespace Internal {
136void dumpBytes( const unsigned char* data, int num ); 136void dumpBytes( const unsigned char* data, int num );
137QString modeToString( int ); 137QString modeToString( int );
138int stringToMode( const QString& ); 138int stringToMode( const QString& );
139} 139}
140} 140}
141} 141}
142 142
143#define IW_PRIV_TYPE_MASK 0x7000 143#define IW_PRIV_TYPE_MASK 0x7000
144#define IW_PRIV_TYPE_NONE 0x0000 144#define IW_PRIV_TYPE_NONE 0x0000
145#define IW_PRIV_TYPE_BYTE 0x1000 145#define IW_PRIV_TYPE_BYTE 0x1000
146#define IW_PRIV_TYPE_CHAR 0x2000 146#define IW_PRIV_TYPE_CHAR 0x2000
147#define IW_PRIV_TYPE_INT 0x4000 147#define IW_PRIV_TYPE_INT 0x4000
148#define IW_PRIV_TYPE_FLOAT 0x5000 148#define IW_PRIV_TYPE_FLOAT 0x5000
149#define IW_PRIV_TYPE_ADDR 0x6000 149#define IW_PRIV_TYPE_ADDR 0x6000
150#define IW_PRIV_SIZE_FIXED 0x0800 150#define IW_PRIV_SIZE_FIXED 0x0800
151#define IW_PRIV_SIZE_MASK 0x07FF 151#define IW_PRIV_SIZE_MASK 0x07FF
152 152
153#ifndef ARPHRD_IEEE80211 153#ifndef ARPHRD_IEEE80211
154#define ARPHRD_IEEE80211 801 154#define ARPHRD_IEEE80211 801
155#endif 155#endif
156#ifndef ARPHRD_IEEE80211_PRISM 156#ifndef ARPHRD_IEEE80211_PRISM
157#define ARPHRD_IEEE80211_PRISM 802 157#define ARPHRD_IEEE80211_PRISM 802
158#endif 158#endif
159 159
160 160
161/* Network to host order macros */ 161/* Network to host order macros */
162 162
163#ifdef LBL_ALIGN 163#ifdef LBL_ALIGN
164#define EXTRACT_16BITS(p) \ 164#define EXTRACT_16BITS(p) \
165 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \ 165 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 0) << 8 | \
166 (u_int16_t)*((const u_int8_t *)(p) + 1))) 166 (u_int16_t)*((const u_int8_t *)(p) + 1)))
167#define EXTRACT_32BITS(p) \ 167#define EXTRACT_32BITS(p) \
168 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \ 168 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 24 | \
169 (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \ 169 (u_int32_t)*((const u_int8_t *)(p) + 1) << 16 | \
170 (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \ 170 (u_int32_t)*((const u_int8_t *)(p) + 2) << 8 | \
171 (u_int32_t)*((const u_int8_t *)(p) + 3))) 171 (u_int32_t)*((const u_int8_t *)(p) + 3)))
172#else 172#else
173#define EXTRACT_16BITS(p) \ 173#define EXTRACT_16BITS(p) \
174 ((u_int16_t)ntohs(*(const u_int16_t *)(p))) 174 ((u_int16_t)ntohs(*(const u_int16_t *)(p)))
175#define EXTRACT_32BITS(p) \ 175#define EXTRACT_32BITS(p) \
176 ((u_int32_t)ntohl(*(const u_int32_t *)(p))) 176 ((u_int32_t)ntohl(*(const u_int32_t *)(p)))
177#endif 177#endif
178 178
179#define EXTRACT_24BITS(p) \ 179#define EXTRACT_24BITS(p) \
180 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \ 180 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 0) << 16 | \
181 (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ 181 (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
182 (u_int32_t)*((const u_int8_t *)(p) + 2))) 182 (u_int32_t)*((const u_int8_t *)(p) + 2)))
183 183
184/* Little endian protocol host order macros */ 184/* Little endian protocol host order macros */
185#define EXTRACT_LE_8BITS(p) (*(p)) 185#define EXTRACT_LE_8BITS(p) (*(p))
186#define EXTRACT_LE_16BITS(p) \ 186#define EXTRACT_LE_16BITS(p) \
187 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \ 187 ((u_int16_t)((u_int16_t)*((const u_int8_t *)(p) + 1) << 8 | \
188 (u_int16_t)*((const u_int8_t *)(p) + 0))) 188 (u_int16_t)*((const u_int8_t *)(p) + 0)))
189#define EXTRACT_LE_32BITS(p) \ 189#define EXTRACT_LE_32BITS(p) \
190 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \ 190 ((u_int32_t)((u_int32_t)*((const u_int8_t *)(p) + 3) << 24 | \
191 (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \ 191 (u_int32_t)*((const u_int8_t *)(p) + 2) << 16 | \
192 (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \ 192 (u_int32_t)*((const u_int8_t *)(p) + 1) << 8 | \
193 (u_int32_t)*((const u_int8_t *)(p) + 0))) 193 (u_int32_t)*((const u_int8_t *)(p) + 0)))
194 194
195#endif // ONETUTILS_H 195#endif // ONETUTILS_H
196 196
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index 26a6c81..b6c9876 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -1,234 +1,234 @@
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 by Michael 'Mickey' Lauer 3              Copyright (C) 2003-2004 by Michael 'Mickey' Lauer
4 =. <mickey@Vanille.de> 4 =. <mickey@Vanille.de>
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 30
31/* OPIE */ 31/* OPIE */
32 32
33#include <opie2/onetwork.h> 33#include <opie2/onetwork.h>
34#include <opie2/ostation.h> 34#include <opie2/ostation.h>
35#include <opie2/odebug.h> 35#include <opie2/odebug.h>
36 36
37/* QT */ 37/* QT */
38 38
39#include <qfile.h> 39#include <qfile.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
41 41
42/* UNIX */ 42/* UNIX */
43 43
44#include <assert.h> 44#include <assert.h>
45#include <arpa/inet.h> 45#include <arpa/inet.h>
46#include <errno.h> 46#include <errno.h>
47#include <string.h> 47#include <string.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <math.h> 49#include <math.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/socket.h> 51#include <sys/socket.h>
52#include <sys/types.h> 52#include <sys/types.h>
53#include <unistd.h> 53#include <unistd.h>
54#include <linux/sockios.h> 54#include <linux/sockios.h>
55#include <net/if_arp.h> 55#include <net/if_arp.h>
56#include <stdarg.h> 56#include <stdarg.h>
57 57
58#ifndef NODEBUG 58#ifndef NODEBUG
59#include <opie2/odebugmapper.h> 59#include <opie2/odebugmapper.h>
60 60
61 61
62using namespace Opie::Core; 62using namespace Opie::Core;
63using namespace Opie::Net::Private; 63using namespace Opie::Net::Internal;
64DebugMapper* debugmapper = new DebugMapper(); 64DebugMapper* debugmapper = new DebugMapper();
65#endif 65#endif
66 66
67/*====================================================================================== 67/*======================================================================================
68 * ONetwork 68 * ONetwork
69 *======================================================================================*/ 69 *======================================================================================*/
70 70
71namespace Opie { 71namespace Opie {
72namespace Net { 72namespace Net {
73ONetwork* ONetwork::_instance = 0; 73ONetwork* ONetwork::_instance = 0;
74 74
75ONetwork::ONetwork() 75ONetwork::ONetwork()
76{ 76{
77 odebug << "ONetwork::ONetwork()" << oendl; 77 odebug << "ONetwork::ONetwork()" << oendl;
78 odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl; 78 odebug << "ONetwork: This code has been compiled against Wireless Extensions V" << WIRELESS_EXT << oendl;
79 synchronize(); 79 synchronize();
80} 80}
81 81
82void ONetwork::synchronize() 82void ONetwork::synchronize()
83{ 83{
84 // gather available interfaces by inspecting /proc/net/dev 84 // gather available interfaces by inspecting /proc/net/dev
85 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices 85 //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices
86 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices 86 //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices
87 //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev 87 //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev
88 88
89 _interfaces.clear(); 89 _interfaces.clear();
90 QString str; 90 QString str;
91 QFile f( "/proc/net/dev" ); 91 QFile f( "/proc/net/dev" );
92 bool hasFile = f.open( IO_ReadOnly ); 92 bool hasFile = f.open( IO_ReadOnly );
93 if ( !hasFile ) 93 if ( !hasFile )
94 { 94 {
95 odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl; 95 odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl;
96 return; 96 return;
97 } 97 }
98 QTextStream s( &f ); 98 QTextStream s( &f );
99 s.readLine(); 99 s.readLine();
100 s.readLine(); 100 s.readLine();
101 while ( !s.atEnd() ) 101 while ( !s.atEnd() )
102 { 102 {
103 s >> str; 103 s >> str;
104 str.truncate( str.find( ':' ) ); 104 str.truncate( str.find( ':' ) );
105 odebug << "ONetwork: found interface '" << str << "'" << oendl; 105 odebug << "ONetwork: found interface '" << str << "'" << oendl;
106 ONetworkInterface* iface; 106 ONetworkInterface* iface = 0;
107 if ( isWirelessInterface( str ) ) 107 if ( isWirelessInterface( str ) )
108 { 108 {
109 iface = new OWirelessNetworkInterface( this, (const char*) str ); 109 iface = new OWirelessNetworkInterface( this, (const char*) str );
110 odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl; 110 odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl;
111 } 111 }
112 else 112 else
113 { 113 {
114 iface = new ONetworkInterface( this, (const char*) str ); 114 iface = new ONetworkInterface( this, (const char*) str );
115 } 115 }
116 _interfaces.insert( str, iface ); 116 _interfaces.insert( str, iface );
117 s.readLine(); 117 s.readLine();
118 } 118 }
119} 119}
120 120
121 121
122short ONetwork::wirelessExtensionVersion() 122short ONetwork::wirelessExtensionVersion()
123{ 123{
124 return WIRELESS_EXT; 124 return WIRELESS_EXT;
125} 125}
126 126
127 127
128int ONetwork::count() const 128int ONetwork::count() const
129{ 129{
130 return _interfaces.count(); 130 return _interfaces.count();
131} 131}
132 132
133 133
134ONetworkInterface* ONetwork::interface( const QString& iface ) const 134ONetworkInterface* ONetwork::interface( const QString& iface ) const
135{ 135{
136 return _interfaces[iface]; 136 return _interfaces[iface];
137} 137}
138 138
139 139
140ONetwork* ONetwork::instance() 140ONetwork* ONetwork::instance()
141{ 141{
142 if ( !_instance ) _instance = new ONetwork(); 142 if ( !_instance ) _instance = new ONetwork();
143 return _instance; 143 return _instance;
144} 144}
145 145
146 146
147ONetwork::InterfaceIterator ONetwork::iterator() const 147ONetwork::InterfaceIterator ONetwork::iterator() const
148{ 148{
149 return ONetwork::InterfaceIterator( _interfaces ); 149 return ONetwork::InterfaceIterator( _interfaces );
150} 150}
151 151
152 152
153bool ONetwork::isPresent( const char* name ) const 153bool ONetwork::isPresent( const char* name ) const
154{ 154{
155 int sfd = socket( AF_INET, SOCK_STREAM, 0 ); 155 int sfd = socket( AF_INET, SOCK_STREAM, 0 );
156 struct ifreq ifr; 156 struct ifreq ifr;
157 memset( &ifr, 0, sizeof( struct ifreq ) ); 157 memset( &ifr, 0, sizeof( struct ifreq ) );
158 strcpy( (char*) &ifr.ifr_name, name ); 158 strcpy( (char*) &ifr.ifr_name, name );
159 int result = ::ioctl( sfd, SIOCGIFFLAGS, &ifr ); 159 int result = ::ioctl( sfd, SIOCGIFFLAGS, &ifr );
160 return result != -1; 160 return result != -1;
161} 161}
162 162
163 163
164bool ONetwork::isWirelessInterface( const char* name ) const 164bool ONetwork::isWirelessInterface( const char* name ) const
165{ 165{
166 int sfd = socket( AF_INET, SOCK_STREAM, 0 ); 166 int sfd = socket( AF_INET, SOCK_STREAM, 0 );
167 struct iwreq iwr; 167 struct iwreq iwr;
168 memset( &iwr, 0, sizeof( struct iwreq ) ); 168 memset( &iwr, 0, sizeof( struct iwreq ) );
169 strcpy( (char*) &iwr.ifr_name, name ); 169 strcpy( (char*) &iwr.ifr_name, name );
170 int result = ::ioctl( sfd, SIOCGIWNAME, &iwr ); 170 int result = ::ioctl( sfd, SIOCGIWNAME, &iwr );
171 return result != -1; 171 return result != -1;
172} 172}
173 173
174/*====================================================================================== 174/*======================================================================================
175 * ONetworkInterface 175 * ONetworkInterface
176 *======================================================================================*/ 176 *======================================================================================*/
177 177
178ONetworkInterface::ONetworkInterface( QObject* parent, const char* name ) 178ONetworkInterface::ONetworkInterface( QObject* parent, const char* name )
179 :QObject( parent, name ), 179 :QObject( parent, name ),
180 _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 ) 180 _sfd( socket( AF_INET, SOCK_DGRAM, 0 ) ), _mon( 0 )
181{ 181{
182 odebug << "ONetworkInterface::ONetworkInterface()" << oendl; 182 odebug << "ONetworkInterface::ONetworkInterface()" << oendl;
183 init(); 183 init();
184} 184}
185 185
186 186
187struct ifreq& ONetworkInterface::ifr() const 187struct ifreq& ONetworkInterface::ifr() const
188{ 188{
189 return _ifr; 189 return _ifr;
190} 190}
191 191
192 192
193void ONetworkInterface::init() 193void ONetworkInterface::init()
194{ 194{
195 odebug << "ONetworkInterface::init()" << oendl; 195 odebug << "ONetworkInterface::init()" << oendl;
196 196
197 memset( &_ifr, 0, sizeof( struct ifreq ) ); 197 memset( &_ifr, 0, sizeof( struct ifreq ) );
198 198
199 if ( _sfd == -1 ) 199 if ( _sfd == -1 )
200 { 200 {
201 odebug << "ONetworkInterface::init(): Warning - can't get socket for device '" << name() << "'" << oendl; 201 odebug << "ONetworkInterface::init(): Warning - can't get socket for device '" << name() << "'" << oendl;
202 return; 202 return;
203 } 203 }
204} 204}
205 205
206 206
207bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const 207bool ONetworkInterface::ioctl( int call, struct ifreq& ifreq ) const
208{ 208{
209 #ifndef NODEBUG 209 #ifndef NODEBUG
210 int result = ::ioctl( _sfd, call, &ifreq ); 210 int result = ::ioctl( _sfd, call, &ifreq );
211 if ( result == -1 ) 211 if ( result == -1 )
212 odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call ) 212 odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call )
213 << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl; 213 << "' FAILED! " << result << " (" << strerror( errno ) << ")" << oendl;
214 else 214 else
215 odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call ) 215 odebug << "ONetworkInterface::ioctl (" << name() << ") call '" << debugmapper->map( call )
216 << "' - Status: Ok." << oendl; 216 << "' - Status: Ok." << oendl;
217 return ( result != -1 ); 217 return ( result != -1 );
218 #else 218 #else
219 return ::ioctl( _sfd, call, &ifreq ) != -1; 219 return ::ioctl( _sfd, call, &ifreq ) != -1;
220 #endif 220 #endif
221} 221}
222 222
223 223
224bool ONetworkInterface::ioctl( int call ) const 224bool ONetworkInterface::ioctl( int call ) const
225{ 225{
226 strcpy( _ifr.ifr_name, name() ); 226 strcpy( _ifr.ifr_name, name() );
227 return ioctl( call, _ifr ); 227 return ioctl( call, _ifr );
228} 228}
229 229
230 230
231bool ONetworkInterface::isLoopback() const 231bool ONetworkInterface::isLoopback() const
232{ 232{
233 ioctl( SIOCGIFFLAGS ); 233 ioctl( SIOCGIFFLAGS );
234 return _ifr.ifr_flags & IFF_LOOPBACK; 234 return _ifr.ifr_flags & IFF_LOOPBACK;
diff --git a/libopie2/opieui/big-screen/obigscreen_p.h b/libopie2/opieui/big-screen/obigscreen_p.h
index a85a56c..baa2bbc 100644
--- a/libopie2/opieui/big-screen/obigscreen_p.h
+++ b/libopie2/opieui/big-screen/obigscreen_p.h
@@ -1,31 +1,31 @@
1#ifndef OPIE_BIG_SCREEN_PRIVATE 1#ifndef OPIE_BIG_SCREEN_PRIVATE
2#define OPIE_BIG_SCREEN_PRIVATE 2#define OPIE_BIG_SCREEN_PRIVATE
3 3
4/* QT */ 4/* QT */
5#include <qstring.h> 5#include <qstring.h>
6 6
7class QWidget; 7class QWidget;
8 8
9namespace Opie { 9namespace Opie {
10namespace Ui { 10namespace Ui {
11namespace Private{ 11namespace Internal{
12 12
13struct OSplitterContainer 13struct OSplitterContainer
14{ 14{
15 bool operator==( const OSplitterContainer& o) const 15 bool operator==( const OSplitterContainer& o) const
16 { 16 {
17 if (widget != o.widget ) return false; 17 if (widget != o.widget ) return false;
18 if (icon != o.icon ) return false; 18 if (icon != o.icon ) return false;
19 if (name != o.name ) return false; 19 if (name != o.name ) return false;
20 return true; 20 return true;
21 } 21 }
22 QWidget* widget; 22 QWidget* widget;
23 QString icon; 23 QString icon;
24 QString name; 24 QString name;
25}; 25};
26 26
27} 27}
28} 28}
29} 29}
30 30
31#endif 31#endif
diff --git a/libopie2/opieui/big-screen/osplitter.cpp b/libopie2/opieui/big-screen/osplitter.cpp
index bcfd3a6..f0287ed 100644
--- a/libopie2/opieui/big-screen/osplitter.cpp
+++ b/libopie2/opieui/big-screen/osplitter.cpp
@@ -1,167 +1,167 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> 3             .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "osplitter.h" 29#include "osplitter.h"
30 30
31/* OPIE */ 31/* OPIE */
32#include <opie2/otabwidget.h> 32#include <opie2/otabwidget.h>
33 33
34/* QT */ 34/* QT */
35#include <qvaluelist.h> 35#include <qvaluelist.h>
36#include <qvbox.h> 36#include <qvbox.h>
37 37
38using namespace Opie::Ui; 38using namespace Opie::Ui;
39using namespace Opie::Ui::Private; 39using namespace Opie::Ui::Internal;
40 40
41/** 41/**
42 * 42 *
43 * This is the constructor of OSplitter 43 * This is the constructor of OSplitter
44 * You might want to call setSizeChange to tell 44 * You might want to call setSizeChange to tell
45 * OSplitter to change its layout when a specefic 45 * OSplitter to change its layout when a specefic
46 * mark was crossed. OSplitter sets a default value. 46 * mark was crossed. OSplitter sets a default value.
47 * 47 *
48 * You cann add widget with addWidget to the OSplitter. 48 * You cann add widget with addWidget to the OSplitter.
49 * OSplitter supports also grouping of Splitters where they 49 * OSplitter supports also grouping of Splitters where they
50 * can share one OTabBar in small screen mode. This can be used 50 * can share one OTabBar in small screen mode. This can be used
51 * for email clients like vies but see the example. 51 * for email clients like vies but see the example.
52 * 52 *
53 * @param orient The orientation wether to layout horizontal or vertical 53 * @param orient The orientation wether to layout horizontal or vertical
54 * @param parent The parent of this widget 54 * @param parent The parent of this widget
55 * @param name The name passed on to QObject 55 * @param name The name passed on to QObject
56 * @param fl Additional widgets flags passed to QWidget 56 * @param fl Additional widgets flags passed to QWidget
57 * 57 *
58 * @short single c'tor of the OSplitter 58 * @short single c'tor of the OSplitter
59 */ 59 */
60OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl ) 60OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl )
61 : QFrame( parent, name, fl ) 61 : QFrame( parent, name, fl )
62{ 62{
63 m_orient = orient; 63 m_orient = orient;
64 m_hbox = 0; 64 m_hbox = 0;
65 m_size_policy = 330; 65 m_size_policy = 330;
66 setFontPropagation( AllChildren ); 66 setFontPropagation( AllChildren );
67 setPalettePropagation( AllChildren ); 67 setPalettePropagation( AllChildren );
68 68
69 /* start by default with the tab widget */ 69 /* start by default with the tab widget */
70 m_tabWidget = 0; 70 m_tabWidget = 0;
71 m_parentTab = 0; 71 m_parentTab = 0;
72 changeTab(); 72 changeTab();
73 73
74} 74}
75 75
76 76
77/** 77/**
78 * Destructor destructs this object and cleans up. All child 78 * Destructor destructs this object and cleans up. All child
79 * widgets will be deleted 79 * widgets will be deleted
80 * @see addWidget 80 * @see addWidget
81 */ 81 */
82OSplitter::~OSplitter() 82OSplitter::~OSplitter()
83{ 83{
84 qWarning("Deleted Splitter"); 84 qWarning("Deleted Splitter");
85 m_splitter.setAutoDelete( true ); 85 m_splitter.setAutoDelete( true );
86 m_splitter.clear(); 86 m_splitter.clear();
87 87
88 delete m_hbox; 88 delete m_hbox;
89 delete m_tabWidget; 89 delete m_tabWidget;
90} 90}
91 91
92 92
93/** 93/**
94 * Sets the label for the Splitter. This label will be used 94 * Sets the label for the Splitter. This label will be used
95 * if a parent splitter is arranged as TabWidget but 95 * if a parent splitter is arranged as TabWidget but
96 * this splitter is in fullscreen mode. Then a tab with OSplitter::label() 96 * this splitter is in fullscreen mode. Then a tab with OSplitter::label()
97 * and iconName() gets added. 97 * and iconName() gets added.
98 * 98 *
99 * @param name The name of the Label 99 * @param name The name of the Label
100 */ 100 */
101void OSplitter::setLabel( const QString& name ) 101void OSplitter::setLabel( const QString& name )
102{ 102{
103 m_name = name; 103 m_name = name;
104} 104}
105 105
106/** 106/**
107 * @see setLabel but this is for the icon retrieved by Resource 107 * @see setLabel but this is for the icon retrieved by Resource
108 * 108 *
109 * @param name The name of the icon in example ( "zoom" ) 109 * @param name The name of the icon in example ( "zoom" )
110 */ 110 */
111void OSplitter::setIconName( const QString& name ) 111void OSplitter::setIconName( const QString& name )
112{ 112{
113 m_icon = name; 113 m_icon = name;
114} 114}
115 115
116 116
117/** 117/**
118 * returns the iconName 118 * returns the iconName
119 * @see setIconName 119 * @see setIconName
120 */ 120 */
121QString OSplitter::iconName()const 121QString OSplitter::iconName()const
122{ 122{
123 return m_icon; 123 return m_icon;
124} 124}
125 125
126/** 126/**
127 * returns the label set with setLabel 127 * returns the label set with setLabel
128 * @see setLabel 128 * @see setLabel
129 */ 129 */
130QString OSplitter::label()const 130QString OSplitter::label()const
131{ 131{
132 return m_name; 132 return m_name;
133} 133}
134 134
135/** 135/**
136 * This function sets the size change policy of the splitter. 136 * This function sets the size change policy of the splitter.
137 * If this size marked is crossed the splitter will relayout. 137 * If this size marked is crossed the splitter will relayout.
138 * Note: that depending on the set Orientation it'll either look 138 * Note: that depending on the set Orientation it'll either look
139 * at the width or height. 139 * at the width or height.
140 * Note: If you want to from side to side view to tabbed view you need 140 * Note: If you want to from side to side view to tabbed view you need
141 * to make sure that the size you supply is not smaller than the minimum 141 * to make sure that the size you supply is not smaller than the minimum
142 * size of your added widgets. Note that if you use widgets like QComboBoxes 142 * size of your added widgets. Note that if you use widgets like QComboBoxes
143 * you need to teach them to accept smaller sizes as well @see QWidget::setSizePolicy 143 * you need to teach them to accept smaller sizes as well @see QWidget::setSizePolicy
144 * 144 *
145 * @param width_height The mark that will be watched. Interpreted depending on the Orientation of the Splitter. 145 * @param width_height The mark that will be watched. Interpreted depending on the Orientation of the Splitter.
146 * @return void 146 * @return void
147 */ 147 */
148void OSplitter::setSizeChange( int width_height ) 148void OSplitter::setSizeChange( int width_height )
149{ 149{
150 m_size_policy = width_height; 150 m_size_policy = width_height;
151 QSize sz(width(), height() ); 151 QSize sz(width(), height() );
152 QResizeEvent ev(sz, sz ); 152 QResizeEvent ev(sz, sz );
153 resizeEvent(&ev); 153 resizeEvent(&ev);
154} 154}
155 155
156/** 156/**
157 * This functions allows to add another OSplitter and to share 157 * This functions allows to add another OSplitter and to share
158 * the OTabBar in small screen mode. The ownerships gets transfered. 158 * the OTabBar in small screen mode. The ownerships gets transfered.
159 * OSplitters are always added after normal widget items 159 * OSplitters are always added after normal widget items
160 */ 160 */
161void OSplitter::addWidget( OSplitter* split ) 161void OSplitter::addWidget( OSplitter* split )
162{ 162{
163 m_splitter.append( split ); 163 m_splitter.append( split );
164 164
165 /* 165 /*
166 * set tab widget 166 * set tab widget
167 */ 167 */
@@ -272,271 +272,271 @@ void OSplitter::removeWidget( QWidget* w)
272 * This method will give focus to the widget. If in a tabwidget 272 * This method will give focus to the widget. If in a tabwidget
273 * the tabbar will be changed 273 * the tabbar will be changed
274 * 274 *
275 * @param w The widget which will be set the current one 275 * @param w The widget which will be set the current one
276 */ 276 */
277void OSplitter::setCurrentWidget( QWidget* w) 277void OSplitter::setCurrentWidget( QWidget* w)
278{ 278{
279 if (m_tabWidget ) 279 if (m_tabWidget )
280 m_tabWidget->setCurrentTab( w ); 280 m_tabWidget->setCurrentTab( w );
281 // else 281 // else
282 // m_hbox->setFocus( w ); 282 // m_hbox->setFocus( w );
283 283
284} 284}
285 285
286/** 286/**
287 * This is an overloaded member function and only differs in the 287 * This is an overloaded member function and only differs in the
288 * argument it takes. 288 * argument it takes.
289 * Searches list of widgets for label. It'll pick the first label it finds 289 * Searches list of widgets for label. It'll pick the first label it finds
290 * 290 *
291 * @param label Label to look for. First match will be taken 291 * @param label Label to look for. First match will be taken
292 */ 292 */
293void OSplitter::setCurrentWidget( const QString& label ) 293void OSplitter::setCurrentWidget( const QString& label )
294{ 294{
295 ContainerList::Iterator it; 295 ContainerList::Iterator it;
296 for (it = m_container.begin(); it != m_container.end(); ++it ) 296 for (it = m_container.begin(); it != m_container.end(); ++it )
297 { 297 {
298 if ( (*it).name == label ) 298 if ( (*it).name == label )
299 { 299 {
300 setCurrentWidget( (*it).widget ); 300 setCurrentWidget( (*it).widget );
301 break; 301 break;
302 } 302 }
303 } 303 }
304} 304}
305 305
306/** 306/**
307 * This will only work when the TabWidget is active 307 * This will only work when the TabWidget is active
308 * If everything is visible this signal is kindly ignored 308 * If everything is visible this signal is kindly ignored
309 * @see OTabWidget::setCurrentTab(int) 309 * @see OTabWidget::setCurrentTab(int)
310 * 310 *
311 * @param tab The tab to make current 311 * @param tab The tab to make current
312 */ 312 */
313void OSplitter::setCurrentWidget( int tab ) 313void OSplitter::setCurrentWidget( int tab )
314{ 314{
315 if (m_tabWidget ) 315 if (m_tabWidget )
316 m_tabWidget->setCurrentTab( tab ); 316 m_tabWidget->setCurrentTab( tab );
317} 317}
318 318
319/** 319/**
320 * return the currently activated widget if in tab widget mode 320 * return the currently activated widget if in tab widget mode
321 * or null because all widgets are visible 321 * or null because all widgets are visible
322 */ 322 */
323QWidget* OSplitter::currentWidget() const 323QWidget* OSplitter::currentWidget() const
324{ 324{
325 if (m_tabWidget) 325 if (m_tabWidget)
326 return m_tabWidget->currentWidget(); 326 return m_tabWidget->currentWidget();
327 else if (m_parentTab ) 327 else if (m_parentTab )
328 return m_parentTab->currentWidget(); 328 return m_parentTab->currentWidget();
329 329
330 return 0l; 330 return 0l;
331} 331}
332/* wrong */ 332/* wrong */
333#if 0 333#if 0
334/** 334/**
335 * @reimplented for internal reasons 335 * @reimplented for internal reasons
336 * returns the sizeHint of one of its sub widgets 336 * returns the sizeHint of one of its sub widgets
337 */ 337 */
338QSize OSplitter::sizeHint()const 338QSize OSplitter::sizeHint()const
339{ 339{
340 if (m_parentTab ) 340 if (m_parentTab )
341 return QFrame::sizeHint(); 341 return QFrame::sizeHint();
342 342
343 if (m_hbox ) 343 if (m_hbox )
344 return m_hbox->sizeHint(); 344 return m_hbox->sizeHint();
345 else 345 else
346 return m_tabWidget->sizeHint(); 346 return m_tabWidget->sizeHint();
347} 347}
348 348
349QSize OSplitter::minimumSizeHint()const 349QSize OSplitter::minimumSizeHint()const
350{ 350{
351 if (m_parentTab ) 351 if (m_parentTab )
352 return QFrame::minimumSizeHint(); 352 return QFrame::minimumSizeHint();
353 if (m_hbox) 353 if (m_hbox)
354 return m_hbox->sizeHint(); 354 return m_hbox->sizeHint();
355 else 355 else
356 return m_tabWidget->sizeHint(); 356 return m_tabWidget->sizeHint();
357} 357}
358#endif 358#endif
359 359
360/** 360/**
361 * @reimplemented for internal reasons 361 * @reimplemented for internal reasons
362 */ 362 */
363void OSplitter::resizeEvent( QResizeEvent* res ) 363void OSplitter::resizeEvent( QResizeEvent* res )
364{ 364{
365 QFrame::resizeEvent( res ); 365 QFrame::resizeEvent( res );
366 /* 366 /*
367 * 367 *
368 */ 368 */
369 // qWarning("Old size was width = %d height = %d", res->oldSize().width(), res->oldSize().height() ); 369 // qWarning("Old size was width = %d height = %d", res->oldSize().width(), res->oldSize().height() );
370 bool mode = true; 370 bool mode = true;
371 qWarning("New size is width = %d height = %d %s", res->size().width(), res->size().height(), name() ); 371 qWarning("New size is width = %d height = %d %s", res->size().width(), res->size().height(), name() );
372 if ( res->size().width() > m_size_policy && 372 if ( res->size().width() > m_size_policy &&
373 m_orient == Horizontal ) 373 m_orient == Horizontal )
374 { 374 {
375 changeHBox(); 375 changeHBox();
376 mode = false; 376 mode = false;
377 } 377 }
378 else if ( (res->size().width() <= m_size_policy && 378 else if ( (res->size().width() <= m_size_policy &&
379 m_orient == Horizontal ) || 379 m_orient == Horizontal ) ||
380 (res->size().height() <= m_size_policy && 380 (res->size().height() <= m_size_policy &&
381 m_orient == Vertical ) ) 381 m_orient == Vertical ) )
382 { 382 {
383 changeTab(); 383 changeTab();
384 } 384 }
385 else if ( res->size().height() > m_size_policy && 385 else if ( res->size().height() > m_size_policy &&
386 m_orient == Vertical ) 386 m_orient == Vertical )
387 { 387 {
388 qWarning("Changng to vbox %s", name() ); 388 qWarning("Changng to vbox %s", name() );
389 changeVBox(); 389 changeVBox();
390 mode = false; 390 mode = false;
391 } 391 }
392 392
393 emit sizeChanged(mode, m_orient ); 393 emit sizeChanged(mode, m_orient );
394} 394}
395 395
396/* 396/*
397 * Adds a container to a tab either the parent tab 397 * Adds a container to a tab either the parent tab
398 * or our own 398 * or our own
399 */ 399 */
400void OSplitter::addToTab( const Opie::Ui::Private::OSplitterContainer& con ) 400void OSplitter::addToTab( const Opie::Ui::Internal::OSplitterContainer& con )
401{ 401{
402 QWidget *wid = con.widget; 402 QWidget *wid = con.widget;
403 // not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) ); 403 // not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) );
404 if (m_parentTab ) 404 if (m_parentTab )
405 m_parentTab->addTab( wid, con.icon, con.name ); 405 m_parentTab->addTab( wid, con.icon, con.name );
406 else 406 else
407 m_tabWidget->addTab( wid, con.icon, con.name ); 407 m_tabWidget->addTab( wid, con.icon, con.name );
408} 408}
409 409
410 410
411/* 411/*
412 * adds a container to the box 412 * adds a container to the box
413 */ 413 */
414void OSplitter::addToBox( const Opie::Ui::Private::OSplitterContainer& con ) 414void OSplitter::addToBox( const Opie::Ui::Internal::OSplitterContainer& con )
415{ 415{
416 QWidget* wid = con.widget; 416 QWidget* wid = con.widget;
417 wid->reparent(m_hbox, 0, QPoint(0, 0) ); 417 wid->reparent(m_hbox, 0, QPoint(0, 0) );
418} 418}
419 419
420 420
421/* 421/*
422 * Removes a widget from the tab 422 * Removes a widget from the tab
423 */ 423 */
424void OSplitter::removeFromTab( QWidget* wid ) 424void OSplitter::removeFromTab( QWidget* wid )
425{ 425{
426 if (m_parentTab ) 426 if (m_parentTab )
427 m_parentTab->removePage( wid ); 427 m_parentTab->removePage( wid );
428 else 428 else
429 m_tabWidget->removePage( wid ); 429 m_tabWidget->removePage( wid );
430} 430}
431 431
432/* 432/*
433 * switches over to a OTabWidget layout 433 * switches over to a OTabWidget layout
434 * it is recursive 434 * it is recursive
435 */ 435 */
436void OSplitter::changeTab() 436void OSplitter::changeTab()
437{ 437{
438 /* if we're the owner of the tab widget */ 438 /* if we're the owner of the tab widget */
439 if (m_tabWidget ) 439 if (m_tabWidget )
440 { 440 {
441 raise(); 441 raise();
442 show(); 442 show();
443 m_tabWidget->setGeometry( frameRect() ); 443 m_tabWidget->setGeometry( frameRect() );
444 return; 444 return;
445 } 445 }
446 446
447 qWarning(" New Tab Widget %s", name() ); 447 qWarning(" New Tab Widget %s", name() );
448 /* 448 /*
449 * and add all widgets this will reparent them 449 * and add all widgets this will reparent them
450 * delete m_hbox set it to 0 450 * delete m_hbox set it to 0
451 * 451 *
452 */ 452 */
453 OTabWidget *tab; 453 OTabWidget *tab;
454 if ( m_parentTab ) 454 if ( m_parentTab )
455 { 455 {
456 hide(); 456 hide();
457 tab = m_parentTab; 457 tab = m_parentTab;
458 /* expensive but needed cause we're called from setTabWidget and resizeEvent*/ 458 /* expensive but needed cause we're called from setTabWidget and resizeEvent*/
459 if (!m_container.isEmpty() ) 459 if (!m_container.isEmpty() )
460 { 460 {
461 ContainerList::Iterator it = m_container.begin(); 461 ContainerList::Iterator it = m_container.begin();
462 for (; it != m_container.end(); ++it ) 462 for (; it != m_container.end(); ++it )
463 m_parentTab->removePage( (*it).widget ); 463 m_parentTab->removePage( (*it).widget );
464 } 464 }
465 } 465 }
466 else 466 else
467 tab = m_tabWidget = new OTabWidget( this ); 467 tab = m_tabWidget = new OTabWidget( this );
468 468
469 connect(tab, SIGNAL(currentChanged(QWidget*) ), 469 connect(tab, SIGNAL(currentChanged(QWidget*) ),
470 this, SIGNAL(currentChanged(QWidget*) ) ); 470 this, SIGNAL(currentChanged(QWidget*) ) );
471 471
472 for ( ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) 472 for ( ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it )
473 { 473 {
474 qWarning("Widget is %s", (*it).name.latin1() ); 474 qWarning("Widget is %s", (*it).name.latin1() );
475 addToTab( (*it) ); 475 addToTab( (*it) );
476 } 476 }
477 477
478 for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) 478 for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() )
479 { 479 {
480 split->reparent(this, 0, QPoint(0, 0) ); 480 split->reparent(this, 0, QPoint(0, 0) );
481 split->setTabWidget( tab ); 481 split->setTabWidget( tab );
482 } 482 }
483 483
484 484
485 delete m_hbox; 485 delete m_hbox;
486 m_hbox = 0; 486 m_hbox = 0;
487 if (!m_tabWidget ) 487 if (!m_tabWidget )
488 return; 488 return;
489 489
490 m_tabWidget->setGeometry( frameRect() ); 490 m_tabWidget->setGeometry( frameRect() );
491 m_tabWidget->show(); 491 m_tabWidget->show();
492 492
493} 493}
494 494
495/* 495/*
496 * changes over to a box 496 * changes over to a box
497 * this is recursive as well 497 * this is recursive as well
498 */ 498 */
499void OSplitter::changeHBox() 499void OSplitter::changeHBox()
500{ 500{
501 if (m_hbox ) 501 if (m_hbox )
502 { 502 {
503 m_hbox->setGeometry( frameRect() ); 503 m_hbox->setGeometry( frameRect() );
504 return; 504 return;
505 } 505 }
506 506
507 qWarning("new HBox %s", name() ); 507 qWarning("new HBox %s", name() );
508 m_hbox = new QHBox( this ); 508 m_hbox = new QHBox( this );
509 commonChangeBox(); 509 commonChangeBox();
510} 510}
511 511
512void OSplitter::changeVBox() 512void OSplitter::changeVBox()
513{ 513{
514 if (m_hbox ) 514 if (m_hbox )
515 { 515 {
516 m_hbox->setGeometry( frameRect() ); 516 m_hbox->setGeometry( frameRect() );
517 return; 517 return;
518 } 518 }
519 519
520 qWarning("New VBOX %s", name() ); 520 qWarning("New VBOX %s", name() );
521 m_hbox = new QVBox( this ); 521 m_hbox = new QVBox( this );
522 522
523 commonChangeBox(); 523 commonChangeBox();
524 524
525} 525}
526 526
527/* 527/*
528 * common box code 528 * common box code
529 * first remove and add children 529 * first remove and add children
530 * the other splitters 530 * the other splitters
531 * it is recursive as well due the call to setTabWidget 531 * it is recursive as well due the call to setTabWidget
532 */ 532 */
533void OSplitter::commonChangeBox() 533void OSplitter::commonChangeBox()
534{ 534{
535 qWarning(" Name of Splitters is %s", name() ); 535 qWarning(" Name of Splitters is %s", name() );
536 536
537 for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) 537 for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it )
538 { 538 {
539 /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */ 539 /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */
540 if (m_parentTab ) 540 if (m_parentTab )
541 removeFromTab( (*it).widget ); 541 removeFromTab( (*it).widget );
542 qWarning("Adding to box %s", (*it).name.latin1() ); 542 qWarning("Adding to box %s", (*it).name.latin1() );
diff --git a/libopie2/opieui/big-screen/osplitter.h b/libopie2/opieui/big-screen/osplitter.h
index 7b5ea53..46dad05 100644
--- a/libopie2/opieui/big-screen/osplitter.h
+++ b/libopie2/opieui/big-screen/osplitter.h
@@ -1,151 +1,151 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> 3             .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef OSPLITTER_H 29#ifndef OSPLITTER_H
30#define OSPLITTER_H 30#define OSPLITTER_H
31 31
32#include "obigscreen_p.h" 32#include "obigscreen_p.h"
33 33
34/* QT */ 34/* QT */
35#include <qframe.h> 35#include <qframe.h>
36#include <qlist.h> 36#include <qlist.h>
37#include <qstring.h> 37#include <qstring.h>
38#include <qvaluelist.h> 38#include <qvaluelist.h>
39 39
40class QHBox; 40class QHBox;
41 41
42//template class QValueList<Opie::OSplitterContainer>; 42//template class QValueList<Opie::OSplitterContainer>;
43 43
44/* 44/*
45 * TODO 45 * TODO
46 * -check API docu 46 * -check API docu
47 * -one more example 47 * -one more example
48 * -allow inserting at a position 48 * -allow inserting at a position
49 */ 49 */
50 50
51namespace Opie{ 51namespace Opie{
52namespace Ui { 52namespace Ui {
53class OTabWidget; 53class OTabWidget;
54 54
55/** 55/**
56 * 56 *
57 * If you've widgets that could be placed side by side but you think 57 * If you've widgets that could be placed side by side but you think
58 * on small resolutions is not enough place but it would really make sense 58 * on small resolutions is not enough place but it would really make sense
59 * on bigger resolutions this class will help you. 59 * on bigger resolutions this class will help you.
60 * You can add as many widgets you want to it. Set a poliy on which width/height it 60 * You can add as many widgets you want to it. Set a poliy on which width/height it
61 * should switch the layout. 61 * should switch the layout.
62 * You can either say to place widgets vertical or horizontal. 62 * You can either say to place widgets vertical or horizontal.
63 * This class uses QHBox, QVBox and QTAbWidget internally. 63 * This class uses QHBox, QVBox and QTAbWidget internally.
64 * OSplitter takes ownership of the widgets 64 * OSplitter takes ownership of the widgets
65 * 65 *
66 * @since 1.2 66 * @since 1.2
67 * 67 *
68 * @short a small dynamically changing its layout to store two or more widgets side by side 68 * @short a small dynamically changing its layout to store two or more widgets side by side
69 * @version 0.1 69 * @version 0.1
70 * @author zecke 70 * @author zecke
71 */ 71 */
72class OSplitter : public QFrame 72class OSplitter : public QFrame
73{ 73{
74 Q_OBJECT 74 Q_OBJECT
75public: 75public:
76 typedef QValueList<Opie::Ui::Private::OSplitterContainer> ContainerList; 76 typedef QValueList<Opie::Ui::Internal::OSplitterContainer> ContainerList;
77 OSplitter( Qt::Orientation = Horizontal, QWidget *parent = 0, 77 OSplitter( Qt::Orientation = Horizontal, QWidget *parent = 0,
78 const char* name = 0, WFlags fl = 0 ); 78 const char* name = 0, WFlags fl = 0 );
79 ~OSplitter(); 79 ~OSplitter();
80 80
81 void setLabel( const QString& name ); 81 void setLabel( const QString& name );
82 void setIconName( const QString& name ); 82 void setIconName( const QString& name );
83 QString label()const; 83 QString label()const;
84 QString iconName()const; 84 QString iconName()const;
85 85
86 void setSizeChange( int width_height ); 86 void setSizeChange( int width_height );
87 87
88 void addWidget( OSplitter* splitter ); 88 void addWidget( OSplitter* splitter );
89 void addWidget( QWidget* wid, const QString& icon, const QString& label ); 89 void addWidget( QWidget* wid, const QString& icon, const QString& label );
90 void removeWidget( QWidget* ); 90 void removeWidget( QWidget* );
91 void removeWidget( OSplitter* ); 91 void removeWidget( OSplitter* );
92 92
93 void setCurrentWidget( QWidget* ); 93 void setCurrentWidget( QWidget* );
94 void setCurrentWidget( const QString& label ); 94 void setCurrentWidget( const QString& label );
95 void setCurrentWidget( int ); 95 void setCurrentWidget( int );
96 QWidget* currentWidget()const; 96 QWidget* currentWidget()const;
97 97
98 98
99signals: 99signals:
100 /** 100 /**
101 * Emitted if in tab and comes directly from the tab widget 101 * Emitted if in tab and comes directly from the tab widget
102 * 102 *
103 */ 103 */
104 void currentChanged( QWidget* ); 104 void currentChanged( QWidget* );
105 105
106 /** 106 /**
107 * emitted whenever a border is crossed 107 * emitted whenever a border is crossed
108 * true if in small screen mode 108 * true if in small screen mode
109 * false if in bigscreen 109 * false if in bigscreen
110 * this signal is emitted after the layout switch 110 * this signal is emitted after the layout switch
111 * @param b The layout mode 111 * @param b The layout mode
112 * @param ori The orientation 112 * @param ori The orientation
113 */ 113 */
114 void sizeChanged( bool b, Orientation ori); 114 void sizeChanged( bool b, Orientation ori);
115public: 115public:
116 // QSize sizeHint()const; 116 // QSize sizeHint()const;
117 // QSize minimumSizeHint()const; 117 // QSize minimumSizeHint()const;
118 118
119protected: 119protected:
120 void resizeEvent( QResizeEvent* ); 120 void resizeEvent( QResizeEvent* );
121 121
122private: 122private:
123 /* true if OTabMode */ 123 /* true if OTabMode */
124 bool layoutMode()const; 124 bool layoutMode()const;
125 // void reparentAll(); 125 // void reparentAll();
126 void setTabWidget( OTabWidget*); 126 void setTabWidget( OTabWidget*);
127 void addToTab( const Opie::Ui::Private::OSplitterContainer& ); 127 void addToTab( const Opie::Ui::Internal::OSplitterContainer& );
128 void addToBox( const Opie::Ui::Private::OSplitterContainer& ); 128 void addToBox( const Opie::Ui::Internal::OSplitterContainer& );
129 void removeFromTab( QWidget* ); 129 void removeFromTab( QWidget* );
130 void changeTab(); 130 void changeTab();
131 void changeHBox(); 131 void changeHBox();
132 void changeVBox(); 132 void changeVBox();
133 void commonChangeBox(); 133 void commonChangeBox();
134 QHBox *m_hbox; 134 QHBox *m_hbox;
135 OTabWidget *m_tabWidget; 135 OTabWidget *m_tabWidget;
136 OTabWidget *m_parentTab; 136 OTabWidget *m_parentTab;
137 Orientation m_orient; 137 Orientation m_orient;
138 int m_size_policy; 138 int m_size_policy;
139 139
140 ContainerList m_container; 140 ContainerList m_container;
141 QList<OSplitter> m_splitter; 141 QList<OSplitter> m_splitter;
142 142
143 QString m_icon, m_name; 143 QString m_icon, m_name;
144 144
145 struct Private; 145 struct Private;
146 Private *d; 146 Private *d;
147}; 147};
148} 148}
149} 149}
150 150
151#endif 151#endif
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp
index c4d5033..a9ec8c4 100644
--- a/libopie2/opieui/fileselector/ofileselector.cpp
+++ b/libopie2/opieui/fileselector/ofileselector.cpp
@@ -1,190 +1,191 @@
1
1/* 2/*
2               =. This file is part of the OPIE Project 3               =. This file is part of the OPIE Project
3             .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org> 4             .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org>
4           .>+-= 5           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 6 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 12    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 13    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 19++=   -.     .`     .: details.
19 :     =  ...= . :.=- 20 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
26 27
27*/ 28*/
28 29
29/* hacky but we need to get FileSelector::filter */ 30/* hacky but we need to get FileSelector::filter */
30#define private public 31#define private public
31#include <qpe/fileselector.h> 32#include <qpe/fileselector.h>
32#undef private 33#undef private
33 34
34#include "ofileselector_p.h" 35#include "ofileselector_p.h"
35 36
36/* OPIE */ 37/* OPIE */
37#include <opie2/ofileselector.h> 38#include <opie2/ofileselector.h>
38 39
39#include <qpe/qpeapplication.h> 40#include <qpe/qpeapplication.h>
40#include <qpe/mimetype.h> 41#include <qpe/mimetype.h>
41#include <qpe/resource.h> 42#include <qpe/resource.h>
42#include <qpe/storage.h> 43#include <qpe/storage.h>
43 44
44/* QT */ 45/* QT */
45#include <qcombobox.h> 46#include <qcombobox.h>
46#include <qdir.h> 47#include <qdir.h>
47#include <qhbox.h> 48#include <qhbox.h>
48#include <qheader.h> 49#include <qheader.h>
49#include <qlabel.h> 50#include <qlabel.h>
50#include <qlayout.h> 51#include <qlayout.h>
51#include <qlineedit.h> 52#include <qlineedit.h>
52#include <qlistview.h> 53#include <qlistview.h>
53#include <qpopupmenu.h> 54#include <qpopupmenu.h>
54#include <qwidgetstack.h> 55#include <qwidgetstack.h>
55#include <qregexp.h> 56#include <qregexp.h>
56#include <qobjectlist.h> 57#include <qobjectlist.h>
57 58
58using namespace Opie::Ui::Private; 59using namespace Opie::Ui::Internal;
59 60
60namespace Opie { 61namespace Opie {
61namespace Ui { 62namespace Ui {
62namespace Private { 63namespace Internal {
63OFileViewInterface::OFileViewInterface( OFileSelector* selector ) 64OFileViewInterface::OFileViewInterface( OFileSelector* selector )
64 : m_selector( selector ) 65 : m_selector( selector )
65{} 66{}
66 67
67OFileViewInterface::~OFileViewInterface() 68OFileViewInterface::~OFileViewInterface()
68{} 69{}
69 70
70QString OFileViewInterface::name()const 71QString OFileViewInterface::name()const
71{ 72{
72 return m_name; 73 return m_name;
73} 74}
74 75
75void OFileViewInterface::setName( const QString& name ) 76void OFileViewInterface::setName( const QString& name )
76{ 77{
77 m_name = name; 78 m_name = name;
78} 79}
79 80
80OFileSelector* OFileViewInterface::selector()const 81OFileSelector* OFileViewInterface::selector()const
81{ 82{
82 return m_selector; 83 return m_selector;
83} 84}
84 85
85DocLnk OFileViewInterface::selectedDocument()const 86DocLnk OFileViewInterface::selectedDocument()const
86{ 87{
87 return DocLnk( selectedName() ); 88 return DocLnk( selectedName() );
88} 89}
89 90
90bool OFileViewInterface::showNew()const 91bool OFileViewInterface::showNew()const
91{ 92{
92 return selector()->showNew(); 93 return selector()->showNew();
93} 94}
94 95
95bool OFileViewInterface::showClose()const 96bool OFileViewInterface::showClose()const
96{ 97{
97 return selector()->showClose(); 98 return selector()->showClose();
98} 99}
99 100
100MimeTypes OFileViewInterface::mimeTypes()const 101MimeTypes OFileViewInterface::mimeTypes()const
101{ 102{
102 return selector()->mimeTypes(); 103 return selector()->mimeTypes();
103} 104}
104 105
105QStringList OFileViewInterface::currentMimeType()const 106QStringList OFileViewInterface::currentMimeType()const
106{ 107{
107 return selector()->currentMimeType(); 108 return selector()->currentMimeType();
108} 109}
109 110
110void OFileViewInterface::activate( const QString& ) 111void OFileViewInterface::activate( const QString& )
111{ 112{
112 // not implemented here 113 // not implemented here
113} 114}
114 115
115void OFileViewInterface::ok() 116void OFileViewInterface::ok()
116{ 117{
117 emit selector()->ok(); 118 emit selector()->ok();
118} 119}
119 120
120void OFileViewInterface::cancel() 121void OFileViewInterface::cancel()
121{ 122{
122 emit selector()->cancel(); 123 emit selector()->cancel();
123} 124}
124 125
125void OFileViewInterface::closeMe() 126void OFileViewInterface::closeMe()
126{ 127{
127 emit selector()->closeMe(); 128 emit selector()->closeMe();
128} 129}
129 130
130void OFileViewInterface::fileSelected( const QString& str) 131void OFileViewInterface::fileSelected( const QString& str)
131{ 132{
132 emit selector()->fileSelected( str); 133 emit selector()->fileSelected( str);
133} 134}
134 135
135void OFileViewInterface::fileSelected( const DocLnk& lnk) 136void OFileViewInterface::fileSelected( const DocLnk& lnk)
136{ 137{
137 emit selector()->fileSelected( lnk ); 138 emit selector()->fileSelected( lnk );
138} 139}
139 140
140void OFileViewInterface::setCurrentFileName( const QString& str ) 141void OFileViewInterface::setCurrentFileName( const QString& str )
141{ 142{
142 selector()->m_lneEdit->setText( str ); 143 selector()->m_lneEdit->setText( str );
143} 144}
144 145
145QString OFileViewInterface::currentFileName()const 146QString OFileViewInterface::currentFileName()const
146{ 147{
147 return selector()->m_lneEdit->text(); 148 return selector()->m_lneEdit->text();
148} 149}
149 150
150QString OFileViewInterface::startDirectory()const 151QString OFileViewInterface::startDirectory()const
151{ 152{
152 return selector()->m_startDir; 153 return selector()->m_startDir;
153} 154}
154 155
155ODocumentFileView::ODocumentFileView( OFileSelector* selector ) 156ODocumentFileView::ODocumentFileView( OFileSelector* selector )
156 :OFileViewInterface( selector ) 157 :OFileViewInterface( selector )
157{ 158{
158 m_selector = 0; 159 m_selector = 0;
159 setName( QObject::tr("Documents") ); 160 setName( QObject::tr("Documents") );
160} 161}
161 162
162ODocumentFileView::~ODocumentFileView() 163ODocumentFileView::~ODocumentFileView()
163{ 164{
164} 165}
165 166
166QString ODocumentFileView::selectedName()const 167QString ODocumentFileView::selectedName()const
167{ 168{
168 if (!m_selector) 169 if (!m_selector)
169 return QString::null; 170 return QString::null;
170 171
171 return m_selector->selectedDocument().file(); 172 return m_selector->selectedDocument().file();
172} 173}
173 174
174QString ODocumentFileView::selectedPath()const 175QString ODocumentFileView::selectedPath()const
175{ 176{
176 return QPEApplication::documentDir(); 177 return QPEApplication::documentDir();
177} 178}
178 179
179QString ODocumentFileView::directory()const 180QString ODocumentFileView::directory()const
180{ 181{
181 return selectedPath(); 182 return selectedPath();
182} 183}
183 184
184void ODocumentFileView::reread() 185void ODocumentFileView::reread()
185{ 186{
186 if (!m_selector) 187 if (!m_selector)
187 return; 188 return;
188 189
189 m_selector->setNewVisible( showNew() ); 190 m_selector->setNewVisible( showNew() );
190 m_selector->setCloseVisible( showClose() ); 191 m_selector->setCloseVisible( showClose() );
diff --git a/libopie2/opieui/fileselector/ofileselector.h b/libopie2/opieui/fileselector/ofileselector.h
index 2205963..8bcd9ee 100644
--- a/libopie2/opieui/fileselector/ofileselector.h
+++ b/libopie2/opieui/fileselector/ofileselector.h
@@ -1,222 +1,222 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org> 3             .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29/* 29/*
30 This is based on code and ideas of 30 This is based on code and ideas of
31 L. J. Potter ljp@llornkcor.com 31 L. J. Potter ljp@llornkcor.com
32 Thanks a lot 32 Thanks a lot
33*/ 33*/
34 34
35#ifndef OFILESELECTOR_H 35#ifndef OFILESELECTOR_H
36#define OFILESELECTOR_H 36#define OFILESELECTOR_H
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/applnk.h> 39#include <qpe/applnk.h>
40 40
41/* QT */ 41/* QT */
42#include <qlist.h> 42#include <qlist.h>
43#include <qwidget.h> 43#include <qwidget.h>
44#include <qmap.h> 44#include <qmap.h>
45#include <qvaluelist.h> 45#include <qvaluelist.h>
46#include <qstringlist.h> 46#include <qstringlist.h>
47 47
48class QLineEdit; 48class QLineEdit;
49class QComboBox; 49class QComboBox;
50class QWidgetStack; 50class QWidgetStack;
51class QHBox; 51class QHBox;
52 52
53typedef QMap<QString, QStringList> MimeTypes; 53typedef QMap<QString, QStringList> MimeTypes;
54 54
55namespace Opie { 55namespace Opie {
56namespace Ui { 56namespace Ui {
57 57
58namespace Private { 58namespace Internal {
59class OFileViewInterface; 59class OFileViewInterface;
60class OFileViewFileListView; 60class OFileViewFileListView;
61} 61}
62 62
63 63
64/** 64/**
65 * @short a dropin replacement for the FileSelector 65 * @short a dropin replacement for the FileSelector
66 * 66 *
67 * This class is first used insert the OFileDialog. 67 * This class is first used insert the OFileDialog.
68 * It supports multiple view and mimetype filtering for now. 68 * It supports multiple view and mimetype filtering for now.
69 * 69 *
70 * @see OFileDialog 70 * @see OFileDialog
71 * @see FileSelector 71 * @see FileSelector
72 * @author zecke 72 * @author zecke
73 * @version 0.1 73 * @version 0.1
74 */ 74 */
75class OFileSelector : public QWidget 75class OFileSelector : public QWidget
76{ 76{
77 Q_OBJECT 77 Q_OBJECT
78 friend class Private::OFileViewInterface; 78 friend class Internal::OFileViewInterface;
79 friend class Private::OFileViewFileListView; 79 friend class Internal::OFileViewFileListView;
80 80
81public: 81public:
82 /** 82 /**
83 * The Mode of the Fileselector 83 * The Mode of the Fileselector
84 * Open = Open A File 84 * Open = Open A File
85 * Save = Save a File 85 * Save = Save a File
86 * FILESELECTOR = As A GUI in a screen to select a file 86 * FILESELECTOR = As A GUI in a screen to select a file
87 */ 87 */
88 enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 }; 88 enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 };
89 // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 }; 89 // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 };
90 /** 90 /**
91 * Normal = The old FileSelector 91 * Normal = The old FileSelector
92 * Extended = Dir View 92 * Extended = Dir View
93 * ExtendedAll = Dir View with all hidden files 93 * ExtendedAll = Dir View with all hidden files
94 * Default = What the vendor considers best 94 * Default = What the vendor considers best
95 */ 95 */
96 enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 }; 96 enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 };
97 // enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2}; 97 // enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2};
98 98
99 OFileSelector(QWidget* parent, int mode, int selector, 99 OFileSelector(QWidget* parent, int mode, int selector,
100 const QString& dirName, 100 const QString& dirName,
101 const QString& fileName, 101 const QString& fileName,
102 const MimeTypes& mimetypes = MimeTypes(), 102 const MimeTypes& mimetypes = MimeTypes(),
103 bool newVisible = FALSE, bool closeVisible = FALSE ); 103 bool newVisible = FALSE, bool closeVisible = FALSE );
104 104
105 OFileSelector(const QString& mimeFilter, QWidget* parent, 105 OFileSelector(const QString& mimeFilter, QWidget* parent,
106 const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE ); 106 const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE );
107 ~OFileSelector(); 107 ~OFileSelector();
108 108
109 const DocLnk* selected(); 109 const DocLnk* selected();
110 110
111 QString selectedName()const; 111 QString selectedName()const;
112 QString selectedPath()const; 112 QString selectedPath()const;
113 QString directory()const; 113 QString directory()const;
114 114
115 DocLnk selectedDocument()const; 115 DocLnk selectedDocument()const;
116 116
117 int fileCount()const; 117 int fileCount()const;
118 void reread(); 118 void reread();
119 119
120 int mode()const; 120 int mode()const;
121 int selector()const; 121 int selector()const;
122 122
123 /** 123 /**
124 * Set the Icon visible 124 * Set the Icon visible
125 * @param b Show or Hide the New Button 125 * @param b Show or Hide the New Button
126 */ 126 */
127 void setNewVisible( bool b ); 127 void setNewVisible( bool b );
128 128
129 /** 129 /**
130 * Set the Icon visible 130 * Set the Icon visible
131 */ 131 */
132 void setCloseVisible( bool b ); 132 void setCloseVisible( bool b );
133 133
134 /** 134 /**
135 * Set the Name Line visible 135 * Set the Name Line visible
136 */ 136 */
137 void setNameVisible( bool b ); 137 void setNameVisible( bool b );
138 138
139signals: 139signals:
140 /** 140 /**
141 * dirSelected is emitted whenever changed into a different dir 141 * dirSelected is emitted whenever changed into a different dir
142 */ 142 */
143 void dirSelected( const QString& ); 143 void dirSelected( const QString& );
144 144
145 /** 145 /**
146 * fileSelected is emitted when a file is selected 146 * fileSelected is emitted when a file is selected
147 * it uses a DocLnk as parameter 147 * it uses a DocLnk as parameter
148 */ 148 */
149 void fileSelected( const DocLnk& ); 149 void fileSelected( const DocLnk& );
150 150
151 /** 151 /**
152 * fileSelected is emitted when a file is selected 152 * fileSelected is emitted when a file is selected
153 * the complete path is a parameter 153 * the complete path is a parameter
154 */ 154 */
155 void fileSelected( const QString& ); 155 void fileSelected( const QString& );
156 156
157 /** 157 /**
158 * Create a new File with a DocLnk 158 * Create a new File with a DocLnk
159 */ 159 */
160 void newSelected( const DocLnk& ); 160 void newSelected( const DocLnk& );
161 161
162 void closeMe(); 162 void closeMe();
163 163
164 /** 164 /**
165 * Ok is emitted on a Qt::Key_Return or Q::Key_Enter 165 * Ok is emitted on a Qt::Key_Return or Q::Key_Enter
166 * in the line edit 166 * in the line edit
167 */ 167 */
168 void ok(); 168 void ok();
169 void cancel(); 169 void cancel();
170 170
171 /* used by the ViewInterface */ 171 /* used by the ViewInterface */
172private: 172private:
173 bool showNew()const; 173 bool showNew()const;
174 bool showClose()const; 174 bool showClose()const;
175 MimeTypes mimeTypes()const; 175 MimeTypes mimeTypes()const;
176 QStringList currentMimeType()const; 176 QStringList currentMimeType()const;
177 177
178private: 178private:
179 /* inits the Widgets */ 179 /* inits the Widgets */
180 void initUI(); 180 void initUI();
181 /* inits the MimeType ComboBox content + connects signals and slots */ 181 /* inits the MimeType ComboBox content + connects signals and slots */
182 void initMime(); 182 void initMime();
183 /* init the Views :) */ 183 /* init the Views :) */
184 void initViews(); 184 void initViews();
185 185
186private: 186private:
187 QLineEdit* m_lneEdit; // the LineEdit for the Name 187 QLineEdit* m_lneEdit; // the LineEdit for the Name
188 QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType 188 QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType
189 QWidgetStack* m_stack; // our widget stack which will contain the views 189 QWidgetStack* m_stack; // our widget stack which will contain the views
190 Private::OFileViewInterface* currentView() const; // returns the currentView 190 Internal::OFileViewInterface* currentView() const; // returns the currentView
191 Private::OFileViewInterface* m_current; // here is the view saved 191 Internal::OFileViewInterface* m_current; // here is the view saved
192 bool m_shNew : 1; // should we show New? 192 bool m_shNew : 1; // should we show New?
193 bool m_shClose : 1; // should we show Close? 193 bool m_shClose : 1; // should we show Close?
194 MimeTypes m_mimeType; // list of mimetypes 194 MimeTypes m_mimeType; // list of mimetypes
195 195
196 QMap<QString, Private::OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr 196 QMap<QString, Internal::OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr
197 QHBox* m_nameBox; // the LineEdit + Label is hold here 197 QHBox* m_nameBox; // the LineEdit + Label is hold here
198 QHBox* m_cmbBox; // this holds the two combo boxes 198 QHBox* m_cmbBox; // this holds the two combo boxes
199 199
200 QString m_startDir; 200 QString m_startDir;
201 int m_mode; 201 int m_mode;
202 int m_selector; 202 int m_selector;
203 203
204 struct Data; // used for future versions 204 struct Data; // used for future versions
205 Data *d; 205 Data *d;
206 206
207private slots: 207private slots:
208 void slotMimeTypeChanged(); 208 void slotMimeTypeChanged();
209 209
210 /* will set the text of the lineedit and emit a fileChanged signal */ 210 /* will set the text of the lineedit and emit a fileChanged signal */
211 void slotDocLnkBridge( const DocLnk& ); 211 void slotDocLnkBridge( const DocLnk& );
212 void slotFileBridge( const QString& ); 212 void slotFileBridge( const QString& );
213 void slotViewChange( const QString& ); 213 void slotViewChange( const QString& );
214 214
215 bool eventFilter (QObject *o, QEvent *e); 215 bool eventFilter (QObject *o, QEvent *e);
216 216
217}; 217};
218 218
219} 219}
220} 220}
221 221
222#endif 222#endif
diff --git a/libopie2/opieui/fileselector/ofileselector_p.h b/libopie2/opieui/fileselector/ofileselector_p.h
index 376dc98..a3ef8e2 100644
--- a/libopie2/opieui/fileselector/ofileselector_p.h
+++ b/libopie2/opieui/fileselector/ofileselector_p.h
@@ -1,190 +1,190 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (C) Holger Freyther <zecke@handhelds.org> 3             .=l. Copyright (C) Holger Freyther <zecke@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#ifndef OFILESELECTOR_PRIVATE_H 29#ifndef OFILESELECTOR_PRIVATE_H
30#define OFILESELECTOR_PRIVATE_H 30#define OFILESELECTOR_PRIVATE_H
31 31
32/* OPIE */ 32/* OPIE */
33#include <qpe/applnk.h> 33#include <qpe/applnk.h>
34#include <qpe/fileselector.h> 34#include <qpe/fileselector.h>
35 35
36/* QT */ 36/* QT */
37#include <qmap.h> 37#include <qmap.h>
38#include <qstringlist.h> 38#include <qstringlist.h>
39#include <qwidget.h> 39#include <qwidget.h>
40#include <qlistview.h> 40#include <qlistview.h>
41 41
42/* 42/*
43 * How to avoid having really two different objects 43 * How to avoid having really two different objects
44 * for Extended and ExtendedAll 44 * for Extended and ExtendedAll
45 * The only difference is the Lister... 45 * The only difference is the Lister...
46 * a) static object? 46 * a) static object?
47 * b) leave some object inside the OFileSelector which can be used? 47 * b) leave some object inside the OFileSelector which can be used?
48 * c) when switching views tell which view we want o have.. internally we can switch then 48 * c) when switching views tell which view we want o have.. internally we can switch then
49 * 49 *
50 * I'll take c) -zecke 50 * I'll take c) -zecke
51 */ 51 */
52 52
53typedef QMap<QString, QStringList> MimeTypes; 53typedef QMap<QString, QStringList> MimeTypes;
54 54
55/* the View Interface */ 55/* the View Interface */
56class QFileInfo; 56class QFileInfo;
57class QToolButton; 57class QToolButton;
58 58
59namespace Opie{ 59namespace Opie{
60namespace Ui{ 60namespace Ui{
61class OFileSelector; 61class OFileSelector;
62namespace Private { 62namespace Internal {
63 63
64class OFileViewInterface 64class OFileViewInterface
65{ 65{
66public: 66public:
67 OFileViewInterface( OFileSelector* selector ); 67 OFileViewInterface( OFileSelector* selector );
68 virtual ~OFileViewInterface(); 68 virtual ~OFileViewInterface();
69 virtual QString selectedName()const = 0; 69 virtual QString selectedName()const = 0;
70 virtual QString selectedPath()const = 0; 70 virtual QString selectedPath()const = 0;
71 virtual QString directory()const = 0; 71 virtual QString directory()const = 0;
72 virtual void reread() = 0; 72 virtual void reread() = 0;
73 virtual int fileCount()const = 0; 73 virtual int fileCount()const = 0;
74 virtual DocLnk selectedDocument()const; 74 virtual DocLnk selectedDocument()const;
75 virtual QWidget* widget( QWidget* parent) = 0; 75 virtual QWidget* widget( QWidget* parent) = 0;
76 virtual void activate( const QString& ); 76 virtual void activate( const QString& );
77 QString name()const; 77 QString name()const;
78protected: 78protected:
79 OFileSelector* selector()const; 79 OFileSelector* selector()const;
80 void setName( const QString& ); 80 void setName( const QString& );
81 bool showNew()const; 81 bool showNew()const;
82 bool showClose()const; 82 bool showClose()const;
83 MimeTypes mimeTypes()const; 83 MimeTypes mimeTypes()const;
84 QStringList currentMimeType()const; 84 QStringList currentMimeType()const;
85 QString startDirectory()const; 85 QString startDirectory()const;
86protected: 86protected:
87 void ok(); 87 void ok();
88 void cancel(); 88 void cancel();
89 void closeMe(); 89 void closeMe();
90 void fileSelected( const QString& ); 90 void fileSelected( const QString& );
91 void fileSelected( const DocLnk& ); 91 void fileSelected( const DocLnk& );
92 void setCurrentFileName( const QString& ); 92 void setCurrentFileName( const QString& );
93 QString currentFileName()const; 93 QString currentFileName()const;
94 94
95private: 95private:
96 QString m_name; 96 QString m_name;
97 OFileSelector* m_selector; 97 OFileSelector* m_selector;
98}; 98};
99 99
100 100
101/* THE Document View hosting a FileSelector*/ 101/* THE Document View hosting a FileSelector*/
102class ODocumentFileView : public OFileViewInterface 102class ODocumentFileView : public OFileViewInterface
103{ 103{
104public: 104public:
105 ODocumentFileView( OFileSelector* selector ); 105 ODocumentFileView( OFileSelector* selector );
106 ~ODocumentFileView(); 106 ~ODocumentFileView();
107 107
108 QString selectedName() const; 108 QString selectedName() const;
109 QString selectedPath() const; 109 QString selectedPath() const;
110 110
111 QString directory() const; 111 QString directory() const;
112 void reread(); 112 void reread();
113 int fileCount()const; 113 int fileCount()const;
114 DocLnk selectedDocument()const; 114 DocLnk selectedDocument()const;
115 115
116 QWidget* widget( QWidget* parent ); 116 QWidget* widget( QWidget* parent );
117 117
118private: 118private:
119 mutable FileSelector* m_selector; 119 mutable FileSelector* m_selector;
120 120
121}; 121};
122 122
123 123
124class OFileSelectorItem : public QListViewItem 124class OFileSelectorItem : public QListViewItem
125{ 125{
126public: 126public:
127 OFileSelectorItem( QListView* view, const QPixmap& pixmap, 127 OFileSelectorItem( QListView* view, const QPixmap& pixmap,
128 const QString& path, const QString& date, 128 const QString& path, const QString& date,
129 const QString& size, const QString& mDir, 129 const QString& size, const QString& mDir,
130 bool isLocked = false, bool isDir = false ); 130 bool isLocked = false, bool isDir = false );
131 ~OFileSelectorItem(); 131 ~OFileSelectorItem();
132 bool isLocked()const; 132 bool isLocked()const;
133 bool isDir()const; 133 bool isDir()const;
134 QString directory()const; 134 QString directory()const;
135 QString path()const; 135 QString path()const;
136 QString key(int id, bool )const; 136 QString key(int id, bool )const;
137 137
138private: 138private:
139 bool m_locked : 1; 139 bool m_locked : 1;
140 bool m_isDir : 1; 140 bool m_isDir : 1;
141 QString m_dir; 141 QString m_dir;
142}; 142};
143 143
144class OFileViewFileListView : public QWidget 144class OFileViewFileListView : public QWidget
145{ 145{
146 Q_OBJECT 146 Q_OBJECT
147public: 147public:
148 OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector ); 148 OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector );
149 ~OFileViewFileListView(); 149 ~OFileViewFileListView();
150 150
151 OFileSelectorItem* currentItem()const; 151 OFileSelectorItem* currentItem()const;
152 void reread( bool all = false ); 152 void reread( bool all = false );
153 int fileCount()const; 153 int fileCount()const;
154 QString currentDir()const; 154 QString currentDir()const;
155protected: 155protected:
156 bool eventFilter (QObject *o, QEvent *e); 156 bool eventFilter (QObject *o, QEvent *e);
157private slots: 157private slots:
158 void slotNew(); // will emit newSelected 158 void slotNew(); // will emit newSelected
159 void cdUP(); 159 void cdUP();
160 void cdHome(); 160 void cdHome();
161 void cdDoc(); 161 void cdDoc();
162 void changeDir( const QString& ); 162 void changeDir( const QString& );
163 void slotCurrentChanged( QListViewItem* ); 163 void slotCurrentChanged( QListViewItem* );
164 void slotClicked(int, QListViewItem*, const QPoint&, int ); 164 void slotClicked(int, QListViewItem*, const QPoint&, int );
165 void slotFSActivated(int); 165 void slotFSActivated(int);
166 166
167protected: 167protected:
168 OFileSelector* selector(); 168 OFileSelector* selector();
169 169
170private: 170private:
171 QMap<QString, QString> m_dev; 171 QMap<QString, QString> m_dev;
172 bool m_all : 1; 172 bool m_all : 1;
173 OFileSelector* m_sel; 173 OFileSelector* m_sel;
174 QPopupMenu* m_fsPop; 174 QPopupMenu* m_fsPop;
175 bool compliesMime( const QString& ); 175 bool compliesMime( const QString& );
176 QStringList m_mimes; // used in compy mime 176 QStringList m_mimes; // used in compy mime
177 QString m_currentDir; 177 QString m_currentDir;
178 QToolButton *m_btnNew, *m_btnClose; 178 QToolButton *m_btnNew, *m_btnClose;
179 void connectSlots(); 179 void connectSlots();
180 void addFile( QFileInfo* info, bool symlink = FALSE ); 180 void addFile( QFileInfo* info, bool symlink = FALSE );
181 void addDir ( QFileInfo* info, bool symlink = FALSE ); 181 void addDir ( QFileInfo* info, bool symlink = FALSE );
182 void addSymlink( QFileInfo* info, bool = FALSE ); 182 void addSymlink( QFileInfo* info, bool = FALSE );
183 183
184 184
185private: 185private:
186 QListView* m_view; 186 QListView* m_view;
187}; 187};
188 188
189} 189}
190} 190}
diff --git a/libopie2/opieui/ofontselector.cpp b/libopie2/opieui/ofontselector.cpp
index b19c26e..6763ee6 100644
--- a/libopie2/opieui/ofontselector.cpp
+++ b/libopie2/opieui/ofontselector.cpp
@@ -1,227 +1,227 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Robert Griebl <sandman@handhelds.org> 3 Copyright (C) Robert Griebl <sandman@handhelds.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@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/* OPIE */ 30/* OPIE */
31#include <opie2/ofontselector.h> 31#include <opie2/ofontselector.h>
32#include <qpe/fontdatabase.h> 32#include <qpe/fontdatabase.h>
33 33
34/* QT */ 34/* QT */
35#include <qlayout.h> 35#include <qlayout.h>
36#include <qlistbox.h> 36#include <qlistbox.h>
37#include <qcombobox.h> 37#include <qcombobox.h>
38#include <qlabel.h> 38#include <qlabel.h>
39#include <qmultilineedit.h> 39#include <qmultilineedit.h>
40 40
41 41
42namespace Opie { 42namespace Opie {
43namespace Ui { 43namespace Ui {
44namespace Private { 44namespace Internal {
45 45
46class OFontSelectorPrivate 46class OFontSelectorPrivate
47{ 47{
48public: 48public:
49 QListBox * m_font_family_list; 49 QListBox * m_font_family_list;
50 QComboBox * m_font_style_list; 50 QComboBox * m_font_style_list;
51 QComboBox * m_font_size_list; 51 QComboBox * m_font_size_list;
52 QMultiLineEdit *m_preview; 52 QMultiLineEdit *m_preview;
53 53
54 bool m_pointbug : 1; 54 bool m_pointbug : 1;
55 55
56 FontDatabase m_fdb; 56 FontDatabase m_fdb;
57}; 57};
58 58
59class FontListItem : public QListBoxText 59class FontListItem : public QListBoxText
60{ 60{
61public: 61public:
62 FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText() 62 FontListItem ( const QString &t, const QStringList &styles, const QValueList<int> &sizes ) : QListBoxText()
63 { 63 {
64 m_name = t; 64 m_name = t;
65 m_styles = styles; 65 m_styles = styles;
66 m_sizes = sizes; 66 m_sizes = sizes;
67 67
68 QString str = t; 68 QString str = t;
69 str [0] = str [0]. upper(); 69 str [0] = str [0]. upper();
70 setText ( str ); 70 setText ( str );
71 } 71 }
72 72
73 QString family() const 73 QString family() const
74 { 74 {
75 return m_name; 75 return m_name;
76 } 76 }
77 77
78 const QStringList &styles() const 78 const QStringList &styles() const
79 { 79 {
80 return m_styles; 80 return m_styles;
81 } 81 }
82 82
83 const QValueList<int> &sizes() const 83 const QValueList<int> &sizes() const
84 { 84 {
85 return m_sizes; 85 return m_sizes;
86 } 86 }
87 87
88private: 88private:
89 QStringList m_styles; 89 QStringList m_styles;
90 QValueList<int> m_sizes; 90 QValueList<int> m_sizes;
91 QString m_name; 91 QString m_name;
92}; 92};
93} 93}
94} 94}
95} 95}
96 96
97 97
98using namespace Opie::Ui; 98using namespace Opie::Ui;
99using namespace Opie::Ui::Private; 99using namespace Opie::Ui::Internal;
100 100
101static int findItemCB( QComboBox *box, const QString &str ) 101static int findItemCB( QComboBox *box, const QString &str )
102{ 102{
103 for ( int i = 0; i < box->count(); i++ ) 103 for ( int i = 0; i < box->count(); i++ )
104 { 104 {
105 if ( box->text ( i ) == str ) 105 if ( box->text ( i ) == str )
106 return i; 106 return i;
107 } 107 }
108 return -1; 108 return -1;
109} 109}
110 110
111/* static same as anon. namespace */ 111/* static same as anon. namespace */
112static int qt_version() 112static int qt_version()
113{ 113{
114 const char *qver = qVersion(); 114 const char *qver = qVersion();
115 115
116 return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' ); 116 return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' );
117} 117}
118 118
119/** 119/**
120 * Constructs the Selector object 120 * Constructs the Selector object
121 * @param withpreview If a font preview should be given 121 * @param withpreview If a font preview should be given
122 * @param parent The parent of the Font Selector 122 * @param parent The parent of the Font Selector
123 * @param name The name of the object 123 * @param name The name of the object
124 * @param fl WidgetFlags 124 * @param fl WidgetFlags
125 */ 125 */
126OFontSelector::OFontSelector( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl ) 126OFontSelector::OFontSelector( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl )
127{ 127{
128 d = new OFontSelectorPrivate(); 128 d = new OFontSelectorPrivate();
129 129
130 QGridLayout *gridLayout = new QGridLayout( this, 0, 0, 4, 4 ); 130 QGridLayout *gridLayout = new QGridLayout( this, 0, 0, 4, 4 );
131 gridLayout->setRowStretch( 4, 10 ); 131 gridLayout->setRowStretch( 4, 10 );
132 132
133 d->m_font_family_list = new QListBox( this, "FontListBox" ); 133 d->m_font_family_list = new QListBox( this, "FontListBox" );
134 gridLayout->addMultiCellWidget( d->m_font_family_list, 0, 4, 0, 0 ); 134 gridLayout->addMultiCellWidget( d->m_font_family_list, 0, 4, 0, 0 );
135 connect( d->m_font_family_list, SIGNAL( highlighted(int) ), this, SLOT( fontFamilyClicked(int) ) ); 135 connect( d->m_font_family_list, SIGNAL( highlighted(int) ), this, SLOT( fontFamilyClicked(int) ) );
136 136
137 QLabel *label = new QLabel( tr( "Style" ), this ); 137 QLabel *label = new QLabel( tr( "Style" ), this );
138 gridLayout->addWidget( label, 0, 1 ); 138 gridLayout->addWidget( label, 0, 1 );
139 139
140 d->m_font_style_list = new QComboBox( this, "StyleListBox" ); 140 d->m_font_style_list = new QComboBox( this, "StyleListBox" );
141 connect( d->m_font_style_list, SIGNAL( activated(int) ), this, SLOT( fontStyleClicked(int) ) ); 141 connect( d->m_font_style_list, SIGNAL( activated(int) ), this, SLOT( fontStyleClicked(int) ) );
142 gridLayout->addWidget( d->m_font_style_list, 1, 1 ); 142 gridLayout->addWidget( d->m_font_style_list, 1, 1 );
143 143
144 label = new QLabel( tr( "Size" ), this ); 144 label = new QLabel( tr( "Size" ), this );
145 gridLayout->addWidget( label, 2, 1 ); 145 gridLayout->addWidget( label, 2, 1 );
146 146
147 d->m_font_size_list = new QComboBox( this, "SizeListBox" ); 147 d->m_font_size_list = new QComboBox( this, "SizeListBox" );
148 connect( d->m_font_size_list, SIGNAL( activated(int) ), 148 connect( d->m_font_size_list, SIGNAL( activated(int) ),
149 this, SLOT( fontSizeClicked(int) ) ); 149 this, SLOT( fontSizeClicked(int) ) );
150 gridLayout->addWidget( d->m_font_size_list, 3, 1 ); 150 gridLayout->addWidget( d->m_font_size_list, 3, 1 );
151 151
152 d->m_pointbug = ( qt_version() <= 233 ); 152 d->m_pointbug = ( qt_version() <= 233 );
153 153
154 if ( withpreview ) 154 if ( withpreview )
155 { 155 {
156 d->m_preview = new QMultiLineEdit ( this, "Preview" ); 156 d->m_preview = new QMultiLineEdit ( this, "Preview" );
157 d->m_preview->setAlignment ( AlignCenter ); 157 d->m_preview->setAlignment ( AlignCenter );
158 d->m_preview->setWordWrap ( QMultiLineEdit::WidgetWidth ); 158 d->m_preview->setWordWrap ( QMultiLineEdit::WidgetWidth );
159 d->m_preview->setMargin ( 3 ); 159 d->m_preview->setMargin ( 3 );
160 d->m_preview->setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" )); 160 d->m_preview->setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" ));
161 gridLayout->addRowSpacing ( 5, 4 ); 161 gridLayout->addRowSpacing ( 5, 4 );
162 gridLayout->addMultiCellWidget ( d->m_preview, 6, 6, 0, 1 ); 162 gridLayout->addMultiCellWidget ( d->m_preview, 6, 6, 0, 1 );
163 gridLayout->setRowStretch ( 6, 5 ); 163 gridLayout->setRowStretch ( 6, 5 );
164 } 164 }
165 else 165 else
166 d->m_preview = 0; 166 d->m_preview = 0;
167 167
168 loadFonts ( d->m_font_family_list ); 168 loadFonts ( d->m_font_family_list );
169} 169}
170 170
171OFontSelector::~OFontSelector() 171OFontSelector::~OFontSelector()
172{ 172{
173 delete d; 173 delete d;
174} 174}
175 175
176/** 176/**
177 * This methods tries to set the font 177 * This methods tries to set the font
178 * @param f The wishes font 178 * @param f The wishes font
179 * @return success or failure 179 * @return success or failure
180 */ 180 */
181bool OFontSelector::setSelectedFont ( const QFont &f ) 181bool OFontSelector::setSelectedFont ( const QFont &f )
182{ 182{
183 return setSelectedFont ( f. family(), d->m_fdb. styleString ( f ), f. pointSize(), QFont::encodingName ( f. charSet())); 183 return setSelectedFont ( f. family(), d->m_fdb. styleString ( f ), f. pointSize(), QFont::encodingName ( f. charSet()));
184} 184}
185 185
186 186
187/** 187/**
188 * This is an overloaded method @see setSelectedFont 188 * This is an overloaded method @see setSelectedFont
189 * @param familyStr The family of the font 189 * @param familyStr The family of the font
190 * @param styleStr The style of the font 190 * @param styleStr The style of the font
191 * @param sizeVal The size of font 191 * @param sizeVal The size of font
192 * @param charset The charset to be used. Will be deprecated by QT3 192 * @param charset The charset to be used. Will be deprecated by QT3
193 */ 193 */
194bool OFontSelector::setSelectedFont( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset ) 194bool OFontSelector::setSelectedFont( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset )
195{ 195{
196 QString sizeStr = QString::number ( sizeVal ); 196 QString sizeStr = QString::number ( sizeVal );
197 197
198 QListBoxItem *family = d->m_font_family_list->findItem ( familyStr ); 198 QListBoxItem *family = d->m_font_family_list->findItem ( familyStr );
199 if ( !family ) 199 if ( !family )
200 family = d->m_font_family_list->findItem ( "Helvetica" ); 200 family = d->m_font_family_list->findItem ( "Helvetica" );
201 if ( !family ) 201 if ( !family )
202 family = d->m_font_family_list->firstItem(); 202 family = d->m_font_family_list->firstItem();
203 d->m_font_family_list->setCurrentItem ( family ); 203 d->m_font_family_list->setCurrentItem ( family );
204 fontFamilyClicked ( d->m_font_family_list->index ( family )); 204 fontFamilyClicked ( d->m_font_family_list->index ( family ));
205 205
206 int style = findItemCB ( d->m_font_style_list, styleStr ); 206 int style = findItemCB ( d->m_font_style_list, styleStr );
207 if ( style < 0 ) 207 if ( style < 0 )
208 style = findItemCB ( d->m_font_style_list, "Regular" ); 208 style = findItemCB ( d->m_font_style_list, "Regular" );
209 if ( style < 0 && d->m_font_style_list->count() > 0 ) 209 if ( style < 0 && d->m_font_style_list->count() > 0 )
210 style = 0; 210 style = 0;
211 d->m_font_style_list->setCurrentItem ( style ); 211 d->m_font_style_list->setCurrentItem ( style );
212 fontStyleClicked ( style ); 212 fontStyleClicked ( style );
213 213
214 int size = findItemCB ( d->m_font_size_list, sizeStr ); 214 int size = findItemCB ( d->m_font_size_list, sizeStr );
215 if ( size < 0 ) 215 if ( size < 0 )
216 size = findItemCB ( d->m_font_size_list, "10" ); 216 size = findItemCB ( d->m_font_size_list, "10" );
217 if ( size < 0 && d->m_font_size_list->count() > 0 ) 217 if ( size < 0 && d->m_font_size_list->count() > 0 )
218 size = 0; 218 size = 0;
219 d->m_font_size_list->setCurrentItem ( size ); 219 d->m_font_size_list->setCurrentItem ( size );
220 fontSizeClicked ( size ); 220 fontSizeClicked ( size );
221 221
222 return (( family ) && ( style >= 0 ) && ( size >= 0 )); 222 return (( family ) && ( style >= 0 ) && ( size >= 0 ));
223} 223}
224 224
225/** 225/**
226 * This method returns the name, style and size of the currently selected 226 * This method returns the name, style and size of the currently selected
227 * font or false if no font is selected 227 * font or false if no font is selected
diff --git a/libopie2/opieui/ofontselector.h b/libopie2/opieui/ofontselector.h
index 1d97233..cd134f4 100644
--- a/libopie2/opieui/ofontselector.h
+++ b/libopie2/opieui/ofontselector.h
@@ -1,106 +1,106 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Robert Griebl <sandman@handhelds.org> 3 Copyright (C) Robert Griebl <sandman@handhelds.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@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#ifndef OFONTSELECTOR_H 30#ifndef OFONTSELECTOR_H
31#define OFONTSELECTOR_H 31#define OFONTSELECTOR_H
32 32
33/* QT */ 33/* QT */
34#include <qwidget.h> 34#include <qwidget.h>
35 35
36class QListBox; 36class QListBox;
37 37
38namespace Opie { 38namespace Opie {
39namespace Ui { 39namespace Ui {
40namespace Private { 40namespace Internal {
41class OFontSelectorPrivate; 41class OFontSelectorPrivate;
42} 42}
43 43
44/** 44/**
45 * This class lets you chose a Font out of a list of Fonts. 45 * This class lets you chose a Font out of a list of Fonts.
46 * It can show a preview too. This selector will use all available 46 * It can show a preview too. This selector will use all available
47 * fonts 47 * fonts
48 * 48 *
49 * 49 *
50 * @short A widget to select a font 50 * @short A widget to select a font
51 * @see QWidget 51 * @see QWidget
52 * @see QFont 52 * @see QFont
53 * @author Rober Griebl 53 * @author Rober Griebl
54 */ 54 */
55class OFontSelector : public QWidget 55class OFontSelector : public QWidget
56{ 56{
57 Q_OBJECT 57 Q_OBJECT
58 58
59public: 59public:
60 OFontSelector ( bool withpreview, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 60 OFontSelector ( bool withpreview, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
61 virtual ~OFontSelector ( ); 61 virtual ~OFontSelector ( );
62 62
63 bool selectedFont ( QString &family, QString &style, int &size ); 63 bool selectedFont ( QString &family, QString &style, int &size );
64 bool selectedFont ( QString &family, QString &style, int &size, QString &charset ); 64 bool selectedFont ( QString &family, QString &style, int &size, QString &charset );
65 65
66 QFont selectedFont ( ); 66 QFont selectedFont ( );
67 67
68 bool setSelectedFont ( const QFont & ); 68 bool setSelectedFont ( const QFont & );
69 bool setSelectedFont ( const QString &family, const QString &style, int size, const QString &charset = 0 ); 69 bool setSelectedFont ( const QString &family, const QString &style, int size, const QString &charset = 0 );
70 70
71 QString fontFamily ( ) const; 71 QString fontFamily ( ) const;
72 QString fontStyle ( ) const; 72 QString fontStyle ( ) const;
73 int fontSize ( ) const; 73 int fontSize ( ) const;
74 QString fontCharSet ( ) const; 74 QString fontCharSet ( ) const;
75 75
76signals: 76signals:
77 /** 77 /**
78 * This signal gets emitted when a font got chosen 78 * This signal gets emitted when a font got chosen
79 */ 79 */
80 void fontSelected ( const QFont & ); 80 void fontSelected ( const QFont & );
81 81
82protected slots: 82protected slots:
83 /** @internal */ 83 /** @internal */
84 virtual void fontFamilyClicked ( int ); 84 virtual void fontFamilyClicked ( int );
85 /** @internal */ 85 /** @internal */
86 virtual void fontStyleClicked ( int ); 86 virtual void fontStyleClicked ( int );
87 /** @internal */ 87 /** @internal */
88 virtual void fontSizeClicked ( int ); 88 virtual void fontSizeClicked ( int );
89 89
90protected: 90protected:
91 virtual void resizeEvent ( QResizeEvent *re ); 91 virtual void resizeEvent ( QResizeEvent *re );
92 92
93private: 93private:
94 void loadFonts ( QListBox * ); 94 void loadFonts ( QListBox * );
95 95
96 void changeFont ( ); 96 void changeFont ( );
97 97
98private: 98private:
99 Private::OFontSelectorPrivate *d; 99 Internal::OFontSelectorPrivate *d;
100}; 100};
101 101
102} 102}
103} 103}
104 104
105#endif 105#endif
106 106
diff --git a/libopie2/opieui/okeyconfigwidget.cpp b/libopie2/opieui/okeyconfigwidget.cpp
index ef6d713..eb7acbd 100644
--- a/libopie2/opieui/okeyconfigwidget.cpp
+++ b/libopie2/opieui/okeyconfigwidget.cpp
@@ -349,899 +349,900 @@ void OKeyConfigItem::setConfigKey( const QCString& str) {
349 m_config.detach(); 349 m_config.detach();
350} 350}
351 351
352/** 352/**
353 * @internal 353 * @internal
354 */ 354 */
355void OKeyConfigItem::setId( int id ) { 355void OKeyConfigItem::setId( int id ) {
356 m_id = id; 356 m_id = id;
357} 357}
358 358
359/** 359/**
360 * If the item is not configured isEmpty() will return true 360 * If the item is not configured isEmpty() will return true
361 * It is empty if no text is present and no default 361 * It is empty if no text is present and no default
362 * and no configured key 362 * and no configured key
363 */ 363 */
364bool OKeyConfigItem::isEmpty()const { 364bool OKeyConfigItem::isEmpty()const {
365 if ( !m_def.isEmpty() ) return false; 365 if ( !m_def.isEmpty() ) return false;
366 if ( !m_key.isEmpty() ) return false; 366 if ( !m_key.isEmpty() ) return false;
367 if ( !m_text.isEmpty() ) return false; 367 if ( !m_text.isEmpty() ) return false;
368 if ( m_id != -1 ) return false; 368 if ( m_id != -1 ) return false;
369 369
370 return true; 370 return true;
371} 371}
372 372
373/** 373/**
374 * Check if the KeyPairs are the same 374 * Check if the KeyPairs are the same
375 */ 375 */
376bool OKeyConfigItem::operator==( const OKeyConfigItem& conf )const { 376bool OKeyConfigItem::operator==( const OKeyConfigItem& conf )const {
377/* if ( isEmpty() == conf.isEmpty() ) return true; 377/* if ( isEmpty() == conf.isEmpty() ) return true;
378 else if ( isEmpty() != conf.isEmpty() ) return false; 378 else if ( isEmpty() != conf.isEmpty() ) return false;
379 else if ( !isEmpty()!= conf.isEmpty() ) return false; 379 else if ( !isEmpty()!= conf.isEmpty() ) return false;
380*/ 380*/
381 381
382 if ( m_id != conf.m_id ) return false; 382 if ( m_id != conf.m_id ) return false;
383 if ( m_obj != conf.m_obj ) return false; 383 if ( m_obj != conf.m_obj ) return false;
384 if ( m_text != conf.m_text ) return false; 384 if ( m_text != conf.m_text ) return false;
385 if ( m_key != conf.m_key ) return false; 385 if ( m_key != conf.m_key ) return false;
386 if ( m_def != conf.m_def ) return false; 386 if ( m_def != conf.m_def ) return false;
387 387
388 388
389 389
390 return true; 390 return true;
391 391
392} 392}
393 393
394bool OKeyConfigItem::operator!=( const OKeyConfigItem& conf )const { 394bool OKeyConfigItem::operator!=( const OKeyConfigItem& conf )const {
395 return !( *this == conf ); 395 return !( *this == conf );
396} 396}
397 397
398/** 398/**
399 * \brief c'tor 399 * \brief c'tor
400 * The Constructor for a OKeyConfigManager 400 * The Constructor for a OKeyConfigManager
401 * 401 *
402 * You can use this manager in multiple ways. Either make it handle 402 * You can use this manager in multiple ways. Either make it handle
403 * QKeyEvents 403 * QKeyEvents
404 * 404 *
405 * \code 405 * \code
406 * Opie::Core::Config conf = oApp->config(); 406 * Opie::Core::Config conf = oApp->config();
407 * Opie::Ui::OKeyPairList blackList; 407 * Opie::Ui::OKeyPairList blackList;
408 * blackList.append(Opie::Ui::OKeyPair::leftArrowKey()); 408 * blackList.append(Opie::Ui::OKeyPair::leftArrowKey());
409 * blackList.append(Opie::Ui::OKeyPair::rightArrowKey()); 409 * blackList.append(Opie::Ui::OKeyPair::rightArrowKey());
410 * Opie::Ui::OKeyConfigManager *manager = new Opie::Ui::OKeyConfigManager(conf,"key_actions",blackList, 410 * Opie::Ui::OKeyConfigManager *manager = new Opie::Ui::OKeyConfigManager(conf,"key_actions",blackList,
411 * false); 411 * false);
412 * QListView *view = new QListView(); 412 * QListView *view = new QListView();
413 * manager->handleWidget(view); 413 * manager->handleWidget(view);
414 * manager->addKeyConfig( Opie::Ui::OKeyPair::returnKey()); 414 * manager->addKeyConfig( Opie::Ui::OKeyPair::returnKey());
415 * manager->load(); 415 * manager->load();
416 * 416 *
417 * connect(manager,SIGNAL(actionActivated(QWidget*,QKeyEvent*,const Opie::Ui::OKeyConfigItem&)), 417 * connect(manager,SIGNAL(actionActivated(QWidget*,QKeyEvent*,const Opie::Ui::OKeyConfigItem&)),
418 * this,SLOT(slotHandleKey(QWidget*,QKeyEvent*,const Opie::Ui::OKeyConfigItem&))); 418 * this,SLOT(slotHandleKey(QWidget*,QKeyEvent*,const Opie::Ui::OKeyConfigItem&)));
419 * 419 *
420 * .... 420 * ....
421 * 421 *
422 * void update(){ 422 * void update(){
423 * QDialog diag(true); 423 * QDialog diag(true);
424 * QHBoxLayout *lay = new QHBoxLayout(&diag); 424 * QHBoxLayout *lay = new QHBoxLayout(&diag);
425 * Opie::Ui::OKeyConfigWidget *wid = new Opie::Ui::OKeyConfigWidget(manager,&diag); 425 * Opie::Ui::OKeyConfigWidget *wid = new Opie::Ui::OKeyConfigWidget(manager,&diag);
426 * wid->setChangeMode(Opie::Ui::OKeyConfigWidget::Queu); 426 * wid->setChangeMode(Opie::Ui::OKeyConfigWidget::Queu);
427 * lay->addWidget(wid); 427 * lay->addWidget(wid);
428 * if(QPEApplication::execDialog( &diag)== QDialog::Accepted){ 428 * if(QPEApplication::execDialog( &diag)== QDialog::Accepted){
429 * wid->save(); 429 * wid->save();
430 * } 430 * }
431 * } 431 * }
432 * 432 *
433 * .... 433 * ....
434 * MyListView::keyPressEvent( QKeyEvent* e ){ 434 * MyListView::keyPressEvent( QKeyEvent* e ){
435 * Opie::Ui::OKeyConfigItem item = manager->handleKeyEvent(e); 435 * Opie::Ui::OKeyConfigItem item = manager->handleKeyEvent(e);
436 * if(!item.isEmpty() ){ 436 * if(!item.isEmpty() ){
437 * switch(item.id()){ 437 * switch(item.id()){
438 * case My_Delete_Key: 438 * case My_Delete_Key:
439 * break; 439 * break;
440 * } 440 * }
441 * } 441 * }
442 * } 442 * }
443 * 443 *
444 * \endcode 444 * \endcode
445 * 445 *
446 * @param conf The Config where the KeySetting should be stored 446 * @param conf The Config where the KeySetting should be stored
447 * @param group The group where the KeySetting will be stored 447 * @param group The group where the KeySetting will be stored
448 * @param black Which keys shouldn't be allowed to handle 448 * @param black Which keys shouldn't be allowed to handle
449 * @param grabkeyboard Calls QPEApplication::grabKeyboard to allow handling of DeviceButtons 449 * @param grabkeyboard Calls QPEApplication::grabKeyboard to allow handling of DeviceButtons
450 * @param par The parent/owner of this manager 450 * @param par The parent/owner of this manager
451 * @param name The name of this object 451 * @param name The name of this object
452 */ 452 */
453OKeyConfigManager::OKeyConfigManager( Opie::Core::OConfig* conf, 453OKeyConfigManager::OKeyConfigManager( Opie::Core::OConfig* conf,
454 const QString& group, 454 const QString& group,
455 const OKeyPair::List& black, 455 const OKeyPair::List& black,
456 bool grabkeyboard, QObject* par, 456 bool grabkeyboard, QObject* par,
457 const char* name) 457 const char* name)
458 : QObject( par, name ), m_conf( conf ), m_group( group ), 458 : QObject( par, name ), m_conf( conf ), m_group( group ),
459 m_blackKeys( black ), m_grab( grabkeyboard ), m_map( 0 ){ 459 m_blackKeys( black ), m_grab( grabkeyboard ), m_map( 0 ){
460 if ( m_grab ) 460 if ( m_grab )
461 QPEApplication::grabKeyboard(); 461 QPEApplication::grabKeyboard();
462} 462}
463 463
464 464
465/** 465/**
466 * Destructor 466 * Destructor
467 */ 467 */
468OKeyConfigManager::~OKeyConfigManager() { 468OKeyConfigManager::~OKeyConfigManager() {
469 if ( m_grab ) 469 if ( m_grab )
470 QPEApplication::ungrabKeyboard(); 470 QPEApplication::ungrabKeyboard();
471} 471}
472 472
473/** 473/**
474 * Load the Configuration from the OConfig 474 * Load the Configuration from the OConfig
475 * If a Key is restricted but was in the config we will 475 * If a Key is restricted but was in the config we will
476 * make it be the empty key paur 476 * make it be the empty key paur
477 * We will change the group of the OConfig Item! 477 * We will change the group but restore to the previous.
478 * 478 *
479 * @see OKeyPair::emptyKey 479 * @see OKeyPair::emptyKey
480 */ 480 */
481void OKeyConfigManager::load() { 481void OKeyConfigManager::load() {
482 m_conf->setGroup( m_group ); 482 Opie::Core::OConfigGroupSaver( m_conf, m_group );
483 483
484 /* 484 /*
485 * Read each item 485 * Read each item
486 */ 486 */
487 int key, mod; 487 int key, mod;
488 for( OKeyConfigItem::List::Iterator it = m_keys.begin(); it != m_keys.end(); ++it ) { 488 for( OKeyConfigItem::List::Iterator it = m_keys.begin(); it != m_keys.end(); ++it ) {
489 key = m_conf->readNumEntry( (*it).configKey()+"key", (*it).defaultKeyPair().keycode() ); 489 key = m_conf->readNumEntry( (*it).configKey()+"key", (*it).defaultKeyPair().keycode() );
490 mod = m_conf->readNumEntry( (*it).configKey()+"mod", (*it).defaultKeyPair().modifier() ); 490 mod = m_conf->readNumEntry( (*it).configKey()+"mod", (*it).defaultKeyPair().modifier() );
491 OKeyPair okey( key, mod ); 491 OKeyPair okey( key, mod );
492 492
493 if ( !m_blackKeys.contains( okey ) && key != -1 && mod != -1 ) 493 if ( !m_blackKeys.contains( okey ) && key != -1 && mod != -1 )
494 (*it).setKeyPair( OKeyPair(key, mod) ); 494 (*it).setKeyPair( OKeyPair(key, mod) );
495 else 495 else
496 (*it).setKeyPair( OKeyPair::emptyKey() ); 496 (*it).setKeyPair( OKeyPair::emptyKey() );
497 } 497 }
498 delete m_map; m_map = 0; 498 delete m_map; m_map = 0;
499} 499}
500 500
501/** 501/**
502 * We will save the current configuration 502 * We will save the current configuration
503 * to the OConfig. We will change the group. 503 * to the OConfig. We will change the group but restore
504 * to the previous
504 */ 505 */
505void OKeyConfigManager::save() { 506void OKeyConfigManager::save() {
506 m_conf->setGroup( m_group ); 507 Opie::Core::OConfigGroupSaver( m_conf, m_group );
507 508
508 /* 509 /*
509 * Write each item 510 * Write each item
510 */ 511 */
511 for( OKeyConfigItem::List::Iterator it = m_keys.begin();it != m_keys.end(); ++it ) { 512 for( OKeyConfigItem::List::Iterator it = m_keys.begin();it != m_keys.end(); ++it ) {
512 /* skip empty items */ 513 /* skip empty items */
513 if ( (*it).isEmpty() ) 514 if ( (*it).isEmpty() )
514 continue; 515 continue;
515 OKeyPair pair = (*it).keyPair(); 516 OKeyPair pair = (*it).keyPair();
516 OKeyPair deft = (*it).defaultKeyPair(); 517 OKeyPair deft = (*it).defaultKeyPair();
517 /* 518 /*
518 * don't write if it is the default setting 519 * don't write if it is the default setting
519 * FIXME allow to remove Keys from config 520 * FIXME allow to remove Keys from config
520 if ( (pair.keycode() == deft.keycode()) && 521 if ( (pair.keycode() == deft.keycode()) &&
521 (pair.modifier()== deft.modifier() ) ) 522 (pair.modifier()== deft.modifier() ) )
522 return; 523 return;
523 */ 524 */
524 525
525 m_conf->writeEntry((*it).configKey()+"key", pair.keycode() ); 526 m_conf->writeEntry((*it).configKey()+"key", pair.keycode() );
526 m_conf->writeEntry((*it).configKey()+"mod", pair.modifier() ); 527 m_conf->writeEntry((*it).configKey()+"mod", pair.modifier() );
527 } 528 }
528} 529}
529 530
530/** 531/**
531 * This is function uses a QMap internally but you can have the same keycode 532 * This is function uses a QMap internally but you can have the same keycode
532 * with different modifier key. The behaviour is undefined if you add a OKeyConfigItem 533 * with different modifier key. The behaviour is undefined if you add a OKeyConfigItem
533 * with same keycode and modifier key. The GUI takes care that a user can't 534 * with same keycode and modifier key. The GUI takes care that a user can't
534 * cofigure two keys. 535 * cofigure two keys.
535 * 536 *
536 * Make sure you call e->ignore if you don't want to handle this event 537 * Make sure you call e->ignore if you don't want to handle this event
537 */ 538 */
538OKeyConfigItem OKeyConfigManager::handleKeyEvent( QKeyEvent* e ) { 539OKeyConfigItem OKeyConfigManager::handleKeyEvent( QKeyEvent* e ) {
539 /* 540 /*
540 * Fix Up issues with Qt/E, my keybard, and virtual input 541 * Fix Up issues with Qt/E, my keybard, and virtual input
541 * methods 542 * methods
542 * First my Keyboard delivers 256,512,1024 for shift/ctrl/alt instead of the button state 543 * First my Keyboard delivers 256,512,1024 for shift/ctrl/alt instead of the button state
543 * Also key() on virtual inputmethods are zero and only ascii. We need to fix upper and lower 544 * Also key() on virtual inputmethods are zero and only ascii. We need to fix upper and lower
544 * case ascii 545 * case ascii
545 */ 546 */
546 int key, mod; 547 int key, mod;
547 Opie::Ui::Private::fixupKeys( key, mod, e ); 548 Opie::Ui::Internal::fixupKeys( key, mod, e );
548 549
549 OKeyConfigItem::List _keyList = keyList( key ); 550 OKeyConfigItem::List _keyList = keyList( key );
550 if ( _keyList.isEmpty() ) 551 if ( _keyList.isEmpty() )
551 return OKeyConfigItem(); 552 return OKeyConfigItem();
552 553
553 OKeyConfigItem item; 554 OKeyConfigItem item;
554 for ( OKeyConfigItem::List::Iterator it = _keyList.begin(); it != _keyList.end(); 555 for ( OKeyConfigItem::List::Iterator it = _keyList.begin(); it != _keyList.end();
555 ++it ) { 556 ++it ) {
556 if ( (*it).keyPair().modifier() == mod ) { 557 if ( (*it).keyPair().modifier() == mod ) {
557 item = *it; 558 item = *it;
558 break; 559 break;
559 } 560 }
560 561
561 } 562 }
562 563
563 return item; 564 return item;
564} 565}
565 566
566/** 567/**
567 * Return the associated id of the item or -1 if no item 568 * Return the associated id of the item or -1 if no item
568 * matched the key 569 * matched the key
569 * 570 *
570 * @see handleKeyEvent 571 * @see handleKeyEvent
571 */ 572 */
572int OKeyConfigManager::handleKeyEventId( QKeyEvent* ev) { 573int OKeyConfigManager::handleKeyEventId( QKeyEvent* ev) {
573 return handleKeyEvent( ev ).id(); 574 return handleKeyEvent( ev ).id();
574} 575}
575 576
576/** 577/**
577 * Add Key Config to the List of items 578 * Add Key Config to the List of items
578 */ 579 */
579void OKeyConfigManager::addKeyConfig( const OKeyConfigItem& item ) { 580void OKeyConfigManager::addKeyConfig( const OKeyConfigItem& item ) {
580 m_keys.append( item ); 581 m_keys.append( item );
581 delete m_map; m_map = 0; 582 delete m_map; m_map = 0;
582} 583}
583 584
584/** 585/**
585 * Remove the Key from the Config. Internal lists will be destroyed 586 * Remove the Key from the Config. Internal lists will be destroyed
586 * and rebuild on demand later 587 * and rebuild on demand later
587 */ 588 */
588void OKeyConfigManager::removeKeyConfig( const OKeyConfigItem& item ) { 589void OKeyConfigManager::removeKeyConfig( const OKeyConfigItem& item ) {
589 m_keys.remove( item ); 590 m_keys.remove( item );
590 delete m_map; m_map = 0; 591 delete m_map; m_map = 0;
591} 592}
592 593
593/** 594/**
594 * Clears the complete list 595 * Clears the complete list
595 */ 596 */
596void OKeyConfigManager::clearKeyConfig() { 597void OKeyConfigManager::clearKeyConfig() {
597 m_keys.clear(); 598 m_keys.clear();
598 delete m_map; m_map = 0; 599 delete m_map; m_map = 0;
599} 600}
600 601
601/** 602/**
602 * 603 *
603 */ 604 */
604Opie::Ui::OKeyConfigItem::List OKeyConfigManager::keyConfigList()const{ 605Opie::Ui::OKeyConfigItem::List OKeyConfigManager::keyConfigList()const{
605 return m_keys; 606 return m_keys;
606} 607}
607 608
608/** 609/**
609 * Add this OKeyPair to the blackList. 610 * Add this OKeyPair to the blackList.
610 * Internal lists will be destroyed 611 * Internal lists will be destroyed
611 */ 612 */
612void OKeyConfigManager::addToBlackList( const OKeyPair& key) { 613void OKeyConfigManager::addToBlackList( const OKeyPair& key) {
613 m_blackKeys.append( key ); 614 m_blackKeys.append( key );
614 delete m_map; m_map = 0; 615 delete m_map; m_map = 0;
615} 616}
616 617
617 618
618/** 619/**
619 * Remove this OKeyPair from the black List 620 * Remove this OKeyPair from the black List
620 * Internal lists will be destroyed 621 * Internal lists will be destroyed
621 */ 622 */
622void OKeyConfigManager::removeFromBlackList( const OKeyPair& key ) { 623void OKeyConfigManager::removeFromBlackList( const OKeyPair& key ) {
623 m_blackKeys.remove( key ); 624 m_blackKeys.remove( key );
624 delete m_map; m_map = 0; 625 delete m_map; m_map = 0;
625} 626}
626 627
627 628
628/** 629/**
629 * Clear the blackList 630 * Clear the blackList
630 */ 631 */
631void OKeyConfigManager::clearBlackList() { 632void OKeyConfigManager::clearBlackList() {
632 m_blackKeys.clear(); 633 m_blackKeys.clear();
633 delete m_map; m_map = 0; 634 delete m_map; m_map = 0;
634} 635}
635 636
636 637
637/** 638/**
638 * Return a copy of the blackList 639 * Return a copy of the blackList
639 */ 640 */
640OKeyPair::List OKeyConfigManager::blackList()const { 641OKeyPair::List OKeyConfigManager::blackList()const {
641 return m_blackKeys; 642 return m_blackKeys;
642} 643}
643 644
644 645
645/** 646/**
646 * Ask the Manager to handle KeyEvents for you. 647 * Ask the Manager to handle KeyEvents for you.
647 * All handled keys will emit a QSignal and return true 648 * All handled keys will emit a QSignal and return true
648 * that it handled the keyevent 649 * that it handled the keyevent
649 */ 650 */
650void OKeyConfigManager::handleWidget( QWidget* wid ) { 651void OKeyConfigManager::handleWidget( QWidget* wid ) {
651 wid->installEventFilter( this ); 652 wid->installEventFilter( this );
652} 653}
653 654
654/** 655/**
655 * @internal 656 * @internal
656 */ 657 */
657bool OKeyConfigManager::eventFilter( QObject* obj, QEvent* ev) { 658bool OKeyConfigManager::eventFilter( QObject* obj, QEvent* ev) {
658 if ( !obj->isWidgetType() ) 659 if ( !obj->isWidgetType() )
659 return false; 660 return false;
660 661
661 if ( ev->type() != QEvent::KeyPress && ev->type() != QEvent::KeyRelease ) 662 if ( ev->type() != QEvent::KeyPress && ev->type() != QEvent::KeyRelease )
662 return false; 663 return false;
663 664
664 QKeyEvent *key = static_cast<QKeyEvent*>( ev ); 665 QKeyEvent *key = static_cast<QKeyEvent*>( ev );
665 OKeyConfigItem item = handleKeyEvent( key ); 666 OKeyConfigItem item = handleKeyEvent( key );
666 667
667 if ( item.isEmpty() ) 668 if ( item.isEmpty() )
668 return false; 669 return false;
669 670
670 QWidget *wid = static_cast<QWidget*>( obj ); 671 QWidget *wid = static_cast<QWidget*>( obj );
671 672
672 if ( item.object() && !item.slot().isEmpty() ) { 673 if ( item.object() && !item.slot().isEmpty() ) {
673 connect( this, SIGNAL( actionActivated(QWidget*, QKeyEvent*)), 674 connect( this, SIGNAL( actionActivated(QWidget*, QKeyEvent*)),
674 item.object(), item.slot().data() ); 675 item.object(), item.slot().data() );
675 emit actionActivated(wid, key); 676 emit actionActivated(wid, key);
676 disconnect( this, SIGNAL(actionActivated(QWidget*,QKeyEvent*)), 677 disconnect( this, SIGNAL(actionActivated(QWidget*,QKeyEvent*)),
677 item.object(), item.slot().data() ); 678 item.object(), item.slot().data() );
678 } 679 }
679 emit actionActivated( wid, key, item ); 680 emit actionActivated( wid, key, item );
680 681
681 return true; 682 return true;
682} 683}
683 684
684/** 685/**
685 * @internal 686 * @internal
686 */ 687 */
687OKeyConfigItem::List OKeyConfigManager::keyList( int keycode) { 688OKeyConfigItem::List OKeyConfigManager::keyList( int keycode) {
688 /* 689 /*
689 * Create the map if not existing anymore 690 * Create the map if not existing anymore
690 */ 691 */
691 if ( !m_map ) { 692 if ( !m_map ) {
692 m_map = new OKeyMapConfigPrivate; 693 m_map = new OKeyMapConfigPrivate;
693 /* for every key */ 694 /* for every key */
694 for ( OKeyConfigItem::List::Iterator it = m_keys.begin(); 695 for ( OKeyConfigItem::List::Iterator it = m_keys.begin();
695 it!= m_keys.end(); ++it ) { 696 it!= m_keys.end(); ++it ) {
696 697
697 bool add = true; 698 bool add = true;
698 /* see if this key is blocked */ 699 /* see if this key is blocked */
699 OKeyPair pair = (*it).keyPair(); 700 OKeyPair pair = (*it).keyPair();
700 for ( OKeyPair::List::Iterator pairIt = m_blackKeys.begin(); 701 for ( OKeyPair::List::Iterator pairIt = m_blackKeys.begin();
701 pairIt != m_blackKeys.end(); ++pairIt ) { 702 pairIt != m_blackKeys.end(); ++pairIt ) {
702 if ( (*pairIt).keycode() == pair.keycode() && 703 if ( (*pairIt).keycode() == pair.keycode() &&
703 (*pairIt).modifier() == pair.modifier() ) { 704 (*pairIt).modifier() == pair.modifier() ) {
704 add = false; 705 add = false;
705 break; 706 break;
706 } 707 }
707 } 708 }
708 /* check if we added it */ 709 /* check if we added it */
709 if ( add ) 710 if ( add )
710 (*m_map)[pair.keycode()].append( *it ); 711 (*m_map)[pair.keycode()].append( *it );
711 } 712 }
712 } 713 }
713 return (*m_map)[keycode]; 714 return (*m_map)[keycode];
714} 715}
715 716
716 717
717namespace Opie { 718namespace Opie {
718namespace Ui { 719namespace Ui {
719namespace Private { 720namespace Internal {
720 721
721 OKeyListViewItem::OKeyListViewItem( const OKeyConfigItem& item, OKeyConfigManager* man, OListViewItem* parent) 722 OKeyListViewItem::OKeyListViewItem( const OKeyConfigItem& item, OKeyConfigManager* man, OListViewItem* parent)
722 : Opie::Ui::OListViewItem( parent ), m_manager( man ) { 723 : Opie::Ui::OListViewItem( parent ), m_manager( man ) {
723 m_origItem = item; 724 m_origItem = item;
724 setItem( item ); 725 setItem( item );
725 } 726 }
726 OKeyListViewItem::~OKeyListViewItem() {} 727 OKeyListViewItem::~OKeyListViewItem() {}
727 OKeyConfigItem &OKeyListViewItem::item(){ 728 OKeyConfigItem &OKeyListViewItem::item(){
728 return m_item; 729 return m_item;
729 } 730 }
730 OKeyConfigItem OKeyListViewItem::origItem() const{ 731 OKeyConfigItem OKeyListViewItem::origItem() const{
731 return m_origItem; 732 return m_origItem;
732 } 733 }
733 OKeyConfigManager* OKeyListViewItem::manager() { 734 OKeyConfigManager* OKeyListViewItem::manager() {
734 return m_manager; 735 return m_manager;
735 } 736 }
736 void OKeyListViewItem::setItem( const OKeyConfigItem& item ) { 737 void OKeyListViewItem::setItem( const OKeyConfigItem& item ) {
737 m_item = item; 738 m_item = item;
738 setPixmap( 0, m_item.pixmap() ); 739 setPixmap( 0, m_item.pixmap() );
739 setText ( 1, m_item.text() ); 740 setText ( 1, m_item.text() );
740 m_item.keyPair().isEmpty() ? setText( 2, QObject::tr( "None" ) ) : 741 m_item.keyPair().isEmpty() ? setText( 2, QObject::tr( "None" ) ) :
741 setText( 2, keyToString( m_item.keyPair() ) ); 742 setText( 2, keyToString( m_item.keyPair() ) );
742 743
743 m_item.defaultKeyPair().isEmpty() ? setText( 3, QObject::tr( "None" ) ) : 744 m_item.defaultKeyPair().isEmpty() ? setText( 3, QObject::tr( "None" ) ) :
744 setText ( 3, keyToString( m_item.defaultKeyPair() ) ); 745 setText ( 3, keyToString( m_item.defaultKeyPair() ) );
745 } 746 }
746 void OKeyListViewItem::updateText() { 747 void OKeyListViewItem::updateText() {
747 m_item.keyPair().isEmpty() ? setText( 2, QObject::tr( "None" ) ) : 748 m_item.keyPair().isEmpty() ? setText( 2, QObject::tr( "None" ) ) :
748 setText( 2, keyToString( m_item.keyPair() ) ); 749 setText( 2, keyToString( m_item.keyPair() ) );
749 } 750 }
750 751
751 QString keyToString( const OKeyPair& pair ) { 752 QString keyToString( const OKeyPair& pair ) {
752 int mod = 0; 753 int mod = 0;
753 if ( pair.modifier() & Qt::ShiftButton ) 754 if ( pair.modifier() & Qt::ShiftButton )
754 mod |= Qt::SHIFT; 755 mod |= Qt::SHIFT;
755 if ( pair.modifier() & Qt::ControlButton ) 756 if ( pair.modifier() & Qt::ControlButton )
756 mod |= Qt::CTRL; 757 mod |= Qt::CTRL;
757 if ( pair.modifier() & Qt::AltButton ) 758 if ( pair.modifier() & Qt::AltButton )
758 mod |= Qt::ALT; 759 mod |= Qt::ALT;
759 760
760 return QAccel::keyToString( mod + pair.keycode() ); 761 return QAccel::keyToString( mod + pair.keycode() );
761 } 762 }
762 763
763 /* 764 /*
764 * the virtual and hardware key events have both issues... 765 * the virtual and hardware key events have both issues...
765 */ 766 */
766 void fixupKeys( int& key, int &mod, QKeyEvent* e ) { 767 void fixupKeys( int& key, int &mod, QKeyEvent* e ) {
767 key = e->key(); 768 key = e->key();
768 mod = e->state(); 769 mod = e->state();
769 /* 770 /*
770 * virtual keyboard 771 * virtual keyboard
771 * else change the button mod only 772 * else change the button mod only
772 */ 773 */
773 if ( key == 0 ) { 774 if ( key == 0 ) {
774 key = e->ascii(); 775 key = e->ascii();
775 if ( key > 96 && key < 123) 776 if ( key > 96 && key < 123)
776 key -= 32; 777 key -= 32;
777 }else{ 778 }else{
778 int new_mod = 0; 779 int new_mod = 0;
779 if ( mod & 256 ) 780 if ( mod & 256 )
780 new_mod |= Qt::ShiftButton; 781 new_mod |= Qt::ShiftButton;
781 else if ( mod & 512 ) 782 else if ( mod & 512 )
782 new_mod |= Qt::ControlButton; 783 new_mod |= Qt::ControlButton;
783 else if ( mod & 1024 ) 784 else if ( mod & 1024 )
784 new_mod |= Qt::AltButton; 785 new_mod |= Qt::AltButton;
785 786
786 mod = new_mod == 0? mod : new_mod; 787 mod = new_mod == 0? mod : new_mod;
787 } 788 }
788 } 789 }
789 790
790 struct OKeyConfigWidgetPrivate{ 791 struct OKeyConfigWidgetPrivate{
791 OKeyConfigWidgetPrivate(const QString& = QString::null, 792 OKeyConfigWidgetPrivate(const QString& = QString::null,
792 OKeyConfigManager* = 0); 793 OKeyConfigManager* = 0);
793 bool operator==( const OKeyConfigWidgetPrivate& ); 794 bool operator==( const OKeyConfigWidgetPrivate& );
794 QString name; 795 QString name;
795 OKeyConfigManager *manager; 796 OKeyConfigManager *manager;
796 }; 797 };
797 798
798 OKeyConfigWidgetPrivate::OKeyConfigWidgetPrivate( const QString& _name, 799 OKeyConfigWidgetPrivate::OKeyConfigWidgetPrivate( const QString& _name,
799 OKeyConfigManager* man ) 800 OKeyConfigManager* man )
800 : name( _name ), manager( man ){} 801 : name( _name ), manager( man ){}
801 802
802 bool OKeyConfigWidgetPrivate::operator==( const OKeyConfigWidgetPrivate& item) { 803 bool OKeyConfigWidgetPrivate::operator==( const OKeyConfigWidgetPrivate& item) {
803 if ( manager != item.manager) return false; 804 if ( manager != item.manager) return false;
804 if ( name != item.name ) return false; 805 if ( name != item.name ) return false;
805 806
806 return true; 807 return true;
807 } 808 }
808 809
809} 810}
810} 811}
811} 812}
812 813
813 814
814 815
815//////////////////////// 816////////////////////////
816//////////////////////// 817////////////////////////
817//////// Widget Starts Here 818//////// Widget Starts Here
818 819
819 820
820 821
821 822
822/** 823/**
823 * 824 *
824 * This is a c'tor. You still need to pass the OKeyConfigManager 825 * This is a c'tor. You still need to pass the OKeyConfigManager
825 * and then issue a load. 826 * and then issue a load.
826 * The default mode is Immediate 827 * The default mode is Immediate
827 * 828 *
828 */ 829 */
829OKeyConfigWidget::OKeyConfigWidget( QWidget* parent, const char *name, WFlags fl ) 830OKeyConfigWidget::OKeyConfigWidget( QWidget* parent, const char *name, WFlags fl )
830 : QWidget( parent, name, fl ) { 831 : QWidget( parent, name, fl ) {
831 initUi(); 832 initUi();
832} 833}
833 834
834 835
835 836
836/** 837/**
837 * c'tor 838 * c'tor
838 */ 839 */
839OKeyConfigWidget::~OKeyConfigWidget() { 840OKeyConfigWidget::~OKeyConfigWidget() {
840} 841}
841 842
842 843
843/** 844/**
844 * @internal 845 * @internal
845 */ 846 */
846void OKeyConfigWidget::initUi() { 847void OKeyConfigWidget::initUi() {
847 QBoxLayout *layout = new QVBoxLayout( this ); 848 QBoxLayout *layout = new QVBoxLayout( this );
848 QGridLayout *gridLay = new QGridLayout( 2, 2 ); 849 QGridLayout *gridLay = new QGridLayout( 2, 2 );
849 layout->addLayout( gridLay, 10 ); 850 layout->addLayout( gridLay, 10 );
850 gridLay->setRowStretch( 1, 10 ); // let only the ListView strecth 851 gridLay->setRowStretch( 1, 10 ); // let only the ListView strecth
851 852
852/* 853/*
853 * LISTVIEW with the Keys 854 * LISTVIEW with the Keys
854 */ 855 */
855 m_view = new Opie::Ui::OListView( this ); 856 m_view = new Opie::Ui::OListView( this );
856 m_view->setFocus(); 857 m_view->setFocus();
857 m_view->setAllColumnsShowFocus( true ); 858 m_view->setAllColumnsShowFocus( true );
858 m_view->addColumn( tr("Pixmap") ); 859 m_view->addColumn( tr("Pixmap") );
859 m_view->addColumn( tr("Name","Name of the Action in the ListView Header" ) ); 860 m_view->addColumn( tr("Name","Name of the Action in the ListView Header" ) );
860 m_view->addColumn( tr("Key" ) ); 861 m_view->addColumn( tr("Key" ) );
861 m_view->addColumn( tr("Default Key" ) ); 862 m_view->addColumn( tr("Default Key" ) );
862 m_view->setRootIsDecorated( true ); 863 m_view->setRootIsDecorated( true );
863 connect(m_view, SIGNAL(currentChanged(QListViewItem*)), 864 connect(m_view, SIGNAL(currentChanged(QListViewItem*)),
864 this, SLOT(slotListViewItem(QListViewItem*)) ); 865 this, SLOT(slotListViewItem(QListViewItem*)) );
865 866
866 gridLay->addMultiCellWidget( m_view, 1, 1, 0, 1 ); 867 gridLay->addMultiCellWidget( m_view, 1, 1, 0, 1 );
867 868
868/* 869/*
869 * GROUP with button info 870 * GROUP with button info
870 */ 871 */
871 872
872 QGroupBox *box = new QGroupBox( this ); 873 QGroupBox *box = new QGroupBox( this );
873 box ->setTitle( tr("Shortcut for Selected Action") ); 874 box ->setTitle( tr("Shortcut for Selected Action") );
874 box ->setFrameStyle( QFrame::Box | QFrame::Sunken ); 875 box ->setFrameStyle( QFrame::Box | QFrame::Sunken );
875 layout->addWidget( box, 1 ); 876 layout->addWidget( box, 1 );
876 877
877 gridLay = new QGridLayout( box, 3, 4 ); 878 gridLay = new QGridLayout( box, 3, 4 );
878 gridLay->addRowSpacing( 0, fontMetrics().lineSpacing() ); 879 gridLay->addRowSpacing( 0, fontMetrics().lineSpacing() );
879 gridLay->setMargin( 4 ); 880 gridLay->setMargin( 4 );
880 881
881 QButtonGroup *gr = new QButtonGroup( box ); 882 QButtonGroup *gr = new QButtonGroup( box );
882 gr->hide(); 883 gr->hide();
883 gr->setExclusive( true ); 884 gr->setExclusive( true );
884 885
885 QRadioButton *rad = new QRadioButton( tr( "&None" ), box ); 886 QRadioButton *rad = new QRadioButton( tr( "&None" ), box );
886 connect( rad, SIGNAL(clicked()), 887 connect( rad, SIGNAL(clicked()),
887 this, SLOT(slotNoKey()) ); 888 this, SLOT(slotNoKey()) );
888 gr->insert( rad, 10 ); 889 gr->insert( rad, 10 );
889 gridLay->addWidget( rad, 1, 0 ); 890 gridLay->addWidget( rad, 1, 0 );
890 m_none = rad; 891 m_none = rad;
891 892
892 rad = new QRadioButton( tr("&Default" ), box ); 893 rad = new QRadioButton( tr("&Default" ), box );
893 connect( rad, SIGNAL(clicked()), 894 connect( rad, SIGNAL(clicked()),
894 this, SLOT(slotDefaultKey()) ); 895 this, SLOT(slotDefaultKey()) );
895 gr->insert( rad, 11 ); 896 gr->insert( rad, 11 );
896 gridLay->addWidget( rad, 1, 1 ); 897 gridLay->addWidget( rad, 1, 1 );
897 m_def = rad; 898 m_def = rad;
898 899
899 rad = new QRadioButton( tr("C&ustom"), box ); 900 rad = new QRadioButton( tr("C&ustom"), box );
900 connect( rad, SIGNAL(clicked()), 901 connect( rad, SIGNAL(clicked()),
901 this, SLOT(slotCustomKey()) ); 902 this, SLOT(slotCustomKey()) );
902 gr->insert( rad, 12 ); 903 gr->insert( rad, 12 );
903 gridLay->addWidget( rad, 1, 2 ); 904 gridLay->addWidget( rad, 1, 2 );
904 m_cus = rad; 905 m_cus = rad;
905 906
906 m_btn = new QPushButton( tr("Configure Key"), box ); 907 m_btn = new QPushButton( tr("Configure Key"), box );
907 gridLay->addWidget( m_btn, 1, 4 ); 908 gridLay->addWidget( m_btn, 1, 4 );
908 909
909 m_lbl= new QLabel( tr( "Default: " ), box ); 910 m_lbl= new QLabel( tr( "Default: " ), box );
910 gridLay->addWidget( m_lbl, 2, 0 ); 911 gridLay->addWidget( m_lbl, 2, 0 );
911 912
912 connect(m_btn, SIGNAL(clicked()), 913 connect(m_btn, SIGNAL(clicked()),
913 this, SLOT(slotConfigure())); 914 this, SLOT(slotConfigure()));
914 915
915 m_box = box; 916 m_box = box;
916} 917}
917 918
918/** 919/**
919 * Set the ChangeMode. 920 * Set the ChangeMode.
920 * You need to call this function prior to load 921 * You need to call this function prior to load
921 * If you call this function past load the behaviour is undefined 922 * If you call this function past load the behaviour is undefined
922 * But caling load again is safe 923 * But caling load again is safe
923 */ 924 */
924void OKeyConfigWidget::setChangeMode( enum ChangeMode mode) { 925void OKeyConfigWidget::setChangeMode( enum ChangeMode mode) {
925 m_mode = mode; 926 m_mode = mode;
926} 927}
927 928
928 929
929/** 930/**
930 * return the current mode 931 * return the current mode
931 */ 932 */
932OKeyConfigWidget::ChangeMode OKeyConfigWidget::changeMode()const { 933OKeyConfigWidget::ChangeMode OKeyConfigWidget::changeMode()const {
933 return m_mode; 934 return m_mode;
934} 935}
935 936
936 937
937/** 938/**
938 * insert these items before calling load 939 * insert these items before calling load
939 */ 940 */
940void OKeyConfigWidget::insert( const QString& str, OKeyConfigManager* man ) { 941void OKeyConfigWidget::insert( const QString& str, OKeyConfigManager* man ) {
941 Opie::Ui::Private::OKeyConfigWidgetPrivate root( str, man ); 942 Opie::Ui::Internal::OKeyConfigWidgetPrivate root( str, man );
942 m_list.append(root); 943 m_list.append(root);
943} 944}
944 945
945 946
946/** 947/**
947 * loads the items and allows editing them 948 * loads the items and allows editing them
948 */ 949 */
949void OKeyConfigWidget::load() { 950void OKeyConfigWidget::load() {
950 Opie::Ui::Private::OKeyConfigWidgetPrivateList::Iterator it; 951 Opie::Ui::Internal::OKeyConfigWidgetPrivateList::Iterator it;
951 for ( it = m_list.begin(); it != m_list.end(); ++it ) { 952 for ( it = m_list.begin(); it != m_list.end(); ++it ) {
952 OListViewItem *item = new OListViewItem( m_view, (*it).name ); 953 OListViewItem *item = new OListViewItem( m_view, (*it).name );
953 OKeyConfigItem::List list = (*it).manager->keyConfigList(); 954 OKeyConfigItem::List list = (*it).manager->keyConfigList();
954 for (OKeyConfigItem::List::Iterator keyIt = list.begin(); keyIt != list.end();++keyIt ) 955 for (OKeyConfigItem::List::Iterator keyIt = list.begin(); keyIt != list.end();++keyIt )
955 (void )new Opie::Ui::Private::OKeyListViewItem(*keyIt, (*it).manager, item ); 956 (void )new Opie::Ui::Internal::OKeyListViewItem(*keyIt, (*it).manager, item );
956 957
957 } 958 }
958} 959}
959 960
960/** 961/**
961 * Saves if in Queue Mode. It'll update the supplied 962 * Saves if in Queue Mode. It'll update the supplied
962 * OKeyConfigManager objects. 963 * OKeyConfigManager objects.
963 * If in Queue mode it'll just return 964 * If in Queue mode it'll just return
964 */ 965 */
965void OKeyConfigWidget::save() { 966void OKeyConfigWidget::save() {
966 /* 967 /*
967 * Iterate over all config items 968 * Iterate over all config items
968 */ 969 */
969 QListViewItemIterator it( m_view ); 970 QListViewItemIterator it( m_view );
970 while ( it.current() ) { 971 while ( it.current() ) {
971 if (it.current()->parent() ) { 972 if (it.current()->parent() ) {
972 Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>( it.current() ); 973 Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>( it.current() );
973 OKeyConfigManager *man = item->manager(); 974 OKeyConfigManager *man = item->manager();
974 man->removeKeyConfig( item->origItem() ); 975 man->removeKeyConfig( item->origItem() );
975 man->addKeyConfig( item->item() ); 976 man->addKeyConfig( item->item() );
976 } 977 }
977 ++it; 978 ++it;
978 } 979 }
979 980
980 981
981} 982}
982 983
983 984
984/** 985/**
985 * @internal 986 * @internal
986 */ 987 */
987void OKeyConfigWidget::slotListViewItem( QListViewItem* _item) { 988void OKeyConfigWidget::slotListViewItem( QListViewItem* _item) {
988 if ( !_item || !_item->parent() ) { 989 if ( !_item || !_item->parent() ) {
989 m_box->setEnabled( false ); 990 m_box->setEnabled( false );
990 m_none->setChecked( true ); 991 m_none->setChecked( true );
991 m_btn ->setEnabled( false ); 992 m_btn ->setEnabled( false );
992 m_def ->setChecked( false ); 993 m_def ->setChecked( false );
993 m_cus ->setChecked( false ); 994 m_cus ->setChecked( false );
994 }else{ 995 }else{
995 m_box->setEnabled( true ); 996 m_box->setEnabled( true );
996 Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>( _item ); 997 Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>( _item );
997 OKeyConfigItem keyItem= item->item(); 998 OKeyConfigItem keyItem= item->item();
998 m_lbl->setText( tr("Default: " )+ item->text( 3 ) ); 999 m_lbl->setText( tr("Default: " )+ item->text( 3 ) );
999 if ( keyItem.keyPair().isEmpty() ) { 1000 if ( keyItem.keyPair().isEmpty() ) {
1000 m_none->setChecked( true ); 1001 m_none->setChecked( true );
1001 m_btn ->setEnabled( false ); 1002 m_btn ->setEnabled( false );
1002 m_def ->setChecked( false ); 1003 m_def ->setChecked( false );
1003 m_cus ->setChecked( false ); 1004 m_cus ->setChecked( false );
1004 }else { 1005 }else {
1005 m_none->setChecked( false ); 1006 m_none->setChecked( false );
1006 m_cus ->setChecked( true ); 1007 m_cus ->setChecked( true );
1007 m_btn ->setEnabled( true ); 1008 m_btn ->setEnabled( true );
1008 m_def ->setChecked( false ); 1009 m_def ->setChecked( false );
1009 } 1010 }
1010 } 1011 }
1011} 1012}
1012 1013
1013void OKeyConfigWidget::slotNoKey() { 1014void OKeyConfigWidget::slotNoKey() {
1014 m_none->setChecked( true ); 1015 m_none->setChecked( true );
1015 m_cus ->setChecked( false ); 1016 m_cus ->setChecked( false );
1016 m_btn ->setEnabled( false ); 1017 m_btn ->setEnabled( false );
1017 m_def ->setChecked( false ); 1018 m_def ->setChecked( false );
1018 1019
1019 if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) 1020 if ( !m_view->currentItem() || !m_view->currentItem()->parent() )
1020 return; 1021 return;
1021 1022
1022 1023
1023 1024
1024 /* 1025 /*
1025 * If immediate we need to remove and readd the key 1026 * If immediate we need to remove and readd the key
1026 */ 1027 */
1027 Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); 1028 Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>(m_view->currentItem());
1028 updateItem( item, OKeyPair::emptyKey() ); 1029 updateItem( item, OKeyPair::emptyKey() );
1029} 1030}
1030 1031
1031void OKeyConfigWidget::slotDefaultKey() { 1032void OKeyConfigWidget::slotDefaultKey() {
1032 m_none->setChecked( false ); 1033 m_none->setChecked( false );
1033 m_cus ->setChecked( false ); 1034 m_cus ->setChecked( false );
1034 m_btn ->setEnabled( false ); 1035 m_btn ->setEnabled( false );
1035 m_def ->setChecked( true ); 1036 m_def ->setChecked( true );
1036 1037
1037 if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) 1038 if ( !m_view->currentItem() || !m_view->currentItem()->parent() )
1038 return; 1039 return;
1039 1040
1040 Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); 1041 Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>(m_view->currentItem());
1041 updateItem( item, item->item().defaultKeyPair() ); 1042 updateItem( item, item->item().defaultKeyPair() );
1042} 1043}
1043 1044
1044void OKeyConfigWidget::slotCustomKey() { 1045void OKeyConfigWidget::slotCustomKey() {
1045 m_cus ->setChecked( true ); 1046 m_cus ->setChecked( true );
1046 m_btn ->setEnabled( true ); 1047 m_btn ->setEnabled( true );
1047 m_def ->setChecked( false ); 1048 m_def ->setChecked( false );
1048 m_none->setChecked( false ); 1049 m_none->setChecked( false );
1049 1050
1050 if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) 1051 if ( !m_view->currentItem() || !m_view->currentItem()->parent() )
1051 return; 1052 return;
1052 1053
1053 1054
1054} 1055}
1055 1056
1056void OKeyConfigWidget::slotConfigure() { 1057void OKeyConfigWidget::slotConfigure() {
1057 if ( !m_view->currentItem() || !m_view->currentItem()->parent() ) 1058 if ( !m_view->currentItem() || !m_view->currentItem()->parent() )
1058 return; 1059 return;
1059 1060
1060 /* FIXME make use of OModalHelper */ 1061 /* FIXME make use of OModalHelper */
1061 OKeyChooserConfigDialog dlg( this, "Dialog Name", true ); 1062 OKeyChooserConfigDialog dlg( this, "Dialog Name", true );
1062 dlg.setCaption(tr("Configure Key")); 1063 dlg.setCaption(tr("Configure Key"));
1063 connect(&dlg, SIGNAL(keyCaptured()), &dlg, SLOT(accept()) ); 1064 connect(&dlg, SIGNAL(keyCaptured()), &dlg, SLOT(accept()) );
1064 1065
1065 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { 1066 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) {
1066 Opie::Ui::Private::OKeyListViewItem *item = static_cast<Opie::Ui::Private::OKeyListViewItem*>(m_view->currentItem()); 1067 Opie::Ui::Internal::OKeyListViewItem *item = static_cast<Opie::Ui::Internal::OKeyListViewItem*>(m_view->currentItem());
1067 updateItem( item, dlg.keyPair() ); 1068 updateItem( item, dlg.keyPair() );
1068 } 1069 }
1069 1070
1070 1071
1071} 1072}
1072 1073
1073bool OKeyConfigWidget::sanityCheck( Opie::Ui::Private::OKeyListViewItem* item, 1074bool OKeyConfigWidget::sanityCheck( Opie::Ui::Internal::OKeyListViewItem* item,
1074 const OKeyPair& newItem ) { 1075 const OKeyPair& newItem ) {
1075 OKeyPair::List bList = item->manager()->blackList(); 1076 OKeyPair::List bList = item->manager()->blackList();
1076 for ( OKeyPair::List::Iterator it = bList.begin(); it != bList.end(); ++it ) { 1077 for ( OKeyPair::List::Iterator it = bList.begin(); it != bList.end(); ++it ) {
1077 /* black list matched */ 1078 /* black list matched */
1078 if ( *it == newItem ) { 1079 if ( *it == newItem ) {
1079 QMessageBox::warning( 0, tr("Key is on BlackList" ), 1080 QMessageBox::warning( 0, tr("Key is on BlackList" ),
1080 tr("<qt>The Key you choose is on the black list " 1081 tr("<qt>The Key you choose is on the black list "
1081 "and may not be used with this manager. Please " 1082 "and may not be used with this manager. Please "
1082 "use a different key.</qt>" ) ); 1083 "use a different key.</qt>" ) );
1083 return false; 1084 return false;
1084 } 1085 }
1085 } 1086 }
1086 /* no we need to check the other items which is dog slow */ 1087 /* no we need to check the other items which is dog slow */
1087 QListViewItemIterator it( item->parent() ); 1088 QListViewItemIterator it( item->parent() );
1088 while ( it.current() ) { 1089 while ( it.current() ) {
1089 /* if not our parent and not us */ 1090 /* if not our parent and not us */
1090 if (it.current()->parent() && it.current() != item) { 1091 if (it.current()->parent() && it.current() != item) {
1091 /* damn already given away*/ 1092 /* damn already given away*/
1092 if ( newItem == static_cast<Opie::Ui::Private::OKeyListViewItem*>(it.current() )->item().keyPair() ) { 1093 if ( newItem == static_cast<Opie::Ui::Internal::OKeyListViewItem*>(it.current() )->item().keyPair() ) {
1093 QMessageBox::warning( 0, tr("Key is already assigned" ), 1094 QMessageBox::warning( 0, tr("Key is already assigned" ),
1094 tr("<qt>The Key you choose is already taken by " 1095 tr("<qt>The Key you choose is already taken by "
1095 "a different Item of your config. Please try" 1096 "a different Item of your config. Please try"
1096 "using a different key.</qt>" ) ); 1097 "using a different key.</qt>" ) );
1097 return false; 1098 return false;
1098 } 1099 }
1099 } 1100 }
1100 ++it; 1101 ++it;
1101 } 1102 }
1102 1103
1103 return true; 1104 return true;
1104} 1105}
1105 1106
1106void OKeyConfigWidget::updateItem( Opie::Ui::Private::OKeyListViewItem *item, 1107void OKeyConfigWidget::updateItem( Opie::Ui::Internal::OKeyListViewItem *item,
1107 const OKeyPair& newItem) { 1108 const OKeyPair& newItem) {
1108 /* sanity check 1109 /* sanity check
1109 * check against the blacklist of the manager 1110 * check against the blacklist of the manager
1110 * check if another item uses this key which is o(n) at least 1111 * check if another item uses this key which is o(n) at least
1111 */ 1112 */
1112 if ( !newItem.isEmpty() && !sanityCheck(item, newItem )) 1113 if ( !newItem.isEmpty() && !sanityCheck(item, newItem ))
1113 return; 1114 return;
1114 1115
1115 1116
1116 1117
1117 /* 1118 /*
1118 * If immediate we need to remove and readd the key 1119 * If immediate we need to remove and readd the key
1119 */ 1120 */
1120 if ( m_mode == Imediate ) 1121 if ( m_mode == Imediate )
1121 item->manager()->removeKeyConfig( item->item() ); 1122 item->manager()->removeKeyConfig( item->item() );
1122 1123
1123 item->item().setKeyPair( newItem ); 1124 item->item().setKeyPair( newItem );
1124 item->updateText(); 1125 item->updateText();
1125 1126
1126 if ( m_mode == Imediate ) 1127 if ( m_mode == Imediate )
1127 item->manager()->addKeyConfig( item->item() ); 1128 item->manager()->addKeyConfig( item->item() );
1128} 1129}
1129 1130
1130 1131
1131 1132
1132///// 1133/////
1133OKeyChooserConfigDialog::OKeyChooserConfigDialog( QWidget* par, const char* nam, 1134OKeyChooserConfigDialog::OKeyChooserConfigDialog( QWidget* par, const char* nam,
1134 bool mod, WFlags fl ) 1135 bool mod, WFlags fl )
1135 : QDialog( par, nam, mod, fl ), m_virtKey( false ), m_keyPair( OKeyPair::emptyKey() ) , 1136 : QDialog( par, nam, mod, fl ), m_virtKey( false ), m_keyPair( OKeyPair::emptyKey() ) ,
1136 m_key( 0 ), m_mod( 0 ) { 1137 m_key( 0 ), m_mod( 0 ) {
1137 setFocusPolicy( StrongFocus ); 1138 setFocusPolicy( StrongFocus );
1138 1139
1139 QHBoxLayout *lay = new QHBoxLayout( this ); 1140 QHBoxLayout *lay = new QHBoxLayout( this );
1140 1141
1141 QLabel *lbl = new QLabel( tr("Configure Key" ), this ); 1142 QLabel *lbl = new QLabel( tr("Configure Key" ), this );
1142 lay->addWidget( lbl ); 1143 lay->addWidget( lbl );
1143 lbl->setFocusPolicy( NoFocus ); 1144 lbl->setFocusPolicy( NoFocus );
1144 1145
1145 m_lbl = new QLabel( this ); 1146 m_lbl = new QLabel( this );
1146 lay->addWidget( m_lbl ); 1147 lay->addWidget( m_lbl );
1147 m_lbl->setFocusPolicy( NoFocus ); 1148 m_lbl->setFocusPolicy( NoFocus );
1148 1149
1149 m_timer = new QTimer( this ); 1150 m_timer = new QTimer( this );
1150 connect(m_timer, SIGNAL(timeout()), 1151 connect(m_timer, SIGNAL(timeout()),
1151 this, SLOT(slotTimeUp()) ); 1152 this, SLOT(slotTimeUp()) );
1152} 1153}
1153 1154
1154OKeyChooserConfigDialog::~OKeyChooserConfigDialog() { 1155OKeyChooserConfigDialog::~OKeyChooserConfigDialog() {
1155} 1156}
1156 1157
1157Opie::Ui::OKeyPair OKeyChooserConfigDialog::keyPair()const{ 1158Opie::Ui::OKeyPair OKeyChooserConfigDialog::keyPair()const{
1158 return m_keyPair; 1159 return m_keyPair;
1159} 1160}
1160 1161
1161void OKeyChooserConfigDialog::keyPressEvent( QKeyEvent* ev ) { 1162void OKeyChooserConfigDialog::keyPressEvent( QKeyEvent* ev ) {
1162 QDialog::keyPressEvent( ev ); 1163 QDialog::keyPressEvent( ev );
1163 1164
1164 if ( ev->isAutoRepeat() ) 1165 if ( ev->isAutoRepeat() )
1165 return; 1166 return;
1166 1167
1167 int mod, key; 1168 int mod, key;
1168 Opie::Ui::Private::fixupKeys( key,mod, ev ); 1169 Opie::Ui::Internal::fixupKeys( key,mod, ev );
1169 1170
1170 /* either we used software keyboard 1171 /* either we used software keyboard
1171 * or we've true support 1172 * or we've true support
1172 */ 1173 */
1173 if ( !m_virtKey && !ev->key()) { 1174 if ( !m_virtKey && !ev->key()) {
1174 m_virtKey = true; 1175 m_virtKey = true;
1175 m_keyPair = OKeyPair( key, mod ); 1176 m_keyPair = OKeyPair( key, mod );
1176 }else{ 1177 }else{
1177 mod = 0; 1178 mod = 0;
1178 switch( key ) { 1179 switch( key ) {
1179 case Qt::Key_Control: 1180 case Qt::Key_Control:
1180 mod = Qt::ControlButton; 1181 mod = Qt::ControlButton;
1181 break; 1182 break;
1182 case Qt::Key_Shift: 1183 case Qt::Key_Shift:
1183 mod = Qt::ShiftButton; 1184 mod = Qt::ShiftButton;
1184 break; 1185 break;
1185 case Qt::Key_Alt: 1186 case Qt::Key_Alt:
1186 mod = Qt::AltButton; 1187 mod = Qt::AltButton;
1187 break; 1188 break;
1188 default: 1189 default:
1189 break; 1190 break;
1190 } 1191 }
1191 if (mod ) { 1192 if (mod ) {
1192 m_mod |= mod; 1193 m_mod |= mod;
1193 key = 0; 1194 key = 0;
1194 }else 1195 }else
1195 m_key = key; 1196 m_key = key;
1196 1197
1197 if ( ( !mod || m_key || key ) && !m_timer->isActive() ) 1198 if ( ( !mod || m_key || key ) && !m_timer->isActive() )
1198 m_timer->start( 150, true ); 1199 m_timer->start( 150, true );
1199 1200
1200 m_keyPair = OKeyPair( m_key, m_mod ); 1201 m_keyPair = OKeyPair( m_key, m_mod );
1201 } 1202 }
1202 1203
1203 m_lbl->setText( Opie::Ui::Private::keyToString( m_keyPair ) ); 1204 m_lbl->setText( Opie::Ui::Internal::keyToString( m_keyPair ) );
1204 1205
1205} 1206}
1206 1207
1207void OKeyChooserConfigDialog::keyReleaseEvent( QKeyEvent* ev ) { 1208void OKeyChooserConfigDialog::keyReleaseEvent( QKeyEvent* ev ) {
1208 m_timer->stop(); 1209 m_timer->stop();
1209 QDialog::keyPressEvent( ev ); 1210 QDialog::keyPressEvent( ev );
1210 1211
1211 if ( ev->isAutoRepeat() ) 1212 if ( ev->isAutoRepeat() )
1212 return; 1213 return;
1213 1214
1214 1215
1215 if ( m_virtKey && !ev->key()) { 1216 if ( m_virtKey && !ev->key()) {
1216 m_virtKey = false; 1217 m_virtKey = false;
1217 slotTimeUp(); 1218 slotTimeUp();
1218 }else { 1219 }else {
1219 int mod = 0; 1220 int mod = 0;
1220 int key = ev->key(); 1221 int key = ev->key();
1221 switch( key ) { 1222 switch( key ) {
1222 case Qt::Key_Control: 1223 case Qt::Key_Control:
1223 mod = Qt::ControlButton; 1224 mod = Qt::ControlButton;
1224 break; 1225 break;
1225 case Qt::Key_Shift: 1226 case Qt::Key_Shift:
1226 mod = Qt::ShiftButton; 1227 mod = Qt::ShiftButton;
1227 break; 1228 break;
1228 case Qt::Key_Alt: 1229 case Qt::Key_Alt:
1229 mod = Qt::AltButton; 1230 mod = Qt::AltButton;
1230 break; 1231 break;
1231 default: 1232 default:
1232 break; 1233 break;
1233 } 1234 }
1234 if (mod ) 1235 if (mod )
1235 m_mod &= ~mod; 1236 m_mod &= ~mod;
1236 else 1237 else
1237 m_key = key; 1238 m_key = key;
1238 m_keyPair = OKeyPair( m_key, m_mod ); 1239 m_keyPair = OKeyPair( m_key, m_mod );
1239 m_lbl->setText( Opie::Ui::Private::keyToString( m_keyPair ) ); 1240 m_lbl->setText( Opie::Ui::Internal::keyToString( m_keyPair ) );
1240 } 1241 }
1241} 1242}
1242 1243
1243 1244
1244void OKeyChooserConfigDialog::slotTimeUp() { 1245void OKeyChooserConfigDialog::slotTimeUp() {
1245 m_mod = m_key = 0; 1246 m_mod = m_key = 0;
1246 QTimer::singleShot(0, this, SIGNAL(keyCaptured()) ); 1247 QTimer::singleShot(0, this, SIGNAL(keyCaptured()) );
1247} 1248}
diff --git a/libopie2/opieui/okeyconfigwidget.h b/libopie2/opieui/okeyconfigwidget.h
index f75ed99..bb8eb6c 100644
--- a/libopie2/opieui/okeyconfigwidget.h
+++ b/libopie2/opieui/okeyconfigwidget.h
@@ -1,322 +1,322 @@
1/* 1/*
2 * Copyright (C) 2004 2 * Copyright (C) 2004
3 * LGPL v2 zecke@handhelds.org 3 * LGPL v2 zecke@handhelds.org
4 */ 4 */
5 5
6 6
7#ifndef ODP_KEY_CONFIG_WIDGET_H 7#ifndef ODP_KEY_CONFIG_WIDGET_H
8#define ODP_KEY_CONFIG_WIDGET_H 8#define ODP_KEY_CONFIG_WIDGET_H
9 9
10#include <opie2/oconfig.h> 10#include <opie2/oconfig.h>
11#include <opie2/odevice.h> 11#include <opie2/odevice.h>
12 12
13#include <qstring.h> 13#include <qstring.h>
14#include <qpixmap.h> 14#include <qpixmap.h>
15#include <qcstring.h> 15#include <qcstring.h>
16#include <qhbox.h> 16#include <qhbox.h>
17#include <qvaluelist.h> 17#include <qvaluelist.h>
18 18
19class QKeyEvent; 19class QKeyEvent;
20class QLabel; 20class QLabel;
21class QPushButton; 21class QPushButton;
22class QListViewItem; 22class QListViewItem;
23class QRadioButton; 23class QRadioButton;
24class QTimer; 24class QTimer;
25 25
26namespace Opie { 26namespace Opie {
27namespace Ui { 27namespace Ui {
28namespace Private { 28namespace Internal {
29 class OKeyConfigWidgetPrivate; 29 class OKeyConfigWidgetPrivate;
30 typedef QValueList<OKeyConfigWidgetPrivate> OKeyConfigWidgetPrivateList; 30 typedef QValueList<OKeyConfigWidgetPrivate> OKeyConfigWidgetPrivateList;
31 class OKeyListViewItem; 31 class OKeyListViewItem;
32} 32}
33 class OListViewItem; 33 class OListViewItem;
34 class OListView; 34 class OListView;
35 35
36/** 36/**
37 * \brief small class representing a Key with possible modifiers 37 * \brief small class representing a Key with possible modifiers
38 * This class holds information about key code and possible 38 * This class holds information about key code and possible
39 * modifier state. That is the lowest level of the key input 39 * modifier state. That is the lowest level of the key input
40 * functions. 40 * functions.
41 * There are also static methods to get special keys. 41 * There are also static methods to get special keys.
42 * OKeyPair will be used with \see OKeyConfigItem 42 * OKeyPair will be used with \see OKeyConfigItem
43 * 43 *
44 * @since 1.2 44 * @since 1.2
45 */ 45 */
46class OKeyPair { 46class OKeyPair {
47public: 47public:
48 typedef QValueList<OKeyPair> List; 48 typedef QValueList<OKeyPair> List;
49 OKeyPair( int key = -1, int modifier = -1); 49 OKeyPair( int key = -1, int modifier = -1);
50 ~OKeyPair(); 50 ~OKeyPair();
51 51
52 bool operator==( const OKeyPair& )const; 52 bool operator==( const OKeyPair& )const;
53 bool operator!=( const OKeyPair& )const; 53 bool operator!=( const OKeyPair& )const;
54 54
55 bool isEmpty()const; 55 bool isEmpty()const;
56 56
57 int keycode()const; 57 int keycode()const;
58 int modifier()const; 58 int modifier()const;
59 59
60 void setKeycode( int ); 60 void setKeycode( int );
61 void setModifier( int ); 61 void setModifier( int );
62 62
63 static OKeyPair returnKey(); 63 static OKeyPair returnKey();
64 static OKeyPair leftArrowKey(); 64 static OKeyPair leftArrowKey();
65 static OKeyPair rightArrowKey(); 65 static OKeyPair rightArrowKey();
66 static OKeyPair upArrowKey(); 66 static OKeyPair upArrowKey();
67 static OKeyPair downArrowKey(); 67 static OKeyPair downArrowKey();
68 static OKeyPair emptyKey(); 68 static OKeyPair emptyKey();
69 static OKeyPair::List hardwareKeys(); 69 static OKeyPair::List hardwareKeys();
70 70
71private: 71private:
72 int m_key; 72 int m_key;
73 int m_mod; 73 int m_mod;
74 class Private; 74 class Private;
75 Private* d; 75 Private* d;
76}; 76};
77 77
78/** 78/**
79 * A class to represent an OKeyPair. 79 * A class to represent an OKeyPair.
80 * It consists out of a Text exposed to the user, Config Key Item, 80 * It consists out of a Text exposed to the user, Config Key Item,
81 * Pixmap, A default OKeyPair and the set OKeyPair. 81 * Pixmap, A default OKeyPair and the set OKeyPair.
82 * You can also pass an id to it 82 * You can also pass an id to it
83 * 83 *
84 * @since 1.1.2 84 * @since 1.1.2
85 */ 85 */
86class OKeyConfigItem { 86class OKeyConfigItem {
87 friend class OKeyConfigManager; 87 friend class OKeyConfigManager;
88public: 88public:
89 typedef QValueList<OKeyConfigItem> List; 89 typedef QValueList<OKeyConfigItem> List;
90 OKeyConfigItem( const QString& text = QString::null , const QCString& config_key = QCString(), 90 OKeyConfigItem( const QString& text = QString::null , const QCString& config_key = QCString(),
91 const QPixmap& symbol = QPixmap(), 91 const QPixmap& symbol = QPixmap(),
92 int id = -1, 92 int id = -1,
93 const OKeyPair& def = OKeyPair::emptyKey(), 93 const OKeyPair& def = OKeyPair::emptyKey(),
94 QObject *caller = 0, const char* slot = 0); 94 QObject *caller = 0, const char* slot = 0);
95 OKeyConfigItem( const Opie::Core::ODeviceButton& ); 95 OKeyConfigItem( const Opie::Core::ODeviceButton& );
96 ~OKeyConfigItem(); 96 ~OKeyConfigItem();
97 97
98 bool operator==( const OKeyConfigItem& )const; 98 bool operator==( const OKeyConfigItem& )const;
99 bool operator!=( const OKeyConfigItem& )const; 99 bool operator!=( const OKeyConfigItem& )const;
100 100
101 QString text()const; 101 QString text()const;
102 QPixmap pixmap()const; 102 QPixmap pixmap()const;
103 int id()const; 103 int id()const;
104 104
105 105
106 106
107 OKeyPair keyPair()const; 107 OKeyPair keyPair()const;
108 OKeyPair defaultKeyPair()const; 108 OKeyPair defaultKeyPair()const;
109 QCString configKey()const; 109 QCString configKey()const;
110 110
111 111
112 void setText( const QString& text ); 112 void setText( const QString& text );
113 void setPixmap( const QPixmap& ); 113 void setPixmap( const QPixmap& );
114 void setKeyPair( const OKeyPair& ); 114 void setKeyPair( const OKeyPair& );
115 void setDefaultKeyPair( const OKeyPair& ); 115 void setDefaultKeyPair( const OKeyPair& );
116 116
117 bool isEmpty()const; 117 bool isEmpty()const;
118 118
119protected: 119protected:
120 QObject *object()const; 120 QObject *object()const;
121 QCString slot()const; 121 QCString slot()const;
122 void setId( int id ); 122 void setId( int id );
123 void setConfigKey( const QCString& ); 123 void setConfigKey( const QCString& );
124 124
125private: 125private:
126 QString m_text; 126 QString m_text;
127 QCString m_config; 127 QCString m_config;
128 QPixmap m_pix; 128 QPixmap m_pix;
129 int m_id; 129 int m_id;
130 OKeyPair m_key; 130 OKeyPair m_key;
131 OKeyPair m_def; 131 OKeyPair m_def;
132 QObject *m_obj; 132 QObject *m_obj;
133 QCString m_str; 133 QCString m_str;
134 class Private; 134 class Private;
135 Private *d; 135 Private *d;
136}; 136};
137 137
138 138
139 139
140/** 140/**
141 * \brief A manager to load and save Key Actions and get notified 141 * \brief A manager to load and save Key Actions and get notified
142 * This is the Manager for KeyActions. 142 * This is the Manager for KeyActions.
143 * You can say from which config and group to read data, to grab the 143 * You can say from which config and group to read data, to grab the
144 * keyboard to handle hardware keys, you can supply a blacklist of 144 * keyboard to handle hardware keys, you can supply a blacklist of
145 * keys which should not be used by allowed to be used. 145 * keys which should not be used by allowed to be used.
146 * You can even pass this manager to a Widget to do the configuration for you. 146 * You can even pass this manager to a Widget to do the configuration for you.
147 * You need to add OKeyConfigItem for your keys and then issue a load() to 147 * You need to add OKeyConfigItem for your keys and then issue a load() to
148 * read the Key information. 148 * read the Key information.
149 * You can either handle the QKeyEvent yourself and ask this class if it is 149 * You can either handle the QKeyEvent yourself and ask this class if it is
150 * handled by your action and let give you the action. Or you can install 150 * handled by your action and let give you the action. Or you can install
151 * the event filter and get a signal. 151 * the event filter and get a signal.
152 * You need to load ans save yourself! 152 * You need to load ans save yourself!
153 * 153 *
154 * @since 1.1.2 154 * @since 1.1.2
155 */ 155 */
156class OKeyConfigManager : public QObject { 156class OKeyConfigManager : public QObject {
157 Q_OBJECT 157 Q_OBJECT
158 typedef QMap<int, OKeyConfigItem::List> OKeyMapConfigPrivate; 158 typedef QMap<int, OKeyConfigItem::List> OKeyMapConfigPrivate;
159public: 159public:
160 OKeyConfigManager(Opie::Core::OConfig *conf = 0, 160 OKeyConfigManager(Opie::Core::OConfig *conf = 0,
161 const QString& group = QString::null, 161 const QString& group = QString::null,
162 const OKeyPair::List &block = OKeyPair::List(), 162 const OKeyPair::List &block = OKeyPair::List(),
163 bool grabkeyboard = false, QObject * par = 0, 163 bool grabkeyboard = false, QObject * par = 0,
164 const char* name = 0 ); 164 const char* name = 0 );
165 ~OKeyConfigManager(); 165 ~OKeyConfigManager();
166 166
167 void load(); 167 void load();
168 void save(); 168 void save();
169 169
170 OKeyConfigItem handleKeyEvent( QKeyEvent* ); 170 OKeyConfigItem handleKeyEvent( QKeyEvent* );
171 int handleKeyEventId( QKeyEvent* ); 171 int handleKeyEventId( QKeyEvent* );
172 172
173 void addKeyConfig( const OKeyConfigItem& ); 173 void addKeyConfig( const OKeyConfigItem& );
174 void removeKeyConfig( const OKeyConfigItem& ); 174 void removeKeyConfig( const OKeyConfigItem& );
175 void clearKeyConfig(); 175 void clearKeyConfig();
176 176
177 void addToBlackList( const OKeyPair& ); 177 void addToBlackList( const OKeyPair& );
178 void removeFromBlackList( const OKeyPair& ); 178 void removeFromBlackList( const OKeyPair& );
179 void clearBlackList(); 179 void clearBlackList();
180 OKeyPair::List blackList()const; 180 OKeyPair::List blackList()const;
181 181
182 void handleWidget( QWidget* ); 182 void handleWidget( QWidget* );
183 183
184 bool eventFilter( QObject*, QEvent* ); 184 bool eventFilter( QObject*, QEvent* );
185 185
186 OKeyConfigItem::List keyConfigList()const; 186 OKeyConfigItem::List keyConfigList()const;
187signals: 187signals:
188 /** 188 /**
189 * The Signals are triggered on KeyPress and KeyRelease! 189 * The Signals are triggered on KeyPress and KeyRelease!
190 * You can check the isDown of the QKeyEvent 190 * You can check the isDown of the QKeyEvent
191 * @see QKeyEvent 191 * @see QKeyEvent
192 */ 192 */
193 void actionActivated( QWidget*, QKeyEvent*, const Opie::Ui::OKeyConfigItem& ); 193 void actionActivated( QWidget*, QKeyEvent*, const Opie::Ui::OKeyConfigItem& );
194 194
195 /** 195 /**
196 * This Signal correspondents to the OKeyConfigItem slot 196 * This Signal correspondents to the OKeyConfigItem slot
197 * and object 197 * and object
198 * 198 *
199 * @see OKeyConfigItem::slot 199 * @see OKeyConfigItem::slot
200 * @see OKeyConfigItem::object 200 * @see OKeyConfigItem::object
201 */ 201 */
202 void actionActivated( QWidget* par, QKeyEvent* key); 202 void actionActivated( QWidget* par, QKeyEvent* key);
203 203
204private: 204private:
205 OKeyConfigItem::List keyList( int ); 205 OKeyConfigItem::List keyList( int );
206 OKeyConfigItem::List m_keys; 206 OKeyConfigItem::List m_keys;
207 QValueList<QWidget*> m_widgets; 207 QValueList<QWidget*> m_widgets;
208 Opie::Core::OConfig *m_conf; 208 Opie::Core::OConfig *m_conf;
209 QString m_group; 209 QString m_group;
210 OKeyPair::List m_blackKeys; 210 OKeyPair::List m_blackKeys;
211 bool m_grab : 1; 211 bool m_grab : 1;
212 OKeyMapConfigPrivate *m_map; 212 OKeyMapConfigPrivate *m_map;
213 class Private; 213 class Private;
214 Private *d; 214 Private *d;
215}; 215};
216 216
217 217
218/** 218/**
219 * With this Widget you can let the Keyboard Shortcuts 219 * With this Widget you can let the Keyboard Shortcuts
220 * be configured by the user. 220 * be configured by the user.
221 * There are two ways you can use this widget. Either in a tab were 221 * There are two ways you can use this widget. Either in a tab were
222 * all changes are immediately getting into effect or in a queue 222 * all changes are immediately getting into effect or in a queue
223 * were you ask for saving. Save won't write the data but only set 223 * were you ask for saving. Save won't write the data but only set
224 * it to the OKeyConfigManager 224 * it to the OKeyConfigManager
225 * 225 *
226 * @since 1.2 226 * @since 1.2
227 */ 227 */
228class OKeyConfigWidget : public QWidget { 228class OKeyConfigWidget : public QWidget {
229 Q_OBJECT 229 Q_OBJECT
230 230
231public: 231public:
232 /** 232 /**
233 * Immediate Apply the change directly to the underlying OKeyConfigManager 233 * Immediate Apply the change directly to the underlying OKeyConfigManager
234 * Queue Save all items and then apply when you save() 234 * Queue Save all items and then apply when you save()
235 */ 235 */
236 enum ChangeMode { Imediate, Queue }; 236 enum ChangeMode { Imediate, Queue };
237 OKeyConfigWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 237 OKeyConfigWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
238 ~OKeyConfigWidget(); 238 ~OKeyConfigWidget();
239 239
240 void setChangeMode( enum ChangeMode ); 240 void setChangeMode( enum ChangeMode );
241 ChangeMode changeMode()const; 241 ChangeMode changeMode()const;
242 242
243 void insert( const QString& name, OKeyConfigManager* ); 243 void insert( const QString& name, OKeyConfigManager* );
244 244
245 void load(); 245 void load();
246 void save(); 246 void save();
247 247
248private slots: 248private slots:
249 void slotListViewItem( QListViewItem* ); 249 void slotListViewItem( QListViewItem* );
250 void slotNoKey(); 250 void slotNoKey();
251 void slotDefaultKey(); 251 void slotDefaultKey();
252 void slotCustomKey(); 252 void slotCustomKey();
253 void slotConfigure(); 253 void slotConfigure();
254 254
255private: 255private:
256 static bool sanityCheck( Opie::Ui::Private::OKeyListViewItem* man, 256 static bool sanityCheck( Opie::Ui::Internal::OKeyListViewItem* man,
257 const OKeyPair& newItem ); 257 const OKeyPair& newItem );
258 void updateItem( Opie::Ui::Private::OKeyListViewItem* man, 258 void updateItem( Opie::Ui::Internal::OKeyListViewItem* man,
259 const OKeyPair& newItem); 259 const OKeyPair& newItem);
260 void initUi(); 260 void initUi();
261 Opie::Ui::OListView *m_view; 261 Opie::Ui::OListView *m_view;
262 Opie::Ui::Private::OKeyConfigWidgetPrivateList m_list; 262 Opie::Ui::Internal::OKeyConfigWidgetPrivateList m_list;
263 QLabel *m_lbl; 263 QLabel *m_lbl;
264 QPushButton *m_btn; 264 QPushButton *m_btn;
265 QRadioButton *m_def, *m_cus, *m_none; 265 QRadioButton *m_def, *m_cus, *m_none;
266 QWidget* m_box; 266 QWidget* m_box;
267 ChangeMode m_mode; 267 ChangeMode m_mode;
268 class Private; 268 class Private;
269 Private *d; 269 Private *d;
270}; 270};
271 271
272 272
273/** 273/**
274 * This is a small dialog that allows you to 274 * This is a small dialog that allows you to
275 * capture a key sequence. 275 * capture a key sequence.
276 * If you want it to close after a key was captured you 276 * If you want it to close after a key was captured you
277 * can use this code snippet. 277 * can use this code snippet.
278 * 278 *
279 * \code 279 * \code
280 * OKeyChooserConfigDialog diag(0,0,true); 280 * OKeyChooserConfigDialog diag(0,0,true);
281 * connect(&diag,SIGNAL(keyCaptured()), 281 * connect(&diag,SIGNAL(keyCaptured()),
282 * this,SLOT(accept())); 282 * this,SLOT(accept()));
283 * if( QPEApplication::execDialog(&diag) == QDialog::Accept ){ 283 * if( QPEApplication::execDialog(&diag) == QDialog::Accept ){
284 * take_the_key_and_do_something 284 * take_the_key_and_do_something
285 * } 285 * }
286 * 286 *
287 * \endcode 287 * \endcode
288 * 288 *
289 */ 289 */
290class OKeyChooserConfigDialog : public QDialog { 290class OKeyChooserConfigDialog : public QDialog {
291 Q_OBJECT 291 Q_OBJECT
292public: 292public:
293 OKeyChooserConfigDialog( QWidget* parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 ); 293 OKeyChooserConfigDialog( QWidget* parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 );
294 ~OKeyChooserConfigDialog(); 294 ~OKeyChooserConfigDialog();
295 295
296 OKeyPair keyPair()const; 296 OKeyPair keyPair()const;
297 297
298protected: 298protected:
299 void keyPressEvent( QKeyEvent* ); 299 void keyPressEvent( QKeyEvent* );
300 void keyReleaseEvent( QKeyEvent* ); 300 void keyReleaseEvent( QKeyEvent* );
301 301
302signals: 302signals:
303 void keyCaptured(); 303 void keyCaptured();
304 304
305private slots: 305private slots:
306 void slotTimeUp(); 306 void slotTimeUp();
307 307
308private: 308private:
309 QTimer *m_timer; 309 QTimer *m_timer;
310 QLabel *m_lbl; 310 QLabel *m_lbl;
311 bool m_virtKey : 1; 311 bool m_virtKey : 1;
312 OKeyPair m_keyPair; 312 OKeyPair m_keyPair;
313 int m_key, m_mod; 313 int m_key, m_mod;
314 class Private; 314 class Private;
315 Private *d; 315 Private *d;
316}; 316};
317 317
318} 318}
319} 319}
320 320
321 321
322#endif 322#endif
diff --git a/libopie2/opieui/okeyconfigwidget_p.h b/libopie2/opieui/okeyconfigwidget_p.h
index e7eaba6..7690846 100644
--- a/libopie2/opieui/okeyconfigwidget_p.h
+++ b/libopie2/opieui/okeyconfigwidget_p.h
@@ -1,33 +1,33 @@
1/* 1/*
2 * Only Internal implemented in the same .cpp file anyway 2 * Only Internal implemented in the same .cpp file anyway
3 */ 3 */
4#include <opie2/olistview.h> 4#include <opie2/olistview.h>
5 5
6 6
7namespace Opie { 7namespace Opie {
8namespace Ui { 8namespace Ui {
9namespace Private { 9namespace Internal {
10 static QString keyToString( const OKeyPair& ); 10 static QString keyToString( const OKeyPair& );
11 static void fixupKeys( int&, int&, QKeyEvent* ); 11 static void fixupKeys( int&, int&, QKeyEvent* );
12 class OKeyListViewItem : public Opie::Ui::OListViewItem { 12 class OKeyListViewItem : public Opie::Ui::OListViewItem {
13 public: 13 public:
14 OKeyListViewItem( const OKeyConfigItem& item, OKeyConfigManager*, Opie::Ui::OListViewItem* parent); 14 OKeyListViewItem( const OKeyConfigItem& item, OKeyConfigManager*, Opie::Ui::OListViewItem* parent);
15 ~OKeyListViewItem(); 15 ~OKeyListViewItem();
16 16
17 void setDefault(); 17 void setDefault();
18 18
19 OKeyConfigItem& item(); 19 OKeyConfigItem& item();
20 OKeyConfigItem origItem()const; 20 OKeyConfigItem origItem()const;
21 void setItem( const OKeyConfigItem& item ); 21 void setItem( const OKeyConfigItem& item );
22 void updateText(); 22 void updateText();
23 23
24 OKeyConfigManager *manager(); 24 OKeyConfigManager *manager();
25 private: 25 private:
26 OKeyConfigItem m_item; 26 OKeyConfigItem m_item;
27 OKeyConfigItem m_origItem; 27 OKeyConfigItem m_origItem;
28 OKeyConfigManager* m_manager; 28 OKeyConfigManager* m_manager;
29 29
30 }; 30 };
31} 31}
32} 32}
33} 33}
diff --git a/libopie2/opieui/otaskbarapplet.h b/libopie2/opieui/otaskbarapplet.h
index 0c85ee7..ec7b9c4 100644
--- a/libopie2/opieui/otaskbarapplet.h
+++ b/libopie2/opieui/otaskbarapplet.h
@@ -1,129 +1,129 @@
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 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 4              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 5 =.
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 31
32#ifndef OTASKBARAPPLET_H 32#ifndef OTASKBARAPPLET_H
33#define OTASKBARAPPLET_H 33#define OTASKBARAPPLET_H
34 34
35#include <qpe/taskbarappletinterface.h> 35#include <qpe/taskbarappletinterface.h>
36#include <qpe/qcom.h> 36#include <qpe/qcom.h>
37 37
38#include <qwidget.h> 38#include <qwidget.h>
39 39
40class QMouseEvent; 40class QMouseEvent;
41 41
42namespace Opie { 42namespace Opie {
43namespace Ui { 43namespace Ui {
44namespace Private { 44namespace Internal {
45/*====================================================================================== 45/*======================================================================================
46 * OTaskbarAppletWrapper 46 * OTaskbarAppletWrapper
47 *======================================================================================*/ 47 *======================================================================================*/
48 48
49class OTaskbarAppletWrapperPrivate; 49class OTaskbarAppletWrapperPrivate;
50template<class T> class OTaskbarAppletWrapper : public TaskbarAppletInterface 50template<class T> class OTaskbarAppletWrapper : public TaskbarAppletInterface
51{ 51{
52 public: 52 public:
53 OTaskbarAppletWrapper():_applet( 0 ) 53 OTaskbarAppletWrapper():_applet( 0 )
54 { 54 {
55 } 55 }
56 56
57 virtual ~OTaskbarAppletWrapper() 57 virtual ~OTaskbarAppletWrapper()
58 { 58 {
59 delete _applet; 59 delete _applet;
60 } 60 }
61 61
62 QRESULT queryInterface( const QUuid& uuid, QUnknownInterface** iface ) 62 QRESULT queryInterface( const QUuid& uuid, QUnknownInterface** iface )
63 { 63 {
64 qDebug( "OTaskbarAppletWrapper::queryInterface()" ); 64 qDebug( "OTaskbarAppletWrapper::queryInterface()" );
65 *iface = 0; 65 *iface = 0;
66 if ( uuid == IID_QUnknown ) 66 if ( uuid == IID_QUnknown )
67 *iface = this; 67 *iface = this;
68 else if ( uuid == IID_TaskbarApplet ) 68 else if ( uuid == IID_TaskbarApplet )
69 *iface = this; 69 *iface = this;
70 else 70 else
71 return QS_FALSE; 71 return QS_FALSE;
72 72
73 if ( *iface ) (*iface)->addRef(); 73 if ( *iface ) (*iface)->addRef();
74 return QS_OK; 74 return QS_OK;
75 } 75 }
76 76
77 Q_REFCOUNT 77 Q_REFCOUNT
78 78
79 virtual T* applet( QWidget* parent ) 79 virtual T* applet( QWidget* parent )
80 { 80 {
81 if ( !_applet ) _applet = new T( parent ); 81 if ( !_applet ) _applet = new T( parent );
82 return _applet; 82 return _applet;
83 } 83 }
84 84
85 virtual int position() const 85 virtual int position() const
86 { 86 {
87 return T::position(); 87 return T::position();
88 } 88 }
89 89
90 private: 90 private:
91 T* _applet; 91 T* _applet;
92 OTaskbarAppletWrapperPrivate *d; 92 OTaskbarAppletWrapperPrivate *d;
93}; 93};
94 94
95} 95}
96/*====================================================================================== 96/*======================================================================================
97 * OTaskbarApplet 97 * OTaskbarApplet
98 *======================================================================================*/ 98 *======================================================================================*/
99 99
100// Must be inline until after we shipped Opie 1.0 100// Must be inline until after we shipped Opie 1.0
101 101
102// Having OTaskBarApplet reside in libopieui2 is not possible 102// Having OTaskBarApplet reside in libopieui2 is not possible
103// until we link the launcher binary against libopieui2 - 103// until we link the launcher binary against libopieui2 -
104// otherwise the necessary symbols are not present, when 104// otherwise the necessary symbols are not present, when
105// the dynamic loader [dlopen] tries to resolve an applet which 105// the dynamic loader [dlopen] tries to resolve an applet which
106// inherits OTaskbarApplet 106// inherits OTaskbarApplet
107 107
108class OTaskbarApplet : public QWidget 108class OTaskbarApplet : public QWidget
109{ 109{
110 public: 110 public:
111 OTaskbarApplet( QWidget* parent, const char* name = 0 ); 111 OTaskbarApplet( QWidget* parent, const char* name = 0 );
112 virtual ~OTaskbarApplet(); 112 virtual ~OTaskbarApplet();
113 113
114 protected: 114 protected:
115 virtual void popup( QWidget* widget ); 115 virtual void popup( QWidget* widget );
116private: 116private:
117 class Private; 117 class Private;
118 Private *d; 118 Private *d;
119}; 119};
120} 120}
121} 121}
122 122
123#define EXPORT_OPIE_APPLET_v1( AppLet ) \ 123#define EXPORT_OPIE_APPLET_v1( AppLet ) \
124 Q_EXPORT_INTERFACE() { \ 124 Q_EXPORT_INTERFACE() { \
125 Q_CREATE_INSTANCE( Opie::Ui::Private::OTaskbarAppletWrapper<AppLet> ) \ 125 Q_CREATE_INSTANCE( Opie::Ui::Internal::OTaskbarAppletWrapper<AppLet> ) \
126 } 126 }
127 127
128#endif 128#endif
129 129