33 files changed, 381 insertions, 56 deletions
diff --git a/core/applets/batteryapplet/batteryapplet.pro b/core/applets/batteryapplet/batteryapplet.pro index c68ceb7..1bc208b 100644 --- a/core/applets/batteryapplet/batteryapplet.pro +++ b/core/applets/batteryapplet/batteryapplet.pro @@ -1,33 +1,33 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt plugin warn_on release HEADERS = battery.h batterystatus.h batteryappletimpl.h SOURCES = battery.cpp batterystatus.cpp batteryappletimpl.cpp TARGET = batteryapplet DESTDIR = $(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += ../$(OPIEDIR)/include .. LIBS += -lqpe -lopie VERSION = 1.0.0 TRANSLATIONS = ../../../i18n/de/libbatteryapplet.ts \ ../../../i18n/nl/libbatteryapplet.ts \ ../../../i18n/da/libbatteryapplet.ts \ ../../../i18n/xx/libbatteryapplet.ts \ ../../../i18n/en/libbatteryapplet.ts \ ../../../i18n/es/libbatteryapplet.ts \ ../../../i18n/fr/libbatteryapplet.ts \ ../../../i18n/hu/libbatteryapplet.ts \ ../../../i18n/ja/libbatteryapplet.ts \ ../../../i18n/ko/libbatteryapplet.ts \ ../../../i18n/no/libbatteryapplet.ts \ ../../../i18n/pl/libbatteryapplet.ts \ ../../../i18n/pt/libbatteryapplet.ts \ ../../../i18n/pt_BR/libbatteryapplet.ts \ ../../../i18n/sl/libbatteryapplet.ts \ ../../../i18n/zh_CN/libbatteryapplet.ts \ ../../../i18n/zh_TW/libbatteryapplet.ts include ( $(OPIEDIR)/include.pro ) target.path = $$prefix/plugins/applets diff --git a/core/applets/cardmon/cardmon.pro b/core/applets/cardmon/cardmon.pro index 3907aa4..75facde 100644 --- a/core/applets/cardmon/cardmon.pro +++ b/core/applets/cardmon/cardmon.pro @@ -1,33 +1,33 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt plugin warn_on release HEADERS = cardmon.h cardmonimpl.h SOURCES = cardmon.cpp cardmonimpl.cpp TARGET = cardmonapplet DESTDIR = $(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include ../launcher LIBS += -lqpe -lopie VERSION = 1.0.0 TRANSLATIONS = ../../../i18n/de/libcardmonapplet.ts \ ../../../i18n/nl/libcardmonapplet.ts \ ../../../i18n/da/libcardmonapplet.ts \ ../../../i18n/xx/libcardmonapplet.ts \ ../../../i18n/en/libcardmonapplet.ts \ ../../../i18n/es/libcardmonapplet.ts \ ../../../i18n/fr/libcardmonapplet.ts \ ../../../i18n/hu/libcardmonapplet.ts \ ../../../i18n/ja/libcardmonapplet.ts \ ../../../i18n/ko/libcardmonapplet.ts \ ../../../i18n/no/libcardmonapplet.ts \ ../../../i18n/pl/libcardmonapplet.ts \ ../../../i18n/pt/libcardmonapplet.ts \ ../../../i18n/pt_BR/libcardmonapplet.ts \ ../../../i18n/sl/libcardmonapplet.ts \ ../../../i18n/zh_CN/libcardmonapplet.ts \ ../../../i18n/zh_TW/libcardmonapplet.ts include ( $(OPIEDIR)/include.pro ) target.path = $$prefix/plugins/applets diff --git a/core/applets/clipboardapplet/clipboardapplet.pro b/core/applets/clipboardapplet/clipboardapplet.pro index 1e9cc4f..358d658 100644 --- a/core/applets/clipboardapplet/clipboardapplet.pro +++ b/core/applets/clipboardapplet/clipboardapplet.pro @@ -1,33 +1,33 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt plugin warn_on release HEADERS = clipboard.h clipboardappletimpl.h SOURCES = clipboard.cpp clipboardappletimpl.cpp TARGET = clipboardapplet DESTDIR = $(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += ../$(OPIEDIR)/include LIBS += -lqpe VERSION = 1.0.0 TRANSLATIONS = ../../../i18n/de/libclipboardapplet.ts \ ../../../i18n/nl/libclipboardapplet.ts \ ../../../i18n/da/libclipboardapplet.ts \ ../../../i18n/xx/libclipboardapplet.ts \ ../../../i18n/en/libclipboardapplet.ts \ ../../../i18n/es/libclipboardapplet.ts \ ../../../i18n/fr/libclipboardapplet.ts \ ../../../i18n/hu/libclipboardapplet.ts \ ../../../i18n/ja/libclipboardapplet.ts \ ../../../i18n/ko/libclipboardapplet.ts \ ../../../i18n/no/libclipboardapplet.ts \ ../../../i18n/pl/libclipboardapplet.ts \ ../../../i18n/pt/libclipboardapplet.ts \ ../../../i18n/pt_BR/libclipboardapplet.ts \ ../../../i18n/sl/libclipboardapplet.ts \ ../../../i18n/zh_CN/libclipboardapplet.ts \ ../../../i18n/zh_TW/libclipboardapplet.ts include ( $(OPIEDIR)/include.pro ) target.path = $$prefix/plugins/applets diff --git a/core/applets/clockapplet/clockapplet.pro b/core/applets/clockapplet/clockapplet.pro index 22c7b55..88092f5 100644 --- a/core/applets/clockapplet/clockapplet.pro +++ b/core/applets/clockapplet/clockapplet.pro @@ -1,33 +1,33 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt plugin warn_on release HEADERS = clock.h clockappletimpl.h SOURCES = clock.cpp clockappletimpl.cpp TARGET = clockapplet DESTDIR = $(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += ../$(OPIEDIR)/include .. LIBS += -lqpe VERSION = 1.0.0 TRANSLATIONS = ../../../i18n/de/libclockapplet.ts \ ../../../i18n/nl/libclockapplet.ts \ ../../../i18n/da/libclockapplet.ts \ ../../../i18n/xx/libclockapplet.ts \ ../../../i18n/en/libclockapplet.ts \ ../../../i18n/es/libclockapplet.ts \ ../../../i18n/fr/libclockapplet.ts \ ../../../i18n/hu/libclockapplet.ts \ ../../../i18n/ja/libclockapplet.ts \ ../../../i18n/ko/libclockapplet.ts \ ../../../i18n/no/libclockapplet.ts \ ../../../i18n/pl/libclockapplet.ts \ ../../../i18n/pt/libclockapplet.ts \ ../../../i18n/pt_BR/libclockapplet.ts \ ../../../i18n/sl/libclockapplet.ts \ ../../../i18n/zh_CN/libclockapplet.ts \ ../../../i18n/zh_TW/libclockapplet.ts include ( $(OPIEDIR)/include.pro ) target.path = $$prefix/plugins/applets diff --git a/core/applets/homeapplet/homeapplet.pro b/core/applets/homeapplet/homeapplet.pro index ac7956b..854050f 100644 --- a/core/applets/homeapplet/homeapplet.pro +++ b/core/applets/homeapplet/homeapplet.pro @@ -1,33 +1,33 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt plugin warn_on release HEADERS = home.h SOURCES = home.cpp TARGET = homeapplet DESTDIR = $(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe VERSION = 1.0.0 TRANSLATIONS = ../../../i18n/de/libhomeapplet.ts \ ../../../i18n/nl/libhomeapplet.ts \ ../../../i18n/da/libhomeapplet.ts \ ../../../i18n/xx/libhomeapplet.ts \ ../../../i18n/en/libhomeapplet.ts \ ../../../i18n/es/libhomeapplet.ts \ ../../../i18n/fr/libhomeapplet.ts \ ../../../i18n/hu/libhomeapplet.ts \ ../../../i18n/ja/libhomeapplet.ts \ ../../../i18n/ko/libhomeapplet.ts \ ../../../i18n/no/libhomeapplet.ts \ ../../../i18n/pl/libhomeapplet.ts \ ../../../i18n/pt/libhomeapplet.ts \ ../../../i18n/pt_BR/libhomeapplet.ts \ ../../../i18n/sl/libhomeapplet.ts \ ../../../i18n/zh_CN/libhomeapplet.ts \ ../../../i18n/zh_TW/libhomeapplet.ts include ( $(OPIEDIR)/include.pro ) target.path = $$prefix/plugins/applets diff --git a/core/applets/irdaapplet/irdaapplet.pro b/core/applets/irdaapplet/irdaapplet.pro index 56632ed..be16bad 100644 --- a/core/applets/irdaapplet/irdaapplet.pro +++ b/core/applets/irdaapplet/irdaapplet.pro @@ -1,33 +1,33 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt plugin warn_on release HEADERS = irda.h irdaappletimpl.h SOURCES = irda.cpp irdaappletimpl.cpp TARGET = irdaapplet DESTDIR = $(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += ../$(OPIEDIR)/include LIBS += -lqpe VERSION = 1.0.0 TRANSLATIONS = ../../../i18n/de/libirdaapplet.ts \ ../../../i18n/nl/libirdaapplet.ts \ ../../../i18n/da/libirdaapplet.ts \ ../../../i18n/xx/libirdaapplet.ts \ ../../../i18n/en/libirdaapplet.ts \ ../../../i18n/es/libirdaapplet.ts \ ../../../i18n/fr/libirdaapplet.ts \ ../../../i18n/hu/libirdaapplet.ts \ ../../../i18n/ja/libirdaapplet.ts \ ../../../i18n/ko/libirdaapplet.ts \ ../../../i18n/no/libirdaapplet.ts \ ../../../i18n/pl/libirdaapplet.ts \ ../../../i18n/pt/libirdaapplet.ts \ ../../../i18n/pt_BR/libirdaapplet.ts \ ../../../i18n/sl/libirdaapplet.ts \ ../../../i18n/zh_CN/libirdaapplet.ts \ ../../../i18n/zh_TW/libirdaapplet.ts include ( $(OPIEDIR)/include.pro ) target.path = $$prefix/plugins/applets diff --git a/core/applets/logoutapplet/logoutapplet.pro b/core/applets/logoutapplet/logoutapplet.pro index a019303..7826bb3 100644 --- a/core/applets/logoutapplet/logoutapplet.pro +++ b/core/applets/logoutapplet/logoutapplet.pro @@ -1,33 +1,33 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt plugin warn_on release HEADERS = logout.h SOURCES = logout.cpp TARGET = logoutapplet DESTDIR = $(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe VERSION = 1.0.0 TRANSLATIONS = ../../../i18n/de/liblogoutapplet.ts \ ../../../i18n/nl/liblogoutapplet.ts \ ../../../i18n/da/liblogoutapplet.ts \ ../../../i18n/xx/liblogoutapplet.ts \ ../../../i18n/en/liblogoutapplet.ts \ ../../../i18n/es/liblogoutapplet.ts \ ../../../i18n/fr/liblogoutapplet.ts \ ../../../i18n/hu/liblogoutapplet.ts \ ../../../i18n/ja/liblogoutapplet.ts \ ../../../i18n/ko/liblogoutapplet.ts \ ../../../i18n/no/liblogoutapplet.ts \ ../../../i18n/pl/liblogoutapplet.ts \ ../../../i18n/pt/liblogoutapplet.ts \ ../../../i18n/pt_BR/liblogoutapplet.ts \ ../../../i18n/sl/liblogoutapplet.ts \ ../../../i18n/zh_CN/liblogoutapplet.ts \ ../../../i18n/zh_TW/liblogoutapplet.ts include ( $(OPIEDIR)/include.pro ) target.path = $$prefix/plugins/applets diff --git a/core/applets/restartapplet/restartapplet.pro b/core/applets/restartapplet/restartapplet.pro index bd27b0a..368a0ea 100644 --- a/core/applets/restartapplet/restartapplet.pro +++ b/core/applets/restartapplet/restartapplet.pro @@ -1,17 +1,17 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt plugin warn_on release HEADERS = restart.h restartappletimpl.h SOURCES = restart.cpp restartappletimpl.cpp TARGET = restartapplet DESTDIR = $(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += ../$(OPIEDIR)/include LIBS += -lqpe VERSION = 1.0.0 MOC_DIR=opieobj OBJECTS_DIR=opieobj include ( $(OPIEDIR)/include.pro ) target.path = $$prefix/plugins/applets diff --git a/core/applets/restartapplet2/restartapplet.pro b/core/applets/restartapplet2/restartapplet.pro index 85a3b66..12a7922 100644 --- a/core/applets/restartapplet2/restartapplet.pro +++ b/core/applets/restartapplet2/restartapplet.pro @@ -1,17 +1,17 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt plugin warn_on release HEADERS = restart.h SOURCES = restart.cpp TARGET = restartapplet DESTDIR = $(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe VERSION = 1.0.0 MOC_DIR=opieobj OBJECTS_DIR=opieobj include ( $(OPIEDIR)/include.pro ) target.path = $$prefix/plugins/applets diff --git a/core/applets/rotateapplet/rotateapplet.pro b/core/applets/rotateapplet/rotateapplet.pro index 9b39dba..2c8de8d 100644 --- a/core/applets/rotateapplet/rotateapplet.pro +++ b/core/applets/rotateapplet/rotateapplet.pro @@ -1,31 +1,31 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt plugn warn_on release HEADERS = rotate.h SOURCES = rotate.cpp TARGET = rotateapplet DESTDIR = $(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe VERSION = 1.0.0 TRANSLATIONS = ../../../i18n/de/librotateapplet.ts \ ../../../i18n/nl/librotateapplet.ts \ ../../../i18n/da/librotateapplet.ts \ ../../../i18n/xx/librotateapplet.ts \ ../../../i18n/en/librotateapplet.ts \ ../../../i18n/es/librotateapplet.ts \ ../../../i18n/fr/librotateapplet.ts \ ../../../i18n/hu/librotateapplet.ts \ ../../../i18n/ja/librotateapplet.ts \ ../../../i18n/ko/librotateapplet.ts \ ../../../i18n/no/librotateapplet.ts \ ../../../i18n/pl/librotateapplet.ts \ ../../../i18n/pt/librotateapplet.ts \ ../../../i18n/pt_BR/librotateapplet.ts \ ../../../i18n/sl/librotateapplet.ts \ ../../../i18n/zh_CN/librotateapplet.ts \ ../../../i18n/zh_TW/librotateapplet.ts include ( $(OPIEDIR)/include.pro ) target.path = $$prefix/plugins/applets diff --git a/core/applets/screenshotapplet/screenshotapplet.pro b/core/applets/screenshotapplet/screenshotapplet.pro index fe7b299..a86eff2 100644 --- a/core/applets/screenshotapplet/screenshotapplet.pro +++ b/core/applets/screenshotapplet/screenshotapplet.pro @@ -1,35 +1,35 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt plugin warn_on release HEADERS = screenshot.h inputDialog.h screenshotappletimpl.h SOURCES = screenshot.cpp inputDialog.cpp screenshotappletimpl.cpp TARGET = screenshotapplet DESTDIR = $(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += ../$(OPIEDIR)/include LIBS += -lqpe VERSION = 1.0.0 MOC_DIR=opieobj OBJECTS_DIR=opieobj TRANSLATIONS = ../../../i18n/de/libscreenshotapplet.ts \ ../../../i18n/nl/libscreenshotapplet.ts \ ../../../i18n/da/libscreenshotapplet.ts \ ../../../i18n/xx/libscreenshotapplet.ts \ ../../../i18n/en/libscreenshotapplet.ts \ ../../../i18n/es/libscreenshotapplet.ts \ ../../../i18n/fr/libscreenshotapplet.ts \ ../../../i18n/hu/libscreenshotapplet.ts \ ../../../i18n/ja/libscreenshotapplet.ts \ ../../../i18n/ko/libscreenshotapplet.ts \ ../../../i18n/no/libscreenshotapplet.ts \ ../../../i18n/pl/libscreenshotapplet.ts \ ../../../i18n/pt/libscreenshotapplet.ts \ ../../../i18n/pt_BR/libscreenshotapplet.ts \ ../../../i18n/sl/libscreenshotapplet.ts \ ../../../i18n/zh_CN/libscreenshotapplet.ts \ ../../../i18n/zh_TW/libscreenshotapplet.ts include ( $(OPIEDIR)/include.pro ) target.path = $$prefix/plugins/applets diff --git a/core/applets/suspendapplet/suspendapplet.pro b/core/applets/suspendapplet/suspendapplet.pro index 7635d32..f58de63 100644 --- a/core/applets/suspendapplet/suspendapplet.pro +++ b/core/applets/suspendapplet/suspendapplet.pro @@ -1,33 +1,33 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt plugin warn_on release HEADERS = suspend.h SOURCES = suspend.cpp TARGET = suspendapplet DESTDIR = $(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe VERSION = 1.0.0 TRANSLATIONS = ../../../i18n/de/libsuspendapplet.ts \ ../../../i18n/nl/libsuspendapplet.ts \ ../../../i18n/da/libsuspendapplet.ts \ ../../../i18n/xx/libsuspendapplet.ts \ ../../../i18n/en/libsuspendapplet.ts \ ../../../i18n/es/libsuspendapplet.ts \ ../../../i18n/fr/libsuspendapplet.ts \ ../../../i18n/hu/libsuspendapplet.ts \ ../../../i18n/ja/libsuspendapplet.ts \ ../../../i18n/ko/libsuspendapplet.ts \ ../../../i18n/no/libsuspendapplet.ts \ ../../../i18n/pl/libsuspendapplet.ts \ ../../../i18n/pt/libsuspendapplet.ts \ ../../../i18n/pt_BR/libsuspendapplet.ts \ ../../../i18n/sl/libsuspendapplet.ts \ ../../../i18n/zh_CN/libsuspendapplet.ts \ ../../../i18n/zh_TW/libsuspendapplet.ts include ( $(OPIEDIR)/include.pro ) target.path = $$prefix/plugins/applets diff --git a/core/applets/vmemo/vmemo.pro b/core/applets/vmemo/vmemo.pro index 8cf1f07..43cb767 100644 --- a/core/applets/vmemo/vmemo.pro +++ b/core/applets/vmemo/vmemo.pro @@ -1,33 +1,33 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt plugin warn_on release HEADERS = vmemo.h vmemoimpl.h adpcm.h SOURCES = vmemo.cpp vmemoimpl.cpp adpcm.c TARGET = vmemoapplet DESTDIR =$(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe VERSION = 1.0.0 TRANSLATIONS = ../../../i18n/de/libvmemoapplet.ts \ ../../../i18n/nl/libvmemoapplet.ts \ ../../../i18n/da/libvmemoapplet.ts \ ../../../i18n/xx/libvmemoapplet.ts \ ../../../i18n/en/libvmemoapplet.ts \ ../../../i18n/es/libvmemoapplet.ts \ ../../../i18n/fr/libvmemoapplet.ts \ ../../../i18n/hu/libvmemoapplet.ts \ ../../../i18n/ja/libvmemoapplet.ts \ ../../../i18n/ko/libvmemoapplet.ts \ ../../../i18n/no/libvmemoapplet.ts \ ../../../i18n/pl/libvmemoapplet.ts \ ../../../i18n/pt/libvmemoapplet.ts \ ../../../i18n/pt_BR/libvmemoapplet.ts \ ../../../i18n/sl/libvmemoapplet.ts \ ../../../i18n/zh_CN/libvmemoapplet.ts \ ../../../i18n/zh_TW/libvmemoapplet.ts include ( $(OPIEDIR)/include.pro ) target.path = $$prefix/plugins/applets diff --git a/core/applets/volumeapplet/volumeapplet.pro b/core/applets/volumeapplet/volumeapplet.pro index d30567c..68d9eff 100644 --- a/core/applets/volumeapplet/volumeapplet.pro +++ b/core/applets/volumeapplet/volumeapplet.pro @@ -1,33 +1,33 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt plugin warn_on release HEADERS = volume.h volumeappletimpl.h oledbox.h SOURCES = volume.cpp volumeappletimpl.cpp oledbox.cpp TARGET = volumeapplet DESTDIR = $(OPIEDIR)/plugins/applets INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += ../$(OPIEDIR)/include LIBS += -lqpe VERSION = 1.0.0 TRANSLATIONS = ../../../i18n/de/libvolumeapplet.ts \ ../../../i18n/nl/libvolumeapplet.ts \ ../../../i18n/da/libvolumeapplet.ts \ ../../../i18n/xx/libvolumeapplet.ts \ ../../../i18n/en/libvolumeapplet.ts \ ../../../i18n/es/libvolumeapplet.ts \ ../../../i18n/fr/libvolumeapplet.ts \ ../../../i18n/hu/libvolumeapplet.ts \ ../../../i18n/ja/libvolumeapplet.ts \ ../../../i18n/ko/libvolumeapplet.ts \ ../../../i18n/no/libvolumeapplet.ts \ ../../../i18n/pl/libvolumeapplet.ts \ ../../../i18n/pt/libvolumeapplet.ts \ ../../../i18n/pt_BR/libvolumeapplet.ts \ ../../../i18n/sl/libvolumeapplet.ts \ ../../../i18n/zh_CN/libvolumeapplet.ts \ ../../../i18n/zh_TW/libvolumeapplet.ts include ( $(OPIEDIR)/include.pro ) target.path = $$prefix/plugins/applets diff --git a/core/launcher/applauncher.cpp b/core/launcher/applauncher.cpp index d6f93da..0ac043b 100644 --- a/core/launcher/applauncher.cpp +++ b/core/launcher/applauncher.cpp @@ -165,550 +165,554 @@ void AppLauncher::received(const QCString& msg, const QByteArray& data) QDataStream stream( data, IO_ReadOnly ); if ( msg == "execute(QString)" ) { QString t; stream >> t; if ( !executeBuiltin( t, QString::null ) ) execute(t, QString::null); } else if ( msg == "execute(QString,QString)" ) { QString t,d; stream >> t >> d; if ( !executeBuiltin( t, d ) ) execute( t, d ); } else if ( msg == "processQCop(QString)" ) { // from QPE/Server QString t; stream >> t; if ( !executeBuiltin( t, QString::null ) ) execute( t, QString::null, TRUE); } else if ( msg == "raise(QString)" ) { QString appName; stream >> appName; if ( !executeBuiltin( appName, QString::null ) ) { if ( !waitingHeartbeat.contains( appName ) && appKillerName != appName ) { //qDebug( "Raising: %s", appName.latin1() ); QCString channel = "QPE/Application/"; channel += appName.latin1(); // Need to lock it to avoid race conditions with QPEApplication::processQCopFile QFile f("/tmp/qcop-msg-" + appName); if ( f.open(IO_WriteOnly | IO_Append) ) { #ifndef Q_OS_WIN32 flock(f.handle(), LOCK_EX); #endif QDataStream ds(&f); QByteArray b; QDataStream bstream(b, IO_WriteOnly); ds << channel << QCString("raise()") << b; f.flush(); #ifndef Q_OS_WIN32 flock(f.handle(), LOCK_UN); #endif f.close(); } bool alreadyRunning = isRunning( appName ); if ( execute(appName, QString::null) ) { int id = startTimer(RAISE_TIMEOUT_MS + alreadyRunning?2000:0); waitingHeartbeat.insert( appName, id ); } } } } else if ( msg == "sendRunningApps()" ) { QStringList apps; QMap<int,QString>::Iterator it; for( it = runningApps.begin(); it != runningApps.end(); ++it ) apps.append( *it ); QCopEnvelope e( "QPE/Desktop", "runningApps(QStringList)" ); e << apps; } else if ( msg == "appRaised(QString)" ) { QString appName; stream >> appName; qDebug("Got a heartbeat from %s", appName.latin1()); QMap<QString,int>::Iterator it = waitingHeartbeat.find(appName); if ( it != waitingHeartbeat.end() ) { killTimer( *it ); waitingHeartbeat.remove(it); } // Check to make sure we're not waiting on user input... if ( appKillerBox && appName == appKillerName ) { // If we are, we kill the dialog box, and the code waiting on the result // will clean us up (basically the user said "no"). delete appKillerBox; appKillerBox = 0; appKillerName = QString::null; } } } void AppLauncher::signalHandler(int) { #ifndef Q_OS_WIN32 int status; pid_t pid = waitpid(-1, &status, WNOHANG); /* if (pid == 0 || &status == 0 ) { qDebug("hmm, could not get return value from signal"); } */ QApplication::postEvent(appLauncherPtr, new AppStoppedEvent(pid, status) ); #else qDebug("Unhandled signal see by AppLauncher::signalHandler(int)"); #endif } bool AppLauncher::event(QEvent *e) { if ( e->type() == appStopEventID ) { AppStoppedEvent *ae = (AppStoppedEvent *) e; sigStopped(ae->pid(), ae->status() ); return TRUE; } return QObject::event(e); } void AppLauncher::timerEvent( QTimerEvent *e ) { int id = e->timerId(); QMap<QString,int>::Iterator it; for ( it = waitingHeartbeat.begin(); it != waitingHeartbeat.end(); ++it ) { if ( *it == id ) { if ( appKillerBox ) // we're already dealing with one return; appKillerName = it.key(); killTimer( id ); waitingHeartbeat.remove( it ); // qDebug("Checking in on %s", appKillerName.latin1()); // We store this incase the application responds while we're // waiting for user input so we know not to delete ourselves. appKillerBox = new QMessageBox(tr("Application Problem"), tr("<p>%1 is not responding.</p>").arg(appKillerName) + tr("<p>Would you like to force the application to exit?</p>"), QMessageBox::Warning, QMessageBox::Yes, QMessageBox::No | QMessageBox::Default, QMessageBox::NoButton); if (appKillerBox->exec() == QMessageBox::Yes) { // qDebug("Killing the app!!! Bwuhahahaha!"); int pid = pidForName(appKillerName); if ( pid > 0 ) kill( pid ); } appKillerName = QString::null; delete appKillerBox; appKillerBox = 0; return; } } QObject::timerEvent( e ); } #ifndef Q_OS_WIN32 void AppLauncher::sigStopped(int sigPid, int sigStatus) { int exitStatus = 0; bool crashed = WIFSIGNALED(sigStatus); if ( !crashed ) { if ( WIFEXITED(sigStatus) ) exitStatus = WEXITSTATUS(sigStatus); } else { exitStatus = WTERMSIG(sigStatus); } QMap<int,QString>::Iterator it = runningApps.find( sigPid ); if ( it == runningApps.end() ) { if ( sigPid == qlPid ) { qDebug( "quicklauncher stopped" ); qlPid = 0; qlReady = FALSE; QFile::remove("/tmp/qcop-msg-quicklauncher" ); QTimer::singleShot( 2000, this, SLOT(createQuickLauncher()) ); } /* if ( sigPid == -1 ) qDebug("non-qtopia application exited (disregarded)"); else qDebug("==== no pid matching %d in list, definite bug", sigPid); */ return; } QString appName = *it; runningApps.remove(it); QMap<QString,int>::Iterator hbit = waitingHeartbeat.find(appName); if ( hbit != waitingHeartbeat.end() ) { killTimer( *hbit ); waitingHeartbeat.remove( hbit ); } if ( appName == appKillerName ) { appKillerName = QString::null; delete appKillerBox; appKillerBox = 0; } /* we must disable preload for an app that crashes as the system logic relies on preloaded apps actually being loaded. If eg. the crash happened in the constructor, we can't automatically reload the app (withouth some timeout value for eg. 3 tries (which I think is a bad solution) */ bool preloadDisabled = FALSE; if ( !DocumentList::appLnkSet ) return; const AppLnk* app = DocumentList::appLnkSet->findExec( appName ); if ( !app ) return; // QCop messages processed to slow? if ( crashed && app->isPreloaded() ) { Config cfg("Launcher"); cfg.setGroup("Preload"); QStringList apps = cfg.readListEntry("Apps",','); QString exe = app->exec(); apps.remove(exe); cfg.writeEntry("Apps",apps,','); preloadDisabled = TRUE; } // clean up if ( exitStatus ) { QCopEnvelope e("QPE/System", "notBusy(QString)"); e << app->exec(); } /* // debug info for (it = runningApps.begin(); it != runningApps.end(); ++it) { qDebug("running according to internal list: %s, with pid %d", (*it).data(), it.key() ); } */ #ifdef QTOPIA_PROGRAM_MONITOR if ( crashed ) { QString sig; switch( exitStatus ) { case SIGABRT: sig = "SIGABRT"; break; case SIGALRM: sig = "SIGALRM"; break; case SIGBUS: sig = "SIGBUS"; break; case SIGFPE: sig = "SIGFPE"; break; case SIGHUP: sig = "SIGHUP"; break; case SIGILL: sig = "SIGILL"; break; case SIGKILL: sig = "SIGKILL"; break; case SIGPIPE: sig = "SIGPIPE"; break; case SIGQUIT: sig = "SIGQUIT"; break; case SIGSEGV: sig = "SIGSEGV"; break; case SIGTERM: sig = "SIGTERM"; break; case SIGTRAP: sig = "SIGTRAP"; break; default: sig = QString("Unkown %1").arg(exitStatus); } if ( preloadDisabled ) sig += tr("<qt><p>Fast loading has been disabled for this application. Tap and hold the application icon to reenable it.</qt>"); QString str = tr("<qt><b>%1</b> was terminated due to signal code %2</qt>").arg( app->name() ).arg( sig ); QMessageBox::information(0, tr("Application terminated"), str ); } else { if ( exitStatus == 255 ) { //could not find app (because global returns -1) QMessageBox::information(0, tr("Application not found"), tr("<qt>Could not locate application <b>%1</b></qt>").arg( app->exec() ) ); } else { QFileInfo fi(Opie::Global::tempDir() + "qcop-msg-" + appName); if ( fi.exists() && fi.size() ) { emit terminated(sigPid, appName); qWarning("Re executing obmitted for %s", appName.latin1() ); // execute( appName, QString::null ); return; } } } #endif emit terminated(sigPid, appName); } #else void AppLauncher::sigStopped(int sigPid, int sigStatus) { qDebug("Unhandled signal : AppLauncher::sigStopped(int sigPid, int sigStatus)"); } #endif // Q_OS_WIN32 bool AppLauncher::isRunning(const QString &app) { for (QMap<int,QString>::ConstIterator it = runningApps.begin(); it != runningApps.end(); ++it) { if ( *it == app ) { #ifdef Q_OS_UNIX pid_t t = ::__getpgid( it.key() ); if ( t == -1 ) { qDebug("appLauncher bug, %s believed running, but pid %d is not existing", app.data(), it.key() ); runningApps.remove( it.key() ); return FALSE; } #endif return TRUE; } } return FALSE; } bool AppLauncher::executeBuiltin(const QString &c, const QString &document) { Global::Command* builtin = Opie::Global::builtinCommands(); QGuardedPtr<QWidget> *running = Opie::Global::builtinRunning(); // Attempt to execute the app using a builtin class for the app if (builtin) { for (int i = 0; builtin[i].file; i++) { if ( builtin[i].file == c ) { if ( running[i] ) { if ( !document.isNull() && builtin[i].documentary ) Global::setDocument(running[i], document); running[i]->raise(); running[i]->show(); running[i]->setActiveWindow(); } else { running[i] = builtin[i].func( builtin[i].maximized ); } #ifndef QT_NO_COP QCopEnvelope e("QPE/System", "notBusy(QString)" ); e << c; // that was quick ;-) #endif return TRUE; } } } // Convert the command line in to a list of arguments QStringList list = QStringList::split(QRegExp(" *"),c); QString ap=list[0]; if ( ap == "suspend" ) { // No tr QWSServer::processKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); return TRUE; } return FALSE; } bool AppLauncher::execute(const QString &c, const QString &docParam, bool noRaise) { qWarning("AppLauncher::execute"); // Convert the command line in to a list of arguments QStringList list = QStringList::split(QRegExp(" *"),c); if ( !docParam.isEmpty() ) list.append( docParam ); QString appName = list[0]; if ( isRunning(appName) ) { QCString channel = "QPE/Application/"; channel += appName.latin1(); // Need to lock it to avoid race conditions with QPEApplication::processQCopFile QFile f(Opie::Global::tempDir() + "qcop-msg-" + appName); if ( !noRaise && f.open(IO_WriteOnly | IO_Append) ) { #ifndef Q_OS_WIN32 flock(f.handle(), LOCK_EX); #endif QDataStream ds(&f); QByteArray b; QDataStream bstream(b, IO_WriteOnly); if ( !f.size() ) { ds << channel << QCString("raise()") << b; if ( !waitingHeartbeat.contains( appName ) && appKillerName != appName ) { int id = startTimer(RAISE_TIMEOUT_MS); waitingHeartbeat.insert( appName, id ); } } if ( !docParam.isEmpty() ) { bstream << docParam; ds << channel << QCString("setDocument(QString)") << b; } f.flush(); #ifndef Q_OS_WIN32 flock(f.handle(), LOCK_UN); #endif f.close(); } if ( QCopChannel::isRegistered(channel) ) // avoid unnecessary warnings QCopChannel::send(channel,"QPEProcessQCop()"); return TRUE; } #ifdef QT_NO_QWS_MULTIPROCESS QMessageBox::warning( 0, tr("Error"), tr("<qt>Could not find the application %1</qt>").arg(c), tr("OK"), 0, 0, 0, 1 ); #else QStrList slist; unsigned j; for ( j = 0; j < list.count(); j++ ) slist.append( list[j].utf8() ); const char **args = new const char *[slist.count() + 1]; for ( j = 0; j < slist.count(); j++ ) args[j] = slist.at(j); args[j] = NULL; #ifndef Q_OS_WIN32 +#ifdef Q_OS_MACX + if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".dylib" ) ) { +#else if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".so" ) ) { +#endif /* Q_OS_MACX */ qDebug( "Quick launching: %s", args[0] ); if ( getuid() == 0 ) setpriority( PRIO_PROCESS, qlPid, 0 ); QCString qlch("QPE/QuickLauncher-"); qlch += QString::number(qlPid); QCopEnvelope env( qlch, "execute(QStrList)" ); env << slist; runningApps[qlPid] = QString(args[0]); emit launched(qlPid, QString(args[0])); QCopEnvelope e("QPE/System", "busy()"); qlPid = 0; qlReady = FALSE; QTimer::singleShot( getuid() == 0 ? 800 : 1500, this, SLOT(createQuickLauncher()) ); } else { int pid = ::vfork(); if ( !pid ) { for ( int fd = 3; fd < 100; fd++ ) ::close( fd ); ::setpgid( ::getpid(), ::getppid() ); // Try bindir first, so that foo/bar works too ::execv( QPEApplication::qpeDir()+"bin/"+args[0], (char * const *)args ); ::execvp( args[0], (char * const *)args ); _exit( -1 ); } runningApps[pid] = QString(args[0]); emit launched(pid, QString(args[0])); QCopEnvelope e("QPE/System", "busy()"); } #else QProcess *proc = new QProcess(this); if (proc){ for (int i=0; i < slist.count(); i++) proc->addArgument(args[i]); connect(proc, SIGNAL(processExited()), this, SLOT(processExited())); if (!proc->start()){ qDebug("Unable to start application %s", args[0]); }else{ PROCESS_INFORMATION *procInfo = (PROCESS_INFORMATION *)proc->processIdentifier(); if (procInfo){ DWORD pid = procInfo->dwProcessId; runningApps[pid] = QString(args[0]); runningAppsProc.append(proc); emit launched(pid, QString(args[0])); QCopEnvelope e("QPE/System", "busy()"); }else{ qDebug("Unable to read process inforation #1 for %s", args[0]); } } }else{ qDebug("Unable to create process for application %s", args[0]); return FALSE; } #endif #endif //QT_NO_QWS_MULTIPROCESS delete [] args; return TRUE; } void AppLauncher::kill( int pid ) { #ifndef Q_OS_WIN32 ::kill( pid, SIGTERM ); #else for ( QProcess *proc = runningAppsProc.first(); proc; proc = runningAppsProc.next() ) { if ( proc->processIdentifier() == pid ) { proc->kill(); break; } } #endif } int AppLauncher::pidForName( const QString &appName ) { int pid = -1; QMap<int, QString>::Iterator it; for (it = runningApps.begin(); it!= runningApps.end(); ++it) { if (*it == appName) { pid = it.key(); break; } } return pid; } void AppLauncher::createQuickLauncher() { static bool disabled = FALSE; if (disabled) return; qlReady = FALSE; qlPid = ::vfork(); if ( !qlPid ) { char **args = new char *[2]; args[0] = "quicklauncher"; args[1] = 0; for ( int fd = 3; fd < 100; fd++ ) ::close( fd ); ::setpgid( ::getpid(), ::getppid() ); // Try bindir first, so that foo/bar works too setenv( "LD_BIND_NOW", "1", 1 ); ::execv( QPEApplication::qpeDir()+"bin/quicklauncher", args ); ::execvp( "quicklauncher", args ); delete []args; disabled = TRUE; _exit( -1 ); } else if ( qlPid == -1 ) { qlPid = 0; } else { if ( getuid() == 0 ) setpriority( PRIO_PROCESS, qlPid, 19 ); } } // Used only by Win32 void AppLauncher::processExited() { #ifdef Q_OS_WIN32 qDebug("AppLauncher::processExited()"); bool found = FALSE; QProcess *proc = (QProcess *) sender(); if (!proc){ qDebug("Interanl error NULL proc"); return; } QString appName = proc->arguments()[0]; qDebug("Removing application %s", appName.latin1()); runningAppsProc.remove(proc); QMap<QString,int>::Iterator hbit = waitingHeartbeat.find(appName); if ( hbit != waitingHeartbeat.end() ) { killTimer( *hbit ); waitingHeartbeat.remove( hbit ); } if ( appName == appKillerName ) { appKillerName = QString::null; delete appKillerBox; appKillerBox = 0; } // Search for the app to find its PID QMap<int, QString>::Iterator it; for (it = runningApps.begin(); it!= runningApps.end(); ++it){ if (it.data() == appName){ found = TRUE; break; } } if (found){ emit terminated(it.key(), it.data()); runningApps.remove(it.key()); }else{ qDebug("Internal error application %s not listed as running", appName.latin1()); } #endif } diff --git a/core/launcher/inputmethods.cpp b/core/launcher/inputmethods.cpp index 8f3e812..62e316c 100644 --- a/core/launcher/inputmethods.cpp +++ b/core/launcher/inputmethods.cpp @@ -1,614 +1,618 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #define QTOPIA_INTERNAL_LANGLIST #include "inputmethods.h" #include <qtopia/config.h> #include <qtopia/qpeapplication.h> #include <qtopia/inputmethodinterface.h> #include <qtopia/global.h> #include <qpopupmenu.h> #include <qpushbutton.h> #include <qtoolbutton.h> #include <qwidgetstack.h> #include <qwidget.h> #include <qlayout.h> #include <qtimer.h> #include <qdir.h> #include <stdlib.h> #include <qtranslator.h> #include <qtl.h> #ifdef Q_WS_QWS #include <qwindowsystem_qws.h> #include <qwsevent_qws.h> #include <qcopchannel_qws.h> #endif /* ### SingleFloppy if someone is interested? */ #if 0 #ifdef QT_NO_COMPONENT #include "../plugins/inputmethods/handwriting/handwritingimpl.h" #include "../plugins/inputmethods/keyboard/keyboardimpl.h" #include "../3rdparty/plugins/inputmethods/pickboard/pickboardimpl.h" #endif #endif /* XPM */ static const char * tri_xpm[]={ "9 9 2 1", "a c #000000", ". c None", ".........", ".........", ".........", "....a....", "...aaa...", "..aaaaa..", ".aaaaaaa.", ".........", "........."}; int InputMethod::operator <(const InputMethod& o) const { return name() < o.name(); } int InputMethod::operator >(const InputMethod& o) const { return name() > o.name(); } int InputMethod::operator <=(const InputMethod& o) const { return name() <= o.name(); } /* Slightly hacky: We use WStyle_Tool as a flag to say "this widget belongs to the IM system, so clicking it should not cause a reset". */ class IMToolButton : public QToolButton { public: IMToolButton::IMToolButton( QWidget *parent ) : QToolButton( parent ) { setWFlags( WStyle_Tool ); } }; InputMethods::InputMethods( QWidget *parent ) : QWidget( parent, "InputMethods", WStyle_Tool | WStyle_Customize ), mkeyboard(0), imethod(0) { Config cfg( "Launcher" ); cfg.setGroup( "InputMethods" ); inputWidgetStyle = QWidget::WStyle_Customize | QWidget::WStyle_StaysOnTop | QWidget::WGroupLeader | QWidget::WStyle_Tool; inputWidgetStyle |= cfg.readBoolEntry( "Float", false ) ? QWidget::WStyle_DialogBorder : 0; inputWidgetWidth = cfg.readNumEntry( "Width", 100 ); setBackgroundMode( PaletteBackground ); QHBoxLayout *hbox = new QHBoxLayout( this ); kbdButton = new IMToolButton( this); kbdButton->setFocusPolicy(NoFocus); kbdButton->setToggleButton( TRUE ); if (parent->sizeHint().height() > 0) kbdButton->setFixedHeight( parent->sizeHint().height() ); kbdButton->setFixedWidth( 32 ); kbdButton->setAutoRaise( TRUE ); kbdButton->setUsesBigPixmap( TRUE ); hbox->addWidget( kbdButton ); connect( kbdButton, SIGNAL(toggled(bool)), this, SLOT(showKbd(bool)) ); kbdChoice = new IMToolButton( this ); kbdChoice->setFocusPolicy(NoFocus); kbdChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); if (parent->sizeHint().height() > 0) kbdChoice->setFixedHeight( parent->sizeHint().height() ); kbdChoice->setFixedWidth( 13 ); kbdChoice->setAutoRaise( TRUE ); hbox->addWidget( kbdChoice ); connect( kbdChoice, SIGNAL(clicked()), this, SLOT(chooseKbd()) ); connect( (QPEApplication*)qApp, SIGNAL(clientMoused()), this, SLOT(resetStates()) ); imButton = new QWidgetStack( this ); // later a widget stack imButton->setFocusPolicy(NoFocus); if (parent->sizeHint().height() > 0) imButton->setFixedHeight( parent->sizeHint().height() ); hbox->addWidget(imButton); imChoice = new QToolButton( this ); imChoice->setFocusPolicy(NoFocus); imChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); if (parent->sizeHint().height() > 0) imChoice->setFixedHeight( parent->sizeHint().height() ); imChoice->setFixedWidth( 13 ); imChoice->setAutoRaise( TRUE ); hbox->addWidget( imChoice ); connect( imChoice, SIGNAL(clicked()), this, SLOT(chooseIm()) ); loadInputMethods(); QCopChannel *channel = new QCopChannel( "QPE/IME", this ); connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(qcopReceive(const QCString&, const QByteArray&)) ); } InputMethods::~InputMethods() { Config cfg("qpe"); cfg.setGroup("InputMethod"); if (imethod) cfg.writeEntry("im", imethod->name() ); if (mkeyboard) cfg.writeEntry("current", mkeyboard->name() ); unloadInputMethods(); } void InputMethods::hideInputMethod() { kbdButton->setOn( FALSE ); } void InputMethods::showInputMethod() { kbdButton->setOn( TRUE ); } void InputMethods::showInputMethod(const QString& name) { int i = 0; QValueList<InputMethod>::Iterator it; InputMethod *im = 0; for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { QString lname = (*it).libName.mid((*it).libName.findRev('/') + 1); if ( (*it).name() == name || lname == name ) { im = &(*it); break; } } if ( im ) chooseKeyboard(im); } void InputMethods::resetStates() { if ( mkeyboard && !mkeyboard->newIM ) mkeyboard->interface->resetState(); } QRect InputMethods::inputRect() const { if ( !mkeyboard || !mkeyboard->widget || !mkeyboard->widget->isVisible() ) return QRect(); else return mkeyboard->widget->geometry(); } void InputMethods::unloadInputMethods() { unloadMethod( inputMethodList ); unloadMethod( inputModifierList ); inputMethodList.clear(); inputModifierList.clear(); } void InputMethods::unloadMethod( QValueList<InputMethod>& list ) { QValueList<InputMethod>::Iterator it; for (it = list.begin(); it != list.end(); ++it ) (*it).releaseInterface(); } QStringList InputMethods::plugins()const { QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; +#ifdef Q_OS_MACX + QDir dir( path, "lib*.dylib" ); +#else QDir dir( path, "lib*.so" ); +#endif /* Q_OS_MACX */ return dir.entryList(); } void InputMethods::installTranslator( const QString& type ) { QStringList langs = Global::languageList(); QStringList::ConstIterator lit; for ( lit= langs.begin(); lit!=langs.end(); ++lit) { QString lang = *lit; QTranslator * trans = new QTranslator(qApp); QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; if ( trans->load( tfn )) qApp->installTranslator( trans ); else delete trans; } } void InputMethods::setPreferedHandlers() { Config cfg("qpe"); cfg.setGroup("InputMethod"); QString current = cfg.readEntry("current"); QString im = cfg.readEntry("im"); QValueList<InputMethod>::Iterator it; if (!inputModifierList.isEmpty() && !im.isEmpty() ) { for (it = inputModifierList.begin(); it != inputModifierList.end(); ++it ) if ( (*it).name() == im ) { imethod = &(*it); break; } } if (!inputMethodList.isEmpty() && !current.isEmpty() ) { for (it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) if ( (*it).name() == current ) { qWarning("preferred keyboard is %s", current.latin1() ); mkeyboard = &(*it); kbdButton->setPixmap( *mkeyboard->icon() ); break; } } } void InputMethods::loadInputMethods() { #ifndef QT_NO_COMPONENT hideInputMethod(); mkeyboard = 0; unloadInputMethods(); QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; QStringList list = plugins(); QStringList::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { InputMethodInterface *iface = 0; ExtInputMethodInterface *eface = 0; QLibrary *lib = new QLibrary( path + "/" + *it ); if ( lib->queryInterface( IID_InputMethod, (QUnknownInterface**)&iface ) == QS_OK ) { InputMethod input; input.newIM = FALSE; input.library = lib; input.libName = *it; input.interface = iface; input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); inputMethodList.append( input ); } else if ( lib->queryInterface( IID_ExtInputMethod, (QUnknownInterface**)&eface ) == QS_OK ) { InputMethod input; input.newIM = TRUE; input.library = lib; input.libName = *it; input.extInterface = eface; input.widget = input.extInterface->keyboardWidget( 0, inputWidgetStyle ); // may be either a simple, or advanced. if (input.widget) { //qDebug("its a keyboard"); inputMethodList.append( input ); } else { //qDebug("its a real im"); input.widget = input.extInterface->statusWidget( 0, 0 ); if (input.widget) { //qDebug("blah"); inputModifierList.append( input ); imButton->addWidget(input.widget, inputModifierList.count()); } } }else{ delete lib; lib = 0l; } installTranslator( (*it).left( (*it).find(".") ) ); } qHeapSort( inputMethodList ); #endif /* killed BUILT in cause they would not compile */ QWSServer::setCurrentInputMethod( 0 ); /* set the prefered IM + handler */ setPreferedHandlers(); if ( !inputModifierList.isEmpty() ) { if (!imethod) imethod = &inputModifierList[0]; imButton->raiseWidget(imethod->widget); QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); } else { imethod = 0; } // we need to update keyboards afterwards, as some of them may not be compatible with // the current input method updateKeyboards(imethod); if ( !inputModifierList.isEmpty() ) imButton->show(); else imButton->hide(); if ( inputModifierList.count() > 1 ) imChoice->show(); else imChoice->hide(); } void InputMethods::chooseKbd() { QPopupMenu pop( this ); pop.setFocusPolicy( NoFocus ); //don't reset IM QString imname; if (imethod) imname = imethod->libName.mid(imethod->libName.findRev('/') + 1); int i = 0; int firstDepKbd = 0; QValueList<InputMethod>::Iterator it; for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { // add empty new items, all old items. if (!(*it).newIM || (*it).extInterface->compatible().count() == 0 ) { pop.insertItem( (*it).name(), i, firstDepKbd); if ( mkeyboard == &(*it) ) pop.setItemChecked( i, TRUE ); firstDepKbd++; } else if ( (*it).extInterface->compatible().contains(imname)) { // check if we need to insert a sep. if (firstDepKbd == i) pop.insertSeparator(); pop.insertItem( (*it).name(), i, -1); if ( mkeyboard == &(*it) ) pop.setItemChecked( i, TRUE ); } } QPoint pt = mapToGlobal(kbdChoice->geometry().topRight()); QSize s = pop.sizeHint(); pt.ry() -= s.height(); pt.rx() -= s.width(); i = pop.exec( pt ); if ( i == -1 ) return; InputMethod *im = &inputMethodList[i]; chooseKeyboard(im); } void InputMethods::chooseIm() { QPopupMenu pop( this ); int i = 0; QValueList<InputMethod>::Iterator it; for ( it = inputModifierList.begin(); it != inputModifierList.end(); ++it, i++ ) { pop.insertItem( (*it).name(), i ); if ( imethod == &(*it) ) pop.setItemChecked( i, TRUE ); } QPoint pt = mapToGlobal(imChoice->geometry().topRight()); QSize s = pop.sizeHint(); pt.ry() -= s.height(); pt.rx() -= s.width(); i = pop.exec( pt ); if ( i == -1 ) return; InputMethod *im = &inputModifierList[i]; chooseMethod(im); } void InputMethods::chooseKeyboard(InputMethod* im) { if ( im != mkeyboard ) { if ( mkeyboard && mkeyboard->widget->isVisible() ) mkeyboard->widget->hide(); mkeyboard = im; kbdButton->setPixmap( *mkeyboard->icon() ); } if ( !kbdButton->isOn() ) kbdButton->setOn( TRUE ); else showKbd( TRUE ); } static bool keyboardCompatible(InputMethod *keyb, const QString &imname ) { if ( !keyb || !keyb->newIM || !keyb->extInterface->compatible().count() ) return TRUE; if ( keyb->extInterface->compatible().contains(imname) ) return TRUE; return FALSE; } // Updates the display of the soft keyboards available to the current input method void InputMethods::updateKeyboards(InputMethod *im ) { uint count; if ( im ) { QString imname = im->libName.mid(im->libName.findRev('/') + 1); if ( mkeyboard && !keyboardCompatible(mkeyboard, imname) ) { kbdButton->setOn( FALSE ); showKbd( FALSE ); mkeyboard = 0; } count = 0; QValueList<InputMethod>::Iterator it; for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it ) { if ( keyboardCompatible( &(*it), imname ) ) { if ( !mkeyboard ) { mkeyboard = &(*it); kbdButton->setPixmap( *mkeyboard->icon() ); } count++; } } } else { count = inputMethodList.count(); if ( count && !mkeyboard ) { mkeyboard = &inputMethodList[0]; kbdButton->setPixmap( *mkeyboard->icon() ); } else if (!count){ mkeyboard = 0; //might be redundant } } if ( count > 1 ) kbdChoice->show(); else kbdChoice->hide(); if ( count ) kbdButton->show(); else kbdButton->hide(); } void InputMethods::chooseMethod(InputMethod* im) { if ( im != imethod ) { updateKeyboards( im ); Config cfg("qpe"); cfg.setGroup("InputMethod"); if (im ) cfg.writeEntry("im", im->name() ); if (mkeyboard) cfg.writeEntry("current", mkeyboard->name() ); QWSServer::setCurrentInputMethod( 0 ); imethod = im; if ( imethod && imethod->newIM ) QWSServer::setCurrentInputMethod( imethod->extInterface->inputMethod() ); else QWSServer::setCurrentInputMethod( 0 ); if ( im ) imButton->raiseWidget(im->widget); else imButton->hide(); //### good UI? make sure it is shown again! } } void InputMethods::qcopReceive( const QCString &msg, const QByteArray &data ) { if ( imethod && imethod->newIM ) imethod->extInterface->qcopReceive( msg, data ); } void InputMethods::showKbd( bool on ) { if ( !mkeyboard ) return; if ( on ) { mkeyboard->resetState(); int height = QMIN( mkeyboard->widget->sizeHint().height(), 134 ); int width = qApp->desktop()->width() * (inputWidgetWidth*0.01); int left = 0; int top = mapToGlobal( QPoint() ).y() - height; if ( inputWidgetStyle & QWidget::WStyle_DialogBorder ) { qDebug( "InputMethods: reading geometry." ); Config cfg( "Launcher" ); cfg.setGroup( "InputMethods" ); int l = cfg.readNumEntry( "absX", -1 ); int t = cfg.readNumEntry( "absY", -1 ); int w = cfg.readNumEntry( "absWidth", -1 ); int h = cfg.readNumEntry( "absHeight", -1 ); if ( l > -1 && t > -1 && w > -1 && h > -1 ) { qDebug( "InputMethods: config values ( %d, %d, %d, %d ) are ok.", l, t, w, h ); left = l; top = t; width = w; height = h; } else { qDebug( "InputMethods: config values are new or not ok." ); } } else { qDebug( "InputMethods: no floating selected." ); } mkeyboard->widget->resize( width, height ); mkeyboard->widget->move( left, top ); mkeyboard->widget->show(); mkeyboard->widget->installEventFilter( this ); } else { if ( inputWidgetStyle & QWidget::WStyle_DialogBorder ) { QPoint pos = mkeyboard->widget->pos(); QSize siz = mkeyboard->widget->size(); qDebug( "InputMethods: saving geometry." ); Config cfg( "Launcher" ); cfg.setGroup( "InputMethods" ); cfg.writeEntry( "absX", pos.x() ); cfg.writeEntry( "absY", pos.y() ); cfg.writeEntry( "absWidth", siz.width() ); cfg.writeEntry( "absHeight", siz.height() ); cfg.write(); mkeyboard->widget->hide(); mkeyboard->widget->removeEventFilter( this ); } } emit inputToggled( on ); } bool InputMethods::shown() const { return mkeyboard && mkeyboard->widget->isVisible(); } QString InputMethods::currentShown() const { return mkeyboard && mkeyboard->widget->isVisible() ? mkeyboard->name() : QString::null; } void InputMethods::sendKey( ushort unicode, ushort scancode, ushort mod, bool press, bool repeat ) { #if defined(Q_WS_QWS) QWSServer::sendKeyEvent( unicode, scancode, mod, press, repeat ); #endif } diff --git a/core/launcher/irserver.cpp b/core/launcher/irserver.cpp index 579c78c..63f8d05 100644 --- a/core/launcher/irserver.cpp +++ b/core/launcher/irserver.cpp @@ -1,73 +1,77 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "irserver.h" #include <qtopia/qlibrary.h> #include <qtopia/qpeapplication.h> #include <qtranslator.h> #include "obexinterface.h" #include <qdir.h> IrServer::IrServer( QObject *parent, const char *name ) : QObject( parent, name ), obexIface(0) { lib = 0; obexIface = 0; QString path = QPEApplication::qpeDir() + "/plugins/obex/"; +#ifdef Q_OS_MACX + QDir dir( path, "lib*.dylib" ); +#else QDir dir( path, "lib*.so" ); +#endif /* Q_OS_MACX */ QStringList list = dir.entryList(); QStringList::Iterator it; for ( it = list.begin(); it != list.end(); ++it ) { QLibrary *trylib = new QLibrary( path + *it ); //qDebug("trying lib %s", (path + (*it)).latin1() ); if ( trylib->queryInterface( IID_ObexInterface, (QUnknownInterface**)&obexIface ) == QS_OK ) { lib = trylib; //qDebug("found obex lib" ); QString lang = getenv( "LANG" ); QTranslator * trans = new QTranslator(qApp); QString type = (*it).left( (*it).find(".") ); QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; //qDebug("tr fpr obex: %s", tfn.latin1() ); if ( trans->load( tfn )) qApp->installTranslator( trans ); else delete trans; break; } else { delete lib; } } if ( !lib ) qDebug("could not load IR plugin" ); } IrServer::~IrServer() { if ( obexIface ) obexIface->release(); delete lib; } diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp index 74965df..5416d33 100644 --- a/core/launcher/main.cpp +++ b/core/launcher/main.cpp @@ -1,354 +1,356 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef QTOPIA_INTERNAL_FILEOPERATIONS #define QTOPIA_INTERNAL_FILEOPERATIONS #endif #include "server.h" #include "serverapp.h" #include "taskbar.h" #include "stabmon.h" #include "launcher.h" #include "firstuse.h" #include "launcherglobal.h" #include <qtopia/qpeapplication.h> #include <qtopia/network.h> #include <qtopia/config.h> #include <qtopia/custom.h> #include <qtopia/global.h> #include <qfile.h> #include <qdir.h> #ifdef QWS #include <qwindowsystem_qws.h> #include <qtopia/qcopenvelope_qws.h> #endif #include <qtopia/alarmserver.h> #include <stdlib.h> #include <stdio.h> #include <signal.h> #ifndef Q_OS_WIN32 #include <unistd.h> #else #include <process.h> #endif #include "calibrate.h" #ifdef QT_QWS_LOGIN #include "../login/qdmdialogimpl.h" #endif #ifdef Q_WS_QWS #include <qkeyboard_qws.h> #endif #include <qmessagebox.h> #include <opie/odevice.h> using namespace Opie; static void cleanup() { QDir dir( Opie::Global::tempDir(), "qcop-msg-*" ); QStringList stale = dir.entryList(); QStringList::Iterator it; for ( it = stale.begin(); it != stale.end(); ++it ) { dir.remove( *it ); } } static void refreshTimeZoneConfig() { /* ### FIXME timezone handling */ #if 0 // We need to help WorldTime in setting up its configuration for // the current translation // BEGIN no tr const char *defaultTz[] = { "America/New_York", "America/Los_Angeles", "Europe/Oslo", "Asia/Tokyo", "Asia/Hong_Kong", "Australia/Brisbane", 0 }; // END no tr TimeZone curZone; QString zoneID; int zoneIndex; Config cfg = Config( "WorldTime" ); cfg.setGroup( "TimeZones" ); if (!cfg.hasKey( "Zone0" )){ // We have no existing timezones use the defaults which are untranslated strings QString currTz = TimeZone::current().id(); QStringList zoneDefaults; zoneDefaults.append( currTz ); for ( int i = 0; defaultTz[i] && zoneDefaults.count() < 6; i++ ) { if ( defaultTz[i] != currTz ) zoneDefaults.append( defaultTz[i] ); } zoneIndex = 0; for (QStringList::Iterator it = zoneDefaults.begin(); it != zoneDefaults.end() ; ++it){ cfg.writeEntry( "Zone" + QString::number( zoneIndex ) , *it); zoneIndex++; } } // We have an existing list of timezones refresh the // translations of TimeZone name zoneIndex = 0; while (cfg.hasKey( "Zone"+ QString::number( zoneIndex ))){ zoneID = cfg.readEntry( "Zone" + QString::number( zoneIndex )); curZone = TimeZone( zoneID ); if ( !curZone.isValid() ){ qDebug( "initEnvironment() Invalid TimeZone %s", zoneID.latin1() ); break; } cfg.writeEntry( "ZoneName" + QString::number( zoneIndex ), curZone.city() ); zoneIndex++; } #endif } void initEnvironment() { #ifdef Q_OS_WIN32 // Config file requires HOME dir which uses QDir which needs the winver qt_init_winver(); #endif Config config("locale"); config.setGroup( "Location" ); QString tz = config.readEntry( "Timezone", getenv("TZ") ).stripWhiteSpace(); // if not timezone set, pick New York if (tz.isNull() || tz.isEmpty()) tz = "America/New_York"; setenv( "TZ", tz, 1 ); config.writeEntry( "Timezone", tz); config.setGroup( "Language" ); QString lang = config.readEntry( "Language", getenv("LANG") ).stripWhiteSpace(); if( lang.isNull() || lang.isEmpty()) lang = "en_US"; setenv( "LANG", lang, 1 ); config.writeEntry("Language", lang); config.write(); #if 0 setenv( "QWS_SIZE", "240x320", 0 ); #endif QString env(getenv("QWS_DISPLAY")); if (env.contains("Transformed")) { int rot; // transformed driver default rotation is controlled by the hardware. Config config("qpe"); config.setGroup( "Rotation" ); if ( ( rot = config.readNumEntry( "Rot", -1 ) ) == -1 ) rot = ODevice::inst ( )-> rotation ( ) * 90; setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1); QPEApplication::defaultRotation ( ); /* to ensure deforient matches reality */ } } static void initKeyboard() { Config config("qpe"); config.setGroup( "Keyboard" ); int ard = config.readNumEntry( "RepeatDelay" ); int arp = config.readNumEntry( "RepeatPeriod" ); if ( ard > 0 && arp > 0 ) qwsSetKeyboardAutoRepeat( ard, arp ); QString layout = config.readEntry( "Layout", "us101" ); Server::setKeyboardLayout( layout ); } static bool firstUse() { bool needFirstUse = FALSE; if ( QWSServer::mouseHandler() && QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { if ( !QFile::exists( "/etc/pointercal" ) ) needFirstUse = TRUE; } { Config config( "qpe" ); config.setGroup( "Startup" ); needFirstUse |= config.readBoolEntry( "FirstUse", TRUE ); } if ( !needFirstUse ) return FALSE; FirstUse *fu = new FirstUse(); fu->exec(); bool rs = fu->restartNeeded(); delete fu; return rs; } int initApplication( int argc, char ** argv ) { cleanup(); initEnvironment(); //Don't flicker at startup: #ifdef QWS QWSServer::setDesktopBackground( QImage() ); #endif ServerApplication a( argc, argv, QApplication::GuiServer ); refreshTimeZoneConfig(); initKeyboard(); // Don't use first use under Windows if ( firstUse() ) { a.restart(); return 0; } ODevice::inst ( )-> setSoftSuspend ( true ); { QCopEnvelope e("QPE/System", "setBacklight(int)" ); e << -3; // Forced on } AlarmServer::initialize(); Server *s = new Server(); (void)new SysFileMonitor(s); #ifdef QWS Network::createServer(s); #endif s->show(); /* THE ARM rtc has problem holdings the time on reset */ if ( QDate::currentDate ( ). year ( ) < 2000 ) { 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 ) { QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" ); e << QString ( ); } } int rv = a.exec(); qDebug("exiting..."); delete s; +#ifndef Q_OS_MACX ODevice::inst()->setSoftSuspend( false ); +#endif return rv; } static const char *pidfile_path = "/var/run/opie.pid"; void create_pidfile ( ) { FILE *f; if (( f = ::fopen ( pidfile_path, "w" ))) { ::fprintf ( f, "%d", getpid ( )); ::fclose ( f ); } } void remove_pidfile ( ) { ::unlink ( pidfile_path ); } void handle_sigterm ( int /* sig */ ) { if ( qApp ) qApp-> quit ( ); } #ifndef Q_OS_WIN32 int main( int argc, char ** argv ) { ::signal ( SIGCHLD, SIG_IGN ); ::signal ( SIGTERM, handle_sigterm ); ::signal ( SIGINT, handle_sigterm ); ::setsid ( ); ::setpgid ( 0, 0 ); ::atexit ( remove_pidfile ); create_pidfile ( ); int retVal = initApplication( argc, argv ); // Have we been asked to restart? if ( ServerApplication::doRestart ) { for ( int fd = 3; fd < 100; fd++ ) close( fd ); execl( (QPEApplication::qpeDir()+"bin/qpe").latin1(), "qpe", 0 ); } // Kill them. Kill them all. ::kill ( 0, SIGTERM ); ::sleep ( 1 ); ::kill ( 0, SIGKILL ); return retVal; } #else int main( int argc, char ** argv ) { int retVal = initApplication( argc, argv ); if ( DesktopApplication::doRestart ) { qDebug("Trying to restart"); execl( (QPEApplication::qpeDir()+"bin\\qpe").latin1(), "qpe", 0 ); } return retVal; } #endif diff --git a/core/launcher/packageslave.cpp b/core/launcher/packageslave.cpp index 4f149a5..bf34368 100644 --- a/core/launcher/packageslave.cpp +++ b/core/launcher/packageslave.cpp @@ -1,97 +1,341 @@ /********************************************************************** -** Copyright (C) 2000 Trolltech AS. All rights reserved. +** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** -** This file is part of Qtopia Environment. +** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "packageslave.h" +#include <qtopia/qprocess.h> -#include <qpe/process.h> -#include <qpe/qcopenvelope_qws.h> +#ifdef Q_WS_QWS +#include <qtopia/qcopenvelope_qws.h> +#endif #include <qdatastream.h> +#ifdef Q_WS_QWS #include <qcopchannel_qws.h> +#endif +#include <qtextstream.h> +#include <qdir.h> + +#include <stdlib.h> +#include <sys/stat.h> // mkdir() + +#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) #include <unistd.h> +#include <sys/vfs.h> +#include <mntent.h> +#elif defined(Q_OS_WIN32) +#include <windows.h> +#include <winbase.h> +#elif defined(Q_OS_MACX) +#include <unistd.h> +#endif + -PackageSlave::PackageSlave( QObject *parent, char* name ) - : QObject( parent, name ), packageChannel( 0 ) +PackageHandler::PackageHandler( QObject *parent, char* name ) + : QObject( parent, name ), packageChannel( 0 ), currentProcess( 0 ), mNoSpaceLeft( FALSE ) { // setup qcop channel +#ifndef QT_NO_COP packageChannel = new QCopChannel( "QPE/Package", this ); connect( packageChannel, SIGNAL( received(const QCString &, const QByteArray &) ), this, SLOT( qcopMessage( const QCString &, const QByteArray &) ) ); +#endif } -void PackageSlave::qcopMessage( const QCString &msg, const QByteArray &data ) +void PackageHandler::qcopMessage( const QCString &msg, const QByteArray &data ) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "installPackage(QString)" ) { QString file; stream >> file; installPackage( file ); - } - else if ( msg == "removePackage(QString)" ) { + } else if ( msg == "removePackage(QString)" ) { QString file; stream >> file; removePackage( file ); + } else if ( msg == "addPackageFiles(QString,QString)" ) { + QString location, listfile; + stream >> location >> listfile; + addPackageFiles( location, listfile); + } else if ( msg == "addPackages(QString)" ) { + QString location; + stream >> location; + addPackages( location ); + } else if ( msg == "cleanupPackageFiles(QString)" ) { + QString listfile; + stream >> listfile; + cleanupPackageFiles( listfile ); + } else if ( msg == "cleanupPackages(QString)" ) { + QString location; + stream >> location; + cleanupPackages( location ); + } else if ( msg == "prepareInstall(QString,QString)" ) { + QString size, path; + stream >> size; + stream >> path; + prepareInstall( size, path ); } } -void PackageSlave::installPackage( const QString &package ) +void PackageHandler::installPackage( const QString &package ) { - Process proc( QStringList() << "ipkg" << "install" << package ); + if ( mNoSpaceLeft ) { + mNoSpaceLeft = FALSE; + // Don't emit that for now, I still couldn't test it (Wener) + //sendReply( "installFailed(QString)", package ); + //return; + } + + currentProcess = new QProcess( QStringList() << "ipkg" << "install" << package ); // No tr + connect( currentProcess, SIGNAL( processExited() ), SLOT( iProcessExited() ) ); + connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); + connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); + currentPackage = package; + currentProcessError=""; sendReply( "installStarted(QString)", package ); + currentProcess->start(); +} + +void PackageHandler::removePackage( const QString &package ) +{ + currentProcess = new QProcess( QStringList() << "ipkg" << "remove" << package ); // No tr + connect( currentProcess, SIGNAL( processExited() ), SLOT( rmProcessExited() ) ); + connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); + connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); + currentPackage = package; + + currentProcessError=""; + sendReply( "removeStarted(QString)", package ); + currentProcess->start(); +} + +void PackageHandler::sendReply( const QCString& msg, const QString& arg ) +{ +#ifndef QT_NO_COP + QCopEnvelope e( "QPE/Desktop", msg ); + e << arg; +#endif +} + +void PackageHandler::addPackageFiles( const QString &location, + const QString &listfile ) +{ + QFile f(listfile); +#ifndef Q_OS_WIN32 + //make a copy so we can remove the symlinks later + mkdir( ("/usr/lib/ipkg/info/"+location).ascii(), 0777 ); + system(("cp " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); +#else + QDir d; + //#### revise + qDebug("Copy file at %s: %s", __FILE__, __LINE__ ); + d.mkdir(("/usr/lib/ipkg/info/" + location).ascii()); + system(("copy " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); +#endif + + + if ( f.open(IO_ReadOnly) ) { + QTextStream ts(&f); + + QString s; + while ( !ts.eof() ) { // until end of file... + s = ts.readLine(); // line of text excluding '\n' + // for s, do link/mkdir. + if ( s.right(1) == "/" ) { + qDebug("do mkdir for %s", s.ascii()); +#ifndef Q_OS_WIN32 + mkdir( s.ascii(), 0777 ); + //possible optimization: symlink directories + //that don't exist already. -- Risky. +#else + d.mkdir( s.ascii()); +#endif + + } else { +#ifndef Q_OS_WIN32 + qDebug("do symlink for %s", s.ascii()); + symlink( (location + s).ascii(), s.ascii() ); +#else + qDebug("Copy file instead of a symlink for WIN32"); + if (!CopyFile((TCHAR*)qt_winTchar((location + s), TRUE), (TCHAR*)qt_winTchar(s, TRUE), FALSE)) + qWarning("Unable to create symlinkfor %s", + (location + s).ascii()); +#endif + } + } + f.close(); + } +} - QString output; - if ( proc.exec( "", output ) ) { - sendReply( "installDone(QString)", package ); +void PackageHandler::addPackages( const QString &location ) +{ + // get list of *.list in location/usr/lib/ipkg/info/*.list + QDir dir(location + "/usr/lib/ipkg/info", "*.list", // No tr + QDir::Name, QDir::Files); + if ( !dir.exists() ) + return; + + QStringList packages = dir.entryList(); + for ( QStringList::Iterator it = packages.begin(); + it != packages.end(); ++it ) { + addPackageFiles( location, *it ); } +} + + +void PackageHandler::cleanupPackageFiles( const QString &listfile ) +{ + QFile f(listfile); + + if ( f.open(IO_ReadOnly) ) { + QTextStream ts(&f); + + QString s; + while ( !ts.eof() ) { // until end of file... + s = ts.readLine(); // line of text excluding '\n' + // for s, do link/mkdir. + if ( s.right(1) == "/" ) { + //should rmdir if empty, after all files have been removed + } else { +#ifndef Q_OS_WIN32 + qDebug("remove symlink for %s", s.ascii()); + //check if it is a symlink first (don't remove /etc/passwd...) + char buf[10]; //we don't care about the contents + if ( ::readlink( s.ascii(),buf, 10 >= 0 ) ) + ::unlink( s.ascii() ); +#else + // ### revise + qWarning("Unable to remove symlink %s:%s", __FILE__, __LINE__); +#endif + } + } + f.close(); + + //remove the list file + ::unlink( listfile.ascii() ); + + } +} + +void PackageHandler::cleanupPackages( const QString &location ) +{ + // get list of *.list in location/usr/lib/ipkg/info/*.list + QDir dir( "/usr/lib/ipkg/info/"+location, "*.list", // No tr + QDir::Name, QDir::Files); + if ( !dir.exists() ) + return; + + QStringList packages = dir.entryList(); + for ( QStringList::Iterator it = packages.begin(); + it != packages.end(); ++it ) { + cleanupPackageFiles( *it ); + } + + //remove the backup directory + //### +} + +void PackageHandler::prepareInstall( const QString& size, const QString& path ) +{ + // Check whether there will be enough space to install the next package. + bool ok; + unsigned int s = size.toUInt( &ok ); + + if ( !ok ) + return; + + // Shamelessly stolen from the sysinfo application (Werner) +#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) + struct statfs fs; + if ( statfs( path.latin1(), &fs ) == 0 ) + if ( s > fs.f_bsize * fs.f_bavail ) { + //qDebug("############### Not enough space left ###############"); + mNoSpaceLeft = TRUE; + } +#endif +} + +void PackageHandler::iProcessExited() +{ + if ( currentProcess->normalExit() && currentProcess->exitStatus() == 0 ) + sendReply( "installDone(QString)", currentPackage ); else { - sendReply( "installFailed(QString)", package ); +#ifndef QT_NO_COP + QCopEnvelope e( "QPE/Desktop", "installFailed(QString,int,QString)" ); + e << currentPackage << currentProcess->exitStatus() + << currentProcessError; +#endif } + + delete currentProcess; + currentProcess = 0; + +#ifndef QT_NO_COP QCopEnvelope e("QPE/System", "linkChanged(QString)"); QString lf = QString::null; e << lf; - unlink( package ); +#endif + unlink( currentPackage ); } -void PackageSlave::removePackage( const QString &package ) +void PackageHandler::rmProcessExited() { - Process proc( QStringList() << "ipkg" << "remove" << package ); + if ( currentProcess->normalExit() && currentProcess->exitStatus() == 0 ) + sendReply( "removeDone(QString)", currentPackage ); + else + sendReply( "removeFailed(QString)", currentPackage ); - sendReply( "removeStarted(QString)", package ); - - QString output; - if ( proc.exec( "", output ) ) { - sendReply( "removeDone(QString)", package ); - } - else { - sendReply( "removeFailed(QString)", package ); - } +#ifndef QT_NO_COP QCopEnvelope e("QPE/System", "linkChanged(QString)"); QString lf = QString::null; e << lf; +#endif } -void PackageSlave::sendReply( const QCString& msg, const QString& arg ) +void PackageHandler::readyReadStdout() { - QCopEnvelope e( "QPE/Desktop", msg ); - e << arg; + while ( currentProcess->canReadLineStdout() ) { + QString line = currentProcess->readLineStdout(); + currentProcessError.append("OUT:"+line); + if ( line.contains( "Unpacking" ) ) // No tr + sendReply( "installStep(QString)", "one" ); // No tr + else if ( line.contains( "Configuring" ) ) // No tr + sendReply( "installStep(QString)", "two" ); // No tr + } +} + +void PackageHandler::readyReadStderr() +{ + while ( currentProcess->canReadLineStderr() ) { + QString line = currentProcess->readLineStderr(); + currentProcessError.append("ERR:"+line); + } +} + +void PackageHandler::redoPackages() +{ + //get list of filesystems + + //call cleanupPackages for the ones that have disappeared + + //call addPackageFiles for the new ones } diff --git a/core/launcher/qprocess_unix.cpp b/core/launcher/qprocess_unix.cpp index a07bf64..19a8c93 100644 --- a/core/launcher/qprocess_unix.cpp +++ b/core/launcher/qprocess_unix.cpp @@ -1,436 +1,439 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ //#include "qplatformdefs.h" // Solaris redefines connect -> __xnet_connect with _XOPEN_SOURCE_EXTENDED. #if defined(connect) #undef connect #endif #include "qprocess.h" #ifndef QT_NO_PROCESS #include "qapplication.h" #include "qqueue.h" #include "qlist.h" #include "qsocketnotifier.h" #include "qtimer.h" #include "qregexp.h" #include "qcleanuphandler_p.h" #include <stdlib.h> // ### FOR Qt 2.3 compat #include <unistd.h> #include <signal.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <sys/wait.h> #include <sys/fcntl.h> #include <errno.h> +#ifdef Q_OS_MACX +#include <sys/time.h> +#endif #include <sys/resource.h> #ifdef __MIPSEL__ # ifndef SOCK_DGRAM # define SOCK_DGRAM 1 # endif # ifndef SOCK_STREAM # define SOCK_STREAM 2 # endif #endif //#define QT_QPROCESS_DEBUG #ifdef Q_C_CALLBACKS extern "C" { #endif // Q_C_CALLBACKS #define QT_SIGNAL_RETTYPE void #define QT_SIGNAL_ARGS int #define QT_SIGNAL_IGNORE SIG_IGN QT_SIGNAL_RETTYPE qt_C_sigchldHnd(QT_SIGNAL_ARGS); QT_SIGNAL_RETTYPE qt_C_sigpipeHnd(QT_SIGNAL_ARGS); #ifdef Q_C_CALLBACKS } #endif // Q_C_CALLBACKS class QProc; class QProcessManager; class QProcessPrivate { public: QProcessPrivate(); ~QProcessPrivate(); void closeOpenSocketsForChild(); void newProc( pid_t pid, QProcess *process ); QByteArray bufStdout; QByteArray bufStderr; QQueue<QByteArray> stdinBuf; QSocketNotifier *notifierStdin; QSocketNotifier *notifierStdout; QSocketNotifier *notifierStderr; ssize_t stdinBufRead; QProc *proc; bool exitValuesCalculated; bool socketReadCalled; static QProcessManager *procManager; }; /*********************************************************************** * * QProc * **********************************************************************/ /* The class QProcess does not necessarily map exactly to the running child processes: if the process is finished, the QProcess class may still be there; furthermore a user can use QProcess to start more than one process. The helper-class QProc has the semantics that one instance of this class maps directly to a running child process. */ class QProc { public: QProc( pid_t p, QProcess *proc=0 ) : pid(p), process(proc) { #if defined(QT_QPROCESS_DEBUG) qDebug( "QProc: Constructor for pid %d and QProcess %p", pid, process ); #endif socketStdin = 0; socketStdout = 0; socketStderr = 0; } ~QProc() { #if defined(QT_QPROCESS_DEBUG) qDebug( "QProc: Destructor for pid %d and QProcess %p", pid, process ); #endif if ( process != 0 ) { if ( process->d->notifierStdin ) process->d->notifierStdin->setEnabled( FALSE ); if ( process->d->notifierStdout ) process->d->notifierStdout->setEnabled( FALSE ); if ( process->d->notifierStderr ) process->d->notifierStderr->setEnabled( FALSE ); process->d->proc = 0; } if( socketStdin != 0 ) ::close( socketStdin ); // ### close these sockets even on parent exit or is it better only on // sigchld (but what do I have to do with them on exit then)? if( socketStdout != 0 ) ::close( socketStdout ); if( socketStderr != 0 ) ::close( socketStderr ); } pid_t pid; int socketStdin; int socketStdout; int socketStderr; QProcess *process; }; /*********************************************************************** * * QProcessManager * **********************************************************************/ class QProcessManager : public QObject { Q_OBJECT public: QProcessManager(); ~QProcessManager(); void append( QProc *p ); void remove( QProc *p ); void cleanup(); public slots: void removeMe(); void sigchldHnd( int ); public: struct sigaction oldactChld; struct sigaction oldactPipe; QList<QProc> *procList; int sigchldFd[2]; }; QCleanupHandler<QProcessManager> qprocess_cleanup_procmanager; QProcessManager::QProcessManager() { procList = new QList<QProc>; procList->setAutoDelete( TRUE ); // The SIGCHLD handler writes to a socket to tell the manager that // something happened. This is done to get the processing in sync with the // event reporting. if ( ::socketpair( AF_UNIX, SOCK_STREAM, 0, sigchldFd ) ) { sigchldFd[0] = 0; sigchldFd[1] = 0; } else { #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcessManager: install socket notifier (%d)", sigchldFd[1] ); #endif QSocketNotifier *sn = new QSocketNotifier( sigchldFd[1], QSocketNotifier::Read, this ); connect( sn, SIGNAL(activated(int)), this, SLOT(sigchldHnd(int)) ); sn->setEnabled( TRUE ); } // install a SIGCHLD handler and ignore SIGPIPE struct sigaction act; #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcessManager: install a SIGCHLD handler" ); #endif act.sa_handler = qt_C_sigchldHnd; sigemptyset( &(act.sa_mask) ); sigaddset( &(act.sa_mask), SIGCHLD ); act.sa_flags = SA_NOCLDSTOP; #if defined(SA_RESTART) act.sa_flags |= SA_RESTART; #endif if ( sigaction( SIGCHLD, &act, &oldactChld ) != 0 ) qWarning( "Error installing SIGCHLD handler" ); #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcessManager: install a SIGPIPE handler (SIG_IGN)" ); #endif /* Using qt_C_sigpipeHnd rather than SIG_IGN is a workaround for a strange problem where GNU tar (called by backuprestore) would hang on filesystem-full. Strangely, the qt_C_sigpipeHnd is never even called, yet this avoids the hang. */ act.sa_handler = qt_C_sigpipeHnd; sigemptyset( &(act.sa_mask) ); sigaddset( &(act.sa_mask), SIGPIPE ); act.sa_flags = 0; if ( sigaction( SIGPIPE, &act, &oldactPipe ) != 0 ) qWarning( "Error installing SIGPIPE handler" ); } QProcessManager::~QProcessManager() { delete procList; if ( sigchldFd[0] != 0 ) ::close( sigchldFd[0] ); if ( sigchldFd[1] != 0 ) ::close( sigchldFd[1] ); // restore SIGCHLD handler #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcessManager: restore old sigchild handler" ); #endif if ( sigaction( SIGCHLD, &oldactChld, 0 ) != 0 ) qWarning( "Error restoring SIGCHLD handler" ); #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcessManager: restore old sigpipe handler" ); #endif if ( sigaction( SIGPIPE, &oldactPipe, 0 ) != 0 ) qWarning( "Error restoring SIGPIPE handler" ); } void QProcessManager::append( QProc *p ) { procList->append( p ); #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcessManager: append process (procList.count(): %d)", procList->count() ); #endif } void QProcessManager::remove( QProc *p ) { procList->remove( p ); #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcessManager: remove process (procList.count(): %d)", procList->count() ); #endif cleanup(); } void QProcessManager::cleanup() { if ( procList->count() == 0 ) { QTimer::singleShot( 0, this, SLOT(removeMe()) ); } } void QProcessManager::removeMe() { if ( procList->count() == 0 ) { qprocess_cleanup_procmanager.remove( &QProcessPrivate::procManager ); QProcessPrivate::procManager = 0; delete this; } } void QProcessManager::sigchldHnd( int fd ) { char tmp; ::read( fd, &tmp, sizeof(tmp) ); #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcessManager::sigchldHnd()" ); #endif QProc *proc; QProcess *process; bool removeProc; proc = procList->first(); while ( proc != 0 ) { removeProc = FALSE; process = proc->process; QProcess *process_exit_notify=0; if ( process != 0 ) { if ( !process->isRunning() ) { #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcessManager::sigchldHnd() (PID: %d): process exited (QProcess available)", proc->pid ); #endif // read pending data int nbytes = 0; if ( ::ioctl(proc->socketStdout, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) { #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcessManager::sigchldHnd() (PID: %d): reading %d bytes of pending data on stdout", proc->pid, nbytes ); #endif process->socketRead( proc->socketStdout ); } nbytes = 0; if ( ::ioctl(proc->socketStderr, FIONREAD, (char*)&nbytes)==0 && nbytes>0 ) { #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcessManager::sigchldHnd() (PID: %d): reading %d bytes of pending data on stderr", proc->pid, nbytes ); #endif process->socketRead( proc->socketStderr ); } if ( process->notifyOnExit ) process_exit_notify = process; removeProc = TRUE; } } else { int status; if ( ::waitpid( proc->pid, &status, WNOHANG ) == proc->pid ) { #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcessManager::sigchldHnd() (PID: %d): process exited (QProcess not available)", proc->pid ); #endif removeProc = TRUE; } } if ( removeProc ) { QProc *oldproc = proc; proc = procList->next(); remove( oldproc ); } else { proc = procList->next(); } if ( process_exit_notify ) emit process_exit_notify->processExited(); } } #include "qprocess_unix.moc" /*********************************************************************** * * QProcessPrivate * **********************************************************************/ QProcessManager *QProcessPrivate::procManager = 0; QProcessPrivate::QProcessPrivate() { #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcessPrivate: Constructor" ); #endif stdinBufRead = 0; notifierStdin = 0; notifierStdout = 0; notifierStderr = 0; exitValuesCalculated = FALSE; socketReadCalled = FALSE; proc = 0; } QProcessPrivate::~QProcessPrivate() { #if defined(QT_QPROCESS_DEBUG) qDebug( "QProcessPrivate: Destructor" ); #endif if ( proc != 0 ) { if ( proc->socketStdin != 0 ) { ::close( proc->socketStdin ); proc->socketStdin = 0; } proc->process = 0; } while ( !stdinBuf.isEmpty() ) { delete stdinBuf.dequeue(); } delete notifierStdin; delete notifierStdout; delete notifierStderr; } /* Closes all open sockets in the child process that are not needed by the child process. Otherwise one child may have an open socket on standard input, etc. of another child. */ void QProcessPrivate::closeOpenSocketsForChild() { if ( procManager != 0 ) { if ( procManager->sigchldFd[0] != 0 ) ::close( procManager->sigchldFd[0] ); if ( procManager->sigchldFd[1] != 0 ) ::close( procManager->sigchldFd[1] ); // close also the sockets from other QProcess instances QProc *proc; diff --git a/core/launcher/server.pro b/core/launcher/server.pro index 93baeb4..0513536 100644 --- a/core/launcher/server.pro +++ b/core/launcher/server.pro @@ -1,120 +1,125 @@ TEMPLATE = app CONFIG += qtopia warn_on release DESTDIR = $$(OPIEDIR)/bin HEADERS += server.h \ serverinterface.h \ launchertab.h \ documentlist.h \ appicons.h \ taskbar.h \ runningappbar.h \ applauncher.h \ stabmon.h \ inputmethods.h \ systray.h \ wait.h \ shutdownimpl.h \ launcher.h \ launcherview.h \ $$(OPIEDIR)/core/apps/calibrate/calibrate.h \ startmenu.h \ transferserver.h \ qcopbridge.h \ packageslave.h \ irserver.h \ firstuse.h \ $$(OPIEDIR)/rsync/buf.h \ $$(OPIEDIR)/rsync/checksum.h \ $$(OPIEDIR)/rsync/command.h \ $$(OPIEDIR)/rsync/emit.h \ $$(OPIEDIR)/rsync/job.h \ $$(OPIEDIR)/rsync/netint.h \ $$(OPIEDIR)/rsync/protocol.h \ $$(OPIEDIR)/rsync/prototab.h \ $$(OPIEDIR)/rsync/rsync.h \ $$(OPIEDIR)/rsync/search.h \ $$(OPIEDIR)/rsync/stream.h \ $$(OPIEDIR)/rsync/sumset.h \ $$(OPIEDIR)/rsync/trace.h \ $$(OPIEDIR)/rsync/types.h \ $$(OPIEDIR)/rsync/util.h \ $$(OPIEDIR)/rsync/whole.h \ $$(OPIEDIR)/rsync/config_rsync.h \ $$(OPIEDIR)/rsync/qrsync.h \ syncdialog.h \ serverapp.h \ launcherglobal.h \ qprocess.h \ screensaver.h SOURCES += server.cpp \ serverinterface.cpp \ launchertab.cpp \ documentlist.cpp \ appicons.cpp \ taskbar.cpp \ runningappbar.cpp \ applauncher.cpp \ stabmon.cpp \ inputmethods.cpp \ systray.cpp \ wait.cpp \ shutdownimpl.cpp \ launcher.cpp \ launcherview.cpp \ $$(OPIEDIR)/core/apps/calibrate/calibrate.cpp \ transferserver.cpp \ packageslave.cpp \ irserver.cpp \ qcopbridge.cpp \ startmenu.cpp \ main.cpp \ firstuse.cpp \ $$(OPIEDIR)/rsync/base64.c \ $$(OPIEDIR)/rsync/buf.c \ $$(OPIEDIR)/rsync/checksum.c \ $$(OPIEDIR)/rsync/command.c \ $$(OPIEDIR)/rsync/delta.c \ $$(OPIEDIR)/rsync/emit.c \ $$(OPIEDIR)/rsync/hex.c \ $$(OPIEDIR)/rsync/job.c \ $$(OPIEDIR)/rsync/mdfour.c \ $$(OPIEDIR)/rsync/mksum.c \ $$(OPIEDIR)/rsync/msg.c \ $$(OPIEDIR)/rsync/netint.c \ $$(OPIEDIR)/rsync/patch.c \ $$(OPIEDIR)/rsync/prototab.c \ $$(OPIEDIR)/rsync/readsums.c \ $$(OPIEDIR)/rsync/scoop.c \ $$(OPIEDIR)/rsync/search.c \ $$(OPIEDIR)/rsync/stats.c \ $$(OPIEDIR)/rsync/stream.c \ $$(OPIEDIR)/rsync/sumset.c \ $$(OPIEDIR)/rsync/trace.c \ $$(OPIEDIR)/rsync/tube.c \ $$(OPIEDIR)/rsync/util.c \ $$(OPIEDIR)/rsync/version.c \ $$(OPIEDIR)/rsync/whole.c \ $$(OPIEDIR)/rsync/qrsync.cpp \ syncdialog.cpp \ serverapp.cpp \ launcherglobal.cpp \ qprocess.cpp \ qprocess_unix.cpp \ screensaver.cpp INCLUDEPATH += $(OPIEDIR)/core/apps/calibrate DEPENDPATH += $(OPIEDIR)/core/apps/calibrate INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/rsync DEPENDPATH += $(OPIEDIR)/rsync TARGET = qpe -LIBS += -lcrypt -lqpe -lopie +CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) +contains( CONFTEST, y ){ + LIBS += -lqpe -lopie +}else{ + LIBS += -lcrypt -lqpe -lopie +} include ( $(OPIEDIR)/include.pro ) diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp index 014418d..08ae885 100644 --- a/core/launcher/startmenu.cpp +++ b/core/launcher/startmenu.cpp @@ -1,333 +1,337 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #define INCLUDE_MENUITEM_DEF #include "startmenu.h" #include <qtopia/qpeapplication.h> #include <qtopia/config.h> #include <qtopia/applnk.h> #include <qtopia/global.h> #include <qtopia/resource.h> #include <qtopia/mimetype.h> #include <qtopia/qlibrary.h> #include <qdict.h> #include <qdir.h> #include <qpainter.h> #include <stdlib.h> void StartPopupMenu::keyPressEvent( QKeyEvent *e ) { if ( e->key() == Key_F33 || e->key() == Key_Space ) { // "OK" button, little hacky QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0); QPopupMenu::keyPressEvent( &ke ); } else { QPopupMenu::keyPressEvent( e ); } } //--------------------------------------------------------------------------- StartMenu::StartMenu(QWidget *parent) : QLabel( parent ) { startButtonPixmap = "go"; // No tr int sz = AppLnk::smallIconSize()+3; QPixmap pm; pm.convertFromImage(Resource::loadImage(startButtonPixmap).smoothScale(sz,sz)); setPixmap(pm); setFocusPolicy( NoFocus ); launchMenu = 0; refreshMenu(); } void StartMenu::mousePressEvent( QMouseEvent * ) { launch(); } StartMenu::~StartMenu() { clearApplets(); } void StartMenu::createMenu() { clearApplets(); delete launchMenu; launchMenu = new StartPopupMenu( this ); loadMenu( launchMenu ); loadApplets(); bool result = nother || ntabs || m_applets.count(); if ( result ) connect( launchMenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); } void StartMenu::refreshMenu() { Config cfg("Taskbar"); cfg.setGroup("Menu"); bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE); bool lot = cfg.readBoolEntry("LauncherOther",TRUE); bool lt = ltabs || lot; if ( launchMenu && !lt ) return; // nothing to do if ( launchMenu ) { int i; /* find the first entry we want to remove */ for (i=0; i<(int)launchMenu->count(); i++) { QMenuItem* item = launchMenu->findItem(launchMenu->idAt(i)); if ( item && item->id() >= 0 && item->id() < ntabs ) { break; } if ( item && item->isSeparator() ) { i++; break; } } /* remove them */ while (i<(int)launchMenu->count()) launchMenu->removeItemAt(i); loadMenu(launchMenu); addApplets(launchMenu); } else { createMenu(); } } void StartMenu::itemSelected( int id ) { if ( id >= 0 && id < ntabs ) { emit tabSelected(tabs[id]); } else if ( id >= 20 && id < 20+nother ) { other.at(id-20)->execute(); }else { MenuApplet *applet = m_applets.find ( id ); if ( applet ) { qWarning("activated"); applet-> iface-> activated(); } } } bool StartMenu::loadMenu( QPopupMenu *menu ) { Config cfg("Taskbar"); cfg.setGroup("Menu"); bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE); bool lot = cfg.readBoolEntry("LauncherOther",TRUE); bool sepfirst = !ltabs && !lot; tabs.clear(); other.setAutoDelete(TRUE); other.clear(); ntabs = 0; nother = 0; bool f=TRUE; if ( ltabs || lot ) { QDir dir( MimeType::appsFolderName(), QString::null, QDir::Name ); for (int i=0; i<(int)dir.count(); i++) { QString d = dir[i]; Config cfg(dir.path()+"/"+d+"/.directory",Config::File); if ( cfg.isValid() ) { QString nm = cfg.readEntry("Name"); QString ic = cfg.readEntry("Icon"); if ( !!nm && !!ic ) { tabs.append(d); menu->insertItem( Resource::loadIconSet(ic), nm, ntabs++ ); } } else if ( lot && d.right(8)==".desktop") { AppLnk* applnk = new AppLnk(dir.path()+"/"+d); if ( applnk->isValid() ) { if ( applnk->type() == "Separator" ) { // No tr if ( lot ) { menu->insertSeparator(); sepfirst = f && !ltabs; } delete applnk; } else { f = FALSE; other.append(applnk); menu->insertItem( Resource::loadIconSet(applnk->icon()), applnk->name(), 20+nother++ ); } } else { delete applnk; } } } if ( !menu->count() ) sepfirst = TRUE; } launchMenu->setName(sepfirst ? "accessories" : "accessories_need_sep"); // No tr return (nother || ntabs ); } void StartMenu::launch() { int y = mapToGlobal( QPoint() ).y() - launchMenu->sizeHint().height(); if ( launchMenu->isVisible() ) launchMenu->hide(); else launchMenu->popup( QPoint( 1, y ) ); } static int compareAppletPositions(const void *a, const void *b) { const MenuApplet* aa = *(const MenuApplet**)a; const MenuApplet* ab = *(const MenuApplet**)b; int d = aa->iface->position() - ab->iface->position(); if ( d ) return d; return QString::compare(aa->library->library(),ab->library->library()); } void StartMenu::clearApplets() { if (launchMenu ) launchMenu-> hide(); for ( QIntDictIterator<MenuApplet> it ( m_applets ); it. current ( ); ++it ) { MenuApplet *applet = it. current ( ); if ( launchMenu ) { launchMenu-> removeItem ( applet-> id ); delete applet-> popup; } applet-> iface-> release(); applet-> library-> unload(); delete applet-> library; } m_applets.clear(); } void StartMenu::loadApplets() { Config cfg( "StartMenu" ); cfg.setGroup( "Applets" ); // SafeMode causes too much problems, so we disable it for now -- // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02 // removed in the remerge PluginManager could handle it // we don't currently use it -zecke QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); QString lang = getenv( "LANG" ); QString path = QPEApplication::qpeDir() + "/plugins/applets"; +#ifdef Q_OS_MACX + QDir dir( path, "lib*.dylib" ); +#else QDir dir( path, "lib*.so" ); +#endif /* Q_OS_MACX */ QStringList list = dir.entryList(); QStringList::Iterator it; int napplets=0; MenuApplet* *xapplets = new MenuApplet*[list.count()]; for ( it = list.begin(); it != list.end(); ++it ) { if ( exclude.find( *it ) != exclude.end() ) continue; MenuAppletInterface *iface = 0; QLibrary *lib = new QLibrary( path + "/" + *it ); if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { MenuApplet *applet = new MenuApplet; xapplets[napplets++] = applet; applet->library = lib; applet->iface = iface; QTranslator *trans = new QTranslator(qApp); QString type = (*it).left( (*it).find(".") ); QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; if ( trans->load( tfn )) qApp->installTranslator( trans ); else delete trans; } else { exclude += *it; delete lib; } } cfg.writeEntry( "ExcludeApplets", exclude, ',' ); qsort(xapplets,napplets,sizeof(m_applets[0]),compareAppletPositions); int foo = ( launchMenu-> count ( )) ? launchMenu-> insertSeparator ( ) : 0; while (napplets--) { MenuApplet *applet = xapplets[napplets]; applet-> popup = applet-> iface-> popup ( this ); if ( applet-> popup ) applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ), applet-> popup ); else applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ) ); m_applets.insert ( applet-> id, new MenuApplet(*applet)); } delete [] xapplets; } /* * Launcher calls loadMenu too often fix that */ void StartMenu::addApplets(QPopupMenu* pop) { QIntDict<MenuApplet> dict; if( pop-> count ( )) pop-> insertSeparator ( ); for ( QIntDictIterator<MenuApplet> it ( m_applets ); it. current ( ); ++it ) { MenuApplet *applet = it. current ( ); if ( applet-> popup ) applet-> id = pop-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ), applet-> popup ); else applet-> id = pop-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ) ); dict.insert( applet->id, new MenuApplet(*applet) ); } /* need to update the key */ m_applets.setAutoDelete( true ); m_applets.clear(); m_applets.setAutoDelete( false ); m_applets = dict; } diff --git a/core/launcher/systray.cpp b/core/launcher/systray.cpp index 6122770..691f6b8 100644 --- a/core/launcher/systray.cpp +++ b/core/launcher/systray.cpp @@ -1,149 +1,154 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include <qtopia/qpeapplication.h> #include <qtopia/qlibrary.h> #include <qtopia/config.h> #include <qlayout.h> #include <qdir.h> #include <qmessagebox.h> #include <qtranslator.h> #include "systray.h" #include <stdlib.h> /* ### Single build floppies ### */ #if 0 #ifdef QT_NO_COMPONENTS #include "../plugins/applets/clockapplet/clockappletimpl.h" #endif #endif SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0) { //setFrameStyle( QFrame::Panel | QFrame::Sunken ); loadApplets(); } SysTray::~SysTray() { clearApplets(); } static int compareAppletPositions(const void *a, const void *b) { const TaskbarApplet* aa = *(const TaskbarApplet**)a; const TaskbarApplet* ab = *(const TaskbarApplet**)b; int d = ab->iface->position() - aa->iface->position(); if ( d ) return d; return QString::compare(ab->name,aa->name); } void SysTray::loadApplets() { hide(); clearApplets(); addApplets(); } void SysTray::clearApplets() { #ifndef QT_NO_COMPONENTS /* * Note on clearing. SOme applets delete their * applets themselves some don't do it * and on restart this can crash. If we delete it * here we might end up in a double deletion. We could * use QGuardedPtr but that would be one QOBject * for every applet more but only useful for restart */ QValueList<TaskbarApplet>::Iterator mit; for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) { (*mit).iface->release(); (*mit).library->unload(); delete (*mit).library; } #endif appletList.clear(); if ( layout ) delete layout; layout = new QHBoxLayout( this, 0, 1 ); layout->setAutoAdd(TRUE); } void SysTray::addApplets() { hide(); #ifndef QT_NO_COMPONENTS Config cfg( "Taskbar" ); cfg.setGroup( "Applets" ); QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); QString lang = getenv( "LANG" ); QString path = QPEApplication::qpeDir() + "/plugins/applets"; +#ifdef Q_OS_MACX + QDir dir( path, "lib*.dylib" ); +#else QDir dir( path, "lib*.so" ); +#endif /* Q_OS_MACX */ QStringList list = dir.entryList(); QStringList::Iterator it; int napplets=0; TaskbarApplet* *applets = new TaskbarApplet*[list.count()]; for ( it = list.begin(); it != list.end(); ++it ) { if ( exclude.find( *it ) != exclude.end() ) continue; + qWarning( "Found Applet: %s", (*it).latin1() ); TaskbarAppletInterface *iface = 0; QLibrary *lib = new QLibrary( path + "/" + *it ); if (( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { TaskbarApplet *applet = new TaskbarApplet; applets[napplets++] = applet; applet->library = lib; applet->iface = iface; QTranslator *trans = new QTranslator(qApp); QString type = (*it).left( (*it).find(".") ); QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; if ( trans->load( tfn )) qApp->installTranslator( trans ); else delete trans; } else { exclude += *it; delete lib; } } cfg.writeEntry( "ExcludeApplets", exclude, ',' ); qsort(applets,napplets,sizeof(applets[0]),compareAppletPositions); while (napplets--) { TaskbarApplet *applet = applets[napplets]; applet->applet = applet->iface->applet( this ); appletList.append(*applet); } delete [] applets; #else /* ## FIXME single app */ TaskbarApplet * const applet = new TaskbarApplet(); applet->iface = new ClockAppletImpl(); applet->applet = applet->iface->applet( this ); appletList.append( applet ); #endif show(); } diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp index c69df2d..439e110 100644 --- a/core/launcher/transferserver.cpp +++ b/core/launcher/transferserver.cpp @@ -1,416 +1,419 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ //#define _XOPEN_SOURCE #include <qtopia/global.h> #include <qtopia/qpeapplication.h> #ifndef Q_OS_WIN32 #include <pwd.h> #include <sys/types.h> #include <unistd.h> #include <stdlib.h> #include <time.h> + +#ifndef Q_OS_MACX #include <shadow.h> #include <crypt.h> +#endif /* Q_OS_MACX */ #else #include <stdlib.h> #include <time.h> #endif #if defined(_OS_LINUX_) #include <shadow.h> #endif #include <qdir.h> #include <qfile.h> #include <qtextstream.h> #include <qdatastream.h> #include <qmessagebox.h> #include <qstringlist.h> #include <qfileinfo.h> #include <qregexp.h> //#include <qtopia/qcopchannel_qws.h> #include <qtopia/process.h> #include <qtopia/global.h> #include <qtopia/config.h> #include <qtopia/private/contact.h> #include <qtopia/quuid.h> #include <qtopia/version.h> #ifdef Q_WS_QWS #include <qtopia/qcopenvelope_qws.h> #endif #include "launcherglobal.h" #include "transferserver.h" #include <qtopia/qprocess.h> const int block_size = 51200; TransferServer::TransferServer( Q_UINT16 port, QObject *parent, const char* name) : QServerSocket( port, 1, parent, name ) { connections.setAutoDelete( TRUE ); if ( !ok() ) qWarning( "Failed to bind to port %d", port ); } void TransferServer::authorizeConnections() { QListIterator<ServerPI> it(connections); while ( it.current() ) { if ( !it.current()->verifyAuthorised() ) { disconnect( it.current(), SIGNAL(connectionClosed(ServerPI *)), this, SLOT( closed(ServerPI *)) ); connections.removeRef( it.current() ); } else ++it; } } void TransferServer::closed(ServerPI *item) { connections.removeRef(item); } TransferServer::~TransferServer() { } void TransferServer::newConnection( int socket ) { ServerPI *ptr = new ServerPI( socket, this ); connect( ptr, SIGNAL(connectionClosed(ServerPI *)), this, SLOT( closed(ServerPI *)) ); connections.append( ptr ); } QString SyncAuthentication::serverId() { Config cfg("Security"); cfg.setGroup("Sync"); QString r = cfg.readEntry("serverid"); if ( r.isEmpty() ) { r = Opie::Global::uuid(); cfg.writeEntry("serverid", r ); } return r; } QString SyncAuthentication::ownerName() { QString vfilename = Global::applicationFileName("addressbook", "businesscard.vcf"); if (QFile::exists(vfilename)) { Contact c; c = Contact::readVCard( vfilename )[0]; return c.fullName(); } return QString::null; } QString SyncAuthentication::loginName() { struct passwd *pw = 0L; #ifndef Q_OS_WIN32 pw = getpwuid( geteuid() ); return QString::fromLocal8Bit( pw->pw_name ); #else //### revise return QString(); #endif } int SyncAuthentication::isAuthorized(QHostAddress peeraddress) { Config cfg("Security"); cfg.setGroup("Sync"); // QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0"); uint auth_peer = cfg.readNumEntry("auth_peer", 0xc0a80100); // QHostAddress allowed; // allowed.setAddress(allowedstr); // uint auth_peer = allowed.ip4Addr(); uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits", 24); uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined ? 0xffffffff : (((1 << auth_peer_bits) - 1) << (32 - auth_peer_bits)); return (peeraddress.ip4Addr() & mask) == auth_peer; } bool SyncAuthentication::checkUser( const QString& user ) { if ( user.isEmpty() ) return FALSE; QString euser = loginName(); return user == euser; } bool SyncAuthentication::checkPassword( const QString& password ) { #ifdef ALLOW_UNIX_USER_FTP // First, check system password... struct passwd *pw = 0; struct spwd *spw = 0; pw = getpwuid( geteuid() ); spw = getspnam( pw->pw_name ); QString cpwd = QString::fromLocal8Bit( pw->pw_passwd ); if ( cpwd == "x" && spw ) cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); // Note: some systems use more than crypt for passwords. QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); if ( cpwd == cpassword ) return TRUE; #endif static int lastdenial=0; static int denials=0; int now = time(0); // Detect old Qtopia Desktop (no password) if ( password.isEmpty() ) { if ( denials < 1 || now > lastdenial+600 ) { QMessageBox unauth( tr("Sync Connection"), tr("<p>An unauthorized system is requesting access to this device." "<p>If you are using a version of Qtopia Desktop older than 1.5.1, " "please upgrade."), QMessageBox::Warning, QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, 0, QString::null, TRUE, WStyle_StaysOnTop); unauth.setButtonText(QMessageBox::Cancel, tr("Deny")); unauth.exec(); denials++; lastdenial=now; } return FALSE; } // Second, check sync password... static int lock=0; if ( lock ) return FALSE; ++lock; /* * we need to support old Sync software and QtopiaDesktop */ if ( password.left(6) == "Qtopia" || password.left(6) == "rootme" ) { Config cfg( "Security" ); cfg.setGroup("Sync"); QStringList pwds = cfg.readListEntry("Passwords",' '); for (QStringList::ConstIterator it=pwds.begin(); it!=pwds.end(); ++it) { #ifndef Q_OS_WIN32 QString cpassword = QString::fromLocal8Bit( crypt( password.mid(8).local8Bit(), (*it).left(2).latin1() ) ); #else // ### revise QString cpassword(""); #endif if ( *it == cpassword ) { lock--; return TRUE; } } // Unrecognized system. Be careful... QMessageBox unrecbox( tr("Sync Connection"), tr( "<p>An unrecognized system is requesting access to this device." "<p>If you have just initiated a Sync for the first time, this is normal."), QMessageBox::Warning, QMessageBox::Cancel, QMessageBox::Yes, QMessageBox::NoButton, 0, QString::null, TRUE, WStyle_StaysOnTop); unrecbox.setButtonText(QMessageBox::Cancel, tr("Deny")); unrecbox.setButtonText(QMessageBox::Yes, tr("Allow")); if ( (denials > 2 && now < lastdenial+600) || unrecbox.exec() != QMessageBox::Yes) { denials++; lastdenial=now; lock--; return FALSE; } else { const char salty[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789/."; char salt[2]; salt[0]= salty[rand() % (sizeof(salty)-1)]; salt[1]= salty[rand() % (sizeof(salty)-1)]; #ifndef Q_OS_WIN32 QString cpassword = QString::fromLocal8Bit( crypt( password.mid(8).local8Bit(), salt ) ); #else //### revise QString cpassword(""); #endif denials=0; pwds.prepend(cpassword); cfg.writeEntry("Passwords",pwds,' '); lock--; return TRUE; } } lock--; return FALSE; } ServerPI::ServerPI( int socket, QObject *parent, const char* name ) : QSocket( parent, name ) , dtp( 0 ), serversocket( 0 ), waitsocket( 0 ), storFileSize(-1) { state = Connected; setSocket( socket ); peerport = peerPort(); peeraddress = peerAddress(); #ifndef INSECURE if ( !SyncAuthentication::isAuthorized(peeraddress) ) { state = Forbidden; startTimer( 0 ); } else #endif { connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); passiv = FALSE; for( int i = 0; i < 4; i++ ) wait[i] = FALSE; send( "220 Qtopia " QPE_VERSION " FTP Server" ); // No tr state = Wait_USER; dtp = new ServerDTP( this ); connect( dtp, SIGNAL( completed() ), SLOT( dtpCompleted() ) ); connect( dtp, SIGNAL( failed() ), SLOT( dtpFailed() ) ); connect( dtp, SIGNAL( error( int ) ), SLOT( dtpError( int ) ) ); directory = QDir::currentDirPath(); static int p = 1024; while ( !serversocket || !serversocket->ok() ) { delete serversocket; serversocket = new ServerSocket( ++p, this ); } connect( serversocket, SIGNAL( newIncomming( int ) ), SLOT( newConnection( int ) ) ); } } ServerPI::~ServerPI() { close(); dtp->close(); delete dtp; delete serversocket; } bool ServerPI::verifyAuthorised() { if ( !SyncAuthentication::isAuthorized(peerAddress()) ) { state = Forbidden; return FALSE; } return TRUE; } void ServerPI::connectionClosed() { // qDebug( "Debug: Connection closed" ); emit connectionClosed(this); } void ServerPI::send( const QString& msg ) { QTextStream os( this ); os << msg << endl; //qDebug( "Reply: %s", msg.latin1() ); } void ServerPI::read() { while ( canReadLine() ) process( readLine().stripWhiteSpace() ); } bool ServerPI::checkReadFile( const QString& file ) { QString filename; if ( file[0] != "/" ) filename = directory.path() + "/" + file; else filename = file; QFileInfo fi( filename ); return ( fi.exists() && fi.isReadable() ); } bool ServerPI::checkWriteFile( const QString& file ) { QString filename; if ( file[0] != "/" ) filename = directory.path() + "/" + file; else filename = file; QFileInfo fi( filename ); if ( fi.exists() ) if ( !QFile( filename ).remove() ) return FALSE; return TRUE; } void ServerPI::process( const QString& message ) { //qDebug( "Command: %s", message.latin1() ); // split message using "," as separator QStringList msg = QStringList::split( " ", message ); if ( msg.isEmpty() ) return; // command token QString cmd = msg[0].upper(); // argument token QString arg; if ( msg.count() >= 2 ) arg = msg[1]; // full argument string QString args; if ( msg.count() >= 2 ) { diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.pro b/core/multimedia/opieplayer/wavplugin/wavplugin.pro index 0366542..db41ad4 100644 --- a/core/multimedia/opieplayer/wavplugin/wavplugin.pro +++ b/core/multimedia/opieplayer/wavplugin/wavplugin.pro @@ -1,32 +1,32 @@ TEMPLATE = lib -CONFIG += qt warn_on release +CONFIG += qt plugin warn_on release HEADERS = wavplugin.h wavpluginimpl.h SOURCES = wavplugin.cpp wavpluginimpl.cpp TARGET = wavplugin DESTDIR = $(OPIEDIR)/plugins/codecs INCLUDEPATH += $(OPIEDIR)/include .. DEPENDPATH += ../$(OPIEDIR)/include .. LIBS += -lqpe VERSION = 1.0.0 TRANSLATIONS = ../../../../i18n/de/libwavplugin.ts \ ../../../../i18n/nl/libwavplugin.ts \ ../../../../i18n/da/libwavplugin.ts \ ../../../../i18n/xx/libwavplugin.ts \ ../../../../i18n/en/libwavplugin.ts \ ../../../../i18n/es/libwavplugin.ts \ ../../../../i18n/fr/libwavplugin.ts \ ../../../../i18n/hu/libwavplugin.ts \ ../../../../i18n/ja/libwavplugin.ts \ ../../../../i18n/ko/libwavplugin.ts \ ../../../../i18n/no/libwavplugin.ts \ ../../../../i18n/pl/libwavplugin.ts \ ../../../../i18n/pt/libwavplugin.ts \ ../../../../i18n/pt_BR/libwavplugin.ts \ ../../../../i18n/sl/libwavplugin.ts \ ../../../../i18n/zh_CN/libwavplugin.ts \ ../../../../i18n/zh_TW/libwavplugin.ts include ( $(OPIEDIR)/include.pro ) diff --git a/core/pim/today/plugins/addressbook/addressbook.pro b/core/pim/today/plugins/addressbook/addressbook.pro index 4ebbc9e..54aaff2 100644 --- a/core/pim/today/plugins/addressbook/addressbook.pro +++ b/core/pim/today/plugins/addressbook/addressbook.pro @@ -1,43 +1,43 @@ TEMPLATE = lib CONFIG -= moc -CONFIG += qt release +CONFIG += qt plugin release # Input HEADERS = addressplugin.h addresspluginimpl.h addresspluginconfig.h \ addresspluginwidget.h SOURCES = addressplugin.cpp addresspluginimpl.cpp addresspluginconfig.cpp \ addresspluginwidget.cpp INCLUDEPATH += $(OPIEDIR)/include \ ../ ../library DEPENDPATH += $(OPIEDIR)/include \ ../ ../library LIBS+= -lqpe -lopie DESTDIR = $(OPIEDIR)/plugins/today TARGET = todayaddressbookplugin TRANSLATIONS = ../../../../../i18n/de/libtodayaddressbookplugin.ts \ ../../../../../i18n/nl/libtodayaddressbookplugin.ts \ ../../../../../i18n/xx/libtodayaddressbookplugin.ts \ ../../../../../i18n/en/libtodayaddressbookplugin.ts \ ../../../../../i18n/es/libtodayaddressbookplugin.ts \ ../../../../../i18n/fr/libtodayaddressbookplugin.ts \ ../../../../../i18n/hu/libtodayaddressbookplugin.ts \ ../../../../../i18n/ja/libtodayaddressbookplugin.ts \ ../../../../../i18n/ko/libtodayaddressbookplugin.ts \ ../../../../../i18n/no/libtodayaddressbookplugin.ts \ ../../../../../i18n/pl/libtodayaddressbookplugin.ts \ ../../../../../i18n/pt/libtodayaddressbookplugin.ts \ ../../../../../i18n/pt_BR/libtodayaddressbookplugin.ts \ ../../../../../i18n/sl/libtodayaddressbookplugin.ts \ ../../../../../i18n/zh_CN/libtodayaddressbookplugin.ts \ ../../../../../i18n/zh_TW/libtodayaddressbookplugin.ts \ ../../../../../i18n/it/libtodayaddressbookplugin.ts \ ../../../../../i18n/da/libtodayaddressbookplugin.ts include ( $(OPIEDIR)/include.pro ) diff --git a/core/pim/today/plugins/datebook/datebook.pro b/core/pim/today/plugins/datebook/datebook.pro index e0a1dcb..2139f63 100644 --- a/core/pim/today/plugins/datebook/datebook.pro +++ b/core/pim/today/plugins/datebook/datebook.pro @@ -1,39 +1,39 @@ TEMPLATE = lib CONFIG -= moc -CONFIG += qt release +CONFIG += qt plugin release # Input HEADERS = datebookplugin.h datebookpluginimpl.h datebookpluginconfig.h \ datebookevent.h datebookpluginwidget.h SOURCES = datebookplugin.cpp datebookpluginimpl.cpp datebookpluginconfig.cpp \ datebookevent.cpp datebookpluginwidget.cpp INCLUDEPATH += $(OPIEDIR)/include \ ../ ../library DEPENDPATH += $(OPIEDIR)/include \ ../ ../library LIBS+= -lqpe -lopie DESTDIR = $(OPIEDIR)/plugins/today TARGET = todaydatebookplugin TRANSLATIONS = ../../../../../i18n/de/libtodaydatebookplugin.ts \ ../../../../../i18n/nl/libtodaydatebookplugin.ts \ ../../../../../i18n/xx/libtodaydatebookplugin.ts \ ../../../../../i18n/en/libtodaydatebookplugin.ts \ ../../../../../i18n/es/libtodaydatebookplugin.ts \ ../../../../../i18n/fr/libtodaydatebookplugin.ts \ ../../../../../i18n/hu/libtodaydatebookplugin.ts \ ../../../../../i18n/ja/libtodaydatebookplugin.ts \ ../../../../../i18n/ko/libtodaydatebookplugin.ts \ ../../../../../i18n/no/libtodaydatebookplugin.ts \ ../../../../../i18n/pl/libtodaydatebookplugin.ts \ ../../../../../i18n/pt/libtodaydatebookplugin.ts \ ../../../../../i18n/pt_BR/libtodaydatebookplugin.ts \ ../../../../../i18n/sl/libtodaydatebookplugin.ts \ ../../../../../i18n/zh_CN/libtodaydatebookplugin.ts \ ../../../../../i18n/zh_TW/libtodaydatebookplugin.ts \ ../../../../../i18n/it/libtodaydatebookplugin.ts \ ../../../../../i18n/da/libtodaydatebookplugin.ts include ( $(OPIEDIR)/include.pro ) diff --git a/core/pim/today/plugins/mail/mail.pro b/core/pim/today/plugins/mail/mail.pro index 70c484d..421b3a5 100644 --- a/core/pim/today/plugins/mail/mail.pro +++ b/core/pim/today/plugins/mail/mail.pro @@ -1,37 +1,37 @@ TEMPLATE = lib CONFIG -= moc -CONFIG += qt release +CONFIG += qt plugin release # Input HEADERS = mailplugin.h mailpluginimpl.h mailpluginwidget.h SOURCES = mailplugin.cpp mailpluginimpl.cpp mailpluginwidget.cpp INCLUDEPATH += $(OPIEDIR)/include \ ../ ../library DEPENDPATH += $(OPIEDIR)/include \ ../ ../library LIBS+= -lqpe -lopie DESTDIR = $(OPIEDIR)/plugins/today TARGET = todaymailplugin TRANSLATIONS = ../../../../../i18n/de/libtodaymailplugin.ts \ ../../../../../i18n/nl/libtodaymailplugin.ts \ ../../../../../i18n/xx/libtodaymailplugin.ts \ ../../../../../i18n/en/libtodaymailplugin.ts \ ../../../../../i18n/es/libtodaymailplugin.ts \ ../../../../../i18n/fr/libtodaymailplugin.ts \ ../../../../../i18n/hu/libtodaymailplugin.ts \ ../../../../../i18n/ja/libtodaymailplugin.ts \ ../../../../../i18n/ko/libtodaymailplugin.ts \ ../../../../../i18n/no/libtodaymailplugin.ts \ ../../../../../i18n/pl/libtodaymailplugin.ts \ ../../../../../i18n/pt/libtodaymailplugin.ts \ ../../../../../i18n/pt_BR/libtodaymailplugin.ts \ ../../../../../i18n/sl/libtodaymailplugin.ts \ ../../../../../i18n/zh_CN/libtodaymailplugin.ts \ ../../../../../i18n/zh_TW/libtodaymailplugin.ts \ ../../../../../i18n/it/libtodaymailplugin.ts \ ../../../../../i18n/da/libtodaymailplugin.ts include ( $(OPIEDIR)/include.pro ) diff --git a/core/pim/today/plugins/todolist/todolist.pro b/core/pim/today/plugins/todolist/todolist.pro index 31a6a27..c8730bb 100644 --- a/core/pim/today/plugins/todolist/todolist.pro +++ b/core/pim/today/plugins/todolist/todolist.pro @@ -1,40 +1,40 @@ TEMPLATE = lib CONFIG -= moc -CONFIG += qt release +CONFIG += qt plugin release # Input HEADERS = todoplugin.h todopluginimpl.h todopluginconfig.h \ todopluginwidget.h SOURCES = todoplugin.cpp todopluginimpl.cpp todopluginconfig.cpp \ todopluginwidget.cpp INCLUDEPATH += $(OPIEDIR)/include \ ../ ../library DEPENDPATH += $(OPIEDIR)/include \ ../ ../library LIBS+= -lqpe -lopie DESTDIR = $(OPIEDIR)/plugins/today TARGET = todaytodolistplugin TRANSLATIONS = ../../../../../i18n/de/libtodaytodolistplugin.ts \ ../../../../../i18n/nl/libtodaytodolistplugin.ts \ ../../../../../i18n/xx/libtodaytodolistplugin.ts \ ../../../../../i18n/en/libtodaytodolistplugin.ts \ ../../../../../i18n/es/libtodaytodolistplugin.ts \ ../../../../../i18n/fr/libtodaytodolistplugin.ts \ ../../../../../i18n/hu/libtodaytodolistplugin.ts \ ../../../../../i18n/ja/libtodaytodolistplugin.ts \ ../../../../../i18n/ko/libtodaytodolistplugin.ts \ ../../../../../i18n/no/libtodaytodolistplugin.ts \ ../../../../../i18n/pl/libtodaytodolistplugin.ts \ ../../../../../i18n/pt/libtodaytodolistplugin.ts \ ../../../../../i18n/pt_BR/libtodaytodolistplugin.ts \ ../../../../../i18n/sl/libtodaytodolistplugin.ts \ ../../../../../i18n/zh_CN/libtodaytodolistplugin.ts \ ../../../../../i18n/zh_TW/libtodaytodolistplugin.ts \ ../../../../../i18n/it/libtodaytodolistplugin.ts \ ../../../../../i18n/da/libtodaytodolistplugin.ts include ( $(OPIEDIR)/include.pro ) diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index f213943..cb18c1c 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp @@ -1,402 +1,409 @@ /* * today.cpp * * copyright : (c) 2002,2003 by Maximilian Reiß * email : harlekin@handhelds.org * */ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #define QTOPIA_INTERNAL_LANGLIST #include "today.h" #include <qpe/config.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/resource.h> #include <qpe/global.h> #include <qpe/qpeapplication.h> #include <qpe/contact.h> #include <qpe/timestring.h> #include <qdir.h> #include <qfile.h> #include <qtimer.h> #include <qwhatsthis.h> #include <qtranslator.h> struct TodayPlugin { TodayPlugin() : library( 0 ), iface( 0 ), guiPart( 0 ), guiBox( 0 ) {} QLibrary *library; QInterfacePtr<TodayPluginInterface> iface; TodayPluginObject *guiPart; QWidget *guiBox; QString name; bool active; bool excludeRefresh; int pos; }; static QValueList<TodayPlugin> pluginList; Today::Today( QWidget* parent, const char* name, WFlags fl ) : TodayBase( parent, name, fl ) { QObject::connect( (QObject*)ConfigButton, SIGNAL( clicked() ), this, SLOT( startConfig() ) ); QObject::connect( (QObject*)OwnerField, SIGNAL( clicked() ), this, SLOT( editCard() ) ); #if defined(Q_WS_QWS) #if !defined(QT_NO_COP) QCopChannel *todayChannel = new QCopChannel( "QPE/Today" , this ); connect ( todayChannel, SIGNAL( received( const QCString &, const QByteArray &) ), this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); #endif #endif setOwnerField(); m_refreshTimer = new QTimer( this ); connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); m_refreshTimer->start( 15000 ); //init(); loadPlugins(); showMaximized(); } /** * Qcop receive method. */ void Today::channelReceived( const QCString &msg, const QByteArray & data ) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "message(QString)" ) { QString message; stream >> message; setOwnerField( message ); } } void Today::setRefreshTimer( int interval ) { disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); // 0 is "never" case if ( !interval == 0 ) { connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); m_refreshTimer->changeInterval( interval ); } } /** * Initialises the owner field with the default value, the username */ void Today::setOwnerField() { QString file = Global::applicationFileName( "addressbook", "businesscard.vcf" ); if ( QFile::exists( file ) ) { Contact cont = Contact::readVCard( file )[0]; QString returnString = cont.fullName(); OwnerField->setText( "<b>" + tr ( "Owned by " ) + returnString + "</b>" ); } else { OwnerField->setText( "<b>" + tr ( "Please fill out the business card" ) + " </b>" ); } } /** * Set the owner field with a given QString, for example per qcop. */ void Today::setOwnerField( QString &message ) { if ( !message.isEmpty() ) { OwnerField->setText( "<b>" + message + "</b>" ); } } /** * Init stuff needed for today. Reads the config file. */ void Today::init() { // read config Config cfg( "today" ); cfg.setGroup( "Plugins" ); m_excludeApplets = cfg.readListEntry( "ExcludeApplets", ',' ); m_allApplets = cfg.readListEntry( "AllApplets", ',' ); cfg.setGroup( "General" ); m_iconSize = cfg.readNumEntry( "IconSize", 18 ); m_hideBanner = cfg.readNumEntry( "HideBanner", 0 ); setRefreshTimer( cfg.readNumEntry( "checkinterval", 15000 ) ); // set the date in top label QDate date = QDate::currentDate(); DateLabel->setText( QString( "<font color=#FFFFFF>" + TimeString::longDateString( date ) + "</font>" ) ); if ( layout ) { delete layout; } if ( m_hideBanner ) { Opiezilla->hide(); TodayLabel->hide(); } else { Opiezilla->show(); TodayLabel->show(); } layout = new QVBoxLayout( this ); layout->addWidget( Frame ); layout->addWidget( OwnerField ); } /** * Load the plugins */ void Today::loadPlugins() { init(); QValueList<TodayPlugin>::Iterator tit; if ( !pluginList.isEmpty() ) { for ( tit = pluginList.begin(); tit != pluginList.end(); ++tit ) { (*tit).guiBox->hide(); (*tit).guiBox->reparent( 0, QPoint( 0, 0 ) ); delete (*tit).guiBox; (*tit).library->unload(); delete (*tit).library; } pluginList.clear(); } QString path = QPEApplication::qpeDir() + "/plugins/today"; + qWarning("Searching for Plugins in: %s", path.latin1()); +#ifdef Q_OS_MACX + QDir dir( path, "lib*.dylib" ); +#else QDir dir( path, "lib*.so" ); +#endif QStringList list = dir.entryList(); QStringList::Iterator it; + qWarning("Found: %d entries !", list.count() ); + QMap<QString, TodayPlugin> tempList; for ( it = list.begin(); it != list.end(); ++it ) { QInterfacePtr<TodayPluginInterface> iface; QLibrary *lib = new QLibrary( path + "/" + *it ); qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); if ( lib->queryInterface( IID_TodayPluginInterface, (QUnknownInterface**)&iface ) == QS_OK ) { qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() ); qDebug( QString(*it) ); TodayPlugin plugin; plugin.library = lib; plugin.iface = iface; plugin.name = QString(*it); QString type = (*it).left( (*it).find(".") ); // grr, sharp rom does not know Global::languageList(); // QStringList langs = Global::languageList(); QString tfn = QPEApplication::qpeDir() + "/i18n/"; QDir langDir = tfn; QStringList langs = langDir.entryList("*", QDir::Dirs ); for (QStringList::ConstIterator lit = langs.begin(); lit!=langs.end(); ++lit) { QString lang = *lit; qDebug( "Languages: " + lang ); QTranslator * trans = new QTranslator( qApp ); QString tfn = QPEApplication::qpeDir()+"/i18n/" + lang + "/" + type + ".qm"; if ( trans->load( tfn ) ) { qApp->installTranslator( trans ); } else { delete trans; } } // find out if plugins should be shown if ( m_excludeApplets.grep( *it ).isEmpty() ) { plugin.active = true; } else { plugin.active = false; } plugin.guiPart = plugin.iface->guiPart(); plugin.excludeRefresh = plugin.guiPart->excludeFromRefresh(); // package the whole thing into a qwidget so it can be shown and hidden plugin.guiBox = new QWidget( this ); QHBoxLayout *boxLayout = new QHBoxLayout( plugin.guiBox ); QPixmap plugPix; plugPix.convertFromImage( Resource::loadImage( plugin.guiPart->pixmapNameWidget() ).smoothScale( m_iconSize, m_iconSize ), 0 ); OClickableLabel* plugIcon = new OClickableLabel( plugin.guiBox ); plugIcon->setPixmap( plugPix ); QWhatsThis::add( plugIcon, tr("Click here to launch the associated app") ); plugIcon->setName( plugin.guiPart->appName() ); connect( plugIcon, SIGNAL( clicked() ), this, SLOT( startApplication() ) ); // a scrollview for each plugin QScrollView* sv = new QScrollView( plugin.guiBox ); QWidget *plugWidget = plugin.guiPart->widget( sv->viewport() ); // not sure if that is good .-) sv->setMinimumHeight( 12 ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setHScrollBarMode( QScrollView::AlwaysOff ); sv->setFrameShape( QFrame::NoFrame ); sv->addChild( plugWidget ); // make sure the icon is on the top alligned boxLayout->addWidget( plugIcon, 0, AlignTop ); boxLayout->addWidget( sv, 0, AlignTop ); boxLayout->setStretchFactor( plugIcon, 1 ); boxLayout->setStretchFactor( sv, 9 ); // "prebuffer" it in one more list, to get the sorting done tempList.insert( plugin.name, plugin ); // on first start the list is off course empty if ( m_allApplets.isEmpty() ) { layout->addWidget( plugin.guiBox ); pluginList.append( plugin ); } // if plugin is not yet in the list, add it to the layout too else if ( !m_allApplets.contains( plugin.name ) ) { layout->addWidget( plugin.guiBox ); pluginList.append( plugin ); } } else { qDebug( "could not recognize %s", QString( path + "/" + *it ).latin1() ); delete lib; } } if ( !m_allApplets.isEmpty() ) { TodayPlugin tempPlugin; QStringList::Iterator stringit; for( stringit = m_allApplets.begin(); stringit != m_allApplets.end(); ++stringit ) { tempPlugin = ( tempList.find( *stringit ) ).data(); if ( !( (tempPlugin.name).isEmpty() ) ) { layout->addWidget( tempPlugin.guiBox ); pluginList.append( tempPlugin ); } } } draw(); } /** * Repaint method. Reread all fields. */ void Today::draw() { if ( pluginList.count() == 0 ) { QLabel *noPlugins = new QLabel( this ); noPlugins->setText( tr( "No plugins found" ) ); layout->addWidget( noPlugins ); return; } uint count = 0; TodayPlugin plugin; for ( uint i = 0; i < pluginList.count(); i++ ) { plugin = pluginList[i]; if ( plugin.active ) { // qDebug( plugin.name + " is ACTIVE " ); plugin.guiBox->show(); } else { // qDebug( plugin.name + " is INACTIVE" ); plugin.guiBox->hide(); } count++; } if ( count == 0 ) { QLabel *noPluginsActive = new QLabel( this ); noPluginsActive->setText( tr( "No plugins activated" ) ); layout->addWidget( noPluginsActive ); } layout->addStretch(0); } /** * The method for the configuration dialog. */ void Today::startConfig() { // disconnect timer to prevent problems while being on config dialog disconnect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); m_refreshTimer->stop( ); TodayConfig conf( this, "dialog", true ); TodayPlugin plugin; QList<TodayConfigWidget> configWidgetList; for ( int i = pluginList.count() - 1; i >= 0; i-- ) { plugin = pluginList[i]; // load the config widgets in the tabs if ( plugin.guiPart->configWidget( this ) != 0l ) { TodayConfigWidget* widget = plugin.guiPart->configWidget( conf.TabWidget3 ); configWidgetList.append( widget ); conf.TabWidget3->addTab( widget, plugin.guiPart->pixmapNameConfig() , plugin.guiPart->appName() ); } // set the order/activate tab conf.pluginManagement( plugin.name, plugin.guiPart->pluginName(), Resource::loadPixmap( plugin.guiPart->pixmapNameWidget() ) ); } if ( conf.exec() == QDialog::Accepted ) { conf.writeConfig(); TodayConfigWidget *confWidget; for ( confWidget = configWidgetList.first(); confWidget != 0; confWidget = configWidgetList.next() ) { confWidget->writeConfig(); } loadPlugins(); } else { // since refresh is not called in that case , reconnect the signal m_refreshTimer->start( 15000 ); // get the config value in here later connect( m_refreshTimer, SIGNAL( timeout() ), this, SLOT( refresh() ) ); } } /** * Refresh for the view. Reload all applets * */ void Today::refresh() { init(); QValueList<TodayPlugin>::Iterator it; for ( it = pluginList.begin(); it != pluginList.end(); ++it ) { if ( !(*it).excludeRefresh ) { (*it).guiPart->refresh(); layout->addWidget( (*it).guiBox ); qDebug( "refresh" ); } } layout->addStretch(0); } void Today::startApplication() { QCopEnvelope e( "QPE/System", "execute(QString)" ); e << QString( sender()->name() ); } /** * launch addressbook (personal card) */ void Today::editCard() { QCopEnvelope env( "QPE/Application/addressbook", "editPersonalAndClose()" ); } Today::~Today() { } diff --git a/core/qws/transferserver.cpp b/core/qws/transferserver.cpp index 0337a94..239c824 100644 --- a/core/qws/transferserver.cpp +++ b/core/qws/transferserver.cpp @@ -1,500 +1,519 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #define _XOPEN_SOURCE #include <pwd.h> #include <sys/types.h> #include <unistd.h> #include <stdlib.h> #include <time.h> + +#ifndef Q_OS_MACX #include <shadow.h> +#endif /* Q_OS_MACX */ /* we need the _OS_LINUX stuff first ! */ #include <qglobal.h> #ifndef _OS_LINUX_ +// Is anybody able to review this ? The include "uuid/uuid.h" couldn't be found +// anywhere ? Therfore I removed it completely.. +// I think it should be made permanentyl !? (eilers) +#warning "Where should uuid/uuid.h be found ? Removed this part .. (eilers)" +#if 0 extern "C" { #include <uuid/uuid.h> #define UUID_H_INCLUDED } +#endif + #endif // not defined linux #if defined(_OS_LINUX_) #include <shadow.h> +#elif defined(Q_OS_MACX) +#include <stdlib.h> #endif #include <qdir.h> #include <qfile.h> #include <qtextstream.h> #include <qdatastream.h> #include <qmessagebox.h> #include <qstringlist.h> #include <qfileinfo.h> #include <qregexp.h> //#include <qpe/qcopchannel_qws.h> #include <qpe/process.h> #include <qpe/global.h> #include <qpe/config.h> #include <qpe/contact.h> #include <qpe/quuid.h> #include <qpe/version.h> #include <qpe/qcopenvelope_qws.h> #include "transferserver.h" #include <opie/oprocess.h> const int block_size = 51200; TransferServer::TransferServer( Q_UINT16 port, QObject *parent , const char* name ) : QServerSocket( port, 1, parent, name ) { if ( !ok() ) qWarning( "Failed to bind to port %d", port ); } TransferServer::~TransferServer() { } void TransferServer::newConnection( int socket ) { (void) new ServerPI( socket, this ); } /* * small class in anonymous namespace * to generate a QUUid for us */ namespace { struct UidGen { QString uuid(); }; -#if !defined(_OS_LINUX_) - +#if defined(Q_OS_MACX) QString UidGen::uuid() { - uuid_t uuid; - uuid_generate( uuid ); - return QUUid( uuid ).toString(); + srandom( random() ); + QString numStr = QString::number( random() ); + + return "{" + numStr + "}"; } -#else +#elif defined(_OS_LINUX_) /* * linux got a /proc/sys/kernel/random/uuid file * it'll generate the uuids for us */ QString UidGen::uuid() { QFile file( "/proc/sys/kernel/random/uuid" ); if (!file.open(IO_ReadOnly ) ) return QString::null; QTextStream stream(&file); return "{" + stream.read().stripWhiteSpace() + "}"; } +#else +QString UidGen::uuid() +{ + uuid_t uuid; + ::uuid_generate( uuid ); + return QUUid( uuid ).toString(); +} #endif } QString SyncAuthentication::serverId() { Config cfg("Security"); cfg.setGroup("Sync"); QString r = cfg.readEntry("serverid"); if ( r.isEmpty() ) { UidGen gen; r = gen.uuid(); cfg.writeEntry("serverid", r ); } return r; } QString SyncAuthentication::ownerName() { QString vfilename = Global::applicationFileName("addressbook", "businesscard.vcf"); if (QFile::exists(vfilename)) { Contact c; c = Contact::readVCard( vfilename )[0]; return c.fullName(); } return ""; } QString SyncAuthentication::loginName() { struct passwd *pw; pw = getpwuid( geteuid() ); return QString::fromLocal8Bit( pw->pw_name ); } int SyncAuthentication::isAuthorized(QHostAddress peeraddress) { Config cfg("Security"); cfg.setGroup("Sync"); // QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0"); uint auth_peer = cfg.readNumEntry("auth_peer", 0xc0a80100); // QHostAddress allowed; // allowed.setAddress(allowedstr); // uint auth_peer = allowed.ip4Addr(); uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits", 24); uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined ? 0xffffffff : (((1 << auth_peer_bits) - 1) << (32 - auth_peer_bits)); return (peeraddress.ip4Addr() & mask) == auth_peer; } bool SyncAuthentication::checkUser( const QString& user ) { if ( user.isEmpty() ) return FALSE; QString euser = loginName(); return user == euser; } bool SyncAuthentication::checkPassword( const QString& password ) { #ifdef ALLOW_UNIX_USER_FTP // First, check system password... struct passwd *pw = 0; struct spwd *spw = 0; pw = getpwuid( geteuid() ); spw = getspnam( pw->pw_name ); QString cpwd = QString::fromLocal8Bit( pw->pw_passwd ); if ( cpwd == "x" && spw ) cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); // Note: some systems use more than crypt for passwords. QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); if ( cpwd == cpassword ) return TRUE; #endif static int lastdenial = 0; static int denials = 0; int now = time(0); // Detect old Qtopia Desktop (no password) if ( password.isEmpty() ) { if ( denials < 1 || now > lastdenial + 600 ) { QMessageBox::warning( 0, tr("Sync Connection"), tr("<p>An unauthorized system is requesting access to this device." "<p>If you are using a version of Qtopia Desktop older than 1.5.1, " "please upgrade."), tr("Deny") ); denials++; lastdenial = now; } return FALSE; } // Second, check sync password... QString pass = password.left(6); /* old QtopiaDesktops are sending * rootme newer versions got a Qtopia * prefixed. Qtopia prefix will suceed * until the sync software syncs up * FIXME */ if ( pass == "rootme" || pass == "Qtopia") { QString cpassword = QString::fromLocal8Bit( crypt( password.mid(8).local8Bit(), "qp" ) ); Config cfg("Security"); cfg.setGroup("Sync"); QString pwds = cfg.readEntry("Passwords"); if ( QStringList::split(QChar(' '), pwds).contains(cpassword) ) return TRUE; // Unrecognized system. Be careful... if ( (denials > 2 && now < lastdenial + 600) || QMessageBox::warning(0, tr("Sync Connection"), tr("<p>An unrecognized system is requesting access to this device." "<p>If you have just initiated a Sync for the first time, this is normal."), tr("Allow"), tr("Deny"), 0, 1, 1 ) == 1 ) { denials++; lastdenial = now; return FALSE; } else { denials = 0; cfg.writeEntry("Passwords", pwds + " " + cpassword); return TRUE; } } return FALSE; } ServerPI::ServerPI( int socket, QObject *parent , const char* name ) : QSocket( parent, name ) , dtp( 0 ), serversocket( 0 ), waitsocket( 0 ) { state = Connected; setSocket( socket ); peerport = peerPort(); peeraddress = peerAddress(); #ifndef INSECURE if ( !SyncAuthentication::isAuthorized(peeraddress) ) { state = Forbidden; startTimer( 0 ); } else #endif { connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); passiv = FALSE; for ( int i = 0; i < 4; i++ ) wait[i] = FALSE; send( "220 Qtopia " QPE_VERSION " FTP Server" ); state = Wait_USER; dtp = new ServerDTP( this ); connect( dtp, SIGNAL( completed() ), SLOT( dtpCompleted() ) ); connect( dtp, SIGNAL( failed() ), SLOT( dtpFailed() ) ); connect( dtp, SIGNAL( error( int ) ), SLOT( dtpError( int ) ) ); directory = QDir::currentDirPath(); static int p = 1024; while ( !serversocket || !serversocket->ok() ) { delete serversocket; serversocket = new ServerSocket( ++p, this ); } connect( serversocket, SIGNAL( newIncomming( int ) ), SLOT( newConnection( int ) ) ); } } ServerPI::~ServerPI() { } void ServerPI::connectionClosed() { // qDebug( "Debug: Connection closed" ); delete this; } void ServerPI::send( const QString& msg ) { QTextStream os( this ); os << msg << endl; //qDebug( "Reply: %s", msg.latin1() ); } void ServerPI::read() { while ( canReadLine() ) process( readLine().stripWhiteSpace() ); } bool ServerPI::checkReadFile( const QString& file ) { QString filename; if ( file[0] != "/" ) filename = directory.path() + "/" + file; else filename = file; QFileInfo fi( filename ); return ( fi.exists() && fi.isReadable() ); } bool ServerPI::checkWriteFile( const QString& file ) { QString filename; if ( file[0] != "/" ) filename = directory.path() + "/" + file; else filename = file; QFileInfo fi( filename ); if ( fi.exists() ) if ( !QFile( filename ).remove() ) return FALSE; return TRUE; } void ServerPI::process( const QString& message ) { //qDebug( "Command: %s", message.latin1() ); // split message using "," as separator QStringList msg = QStringList::split( " ", message ); if ( msg.isEmpty() ) return ; // command token QString cmd = msg[0].upper(); // argument token QString arg; if ( msg.count() >= 2 ) arg = msg[1]; // full argument string QString args; if ( msg.count() >= 2 ) { QStringList copy( msg ); // FIXME: for Qt3 // copy.pop_front() copy.remove( copy.begin() ); args = copy.join( " " ); } //qDebug( "args: %s", args.latin1() ); // we always respond to QUIT, regardless of state if ( cmd == "QUIT" ) { send( "211 Good bye!" ); delete this; return ; } // connected to client if ( Connected == state ) return ; // waiting for user name if ( Wait_USER == state ) { if ( cmd != "USER" || msg.count() < 2 || !SyncAuthentication::checkUser( arg ) ) { send( "530 Please login with USER and PASS" ); return ; } send( "331 User name ok, need password" ); state = Wait_PASS; return ; } // waiting for password if ( Wait_PASS == state ) { if ( cmd != "PASS" || !SyncAuthentication::checkPassword( arg ) ) { send( "530 Please login with USER and PASS" ); return ; } send( "230 User logged in, proceed" ); state = Ready; return ; } // ACCESS CONTROL COMMANDS // account (ACCT) if ( cmd == "ACCT" ) { // even wu-ftp does not support it send( "502 Command not implemented" ); } // change working directory (CWD) else if ( cmd == "CWD" ) { if ( !args.isEmpty() ) { if ( directory.cd( args, TRUE ) ) send( "250 Requested file action okay, completed" ); else send( "550 Requested action not taken" ); } else send( "500 Syntax error, command unrecognized" ); } // change to parent directory (CDUP) else if ( cmd == "CDUP" ) { if ( directory.cdUp() ) send( "250 Requested file action okay, completed" ); else send( "550 Requested action not taken" ); } // structure mount (SMNT) else if ( cmd == "SMNT" ) { // even wu-ftp does not support it send( "502 Command not implemented" ); } // reinitialize (REIN) else if ( cmd == "REIN" ) { // even wu-ftp does not support it send( "502 Command not implemented" ); } // TRANSFER PARAMETER COMMANDS // data port (PORT) else if ( cmd == "PORT" ) { if ( parsePort( arg ) ) send( "200 Command okay" ); else send( "500 Syntax error, command unrecognized" ); } // passive (PASV) else if ( cmd == "PASV" ) { passiv = TRUE; send( "227 Entering Passive Mode (" + address().toString().replace( QRegExp( "\\." ), "," ) + "," + QString::number( ( serversocket->port() ) >> 8 ) + "," + QString::number( ( serversocket->port() ) & 0xFF ) + ")" ); } // representation type (TYPE) else if ( cmd == "TYPE" ) { if ( arg.upper() == "A" || arg.upper() == "I" ) send( "200 Command okay" ); else send( "504 Command not implemented for that parameter" ); } // file structure (STRU) else if ( cmd == "STRU" ) { if ( arg.upper() == "F" ) send( "200 Command okay" ); else send( "504 Command not implemented for that parameter" ); } // transfer mode (MODE) else if ( cmd == "MODE" ) { if ( arg.upper() == "S" ) diff --git a/core/settings/launcher/menusettings.cpp b/core/settings/launcher/menusettings.cpp index 5a9fada..6fca621 100644 --- a/core/settings/launcher/menusettings.cpp +++ b/core/settings/launcher/menusettings.cpp @@ -1,159 +1,163 @@ /* This file is part of the OPIE Project =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "menusettings.h" #include <qpe/config.h> #include <qpe/qlibrary.h> #include <qpe/qpeapplication.h> #include <qpe/menuappletinterface.h> #include <qpe/qcopenvelope_qws.h> #include <qdir.h> #include <qlistview.h> #include <qcheckbox.h> #include <qheader.h> #include <qlayout.h> #include <qlabel.h> #include <qwhatsthis.h> #include <stdlib.h> MenuSettings::MenuSettings ( QWidget *parent, const char *name ) : QWidget ( parent, name ) { m_applets_changed = false; QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 ); QLabel *l = new QLabel ( tr( "Load applets in O-Menu:" ), this ); lay-> addWidget ( l ); m_list = new QListView ( this ); m_list-> addColumn ( "foobar" ); m_list-> header ( )-> hide ( ); lay-> addWidget ( m_list ); m_menutabs = new QCheckBox ( tr( "Show Launcher tabs in O-Menu" ), this ); lay-> addWidget ( m_menutabs ); QWhatsThis::add ( m_list, tr( "Check the applets that you want to have included in the O-Menu." )); QWhatsThis::add ( m_menutabs, tr( "Adds the contents of the Launcher Tabs as menus in the O-Menu." )); connect ( m_list, SIGNAL( clicked ( QListViewItem * )), this, SLOT( appletChanged ( ))); init ( ); } void MenuSettings::init ( ) { Config cfg ( "StartMenu" ); cfg. setGroup ( "Applets" ); QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' ); QString path = QPEApplication::qpeDir ( ) + "/plugins/applets"; +#ifdef Q_OS_MACX + QStringList list = QDir ( path, "lib*.dylib" ). entryList ( ); +#else QStringList list = QDir ( path, "lib*.so" ). entryList ( ); +#endif /* Q_OS_MACX */ for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { QString name; QPixmap icon; MenuAppletInterface *iface = 0; QLibrary *lib = new QLibrary ( path + "/" + *it ); lib-> queryInterface ( IID_MenuApplet, (QUnknownInterface**) &iface ); if ( iface ) { QString lang = getenv( "LANG" ); QTranslator *trans = new QTranslator ( qApp ); QString type = (*it). left ((*it). find (".")); QString tfn = QPEApplication::qpeDir ( ) + "/i18n/" + lang + "/" + type + ".qm"; if ( trans-> load ( tfn )) qApp-> installTranslator ( trans ); else delete trans; name = iface-> name ( ); icon = iface-> icon ( ). pixmap ( QIconSet::Small, QIconSet::Normal ); iface-> release ( ); lib-> unload ( ); QCheckListItem *item; item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); if ( !icon. isNull ( )) item-> setPixmap ( 0, icon ); item-> setOn ( exclude. find ( *it ) == exclude. end ( )); m_applets [*it] = item; } else { delete lib; } } cfg. setGroup ( "Menu" ); m_menutabs-> setChecked ( cfg. readBoolEntry ( "LauncherTabs", true )); } void MenuSettings::appletChanged() { m_applets_changed = true; } void MenuSettings::accept ( ) { bool apps_changed = false; Config cfg ( "StartMenu" ); cfg. setGroup ( "Applets" ); if ( m_applets_changed ) { QStringList exclude; QMap <QString, QCheckListItem *>::Iterator it; for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) { if ( !(*it)-> isOn ( )) exclude << it. key ( ); } cfg. writeEntry ( "ExcludeApplets", exclude, ',' ); } cfg. writeEntry ( "SafeMode", false ); cfg. setGroup ( "Menu" ); if ( m_menutabs-> isChecked ( ) != cfg. readBoolEntry ( "LauncherTabs", true )) { apps_changed = true; cfg. writeEntry ( "LauncherTabs", m_menutabs-> isChecked ( )); } cfg. write ( ); if ( m_applets_changed ) { QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" ); m_applets_changed = false; } if ( apps_changed ) { QCopEnvelope ( "QPE/TaskBar", "reloadApps()" ); } } diff --git a/core/settings/launcher/taskbarsettings.cpp b/core/settings/launcher/taskbarsettings.cpp index b3e302a..d03ea49 100644 --- a/core/settings/launcher/taskbarsettings.cpp +++ b/core/settings/launcher/taskbarsettings.cpp @@ -1,156 +1,173 @@ /* This file is part of the OPIE Project =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "taskbarsettings.h" #include <qpe/config.h> #include <qpe/qlibrary.h> #include <qpe/qpeapplication.h> #include <qpe/taskbarappletinterface.h> #include <qpe/qcopenvelope_qws.h> #include <qdir.h> #include <qlistview.h> #include <qcheckbox.h> #include <qheader.h> #include <qlayout.h> #include <qlabel.h> #include <qwhatsthis.h> #include <stdlib.h> TaskbarSettings::TaskbarSettings ( QWidget *parent, const char *name ) : QWidget ( parent, name ) { m_applets_changed = false; QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 ); QLabel *l = new QLabel ( tr( "Load applets in Taskbar:" ), this ); lay-> addWidget ( l ); m_list = new QListView ( this ); m_list-> addColumn ( "foobar" ); m_list-> header ( )-> hide ( ); lay-> addWidget ( m_list ); QWhatsThis::add ( m_list, tr( "Check the applets that you want displayed in the Taskbar." )); connect ( m_list, SIGNAL( clicked ( QListViewItem * )), this, SLOT( appletChanged ( ))); init ( ); } void TaskbarSettings::init ( ) { Config cfg ( "Taskbar" ); cfg. setGroup ( "Applets" ); QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' ); QString path = QPEApplication::qpeDir ( ) + "/plugins/applets"; +#ifdef Q_OS_MACX + QStringList list = QDir ( path, "lib*.dylib" ). entryList ( ); +#else QStringList list = QDir ( path, "lib*.so" ). entryList ( ); +#endif /* Q_OS_MACX */ for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) { QString name; QPixmap icon; TaskbarNamedAppletInterface *iface = 0; + qWarning("Load applet: %s", (*it).latin1() ); QLibrary *lib = new QLibrary ( path + "/" + *it ); lib-> queryInterface ( IID_TaskbarNamedApplet, (QUnknownInterface**) &iface ); + qWarning("<1>"); if ( iface ) { + qWarning("<2>"); QString lang = getenv( "LANG" ); QTranslator *trans = new QTranslator ( qApp ); QString type = (*it). left ((*it). find (".")); QString tfn = QPEApplication::qpeDir ( ) + "/i18n/" + lang + "/" + type + ".qm"; if ( trans-> load ( tfn )) qApp-> installTranslator ( trans ); else delete trans; name = iface-> name ( ); icon = iface-> icon ( ); iface-> release ( ); } + qWarning("<3>"); if ( !iface ) { + qWarning("<4>"); lib-> queryInterface ( IID_TaskbarApplet, (QUnknownInterface**) &iface ); if ( iface ) { + qWarning("<5>"); name = (*it). mid ( 3 ); + qWarning("Found applet: %s", name.latin1() ); +#ifdef Q_OS_MACX + int sep = name. find( ".dylib" ); +#else int sep = name. find( ".so" ); +#endif /* Q_OS_MACX */ if ( sep > 0 ) name. truncate ( sep ); sep = name. find ( "applet" ); if ( sep == (int) name.length ( ) - 6 ) name. truncate ( sep ); name[0] = name[0]. upper ( ); iface-> release ( ); } } + qWarning("<6>"); if ( iface ) { + qWarning("<7>"); QCheckListItem *item; item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox ); if ( !icon. isNull ( )) item-> setPixmap ( 0, icon ); item-> setOn ( exclude. find ( *it ) == exclude. end ( )); m_applets [*it] = item; } lib-> unload ( ); delete lib; } } void TaskbarSettings::appletChanged() { m_applets_changed = true; } void TaskbarSettings::accept ( ) { Config cfg ( "Taskbar" ); cfg. setGroup ( "Applets" ); if ( m_applets_changed ) { QStringList exclude; QMap <QString, QCheckListItem *>::Iterator it; for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) { if ( !(*it)-> isOn ( )) exclude << it. key ( ); } cfg. writeEntry ( "ExcludeApplets", exclude, ',' ); } cfg. writeEntry ( "SafeMode", false ); cfg. write ( ); if ( m_applets_changed ) { QCopEnvelope e ( "QPE/TaskBar", "reloadApplets()" ); m_applets_changed = false; } } |