summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/applauncher.cpp83
-rw-r--r--core/launcher/documentlist.cpp46
-rw-r--r--core/launcher/firstuse.cpp44
-rw-r--r--core/launcher/inputmethods.cpp34
-rw-r--r--core/launcher/irserver.cpp16
-rw-r--r--core/launcher/launcher.cpp37
-rw-r--r--core/launcher/launcherview.cpp9
-rw-r--r--core/launcher/main.cpp42
-rw-r--r--core/launcher/packageslave.cpp26
-rw-r--r--core/launcher/qcopbridge.cpp23
-rw-r--r--core/launcher/qprocess.cpp14
-rw-r--r--core/launcher/qprocess_unix.cpp93
-rw-r--r--core/launcher/runningappbar.cpp24
-rw-r--r--core/launcher/screensaver.cpp2
-rw-r--r--core/launcher/server.cpp32
-rw-r--r--core/launcher/serverapp.cpp26
-rw-r--r--core/launcher/suspendmonitor.cpp2
-rw-r--r--core/launcher/systray.cpp18
-rw-r--r--core/launcher/taskbar.cpp7
-rw-r--r--core/launcher/transferserver.cpp107
20 files changed, 334 insertions, 351 deletions
diff --git a/core/launcher/applauncher.cpp b/core/launcher/applauncher.cpp
index 5a5517c..7000346 100644
--- a/core/launcher/applauncher.cpp
+++ b/core/launcher/applauncher.cpp
@@ -18,56 +18,53 @@
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#ifndef QTOPIA_INTERNAL_PRELOADACCESS 21#ifndef QTOPIA_INTERNAL_PRELOADACCESS
22#define QTOPIA_INTERNAL_PRELOADACCESS 22#define QTOPIA_INTERNAL_PRELOADACCESS
23#endif 23#endif
24#ifndef QTOPIA_INTERNAL_FILEOPERATIONS 24#ifndef QTOPIA_INTERNAL_FILEOPERATIONS
25#define QTOPIA_INTERNAL_FILEOPERATIONS 25#define QTOPIA_INTERNAL_FILEOPERATIONS
26#endif 26#endif
27#ifndef QTOPIA_PROGRAM_MONITOR 27#ifndef QTOPIA_PROGRAM_MONITOR
28#define QTOPIA_PROGRAM_MONITOR 28#define QTOPIA_PROGRAM_MONITOR
29#endif 29#endif
30
31#include "applauncher.h"
32#include "documentlist.h"
33
34/* OPIE */
35#include <opie2/odebug.h>
30#include <opie2/oglobal.h> 36#include <opie2/oglobal.h>
37#include <qtopia/qcopenvelope_qws.h>
38#include <qtopia/qpeapplication.h>
39using namespace Opie::Core;
31 40
32#ifndef Q_OS_WIN32 41/* QT */
42#include <qtimer.h>
43#include <qwindowsystem_qws.h>
44#include <qmessagebox.h>
45#include <qfileinfo.h>
46
47/* STD */
33#include <sys/stat.h> 48#include <sys/stat.h>
34#include <sys/wait.h> 49#include <sys/wait.h>
35#include <sys/file.h> 50#include <sys/file.h>
36#include <unistd.h> 51#include <unistd.h>
37#include <sys/time.h> 52#include <sys/time.h>
38#include <sys/resource.h> 53#include <sys/resource.h>
39#include <errno.h> 54#include <errno.h>
40#else
41#include <process.h>
42#include <windows.h>
43#include <winbase.h>
44#endif
45
46#include <signal.h> 55#include <signal.h>
47#include <sys/types.h> 56#include <sys/types.h>
48#include <stdlib.h> 57#include <stdlib.h>
49 58
50#include <qtimer.h>
51#include <qwindowsystem_qws.h>
52#include <qmessagebox.h>
53#include <qfileinfo.h>
54
55#include <qtopia/qcopenvelope_qws.h>
56#include <qtopia/qpeapplication.h>
57
58#include "applauncher.h"
59#include "documentlist.h"
60
61using namespace Opie::Core;
62const int AppLauncher::RAISE_TIMEOUT_MS = 5000; 59const int AppLauncher::RAISE_TIMEOUT_MS = 5000;
63 60
64//--------------------------------------------------------------------------- 61//---------------------------------------------------------------------------
65 62
66static AppLauncher* appLauncherPtr; 63static AppLauncher* appLauncherPtr;
67 64
68const int appStopEventID = 1290; 65const int appStopEventID = 1290;
69 66
70class AppStoppedEvent : public QCustomEvent 67class AppStoppedEvent : public QCustomEvent
71{ 68{
72public: 69public:
73 AppStoppedEvent(int pid, int status) 70 AppStoppedEvent(int pid, int status)
@@ -118,39 +115,39 @@ AppLauncher::~AppLauncher()
118#endif 115#endif
119 if ( qlPid ) { 116 if ( qlPid ) {
120 int status; 117 int status;
121 ::kill( qlPid, SIGTERM ); 118 ::kill( qlPid, SIGTERM );
122 waitpid( qlPid, &status, 0 ); 119 waitpid( qlPid, &status, 0 );
123 } 120 }
124} 121}
125 122
126/* We use the QCopChannel of the app as an indicator of when it has been launched 123/* We use the QCopChannel of the app as an indicator of when it has been launched
127 so that we can disable the busy indicators */ 124 so that we can disable the busy indicators */
128void AppLauncher::newQcopChannel(const QString& channelName) 125void AppLauncher::newQcopChannel(const QString& channelName)
129{ 126{
130// qDebug("channel %s added", channelName.data() ); 127// odebug << "channel " << channelName.data() << " added" << oendl;
131 QString prefix("QPE/Application/"); 128 QString prefix("QPE/Application/");
132 if (channelName.startsWith(prefix)) { 129 if (channelName.startsWith(prefix)) {
133 { 130 {
134 QCopEnvelope e("QPE/System", "newChannel(QString)"); 131 QCopEnvelope e("QPE/System", "newChannel(QString)");
135 e << channelName; 132 e << channelName;
136 } 133 }
137 QString appName = channelName.mid(prefix.length()); 134 QString appName = channelName.mid(prefix.length());
138 if ( appName != "quicklauncher" ) { 135 if ( appName != "quicklauncher" ) {
139 emit connected( appName ); 136 emit connected( appName );
140 QCopEnvelope e("QPE/System", "notBusy(QString)"); 137 QCopEnvelope e("QPE/System", "notBusy(QString)");
141 e << appName; 138 e << appName;
142 } 139 }
143 } else if (channelName.startsWith("QPE/QuickLauncher-")) { 140 } else if (channelName.startsWith("QPE/QuickLauncher-")) {
144 qDebug("Registered %s", channelName.latin1()); 141 odebug << "Registered " << channelName << "" << oendl;
145 int pid = channelName.mid(18).toInt(); 142 int pid = channelName.mid(18).toInt();
146 if (pid == qlPid) 143 if (pid == qlPid)
147 qlReady = TRUE; 144 qlReady = TRUE;
148 } 145 }
149} 146}
150 147
151void AppLauncher::removedQcopChannel(const QString& channelName) 148void AppLauncher::removedQcopChannel(const QString& channelName)
152{ 149{
153 if (channelName.startsWith("QPE/Application/")) { 150 if (channelName.startsWith("QPE/Application/")) {
154 QCopEnvelope e("QPE/System", "removedChannel(QString)"); 151 QCopEnvelope e("QPE/System", "removedChannel(QString)");
155 e << channelName; 152 e << channelName;
156 } 153 }
@@ -171,25 +168,25 @@ void AppLauncher::received(const QCString& msg, const QByteArray& data)
171 execute( t, d ); 168 execute( t, d );
172 } else if ( msg == "processQCop(QString)" ) { // from QPE/Server 169 } else if ( msg == "processQCop(QString)" ) { // from QPE/Server
173 QString t; 170 QString t;
174 stream >> t; 171 stream >> t;
175 if ( !executeBuiltin( t, QString::null ) ) 172 if ( !executeBuiltin( t, QString::null ) )
176 execute( t, QString::null, TRUE); 173 execute( t, QString::null, TRUE);
177 } else if ( msg == "raise(QString)" ) { 174 } else if ( msg == "raise(QString)" ) {
178 QString appName; 175 QString appName;
179 stream >> appName; 176 stream >> appName;
180 177
181 if ( !executeBuiltin( appName, QString::null ) ) { 178 if ( !executeBuiltin( appName, QString::null ) ) {
182 if ( !waitingHeartbeat.contains( appName ) && appKillerName != appName ) { 179 if ( !waitingHeartbeat.contains( appName ) && appKillerName != appName ) {
183 //qDebug( "Raising: %s", appName.latin1() ); 180 //odebug << "Raising: " << appName << "" << oendl;
184 QCString channel = "QPE/Application/"; 181 QCString channel = "QPE/Application/";
185 channel += appName.latin1(); 182 channel += appName.latin1();
186 183
187 // Need to lock it to avoid race conditions with QPEApplication::processQCopFile 184 // Need to lock it to avoid race conditions with QPEApplication::processQCopFile
188 QFile f("/tmp/qcop-msg-" + appName); 185 QFile f("/tmp/qcop-msg-" + appName);
189 if ( f.open(IO_WriteOnly | IO_Append) ) { 186 if ( f.open(IO_WriteOnly | IO_Append) ) {
190#ifndef Q_OS_WIN32 187#ifndef Q_OS_WIN32
191 flock(f.handle(), LOCK_EX); 188 flock(f.handle(), LOCK_EX);
192#endif 189#endif
193 QDataStream ds(&f); 190 QDataStream ds(&f);
194 QByteArray b; 191 QByteArray b;
195 QDataStream bstream(b, IO_WriteOnly); 192 QDataStream bstream(b, IO_WriteOnly);
@@ -208,53 +205,53 @@ void AppLauncher::received(const QCString& msg, const QByteArray& data)
208 } 205 }
209 } 206 }
210 } else if ( msg == "sendRunningApps()" ) { 207 } else if ( msg == "sendRunningApps()" ) {
211 QStringList apps; 208 QStringList apps;
212 QMap<int,QString>::Iterator it; 209 QMap<int,QString>::Iterator it;
213 for( it = runningApps.begin(); it != runningApps.end(); ++it ) 210 for( it = runningApps.begin(); it != runningApps.end(); ++it )
214 apps.append( *it ); 211 apps.append( *it );
215 QCopEnvelope e( "QPE/Desktop", "runningApps(QStringList)" ); 212 QCopEnvelope e( "QPE/Desktop", "runningApps(QStringList)" );
216 e << apps; 213 e << apps;
217 } else if ( msg == "appRaised(QString)" ) { 214 } else if ( msg == "appRaised(QString)" ) {
218 QString appName; 215 QString appName;
219 stream >> appName; 216 stream >> appName;
220 qDebug("Got a heartbeat from %s", appName.latin1()); 217 odebug << "Got a heartbeat from " << appName << "" << oendl;
221 QMap<QString,int>::Iterator it = waitingHeartbeat.find(appName); 218 QMap<QString,int>::Iterator it = waitingHeartbeat.find(appName);
222 if ( it != waitingHeartbeat.end() ) { 219 if ( it != waitingHeartbeat.end() ) {
223 killTimer( *it ); 220 killTimer( *it );
224 waitingHeartbeat.remove(it); 221 waitingHeartbeat.remove(it);
225 } 222 }
226 // Check to make sure we're not waiting on user input... 223 // Check to make sure we're not waiting on user input...
227 if ( appKillerBox && appName == appKillerName ) { 224 if ( appKillerBox && appName == appKillerName ) {
228 // If we are, we kill the dialog box, and the code waiting on the result 225 // If we are, we kill the dialog box, and the code waiting on the result
229 // will clean us up (basically the user said "no"). 226 // will clean us up (basically the user said "no").
230 delete appKillerBox; 227 delete appKillerBox;
231 appKillerBox = 0; 228 appKillerBox = 0;
232 appKillerName = QString::null; 229 appKillerName = QString::null;
233 } 230 }
234 } 231 }
235} 232}
236 233
237void AppLauncher::signalHandler(int) 234void AppLauncher::signalHandler(int)
238{ 235{
239#ifndef Q_OS_WIN32 236#ifndef Q_OS_WIN32
240 int status; 237 int status;
241 pid_t pid = waitpid(-1, &status, WNOHANG); 238 pid_t pid = waitpid(-1, &status, WNOHANG);
242/* if (pid == 0 || &status == 0 ) { 239/* if (pid == 0 || &status == 0 ) {
243 qDebug("hmm, could not get return value from signal"); 240 odebug << "hmm, could not get return value from signal" << oendl;
244 } 241 }
245*/ 242*/
246 QApplication::postEvent(appLauncherPtr, new AppStoppedEvent(pid, status) ); 243 QApplication::postEvent(appLauncherPtr, new AppStoppedEvent(pid, status) );
247#else 244#else
248 qDebug("Unhandled signal see by AppLauncher::signalHandler(int)"); 245 odebug << "Unhandled signal see by AppLauncher::signalHandler(int)" << oendl;
249#endif 246#endif
250} 247}
251 248
252bool AppLauncher::event(QEvent *e) 249bool AppLauncher::event(QEvent *e)
253{ 250{
254 if ( e->type() == appStopEventID ) { 251 if ( e->type() == appStopEventID ) {
255 AppStoppedEvent *ae = (AppStoppedEvent *) e; 252 AppStoppedEvent *ae = (AppStoppedEvent *) e;
256 sigStopped(ae->pid(), ae->status() ); 253 sigStopped(ae->pid(), ae->status() );
257 return TRUE; 254 return TRUE;
258 } 255 }
259 256
260 return QObject::event(e); 257 return QObject::event(e);
@@ -264,36 +261,36 @@ void AppLauncher::timerEvent( QTimerEvent *e )
264{ 261{
265 int id = e->timerId(); 262 int id = e->timerId();
266 QMap<QString,int>::Iterator it; 263 QMap<QString,int>::Iterator it;
267 for ( it = waitingHeartbeat.begin(); it != waitingHeartbeat.end(); ++it ) { 264 for ( it = waitingHeartbeat.begin(); it != waitingHeartbeat.end(); ++it ) {
268 if ( *it == id ) { 265 if ( *it == id ) {
269 if ( appKillerBox ) // we're already dealing with one 266 if ( appKillerBox ) // we're already dealing with one
270 return; 267 return;
271 268
272 appKillerName = it.key(); 269 appKillerName = it.key();
273 killTimer( id ); 270 killTimer( id );
274 waitingHeartbeat.remove( it ); 271 waitingHeartbeat.remove( it );
275 272
276 // qDebug("Checking in on %s", appKillerName.latin1()); 273 // odebug << "Checking in on " << appKillerName << "" << oendl;
277 274
278 // We store this incase the application responds while we're 275 // We store this incase the application responds while we're
279 // waiting for user input so we know not to delete ourselves. 276 // waiting for user input so we know not to delete ourselves.
280 appKillerBox = new QMessageBox(tr("Application Problem"), 277 appKillerBox = new QMessageBox(tr("Application Problem"),
281 tr("<p>%1 is not responding.</p>").arg(appKillerName) + 278 tr("<p>%1 is not responding.</p>").arg(appKillerName) +
282 tr("<p>Would you like to force the application to exit?</p>"), 279 tr("<p>Would you like to force the application to exit?</p>"),
283 QMessageBox::Warning, QMessageBox::Yes, 280 QMessageBox::Warning, QMessageBox::Yes,
284 QMessageBox::No | QMessageBox::Default, 281 QMessageBox::No | QMessageBox::Default,
285 QMessageBox::NoButton); 282 QMessageBox::NoButton);
286 if (appKillerBox->exec() == QMessageBox::Yes) { 283 if (appKillerBox->exec() == QMessageBox::Yes) {
287 // qDebug("Killing the app!!! Bwuhahahaha!"); 284 // odebug << "Killing the app!!! Bwuhahahaha!" << oendl;
288 int pid = pidForName(appKillerName); 285 int pid = pidForName(appKillerName);
289 if ( pid > 0 ) 286 if ( pid > 0 )
290 kill( pid ); 287 kill( pid );
291 } 288 }
292 appKillerName = QString::null; 289 appKillerName = QString::null;
293 delete appKillerBox; 290 delete appKillerBox;
294 appKillerBox = 0; 291 appKillerBox = 0;
295 return; 292 return;
296 } 293 }
297 } 294 }
298 295
299 QObject::timerEvent( e ); 296 QObject::timerEvent( e );
@@ -306,35 +303,35 @@ void AppLauncher::sigStopped(int sigPid, int sigStatus)
306 303
307 bool crashed = WIFSIGNALED(sigStatus); 304 bool crashed = WIFSIGNALED(sigStatus);
308 if ( !crashed ) { 305 if ( !crashed ) {
309 if ( WIFEXITED(sigStatus) ) 306 if ( WIFEXITED(sigStatus) )
310 exitStatus = WEXITSTATUS(sigStatus); 307 exitStatus = WEXITSTATUS(sigStatus);
311 } else { 308 } else {
312 exitStatus = WTERMSIG(sigStatus); 309 exitStatus = WTERMSIG(sigStatus);
313 } 310 }
314 311
315 QMap<int,QString>::Iterator it = runningApps.find( sigPid ); 312 QMap<int,QString>::Iterator it = runningApps.find( sigPid );
316 if ( it == runningApps.end() ) { 313 if ( it == runningApps.end() ) {
317 if ( sigPid == qlPid ) { 314 if ( sigPid == qlPid ) {
318 qDebug( "quicklauncher stopped" ); 315 odebug << "quicklauncher stopped" << oendl;
319 qlPid = 0; 316 qlPid = 0;
320 qlReady = FALSE; 317 qlReady = FALSE;
321 QFile::remove("/tmp/qcop-msg-quicklauncher" ); 318 QFile::remove("/tmp/qcop-msg-quicklauncher" );
322 QTimer::singleShot( 2000, this, SLOT(createQuickLauncher()) ); 319 QTimer::singleShot( 2000, this, SLOT(createQuickLauncher()) );
323 } 320 }
324/* 321/*
325 if ( sigPid == -1 ) 322 if ( sigPid == -1 )
326 qDebug("non-qtopia application exited (disregarded)"); 323 odebug << "non-qtopia application exited (disregarded)" << oendl;
327 else 324 else
328 qDebug("==== no pid matching %d in list, definite bug", sigPid); 325 odebug << "==== no pid matching " << sigPid << " in list, definite bug" << oendl;
329*/ 326*/
330 return; 327 return;
331 } 328 }
332 QString appName = *it; 329 QString appName = *it;
333 runningApps.remove(it); 330 runningApps.remove(it);
334 331
335 QMap<QString,int>::Iterator hbit = waitingHeartbeat.find(appName); 332 QMap<QString,int>::Iterator hbit = waitingHeartbeat.find(appName);
336 if ( hbit != waitingHeartbeat.end() ) { 333 if ( hbit != waitingHeartbeat.end() ) {
337 killTimer( *hbit ); 334 killTimer( *hbit );
338 waitingHeartbeat.remove( hbit ); 335 waitingHeartbeat.remove( hbit );
339 } 336 }
340 if ( appName == appKillerName ) { 337 if ( appName == appKillerName ) {
@@ -360,25 +357,25 @@ void AppLauncher::sigStopped(int sigPid, int sigStatus)
360 cfg.writeEntry("Apps",apps,','); 357 cfg.writeEntry("Apps",apps,',');
361 preloadDisabled = TRUE; 358 preloadDisabled = TRUE;
362 } 359 }
363 360
364 // clean up 361 // clean up
365 if ( exitStatus ) { 362 if ( exitStatus ) {
366 QCopEnvelope e("QPE/System", "notBusy(QString)"); 363 QCopEnvelope e("QPE/System", "notBusy(QString)");
367 e << app->exec(); 364 e << app->exec();
368 } 365 }
369/* 366/*
370 // debug info 367 // debug info
371 for (it = runningApps.begin(); it != runningApps.end(); ++it) { 368 for (it = runningApps.begin(); it != runningApps.end(); ++it) {
372 qDebug("running according to internal list: %s, with pid %d", (*it).data(), it.key() ); 369 odebug << "running according to internal list: " << (*it).data() << ", with pid " << it.key() << "" << oendl;
373 } 370 }
374*/ 371*/
375 372
376#ifdef QTOPIA_PROGRAM_MONITOR 373#ifdef QTOPIA_PROGRAM_MONITOR
377 if ( crashed ) { 374 if ( crashed ) {
378 QString sig; 375 QString sig;
379 switch( exitStatus ) { 376 switch( exitStatus ) {
380 case SIGABRT: sig = "SIGABRT"; break; 377 case SIGABRT: sig = "SIGABRT"; break;
381 case SIGALRM: sig = "SIGALRM"; break; 378 case SIGALRM: sig = "SIGALRM"; break;
382 case SIGBUS: sig = "SIGBUS"; break; 379 case SIGBUS: sig = "SIGBUS"; break;
383 case SIGFPE: sig = "SIGFPE"; break; 380 case SIGFPE: sig = "SIGFPE"; break;
384 case SIGHUP: sig = "SIGHUP"; break; 381 case SIGHUP: sig = "SIGHUP"; break;
@@ -394,50 +391,50 @@ void AppLauncher::sigStopped(int sigPid, int sigStatus)
394 if ( preloadDisabled ) 391 if ( preloadDisabled )
395 sig += tr("<qt><p>Fast loading has been disabled for this application. Tap and hold the application icon to reenable it.</qt>"); 392 sig += tr("<qt><p>Fast loading has been disabled for this application. Tap and hold the application icon to reenable it.</qt>");
396 393
397 QString str = tr("<qt><b>%1</b> was terminated due to signal code %2</qt>").arg( app->name() ).arg( sig ); 394 QString str = tr("<qt><b>%1</b> was terminated due to signal code %2</qt>").arg( app->name() ).arg( sig );
398 QMessageBox::information(0, tr("Application terminated"), str ); 395 QMessageBox::information(0, tr("Application terminated"), str );
399 } else { 396 } else {
400 if ( exitStatus == 255 ) { //could not find app (because global returns -1) 397 if ( exitStatus == 255 ) { //could not find app (because global returns -1)
401 QMessageBox::information(0, tr("Application not found"), tr("<qt>Could not locate application <b>%1</b></qt>").arg( app->exec() ) ); 398 QMessageBox::information(0, tr("Application not found"), tr("<qt>Could not locate application <b>%1</b></qt>").arg( app->exec() ) );
402 } else { 399 } else {
403 QFileInfo fi(QString::fromLatin1("/tmp/qcop-msg-") + appName); 400 QFileInfo fi(QString::fromLatin1("/tmp/qcop-msg-") + appName);
404 if ( fi.exists() && fi.size() ) { 401 if ( fi.exists() && fi.size() ) {
405 emit terminated(sigPid, appName); 402 emit terminated(sigPid, appName);
406 qWarning("Re executing obmitted for %s", appName.latin1() ); 403 owarn << "Re executing obmitted for " << appName << "" << oendl;
407 // execute( appName, QString::null ); 404 // execute( appName, QString::null );
408 return; 405 return;
409 } 406 }
410 } 407 }
411 } 408 }
412 409
413#endif 410#endif
414 411
415 emit terminated(sigPid, appName); 412 emit terminated(sigPid, appName);
416} 413}
417#else 414#else
418void AppLauncher::sigStopped(int sigPid, int sigStatus) 415void AppLauncher::sigStopped(int sigPid, int sigStatus)
419{ 416{
420 qDebug("Unhandled signal : AppLauncher::sigStopped(int sigPid, int sigStatus)"); 417 odebug << "Unhandled signal : AppLauncher::sigStopped(int sigPid, int sigStatus)" << oendl;
421} 418}
422#endif // Q_OS_WIN32 419#endif // Q_OS_WIN32
423 420
424bool AppLauncher::isRunning(const QString &app) 421bool AppLauncher::isRunning(const QString &app)
425{ 422{
426 for (QMap<int,QString>::ConstIterator it = runningApps.begin(); it != runningApps.end(); ++it) { 423 for (QMap<int,QString>::ConstIterator it = runningApps.begin(); it != runningApps.end(); ++it) {
427 if ( *it == app ) { 424 if ( *it == app ) {
428#ifdef Q_OS_UNIX 425#ifdef Q_OS_UNIX
429 pid_t t = ::__getpgid( it.key() ); 426 pid_t t = ::__getpgid( it.key() );
430 if ( t == -1 ) { 427 if ( t == -1 ) {
431 qDebug("appLauncher bug, %s believed running, but pid %d is not existing", app.data(), it.key() ); 428 odebug << "appLauncher bug, " << app.data() << " believed running, but pid " << it.key() << " is not existing" << oendl;
432 runningApps.remove( it.key() ); 429 runningApps.remove( it.key() );
433 return FALSE; 430 return FALSE;
434 } 431 }
435#endif 432#endif
436 return TRUE; 433 return TRUE;
437 } 434 }
438 } 435 }
439 436
440 return FALSE; 437 return FALSE;
441} 438}
442 439
443bool AppLauncher::executeBuiltin(const QString &c, const QString &document) 440bool AppLauncher::executeBuiltin(const QString &c, const QString &document)
@@ -472,25 +469,25 @@ bool AppLauncher::executeBuiltin(const QString &c, const QString &document)
472 QString ap=list[0]; 469 QString ap=list[0];
473 470
474 if ( ap == "suspend" ) { // No tr 471 if ( ap == "suspend" ) { // No tr
475 QWSServer::processKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 472 QWSServer::processKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
476 return TRUE; 473 return TRUE;
477 } 474 }
478 475
479 return FALSE; 476 return FALSE;
480} 477}
481 478
482bool AppLauncher::execute(const QString &c, const QString &docParam, bool noRaise) 479bool AppLauncher::execute(const QString &c, const QString &docParam, bool noRaise)
483{ 480{
484 qWarning("AppLauncher::execute '%s' '%s'", (const char*) c, (const char*) docParam ); 481 owarn << "AppLauncher::execute '" << c << "' '" << docParam << "'" << oendl;
485 // Convert the command line in to a list of arguments 482 // Convert the command line in to a list of arguments
486 QStringList list = QStringList::split(QRegExp(" *"),c); 483 QStringList list = QStringList::split(QRegExp(" *"),c);
487 QStringList arglist = QStringList::split(QRegExp(" *"),docParam); 484 QStringList arglist = QStringList::split(QRegExp(" *"),docParam);
488 for ( QStringList::Iterator it = arglist.begin(); it != arglist.end(); ++it ) 485 for ( QStringList::Iterator it = arglist.begin(); it != arglist.end(); ++it )
489 list.append( *it ); 486 list.append( *it );
490 487
491 QString appName = list[0]; 488 QString appName = list[0];
492 if ( isRunning(appName) ) { 489 if ( isRunning(appName) ) {
493 QCString channel = "QPE/Application/"; 490 QCString channel = "QPE/Application/";
494 channel += appName.latin1(); 491 channel += appName.latin1();
495 492
496 // Need to lock it to avoid race conditions with QPEApplication::processQCopFile 493 // Need to lock it to avoid race conditions with QPEApplication::processQCopFile
@@ -539,25 +536,25 @@ bool AppLauncher::execute(const QString &c, const QString &docParam, bool noRais
539 536
540 const char **args = new const char *[slist.count() + 1]; 537 const char **args = new const char *[slist.count() + 1];
541 for ( j = 0; j < slist.count(); j++ ) 538 for ( j = 0; j < slist.count(); j++ )
542 args[j] = slist.at(j); 539 args[j] = slist.at(j);
543 args[j] = NULL; 540 args[j] = NULL;
544 541
545#ifndef Q_OS_WIN32 542#ifndef Q_OS_WIN32
546#ifdef Q_OS_MACX 543#ifdef Q_OS_MACX
547 if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".dylib" ) ) { 544 if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".dylib" ) ) {
548#else 545#else
549 if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".so" ) ) { 546 if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".so" ) ) {
550#endif /* Q_OS_MACX */ 547#endif /* Q_OS_MACX */
551 qDebug( "Quick launching: %s", args[0] ); 548 odebug << "Quick launching: " << args[0] << "" << oendl;
552 if ( getuid() == 0 ) 549 if ( getuid() == 0 )
553 setpriority( PRIO_PROCESS, qlPid, 0 ); 550 setpriority( PRIO_PROCESS, qlPid, 0 );
554 QCString qlch("QPE/QuickLauncher-"); 551 QCString qlch("QPE/QuickLauncher-");
555 qlch += QString::number(qlPid); 552 qlch += QString::number(qlPid);
556 QCopEnvelope env( qlch, "execute(QStrList)" ); 553 QCopEnvelope env( qlch, "execute(QStrList)" );
557 env << slist; 554 env << slist;
558 runningApps[qlPid] = QString(args[0]); 555 runningApps[qlPid] = QString(args[0]);
559 emit launched(qlPid, QString(args[0])); 556 emit launched(qlPid, QString(args[0]));
560 QCopEnvelope e("QPE/System", "busy()"); 557 QCopEnvelope e("QPE/System", "busy()");
561 qlPid = 0; 558 qlPid = 0;
562 qlReady = FALSE; 559 qlReady = FALSE;
563 QTimer::singleShot( getuid() == 0 ? 800 : 1500, this, SLOT(createQuickLauncher()) ); 560 QTimer::singleShot( getuid() == 0 ? 800 : 1500, this, SLOT(createQuickLauncher()) );
@@ -575,39 +572,39 @@ bool AppLauncher::execute(const QString &c, const QString &docParam, bool noRais
575 572
576 runningApps[pid] = QString(args[0]); 573 runningApps[pid] = QString(args[0]);
577 emit launched(pid, QString(args[0])); 574 emit launched(pid, QString(args[0]));
578 QCopEnvelope e("QPE/System", "busy()"); 575 QCopEnvelope e("QPE/System", "busy()");
579 } 576 }
580#else 577#else
581 QProcess *proc = new QProcess(this); 578 QProcess *proc = new QProcess(this);
582 if (proc){ 579 if (proc){
583 for (int i=0; i < slist.count(); i++) 580 for (int i=0; i < slist.count(); i++)
584 proc->addArgument(args[i]); 581 proc->addArgument(args[i]);
585 connect(proc, SIGNAL(processExited()), this, SLOT(processExited())); 582 connect(proc, SIGNAL(processExited()), this, SLOT(processExited()));
586 if (!proc->start()){ 583 if (!proc->start()){
587 qDebug("Unable to start application %s", args[0]); 584 odebug << "Unable to start application " << args[0] << "" << oendl;
588 }else{ 585 }else{
589 PROCESS_INFORMATION *procInfo = (PROCESS_INFORMATION *)proc->processIdentifier(); 586 PROCESS_INFORMATION *procInfo = (PROCESS_INFORMATION *)proc->processIdentifier();
590 if (procInfo){ 587 if (procInfo){
591 DWORD pid = procInfo->dwProcessId; 588 DWORD pid = procInfo->dwProcessId;
592 runningApps[pid] = QString(args[0]); 589 runningApps[pid] = QString(args[0]);
593 runningAppsProc.append(proc); 590 runningAppsProc.append(proc);
594 emit launched(pid, QString(args[0])); 591 emit launched(pid, QString(args[0]));
595 QCopEnvelope e("QPE/System", "busy()"); 592 QCopEnvelope e("QPE/System", "busy()");
596 }else{ 593 }else{
597 qDebug("Unable to read process inforation #1 for %s", args[0]); 594 odebug << "Unable to read process inforation #1 for " << args[0] << "" << oendl;
598 } 595 }
599 } 596 }
600 }else{ 597 }else{
601 qDebug("Unable to create process for application %s", args[0]); 598 odebug << "Unable to create process for application " << args[0] << "" << oendl;
602 return FALSE; 599 return FALSE;
603 } 600 }
604#endif 601#endif
605#endif //QT_NO_QWS_MULTIPROCESS 602#endif //QT_NO_QWS_MULTIPROCESS
606 603
607 delete [] args; 604 delete [] args;
608 return TRUE; 605 return TRUE;
609} 606}
610 607
611void AppLauncher::kill( int pid ) 608void AppLauncher::kill( int pid )
612{ 609{
613#ifndef Q_OS_WIN32 610#ifndef Q_OS_WIN32
@@ -669,34 +666,34 @@ void AppLauncher::createQuickLauncher()
669 } else if ( qlPid == -1 ) { 666 } else if ( qlPid == -1 ) {
670 qlPid = 0; 667 qlPid = 0;
671 } else { 668 } else {
672 if ( getuid() == 0 ) 669 if ( getuid() == 0 )
673 setpriority( PRIO_PROCESS, qlPid, 19 ); 670 setpriority( PRIO_PROCESS, qlPid, 19 );
674 } 671 }
675} 672}
676 673
677// Used only by Win32 674// Used only by Win32
678void AppLauncher::processExited() 675void AppLauncher::processExited()
679{ 676{
680#ifdef Q_OS_WIN32 677#ifdef Q_OS_WIN32
681 qDebug("AppLauncher::processExited()"); 678 odebug << "AppLauncher::processExited()" << oendl;
682 bool found = FALSE; 679 bool found = FALSE;
683 QProcess *proc = (QProcess *) sender(); 680 QProcess *proc = (QProcess *) sender();
684 if (!proc){ 681 if (!proc){
685 qDebug("Interanl error NULL proc"); 682 odebug << "Interanl error NULL proc" << oendl;
686 return; 683 return;
687 } 684 }
688 685
689 QString appName = proc->arguments()[0]; 686 QString appName = proc->arguments()[0];
690 qDebug("Removing application %s", appName.latin1()); 687 odebug << "Removing application " << appName << "" << oendl;
691 runningAppsProc.remove(proc); 688 runningAppsProc.remove(proc);
692 689
693 QMap<QString,int>::Iterator hbit = waitingHeartbeat.find(appName); 690 QMap<QString,int>::Iterator hbit = waitingHeartbeat.find(appName);
694 if ( hbit != waitingHeartbeat.end() ) { 691 if ( hbit != waitingHeartbeat.end() ) {
695 killTimer( *hbit ); 692 killTimer( *hbit );
696 waitingHeartbeat.remove( hbit ); 693 waitingHeartbeat.remove( hbit );
697 } 694 }
698 if ( appName == appKillerName ) { 695 if ( appName == appKillerName ) {
699 appKillerName = QString::null; 696 appKillerName = QString::null;
700 delete appKillerBox; 697 delete appKillerBox;
701 appKillerBox = 0; 698 appKillerBox = 0;
702 } 699 }
@@ -705,18 +702,18 @@ void AppLauncher::processExited()
705 QMap<int, QString>::Iterator it; 702 QMap<int, QString>::Iterator it;
706 for (it = runningApps.begin(); it!= runningApps.end(); ++it){ 703 for (it = runningApps.begin(); it!= runningApps.end(); ++it){
707 if (it.data() == appName){ 704 if (it.data() == appName){
708 found = TRUE; 705 found = TRUE;
709 break; 706 break;
710 } 707 }
711 } 708 }
712 709
713 if (found){ 710 if (found){
714 emit terminated(it.key(), it.data()); 711 emit terminated(it.key(), it.data());
715 runningApps.remove(it.key()); 712 runningApps.remove(it.key());
716 }else{ 713 }else{
717 qDebug("Internal error application %s not listed as running", appName.latin1()); 714 odebug << "Internal error application " << appName << " not listed as running" << oendl;
718 } 715 }
719 716
720#endif 717#endif
721} 718}
722 719
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp
index 3e0a96c..92b8c25 100644
--- a/core/launcher/documentlist.cpp
+++ b/core/launcher/documentlist.cpp
@@ -12,51 +12,53 @@
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#include "documentlist.h" 20#include "documentlist.h"
21#include "serverinterface.h" 21#include "serverinterface.h"
22#include "mediadlg.h" 22#include "mediadlg.h"
23 23
24/* OPIE */
24#include <opie2/oglobal.h> 25#include <opie2/oglobal.h>
25 26#include <opie2/odebug.h>
26#include <qtopia/config.h> 27#include <qtopia/config.h>
27#include <qtopia/mimetype.h> 28#include <qtopia/mimetype.h>
28#include <qtopia/resource.h> 29#include <qtopia/resource.h>
29#include <qtopia/private/categories.h> 30#include <qtopia/private/categories.h>
30#include <qtopia/qpeapplication.h> 31#include <qtopia/qpeapplication.h>
31#include <qtopia/applnk.h> 32#include <qtopia/applnk.h>
32#include <qtopia/storage.h> 33#include <qtopia/storage.h>
33#ifdef Q_WS_QWS 34#ifdef Q_WS_QWS
34#include <qtopia/qcopenvelope_qws.h> 35#include <qtopia/qcopenvelope_qws.h>
35#endif 36#endif
37using namespace Opie::Core;
36 38
39/* QT */
37#include <qtimer.h> 40#include <qtimer.h>
38#include <qfileinfo.h> 41#include <qfileinfo.h>
39#include <qtextstream.h> 42#include <qtextstream.h>
40#include <qfile.h> 43#include <qfile.h>
41#include <qdir.h> 44#include <qdir.h>
42#include <qpainter.h> 45#include <qpainter.h>
43#include <qimage.h> 46#include <qimage.h>
44#include <qcopchannel_qws.h> 47#include <qcopchannel_qws.h>
45#include <qlistview.h> 48#include <qlistview.h>
46#include <qlist.h> 49#include <qlist.h>
47#include <qpixmap.h> 50#include <qpixmap.h>
48 51
49 52
50using namespace Opie::Core;
51AppLnkSet *DocumentList::appLnkSet = 0; 53AppLnkSet *DocumentList::appLnkSet = 0;
52 54
53static const int MAX_SEARCH_DEPTH = 10; 55static const int MAX_SEARCH_DEPTH = 10;
54 56
55 57
56class DocumentListPrivate : public QObject { 58class DocumentListPrivate : public QObject {
57 Q_OBJECT 59 Q_OBJECT
58public: 60public:
59 DocumentListPrivate( ServerInterface *gui ); 61 DocumentListPrivate( ServerInterface *gui );
60 ~DocumentListPrivate(); 62 ~DocumentListPrivate();
61 63
62 void initialize(); 64 void initialize();
@@ -99,25 +101,25 @@ public:
99 */ 101 */
100DocumentList::DocumentList( ServerInterface *serverGui, bool /*scanDocs*/, 102DocumentList::DocumentList( ServerInterface *serverGui, bool /*scanDocs*/,
101 QObject *parent, const char *name ) 103 QObject *parent, const char *name )
102 : QObject( parent, name ) 104 : QObject( parent, name )
103{ 105{
104 appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); 106 appLnkSet = new AppLnkSet( MimeType::appsFolderName() );
105 d = new DocumentListPrivate( serverGui ); 107 d = new DocumentListPrivate( serverGui );
106 d->needToSendAllDocLinks = false; 108 d->needToSendAllDocLinks = false;
107 109
108 Config cfg( "Launcher" ); 110 Config cfg( "Launcher" );
109 cfg.setGroup( "DocTab" ); 111 cfg.setGroup( "DocTab" );
110 d->scanDocs = cfg.readBoolEntry( "Enable", true ); 112 d->scanDocs = cfg.readBoolEntry( "Enable", true );
111 qDebug( "DocumentList::DocumentList() : scanDocs = %d", d->scanDocs ); 113 odebug << "DocumentList::DocumentList() : scanDocs = " << d->scanDocs << "" << oendl;
112 114
113 QTimer::singleShot( 10, this, SLOT( startInitialScan() ) ); 115 QTimer::singleShot( 10, this, SLOT( startInitialScan() ) );
114} 116}
115 117
116void DocumentList::startInitialScan() 118void DocumentList::startInitialScan()
117{ 119{
118 reloadAppLnks(); 120 reloadAppLnks();
119 reloadDocLnks(); 121 reloadDocLnks();
120} 122}
121 123
122DocumentList::~DocumentList() 124DocumentList::~DocumentList()
123{ 125{
@@ -132,35 +134,35 @@ void DocumentList::add( const DocLnk& doc )
132 d->serverGui->documentAdded( doc ); 134 d->serverGui->documentAdded( doc );
133} 135}
134 136
135 137
136void DocumentList::start() 138void DocumentList::start()
137{ 139{
138 resume(); 140 resume();
139} 141}
140 142
141 143
142void DocumentList::pause() 144void DocumentList::pause()
143{ 145{
144 //qDebug("pause %i", d->tid); 146 //odebug << "pause " << d->tid << "" << oendl;
145 killTimer( d->tid ); 147 killTimer( d->tid );
146 d->tid = 0; 148 d->tid = 0;
147} 149}
148 150
149 151
150void DocumentList::resume() 152void DocumentList::resume()
151{ 153{
152 if ( d->tid == 0 ) { 154 if ( d->tid == 0 ) {
153 d->tid = startTimer( 20 ); 155 d->tid = startTimer( 20 );
154 //qDebug("resumed %i", d->tid); 156 //odebug << "resumed " << d->tid << "" << oendl;
155 } 157 }
156} 158}
157 159
158/* 160/*
159void DocumentList::resend() 161void DocumentList::resend()
160{ 162{
161 // Re-emits all the added items to the list (firstly letting everyone know to 163 // Re-emits all the added items to the list (firstly letting everyone know to
162 // clear what they have as it is being sent again) 164 // clear what they have as it is being sent again)
163 pause(); 165 pause();
164 emit allRemoved(); 166 emit allRemoved();
165 QTimer::singleShot( 5, this, SLOT( resendWorker() ) ); 167 QTimer::singleShot( 5, this, SLOT( resendWorker() ) );
166} 168}
@@ -168,25 +170,25 @@ void DocumentList::resend()
168 170
169void DocumentList::resendWorker() 171void DocumentList::resendWorker()
170{ 172{
171 const QList<DocLnk> &list = d->dls.children(); 173 const QList<DocLnk> &list = d->dls.children();
172 for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) 174 for ( QListIterator<DocLnk> it( list ); it.current(); ++it )
173 add( *(*it) ); 175 add( *(*it) );
174 resume(); 176 resume();
175} 177}
176*/ 178*/
177 179
178void DocumentList::rescan() 180void DocumentList::rescan()
179{ 181{
180 //qDebug("rescan"); 182 //odebug << "rescan" << oendl;
181 pause(); 183 pause();
182 d->initialize(); 184 d->initialize();
183 resume(); 185 resume();
184} 186}
185 187
186 188
187void DocumentList::timerEvent( QTimerEvent *te ) 189void DocumentList::timerEvent( QTimerEvent *te )
188{ 190{
189 if ( te->timerId() == d->tid ) { 191 if ( te->timerId() == d->tid ) {
190 // Do 3 at a time 192 // Do 3 at a time
191 for (int i = 0; i < 3; i++ ) { 193 for (int i = 0; i < 3; i++ ) {
192 const DocLnk *lnk = d->iterate(); 194 const DocLnk *lnk = d->iterate();
@@ -223,34 +225,34 @@ void DocumentList::reloadAppLnks()
223 if ( !(*ittypes).isEmpty() ) { 225 if ( !(*ittypes).isEmpty() ) {
224 if ( !prevTypeList.contains(*ittypes) ) { 226 if ( !prevTypeList.contains(*ittypes) ) {
225 QString name = appLnkSet->typeName(*ittypes); 227 QString name = appLnkSet->typeName(*ittypes);
226 QPixmap pm = appLnkSet->typePixmap(*ittypes); 228 QPixmap pm = appLnkSet->typePixmap(*ittypes);
227 QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes); 229 QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes);
228 230
229 if (pm.isNull()) { 231 if (pm.isNull()) {
230 QImage img( Resource::loadImage( "UnknownDocument" ) ); 232 QImage img( Resource::loadImage( "UnknownDocument" ) );
231 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 233 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
232 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); 234 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() );
233 } 235 }
234 236
235 //qDebug("adding type %s", (*ittypes).latin1()); 237 //odebug << "adding type " << (*ittypes) << "" << oendl;
236 238
237 // ### our current launcher expects docs tab to be last 239 // ### our current launcher expects docs tab to be last
238 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); 240 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm );
239 } 241 }
240 prevTypeList.remove(*ittypes); 242 prevTypeList.remove(*ittypes);
241 } 243 }
242 } 244 }
243 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { 245 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) {
244 //qDebug("removing type %s", (*ittypes).latin1()); 246 //odebug << "removing type " << (*ittypes) << "" << oendl;
245 d->serverGui->typeRemoved(*ittypes); 247 d->serverGui->typeRemoved(*ittypes);
246 } 248 }
247 prevTypeList = types; 249 prevTypeList = types;
248 } 250 }
249 251
250 QListIterator<AppLnk> itapp( appLnkSet->children() ); 252 QListIterator<AppLnk> itapp( appLnkSet->children() );
251 AppLnk* l; 253 AppLnk* l;
252 while ( (l=itapp.current()) ) { 254 while ( (l=itapp.current()) ) {
253 ++itapp; 255 ++itapp;
254 if ( d->sendAppLnks && d->serverGui ) 256 if ( d->sendAppLnks && d->serverGui )
255 d->serverGui->applicationAdded( l->type(), *l ); 257 d->serverGui->applicationAdded( l->type(), *l );
256 } 258 }
@@ -265,65 +267,65 @@ void DocumentList::reloadDocLnks()
265 return; 267 return;
266 268
267 if ( d->sendDocLnks && d->serverGui ) { 269 if ( d->sendDocLnks && d->serverGui ) {
268 d->serverGui->documentScanningProgress( 0 ); 270 d->serverGui->documentScanningProgress( 0 );
269 d->serverGui->allDocumentsRemoved(); 271 d->serverGui->allDocumentsRemoved();
270 } 272 }
271 273
272 rescan(); 274 rescan();
273} 275}
274 276
275void DocumentList::linkChanged( QString arg ) 277void DocumentList::linkChanged( QString arg )
276{ 278{
277 //qDebug( "linkchanged( %s )", arg.latin1() ); 279 //odebug << "linkchanged( " << arg << " )" << oendl;
278 280
279 if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) { 281 if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) {
280 reloadAppLnks(); 282 reloadAppLnks();
281 } else { 283 } else {
282 284
283 const QList<DocLnk> &list = d->dls.children(); 285 const QList<DocLnk> &list = d->dls.children();
284 QListIterator<DocLnk> it( list ); 286 QListIterator<DocLnk> it( list );
285 while ( it.current() ) { 287 while ( it.current() ) {
286 DocLnk *doc = it.current(); 288 DocLnk *doc = it.current();
287 ++it; 289 ++it;
288 if ( ( doc->linkFileKnown() && doc->linkFile() == arg ) 290 if ( ( doc->linkFileKnown() && doc->linkFile() == arg )
289 || ( doc->fileKnown() && doc->file() == arg ) ) { 291 || ( doc->fileKnown() && doc->file() == arg ) ) {
290 //qDebug( "found old link" ); 292 //odebug << "found old link" << oendl;
291 DocLnk* dl = new DocLnk( arg ); 293 DocLnk* dl = new DocLnk( arg );
292 // add new one if it exists and matches the mimetype 294 // add new one if it exists and matches the mimetype
293 if ( d->store( dl ) ) { 295 if ( d->store( dl ) ) {
294 // Existing link has been changed, send old link ref and a ref 296 // Existing link has been changed, send old link ref and a ref
295 // to the new link 297 // to the new link
296 //qDebug( "change case" ); 298 //odebug << "change case" << oendl;
297 if ( d->serverGui ) 299 if ( d->serverGui )
298 d->serverGui->documentChanged( *doc, *dl ); 300 d->serverGui->documentChanged( *doc, *dl );
299 301
300 } else { 302 } else {
301 // Link has been removed or doesn't match the mimetypes any more 303 // Link has been removed or doesn't match the mimetypes any more
302 // so we aren't interested in it, so take it away from the list 304 // so we aren't interested in it, so take it away from the list
303 //qDebug( "removal case" ); 305 //odebug << "removal case" << oendl;
304 if ( d->serverGui ) 306 if ( d->serverGui )
305 d->serverGui->documentRemoved( *doc ); 307 d->serverGui->documentRemoved( *doc );
306 308
307 } 309 }
308 d->dls.remove( doc ); // remove old link from docLnkSet 310 d->dls.remove( doc ); // remove old link from docLnkSet
309 delete doc; 311 delete doc;
310 return; 312 return;
311 } 313 }
312 } 314 }
313 // Didn't find existing link, must be new 315 // Didn't find existing link, must be new
314 DocLnk* dl = new DocLnk( arg ); 316 DocLnk* dl = new DocLnk( arg );
315 if ( d->store( dl ) ) { 317 if ( d->store( dl ) ) {
316 // Add if it's a link we are interested in 318 // Add if it's a link we are interested in
317 //qDebug( "add case" ); 319 //odebug << "add case" << oendl;
318 add( *dl ); 320 add( *dl );
319 } 321 }
320 322
321 } 323 }
322} 324}
323 325
324void DocumentList::restoreDone() 326void DocumentList::restoreDone()
325{ 327{
326 reloadAppLnks(); 328 reloadAppLnks();
327 reloadDocLnks(); 329 reloadDocLnks();
328} 330}
329 331
@@ -369,30 +371,30 @@ void DocumentList::sendAllDocLinks()
369 } 371 }
370 if (fake) { 372 if (fake) {
371 contents += "[Desktop Entry]\n"; // No tr 373 contents += "[Desktop Entry]\n"; // No tr
372 contents += "Categories = " + // No tr 374 contents += "Categories = " + // No tr
373 cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr 375 cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr
374 contents += "Name = "+doc->name()+"\n"; // No tr 376 contents += "Name = "+doc->name()+"\n"; // No tr
375 contents += "Type = "+doc->type()+"\n"; // No tr 377 contents += "Type = "+doc->type()+"\n"; // No tr
376 } 378 }
377 contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) 379 contents += "File = "+doc->file()+"\n"; // No tr // (resolves path)
378 contents += QString("Size = %1\n").arg( fi.size() ); // No tr 380 contents += QString("Size = %1\n").arg( fi.size() ); // No tr
379 } 381 }
380 382
381 //qDebug( "sending length %d", contents.length() ); 383 //odebug << "sending length " << contents.length() << "" << oendl;
382#ifndef QT_NO_COP 384#ifndef QT_NO_COP
383 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); 385 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" );
384 e << contents; 386 e << contents;
385#endif 387#endif
386 //qDebug( "================ \n\n%s\n\n===============", contents.latin1() ); 388 //odebug << "================ \n\n" << contents << "\n\n===============" << oendl;
387 389
388 d->needToSendAllDocLinks = false; 390 d->needToSendAllDocLinks = false;
389} 391}
390 392
391 393
392 394
393 395
394 396
395 397
396 398
397 399
398 400
@@ -527,42 +529,42 @@ void DocumentListPrivate::estimatedPercentScanned()
527 if ( listDirs[d] ) { 529 if ( listDirs[d] ) {
528 int items = lists[d]->count(); 530 int items = lists[d]->count();
529 if ( items > 1 ) { 531 if ( items > 1 ) {
530 levelWeight = levelWeight / items; 532 levelWeight = levelWeight / items;
531 // Take in to account "." and ".." 533 // Take in to account "." and ".."
532 overallProgress += (listPositions[d] - 3) * levelWeight; 534 overallProgress += (listPositions[d] - 3) * levelWeight;
533 } 535 }
534 } else { 536 } else {
535 break; 537 break;
536 } 538 }
537 } 539 }
538 540
539 // qDebug( "overallProgress: %f", overallProgress ); 541 // odebug << "overallProgress: " << overallProgress << "" << oendl;
540 542
541 if ( serverGui ) 543 if ( serverGui )
542 serverGui->documentScanningProgress( (int)overallProgress ); 544 serverGui->documentScanningProgress( (int)overallProgress );
543} 545}
544 546
545 547
546const QString DocumentListPrivate::nextFile() 548const QString DocumentListPrivate::nextFile()
547{ 549{
548 while ( TRUE ) { 550 while ( TRUE ) {
549 while ( searchDepth < 0 ) { 551 while ( searchDepth < 0 ) {
550 // go to next base path 552 // go to next base path
551 if ( docPathsSearched >= docPaths.count() ) { 553 if ( docPathsSearched >= docPaths.count() ) {
552 // end of base paths 554 // end of base paths
553 return QString::null; 555 return QString::null;
554 } else { 556 } else {
555 QDir dir( docPaths[docPathsSearched] ); 557 QDir dir( docPaths[docPathsSearched] );
556 // qDebug("now using base path: %s", docPaths[docPathsSearched].latin1() ); 558 // odebug << "now using base path: " << docPaths[docPathsSearched] << "" << oendl;
557 docPathsSearched++; 559 docPathsSearched++;
558 if ( !dir.exists( ".Qtopia-ignore" ) ) { 560 if ( !dir.exists( ".Qtopia-ignore" ) ) {
559 listDirs[0] = new QDir( dir ); 561 listDirs[0] = new QDir( dir );
560 lists[0] = listDirs[0]->entryInfoList(); 562 lists[0] = listDirs[0]->entryInfoList();
561 listPositions[0] = 0; 563 listPositions[0] = 0;
562 searchDepth = 0; 564 searchDepth = 0;
563 } 565 }
564 } 566 }
565 } 567 }
566 568
567 const QFileInfoList *fil = lists[searchDepth]; 569 const QFileInfoList *fil = lists[searchDepth];
568 if (!fil) { 570 if (!fil) {
@@ -578,25 +580,25 @@ const QString DocumentListPrivate::nextFile()
578 lists[searchDepth] = 0; 580 lists[searchDepth] = 0;
579 listPositions[searchDepth] = 0; 581 listPositions[searchDepth] = 0;
580 searchDepth--; 582 searchDepth--;
581 } else { 583 } else {
582 const QFileInfo *fi = fl->at(pos); 584 const QFileInfo *fi = fl->at(pos);
583 listPositions[searchDepth]++; 585 listPositions[searchDepth]++;
584 QString bn = fi->fileName(); 586 QString bn = fi->fileName();
585 if ( bn[0] != '.' ) { 587 if ( bn[0] != '.' ) {
586 if ( fi->isDir() ) { 588 if ( fi->isDir() ) {
587 if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) { 589 if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) {
588 // go down a depth 590 // go down a depth
589 QDir dir( fi->filePath() ); 591 QDir dir( fi->filePath() );
590 // qDebug("now going in to path: %s", bn.latin1() ); 592 // odebug << "now going in to path: " << bn << "" << oendl;
591 if ( !dir.exists( ".Qtopia-ignore" ) ) { 593 if ( !dir.exists( ".Qtopia-ignore" ) ) {
592 if ( searchDepth < MAX_SEARCH_DEPTH - 1) { 594 if ( searchDepth < MAX_SEARCH_DEPTH - 1) {
593 searchDepth++; 595 searchDepth++;
594 listDirs[searchDepth] = new QDir( dir ); 596 listDirs[searchDepth] = new QDir( dir );
595 lists[searchDepth] = listDirs[searchDepth]->entryInfoList(); 597 lists[searchDepth] = listDirs[searchDepth]->entryInfoList();
596 listPositions[searchDepth] = 0; 598 listPositions[searchDepth] = 0;
597 } 599 }
598 } 600 }
599 } 601 }
600 } else { 602 } else {
601 estimatedPercentScanned(); 603 estimatedPercentScanned();
602 return fl->at(pos)->filePath(); 604 return fl->at(pos)->filePath();
@@ -619,80 +621,80 @@ bool DocumentListPrivate::store( DocLnk* dl )
619 621
620 // don't store - delete 622 // don't store - delete
621 delete dl; 623 delete dl;
622 return FALSE; 624 return FALSE;
623} 625}
624 626
625 627
626 #define MAGIC_NUMBER((void*)2) 628 #define MAGIC_NUMBER((void*)2)
627 629
628const DocLnk *DocumentListPrivate::iterate() 630const DocLnk *DocumentListPrivate::iterate()
629{ 631{
630 if ( state == Find ) { 632 if ( state == Find ) {
631 //qDebug("state Find"); 633 //odebug << "state Find" << oendl;
632 QString file = nextFile(); 634 QString file = nextFile();
633 while ( !file.isNull() ) { 635 while ( !file.isNull() ) {
634 if ( file.right(8) == ".desktop" ) { // No tr 636 if ( file.right(8) == ".desktop" ) { // No tr
635 DocLnk* dl = new DocLnk( file ); 637 DocLnk* dl = new DocLnk( file );
636 if ( store(dl) ) 638 if ( store(dl) )
637 return dl; 639 return dl;
638 } else { 640 } else {
639 reference.insert( file, MAGIC_NUMBER ); 641 reference.insert( file, MAGIC_NUMBER );
640 } 642 }
641 file = nextFile(); 643 file = nextFile();
642 } 644 }
643 state = RemoveKnownFiles; 645 state = RemoveKnownFiles;
644 646
645 if ( serverGui ) 647 if ( serverGui )
646 serverGui->documentScanningProgress( 75 ); 648 serverGui->documentScanningProgress( 75 );
647 } 649 }
648 650
649 static int iterationI; 651 static int iterationI;
650 static int iterationCount; 652 static int iterationCount;
651 653
652 if ( state == RemoveKnownFiles ) { 654 if ( state == RemoveKnownFiles ) {
653 //qDebug("state RemoveKnownFiles"); 655 //odebug << "state RemoveKnownFiles" << oendl;
654 const QList<DocLnk> &list = dls.children(); 656 const QList<DocLnk> &list = dls.children();
655 for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) { 657 for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) {
656 reference.remove( (*it)->file() ); 658 reference.remove( (*it)->file() );
657 // ### does this need to be deleted? 659 // ### does this need to be deleted?
658 } 660 }
659 dit = new QDictIterator<void>(reference); 661 dit = new QDictIterator<void>(reference);
660 state = MakeUnknownFiles; 662 state = MakeUnknownFiles;
661 663
662 iterationI = 0; 664 iterationI = 0;
663 iterationCount = dit->count(); 665 iterationCount = dit->count();
664 } 666 }
665 667
666 if ( state == MakeUnknownFiles ) { 668 if ( state == MakeUnknownFiles ) {
667 //qDebug("state MakeUnknownFiles"); 669 //odebug << "state MakeUnknownFiles" << oendl;
668 for (void* c; (c=dit->current()); ++(*dit) ) { 670 for (void* c; (c=dit->current()); ++(*dit) ) {
669 if ( c == MAGIC_NUMBER ) { 671 if ( c == MAGIC_NUMBER ) {
670 DocLnk* dl = new DocLnk; 672 DocLnk* dl = new DocLnk;
671 QFileInfo fi( dit->currentKey() ); 673 QFileInfo fi( dit->currentKey() );
672 dl->setFile( fi.filePath() ); 674 dl->setFile( fi.filePath() );
673 dl->setName( fi.baseName() ); 675 dl->setName( fi.baseName() );
674 if ( store(dl) ) { 676 if ( store(dl) ) {
675 ++*dit; 677 ++*dit;
676 iterationI++; 678 iterationI++;
677 if ( serverGui ) 679 if ( serverGui )
678 serverGui->documentScanningProgress( 75 + (25*iterationI)/iterationCount ); 680 serverGui->documentScanningProgress( 75 + (25*iterationI)/iterationCount );
679 return dl; 681 return dl;
680 } 682 }
681 } 683 }
682 iterationI++; 684 iterationI++;
683 } 685 }
684 686
685 delete dit; 687 delete dit;
686 dit = 0; 688 dit = 0;
687 state = Done; 689 state = Done;
688 } 690 }
689 691
690 //qDebug("state Done"); 692 //odebug << "state Done" << oendl;
691 return NULL; 693 return NULL;
692} 694}
693 695
694 696
695#include "documentlist.moc" 697#include "documentlist.moc"
696 698
697 699
698 700
diff --git a/core/launcher/firstuse.cpp b/core/launcher/firstuse.cpp
index 4316648..e9e2d83 100644
--- a/core/launcher/firstuse.cpp
+++ b/core/launcher/firstuse.cpp
@@ -20,47 +20,49 @@
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>
33
34#include "calibrate.h" 32#include "calibrate.h"
35#include "documentlist.h" 33#include "documentlist.h"
36 34
35/* OPIE */
36#include <opie2/odebug.h>
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/config.h> 39#include <qtopia/config.h>
40#include <qtopia/fontmanager.h> 40#include <qtopia/fontmanager.h>
41using namespace Opie::Core;
41 42
43/* QT */
42#include <qfile.h> 44#include <qfile.h>
43#include <qpainter.h> 45#include <qpainter.h>
44#include <qsimplerichtext.h> 46#include <qsimplerichtext.h>
45#include <qpushbutton.h> 47#include <qpushbutton.h>
46#include <qlabel.h> 48#include <qlabel.h>
47#include <qtimer.h> 49#include <qtimer.h>
48 50
49#if defined( Q_WS_QWS ) 51#if defined( Q_WS_QWS )
50#include <qwsdisplay_qws.h> 52#include <qwsdisplay_qws.h>
51#include <qgfx_qws.h> 53#include <qgfx_qws.h>
52#endif 54#endif
53 55
54 56/* STD */
55#include <stdlib.h> 57#include <stdlib.h>
56#include <sys/types.h> 58#include <sys/types.h>
57#if defined(Q_OS_LINUX) || defined(_OS_LINUX_) 59#if defined(Q_OS_LINUX) || defined(_OS_LINUX_)
58#include <unistd.h> 60#include <unistd.h>
59#endif 61#endif
60 62
61 63
62struct { 64struct {
63 bool enabled; 65 bool enabled;
64 const char *app; 66 const char *app;
65 const char *start; 67 const char *start;
66 const char *stop; 68 const char *stop;
@@ -146,25 +148,25 @@ FirstUse::FirstUse(QWidget* parent, const char * name, WFlags wf) :
146 148
147 inputMethods->setGeometry(0,0, sz.width(), controlHeight ); 149 inputMethods->setGeometry(0,0, sz.width(), controlHeight );
148 x += sz.width(); 150 x += sz.width();
149 151
150 back->setGeometry(x, 0, buttonWidth, controlHeight); 152 back->setGeometry(x, 0, buttonWidth, controlHeight);
151 x += buttonWidth; 153 x += buttonWidth;
152 next->setGeometry(x, 0, buttonWidth, controlHeight); 154 next->setGeometry(x, 0, buttonWidth, controlHeight);
153 155
154 taskBar->setGeometry( 0, height() - controlHeight, desk.width(), controlHeight); 156 taskBar->setGeometry( 0, height() - controlHeight, desk.width(), controlHeight);
155 taskBar->hide(); 157 taskBar->hide();
156 158
157#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 159#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
158 qDebug("Setting up QCop to QPE/System"); 160 odebug << "Setting up QCop to QPE/System" << oendl;
159 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 161 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
160 connect(sysChannel, SIGNAL(received(const QCString&,const QByteArray&)), 162 connect(sysChannel, SIGNAL(received(const QCString&,const QByteArray&)),
161 this, SLOT(message(const QCString&,const QByteArray&)) ); 163 this, SLOT(message(const QCString&,const QByteArray&)) );
162#endif 164#endif
163 calcMaxWindowRect(); 165 calcMaxWindowRect();
164 166
165 m_calHandler = ( QWSServer::mouseHandler() && QWSServer::mouseHandler()->inherits("QCalibratedMouseHandler") ) ? true : false; 167 m_calHandler = ( QWSServer::mouseHandler() && QWSServer::mouseHandler()->inherits("QCalibratedMouseHandler") ) ? true : false;
166 168
167 if ( m_calHandler) { 169 if ( m_calHandler) {
168 if ( !QFile::exists("/etc/pointercal") ) { 170 if ( !QFile::exists("/etc/pointercal") ) {
169 needCalibrate = TRUE; 171 needCalibrate = TRUE;
170 grabMouse(); 172 grabMouse();
@@ -214,122 +216,122 @@ void FirstUse::calcMaxWindowRect()
214#else 216#else
215 QWSServer::setMaxWindowRect( wr ); 217 QWSServer::setMaxWindowRect( wr );
216#endif 218#endif
217#endif 219#endif
218} 220}
219 221
220/* cancel current dialog, and bring up next */ 222/* cancel current dialog, and bring up next */
221void FirstUse::nextDialog() 223void FirstUse::nextDialog()
222{ 224{
223 int prevApp = currApp; 225 int prevApp = currApp;
224 do { 226 do {
225 currApp++; 227 currApp++;
226 qDebug( "currApp = %d", currApp ); 228 odebug << "currApp = " << currApp << "" << oendl;
227 if ( settingsTable[currApp].app == 0 ) { 229 if ( settingsTable[currApp].app == 0 ) {
228 if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) { 230 if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) {
229 // The last application is still running. 231 // The last application is still running.
230 // Tell it to stop, and when its done we'll come back 232 // Tell it to stop, and when its done we'll come back
231 // to nextDialog and exit. 233 // to nextDialog and exit.
232 qDebug( "Waiting for %s to exit", settingsTable[prevApp].app ); 234 odebug << "Waiting for " << settingsTable[prevApp].app << " to exit" << oendl;
233 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, 235 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app,
234 settingsTable[prevApp].stop ); 236 settingsTable[prevApp].stop );
235 currApp = prevApp; 237 currApp = prevApp;
236 } else { 238 } else {
237 qDebug( "Done!" ); 239 odebug << "Done!" << oendl;
238 Config config( "qpe" ); 240 Config config( "qpe" );
239 config.setGroup( "Startup" ); 241 config.setGroup( "Startup" );
240 config.writeEntry( "FirstUse", FALSE ); 242 config.writeEntry( "FirstUse", FALSE );
241 QPixmap pix = Resource::loadPixmap("bigwait"); 243 QPixmap pix = Resource::loadPixmap("bigwait");
242 QLabel *lblWait = new QLabel(0, "wait hack!", // No tr 244 QLabel *lblWait = new QLabel(0, "wait hack!", // No tr
243 QWidget::WStyle_Customize | QWidget::WDestructiveClose | 245 QWidget::WStyle_Customize | QWidget::WDestructiveClose |
244 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool | 246 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool |
245 QWidget::WStyle_StaysOnTop); 247 QWidget::WStyle_StaysOnTop);
246 lblWait->setPixmap( pix ); 248 lblWait->setPixmap( pix );
247 lblWait->setAlignment( QWidget::AlignCenter ); 249 lblWait->setAlignment( QWidget::AlignCenter );
248 lblWait->setGeometry( qApp->desktop()->geometry() ); 250 lblWait->setGeometry( qApp->desktop()->geometry() );
249 lblWait->show(); 251 lblWait->show();
250 qApp->processEvents(); 252 qApp->processEvents();
251 QTimer::singleShot( 1000, lblWait, SLOT(close()) ); 253 QTimer::singleShot( 1000, lblWait, SLOT(close()) );
252 repaint(); 254 repaint();
253 close(); 255 close();
254 ServerApplication::allowRestart = TRUE; 256 ServerApplication::allowRestart = TRUE;
255 } 257 }
256 return; 258 return;
257 } 259 }
258 } while ( !settingsTable[currApp].enabled ); 260 } while ( !settingsTable[currApp].enabled );
259 261
260 if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) { 262 if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) {
261 qDebug( "Shutdown: %s", settingsTable[prevApp].app ); 263 odebug << "Shutdown: " << settingsTable[prevApp].app << "" << oendl;
262 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, 264 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app,
263 settingsTable[prevApp].stop ); 265 settingsTable[prevApp].stop );
264 waitForExit = prevApp; 266 waitForExit = prevApp;
265 } else { 267 } else {
266 qDebug( "Startup: %s", settingsTable[currApp].app ); 268 odebug << "Startup: " << settingsTable[currApp].app << "" << oendl;
267 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, 269 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app,
268 settingsTable[currApp].start ); 270 settingsTable[currApp].start );
269 waitingForLaunch = TRUE; 271 waitingForLaunch = TRUE;
270 } 272 }
271 273
272 updateButtons(); 274 updateButtons();
273} 275}
274 276
275/* accept current dialog and bring up previous */ 277/* accept current dialog and bring up previous */
276void FirstUse::previousDialog() 278void FirstUse::previousDialog()
277{ 279{
278 int prevApp = currApp; 280 int prevApp = currApp;
279 do { 281 do {
280 currApp--; 282 currApp--;
281 if ( currApp < 0 ) { 283 if ( currApp < 0 ) {
282 currApp = prevApp; 284 currApp = prevApp;
283 return; 285 return;
284 } 286 }
285 } while ( !settingsTable[currApp].enabled ); 287 } while ( !settingsTable[currApp].enabled );
286 288
287 if ( prevApp >= 0 ) { 289 if ( prevApp >= 0 ) {
288 qDebug( "Shutdown: %s", settingsTable[prevApp].app ); 290 odebug << "Shutdown: " << settingsTable[prevApp].app << "" << oendl;
289 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, 291 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app,
290 settingsTable[prevApp].stop ); 292 settingsTable[prevApp].stop );
291/* 293/*
292 if (settingsTable[prevApp].app == QString("systemtime")) 294 if (settingsTable[prevApp].app == QString("systemtime"))
293 QCopEnvelope e("QPE/Application/citytime", "close()"); 295 QCopEnvelope e("QPE/Application/citytime", "close()");
294*/ 296*/
295 waitForExit = prevApp; 297 waitForExit = prevApp;
296 } else { 298 } else {
297 qDebug( "Startup: %s", settingsTable[currApp].app ); 299 odebug << "Startup: " << settingsTable[currApp].app << "" << oendl;
298 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, 300 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app,
299 settingsTable[currApp].start ); 301 settingsTable[currApp].start );
300 waitingForLaunch = TRUE; 302 waitingForLaunch = TRUE;
301 } 303 }
302 304
303 updateButtons(); 305 updateButtons();
304} 306}
305 307
306void FirstUse::message(const QCString &msg, const QByteArray &data) 308void FirstUse::message(const QCString &msg, const QByteArray &data)
307{ 309{
308 QDataStream stream( data, IO_ReadOnly ); 310 QDataStream stream( data, IO_ReadOnly );
309 if ( msg == "timeChange(QString)" ) { 311 if ( msg == "timeChange(QString)" ) {
310 QString t; 312 QString t;
311 stream >> t; 313 stream >> t;
312 if ( t.isNull() ) 314 if ( t.isNull() )
313 unsetenv("TZ"); 315 unsetenv("TZ");
314 else 316 else
315 setenv( "TZ", t.latin1(), 1 ); 317 setenv( "TZ", t.latin1(), 1 );
316 } 318 }
317} 319}
318 320
319void FirstUse::terminated( int, const QString &app ) 321void FirstUse::terminated( int, const QString &app )
320{ 322{
321 qDebug( "--- terminated: %s", app.latin1() ); 323 odebug << "--- terminated: " << app << "" << oendl;
322 if ( waitForExit != -1 && settingsTable[waitForExit].app == app ) { 324 if ( waitForExit != -1 && settingsTable[waitForExit].app == app ) {
323 qDebug( "Startup: %s", settingsTable[currApp].app ); 325 odebug << "Startup: " << settingsTable[currApp].app << "" << oendl;
324 if ( settingsTable[waitForExit].app == "language" ) { // No tr 326 if ( settingsTable[waitForExit].app == "language" ) { // No tr
325 Config config("locale"); 327 Config config("locale");
326 config.setGroup( "Language"); 328 config.setGroup( "Language");
327 QString l = config.readEntry( "Language", "en"); 329 QString l = config.readEntry( "Language", "en");
328 if ( l != lang ) { 330 if ( l != lang ) {
329 reloadLanguages(); 331 reloadLanguages();
330 needRestart = TRUE; 332 needRestart = TRUE;
331 lang = l; 333 lang = l;
332 } 334 }
333 } 335 }
334 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, 336 QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app,
335 settingsTable[currApp].start ); 337 settingsTable[currApp].start );
@@ -338,83 +340,83 @@ void FirstUse::terminated( int, const QString &app )
338 repaint(); 340 repaint();
339 waitForExit = -1; 341 waitForExit = -1;
340 } else if ( settingsTable[currApp].app == app ) { 342 } else if ( settingsTable[currApp].app == app ) {
341 nextDialog(); 343 nextDialog();
342 } else { 344 } else {
343 back->setEnabled(TRUE); 345 back->setEnabled(TRUE);
344 next->setEnabled(TRUE); 346 next->setEnabled(TRUE);
345 } 347 }
346} 348}
347 349
348void FirstUse::newQcopChannel(const QString& channelName) 350void FirstUse::newQcopChannel(const QString& channelName)
349{ 351{
350 qDebug("channel %s added", channelName.data() ); 352 odebug << "channel " << channelName.data() << " added" << oendl;
351 QString prefix("QPE/Application/"); 353 QString prefix("QPE/Application/");
352 if (channelName.startsWith(prefix)) { 354 if (channelName.startsWith(prefix)) {
353 QString appName = channelName.mid(prefix.length()); 355 QString appName = channelName.mid(prefix.length());
354 if ( currApp >= 0 && appName == settingsTable[currApp].app ) { 356 if ( currApp >= 0 && appName == settingsTable[currApp].app ) {
355 qDebug( "Application: %s started", settingsTable[currApp].app ); 357 odebug << "Application: " << settingsTable[currApp].app << " started" << oendl;
356 waitingForLaunch = FALSE; 358 waitingForLaunch = FALSE;
357 updateButtons(); 359 updateButtons();
358 repaint(); 360 repaint();
359 } else if (appName != "quicklauncher") { 361 } else if (appName != "quicklauncher") {
360 back->setEnabled(FALSE); 362 back->setEnabled(FALSE);
361 next->setEnabled(FALSE); 363 next->setEnabled(FALSE);
362 } 364 }
363 } 365 }
364} 366}
365 367
366void FirstUse::reloadLanguages() 368void FirstUse::reloadLanguages()
367{ 369{
368 // read language from config file. Waiting on QCop takes too long. 370 // read language from config file. Waiting on QCop takes too long.
369 Config config("locale"); 371 Config config("locale");
370 config.setGroup( "Language"); 372 config.setGroup( "Language");
371 QString l = config.readEntry( "Language", "en"); 373 QString l = config.readEntry( "Language", "en");
372 QString cl = getenv("LANG"); 374 QString cl = getenv("LANG");
373 qWarning("language message - " + l); 375 owarn << "language message - " + l << oendl;
374 // setting anyway... 376 // setting anyway...
375 if (l.isNull() ) 377 if (l.isNull() )
376 unsetenv( "LANG" ); 378 unsetenv( "LANG" );
377 else { 379 else {
378 qWarning("and its not null"); 380 owarn << "and its not null" << oendl;
379 setenv( "LANG", l.latin1(), 1 ); 381 setenv( "LANG", l.latin1(), 1 );
380 } 382 }
381#ifndef QT_NO_TRANSLATION 383#ifndef QT_NO_TRANSLATION
382 // clear old translators 384 // clear old translators
383#ifndef _MSC_VER 385#ifndef _MSC_VER
384 //### revise to allow removal of translators under MSVC 386 //### revise to allow removal of translators under MSVC
385 if(qApp->translators) { 387 if(qApp->translators) {
386 qApp->translators->setAutoDelete(TRUE); 388 qApp->translators->setAutoDelete(TRUE);
387 delete (qApp->translators); 389 delete (qApp->translators);
388 qApp->translators = 0; 390 qApp->translators = 0;
389 } 391 }
390#endif 392#endif
391 393
392 // load translation tables 394 // load translation tables
393 transApp = new QTranslator(qApp); 395 transApp = new QTranslator(qApp);
394 QString tfn = QPEApplication::qpeDir() + "i18n/"+l+"/qpe.qm"; 396 QString tfn = QPEApplication::qpeDir() + "i18n/"+l+"/qpe.qm";
395 qWarning("loading " + tfn); 397 owarn << "loading " + tfn << oendl;
396 if ( transApp->load(tfn) ) { 398 if ( transApp->load(tfn) ) {
397 qWarning("installing translator"); 399 owarn << "installing translator" << oendl;
398 qApp->installTranslator( transApp ); 400 qApp->installTranslator( transApp );
399 } else { 401 } else {
400 delete transApp; 402 delete transApp;
401 transApp = 0; 403 transApp = 0;
402 } 404 }
403 405
404 transLib = new QTranslator(qApp); 406 transLib = new QTranslator(qApp);
405 tfn = QPEApplication::qpeDir() + "i18n/"+l+"/libqpe.qm"; 407 tfn = QPEApplication::qpeDir() + "i18n/"+l+"/libqpe.qm";
406 qWarning("loading " + tfn); 408 owarn << "loading " + tfn << oendl;
407 if ( transLib->load(tfn) ) { 409 if ( transLib->load(tfn) ) {
408 qWarning("installing translator library"); 410 owarn << "installing translator library" << oendl;
409 qApp->installTranslator( transLib ); 411 qApp->installTranslator( transLib );
410 } else { 412 } else {
411 delete transLib; 413 delete transLib;
412 transLib = 0; 414 transLib = 0;
413 } 415 }
414 loadPixmaps(); 416 loadPixmaps();
415 //###language/font hack; should look it up somewhere 417 //###language/font hack; should look it up somewhere
416#ifdef Q_WS_QWS 418#ifdef Q_WS_QWS
417 if ( l == "ja" || l == "zh_CN" || l == "zh_TW" || l == "ko" ) { 419 if ( l == "ja" || l == "zh_CN" || l == "zh_TW" || l == "ko" ) {
418 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 420 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
419 qApp->setFont( fn, TRUE ); 421 qApp->setFont( fn, TRUE );
420 } else { 422 } else {
diff --git a/core/launcher/inputmethods.cpp b/core/launcher/inputmethods.cpp
index 19e799a..cef16bf 100644
--- a/core/launcher/inputmethods.cpp
+++ b/core/launcher/inputmethods.cpp
@@ -12,49 +12,45 @@
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#define QTOPIA_INTERNAL_LANGLIST 21#define QTOPIA_INTERNAL_LANGLIST
22#include "inputmethods.h" 22#include "inputmethods.h"
23 23
24/* OPIE */
25#include <opie2/odebug.h>
24#include <qtopia/config.h> 26#include <qtopia/config.h>
25#include <qtopia/qpeapplication.h> 27#include <qtopia/qpeapplication.h>
28using namespace Opie::Core;
26 29
30/* QT */
27#include <qpopupmenu.h> 31#include <qpopupmenu.h>
28#include <qtoolbutton.h> 32#include <qtoolbutton.h>
29#include <qwidgetstack.h> 33#include <qwidgetstack.h>
30#include <qlayout.h> 34#include <qlayout.h>
31#include <qdir.h> 35#include <qdir.h>
32#include <stdlib.h>
33#include <qtl.h> 36#include <qtl.h>
34
35#ifdef Q_WS_QWS 37#ifdef Q_WS_QWS
36#include <qwindowsystem_qws.h> 38#include <qwindowsystem_qws.h>
37#include <qwsevent_qws.h> 39#include <qwsevent_qws.h>
38#include <qcopchannel_qws.h> 40#include <qcopchannel_qws.h>
39#endif 41#endif
40 42
41/* ### SingleFloppy if someone is interested? */ 43/* STD */
42#if 0 44#include <stdlib.h>
43#ifdef QT_NO_COMPONENT
44#include "../plugins/inputmethods/handwriting/handwritingimpl.h"
45#include "../plugins/inputmethods/keyboard/keyboardimpl.h"
46#include "../3rdparty/plugins/inputmethods/pickboard/pickboardimpl.h"
47#endif
48#endif
49 45
50/* XPM */ 46/* XPM */
51static const char * tri_xpm[]={ 47static const char * tri_xpm[]={
52"9 9 2 1", 48"9 9 2 1",
53"a c #000000", 49"a c #000000",
54". c None", 50". c None",
55".........", 51".........",
56".........", 52".........",
57".........", 53".........",
58"....a....", 54"....a....",
59"...aaa...", 55"...aaa...",
60"..aaaaa..", 56"..aaaaa..",
@@ -253,25 +249,25 @@ void InputMethods::setPreferedHandlers() {
253 249
254 QValueList<InputMethod>::Iterator it; 250 QValueList<InputMethod>::Iterator it;
255 if (!inputModifierList.isEmpty() && !im.isEmpty() ) { 251 if (!inputModifierList.isEmpty() && !im.isEmpty() ) {
256 for (it = inputModifierList.begin(); it != inputModifierList.end(); ++it ) 252 for (it = inputModifierList.begin(); it != inputModifierList.end(); ++it )
257 if ( (*it).name() == im ) { 253 if ( (*it).name() == im ) {
258 imethod = &(*it); break; 254 imethod = &(*it); break;
259 } 255 }
260 256
261 } 257 }
262 if (!inputMethodList.isEmpty() && !current.isEmpty() ) { 258 if (!inputMethodList.isEmpty() && !current.isEmpty() ) {
263 for (it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) 259 for (it = inputMethodList.begin(); it != inputMethodList.end(); ++it )
264 if ( (*it).name() == current ) { 260 if ( (*it).name() == current ) {
265 qWarning("preferred keyboard is %s", current.latin1() ); 261 owarn << "preferred keyboard is " << current << "" << oendl;
266 mkeyboard = &(*it); 262 mkeyboard = &(*it);
267 kbdButton->setPixmap( *mkeyboard->icon() ); 263 kbdButton->setPixmap( *mkeyboard->icon() );
268 break; 264 break;
269 } 265 }
270 } 266 }
271 267
272} 268}
273 269
274void InputMethods::loadInputMethods() 270void InputMethods::loadInputMethods()
275{ 271{
276#ifndef QT_NO_COMPONENT 272#ifndef QT_NO_COMPONENT
277 hideInputMethod(); 273 hideInputMethod();
@@ -296,31 +292,31 @@ void InputMethods::loadInputMethods()
296 input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); 292 input.widget = input.interface->inputMethod( 0, inputWidgetStyle );
297 input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); 293 input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) );
298 inputMethodList.append( input ); 294 inputMethodList.append( input );
299 } else if ( lib->queryInterface( IID_ExtInputMethod, (QUnknownInterface**)&eface ) == QS_OK ) { 295 } else if ( lib->queryInterface( IID_ExtInputMethod, (QUnknownInterface**)&eface ) == QS_OK ) {
300 InputMethod input; 296 InputMethod input;
301 input.newIM = TRUE; 297 input.newIM = TRUE;
302 input.library = lib; 298 input.library = lib;
303 input.libName = *it; 299 input.libName = *it;
304 input.extInterface = eface; 300 input.extInterface = eface;
305 input.widget = input.extInterface->keyboardWidget( 0, inputWidgetStyle ); 301 input.widget = input.extInterface->keyboardWidget( 0, inputWidgetStyle );
306 // may be either a simple, or advanced. 302 // may be either a simple, or advanced.
307 if (input.widget) { 303 if (input.widget) {
308 //qDebug("its a keyboard"); 304 //odebug << "its a keyboard" << oendl;
309 inputMethodList.append( input ); 305 inputMethodList.append( input );
310 } else { 306 } else {
311 //qDebug("its a real im"); 307 //odebug << "its a real im" << oendl;
312 input.widget = input.extInterface->statusWidget( 0, 0 ); 308 input.widget = input.extInterface->statusWidget( 0, 0 );
313 if (input.widget) { 309 if (input.widget) {
314 //qDebug("blah"); 310 //odebug << "blah" << oendl;
315 inputModifierList.append( input ); 311 inputModifierList.append( input );
316 imButton->addWidget(input.widget, inputModifierList.count()); 312 imButton->addWidget(input.widget, inputModifierList.count());
317 } 313 }
318 } 314 }
319 }else{ 315 }else{
320 delete lib; 316 delete lib;
321 lib = 0l; 317 lib = 0l;
322 } 318 }
323 installTranslator( (*it).left( (*it).find(".") ) ); 319 installTranslator( (*it).left( (*it).find(".") ) );
324 } 320 }
325 qHeapSort( inputMethodList ); 321 qHeapSort( inputMethodList );
326#endif /* killed BUILT in cause they would not compile */ 322#endif /* killed BUILT in cause they would not compile */
@@ -532,61 +528,61 @@ void InputMethods::showKbd( bool on )
532 528
533 if ( on ) 529 if ( on )
534 { 530 {
535 mkeyboard->resetState(); 531 mkeyboard->resetState();
536 532
537 int height = QMIN( mkeyboard->widget->sizeHint().height(), 134 ); 533 int height = QMIN( mkeyboard->widget->sizeHint().height(), 134 );
538 int width = qApp->desktop()->width() * (inputWidgetWidth*0.01); 534 int width = qApp->desktop()->width() * (inputWidgetWidth*0.01);
539 int left = 0; 535 int left = 0;
540 int top = mapToGlobal( QPoint() ).y() - height; 536 int top = mapToGlobal( QPoint() ).y() - height;
541 537
542 if ( inputWidgetStyle & QWidget::WStyle_DialogBorder ) 538 if ( inputWidgetStyle & QWidget::WStyle_DialogBorder )
543 { 539 {
544 qDebug( "InputMethods: reading geometry." ); 540 odebug << "InputMethods: reading geometry." << oendl;
545 Config cfg( "Launcher" ); 541 Config cfg( "Launcher" );
546 cfg.setGroup( "InputMethods" ); 542 cfg.setGroup( "InputMethods" );
547 int l = cfg.readNumEntry( "absX", -1 ); 543 int l = cfg.readNumEntry( "absX", -1 );
548 int t = cfg.readNumEntry( "absY", -1 ); 544 int t = cfg.readNumEntry( "absY", -1 );
549 int w = cfg.readNumEntry( "absWidth", -1 ); 545 int w = cfg.readNumEntry( "absWidth", -1 );
550 int h = cfg.readNumEntry( "absHeight", -1 ); 546 int h = cfg.readNumEntry( "absHeight", -1 );
551 547
552 if ( l > -1 && t > -1 && w > -1 && h > -1 ) 548 if ( l > -1 && t > -1 && w > -1 && h > -1 )
553 { 549 {
554 qDebug( "InputMethods: config values ( %d, %d, %d, %d ) are ok.", l, t, w, h ); 550 odebug << "InputMethods: config values ( " << l << ", " << t << ", " << w << ", " << h << " ) are ok." << oendl;
555 left = l; 551 left = l;
556 top = t; 552 top = t;
557 width = w; 553 width = w;
558 height = h; 554 height = h;
559 } 555 }
560 else 556 else
561 { 557 {
562 qDebug( "InputMethods: config values are new or not ok." ); 558 odebug << "InputMethods: config values are new or not ok." << oendl;
563 } 559 }
564 } 560 }
565 else 561 else
566 { 562 {
567 qDebug( "InputMethods: no floating selected." ); 563 odebug << "InputMethods: no floating selected." << oendl;
568 } 564 }
569 mkeyboard->widget->resize( width, height ); 565 mkeyboard->widget->resize( width, height );
570 mkeyboard->widget->move( left, top ); 566 mkeyboard->widget->move( left, top );
571 mkeyboard->widget->show(); 567 mkeyboard->widget->show();
572 mkeyboard->widget->installEventFilter( this ); 568 mkeyboard->widget->installEventFilter( this );
573 } 569 }
574 else 570 else
575 { 571 {
576 if ( inputWidgetStyle & QWidget::WStyle_DialogBorder ) 572 if ( inputWidgetStyle & QWidget::WStyle_DialogBorder )
577 { 573 {
578 QPoint pos = mkeyboard->widget->pos(); 574 QPoint pos = mkeyboard->widget->pos();
579 QSize siz = mkeyboard->widget->size(); 575 QSize siz = mkeyboard->widget->size();
580 qDebug( "InputMethods: saving geometry." ); 576 odebug << "InputMethods: saving geometry." << oendl;
581 Config cfg( "Launcher" ); 577 Config cfg( "Launcher" );
582 cfg.setGroup( "InputMethods" ); 578 cfg.setGroup( "InputMethods" );
583 cfg.writeEntry( "absX", pos.x() ); 579 cfg.writeEntry( "absX", pos.x() );
584 cfg.writeEntry( "absY", pos.y() ); 580 cfg.writeEntry( "absY", pos.y() );
585 cfg.writeEntry( "absWidth", siz.width() ); 581 cfg.writeEntry( "absWidth", siz.width() );
586 cfg.writeEntry( "absHeight", siz.height() ); 582 cfg.writeEntry( "absHeight", siz.height() );
587 cfg.write(); 583 cfg.write();
588 mkeyboard->widget->removeEventFilter( this ); 584 mkeyboard->widget->removeEventFilter( this );
589 } 585 }
590 mkeyboard->widget->hide(); 586 mkeyboard->widget->hide();
591 } 587 }
592 588
diff --git a/core/launcher/irserver.cpp b/core/launcher/irserver.cpp
index a0e9c16..092eb0c 100644
--- a/core/launcher/irserver.cpp
+++ b/core/launcher/irserver.cpp
@@ -9,68 +9,68 @@
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
22#include "irserver.h" 21#include "irserver.h"
22#include "obexinterface.h"
23 23
24/* OPIE */
25#include <opie2/odebug.h>
24#include <qtopia/qlibrary.h> 26#include <qtopia/qlibrary.h>
25#include <qtopia/qpeapplication.h> 27#include <qtopia/qpeapplication.h>
26 28
27 29/* QT */
28#include "obexinterface.h"
29
30#include <qdir.h> 30#include <qdir.h>
31 31
32IrServer::IrServer( QObject *parent, const char *name ) 32IrServer::IrServer( QObject *parent, const char *name )
33 : QObject( parent, name ), obexIface(0) 33 : QObject( parent, name ), obexIface(0)
34{ 34{
35 lib = 0; 35 lib = 0;
36 obexIface = 0; 36 obexIface = 0;
37 QString path = QPEApplication::qpeDir() + "/plugins/obex/"; 37 QString path = QPEApplication::qpeDir() + "/plugins/obex/";
38#ifdef Q_OS_MACX 38#ifdef Q_OS_MACX
39 QDir dir( path, "lib*.dylib" ); 39 QDir dir( path, "lib*.dylib" );
40#else 40#else
41 QDir dir( path, "lib*.so" ); 41 QDir dir( path, "lib*.so" );
42#endif /* Q_OS_MACX */ 42#endif /* Q_OS_MACX */
43 QStringList list = dir.entryList(); 43 QStringList list = dir.entryList();
44 QStringList::Iterator it; 44 QStringList::Iterator it;
45 for ( it = list.begin(); it != list.end(); ++it ) { 45 for ( it = list.begin(); it != list.end(); ++it ) {
46 QLibrary *trylib = new QLibrary( path + *it ); 46 QLibrary *trylib = new QLibrary( path + *it );
47 //qDebug("trying lib %s", (path + (*it)).latin1() ); 47 //odebug << "trying lib " << (path + (*it)) << "" << oendl;
48 if ( trylib->queryInterface( IID_ObexInterface, (QUnknownInterface**)&obexIface ) == QS_OK ) { 48 if ( trylib->queryInterface( IID_ObexInterface, (QUnknownInterface**)&obexIface ) == QS_OK ) {
49 lib = trylib; 49 lib = trylib;
50 //qDebug("found obex lib" ); 50 //odebug << "found obex lib" << oendl;
51 QString lang = getenv( "LANG" ); 51 QString lang = getenv( "LANG" );
52 QTranslator * trans = new QTranslator(qApp); 52 QTranslator * trans = new QTranslator(qApp);
53 QString type = (*it).left( (*it).find(".") ); 53 QString type = (*it).left( (*it).find(".") );
54 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; 54 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm";
55 //qDebug("tr fpr obex: %s", tfn.latin1() ); 55 //odebug << "tr fpr obex: " << tfn << "" << oendl;
56 if ( trans->load( tfn )) 56 if ( trans->load( tfn ))
57 qApp->installTranslator( trans ); 57 qApp->installTranslator( trans );
58 else 58 else
59 delete trans; 59 delete trans;
60 60
61 break; 61 break;
62 } else { 62 } else {
63 delete lib; 63 delete lib;
64 } 64 }
65 } 65 }
66 if ( !lib ) 66 if ( !lib )
67 qDebug("could not load IR plugin" ); 67 odebug << "could not load IR plugin" << oendl;
68} 68}
69 69
70IrServer::~IrServer() 70IrServer::~IrServer()
71{ 71{
72 if ( obexIface ) 72 if ( obexIface )
73 obexIface->release(); 73 obexIface->release();
74 delete lib; 74 delete lib;
75} 75}
76 76
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index 5d0c778..bf2287d 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -9,81 +9,78 @@
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"
22#include "taskbar.h"
23#include "serverinterface.h"
24#include "launcherview.h"
25#include "launcher.h"
26#include "server.h"
27
28/* OPIE */
29#include <opie2/odebug.h>
21#include <qtopia/global.h> 30#include <qtopia/global.h>
22#ifdef Q_WS_QWS 31#ifdef Q_WS_QWS
23#include <qtopia/qcopenvelope_qws.h> 32#include <qtopia/qcopenvelope_qws.h>
24#endif 33#endif
25#include <qtopia/resource.h> 34#include <qtopia/resource.h>
26#include <qtopia/applnk.h> 35#include <qtopia/applnk.h>
27#include <qtopia/config.h> 36#include <qtopia/config.h>
28#include <qtopia/qpeapplication.h> 37#include <qtopia/qpeapplication.h>
29#include <qtopia/mimetype.h> 38#include <qtopia/mimetype.h>
30#include <qtopia/private/categories.h> 39#include <qtopia/private/categories.h>
31//#include <qtopia/custom.h> 40#define QTOPIA_INTERNAL_FSLP
41#include <qtopia/lnkproperties.h>
32 42
43/* QT */
33#include <qdir.h> 44#include <qdir.h>
34#ifdef Q_WS_QWS 45#ifdef Q_WS_QWS
46#include <qkeyboard_qws.h>
35#include <qwindowsystem_qws.h> 47#include <qwindowsystem_qws.h>
36#endif 48#endif
37#include <qtimer.h> 49#include <qtimer.h>
38#include <qcombobox.h> 50#include <qcombobox.h>
39#include <qvbox.h> 51#include <qvbox.h>
40#include <qlayout.h> 52#include <qlayout.h>
41#include <qstyle.h> 53#include <qstyle.h>
42#include <qpushbutton.h> 54#include <qpushbutton.h>
43#include <qtabbar.h> 55#include <qtabbar.h>
44#include <qwidgetstack.h> 56#include <qwidgetstack.h>
45#include <qregexp.h> 57#include <qregexp.h>
46#include <qmessagebox.h> 58#include <qmessagebox.h>
47#include <qframe.h> 59#include <qframe.h>
48#include <qpainter.h> 60#include <qpainter.h>
49#include <qlabel.h> 61#include <qlabel.h>
50#include <qtextstream.h> 62#include <qtextstream.h>
51#include <qpopupmenu.h> 63#include <qpopupmenu.h>
52 64
53#include "startmenu.h" 65/* STD */
54#include "taskbar.h"
55
56#include "serverinterface.h"
57#include "launcherview.h"
58#include "launcher.h"
59#include "server.h"
60
61#define QTOPIA_INTERNAL_FSLP
62#include <qtopia/lnkproperties.h>
63#include <stdlib.h> 66#include <stdlib.h>
64#include <assert.h> 67#include <assert.h>
65
66#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 68#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
67#include <unistd.h> 69#include <unistd.h>
68#include <stdio.h> 70#include <stdio.h>
69#include <sys/vfs.h> 71#include <sys/vfs.h>
70#include <mntent.h> 72#include <mntent.h>
71#endif 73#endif
72 74
73#ifdef Q_WS_QWS
74#include <qkeyboard_qws.h>
75#include <qpe/lnkproperties.h>
76#endif
77
78 75
79static bool isVisibleWindow( int ); 76static bool isVisibleWindow( int );
80//=========================================================================== 77//===========================================================================
81 78
82LauncherTabWidget::LauncherTabWidget( Launcher* parent ) : 79LauncherTabWidget::LauncherTabWidget( Launcher* parent ) :
83 QVBox( parent ), docview( 0 ) 80 QVBox( parent ), docview( 0 )
84{ 81{
85 docLoadingWidgetEnabled = false; 82 docLoadingWidgetEnabled = false;
86 docLoadingWidget = 0; 83 docLoadingWidget = 0;
87 docLoadingWidgetProgress = 0; 84 docLoadingWidgetProgress = 0;
88 launcher = parent; 85 launcher = parent;
89 categoryBar = new LauncherTabBar( this ); 86 categoryBar = new LauncherTabBar( this );
@@ -219,25 +216,25 @@ LauncherView* LauncherTabWidget::newView( const QString& id, const QPixmap& pm,
219 connect( view, SIGNAL(rightPressed(AppLnk*)), 216 connect( view, SIGNAL(rightPressed(AppLnk*)),
220 this, SIGNAL(rightPressed(AppLnk*))); 217 this, SIGNAL(rightPressed(AppLnk*)));
221 218
222 int n = categoryBar->count(); 219 int n = categoryBar->count();
223 stack->addWidget( view, n ); 220 stack->addWidget( view, n );
224 221
225 LauncherTab *tab = new LauncherTab( id, view, pm, label ); 222 LauncherTab *tab = new LauncherTab( id, view, pm, label );
226 categoryBar->insertTab( tab, n-1 ); 223 categoryBar->insertTab( tab, n-1 );
227 224
228 if ( id == "Documents" ) 225 if ( id == "Documents" )
229 docview = view; 226 docview = view;
230 227
231 qDebug("inserting %s at %d", id.latin1(), n-1 ); 228 odebug << "inserting " << id << " at " << n-1 << "" << oendl;
232 229
233 Config cfg("Launcher"); 230 Config cfg("Launcher");
234 setTabAppearance( tab, cfg ); 231 setTabAppearance( tab, cfg );
235 232
236 cfg.setGroup( "GUI" ); 233 cfg.setGroup( "GUI" );
237 view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) ); 234 view->setBusyIndicatorType( cfg.readEntry( "BusyType", QString::null ) );
238 235
239 return view; 236 return view;
240} 237}
241 238
242LauncherView *LauncherTabWidget::view( const QString &id ) 239LauncherView *LauncherTabWidget::view( const QString &id )
243{ 240{
@@ -404,25 +401,25 @@ void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &
404 stream >> id; 401 stream >> id;
405 QString fam; 402 QString fam;
406 stream >> fam; 403 stream >> fam;
407 int size; 404 int size;
408 stream >> size; 405 stream >> size;
409 int weight; 406 int weight;
410 stream >> weight; 407 stream >> weight;
411 int italic; 408 int italic;
412 stream >> italic; 409 stream >> italic;
413 if ( view(id) ) { 410 if ( view(id) ) {
414 if ( !fam.isEmpty() ) { 411 if ( !fam.isEmpty() ) {
415 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); 412 view(id)->setViewFont( QFont(fam, size, weight, italic!=0) );
416 qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); 413 odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl;
417 } else { 414 } else {
418 view(id)->clearViewFont(); 415 view(id)->clearViewFont();
419 } 416 }
420 } 417 }
421 }else if ( msg == "setBusyIndicatorType(QString)" ) { 418 }else if ( msg == "setBusyIndicatorType(QString)" ) {
422 QString type; 419 QString type;
423 stream >> type; 420 stream >> type;
424 setBusyIndicatorType( type ); 421 setBusyIndicatorType( type );
425 }else if ( msg == "home()" ) { 422 }else if ( msg == "home()" ) {
426 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { 423 if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) {
427 if (categoryBar) 424 if (categoryBar)
428 categoryBar->nextTab(); 425 categoryBar->nextTab();
@@ -675,25 +672,25 @@ void Launcher::applicationAdded( const QString& type, const AppLnk& app )
675 qWarning("addAppLnk: No view for type %s. Can't add app %s!", 672 qWarning("addAppLnk: No view for type %s. Can't add app %s!",
676 type.latin1(),app.name().latin1() ); 673 type.latin1(),app.name().latin1() );
677 674
678 MimeType::registerApp( app ); 675 MimeType::registerApp( app );
679} 676}
680 677
681void Launcher::applicationRemoved( const QString& type, const AppLnk& app ) 678void Launcher::applicationRemoved( const QString& type, const AppLnk& app )
682{ 679{
683 LauncherView *view = tabs->view( type ); 680 LauncherView *view = tabs->view( type );
684 if ( view ) 681 if ( view )
685 view->removeLink( app.linkFile() ); 682 view->removeLink( app.linkFile() );
686 else 683 else
687 qWarning("removeAppLnk: No view for %s!", type.latin1() ); 684 owarn << "removeAppLnk: No view for " << type << "!" << oendl;
688} 685}
689 686
690void Launcher::allApplicationsRemoved() 687void Launcher::allApplicationsRemoved()
691{ 688{
692 MimeType::clear(); 689 MimeType::clear();
693 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it) 690 for ( QStringList::ConstIterator it=ids.begin(); it!= ids.end(); ++it)
694 tabs->view( (*it) )->removeAllItems(); 691 tabs->view( (*it) )->removeAllItems();
695} 692}
696 693
697void Launcher::documentAdded( const DocLnk& doc ) 694void Launcher::documentAdded( const DocLnk& doc )
698{ 695{
699 tabs->docView()->addItem( new DocLnk( doc ), FALSE ); 696 tabs->docView()->addItem( new DocLnk( doc ), FALSE );
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 6c7d487..71e8753 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -11,31 +11,34 @@
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 "launcherview.h" 21#include "launcherview.h"
22 22
23/* OPIE */
24#include <opie2/odebug.h>
23#include <qtopia/qpeapplication.h> 25#include <qtopia/qpeapplication.h>
24#include <qtopia/private/categories.h> 26#include <qtopia/private/categories.h>
25#include <qtopia/categoryselect.h> 27#include <qtopia/categoryselect.h>
26#include <qtopia/mimetype.h> 28#include <qtopia/mimetype.h>
27#include <qtopia/resource.h> 29#include <qtopia/resource.h>
28//#include <qtopia/private/palmtoprecord.h> 30using namespace Opie::Core;
29 31
32/* QT */
30#include <qtimer.h> 33#include <qtimer.h>
31#include <qfileinfo.h> 34#include <qfileinfo.h>
32#include <qiconview.h> 35#include <qiconview.h>
33#include <qobjectlist.h> 36#include <qobjectlist.h>
34 37
35 38
36// These define how the busy icon is animated and highlighted 39// These define how the busy icon is animated and highlighted
37#define BRIGHTEN_BUSY_ICON 40#define BRIGHTEN_BUSY_ICON
38//#define ALPHA_FADE_BUSY_ICON 41//#define ALPHA_FADE_BUSY_ICON
39//#define USE_ANIMATED_BUSY_ICON_OVERLAY 42//#define USE_ANIMATED_BUSY_ICON_OVERLAY
40#define BOUNCE_BUSY_ICON 43#define BOUNCE_BUSY_ICON
41 44
@@ -106,25 +109,25 @@ public:
106 hidden.setAutoDelete(TRUE); 109 hidden.setAutoDelete(TRUE);
107 ike = FALSE; 110 ike = FALSE;
108 calculateGrid( Bottom ); 111 calculateGrid( Bottom );
109 } 112 }
110 113
111 ~LauncherIconView() 114 ~LauncherIconView()
112 { 115 {
113#if 0 // debuggery 116#if 0 // debuggery
114 QListIterator<AppLnk> it(hidden); 117 QListIterator<AppLnk> it(hidden);
115 AppLnk* l; 118 AppLnk* l;
116 while ((l=it.current())) { 119 while ((l=it.current())) {
117 ++it; 120 ++it;
118 //qDebug("%p: hidden (should remove)",l); 121 //odebug << "" << l << ": hidden (should remove)" << oendl;
119 } 122 }
120#endif 123#endif
121 } 124 }
122 125
123 QIconViewItem* busyItem() const { return bsy; } 126 QIconViewItem* busyItem() const { return bsy; }
124#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 127#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
125 QPixmap busyPixmap() const { return busyPix; } 128 QPixmap busyPixmap() const { return busyPix; }
126#endif 129#endif
127 void setBigIcons( bool bi ) { 130 void setBigIcons( bool bi ) {
128 bigIcns = bi; 131 bigIcns = bi;
129#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 132#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
130 busyPix.resize(0,0); 133 busyPix.resize(0,0);
@@ -1020,25 +1023,25 @@ void LauncherView::paletteChange( const QPalette &p )
1020{ 1023{
1021 icons->unsetPalette(); 1024 icons->unsetPalette();
1022 QVBox::paletteChange( p ); 1025 QVBox::paletteChange( p );
1023 if ( bgType == Ruled ) 1026 if ( bgType == Ruled )
1024 setBackgroundType( Ruled, QString::null ); 1027 setBackgroundType( Ruled, QString::null );
1025 QColorGroup cg = icons->colorGroup(); 1028 QColorGroup cg = icons->colorGroup();
1026 cg.setColor( QColorGroup::Text, textCol ); 1029 cg.setColor( QColorGroup::Text, textCol );
1027 icons->setPalette( QPalette(cg,cg,cg) ); 1030 icons->setPalette( QPalette(cg,cg,cg) );
1028} 1031}
1029 1032
1030void LauncherView::fontChanged(const QFont&) 1033void LauncherView::fontChanged(const QFont&)
1031{ 1034{
1032 qDebug("LauncherView::fontChanged()"); 1035 odebug << "LauncherView::fontChanged()" << oendl;
1033 icons->hideOrShowItems( FALSE ); 1036 icons->hideOrShowItems( FALSE );
1034} 1037}
1035 1038
1036void LauncherView::relayout(void) 1039void LauncherView::relayout(void)
1037{ 1040{
1038 icons->hideOrShowItems(FALSE); 1041 icons->hideOrShowItems(FALSE);
1039} 1042}
1040 1043
1041void LauncherView::flushBgCache() 1044void LauncherView::flushBgCache()
1042{ 1045{
1043 if ( !bgCache ) 1046 if ( !bgCache )
1044 return; 1047 return;
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp
index 3e7e0d2..a86aca6 100644
--- a/core/launcher/main.cpp
+++ b/core/launcher/main.cpp
@@ -12,68 +12,62 @@
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#ifdef QT_QWS_LOGIN
25#include "../login/qdmdialogimpl.h"
26#endif
27#include "calibrate.h"
24#include "server.h" 28#include "server.h"
25#include "serverapp.h" 29#include "serverapp.h"
26#include "stabmon.h" 30#include "stabmon.h"
27#include "firstuse.h" 31#include "firstuse.h"
28 32
33/* OPIE */
34#include <opie2/odebug.h>
35#include <opie2/odevice.h>
29#include <opie2/oglobal.h> 36#include <opie2/oglobal.h>
30
31#include <qtopia/network.h> 37#include <qtopia/network.h>
32//#include <qtopia/custom.h> 38#include <qtopia/alarmserver.h>
33 39using namespace Opie::Core;
34 40
41/* QT */
35#include <qdir.h> 42#include <qdir.h>
43#include <qmessagebox.h>
36#ifdef QWS 44#ifdef QWS
37#include <qwindowsystem_qws.h> 45#include <qwindowsystem_qws.h>
38#include <qtopia/qcopenvelope_qws.h> 46#include <qtopia/qcopenvelope_qws.h>
39#endif 47#endif
40#include <qtopia/alarmserver.h> 48#ifdef Q_WS_QWS
49#include <qkeyboard_qws.h>
50#endif
41 51
52/* STD */
42#include <stdlib.h> 53#include <stdlib.h>
43#include <stdio.h> 54#include <stdio.h>
44#include <signal.h> 55#include <signal.h>
45#ifndef Q_OS_WIN32 56#ifndef Q_OS_WIN32
46#include <unistd.h> 57#include <unistd.h>
47#else 58#else
48#include <process.h> 59#include <process.h>
49#endif 60#endif
50 61
51#include "calibrate.h"
52
53
54#ifdef QT_QWS_LOGIN
55#include "../login/qdmdialogimpl.h"
56#endif
57
58#ifdef Q_WS_QWS
59#include <qkeyboard_qws.h>
60#endif
61
62#include <qmessagebox.h>
63#include <opie2/odevice.h>
64
65using namespace Opie::Core;
66
67
68static void cleanup() 62static void cleanup()
69{ 63{
70 QDir dir( "/tmp", "qcop-msg-*" ); 64 QDir dir( "/tmp", "qcop-msg-*" );
71 65
72 QStringList stale = dir.entryList(); 66 QStringList stale = dir.entryList();
73 QStringList::Iterator it; 67 QStringList::Iterator it;
74 for ( it = stale.begin(); it != stale.end(); ++it ) { 68 for ( it = stale.begin(); it != stale.end(); ++it ) {
75 dir.remove( *it ); 69 dir.remove( *it );
76 } 70 }
77} 71}
78 72
79static void refreshTimeZoneConfig() 73static void refreshTimeZoneConfig()
@@ -112,25 +106,25 @@ static void refreshTimeZoneConfig()
112 for (QStringList::Iterator it = zoneDefaults.begin(); it != zoneDefaults.end() ; ++it){ 106 for (QStringList::Iterator it = zoneDefaults.begin(); it != zoneDefaults.end() ; ++it){
113 cfg.writeEntry( "Zone" + QString::number( zoneIndex ) , *it); 107 cfg.writeEntry( "Zone" + QString::number( zoneIndex ) , *it);
114 zoneIndex++; 108 zoneIndex++;
115 } 109 }
116 } 110 }
117 // We have an existing list of timezones refresh the 111 // We have an existing list of timezones refresh the
118 // translations of TimeZone name 112 // translations of TimeZone name
119 zoneIndex = 0; 113 zoneIndex = 0;
120 while (cfg.hasKey( "Zone"+ QString::number( zoneIndex ))){ 114 while (cfg.hasKey( "Zone"+ QString::number( zoneIndex ))){
121 zoneID = cfg.readEntry( "Zone" + QString::number( zoneIndex )); 115 zoneID = cfg.readEntry( "Zone" + QString::number( zoneIndex ));
122 curZone = TimeZone( zoneID ); 116 curZone = TimeZone( zoneID );
123 if ( !curZone.isValid() ){ 117 if ( !curZone.isValid() ){
124 qDebug( "initEnvironment() Invalid TimeZone %s", zoneID.latin1() ); 118 odebug << "initEnvironment() Invalid TimeZone " << zoneID << "" << oendl;
125 break; 119 break;
126 } 120 }
127 cfg.writeEntry( "ZoneName" + QString::number( zoneIndex ), curZone.city() ); 121 cfg.writeEntry( "ZoneName" + QString::number( zoneIndex ), curZone.city() );
128 zoneIndex++; 122 zoneIndex++;
129 } 123 }
130#endif 124#endif
131} 125}
132 126
133void initEnvironment() 127void initEnvironment()
134{ 128{
135#ifdef Q_OS_WIN32 129#ifdef Q_OS_WIN32
136 // Config file requires HOME dir which uses QDir which needs the winver 130 // Config file requires HOME dir which uses QDir which needs the winver
@@ -260,25 +254,25 @@ int initApplication( int argc, char ** argv )
260 s->show(); 254 s->show();
261 255
262 /* THE ARM rtc has problem holdings the time on reset */ 256 /* THE ARM rtc has problem holdings the time on reset */
263 if ( QDate::currentDate ( ). year ( ) < 2000 ) { 257 if ( QDate::currentDate ( ). year ( ) < 2000 ) {
264 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 ) { 258 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 ) {
265 QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" ); 259 QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" );
266 e << QString ( ); 260 e << QString ( );
267 } 261 }
268 } 262 }
269 263
270 int rv = a.exec(); 264 int rv = a.exec();
271 265
272 qDebug("exiting..."); 266 odebug << "exiting..." << oendl;
273 delete s; 267 delete s;
274 268
275#ifndef Q_OS_MACX 269#ifndef Q_OS_MACX
276 ODevice::inst()->setSoftSuspend( false ); 270 ODevice::inst()->setSoftSuspend( false );
277#endif 271#endif
278 272
279 return rv; 273 return rv;
280} 274}
281 275
282static const char *pidfile_path = "/var/run/opie.pid"; 276static const char *pidfile_path = "/var/run/opie.pid";
283 277
284void create_pidfile ( ) 278void create_pidfile ( )
@@ -332,21 +326,21 @@ int main( int argc, char ** argv )
332 ::sleep ( 1 ); 326 ::sleep ( 1 );
333 ::kill ( 0, SIGKILL ); 327 ::kill ( 0, SIGKILL );
334 328
335 return retVal; 329 return retVal;
336} 330}
337#else 331#else
338 332
339int main( int argc, char ** argv ) 333int main( int argc, char ** argv )
340{ 334{
341 int retVal = initApplication( argc, argv ); 335 int retVal = initApplication( argc, argv );
342 336
343 if ( DesktopApplication::doRestart ) { 337 if ( DesktopApplication::doRestart ) {
344 qDebug("Trying to restart"); 338 odebug << "Trying to restart" << oendl;
345 execl( (QPEApplication::qpeDir()+"bin\\qpe").latin1(), "qpe", 0 ); 339 execl( (QPEApplication::qpeDir()+"bin\\qpe").latin1(), "qpe", 0 );
346 } 340 }
347 341
348 return retVal; 342 return retVal;
349} 343}
350 344
351#endif 345#endif
352 346
diff --git a/core/launcher/packageslave.cpp b/core/launcher/packageslave.cpp
index 7e61b0e..a11ac86 100644
--- a/core/launcher/packageslave.cpp
+++ b/core/launcher/packageslave.cpp
@@ -10,46 +10,46 @@
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 "packageslave.h" 21#include "packageslave.h"
22#include <qtopia/qprocess.h>
23 22
23/* OPIE */
24#include <opie2/odebug.h>
25#include <qtopia/qprocess.h>
24#ifdef Q_WS_QWS 26#ifdef Q_WS_QWS
25#include <qtopia/qcopenvelope_qws.h> 27#include <qtopia/qcopenvelope_qws.h>
26#endif 28#endif
29using namespace Opie::Core;
27 30
31/* QT */
28#ifdef Q_WS_QWS 32#ifdef Q_WS_QWS
29#include <qcopchannel_qws.h> 33#include <qcopchannel_qws.h>
30#endif 34#endif
31
32#include <qtextstream.h> 35#include <qtextstream.h>
33 36
37/* STD */
34#include <stdlib.h> 38#include <stdlib.h>
35#include <sys/stat.h> // mkdir() 39#include <sys/stat.h> // mkdir()
36
37#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 40#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
38#include <unistd.h> 41#include <unistd.h>
39#include <sys/vfs.h> 42#include <sys/vfs.h>
40#include <mntent.h> 43#include <mntent.h>
41#elif defined(Q_OS_WIN32)
42#include <windows.h>
43#include <winbase.h>
44#elif defined(Q_OS_MACX) 44#elif defined(Q_OS_MACX)
45#include <unistd.h> 45#include <unistd.h>
46#endif 46#endif
47 47
48 48
49PackageHandler::PackageHandler( QObject *parent, char* name ) 49PackageHandler::PackageHandler( QObject *parent, char* name )
50 : QObject( parent, name ), packageChannel( 0 ), currentProcess( 0 ), mNoSpaceLeft( FALSE ) 50 : QObject( parent, name ), packageChannel( 0 ), currentProcess( 0 ), mNoSpaceLeft( FALSE )
51{ 51{
52 // setup qcop channel 52 // setup qcop channel
53#ifndef QT_NO_COP 53#ifndef QT_NO_COP
54 packageChannel = new QCopChannel( "QPE/Package", this ); 54 packageChannel = new QCopChannel( "QPE/Package", this );
55 connect( packageChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 55 connect( packageChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
@@ -136,53 +136,53 @@ void PackageHandler::sendReply( const QCString& msg, const QString& arg )
136 136
137void PackageHandler::addPackageFiles( const QString &location, 137void PackageHandler::addPackageFiles( const QString &location,
138 const QString &listfile ) 138 const QString &listfile )
139{ 139{
140 QFile f(listfile); 140 QFile f(listfile);
141#ifndef Q_OS_WIN32 141#ifndef Q_OS_WIN32
142 //make a copy so we can remove the symlinks later 142 //make a copy so we can remove the symlinks later
143 mkdir( ("/usr/lib/ipkg/info/"+location).ascii(), 0777 ); 143 mkdir( ("/usr/lib/ipkg/info/"+location).ascii(), 0777 );
144 system(("cp " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); 144 system(("cp " + f.name() + " /usr/lib/ipkg/info/"+location).ascii());
145#else 145#else
146 QDir d; 146 QDir d;
147 //#### revise 147 //#### revise
148 qDebug("Copy file at %s: %s", __FILE__, __LINE__ ); 148 odebug << "Copy file at " << __FILE__ << ": " << __LINE__ << "" << oendl;
149 d.mkdir(("/usr/lib/ipkg/info/" + location).ascii()); 149 d.mkdir(("/usr/lib/ipkg/info/" + location).ascii());
150 system(("copy " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); 150 system(("copy " + f.name() + " /usr/lib/ipkg/info/"+location).ascii());
151#endif 151#endif
152 152
153 153
154 if ( f.open(IO_ReadOnly) ) { 154 if ( f.open(IO_ReadOnly) ) {
155 QTextStream ts(&f); 155 QTextStream ts(&f);
156 156
157 QString s; 157 QString s;
158 while ( !ts.eof() ) { // until end of file... 158 while ( !ts.eof() ) { // until end of file...
159 s = ts.readLine(); // line of text excluding '\n' 159 s = ts.readLine(); // line of text excluding '\n'
160 // for s, do link/mkdir. 160 // for s, do link/mkdir.
161 if ( s.right(1) == "/" ) { 161 if ( s.right(1) == "/" ) {
162 qDebug("do mkdir for %s", s.ascii()); 162 odebug << "do mkdir for " << s.ascii() << "" << oendl;
163#ifndef Q_OS_WIN32 163#ifndef Q_OS_WIN32
164 mkdir( s.ascii(), 0777 ); 164 mkdir( s.ascii(), 0777 );
165 //possible optimization: symlink directories 165 //possible optimization: symlink directories
166 //that don't exist already. -- Risky. 166 //that don't exist already. -- Risky.
167#else 167#else
168 d.mkdir( s.ascii()); 168 d.mkdir( s.ascii());
169#endif 169#endif
170 170
171 } else { 171 } else {
172#ifndef Q_OS_WIN32 172#ifndef Q_OS_WIN32
173 qDebug("do symlink for %s", s.ascii()); 173 odebug << "do symlink for " << s.ascii() << "" << oendl;
174 symlink( (location + s).ascii(), s.ascii() ); 174 symlink( (location + s).ascii(), s.ascii() );
175#else 175#else
176 qDebug("Copy file instead of a symlink for WIN32"); 176 odebug << "Copy file instead of a symlink for WIN32" << oendl;
177 if (!CopyFile((TCHAR*)qt_winTchar((location + s), TRUE), (TCHAR*)qt_winTchar(s, TRUE), FALSE)) 177 if (!CopyFile((TCHAR*)qt_winTchar((location + s), TRUE), (TCHAR*)qt_winTchar(s, TRUE), FALSE))
178 qWarning("Unable to create symlinkfor %s", 178 qWarning("Unable to create symlinkfor %s",
179 (location + s).ascii()); 179 (location + s).ascii());
180#endif 180#endif
181 } 181 }
182 } 182 }
183 f.close(); 183 f.close();
184 } 184 }
185} 185}
186 186
187void PackageHandler::addPackages( const QString &location ) 187void PackageHandler::addPackages( const QString &location )
188{ 188{
@@ -206,32 +206,32 @@ void PackageHandler::cleanupPackageFiles( const QString &listfile )
206 206
207 if ( f.open(IO_ReadOnly) ) { 207 if ( f.open(IO_ReadOnly) ) {
208 QTextStream ts(&f); 208 QTextStream ts(&f);
209 209
210 QString s; 210 QString s;
211 while ( !ts.eof() ) { // until end of file... 211 while ( !ts.eof() ) { // until end of file...
212 s = ts.readLine(); // line of text excluding '\n' 212 s = ts.readLine(); // line of text excluding '\n'
213 // for s, do link/mkdir. 213 // for s, do link/mkdir.
214 if ( s.right(1) == "/" ) { 214 if ( s.right(1) == "/" ) {
215 //should rmdir if empty, after all files have been removed 215 //should rmdir if empty, after all files have been removed
216 } else { 216 } else {
217#ifndef Q_OS_WIN32 217#ifndef Q_OS_WIN32
218 qDebug("remove symlink for %s", s.ascii()); 218 odebug << "remove symlink for " << s.ascii() << "" << oendl;
219 //check if it is a symlink first (don't remove /etc/passwd...) 219 //check if it is a symlink first (don't remove /etc/passwd...)
220 char buf[10]; //we don't care about the contents 220 char buf[10]; //we don't care about the contents
221 if ( ::readlink( s.ascii(),buf, 10 >= 0 ) ) 221 if ( ::readlink( s.ascii(),buf, 10 >= 0 ) )
222 ::unlink( s.ascii() ); 222 ::unlink( s.ascii() );
223 #else 223 #else
224 // ### revise 224 // ### revise
225 qWarning("Unable to remove symlink %s:%s", __FILE__, __LINE__); 225 owarn << "Unable to remove symlink " << __FILE__ << ":" << __LINE__ << "" << oendl;
226#endif 226#endif
227 } 227 }
228 } 228 }
229 f.close(); 229 f.close();
230 230
231 //remove the list file 231 //remove the list file
232 ::unlink( listfile.ascii() ); 232 ::unlink( listfile.ascii() );
233 233
234 } 234 }
235} 235}
236 236
237void PackageHandler::cleanupPackages( const QString &location ) 237void PackageHandler::cleanupPackages( const QString &location )
@@ -257,25 +257,25 @@ void PackageHandler::prepareInstall( const QString& size, const QString& path )
257 // Check whether there will be enough space to install the next package. 257 // Check whether there will be enough space to install the next package.
258 bool ok; 258 bool ok;
259 unsigned int s = size.toUInt( &ok ); 259 unsigned int s = size.toUInt( &ok );
260 260
261 if ( !ok ) 261 if ( !ok )
262 return; 262 return;
263 263
264 // Shamelessly stolen from the sysinfo application (Werner) 264 // Shamelessly stolen from the sysinfo application (Werner)
265#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 265#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
266 struct statfs fs; 266 struct statfs fs;
267 if ( statfs( path.latin1(), &fs ) == 0 ) 267 if ( statfs( path.latin1(), &fs ) == 0 )
268 if ( s > fs.f_bsize * fs.f_bavail ) { 268 if ( s > fs.f_bsize * fs.f_bavail ) {
269 //qDebug("############### Not enough space left ###############"); 269 //odebug << "############### Not enough space left ###############" << oendl;
270 mNoSpaceLeft = TRUE; 270 mNoSpaceLeft = TRUE;
271 } 271 }
272#endif 272#endif
273} 273}
274 274
275void PackageHandler::iProcessExited() 275void PackageHandler::iProcessExited()
276{ 276{
277 if ( currentProcess->normalExit() && currentProcess->exitStatus() == 0 ) 277 if ( currentProcess->normalExit() && currentProcess->exitStatus() == 0 )
278 sendReply( "installDone(QString)", currentPackage ); 278 sendReply( "installDone(QString)", currentPackage );
279 else { 279 else {
280#ifndef QT_NO_COP 280#ifndef QT_NO_COP
281 QCopEnvelope e( "QPE/Desktop", "installFailed(QString,int,QString)" ); 281 QCopEnvelope e( "QPE/Desktop", "installFailed(QString,int,QString)" );
diff --git a/core/launcher/qcopbridge.cpp b/core/launcher/qcopbridge.cpp
index 33df6c4..e339dc7 100644
--- a/core/launcher/qcopbridge.cpp
+++ b/core/launcher/qcopbridge.cpp
@@ -12,66 +12,65 @@
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 "qcopbridge.h" 21#include "qcopbridge.h"
22#include "transferserver.h" 22#include "transferserver.h"
23 23
24/* OPIE */
25#include <opie2/odebug.h>
24#include <opie2/oglobal.h> 26#include <opie2/oglobal.h>
25
26#ifdef Q_WS_QWS 27#ifdef Q_WS_QWS
27#include <qtopia/qcopenvelope_qws.h> 28#include <qtopia/qcopenvelope_qws.h>
28#endif 29#endif
29#include <qtopia/qpeapplication.h> 30#include <qtopia/qpeapplication.h>
30
31#include <qtopia/version.h> 31#include <qtopia/version.h>
32using namespace Opie::Core;
32 33
34/* QT */
33#include <qtextstream.h> 35#include <qtextstream.h>
34#include <qtimer.h> 36#include <qtimer.h>
35#ifdef Q_WS_QWS 37#ifdef Q_WS_QWS
36#include <qcopchannel_qws.h> 38#include <qcopchannel_qws.h>
37#endif 39#endif
38 40
41/* STD */
39#ifndef _XOPEN_SOURCE 42#ifndef _XOPEN_SOURCE
40#define _XOPEN_SOURCE 43#define _XOPEN_SOURCE
41#endif 44#endif
42#ifndef Q_OS_WIN32 45#ifndef Q_OS_WIN32
43#include <pwd.h> 46#include <pwd.h>
44#include <unistd.h> 47#include <unistd.h>
45#include <sys/types.h> 48#include <sys/types.h>
46#endif 49#endif
47 50
48#if defined(_OS_LINUX_) 51#if defined(_OS_LINUX_)
49#include <shadow.h> 52#include <shadow.h>
50#endif 53#endif
51 54
52
53//#define INSECURE
54
55const int block_size = 51200; 55const int block_size = 51200;
56 56
57using namespace Opie::Core;
58QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent, 57QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent,
59 const char* name ) 58 const char* name )
60 : QServerSocket( port, 1, parent, name ), 59 : QServerSocket( port, 1, parent, name ),
61 desktopChannel( 0 ), 60 desktopChannel( 0 ),
62 cardChannel( 0 ) 61 cardChannel( 0 )
63{ 62{
64 if ( !ok() ) 63 if ( !ok() )
65 qWarning( "Failed to bind to port %d", port ); 64 owarn << "Failed to bind to port " << port << "" << oendl;
66 else { 65 else {
67#ifndef QT_NO_COP 66#ifndef QT_NO_COP
68 desktopChannel = new QCopChannel( "QPE/Desktop", this ); 67 desktopChannel = new QCopChannel( "QPE/Desktop", this );
69 connect( desktopChannel, SIGNAL(received(const QCString&,const QByteArray&)), 68 connect( desktopChannel, SIGNAL(received(const QCString&,const QByteArray&)),
70 this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); 69 this, SLOT(desktopMessage(const QCString&,const QByteArray&)) );
71 cardChannel = new QCopChannel( "QPE/Card", this ); 70 cardChannel = new QCopChannel( "QPE/Card", this );
72 connect( cardChannel, SIGNAL(received(const QCString&,const QByteArray&)), 71 connect( cardChannel, SIGNAL(received(const QCString&,const QByteArray&)),
73 this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); 72 this, SLOT(desktopMessage(const QCString&,const QByteArray&)) );
74#endif 73#endif
75 } 74 }
76 sendSync = FALSE; 75 sendSync = FALSE;
77 openConnections.setAutoDelete( TRUE ); 76 openConnections.setAutoDelete( TRUE );
@@ -162,31 +161,31 @@ void QCopBridge::desktopMessage( const QCString &command, const QByteArray &data
162 sendDesktopMessageOld( command, data ); 161 sendDesktopMessageOld( command, data );
163} 162}
164 163
165#ifndef OPIE_NO_OLD_SYNC_CODE 164#ifndef OPIE_NO_OLD_SYNC_CODE
166/* 165/*
167 * Old compat mode 166 * Old compat mode
168 */ 167 */
169void QCopBridge::sendDesktopMessageOld( const QCString& command, const QByteArray& args) { 168void QCopBridge::sendDesktopMessageOld( const QCString& command, const QByteArray& args) {
170 command.stripWhiteSpace(); 169 command.stripWhiteSpace();
171 170
172 int paren = command.find( "(" ); 171 int paren = command.find( "(" );
173 if ( paren <= 0 ) { 172 if ( paren <= 0 ) {
174 qDebug("DesktopMessage: bad qcop syntax"); 173 odebug << "DesktopMessage: bad qcop syntax" << oendl;
175 return; 174 return;
176 } 175 }
177 176
178 QString params = command.mid( paren + 1 ); 177 QString params = command.mid( paren + 1 );
179 if ( params[params.length()-1] != ')' ) { 178 if ( params[params.length()-1] != ')' ) {
180 qDebug("DesktopMessage: bad qcop syntax"); 179 odebug << "DesktopMessage: bad qcop syntax" << oendl;
181 return; 180 return;
182 } 181 }
183 182
184 params.truncate( params.length()-1 ); 183 params.truncate( params.length()-1 );
185 184
186 QStringList paramList = QStringList::split( ",", params ); 185 QStringList paramList = QStringList::split( ",", params );
187 QString data; 186 QString data;
188 if ( paramList.count() ) { 187 if ( paramList.count() ) {
189 QDataStream stream( args, IO_ReadOnly ); 188 QDataStream stream( args, IO_ReadOnly );
190 for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) { 189 for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) {
191 QString str; 190 QString str;
192 if ( *it == "QString" ) { 191 if ( *it == "QString" ) {
@@ -195,25 +194,25 @@ void QCopBridge::sendDesktopMessageOld( const QCString& command, const QByteArra
195 QCString cstr; 194 QCString cstr;
196 stream >> cstr; 195 stream >> cstr;
197 str = QString::fromLocal8Bit( cstr ); 196 str = QString::fromLocal8Bit( cstr );
198 } else if ( *it == "int" ) { 197 } else if ( *it == "int" ) {
199 int i; 198 int i;
200 stream >> i; 199 stream >> i;
201 str = QString::number( i ); 200 str = QString::number( i );
202 } else if ( *it == "bool" ) { 201 } else if ( *it == "bool" ) {
203 int i; 202 int i;
204 stream >> i; 203 stream >> i;
205 str = QString::number( i ); 204 str = QString::number( i );
206 } else { 205 } else {
207 qDebug(" cannot route the argument type %s throught the qcop bridge", (*it).latin1() ); 206 odebug << " cannot route the argument type " << (*it) << " throught the qcop bridge" << oendl;
208 return; 207 return;
209 } 208 }
210 QString estr; 209 QString estr;
211 for (int i=0; i<(int)str.length(); i++) { 210 for (int i=0; i<(int)str.length(); i++) {
212 QChar ch = str[i]; 211 QChar ch = str[i];
213 if ( ch.row() ) 212 if ( ch.row() )
214 goto quick; 213 goto quick;
215 switch (ch.cell()) { 214 switch (ch.cell()) {
216 case '&': 215 case '&':
217 estr.append( "&amp;" ); 216 estr.append( "&amp;" );
218 break; 217 break;
219 case ' ': 218 case ' ':
@@ -323,38 +322,38 @@ void QCopBridgePI::sendDesktopMessage( const QCString &msg, const QByteArray& da
323 writeBlock(b64.data(),b64.size()); 322 writeBlock(b64.data(),b64.size());
324 writeBlock("\r\n",2); 323 writeBlock("\r\n",2);
325 324
326} 325}
327 326
328 327
329void QCopBridgePI::send( const QString& msg ) 328void QCopBridgePI::send( const QString& msg )
330{ 329{
331 if ( !isOpen() ) // eg. Forbidden 330 if ( !isOpen() ) // eg. Forbidden
332 return; 331 return;
333 QTextStream os( this ); 332 QTextStream os( this );
334 os << msg << endl; 333 os << msg << endl;
335 //qDebug( "sending qcop message: %s", msg.latin1() ); 334 //odebug << "sending qcop message: " << msg << "" << oendl;
336} 335}
337 336
338void QCopBridgePI::read() 337void QCopBridgePI::read()
339{ 338{
340 while ( canReadLine() ) { 339 while ( canReadLine() ) {
341 timer->start( 300000, TRUE ); 340 timer->start( 300000, TRUE );
342 process( readLine().stripWhiteSpace() ); 341 process( readLine().stripWhiteSpace() );
343 } 342 }
344} 343}
345 344
346void QCopBridgePI::process( const QString& message ) 345void QCopBridgePI::process( const QString& message )
347{ 346{
348 //qDebug( "Command: %s", message.latin1() ); 347 //odebug << "Command: " << message << "" << oendl;
349 348
350 // split message using "," as separator 349 // split message using "," as separator
351 QStringList msg = QStringList::split( " ", message ); 350 QStringList msg = QStringList::split( " ", message );
352 if ( msg.isEmpty() ) return; 351 if ( msg.isEmpty() ) return;
353 352
354 // command token 353 // command token
355 QString cmd = msg[0].upper(); 354 QString cmd = msg[0].upper();
356 355
357 // argument token 356 // argument token
358 QString arg; 357 QString arg;
359 if ( msg.count() >= 2 ) 358 if ( msg.count() >= 2 )
360 arg = msg[1]; 359 arg = msg[1];
diff --git a/core/launcher/qprocess.cpp b/core/launcher/qprocess.cpp
index 97bd539..3fe1238 100644
--- a/core/launcher/qprocess.cpp
+++ b/core/launcher/qprocess.cpp
@@ -572,68 +572,68 @@ void QProcess::writeToStdin( const QString& buf )
572 * Under Windows the implementation is not so nice: it is not that easy to 572 * Under Windows the implementation is not so nice: it is not that easy to
573 * detect when one of the signals should be emitted; therefore there are some 573 * detect when one of the signals should be emitted; therefore there are some
574 * timers that query the information. 574 * timers that query the information.
575 * To keep it a little efficient, use the timers only when they are needed. 575 * To keep it a little efficient, use the timers only when they are needed.
576 * They are needed, if you are interested in the signals. So use 576 * They are needed, if you are interested in the signals. So use
577 * connectNotify() and disconnectNotify() to keep track of your interest. 577 * connectNotify() and disconnectNotify() to keep track of your interest.
578 */ 578 */
579/*! \reimp 579/*! \reimp
580*/ 580*/
581void QProcess::connectNotify( const char * signal ) 581void QProcess::connectNotify( const char * signal )
582{ 582{
583#if defined(QT_QPROCESS_DEBUG) 583#if defined(QT_QPROCESS_DEBUG)
584 qDebug( "QProcess::connectNotify(): signal %s has been connected", signal ); 584 odebug << "QProcess::connectNotify(): signal " << signal << " has been connected" << oendl;
585#endif 585#endif
586 if ( !ioRedirection ) 586 if ( !ioRedirection )
587 if ( qstrcmp( signal, SIGNAL(readyReadStdout()) )==0 || 587 if ( qstrcmp( signal, SIGNAL(readyReadStdout()) )==0 ||
588 qstrcmp( signal, SIGNAL(readyReadStderr()) )==0 588 qstrcmp( signal, SIGNAL(readyReadStderr()) )==0
589 ) { 589 ) {
590#if defined(QT_QPROCESS_DEBUG) 590#if defined(QT_QPROCESS_DEBUG)
591 qDebug( "QProcess::connectNotify(): set ioRedirection to TRUE" ); 591 odebug << "QProcess::connectNotify(): set ioRedirection to TRUE" << oendl;
592#endif 592#endif
593 setIoRedirection( TRUE ); 593 setIoRedirection( TRUE );
594 return; 594 return;
595 } 595 }
596 if ( !notifyOnExit && qstrcmp( signal, SIGNAL(processExited()) )==0 ) { 596 if ( !notifyOnExit && qstrcmp( signal, SIGNAL(processExited()) )==0 ) {
597#if defined(QT_QPROCESS_DEBUG) 597#if defined(QT_QPROCESS_DEBUG)
598 qDebug( "QProcess::connectNotify(): set notifyOnExit to TRUE" ); 598 odebug << "QProcess::connectNotify(): set notifyOnExit to TRUE" << oendl;
599#endif 599#endif
600 setNotifyOnExit( TRUE ); 600 setNotifyOnExit( TRUE );
601 return; 601 return;
602 } 602 }
603 if ( !wroteToStdinConnected && qstrcmp( signal, SIGNAL(wroteToStdin()) )==0 ) { 603 if ( !wroteToStdinConnected && qstrcmp( signal, SIGNAL(wroteToStdin()) )==0 ) {
604#if defined(QT_QPROCESS_DEBUG) 604#if defined(QT_QPROCESS_DEBUG)
605 qDebug( "QProcess::connectNotify(): set wroteToStdinConnected to TRUE" ); 605 odebug << "QProcess::connectNotify(): set wroteToStdinConnected to TRUE" << oendl;
606#endif 606#endif
607 setWroteStdinConnected( TRUE ); 607 setWroteStdinConnected( TRUE );
608 return; 608 return;
609 } 609 }
610} 610}
611 611
612/*! \reimp 612/*! \reimp
613*/ 613*/
614void QProcess::disconnectNotify( const char * ) 614void QProcess::disconnectNotify( const char * )
615{ 615{
616 if ( ioRedirection && 616 if ( ioRedirection &&
617 receivers( SIGNAL(readyReadStdout()) ) ==0 && 617 receivers( SIGNAL(readyReadStdout()) ) ==0 &&
618 receivers( SIGNAL(readyReadStderr()) ) ==0 618 receivers( SIGNAL(readyReadStderr()) ) ==0
619 ) { 619 ) {
620#if defined(QT_QPROCESS_DEBUG) 620#if defined(QT_QPROCESS_DEBUG)
621 qDebug( "QProcess::disconnectNotify(): set ioRedirection to FALSE" ); 621 odebug << "QProcess::disconnectNotify(): set ioRedirection to FALSE" << oendl;
622#endif 622#endif
623 setIoRedirection( FALSE ); 623 setIoRedirection( FALSE );
624 } 624 }
625 if ( notifyOnExit && receivers( SIGNAL(processExited()) ) == 0 ) { 625 if ( notifyOnExit && receivers( SIGNAL(processExited()) ) == 0 ) {
626#if defined(QT_QPROCESS_DEBUG) 626#if defined(QT_QPROCESS_DEBUG)
627 qDebug( "QProcess::disconnectNotify(): set notifyOnExit to FALSE" ); 627 odebug << "QProcess::disconnectNotify(): set notifyOnExit to FALSE" << oendl;
628#endif 628#endif
629 setNotifyOnExit( FALSE ); 629 setNotifyOnExit( FALSE );
630 } 630 }
631 if ( wroteToStdinConnected && receivers( SIGNAL(wroteToStdin()) ) == 0 ) { 631 if ( wroteToStdinConnected && receivers( SIGNAL(wroteToStdin()) ) == 0 ) {
632#if defined(QT_QPROCESS_DEBUG) 632#if defined(QT_QPROCESS_DEBUG)
633 qDebug( "QProcess::disconnectNotify(): set wroteToStdinConnected to FALSE" ); 633 odebug << "QProcess::disconnectNotify(): set wroteToStdinConnected to FALSE" << oendl;
634#endif 634#endif
635 setWroteStdinConnected( FALSE ); 635 setWroteStdinConnected( FALSE );
636 } 636 }
637} 637}
638 638
639#endif // QT_NO_PROCESS 639#endif // QT_NO_PROCESS
diff --git a/core/launcher/qprocess_unix.cpp b/core/launcher/qprocess_unix.cpp
index 19a8c93..d62e4e6 100644
--- a/core/launcher/qprocess_unix.cpp
+++ b/core/launcher/qprocess_unix.cpp
@@ -9,60 +9,59 @@
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 "qplatformdefs.h"
22
23// Solaris redefines connect -> __xnet_connect with _XOPEN_SOURCE_EXTENDED. 21// Solaris redefines connect -> __xnet_connect with _XOPEN_SOURCE_EXTENDED.
24#if defined(connect) 22#if defined(connect)
25#undef connect 23#undef connect
26#endif 24#endif
27 25
28#include "qprocess.h" 26#include "qprocess.h"
29 27
30#ifndef QT_NO_PROCESS 28/* OPIE */
29#include <opie2/odebug.h>
30using namespace Opie::Core;
31 31
32#include "qapplication.h" 32/* QT */
33#include "qqueue.h" 33#ifndef QT_NO_PROCESS
34#include "qlist.h" 34#include <qapplication.h>
35#include "qsocketnotifier.h" 35#include <qqueue.h>
36#include "qtimer.h" 36#include <qlist.h>
37#include "qregexp.h" 37#include <qsocketnotifier.h>
38#include <qtimer.h>
39#include <qregexp.h>
38 40
39#include "qcleanuphandler_p.h" 41#include "qcleanuphandler_p.h"
40 42
43/* STD */
41#include <stdlib.h> 44#include <stdlib.h>
42
43// ### FOR Qt 2.3 compat
44#include <unistd.h> 45#include <unistd.h>
45#include <signal.h> 46#include <signal.h>
46#include <sys/socket.h> 47#include <sys/socket.h>
47#include <sys/ioctl.h> 48#include <sys/ioctl.h>
48#include <sys/wait.h> 49#include <sys/wait.h>
49#include <sys/fcntl.h> 50#include <sys/fcntl.h>
50 51#include <sys/resource.h>
51#include <errno.h> 52#include <errno.h>
52
53#ifdef Q_OS_MACX 53#ifdef Q_OS_MACX
54#include <sys/time.h> 54#include <sys/time.h>
55#endif 55#endif
56#include <sys/resource.h>
57 56
58#ifdef __MIPSEL__ 57#ifdef __MIPSEL__
59# ifndef SOCK_DGRAM 58# ifndef SOCK_DGRAM
60# define SOCK_DGRAM 1 59# define SOCK_DGRAM 1
61# endif 60# endif
62# ifndef SOCK_STREAM 61# ifndef SOCK_STREAM
63# define SOCK_STREAM 2 62# define SOCK_STREAM 2
64# endif 63# endif
65#endif 64#endif
66 65
67//#define QT_QPROCESS_DEBUG 66//#define QT_QPROCESS_DEBUG
68 67
@@ -123,34 +122,34 @@ public:
123 child processes: if the process is finished, the QProcess class may still be 122 child processes: if the process is finished, the QProcess class may still be
124 there; furthermore a user can use QProcess to start more than one process. 123 there; furthermore a user can use QProcess to start more than one process.
125 124
126 The helper-class QProc has the semantics that one instance of this class maps 125 The helper-class QProc has the semantics that one instance of this class maps
127 directly to a running child process. 126 directly to a running child process.
128*/ 127*/
129class QProc 128class QProc
130{ 129{
131public: 130public:
132 QProc( pid_t p, QProcess *proc=0 ) : pid(p), process(proc) 131 QProc( pid_t p, QProcess *proc=0 ) : pid(p), process(proc)
133 { 132 {
134#if defined(QT_QPROCESS_DEBUG) 133#if defined(QT_QPROCESS_DEBUG)
135 qDebug( "QProc: Constructor for pid %d and QProcess %p", pid, process ); 134 odebug << "QProc: Constructor for pid " << pid << " and QProcess " << process << "" << oendl;
136#endif 135#endif
137 socketStdin = 0; 136 socketStdin = 0;
138 socketStdout = 0; 137 socketStdout = 0;
139 socketStderr = 0; 138 socketStderr = 0;
140 } 139 }
141 ~QProc() 140 ~QProc()
142 { 141 {
143#if defined(QT_QPROCESS_DEBUG) 142#if defined(QT_QPROCESS_DEBUG)
144 qDebug( "QProc: Destructor for pid %d and QProcess %p", pid, process ); 143 odebug << "QProc: Destructor for pid " << pid << " and QProcess " << process << "" << oendl;
145#endif 144#endif
146 if ( process != 0 ) { 145 if ( process != 0 ) {
147 if ( process->d->notifierStdin ) 146 if ( process->d->notifierStdin )
148 process->d->notifierStdin->setEnabled( FALSE ); 147 process->d->notifierStdin->setEnabled( FALSE );
149 if ( process->d->notifierStdout ) 148 if ( process->d->notifierStdout )
150 process->d->notifierStdout->setEnabled( FALSE ); 149 process->d->notifierStdout->setEnabled( FALSE );
151 if ( process->d->notifierStderr ) 150 if ( process->d->notifierStderr )
152 process->d->notifierStderr->setEnabled( FALSE ); 151 process->d->notifierStderr->setEnabled( FALSE );
153 process->d->proc = 0; 152 process->d->proc = 0;
154 } 153 }
155 if( socketStdin != 0 ) 154 if( socketStdin != 0 )
156 ::close( socketStdin ); 155 ::close( socketStdin );
@@ -204,102 +203,102 @@ QProcessManager::QProcessManager()
204{ 203{
205 procList = new QList<QProc>; 204 procList = new QList<QProc>;
206 procList->setAutoDelete( TRUE ); 205 procList->setAutoDelete( TRUE );
207 206
208 // The SIGCHLD handler writes to a socket to tell the manager that 207 // The SIGCHLD handler writes to a socket to tell the manager that
209 // something happened. This is done to get the processing in sync with the 208 // something happened. This is done to get the processing in sync with the
210 // event reporting. 209 // event reporting.
211 if ( ::socketpair( AF_UNIX, SOCK_STREAM, 0, sigchldFd ) ) { 210 if ( ::socketpair( AF_UNIX, SOCK_STREAM, 0, sigchldFd ) ) {
212 sigchldFd[0] = 0; 211 sigchldFd[0] = 0;
213 sigchldFd[1] = 0; 212 sigchldFd[1] = 0;
214 } else { 213 } else {
215#if defined(QT_QPROCESS_DEBUG) 214#if defined(QT_QPROCESS_DEBUG)
216 qDebug( "QProcessManager: install socket notifier (%d)", sigchldFd[1] ); 215 odebug << "QProcessManager: install socket notifier (" << sigchldFd[1] << ")" << oendl;
217#endif 216#endif
218 QSocketNotifier *sn = new QSocketNotifier( sigchldFd[1], 217 QSocketNotifier *sn = new QSocketNotifier( sigchldFd[1],
219 QSocketNotifier::Read, this ); 218 QSocketNotifier::Read, this );
220 connect( sn, SIGNAL(activated(int)), 219 connect( sn, SIGNAL(activated(int)),
221 this, SLOT(sigchldHnd(int)) ); 220 this, SLOT(sigchldHnd(int)) );
222 sn->setEnabled( TRUE ); 221 sn->setEnabled( TRUE );
223 } 222 }
224 223
225 // install a SIGCHLD handler and ignore SIGPIPE 224 // install a SIGCHLD handler and ignore SIGPIPE
226 struct sigaction act; 225 struct sigaction act;
227 226
228#if defined(QT_QPROCESS_DEBUG) 227#if defined(QT_QPROCESS_DEBUG)
229 qDebug( "QProcessManager: install a SIGCHLD handler" ); 228 odebug << "QProcessManager: install a SIGCHLD handler" << oendl;
230#endif 229#endif
231 act.sa_handler = qt_C_sigchldHnd; 230 act.sa_handler = qt_C_sigchldHnd;
232 sigemptyset( &(act.sa_mask) ); 231 sigemptyset( &(act.sa_mask) );
233 sigaddset( &(act.sa_mask), SIGCHLD ); 232 sigaddset( &(act.sa_mask), SIGCHLD );
234 act.sa_flags = SA_NOCLDSTOP; 233 act.sa_flags = SA_NOCLDSTOP;
235#if defined(SA_RESTART) 234#if defined(SA_RESTART)
236 act.sa_flags |= SA_RESTART; 235 act.sa_flags |= SA_RESTART;
237#endif 236#endif
238 if ( sigaction( SIGCHLD, &act, &oldactChld ) != 0 ) 237 if ( sigaction( SIGCHLD, &act, &oldactChld ) != 0 )
239 qWarning( "Error installing SIGCHLD handler" ); 238 owarn << "Error installing SIGCHLD handler" << oendl;
240 239
241#if defined(QT_QPROCESS_DEBUG) 240#if defined(QT_QPROCESS_DEBUG)
242 qDebug( "QProcessManager: install a SIGPIPE handler (SIG_IGN)" ); 241 odebug << "QProcessManager: install a SIGPIPE handler (SIG_IGN)" << oendl;
243#endif 242#endif
244 /* 243 /*
245 Using qt_C_sigpipeHnd rather than SIG_IGN is a workaround 244 Using qt_C_sigpipeHnd rather than SIG_IGN is a workaround
246 for a strange problem where GNU tar (called by backuprestore) 245 for a strange problem where GNU tar (called by backuprestore)
247 would hang on filesystem-full. Strangely, the qt_C_sigpipeHnd 246 would hang on filesystem-full. Strangely, the qt_C_sigpipeHnd
248 is never even called, yet this avoids the hang. 247 is never even called, yet this avoids the hang.
249 */ 248 */
250 act.sa_handler = qt_C_sigpipeHnd; 249 act.sa_handler = qt_C_sigpipeHnd;
251 sigemptyset( &(act.sa_mask) ); 250 sigemptyset( &(act.sa_mask) );
252 sigaddset( &(act.sa_mask), SIGPIPE ); 251 sigaddset( &(act.sa_mask), SIGPIPE );
253 act.sa_flags = 0; 252 act.sa_flags = 0;
254 if ( sigaction( SIGPIPE, &act, &oldactPipe ) != 0 ) 253 if ( sigaction( SIGPIPE, &act, &oldactPipe ) != 0 )
255 qWarning( "Error installing SIGPIPE handler" ); 254 owarn << "Error installing SIGPIPE handler" << oendl;
256} 255}
257 256
258QProcessManager::~QProcessManager() 257QProcessManager::~QProcessManager()
259{ 258{
260 delete procList; 259 delete procList;
261 260
262 if ( sigchldFd[0] != 0 ) 261 if ( sigchldFd[0] != 0 )
263 ::close( sigchldFd[0] ); 262 ::close( sigchldFd[0] );
264 if ( sigchldFd[1] != 0 ) 263 if ( sigchldFd[1] != 0 )
265 ::close( sigchldFd[1] ); 264 ::close( sigchldFd[1] );
266 265
267 // restore SIGCHLD handler 266 // restore SIGCHLD handler
268#if defined(QT_QPROCESS_DEBUG) 267#if defined(QT_QPROCESS_DEBUG)
269 qDebug( "QProcessManager: restore old sigchild handler" ); 268 odebug << "QProcessManager: restore old sigchild handler" << oendl;
270#endif 269#endif
271 if ( sigaction( SIGCHLD, &oldactChld, 0 ) != 0 ) 270 if ( sigaction( SIGCHLD, &oldactChld, 0 ) != 0 )
272 qWarning( "Error restoring SIGCHLD handler" ); 271 owarn << "Error restoring SIGCHLD handler" << oendl;
273 272
274#if defined(QT_QPROCESS_DEBUG) 273#if defined(QT_QPROCESS_DEBUG)
275 qDebug( "QProcessManager: restore old sigpipe handler" ); 274 odebug << "QProcessManager: restore old sigpipe handler" << oendl;
276#endif 275#endif
277 if ( sigaction( SIGPIPE, &oldactPipe, 0 ) != 0 ) 276 if ( sigaction( SIGPIPE, &oldactPipe, 0 ) != 0 )
278 qWarning( "Error restoring SIGPIPE handler" ); 277 owarn << "Error restoring SIGPIPE handler" << oendl;
279} 278}
280 279
281void QProcessManager::append( QProc *p ) 280void QProcessManager::append( QProc *p )
282{ 281{
283 procList->append( p ); 282 procList->append( p );
284#if defined(QT_QPROCESS_DEBUG) 283#if defined(QT_QPROCESS_DEBUG)
285 qDebug( "QProcessManager: append process (procList.count(): %d)", procList->count() ); 284 odebug << "QProcessManager: append process (procList.count(): " << procList->count() << ")" << oendl;
286#endif 285#endif
287} 286}
288 287
289void QProcessManager::remove( QProc *p ) 288void QProcessManager::remove( QProc *p )
290{ 289{
291 procList->remove( p ); 290 procList->remove( p );
292#if defined(QT_QPROCESS_DEBUG) 291#if defined(QT_QPROCESS_DEBUG)
293 qDebug( "QProcessManager: remove process (procList.count(): %d)", procList->count() ); 292 odebug << "QProcessManager: remove process (procList.count(): " << procList->count() << ")" << oendl;
294#endif 293#endif
295 cleanup(); 294 cleanup();
296} 295}
297 296
298void QProcessManager::cleanup() 297void QProcessManager::cleanup()
299{ 298{
300 if ( procList->count() == 0 ) { 299 if ( procList->count() == 0 ) {
301 QTimer::singleShot( 0, this, SLOT(removeMe()) ); 300 QTimer::singleShot( 0, this, SLOT(removeMe()) );
302 } 301 }
303} 302}
304 303
305void QProcessManager::removeMe() 304void QProcessManager::removeMe()
@@ -307,65 +306,65 @@ void QProcessManager::removeMe()
307 if ( procList->count() == 0 ) { 306 if ( procList->count() == 0 ) {
308 qprocess_cleanup_procmanager.remove( &QProcessPrivate::procManager ); 307 qprocess_cleanup_procmanager.remove( &QProcessPrivate::procManager );
309 QProcessPrivate::procManager = 0; 308 QProcessPrivate::procManager = 0;
310 delete this; 309 delete this;
311 } 310 }
312} 311}
313 312
314void QProcessManager::sigchldHnd( int fd ) 313void QProcessManager::sigchldHnd( int fd )
315{ 314{
316 char tmp; 315 char tmp;
317 ::read( fd, &tmp, sizeof(tmp) ); 316 ::read( fd, &tmp, sizeof(tmp) );
318#if defined(QT_QPROCESS_DEBUG) 317#if defined(QT_QPROCESS_DEBUG)
319 qDebug( "QProcessManager::sigchldHnd()" ); 318 odebug << "QProcessManager::sigchldHnd()" << oendl;
320#endif 319#endif
321 QProc *proc; 320 QProc *proc;
322 QProcess *process; 321 QProcess *process;
323 bool removeProc; 322 bool removeProc;
324 proc = procList->first(); 323 proc = procList->first();
325 while ( proc != 0 ) { 324 while ( proc != 0 ) {
326 removeProc = FALSE; 325 removeProc = FALSE;
327 process = proc->process; 326 process = proc->process;
328 QProcess *process_exit_notify=0; 327 QProcess *process_exit_notify=0;
329 if ( process != 0 ) { 328 if ( process != 0 ) {
330 if ( !process->isRunning() ) { 329 if ( !process->isRunning() ) {
331#if defined(QT_QPROCESS_DEBUG) 330#if defined(QT_QPROCESS_DEBUG)
332 qDebug( "QProcessManager::sigchldHnd() (PID: %d): process exited (QProcess available)", proc->pid ); 331 odebug << "QProcessManager::sigchldHnd() (PID: " << proc->pid << "): process exited (QProcess available)" << oendl;
333#endif 332#endif
334 // read pending data 333 // read pending data
335 int nbytes = 0; 334 int nbytes = 0;
336 if ( ::ioctl(proc->socketStdout, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) { 335 if ( ::ioctl(proc->socketStdout, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) {
337#if defined(QT_QPROCESS_DEBUG) 336#if defined(QT_QPROCESS_DEBUG)
338 qDebug( "QProcessManager::sigchldHnd() (PID: %d): reading %d bytes of pending data on stdout", proc->pid, nbytes ); 337 odebug << "QProcessManager::sigchldHnd() (PID: " << proc->pid << "): reading " << nbytes << " bytes of pending data on stdout" << oendl;
339#endif 338#endif
340 process->socketRead( proc->socketStdout ); 339 process->socketRead( proc->socketStdout );
341 } 340 }
342 nbytes = 0; 341 nbytes = 0;
343 if ( ::ioctl(proc->socketStderr, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) { 342 if ( ::ioctl(proc->socketStderr, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) {
344#if defined(QT_QPROCESS_DEBUG) 343#if defined(QT_QPROCESS_DEBUG)
345 qDebug( "QProcessManager::sigchldHnd() (PID: %d): reading %d bytes of pending data on stderr", proc->pid, nbytes ); 344 odebug << "QProcessManager::sigchldHnd() (PID: " << proc->pid << "): reading " << nbytes << " bytes of pending data on stderr" << oendl;
346#endif 345#endif
347 process->socketRead( proc->socketStderr ); 346 process->socketRead( proc->socketStderr );
348 } 347 }
349 348
350 if ( process->notifyOnExit ) 349 if ( process->notifyOnExit )
351 process_exit_notify = process; 350 process_exit_notify = process;
352 351
353 removeProc = TRUE; 352 removeProc = TRUE;
354 } 353 }
355 } else { 354 } else {
356 int status; 355 int status;
357 if ( ::waitpid( proc->pid, &status, WNOHANG ) == proc->pid ) { 356 if ( ::waitpid( proc->pid, &status, WNOHANG ) == proc->pid ) {
358#if defined(QT_QPROCESS_DEBUG) 357#if defined(QT_QPROCESS_DEBUG)
359 qDebug( "QProcessManager::sigchldHnd() (PID: %d): process exited (QProcess not available)", proc->pid ); 358 odebug << "QProcessManager::sigchldHnd() (PID: " << proc->pid << "): process exited (QProcess not available)" << oendl;
360#endif 359#endif
361 removeProc = TRUE; 360 removeProc = TRUE;
362 } 361 }
363 } 362 }
364 if ( removeProc ) { 363 if ( removeProc ) {
365 QProc *oldproc = proc; 364 QProc *oldproc = proc;
366 proc = procList->next(); 365 proc = procList->next();
367 remove( oldproc ); 366 remove( oldproc );
368 } else { 367 } else {
369 proc = procList->next(); 368 proc = procList->next();
370 } 369 }
371 if ( process_exit_notify ) 370 if ( process_exit_notify )
@@ -377,42 +376,42 @@ void QProcessManager::sigchldHnd( int fd )
377 376
378 377
379/*********************************************************************** 378/***********************************************************************
380 * 379 *
381 * QProcessPrivate 380 * QProcessPrivate
382 * 381 *
383 **********************************************************************/ 382 **********************************************************************/
384QProcessManager *QProcessPrivate::procManager = 0; 383QProcessManager *QProcessPrivate::procManager = 0;
385 384
386QProcessPrivate::QProcessPrivate() 385QProcessPrivate::QProcessPrivate()
387{ 386{
388#if defined(QT_QPROCESS_DEBUG) 387#if defined(QT_QPROCESS_DEBUG)
389 qDebug( "QProcessPrivate: Constructor" ); 388 odebug << "QProcessPrivate: Constructor" << oendl;
390#endif 389#endif
391 stdinBufRead = 0; 390 stdinBufRead = 0;
392 391
393 notifierStdin = 0; 392 notifierStdin = 0;
394 notifierStdout = 0; 393 notifierStdout = 0;
395 notifierStderr = 0; 394 notifierStderr = 0;
396 395
397 exitValuesCalculated = FALSE; 396 exitValuesCalculated = FALSE;
398 socketReadCalled = FALSE; 397 socketReadCalled = FALSE;
399 398
400 proc = 0; 399 proc = 0;
401} 400}
402 401
403QProcessPrivate::~QProcessPrivate() 402QProcessPrivate::~QProcessPrivate()
404{ 403{
405#if defined(QT_QPROCESS_DEBUG) 404#if defined(QT_QPROCESS_DEBUG)
406 qDebug( "QProcessPrivate: Destructor" ); 405 odebug << "QProcessPrivate: Destructor" << oendl;
407#endif 406#endif
408 407
409 if ( proc != 0 ) { 408 if ( proc != 0 ) {
410 if ( proc->socketStdin != 0 ) { 409 if ( proc->socketStdin != 0 ) {
411 ::close( proc->socketStdin ); 410 ::close( proc->socketStdin );
412 proc->socketStdin = 0; 411 proc->socketStdin = 0;
413 } 412 }
414 proc->process = 0; 413 proc->process = 0;
415 } 414 }
416 415
417 while ( !stdinBuf.isEmpty() ) { 416 while ( !stdinBuf.isEmpty() ) {
418 delete stdinBuf.dequeue(); 417 delete stdinBuf.dequeue();
@@ -590,25 +589,25 @@ QProcess::~QProcess()
590 You can call this function even when there already is a running 589 You can call this function even when there already is a running
591 process in this object. In this case, QProcess closes standard input 590 process in this object. In this case, QProcess closes standard input
592 of the old process and deletes pending data, i.e., you loose all 591 of the old process and deletes pending data, i.e., you loose all
593 control over that process, but the process is not terminated. This applies 592 control over that process, but the process is not terminated. This applies
594 also if the process could not be started. (On operating systems that have 593 also if the process could not be started. (On operating systems that have
595 zombie processes, Qt will also wait() on the old process.) 594 zombie processes, Qt will also wait() on the old process.)
596 595
597 \sa launch() closeStdin() 596 \sa launch() closeStdin()
598*/ 597*/
599bool QProcess::start( QStringList *env ) 598bool QProcess::start( QStringList *env )
600{ 599{
601#if defined(QT_QPROCESS_DEBUG) 600#if defined(QT_QPROCESS_DEBUG)
602 qDebug( "QProcess::start()" ); 601 odebug << "QProcess::start()" << oendl;
603#endif 602#endif
604 reset(); 603 reset();
605 604
606 int sStdin[2]; 605 int sStdin[2];
607 int sStdout[2]; 606 int sStdout[2];
608 int sStderr[2]; 607 int sStderr[2];
609 608
610 // open sockets for piping 609 // open sockets for piping
611 if ( (comms & Stdin) && ::socketpair( AF_UNIX, SOCK_STREAM, 0, sStdin ) == -1 ) { 610 if ( (comms & Stdin) && ::socketpair( AF_UNIX, SOCK_STREAM, 0, sStdin ) == -1 ) {
612 return FALSE; 611 return FALSE;
613 } 612 }
614 if ( (comms & Stderr) && ::socketpair( AF_UNIX, SOCK_STREAM, 0, sStderr ) == -1 ) { 613 if ( (comms & Stderr) && ::socketpair( AF_UNIX, SOCK_STREAM, 0, sStderr ) == -1 ) {
@@ -626,25 +625,25 @@ bool QProcess::start( QStringList *env )
626 fd[0] = 0; 625 fd[0] = 0;
627 fd[1] = 0; 626 fd[1] = 0;
628 } 627 }
629 628
630 // construct the arguments for exec 629 // construct the arguments for exec
631 QCString *arglistQ = new QCString[ _arguments.count() + 1 ]; 630 QCString *arglistQ = new QCString[ _arguments.count() + 1 ];
632 const char** arglist = new const char*[ _arguments.count() + 1 ]; 631 const char** arglist = new const char*[ _arguments.count() + 1 ];
633 int i = 0; 632 int i = 0;
634 for ( QStringList::Iterator it = _arguments.begin(); it != _arguments.end(); ++it ) { 633 for ( QStringList::Iterator it = _arguments.begin(); it != _arguments.end(); ++it ) {
635 arglistQ[i] = (*it).local8Bit(); 634 arglistQ[i] = (*it).local8Bit();
636 arglist[i] = arglistQ[i]; 635 arglist[i] = arglistQ[i];
637#if defined(QT_QPROCESS_DEBUG) 636#if defined(QT_QPROCESS_DEBUG)
638 qDebug( "QProcess::start(): arg %d = %s", i, arglist[i] ); 637 odebug << "QProcess::start(): arg " << i << " = " << arglist[i] << "" << oendl;
639#endif 638#endif
640 i++; 639 i++;
641 } 640 }
642 arglist[i] = 0; 641 arglist[i] = 0;
643 642
644 // Must make sure signal handlers are installed before exec'ing 643 // Must make sure signal handlers are installed before exec'ing
645 // in case the process exits quickly. 644 // in case the process exits quickly.
646 if ( d->procManager == 0 ) { 645 if ( d->procManager == 0 ) {
647 d->procManager = new QProcessManager; 646 d->procManager = new QProcessManager;
648 qprocess_cleanup_procmanager.add( &d->procManager ); 647 qprocess_cleanup_procmanager.add( &d->procManager );
649 } 648 }
650 649
@@ -790,25 +789,25 @@ bool QProcess::start( QStringList *env )
790 this, SLOT(socketRead(int)) ); 789 this, SLOT(socketRead(int)) );
791 if ( ioRedirection ) 790 if ( ioRedirection )
792 d->notifierStderr->setEnabled( TRUE ); 791 d->notifierStderr->setEnabled( TRUE );
793 } 792 }
794 793
795 // cleanup and return 794 // cleanup and return
796 delete[] arglistQ; 795 delete[] arglistQ;
797 delete[] arglist; 796 delete[] arglist;
798 return TRUE; 797 return TRUE;
799 798
800error: 799error:
801#if defined(QT_QPROCESS_DEBUG) 800#if defined(QT_QPROCESS_DEBUG)
802 qDebug( "QProcess::start(): error starting process" ); 801 odebug << "QProcess::start(): error starting process" << oendl;
803#endif 802#endif
804 if ( d->procManager ) 803 if ( d->procManager )
805 d->procManager->cleanup(); 804 d->procManager->cleanup();
806 if ( comms & Stdin ) { 805 if ( comms & Stdin ) {
807 ::close( sStdin[1] ); 806 ::close( sStdin[1] );
808 ::close( sStdin[0] ); 807 ::close( sStdin[0] );
809 } 808 }
810 if ( comms & Stdout ) { 809 if ( comms & Stdout ) {
811 ::close( sStdout[0] ); 810 ::close( sStdout[0] );
812 ::close( sStdout[1] ); 811 ::close( sStdout[1] );
813 } 812 }
814 if ( comms & Stderr ) { 813 if ( comms & Stderr ) {
@@ -869,67 +868,67 @@ void QProcess::kill() const
869 ::kill( d->proc->pid, SIGKILL ); 868 ::kill( d->proc->pid, SIGKILL );
870} 869}
871 870
872/*! 871/*!
873 Returns TRUE if the process is running, otherwise FALSE. 872 Returns TRUE if the process is running, otherwise FALSE.
874 873
875 \sa normalExit() exitStatus() processExited() 874 \sa normalExit() exitStatus() processExited()
876*/ 875*/
877bool QProcess::isRunning() const 876bool QProcess::isRunning() const
878{ 877{
879 if ( d->exitValuesCalculated ) { 878 if ( d->exitValuesCalculated ) {
880#if defined(QT_QPROCESS_DEBUG) 879#if defined(QT_QPROCESS_DEBUG)
881 qDebug( "QProcess::isRunning(): FALSE (already computed)" ); 880 odebug << "QProcess::isRunning(): FALSE (already computed)" << oendl;
882#endif 881#endif
883 return FALSE; 882 return FALSE;
884 } 883 }
885 if ( d->proc == 0 ) 884 if ( d->proc == 0 )
886 return FALSE; 885 return FALSE;
887 int status; 886 int status;
888 if ( ::waitpid( d->proc->pid, &status, WNOHANG ) == d->proc->pid ) 887 if ( ::waitpid( d->proc->pid, &status, WNOHANG ) == d->proc->pid )
889 { 888 {
890 // compute the exit values 889 // compute the exit values
891 QProcess *that = (QProcess*)this; // mutable 890 QProcess *that = (QProcess*)this; // mutable
892 that->exitNormal = WIFEXITED( status ) != 0; 891 that->exitNormal = WIFEXITED( status ) != 0;
893 if ( exitNormal ) { 892 if ( exitNormal ) {
894 that->exitStat = (char)WEXITSTATUS( status ); 893 that->exitStat = (char)WEXITSTATUS( status );
895 } 894 }
896 d->exitValuesCalculated = TRUE; 895 d->exitValuesCalculated = TRUE;
897#if defined(QT_QPROCESS_DEBUG) 896#if defined(QT_QPROCESS_DEBUG)
898 qDebug( "QProcess::isRunning() (PID: %d): FALSE", d->proc->pid ); 897 odebug << "QProcess::isRunning() (PID: " << d->proc->pid << "): FALSE" << oendl;
899#endif 898#endif
900 return FALSE; 899 return FALSE;
901 } 900 }
902#if defined(QT_QPROCESS_DEBUG) 901#if defined(QT_QPROCESS_DEBUG)
903 qDebug( "QProcess::isRunning() (PID: %d): TRUE", d->proc->pid ); 902 odebug << "QProcess::isRunning() (PID: " << d->proc->pid << "): TRUE" << oendl;
904#endif 903#endif
905 return TRUE; 904 return TRUE;
906} 905}
907 906
908/*! 907/*!
909 Writes the data \a buf to the standard input of the process. The process may 908 Writes the data \a buf to the standard input of the process. The process may
910 or may not read this data. 909 or may not read this data.
911 910
912 This function returns immediately; the QProcess class might write the data at 911 This function returns immediately; the QProcess class might write the data at
913 a later point (you have to enter the event loop for that). When all the data 912 a later point (you have to enter the event loop for that). When all the data
914 is written to the process, the signal wroteToStdin() is emitted. This does 913 is written to the process, the signal wroteToStdin() is emitted. This does
915 not mean that the process really read the data, since this class only detects 914 not mean that the process really read the data, since this class only detects
916 when it was able to write the data to the operating system. 915 when it was able to write the data to the operating system.
917 916
918 \sa wroteToStdin() closeStdin() readStdout() readStderr() 917 \sa wroteToStdin() closeStdin() readStdout() readStderr()
919*/ 918*/
920void QProcess::writeToStdin( const QByteArray& buf ) 919void QProcess::writeToStdin( const QByteArray& buf )
921{ 920{
922#if defined(QT_QPROCESS_DEBUG) 921#if defined(QT_QPROCESS_DEBUG)
923// qDebug( "QProcess::writeToStdin(): write to stdin (%d)", d->socketStdin ); 922// odebug << "QProcess::writeToStdin(): write to stdin (" << d->socketStdin << ")" << oendl;
924#endif 923#endif
925 d->stdinBuf.enqueue( new QByteArray(buf) ); 924 d->stdinBuf.enqueue( new QByteArray(buf) );
926 if ( d->notifierStdin != 0 ) 925 if ( d->notifierStdin != 0 )
927 d->notifierStdin->setEnabled( TRUE ); 926 d->notifierStdin->setEnabled( TRUE );
928} 927}
929 928
930 929
931/*! 930/*!
932 Closes standard input of the process. 931 Closes standard input of the process.
933 932
934 This function also deletes pending data that is not written to standard input 933 This function also deletes pending data that is not written to standard input
935 yet. 934 yet.
@@ -938,48 +937,48 @@ void QProcess::writeToStdin( const QByteArray& buf )
938*/ 937*/
939void QProcess::closeStdin() 938void QProcess::closeStdin()
940{ 939{
941 if ( d->proc == 0 ) 940 if ( d->proc == 0 )
942 return; 941 return;
943 if ( d->proc->socketStdin !=0 ) { 942 if ( d->proc->socketStdin !=0 ) {
944 while ( !d->stdinBuf.isEmpty() ) { 943 while ( !d->stdinBuf.isEmpty() ) {
945 delete d->stdinBuf.dequeue(); 944 delete d->stdinBuf.dequeue();
946 } 945 }
947 delete d->notifierStdin; 946 delete d->notifierStdin;
948 d->notifierStdin = 0; 947 d->notifierStdin = 0;
949 if ( ::close( d->proc->socketStdin ) != 0 ) { 948 if ( ::close( d->proc->socketStdin ) != 0 ) {
950 qWarning( "Could not close stdin of child process" ); 949 owarn << "Could not close stdin of child process" << oendl;
951 } 950 }
952#if defined(QT_QPROCESS_DEBUG) 951#if defined(QT_QPROCESS_DEBUG)
953 qDebug( "QProcess::closeStdin(): stdin (%d) closed", d->proc->socketStdin ); 952 odebug << "QProcess::closeStdin(): stdin (" << d->proc->socketStdin << ") closed" << oendl;
954#endif 953#endif
955 d->proc->socketStdin = 0; 954 d->proc->socketStdin = 0;
956 } 955 }
957} 956}
958 957
959 958
960/* 959/*
961 This private slot is called when the process has outputted data to either 960 This private slot is called when the process has outputted data to either
962 standard output or standard error. 961 standard output or standard error.
963*/ 962*/
964void QProcess::socketRead( int fd ) 963void QProcess::socketRead( int fd )
965{ 964{
966 if ( d->socketReadCalled ) { 965 if ( d->socketReadCalled ) {
967 // the slots that are connected to the readyRead...() signals might 966 // the slots that are connected to the readyRead...() signals might
968 // trigger a recursive call of socketRead(). Avoid this since you get a 967 // trigger a recursive call of socketRead(). Avoid this since you get a
969 // blocking read otherwise. 968 // blocking read otherwise.
970 return; 969 return;
971 } 970 }
972#if defined(QT_QPROCESS_DEBUG) 971#if defined(QT_QPROCESS_DEBUG)
973 qDebug( "QProcess::socketRead(): %d", fd ); 972 odebug << "QProcess::socketRead(): " << fd << "" << oendl;
974#endif 973#endif
975 if ( fd == 0 ) 974 if ( fd == 0 )
976 return; 975 return;
977 const int bufsize = 4096; 976 const int bufsize = 4096;
978 QByteArray *buffer = 0; 977 QByteArray *buffer = 0;
979 uint oldSize; 978 uint oldSize;
980 int n; 979 int n;
981 if ( fd == d->proc->socketStdout ) { 980 if ( fd == d->proc->socketStdout ) {
982 buffer = &d->bufStdout; 981 buffer = &d->bufStdout;
983 } else if ( fd == d->proc->socketStderr ) { 982 } else if ( fd == d->proc->socketStderr ) {
984 buffer = &d->bufStderr; 983 buffer = &d->bufStderr;
985 } else { 984 } else {
@@ -990,35 +989,35 @@ void QProcess::socketRead( int fd )
990 // read data 989 // read data
991 oldSize = buffer->size(); 990 oldSize = buffer->size();
992 buffer->resize( oldSize + bufsize ); 991 buffer->resize( oldSize + bufsize );
993 n = ::read( fd, buffer->data()+oldSize, bufsize ); 992 n = ::read( fd, buffer->data()+oldSize, bufsize );
994 if ( n > 0 ) 993 if ( n > 0 )
995 buffer->resize( oldSize + n ); 994 buffer->resize( oldSize + n );
996 else 995 else
997 buffer->resize( oldSize ); 996 buffer->resize( oldSize );
998 // eof or error? 997 // eof or error?
999 if ( n == 0 || n == -1 ) { 998 if ( n == 0 || n == -1 ) {
1000 if ( fd == d->proc->socketStdout ) { 999 if ( fd == d->proc->socketStdout ) {
1001#if defined(QT_QPROCESS_DEBUG) 1000#if defined(QT_QPROCESS_DEBUG)
1002 qDebug( "QProcess::socketRead(): stdout (%d) closed", fd ); 1001 odebug << "QProcess::socketRead(): stdout (" << fd << ") closed" << oendl;
1003#endif 1002#endif
1004 d->notifierStdout->setEnabled( FALSE ); 1003 d->notifierStdout->setEnabled( FALSE );
1005 delete d->notifierStdout; 1004 delete d->notifierStdout;
1006 d->notifierStdout = 0; 1005 d->notifierStdout = 0;
1007 ::close( d->proc->socketStdout ); 1006 ::close( d->proc->socketStdout );
1008 d->proc->socketStdout = 0; 1007 d->proc->socketStdout = 0;
1009 return; 1008 return;
1010 } else if ( fd == d->proc->socketStderr ) { 1009 } else if ( fd == d->proc->socketStderr ) {
1011#if defined(QT_QPROCESS_DEBUG) 1010#if defined(QT_QPROCESS_DEBUG)
1012 qDebug( "QProcess::socketRead(): stderr (%d) closed", fd ); 1011 odebug << "QProcess::socketRead(): stderr (" << fd << ") closed" << oendl;
1013#endif 1012#endif
1014 d->notifierStderr->setEnabled( FALSE ); 1013 d->notifierStderr->setEnabled( FALSE );
1015 delete d->notifierStderr; 1014 delete d->notifierStderr;
1016 d->notifierStderr = 0; 1015 d->notifierStderr = 0;
1017 ::close( d->proc->socketStderr ); 1016 ::close( d->proc->socketStderr );
1018 d->proc->socketStderr = 0; 1017 d->proc->socketStderr = 0;
1019 return; 1018 return;
1020 } 1019 }
1021 } 1020 }
1022 // read all data that is available 1021 // read all data that is available
1023 while ( n == bufsize ) { 1022 while ( n == bufsize ) {
1024 oldSize = buffer->size(); 1023 oldSize = buffer->size();
@@ -1052,25 +1051,25 @@ void QProcess::socketRead( int fd )
1052 This private slot is called when the process tries to read data from standard 1051 This private slot is called when the process tries to read data from standard
1053 input. 1052 input.
1054*/ 1053*/
1055void QProcess::socketWrite( int fd ) 1054void QProcess::socketWrite( int fd )
1056{ 1055{
1057 if ( fd != d->proc->socketStdin || d->proc->socketStdin == 0 ) 1056 if ( fd != d->proc->socketStdin || d->proc->socketStdin == 0 )
1058 return; 1057 return;
1059 if ( d->stdinBuf.isEmpty() ) { 1058 if ( d->stdinBuf.isEmpty() ) {
1060 d->notifierStdin->setEnabled( FALSE ); 1059 d->notifierStdin->setEnabled( FALSE );
1061 return; 1060 return;
1062 } 1061 }
1063#if defined(QT_QPROCESS_DEBUG) 1062#if defined(QT_QPROCESS_DEBUG)
1064 qDebug( "QProcess::socketWrite(): write to stdin (%d)", fd ); 1063 odebug << "QProcess::socketWrite(): write to stdin (" << fd << ")" << oendl;
1065#endif 1064#endif
1066 ssize_t ret = ::write( fd, 1065 ssize_t ret = ::write( fd,
1067 d->stdinBuf.head()->data() + d->stdinBufRead, 1066 d->stdinBuf.head()->data() + d->stdinBufRead,
1068 d->stdinBuf.head()->size() - d->stdinBufRead ); 1067 d->stdinBuf.head()->size() - d->stdinBufRead );
1069 if ( ret > 0 ) 1068 if ( ret > 0 )
1070 d->stdinBufRead += ret; 1069 d->stdinBufRead += ret;
1071 if ( d->stdinBufRead == (ssize_t)d->stdinBuf.head()->size() ) { 1070 if ( d->stdinBufRead == (ssize_t)d->stdinBuf.head()->size() ) {
1072 d->stdinBufRead = 0; 1071 d->stdinBufRead = 0;
1073 delete d->stdinBuf.dequeue(); 1072 delete d->stdinBuf.dequeue();
1074 if ( wroteToStdinConnected && d->stdinBuf.isEmpty() ) 1073 if ( wroteToStdinConnected && d->stdinBuf.isEmpty() )
1075 emit wroteToStdin(); 1074 emit wroteToStdin();
1076 socketWrite( fd ); 1075 socketWrite( fd );
diff --git a/core/launcher/runningappbar.cpp b/core/launcher/runningappbar.cpp
index 2e9d2a9..a25963f 100644
--- a/core/launcher/runningappbar.cpp
+++ b/core/launcher/runningappbar.cpp
@@ -11,80 +11,84 @@
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#define QTOPIA_INTERNAL_PRELOADACCESS 21#define QTOPIA_INTERNAL_PRELOADACCESS
22 22
23#include "runningappbar.h"
24#include "serverinterface.h"
23 25
24#include <stdlib.h> 26/* OPIE */
27#include <opie2/odebug.h>
28#include <qtopia/qcopenvelope_qws.h>
29using namespace Opie::Core;
25 30
31/* QT */
26#include <qpainter.h> 32#include <qpainter.h>
27 33
28#include <qtopia/qcopenvelope_qws.h> 34/* STD */
29 35#include <stdlib.h>
30#include "runningappbar.h"
31#include "serverinterface.h"
32 36
33RunningAppBar::RunningAppBar(QWidget* parent) 37RunningAppBar::RunningAppBar(QWidget* parent)
34 : QFrame(parent), selectedAppIndex(-1) 38 : QFrame(parent), selectedAppIndex(-1)
35{ 39{
36 QCopChannel* channel = new QCopChannel( "QPE/System", this ); 40 QCopChannel* channel = new QCopChannel( "QPE/System", this );
37 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), 41 connect( channel, SIGNAL(received(const QCString&,const QByteArray&)),
38 this, SLOT(received(const QCString&,const QByteArray&)) ); 42 this, SLOT(received(const QCString&,const QByteArray&)) );
39 43
40 spacing = AppLnk::smallIconSize()+3; 44 spacing = AppLnk::smallIconSize()+3;
41} 45}
42 46
43RunningAppBar::~RunningAppBar() 47RunningAppBar::~RunningAppBar()
44{ 48{
45} 49}
46 50
47void RunningAppBar::received(const QCString& msg, const QByteArray& data) { 51void RunningAppBar::received(const QCString& msg, const QByteArray& data) {
48 // Since fast apps appear and disappear without disconnecting from their 52 // Since fast apps appear and disappear without disconnecting from their
49 // channel we need to watch for the showing/hiding events and update according. 53 // channel we need to watch for the showing/hiding events and update according.
50 QDataStream stream( data, IO_ReadOnly ); 54 QDataStream stream( data, IO_ReadOnly );
51 if ( msg == "fastAppShowing(QString)") { 55 if ( msg == "fastAppShowing(QString)") {
52 QString appName; 56 QString appName;
53 stream >> appName; 57 stream >> appName;
54 // qDebug("fastAppShowing %s", appName.data() ); 58 // odebug << "fastAppShowing " << appName.data() << "" << oendl;
55 const AppLnk* f = ServerInterface::appLnks().findExec(appName); 59 const AppLnk* f = ServerInterface::appLnks().findExec(appName);
56 if ( f ) addTask(*f); 60 if ( f ) addTask(*f);
57 } else if ( msg == "fastAppHiding(QString)") { 61 } else if ( msg == "fastAppHiding(QString)") {
58 QString appName; 62 QString appName;
59 stream >> appName; 63 stream >> appName;
60 const AppLnk* f = ServerInterface::appLnks().findExec(appName); 64 const AppLnk* f = ServerInterface::appLnks().findExec(appName);
61 if ( f ) removeTask(*f); 65 if ( f ) removeTask(*f);
62 } 66 }
63} 67}
64 68
65void RunningAppBar::addTask(const AppLnk& appLnk) { 69void RunningAppBar::addTask(const AppLnk& appLnk) {
66 qDebug("Added %s to app list.", appLnk.name().latin1()); 70 odebug << "Added " << appLnk.name() << " to app list." << oendl;
67 AppLnk* newApp = new AppLnk(appLnk); 71 AppLnk* newApp = new AppLnk(appLnk);
68 newApp->setExec(appLnk.exec()); 72 newApp->setExec(appLnk.exec());
69 appList.prepend(newApp); 73 appList.prepend(newApp);
70 update(); 74 update();
71} 75}
72 76
73void RunningAppBar::removeTask(const AppLnk& appLnk) { 77void RunningAppBar::removeTask(const AppLnk& appLnk) {
74 unsigned int i = 0; 78 unsigned int i = 0;
75 for (; i < appList.count() ; i++) { 79 for (; i < appList.count() ; i++) {
76 AppLnk* target = appList.at(i); 80 AppLnk* target = appList.at(i);
77 if (target->exec() == appLnk.exec()) { 81 if (target->exec() == appLnk.exec()) {
78 qDebug("Removing %s from app list.", appLnk.name().latin1()); 82 odebug << "Removing " << appLnk.name() << " from app list." << oendl;
79 appList.remove(); 83 appList.remove();
80 delete target; 84 delete target;
81 } 85 }
82 } 86 }
83 update(); 87 update();
84} 88}
85 89
86void RunningAppBar::mousePressEvent(QMouseEvent *e) 90void RunningAppBar::mousePressEvent(QMouseEvent *e)
87{ 91{
88 // Find out if the user is clicking on an app icon... 92 // Find out if the user is clicking on an app icon...
89 // If so, snag the index so when we repaint we show it 93 // If so, snag the index so when we repaint we show it
90 // as highlighed. 94 // as highlighed.
@@ -126,43 +130,43 @@ void RunningAppBar::paintEvent( QPaintEvent * )
126 AppLnk *curApp; 130 AppLnk *curApp;
127 int x = 0; 131 int x = 0;
128 int y = (height() - AppLnk::smallIconSize()) / 2; 132 int y = (height() - AppLnk::smallIconSize()) / 2;
129 int i = 0; 133 int i = 0;
130 134
131 p.fillRect( 0, 0, width(), height(), colorGroup().background() ); 135 p.fillRect( 0, 0, width(), height(), colorGroup().background() );
132 136
133 QListIterator<AppLnk> it(appList); 137 QListIterator<AppLnk> it(appList);
134 138
135 for (; it.current(); i++, ++it ) { 139 for (; it.current(); i++, ++it ) {
136 if ( x + spacing <= width() ) { 140 if ( x + spacing <= width() ) {
137 curApp = it.current(); 141 curApp = it.current();
138 qWarning("Drawing %s", curApp->name().latin1() ); 142 owarn << "Drawing " << curApp->name() << "" << oendl;
139 if ( (int)i == selectedAppIndex ) 143 if ( (int)i == selectedAppIndex )
140 p.fillRect( x, y, spacing, curApp->pixmap().height()+1, colorGroup().highlight() ); 144 p.fillRect( x, y, spacing, curApp->pixmap().height()+1, colorGroup().highlight() );
141 else 145 else
142 p.eraseRect( x, y, spacing, curApp->pixmap().height()+1 ); 146 p.eraseRect( x, y, spacing, curApp->pixmap().height()+1 );
143 p.drawPixmap( x, y, curApp->pixmap() ); 147 p.drawPixmap( x, y, curApp->pixmap() );
144 x += spacing; 148 x += spacing;
145 } 149 }
146 } 150 }
147} 151}
148 152
149QSize RunningAppBar::sizeHint() const 153QSize RunningAppBar::sizeHint() const
150{ 154{
151 return QSize( frameWidth(), AppLnk::smallIconSize()+frameWidth()*2+3 ); 155 return QSize( frameWidth(), AppLnk::smallIconSize()+frameWidth()*2+3 );
152} 156}
153 157
154void RunningAppBar::applicationLaunched(const QString &appName) 158void RunningAppBar::applicationLaunched(const QString &appName)
155{ 159{
156 qDebug("desktop:: app: %s launched with pid ", appName.data() ); 160 odebug << "desktop:: app: " << appName.data() << " launched with pid " << oendl;
157 const AppLnk* newGuy = ServerInterface::appLnks().findExec(appName); 161 const AppLnk* newGuy = ServerInterface::appLnks().findExec(appName);
158 if ( newGuy && !newGuy->isPreloaded() ) { 162 if ( newGuy && !newGuy->isPreloaded() ) {
159 addTask( *newGuy ); 163 addTask( *newGuy );
160 } 164 }
161} 165}
162 166
163void RunningAppBar::applicationTerminated(const QString &app) 167void RunningAppBar::applicationTerminated(const QString &app)
164{ 168{
165 const AppLnk* gone = ServerInterface::appLnks().findExec(app); 169 const AppLnk* gone = ServerInterface::appLnks().findExec(app);
166 if ( gone ) { 170 if ( gone ) {
167 removeTask(*gone); 171 removeTask(*gone);
168 } 172 }
diff --git a/core/launcher/screensaver.cpp b/core/launcher/screensaver.cpp
index 6aaab3a..a7d23c4 100644
--- a/core/launcher/screensaver.cpp
+++ b/core/launcher/screensaver.cpp
@@ -149,25 +149,25 @@ void OpieScreenSaver::setIntervals ( int dim, int lightoff, int suspend )
149 m_enable_dim_ac = ( dim > 0 ); 149 m_enable_dim_ac = ( dim > 0 );
150 m_enable_lightoff_ac = ( lightoff > 0 ); 150 m_enable_lightoff_ac = ( lightoff > 0 );
151 m_enable_suspend_ac = ( suspend > 0 ); 151 m_enable_suspend_ac = ( suspend > 0 );
152 m_onlylcdoff_ac = config.readBoolEntry ( "LcdOffOnly", false ); 152 m_onlylcdoff_ac = config.readBoolEntry ( "LcdOffOnly", false );
153 } 153 }
154 else { 154 else {
155 m_enable_dim = ( dim > 0 ); 155 m_enable_dim = ( dim > 0 );
156 m_enable_lightoff = ( lightoff > 0 ); 156 m_enable_lightoff = ( lightoff > 0 );
157 m_enable_suspend = ( suspend > 0 ); 157 m_enable_suspend = ( suspend > 0 );
158 m_onlylcdoff = config.readBoolEntry ( "LcdOffOnly", false ); 158 m_onlylcdoff = config.readBoolEntry ( "LcdOffOnly", false );
159 } 159 }
160 160
161 //qDebug("screen saver intervals: %d %d %d", dim, lightoff, suspend); 161 //odebug << "screen saver intervals: " << dim << " " << lightoff << " " << suspend << "" << oendl;
162 162
163 v [ 0 ] = QMAX( 1000 * dim, 100 ); 163 v [ 0 ] = QMAX( 1000 * dim, 100 );
164 v [ 1 ] = QMAX( 1000 * lightoff, 100 ); 164 v [ 1 ] = QMAX( 1000 * lightoff, 100 );
165 v [ 2 ] = QMAX( 1000 * suspend, 100 ); 165 v [ 2 ] = QMAX( 1000 * suspend, 100 );
166 v [ 3 ] = 0; 166 v [ 3 ] = 0;
167 167
168 if ( !dim && !lightoff && !suspend ) 168 if ( !dim && !lightoff && !suspend )
169 QWSServer::setScreenSaverInterval( 0 ); 169 QWSServer::setScreenSaverInterval( 0 );
170 else 170 else
171 QWSServer::setScreenSaverIntervals( v ); 171 QWSServer::setScreenSaverIntervals( v );
172} 172}
173 173
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp
index 9a86a80..b9fa1e5 100644
--- a/core/launcher/server.cpp
+++ b/core/launcher/server.cpp
@@ -27,53 +27,53 @@
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 "shutdownimpl.h" 32#include "shutdownimpl.h"
33#include "applauncher.h" 33#include "applauncher.h"
34#if 0 34#if 0
35#include "suspendmonitor.h" 35#include "suspendmonitor.h"
36#endif 36#endif
37#include "documentlist.h" 37#include "documentlist.h"
38 38
39/* OPIE */
40#include <opie2/odebug.h>
41#include <opie2/odevicebutton.h>
42#include <opie2/odevice.h>
39#include <qtopia/applnk.h> 43#include <qtopia/applnk.h>
40#include <qtopia/private/categories.h> 44#include <qtopia/private/categories.h>
41#include <qtopia/mimetype.h> 45#include <qtopia/mimetype.h>
42#include <qtopia/config.h> 46#include <qtopia/config.h>
43#include <qtopia/resource.h> 47#include <qtopia/resource.h>
44#include <qtopia/version.h> 48#include <qtopia/version.h>
45#include <qtopia/storage.h> 49#include <qtopia/storage.h>
46
47#include <qtopia/qcopenvelope_qws.h> 50#include <qtopia/qcopenvelope_qws.h>
48#include <qwindowsystem_qws.h>
49#include <qgfx_qws.h>
50#include <qtopia/global.h> 51#include <qtopia/global.h>
51//#include <qtopia/custom.h> 52using namespace Opie::Core;
52
53#include <opie2/odevicebutton.h>
54#include <opie2/odevice.h>
55 53
56#include <unistd.h> 54/* QT */
57#include <qmainwindow.h> 55#include <qmainwindow.h>
58#include <qmessagebox.h> 56#include <qmessagebox.h>
59#include <qtimer.h> 57#include <qtimer.h>
60#include <qtextstream.h> 58#include <qtextstream.h>
59#include <qwindowsystem_qws.h>
60#include <qgfx_qws.h>
61 61
62/* STD */
63#include <unistd.h>
62#include <stdlib.h> 64#include <stdlib.h>
63 65
64extern QRect qt_maxWindowRect; 66extern QRect qt_maxWindowRect;
65 67
66
67using namespace Opie::Core;
68static QWidget *calibrate(bool) 68static QWidget *calibrate(bool)
69{ 69{
70#ifdef Q_WS_QWS 70#ifdef Q_WS_QWS
71 Calibrate *c = new Calibrate; 71 Calibrate *c = new Calibrate;
72 c->show(); 72 c->show();
73 return c; 73 return c;
74#else 74#else
75 return 0; 75 return 0;
76#endif 76#endif
77} 77}
78 78
79#define FACTORY(T) \ 79#define FACTORY(T) \
@@ -320,25 +320,25 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data)
320 } 320 }
321 /* ### FIXME support TempScreenSaverMode */ 321 /* ### FIXME support TempScreenSaverMode */
322#if 0 322#if 0
323 else if ( msg == "setTempScreenSaverMode(int,int)" ) { 323 else if ( msg == "setTempScreenSaverMode(int,int)" ) {
324 int mode, pid; 324 int mode, pid;
325 stream >> mode >> pid; 325 stream >> mode >> pid;
326 tsmMonitor->setTempMode(mode, pid); 326 tsmMonitor->setTempMode(mode, pid);
327 } 327 }
328#endif 328#endif
329 else if ( msg == "linkChanged(QString)" ) { 329 else if ( msg == "linkChanged(QString)" ) {
330 QString link; 330 QString link;
331 stream >> link; 331 stream >> link;
332 qDebug( "desktop.cpp systemMsg -> linkchanged( %s )", link.latin1() ); 332 odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl;
333 docList->linkChanged(link); 333 docList->linkChanged(link);
334 } else if ( msg == "serviceChanged(QString)" ) { 334 } else if ( msg == "serviceChanged(QString)" ) {
335 MimeType::updateApplications(); 335 MimeType::updateApplications();
336 } else if ( msg == "mkdir(QString)" ) { 336 } else if ( msg == "mkdir(QString)" ) {
337 QString dir; 337 QString dir;
338 stream >> dir; 338 stream >> dir;
339 if ( !dir.isEmpty() ) 339 if ( !dir.isEmpty() )
340 mkdir( dir ); 340 mkdir( dir );
341 } else if ( msg == "rdiffGenSig(QString,QString)" ) { 341 } else if ( msg == "rdiffGenSig(QString,QString)" ) {
342 QString baseFile, sigFile; 342 QString baseFile, sigFile;
343 stream >> baseFile >> sigFile; 343 stream >> baseFile >> sigFile;
344 QRsync::generateSignature( baseFile, sigFile ); 344 QRsync::generateSignature( baseFile, sigFile );
@@ -425,25 +425,25 @@ void Server::systemMsg(const QCString &msg, const QByteArray &data)
425#ifndef QT_NO_COP 425#ifndef QT_NO_COP
426 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); 426 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" );
427 e << app << cfg.readEntry( app ); 427 e << app << cfg.readEntry( app );
428#endif 428#endif
429 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), 429 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(),
430 //cfg.readEntry( app ).latin1() ); 430 //cfg.readEntry( app ).latin1() );
431 } else if ( msg == "setSyncDate(QString,QString)" ) { 431 } else if ( msg == "setSyncDate(QString,QString)" ) {
432 QString app, date; 432 QString app, date;
433 stream >> app >> date; 433 stream >> app >> date;
434 Config cfg( "qpe" ); 434 Config cfg( "qpe" );
435 cfg.setGroup("SyncDate"); 435 cfg.setGroup("SyncDate");
436 cfg.writeEntry( app, date ); 436 cfg.writeEntry( app, date );
437 //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); 437 //odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl;
438 } else if ( msg == "startSync(QString)" ) { 438 } else if ( msg == "startSync(QString)" ) {
439 QString what; 439 QString what;
440 stream >> what; 440 stream >> what;
441 delete syncDialog; 441 delete syncDialog;
442 syncDialog = new SyncDialog( this, what ); 442 syncDialog = new SyncDialog( this, what );
443 syncDialog->show(); 443 syncDialog->show();
444 connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); 444 connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) );
445 } else if ( msg == "stopSync()") { 445 } else if ( msg == "stopSync()") {
446 delete syncDialog; 446 delete syncDialog;
447 syncDialog = 0; 447 syncDialog = 0;
448 } else if (msg == "restoreDone(QString)") { 448 } else if (msg == "restoreDone(QString)") {
449 docList->restoreDone(); 449 docList->restoreDone();
@@ -563,45 +563,45 @@ bool Server::mkdir(const QString &localPath)
563 return true; 563 return true;
564 564
565 // at this point the directory doesn't exist 565 // at this point the directory doesn't exist
566 // go through the directory tree and start creating the direcotories 566 // go through the directory tree and start creating the direcotories
567 // that don't exist; if we can't create the directories, return false 567 // that don't exist; if we can't create the directories, return false
568 568
569 QString dirSeps = "/"; 569 QString dirSeps = "/";
570 int dirIndex = localPath.find(dirSeps); 570 int dirIndex = localPath.find(dirSeps);
571 QString checkedPath; 571 QString checkedPath;
572 572
573 // didn't find any seps; weird, use the cur dir instead 573 // didn't find any seps; weird, use the cur dir instead
574 if (dirIndex == -1) { 574 if (dirIndex == -1) {
575 //qDebug("No seperators found in path %s", localPath.latin1()); 575 //odebug << "No seperators found in path " << localPath << "" << oendl;
576 checkedPath = QDir::currentDirPath(); 576 checkedPath = QDir::currentDirPath();
577 } 577 }
578 578
579 while (checkedPath != localPath) { 579 while (checkedPath != localPath) {
580 // no more seperators found, use the local path 580 // no more seperators found, use the local path
581 if (dirIndex == -1) 581 if (dirIndex == -1)
582 checkedPath = localPath; 582 checkedPath = localPath;
583 else { 583 else {
584 // the next directory to check 584 // the next directory to check
585 checkedPath = localPath.left(dirIndex) + "/"; 585 checkedPath = localPath.left(dirIndex) + "/";
586 // advance the iterator; the next dir seperator 586 // advance the iterator; the next dir seperator
587 dirIndex = localPath.find(dirSeps, dirIndex+1); 587 dirIndex = localPath.find(dirSeps, dirIndex+1);
588 } 588 }
589 589
590 QDir checkDir(checkedPath); 590 QDir checkDir(checkedPath);
591 if (!checkDir.exists()) { 591 if (!checkDir.exists()) {
592 //qDebug("mkdir making dir %s", checkedPath.latin1()); 592 //odebug << "mkdir making dir " << checkedPath << "" << oendl;
593 593
594 if (!checkDir.mkdir(checkedPath)) { 594 if (!checkDir.mkdir(checkedPath)) {
595 qDebug("Unable to make directory %s", checkedPath.latin1()); 595 odebug << "Unable to make directory " << checkedPath << "" << oendl;
596 return FALSE; 596 return FALSE;
597 } 597 }
598 } 598 }
599 599
600 } 600 }
601 return TRUE; 601 return TRUE;
602} 602}
603 603
604void Server::styleChange( QStyle &s ) 604void Server::styleChange( QStyle &s )
605{ 605{
606 QWidget::styleChange( s ); 606 QWidget::styleChange( s );
607} 607}
@@ -661,25 +661,25 @@ void Server::timerEvent( QTimerEvent *e )
661} 661}
662 662
663void Server::terminateServers() 663void Server::terminateServers()
664{ 664{
665 delete transferServer; 665 delete transferServer;
666 delete qcopBridge; 666 delete qcopBridge;
667 transferServer = 0; 667 transferServer = 0;
668 qcopBridge = 0; 668 qcopBridge = 0;
669} 669}
670 670
671void Server::syncConnectionClosed( const QHostAddress & ) 671void Server::syncConnectionClosed( const QHostAddress & )
672{ 672{
673 qDebug( "Lost sync connection" ); 673 odebug << "Lost sync connection" << oendl;
674 delete syncDialog; 674 delete syncDialog;
675 syncDialog = 0; 675 syncDialog = 0;
676} 676}
677 677
678void Server::pokeTimeMonitors() 678void Server::pokeTimeMonitors()
679{ 679{
680#if 0 680#if 0
681 // inform all TimeMonitors 681 // inform all TimeMonitors
682 QStrList tms = Service::channels("TimeMonitor"); 682 QStrList tms = Service::channels("TimeMonitor");
683 for (const char* ch = tms.first(); ch; ch=tms.next()) { 683 for (const char* ch = tms.first(); ch; ch=tms.next()) {
684 QString t = getenv("TZ"); 684 QString t = getenv("TZ");
685 QCopEnvelope e(ch, "timeChange(QString)"); 685 QCopEnvelope e(ch, "timeChange(QString)");
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp
index e4e16f2..cf543ce 100644
--- a/core/launcher/serverapp.cpp
+++ b/core/launcher/serverapp.cpp
@@ -10,61 +10,61 @@
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#include "screensaver.h"
22 23
24/* OPIE */
25#include <opie2/odebug.h>
23#include <opie2/odevice.h> 26#include <opie2/odevice.h>
24
25#include <qtopia/password.h> 27#include <qtopia/password.h>
26#include <qtopia/config.h> 28#include <qtopia/config.h>
27#include <qtopia/power.h> 29#include <qtopia/power.h>
28 30
29#ifdef Q_WS_QWS 31#ifdef Q_WS_QWS
30#include <qtopia/qcopenvelope_qws.h> 32#include <qtopia/qcopenvelope_qws.h>
31#endif 33#endif
32#include <qtopia/global.h> 34#include <qtopia/global.h>
33//#include <qtopia/custom.h> 35using namespace Opie::Core;
34 36
37/* QT */
35#ifdef Q_WS_QWS 38#ifdef Q_WS_QWS
36#include <qgfx_qws.h> 39#include <qgfx_qws.h>
37#endif 40#endif
38#ifdef Q_OS_WIN32
39#include <io.h>
40#include <process.h>
41#else
42#include <unistd.h>
43#endif
44#include <qmessagebox.h> 41#include <qmessagebox.h>
45#include <qtimer.h> 42#include <qtimer.h>
46#include <qpainter.h> 43#include <qpainter.h>
47#include <qfile.h> 44#include <qfile.h>
48#include <qpixmapcache.h> 45#include <qpixmapcache.h>
49 46
47/* STD */
48#ifdef Q_OS_WIN32
49#include <io.h>
50#include <process.h>
51#else
52#include <unistd.h>
53#endif
50#include <stdlib.h> 54#include <stdlib.h>
51#include "screensaver.h"
52 55
53static ServerApplication *serverApp = 0; 56static ServerApplication *serverApp = 0;
54static int loggedin=0; 57static int loggedin=0;
55 58
56using namespace Opie;
57
58using namespace Opie::Core;
59QCopKeyRegister::QCopKeyRegister() 59QCopKeyRegister::QCopKeyRegister()
60 : m_keyCode( 0 ) { 60 : m_keyCode( 0 ) {
61} 61}
62 62
63QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m ) 63QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m )
64 :m_keyCode( k ), m_channel( c ), m_message( m ) { 64 :m_keyCode( k ), m_channel( c ), m_message( m ) {
65} 65}
66 66
67int QCopKeyRegister::keyCode()const { 67int QCopKeyRegister::keyCode()const {
68 return m_keyCode; 68 return m_keyCode;
69} 69}
70 70
@@ -847,17 +847,17 @@ ServerApplication *ServerApplication::me ( )
847{ 847{
848 return static_cast<ServerApplication*>( qApp ); 848 return static_cast<ServerApplication*>( qApp );
849} 849}
850 850
851bool ServerApplication::isStarting() 851bool ServerApplication::isStarting()
852{ 852{
853 return ms_is_starting; 853 return ms_is_starting;
854} 854}
855 855
856int ServerApplication::exec() 856int ServerApplication::exec()
857{ 857{
858 ms_is_starting = true; 858 ms_is_starting = true;
859 qDebug("Serverapp - exec"); 859 odebug << "Serverapp - exec" << oendl;
860 return QPEApplication::exec(); 860 return QPEApplication::exec();
861} 861}
862 862
863#include "serverapp.moc" 863#include "serverapp.moc"
diff --git a/core/launcher/suspendmonitor.cpp b/core/launcher/suspendmonitor.cpp
index f555e84..50bc56f 100644
--- a/core/launcher/suspendmonitor.cpp
+++ b/core/launcher/suspendmonitor.cpp
@@ -41,25 +41,25 @@ void TempScreenSaverMonitor::setTempMode(int mode, int pid)
41 case QPEApplication::Disable: 41 case QPEApplication::Disable:
42 sStatus[0].append(pid); 42 sStatus[0].append(pid);
43 break; 43 break;
44 case QPEApplication::DisableLightOff: 44 case QPEApplication::DisableLightOff:
45 sStatus[1].append(pid); 45 sStatus[1].append(pid);
46 break; 46 break;
47 case QPEApplication::DisableSuspend: 47 case QPEApplication::DisableSuspend:
48 sStatus[2].append(pid); 48 sStatus[2].append(pid);
49 break; 49 break;
50 case QPEApplication::Enable: 50 case QPEApplication::Enable:
51 break; 51 break;
52 default: 52 default:
53 qWarning("Unrecognized temp power setting. Ignored"); 53 owarn << "Unrecognized temp power setting. Ignored" << oendl;
54 return; 54 return;
55 } 55 }
56 updateAll(); 56 updateAll();
57} 57}
58 58
59// Returns true if app had set a temp Mode earlier 59// Returns true if app had set a temp Mode earlier
60bool TempScreenSaverMonitor::removeOld(int pid) 60bool TempScreenSaverMonitor::removeOld(int pid)
61{ 61{
62 QValueList<int>::Iterator it; 62 QValueList<int>::Iterator it;
63 for (int i = 0; i < 3; i++) { 63 for (int i = 0; i < 3; i++) {
64 it = sStatus[i].find(pid); 64 it = sStatus[i].find(pid);
65 if ( it != sStatus[i].end() ) { 65 if ( it != sStatus[i].end() ) {
diff --git a/core/launcher/systray.cpp b/core/launcher/systray.cpp
index 6cc1446..3c72d25 100644
--- a/core/launcher/systray.cpp
+++ b/core/launcher/systray.cpp
@@ -9,42 +9,40 @@
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 "systray.h"
22
23/* OPIE */
24#include <opie2/odebug.h>
21#include <qtopia/qpeapplication.h> 25#include <qtopia/qpeapplication.h>
22#include <qtopia/qlibrary.h> 26#include <qtopia/qlibrary.h>
23#include <qtopia/config.h> 27#include <qtopia/config.h>
28using namespace Opie::Core;
24 29
30/* QT */
25#include <qlayout.h> 31#include <qlayout.h>
26#include <qdir.h> 32#include <qdir.h>
27 33
28#include "systray.h" 34/* STD */
29
30#include <stdlib.h> 35#include <stdlib.h>
31 36
32/* ### Single build floppies ### */
33#if 0
34#ifdef QT_NO_COMPONENTS
35#include "../plugins/applets/clockapplet/clockappletimpl.h"
36#endif
37#endif
38
39SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0) 37SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0)
40{ 38{
41 //setFrameStyle( QFrame::Panel | QFrame::Sunken ); 39 //setFrameStyle( QFrame::Panel | QFrame::Sunken );
42 loadApplets(); 40 loadApplets();
43} 41}
44 42
45SysTray::~SysTray() 43SysTray::~SysTray()
46{ 44{
47 clearApplets(); 45 clearApplets();
48} 46}
49 47
50static int compareAppletPositions(const void *a, const void *b) 48static int compareAppletPositions(const void *a, const void *b)
@@ -103,25 +101,25 @@ void SysTray::addApplets()
103#ifdef Q_OS_MACX 101#ifdef Q_OS_MACX
104 QDir dir( path, "lib*.dylib" ); 102 QDir dir( path, "lib*.dylib" );
105#else 103#else
106 QDir dir( path, "lib*.so" ); 104 QDir dir( path, "lib*.so" );
107#endif /* Q_OS_MACX */ 105#endif /* Q_OS_MACX */
108 QStringList list = dir.entryList(); 106 QStringList list = dir.entryList();
109 QStringList::Iterator it; 107 QStringList::Iterator it;
110 int napplets=0; 108 int napplets=0;
111 TaskbarApplet* *applets = new TaskbarApplet*[list.count()]; 109 TaskbarApplet* *applets = new TaskbarApplet*[list.count()];
112 for ( it = list.begin(); it != list.end(); ++it ) { 110 for ( it = list.begin(); it != list.end(); ++it ) {
113 if ( exclude.find( *it ) != exclude.end() ) 111 if ( exclude.find( *it ) != exclude.end() )
114 continue; 112 continue;
115 qWarning( "Found Applet: %s", (*it).latin1() ); 113 owarn << "Found Applet: " << (*it) << "" << oendl;
116 TaskbarAppletInterface *iface = 0; 114 TaskbarAppletInterface *iface = 0;
117 QLibrary *lib = new QLibrary( path + "/" + *it ); 115 QLibrary *lib = new QLibrary( path + "/" + *it );
118 if (( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { 116 if (( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) {
119 TaskbarApplet *applet = new TaskbarApplet; 117 TaskbarApplet *applet = new TaskbarApplet;
120 applets[napplets++] = applet; 118 applets[napplets++] = applet;
121 applet->library = lib; 119 applet->library = lib;
122 applet->iface = iface; 120 applet->iface = iface;
123 121
124 QTranslator *trans = new QTranslator(qApp); 122 QTranslator *trans = new QTranslator(qApp);
125 QString type = (*it).left( (*it).find(".") ); 123 QString type = (*it).left( (*it).find(".") );
126 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; 124 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm";
127 if ( trans->load( tfn )) 125 if ( trans->load( tfn ))
diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp
index 91e2f20..86e0d0d 100644
--- a/core/launcher/taskbar.cpp
+++ b/core/launcher/taskbar.cpp
@@ -19,32 +19,35 @@
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/* OPIE */
32#include <opie2/odebug.h>
31#include <qtopia/config.h> 33#include <qtopia/config.h>
32#include <qtopia/qpeapplication.h> 34#include <qtopia/qpeapplication.h>
33#ifdef QWS 35#ifdef QWS
34#include <qtopia/qcopenvelope_qws.h> 36#include <qtopia/qcopenvelope_qws.h>
35#endif 37#endif
36#include <qtopia/global.h> 38#include <qtopia/global.h>
37//#include <qtopia/custom.h> 39using namespace Opie::Core;
38 40
41/* QT */
39#include <qlabel.h> 42#include <qlabel.h>
40#include <qlayout.h> 43#include <qlayout.h>
41#include <qtimer.h> 44#include <qtimer.h>
42#ifdef QWS 45#ifdef QWS
43#include <qwindowsystem_qws.h> 46#include <qwindowsystem_qws.h>
44#endif 47#endif
45#include <qwidgetstack.h> 48#include <qwidgetstack.h>
46 49
47#if defined( Q_WS_QWS ) 50#if defined( Q_WS_QWS )
48#include <qwsdisplay_qws.h> 51#include <qwsdisplay_qws.h>
49#include <qgfx_qws.h> 52#include <qgfx_qws.h>
50#endif 53#endif
@@ -276,25 +279,25 @@ void TaskBar::stopWait()
276 * bounds and repaint() won't trigger an Event 279 * bounds and repaint() won't trigger an Event
277 */ 280 */
278void TaskBar::resizeEvent( QResizeEvent *e ) 281void TaskBar::resizeEvent( QResizeEvent *e )
279{ 282{
280 if ( sysTray ) 283 if ( sysTray )
281 sysTray->hide(); 284 sysTray->hide();
282 285
283 QHBox::resizeEvent( e ); 286 QHBox::resizeEvent( e );
284 287
285 if ( sysTray ) 288 if ( sysTray )
286 sysTray->show(); 289 sysTray->show();
287 290
288 qWarning("TaskBar::resize event"); 291 owarn << "TaskBar::resize event" << oendl;
289} 292}
290 293
291void TaskBar::styleChange( QStyle &s ) 294void TaskBar::styleChange( QStyle &s )
292{ 295{
293 QHBox::styleChange( s ); 296 QHBox::styleChange( s );
294 calcMaxWindowRect(); 297 calcMaxWindowRect();
295} 298}
296 299
297void TaskBar::calcMaxWindowRect() 300void TaskBar::calcMaxWindowRect()
298{ 301{
299 if ( resizeRunningApp ) 302 if ( resizeRunningApp )
300 { 303 {
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp
index e32cf41..4b764e3 100644
--- a/core/launcher/transferserver.cpp
+++ b/core/launcher/transferserver.cpp
@@ -8,74 +8,63 @@
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20//#define _XOPEN_SOURCE 20#include "transferserver.h"
21 21
22/* OPIE */
23#include <opie2/odebug.h>
22#include <opie2/oglobal.h> 24#include <opie2/oglobal.h>
25#include <qtopia/qprocess.h>
26#include <qtopia/process.h>
27#include <qtopia/private/contact.h>
28#include <qtopia/version.h>
29#ifdef Q_WS_QWS
30#include <qtopia/qcopenvelope_qws.h>
31#endif
32using namespace Opie::Core;
23 33
24#ifndef Q_OS_WIN32 34/* QT */
35#include <qtextstream.h>
36#include <qmessagebox.h>
37
38/* STD */
25#include <pwd.h> 39#include <pwd.h>
26#include <sys/types.h> 40#include <sys/types.h>
27#include <unistd.h> 41#include <unistd.h>
28#include <stdlib.h> 42#include <stdlib.h>
29#include <time.h> 43#include <time.h>
30 44
31#ifndef Q_OS_MACX 45#ifndef Q_OS_MACX
32#include <shadow.h> 46#include <shadow.h>
33#include <crypt.h> 47#include <crypt.h>
34#endif /* Q_OS_MACX */ 48#endif /* Q_OS_MACX */
35 49
36#else
37#include <stdlib.h>
38#include <time.h>
39#endif
40
41
42#if defined(_OS_LINUX_)
43#include <shadow.h>
44#endif
45
46#include <qtextstream.h>
47#include <qmessagebox.h>
48//#include <qtopia/qcopchannel_qws.h>
49#include <qtopia/process.h>
50#include <qtopia/private/contact.h>
51#include <qtopia/version.h>
52#ifdef Q_WS_QWS
53#include <qtopia/qcopenvelope_qws.h>
54#endif
55
56
57#include "transferserver.h"
58#include <qtopia/qprocess.h>
59
60const int block_size = 51200; 50const int block_size = 51200;
61 51
62using namespace Opie::Core;
63TransferServer::TransferServer( Q_UINT16 port, QObject *parent, 52TransferServer::TransferServer( Q_UINT16 port, QObject *parent,
64 const char* name) 53 const char* name)
65 : QServerSocket( port, 1, parent, name ) 54 : QServerSocket( port, 1, parent, name )
66{ 55{
67 connections.setAutoDelete( TRUE ); 56 connections.setAutoDelete( TRUE );
68 if ( !ok() ) 57 if ( !ok() )
69 qWarning( "Failed to bind to port %d", port ); 58 owarn << "Failed to bind to port " << port << "" << oendl;
70} 59}
71 60
72void TransferServer::authorizeConnections() 61void TransferServer::authorizeConnections()
73{ 62{
74 QListIterator<ServerPI> it(connections); 63 QListIterator<ServerPI> it(connections);
75 while ( it.current() ) { 64 while ( it.current() ) {
76 if ( !it.current()->verifyAuthorised() ) { 65 if ( !it.current()->verifyAuthorised() ) {
77 disconnect( it.current(), SIGNAL(connectionClosed(ServerPI*)), this, SLOT( closed(ServerPI*)) ); 66 disconnect( it.current(), SIGNAL(connectionClosed(ServerPI*)), this, SLOT( closed(ServerPI*)) );
78 connections.removeRef( it.current() ); 67 connections.removeRef( it.current() );
79 } else 68 } else
80 ++it; 69 ++it;
81 } 70 }
@@ -362,33 +351,33 @@ ServerPI::~ServerPI()
362 351
363bool ServerPI::verifyAuthorised() 352bool ServerPI::verifyAuthorised()
364{ 353{
365 if ( !SyncAuthentication::isAuthorized(peerAddress()) ) { 354 if ( !SyncAuthentication::isAuthorized(peerAddress()) ) {
366 state = Forbidden; 355 state = Forbidden;
367 return FALSE; 356 return FALSE;
368 } 357 }
369 return TRUE; 358 return TRUE;
370} 359}
371 360
372void ServerPI::connectionClosed() 361void ServerPI::connectionClosed()
373{ 362{
374 // qDebug( "Debug: Connection closed" ); 363 // odebug << "Debug: Connection closed" << oendl;
375 emit connectionClosed(this); 364 emit connectionClosed(this);
376} 365}
377 366
378void ServerPI::send( const QString& msg ) 367void ServerPI::send( const QString& msg )
379{ 368{
380 QTextStream os( this ); 369 QTextStream os( this );
381 os << msg << endl; 370 os << msg << endl;
382 //qDebug( "Reply: %s", msg.latin1() ); 371 //odebug << "Reply: " << msg << "" << oendl;
383} 372}
384 373
385void ServerPI::read() 374void ServerPI::read()
386{ 375{
387 while ( canReadLine() ) 376 while ( canReadLine() )
388 process( readLine().stripWhiteSpace() ); 377 process( readLine().stripWhiteSpace() );
389} 378}
390 379
391bool ServerPI::checkReadFile( const QString& file ) 380bool ServerPI::checkReadFile( const QString& file )
392{ 381{
393 QString filename; 382 QString filename;
394 383
@@ -411,49 +400,49 @@ bool ServerPI::checkWriteFile( const QString& file )
411 filename = file; 400 filename = file;
412 401
413 QFileInfo fi( filename ); 402 QFileInfo fi( filename );
414 403
415 if ( fi.exists() ) 404 if ( fi.exists() )
416 if ( !QFile( filename ).remove() ) 405 if ( !QFile( filename ).remove() )
417 return FALSE; 406 return FALSE;
418 return TRUE; 407 return TRUE;
419} 408}
420 409
421void ServerPI::process( const QString& message ) 410void ServerPI::process( const QString& message )
422{ 411{
423 //qDebug( "Command: %s", message.latin1() ); 412 //odebug << "Command: " << message << "" << oendl;
424 413
425 // split message using "," as separator 414 // split message using "," as separator
426 QStringList msg = QStringList::split( " ", message ); 415 QStringList msg = QStringList::split( " ", message );
427 if ( msg.isEmpty() ) return; 416 if ( msg.isEmpty() ) return;
428 417
429 // command token 418 // command token
430 QString cmd = msg[0].upper(); 419 QString cmd = msg[0].upper();
431 420
432 // argument token 421 // argument token
433 QString arg; 422 QString arg;
434 if ( msg.count() >= 2 ) 423 if ( msg.count() >= 2 )
435 arg = msg[1]; 424 arg = msg[1];
436 425
437 // full argument string 426 // full argument string
438 QString args; 427 QString args;
439 if ( msg.count() >= 2 ) { 428 if ( msg.count() >= 2 ) {
440 QStringList copy( msg ); 429 QStringList copy( msg );
441 // FIXME: for Qt3 430 // FIXME: for Qt3
442 // copy.pop_front() 431 // copy.pop_front()
443 copy.remove( copy.begin() ); 432 copy.remove( copy.begin() );
444 args = copy.join( " " ); 433 args = copy.join( " " );
445 } 434 }
446 435
447 //qDebug( "args: %s", args.latin1() ); 436 //odebug << "args: " << args << "" << oendl;
448 437
449 // we always respond to QUIT, regardless of state 438 // we always respond to QUIT, regardless of state
450 if ( cmd == "QUIT" ) { 439 if ( cmd == "QUIT" ) {
451 send( "211 Good bye!" ); // No tr 440 send( "211 Good bye!" ); // No tr
452 close(); 441 close();
453 return; 442 return;
454 } 443 }
455 444
456 // connected to client 445 // connected to client
457 if ( Connected == state ) 446 if ( Connected == state )
458 return; 447 return;
459 448
@@ -574,25 +563,25 @@ void ServerPI::process( const QString& message )
574 563
575 // FTP SERVICE COMMANDS 564 // FTP SERVICE COMMANDS
576 565
577 566
578 // retrieve (RETR) 567 // retrieve (RETR)
579 else if ( cmd == "RETR" ) 568 else if ( cmd == "RETR" )
580 if ( !args.isEmpty() && checkReadFile( absFilePath( args ) ) 569 if ( !args.isEmpty() && checkReadFile( absFilePath( args ) )
581 || backupRestoreGzip( absFilePath( args ) ) ) { 570 || backupRestoreGzip( absFilePath( args ) ) ) {
582 send( "150 File status okay" ); // No tr 571 send( "150 File status okay" ); // No tr
583 sendFile( absFilePath( args ) ); 572 sendFile( absFilePath( args ) );
584 } 573 }
585 else { 574 else {
586 qDebug("550 Requested action not taken"); 575 odebug << "550 Requested action not taken" << oendl;
587 send( "550 Requested action not taken" ); // No tr 576 send( "550 Requested action not taken" ); // No tr
588 } 577 }
589 578
590 // store (STOR) 579 // store (STOR)
591 else if ( cmd == "STOR" ) 580 else if ( cmd == "STOR" )
592 if ( !args.isEmpty() && checkWriteFile( absFilePath( args ) ) ) { 581 if ( !args.isEmpty() && checkWriteFile( absFilePath( args ) ) ) {
593 send( "150 File status okay" ); // No tr 582 send( "150 File status okay" ); // No tr
594 retrieveFile( absFilePath( args ) ); 583 retrieveFile( absFilePath( args ) );
595 } 584 }
596 else 585 else
597 send( "550 Requested action not taken" ); // No tr 586 send( "550 Requested action not taken" ); // No tr
598 587
@@ -680,25 +669,25 @@ void ServerPI::process( const QString& message )
680 else { 669 else {
681 QDir dir; 670 QDir dir;
682 if ( dir.rmdir( absFilePath( args ), TRUE ) ) 671 if ( dir.rmdir( absFilePath( args ), TRUE ) )
683 send( "250 Requested file action okay, completed" ); // No tr 672 send( "250 Requested file action okay, completed" ); // No tr
684 else 673 else
685 send( "550 Requested action not taken" ); // No tr 674 send( "550 Requested action not taken" ); // No tr
686 } 675 }
687 } 676 }
688 677
689 // make directory (MKD) 678 // make directory (MKD)
690 else if ( cmd == "MKD" ) { 679 else if ( cmd == "MKD" ) {
691 if ( args.isEmpty() ) { 680 if ( args.isEmpty() ) {
692 qDebug(" Error: no arg"); 681 odebug << " Error: no arg" << oendl;
693 send( "500 Syntax error, command unrecognized" ); // No tr 682 send( "500 Syntax error, command unrecognized" ); // No tr
694 } 683 }
695 else { 684 else {
696 QDir dir; 685 QDir dir;
697 if ( dir.mkdir( absFilePath( args ), TRUE ) ) 686 if ( dir.mkdir( absFilePath( args ), TRUE ) )
698 send( "250 Requested file action okay, completed." ); // No tr 687 send( "250 Requested file action okay, completed." ); // No tr
699 else 688 else
700 send( "550 Requested action not taken" ); // No tr 689 send( "550 Requested action not taken" ); // No tr
701 } 690 }
702 } 691 }
703 692
704 // print working directory (PWD) 693 // print working directory (PWD)
@@ -720,33 +709,33 @@ void ServerPI::process( const QString& message )
720 QFileInfo fi( filePath ); 709 QFileInfo fi( filePath );
721 bool gzipfile = backupRestoreGzip( filePath ); 710 bool gzipfile = backupRestoreGzip( filePath );
722 if ( !fi.exists() && !gzipfile ) 711 if ( !fi.exists() && !gzipfile )
723 send( "500 Syntax error, command unrecognized" ); // No tr 712 send( "500 Syntax error, command unrecognized" ); // No tr
724 else { 713 else {
725 if ( !gzipfile ) 714 if ( !gzipfile )
726 send( "213 " + QString::number( fi.size() ) ); 715 send( "213 " + QString::number( fi.size() ) );
727 else { 716 else {
728 Process duproc( QString("du") ); 717 Process duproc( QString("du") );
729 duproc.addArgument("-s"); 718 duproc.addArgument("-s");
730 QString in, out; 719 QString in, out;
731 if ( !duproc.exec(in, out) ) { 720 if ( !duproc.exec(in, out) ) {
732 qDebug("du process failed; just sending back 1K"); 721 odebug << "du process failed; just sending back 1K" << oendl;
733 send( "213 1024"); 722 send( "213 1024");
734 } 723 }
735 else { 724 else {
736 QString size = out.left( out.find("\t") ); 725 QString size = out.left( out.find("\t") );
737 int guess = size.toInt()/5; 726 int guess = size.toInt()/5;
738 if ( filePath.contains("doc") ) // No tr 727 if ( filePath.contains("doc") ) // No tr
739 guess *= 1000; 728 guess *= 1000;
740 qDebug("sending back gzip guess of %d", guess); 729 odebug << "sending back gzip guess of " << guess << "" << oendl;
741 send( "213 " + QString::number(guess) ); 730 send( "213 " + QString::number(guess) );
742 } 731 }
743 } 732 }
744 } 733 }
745 } 734 }
746 // name list (NLST) 735 // name list (NLST)
747 else if ( cmd == "NLST" ) { 736 else if ( cmd == "NLST" ) {
748 send( "502 Command not implemented" ); // No tr 737 send( "502 Command not implemented" ); // No tr
749 } 738 }
750 739
751 // site parameters (SITE) 740 // site parameters (SITE)
752 else if ( cmd == "SITE" ) { 741 else if ( cmd == "SITE" ) {
@@ -1017,50 +1006,50 @@ QString ServerPI::permissionString( QFileInfo *info )
1017 if ( info->permission( QFileInfo::ReadOther ) ) s += "r"; 1006 if ( info->permission( QFileInfo::ReadOther ) ) s += "r";
1018 else s += "-"; 1007 else s += "-";
1019 if ( info->permission( QFileInfo::WriteOther ) ) s += "w"; 1008 if ( info->permission( QFileInfo::WriteOther ) ) s += "w";
1020 else s += "-"; 1009 else s += "-";
1021 if ( info->permission( QFileInfo::ExeOther ) ) s += "x"; 1010 if ( info->permission( QFileInfo::ExeOther ) ) s += "x";
1022 else s += "-"; 1011 else s += "-";
1023 1012
1024 return s; 1013 return s;
1025} 1014}
1026 1015
1027void ServerPI::newConnection( int socket ) 1016void ServerPI::newConnection( int socket )
1028{ 1017{
1029 //qDebug( "New incomming connection" ); 1018 //odebug << "New incomming connection" << oendl;
1030 1019
1031 if ( !passiv ) return; 1020 if ( !passiv ) return;
1032 1021
1033 if ( wait[SendFile] ) { 1022 if ( wait[SendFile] ) {
1034 QStringList targets; 1023 QStringList targets;
1035 if ( backupRestoreGzip( waitfile, targets ) ) 1024 if ( backupRestoreGzip( waitfile, targets ) )
1036 dtp->sendGzipFile( waitfile, targets ); 1025 dtp->sendGzipFile( waitfile, targets );
1037 else 1026 else
1038 dtp->sendFile( waitfile ); 1027 dtp->sendFile( waitfile );
1039 dtp->setSocket( socket ); 1028 dtp->setSocket( socket );
1040 } 1029 }
1041 else if ( wait[RetrieveFile] ) { 1030 else if ( wait[RetrieveFile] ) {
1042 qDebug("check retrieve file"); 1031 odebug << "check retrieve file" << oendl;
1043 if ( backupRestoreGzip( waitfile ) ) 1032 if ( backupRestoreGzip( waitfile ) )
1044 dtp->retrieveGzipFile( waitfile ); 1033 dtp->retrieveGzipFile( waitfile );
1045 else 1034 else
1046 dtp->retrieveFile( waitfile, storFileSize ); 1035 dtp->retrieveFile( waitfile, storFileSize );
1047 dtp->setSocket( socket ); 1036 dtp->setSocket( socket );
1048 } 1037 }
1049 else if ( wait[SendByteArray] ) { 1038 else if ( wait[SendByteArray] ) {
1050 dtp->sendByteArray( waitarray ); 1039 dtp->sendByteArray( waitarray );
1051 dtp->setSocket( socket ); 1040 dtp->setSocket( socket );
1052 } 1041 }
1053 else if ( wait[RetrieveByteArray] ) { 1042 else if ( wait[RetrieveByteArray] ) {
1054 qDebug("retrieve byte array"); 1043 odebug << "retrieve byte array" << oendl;
1055 dtp->retrieveByteArray(); 1044 dtp->retrieveByteArray();
1056 dtp->setSocket( socket ); 1045 dtp->setSocket( socket );
1057 } 1046 }
1058 else 1047 else
1059 waitsocket = socket; 1048 waitsocket = socket;
1060 1049
1061 for( int i = 0; i < 4; i++ ) 1050 for( int i = 0; i < 4; i++ )
1062 wait[i] = FALSE; 1051 wait[i] = FALSE;
1063} 1052}
1064 1053
1065QString ServerPI::absFilePath( const QString& file ) 1054QString ServerPI::absFilePath( const QString& file )
1066{ 1055{
@@ -1102,247 +1091,247 @@ ServerDTP::ServerDTP( QObject *parent, const char* name)
1102 SIGNAL( completed() ) ); 1091 SIGNAL( completed() ) );
1103 connect( retrieveTargzProc, SIGNAL( processExited() ), 1092 connect( retrieveTargzProc, SIGNAL( processExited() ),
1104 SLOT( extractTarDone() ) ); 1093 SLOT( extractTarDone() ) );
1105} 1094}
1106 1095
1107ServerDTP::~ServerDTP() 1096ServerDTP::~ServerDTP()
1108{ 1097{
1109 buf.close(); 1098 buf.close();
1110 if ( RetrieveFile == mode && file.isOpen() ) { 1099 if ( RetrieveFile == mode && file.isOpen() ) {
1111 // We're being shutdown before the client closed. 1100 // We're being shutdown before the client closed.
1112 file.close(); 1101 file.close();
1113 if ( recvFileSize >= 0 && (int)file.size() != recvFileSize ) { 1102 if ( recvFileSize >= 0 && (int)file.size() != recvFileSize ) {
1114 qDebug( "STOR incomplete" ); 1103 odebug << "STOR incomplete" << oendl;
1115 file.remove(); 1104 file.remove();
1116 } 1105 }
1117 } else { 1106 } else {
1118 file.close(); 1107 file.close();
1119 } 1108 }
1120 createTargzProc->kill(); 1109 createTargzProc->kill();
1121} 1110}
1122 1111
1123void ServerDTP::extractTarDone() 1112void ServerDTP::extractTarDone()
1124{ 1113{
1125 qDebug("extract done"); 1114 odebug << "extract done" << oendl;
1126#ifndef QT_NO_COP 1115#ifndef QT_NO_COP
1127 QCopEnvelope e( "QPE/System", "restoreDone(QString)" ); 1116 QCopEnvelope e( "QPE/System", "restoreDone(QString)" );
1128 e << file.name(); 1117 e << file.name();
1129#endif 1118#endif
1130} 1119}
1131 1120
1132void ServerDTP::connected() 1121void ServerDTP::connected()
1133{ 1122{
1134 // send file mode 1123 // send file mode
1135 switch ( mode ) { 1124 switch ( mode ) {
1136 case SendFile : 1125 case SendFile :
1137 if ( !file.exists() || !file.open( IO_ReadOnly) ) { 1126 if ( !file.exists() || !file.open( IO_ReadOnly) ) {
1138 emit failed(); 1127 emit failed();
1139 mode = Idle; 1128 mode = Idle;
1140 return; 1129 return;
1141 } 1130 }
1142 1131
1143 //qDebug( "Debug: Sending file '%s'", file.name().latin1() ); 1132 //odebug << "Debug: Sending file '" << file.name() << "'" << oendl;
1144 1133
1145 bytes_written = 0; 1134 bytes_written = 0;
1146 if ( file.size() == 0 ) { 1135 if ( file.size() == 0 ) {
1147 //make sure it doesn't hang on empty files 1136 //make sure it doesn't hang on empty files
1148 file.close(); 1137 file.close();
1149 emit completed(); 1138 emit completed();
1150 mode = Idle; 1139 mode = Idle;
1151 } else { 1140 } else {
1152 // Don't write more if there is plenty buffered already. 1141 // Don't write more if there is plenty buffered already.
1153 if ( bytesToWrite() <= block_size && !file.atEnd() ) { 1142 if ( bytesToWrite() <= block_size && !file.atEnd() ) {
1154 QCString s; 1143 QCString s;
1155 s.resize( block_size ); 1144 s.resize( block_size );
1156 int bytes = file.readBlock( s.data(), block_size ); 1145 int bytes = file.readBlock( s.data(), block_size );
1157 writeBlock( s.data(), bytes ); 1146 writeBlock( s.data(), bytes );
1158 } 1147 }
1159 } 1148 }
1160 break; 1149 break;
1161 case SendGzipFile: 1150 case SendGzipFile:
1162 if ( createTargzProc->isRunning() ) { 1151 if ( createTargzProc->isRunning() ) {
1163 // SHOULDN'T GET HERE, BUT DOING A SAFETY CHECK ANYWAY 1152 // SHOULDN'T GET HERE, BUT DOING A SAFETY CHECK ANYWAY
1164 qWarning("Previous tar --gzip process is still running; killing it..."); 1153 owarn << "Previous tar --gzip process is still running; killing it..." << oendl;
1165 createTargzProc->kill(); 1154 createTargzProc->kill();
1166 } 1155 }
1167 1156
1168 bytes_written = 0; 1157 bytes_written = 0;
1169 qDebug("==>start send tar process"); 1158 odebug << "==>start send tar process" << oendl;
1170 if ( !createTargzProc->start() ) 1159 if ( !createTargzProc->start() )
1171 qWarning("Error starting %s", 1160 qWarning("Error starting %s",
1172 createTargzProc->arguments().join(" ").latin1()); 1161 createTargzProc->arguments().join(" ").latin1());
1173 break; 1162 break;
1174 case SendBuffer: 1163 case SendBuffer:
1175 if ( !buf.open( IO_ReadOnly) ) { 1164 if ( !buf.open( IO_ReadOnly) ) {
1176 emit failed(); 1165 emit failed();
1177 mode = Idle; 1166 mode = Idle;
1178 return; 1167 return;
1179 } 1168 }
1180 1169
1181 // qDebug( "Debug: Sending byte array" ); 1170 // odebug << "Debug: Sending byte array" << oendl;
1182 bytes_written = 0; 1171 bytes_written = 0;
1183 while( !buf.atEnd() ) 1172 while( !buf.atEnd() )
1184 putch( buf.getch() ); 1173 putch( buf.getch() );
1185 buf.close(); 1174 buf.close();
1186 break; 1175 break;
1187 case RetrieveFile: 1176 case RetrieveFile:
1188 // retrieve file mode 1177 // retrieve file mode
1189 if ( file.exists() && !file.remove() ) { 1178 if ( file.exists() && !file.remove() ) {
1190 emit failed(); 1179 emit failed();
1191 mode = Idle; 1180 mode = Idle;
1192 return; 1181 return;
1193 } 1182 }
1194 1183
1195 if ( !file.open( IO_WriteOnly) ) { 1184 if ( !file.open( IO_WriteOnly) ) {
1196 emit failed(); 1185 emit failed();
1197 mode = Idle; 1186 mode = Idle;
1198 return; 1187 return;
1199 } 1188 }
1200 // qDebug( "Debug: Retrieving file %s", file.name().latin1() ); 1189 // odebug << "Debug: Retrieving file " << file.name() << "" << oendl;
1201 break; 1190 break;
1202 case RetrieveGzipFile: 1191 case RetrieveGzipFile:
1203 qDebug("=-> starting tar process to receive .tgz file"); 1192 odebug << "=-> starting tar process to receive .tgz file" << oendl;
1204 break; 1193 break;
1205 case RetrieveBuffer: 1194 case RetrieveBuffer:
1206 // retrieve buffer mode 1195 // retrieve buffer mode
1207 if ( !buf.open( IO_WriteOnly) ) { 1196 if ( !buf.open( IO_WriteOnly) ) {
1208 emit failed(); 1197 emit failed();
1209 mode = Idle; 1198 mode = Idle;
1210 return; 1199 return;
1211 } 1200 }
1212 // qDebug( "Debug: Retrieving byte array" ); 1201 // odebug << "Debug: Retrieving byte array" << oendl;
1213 break; 1202 break;
1214 case Idle: 1203 case Idle:
1215 qDebug("connection established but mode set to Idle; BUG!"); 1204 odebug << "connection established but mode set to Idle; BUG!" << oendl;
1216 break; 1205 break;
1217 } 1206 }
1218} 1207}
1219 1208
1220void ServerDTP::connectionClosed() 1209void ServerDTP::connectionClosed()
1221{ 1210{
1222 //qDebug( "Debug: Data connection closed %ld bytes written", bytes_written ); 1211 //odebug << "Debug: Data connection closed " << bytes_written << " bytes written" << oendl;
1223 1212
1224 // send file mode 1213 // send file mode
1225 if ( SendFile == mode ) { 1214 if ( SendFile == mode ) {
1226 if ( bytes_written == file.size() ) 1215 if ( bytes_written == file.size() )
1227 emit completed(); 1216 emit completed();
1228 else 1217 else
1229 emit failed(); 1218 emit failed();
1230 } 1219 }
1231 1220
1232 // send buffer mode 1221 // send buffer mode
1233 else if ( SendBuffer == mode ) { 1222 else if ( SendBuffer == mode ) {
1234 if ( bytes_written == buf.size() ) 1223 if ( bytes_written == buf.size() )
1235 emit completed(); 1224 emit completed();
1236 else 1225 else
1237 emit failed(); 1226 emit failed();
1238 } 1227 }
1239 1228
1240 // retrieve file mode 1229 // retrieve file mode
1241 else if ( RetrieveFile == mode ) { 1230 else if ( RetrieveFile == mode ) {
1242 file.close(); 1231 file.close();
1243 if ( recvFileSize >= 0 && (int)file.size() != recvFileSize ) { 1232 if ( recvFileSize >= 0 && (int)file.size() != recvFileSize ) {
1244 qDebug( "STOR incomplete" ); 1233 odebug << "STOR incomplete" << oendl;
1245 file.remove(); 1234 file.remove();
1246 emit failed(); 1235 emit failed();
1247 } else { 1236 } else {
1248 emit completed(); 1237 emit completed();
1249 } 1238 }
1250 } 1239 }
1251 1240
1252 else if ( RetrieveGzipFile == mode ) { 1241 else if ( RetrieveGzipFile == mode ) {
1253 qDebug("Done writing ungzip file; closing input"); 1242 odebug << "Done writing ungzip file; closing input" << oendl;
1254 retrieveTargzProc->flushStdin(); 1243 retrieveTargzProc->flushStdin();
1255 retrieveTargzProc->closeStdin(); 1244 retrieveTargzProc->closeStdin();
1256 } 1245 }
1257 1246
1258 // retrieve buffer mode 1247 // retrieve buffer mode
1259 else if ( RetrieveBuffer == mode ) { 1248 else if ( RetrieveBuffer == mode ) {
1260 buf.close(); 1249 buf.close();
1261 emit completed(); 1250 emit completed();
1262 } 1251 }
1263 1252
1264 mode = Idle; 1253 mode = Idle;
1265} 1254}
1266 1255
1267void ServerDTP::bytesWritten( int bytes ) 1256void ServerDTP::bytesWritten( int bytes )
1268{ 1257{
1269 bytes_written += bytes; 1258 bytes_written += bytes;
1270 1259
1271 // send file mode 1260 // send file mode
1272 if ( SendFile == mode ) { 1261 if ( SendFile == mode ) {
1273 1262
1274 if ( bytes_written == file.size() ) { 1263 if ( bytes_written == file.size() ) {
1275 // qDebug( "Debug: Sending complete: %d bytes", file.size() ); 1264 // odebug << "Debug: Sending complete: " << file.size() << " bytes" << oendl;
1276 file.close(); 1265 file.close();
1277 emit completed(); 1266 emit completed();
1278 mode = Idle; 1267 mode = Idle;
1279 } 1268 }
1280 else if( !file.atEnd() ) { 1269 else if( !file.atEnd() ) {
1281 QCString s; 1270 QCString s;
1282 s.resize( block_size ); 1271 s.resize( block_size );
1283 int bytes = file.readBlock( s.data(), block_size ); 1272 int bytes = file.readBlock( s.data(), block_size );
1284 writeBlock( s.data(), bytes ); 1273 writeBlock( s.data(), bytes );
1285 } 1274 }
1286 } 1275 }
1287 1276
1288 // send buffer mode 1277 // send buffer mode
1289 if ( SendBuffer == mode ) { 1278 if ( SendBuffer == mode ) {
1290 1279
1291 if ( bytes_written == buf.size() ) { 1280 if ( bytes_written == buf.size() ) {
1292 // qDebug( "Debug: Sending complete: %d bytes", buf.size() ); 1281 // odebug << "Debug: Sending complete: " << buf.size() << " bytes" << oendl;
1293 emit completed(); 1282 emit completed();
1294 mode = Idle; 1283 mode = Idle;
1295 } 1284 }
1296 } 1285 }
1297} 1286}
1298 1287
1299void ServerDTP::readyRead() 1288void ServerDTP::readyRead()
1300{ 1289{
1301 // retrieve file mode 1290 // retrieve file mode
1302 if ( RetrieveFile == mode ) { 1291 if ( RetrieveFile == mode ) {
1303 QCString s; 1292 QCString s;
1304 s.resize( bytesAvailable() ); 1293 s.resize( bytesAvailable() );
1305 readBlock( s.data(), bytesAvailable() ); 1294 readBlock( s.data(), bytesAvailable() );
1306 file.writeBlock( s.data(), s.size() ); 1295 file.writeBlock( s.data(), s.size() );
1307 } 1296 }
1308 else if ( RetrieveGzipFile == mode ) { 1297 else if ( RetrieveGzipFile == mode ) {
1309 if ( !retrieveTargzProc->isRunning() ) 1298 if ( !retrieveTargzProc->isRunning() )
1310 retrieveTargzProc->start(); 1299 retrieveTargzProc->start();
1311 1300
1312 QByteArray s; 1301 QByteArray s;
1313 s.resize( bytesAvailable() ); 1302 s.resize( bytesAvailable() );
1314 readBlock( s.data(), bytesAvailable() ); 1303 readBlock( s.data(), bytesAvailable() );
1315 retrieveTargzProc->writeToStdin( s ); 1304 retrieveTargzProc->writeToStdin( s );
1316 qDebug("wrote %d bytes to ungzip ", s.size() ); 1305 odebug << "wrote " << s.size() << " bytes to ungzip " << oendl;
1317 } 1306 }
1318 // retrieve buffer mode 1307 // retrieve buffer mode
1319 else if ( RetrieveBuffer == mode ) { 1308 else if ( RetrieveBuffer == mode ) {
1320 QCString s; 1309 QCString s;
1321 s.resize( bytesAvailable() ); 1310 s.resize( bytesAvailable() );
1322 readBlock( s.data(), bytesAvailable() ); 1311 readBlock( s.data(), bytesAvailable() );
1323 buf.writeBlock( s.data(), s.size() ); 1312 buf.writeBlock( s.data(), s.size() );
1324 } 1313 }
1325} 1314}
1326 1315
1327void ServerDTP::writeTargzBlock() 1316void ServerDTP::writeTargzBlock()
1328{ 1317{
1329 QByteArray block = createTargzProc->readStdout(); 1318 QByteArray block = createTargzProc->readStdout();
1330 writeBlock( block.data(), block.size() ); 1319 writeBlock( block.data(), block.size() );
1331 qDebug("writeTargzBlock %d", block.size()); 1320 odebug << "writeTargzBlock " << block.size() << "" << oendl;
1332} 1321}
1333 1322
1334void ServerDTP::targzDone() 1323void ServerDTP::targzDone()
1335{ 1324{
1336 qDebug("tar and gzip done"); 1325 odebug << "tar and gzip done" << oendl;
1337 emit completed(); 1326 emit completed();
1338 mode = Idle; 1327 mode = Idle;
1339 disconnect( createTargzProc, SIGNAL( readyReadStdout() ), 1328 disconnect( createTargzProc, SIGNAL( readyReadStdout() ),
1340 this, SLOT( writeTargzBlock() ) ); 1329 this, SLOT( writeTargzBlock() ) );
1341} 1330}
1342 1331
1343void ServerDTP::sendFile( const QString fn, const QHostAddress& host, Q_UINT16 port ) 1332void ServerDTP::sendFile( const QString fn, const QHostAddress& host, Q_UINT16 port )
1344{ 1333{
1345 file.setName( fn ); 1334 file.setName( fn );
1346 mode = SendFile; 1335 mode = SendFile;
1347 connectToHost( host.toString(), port ); 1336 connectToHost( host.toString(), port );
1348} 1337}
@@ -1361,48 +1350,48 @@ void ServerDTP::sendGzipFile( const QString &fn,
1361 connectToHost( host.toString(), port ); 1350 connectToHost( host.toString(), port );
1362} 1351}
1363 1352
1364void ServerDTP::sendGzipFile( const QString &fn, 1353void ServerDTP::sendGzipFile( const QString &fn,
1365 const QStringList &archiveTargets ) 1354 const QStringList &archiveTargets )
1366{ 1355{
1367 mode = SendGzipFile; 1356 mode = SendGzipFile;
1368 file.setName( fn ); 1357 file.setName( fn );
1369 1358
1370 QStringList args = "targzip"; 1359 QStringList args = "targzip";
1371 //args += "-cv"; 1360 //args += "-cv";
1372 args += archiveTargets; 1361 args += archiveTargets;
1373 qDebug("sendGzipFile %s", args.join(" ").latin1() ); 1362 odebug << "sendGzipFile " << args.join(" ") << "" << oendl;
1374 createTargzProc->setArguments( args ); 1363 createTargzProc->setArguments( args );
1375 connect( createTargzProc, 1364 connect( createTargzProc,
1376 SIGNAL( readyReadStdout() ), SLOT( writeTargzBlock() ) ); 1365 SIGNAL( readyReadStdout() ), SLOT( writeTargzBlock() ) );
1377} 1366}
1378 1367
1379void ServerDTP::retrieveFile( const QString fn, const QHostAddress& host, Q_UINT16 port, int fileSize ) 1368void ServerDTP::retrieveFile( const QString fn, const QHostAddress& host, Q_UINT16 port, int fileSize )
1380{ 1369{
1381 recvFileSize = fileSize; 1370 recvFileSize = fileSize;
1382 file.setName( fn ); 1371 file.setName( fn );
1383 mode = RetrieveFile; 1372 mode = RetrieveFile;
1384 connectToHost( host.toString(), port ); 1373 connectToHost( host.toString(), port );
1385} 1374}
1386 1375
1387void ServerDTP::retrieveFile( const QString fn, int fileSize ) 1376void ServerDTP::retrieveFile( const QString fn, int fileSize )
1388{ 1377{
1389 recvFileSize = fileSize; 1378 recvFileSize = fileSize;
1390 file.setName( fn ); 1379 file.setName( fn );
1391 mode = RetrieveFile; 1380 mode = RetrieveFile;
1392} 1381}
1393 1382
1394void ServerDTP::retrieveGzipFile( const QString &fn ) 1383void ServerDTP::retrieveGzipFile( const QString &fn )
1395{ 1384{
1396 qDebug("retrieveGzipFile %s", fn.latin1()); 1385 odebug << "retrieveGzipFile " << fn << "" << oendl;
1397 file.setName( fn ); 1386 file.setName( fn );
1398 mode = RetrieveGzipFile; 1387 mode = RetrieveGzipFile;
1399 1388
1400 retrieveTargzProc->setArguments( "targunzip" ); 1389 retrieveTargzProc->setArguments( "targunzip" );
1401 connect( retrieveTargzProc, SIGNAL( processExited() ), 1390 connect( retrieveTargzProc, SIGNAL( processExited() ),
1402 SLOT( extractTarDone() ) ); 1391 SLOT( extractTarDone() ) );
1403} 1392}
1404 1393
1405void ServerDTP::retrieveGzipFile( const QString &fn, const QHostAddress& host, Q_UINT16 port ) 1394void ServerDTP::retrieveGzipFile( const QString &fn, const QHostAddress& host, Q_UINT16 port )
1406{ 1395{
1407 retrieveGzipFile( fn ); 1396 retrieveGzipFile( fn );
1408 connectToHost( host.toString(), port ); 1397 connectToHost( host.toString(), port );