Commit ee990e85 authored by LordTermor's avatar LordTermor

Snap plugin classes added

parent 74e345c4
#pragma once
#include <QObject>
#include <pamac.h>
#include <Package.h>
#include <Utils.h>
namespace LibQPamac {
class SnapPackage: public Package{
Q_GADGET
PAMAC_QT_STRING_PROPERTY_GET(channel, pamac_snap_package_get_channel(m_handle))
PAMAC_QT_STRING_PROPERTY_GET(publisher, pamac_snap_package_get_publisher(m_handle))
PAMAC_QT_STRING_PROPERTY_GET(license, pamac_snap_package_get_license(m_handle))
PAMAC_QT_STRING_PROPERTY_GET(confined, pamac_snap_package_get_confined(m_handle))
public:
SnapPackage() = default;
SnapPackage(PamacSnapPackage* pkg):m_handle(pkg){}
static SnapPackage fromData(void* data){return {reinterpret_cast<PamacSnapPackage*>(data)};};
PamacSnapPackage* handle() const {return m_handle;}
protected:
PamacSnapPackage *m_handle;
};
} // namespace LibQPamac
Q_DECLARE_METATYPE(LibQPamac::SnapPackage)
#pragma once
#include <pamac.h>
#include <QObject>
#include <SnapPackage.h>
namespace LibQPamac {
class SnapPlugin: public QObject {
Q_OBJECT
public:
explicit SnapPlugin(QObject* parent = nullptr);
Q_INVOKABLE QList<SnapPackage> searchSnaps(const QString& searchString ){
return Utils::gListToQList<SnapPackage>(pamac_snap_plugin_search_snaps(m_handle,searchString.toUtf8()),SnapPackage::fromData);
}
Q_INVOKABLE bool isInstalledSnap(const QString& name){
return pamac_snap_plugin_is_installed_snap(m_handle, name.toUtf8());
}
Q_INVOKABLE QList<SnapPackage> getInstalledSnaps(){
return Utils::gListToQList<SnapPackage>(pamac_snap_plugin_get_installed_snaps(m_handle),SnapPackage::fromData);
}
Q_INVOKABLE QList<SnapPackage> getCategorySnaps(const QString& category){
return Utils::gListToQList<SnapPackage>(pamac_snap_plugin_get_category_snaps(m_handle,category.toUtf8()),SnapPackage::fromData);
}
protected:
PamacSnapPlugin* m_handle;
};
} // namespace LibQPamac
......@@ -5,6 +5,8 @@
#include <memory>
#include <cstring>
#include "Database.h"
#include <SnapPackage.h>
namespace LibQPamac{
class Database;
class TransactionSummary{
......@@ -82,7 +84,8 @@ public:
}
Q_INVOKABLE bool run(const QStringList& toInstall = QStringList(), const QStringList& toRemove = QStringList(), const QStringList& toLoad = QStringList(),
const QStringList& toBuild = QStringList(), const QStringList& tempIgnore = QStringList(), const QStringList& overwriteFiles = QStringList());
const QStringList& toBuild = QStringList(), const QStringList& tempIgnore = QStringList(), const QStringList& overwriteFiles = QStringList(),
const QList<SnapPackage>& toInstallSnap = QList<SnapPackage>(), const QList<SnapPackage>& toRemoveSnap = QList<SnapPackage>());
Q_INVOKABLE bool runSysupgrade(bool forceRefresh);
......
#include <SnapPlugin.h>
LibQPamac::SnapPlugin::SnapPlugin(QObject *parent)
:QObject(parent)
{
}
......@@ -34,7 +34,8 @@ GenericQmlFuture LibQPamac::Transaction::getBuildFiles(const QString &pkgname){
}
bool LibQPamac::Transaction::run(const QStringList& toInstall, const QStringList& toRemove, const QStringList& toLoad,
const QStringList& toBuild, const QStringList& tempIgnore, const QStringList& overwriteFiles)
const QStringList& toBuild, const QStringList& tempIgnore, const QStringList& overwriteFiles,
const QList<SnapPackage>& toInstallSnap, const QList<SnapPackage>& toRemoveSnap)
{
for(auto& name : toInstall){
......@@ -60,6 +61,14 @@ bool LibQPamac::Transaction::run(const QStringList& toInstall, const QStringList
for(auto& name : overwriteFiles){
pamac_transaction_add_overwrite_file(m_handle,name.toUtf8());
}
for(auto& pkg :toInstallSnap){
pamac_transaction_add_snap_to_install(m_handle,pkg.handle());
}
for(auto& pkg: toRemoveSnap){
pamac_transaction_add_snap_to_remove(m_handle,pkg.handle());
}
setProperty("started",true);
auto result = bool(pamac_transaction_run(m_handle));
this->setProperty("progress",0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment