forked from blue/squawk
first attempt to remove accounts
This commit is contained in:
parent
8432a574b9
commit
234697050b
14 changed files with 190 additions and 14 deletions
|
@ -738,4 +738,3 @@ void Core::Account::onClientError(QXmppClient::Error err)
|
|||
qDebug() << errorType << errorText;
|
||||
emit error(errorText);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "squawk.h"
|
||||
#include <QDebug>
|
||||
#include <QSettings>
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
|
||||
Core::Squawk::Squawk(QObject* parent):
|
||||
QObject(parent),
|
||||
|
@ -298,3 +300,31 @@ void Core::Squawk::onAccountError(const QString& text)
|
|||
Account* acc = static_cast<Account*>(sender());
|
||||
emit changeAccount(acc->getName(), {{"error", text}});
|
||||
}
|
||||
|
||||
void Core::Squawk::removeAccountRequest(const QString& name)
|
||||
{
|
||||
AccountsMap::const_iterator itr = amap.find(name);
|
||||
if (itr == amap.end()) {
|
||||
qDebug() << "An attempt to remove non existing account " << name << " from core, skipping";
|
||||
return;
|
||||
}
|
||||
|
||||
Account* acc = itr->second;
|
||||
|
||||
for (Accounts::const_iterator aItr = accounts.begin(); aItr != accounts.end(); ++aItr) {
|
||||
if (*aItr == acc) {
|
||||
accounts.erase(aItr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
amap.erase(itr);
|
||||
delete acc;
|
||||
|
||||
QString path(QStandardPaths::writableLocation(QStandardPaths::CacheLocation));
|
||||
path += "/" + name;
|
||||
QDir dir(path);
|
||||
dir.removeRecursively();
|
||||
|
||||
emit removeAccount(name);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ signals:
|
|||
void quit();
|
||||
void newAccount(const QMap<QString, QVariant>&);
|
||||
void changeAccount(const QString& account, const QMap<QString, QVariant>& data);
|
||||
void removeAccount(const QString& account);
|
||||
void addGroup(const QString& account, const QString& name);
|
||||
void removeGroup(const QString& account, const QString& name);
|
||||
void addContact(const QString& account, const QString& jid, const QString& group, const QMap<QString, QVariant>& data);
|
||||
|
@ -42,6 +43,7 @@ public slots:
|
|||
void stop();
|
||||
void newAccountRequest(const QMap<QString, QVariant>& map);
|
||||
void modifyAccountRequest(const QString& name, const QMap<QString, QVariant>& map);
|
||||
void removeAccountRequest(const QString& name);
|
||||
void connectAccount(const QString& account);
|
||||
void disconnectAccount(const QString& account);
|
||||
void changeState(int state);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue