Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit bb3df07a authored by Allen Winter's avatar Allen Winter

configure plugin fixes for Akonadi instances

Differential Revision: https://phabricator.kde.org/D6507
parent 63703b8f
......@@ -232,21 +232,17 @@ void ConfigurePluginsListWidget::initializeAgentPlugins()
agentAkonadiGroupName());
}
PimCommon::PluginUtilData ConfigurePluginsListWidget::createAgentPluginData(const QString &interfaceName, const QString &path)
PimCommon::PluginUtilData ConfigurePluginsListWidget::createAgentPluginData(const QString &agentIdentifier, const QString &path)
{
PimCommon::PluginUtilData data;
data.mEnableByDefault = true;
data.mHasConfigureDialog = true;
const Akonadi::AgentType::List lstAgent = Akonadi::AgentManager::self()->types();
QString service = interfaceName;
if (Akonadi::ServerManager::hasInstanceIdentifier()) {
service += QLatin1Char('.') + Akonadi::ServerManager::instanceIdentifier();
}
for (const Akonadi::AgentType &type : lstAgent) {
if (type.identifier() == service) {
data.mExtraInfo << service;
if (type.identifier() == agentIdentifier) {
data.mExtraInfo << agentIdentifier;
data.mExtraInfo << path;
const bool enabled = agentActivateState(interfaceName, path);
const bool enabled = agentActivateState(agentIdentifier, path);
data.mEnableByDefault = enabled;
data.mName = type.name();
data.mDescription = type.description();
......@@ -257,31 +253,35 @@ PimCommon::PluginUtilData ConfigurePluginsListWidget::createAgentPluginData(cons
return data;
}
bool ConfigurePluginsListWidget::agentActivateState(const QString &interfaceName, const QString &pathName)
bool ConfigurePluginsListWidget::agentActivateState(const QString &agentIdentifier, const QString &pathName)
{
QDBusInterface interface(QLatin1String("org.freedesktop.Akonadi.Agent.") + interfaceName, pathName);
const QString service =
Akonadi::ServerManager::agentServiceName(Akonadi::ServerManager::Agent, agentIdentifier);
QDBusInterface interface(service, pathName);
if (interface.isValid()) {
QDBusReply<bool> enabled = interface.call(QStringLiteral("enabledAgent"));
if (enabled.isValid()) {
return enabled;
} else {
qCDebug(KMAIL_LOG) << interfaceName << "doesn't have enabledAgent function";
qCDebug(KMAIL_LOG) << agentIdentifier << "doesn't have enabledAgent function";
return false;
}
} else {
qCDebug(KMAIL_LOG) << interfaceName << "does not exist ";
qCDebug(KMAIL_LOG) << agentIdentifier << "does not exist when trying to activate the agent state";
}
return false;
}
void ConfigurePluginsListWidget::changeAgentActiveState(const QString &interfaceName, const QString &path, bool enable)
void ConfigurePluginsListWidget::changeAgentActiveState(const QString &agentIdentifier, const QString &path, bool enable)
{
if (!interfaceName.isEmpty() && !path.isEmpty()) {
QDBusInterface interface(QLatin1String("org.freedesktop.Akonadi.Agent.") + interfaceName, path);
if (!agentIdentifier.isEmpty() && !path.isEmpty()) {
const QString service =
Akonadi::ServerManager::agentServiceName(Akonadi::ServerManager::Agent, agentIdentifier);
QDBusInterface interface(service, path);
if (interface.isValid()) {
interface.call(QStringLiteral("setEnableAgent"), enable);
} else {
qCDebug(KMAIL_LOG) << interfaceName << "does not exist ";
qCDebug(KMAIL_LOG) << agentIdentifier << "does not exist when trying to change the agent active state";
}
}
}
......@@ -313,11 +313,12 @@ void ConfigurePluginsListWidget::slotConfigureClicked(const QString &configureGr
} else if (configureGroupName == agentAkonadiGroupName()) {
for (const PimCommon::PluginUtilData &data : qAsConst(mPluginUtilDataList)) {
if (data.mIdentifier == identifier) {
QDBusInterface interface(QLatin1String("org.freedesktop.Akonadi.Agent.") + data.mExtraInfo.at(0), data.mExtraInfo.at(1));
const QString service = Akonadi::ServerManager::agentServiceName(Akonadi::ServerManager::Agent, data.mExtraInfo.at(0));
QDBusInterface interface(service, data.mExtraInfo.at(1));
if (interface.isValid()) {
interface.call(QStringLiteral("showConfigureDialog"), (qlonglong)winId());
} else {
qCDebug(KMAIL_LOG) << " interface does not exist ";
qCDebug(KMAIL_LOG) << " interface does not exist when trying to configure the plugin";
}
break;
}
......
......@@ -37,9 +37,9 @@ public:
private:
void slotConfigureClicked(const QString &configureGroupName, const QString &identifier);
void initializeAgentPlugins();
PimCommon::PluginUtilData createAgentPluginData(const QString &interfaceName, const QString &path);
bool agentActivateState(const QString &interfaceName, const QString &pathName);
void changeAgentActiveState(const QString &interfaceName, const QString &path, bool enable);
PimCommon::PluginUtilData createAgentPluginData(const QString &agentIdentifier, const QString &path);
bool agentActivateState(const QString &agentIdentifier, const QString &pathName);
void changeAgentActiveState(const QString &agentIdentifier, const QString &path, bool enable);
void saveAkonadiAgent();
QList<PluginItem *> mPluginEditorItems;
QList<PluginItem *> mPluginMessageViewerItems;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment