author | sandman <sandman> | 2002-06-27 01:39:00 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-06-27 01:39:00 (UTC) |
commit | ed8d1696ca8f0407cb7e6b91cc8d410dede5ccdc (patch) (unidiff) | |
tree | ac60a3f150442a35d13fbe90733a70f891c81a28 /library/qpeapplication.cpp | |
parent | a86c09e8a12b504471ffeb8966e34a79dd8518b5 (diff) | |
download | opie-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)
-rw-r--r-- | library/qpeapplication.cpp | 13 |
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,243 +1,254 @@ | |||
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 | ||
95 | class QPEApplicationData { | 106 | class QPEApplicationData { |
96 | public: | 107 | public: |
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 | ||
143 | class ResourceMimeFactory : public QMimeSourceFactory { | 154 | class ResourceMimeFactory : public QMimeSourceFactory { |
144 | public: | 155 | public: |
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 | ||
171 | static int muted=0; | 182 | static int muted=0; |
172 | static int micMuted=0; | 183 | static int micMuted=0; |
173 | 184 | ||
174 | static void setVolume(int t=0, int percent=-1) | 185 | static 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 | ||
194 | static void setMic(int t=0, int percent=-1) | 205 | static 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 | ||
213 | int qpe_sysBrightnessSteps() | 224 | int 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 | ||
225 | static int& hack(int& i) | 236 | static 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 | ||
235 | static bool forced_off = FALSE; | 246 | static bool forced_off = FALSE; |
236 | static int curbl=-1; | 247 | static int curbl=-1; |
237 | 248 | ||
238 | static int backlight() | 249 | static 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" ); |