Commit 5f95c467 authored by Martin Klapetek's avatar Martin Klapetek

Stop building the akonadi plugin

It is unused, untested and will be replaced by akonadi-next hopefully.
parent 52fdbbe6
......@@ -20,7 +20,6 @@ set(SIGNONQT_DEP_VERSION "8.55")
find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core Widgets Qml)
find_package(KF5 ${REQUIRED_KF5_VERSION} REQUIRED KCMUtils KIO I18n WidgetsAddons CoreAddons IconThemes Config Wallet DBusAddons)
find_package(KF5Akonadi) #Akonadi-qt5 is at version 4.75.0 right now, so cannot be up here^
find_package(AccountsQt5 ${ACCOUNTSQT_DEP_VERSION} REQUIRED CONFIG)
find_package(SignOnQt5 ${SIGNONQT_DEP_VERSION} REQUIRED CONFIG)
......
......@@ -29,34 +29,3 @@ target_link_libraries(kded_accounts
install(TARGETS kded_accounts DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES accounts.desktop DESTINATION ${SERVICES_INSTALL_DIR}/kded)
####################################################################################
if (KF5Akonadi_FOUND)
set(akonadi_plugin_SRCS
akonadi/akonadiservices.cpp
akonadi/akonadiaccounts.cpp
akonadi/jobs/abstractakonadijob.cpp
akonadi/jobs/createresourcejob.cpp
akonadi/jobs/removeresourcejob.cpp
akonadi/jobs/changesettingsjob.cpp
akonadi/jobs/fetchsettingsjob.cpp
akonadi/jobs/enableservicejob.cpp
akonadi/jobs/dbussettingsinterfacejob.cpp
akonadi/jobs/lookupakonadiservices.cpp
akonadi/jobs/removeakonadiservicesjob.cpp)
add_library(kaccounts_akonadi_plugin MODULE ${akonadi_plugin_SRCS})
target_link_libraries(kaccounts_akonadi_plugin
kaccounts
Qt5::DBus
KF5::ConfigCore
KF5::AkonadiCore)
# Install:
install (TARGETS kaccounts_akonadi_plugin
DESTINATION ${PLUGIN_INSTALL_DIR}/kaccounts/daemonplugins
)
endif()
/*************************************************************************************
* Copyright (C) 2013 by Alejandro Fiestas Olivares <afiestas@kde.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#include "akonadiaccounts.h"
#include <QDebug>
#include <KConfigGroup>
#include <KSharedConfig>
AkonadiAccounts::AkonadiAccounts(const QString &configName)
{
m_config = KSharedConfig::openConfig(configName);
}
bool AkonadiAccounts::hasService(const Accounts::AccountId accId, const QString &serviceName)
{
qDebug() << accId;
KConfigGroup account = group(accId);
return account.keyList().contains(serviceName);
}
bool AkonadiAccounts::hasServices(const Accounts::AccountId accId)
{
qDebug() << accId;
KConfigGroup account = group(accId);
return !account.keyList().isEmpty();
}
QStringList AkonadiAccounts::services(const Accounts::AccountId accId)
{
qDebug() << accId;
KConfigGroup account = group(accId);
return account.keyList();
}
void AkonadiAccounts::addService(const Accounts::AccountId accId, const QString &serviceName, const QString &resourceId)
{
addService(accId, QStringList() << serviceName, resourceId);
}
void AkonadiAccounts::addService(const Accounts::AccountId accId, const QStringList &serviceNames, const QString &resourceId)
{
qDebug() << accId << serviceNames << resourceId;
KConfigGroup account = group(accId);
Q_FOREACH (const QString &service, serviceNames) {
account.writeEntry(service, resourceId);
}
account.sync();
}
void AkonadiAccounts::addService(const Accounts::AccountId accId, const Accounts::ServiceList &services, const QString &resourceId)
{
QStringList servicesToStore;
Q_FOREACH (const Accounts::Service &service, services) {
servicesToStore << service.name();
}
addService(accId, servicesToStore, resourceId);
}
void AkonadiAccounts::removeService(const Accounts::AccountId accId, const QString &serviceName)
{
removeService(accId, QStringList() << serviceName);
}
void AkonadiAccounts::removeService(const Accounts::AccountId accId, const QStringList &serviceNames)
{
qDebug() << accId << serviceNames;
KConfigGroup account = group(accId);
Q_FOREACH (const QString &service, serviceNames) {
account.deleteEntry(service);
}
QString key("Account_" + QString::number(accId));
if (account.entryMap().isEmpty()) {
m_config->deleteGroup(key);
}
m_config->sync();
}
void AkonadiAccounts::removeService(const Accounts::AccountId accId, const Accounts::ServiceList &services)
{
QStringList servicesToRemove;
Q_FOREACH (const Accounts::Service &service, services) {
servicesToRemove << service.name();
}
removeService(accId, services);
}
QStringList AkonadiAccounts::resources(const Accounts::AccountId accId)
{
qDebug() << accId;
KConfigGroup account = group(accId);
QStringList cleaned;
QStringList duplicated = account.entryMap().values();
Q_FOREACH(const QString &resource, duplicated) {
if (cleaned.contains(resource)) {
continue;
}
cleaned.append(resource);
}
return cleaned;
}
QString AkonadiAccounts::resource(const Accounts::AccountId accId, const QString &serviceName) const
{
qDebug() << accId << serviceName;
KConfigGroup account = group(accId);
return account.readEntry(serviceName, QString());
}
QString AkonadiAccounts::resourceFromType(const Accounts::AccountId accId, const QString &resourceType) const
{
qDebug() << accId << resourceType;
KConfigGroup cGroup = group(accId);
QStringList resources = cGroup.entryMap().values();
qDebug() << resources;
Q_FOREACH(const QString &instance, resources) {
if (instance.startsWith(resourceType)) {
return instance;
}
}
return QString();
}
void AkonadiAccounts::removeAccount(const Accounts::AccountId accId)
{
qDebug();
QString key("Account_" + QString::number(accId));
m_config->deleteGroup(key);
m_config->sync();
}
KConfigGroup AkonadiAccounts::group(const Accounts::AccountId accId) const
{
QString group("Account_" + QString::number(accId));
return m_config->group(group);
}
/*************************************************************************************
* Copyright (C) 2013 by Alejandro Fiestas Olivares <afiestas@kde.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#ifndef ACCOUNTS_AKONADI_DAEMON_H
#define ACCOUNTS_AKONADI_DAEMON_H
#include <Accounts/Account>
#include <KSharedConfig>
#include <KConfigGroup>
#include <AkonadiCore/Attribute>
class AkonadiAccounts
{
public:
AkonadiAccounts(const QString &configName = QLatin1String("accounts-akonadi"));
bool hasService(const Accounts::AccountId accId, const QString &serviceName);
bool hasServices(const Accounts::AccountId accId);
QStringList services(const Accounts::AccountId accId);
void addService(const Accounts::AccountId accId, const QString &serviceName, const QString &resourceId);
void addService(const Accounts::AccountId accId, const QStringList &serviceNames, const QString &resourceId);
void addService(const Accounts::AccountId accId, const Accounts::ServiceList &services, const QString &resourceId);
void removeService(const Accounts::AccountId accId, const QString &serviceName);
void removeService(const Accounts::AccountId accId, const QStringList &serviceNames);
void removeService(const Accounts::AccountId accId, const Accounts::ServiceList &services);
QStringList resources(const Accounts::AccountId accId);
QString resource(const Accounts::AccountId accId, const QString &serviceName) const;
QString resourceFromType(const Accounts::AccountId accId, const QString &resourceType) const;
void removeAccount(const Accounts::AccountId accId);
private:
KSharedConfig::Ptr m_config;
KConfigGroup group(const Accounts::AccountId accId) const;
};
#endif //ACCOUNTS_AKONADI_DAEMON_H
/*************************************************************************************
* Copyright (C) 2013 by Alejandro Fiestas Olivares <afiestas@kde.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#include "akonadiservices.h"
#include "akonadiaccounts.h"
#include "jobs/lookupakonadiservices.h"
#include "jobs/removeakonadiservicesjob.h"
#include "jobs/enableservicejob.h"
#include "jobs/removeresourcejob.h"
#include <QDebug>
#include <AkonadiCore/AgentManager>
using namespace Akonadi;
AkonadiServices::AkonadiServices(QObject* parent)
: KAccountsDPlugin(parent)
, m_accounts(new AkonadiAccounts())
{
}
AkonadiServices::~AkonadiServices()
{
delete m_accounts;
}
void AkonadiServices::onAccountCreated(const Accounts::AccountId accId, const Accounts::ServiceList &serviceList)
{
LookupAkonadiServices *lookup = new LookupAkonadiServices(m_accounts, this);
lookup->setServices(serviceList);
lookup->setAccountId(accId);
connect(lookup, &LookupAkonadiServices::finished, this, [=](KJob *job){
if (job->error()) {
qDebug() << "Lookup job failed" << job->errorText();
}
});
lookup->start();
}
void AkonadiServices::onAccountRemoved(const Accounts::AccountId accId)
{
if (!m_accounts->hasServices(accId)) {
qDebug() << "No service enabled";
return;
}
RemoveAkonadiServicesJob *job = new RemoveAkonadiServicesJob(m_accounts, this);
job->setAccountId(accId);
job->start();
}
void AkonadiServices::onServiceEnabled(const Accounts::AccountId accId, const Accounts::Service &service)
{
Accounts::ServiceList list;
list.append(service);
onAccountCreated(accId, list);
}
void AkonadiServices::onServiceDisabled(const Accounts::AccountId accId, const Accounts::Service &service)
{
if (!m_accounts->hasService(accId, service.name())) {
qDebug() << "No service enabled";
return;
}
QString serviceName = service.name();
EnableServiceJob *job = new EnableServiceJob(this);
connect(job, SIGNAL(finished(KJob*)), SLOT(disableServiceJobDone(KJob*)));
job->setResourceId(m_accounts->resource(accId, serviceName));
job->addService(service, EnableServiceJob::Disable);
job->setAccountId(accId);
job->start();
}
void AkonadiServices::disableServiceJobDone(KJob *job)
{
qDebug();
if (job->error()) {
qDebug() << job->errorText();
return;
}
EnableServiceJob *serviceJob = qobject_cast<EnableServiceJob*>(job);
AgentManager::self()->instance(serviceJob->resourceId()).reconfigure();
m_accounts->removeService(serviceJob->accountId(), serviceJob->services());
if (!m_accounts->resources(serviceJob->accountId()).contains(serviceJob->resourceId())) {
RemoveResourceJob *rJob = new RemoveResourceJob(this);
rJob->setResourceId(serviceJob->resourceId());
rJob->start();
}
}
\ No newline at end of file
/*************************************************************************************
* Copyright (C) 2013 by Alejandro Fiestas Olivares <afiestas@kde.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#ifndef AKONADI_SERVICES_H
#define AKONADI_SERVICES_H
#include <QtCore/QObject>
#include <Accounts/Account>
#include <Accounts/Service>
#include <kaccountsdplugin.h>
class KJob;
class AkonadiAccounts;
class AkonadiServices : public KAccountsDPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.kde.kaccounts.DPlugin")
Q_INTERFACES(KAccountsDPlugin)
public:
explicit AkonadiServices(QObject *parent = 0);
virtual ~AkonadiServices();
public Q_SLOTS:
void onAccountCreated(const Accounts::AccountId accId, const Accounts::ServiceList &serviceList);
void onAccountRemoved(const Accounts::AccountId accId);
void onServiceEnabled(const Accounts::AccountId accId, const Accounts::Service &service);
void onServiceDisabled(const Accounts::AccountId accId, const Accounts::Service &service);
private Q_SLOTS:
void disableServiceJobDone(KJob *job);
private:
AkonadiAccounts* m_accounts;
};
#endif //AKONADI_SERVICES_H
\ No newline at end of file
/*************************************************************************************
* Copyright (C) 2013 by Alejandro Fiestas Olivares <afiestas@kde.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#include "abstractakonadijob.h"
AbstractAkonadiJob::AbstractAkonadiJob(QObject *parent)
: KJob(parent)
{
}
QString AbstractAkonadiJob::resourceId() const
{
return m_resourceId;
}
void AbstractAkonadiJob::setResourceId(const QString &resourceId)
{
m_resourceId = resourceId;
}
QString AbstractAkonadiJob::interface() const
{
return m_interface;
}
void AbstractAkonadiJob::setInterface(const QString &interface)
{
m_interface = interface;
}
Accounts::AccountId AbstractAkonadiJob::accountId() const
{
return m_accountId;
}
void AbstractAkonadiJob::setAccountId(const Accounts::AccountId accountId)
{
m_accountId = accountId;
}
uint qHash(const Accounts::Service &key, uint seed)
{
return qHash(key.name() + key.provider() + key.serviceType(), seed);
}
uint qHash(const Accounts::Service &key)
{
return qHash(key.name() + key.provider() + key.serviceType());
}
/*************************************************************************************
* Copyright (C) 2013 by Alejandro Fiestas Olivares <afiestas@kde.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#ifndef ABSTRACT_AKONADI_JOB_H
#define ABSTRACT_AKONADI_JOB_H
namespace Accounts {
class Service;
};
#include <cstdlib> //needed for uint below
uint qHash(const Accounts::Service &key, uint seed);
uint qHash(const Accounts::Service &key);
#include <Accounts/Account>
#include <KJob>
class AbstractAkonadiJob : public KJob
{
Q_OBJECT
public:
explicit AbstractAkonadiJob(QObject *parent = 0);
QString resourceId() const;
void setResourceId(const QString &resourceId);
QString interface() const;
void setInterface(const QString &interface);
Accounts::AccountId accountId() const;
void setAccountId(const Accounts::AccountId accountId);
protected:
QString m_resourceId;
QString m_interface;
Accounts::AccountId m_accountId;
};
#endif
\ No newline at end of file
/*************************************************************************************
* Copyright (C) 2013 by Alejandro Fiestas Olivares <afiestas@kde.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#include "changesettingsjob.h"
#include "dbussettingsinterfacejob.h"
#include <QDBusInterface>
#include <QDBusConnection>
#include <QDBusPendingCall>
#include <QDBusPendingReply>
#include <QDebug>
ChangeSettingsJob::ChangeSettingsJob(QObject *parent)
: AbstractAkonadiJob(parent)
{
}
ChangeSettingsJob::~ChangeSettingsJob()
{
}
void ChangeSettingsJob::start()
{
qDebug();
QMetaObject::invokeMethod(this, "init", Qt::QueuedConnection);
}
void ChangeSettingsJob::init()
{
if (m_interface.isEmpty()) {
DBusSettingsInterfaceJob *job = new DBusSettingsInterfaceJob(this);
connect(job, SIGNAL(finished(KJob*)), SLOT(dbusSettingsPath(KJob*)));
job->setResourceId(m_resourceId);
job->start();
return;
}
setConfiguration();
}
void ChangeSettingsJob::dbusSettingsPath(KJob *job)
{
DBusSettingsInterfaceJob *dbusJob = qobject_cast<DBusSettingsInterfaceJob*>(job);
m_interface = dbusJob->interface();
setConfiguration();
}
void ChangeSettingsJob::setSetting(const QString &key, const QVariant &value)
{
m_key = key;
m_value = value;
}
void ChangeSettingsJob::setConfiguration()
{