Commit 92cdf7e4 authored by Martin Klapetek's avatar Martin Klapetek
Browse files

Remove long-time unused code

Contains lots of i18n strings which are getting extracted and translated
and not being used at all
parent 4dc82378
/*************************************************************************************
* Copyright (C) 2012 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 "ocreatecalendar.h"
OCreateCalendar::OCreateCalendar(KConfigGroup group, QObject* parent)
: OCreateContact(group, parent)
{
}
OCreateCalendar::~OCreateCalendar()
{
}
void OCreateCalendar::start()
{
OCreateContact::start();
}
void OCreateCalendar::startByContact()
{
start();
}
const QString OCreateCalendar::davUrl()
{
QUrl url(m_config.readEntry("server", ""));
url = url.adjusted(QUrl::StripTrailingSlash);
url.setPath(url.path() + '/' + "remote.php/caldav/");
QString str("$default$|CalDav|");
str.append(url.url());
m_config.group("services").writeEntry("Calendar", 1);
return str;
}
/*************************************************************************************
* Copyright (C) 2012 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 OCREATECALENDAR_H
#define OCREATECALENDAR_H
#include "ocreatecontact.h"
class OCreateCalendar : public OCreateContact
{
Q_OBJECT
public:
explicit OCreateCalendar(KConfigGroup group, QObject* parent);
virtual ~OCreateCalendar();
virtual void start();
public Q_SLOTS:
void startByContact();
protected:
virtual const QString davUrl();
};
#endif //OCREATECALENDAR_H
\ No newline at end of file
/*************************************************************************************
* Copyright (C) 2012 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 "ocreatecontact.h"
#include "davGroupware_settings.h"
#include <QWidget>
#include <QApplication>
#include <QDBusInterface>
#include <QDebug>
#include <akonadi/agenttype.h>
#include <akonadi/agentmanager.h>
#include <akonadi/agentinstancecreatejob.h>
#include <unistd.h>
#include <klocalizedstring.h>
#include <KWallet/Wallet>
using namespace KWallet;
using namespace Akonadi;
OCreateContact::OCreateContact(KConfigGroup group, QObject* parent)
: KJob(parent)
, m_config(group)
{
}
OCreateContact::~OCreateContact()
{
}
void OCreateContact::start()
{
m_config.sync();
if (m_config.hasGroup("private") && m_config.group("private").hasKey("contactAndCalendarResource")) {
QMetaObject::invokeMethod(this, "useCalendarResource", Qt::QueuedConnection);
return;
}
QMetaObject::invokeMethod(this, "createResource", Qt::QueuedConnection);
}
KConfigGroup OCreateContact::config() const
{
return m_config;
}
void OCreateContact::createResource()
{
qDebug() << "Creating new resource";
const AgentType type = AgentManager::self()->type("akonadi_davgroupware_resource");
AgentInstanceCreateJob *job = new AgentInstanceCreateJob( type, this );
connect( job, SIGNAL(result(KJob*)), SLOT(resourceCreated(KJob*)) );
job->start();
}
const QString OCreateContact::davUrl()
{
QUrl url(m_config.readEntry("server", ""));
url = url.adjusted(QUrl::StripTrailingSlash);
url.setPath(url.path() + '/' + "remote.php/carddav/");
QString str("$default$|CardDav|");
str.append(url.url());
m_config.group("services").writeEntry("Contact", 1);
return str;
}
void OCreateContact::resourceCreated(KJob* job)
{
if (job->error()) {
setError(-1);
emitResult();
return;
}
AgentInstance agent = qobject_cast<AgentInstanceCreateJob*>( job )->instance();
agent.setName(m_config.name() + " " + i18n("Calendar and Contacts"));
QString service = "org.freedesktop.Akonadi.Resource." + agent.identifier();
KConfigGroup privates(&m_config, "private");
privates.writeEntry("contactAndCalendarResource", service);
m_config.sync();
org::kde::Akonadi::davGroupware::Settings *settings = new org::kde::Akonadi::davGroupware::Settings(service, "/Settings", QDBusConnection::sessionBus());
settings->setDefaultUsername(m_config.name());
settings->setRemoteUrls(QStringList(davUrl()));
settings->setDisplayName(m_config.name());
settings->setSettingsVersion(2);
WId windowId = 0;
if (qApp->activeWindow()) {
windowId = qApp->activeWindow()->winId();
}
Wallet *wallet = Wallet::openWallet(Wallet::NetworkWallet(), windowId, Wallet::Synchronous);
if (!wallet || !wallet->isOpen() || !wallet->isEnabled()) {
setError(-1);
emitResult();
return;
}
QString password, prefix;
if (m_config.readEntry("type", "owncloud") == "runnerid") {
prefix = "runnerid";
} else {
prefix = "owncloud";
}
wallet->setFolder("WebAccounts");
wallet->readPassword(prefix + "-" + m_config.name(), password);
QString key (agent.identifier());
key.append(",$default$");
wallet->setFolder(Wallet::PasswordFolder());
wallet->writePassword(key, password);
settings->writeConfig();
agent.reconfigure();
emitResult();
}
void OCreateContact::useCalendarResource()
{
QString resource = m_config.group("private").readEntry("contactAndCalendarResource");
org::kde::Akonadi::davGroupware::Settings *settings = new org::kde::Akonadi::davGroupware::Settings(resource, "/Settings", QDBusConnection::sessionBus());
QStringList list = settings->remoteUrls().value();
list.append(davUrl());
qDebug() << list;
settings->setRemoteUrls(list).waitForFinished();
settings->setDefaultUsername(m_config.name()).waitForFinished();
settings->writeConfig().waitForFinished();
resource.remove("org.freedesktop.Akonadi.Resource.");
AgentInstance instance = AgentManager::self()->instance(resource);
if (!instance.isValid()) {
return;
}
instance.reconfigure();
emitResult();
}
/*************************************************************************************
* Copyright (C) 2012 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 OCREATECONTACT_H
#define OCREATECONTACT_H
#include <QString>
#include <kjob.h>
#include <kconfiggroup.h>
#include <akonadi/agentinstance.h>
using namespace Akonadi;
class KConfigGroup;
class OCreateContact : public KJob
{
Q_OBJECT
public:
explicit OCreateContact(KConfigGroup group, QObject* parent);
virtual ~OCreateContact();
virtual void start();
KConfigGroup config() const;
protected:
virtual const QString davUrl();
private Q_SLOTS:
void useCalendarResource();
void createResource();
void resourceCreated(KJob *job);
protected:
KConfigGroup m_config;
};
#endif //OCREATECONTACT_H
\ No newline at end of file
/*************************************************************************************
* Copyright (C) 2012 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 "oremovecalendar.h"
#include "jobs/removeakonadiresource.h"
#include "davGroupware_settings.h"
#include <QDebug>
ORemoveCalendar::ORemoveCalendar(KConfigGroup group, QObject* parent)
: KJob(parent)
, m_config(group)
{
setObjectName(m_config.name());
setProperty("type", QVariant::fromValue(m_config.readEntry("type")));
}
ORemoveCalendar::~ORemoveCalendar()
{
}
void ORemoveCalendar::start()
{
QMetaObject::invokeMethod(this, "deleteCalendar", Qt::QueuedConnection);
}
void ORemoveCalendar::deleteCalendar()
{
KConfigGroup services = m_config.group("services");
if (services.readEntry("Contact", 0) == 0) {
removeResource();
return;
}
removeCalendarsInResource();
}
void ORemoveCalendar::removeResource()
{
RemoveAkonadiResource *remove = new RemoveAkonadiResource("contactAndCalendarResource", "Calendar", m_config, this);
connect(remove, SIGNAL(finished(KJob*)), this, SLOT(resourceRemoved()));
remove->start();
}
void ORemoveCalendar::removeCalendarsInResource()
{
org::kde::Akonadi::davGroupware::Settings *settings = new org::kde::Akonadi::davGroupware::Settings(m_config.group("private").readEntry("contactAndCalendarResource"), "/Settings", QDBusConnection::sessionBus());
QStringList list = settings->remoteUrls().value();
Q_FOREACH(const QString &url, list) {
if (url.contains("CalDav")) {
list.removeOne(url);
}
}
qDebug() << "Updated list: " << list;
settings->setRemoteUrls(list);
settings->writeConfig();
if (m_config.group("services").readEntry("Contact", 0) == 0) {
removeResource();
return;
}
resourceRemoved();
}
void ORemoveCalendar::resourceRemoved()
{
m_config.group("services").writeEntry("Calendar", 0);
emitResult();
}
/*************************************************************************************
* Copyright (C) 2012 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 OREMOVE_CALENDAR_H
#define OREMOVE_CALENDAR_H
#include <KJob>
#include <KConfigGroup>
class ORemoveCalendar : public KJob
{
Q_OBJECT
public:
explicit ORemoveCalendar(KConfigGroup group, QObject* parent);
virtual ~ORemoveCalendar();
virtual void start();
protected Q_SLOTS:
void deleteCalendar();
void removeResource();
void resourceRemoved();
private Q_SLOTS:
void removeCalendarsInResource();
private:
KConfigGroup m_config;
};
#endif //OREMOVE_CONTACT_H
/*************************************************************************************
* Copyright (C) 2012 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 "oremovecontact.h"
#include "jobs/removeakonadiresource.h"
#include "davGroupware_settings.h"
#include <QDebug>
ORemoveContact::ORemoveContact(KConfigGroup group, QObject* parent)
: KJob(parent)
, m_config(group)
{
setObjectName(m_config.name());
setProperty("type", QVariant::fromValue(m_config.readEntry("type")));
}
ORemoveContact::~ORemoveContact()
{
}
void ORemoveContact::start()
{
QMetaObject::invokeMethod(this, "deleteContact", Qt::QueuedConnection);
}
void ORemoveContact::deleteContact()
{
KConfigGroup services = m_config.group("services");
if (services.readEntry("Calendar", 0) == 0) {
removeResource();
return;
}
removeCalendarsInResource();
}
void ORemoveContact::removeResource()
{
RemoveAkonadiResource *remove = new RemoveAkonadiResource("contactAndCalendarResource", "Contact", m_config, this);
connect(remove, SIGNAL(finished(KJob*)), this, SLOT(resourceRemoved()));
remove->start();
}
void ORemoveContact::removeCalendarsInResource()
{
org::kde::Akonadi::davGroupware::Settings *settings = new org::kde::Akonadi::davGroupware::Settings(m_config.group("private").readEntry("contactAndCalendarResource"), "/Settings", QDBusConnection::sessionBus());
QStringList list = settings->remoteUrls().value();
Q_FOREACH(const QString &url, list) {
if (url.contains("CardDav")) {
list.removeOne(url);
}
}
qDebug() << "Updated list: " << list;
settings->setRemoteUrls(list);
settings->writeConfig();
if (m_config.group("services").readEntry("Calendar", 0) == 0) {
removeResource();
return;
}
resourceRemoved();
}
void ORemoveContact::resourceRemoved()
{
m_config.group("services").writeEntry("Contact", 0);
emitResult();
}
/*************************************************************************************
* Copyright (C) 2012 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 OREMOVE_CONTACT_H
#define OREMOVE_CONTACT_H
#include <KJob>
#include <KConfigGroup>
class ORemoveContact : public KJob
{
Q_OBJECT
public:
explicit ORemoveContact(KConfigGroup group, QObject* parent);
virtual ~ORemoveContact();
virtual void start();
protected Q_SLOTS:
void deleteContact();
void removeResource();
void resourceRemoved();
private Q_SLOTS:
void removeCalendarsInResource();
private:
KConfigGroup m_config;
};
#endif //OREMOVE_CONTACT_H
\ No newline at end of file
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.kde.Akonadi.davGroupware.Settings">
<method name="writeConfig"/>
<method name="settingsVersion">
<arg direction="out" type="i"/>
</method>
<method name="setSettingsVersion">
<arg direction="in" identifier="value" type="i"/>
</method>
<method name="displayName">
<arg direction="out" type="s"/>
</method>
<method name="setDisplayName">
<arg direction="in" identifier="value" type="s"/>
</method>
<method name="refreshInterval">
<arg direction="out" type="i"/>