summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
Unidiff
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp2
1 files changed, 0 insertions, 2 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index ae1632e..5ce3011 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -1,765 +1,763 @@
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*/ 19*/
20#define QTOPIA_INTERNAL_LANGLIST 20#define QTOPIA_INTERNAL_LANGLIST
21#include <stdlib.h> 21#include <stdlib.h>
22#include <unistd.h> 22#include <unistd.h>
23#ifndef Q_OS_MACX 23#ifndef Q_OS_MACX
24#include <linux/limits.h> // needed for some toolchains (PATH_MAX) 24#include <linux/limits.h> // needed for some toolchains (PATH_MAX)
25#endif 25#endif
26#include <qfile.h> 26#include <qfile.h>
27#include <qqueue.h> 27#include <qqueue.h>
28#ifdef Q_WS_QWS 28#ifdef Q_WS_QWS
29#ifndef QT_NO_COP 29#ifndef QT_NO_COP
30#if QT_VERSION <= 231 30#if QT_VERSION <= 231
31#define private public 31#define private public
32#define sendLocally processEvent 32#define sendLocally processEvent
33#include "qcopenvelope_qws.h" 33#include "qcopenvelope_qws.h"
34#undef private 34#undef private
35#else 35#else
36#include "qcopenvelope_qws.h" 36#include "qcopenvelope_qws.h"
37#endif 37#endif
38#endif 38#endif
39#include <qwindowsystem_qws.h> 39#include <qwindowsystem_qws.h>
40#endif 40#endif
41#include <qtextstream.h> 41#include <qtextstream.h>
42#include <qpalette.h> 42#include <qpalette.h>
43#include <qbuffer.h> 43#include <qbuffer.h>
44#include <qptrdict.h> 44#include <qptrdict.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qdir.h> 46#include <qdir.h>
47#include <qlabel.h> 47#include <qlabel.h>
48#include <qdialog.h> 48#include <qdialog.h>
49#include <qdragobject.h> 49#include <qdragobject.h>
50#include <qtextcodec.h> 50#include <qtextcodec.h>
51#include <qevent.h> 51#include <qevent.h>
52#include <qtooltip.h> 52#include <qtooltip.h>
53#include <qsignal.h> 53#include <qsignal.h>
54#include <qmainwindow.h> 54#include <qmainwindow.h>
55#include <qwidgetlist.h> 55#include <qwidgetlist.h>
56#include <qpixmapcache.h> 56#include <qpixmapcache.h>
57 57
58#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 58#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
59#define QTOPIA_INTERNAL_INITAPP 59#define QTOPIA_INTERNAL_INITAPP
60#include "qpeapplication.h" 60#include "qpeapplication.h"
61#include "qpestyle.h" 61#include "qpestyle.h"
62#include "styleinterface.h" 62#include "styleinterface.h"
63#if QT_VERSION >= 300 63#if QT_VERSION >= 300
64#include <qstylefactory.h> 64#include <qstylefactory.h>
65#else 65#else
66#include <qplatinumstyle.h> 66#include <qplatinumstyle.h>
67#include <qwindowsstyle.h> 67#include <qwindowsstyle.h>
68#include <qmotifstyle.h> 68#include <qmotifstyle.h>
69#include <qmotifplusstyle.h> 69#include <qmotifplusstyle.h>
70#include "lightstyle.h" 70#include "lightstyle.h"
71 71
72#include <qpe/qlibrary.h> 72#include <qpe/qlibrary.h>
73#endif 73#endif
74#include "global.h" 74#include "global.h"
75#include "resource.h" 75#include "resource.h"
76#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 76#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
77#include "qutfcodec.h" 77#include "qutfcodec.h"
78#endif 78#endif
79#include "config.h" 79#include "config.h"
80#include "network.h" 80#include "network.h"
81#ifdef QWS 81#ifdef QWS
82#include "fontmanager.h" 82#include "fontmanager.h"
83#endif 83#endif
84 84
85#include "alarmserver.h" 85#include "alarmserver.h"
86#include "applnk.h" 86#include "applnk.h"
87#include "qpemenubar.h" 87#include "qpemenubar.h"
88#include "textcodecinterface.h" 88#include "textcodecinterface.h"
89#include "imagecodecinterface.h" 89#include "imagecodecinterface.h"
90 90
91#include <unistd.h> 91#include <unistd.h>
92#include <sys/file.h> 92#include <sys/file.h>
93#include <sys/ioctl.h> 93#include <sys/ioctl.h>
94#ifndef QT_NO_SOUND 94#ifndef QT_NO_SOUND
95#include <sys/soundcard.h> 95#include <sys/soundcard.h>
96#endif 96#endif
97#include "qt_override_p.h" 97#include "qt_override_p.h"
98 98
99class HackWidget : public QWidget 99class HackWidget : public QWidget
100{ 100{
101public: 101public:
102 bool needsOk() 102 bool needsOk()
103 { return (getWState() & WState_Reserved1 ); } 103 { return (getWState() & WState_Reserved1 ); }
104 104
105 QRect normalGeometry() 105 QRect normalGeometry()
106 { return topData()->normalGeometry; }; 106 { return topData()->normalGeometry; };
107}; 107};
108 108
109class QPEApplicationData 109class QPEApplicationData
110{ 110{
111public: 111public:
112 QPEApplicationData ( ) 112 QPEApplicationData ( )
113 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), 113 : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ),
114 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), 114 notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ),
115 keep_running( true ), qcopQok( false ), qpe_main_widget( 0 ) 115 keep_running( true ), qcopQok( false ), qpe_main_widget( 0 )
116 116
117 {} 117 {}
118 118
119 int presstimer; 119 int presstimer;
120 QWidget* presswidget; 120 QWidget* presswidget;
121 QPoint presspos; 121 QPoint presspos;
122 122
123 bool rightpressed : 1; 123 bool rightpressed : 1;
124 bool kbgrabbed : 1; 124 bool kbgrabbed : 1;
125 bool notbusysent : 1; 125 bool notbusysent : 1;
126 bool preloaded : 1; 126 bool preloaded : 1;
127 bool forceshow : 1; 127 bool forceshow : 1;
128 bool nomaximize : 1; 128 bool nomaximize : 1;
129 bool keep_running : 1; 129 bool keep_running : 1;
130 bool qcopQok : 1; 130 bool qcopQok : 1;
131 131
132 132
133 QStringList langs; 133 QStringList langs;
134 QString appName; 134 QString appName;
135 struct QCopRec 135 struct QCopRec
136 { 136 {
137 QCopRec( const QCString &ch, const QCString &msg, 137 QCopRec( const QCString &ch, const QCString &msg,
138 const QByteArray &d ) : 138 const QByteArray &d ) :
139 channel( ch ), message( msg ), data( d ) 139 channel( ch ), message( msg ), data( d )
140 { } 140 { }
141 141
142 QCString channel; 142 QCString channel;
143 QCString message; 143 QCString message;
144 QByteArray data; 144 QByteArray data;
145 }; 145 };
146 QWidget* qpe_main_widget; 146 QWidget* qpe_main_widget;
147 QGuardedPtr<QWidget> lastraised; 147 QGuardedPtr<QWidget> lastraised;
148 QQueue<QCopRec> qcopq; 148 QQueue<QCopRec> qcopq;
149 QString styleName; 149 QString styleName;
150 QString decorationName; 150 QString decorationName;
151 151
152 void enqueueQCop( const QCString &ch, const QCString &msg, 152 void enqueueQCop( const QCString &ch, const QCString &msg,
153 const QByteArray &data ) 153 const QByteArray &data )
154 { 154 {
155 qcopq.enqueue( new QCopRec( ch, msg, data ) ); 155 qcopq.enqueue( new QCopRec( ch, msg, data ) );
156 } 156 }
157 void sendQCopQ() 157 void sendQCopQ()
158 { 158 {
159 if (!qcopQok ) 159 if (!qcopQok )
160 return; 160 return;
161 161
162 QCopRec * r; 162 QCopRec * r;
163 163
164 while((r=qcopq.dequeue())) { 164 while((r=qcopq.dequeue())) {
165 // remove from queue before sending... 165 // remove from queue before sending...
166 // event loop can come around again before getting 166 // event loop can come around again before getting
167 // back from sendLocally 167 // back from sendLocally
168#ifndef QT_NO_COP 168#ifndef QT_NO_COP
169 QCopChannel::sendLocally( r->channel, r->message, r->data ); 169 QCopChannel::sendLocally( r->channel, r->message, r->data );
170#endif 170#endif
171 171
172 delete r; 172 delete r;
173 } 173 }
174 } 174 }
175 175
176 static void show_mx(QWidget* mw, bool nomaximize, QString &strName/* = QString::null */) 176 static void show_mx(QWidget* mw, bool nomaximize, QString &strName/* = QString::null */)
177 { 177 {
178 QPoint p; 178 QPoint p;
179 QSize s; 179 QSize s;
180 bool max; 180 bool max;
181 if ( mw->isVisible() ) { 181 if ( mw->isVisible() ) {
182 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 182 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
183 mw->resize(s); 183 mw->resize(s);
184 mw->move(p); 184 mw->move(p);
185 } 185 }
186 mw->raise(); 186 mw->raise();
187 } else { 187 } else {
188 188
189 if ( mw->layout() && mw->inherits("QDialog") ) { 189 if ( mw->layout() && mw->inherits("QDialog") ) {
190 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 190 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
191 mw->resize(s); 191 mw->resize(s);
192 mw->move(p); 192 mw->move(p);
193 193
194 if ( max && !nomaximize ) { 194 if ( max && !nomaximize ) {
195 mw->showMaximized(); 195 mw->showMaximized();
196 } else { 196 } else {
197 mw->show(); 197 mw->show();
198 } 198 }
199 } else { 199 } else {
200 qpe_show_dialog((QDialog*)mw,nomaximize); 200 qpe_show_dialog((QDialog*)mw,nomaximize);
201 } 201 }
202 } else { 202 } else {
203 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 203 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
204 mw->resize(s); 204 mw->resize(s);
205 mw->move(p); 205 mw->move(p);
206 } else { //no stored rectangle, make an estimation 206 } else { //no stored rectangle, make an estimation
207 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; 207 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2;
208 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; 208 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2;
209 mw->move( QMAX(x,0), QMAX(y,0) ); 209 mw->move( QMAX(x,0), QMAX(y,0) );
210#ifdef Q_WS_QWS 210#ifdef Q_WS_QWS
211 if ( !nomaximize ) 211 if ( !nomaximize )
212 mw->showMaximized(); 212 mw->showMaximized();
213#endif 213#endif
214 } 214 }
215 if ( max && !nomaximize ) 215 if ( max && !nomaximize )
216 mw->showMaximized(); 216 mw->showMaximized();
217 else 217 else
218 mw->show(); 218 mw->show();
219 } 219 }
220 } 220 }
221 } 221 }
222// // ugly hack, remove that later after finding a sane solution 222// // ugly hack, remove that later after finding a sane solution
223// // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, 223// // Addendum: Only Sharp currently has models with high resolution but (physically) small displays,
224// // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has 224// // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has
225// // a (physically) large enough display to use the small icons 225// // a (physically) large enough display to use the small icons
226// #if defined(OPIE_HIGH_RES_SMALL_PHY) 226// #if defined(OPIE_HIGH_RES_SMALL_PHY)
227// if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { 227// if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) {
228// ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); 228// ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true );
229// } 229// }
230// #endif 230// #endif
231 231
232 // if ( mw->layout() && mw->inherits("QDialog") ) { 232 // if ( mw->layout() && mw->inherits("QDialog") ) {
233 // QPEApplication::showDialog((QDialog*)mw, nomaximize); 233 // QPEApplication::showDialog((QDialog*)mw, nomaximize);
234 // } 234 // }
235 // else { 235 // else {
236// #ifdef Q_WS_QWS 236// #ifdef Q_WS_QWS
237 // if ( !nomaximize ) { 237 // if ( !nomaximize ) {
238 // qDebug("QDialog special case XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); 238 // qDebug("QDialog special case XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
239 // mw->showMaximized(); 239 // mw->showMaximized();
240 // //QPEApplication::showWidget( mw, !nomaximize ); 240 // //QPEApplication::showWidget( mw, !nomaximize );
241 // }else 241 // }else
242// #endif 242// #endif
243 // mw->show(); 243 // mw->show();
244 // } 244 // }
245 //} 245 //}
246 246
247 247
248static void qpe_show_dialog( QDialog* d, bool nomax ) 248static void qpe_show_dialog( QDialog* d, bool nomax )
249{ 249{
250 QSize sh = d->sizeHint(); 250 QSize sh = d->sizeHint();
251 int w = QMAX(sh.width(),d->width()); 251 int w = QMAX(sh.width(),d->width());
252 int h = QMAX(sh.height(),d->height()); 252 int h = QMAX(sh.height(),d->height());
253 253
254 if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) 254 if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() )
255 nomax = TRUE; 255 nomax = TRUE;
256 256
257#ifndef Q_WS_QWS 257#ifndef Q_WS_QWS
258 QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); 258 QSize s(qApp->desktop()->width(), qApp->desktop()->height() );
259#else 259#else
260 QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); 260 QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() );
261#endif 261#endif
262 262
263 int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); 263 int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width());
264 int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); 264 int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height());
265 265
266 if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { 266 if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) {
267 d->showMaximized(); 267 d->showMaximized();
268 } else { 268 } else {
269 // try centering the dialog around its parent 269 // try centering the dialog around its parent
270 QPoint p(0,0); 270 QPoint p(0,0);
271 if ( d->parentWidget() ) { 271 if ( d->parentWidget() ) {
272 QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); 272 QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) );
273 p = QPoint( pp.x() + d->parentWidget()->width()/2, 273 p = QPoint( pp.x() + d->parentWidget()->width()/2,
274 pp.y() + d->parentWidget()->height()/ 2 ); 274 pp.y() + d->parentWidget()->height()/ 2 );
275 } else { 275 } else {
276 p = QPoint( maxX/2, maxY/2 ); 276 p = QPoint( maxX/2, maxY/2 );
277 } 277 }
278 278
279 p = QPoint( p.x() - w/2, p.y() - h/2 ); 279 p = QPoint( p.x() - w/2, p.y() - h/2 );
280 //qDebug("p(x,y) is %d %d", p.x(), p.y() ); 280 //qDebug("p(x,y) is %d %d", p.x(), p.y() );
281 281
282 if ( w >= maxX ) { 282 if ( w >= maxX ) {
283 if ( p.y() < 0 ) 283 if ( p.y() < 0 )
284 p.setY(0); 284 p.setY(0);
285 if ( p.y() + h > maxY ) 285 if ( p.y() + h > maxY )
286 p.setY( maxY - h); 286 p.setY( maxY - h);
287 287
288 d->resize(maxX, h); 288 d->resize(maxX, h);
289 d->move(0, p.y() ); 289 d->move(0, p.y() );
290 } else if ( h >= maxY ) { 290 } else if ( h >= maxY ) {
291 if ( p.x() < 0 ) 291 if ( p.x() < 0 )
292 p.setX(0); 292 p.setX(0);
293 if ( p.x() + w > maxX ) 293 if ( p.x() + w > maxX )
294 p.setX( maxX - w); 294 p.setX( maxX - w);
295 295
296 d->resize(w, maxY); 296 d->resize(w, maxY);
297 d->move(p.x(),0); 297 d->move(p.x(),0);
298 } else { 298 } else {
299 d->resize(w, h); 299 d->resize(w, h);
300 } 300 }
301 301
302 d->show(); 302 d->show();
303 } 303 }
304} 304}
305 305
306 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) 306 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s)
307 { 307 {
308 maximized = TRUE; 308 maximized = TRUE;
309 qDebug("read_widget_rect");
310 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 309 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
311 if ( qApp->desktop()->width() <= 350 ) 310 if ( qApp->desktop()->width() <= 350 )
312 return FALSE; 311 return FALSE;
313 312
314 Config cfg( "qpe" ); 313 Config cfg( "qpe" );
315 cfg.setGroup("ApplicationPositions"); 314 cfg.setGroup("ApplicationPositions");
316 QString str = cfg.readEntry( app, QString::null ); 315 QString str = cfg.readEntry( app, QString::null );
317 QStringList l = QStringList::split(",", str); 316 QStringList l = QStringList::split(",", str);
318 317
319 if ( l.count() == 5) { 318 if ( l.count() == 5) {
320 p.setX( l[0].toInt() ); 319 p.setX( l[0].toInt() );
321 p.setY( l[1].toInt() ); 320 p.setY( l[1].toInt() );
322 321
323 s.setWidth( l[2].toInt() ); 322 s.setWidth( l[2].toInt() );
324 s.setHeight( l[3].toInt() ); 323 s.setHeight( l[3].toInt() );
325 324
326 maximized = l[4].toInt(); 325 maximized = l[4].toInt();
327 326
328 return TRUE; 327 return TRUE;
329 } 328 }
330 329
331 return FALSE; 330 return FALSE;
332 } 331 }
333 332
334 333
335 static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) 334 static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s)
336 { 335 {
337#ifndef Q_WS_QWS 336#ifndef Q_WS_QWS
338 QRect qt_maxWindowRect = qApp->desktop()->geometry(); 337 QRect qt_maxWindowRect = qApp->desktop()->geometry();
339#endif 338#endif
340 int maxX = qt_maxWindowRect.width(); 339 int maxX = qt_maxWindowRect.width();
341 int maxY = qt_maxWindowRect.height(); 340 int maxY = qt_maxWindowRect.height();
342 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); 341 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() );
343 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); 342 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() );
344 343
345 // total window size is not allowed to be larger than desktop window size 344 // total window size is not allowed to be larger than desktop window size
346 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) 345 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) )
347 return FALSE; 346 return FALSE;
348 347
349 if ( wWidth > maxX ) { 348 if ( wWidth > maxX ) {
350 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); 349 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) );
351 wWidth = maxX; 350 wWidth = maxX;
352 } 351 }
353 352
354 if ( wHeight > maxY ) { 353 if ( wHeight > maxY ) {
355 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); 354 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) );
356 wHeight = maxY; 355 wHeight = maxY;
357 } 356 }
358 357
359 // any smaller than this and the maximize/close/help buttons will be overlapping 358 // any smaller than this and the maximize/close/help buttons will be overlapping
360 if ( wWidth < 80 || wHeight < 60 ) 359 if ( wWidth < 80 || wHeight < 60 )
361 return FALSE; 360 return FALSE;
362 361
363 if ( p.x() < 0 ) 362 if ( p.x() < 0 )
364 p.setX(0); 363 p.setX(0);
365 if ( p.y() < 0 ) 364 if ( p.y() < 0 )
366 p.setY(0); 365 p.setY(0);
367 366
368 if ( p.x() + wWidth > maxX ) 367 if ( p.x() + wWidth > maxX )
369 p.setX( maxX - wWidth ); 368 p.setX( maxX - wWidth );
370 if ( p.y() + wHeight > maxY ) 369 if ( p.y() + wHeight > maxY )
371 p.setY( maxY - wHeight ); 370 p.setY( maxY - wHeight );
372 371
373 return TRUE; 372 return TRUE;
374 } 373 }
375 374
376 static void store_widget_rect(QWidget *w, QString &app) 375 static void store_widget_rect(QWidget *w, QString &app)
377 { 376 {
378 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 377 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
379 if ( qApp->desktop()->width() <= 350 ) 378 if ( qApp->desktop()->width() <= 350 )
380 return; 379 return;
381 qDebug("store_widget_rect");
382 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to 380 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to
383 // get the non-maximized version, so we have to do it the hard way ) 381 // get the non-maximized version, so we have to do it the hard way )
384 int offsetX = w->x() - w->geometry().left(); 382 int offsetX = w->x() - w->geometry().left();
385 int offsetY = w->y() - w->geometry().top(); 383 int offsetY = w->y() - w->geometry().top();
386 384
387 QRect r; 385 QRect r;
388 if ( w->isMaximized() ) 386 if ( w->isMaximized() )
389 r = ( (HackWidget *) w)->normalGeometry(); 387 r = ( (HackWidget *) w)->normalGeometry();
390 else 388 else
391 r = w->geometry(); 389 r = w->geometry();
392 390
393 // Stores the window placement as pos(), size() (due to the offset mapping) 391 // Stores the window placement as pos(), size() (due to the offset mapping)
394 Config cfg( "qpe" ); 392 Config cfg( "qpe" );
395 cfg.setGroup("ApplicationPositions"); 393 cfg.setGroup("ApplicationPositions");
396 QString s; 394 QString s;
397 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); 395 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() );
398 cfg.writeEntry( app, s ); 396 cfg.writeEntry( app, s );
399 } 397 }
400 398
401 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 399 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
402 { 400 {
403 /* 401 /*
404 // This works but disable it for now until it is safe to apply 402 // This works but disable it for now until it is safe to apply
405 // What is does is scan the .desktop files of all the apps for 403 // What is does is scan the .desktop files of all the apps for
406 // the applnk that has the corresponding argv[0] as this program 404 // the applnk that has the corresponding argv[0] as this program
407 // then it uses the name stored in the .desktop file as the caption 405 // then it uses the name stored in the .desktop file as the caption
408 // for the main widget. This saves duplicating translations for 406 // for the main widget. This saves duplicating translations for
409 // the app name in the program and in the .desktop files. 407 // the app name in the program and in the .desktop files.
410 408
411 AppLnkSet apps( appsPath ); 409 AppLnkSet apps( appsPath );
412 410
413 QList<AppLnk> appsList = apps.children(); 411 QList<AppLnk> appsList = apps.children();
414 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 412 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
415 if ( (*it)->exec() == appName ) { 413 if ( (*it)->exec() == appName ) {
416 mw->setCaption( (*it)->name() ); 414 mw->setCaption( (*it)->name() );
417 return TRUE; 415 return TRUE;
418 } 416 }
419 } 417 }
420 */ 418 */
421 return FALSE; 419 return FALSE;
422 } 420 }
423 421
424 422
425 void show(QWidget* mw, bool nomax) 423 void show(QWidget* mw, bool nomax)
426 { 424 {
427 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); 425 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
428 nomaximize = nomax; 426 nomaximize = nomax;
429 qpe_main_widget = mw; 427 qpe_main_widget = mw;
430 qcopQok = TRUE; 428 qcopQok = TRUE;
431#ifndef QT_NO_COP 429#ifndef QT_NO_COP
432 430
433 sendQCopQ(); 431 sendQCopQ();
434#endif 432#endif
435 433
436 if ( preloaded ) { 434 if ( preloaded ) {
437 if (forceshow) 435 if (forceshow)
438 show_mx(mw, nomax, appName); 436 show_mx(mw, nomax, appName);
439 } 437 }
440 else if ( keep_running ) { 438 else if ( keep_running ) {
441 show_mx(mw, nomax, appName); 439 show_mx(mw, nomax, appName);
442 } 440 }
443 } 441 }
444 442
445 void loadTextCodecs() 443 void loadTextCodecs()
446 { 444 {
447 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; 445 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs";
448#ifdef Q_OS_MACX 446#ifdef Q_OS_MACX
449 QDir dir( path, "lib*.dylib" ); 447 QDir dir( path, "lib*.dylib" );
450#else 448#else
451 QDir dir( path, "lib*.so" ); 449 QDir dir( path, "lib*.so" );
452#endif 450#endif
453 QStringList list; 451 QStringList list;
454 if ( dir. exists ( )) 452 if ( dir. exists ( ))
455 list = dir.entryList(); 453 list = dir.entryList();
456 QStringList::Iterator it; 454 QStringList::Iterator it;
457 for ( it = list.begin(); it != list.end(); ++it ) { 455 for ( it = list.begin(); it != list.end(); ++it ) {
458 TextCodecInterface *iface = 0; 456 TextCodecInterface *iface = 0;
459 QLibrary *lib = new QLibrary( path + "/" + *it ); 457 QLibrary *lib = new QLibrary( path + "/" + *it );
460 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 458 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
461 QValueList<int> mibs = iface->mibEnums(); 459 QValueList<int> mibs = iface->mibEnums();
462 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 460 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
463 (void)iface->createForMib(*i); 461 (void)iface->createForMib(*i);
464 // ### it exists now; need to remember if we can delete it 462 // ### it exists now; need to remember if we can delete it
465 } 463 }
466 } 464 }
467 else { 465 else {
468 lib->unload(); 466 lib->unload();
469 delete lib; 467 delete lib;
470 } 468 }
471 } 469 }
472 } 470 }
473 471
474 void loadImageCodecs() 472 void loadImageCodecs()
475 { 473 {
476 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; 474 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
477#ifdef Q_OS_MACX 475#ifdef Q_OS_MACX
478 QDir dir( path, "lib*.dylib" ); 476 QDir dir( path, "lib*.dylib" );
479#else 477#else
480 QDir dir( path, "lib*.so" ); 478 QDir dir( path, "lib*.so" );
481#endif 479#endif
482 QStringList list; 480 QStringList list;
483 if ( dir. exists ( )) 481 if ( dir. exists ( ))
484 list = dir.entryList(); 482 list = dir.entryList();
485 QStringList::Iterator it; 483 QStringList::Iterator it;
486 for ( it = list.begin(); it != list.end(); ++it ) { 484 for ( it = list.begin(); it != list.end(); ++it ) {
487 ImageCodecInterface *iface = 0; 485 ImageCodecInterface *iface = 0;
488 QLibrary *lib = new QLibrary( path + "/" + *it ); 486 QLibrary *lib = new QLibrary( path + "/" + *it );
489 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 487 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
490 QStringList formats = iface->keys(); 488 QStringList formats = iface->keys();
491 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 489 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
492 (void)iface->installIOHandler(*i); 490 (void)iface->installIOHandler(*i);
493 // ### it exists now; need to remember if we can delete it 491 // ### it exists now; need to remember if we can delete it
494 } 492 }
495 } 493 }
496 else { 494 else {
497 lib->unload(); 495 lib->unload();
498 delete lib; 496 delete lib;
499 } 497 }
500 } 498 }
501 } 499 }
502}; 500};
503 501
504class ResourceMimeFactory : public QMimeSourceFactory 502class ResourceMimeFactory : public QMimeSourceFactory
505{ 503{
506public: 504public:
507 ResourceMimeFactory() : resImage( 0 ) 505 ResourceMimeFactory() : resImage( 0 )
508 { 506 {
509 setFilePath( Global::helpPath() ); 507 setFilePath( Global::helpPath() );
510 setExtensionType( "html", "text/html;charset=UTF-8" ); 508 setExtensionType( "html", "text/html;charset=UTF-8" );
511 } 509 }
512 ~ResourceMimeFactory() { 510 ~ResourceMimeFactory() {
513 delete resImage; 511 delete resImage;
514 } 512 }
515 513
516 const QMimeSource* data( const QString& abs_name ) const 514 const QMimeSource* data( const QString& abs_name ) const
517 { 515 {
518 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 516 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
519 if ( !r ) { 517 if ( !r ) {
520 int sl = abs_name.length(); 518 int sl = abs_name.length();
521 do { 519 do {
522 sl = abs_name.findRev( '/', sl - 1 ); 520 sl = abs_name.findRev( '/', sl - 1 );
523 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 521 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
524 int dot = name.findRev( '.' ); 522 int dot = name.findRev( '.' );
525 if ( dot >= 0 ) 523 if ( dot >= 0 )
526 name = name.left( dot ); 524 name = name.left( dot );
527 QImage img = Resource::loadImage( name ); 525 QImage img = Resource::loadImage( name );
528 if ( !img.isNull() ) { 526 if ( !img.isNull() ) {
529 delete resImage; 527 delete resImage;
530 resImage = new QImageDrag( img ); 528 resImage = new QImageDrag( img );
531 r = resImage; 529 r = resImage;
532 } 530 }
533 } 531 }
534 while ( !r && sl > 0 ); 532 while ( !r && sl > 0 );
535 } 533 }
536 return r; 534 return r;
537 } 535 }
538private: 536private:
539 mutable QImageDrag *resImage; 537 mutable QImageDrag *resImage;
540}; 538};
541 539
542static int& hack(int& i) 540static int& hack(int& i)
543{ 541{
544#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 542#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
545 // These should be created, but aren't in Qt 2.3.0 543 // These should be created, but aren't in Qt 2.3.0
546 (void)new QUtf8Codec; 544 (void)new QUtf8Codec;
547 (void)new QUtf16Codec; 545 (void)new QUtf16Codec;
548#endif 546#endif
549 return i; 547 return i;
550} 548}
551 549
552static int muted = 0; 550static int muted = 0;
553static int micMuted = 0; 551static int micMuted = 0;
554 552
555static void setVolume( int t = 0, int percent = -1 ) 553static void setVolume( int t = 0, int percent = -1 )
556{ 554{
557 switch ( t ) { 555 switch ( t ) {
558 case 0: { 556 case 0: {
559 Config cfg( "qpe" ); 557 Config cfg( "qpe" );
560 cfg.setGroup( "Volume" ); 558 cfg.setGroup( "Volume" );
561 if ( percent < 0 ) 559 if ( percent < 0 )
562 percent = cfg.readNumEntry( "VolumePercent", 50 ); 560 percent = cfg.readNumEntry( "VolumePercent", 50 );
563#ifndef QT_NO_SOUND 561#ifndef QT_NO_SOUND
564 int fd = 0; 562 int fd = 0;
565 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 563 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
566 int vol = muted ? 0 : percent; 564 int vol = muted ? 0 : percent;
567 // set both channels to same volume 565 // set both channels to same volume
568 vol |= vol << 8; 566 vol |= vol << 8;
569 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); 567 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol );
570 ::close( fd ); 568 ::close( fd );
571 } 569 }
572#endif 570#endif
573 } 571 }
574 break; 572 break;
575 } 573 }
576} 574}
577 575
578static void setMic( int t = 0, int percent = -1 ) 576static void setMic( int t = 0, int percent = -1 )
579{ 577{
580 switch ( t ) { 578 switch ( t ) {
581 case 0: { 579 case 0: {
582 Config cfg( "qpe" ); 580 Config cfg( "qpe" );
583 cfg.setGroup( "Volume" ); 581 cfg.setGroup( "Volume" );
584 if ( percent < 0 ) 582 if ( percent < 0 )
585 percent = cfg.readNumEntry( "Mic", 50 ); 583 percent = cfg.readNumEntry( "Mic", 50 );
586 584
587#ifndef QT_NO_SOUND 585#ifndef QT_NO_SOUND
588 int fd = 0; 586 int fd = 0;
589 int mic = micMuted ? 0 : percent; 587 int mic = micMuted ? 0 : percent;
590 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 588 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
591 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); 589 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic );
592 ::close( fd ); 590 ::close( fd );
593 } 591 }
594#endif 592#endif
595 } 593 }
596 break; 594 break;
597 } 595 }
598} 596}
599 597
600 598
601static void setBass( int t = 0, int percent = -1 ) 599static void setBass( int t = 0, int percent = -1 )
602{ 600{
603 switch ( t ) { 601 switch ( t ) {
604 case 0: { 602 case 0: {
605 Config cfg( "qpe" ); 603 Config cfg( "qpe" );
606 cfg.setGroup( "Volume" ); 604 cfg.setGroup( "Volume" );
607 if ( percent < 0 ) 605 if ( percent < 0 )
608 percent = cfg.readNumEntry( "BassPercent", 50 ); 606 percent = cfg.readNumEntry( "BassPercent", 50 );
609 607
610#ifndef QT_NO_SOUND 608#ifndef QT_NO_SOUND
611 int fd = 0; 609 int fd = 0;
612 int bass = percent; 610 int bass = percent;
613 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 611 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
614 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); 612 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass );
615 ::close( fd ); 613 ::close( fd );
616 } 614 }
617#endif 615#endif
618 } 616 }
619 break; 617 break;
620 } 618 }
621} 619}
622 620
623 621
624static void setTreble( int t = 0, int percent = -1 ) 622static void setTreble( int t = 0, int percent = -1 )
625{ 623{
626 switch ( t ) { 624 switch ( t ) {
627 case 0: { 625 case 0: {
628 Config cfg( "qpe" ); 626 Config cfg( "qpe" );
629 cfg.setGroup( "Volume" ); 627 cfg.setGroup( "Volume" );
630 if ( percent < 0 ) 628 if ( percent < 0 )
631 percent = cfg.readNumEntry( "TreblePercent", 50 ); 629 percent = cfg.readNumEntry( "TreblePercent", 50 );
632 630
633#ifndef QT_NO_SOUND 631#ifndef QT_NO_SOUND
634 int fd = 0; 632 int fd = 0;
635 int treble = percent; 633 int treble = percent;
636 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 634 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
637 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); 635 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble );
638 ::close( fd ); 636 ::close( fd );
639 } 637 }
640#endif 638#endif
641 } 639 }
642 break; 640 break;
643 } 641 }
644} 642}
645 643
646 644
647/** 645/**
648 \class QPEApplication 646 \class QPEApplication
649 \brief The QPEApplication class implements various system services 647 \brief The QPEApplication class implements various system services
650 that are available to all Qtopia applications. 648 that are available to all Qtopia applications.
651 649
652 Simply by using QPEApplication instead of QApplication, a standard Qt 650 Simply by using QPEApplication instead of QApplication, a standard Qt
653 application becomes a Qtopia application. It automatically follows 651 application becomes a Qtopia application. It automatically follows
654 style changes, quits and raises, and in the 652 style changes, quits and raises, and in the
655 case of \link docwidget.html document-oriented\endlink applications, 653 case of \link docwidget.html document-oriented\endlink applications,
656 changes the currently displayed document in response to the environment. 654 changes the currently displayed document in response to the environment.
657 655
658 To create a \link docwidget.html document-oriented\endlink 656 To create a \link docwidget.html document-oriented\endlink
659 application use showMainDocumentWidget(); to create a 657 application use showMainDocumentWidget(); to create a
660 non-document-oriented application use showMainWidget(). The 658 non-document-oriented application use showMainWidget(). The
661 keepRunning() function indicates whether the application will 659 keepRunning() function indicates whether the application will
662 continue running after it's processed the last \link qcop.html 660 continue running after it's processed the last \link qcop.html
663 QCop\endlink message. This can be changed using setKeepRunning(). 661 QCop\endlink message. This can be changed using setKeepRunning().
664 662
665 A variety of signals are emitted when certain events occur, for 663 A variety of signals are emitted when certain events occur, for
666 example, timeChanged(), clockChanged(), weekChanged(), 664 example, timeChanged(), clockChanged(), weekChanged(),
667 dateFormatChanged() and volumeChanged(). If the application receives 665 dateFormatChanged() and volumeChanged(). If the application receives
668 a \link qcop.html QCop\endlink message on the application's 666 a \link qcop.html QCop\endlink message on the application's
669 QPE/Application/\e{appname} channel, the appMessage() signal is 667 QPE/Application/\e{appname} channel, the appMessage() signal is
670 emitted. There are also flush() and reload() signals, which 668 emitted. There are also flush() and reload() signals, which
671 are emitted when synching begins and ends respectively - upon these 669 are emitted when synching begins and ends respectively - upon these
672 signals, the application should save and reload any data 670 signals, the application should save and reload any data
673 files that are involved in synching. Most of these signals will initially 671 files that are involved in synching. Most of these signals will initially
674 be received and unfiltered through the appMessage() signal. 672 be received and unfiltered through the appMessage() signal.
675 673
676 This class also provides a set of useful static functions. The 674 This class also provides a set of useful static functions. The
677 qpeDir() and documentDir() functions return the respective paths. 675 qpeDir() and documentDir() functions return the respective paths.
678 The grabKeyboard() and ungrabKeyboard() functions are used to 676 The grabKeyboard() and ungrabKeyboard() functions are used to
679 control whether the application takes control of the device's 677 control whether the application takes control of the device's
680 physical buttons (e.g. application launch keys). The stylus' mode of 678 physical buttons (e.g. application launch keys). The stylus' mode of
681 operation is set with setStylusOperation() and retrieved with 679 operation is set with setStylusOperation() and retrieved with
682 stylusOperation(). There are also setInputMethodHint() and 680 stylusOperation(). There are also setInputMethodHint() and
683 inputMethodHint() functions. 681 inputMethodHint() functions.
684 682
685 \ingroup qtopiaemb 683 \ingroup qtopiaemb
686*/ 684*/
687 685
688/*! 686/*!
689 \fn void QPEApplication::clientMoused() 687 \fn void QPEApplication::clientMoused()
690 688
691 \internal 689 \internal
692*/ 690*/
693 691
694/*! 692/*!
695 \fn void QPEApplication::timeChanged(); 693 \fn void QPEApplication::timeChanged();
696 This signal is emitted when the time changes outside the normal 694 This signal is emitted when the time changes outside the normal
697 passage of time, i.e. if the time is set backwards or forwards. 695 passage of time, i.e. if the time is set backwards or forwards.
698*/ 696*/
699 697
700/*! 698/*!
701 \fn void QPEApplication::clockChanged( bool ampm ); 699 \fn void QPEApplication::clockChanged( bool ampm );
702 700
703 This signal is emitted when the user changes the clock's style. If 701 This signal is emitted when the user changes the clock's style. If
704 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, 702 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
705 they want a 24-hour clock. 703 they want a 24-hour clock.
706*/ 704*/
707 705
708/*! 706/*!
709 \fn void QPEApplication::volumeChanged( bool muted ) 707 \fn void QPEApplication::volumeChanged( bool muted )
710 708
711 This signal is emitted whenever the mute state is changed. If \a 709 This signal is emitted whenever the mute state is changed. If \a
712 muted is TRUE, then sound output has been muted. 710 muted is TRUE, then sound output has been muted.
713*/ 711*/
714 712
715/*! 713/*!
716 \fn void QPEApplication::weekChanged( bool startOnMonday ) 714 \fn void QPEApplication::weekChanged( bool startOnMonday )
717 715
718 This signal is emitted if the week start day is changed. If \a 716 This signal is emitted if the week start day is changed. If \a
719 startOnMonday is TRUE then the first day of the week is Monday; if 717 startOnMonday is TRUE then the first day of the week is Monday; if
720 \a startOnMonday is FALSE then the first day of the week is 718 \a startOnMonday is FALSE then the first day of the week is
721 Sunday. 719 Sunday.
722*/ 720*/
723 721
724/*! 722/*!
725 \fn void QPEApplication::dateFormatChanged(DateFormat) 723 \fn void QPEApplication::dateFormatChanged(DateFormat)
726 724
727 This signal is emitted whenever the date format is changed. 725 This signal is emitted whenever the date format is changed.
728*/ 726*/
729 727
730/*! 728/*!
731 \fn void QPEApplication::flush() 729 \fn void QPEApplication::flush()
732 730
733 ### 731 ###
734*/ 732*/
735 733
736/*! 734/*!
737 \fn void QPEApplication::reload() 735 \fn void QPEApplication::reload()
738 736
739*/ 737*/
740 738
741 739
742 740
743void QPEApplication::processQCopFile() 741void QPEApplication::processQCopFile()
744{ 742{
745 QString qcopfn("/tmp/qcop-msg-"); 743 QString qcopfn("/tmp/qcop-msg-");
746 qcopfn += d->appName; // append command name 744 qcopfn += d->appName; // append command name
747 745
748 QFile f(qcopfn); 746 QFile f(qcopfn);
749 if ( f.open(IO_ReadWrite) ) { 747 if ( f.open(IO_ReadWrite) ) {
750#ifndef Q_OS_WIN32 748#ifndef Q_OS_WIN32
751 flock(f.handle(), LOCK_EX); 749 flock(f.handle(), LOCK_EX);
752#endif 750#endif
753 QDataStream ds(&f); 751 QDataStream ds(&f);
754 QCString channel, message; 752 QCString channel, message;
755 QByteArray data; 753 QByteArray data;
756 while(!ds.atEnd()) { 754 while(!ds.atEnd()) {
757 ds >> channel >> message >> data; 755 ds >> channel >> message >> data;
758 d->enqueueQCop(channel,message,data); 756 d->enqueueQCop(channel,message,data);
759 } 757 }
760 ::ftruncate(f.handle(), 0); 758 ::ftruncate(f.handle(), 0);
761#ifndef Q_OS_WIN32 759#ifndef Q_OS_WIN32
762 f.flush(); 760 f.flush();
763 flock(f.handle(), LOCK_UN); 761 flock(f.handle(), LOCK_UN);
764#endif 762#endif
765 } 763 }