Commit b43af0fa authored by Àlex Fiestas's avatar Àlex Fiestas
Browse files

Reintroduce uniqueId in netattach jobs

We need a way of specifing only with accountId which desktop file is, so
we end up with one desktop file per account
parent 376291ef
......@@ -85,7 +85,7 @@ void CreateNetAttachJob::createDesktopFile()
url.addPath("files/webdav.php/");
QString path = KGlobal::dirs()->saveLocation("remote_entries");
path += m_username + "_" + m_host + ".desktop";
path += m_uniqueId + ".desktop";
qDebug() << "Creating knetAttach place";
qDebug() << path;
......@@ -151,6 +151,16 @@ void CreateNetAttachJob::setPassword(const QString &password)
m_password = password;
}
QString CreateNetAttachJob::uniqueId() const
{
return m_uniqueId;
}
void CreateNetAttachJob::setUniqueId(const QString& uniqueId)
{
m_uniqueId = uniqueId;
}
QString CreateNetAttachJob::icon() const
{
return m_icon;
......
......@@ -43,6 +43,9 @@ class CreateNetAttachJob : public KJob
QString password() const;
void setPassword(const QString &password);
QString uniqueId() const;
void setUniqueId(const QString &uniqueId);
QString icon() const;
void setIcon(const QString &icon);
......
......@@ -72,7 +72,7 @@ void RemoveNetAttachJob::deleteDesktopFile()
{
KGlobal::dirs()->addResourceType("remote_entries", "data", "remoteview");
QString destPath = KGlobal::dirs()->saveLocation("remote_entries");
destPath.append(m_username + "_" + m_host + ".desktop");
destPath.append(m_uniqueId + ".desktop");
QFile::remove(destPath);
org::kde::KDirNotify::emitFilesAdded( "remote:/" );
......@@ -107,4 +107,14 @@ QString RemoveNetAttachJob::username() const
void RemoveNetAttachJob::setUsername(const QString &username)
{
m_username = username;
}
QString RemoveNetAttachJob::uniqueId() const
{
return m_uniqueId;
}
void RemoveNetAttachJob::setUniqueId(const QString& uniqueId)
{
m_uniqueId = uniqueId;
}
\ No newline at end of file
......@@ -40,6 +40,9 @@ class RemoveNetAttachJob : public KJob
QString username() const;
void setUsername(const QString &username);
QString uniqueId() const;
void setUniqueId(const QString &uniqueId);
private Q_SLOTS:
void removeNetAttach();
void walletOpened(bool opened);
......@@ -48,6 +51,7 @@ class RemoveNetAttachJob : public KJob
private:
QString m_host;
QString m_username;
QString m_uniqueId;
KWallet::Wallet *m_wallet;
};
......
......@@ -41,13 +41,14 @@ void testCreateNetAttachJob::testCreate()
{
KGlobal::dirs()->addResourceType("remote_entries", "data", "remoteview");
QString destPath = KGlobal::dirs()->saveLocation("remote_entries");
destPath.append("username_host.com.desktop");
destPath.append("test-unique-id.desktop");
CreateNetAttachJob *job = new CreateNetAttachJob(this);
job->setHost("host.com");
job->setUsername("username");
job->setPassword("password");
job->setIcon("modem");
job->setUniqueId("test-unique-id");
job->exec();
Wallet *wallet = Wallet::openWallet(Wallet::NetworkWallet(), 0, Wallet::Synchronous);
......
......@@ -47,7 +47,7 @@ testRemoveNetAttachJob::testRemoveNetAttachJob(QObject* parent) : QObject(parent
{
KGlobal::dirs()->addResourceType("remote_entries", "data", "remoteview");
QString destPath = KGlobal::dirs()->saveLocation("remote_entries");
destPath.append("username_host.com.desktop");
destPath.append("test-unique-id.desktop");
QFile file(destPath);
file.open(QIODevice::WriteOnly);
......@@ -67,11 +67,12 @@ void testRemoveNetAttachJob::testRemove()
{
KGlobal::dirs()->addResourceType("remote_entries", "data", "remoteview");
QString destPath = KGlobal::dirs()->saveLocation("remote_entries");
destPath.append("username_host.com.desktop");
destPath.append("test-unique-id.desktop");
RemoveNetAttachJob *job = new RemoveNetAttachJob(this);
job->setHost("host.com");
job->setUsername("username");
job->setUniqueId("test-unique-id");
job->exec();
QVERIFY2(!QFile::exists(destPath), "Desktop file has not been deleted");
......
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