summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index ff8f182..06e2a03 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -75,322 +75,322 @@ void NetworkPackageManager :: updateData()
75 75
76 vector<Server>::iterator it; 76 vector<Server>::iterator it;
77 int activeItem = -1; 77 int activeItem = -1;
78 int i; 78 int i;
79 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) 79 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i )
80 { 80 {
81 serversList->insertItem( it->getServerName() ); 81 serversList->insertItem( it->getServerName() );
82 if ( it->getServerName() == dataMgr->getActiveServer() ) 82 if ( it->getServerName() == dataMgr->getActiveServer() )
83 activeItem = i; 83 activeItem = i;
84 } 84 }
85 85
86 // set selected server to be active server 86 // set selected server to be active server
87 if ( activeItem != -1 ) 87 if ( activeItem != -1 )
88 serversList->setCurrentItem( activeItem ); 88 serversList->setCurrentItem( activeItem );
89 serverSelected( 0 ); 89 serverSelected( 0 );
90} 90}
91 91
92 92
93void NetworkPackageManager :: initGui() 93void NetworkPackageManager :: initGui()
94{ 94{
95 QLabel *l = new QLabel( "Servers", this ); 95 QLabel *l = new QLabel( "Servers", this );
96 serversList = new QComboBox( this ); 96 serversList = new QComboBox( this );
97 packagesList = new QListView( this ); 97 packagesList = new QListView( this );
98 update = new QPushButton( "Refresh List", this ); 98 update = new QPushButton( "Refresh List", this );
99 download = new QPushButton( "Download", this ); 99 download = new QPushButton( "Download", this );
100 apply = new QPushButton( "Apply", this ); 100 apply = new QPushButton( "Apply", this );
101 101
102 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); 102 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" );
103 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); 103 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" );
104 hbox1->addWidget( l ); 104 hbox1->addWidget( l );
105 hbox1->addWidget( serversList ); 105 hbox1->addWidget( serversList );
106 106
107 vbox->addWidget( packagesList ); 107 vbox->addWidget( packagesList );
108 packagesList->addColumn( "Packages" ); 108 packagesList->addColumn( "Packages" );
109 109
110 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); 110 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" );
111 hbox2->addWidget( update ); 111 hbox2->addWidget( update );
112 hbox2->addWidget( download ); 112 hbox2->addWidget( download );
113 hbox2->addWidget( apply ); 113 hbox2->addWidget( apply );
114} 114}
115 115
116void NetworkPackageManager :: setupConnections() 116void NetworkPackageManager :: setupConnections()
117{ 117{
118 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); 118 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int )));
119 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); 119 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) );
120 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); 120 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) );
121 connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); 121 connect( update, SIGNAL(released()), this, SLOT(updateServer()) );
122} 122}
123 123
124void NetworkPackageManager :: showProgressDialog() 124void NetworkPackageManager :: showProgressDialog()
125{ 125{
126 if ( !progressDlg ) 126 if ( !progressDlg )
127 progressDlg = new ProgressDlg( this, "Progress", false ); 127 progressDlg = new ProgressDlg( this, "Progress", false );
128 progressDlg->setText( "Reading installed packages" ); 128 progressDlg->setText( "Reading installed packages" );
129 progressDlg->show(); 129 progressDlg->show();
130} 130}
131 131
132 132
133void NetworkPackageManager :: serverSelected( int ) 133void NetworkPackageManager :: serverSelected( int )
134{ 134{
135 packagesList->clear(); 135 packagesList->clear();
136 136
137 // display packages 137 // display packages
138 QString serverName = serversList->currentText(); 138 QString serverName = serversList->currentText();
139 Server *s = dataMgr->getServer( serverName ); 139 Server *s = dataMgr->getServer( serverName );
140 dataMgr->setActiveServer( serverName ); 140 dataMgr->setActiveServer( serverName );
141 141
142 vector<Package> &list = s->getPackageList(); 142 vector<Package> &list = s->getPackageList();
143 vector<Package>::iterator it; 143 vector<Package>::iterator it;
144 for ( it = list.begin() ; it != list.end() ; ++it ) 144 for ( it = list.begin() ; it != list.end() ; ++it )
145 { 145 {
146 QString text = ""; 146 QString text = "";
147 147
148 // If the local server, only display installed packages 148 // If the local server, only display installed packages
149 if ( serverName == LOCAL_SERVER && !it->isInstalled() ) 149 if ( serverName == LOCAL_SERVER && !it->isInstalled() )
150 continue; 150 continue;
151 151
152 text += it->getPackageName(); 152 text += it->getPackageName();
153 if ( it->isInstalled() ) 153 if ( it->isInstalled() )
154 { 154 {
155 text += " (installed)"; 155 text += " (installed)";
156 156
157 // If a different version of package is available, postfix it with an * 157 // If a different version of package is available, postfix it with an *
158 if ( it->getVersion() != it->getInstalledVersion() ) 158 if ( it->getVersion() != it->getInstalledVersion() )
159 text += "*"; 159 text += "*";
160 } 160 }
161 161
162 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); 162 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox );
163 if ( !it->isPackageStoredLocally() ) 163 if ( !it->isPackageStoredLocally() )
164 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); 164 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() );
165 else 165 else
166 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); 166 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() );
167 167
168 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); 168 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() );
169 if ( it->getLocalPackage() ) 169 if ( it->getLocalPackage() )
170 { 170 {
171 if ( it->isInstalled() ) 171 if ( it->isInstalled() )
172 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); 172 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() );
173 } 173 }
174 packagesList->insertItem( item ); 174 packagesList->insertItem( item );
175 } 175 }
176 176
177 // If the local server or the local ipkgs server disable the download button 177 // If the local server or the local ipkgs server disable the download button
178 download->setText( "Download" ); 178 download->setText( "Download" );
179 if ( serverName == LOCAL_SERVER ) 179 if ( serverName == LOCAL_SERVER )
180 download->setEnabled( false ); 180 download->setEnabled( false );
181 else if ( serverName == LOCAL_IPKGS ) 181 else if ( serverName == LOCAL_IPKGS )
182 { 182 {
183 download->setEnabled( true ); 183 download->setEnabled( true );
184 download->setText( "Remove" ); 184 download->setText( "Remove" );
185 } 185 }
186 else 186 else
187 download->setEnabled( true ); 187 download->setEnabled( true );
188} 188}
189 189
190void NetworkPackageManager :: updateServer() 190void NetworkPackageManager :: updateServer()
191{ 191{
192 QString serverName = serversList->currentText(); 192 QString serverName = serversList->currentText();
193 193
194 // Update the current server 194 // Update the current server
195 // Display dialog 195 // Display dialog
196 ProgressDlg *dlg = new ProgressDlg( this ); 196 ProgressDlg *dlg = new ProgressDlg( this );
197 QString status = "Updating package list for "; 197 QString status = "Updating package list for ";
198 status += serverName; 198 status += serverName;
199 dlg->show(); 199 dlg->show();
200 dlg->setText( status ); 200 dlg->setText( status );
201 201
202 // Disable buttons to stop silly people clicking lots on them :) 202 // Disable buttons to stop silly people clicking lots on them :)
203 203
204 // First, write out ipkg_conf file so that ipkg can use it 204 // First, write out ipkg_conf file so that ipkg can use it
205 dataMgr->writeOutIpkgConf(); 205 dataMgr->writeOutIpkgConf();
206 206
207 if ( serverName == LOCAL_SERVER ) 207 if ( serverName == LOCAL_SERVER )
208 ; 208 ;
209 else if ( serverName == LOCAL_IPKGS ) 209 else if ( serverName == LOCAL_IPKGS )
210 ; 210 ;
211 else 211 else
212 { 212 {
213 QString option = "update"; 213 QString option = "update";
214 QString dummy = ""; 214 QString dummy = "";
215 Ipkg ipkg; 215 Ipkg ipkg;
216 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 216 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
217 ipkg.setOption( option ); 217 ipkg.setOption( option );
218 218
219 ipkg.runIpkg( ); 219 ipkg.runIpkg( );
220 } 220 }
221 221
222 // Reload data 222 // Reload data
223 dataMgr->reloadServerData( serversList->currentText() ); 223 dataMgr->reloadServerData( serversList->currentText() );
224 serverSelected(-1); 224 serverSelected(-1);
225 delete dlg; 225 delete dlg;
226} 226}
227 227
228 228
229void NetworkPackageManager :: downloadPackage() 229void NetworkPackageManager :: downloadPackage()
230{ 230{
231 if ( download->text() == "Download" ) 231 if ( download->text() == "Download" )
232 { 232 {
233 // First, write out ipkg_conf file so that ipkg can use it 233 // First, write out ipkg_conf file so that ipkg can use it
234 dataMgr->writeOutIpkgConf(); 234 dataMgr->writeOutIpkgConf();
235 235
236 // Display dialog to user asking where to download the files to 236 // Display dialog to user asking where to download the files to
237 bool ok = FALSE; 237 bool ok = FALSE;
238 QString dir = ""; 238 QString dir = "";
239#ifdef QWS 239#ifdef QWS
240 // read download directory from config file 240 // read download directory from config file
241 Config cfg( "aqpkg" ); 241 Config cfg( "aqpkg" );
242 cfg.setGroup( "settings" ); 242 cfg.setGroup( "settings" );
243 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); 243 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
244#endif 244#endif
245 245
246 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); 246 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
247 if ( ok && !text.isEmpty() ) 247 if ( ok && !text.isEmpty() )
248 dir = text; // user entered something and pressed ok 248 dir = text; // user entered something and pressed ok
249 else 249 else
250 return; // user entered nothing or pressed cancel 250 return; // user entered nothing or pressed cancel
251 251
252#ifdef QWS 252#ifdef QWS
253 // Store download directory in config file 253 // Store download directory in config file
254 cfg.writeEntry( "downloadDir", dir ); 254 cfg.writeEntry( "downloadDir", dir );
255#endif 255#endif
256 256
257 // Get starting directory 257 // Get starting directory
258 char initDir[PATH_MAX]; 258 char initDir[PATH_MAX];
259 getcwd( initDir, PATH_MAX ); 259 getcwd( initDir, PATH_MAX );
260 260
261 // Download each package 261 // Download each package
262 Ipkg ipkg; 262 Ipkg ipkg;
263 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 263 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
264 264
265 QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 265 QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
266 ipkg.setOption( "download" ); 266 ipkg.setOption( "download" );
267 ipkg.setRuntimeDirectory( initDir ); 267 ipkg.setRuntimeDirectory( dir );
268 do 268 do
269 { 269 {
270 if ( item->isOn() ) 270 if ( item->isOn() )
271 { 271 {
272 QString name = item->text(); 272 QString name = item->text();
273 int pos = name.find( "*" ); 273 int pos = name.find( "*" );
274 name.truncate( pos ); 274 name.truncate( pos );
275 275
276 // if (there is a (installed), remove it 276 // if (there is a (installed), remove it
277 pos = name.find( "(installed)" ); 277 pos = name.find( "(installed)" );
278 if ( pos > 0 ) 278 if ( pos > 0 )
279 name.truncate( pos - 1 ); 279 name.truncate( pos - 1 );
280 280
281 ipkg.setPackage( name ); 281 ipkg.setPackage( name );
282 ipkg.runIpkg( ); 282 ipkg.runIpkg( );
283 } 283 }
284 284
285 item = (QCheckListItem *)item->nextSibling(); 285 item = (QCheckListItem *)item->nextSibling();
286 } while ( item ); 286 } while ( item );
287 } 287 }
288 else if ( download->text() == "Remove" ) 288 else if ( download->text() == "Remove" )
289 { 289 {
290 QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 290 QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
291 do 291 do
292 { 292 {
293 if ( item->isOn() ) 293 if ( item->isOn() )
294 { 294 {
295 QString name = item->text(); 295 QString name = item->text();
296 int pos = name.find( "*" ); 296 int pos = name.find( "*" );
297 name.truncate( pos ); 297 name.truncate( pos );
298 298
299 // if (there is a (installed), remove it 299 // if (there is a (installed), remove it
300 pos = name.find( "(installed)" ); 300 pos = name.find( "(installed)" );
301 if ( pos > 0 ) 301 if ( pos > 0 )
302 name.truncate( pos - 1 ); 302 name.truncate( pos - 1 );
303 303
304 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); 304 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name );
305 QFile f( p->getFilename() ); 305 QFile f( p->getFilename() );
306 f.remove(); 306 f.remove();
307 } 307 }
308 item = (QCheckListItem *)item->nextSibling(); 308 item = (QCheckListItem *)item->nextSibling();
309 } while ( item ); 309 } while ( item );
310 } 310 }
311 311
312 dataMgr->reloadServerData( LOCAL_IPKGS ); 312 dataMgr->reloadServerData( LOCAL_IPKGS );
313 serverSelected( -1 ); 313 serverSelected( -1 );
314} 314}
315 315
316 316
317void NetworkPackageManager :: applyChanges() 317void NetworkPackageManager :: applyChanges()
318{ 318{
319 // Disable buttons to stop silly people clicking lots on them :) 319 // Disable buttons to stop silly people clicking lots on them :)
320 320
321 // First, write out ipkg_conf file so that ipkg can use it 321 // First, write out ipkg_conf file so that ipkg can use it
322 dataMgr->writeOutIpkgConf(); 322 dataMgr->writeOutIpkgConf();
323 323
324 // Now for each selected item 324 // Now for each selected item
325 // deal with it 325 // deal with it
326 326
327 vector<QString> workingPackages; 327 vector<QString> workingPackages;
328 QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 328 QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
329 do 329 do
330 { 330 {
331 if ( item->isOn() ) 331 if ( item->isOn() )
332 { 332 {
333 QString p = dealWithItem( item ); 333 QString p = dealWithItem( item );
334 workingPackages.push_back( p ); 334 workingPackages.push_back( p );
335 } 335 }
336 336
337 item = (QCheckListItem *)item->nextSibling(); 337 item = (QCheckListItem *)item->nextSibling();
338 } while ( item ); 338 } while ( item );
339 339
340 // do the stuff 340 // do the stuff
341 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); 341 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true );
342 dlg.showDlg(); 342 dlg.showDlg();
343 343
344 // Reload data 344 // Reload data
345 dataMgr->reloadServerData( LOCAL_SERVER ); 345 dataMgr->reloadServerData( LOCAL_SERVER );
346 dataMgr->reloadServerData( serversList->currentText() ); 346 dataMgr->reloadServerData( serversList->currentText() );
347 serverSelected(-1); 347 serverSelected(-1);
348 348
349#ifdef QWS 349#ifdef QWS
350 // Finally let the main system update itself 350 // Finally let the main system update itself
351 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 351 QCopEnvelope e("QPE/System", "linkChanged(QString)");
352 QString lf = QString::null; 352 QString lf = QString::null;
353 e << lf; 353 e << lf;
354#endif 354#endif
355} 355}
356 356
357// decide what to do - either remove, upgrade or install 357// decide what to do - either remove, upgrade or install
358// Current rules: 358// Current rules:
359// If not installed - install 359// If not installed - install
360// If installed and different version available - upgrade 360// If installed and different version available - upgrade
361// If installed and version up to date - remove 361// If installed and version up to date - remove
362QString NetworkPackageManager :: dealWithItem( QCheckListItem *item ) 362QString NetworkPackageManager :: dealWithItem( QCheckListItem *item )
363{ 363{
364 QString name = item->text(); 364 QString name = item->text();
365 int pos = name.find( "*" ); 365 int pos = name.find( "*" );
366 name.truncate( pos ); 366 name.truncate( pos );
367 367
368 // if (there is a (installed), remove it 368 // if (there is a (installed), remove it
369 pos = name.find( "(installed)" ); 369 pos = name.find( "(installed)" );
370 if ( pos > 0 ) 370 if ( pos > 0 )
371 name.truncate( pos - 1 ); 371 name.truncate( pos - 1 );
372 372
373 // Get package 373 // Get package
374 Server *s = dataMgr->getServer( serversList->currentText() ); 374 Server *s = dataMgr->getServer( serversList->currentText() );
375 Package *p = s->getPackage( name ); 375 Package *p = s->getPackage( name );
376 376
377 // If the package has a filename then it is a local file 377 // If the package has a filename then it is a local file
378 if ( p->isPackageStoredLocally() ) 378 if ( p->isPackageStoredLocally() )
379 name = p->getFilename(); 379 name = p->getFilename();
380 QString option; 380 QString option;
381 QString dest = "root"; 381 QString dest = "root";
382 if ( !p->isInstalled() ) 382 if ( !p->isInstalled() )
383 return QString( "I" ) + name; 383 return QString( "I" ) + name;
384 else 384 else
385 { 385 {
386 if ( p->getVersion() == p->getInstalledVersion() ) 386 if ( p->getVersion() == p->getInstalledVersion() )
387 return QString( "D" ) + name; 387 return QString( "D" ) + name;
388 else 388 else
389 return QString( "U" ) + name; 389 return QString( "U" ) + name;
390 } 390 }
391} 391}
392 392
393void NetworkPackageManager :: displayText( const QString &t ) 393void NetworkPackageManager :: displayText( const QString &t )
394{ 394{
395 cout << t << endl; 395 cout << t << endl;
396} 396}