author | kergoth <kergoth> | 2002-01-25 22:14:26 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-01-25 22:14:26 (UTC) |
commit | 15318cad33835e4e2dc620d033e43cd930676cdd (patch) (side-by-side diff) | |
tree | c2fa0399a2c47fda8e2cd0092c73a809d17f68eb /core/launcher | |
download | opie-15318cad33835e4e2dc620d033e43cd930676cdd.zip opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.gz opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.bz2 |
Initial revision
49 files changed, 9945 insertions, 0 deletions
diff --git a/core/launcher/.cvsignore b/core/launcher/.cvsignore new file mode 100644 index 0000000..1924a2d --- a/dev/null +++ b/core/launcher/.cvsignore @@ -0,0 +1,7 @@ +moc_* +*.moc +Makefile +shutdown.cpp +shutdown.h +qimpenprefbase.h +lnkpropertiesbase.h diff --git a/core/launcher/Makefile.in b/core/launcher/Makefile.in new file mode 100644 index 0000000..e129fca --- a/dev/null +++ b/core/launcher/Makefile.in @@ -0,0 +1,867 @@ +############################################################################# + +####### Compiler, tools and options + +CXX = $(SYSCONF_CXX) $(QT_CXX_MT) +CXXFLAGS= $(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) +CC = $(SYSCONF_CC) $(QT_C_MT) +CFLAGS = $(SYSCONF_CFLAGS) +INCPATH = -I$(QPEDIR)/include -I$(QPEDIR)/calibrate -I$(QPEDIR)/rsync +LFLAGS = $(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) +LIBS = $(SUBLIBS) -lqpe -lcrypt $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP) +MOC = $(SYSCONF_MOC) +UIC = $(SYSCONF_UIC) + +####### Target + +DESTDIR = $(QPEDIR)/bin/ +VER_MAJ = 1 +VER_MIN = 0 +VER_PATCH = 0 +TARGET = qpe +TARGET1 = lib$(TARGET).so.$(VER_MAJ) + +####### Files + +HEADERS = background.h \ + desktop.h \ + info.h \ + appicons.h \ + taskbar.h \ + sidething.h \ + mrulist.h \ + stabmon.h \ + inputmethods.h \ + systray.h \ + wait.h \ + shutdownimpl.h \ + launcher.h \ + launcherview.h \ + ../calibrate/calibrate.h \ + startmenu.h \ + transferserver.h \ + qcopbridge.h \ + packageslave.h \ + irserver.h \ + $(QPEDIR)/rsync/buf.h \ + $(QPEDIR)/rsync/checksum.h \ + $(QPEDIR)/rsync/command.h \ + $(QPEDIR)/rsync/emit.h \ + $(QPEDIR)/rsync/job.h \ + $(QPEDIR)/rsync/netint.h \ + $(QPEDIR)/rsync/protocol.h \ + $(QPEDIR)/rsync/prototab.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/search.h \ + $(QPEDIR)/rsync/stream.h \ + $(QPEDIR)/rsync/sumset.h \ + $(QPEDIR)/rsync/trace.h \ + $(QPEDIR)/rsync/types.h \ + $(QPEDIR)/rsync/util.h \ + $(QPEDIR)/rsync/whole.h \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/qrsync.h +SOURCES = background.cpp \ + desktop.cpp \ + info.cpp \ + appicons.cpp \ + taskbar.cpp \ + sidething.cpp \ + mrulist.cpp \ + stabmon.cpp \ + inputmethods.cpp \ + systray.cpp \ + wait.cpp \ + shutdownimpl.cpp \ + launcher.cpp \ + launcherview.cpp \ + $(QPEDIR)/calibrate/calibrate.cpp \ + transferserver.cpp \ + packageslave.cpp \ + irserver.cpp \ + qcopbridge.cpp \ + startmenu.cpp \ + main.cpp \ + $(QPEDIR)/rsync/base64.c \ + $(QPEDIR)/rsync/buf.c \ + $(QPEDIR)/rsync/checksum.c \ + $(QPEDIR)/rsync/command.c \ + $(QPEDIR)/rsync/delta.c \ + $(QPEDIR)/rsync/emit.c \ + $(QPEDIR)/rsync/hex.c \ + $(QPEDIR)/rsync/job.c \ + $(QPEDIR)/rsync/mdfour.c \ + $(QPEDIR)/rsync/mksum.c \ + $(QPEDIR)/rsync/msg.c \ + $(QPEDIR)/rsync/netint.c \ + $(QPEDIR)/rsync/patch.c \ + $(QPEDIR)/rsync/prototab.c \ + $(QPEDIR)/rsync/readsums.c \ + $(QPEDIR)/rsync/scoop.c \ + $(QPEDIR)/rsync/search.c \ + $(QPEDIR)/rsync/stats.c \ + $(QPEDIR)/rsync/stream.c \ + $(QPEDIR)/rsync/sumset.c \ + $(QPEDIR)/rsync/trace.c \ + $(QPEDIR)/rsync/tube.c \ + $(QPEDIR)/rsync/util.c \ + $(QPEDIR)/rsync/version.c \ + $(QPEDIR)/rsync/whole.c \ + $(QPEDIR)/rsync/qrsync.cpp +OBJECTS = background.o \ + desktop.o \ + info.o \ + appicons.o \ + taskbar.o \ + sidething.o \ + mrulist.o \ + stabmon.o \ + inputmethods.o \ + systray.o \ + wait.o \ + shutdownimpl.o \ + launcher.o \ + launcherview.o \ + $(QPEDIR)/calibrate/calibrate.o \ + transferserver.o \ + packageslave.o \ + irserver.o \ + qcopbridge.o \ + startmenu.o \ + main.o \ + $(QPEDIR)/rsync/base64.o \ + $(QPEDIR)/rsync/buf.o \ + $(QPEDIR)/rsync/checksum.o \ + $(QPEDIR)/rsync/command.o \ + $(QPEDIR)/rsync/delta.o \ + $(QPEDIR)/rsync/emit.o \ + $(QPEDIR)/rsync/hex.o \ + $(QPEDIR)/rsync/job.o \ + $(QPEDIR)/rsync/mdfour.o \ + $(QPEDIR)/rsync/mksum.o \ + $(QPEDIR)/rsync/msg.o \ + $(QPEDIR)/rsync/netint.o \ + $(QPEDIR)/rsync/patch.o \ + $(QPEDIR)/rsync/prototab.o \ + $(QPEDIR)/rsync/readsums.o \ + $(QPEDIR)/rsync/scoop.o \ + $(QPEDIR)/rsync/search.o \ + $(QPEDIR)/rsync/stats.o \ + $(QPEDIR)/rsync/stream.o \ + $(QPEDIR)/rsync/sumset.o \ + $(QPEDIR)/rsync/trace.o \ + $(QPEDIR)/rsync/tube.o \ + $(QPEDIR)/rsync/util.o \ + $(QPEDIR)/rsync/version.o \ + $(QPEDIR)/rsync/whole.o \ + $(QPEDIR)/rsync/qrsync.o \ + shutdown.o \ + syncdialog.o +INTERFACES = shutdown.ui \ + syncdialog.ui +UICDECLS = shutdown.h \ + syncdialog.h +UICIMPLS = shutdown.cpp \ + syncdialog.cpp +SRCMOC = moc_background.cpp \ + moc_desktop.cpp \ + moc_info.cpp \ + moc_appicons.cpp \ + moc_taskbar.cpp \ + moc_sidething.cpp \ + moc_inputmethods.cpp \ + moc_systray.cpp \ + moc_shutdownimpl.cpp \ + moc_launcher.cpp \ + moc_launcherview.cpp \ + ../calibrate/moc_calibrate.cpp \ + moc_startmenu.cpp \ + moc_transferserver.cpp \ + moc_qcopbridge.cpp \ + moc_packageslave.cpp \ + moc_irserver.cpp \ + appicons.moc \ + moc_shutdown.cpp \ + moc_syncdialog.cpp +OBJMOC = moc_background.o \ + moc_desktop.o \ + moc_info.o \ + moc_appicons.o \ + moc_taskbar.o \ + moc_sidething.o \ + moc_inputmethods.o \ + moc_systray.o \ + moc_shutdownimpl.o \ + moc_launcher.o \ + moc_launcherview.o \ + ../calibrate/moc_calibrate.o \ + moc_startmenu.o \ + moc_transferserver.o \ + moc_qcopbridge.o \ + moc_packageslave.o \ + moc_irserver.o \ + moc_shutdown.o \ + moc_syncdialog.o + + +####### Implicit rules + +.SUFFIXES: .cpp .cxx .cc .C .c + +.cpp.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cxx.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.cc.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.C.o: + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< + +.c.o: + $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< + +####### Build rules + + +all: $(DESTDIR)$(TARGET) + +$(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) + $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) + +moc: $(SRCMOC) + +tmake: + tmake taskbar.pro + +clean: + -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) + -rm -f *~ core + -rm -f allmoc.cpp + +####### Extension Modules + +listpromodules: + @echo + +listallmodules: + @echo + +listaddonpromodules: + @echo + +listaddonentmodules: + @echo + + +REQUIRES= + +####### Sub-libraries + + +###### Combined headers + + + +####### Compile + +background.o: background.cpp \ + background.h \ + desktop.h \ + shutdownimpl.h \ + shutdown.h \ + $(QPEDIR)/include/qpe/qpeapplication.h \ + $(QPEDIR)/include/qpe/resource.h + +desktop.o: desktop.cpp \ + desktop.h \ + shutdownimpl.h \ + shutdown.h \ + $(QPEDIR)/include/qpe/qpeapplication.h \ + info.h \ + background.h \ + launcher.h \ + launcherview.h \ + $(QPEDIR)/include/qpe/storage.h \ + mrulist.h \ + $(QPEDIR)/include/qpe/applnk.h \ + qcopbridge.h \ + startmenu.h \ + taskbar.h \ + $(QPEDIR)/include/qpe/custom.h \ + transferserver.h \ + irserver.h \ + packageslave.h \ + $(QPEDIR)/include/qpe/mimetype.h \ + $(QPEDIR)/include/qpe/password.h \ + $(QPEDIR)/include/qpe/config.h \ + $(QPEDIR)/include/qpe/power.h \ + $(QPEDIR)/include/qpe/qcopenvelope_qws.h \ + $(QPEDIR)/include/qpe/global.h + +info.o: info.cpp \ + info.h \ + background.h \ + desktop.h \ + shutdownimpl.h \ + shutdown.h \ + $(QPEDIR)/include/qpe/qpeapplication.h \ + $(QPEDIR)/include/qpe/resource.h \ + $(QPEDIR)/include/qpe/version.h + +appicons.o: appicons.cpp \ + appicons.moc \ + appicons.h \ + $(QPEDIR)/include/qpe/qcopenvelope_qws.h + +taskbar.o: taskbar.cpp \ + startmenu.h \ + inputmethods.h \ + $(QPEDIR)/include/qpe/inputmethodinterface.h \ + $(QPEDIR)/include/qpe/qcom.h \ + $(QPEDIR)/include/qpe/quuid.h \ + mrulist.h \ + $(QPEDIR)/include/qpe/applnk.h \ + systray.h \ + $(QPEDIR)/include/qpe/taskbarappletinterface.h \ + $(QPEDIR)/calibrate/calibrate.h \ + wait.h \ + $(QPEDIR)/include/qpe/resource.h \ + appicons.h \ + taskbar.h \ + $(QPEDIR)/include/qpe/custom.h \ + desktop.h \ + shutdownimpl.h \ + shutdown.h \ + $(QPEDIR)/include/qpe/qpeapplication.h \ + $(QPEDIR)/include/qpe/qcopenvelope_qws.h \ + $(QPEDIR)/include/qpe/global.h \ + ../taskbar/apps.h \ + ../addressbook/addressbook.h \ + ../datebook/datebook.h \ + $(QPEDIR)/include/qpe/datebookdb.h \ + $(QPEDIR)/include/qpe/event.h \ + $(QPEDIR)/include/qpe/palmtoprecord.h \ + ../helpbrowser/helpbrowser.h \ + ../minesweep/minesweep.h \ + ../textedit/textedit.h \ + $(QPEDIR)/include/qpe/filemanager.h \ + ../todo/mainwindow.h \ + ../citytime/citytime.h \ + ../clock/clock.h \ + ../calculator/calculatorimpl.h \ + ../sysinfo/sysinfo.h \ + ../settings/appearance/settings.h \ + ../settings/systemtime/settime.h \ + $(QPEDIR)/include/qpe/timestring.h \ + ../filebrowser/filebrowser.h \ + ../solitaire/canvascardwindow.h \ + ../snake/interface.h \ + ../parashoot/interface.h \ + $(QPEDIR)/include/qpe/sound.h \ + ../mpegplayer/mediaplayer.h \ + $(QPEDIR)/include/qpe/qlibrary.h \ + ../embeddedkonsole/konsole.h \ + ../wordgame/wordgame.h \ + $(QPEDIR)/include/qpe/qdawg.h + +sidething.o: sidething.cpp \ + sidething.h \ + startmenu.h \ + $(QPEDIR)/include/qpe/resource.h + +mrulist.o: mrulist.cpp \ + mrulist.h \ + $(QPEDIR)/include/qpe/applnk.h \ + $(QPEDIR)/include/qpe/global.h \ + $(QPEDIR)/include/qpe/resource.h + +stabmon.o: stabmon.cpp \ + stabmon.h \ + $(QPEDIR)/include/qpe/qcopenvelope_qws.h + +inputmethods.o: inputmethods.cpp \ + inputmethods.h \ + $(QPEDIR)/include/qpe/inputmethodinterface.h \ + $(QPEDIR)/include/qpe/qcom.h \ + $(QPEDIR)/include/qpe/quuid.h \ + $(QPEDIR)/include/qpe/config.h \ + $(QPEDIR)/include/qpe/qpeapplication.h \ + $(QPEDIR)/include/qpe/qlibrary.h + +systray.o: systray.cpp \ + $(QPEDIR)/include/qpe/qpeapplication.h \ + $(QPEDIR)/include/qpe/qlibrary.h \ + $(QPEDIR)/include/qpe/qcom.h \ + $(QPEDIR)/include/qpe/quuid.h \ + $(QPEDIR)/include/qpe/config.h \ + quicklauncher.h \ + systray.h \ + $(QPEDIR)/include/qpe/taskbarappletinterface.h + +wait.o: wait.cpp \ + wait.h \ + $(QPEDIR)/include/qpe/resource.h + +shutdownimpl.o: shutdownimpl.cpp \ + shutdownimpl.h \ + shutdown.h \ + $(QPEDIR)/include/qpe/global.h + +launcher.o: launcher.cpp \ + $(QPEDIR)/include/qpe/qcopenvelope_qws.h \ + $(QPEDIR)/include/qpe/resource.h \ + $(QPEDIR)/include/qpe/applnk.h \ + $(QPEDIR)/include/qpe/config.h \ + $(QPEDIR)/include/qpe/global.h \ + $(QPEDIR)/include/qpe/qpeapplication.h \ + $(QPEDIR)/include/qpe/mimetype.h \ + $(QPEDIR)/include/qpe/storage.h \ + launcherview.h \ + launcher.h \ + $(QPEDIR)/include/qpe/lnkproperties.h \ + mrulist.h \ + $(QPEDIR)/rsync/qrsync.h + +launcherview.o: launcherview.cpp \ + launcherview.h \ + $(QPEDIR)/include/qpe/storage.h \ + $(QPEDIR)/include/qpe/qpeapplication.h \ + $(QPEDIR)/include/qpe/applnk.h \ + $(QPEDIR)/include/qpe/qpedebug.h \ + $(QPEDIR)/include/qpe/categories.h \ + $(QPEDIR)/include/qpe/categoryselect.h \ + $(QPEDIR)/include/qpe/menubutton.h \ + $(QPEDIR)/include/qpe/resource.h \ + $(QPEDIR)/include/qpe/qpetoolbar.h + +$(QPEDIR)/calibrate/calibrate.o: $(QPEDIR)/calibrate/calibrate.cpp \ + $(QPEDIR)/calibrate/calibrate.h \ + $(QPEDIR)/include/qpe/resource.h + +transferserver.o: transferserver.cpp \ + $(QPEDIR)/include/qpe/qprocess.h \ + $(QPEDIR)/include/qpe/process.h \ + transferserver.h + +packageslave.o: packageslave.cpp \ + packageslave.h \ + $(QPEDIR)/include/qpe/process.h \ + $(QPEDIR)/include/qpe/qcopenvelope_qws.h + +irserver.o: irserver.cpp \ + irserver.h \ + $(QPEDIR)/include/qpe/qlibrary.h \ + $(QPEDIR)/include/qpe/qcom.h \ + $(QPEDIR)/include/qpe/quuid.h \ + $(QPEDIR)/include/qpe/qpeapplication.h \ + obexinterface.h + +qcopbridge.o: qcopbridge.cpp \ + qcopbridge.h \ + $(QPEDIR)/include/qpe/qcopenvelope_qws.h \ + $(QPEDIR)/include/qpe/qpeapplication.h + +startmenu.o: startmenu.cpp \ + startmenu.h \ + sidething.h \ + mrulist.h \ + $(QPEDIR)/include/qpe/applnk.h \ + info.h \ + background.h \ + $(QPEDIR)/include/qpe/qpeapplication.h \ + $(QPEDIR)/include/qpe/config.h \ + $(QPEDIR)/include/qpe/global.h \ + $(QPEDIR)/include/qpe/resource.h + +main.o: main.cpp \ + desktop.h \ + shutdownimpl.h \ + shutdown.h \ + $(QPEDIR)/include/qpe/qpeapplication.h \ + taskbar.h \ + $(QPEDIR)/include/qpe/custom.h \ + stabmon.h \ + $(QPEDIR)/include/qpe/network.h \ + $(QPEDIR)/include/qpe/config.h \ + $(QPEDIR)/include/qpe/qcopenvelope_qws.h \ + $(QPEDIR)/include/qpe/alarmserver.h \ + ../calibrate/calibrate.h \ + ../login/qdmdialogimpl.h \ + $(QPEDIR)/include/qpe/global.h + +$(QPEDIR)/rsync/base64.o: $(QPEDIR)/rsync/base64.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h + +$(QPEDIR)/rsync/buf.o: $(QPEDIR)/rsync/buf.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/trace.h \ + $(QPEDIR)/rsync/buf.h \ + $(QPEDIR)/rsync/util.h + +$(QPEDIR)/rsync/checksum.o: $(QPEDIR)/rsync/checksum.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/checksum.h + +$(QPEDIR)/rsync/command.o: $(QPEDIR)/rsync/command.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/command.h + +$(QPEDIR)/rsync/delta.o: $(QPEDIR)/rsync/delta.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/emit.h \ + $(QPEDIR)/rsync/stream.h \ + $(QPEDIR)/rsync/util.h \ + $(QPEDIR)/rsync/sumset.h \ + $(QPEDIR)/rsync/job.h \ + $(QPEDIR)/rsync/trace.h \ + $(QPEDIR)/rsync/checksum.h \ + $(QPEDIR)/rsync/search.h \ + $(QPEDIR)/rsync/types.h + +$(QPEDIR)/rsync/emit.o: $(QPEDIR)/rsync/emit.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/command.h \ + $(QPEDIR)/rsync/protocol.h \ + $(QPEDIR)/rsync/trace.h \ + $(QPEDIR)/rsync/emit.h \ + $(QPEDIR)/rsync/prototab.h \ + $(QPEDIR)/rsync/netint.h \ + $(QPEDIR)/rsync/sumset.h \ + $(QPEDIR)/rsync/job.h + +$(QPEDIR)/rsync/hex.o: $(QPEDIR)/rsync/hex.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h + +$(QPEDIR)/rsync/job.o: $(QPEDIR)/rsync/job.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/stream.h \ + $(QPEDIR)/rsync/util.h \ + $(QPEDIR)/rsync/sumset.h \ + $(QPEDIR)/rsync/job.h \ + $(QPEDIR)/rsync/trace.h + +$(QPEDIR)/rsync/mdfour.o: $(QPEDIR)/rsync/mdfour.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/trace.h \ + $(QPEDIR)/rsync/types.h + +$(QPEDIR)/rsync/mksum.o: $(QPEDIR)/rsync/mksum.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/stream.h \ + $(QPEDIR)/rsync/util.h \ + $(QPEDIR)/rsync/sumset.h \ + $(QPEDIR)/rsync/job.h \ + $(QPEDIR)/rsync/protocol.h \ + $(QPEDIR)/rsync/netint.h \ + $(QPEDIR)/rsync/trace.h \ + $(QPEDIR)/rsync/checksum.h + +$(QPEDIR)/rsync/msg.o: $(QPEDIR)/rsync/msg.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h + +$(QPEDIR)/rsync/netint.o: $(QPEDIR)/rsync/netint.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/job.h \ + $(QPEDIR)/rsync/netint.h \ + $(QPEDIR)/rsync/trace.h \ + $(QPEDIR)/rsync/stream.h + +$(QPEDIR)/rsync/patch.o: $(QPEDIR)/rsync/patch.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/util.h \ + $(QPEDIR)/rsync/trace.h \ + $(QPEDIR)/rsync/protocol.h \ + $(QPEDIR)/rsync/netint.h \ + $(QPEDIR)/rsync/command.h \ + $(QPEDIR)/rsync/sumset.h \ + $(QPEDIR)/rsync/prototab.h \ + $(QPEDIR)/rsync/stream.h \ + $(QPEDIR)/rsync/job.h + +$(QPEDIR)/rsync/prototab.o: $(QPEDIR)/rsync/prototab.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/protocol.h \ + $(QPEDIR)/rsync/command.h \ + $(QPEDIR)/rsync/prototab.h + +$(QPEDIR)/rsync/readsums.o: $(QPEDIR)/rsync/readsums.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/sumset.h \ + $(QPEDIR)/rsync/job.h \ + $(QPEDIR)/rsync/trace.h \ + $(QPEDIR)/rsync/netint.h \ + $(QPEDIR)/rsync/protocol.h \ + $(QPEDIR)/rsync/util.h \ + $(QPEDIR)/rsync/stream.h + +$(QPEDIR)/rsync/scoop.o: $(QPEDIR)/rsync/scoop.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/job.h \ + $(QPEDIR)/rsync/stream.h \ + $(QPEDIR)/rsync/trace.h \ + $(QPEDIR)/rsync/util.h + +$(QPEDIR)/rsync/search.o: $(QPEDIR)/rsync/search.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/trace.h \ + $(QPEDIR)/rsync/util.h \ + $(QPEDIR)/rsync/sumset.h \ + $(QPEDIR)/rsync/search.h \ + $(QPEDIR)/rsync/checksum.h + +$(QPEDIR)/rsync/stats.o: $(QPEDIR)/rsync/stats.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/trace.h + +$(QPEDIR)/rsync/stream.o: $(QPEDIR)/rsync/stream.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/stream.h \ + $(QPEDIR)/rsync/util.h \ + $(QPEDIR)/rsync/trace.h + +$(QPEDIR)/rsync/sumset.o: $(QPEDIR)/rsync/sumset.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/sumset.h \ + $(QPEDIR)/rsync/util.h \ + $(QPEDIR)/rsync/trace.h + +$(QPEDIR)/rsync/trace.o: $(QPEDIR)/rsync/trace.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/util.h \ + $(QPEDIR)/rsync/trace.h + +$(QPEDIR)/rsync/tube.o: $(QPEDIR)/rsync/tube.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/trace.h \ + $(QPEDIR)/rsync/util.h \ + $(QPEDIR)/rsync/job.h \ + $(QPEDIR)/rsync/stream.h + +$(QPEDIR)/rsync/util.o: $(QPEDIR)/rsync/util.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/util.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/trace.h + +$(QPEDIR)/rsync/version.o: $(QPEDIR)/rsync/version.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h + +$(QPEDIR)/rsync/whole.o: $(QPEDIR)/rsync/whole.c \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/config_linux.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/trace.h \ + $(QPEDIR)/rsync/fileutil.h \ + $(QPEDIR)/rsync/sumset.h \ + $(QPEDIR)/rsync/job.h \ + $(QPEDIR)/rsync/buf.h \ + $(QPEDIR)/rsync/whole.h \ + $(QPEDIR)/rsync/util.h + +$(QPEDIR)/rsync/qrsync.o: $(QPEDIR)/rsync/qrsync.cpp \ + $(QPEDIR)/rsync/qrsync.h \ + $(QPEDIR)/rsync/rsync.h + +shutdown.h: shutdown.ui + $(UIC) shutdown.ui -o $(INTERFACE_DECL_PATH)/shutdown.h + +shutdown.cpp: shutdown.ui + $(UIC) shutdown.ui -i shutdown.h -o shutdown.cpp + +syncdialog.h: syncdialog.ui + $(UIC) syncdialog.ui -o $(INTERFACE_DECL_PATH)/syncdialog.h + +syncdialog.cpp: syncdialog.ui + $(UIC) syncdialog.ui -i syncdialog.h -o syncdialog.cpp + +shutdown.o: shutdown.cpp \ + shutdown.h + +syncdialog.o: syncdialog.cpp + +moc_background.o: moc_background.cpp \ + background.h + +moc_desktop.o: moc_desktop.cpp \ + desktop.h \ + shutdownimpl.h \ + shutdown.h \ + $(QPEDIR)/include/qpe/qpeapplication.h + +moc_info.o: moc_info.cpp \ + info.h \ + background.h + +moc_appicons.o: moc_appicons.cpp \ + appicons.h + +moc_taskbar.o: moc_taskbar.cpp \ + taskbar.h \ + $(QPEDIR)/include/qpe/custom.h + +moc_sidething.o: moc_sidething.cpp \ + sidething.h \ + startmenu.h + +moc_inputmethods.o: moc_inputmethods.cpp \ + inputmethods.h \ + $(QPEDIR)/include/qpe/inputmethodinterface.h \ + $(QPEDIR)/include/qpe/qcom.h \ + $(QPEDIR)/include/qpe/quuid.h + +moc_systray.o: moc_systray.cpp \ + systray.h \ + $(QPEDIR)/include/qpe/taskbarappletinterface.h \ + $(QPEDIR)/include/qpe/qcom.h \ + $(QPEDIR)/include/qpe/quuid.h + +moc_shutdownimpl.o: moc_shutdownimpl.cpp \ + shutdownimpl.h \ + shutdown.h + +moc_launcher.o: moc_launcher.cpp \ + launcher.h \ + launcherview.h \ + $(QPEDIR)/include/qpe/storage.h + +moc_launcherview.o: moc_launcherview.cpp \ + launcherview.h \ + $(QPEDIR)/include/qpe/storage.h + +../calibrate/moc_calibrate.o: ../calibrate/moc_calibrate.cpp \ + ../calibrate/calibrate.h + +moc_startmenu.o: moc_startmenu.cpp \ + startmenu.h + +moc_transferserver.o: moc_transferserver.cpp \ + transferserver.h + +moc_qcopbridge.o: moc_qcopbridge.cpp \ + qcopbridge.h + +moc_packageslave.o: moc_packageslave.cpp \ + packageslave.h + +moc_irserver.o: moc_irserver.cpp \ + irserver.h + +moc_shutdown.o: appicons.moc \ + appicons.cpp \ + appicons.h \ + $(QPEDIR)/include/qpe/qcopenvelope_qws.h + +moc_syncdialog.o: moc_shutdown.cpp \ + shutdown.h + +moc_background.cpp: background.h + $(MOC) background.h -o moc_background.cpp + +moc_desktop.cpp: desktop.h + $(MOC) desktop.h -o moc_desktop.cpp + +moc_info.cpp: info.h + $(MOC) info.h -o moc_info.cpp + +moc_appicons.cpp: appicons.h + $(MOC) appicons.h -o moc_appicons.cpp + +moc_taskbar.cpp: taskbar.h + $(MOC) taskbar.h -o moc_taskbar.cpp + +moc_sidething.cpp: sidething.h + $(MOC) sidething.h -o moc_sidething.cpp + +moc_inputmethods.cpp: inputmethods.h + $(MOC) inputmethods.h -o moc_inputmethods.cpp + +moc_systray.cpp: systray.h + $(MOC) systray.h -o moc_systray.cpp + +moc_shutdownimpl.cpp: shutdownimpl.h + $(MOC) shutdownimpl.h -o moc_shutdownimpl.cpp + +moc_launcher.cpp: launcher.h + $(MOC) launcher.h -o moc_launcher.cpp + +moc_launcherview.cpp: launcherview.h + $(MOC) launcherview.h -o moc_launcherview.cpp + +../calibrate/moc_calibrate.cpp: ../calibrate/calibrate.h + $(MOC) ../calibrate/calibrate.h -o ../calibrate/moc_calibrate.cpp + +moc_startmenu.cpp: startmenu.h + $(MOC) startmenu.h -o moc_startmenu.cpp + +moc_transferserver.cpp: transferserver.h + $(MOC) transferserver.h -o moc_transferserver.cpp + +moc_qcopbridge.cpp: qcopbridge.h + $(MOC) qcopbridge.h -o moc_qcopbridge.cpp + +moc_packageslave.cpp: packageslave.h + $(MOC) packageslave.h -o moc_packageslave.cpp + +moc_irserver.cpp: irserver.h + $(MOC) irserver.h -o moc_irserver.cpp + +appicons.moc: appicons.cpp + $(MOC) appicons.cpp -o appicons.moc + +moc_shutdown.cpp: shutdown.h + $(MOC) shutdown.h -o moc_shutdown.cpp + +moc_syncdialog.cpp: syncdialog.h + $(MOC) syncdialog.h -o moc_syncdialog.cpp + + diff --git a/core/launcher/appicons.cpp b/core/launcher/appicons.cpp new file mode 100644 index 0000000..c51ee5a --- a/dev/null +++ b/core/launcher/appicons.cpp @@ -0,0 +1,129 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 "appicons.h" + +#include <qpe/qcopenvelope_qws.h> + +#include <qtooltip.h> +#include <qpixmap.h> + + +AppIcons::AppIcons( QWidget *parent ) : + QHBox(parent) +{ + buttons.setAutoDelete(TRUE); + +#ifndef QT_NO_COP + QCopChannel* channel = new QCopChannel("Qt/Tray", this); + connect(channel, SIGNAL(received(const QCString&, const QByteArray&)), + this, SLOT(receive(const QCString&, const QByteArray&))); +#endif +} + +void AppIcons::setIcon(int id, const QPixmap& pm) +{ + button(id)->setPixmap(pm); +} + +class FlatButton : public QLabel { + Q_OBJECT +public: + FlatButton(QWidget* parent) : QLabel(parent) { } + + void mouseDoubleClickEvent(QMouseEvent* e) + { + emit clicked(e->pos(),e->button(),TRUE); + } + void mouseReleaseEvent(QMouseEvent* e) + { + if ( rect().contains(e->pos()) ) + emit clicked(e->pos(),e->button(),FALSE); + } + +signals: + void clicked(const QPoint&, int, bool); +}; + +QLabel* AppIcons::button(int id) +{ + QLabel* f = buttons.find(id); + if ( !f ) { + buttons.insert(id,f=new FlatButton(this)); + connect(f,SIGNAL(clicked(const QPoint&, int, bool)),this,SLOT(clicked(const QPoint&, int, bool))); + f->show(); + } + return f; +} + +int AppIcons::findId(QLabel* b) +{ + QIntDictIterator<QLabel> it(buttons); + for ( ; ; ++it ) + if ( it.current() == b ) return it.currentKey(); +} + +void AppIcons::clicked(const QPoint& relpos, int button, bool dbl) +{ +#ifndef QT_NO_COP + QLabel* s = (QLabel*)sender(); + if ( button == RightButton ) { + QCopEnvelope("Qt/Tray","popup(int,QPoint)") + << findId(s) << s->mapToGlobal(QPoint(0,0)); + } else { + QCopEnvelope("Qt/Tray", + dbl ? "doubleClicked(int,QPoint)" : "clicked(int,QPoint)") + << findId(s) << relpos; + } +#endif +} + +void AppIcons::setToolTip(int id, const QString& tip) +{ + QToolTip::add(button(id),tip); +} + +void AppIcons::remove(int id) +{ + buttons.remove(id); +} + +void AppIcons::receive( const QCString &msg, const QByteArray &data ) +{ + QDataStream stream( data, IO_ReadOnly ); + if ( msg == "remove(int)" ) { + int id; + stream >> id; + remove(id); + } else if ( msg == "setIcon(int,QPixmap)" ) { + int id; + QPixmap pm; + stream >> id >> pm; + setIcon(id,pm); + } else if ( msg == "setToolTip(int,QString)" ) { + int id; + QString s; + stream >> id >> s; + setToolTip(id,s); + } +} + +#include "appicons.moc" diff --git a/core/launcher/appicons.h b/core/launcher/appicons.h new file mode 100644 index 0000000..f53f4a7 --- a/dev/null +++ b/core/launcher/appicons.h @@ -0,0 +1,51 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 APPICONS_H +#define APPICONS_H + + +#include <qhbox.h> +#include <qintdict.h> +#include <qlabel.h> + + +class AppIcons : public QHBox +{ + Q_OBJECT + +public: + AppIcons( QWidget *parent ); + void setIcon(int id, const QPixmap&); + void setToolTip(int id, const QString&); + void remove(int id); + +private slots: + void receive( const QCString &msg, const QByteArray &data ); + void clicked(const QPoint& relpos, int button, bool dbl); + +private: + QIntDict<QLabel> buttons; + QLabel* button(int id); + int findId(QLabel*); +}; + + +#endif diff --git a/core/launcher/apps.h b/core/launcher/apps.h new file mode 100644 index 0000000..6216941 --- a/dev/null +++ b/core/launcher/apps.h @@ -0,0 +1,83 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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. +** +**********************************************************************/ + + +// To add a new app, include appropriate files and add another APP(). + +#ifndef APP_INCLUDES +#define APP_INCLUDES + +#include "../addressbook/addressbook.h" +#include "../datebook/datebook.h" +#include "../helpbrowser/helpbrowser.h" +#include "../minesweep/minesweep.h" +#include "../textedit/textedit.h" +#include "../todo/mainwindow.h" +#include "../citytime/citytime.h" +#include "../clock/clock.h" +#include "../calculator/calculatorimpl.h" +#include "../sysinfo/sysinfo.h" +#include "../settings/appearance/settings.h" +//#include "../settings/language/settings.h" +//#include "../settings/light-and-power/settings.h" +//#include "../settings/rotation/settings.h" +#include "../settings/systemtime/settime.h" +#if !defined(QT_QPE_SMALL_BUILD) +#include "../filebrowser/filebrowser.h" +#include "../solitaire/canvascardwindow.h" +#include "../snake/interface.h" +#include "../parashoot/interface.h" +#include "../mpegplayer/mediaplayer.h" +#endif +#if !defined(QT_DEMO_SINGLE_FLOPPY) && !defined(QT_QPE_SMALL_BUILD) +#include "../embeddedkonsole/konsole.h" +#include "../wordgame/wordgame.h" +#endif + +#endif + +// app-id class maximize? documentary? + +APP( "addressbook", AddressbookWindow, 1, 0 ) +APP( "datebook", DateBook, 1, 0 ) +APP( "helpbrowser", HelpBrowser, 1, 1 ) +APP( "textedit", TextEdit, 1, 1 ) +APP( "todo", TodoWindow, 1, 0 ) +APP( "calculator", CalculatorImpl, 1, 0 ) +APP( "citytime", CityTime, 1, 0 ) +APP( "clock", Clock, 1, 0 ) +APP( "minesweep", MineSweep, 1, 0 ) +APP( "sysinfo", SystemInfo, 1, 0 ) +APP( "appearance", AppearanceSettings, 1, 0 ) +APP( "systemtime", SetDateTime, 1, 0 ) +#if !defined(QT_QPE_SMALL_BUILD) +//APP( "light-and-power", LightSettings, 1, 0 ) +//APP( "sound", SoundSettings, 1, 0 ) +APP( "filebrowser", FileBrowser, 1, 0 ) +APP( "solitaire", CanvasCardWindow, 1, 0 ) +APP( "snake", SnakeGame, 1, 0 ) +APP( "parashoot", ParaShoot, 1, 0 ) +APP( "mpegplayer", MediaPlayer, 1, 0 ) +#endif +#if !defined(QT_DEMO_SINGLE_FLOPPY) && !defined(QT_QPE_SMALL_BUILD) +APP( "embeddedkonsole", Konsole, 1, 0 ) +APP( "wordgame", WordGame, 1, 0 ) +#endif + diff --git a/core/launcher/background.cpp b/core/launcher/background.cpp new file mode 100644 index 0000000..04ebc37 --- a/dev/null +++ b/core/launcher/background.cpp @@ -0,0 +1,41 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 "background.h" +#include "desktop.h" + +#include <qpe/resource.h> + +#include <qpainter.h> + + +Background::Background( Desktop *d ) : + QWidget( d, 0, WStyle_Tool | WStyle_Customize ) +{ +/* + if ( QPixmap::defaultDepth() < 12 ) { + setBackgroundColor(QColor(0x20, 0xb0, 0x50)); + } else { + setBackgroundPixmap( Resource::loadPixmap( "bg" ) ); + } +*/ + setBackgroundMode( PaletteButton ); +} + diff --git a/core/launcher/background.h b/core/launcher/background.h new file mode 100644 index 0000000..0885747 --- a/dev/null +++ b/core/launcher/background.h @@ -0,0 +1,40 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 __BACKGROUND_H__ +#define __BACKGROUND_H__ + + +#include <qwidget.h> + + +class Desktop; + + +class Background : public QWidget { + Q_OBJECT +public: + Background( Desktop *d ); +}; + + +#endif // __BACKGROUND_H__ + + diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp new file mode 100644 index 0000000..d39af25 --- a/dev/null +++ b/core/launcher/desktop.cpp @@ -0,0 +1,655 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 "desktop.h" +#include "info.h" +#include "launcher.h" +#include "mrulist.h" +#include "qcopbridge.h" +#include "shutdownimpl.h" +#include "startmenu.h" +#include "taskbar.h" +#include "transferserver.h" +#include "irserver.h" +#include "packageslave.h" + +#include <qpe/applnk.h> +#include <qpe/mimetype.h> +#include <qpe/password.h> +#include <qpe/config.h> +#include <qpe/power.h> +#include <qpe/qcopenvelope_qws.h> +#include <qpe/global.h> +#ifdef QT_QWS_CUSTOM +#include "qpe/custom.h" +#endif + +#include <qgfx_qws.h> +#include <qmainwindow.h> +#include <qmessagebox.h> +#include <qtimer.h> +#include <qwindowsystem_qws.h> + +#include <stdlib.h> +#include <unistd.h> + +static Desktop* qpedesktop = 0; +static int loggedin=0; +static void login(bool at_poweron) +{ + if ( !loggedin ) { + Global::terminateBuiltin("calibrate"); + Password::authenticate(at_poweron); + loggedin=1; + QCopEnvelope e( "QPE/Desktop", "unlocked()" ); + } +} + +bool Desktop::screenLocked() +{ + return loggedin == 0; +} + +/* + Priority is number of alerts that are needed to pop up + alert. + */ +class DesktopPowerAlerter : public QMessageBox +{ +public: + DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) + : QMessageBox( tr("Battery Status"), "Low Battery", + QMessageBox::Critical, + QMessageBox::Ok | QMessageBox::Default, + QMessageBox::NoButton, QMessageBox::NoButton, + parent, name, FALSE ) + { + currentPriority = INT_MAX; + alertCount = 0; + } + + void alert( const QString &text, int priority ); + void hideEvent( QHideEvent * ); +private: + int currentPriority; + int alertCount; +}; + +void DesktopPowerAlerter::alert( const QString &text, int priority ) +{ + alertCount++; + if ( alertCount < priority ) + return; + if ( priority > currentPriority ) + return; + currentPriority = priority; + setText( text ); + show(); +} + + +void DesktopPowerAlerter::hideEvent( QHideEvent *e ) +{ + QMessageBox::hideEvent( e ); + alertCount = 0; + currentPriority = INT_MAX; +} + + + +DesktopApplication::DesktopApplication( int& argc, char **argv, Type t ) + : QPEApplication( argc, argv, t ) +{ + + QTimer *t = new QTimer( this ); + connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); + t->start( 10000 ); + ps = new PowerStatus; + pa = new DesktopPowerAlerter( 0 ); +} + + +DesktopApplication::~DesktopApplication() +{ + delete ps; + delete pa; +} + + +enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; + +#ifdef Q_WS_QWS +bool DesktopApplication::qwsEventFilter( QWSEvent *e ) +{ + qpedesktop->checkMemory(); + + if ( e->type == QWSEvent::Key ) { + QWSKeyEvent *ke = (QWSKeyEvent *)e; + if ( !loggedin && ke->simpleData.keycode != Key_F34 ) + return TRUE; + bool press = ke->simpleData.is_press; + if ( !keyboardGrabbed() ) { + if ( ke->simpleData.keycode == Key_F9 ) { + if ( press ) emit datebook(); + return TRUE; + } + if ( ke->simpleData.keycode == Key_F10 ) { + if ( !press && cardSendTimer ) { + emit contacts(); + delete cardSendTimer; + } else if ( press ) { + cardSendTimer = new QTimer(); + cardSendTimer->start( 2000, TRUE ); + connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); + } + return TRUE; + } + /* menu key now opens application menu/toolbar + if ( ke->simpleData.keycode == Key_F11 ) { + if ( press ) emit menu(); + return TRUE; + } + */ + if ( ke->simpleData.keycode == Key_F12 ) { + while( activePopupWidget() ) + activePopupWidget()->close(); + if ( press ) emit launch(); + return TRUE; + } + if ( ke->simpleData.keycode == Key_F13 ) { + if ( press ) emit email(); + return TRUE; + } + } + if ( ke->simpleData.keycode == Key_F34 ) { + if ( press ) emit power(); + return TRUE; + } + if ( ke->simpleData.keycode == Key_F35 ) { + if ( press ) emit backlight(); + return TRUE; + } + if ( ke->simpleData.keycode == Key_F32 ) { + if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); + return TRUE; + } + if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { + if ( press ) emit symbol(); + return TRUE; + } + if ( ke->simpleData.keycode == Key_NumLock ) { + if ( press ) emit numLockStateToggle(); + } + if ( ke->simpleData.keycode == Key_CapsLock ) { + if ( press ) emit capsLockStateToggle(); + } + if ( press ) + qpedesktop->keyClick(); + } else { + if ( e->type == QWSEvent::Mouse ) { + QWSMouseEvent *me = (QWSMouseEvent *)e; + static bool up = TRUE; + if ( me->simpleData.state&LeftButton ) { + if ( up ) { + up = FALSE; + qpedesktop->screenClick(); + } + } else { + up = TRUE; + } + } + } + + return QPEApplication::qwsEventFilter( e ); +} +#endif + +void DesktopApplication::psTimeout() +{ + qpedesktop->checkMemory(); // in case no events are being generated + + *ps = PowerStatusManager::readStatus(); + + if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { + pa->alert( tr( "Battery is running very low." ), 6 ); + } + + if ( ps->batteryStatus() == PowerStatus::Critical ) { + pa->alert( tr( "Battery level is critical!\n" + "Keep power off until power restored!" ), 1 ); + } + + if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { + pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); + } +} + + +void DesktopApplication::sendCard() +{ + delete cardSendTimer; + cardSendTimer = 0; + QString card = getenv("HOME"); + card += "/Applications/addressbook/businesscard.vcf"; + + if ( QFile::exists( card ) ) { + QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); + QString mimetype = "text/x-vCard"; + e << tr("business card") << card << mimetype; + } +} + +#if defined(QPE_HAVE_MEMALERTER) +QPE_MEMALERTER_IMPL +#endif + +#if defined(CUSTOM_SOUND_IMPL) +CUSTOM_SOUND_IMPL +#endif + +//=========================================================================== + +Desktop::Desktop() : + QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), + qcopBridge( 0 ), + transferServer( 0 ), + packageSlave( 0 ) +{ +#ifdef CUSTOM_SOUND_INIT + CUSTOM_SOUND_INIT; +#endif + + qpedesktop = this; + +// bg = new Info( this ); + tb = new TaskBar; + + launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); + + connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); + connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); + + int displayw = qApp->desktop()->width(); + int displayh = qApp->desktop()->height(); + + + QSize sz = tb->sizeHint(); + + setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); + tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); + + tb->show(); + launcher->showMaximized(); + launcher->show(); + launcher->raise(); +#if defined(QPE_HAVE_MEMALERTER) + initMemalerter(); +#endif + // start services + startTransferServer(); + (void) new IrServer( this ); + rereadVolumes(); + + packageSlave = new PackageSlave( this ); + connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); + + qApp->installEventFilter( this ); +} + +void Desktop::show() +{ + login(TRUE); + QWidget::show(); +} + +Desktop::~Desktop() +{ + delete launcher; + delete tb; + delete qcopBridge; + delete transferServer; +} + +bool Desktop::recoverMemory() +{ + return tb->recoverMemory(); +} + +void Desktop::checkMemory() +{ +#if defined(QPE_HAVE_MEMALERTER) + static bool ignoreNormal=FALSE; + static bool existingMessage=FALSE; + + if(existingMessage) + return; // don't show a second message while still on first + + existingMessage = TRUE; + switch ( memstate ) { + case Unknown: + break; + case Low: + memstate = Unknown; + if ( recoverMemory() ) + ignoreNormal = TRUE; + else + QMessageBox::warning( 0 , "Memory Status", + "The memory smacks of shortage. \n" + "Please save data. " ); + break; + case Normal: + memstate = Unknown; + if ( ignoreNormal ) + ignoreNormal = FALSE; + else + QMessageBox::information ( 0 , "Memory Status", + "There is enough memory again." ); + break; + case VeryLow: + memstate = Unknown; + QMessageBox::critical( 0 , "Memory Status", + "The memory is very low. \n" + "Please end this application \n" + "immediately." ); + recoverMemory(); + } + existingMessage = FALSE; +#endif +} + +static bool isVisibleWindow(int wid) +{ + const QList<QWSWindow> &list = qwsServer->clientWindows(); + QWSWindow* w; + for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { + if ( w->winId() == wid ) + return !w->isFullyObscured(); + } + return FALSE; +} + +static bool hasVisibleWindow(const QString& clientname) +{ + const QList<QWSWindow> &list = qwsServer->clientWindows(); + QWSWindow* w; + for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { + if ( w->client()->identity() == clientname && !w->isFullyObscured() ) + return TRUE; + } + return FALSE; +} + +void Desktop::raiseLauncher() +{ + if ( isVisibleWindow(launcher->winId()) ) + launcher->nextView(); + else + launcher->raise(); +} + +void Desktop::executeOrModify(const QString& appLnkFile) +{ + AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); + if ( lnk.isValid() ) { + QCString app = lnk.exec().utf8(); + Global::terminateBuiltin("calibrate"); + if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { + MRUList::addTask(&lnk); + if ( hasVisibleWindow(app) ) + QCopChannel::send("QPE/Application/" + app, "nextView()"); + else + QCopChannel::send("QPE/Application/" + app, "raise()"); + } else { + lnk.execute(); + } + } +} + +void Desktop::raiseDatebook() +{ + executeOrModify("Applications/datebook.desktop"); +} + +void Desktop::raiseContacts() +{ + executeOrModify("Applications/addressbook.desktop"); +} + +void Desktop::raiseMenu() +{ + Global::terminateBuiltin("calibrate"); + tb->startMenu()->launch(); +} + +void Desktop::raiseEmail() +{ + executeOrModify("Applications/qtmail.desktop"); +} + +#if defined(QPE_HAVE_TOGGLELIGHT) +#include <qpe/config.h> + +#include <sys/ioctl.h> +#include <sys/types.h> +#include <fcntl.h> +#include <unistd.h> +#include <errno.h> +#include <linux/ioctl.h> +#include <time.h> +#endif + +static bool blanked=FALSE; + +static void blankScreen() +{ + if ( !qt_screen ) return; + /* Should use a big black window instead. + QGfx* g = qt_screen->screenGfx(); + g->fillRect(0,0,qt_screen->width(),qt_screen->height()); + delete g; + */ + blanked = TRUE; +} + +static void darkScreen() +{ + extern void qpe_setBacklight(int); + qpe_setBacklight(0); // force off +} + + +void Desktop::togglePower() +{ + bool wasloggedin = loggedin; + loggedin=0; + darkScreen(); + if ( wasloggedin ) + blankScreen(); + system("apm --suspend"); + QWSServer::screenSaverActivate( FALSE ); + { + QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep + QCopEnvelope e("QPE/System", "setBacklight(int)"); + e << -3; // Force on + } + if ( wasloggedin ) + login(TRUE); + //qcopBridge->closeOpenConnections(); + //qDebug("called togglePower()!!!!!!"); +} + +void Desktop::toggleLight() +{ + QCopEnvelope e("QPE/System", "setBacklight(int)"); + e << -2; // toggle +} + +void Desktop::toggleSymbolInput() +{ + tb->toggleSymbolInput(); +} + +void Desktop::toggleNumLockState() +{ + tb->toggleNumLockState(); +} + +void Desktop::toggleCapsLockState() +{ + tb->toggleCapsLockState(); +} + +void Desktop::styleChange( QStyle &s ) +{ + QWidget::styleChange( s ); + int displayw = qApp->desktop()->width(); + int displayh = qApp->desktop()->height(); + + QSize sz = tb->sizeHint(); + + tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); +} + +void DesktopApplication::shutdown() +{ + if ( type() != GuiServer ) + return; + ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); + connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), + this, SLOT(shutdown(ShutdownImpl::Type)) ); + sd->showMaximized(); +} + +void DesktopApplication::shutdown( ShutdownImpl::Type t ) +{ + switch ( t ) { + case ShutdownImpl::ShutdownSystem: + execlp("shutdown", "shutdown", "-h", "now", (void*)0); + break; + case ShutdownImpl::RebootSystem: + execlp("shutdown", "shutdown", "-r", "now", (void*)0); + break; + case ShutdownImpl::RestartDesktop: + restart(); + break; + case ShutdownImpl::TerminateDesktop: + prepareForTermination(FALSE); + quit(); + break; + } +} + +void DesktopApplication::restart() +{ + prepareForTermination(TRUE); + +#ifdef Q_WS_QWS + for ( int fd = 3; fd < 100; fd++ ) + close( fd ); +#if defined(QT_DEMO_SINGLE_FLOPPY) + execl( "/sbin/init", "qpe", 0 ); +#elif defined(QT_QWS_CASSIOPEIA) + execl( "/bin/sh", "sh", 0 ); +#else + execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); +#endif + exit(1); +#endif +} + +void Desktop::startTransferServer() +{ + // start qcop bridge server + qcopBridge = new QCopBridge( 4243 ); + if ( !qcopBridge->ok() ) { + delete qcopBridge; + qcopBridge = 0; + } + // start transfer server + transferServer = new TransferServer( 4242 ); + if ( !transferServer->ok() ) { + delete transferServer; + transferServer = 0; + } + if ( !transferServer || !qcopBridge ) + startTimer( 2000 ); +} + +void Desktop::timerEvent( QTimerEvent *e ) +{ + killTimer( e->timerId() ); + startTransferServer(); +} + +void Desktop::terminateServers() +{ + delete transferServer; + delete qcopBridge; + transferServer = 0; + qcopBridge = 0; +} + +void Desktop::rereadVolumes() +{ + Config cfg("Sound"); + cfg.setGroup("System"); + touchclick = cfg.readBoolEntry("Touch"); + keyclick = cfg.readBoolEntry("Key"); +} + +void Desktop::keyClick() +{ +#ifdef CUSTOM_SOUND_KEYCLICK + if ( keyclick ) + CUSTOM_SOUND_KEYCLICK; +#endif +} + +void Desktop::screenClick() +{ +#ifdef CUSTOM_SOUND_TOUCH + if ( touchclick ) + CUSTOM_SOUND_TOUCH; +#endif +} + +void Desktop::soundAlarm() +{ +#ifdef CUSTOM_SOUND_ALARM + CUSTOM_SOUND_ALARM; +#endif +} + +bool Desktop::eventFilter( QObject *w, QEvent *ev ) +{ + if ( ev->type() == QEvent::KeyPress ) { + QKeyEvent *ke = (QKeyEvent *)ev; + if ( ke->key() == Qt::Key_F11 ) { // menu key + QWidget *active = qApp->activeWindow(); + if ( active && active->isPopup() ) { + active->close(); + } + raiseMenu(); + return TRUE; + } + } + return FALSE; +} + diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h new file mode 100644 index 0000000..dfdbeab --- a/dev/null +++ b/core/launcher/desktop.h @@ -0,0 +1,129 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 __DESKTOP_H__ +#define __DESKTOP_H__ + + +#include "shutdownimpl.h" + +#include <qpe/qpeapplication.h> + +#include <qwidget.h> + +class Background; +class Launcher; +class TaskBar; +class PowerStatus; +class QCopBridge; +class TransferServer; +class DesktopPowerAlerter; +class PackageSlave; + +class DesktopApplication : public QPEApplication +{ + Q_OBJECT +public: + DesktopApplication( int& argc, char **argv, Type t ); + ~DesktopApplication(); +signals: + void home(); + void datebook(); + void contacts(); + void launch(); + void email(); + void backlight(); + void power(); + void symbol(); + void numLockStateToggle(); + void capsLockStateToggle(); + void prepareForRestart(); + +protected: +#ifdef Q_WS_QWS + bool qwsEventFilter( QWSEvent * ); +#endif + void shutdown(); + void restart(); + +protected slots: + void shutdown(ShutdownImpl::Type); + void psTimeout(); + void sendCard(); +private: + DesktopPowerAlerter *pa; + PowerStatus *ps; + QTimer *cardSendTimer; +}; + + +class Desktop : public QWidget { + Q_OBJECT +public: + Desktop(); + ~Desktop(); + + static bool screenLocked(); + + void show(); + void checkMemory(); + + void keyClick(); + void screenClick(); + static void soundAlarm(); + +public slots: + void raiseDatebook(); + void raiseContacts(); + void raiseMenu(); + void raiseLauncher(); + void raiseEmail(); + void togglePower(); + void toggleLight(); + void toggleNumLockState(); + void toggleCapsLockState(); + void toggleSymbolInput(); + void terminateServers(); + void rereadVolumes(); + +protected: + void executeOrModify(const QString& appLnkFile); + void styleChange( QStyle & ); + void timerEvent( QTimerEvent *e ); + bool eventFilter( QObject *, QEvent * ); + + QWidget *bg; + Launcher *launcher; + TaskBar *tb; + +private: + void startTransferServer(); + bool recoverMemory(); + + QCopBridge *qcopBridge; + TransferServer *transferServer; + PackageSlave *packageSlave; + + bool keyclick,touchclick; +}; + + +#endif // __DESKTOP_H__ + diff --git a/core/launcher/info.cpp b/core/launcher/info.cpp new file mode 100644 index 0000000..609e9e2 --- a/dev/null +++ b/core/launcher/info.cpp @@ -0,0 +1,116 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 "info.h" +#include "desktop.h" + +#include <qpe/resource.h> +#include <qpe/version.h> + +#include <qlayout.h> +#include <qimage.h> +#include <qpainter.h> +#include <qsimplerichtext.h> + + +Info *desktopInfo = NULL; + + +Info::Info( Desktop *d ) : Background( d ), needsClear(FALSE), menuHasBeenClicked(FALSE) +{ + QString motd; + /* eg. + = + "<table width=100% cellspacing=0 cellpadding=2>" + "<tr><td bgcolor=#9090ff><h2>Today <small>June 15, 2001</small></h2></td>" + "<tr><td bgcolor=#c0c0ff><big><a href=datebook>Appointments</a></big>" + "<tr><td bgcolor=#e0e0ff>" + "<b>8:30am</b> Meeting with John<br>" + "<b>1:10pm</b> Lunch with Sharon" + "<tr><td bgcolor=#c0c0ff><big><a href=todo>Reminders</a></big>" + "<tr><td bgcolor=#e0e0ff>" + "<b>#1</b> Port XMAME to QPE<br>" + "<b>#2</b> Flowers for wife" + "<tr><td bgcolor=#c0c0ff><big><a href=channels>Net channels</a></big>" + "<tr><td bgcolor=#e0e0ff>" + "<b>LinuxDevices:</b><a href=http://www.linuxdevices.com> QPE announcement</a><br>" + "<b>Slashdot:</b><a href=http://www.slashdot.org> GPL Examined</a>" + "</table>"; + */ + info = new QSimpleRichText(motd, QFont("lucidux_sans",10)); + desktopInfo = this; +} + + +void Info::mouseReleaseEvent( QMouseEvent * ) +{ +} + + +void Info::menuClicked( ) +{ + QPainter p(this); + if ( needsClear ) { + QColor col = colorGroup().color( QColorGroup::Button ).dark( 0 ); + p.fillRect( 5, height() - 24, width() - 5, 20, col ); + needsClear = FALSE; + menuHasBeenClicked = TRUE; + } +} + + +void Info::paintEvent( QPaintEvent *e ) +{ + QPainter p(this); + + BrushStyle styles[] = { Dense1Pattern, Dense2Pattern, Dense3Pattern, + Dense4Pattern, Dense5Pattern, Dense6Pattern }; + + QColor shade = colorGroup().color( QColorGroup::Button ).dark( 110 ); + int blend = width() * 3 / 4; + int step = blend/6; + p.fillRect( 0, 0, width()-blend, 30, shade ); + for ( int i = 0; i < 6; i++ ) { + QBrush brush( shade, styles[i] ); + p.fillRect( width()-blend+i*step, 0, step, 30, brush ); + } + p.setFont( QFont("Helvetica", 24, QFont::Bold) ); + p.setPen( shade.dark( 140 ) ); + p.drawText( 5, 24, "QPE" ); + int pos = 5 + p.fontMetrics().width( "QPE" ); + QFont f("Helvetica", 10, QFont::Bold); + p.setFont( f ); + p.drawText( pos + 5, 24, QString( "Version " ) + QPE_VERSION ); + + if (!menuHasBeenClicked) { + p.drawText( 5, height()-10, QString( "Click on the " ) ); + int pos = 5 + p.fontMetrics().width( "Click on the " ); + p.drawPixmap( pos, height()-10-14, Resource::loadPixmap( "go" ) ); + p.drawText( pos + 16, height()-10, QString( " logo to start." ) ); + needsClear = TRUE; + } + + if ( info ) { + info->setWidth(&p,width()-10); + info->draw(&p, 5, 35, e->region(), colorGroup()); + } +} + + diff --git a/core/launcher/info.h b/core/launcher/info.h new file mode 100644 index 0000000..317dec5 --- a/dev/null +++ b/core/launcher/info.h @@ -0,0 +1,55 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 __INFO_H__ +#define __INFO_H__ + + +#include <qwidget.h> +#include <qpainter.h> +#include "background.h" + +class QSimpleRichText; + +class Info : public Background { + Q_OBJECT +public: + Info( Desktop *d ); + void menuClicked( ); + +signals: + void giveInfo( ); + +protected: + void mouseReleaseEvent( QMouseEvent *e ); + void paintEvent( QPaintEvent *pe ); + +private: + QSimpleRichText* info; + bool needsClear; + bool menuHasBeenClicked; +}; + + +extern Info *desktopInfo; + + +#endif // __INFO_H__ + diff --git a/core/launcher/inputmethods.cpp b/core/launcher/inputmethods.cpp new file mode 100644 index 0000000..003dc77 --- a/dev/null +++ b/core/launcher/inputmethods.cpp @@ -0,0 +1,297 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 "inputmethods.h" + +#include <qpe/config.h> +#include <qpe/qpeapplication.h> +#include <qpe/inputmethodinterface.h> +#include <qpe/qlibrary.h> + +#include <qpopupmenu.h> +#include <qpushbutton.h> +#include <qtoolbutton.h> +#include <qwidget.h> +#include <qlayout.h> +#include <qtimer.h> +#include <qdir.h> +#include <stdlib.h> +#include <qtranslator.h> + +#ifdef Q_WS_QWS +#include <qwindowsystem_qws.h> +#include <qwsevent_qws.h> +#endif + +#ifdef SINGLE_APP +#include "handwritingimpl.h" +#include "keyboardimpl.h" +#include "pickboardimpl.h" +#endif + + +/* XPM */ +static const char * tri_xpm[]={ +"9 9 2 1", +"a c #000000", +". c None", +".........", +".........", +".........", +"....a....", +"...aaa...", +"..aaaaa..", +".aaaaaaa.", +".........", +"........."}; + +static const int inputWidgetStyle = QWidget::WStyle_Customize | + QWidget::WStyle_Tool | + QWidget::WStyle_StaysOnTop | + QWidget::WGroupLeader; + +InputMethods::InputMethods( QWidget *parent ) : + QWidget( parent, "InputMethods", WStyle_Tool | WStyle_Customize ) +{ + method = NULL; + + QHBoxLayout *hbox = new QHBoxLayout( this ); + + kbdButton = new QToolButton( this ); + kbdButton->setFocusPolicy(NoFocus); + kbdButton->setToggleButton( TRUE ); + kbdButton->setFixedHeight( 17 ); + kbdButton->setFixedWidth( 32 ); + kbdButton->setAutoRaise( TRUE ); + kbdButton->setUsesBigPixmap( TRUE ); + hbox->addWidget( kbdButton ); + connect( kbdButton, SIGNAL(toggled(bool)), this, SLOT(showKbd(bool)) ); + + kbdChoice = new QToolButton( this ); + kbdChoice->setFocusPolicy(NoFocus); + kbdChoice->setPixmap( QPixmap( (const char **)tri_xpm ) ); + kbdChoice->setFixedHeight( 17 ); + kbdChoice->setFixedWidth( 12 ); + kbdChoice->setAutoRaise( TRUE ); + hbox->addWidget( kbdChoice ); + connect( kbdChoice, SIGNAL(clicked()), this, SLOT(chooseKbd()) ); + + connect( (QPEApplication*)qApp, SIGNAL(clientMoused()), + this, SLOT(resetStates()) ); + + loadInputMethods(); +} + +InputMethods::~InputMethods() +{ +#ifndef SINGLE_APP + QValueList<InputMethod>::Iterator mit; + for ( mit = inputMethodList.begin(); mit != inputMethodList.end(); ++mit ) { + int i = (*mit).interface->release(); + (*mit).library->unload(); + delete (*mit).library; + } +#endif +} + +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++ ) { + if ( (*it).interface->name() == name ) { + im = &(*it); + break; + } + } + if ( im ) + chooseMethod(im); +} + +void InputMethods::resetStates() +{ + if ( method ) + method->interface->resetState(); +} + +QRect InputMethods::inputRect() const +{ + if ( !method || !method->widget->isVisible() ) + return QRect(); + else + return method->widget->geometry(); +} + +void InputMethods::loadInputMethods() +{ +#ifndef SINGLE_APP + hideInputMethod(); + method = 0; + + QValueList<InputMethod>::Iterator mit; + for ( mit = inputMethodList.begin(); mit != inputMethodList.end(); ++mit ) { + (*mit).interface->release(); + (*mit).library->unload(); + delete (*mit).library; + } + inputMethodList.clear(); + + QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; + QDir dir( path, "lib*.so" ); + QStringList list = dir.entryList(); + QStringList::Iterator it; + for ( it = list.begin(); it != list.end(); ++it ) { + InputMethodInterface *iface = 0; + QLibrary *lib = new QLibrary( path + "/" + *it ); + if ( lib->queryInterface( IID_InputMethod, (QUnknownInterface**)&iface ) == QS_OK ) { + InputMethod input; + input.library = lib; + input.interface = iface; + input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); + input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); + inputMethodList.append( input ); + 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 for inputmethod: %s", tfn.latin1() ); + if ( trans->load( tfn )) + qApp->installTranslator( trans ); + else + delete trans; + } else { + delete lib; + } + } +#else + InputMethod input; + input.interface = new HandwritingImpl(); + input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); + input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); + inputMethodList.append( input ); + input.interface = new KeyboardImpl(); + input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); + input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); + inputMethodList.append( input ); + input.interface = new PickboardImpl(); + input.widget = input.interface->inputMethod( 0, inputWidgetStyle ); + input.interface->onKeyPress( this, SLOT(sendKey(ushort,ushort,ushort,bool,bool)) ); + inputMethodList.append( input ); +#endif + if ( !inputMethodList.isEmpty() ) { + method = &inputMethodList[0]; + kbdButton->setPixmap( *method->interface->icon() ); + } + if ( !inputMethodList.isEmpty() ) + kbdButton->show(); + else + kbdButton->hide(); + if ( inputMethodList.count() > 1 ) + kbdChoice->show(); + else + kbdChoice->hide(); +} + +void InputMethods::chooseKbd() +{ + QPopupMenu pop( this ); + + int i = 0; + QValueList<InputMethod>::Iterator it; + for ( it = inputMethodList.begin(); it != inputMethodList.end(); ++it, i++ ) { + pop.insertItem( (*it).interface->name(), i ); + if ( method == &(*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]; + chooseMethod(im); +} + +void InputMethods::chooseMethod(InputMethod* im) +{ + if ( im != method ) { + if ( method && method->widget->isVisible() ) + method->widget->hide(); + method = im; + kbdButton->setPixmap( *method->interface->icon() ); + } + if ( !kbdButton->isOn() ) + kbdButton->setOn( TRUE ); + else + showKbd( TRUE ); +} + + +void InputMethods::showKbd( bool on ) +{ + if ( !method ) + return; + + if ( on ) { + method->interface->resetState(); + // HACK... Make the texteditor fit with all input methods + // Input methods should also never use more than about 40% of the screen + int height = QMIN( method->widget->sizeHint().height(), 134 ); + method->widget->resize( qApp->desktop()->width(), height ); + method->widget->move( 0, mapToGlobal( QPoint() ).y() - height ); + method->widget->show(); + } else { + method->widget->hide(); + } + + emit inputToggled( on ); +} + +bool InputMethods::shown() const +{ + return method && method->widget->isVisible(); +} + +QString InputMethods::currentShown() const +{ + return method && method->widget->isVisible() + ? method->interface->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/inputmethods.h b/core/launcher/inputmethods.h new file mode 100644 index 0000000..286a818 --- a/dev/null +++ b/core/launcher/inputmethods.h @@ -0,0 +1,76 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 __INPUT_METHODS_H__ +#define __INPUT_METHODS_H__ + + +#include <qpe/inputmethodinterface.h> + +#include <qwidget.h> +#include <qvaluelist.h> + +class QToolButton; +class QLibrary; + +struct InputMethod +{ +#ifndef QT_NO_COMPONENT + QLibrary *library; +#endif + QWidget *widget; + InputMethodInterface *interface; +}; + +class InputMethods : public QWidget +{ + Q_OBJECT +public: + InputMethods( QWidget * ); + ~InputMethods(); + + QRect inputRect() const; + bool shown() const; + QString currentShown() const; // name of interface + void showInputMethod(const QString& id); + void showInputMethod(); + void hideInputMethod(); + void loadInputMethods(); + +signals: + void inputToggled( bool on ); + +private slots: + void chooseKbd(); + void showKbd( bool ); + void resetStates(); + void sendKey( ushort unicode, ushort scancode, ushort modifiers, bool, bool ); + +private: + void chooseMethod(InputMethod* im); + QToolButton *kbdButton; + QToolButton *kbdChoice; + InputMethod *method; + QValueList<InputMethod> inputMethodList; +}; + + +#endif // __INPUT_METHODS_H__ + diff --git a/core/launcher/irserver.cpp b/core/launcher/irserver.cpp new file mode 100644 index 0000000..b22e064 --- a/dev/null +++ b/core/launcher/irserver.cpp @@ -0,0 +1,50 @@ +#include "irserver.h" + +#include <qpe/qlibrary.h> +#include <qpe/qpeapplication.h> + +#include <qtranslator.h> +#include <stdlib.h> + +#include "obexinterface.h" + +#include <qdir.h> + +IrServer::IrServer( QObject *parent, const char *name ) + : QObject( parent, name ) +{ + lib = 0; + QString path = QPEApplication::qpeDir() + "/plugins/obex/"; + QDir dir( path, "lib*.so" ); + QStringList list = dir.entryList(); + QStringList::Iterator it; + for ( it = list.begin(); it != list.end(); ++it ) { + ObexInterface *iface = 0; + QLibrary *trylib = new QLibrary( path + *it ); + qDebug("trying lib %s", (path + (*it)).latin1() ); + if ( trylib->queryInterface( IID_ObexInterface, (QUnknownInterface**)&iface ) == 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() +{ + delete lib; +} diff --git a/core/launcher/irserver.h b/core/launcher/irserver.h new file mode 100644 index 0000000..f9f682f --- a/dev/null +++ b/core/launcher/irserver.h @@ -0,0 +1,20 @@ +#ifndef IRSERVER_H +#define IRSERVER_H + +#include <qobject.h> + +class QCopChannel; +class QLibrary; + +class IrServer : public QObject +{ + Q_OBJECT +public: + IrServer( QObject *parent = 0, const char *name = 0 ); + ~IrServer(); + +private: + QLibrary *lib; +}; + +#endif diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp new file mode 100644 index 0000000..66a2ce5 --- a/dev/null +++ b/core/launcher/launcher.cpp @@ -0,0 +1,804 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 <qpe/qcopenvelope_qws.h> +#include <qpe/resource.h> +#include <qpe/applnk.h> +#include <qpe/config.h> +#include <qpe/global.h> +#include <qpe/qpeapplication.h> +#include <qpe/mimetype.h> +#include <qpe/storage.h> +#include <qpe/palmtoprecord.h> + +#include <qdir.h> +#include <qwindowsystem_qws.h> +#include <qtimer.h> +#include <qcombobox.h> +#include <qvbox.h> +#include <qlayout.h> +#include <qstyle.h> +#include <qpushbutton.h> +#include <qtabbar.h> +#include <qwidgetstack.h> +#include <qlayout.h> +#include <qregexp.h> +#include <qmessagebox.h> +#include <qframe.h> +#include <qpainter.h> +#include <qlabel.h> +#include <qtextstream.h> + +#include "launcherview.h" +#include "launcher.h" +#include "syncdialog.h" +#include "desktop.h" +#include <qpe/lnkproperties.h> +#include "mrulist.h" +#include "qrsync.h" +#include <stdlib.h> +#include <unistd.h> + +#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) +#include <stdio.h> +#include <sys/vfs.h> +#include <mntent.h> +#endif + +//#define SHOW_ALL + +CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : + QVBox( parent ) +{ + categoryBar = 0; + stack = 0; +} + +void CategoryTabWidget::prevTab() +{ + if ( categoryBar ) { + int n = categoryBar->count(); + int tab = categoryBar->currentTab(); + if ( tab >= 0 ) + categoryBar->setCurrentTab( (tab - 1 + n)%n ); + } +} + +void CategoryTabWidget::nextTab() +{ + if ( categoryBar ) { + int n = categoryBar->count(); + int tab = categoryBar->currentTab(); + categoryBar->setCurrentTab( (tab + 1)%n ); + } +} + +void CategoryTabWidget::addItem( const QString& linkfile ) +{ + int i=0; + AppLnk *app = new AppLnk(linkfile); + if ( !app->isValid() ) { + delete app; + return; + } + if ( !app->file().isEmpty() ) { + // A document + delete app; + app = new DocLnk(linkfile); + ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); + return; + } + for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { + if ( !(*it).isEmpty() ) { + QRegExp tf(*it,FALSE,TRUE); + if ( tf.match(app->type()) >= 0 ) { + ((LauncherView*)stack->widget(i))->addItem(app); + return; + } + i++; + } + } +} + +void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, + AppLnkSet* docFolder, const QList<FileSystem> &fs) +{ + delete categoryBar; + categoryBar = new CategoryTabBar( this ); + QPalette pal = categoryBar->palette(); + pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); + pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); + categoryBar->setPalette( pal ); + + delete stack; + stack = new QWidgetStack(this); + tabs=0; + + ids.clear(); + + QStringList types = rootFolder->types(); + for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { + if ( !(*it).isEmpty() ) { + newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); + } + } + QListIterator<AppLnk> it( rootFolder->children() ); + AppLnk* l; + while ( (l=it.current()) ) { + if ( l->type() == "Separator" ) { + rootFolder->remove(l); + delete l; + } else { + int i=0; + for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { + if ( *it == l->type() ) + ((LauncherView*)stack->widget(i))->addItem(l,FALSE); + i++; + } + } + ++it; + } + rootFolder->detachChildren(); + for (int i=0; i<tabs; i++) + ((LauncherView*)stack->widget(i))->sort(); + + // all documents + docview = newView( QString::null, Resource::loadPixmap("DocsIcon"), tr("Documents")); + docview->populate( docFolder, QString::null ); + docFolder->detachChildren(); + docview->setFileSystems(fs); + docview->setToolsEnabled(TRUE); + + connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); + + ((LauncherView*)stack->widget(0))->setFocus(); + + categoryBar->show(); + stack->show(); +} + +void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) +{ + docview->populate( docFolder, QString::null ); + docFolder->detachChildren(); + docview->setFileSystems(fs); + docview->updateTools(); +} + +LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) +{ + LauncherView* view = new LauncherView( stack ); + connect( view, SIGNAL(clicked(const AppLnk*)), + this, SIGNAL(clicked(const AppLnk*))); + connect( view, SIGNAL(rightPressed(AppLnk*)), + this, SIGNAL(rightPressed(AppLnk*))); + ids.append(id); + categoryBar->addTab( new QTab( pm, label ) ); + stack->addWidget( view, tabs++ ); + return view; +} + +void CategoryTabWidget::updateLink(const QString& linkfile) +{ + int i=0; + LauncherView* view; + while ((view = (LauncherView*)stack->widget(i++))) { + if ( view->removeLink(linkfile) ) + break; + } + addItem(linkfile); + docview->updateTools(); +} + +void CategoryTabWidget::paletteChange( const QPalette &p ) +{ + QVBox::paletteChange( p ); + QPalette pal = palette(); + pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); + pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); + categoryBar->setPalette( pal ); + categoryBar->update(); +} + +void CategoryTabWidget::setBusy(bool on) +{ + if ( on ) + ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); + else + for (int i=0; i<tabs; i++) + ((LauncherView*)stack->widget(i))->setBusy(FALSE); +} + + +CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) + : QTabBar( parent, name ) +{ + setFocusPolicy( NoFocus ); + connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); +} + +CategoryTabBar::~CategoryTabBar() +{ +} + +void CategoryTabBar::layoutTabs() +{ + if ( !count() ) + return; + +// int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; + int hiddenTabWidth = -12; + int middleTab = currentTab(); + int hframe, vframe, overlap; + style().tabbarMetrics( this, hframe, vframe, overlap ); + QFontMetrics fm = fontMetrics(); + int x = 0; + QRect r; + QTab *t; + int available = width()-1; + int required = 0; + for ( int i = 0; i < count(); i++ ) { + t = tab(i); + // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { + if ( i != middleTab ) { + // required += hiddenTabWidth + hframe - overlap; + available -= hiddenTabWidth + hframe - overlap; + if ( t->iconSet() != 0 ) + available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); + } else { + required += fm.width( t->text() ) + hframe - overlap; + if ( t->iconSet() != 0 ) + required += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); + } + } + for ( int i = 0; i < count(); i++ ) { + t = tab(i); + // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { + if ( i != middleTab ) { + int w = hiddenTabWidth; + int ih = 0; + if ( t->iconSet() != 0 ) { + w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); + ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); + } + int h = QMAX( fm.height(), ih ); + h = QMAX( h, QApplication::globalStrut().height() ); + + h += vframe; + w += hframe; + + t->setRect( QRect(x, 0, w, h) ); + x += t->rect().width() - overlap; + r = r.unite( t->rect() ); + } else { + int w = fm.width( t->text() ); + int ih = 0; + if ( t->iconSet() != 0 ) { + w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); + ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); + } + int h = QMAX( fm.height(), ih ); + h = QMAX( h, QApplication::globalStrut().height() ); + + h += vframe; + w += hframe; + + // t->setRect( QRect(x, 0, w * available/required, h) ); + t->setRect( QRect(x, 0, available, h) ); + x += t->rect().width() - overlap; + r = r.unite( t->rect() ); + } + } + + QRect rr = tab(count()-1)->rect(); + rr.setRight(width()-1); + tab(count()-1)->setRect( rr ); + + for ( t = tabList()->first(); t; t = tabList()->next() ) { + QRect tr = t->rect(); + tr.setHeight( r.height() ); + t->setRect( tr ); + } + + update(); +} + + +void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const +{ +#if QT_VERSION >= 300 + QStyle::SFlags flags = QStyle::Style_Default; + if ( selected ) + flags |= QStyle::Style_Selected; + style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), + colorGroup(), flags, QStyleOption(t) ); +#else + style().drawTab( p, this, t, selected ); +#endif + + QRect r( t->rect() ); + QFont f( font() ); + if ( selected ) + f.setBold( TRUE ); + p->setFont( f ); + + int iw = 0; + int ih = 0; + if ( t->iconSet() != 0 ) { + iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; + ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); + } + int w = iw + p->fontMetrics().width( t->text() ) + 4; + int h = QMAX(p->fontMetrics().height() + 4, ih ); + paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, + r.top() + (r.height()-h)/2, w, h ), t, +#if QT_VERSION >= 300 + t->identifier() == keyboardFocusTab() +#else + t->identitifer() == keyboardFocusTab() +#endif + ); +} + + +void CategoryTabBar::paintLabel( QPainter* p, const QRect&, + QTab* t, bool has_focus ) const +{ + QRect r = t->rect(); + // if ( t->id != currentTab() ) + //r.moveBy( 1, 1 ); + // + if ( t->iconSet() ) { + // the tab has an iconset, draw it in the right mode + QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; + if ( mode == QIconSet::Normal && has_focus ) + mode = QIconSet::Active; + QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); + int pixw = pixmap.width(); + int pixh = pixmap.height(); + p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); + r.setLeft( r.left() + pixw + 5 ); + } + + QRect tr = r; + + if ( r.width() < 20 ) + return; + + if ( t->isEnabled() && isEnabled() ) { +#if defined(_WS_WIN32_) + if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) + p->setPen( colorGroup().buttonText() ); + else + p->setPen( colorGroup().foreground() ); +#else + p->setPen( colorGroup().foreground() ); +#endif + p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); + } else { + p->setPen( palette().disabled().foreground() ); + p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); + } +} + +//--------------------------------------------------------------------------- + +Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) + : QMainWindow( parent, name, fl ) +{ + setCaption( tr("Launcher") ); + + syncDialog = 0; + + // we have a pretty good idea how big we'll be + setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); + + tabs = 0; + rootFolder = 0; + docsFolder = 0; + + tabs = new CategoryTabWidget( this ); + tabs->setMaximumWidth( qApp->desktop()->width() ); + setCentralWidget( tabs ); + + connect( tabs, SIGNAL(selected(const QString&)), + this, SLOT(viewSelected(const QString&)) ); + connect( tabs, SIGNAL(clicked(const AppLnk*)), + this, SLOT(select(const AppLnk*))); + connect( tabs, SIGNAL(rightPressed(AppLnk*)), + this, SLOT(properties(AppLnk*))); + +#if defined(Q_WS_QWS) && !defined(QT_NO_COP) + QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); + connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), + this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); +#endif + + storage = new StorageInfo( this ); + connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); + + updateTabs(); + + preloadApps(); + + in_lnk_props = FALSE; + got_lnk_change = FALSE; +} + +Launcher::~Launcher() +{ +} + +static bool isVisibleWindow(int wid) +{ + const QList<QWSWindow> &list = qwsServer->clientWindows(); + QWSWindow* w; + for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { + if ( w->winId() == wid ) + return !w->isFullyObscured(); + } + return FALSE; +} + +void Launcher::showMaximized() +{ + if ( isVisibleWindow( winId() ) ) + doMaximize(); + else + QTimer::singleShot( 20, this, SLOT(doMaximize()) ); +} + +void Launcher::doMaximize() +{ + QMainWindow::showMaximized(); +} + +void Launcher::updateMimeTypes() +{ + MimeType::clear(); + updateMimeTypes(rootFolder); +} + +void Launcher::updateMimeTypes(AppLnkSet* folder) +{ + for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { + AppLnk *app = it.current(); + if ( app->type() == "Folder" ) + updateMimeTypes((AppLnkSet *)app); + else { + MimeType::registerApp(*app); + } + } +} + +void Launcher::loadDocs() +{ + delete docsFolder; + docsFolder = new DocLnkSet; + Global::findDocuments(docsFolder); +} + +void Launcher::updateTabs() +{ + MimeType::updateApplications(); // ### reads all applnks twice + + delete rootFolder; + rootFolder = new AppLnkSet( MimeType::appsFolderName() ); + + loadDocs(); + + tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); +} + +void Launcher::updateDocs() +{ + loadDocs(); + tabs->updateDocs(docsFolder,storage->fileSystems()); +} + +void Launcher::viewSelected(const QString& s) +{ + setCaption( s + tr(" - Launcher") ); +} + +void Launcher::nextView() +{ + tabs->nextTab(); +} + + +void Launcher::select( const AppLnk *appLnk ) +{ + if ( appLnk->type() == "Folder" ) { + // Not supported: flat is simpler for the user + } else { + if ( appLnk->exec().isNull() ) { + QMessageBox::information(this,tr("No application"), + tr("<p>No application is defined for this document." + "<p>Type is %1.").arg(appLnk->type())); + return; + } + tabs->setBusy(TRUE); + emit executing( appLnk ); + appLnk->execute(); + } +} + +void Launcher::externalSelected(const AppLnk *appLnk) +{ + tabs->setBusy(TRUE); + emit executing( appLnk ); +} + +void Launcher::properties( AppLnk *appLnk ) +{ + if ( appLnk->type() == "Folder" ) { + // Not supported: flat is simpler for the user + } else { + in_lnk_props = TRUE; + got_lnk_change = FALSE; + LnkProperties prop(appLnk); + connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); + prop.showMaximized(); + prop.exec(); + in_lnk_props = FALSE; + if ( got_lnk_change ) { + updateLink(lnk_change); + } + } +} + +void Launcher::updateLink(const QString& link) +{ + if (link.isNull()) + updateTabs(); + else if (link.isEmpty()) + updateDocs(); + else + tabs->updateLink(link); +} + +void Launcher::systemMessage( const QCString &msg, const QByteArray &data) +{ + QDataStream stream( data, IO_ReadOnly ); + if ( msg == "linkChanged(QString)" ) { + QString link; + stream >> link; + if ( in_lnk_props ) { + got_lnk_change = TRUE; + lnk_change = link; + } else { + updateLink(link); + } + } else if ( msg == "busy()" ) { + emit busy(); + } else if ( msg == "notBusy(QString)" ) { + QString app; + stream >> app; + tabs->setBusy(FALSE); + emit notBusy(app); + } else if ( msg == "mkdir(QString)" ) { + QString dir; + stream >> dir; + if ( !dir.isEmpty() ) + mkdir( dir ); + } else if ( msg == "rdiffGenSig(QString,QString)" ) { + QString baseFile, sigFile; + stream >> baseFile >> sigFile; + QRsync::generateSignature( baseFile, sigFile ); + } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { + QString baseFile, sigFile, deltaFile; + stream >> baseFile >> sigFile >> deltaFile; + QRsync::generateDiff( baseFile, sigFile, deltaFile ); + } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { + QString baseFile, deltaFile; + stream >> baseFile >> deltaFile; + if ( !QFile::exists( baseFile ) ) { + QFile f( baseFile ); + f.open( IO_WriteOnly ); + f.close(); + } + QRsync::applyDiff( baseFile, deltaFile ); + QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); + e << baseFile; + } else if ( msg == "rdiffCleanup()" ) { + mkdir( "/tmp/rdiff" ); + QDir dir; + dir.setPath( "/tmp/rdiff" ); + QStringList entries = dir.entryList(); + for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) + dir.remove( *it ); + } else if ( msg == "sendHandshakeInfo()" ) { + QString home = getenv( "HOME" ); + QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); + e << home; + int locked = (int) Desktop::screenLocked(); + e << locked; + } else if ( msg == "sendCardInfo()" ) { + QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); + const QList<FileSystem> &fs = storage->fileSystems(); + QListIterator<FileSystem> it ( fs ); + QString s; + QString homeDir = getenv("HOME"); + QString hardDiskHome; + for ( ; it.current(); ++it ) { + if ( (*it)->isRemovable() ) + s += (*it)->name() + "=" + (*it)->path() + "/Documents " + + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) + + " " + (*it)->options() + ";"; + else if ( (*it)->disk() == "/dev/mtdblock1" || + (*it)->disk() == "/dev/mtdblock/1" ) + s += (*it)->name() + "=" + homeDir + "/Documents " + + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) + + " " + (*it)->options() + ";"; + else if ( (*it)->name().contains( "Hard Disk") && + homeDir.contains( (*it)->path() ) && + (*it)->path().length() > hardDiskHome.length() ) + hardDiskHome = + (*it)->name() + "=" + homeDir + "/Documents " + + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) + + " " + (*it)->options() + ";"; + } + if ( !hardDiskHome.isEmpty() ) + s += hardDiskHome; + + e << s; + } else if ( msg == "sendSyncDate(QString)" ) { + QString app; + stream >> app; + Config cfg( "qpe" ); + cfg.setGroup("SyncDate"); + QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); + e << app << cfg.readEntry( app ); + //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), + //cfg.readEntry( app ).latin1() ); + } else if ( msg == "setSyncDate(QString,QString)" ) { + QString app, date; + stream >> app >> date; + Config cfg( "qpe" ); + cfg.setGroup("SyncDate"); + cfg.writeEntry( app, date ); + //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); + } else if ( msg == "startSync(QString)" ) { + QString what; + stream >> what; + delete syncDialog; syncDialog = 0; + syncDialog = new SyncDialog( this, "syncProgress", FALSE, + WStyle_Tool | WStyle_Customize | + Qt::WStyle_StaysOnTop ); + syncDialog->showMaximized(); + syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); + connect( syncDialog->buttonCancel, SIGNAL( clicked() ), + SLOT( cancelSync() ) ); + } + else if ( msg == "stopSync()") { + delete syncDialog; syncDialog = 0; + } else if ( msg == "getAllDocLinks()" ) { + loadDocs(); + + QString contents; + + for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { + DocLnk *doc = it.current(); + QString lfn = doc->linkFile(); + QFileInfo fi( doc->file() ); + if ( !fi.exists() ) + continue; + + + + QFile f( lfn ); + if ( f.open( IO_ReadOnly ) ) { + QTextStream ts( &f ); + ts.setEncoding( QTextStream::UnicodeUTF8 ); + contents += ts.read(); + f.close(); + } else { + contents += "[Desktop Entry]\n"; + contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; + contents += "File = "+doc->file()+"\n"; + contents += "Name = "+doc->name()+"\n"; + contents += "Type = "+doc->type()+"\n"; + } + contents += QString("Size = %1\n").arg( fi.size() ); + } + + //qDebug( "sending length %d", contents.length() ); + QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); + e << contents; + + //qDebug( "================ \n\n%s\n\n===============", + //contents.latin1() ); + + delete docsFolder; + docsFolder = 0; + } +} + +void Launcher::cancelSync() +{ + QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); +} + +void Launcher::storageChanged() +{ + if ( in_lnk_props ) { + got_lnk_change = TRUE; + lnk_change = ""; + } else { + updateDocs(); + } +} + + +bool Launcher::mkdir(const QString &localPath) +{ + QDir fullDir(localPath); + if (fullDir.exists()) + return true; + + // at this point the directory doesn't exist + // go through the directory tree and start creating the direcotories + // that don't exist; if we can't create the directories, return false + + QString dirSeps = "/"; + int dirIndex = localPath.find(dirSeps); + QString checkedPath; + + // didn't find any seps; weird, use the cur dir instead + if (dirIndex == -1) { + //qDebug("No seperators found in path %s", localPath.latin1()); + checkedPath = QDir::currentDirPath(); + } + + while (checkedPath != localPath) { + // no more seperators found, use the local path + if (dirIndex == -1) + checkedPath = localPath; + else { + // the next directory to check + checkedPath = localPath.left(dirIndex) + "/"; + // advance the iterator; the next dir seperator + dirIndex = localPath.find(dirSeps, dirIndex+1); + } + + QDir checkDir(checkedPath); + if (!checkDir.exists()) { + //qDebug("mkdir making dir %s", checkedPath.latin1()); + + if (!checkDir.mkdir(checkedPath)) { + qDebug("Unable to make directory %s", checkedPath.latin1()); + return FALSE; + } + } + + } + return TRUE; +} + +void Launcher::preloadApps() +{ + Config cfg("Launcher"); + cfg.setGroup("Preload"); + QStringList apps = cfg.readListEntry("Apps",','); + for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { + QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); + } +} diff --git a/core/launcher/launcher.h b/core/launcher/launcher.h new file mode 100644 index 0000000..00ae980 --- a/dev/null +++ b/core/launcher/launcher.h @@ -0,0 +1,136 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 LAUNCHER_H +#define LAUNCHER_H + +#include <qmainwindow.h> +#include <qtabbar.h> +#include <qstringlist.h> +#include <qvbox.h> +#include <qlist.h> +#include "launcherview.h" + +class AppLnk; +class AppLnkSet; +class DocLnkSet; +class QWidgetStack; +class StorageInfo; +class SyncDialog; + +class CategoryTabBar : public QTabBar +{ + Q_OBJECT +public: + CategoryTabBar( QWidget *parent=0, const char *name=0 ); + ~CategoryTabBar(); + +protected slots: + virtual void layoutTabs(); + +protected: + void paint ( QPainter *p, QTab *t, bool f ) const; + void paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const; +}; + +class CategoryTabWidget : public QVBox { + // can't use a QTabWidget, since it won't let us set the frame style. + Q_OBJECT +public: + CategoryTabWidget( QWidget* parent ); + void initializeCategories(AppLnkSet* rootFolder, AppLnkSet* docFolder, + const QList<FileSystem> &); + void updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs); + void updateLink(const QString& linkfile); + void setBusy(bool on); + +signals: + void selected(const QString&); + void clicked(const AppLnk*); + void rightPressed(AppLnk*); + +public slots: + void nextTab(); + void prevTab(); + +protected: + void paletteChange( const QPalette &p ); + +private: + CategoryTabBar* categoryBar; + QWidgetStack* stack; + LauncherView* docview; + QStringList ids; + int tabs; + LauncherView* newView( const QString&, const QPixmap& pm, const QString& label ); + void addItem( const QString& ); +}; + +class Launcher : public QMainWindow +{ + Q_OBJECT + friend class LauncherPrivate; +public: + Launcher( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~Launcher(); + + static QString appsFolderName(); + + virtual void showMaximized(); + static bool mkdir(const QString &path); + +public slots: + void viewSelected(const QString&); + void select( const AppLnk * ); + void externalSelected( const AppLnk *); + void properties( AppLnk * ); + void nextView(); + +signals: + void executing( const AppLnk * ); + void busy(); + void notBusy(const QString&); + +private slots: + void doMaximize(); + void systemMessage( const QCString &, const QByteArray &); + void storageChanged(); + void cancelSync(); + +private: + void updateApps(); + void loadDocs(); + void updateDocs(); + void updateTabs(); + void updateMimeTypes(); + void updateMimeTypes(AppLnkSet*); + void preloadApps(); + AppLnkSet *rootFolder; + DocLnkSet *docsFolder; + CategoryTabWidget *tabs; + StorageInfo *storage; + SyncDialog *syncDialog; + + void updateLink(const QString& link); + bool in_lnk_props; + bool got_lnk_change; + QString lnk_change; +}; + +#endif // LAUNCHERVIEW_H diff --git a/core/launcher/launcher.pro b/core/launcher/launcher.pro new file mode 100644 index 0000000..7d7c9ac --- a/dev/null +++ b/core/launcher/launcher.pro @@ -0,0 +1,110 @@ +TEMPLATE = app + +CONFIG = qt warn_on release + +DESTDIR = $(QPEDIR)/bin + +HEADERS = background.h \ + desktop.h \ + info.h \ + appicons.h \ + taskbar.h \ + sidething.h \ + mrulist.h \ + stabmon.h \ + inputmethods.h \ + systray.h \ + wait.h \ + shutdownimpl.h \ + launcher.h \ + launcherview.h \ + ../calibrate/calibrate.h \ + startmenu.h \ + transferserver.h \ + qcopbridge.h \ + packageslave.h \ + irserver.h \ + $(QPEDIR)/rsync/buf.h \ + $(QPEDIR)/rsync/checksum.h \ + $(QPEDIR)/rsync/command.h \ + $(QPEDIR)/rsync/emit.h \ + $(QPEDIR)/rsync/job.h \ + $(QPEDIR)/rsync/netint.h \ + $(QPEDIR)/rsync/protocol.h \ + $(QPEDIR)/rsync/prototab.h \ + $(QPEDIR)/rsync/rsync.h \ + $(QPEDIR)/rsync/search.h \ + $(QPEDIR)/rsync/stream.h \ + $(QPEDIR)/rsync/sumset.h \ + $(QPEDIR)/rsync/trace.h \ + $(QPEDIR)/rsync/types.h \ + $(QPEDIR)/rsync/util.h \ + $(QPEDIR)/rsync/whole.h \ + $(QPEDIR)/rsync/config_rsync.h \ + $(QPEDIR)/rsync/qrsync.h +# quicklauncher.h \ + +SOURCES = background.cpp \ + desktop.cpp \ + info.cpp \ + appicons.cpp \ + taskbar.cpp \ + sidething.cpp \ + mrulist.cpp \ + stabmon.cpp \ + inputmethods.cpp \ + systray.cpp \ + wait.cpp \ + shutdownimpl.cpp \ + launcher.cpp \ + launcherview.cpp \ + $(QPEDIR)/calibrate/calibrate.cpp \ + transferserver.cpp \ + packageslave.cpp \ + irserver.cpp \ + qcopbridge.cpp \ + startmenu.cpp \ + main.cpp \ + $(QPEDIR)/rsync/base64.c \ + $(QPEDIR)/rsync/buf.c \ + $(QPEDIR)/rsync/checksum.c \ + $(QPEDIR)/rsync/command.c \ + $(QPEDIR)/rsync/delta.c \ + $(QPEDIR)/rsync/emit.c \ + $(QPEDIR)/rsync/hex.c \ + $(QPEDIR)/rsync/job.c \ + $(QPEDIR)/rsync/mdfour.c \ + $(QPEDIR)/rsync/mksum.c \ + $(QPEDIR)/rsync/msg.c \ + $(QPEDIR)/rsync/netint.c \ + $(QPEDIR)/rsync/patch.c \ + $(QPEDIR)/rsync/prototab.c \ + $(QPEDIR)/rsync/readsums.c \ + $(QPEDIR)/rsync/scoop.c \ + $(QPEDIR)/rsync/search.c \ + $(QPEDIR)/rsync/stats.c \ + $(QPEDIR)/rsync/stream.c \ + $(QPEDIR)/rsync/sumset.c \ + $(QPEDIR)/rsync/trace.c \ + $(QPEDIR)/rsync/tube.c \ + $(QPEDIR)/rsync/util.c \ + $(QPEDIR)/rsync/version.c \ + $(QPEDIR)/rsync/whole.c \ + $(QPEDIR)/rsync/qrsync.cpp + +INTERFACES = shutdown.ui syncdialog.ui + +INCLUDEPATH += $(QPEDIR)/include +DEPENDPATH += $(QPEDIR)/include . + +INCLUDEPATH += $(QPEDIR)/calibrate +DEPENDPATH += $(QPEDIR)/calibrate + +INCLUDEPATH += $(QPEDIR)/rsync +DEPENDPATH += $(QPEDIR)/rsync + +TARGET = qpe + +LIBS += -lqpe -lcrypt + +TRANSLATIONS = ../i18n/de/qpe.ts diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp new file mode 100644 index 0000000..68e3245 --- a/dev/null +++ b/core/launcher/launcherview.cpp @@ -0,0 +1,596 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 "launcherview.h" + +#include <qpe/qpeapplication.h> +#include <qpe/applnk.h> +#include <qpe/qpedebug.h> +#include <qpe/categories.h> +#include <qpe/categoryselect.h> +#include <qpe/menubutton.h> +#include <qpe/resource.h> +#include <qpe/qpetoolbar.h> + +#include <qtimer.h> +#include <qdict.h> +#include <qfile.h> +#include <qfileinfo.h> +#include <qhbox.h> +#include <qiconview.h> +#include <qpainter.h> +#include <qregexp.h> +#include <qtoolbutton.h> + +class LauncherIconView : public QIconView { +public: + LauncherIconView( QWidget* parent, const char* name=0 ) : + QIconView(parent,name), + tf(""), + cf(0), + bsy(0) + { + sortmeth = Name; + hidden.setAutoDelete(TRUE); + ike = FALSE; + } + + ~LauncherIconView() + { +#if 0 // debuggery + QListIterator<AppLnk> it(hidden); + AppLnk* l; + while ((l=it.current())) { + ++it; + //qDebug("%p: hidden (should remove)",l); + } +#endif + } + + QIconViewItem* busyItem() const { return bsy; } + + void updateCategoriesAndMimeTypes(); + + void doAutoScroll() + { + // We don't want rubberbanding (yet) + } + + void setBusy(bool on) + { + QIconViewItem *c = on ? currentItem() : 0; + if ( bsy != c ) { + QIconViewItem* o = bsy; + bsy = c; + if ( o ) o->repaint(); + if ( c ) c->repaint(); + } + } + + bool inKeyEvent() const { return ike; } + void keyPressEvent(QKeyEvent* e) + { + ike = TRUE; + if ( e->key() == Key_F33 ) { + // "OK" button + returnPressed(currentItem()); + } + QIconView::keyPressEvent(e); + ike = FALSE; + } + + void addItem(AppLnk* app, bool resort=TRUE); + bool removeLink(const QString& linkfile); + + QStringList mimeTypes() const; + QStringList categories() const; + + void clear() + { + mimes.clear(); + cats.clear(); + QIconView::clear(); + hidden.clear(); + } + + void addCatsAndMimes(AppLnk* app) + { + // QStringList c = app->categories(); + // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { + // cats.replace(*cit,(void*)1); + // } + QString maj=app->type(); + int sl=maj.find('/'); + if (sl>=0) { + QString k = maj.left(sl); + mimes.replace(k,(void*)1); + } + } + + void drawBackground( QPainter *p, const QRect &r ) + { + // int backgroundMode = QPixmap::defaultDepth() >= 12 ? 1 : 0; + int backgroundMode = 2; + + if ( backgroundMode == 1 ) { + + // Double buffer the background + static QPixmap *bg = NULL; + static QColor bgColor; + + if ( (bg == NULL) || (bgColor != colorGroup().button()) ) { + // Create a new background double buffer + if (bg == NULL) + bg = new QPixmap( width(), height() ); + bgColor = colorGroup().button(); + QPainter painter( bg ); + + painter.fillRect( QRect( 0, 0, width(), height() ), QBrush( white ) ); + + // Overlay the Qtopia logo in the center + QImage logo = Resource::loadImage( "qpe-logo" ); + if ( !logo.isNull() ) + painter.drawImage( (width() - logo.width()) / 2, + (height() - logo.height()) / 2, logo ); + } + + // Draw the double buffer to the widget (it is tiled for when the icon view is large) + p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(), + (r.y() + contentsY()) % bg->height() ) ); + } else if ( backgroundMode == 2 ) { + static QPixmap *bg = 0; + static QColor bgColor; + if ( !bg || (bgColor != colorGroup().background()) ) { + bgColor = colorGroup().background(); + bg = new QPixmap( width(), 9 ); + QPainter painter( bg ); + for ( int i = 0; i < 3; i++ ) { + painter.setPen( white ); + painter.drawLine( 0, i*3, width()-1, i*3 ); + painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); + painter.setPen( colorGroup().background().light(105) ); + painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); + } + } + p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(), + (r.y() + contentsY()) % bg->height() ) ); + } else { + p->fillRect( r, QBrush( white ) ); + } + } + + void hideOrShowItems(bool resort); + + void setTypeFilter(const QString& typefilter, bool resort) + { + tf = QRegExp(typefilter,FALSE,TRUE); + hideOrShowItems(resort); + } + + void setCategoryFilter( int catfilter, bool resort ) + { + Categories cat; + cat.load( categoryFileName() ); + QString str; + if ( catfilter == -2 ) + cf = 0; + else + cf = catfilter; + hideOrShowItems(resort); + } + + enum SortMethod { Name, Date, Type }; + + void setSortMethod( SortMethod m ) + { + if ( sortmeth != m ) { + sortmeth = m; + sort(); + } + } + + int compare(const AppLnk* a, const AppLnk* b) + { + switch (sortmeth) { + case Name: + return a->name().compare(b->name()); + case Date: { + QFileInfo fa(a->linkFile()); + if ( !fa.exists() ) fa.setFile(a->file()); + QFileInfo fb(b->linkFile()); + if ( !fb.exists() ) fb.setFile(b->file()); + return fa.lastModified().secsTo(fb.lastModified()); + } + case Type: + return a->type().compare(b->type()); + } + return 0; + } + +protected: + + void styleChange( QStyle &old ) + { + QIconView::styleChange( old ); + //### duplicated code from LauncherView constructor + int dw = QApplication::desktop()->width(); + setGridX( (dw-13-style().scrollBarExtent().width())/3 ); // tweaked for 8pt+dw=176 and 10pt+dw=240 + } + +private: + QList<AppLnk> hidden; + QDict<void> mimes; + QDict<void> cats; + SortMethod sortmeth; + QRegExp tf; + int cf; + QIconViewItem* bsy; + bool ike; + +}; + + +bool LauncherView::bsy=FALSE; + +void LauncherView::setBusy(bool on) +{ + icons->setBusy(on); +} + +class LauncherItem : public QIconViewItem +{ +public: + LauncherItem( QIconView *parent, AppLnk* applnk ); + ~LauncherItem() + { + LauncherIconView* liv = (LauncherIconView*)iconView(); + if ( liv->busyItem() == this ) + liv->setBusy(FALSE); + delete app; + } + + AppLnk* appLnk() const { return app; } + AppLnk* takeAppLnk() { AppLnk* r=app; app=0; return r; } + + virtual int compare ( QIconViewItem * i ) const; + + void paintItem( QPainter *p, const QColorGroup &cg ) + { + LauncherIconView* liv = (LauncherIconView*)iconView(); + QBrush oldBrush( liv->itemTextBackground() ); + QColorGroup mycg( cg ); + if ( liv->currentItem() == this ) { + liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); + mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); + } + QIconViewItem::paintItem(p,mycg); + if ( liv->currentItem() == this ) + liv->setItemTextBackground( oldBrush ); + if ( liv->busyItem() == this ) { + static QPixmap* busypm=0; + if ( !busypm ) + busypm = new QPixmap(Resource::loadPixmap("launching")); + p->drawPixmap(x()+(width()-busypm->width())/2, y(),*busypm); + } + } + +protected: + AppLnk* app; +}; + + +LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk ) + : QIconViewItem( parent, applnk->name(), applnk->bigPixmap() ), + app(applnk) // Takes ownership +{ +} + +int LauncherItem::compare ( QIconViewItem * i ) const +{ + LauncherIconView* view = (LauncherIconView*)iconView(); + return view->compare(app,((LauncherItem *)i)->appLnk()); +} + +QStringList LauncherIconView::mimeTypes() const +{ + QStringList r; + QDictIterator<void> it(mimes); + while (it.current()) { + r.append(it.currentKey()); + ++it; + } + r.sort(); + return r; +} + +void LauncherIconView::addItem(AppLnk* app, bool resort) +{ + addCatsAndMimes(app); + + if ( (tf.isEmpty() || tf.match(app->type()) >= 0) + && (cf == 0 || app->categories().contains(cf) + || cf == -1 && app->categories().count() == 0 ) ) + (void) new LauncherItem( this, app ); + else + hidden.append(app); + if ( resort ) + sort(); +} + +void LauncherIconView::updateCategoriesAndMimeTypes() +{ + mimes.clear(); + cats.clear(); + LauncherItem* item = (LauncherItem*)firstItem(); + while (item) { + addCatsAndMimes(item->appLnk()); + item = (LauncherItem*)item->nextItem(); + } + QListIterator<AppLnk> it(hidden); + AppLnk* l; + while ((l=it.current())) { + addCatsAndMimes(l); + ++it; + } +} + +void LauncherIconView::hideOrShowItems(bool resort) +{ + hidden.setAutoDelete(FALSE); + QList<AppLnk> links=hidden; + hidden.clear(); + hidden.setAutoDelete(TRUE); + LauncherItem* item = (LauncherItem*)firstItem(); + while (item) { + links.append(item->takeAppLnk()); + item = (LauncherItem*)item->nextItem(); + } + clear(); + QListIterator<AppLnk> it(links); + AppLnk* l; + while ((l=it.current())) { + addItem(l,FALSE); + ++it; + } + if ( resort ) + sort(); +} + +bool LauncherIconView::removeLink(const QString& linkfile) +{ + LauncherItem* item = (LauncherItem*)firstItem(); + while (item) { + if ( item->appLnk()->linkFile() == linkfile ) { + delete item; + return TRUE; + } + item = (LauncherItem*)item->nextItem(); + } + QListIterator<AppLnk> it(hidden); + AppLnk* l; + while ((l=it.current())) { + ++it; + if ( l->linkFile() == linkfile ) { + hidden.removeRef(l); + return TRUE; + } + } + return FALSE; +} + +LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) + : QVBox( parent, name, fl ) +{ + icons = new LauncherIconView( this ); + setFocusProxy(icons); + QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); + + int dw = QApplication::desktop()->width(); + icons->setItemsMovable( FALSE ); + icons->setAutoArrange( TRUE ); + icons->setSorting( TRUE ); + icons->setGridX( (dw-13-style().scrollBarExtent().width())/3 ); // tweaked for 8pt+dw=176 and 10pt+dw=240 + icons->setGridY( fontMetrics().height()*2+24 ); + icons->setFrameStyle( QFrame::NoFrame ); + icons->setSpacing( 4 ); + icons->setMargin( 0 ); + icons->setSelectionMode( QIconView::Multi ); + icons->setBackgroundMode( PaletteBase ); + + connect( icons, SIGNAL(mouseButtonClicked(int, QIconViewItem *, const QPoint&)), + SLOT(itemClicked(int, QIconViewItem *)) ); + connect( icons, SIGNAL(selectionChanged()), + SLOT(selectionChanged()) ); + connect( icons, SIGNAL(returnPressed(QIconViewItem *)), + SLOT(returnPressed(QIconViewItem *)) ); + connect( icons, SIGNAL(mouseButtonPressed(int, QIconViewItem *, const QPoint&)), + SLOT(itemPressed(int, QIconViewItem *)) ); + + tools = 0; +} + +LauncherView::~LauncherView() +{ +} + +void LauncherView::setToolsEnabled(bool y) +{ + if ( !y != !tools ) { + if ( y ) { + tools = new QHBox(this); + + // Type filter + typemb = new MenuButton(tools); + typemb->setLabel(tr("Type: %1")); + + // Category filter + catmb = new CategorySelect(tools); + + updateTools(); + tools->show(); + } else { + delete tools; + tools = 0; + } + } +} + +void LauncherView::updateTools() +{ + disconnect( typemb, SIGNAL(selected(const QString&)), + this, SLOT(showType(const QString&)) ); + disconnect( catmb, SIGNAL(signalSelected(int)), + this, SLOT(showCategory(int)) ); + + icons->updateCategoriesAndMimeTypes(); + + QString prev; + + // Type filter + QStringList types; + types << tr("All"); + types << "--"; + types += icons->mimeTypes(); + prev = typemb->currentText(); + typemb->clear(); + typemb->insertItems(types); + typemb->select(prev); + + Categories cats( 0 ); + cats.load( categoryFileName() ); + QArray<int> vl( 0 ); + catmb->setCategories( vl, "Document View", tr("Document View") ); + catmb->setRemoveCategoryEdit( TRUE ); + catmb->setAllCategories( TRUE ); + + connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&))); + connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); +} + +void LauncherView::sortBy(int s) +{ + icons->setSortMethod((LauncherIconView::SortMethod)s); +} + +void LauncherView::showType(const QString& t) +{ + if ( t == tr("All") ) { + icons->setTypeFilter("",TRUE); + } else { + icons->setTypeFilter(t+"/*",TRUE); + } +} + +void LauncherView::showCategory( int c ) +{ + icons->setCategoryFilter( c, TRUE ); +} + +void LauncherView::resizeEvent(QResizeEvent *e) +{ + QVBox::resizeEvent( e ); + if ( e->size().width() != e->oldSize().width() ) + sort(); +} + +void LauncherView::populate( AppLnkSet *folder, const QString& typefilter ) +{ + icons->clear(); + internalPopulate( folder, typefilter ); +} + +void LauncherView::selectionChanged() +{ + QIconViewItem* item = icons->currentItem(); + if ( item && item->isSelected() ) { + AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); + if ( icons->inKeyEvent() ) // not for mouse press + emit clicked( appLnk ); + item->setSelected(FALSE); + } +} + +void LauncherView::returnPressed( QIconViewItem *item ) +{ + if ( item ) { + AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); + emit clicked( appLnk ); + } +} + +void LauncherView::itemClicked( int btn, QIconViewItem *item ) +{ + if ( item ) { + AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); + if ( btn == LeftButton ) { + // Make sure it's the item we execute that gets highlighted + icons->setCurrentItem( item ); + emit clicked( appLnk ); + } + item->setSelected(FALSE); + } +} + +void LauncherView::itemPressed( int btn, QIconViewItem *item ) +{ + if ( item ) { + AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); + if ( btn == RightButton ) + emit rightPressed( appLnk ); +/* + else if ( btn == LeftButton ) + emit clicked( appLnk ); +*/ + item->setSelected(FALSE); + } +} + +void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilter ) +{ + QListIterator<AppLnk> it( folder->children() ); + icons->setTypeFilter(typefilter,FALSE); + + while ( it.current() ) { + icons->addItem(*it,FALSE); + ++it; + } + + icons->sort(); +} + +bool LauncherView::removeLink(const QString& linkfile) +{ + return icons->removeLink(linkfile); +} + +void LauncherView::sort() +{ + icons->sort(); +} + +void LauncherView::addItem(AppLnk* app, bool resort) +{ + icons->addItem(app,resort); +} + +void LauncherView::setFileSystems(const QList<FileSystem> &) +{ + // ### does nothing now... +} diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h new file mode 100644 index 0000000..3aaef7e --- a/dev/null +++ b/core/launcher/launcherview.h @@ -0,0 +1,81 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 LAUNCHERVIEW_H +#define LAUNCHERVIEW_H + +#include <qpe/storage.h> + +#include <qvbox.h> + +class AppLnk; +class AppLnkSet; +class CategorySelect; +class LauncherIconView; +class QIconView; +class QIconViewItem; +class MenuButton; + +class LauncherView : public QVBox +{ + Q_OBJECT + +public: + LauncherView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + ~LauncherView(); + + bool removeLink(const QString& linkfile); + void addItem(AppLnk* app, bool resort=TRUE); + void sort(); + + void setFileSystems(const QList<FileSystem> &); + void setToolsEnabled(bool); + void updateTools(); + + void setBusy(bool); + +public slots: + void populate( AppLnkSet *folder, const QString& categoryfilter ); + +signals: + void clicked( const AppLnk * ); + void rightPressed( AppLnk * ); + +protected slots: + void selectionChanged(); + void returnPressed( QIconViewItem *item ); + void itemClicked( int, QIconViewItem * ); + void itemPressed( int, QIconViewItem * ); + void sortBy(int); + void showType(const QString&); + void showCategory( int ); + void resizeEvent(QResizeEvent *); + +protected: + void internalPopulate( AppLnkSet *, const QString& categoryfilter ); + +private: + static bool bsy; + QWidget* tools; + LauncherIconView* icons; + MenuButton *typemb; + CategorySelect *catmb; +}; + +#endif // LAUNCHERVIEW_H diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp new file mode 100644 index 0000000..024f9cc --- a/dev/null +++ b/core/launcher/main.cpp @@ -0,0 +1,276 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 "desktop.h" +#include "taskbar.h" +#include "stabmon.h" + +#include <qpe/qpeapplication.h> +#include <qpe/network.h> +#include <qpe/config.h> +#ifdef QT_QWS_CUSTOM +#include <qpe/custom.h> +#endif + +#include <qfile.h> +#include <qwindowsystem_qws.h> +#include <qpe/qcopenvelope_qws.h> +#include <qpe/alarmserver.h> + +#include <stdlib.h> +#include <stdio.h> +#include <signal.h> +#include <unistd.h> + +#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) +#include "../calibrate/calibrate.h" +#endif + +#ifdef QT_QWS_LOGIN +#include "../login/qdmdialogimpl.h" +#endif + +#ifdef QT_QWS_CASSIOPEIA +static void ignoreMessage( QtMsgType, const char * ) +{ +} +#include <sys/mount.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/time.h> +#include <fcntl.h> +#include <qdatetime.h> + +void initCassiopeia() +{ + // MIPSEL-specific init - make sure /proc exists for shm +/* + if ( mount("/dev/ram0", "/", "ext2", MS_REMOUNT | MS_MGC_VAL, 0 ) ) { + perror("Remounting - / read/write"); + } +*/ + if ( mount("none", "/tmp", "ramfs", 0, 0 ) ) { + perror("mounting ramfs /tmp"); + } else { + fprintf( stderr, "mounted /tmp\n" ); + } + if ( mount("none", "/home", "ramfs", 0, 0 ) ) { + perror("mounting ramfs /home"); + } else { + fprintf( stderr, "mounted /home\n" ); + } + if ( mount("none","/proc","proc",0,0) ) { + perror("Mounting - /proc"); + } else { + fprintf( stderr, "mounted /proc\n" ); + } + if ( mount("none","/mnt","shm",0,0) ) { + perror("Mounting - shm"); + } + setenv( "QTDIR", "/", 1 ); + setenv( "QPEDIR", "/", 1 ); + setenv( "HOME", "/home", 1 ); + mkdir( "/home/Documents", 0755 ); + + // set a reasonable starting date + QDateTime dt( QDate( 2001, 3, 15 ) ); + QDateTime now = QDateTime::currentDateTime(); + int change = now.secsTo( dt ); + + time_t t = ::time(0); + t += change; + stime(&t); + + qInstallMsgHandler(ignoreMessage); +} +#endif + +#ifdef QPE_OWNAPM +#include <sys/ioctl.h> +#include <sys/types.h> +#include <fcntl.h> +#include <unistd.h> +#include <errno.h> +#include <linux/ioctl.h> +#include <qpe/global.h> + +static void disableAPM() +{ + + int fd, cur_val, ret; + char *device = "/dev/apm_bios"; + + fd = open (device, O_WRONLY); + + if (fd == -1) { + perror(device); + return; + } + + cur_val = ioctl(fd, APM_IOCGEVTSRC, 0); + if (cur_val == -1) { + perror("ioctl"); + exit(errno); + } + + ret = ioctl(fd, APM_IOCSEVTSRC, cur_val & ~APM_EVT_POWER_BUTTON); + if (ret == -1) { + perror("ioctl"); + return; + } + close(fd); +} + +static void initAPM() +{ + // So that we have to do it ourself, but better. + disableAPM(); +} +#endif + +#ifdef QT_DEMO_SINGLE_FLOPPY +#include <sys/mount.h> + +void initFloppy() +{ + mount("none","/proc","proc",0,0); + setenv( "QTDIR", "/", 0 ); + setenv( "HOME", "/root", 0 ); + setenv( "QWS_SIZE", "240x320", 0 ); +} +#endif + + +void initEnvironment() +{ + Config config("locale"); + config.setGroup( "Location" ); + QString tz = config.readEntry( "Timezone", getenv("TZ") ); + + // if not timezone set, pick New York + if (tz.isNull()) + tz = "America/New_York"; + + setenv( "TZ", tz, 1 ); + config.writeEntry( "Timezone", tz); + + config.setGroup( "Language" ); + QString lang = config.readEntry( "Language", getenv("LANG") ); + if ( !lang.isNull() ) + setenv( "LANG", lang, 1 ); +} + +static void initBacklight() +{ + QCopEnvelope e("QPE/System", "setBacklight(int)" ); + e << -3; // Forced on +} + + + +int initApplication( int argc, char ** argv ) +{ +#ifdef QT_QWS_CASSIOPEIA + initCassiopeia(); +#endif + +#ifdef QPE_OWNAPM + initAPM(); +#endif + +#ifdef QT_DEMO_SINGLE_FLOPPY + initFloppy(); +#endif + + initEnvironment(); + +#if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) + setenv( "QWS_SIZE", "240x320", 0 ); +#endif + + //Don't flicker at startup: + QWSServer::setDesktopBackground( QImage() ); + DesktopApplication a( argc, argv, QApplication::GuiServer ); + + initBacklight(); + + AlarmServer::initialize(); + +#if defined(QT_QWS_LOGIN) + for( int i=0; i<a.argc(); i++ ) + if( strcmp( a.argv()[i], "-login" ) == 0 ) { + QDMDialogImpl::login( ); + return 0; + } +#endif + + Desktop *d = new Desktop(); + + QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) ); + QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) ); + QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) ); + QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) ); + QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); + QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); + QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); + QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); + QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); + QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); + + (void)new SysFileMonitor(d); + Network::createServer(d); + +#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) + if ( !QFile::exists( "/etc/pointercal" ) ) { + // Make sure calibration widget starts on top. + Calibrate *cal = new Calibrate; + cal->exec(); + delete cal; + } +#endif + + d->show(); + + int rv = a.exec(); + + delete d; + + return rv; +} + +int main( int argc, char ** argv ) +{ +#ifndef SINGLE_APP + signal( SIGCHLD, SIG_IGN ); +#endif + + int retVal = initApplication( argc, argv ); + +#ifndef SINGLE_APP + // Kill them. Kill them all. + setpgid( getpid(), getppid() ); + killpg( getpid(), SIGTERM ); + sleep( 1 ); + killpg( getpid(), SIGKILL ); +#endif + + return retVal; +} + diff --git a/core/launcher/mrulist.cpp b/core/launcher/mrulist.cpp new file mode 100644 index 0000000..4daf7d2 --- a/dev/null +++ b/core/launcher/mrulist.cpp @@ -0,0 +1,199 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 "mrulist.h" + +#include <qpe/global.h> +#include <qpe/applnk.h> +#include <qpe/resource.h> + +#include <qframe.h> +#include <qpushbutton.h> +#include <qtoolbutton.h> +#include <qpopupmenu.h> +#include <qpainter.h> +#include <qwindowsystem_qws.h> + + +QList<MRUList> *MRUList::MRUListWidgets = NULL; +QList<AppLnk> *MRUList::task = NULL; + + +MRUList::MRUList( QWidget *parent ) + : QFrame( parent ), selected(-1), oldsel(-1) +{ + setBackgroundMode( PaletteButton ); + if (!MRUListWidgets) + MRUListWidgets = new QList<MRUList>; + if (!task) + task = new QList<AppLnk>; + MRUListWidgets->append( this ); +} + + +MRUList::~MRUList() +{ + if (MRUListWidgets) + MRUListWidgets->remove( this ); + if (task) + task->setAutoDelete( TRUE ); +} + + +QSize MRUList::sizeHint() const +{ + return QSize( frameWidth(), 16 ); +} + + +void MRUList::addTask( const AppLnk *appLnk ) +{ + if ( !appLnk ) + return; + unsigned int i = 0; + + if ( !task ) + return; + + for ( ; i < task->count(); i++ ) { + AppLnk *t = task->at(i); + if ( t->exec() == appLnk->exec() ) { + if (i != 0) { + task->remove(); + task->prepend( t ); + } + for (unsigned i = 0; i < MRUListWidgets->count(); i++ ) + MRUListWidgets->at(i)->update(); + return; + } + } + + AppLnk *t = new AppLnk( *appLnk ); + // DocLnks have an overloaded virtual function exec() + t->setExec( appLnk->exec() ); + task->prepend( t ); + + if ( task->count() > 6 ) { + t = task->last(); + task->remove(); + Global::terminate(t); + delete t; + } + + for (unsigned i = 0; i < MRUListWidgets->count(); i++ ) + MRUListWidgets->at(i)->update(); +} + +bool MRUList::quitOldApps() +{ + QStringList appsstarted; + QStringList appsrunning; + for ( int i=task->count()-1; i>=0; --i ) { + AppLnk *t = task->at(i); + appsstarted.append(t->exec()); + } + + const QList<QWSWindow> &list = qwsServer->clientWindows(); + QWSWindow* w; + for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { + QString app = w->client()->identity(); + if ( appsstarted.contains(app) && !appsrunning.contains(app) ) + appsrunning.append(app); + } + + if ( appsrunning.count() > 1 ) { + QStringList::ConstIterator it = appsrunning.begin(); + ++it; // top stays running! + for (; it != appsrunning.end(); it++) { + for ( int i=task->count()-1; i>=0; --i ) { + AppLnk *t = task->at(i); + if ( t->exec() == *it ) + Global::terminate(t); + } + } + return TRUE; + } else { + return FALSE; + } +} + + +void MRUList::mousePressEvent(QMouseEvent *e) +{ + selected = 0; + int x=0; + QListIterator<AppLnk> it( *task ); + for ( ; it.current(); ++it,++selected,x+=15 ) { + if ( x + 15 <= width() ) { + if ( e->x() >= x && e->x() < x+15 ) { + if ( selected < (int)task->count() ) { + repaint(FALSE); + return; + } + } + } else { + break; + } + } + selected = -1; + repaint( FALSE ); +} + + +void MRUList::mouseReleaseEvent(QMouseEvent *) +{ + if ( selected >= 0 ) { + if ( parentWidget() ) + if ( parentWidget()->isA( "QPopupMenu" ) ) + parentWidget()->hide(); + Global::execute( task->at(selected)->exec() ); + selected = -1; + oldsel = -1; + update(); + } +} + + +void MRUList::paintEvent( QPaintEvent * ) +{ + QPainter p( this ); + AppLnk *t; + int x = 0; + int y = (height() - 14) / 2; + int i = 0; + + p.fillRect( 0, 0, width(), height(), colorGroup().background() ); + + if ( task ) { + QListIterator<AppLnk> it( *task ); + for ( ; it.current(); i++, ++it ) { + if ( x + 15 <= width() ) { + t = it.current(); + if ( (int)i == selected ) + p.fillRect( x, y, 15, t->pixmap().height()+1, colorGroup().highlight() ); + else if ( (int)i == oldsel ) + p.eraseRect( x, y, 15, t->pixmap().height()+1 ); + p.drawPixmap( x, y, t->pixmap() ); + x += 15; + } + } + } +} + diff --git a/core/launcher/mrulist.h b/core/launcher/mrulist.h new file mode 100644 index 0000000..141a09b --- a/dev/null +++ b/core/launcher/mrulist.h @@ -0,0 +1,55 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 __MRU_LIST_H__ +#define __MRU_LIST_H__ + + +#include <qpe/applnk.h> + +#include <qframe.h> +#include <qlist.h> +#include <qpixmap.h> + + +class MRUList : public QFrame +{ +public: + MRUList( QWidget *parent ); + ~MRUList(); + virtual QSize sizeHint() const; + static void addTask( const AppLnk *appLnk ); + bool quitOldApps(); + +protected: + void mousePressEvent(QMouseEvent *e); + void mouseReleaseEvent(QMouseEvent *e); + void paintEvent( QPaintEvent *event ); + +private: + static QList<MRUList> *MRUListWidgets; + static QList<AppLnk> *task; + int selected; + int oldsel; +}; + + +#endif // __MRU_LIST_H__ + diff --git a/core/launcher/obexinterface.h b/core/launcher/obexinterface.h new file mode 100644 index 0000000..a73fde6 --- a/dev/null +++ b/core/launcher/obexinterface.h @@ -0,0 +1,40 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 OBEXINTERFACE_H +#define OBEXINTERFACE_H + +#include <qpe/qcom.h> + +#ifndef QT_NO_COMPONENT +// ### regenerate!!!!!! +// {6CA35D0B-C637-4865-A667-7D4CD8A70407} +# ifndef IID_ObexInterface +# define IID_ObexInterface QUuid( 0x6ca35d0b, 0xc637, 0x4865, 0xa6, 0x67, 0x7d, 0x4c, 0xd8, 0xa7, 0x04, 0x07) +# endif +#endif + +class QObject; + +struct ObexInterface : public QUnknownInterface +{ +}; + +#endif diff --git a/core/launcher/packageslave.cpp b/core/launcher/packageslave.cpp new file mode 100644 index 0000000..4f149a5 --- a/dev/null +++ b/core/launcher/packageslave.cpp @@ -0,0 +1,97 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 <qpe/process.h> +#include <qpe/qcopenvelope_qws.h> + +#include <qdatastream.h> +#include <qcopchannel_qws.h> + +#include <unistd.h> + +PackageSlave::PackageSlave( QObject *parent, char* name ) + : QObject( parent, name ), packageChannel( 0 ) +{ + // setup qcop channel + packageChannel = new QCopChannel( "QPE/Package", this ); + connect( packageChannel, SIGNAL( received(const QCString &, const QByteArray &) ), + this, SLOT( qcopMessage( const QCString &, const QByteArray &) ) ); +} + +void PackageSlave::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)" ) { + QString file; + stream >> file; + removePackage( file ); + } +} + +void PackageSlave::installPackage( const QString &package ) +{ + Process proc( QStringList() << "ipkg" << "install" << package ); + + sendReply( "installStarted(QString)", package ); + + QString output; + if ( proc.exec( "", output ) ) { + sendReply( "installDone(QString)", package ); + } + else { + sendReply( "installFailed(QString)", package ); + } + QCopEnvelope e("QPE/System", "linkChanged(QString)"); + QString lf = QString::null; + e << lf; + unlink( package ); +} + +void PackageSlave::removePackage( const QString &package ) +{ + Process proc( QStringList() << "ipkg" << "remove" << package ); + + sendReply( "removeStarted(QString)", package ); + + QString output; + if ( proc.exec( "", output ) ) { + sendReply( "removeDone(QString)", package ); + } + else { + sendReply( "removeFailed(QString)", package ); + } + QCopEnvelope e("QPE/System", "linkChanged(QString)"); + QString lf = QString::null; + e << lf; +} + +void PackageSlave::sendReply( const QCString& msg, const QString& arg ) +{ + QCopEnvelope e( "QPE/Desktop", msg ); + e << arg; +} diff --git a/core/launcher/packageslave.h b/core/launcher/packageslave.h new file mode 100644 index 0000000..036abed --- a/dev/null +++ b/core/launcher/packageslave.h @@ -0,0 +1,52 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 __packageslave_h__ +#define __packageslave_h__ + +#include <qobject.h> + +class QCopChannel; + +class PackageSlave : public QObject +{ + Q_OBJECT + +public: + PackageSlave( QObject *parent, char* name = 0 ); + +protected: + void installPackage( const QString &package ); + void removePackage( const QString &package ); + +protected slots: + void qcopMessage( const QCString &msg, const QByteArray &data ); + +private: + void sendReply( const QCString& msg, const QString& arg ); + +private: + QCopChannel *packageChannel; +}; + + +#endif // __QUICK_LAUNCHER_H__ + + diff --git a/core/launcher/qcopbridge.cpp b/core/launcher/qcopbridge.cpp new file mode 100644 index 0000000..c78e827 --- a/dev/null +++ b/core/launcher/qcopbridge.cpp @@ -0,0 +1,416 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 "qcopbridge.h" +#include "transferserver.h" + +#include <qpe/qcopenvelope_qws.h> +#include <qpe/qpeapplication.h> + +#include <qdir.h> +#include <qfile.h> +#include <qtextstream.h> +#include <qdatastream.h> +#include <qstringlist.h> +#include <qfileinfo.h> +#include <qregexp.h> +#include <qcopchannel_qws.h> + +#define _XOPEN_SOURCE +#include <pwd.h> +#include <sys/types.h> +#include <unistd.h> + +#if defined(_OS_LINUX_) +#include <shadow.h> +#endif + +//#define INSECURE + +const int block_size = 51200; + +QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent = 0, + const char* name = 0) + : QServerSocket( port, 1, parent, name ), + desktopChannel( 0 ), + cardChannel( 0 ) +{ + if ( !ok() ) + qWarning( "Failed to bind to port %d", port ); + else { + desktopChannel = new QCopChannel( "QPE/Desktop", this ); + connect( desktopChannel, SIGNAL(received(const QCString &, const QByteArray &)), + this, SLOT(desktopMessage( const QCString &, const QByteArray &)) ); + cardChannel = new QCopChannel( "QPE/Card", this ); + connect( cardChannel, SIGNAL(received(const QCString &, const QByteArray &)), + this, SLOT(desktopMessage( const QCString &, const QByteArray &)) ); + } + sendSync = FALSE; +} + +QCopBridge::~QCopBridge() +{ + delete desktopChannel; +} + +void QCopBridge::newConnection( int socket ) +{ + QCopBridgePI *pi = new QCopBridgePI( socket, this ); + openConnections.append( pi ); + connect ( pi, SIGNAL( connectionClosed( QCopBridgePI *) ), this, SLOT( connectionClosed( QCopBridgePI *) ) ); + QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; + + if ( sendSync ) { + pi ->startSync(); + sendSync = FALSE; + } +} + +void QCopBridge::connectionClosed( QCopBridgePI *pi ) +{ + openConnections.remove( pi ); + if ( openConnections.count() == 0 ) { + QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; + } +} + +void QCopBridge::closeOpenConnections() +{ + QCopBridgePI *pi; + for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) + pi->close(); +} + + +void QCopBridge::desktopMessage( const QCString &command, const QByteArray &args ) +{ + command.stripWhiteSpace(); + + int paren = command.find( "(" ); + if ( paren <= 0 ) { + qDebug("DesktopMessage: bad qcop syntax"); + return; + } + + QString params = command.mid( paren + 1 ); + if ( params[params.length()-1] != ')' ) { + qDebug("DesktopMessage: bad qcop syntax"); + return; + } + + params.truncate( params.length()-1 ); + + QStringList paramList = QStringList::split( ",", params ); + QString data; + if ( paramList.count() ) { + QDataStream stream( args, IO_ReadOnly ); + for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) { + QString str; + if ( *it == "QString" ) { + stream >> str; + } else if ( *it == "QCString" ) { + QCString cstr; + stream >> cstr; + str = QString::fromLocal8Bit( cstr ); + } else if ( *it == "int" ) { + int i; + stream >> i; + str = QString::number( i ); + } else if ( *it == "bool" ) { + int i; + stream >> i; + str = QString::number( i ); + } else { + qDebug(" cannot route the argument type %s throught the qcop bridge", (*it).latin1() ); + return; + } + str.replace( QRegExp("&"), "&" ); + str.replace( QRegExp(" "), "&0x20;" ); + str.replace( QRegExp("\n"), "&0x0d;" ); + str.replace( QRegExp("\r"), "&0x0a;" ); + data += " " + str; + } + } + QString sendCommand = QString(command.data()) + data; + // send the command to all open connections + if ( command == "startSync()" ) { + // we need to buffer it a bit + sendSync = TRUE; + startTimer( 20000 ); + } + + QCopBridgePI *pi; + for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) { + pi->sendDesktopMessage( sendCommand ); + } +} + +void QCopBridge::timerEvent( QTimerEvent * ) +{ + sendSync = FALSE; + killTimers(); +} + + +QCopBridgePI::QCopBridgePI( int socket, QObject *parent = 0, const char* name = 0 ) + : QSocket( parent, name ) +{ + setSocket( socket ); + + peerport = peerPort(); + peeraddress = peerAddress(); + +#ifndef INSECURE + if ( !accessAuthorized(peeraddress) ) { + state = Forbidden; + startTimer( 0 ); + } else +#endif + { + state = Connected; + sendSync = FALSE; + connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); + connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); + + send( "220 Qtopia QCop bridge ready!" ); + state = Wait_USER; + + // idle timer to close connections when not used anymore + startTimer( 60000 ); + connected = TRUE; + } +} + + +QCopBridgePI::~QCopBridgePI() +{ + +} + +void QCopBridgePI::connectionClosed() +{ + emit connectionClosed( this ); + // qDebug( "Debug: Connection closed" ); + delete this; +} + +void QCopBridgePI::sendDesktopMessage( const QString &msg ) +{ + QString str = "CALL QPE/Desktop " + msg; + send ( str ); +} + + +void QCopBridgePI::send( const QString& msg ) +{ + QTextStream os( this ); + os << msg << endl; + //qDebug( "sending qcop message: %s", msg.latin1() ); +} + +void QCopBridgePI::read() +{ + while ( canReadLine() ) + process( readLine().stripWhiteSpace() ); +} + +bool QCopBridgePI::checkUser( const QString& user ) +{ + if ( user.isEmpty() ) return FALSE; + + struct passwd *pw; + pw = getpwuid( geteuid() ); + QString euser = QString::fromLocal8Bit( pw->pw_name ); + return user == euser; +} + +bool QCopBridgePI::checkPassword( const QString& password ) +{ + // ### HACK for testing on local host + return true; + + /* + 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 ); + + QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); + return cpwd == cpassword; +*/ +} + +void QCopBridgePI::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]; + + // we always respond to QUIT, regardless of state + if ( cmd == "QUIT" ) { + send( "211 Have a nice day!" ); + delete this; + return; + } + + // connected to client + if ( Connected == state ) + return; + + // waiting for user name + if ( Wait_USER == state ) { + + if ( cmd != "USER" || msg.count() < 2 || !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" || !checkPassword( arg ) ) { + //if ( cmd != "PASS" || msg.count() < 2 || !checkPassword( arg ) ) { + send( "530 Please login with USER and PASS" ); + return; + } + send( "230 User logged in, proceed" ); + state = Ready; + if ( sendSync ) { + sendDesktopMessage( "startSync()" ); + sendSync = FALSE; + } + return; + } + + // noop (NOOP) + else if ( cmd == "NOOP" ) { + connected = TRUE; + send( "200 Command okay" ); + } + + // call (CALL) + else if ( cmd == "CALL" ) { + + // example: call QPE/System execute(QString) addressbook + + if ( msg.count() < 3 ) { + send( "500 Syntax error, command unrecognized" ); + } + else { + + QString channel = msg[1]; + QString command = msg[2]; + + command.stripWhiteSpace(); + + int paren = command.find( "(" ); + if ( paren <= 0 ) { + send( "500 Syntax error, command unrecognized" ); + return; + } + + QString params = command.mid( paren + 1 ); + if ( params[params.length()-1] != ')' ) { + send( "500 Syntax error, command unrecognized" ); + return; + } + + params.truncate( params.length()-1 ); + QByteArray buffer; + QDataStream ds( buffer, IO_WriteOnly ); + + int msgId = 3; + + QStringList paramList = QStringList::split( ",", params ); + if ( paramList.count() > msg.count() - 3 ) { + send( "500 Syntax error, command unrecognized" ); + return; + } + + for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) { + + QString arg = msg[msgId]; + arg.replace( QRegExp("&0x20;"), " " ); + arg.replace( QRegExp("&"), "&" ); + arg.replace( QRegExp("&0x0d;"), "\n" ); + arg.replace( QRegExp("&0x0a;"), "\r" ); + if ( *it == "QString" ) + ds << arg; + else if ( *it == "QCString" ) + ds << arg.local8Bit(); + else if ( *it == "int" ) + ds << arg.toInt(); + else if ( *it == "bool" ) + ds << arg.toInt(); + else { + send( "500 Syntax error, command unrecognized" ); + return; + } + msgId++; + } + + if ( !QCopChannel::isRegistered( channel.latin1() ) ) { + // send message back about it + QString answer = "599 ChannelNotRegistered " + channel; + send( answer ); + return; + } + + if ( paramList.count() ) + QCopChannel::send( channel.latin1(), command.latin1(), buffer ); + else + QCopChannel::send( channel.latin1(), command.latin1() ); + + send( "200 Command okay" ); + } + } + // not implemented + else + send( "502 Command not implemented" ); +} + + + +void QCopBridgePI::timerEvent( QTimerEvent * ) +{ + if ( connected ) + connected = FALSE; + else + connectionClosed(); +} diff --git a/core/launcher/qcopbridge.h b/core/launcher/qcopbridge.h new file mode 100644 index 0000000..114b3ee --- a/dev/null +++ b/core/launcher/qcopbridge.h @@ -0,0 +1,95 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 __qcopbridge_h__ +#define __qcopbridge_h__ + +#include <qserversocket.h> +#include <qsocket.h> +#include <qdir.h> +#include <qfile.h> +#include <qbuffer.h> + +class QFileInfo; +class QCopBridgePI; +class QCopChannel; + +class QCopBridge : public QServerSocket +{ + Q_OBJECT + +public: + QCopBridge( Q_UINT16 port, QObject *parent = 0, const char* name = 0 ); + virtual ~QCopBridge(); + + void newConnection( int socket ); + void closeOpenConnections(); + +public slots: + void connectionClosed( QCopBridgePI *pi ); + void desktopMessage( const QCString &call, const QByteArray & ); + +protected: + void timerEvent( QTimerEvent * ); + +private: + QCopChannel *desktopChannel; + QCopChannel *cardChannel; + QList<QCopBridgePI> openConnections; + bool sendSync; +}; + + +class QCopBridgePI : public QSocket +{ + Q_OBJECT + + enum State { Connected, Wait_USER, Wait_PASS, Ready, Forbidden }; + +public: + QCopBridgePI( int socket, QObject *parent = 0, const char* name = 0 ); + virtual ~QCopBridgePI(); + + void sendDesktopMessage( const QString &msg ); + void startSync() { sendSync = TRUE; } + +signals: + void connectionClosed( QCopBridgePI *); + +protected slots: + void read(); + void send( const QString& msg ); + void process( const QString& command ); + void connectionClosed(); + +protected: + bool checkUser( const QString& user ); + bool checkPassword( const QString& pw ); + + void timerEvent( QTimerEvent *e ); + +private: + State state; + Q_UINT16 peerport; + QHostAddress peeraddress; + bool connected; + bool sendSync; +}; + +#endif diff --git a/core/launcher/qpe-taskbar.control b/core/launcher/qpe-taskbar.control new file mode 100644 index 0000000..f78f136 --- a/dev/null +++ b/core/launcher/qpe-taskbar.control @@ -0,0 +1,9 @@ +Files: bin/qpe apps/Settings/Calibrate.desktop +Priority: required +Section: qpe/system +Maintainer: Warwick Allison <warwick@trolltech.com> +Architecture: arm +Version: $QPE_VERSION-3 +Depends: qt-embedded (>=$QTE_VERSION) +Description: Launcher for QPE + The "finder" or "explorer", or whatever you want to call it. diff --git a/core/launcher/quicklauncher.cpp b/core/launcher/quicklauncher.cpp new file mode 100644 index 0000000..925b3b5 --- a/dev/null +++ b/core/launcher/quicklauncher.cpp @@ -0,0 +1,49 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 <qapplication.h> +#include <qlayout.h> +#include <qpushbutton.h> +#include <applnk.h> +#include <resource.h> +#include "quicklauncher.h" + + +void QuickLauncher::addLauncherButton( AppLnk *appLnk ) +{ + QPushButton *pb = new QPushButton( this ); + // It's no a QObject anymore + //pb->connect( pb, SIGNAL( clicked( ) ), appLnk, SLOT( execute() ) ); + pb->setPixmap( appLnk->pixmap() ); + pb->setFocusPolicy( QWidget::NoFocus ); + pb->setFlat( TRUE ); + pb->setFixedSize( 18, 18 ); +} + + +QuickLauncher::QuickLauncher( QWidget *parent ) : QHBox( parent ) +{ +// Example usage to add icons to the quick launcher area +// addLauncherButton( "filebrowser_icon", "filebrowser" ); +// addLauncherButton( "textedit_icon", "textedit" ); +// addLauncherButton( "help_icon", "helpbrowser" ); +} + + diff --git a/core/launcher/quicklauncher.h b/core/launcher/quicklauncher.h new file mode 100644 index 0000000..92c6c66 --- a/dev/null +++ b/core/launcher/quicklauncher.h @@ -0,0 +1,40 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 __QUICK_LAUNCHER_H__ +#define __QUICK_LAUNCHER_H__ + + +#include <qhbox.h> + +class AppLnk; + + +class QuickLauncher : public QHBox { + Q_OBJECT +public: + QuickLauncher( QWidget *parent ); + void addLauncherButton( AppLnk * ); +}; + + +#endif // __QUICK_LAUNCHER_H__ + + diff --git a/core/launcher/shutdown.ui b/core/launcher/shutdown.ui new file mode 100644 index 0000000..0023427 --- a/dev/null +++ b/core/launcher/shutdown.ui @@ -0,0 +1,1323 @@ +<!DOCTYPE UI><UI> +<class>Shutdown</class> +<widget> + <class>QWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Form1</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>437</width> + <height>465</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>Shut down...</string> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>6</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>3</number> + </property> + <widget> + <class>QButtonGroup</class> + <property stdset="1"> + <name>name</name> + <cstring>ButtonGroup1</cstring> + </property> + <property stdset="1"> + <name>title</name> + <string>Terminate</string> + </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <grid> + <property stdset="1"> + <name>margin</name> + <number>7</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>3</number> + </property> + <widget row="1" column="1" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>quit</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>palette</name> + <palette> + <active> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>236</red> + <green>236</green> + <blue>179</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>245</red> + <green>245</green> + <blue>217</blue> + </color> + <color> + <red>118</red> + <green>118</green> + <blue>89</blue> + </color> + <color> + <red>157</red> + <green>157</green> + <blue>119</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>222</red> + <green>222</green> + <blue>222</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </active> + <disabled> + <color> + <red>128</red> + <green>128</green> + <blue>128</blue> + </color> + <color> + <red>236</red> + <green>236</green> + <blue>179</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>209</blue> + </color> + <color> + <red>118</red> + <green>118</green> + <blue>89</blue> + </color> + <color> + <red>157</red> + <green>157</green> + <blue>119</blue> + </color> + <color> + <red>128</red> + <green>128</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>128</red> + <green>128</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>222</red> + <green>222</green> + <blue>222</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </disabled> + <inactive> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>236</red> + <green>236</green> + <blue>179</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>209</blue> + </color> + <color> + <red>118</red> + <green>118</green> + <blue>89</blue> + </color> + <color> + <red>157</red> + <green>157</green> + <blue>119</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>222</red> + <green>222</green> + <blue>222</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </inactive> + </palette> + </property> + <property stdset="1"> + <name>text</name> + <string>Terminate Server</string> + </property> + <property stdset="1"> + <name>buttonGroupId</name> + <number>4</number> + </property> + </widget> + <widget row="1" column="0" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>reboot</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>0</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>palette</name> + <palette> + <active> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>236</red> + <green>183</green> + <blue>181</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>245</red> + <green>219</green> + <blue>218</blue> + </color> + <color> + <red>118</red> + <green>92</green> + <blue>91</blue> + </color> + <color> + <red>157</red> + <green>122</green> + <blue>121</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>222</red> + <green>222</green> + <blue>222</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </active> + <disabled> + <color> + <red>128</red> + <green>128</green> + <blue>128</blue> + </color> + <color> + <red>236</red> + <green>183</green> + <blue>181</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>255</red> + <green>213</green> + <blue>212</blue> + </color> + <color> + <red>118</red> + <green>92</green> + <blue>91</blue> + </color> + <color> + <red>157</red> + <green>122</green> + <blue>121</blue> + </color> + <color> + <red>128</red> + <green>128</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>128</red> + <green>128</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>222</red> + <green>222</green> + <blue>222</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </disabled> + <inactive> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>236</red> + <green>183</green> + <blue>181</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>255</red> + <green>213</green> + <blue>212</blue> + </color> + <color> + <red>118</red> + <green>92</green> + <blue>91</blue> + </color> + <color> + <red>157</red> + <green>122</green> + <blue>121</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>222</red> + <green>222</green> + <blue>222</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </inactive> + </palette> + </property> + <property stdset="1"> + <name>text</name> + <string>Reboot</string> + </property> + <property stdset="1"> + <name>buttonGroupId</name> + <number>2</number> + </property> + </widget> + <widget row="0" column="1" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>restart</cstring> + </property> + <property stdset="1"> + <name>palette</name> + <palette> + <active> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>236</red> + <green>236</green> + <blue>179</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>245</red> + <green>245</green> + <blue>217</blue> + </color> + <color> + <red>118</red> + <green>118</green> + <blue>89</blue> + </color> + <color> + <red>157</red> + <green>157</green> + <blue>119</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>222</red> + <green>222</green> + <blue>222</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </active> + <disabled> + <color> + <red>128</red> + <green>128</green> + <blue>128</blue> + </color> + <color> + <red>236</red> + <green>236</green> + <blue>179</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>209</blue> + </color> + <color> + <red>118</red> + <green>118</green> + <blue>89</blue> + </color> + <color> + <red>157</red> + <green>157</green> + <blue>119</blue> + </color> + <color> + <red>128</red> + <green>128</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>128</red> + <green>128</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>222</red> + <green>222</green> + <blue>222</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </disabled> + <inactive> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>236</red> + <green>236</green> + <blue>179</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>209</blue> + </color> + <color> + <red>118</red> + <green>118</green> + <blue>89</blue> + </color> + <color> + <red>157</red> + <green>157</green> + <blue>119</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>222</red> + <green>222</green> + <blue>222</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </inactive> + </palette> + </property> + <property stdset="1"> + <name>text</name> + <string>Restart Server</string> + </property> + <property stdset="1"> + <name>buttonGroupId</name> + <number>3</number> + </property> + </widget> + <widget row="0" column="0" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>shutdown</cstring> + </property> + <property stdset="1"> + <name>palette</name> + <palette> + <active> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>236</red> + <green>183</green> + <blue>181</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>245</red> + <green>219</green> + <blue>218</blue> + </color> + <color> + <red>118</red> + <green>92</green> + <blue>91</blue> + </color> + <color> + <red>157</red> + <green>122</green> + <blue>121</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>222</red> + <green>222</green> + <blue>222</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </active> + <disabled> + <color> + <red>128</red> + <green>128</green> + <blue>128</blue> + </color> + <color> + <red>236</red> + <green>183</green> + <blue>181</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>255</red> + <green>213</green> + <blue>212</blue> + </color> + <color> + <red>118</red> + <green>92</green> + <blue>91</blue> + </color> + <color> + <red>157</red> + <green>122</green> + <blue>121</blue> + </color> + <color> + <red>128</red> + <green>128</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>128</red> + <green>128</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>222</red> + <green>222</green> + <blue>222</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </disabled> + <inactive> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>236</red> + <green>183</green> + <blue>181</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>255</red> + <green>213</green> + <blue>212</blue> + </color> + <color> + <red>118</red> + <green>92</green> + <blue>91</blue> + </color> + <color> + <red>157</red> + <green>122</green> + <blue>121</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>222</red> + <green>222</green> + <blue>222</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </inactive> + </palette> + </property> + <property stdset="1"> + <name>text</name> + <string>Shutdown</string> + </property> + <property stdset="1"> + <name>buttonGroupId</name> + <number>1</number> + </property> + </widget> + </grid> + </widget> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>info</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string><p> +These termination options are provided primarily for use while developing and testing the Qtopia system. In a normal environment, these concepts are unnecessary.</string> + </property> + </widget> + <widget> + <class>QProgressBar</class> + <property stdset="1"> + <name>name</name> + <cstring>progressBar</cstring> + </property> + <property stdset="1"> + <name>frameShape</name> + <enum>Panel</enum> + </property> + <property stdset="1"> + <name>frameShadow</name> + <enum>Sunken</enum> + </property> + <property stdset="1"> + <name>totalSteps</name> + <number>20</number> + </property> + <property stdset="1"> + <name>indicatorFollowsStyle</name> + <bool>false</bool> + </property> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer2</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Vertical</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget> + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>cancel</cstring> + </property> + <property stdset="1"> + <name>sizePolicy</name> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>7</vsizetype> + </sizepolicy> + </property> + <property stdset="1"> + <name>palette</name> + <palette> + <active> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>181</red> + <green>222</green> + <blue>178</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>218</red> + <green>238</green> + <blue>216</blue> + </color> + <color> + <red>90</red> + <green>111</green> + <blue>89</blue> + </color> + <color> + <red>120</red> + <green>148</green> + <blue>118</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>174</red> + <green>222</green> + <blue>158</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </active> + <disabled> + <color> + <red>128</red> + <green>128</green> + <blue>128</blue> + </color> + <color> + <red>181</red> + <green>222</green> + <blue>178</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>207</red> + <green>255</green> + <blue>204</blue> + </color> + <color> + <red>90</red> + <green>111</green> + <blue>89</blue> + </color> + <color> + <red>120</red> + <green>148</green> + <blue>118</blue> + </color> + <color> + <red>128</red> + <green>128</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>128</red> + <green>128</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>174</red> + <green>222</green> + <blue>158</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </disabled> + <inactive> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>181</red> + <green>222</green> + <blue>178</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>207</red> + <green>255</green> + <blue>204</blue> + </color> + <color> + <red>90</red> + <green>111</green> + <blue>89</blue> + </color> + <color> + <red>120</red> + <green>148</green> + <blue>118</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + <color> + <red>174</red> + <green>222</green> + <blue>158</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + <color> + <red>0</red> + <green>0</green> + <blue>128</blue> + </color> + <color> + <red>255</red> + <green>255</green> + <blue>255</blue> + </color> + </inactive> + </palette> + </property> + <property stdset="1"> + <name>text</name> + <string>Cancel</string> + </property> + <property stdset="1"> + <name>default</name> + <bool>true</bool> + </property> + </widget> + </vbox> +</widget> +</UI> diff --git a/core/launcher/shutdownimpl.cpp b/core/launcher/shutdownimpl.cpp new file mode 100644 index 0000000..06ed756 --- a/dev/null +++ b/core/launcher/shutdownimpl.cpp @@ -0,0 +1,95 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 "shutdownimpl.h" + +#include <qpe/global.h> + +#include <qtimer.h> +#include <qprogressbar.h> +#include <qpushbutton.h> +#include <qbuttongroup.h> +#include <qlabel.h> + + + +#include <stdio.h> +ShutdownImpl::ShutdownImpl( QWidget* parent, const char *name, WFlags fl ) + : Shutdown( parent, name, fl ) +{ + timer = new QTimer( this ); + connect( timer, SIGNAL(timeout()), this, SLOT(timeout()) ); + + connect( ButtonGroup1, SIGNAL(clicked(int)), this, SLOT(buttonClicked(int)) ); + connect( cancel, SIGNAL(clicked()), this, SLOT(cancelClicked()) ); + + progressBar->hide(); + Global::hideInputMethod(); +#ifdef QT_QWS_CUSTOM + QPushButton *sb = Shutdown::shutdown; + sb->hide(); +#endif +} + +void ShutdownImpl::buttonClicked( int b ) +{ + progress = 0; + switch ( b ) { + case 1: + operation = ShutdownSystem; + break; + case 2: + operation = RebootSystem; + break; + case 3: + operation = RestartDesktop; + break; + case 4: + operation = TerminateDesktop; + break; + } + info->hide(); + progressBar->show(); + timer->start( 300 ); + timeout(); +} + +void ShutdownImpl::cancelClicked() +{ + progressBar->hide(); + info->show(); + if ( timer->isActive() ) + timer->stop(); + else + close(); +} + +void ShutdownImpl::timeout() +{ + if ( (progress+=2) > progressBar->totalSteps() ) { + progressBar->hide(); + timer->stop(); + emit shutdown( operation ); + } else { + progressBar->setProgress( progress ); + } +} + + diff --git a/core/launcher/shutdownimpl.h b/core/launcher/shutdownimpl.h new file mode 100644 index 0000000..54668f3 --- a/dev/null +++ b/core/launcher/shutdownimpl.h @@ -0,0 +1,50 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 SHUTDOWNIMPL_H +#define SHUTDOWNIMPL_H + +#include "shutdown.h" + +class QTimer; + +class ShutdownImpl : public Shutdown +{ + Q_OBJECT +public: + ShutdownImpl( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + + enum Type { ShutdownSystem, RebootSystem, RestartDesktop, TerminateDesktop }; + +signals: + void shutdown( ShutdownImpl::Type ); + +private slots: + void buttonClicked( int ); + void cancelClicked(); + void timeout(); + +private: + QTimer *timer; + int progress; + Type operation; +}; + +#endif + diff --git a/core/launcher/sidething.cpp b/core/launcher/sidething.cpp new file mode 100644 index 0000000..821c9d5 --- a/dev/null +++ b/core/launcher/sidething.cpp @@ -0,0 +1,75 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 "sidething.h" + +#include <qpe/resource.h> + +#include <qrect.h> +#include <qpopupmenu.h> +#include <qpainter.h> + + +void PopupWithLaunchSideThing::setFrameRect( const QRect &r ) +{ + fr = r; + QPopupMenu::setFrameRect( r ); +} + + +void PopupWithLaunchSideThing::paintEvent( QPaintEvent *event ) +{ + QPainter paint( this ); + + if ( !contentsRect().contains( event->rect() ) ) { + + QPopupMenu::setFrameRect( fr ); + int oldLW = lineWidth(); + setUpdatesEnabled(FALSE); + setLineWidth(oldLW); + setUpdatesEnabled(TRUE); + + paint.save(); + paint.setClipRegion( event->region().intersect( frameRect() ) ); + QPixmap pm( Resource::loadPixmap( sidePixmap ) ); + paint.drawPixmap( 2, fr.height() - pm.height() - 2, pm ); +// Need to draw a filled rectangle that extends the colour from the +// end of the pixmap up to the top of the popupmenu +// paint.fillRect(); + drawFrame( &paint ); + paint.restore(); + + } + if ( event->rect().intersects( contentsRect() ) /* && + (fstyle & MShape) != HLine && (fstyle & MShape) != VLine */ ) { + + QPopupMenu::setFrameRect( QRect(fr.left() + 21, fr.top(), fr.width() - 21, fr.height()) ); + int oldLW = lineWidth(); + setUpdatesEnabled(FALSE); + setLineWidth(oldLW); + setUpdatesEnabled(TRUE); + + paint.setClipRegion( event->region().intersect( contentsRect() ) ); + drawContents( &paint ); + } + +} + + diff --git a/core/launcher/sidething.h b/core/launcher/sidething.h new file mode 100644 index 0000000..666a59d --- a/dev/null +++ b/core/launcher/sidething.h @@ -0,0 +1,43 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 __SIDE_THING_H__ +#define __SIDE_THING_H__ + + +#include "startmenu.h" + + +class PopupWithLaunchSideThing : public StartPopupMenu +{ +Q_OBJECT +public: + PopupWithLaunchSideThing( QWidget *parent, QString *pixmap ) : StartPopupMenu( parent ), sidePixmap(*pixmap) { } + +protected: + void setFrameRect( const QRect & ); + void paintEvent( QPaintEvent *event ); + QRect fr; + QString sidePixmap; +}; + + +#endif // __SIDE_THING_H__ + diff --git a/core/launcher/stabmon.cpp b/core/launcher/stabmon.cpp new file mode 100644 index 0000000..2911a1c --- a/dev/null +++ b/core/launcher/stabmon.cpp @@ -0,0 +1,92 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 "stabmon.h" + +#include <qpe/qcopenvelope_qws.h> + +#include <qfile.h> +#include <qcstring.h> + +#include <sys/stat.h> +#include <unistd.h> +#include <stdlib.h> + +SysFileMonitor::SysFileMonitor(QObject* parent) : + QObject(parent) +{ + startTimer(2000); +} + +const char * stab0 = "/var/run/stab"; +const char * stab1 = "/var/state/pcmcia/stab"; +const char * stab2 = "/var/lib/pcmcia/stab"; + +void SysFileMonitor::timerEvent(QTimerEvent*) +{ + struct stat s; + + static const char * tab [] = { + stab0, + stab1, + stab2 + }; + static const int nstab = sizeof(tab)/sizeof(const char *); + static int last[nstab]; + + bool ch = FALSE; + for ( int i=0; i<nstab; i++ ) { + if ( ::stat(tab[i], &s)==0 && (long)s.st_mtime != last[i] ) { + last[i] = (long)s.st_mtime; + ch=TRUE; + } + if ( ch ) { + QCopEnvelope("QPE/Card", "stabChanged()" ); + break; + } + } + + // st_size is no use, it's 0 for /proc/mounts too. Read it all. + static int mtabSize = 0; + QFile f( "/etc/mtab" ); + if ( f.open(IO_ReadOnly) ) { +#if 0 + // readAll does not work correctly on sequential devices (as eg. /proc files) + QByteArray ba = f.readAll(); + if ( (int)ba.size() != mtabSize ) { + mtabSize = (int)ba.size(); + QCopEnvelope("QPE/Card", "mtabChanged()" ); + } +#else + QString s; + while( !f.atEnd() ) { + QString tmp; + f.readLine( tmp, 1024 ); + s += tmp; + } + if ( (int)s.length() != mtabSize ) { + mtabSize = (int)s.length(); + QCopEnvelope("QPE/Card", "mtabChanged()" ); + } +#endif + } +} + diff --git a/core/launcher/stabmon.h b/core/launcher/stabmon.h new file mode 100644 index 0000000..10c79a3 --- a/dev/null +++ b/core/launcher/stabmon.h @@ -0,0 +1,34 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 STABMON_H +#define STABMON_H + +#include <qobject.h> + +class SysFileMonitor : public QObject { +public: + SysFileMonitor(QObject* parent); +protected: + void timerEvent(QTimerEvent*); +}; + +#endif diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp new file mode 100644 index 0000000..54bdfcc --- a/dev/null +++ b/core/launcher/startmenu.cpp @@ -0,0 +1,171 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 "startmenu.h" +#include "sidething.h" +#include "mrulist.h" +#include "info.h" + +#include <qpe/qpeapplication.h> +#include <qpe/config.h> +#include <qpe/applnk.h> +#include <qpe/global.h> +#include <qpe/resource.h> + +#include <qdict.h> + +#include <stdlib.h> + + +// #define USE_CONFIG_FILE + + +StartMenu::StartMenu(QWidget *parent) : QLabel( parent ) +{ + loadOptions(); + + setPixmap( Resource::loadPixmap( startButtonPixmap ) ); + setFocusPolicy( NoFocus ); + //setFlat( startButtonIsFlat ); + + apps = new AppLnkSet( QPEApplication::qpeDir() + "apps" ); + + createMenu(); +} + + +void StartMenu::mousePressEvent( QMouseEvent * ) +{ + launch(); + if (desktopInfo) + desktopInfo->menuClicked(); +} + + +StartMenu::~StartMenu() +{ + delete apps; +} + + +void StartMenu::loadOptions() +{ +#ifdef USE_CONFIG_FILE + // Read configuration file + Config config("StartMenu"); + config.setGroup( "StartMenu" ); + QString tmpBoolString1 = config.readEntry( "UseWidePopupMenu", "FALSE" ); + useWidePopupMenu = ( tmpBoolString1 == "TRUE" ) ? TRUE : FALSE; + QString tmpBoolString2 = config.readEntry( "StartButtonIsFlat", "TRUE" ); + startButtonIsFlat = ( tmpBoolString2 == "TRUE" ) ? TRUE : FALSE; + QString tmpBoolString3 = config.readEntry( "UseMRUList", "TRUE" ); + popupMenuSidePixmap = config.readEntry( "PopupMenuSidePixmap", "sidebar" ); + startButtonPixmap = config.readEntry( "StartButtonPixmap", "go" ); +#else + // Basically just #include the .qpe_menu.conf file settings + useWidePopupMenu = FALSE; + popupMenuSidePixmap = "sidebar"; + startButtonIsFlat = TRUE; + startButtonPixmap = "go"; +#endif +} + + +void StartMenu::createMenu() +{ + if ( useWidePopupMenu ) + launchMenu = new PopupWithLaunchSideThing( this, &popupMenuSidePixmap ); + else + launchMenu = new StartPopupMenu( this ); + + loadMenu( apps, launchMenu ); + +} + +void StartMenu::itemSelected( int id ) +{ + const AppLnk *app = apps->find( id ); + if ( app ) + app->execute(); +} + +bool StartMenu::loadMenu( AppLnkSet *folder, QPopupMenu *menu ) +{ + bool result = FALSE; + + QStringList typs = folder->types(); + QDict<QPopupMenu> typpop; + for (QStringList::Iterator tit=typs.begin(); tit!=typs.end(); ++tit) { + if ( !(*tit).isEmpty() ) { + QPopupMenu *new_menu = new StartPopupMenu( menu ); + typpop.insert(*tit, new_menu); + connect( new_menu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); + menu->insertItem( folder->typePixmap(*tit), *tit, new_menu ); + } + } + + QListIterator<AppLnk> it( folder->children() ); + for ( ; it.current(); ++it ) { + AppLnk *app = it.current(); + if ( app->type() == "Separator" ) { + menu->insertSeparator(); + } else { + QString t = app->type(); + QPopupMenu* pmenu = typpop.find(t); + if ( !pmenu ) + pmenu = menu; + pmenu->insertItem( app->pixmap(), app->name(), app->id() ); + result=TRUE; + } + } + + if ( result ) + connect( menu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); + + return result; +} + + +void StartMenu::launch() +{ + int y = mapToGlobal( QPoint() ).y() - launchMenu->sizeHint().height(); + + if ( launchMenu->isVisible() ) + launchMenu->hide(); + else + launchMenu->popup( QPoint( 1, y ) ); +} + +const AppLnk* StartMenu::execToLink(const QString& appname) +{ + const AppLnk* a = apps->findExec( appname ); + return a; +} + +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 ); + } +} diff --git a/core/launcher/startmenu.h b/core/launcher/startmenu.h new file mode 100644 index 0000000..a02f39e --- a/dev/null +++ b/core/launcher/startmenu.h @@ -0,0 +1,76 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 __START_MENU_H__ +#define __START_MENU_H__ + +#include <qstring.h> +#include <qlist.h> +#include <qlabel.h> +#include <qpopupmenu.h> + + +class AppLnkSet; +class AppLnk; + +class StartPopupMenu : public QPopupMenu +{ +public: + StartPopupMenu( QWidget *parent ) : QPopupMenu( parent ) {} +protected: + void keyPressEvent( QKeyEvent *e ); +}; + +class StartMenu : public QLabel { + Q_OBJECT +public: + StartMenu( QWidget * ); + ~StartMenu(); + + const AppLnk* execToLink(const QString& appname); + +public: + StartPopupMenu *launchMenu; + +public slots: + void launch( ); + void loadOptions( ); + void createMenu( ); + +protected slots: + void itemSelected( int id ); + +protected: + virtual void mousePressEvent( QMouseEvent * ); + +private: + bool loadMenu( AppLnkSet *folder, QPopupMenu *menu ); + +private: + bool useWidePopupMenu; + QString popupMenuSidePixmap; + + bool startButtonIsFlat; + QString startButtonPixmap; + + AppLnkSet *apps; +}; + +#endif // __START_MENU_H__ diff --git a/core/launcher/syncdialog.ui b/core/launcher/syncdialog.ui new file mode 100644 index 0000000..141f123 --- a/dev/null +++ b/core/launcher/syncdialog.ui @@ -0,0 +1,228 @@ +<!DOCTYPE UI><UI> +<class>SyncDialog</class> +<widget> + <class>QDialog</class> + <property stdset="1"> + <name>name</name> + <cstring>SyncDialog</cstring> + </property> + <property stdset="1"> + <name>geometry</name> + <rect> + <x>0</x> + <y>0</y> + <width>210</width> + <height>244</height> + </rect> + </property> + <property stdset="1"> + <name>caption</name> + <string>Syncing</string> + </property> + <property stdset="1"> + <name>sizeGripEnabled</name> + <bool>true</bool> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>11</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <spacer> + <property> + <name>name</name> + <cstring>Spacer10</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Vertical</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout3</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>TextLabel1</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Syncing</string> + </property> + <property stdset="1"> + <name>alignment</name> + <set>AlignCenter</set> + </property> + <property> + <name>hAlign</name> + </property> + </widget> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>whatLabel</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string><b>Contacts</b></string> + </property> + </widget> + </hbox> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer11</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Vertical</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget> + <class>QLayoutWidget</class> + <property stdset="1"> + <name>name</name> + <cstring>Layout4</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <spacer> + <property> + <name>name</name> + <cstring>Spacer4</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + <widget> + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>buttonCancel</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>&Cancel</string> + </property> + <property stdset="1"> + <name>autoDefault</name> + <bool>true</bool> + </property> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer5</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Horizontal</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <spacer> + <property> + <name>name</name> + <cstring>Spacer12</cstring> + </property> + <property stdset="1"> + <name>orientation</name> + <enum>Vertical</enum> + </property> + <property stdset="1"> + <name>sizeType</name> + <enum>Expanding</enum> + </property> + <property> + <name>sizeHint</name> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </spacer> + </vbox> +</widget> +<connections> + <connection> + <sender>buttonCancel</sender> + <signal>clicked()</signal> + <receiver>SyncDialog</receiver> + <slot>reject()</slot> + </connection> +</connections> +</UI> diff --git a/core/launcher/systray.cpp b/core/launcher/systray.cpp new file mode 100644 index 0000000..ad1553f --- a/dev/null +++ b/core/launcher/systray.cpp @@ -0,0 +1,107 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 <qpe/qpeapplication.h> +#include <qpe/qlibrary.h> +#include <qpe/config.h> + +#include <qlayout.h> +#include <qdir.h> +#include <qtranslator.h> + +#include "quicklauncher.h" +#include "systray.h" + +#include <stdlib.h> + +#ifdef SINGLE_APP +#include "clockappletimpl.h" +#endif + +SysTray::SysTray( QWidget *parent ) : QFrame( parent ), layout(0) +{ + //setFrameStyle( QFrame::Panel | QFrame::Sunken ); + loadApplets(); +} + +void SysTray::loadApplets() +{ +#ifndef SINGLE_APP + QValueList<TaskbarApplet>::Iterator mit; + for ( mit = appletList.begin(); mit != appletList.end(); ++mit ) { + (*mit).iface->release(); + (*mit).library->unload(); + delete (*mit).library; + } + appletList.clear(); + if ( layout ) + delete layout; + layout = new QHBoxLayout( this ); + + QString path = QPEApplication::qpeDir() + "/plugins/applets"; + QDir dir( path, "lib*.so" ); + QStringList list = dir.entryList(); + QStringList::Iterator it; + for ( it = list.begin(); it != list.end(); ++it ) { + TaskbarAppletInterface *iface = 0; + QLibrary *lib = new QLibrary( path + "/" + *it ); + if ( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) { + TaskbarApplet applet; + applet.library = lib; + applet.iface = iface; + applet.applet = applet.iface->applet( this ); + positionApplet( applet ); + 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 sysapplet: %s", tfn.latin1() ); + if ( trans->load( tfn )) + qApp->installTranslator( trans ); + else + delete trans; + } else { + delete lib; + } + } +#else + layout = new QHBoxLayout( this ); + TaskbarApplet applet; + applet.iface = new ClockAppletImpl(); + applet.applet = applet.iface->applet( this ); + positionApplet( applet ); +#endif +} + +void SysTray::positionApplet( const TaskbarApplet &a ) +{ + int p = 0; + QValueList<TaskbarApplet>::Iterator it; + for ( it = appletList.begin(); it != appletList.end(); ++it ) { + if ( (*it).iface->position() > a.iface->position() ) + break; + p += 2; + } + + appletList.insert( it, a ); + layout->insertWidget( p, a.applet ); + layout->insertSpacing( p, 1 ); +} + diff --git a/core/launcher/systray.h b/core/launcher/systray.h new file mode 100644 index 0000000..0aed348 --- a/dev/null +++ b/core/launcher/systray.h @@ -0,0 +1,58 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 __SYSTRAY_H__ +#define __SYSTRAY_H__ + +#include <qpe/taskbarappletinterface.h> + +#include <qframe.h> +#include <qvaluelist.h> + +class QHBoxLayout; +class QLibrary; + +struct TaskbarApplet +{ +#ifndef QT_NO_COMPONENT + QLibrary *library; +#endif + TaskbarAppletInterface *iface; + QWidget *applet; +}; + +class SysTray : public QFrame { + Q_OBJECT +public: + SysTray( QWidget *parent ); + + void loadApplets(); + +private: + void positionApplet( const TaskbarApplet &a ); + +private: + QHBoxLayout *layout; + QValueList<TaskbarApplet> appletList; +}; + + +#endif // __SYSTRAY_H__ + diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp new file mode 100644 index 0000000..d7f36bd --- a/dev/null +++ b/core/launcher/taskbar.cpp @@ -0,0 +1,314 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 "startmenu.h" +#include "inputmethods.h" +#include "mrulist.h" +#include "systray.h" +#include "calibrate.h" +#include "wait.h" +#include "appicons.h" + +#include "taskbar.h" +#include "desktop.h" + +#include <qpe/qpeapplication.h> +#include <qpe/qcopenvelope_qws.h> +#include <qpe/global.h> +#ifdef QT_QWS_CUSTOM +#include <qpe/custom.h> +#endif + +#include <qlabel.h> +#include <qlayout.h> +#include <qtimer.h> +#include <qwindowsystem_qws.h> +#include <qwidgetstack.h> + +#if defined( Q_WS_QWS ) +#include <qwsdisplay_qws.h> +#include <qgfx_qws.h> +#endif + + +#define FACTORY(T) \ + static QWidget *new##T( bool maximized ) { \ + QWidget *w = new T( 0, "test", QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ + if ( maximized ) { \ + if ( qApp->desktop()->width() <= 350 ) { \ + w->showMaximized(); \ + } else { \ + w->resize( QSize( 300, 300 ) ); \ + } \ + } \ + w->show(); \ + return w; \ + } + + +#ifdef SINGLE_APP +#define APP(a,b,c,d) FACTORY(b) +#include "../taskbar/apps.h" +#undef APP +#endif // SINGLE_APP + +static Global::Command builtins[] = { + +#ifdef SINGLE_APP +#define APP(a,b,c,d) { a, new##b, c }, +#include "../taskbar/apps.h" +#undef APP +#endif + +#if defined(QT_QWS_IPAQ) || defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_EBX) + { "calibrate", TaskBar::calibrate, 1, 0 }, +#endif +#if !defined(QT_QWS_CASSIOPEIA) + { "shutdown", Global::shutdown, 1, 0 }, +// { "run", run, 1, 0 }, +#endif + + { 0, TaskBar::calibrate, 0, 0 }, +}; + +static bool initNumLock() +{ +#ifdef QPE_INITIAL_NUMLOCK_STATE + QPE_INITIAL_NUMLOCK_STATE +#endif + return FALSE; +} + +class LockKeyState : public QWidget +{ +public: + LockKeyState( QWidget *parent ) : + QWidget(parent), + nl(initNumLock()), cl(FALSE) + { + nl_pm = Resource::loadPixmap("numlock"); + cl_pm = Resource::loadPixmap("capslock"); + } + QSize sizeHint() const + { + return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1); + } + void toggleNumLockState() + { + nl = !nl; repaint(); + } + void toggleCapsLockState() + { + cl = !cl; repaint(); + } + void paintEvent( QPaintEvent * ) + { + int y = (height()-sizeHint().height())/2; + QPainter p(this); + if ( nl ) + p.drawPixmap(1,y,nl_pm); + if ( cl ) + p.drawPixmap(1,y+nl_pm.height()+1,cl_pm); + } +private: + QPixmap nl_pm, cl_pm; + bool nl, cl; +}; + +TaskBar::~TaskBar() +{ +} + + +TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader) +{ + Global::setBuiltinCommands(builtins); + + sm = new StartMenu( this ); + + inputMethods = new InputMethods( this ); + connect( inputMethods, SIGNAL(inputToggled(bool)), + this, SLOT(calcMaxWindowRect()) ); + //new QuickLauncher( this ); + + stack = new QWidgetStack( this ); + stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + label = new QLabel(stack); + + mru = new MRUList( stack ); + stack->raiseWidget( mru ); + + waitIcon = new Wait( this ); + (void) new AppIcons( this ); + + sysTray = new SysTray( this ); + + // ## make customizable in some way? +#ifdef QT_QWS_CUSTOM + lockState = new LockKeyState( this ); +#else + lockState = 0; +#endif + +#if defined(Q_WS_QWS) +#if !defined(QT_NO_COP) + QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this ); + connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), + this, SLOT(receive(const QCString&, const QByteArray&)) ); +#endif +#endif + waitTimer = new QTimer( this ); + connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) ); + clearer = new QTimer( this ); + QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar())); + QObject::connect(clearer, SIGNAL(timeout()), sysTray, SLOT(show())); +} + +void TaskBar::setStatusMessage( const QString &text ) +{ + label->setText( text ); + stack->raiseWidget( label ); + if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) ) + sysTray->hide(); + clearer->start( 3000 ); +} + +void TaskBar::clearStatusBar() +{ + label->clear(); + stack->raiseWidget( mru ); +} + +void TaskBar::startWait() +{ + waitIcon->setWaiting( true ); + // a catchall stop after 10 seconds... + waitTimer->start( 10 * 1000, true ); +} + +void TaskBar::stopWait(const QString& app) +{ + waitTimer->stop(); + mru->addTask(sm->execToLink(app)); + waitIcon->setWaiting( false ); +} + +void TaskBar::stopWait() +{ + waitTimer->stop(); + waitIcon->setWaiting( false ); +} + +void TaskBar::resizeEvent( QResizeEvent *e ) +{ + QHBox::resizeEvent( e ); + calcMaxWindowRect(); +} + +void TaskBar::styleChange( QStyle &s ) +{ + QHBox::styleChange( s ); + calcMaxWindowRect(); +} + +void TaskBar::calcMaxWindowRect() +{ +#ifdef Q_WS_QWS + QRect wr; + int displayWidth = qApp->desktop()->width(); + QRect ir = inputMethods->inputRect(); + if ( ir.isValid() ) { + wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); + } else { + wr.setCoords( 0, 0, displayWidth-1, y()-1 ); + } + +#if QT_VERSION < 300 + QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, + QSize(qt_screen->width(),qt_screen->height())) + ); +#else + QWSServer::setMaxWindowRect( wr ); +#endif +#endif +} + +void TaskBar::receive( const QCString &msg, const QByteArray &data ) +{ + QDataStream stream( data, IO_ReadOnly ); + if ( msg == "message(QString)" ) { + QString text; + stream >> text; + setStatusMessage( text ); + } else if ( msg == "hideInputMethod()" ) { + inputMethods->hideInputMethod(); + } else if ( msg == "showInputMethod()" ) { + inputMethods->showInputMethod(); + } else if ( msg == "reloadInputMethods()" ) { + inputMethods->loadInputMethods(); + } else if ( msg == "reloadApplets()" ) { + sysTray->loadApplets(); + } else if ( msg == "soundAlarm()" ) { + Desktop::soundAlarm(); + } +#ifdef CUSTOM_LEDS + else if ( msg == "setLed(int,bool)" ) { + int led, status; + stream >> led >> status; + CUSTOM_LEDS( led, status ); + } +#endif +} + +QWidget *TaskBar::calibrate(bool) +{ +#ifdef Q_WS_QWS + Calibrate *c = new Calibrate; + c->show(); + return c; +#else + return 0; +#endif +} + +void TaskBar::toggleNumLockState() +{ + if ( lockState ) lockState->toggleNumLockState(); +} + +void TaskBar::toggleCapsLockState() +{ + if ( lockState ) lockState->toggleCapsLockState(); +} + +void TaskBar::toggleSymbolInput() +{ + if ( inputMethods->currentShown() == "Unicode" ) { + inputMethods->hideInputMethod(); + } else { + inputMethods->showInputMethod("Unicode"); + } +} + +bool TaskBar::recoverMemory() +{ + return mru->quitOldApps(); +} + diff --git a/core/launcher/taskbar.h b/core/launcher/taskbar.h new file mode 100644 index 0000000..cdeb3c7 --- a/dev/null +++ b/core/launcher/taskbar.h @@ -0,0 +1,86 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 __TASKBAR_H__ +#define __TASKBAR_H__ + +#ifdef QT_QWS_CUSTOM +#include <qpe/custom.h> +#endif + +#include <qhbox.h> + +class QLabel; +class QTimer; +class InputMethods; +class Wait; +class SysTray; +class MRUList; +class QWidgetStack; +class QTimer; +class QLabel; +class StartMenu; +class LockKeyState; + +class TaskBar : public QHBox { + Q_OBJECT +public: + TaskBar(); + ~TaskBar(); + + static QWidget *calibrate( bool ); + + bool recoverMemory(); + + StartMenu *startMenu() const { return sm; } +public slots: + void startWait(); + void stopWait(const QString&); + void stopWait(); + void clearStatusBar(); + void toggleNumLockState(); + void toggleCapsLockState(); + void toggleSymbolInput(); + +protected: + void resizeEvent( QResizeEvent * ); + void styleChange( QStyle & ); + void setStatusMessage( const QString &text ); + +private slots: + void calcMaxWindowRect(); + void receive( const QCString &msg, const QByteArray &data ); + +private: + + QTimer *waitTimer; + Wait *waitIcon; + InputMethods *inputMethods; + SysTray *sysTray; + MRUList *mru; + QWidgetStack *stack; + QTimer *clearer; + QLabel *label; + LockKeyState* lockState; + StartMenu *sm; +}; + + +#endif // __TASKBAR_H__ diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp new file mode 100644 index 0000000..87a49eb --- a/dev/null +++ b/core/launcher/transferserver.cpp @@ -0,0 +1,1245 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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> + +#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 <qpe/qcopchannel_qws.h> +#include <qpe/qprocess.h> +#include <qpe/process.h> +#include <qpe/config.h> +#include <qpe/qcopenvelope_qws.h> + +#include "transferserver.h" + +const int block_size = 51200; + +TransferServer::TransferServer( Q_UINT16 port, QObject *parent = 0, + const char* name = 0) + : 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 ); +} + +bool accessAuthorized(QHostAddress peeraddress) +{ + Config cfg("Security"); + cfg.setGroup("Sync"); + uint auth_peer = cfg.readNumEntry("auth_peer",0xc0a80100); + uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24); + bool ok = (peeraddress.ip4Addr() & (((1<<auth_peer_bits)-1)<<(32-auth_peer_bits))) + == auth_peer; + /* Allows denial-of-service attack. + if ( !ok ) { + QMessageBox::warning(0,tr("Security"), + tr("<p>An attempt to access this device from %1 has been denied.") + .arg(peeraddress.toString())); + } + */ + return ok; +} + +ServerPI::ServerPI( int socket, QObject *parent = 0, const char* name = 0 ) + : QSocket( parent, name ) , dtp( 0 ), serversocket( 0 ), waitsocket( 0 ) +{ + state = Connected; + + setSocket( socket ); + + peerport = peerPort(); + peeraddress = peerAddress(); + +#ifndef INSECURE + if ( !accessAuthorized(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 transfer service ready!" ); + 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::checkUser( const QString& user ) +{ + if ( user.isEmpty() ) return FALSE; + + struct passwd *pw; + pw = getpwuid( geteuid() ); + QString euser = QString::fromLocal8Bit( pw->pw_name ); + return user == euser; +} + +bool ServerPI::checkPassword( const QString& /* password */ ) +{ + // ### HACK for testing on local host + return true; + + /* + 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 ); + + QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); + return cpwd == cpassword; +*/ +} + +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 || !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" || !checkPassword( arg ) ) { + //if ( cmd != "PASS" || msg.count() < 2 || !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" ) + send( "200 Command okay" ); + else + send( "504 Command not implemented for that parameter" ); + } + + + // FTP SERVICE COMMANDS + + + // retrieve (RETR) + else if ( cmd == "RETR" ) + if ( !args.isEmpty() && checkReadFile( absFilePath( args ) ) + || backupRestoreGzip( absFilePath( args ) ) ) { + send( "150 File status okay" ); + sendFile( absFilePath( args ) ); + } + else { + qDebug("550 Requested action not taken"); + send( "550 Requested action not taken" ); + } + + // store (STOR) + else if ( cmd == "STOR" ) + if ( !args.isEmpty() && checkWriteFile( absFilePath( args ) ) ) { + send( "150 File status okay" ); + retrieveFile( absFilePath( args ) ); + } + else + send( "550 Requested action not taken" ); + + // store unique (STOU) + else if ( cmd == "STOU" ) { + send( "502 Command not implemented" ); + } + + // append (APPE) + else if ( cmd == "APPE" ) { + send( "502 Command not implemented" ); + } + + // allocate (ALLO) + else if ( cmd == "ALLO" ) { + send( "200 Command okay" ); + } + + // restart (REST) + else if ( cmd == "REST" ) { + send( "502 Command not implemented" ); + } + + // rename from (RNFR) + else if ( cmd == "RNFR" ) { + renameFrom = QString::null; + if ( args.isEmpty() ) + send( "500 Syntax error, command unrecognized" ); + else { + QFile file( absFilePath( args ) ); + if ( file.exists() ) { + send( "350 File exists, ready for destination name" ); + renameFrom = absFilePath( args ); + } + else + send( "550 Requested action not taken" ); + } + } + + // rename to (RNTO) + else if ( cmd == "RNTO" ) { + if ( lastCommand != "RNFR" ) + send( "503 Bad sequence of commands" ); + else if ( args.isEmpty() ) + send( "500 Syntax error, command unrecognized" ); + else { + QDir dir( absFilePath( args ) ); + if ( dir.rename( renameFrom, absFilePath( args ), TRUE ) ) + send( "250 Requested file action okay, completed." ); + else + send( "550 Requested action not taken" ); + } + } + + // abort (ABOR) + else if ( cmd.contains( "ABOR" ) ) { + dtp->close(); + if ( dtp->dtpMode() != ServerDTP::Idle ) + send( "426 Connection closed; transfer aborted" ); + else + send( "226 Closing data connection" ); + } + + // delete (DELE) + else if ( cmd == "DELE" ) { + if ( args.isEmpty() ) + send( "500 Syntax error, command unrecognized" ); + else { + QFile file( absFilePath( args ) ) ; + if ( file.remove() ) + send( "250 Requested file action okay, completed" ); + else + send( "550 Requested action not taken" ); + } + } + + // remove directory (RMD) + else if ( cmd == "RMD" ) { + if ( args.isEmpty() ) + send( "500 Syntax error, command unrecognized" ); + else { + QDir dir; + if ( dir.rmdir( absFilePath( args ), TRUE ) ) + send( "250 Requested file action okay, completed" ); + else + send( "550 Requested action not taken" ); + } + } + + // make directory (MKD) + else if ( cmd == "MKD" ) { + if ( args.isEmpty() ) { + qDebug(" Error: no arg"); + send( "500 Syntax error, command unrecognized" ); + } + else { + QDir dir; + if ( dir.mkdir( absFilePath( args ), TRUE ) ) + send( "250 Requested file action okay, completed." ); + else + send( "550 Requested action not taken" ); + } + } + + // print working directory (PWD) + else if ( cmd == "PWD" ) { + send( "257 \"" + directory.path() +"\"" ); + } + + // list (LIST) + else if ( cmd == "LIST" ) { + if ( sendList( absFilePath( args ) ) ) + send( "150 File status okay" ); + else + send( "500 Syntax error, command unrecognized" ); + } + + // size (SIZE) + else if ( cmd == "SIZE" ) { + QString filePath = absFilePath( args ); + QFileInfo fi( filePath ); + bool gzipfile = backupRestoreGzip( filePath ); + if ( !fi.exists() && !gzipfile ) + send( "500 Syntax error, command unrecognized" ); + else { + if ( !gzipfile ) + send( "213 " + QString::number( fi.size() ) ); + else { + Process duproc( QString("du") ); + duproc.addArgument("-s"); + QString in, out; + if ( !duproc.exec(in, out) ) { + qDebug("du process failed; just sending back 1K"); + send( "213 1024"); + } + else { + QString size = out.left( out.find("\t") ); + int guess = size.toInt()/5; + if ( filePath.contains("doc") ) + guess *= 1000; + qDebug("sending back gzip guess of %d", guess); + send( "213 " + QString::number(guess) ); + } + } + } + } + // name list (NLST) + else if ( cmd == "NLST" ) { + send( "502 Command not implemented" ); + } + + // site parameters (SITE) + else if ( cmd == "SITE" ) { + send( "502 Command not implemented" ); + } + + // system (SYST) + else if ( cmd == "SYST" ) { + send( "215 UNIX Type: L8" ); + } + + // status (STAT) + else if ( cmd == "STAT" ) { + send( "502 Command not implemented" ); + } + + // help (HELP ) + else if ( cmd == "HELP" ) { + send( "502 Command not implemented" ); + } + + // noop (NOOP) + else if ( cmd == "NOOP" ) { + send( "200 Command okay" ); + } + + // not implemented + else + send( "502 Command not implemented" ); + + lastCommand = cmd; +} + +bool ServerPI::backupRestoreGzip( const QString &file ) +{ + return (file.find( "backup" ) != -1 && + file.findRev( ".tgz" ) == (int)file.length()-4 ); +} + +bool ServerPI::backupRestoreGzip( const QString &file, QStringList &targets ) +{ + if ( file.find( "backup" ) != -1 && + file.findRev( ".tgz" ) == (int)file.length()-4 ) { + QFileInfo info( file ); + targets = info.dirPath( TRUE ); + qDebug("ServerPI::backupRestoreGzip for %s = %s", file.latin1(), + targets.join(" ").latin1() ); + return true; + } + return false; +} + +void ServerPI::sendFile( const QString& file ) +{ + if ( passiv ) { + wait[SendFile] = TRUE; + waitfile = file; + if ( waitsocket ) + newConnection( waitsocket ); + } + else { + QStringList targets; + if ( backupRestoreGzip( file, targets ) ) + dtp->sendGzipFile( file, targets, peeraddress, peerport ); + else dtp->sendFile( file, peeraddress, peerport ); + } +} + +void ServerPI::retrieveFile( const QString& file ) +{ + if ( passiv ) { + wait[RetrieveFile] = TRUE; + waitfile = file; + if ( waitsocket ) + newConnection( waitsocket ); + } + else { + QStringList targets; + if ( backupRestoreGzip( file, targets ) ) + dtp->retrieveGzipFile( file, peeraddress, peerport ); + else + dtp->retrieveFile( file, peeraddress, peerport ); + } +} + +bool ServerPI::parsePort( const QString& pp ) +{ + QStringList p = QStringList::split( ",", pp ); + if ( p.count() != 6 ) return FALSE; + + // h1,h2,h3,h4,p1,p2 + peeraddress = QHostAddress( ( p[0].toInt() << 24 ) + ( p[1].toInt() << 16 ) + + ( p[2].toInt() << 8 ) + p[3].toInt() ); + peerport = ( p[4].toInt() << 8 ) + p[5].toInt(); + return TRUE; +} + +void ServerPI::dtpCompleted() +{ + dtp->close(); + waitsocket = 0; + send( "226 Closing data connection, file transfer successful" ); +} + +void ServerPI::dtpFailed() +{ + dtp->close(); + waitsocket = 0; + send( "451 Requested action aborted: local error in processing" ); +} + +void ServerPI::dtpError( int ) +{ + dtp->close(); + waitsocket = 0; + send( "451 Requested action aborted: local error in processing" ); +} + +bool ServerPI::sendList( const QString& arg ) +{ + QByteArray listing; + QBuffer buffer( listing ); + + if ( !buffer.open( IO_WriteOnly ) ) + return FALSE; + + QTextStream ts( &buffer ); + QString fn = arg; + + if ( fn.isEmpty() ) + fn = directory.path(); + + QFileInfo fi( fn ); + if ( !fi.exists() ) return FALSE; + + // return file listing + if ( fi.isFile() ) { + ts << fileListing( &fi ) << endl; + } + + // return directory listing + else if ( fi.isDir() ) { + QDir dir( fn ); + const QFileInfoList *list = dir.entryInfoList( QDir::All | QDir::Hidden ); + + QFileInfoListIterator it( *list ); + QFileInfo *info; + + unsigned long total = 0; + while ( ( info = it.current() ) ) { + if ( info->fileName() != "." && info->fileName() != ".." ) + total += info->size(); + ++it; + } + + ts << "total " << QString::number( total / 1024 ) << endl; + + it.toFirst(); + while ( ( info = it.current() ) ) { + if ( info->fileName() == "." || info->fileName() == ".." ) { + ++it; + continue; + } + ts << fileListing( info ) << endl; + ++it; + } + } + + if ( passiv ) { + waitarray = buffer.buffer(); + wait[SendByteArray] = TRUE; + if ( waitsocket ) + newConnection( waitsocket ); + } + else + dtp->sendByteArray( buffer.buffer(), peeraddress, peerport ); + return TRUE; +} + +QString ServerPI::fileListing( QFileInfo *info ) +{ + if ( !info ) return QString::null; + QString s; + + // type char + if ( info->isDir() ) + s += "d"; + else if ( info->isSymLink() ) + s += "l"; + else + s += "-"; + + // permisson string + s += permissionString( info ) + " "; + + // number of hardlinks + int subdirs = 1; + + if ( info->isDir() ) + subdirs = 2; + // FIXME : this is to slow + //if ( info->isDir() ) + //subdirs = QDir( info->absFilePath() ).entryList( QDir::Dirs ).count(); + + s += QString::number( subdirs ).rightJustify( 3, ' ', TRUE ) + " "; + + // owner + s += info->owner().leftJustify( 8, ' ', TRUE ) + " "; + + // group + s += info->group().leftJustify( 8, ' ', TRUE ) + " "; + + // file size in bytes + s += QString::number( info->size() ).rightJustify( 9, ' ', TRUE ) + " "; + + // last modified date + QDate date = info->lastModified().date(); + QTime time = info->lastModified().time(); + s += date.monthName( date.month() ) + " " + + QString::number( date.day() ).rightJustify( 2, ' ', TRUE ) + " " + + QString::number( time.hour() ).rightJustify( 2, '0', TRUE ) + ":" + + QString::number( time.minute() ).rightJustify( 2,'0', TRUE ) + " "; + + // file name + s += info->fileName(); + + return s; +} + +QString ServerPI::permissionString( QFileInfo *info ) +{ + if ( !info ) return QString( "---------" ); + QString s; + + // user + if ( info->permission( QFileInfo::ReadUser ) ) s += "r"; + else s += "-"; + if ( info->permission( QFileInfo::WriteUser ) ) s += "w"; + else s += "-"; + if ( info->permission( QFileInfo::ExeUser ) ) s += "x"; + else s += "-"; + + // group + if ( info->permission( QFileInfo::ReadGroup ) ) s += "r"; + else s += "-"; + if ( info->permission( QFileInfo::WriteGroup ) )s += "w"; + else s += "-"; + if ( info->permission( QFileInfo::ExeGroup ) ) s += "x"; + else s += "-"; + + // exec + if ( info->permission( QFileInfo::ReadOther ) ) s += "r"; + else s += "-"; + if ( info->permission( QFileInfo::WriteOther ) ) s += "w"; + else s += "-"; + if ( info->permission( QFileInfo::ExeOther ) ) s += "x"; + else s += "-"; + + return s; +} + +void ServerPI::newConnection( int socket ) +{ + //qDebug( "New incomming connection" ); + + if ( !passiv ) return; + + if ( wait[SendFile] ) { + QStringList targets; + if ( backupRestoreGzip( waitfile, targets ) ) + dtp->sendGzipFile( waitfile, targets ); + else + dtp->sendFile( waitfile ); + dtp->setSocket( socket ); + } + else if ( wait[RetrieveFile] ) { + qDebug("check retrieve file"); + if ( backupRestoreGzip( waitfile ) ) + dtp->retrieveGzipFile( waitfile ); + else + dtp->retrieveFile( waitfile ); + dtp->setSocket( socket ); + } + else if ( wait[SendByteArray] ) { + dtp->sendByteArray( waitarray ); + dtp->setSocket( socket ); + } + else if ( wait[RetrieveByteArray] ) { + qDebug("retrieve byte array"); + dtp->retrieveByteArray(); + dtp->setSocket( socket ); + } + else + waitsocket = socket; + + for( int i = 0; i < 4; i++ ) + wait[i] = FALSE; +} + +QString ServerPI::absFilePath( const QString& file ) +{ + if ( file.isEmpty() ) return file; + + QString filepath( file ); + if ( file[0] != "/" ) + filepath = directory.path() + "/" + file; + + return filepath; +} + + +void ServerPI::timerEvent( QTimerEvent * ) +{ + connectionClosed(); +} + + +ServerDTP::ServerDTP( QObject *parent = 0, const char* name = 0) + : QSocket( parent, name ), mode( Idle ), createTargzProc( 0 ), +retrieveTargzProc( 0 ), gzipProc( 0 ) +{ + + connect( this, SIGNAL( connected() ), SLOT( connected() ) ); + connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); + connect( this, SIGNAL( bytesWritten( int ) ), SLOT( bytesWritten( int ) ) ); + connect( this, SIGNAL( readyRead() ), SLOT( readyRead() ) ); + + gzipProc = new QProcess( this, "gzipProc" ); + gzipProc->setCommunication( QProcess::Stdin | QProcess::Stdout ); + + createTargzProc = new QProcess( QString("tar"), this, "createTargzProc"); + createTargzProc->setCommunication( QProcess::Stdout ); + createTargzProc->setWorkingDirectory( QDir::rootDirPath() ); + connect( createTargzProc, SIGNAL( processExited() ), SLOT( targzDone() ) ); + + QStringList args = "tar"; + args += "-xv"; + retrieveTargzProc = new QProcess( args, this, "retrieveTargzProc" ); + retrieveTargzProc->setCommunication( QProcess::Stdin ); + retrieveTargzProc->setWorkingDirectory( QDir::rootDirPath() ); + connect( retrieveTargzProc, SIGNAL( processExited() ), + SIGNAL( completed() ) ); + connect( retrieveTargzProc, SIGNAL( processExited() ), + SLOT( extractTarDone() ) ); +} + +ServerDTP::~ServerDTP() +{ + buf.close(); + file.close(); + createTargzProc->kill(); +} + +void ServerDTP::extractTarDone() +{ + qDebug("extract done"); + QCopEnvelope e( "QPE/Desktop", "restoreDone(QString)" ); + e << file.name(); +} + +void ServerDTP::connected() +{ + // send file mode + switch ( mode ) { + case SendFile : + if ( !file.exists() || !file.open( IO_ReadOnly) ) { + emit failed(); + mode = Idle; + return; + } + + //qDebug( "Debug: Sending file '%s'", file.name().latin1() ); + + bytes_written = 0; + if ( file.size() == 0 ) { + //make sure it doesn't hang on empty files + file.close(); + emit completed(); + mode = Idle; + } else { + + if( !file.atEnd() ) { + QCString s; + s.resize( block_size ); + int bytes = file.readBlock( s.data(), block_size ); + writeBlock( s.data(), bytes ); + } + } + break; + case SendGzipFile: + if ( createTargzProc->isRunning() ) { + // SHOULDN'T GET HERE, BUT DOING A SAFETY CHECK ANYWAY + qWarning("Previous tar --gzip process is still running; killing it..."); + createTargzProc->kill(); + } + + bytes_written = 0; + qDebug("==>start send tar process"); + if ( !createTargzProc->start() ) + qWarning("Error starting %s or %s", + createTargzProc->arguments().join(" ").latin1(), + gzipProc->arguments().join(" ").latin1() ); + break; + case SendBuffer: + if ( !buf.open( IO_ReadOnly) ) { + emit failed(); + mode = Idle; + return; + } + + // qDebug( "Debug: Sending byte array" ); + bytes_written = 0; + while( !buf.atEnd() ) + putch( buf.getch() ); + buf.close(); + break; + case RetrieveFile: + // retrieve file mode + if ( file.exists() && !file.remove() ) { + emit failed(); + mode = Idle; + return; + } + + if ( !file.open( IO_WriteOnly) ) { + emit failed(); + mode = Idle; + return; + } + // qDebug( "Debug: Retrieving file %s", file.name().latin1() ); + break; + case RetrieveGzipFile: + qDebug("=-> starting tar process to receive .tgz file"); + break; + case RetrieveBuffer: + // retrieve buffer mode + if ( !buf.open( IO_WriteOnly) ) { + emit failed(); + mode = Idle; + return; + } + // qDebug( "Debug: Retrieving byte array" ); + break; + case Idle: + qDebug("connection established but mode set to Idle; BUG!"); + break; + } +} + +void ServerDTP::connectionClosed() +{ + //qDebug( "Debug: Data connection closed %ld bytes written", bytes_written ); + + // send file mode + if ( SendFile == mode ) { + if ( bytes_written == file.size() ) + emit completed(); + else + emit failed(); + } + + // send buffer mode + else if ( SendBuffer == mode ) { + if ( bytes_written == buf.size() ) + emit completed(); + else + emit failed(); + } + + // retrieve file mode + else if ( RetrieveFile == mode ) { + file.close(); + emit completed(); + } + + else if ( RetrieveGzipFile == mode ) { + qDebug("Done writing ungzip file; closing input"); + gzipProc->flushStdin(); + gzipProc->closeStdin(); + } + + // retrieve buffer mode + else if ( RetrieveBuffer == mode ) { + buf.close(); + emit completed(); + } + + mode = Idle; +} + +void ServerDTP::bytesWritten( int bytes ) +{ + bytes_written += bytes; + + // send file mode + if ( SendFile == mode ) { + + if ( bytes_written == file.size() ) { + // qDebug( "Debug: Sending complete: %d bytes", file.size() ); + file.close(); + emit completed(); + mode = Idle; + } + else if( !file.atEnd() ) { + QCString s; + s.resize( block_size ); + int bytes = file.readBlock( s.data(), block_size ); + writeBlock( s.data(), bytes ); + } + } + + // send buffer mode + if ( SendBuffer == mode ) { + + if ( bytes_written == buf.size() ) { + // qDebug( "Debug: Sending complete: %d bytes", buf.size() ); + emit completed(); + mode = Idle; + } + } +} + +void ServerDTP::readyRead() +{ + // retrieve file mode + if ( RetrieveFile == mode ) { + QCString s; + s.resize( bytesAvailable() ); + readBlock( s.data(), bytesAvailable() ); + file.writeBlock( s.data(), s.size() ); + } + else if ( RetrieveGzipFile == mode ) { + if ( !gzipProc->isRunning() ) + gzipProc->start(); + + QByteArray s; + s.resize( bytesAvailable() ); + readBlock( s.data(), bytesAvailable() ); + gzipProc->writeToStdin( s ); + qDebug("wrote %d bytes to ungzip ", s.size() ); + } + // retrieve buffer mode + else if ( RetrieveBuffer == mode ) { + QCString s; + s.resize( bytesAvailable() ); + readBlock( s.data(), bytesAvailable() ); + buf.writeBlock( s.data(), s.size() ); + } +} + +void ServerDTP::writeTargzBlock() +{ + QByteArray block = gzipProc->readStdout(); + writeBlock( block.data(), block.size() ); + qDebug("writeTargzBlock %d", block.size()); + if ( !createTargzProc->isRunning() ) { + qDebug("tar and gzip done"); + emit completed(); + mode = Idle; + disconnect( gzipProc, SIGNAL( readyReadStdout() ), + this, SLOT( writeTargzBlock() ) ); + } +} + +void ServerDTP::targzDone() +{ + //qDebug("targz done"); + disconnect( createTargzProc, SIGNAL( readyReadStdout() ), + this, SLOT( gzipTarBlock() ) ); + gzipProc->closeStdin(); +} + +void ServerDTP::gzipTarBlock() +{ + //qDebug("gzipTarBlock"); + if ( !gzipProc->isRunning() ) { + //qDebug("auto start gzip proc"); + gzipProc->start(); + } + gzipProc->writeToStdin( createTargzProc->readStdout() ); +} + +void ServerDTP::sendFile( const QString fn, const QHostAddress& host, Q_UINT16 port ) +{ + file.setName( fn ); + mode = SendFile; + connectToHost( host.toString(), port ); +} + +void ServerDTP::sendFile( const QString fn ) +{ + file.setName( fn ); + mode = SendFile; +} + +void ServerDTP::sendGzipFile( const QString &fn, + const QStringList &archiveTargets, + const QHostAddress& host, Q_UINT16 port ) +{ + sendGzipFile( fn, archiveTargets ); + connectToHost( host.toString(), port ); +} + +void ServerDTP::sendGzipFile( const QString &fn, + const QStringList &archiveTargets ) +{ + mode = SendGzipFile; + file.setName( fn ); + + QStringList args = "tar"; + args += "-cv"; + args += archiveTargets; + qDebug("sendGzipFile %s", args.join(" ").latin1() ); + createTargzProc->setArguments( args ); + connect( createTargzProc, + SIGNAL( readyReadStdout() ), SLOT( gzipTarBlock() ) ); + + gzipProc->setArguments( "gzip" ); + connect( gzipProc, SIGNAL( readyReadStdout() ), + SLOT( writeTargzBlock() ) ); +} + +void ServerDTP::gunzipDone() +{ + qDebug("gunzipDone"); + disconnect( gzipProc, SIGNAL( processExited() ), + this, SLOT( gunzipDone() ) ); + retrieveTargzProc->closeStdin(); + disconnect( gzipProc, SIGNAL( readyReadStdout() ), + this, SLOT( tarExtractBlock() ) ); +} + +void ServerDTP::tarExtractBlock() +{ + qDebug("ungzipTarBlock"); + if ( !retrieveTargzProc->isRunning() ) { + qDebug("auto start ungzip proc"); + if ( !retrieveTargzProc->start() ) + qWarning(" failed to start tar -x process"); + } + retrieveTargzProc->writeToStdin( gzipProc->readStdout() ); +} + + +void ServerDTP::retrieveFile( const QString fn, const QHostAddress& host, Q_UINT16 port ) +{ + file.setName( fn ); + mode = RetrieveFile; + connectToHost( host.toString(), port ); +} + +void ServerDTP::retrieveFile( const QString fn ) +{ + file.setName( fn ); + mode = RetrieveFile; +} + +void ServerDTP::retrieveGzipFile( const QString &fn ) +{ + qDebug("retrieveGzipFile %s", fn.latin1()); + file.setName( fn ); + mode = RetrieveGzipFile; + + gzipProc->setArguments( "gunzip" ); + connect( gzipProc, SIGNAL( readyReadStdout() ), + SLOT( tarExtractBlock() ) ); + connect( gzipProc, SIGNAL( processExited() ), + SLOT( gunzipDone() ) ); +} + +void ServerDTP::retrieveGzipFile( const QString &fn, const QHostAddress& host, Q_UINT16 port ) +{ + retrieveGzipFile( fn ); + connectToHost( host.toString(), port ); +} + +void ServerDTP::sendByteArray( const QByteArray& array, const QHostAddress& host, Q_UINT16 port ) +{ + buf.setBuffer( array ); + mode = SendBuffer; + connectToHost( host.toString(), port ); +} + +void ServerDTP::sendByteArray( const QByteArray& array ) +{ + buf.setBuffer( array ); + mode = SendBuffer; +} + +void ServerDTP::retrieveByteArray( const QHostAddress& host, Q_UINT16 port ) +{ + buf.setBuffer( QByteArray() ); + mode = RetrieveBuffer; + connectToHost( host.toString(), port ); +} + +void ServerDTP::retrieveByteArray() +{ + buf.setBuffer( QByteArray() ); + mode = RetrieveBuffer; +} + +void ServerDTP::setSocket( int socket ) +{ + QSocket::setSocket( socket ); + connected(); +} + diff --git a/core/launcher/transferserver.h b/core/launcher/transferserver.h new file mode 100644 index 0000000..076e460 --- a/dev/null +++ b/core/launcher/transferserver.h @@ -0,0 +1,168 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 <qserversocket.h> +#include <qsocket.h> +#include <qdir.h> +#include <qfile.h> +#include <qbuffer.h> + +class QFileInfo; +class QProcess; +class TransferServer : public QServerSocket +{ + Q_OBJECT + +public: + TransferServer( Q_UINT16 port, QObject *parent = 0, const char* name = 0 ); + virtual ~TransferServer(); + + void newConnection( int socket ); +}; + + +class ServerDTP : public QSocket +{ + Q_OBJECT + +public: + ServerDTP( QObject *parent = 0, const char* name = 0 ); + ~ServerDTP(); + + enum Mode{ Idle = 0, SendFile, SendGzipFile, SendBuffer, + RetrieveFile, RetrieveGzipFile, RetrieveBuffer }; + + void sendFile( const QString fn ); + void sendFile( const QString fn, const QHostAddress& host, Q_UINT16 port ); + void sendGzipFile( const QString &fn, const QStringList &archiveTargets ); + void sendGzipFile( const QString &fn, const QStringList &archiveTargets, + const QHostAddress& host, Q_UINT16 port ); + void sendByteArray( const QByteArray& array ); + void sendByteArray( const QByteArray& array, const QHostAddress& host, Q_UINT16 port ); + + void retrieveFile( const QString fn ); + void retrieveFile( const QString fn, const QHostAddress& host, Q_UINT16 port ); + void retrieveGzipFile( const QString &fn ); + void retrieveGzipFile( const QString &fn, const QHostAddress& host, Q_UINT16 port ); + void retrieveByteArray(); + void retrieveByteArray( const QHostAddress& host, Q_UINT16 port ); + + Mode dtpMode() { return mode; } + QByteArray buffer() { return buf.buffer(); } + + void setSocket( int socket ); + +signals: + void completed(); + void failed(); + +private slots: + void connectionClosed(); + void connected(); + void bytesWritten( int bytes ); + void readyRead(); + void writeTargzBlock(); + void targzDone(); + + void gzipTarBlock(); + void tarExtractBlock(); + void gunzipDone(); + void extractTarDone(); + +private: + + unsigned long bytes_written; + Mode mode; + QFile file; + QBuffer buf; + QProcess *createTargzProc; + QProcess *retrieveTargzProc; + QProcess *gzipProc; +}; + +class ServerSocket : public QServerSocket +{ + Q_OBJECT + +public: + ServerSocket( Q_UINT16 port, QObject *parent = 0, const char* name = 0 ) + : QServerSocket( port, 1, parent, name ) {} + + void newConnection( int socket ) { emit newIncomming( socket ); } +signals: + void newIncomming( int socket ); +}; + +class ServerPI : public QSocket +{ + Q_OBJECT + + enum State { Connected, Wait_USER, Wait_PASS, Ready, Forbidden }; + enum Transfer { SendFile = 0, RetrieveFile = 1, SendByteArray = 2, RetrieveByteArray = 3 }; + +public: + ServerPI( int socket, QObject *parent = 0, const char* name = 0 ); + virtual ~ServerPI(); + +protected slots: + void read(); + void send( const QString& msg ); + void process( const QString& command ); + void connectionClosed(); + void dtpCompleted(); + void dtpFailed(); + void dtpError( int ); + void newConnection( int socket ); + +protected: + bool checkUser( const QString& user ); + bool checkPassword( const QString& pw ); + bool checkReadFile( const QString& file ); + bool checkWriteFile( const QString& file ); + bool parsePort( const QString& pw ); + bool backupRestoreGzip( const QString &file, QStringList &targets ); + bool backupRestoreGzip( const QString &file ); + + bool sendList( const QString& arg ); + void sendFile( const QString& file ); + void retrieveFile( const QString& file ); + + QString permissionString( QFileInfo *info ); + QString fileListing( QFileInfo *info ); + QString absFilePath( const QString& file ); + + void timerEvent( QTimerEvent *e ); + +private: + State state; + Q_UINT16 peerport; + QHostAddress peeraddress; + bool passiv; + bool wait[4]; + ServerDTP *dtp; + ServerSocket *serversocket; + QString waitfile; + QDir directory; + QByteArray waitarray; + QString renameFrom; + QString lastCommand; + int waitsocket; +}; + +bool accessAuthorized(QHostAddress peeraddress); diff --git a/core/launcher/wait.cpp b/core/launcher/wait.cpp new file mode 100644 index 0000000..059e6f1 --- a/dev/null +++ b/core/launcher/wait.cpp @@ -0,0 +1,64 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 "wait.h" + +#include <qpe/resource.h> + +#include <qwidget.h> +#include <qpixmap.h> +#include <qpainter.h> + + +Wait *lastWaitObject = NULL; + + +Wait::Wait( QWidget *parent ) : QWidget( parent ), + pm( Resource::loadPixmap( "wait" ) ), waiting( FALSE ) +{ + setFixedSize( pm.size() ); + lastWaitObject = this; + hide(); +} + + +Wait *Wait::getWaitObject() +{ + return lastWaitObject; +} + + +void Wait::setWaiting( bool w ) +{ + waiting = w; + if ( w ) + show(); + else + hide(); +} + + +void Wait::paintEvent( QPaintEvent * ) +{ + QPainter p( this ); + p.drawPixmap( 0, 0, pm ); +} + + diff --git a/core/launcher/wait.h b/core/launcher/wait.h new file mode 100644 index 0000000..519b654 --- a/dev/null +++ b/core/launcher/wait.h @@ -0,0 +1,45 @@ +/********************************************************************** +** Copyright (C) 2000 Trolltech AS. All rights reserved. +** +** This file is part of 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 __WAIT_H__ +#define __WAIT_H__ + +#include <qpe/resource.h> + +#include <qwidget.h> +#include <qpixmap.h> +#include <qpainter.h> + + +class Wait : public QWidget +{ +public: + Wait( QWidget *parent ); + void setWaiting( bool w ); + void paintEvent( QPaintEvent * ); + static Wait *getWaitObject(); +private: + QPixmap pm; + bool waiting; +}; + + +#endif // __WAIT_H__ + |