summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-11-05 10:29:08 (UTC)
committer llornkcor <llornkcor>2003-11-05 10:29:08 (UTC)
commit91369ae9ca93f499fd0883a13f046a4b435d1b56 (patch) (unidiff)
tree212e2dcaa21365a55bd16451c4087e684283b8ba
parentd0e7b4f9da3275e6d2fb4dcc8e1b38a2117443f5 (diff)
downloadopie-91369ae9ca93f499fd0883a13f046a4b435d1b56.zip
opie-91369ae9ca93f499fd0883a13f046a4b435d1b56.tar.gz
opie-91369ae9ca93f499fd0883a13f046a4b435d1b56.tar.bz2
removed include custom.h cause build system doesn't create it for me and I am tired of not having a compiling opie to work on. fix it if you need too
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/firstuse.cpp2
-rw-r--r--core/launcher/launcher.cpp2
-rw-r--r--core/launcher/main.cpp2
-rw-r--r--core/launcher/server.cpp2
-rw-r--r--core/launcher/serverapp.cpp2
-rw-r--r--core/launcher/taskbar.cpp2
6 files changed, 6 insertions, 6 deletions
diff --git a/core/launcher/firstuse.cpp b/core/launcher/firstuse.cpp
index 3f769ae..57469cf 100644
--- a/core/launcher/firstuse.cpp
+++ b/core/launcher/firstuse.cpp
@@ -1,519 +1,519 @@
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 20
21// I need access to some things you don't normally get access to. 21// I need access to some things you don't normally get access to.
22 22
23#ifndef _MSC_VER 23#ifndef _MSC_VER
24 //### revise to allow removal of translators under MSVC 24 //### revise to allow removal of translators under MSVC
25#define private public 25#define private public
26#define protected public 26#define protected public
27#endif 27#endif
28#include "firstuse.h" 28#include "firstuse.h"
29#include "inputmethods.h" 29#include "inputmethods.h"
30#include "applauncher.h" 30#include "applauncher.h"
31#include "serverapp.h" 31#include "serverapp.h"
32#include <qtopia/custom.h> 32//#include <qtopia/custom.h>
33 33
34#include "calibrate.h" 34#include "calibrate.h"
35#include "documentlist.h" 35#include "documentlist.h"
36 36
37#include <qtopia/resource.h> 37#include <qtopia/resource.h>
38#include <qtopia/qcopenvelope_qws.h> 38#include <qtopia/qcopenvelope_qws.h>
39#include <qtopia/qpeapplication.h> 39#include <qtopia/qpeapplication.h>
40#include <qtopia/config.h> 40#include <qtopia/config.h>
41#include <qtopia/applnk.h> 41#include <qtopia/applnk.h>
42#include <qtopia/mimetype.h> 42#include <qtopia/mimetype.h>
43#include <qtopia/fontmanager.h> 43#include <qtopia/fontmanager.h>
44 44
45#include <qapplication.h> 45#include <qapplication.h>
46#include <qfile.h> 46#include <qfile.h>
47#include <qpainter.h> 47#include <qpainter.h>
48#include <qcstring.h> 48#include <qcstring.h>
49#include <qsimplerichtext.h> 49#include <qsimplerichtext.h>
50#include <qcolor.h> 50#include <qcolor.h>
51#include <qpushbutton.h> 51#include <qpushbutton.h>
52#include <qhbox.h> 52#include <qhbox.h>
53#include <qlabel.h> 53#include <qlabel.h>
54#include <qtimer.h> 54#include <qtimer.h>
55 55
56#if defined( Q_WS_QWS ) 56#if defined( Q_WS_QWS )
57#include <qwsdisplay_qws.h> 57#include <qwsdisplay_qws.h>
58#include <qgfx_qws.h> 58#include <qgfx_qws.h>
59#endif 59#endif
60 60
61#include <qwindowsystem_qws.h> 61#include <qwindowsystem_qws.h>
62 62
63#include <stdlib.h> 63#include <stdlib.h>
64#include <sys/types.h> 64#include <sys/types.h>
65#if defined(Q_OS_LINUX) || defined(_OS_LINUX_) 65#if defined(Q_OS_LINUX) || defined(_OS_LINUX_)
66#include <unistd.h> 66#include <unistd.h>
67#endif 67#endif
68 68
69 69
70struct { 70struct {
71 bool enabled; 71 bool enabled;
72 const char *app; 72 const char *app;
73 const char *start; 73 const char *start;
74 const char *stop; 74 const char *stop;
75 const char *desc; 75 const char *desc;
76} 76}
77settingsTable [] = 77settingsTable [] =
78{ 78{
79 { FALSE, "language", "raise()", "accept()", // No tr 79 { FALSE, "language", "raise()", "accept()", // No tr
80 QT_TR_NOOP("Language") }, 80 QT_TR_NOOP("Language") },
81#ifndef Q_OS_WIN32 81#ifndef Q_OS_WIN32
82 { FALSE, "systemtime", "raise()", "accept()", // No tr 82 { FALSE, "systemtime", "raise()", "accept()", // No tr
83 QT_TR_NOOP("Time and Date") }, 83 QT_TR_NOOP("Time and Date") },
84#endif 84#endif
85 { FALSE, "addressbook", "editPersonalAndClose()", "accept()", // No tr 85 { FALSE, "addressbook", "editPersonalAndClose()", "accept()", // No tr
86 QT_TR_NOOP("Personal Information") }, 86 QT_TR_NOOP("Personal Information") },
87 { FALSE, 0, 0, 0, 0 } 87 { FALSE, 0, 0, 0, 0 }
88}; 88};
89 89
90 90
91FirstUse::FirstUse(QWidget* parent, const char * name, WFlags wf) : 91FirstUse::FirstUse(QWidget* parent, const char * name, WFlags wf) :
92 QDialog( parent, name, TRUE, wf), 92 QDialog( parent, name, TRUE, wf),
93 transApp(0), transLib(0), needCalibrate(FALSE), currApp(-1), 93 transApp(0), transLib(0), needCalibrate(FALSE), currApp(-1),
94 waitForExit(-1), waitingForLaunch(FALSE), needRestart(FALSE) 94 waitForExit(-1), waitingForLaunch(FALSE), needRestart(FALSE)
95{ 95{
96 ServerApplication::allowRestart = FALSE; 96 ServerApplication::allowRestart = FALSE;
97 // we force our height beyound the maximum (which we set anyway) 97 // we force our height beyound the maximum (which we set anyway)
98 QRect desk = qApp->desktop()->geometry(); 98 QRect desk = qApp->desktop()->geometry();
99 setGeometry( 0, 0, desk.width(), desk.height() ); 99 setGeometry( 0, 0, desk.width(), desk.height() );
100 100
101 connect(qwsServer, SIGNAL(newChannel(const QString&)), 101 connect(qwsServer, SIGNAL(newChannel(const QString&)),
102 this, SLOT(newQcopChannel(const QString&))); 102 this, SLOT(newQcopChannel(const QString&)));
103 103
104 // Create a DocumentList so appLauncher has appLnkSet to search 104 // Create a DocumentList so appLauncher has appLnkSet to search
105 docList = new DocumentList( 0, FALSE ); 105 docList = new DocumentList( 0, FALSE );
106 appLauncher = new AppLauncher( this ); 106 appLauncher = new AppLauncher( this );
107 connect( appLauncher, SIGNAL(terminated(int, const QString&)), 107 connect( appLauncher, SIGNAL(terminated(int, const QString&)),
108 this, SLOT(terminated(int, const QString&)) ); 108 this, SLOT(terminated(int, const QString&)) );
109 109
110 // more hackery 110 // more hackery
111 // I will be run as either the main server or as part of the main server 111 // I will be run as either the main server or as part of the main server
112 QWSServer::setScreenSaverIntervals(0); 112 QWSServer::setScreenSaverIntervals(0);
113 loadPixmaps(); 113 loadPixmaps();
114 114
115 //check if there is a language program 115 //check if there is a language program
116#ifndef Q_OS_WIN32 116#ifndef Q_OS_WIN32
117 QString exeSuffix; 117 QString exeSuffix;
118#else 118#else
119 QString exeSuffix(".exe"); 119 QString exeSuffix(".exe");
120#endif 120#endif
121 121
122 for ( int i = 0; settingsTable[i].app; i++ ) { 122 for ( int i = 0; settingsTable[i].app; i++ ) {
123 QString file = QPEApplication::qpeDir() + "bin/"; 123 QString file = QPEApplication::qpeDir() + "bin/";
124 file += settingsTable[i].app; 124 file += settingsTable[i].app;
125 file += exeSuffix; 125 file += exeSuffix;
126 if ( QFile::exists(file) ) 126 if ( QFile::exists(file) )
127 settingsTable[i].enabled = TRUE; 127 settingsTable[i].enabled = TRUE;
128 } 128 }
129 129
130 setFocusPolicy(NoFocus); 130 setFocusPolicy(NoFocus);
131 131
132 taskBar = new QWidget(0, 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | WGroupLeader); 132 taskBar = new QWidget(0, 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | WGroupLeader);
133 133
134 inputMethods = new InputMethods(taskBar); 134 inputMethods = new InputMethods(taskBar);
135 connect(inputMethods, SIGNAL(inputToggled(bool)), 135 connect(inputMethods, SIGNAL(inputToggled(bool)),
136 this, SLOT(calcMaxWindowRect())); 136 this, SLOT(calcMaxWindowRect()));
137 137
138 back = new QPushButton(tr("<< Back"), taskBar); 138 back = new QPushButton(tr("<< Back"), taskBar);
139 back->setFocusPolicy(NoFocus); 139 back->setFocusPolicy(NoFocus);
140 connect(back, SIGNAL(clicked()), this, SLOT(previousDialog()) ); 140 connect(back, SIGNAL(clicked()), this, SLOT(previousDialog()) );
141 141
142 next = new QPushButton(tr("Next >>"), taskBar); 142 next = new QPushButton(tr("Next >>"), taskBar);
143 next->setFocusPolicy(NoFocus); 143 next->setFocusPolicy(NoFocus);
144 connect(next, SIGNAL(clicked()), this, SLOT(nextDialog()) ); 144 connect(next, SIGNAL(clicked()), this, SLOT(nextDialog()) );
145 145
146 // need to set the geom to lower corner 146 // need to set the geom to lower corner
147 QSize sz = inputMethods->sizeHint(); 147 QSize sz = inputMethods->sizeHint();
148 int buttonWidth = (width() - sz.width()) / 2; 148 int buttonWidth = (width() - sz.width()) / 2;
149 int x = 0; 149 int x = 0;
150 150
151 controlHeight = back->sizeHint().height(); 151 controlHeight = back->sizeHint().height();
152 152
153 inputMethods->setGeometry(0,0, sz.width(), controlHeight ); 153 inputMethods->setGeometry(0,0, sz.width(), controlHeight );
154 x += sz.width(); 154 x += sz.width();
155 155
156 back->setGeometry(x, 0, buttonWidth, controlHeight); 156 back->setGeometry(x, 0, buttonWidth, controlHeight);
157 x += buttonWidth; 157 x += buttonWidth;
158 next->setGeometry(x, 0, buttonWidth, controlHeight); 158 next->setGeometry(x, 0, buttonWidth, controlHeight);
159 159
160 taskBar->setGeometry( 0, height() - controlHeight, desk.width(), controlHeight); 160 taskBar->setGeometry( 0, height() - controlHeight, desk.width(), controlHeight);
161 taskBar->hide(); 161 taskBar->hide();
162 162
163#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 163#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
164 qDebug("Setting up QCop to QPE/System"); 164 qDebug("Setting up QCop to QPE/System");
165 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 165 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
166 connect(sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), 166 connect(sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
167 this, SLOT(message(const QCString &, const QByteArray &)) ); 167 this, SLOT(message(const QCString &, const QByteArray &)) );
168#endif 168#endif
169 calcMaxWindowRect(); 169 calcMaxWindowRect();
170 170
171 m_calHandler = ( QWSServer::mouseHandler() && QWSServer::mouseHandler()->inherits("QCalibratedMouseHandler") ) ? true : false; 171 m_calHandler = ( QWSServer::mouseHandler() && QWSServer::mouseHandler()->inherits("QCalibratedMouseHandler") ) ? true : false;
172 172
173 if ( m_calHandler) { 173 if ( m_calHandler) {
174 if ( !QFile::exists("/etc/pointercal") ) { 174 if ( !QFile::exists("/etc/pointercal") ) {
175 needCalibrate = TRUE; 175 needCalibrate = TRUE;
176 grabMouse(); 176 grabMouse();
177 } 177 }
178 } 178 }
179 179
180 Config config("locale"); 180 Config config("locale");
181 config.setGroup( "Language"); 181 config.setGroup( "Language");
182 lang = config.readEntry( "Language", "en"); 182 lang = config.readEntry( "Language", "en");
183 183
184 defaultFont = font(); 184 defaultFont = font();
185 185
186 //###language/font hack; should look it up somewhere 186 //###language/font hack; should look it up somewhere
187#ifdef Q_WS_QWS 187#ifdef Q_WS_QWS
188 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 188 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
189 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 189 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
190 qApp->setFont( fn, TRUE ); 190 qApp->setFont( fn, TRUE );
191 } 191 }
192#endif 192#endif
193} 193}
194 194
195FirstUse::~FirstUse() 195FirstUse::~FirstUse()
196{ 196{
197 delete appLauncher; 197 delete appLauncher;
198 delete docList; 198 delete docList;
199 delete taskBar; 199 delete taskBar;
200 ServerApplication::allowRestart = TRUE; 200 ServerApplication::allowRestart = TRUE;
201} 201}
202 202
203void FirstUse::calcMaxWindowRect() 203void FirstUse::calcMaxWindowRect()
204{ 204{
205#ifdef Q_WS_QWS 205#ifdef Q_WS_QWS
206 QRect wr; 206 QRect wr;
207 int displayWidth = qApp->desktop()->width(); 207 int displayWidth = qApp->desktop()->width();
208 QRect ir = inputMethods->inputRect(); 208 QRect ir = inputMethods->inputRect();
209 if ( ir.isValid() ) { 209 if ( ir.isValid() ) {
210 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); 210 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 );
211 } else { 211 } else {
212 wr.setCoords( 0, 0, displayWidth-1, 212 wr.setCoords( 0, 0, displayWidth-1,
213 qApp->desktop()->height() - controlHeight-1); 213 qApp->desktop()->height() - controlHeight-1);
214 } 214 }
215 215
216#if QT_VERSION < 0x030000 216#if QT_VERSION < 0x030000
217 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, 217 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,
218 QSize(qt_screen->width(),qt_screen->height())) 218 QSize(qt_screen->width(),qt_screen->height()))
219 ); 219 );
220#else 220#else
221 QWSServer::setMaxWindowRect( wr ); 221 QWSServer::setMaxWindowRect( wr );
222#endif 222#endif
223#endif 223#endif
224} 224}
225 225
226/* cancel current dialog, and bring up next */ 226/* cancel current dialog, and bring up next */
227void FirstUse::nextDialog() 227void FirstUse::nextDialog()
228{ 228{
229 int prevApp = currApp; 229 int prevApp = currApp;
230 do { 230 do {
231 currApp++; 231 currApp++;
232 qDebug( "currApp = %d", currApp ); 232 qDebug( "currApp = %d", currApp );
233 if ( settingsTable[currApp].app == 0 ) { 233 if ( settingsTable[currApp].app == 0 ) {
234 if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) { 234 if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) {
235 // The last application is still running. 235 // The last application is still running.
236 // Tell it to stop, and when its done we'll come back 236 // Tell it to stop, and when its done we'll come back
237 // to nextDialog and exit. 237 // to nextDialog and exit.
238 qDebug( "Waiting for %s to exit", settingsTable[prevApp].app ); 238 qDebug( "Waiting for %s to exit", settingsTable[prevApp].app );
239 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, 239 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app,
240 settingsTable[prevApp].stop ); 240 settingsTable[prevApp].stop );
241 currApp = prevApp; 241 currApp = prevApp;
242 } else { 242 } else {
243 qDebug( "Done!" ); 243 qDebug( "Done!" );
244 Config config( "qpe" ); 244 Config config( "qpe" );
245 config.setGroup( "Startup" ); 245 config.setGroup( "Startup" );
246 config.writeEntry( "FirstUse", FALSE ); 246 config.writeEntry( "FirstUse", FALSE );
247 QPixmap pix = Resource::loadPixmap("bigwait"); 247 QPixmap pix = Resource::loadPixmap("bigwait");
248 QLabel *lblWait = new QLabel(0, "wait hack!", // No tr 248 QLabel *lblWait = new QLabel(0, "wait hack!", // No tr
249 QWidget::WStyle_Customize | QWidget::WDestructiveClose | 249 QWidget::WStyle_Customize | QWidget::WDestructiveClose |
250 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool | 250 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool |
251 QWidget::WStyle_StaysOnTop); 251 QWidget::WStyle_StaysOnTop);
252 lblWait->setPixmap( pix ); 252 lblWait->setPixmap( pix );
253 lblWait->setAlignment( QWidget::AlignCenter ); 253 lblWait->setAlignment( QWidget::AlignCenter );
254 lblWait->setGeometry( qApp->desktop()->geometry() ); 254 lblWait->setGeometry( qApp->desktop()->geometry() );
255 lblWait->show(); 255 lblWait->show();
256 qApp->processEvents(); 256 qApp->processEvents();
257 QTimer::singleShot( 1000, lblWait, SLOT(close()) ); 257 QTimer::singleShot( 1000, lblWait, SLOT(close()) );
258 repaint(); 258 repaint();
259 close(); 259 close();
260 ServerApplication::allowRestart = TRUE; 260 ServerApplication::allowRestart = TRUE;
261 } 261 }
262 return; 262 return;
263 } 263 }
264 } while ( !settingsTable[currApp].enabled ); 264 } while ( !settingsTable[currApp].enabled );
265 265
266 if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) { 266 if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) {
267 qDebug( "Shutdown: %s", settingsTable[prevApp].app ); 267 qDebug( "Shutdown: %s", settingsTable[prevApp].app );
268 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, 268 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app,
269 settingsTable[prevApp].stop ); 269 settingsTable[prevApp].stop );
270 waitForExit = prevApp; 270 waitForExit = prevApp;
271 } else { 271 } else {
272 qDebug( "Startup: %s", settingsTable[currApp].app ); 272 qDebug( "Startup: %s", settingsTable[currApp].app );
273 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, 273 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app,
274 settingsTable[currApp].start ); 274 settingsTable[currApp].start );
275 waitingForLaunch = TRUE; 275 waitingForLaunch = TRUE;
276 } 276 }
277 277
278 updateButtons(); 278 updateButtons();
279} 279}
280 280
281/* accept current dialog and bring up previous */ 281/* accept current dialog and bring up previous */
282void FirstUse::previousDialog() 282void FirstUse::previousDialog()
283{ 283{
284 int prevApp = currApp; 284 int prevApp = currApp;
285 do { 285 do {
286 currApp--; 286 currApp--;
287 if ( currApp < 0 ) { 287 if ( currApp < 0 ) {
288 currApp = prevApp; 288 currApp = prevApp;
289 return; 289 return;
290 } 290 }
291 } while ( !settingsTable[currApp].enabled ); 291 } while ( !settingsTable[currApp].enabled );
292 292
293 if ( prevApp >= 0 ) { 293 if ( prevApp >= 0 ) {
294 qDebug( "Shutdown: %s", settingsTable[prevApp].app ); 294 qDebug( "Shutdown: %s", settingsTable[prevApp].app );
295 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, 295 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app,
296 settingsTable[prevApp].stop ); 296 settingsTable[prevApp].stop );
297/* 297/*
298 if (settingsTable[prevApp].app == QString("systemtime")) 298 if (settingsTable[prevApp].app == QString("systemtime"))
299 QCopEnvelope e("QPE/Application/citytime", "close()"); 299 QCopEnvelope e("QPE/Application/citytime", "close()");
300*/ 300*/
301 waitForExit = prevApp; 301 waitForExit = prevApp;
302 } else { 302 } else {
303 qDebug( "Startup: %s", settingsTable[currApp].app ); 303 qDebug( "Startup: %s", settingsTable[currApp].app );
304 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, 304 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app,
305 settingsTable[currApp].start ); 305 settingsTable[currApp].start );
306 waitingForLaunch = TRUE; 306 waitingForLaunch = TRUE;
307 } 307 }
308 308
309 updateButtons(); 309 updateButtons();
310} 310}
311 311
312void FirstUse::message(const QCString &msg, const QByteArray &data) 312void FirstUse::message(const QCString &msg, const QByteArray &data)
313{ 313{
314 QDataStream stream( data, IO_ReadOnly ); 314 QDataStream stream( data, IO_ReadOnly );
315 if ( msg == "timeChange(QString)" ) { 315 if ( msg == "timeChange(QString)" ) {
316 QString t; 316 QString t;
317 stream >> t; 317 stream >> t;
318 if ( t.isNull() ) 318 if ( t.isNull() )
319 unsetenv("TZ"); 319 unsetenv("TZ");
320 else 320 else
321 setenv( "TZ", t.latin1(), 1 ); 321 setenv( "TZ", t.latin1(), 1 );
322 } 322 }
323} 323}
324 324
325void FirstUse::terminated( int, const QString &app ) 325void FirstUse::terminated( int, const QString &app )
326{ 326{
327 qDebug( "--- terminated: %s", app.latin1() ); 327 qDebug( "--- terminated: %s", app.latin1() );
328 if ( waitForExit != -1 && settingsTable[waitForExit].app == app ) { 328 if ( waitForExit != -1 && settingsTable[waitForExit].app == app ) {
329 qDebug( "Startup: %s", settingsTable[currApp].app ); 329 qDebug( "Startup: %s", settingsTable[currApp].app );
330 if ( settingsTable[waitForExit].app == "language" ) { // No tr 330 if ( settingsTable[waitForExit].app == "language" ) { // No tr
331 Config config("locale"); 331 Config config("locale");
332 config.setGroup( "Language"); 332 config.setGroup( "Language");
333 QString l = config.readEntry( "Language", "en"); 333 QString l = config.readEntry( "Language", "en");
334 if ( l != lang ) { 334 if ( l != lang ) {
335 reloadLanguages(); 335 reloadLanguages();
336 needRestart = TRUE; 336 needRestart = TRUE;
337 lang = l; 337 lang = l;
338 } 338 }
339 } 339 }
340 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, 340 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app,
341 settingsTable[currApp].start ); 341 settingsTable[currApp].start );
342 waitingForLaunch = TRUE; 342 waitingForLaunch = TRUE;
343 updateButtons(); 343 updateButtons();
344 repaint(); 344 repaint();
345 waitForExit = -1; 345 waitForExit = -1;
346 } else if ( settingsTable[currApp].app == app ) { 346 } else if ( settingsTable[currApp].app == app ) {
347 nextDialog(); 347 nextDialog();
348 } else { 348 } else {
349 back->setEnabled(TRUE); 349 back->setEnabled(TRUE);
350 next->setEnabled(TRUE); 350 next->setEnabled(TRUE);
351 } 351 }
352} 352}
353 353
354void FirstUse::newQcopChannel(const QString& channelName) 354void FirstUse::newQcopChannel(const QString& channelName)
355{ 355{
356 qDebug("channel %s added", channelName.data() ); 356 qDebug("channel %s added", channelName.data() );
357 QString prefix("QPE/Application/"); 357 QString prefix("QPE/Application/");
358 if (channelName.startsWith(prefix)) { 358 if (channelName.startsWith(prefix)) {
359 QString appName = channelName.mid(prefix.length()); 359 QString appName = channelName.mid(prefix.length());
360 if ( currApp >= 0 && appName == settingsTable[currApp].app ) { 360 if ( currApp >= 0 && appName == settingsTable[currApp].app ) {
361 qDebug( "Application: %s started", settingsTable[currApp].app ); 361 qDebug( "Application: %s started", settingsTable[currApp].app );
362 waitingForLaunch = FALSE; 362 waitingForLaunch = FALSE;
363 updateButtons(); 363 updateButtons();
364 repaint(); 364 repaint();
365 } else if (appName != "quicklauncher") { 365 } else if (appName != "quicklauncher") {
366 back->setEnabled(FALSE); 366 back->setEnabled(FALSE);
367 next->setEnabled(FALSE); 367 next->setEnabled(FALSE);
368 } 368 }
369 } 369 }
370} 370}
371 371
372void FirstUse::reloadLanguages() 372void FirstUse::reloadLanguages()
373{ 373{
374 // read language from config file. Waiting on QCop takes too long. 374 // read language from config file. Waiting on QCop takes too long.
375 Config config("locale"); 375 Config config("locale");
376 config.setGroup( "Language"); 376 config.setGroup( "Language");
377 QString l = config.readEntry( "Language", "en"); 377 QString l = config.readEntry( "Language", "en");
378 QString cl = getenv("LANG"); 378 QString cl = getenv("LANG");
379 qWarning("language message - " + l); 379 qWarning("language message - " + l);
380 // setting anyway... 380 // setting anyway...
381 if (l.isNull() ) 381 if (l.isNull() )
382 unsetenv( "LANG" ); 382 unsetenv( "LANG" );
383 else { 383 else {
384 qWarning("and its not null"); 384 qWarning("and its not null");
385 setenv( "LANG", l.latin1(), 1 ); 385 setenv( "LANG", l.latin1(), 1 );
386 } 386 }
387#ifndef QT_NO_TRANSLATION 387#ifndef QT_NO_TRANSLATION
388 // clear old translators 388 // clear old translators
389#ifndef _MSC_VER 389#ifndef _MSC_VER
390 //### revise to allow removal of translators under MSVC 390 //### revise to allow removal of translators under MSVC
391 if(qApp->translators) { 391 if(qApp->translators) {
392 qApp->translators->setAutoDelete(TRUE); 392 qApp->translators->setAutoDelete(TRUE);
393 delete (qApp->translators); 393 delete (qApp->translators);
394 qApp->translators = 0; 394 qApp->translators = 0;
395 } 395 }
396#endif 396#endif
397 397
398 // load translation tables 398 // load translation tables
399 transApp = new QTranslator(qApp); 399 transApp = new QTranslator(qApp);
400 QString tfn = QPEApplication::qpeDir() + "i18n/"+l+"/qpe.qm"; 400 QString tfn = QPEApplication::qpeDir() + "i18n/"+l+"/qpe.qm";
401 qWarning("loading " + tfn); 401 qWarning("loading " + tfn);
402 if ( transApp->load(tfn) ) { 402 if ( transApp->load(tfn) ) {
403 qWarning("installing translator"); 403 qWarning("installing translator");
404 qApp->installTranslator( transApp ); 404 qApp->installTranslator( transApp );
405 } else { 405 } else {
406 delete transApp; 406 delete transApp;
407 transApp = 0; 407 transApp = 0;
408 } 408 }
409 409
410 transLib = new QTranslator(qApp); 410 transLib = new QTranslator(qApp);
411 tfn = QPEApplication::qpeDir() + "i18n/"+l+"/libqpe.qm"; 411 tfn = QPEApplication::qpeDir() + "i18n/"+l+"/libqpe.qm";
412 qWarning("loading " + tfn); 412 qWarning("loading " + tfn);
413 if ( transLib->load(tfn) ) { 413 if ( transLib->load(tfn) ) {
414 qWarning("installing translator library"); 414 qWarning("installing translator library");
415 qApp->installTranslator( transLib ); 415 qApp->installTranslator( transLib );
416 } else { 416 } else {
417 delete transLib; 417 delete transLib;
418 transLib = 0; 418 transLib = 0;
419 } 419 }
420 loadPixmaps(); 420 loadPixmaps();
421 //###language/font hack; should look it up somewhere 421 //###language/font hack; should look it up somewhere
422#ifdef Q_WS_QWS 422#ifdef Q_WS_QWS
423 if ( l == "ja" || l == "zh_CN" || l == "zh_TW" || l == "ko" ) { 423 if ( l == "ja" || l == "zh_CN" || l == "zh_TW" || l == "ko" ) {
424 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 424 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
425 qApp->setFont( fn, TRUE ); 425 qApp->setFont( fn, TRUE );
426 } else { 426 } else {
427 qApp->setFont( defaultFont, TRUE ); 427 qApp->setFont( defaultFont, TRUE );
428 } 428 }
429#endif 429#endif
430#endif 430#endif
431} 431}
432 432
433void FirstUse::paintEvent( QPaintEvent * ) 433void FirstUse::paintEvent( QPaintEvent * )
434{ 434{
435 QPainter p( this ); 435 QPainter p( this );
436 436
437 p.drawPixmap(0,0, splash); 437 p.drawPixmap(0,0, splash);
438 438
439 QFont f = p.font(); 439 QFont f = p.font();
440 f.setPointSize(15); 440 f.setPointSize(15);
441 f.setItalic(FALSE); 441 f.setItalic(FALSE);
442 f.setBold(FALSE); 442 f.setBold(FALSE);
443 p.setFont(f); 443 p.setFont(f);
444 444
445 if ( currApp < 0 ) { 445 if ( currApp < 0 ) {
446 drawText(p, tr( "Tap anywhere on the screen to continue." )); 446 drawText(p, tr( "Tap anywhere on the screen to continue." ));
447 } else if ( settingsTable[currApp].app ) { 447 } else if ( settingsTable[currApp].app ) {
448 if ( waitingForLaunch ) 448 if ( waitingForLaunch )
449 drawText(p, tr("Please wait, loading %1 settings.").arg(tr(settingsTable[currApp].desc)) ); 449 drawText(p, tr("Please wait, loading %1 settings.").arg(tr(settingsTable[currApp].desc)) );
450 } else { 450 } else {
451 drawText(p, tr("Please wait...")); 451 drawText(p, tr("Please wait..."));
452 } 452 }
453} 453}
454 454
455void FirstUse::loadPixmaps() 455void FirstUse::loadPixmaps()
456{ 456{
457 /* create background, tr so can change image with language. 457 /* create background, tr so can change image with language.
458 images will likely contain text. */ 458 images will likely contain text. */
459 splash.convertFromImage( Resource::loadImage(tr("FirstUseBackground")) 459 splash.convertFromImage( Resource::loadImage(tr("FirstUseBackground"))
460 .smoothScale( width(), height() ) ); 460 .smoothScale( width(), height() ) );
461 461
462 setBackgroundPixmap(splash); 462 setBackgroundPixmap(splash);
463} 463}
464 464
465void FirstUse::drawText(QPainter &p, const QString &text) 465void FirstUse::drawText(QPainter &p, const QString &text)
466{ 466{
467 QString altered = "<CENTER>" + text + "</CENTER>"; 467 QString altered = "<CENTER>" + text + "</CENTER>";
468 468
469 QSimpleRichText rt(altered, p.font()); 469 QSimpleRichText rt(altered, p.font());
470 rt.setWidth(width() - 20); 470 rt.setWidth(width() - 20);
471 471
472 int h = (height() * 3) / 10; // start at 30% 472 int h = (height() * 3) / 10; // start at 30%
473 if (rt.height() < height() / 2) 473 if (rt.height() < height() / 2)
474 h += ((height() / 2) - rt.height()) / 2; 474 h += ((height() / 2) - rt.height()) / 2;
475 rt.draw(&p, 10, h, QRegion(0,0, width()-20, height()), palette()); 475 rt.draw(&p, 10, h, QRegion(0,0, width()-20, height()), palette());
476} 476}
477 477
478void FirstUse::updateButtons() 478void FirstUse::updateButtons()
479{ 479{
480 if ( currApp >= 0 ) { 480 if ( currApp >= 0 ) {
481 taskBar->show(); 481 taskBar->show();
482 } 482 }
483 483
484 int i = currApp-1; 484 int i = currApp-1;
485 while ( i >= 0 && !settingsTable[i].enabled ) 485 while ( i >= 0 && !settingsTable[i].enabled )
486 i--; 486 i--;
487 back->setText(tr("<< Back")); 487 back->setText(tr("<< Back"));
488 back->setEnabled( i >= 0 && !waitingForLaunch ); 488 back->setEnabled( i >= 0 && !waitingForLaunch );
489 489
490 i = currApp+1; 490 i = currApp+1;
491 while ( settingsTable[i].app && !settingsTable[i].enabled ) 491 while ( settingsTable[i].app && !settingsTable[i].enabled )
492 i++; 492 i++;
493 if ( !settingsTable[i].app ) 493 if ( !settingsTable[i].app )
494 next->setText(tr("Finish")); 494 next->setText(tr("Finish"));
495 else 495 else
496 next->setText(tr("Next >>")); 496 next->setText(tr("Next >>"));
497 497
498 next->setEnabled( !waitingForLaunch ); 498 next->setEnabled( !waitingForLaunch );
499} 499}
500 500
501void FirstUse::keyPressEvent( QKeyEvent *e ) 501void FirstUse::keyPressEvent( QKeyEvent *e )
502{ 502{
503 // Allow cancelling at first dialog, in case display is broken. 503 // Allow cancelling at first dialog, in case display is broken.
504 if ( e->key() == Key_Escape && currApp < 0 ) 504 if ( e->key() == Key_Escape && currApp < 0 )
505 QDialog::keyPressEvent(e); 505 QDialog::keyPressEvent(e);
506} 506}
507 507
508void FirstUse::mouseReleaseEvent( QMouseEvent * ) 508void FirstUse::mouseReleaseEvent( QMouseEvent * )
509{ 509{
510 if ( currApp < 0 ) { 510 if ( currApp < 0 ) {
511 if ( m_calHandler && needCalibrate ) { 511 if ( m_calHandler && needCalibrate ) {
512 releaseMouse(); 512 releaseMouse();
513 Calibrate *cal = new Calibrate; 513 Calibrate *cal = new Calibrate;
514 cal->exec(); 514 cal->exec();
515 delete cal; 515 delete cal;
516 } 516 }
517 nextDialog(); 517 nextDialog();
518 } 518 }
519} 519}
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index 35d404a..d697c43 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -1,757 +1,757 @@
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 20
21#include <qtopia/global.h> 21#include <qtopia/global.h>
22#ifdef Q_WS_QWS 22#ifdef Q_WS_QWS
23#include <qtopia/qcopenvelope_qws.h> 23#include <qtopia/qcopenvelope_qws.h>
24#endif 24#endif
25#include <qtopia/resource.h> 25#include <qtopia/resource.h>
26#include <qtopia/applnk.h> 26#include <qtopia/applnk.h>
27#include <qtopia/config.h> 27#include <qtopia/config.h>
28#include <qtopia/global.h> 28#include <qtopia/global.h>
29#include <qtopia/qpeapplication.h> 29#include <qtopia/qpeapplication.h>
30#include <qtopia/mimetype.h> 30#include <qtopia/mimetype.h>
31#include <qtopia/private/categories.h> 31#include <qtopia/private/categories.h>
32#include <qtopia/custom.h> 32//#include <qtopia/custom.h>
33 33
34#include <qdir.h> 34#include <qdir.h>
35#ifdef Q_WS_QWS 35#ifdef Q_WS_QWS
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37#endif 37#endif
38#include <qtimer.h> 38#include <qtimer.h>
39#include <qcombobox.h> 39#include <qcombobox.h>
40#include <qvbox.h> 40#include <qvbox.h>
41#include <qlayout.h> 41#include <qlayout.h>
42#include <qstyle.h> 42#include <qstyle.h>
43#include <qpushbutton.h> 43#include <qpushbutton.h>
44#include <qtabbar.h> 44#include <qtabbar.h>
45#include <qwidgetstack.h> 45#include <qwidgetstack.h>
46#include <qlayout.h> 46#include <qlayout.h>
47#include <qregexp.h> 47#include <qregexp.h>
48#include <qmessagebox.h> 48#include <qmessagebox.h>
49#include <qframe.h> 49#include <qframe.h>
50#include <qpainter.h> 50#include <qpainter.h>
51#include <qlabel.h> 51#include <qlabel.h>
52#include <qtextstream.h> 52#include <qtextstream.h>
53#include <qpopupmenu.h> 53#include <qpopupmenu.h>
54 54
55#include "startmenu.h" 55#include "startmenu.h"
56#include "taskbar.h" 56#include "taskbar.h"
57 57
58#include "serverinterface.h" 58#include "serverinterface.h"
59#include "launcherview.h" 59#include "launcherview.h"
60#include "launcher.h" 60#include "launcher.h"
61#include "server.h" 61#include "server.h"
62 62
63#define QTOPIA_INTERNAL_FSLP 63#define QTOPIA_INTERNAL_FSLP
64#include <qtopia/lnkproperties.h> 64#include <qtopia/lnkproperties.h>
65#include <stdlib.h> 65#include <stdlib.h>
66#include <assert.h> 66#include <assert.h>
67 67
68#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 68#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
69#include <unistd.h> 69#include <unistd.h>
70#include <stdio.h> 70#include <stdio.h>
71#include <sys/vfs.h> 71#include <sys/vfs.h>
72#include <mntent.h> 72#include <mntent.h>
73#endif 73#endif
74 74
75#ifdef Q_WS_QWS 75#ifdef Q_WS_QWS
76#include <qkeyboard_qws.h> 76#include <qkeyboard_qws.h>
77#include <qpe/lnkproperties.h> 77#include <qpe/lnkproperties.h>
78#endif 78#endif
79 79
80 80
81static bool isVisibleWindow( int ); 81static bool isVisibleWindow( int );
82//=========================================================================== 82//===========================================================================
83 83
84LauncherTabWidget::LauncherTabWidget( Launcher* parent ) : 84LauncherTabWidget::LauncherTabWidget( Launcher* parent ) :
85 QVBox( parent ) 85 QVBox( parent )
86{ 86{
87 docLoadingWidgetEnabled = false; 87 docLoadingWidgetEnabled = false;
88 docLoadingWidget = 0; 88 docLoadingWidget = 0;
89 docLoadingWidgetProgress = 0; 89 docLoadingWidgetProgress = 0;
90 launcher = parent; 90 launcher = parent;
91 categoryBar = new LauncherTabBar( this ); 91 categoryBar = new LauncherTabBar( this );
92 QPalette pal = categoryBar->palette(); 92 QPalette pal = categoryBar->palette();
93 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 93 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
94 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 94 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
95 categoryBar->setPalette( pal ); 95 categoryBar->setPalette( pal );
96 stack = new QWidgetStack(this); 96 stack = new QWidgetStack(this);
97 connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) ); 97 connect( categoryBar, SIGNAL(selected(int)), this, SLOT(raiseTabWidget()) );
98 categoryBar->show(); 98 categoryBar->show();
99 stack->show(); 99 stack->show();
100 100
101#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 101#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
102 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); 102 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this );
103 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 103 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
104 this, SLOT(launcherMessage(const QCString&, const QByteArray&)) ); 104 this, SLOT(launcherMessage(const QCString&, const QByteArray&)) );
105 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), 105 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
106 this, SLOT(appMessage(const QCString&, const QByteArray&))); 106 this, SLOT(appMessage(const QCString&, const QByteArray&)));
107#endif 107#endif
108 108
109 createDocLoadingWidget(); 109 createDocLoadingWidget();
110} 110}
111 111
112void LauncherTabWidget::createDocLoadingWidget() 112void LauncherTabWidget::createDocLoadingWidget()
113{ 113{
114 // Construct the 'doc loading widget' shown when finding documents 114 // Construct the 'doc loading widget' shown when finding documents
115 115
116 // ### LauncherView class needs changing to be more generic so 116 // ### LauncherView class needs changing to be more generic so
117 // this widget can change its background similar to the iconviews 117 // this widget can change its background similar to the iconviews
118 // so the background for this matches 118 // so the background for this matches
119 docLoadingWidget = new LauncherView( stack ); 119 docLoadingWidget = new LauncherView( stack );
120 docLoadingWidget->hideIcons(); 120 docLoadingWidget->hideIcons();
121 QVBox *docLoadingVBox = new QVBox( docLoadingWidget ); 121 QVBox *docLoadingVBox = new QVBox( docLoadingWidget );
122 122
123 docLoadingVBox->setSpacing( 20 ); 123 docLoadingVBox->setSpacing( 20 );
124 docLoadingVBox->setMargin( 10 ); 124 docLoadingVBox->setMargin( 10 );
125 125
126 QWidget *space1 = new QWidget( docLoadingVBox ); 126 QWidget *space1 = new QWidget( docLoadingVBox );
127 docLoadingVBox->setStretchFactor( space1, 1 ); 127 docLoadingVBox->setStretchFactor( space1, 1 );
128 128
129 QLabel *waitPixmap = new QLabel( docLoadingVBox ); 129 QLabel *waitPixmap = new QLabel( docLoadingVBox );
130 waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) ); 130 waitPixmap->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, waitPixmap->sizePolicy().hasHeightForWidth() ) );
131 waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) ); 131 waitPixmap->setPixmap( Resource::loadPixmap( "bigwait" ) );
132 waitPixmap->setAlignment( int( QLabel::AlignCenter ) ); 132 waitPixmap->setAlignment( int( QLabel::AlignCenter ) );
133 133
134 QLabel *textLabel = new QLabel( docLoadingVBox ); 134 QLabel *textLabel = new QLabel( docLoadingVBox );
135 textLabel->setText( tr( "<b>Finding Documents...</b>" ) ); 135 textLabel->setText( tr( "<b>Finding Documents...</b>" ) );
136 textLabel->setAlignment( int( QLabel::AlignCenter ) ); 136 textLabel->setAlignment( int( QLabel::AlignCenter ) );
137 137
138 docLoadingWidgetProgress = new QProgressBar( docLoadingVBox ); 138 docLoadingWidgetProgress = new QProgressBar( docLoadingVBox );
139 docLoadingWidgetProgress->setProgress( 0 ); 139 docLoadingWidgetProgress->setProgress( 0 );
140 docLoadingWidgetProgress->setCenterIndicator( TRUE ); 140 docLoadingWidgetProgress->setCenterIndicator( TRUE );
141 docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker 141 docLoadingWidgetProgress->setBackgroundMode( NoBackground ); // No flicker
142 setProgressStyle(); 142 setProgressStyle();
143 143
144 QWidget *space2 = new QWidget( docLoadingVBox ); 144 QWidget *space2 = new QWidget( docLoadingVBox );
145 docLoadingVBox->setStretchFactor( space2, 1 ); 145 docLoadingVBox->setStretchFactor( space2, 1 );
146 146
147 Config cfg("Launcher"); 147 Config cfg("Launcher");
148 cfg.setGroup( "Tab Documents" ); // No tr 148 cfg.setGroup( "Tab Documents" ); // No tr
149 setTabViewAppearance( docLoadingWidget, cfg ); 149 setTabViewAppearance( docLoadingWidget, cfg );
150 150
151 stack->addWidget( docLoadingWidget, 0 ); 151 stack->addWidget( docLoadingWidget, 0 );
152} 152}
153 153
154void LauncherTabWidget::initLayout() 154void LauncherTabWidget::initLayout()
155{ 155{
156 layout()->activate(); 156 layout()->activate();
157 docView()->setFocus(); 157 docView()->setFocus();
158 categoryBar->showTab("Documents"); 158 categoryBar->showTab("Documents");
159} 159}
160 160
161void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&) 161void LauncherTabWidget::appMessage(const QCString& message, const QByteArray&)
162{ 162{
163 if ( message == "nextView()" ) 163 if ( message == "nextView()" )
164 categoryBar->nextTab(); 164 categoryBar->nextTab();
165} 165}
166 166
167void LauncherTabWidget::raiseTabWidget() 167void LauncherTabWidget::raiseTabWidget()
168{ 168{
169 if ( categoryBar->currentView() == docView() 169 if ( categoryBar->currentView() == docView()
170 && docLoadingWidgetEnabled ) { 170 && docLoadingWidgetEnabled ) {
171 stack->raiseWidget( docLoadingWidget ); 171 stack->raiseWidget( docLoadingWidget );
172 docLoadingWidget->updateGeometry(); 172 docLoadingWidget->updateGeometry();
173 } else { 173 } else {
174 stack->raiseWidget( categoryBar->currentView() ); 174 stack->raiseWidget( categoryBar->currentView() );
175 } 175 }
176} 176}
177 177
178void LauncherTabWidget::tabProperties() 178void LauncherTabWidget::tabProperties()
179{ 179{
180 LauncherView *view = categoryBar->currentView(); 180 LauncherView *view = categoryBar->currentView();
181 QPopupMenu *m = new QPopupMenu( this ); 181 QPopupMenu *m = new QPopupMenu( this );
182 m->insertItem( tr("Icon View"), LauncherView::Icon ); 182 m->insertItem( tr("Icon View"), LauncherView::Icon );
183 m->insertItem( tr("List View"), LauncherView::List ); 183 m->insertItem( tr("List View"), LauncherView::List );
184 m->setItemChecked( (int)view->viewMode(), TRUE ); 184 m->setItemChecked( (int)view->viewMode(), TRUE );
185 int rv = m->exec( QCursor::pos() ); 185 int rv = m->exec( QCursor::pos() );
186 if ( rv >= 0 && rv != view->viewMode() ) { 186 if ( rv >= 0 && rv != view->viewMode() ) {
187 view->setViewMode( (LauncherView::ViewMode)rv ); 187 view->setViewMode( (LauncherView::ViewMode)rv );
188 } 188 }
189 189
190 delete m; 190 delete m;
191} 191}
192 192
193void LauncherTabWidget::deleteView( const QString& id ) 193void LauncherTabWidget::deleteView( const QString& id )
194{ 194{
195 LauncherTab *t = categoryBar->launcherTab(id); 195 LauncherTab *t = categoryBar->launcherTab(id);
196 if ( t ) { 196 if ( t ) {
197 stack->removeWidget( t->view ); 197 stack->removeWidget( t->view );
198 delete t->view; 198 delete t->view;
199 categoryBar->removeTab( t ); 199 categoryBar->removeTab( t );
200 } 200 }
201} 201}
202 202
203LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) 203LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label )
204{ 204{
205 LauncherView* view = new LauncherView( stack ); 205 LauncherView* view = new LauncherView( stack );
206 connect( view, SIGNAL(clicked(const AppLnk*)), 206 connect( view, SIGNAL(clicked(const AppLnk*)),
207 this, SIGNAL(clicked(const AppLnk*))); 207 this, SIGNAL(clicked(const AppLnk*)));
208 connect( view, SIGNAL(rightPressed(AppLnk*)), 208 connect( view, SIGNAL(rightPressed(AppLnk*)),
209 this, SIGNAL(rightPressed(AppLnk*))); 209 this, SIGNAL(rightPressed(AppLnk*)));
210 210
211 int n = categoryBar->count(); 211 int n = categoryBar->count();
212 stack->addWidget( view, n ); 212 stack->addWidget( view, n );
213 213
214 LauncherTab *tab = new LauncherTab( id, view, pm, label ); 214 LauncherTab *tab = new LauncherTab( id, view, pm, label );
215 categoryBar->insertTab( tab, n-1 ); 215 categoryBar->insertTab( tab, n-1 );
216 216
217 if ( id == "Documents" ) 217 if ( id == "Documents" )
218 docview = view; 218 docview = view;
219 219
220 qDebug("inserting %s at %d", id.latin1(), n-1 ); 220 qDebug("inserting %s at %d", id.latin1(), n-1 );
221 221
222 Config cfg("Launcher"); 222 Config cfg("Launcher");
223 setTabAppearance( tab, cfg ); 223 setTabAppearance( tab, cfg );
224 224
225 cfg.setGroup( "GUI" ); 225 cfg.setGroup( "GUI" );
226 view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) ); 226 view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) );
227 227
228 return view; 228 return view;
229} 229}
230 230
231LauncherView *LauncherTabWidget::view( const QString &id ) 231LauncherView *LauncherTabWidget::view( const QString &id )
232{ 232{
233 LauncherTab *t = categoryBar->launcherTab(id); 233 LauncherTab *t = categoryBar->launcherTab(id);
234 if ( !t ) 234 if ( !t )
235 return 0; 235 return 0;
236 return t->view; 236 return t->view;
237} 237}
238 238
239LauncherView *LauncherTabWidget::docView() 239LauncherView *LauncherTabWidget::docView()
240{ 240{
241 return docview; 241 return docview;
242} 242}
243 243
244void LauncherTabWidget::setLoadingWidgetEnabled( bool v ) 244void LauncherTabWidget::setLoadingWidgetEnabled( bool v )
245{ 245{
246 if ( v != docLoadingWidgetEnabled && docLoadingWidget ) { 246 if ( v != docLoadingWidgetEnabled && docLoadingWidget ) {
247 docLoadingWidgetEnabled = v; 247 docLoadingWidgetEnabled = v;
248 raiseTabWidget(); 248 raiseTabWidget();
249 } 249 }
250} 250}
251 251
252void LauncherTabWidget::setLoadingProgress( int percent ) 252void LauncherTabWidget::setLoadingProgress( int percent )
253{ 253{
254 docLoadingWidgetProgress->setProgress( (percent / 4) * 4 ); 254 docLoadingWidgetProgress->setProgress( (percent / 4) * 4 );
255} 255}
256 256
257// ### this function could more to LauncherView 257// ### this function could more to LauncherView
258void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg ) 258void LauncherTabWidget::setTabViewAppearance( LauncherView *v, Config &cfg )
259{ 259{
260 // View 260 // View
261 QString view = cfg.readEntry( "View", "Icon" ); 261 QString view = cfg.readEntry( "View", "Icon" );
262 if ( view == "List" ) // No tr 262 if ( view == "List" ) // No tr
263 v->setViewMode( LauncherView::List ); 263 v->setViewMode( LauncherView::List );
264 QString bgType = cfg.readEntry( "BackgroundType", "Image" ); 264 QString bgType = cfg.readEntry( "BackgroundType", "Image" );
265 if ( bgType == "Image" ) { // No tr 265 if ( bgType == "Image" ) { // No tr
266 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); 266 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" );
267 v->setBackgroundType( LauncherView::Image, pm ); 267 v->setBackgroundType( LauncherView::Image, pm );
268 } else if ( bgType == "SolidColor" ) { 268 } else if ( bgType == "SolidColor" ) {
269 QString c = cfg.readEntry( "BackgroundColor" ); 269 QString c = cfg.readEntry( "BackgroundColor" );
270 v->setBackgroundType( LauncherView::SolidColor, c ); 270 v->setBackgroundType( LauncherView::SolidColor, c );
271 } else { 271 } else {
272 v->setBackgroundType( LauncherView::Ruled, QString::null ); 272 v->setBackgroundType( LauncherView::Ruled, QString::null );
273 } 273 }
274 QString textCol = cfg.readEntry( "TextColor" ); 274 QString textCol = cfg.readEntry( "TextColor" );
275 if ( textCol.isEmpty() ) 275 if ( textCol.isEmpty() )
276 v->setTextColor( QColor() ); 276 v->setTextColor( QColor() );
277 else 277 else
278 v->setTextColor( QColor(textCol) ); 278 v->setTextColor( QColor(textCol) );
279// bool customFont = cfg.readBoolEntry( "CustomFont", FALSE ); 279// bool customFont = cfg.readBoolEntry( "CustomFont", FALSE );
280 280
281 281
282 QStringList font = cfg.readListEntry( "Font", ',' ); 282 QStringList font = cfg.readListEntry( "Font", ',' );
283 if ( font.count() == 4 ) 283 if ( font.count() == 4 )
284 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); 284 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) );
285 285
286 // ### FIXME TabColor TabTextColor 286 // ### FIXME TabColor TabTextColor
287 287
288} 288}
289 289
290// ### Could move to LauncherTab 290// ### Could move to LauncherTab
291void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg ) 291void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg )
292{ 292{
293 cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr 293 cfg.setGroup( QString( "Tab %1" ).arg(tab->type) ); // No tr
294 294
295 setTabViewAppearance( tab->view, cfg ); 295 setTabViewAppearance( tab->view, cfg );
296 296
297 // Tabs 297 // Tabs
298 QString tabCol = cfg.readEntry( "TabColor" ); 298 QString tabCol = cfg.readEntry( "TabColor" );
299 if ( tabCol.isEmpty() ) 299 if ( tabCol.isEmpty() )
300 tab->bgColor = QColor(); 300 tab->bgColor = QColor();
301 else 301 else
302 tab->bgColor = QColor(tabCol); 302 tab->bgColor = QColor(tabCol);
303 QString tabTextCol = cfg.readEntry( "TabTextColor" ); 303 QString tabTextCol = cfg.readEntry( "TabTextColor" );
304 if ( tabTextCol.isEmpty() ) 304 if ( tabTextCol.isEmpty() )
305 tab->fgColor = QColor(); 305 tab->fgColor = QColor();
306 else 306 else
307 tab->fgColor = QColor(tabTextCol); 307 tab->fgColor = QColor(tabTextCol);
308} 308}
309 309
310void LauncherTabWidget::paletteChange( const QPalette &p ) 310void LauncherTabWidget::paletteChange( const QPalette &p )
311{ 311{
312 QVBox::paletteChange( p ); 312 QVBox::paletteChange( p );
313 QPalette pal = palette(); 313 QPalette pal = palette();
314 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 314 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
315 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 315 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
316 categoryBar->setPalette( pal ); 316 categoryBar->setPalette( pal );
317 categoryBar->update(); 317 categoryBar->update();
318} 318}
319 319
320void LauncherTabWidget::styleChange( QStyle & ) 320void LauncherTabWidget::styleChange( QStyle & )
321{ 321{
322 QTimer::singleShot( 0, this, SLOT(setProgressStyle()) ); 322 QTimer::singleShot( 0, this, SLOT(setProgressStyle()) );
323} 323}
324 324
325void LauncherTabWidget::setProgressStyle() 325void LauncherTabWidget::setProgressStyle()
326{ 326{
327 if (docLoadingWidgetProgress) { 327 if (docLoadingWidgetProgress) {
328 docLoadingWidgetProgress->setFrameShape( QProgressBar::Box ); 328 docLoadingWidgetProgress->setFrameShape( QProgressBar::Box );
329 docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain ); 329 docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain );
330 docLoadingWidgetProgress->setMargin( 1 ); 330 docLoadingWidgetProgress->setMargin( 1 );
331 docLoadingWidgetProgress->setLineWidth( 1 ); 331 docLoadingWidgetProgress->setLineWidth( 1 );
332 } 332 }
333} 333}
334 334
335void LauncherTabWidget::setBusy(bool on) 335void LauncherTabWidget::setBusy(bool on)
336{ 336{
337 if ( on ) 337 if ( on )
338 currentView()->setBusy(TRUE); 338 currentView()->setBusy(TRUE);
339 else { 339 else {
340 for ( int i = 0; i < categoryBar->count(); i++ ) { 340 for ( int i = 0; i < categoryBar->count(); i++ ) {
341 LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; 341 LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view;
342 view->setBusy( FALSE ); 342 view->setBusy( FALSE );
343 } 343 }
344 } 344 }
345} 345}
346 346
347void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { 347void LauncherTabWidget::setBusyIndicatorType( const QString& str ) {
348 for (int i = 0; i < categoryBar->count(); i++ ) { 348 for (int i = 0; i < categoryBar->count(); i++ ) {
349 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; 349 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view;
350 view->setBusyIndicatorType( str ); 350 view->setBusyIndicatorType( str );
351 } 351 }
352} 352}
353 353
354LauncherView *LauncherTabWidget::currentView(void) 354LauncherView *LauncherTabWidget::currentView(void)
355{ 355{
356 return (LauncherView*)stack->visibleWidget(); 356 return (LauncherView*)stack->visibleWidget();
357} 357}
358 358
359 359
360 360
361void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) 361void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data)
362{ 362{
363 QDataStream stream( data, IO_ReadOnly ); 363 QDataStream stream( data, IO_ReadOnly );
364 if ( msg == "setTabView(QString,int)" ) { 364 if ( msg == "setTabView(QString,int)" ) {
365 QString id; 365 QString id;
366 stream >> id; 366 stream >> id;
367 int mode; 367 int mode;
368 stream >> mode; 368 stream >> mode;
369 if ( view(id) ) 369 if ( view(id) )
370 view(id)->setViewMode( (LauncherView::ViewMode)mode ); 370 view(id)->setViewMode( (LauncherView::ViewMode)mode );
371 } else if ( msg == "setTabBackground(QString,int,QString)" ) { 371 } else if ( msg == "setTabBackground(QString,int,QString)" ) {
372 QString id; 372 QString id;
373 stream >> id; 373 stream >> id;
374 int mode; 374 int mode;
375 stream >> mode; 375 stream >> mode;
376 QString pixmapOrColor; 376 QString pixmapOrColor;
377 stream >> pixmapOrColor; 377 stream >> pixmapOrColor;
378 if ( view(id) ) 378 if ( view(id) )
379 view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 379 view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
380 if ( id == "Documents" ) 380 if ( id == "Documents" )
381 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 381 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
382 } else if ( msg == "setTextColor(QString,QString)" ) { 382 } else if ( msg == "setTextColor(QString,QString)" ) {
383 QString id; 383 QString id;
384 stream >> id; 384 stream >> id;
385 QString color; 385 QString color;
386 stream >> color; 386 stream >> color;
387 if ( view(id) ) 387 if ( view(id) )
388 view(id)->setTextColor( QColor(color) ); 388 view(id)->setTextColor( QColor(color) );
389 if ( id == "Documents" ) 389 if ( id == "Documents" )
390 docLoadingWidget->setTextColor( QColor(color) ); 390 docLoadingWidget->setTextColor( QColor(color) );
391 } else if ( msg == "setFont(QString,QString,int,int,int)" ) { 391 } else if ( msg == "setFont(QString,QString,int,int,int)" ) {
392 QString id; 392 QString id;
393 stream >> id; 393 stream >> id;
394 QString fam; 394 QString fam;
395 stream >> fam; 395 stream >> fam;
396 int size; 396 int size;
397 stream >> size; 397 stream >> size;
398 int weight; 398 int weight;
399 stream >> weight; 399 stream >> weight;
400 int italic; 400 int italic;
401 stream >> italic; 401 stream >> italic;
402 if ( view(id) ) { 402 if ( view(id) ) {
403 if ( !fam.isEmpty() ) { 403 if ( !fam.isEmpty() ) {
404 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); 404 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) );
405 qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); 405 qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic );
406 } else { 406 } else {
407 view(id)->clearViewFont(); 407 view(id)->clearViewFont();
408 } 408 }
409 } 409 }
410 }else if ( msg == "setBusyIndicatorType(QString)" ) { 410 }else if ( msg == "setBusyIndicatorType(QString)" ) {
411 QString type; 411 QString type;
412 stream >> type; 412 stream >> type;
413 setBusyIndicatorType( type ); 413 setBusyIndicatorType( type );
414 }else if ( msg == "home()" ) { 414 }else if ( msg == "home()" ) {
415 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { 415 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) {
416 if (categoryBar) 416 if (categoryBar)
417 categoryBar->nextTab(); 417 categoryBar->nextTab();
418 }else 418 }else
419 static_cast<QWidget*>(parent())->raise(); 419 static_cast<QWidget*>(parent())->raise();
420 } 420 }
421} 421}
422 422
423 423
424 424
425//--------------------------------------------------------------------------- 425//---------------------------------------------------------------------------
426 426
427Launcher::Launcher() 427Launcher::Launcher()
428 : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) 428 : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader )
429{ 429{
430 tabs = 0; 430 tabs = 0;
431 tb = 0; 431 tb = 0;
432} 432}
433 433
434void Launcher::createGUI() 434void Launcher::createGUI()
435{ 435{
436 setCaption( tr("Launcher") ); 436 setCaption( tr("Launcher") );
437 437
438 // we have a pretty good idea how big we'll be 438 // we have a pretty good idea how big we'll be
439 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); 439 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() );
440 440
441 tb = new TaskBar; 441 tb = new TaskBar;
442 tabs = new LauncherTabWidget( this ); 442 tabs = new LauncherTabWidget( this );
443 setCentralWidget( tabs ); 443 setCentralWidget( tabs );
444 444
445 ServerInterface::dockWidget( tb, ServerInterface::Bottom ); 445 ServerInterface::dockWidget( tb, ServerInterface::Bottom );
446 tb->show(); 446 tb->show();
447 447
448 qApp->installEventFilter( this ); 448 qApp->installEventFilter( this );
449 449
450 450
451 connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) ); 451 connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) );
452 connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) ); 452 connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) );
453 connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) ); 453 connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) );
454 454
455 connect( tb, SIGNAL(tabSelected(const QString&)), 455 connect( tb, SIGNAL(tabSelected(const QString&)),
456 this, SLOT(showTab(const QString&)) ); 456 this, SLOT(showTab(const QString&)) );
457 connect( tabs, SIGNAL(selected(const QString&)), 457 connect( tabs, SIGNAL(selected(const QString&)),
458 this, SLOT(viewSelected(const QString&)) ); 458 this, SLOT(viewSelected(const QString&)) );
459 connect( tabs, SIGNAL(clicked(const AppLnk*)), 459 connect( tabs, SIGNAL(clicked(const AppLnk*)),
460 this, SLOT(select(const AppLnk*))); 460 this, SLOT(select(const AppLnk*)));
461 connect( tabs, SIGNAL(rightPressed(AppLnk*)), 461 connect( tabs, SIGNAL(rightPressed(AppLnk*)),
462 this, SLOT(properties(AppLnk*))); 462 this, SLOT(properties(AppLnk*)));
463 463
464#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 464#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
465 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 465 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
466 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), 466 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
467 this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); 467 this, SLOT(systemMessage( const QCString &, const QByteArray &)) );
468#endif 468#endif
469 469
470 // all documents 470 // all documents
471 QImage img( Resource::loadImage( "DocsIcon" ) ); 471 QImage img( Resource::loadImage( "DocsIcon" ) );
472 QPixmap pm; 472 QPixmap pm;
473 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 473 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
474 // It could add this itself if it handles docs 474 // It could add this itself if it handles docs
475 tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE ); 475 tabs->newView("Documents", pm, tr("Documents") )->setToolsEnabled( TRUE );
476 QTimer::singleShot( 0, tabs, SLOT( initLayout() ) ); 476 QTimer::singleShot( 0, tabs, SLOT( initLayout() ) );
477 477
478 qApp->setMainWidget( this ); 478 qApp->setMainWidget( this );
479 479
480 QTimer::singleShot( 500, this, SLOT( makeVisible() ) ); 480 QTimer::singleShot( 500, this, SLOT( makeVisible() ) );
481} 481}
482 482
483Launcher::~Launcher() 483Launcher::~Launcher()
484{ 484{
485 if ( tb ) 485 if ( tb )
486 destroyGUI(); 486 destroyGUI();
487} 487}
488 488
489void Launcher::makeVisible() 489void Launcher::makeVisible()
490{ 490{
491 showMaximized(); 491 showMaximized();
492} 492}
493 493
494void Launcher::destroyGUI() 494void Launcher::destroyGUI()
495{ 495{
496 delete tb; 496 delete tb;
497 tb = 0; 497 tb = 0;
498 delete tabs; 498 delete tabs;
499 tabs =0; 499 tabs =0;
500} 500}
501 501
502bool Launcher::eventFilter( QObject*, QEvent *ev ) 502bool Launcher::eventFilter( QObject*, QEvent *ev )
503{ 503{
504#ifdef QT_QWS_CUSTOM 504#ifdef QT_QWS_CUSTOM
505 if ( ev->type() == QEvent::KeyPress ) { 505 if ( ev->type() == QEvent::KeyPress ) {
506 QKeyEvent *ke = (QKeyEvent *)ev; 506 QKeyEvent *ke = (QKeyEvent *)ev;
507 if ( ke->key() == Qt::Key_F11 ) { // menu key 507 if ( ke->key() == Qt::Key_F11 ) { // menu key
508 QWidget *active = qApp->activeWindow(); 508 QWidget *active = qApp->activeWindow();
509 if ( active && active->isPopup() ) 509 if ( active && active->isPopup() )
510 active->close(); 510 active->close();
511 else { 511 else {
512 Global::terminateBuiltin("calibrate"); // No tr 512 Global::terminateBuiltin("calibrate"); // No tr
513 tb->launchStartMenu(); 513 tb->launchStartMenu();
514 } 514 }
515 return TRUE; 515 return TRUE;
516 } 516 }
517 } 517 }
518#else 518#else
519 Q_UNUSED(ev); 519 Q_UNUSED(ev);
520#endif 520#endif
521 return FALSE; 521 return FALSE;
522} 522}
523 523
524void Launcher::toggleSymbolInput() 524void Launcher::toggleSymbolInput()
525{ 525{
526 tb->toggleSymbolInput(); 526 tb->toggleSymbolInput();
527} 527}
528 528
529void Launcher::toggleNumLockState() 529void Launcher::toggleNumLockState()
530{ 530{
531 tb->toggleNumLockState(); 531 tb->toggleNumLockState();
532} 532}
533 533
534void Launcher::toggleCapsLockState() 534void Launcher::toggleCapsLockState()
535{ 535{
536 tb->toggleCapsLockState(); 536 tb->toggleCapsLockState();
537} 537}
538 538
539static bool isVisibleWindow(int wid) 539static bool isVisibleWindow(int wid)
540{ 540{
541#ifdef Q_WS_QWS 541#ifdef Q_WS_QWS
542 const QList<QWSWindow> &list = qwsServer->clientWindows(); 542 const QList<QWSWindow> &list = qwsServer->clientWindows();
543 QWSWindow* w; 543 QWSWindow* w;
544 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 544 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
545 if ( w->winId() == wid ) 545 if ( w->winId() == wid )
546 return !w->isFullyObscured(); 546 return !w->isFullyObscured();
547 } 547 }
548#endif 548#endif
549 return FALSE; 549 return FALSE;
550} 550}
551 551
552void Launcher::viewSelected(const QString& s) 552void Launcher::viewSelected(const QString& s)
553{ 553{
554 setCaption( s + tr(" - Launcher") ); 554 setCaption( s + tr(" - Launcher") );
555} 555}
556 556
557void Launcher::showTab(const QString& id) 557void Launcher::showTab(const QString& id)
558{ 558{
559 tabs->categoryBar->showTab(id); 559 tabs->categoryBar->showTab(id);
560 raise(); 560 raise();
561} 561}
562 562
563void Launcher::select( const AppLnk *appLnk ) 563void Launcher::select( const AppLnk *appLnk )
564{ 564{
565 if ( appLnk->type() == "Folder" ) { // No tr 565 if ( appLnk->type() == "Folder" ) { // No tr
566 // Not supported: flat is simpler for the user 566 // Not supported: flat is simpler for the user
567 } else { 567 } else {
568 if ( appLnk->exec().isNull() ) { 568 if ( appLnk->exec().isNull() ) {
569 int i = QMessageBox::information(this,tr("No application"), 569 int i = QMessageBox::information(this,tr("No application"),
570 tr("<p>No application is defined for this document." 570 tr("<p>No application is defined for this document."
571 "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); 571 "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1);
572 572
573#if 0 573#if 0
574 /* ### Fixme */ 574 /* ### Fixme */
575 if ( i == 1 ) 575 if ( i == 1 )
576 Global::execute(Service::app("Open/text/*"),appLnk->file()); 576 Global::execute(Service::app("Open/text/*"),appLnk->file());
577#endif 577#endif
578 return; 578 return;
579 } 579 }
580 tabs->setBusy(TRUE); 580 tabs->setBusy(TRUE);
581 emit executing( appLnk ); 581 emit executing( appLnk );
582 appLnk->execute(); 582 appLnk->execute();
583 } 583 }
584} 584}
585 585
586void Launcher::properties( AppLnk *appLnk ) 586void Launcher::properties( AppLnk *appLnk )
587{ 587{
588 if ( appLnk->type() == "Folder" ) { // No tr 588 if ( appLnk->type() == "Folder" ) { // No tr
589 // Not supported: flat is simpler for the user 589 // Not supported: flat is simpler for the user
590 } else { 590 } else {
591/* ### libqtopia FIXME also moving docLnks... */ 591/* ### libqtopia FIXME also moving docLnks... */
592 LnkProperties prop(appLnk,0 ); 592 LnkProperties prop(appLnk,0 );
593 593
594 prop.showMaximized(); 594 prop.showMaximized();
595 prop.exec(); 595 prop.exec();
596 } 596 }
597} 597}
598 598
599void Launcher::storageChanged( const QList<FileSystem> &fs ) 599void Launcher::storageChanged( const QList<FileSystem> &fs )
600{ 600{
601 // ### update combo boxes if we had a combo box for the storage type 601 // ### update combo boxes if we had a combo box for the storage type
602} 602}
603 603
604void Launcher::systemMessage( const QCString &msg, const QByteArray &data) 604void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
605{ 605{
606 QDataStream stream( data, IO_ReadOnly ); 606 QDataStream stream( data, IO_ReadOnly );
607 if ( msg == "busy()" ) { 607 if ( msg == "busy()" ) {
608 tb->startWait(); 608 tb->startWait();
609 } else if ( msg == "notBusy(QString)" ) { 609 } else if ( msg == "notBusy(QString)" ) {
610 QString app; 610 QString app;
611 stream >> app; 611 stream >> app;
612 tabs->setBusy(FALSE); 612 tabs->setBusy(FALSE);
613 tb->stopWait(app); 613 tb->stopWait(app);
614 } else if (msg == "applyStyle()") { 614 } else if (msg == "applyStyle()") {
615 tabs->currentView()->relayout(); 615 tabs->currentView()->relayout();
616 } 616 }
617} 617}
618 618
619// These are the update functions from the server 619// These are the update functions from the server
620void Launcher::typeAdded( const QString& type, const QString& name, 620void Launcher::typeAdded( const QString& type, const QString& name,
621 const QPixmap& pixmap, const QPixmap& ) 621 const QPixmap& pixmap, const QPixmap& )
622{ 622{
623 tabs->newView( type, pixmap, name ); 623 tabs->newView( type, pixmap, name );
624 ids.append( type ); 624 ids.append( type );
625 tb->refreshStartMenu(); 625 tb->refreshStartMenu();
626 626
627 static bool first = TRUE; 627 static bool first = TRUE;
628 if ( first ) { 628 if ( first ) {
629 first = FALSE; 629 first = FALSE;
630 tabs->categoryBar->showTab(type); 630 tabs->categoryBar->showTab(type);
631 } 631 }
632 632
633 tabs->view( type )->setUpdatesEnabled( FALSE ); 633 tabs->view( type )->setUpdatesEnabled( FALSE );
634 tabs->view( type )->setSortEnabled( FALSE ); 634 tabs->view( type )->setSortEnabled( FALSE );
635} 635}
636 636
637void Launcher::typeRemoved( const QString& type ) 637void Launcher::typeRemoved( const QString& type )
638{ 638{
639 tabs->view( type )->removeAllItems(); 639 tabs->view( type )->removeAllItems();
640 tabs->deleteView( type ); 640 tabs->deleteView( type );
641 ids.remove( type ); 641 ids.remove( type );
642 tb->refreshStartMenu(); 642 tb->refreshStartMenu();
643} 643}
644 644
645void Launcher::applicationAdded( const QString& type, const AppLnk& app ) 645void Launcher::applicationAdded( const QString& type, const AppLnk& app )
646{ 646{
647 if ( app.type() == "Separator" ) // No tr 647 if ( app.type() == "Separator" ) // No tr
648 return; 648 return;
649 649
650 LauncherView *view = tabs->view( type ); 650 LauncherView *view = tabs->view( type );
651 if ( view ) 651 if ( view )
652 view->addItem( new AppLnk( app ), FALSE ); 652 view->addItem( new AppLnk( app ), FALSE );
653 else 653 else
654 qWarning("addAppLnk: No view for type %s. Can't add app %s!", 654 qWarning("addAppLnk: No view for type %s. Can't add app %s!",
655 type.latin1(),app.name().latin1() ); 655 type.latin1(),app.name().latin1() );
656 656
657 MimeType::registerApp( app ); 657 MimeType::registerApp( app );
658} 658}
659 659
660void Launcher::applicationRemoved( const QString& type, const AppLnk& app ) 660void Launcher::applicationRemoved( const QString& type, const AppLnk& app )
661{ 661{
662 LauncherView *view = tabs->view( type ); 662 LauncherView *view = tabs->view( type );
663 if ( view ) 663 if ( view )
664 view->removeLink( app.linkFile() ); 664 view->removeLink( app.linkFile() );
665 else 665 else
666 qWarning("removeAppLnk: No view for %s!", type.latin1() ); 666 qWarning("removeAppLnk: No view for %s!", type.latin1() );
667} 667}
668 668
669void Launcher::allApplicationsRemoved() 669void Launcher::allApplicationsRemoved()
670{ 670{
671 MimeType::clear(); 671 MimeType::clear();
672 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) 672 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it)
673 tabs->view( (*it) )->removeAllItems(); 673 tabs->view( (*it) )->removeAllItems();
674} 674}
675 675
676void Launcher::documentAdded( const DocLnk& doc ) 676void Launcher::documentAdded( const DocLnk& doc )
677{ 677{
678 tabs->docView()->addItem( new DocLnk( doc ), FALSE ); 678 tabs->docView()->addItem( new DocLnk( doc ), FALSE );
679} 679}
680 680
681void Launcher::showLoadingDocs() 681void Launcher::showLoadingDocs()
682{ 682{
683 tabs->docView()->hide(); 683 tabs->docView()->hide();
684} 684}
685 685
686void Launcher::showDocTab() 686void Launcher::showDocTab()
687{ 687{
688 if ( tabs->categoryBar->currentView() == tabs->docView() ) 688 if ( tabs->categoryBar->currentView() == tabs->docView() )
689 tabs->docView()->show(); 689 tabs->docView()->show();
690} 690}
691 691
692void Launcher::documentRemoved( const DocLnk& doc ) 692void Launcher::documentRemoved( const DocLnk& doc )
693{ 693{
694 tabs->docView()->removeLink( doc.linkFile() ); 694 tabs->docView()->removeLink( doc.linkFile() );
695} 695}
696 696
697void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ) 697void Launcher::documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc )
698{ 698{
699 documentRemoved( oldDoc ); 699 documentRemoved( oldDoc );
700 documentAdded( newDoc ); 700 documentAdded( newDoc );
701} 701}
702 702
703void Launcher::allDocumentsRemoved() 703void Launcher::allDocumentsRemoved()
704{ 704{
705 tabs->docView()->removeAllItems(); 705 tabs->docView()->removeAllItems();
706} 706}
707 707
708void Launcher::applicationStateChanged( const QString& name, ApplicationState state ) 708void Launcher::applicationStateChanged( const QString& name, ApplicationState state )
709{ 709{
710 tb->setApplicationState( name, state ); 710 tb->setApplicationState( name, state );
711} 711}
712 712
713void Launcher::applicationScanningProgress( int percent ) 713void Launcher::applicationScanningProgress( int percent )
714{ 714{
715 switch ( percent ) { 715 switch ( percent ) {
716 case 0: { 716 case 0: {
717 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { 717 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) {
718 tabs->view( (*it) )->setUpdatesEnabled( FALSE ); 718 tabs->view( (*it) )->setUpdatesEnabled( FALSE );
719 tabs->view( (*it) )->setSortEnabled( FALSE ); 719 tabs->view( (*it) )->setSortEnabled( FALSE );
720 } 720 }
721 break; 721 break;
722 } 722 }
723 case 100: { 723 case 100: {
724 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) { 724 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) {
725 tabs->view( (*it) )->setUpdatesEnabled( TRUE ); 725 tabs->view( (*it) )->setUpdatesEnabled( TRUE );
726 tabs->view( (*it) )->setSortEnabled( TRUE ); 726 tabs->view( (*it) )->setSortEnabled( TRUE );
727 } 727 }
728 break; 728 break;
729 } 729 }
730 default: 730 default:
731 break; 731 break;
732 } 732 }
733} 733}
734 734
735void Launcher::documentScanningProgress( int percent ) 735void Launcher::documentScanningProgress( int percent )
736{ 736{
737 switch ( percent ) { 737 switch ( percent ) {
738 case 0: { 738 case 0: {
739 tabs->setLoadingProgress( 0 ); 739 tabs->setLoadingProgress( 0 );
740 tabs->setLoadingWidgetEnabled( TRUE ); 740 tabs->setLoadingWidgetEnabled( TRUE );
741 tabs->docView()->setUpdatesEnabled( FALSE ); 741 tabs->docView()->setUpdatesEnabled( FALSE );
742 tabs->docView()->setSortEnabled( FALSE ); 742 tabs->docView()->setSortEnabled( FALSE );
743 break; 743 break;
744 } 744 }
745 case 100: { 745 case 100: {
746 tabs->docView()->updateTools(); 746 tabs->docView()->updateTools();
747 tabs->docView()->setSortEnabled( TRUE ); 747 tabs->docView()->setSortEnabled( TRUE );
748 tabs->docView()->setUpdatesEnabled( TRUE ); 748 tabs->docView()->setUpdatesEnabled( TRUE );
749 tabs->setLoadingWidgetEnabled( FALSE ); 749 tabs->setLoadingWidgetEnabled( FALSE );
750 break; 750 break;
751 } 751 }
752 default: 752 default:
753 tabs->setLoadingProgress( percent ); 753 tabs->setLoadingProgress( percent );
754 break; 754 break;
755 } 755 }
756} 756}
757 757
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp
index 5416d33..988e432 100644
--- a/core/launcher/main.cpp
+++ b/core/launcher/main.cpp
@@ -1,356 +1,356 @@
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 20
21#ifndef QTOPIA_INTERNAL_FILEOPERATIONS 21#ifndef QTOPIA_INTERNAL_FILEOPERATIONS
22#define QTOPIA_INTERNAL_FILEOPERATIONS 22#define QTOPIA_INTERNAL_FILEOPERATIONS
23#endif 23#endif
24#include "server.h" 24#include "server.h"
25#include "serverapp.h" 25#include "serverapp.h"
26#include "taskbar.h" 26#include "taskbar.h"
27#include "stabmon.h" 27#include "stabmon.h"
28#include "launcher.h" 28#include "launcher.h"
29#include "firstuse.h" 29#include "firstuse.h"
30#include "launcherglobal.h" 30#include "launcherglobal.h"
31 31
32#include <qtopia/qpeapplication.h> 32#include <qtopia/qpeapplication.h>
33#include <qtopia/network.h> 33#include <qtopia/network.h>
34#include <qtopia/config.h> 34#include <qtopia/config.h>
35#include <qtopia/custom.h> 35//#include <qtopia/custom.h>
36#include <qtopia/global.h> 36#include <qtopia/global.h>
37 37
38#include <qfile.h> 38#include <qfile.h>
39#include <qdir.h> 39#include <qdir.h>
40#ifdef QWS 40#ifdef QWS
41#include <qwindowsystem_qws.h> 41#include <qwindowsystem_qws.h>
42#include <qtopia/qcopenvelope_qws.h> 42#include <qtopia/qcopenvelope_qws.h>
43#endif 43#endif
44#include <qtopia/alarmserver.h> 44#include <qtopia/alarmserver.h>
45 45
46#include <stdlib.h> 46#include <stdlib.h>
47#include <stdio.h> 47#include <stdio.h>
48#include <signal.h> 48#include <signal.h>
49#ifndef Q_OS_WIN32 49#ifndef Q_OS_WIN32
50#include <unistd.h> 50#include <unistd.h>
51#else 51#else
52#include <process.h> 52#include <process.h>
53#endif 53#endif
54 54
55#include "calibrate.h" 55#include "calibrate.h"
56 56
57 57
58#ifdef QT_QWS_LOGIN 58#ifdef QT_QWS_LOGIN
59#include "../login/qdmdialogimpl.h" 59#include "../login/qdmdialogimpl.h"
60#endif 60#endif
61 61
62#ifdef Q_WS_QWS 62#ifdef Q_WS_QWS
63#include <qkeyboard_qws.h> 63#include <qkeyboard_qws.h>
64#endif 64#endif
65 65
66#include <qmessagebox.h> 66#include <qmessagebox.h>
67#include <opie/odevice.h> 67#include <opie/odevice.h>
68 68
69using namespace Opie; 69using namespace Opie;
70 70
71 71
72static void cleanup() 72static void cleanup()
73{ 73{
74 QDir dir( Opie::Global::tempDir(), "qcop-msg-*" ); 74 QDir dir( Opie::Global::tempDir(), "qcop-msg-*" );
75 75
76 QStringList stale = dir.entryList(); 76 QStringList stale = dir.entryList();
77 QStringList::Iterator it; 77 QStringList::Iterator it;
78 for ( it = stale.begin(); it != stale.end(); ++it ) { 78 for ( it = stale.begin(); it != stale.end(); ++it ) {
79 dir.remove( *it ); 79 dir.remove( *it );
80 } 80 }
81} 81}
82 82
83static void refreshTimeZoneConfig() 83static void refreshTimeZoneConfig()
84{ 84{
85 /* ### FIXME timezone handling */ 85 /* ### FIXME timezone handling */
86#if 0 86#if 0
87 // We need to help WorldTime in setting up its configuration for 87 // We need to help WorldTime in setting up its configuration for
88 // the current translation 88 // the current translation
89 // BEGIN no tr 89 // BEGIN no tr
90 const char *defaultTz[] = { 90 const char *defaultTz[] = {
91 "America/New_York", 91 "America/New_York",
92 "America/Los_Angeles", 92 "America/Los_Angeles",
93 "Europe/Oslo", 93 "Europe/Oslo",
94 "Asia/Tokyo", 94 "Asia/Tokyo",
95 "Asia/Hong_Kong", 95 "Asia/Hong_Kong",
96 "Australia/Brisbane", 96 "Australia/Brisbane",
97 0 97 0
98 }; 98 };
99 // END no tr 99 // END no tr
100 100
101 TimeZone curZone; 101 TimeZone curZone;
102 QString zoneID; 102 QString zoneID;
103 int zoneIndex; 103 int zoneIndex;
104 Config cfg = Config( "WorldTime" ); 104 Config cfg = Config( "WorldTime" );
105 cfg.setGroup( "TimeZones" ); 105 cfg.setGroup( "TimeZones" );
106 if (!cfg.hasKey( "Zone0" )){ 106 if (!cfg.hasKey( "Zone0" )){
107 // We have no existing timezones use the defaults which are untranslated strings 107 // We have no existing timezones use the defaults which are untranslated strings
108 QString currTz = TimeZone::current().id(); 108 QString currTz = TimeZone::current().id();
109 QStringList zoneDefaults; 109 QStringList zoneDefaults;
110 zoneDefaults.append( currTz ); 110 zoneDefaults.append( currTz );
111 for ( int i = 0; defaultTz[i] && zoneDefaults.count() < 6; i++ ) { 111 for ( int i = 0; defaultTz[i] && zoneDefaults.count() < 6; i++ ) {
112 if ( defaultTz[i] != currTz ) 112 if ( defaultTz[i] != currTz )
113 zoneDefaults.append( defaultTz[i] ); 113 zoneDefaults.append( defaultTz[i] );
114 } 114 }
115 zoneIndex = 0; 115 zoneIndex = 0;
116 for (QStringList::Iterator it = zoneDefaults.begin(); it != zoneDefaults.end() ; ++it){ 116 for (QStringList::Iterator it = zoneDefaults.begin(); it != zoneDefaults.end() ; ++it){
117 cfg.writeEntry( "Zone" + QString::number( zoneIndex ) , *it); 117 cfg.writeEntry( "Zone" + QString::number( zoneIndex ) , *it);
118 zoneIndex++; 118 zoneIndex++;
119 } 119 }
120 } 120 }
121 // We have an existing list of timezones refresh the 121 // We have an existing list of timezones refresh the
122 // translations of TimeZone name 122 // translations of TimeZone name
123 zoneIndex = 0; 123 zoneIndex = 0;
124 while (cfg.hasKey( "Zone"+ QString::number( zoneIndex ))){ 124 while (cfg.hasKey( "Zone"+ QString::number( zoneIndex ))){
125 zoneID = cfg.readEntry( "Zone" + QString::number( zoneIndex )); 125 zoneID = cfg.readEntry( "Zone" + QString::number( zoneIndex ));
126 curZone = TimeZone( zoneID ); 126 curZone = TimeZone( zoneID );
127 if ( !curZone.isValid() ){ 127 if ( !curZone.isValid() ){
128 qDebug( "initEnvironment() Invalid TimeZone %s", zoneID.latin1() ); 128 qDebug( "initEnvironment() Invalid TimeZone %s", zoneID.latin1() );
129 break; 129 break;
130 } 130 }
131 cfg.writeEntry( "ZoneName" + QString::number( zoneIndex ), curZone.city() ); 131 cfg.writeEntry( "ZoneName" + QString::number( zoneIndex ), curZone.city() );
132 zoneIndex++; 132 zoneIndex++;
133 } 133 }
134#endif 134#endif
135} 135}
136 136
137void initEnvironment() 137void initEnvironment()
138{ 138{
139#ifdef Q_OS_WIN32 139#ifdef Q_OS_WIN32
140 // Config file requires HOME dir which uses QDir which needs the winver 140 // Config file requires HOME dir which uses QDir which needs the winver
141 qt_init_winver(); 141 qt_init_winver();
142#endif 142#endif
143 Config config("locale"); 143 Config config("locale");
144 config.setGroup( "Location" ); 144 config.setGroup( "Location" );
145 QString tz = config.readEntry( "Timezone", getenv("TZ") ).stripWhiteSpace(); 145 QString tz = config.readEntry( "Timezone", getenv("TZ") ).stripWhiteSpace();
146 146
147 // if not timezone set, pick New York 147 // if not timezone set, pick New York
148 if (tz.isNull() || tz.isEmpty()) 148 if (tz.isNull() || tz.isEmpty())
149 tz = "America/New_York"; 149 tz = "America/New_York";
150 150
151 setenv( "TZ", tz, 1 ); 151 setenv( "TZ", tz, 1 );
152 config.writeEntry( "Timezone", tz); 152 config.writeEntry( "Timezone", tz);
153 153
154 config.setGroup( "Language" ); 154 config.setGroup( "Language" );
155 QString lang = config.readEntry( "Language", getenv("LANG") ).stripWhiteSpace(); 155 QString lang = config.readEntry( "Language", getenv("LANG") ).stripWhiteSpace();
156 if( lang.isNull() || lang.isEmpty()) 156 if( lang.isNull() || lang.isEmpty())
157 lang = "en_US"; 157 lang = "en_US";
158 158
159 setenv( "LANG", lang, 1 ); 159 setenv( "LANG", lang, 1 );
160 config.writeEntry("Language", lang); 160 config.writeEntry("Language", lang);
161 config.write(); 161 config.write();
162 162
163#if 0 163#if 0
164 setenv( "QWS_SIZE", "240x320", 0 ); 164 setenv( "QWS_SIZE", "240x320", 0 );
165#endif 165#endif
166 166
167 167
168 168
169 QString env(getenv("QWS_DISPLAY")); 169 QString env(getenv("QWS_DISPLAY"));
170 if (env.contains("Transformed")) { 170 if (env.contains("Transformed")) {
171 int rot; 171 int rot;
172 // transformed driver default rotation is controlled by the hardware. 172 // transformed driver default rotation is controlled by the hardware.
173 Config config("qpe"); 173 Config config("qpe");
174 config.setGroup( "Rotation" ); 174 config.setGroup( "Rotation" );
175 if ( ( rot = config.readNumEntry( "Rot", -1 ) ) == -1 ) 175 if ( ( rot = config.readNumEntry( "Rot", -1 ) ) == -1 )
176 rot = ODevice::inst ( )-> rotation ( ) * 90; 176 rot = ODevice::inst ( )-> rotation ( ) * 90;
177 177
178 setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1); 178 setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1);
179 QPEApplication::defaultRotation ( ); /* to ensure deforient matches reality */ 179 QPEApplication::defaultRotation ( ); /* to ensure deforient matches reality */
180 } 180 }
181} 181}
182 182
183static void initKeyboard() 183static void initKeyboard()
184{ 184{
185 Config config("qpe"); 185 Config config("qpe");
186 186
187 config.setGroup( "Keyboard" ); 187 config.setGroup( "Keyboard" );
188 188
189 int ard = config.readNumEntry( "RepeatDelay" ); 189 int ard = config.readNumEntry( "RepeatDelay" );
190 int arp = config.readNumEntry( "RepeatPeriod" ); 190 int arp = config.readNumEntry( "RepeatPeriod" );
191 if ( ard > 0 && arp > 0 ) 191 if ( ard > 0 && arp > 0 )
192 qwsSetKeyboardAutoRepeat( ard, arp ); 192 qwsSetKeyboardAutoRepeat( ard, arp );
193 193
194 QString layout = config.readEntry( "Layout", "us101" ); 194 QString layout = config.readEntry( "Layout", "us101" );
195 Server::setKeyboardLayout( layout ); 195 Server::setKeyboardLayout( layout );
196} 196}
197 197
198static bool firstUse() 198static bool firstUse()
199{ 199{
200 bool needFirstUse = FALSE; 200 bool needFirstUse = FALSE;
201 if ( QWSServer::mouseHandler() && 201 if ( QWSServer::mouseHandler() &&
202 QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { 202 QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) {
203 if ( !QFile::exists( "/etc/pointercal" ) ) 203 if ( !QFile::exists( "/etc/pointercal" ) )
204 needFirstUse = TRUE; 204 needFirstUse = TRUE;
205 } 205 }
206 206
207 { 207 {
208 Config config( "qpe" ); 208 Config config( "qpe" );
209 config.setGroup( "Startup" ); 209 config.setGroup( "Startup" );
210 needFirstUse |= config.readBoolEntry( "FirstUse", TRUE ); 210 needFirstUse |= config.readBoolEntry( "FirstUse", TRUE );
211 } 211 }
212 212
213 if ( !needFirstUse ) 213 if ( !needFirstUse )
214 return FALSE; 214 return FALSE;
215 215
216 FirstUse *fu = new FirstUse(); 216 FirstUse *fu = new FirstUse();
217 fu->exec(); 217 fu->exec();
218 bool rs = fu->restartNeeded(); 218 bool rs = fu->restartNeeded();
219 delete fu; 219 delete fu;
220 return rs; 220 return rs;
221} 221}
222 222
223int initApplication( int argc, char ** argv ) 223int initApplication( int argc, char ** argv )
224{ 224{
225 cleanup(); 225 cleanup();
226 226
227 227
228 initEnvironment(); 228 initEnvironment();
229 229
230 //Don't flicker at startup: 230 //Don't flicker at startup:
231#ifdef QWS 231#ifdef QWS
232 QWSServer::setDesktopBackground( QImage() ); 232 QWSServer::setDesktopBackground( QImage() );
233#endif 233#endif
234 ServerApplication a( argc, argv, QApplication::GuiServer ); 234 ServerApplication a( argc, argv, QApplication::GuiServer );
235 235
236 refreshTimeZoneConfig(); 236 refreshTimeZoneConfig();
237 237
238 initKeyboard(); 238 initKeyboard();
239 239
240 // Don't use first use under Windows 240 // Don't use first use under Windows
241 if ( firstUse() ) { 241 if ( firstUse() ) {
242 a.restart(); 242 a.restart();
243 return 0; 243 return 0;
244 } 244 }
245 245
246 ODevice::inst ( )-> setSoftSuspend ( true ); 246 ODevice::inst ( )-> setSoftSuspend ( true );
247 247
248 { 248 {
249 QCopEnvelope e("QPE/System", "setBacklight(int)" ); 249 QCopEnvelope e("QPE/System", "setBacklight(int)" );
250 e << -3; // Forced on 250 e << -3; // Forced on
251 } 251 }
252 252
253 AlarmServer::initialize(); 253 AlarmServer::initialize();
254 254
255 255
256 256
257 Server *s = new Server(); 257 Server *s = new Server();
258 258
259 (void)new SysFileMonitor(s); 259 (void)new SysFileMonitor(s);
260#ifdef QWS 260#ifdef QWS
261 Network::createServer(s); 261 Network::createServer(s);
262#endif 262#endif
263 263
264 s->show(); 264 s->show();
265 265
266 /* THE ARM rtc has problem holdings the time on reset */ 266 /* THE ARM rtc has problem holdings the time on reset */
267 if ( QDate::currentDate ( ). year ( ) < 2000 ) { 267 if ( QDate::currentDate ( ). year ( ) < 2000 ) {
268 if ( QMessageBox::information ( 0, ServerApplication::tr( "Information" ), ServerApplication::tr( "<p>The system date doesn't seem to be valid.\n(%1)</p><p>Do you want to correct the clock ?</p>" ). arg( TimeString::dateString ( QDate::currentDate ( ))), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { 268 if ( QMessageBox::information ( 0, ServerApplication::tr( "Information" ), ServerApplication::tr( "<p>The system date doesn't seem to be valid.\n(%1)</p><p>Do you want to correct the clock ?</p>" ). arg( TimeString::dateString ( QDate::currentDate ( ))), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) {
269 QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" ); 269 QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" );
270 e << QString ( ); 270 e << QString ( );
271 } 271 }
272 } 272 }
273 273
274 int rv = a.exec(); 274 int rv = a.exec();
275 275
276 qDebug("exiting..."); 276 qDebug("exiting...");
277 delete s; 277 delete s;
278 278
279#ifndef Q_OS_MACX 279#ifndef Q_OS_MACX
280 ODevice::inst()->setSoftSuspend( false ); 280 ODevice::inst()->setSoftSuspend( false );
281#endif 281#endif
282 282
283 return rv; 283 return rv;
284} 284}
285 285
286static const char *pidfile_path = "/var/run/opie.pid"; 286static const char *pidfile_path = "/var/run/opie.pid";
287 287
288void create_pidfile ( ) 288void create_pidfile ( )
289{ 289{
290 FILE *f; 290 FILE *f;
291 291
292 if (( f = ::fopen ( pidfile_path, "w" ))) { 292 if (( f = ::fopen ( pidfile_path, "w" ))) {
293 ::fprintf ( f, "%d", getpid ( )); 293 ::fprintf ( f, "%d", getpid ( ));
294 ::fclose ( f ); 294 ::fclose ( f );
295 } 295 }
296} 296}
297 297
298void remove_pidfile ( ) 298void remove_pidfile ( )
299{ 299{
300 ::unlink ( pidfile_path ); 300 ::unlink ( pidfile_path );
301} 301}
302 302
303void handle_sigterm ( int /* sig */ ) 303void handle_sigterm ( int /* sig */ )
304{ 304{
305 if ( qApp ) 305 if ( qApp )
306 qApp-> quit ( ); 306 qApp-> quit ( );
307} 307}
308 308
309#ifndef Q_OS_WIN32 309#ifndef Q_OS_WIN32
310int main( int argc, char ** argv ) 310int main( int argc, char ** argv )
311{ 311{
312 312
313 ::signal ( SIGCHLD, SIG_IGN ); 313 ::signal ( SIGCHLD, SIG_IGN );
314 314
315 ::signal ( SIGTERM, handle_sigterm ); 315 ::signal ( SIGTERM, handle_sigterm );
316 ::signal ( SIGINT, handle_sigterm ); 316 ::signal ( SIGINT, handle_sigterm );
317 317
318 ::setsid ( ); 318 ::setsid ( );
319 ::setpgid ( 0, 0 ); 319 ::setpgid ( 0, 0 );
320 320
321 ::atexit ( remove_pidfile ); 321 ::atexit ( remove_pidfile );
322 create_pidfile ( ); 322 create_pidfile ( );
323 323
324 int retVal = initApplication( argc, argv ); 324 int retVal = initApplication( argc, argv );
325 325
326 // Have we been asked to restart? 326 // Have we been asked to restart?
327 if ( ServerApplication::doRestart ) { 327 if ( ServerApplication::doRestart ) {
328 for ( int fd = 3; fd < 100; fd++ ) 328 for ( int fd = 3; fd < 100; fd++ )
329 close( fd ); 329 close( fd );
330 330
331 execl( (QPEApplication::qpeDir()+"bin/qpe").latin1(), "qpe", 0 ); 331 execl( (QPEApplication::qpeDir()+"bin/qpe").latin1(), "qpe", 0 );
332 } 332 }
333 333
334 // Kill them. Kill them all. 334 // Kill them. Kill them all.
335 ::kill ( 0, SIGTERM ); 335 ::kill ( 0, SIGTERM );
336 ::sleep ( 1 ); 336 ::sleep ( 1 );
337 ::kill ( 0, SIGKILL ); 337 ::kill ( 0, SIGKILL );
338 338
339 return retVal; 339 return retVal;
340} 340}
341#else 341#else
342 342
343int main( int argc, char ** argv ) 343int main( int argc, char ** argv )
344{ 344{
345 int retVal = initApplication( argc, argv ); 345 int retVal = initApplication( argc, argv );
346 346
347 if ( DesktopApplication::doRestart ) { 347 if ( DesktopApplication::doRestart ) {
348 qDebug("Trying to restart"); 348 qDebug("Trying to restart");
349 execl( (QPEApplication::qpeDir()+"bin\\qpe").latin1(), "qpe", 0 ); 349 execl( (QPEApplication::qpeDir()+"bin\\qpe").latin1(), "qpe", 0 );
350 } 350 }
351 351
352 return retVal; 352 return retVal;
353} 353}
354 354
355#endif 355#endif
356 356
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp
index 4c62b78..6a140e9 100644
--- a/core/launcher/server.cpp
+++ b/core/launcher/server.cpp
@@ -1,730 +1,730 @@
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 20
21#include "server.h" 21#include "server.h"
22#include "serverapp.h" 22#include "serverapp.h"
23#include "launcher.h" 23#include "launcher.h"
24#include "startmenu.h" 24#include "startmenu.h"
25#include "transferserver.h" 25#include "transferserver.h"
26#include "qcopbridge.h" 26#include "qcopbridge.h"
27#include "irserver.h" 27#include "irserver.h"
28#include "packageslave.h" 28#include "packageslave.h"
29#include "calibrate.h" 29#include "calibrate.h"
30#include "qrsync.h" 30#include "qrsync.h"
31#include "syncdialog.h" 31#include "syncdialog.h"
32#include "launcher.h" 32#include "launcher.h"
33#include "shutdownimpl.h" 33#include "shutdownimpl.h"
34#include "applauncher.h" 34#include "applauncher.h"
35#if 0 35#if 0
36#include "suspendmonitor.h" 36#include "suspendmonitor.h"
37#endif 37#endif
38#include "documentlist.h" 38#include "documentlist.h"
39 39
40#include <qtopia/applnk.h> 40#include <qtopia/applnk.h>
41#include <qtopia/private/categories.h> 41#include <qtopia/private/categories.h>
42#include <qtopia/mimetype.h> 42#include <qtopia/mimetype.h>
43#include <qtopia/config.h> 43#include <qtopia/config.h>
44#include <qtopia/resource.h> 44#include <qtopia/resource.h>
45#include <qtopia/version.h> 45#include <qtopia/version.h>
46#include <qtopia/storage.h> 46#include <qtopia/storage.h>
47 47
48#include <qtopia/qcopenvelope_qws.h> 48#include <qtopia/qcopenvelope_qws.h>
49#include <qwindowsystem_qws.h> 49#include <qwindowsystem_qws.h>
50#include <qgfx_qws.h> 50#include <qgfx_qws.h>
51#include <qtopia/global.h> 51#include <qtopia/global.h>
52#include <qtopia/custom.h> 52//#include <qtopia/custom.h>
53 53
54#include <opie/odevicebutton.h> 54#include <opie/odevicebutton.h>
55#include <opie/odevice.h> 55#include <opie/odevice.h>
56 56
57#include <unistd.h> 57#include <unistd.h>
58#include <qmainwindow.h> 58#include <qmainwindow.h>
59#include <qmessagebox.h> 59#include <qmessagebox.h>
60#include <qtimer.h> 60#include <qtimer.h>
61#include <qtextstream.h> 61#include <qtextstream.h>
62 62
63#include <stdlib.h> 63#include <stdlib.h>
64 64
65extern QRect qt_maxWindowRect; 65extern QRect qt_maxWindowRect;
66 66
67using namespace Opie; 67using namespace Opie;
68 68
69static QWidget *calibrate(bool) 69static QWidget *calibrate(bool)
70{ 70{
71#ifdef Q_WS_QWS 71#ifdef Q_WS_QWS
72 Calibrate *c = new Calibrate; 72 Calibrate *c = new Calibrate;
73 c->show(); 73 c->show();
74 return c; 74 return c;
75#else 75#else
76 return 0; 76 return 0;
77#endif 77#endif
78} 78}
79 79
80#define FACTORY(T) \ 80#define FACTORY(T) \
81 static QWidget *new##T( bool maximized ) { \ 81 static QWidget *new##T( bool maximized ) { \
82 QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ 82 QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \
83 if ( maximized ) { \ 83 if ( maximized ) { \
84 if ( qApp->desktop()->width() <= 350 ) { \ 84 if ( qApp->desktop()->width() <= 350 ) { \
85 w->showMaximized(); \ 85 w->showMaximized(); \
86 } else { \ 86 } else { \
87 w->resize( QSize( 300, 300 ) ); \ 87 w->resize( QSize( 300, 300 ) ); \
88 } \ 88 } \
89 } \ 89 } \
90 w->show(); \ 90 w->show(); \
91 return w; \ 91 return w; \
92 } 92 }
93 93
94 94
95#ifdef SINGLE_APP 95#ifdef SINGLE_APP
96#define APP(a,b,c,d) FACTORY(b) 96#define APP(a,b,c,d) FACTORY(b)
97#include "apps.h" 97#include "apps.h"
98#undef APP 98#undef APP
99#endif // SINGLE_APP 99#endif // SINGLE_APP
100 100
101static Global::Command builtins[] = { 101static Global::Command builtins[] = {
102 102
103#ifdef SINGLE_APP 103#ifdef SINGLE_APP
104#define APP(a,b,c,d) { a, new##b, c, d }, 104#define APP(a,b,c,d) { a, new##b, c, d },
105#include "apps.h" 105#include "apps.h"
106#undef APP 106#undef APP
107#endif 107#endif
108 108
109 /* FIXME defines need to be defined*/ 109 /* FIXME defines need to be defined*/
110#if defined(QPE_NEED_CALIBRATION) 110#if defined(QPE_NEED_CALIBRATION)
111 { "calibrate", calibrate, 1, 0 }, // No tr 111 { "calibrate", calibrate, 1, 0 }, // No tr
112#endif 112#endif
113#if !defined(OPIE_NO_BUILTIN_SHUTDOWN) 113#if !defined(OPIE_NO_BUILTIN_SHUTDOWN)
114 { "shutdown", Global::shutdown, 1, 0 }, // No tr 114 { "shutdown", Global::shutdown, 1, 0 }, // No tr
115 // { "run", run, 1, 0 }, // No tr 115 // { "run", run, 1, 0 }, // No tr
116#endif 116#endif
117 117
118 { 0, calibrate,0, 0 }, 118 { 0, calibrate,0, 0 },
119}; 119};
120 120
121 121
122//--------------------------------------------------------------------------- 122//---------------------------------------------------------------------------
123 123
124 124
125//=========================================================================== 125//===========================================================================
126 126
127Server::Server() : 127Server::Server() :
128 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 128 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
129 qcopBridge( 0 ), 129 qcopBridge( 0 ),
130 transferServer( 0 ), 130 transferServer( 0 ),
131 packageHandler( 0 ), 131 packageHandler( 0 ),
132 syncDialog( 0 ) 132 syncDialog( 0 )
133{ 133{
134 Global::setBuiltinCommands(builtins); 134 Global::setBuiltinCommands(builtins);
135 135
136 tid_xfer = 0; 136 tid_xfer = 0;
137 /* ### FIXME ### */ 137 /* ### FIXME ### */
138/* tid_today = startTimer(3600*2*1000);*/ 138/* tid_today = startTimer(3600*2*1000);*/
139 last_today_show = QDate::currentDate(); 139 last_today_show = QDate::currentDate();
140 140
141#if 0 141#if 0
142 tsmMonitor = new TempScreenSaverMode(); 142 tsmMonitor = new TempScreenSaverMode();
143 connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) ); 143 connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) );
144#endif 144#endif
145 145
146 serverGui = new Launcher; 146 serverGui = new Launcher;
147 serverGui->createGUI(); 147 serverGui->createGUI();
148 148
149 docList = new DocumentList( serverGui ); 149 docList = new DocumentList( serverGui );
150 appLauncher = new AppLauncher(this); 150 appLauncher = new AppLauncher(this);
151 connect(appLauncher, SIGNAL(launched(int, const QString &)), this, SLOT(applicationLaunched(int, const QString &)) ); 151 connect(appLauncher, SIGNAL(launched(int, const QString &)), this, SLOT(applicationLaunched(int, const QString &)) );
152 connect(appLauncher, SIGNAL(terminated(int, const QString &)), this, SLOT(applicationTerminated(int, const QString &)) ); 152 connect(appLauncher, SIGNAL(terminated(int, const QString &)), this, SLOT(applicationTerminated(int, const QString &)) );
153 connect(appLauncher, SIGNAL(connected(const QString &)), this, SLOT(applicationConnected(const QString &)) ); 153 connect(appLauncher, SIGNAL(connected(const QString &)), this, SLOT(applicationConnected(const QString &)) );
154 154
155 storage = new StorageInfo( this ); 155 storage = new StorageInfo( this );
156 connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) ); 156 connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) );
157 157
158 // start services 158 // start services
159 startTransferServer(); 159 startTransferServer();
160 (void) new IrServer( this ); 160 (void) new IrServer( this );
161 161
162 packageHandler = new PackageHandler( this ); 162 packageHandler = new PackageHandler( this );
163 connect(qApp, SIGNAL(activate(const Opie::ODeviceButton*,bool)), 163 connect(qApp, SIGNAL(activate(const Opie::ODeviceButton*,bool)),
164 this,SLOT(activate(const Opie::ODeviceButton*,bool))); 164 this,SLOT(activate(const Opie::ODeviceButton*,bool)));
165 165
166 setGeometry( -10, -10, 9, 9 ); 166 setGeometry( -10, -10, 9, 9 );
167 167
168 QCopChannel *channel = new QCopChannel("QPE/System", this); 168 QCopChannel *channel = new QCopChannel("QPE/System", this);
169 connect(channel, SIGNAL(received(const QCString &, const QByteArray &)), 169 connect(channel, SIGNAL(received(const QCString &, const QByteArray &)),
170 this, SLOT(systemMsg(const QCString &, const QByteArray &)) ); 170 this, SLOT(systemMsg(const QCString &, const QByteArray &)) );
171 171
172 QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this ); 172 QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this );
173 connect( tbChannel, SIGNAL(received(const QCString&, const QByteArray&)), 173 connect( tbChannel, SIGNAL(received(const QCString&, const QByteArray&)),
174 this, SLOT(receiveTaskBar(const QCString&, const QByteArray&)) ); 174 this, SLOT(receiveTaskBar(const QCString&, const QByteArray&)) );
175 175
176 connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) ); 176 connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) );
177 connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) ); 177 connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) );
178 178
179 preloadApps(); 179 preloadApps();
180} 180}
181 181
182void Server::show() 182void Server::show()
183{ 183{
184 ServerApplication::login(TRUE); 184 ServerApplication::login(TRUE);
185 QWidget::show(); 185 QWidget::show();
186} 186}
187 187
188Server::~Server() 188Server::~Server()
189{ 189{
190 serverGui->destroyGUI(); 190 serverGui->destroyGUI();
191 delete docList; 191 delete docList;
192 delete qcopBridge; 192 delete qcopBridge;
193 delete transferServer; 193 delete transferServer;
194 delete serverGui; 194 delete serverGui;
195#if 0 195#if 0
196 delete tsmMonitor; 196 delete tsmMonitor;
197#endif 197#endif
198} 198}
199 199
200static bool hasVisibleWindow(const QString& clientname, bool partial) 200static bool hasVisibleWindow(const QString& clientname, bool partial)
201{ 201{
202#ifdef QWS 202#ifdef QWS
203 const QList<QWSWindow> &list = qwsServer->clientWindows(); 203 const QList<QWSWindow> &list = qwsServer->clientWindows();
204 QWSWindow* w; 204 QWSWindow* w;
205 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 205 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
206 if ( w->client()->identity() == clientname ) { 206 if ( w->client()->identity() == clientname ) {
207 if ( partial && !w->isFullyObscured() ) 207 if ( partial && !w->isFullyObscured() )
208 return TRUE; 208 return TRUE;
209 if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { 209 if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) {
210# if QT_VERSION < 0x030000 210# if QT_VERSION < 0x030000
211 QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, 211 QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect,
212 QSize(qt_screen->width(),qt_screen->height()) ); 212 QSize(qt_screen->width(),qt_screen->height()) );
213# else 213# else
214 QRect mwr = qt_maxWindowRect; 214 QRect mwr = qt_maxWindowRect;
215# endif 215# endif
216 if ( mwr.contains(w->requested().boundingRect()) ) 216 if ( mwr.contains(w->requested().boundingRect()) )
217 return TRUE; 217 return TRUE;
218 } 218 }
219 } 219 }
220 } 220 }
221#endif 221#endif
222 return FALSE; 222 return FALSE;
223} 223}
224 224
225void Server::activate(const Opie::ODeviceButton* button, bool held) 225void Server::activate(const Opie::ODeviceButton* button, bool held)
226{ 226{
227 Global::terminateBuiltin("calibrate"); // No tr 227 Global::terminateBuiltin("calibrate"); // No tr
228 Opie::OQCopMessage om; 228 Opie::OQCopMessage om;
229 if ( held ) { 229 if ( held ) {
230 om = button->heldAction(); 230 om = button->heldAction();
231 } else { 231 } else {
232 om = button->pressedAction(); 232 om = button->pressedAction();
233 } 233 }
234 234
235 if ( om.channel() != "ignore" ) 235 if ( om.channel() != "ignore" )
236 om.send(); 236 om.send();
237 237
238 // A button with no action defined, will return a null ServiceRequest. Don't attempt 238 // A button with no action defined, will return a null ServiceRequest. Don't attempt
239 // to send/do anything with this as it will crash 239 // to send/do anything with this as it will crash
240 /* ### FIXME */ 240 /* ### FIXME */
241#if 0 241#if 0
242 if ( !sr.isNull() ) { 242 if ( !sr.isNull() ) {
243 QString app = sr.app(); 243 QString app = sr.app();
244 bool vis = hasVisibleWindow(app, app != "qpe"); 244 bool vis = hasVisibleWindow(app, app != "qpe");
245 if ( sr.message() == "raise()" && vis ) { 245 if ( sr.message() == "raise()" && vis ) {
246 sr.setMessage("nextView()"); 246 sr.setMessage("nextView()");
247 } else { 247 } else {
248 // "back door" 248 // "back door"
249 sr << (int)vis; 249 sr << (int)vis;
250 } 250 }
251 251
252 sr.send(); 252 sr.send();
253 } 253 }
254#endif 254#endif
255} 255}
256 256
257 257
258#ifdef Q_WS_QWS 258#ifdef Q_WS_QWS
259 259
260 260
261typedef struct KeyOverride { 261typedef struct KeyOverride {
262 ushort scan_code; 262 ushort scan_code;
263 QWSServer::KeyMap map; 263 QWSServer::KeyMap map;
264}; 264};
265 265
266 266
267static const KeyOverride jp109keys[] = { 267static const KeyOverride jp109keys[] = {
268 { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } }, 268 { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } },
269 { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } }, 269 { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } },
270 { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } }, 270 { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } },
271 { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } }, 271 { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } },
272 { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } }, 272 { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } },
273 { 0x0b, { Qt::Key_0, '0' , 0xffff , 0xffff } }, 273 { 0x0b, { Qt::Key_0, '0' , 0xffff , 0xffff } },
274 { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } }, 274 { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } },
275 { 0x0d, { Qt::Key_AsciiCircum,'^' , '~' , '^' - 64 } }, 275 { 0x0d, { Qt::Key_AsciiCircum,'^' , '~' , '^' - 64 } },
276 { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } }, 276 { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } },
277 { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '[' - 64 } }, 277 { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '[' - 64 } },
278 { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } }, 278 { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } },
279 { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } }, 279 { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } },
280 { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff , 0xffff , 0xffff } }, 280 { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff , 0xffff , 0xffff } },
281 { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } }, 281 { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } },
282 { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff , 0xffff , 0xffff } }, 282 { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff , 0xffff , 0xffff } },
283 { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } }, 283 { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } },
284 { 0x79, { Qt::Key_Henkan, 0xffff , 0xffff , 0xffff } }, 284 { 0x79, { Qt::Key_Henkan, 0xffff , 0xffff , 0xffff } },
285 { 0x7b, { Qt::Key_Muhenkan, 0xffff , 0xffff , 0xffff } }, 285 { 0x7b, { Qt::Key_Muhenkan, 0xffff , 0xffff , 0xffff } },
286 { 0x7d, { Qt::Key_yen, 0x00a5 , '|' , 0xffff } }, 286 { 0x7d, { Qt::Key_yen, 0x00a5 , '|' , 0xffff } },
287 { 0x00, { 0, 0xffff , 0xffff , 0xffff } } 287 { 0x00, { 0, 0xffff , 0xffff , 0xffff } }
288}; 288};
289 289
290bool Server::setKeyboardLayout( const QString &kb ) 290bool Server::setKeyboardLayout( const QString &kb )
291{ 291{
292 //quick demo version that can be extended 292 //quick demo version that can be extended
293 293
294 QIntDict<QWSServer::KeyMap> *om = 0; 294 QIntDict<QWSServer::KeyMap> *om = 0;
295 if ( kb == "us101" ) { // No tr 295 if ( kb == "us101" ) { // No tr
296 om = 0; 296 om = 0;
297 } else if ( kb == "jp109" ) { 297 } else if ( kb == "jp109" ) {
298 om = new QIntDict<QWSServer::KeyMap>(37); 298 om = new QIntDict<QWSServer::KeyMap>(37);
299 const KeyOverride *k = jp109keys; 299 const KeyOverride *k = jp109keys;
300 while ( k->scan_code ) { 300 while ( k->scan_code ) {
301 om->insert( k->scan_code, &k->map ); 301 om->insert( k->scan_code, &k->map );
302 k++; 302 k++;
303 } 303 }
304 } 304 }
305 QWSServer::setOverrideKeys( om ); 305 QWSServer::setOverrideKeys( om );
306 306
307 return TRUE; 307 return TRUE;
308} 308}
309 309
310#endif 310#endif
311 311
312void Server::systemMsg(const QCString &msg, const QByteArray &data) 312void Server::systemMsg(const QCString &msg, const QByteArray &data)
313{ 313{
314 QDataStream stream( data, IO_ReadOnly ); 314 QDataStream stream( data, IO_ReadOnly );
315 315
316 if ( msg == "securityChanged()" ) { 316 if ( msg == "securityChanged()" ) {
317 if ( transferServer ) 317 if ( transferServer )
318 transferServer->authorizeConnections(); 318 transferServer->authorizeConnections();
319 if ( qcopBridge ) 319 if ( qcopBridge )
320 qcopBridge->authorizeConnections(); 320 qcopBridge->authorizeConnections();
321 } 321 }
322 /* ### FIXME support TempScreenSaverMode */ 322 /* ### FIXME support TempScreenSaverMode */
323#if 0 323#if 0
324 else if ( msg == "setTempScreenSaverMode(int,int)" ) { 324 else if ( msg == "setTempScreenSaverMode(int,int)" ) {
325 int mode, pid; 325 int mode, pid;
326 stream >> mode >> pid; 326 stream >> mode >> pid;
327 tsmMonitor->setTempMode(mode, pid); 327 tsmMonitor->setTempMode(mode, pid);
328 } 328 }
329#endif 329#endif
330 else if ( msg == "linkChanged(QString)" ) { 330 else if ( msg == "linkChanged(QString)" ) {
331 QString link; 331 QString link;
332 stream >> link; 332 stream >> link;
333 qDebug( "desktop.cpp systemMsg -> linkchanged( %s )", link.latin1() ); 333 qDebug( "desktop.cpp systemMsg -> linkchanged( %s )", link.latin1() );
334 docList->linkChanged(link); 334 docList->linkChanged(link);
335 } else if ( msg == "serviceChanged(QString)" ) { 335 } else if ( msg == "serviceChanged(QString)" ) {
336 MimeType::updateApplications(); 336 MimeType::updateApplications();
337 } else if ( msg == "mkdir(QString)" ) { 337 } else if ( msg == "mkdir(QString)" ) {
338 QString dir; 338 QString dir;
339 stream >> dir; 339 stream >> dir;
340 if ( !dir.isEmpty() ) 340 if ( !dir.isEmpty() )
341 mkdir( dir ); 341 mkdir( dir );
342 } else if ( msg == "rdiffGenSig(QString,QString)" ) { 342 } else if ( msg == "rdiffGenSig(QString,QString)" ) {
343 QString baseFile, sigFile; 343 QString baseFile, sigFile;
344 stream >> baseFile >> sigFile; 344 stream >> baseFile >> sigFile;
345 QRsync::generateSignature( baseFile, sigFile ); 345 QRsync::generateSignature( baseFile, sigFile );
346 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { 346 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) {
347 QString baseFile, sigFile, deltaFile; 347 QString baseFile, sigFile, deltaFile;
348 stream >> baseFile >> sigFile >> deltaFile; 348 stream >> baseFile >> sigFile >> deltaFile;
349 QRsync::generateDiff( baseFile, sigFile, deltaFile ); 349 QRsync::generateDiff( baseFile, sigFile, deltaFile );
350 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { 350 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) {
351 QString baseFile, deltaFile; 351 QString baseFile, deltaFile;
352 stream >> baseFile >> deltaFile; 352 stream >> baseFile >> deltaFile;
353 if ( !QFile::exists( baseFile ) ) { 353 if ( !QFile::exists( baseFile ) ) {
354 QFile f( baseFile ); 354 QFile f( baseFile );
355 f.open( IO_WriteOnly ); 355 f.open( IO_WriteOnly );
356 f.close(); 356 f.close();
357 } 357 }
358 QRsync::applyDiff( baseFile, deltaFile ); 358 QRsync::applyDiff( baseFile, deltaFile );
359#ifndef QT_NO_COP 359#ifndef QT_NO_COP
360 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); 360 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" );
361 e << baseFile; 361 e << baseFile;
362#endif 362#endif
363 } else if ( msg == "rdiffCleanup()" ) { 363 } else if ( msg == "rdiffCleanup()" ) {
364 mkdir( "/tmp/rdiff" ); 364 mkdir( "/tmp/rdiff" );
365 QDir dir; 365 QDir dir;
366 dir.setPath( "/tmp/rdiff" ); 366 dir.setPath( "/tmp/rdiff" );
367 QStringList entries = dir.entryList(); 367 QStringList entries = dir.entryList();
368 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) 368 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it )
369 dir.remove( *it ); 369 dir.remove( *it );
370 } else if ( msg == "sendHandshakeInfo()" ) { 370 } else if ( msg == "sendHandshakeInfo()" ) {
371 QString home = getenv( "HOME" ); 371 QString home = getenv( "HOME" );
372#ifndef QT_NO_COP 372#ifndef QT_NO_COP
373 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); 373 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" );
374 e << home; 374 e << home;
375 int locked = (int) ServerApplication::screenLocked(); 375 int locked = (int) ServerApplication::screenLocked();
376 e << locked; 376 e << locked;
377#endif 377#endif
378 378
379 } 379 }
380 /* 380 /*
381 * QtopiaDesktop relies on the major number 381 * QtopiaDesktop relies on the major number
382 * to start with 1. We're at 0.9 382 * to start with 1. We're at 0.9
383 * so wee need to fake at least 1.4 to be able 383 * so wee need to fake at least 1.4 to be able
384 * to sync with QtopiaDesktop1.6 384 * to sync with QtopiaDesktop1.6
385 */ 385 */
386 else if ( msg == "sendVersionInfo()" ) { 386 else if ( msg == "sendVersionInfo()" ) {
387 QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" ); 387 QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" );
388 /* ### FIXME Architecture ### */ 388 /* ### FIXME Architecture ### */
389 e << QString::fromLatin1("1.7") << "Uncustomized Device"; 389 e << QString::fromLatin1("1.7") << "Uncustomized Device";
390 } else if ( msg == "sendCardInfo()" ) { 390 } else if ( msg == "sendCardInfo()" ) {
391#ifndef QT_NO_COP 391#ifndef QT_NO_COP
392 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); 392 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" );
393#endif 393#endif
394 storage->update(); 394 storage->update();
395 const QList<FileSystem> &fs = storage->fileSystems(); 395 const QList<FileSystem> &fs = storage->fileSystems();
396 QListIterator<FileSystem> it ( fs ); 396 QListIterator<FileSystem> it ( fs );
397 QString s; 397 QString s;
398 QString homeDir = getenv("HOME"); 398 QString homeDir = getenv("HOME");
399 QString homeFs, homeFsPath; 399 QString homeFs, homeFsPath;
400 for ( ; it.current(); ++it ) { 400 for ( ; it.current(); ++it ) {
401 int k4 = (*it)->blockSize()/256; 401 int k4 = (*it)->blockSize()/256;
402 if ( (*it)->isRemovable() ) { 402 if ( (*it)->isRemovable() ) {
403 s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr 403 s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr
404 + QString::number( (*it)->availBlocks() * k4/4 ) 404 + QString::number( (*it)->availBlocks() * k4/4 )
405 + "K " + (*it)->options() + ";"; 405 + "K " + (*it)->options() + ";";
406 } else if ( homeDir.contains( (*it)->path() ) && 406 } else if ( homeDir.contains( (*it)->path() ) &&
407 (*it)->path().length() > homeFsPath.length() ) { 407 (*it)->path().length() > homeFsPath.length() ) {
408 homeFsPath = (*it)->path(); 408 homeFsPath = (*it)->path();
409 homeFs = 409 homeFs =
410 (*it)->name() + "=" + homeDir + "/Documents " // No tr 410 (*it)->name() + "=" + homeDir + "/Documents " // No tr
411 + QString::number( (*it)->availBlocks() * k4/4 ) 411 + QString::number( (*it)->availBlocks() * k4/4 )
412 + "K " + (*it)->options() + ";"; 412 + "K " + (*it)->options() + ";";
413 } 413 }
414 } 414 }
415 if ( !homeFs.isEmpty() ) 415 if ( !homeFs.isEmpty() )
416 s += homeFs; 416 s += homeFs;
417 417
418#ifndef QT_NO_COP 418#ifndef QT_NO_COP
419 e << s; 419 e << s;
420#endif 420#endif
421 } else if ( msg == "sendSyncDate(QString)" ) { 421 } else if ( msg == "sendSyncDate(QString)" ) {
422 QString app; 422 QString app;
423 stream >> app; 423 stream >> app;
424 Config cfg( "qpe" ); 424 Config cfg( "qpe" );
425 cfg.setGroup("SyncDate"); 425 cfg.setGroup("SyncDate");
426#ifndef QT_NO_COP 426#ifndef QT_NO_COP
427 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); 427 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" );
428 e << app << cfg.readEntry( app ); 428 e << app << cfg.readEntry( app );
429#endif 429#endif
430 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), 430 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(),
431 //cfg.readEntry( app ).latin1() ); 431 //cfg.readEntry( app ).latin1() );
432 } else if ( msg == "setSyncDate(QString,QString)" ) { 432 } else if ( msg == "setSyncDate(QString,QString)" ) {
433 QString app, date; 433 QString app, date;
434 stream >> app >> date; 434 stream >> app >> date;
435 Config cfg( "qpe" ); 435 Config cfg( "qpe" );
436 cfg.setGroup("SyncDate"); 436 cfg.setGroup("SyncDate");
437 cfg.writeEntry( app, date ); 437 cfg.writeEntry( app, date );
438 //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); 438 //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1());
439 } else if ( msg == "startSync(QString)" ) { 439 } else if ( msg == "startSync(QString)" ) {
440 QString what; 440 QString what;
441 stream >> what; 441 stream >> what;
442 delete syncDialog; 442 delete syncDialog;
443 syncDialog = new SyncDialog( this, what ); 443 syncDialog = new SyncDialog( this, what );
444 syncDialog->show(); 444 syncDialog->show();
445 connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); 445 connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) );
446 } else if ( msg == "stopSync()") { 446 } else if ( msg == "stopSync()") {
447 delete syncDialog; 447 delete syncDialog;
448 syncDialog = 0; 448 syncDialog = 0;
449 } else if (msg == "restoreDone(QString)") { 449 } else if (msg == "restoreDone(QString)") {
450 docList->restoreDone(); 450 docList->restoreDone();
451 } else if ( msg == "getAllDocLinks()" ) { 451 } else if ( msg == "getAllDocLinks()" ) {
452 docList->sendAllDocLinks(); 452 docList->sendAllDocLinks();
453 } 453 }
454#ifdef Q_WS_QWS 454#ifdef Q_WS_QWS
455 else if ( msg == "setMouseProto(QString)" ) { 455 else if ( msg == "setMouseProto(QString)" ) {
456 QString mice; 456 QString mice;
457 stream >> mice; 457 stream >> mice;
458 setenv("QWS_MOUSE_PROTO",mice.latin1(),1); 458 setenv("QWS_MOUSE_PROTO",mice.latin1(),1);
459 qwsServer->openMouse(); 459 qwsServer->openMouse();
460 } else if ( msg == "setKeyboard(QString)" ) { 460 } else if ( msg == "setKeyboard(QString)" ) {
461 QString kb; 461 QString kb;
462 stream >> kb; 462 stream >> kb;
463 setenv("QWS_KEYBOARD",kb.latin1(),1); 463 setenv("QWS_KEYBOARD",kb.latin1(),1);
464 qwsServer->openKeyboard(); 464 qwsServer->openKeyboard();
465 465
466 } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) { 466 } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) {
467 int delay, period; 467 int delay, period;
468 stream >> delay >> period; 468 stream >> delay >> period;
469 qwsSetKeyboardAutoRepeat( delay, period ); 469 qwsSetKeyboardAutoRepeat( delay, period );
470 Config cfg( "qpe" ); 470 Config cfg( "qpe" );
471 cfg.setGroup("Keyboard"); 471 cfg.setGroup("Keyboard");
472 cfg.writeEntry( "RepeatDelay", delay ); 472 cfg.writeEntry( "RepeatDelay", delay );
473 cfg.writeEntry( "RepeatPeriod", period ); 473 cfg.writeEntry( "RepeatPeriod", period );
474 } else if ( msg == "setKeyboardLayout(QString)" ) { 474 } else if ( msg == "setKeyboardLayout(QString)" ) {
475 QString kb; 475 QString kb;
476 stream >> kb; 476 stream >> kb;
477 setKeyboardLayout( kb ); 477 setKeyboardLayout( kb );
478 Config cfg( "qpe" ); 478 Config cfg( "qpe" );
479 cfg.setGroup("Keyboard"); 479 cfg.setGroup("Keyboard");
480 cfg.writeEntry( "Layout", kb ); 480 cfg.writeEntry( "Layout", kb );
481 } else if ( msg == "autoStart(QString)" ) { 481 } else if ( msg == "autoStart(QString)" ) {
482 QString appName; 482 QString appName;
483 stream >> appName; 483 stream >> appName;
484 Config cfg( "autostart" ); 484 Config cfg( "autostart" );
485 cfg.setGroup( "AutoStart" ); 485 cfg.setGroup( "AutoStart" );
486 if ( appName.compare("clear") == 0){ 486 if ( appName.compare("clear") == 0){
487 cfg.writeEntry("Apps", ""); 487 cfg.writeEntry("Apps", "");
488 } 488 }
489 } else if ( msg == "autoStart(QString,QString)" ) { 489 } else if ( msg == "autoStart(QString,QString)" ) {
490 QString modifier, appName; 490 QString modifier, appName;
491 stream >> modifier >> appName; 491 stream >> modifier >> appName;
492 Config cfg( "autostart" ); 492 Config cfg( "autostart" );
493 cfg.setGroup( "AutoStart" ); 493 cfg.setGroup( "AutoStart" );
494 if ( modifier.compare("add") == 0 ){ 494 if ( modifier.compare("add") == 0 ){
495 // only add if appname is entered 495 // only add if appname is entered
496 if (!appName.isEmpty()) { 496 if (!appName.isEmpty()) {
497 cfg.writeEntry("Apps", appName); 497 cfg.writeEntry("Apps", appName);
498 } 498 }
499 } else if (modifier.compare("remove") == 0 ) { 499 } else if (modifier.compare("remove") == 0 ) {
500 // need to change for multiple entries 500 // need to change for multiple entries
501 // actually remove is right now simular to clear, but in future there 501 // actually remove is right now simular to clear, but in future there
502 // should be multiple apps in autostart possible. 502 // should be multiple apps in autostart possible.
503 QString checkName; 503 QString checkName;
504 checkName = cfg.readEntry("Apps", ""); 504 checkName = cfg.readEntry("Apps", "");
505 if (checkName == appName) { 505 if (checkName == appName) {
506 cfg.writeEntry("Apps", ""); 506 cfg.writeEntry("Apps", "");
507 } 507 }
508 } 508 }
509 // case the autostart feature should be delayed 509 // case the autostart feature should be delayed
510 } else if ( msg == "autoStart(QString,QString,QString)") { 510 } else if ( msg == "autoStart(QString,QString,QString)") {
511 QString modifier, appName, delay; 511 QString modifier, appName, delay;
512 stream >> modifier >> appName >> delay; 512 stream >> modifier >> appName >> delay;
513 Config cfg( "autostart" ); 513 Config cfg( "autostart" );
514 514
515 cfg.setGroup( "AutoStart" ); 515 cfg.setGroup( "AutoStart" );
516 if ( modifier.compare("add") == 0 ){ 516 if ( modifier.compare("add") == 0 ){
517 // only add it appname is entered 517 // only add it appname is entered
518 if (!appName.isEmpty()) { 518 if (!appName.isEmpty()) {
519 cfg.writeEntry("Apps", appName); 519 cfg.writeEntry("Apps", appName);
520 cfg.writeEntry("Delay", delay); 520 cfg.writeEntry("Delay", delay);
521 } 521 }
522 } else { 522 } else {
523 } 523 }
524 } 524 }
525#endif 525#endif
526} 526}
527 527
528void Server::receiveTaskBar(const QCString &msg, const QByteArray &data) 528void Server::receiveTaskBar(const QCString &msg, const QByteArray &data)
529{ 529{
530 QDataStream stream( data, IO_ReadOnly ); 530 QDataStream stream( data, IO_ReadOnly );
531 531
532 if ( msg == "reloadApps()" ) { 532 if ( msg == "reloadApps()" ) {
533 docList->reloadAppLnks(); 533 docList->reloadAppLnks();
534 } else if ( msg == "soundAlarm()" ) { 534 } else if ( msg == "soundAlarm()" ) {
535 ServerApplication::soundAlarm(); 535 ServerApplication::soundAlarm();
536 } 536 }
537 else if ( msg == "setLed(int,bool)" ) { 537 else if ( msg == "setLed(int,bool)" ) {
538 int led, status; 538 int led, status;
539 stream >> led >> status; 539 stream >> led >> status;
540 540
541 QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); 541 QValueList <OLed> ll = ODevice::inst ( )-> ledList ( );
542 if ( ll. count ( )){ 542 if ( ll. count ( )){
543 OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; 543 OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0];
544 bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); 544 bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow );
545 545
546 ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); 546 ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off );
547 } 547 }
548 } 548 }
549} 549}
550 550
551void Server::cancelSync() 551void Server::cancelSync()
552{ 552{
553#ifndef QT_NO_COP 553#ifndef QT_NO_COP
554 QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); 554 QCopEnvelope e( "QPE/Desktop", "cancelSync()" );
555#endif 555#endif
556 delete syncDialog; 556 delete syncDialog;
557 syncDialog = 0; 557 syncDialog = 0;
558} 558}
559 559
560bool Server::mkdir(const QString &localPath) 560bool Server::mkdir(const QString &localPath)
561{ 561{
562 QDir fullDir(localPath); 562 QDir fullDir(localPath);
563 if (fullDir.exists()) 563 if (fullDir.exists())
564 return true; 564 return true;
565 565
566 // at this point the directory doesn't exist 566 // at this point the directory doesn't exist
567 // go through the directory tree and start creating the direcotories 567 // go through the directory tree and start creating the direcotories
568 // that don't exist; if we can't create the directories, return false 568 // that don't exist; if we can't create the directories, return false
569 569
570 QString dirSeps = "/"; 570 QString dirSeps = "/";
571 int dirIndex = localPath.find(dirSeps); 571 int dirIndex = localPath.find(dirSeps);
572 QString checkedPath; 572 QString checkedPath;
573 573
574 // didn't find any seps; weird, use the cur dir instead 574 // didn't find any seps; weird, use the cur dir instead
575 if (dirIndex == -1) { 575 if (dirIndex == -1) {
576 //qDebug("No seperators found in path %s", localPath.latin1()); 576 //qDebug("No seperators found in path %s", localPath.latin1());
577 checkedPath = QDir::currentDirPath(); 577 checkedPath = QDir::currentDirPath();
578 } 578 }
579 579
580 while (checkedPath != localPath) { 580 while (checkedPath != localPath) {
581 // no more seperators found, use the local path 581 // no more seperators found, use the local path
582 if (dirIndex == -1) 582 if (dirIndex == -1)
583 checkedPath = localPath; 583 checkedPath = localPath;
584 else { 584 else {
585 // the next directory to check 585 // the next directory to check
586 checkedPath = localPath.left(dirIndex) + "/"; 586 checkedPath = localPath.left(dirIndex) + "/";
587 // advance the iterator; the next dir seperator 587 // advance the iterator; the next dir seperator
588 dirIndex = localPath.find(dirSeps, dirIndex+1); 588 dirIndex = localPath.find(dirSeps, dirIndex+1);
589 } 589 }
590 590
591 QDir checkDir(checkedPath); 591 QDir checkDir(checkedPath);
592 if (!checkDir.exists()) { 592 if (!checkDir.exists()) {
593 //qDebug("mkdir making dir %s", checkedPath.latin1()); 593 //qDebug("mkdir making dir %s", checkedPath.latin1());
594 594
595 if (!checkDir.mkdir(checkedPath)) { 595 if (!checkDir.mkdir(checkedPath)) {
596 qDebug("Unable to make directory %s", checkedPath.latin1()); 596 qDebug("Unable to make directory %s", checkedPath.latin1());
597 return FALSE; 597 return FALSE;
598 } 598 }
599 } 599 }
600 600
601 } 601 }
602 return TRUE; 602 return TRUE;
603} 603}
604 604
605void Server::styleChange( QStyle &s ) 605void Server::styleChange( QStyle &s )
606{ 606{
607 QWidget::styleChange( s ); 607 QWidget::styleChange( s );
608} 608}
609 609
610void Server::startTransferServer() 610void Server::startTransferServer()
611{ 611{
612 if ( !qcopBridge ) { 612 if ( !qcopBridge ) {
613 // start qcop bridge server 613 // start qcop bridge server
614 qcopBridge = new QCopBridge( 4243 ); 614 qcopBridge = new QCopBridge( 4243 );
615 if ( qcopBridge->ok() ) { 615 if ( qcopBridge->ok() ) {
616 // ... OK 616 // ... OK
617 connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress &)), 617 connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress &)),
618 this, SLOT(syncConnectionClosed(const QHostAddress &)) ); 618 this, SLOT(syncConnectionClosed(const QHostAddress &)) );
619 } else { 619 } else {
620 delete qcopBridge; 620 delete qcopBridge;
621 qcopBridge = 0; 621 qcopBridge = 0;
622 } 622 }
623 } 623 }
624 if ( !transferServer ) { 624 if ( !transferServer ) {
625 // start transfer server 625 // start transfer server
626 transferServer = new TransferServer( 4242 ); 626 transferServer = new TransferServer( 4242 );
627 if ( transferServer->ok() ) { 627 if ( transferServer->ok() ) {
628 // ... OK 628 // ... OK
629 } else { 629 } else {
630 delete transferServer; 630 delete transferServer;
631 transferServer = 0; 631 transferServer = 0;
632 } 632 }
633 } 633 }
634 if ( !transferServer || !qcopBridge ) 634 if ( !transferServer || !qcopBridge )
635 tid_xfer = startTimer( 2000 ); 635 tid_xfer = startTimer( 2000 );
636} 636}
637 637
638void Server::timerEvent( QTimerEvent *e ) 638void Server::timerEvent( QTimerEvent *e )
639{ 639{
640 if ( e->timerId() == tid_xfer ) { 640 if ( e->timerId() == tid_xfer ) {
641 killTimer( tid_xfer ); 641 killTimer( tid_xfer );
642 tid_xfer = 0; 642 tid_xfer = 0;
643 startTransferServer(); 643 startTransferServer();
644 } 644 }
645 /* ### FIXME today startin */ 645 /* ### FIXME today startin */
646#if 0 646#if 0
647 else if ( e->timerId() == tid_today ) { 647 else if ( e->timerId() == tid_today ) {
648 QDate today = QDate::currentDate(); 648 QDate today = QDate::currentDate();
649 if ( today != last_today_show ) { 649 if ( today != last_today_show ) {
650 last_today_show = today; 650 last_today_show = today;
651 Config cfg("today"); 651 Config cfg("today");
652 cfg.setGroup("Start"); 652 cfg.setGroup("Start");
653#ifndef QPE_DEFAULT_TODAY_MODE 653#ifndef QPE_DEFAULT_TODAY_MODE
654#define QPE_DEFAULT_TODAY_MODE "Never" 654#define QPE_DEFAULT_TODAY_MODE "Never"
655#endif 655#endif
656 if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) { 656 if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) {
657 QCopEnvelope env(Service::channel("today"),"raise()"); 657 QCopEnvelope env(Service::channel("today"),"raise()");
658 } 658 }
659 } 659 }
660 } 660 }
661#endif 661#endif
662} 662}
663 663
664void Server::terminateServers() 664void Server::terminateServers()
665{ 665{
666 delete transferServer; 666 delete transferServer;
667 delete qcopBridge; 667 delete qcopBridge;
668 transferServer = 0; 668 transferServer = 0;
669 qcopBridge = 0; 669 qcopBridge = 0;
670} 670}
671 671
672void Server::syncConnectionClosed( const QHostAddress & ) 672void Server::syncConnectionClosed( const QHostAddress & )
673{ 673{
674 qDebug( "Lost sync connection" ); 674 qDebug( "Lost sync connection" );
675 delete syncDialog; 675 delete syncDialog;
676 syncDialog = 0; 676 syncDialog = 0;
677} 677}
678 678
679void Server::pokeTimeMonitors() 679void Server::pokeTimeMonitors()
680{ 680{
681#if 0 681#if 0
682 // inform all TimeMonitors 682 // inform all TimeMonitors
683 QStrList tms = Service::channels("TimeMonitor"); 683 QStrList tms = Service::channels("TimeMonitor");
684 for (const char* ch = tms.first(); ch; ch=tms.next()) { 684 for (const char* ch = tms.first(); ch; ch=tms.next()) {
685 QString t = getenv("TZ"); 685 QString t = getenv("TZ");
686 QCopEnvelope e(ch, "timeChange(QString)"); 686 QCopEnvelope e(ch, "timeChange(QString)");
687 e << t; 687 e << t;
688 } 688 }
689#endif 689#endif
690} 690}
691 691
692void Server::applicationLaunched(int, const QString &app) 692void Server::applicationLaunched(int, const QString &app)
693{ 693{
694 serverGui->applicationStateChanged( app, ServerInterface::Launching ); 694 serverGui->applicationStateChanged( app, ServerInterface::Launching );
695} 695}
696 696
697void Server::applicationTerminated(int pid, const QString &app) 697void Server::applicationTerminated(int pid, const QString &app)
698{ 698{
699 serverGui->applicationStateChanged( app, ServerInterface::Terminated ); 699 serverGui->applicationStateChanged( app, ServerInterface::Terminated );
700#if 0 700#if 0
701 tsmMonitor->applicationTerminated( pid ); 701 tsmMonitor->applicationTerminated( pid );
702#endif 702#endif
703} 703}
704 704
705void Server::applicationConnected(const QString &app) 705void Server::applicationConnected(const QString &app)
706{ 706{
707 serverGui->applicationStateChanged( app, ServerInterface::Running ); 707 serverGui->applicationStateChanged( app, ServerInterface::Running );
708} 708}
709 709
710void Server::storageChanged() 710void Server::storageChanged()
711{ 711{
712 system( "qtopia-update-symlinks" ); 712 system( "qtopia-update-symlinks" );
713 serverGui->storageChanged( storage->fileSystems() ); 713 serverGui->storageChanged( storage->fileSystems() );
714 docList->storageChanged(); 714 docList->storageChanged();
715} 715}
716 716
717 717
718 718
719void Server::preloadApps() 719void Server::preloadApps()
720{ 720{
721 Config cfg("Launcher"); 721 Config cfg("Launcher");
722 cfg.setGroup("Preload"); 722 cfg.setGroup("Preload");
723 QStringList apps = cfg.readListEntry("Apps",','); 723 QStringList apps = cfg.readListEntry("Apps",',');
724 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { 724 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) {
725#ifndef QT_NO_COP 725#ifndef QT_NO_COP
726 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); 726 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()");
727#endif 727#endif
728 } 728 }
729} 729}
730 730
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp
index 69e083d..23a7f95 100644
--- a/core/launcher/serverapp.cpp
+++ b/core/launcher/serverapp.cpp
@@ -1,801 +1,801 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2003 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 20
21#include "serverapp.h" 21#include "serverapp.h"
22 22
23#include <opie/odevice.h> 23#include <opie/odevice.h>
24 24
25#include <qtopia/password.h> 25#include <qtopia/password.h>
26#include <qtopia/config.h> 26#include <qtopia/config.h>
27#include <qtopia/power.h> 27#include <qtopia/power.h>
28 28
29#ifdef Q_WS_QWS 29#ifdef Q_WS_QWS
30#include <qtopia/qcopenvelope_qws.h> 30#include <qtopia/qcopenvelope_qws.h>
31#endif 31#endif
32#include <qtopia/global.h> 32#include <qtopia/global.h>
33#include <qtopia/custom.h> 33//#include <qtopia/custom.h>
34 34
35#ifdef Q_WS_QWS 35#ifdef Q_WS_QWS
36#include <qgfx_qws.h> 36#include <qgfx_qws.h>
37#endif 37#endif
38#ifdef Q_OS_WIN32 38#ifdef Q_OS_WIN32
39#include <io.h> 39#include <io.h>
40#include <process.h> 40#include <process.h>
41#else 41#else
42#include <unistd.h> 42#include <unistd.h>
43#endif 43#endif
44#include <qmessagebox.h> 44#include <qmessagebox.h>
45#include <qtimer.h> 45#include <qtimer.h>
46#include <qpainter.h> 46#include <qpainter.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qpixmapcache.h> 48#include <qpixmapcache.h>
49 49
50#include <stdlib.h> 50#include <stdlib.h>
51#include "screensaver.h" 51#include "screensaver.h"
52 52
53static ServerApplication *serverApp = 0; 53static ServerApplication *serverApp = 0;
54static int loggedin=0; 54static int loggedin=0;
55 55
56using namespace Opie; 56using namespace Opie;
57 57
58QCopKeyRegister::QCopKeyRegister() 58QCopKeyRegister::QCopKeyRegister()
59 : m_keyCode( 0 ) { 59 : m_keyCode( 0 ) {
60} 60}
61 61
62QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m ) 62QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m )
63 :m_keyCode( k ), m_channel( c ), m_message( m ) { 63 :m_keyCode( k ), m_channel( c ), m_message( m ) {
64} 64}
65 65
66int QCopKeyRegister::keyCode()const { 66int QCopKeyRegister::keyCode()const {
67 return m_keyCode; 67 return m_keyCode;
68} 68}
69 69
70QCString QCopKeyRegister::channel()const { 70QCString QCopKeyRegister::channel()const {
71 return m_channel; 71 return m_channel;
72} 72}
73 73
74QCString QCopKeyRegister::message()const { 74QCString QCopKeyRegister::message()const {
75 return m_message; 75 return m_message;
76} 76}
77 77
78bool QCopKeyRegister::send() { 78bool QCopKeyRegister::send() {
79 if (m_channel.isNull() ) 79 if (m_channel.isNull() )
80 return false; 80 return false;
81 81
82 QCopEnvelope( m_channel, m_message ); 82 QCopEnvelope( m_channel, m_message );
83 83
84 return true; 84 return true;
85} 85}
86 86
87//--------------------------------------------------------------------------- 87//---------------------------------------------------------------------------
88 88
89/* 89/*
90 Priority is number of alerts that are needed to pop up 90 Priority is number of alerts that are needed to pop up
91 alert. 91 alert.
92 */ 92 */
93class DesktopPowerAlerter : public QMessageBox 93class DesktopPowerAlerter : public QMessageBox
94{ 94{
95 Q_OBJECT 95 Q_OBJECT
96public: 96public:
97 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 97 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
98 : QMessageBox( tr("Battery Status"), tr("Low Battery"), 98 : QMessageBox( tr("Battery Status"), tr("Low Battery"),
99 QMessageBox::Critical, 99 QMessageBox::Critical,
100 QMessageBox::Ok | QMessageBox::Default, 100 QMessageBox::Ok | QMessageBox::Default,
101 QMessageBox::NoButton, QMessageBox::NoButton, 101 QMessageBox::NoButton, QMessageBox::NoButton,
102 parent, name, FALSE ) 102 parent, name, FALSE )
103 { 103 {
104 currentPriority = INT_MAX; 104 currentPriority = INT_MAX;
105 alertCount = 0; 105 alertCount = 0;
106 } 106 }
107 107
108 void alert( const QString &text, int priority ); 108 void alert( const QString &text, int priority );
109 void hideEvent( QHideEvent * ); 109 void hideEvent( QHideEvent * );
110private: 110private:
111 int currentPriority; 111 int currentPriority;
112 int alertCount; 112 int alertCount;
113}; 113};
114 114
115void DesktopPowerAlerter::alert( const QString &text, int priority ) 115void DesktopPowerAlerter::alert( const QString &text, int priority )
116{ 116{
117 alertCount++; 117 alertCount++;
118 if ( alertCount < priority ) 118 if ( alertCount < priority )
119 return; 119 return;
120 if ( priority > currentPriority ) 120 if ( priority > currentPriority )
121 return; 121 return;
122 currentPriority = priority; 122 currentPriority = priority;
123 setText( text ); 123 setText( text );
124 show(); 124 show();
125} 125}
126 126
127 127
128void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 128void DesktopPowerAlerter::hideEvent( QHideEvent *e )
129{ 129{
130 QMessageBox::hideEvent( e ); 130 QMessageBox::hideEvent( e );
131 alertCount = 0; 131 alertCount = 0;
132 currentPriority = INT_MAX; 132 currentPriority = INT_MAX;
133} 133}
134 134
135//--------------------------------------------------------------------------- 135//---------------------------------------------------------------------------
136 136
137KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0) 137KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0)
138{ 138{
139 /* We don't do this cause it would interfere with ODevice */ 139 /* We don't do this cause it would interfere with ODevice */
140#if 0 140#if 0
141 qwsServer->setKeyboardFilter(this); 141 qwsServer->setKeyboardFilter(this);
142#endif 142#endif
143} 143}
144 144
145void KeyFilter::timerEvent(QTimerEvent* e) 145void KeyFilter::timerEvent(QTimerEvent* e)
146{ 146{
147 if ( e->timerId() == held_tid ) { 147 if ( e->timerId() == held_tid ) {
148 killTimer(held_tid); 148 killTimer(held_tid);
149 // button held 149 // button held
150 if ( heldButton ) { 150 if ( heldButton ) {
151 emit activate(heldButton, TRUE); 151 emit activate(heldButton, TRUE);
152 heldButton = 0; 152 heldButton = 0;
153 } 153 }
154 held_tid = 0; 154 held_tid = 0;
155 } 155 }
156} 156}
157 157
158void KeyFilter::registerKey( const QCopKeyRegister& key ) { 158void KeyFilter::registerKey( const QCopKeyRegister& key ) {
159 m_keys.insert( key.keyCode(), key ); 159 m_keys.insert( key.keyCode(), key );
160} 160}
161 161
162void KeyFilter::unregisterKey( const QCopKeyRegister& key ) { 162void KeyFilter::unregisterKey( const QCopKeyRegister& key ) {
163 m_keys.remove( key.keyCode() ); 163 m_keys.remove( key.keyCode() );
164} 164}
165 165
166bool KeyFilter::keyRegistered( int key ) { 166bool KeyFilter::keyRegistered( int key ) {
167 /* 167 /*
168 * Check if we've a key registered 168 * Check if we've a key registered
169 */ 169 */
170 if ( !m_keys[key].send()) 170 if ( !m_keys[key].send())
171 return false; 171 return false;
172 else 172 else
173 return true; 173 return true;
174 174
175} 175}
176 176
177bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) 177bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat)
178{ 178{
179 if ( !loggedin 179 if ( !loggedin
180 // Permitted keys 180 // Permitted keys
181 && keycode != Key_F34 // power 181 && keycode != Key_F34 // power
182 && keycode != Key_F30 // select 182 && keycode != Key_F30 // select
183 && keycode != Key_Enter 183 && keycode != Key_Enter
184 && keycode != Key_Return 184 && keycode != Key_Return
185 && keycode != Key_Space 185 && keycode != Key_Space
186 && keycode != Key_Left 186 && keycode != Key_Left
187 && keycode != Key_Right 187 && keycode != Key_Right
188 && keycode != Key_Up 188 && keycode != Key_Up
189 && keycode != Key_Down ) 189 && keycode != Key_Down )
190 return TRUE; 190 return TRUE;
191 191
192 /* check if it was registered */ 192 /* check if it was registered */
193 if (!db ) { 193 if (!db ) {
194 if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) 194 if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) )
195 return true; 195 return true;
196 }else { 196 }else {
197 197
198 198
199 // First check to see if DeviceButtonManager knows something about this button: 199 // First check to see if DeviceButtonManager knows something about this button:
200 const Opie::ODeviceButton* button = Opie::ODevice::inst()->buttonForKeycode(keycode); 200 const Opie::ODeviceButton* button = Opie::ODevice::inst()->buttonForKeycode(keycode);
201 if (button && !autoRepeat) { 201 if (button && !autoRepeat) {
202 if ( held_tid ) { 202 if ( held_tid ) {
203 killTimer(held_tid); 203 killTimer(held_tid);
204 held_tid = 0; 204 held_tid = 0;
205 } 205 }
206 if ( button->heldAction().isNull() ) { 206 if ( button->heldAction().isNull() ) {
207 if ( press ) 207 if ( press )
208 emit activate(button, FALSE); 208 emit activate(button, FALSE);
209 } else if ( press ) { 209 } else if ( press ) {
210 heldButton = button; 210 heldButton = button;
211 held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); 211 held_tid = startTimer( ODevice::inst ()->buttonHoldTime () );
212 } else if ( heldButton ) { 212 } else if ( heldButton ) {
213 heldButton = 0; 213 heldButton = 0;
214 emit activate(button, FALSE); 214 emit activate(button, FALSE);
215 } 215 }
216 QWSServer::screenSaverActivate(FALSE); 216 QWSServer::screenSaverActivate(FALSE);
217 return TRUE; 217 return TRUE;
218 } 218 }
219 return false; 219 return false;
220 } 220 }
221 if ( keycode == HardKey_Suspend ) { 221 if ( keycode == HardKey_Suspend ) {
222 if ( press ) emit power(); 222 if ( press ) emit power();
223 return TRUE; 223 return TRUE;
224 } 224 }
225 if ( keycode == HardKey_Backlight ) { 225 if ( keycode == HardKey_Backlight ) {
226 if ( press ) emit backlight(); 226 if ( press ) emit backlight();
227 return TRUE; 227 return TRUE;
228 } 228 }
229 if ( keycode == Key_F32 ) { 229 if ( keycode == Key_F32 ) {
230#ifndef QT_NO_COP 230#ifndef QT_NO_COP
231 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); 231 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" );
232#endif 232#endif
233 return TRUE; 233 return TRUE;
234 } 234 }
235 if ( keycode == Key_F31 ) { 235 if ( keycode == Key_F31 ) {
236 if ( press ) emit symbol(); 236 if ( press ) emit symbol();
237 QWSServer::screenSaverActivate(FALSE); 237 QWSServer::screenSaverActivate(FALSE);
238 return TRUE; 238 return TRUE;
239 } 239 }
240 240
241 if ( keycode == Key_NumLock ) 241 if ( keycode == Key_NumLock )
242 if ( press ) emit numLockStateToggle(); 242 if ( press ) emit numLockStateToggle();
243 243
244 if ( keycode == Key_CapsLock ) 244 if ( keycode == Key_CapsLock )
245 if ( press ) emit capsLockStateToggle(); 245 if ( press ) emit capsLockStateToggle();
246 246
247 if ( serverApp ) 247 if ( serverApp )
248 serverApp->keyClick(keycode,press,autoRepeat); 248 serverApp->keyClick(keycode,press,autoRepeat);
249 249
250 return FALSE; 250 return FALSE;
251} 251}
252 252
253enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; 253enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown;
254 254
255#if defined(QPE_HAVE_MEMALERTER) 255#if defined(QPE_HAVE_MEMALERTER)
256QPE_MEMALERTER_IMPL 256QPE_MEMALERTER_IMPL
257#endif 257#endif
258 258
259 259
260 260
261//--------------------------------------------------------------------------- 261//---------------------------------------------------------------------------
262 262
263bool ServerApplication::doRestart = FALSE; 263bool ServerApplication::doRestart = FALSE;
264bool ServerApplication::allowRestart = TRUE; 264bool ServerApplication::allowRestart = TRUE;
265 265
266void ServerApplication::switchLCD( bool on ) { 266void ServerApplication::switchLCD( bool on ) {
267 if ( !qApp ) 267 if ( !qApp )
268 return; 268 return;
269 269
270 ServerApplication *dapp = ServerApplication::me() ; 270 ServerApplication *dapp = ServerApplication::me() ;
271 271
272 if ( !dapp-> m_screensaver ) 272 if ( !dapp-> m_screensaver )
273 return; 273 return;
274 274
275 if ( on ) { 275 if ( on ) {
276 dapp-> m_screensaver-> setDisplayState ( true ); 276 dapp-> m_screensaver-> setDisplayState ( true );
277 dapp-> m_screensaver-> setBacklight ( -3 ); 277 dapp-> m_screensaver-> setBacklight ( -3 );
278 }else 278 }else
279 dapp-> m_screensaver-> setDisplayState ( false ); 279 dapp-> m_screensaver-> setDisplayState ( false );
280 280
281 281
282} 282}
283 283
284ServerApplication::ServerApplication( int& argc, char **argv, Type t ) 284ServerApplication::ServerApplication( int& argc, char **argv, Type t )
285 : QPEApplication( argc, argv, t ) 285 : QPEApplication( argc, argv, t )
286{ 286{
287 287
288 288
289 // We know we'll have lots of cached pixmaps due to App/DocLnks 289 // We know we'll have lots of cached pixmaps due to App/DocLnks
290 QPixmapCache::setCacheLimit(512); 290 QPixmapCache::setCacheLimit(512);
291 291
292 m_ps = new PowerStatus; 292 m_ps = new PowerStatus;
293 m_ps_last = new PowerStatus; 293 m_ps_last = new PowerStatus;
294 pa = new DesktopPowerAlerter( 0 ); 294 pa = new DesktopPowerAlerter( 0 );
295 295
296 m_apm_timer = new QTimer( this ); 296 m_apm_timer = new QTimer( this );
297 connect(m_apm_timer, SIGNAL( timeout() ), 297 connect(m_apm_timer, SIGNAL( timeout() ),
298 this, SLOT( apmTimeout() ) ); 298 this, SLOT( apmTimeout() ) );
299 299
300 reloadPowerWarnSettings(); 300 reloadPowerWarnSettings();
301 301
302 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 302 QCopChannel *channel = new QCopChannel( "QPE/System", this );
303 connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), 303 connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ),
304 this, SLOT(systemMessage(const QCString&, const QByteArray& ) ) ); 304 this, SLOT(systemMessage(const QCString&, const QByteArray& ) ) );
305 305
306 channel = new QCopChannel("QPE/Launcher", this ); 306 channel = new QCopChannel("QPE/Launcher", this );
307 connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), 307 connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ),
308 this, SLOT(launcherMessage( const QCString&, const QByteArray& ) ) ); 308 this, SLOT(launcherMessage( const QCString&, const QByteArray& ) ) );
309 309
310 m_screensaver = new OpieScreenSaver(); 310 m_screensaver = new OpieScreenSaver();
311 m_screensaver->setInterval( -1 ); 311 m_screensaver->setInterval( -1 );
312 QWSServer::setScreenSaver( m_screensaver ); 312 QWSServer::setScreenSaver( m_screensaver );
313 313
314 connect( qApp, SIGNAL( volumeChanged( bool ) ), 314 connect( qApp, SIGNAL( volumeChanged( bool ) ),
315 this, SLOT( rereadVolumes() ) ); 315 this, SLOT( rereadVolumes() ) );
316 316
317 317
318 /* ### PluginLoader libqtopia SafeMode */ 318 /* ### PluginLoader libqtopia SafeMode */
319#if 0 319#if 0
320 if ( PluginLoader::inSafeMode() ) 320 if ( PluginLoader::inSafeMode() )
321 QTimer::singleShot(500, this, SLOT(showSafeMode()) ); 321 QTimer::singleShot(500, this, SLOT(showSafeMode()) );
322 QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); 322 QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) );
323#endif 323#endif
324 324
325 kf = new KeyFilter(this); 325 kf = new KeyFilter(this);
326 326
327 connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); 327 connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) );
328 connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); 328 connect( kf, SIGNAL(power()), this, SIGNAL(power()) );
329 connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); 329 connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) );
330 connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); 330 connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol()));
331 connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); 331 connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle()));
332 connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); 332 connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle()));
333 connect( kf, SIGNAL(activate(const Opie::ODeviceButton*,bool)), 333 connect( kf, SIGNAL(activate(const Opie::ODeviceButton*,bool)),
334 this,SIGNAL(activate(const Opie::ODeviceButton*,bool))); 334 this,SIGNAL(activate(const Opie::ODeviceButton*,bool)));
335 335
336 336
337 connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); 337 connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) );
338 338
339 connect( this, SIGNAL(power() ), 339 connect( this, SIGNAL(power() ),
340 SLOT(togglePower() ) ); 340 SLOT(togglePower() ) );
341 341
342 rereadVolumes(); 342 rereadVolumes();
343 343
344 serverApp = this; 344 serverApp = this;
345 345
346 apmTimeout(); 346 apmTimeout();
347 grabKeyboard(); 347 grabKeyboard();
348 348
349 /* make sure the event filter is installed */ 349 /* make sure the event filter is installed */
350 const Opie::ODeviceButton* but = Opie::ODevice::inst()->buttonForKeycode( -1 ); 350 const Opie::ODeviceButton* but = Opie::ODevice::inst()->buttonForKeycode( -1 );
351} 351}
352 352
353 353
354ServerApplication::~ServerApplication() 354ServerApplication::~ServerApplication()
355{ 355{
356 ungrabKeyboard(); 356 ungrabKeyboard();
357 357
358 358
359 delete pa; 359 delete pa;
360 delete m_ps; 360 delete m_ps;
361 delete m_ps_last; 361 delete m_ps_last;
362} 362}
363 363
364void ServerApplication::apmTimeout() { 364void ServerApplication::apmTimeout() {
365 serverApp-> checkMemory( ); // in case no events are generated 365 serverApp-> checkMemory( ); // in case no events are generated
366 *m_ps_last = *m_ps; 366 *m_ps_last = *m_ps;
367 *m_ps = PowerStatusManager::readStatus(); 367 *m_ps = PowerStatusManager::readStatus();
368 368
369 if ( m_ps->acStatus() != m_ps_last-> acStatus() ) 369 if ( m_ps->acStatus() != m_ps_last-> acStatus() )
370 m_screensaver-> powerStatusChanged( *m_ps ); 370 m_screensaver-> powerStatusChanged( *m_ps );
371 371
372 if ( m_ps->acStatus() == PowerStatus::Online ) 372 if ( m_ps->acStatus() == PowerStatus::Online )
373 return; 373 return;
374 374
375 int bat = m_ps-> batteryPercentRemaining(); 375 int bat = m_ps-> batteryPercentRemaining();
376 376
377 if ( bat < m_ps_last-> batteryPercentRemaining() ) { 377 if ( bat < m_ps_last-> batteryPercentRemaining() ) {
378 if ( bat <= m_powerCritical ) 378 if ( bat <= m_powerCritical )
379 pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 ); 379 pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 );
380 else if ( bat <= m_powerVeryLow ) 380 else if ( bat <= m_powerVeryLow )
381 pa->alert( tr( "Battery is running very low. "), 2 ); 381 pa->alert( tr( "Battery is running very low. "), 2 );
382 } 382 }
383 if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) 383 if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow )
384 pa->alert( tr("The Back-up battery is very low.\nPlease charge the back-up battery." ), 2); 384 pa->alert( tr("The Back-up battery is very low.\nPlease charge the back-up battery." ), 2);
385 385
386} 386}
387 387
388void ServerApplication::systemMessage( const QCString& msg, 388void ServerApplication::systemMessage( const QCString& msg,
389 const QByteArray& data ) { 389 const QByteArray& data ) {
390 QDataStream stream ( data, IO_ReadOnly ); 390 QDataStream stream ( data, IO_ReadOnly );
391 391
392 if ( msg == "setScreenSaverInterval(int)" ) { 392 if ( msg == "setScreenSaverInterval(int)" ) {
393 int time; 393 int time;
394 stream >> time; 394 stream >> time;
395 m_screensaver-> setInterval( time ); 395 m_screensaver-> setInterval( time );
396 } 396 }
397 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { 397 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
398 int t1, t2, t3; 398 int t1, t2, t3;
399 stream >> t1 >> t2 >> t3; 399 stream >> t1 >> t2 >> t3;
400 m_screensaver-> setIntervals( t1, t2, t3 ); 400 m_screensaver-> setIntervals( t1, t2, t3 );
401 } 401 }
402 else if ( msg == "setBacklight(int)" ) { 402 else if ( msg == "setBacklight(int)" ) {
403 int bright; 403 int bright;
404 stream >> bright; 404 stream >> bright;
405 m_screensaver-> setBacklight( bright ); 405 m_screensaver-> setBacklight( bright );
406 } 406 }
407 else if ( msg == "setScreenSaverMode(int)" ) { 407 else if ( msg == "setScreenSaverMode(int)" ) {
408 int mode; 408 int mode;
409 stream >> mode; 409 stream >> mode;
410 m_screensaver-> setMode ( mode ); 410 m_screensaver-> setMode ( mode );
411 } 411 }
412 else if ( msg == "reloadPowerWarnSettings()" ) { 412 else if ( msg == "reloadPowerWarnSettings()" ) {
413 reloadPowerWarnSettings(); 413 reloadPowerWarnSettings();
414 } 414 }
415 else if ( msg == "setDisplayState(int)" ) { 415 else if ( msg == "setDisplayState(int)" ) {
416 int state; 416 int state;
417 stream >> state; 417 stream >> state;
418 m_screensaver-> setDisplayState ( state != 0 ); 418 m_screensaver-> setDisplayState ( state != 0 );
419 } 419 }
420 else if ( msg == "suspend()" ) { 420 else if ( msg == "suspend()" ) {
421 emit power(); 421 emit power();
422 } 422 }
423 else if ( msg == "sendBusinessCard()" ) { 423 else if ( msg == "sendBusinessCard()" ) {
424 QString card = ::getenv ( "HOME" ); 424 QString card = ::getenv ( "HOME" );
425 card += "/Applications/addressbook/businesscard.vcf"; 425 card += "/Applications/addressbook/businesscard.vcf";
426 426
427 if ( QFile::exists( card ) ) { 427 if ( QFile::exists( card ) ) {
428 QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); 428 QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" );
429 QString mimetype = "text/x-vCard"; 429 QString mimetype = "text/x-vCard";
430 e << tr( "business card" ) << card << mimetype; 430 e << tr( "business card" ) << card << mimetype;
431 } 431 }
432 } 432 }
433} 433}
434 434
435void ServerApplication::reloadPowerWarnSettings ( ) 435void ServerApplication::reloadPowerWarnSettings ( )
436{ 436{
437 Config cfg ( "apm" ); 437 Config cfg ( "apm" );
438 cfg. setGroup ( "Warnings" ); 438 cfg. setGroup ( "Warnings" );
439 439
440 int iv = cfg. readNumEntry ( "checkinterval", 10000 ); 440 int iv = cfg. readNumEntry ( "checkinterval", 10000 );
441 441
442 m_apm_timer-> stop ( ); 442 m_apm_timer-> stop ( );
443 if ( iv ) 443 if ( iv )
444 m_apm_timer-> start ( iv ); 444 m_apm_timer-> start ( iv );
445 445
446 m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); 446 m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 );
447 m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); 447 m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 );
448} 448}
449 449
450void ServerApplication::launcherMessage( const QCString & msg, const QByteArray & data ) 450void ServerApplication::launcherMessage( const QCString & msg, const QByteArray & data )
451{ 451{
452 QDataStream stream ( data, IO_ReadOnly ); 452 QDataStream stream ( data, IO_ReadOnly );
453 453
454 if ( msg == "deviceButton(int,int,int)" ) { 454 if ( msg == "deviceButton(int,int,int)" ) {
455 int keycode, press, autoRepeat; 455 int keycode, press, autoRepeat;
456 stream >> keycode >> press >> autoRepeat; 456 stream >> keycode >> press >> autoRepeat;
457 457
458 kf->checkButtonAction ( true, keycode, press, autoRepeat ); 458 kf->checkButtonAction ( true, keycode, press, autoRepeat );
459 } 459 }
460 else if ( msg == "keyRegister(int,QCString,QCString)" ) { 460 else if ( msg == "keyRegister(int,QCString,QCString)" ) {
461 int k; 461 int k;
462 QCString c, m; 462 QCString c, m;
463 stream >> k >> c >> m; 463 stream >> k >> c >> m;
464 464
465 kf -> registerKey( QCopKeyRegister(k, c, m) ); 465 kf -> registerKey( QCopKeyRegister(k, c, m) );
466 } 466 }
467} 467}
468 468
469 469
470bool ServerApplication::screenLocked() 470bool ServerApplication::screenLocked()
471{ 471{
472 return loggedin == 0; 472 return loggedin == 0;
473} 473}
474 474
475void ServerApplication::login(bool at_poweron) 475void ServerApplication::login(bool at_poweron)
476{ 476{
477 if ( !loggedin ) { 477 if ( !loggedin ) {
478 Global::terminateBuiltin("calibrate"); // No tr 478 Global::terminateBuiltin("calibrate"); // No tr
479 Password::authenticate(at_poweron); 479 Password::authenticate(at_poweron);
480 loggedin=1; 480 loggedin=1;
481#ifndef QT_NO_COP 481#ifndef QT_NO_COP
482 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 482 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
483#endif 483#endif
484 } 484 }
485} 485}
486 486
487#if defined(QPE_HAVE_TOGGLELIGHT) 487#if defined(QPE_HAVE_TOGGLELIGHT)
488#include <qtopia/config.h> 488#include <qtopia/config.h>
489 489
490#include <sys/ioctl.h> 490#include <sys/ioctl.h>
491#include <sys/types.h> 491#include <sys/types.h>
492#include <fcntl.h> 492#include <fcntl.h>
493#include <unistd.h> 493#include <unistd.h>
494#include <errno.h> 494#include <errno.h>
495#include <linux/ioctl.h> 495#include <linux/ioctl.h>
496#include <time.h> 496#include <time.h>
497#endif 497#endif
498 498
499#if 0 499#if 0
500static bool blanked=FALSE; 500static bool blanked=FALSE;
501 501
502static void blankScreen() 502static void blankScreen()
503{ 503{
504#ifdef QWS 504#ifdef QWS
505 QWidget w(0, 0, Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool | Qt::WStyle_StaysOnTop | Qt::WPaintUnclipped); 505 QWidget w(0, 0, Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool | Qt::WStyle_StaysOnTop | Qt::WPaintUnclipped);
506 w.resize( qt_screen->width(), qt_screen->height() ); 506 w.resize( qt_screen->width(), qt_screen->height() );
507 w.move(0, 0); 507 w.move(0, 0);
508 508
509 QPainter p(&w); 509 QPainter p(&w);
510 p.fillRect(w.rect(), QBrush(QColor(255,255,255)) ); 510 p.fillRect(w.rect(), QBrush(QColor(255,255,255)) );
511 p.end(); 511 p.end();
512 w.repaint(); 512 w.repaint();
513 513
514 blanked = TRUE; 514 blanked = TRUE;
515#endif 515#endif
516} 516}
517 517
518static void darkScreen() 518static void darkScreen()
519{ 519{
520 /* ### Screen blanking ODevice */ 520 /* ### Screen blanking ODevice */
521#if 0 521#if 0
522 qpe_setBacklight(0); // force off 522 qpe_setBacklight(0); // force off
523#endif 523#endif
524} 524}
525#endif 525#endif
526 526
527namespace { 527namespace {
528 void execAutoStart(const QDateTime& suspendTime ) { 528 void execAutoStart(const QDateTime& suspendTime ) {
529 QString appName; 529 QString appName;
530 int delay; 530 int delay;
531 QDateTime now = QDateTime::currentDateTime(); 531 QDateTime now = QDateTime::currentDateTime();
532 532
533 Config cfg( "autostart" ); 533 Config cfg( "autostart" );
534 cfg.setGroup( "AutoStart" ); 534 cfg.setGroup( "AutoStart" );
535 appName = cfg.readEntry( "Apps", "" ); 535 appName = cfg.readEntry( "Apps", "" );
536 delay = cfg.readNumEntry( "Delay", 0 ); 536 delay = cfg.readNumEntry( "Delay", 0 );
537 537
538 // If the time between suspend and resume was longer then the 538 // If the time between suspend and resume was longer then the
539 // value saved as delay, start the app 539 // value saved as delay, start the app
540 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { 540 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) {
541 QCopEnvelope e( "QPE/System", "execute(QString)" ); 541 QCopEnvelope e( "QPE/System", "execute(QString)" );
542 e << QString( appName ); 542 e << QString( appName );
543 } 543 }
544 } 544 }
545} 545}
546 546
547 547
548void ServerApplication::togglePower() 548void ServerApplication::togglePower()
549{ 549{
550 static bool excllock = false; 550 static bool excllock = false;
551 551
552 if ( excllock ) 552 if ( excllock )
553 return ; 553 return ;
554 554
555 excllock = true; 555 excllock = true;
556 556
557 bool wasloggedin = loggedin; 557 bool wasloggedin = loggedin;
558 loggedin = 0; 558 loggedin = 0;
559 m_suspendTime = QDateTime::currentDateTime(); 559 m_suspendTime = QDateTime::currentDateTime();
560 560
561#ifdef QWS 561#ifdef QWS
562 562
563 if ( Password::needToAuthenticate ( true ) && qt_screen ) { 563 if ( Password::needToAuthenticate ( true ) && qt_screen ) {
564 // Should use a big black window instead. 564 // Should use a big black window instead.
565 // But this would not show up fast enough 565 // But this would not show up fast enough
566 QGfx *g = qt_screen-> screenGfx ( ); 566 QGfx *g = qt_screen-> screenGfx ( );
567 g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); 567 g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( ));
568 delete g; 568 delete g;
569 } 569 }
570#endif 570#endif
571 571
572 ODevice::inst ( )-> suspend ( ); 572 ODevice::inst ( )-> suspend ( );
573 573
574 ServerApplication::switchLCD ( true ); // force LCD on without slow qcop call 574 ServerApplication::switchLCD ( true ); // force LCD on without slow qcop call
575 QWSServer::screenSaverActivate ( false ); 575 QWSServer::screenSaverActivate ( false );
576 576
577 { 577 {
578 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep 578 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep
579 } 579 }
580 580
581 if ( wasloggedin ) 581 if ( wasloggedin )
582 login ( true ); 582 login ( true );
583 583
584 execAutoStart(m_suspendTime); 584 execAutoStart(m_suspendTime);
585 //qcopBridge->closeOpenConnections(); 585 //qcopBridge->closeOpenConnections();
586 586
587 excllock = false; 587 excllock = false;
588} 588}
589 589
590void ServerApplication::toggleLight() 590void ServerApplication::toggleLight()
591{ 591{
592#ifndef QT_NO_COP 592#ifndef QT_NO_COP
593 QCopEnvelope e("QPE/System", "setBacklight(int)"); 593 QCopEnvelope e("QPE/System", "setBacklight(int)");
594 e << -2; // toggle 594 e << -2; // toggle
595#endif 595#endif
596} 596}
597 597
598 598
599/* 599/*
600 * We still listen to key events but handle them in 600 * We still listen to key events but handle them in
601 * a special class 601 * a special class
602 */ 602 */
603 603
604bool ServerApplication::eventFilter( QObject *o, QEvent *e) { 604bool ServerApplication::eventFilter( QObject *o, QEvent *e) {
605 if ( e->type() != QEvent::KeyPress && 605 if ( e->type() != QEvent::KeyPress &&
606 e->type() != QEvent::KeyRelease ) 606 e->type() != QEvent::KeyRelease )
607 return QPEApplication::eventFilter( o, e ); 607 return QPEApplication::eventFilter( o, e );
608 608
609 QKeyEvent *ke = static_cast<QKeyEvent*>( e ); 609 QKeyEvent *ke = static_cast<QKeyEvent*>( e );
610 if ( kf->checkButtonAction( true, ke->key(), 610 if ( kf->checkButtonAction( true, ke->key(),
611 e->type() == QEvent::KeyPress, 611 e->type() == QEvent::KeyPress,
612 ke-> isAutoRepeat() )) 612 ke-> isAutoRepeat() ))
613 return true; 613 return true;
614 614
615 return QPEApplication::eventFilter( o, e ); 615 return QPEApplication::eventFilter( o, e );
616 616
617} 617}
618 618
619#ifdef Q_WS_QWS 619#ifdef Q_WS_QWS
620bool ServerApplication::qwsEventFilter( QWSEvent *e ) 620bool ServerApplication::qwsEventFilter( QWSEvent *e )
621{ 621{
622 checkMemory(); 622 checkMemory();
623 623
624 if ( e->type == QWSEvent::Mouse ) { 624 if ( e->type == QWSEvent::Mouse ) {
625 QWSMouseEvent *me = (QWSMouseEvent *)e; 625 QWSMouseEvent *me = (QWSMouseEvent *)e;
626 static bool up = TRUE; 626 static bool up = TRUE;
627 if ( me->simpleData.state&LeftButton ) { 627 if ( me->simpleData.state&LeftButton ) {
628 if ( up ) { 628 if ( up ) {
629 up = FALSE; 629 up = FALSE;
630 screenClick(TRUE); 630 screenClick(TRUE);
631 } 631 }
632 } else if ( !up ) { 632 } else if ( !up ) {
633 up = TRUE; 633 up = TRUE;
634 screenClick(FALSE); 634 screenClick(FALSE);
635 } 635 }
636 }else if ( e->type == QWSEvent::Key ) { 636 }else if ( e->type == QWSEvent::Key ) {
637 QWSKeyEvent * ke = static_cast<QWSKeyEvent*>( e ); 637 QWSKeyEvent * ke = static_cast<QWSKeyEvent*>( e );
638 if ( kf->checkButtonAction( false, 638 if ( kf->checkButtonAction( false,
639 ke-> simpleData.keycode, 639 ke-> simpleData.keycode,
640 ke-> simpleData.is_press, 640 ke-> simpleData.is_press,
641 ke-> simpleData.is_auto_repeat ) ) 641 ke-> simpleData.is_auto_repeat ) )
642 return true; 642 return true;
643 } 643 }
644 644
645 return QPEApplication::qwsEventFilter( e ); 645 return QPEApplication::qwsEventFilter( e );
646} 646}
647#endif 647#endif
648 648
649 649
650/* ### FIXME libqtopia Plugin Safe Mode */ 650/* ### FIXME libqtopia Plugin Safe Mode */
651 651
652void ServerApplication::showSafeMode() 652void ServerApplication::showSafeMode()
653{ 653{
654#if 0 654#if 0
655 if ( QMessageBox::warning(0, tr("Safe Mode"), tr("<P>A system startup error occurred, " 655 if ( QMessageBox::warning(0, tr("Safe Mode"), tr("<P>A system startup error occurred, "
656 "and the system is now in Safe Mode. " 656 "and the system is now in Safe Mode. "
657 "Plugins are not loaded in Safe Mode. " 657 "Plugins are not loaded in Safe Mode. "
658 "You can use the Plugin Manager to " 658 "You can use the Plugin Manager to "
659 "disable plugins that cause system error."), tr("OK"), tr("Plugin Manager..."), 0) == 1 ) { 659 "disable plugins that cause system error."), tr("OK"), tr("Plugin Manager..."), 0) == 1 ) {
660 Global::execute( "pluginmanager" ); 660 Global::execute( "pluginmanager" );
661 } 661 }
662#endif 662#endif
663} 663}
664 664
665void ServerApplication::clearSafeMode() 665void ServerApplication::clearSafeMode()
666{ 666{
667#if 0 667#if 0
668 // If we've been running OK for a while then we won't bother going into 668 // If we've been running OK for a while then we won't bother going into
669 // safe mode immediately on the next crash. 669 // safe mode immediately on the next crash.
670 Config cfg( "PluginLoader" ); 670 Config cfg( "PluginLoader" );
671 cfg.setGroup( "Global" ); 671 cfg.setGroup( "Global" );
672 QString mode = cfg.readEntry( "Mode", "Normal" ); 672 QString mode = cfg.readEntry( "Mode", "Normal" );
673 if ( mode == "MaybeSafe" ) { 673 if ( mode == "MaybeSafe" ) {
674 cfg.writeEntry( "Mode", "Normal" ); 674 cfg.writeEntry( "Mode", "Normal" );
675 } 675 }
676#endif 676#endif
677} 677}
678 678
679 679
680void ServerApplication::shutdown() 680void ServerApplication::shutdown()
681{ 681{
682 if ( type() != GuiServer ) 682 if ( type() != GuiServer )
683 return; 683 return;
684 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 684 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
685 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), 685 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)),
686 this, SLOT(shutdown(ShutdownImpl::Type)) ); 686 this, SLOT(shutdown(ShutdownImpl::Type)) );
687 sd->showMaximized(); 687 sd->showMaximized();
688} 688}
689 689
690void ServerApplication::shutdown( ShutdownImpl::Type t ) 690void ServerApplication::shutdown( ShutdownImpl::Type t )
691{ 691{
692 char *opt = 0; 692 char *opt = 0;
693 693
694 switch ( t ) { 694 switch ( t ) {
695 case ShutdownImpl::ShutdownSystem: 695 case ShutdownImpl::ShutdownSystem:
696 opt = "-h"; 696 opt = "-h";
697 // fall through 697 // fall through
698 case ShutdownImpl::RebootSystem: 698 case ShutdownImpl::RebootSystem:
699 if ( opt == 0 ) 699 if ( opt == 0 )
700 opt = "-r"; 700 opt = "-r";
701 701
702 if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 ) 702 if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 )
703 perror("shutdown"); 703 perror("shutdown");
704 // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); 704 // ::syslog ( LOG_ERR, "Erroring execing shutdown\n" );
705 705
706 break; 706 break;
707 case ShutdownImpl::RestartDesktop: 707 case ShutdownImpl::RestartDesktop:
708 restart(); 708 restart();
709 break; 709 break;
710 case ShutdownImpl::TerminateDesktop: 710 case ShutdownImpl::TerminateDesktop:
711 prepareForTermination( FALSE ); 711 prepareForTermination( FALSE );
712 712
713 // This is a workaround for a Qt bug 713 // This is a workaround for a Qt bug
714 // clipboard applet has to stop its poll timer, or Qt/E 714 // clipboard applet has to stop its poll timer, or Qt/E
715 // will hang on quit() right before it emits aboutToQuit() 715 // will hang on quit() right before it emits aboutToQuit()
716 emit aboutToQuit ( ); 716 emit aboutToQuit ( );
717 717
718 quit(); 718 quit();
719 break; 719 break;
720 } 720 }
721} 721}
722 722
723void ServerApplication::restart() 723void ServerApplication::restart()
724{ 724{
725 if ( allowRestart ) { 725 if ( allowRestart ) {
726 726
727 /* 727 /*
728 * Applets and restart is a problem. Some applets delete 728 * Applets and restart is a problem. Some applets delete
729 * their widgets even if ownership gets transfered to the 729 * their widgets even if ownership gets transfered to the
730 * parent (Systray ) but deleting the applet may be unsafe 730 * parent (Systray ) but deleting the applet may be unsafe
731 * as well ( double deletion ). Some have topLevel widgets 731 * as well ( double deletion ). Some have topLevel widgets
732 * and when we dlclose and then delete the widget we will 732 * and when we dlclose and then delete the widget we will
733 * crash and an crash during restart is not nice 733 * crash and an crash during restart is not nice
734 */ 734 */
735#ifdef ALL_APPLETS_ON_THIS_WORLD_ARE_FIXED 735#ifdef ALL_APPLETS_ON_THIS_WORLD_ARE_FIXED
736 /* same as above */ 736 /* same as above */
737 emit aboutToQuit(); 737 emit aboutToQuit();
738 prepareForTermination(TRUE); 738 prepareForTermination(TRUE);
739 doRestart = TRUE; 739 doRestart = TRUE;
740 quit(); 740 quit();
741#else 741#else
742 prepareForTermination( true ); 742 prepareForTermination( true );
743 for ( int fd = 3; fd < 100; fd++ ) 743 for ( int fd = 3; fd < 100; fd++ )
744 close( fd ); 744 close( fd );
745 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); 745 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 );
746 exit( 1 ); 746 exit( 1 );
747#endif 747#endif
748 } 748 }
749} 749}
750 750
751void ServerApplication::rereadVolumes() 751void ServerApplication::rereadVolumes()
752{ 752{
753 Config cfg( "qpe" ); 753 Config cfg( "qpe" );
754 cfg. setGroup ( "Volume" ); 754 cfg. setGroup ( "Volume" );
755 755
756 m_screentap_sound = cfg. readBoolEntry ( "TouchSound" ); 756 m_screentap_sound = cfg. readBoolEntry ( "TouchSound" );
757 m_keyclick_sound = cfg. readBoolEntry ( "KeySound" ); 757 m_keyclick_sound = cfg. readBoolEntry ( "KeySound" );
758 m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" ); 758 m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" );
759} 759}
760 760
761 761
762void ServerApplication::checkMemory() 762void ServerApplication::checkMemory()
763{ 763{
764#if defined(QPE_HAVE_MEMALERTER) 764#if defined(QPE_HAVE_MEMALERTER)
765 static bool ignoreNormal=TRUE; 765 static bool ignoreNormal=TRUE;
766 static bool existingMessage=FALSE; 766 static bool existingMessage=FALSE;
767 767
768 if(existingMessage) 768 if(existingMessage)
769 return; // don't show a second message while still on first 769 return; // don't show a second message while still on first
770 770
771 existingMessage = TRUE; 771 existingMessage = TRUE;
772 switch ( memstate ) { 772 switch ( memstate ) {
773 case MemUnknown: 773 case MemUnknown:
774 break; 774 break;
775 case MemLow: 775 case MemLow:
776 memstate = MemUnknown; 776 memstate = MemUnknown;
777 if ( !recoverMemory() ) { 777 if ( !recoverMemory() ) {
778 QMessageBox::warning( 0 , tr("Memory Status"), 778 QMessageBox::warning( 0 , tr("Memory Status"),
779 tr("Memory Low\nPlease save data.") ); 779 tr("Memory Low\nPlease save data.") );
780 ignoreNormal = FALSE; 780 ignoreNormal = FALSE;
781 } 781 }
782 break; 782 break;
783 case MemNormal: 783 case MemNormal:
784 memstate = MemUnknown; 784 memstate = MemUnknown;
785 if ( !ignoreNormal ) { 785 if ( !ignoreNormal ) {
786 ignoreNormal = TRUE; 786 ignoreNormal = TRUE;
787 QMessageBox::information ( 0 , tr("Memory Status"), 787 QMessageBox::information ( 0 , tr("Memory Status"),
788 "Memory OK" ); 788 "Memory OK" );
789 } 789 }
790 break; 790 break;
791 case MemVeryLow: 791 case MemVeryLow:
792 memstate = MemUnknown; 792 memstate = MemUnknown;
793 QMessageBox::critical( 0 , tr("Memory Status"), 793 QMessageBox::critical( 0 , tr("Memory Status"),
794 tr("Critical Memory Shortage\n" 794 tr("Critical Memory Shortage\n"
795 "Please end this application\n" 795 "Please end this application\n"
796 "immediately.") ); 796 "immediately.") );
797 recoverMemory(); 797 recoverMemory();
798 } 798 }
799 existingMessage = FALSE; 799 existingMessage = FALSE;
800#endif 800#endif
801} 801}
diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp
index 2966168..491a8a3 100644
--- a/core/launcher/taskbar.cpp
+++ b/core/launcher/taskbar.cpp
@@ -1,377 +1,377 @@
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 20
21#include "startmenu.h" 21#include "startmenu.h"
22#include "inputmethods.h" 22#include "inputmethods.h"
23#include "runningappbar.h" 23#include "runningappbar.h"
24#include "systray.h" 24#include "systray.h"
25#include "wait.h" 25#include "wait.h"
26#include "appicons.h" 26#include "appicons.h"
27 27
28#include "taskbar.h" 28#include "taskbar.h"
29#include "server.h" 29#include "server.h"
30 30
31#include <qtopia/config.h> 31#include <qtopia/config.h>
32#include <qtopia/qpeapplication.h> 32#include <qtopia/qpeapplication.h>
33#ifdef QWS 33#ifdef QWS
34#include <qtopia/qcopenvelope_qws.h> 34#include <qtopia/qcopenvelope_qws.h>
35#endif 35#endif
36#include <qtopia/global.h> 36#include <qtopia/global.h>
37#include <qtopia/custom.h> 37//#include <qtopia/custom.h>
38 38
39#include <qlabel.h> 39#include <qlabel.h>
40#include <qlayout.h> 40#include <qlayout.h>
41#include <qtimer.h> 41#include <qtimer.h>
42#ifdef QWS 42#ifdef QWS
43#include <qwindowsystem_qws.h> 43#include <qwindowsystem_qws.h>
44#endif 44#endif
45#include <qwidgetstack.h> 45#include <qwidgetstack.h>
46 46
47#if defined( Q_WS_QWS ) 47#if defined( Q_WS_QWS )
48#include <qwsdisplay_qws.h> 48#include <qwsdisplay_qws.h>
49#include <qgfx_qws.h> 49#include <qgfx_qws.h>
50#endif 50#endif
51 51
52 52
53static bool initNumLock() 53static bool initNumLock()
54{ 54{
55#ifdef QPE_INITIAL_NUMLOCK_STATE 55#ifdef QPE_INITIAL_NUMLOCK_STATE
56 QPE_INITIAL_NUMLOCK_STATE 56 QPE_INITIAL_NUMLOCK_STATE
57#endif 57#endif
58 return FALSE; 58 return FALSE;
59} 59}
60 60
61//--------------------------------------------------------------------------- 61//---------------------------------------------------------------------------
62 62
63class SafeMode : public QWidget 63class SafeMode : public QWidget
64{ 64{
65 Q_OBJECT 65 Q_OBJECT
66public: 66public:
67 SafeMode( QWidget *parent ) : QWidget( parent ), menu(0) 67 SafeMode( QWidget *parent ) : QWidget( parent ), menu(0)
68 { 68 {
69 message = tr("Safe Mode"); 69 message = tr("Safe Mode");
70 QFont f( font() ); 70 QFont f( font() );
71 f.setWeight( QFont::Bold ); 71 f.setWeight( QFont::Bold );
72 setFont( f ); 72 setFont( f );
73 } 73 }
74 74
75 void mousePressEvent( QMouseEvent *); 75 void mousePressEvent( QMouseEvent *);
76 QSize sizeHint() const; 76 QSize sizeHint() const;
77 void paintEvent( QPaintEvent* ); 77 void paintEvent( QPaintEvent* );
78 78
79private slots: 79private slots:
80 void action(int i); 80 void action(int i);
81 81
82private: 82private:
83 QString message; 83 QString message;
84 QPopupMenu *menu; 84 QPopupMenu *menu;
85}; 85};
86 86
87void SafeMode::mousePressEvent( QMouseEvent *) 87void SafeMode::mousePressEvent( QMouseEvent *)
88{ 88{
89 if ( !menu ) { 89 if ( !menu ) {
90 menu = new QPopupMenu(this); 90 menu = new QPopupMenu(this);
91 menu->insertItem( tr("Plugin Manager..."), 0 ); 91 menu->insertItem( tr("Plugin Manager..."), 0 );
92 menu->insertItem( tr("Restart Qtopia"), 1 ); 92 menu->insertItem( tr("Restart Qtopia"), 1 );
93 menu->insertItem( tr("Help..."), 2 ); 93 menu->insertItem( tr("Help..."), 2 );
94 connect(menu, SIGNAL(activated(int)), this, SLOT(action(int))); 94 connect(menu, SIGNAL(activated(int)), this, SLOT(action(int)));
95 } 95 }
96 QPoint curPos = mapToGlobal( QPoint(0,0) ); 96 QPoint curPos = mapToGlobal( QPoint(0,0) );
97 QSize sh = menu->sizeHint(); 97 QSize sh = menu->sizeHint();
98 menu->popup( curPos-QPoint((sh.width()-width())/2,sh.height()) ); 98 menu->popup( curPos-QPoint((sh.width()-width())/2,sh.height()) );
99} 99}
100 100
101void SafeMode::action(int i) 101void SafeMode::action(int i)
102{ 102{
103 switch (i) { 103 switch (i) {
104 case 0: 104 case 0:
105 Global::execute( "pluginmanager" ); 105 Global::execute( "pluginmanager" );
106 break; 106 break;
107 case 1: 107 case 1:
108 Global::restart(); 108 Global::restart();
109 break; 109 break;
110 case 2: 110 case 2:
111 Global::execute( "helpbrowser", "safemode.html" ); 111 Global::execute( "helpbrowser", "safemode.html" );
112 break; 112 break;
113 } 113 }
114} 114}
115 115
116QSize SafeMode::sizeHint() const 116QSize SafeMode::sizeHint() const
117{ 117{
118 QFontMetrics fm = fontMetrics(); 118 QFontMetrics fm = fontMetrics();
119 119
120 return QSize( fm.width(message), fm.height() ); 120 return QSize( fm.width(message), fm.height() );
121} 121}
122 122
123void SafeMode::paintEvent( QPaintEvent* ) 123void SafeMode::paintEvent( QPaintEvent* )
124{ 124{
125 QPainter p(this); 125 QPainter p(this);
126 p.drawText( rect(), AlignCenter, message ); 126 p.drawText( rect(), AlignCenter, message );
127} 127}
128 128
129//--------------------------------------------------------------------------- 129//---------------------------------------------------------------------------
130 130
131class LockKeyState : public QWidget 131class LockKeyState : public QWidget
132{ 132{
133public: 133public:
134 LockKeyState( QWidget *parent ) : 134 LockKeyState( QWidget *parent ) :
135 QWidget(parent), 135 QWidget(parent),
136 nl(initNumLock()), cl(FALSE) 136 nl(initNumLock()), cl(FALSE)
137 { 137 {
138 nl_pm = Resource::loadPixmap("numlock"); 138 nl_pm = Resource::loadPixmap("numlock");
139 cl_pm = Resource::loadPixmap("capslock"); 139 cl_pm = Resource::loadPixmap("capslock");
140 } 140 }
141 QSize sizeHint() const 141 QSize sizeHint() const
142 { 142 {
143 return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1); 143 return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1);
144 } 144 }
145 void toggleNumLockState() 145 void toggleNumLockState()
146 { 146 {
147 nl = !nl; repaint(); 147 nl = !nl; repaint();
148 } 148 }
149 void toggleCapsLockState() 149 void toggleCapsLockState()
150 { 150 {
151 cl = !cl; repaint(); 151 cl = !cl; repaint();
152 } 152 }
153 void paintEvent( QPaintEvent * ) 153 void paintEvent( QPaintEvent * )
154 { 154 {
155 int y = (height()-sizeHint().height())/2; 155 int y = (height()-sizeHint().height())/2;
156 QPainter p(this); 156 QPainter p(this);
157 if ( nl ) 157 if ( nl )
158 p.drawPixmap(1,y,nl_pm); 158 p.drawPixmap(1,y,nl_pm);
159 if ( cl ) 159 if ( cl )
160 p.drawPixmap(1,y+nl_pm.height()+1,cl_pm); 160 p.drawPixmap(1,y+nl_pm.height()+1,cl_pm);
161 } 161 }
162private: 162private:
163 QPixmap nl_pm, cl_pm; 163 QPixmap nl_pm, cl_pm;
164 bool nl, cl; 164 bool nl, cl;
165}; 165};
166 166
167//--------------------------------------------------------------------------- 167//---------------------------------------------------------------------------
168 168
169TaskBar::~TaskBar() 169TaskBar::~TaskBar()
170{ 170{
171} 171}
172 172
173 173
174TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader) 174TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader)
175{ 175{
176 Config cfg( "Launcher" ); 176 Config cfg( "Launcher" );
177 cfg.setGroup( "InputMethods" ); 177 cfg.setGroup( "InputMethods" );
178 resizeRunningApp = cfg.readBoolEntry( "Resize", true ); 178 resizeRunningApp = cfg.readBoolEntry( "Resize", true );
179 179
180 sm = new StartMenu( this ); 180 sm = new StartMenu( this );
181 connect( sm, SIGNAL(tabSelected(const QString&)), this, 181 connect( sm, SIGNAL(tabSelected(const QString&)), this,
182 SIGNAL(tabSelected(const QString&)) ); 182 SIGNAL(tabSelected(const QString&)) );
183 183
184 inputMethods = new InputMethods( this ); 184 inputMethods = new InputMethods( this );
185 connect( inputMethods, SIGNAL(inputToggled(bool)), 185 connect( inputMethods, SIGNAL(inputToggled(bool)),
186 this, SLOT(calcMaxWindowRect()) ); 186 this, SLOT(calcMaxWindowRect()) );
187 187
188 stack = new QWidgetStack( this ); 188 stack = new QWidgetStack( this );
189 stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); 189 stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
190 label = new QLabel(stack); 190 label = new QLabel(stack);
191 191
192 runningAppBar = new RunningAppBar(stack); 192 runningAppBar = new RunningAppBar(stack);
193 stack->raiseWidget(runningAppBar); 193 stack->raiseWidget(runningAppBar);
194 194
195 waitIcon = new Wait( this ); 195 waitIcon = new Wait( this );
196 (void) new AppIcons( this ); 196 (void) new AppIcons( this );
197 197
198 sysTray = new SysTray( this ); 198 sysTray = new SysTray( this );
199 199
200 /* ### FIXME plugin loader and safe mode */ 200 /* ### FIXME plugin loader and safe mode */
201#if 0 201#if 0
202 if (PluginLoader::inSafeMode()) 202 if (PluginLoader::inSafeMode())
203 (void)new SafeMode( this ); 203 (void)new SafeMode( this );
204#endif 204#endif
205 205
206 // ## make customizable in some way? 206 // ## make customizable in some way?
207#ifdef QT_QWS_CUSTOM 207#ifdef QT_QWS_CUSTOM
208 lockState = new LockKeyState( this ); 208 lockState = new LockKeyState( this );
209#else 209#else
210 lockState = 0; 210 lockState = 0;
211#endif 211#endif
212 212
213#if defined(Q_WS_QWS) 213#if defined(Q_WS_QWS)
214#if !defined(QT_NO_COP) 214#if !defined(QT_NO_COP)
215 QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this ); 215 QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this );
216 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 216 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
217 this, SLOT(receive(const QCString&, const QByteArray&)) ); 217 this, SLOT(receive(const QCString&, const QByteArray&)) );
218#endif 218#endif
219#endif 219#endif
220 waitTimer = new QTimer( this ); 220 waitTimer = new QTimer( this );
221 connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) ); 221 connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) );
222 clearer = new QTimer( this ); 222 clearer = new QTimer( this );
223 QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar())); 223 QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar()));
224 224
225 connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) ); 225 connect( qApp, SIGNAL(symbol()), this, SLOT(toggleSymbolInput()) );
226 connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) ); 226 connect( qApp, SIGNAL(numLockStateToggle()), this, SLOT(toggleNumLockState()) );
227 connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) ); 227 connect( qApp, SIGNAL(capsLockStateToggle()), this, SLOT(toggleCapsLockState()) );
228} 228}
229 229
230void TaskBar::setStatusMessage( const QString &text ) 230void TaskBar::setStatusMessage( const QString &text )
231{ 231{
232 if ( !text.isEmpty() ) { 232 if ( !text.isEmpty() ) {
233 label->setText( text ); 233 label->setText( text );
234 stack->raiseWidget( label ); 234 stack->raiseWidget( label );
235 if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) ) 235 if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) )
236 sysTray->hide(); 236 sysTray->hide();
237 clearer->start( 3000, TRUE ); 237 clearer->start( 3000, TRUE );
238 } else { 238 } else {
239 clearStatusBar(); 239 clearStatusBar();
240 } 240 }
241} 241}
242 242
243void TaskBar::clearStatusBar() 243void TaskBar::clearStatusBar()
244{ 244{
245 label->clear(); 245 label->clear();
246 stack->raiseWidget(runningAppBar); 246 stack->raiseWidget(runningAppBar);
247 if ( sysTray ) 247 if ( sysTray )
248 sysTray->show(); 248 sysTray->show();
249 // stack->raiseWidget( mru ); 249 // stack->raiseWidget( mru );
250} 250}
251 251
252void TaskBar::startWait() 252void TaskBar::startWait()
253{ 253{
254 waitIcon->setWaiting( true ); 254 waitIcon->setWaiting( true );
255 // a catchall stop after 10 seconds... 255 // a catchall stop after 10 seconds...
256 waitTimer->start( 10 * 1000, true ); 256 waitTimer->start( 10 * 1000, true );
257} 257}
258 258
259void TaskBar::stopWait(const QString&) 259void TaskBar::stopWait(const QString&)
260{ 260{
261 waitTimer->stop(); 261 waitTimer->stop();
262 waitIcon->setWaiting( false ); 262 waitIcon->setWaiting( false );
263} 263}
264 264
265void TaskBar::stopWait() 265void TaskBar::stopWait()
266{ 266{
267 waitTimer->stop(); 267 waitTimer->stop();
268 waitIcon->setWaiting( false ); 268 waitIcon->setWaiting( false );
269} 269}
270 270
271/* 271/*
272 * This resizeEvent will be captured by 272 * This resizeEvent will be captured by
273 * the ServerInterface and it'll layout 273 * the ServerInterface and it'll layout
274 * and calc rect. Now if we go from bigger 274 * and calc rect. Now if we go from bigger
275 * to smaller screen the SysTray is out of 275 * to smaller screen the SysTray is out of
276 * bounds and repaint() won't trigger an Event 276 * bounds and repaint() won't trigger an Event
277 */ 277 */
278void TaskBar::resizeEvent( QResizeEvent *e ) 278void TaskBar::resizeEvent( QResizeEvent *e )
279{ 279{
280 if ( sysTray ) 280 if ( sysTray )
281 sysTray->hide(); 281 sysTray->hide();
282 282
283 QHBox::resizeEvent( e ); 283 QHBox::resizeEvent( e );
284 284
285 if ( sysTray ) 285 if ( sysTray )
286 sysTray->show(); 286 sysTray->show();
287 287
288 qWarning("TaskBar::resize event"); 288 qWarning("TaskBar::resize event");
289} 289}
290 290
291void TaskBar::styleChange( QStyle &s ) 291void TaskBar::styleChange( QStyle &s )
292{ 292{
293 QHBox::styleChange( s ); 293 QHBox::styleChange( s );
294 calcMaxWindowRect(); 294 calcMaxWindowRect();
295} 295}
296 296
297void TaskBar::calcMaxWindowRect() 297void TaskBar::calcMaxWindowRect()
298{ 298{
299 if ( resizeRunningApp ) 299 if ( resizeRunningApp )
300 { 300 {
301 #if defined(Q_WS_QWS) 301 #if defined(Q_WS_QWS)
302 QRect wr; 302 QRect wr;
303 int displayWidth = qApp->desktop()->width(); 303 int displayWidth = qApp->desktop()->width();
304 QRect ir = inputMethods->inputRect(); 304 QRect ir = inputMethods->inputRect();
305 if ( ir.isValid() ) { 305 if ( ir.isValid() ) {
306 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); 306 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 );
307 } else { 307 } else {
308 wr.setCoords( 0, 0, displayWidth-1, y()-1 ); 308 wr.setCoords( 0, 0, displayWidth-1, y()-1 );
309 } 309 }
310 #if QT_VERSION < 0x030000 310 #if QT_VERSION < 0x030000
311 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,QSize(qt_screen->width(),qt_screen->height())) ); 311 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,QSize(qt_screen->width(),qt_screen->height())) );
312 #else 312 #else
313 QWSServer::setMaxWindowRect( wr ); 313 QWSServer::setMaxWindowRect( wr );
314 #endif 314 #endif
315 #endif 315 #endif
316 } 316 }
317} 317}
318 318
319void TaskBar::receive( const QCString &msg, const QByteArray &data ) 319void TaskBar::receive( const QCString &msg, const QByteArray &data )
320{ 320{
321 QDataStream stream( data, IO_ReadOnly ); 321 QDataStream stream( data, IO_ReadOnly );
322 if ( msg == "message(QString)" ) { 322 if ( msg == "message(QString)" ) {
323 QString text; 323 QString text;
324 stream >> text; 324 stream >> text;
325 setStatusMessage( text ); 325 setStatusMessage( text );
326 } else if ( msg == "hideInputMethod()" ) { 326 } else if ( msg == "hideInputMethod()" ) {
327 inputMethods->hideInputMethod(); 327 inputMethods->hideInputMethod();
328 } else if ( msg == "showInputMethod()" ) { 328 } else if ( msg == "showInputMethod()" ) {
329 inputMethods->showInputMethod(); 329 inputMethods->showInputMethod();
330 } else if ( msg == "showInputMethod(QString)" ) { 330 } else if ( msg == "showInputMethod(QString)" ) {
331 QString name; 331 QString name;
332 stream >> name; 332 stream >> name;
333 inputMethods->showInputMethod(name); 333 inputMethods->showInputMethod(name);
334 } else if ( msg == "reloadInputMethods()" ) { 334 } else if ( msg == "reloadInputMethods()" ) {
335 inputMethods->loadInputMethods(); 335 inputMethods->loadInputMethods();
336 } else if ( msg == "reloadApplets()" ) { 336 } else if ( msg == "reloadApplets()" ) {
337 sysTray->clearApplets(); 337 sysTray->clearApplets();
338 sm->createMenu(); 338 sm->createMenu();
339 sysTray->addApplets(); 339 sysTray->addApplets();
340 }else if ( msg == "toggleMenu()" ) { 340 }else if ( msg == "toggleMenu()" ) {
341 if ( sm-> launchMenu-> isVisible() ) 341 if ( sm-> launchMenu-> isVisible() )
342 sm-> launch(); 342 sm-> launch();
343 else 343 else
344 QCopEnvelope e( "QPE/System", "toggleApplicationMenu()" ); 344 QCopEnvelope e( "QPE/System", "toggleApplicationMenu()" );
345 }else if ( msg == "toggleStartMenu()" ) 345 }else if ( msg == "toggleStartMenu()" )
346 sm->launch(); 346 sm->launch();
347} 347}
348 348
349void TaskBar::setApplicationState( const QString &name, ServerInterface::ApplicationState state ) 349void TaskBar::setApplicationState( const QString &name, ServerInterface::ApplicationState state )
350{ 350{
351 if ( state == ServerInterface::Launching ) 351 if ( state == ServerInterface::Launching )
352 runningAppBar->applicationLaunched( name ); 352 runningAppBar->applicationLaunched( name );
353 else if ( state == ServerInterface::Terminated ) 353 else if ( state == ServerInterface::Terminated )
354 runningAppBar->applicationTerminated( name ); 354 runningAppBar->applicationTerminated( name );
355} 355}
356 356
357void TaskBar::toggleNumLockState() 357void TaskBar::toggleNumLockState()
358{ 358{
359 if ( lockState ) lockState->toggleNumLockState(); 359 if ( lockState ) lockState->toggleNumLockState();
360} 360}
361 361
362void TaskBar::toggleCapsLockState() 362void TaskBar::toggleCapsLockState()
363{ 363{
364 if ( lockState ) lockState->toggleCapsLockState(); 364 if ( lockState ) lockState->toggleCapsLockState();
365} 365}
366 366
367void TaskBar::toggleSymbolInput() 367void TaskBar::toggleSymbolInput()
368{ 368{
369 QString unicodeInput = qApp->translate( "InputMethods", "Unicode" ); 369 QString unicodeInput = qApp->translate( "InputMethods", "Unicode" );
370 if ( inputMethods->currentShown() == unicodeInput ) { 370 if ( inputMethods->currentShown() == unicodeInput ) {
371 inputMethods->hideInputMethod(); 371 inputMethods->hideInputMethod();
372 } else { 372 } else {
373 inputMethods->showInputMethod( unicodeInput ); 373 inputMethods->showInputMethod( unicodeInput );
374 } 374 }
375} 375}
376 376
377#include "taskbar.moc" 377#include "taskbar.moc"