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
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue