Diffstat (limited to 'core/launcher/packageslave.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/launcher/packageslave.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/core/launcher/packageslave.cpp b/core/launcher/packageslave.cpp index 0461432..abbc610 100644 --- a/core/launcher/packageslave.cpp +++ b/core/launcher/packageslave.cpp | |||
@@ -20,134 +20,144 @@ | |||
20 | 20 | ||
21 | #include "packageslave.h" | 21 | #include "packageslave.h" |
22 | 22 | ||
23 | /* OPIE */ | 23 | /* OPIE */ |
24 | #include <opie2/odebug.h> | 24 | #include <opie2/odebug.h> |
25 | #include <qtopia/qprocess.h> | 25 | #include <qtopia/qprocess.h> |
26 | #ifdef Q_WS_QWS | 26 | #ifdef Q_WS_QWS |
27 | #include <qtopia/qcopenvelope_qws.h> | 27 | #include <qtopia/qcopenvelope_qws.h> |
28 | #endif | 28 | #endif |
29 | using namespace Opie::Core; | 29 | using namespace Opie::Core; |
30 | 30 | ||
31 | /* QT */ | 31 | /* QT */ |
32 | #ifdef Q_WS_QWS | 32 | #ifdef Q_WS_QWS |
33 | #include <qcopchannel_qws.h> | 33 | #include <qcopchannel_qws.h> |
34 | #endif | 34 | #endif |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | 36 | ||
37 | /* STD */ | 37 | /* STD */ |
38 | #include <stdlib.h> | 38 | #include <stdlib.h> |
39 | #include <sys/stat.h> // mkdir() | 39 | #include <sys/stat.h> // mkdir() |
40 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 40 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
41 | #include <unistd.h> | 41 | #include <unistd.h> |
42 | #include <sys/vfs.h> | 42 | #include <sys/vfs.h> |
43 | #include <mntent.h> | 43 | #include <mntent.h> |
44 | #elif defined(Q_OS_MACX) | 44 | #elif defined(Q_OS_MACX) |
45 | #include <unistd.h> | 45 | #include <unistd.h> |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | 48 | ||
49 | PackageHandler::PackageHandler( QObject *parent, char* name ) | 49 | PackageHandler::PackageHandler( QObject *parent, char* name ) |
50 | : QObject( parent, name ), packageChannel( 0 ), currentProcess( 0 ), mNoSpaceLeft( FALSE ) | 50 | : QObject( parent, name ), packageChannel( 0 ), currentProcess( 0 ), mNoSpaceLeft( FALSE ) |
51 | { | 51 | { |
52 | // setup qcop channel | 52 | // setup qcop channel |
53 | #ifndef QT_NO_COP | 53 | #ifndef QT_NO_COP |
54 | packageChannel = new QCopChannel( "QPE/Package", this ); | 54 | packageChannel = new QCopChannel( "QPE/Package", this ); |
55 | connect( packageChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 55 | connect( packageChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
56 | this, SLOT( qcopMessage(const QCString&,const QByteArray&) ) ); | 56 | this, SLOT( qcopMessage(const QCString&,const QByteArray&) ) ); |
57 | #endif | 57 | #endif |
58 | } | 58 | } |
59 | 59 | ||
60 | void PackageHandler::qcopMessage( const QCString &msg, const QByteArray &data ) | 60 | void PackageHandler::qcopMessage( const QCString &msg, const QByteArray &data ) |
61 | { | 61 | { |
62 | QDataStream stream( data, IO_ReadOnly ); | 62 | QDataStream stream( data, IO_ReadOnly ); |
63 | 63 | ||
64 | if ( msg == "installPackage(QString)" ) { | 64 | if ( msg == "installPackage(QString)" ) { |
65 | QString file; | 65 | QString file; |
66 | stream >> file; | 66 | stream >> file; |
67 | installPackage( file ); | 67 | installPackage( file ); |
68 | } else if ( msg == "installPackage(QString,QString)" ) { | ||
69 | QString file, dest; | ||
70 | stream >> file >> dest; | ||
71 | installPackage( file, dest ); | ||
68 | } else if ( msg == "removePackage(QString)" ) { | 72 | } else if ( msg == "removePackage(QString)" ) { |
69 | QString file; | 73 | QString file; |
70 | stream >> file; | 74 | stream >> file; |
71 | removePackage( file ); | 75 | removePackage( file ); |
72 | } else if ( msg == "addPackageFiles(QString,QString)" ) { | 76 | } else if ( msg == "addPackageFiles(QString,QString)" ) { |
73 | QString location, listfile; | 77 | QString location, listfile; |
74 | stream >> location >> listfile; | 78 | stream >> location >> listfile; |
75 | addPackageFiles( location, listfile); | 79 | addPackageFiles( location, listfile); |
76 | } else if ( msg == "addPackages(QString)" ) { | 80 | } else if ( msg == "addPackages(QString)" ) { |
77 | QString location; | 81 | QString location; |
78 | stream >> location; | 82 | stream >> location; |
79 | addPackages( location ); | 83 | addPackages( location ); |
80 | } else if ( msg == "cleanupPackageFiles(QString)" ) { | 84 | } else if ( msg == "cleanupPackageFiles(QString)" ) { |
81 | QString listfile; | 85 | QString listfile; |
82 | stream >> listfile; | 86 | stream >> listfile; |
83 | cleanupPackageFiles( listfile ); | 87 | cleanupPackageFiles( listfile ); |
84 | } else if ( msg == "cleanupPackages(QString)" ) { | 88 | } else if ( msg == "cleanupPackages(QString)" ) { |
85 | QString location; | 89 | QString location; |
86 | stream >> location; | 90 | stream >> location; |
87 | cleanupPackages( location ); | 91 | cleanupPackages( location ); |
88 | } else if ( msg == "prepareInstall(QString,QString)" ) { | 92 | } else if ( msg == "prepareInstall(QString,QString)" ) { |
89 | QString size, path; | 93 | QString size, path; |
90 | stream >> size; | 94 | stream >> size; |
91 | stream >> path; | 95 | stream >> path; |
92 | prepareInstall( size, path ); | 96 | prepareInstall( size, path ); |
93 | } | 97 | } |
94 | } | 98 | } |
95 | 99 | ||
96 | void PackageHandler::installPackage( const QString &package ) | 100 | void PackageHandler::installPackage( const QString &package, const QString &dest ) |
97 | { | 101 | { |
98 | if ( mNoSpaceLeft ) { | 102 | if ( mNoSpaceLeft ) { |
99 | mNoSpaceLeft = FALSE; | 103 | mNoSpaceLeft = FALSE; |
100 | // Don't emit that for now, I still couldn't test it (Wener) | 104 | // Don't emit that for now, I still couldn't test it (Wener) |
101 | //sendReply( "installFailed(QString)", package ); | 105 | //sendReply( "installFailed(QString)", package ); |
102 | //return; | 106 | //return; |
103 | } | 107 | } |
104 | 108 | ||
105 | currentProcess = new QProcess( QStringList() << "ipkg" << "install" << package ); // No tr | 109 | QStringList cmd; |
110 | cmd << "ipkg"; | ||
111 | if ( !dest.isEmpty() ) { | ||
112 | cmd << "-d" << dest; | ||
113 | } | ||
114 | cmd << "install" << package; | ||
115 | currentProcess = new QProcess( cmd ); // No tr | ||
106 | connect( currentProcess, SIGNAL( processExited() ), SLOT( iProcessExited() ) ); | 116 | connect( currentProcess, SIGNAL( processExited() ), SLOT( iProcessExited() ) ); |
107 | connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); | 117 | connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); |
108 | connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); | 118 | connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); |
109 | currentPackage = package; | 119 | currentPackage = package; |
110 | 120 | ||
111 | currentProcessError=""; | 121 | currentProcessError=""; |
112 | sendReply( "installStarted(QString)", package ); | 122 | sendReply( "installStarted(QString)", package ); |
113 | currentProcess->start(); | 123 | currentProcess->start(); |
114 | } | 124 | } |
115 | 125 | ||
116 | void PackageHandler::removePackage( const QString &package ) | 126 | void PackageHandler::removePackage( const QString &package ) |
117 | { | 127 | { |
118 | currentProcess = new QProcess( QStringList() << "ipkg" << "remove" << package ); // No tr | 128 | currentProcess = new QProcess( QStringList() << "ipkg" << "remove" << package ); // No tr |
119 | connect( currentProcess, SIGNAL( processExited() ), SLOT( rmProcessExited() ) ); | 129 | connect( currentProcess, SIGNAL( processExited() ), SLOT( rmProcessExited() ) ); |
120 | connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); | 130 | connect( currentProcess, SIGNAL( readyReadStdout() ), SLOT( readyReadStdout() ) ); |
121 | connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); | 131 | connect( currentProcess, SIGNAL( readyReadStderr() ), SLOT( readyReadStderr() ) ); |
122 | currentPackage = package; | 132 | currentPackage = package; |
123 | 133 | ||
124 | currentProcessError=""; | 134 | currentProcessError=""; |
125 | sendReply( "removeStarted(QString)", package ); | 135 | sendReply( "removeStarted(QString)", package ); |
126 | currentProcess->start(); | 136 | currentProcess->start(); |
127 | } | 137 | } |
128 | 138 | ||
129 | void PackageHandler::sendReply( const QCString& msg, const QString& arg ) | 139 | void PackageHandler::sendReply( const QCString& msg, const QString& arg ) |
130 | { | 140 | { |
131 | #ifndef QT_NO_COP | 141 | #ifndef QT_NO_COP |
132 | QCopEnvelope e( "QPE/Desktop", msg ); | 142 | QCopEnvelope e( "QPE/Desktop", msg ); |
133 | e << arg; | 143 | e << arg; |
134 | #endif | 144 | #endif |
135 | } | 145 | } |
136 | 146 | ||
137 | void PackageHandler::addPackageFiles( const QString &location, | 147 | void PackageHandler::addPackageFiles( const QString &location, |
138 | const QString &listfile ) | 148 | const QString &listfile ) |
139 | { | 149 | { |
140 | QFile f(listfile); | 150 | QFile f(listfile); |
141 | #ifndef Q_OS_WIN32 | 151 | #ifndef Q_OS_WIN32 |
142 | //make a copy so we can remove the symlinks later | 152 | //make a copy so we can remove the symlinks later |
143 | mkdir( ("/usr/lib/ipkg/info/"+location).ascii(), 0777 ); | 153 | mkdir( ("/usr/lib/ipkg/info/"+location).ascii(), 0777 ); |
144 | system(("cp " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); | 154 | system(("cp " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); |
145 | #else | 155 | #else |
146 | QDir d; | 156 | QDir d; |
147 | //#### revise | 157 | //#### revise |
148 | odebug << "Copy file at " << __FILE__ << ": " << __LINE__ << "" << oendl; | 158 | odebug << "Copy file at " << __FILE__ << ": " << __LINE__ << "" << oendl; |
149 | d.mkdir(("/usr/lib/ipkg/info/" + location).ascii()); | 159 | d.mkdir(("/usr/lib/ipkg/info/" + location).ascii()); |
150 | system(("copy " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); | 160 | system(("copy " + f.name() + " /usr/lib/ipkg/info/"+location).ascii()); |
151 | #endif | 161 | #endif |
152 | 162 | ||
153 | 163 | ||