author | mickeyl <mickeyl> | 2003-11-06 09:50:40 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-11-06 09:50:40 (UTC) |
commit | 2f974fea9a432e9dd7b7a8ad235a4e6bc2ef51fe (patch) (unidiff) | |
tree | ab2089d9282c53146cd0e03b96345a34d74d156e | |
parent | 26ae86ca1e42b61bd0f0031b437ed90a640aa82b (diff) | |
download | opie-2f974fea9a432e9dd7b7a8ad235a4e6bc2ef51fe.zip opie-2f974fea9a432e9dd7b7a8ad235a4e6bc2ef51fe.tar.gz opie-2f974fea9a432e9dd7b7a8ad235a4e6bc2ef51fe.tar.bz2 |
merge core/tools/*
-rw-r--r-- | core/tools/quicklauncher/config.in | 4 | ||||
-rw-r--r-- | core/tools/quicklauncher/main.cpp | 22 | ||||
-rw-r--r-- | core/tools/quicklauncher/opie-quicklauncher.control | 10 |
3 files changed, 34 insertions, 2 deletions
diff --git a/core/tools/quicklauncher/config.in b/core/tools/quicklauncher/config.in new file mode 100644 index 0000000..c105e94 --- a/dev/null +++ b/core/tools/quicklauncher/config.in | |||
@@ -0,0 +1,4 @@ | |||
1 | config QUICKLAUNCHER | ||
2 | boolean "The Quick Launcher Loader" | ||
3 | default "y" | ||
4 | depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE | ||
diff --git a/core/tools/quicklauncher/main.cpp b/core/tools/quicklauncher/main.cpp index 7d368ab..cc411fd 100644 --- a/core/tools/quicklauncher/main.cpp +++ b/core/tools/quicklauncher/main.cpp | |||
@@ -1,123 +1,129 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
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 <qpainter.h> | 21 | #include <qpainter.h> |
22 | #include <qstrlist.h> | 22 | #include <qstrlist.h> |
23 | #include <qtimer.h> | 23 | #include <qtimer.h> |
24 | #include <qguardedptr.h> | 24 | #include <qguardedptr.h> |
25 | #include <qcopchannel_qws.h> | 25 | #include <qcopchannel_qws.h> |
26 | #define QTOPIA_INTERNAL_INITAPP | 26 | #define QTOPIA_INTERNAL_INITAPP |
27 | |||
28 | #ifdef private | ||
29 | # undef private | ||
30 | #endif | ||
31 | #define private public | ||
27 | #include <qtopia/qpeapplication.h> | 32 | #include <qtopia/qpeapplication.h> |
33 | #undef private | ||
28 | #include <stdio.h> | 34 | #include <stdio.h> |
29 | #include <stdlib.h> | 35 | #include <stdlib.h> |
30 | #include <sys/types.h> | 36 | #include <sys/types.h> |
31 | #include <sys/stat.h> | 37 | #include <sys/stat.h> |
32 | #include <unistd.h> | 38 | #include <unistd.h> |
33 | 39 | ||
34 | #include "dropins.h" | 40 | #include "dropins.h" |
35 | 41 | ||
36 | static QPEApplication *app = 0; | 42 | static QPEApplication *app = 0; |
37 | static PluginLoader *loader = 0; | 43 | static PluginLoader *loader = 0; |
38 | static ApplicationInterface *appIface = 0; | 44 | static ApplicationInterface *appIface = 0; |
39 | static QGuardedPtr<QWidget> mainWindow; | 45 | static QGuardedPtr<QWidget> mainWindow; |
40 | 46 | ||
41 | #ifdef _OS_LINUX_ | 47 | #ifdef _OS_LINUX_ |
42 | static char **argv0 = 0; | 48 | static char **argv0 = 0; |
43 | static int argv_lth; | 49 | static int argv_lth; |
44 | extern char **environ; | 50 | extern char **environ; |
45 | #ifndef SPT_BUFSIZE | 51 | #ifndef SPT_BUFSIZE |
46 | #define SPT_BUFSIZE 2048 | 52 | #define SPT_BUFSIZE 2048 |
47 | #endif | 53 | #endif |
48 | #include <stdarg.h> | 54 | #include <stdarg.h> |
49 | void setproctitle (const char *fmt,...) { | 55 | void setproctitle (const char *fmt,...) { |
50 | int i; | 56 | int i; |
51 | char buf[SPT_BUFSIZE]; | 57 | char buf[SPT_BUFSIZE]; |
52 | va_list ap; | 58 | va_list ap; |
53 | 59 | ||
54 | if (!argv0) | 60 | if (!argv0) |
55 | return; | 61 | return; |
56 | 62 | ||
57 | va_start(ap, fmt); | 63 | va_start(ap, fmt); |
58 | (void) vsnprintf(buf, SPT_BUFSIZE, fmt, ap); | 64 | (void) vsnprintf(buf, SPT_BUFSIZE, fmt, ap); |
59 | va_end(ap); | 65 | va_end(ap); |
60 | 66 | ||
61 | i = strlen (buf); | 67 | i = strlen (buf); |
62 | if (i > argv_lth - 2) { | 68 | if (i > argv_lth - 2) { |
63 | i = argv_lth - 2; | 69 | i = argv_lth - 2; |
64 | buf[i] = '\0'; | 70 | buf[i] = '\0'; |
65 | } | 71 | } |
66 | memset(argv0[0], '\0', argv_lth); /* clear the memory area */ | 72 | memset(argv0[0], '\0', argv_lth); /* clear the memory area */ |
67 | (void) strcpy (argv0[0], buf); | 73 | (void) strcpy (argv0[0], buf); |
68 | 74 | ||
69 | argv0[1] = NULL; | 75 | argv0[1] = NULL; |
70 | } | 76 | } |
71 | #endif | 77 | #endif |
72 | 78 | ||
73 | 79 | ||
74 | class QuickLauncher : public QObject | 80 | class QuickLauncher : public QObject |
75 | { | 81 | { |
76 | Q_OBJECT | 82 | Q_OBJECT |
77 | public: | 83 | public: |
78 | QuickLauncher() : QObject() | 84 | QuickLauncher() : QObject() |
79 | { | 85 | { |
80 | QCString ch("QPE/QuickLauncher-"); | 86 | QCString ch("QPE/QuickLauncher-"); |
81 | ch += QString::number(getpid()); | 87 | ch += QString::number(getpid()); |
82 | qlChannel = new QCopChannel( ch, this); | 88 | qlChannel = new QCopChannel( ch, this); |
83 | connect( qlChannel, SIGNAL(received(const QCString&, const QByteArray&)), | 89 | connect( qlChannel, SIGNAL(received(const QCString&, const QByteArray&)), |
84 | this, SLOT(message(const QCString&, const QByteArray&)) ); | 90 | this, SLOT(message(const QCString&, const QByteArray&)) ); |
85 | } | 91 | } |
86 | 92 | ||
87 | static void exec( int /*argc*/, char **argv ) | 93 | static void exec( int /*argc*/, char **argv ) |
88 | { | 94 | { |
89 | QString appName = argv[0]; | 95 | QString appName = argv[0]; |
90 | int sep = appName.findRev( '/' ); | 96 | int sep = appName.findRev( '/' ); |
91 | if ( sep > 0 ) | 97 | if ( sep > 0 ) |
92 | appName = appName.mid( sep+1 ); | 98 | appName = appName.mid( sep+1 ); |
93 | 99 | ||
94 | appIface = 0; | 100 | appIface = 0; |
95 | if ( loader->queryInterface(appName, IID_QtopiaApplication, (QUnknownInterface**)&appIface) == QS_OK ) { | 101 | if ( loader->queryInterface(appName, IID_QtopiaApplication, (QUnknownInterface**)&appIface) == QS_OK ) { |
96 | mainWindow = appIface->createMainWindow( appName ); | 102 | mainWindow = appIface->createMainWindow( appName ); |
97 | } | 103 | } |
98 | if ( mainWindow ) { | 104 | if ( mainWindow ) { |
99 | if ( mainWindow->metaObject()->slotNames().contains("setDocument(const QString&)") ) { | 105 | if ( mainWindow->metaObject()->slotNames().contains("setDocument(const QString&)") ) { |
100 | app->showMainDocumentWidget( mainWindow ); | 106 | app->showMainDocumentWidget( mainWindow ); |
101 | } else { | 107 | } else { |
102 | app->showMainWidget( mainWindow ); | 108 | app->showMainWidget( mainWindow ); |
103 | } | 109 | } |
104 | } else { | 110 | } else { |
105 | qWarning( "Could not create application main window" ); | 111 | qWarning( "Could not create application main window" ); |
106 | exit(-1); | 112 | exit(-1); |
107 | } | 113 | } |
108 | } | 114 | } |
109 | 115 | ||
110 | private slots: | 116 | private slots: |
111 | void message(const QCString &msg, const QByteArray & data) | 117 | void message(const QCString &msg, const QByteArray & data) |
112 | { | 118 | { |
113 | QStrList argList; | 119 | QStrList argList; |
114 | 120 | ||
115 | if ( msg == "execute(QStrList)" ) { | 121 | if ( msg == "execute(QStrList)" ) { |
116 | delete qlChannel; | 122 | delete qlChannel; |
117 | QDataStream stream( data, IO_ReadOnly ); | 123 | QDataStream stream( data, IO_ReadOnly ); |
118 | QStrList argList; | 124 | QStrList argList; |
119 | stream >> argList; | 125 | stream >> argList; |
120 | qDebug( "QuickLauncher execute: %s", argList.at(0) ); | 126 | qDebug( "QuickLauncher execute: %s", argList.at(0) ); |
121 | doQuickLaunch( argList ); | 127 | doQuickLaunch( argList ); |
122 | delete this; | 128 | delete this; |
123 | } else if ( msg == "execute(QString)" ) { | 129 | } else if ( msg == "execute(QString)" ) { |
@@ -142,106 +148,118 @@ private: | |||
142 | myargv[j] = new char [strlen(argList.at(j))+1]; | 148 | myargv[j] = new char [strlen(argList.at(j))+1]; |
143 | strcpy( myargv[j], argList.at(j) ); | 149 | strcpy( myargv[j], argList.at(j) ); |
144 | } | 150 | } |
145 | myargv[myargc] = NULL; | 151 | myargv[myargc] = NULL; |
146 | #ifdef _OS_LINUX_ | 152 | #ifdef _OS_LINUX_ |
147 | // Change name of process | 153 | // Change name of process |
148 | setproctitle(myargv[0]); | 154 | setproctitle(myargv[0]); |
149 | #endif | 155 | #endif |
150 | 156 | ||
151 | connect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); | 157 | connect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); |
152 | app->exit_loop(); | 158 | app->exit_loop(); |
153 | app->initApp( myargc, myargv ); | 159 | app->initApp( myargc, myargv ); |
154 | exec( myargc, myargv ); | 160 | exec( myargc, myargv ); |
155 | } | 161 | } |
156 | 162 | ||
157 | private: | 163 | private: |
158 | QCopChannel *qlChannel; | 164 | QCopChannel *qlChannel; |
159 | }; | 165 | }; |
160 | 166 | ||
161 | int main( int argc, char** argv ) | 167 | int main( int argc, char** argv ) |
162 | { | 168 | { |
163 | app = new QPEApplication( argc, argv ); | 169 | app = new QPEApplication( argc, argv ); |
164 | 170 | ||
165 | loader = new PluginLoader( "application" ); | 171 | loader = new PluginLoader( "application" ); |
166 | 172 | ||
167 | unsetenv( "LD_BIND_NOW" ); | 173 | unsetenv( "LD_BIND_NOW" ); |
168 | 174 | ||
169 | QCString arg0 = argv[0]; | 175 | QCString arg0 = argv[0]; |
170 | int sep = arg0.findRev( '/' ); | 176 | int sep = arg0.findRev( '/' ); |
171 | if ( sep > 0 ) | 177 | if ( sep > 0 ) |
172 | arg0 = arg0.mid( sep+1 ); | 178 | arg0 = arg0.mid( sep+1 ); |
173 | if ( arg0 != "quicklauncher" ) { | 179 | if ( arg0 != "quicklauncher" ) { |
174 | qDebug( "QuickLauncher invoked as: %s", arg0.data() ); | 180 | qDebug( "QuickLauncher invoked as: %s", arg0.data() ); |
175 | QuickLauncher::exec( argc, argv ); | 181 | QuickLauncher::exec( argc, argv ); |
176 | } else { | 182 | } else { |
177 | #ifdef _OS_LINUX_ | 183 | #ifdef _OS_LINUX_ |
178 | // Setup to change proc title | 184 | // Setup to change proc title |
179 | int i; | 185 | int i; |
180 | char **envp = environ; | 186 | char **envp = environ; |
181 | /* Move the environment so we can reuse the memory. | 187 | /* Move the environment so we can reuse the memory. |
182 | * (Code borrowed from sendmail.) */ | 188 | * (Code borrowed from sendmail.) */ |
183 | for (i = 0; envp[i] != NULL; i++) | 189 | for (i = 0; envp[i] != NULL; i++) |
184 | continue; | 190 | continue; |
185 | environ = (char **) malloc(sizeof(char *) * (i + 1)); | 191 | environ = (char **) malloc(sizeof(char *) * (i + 1)); |
186 | if (environ == NULL) | 192 | if (environ == NULL) |
187 | return -1; | 193 | return -1; |
188 | for (i = 0; envp[i] != NULL; i++) | 194 | for (i = 0; envp[i] != NULL; i++) |
189 | if ((environ[i] = strdup(envp[i])) == NULL) | 195 | if ((environ[i] = strdup(envp[i])) == NULL) |
190 | return -1; | 196 | return -1; |
191 | environ[i] = NULL; | 197 | environ[i] = NULL; |
192 | 198 | ||
193 | argv0 = argv; | 199 | argv0 = argv; |
194 | if (i > 0) | 200 | if (i > 0) |
195 | argv_lth = envp[i-1] + strlen(envp[i-1]) - argv0[0]; | 201 | argv_lth = envp[i-1] + strlen(envp[i-1]) - argv0[0]; |
196 | else | 202 | else |
197 | argv_lth = argv0[argc-1] + strlen(argv0[argc-1]) - argv0[0]; | 203 | argv_lth = argv0[argc-1] + strlen(argv0[argc-1]) - argv0[0]; |
198 | #endif | 204 | #endif |
199 | (void)new QuickLauncher(); | 205 | (void)new QuickLauncher(); |
200 | qDebug( "QuickLauncher running" ); | 206 | qDebug( "QuickLauncher running" ); |
201 | // Pre-load default fonts | 207 | // Pre-load default fonts |
202 | QFontMetrics fm( QApplication::font() ); | 208 | QFontMetrics fm( QApplication::font() ); |
203 | fm.ascent(); // causes font load. | 209 | fm.ascent(); // causes font load. |
204 | QFont f( QApplication::font() ); | 210 | QFont f( QApplication::font() ); |
205 | f.setWeight( QFont::Bold ); | 211 | f.setWeight( QFont::Bold ); |
206 | QFontMetrics fmb( f ); | 212 | QFontMetrics fmb( f ); |
207 | fmb.ascent(); // causes font load. | 213 | fmb.ascent(); // causes font load. |
208 | 214 | ||
209 | // Each of the following force internal structures/internal | 215 | // Each of the following force internal structures/internal |
210 | // initialization to be performed. This may mean allocating | 216 | // initialization to be performed. This may mean allocating |
211 | // memory that is not needed by all applications. | 217 | // memory that is not needed by all applications. |
212 | #if 0 | 218 | #if 0 |
213 | TimeZone::current().isValid(); // popuplate timezone cache | 219 | TimeZone::current().isValid(); // popuplate timezone cache |
214 | TimeString::currentDateFormat(); // create internal structures | 220 | TimeString::currentDateFormat(); // create internal structures |
215 | TimeString::currentAMPM(); | 221 | TimeString::currentAMPM(); |
216 | #endif | 222 | #endif |
217 | Resource::loadIconSet("new"); // do internal init | 223 | Resource::loadIconSet("new"); // do internal init |
218 | 224 | ||
219 | /* make sure libopie gets lined in */ | 225 | /* make sure libopie gets lined in */ |
220 | { | 226 | { |
221 | OWait item; | 227 | OWait item; |
222 | } | 228 | } |
223 | 229 | ||
224 | // Create a widget to force initialization of title bar images, etc. | 230 | // Create a widget to force initialization of title bar images, etc. |
225 | QObject::disconnect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); | 231 | QObject::disconnect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); |
226 | QWidget *w = new QWidget(0,0,Qt::WDestructiveClose|Qt::WStyle_ContextHelp|Qt::WStyle_Tool); | 232 | QWidget *w = new QWidget(0,0,Qt::WDestructiveClose|Qt::WStyle_ContextHelp|Qt::WStyle_Tool); |
227 | w->setGeometry( -100, -100, 10, 10 ); | 233 | w->setGeometry( -100, -100, 10, 10 ); |
228 | w->show(); | 234 | w->show(); |
229 | QTimer::singleShot( 0, w, SLOT(close()) ); | 235 | QTimer::singleShot( 0, w, SLOT(close()) ); |
230 | 236 | ||
231 | app->enter_loop(); | 237 | app->enter_loop(); |
232 | } | 238 | } |
233 | 239 | ||
234 | int rv = app->exec(); | 240 | int rv = app->exec(); |
235 | 241 | ||
236 | if ( mainWindow ) | 242 | if ( mainWindow ) |
237 | delete (QWidget*)mainWindow; | 243 | delete (QWidget*)mainWindow; |
244 | |||
245 | delete app; | ||
238 | if ( appIface ) | 246 | if ( appIface ) |
239 | loader->releaseInterface( appIface ); | 247 | loader->releaseInterface( appIface ); |
240 | delete loader; | 248 | delete loader; |
241 | 249 | // Neither QLibrary nor my Dropin is a QObject and they don't depend | |
242 | delete app; | 250 | // on a qApp so we destroy QWidget::destroyMapper() without |
251 | // crashing the app | ||
252 | // | ||
253 | // The problem is there are some 'static' resources not freed | ||
254 | // in the apps and on destructing these objects are not available | ||
255 | // anymore. In future fix up the apps but for now | ||
256 | // we just skip deletion and hope things go well -zecke | ||
257 | // delete app; | ||
258 | // hack instead -zecke | ||
259 | // delete app->pidChannel; | ||
260 | // app->pidChannel = 0; | ||
243 | 261 | ||
244 | return rv; | 262 | return rv; |
245 | } | 263 | } |
246 | 264 | ||
247 | #include "main.moc" | 265 | #include "main.moc" |
diff --git a/core/tools/quicklauncher/opie-quicklauncher.control b/core/tools/quicklauncher/opie-quicklauncher.control new file mode 100644 index 0000000..79b9493 --- a/dev/null +++ b/core/tools/quicklauncher/opie-quicklauncher.control | |||
@@ -0,0 +1,10 @@ | |||
1 | Package: opie-quicklauncher | ||
2 | Files: bin/quicklauncher | ||
3 | Priority: required | ||
4 | Section: opie/system | ||
5 | Maintainer: Trolltech (www.trolltech.com) | ||
6 | Architecture: arm | ||
7 | Version: $QPE_VERSION$EXTRAVERSION | ||
8 | Depends: | ||
9 | Description: Quick launcher stub | ||
10 | Launcher stub for quick launch enabled applications. | ||