X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=aaptinterface.cpp;h=bda25dca4a718be7717da12dbc798059a90967a2;hb=HEAD;hp=1a0f04626d5683210ffd65059c5c6410d60536c7;hpb=0cd056de74ad46cfcd0cdca7f21a4ea47ff06b14;p=fapman diff --git a/aaptinterface.cpp b/aaptinterface.cpp index 1a0f046..bda25dc 100644 --- a/aaptinterface.cpp +++ b/aaptinterface.cpp @@ -86,12 +86,6 @@ AAptInterface::AAptInterface(QObject* parent = 0) : QObject(parent) QFile logfile(KLogFile); logfile.remove(); - // clear files left from old versions - QFile f1("/root/.fapman/dates.cache"); - f1.remove(); - QFile f2("/root/.fapman/lastupdate"); - f2.remove(); - readRepositoryInfo(); } @@ -106,7 +100,32 @@ AAptInterface::~AAptInterface() if( iProcAptGetClean->state() != QProcess::NotRunning ) iProcAptGetClean->kill(); - delete iDataReadBuffer; + // qprocesses are automatically deleted by their parent + + QHashIterator a( iPackagesAvailable ); + while (a.hasNext()) + { + a.next(); + delete a.value(); + } + iPackagesAvailable.clear(); + + QHashIterator i( iPackagesInstalled ); + while (i.hasNext()) + { + i.next(); + delete i.value(); + } + iPackagesInstalled.clear(); + + for(int x=0; xopenNetworkConnection(); + if( iUiDimmer ) { iUiDimmer->setProgress(0); iUiDimmer->updateText("Updating catalogs"); @@ -361,6 +382,8 @@ bool AAptInterface::startAptGetInstall() iProcAptGetInstallOutput.clear(); + iMainWindow->openNetworkConnection(); + qDebug() << "running apt-get install"; QString runBinary = "/usr/bin/apt-get"; @@ -526,7 +549,7 @@ QString AAptInterface::finishProcessCommonErrorMessages(QByteArray& output) } else if( output.contains("E: Broken packages") ) { msg = "Your system has broken packages or you are trying to install conflicting packages. See the log for details."; } else if( output.contains("E: Handler silently failed") ) { - msg = "Handler silently failed - This can happen if you try to install from the forbidden user/hidden category"; + msg = "Handler silently failed - This can happen if you try to install from the forbidden user/hidden category. Disabling OVI store repositories might help."; } else if( iTerminated ) { msg = "The operation was cancelled by user"; } else if( output.contains("Temporary failure resolving") || output.contains("Could not resolve host") ) { @@ -539,6 +562,10 @@ QString AAptInterface::finishProcessCommonErrorMessages(QByteArray& output) msg = "Some of your packages have unmet dependencies which could not be fixed. See the log for details."; } else if( output.contains("E: The method driver") ) { msg = "Apt failed to find a suitable method driver. One or more of your repositories might have an invalid URL."; + } else if( output.contains("E: Invalid record in the preferences file") ) { + msg = "Invalid record in the apt preferences file."; + } else if( output.contains("E: Malformed line") && output.contains("in source list") ) { + msg = "Malformed line in sources list. Check your repository settings."; } return msg; @@ -750,15 +777,26 @@ void AAptInterface::uiUpdaterAptGetUpdate() return; QStringList lines = QString( data.trimmed() ).split('\n'); + QString infoline; for( int i=0; iupdateText( QString("Updating catalogs (%1)").arg(iCatalogCounter) ); //qDebug() << iCatalogCounter << iCatalogsTotal; - iUiDimmer->setProgress( iCatalogCounter*100/iCatalogsTotal ); + + //iUiDimmer->updateText("Updating catalogs
" + infoline + ""); + + if( iCatalogsTotal > 0 ) + iUiDimmer->setProgress( iCatalogCounter*100/iCatalogsTotal ); } void AAptInterface::uiUpdaterAptGetInstall() @@ -789,7 +827,7 @@ void AAptInterface::uiUpdaterAptGetInstall() if( pkg!=0 ) { iAptGetCurrentDownloadFileName = pkg->fileName(); iAptGetCurrentFileTotalSize = pkg->size()/1024; - pkgname += QString(" (%1 kB)").arg(iAptGetCurrentFileTotalSize); + pkgname += QString(" (%L1 kB)").arg(iAptGetCurrentFileTotalSize); } iAptGetDownloadCount++; oper += QString(" %1/%2").arg(iAptGetDownloadCount).arg(iAptGetInstallTotal); @@ -961,6 +999,7 @@ void AAptInterface::readRepositoryInfo() //qDebug() << r->toListFileNames(); } else { delete r; + r=0; } } } @@ -984,8 +1023,10 @@ void AAptInterface::readRepositoryInfo() return; } - if( ownFound ) + if( ownFound ) { + qDebug() << "own repo lists found"; return; + } QFile ham( KHamRepoListFile ); if( ham.open(QIODevice::ReadOnly | QIODevice::Text ) ) @@ -996,20 +1037,26 @@ void AAptInterface::readRepositoryInfo() Repository* r = new Repository(); if( r->setFromString(line) ) { iRepositories.append(r); + +#ifdef Q_WS_MAEMO_5 + // disable the ovi repository by default + if( line.contains("https://downloads.maemo.nokia.com/fremantle1.2/ovi/") ) { + r->setEnabled(false); + } +#endif } else { delete r; + r=0; } } ham.close(); + qDebug() << "system repo list loaded"; } + } bool AAptInterface::writeRepositories() { -#ifndef Q_WS_MAEMO_5 // for simulator - return true; -#endif - iNeedListRefresh = true; QFile own( KOwnRepoFile ); @@ -1048,10 +1095,6 @@ bool AAptInterface::writeRepositories() bool AAptInterface::needRepoRefresh() { -#ifndef Q_WS_MAEMO_5 // for simulator - return false; -#endif - if( iNeedRepoRefresh || iSettings->qsettings()->value("need_repo_refresh", false).toBool() ) { iNeedRepoRefresh = false; iSettings->qsettings()->setValue("need_repo_refresh", false); @@ -1445,6 +1488,10 @@ bool AAptInterface::processPackageDataLine(Package*& pkg, QByteArray& line) { pkg->appendBreaks( line.mid(7).trimmed() ); } + else if( line.startsWith("Maintainer:") ) + { + pkg->setMaintainer( line.mid(11).trimmed() ); + } else if( line.startsWith("Description:") ) { @@ -1556,20 +1603,23 @@ void AAptInterface::removeFromBlacklist(Package *pkg, BlacklistSelect::blackList return; } - QStringList newlist; bool removed = false; for( int i=0; iname()) ) { - newlist << iBlacklist.at(i); - } else removed = true; + if( iBlacklist.at(i) == pkg->name() ) { + iBlacklist.removeAt(i); + i--; + removed = true; + } } else if( oldstate == BlacklistSelect::BlacklistThis ) { - if( !(iBlacklist.at(i) == (pkg->name()+" "+pkg->version())) ) { - newlist << iBlacklist.at(i); - } else removed = true; + if( iBlacklist.at(i) == (pkg->name()+" "+pkg->version()) ) { + iBlacklist.removeAt(i); + i--; + removed = true; + } } } @@ -1578,7 +1628,6 @@ void AAptInterface::removeFromBlacklist(Package *pkg, BlacklistSelect::blackList else qDebug() << "blacklist:" << pkg->name() << "not in saved list"; - iBlacklist = newlist; } @@ -1608,6 +1657,8 @@ void AAptInterface::startFetchDates() QApplication::processEvents(); } + iMainWindow->openNetworkConnection(); + QNetworkAccessManager* nam = new QNetworkAccessManager(this); if( iSettings->qsettings()->value("use_proxies").toBool() && !iSettings->qsettings()->value("http_proxy").toString().isEmpty() ) @@ -1628,7 +1679,7 @@ void AAptInterface::startFetchDates() i.next(); if( !i.value()->date().isValid() && i.value()->section().startsWith("user/") && !i.value()->isBlacklisted() ) { - Repository* repo = 0; + const Repository* repo = 0; for( int x=0; xrepositories().count(); x++ ) { if( i.value()->repositories().at(x) && i.value()->repositories().at(x)->url().startsWith("http://repository.maemo.org") ) { @@ -1665,13 +1716,13 @@ void AAptInterface::startFetchDates() if( !fe.value()->date().isValid() && fe.value()->section().startsWith("user/") && !fe.value()->isBlacklisted() ) { QString url; - Repository* repo = 0; + const Repository* repo = 0; QString fullFilename = "unknown_filename"; for( int x=0; xrepositories().count(); x++ ) { if( fe.value()->repositories().at(x) && fe.value()->repositories().at(x)->url().startsWith("http://repository.maemo.org") ) { repo = fe.value()->repositories().at(x); - if( fe.value()->fullFileNames().count()>x ) + if( repo && fe.value()->fullFileNames().count()>x ) fullFilename = fe.value()->fullFileNames().at(x); break; } @@ -1692,7 +1743,7 @@ void AAptInterface::startFetchDates() QApplication::processEvents(QEventLoop::WaitForMoreEvents); } } else { - while( iDateRequestsWaiting>50 ) { + while( iDateRequestsWaiting>5 ) { QApplication::processEvents(QEventLoop::WaitForMoreEvents); } } @@ -1723,6 +1774,7 @@ void AAptInterface::startFetchDates() updProgress++; } delete nam; + nam=0; if( iDateRequestsReceived>0 && iNetworkError != QNetworkReply::NoError && iNetworkError != QNetworkReply::QNetworkReply::ContentAccessDenied && iNetworkError != QNetworkReply::QNetworkReply::ContentNotFoundError ) @@ -1773,10 +1825,10 @@ void AAptInterface::dateFetchNetworkReply(QNetworkReply* reply) { iDateRequestsWaiting--; iDateRequestsReceived++; - //qDebug() << "reply" << reply->header(QNetworkRequest::LastModifiedHeader).toDateTime(); iNetworkError = reply->error(); + QDateTime dateModified = reply->header(QNetworkRequest::LastModifiedHeader).toDateTime(); - if( reply->error() == QNetworkReply::NoError && reply->header(QNetworkRequest::LastModifiedHeader).toDateTime().isValid() ) + if( reply->error() == QNetworkReply::NoError && dateModified.isValid() ) { QString pkgname = reply->url().fragment(); //qDebug() << pkgname; @@ -1786,7 +1838,7 @@ void AAptInterface::dateFetchNetworkReply(QNetworkReply* reply) Package* pkg = iPackagesAvailable.value(pkgname, 0); if( pkg ) { - pkg->setDate( reply->header(QNetworkRequest::LastModifiedHeader).toDateTime() ); + pkg->setDate( dateModified ); } else { qDebug() << "warning: unknown packagename in reply:" << pkgname; } @@ -1868,6 +1920,7 @@ void AAptInterface::readPinnedPackages() if( !f.exists() ) return; + bool warnAllPinned = false; if( f.open(QIODevice::ReadOnly | QIODevice::Text ) ) { qDebug() << "apt preferences exist: reading pinned packages"; @@ -1875,6 +1928,10 @@ void AAptInterface::readPinnedPackages() while( !f.atEnd() ) { QString line = f.readLine().trimmed(); + + if( line=="Package: *" || line=="Package:*") + warnAllPinned = true; + if( line.startsWith("Package:") ) { pinned_packages++; QString pkg = line.mid(8).trimmed(); @@ -1891,11 +1948,9 @@ void AAptInterface::readPinnedPackages() f.close(); qDebug() << "read" << pinned_packages << "pinned packages"; } -} - -bool AAptInterface::loadInstallFiles(QStringList files_) -{ - qDebug() << files_; - return false; + if( warnAllPinned ) { + iMainWindow->notifyDialog("Warning","You have pinned packages with '*' in apt preferences. It is strongly recommended to " + "remove such settings as they can result in unexpected behavior of Faster Application Manager."); + } }