Commit 1cd62af3 authored by Àlex Fiestas's avatar Àlex Fiestas
Browse files

Implement removeOwncloud

parent bb29f2a1
......@@ -34,6 +34,9 @@ set(webaccounts_SRCS
jobs/ocreatefile.cpp
jobs/ocreatecontact.cpp
jobs/ocreatecalendar.cpp
jobs/oremovecalendar.cpp
jobs/oremovecontact.cpp
jobs/oremovefile.cpp
)
qt4_add_dbus_interface(webaccounts_SRCS
......
......@@ -63,6 +63,8 @@ void OCreateFile::createNetAttach()
qDebug() << path;
qDebug() << url.prettyUrl();
m_config.group("private").writeEntry("fileDesktop", path);
KConfig _desktopFile( path, KConfig::SimpleConfig );
KConfigGroup desktopFile(&_desktopFile, "Desktop Entry");
......@@ -95,6 +97,7 @@ void OCreateFile::createNetAttach()
QMap<QString, QString> info;
info["login"] = m_config.name();
info["password"] = "12344321";
wallet->setFolder("Passwords");
wallet->writeMap(walletUrl, info);
wallet->sync();
......
/*************************************************************************************
* 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 "removeakonadiresource.h"
#include "davGroupware_settings.h"
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", 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 "removeakonadiresource.h"
#include "davGroupware_settings.h"
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", 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
/*************************************************************************************
* 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();
}
/*************************************************************************************
* 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
......@@ -37,6 +37,9 @@
#include "jobs/ocreatefile.h"
#include "jobs/ocreatecontact.h"
#include "jobs/ocreatecalendar.h"
#include "jobs/oremovecalendar.h"
#include "jobs/oremovecontact.h"
#include "jobs/oremovefile.h"
#include <QDebug>
......@@ -137,6 +140,8 @@ void WebAccounts::rmBtnClicked()
removeGoogleAccount(group);
} else if(type == "facebook") {
removeFacebookACcount(group);
} else if(type == "owncloud") {
removeOwncloudAccount(group);
}
removeAccountIfPossible(accName, type);
......@@ -366,6 +371,29 @@ void WebAccounts::createOwncloudAccount(KConfigGroup group)
}
}
void WebAccounts::removeOwncloudAccount(KConfigGroup group)
{
KConfigGroup services = group.group("services");
if (services.readEntry("Calendar", 0) == 1) {
ORemoveCalendar *removeCalendar = new ORemoveCalendar(group, this);
connect(removeCalendar, SIGNAL(finished(KJob*)), this, SLOT(serviceRemoved(KJob*)));
removeCalendar->start();
}
if (services.readEntry("Contact", 0) == 1) {
ORemoveContact *removeContact = new ORemoveContact(group, this);
connect(removeContact, SIGNAL(finished(KJob*)), this, SLOT(serviceRemoved(KJob*)));
removeContact->start();
}
if (services.readEntry("File", 0) == 1) {
ORemoveFile *removeFile = new ORemoveFile(group, this);
connect(removeFile, SIGNAL(finished(KJob*)), this, SLOT(serviceRemoved(KJob*)));
removeFile->start();
}
}
void WebAccounts::createOCalendar(KJob* job)
{
qDebug() << "Creating oCalendar";
......
......@@ -62,6 +62,7 @@ private:
void removeFacebookACcount(KConfigGroup group);
void createOwncloudAccount(KConfigGroup group);
void removeOwncloudAccount(KConfigGroup group);
private:
Create *m_create;
......
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