Accounts saving, tree status, sigint catching
This commit is contained in:
parent
d4afdd7a5f
commit
4a4ba47968
11 changed files with 251 additions and 15 deletions
|
@ -40,7 +40,7 @@ void Core::Account::connect()
|
|||
void Core::Account::disconnect()
|
||||
{
|
||||
if (state != Shared::disconnected) {
|
||||
client.disconnect();
|
||||
client.disconnectFromServer();
|
||||
state = Shared::disconnected;
|
||||
emit connectionStateChanged(state);
|
||||
}
|
||||
|
@ -71,4 +71,17 @@ QString Core::Account::getName() const
|
|||
return name;
|
||||
}
|
||||
|
||||
QString Core::Account::getLogin() const
|
||||
{
|
||||
return login;
|
||||
}
|
||||
|
||||
QString Core::Account::getPassword() const
|
||||
{
|
||||
return password;
|
||||
}
|
||||
|
||||
QString Core::Account::getServer() const
|
||||
{
|
||||
return server;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@ public:
|
|||
|
||||
Shared::ConnectionState getState() const;
|
||||
QString getName() const;
|
||||
QString getLogin() const;
|
||||
QString getServer() const;
|
||||
QString getPassword() const;
|
||||
|
||||
signals:
|
||||
void connectionStateChanged(int);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "squawk.h"
|
||||
#include <QDebug>
|
||||
#include <QSettings>
|
||||
|
||||
Core::Squawk::Squawk(QObject* parent):
|
||||
QObject(parent),
|
||||
|
@ -14,12 +15,46 @@ Core::Squawk::~Squawk()
|
|||
Accounts::const_iterator itr = accounts.begin();
|
||||
Accounts::const_iterator end = accounts.end();
|
||||
for (; itr != end; ++itr) {
|
||||
(*itr)->deleteLater();
|
||||
delete (*itr);
|
||||
}
|
||||
}
|
||||
|
||||
void Core::Squawk::stop()
|
||||
{
|
||||
qDebug("Stopping squawk core..");
|
||||
|
||||
QSettings settings;
|
||||
settings.beginGroup("core");
|
||||
settings.beginWriteArray("accounts");
|
||||
for (int i = 0; i < accounts.size(); ++i) {
|
||||
settings.setArrayIndex(i);
|
||||
Account* acc = accounts[i];
|
||||
settings.setValue("name", acc->getName());
|
||||
settings.setValue("server", acc->getServer());
|
||||
settings.setValue("login", acc->getLogin());
|
||||
settings.setValue("password", acc->getPassword());
|
||||
}
|
||||
settings.endArray();
|
||||
settings.endGroup();
|
||||
|
||||
settings.sync();
|
||||
|
||||
emit quit();
|
||||
}
|
||||
|
||||
void Core::Squawk::start()
|
||||
{
|
||||
qDebug("Starting squawk core..");
|
||||
|
||||
QSettings settings;
|
||||
settings.beginGroup("core");
|
||||
int size = settings.beginReadArray("accounts");
|
||||
for (int i = 0; i < size; ++i) {
|
||||
settings.setArrayIndex(i);
|
||||
addAccount(settings.value("login").toString(), settings.value("server").toString(), settings.value("password").toString(), settings.value("name").toString());
|
||||
}
|
||||
settings.endArray();
|
||||
settings.endGroup();
|
||||
}
|
||||
|
||||
void Core::Squawk::newAccountRequest(const QMap<QString, QVariant>& map)
|
||||
|
|
|
@ -22,11 +22,13 @@ public:
|
|||
~Squawk();
|
||||
|
||||
signals:
|
||||
void quit();
|
||||
void newAccount(const QMap<QString, QVariant>&);
|
||||
void accountConnectionStateChanged(const QString&, int);
|
||||
|
||||
public slots:
|
||||
void start();
|
||||
void stop();
|
||||
void newAccountRequest(const QMap<QString, QVariant>& map);
|
||||
void connectAccount(const QString& account);
|
||||
void disconnectAccount(const QString& account);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue