[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kaccounts-providers] jobs: Move all owncloud jobs into owncloud/jobs (and one facebook into faceboo
From: Alex Fiestas <afiestas () kde ! org>
Date: 2015-10-15 21:01:24
Message-ID: E1ZmpeO-0000yK-LN () scm ! kde ! org
[Download RAW message or body]
Git commit 5cc7fe3dc1ac28bbd9fb4af68dc644c7a0b2c521 by Alex Fiestas.
Committed on 02/05/2012 at 10:44.
Pushed by mklapetek into branch 'master'.
Move all owncloud jobs into owncloud/jobs (and one facebook into facebooks)
A +49 -0 jobs/ocreatecalendar.cpp [License: GPL (v2+)]
A +37 -0 jobs/ocreatecalendar.h [License: GPL (v2+)]
A +172 -0 jobs/ocreatecontact.cpp [License: GPL (v2+)]
A +56 -0 jobs/ocreatecontact.h [License: GPL (v2+)]
A +111 -0 jobs/ocreatefile.cpp [License: GPL (v2+)]
A +41 -0 jobs/ocreatefile.h [License: GPL (v2+)]
A +89 -0 jobs/oremovecalendar.cpp [License: GPL (v2+)]
A +46 -0 jobs/oremovecalendar.h [License: GPL (v2+)]
A +89 -0 jobs/oremovecontact.cpp [License: GPL (v2+)]
A +46 -0 jobs/oremovecontact.h [License: GPL (v2+)]
A +49 -0 jobs/oremovefile.cpp [License: GPL (v2+)]
A +41 -0 jobs/oremovefile.h [License: GPL (v2+)]
A +49 -0 jobs/org.kde.Akonadi.davGroupware.Settings.xml
http://commits.kde.org/kaccounts-providers/5cc7fe3dc1ac28bbd9fb4af68dc644c7a0b2c521
diff --git a/jobs/ocreatecalendar.cpp b/jobs/ocreatecalendar.cpp
new file mode 100644
index 0000000..8a59270
--- /dev/null
+++ b/jobs/ocreatecalendar.cpp
@@ -0,0 +1,49 @@
+/*************************************************************************************
+ * 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();
+}
+
+const QString OCreateCalendar::davUrl()
+{
+ KUrl url(m_config.readEntry("server", ""));
+ url.addPath("apps/calendar/caldav.php/");
+
+ QString str("$default$|CalDav|");
+ str.append(url.url());
+
+ m_config.group("services").writeEntry("Calendar", 1);
+
+ return str;
+}
+
diff --git a/jobs/ocreatecalendar.h b/jobs/ocreatecalendar.h
new file mode 100644
index 0000000..8c69450
--- /dev/null
+++ b/jobs/ocreatecalendar.h
@@ -0,0 +1,37 @@
+/*************************************************************************************
+ * 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();
+
+ protected:
+ virtual const QString davUrl();
+};
+
+#endif //OCREATECALENDAR_H
\ No newline at end of file
diff --git a/jobs/ocreatecontact.cpp b/jobs/ocreatecontact.cpp
new file mode 100644
index 0000000..5717922
--- /dev/null
+++ b/jobs/ocreatecontact.cpp
@@ -0,0 +1,172 @@
+/*************************************************************************************
+ * 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 <QtGui/QWidget>
+#include <QtGui/QApplication>
+
+#include <QtDBus/QDBusInterface>
+
+#include <libkgoogle/auth.h>
+#include <libkgoogle/reply.h>
+#include <libkgoogle/request.h>
+#include <libkgoogle/accessmanager.h>
+#include <libkgoogle/objects/calendar.h>
+#include <libkgoogle/services/calendar.h>
+
+#include <akonadi/agenttype.h>
+#include <akonadi/agentmanager.h>
+#include <akonadi/agentinstancecreatejob.h>
+#include <unistd.h>
+
+#include <KDebug>
+#include <KWallet/Wallet>
+
+using namespace KWallet;
+using namespace Akonadi;
+using namespace KGoogle;
+
+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()
+{
+ kDebug() << "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()
+{
+ KUrl url(m_config.readEntry("server", ""));
+ url.addPath("apps/contacts/carddav.php/");
+
+ 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);
+
+ settings->writeConfig();
+ agent.reconfigure();
+
+ WId windowId = 0;
+ if (qApp->activeWindow()) {
+ windowId = qApp->activeWindow()->winId();
+ }
+ Wallet *wallet = Wallet::openWallet(Wallet::NetworkWallet(), windowId, Wallet::Synchronous);
+
+ if (!wallet->isOpen() || !wallet->isEnabled()) {
+ setError(-1);
+ emitResult();
+ return;
+ }
+
+ QString password;
+ wallet->setFolder("WebAccounts");
+ wallet->readPassword("owncloud-" + m_config.name(), password);
+
+ QString key (agent.identifier());
+ key.append(",$default$");
+
+ wallet->setFolder(Wallet::PasswordFolder());
+ wallet->writePassword(key, password);
+
+ agent.synchronize();
+
+ 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());
+ kDebug() << 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();
+ instance.synchronize();
+
+ emitResult();
+}
\ No newline at end of file
diff --git a/jobs/ocreatecontact.h b/jobs/ocreatecontact.h
new file mode 100644
index 0000000..f048c14
--- /dev/null
+++ b/jobs/ocreatecontact.h
@@ -0,0 +1,56 @@
+/*************************************************************************************
+ * 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 <QtCore/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
diff --git a/jobs/ocreatefile.cpp b/jobs/ocreatefile.cpp
new file mode 100644
index 0000000..ce421e6
--- /dev/null
+++ b/jobs/ocreatefile.cpp
@@ -0,0 +1,111 @@
+/*************************************************************************************
+ * 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 "ocreatefile.h"
+
+#include <QWidget>
+#include <QApplication>
+
+#include <KGlobal>
+#include <KConfig>
+#include <KDirNotify>
+#include <KStandardDirs>
+#include <KWallet/Wallet>
+#include <KDebug>
+
+using namespace KWallet;
+
+OCreateFile::OCreateFile(KConfigGroup group, QObject* parent)
+ : KJob(parent)
+ , m_config(group)
+{
+
+}
+
+OCreateFile::~OCreateFile()
+{
+
+}
+
+void OCreateFile::start()
+{
+ QMetaObject::invokeMethod(this, "createNetAttach", Qt::QueuedConnection);
+}
+
+void OCreateFile::createNetAttach()
+{
+ KGlobal::dirs()->addResourceType("remote_entries", "data", "remoteview");
+
+ KUrl url(m_config.readEntry("server", ""));
+ url.setUser(m_config.name());
+ url.setScheme("webdav");
+ url.addPath("files/webdav.php/");
+
+ QString path = KGlobal::dirs()->saveLocation("remote_entries");
+ path += m_config.name() + "ownCloud.desktop";
+
+ kDebug() << "Creating knetAttach place";
+ kDebug() << path;
+ kDebug() << url.prettyUrl();
+
+ m_config.group("private").writeEntry("fileDesktop", path);
+
+ KConfig _desktopFile( path, KConfig::SimpleConfig );
+ KConfigGroup desktopFile(&_desktopFile, "Desktop Entry");
+
+ desktopFile.writeEntry("Icon", "owncloud");
+ desktopFile.writeEntry("Name", url.host());
+ desktopFile.writeEntry("Type", "Link");
+ desktopFile.writeEntry("URL", url.prettyUrl());
+ desktopFile.writeEntry("Charset", url.fileEncoding());
+ desktopFile.sync();
+
+ org::kde::KDirNotify::emitFilesAdded( "remote:/" );
+
+ QString walletUrl(url.scheme());
+ walletUrl.append("-");
+ walletUrl.append(m_config.name());
+ walletUrl.append("@");
+ walletUrl.append(url.host());
+ walletUrl.append(":-1");//Overwrite the first option
+
+ WId windowId = 0;
+ if (qApp->activeWindow()) {
+ windowId = qApp->activeWindow()->winId();
+ }
+ Wallet *wallet = Wallet::openWallet(Wallet::NetworkWallet(), windowId, Wallet::Synchronous);
+
+ if (!wallet->isOpen() || !wallet->isEnabled()) {
+ return;
+ }
+
+ QString password;
+ wallet->setFolder("WebAccounts");
+ wallet->readPassword("owncloud-" + m_config.name(), password);
+
+ QMap<QString, QString> info;
+ info["login"] = m_config.name();
+ info["password"] = password;
+
+ wallet->setFolder("Passwords");
+ wallet->writeMap(walletUrl, info);
+ wallet->sync();
+
+ m_config.group("services").writeEntry("File", 1);
+ emitResult();
+}
diff --git a/jobs/ocreatefile.h b/jobs/ocreatefile.h
new file mode 100644
index 0000000..cd911d8
--- /dev/null
+++ b/jobs/ocreatefile.h
@@ -0,0 +1,41 @@
+/*************************************************************************************
+ * 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 OCREATEFILE_H
+#define OCREATEFILE_H
+
+#include <KJob>
+#include <KConfigGroup>
+
+class OCreateFile : public KJob
+{
+ Q_OBJECT
+ public:
+ explicit OCreateFile(KConfigGroup group, QObject* parent = 0);
+ virtual ~OCreateFile();
+
+ virtual void start();
+
+ private Q_SLOTS:
+ void createNetAttach();
+
+ private:
+ KConfigGroup m_config;
+};
+
+#endif //OCREATEFILE_H
\ No newline at end of file
diff --git a/jobs/oremovecalendar.cpp b/jobs/oremovecalendar.cpp
new file mode 100644
index 0000000..4002b66
--- /dev/null
+++ b/jobs/oremovecalendar.cpp
@@ -0,0 +1,89 @@
+/*************************************************************************************
+ * 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 <KDebug>
+
+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);
+ }
+ }
+ kDebug() << "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();
+}
+
diff --git a/jobs/oremovecalendar.h b/jobs/oremovecalendar.h
new file mode 100644
index 0000000..7559dfa
--- /dev/null
+++ b/jobs/oremovecalendar.h
@@ -0,0 +1,46 @@
+/*************************************************************************************
+ * 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
diff --git a/jobs/oremovecontact.cpp b/jobs/oremovecontact.cpp
new file mode 100644
index 0000000..0d68914
--- /dev/null
+++ b/jobs/oremovecontact.cpp
@@ -0,0 +1,89 @@
+/*************************************************************************************
+ * 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 <KDebug>
+
+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);
+ }
+ }
+ kDebug() << "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();
+}
+
diff --git a/jobs/oremovecontact.h b/jobs/oremovecontact.h
new file mode 100644
index 0000000..ec01721
--- /dev/null
+++ b/jobs/oremovecontact.h
@@ -0,0 +1,46 @@
+/*************************************************************************************
+ * 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
diff --git a/jobs/oremovefile.cpp b/jobs/oremovefile.cpp
new file mode 100644
index 0000000..0216fd9
--- /dev/null
+++ b/jobs/oremovefile.cpp
@@ -0,0 +1,49 @@
+/*************************************************************************************
+ * 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 "oremovefile.h"
+
+#include <QFile>
+
+#include <KDirNotify>
+
+ORemoveFile::ORemoveFile(KConfigGroup group, QObject* parent)
+ : KJob(parent)
+ , m_config(group)
+{
+ setObjectName(m_config.name());
+ setProperty("type", QVariant::fromValue(m_config.readEntry("type")));
+}
+
+ORemoveFile::~ORemoveFile()
+{
+
+}
+
+void ORemoveFile::start()
+{
+ QMetaObject::invokeMethod(this, "removeFile", Qt::QueuedConnection);
+}
+
+void ORemoveFile::removeFile()
+{
+ QFile::remove(m_config.group("private").readEntry("fileDesktop"));
+ org::kde::KDirNotify::emitFilesAdded( "remote:/" );
+ m_config.group("services").writeEntry("File", 0);
+ emitResult();
+}
diff --git a/jobs/oremovefile.h b/jobs/oremovefile.h
new file mode 100644
index 0000000..6eec22a
--- /dev/null
+++ b/jobs/oremovefile.h
@@ -0,0 +1,41 @@
+/*************************************************************************************
+ * 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 OREMOVEFILE_H
+#define OREMOVEFILE_H
+
+#include <KJob>
+#include <KConfigGroup>
+
+class ORemoveFile : public KJob
+{
+ Q_OBJECT
+ public:
+ explicit ORemoveFile(KConfigGroup group, QObject* parent = 0);
+ virtual ~ORemoveFile();
+
+ virtual void start();
+
+ private Q_SLOTS:
+ void removeFile();
+
+ private:
+ KConfigGroup m_config;
+};
+
+#endif //OREMOVEFILE_H
\ No newline at end of file
diff --git a/jobs/org.kde.Akonadi.davGroupware.Settings.xml \
b/jobs/org.kde.Akonadi.davGroupware.Settings.xml new file mode 100644
index 0000000..3b0e5c1
--- /dev/null
+++ b/jobs/org.kde.Akonadi.davGroupware.Settings.xml
@@ -0,0 +1,49 @@
+<!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"/>
+ </method>
+ <method name="setRefreshInterval">
+ <arg direction="in" identifier="value" type="i"/>
+ </method>
+ <method name="remoteUrls">
+ <arg direction="out" type="as"/>
+ </method>
+ <method name="setRemoteUrls">
+ <arg direction="in" identifier="value" type="as"/>
+ </method>
+ <method name="defaultUsername">
+ <arg direction="out" type="s"/>
+ </method>
+ <method name="setDefaultUsername">
+ <arg direction="in" identifier="value" type="s"/>
+ </method>
+ <method name="collectionsUrlsMappings">
+ <arg direction="out" type="s"/>
+ </method>
+ <method name="setCollectionsUrlsMappings">
+ <arg direction="in" identifier="value" type="s"/>
+ </method>
+ <method name="readOnly">
+ <arg direction="out" type="b"/>
+ </method>
+ <method name="setReadOnly">
+ <arg direction="in" identifier="value" type="b"/>
+ </method>
+ </interface>
+</node>
\ No newline at end of file
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic