Commit 42fca287 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

flatpak: Add the repositories added by a transaction

BUG: 447772
parent 455087d4
Pipeline #126078 passed with stage
in 1 minute and 12 seconds
......@@ -1560,6 +1560,7 @@ Transaction *FlatpakBackend::removeApplication(AbstractResource *app)
}
FlatpakJobTransaction *transaction = new FlatpakJobTransaction(resource, Transaction::RemoveRole);
connect(transaction, &FlatpakJobTransaction::repositoriesAdded, m_sources, &FlatpakSourcesBackend::checkRepositories);
connect(transaction, &FlatpakJobTransaction::statusChanged, this, [this, resource](Transaction::Status status) {
if (status == Transaction::Status::DoneStatus) {
......
......@@ -77,6 +77,10 @@ public:
void unloadRemote(FlatpakInstallation *installation, FlatpakRemote *remote);
HelpfulError *explainDysfunction() const override;
QVector<FlatpakInstallation *> installations() const
{
return m_installations;
}
private Q_SLOTS:
void onFetchMetadataFinished(FlatpakResource *resource, const QByteArray &metadata);
......
......@@ -31,6 +31,9 @@ public Q_SLOTS:
void finishTransaction();
void start();
Q_SIGNALS:
void repositoriesAdded(const QStringList &repositoryNames);
private:
void updateProgress();
......
......@@ -457,3 +457,19 @@ void FlatpakSourcesBackend::proceed()
{
m_proceedFunctions.pop()();
}
void FlatpakSourcesBackend::checkRepositories(const QStringList &repoNames)
{
FlatpakBackend *backend = qobject_cast<FlatpakBackend *>(parent());
const auto insts = backend->installations();
for (const QString &repoName : repoNames) {
const QByteArray name = repoName.toUtf8();
for (auto installation : insts) {
g_autoptr(GError) error = nullptr;
auto remote = flatpak_installation_get_remote_by_name(installation, name, nullptr, &error);
if (remote) {
addRemote(remote, installation);
}
}
}
}
......@@ -57,6 +57,7 @@ public:
void proceed() override;
static void populateRemote(FlatpakRemote *remote, const QString &name, const QString &url, const QString &gpgkey);
void checkRepositories(const QStringList &repoNames);
private:
bool listRepositories(FlatpakInstallation *installation);
......
......@@ -12,13 +12,19 @@
static int FLATPAK_CLI_UPDATE_FREQUENCY = 150;
gboolean add_new_remote_cb(FlatpakTransaction * /*object*/, gint /*reason*/, gchar *from_id, gchar *suggested_remote_name, gchar *url, gpointer user_data)
gboolean FlatpakTransactionThread::add_new_remote_cb(FlatpakTransaction * /*object*/,
gint /*reason*/,
gchar *from_id,
gchar *suggested_remote_name,
gchar *url,
gpointer user_data)
{
FlatpakTransactionThread *obj = (FlatpakTransactionThread *)user_data;
// TODO ask instead
obj->m_addedRepositories << QString::fromUtf8(suggested_remote_name);
Q_EMIT obj->passiveMessage(
i18n("Adding remote '%1' in %2 from %3", QString::fromUtf8(suggested_remote_name), QString::fromUtf8(url), QString::fromUtf8(from_id)));
i18n("Adding remote '%1' in %2 from %3", obj->m_addedRepositories.constLast(), QString::fromUtf8(url), QString::fromUtf8(from_id)));
return true;
}
......
......@@ -40,6 +40,10 @@ public:
}
void addErrorMessage(const QString &error);
QStringList addedRepositories() const
{
return m_addedRepositories;
}
Q_SIGNALS:
void progressChanged(int progress);
......@@ -47,8 +51,10 @@ Q_SIGNALS:
void passiveMessage(const QString &msg);
private:
FlatpakTransaction *m_transaction;
static gboolean
add_new_remote_cb(FlatpakTransaction * /*object*/, gint /*reason*/, gchar *from_id, gchar *suggested_remote_name, gchar *url, gpointer user_data);
FlatpakTransaction *m_transaction;
bool m_result = false;
bool m_cancelled = false;
int m_progress = 0;
......@@ -57,6 +63,7 @@ private:
GCancellable *m_cancellable;
FlatpakResource *const m_app;
const Transaction::Role m_role;
QStringList m_addedRepositories;
};
#endif // FLATPAKTRANSACTIONJOB_H
Supports Markdown
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