Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
libkleo
Commits
82b04017
Commit
82b04017
authored
Feb 17, 2021
by
Ingo Klöcker
Browse files
Move most code of update() to private implementation
GnuPG-bug-id: 5175, 5239
parent
6838d7c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/models/keycache.cpp
View file @
82b04017
...
...
@@ -340,6 +340,37 @@ public:
readGroupsFromGroupsConfig
();
}
bool
update
(
const
KeyGroup
&
group
)
{
Q_ASSERT
(
!
group
.
isNull
());
Q_ASSERT
(
group
.
source
()
==
KeyGroup
::
ApplicationConfig
);
if
(
group
.
isNull
()
||
group
.
source
()
!=
KeyGroup
::
ApplicationConfig
)
{
qCDebug
(
LIBKLEO_LOG
)
<<
"KeyCache::Private::update - Invalid group:"
<<
group
;
return
false
;
}
const
auto
it
=
std
::
find_if
(
m_groups
.
cbegin
(),
m_groups
.
cend
(),
[
group
]
(
const
auto
&
g
)
{
return
g
.
source
()
==
group
.
source
()
&&
g
.
id
()
==
group
.
id
();
});
if
(
it
==
m_groups
.
cend
())
{
qCDebug
(
LIBKLEO_LOG
)
<<
"KeyCache::Private::update - Group not found in list of groups:"
<<
group
;
return
false
;
}
const
auto
groupIndex
=
std
::
distance
(
m_groups
.
cbegin
(),
it
);
const
KeyGroup
savedGroup
=
writeGroupToGroupsConfig
(
group
);
if
(
savedGroup
.
isNull
())
{
qCDebug
(
LIBKLEO_LOG
)
<<
"KeyCache::Private::update - Writing group"
<<
group
.
id
()
<<
"to config file failed"
;
return
false
;
}
m_groups
[
groupIndex
]
=
savedGroup
;
Q_EMIT
q
->
groupUpdated
(
savedGroup
);
return
true
;
}
private:
QPointer
<
RefreshKeysJob
>
m_refreshJob
;
std
::
vector
<
std
::
shared_ptr
<
FileSystemWatcher
>
>
m_fsWatchers
;
...
...
@@ -1012,31 +1043,10 @@ std::vector<KeyGroup> KeyCache::groups() const
bool
KeyCache
::
update
(
const
KeyGroup
&
group
)
{
Q_ASSERT
(
!
group
.
isNull
());
Q_ASSERT
(
group
.
source
()
==
KeyGroup
::
ApplicationConfig
);
if
(
group
.
isNull
()
||
group
.
source
()
!=
KeyGroup
::
ApplicationConfig
)
{
qCDebug
(
LIBKLEO_LOG
)
<<
"KeyCache::update - Invalid group:"
<<
group
;
return
false
;
}
const
auto
it
=
std
::
find_if
(
d
->
m_groups
.
cbegin
(),
d
->
m_groups
.
cend
(),
[
group
]
(
const
auto
&
g
)
{
return
g
.
source
()
==
group
.
source
()
&&
g
.
id
()
==
group
.
id
();
});
if
(
it
==
d
->
m_groups
.
cend
())
{
qCDebug
(
LIBKLEO_LOG
)
<<
"KeyCache::update - Group not found in list of groups:"
<<
group
;
if
(
!
d
->
update
(
group
))
{
return
false
;
}
const
auto
groupIndex
=
std
::
distance
(
d
->
m_groups
.
cbegin
(),
it
);
const
KeyGroup
savedGroup
=
d
->
writeGroupToGroupsConfig
(
group
);
if
(
savedGroup
.
isNull
())
{
qCDebug
(
LIBKLEO_LOG
)
<<
"KeyCache::update - Writing group"
<<
group
.
id
()
<<
"to config file failed"
;
return
false
;
}
d
->
m_groups
[
groupIndex
]
=
savedGroup
;
Q_EMIT
groupUpdated
(
savedGroup
);
Q_EMIT
keysMayHaveChanged
();
return
true
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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