author | ar <ar> | 2004-05-02 17:31:50 (UTC) |
---|---|---|
committer | ar <ar> | 2004-05-02 17:31:50 (UTC) |
commit | a210b9a597ba0c929d95c38ffbaf972916c7b8a7 (patch) (side-by-side diff) | |
tree | ce121d5017eb054222c86e0afb6057a28ea7bf8a /core/tools | |
parent | 18759e9156c96795831120408a9da0d3b4ec71a4 (diff) | |
download | opie-a210b9a597ba0c929d95c38ffbaf972916c7b8a7.zip opie-a210b9a597ba0c929d95c38ffbaf972916c7b8a7.tar.gz opie-a210b9a597ba0c929d95c38ffbaf972916c7b8a7.tar.bz2 |
- convert qDebug to odebug
-rw-r--r-- | core/tools/quicklauncher/main.cpp | 231 |
1 files changed, 119 insertions, 112 deletions
diff --git a/core/tools/quicklauncher/main.cpp b/core/tools/quicklauncher/main.cpp index d467d6e..c2467fb 100644 --- a/core/tools/quicklauncher/main.cpp +++ b/core/tools/quicklauncher/main.cpp @@ -18,6 +18,12 @@ ** **********************************************************************/ +#include "dropins.h" + +/* OPIE */ +#include <opie2/odebug.h> + +/* QT */ #include <qpainter.h> #include <qstrlist.h> #include <qtimer.h> @@ -31,13 +37,14 @@ #define private public #include <qtopia/qpeapplication.h> #undef private + +/* STD */ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> -#include "dropins.h" using QuickPrivate::PluginLoader; @@ -61,7 +68,7 @@ void setproctitle (const char *fmt,...) { va_list ap; if (!argv0) - return; + return; va_start(ap, fmt); (void) vsnprintf(buf, SPT_BUFSIZE, fmt, ap); @@ -69,8 +76,8 @@ void setproctitle (const char *fmt,...) { i = strlen (buf); if (i > argv_lth - 2) { - i = argv_lth - 2; - buf[i] = '\0'; + i = argv_lth - 2; + buf[i] = '\0'; } memset(argv0[0], '\0', argv_lth); /* clear the memory area */ (void) strcpy (argv0[0], buf); @@ -86,81 +93,81 @@ class QuickLauncher : public QObject 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&)) ); + 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); - } + 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 { + 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; - 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; - } + 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; + 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]); + // 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 ); + connect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); + app->exit_loop(); + app->initApp( myargc, myargv ); + exec( myargc, myargv ); } private: @@ -178,76 +185,76 @@ int main( int argc, char** argv ) QCString arg0 = argv[0]; int sep = arg0.findRev( '/' ); if ( sep > 0 ) - arg0 = arg0.mid( sep+1 ); + arg0 = arg0.mid( sep+1 ); if ( arg0 != "quicklauncher" ) { - qDebug( "QuickLauncher invoked as: %s", arg0.data() ); - QuickLauncher::exec( argc, argv ); + odebug << "QuickLauncher invoked as: " << arg0.data() << "" << oendl; + 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]; + // 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. + (void)new QuickLauncher(); + odebug << "QuickLauncher running" << oendl; + // 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. #if 0 - TimeZone::current().isValid(); // popuplate timezone cache - TimeString::currentDateFormat(); // create internal structures - TimeString::currentAMPM(); + TimeZone::current().isValid(); // popuplate timezone cache + TimeString::currentDateFormat(); // create internal structures + TimeString::currentAMPM(); #endif - Resource::loadIconSet("new"); // do internal init + Resource::loadIconSet("new"); // do internal init /* make sure libopie gets lined in */ { Opie::Ui::OWait item; } - // 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()) ); + // 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(); + app->enter_loop(); } int rv = app->exec(); if ( mainWindow ) - delete (QWidget*)mainWindow; - + delete (QWidget*)mainWindow; + delete app; if ( appIface ) - loader->releaseInterface( appIface ); + loader->releaseInterface( appIface ); delete loader; // Neither QLibrary nor my Dropin is a QObject and they don't depend // on a qApp so we destroy QWidget::destroyMapper() without |