summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 5f61c0c..cf437da 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -47,278 +47,278 @@
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#include <linux/fb.h>
52 52
53#include <qsignal.h> 53#include <qsignal.h>
54#include "qpeapplication.h" 54#include "qpeapplication.h"
55#include "qpestyle.h" 55#include "qpestyle.h"
56#if QT_VERSION >= 300 56#if QT_VERSION >= 300
57#include <qstylefactory.h> 57#include <qstylefactory.h>
58#else 58#else
59#include <qplatinumstyle.h> 59#include <qplatinumstyle.h>
60#include <qwindowsstyle.h> 60#include <qwindowsstyle.h>
61#include <qmotifstyle.h> 61#include <qmotifstyle.h>
62#include <qmotifplusstyle.h> 62#include <qmotifplusstyle.h>
63#include "lightstyle.h" 63#include "lightstyle.h"
64#endif 64#endif
65#include "global.h" 65#include "global.h"
66#include "resource.h" 66#include "resource.h"
67#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 67#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
68#include "qutfcodec.h" 68#include "qutfcodec.h"
69#endif 69#endif
70#include "config.h" 70#include "config.h"
71#include "network.h" 71#include "network.h"
72#include "fontmanager.h" 72#include "fontmanager.h"
73#include "power.h" 73#include "power.h"
74#include "alarmserver.h" 74#include "alarmserver.h"
75#include "applnk.h" 75#include "applnk.h"
76#include "qpemenubar.h" 76#include "qpemenubar.h"
77 77
78#include <unistd.h> 78#include <unistd.h>
79#include <sys/file.h> 79#include <sys/file.h>
80#include <sys/ioctl.h> 80#include <sys/ioctl.h>
81#include <sys/soundcard.h> 81#include <sys/soundcard.h>
82 82
83// for setBacklight() 83// for setBacklight()
84#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 84#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
85#include <linux/fb.h> 85#include <linux/fb.h>
86#include <sys/types.h> 86#include <sys/types.h>
87#include <sys/stat.h> 87#include <sys/stat.h>
88#endif 88#endif
89#include <stdlib.h> 89#include <stdlib.h>
90 90
91 91
92class QPEApplicationData { 92class QPEApplicationData {
93public: 93public:
94 QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE), 94 QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE),
95 kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE), 95 kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE),
96 forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0), 96 forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0),
97 keep_running(TRUE) 97 keep_running(TRUE)
98 { 98 {
99 qcopq.setAutoDelete(TRUE); 99 qcopq.setAutoDelete(TRUE);
100 } 100 }
101 101
102 int presstimer; 102 int presstimer;
103 QWidget* presswidget; 103 QWidget* presswidget;
104 QPoint presspos; 104 QPoint presspos;
105 bool rightpressed; 105 bool rightpressed;
106 int kbgrabber; 106 int kbgrabber;
107 bool kbregrab; 107 bool kbregrab;
108 bool notbusysent; 108 bool notbusysent;
109 QString appName; 109 QString appName;
110 struct QCopRec { 110 struct QCopRec {
111 QCopRec(const QCString &ch, const QCString &msg, 111 QCopRec(const QCString &ch, const QCString &msg,
112 const QByteArray &d) : 112 const QByteArray &d) :
113 channel(ch), message(msg), data(d) { } 113 channel(ch), message(msg), data(d) { }
114 114
115 QCString channel; 115 QCString channel;
116 QCString message; 116 QCString message;
117 QByteArray data; 117 QByteArray data;
118 }; 118 };
119 bool preloaded; 119 bool preloaded;
120 bool forceshow; 120 bool forceshow;
121 bool nomaximize; 121 bool nomaximize;
122 QWidget* qpe_main_widget; 122 QWidget* qpe_main_widget;
123 bool keep_running; 123 bool keep_running;
124 QList<QCopRec> qcopq; 124 QList<QCopRec> qcopq;
125 125
126 void enqueueQCop(const QCString &ch, const QCString &msg, 126 void enqueueQCop(const QCString &ch, const QCString &msg,
127 const QByteArray &data) 127 const QByteArray &data)
128 { 128 {
129 qcopq.append(new QCopRec(ch,msg,data)); 129 qcopq.append(new QCopRec(ch,msg,data));
130 } 130 }
131 void sendQCopQ() 131 void sendQCopQ()
132 { 132 {
133 QCopRec* r; 133 QCopRec* r;
134 for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it) 134 for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it)
135 QCopChannel::sendLocally(r->channel,r->message,r->data); 135 QCopChannel::sendLocally(r->channel,r->message,r->data);
136 qcopq.clear(); 136 qcopq.clear();
137 } 137 }
138}; 138};
139 139
140class ResourceMimeFactory : public QMimeSourceFactory { 140class ResourceMimeFactory : public QMimeSourceFactory {
141public: 141public:
142 ResourceMimeFactory() 142 ResourceMimeFactory()
143 { 143 {
144 setFilePath( Global::helpPath() ); 144 setFilePath( Global::helpPath() );
145 setExtensionType("html","text/html;charset=UTF-8"); 145 setExtensionType("html","text/html;charset=UTF-8");
146 } 146 }
147 147
148 const QMimeSource* data(const QString& abs_name) const 148 const QMimeSource* data(const QString& abs_name) const
149 { 149 {
150 const QMimeSource* r = QMimeSourceFactory::data(abs_name); 150 const QMimeSource* r = QMimeSourceFactory::data(abs_name);
151 if ( !r ) { 151 if ( !r ) {
152 int sl = abs_name.length(); 152 int sl = abs_name.length();
153 do { 153 do {
154 sl = abs_name.findRev('/',sl-1); 154 sl = abs_name.findRev('/',sl-1);
155 QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name; 155 QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name;
156 int dot = name.findRev('.'); 156 int dot = name.findRev('.');
157 if ( dot >= 0 ) 157 if ( dot >= 0 )
158 name = name.left(dot); 158 name = name.left(dot);
159 QImage img = Resource::loadImage(name); 159 QImage img = Resource::loadImage(name);
160 if ( !img.isNull() ) 160 if ( !img.isNull() )
161 r = new QImageDrag(img); 161 r = new QImageDrag(img);
162 } while (!r && sl>0); 162 } while (!r && sl>0);
163 } 163 }
164 return r; 164 return r;
165 } 165 }
166}; 166};
167 167
168static int muted=0; 168static int muted=0;
169static int micMuted=0; 169static int micMuted=0;
170 170
171static void setVolume(int t=0, int percent=-1) 171static void setVolume(int t=0, int percent=-1)
172{ 172{
173 switch (t) { 173 switch (t) {
174 case 0: { 174 case 0: {
175 Config cfg("Sound"); 175 Config cfg("qpe");
176 cfg.setGroup("System"); 176 cfg.setGroup("Volume");
177 if ( percent < 0 ) 177 if ( percent < 0 )
178 percent = cfg.readNumEntry("Volume",50); 178 percent = cfg.readNumEntry("VolumePercent",50);
179 int fd = 0; 179 int fd = 0;
180 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 180 if ((fd = open("/dev/mixer", O_RDWR))>=0) {
181 int vol = muted ? 0 : percent; 181 int vol = muted ? 0 : percent;
182 // set both channels to same volume 182 // set both channels to same volume
183 vol |= vol << 8; 183 vol |= vol << 8;
184 ioctl(fd, MIXER_WRITE(0), &vol); 184 ioctl(fd, MIXER_WRITE(0), &vol);
185 ::close(fd); 185 ::close(fd);
186 } 186 }
187 } break; 187 } break;
188 } 188 }
189} 189}
190 190
191static void setMic(int t=0, int percent=-1) 191static void setMic(int t=0, int percent=-1)
192{ 192{
193 switch (t) { 193 switch (t) {
194 case 0: { 194 case 0: {
195 Config cfg("Sound"); 195 Config cfg("qpe");
196 cfg.setGroup("System"); 196 cfg.setGroup("Volume");
197 if ( percent < 0 ) 197 if ( percent < 0 )
198 percent = cfg.readNumEntry("Mic",50); 198 percent = cfg.readNumEntry("Mic",50);
199 199
200 int fd = 0; 200 int fd = 0;
201 int mic = micMuted ? 0 : percent; 201 int mic = micMuted ? 0 : percent;
202 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 202 if ((fd = open("/dev/mixer", O_RDWR))>=0) {
203 ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic); 203 ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic);
204 ::close(fd); 204 ::close(fd);
205 } 205 }
206 } break; 206 } break;
207 } 207 }
208} 208}
209 209
210int qpe_sysBrightnessSteps() 210int qpe_sysBrightnessSteps()
211{ 211{
212#if defined(QT_QWS_IPAQ) 212#if defined(QT_QWS_IPAQ)
213 return 255; 213 return 255;
214#elif defined(QT_QWS_EBX) 214#elif defined(QT_QWS_EBX)
215 return 4; 215 return 4;
216#else 216#else
217 return 255; // ? 217 return 255; // ?
218#endif 218#endif
219} 219}
220 220
221 221
222static int& hack(int& i) 222static int& hack(int& i)
223{ 223{
224#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 224#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
225 // These should be created, but aren't in Qt 2.3.0 225 // These should be created, but aren't in Qt 2.3.0
226 (void)new QUtf8Codec; 226 (void)new QUtf8Codec;
227 (void)new QUtf16Codec; 227 (void)new QUtf16Codec;
228#endif 228#endif
229 return i; 229 return i;
230} 230}
231 231
232static bool forced_off = FALSE; 232static bool forced_off = FALSE;
233static int curbl=-1; 233static int curbl=-1;
234 234
235static int backlight() 235static int backlight()
236{ 236{
237 if ( curbl == -1 ) { 237 if ( curbl == -1 ) {
238 // Read from config 238 // Read from config
239 Config config( "qpe" ); 239 Config config( "qpe" );
240 config.setGroup( "Screensaver" ); 240 config.setGroup( "Screensaver" );
241 curbl = config.readNumEntry("Brightness",255); 241 curbl = config.readNumEntry("Brightness",255);
242 } 242 }
243 return curbl; 243 return curbl;
244} 244}
245 245
246static void setBacklight(int bright) 246static void setBacklight(int bright)
247{ 247{
248 if ( bright == -3 ) { 248 if ( bright == -3 ) {
249 // Forced on 249 // Forced on
250 forced_off = FALSE; 250 forced_off = FALSE;
251 bright = -1; 251 bright = -1;
252 } 252 }
253 if ( forced_off && bright != -2 ) 253 if ( forced_off && bright != -2 )
254 return; 254 return;
255 if ( bright == -2 ) { 255 if ( bright == -2 ) {
256 // Toggle between off and on 256 // Toggle between off and on
257 bright = curbl ? 0 : -1; 257 bright = curbl ? 0 : -1;
258 forced_off = !bright; 258 forced_off = !bright;
259 } 259 }
260 if ( bright == -1 ) { 260 if ( bright == -1 ) {
261 // Read from config 261 // Read from config
262 Config config( "qpe" ); 262 Config config( "qpe" );
263 config.setGroup( "Screensaver" ); 263 config.setGroup( "Screensaver" );
264 bright = config.readNumEntry("Brightness",255); 264 bright = config.readNumEntry("Brightness",255);
265 } 265 }
266#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 266#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
267 if ( QFile::exists("/usr/bin/bl") ) { 267 if ( QFile::exists("/usr/bin/bl") ) {
268 QString cmd = "/usr/bin/bl 1 "; 268 QString cmd = "/usr/bin/bl 1 ";
269 cmd += bright<=0 ? "0 " : "1 "; 269 cmd += bright<=0 ? "0 " : "1 ";
270 cmd += QString::number(bright); 270 cmd += QString::number(bright);
271 system(cmd.latin1()); 271 system(cmd.latin1());
272#if defined(QT_QWS_EBX) 272#if defined(QT_QWS_EBX)
273 } else if ( QFile::exists("/dev/fl") ) { 273 } else if ( QFile::exists("/dev/fl") ) {
274#define FL_IOCTL_STEP_CONTRAST 100 274#define FL_IOCTL_STEP_CONTRAST 100
275 int fd = open("/dev/fl", O_WRONLY); 275 int fd = open("/dev/fl", O_WRONLY);
276 if (fd >= 0 ) { 276 if (fd >= 0 ) {
277 int steps = qpe_sysBrightnessSteps(); 277 int steps = qpe_sysBrightnessSteps();
278 int bl = ( bright * steps + 127 ) / 255; 278 int bl = ( bright * steps + 127 ) / 255;
279 if ( bright && !bl ) bl = 1; 279 if ( bright && !bl ) bl = 1;
280 bl = ioctl(fd, FL_IOCTL_STEP_CONTRAST, bl); 280 bl = ioctl(fd, FL_IOCTL_STEP_CONTRAST, bl);
281 close(fd); 281 close(fd);
282 } 282 }
283 } 283 }
284#elif defined(QT_QWS_IPAQ) 284#elif defined(QT_QWS_IPAQ)
285 } else if ( QFile::exists("/dev/ts") || QFile::exists("/dev/h3600_ts") ) { 285 } else if ( QFile::exists("/dev/ts") || QFile::exists("/dev/h3600_ts") ) {
286 typedef struct { 286 typedef struct {
287 unsigned char mode; 287 unsigned char mode;
288 unsigned char pwr; 288 unsigned char pwr;
289 unsigned char brightness; 289 unsigned char brightness;
290 } FLITE_IN; 290 } FLITE_IN;
291# ifndef FLITE_ON 291# ifndef FLITE_ON
292# ifndef _LINUX_IOCTL_H 292# ifndef _LINUX_IOCTL_H
293# include <linux/ioctl.h> 293# include <linux/ioctl.h>
294# endif 294# endif
295# define FLITE_ON _IOW('f', 7, FLITE_IN) 295# define FLITE_ON _IOW('f', 7, FLITE_IN)
296# endif 296# endif
297 int fd; 297 int fd;
298 if ( QFile::exists("/dev/ts") ) 298 if ( QFile::exists("/dev/ts") )
299 fd = open("/dev/ts", O_WRONLY); 299 fd = open("/dev/ts", O_WRONLY);
300 else 300 else
301 fd = open("/dev/h3600_ts", O_WRONLY); 301 fd = open("/dev/h3600_ts", O_WRONLY);
302 if (fd >= 0 ) { 302 if (fd >= 0 ) {
303 FLITE_IN bl; 303 FLITE_IN bl;
304 bl.mode = 1; 304 bl.mode = 1;
305 bl.pwr = bright ? 1 : 0; 305 bl.pwr = bright ? 1 : 0;
306 bl.brightness = bright; 306 bl.brightness = bright;
307 ioctl(fd, FLITE_ON, &bl); 307 ioctl(fd, FLITE_ON, &bl);
308 close(fd); 308 close(fd);
309 } 309 }
310 } 310 }
311#endif 311#endif
312#endif 312#endif
313 curbl = bright; 313 curbl = bright;
314} 314}
315 315
316void qpe_setBacklight(int bright) { setBacklight(bright); } 316void qpe_setBacklight(int bright) { setBacklight(bright); }
317 317
318static bool dim_on = FALSE; 318static bool dim_on = FALSE;
319static bool lightoff_on = FALSE; 319static bool lightoff_on = FALSE;
320static int disable_suspend = 100; 320static int disable_suspend = 100;
321 321
322static bool powerOnline() 322static bool powerOnline()
323{ 323{
324 return PowerStatusManager::readStatus().acStatus() == PowerStatus::Online; 324 return PowerStatusManager::readStatus().acStatus() == PowerStatus::Online;