[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/sysadmin/libqapt/src
From: Jonathan Michael Thomas <echidnaman () kubuntu ! org>
Date: 2010-12-23 3:01:50
Message-ID: 20101223030150.BD06C3E1F1 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1208758 by jmthomas:
Add a Package::controlField() function to get the string data of a certain field of \
the package control file. With this, we can obtain an accurate value for the \
supportedUntil() function instead of hardcoding 18 months. It can also be used to get \
custom fields such as GStreamer-specific tools
M +28 -2 package.cpp
M +2 -0 package.h
--- trunk/extragear/sysadmin/libqapt/src/package.cpp #1208757:1208758
@@ -508,14 +508,40 @@
return QString();
}
- //FIXME: Figure out how to get the value from the package record
- const int supportTime = 18; // months
+ QString supportTimeString = controlField(QLatin1String("Supported"));
+ supportTimeString.chop(1); // Remove the letter signifying months
+ const int supportTime = supportTimeString.toInt(); // months
QDateTime supportEnd = \
QDateTime::fromTime_t(releaseDate).addMonths(supportTime);
return supportEnd.toString(QLatin1String("MMMM yyyy"));
}
+QString Package::controlField(const QLatin1String &name) const
+{
+ QString field;
+ pkgCache::VerIterator ver = \
(*d->depCache)[*d->packageIter].CandidateVerIter(*d->depCache); + if (ver.end()) {
+ return field;
+ }
+
+ pkgRecords::Parser &rec = d->records->Lookup(ver.FileList());
+ const char *start, *stop;
+ rec.GetRec(start, stop);
+ QString record(start);
+
+ QStringList lines = record.split(QLatin1Char('\n'));
+
+ foreach (const QString &line, lines) {
+ if (line.startsWith(name)) {
+ field = line.split(QLatin1String(": ")).at(1);
+ break;
+ }
+ }
+
+ return field;
+}
+
qint64 Package::currentInstalledSize() const
{
pkgCache::VerIterator ver = d->packageIter->CurrentVer();
--- trunk/extragear/sysadmin/libqapt/src/package.h #1208757:1208758
@@ -256,6 +256,8 @@
*/
QString supportedUntil() const;
+ QString controlField(const QLatin1String &name) const;
+
/**
* Returns the amount of hard drive space that the currently-installed
* version of this package takes up.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic