Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
PIM
KAlarm
Commits
4aca027e
Commit
4aca027e
authored
Dec 17, 2020
by
David Jarvie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Alter priority for removing duplicate Akonadi resources
Give priority to keeping enabled, standard, resources.
parent
4658689a
Pipeline
#44445
passed with stage
in 12 minutes and 37 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
8 deletions
+55
-8
Changelog
Changelog
+2
-1
src/resources/akonadiresource.cpp
src/resources/akonadiresource.cpp
+53
-7
No files found.
Changelog
View file @
4aca027e
KAlarm Change Log
=== Version 3.1.1 (KDE Applications 20.12.1) --- 1
6
December 2020 ===
=== Version 3.1.1 (KDE Applications 20.12.1) --- 1
8
December 2020 ===
* Ensure that build uses the file resources option.
* When removing duplicate Akonadi resources, in priority keep enabled/standard ones.
* Fix regression introduced in version 3.1.0:
Show correct alarm columns in main window on first run of KAlarm.
...
...
src/resources/akonadiresource.cpp
View file @
4aca027e
...
...
@@ -34,6 +34,20 @@ using namespace Akonadi;
namespace
{
// Holds an Akonadi Collection's properties.
struct
CollectionProperties
{
QColor
backgroundColour
;
CalEvent
::
Types
alarmTypes
;
CalEvent
::
Types
enabledTypes
{
CalEvent
::
EMPTY
};
CalEvent
::
Types
standardTypes
{
CalEvent
::
EMPTY
};
bool
readOnly
;
// Fetch the properties of a Collection which has been fetched by CollectionFetchJob.
CollectionProperties
(
const
Collection
&
);
};
const
Collection
::
Rights
WritableRights
=
Collection
::
CanChangeItem
|
Collection
::
CanCreateItem
|
Collection
::
CanDeleteItem
;
const
QRegularExpression
MatchMimeType
(
QStringLiteral
(
"^application/x-vnd
\\
.kde
\\
.alarm.*"
),
...
...
@@ -65,10 +79,10 @@ private:
struct
ResourceCol
{
QString
resourceId
;
// Akonadi resource identifier
ResourceId
collection
Id
;
// Akonadi collection
ID
Collection
collection
;
// Akonadi collection
ResourceCol
()
{}
ResourceCol
(
const
QString
&
r
,
ResourceId
c
)
:
resourceId
(
r
),
collection
Id
(
c
)
{}
ResourceCol
(
const
QString
&
r
,
const
Collection
&
c
)
:
resourceId
(
r
),
collection
(
c
)
{}
};
QHash
<
QString
,
ResourceCol
>
mAgentPaths
;
// path, (resource identifier, collection ID) pairs
void
(
*
mCompletionFunc
)()
{
nullptr
};
// function to call on completion
...
...
@@ -597,14 +611,25 @@ void DuplicateResourceObject::collectionFetchResult(KJob* j)
{
if
(
c
.
contentMimeTypes
().
indexOf
(
MatchMimeType
)
>=
0
)
{
ResourceCol
thisRes
(
job
->
fetchScope
().
resource
(),
c
.
id
()
);
ResourceCol
thisRes
(
job
->
fetchScope
().
resource
(),
c
);
auto
it
=
mAgentPaths
.
constFind
(
c
.
remoteId
());
if
(
it
!=
mAgentPaths
.
constEnd
())
{
// Remove the resource containing the higher numbered Collection
// ID, which is likely to be the more recently created.
// Remove the resource which, in decreasing order of priority:
// - Is disabled;
// - Is not a standard resource;
// - Contains the higher numbered Collection ID, which is likely
// to be the more recently created.
const
ResourceCol
prevRes
=
it
.
value
();
if
(
thisRes
.
collectionId
>
prevRes
.
collectionId
)
const
CollectionProperties
properties
[
2
]
=
{
CollectionProperties
(
prevRes
.
collection
),
CollectionProperties
(
thisRes
.
collection
)
};
int
propToUse
=
(
thisRes
.
collection
.
id
()
<
prevRes
.
collection
.
id
())
?
1
:
0
;
if
(
properties
[
1
-
propToUse
].
standardTypes
&&
!
properties
[
propToUse
].
standardTypes
)
propToUse
=
1
-
propToUse
;
if
(
properties
[
1
-
propToUse
].
enabledTypes
&&
!
properties
[
propToUse
].
enabledTypes
)
propToUse
=
1
-
propToUse
;
if
(
propToUse
==
0
)
{
qCWarning
(
KALARM_LOG
)
<<
"AkonadiResource::collectionFetchResult: Removing duplicate resource"
<<
thisRes
.
resourceId
;
agentManager
->
removeInstance
(
agentManager
->
instance
(
thisRes
.
resourceId
));
...
...
@@ -967,6 +992,27 @@ void AkonadiResource::modifyCollectionAttrJobDone(KJob* j)
}
}
namespace
{
/******************************************************************************
* Fetch an Akonadi collection's properties.
*/
CollectionProperties
::
CollectionProperties
(
const
Collection
&
collection
)
{
readOnly
=
(
collection
.
rights
()
&
WritableRights
)
!=
WritableRights
;
alarmTypes
=
CalEvent
::
types
(
collection
.
contentMimeTypes
());
if
(
collection
.
hasAttribute
<
CollectionAttribute
>
())
{
const
auto
*
attr
=
collection
.
attribute
<
CollectionAttribute
>
();
enabledTypes
=
attr
->
enabled
()
&
alarmTypes
;
standardTypes
=
attr
->
standard
()
&
enabledTypes
;
backgroundColour
=
attr
->
backgroundColor
();
}
}
}
#include "akonadiresource.moc"
// vim: et sw=4:
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