Diffstat (limited to 'core/tools/quicklauncher/main.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/tools/quicklauncher/main.cpp | 19 |
1 files changed, 13 insertions, 6 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 | |||
@@ -9,44 +9,51 @@ | |||
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "dropins.h" | ||
22 | |||
23 | /* OPIE */ | ||
24 | #include <opie2/odebug.h> | ||
25 | |||
26 | /* QT */ | ||
21 | #include <qpainter.h> | 27 | #include <qpainter.h> |
22 | #include <qstrlist.h> | 28 | #include <qstrlist.h> |
23 | #include <qtimer.h> | 29 | #include <qtimer.h> |
24 | #include <qguardedptr.h> | 30 | #include <qguardedptr.h> |
25 | #include <qcopchannel_qws.h> | 31 | #include <qcopchannel_qws.h> |
26 | #define QTOPIA_INTERNAL_INITAPP | 32 | #define QTOPIA_INTERNAL_INITAPP |
27 | 33 | ||
28 | #ifdef private | 34 | #ifdef private |
29 | # undef private | 35 | # undef private |
30 | #endif | 36 | #endif |
31 | #define private public | 37 | #define private public |
32 | #include <qtopia/qpeapplication.h> | 38 | #include <qtopia/qpeapplication.h> |
33 | #undef private | 39 | #undef private |
40 | |||
41 | /* STD */ | ||
34 | #include <stdio.h> | 42 | #include <stdio.h> |
35 | #include <stdlib.h> | 43 | #include <stdlib.h> |
36 | #include <sys/types.h> | 44 | #include <sys/types.h> |
37 | #include <sys/stat.h> | 45 | #include <sys/stat.h> |
38 | #include <unistd.h> | 46 | #include <unistd.h> |
39 | 47 | ||
40 | #include "dropins.h" | ||
41 | 48 | ||
42 | using QuickPrivate::PluginLoader; | 49 | using QuickPrivate::PluginLoader; |
43 | 50 | ||
44 | static QPEApplication *app = 0; | 51 | static QPEApplication *app = 0; |
45 | static PluginLoader *loader = 0; | 52 | static PluginLoader *loader = 0; |
46 | static ApplicationInterface *appIface = 0; | 53 | static ApplicationInterface *appIface = 0; |
47 | static QGuardedPtr<QWidget> mainWindow; | 54 | static QGuardedPtr<QWidget> mainWindow; |
48 | 55 | ||
49 | #ifdef _OS_LINUX_ | 56 | #ifdef _OS_LINUX_ |
50 | static char **argv0 = 0; | 57 | static char **argv0 = 0; |
51 | static int argv_lth; | 58 | static int argv_lth; |
52 | extern char **environ; | 59 | extern char **environ; |
@@ -102,48 +109,48 @@ public: | |||
102 | 109 | ||
103 | appIface = 0; | 110 | appIface = 0; |
104 | if ( loader->queryInterface(appName, IID_QtopiaApplication, (QUnknownInterface**)&appIface) == QS_OK ) { | 111 | if ( loader->queryInterface(appName, IID_QtopiaApplication, (QUnknownInterface**)&appIface) == QS_OK ) { |
105 | mainWindow = appIface->createMainWindow( appName ); | 112 | mainWindow = appIface->createMainWindow( appName ); |
106 | } | 113 | } |
107 | if ( mainWindow ) { | 114 | if ( mainWindow ) { |
108 | if ( mainWindow->metaObject()->slotNames().contains("setDocument(const QString&)") ) { | 115 | if ( mainWindow->metaObject()->slotNames().contains("setDocument(const QString&)") ) { |
109 | app->showMainDocumentWidget( mainWindow ); | 116 | app->showMainDocumentWidget( mainWindow ); |
110 | } else { | 117 | } else { |
111 | app->showMainWidget( mainWindow ); | 118 | app->showMainWidget( mainWindow ); |
112 | } | 119 | } |
113 | } else { | 120 | } else { |
114 | qWarning( "Could not create application main window" ); | 121 | owarn << "Could not create application main window" << oendl; |
115 | exit(-1); | 122 | exit(-1); |
116 | } | 123 | } |
117 | } | 124 | } |
118 | 125 | ||
119 | private slots: | 126 | private slots: |
120 | void message(const QCString &msg, const QByteArray & data) | 127 | void message(const QCString &msg, const QByteArray & data) |
121 | { | 128 | { |
122 | QStrList argList; | 129 | QStrList argList; |
123 | 130 | ||
124 | if ( msg == "execute(QStrList)" ) { | 131 | if ( msg == "execute(QStrList)" ) { |
125 | delete qlChannel; | 132 | delete qlChannel; |
126 | QDataStream stream( data, IO_ReadOnly ); | 133 | QDataStream stream( data, IO_ReadOnly ); |
127 | QStrList argList; | 134 | QStrList argList; |
128 | stream >> argList; | 135 | stream >> argList; |
129 | qDebug( "QuickLauncher execute: %s", argList.at(0) ); | 136 | odebug << "QuickLauncher execute: " << argList.at(0) << "" << oendl; |
130 | doQuickLaunch( argList ); | 137 | doQuickLaunch( argList ); |
131 | delete this; | 138 | delete this; |
132 | } else if ( msg == "execute(QString)" ) { | 139 | } else if ( msg == "execute(QString)" ) { |
133 | delete qlChannel; | 140 | delete qlChannel; |
134 | QDataStream stream( data, IO_ReadOnly ); | 141 | QDataStream stream( data, IO_ReadOnly ); |
135 | QString arg; | 142 | QString arg; |
136 | stream >> arg; | 143 | stream >> arg; |
137 | qDebug( "QuickLauncher execute: %s", arg.latin1() ); | 144 | odebug << "QuickLauncher execute: " << arg << "" << oendl; |
138 | QStrList argList; | 145 | QStrList argList; |
139 | argList.append( arg.utf8() ); | 146 | argList.append( arg.utf8() ); |
140 | doQuickLaunch( argList ); | 147 | doQuickLaunch( argList ); |
141 | delete this; | 148 | delete this; |
142 | } | 149 | } |
143 | } | 150 | } |
144 | 151 | ||
145 | private: | 152 | private: |
146 | void doQuickLaunch( QStrList &argList ) | 153 | void doQuickLaunch( QStrList &argList ) |
147 | { | 154 | { |
148 | static int myargc = argList.count(); | 155 | static int myargc = argList.count(); |
149 | static char **myargv = new char *[myargc + 1]; | 156 | static char **myargv = new char *[myargc + 1]; |
@@ -171,25 +178,25 @@ int main( int argc, char** argv ) | |||
171 | { | 178 | { |
172 | app = new QPEApplication( argc, argv ); | 179 | app = new QPEApplication( argc, argv ); |
173 | 180 | ||
174 | loader = new PluginLoader( "application" ); | 181 | loader = new PluginLoader( "application" ); |
175 | 182 | ||
176 | unsetenv( "LD_BIND_NOW" ); | 183 | unsetenv( "LD_BIND_NOW" ); |
177 | 184 | ||
178 | QCString arg0 = argv[0]; | 185 | QCString arg0 = argv[0]; |
179 | int sep = arg0.findRev( '/' ); | 186 | int sep = arg0.findRev( '/' ); |
180 | if ( sep > 0 ) | 187 | if ( sep > 0 ) |
181 | arg0 = arg0.mid( sep+1 ); | 188 | arg0 = arg0.mid( sep+1 ); |
182 | if ( arg0 != "quicklauncher" ) { | 189 | if ( arg0 != "quicklauncher" ) { |
183 | qDebug( "QuickLauncher invoked as: %s", arg0.data() ); | 190 | odebug << "QuickLauncher invoked as: " << arg0.data() << "" << oendl; |
184 | QuickLauncher::exec( argc, argv ); | 191 | QuickLauncher::exec( argc, argv ); |
185 | } else { | 192 | } else { |
186 | #ifdef _OS_LINUX_ | 193 | #ifdef _OS_LINUX_ |
187 | // Setup to change proc title | 194 | // Setup to change proc title |
188 | int i; | 195 | int i; |
189 | char **envp = environ; | 196 | char **envp = environ; |
190 | /* Move the environment so we can reuse the memory. | 197 | /* Move the environment so we can reuse the memory. |
191 | * (Code borrowed from sendmail.) */ | 198 | * (Code borrowed from sendmail.) */ |
192 | for (i = 0; envp[i] != NULL; i++) | 199 | for (i = 0; envp[i] != NULL; i++) |
193 | continue; | 200 | continue; |
194 | environ = (char **) malloc(sizeof(char *) * (i + 1)); | 201 | environ = (char **) malloc(sizeof(char *) * (i + 1)); |
195 | if (environ == NULL) | 202 | if (environ == NULL) |
@@ -197,25 +204,25 @@ int main( int argc, char** argv ) | |||
197 | for (i = 0; envp[i] != NULL; i++) | 204 | for (i = 0; envp[i] != NULL; i++) |
198 | if ((environ[i] = strdup(envp[i])) == NULL) | 205 | if ((environ[i] = strdup(envp[i])) == NULL) |
199 | return -1; | 206 | return -1; |
200 | environ[i] = NULL; | 207 | environ[i] = NULL; |
201 | 208 | ||
202 | argv0 = argv; | 209 | argv0 = argv; |
203 | if (i > 0) | 210 | if (i > 0) |
204 | argv_lth = envp[i-1] + strlen(envp[i-1]) - argv0[0]; | 211 | argv_lth = envp[i-1] + strlen(envp[i-1]) - argv0[0]; |
205 | else | 212 | else |
206 | argv_lth = argv0[argc-1] + strlen(argv0[argc-1]) - argv0[0]; | 213 | argv_lth = argv0[argc-1] + strlen(argv0[argc-1]) - argv0[0]; |
207 | #endif | 214 | #endif |
208 | (void)new QuickLauncher(); | 215 | (void)new QuickLauncher(); |
209 | qDebug( "QuickLauncher running" ); | 216 | odebug << "QuickLauncher running" << oendl; |
210 | // Pre-load default fonts | 217 | // Pre-load default fonts |
211 | QFontMetrics fm( QApplication::font() ); | 218 | QFontMetrics fm( QApplication::font() ); |
212 | fm.ascent(); // causes font load. | 219 | fm.ascent(); // causes font load. |
213 | QFont f( QApplication::font() ); | 220 | QFont f( QApplication::font() ); |
214 | f.setWeight( QFont::Bold ); | 221 | f.setWeight( QFont::Bold ); |
215 | QFontMetrics fmb( f ); | 222 | QFontMetrics fmb( f ); |
216 | fmb.ascent(); // causes font load. | 223 | fmb.ascent(); // causes font load. |
217 | 224 | ||
218 | // Each of the following force internal structures/internal | 225 | // Each of the following force internal structures/internal |
219 | // initialization to be performed. This may mean allocating | 226 | // initialization to be performed. This may mean allocating |
220 | // memory that is not needed by all applications. | 227 | // memory that is not needed by all applications. |
221 | #if 0 | 228 | #if 0 |