Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
Discover
Commits
42fca287
Commit
42fca287
authored
Jan 17, 2022
by
Aleix Pol Gonzalez
🐧
Committed by
Aleix Pol Gonzalez
Jan 20, 2022
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
Changes
7
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
libdiscover/backends/FlatpakBackend/FlatpakBackend.cpp
View file @
42fca287
...
...
@@ -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
)
{
...
...
libdiscover/backends/FlatpakBackend/FlatpakBackend.h
View file @
42fca287
...
...
@@ -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
);
...
...
libdiscover/backends/FlatpakBackend/FlatpakJobTransaction.h
View file @
42fca287
...
...
@@ -31,6 +31,9 @@ public Q_SLOTS:
void
finishTransaction
();
void
start
();
Q_SIGNALS:
void
repositoriesAdded
(
const
QStringList
&
repositoryNames
);
private:
void
updateProgress
();
...
...
libdiscover/backends/FlatpakBackend/FlatpakSourcesBackend.cpp
View file @
42fca287
...
...
@@ -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
);
}
}
}
}
libdiscover/backends/FlatpakBackend/FlatpakSourcesBackend.h
View file @
42fca287
...
...
@@ -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
);
...
...
libdiscover/backends/FlatpakBackend/FlatpakTransactionThread.cpp
View file @
42fca287
...
...
@@ -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
;
}
...
...
libdiscover/backends/FlatpakBackend/FlatpakTransactionThread.h
View file @
42fca287
...
...
@@ -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
Aleix Pol Gonzalez
🐧
@apol
mentioned in commit
550f0c29
·
Jan 20, 2022
mentioned in commit
550f0c29
mentioned in commit 550f0c29748a413685bcf0446ceb4642234dee91
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment