19#define AKONADI_DBUS_SERVER_SERVICE u"org.freedesktop.Akonadi"
20#define AKONADI_DBUS_CONTROL_SERVICE u"org.freedesktop.Akonadi.Control"
21#define AKONADI_DBUS_CONTROL_SERVICE_LOCK u"org.freedesktop.Akonadi.Control.lock"
22#define AKONADI_DBUS_AGENTSERVER_SERVICE u"org.freedesktop.Akonadi.AgentServer"
23#define AKONADI_DBUS_STORAGEJANITOR_SERVICE u"org.freedesktop.Akonadi.Janitor"
24#define AKONADI_DBUS_SERVER_SERVICE_UPGRADING u"org.freedesktop.Akonadi.upgrading"
28 if (!Instance::hasIdentifier()) {
31 return base +
QLatin1Char(
'.') + Instance::identifier();
34QString DBus::serviceName(DBus::ServiceType serviceType)
36 switch (serviceType) {
38 return makeServiceName(AKONADI_DBUS_SERVER_SERVICE);
40 return makeServiceName(AKONADI_DBUS_CONTROL_SERVICE);
42 return makeServiceName(AKONADI_DBUS_CONTROL_SERVICE_LOCK);
44 return makeServiceName(AKONADI_DBUS_AGENTSERVER_SERVICE);
46 return makeServiceName(AKONADI_DBUS_STORAGEJANITOR_SERVICE);
47 case UpgradeIndicator:
48 return makeServiceName(AKONADI_DBUS_SERVER_SERVICE_UPGRADING);
54std::optional<DBus::AgentService> DBus::parseAgentServiceName(
const QString &serviceName)
56 if (!serviceName.
startsWith(AKONADI_DBUS_SERVER_SERVICE
".")) {
60 if ((parts.size() == 2 && !Akonadi::Instance::hasIdentifier())
61 || (parts.size() == 3 && Akonadi::Instance::hasIdentifier() && Akonadi::Instance::identifier() == parts.at(2))) {
64 return AgentService{parts.at(1).toString(), DBus::Agent};
66 return AgentService{parts.at(1).toString(), DBus::Resource};
68 return AgentService{parts.at(1).toString(), DBus::Preprocessor};
77QString DBus::agentServiceName(
const QString &agentIdentifier, DBus::AgentType agentType)
79 Q_ASSERT(!agentIdentifier.
isEmpty());
80 Q_ASSERT(agentType != Unknown);
81 QString serviceName = QStringLiteral(AKONADI_DBUS_SERVER_SERVICE
".");
95 serviceName += agentIdentifier;
96 if (Akonadi::Instance::hasIdentifier()) {
97 serviceName +=
QLatin1Char(
'.') % Akonadi::Instance::identifier();
102std::optional<QString> DBus::parseInstanceIdentifier(
const QString &serviceName)
104 constexpr std::array<QStringView, 5> services = {
QStringView{AKONADI_DBUS_STORAGEJANITOR_SERVICE},
105 QStringView{AKONADI_DBUS_SERVER_SERVICE_UPGRADING},
109 for (
const auto &service : services) {
111 if (serviceName != service) {
112 return serviceName.
mid(service.length() + 1);
120 if (split.size() <= 3) {
126 if (split.size() == 6) {
127 return split[5].toString();
132 return split[3].toString();
Provides methods to control the Akonadi server process.
Helper integration between Akonadi and Qt.
bool isEmpty() const const
QString mid(qsizetype position, qsizetype n) const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QStringView mid(qsizetype start, qsizetype length) const const
QList< QStringView > split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
QString toString() const const