summaryrefslogtreecommitdiff
authorkergoth <kergoth>2002-04-14 01:02:18 (UTC)
committer kergoth <kergoth>2002-04-14 01:02:18 (UTC)
commited4148887805150f52e1f20d45efcefc1bb2f390 (patch) (unidiff)
tree1d84859b7729d47cf71ba8e154a8e6310404595b
parent47f50cc423eab9e36a72bff18d1815d77d5dee00 (diff)
downloadopie-ed4148887805150f52e1f20d45efcefc1bb2f390.zip
opie-ed4148887805150f52e1f20d45efcefc1bb2f390.tar.gz
opie-ed4148887805150f52e1f20d45efcefc1bb2f390.tar.bz2
commenting added feeds by default when unselected is unintuitive.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/packagemanager.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/unsupported/oipkg/packagemanager.cpp b/noncore/unsupported/oipkg/packagemanager.cpp
index f3da15d..642eae9 100644
--- a/noncore/unsupported/oipkg/packagemanager.cpp
+++ b/noncore/unsupported/oipkg/packagemanager.cpp
@@ -224,674 +224,674 @@ void PackageManager::removeServer()
224 settings->servername->setText(settings->servers->text(editedserver)); 224 settings->servername->setText(settings->servers->text(editedserver));
225 settings->serverurl->setText(*serverurl[editedserver]); 225 settings->serverurl->setText(*serverurl[editedserver]);
226 disconnect( settings->servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); 226 disconnect( settings->servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
227 settings->servers->removeItem(editedserver); 227 settings->servers->removeItem(editedserver);
228 connect( settings->servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); 228 connect( settings->servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
229 settings->servername->setEnabled(FALSE); 229 settings->servername->setEnabled(FALSE);
230 settings->serverurl->setEnabled(FALSE); 230 settings->serverurl->setEnabled(FALSE);
231} 231}
232 232
233void PackageManager::nameChanged(const QString& t) 233void PackageManager::nameChanged(const QString& t)
234{ 234{
235 disconnect( settings->servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); 235 disconnect( settings->servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
236 settings->servers->changeItem( t, editedserver ); 236 settings->servers->changeItem( t, editedserver );
237 connect( settings->servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) ); 237 connect( settings->servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
238} 238}
239 239
240void PackageManager::urlChanged(const QString& t) 240void PackageManager::urlChanged(const QString& t)
241{ 241{
242 serverurl.replace(editedserver, new QString(t)); 242 serverurl.replace(editedserver, new QString(t));
243} 243}
244 244
245static void selectComboItem(QComboBox *cb, const QString s) 245static void selectComboItem(QComboBox *cb, const QString s)
246{ 246{
247 for (int i=0; i<cb->count(); i++) { 247 for (int i=0; i<cb->count(); i++) {
248 if ( cb->text(i) == s ) { 248 if ( cb->text(i) == s ) {
249 cb->setCurrentItem(i); 249 cb->setCurrentItem(i);
250 return; 250 return;
251 } 251 }
252 } 252 }
253} 253}
254 254
255void PackageManager::updatePackageList() 255void PackageManager::updatePackageList()
256{ 256{
257 disconnect(section,SIGNAL(activated(int)),this,SLOT(updatePackageList())); 257 disconnect(section,SIGNAL(activated(int)),this,SLOT(updatePackageList()));
258 disconnect(subsection,SIGNAL(activated(int)),this,SLOT(updatePackageList())); 258 disconnect(subsection,SIGNAL(activated(int)),this,SLOT(updatePackageList()));
259 259
260 list->clear(); 260 list->clear();
261 QString cursection = section->currentText(); 261 QString cursection = section->currentText();
262 QString cursubsection = subsection->currentText(); 262 QString cursubsection = subsection->currentText();
263 QString all=tr("All"); 263 QString all=tr("All");
264 if ( cursection == all ) cursection=QString::null; 264 if ( cursection == all ) cursection=QString::null;
265 if ( cursubsection == all ) cursubsection=QString::null; 265 if ( cursubsection == all ) cursubsection=QString::null;
266 section->clear(); 266 section->clear();
267 subsection->clear(); 267 subsection->clear();
268 268
269 QDict<void> sections; 269 QDict<void> sections;
270 QDict<void> subsections; 270 QDict<void> subsections;
271 QDict<void> installed; 271 QDict<void> installed;
272 272
273 QRegExp separatorRegExp( ":[\t ]+" ); 273 QRegExp separatorRegExp( ":[\t ]+" );
274 274
275 QString status = ipkgStatusOutput(); 275 QString status = ipkgStatusOutput();
276 if ( !status.isEmpty() ) { 276 if ( !status.isEmpty() ) {
277 QStringList lines = QStringList::split('\n',status,TRUE); 277 QStringList lines = QStringList::split('\n',status,TRUE);
278 QString name; 278 QString name;
279 QString status; 279 QString status;
280 for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) { 280 for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) {
281 QString line = *it; 281 QString line = *it;
282 if ( line.length()<=1 ) { 282 if ( line.length()<=1 ) {
283 // EOR 283 // EOR
284 if ( !name.isEmpty() ) { 284 if ( !name.isEmpty() ) {
285 if ( status.contains(" installed") ) 285 if ( status.contains(" installed") )
286 installed.replace(name,(void*)1); 286 installed.replace(name,(void*)1);
287 name=""; 287 name="";
288 } 288 }
289 status=""; 289 status="";
290 } else if ( line[0] == ' ' || line[0] == '\t' ) { 290 } else if ( line[0] == ' ' || line[0] == '\t' ) {
291 // continuation 291 // continuation
292 } else { 292 } else {
293 int sep = line.find(separatorRegExp); 293 int sep = line.find(separatorRegExp);
294 if ( sep >= 0 ) { 294 if ( sep >= 0 ) {
295 QString tag = line.left(sep); 295 QString tag = line.left(sep);
296 if ( tag == "Package" ) { 296 if ( tag == "Package" ) {
297 name = line.mid(sep+2).simplifyWhiteSpace(); 297 name = line.mid(sep+2).simplifyWhiteSpace();
298 } else if ( tag == "Status" ) { 298 } else if ( tag == "Status" ) {
299 status = line.mid(sep+1); 299 status = line.mid(sep+1);
300 } 300 }
301 } 301 }
302 } 302 }
303 } 303 }
304 } 304 }
305 305
306 QString info = ipkgInfoOutput(); 306 QString info = ipkgInfoOutput();
307 if ( !info.isEmpty() ) { 307 if ( !info.isEmpty() ) {
308 QStringList lines = QStringList::split('\n',info,TRUE); 308 QStringList lines = QStringList::split('\n',info,TRUE);
309 QString description_short; 309 QString description_short;
310 QString name; 310 QString name;
311 QString size; 311 QString size;
312 QString sec; 312 QString sec;
313 for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) { 313 for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) {
314 QString line = *it; 314 QString line = *it;
315 if ( line.length()<=1 ) { 315 if ( line.length()<=1 ) {
316 // EOR 316 // EOR
317 if ( !name.isEmpty() ) { 317 if ( !name.isEmpty() ) {
318 int sl = sec.find('/'); 318 int sl = sec.find('/');
319 QString s = sl < 0 ? sec : sec.left(sl); 319 QString s = sl < 0 ? sec : sec.left(sl);
320 QString ss = sl < 0 ? QString::null : sec.mid(sl+1); 320 QString ss = sl < 0 ? QString::null : sec.mid(sl+1);
321 sections.replace(s,(void*)1); 321 sections.replace(s,(void*)1);
322 if ( cursection.isNull() 322 if ( cursection.isNull()
323 || cursection == s 323 || cursection == s
324 && (cursubsection.isNull() || cursubsection == ss) ) 324 && (cursubsection.isNull() || cursubsection == ss) )
325 { 325 {
326 if ( !cursection.isNull() && !ss.isNull() ) 326 if ( !cursection.isNull() && !ss.isNull() )
327 subsections.replace(ss,(void*)1); 327 subsections.replace(ss,(void*)1);
328 description_short[0] = description_short[0].upper(); 328 description_short[0] = description_short[0].upper();
329 if ( description_short.left(4) == "The " ) 329 if ( description_short.left(4) == "The " )
330 description_short = description_short.mid(4); 330 description_short = description_short.mid(4);
331 if ( description_short.left(2) == "A " ) 331 if ( description_short.left(2) == "A " )
332 description_short = description_short.mid(2); 332 description_short = description_short.mid(2);
333 description_short[0] = description_short[0].upper(); 333 description_short[0] = description_short[0].upper();
334 new PackageItem(list,name,description_short,size, 334 new PackageItem(list,name,description_short,size,
335 installed.find(name)); 335 installed.find(name));
336 } 336 }
337 installed.remove( name ); 337 installed.remove( name );
338 } 338 }
339 name=""; 339 name="";
340 size=""; 340 size="";
341 sec="main"; 341 sec="main";
342 } else if ( line[0] == ' ' || line[0] == '\t' ) { 342 } else if ( line[0] == ' ' || line[0] == '\t' ) {
343 // continuation 343 // continuation
344 } else { 344 } else {
345 int sep = line.find(separatorRegExp); 345 int sep = line.find(separatorRegExp);
346 if ( sep >= 0 ) { 346 if ( sep >= 0 ) {
347 QString tag = line.left(sep); 347 QString tag = line.left(sep);
348 if ( tag == "Package" ) { 348 if ( tag == "Package" ) {
349 name = line.mid(sep+2).simplifyWhiteSpace(); 349 name = line.mid(sep+2).simplifyWhiteSpace();
350 } else if ( tag == "Description" ) { 350 } else if ( tag == "Description" ) {
351 description_short = line.mid(sep+2).simplifyWhiteSpace(); 351 description_short = line.mid(sep+2).simplifyWhiteSpace();
352 } else if ( tag == "Installed-Size" ) { 352 } else if ( tag == "Installed-Size" ) {
353 size = line.mid(sep+2).simplifyWhiteSpace(); 353 size = line.mid(sep+2).simplifyWhiteSpace();
354 } else if ( tag == "Section" ) { 354 } else if ( tag == "Section" ) {
355 sec = line.mid(sep+2).simplifyWhiteSpace(); 355 sec = line.mid(sep+2).simplifyWhiteSpace();
356 } 356 }
357 } 357 }
358 } 358 }
359 } 359 }
360 if ( installed.count() && cursection.isNull() ) { 360 if ( installed.count() && cursection.isNull() ) {
361 // we have some packages without description 361 // we have some packages without description
362 QDictIterator<void> it( installed ); 362 QDictIterator<void> it( installed );
363 for( ; it.current(); ++it ) 363 for( ; it.current(); ++it )
364 new PackageItem( list, it.currentKey(), "", "?" , TRUE ); 364 new PackageItem( list, it.currentKey(), "", "?" , TRUE );
365 } 365 }
366 366
367 QStringList s; 367 QStringList s;
368 QDictIterator<void> it( sections ); 368 QDictIterator<void> it( sections );
369 for( ; it.current(); ++it ) 369 for( ; it.current(); ++it )
370 s.append(it.currentKey()); 370 s.append(it.currentKey());
371 s.sort(); 371 s.sort();
372 section->insertItem(all); 372 section->insertItem(all);
373 section->insertStringList(s); 373 section->insertStringList(s);
374 selectComboItem(section,cursection.isNull()?all:cursection); 374 selectComboItem(section,cursection.isNull()?all:cursection);
375 if ( cursection.isNull() ) { 375 if ( cursection.isNull() ) {
376 subsection->setEnabled(FALSE); 376 subsection->setEnabled(FALSE);
377 } else { 377 } else {
378 subsection->setEnabled(TRUE); 378 subsection->setEnabled(TRUE);
379 QStringList s; 379 QStringList s;
380 QDictIterator<void> it( subsections ); 380 QDictIterator<void> it( subsections );
381 for( ; it.current(); ++it ) 381 for( ; it.current(); ++it )
382 s.append(it.currentKey()); 382 s.append(it.currentKey());
383 s.sort(); 383 s.sort();
384 subsection->insertItem(all); 384 subsection->insertItem(all);
385 subsection->insertStringList(s); 385 subsection->insertStringList(s);
386 selectComboItem(subsection,cursubsection.isNull()?all:cursubsection); 386 selectComboItem(subsection,cursubsection.isNull()?all:cursubsection);
387 } 387 }
388 } else { 388 } else {
389 new QListViewItem(list,"ERROR"); 389 new QListViewItem(list,"ERROR");
390 } 390 }
391 391
392 connect(section,SIGNAL(activated(int)),SLOT(updatePackageList())); 392 connect(section,SIGNAL(activated(int)),SLOT(updatePackageList()));
393 connect(subsection,SIGNAL(activated(int)),this,SLOT(updatePackageList())); 393 connect(subsection,SIGNAL(activated(int)),this,SLOT(updatePackageList()));
394} 394}
395 395
396PackageItem* PackageManager::current() const 396PackageItem* PackageManager::current() const
397{ 397{
398 return (PackageItem*)list->currentItem(); 398 return (PackageItem*)list->currentItem();
399} 399}
400 400
401/* 401/*
402 * public slot 402 * public slot
403 */ 403 */
404void PackageManager::doCurrentDetails(bool multi) 404void PackageManager::doCurrentDetails(bool multi)
405{ 405{
406 PackageItem* pit = current(); 406 PackageItem* pit = current();
407 if ( pit ) { 407 if ( pit ) {
408 if ( !details ) { 408 if ( !details ) {
409 details = new PackageDetails; 409 details = new PackageDetails;
410 connect( details->install, SIGNAL(clicked()), 410 connect( details->install, SIGNAL(clicked()),
411 this, SLOT(installCurrent())); 411 this, SLOT(installCurrent()));
412 connect( details->remove, SIGNAL(clicked()), 412 connect( details->remove, SIGNAL(clicked()),
413 this, SLOT(removeCurrent())); 413 this, SLOT(removeCurrent()));
414 details->description->setTextFormat(RichText); 414 details->description->setTextFormat(RichText);
415 } 415 }
416 if ( multi ) { 416 if ( multi ) {
417 disconnect( details->ignore, SIGNAL(clicked()), 417 disconnect( details->ignore, SIGNAL(clicked()),
418 details, SLOT(close())); 418 details, SLOT(close()));
419 connect( details->ignore, SIGNAL(clicked()), 419 connect( details->ignore, SIGNAL(clicked()),
420 this, SLOT(doNextDetails())); 420 this, SLOT(doNextDetails()));
421 } else { 421 } else {
422 disconnect( details->ignore, SIGNAL(clicked()), 422 disconnect( details->ignore, SIGNAL(clicked()),
423 this, SLOT(doNextDetails())); 423 this, SLOT(doNextDetails()));
424 connect( details->ignore, SIGNAL(clicked()), 424 connect( details->ignore, SIGNAL(clicked()),
425 details, SLOT(close())); 425 details, SLOT(close()));
426 } 426 }
427 pit->setSelected(FALSE); 427 pit->setSelected(FALSE);
428 details->setCaption("Package: " + pit->name()); 428 details->setCaption("Package: " + pit->name());
429 details->description->setText(fullDetails(pit->name())); 429 details->description->setText(fullDetails(pit->name()));
430 details->install->setEnabled(!pit->isInstalled()); 430 details->install->setEnabled(!pit->isInstalled());
431 details->remove->setEnabled(pit->isInstalled()); 431 details->remove->setEnabled(pit->isInstalled());
432 details->showMaximized(); 432 details->showMaximized();
433 } 433 }
434} 434}
435 435
436void PackageManager::doDetails() 436void PackageManager::doDetails()
437{ 437{
438 doCurrentDetails(FALSE); 438 doCurrentDetails(FALSE);
439} 439}
440 440
441void PackageManager::doNextDetails() 441void PackageManager::doNextDetails()
442{ 442{
443 QListViewItem* i = list->firstChild(); 443 QListViewItem* i = list->firstChild();
444 for ( ; i; i = i->nextSibling() ) { 444 for ( ; i; i = i->nextSibling() ) {
445 if ( i->isSelected() ) 445 if ( i->isSelected() )
446 break; 446 break;
447 } 447 }
448 list->setCurrentItem(i); 448 list->setCurrentItem(i);
449 if ( i ) { 449 if ( i ) {
450 doCurrentDetails(TRUE); 450 doCurrentDetails(TRUE);
451 } else if ( details ) 451 } else if ( details )
452 details->close(); 452 details->close();
453} 453}
454 454
455QString PackageManager::fullDetails(const QString& pk) 455QString PackageManager::fullDetails(const QString& pk)
456{ 456{
457 QString status; 457 QString status;
458 Process ipkg_status(QStringList() << "ipkg" << "info" << pk); 458 Process ipkg_status(QStringList() << "ipkg" << "info" << pk);
459 if ( ipkg_status.exec("",status) ) { 459 if ( ipkg_status.exec("",status) ) {
460 QStringList lines = QStringList::split('\n',status,TRUE); 460 QStringList lines = QStringList::split('\n',status,TRUE);
461 QString description; 461 QString description;
462 for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) { 462 for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) {
463 QString line = *it; 463 QString line = *it;
464 if ( line == " ." ) { 464 if ( line == " ." ) {
465 description.append("<p>"); 465 description.append("<p>");
466 } else if ( line[0] == ' ' || line[0] == '\t' ) { 466 } else if ( line[0] == ' ' || line[0] == '\t' ) {
467 // continuation 467 // continuation
468 description.append(" "); 468 description.append(" ");
469 description.append(Qtopia::escapeString(line)); 469 description.append(Qtopia::escapeString(line));
470 } else { 470 } else {
471 int sep = line.find(QRegExp(":[\t ]+")); 471 int sep = line.find(QRegExp(":[\t ]+"));
472 if ( sep >= 0 ) { 472 if ( sep >= 0 ) {
473 QString tag = line.left(sep); 473 QString tag = line.left(sep);
474 description.append("<br>"); 474 description.append("<br>");
475 description.append("<b>"); 475 description.append("<b>");
476 description.append(Qtopia::escapeString(tag)); 476 description.append(Qtopia::escapeString(tag));
477 description.append(":</b> "); 477 description.append(":</b> ");
478 description.append(Qtopia::escapeString(line.mid(sep+2))); 478 description.append(Qtopia::escapeString(line.mid(sep+2)));
479 } else { 479 } else {
480 description.append(" "); 480 description.append(" ");
481 description.append(Qtopia::escapeString(line)); 481 description.append(Qtopia::escapeString(line));
482 } 482 }
483 } 483 }
484 } 484 }
485 return description; 485 return description;
486 } 486 }
487 487
488 return QString::null; 488 return QString::null;
489} 489}
490 490
491void PackageManager::installCurrent() 491void PackageManager::installCurrent()
492{ 492{
493 current()->setOn(TRUE); 493 current()->setOn(TRUE);
494 details->close(); 494 details->close();
495} 495}
496 496
497void PackageManager::removeCurrent() 497void PackageManager::removeCurrent()
498{ 498{
499 current()->setOn(TRUE); 499 current()->setOn(TRUE);
500 details->close(); 500 details->close();
501} 501}
502 502
503bool PackageManager::readIpkgConfig(const QString& conffile) 503bool PackageManager::readIpkgConfig(const QString& conffile)
504{ 504{
505 QFile conf(conffile); 505 QFile conf(conffile);
506 if ( conf.open(IO_ReadOnly) ) { 506 if ( conf.open(IO_ReadOnly) ) {
507 QTextStream s(&conf); 507 QTextStream s(&conf);
508 settings->servers->clear(); 508 settings->servers->clear();
509 serverurl.clear(); 509 serverurl.clear();
510 ipkg_old=0; 510 ipkg_old=0;
511 int currentserver=0; 511 int currentserver=0;
512 while ( !s.atEnd() ) { 512 while ( !s.atEnd() ) {
513 QString l = s.readLine(); 513 QString l = s.readLine();
514 QStringList token = QStringList::split(' ', l); 514 QStringList token = QStringList::split(' ', l);
515 if ( token[0] == "src" || token[0] == "#src" ) { 515 if ( token[0] == "src" || token[0] == "#src" ) {
516 currentserver=settings->servers->count(); 516 currentserver=settings->servers->count();
517 serverurl.insert(settings->servers->count(),new QString(token[2])); 517 serverurl.insert(settings->servers->count(),new QString(token[2]));
518 int a = token[0] == "src" ? 1 : 0; 518 int a = token[0] == "src" ? 1 : 0;
519 int i = settings->servers->count(); 519 int i = settings->servers->count();
520 settings->servers->insertItem(token[1]); 520 settings->servers->insertItem(token[1]);
521 settings->servers->setSelected(i,a); 521 settings->servers->setSelected(i,a);
522 } else if ( token[0] == "dest" ) { 522 } else if ( token[0] == "dest" ) {
523 // needs UI 523 // needs UI
524 } else if ( token[0] == "option" ) { 524 } else if ( token[0] == "option" ) {
525 // ### somehow need to use the settings from netsetup 525 // ### somehow need to use the settings from netsetup
526 // if ( token[1] == "http_proxy" ) 526 // if ( token[1] == "http_proxy" )
527 // settings->http->setText(token[2]); 527 // settings->http->setText(token[2]);
528 // else if ( token[1] == "ftp_proxy" ) 528 // else if ( token[1] == "ftp_proxy" )
529 // settings->ftp->setText(token[2]); 529 // settings->ftp->setText(token[2]);
530 // else if ( token[1] == "proxy_username" ) 530 // else if ( token[1] == "proxy_username" )
531 // settings->username->setText(token[2]); 531 // settings->username->setText(token[2]);
532 // else if ( token[1] == "proxy_password" ) 532 // else if ( token[1] == "proxy_password" )
533 // settings->password->setText(token[2]); 533 // settings->password->setText(token[2]);
534 } else { 534 } else {
535 // Old style? 535 // Old style?
536 int eq = l.find('='); 536 int eq = l.find('=');
537 if ( eq >= 0 ) { 537 if ( eq >= 0 ) {
538 QString v = l.mid(eq+1).stripWhiteSpace(); 538 QString v = l.mid(eq+1).stripWhiteSpace();
539 if ( v[0] == '"' || v[0] == '\'' ) { 539 if ( v[0] == '"' || v[0] == '\'' ) {
540 int cl=v.find(v[0],1); 540 int cl=v.find(v[0],1);
541 if ( cl >= 0 ) 541 if ( cl >= 0 )
542 v = v.mid(1,cl-1); 542 v = v.mid(1,cl-1);
543 } 543 }
544 if ( l.left(12) == "IPKG_SOURCE=" ) { 544 if ( l.left(12) == "IPKG_SOURCE=" ) {
545 ipkg_old=1; 545 ipkg_old=1;
546 currentserver=settings->servers->count(); 546 currentserver=settings->servers->count();
547 serverurl.insert(settings->servers->count(),new QString(v)); 547 serverurl.insert(settings->servers->count(),new QString(v));
548 settings->servers->insertItem(v); 548 settings->servers->insertItem(v);
549 } else if ( l.left(13) == "#IPKG_SOURCE=" ) { 549 } else if ( l.left(13) == "#IPKG_SOURCE=" ) {
550 serverurl.insert(settings->servers->count(),new QString(v)); 550 serverurl.insert(settings->servers->count(),new QString(v));
551 settings->servers->insertItem(v); 551 settings->servers->insertItem(v);
552 } else if ( l.left(10) == "IPKG_ROOT=" ) { 552 } else if ( l.left(10) == "IPKG_ROOT=" ) {
553 // ### no UI 553 // ### no UI
554 // } else if ( l.left(20) == "IPKG_PROXY_USERNAME=" ) { 554 // } else if ( l.left(20) == "IPKG_PROXY_USERNAME=" ) {
555 // settings->username->setText(v); 555 // settings->username->setText(v);
556 // } else if ( l.left(20) == "IPKG_PROXY_PASSWORD=" ) { 556 // } else if ( l.left(20) == "IPKG_PROXY_PASSWORD=" ) {
557 // settings->password->setText(v); 557 // settings->password->setText(v);
558 // } else if ( l.left(16) == "IPKG_PROXY_HTTP=" ) { 558 // } else if ( l.left(16) == "IPKG_PROXY_HTTP=" ) {
559 // settings->http->setText(v); 559 // settings->http->setText(v);
560 // } else if ( l.left(16) == "IPKG_PROXY_FTP=" ) { 560 // } else if ( l.left(16) == "IPKG_PROXY_FTP=" ) {
561 // settings->ftp->setText(v); 561 // settings->ftp->setText(v);
562 } 562 }
563 } 563 }
564 } 564 }
565 } 565 }
566 if ( ipkg_old ) { 566 if ( ipkg_old ) {
567 settings->servers->setSelectionMode(QListBox::Single); 567 settings->servers->setSelectionMode(QListBox::Single);
568 settings->servers->setSelected(currentserver,TRUE); 568 settings->servers->setSelected(currentserver,TRUE);
569 } 569 }
570 return TRUE; 570 return TRUE;
571 } else { 571 } else {
572 return FALSE; 572 return FALSE;
573 } 573 }
574} 574}
575 575
576/* 576/*
577 * public slot 577 * public slot
578 */ 578 */
579void PackageManager::doSettings() 579void PackageManager::doSettings()
580{ 580{
581 settings->showMaximized(); 581 settings->showMaximized();
582 if ( settings->exec() ) { 582 if ( settings->exec() ) {
583 writeSettings(); 583 writeSettings();
584 startRun(); 584 startRun();
585 runIpkg("update"); 585 runIpkg("update");
586 endRun(); 586 endRun();
587 updatePackageList(); 587 updatePackageList();
588 } else { 588 } else {
589 readSettings(); 589 readSettings();
590 } 590 }
591} 591}
592 592
593void PackageManager::readSettings() 593void PackageManager::readSettings()
594{ 594{
595 // read from config file(s) 595 // read from config file(s)
596 readIpkgConfig("/etc/ipkg.conf"); 596 readIpkgConfig("/etc/ipkg.conf");
597} 597}
598 598
599void PackageManager::writeSettings() 599void PackageManager::writeSettings()
600{ 600{
601 QFile conf("/etc/ipkg.conf"); 601 QFile conf("/etc/ipkg.conf");
602 if ( conf.open(IO_WriteOnly) ) { 602 if ( conf.open(IO_WriteOnly) ) {
603 QTextStream s(&conf); 603 QTextStream s(&conf);
604 s << "# Written by Qtopia Package Manager\n"; 604 s << "# Written by Qtopia Package Manager\n";
605 if ( !ipkg_old ) { 605 if ( !ipkg_old ) {
606 for (int i=0; i<(int)settings->servers->count(); i++) { 606 for (int i=0; i<(int)settings->servers->count(); i++) {
607 QString url = serverurl[i] ? *serverurl[i] : QString("???"); 607 QString url = serverurl[i] ? *serverurl[i] : QString("???");
608 if ( !settings->servers->isSelected(i) ) 608 // if ( !settings->servers->isSelected(i) )
609 s << "#"; 609 // s << "#";
610 s << "src " << settings->servers->text(i) << " " << url << "\n"; 610 s << "src " << settings->servers->text(i) << " " << url << "\n";
611 } 611 }
612 s << "dest root /\n"; // ### need UI 612 s << "dest root /\n"; // ### need UI
613 // if ( !settings->username->text().isEmpty() ) 613 // if ( !settings->username->text().isEmpty() )
614 // s << "option proxy_username " << settings->username->text() << "\n"; 614 // s << "option proxy_username " << settings->username->text() << "\n";
615 // if ( !settings->password->text().isEmpty() ) 615 // if ( !settings->password->text().isEmpty() )
616 // s << "option proxy_password " << settings->password->text() << "\n"; 616 // s << "option proxy_password " << settings->password->text() << "\n";
617 // if ( !settings->http->text().isEmpty() ) 617 // if ( !settings->http->text().isEmpty() )
618 // s << "option http_proxy " << settings->http->text() << "\n"; 618 // s << "option http_proxy " << settings->http->text() << "\n";
619 // if ( !settings->ftp->text().isEmpty() ) 619 // if ( !settings->ftp->text().isEmpty() )
620 // s << "option ftp_proxy " << settings->ftp->text() << "\n"; 620 // s << "option ftp_proxy " << settings->ftp->text() << "\n";
621 } else { 621 } else {
622 // Old style 622 // Old style
623 bool src_selected=FALSE; 623 bool src_selected=FALSE;
624 for (int i=0; i<(int)settings->servers->count(); i++) { 624 for (int i=0; i<(int)settings->servers->count(); i++) {
625 if ( settings->servers->isSelected(i) ) { 625 if ( settings->servers->isSelected(i) ) {
626 src_selected=TRUE; 626 src_selected=TRUE;
627 } else { 627 } else {
628 s << "#"; 628 s << "#";
629 } 629 }
630 s << "IPKG_SOURCE=\"" << settings->servers->text(i) << "\"\n"; 630 s << "IPKG_SOURCE=\"" << settings->servers->text(i) << "\"\n";
631 } 631 }
632 if ( !src_selected ) 632 if ( !src_selected )
633 s << "IPKG_SOURCE=\"" << settings->servers->currentText() << "\"\n"; 633 s << "IPKG_SOURCE=\"" << settings->servers->currentText() << "\"\n";
634 s << "IPKG_ROOT=/\n" 634 s << "IPKG_ROOT=/\n"
635 // << "IPKG_PROXY_USERNAME=\"" << settings->username->text() << "\"\n" 635 // << "IPKG_PROXY_USERNAME=\"" << settings->username->text() << "\"\n"
636 // << "IPKG_PROXY_PASSWORD=\"" << settings->password->text() << "\"\n" 636 // << "IPKG_PROXY_PASSWORD=\"" << settings->password->text() << "\"\n"
637 // << "IPKG_PROXY_HTTP=\"" << settings->http->text() << "\"\n" 637 // << "IPKG_PROXY_HTTP=\"" << settings->http->text() << "\"\n"
638 // << "IPKG_PROXY_FTP=\"" << settings->ftp->text() << "\"\n" 638 // << "IPKG_PROXY_FTP=\"" << settings->ftp->text() << "\"\n"
639 ; 639 ;
640 } 640 }
641 conf.close(); 641 conf.close();
642 } 642 }
643} 643}
644 644
645/* 645/*
646 * public slot 646 * public slot
647 */ 647 */
648void PackageManager::doFind() 648void PackageManager::doFind()
649{ 649{
650 Search s(this, 0, TRUE); 650 Search s(this, 0, TRUE);
651 if ( s.exec() ) { 651 if ( s.exec() ) {
652 QString p = s.pattern->text(); 652 QString p = s.pattern->text();
653 if ( p.isEmpty() ) { 653 if ( p.isEmpty() ) {
654 list->selectAll(FALSE); 654 list->selectAll(FALSE);
655 } else { 655 } else {
656 selectPackages(findPackages(p)); 656 selectPackages(findPackages(p));
657 doNextDetails(); 657 doNextDetails();
658 } 658 }
659 } 659 }
660} 660}
661 661
662void PackageManager::selectPackages( const QStringList& l ) 662void PackageManager::selectPackages( const QStringList& l )
663{ 663{
664 QDict<void> d; 664 QDict<void> d;
665 for (QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) 665 for (QStringList::ConstIterator it = l.begin(); it != l.end(); ++it)
666 d.replace(*it,(void*)1); 666 d.replace(*it,(void*)1);
667 QListViewItem* i; 667 QListViewItem* i;
668 for ( i = list->firstChild(); i; i = i->nextSibling() ) { 668 for ( i = list->firstChild(); i; i = i->nextSibling() ) {
669 PackageItem* pit = (PackageItem*)i; 669 PackageItem* pit = (PackageItem*)i;
670 i->setSelected( d[pit->name()] ); 670 i->setSelected( d[pit->name()] );
671 } 671 }
672} 672}
673 673
674QStringList PackageManager::findPackages( const QRegExp& r ) 674QStringList PackageManager::findPackages( const QRegExp& r )
675{ 675{
676 QStringList matches; 676 QStringList matches;
677 677
678 QString info = ipkgInfoOutput(); 678 QString info = ipkgInfoOutput();
679 if ( !info.isEmpty() ) { 679 if ( !info.isEmpty() ) {
680 QStringList lines = QStringList::split('\n',info,TRUE); 680 QStringList lines = QStringList::split('\n',info,TRUE);
681 QRegExp re = r; 681 QRegExp re = r;
682 QString description=""; 682 QString description="";
683 QString name; 683 QString name;
684 for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) { 684 for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) {
685 QString line = *it; 685 QString line = *it;
686 if ( line.length()<=1 ) { 686 if ( line.length()<=1 ) {
687 // EOR 687 // EOR
688 if ( re.match(description) >= 0 ) 688 if ( re.match(description) >= 0 )
689 matches.append(name); 689 matches.append(name);
690 description=""; 690 description="";
691 name=""; 691 name="";
692 } else if ( line[0] == ' ' || line[0] == '\t' ) { 692 } else if ( line[0] == ' ' || line[0] == '\t' ) {
693 // continuation 693 // continuation
694 description.append(" "); 694 description.append(" ");
695 description.append(Qtopia::escapeString(line)); 695 description.append(Qtopia::escapeString(line));
696 } else { 696 } else {
697 int sep = line.find(QRegExp(":[\t ]+")); 697 int sep = line.find(QRegExp(":[\t ]+"));
698 if ( sep >= 0 ) { 698 if ( sep >= 0 ) {
699 QString tag = line.left(sep); 699 QString tag = line.left(sep);
700 if ( tag == "Package" ) 700 if ( tag == "Package" )
701 name = line.mid(sep+2).simplifyWhiteSpace(); 701 name = line.mid(sep+2).simplifyWhiteSpace();
702 if ( !description.isEmpty() ) 702 if ( !description.isEmpty() )
703 description.append("<br>"); 703 description.append("<br>");
704 description.append("<b>"); 704 description.append("<b>");
705 description.append(Qtopia::escapeString(tag)); 705 description.append(Qtopia::escapeString(tag));
706 description.append(":</b> "); 706 description.append(":</b> ");
707 description.append(Qtopia::escapeString(line.mid(sep+2))); 707 description.append(Qtopia::escapeString(line.mid(sep+2)));
708 } 708 }
709 } 709 }
710 } 710 }
711 } 711 }
712 712
713 return matches; 713 return matches;
714} 714}
715 715
716/* 716/*
717 * public slot 717 * public slot
718 */ 718 */
719void PackageManager::doUpgrade() 719void PackageManager::doUpgrade()
720{ 720{
721 startMultiRun(2); 721 startMultiRun(2);
722 runIpkg("update"); 722 runIpkg("update");
723 runIpkg("upgrade"); 723 runIpkg("upgrade");
724 updatePackageList(); 724 updatePackageList();
725 endRun(); 725 endRun();
726} 726}
727 727
728 728
729void PackageManager::doIt() 729void PackageManager::doIt()
730{ 730{
731 bool ok = commitWithIpkg(); 731 bool ok = commitWithIpkg();
732 updatePackageList(); // things may have changed 732 updatePackageList(); // things may have changed
733 if (!ok) qApp->beep(); 733 if (!ok) qApp->beep();
734} 734}
735 735
736bool PackageManager::commitWithIpkg() 736bool PackageManager::commitWithIpkg()
737{ 737{
738 // A full implementation would do the following, but we'll just do 738 // A full implementation would do the following, but we'll just do
739 // it simply and non-interactively for now. 739 // it simply and non-interactively for now.
740 // 740 //
741 // setenv IPKG_CONF_DIR for a null $IPKG_CONF_DIR/ipkg.conf 741 // setenv IPKG_CONF_DIR for a null $IPKG_CONF_DIR/ipkg.conf
742 // setenv IPKG_SOURCE, IPKG_ROOT, etc. 742 // setenv IPKG_SOURCE, IPKG_ROOT, etc.
743 // run ipkg, processing interactivity as dialogs 743 // run ipkg, processing interactivity as dialogs
744 // - "... (Y/I/N/O/D) [default=N] ?" -> ... 744 // - "... (Y/I/N/O/D) [default=N] ?" -> ...
745 // - "[Press ENTER to continue]" (if D chosen above) 745 // - "[Press ENTER to continue]" (if D chosen above)
746 // - "The following packages are marked `Essential'... Install them now [Y/n] ?" 746 // - "The following packages are marked `Essential'... Install them now [Y/n] ?"
747 // - "The following packages...ready to be installed:... Install them now [Y/n] ?" 747 // - "The following packages...ready to be installed:... Install them now [Y/n] ?"
748 // return FALSE cancelled 748 // return FALSE cancelled
749 749
750 QStringList to_remove, to_install; 750 QStringList to_remove, to_install;
751 751
752 for ( QListViewItem* i = list->firstChild(); i; i = i->nextSibling() ) { 752 for ( QListViewItem* i = list->firstChild(); i; i = i->nextSibling() ) {
753 PackageItem* pit = (PackageItem*)i; 753 PackageItem* pit = (PackageItem*)i;
754 if ( pit->isOn() ) { 754 if ( pit->isOn() ) {
755 if ( pit->isInstalled() ) 755 if ( pit->isInstalled() )
756 to_remove.append(pit->name()); 756 to_remove.append(pit->name());
757 else 757 else
758 to_install.append(pit->name()); 758 to_install.append(pit->name());
759 } 759 }
760 } 760 }
761 761
762 bool ok=TRUE; 762 bool ok=TRUE;
763 763
764 int jobs = to_remove.count()+to_install.count(); 764 int jobs = to_remove.count()+to_install.count();
765 if ( jobs ) { 765 if ( jobs ) {
766 startMultiRun(jobs); 766 startMultiRun(jobs);
767 767
768 if ( to_remove.count() ) { 768 if ( to_remove.count() ) {
769 for (QStringList::ConstIterator it=to_remove.begin(); it!=to_remove.end(); ++it) { 769 for (QStringList::ConstIterator it=to_remove.begin(); it!=to_remove.end(); ++it) {
770 if ( runIpkg("remove " + *it) != 0 ) { 770 if ( runIpkg("remove " + *it) != 0 ) {
771 ok = FALSE; 771 ok = FALSE;
772 } 772 }
773 } 773 }
774 } 774 }
775 if ( to_install.count() ) { 775 if ( to_install.count() ) {
776 for (QStringList::ConstIterator it=to_install.begin(); it!=to_install.end(); ++it) { 776 for (QStringList::ConstIterator it=to_install.begin(); it!=to_install.end(); ++it) {
777 if ( runIpkg("install " + *it) != 0 ) { 777 if ( runIpkg("install " + *it) != 0 ) {
778 ok = FALSE; 778 ok = FALSE;
779 } 779 }
780 } 780 }
781 } 781 }
782 782
783 // ##### If we looked in the list of files, we could send out accurate 783 // ##### If we looked in the list of files, we could send out accurate
784 // ##### messages. But we don't bother yet, and just do an "all". 784 // ##### messages. But we don't bother yet, and just do an "all".
785 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 785 QCopEnvelope e("QPE/System", "linkChanged(QString)");
786 QString lf = QString::null; 786 QString lf = QString::null;
787 e << lf; 787 e << lf;
788 788
789#if QT_VERSION > 230 // a bug breaks this otherwise 789#if QT_VERSION > 230 // a bug breaks this otherwise
790 if ( !ok ) 790 if ( !ok )
791 QMessageBox::warning(this, "Error", "<p><tt>ipkg</tt> says something went wrong. Sorry."); 791 QMessageBox::warning(this, "Error", "<p><tt>ipkg</tt> says something went wrong. Sorry.");
792#endif 792#endif
793 793
794 endRun(); 794 endRun();
795 } 795 }
796 796
797 return ok; 797 return ok;
798} 798}
799 799
800QString PackageManager::ipkgStatusOutput() 800QString PackageManager::ipkgStatusOutput()
801{ 801{
802 if ( cachedIpkgStatusOutput.isEmpty() ) { 802 if ( cachedIpkgStatusOutput.isEmpty() ) {
803 Process ipkg_status( QStringList() << "ipkg" << "status" ); 803 Process ipkg_status( QStringList() << "ipkg" << "status" );
804 ipkg_status.exec( 0, cachedIpkgStatusOutput ); 804 ipkg_status.exec( 0, cachedIpkgStatusOutput );
805 } 805 }
806 return QString::fromLocal8Bit( cachedIpkgStatusOutput ); 806 return QString::fromLocal8Bit( cachedIpkgStatusOutput );
807} 807}
808 808
809QString PackageManager::ipkgInfoOutput() 809QString PackageManager::ipkgInfoOutput()
810{ 810{
811 if ( cachedIpkgInfoOutput.isEmpty() ) { 811 if ( cachedIpkgInfoOutput.isEmpty() ) {
812 Process ipkg_info( QStringList() << "ipkg" << "info" ); 812 Process ipkg_info( QStringList() << "ipkg" << "info" );
813 ipkg_info.exec( 0, cachedIpkgInfoOutput ); 813 ipkg_info.exec( 0, cachedIpkgInfoOutput );
814 } 814 }
815 return QString::fromLocal8Bit( cachedIpkgInfoOutput ); 815 return QString::fromLocal8Bit( cachedIpkgInfoOutput );
816} 816}
817 817
818void PackageManager::setCachedIpkgOutputDirty() 818void PackageManager::setCachedIpkgOutputDirty()
819{ 819{
820 cachedIpkgInfoOutput = cachedIpkgStatusOutput = QString::null; 820 cachedIpkgInfoOutput = cachedIpkgStatusOutput = QString::null;
821} 821}
822 822
823void PackageManager::startMultiRun(int jobs) 823void PackageManager::startMultiRun(int jobs)
824{ 824{
825 startRun(); 825 startRun();
826 progress->setTotalSteps(jobs); 826 progress->setTotalSteps(jobs);
827 progress->setProgress(0); 827 progress->setProgress(0);
828} 828}
829 829
830void PackageManager::startRun() 830void PackageManager::startRun()
831{ 831{
832 progress->show(); 832 progress->show();
833 doit->hide(); 833 doit->hide();
834} 834}
835 835
836void PackageManager::endRun() 836void PackageManager::endRun()
837{ 837{
838 doit->show(); 838 doit->show();
839 progress->hide(); 839 progress->hide();
840} 840}
841 841
842int PackageManager::runIpkg(const QString& args) 842int PackageManager::runIpkg(const QString& args)
843{ 843{
844 if ( progress->progress() == -1 ) 844 if ( progress->progress() == -1 )
845 startMultiRun(1); 845 startMultiRun(1);
846 else 846 else
847 startRun(); 847 startRun();
848 QString cmd = "ipkg "; 848 QString cmd = "ipkg ";
849 if ( ipkg_old ) 849 if ( ipkg_old )
850 cmd += "</dev/null "; 850 cmd += "</dev/null ";
851 else 851 else
852 cmd += "-force-defaults "; 852 cmd += "-force-defaults ";
853 int r = system((cmd+args).latin1()); 853 int r = system((cmd+args).latin1());
854 progress->setProgress(progress->progress()+1); 854 progress->setProgress(progress->progress()+1);
855 setCachedIpkgOutputDirty(); 855 setCachedIpkgOutputDirty();
856 endRun(); 856 endRun();
857 return r; 857 return r;
858} 858}
859 859
860// simple hack to get support for ipkg mimetype 860// simple hack to get support for ipkg mimetype
861void PackageManager::maybeInstall( const QString &ipk ) 861void PackageManager::maybeInstall( const QString &ipk )
862{ 862{
863 int pos = ipk.findRev( "/" ); 863 int pos = ipk.findRev( "/" );
864 QString package = ipk.mid( pos + 1 ); 864 QString package = ipk.mid( pos + 1 );
865 pos = package.find ( "_" ); 865 pos = package.find ( "_" );
866 if ( pos != -1 ) 866 if ( pos != -1 )
867 package = package.left( pos ); 867 package = package.left( pos );
868 switch ( QMessageBox::information( 0, tr( "Install Package" ), 868 switch ( QMessageBox::information( 0, tr( "Install Package" ),
869 tr("Are you sure you want to\ninstall package\n\n%1") 869 tr("Are you sure you want to\ninstall package\n\n%1")
870 .arg(package), QMessageBox::Yes, 870 .arg(package), QMessageBox::Yes,
871 QMessageBox::No|QMessageBox::Default|QMessageBox::Escape, 0 ) ) { 871 QMessageBox::No|QMessageBox::Default|QMessageBox::Escape, 0 ) ) {
872 case QMessageBox::Yes: { 872 case QMessageBox::Yes: {
873 startRun(); 873 startRun();
874 runIpkg("install " + ipk ); 874 runIpkg("install " + ipk );
875 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 875 QCopEnvelope e("QPE/System", "linkChanged(QString)");
876 QString lf = QString::null; 876 QString lf = QString::null;
877 e << lf; 877 e << lf;
878 endRun(); 878 endRun();
879 } 879 }
880 break; 880 break;
881 case QMessageBox::No: 881 case QMessageBox::No:
882 default: 882 default:
883 // do nothing 883 // do nothing
884 break; 884 break;
885 } 885 }
886} 886}
887 887
888void PackageManager::setDocument(const QString& fileref) 888void PackageManager::setDocument(const QString& fileref)
889{ 889{
890 if ( fileref.isNull() ) 890 if ( fileref.isNull() )
891 return; 891 return;
892 DocLnk doc( fileref ); 892 DocLnk doc( fileref );
893 if ( doc.file().isEmpty() ) 893 if ( doc.file().isEmpty() )
894 return; 894 return;
895 maybeInstall( doc.file() ); 895 maybeInstall( doc.file() );
896 updatePackageList(); 896 updatePackageList();
897} 897}