[resources/ews] Adjust name of root collection to the name of the resource
ClosedPublic

Authored by poboiko on Mar 3 2020, 10:23 PM.

Details

Summary

The name of root collection inside the Akonadi DB (and thus, i.e. inside KMail)
is always akonadi_ews_resource#, even if the resource itself was renamed.
Even though we call mRootCollection->setName(name()), the name get's
overriden after we fetch it from DB.
The settings UI changes the name of the resource, but not root collection.

This patch runs CollectionModifyJob to rename the root collection in both
scenarios: either when we fetch root collection or change the resource name.

BUG: 413078
BUG: 416663

Test Plan
  1. Open KMail -> Settings -> Accounts -> Receiving -> EWS account
  2. Change "Account Name", save
  3. The change gets applied to Mailbox View inside KMail UI immediately

Diff Detail

Repository
R44 KDE PIM Runtime
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
poboiko created this revision.Mar 3 2020, 10:23 PM
Restricted Application added a project: KDE PIM. · View Herald TranscriptMar 3 2020, 10:23 PM
poboiko requested review of this revision.Mar 3 2020, 10:23 PM
dvratil requested changes to this revision.Mar 17 2020, 1:15 PM

This is not the right way to fix the display name visible to the user. Use EntityDisplayAttribute instead:

auto *attr = collection.attribute<Akonadi::EntityDisplayAttribute>(Akonadi::Collection::AddIfMissing);
attr->setDisplayName(newName);

new CollectionModifyJob(collection);

All UI components prefer using the display name from the attribute over the Collection::name().

This revision now requires changes to proceed.Mar 17 2020, 1:15 PM
poboiko updated this revision to Diff 78108.Mar 20 2020, 4:27 PM

Use EntityDisplayAttribute instead

dvratil accepted this revision.Mar 21 2020, 12:47 PM
This revision is now accepted and ready to land.Mar 21 2020, 12:47 PM
This revision was automatically updated to reflect the committed changes.