summaryrefslogtreecommitdiff
path: root/core/launcher
Unidiff
Diffstat (limited to 'core/launcher') (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/applauncher.cpp4
-rw-r--r--core/launcher/inputmethods.cpp4
-rw-r--r--core/launcher/irserver.cpp4
-rw-r--r--core/launcher/main.cpp2
-rw-r--r--core/launcher/packageslave.cpp304
-rw-r--r--core/launcher/qprocess_unix.cpp3
-rw-r--r--core/launcher/server.pro5
-rw-r--r--core/launcher/startmenu.cpp4
-rw-r--r--core/launcher/systray.cpp5
-rw-r--r--core/launcher/transferserver.cpp3
10 files changed, 308 insertions, 30 deletions
diff --git a/core/launcher/applauncher.cpp b/core/launcher/applauncher.cpp
index d6f93da..0ac043b 100644
--- a/core/launcher/applauncher.cpp
+++ b/core/launcher/applauncher.cpp
@@ -546,7 +546,11 @@ bool AppLauncher::execute(const QString &c, const QString &docParam, bool noRais
546 args[j] = NULL; 546 args[j] = NULL;
547 547
548#ifndef Q_OS_WIN32 548#ifndef Q_OS_WIN32
549#ifdef Q_OS_MACX
550 if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".dylib" ) ) {
551#else
549 if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".so" ) ) { 552 if ( qlPid && qlReady && QFile::exists( QPEApplication::qpeDir()+"plugins/application/lib"+args[0] + ".so" ) ) {
553#endif /* Q_OS_MACX */
550 qDebug( "Quick launching: %s", args[0] ); 554 qDebug( "Quick launching: %s", args[0] );
551 if ( getuid() == 0 ) 555 if ( getuid() == 0 )
552 setpriority( PRIO_PROCESS, qlPid, 0 ); 556 setpriority( PRIO_PROCESS, qlPid, 0 );
diff --git a/core/launcher/inputmethods.cpp b/core/launcher/inputmethods.cpp
index 8f3e812..62e316c 100644
--- a/core/launcher/inputmethods.cpp
+++ b/core/launcher/inputmethods.cpp
@@ -227,7 +227,11 @@ void InputMethods::unloadMethod( QValueList<InputMethod>& list ) {
227 227
228QStringList InputMethods::plugins()const { 228QStringList InputMethods::plugins()const {
229 QString path = QPEApplication::qpeDir() + "/plugins/inputmethods"; 229 QString path = QPEApplication::qpeDir() + "/plugins/inputmethods";
230#ifdef Q_OS_MACX
231 QDir dir( path, "lib*.dylib" );
232#else
230 QDir dir( path, "lib*.so" ); 233 QDir dir( path, "lib*.so" );
234#endif /* Q_OS_MACX */
231 return dir.entryList(); 235 return dir.entryList();
232} 236}
233 237
diff --git a/core/launcher/irserver.cpp b/core/launcher/irserver.cpp
index 579c78c..63f8d05 100644
--- a/core/launcher/irserver.cpp
+++ b/core/launcher/irserver.cpp
@@ -36,7 +36,11 @@ IrServer::IrServer( QObject *parent, const char *name )
36 lib = 0; 36 lib = 0;
37 obexIface = 0; 37 obexIface = 0;
38 QString path = QPEApplication::qpeDir() + "/plugins/obex/"; 38 QString path = QPEApplication::qpeDir() + "/plugins/obex/";
39#ifdef Q_OS_MACX
40 QDir dir( path, "lib*.dylib" );
41#else
39 QDir dir( path, "lib*.so" ); 42 QDir dir( path, "lib*.so" );
43#endif /* Q_OS_MACX */
40 QStringList list = dir.entryList(); 44 QStringList list = dir.entryList();
41 QStringList::Iterator it; 45 QStringList::Iterator it;
42 for ( it = list.begin(); it != list.end(); ++it ) { 46 for ( it = list.begin(); it != list.end(); ++it ) {
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp
index 74965df..5416d33 100644
--- a/core/launcher/main.cpp
+++ b/core/launcher/main.cpp
@@ -276,7 +276,9 @@ int initApplication( int argc, char ** argv )
276 qDebug("exiting..."); 276 qDebug("exiting...");
277 delete s; 277 delete s;
278 278
279#ifndef Q_OS_MACX
279 ODevice::inst()->setSoftSuspend( false ); 280 ODevice::inst()->setSoftSuspend( false );
281#endif
280 282
281 return rv; 283 return rv;
282} 284}
diff --git a/core/launcher/packageslave.cpp b/core/launcher/packageslave.cpp
index 4f149a5..bf34368 100644
--- a/core/launcher/packageslave.cpp
+++ b/core/launcher/packageslave.cpp
@@ -1,7 +1,7 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of 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
@@ -19,25 +19,47 @@
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "packageslave.h" 21#include "packageslave.h"
22#include <qtopia/qprocess.h>
22 23
23#include <qpe/process.h> 24#ifdef Q_WS_QWS
24#include <qpe/qcopenvelope_qws.h> 25#include <qtopia/qcopenvelope_qws.h>
26#endif
25 27
26#include <qdatastream.h> 28#include <qdatastream.h>
29#ifdef Q_WS_QWS
27#include <qcopchannel_qws.h> 30#include <qcopchannel_qws.h>
31#endif
28 32
33#include <qtextstream.h>
34#include <qdir.h>
35
36#include <stdlib.h>
37#include <sys/stat.h> // mkdir()
38
39#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
40#include <unistd.h>
41#include <sys/vfs.h>
42#include <mntent.h>
43#elif defined(Q_OS_WIN32)
44#include <windows.h>
45#include <winbase.h>
46#elif defined(Q_OS_MACX)
29#include <unistd.h> 47#include <unistd.h>
48#endif
30 49
31PackageSlave::PackageSlave( QObject *parent, char* name ) 50
32 : QObject( parent, name ), packageChannel( 0 ) 51PackageHandler::PackageHandler( QObject *parent, char* name )
52 : QObject( parent, name ), packageChannel( 0 ), currentProcess( 0 ), mNoSpaceLeft( FALSE )
33{ 53{
34 // setup qcop channel 54 // setup qcop channel
55#ifndef QT_NO_COP
35 packageChannel = new QCopChannel( "QPE/Package", this ); 56 packageChannel = new QCopChannel( "QPE/Package", this );
36 connect( packageChannel, SIGNAL( received(const QCString &, const QByteArray &) ), 57 connect( packageChannel, SIGNAL( received(const QCString &, const QByteArray &) ),
37 this, SLOT( qcopMessage( const QCString &, const QByteArray &) ) ); 58 this, SLOT( qcopMessage( const QCString &, const QByteArray &) ) );
59#endif
38} 60}
39 61
40void PackageSlave::qcopMessage( const QCString &msg, const QByteArray &data ) 62void PackageHandler::qcopMessage( const QCString &msg, const QByteArray &data )
41{ 63{
42 QDataStream stream( data, IO_ReadOnly ); 64 QDataStream stream( data, IO_ReadOnly );
43 65
@@ -45,53 +67,275 @@ void PackageSlave::qcopMessage( const QCString &msg, const QByteArray &data )
45 QString file; 67 QString file;
46 stream >> file; 68 stream >> file;
47 installPackage( file ); 69 installPackage( file );
48 } 70 } else if ( msg == "removePackage(QString)" ) {
49 else if ( msg == "removePackage(QString)" ) {
50 QString file; 71 QString file;
51 stream >> file; 72 stream >> file;
52 removePackage( file ); 73 removePackage( file );
74 } else if ( msg == "addPackageFiles(QString,QString)" ) {
75 QString location, listfile;
76 stream >> location >> listfile;
77 addPackageFiles( location, listfile);
78 } else if ( msg == "addPackages(QString)" ) {
79 QString location;
80 stream >> location;
81 addPackages( location );
82 } else if ( msg == "cleanupPackageFiles(QString)" ) {
83 QString listfile;
84 stream >> listfile;
85 cleanupPackageFiles( listfile );
86 } else if ( msg == "cleanupPackages(QString)" ) {
87 QString location;
88 stream >> location;
89 cleanupPackages( location );
90 } else if ( msg == "prepareInstall(QString,QString)" ) {
91 QString size, path;
92 stream >> size;
93 stream >> path;
94 prepareInstall( size, path );
53 } 95 }
54} 96}
55 97
56void PackageSlave::installPackage( const QString &package ) 98void PackageHandler::installPackage( const QString &package )
57{ 99{
58 Process proc( QStringList() << "ipkg" << "install" << package ); 100 if ( mNoSpaceLeft ) {
101 mNoSpaceLeft = FALSE;
102 // Don't emit that for now, I still couldn't test it (Wener)
103 //sendReply( "installFailed(QString)", package );
104 //return;
105 }
106
107 currentProcess = new QProcess( QStringList() << "ipkg" << "install" << package ); // No tr
108 connect( currentProcess, SIGNAL( processExited() ), SLOT( iProcessExited() ) );
109 connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) );
110 connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) );
111 currentPackage = package;
59 112
113 currentProcessError="";
60 sendReply( "installStarted(QString)", package ); 114 sendReply( "installStarted(QString)", package );
115 currentProcess->start();
116}
117
118void PackageHandler::removePackage( const QString &package )
119{
120 currentProcess = new QProcess( QStringList() << "ipkg" << "remove" << package ); // No tr
121 connect( currentProcess, SIGNAL( processExited() ), SLOT( rmProcessExited() ) );
122 connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) );
123 connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) );
124 currentPackage = package;
61 125
62 QString output; 126 currentProcessError="";
63 if ( proc.exec( "", output ) ) { 127 sendReply( "removeStarted(QString)", package );
64 sendReply( "installDone(QString)", package ); 128 currentProcess->start();
65 } 129 }
66 else { 130
67 sendReply( "installFailed(QString)", package ); 131void PackageHandler::sendReply( const QCString& msg, const QString& arg )
132{
133#ifndef QT_NO_COP
134 QCopEnvelope e( "QPE/Desktop", msg );
135 e << arg;
136#endif
137}
138
139void PackageHandler::addPackageFiles( const QString &location,
140 const QString &listfile )
141{
142 QFile f(listfile);
143#ifndef Q_OS_WIN32
144 //make a copy so we can remove the symlinks later
145 mkdir( ("/usr/lib/ipkg/info/"+location).ascii(), 0777 );
146 system(("cp " + f.name() + " /usr/lib/ipkg/info/"+location).ascii());
147#else
148 QDir d;
149 //#### revise
150 qDebug("Copy file at %s: %s", __FILE__, __LINE__ );
151 d.mkdir(("/usr/lib/ipkg/info/" + location).ascii());
152 system(("copy " + f.name() + " /usr/lib/ipkg/info/"+location).ascii());
153#endif
154
155
156 if ( f.open(IO_ReadOnly) ) {
157 QTextStream ts(&f);
158
159 QString s;
160 while ( !ts.eof() ) { // until end of file...
161 s = ts.readLine(); // line of text excluding '\n'
162 // for s, do link/mkdir.
163 if ( s.right(1) == "/" ) {
164 qDebug("do mkdir for %s", s.ascii());
165#ifndef Q_OS_WIN32
166 mkdir( s.ascii(), 0777 );
167 //possible optimization: symlink directories
168 //that don't exist already. -- Risky.
169#else
170 d.mkdir( s.ascii());
171#endif
172
173 } else {
174#ifndef Q_OS_WIN32
175 qDebug("do symlink for %s", s.ascii());
176 symlink( (location + s).ascii(), s.ascii() );
177#else
178 qDebug("Copy file instead of a symlink for WIN32");
179 if (!CopyFile((TCHAR*)qt_winTchar((location + s), TRUE), (TCHAR*)qt_winTchar(s, TRUE), FALSE))
180 qWarning("Unable to create symlinkfor %s",
181 (location + s).ascii());
182#endif
183 }
184 }
185 f.close();
68 } 186 }
69 QCopEnvelope e("QPE/System", "linkChanged(QString)");
70 QString lf = QString::null;
71 e << lf;
72 unlink( package );
73} 187}
74 188
75void PackageSlave::removePackage( const QString &package ) 189void PackageHandler::addPackages( const QString &location )
76{ 190{
77 Process proc( QStringList() << "ipkg" << "remove" << package ); 191 // get list of *.list in location/usr/lib/ipkg/info/*.list
192 QDir dir(location + "/usr/lib/ipkg/info", "*.list", // No tr
193 QDir::Name, QDir::Files);
194 if ( !dir.exists() )
195 return;
78 196
79 sendReply( "removeStarted(QString)", package ); 197 QStringList packages = dir.entryList();
198 for ( QStringList::Iterator it = packages.begin();
199 it != packages.end(); ++it ) {
200 addPackageFiles( location, *it );
201 }
202}
203
204
205void PackageHandler::cleanupPackageFiles( const QString &listfile )
206{
207 QFile f(listfile);
80 208
81 QString output; 209 if ( f.open(IO_ReadOnly) ) {
82 if ( proc.exec( "", output ) ) { 210 QTextStream ts(&f);
83 sendReply( "removeDone(QString)", package ); 211
212 QString s;
213 while ( !ts.eof() ) { // until end of file...
214 s = ts.readLine(); // line of text excluding '\n'
215 // for s, do link/mkdir.
216 if ( s.right(1) == "/" ) {
217 //should rmdir if empty, after all files have been removed
218 } else {
219#ifndef Q_OS_WIN32
220 qDebug("remove symlink for %s", s.ascii());
221 //check if it is a symlink first (don't remove /etc/passwd...)
222 char buf[10]; //we don't care about the contents
223 if ( ::readlink( s.ascii(),buf, 10 >= 0 ) )
224 ::unlink( s.ascii() );
225 #else
226 // ### revise
227 qWarning("Unable to remove symlink %s:%s", __FILE__, __LINE__);
228#endif
229 }
84 } 230 }
231 f.close();
232
233 //remove the list file
234 ::unlink( listfile.ascii() );
235
236 }
237}
238
239void PackageHandler::cleanupPackages( const QString &location )
240{
241 // get list of *.list in location/usr/lib/ipkg/info/*.list
242 QDir dir( "/usr/lib/ipkg/info/"+location, "*.list", // No tr
243 QDir::Name, QDir::Files);
244 if ( !dir.exists() )
245 return;
246
247 QStringList packages = dir.entryList();
248 for ( QStringList::Iterator it = packages.begin();
249 it != packages.end(); ++it ) {
250 cleanupPackageFiles( *it );
251 }
252
253 //remove the backup directory
254 //###
255}
256
257void PackageHandler::prepareInstall( const QString& size, const QString& path )
258{
259 // Check whether there will be enough space to install the next package.
260 bool ok;
261 unsigned int s = size.toUInt( &ok );
262
263 if ( !ok )
264 return;
265
266 // Shamelessly stolen from the sysinfo application (Werner)
267#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
268 struct statfs fs;
269 if ( statfs( path.latin1(), &fs ) == 0 )
270 if ( s > fs.f_bsize * fs.f_bavail ) {
271 //qDebug("############### Not enough space left ###############");
272 mNoSpaceLeft = TRUE;
273 }
274#endif
275}
276
277void PackageHandler::iProcessExited()
278{
279 if ( currentProcess->normalExit() && currentProcess->exitStatus() == 0 )
280 sendReply( "installDone(QString)", currentPackage );
85 else { 281 else {
86 sendReply( "removeFailed(QString)", package ); 282#ifndef QT_NO_COP
283 QCopEnvelope e( "QPE/Desktop", "installFailed(QString,int,QString)" );
284 e << currentPackage << currentProcess->exitStatus()
285 << currentProcessError;
286#endif
87 } 287 }
288
289 delete currentProcess;
290 currentProcess = 0;
291
292#ifndef QT_NO_COP
88 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 293 QCopEnvelope e("QPE/System", "linkChanged(QString)");
89 QString lf = QString::null; 294 QString lf = QString::null;
90 e << lf; 295 e << lf;
296#endif
297 unlink( currentPackage );
91} 298}
92 299
93void PackageSlave::sendReply( const QCString& msg, const QString& arg ) 300void PackageHandler::rmProcessExited()
94{ 301{
95 QCopEnvelope e( "QPE/Desktop", msg ); 302 if ( currentProcess->normalExit() && currentProcess->exitStatus() == 0 )
96 e << arg; 303 sendReply( "removeDone(QString)", currentPackage );
304 else
305 sendReply( "removeFailed(QString)", currentPackage );
306
307#ifndef QT_NO_COP
308 QCopEnvelope e("QPE/System", "linkChanged(QString)");
309 QString lf = QString::null;
310 e << lf;
311#endif
312}
313
314void PackageHandler::readyReadStdout()
315{
316 while ( currentProcess->canReadLineStdout() ) {
317 QString line = currentProcess->readLineStdout();
318 currentProcessError.append("OUT:"+line);
319 if ( line.contains( "Unpacking" ) ) // No tr
320 sendReply( "installStep(QString)", "one" ); // No tr
321 else if ( line.contains( "Configuring" ) ) // No tr
322 sendReply( "installStep(QString)", "two" ); // No tr
323 }
324}
325
326void PackageHandler::readyReadStderr()
327{
328 while ( currentProcess->canReadLineStderr() ) {
329 QString line = currentProcess->readLineStderr();
330 currentProcessError.append("ERR:"+line);
331 }
332}
333
334void PackageHandler::redoPackages()
335{
336 //get list of filesystems
337
338 //call cleanupPackages for the ones that have disappeared
339
340 //call addPackageFiles for the new ones
97} 341}
diff --git a/core/launcher/qprocess_unix.cpp b/core/launcher/qprocess_unix.cpp
index a07bf64..19a8c93 100644
--- a/core/launcher/qprocess_unix.cpp
+++ b/core/launcher/qprocess_unix.cpp
@@ -50,6 +50,9 @@
50 50
51#include <errno.h> 51#include <errno.h>
52 52
53#ifdef Q_OS_MACX
54#include <sys/time.h>
55#endif
53#include <sys/resource.h> 56#include <sys/resource.h>
54 57
55#ifdef __MIPSEL__ 58#ifdef __MIPSEL__
diff --git a/core/launcher/server.pro b/core/launcher/server.pro
index 93baeb4..0513536 100644
--- a/core/launcher/server.pro
+++ b/core/launcher/server.pro
@@ -115,6 +115,11 @@ DEPENDPATH += $(OPIEDIR)/rsync
115 115
116 TARGET = qpe 116 TARGET = qpe
117 117
118CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX )
119contains( CONFTEST, y ){
120 LIBS += -lqpe -lopie
121}else{
118 LIBS+= -lcrypt -lqpe -lopie 122 LIBS+= -lcrypt -lqpe -lopie
123}
119 124
120include ( $(OPIEDIR)/include.pro ) 125include ( $(OPIEDIR)/include.pro )
diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp
index 014418d..08ae885 100644
--- a/core/launcher/startmenu.cpp
+++ b/core/launcher/startmenu.cpp
@@ -256,7 +256,11 @@ void StartMenu::loadApplets()
256 256
257 QString lang = getenv( "LANG" ); 257 QString lang = getenv( "LANG" );
258 QString path = QPEApplication::qpeDir() + "/plugins/applets"; 258 QString path = QPEApplication::qpeDir() + "/plugins/applets";
259#ifdef Q_OS_MACX
260 QDir dir( path, "lib*.dylib" );
261#else
259 QDir dir( path, "lib*.so" ); 262 QDir dir( path, "lib*.so" );
263#endif /* Q_OS_MACX */
260 QStringList list = dir.entryList(); 264 QStringList list = dir.entryList();
261 QStringList::Iterator it; 265 QStringList::Iterator it;
262 int napplets=0; 266 int napplets=0;
diff --git a/core/launcher/systray.cpp b/core/launcher/systray.cpp
index 6122770..691f6b8 100644
--- a/core/launcher/systray.cpp
+++ b/core/launcher/systray.cpp
@@ -102,7 +102,11 @@ void SysTray::addApplets()
102 102
103 QString lang = getenv( "LANG" ); 103 QString lang = getenv( "LANG" );
104 QString path = QPEApplication::qpeDir() + "/plugins/applets"; 104 QString path = QPEApplication::qpeDir() + "/plugins/applets";
105#ifdef Q_OS_MACX
106 QDir dir( path, "lib*.dylib" );
107#else
105 QDir dir( path, "lib*.so" ); 108 QDir dir( path, "lib*.so" );
109#endif /* Q_OS_MACX */
106 QStringList list = dir.entryList(); 110 QStringList list = dir.entryList();
107 QStringList::Iterator it; 111 QStringList::Iterator it;
108 int napplets=0; 112 int napplets=0;
@@ -110,6 +114,7 @@ void SysTray::addApplets()
110 for ( it = list.begin(); it != list.end(); ++it ) { 114 for ( it = list.begin(); it != list.end(); ++it ) {
111 if ( exclude.find( *it ) != exclude.end() ) 115 if ( exclude.find( *it ) != exclude.end() )
112 continue; 116 continue;
117 qWarning( "Found Applet: %s", (*it).latin1() );
113 TaskbarAppletInterface *iface = 0; 118 TaskbarAppletInterface *iface = 0;
114 QLibrary *lib = new QLibrary( path + "/" + *it ); 119 QLibrary *lib = new QLibrary( path + "/" + *it );
115 if (( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { 120 if (( lib->queryInterface( IID_TaskbarApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) {
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp
index c69df2d..439e110 100644
--- a/core/launcher/transferserver.cpp
+++ b/core/launcher/transferserver.cpp
@@ -28,8 +28,11 @@
28#include <unistd.h> 28#include <unistd.h>
29#include <stdlib.h> 29#include <stdlib.h>
30#include <time.h> 30#include <time.h>
31
32#ifndef Q_OS_MACX
31#include <shadow.h> 33#include <shadow.h>
32#include <crypt.h> 34#include <crypt.h>
35#endif /* Q_OS_MACX */
33 36
34#else 37#else
35#include <stdlib.h> 38#include <stdlib.h>