repoindex/alpm/alpmdatabase.h

85 lines
1.9 KiB
C
Raw Normal View History

2015-09-04 14:37:01 +02:00
#ifndef ALPM_DATABASE_H
#define ALPM_DATABASE_H
#include "./repository.h"
2015-09-04 14:37:01 +02:00
#include <QJsonArray>
#include <QMutex>
#include <QFuture>
#include <memory>
2015-09-04 14:37:01 +02:00
QT_FORWARD_DECLARE_CLASS(QNetworkRequest)
namespace RepoIndex {
2015-09-04 14:37:01 +02:00
class AlpmPackage;
class AlpmDatabase;
2016-02-14 23:48:43 +01:00
class LoadPackage;
2016-01-18 20:34:29 +01:00
class AlpmPackageLoader : public PackageLoader
2015-09-04 14:37:01 +02:00
{
public:
2016-02-14 23:48:43 +01:00
AlpmPackageLoader(AlpmDatabase *db, PackageOrigin origin);
private:
2016-02-14 23:48:43 +01:00
QList<QPair<QString, QList<QByteArray> > > m_descriptions;
};
class AlpmDatabase : public Repository
{
2016-02-14 23:48:43 +01:00
friend class AlpmPackageLoader;
public:
2016-02-14 23:48:43 +01:00
explicit AlpmDatabase(const QString &name, const QString &dbPath, RepositoryUsage usage, SignatureLevel sigLevel, uint32 index = invalidIndex, QObject *parent = nullptr);
2016-01-18 20:34:29 +01:00
AlpmPackageLoader *init();
2015-09-04 14:37:01 +02:00
RepositoryType type() const;
PackageDetailAvailability requestsRequired(PackageDetail packageDetail) const;
2015-09-04 14:37:01 +02:00
// database meta data
2016-02-14 23:48:43 +01:00
const QString &databasePath() const;
void setDatabasePath(const QString &dbPath);
2015-09-04 14:37:01 +02:00
// updating/refreshing
void downloadDatabase(const QString &targetDir, bool filesDatabase = true);
void refresh(const QString &targetDir);
signals:
void initiated();
2016-02-12 01:05:08 +01:00
protected:
std::unique_ptr<Package> emptyPackage();
private slots:
void databaseDownloadFinished();
2015-09-04 14:37:01 +02:00
private:
2016-02-14 23:48:43 +01:00
void loadDescriptions(QList<QPair<QString, QList<QByteArray> > > &descriptions);
QNetworkRequest regularDatabaseRequest();
QNetworkRequest filesDatabaseRequest();
2015-09-04 14:37:01 +02:00
2016-02-14 23:48:43 +01:00
QString m_dbPath;
QString m_downloadTargetDir;
2016-02-14 23:48:43 +01:00
};
2015-09-04 14:37:01 +02:00
/*!
2016-02-14 23:48:43 +01:00
* \brief Returns the path of the database directory/file.
2015-09-04 14:37:01 +02:00
*/
2016-02-14 23:48:43 +01:00
inline const QString &AlpmDatabase::databasePath() const
2015-09-04 14:37:01 +02:00
{
2016-02-14 23:48:43 +01:00
return m_dbPath;
2015-09-04 14:37:01 +02:00
}
/*!
2016-02-14 23:48:43 +01:00
* \brief Sets the path of the database directory/file.
* \remarks Does not invoke reinitialization using the new path.
2015-09-04 14:37:01 +02:00
*/
2016-02-14 23:48:43 +01:00
inline void AlpmDatabase::setDatabasePath(const QString &dbPath)
2015-09-04 14:37:01 +02:00
{
2016-02-14 23:48:43 +01:00
m_dbPath = dbPath;
2015-09-04 14:37:01 +02:00
}
} // namespace Alpm
#endif // ALPM_DATABASE_H