repoindex/lib/alpm/aurpackage.cpp

62 lines
2.2 KiB
C++
Raw Normal View History

#include "./aurpackage.h"
2015-09-04 14:37:01 +02:00
#include "../network/userrepository.h"
2015-09-04 14:37:01 +02:00
#include <QJsonObject>
2019-06-10 22:51:09 +02:00
using namespace CppUtilities;
2015-09-04 14:37:01 +02:00
namespace RepoIndex {
2015-09-04 14:37:01 +02:00
/*!
* \brief The AurPackage class holds information about AUR packages. It allows to convert the information
* to JSON objects used by the network classes and the web interface.
*/
/*!
* \brief Creates a new instance from the specified "AurJson value".
*/
2015-09-27 19:29:45 +02:00
AurPackage::AurPackage(const QJsonObject &aurJsonObject, UserRepository *repository) :
2015-09-12 20:37:04 +02:00
Package(QString(), repository)
2015-09-04 14:37:01 +02:00
{
m_origin = PackageOrigin::Aur;
2015-09-27 19:29:45 +02:00
putJson(aurJsonObject);
2015-09-04 14:37:01 +02:00
}
/*!
* \brief Creates a new instance where only the name is known.
*/
AurPackage::AurPackage(const QString &name, UserRepository *repository) :
Package(name, repository)
{}
/*!
* \brief Creates a new, empty instance.
* \remarks The only purpose of this c'tor is to use it with restoreFromCacheStream().
*/
2015-09-12 20:37:04 +02:00
AurPackage::AurPackage(UserRepository *repository) :
Package(QString(), repository)
{}
2015-09-27 19:29:45 +02:00
void AurPackage::putJson(const QJsonObject &aurJsonObject)
{
m_name = aurJsonObject.value(QStringLiteral("Name")).toString();
m_hasGeneralInfo = true;
m_id = aurJsonObject.value(QStringLiteral("ID")).toInt(-1);
m_categoryId = aurJsonObject.value(QStringLiteral("CategoryID")).toInt(-1);
m_version = aurJsonObject.value(QStringLiteral("Version")).toString();
m_description = aurJsonObject.value(QStringLiteral("Description")).toString();
m_upstreamUrl = aurJsonObject.value(QStringLiteral("URL")).toString();
m_votes = aurJsonObject.value(QStringLiteral("NumVotes")).toInt(0);
m_outOfDate = DateTime::fromTimeStamp(aurJsonObject.value(QStringLiteral("OutOfDate")).toInt());
m_maintainer = aurJsonObject.value(QStringLiteral("Maintainer")).toString();
m_firstSubmitted = DateTime::fromTimeStamp(aurJsonObject.value(QStringLiteral("FirstSubmitted")).toInt());
m_lastModified = DateTime::fromTimeStamp(aurJsonObject.value(QStringLiteral("LastModified")).toInt());
m_licenses.clear();
m_licenses << aurJsonObject.value(QStringLiteral("License")).toString();
m_tarUrl = aurJsonObject.value(QStringLiteral("URLPath")).toString();
}
2015-09-04 14:37:01 +02:00
} // namespace PackageManagement