Changeset View
Changeset View
Standalone View
Standalone View
src/util/mailutil.cpp
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Line(s) | |||||
64 | 64 | | |||
65 | #include <AgentManager> | 65 | #include <AgentManager> | ||
66 | #include <entitymimetypefiltermodel.h> | 66 | #include <entitymimetypefiltermodel.h> | ||
67 | #include <EntityTreeModel> | 67 | #include <EntityTreeModel> | ||
68 | #include <ItemFetchJob> | 68 | #include <ItemFetchJob> | ||
69 | #include <ItemFetchScope> | 69 | #include <ItemFetchScope> | ||
70 | #include <Akonadi/KMime/MessageParts> | 70 | #include <Akonadi/KMime/MessageParts> | ||
71 | #include <AkonadiCore/NewMailNotifierAttribute> | 71 | #include <AkonadiCore/NewMailNotifierAttribute> | ||
72 | #include <AkonadiCore/ServerManager> | ||||
72 | 73 | | |||
73 | #include <KMime/KMimeMessage> | 74 | #include <KMime/KMimeMessage> | ||
74 | 75 | | |||
75 | #include <KColorScheme> | 76 | #include <KColorScheme> | ||
76 | #include <KDBusServiceStarter> | 77 | #include <KDBusServiceStarter> | ||
77 | #include <KJob> | 78 | #include <KJob> | ||
78 | #include <KIO/JobUiDelegate> | 79 | #include <KIO/JobUiDelegate> | ||
79 | #include <collectionpage/attributes/expirecollectionattribute.h> | 80 | #include <collectionpage/attributes/expirecollectionattribute.h> | ||
80 | 81 | | |||
81 | OrgKdeAkonadiPOP3SettingsInterface *MailCommon::Util::createPop3SettingsInterface( | 82 | OrgKdeAkonadiPOP3SettingsInterface *MailCommon::Util::createPop3SettingsInterface( | ||
82 | const QString &ident) | 83 | const QString &ident) | ||
83 | { | 84 | { | ||
84 | return | 85 | const auto service = Akonadi::ServerManager::agentServiceName(Akonadi::ServerManager::Resource, ident); | ||
85 | new OrgKdeAkonadiPOP3SettingsInterface( | 86 | return new OrgKdeAkonadiPOP3SettingsInterface(service, QStringLiteral("/Settings"), QDBusConnection::sessionBus()); | ||
86 | QLatin1String("org.freedesktop.Akonadi.Resource.") + ident, QStringLiteral("/Settings"), QDBusConnection::sessionBus()); | | |||
87 | } | 87 | } | ||
88 | 88 | | |||
89 | bool MailCommon::Util::isVirtualCollection(const Akonadi::Collection &collection) | 89 | bool MailCommon::Util::isVirtualCollection(const Akonadi::Collection &collection) | ||
90 | { | 90 | { | ||
91 | return MailCommon::Util::isVirtualCollection(collection.resource()); | 91 | return collection.isVirtual() || MailCommon::Util::isVirtualCollection(collection.resource()); | ||
92 | } | 92 | } | ||
93 | 93 | | |||
94 | bool MailCommon::Util::isVirtualCollection(const QString &resource) | 94 | bool MailCommon::Util::isVirtualCollection(const QString &resource) | ||
95 | { | 95 | { | ||
96 | return resource == QLatin1String("akonadi_search_resource"); | 96 | if (resource == QLatin1String("akonadi_search_resource")) { | ||
97 | return true; | ||||
98 | } | ||||
99 | | ||||
100 | const auto type = Akonadi::AgentManager::self()->type(resource); | ||||
101 | return type.capabilities().contains(QStringLiteral("Virtual")); | ||||
97 | } | 102 | } | ||
98 | 103 | | |||
99 | bool MailCommon::Util::isLocalCollection(const QString &resource) | 104 | bool MailCommon::Util::isLocalCollection(const QString &resource) | ||
100 | { | 105 | { | ||
101 | return resource.contains(QStringLiteral("akonadi_mbox_resource")) | 106 | auto type = Akonadi::AgentManager::self()->type(resource); | ||
102 | || resource.contains(QStringLiteral("akonadi_maildir_resource")) | 107 | return type.customProperties().value(QStringLiteral("HasLocalStorage"), false).toBool(); | ||
103 | || resource.contains(QStringLiteral("akonadi_mixedmaildir_resource")); | | |||
104 | } | 108 | } | ||
105 | 109 | | |||
106 | QString MailCommon::Util::fullCollectionPath(const Akonadi::Collection &collection) | 110 | QString MailCommon::Util::fullCollectionPath(const Akonadi::Collection &collection) | ||
107 | { | 111 | { | ||
108 | QString fullPath; | 112 | QString fullPath; | ||
109 | 113 | | |||
110 | QModelIndex idx | 114 | QModelIndex idx | ||
111 | = Akonadi::EntityTreeModel::modelIndexForCollection(KernelIf->collectionModel(), collection); | 115 | = Akonadi::EntityTreeModel::modelIndexForCollection(KernelIf->collectionModel(), collection); | ||
▲ Show 20 Lines • Show All 186 Lines • Show Last 20 Lines |