-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index 318b26d..3ce7960 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp | |||
@@ -1,346 +1,352 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | networkpkgmgr.cpp - description | 2 | networkpkgmgr.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Mon Aug 26 13:32:30 BST 2002 | 4 | begin : Mon Aug 26 13:32:30 BST 2002 |
5 | copyright : (C) 2002 by Andy Qua | 5 | copyright : (C) 2002 by Andy Qua |
6 | email : andy.qua@blueyonder.co.uk | 6 | email : andy.qua@blueyonder.co.uk |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include <fstream> | 18 | #include <fstream> |
19 | #include <iostream> | 19 | #include <iostream> |
20 | using namespace std; | 20 | using namespace std; |
21 | 21 | ||
22 | #include <unistd.h> | 22 | #include <unistd.h> |
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <linux/limits.h> | 24 | #include <linux/limits.h> |
25 | 25 | ||
26 | #ifdef QWS | 26 | #ifdef QWS |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qpe/qcopenvelope_qws.h> | 28 | #include <qpe/qcopenvelope_qws.h> |
29 | #include <qpe/config.h> | 29 | #include <qpe/config.h> |
30 | #else | 30 | #else |
31 | #include <qapplication.h> | 31 | #include <qapplication.h> |
32 | #endif | 32 | #endif |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | 36 | ||
37 | #include "datamgr.h" | 37 | #include "datamgr.h" |
38 | #include "networkpkgmgr.h" | 38 | #include "networkpkgmgr.h" |
39 | #include "installdlgimpl.h" | 39 | #include "installdlgimpl.h" |
40 | #include "ipkg.h" | 40 | #include "ipkg.h" |
41 | #include "inputdlg.h" | 41 | #include "inputdlg.h" |
42 | #include "letterpushbutton.h" | 42 | #include "letterpushbutton.h" |
43 | 43 | ||
44 | #include "global.h" | 44 | #include "global.h" |
45 | 45 | ||
46 | NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) | 46 | NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) |
47 | : QWidget(parent, name) | 47 | : QWidget(parent, name) |
48 | { | 48 | { |
49 | dataMgr = dataManager; | 49 | dataMgr = dataManager; |
50 | 50 | ||
51 | #ifdef QWS | 51 | #ifdef QWS |
52 | // read download directory from config file | 52 | // read download directory from config file |
53 | Config cfg( "aqpkg" ); | 53 | Config cfg( "aqpkg" ); |
54 | cfg.setGroup( "settings" ); | 54 | cfg.setGroup( "settings" ); |
55 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); | 55 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | 58 | ||
59 | initGui(); | 59 | initGui(); |
60 | setupConnections(); | 60 | setupConnections(); |
61 | 61 | ||
62 | progressDlg = 0; | 62 | progressDlg = 0; |
63 | timerId = startTimer( 100 ); | 63 | timerId = startTimer( 100 ); |
64 | } | 64 | } |
65 | 65 | ||
66 | NetworkPackageManager::~NetworkPackageManager() | 66 | NetworkPackageManager::~NetworkPackageManager() |
67 | { | 67 | { |
68 | } | 68 | } |
69 | 69 | ||
70 | void NetworkPackageManager :: timerEvent ( QTimerEvent * ) | 70 | void NetworkPackageManager :: timerEvent ( QTimerEvent * ) |
71 | { | 71 | { |
72 | killTimer( timerId ); | 72 | killTimer( timerId ); |
73 | 73 | ||
74 | // showProgressDialog(); | 74 | // showProgressDialog(); |
75 | // Add server names to listbox | 75 | // Add server names to listbox |
76 | updateData(); | 76 | updateData(); |
77 | 77 | ||
78 | // progressDlg->hide(); | 78 | // progressDlg->hide(); |
79 | } | 79 | } |
80 | 80 | ||
81 | void NetworkPackageManager :: updateData() | 81 | void NetworkPackageManager :: updateData() |
82 | { | 82 | { |
83 | serversList->clear(); | 83 | serversList->clear(); |
84 | packagesList->clear(); | 84 | packagesList->clear(); |
85 | 85 | ||
86 | |||
86 | vector<Server>::iterator it; | 87 | vector<Server>::iterator it; |
87 | int activeItem = -1; | 88 | int activeItem = -1; |
88 | int i; | 89 | int i; |
89 | for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) | 90 | for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) |
90 | { | 91 | { |
92 | if ( !it->isServerActive() ) | ||
93 | { | ||
94 | i--; | ||
95 | continue; | ||
96 | } | ||
91 | serversList->insertItem( it->getServerName() ); | 97 | serversList->insertItem( it->getServerName() ); |
92 | if ( it->getServerName() == currentlySelectedServer ) | 98 | if ( it->getServerName() == currentlySelectedServer ) |
93 | activeItem = i; | 99 | activeItem = i; |
94 | } | 100 | } |
95 | 101 | ||
96 | // set selected server to be active server | 102 | // set selected server to be active server |
97 | if ( activeItem != -1 ) | 103 | if ( activeItem != -1 ) |
98 | serversList->setCurrentItem( activeItem ); | 104 | serversList->setCurrentItem( activeItem ); |
99 | serverSelected( 0 ); | 105 | serverSelected( 0 ); |
100 | } | 106 | } |
101 | 107 | ||
102 | 108 | ||
103 | void NetworkPackageManager :: initGui() | 109 | void NetworkPackageManager :: initGui() |
104 | { | 110 | { |
105 | QLabel *l = new QLabel( "Servers", this ); | 111 | QLabel *l = new QLabel( "Servers", this ); |
106 | serversList = new QComboBox( this ); | 112 | serversList = new QComboBox( this ); |
107 | packagesList = new QListView( this ); | 113 | packagesList = new QListView( this ); |
108 | update = new QPushButton( "Refresh List", this ); | 114 | update = new QPushButton( "Refresh List", this ); |
109 | download = new QPushButton( "Download", this ); | 115 | download = new QPushButton( "Download", this ); |
110 | upgrade = new QPushButton( "Upgrade", this ); | 116 | upgrade = new QPushButton( "Upgrade", this ); |
111 | apply = new QPushButton( "Apply", this ); | 117 | apply = new QPushButton( "Apply", this ); |
112 | 118 | ||
113 | QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); | 119 | QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); |
114 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); | 120 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); |
115 | hbox1->addWidget( l ); | 121 | hbox1->addWidget( l ); |
116 | hbox1->addWidget( serversList ); | 122 | hbox1->addWidget( serversList ); |
117 | 123 | ||
118 | QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); | 124 | QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); |
119 | QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); | 125 | QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); |
120 | 126 | ||
121 | char text[2]; | 127 | char text[2]; |
122 | text[1] = '\0'; | 128 | text[1] = '\0'; |
123 | for ( int i = 0 ; i < 26 ; ++i ) | 129 | for ( int i = 0 ; i < 26 ; ++i ) |
124 | { | 130 | { |
125 | text[0] = 'A' + i; | 131 | text[0] = 'A' + i; |
126 | LetterPushButton *b = new LetterPushButton( text, this ); | 132 | LetterPushButton *b = new LetterPushButton( text, this ); |
127 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); | 133 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); |
128 | if ( i < 16 ) | 134 | if ( i < 16 ) |
129 | hbox3->addWidget( b ); | 135 | hbox3->addWidget( b ); |
130 | else | 136 | else |
131 | hbox4->addWidget( b ); | 137 | hbox4->addWidget( b ); |
132 | } | 138 | } |
133 | 139 | ||
134 | vbox->addWidget( packagesList ); | 140 | vbox->addWidget( packagesList ); |
135 | packagesList->addColumn( "Packages" ); | 141 | packagesList->addColumn( "Packages" ); |
136 | 142 | ||
137 | QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); | 143 | QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); |
138 | hbox2->addWidget( update ); | 144 | hbox2->addWidget( update ); |
139 | hbox2->addWidget( download ); | 145 | hbox2->addWidget( download ); |
140 | hbox2->addWidget( upgrade ); | 146 | hbox2->addWidget( upgrade ); |
141 | hbox2->addWidget( apply ); | 147 | hbox2->addWidget( apply ); |
142 | } | 148 | } |
143 | 149 | ||
144 | void NetworkPackageManager :: setupConnections() | 150 | void NetworkPackageManager :: setupConnections() |
145 | { | 151 | { |
146 | connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); | 152 | connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); |
147 | connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); | 153 | connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); |
148 | connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); | 154 | connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); |
149 | connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); | 155 | connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); |
150 | connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); | 156 | connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); |
151 | } | 157 | } |
152 | 158 | ||
153 | void NetworkPackageManager :: showProgressDialog( char *initialText ) | 159 | void NetworkPackageManager :: showProgressDialog( char *initialText ) |
154 | { | 160 | { |
155 | if ( !progressDlg ) | 161 | if ( !progressDlg ) |
156 | progressDlg = new ProgressDlg( this, "Progress", false ); | 162 | progressDlg = new ProgressDlg( this, "Progress", false ); |
157 | progressDlg->setText( initialText ); | 163 | progressDlg->setText( initialText ); |
158 | progressDlg->show(); | 164 | progressDlg->show(); |
159 | } | 165 | } |
160 | 166 | ||
161 | 167 | ||
162 | void NetworkPackageManager :: serverSelected( int ) | 168 | void NetworkPackageManager :: serverSelected( int ) |
163 | { | 169 | { |
164 | packagesList->clear(); | 170 | packagesList->clear(); |
165 | 171 | ||
166 | // display packages | 172 | // display packages |
167 | QString serverName = serversList->currentText(); | 173 | QString serverName = serversList->currentText(); |
168 | currentlySelectedServer = serverName; | 174 | currentlySelectedServer = serverName; |
169 | 175 | ||
170 | #ifdef QWS | 176 | #ifdef QWS |
171 | // read download directory from config file | 177 | // read download directory from config file |
172 | Config cfg( "aqpkg" ); | 178 | Config cfg( "aqpkg" ); |
173 | cfg.setGroup( "settings" ); | 179 | cfg.setGroup( "settings" ); |
174 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); | 180 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); |
175 | #endif | 181 | #endif |
176 | 182 | ||
177 | Server *s = dataMgr->getServer( serverName ); | 183 | Server *s = dataMgr->getServer( serverName ); |
178 | // dataMgr->setActiveServer( serverName ); | 184 | // dataMgr->setActiveServer( serverName ); |
179 | 185 | ||
180 | vector<Package> &list = s->getPackageList(); | 186 | vector<Package> &list = s->getPackageList(); |
181 | vector<Package>::iterator it; | 187 | vector<Package>::iterator it; |
182 | for ( it = list.begin() ; it != list.end() ; ++it ) | 188 | for ( it = list.begin() ; it != list.end() ; ++it ) |
183 | { | 189 | { |
184 | QString text = ""; | 190 | QString text = ""; |
185 | 191 | ||
186 | // If the local server, only display installed packages | 192 | // If the local server, only display installed packages |
187 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) | 193 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) |
188 | continue; | 194 | continue; |
189 | 195 | ||
190 | text += it->getPackageName(); | 196 | text += it->getPackageName(); |
191 | if ( it->isInstalled() ) | 197 | if ( it->isInstalled() ) |
192 | { | 198 | { |
193 | text += " (installed)"; | 199 | text += " (installed)"; |
194 | 200 | ||
195 | // If a different version of package is available, postfix it with an * | 201 | // If a different version of package is available, postfix it with an * |
196 | if ( it->getVersion() != it->getInstalledVersion() ) | 202 | if ( it->getVersion() != it->getInstalledVersion() ) |
197 | text += "*"; | 203 | text += "*"; |
198 | } | 204 | } |
199 | 205 | ||
200 | QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); | 206 | QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); |
201 | if ( !it->isPackageStoredLocally() ) | 207 | if ( !it->isPackageStoredLocally() ) |
202 | new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); | 208 | new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); |
203 | else | 209 | else |
204 | new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); | 210 | new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); |
205 | 211 | ||
206 | new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); | 212 | new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); |
207 | if ( it->getLocalPackage() ) | 213 | if ( it->getLocalPackage() ) |
208 | { | 214 | { |
209 | if ( it->isInstalled() ) | 215 | if ( it->isInstalled() ) |
210 | new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); | 216 | new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); |
211 | } | 217 | } |
212 | packagesList->insertItem( item ); | 218 | packagesList->insertItem( item ); |
213 | } | 219 | } |
214 | 220 | ||
215 | // If the local server or the local ipkgs server disable the download button | 221 | // If the local server or the local ipkgs server disable the download button |
216 | if ( serverName == LOCAL_SERVER ) | 222 | if ( serverName == LOCAL_SERVER ) |
217 | { | 223 | { |
218 | upgrade->setEnabled( false ); | 224 | upgrade->setEnabled( false ); |
219 | download->setText( "Download" ); | 225 | download->setText( "Download" ); |
220 | download->setEnabled( false ); | 226 | download->setEnabled( false ); |
221 | } | 227 | } |
222 | else if ( serverName == LOCAL_IPKGS ) | 228 | else if ( serverName == LOCAL_IPKGS ) |
223 | { | 229 | { |
224 | upgrade->setEnabled( false ); | 230 | upgrade->setEnabled( false ); |
225 | download->setEnabled( true ); | 231 | download->setEnabled( true ); |
226 | download->setText( "Remove" ); | 232 | download->setText( "Remove" ); |
227 | } | 233 | } |
228 | else | 234 | else |
229 | { | 235 | { |
230 | upgrade->setEnabled( true ); | 236 | upgrade->setEnabled( true ); |
231 | download->setEnabled( true ); | 237 | download->setEnabled( true ); |
232 | download->setText( "Download" ); | 238 | download->setText( "Download" ); |
233 | } | 239 | } |
234 | } | 240 | } |
235 | 241 | ||
236 | void NetworkPackageManager :: updateServer() | 242 | void NetworkPackageManager :: updateServer() |
237 | { | 243 | { |
238 | QString serverName = serversList->currentText(); | 244 | QString serverName = serversList->currentText(); |
239 | 245 | ||
240 | // Update the current server | 246 | // Update the current server |
241 | // Display dialog | 247 | // Display dialog |
242 | ProgressDlg *dlg = new ProgressDlg( this ); | 248 | ProgressDlg *dlg = new ProgressDlg( this ); |
243 | QString status = "Updating package lists..."; | 249 | QString status = "Updating package lists..."; |
244 | dlg->show(); | 250 | dlg->show(); |
245 | dlg->setText( status ); | 251 | dlg->setText( status ); |
246 | 252 | ||
247 | // Disable buttons to stop silly people clicking lots on them :) | 253 | // Disable buttons to stop silly people clicking lots on them :) |
248 | 254 | ||
249 | // First, write out ipkg_conf file so that ipkg can use it | 255 | // First, write out ipkg_conf file so that ipkg can use it |
250 | dataMgr->writeOutIpkgConf(); | 256 | dataMgr->writeOutIpkgConf(); |
251 | 257 | ||
252 | // if ( serverName == LOCAL_SERVER ) | 258 | // if ( serverName == LOCAL_SERVER ) |
253 | // ; | 259 | // ; |
254 | // else if ( serverName == LOCAL_IPKGS ) | 260 | // else if ( serverName == LOCAL_IPKGS ) |
255 | // ; | 261 | // ; |
256 | // else | 262 | // else |
257 | { | 263 | { |
258 | QString option = "update"; | 264 | QString option = "update"; |
259 | QString dummy = ""; | 265 | QString dummy = ""; |
260 | Ipkg ipkg; | 266 | Ipkg ipkg; |
261 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 267 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
262 | ipkg.setOption( option ); | 268 | ipkg.setOption( option ); |
263 | 269 | ||
264 | ipkg.runIpkg( ); | 270 | ipkg.runIpkg( ); |
265 | } | 271 | } |
266 | 272 | ||
267 | // Reload data | 273 | // Reload data |
268 | dataMgr->reloadServerData( serversList->currentText() ); | 274 | dataMgr->reloadServerData( serversList->currentText() ); |
269 | serverSelected(-1); | 275 | serverSelected(-1); |
270 | delete dlg; | 276 | delete dlg; |
271 | } | 277 | } |
272 | 278 | ||
273 | void NetworkPackageManager :: upgradePackages() | 279 | void NetworkPackageManager :: upgradePackages() |
274 | { | 280 | { |
275 | // We're gonna do an upgrade of all packages | 281 | // We're gonna do an upgrade of all packages |
276 | // First warn user that this isn't recommended | 282 | // First warn user that this isn't recommended |
277 | QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; | 283 | QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; |
278 | QMessageBox warn("Warning", text, QMessageBox::Warning, | 284 | QMessageBox warn("Warning", text, QMessageBox::Warning, |
279 | QMessageBox::Yes, | 285 | QMessageBox::Yes, |
280 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , | 286 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , |
281 | 0, this ); | 287 | 0, this ); |
282 | warn.adjustSize(); | 288 | warn.adjustSize(); |
283 | 289 | ||
284 | if ( warn.exec() == QMessageBox::Yes ) | 290 | if ( warn.exec() == QMessageBox::Yes ) |
285 | { | 291 | { |
286 | // First, write out ipkg_conf file so that ipkg can use it | 292 | // First, write out ipkg_conf file so that ipkg can use it |
287 | dataMgr->writeOutIpkgConf(); | 293 | dataMgr->writeOutIpkgConf(); |
288 | 294 | ||
289 | // Now run upgrade | 295 | // Now run upgrade |
290 | InstallDlgImpl dlg( this, "Upgrade", true ); | 296 | InstallDlgImpl dlg( this, "Upgrade", true ); |
291 | dlg.showDlg(); | 297 | dlg.showDlg(); |
292 | 298 | ||
293 | // Reload data | 299 | // Reload data |
294 | dataMgr->reloadServerData( LOCAL_SERVER ); | 300 | dataMgr->reloadServerData( LOCAL_SERVER ); |
295 | 301 | ||
296 | dataMgr->reloadServerData( serversList->currentText() ); | 302 | dataMgr->reloadServerData( serversList->currentText() ); |
297 | serverSelected(-1); | 303 | serverSelected(-1); |
298 | } | 304 | } |
299 | } | 305 | } |
300 | 306 | ||
301 | 307 | ||
302 | void NetworkPackageManager :: downloadPackage() | 308 | void NetworkPackageManager :: downloadPackage() |
303 | { | 309 | { |
304 | if ( download->text() == "Download" ) | 310 | if ( download->text() == "Download" ) |
305 | { | 311 | { |
306 | // First, write out ipkg_conf file so that ipkg can use it | 312 | // First, write out ipkg_conf file so that ipkg can use it |
307 | dataMgr->writeOutIpkgConf(); | 313 | dataMgr->writeOutIpkgConf(); |
308 | 314 | ||
309 | // Display dialog to user asking where to download the files to | 315 | // Display dialog to user asking where to download the files to |
310 | bool ok = FALSE; | 316 | bool ok = FALSE; |
311 | QString dir = ""; | 317 | QString dir = ""; |
312 | #ifdef QWS | 318 | #ifdef QWS |
313 | // read download directory from config file | 319 | // read download directory from config file |
314 | Config cfg( "aqpkg" ); | 320 | Config cfg( "aqpkg" ); |
315 | cfg.setGroup( "settings" ); | 321 | cfg.setGroup( "settings" ); |
316 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); | 322 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); |
317 | #endif | 323 | #endif |
318 | 324 | ||
319 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); | 325 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); |
320 | if ( ok && !text.isEmpty() ) | 326 | if ( ok && !text.isEmpty() ) |
321 | dir = text; // user entered something and pressed ok | 327 | dir = text; // user entered something and pressed ok |
322 | else | 328 | else |
323 | return; // user entered nothing or pressed cancel | 329 | return; // user entered nothing or pressed cancel |
324 | 330 | ||
325 | #ifdef QWS | 331 | #ifdef QWS |
326 | // Store download directory in config file | 332 | // Store download directory in config file |
327 | cfg.writeEntry( "downloadDir", dir ); | 333 | cfg.writeEntry( "downloadDir", dir ); |
328 | #endif | 334 | #endif |
329 | 335 | ||
330 | // Get starting directory | 336 | // Get starting directory |
331 | char initDir[PATH_MAX]; | 337 | char initDir[PATH_MAX]; |
332 | getcwd( initDir, PATH_MAX ); | 338 | getcwd( initDir, PATH_MAX ); |
333 | 339 | ||
334 | // Download each package | 340 | // Download each package |
335 | Ipkg ipkg; | 341 | Ipkg ipkg; |
336 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 342 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
337 | 343 | ||
338 | ipkg.setOption( "download" ); | 344 | ipkg.setOption( "download" ); |
339 | ipkg.setRuntimeDirectory( dir ); | 345 | ipkg.setRuntimeDirectory( dir ); |
340 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 346 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
341 | item != 0 ; | 347 | item != 0 ; |
342 | item = (QCheckListItem *)item->nextSibling() ) | 348 | item = (QCheckListItem *)item->nextSibling() ) |
343 | { | 349 | { |
344 | if ( item->isOn() ) | 350 | if ( item->isOn() ) |
345 | { | 351 | { |
346 | QString name = item->text(); | 352 | QString name = item->text(); |