-rw-r--r-- | noncore/unsupported/oipkg/packagemanager.cpp | 4 |
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 | |||
@@ -512,194 +512,194 @@ bool PackageManager::readIpkgConfig(const QString& conffile) | |||
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 | */ |
579 | void PackageManager::doSettings() | 579 | void 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 | ||
593 | void PackageManager::readSettings() | 593 | void 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 | ||
599 | void PackageManager::writeSettings() | 599 | void 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 | */ |
648 | void PackageManager::doFind() | 648 | void 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 | ||
662 | void PackageManager::selectPackages( const QStringList& l ) | 662 | void 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 | ||
674 | QStringList PackageManager::findPackages( const QRegExp& r ) | 674 | QStringList 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)); |