1
0
forked from blue/squawk
squawk/core/squawk.h

87 lines
3.7 KiB
C
Raw Normal View History

2019-03-29 14:54:34 +00:00
#ifndef CORE_SQUAWK_H
#define CORE_SQUAWK_H
#include <QtCore/QObject>
2019-03-30 20:13:13 +00:00
#include <QString>
#include <QVariant>
#include <QMap>
2019-03-29 14:54:34 +00:00
#include <deque>
#include <deque>
2019-03-29 14:54:34 +00:00
#include "account.h"
#include "../global.h"
2019-03-29 14:54:34 +00:00
namespace Core
{
class Squawk : public QObject
{
Q_OBJECT
public:
Squawk(QObject* parent = 0);
~Squawk();
2019-03-30 20:13:13 +00:00
signals:
void quit();
2019-03-30 20:13:13 +00:00
void newAccount(const QMap<QString, QVariant>&);
void changeAccount(const QString& account, const QMap<QString, QVariant>& data);
2019-05-29 15:05:54 +00:00
void removeAccount(const QString& account);
2019-04-03 21:23:51 +00:00
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);
2019-04-06 10:14:32 +00:00
void removeContact(const QString& account, const QString& jid);
void removeContact(const QString& account, const QString& jid, const QString& group);
void changeContact(const QString& account, const QString& jid, const QMap<QString, QVariant>& data);
2019-04-07 14:02:41 +00:00
void addPresence(const QString& account, const QString& jid, const QString& name, const QMap<QString, QVariant>& data);
void removePresence(const QString& account, const QString& jid, const QString& name);
void stateChanged(int state);
void accountMessage(const QString& account, const Shared::Message& data);
void responseArchive(const QString& account, const QString& jid, const std::list<Shared::Message>& list);
2019-03-30 20:13:13 +00:00
public slots:
void start();
void stop();
2019-03-30 20:13:13 +00:00
void newAccountRequest(const QMap<QString, QVariant>& map);
void modifyAccountRequest(const QString& name, const QMap<QString, QVariant>& map);
2019-05-29 15:05:54 +00:00
void removeAccountRequest(const QString& name);
void connectAccount(const QString& account);
void disconnectAccount(const QString& account);
void changeState(int state);
void sendMessage(const QString& account, const Shared::Message& data);
void requestArchive(const QString& account, const QString& jid, int count, const QString& before);
void subscribeContact(const QString& account, const QString& jid, const QString& reason);
void unsubscribeContact(const QString& account, const QString& jid, const QString& reason);
2019-06-14 16:36:04 +00:00
void removeContactRequest(const QString& account, const QString& jid);
void addContactRequest(const QString& account, const QString& jid, const QString& name, const QSet<QString>& groups);
2019-03-30 20:13:13 +00:00
2019-03-29 14:54:34 +00:00
private:
2019-03-30 20:13:13 +00:00
typedef std::deque<Account*> Accounts;
typedef std::map<QString, Account*> AccountsMap;
2019-03-29 14:54:34 +00:00
Accounts accounts;
AccountsMap amap;
Shared::Availability state;
2019-03-30 20:13:13 +00:00
private:
void addAccount(const QString& login, const QString& server, const QString& password, const QString& name, const QString& resource);
private slots:
void onAccountConnectionStateChanged(int state);
void onAccountAvailabilityChanged(int state);
2019-04-03 21:23:51 +00:00
void onAccountAddGroup(const QString& name);
void onAccountError(const QString& text);
2019-04-03 21:23:51 +00:00
void onAccountRemoveGroup(const QString& name);
void onAccountAddContact(const QString& jid, const QString& group, const QMap<QString, QVariant>& data);
2019-04-06 10:14:32 +00:00
void onAccountRemoveContact(const QString& jid);
void onAccountRemoveContact(const QString& jid, const QString& group);
void onAccountChangeContact(const QString& jid, const QMap<QString, QVariant>& data);
2019-04-07 14:02:41 +00:00
void onAccountAddPresence(const QString& jid, const QString& name, const QMap<QString, QVariant>& data);
void onAccountRemovePresence(const QString& jid, const QString& name);
void onAccountMessage(const Shared::Message& data);
void onAccountResponseArchive(const QString& jid, const std::list<Shared::Message>& list);
2019-03-29 14:54:34 +00:00
};
}
#endif // CORE_SQUAWK_H