author | zecke <zecke> | 2003-08-27 12:36:48 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-08-27 12:36:48 (UTC) |
commit | 81175f54968c0cd749492d3fe43b7243b71c2d5d (patch) (side-by-side diff) | |
tree | ffb83ef7f705ddda3293de80614d31c559b6457c /core/tools | |
parent | 6a6af694205eb9a55b18eb10f2290a9747019388 (diff) | |
download | opie-81175f54968c0cd749492d3fe43b7243b71c2d5d.zip opie-81175f54968c0cd749492d3fe43b7243b71c2d5d.tar.gz opie-81175f54968c0cd749492d3fe43b7243b71c2d5d.tar.bz2 |
Initial revision
-rw-r--r-- | core/tools/quicklauncher/Makefile | 238 | ||||
-rw-r--r-- | core/tools/quicklauncher/Makefile.in | 106 | ||||
-rw-r--r-- | core/tools/quicklauncher/main.cpp | 241 | ||||
-rw-r--r-- | core/tools/quicklauncher/qpe-quicklauncher.control | 10 | ||||
-rw-r--r-- | core/tools/quicklauncher/quicklauncher.pro | 11 |
5 files changed, 606 insertions, 0 deletions
diff --git a/core/tools/quicklauncher/Makefile b/core/tools/quicklauncher/Makefile new file mode 100644 index 0000000..23b2fd0 --- a/dev/null +++ b/core/tools/quicklauncher/Makefile @@ -0,0 +1,238 @@ +############################################################################# +# Automatically generated from tools/quicklauncher/Makefile.in +# Build options from +############################################################################# + +default: all # package + +CONTROL = tools/quicklauncher/qpe-quicklauncher.control + +# Compiling +INTERFACE_DECL_PATH = . +SYSCONF_CXX = g++ +SYSCONF_CC = gcc +DASHCROSS = + +# Compiling with support libraries +SYSCONF_CXXFLAGS_X11 = +SYSCONF_CXXFLAGS_QT = -I$(QTDIR)/include +SYSCONF_CXXFLAGS_QTOPIA = -I$(QPEDIR)/include +SYSCONF_CFLAGS_QTOPIA = -I$(QPEDIR)/include +SYSCONF_CXXFLAGS_OPENGL = -I/usr/X11R6/include + +# Compiling YACC output +SYSCONF_CXXFLAGS_YACC = -Wno-unused -Wno-parentheses + +# Linking with support libraries +SYSCONF_RPATH_X11 = +SYSCONF_RPATH_QT = -Wl,-rpath,$(QTDIR)/lib +SYSCONF_RPATH_QTOPIA = -Wl,-rpath,$(QPEDIR)/lib +SYSCONF_RPATH_OPENGL = -Wl,-rpath,/usr/X11R6/lib + +# Linking with support libraries +# X11 +SYSCONF_LFLAGS_X11 = +SYSCONF_LIBS_X11 = +# Qt, Qt+OpenGL +SYSCONF_LFLAGS_QT = -L$(QTDIR)/lib +SYSCONF_LFLAGS_QTOPIA = -L$(QPEDIR)/lib +SYSCONF_LIBS_QT = -lqte$(QT_THREAD_SUFFIX) +SYSCONF_LIBS_QT_OPENGL = +SYSCONF_LIBS_QTOPIA = -lqtopia +# OpenGL +SYSCONF_LFLAGS_OPENGL = -L/usr/X11R6/lib +SYSCONF_LIBS_OPENGL = +# Yacc +SYSCONF_LIBS_YACC = + +# Linking applications +SYSCONF_LINK = gcc +SYSCONF_LFLAGS = +SYSCONF_LIBS = + +# Link flags for shared objects +SYSCONF_LFLAGS_SHOBJ = -shared + +# Flags for threading +SYSCONF_CFLAGS_THREAD = -D_REENTRANT +SYSCONF_CXXFLAGS_THREAD = -D_REENTRANT +SYSCONF_LFLAGS_THREAD = +SYSCONF_LIBS_THREAD = -lpthread + +# Meta-object compiler +SYSCONF_MOC = $(QTDIR)/bin/moc + +# UI compiler +SYSCONF_UIC = $(QTDIR)/bin/uic + +# Linking shared libraries +# - Build the $(TARGET) library, eg. lib$(TARGET).so.2.2.2 +# - Place target in $(DESTDIR) - which has a trailing / +# - Usually needs to incorporate $(VER_MAJ), $(VER_MIN) and $(VER_PATCH) +# +SYSCONF_LINK_SHLIB = gcc +SYSCONF_LINK_TARGET_SHARED = lib$(TARGET).so.$(VER_MAJ).$(VER_MIN).$(VER_PATCH) +SYSCONF_LINK_LIB_SHARED = $(SYSCONF_LINK_SHLIB) -shared -Wl,-soname,lib$(TARGET).so.$(VER_MAJ) \ + $(LFLAGS) -o $(SYSCONF_LINK_TARGET_SHARED) \ + $(OBJECTS) $(OBJMOC) $(LIBS) && \ + mv $(SYSCONF_LINK_TARGET_SHARED) $(DESTDIR); \ + cd $(DESTDIR) && \ + rm -f lib$(TARGET).so lib$(TARGET).so.$(VER_MAJ) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN); \ + ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so; \ + ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ); \ + ln -s $(SYSCONF_LINK_TARGET_SHARED) lib$(TARGET).so.$(VER_MAJ).$(VER_MIN) + +# Linking static libraries +# - Build the $(TARGET) library, eg. lib$(TARGET).a +# - Place target in $(DESTDIR) - which has a trailing / +# +SYSCONF_AR = ar cqs +SYSCONF_LINK_TARGET_STATIC = lib$(TARGET).a +SYSCONF_LINK_LIB_STATIC = rm -f $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) ; \ + $(SYSCONF_AR) $(DESTDIR)$(SYSCONF_LINK_TARGET_STATIC) $(OBJECTS) $(OBJMOC) +# Compiling application source +SYSCONF_CXXFLAGS = -pipe -DQWS -fno-exceptions -fno-rtti -O2 -Wall -W -DNO_DEBUG +SYSCONF_CFLAGS = -pipe -O2 -Wall -W +# Default link type (static linking is still be used where required) +SYSCONF_LINK_LIB = $(SYSCONF_LINK_LIB_SHARED) +SYSCONF_LINK_TARGET = $(SYSCONF_LINK_TARGET_SHARED) +# Compiling library source +SYSCONF_CXXFLAGS_LIB = -fPIC +SYSCONF_CFLAGS_LIB = -fPIC +# Compiling shared-object source +SYSCONF_CXXFLAGS_SHOBJ = -fPIC +SYSCONF_CFLAGS_SHOBJ = -fPIC +# Linking Qt +SYSCONF_LIBS_QTLIB = $(SYSCONF_LFLAGS_X11) $(QT_LIBS_MT) $(QT_LIBS_OPT) +# Linking Qt applications +SYSCONF_LIBS_QTAPP = + +# Platform output directories +MOC_DIR = .moc/linux-generic-g++/ +OBJECTS_DIR = .obj/linux-generic-g++/ + +############################################################################# + +####### Compiler, tools and options + +CXX = $(SYSCONF_CXX) $(QT_CXX_MT) +CXXFLAGS= $(SYSCONF_CXXFLAGS_QTOPIA) $(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) -DQTOPIA_APP_INTERFACE +CC = $(SYSCONF_CC) $(QT_C_MT) +CFLAGS = $(SYSCONF_CFLAGS_QTOPIA) $(SYSCONF_CFLAGS) -DQTOPIA_APP_INTERFACE +INCPATH = -I$(MOC_DIR) +LFLAGS = $(SYSCONF_LFLAGS_QTOPIA) $(SYSCONF_RPATH_QTOPIA) $(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) +LIBS = $(SUBLIBS) -lqpepim -lpthread -lqpe $(SYSCONF_LIBS_QTOPIA) $(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 = quicklauncher +TARGET1 = lib$(TARGET).so.$(VER_MAJ) + +####### Files + +HEADERS = +SOURCES = main.cpp +OBJECTS = $(OBJECTS_DIR)/main.o +INTERFACES = +UICDECLS = +UICIMPLS = +SRCMOC = $(MOC_DIR)/main.moc +OBJMOC = + + +####### 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 quicklauncher.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 + +$(OBJECTS_DIR)/main.o: main.cpp \ + $(MOC_DIR)/main.moc + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $(OBJECTS_DIR)/main.o main.cpp + +$(MOC_DIR)/main.moc: main.cpp + $(MOC) main.cpp -o $(MOC_DIR)/main.moc + + + +lupdate-check: + @true + +lupdate: + @true + +lrelease: + @echo "No TRANSLATIONS" + + +ipkg: $(DESTDIR)$(TARGET) # among other things... + CTL="$(CONTROL)"; for ctrl in $$CTL; do cd $(QPEDIR)/ipkg; ../bin/mkipks -platform generic $(QPEDIR)/src/$$ctrl ; done + +package: ipkg + cd $(QPEDIR)/ipkg; ../bin/mkPackages + +Makefile: quicklauncher.pro + cd $(QPEDIR)/src; ./configure -platform generic -make tools/quicklauncher diff --git a/core/tools/quicklauncher/Makefile.in b/core/tools/quicklauncher/Makefile.in new file mode 100644 index 0000000..8c7892a --- a/dev/null +++ b/core/tools/quicklauncher/Makefile.in @@ -0,0 +1,106 @@ +############################################################################# + +####### Compiler, tools and options + +CXX = $(SYSCONF_CXX) $(QT_CXX_MT) +CXXFLAGS= $(SYSCONF_CXXFLAGS_QTOPIA) $(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) -DQTOPIA_APP_INTERFACE +CC = $(SYSCONF_CC) $(QT_C_MT) +CFLAGS = $(SYSCONF_CFLAGS_QTOPIA) $(SYSCONF_CFLAGS) -DQTOPIA_APP_INTERFACE +INCPATH = -I$(MOC_DIR) +LFLAGS = $(SYSCONF_LFLAGS_QTOPIA) $(SYSCONF_RPATH_QTOPIA) $(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) +LIBS = $(SUBLIBS) -lqpepim -lpthread -lqpe $(SYSCONF_LIBS_QTOPIA) $(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 = quicklauncher +TARGET1 = lib$(TARGET).so.$(VER_MAJ) + +####### Files + +HEADERS = +SOURCES = main.cpp +OBJECTS = $(OBJECTS_DIR)/main.o +INTERFACES = +UICDECLS = +UICIMPLS = +SRCMOC = $(MOC_DIR)/main.moc +OBJMOC = + + +####### 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 quicklauncher.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 + +$(OBJECTS_DIR)/main.o: main.cpp \ + $(MOC_DIR)/main.moc + $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $(OBJECTS_DIR)/main.o main.cpp + +$(MOC_DIR)/main.moc: main.cpp + $(MOC) main.cpp -o $(MOC_DIR)/main.moc + + diff --git a/core/tools/quicklauncher/main.cpp b/core/tools/quicklauncher/main.cpp new file mode 100644 index 0000000..e509908 --- a/dev/null +++ b/core/tools/quicklauncher/main.cpp @@ -0,0 +1,241 @@ +/********************************************************************** +** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. +** +** This file is part of the Qtopia Environment. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include <qpainter.h> +#include <qstrlist.h> +#include <qtimer.h> +#include <qguardedptr.h> +#include <qcopchannel_qws.h> +#define QTOPIA_INTERNAL_INITAPP +#include <qtopia/timezone.h> +#include <qtopia/qpeapplication.h> +#include <qtopia/resource.h> +#include <qtopia/pluginloader.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + +static QPEApplication *app = 0; +static PluginLoader *loader = 0; +static ApplicationInterface *appIface = 0; +static QGuardedPtr<QWidget> mainWindow; + +#ifdef _OS_LINUX_ +static char **argv0 = 0; +static int argv_lth; +extern char **environ; +#ifndef SPT_BUFSIZE +#define SPT_BUFSIZE 2048 +#endif +#include <stdarg.h> +void setproctitle (const char *fmt,...) { + int i; + char buf[SPT_BUFSIZE]; + va_list ap; + + if (!argv0) + return; + + va_start(ap, fmt); + (void) vsnprintf(buf, SPT_BUFSIZE, fmt, ap); + va_end(ap); + + i = strlen (buf); + if (i > argv_lth - 2) { + i = argv_lth - 2; + buf[i] = '\0'; + } + memset(argv0[0], '\0', argv_lth); /* clear the memory area */ + (void) strcpy (argv0[0], buf); + + argv0[1] = NULL; +} +#endif + + +class QuickLauncher : public QObject +{ + Q_OBJECT +public: + QuickLauncher() : QObject() + { + QCString ch("QPE/QuickLauncher-"); + ch += QString::number(getpid()); + qlChannel = new QCopChannel( ch, this); + connect( qlChannel, SIGNAL(received(const QCString&, const QByteArray&)), + this, SLOT(message(const QCString&, const QByteArray&)) ); + } + + static void exec( int /*argc*/, char **argv ) + { + QString appName = argv[0]; + int sep = appName.findRev( '/' ); + if ( sep > 0 ) + appName = appName.mid( sep+1 ); + + appIface = 0; + if ( loader->queryInterface(appName, IID_QtopiaApplication, (QUnknownInterface**)&appIface) == QS_OK ) { + mainWindow = appIface->createMainWindow( appName ); + } + if ( mainWindow ) { + if ( mainWindow->metaObject()->slotNames().contains("setDocument(const QString&)") ) { + app->showMainDocumentWidget( mainWindow ); + } else { + app->showMainWidget( mainWindow ); + } + } else { + qWarning( "Could not create application main window" ); + exit(-1); + } + } + +private slots: + void message(const QCString &msg, const QByteArray & data) + { + QStrList argList; + + if ( msg == "execute(QStrList)" ) { + delete qlChannel; + QDataStream stream( data, IO_ReadOnly ); + QStrList argList; + stream >> argList; + qDebug( "QuickLauncher execute: %s", argList.at(0) ); + doQuickLaunch( argList ); + delete this; + } else if ( msg == "execute(QString)" ) { + delete qlChannel; + QDataStream stream( data, IO_ReadOnly ); + QString arg; + stream >> arg; + qDebug( "QuickLauncher execute: %s", arg.latin1() ); + QStrList argList; + argList.append( arg.utf8() ); + doQuickLaunch( argList ); + delete this; + } + } + +private: + void doQuickLaunch( QStrList &argList ) + { + static int myargc = argList.count(); + static char **myargv = new char *[myargc + 1]; + for ( int j = 0; j < myargc; j++ ) { + myargv[j] = new char [strlen(argList.at(j))+1]; + strcpy( myargv[j], argList.at(j) ); + } + myargv[myargc] = NULL; +#ifdef _OS_LINUX_ + // Change name of process + setproctitle(myargv[0]); +#endif + + connect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); + app->exit_loop(); + app->initApp( myargc, myargv ); + exec( myargc, myargv ); + } + +private: + QCopChannel *qlChannel; +}; + +int main( int argc, char** argv ) +{ + app = new QPEApplication( argc, argv ); + + loader = new PluginLoader( "application" ); + + unsetenv( "LD_BIND_NOW" ); + + QCString arg0 = argv[0]; + int sep = arg0.findRev( '/' ); + if ( sep > 0 ) + arg0 = arg0.mid( sep+1 ); + if ( arg0 != "quicklauncher" ) { + qDebug( "QuickLauncher invoked as: %s", arg0.data() ); + QuickLauncher::exec( argc, argv ); + } else { +#ifdef _OS_LINUX_ + // Setup to change proc title + int i; + char **envp = environ; + /* Move the environment so we can reuse the memory. + * (Code borrowed from sendmail.) */ + for (i = 0; envp[i] != NULL; i++) + continue; + environ = (char **) malloc(sizeof(char *) * (i + 1)); + if (environ == NULL) + return -1; + for (i = 0; envp[i] != NULL; i++) + if ((environ[i] = strdup(envp[i])) == NULL) + return -1; + environ[i] = NULL; + + argv0 = argv; + if (i > 0) + argv_lth = envp[i-1] + strlen(envp[i-1]) - argv0[0]; + else + argv_lth = argv0[argc-1] + strlen(argv0[argc-1]) - argv0[0]; +#endif + (void)new QuickLauncher(); + qDebug( "QuickLauncher running" ); + // Pre-load default fonts + QFontMetrics fm( QApplication::font() ); + fm.ascent(); // causes font load. + QFont f( QApplication::font() ); + f.setWeight( QFont::Bold ); + QFontMetrics fmb( f ); + fmb.ascent(); // causes font load. + + // Each of the following force internal structures/internal + // initialization to be performed. This may mean allocating + // memory that is not needed by all applications. + TimeZone::current().isValid(); // popuplate timezone cache + TimeString::currentDateFormat(); // create internal structures + TimeString::currentAMPM(); + Resource::loadIconSet("new"); // do internal init + + // Create a widget to force initialization of title bar images, etc. + QObject::disconnect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); + QWidget *w = new QWidget(0,0,Qt::WDestructiveClose|Qt::WStyle_ContextHelp|Qt::WStyle_Tool); + w->setGeometry( -100, -100, 10, 10 ); + w->show(); + QTimer::singleShot( 0, w, SLOT(close()) ); + + app->enter_loop(); + } + + int rv = app->exec(); + + if ( mainWindow ) + delete (QWidget*)mainWindow; + if ( appIface ) + loader->releaseInterface( appIface ); + delete loader; + + delete app; + + return rv; +} + +#include "main.moc" diff --git a/core/tools/quicklauncher/qpe-quicklauncher.control b/core/tools/quicklauncher/qpe-quicklauncher.control new file mode 100644 index 0000000..f07a7d5 --- a/dev/null +++ b/core/tools/quicklauncher/qpe-quicklauncher.control @@ -0,0 +1,10 @@ +Files: bin/quicklauncher +Priority: required +Section: qpe/system +Maintainer: Trolltech (www.trolltech.com) +Architecture: $CPU_ARCH +Arch: $DEVICE_ARCH +Version: $QPE_VERSION-12 +Depends: qpe-libqtopia qpe-pim +Description: Quick launcher stub + Launcher stub for quick launch enabled applications. diff --git a/core/tools/quicklauncher/quicklauncher.pro b/core/tools/quicklauncher/quicklauncher.pro new file mode 100644 index 0000000..52e2106 --- a/dev/null +++ b/core/tools/quicklauncher/quicklauncher.pro @@ -0,0 +1,11 @@ +TEMPLATE = app +CONFIG += qtopia warn_on release +DESTDIR = $(QPEDIR)/bin + +HEADERS = +SOURCES = main.cpp +INTERFACES = + +unix:LIBS += -lqpepim -lpthread + +TARGET = quicklauncher |