summaryrefslogtreecommitdiff
path: root/core/tools/quicklauncher/main.cpp
Unidiff
Diffstat (limited to 'core/tools/quicklauncher/main.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/tools/quicklauncher/main.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/core/tools/quicklauncher/main.cpp b/core/tools/quicklauncher/main.cpp
index fbed5a1..59dd17e 100644
--- a/core/tools/quicklauncher/main.cpp
+++ b/core/tools/quicklauncher/main.cpp
@@ -72,98 +72,97 @@ extern char **environ;
72#include <stdarg.h> 72#include <stdarg.h>
73void setproctitle (const char *fmt,...) { 73void setproctitle (const char *fmt,...) {
74 int i; 74 int i;
75 char buf[SPT_BUFSIZE]; 75 char buf[SPT_BUFSIZE];
76 va_list ap; 76 va_list ap;
77 77
78 if (!argv0) 78 if (!argv0)
79 return; 79 return;
80 80
81 va_start(ap, fmt); 81 va_start(ap, fmt);
82 (void) vsnprintf(buf, SPT_BUFSIZE, fmt, ap); 82 (void) vsnprintf(buf, SPT_BUFSIZE, fmt, ap);
83 va_end(ap); 83 va_end(ap);
84 84
85 i = strlen (buf); 85 i = strlen (buf);
86 if (i > argv_lth - 2) { 86 if (i > argv_lth - 2) {
87 i = argv_lth - 2; 87 i = argv_lth - 2;
88 buf[i] = '\0'; 88 buf[i] = '\0';
89 } 89 }
90 90
91 memset(argv0[0], '\0', argv_lth); /* clear the memory area */ 91 memset(argv0[0], '\0', argv_lth); /* clear the memory area */
92 (void) strcpy (argv0[0], buf); 92 (void) strcpy (argv0[0], buf);
93 93
94 argv0[1] = NULL; 94 argv0[1] = NULL;
95} 95}
96#endif 96#endif
97 97
98 98
99class QuickLauncher : public QObject 99class QuickLauncher : public QObject
100{ 100{
101 Q_OBJECT 101 Q_OBJECT
102public: 102public:
103 QuickLauncher() : QObject() 103 QuickLauncher() : QObject()
104 { 104 {
105 QCString ch("QPE/QuickLauncher-"); 105 QCString ch("QPE/QuickLauncher-");
106 ch += QString::number(getpid()); 106 ch += QString::number(getpid());
107 qlChannel = new QCopChannel( ch, this); 107 qlChannel = new QCopChannel( ch, this);
108 connect( qlChannel, SIGNAL(received(const QCString&,const QByteArray&)), 108 connect( qlChannel, SIGNAL(received(const QCString&,const QByteArray&)),
109 this, SLOT(message(const QCString&,const QByteArray&)) ); 109 this, SLOT(message(const QCString&,const QByteArray&)) );
110 } 110 }
111 111
112 static void exec( int /*argc*/, char **argv ) 112 static void exec( int /*argc*/, char **argv )
113 { 113 {
114 QString appName = argv[0]; 114 QString appName = argv[0];
115 int sep = appName.findRev( '/' ); 115 int sep = appName.findRev( '/' );
116 if ( sep > 0 ) 116 if ( sep > 0 )
117 appName = appName.mid( sep+1 ); 117 appName = appName.mid( sep+1 );
118 118
119 appIface = 0; 119 appIface = 0;
120 if ( loader->queryInterface(appName, IID_QtopiaApplication, (QUnknownInterface**)&appIface) != QS_OK ) { 120 if ( ! ( loader->queryInterface(appName, IID_QtopiaApplication, (QUnknownInterface**)&appIface) == QS_OK ) ) {
121 owarn << "Plugin does not support QuickLauncher interface" << oendl;
122 exit(-1); 121 exit(-1);
123 } 122 }
124 123
125 mainWindow = appIface->createMainWindow( appName ); 124 mainWindow = appIface->createMainWindow( appName );
126 125
127 if ( mainWindow ) { 126 if ( mainWindow ) {
128 if ( mainWindow->metaObject()->slotNames().contains("setDocument(const QString&)") ) { 127 if ( mainWindow->metaObject()->slotNames().contains("setDocument(const QString&)") ) {
129 app->showMainDocumentWidget( mainWindow ); 128 app->showMainDocumentWidget( mainWindow );
130 } else { 129 } else {
131 app->showMainWidget( mainWindow ); 130 app->showMainWidget( mainWindow );
132 } 131 }
133 } else { 132 } else {
134 owarn << "Could not create application main window" << oendl; 133 owarn << "Could not create application main window" << oendl;
135 exit(-1); 134 exit(-1);
136 } 135 }
137 } 136 }
138 137
139private slots: 138private slots:
140 void message(const QCString &msg, const QByteArray & data) 139 void message(const QCString &msg, const QByteArray & data)
141 { 140 {
142 QStrList argList; 141 QStrList argList;
143 142
144 if ( msg == "execute(QStrList)" ) { 143 if ( msg == "execute(QStrList)" ) {
145 delete qlChannel; 144 delete qlChannel;
146 QDataStream stream( data, IO_ReadOnly ); 145 QDataStream stream( data, IO_ReadOnly );
147 QStrList argList; 146 QStrList argList;
148 stream >> argList; 147 stream >> argList;
149 odebug << "QuickLauncher execute: " << argList.at(0) << oendl; 148 odebug << "QuickLauncher execute: " << argList.at(0) << oendl;
150 doQuickLaunch( argList ); 149 doQuickLaunch( argList );
151 delete this; 150 delete this;
152 } else if ( msg == "execute(QString)" ) { 151 } else if ( msg == "execute(QString)" ) {
153 delete qlChannel; 152 delete qlChannel;
154 QDataStream stream( data, IO_ReadOnly ); 153 QDataStream stream( data, IO_ReadOnly );
155 QString arg; 154 QString arg;
156 stream >> arg; 155 stream >> arg;
157 odebug << "QuickLauncher execute: " << arg << oendl; 156 odebug << "QuickLauncher execute: " << arg << oendl;
158 QStrList argList; 157 QStrList argList;
159 argList.append( arg.utf8() ); 158 argList.append( arg.utf8() );
160 doQuickLaunch( argList ); 159 doQuickLaunch( argList );
161 delete this; 160 delete this;
162 } 161 }
163 } 162 }
164 163
165private: 164private:
166 void doQuickLaunch( QStrList &argList ) 165 void doQuickLaunch( QStrList &argList )
167 { 166 {
168 static int myargc = argList.count(); 167 static int myargc = argList.count();
169 static char **myargv = new char *[myargc + 1]; 168 static char **myargv = new char *[myargc + 1];