summaryrefslogtreecommitdiff
authorkergoth <kergoth>2002-04-14 01:02:18 (UTC)
committer kergoth <kergoth>2002-04-14 01:02:18 (UTC)
commited4148887805150f52e1f20d45efcefc1bb2f390 (patch) (side-by-side diff)
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) (show 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
@@ -416,386 +416,386 @@ void PackageManager::doCurrentDetails(bool multi)
if ( multi ) {
disconnect( details->ignore, SIGNAL(clicked()),
details, SLOT(close()));
connect( details->ignore, SIGNAL(clicked()),
this, SLOT(doNextDetails()));
} else {
disconnect( details->ignore, SIGNAL(clicked()),
this, SLOT(doNextDetails()));
connect( details->ignore, SIGNAL(clicked()),
details, SLOT(close()));
}
pit->setSelected(FALSE);
details->setCaption("Package: " + pit->name());
details->description->setText(fullDetails(pit->name()));
details->install->setEnabled(!pit->isInstalled());
details->remove->setEnabled(pit->isInstalled());
details->showMaximized();
}
}
void PackageManager::doDetails()
{
doCurrentDetails(FALSE);
}
void PackageManager::doNextDetails()
{
QListViewItem* i = list->firstChild();
for ( ; i; i = i->nextSibling() ) {
if ( i->isSelected() )
break;
}
list->setCurrentItem(i);
if ( i ) {
doCurrentDetails(TRUE);
} else if ( details )
details->close();
}
QString PackageManager::fullDetails(const QString& pk)
{
QString status;
Process ipkg_status(QStringList() << "ipkg" << "info" << pk);
if ( ipkg_status.exec("",status) ) {
QStringList lines = QStringList::split('\n',status,TRUE);
QString description;
for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) {
QString line = *it;
if ( line == " ." ) {
description.append("<p>");
} else if ( line[0] == ' ' || line[0] == '\t' ) {
// continuation
description.append(" ");
description.append(Qtopia::escapeString(line));
} else {
int sep = line.find(QRegExp(":[\t ]+"));
if ( sep >= 0 ) {
QString tag = line.left(sep);
description.append("<br>");
description.append("<b>");
description.append(Qtopia::escapeString(tag));
description.append(":</b> ");
description.append(Qtopia::escapeString(line.mid(sep+2)));
} else {
description.append(" ");
description.append(Qtopia::escapeString(line));
}
}
}
return description;
}
return QString::null;
}
void PackageManager::installCurrent()
{
current()->setOn(TRUE);
details->close();
}
void PackageManager::removeCurrent()
{
current()->setOn(TRUE);
details->close();
}
bool PackageManager::readIpkgConfig(const QString& conffile)
{
QFile conf(conffile);
if ( conf.open(IO_ReadOnly) ) {
QTextStream s(&conf);
settings->servers->clear();
serverurl.clear();
ipkg_old=0;
int currentserver=0;
while ( !s.atEnd() ) {
QString l = s.readLine();
QStringList token = QStringList::split(' ', l);
if ( token[0] == "src" || token[0] == "#src" ) {
currentserver=settings->servers->count();
serverurl.insert(settings->servers->count(),new QString(token[2]));
int a = token[0] == "src" ? 1 : 0;
int i = settings->servers->count();
settings->servers->insertItem(token[1]);
settings->servers->setSelected(i,a);
} else if ( token[0] == "dest" ) {
// needs UI
} else if ( token[0] == "option" ) {
// ### somehow need to use the settings from netsetup
// if ( token[1] == "http_proxy" )
// settings->http->setText(token[2]);
// else if ( token[1] == "ftp_proxy" )
// settings->ftp->setText(token[2]);
// else if ( token[1] == "proxy_username" )
// settings->username->setText(token[2]);
// else if ( token[1] == "proxy_password" )
// settings->password->setText(token[2]);
} else {
// Old style?
int eq = l.find('=');
if ( eq >= 0 ) {
QString v = l.mid(eq+1).stripWhiteSpace();
if ( v[0] == '"' || v[0] == '\'' ) {
int cl=v.find(v[0],1);
if ( cl >= 0 )
v = v.mid(1,cl-1);
}
if ( l.left(12) == "IPKG_SOURCE=" ) {
ipkg_old=1;
currentserver=settings->servers->count();
serverurl.insert(settings->servers->count(),new QString(v));
settings->servers->insertItem(v);
} else if ( l.left(13) == "#IPKG_SOURCE=" ) {
serverurl.insert(settings->servers->count(),new QString(v));
settings->servers->insertItem(v);
} else if ( l.left(10) == "IPKG_ROOT=" ) {
// ### no UI
// } else if ( l.left(20) == "IPKG_PROXY_USERNAME=" ) {
// settings->username->setText(v);
// } else if ( l.left(20) == "IPKG_PROXY_PASSWORD=" ) {
// settings->password->setText(v);
// } else if ( l.left(16) == "IPKG_PROXY_HTTP=" ) {
// settings->http->setText(v);
// } else if ( l.left(16) == "IPKG_PROXY_FTP=" ) {
// settings->ftp->setText(v);
}
}
}
}
if ( ipkg_old ) {
settings->servers->setSelectionMode(QListBox::Single);
settings->servers->setSelected(currentserver,TRUE);
}
return TRUE;
} else {
return FALSE;
}
}
/*
* public slot
*/
void PackageManager::doSettings()
{
settings->showMaximized();
if ( settings->exec() ) {
writeSettings();
startRun();
runIpkg("update");
endRun();
updatePackageList();
} else {
readSettings();
}
}
void PackageManager::readSettings()
{
// read from config file(s)
readIpkgConfig("/etc/ipkg.conf");
}
void PackageManager::writeSettings()
{
QFile conf("/etc/ipkg.conf");
if ( conf.open(IO_WriteOnly) ) {
QTextStream s(&conf);
s << "# Written by Qtopia Package Manager\n";
if ( !ipkg_old ) {
for (int i=0; i<(int)settings->servers->count(); i++) {
QString url = serverurl[i] ? *serverurl[i] : QString("???");
- if ( !settings->servers->isSelected(i) )
- s << "#";
+// if ( !settings->servers->isSelected(i) )
+// s << "#";
s << "src " << settings->servers->text(i) << " " << url << "\n";
}
s << "dest root /\n"; // ### need UI
// if ( !settings->username->text().isEmpty() )
// s << "option proxy_username " << settings->username->text() << "\n";
// if ( !settings->password->text().isEmpty() )
// s << "option proxy_password " << settings->password->text() << "\n";
// if ( !settings->http->text().isEmpty() )
// s << "option http_proxy " << settings->http->text() << "\n";
// if ( !settings->ftp->text().isEmpty() )
// s << "option ftp_proxy " << settings->ftp->text() << "\n";
} else {
// Old style
bool src_selected=FALSE;
for (int i=0; i<(int)settings->servers->count(); i++) {
if ( settings->servers->isSelected(i) ) {
src_selected=TRUE;
} else {
s << "#";
}
s << "IPKG_SOURCE=\"" << settings->servers->text(i) << "\"\n";
}
if ( !src_selected )
s << "IPKG_SOURCE=\"" << settings->servers->currentText() << "\"\n";
s << "IPKG_ROOT=/\n"
// << "IPKG_PROXY_USERNAME=\"" << settings->username->text() << "\"\n"
// << "IPKG_PROXY_PASSWORD=\"" << settings->password->text() << "\"\n"
// << "IPKG_PROXY_HTTP=\"" << settings->http->text() << "\"\n"
// << "IPKG_PROXY_FTP=\"" << settings->ftp->text() << "\"\n"
;
}
conf.close();
}
}
/*
* public slot
*/
void PackageManager::doFind()
{
Search s(this, 0, TRUE);
if ( s.exec() ) {
QString p = s.pattern->text();
if ( p.isEmpty() ) {
list->selectAll(FALSE);
} else {
selectPackages(findPackages(p));
doNextDetails();
}
}
}
void PackageManager::selectPackages( const QStringList& l )
{
QDict<void> d;
for (QStringList::ConstIterator it = l.begin(); it != l.end(); ++it)
d.replace(*it,(void*)1);
QListViewItem* i;
for ( i = list->firstChild(); i; i = i->nextSibling() ) {
PackageItem* pit = (PackageItem*)i;
i->setSelected( d[pit->name()] );
}
}
QStringList PackageManager::findPackages( const QRegExp& r )
{
QStringList matches;
QString info = ipkgInfoOutput();
if ( !info.isEmpty() ) {
QStringList lines = QStringList::split('\n',info,TRUE);
QRegExp re = r;
QString description="";
QString name;
for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) {
QString line = *it;
if ( line.length()<=1 ) {
// EOR
if ( re.match(description) >= 0 )
matches.append(name);
description="";
name="";
} else if ( line[0] == ' ' || line[0] == '\t' ) {
// continuation
description.append(" ");
description.append(Qtopia::escapeString(line));
} else {
int sep = line.find(QRegExp(":[\t ]+"));
if ( sep >= 0 ) {
QString tag = line.left(sep);
if ( tag == "Package" )
name = line.mid(sep+2).simplifyWhiteSpace();
if ( !description.isEmpty() )
description.append("<br>");
description.append("<b>");
description.append(Qtopia::escapeString(tag));
description.append(":</b> ");
description.append(Qtopia::escapeString(line.mid(sep+2)));
}
}
}
}
return matches;
}
/*
* public slot
*/
void PackageManager::doUpgrade()
{
startMultiRun(2);
runIpkg("update");
runIpkg("upgrade");
updatePackageList();
endRun();
}
void PackageManager::doIt()
{
bool ok = commitWithIpkg();
updatePackageList(); // things may have changed
if (!ok) qApp->beep();
}
bool PackageManager::commitWithIpkg()
{
// A full implementation would do the following, but we'll just do
// it simply and non-interactively for now.
//
// setenv IPKG_CONF_DIR for a null $IPKG_CONF_DIR/ipkg.conf
// setenv IPKG_SOURCE, IPKG_ROOT, etc.
// run ipkg, processing interactivity as dialogs
// - "... (Y/I/N/O/D) [default=N] ?" -> ...
// - "[Press ENTER to continue]" (if D chosen above)
// - "The following packages are marked `Essential'... Install them now [Y/n] ?"
// - "The following packages...ready to be installed:... Install them now [Y/n] ?"
// return FALSE cancelled
QStringList to_remove, to_install;
for ( QListViewItem* i = list->firstChild(); i; i = i->nextSibling() ) {
PackageItem* pit = (PackageItem*)i;
if ( pit->isOn() ) {
if ( pit->isInstalled() )
to_remove.append(pit->name());
else
to_install.append(pit->name());
}
}
bool ok=TRUE;
int jobs = to_remove.count()+to_install.count();
if ( jobs ) {
startMultiRun(jobs);
if ( to_remove.count() ) {
for (QStringList::ConstIterator it=to_remove.begin(); it!=to_remove.end(); ++it) {
if ( runIpkg("remove " + *it) != 0 ) {
ok = FALSE;
}
}
}
if ( to_install.count() ) {
for (QStringList::ConstIterator it=to_install.begin(); it!=to_install.end(); ++it) {
if ( runIpkg("install " + *it) != 0 ) {
ok = FALSE;
}
}
}
// ##### If we looked in the list of files, we could send out accurate
// ##### messages. But we don't bother yet, and just do an "all".
QCopEnvelope e("QPE/System", "linkChanged(QString)");
QString lf = QString::null;
e << lf;
#if QT_VERSION > 230 // a bug breaks this otherwise
if ( !ok )
QMessageBox::warning(this, "Error", "<p><tt>ipkg</tt> says something went wrong. Sorry.");
#endif
endRun();
}
return ok;
}
QString PackageManager::ipkgStatusOutput()
{