summaryrefslogtreecommitdiff
path: root/core/tools
authorwimpie <wimpie>2005-01-09 03:02:21 (UTC)
committer wimpie <wimpie>2005-01-09 03:02:21 (UTC)
commit67d1d0b292553af550219d770cbd5c00987d8b8b (patch) (unidiff)
tree517759c7fbda44a40ff733e3b5d5667d90558caa /core/tools
parent987bc9a2c5b39ddd4dc2a665cea65688bfd2179e (diff)
downloadopie-67d1d0b292553af550219d770cbd5c00987d8b8b.zip
opie-67d1d0b292553af550219d770cbd5c00987d8b8b.tar.gz
opie-67d1d0b292553af550219d770cbd5c00987d8b8b.tar.bz2
CONTROL files : reset version to 'standard' format
(partly rolls back my drastic all-applicatoins-same-version change) now format is x.y(.z)$EXTRAVERSION where x.y (and aptionally .z) are x : major version y : minor version z : application patch and extra version is seconds-since-epoch this value can be used to automatically upgrade versions with minor changes (without manual update of the control file)
Diffstat (limited to 'core/tools') (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
@@ -1,290 +1,289 @@
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#define QTOPIA_INTERNAL_INITAPP 21#define QTOPIA_INTERNAL_INITAPP
22#include "dropins.h" 22#include "dropins.h"
23 23
24/* OPIE */ 24/* OPIE */
25#include <opie2/odebug.h> 25#include <opie2/odebug.h>
26#include <opie2/oapplication.h> 26#include <opie2/oapplication.h>
27 27
28/* QT */ 28/* QT */
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qstrlist.h> 30#include <qstrlist.h>
31#include <qtimer.h> 31#include <qtimer.h>
32#include <qguardedptr.h> 32#include <qguardedptr.h>
33#include <qcopchannel_qws.h> 33#include <qcopchannel_qws.h>
34 34
35#ifdef private 35#ifdef private
36# undef private 36# undef private
37#endif 37#endif
38#define private public 38#define private public
39#include <qtopia/qpeapplication.h> 39#include <qtopia/qpeapplication.h>
40#undef private 40#undef private
41 41
42/* STD */ 42/* STD */
43#include <stdio.h> 43#include <stdio.h>
44#include <stdlib.h> 44#include <stdlib.h>
45#include <sys/types.h> 45#include <sys/types.h>
46#include <sys/stat.h> 46#include <sys/stat.h>
47 47
48#ifdef _OS_LINUX_ 48#ifdef _OS_LINUX_
49#include <sys/prctl.h> 49#include <sys/prctl.h>
50#ifndef PR_SET_NAME 50#ifndef PR_SET_NAME
51#define PR_SET_NAME 15 51#define PR_SET_NAME 15
52#endif 52#endif
53#endif 53#endif
54 54
55#include <unistd.h> 55#include <unistd.h>
56 56
57 57
58using QuickPrivate::PluginLoader; 58using QuickPrivate::PluginLoader;
59 59
60static QPEApplication *app = 0; 60static QPEApplication *app = 0;
61static PluginLoader *loader = 0; 61static PluginLoader *loader = 0;
62static ApplicationInterface *appIface = 0; 62static ApplicationInterface *appIface = 0;
63static QGuardedPtr<QWidget> mainWindow; 63static QGuardedPtr<QWidget> mainWindow;
64 64
65#ifdef _OS_LINUX_ 65#ifdef _OS_LINUX_
66static char **argv0 = 0; 66static char **argv0 = 0;
67static int argv_lth; 67static int argv_lth;
68extern char **environ; 68extern char **environ;
69#ifndef SPT_BUFSIZE 69#ifndef SPT_BUFSIZE
70#define SPT_BUFSIZE 2048 70#define SPT_BUFSIZE 2048
71#endif 71#endif
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];
170 169
171 for ( int j = 0; j < myargc; j++ ) { 170 for ( int j = 0; j < myargc; j++ ) {
172 myargv[j] = new char [strlen(argList.at(j))+1]; 171 myargv[j] = new char [strlen(argList.at(j))+1];
173 strcpy( myargv[j], argList.at(j) ); 172 strcpy( myargv[j], argList.at(j) );
174 } 173 }
175 174
176 myargv[myargc] = NULL; 175 myargv[myargc] = NULL;
177#ifdef _OS_LINUX_ 176#ifdef _OS_LINUX_
178 // Change name of process 177 // Change name of process
179 setproctitle(myargv[0]); 178 setproctitle(myargv[0]);
180 prctl( PR_SET_NAME, (unsigned long)myargv[0], 0, 0, 0 ); 179 prctl( PR_SET_NAME, (unsigned long)myargv[0], 0, 0, 0 );
181#endif 180#endif
182 181
183 connect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); 182 connect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit()));
184 app->exit_loop(); 183 app->exit_loop();
185 app->initApp( myargc, myargv ); 184 app->initApp( myargc, myargv );
186 exec( myargc, myargv ); 185 exec( myargc, myargv );
187 } 186 }
188 187
189private: 188private:
190 QCopChannel *qlChannel; 189 QCopChannel *qlChannel;
191}; 190};
192 191
193int main( int argc, char** argv ) 192int main( int argc, char** argv )
194{ 193{
195 app = new Opie::Core::OApplication( argc, argv ); 194 app = new Opie::Core::OApplication( argc, argv );
196 195
197 loader = new PluginLoader( "application" ); 196 loader = new PluginLoader( "application" );
198 197
199 unsetenv( "LD_BIND_NOW" ); 198 unsetenv( "LD_BIND_NOW" );
200 199
201 QCString arg0 = argv[0]; 200 QCString arg0 = argv[0];
202 int sep = arg0.findRev( '/' ); 201 int sep = arg0.findRev( '/' );
203 202
204 if ( sep > 0 ) 203 if ( sep > 0 )
205 arg0 = arg0.mid( sep+1 ); 204 arg0 = arg0.mid( sep+1 );
206 205
207 if ( arg0 != "quicklauncher" ) { 206 if ( arg0 != "quicklauncher" ) {
208 odebug << "QuickLauncher invoked as: " << arg0.data() << oendl; 207 odebug << "QuickLauncher invoked as: " << arg0.data() << oendl;
209 QuickLauncher::exec( argc, argv ); 208 QuickLauncher::exec( argc, argv );
210 } else { 209 } else {
211#ifdef _OS_LINUX_ 210#ifdef _OS_LINUX_
212 // Setup to change proc title 211 // Setup to change proc title
213 int i; 212 int i;
214 char **envp = environ; 213 char **envp = environ;
215 /* Move the environment so we can reuse the memory. 214 /* Move the environment so we can reuse the memory.
216 * (Code borrowed from sendmail.) */ 215 * (Code borrowed from sendmail.) */
217 for (i = 0; envp[i] != NULL; i++) 216 for (i = 0; envp[i] != NULL; i++)
218 continue; 217 continue;
219 environ = (char **) malloc(sizeof(char *) * (i + 1)); 218 environ = (char **) malloc(sizeof(char *) * (i + 1));
220 if (environ == NULL) 219 if (environ == NULL)
221 return -1; 220 return -1;
222 for (i = 0; envp[i] != NULL; i++) 221 for (i = 0; envp[i] != NULL; i++)
223 if ((environ[i] = strdup(envp[i])) == NULL) 222 if ((environ[i] = strdup(envp[i])) == NULL)
224 return -1; 223 return -1;
225 environ[i] = NULL; 224 environ[i] = NULL;
226 225
227 argv0 = argv; 226 argv0 = argv;
228 if (i > 0) 227 if (i > 0)
229 argv_lth = envp[i-1] + strlen(envp[i-1]) - argv0[0]; 228 argv_lth = envp[i-1] + strlen(envp[i-1]) - argv0[0];
230 else 229 else
231 argv_lth = argv0[argc-1] + strlen(argv0[argc-1]) - argv0[0]; 230 argv_lth = argv0[argc-1] + strlen(argv0[argc-1]) - argv0[0];
232#endif 231#endif
233 (void)new QuickLauncher(); 232 (void)new QuickLauncher();
234 odebug << "QuickLauncher running" << oendl; 233 odebug << "QuickLauncher running" << oendl;
235 // Pre-load default fonts 234 // Pre-load default fonts
236 QFontMetrics fm( QApplication::font() ); 235 QFontMetrics fm( QApplication::font() );
237 fm.ascent(); // causes font load. 236 fm.ascent(); // causes font load.
238 QFont f( QApplication::font() ); 237 QFont f( QApplication::font() );
239 f.setWeight( QFont::Bold ); 238 f.setWeight( QFont::Bold );
240 QFontMetrics fmb( f ); 239 QFontMetrics fmb( f );
241 fmb.ascent(); // causes font load. 240 fmb.ascent(); // causes font load.
242 241
243 // Each of the following force internal structures/internal 242 // Each of the following force internal structures/internal
244 // initialization to be performed. This may mean allocating 243 // initialization to be performed. This may mean allocating
245 // memory that is not needed by all applications. 244 // memory that is not needed by all applications.
246 Resource::loadIconSet("new"); // do internal init 245 Resource::loadIconSet("new"); // do internal init
247 246
248 /* make sure libopie gets lined in */ 247 /* make sure libopie gets lined in */
249 { 248 {
250 Opie::Ui::OWait item; 249 Opie::Ui::OWait item;
251 } 250 }
252 251
253 // Create a widget to force initialization of title bar images, etc. 252 // Create a widget to force initialization of title bar images, etc.
254 QObject::disconnect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit())); 253 QObject::disconnect(app, SIGNAL(lastWindowClosed()), app, SLOT(hideOrQuit()));
255 QWidget *w = new QWidget(0,0,Qt::WDestructiveClose|Qt::WStyle_ContextHelp|Qt::WStyle_Tool); 254 QWidget *w = new QWidget(0,0,Qt::WDestructiveClose|Qt::WStyle_ContextHelp|Qt::WStyle_Tool);
256 w->setGeometry( -100, -100, 10, 10 ); 255 w->setGeometry( -100, -100, 10, 10 );
257 w->show(); 256 w->show();
258 QTimer::singleShot( 0, w, SLOT(close()) ); 257 QTimer::singleShot( 0, w, SLOT(close()) );
259 258
260 app->enter_loop(); 259 app->enter_loop();
261 } 260 }
262 261
263 int rv = app->exec(); 262 int rv = app->exec();
264 263
265 if ( mainWindow ) 264 if ( mainWindow )
266 delete (QWidget*)mainWindow; 265 delete (QWidget*)mainWindow;
267 delete app; 266 delete app;
268 267
269 if ( appIface ) 268 if ( appIface )
270 loader->releaseInterface( appIface ); 269 loader->releaseInterface( appIface );
271 delete loader; 270 delete loader;
272 271
273 272
274 // Neither QLibrary nor my Dropin is a QObject and they don't depend 273 // Neither QLibrary nor my Dropin is a QObject and they don't depend
275 // on a qApp so we destroy QWidget::destroyMapper() without 274 // on a qApp so we destroy QWidget::destroyMapper() without
276 // crashing the app 275 // crashing the app
277 // 276 //
278 // The problem is there are some 'static' resources not freed 277 // The problem is there are some 'static' resources not freed
279 // in the apps and on destructing these objects are not available 278 // in the apps and on destructing these objects are not available
280 // anymore. In future fix up the apps but for now 279 // anymore. In future fix up the apps but for now
281 // we just skip deletion and hope things go well -zecke 280 // we just skip deletion and hope things go well -zecke
282 // delete app; 281 // delete app;
283 // hack instead -zecke 282 // hack instead -zecke
284 // delete app->pidChannel; 283 // delete app->pidChannel;
285 // app->pidChannel = 0; 284 // app->pidChannel = 0;
286 285
287 return rv; 286 return rv;
288} 287}
289 288
290#include "main.moc" 289#include "main.moc"