author | drw <drw> | 2004-01-13 21:46:50 (UTC) |
---|---|---|
committer | drw <drw> | 2004-01-13 21:46:50 (UTC) |
commit | 4dae04411e1cd75237b89dee6b5d6ba74089505d (patch) (unidiff) | |
tree | 1704e1ec9dc235817436568fd9354824c3279a7e | |
parent | 4a48472bbe915852ed6eaa66284b8b8c0f3b493d (diff) | |
download | opie-4dae04411e1cd75237b89dee6b5d6ba74089505d.zip opie-4dae04411e1cd75237b89dee6b5d6ba74089505d.tar.gz opie-4dae04411e1cd75237b89dee6b5d6ba74089505d.tar.bz2 |
Add .cvsignore and fix sigsev when updating and upgrading
-rw-r--r-- | noncore/settings/packagemanager/.cvsignore | 3 | ||||
-rw-r--r-- | noncore/settings/packagemanager/installdlg.cpp | 7 |
2 files changed, 8 insertions, 2 deletions
diff --git a/noncore/settings/packagemanager/.cvsignore b/noncore/settings/packagemanager/.cvsignore new file mode 100644 index 0000000..4183697 --- a/dev/null +++ b/noncore/settings/packagemanager/.cvsignore | |||
@@ -0,0 +1,3 @@ | |||
1 | Makefile* | ||
2 | moc* | ||
3 | .moc* | ||
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp index c0c03fc..980d5eb 100644 --- a/noncore/settings/packagemanager/installdlg.cpp +++ b/noncore/settings/packagemanager/installdlg.cpp | |||
@@ -72,235 +72,238 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap | |||
72 | ++m_numCommands; | 72 | ++m_numCommands; |
73 | } | 73 | } |
74 | if ( command3 != OPackage::NotDefined ) | 74 | if ( command3 != OPackage::NotDefined ) |
75 | { | 75 | { |
76 | m_command[ m_numCommands ] = command3; | 76 | m_command[ m_numCommands ] = command3; |
77 | m_packages[ m_numCommands ] = packages3; | 77 | m_packages[ m_numCommands ] = packages3; |
78 | ++m_numCommands; | 78 | ++m_numCommands; |
79 | } | 79 | } |
80 | 80 | ||
81 | // Initialize UI | 81 | // Initialize UI |
82 | if ( parent ) | 82 | if ( parent ) |
83 | parent->setCaption( caption ); | 83 | parent->setCaption( caption ); |
84 | 84 | ||
85 | QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 ); | 85 | QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 ); |
86 | 86 | ||
87 | if ( showDestInfo ) | 87 | if ( showDestInfo ) |
88 | { | 88 | { |
89 | QLabel *label = new QLabel( tr( "Destination" ), this ); | 89 | QLabel *label = new QLabel( tr( "Destination" ), this ); |
90 | layout->addWidget( label, 0, 0 ); | 90 | layout->addWidget( label, 0, 0 ); |
91 | m_destination = new QComboBox( this ); | 91 | m_destination = new QComboBox( this ); |
92 | m_destination->insertStringList( *(m_packman->destinations()) ); | 92 | m_destination->insertStringList( *(m_packman->destinations()) ); |
93 | layout->addWidget( m_destination, 0, 1 ); | 93 | layout->addWidget( m_destination, 0, 1 ); |
94 | connect( m_destination, SIGNAL(highlighted(const QString&)), | 94 | connect( m_destination, SIGNAL(highlighted(const QString&)), |
95 | this, SLOT(slotDisplayAvailSpace(const QString&)) ); | 95 | this, SLOT(slotDisplayAvailSpace(const QString&)) ); |
96 | 96 | ||
97 | label = new QLabel( tr( "Space Avail" ), this ); | 97 | label = new QLabel( tr( "Space Avail" ), this ); |
98 | layout->addWidget( label, 1, 0 ); | 98 | layout->addWidget( label, 1, 0 ); |
99 | m_availSpace = new QLabel( this ); | 99 | m_availSpace = new QLabel( this ); |
100 | layout->addWidget( m_availSpace, 1, 1 ); | 100 | layout->addWidget( m_availSpace, 1, 1 ); |
101 | 101 | ||
102 | // TODO - select correct destination | 102 | // TODO - select correct destination |
103 | slotDisplayAvailSpace( m_destination->currentText() ); | 103 | slotDisplayAvailSpace( m_destination->currentText() ); |
104 | } | 104 | } |
105 | else | 105 | else |
106 | { | 106 | { |
107 | m_destination = 0x0; | 107 | m_destination = 0x0; |
108 | m_availSpace = 0x0; | 108 | m_availSpace = 0x0; |
109 | } | 109 | } |
110 | 110 | ||
111 | QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); | 111 | QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); |
112 | groupBox->layout()->setSpacing( 0 ); | 112 | groupBox->layout()->setSpacing( 0 ); |
113 | groupBox->layout()->setMargin( 4 ); | 113 | groupBox->layout()->setMargin( 4 ); |
114 | 114 | ||
115 | QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); | 115 | QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); |
116 | m_output = new QMultiLineEdit( groupBox ); | 116 | m_output = new QMultiLineEdit( groupBox ); |
117 | m_output->setReadOnly( true ); | 117 | m_output->setReadOnly( true ); |
118 | groupBoxLayout->addWidget( m_output ); | 118 | groupBoxLayout->addWidget( m_output ); |
119 | layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); | 119 | layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); |
120 | 120 | ||
121 | m_btnStart = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Start" ), this ); | 121 | m_btnStart = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Start" ), this ); |
122 | layout->addWidget( m_btnStart, 3, 0 ); | 122 | layout->addWidget( m_btnStart, 3, 0 ); |
123 | connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) ); | 123 | connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) ); |
124 | 124 | ||
125 | m_btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); | 125 | m_btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); |
126 | layout->addWidget( m_btnOptions, 3, 1 ); | 126 | layout->addWidget( m_btnOptions, 3, 1 ); |
127 | connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) ); | 127 | connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) ); |
128 | 128 | ||
129 | // Display packages being acted upon in output widget | 129 | // Display packages being acted upon in output widget |
130 | for( int i = 0; i < m_numCommands; i++ ) | 130 | for( int i = 0; i < m_numCommands; i++ ) |
131 | { | 131 | { |
132 | if ( m_packages[ i ] ) | 132 | if ( m_packages[ i ] ) |
133 | { | 133 | { |
134 | QString lineStr = tr( "Packages to " ); | 134 | QString lineStr = tr( "Packages to " ); |
135 | 135 | ||
136 | switch( m_command[ i ] ) | 136 | switch( m_command[ i ] ) |
137 | { | 137 | { |
138 | case OPackage::Install : lineStr.append( tr( "install" ) ); | 138 | case OPackage::Install : lineStr.append( tr( "install" ) ); |
139 | break; | 139 | break; |
140 | case OPackage::Remove : lineStr.append( tr( "remove" ) ); | 140 | case OPackage::Remove : lineStr.append( tr( "remove" ) ); |
141 | break; | 141 | break; |
142 | case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) ); | 142 | case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) ); |
143 | break; | 143 | break; |
144 | default : | 144 | default : |
145 | break; | 145 | break; |
146 | }; | 146 | }; |
147 | lineStr.append( ":\n" ); | 147 | lineStr.append( ":\n" ); |
148 | 148 | ||
149 | for ( QStringList::Iterator it = m_packages[ i ]->begin(); it != m_packages[ i ]->end(); ++it ) | 149 | for ( QStringList::Iterator it = m_packages[ i ]->begin(); it != m_packages[ i ]->end(); ++it ) |
150 | { | 150 | { |
151 | lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) ); | 151 | lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) ); |
152 | } | 152 | } |
153 | 153 | ||
154 | m_output->append( lineStr ); | 154 | m_output->append( lineStr ); |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | m_output->append( tr( "Press the start button to begin.\n" ) ); | 158 | m_output->append( tr( "Press the start button to begin.\n" ) ); |
159 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 159 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
160 | 160 | ||
161 | } | 161 | } |
162 | 162 | ||
163 | InstallDlg::~InstallDlg() | 163 | InstallDlg::~InstallDlg() |
164 | { | 164 | { |
165 | for( int i = 0; i < m_numCommands; i++ ) | 165 | for( int i = 0; i < m_numCommands; i++ ) |
166 | { | 166 | { |
167 | if ( m_packages[ i ] ) | 167 | if ( m_packages[ i ] ) |
168 | delete m_packages[ i ]; | 168 | delete m_packages[ i ]; |
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
172 | void InstallDlg::slotDisplayAvailSpace( const QString &destination ) | 172 | void InstallDlg::slotDisplayAvailSpace( const QString &destination ) |
173 | { | 173 | { |
174 | // If available space is not displayed, exit | 174 | // If available space is not displayed, exit |
175 | if ( !m_availSpace ) | 175 | if ( !m_availSpace ) |
176 | return; | 176 | return; |
177 | 177 | ||
178 | QString space = tr( "Unknown" ); | 178 | QString space = tr( "Unknown" ); |
179 | 179 | ||
180 | // Get destination | 180 | // Get destination |
181 | OConfItem *dest = m_packman->findConfItem( OConfItem::Destination, destination ); | 181 | OConfItem *dest = m_packman->findConfItem( OConfItem::Destination, destination ); |
182 | 182 | ||
183 | if ( dest ) | 183 | if ( dest ) |
184 | { | 184 | { |
185 | // Calculate available space | 185 | // Calculate available space |
186 | struct statfs fs; | 186 | struct statfs fs; |
187 | if ( !statfs( dest->value(), &fs ) ) | 187 | if ( !statfs( dest->value(), &fs ) ) |
188 | { | 188 | { |
189 | long mult = fs.f_bsize / 1024; | 189 | long mult = fs.f_bsize / 1024; |
190 | long div = 1024 / fs.f_bsize; | 190 | long div = 1024 / fs.f_bsize; |
191 | 191 | ||
192 | if ( !mult ) mult = 1; | 192 | if ( !mult ) mult = 1; |
193 | if ( !div ) div = 1; | 193 | if ( !div ) div = 1; |
194 | long avail = fs.f_bavail * mult / div; | 194 | long avail = fs.f_bavail * mult / div; |
195 | 195 | ||
196 | space = tr( "%1 Kb" ).arg( avail ); | 196 | space = tr( "%1 Kb" ).arg( avail ); |
197 | } | 197 | } |
198 | } | 198 | } |
199 | 199 | ||
200 | // Display available space (if known) | 200 | // Display available space |
201 | m_availSpace->setText( space ); | 201 | m_availSpace->setText( space ); |
202 | } | 202 | } |
203 | 203 | ||
204 | void InstallDlg::slotBtnStart() | 204 | void InstallDlg::slotBtnStart() |
205 | { | 205 | { |
206 | QString btnText = m_btnStart->text(); | 206 | QString btnText = m_btnStart->text(); |
207 | if ( btnText == tr( "Abort" ) ) | 207 | if ( btnText == tr( "Abort" ) ) |
208 | { | 208 | { |
209 | // Stop execution of current command and prevent any others from executing | 209 | // Stop execution of current command and prevent any others from executing |
210 | m_packman->abortCommand(); | 210 | m_packman->abortCommand(); |
211 | m_currCommand = 999; | 211 | m_currCommand = 999; |
212 | 212 | ||
213 | // Allow user to close dialog | 213 | // Allow user to close dialog |
214 | m_btnStart->setText( tr( "Close" ) ); | 214 | m_btnStart->setText( tr( "Close" ) ); |
215 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); | 215 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); |
216 | return; | 216 | return; |
217 | } | 217 | } |
218 | else if ( btnText == tr( "Close" ) ) | 218 | else if ( btnText == tr( "Close" ) ) |
219 | { | 219 | { |
220 | // TODO - force reload of package data | 220 | // TODO - force reload of package data |
221 | emit closeInstallDlg(); | 221 | emit closeInstallDlg(); |
222 | return; | 222 | return; |
223 | } | 223 | } |
224 | 224 | ||
225 | // Start was clicked, execute first command | 225 | // Start was clicked, execute first command |
226 | m_btnOptions->setEnabled( false ); | 226 | m_btnOptions->setEnabled( false ); |
227 | m_btnStart->setText( tr( "Abort" ) ); | 227 | m_btnStart->setText( tr( "Abort" ) ); |
228 | m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); | 228 | m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); |
229 | 229 | ||
230 | m_packman->executeCommand( m_command[ 0 ], m_packages[ 0 ], m_destination->currentText(), this, | 230 | QString dest; |
231 | if ( m_destination ) | ||
232 | dest = m_destination->currentText(); | ||
233 | m_packman->executeCommand( m_command[ 0 ], m_packages[ 0 ], dest, this, | ||
231 | SLOT(slotOutput(OProcess*,char*,int)), SLOT(slotErrors(OProcess*,char*,int)), | 234 | SLOT(slotOutput(OProcess*,char*,int)), SLOT(slotErrors(OProcess*,char*,int)), |
232 | SLOT(slotFinished(OProcess*)), true ); | 235 | SLOT(slotFinished(OProcess*)), true ); |
233 | } | 236 | } |
234 | 237 | ||
235 | void InstallDlg::slotBtnOptions() | 238 | void InstallDlg::slotBtnOptions() |
236 | { | 239 | { |
237 | QString btnText = m_btnOptions->text(); | 240 | QString btnText = m_btnOptions->text(); |
238 | if ( btnText == tr( "Options" ) ) | 241 | if ( btnText == tr( "Options" ) ) |
239 | { | 242 | { |
240 | // Display configuration dialog (only options tab is enabled) | 243 | // Display configuration dialog (only options tab is enabled) |
241 | m_packman->configureDlg( true ); | 244 | m_packman->configureDlg( true ); |
242 | return; | 245 | return; |
243 | } | 246 | } |
244 | 247 | ||
245 | // Save output was clicked | 248 | // Save output was clicked |
246 | QMap<QString, QStringList> map; | 249 | QMap<QString, QStringList> map; |
247 | map.insert( tr( "All" ), QStringList() ); | 250 | map.insert( tr( "All" ), QStringList() ); |
248 | QStringList text; | 251 | QStringList text; |
249 | text << "text/*"; | 252 | text << "text/*"; |
250 | map.insert(tr( "Text" ), text ); | 253 | map.insert(tr( "Text" ), text ); |
251 | text << "*"; | 254 | text << "*"; |
252 | map.insert( tr( "All" ), text ); | 255 | map.insert( tr( "All" ), text ); |
253 | 256 | ||
254 | QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); | 257 | QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); |
255 | if( !filename.isEmpty() ) | 258 | if( !filename.isEmpty() ) |
256 | { | 259 | { |
257 | QString currentFileName = QFileInfo( filename ).fileName(); | 260 | QString currentFileName = QFileInfo( filename ).fileName(); |
258 | DocLnk doc; | 261 | DocLnk doc; |
259 | doc.setType( "text/plain" ); | 262 | doc.setType( "text/plain" ); |
260 | doc.setFile( filename ); | 263 | doc.setFile( filename ); |
261 | doc.setName( currentFileName ); | 264 | doc.setName( currentFileName ); |
262 | FileManager fm; | 265 | FileManager fm; |
263 | fm.saveFile( doc, m_output->text() ); | 266 | fm.saveFile( doc, m_output->text() ); |
264 | } | 267 | } |
265 | } | 268 | } |
266 | 269 | ||
267 | void InstallDlg::slotOutput( OProcess */*process*/, char *buffer, int buffLen ) | 270 | void InstallDlg::slotOutput( OProcess */*process*/, char *buffer, int buffLen ) |
268 | { | 271 | { |
269 | QString lineStr = buffer; | 272 | QString lineStr = buffer; |
270 | if ( lineStr[buffLen-1] == '\n' ) | 273 | if ( lineStr[buffLen-1] == '\n' ) |
271 | lineStr.truncate( buffLen - 1 ); | 274 | lineStr.truncate( buffLen - 1 ); |
272 | m_output->append( lineStr ); | 275 | m_output->append( lineStr ); |
273 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 276 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
274 | } | 277 | } |
275 | 278 | ||
276 | void InstallDlg::slotErrors( OProcess */*process*/, char *buffer, int buffLen ) | 279 | void InstallDlg::slotErrors( OProcess */*process*/, char *buffer, int buffLen ) |
277 | { | 280 | { |
278 | QString lineStr = buffer; | 281 | QString lineStr = buffer; |
279 | if ( lineStr[buffLen-1] == '\n' ) | 282 | if ( lineStr[buffLen-1] == '\n' ) |
280 | lineStr.truncate( buffLen - 1 ); | 283 | lineStr.truncate( buffLen - 1 ); |
281 | m_output->append( lineStr ); | 284 | m_output->append( lineStr ); |
282 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 285 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
283 | } | 286 | } |
284 | 287 | ||
285 | void InstallDlg::slotFinished( OProcess */*process*/ ) | 288 | void InstallDlg::slotFinished( OProcess */*process*/ ) |
286 | { | 289 | { |
287 | ++m_currCommand; | 290 | ++m_currCommand; |
288 | if ( m_currCommand < m_numCommands ) | 291 | if ( m_currCommand < m_numCommands ) |
289 | { | 292 | { |
290 | // More commands left, execute next one | 293 | // More commands left, execute next one |
291 | m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], m_destination->currentText(), | 294 | m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], m_destination->currentText(), |
292 | this, SLOT(slotOutput(OProcess*,char*,int)), | 295 | this, SLOT(slotOutput(OProcess*,char*,int)), |
293 | SLOT(slotErrors(OProcess*,char*,int)), | 296 | SLOT(slotErrors(OProcess*,char*,int)), |
294 | SLOT(slotFinished(OProcess*)), true ); | 297 | SLOT(slotFinished(OProcess*)), true ); |
295 | } | 298 | } |
296 | else | 299 | else |
297 | { | 300 | { |
298 | // All commands executed, allow user to close dialog | 301 | // All commands executed, allow user to close dialog |
299 | m_btnStart->setText( tr( "Close" ) ); | 302 | m_btnStart->setText( tr( "Close" ) ); |
300 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); | 303 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); |
301 | 304 | ||
302 | m_btnOptions->setEnabled( true ); | 305 | m_btnOptions->setEnabled( true ); |
303 | m_btnOptions->setText( tr( "Save output" ) ); | 306 | m_btnOptions->setText( tr( "Save output" ) ); |
304 | m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); | 307 | m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); |
305 | } | 308 | } |
306 | } | 309 | } |