-rw-r--r-- | noncore/settings/packagemanager/installdlg.cpp | 61 | ||||
-rw-r--r-- | noncore/settings/packagemanager/installdlg.h | 12 | ||||
-rw-r--r-- | noncore/settings/packagemanager/mainwindow.cpp | 2 |
3 files changed, 62 insertions, 13 deletions
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp index 945dfed..781f8f5 100644 --- a/noncore/settings/packagemanager/installdlg.cpp +++ b/noncore/settings/packagemanager/installdlg.cpp | |||
@@ -30,6 +30,7 @@ _;:, .> :=|. This file is free software; you can | |||
30 | #include "installdlg.h" | 30 | #include "installdlg.h" |
31 | 31 | ||
32 | #include <opie2/ofiledialog.h> | 32 | #include <opie2/ofiledialog.h> |
33 | #include <opie2/oprocess.h> | ||
33 | 34 | ||
34 | #include <qpe/fileselector.h> | 35 | #include <qpe/fileselector.h> |
35 | #include <qpe/resource.h> | 36 | #include <qpe/resource.h> |
@@ -57,6 +58,7 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap | |||
57 | , m_packman( pm ) | 58 | , m_packman( pm ) |
58 | , m_numCommands( 0 ) | 59 | , m_numCommands( 0 ) |
59 | , m_currCommand( 0 ) | 60 | , m_currCommand( 0 ) |
61 | , m_destItem( 0x0 ) | ||
60 | { | 62 | { |
61 | // Save command/package list information | 63 | // Save command/package list information |
62 | if ( command1 != OPackage::NotDefined ) | 64 | if ( command1 != OPackage::NotDefined ) |
@@ -163,10 +165,6 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap | |||
163 | 165 | ||
164 | } | 166 | } |
165 | 167 | ||
166 | InstallDlg::~InstallDlg() | ||
167 | { | ||
168 | } | ||
169 | |||
170 | void InstallDlg::slotDisplayAvailSpace( const QString &destination ) | 168 | void InstallDlg::slotDisplayAvailSpace( const QString &destination ) |
171 | { | 169 | { |
172 | // If available space is not displayed, exit | 170 | // If available space is not displayed, exit |
@@ -176,13 +174,14 @@ void InstallDlg::slotDisplayAvailSpace( const QString &destination ) | |||
176 | QString space = tr( "Unknown" ); | 174 | QString space = tr( "Unknown" ); |
177 | 175 | ||
178 | // Get destination | 176 | // Get destination |
179 | OConfItem *dest = m_packman->findConfItem( OConfItem::Destination, destination ); | 177 | if ( !destination.isNull() ) |
178 | m_destItem = m_packman->findConfItem( OConfItem::Destination, destination ); | ||
180 | 179 | ||
181 | if ( dest ) | 180 | if ( m_destItem ) |
182 | { | 181 | { |
183 | // Calculate available space | 182 | // Calculate available space |
184 | struct statfs fs; | 183 | struct statfs fs; |
185 | if ( !statfs( dest->value(), &fs ) ) | 184 | if ( !statfs( m_destItem->value(), &fs ) ) |
186 | { | 185 | { |
187 | long mult = fs.f_bsize / 1024; | 186 | long mult = fs.f_bsize / 1024; |
188 | long div = 1024 / fs.f_bsize; | 187 | long div = 1024 / fs.f_bsize; |
@@ -220,6 +219,13 @@ void InstallDlg::slotBtnStart() | |||
220 | } | 219 | } |
221 | 220 | ||
222 | // Start was clicked, start executing | 221 | // Start was clicked, start executing |
222 | QString dest; | ||
223 | if ( m_destination ) | ||
224 | { | ||
225 | dest = m_destination->currentText(); | ||
226 | m_destination->setEnabled( false ); | ||
227 | } | ||
228 | |||
223 | m_btnOptions->setEnabled( false ); | 229 | m_btnOptions->setEnabled( false ); |
224 | if ( m_numCommands > 1 ) | 230 | if ( m_numCommands > 1 ) |
225 | { | 231 | { |
@@ -231,16 +237,46 @@ void InstallDlg::slotBtnStart() | |||
231 | m_btnStart->setEnabled( false ); | 237 | m_btnStart->setEnabled( false ); |
232 | } | 238 | } |
233 | 239 | ||
234 | QString dest; | ||
235 | if ( m_destination ) | ||
236 | dest = m_destination->currentText(); | ||
237 | |||
238 | for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) | 240 | for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) |
239 | { | 241 | { |
240 | // Execute next command | 242 | // Execute next command |
241 | m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, | 243 | m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, |
242 | this, SLOT(slotOutput(char*)), true ); | 244 | this, SLOT(slotOutput(char*)), true ); |
243 | } | 245 | } |
246 | slotProcessDone(0l); | ||
247 | |||
248 | // Get destination | ||
249 | /* | ||
250 | if ( dest == "root" ) | ||
251 | { | ||
252 | slotProcessDone(0l); | ||
253 | return; | ||
254 | } | ||
255 | |||
256 | m_destItem = m_packman->findConfItem( OConfItem::Destination, dest ); | ||
257 | if ( m_destItem ) | ||
258 | { | ||
259 | QString path = m_destItem->value(); | ||
260 | Opie::Core::OProcess *process = new Opie::Core::OProcess( this, "ipkg-link process" ); | ||
261 | connect( process, SIGNAL(processExited(Opie::Core::OProcess*)), | ||
262 | this, SLOT(slotProcessDone(Opie::Core::OProcess*)) ); | ||
263 | |||
264 | *process << "ipkg-link" << "mount" << path; | ||
265 | if ( !process->start( Opie::Core::OProcess::NotifyOnExit, | ||
266 | Opie::Core::OProcess::NoCommunication ) ) | ||
267 | slotProcessDone( 0l ); | ||
268 | m_output->append( tr( "Starting ipkg-link to link installed applications." ) ); | ||
269 | m_output->setCursorPosition( m_output->numLines(), 0 ); | ||
270 | } | ||
271 | */ | ||
272 | } | ||
273 | |||
274 | void InstallDlg::slotProcessDone( Opie::Core::OProcess *proc ) | ||
275 | { | ||
276 | delete proc; | ||
277 | |||
278 | m_output->append( tr( "The package linking is done." ) ); | ||
279 | m_output->setCursorPosition( m_output->numLines(), 0 ); | ||
244 | 280 | ||
245 | // All commands executed, allow user to close dialog | 281 | // All commands executed, allow user to close dialog |
246 | m_btnStart->setEnabled( true ); | 282 | m_btnStart->setEnabled( true ); |
@@ -294,4 +330,7 @@ void InstallDlg::slotOutput( char *msg ) | |||
294 | lineStr.truncate( lineStr.length() - 1 ); | 330 | lineStr.truncate( lineStr.length() - 1 ); |
295 | m_output->append( lineStr ); | 331 | m_output->append( lineStr ); |
296 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 332 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
333 | |||
334 | // Update available space | ||
335 | slotDisplayAvailSpace( QString::null ); | ||
297 | } | 336 | } |
diff --git a/noncore/settings/packagemanager/installdlg.h b/noncore/settings/packagemanager/installdlg.h index cddc911..f45c17c 100644 --- a/noncore/settings/packagemanager/installdlg.h +++ b/noncore/settings/packagemanager/installdlg.h | |||
@@ -39,8 +39,17 @@ class QLabel; | |||
39 | class QMultiLineEdit; | 39 | class QMultiLineEdit; |
40 | class QPushButton; | 40 | class QPushButton; |
41 | 41 | ||
42 | class OConfItem; | ||
42 | class OPackageManager; | 43 | class OPackageManager; |
43 | 44 | ||
45 | namespace Opie | ||
46 | { | ||
47 | namespace Core | ||
48 | { | ||
49 | class OProcess; | ||
50 | } | ||
51 | } | ||
52 | |||
44 | class InstallDlg : public QWidget | 53 | class InstallDlg : public QWidget |
45 | { | 54 | { |
46 | Q_OBJECT | 55 | Q_OBJECT |
@@ -54,7 +63,6 @@ public: | |||
54 | const QStringList &packages2 = QStringList(), | 63 | const QStringList &packages2 = QStringList(), |
55 | OPackage::Command command3 = OPackage::NotDefined, | 64 | OPackage::Command command3 = OPackage::NotDefined, |
56 | const QStringList &packages3 = QStringList() ); | 65 | const QStringList &packages3 = QStringList() ); |
57 | ~InstallDlg(); | ||
58 | 66 | ||
59 | private: | 67 | private: |
60 | OPackageManager *m_packman; // Pointer to application instance of package manager | 68 | OPackageManager *m_packman; // Pointer to application instance of package manager |
@@ -71,12 +79,14 @@ private: | |||
71 | int m_currCommand; // Number of currently executing command | 79 | int m_currCommand; // Number of currently executing command |
72 | OPackage::Command m_command[3]; // List of commands to be executed | 80 | OPackage::Command m_command[3]; // List of commands to be executed |
73 | QStringList m_packages[3]; // Lists of package names associated to commands (m_command[]) | 81 | QStringList m_packages[3]; // Lists of package names associated to commands (m_command[]) |
82 | OConfItem *m_destItem; // Pointer to destination for package installation | ||
74 | 83 | ||
75 | private slots: | 84 | private slots: |
76 | // UI control slots | 85 | // UI control slots |
77 | void slotDisplayAvailSpace( const QString &destination ); | 86 | void slotDisplayAvailSpace( const QString &destination ); |
78 | void slotBtnStart(); | 87 | void slotBtnStart(); |
79 | void slotBtnOptions(); | 88 | void slotBtnOptions(); |
89 | void slotProcessDone( Opie::Core::OProcess *proc ); | ||
80 | 90 | ||
81 | // Execution slots | 91 | // Execution slots |
82 | void slotOutput( char *msg ); | 92 | void slotOutput( char *msg ); |
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp index 5e15874..459a75b 100644 --- a/noncore/settings/packagemanager/mainwindow.cpp +++ b/noncore/settings/packagemanager/mainwindow.cpp | |||
@@ -531,7 +531,7 @@ void MainWindow::slotApply() | |||
531 | upgradeCmd = OPackage::Upgrade; | 531 | upgradeCmd = OPackage::Upgrade; |
532 | 532 | ||
533 | // Create package manager output widget | 533 | // Create package manager output widget |
534 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true, | 534 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), !installList.isEmpty(), |
535 | removeCmd, removeList, | 535 | removeCmd, removeList, |
536 | installCmd, installList, | 536 | installCmd, installList, |
537 | upgradeCmd, upgradeList ); | 537 | upgradeCmd, upgradeList ); |