-rw-r--r-- | library/qpeapplication.cpp | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index b5dff3a..c41dd06 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -63,105 +63,100 @@ | |||
63 | #include "lightstyle.h" | 63 | #include "lightstyle.h" |
64 | 64 | ||
65 | #include <qpe/qlibrary.h> | 65 | #include <qpe/qlibrary.h> |
66 | #endif | 66 | #endif |
67 | #include "global.h" | 67 | #include "global.h" |
68 | #include "resource.h" | 68 | #include "resource.h" |
69 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 69 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
70 | #include "qutfcodec.h" | 70 | #include "qutfcodec.h" |
71 | #endif | 71 | #endif |
72 | #include "config.h" | 72 | #include "config.h" |
73 | #include "network.h" | 73 | #include "network.h" |
74 | #ifdef QWS | 74 | #ifdef QWS |
75 | #include "fontmanager.h" | 75 | #include "fontmanager.h" |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | #include "alarmserver.h" | 78 | #include "alarmserver.h" |
79 | #include "applnk.h" | 79 | #include "applnk.h" |
80 | #include "qpemenubar.h" | 80 | #include "qpemenubar.h" |
81 | #include "textcodecinterface.h" | 81 | #include "textcodecinterface.h" |
82 | #include "imagecodecinterface.h" | 82 | #include "imagecodecinterface.h" |
83 | 83 | ||
84 | #include <unistd.h> | 84 | #include <unistd.h> |
85 | #include <sys/file.h> | 85 | #include <sys/file.h> |
86 | #include <sys/ioctl.h> | 86 | #include <sys/ioctl.h> |
87 | #include <sys/soundcard.h> | 87 | #include <sys/soundcard.h> |
88 | 88 | ||
89 | #include "qt_override_p.h" | 89 | #include "qt_override_p.h" |
90 | 90 | ||
91 | 91 | ||
92 | class QPEApplicationData | 92 | class QPEApplicationData |
93 | { | 93 | { |
94 | public: | 94 | public: |
95 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), | 95 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), kbgrabber( 0 ), |
96 | kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), | 96 | rightpressed( FALSE ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), |
97 | forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ), | 97 | forceshow( FALSE ), nomaximize( FALSE ), keep_running( TRUE ), qpe_main_widget( 0 ) |
98 | keep_running( TRUE ) | 98 | |
99 | { | 99 | { |
100 | qcopq.setAutoDelete( TRUE ); | 100 | qcopq.setAutoDelete( TRUE ); |
101 | } | 101 | } |
102 | 102 | ||
103 | int presstimer; | 103 | int presstimer; |
104 | QWidget* presswidget; | 104 | QWidget* presswidget; |
105 | QPoint presspos; | ||
106 | bool rightpressed : | ||
107 | 1; // AEH why not use uint foobar :1; if it's tt style -zecke | ||
108 | int kbgrabber; | 105 | int kbgrabber; |
109 | bool kbregrab : | 106 | QPoint presspos; |
110 | 1; | 107 | |
111 | bool notbusysent : | 108 | bool rightpressed : 1; |
112 | 1; | 109 | bool kbregrab : 1; |
110 | bool notbusysent : 1; | ||
111 | bool preloaded : 1; | ||
112 | bool forceshow : 1; | ||
113 | bool nomaximize : 1; | ||
114 | bool keep_running : 1; | ||
115 | |||
113 | QString appName; | 116 | QString appName; |
114 | struct QCopRec | 117 | struct QCopRec |
115 | { | 118 | { |
116 | QCopRec( const QCString &ch, const QCString &msg, | 119 | QCopRec( const QCString &ch, const QCString &msg, |
117 | const QByteArray &d ) : | 120 | const QByteArray &d ) : |
118 | channel( ch ), message( msg ), data( d ) | 121 | channel( ch ), message( msg ), data( d ) |
119 | { } | 122 | { } |
120 | 123 | ||
121 | QCString channel; | 124 | QCString channel; |
122 | QCString message; | 125 | QCString message; |
123 | QByteArray data; | 126 | QByteArray data; |
124 | }; | 127 | }; |
125 | bool preloaded : | ||
126 | 1; | ||
127 | bool forceshow : | ||
128 | 1; | ||
129 | bool nomaximize : | ||
130 | 1; | ||
131 | QWidget* qpe_main_widget; | 128 | QWidget* qpe_main_widget; |
132 | bool keep_running : | ||
133 | 1; | ||
134 | QList<QCopRec> qcopq; | 129 | QList<QCopRec> qcopq; |
135 | 130 | ||
136 | void enqueueQCop( const QCString &ch, const QCString &msg, | 131 | void enqueueQCop( const QCString &ch, const QCString &msg, |
137 | const QByteArray &data ) | 132 | const QByteArray &data ) |
138 | { | 133 | { |
139 | qcopq.append( new QCopRec( ch, msg, data ) ); | 134 | qcopq.append( new QCopRec( ch, msg, data ) ); |
140 | } | 135 | } |
141 | void sendQCopQ() | 136 | void sendQCopQ() |
142 | { | 137 | { |
143 | QCopRec * r; | 138 | QCopRec * r; |
144 | #ifndef QT_NO_COP | 139 | #ifndef QT_NO_COP |
145 | 140 | ||
146 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) | 141 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) |
147 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 142 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
148 | #endif | 143 | #endif |
149 | 144 | ||
150 | qcopq.clear(); | 145 | qcopq.clear(); |
151 | } | 146 | } |
152 | static void show_mx(QWidget* mw, bool nomaximize) | 147 | static void show_mx(QWidget* mw, bool nomaximize) |
153 | { | 148 | { |
154 | if ( mw->layout() && mw->inherits("QDialog") ) { | 149 | if ( mw->layout() && mw->inherits("QDialog") ) { |
155 | QPEApplication::showDialog((QDialog*)mw, nomaximize); | 150 | QPEApplication::showDialog((QDialog*)mw, nomaximize); |
156 | } | 151 | } |
157 | else { | 152 | else { |
158 | #ifdef Q_WS_QWS | 153 | #ifdef Q_WS_QWS |
159 | if ( !nomaximize ) | 154 | if ( !nomaximize ) |
160 | mw->showMaximized(); | 155 | mw->showMaximized(); |
161 | else | 156 | else |
162 | #endif | 157 | #endif |
163 | 158 | ||
164 | mw->show(); | 159 | mw->show(); |
165 | } | 160 | } |
166 | } | 161 | } |
167 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 162 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
@@ -182,88 +177,92 @@ bool keep_running : | |||
182 | mw->setCaption( (*it)->name() ); | 177 | mw->setCaption( (*it)->name() ); |
183 | return TRUE; | 178 | return TRUE; |
184 | } | 179 | } |
185 | } | 180 | } |
186 | */ | 181 | */ |
187 | return FALSE; | 182 | return FALSE; |
188 | } | 183 | } |
189 | 184 | ||
190 | 185 | ||
191 | void show(QWidget* mw, bool nomax) | 186 | void show(QWidget* mw, bool nomax) |
192 | { | 187 | { |
193 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 188 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
194 | nomaximize = nomax; | 189 | nomaximize = nomax; |
195 | qpe_main_widget = mw; | 190 | qpe_main_widget = mw; |
196 | #ifndef QT_NO_COP | 191 | #ifndef QT_NO_COP |
197 | 192 | ||
198 | sendQCopQ(); | 193 | sendQCopQ(); |
199 | #endif | 194 | #endif |
200 | 195 | ||
201 | if ( preloaded ) { | 196 | if ( preloaded ) { |
202 | if (forceshow) | 197 | if (forceshow) |
203 | show_mx(mw, nomax); | 198 | show_mx(mw, nomax); |
204 | } | 199 | } |
205 | else if ( keep_running ) { | 200 | else if ( keep_running ) { |
206 | show_mx(mw, nomax); | 201 | show_mx(mw, nomax); |
207 | } | 202 | } |
208 | } | 203 | } |
209 | 204 | ||
210 | void loadTextCodecs() | 205 | void loadTextCodecs() |
211 | { | 206 | { |
212 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 207 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
213 | QDir dir( path, "lib*.so" ); | 208 | QDir dir( path, "lib*.so" ); |
214 | QStringList list = dir.entryList(); | 209 | QStringList list; |
210 | if ( dir. exists ( )) | ||
211 | list = dir.entryList(); | ||
215 | QStringList::Iterator it; | 212 | QStringList::Iterator it; |
216 | for ( it = list.begin(); it != list.end(); ++it ) { | 213 | for ( it = list.begin(); it != list.end(); ++it ) { |
217 | TextCodecInterface *iface = 0; | 214 | TextCodecInterface *iface = 0; |
218 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 215 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
219 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 216 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
220 | QValueList<int> mibs = iface->mibEnums(); | 217 | QValueList<int> mibs = iface->mibEnums(); |
221 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 218 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
222 | (void)iface->createForMib(*i); | 219 | (void)iface->createForMib(*i); |
223 | // ### it exists now; need to remember if we can delete it | 220 | // ### it exists now; need to remember if we can delete it |
224 | } | 221 | } |
225 | } | 222 | } |
226 | else { | 223 | else { |
227 | lib->unload(); | 224 | lib->unload(); |
228 | delete lib; | 225 | delete lib; |
229 | } | 226 | } |
230 | } | 227 | } |
231 | } | 228 | } |
232 | 229 | ||
233 | void loadImageCodecs() | 230 | void loadImageCodecs() |
234 | { | 231 | { |
235 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 232 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
236 | QDir dir( path, "lib*.so" ); | 233 | QDir dir( path, "lib*.so" ); |
237 | QStringList list = dir.entryList(); | 234 | QStringList list; |
235 | if ( dir. exists ( )) | ||
236 | list = dir.entryList(); | ||
238 | QStringList::Iterator it; | 237 | QStringList::Iterator it; |
239 | for ( it = list.begin(); it != list.end(); ++it ) { | 238 | for ( it = list.begin(); it != list.end(); ++it ) { |
240 | ImageCodecInterface *iface = 0; | 239 | ImageCodecInterface *iface = 0; |
241 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 240 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
242 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 241 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
243 | QStringList formats = iface->keys(); | 242 | QStringList formats = iface->keys(); |
244 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 243 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
245 | (void)iface->installIOHandler(*i); | 244 | (void)iface->installIOHandler(*i); |
246 | // ### it exists now; need to remember if we can delete it | 245 | // ### it exists now; need to remember if we can delete it |
247 | } | 246 | } |
248 | } | 247 | } |
249 | else { | 248 | else { |
250 | lib->unload(); | 249 | lib->unload(); |
251 | delete lib; | 250 | delete lib; |
252 | } | 251 | } |
253 | } | 252 | } |
254 | } | 253 | } |
255 | QString styleName; | 254 | QString styleName; |
256 | QString decorationName; | 255 | QString decorationName; |
257 | }; | 256 | }; |
258 | 257 | ||
259 | class ResourceMimeFactory : public QMimeSourceFactory | 258 | class ResourceMimeFactory : public QMimeSourceFactory |
260 | { | 259 | { |
261 | public: | 260 | public: |
262 | ResourceMimeFactory() | 261 | ResourceMimeFactory() |
263 | { | 262 | { |
264 | setFilePath( Global::helpPath() ); | 263 | setFilePath( Global::helpPath() ); |
265 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 264 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
266 | } | 265 | } |
267 | 266 | ||
268 | const QMimeSource* data( const QString& abs_name ) const | 267 | const QMimeSource* data( const QString& abs_name ) const |
269 | { | 268 | { |