summaryrefslogtreecommitdiff
authorsandman <sandman>2002-06-27 01:39:00 (UTC)
committer sandman <sandman>2002-06-27 01:39:00 (UTC)
commited8d1696ca8f0407cb7e6b91cc8d410dede5ccdc (patch) (unidiff)
treeac60a3f150442a35d13fbe90733a70f891c81a28
parenta86c09e8a12b504471ffeb8966e34a79dd8518b5 (diff)
downloadopie-ed8d1696ca8f0407cb7e6b91cc8d410dede5ccdc.zip
opie-ed8d1696ca8f0407cb7e6b91cc8d410dede5ccdc.tar.gz
opie-ed8d1696ca8f0407cb7e6b91cc8d410dede5ccdc.tar.bz2
Including kernel headers in user space apps is bad .. just copy the defines
(There were problems with some toolchain configurations)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 87a9739..76d62ef 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -1,435 +1,446 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of 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** $Id$ 19** $Id$
20** 20**
21**********************************************************************/ 21**********************************************************************/
22#define QTOPIA_INTERNAL_LANGLIST 22#define QTOPIA_INTERNAL_LANGLIST
23#include <stdlib.h> 23#include <stdlib.h>
24#include <unistd.h> 24#include <unistd.h>
25#include <qfile.h> 25#include <qfile.h>
26#ifdef Q_WS_QWS 26#ifdef Q_WS_QWS
27#ifndef QT_NO_COP 27#ifndef QT_NO_COP
28#if QT_VERSION <= 231 28#if QT_VERSION <= 231
29#define private public 29#define private public
30#define sendLocally processEvent 30#define sendLocally processEvent
31#include "qcopenvelope_qws.h" 31#include "qcopenvelope_qws.h"
32#undef private 32#undef private
33#else 33#else
34#include "qcopenvelope_qws.h" 34#include "qcopenvelope_qws.h"
35#endif 35#endif
36#endif 36#endif
37#include <qwindowsystem_qws.h> 37#include <qwindowsystem_qws.h>
38#endif 38#endif
39#include <qtextstream.h> 39#include <qtextstream.h>
40#include <qpalette.h> 40#include <qpalette.h>
41#include <qbuffer.h> 41#include <qbuffer.h>
42#include <qptrdict.h> 42#include <qptrdict.h>
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qdir.h> 44#include <qdir.h>
45#include <qlabel.h> 45#include <qlabel.h>
46#include <qdialog.h> 46#include <qdialog.h>
47#include <qdragobject.h> 47#include <qdragobject.h>
48#include <qevent.h> 48#include <qevent.h>
49#include <qtooltip.h> 49#include <qtooltip.h>
50#include <qsignal.h> 50#include <qsignal.h>
51#include <linux/fb.h> 51
52
53//#include <linux/fb.h> better not rely on kernel headers in userspace ...
54
55/* VESA Blanking Levels */
56#define VESA_NO_BLANKING 0
57#define VESA_VSYNC_SUSPEND 1
58#define VESA_HSYNC_SUSPEND 2
59#define VESA_POWERDOWN 3
60
61#define FBIOBLANK 0x4611
62
52 63
53#include <qsignal.h> 64#include <qsignal.h>
54#include "qpeapplication.h" 65#include "qpeapplication.h"
55#include "qpestyle.h" 66#include "qpestyle.h"
56#if QT_VERSION >= 300 67#if QT_VERSION >= 300
57#include <qstylefactory.h> 68#include <qstylefactory.h>
58#else 69#else
59#include <qplatinumstyle.h> 70#include <qplatinumstyle.h>
60#include <qwindowsstyle.h> 71#include <qwindowsstyle.h>
61#include <qmotifstyle.h> 72#include <qmotifstyle.h>
62#include <qmotifplusstyle.h> 73#include <qmotifplusstyle.h>
63#include "lightstyle.h" 74#include "lightstyle.h"
64#endif 75#endif
65#include "global.h" 76#include "global.h"
66#include "resource.h" 77#include "resource.h"
67#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 78#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
68#include "qutfcodec.h" 79#include "qutfcodec.h"
69#endif 80#endif
70#include "config.h" 81#include "config.h"
71#include "network.h" 82#include "network.h"
72#include "fontmanager.h" 83#include "fontmanager.h"
73#include "fontdatabase.h" 84#include "fontdatabase.h"
74 85
75#include "power.h" 86#include "power.h"
76#include "alarmserver.h" 87#include "alarmserver.h"
77#include "applnk.h" 88#include "applnk.h"
78#include "qpemenubar.h" 89#include "qpemenubar.h"
79 90
80#include <unistd.h> 91#include <unistd.h>
81#include <sys/file.h> 92#include <sys/file.h>
82#include <sys/ioctl.h> 93#include <sys/ioctl.h>
83#include <sys/soundcard.h> 94#include <sys/soundcard.h>
84 95
85// for setBacklight() 96// for setBacklight()
86#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 97#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
87#include <linux/fb.h> 98#include <linux/fb.h>
88#include <sys/types.h> 99#include <sys/types.h>
89#include <sys/stat.h> 100#include <sys/stat.h>
90#endif 101#endif
91#include <stdlib.h> 102#include <stdlib.h>
92 103
93#include <dlfcn.h> // for Liquid HACK 104#include <dlfcn.h> // for Liquid HACK
94 105
95class QPEApplicationData { 106class QPEApplicationData {
96public: 107public:
97 QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE), 108 QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE),
98 kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE), 109 kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE),
99 forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0), 110 forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0),
100 keep_running(TRUE) 111 keep_running(TRUE)
101 { 112 {
102 qcopq.setAutoDelete(TRUE); 113 qcopq.setAutoDelete(TRUE);
103 } 114 }
104 115
105 int presstimer; 116 int presstimer;
106 QWidget* presswidget; 117 QWidget* presswidget;
107 QPoint presspos; 118 QPoint presspos;
108 bool rightpressed; 119 bool rightpressed;
109 int kbgrabber; 120 int kbgrabber;
110 bool kbregrab; 121 bool kbregrab;
111 bool notbusysent; 122 bool notbusysent;
112 QString appName; 123 QString appName;
113 struct QCopRec { 124 struct QCopRec {
114 QCopRec(const QCString &ch, const QCString &msg, 125 QCopRec(const QCString &ch, const QCString &msg,
115 const QByteArray &d) : 126 const QByteArray &d) :
116 channel(ch), message(msg), data(d) { } 127 channel(ch), message(msg), data(d) { }
117 128
118 QCString channel; 129 QCString channel;
119 QCString message; 130 QCString message;
120 QByteArray data; 131 QByteArray data;
121 }; 132 };
122 bool preloaded; 133 bool preloaded;
123 bool forceshow; 134 bool forceshow;
124 bool nomaximize; 135 bool nomaximize;
125 QWidget* qpe_main_widget; 136 QWidget* qpe_main_widget;
126 bool keep_running; 137 bool keep_running;
127 QList<QCopRec> qcopq; 138 QList<QCopRec> qcopq;
128 139
129 void enqueueQCop(const QCString &ch, const QCString &msg, 140 void enqueueQCop(const QCString &ch, const QCString &msg,
130 const QByteArray &data) 141 const QByteArray &data)
131 { 142 {
132 qcopq.append(new QCopRec(ch,msg,data)); 143 qcopq.append(new QCopRec(ch,msg,data));
133 } 144 }
134 void sendQCopQ() 145 void sendQCopQ()
135 { 146 {
136 QCopRec* r; 147 QCopRec* r;
137 for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it) 148 for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it)
138 QCopChannel::sendLocally(r->channel,r->message,r->data); 149 QCopChannel::sendLocally(r->channel,r->message,r->data);
139 qcopq.clear(); 150 qcopq.clear();
140 } 151 }
141}; 152};
142 153
143class ResourceMimeFactory : public QMimeSourceFactory { 154class ResourceMimeFactory : public QMimeSourceFactory {
144public: 155public:
145 ResourceMimeFactory() 156 ResourceMimeFactory()
146 { 157 {
147 setFilePath( Global::helpPath() ); 158 setFilePath( Global::helpPath() );
148 setExtensionType("html","text/html;charset=UTF-8"); 159 setExtensionType("html","text/html;charset=UTF-8");
149 } 160 }
150 161
151 const QMimeSource* data(const QString& abs_name) const 162 const QMimeSource* data(const QString& abs_name) const
152 { 163 {
153 const QMimeSource* r = QMimeSourceFactory::data(abs_name); 164 const QMimeSource* r = QMimeSourceFactory::data(abs_name);
154 if ( !r ) { 165 if ( !r ) {
155 int sl = abs_name.length(); 166 int sl = abs_name.length();
156 do { 167 do {
157 sl = abs_name.findRev('/',sl-1); 168 sl = abs_name.findRev('/',sl-1);
158 QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name; 169 QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name;
159 int dot = name.findRev('.'); 170 int dot = name.findRev('.');
160 if ( dot >= 0 ) 171 if ( dot >= 0 )
161 name = name.left(dot); 172 name = name.left(dot);
162 QImage img = Resource::loadImage(name); 173 QImage img = Resource::loadImage(name);
163 if ( !img.isNull() ) 174 if ( !img.isNull() )
164 r = new QImageDrag(img); 175 r = new QImageDrag(img);
165 } while (!r && sl>0); 176 } while (!r && sl>0);
166 } 177 }
167 return r; 178 return r;
168 } 179 }
169}; 180};
170 181
171static int muted=0; 182static int muted=0;
172static int micMuted=0; 183static int micMuted=0;
173 184
174static void setVolume(int t=0, int percent=-1) 185static void setVolume(int t=0, int percent=-1)
175{ 186{
176 switch (t) { 187 switch (t) {
177 case 0: { 188 case 0: {
178 Config cfg("qpe"); 189 Config cfg("qpe");
179 cfg.setGroup("Volume"); 190 cfg.setGroup("Volume");
180 if ( percent < 0 ) 191 if ( percent < 0 )
181 percent = cfg.readNumEntry("VolumePercent",50); 192 percent = cfg.readNumEntry("VolumePercent",50);
182 int fd = 0; 193 int fd = 0;
183 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 194 if ((fd = open("/dev/mixer", O_RDWR))>=0) {
184 int vol = muted ? 0 : percent; 195 int vol = muted ? 0 : percent;
185 // set both channels to same volume 196 // set both channels to same volume
186 vol |= vol << 8; 197 vol |= vol << 8;
187 ioctl(fd, MIXER_WRITE(0), &vol); 198 ioctl(fd, MIXER_WRITE(0), &vol);
188 ::close(fd); 199 ::close(fd);
189 } 200 }
190 } break; 201 } break;
191 } 202 }
192} 203}
193 204
194static void setMic(int t=0, int percent=-1) 205static void setMic(int t=0, int percent=-1)
195{ 206{
196 switch (t) { 207 switch (t) {
197 case 0: { 208 case 0: {
198 Config cfg("qpe"); 209 Config cfg("qpe");
199 cfg.setGroup("Volume"); 210 cfg.setGroup("Volume");
200 if ( percent < 0 ) 211 if ( percent < 0 )
201 percent = cfg.readNumEntry("Mic",50); 212 percent = cfg.readNumEntry("Mic",50);
202 213
203 int fd = 0; 214 int fd = 0;
204 int mic = micMuted ? 0 : percent; 215 int mic = micMuted ? 0 : percent;
205 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 216 if ((fd = open("/dev/mixer", O_RDWR))>=0) {
206 ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic); 217 ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic);
207 ::close(fd); 218 ::close(fd);
208 } 219 }
209 } break; 220 } break;
210 } 221 }
211} 222}
212 223
213int qpe_sysBrightnessSteps() 224int qpe_sysBrightnessSteps()
214{ 225{
215#if defined(QT_QWS_IPAQ) 226#if defined(QT_QWS_IPAQ)
216 return 255; 227 return 255;
217#elif defined(QT_QWS_EBX) 228#elif defined(QT_QWS_EBX)
218 return 4; 229 return 4;
219#else 230#else
220 return 255; // ? 231 return 255; // ?
221#endif 232#endif
222} 233}
223 234
224 235
225static int& hack(int& i) 236static int& hack(int& i)
226{ 237{
227#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 238#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
228 // These should be created, but aren't in Qt 2.3.0 239 // These should be created, but aren't in Qt 2.3.0
229 (void)new QUtf8Codec; 240 (void)new QUtf8Codec;
230 (void)new QUtf16Codec; 241 (void)new QUtf16Codec;
231#endif 242#endif
232 return i; 243 return i;
233} 244}
234 245
235static bool forced_off = FALSE; 246static bool forced_off = FALSE;
236static int curbl=-1; 247static int curbl=-1;
237 248
238static int backlight() 249static int backlight()
239{ 250{
240 if ( curbl == -1 ) { 251 if ( curbl == -1 ) {
241 // Read from config 252 // Read from config
242 Config config( "qpe" ); 253 Config config( "qpe" );
243 config.setGroup( "Screensaver" ); 254 config.setGroup( "Screensaver" );
244 curbl = config.readNumEntry("Brightness",255); 255 curbl = config.readNumEntry("Brightness",255);
245 } 256 }
246 return curbl; 257 return curbl;
247} 258}
248 259
249static void setBacklight(int bright) 260static void setBacklight(int bright)
250{ 261{
251 if ( bright == -3 ) { 262 if ( bright == -3 ) {
252 // Forced on 263 // Forced on
253 forced_off = FALSE; 264 forced_off = FALSE;
254 bright = -1; 265 bright = -1;
255 } 266 }
256 if ( forced_off && bright != -2 ) 267 if ( forced_off && bright != -2 )
257 return; 268 return;
258 if ( bright == -2 ) { 269 if ( bright == -2 ) {
259 // Toggle between off and on 270 // Toggle between off and on
260 bright = curbl ? 0 : -1; 271 bright = curbl ? 0 : -1;
261 forced_off = !bright; 272 forced_off = !bright;
262 } 273 }
263 if ( bright == -1 ) { 274 if ( bright == -1 ) {
264 // Read from config 275 // Read from config
265 Config config( "qpe" ); 276 Config config( "qpe" );
266 config.setGroup( "Screensaver" ); 277 config.setGroup( "Screensaver" );
267 bright = config.readNumEntry("Brightness",255); 278 bright = config.readNumEntry("Brightness",255);
268 } 279 }
269#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 280#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
270 if ( QFile::exists("/usr/bin/bl") ) { 281 if ( QFile::exists("/usr/bin/bl") ) {
271 QString cmd = "/usr/bin/bl 1 "; 282 QString cmd = "/usr/bin/bl 1 ";
272 cmd += bright<=0 ? "0 " : "1 "; 283 cmd += bright<=0 ? "0 " : "1 ";
273 cmd += QString::number(bright); 284 cmd += QString::number(bright);
274 system(cmd.latin1()); 285 system(cmd.latin1());
275#if defined(QT_QWS_EBX) 286#if defined(QT_QWS_EBX)
276 } else if ( QFile::exists("/dev/fl") ) { 287 } else if ( QFile::exists("/dev/fl") ) {
277#define FL_IOCTL_STEP_CONTRAST 100 288#define FL_IOCTL_STEP_CONTRAST 100
278 int fd = open("/dev/fl", O_WRONLY); 289 int fd = open("/dev/fl", O_WRONLY);
279 if (fd >= 0 ) { 290 if (fd >= 0 ) {
280 int steps = qpe_sysBrightnessSteps(); 291 int steps = qpe_sysBrightnessSteps();
281 int bl = ( bright * steps + 127 ) / 255; 292 int bl = ( bright * steps + 127 ) / 255;
282 if ( bright && !bl ) bl = 1; 293 if ( bright && !bl ) bl = 1;
283 bl = ioctl(fd, FL_IOCTL_STEP_CONTRAST, bl); 294 bl = ioctl(fd, FL_IOCTL_STEP_CONTRAST, bl);
284 close(fd); 295 close(fd);
285 } 296 }
286 } 297 }
287#elif defined(QT_QWS_IPAQ) 298#elif defined(QT_QWS_IPAQ)
288 } else if ( QFile::exists("/dev/ts") || QFile::exists("/dev/h3600_ts") ) { 299 } else if ( QFile::exists("/dev/ts") || QFile::exists("/dev/h3600_ts") ) {
289 typedef struct { 300 typedef struct {
290 unsigned char mode; 301 unsigned char mode;
291 unsigned char pwr; 302 unsigned char pwr;
292 unsigned char brightness; 303 unsigned char brightness;
293 } FLITE_IN; 304 } FLITE_IN;
294# ifndef FLITE_ON 305# ifndef FLITE_ON
295# ifndef _LINUX_IOCTL_H 306# ifndef _LINUX_IOCTL_H
296# include <linux/ioctl.h> 307# include <linux/ioctl.h>
297# endif 308# endif
298# define FLITE_ON _IOW('f', 7, FLITE_IN) 309# define FLITE_ON _IOW('f', 7, FLITE_IN)
299# endif 310# endif
300 int fd; 311 int fd;
301 if ( QFile::exists("/dev/ts") ) 312 if ( QFile::exists("/dev/ts") )
302 fd = open("/dev/ts", O_WRONLY); 313 fd = open("/dev/ts", O_WRONLY);
303 else 314 else
304 fd = open("/dev/h3600_ts", O_WRONLY); 315 fd = open("/dev/h3600_ts", O_WRONLY);
305 if (fd >= 0 ) { 316 if (fd >= 0 ) {
306 FLITE_IN bl; 317 FLITE_IN bl;
307 bl.mode = 1; 318 bl.mode = 1;
308 bl.pwr = bright ? 1 : 0; 319 bl.pwr = bright ? 1 : 0;
309 bl.brightness = bright; 320 bl.brightness = bright;
310 ioctl(fd, FLITE_ON, &bl); 321 ioctl(fd, FLITE_ON, &bl);
311 close(fd); 322 close(fd);
312 } 323 }
313 } 324 }
314#endif 325#endif
315#endif 326#endif
316 curbl = bright; 327 curbl = bright;
317} 328}
318 329
319void qpe_setBacklight(int bright) { setBacklight(bright); } 330void qpe_setBacklight(int bright) { setBacklight(bright); }
320 331
321static bool dim_on = FALSE; 332static bool dim_on = FALSE;
322static bool lightoff_on = FALSE; 333static bool lightoff_on = FALSE;
323static int disable_suspend = 100; 334static int disable_suspend = 100;
324 335
325static bool powerOnline() 336static bool powerOnline()
326{ 337{
327 return PowerStatusManager::readStatus().acStatus() == PowerStatus::Online; 338 return PowerStatusManager::readStatus().acStatus() == PowerStatus::Online;
328} 339}
329 340
330static bool networkOnline() 341static bool networkOnline()
331{ 342{
332 return Network::networkOnline(); 343 return Network::networkOnline();
333} 344}
334 345
335class QPEScreenSaver : public QWSScreenSaver 346class QPEScreenSaver : public QWSScreenSaver
336{ 347{
337private: 348private:
338 int LcdOn; 349 int LcdOn;
339 350
340public: 351public:
341 QPEScreenSaver() 352 QPEScreenSaver()
342 { 353 {
343 int fd; 354 int fd;
344 355
345 LcdOn = TRUE; 356 LcdOn = TRUE;
346 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) 357 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off)
347 fd=open("/dev/fb0",O_RDWR); 358 fd=open("/dev/fb0",O_RDWR);
348 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_NO_BLANKING); close(fd); } 359 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_NO_BLANKING); close(fd); }
349 } 360 }
350 void restore() 361 void restore()
351 { 362 {
352 if (!LcdOn) // We must have turned it off 363 if (!LcdOn) // We must have turned it off
353 { 364 {
354 int fd; 365 int fd;
355 fd=open("/dev/fb0",O_RDWR); 366 fd=open("/dev/fb0",O_RDWR);
356 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_NO_BLANKING); close(fd); } 367 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_NO_BLANKING); close(fd); }
357 } 368 }
358 setBacklight(-1); 369 setBacklight(-1);
359 } 370 }
360 bool save(int level) 371 bool save(int level)
361 { 372 {
362 int fd; 373 int fd;
363 374
364 switch ( level ) { 375 switch ( level ) {
365 case 0: 376 case 0:
366 if ( disable_suspend > 0 && dim_on ) { 377 if ( disable_suspend > 0 && dim_on ) {
367 if (backlight() > 1) 378 if (backlight() > 1)
368 setBacklight(1); // lowest non-off 379 setBacklight(1); // lowest non-off
369 } 380 }
370 return TRUE; 381 return TRUE;
371 break; 382 break;
372 case 1: 383 case 1:
373 if ( disable_suspend > 1 && lightoff_on ) { 384 if ( disable_suspend > 1 && lightoff_on ) {
374 setBacklight(0); // off 385 setBacklight(0); // off
375 } 386 }
376 return TRUE; 387 return TRUE;
377 break; 388 break;
378 case 2: 389 case 2:
379 Config config( "qpe" ); 390 Config config( "qpe" );
380 config.setGroup( "Screensaver" ); 391 config.setGroup( "Screensaver" );
381 if (config.readNumEntry("LcdOffOnly",0) != 0) // We're only turning off the LCD 392 if (config.readNumEntry("LcdOffOnly",0) != 0) // We're only turning off the LCD
382 { 393 {
383 fd=open("/dev/fb0",O_RDWR); 394 fd=open("/dev/fb0",O_RDWR);
384 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_POWERDOWN); close(fd); } 395 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_POWERDOWN); close(fd); }
385 LcdOn = FALSE; 396 LcdOn = FALSE;
386 } 397 }
387 else // We're going to suspend the whole machine 398 else // We're going to suspend the whole machine
388 { 399 {
389 if ( disable_suspend > 2 && !powerOnline() && !networkOnline() ) { 400 if ( disable_suspend > 2 && !powerOnline() && !networkOnline() ) {
390 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 401 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
391 return TRUE; 402 return TRUE;
392 } 403 }
393 } 404 }
394 break; 405 break;
395 } 406 }
396 return FALSE; 407 return FALSE;
397 } 408 }
398}; 409};
399 410
400static int ssi(int interval, Config &config, const QString &enable, const QString& value, int def) 411static int ssi(int interval, Config &config, const QString &enable, const QString& value, int def)
401{ 412{
402 if ( !enable.isEmpty() && config.readNumEntry(enable,0) == 0 ) 413 if ( !enable.isEmpty() && config.readNumEntry(enable,0) == 0 )
403 return 0; 414 return 0;
404 415
405 if ( interval < 0 ) { 416 if ( interval < 0 ) {
406 // Restore screen blanking and power saving state 417 // Restore screen blanking and power saving state
407 interval = config.readNumEntry( value, def ); 418 interval = config.readNumEntry( value, def );
408 } 419 }
409 return interval; 420 return interval;
410} 421}
411 422
412static void setScreenSaverIntervals(int i1, int i2, int i3) 423static void setScreenSaverIntervals(int i1, int i2, int i3)
413{ 424{
414 Config config( "qpe" ); 425 Config config( "qpe" );
415 config.setGroup( "Screensaver" ); 426 config.setGroup( "Screensaver" );
416 427
417 int v[4]; 428 int v[4];
418 i1 = ssi(i1, config, "Dim","Interval_Dim", 30); 429 i1 = ssi(i1, config, "Dim","Interval_Dim", 30);
419 i2 = ssi(i2, config, "LightOff","Interval_LightOff", 20); 430 i2 = ssi(i2, config, "LightOff","Interval_LightOff", 20);
420 i3 = ssi(i3, config, "","Interval", 60); 431 i3 = ssi(i3, config, "","Interval", 60);
421 432
422 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); 433 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3);
423 434
424 v[0] = QMAX( 1000*i1, 100); 435 v[0] = QMAX( 1000*i1, 100);
425 v[1] = QMAX( 1000*i2, 100); 436 v[1] = QMAX( 1000*i2, 100);
426 v[2] = QMAX( 1000*i3, 100); 437 v[2] = QMAX( 1000*i3, 100);
427 v[3] = 0; 438 v[3] = 0;
428 dim_on = ( (i1 != 0) ? config.readNumEntry("Dim",1) : FALSE ); 439 dim_on = ( (i1 != 0) ? config.readNumEntry("Dim",1) : FALSE );
429 lightoff_on = ( (i2 != 0 ) ? config.readNumEntry("LightOff",1) : FALSE ); 440 lightoff_on = ( (i2 != 0 ) ? config.readNumEntry("LightOff",1) : FALSE );
430 if ( !i1 && !i2 && !i3 ) 441 if ( !i1 && !i2 && !i3 )
431 QWSServer::setScreenSaverInterval(0); 442 QWSServer::setScreenSaverInterval(0);
432 else 443 else
433 QWSServer::setScreenSaverIntervals(v); 444 QWSServer::setScreenSaverIntervals(v);
434} 445}
435 446