-rw-r--r-- | library/qpeapplication.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index c8e6e74..c782837 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1,280 +1,281 @@ | |||
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 | ** $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 <linux/limits.h> // needed for some toolchains (PATH_MAX) | ||
25 | #include <qfile.h> | 26 | #include <qfile.h> |
26 | #ifdef Q_WS_QWS | 27 | #ifdef Q_WS_QWS |
27 | #ifndef QT_NO_COP | 28 | #ifndef QT_NO_COP |
28 | #if QT_VERSION <= 231 | 29 | #if QT_VERSION <= 231 |
29 | #define private public | 30 | #define private public |
30 | #define sendLocally processEvent | 31 | #define sendLocally processEvent |
31 | #include "qcopenvelope_qws.h" | 32 | #include "qcopenvelope_qws.h" |
32 | #undef private | 33 | #undef private |
33 | #else | 34 | #else |
34 | #include "qcopenvelope_qws.h" | 35 | #include "qcopenvelope_qws.h" |
35 | #endif | 36 | #endif |
36 | #endif | 37 | #endif |
37 | #include <qwindowsystem_qws.h> | 38 | #include <qwindowsystem_qws.h> |
38 | #endif | 39 | #endif |
39 | #include <qtextstream.h> | 40 | #include <qtextstream.h> |
40 | #include <qpalette.h> | 41 | #include <qpalette.h> |
41 | #include <qbuffer.h> | 42 | #include <qbuffer.h> |
42 | #include <qptrdict.h> | 43 | #include <qptrdict.h> |
43 | #include <qregexp.h> | 44 | #include <qregexp.h> |
44 | #include <qdir.h> | 45 | #include <qdir.h> |
45 | #include <qlabel.h> | 46 | #include <qlabel.h> |
46 | #include <qdialog.h> | 47 | #include <qdialog.h> |
47 | #include <qdragobject.h> | 48 | #include <qdragobject.h> |
48 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
49 | #include <qevent.h> | 50 | #include <qevent.h> |
50 | #include <qtooltip.h> | 51 | #include <qtooltip.h> |
51 | #include <qsignal.h> | 52 | #include <qsignal.h> |
52 | #include "qpeapplication.h" | 53 | #include "qpeapplication.h" |
53 | #include "qpestyle.h" | 54 | #include "qpestyle.h" |
54 | #include "styleinterface.h" | 55 | #include "styleinterface.h" |
55 | #if QT_VERSION >= 300 | 56 | #if QT_VERSION >= 300 |
56 | #include <qstylefactory.h> | 57 | #include <qstylefactory.h> |
57 | #else | 58 | #else |
58 | #include <qplatinumstyle.h> | 59 | #include <qplatinumstyle.h> |
59 | #include <qwindowsstyle.h> | 60 | #include <qwindowsstyle.h> |
60 | #include <qmotifstyle.h> | 61 | #include <qmotifstyle.h> |
61 | #include <qmotifplusstyle.h> | 62 | #include <qmotifplusstyle.h> |
62 | #include "lightstyle.h" | 63 | #include "lightstyle.h" |
63 | 64 | ||
64 | #include <qpe/qlibrary.h> | 65 | #include <qpe/qlibrary.h> |
65 | #endif | 66 | #endif |
66 | #include "global.h" | 67 | #include "global.h" |
67 | #include "resource.h" | 68 | #include "resource.h" |
68 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 69 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
69 | #include "qutfcodec.h" | 70 | #include "qutfcodec.h" |
70 | #endif | 71 | #endif |
71 | #include "config.h" | 72 | #include "config.h" |
72 | #include "network.h" | 73 | #include "network.h" |
73 | #ifdef QWS | 74 | #ifdef QWS |
74 | #include "fontmanager.h" | 75 | #include "fontmanager.h" |
75 | #endif | 76 | #endif |
76 | 77 | ||
77 | #include "alarmserver.h" | 78 | #include "alarmserver.h" |
78 | #include "applnk.h" | 79 | #include "applnk.h" |
79 | #include "qpemenubar.h" | 80 | #include "qpemenubar.h" |
80 | #include "textcodecinterface.h" | 81 | #include "textcodecinterface.h" |
81 | #include "imagecodecinterface.h" | 82 | #include "imagecodecinterface.h" |
82 | 83 | ||
83 | #include <unistd.h> | 84 | #include <unistd.h> |
84 | #include <sys/file.h> | 85 | #include <sys/file.h> |
85 | #include <sys/ioctl.h> | 86 | #include <sys/ioctl.h> |
86 | #include <sys/soundcard.h> | 87 | #include <sys/soundcard.h> |
87 | 88 | ||
88 | 89 | ||
89 | class QPEApplicationData | 90 | class QPEApplicationData |
90 | { | 91 | { |
91 | public: | 92 | public: |
92 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), | 93 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), |
93 | kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), | 94 | kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), |
94 | forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ), | 95 | forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ), |
95 | keep_running( TRUE ) | 96 | keep_running( TRUE ) |
96 | { | 97 | { |
97 | qcopq.setAutoDelete( TRUE ); | 98 | qcopq.setAutoDelete( TRUE ); |
98 | } | 99 | } |
99 | 100 | ||
100 | int presstimer; | 101 | int presstimer; |
101 | QWidget* presswidget; | 102 | QWidget* presswidget; |
102 | QPoint presspos; | 103 | QPoint presspos; |
103 | bool rightpressed : | 104 | bool rightpressed : |
104 | 1; // AEH why not use uint foobar :1; if it's tt style -zecke | 105 | 1; // AEH why not use uint foobar :1; if it's tt style -zecke |
105 | int kbgrabber; | 106 | int kbgrabber; |
106 | bool kbregrab : | 107 | bool kbregrab : |
107 | 1; | 108 | 1; |
108 | bool notbusysent : | 109 | bool notbusysent : |
109 | 1; | 110 | 1; |
110 | QString appName; | 111 | QString appName; |
111 | struct QCopRec | 112 | struct QCopRec |
112 | { | 113 | { |
113 | QCopRec( const QCString &ch, const QCString &msg, | 114 | QCopRec( const QCString &ch, const QCString &msg, |
114 | const QByteArray &d ) : | 115 | const QByteArray &d ) : |
115 | channel( ch ), message( msg ), data( d ) | 116 | channel( ch ), message( msg ), data( d ) |
116 | { } | 117 | { } |
117 | 118 | ||
118 | QCString channel; | 119 | QCString channel; |
119 | QCString message; | 120 | QCString message; |
120 | QByteArray data; | 121 | QByteArray data; |
121 | }; | 122 | }; |
122 | bool preloaded : | 123 | bool preloaded : |
123 | 1; | 124 | 1; |
124 | bool forceshow : | 125 | bool forceshow : |
125 | 1; | 126 | 1; |
126 | bool nomaximize : | 127 | bool nomaximize : |
127 | 1; | 128 | 1; |
128 | QWidget* qpe_main_widget; | 129 | QWidget* qpe_main_widget; |
129 | bool keep_running : | 130 | bool keep_running : |
130 | 1; | 131 | 1; |
131 | QList<QCopRec> qcopq; | 132 | QList<QCopRec> qcopq; |
132 | 133 | ||
133 | void enqueueQCop( const QCString &ch, const QCString &msg, | 134 | void enqueueQCop( const QCString &ch, const QCString &msg, |
134 | const QByteArray &data ) | 135 | const QByteArray &data ) |
135 | { | 136 | { |
136 | qcopq.append( new QCopRec( ch, msg, data ) ); | 137 | qcopq.append( new QCopRec( ch, msg, data ) ); |
137 | } | 138 | } |
138 | void sendQCopQ() | 139 | void sendQCopQ() |
139 | { | 140 | { |
140 | QCopRec * r; | 141 | QCopRec * r; |
141 | #ifndef QT_NO_COP | 142 | #ifndef QT_NO_COP |
142 | 143 | ||
143 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) | 144 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) |
144 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 145 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
145 | #endif | 146 | #endif |
146 | 147 | ||
147 | qcopq.clear(); | 148 | qcopq.clear(); |
148 | } | 149 | } |
149 | static void show_mx(QWidget* mw, bool nomaximize) | 150 | static void show_mx(QWidget* mw, bool nomaximize) |
150 | { | 151 | { |
151 | if ( mw->layout() && mw->inherits("QDialog") ) { | 152 | if ( mw->layout() && mw->inherits("QDialog") ) { |
152 | QPEApplication::showDialog((QDialog*)mw, nomaximize); | 153 | QPEApplication::showDialog((QDialog*)mw, nomaximize); |
153 | } | 154 | } |
154 | else { | 155 | else { |
155 | #ifdef Q_WS_QWS | 156 | #ifdef Q_WS_QWS |
156 | if ( !nomaximize ) | 157 | if ( !nomaximize ) |
157 | mw->showMaximized(); | 158 | mw->showMaximized(); |
158 | else | 159 | else |
159 | #endif | 160 | #endif |
160 | 161 | ||
161 | mw->show(); | 162 | mw->show(); |
162 | } | 163 | } |
163 | } | 164 | } |
164 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 165 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
165 | { | 166 | { |
166 | /* | 167 | /* |
167 | // This works but disable it for now until it is safe to apply | 168 | // This works but disable it for now until it is safe to apply |
168 | // What is does is scan the .desktop files of all the apps for | 169 | // What is does is scan the .desktop files of all the apps for |
169 | // the applnk that has the corresponding argv[0] as this program | 170 | // the applnk that has the corresponding argv[0] as this program |
170 | // then it uses the name stored in the .desktop file as the caption | 171 | // then it uses the name stored in the .desktop file as the caption |
171 | // for the main widget. This saves duplicating translations for | 172 | // for the main widget. This saves duplicating translations for |
172 | // the app name in the program and in the .desktop files. | 173 | // the app name in the program and in the .desktop files. |
173 | 174 | ||
174 | AppLnkSet apps( appsPath ); | 175 | AppLnkSet apps( appsPath ); |
175 | 176 | ||
176 | QList<AppLnk> appsList = apps.children(); | 177 | QList<AppLnk> appsList = apps.children(); |
177 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 178 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
178 | if ( (*it)->exec() == appName ) { | 179 | if ( (*it)->exec() == appName ) { |
179 | mw->setCaption( (*it)->name() ); | 180 | mw->setCaption( (*it)->name() ); |
180 | return TRUE; | 181 | return TRUE; |
181 | } | 182 | } |
182 | } | 183 | } |
183 | */ | 184 | */ |
184 | return FALSE; | 185 | return FALSE; |
185 | } | 186 | } |
186 | 187 | ||
187 | 188 | ||
188 | void show(QWidget* mw, bool nomax) | 189 | void show(QWidget* mw, bool nomax) |
189 | { | 190 | { |
190 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 191 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
191 | nomaximize = nomax; | 192 | nomaximize = nomax; |
192 | qpe_main_widget = mw; | 193 | qpe_main_widget = mw; |
193 | #ifndef QT_NO_COP | 194 | #ifndef QT_NO_COP |
194 | 195 | ||
195 | sendQCopQ(); | 196 | sendQCopQ(); |
196 | #endif | 197 | #endif |
197 | 198 | ||
198 | if ( preloaded ) { | 199 | if ( preloaded ) { |
199 | if (forceshow) | 200 | if (forceshow) |
200 | show_mx(mw, nomax); | 201 | show_mx(mw, nomax); |
201 | } | 202 | } |
202 | else if ( keep_running ) { | 203 | else if ( keep_running ) { |
203 | show_mx(mw, nomax); | 204 | show_mx(mw, nomax); |
204 | } | 205 | } |
205 | } | 206 | } |
206 | 207 | ||
207 | void loadTextCodecs() | 208 | void loadTextCodecs() |
208 | { | 209 | { |
209 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 210 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
210 | QDir dir( path, "lib*.so" ); | 211 | QDir dir( path, "lib*.so" ); |
211 | QStringList list = dir.entryList(); | 212 | QStringList list = dir.entryList(); |
212 | QStringList::Iterator it; | 213 | QStringList::Iterator it; |
213 | for ( it = list.begin(); it != list.end(); ++it ) { | 214 | for ( it = list.begin(); it != list.end(); ++it ) { |
214 | TextCodecInterface *iface = 0; | 215 | TextCodecInterface *iface = 0; |
215 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 216 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
216 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 217 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
217 | QValueList<int> mibs = iface->mibEnums(); | 218 | QValueList<int> mibs = iface->mibEnums(); |
218 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 219 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
219 | (void)iface->createForMib(*i); | 220 | (void)iface->createForMib(*i); |
220 | // ### it exists now; need to remember if we can delete it | 221 | // ### it exists now; need to remember if we can delete it |
221 | } | 222 | } |
222 | } | 223 | } |
223 | else { | 224 | else { |
224 | lib->unload(); | 225 | lib->unload(); |
225 | delete lib; | 226 | delete lib; |
226 | } | 227 | } |
227 | } | 228 | } |
228 | } | 229 | } |
229 | 230 | ||
230 | void loadImageCodecs() | 231 | void loadImageCodecs() |
231 | { | 232 | { |
232 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 233 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
233 | QDir dir( path, "lib*.so" ); | 234 | QDir dir( path, "lib*.so" ); |
234 | QStringList list = dir.entryList(); | 235 | QStringList list = dir.entryList(); |
235 | QStringList::Iterator it; | 236 | QStringList::Iterator it; |
236 | for ( it = list.begin(); it != list.end(); ++it ) { | 237 | for ( it = list.begin(); it != list.end(); ++it ) { |
237 | ImageCodecInterface *iface = 0; | 238 | ImageCodecInterface *iface = 0; |
238 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 239 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
239 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 240 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
240 | QStringList formats = iface->keys(); | 241 | QStringList formats = iface->keys(); |
241 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 242 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
242 | (void)iface->installIOHandler(*i); | 243 | (void)iface->installIOHandler(*i); |
243 | // ### it exists now; need to remember if we can delete it | 244 | // ### it exists now; need to remember if we can delete it |
244 | } | 245 | } |
245 | } | 246 | } |
246 | else { | 247 | else { |
247 | lib->unload(); | 248 | lib->unload(); |
248 | delete lib; | 249 | delete lib; |
249 | } | 250 | } |
250 | } | 251 | } |
251 | } | 252 | } |
252 | QString styleName; | 253 | QString styleName; |
253 | QString decorationName; | 254 | QString decorationName; |
254 | }; | 255 | }; |
255 | 256 | ||
256 | class ResourceMimeFactory : public QMimeSourceFactory | 257 | class ResourceMimeFactory : public QMimeSourceFactory |
257 | { | 258 | { |
258 | public: | 259 | public: |
259 | ResourceMimeFactory() | 260 | ResourceMimeFactory() |
260 | { | 261 | { |
261 | setFilePath( Global::helpPath() ); | 262 | setFilePath( Global::helpPath() ); |
262 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 263 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
263 | } | 264 | } |
264 | 265 | ||
265 | const QMimeSource* data( const QString& abs_name ) const | 266 | const QMimeSource* data( const QString& abs_name ) const |
266 | { | 267 | { |
267 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 268 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
268 | if ( !r ) { | 269 | if ( !r ) { |
269 | int sl = abs_name.length(); | 270 | int sl = abs_name.length(); |
270 | do { | 271 | do { |
271 | sl = abs_name.findRev( '/', sl - 1 ); | 272 | sl = abs_name.findRev( '/', sl - 1 ); |
272 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 273 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
273 | int dot = name.findRev( '.' ); | 274 | int dot = name.findRev( '.' ); |
274 | if ( dot >= 0 ) | 275 | if ( dot >= 0 ) |
275 | name = name.left( dot ); | 276 | name = name.left( dot ); |
276 | QImage img = Resource::loadImage( name ); | 277 | QImage img = Resource::loadImage( name ); |
277 | if ( !img.isNull() ) | 278 | if ( !img.isNull() ) |
278 | r = new QImageDrag( img ); | 279 | r = new QImageDrag( img ); |
279 | } | 280 | } |
280 | while ( !r && sl > 0 ); | 281 | while ( !r && sl > 0 ); |