Commit 318b3bea authored by Àlex Fiestas's avatar Àlex Fiestas
Browse files

Restore removeNetAttachJob and make it kinda work (have not tested yet)

parent b5c96b53
......@@ -18,6 +18,7 @@ set(accounts_daemon_SRCS
akonadi/jobs/removeakonadiservicesjob.cpp
kio/createnetattachjob.cpp
kio/removenetattachjob.cpp
)
kde4_add_plugin(kded_accounts
......
......@@ -18,32 +18,83 @@
#include "removenetattachjob.h"
#include <QFile>
#include <QtCore/QFile>
#include <QtGui/QWidget>
#include <QtGui/QApplication>
#include <KDebug>
#include <KGlobal>
#include <KStandardDirs>
#include <KWallet/Wallet>
#include <KDirNotify>
RemoveNetAttachJob::ORemoveFile(KConfigGroup group, QObject* parent)
using namespace KWallet;
RemoveNetAttachJob::RemoveNetAttachJob(QObject* parent)
: KJob(parent)
, m_config(group)
, m_wallet(0)
{
setObjectName(m_config.name());
setProperty("type", QVariant::fromValue(m_config.readEntry("type")));
}
RemoveNetAttachJob::~ORemoveFile()
RemoveNetAttachJob::~RemoveNetAttachJob()
{
delete m_wallet;
}
void RemoveNetAttachJob::start()
{
QMetaObject::invokeMethod(this, "removeFile", Qt::QueuedConnection);
QMetaObject::invokeMethod(this, "remoteNetAttach", Qt::QueuedConnection);
}
void RemoveNetAttachJob::removeNetAttach()
{
WId windowId = 0;
if (qApp->activeWindow()) {
windowId = qApp->activeWindow()->winId();
}
m_wallet = Wallet::openWallet(Wallet::NetworkWallet(), windowId, Wallet::Asynchronous);
connect(m_wallet, SIGNAL(walletOpened(bool)), SLOT(walletOpened(bool)));
}
void RemoveNetAttachJob::walletOpened(bool opened)
{
kDebug();
if (!opened) {
setError(-1);
setErrorText("Can't open wallet");
emitResult();
return;
}
deleteDesktopFile();
}
void RemoveNetAttachJob::removeFile()
void RemoveNetAttachJob::deleteDesktopFile()
{
QFile::remove(m_config.group("private").readEntry("fileDesktop"));
KGlobal::dirs()->addResourceType("remote_entries", "data", "remoteview");
QString destPath = KGlobal::dirs()->saveLocation("remote_entries");
destPath.append(m_username + "_" + m_host + ".desktop");
QFile::remove(destPath);
org::kde::KDirNotify::emitFilesAdded( "remote:/" );
m_config.group("services").writeEntry("File", 0);
emitResult();
}
QString RemoveNetAttachJob::host() const
{
return m_host;
}
void RemoveNetAttachJob::setHost(const QString &host)
{
m_host = host;
}
QString RemoveNetAttachJob::username() const
{
return m_username;
}
void RemoveNetAttachJob::setUsername(const QString &username)
{
m_username = username;
}
\ No newline at end of file
......@@ -22,20 +22,34 @@
#include <KJob>
#include <KConfigGroup>
namespace KWallet {
class Wallet;
};
class RemoveNetAttachJob : public KJob
{
Q_OBJECT
public:
explicit RemoveNetAttachJob(KConfigGroup group, QObject* parent = 0);
explicit RemoveNetAttachJob(QObject *parent);
virtual ~RemoveNetAttachJob();
virtual void start();
QString host() const;
void setHost(const QString &host);
QString username() const;
void setUsername(const QString &username);
private Q_SLOTS:
void removeFile();
void removeNetAttach();
void walletOpened(bool opened);
void deleteDesktopFile();
private:
KConfigGroup m_config;
QString m_host;
QString m_username;
KWallet::Wallet *m_wallet;
};
#endif //OREMOVEFILE_H
\ No newline at end of file
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