author | wimpie <wimpie> | 2005-01-08 03:06:55 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-08 03:06:55 (UTC) |
commit | b1b5db12d357898311d67089c94e07f03f2bcf86 (patch) (side-by-side diff) | |
tree | 0e854083cf30eb23c720ffed2435c7f0e5bcaaad | |
parent | 51413c5e05da7a0b233e2456d2e3f111ea20fbf6 (diff) | |
download | opie-b1b5db12d357898311d67089c94e07f03f2bcf86.zip opie-b1b5db12d357898311d67089c94e07f03f2bcf86.tar.gz opie-b1b5db12d357898311d67089c94e07f03f2bcf86.tar.bz2 |
Added error message to make difference between plug loading error
or plugin initialization error
-rw-r--r-- | core/tools/quicklauncher/main.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/core/tools/quicklauncher/main.cpp b/core/tools/quicklauncher/main.cpp index 5f0d80b..fbed5a1 100644 --- a/core/tools/quicklauncher/main.cpp +++ b/core/tools/quicklauncher/main.cpp @@ -56,132 +56,135 @@ using QuickPrivate::PluginLoader; 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 ( loader->queryInterface(appName, IID_QtopiaApplication, (QUnknownInterface**)&appIface) != QS_OK ) { + owarn << "Plugin does not support QuickLauncher interface" << oendl; + exit(-1); } + mainWindow = appIface->createMainWindow( appName ); + if ( mainWindow ) { if ( mainWindow->metaObject()->slotNames().contains("setDocument(const QString&)") ) { app->showMainDocumentWidget( mainWindow ); } else { app->showMainWidget( mainWindow ); } } else { owarn << "Could not create application main window" << oendl; 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; odebug << "QuickLauncher execute: " << argList.at(0) << oendl; doQuickLaunch( argList ); delete this; } else if ( msg == "execute(QString)" ) { delete qlChannel; QDataStream stream( data, IO_ReadOnly ); QString arg; stream >> arg; odebug << "QuickLauncher execute: " << arg << oendl; 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]); prctl( PR_SET_NAME, (unsigned long)myargv[0], 0, 0, 0 ); #endif connect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); app->exit_loop(); app->initApp( myargc, myargv ); exec( myargc, myargv ); } private: QCopChannel *qlChannel; |